@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,342 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/nextjs-vite';
|
|
2
|
+
import { Stack } from '@mantine/core';
|
|
3
|
+
import { NumberInput, Title, Text } from '@appdirect/design-system';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof NumberInput> = {
|
|
7
|
+
title: 'Design System/Inputs/NumberInput',
|
|
8
|
+
component: NumberInput,
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: 'centered',
|
|
11
|
+
docs: {
|
|
12
|
+
description: {
|
|
13
|
+
component: 'NumberInput component for numeric values with consistent design system styling and validation.',
|
|
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
|
+
min: {
|
|
53
|
+
control: 'number',
|
|
54
|
+
description: 'Minimum value',
|
|
55
|
+
},
|
|
56
|
+
max: {
|
|
57
|
+
control: 'number',
|
|
58
|
+
description: 'Maximum value',
|
|
59
|
+
},
|
|
60
|
+
step: {
|
|
61
|
+
control: 'number',
|
|
62
|
+
description: 'Step increment',
|
|
63
|
+
},
|
|
64
|
+
prefix: {
|
|
65
|
+
control: 'text',
|
|
66
|
+
description: 'Prefix symbol (e.g., $)',
|
|
67
|
+
},
|
|
68
|
+
suffix: {
|
|
69
|
+
control: 'text',
|
|
70
|
+
description: 'Suffix symbol (e.g., %)',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default meta;
|
|
76
|
+
type Story = StoryObj<typeof meta>;
|
|
77
|
+
|
|
78
|
+
export const Default: Story = {
|
|
79
|
+
args: {
|
|
80
|
+
label: 'Quantity',
|
|
81
|
+
placeholder: 'Enter a number',
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Sizes: Story = {
|
|
86
|
+
render: () => (
|
|
87
|
+
<Stack gap="md" w={300}>
|
|
88
|
+
<NumberInput size="xs" label="Extra Small" placeholder="xs size" />
|
|
89
|
+
<NumberInput size="sm" label="Small" placeholder="sm size" />
|
|
90
|
+
<NumberInput size="md" label="Medium" placeholder="md size (default)" />
|
|
91
|
+
<NumberInput size="lg" label="Large" placeholder="lg size" />
|
|
92
|
+
<NumberInput size="xl" label="Extra Large" placeholder="xl size" />
|
|
93
|
+
</Stack>
|
|
94
|
+
),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const LabelVariants: Story = {
|
|
98
|
+
render: () => (
|
|
99
|
+
<Stack gap="md" w={300}>
|
|
100
|
+
<NumberInput label="Required Field" placeholder="This field is required" required />
|
|
101
|
+
<NumberInput label="Optional Field" placeholder="This field is optional" showOptional />
|
|
102
|
+
<NumberInput placeholder="No label" />
|
|
103
|
+
</Stack>
|
|
104
|
+
),
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const States: Story = {
|
|
108
|
+
render: () => (
|
|
109
|
+
<Stack gap="md" w={300}>
|
|
110
|
+
<NumberInput label="Default" placeholder="Enter number" />
|
|
111
|
+
<NumberInput label="Disabled" placeholder="Disabled input" disabled />
|
|
112
|
+
<NumberInput label="With Error" placeholder="Enter number" error="Please enter a valid number" />
|
|
113
|
+
<NumberInput label="With Value" defaultValue={42} />
|
|
114
|
+
</Stack>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export const WithConstraints: Story = {
|
|
119
|
+
render: () => (
|
|
120
|
+
<Stack gap="md" w={300}>
|
|
121
|
+
<NumberInput
|
|
122
|
+
label="Rating (1-10)"
|
|
123
|
+
placeholder="Rate from 1 to 10"
|
|
124
|
+
min={1}
|
|
125
|
+
max={10}
|
|
126
|
+
defaultValue={5}
|
|
127
|
+
description="Use the controls or type a number"
|
|
128
|
+
/>
|
|
129
|
+
<NumberInput
|
|
130
|
+
label="Price"
|
|
131
|
+
placeholder="0.00"
|
|
132
|
+
min={0}
|
|
133
|
+
step={0.01}
|
|
134
|
+
decimalScale={2}
|
|
135
|
+
fixedDecimalScale
|
|
136
|
+
prefix="$"
|
|
137
|
+
description="Enter price in dollars"
|
|
138
|
+
/>
|
|
139
|
+
<NumberInput
|
|
140
|
+
label="Percentage"
|
|
141
|
+
placeholder="0"
|
|
142
|
+
min={0}
|
|
143
|
+
max={100}
|
|
144
|
+
suffix="%"
|
|
145
|
+
description="Enter percentage (0-100)"
|
|
146
|
+
/>
|
|
147
|
+
</Stack>
|
|
148
|
+
),
|
|
149
|
+
parameters: {
|
|
150
|
+
docs: {
|
|
151
|
+
description: {
|
|
152
|
+
story: 'NumberInput with various constraints like min/max values, step increments, and formatting.',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const FormattingExamples: Story = {
|
|
159
|
+
render: () => (
|
|
160
|
+
<Stack gap="md" w={300}>
|
|
161
|
+
<NumberInput
|
|
162
|
+
label="Currency"
|
|
163
|
+
placeholder="0.00"
|
|
164
|
+
prefix="$"
|
|
165
|
+
decimalScale={2}
|
|
166
|
+
fixedDecimalScale
|
|
167
|
+
thousandSeparator=","
|
|
168
|
+
defaultValue={1234.56}
|
|
169
|
+
/>
|
|
170
|
+
<NumberInput
|
|
171
|
+
label="Percentage"
|
|
172
|
+
placeholder="0"
|
|
173
|
+
suffix="%"
|
|
174
|
+
min={0}
|
|
175
|
+
max={100}
|
|
176
|
+
defaultValue={75}
|
|
177
|
+
/>
|
|
178
|
+
<NumberInput
|
|
179
|
+
label="Weight"
|
|
180
|
+
placeholder="0"
|
|
181
|
+
suffix=" kg"
|
|
182
|
+
step={0.1}
|
|
183
|
+
decimalScale={1}
|
|
184
|
+
defaultValue={68.5}
|
|
185
|
+
/>
|
|
186
|
+
<NumberInput
|
|
187
|
+
label="Temperature"
|
|
188
|
+
placeholder="0"
|
|
189
|
+
suffix="°C"
|
|
190
|
+
step={0.5}
|
|
191
|
+
defaultValue={22.5}
|
|
192
|
+
/>
|
|
193
|
+
</Stack>
|
|
194
|
+
),
|
|
195
|
+
parameters: {
|
|
196
|
+
docs: {
|
|
197
|
+
description: {
|
|
198
|
+
story: 'Examples of NumberInput with different formatting options like prefixes, suffixes, and decimal places.',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export const ControlledExample: Story = {
|
|
205
|
+
render: () => {
|
|
206
|
+
const [quantity, setQuantity] = useState<number | string>(1);
|
|
207
|
+
const [price, setPrice] = useState<number | string>(9.99);
|
|
208
|
+
const [discount, setDiscount] = useState<number | string>(10);
|
|
209
|
+
|
|
210
|
+
const total = typeof quantity === 'number' && typeof price === 'number' && typeof discount === 'number'
|
|
211
|
+
? (quantity * price * (1 - discount / 100)).toFixed(2)
|
|
212
|
+
: '0.00';
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<Stack gap="md" w={300}>
|
|
216
|
+
<NumberInput
|
|
217
|
+
label="Quantity"
|
|
218
|
+
value={quantity}
|
|
219
|
+
onChange={setQuantity}
|
|
220
|
+
min={1}
|
|
221
|
+
max={99}
|
|
222
|
+
/>
|
|
223
|
+
<NumberInput
|
|
224
|
+
label="Unit Price"
|
|
225
|
+
value={price}
|
|
226
|
+
onChange={setPrice}
|
|
227
|
+
prefix="$"
|
|
228
|
+
min={0}
|
|
229
|
+
step={0.01}
|
|
230
|
+
decimalScale={2}
|
|
231
|
+
fixedDecimalScale
|
|
232
|
+
/>
|
|
233
|
+
<NumberInput
|
|
234
|
+
label="Discount"
|
|
235
|
+
value={discount}
|
|
236
|
+
onChange={setDiscount}
|
|
237
|
+
suffix="%"
|
|
238
|
+
min={0}
|
|
239
|
+
max={50}
|
|
240
|
+
/>
|
|
241
|
+
|
|
242
|
+
<div style={{
|
|
243
|
+
padding: '12px',
|
|
244
|
+
backgroundColor: 'var(--mantine-color-gray-0)',
|
|
245
|
+
borderRadius: '8px',
|
|
246
|
+
border: '1px solid var(--mantine-color-gray-3)'
|
|
247
|
+
}}>
|
|
248
|
+
<Text size="sm" fw={500} mb="xs">Order Summary:</Text>
|
|
249
|
+
<Text size="sm">Quantity: {quantity}</Text>
|
|
250
|
+
<Text size="sm">Unit Price: ${typeof price === 'number' ? price.toFixed(2) : '0.00'}</Text>
|
|
251
|
+
<Text size="sm">Discount: {discount}%</Text>
|
|
252
|
+
<Text size="sm" fw={600} mt="xs">Total: ${total}</Text>
|
|
253
|
+
</div>
|
|
254
|
+
</Stack>
|
|
255
|
+
);
|
|
256
|
+
},
|
|
257
|
+
parameters: {
|
|
258
|
+
docs: {
|
|
259
|
+
description: {
|
|
260
|
+
story: 'Example of controlled NumberInput components with state management and calculations.',
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export const FormExample: Story = {
|
|
267
|
+
render: () => (
|
|
268
|
+
<Stack gap="md" w={400}>
|
|
269
|
+
<Title order={3} size="md" fw={500} mb="xs">Product Information</Title>
|
|
270
|
+
|
|
271
|
+
<NumberInput
|
|
272
|
+
label="Product ID"
|
|
273
|
+
placeholder="Enter product ID"
|
|
274
|
+
required
|
|
275
|
+
min={1}
|
|
276
|
+
description="Unique identifier for the product"
|
|
277
|
+
/>
|
|
278
|
+
<NumberInput
|
|
279
|
+
label="Price"
|
|
280
|
+
placeholder="0.00"
|
|
281
|
+
prefix="$"
|
|
282
|
+
required
|
|
283
|
+
min={0}
|
|
284
|
+
step={0.01}
|
|
285
|
+
decimalScale={2}
|
|
286
|
+
fixedDecimalScale
|
|
287
|
+
description="Product price in USD"
|
|
288
|
+
/>
|
|
289
|
+
<NumberInput
|
|
290
|
+
label="Stock Quantity"
|
|
291
|
+
placeholder="0"
|
|
292
|
+
required
|
|
293
|
+
min={0}
|
|
294
|
+
description="Available inventory count"
|
|
295
|
+
/>
|
|
296
|
+
<NumberInput
|
|
297
|
+
label="Weight"
|
|
298
|
+
placeholder="0.0"
|
|
299
|
+
suffix=" kg"
|
|
300
|
+
min={0}
|
|
301
|
+
step={0.1}
|
|
302
|
+
decimalScale={1}
|
|
303
|
+
showOptional
|
|
304
|
+
description="Product weight for shipping"
|
|
305
|
+
/>
|
|
306
|
+
<NumberInput
|
|
307
|
+
label="Discount"
|
|
308
|
+
placeholder="0"
|
|
309
|
+
suffix="%"
|
|
310
|
+
min={0}
|
|
311
|
+
max={100}
|
|
312
|
+
showOptional
|
|
313
|
+
description="Discount percentage (if applicable)"
|
|
314
|
+
/>
|
|
315
|
+
</Stack>
|
|
316
|
+
),
|
|
317
|
+
parameters: {
|
|
318
|
+
docs: {
|
|
319
|
+
description: {
|
|
320
|
+
story: 'Example of NumberInput components used in a product form layout.',
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const Interactive: Story = {
|
|
327
|
+
args: {
|
|
328
|
+
label: 'Interactive NumberInput',
|
|
329
|
+
placeholder: 'Enter a number...',
|
|
330
|
+
size: 'md',
|
|
331
|
+
min: 0,
|
|
332
|
+
max: 100,
|
|
333
|
+
step: 1,
|
|
334
|
+
},
|
|
335
|
+
parameters: {
|
|
336
|
+
docs: {
|
|
337
|
+
description: {
|
|
338
|
+
story: 'Use the controls below to interact with the NumberInput and see different combinations.',
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
};
|