@appdirect/design-system 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/README.md +85 -5
  2. package/dist/Buttons/ActionIcon.js +14 -0
  3. package/dist/Buttons/Button.js +66 -0
  4. package/dist/Buttons/CloseButton.js +48 -0
  5. package/dist/Buttons/index.js +13 -0
  6. package/dist/Combobox/AutocompleteClearable.js +36 -0
  7. package/dist/Combobox/Combobox.js +28 -0
  8. package/dist/Combobox/Multiselect.js +31 -0
  9. package/dist/Combobox/SearchableSelect.js +43 -0
  10. package/dist/Combobox/Select.js +72 -0
  11. package/dist/Combobox/index.js +10 -0
  12. package/dist/ComplexComponents/DashboardWidget/DashboardWidget.js +96 -0
  13. package/dist/ComplexComponents/DashboardWidget/index.js +1 -0
  14. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/index.js +82 -0
  15. package/dist/ComplexComponents/DataTable/CustomBottomToolbar/utils.js +23 -0
  16. package/dist/ComplexComponents/DataTable/CustomToolbarAlertBannerContent/index.js +23 -0
  17. package/dist/ComplexComponents/DataTable/CustomTopToolbar/DateRangeSelectorFilter/index.js +230 -0
  18. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterChip.js +30 -0
  19. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/DateRangeFilter.js +12 -0
  20. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterRenderer.js +32 -0
  21. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/FilterSystem.js +90 -0
  22. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/MultiSelectFilter.js +43 -0
  23. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/SingleSelectFilter.js +30 -0
  24. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/index.js +39 -0
  25. package/dist/ComplexComponents/DataTable/CustomTopToolbar/FilterSystem/types.js +9 -0
  26. package/dist/ComplexComponents/DataTable/CustomTopToolbar/ResultCount/index.js +31 -0
  27. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SearchFilter.js +42 -0
  28. package/dist/ComplexComponents/DataTable/CustomTopToolbar/SelectFilter.js +21 -0
  29. package/dist/ComplexComponents/DataTable/CustomTopToolbar/index.js +410 -0
  30. package/dist/ComplexComponents/DataTable/DataTable.js +405 -0
  31. package/dist/ComplexComponents/DataTable/ErrorOverlay/index.js +9 -0
  32. package/dist/ComplexComponents/DataTable/SortableHeaderCell/index.js +27 -0
  33. package/dist/ComplexComponents/DataTable/index.js +1 -0
  34. package/dist/ComplexComponents/DataTable/translations/en.js +99 -0
  35. package/dist/ComplexComponents/DataTable/translations/index.js +17 -0
  36. package/dist/ComplexComponents/KeyInsight/KeyInsights.js +176 -0
  37. package/dist/ComplexComponents/KeyInsight/index.js +1 -0
  38. package/dist/ComplexComponents/NameValue/NameValue.js +94 -0
  39. package/dist/ComplexComponents/NameValue/NameValueItem.js +59 -0
  40. package/dist/ComplexComponents/NameValue/index.js +2 -0
  41. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.js +92 -0
  42. package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +24 -34
  43. package/dist/ComplexComponents/PageContentHeader/index.js +1 -0
  44. package/dist/ComplexComponents/PageContentHeader/index.ts +0 -2
  45. package/dist/ComplexComponents/Placeholder/Placeholder.js +51 -0
  46. package/dist/ComplexComponents/Placeholder/index.js +1 -0
  47. package/dist/ComplexComponents/Slat/Slat.js +53 -0
  48. package/dist/ComplexComponents/Slat/index.js +1 -0
  49. package/dist/ComplexComponents/Utilities/CopyButton.js +45 -0
  50. package/dist/ComplexComponents/Utilities/index.js +1 -0
  51. package/dist/DataDisplay/Alert.js +77 -0
  52. package/dist/DataDisplay/Avatar.js +157 -0
  53. package/dist/DataDisplay/Badge.js +78 -0
  54. package/dist/DataDisplay/Card.js +100 -0
  55. package/dist/DataDisplay/Chip.js +36 -0
  56. package/dist/DataDisplay/Indicator.js +59 -0
  57. package/dist/DataDisplay/List.js +60 -0
  58. package/dist/DataDisplay/Pill.js +81 -0
  59. package/dist/DataDisplay/Progress.js +42 -0
  60. package/dist/DataDisplay/Table.js +38 -0
  61. package/dist/DataDisplay/ThemeIcon.js +31 -0
  62. package/dist/DataDisplay/index.js +18 -0
  63. package/dist/Inputs/Checkbox.js +62 -0
  64. package/dist/Inputs/ColorInput.js +48 -0
  65. package/dist/Inputs/DropZone.js +12 -0
  66. package/dist/Inputs/FileInput.js +77 -0
  67. package/dist/Inputs/NumberInput.js +49 -0
  68. package/dist/Inputs/Radio.js +55 -0
  69. package/dist/Inputs/RadioGroup.js +59 -0
  70. package/dist/Inputs/SegmentedControl.js +50 -0
  71. package/dist/Inputs/Slider.js +50 -0
  72. package/dist/Inputs/SliderWithLabel.js +32 -0
  73. package/dist/Inputs/Switch.js +47 -0
  74. package/dist/Inputs/TextArea.js +50 -0
  75. package/dist/Inputs/TextInput.js +87 -0
  76. package/dist/Inputs/index.js +27 -0
  77. package/dist/Layout/Box.js +39 -0
  78. package/dist/Layout/Center.js +11 -0
  79. package/dist/Layout/Container.js +11 -0
  80. package/dist/Layout/Flex.js +12 -0
  81. package/dist/Layout/Grid.js +13 -0
  82. package/dist/Layout/Group.js +14 -0
  83. package/dist/Layout/Inline.js +46 -0
  84. package/dist/Layout/SimpleGrid.js +14 -0
  85. package/dist/Layout/Stack.js +45 -0
  86. package/dist/Layout/index.js +10 -0
  87. package/dist/Misc/Divider.js +8 -0
  88. package/dist/Misc/Paper.js +24 -0
  89. package/dist/Misc/index.js +10 -0
  90. package/dist/Navigation/Breadcrumb.js +60 -0
  91. package/dist/Navigation/NavLink.js +28 -0
  92. package/dist/Navigation/Stepper.js +8 -0
  93. package/dist/Navigation/Tabs.js +22 -0
  94. package/dist/Navigation/index.js +9 -0
  95. package/dist/Overlays/Drawer.js +63 -0
  96. package/dist/Overlays/Menu.js +85 -0
  97. package/dist/Overlays/Modal.js +61 -0
  98. package/dist/Overlays/Popover.js +118 -0
  99. package/dist/Overlays/Tooltip.js +71 -0
  100. package/dist/Overlays/index.js +12 -0
  101. package/dist/Shell/AppShellLayout.js +13 -0
  102. package/dist/Shell/HeaderBar.js +8 -0
  103. package/dist/Shell/SidebarNav.js +9 -0
  104. package/dist/Shell/SidebarNavLink.js +17 -0
  105. package/dist/Shell/SingleColumnLayout.js +11 -0
  106. package/dist/Shell/TertiaryColumnLayout.js +12 -0
  107. package/dist/Shell/index.js +6 -0
  108. package/dist/Typography/Code.js +8 -0
  109. package/dist/Typography/Kbd.js +58 -0
  110. package/dist/Typography/Text.js +8 -0
  111. package/dist/Typography/Title.js +11 -0
  112. package/dist/Typography/index.js +12 -0
  113. package/dist/config.js +202 -0
  114. package/dist/contracts/PageContentHeader.json +10 -5
  115. package/dist/contracts/index.json +1 -1
  116. package/dist/hooks/useTableHandlers.js +136 -0
  117. package/dist/hooks/useTableRenderFunctions.js +164 -0
  118. package/dist/hooks/useTableState.js +70 -0
  119. package/dist/index.js +162 -0
  120. package/dist/index.ts +3 -4
  121. package/dist/stories/Buttons/ActionIcon.stories.tsx +159 -0
  122. package/dist/stories/Buttons/Button.stories.tsx +145 -0
  123. package/dist/stories/Buttons/CloseButton.stories.tsx +121 -0
  124. package/dist/stories/Combobox/AutocompleteClearable.stories.tsx +554 -0
  125. package/dist/stories/Combobox/Combobox.stories.tsx +106 -0
  126. package/dist/stories/Combobox/Multiselect.stories.tsx +664 -0
  127. package/dist/stories/Combobox/SearchableSelect.stories.tsx +640 -0
  128. package/dist/stories/Combobox/Select.stories.tsx +311 -0
  129. package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +822 -0
  130. package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +502 -0
  131. package/dist/stories/ComplexComponents/KeyInsight/KeyInsights.stories.tsx +386 -0
  132. package/dist/stories/ComplexComponents/NameValue/NameValue.stories.tsx +405 -0
  133. package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +527 -0
  134. package/dist/stories/ComplexComponents/Placeholder/Placeholder.stories.tsx +76 -0
  135. package/dist/stories/ComplexComponents/Slat/Slat.stories.tsx +79 -0
  136. package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +479 -0
  137. package/dist/stories/DataDisplay/Alert.stories.tsx +296 -0
  138. package/dist/stories/DataDisplay/Avatar.stories.tsx +251 -0
  139. package/dist/stories/DataDisplay/Badge.stories.tsx +176 -0
  140. package/dist/stories/DataDisplay/Card.stories.tsx +406 -0
  141. package/dist/stories/DataDisplay/Chip.stories.tsx +495 -0
  142. package/dist/stories/DataDisplay/Indicator.stories.tsx +571 -0
  143. package/dist/stories/DataDisplay/List.stories.tsx +376 -0
  144. package/dist/stories/DataDisplay/Pill.stories.tsx +506 -0
  145. package/dist/stories/DataDisplay/Progress.stories.tsx +352 -0
  146. package/dist/stories/DataDisplay/Table.stories.tsx +346 -0
  147. package/dist/stories/DataDisplay/ThemeIcon.stories.tsx +125 -0
  148. package/dist/stories/Inputs/Checkbox.stories.tsx +263 -0
  149. package/dist/stories/Inputs/ColorInput.stories.tsx +434 -0
  150. package/dist/stories/Inputs/DropZone.stories.tsx +401 -0
  151. package/dist/stories/Inputs/FileInput.stories.tsx +383 -0
  152. package/dist/stories/Inputs/NumberInput.stories.tsx +342 -0
  153. package/dist/stories/Inputs/Radio.stories.tsx +437 -0
  154. package/dist/stories/Inputs/RadioGroup.stories.tsx +526 -0
  155. package/dist/stories/Inputs/SegmentedControl.stories.tsx +60 -0
  156. package/dist/stories/Inputs/Slider.stories.tsx +22 -0
  157. package/dist/stories/Inputs/SliderWithLabel.stories.tsx +37 -0
  158. package/dist/stories/Inputs/Switch.stories.tsx +361 -0
  159. package/dist/stories/Inputs/TextArea.stories.tsx +355 -0
  160. package/dist/stories/Inputs/TextInput.stories.tsx +266 -0
  161. package/dist/stories/Misc/Divider.stories.tsx +581 -0
  162. package/dist/stories/Misc/Paper.stories.tsx +557 -0
  163. package/dist/stories/Navigation/Breadcrumb.stories.tsx +489 -0
  164. package/dist/stories/Navigation/NavLink.stories.tsx +601 -0
  165. package/dist/stories/Navigation/Stepper.stories.tsx +413 -0
  166. package/dist/stories/Navigation/Tabs.stories.tsx +528 -0
  167. package/dist/stories/Overlays/Drawer.stories.tsx +802 -0
  168. package/dist/stories/Overlays/Menu.stories.tsx +941 -0
  169. package/dist/stories/Overlays/Modal.stories.tsx +249 -0
  170. package/dist/stories/Overlays/Popover.stories.tsx +780 -0
  171. package/dist/stories/Overlays/Tooltip.stories.tsx +52 -0
  172. package/dist/stories/Typography/Code.stories.tsx +368 -0
  173. package/dist/stories/Typography/Kbd.stories.tsx +514 -0
  174. package/dist/stories/Typography/Text.stories.tsx +117 -0
  175. package/dist/stories/Typography/Title.stories.tsx +112 -0
  176. package/dist/stories/index.json +1435 -0
  177. package/dist/types.js +127 -0
  178. package/package.json +12 -7
  179. package/dist/ComplexComponents/PageContentHeader/DescriptionBlock.tsx +0 -65
