-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TreeSelect to storybook (#28666)
### Parent Issue #28494 ### Proposed Changes Add Support to TreeSelect Component to StoryBook. ### Additional Info This component is based on based [TreeSelect](https://www.primefaces.org/primeng-v15-lts/treeselect) Component by PrimeNG. ### Screenshots | | | |--------|--------| | Basic | Invalid | | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (1)](https://github.com/dotCMS/core/assets/7611944/1f70b3d4-7443-4e3f-8fc1-9f79e7ee8896) | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (2)](https://github.com/dotCMS/core/assets/7611944/e782779d-a4be-478d-b124-46fe5c5e0e58) | | With Label | With float label | | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (3)](https://github.com/dotCMS/core/assets/7611944/cd223b8e-d740-4121-bc14-cb1e352dfc84) | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (5)](https://github.com/dotCMS/core/assets/7611944/be3b04a0-a60b-47ca-b411-d35b54e02254) | | Disabled | Multiple Choice | | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (6)](https://github.com/dotCMS/core/assets/7611944/12837c61-fad0-458e-843f-17019a9137b2) | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (7)](https://github.com/dotCMS/core/assets/7611944/ccab3f9c-2acd-4734-b271-d8a1c54e7af7) | | Checkboxes | Search | | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (8)](https://github.com/dotCMS/core/assets/7611944/c13bb166-3083-4058-bb2f-638382dc080a) | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (9)](https://github.com/dotCMS/core/assets/7611944/bb020f69-5e38-477f-b80f-cb570404c9ec) | | Not found | | | ![localhost_4400__path=_story_primeng-form-treeselect--default globals=backgrounds value_!hex(F8F8F8);backgrounds grid_!false (10)](https://github.com/dotCMS/core/assets/7611944/173b9b3e-ee69-4a1d-aa1e-7193addb5773) | |
- Loading branch information
Showing
10 changed files
with
450 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 23 additions & 36 deletions
59
core-web/apps/dotcms-ui/src/stories/primeng/form/Chips.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,41 @@ | ||
import { Meta, moduleMetadata, Story } from '@storybook/angular'; | ||
import { Meta, StoryObj } from '@storybook/angular'; | ||
|
||
import { FormsModule } from '@angular/forms'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { Chips, ChipsModule } from 'primeng/chips'; | ||
|
||
export default { | ||
const meta: Meta = { | ||
title: 'PrimeNG/Form/Chips', | ||
component: Chips, | ||
parameters: { | ||
docs: { | ||
description: { | ||
component: | ||
'Chips is used to enter multiple values on an input field: https://primeng.org/checkbox' | ||
'Chips is used to enter multiple values on an input field: https://primeng.org/chips' | ||
} | ||
} | ||
}, | ||
decorators: [ | ||
moduleMetadata({ | ||
imports: [ChipsModule, BrowserAnimationsModule] | ||
}) | ||
], | ||
argTypes: { | ||
values: { | ||
name: 'values', | ||
description: 'Array of strings, each representing a chip.' | ||
} | ||
}, | ||
args: { | ||
values: ['first'] | ||
} | ||
} as Meta; | ||
|
||
const ChipsTemplate = `<p-chips [(ngModel)]="values" ></p-chips>`; | ||
|
||
const Template: Story<Chips> = (props: Chips) => { | ||
const template = ChipsTemplate; | ||
|
||
return { | ||
props, | ||
template | ||
}; | ||
}; | ||
|
||
export const Basic: Story = Template.bind({}); | ||
|
||
Basic.argTypes = { | ||
values: { | ||
name: 'values', | ||
description: 'Array of strings, each representing a chip.' | ||
values: ['one', 'two'] | ||
} | ||
}; | ||
|
||
Basic.parameters = { | ||
docs: { | ||
source: { | ||
code: ChipsTemplate | ||
} | ||
} | ||
export default meta; | ||
|
||
type Story = StoryObj<Chips>; | ||
|
||
export const Default: Story = { | ||
render: (args) => ({ | ||
props: args, | ||
moduleMetadata: { | ||
imports: [ChipsModule, BrowserAnimationsModule, FormsModule] | ||
}, | ||
template: `<p-chips [(ngModel)]="values" />` | ||
}) | ||
}; |
231 changes: 231 additions & 0 deletions
231
core-web/apps/dotcms-ui/src/stories/primeng/form/TreeSelect.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,231 @@ | ||
import { Meta, StoryObj } from '@storybook/angular'; | ||
|
||
import { FormsModule } from '@angular/forms'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { TreeSelectModule, TreeSelect } from 'primeng/treeselect'; | ||
|
||
import { files } from './../data/Tree.stories'; | ||
|
||
const meta: Meta<TreeSelect> = { | ||
title: 'PrimeNG/Form/TreeSelect', | ||
component: TreeSelect, | ||
parameters: { | ||
layout: 'centered', | ||
docs: { | ||
description: { | ||
component: | ||
'TreeSelect is a form component to choose from hierarchical data.: https://www.primefaces.org/primeng-v15-lts/treeselect' | ||
} | ||
} | ||
} | ||
}; | ||
export default meta; | ||
|
||
type Story = StoryObj<TreeSelect>; | ||
|
||
const storyConfigBase: Partial<Story['render']> = { | ||
moduleMetadata: { | ||
imports: [TreeSelectModule, FormsModule, BrowserAnimationsModule, BrowserModule] | ||
}, | ||
props: { | ||
files, | ||
selectedNodes: '' | ||
} | ||
}; | ||
|
||
export const Default: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
[(ngModel)]="selectedNodes" | ||
class="md:w-20rem w-full" containerStyleClass="w-full" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const Invalid: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
class="md:w-20rem w-full ng-invalid ng-dirty" | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const WithLabel: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<span class="md:w-20rem w-full"> | ||
<label for="treeselect">Label</label> | ||
<p-treeSelect | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</span> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const WithFloatLabel: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<div class="md:w-20rem w-full"> | ||
<span class="p-float-label w-full"> | ||
<p-treeSelect | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
<label for="treeselect">Float Label</label> | ||
</span> | ||
</div> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const Disable: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
[disabled]="true" | ||
[(ngModel)]="selectedNodes" | ||
class="md:w-20rem w-full" containerStyleClass="w-full" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const Multiple: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
class="w-full md:w-20rem" | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
[metaKeySelection]="false" | ||
selectionMode="multiple" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const Checkbox: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
class="w-full md:w-20rem" | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
[showClear]="true" | ||
display="chip" | ||
[metaKeySelection]="false" | ||
selectionMode="checkbox" | ||
placeholder="Select Item" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; | ||
|
||
export const Filter: Story = { | ||
render: () => ({ | ||
...storyConfigBase, | ||
template: ` | ||
<div class="card flex justify-content-center w-25rem h-25rem"> | ||
<p-treeSelect | ||
class="md:w-20rem w-full" | ||
containerStyleClass="w-full" | ||
[(ngModel)]="selectedNodes" | ||
[options]="files" | ||
placeholder="Select Item" | ||
[filter]="true" | ||
[filterInputAutoFocus]="true" | ||
[showClear]="true" | ||
> | ||
<ng-template pTemplate="triggericon"> | ||
<i class="pi pi-chevron-down"></i> | ||
</ng-template> | ||
<ng-template pTemplate="filtericon"> | ||
<i class="pi pi-search"></i> | ||
</ng-template> | ||
<ng-template pTemplate="closeicon"> | ||
<i class="pi pi-times"></i> | ||
</ng-template> | ||
</p-treeSelect> | ||
</div> | ||
` | ||
}) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.