|
1 | 1 | import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks'; |
2 | 2 | import { Input } from '@ui5/webcomponents-react/lib/Input'; |
| 3 | +import { ListItemTypes } from '@ui5/webcomponents-react/lib/ListItemTypes'; |
3 | 4 | import { InputType } from '@ui5/webcomponents-react/lib/InputType'; |
4 | 5 | import { ValueState } from '@ui5/webcomponents-react/lib/ValueState'; |
5 | 6 | import '@ui5/webcomponents-icons/dist/icons/employee.js'; |
| 7 | +import '@ui5/webcomponents-icons/dist/icons/globe.js'; |
6 | 8 | import { Icon } from '@ui5/webcomponents-react/lib/Icon'; |
7 | | -import { CSSProperties } from 'react'; |
8 | 9 | import { SuggestionItem } from '@ui5/webcomponents-react/lib/SuggestionItem'; |
9 | 10 | import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes'; |
10 | 11 | import { DocsHeader } from '@shared/stories/DocsHeader'; |
11 | 12 | import { DocsCommonProps } from '@shared/stories/DocsCommonProps'; |
| 13 | +import '@ui5/webcomponents/dist/features/InputSuggestions.js'; |
12 | 14 |
|
13 | 15 | <Meta |
14 | 16 | title="UI5 Web Components / Input" |
@@ -44,3 +46,88 @@ import { DocsCommonProps } from '@shared/stories/DocsCommonProps'; |
44 | 46 | </Canvas> |
45 | 47 |
|
46 | 48 | <ArgsTable story="." /> |
| 49 | + |
| 50 | +<br /> |
| 51 | + |
| 52 | +# Stories |
| 53 | + |
| 54 | +<br /> |
| 55 | + |
| 56 | +## Input with customizable SuggestionItem |
| 57 | + |
| 58 | +The `SuggestionItem` represents the suggestion item of the `Input` |
| 59 | + |
| 60 | +**Note:** `SuggestionItems` will only be displayed if the required module has been imported (`import '@ui5/webcomponents/dist/features/InputSuggestions.js';`) |
| 61 | +and the `showSuggestions` prop is set to `true`. |
| 62 | + |
| 63 | +<Canvas> |
| 64 | + <Story |
| 65 | + name="with SuggestionItem" |
| 66 | + args={{ |
| 67 | + description: 'description', |
| 68 | + group: false, |
| 69 | + icon: 'globe', |
| 70 | + iconEnd: false, |
| 71 | + image: '', |
| 72 | + info: 'info', |
| 73 | + infoState: ValueState.None, |
| 74 | + text: 'Customizable SuggestionItem', |
| 75 | + type: ListItemTypes.Active |
| 76 | + }} |
| 77 | + argTypes={{ |
| 78 | + description: { description: `Defines the description displayed right under the item text, if such is present.` }, |
| 79 | + group: { |
| 80 | + description: `Defines the item to be displayed as a group item. <br><br> <b>Note:</b> When set, the other properties, such as <code>image</code>, <code>icon</code>, <code>description</code>, etc. will be omitted and only the <code>text</code> will be displayed.` |
| 81 | + }, |
| 82 | + icon: { |
| 83 | + description: `Defines the <code>icon</code> source URI. <br><br> <b>Note:</b> SAP-icons font provides numerous buil-in icons. To find all the available icons, see the <ui5-link target="_blank" href="https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/iconExplorer/webapp/index.html" class="api-table-content-cell-link">Icon Explorer</ui5-link>.` |
| 84 | + }, |
| 85 | + iconEnd: { |
| 86 | + description: `Defines whether the <code>icon</code> should be displayed in the beginning of the item or in the end. <br><br> <b>Note:</b> If <code>image</code> is set, the <code>icon</code> would be displayed after the <code>image</code>.` |
| 87 | + }, |
| 88 | + image: { |
| 89 | + description: `Defines the <code>image</code> source URI. <br><br> <b>Note:</b> The <code>image</code> would be displayed in the beginning of the item.` |
| 90 | + }, |
| 91 | + info: { description: `Defines the <code>info</code>, displayed in the end of the item.` }, |
| 92 | + infoState: { |
| 93 | + description: `Defines the state of the <code>info</code>. <br><br> Available options are: <code>"None"</code> (by default), <code>"Success"</code>, <code>"Warning"</code> and <code>"Erorr"</code>.` |
| 94 | + }, |
| 95 | + text: { description: `Defines the text of the <code>SuggestionItem</code>.` }, |
| 96 | + type: { |
| 97 | + control: { options: ['Inactive', 'Active', 'Detail'] }, |
| 98 | + description: `Defines the visual indication and behavior of the item. Available options are <code>Active</code> (by default), <code>Inactive</code> and <code>Detail</code>. <br><br> <b>Note:</b> When set to <code>Active</code>, the item will provide visual response upon press and hover, while when <code>Inactive</code> or <code>Detail</code> - will not.` |
| 99 | + }, |
| 100 | + disabled: { table: { disable: true } }, |
| 101 | + highlight: { table: { disable: true } }, |
| 102 | + maxlength: { table: { disable: true } }, |
| 103 | + name: { table: { disable: true } }, |
| 104 | + placeholder: { table: { disable: true } }, |
| 105 | + readonly: { table: { disable: true } }, |
| 106 | + required: { table: { disable: true } }, |
| 107 | + showSuggestions: { table: { disable: true } }, |
| 108 | + value: { table: { disable: true } }, |
| 109 | + valueState: { table: { disable: true } }, |
| 110 | + children: { table: { disable: true } }, |
| 111 | + valueStateMessage: { table: { disable: true } }, |
| 112 | + onChange: { table: { disable: true } }, |
| 113 | + onInput: { table: { disable: true } }, |
| 114 | + onSubmit: { table: { disable: true } }, |
| 115 | + onSuggestionItemPreview: { table: { disable: true } }, |
| 116 | + onSuggestionItemSelect: { table: { disable: true } }, |
| 117 | + onSuggestionScroll: { table: { disable: true } } |
| 118 | + }} |
| 119 | + > |
| 120 | + {(args) => { |
| 121 | + return ( |
| 122 | + <Input showSuggestions placeholder="click here to show suggestions" style={{ width: '400px' }}> |
| 123 | + <SuggestionItem {...args} /> |
| 124 | + <SuggestionItem icon="globe" text="Argentina" /> |
| 125 | + <SuggestionItem icon="globe" text="Iceland" /> |
| 126 | + <SuggestionItem icon="globe" text="Moldova" /> |
| 127 | + </Input> |
| 128 | + ); |
| 129 | + }} |
| 130 | + </Story> |
| 131 | +</Canvas> |
| 132 | + |
| 133 | +<ArgsTable story="with SuggestionItem" /> |
0 commit comments