@@ -0,0 +1,361 @@
1
+ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
+ import { Stack } from '@mantine/core';
3
+ import { Switch, Title, Text } from '@appdirect/design-system';
4
+ import { useState } from 'react';
5
+
6
+ const meta: Meta<typeof Switch> = {
7
+ title: 'Design System/Inputs/Switch',
8
+ component: Switch,
9
+ parameters: {
10
+ layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component: 'Switch component with consistent green color and rounded styling for toggle controls.',
14
+ },
15
+ },
16
+ },
17
+ tags: ['autodocs', 'code-connected'],
18
+ argTypes: {
19
+ label: {
20
+ control: 'text',
21
+ description: 'Switch label',
22
+ },
23
+ size: {
24
+ control: 'select',
25
+ options: ['xs', 'sm', 'md', 'lg', 'xl'],
26
+ description: 'Switch size',
27
+ },
28
+ checked: {
29
+ control: 'boolean',
30
+ description: 'Checked state',
31
+ },
32
+ disabled: {
33
+ control: 'boolean',
34
+ description: 'Disabled state',
35
+ },
36
+ showOptional: {
37
+ control: 'boolean',
38
+ description: 'Show "(Optional)" text after label',
39
+ },
40
+ description: {
41
+ control: 'text',
42
+ description: 'Help text below switch',
43
+ },
44
+ onLabel: {
45
+ control: 'text',
46
+ description: 'Label shown when switch is on',
47
+ },
48
+ offLabel: {
49
+ control: 'text',
50
+ description: 'Label shown when switch is off',
51
+ },
52
+ },
53
+ };
54
+
55
+ export default meta;
56
+ type Story = StoryObj<typeof meta>;
57
+
58
+ export const Default: Story = {
59
+ args: {
60
+ label: 'Enable notifications',
61
+ },
62
+ };
63
+
64
+ export const Sizes: Story = {
65
+ render: () => (
66
+ <Stack gap="md">
67
+ <Switch size="xs" label="Extra Small Switch" />
68
+ <Switch size="sm" label="Small Switch" />
69
+ <Switch size="md" label="Medium Switch (default)" />
70
+ <Switch size="lg" label="Large Switch" />
71
+ <Switch size="xl" label="Extra Large Switch" />
72
+ </Stack>
73
+ ),
74
+ };
75
+
76
+ export const LabelVariants: Story = {
77
+ render: () => (
78
+ <Stack gap="md">
79
+ <Switch label="Required Setting" />
80
+ <Switch label="Optional Setting" showOptional />
81
+ <Switch />
82
+ </Stack>
83
+ ),
84
+ };
85
+
86
+ export const States: Story = {
87
+ render: () => (
88
+ <Stack gap="md">
89
+ <Switch label="Default Switch" />
90
+ <Switch label="Checked Switch" defaultChecked />
91
+ <Switch label="Disabled Switch" disabled />
92
+ <Switch label="Disabled Checked" disabled defaultChecked />
93
+ </Stack>
94
+ ),
95
+ };
96
+
97
+ export const Colors: Story = {
98
+ render: () => (
99
+ <Stack gap="md">
100
+ <Switch label="Default Switch" />
101
+ <Switch label="Checked Switch" defaultChecked />
102
+ <Switch label="Another Switch" />
103
+ <Switch label="Another Checked" defaultChecked />
104
+ </Stack>
105
+ ),
106
+ };
107
+
108
+ export const WithLabels: Story = {
109
+ render: () => (
110
+ <Stack gap="md">
111
+ <Switch label="Power" onLabel="ON" offLabel="OFF" />
112
+ <Switch label="WiFi" onLabel="CONNECTED" offLabel="DISCONNECTED" size="lg" />
113
+ <Switch label="Auto-save" onLabel="YES" offLabel="NO" />
114
+ </Stack>
115
+ ),
116
+ };
117
+
118
+ export const WithDescriptions: Story = {
119
+ render: () => (
120
+ <Stack gap="md">
121
+ <Switch
122
+ label="Email Notifications"
123
+ description="Receive email updates about your account"
124
+ />
125
+ <Switch
126
+ label="Push Notifications"
127
+ description="Get notified on your mobile device"
128
+ defaultChecked
129
+ />
130
+ </Stack>
131
+ ),
132
+ };
133
+
134
+ export const Required: Story = {
135
+ render: () => (
136
+ <Stack gap="md" maw={400}>
137
+ <Switch
138
+ label="Terms and Conditions"
139
+ description="I agree to the terms and conditions"
140
+ required
141
+ />
142
+ <Switch
143
+ label="Marketing Emails"
144
+ description="I want to receive marketing emails (optional)"
145
+ />
146
+ </Stack>
147
+ ),
148
+ };
149
+
150
+ export const FormExample: Story = {
151
+ render: () => (
152
+ <Stack gap="md" maw={400}>
153
+ <Title order={3} size="md" fw={500} mb="xs">Account Settings</Title>
154
+ <Stack gap="sm">
155
+ <Switch
156
+ label="Two-Factor Authentication"
157
+ description="Add an extra layer of security to your account"
158
+ />
159
+ <Switch
160
+ label="Email Notifications"
161
+ description="Receive important updates via email"
162
+ defaultChecked
163
+ />
164
+ <Switch
165
+ label="SMS Notifications"
166
+ description="Get text messages for urgent updates"
167
+ />
168
+ </Stack>
169
+
170
+ <Title order={3} size="md" fw={500} mb="xs" mt="lg">Privacy Settings</Title>
171
+ <Stack gap="sm">
172
+ <Switch
173
+ label="Profile Visibility"
174
+ description="Make your profile visible to other users"
175
+ defaultChecked
176
+ />
177
+ <Switch
178
+ label="Activity Status"
179
+ description="Show when you're online"
180
+ />
181
+ </Stack>
182
+ </Stack>
183
+ ),
184
+ };
185
+
186
+ export const ControlledExample: Story = {
187
+ render: () => {
188
+ const [notifications, setNotifications] = useState(true);
189
+ const [darkMode, setDarkMode] = useState(false);
190
+ const [autoSave, setAutoSave] = useState(true);
191
+
192
+ return (
193
+ <Stack gap="md" maw={400}>
194
+ <Switch
195
+ label="Email Notifications"
196
+ checked={notifications}
197
+ onChange={(event) => setNotifications(event.currentTarget.checked)}
198
+ description="You will receive email updates"
199
+ />
200
+ <Switch
201
+ label="Dark Mode"
202
+ checked={darkMode}
203
+ onChange={(event) => setDarkMode(event.currentTarget.checked)}
204
+ description="Switch to dark theme"
205
+ />
206
+ <Switch
207
+ label="Auto-save"
208
+ checked={autoSave}
209
+ onChange={(event) => setAutoSave(event.currentTarget.checked)}
210
+ description="Automatically save your work"
211
+ />
212
+
213
+ <div style={{
214
+ marginTop: '16px',
215
+ padding: '12px',
216
+ backgroundColor: 'var(--mantine-color-gray-0)',
217
+ borderRadius: '8px',
218
+ fontSize: '14px'
219
+ }}>
220
+ <strong>Current Settings:</strong>
221
+ <ul style={{ margin: '8px 0', paddingLeft: '20px' }}>
222
+ <li>Notifications: {notifications ? 'Enabled' : 'Disabled'}</li>
223
+ <li>Dark Mode: {darkMode ? 'Enabled' : 'Disabled'}</li>
224
+ <li>Auto-save: {autoSave ? 'Enabled' : 'Disabled'}</li>
225
+ </ul>
226
+ </div>
227
+ </Stack>
228
+ );
229
+ },
230
+ parameters: {
231
+ docs: {
232
+ description: {
233
+ story: 'Example of controlled Switch components with state management.',
234
+ },
235
+ },
236
+ },
237
+ };
238
+
239
+ export const SettingsExample: Story = {
240
+ render: () => {
241
+ const [notifications, setNotifications] = useState(true);
242
+ const [darkMode, setDarkMode] = useState(false);
243
+ const [autoSave, setAutoSave] = useState(true);
244
+
245
+ return (
246
+ <Stack gap="lg" maw={400}>
247
+ <Title order={3} size="md" fw={500} mb="xs">Notifications</Title>
248
+ <Stack gap="md">
249
+ <Switch
250
+ label="Email notifications"
251
+ description="Receive updates via email"
252
+ checked={notifications}
253
+ onChange={(event) => setNotifications(event.currentTarget.checked)}
254
+ />
255
+ <Switch
256
+ label="Push notifications"
257
+ description="Receive push notifications on your device"
258
+ checked={darkMode}
259
+ onChange={(event) => setDarkMode(event.currentTarget.checked)}
260
+ />
261
+ <Switch
262
+ label="Marketing emails"
263
+ description="Receive promotional content and updates"
264
+ checked={autoSave}
265
+ onChange={(event) => setAutoSave(event.currentTarget.checked)}
266
+ showOptional
267
+ />
268
+ </Stack>
269
+
270
+ <Title order={3} size="md" fw={500} mb="xs">Privacy</Title>
271
+ <Stack gap="md">
272
+ <Switch
273
+ label="Profile visibility"
274
+ description="Make your profile visible to other users"
275
+ checked={notifications}
276
+ onChange={(event) => setNotifications(event.currentTarget.checked)}
277
+ />
278
+ <Switch
279
+ label="Activity tracking"
280
+ description="Allow us to track your activity for analytics"
281
+ checked={darkMode}
282
+ onChange={(event) => setDarkMode(event.currentTarget.checked)}
283
+ />
284
+ </Stack>
285
+ </Stack>
286
+ );
287
+ },
288
+ };
289
+
290
+ export const SettingsPanel: Story = {
291
+ render: () => (
292
+ <div style={{
293
+ maxWidth: '500px',
294
+ padding: '24px',
295
+ border: '1px solid var(--mantine-color-gray-3)',
296
+ borderRadius: '12px',
297
+ backgroundColor: 'white'
298
+ }}>
299
+ <Title order={3} mb="lg">Account Settings</Title>
300
+
301
+ <Stack gap="lg">
302
+ <div>
303
+ <Title order={5} mb="sm">Notifications</Title>
304
+ <Stack gap="sm">
305
+ <Switch
306
+ label="Email notifications"
307
+ description="Receive updates via email"
308
+ checked
309
+ />
310
+ <Switch
311
+ label="Push notifications"
312
+ description="Receive push notifications on your device"
313
+ />
314
+ <Switch
315
+ label="Marketing emails"
316
+ description="Receive promotional content and updates"
317
+ showOptional
318
+ />
319
+ </Stack>
320
+ </div>
321
+
322
+ <div>
323
+ <Title order={5} mb="sm">Privacy</Title>
324
+ <Stack gap="sm">
325
+ <Switch
326
+ label="Profile visibility"
327
+ description="Make your profile visible to other users"
328
+ checked
329
+ />
330
+ <Switch
331
+ label="Activity tracking"
332
+ description="Allow us to track your activity for analytics"
333
+ showOptional
334
+ />
335
+ </Stack>
336
+ </div>
337
+ </Stack>
338
+ </div>
339
+ ),
340
+ parameters: {
341
+ docs: {
342
+ description: {
343
+ story: 'Example of Switch components used in a settings panel layout.',
344
+ },
345
+ },
346
+ },
347
+ };
348
+
349
+ export const Interactive: Story = {
350
+ args: {
351
+ label: 'Interactive Switch',
352
+ size: 'md',
353
+ },
354
+ parameters: {
355
+ docs: {
356
+ description: {
357
+ story: 'Use the controls below to interact with the Switch and see different combinations.',
358
+ },
359
+ },
360
+ },
361
+ };
@@ -0,0 +1,355 @@
1
+ import type { Meta, StoryObj } from '@storybook/nextjs-vite';
2
+ import { Stack } from '@mantine/core';
3
+ import { TextArea, Title, Text } from '@appdirect/design-system';
4
+ import { useState } from 'react';
5
+
6
+ const meta: Meta<typeof TextArea> = {
7
+ title: 'Design System/Inputs/TextArea',
8
+ component: TextArea,
9
+ parameters: {
10
+ layout: 'centered',
11
+ docs: {
12
+ description: {
13
+ component: 'TextArea component for multi-line text input with consistent design system styling and auto-sizing capabilities.',
14
+ },
15
+ },
16
+ },
17
+ tags: ['autodocs', 'code-connected'],
18
+ argTypes: {
19
+ size: {
20
+ control: 'select',
21
+ options: ['xs', 'sm', 'md', 'lg', 'xl'],
22
+ description: 'Input size',
23
+ },
24
+ label: {
25
+ control: 'text',
26
+ description: 'Input label',
27
+ },
28
+ placeholder: {
29
+ control: 'text',
30
+ description: 'Placeholder text',
31
+ },
32
+ required: {
33
+ control: 'boolean',
34
+ description: 'Required field (shows asterisk)',
35
+ },
36
+ showOptional: {
37
+ control: 'boolean',
38
+ description: 'Show "(Optional)" text after label',
39
+ },
40
+ disabled: {
41
+ control: 'boolean',
42
+ description: 'Disabled state',
43
+ },
44
+ error: {
45
+ control: 'text',
46
+ description: 'Error message',
47
+ },
48
+ description: {
49
+ control: 'text',
50
+ description: 'Help text below input',
51
+ },
52
+ rows: {
53
+ control: 'number',
54
+ description: 'Number of visible rows',
55
+ },
56
+ autosize: {
57
+ control: 'boolean',
58
+ description: 'Auto-resize based on content',
59
+ },
60
+ minRows: {
61
+ control: 'number',
62
+ description: 'Minimum rows when autosize is enabled',
63
+ },
64
+ maxRows: {
65
+ control: 'number',
66
+ description: 'Maximum rows when autosize is enabled',
67
+ },
68
+ },
69
+ };
70
+
71
+ export default meta;
72
+ type Story = StoryObj<typeof meta>;
73
+
74
+ export const Default: Story = {
75
+ args: {
76
+ label: 'Comments',
77
+ placeholder: 'Enter your comments...',
78
+ },
79
+ };
80
+
81
+ export const Sizes: Story = {
82
+ render: () => (
83
+ <Stack gap="md" w={400}>
84
+ <TextArea size="xs" label="Extra Small" placeholder="xs size" rows={2} />
85
+ <TextArea size="sm" label="Small" placeholder="sm size" rows={2} />
86
+ <TextArea size="md" label="Medium" placeholder="md size (default)" rows={2} />
87
+ <TextArea size="lg" label="Large" placeholder="lg size" rows={2} />
88
+ <TextArea size="xl" label="Extra Large" placeholder="xl size" rows={2} />
89
+ </Stack>
90
+ ),
91
+ };
92
+
93
+ export const LabelVariants: Story = {
94
+ render: () => (
95
+ <Stack gap="md" w={400}>
96
+ <TextArea label="Required Field" placeholder="This field is required" required rows={3} />
97
+ <TextArea label="Optional Field" placeholder="This field is optional" showOptional rows={3} />
98
+ <TextArea placeholder="No label" rows={3} />
99
+ </Stack>
100
+ ),
101
+ };
102
+
103
+ export const States: Story = {
104
+ render: () => (
105
+ <Stack gap="md" w={400}>
106
+ <TextArea label="Default" placeholder="Enter text..." rows={3} />
107
+ <TextArea label="Disabled" placeholder="Disabled textarea" disabled rows={3} />
108
+ <TextArea label="With Error" placeholder="Enter text..." error="This field is required" rows={3} />
109
+ <TextArea
110
+ label="With Value"
111
+ defaultValue="This textarea has some default content that demonstrates how text appears in the component."
112
+ rows={3}
113
+ />
114
+ </Stack>
115
+ ),
116
+ };
117
+
118
+ export const RowVariants: Story = {
119
+ render: () => (
120
+ <Stack gap="md" w={400}>
121
+ <TextArea
122
+ label="Small (2 rows)"
123
+ placeholder="Compact textarea for short messages..."
124
+ rows={2}
125
+ />
126
+ <TextArea
127
+ label="Medium (4 rows)"
128
+ placeholder="Standard textarea for comments and descriptions..."
129
+ rows={4}
130
+ />
131
+ <TextArea
132
+ label="Large (6 rows)"
133
+ placeholder="Large textarea for detailed content like articles or long descriptions..."
134
+ rows={6}
135
+ />
136
+ </Stack>
137
+ ),
138
+ parameters: {
139
+ docs: {
140
+ description: {
141
+ story: 'TextArea with different row heights for various content lengths.',
142
+ },
143
+ },
144
+ },
145
+ };
146
+
147
+ export const AutosizeExamples: Story = {
148
+ render: () => (
149
+ <Stack gap="md" w={400}>
150
+ <TextArea
151
+ label="Auto-resize"
152
+ placeholder="Start typing and watch this textarea grow..."
153
+ autosize
154
+ minRows={2}
155
+ maxRows={6}
156
+ description="Automatically adjusts height based on content (2-6 rows)"
157
+ />
158
+ <TextArea
159
+ label="Auto-resize (Large)"
160
+ placeholder="This textarea can grow quite large..."
161
+ autosize
162
+ minRows={3}
163
+ maxRows={10}
164
+ description="Larger auto-resize range (3-10 rows)"
165
+ />
166
+ <TextArea
167
+ label="Fixed Height"
168
+ placeholder="This textarea maintains a fixed height..."
169
+ rows={4}
170
+ description="Fixed at 4 rows, no auto-resize"
171
+ />
172
+ </Stack>
173
+ ),
174
+ parameters: {
175
+ docs: {
176
+ description: {
177
+ story: 'TextArea with auto-sizing capabilities that adjust height based on content.',
178
+ },
179
+ },
180
+ },
181
+ };
182
+
183
+ export const ControlledExample: Story = {
184
+ render: () => {
185
+ const [feedback, setFeedback] = useState('');
186
+ const [notes, setNotes] = useState('');
187
+
188
+ const wordCount = feedback.trim().split(/\s+/).filter(word => word.length > 0).length;
189
+ const charCount = feedback.length;
190
+
191
+ return (
192
+ <Stack gap="md" w={400}>
193
+ <TextArea
194
+ label="Customer Feedback"
195
+ placeholder="Please share your thoughts..."
196
+ value={feedback}
197
+ onChange={(event) => setFeedback(event.currentTarget.value)}
198
+ autosize
199
+ minRows={3}
200
+ maxRows={8}
201
+ description={`${charCount} characters, ${wordCount} words`}
202
+ />
203
+
204
+ <TextArea
205
+ label="Internal Notes"
206
+ placeholder="Add internal notes..."
207
+ value={notes}
208
+ onChange={(event) => setNotes(event.currentTarget.value)}
209
+ rows={4}
210
+ showOptional
211
+ />
212
+
213
+ <div style={{
214
+ padding: '12px',
215
+ backgroundColor: 'var(--mantine-color-gray-0)',
216
+ borderRadius: '8px',
217
+ border: '1px solid var(--mantine-color-gray-3)'
218
+ }}>
219
+ <Text size="sm" fw={500} mb="xs">Content Summary:</Text>
220
+ <Text size="sm">Feedback: {charCount} characters</Text>
221
+ <Text size="sm">Notes: {notes.length} characters</Text>
222
+ <Text size="sm">Total: {charCount + notes.length} characters</Text>
223
+ </div>
224
+ </Stack>
225
+ );
226
+ },
227
+ parameters: {
228
+ docs: {
229
+ description: {
230
+ story: 'Example of controlled TextArea components with character counting and state management.',
231
+ },
232
+ },
233
+ },
234
+ };
235
+
236
+ export const FormExample: Story = {
237
+ render: () => (
238
+ <Stack gap="md" w={500}>
239
+ <Title order={3} size="md" fw={500} mb="xs">Article Submission</Title>
240
+
241
+ <TextArea
242
+ label="Article Title"
243
+ placeholder="Enter a compelling title..."
244
+ required
245
+ rows={2}
246
+ description="Keep it concise and engaging"
247
+ />
248
+ <TextArea
249
+ label="Article Summary"
250
+ placeholder="Brief summary of your article..."
251
+ required
252
+ rows={3}
253
+ description="2-3 sentences describing the main points"
254
+ />
255
+ <TextArea
256
+ label="Article Content"
257
+ placeholder="Write your full article here..."
258
+ required
259
+ autosize
260
+ minRows={6}
261
+ maxRows={15}
262
+ description="Main content of your article"
263
+ />
264
+ <TextArea
265
+ label="Author Bio"
266
+ placeholder="Tell us about yourself..."
267
+ rows={3}
268
+ showOptional
269
+ description="Brief biography to display with your article"
270
+ />
271
+ <TextArea
272
+ label="Additional Notes"
273
+ placeholder="Any special instructions or notes..."
274
+ rows={2}
275
+ showOptional
276
+ description="Internal notes for editors"
277
+ />
278
+ </Stack>
279
+ ),
280
+ parameters: {
281
+ docs: {
282
+ description: {
283
+ story: 'Example of TextArea components used in an article submission form.',
284
+ },
285
+ },
286
+ },
287
+ };
288
+
289
+ export const UseCases: Story = {
290
+ render: () => (
291
+ <Stack gap="lg" w={500}>
292
+ <div>
293
+ <Title order={4} size="sm" fw={500} mb="md">Common Use Cases</Title>
294
+
295
+ <Stack gap="md">
296
+ <TextArea
297
+ label="Product Review"
298
+ placeholder="Share your experience with this product..."
299
+ rows={4}
300
+ description="Help other customers with your honest review"
301
+ />
302
+
303
+ <TextArea
304
+ label="Bug Report"
305
+ placeholder="Describe the issue you encountered..."
306
+ autosize
307
+ minRows={3}
308
+ maxRows={8}
309
+ description="Please include steps to reproduce the issue"
310
+ />
311
+
312
+ <TextArea
313
+ label="Feature Request"
314
+ placeholder="Describe the feature you'd like to see..."
315
+ rows={5}
316
+ description="Explain how this feature would benefit users"
317
+ />
318
+
319
+ <TextArea
320
+ label="Contact Message"
321
+ placeholder="How can we help you today?"
322
+ autosize
323
+ minRows={4}
324
+ maxRows={10}
325
+ description="We'll get back to you within 24 hours"
326
+ />
327
+ </Stack>
328
+ </div>
329
+ </Stack>
330
+ ),
331
+ parameters: {
332
+ docs: {
333
+ description: {
334
+ story: 'Common use cases for TextArea in different contexts like reviews, support, and feedback.',
335
+ },
336
+ },
337
+ },
338
+ };
339
+
340
+ export const Interactive: Story = {
341
+ args: {
342
+ label: 'Interactive TextArea',
343
+ placeholder: 'Start typing...',
344
+ size: 'md',
345
+ rows: 4,
346
+ autosize: false,
347
+ },
348
+ parameters: {
349
+ docs: {
350
+ description: {
351
+ story: 'Use the controls below to interact with the TextArea and see different combinations.',
352
+ },
353
+ },
354
+ },
355
+ };