|
| 1 | +import { hbs } from 'ember-cli-htmlbars'; |
| 2 | +import { action } from '@storybook/addon-actions'; |
| 3 | + |
| 4 | +const ResizeTypes = ['horizontal', 'vertical', 'none', null]; |
| 5 | + |
| 6 | +export default { |
| 7 | + title: 'Components/OSS::Smart::TextArea', |
| 8 | + component: 'smart text-area', |
| 9 | + argTypes: { |
| 10 | + value: { |
| 11 | + description: 'Value of the textarea', |
| 12 | + table: { |
| 13 | + type: { |
| 14 | + summary: 'string' |
| 15 | + }, |
| 16 | + defaultValue: { summary: 'undefined' } |
| 17 | + }, |
| 18 | + control: { type: 'text' } |
| 19 | + }, |
| 20 | + rows: { |
| 21 | + description: 'Number of rows dispayed in the textarea', |
| 22 | + table: { |
| 23 | + type: { |
| 24 | + summary: 'number' |
| 25 | + }, |
| 26 | + defaultValue: { summary: 2 } |
| 27 | + }, |
| 28 | + control: { type: 'number' } |
| 29 | + }, |
| 30 | + resize: { |
| 31 | + description: 'Define direction in which textarea can be resized (By default the resize is set to Both)', |
| 32 | + table: { |
| 33 | + type: { |
| 34 | + summary: ResizeTypes.join('|') |
| 35 | + }, |
| 36 | + defaultValue: { summary: 'both' } |
| 37 | + }, |
| 38 | + options: ResizeTypes, |
| 39 | + control: { type: 'select' } |
| 40 | + }, |
| 41 | + disabled: { |
| 42 | + description: 'Disable the default textarea', |
| 43 | + table: { |
| 44 | + type: { |
| 45 | + summary: 'boolean' |
| 46 | + }, |
| 47 | + defaultValue: { summary: false } |
| 48 | + }, |
| 49 | + control: { type: 'boolean' } |
| 50 | + }, |
| 51 | + placeholder: { |
| 52 | + description: 'Placeholder of the textarea', |
| 53 | + table: { |
| 54 | + type: { |
| 55 | + summary: 'string' |
| 56 | + }, |
| 57 | + defaultValue: { summary: 'undefined' } |
| 58 | + }, |
| 59 | + control: { type: 'text' } |
| 60 | + }, |
| 61 | + loading: { |
| 62 | + description: 'Indicates if the textarea is in a loading state', |
| 63 | + table: { |
| 64 | + type: { |
| 65 | + summary: 'boolean' |
| 66 | + }, |
| 67 | + defaultValue: { summary: false } |
| 68 | + }, |
| 69 | + control: { type: 'boolean' } |
| 70 | + }, |
| 71 | + hasError: { |
| 72 | + description: 'Indicates if the textarea has an error', |
| 73 | + table: { |
| 74 | + type: { |
| 75 | + summary: 'boolean' |
| 76 | + }, |
| 77 | + defaultValue: { summary: false } |
| 78 | + }, |
| 79 | + control: { type: 'boolean' } |
| 80 | + }, |
| 81 | + onChange: { |
| 82 | + description: 'Method called every time the textarea is updated', |
| 83 | + table: { |
| 84 | + category: 'Actions', |
| 85 | + type: { |
| 86 | + summary: 'onChange(value: string): void' |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + }, |
| 91 | + parameters: { |
| 92 | + docs: { |
| 93 | + description: { |
| 94 | + component: 'The OSS version of the textarea component.' |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +}; |
| 99 | + |
| 100 | +const defaultArgs = { |
| 101 | + value: 'John', |
| 102 | + rows: 2, |
| 103 | + resize: null, |
| 104 | + disabled: false, |
| 105 | + placeholder: 'this is the placeholder', |
| 106 | + hasError: false, |
| 107 | + loading: false, |
| 108 | + onChange: action('onChange') |
| 109 | +}; |
| 110 | + |
| 111 | +const DefaultUsageTemplate = (args) => ({ |
| 112 | + template: hbs` |
| 113 | + <OSS::Smart::TextArea @value={{this.value}} @disabled={{this.disabled}} @placeholder={{this.placeholder}} |
| 114 | + @hasError={{this.hasError}} @onChange={{this.onChange}} @rows={{this.rows}} |
| 115 | + @resize={{this.resize}} @loading={{this.loading}}/> |
| 116 | + `, |
| 117 | + context: args |
| 118 | +}); |
| 119 | + |
| 120 | +export const BasicUsage = DefaultUsageTemplate.bind({}); |
| 121 | +BasicUsage.args = defaultArgs; |
0 commit comments