@appdirect/design-system 0.0.9 → 0.0.11
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.
- package/README.md +2 -0
- package/dist/ComplexComponents/PageContentHeader/PageContentHeader.tsx +24 -34
- package/dist/ComplexComponents/PageContentHeader/index.ts +0 -2
- package/dist/contracts/PageContentHeader.json +10 -5
- package/dist/contracts/index.json +1 -1
- package/dist/index.ts +3 -4
- package/dist/stories/Buttons/ActionIcon.stories.tsx +159 -0
- package/dist/stories/Buttons/Button.stories.tsx +145 -0
- package/dist/stories/Buttons/CloseButton.stories.tsx +121 -0
- package/dist/stories/Combobox/AutocompleteClearable.stories.tsx +554 -0
- package/dist/stories/Combobox/Combobox.stories.tsx +106 -0
- package/dist/stories/Combobox/Multiselect.stories.tsx +664 -0
- package/dist/stories/Combobox/SearchableSelect.stories.tsx +640 -0
- package/dist/stories/Combobox/Select.stories.tsx +311 -0
- package/dist/stories/ComplexComponents/DashboardWidget/DashboardWidget.stories.tsx +822 -0
- package/dist/stories/ComplexComponents/DataTable/DataTable.stories.tsx +502 -0
- package/dist/stories/ComplexComponents/KeyInsight/KeyInsights.stories.tsx +386 -0
- package/dist/stories/ComplexComponents/NameValue/NameValue.stories.tsx +405 -0
- package/dist/stories/ComplexComponents/PageContentHeader/PageContentHeader.stories.tsx +527 -0
- package/dist/stories/ComplexComponents/Placeholder/Placeholder.stories.tsx +76 -0
- package/dist/stories/ComplexComponents/Slat/Slat.stories.tsx +79 -0
- package/dist/stories/ComplexComponents/Utilities/CopyButton.stories.tsx +479 -0
- package/dist/stories/DataDisplay/Alert.stories.tsx +296 -0
- package/dist/stories/DataDisplay/Avatar.stories.tsx +251 -0
- package/dist/stories/DataDisplay/Badge.stories.tsx +176 -0
- package/dist/stories/DataDisplay/Card.stories.tsx +406 -0
- package/dist/stories/DataDisplay/Chip.stories.tsx +495 -0
- package/dist/stories/DataDisplay/Indicator.stories.tsx +571 -0
- package/dist/stories/DataDisplay/List.stories.tsx +376 -0
- package/dist/stories/DataDisplay/Pill.stories.tsx +506 -0
- package/dist/stories/DataDisplay/Progress.stories.tsx +352 -0
- package/dist/stories/DataDisplay/Table.stories.tsx +346 -0
- package/dist/stories/DataDisplay/ThemeIcon.stories.tsx +125 -0
- package/dist/stories/Inputs/Checkbox.stories.tsx +263 -0
- package/dist/stories/Inputs/ColorInput.stories.tsx +434 -0
- package/dist/stories/Inputs/DropZone.stories.tsx +401 -0
- package/dist/stories/Inputs/FileInput.stories.tsx +383 -0
- package/dist/stories/Inputs/NumberInput.stories.tsx +342 -0
- package/dist/stories/Inputs/Radio.stories.tsx +437 -0
- package/dist/stories/Inputs/RadioGroup.stories.tsx +526 -0
- package/dist/stories/Inputs/SegmentedControl.stories.tsx +60 -0
- package/dist/stories/Inputs/Slider.stories.tsx +22 -0
- package/dist/stories/Inputs/SliderWithLabel.stories.tsx +37 -0
- package/dist/stories/Inputs/Switch.stories.tsx +361 -0
- package/dist/stories/Inputs/TextArea.stories.tsx +355 -0
- package/dist/stories/Inputs/TextInput.stories.tsx +266 -0
- package/dist/stories/Misc/Divider.stories.tsx +581 -0
- package/dist/stories/Misc/Paper.stories.tsx +557 -0
- package/dist/stories/Navigation/Breadcrumb.stories.tsx +489 -0
- package/dist/stories/Navigation/NavLink.stories.tsx +601 -0
- package/dist/stories/Navigation/Stepper.stories.tsx +413 -0
- package/dist/stories/Navigation/Tabs.stories.tsx +528 -0
- package/dist/stories/Overlays/Drawer.stories.tsx +802 -0
- package/dist/stories/Overlays/Menu.stories.tsx +941 -0
- package/dist/stories/Overlays/Modal.stories.tsx +249 -0
- package/dist/stories/Overlays/Popover.stories.tsx +780 -0
- package/dist/stories/Overlays/Tooltip.stories.tsx +52 -0
- package/dist/stories/Typography/Code.stories.tsx +368 -0
- package/dist/stories/Typography/Kbd.stories.tsx +514 -0
- package/dist/stories/Typography/Text.stories.tsx +117 -0
- package/dist/stories/Typography/Title.stories.tsx +112 -0
- package/dist/stories/index.json +1435 -0
- package/package.json +5 -3
- 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
|
+
};
|