@rovula/ui 0.0.76 → 0.0.78

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 (56) hide show
  1. package/dist/cjs/bundle.css +40 -0
  2. package/dist/cjs/bundle.js +3 -3
  3. package/dist/cjs/bundle.js.map +1 -1
  4. package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +7 -0
  5. package/dist/cjs/types/components/InputFilter/InputFilter.stories.d.ts +7 -0
  6. package/dist/cjs/types/components/MaskedTextInput/MaskedTextInput.d.ts +75 -0
  7. package/dist/cjs/types/components/MaskedTextInput/MaskedTextInput.stories.d.ts +491 -0
  8. package/dist/cjs/types/components/MaskedTextInput/index.d.ts +3 -0
  9. package/dist/cjs/types/components/NumberInput/NumberInput.d.ts +39 -0
  10. package/dist/cjs/types/components/NumberInput/NumberInput.stories.d.ts +18 -0
  11. package/dist/cjs/types/components/NumberInput/index.d.ts +2 -0
  12. package/dist/cjs/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  13. package/dist/cjs/types/components/Search/Search.stories.d.ts +7 -0
  14. package/dist/cjs/types/components/Slider/Slider.stories.d.ts +1 -1
  15. package/dist/cjs/types/components/TextInput/TextInput.d.ts +14 -0
  16. package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +14 -0
  17. package/dist/cjs/types/index.d.ts +4 -0
  18. package/dist/components/MaskedTextInput/MaskedTextInput.js +267 -0
  19. package/dist/components/MaskedTextInput/MaskedTextInput.stories.js +167 -0
  20. package/dist/components/MaskedTextInput/index.js +2 -0
  21. package/dist/components/NumberInput/NumberInput.js +254 -0
  22. package/dist/components/NumberInput/NumberInput.stories.js +212 -0
  23. package/dist/components/NumberInput/index.js +1 -0
  24. package/dist/components/TextInput/TextInput.js +13 -11
  25. package/dist/components/Toast/Toast.styles.js +1 -1
  26. package/dist/esm/bundle.css +40 -0
  27. package/dist/esm/bundle.js +3 -3
  28. package/dist/esm/bundle.js.map +1 -1
  29. package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +7 -0
  30. package/dist/esm/types/components/InputFilter/InputFilter.stories.d.ts +7 -0
  31. package/dist/esm/types/components/MaskedTextInput/MaskedTextInput.d.ts +75 -0
  32. package/dist/esm/types/components/MaskedTextInput/MaskedTextInput.stories.d.ts +491 -0
  33. package/dist/esm/types/components/MaskedTextInput/index.d.ts +3 -0
  34. package/dist/esm/types/components/NumberInput/NumberInput.d.ts +39 -0
  35. package/dist/esm/types/components/NumberInput/NumberInput.stories.d.ts +18 -0
  36. package/dist/esm/types/components/NumberInput/index.d.ts +2 -0
  37. package/dist/esm/types/components/RadioGroup/RadioGroup.stories.d.ts +1 -1
  38. package/dist/esm/types/components/Search/Search.stories.d.ts +7 -0
  39. package/dist/esm/types/components/Slider/Slider.stories.d.ts +1 -1
  40. package/dist/esm/types/components/TextInput/TextInput.d.ts +14 -0
  41. package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +14 -0
  42. package/dist/esm/types/index.d.ts +4 -0
  43. package/dist/index.d.ts +110 -1
  44. package/dist/index.js +2 -0
  45. package/dist/src/theme/global.css +51 -0
  46. package/package.json +1 -1
  47. package/src/components/MaskedTextInput/MaskedTextInput.stories.tsx +414 -0
  48. package/src/components/MaskedTextInput/MaskedTextInput.tsx +391 -0
  49. package/src/components/MaskedTextInput/README.md +202 -0
  50. package/src/components/MaskedTextInput/index.ts +3 -0
  51. package/src/components/NumberInput/NumberInput.stories.tsx +350 -0
  52. package/src/components/NumberInput/NumberInput.tsx +428 -0
  53. package/src/components/NumberInput/index.ts +2 -0
  54. package/src/components/TextInput/TextInput.tsx +54 -12
  55. package/src/components/Toast/Toast.styles.tsx +1 -1
  56. package/src/index.ts +7 -0
@@ -0,0 +1,350 @@
1
+ import React from "react";
2
+ import type { Meta, StoryObj } from "@storybook/react";
3
+ import { NumberInput, type NumberInputProps } from "@/index";
4
+
5
+ const meta: Meta<typeof NumberInput> = {
6
+ title: "Components/NumberInput",
7
+ component: NumberInput,
8
+ parameters: {
9
+ layout: "fullscreen",
10
+ },
11
+ tags: ["autodocs"],
12
+ decorators: [
13
+ (Story) => (
14
+ <div className="p-5 flex h-screen w-full bg-base-bg2">
15
+ <Story />
16
+ </div>
17
+ ),
18
+ ],
19
+ argTypes: {
20
+ size: {
21
+ control: { type: "radio" },
22
+ options: ["sm", "md", "lg"],
23
+ },
24
+ rounded: {
25
+ control: { type: "radio" },
26
+ options: ["none", "normal", "full"],
27
+ },
28
+ variant: {
29
+ control: { type: "radio" },
30
+ options: ["flat", "outline", "underline"],
31
+ },
32
+ isFloatingLabel: { control: "boolean" },
33
+ fullwidth: { control: "boolean" },
34
+ disabled: { control: "boolean" },
35
+ error: { control: "boolean" },
36
+ required: { control: "boolean" },
37
+ hideControls: { control: "boolean" },
38
+ allowDecimal: { control: "boolean" },
39
+ allowNegative: { control: "boolean" },
40
+ },
41
+ args: {
42
+ label: "Number",
43
+ placeholder: "Enter a number",
44
+ size: "md",
45
+ rounded: "normal",
46
+ variant: "outline",
47
+ isFloatingLabel: true,
48
+ fullwidth: true,
49
+ disabled: false,
50
+ error: false,
51
+ required: true,
52
+ hideControls: false,
53
+ allowDecimal: true,
54
+ allowNegative: true,
55
+ } satisfies Partial<NumberInputProps>,
56
+ };
57
+
58
+ export default meta;
59
+ type Story = StoryObj<typeof NumberInput>;
60
+
61
+ export const Default: Story = {
62
+ render: (args) => {
63
+ console.log("args ", args);
64
+ const props: typeof args = {
65
+ ...args,
66
+ };
67
+
68
+ return (
69
+ <div className="flex flex-row gap-4 w-full">
70
+ <NumberInput id="1" {...props} size="lg" />
71
+ <NumberInput id="2" {...props} size="md" />
72
+ <NumberInput id="3" {...props} size="sm" />
73
+ </div>
74
+ );
75
+ },
76
+ };
77
+
78
+ export const WithMinMax: Story = {
79
+ args: {
80
+ label: "Age",
81
+ min: 0,
82
+ max: 120,
83
+ helperText: "Age must be between 0 and 120",
84
+ },
85
+ render: (args) => {
86
+ const props: typeof args = {
87
+ ...args,
88
+ };
89
+
90
+ return (
91
+ <div className="flex flex-row gap-4 w-full">
92
+ <NumberInput id="1" {...props} size="lg" />
93
+ <NumberInput id="2" {...props} size="md" />
94
+ <NumberInput id="3" {...props} size="sm" />
95
+ </div>
96
+ );
97
+ },
98
+ };
99
+
100
+ export const WithStep: Story = {
101
+ args: {
102
+ label: "Rating",
103
+ min: 0,
104
+ max: 5,
105
+ step: 0.5,
106
+ defaultValue: 2.5,
107
+ helperText: "Use 0.5 increments",
108
+ },
109
+ render: (args) => {
110
+ const props: typeof args = {
111
+ ...args,
112
+ };
113
+
114
+ return (
115
+ <div className="flex flex-row gap-4 w-full">
116
+ <NumberInput id="1" {...props} size="lg" />
117
+ <NumberInput id="2" {...props} size="md" />
118
+ <NumberInput id="3" {...props} size="sm" />
119
+ </div>
120
+ );
121
+ },
122
+ };
123
+
124
+ export const IntegerOnly: Story = {
125
+ args: {
126
+ label: "Quantity",
127
+ allowDecimal: false,
128
+ min: 1,
129
+ defaultValue: 1,
130
+ helperText: "Integer values only",
131
+ },
132
+ render: (args) => {
133
+ const props: typeof args = {
134
+ ...args,
135
+ };
136
+
137
+ return (
138
+ <div className="flex flex-row gap-4 w-full">
139
+ <NumberInput id="1" {...props} size="lg" />
140
+ <NumberInput id="2" {...props} size="md" />
141
+ <NumberInput id="3" {...props} size="sm" />
142
+ </div>
143
+ );
144
+ },
145
+ };
146
+
147
+ export const ControllWithOutLine: Story = {
148
+ args: {
149
+ label: "Quantity",
150
+ allowDecimal: false,
151
+ iconMode: "flat",
152
+ min: 1,
153
+ defaultValue: 1,
154
+ helperText: "Integer values only",
155
+ },
156
+ render: (args) => {
157
+ const props: typeof args = {
158
+ ...args,
159
+ };
160
+
161
+ return (
162
+ <div className="flex flex-row gap-4 w-full">
163
+ <NumberInput id="1" {...props} size="lg" />
164
+ <NumberInput id="2" {...props} size="md" />
165
+ <NumberInput id="3" {...props} size="sm" />
166
+ </div>
167
+ );
168
+ },
169
+ };
170
+
171
+ export const WithoutControls: Story = {
172
+ args: {
173
+ label: "Custom Number",
174
+ hideControls: true,
175
+ helperText: "No increment/decrement buttons",
176
+ },
177
+ render: (args) => {
178
+ const props: typeof args = {
179
+ ...args,
180
+ };
181
+
182
+ return (
183
+ <div className="flex flex-row gap-4 w-full">
184
+ <NumberInput id="1" {...props} size="lg" />
185
+ <NumberInput id="2" {...props} size="md" />
186
+ <NumberInput id="3" {...props} size="sm" />
187
+ </div>
188
+ );
189
+ },
190
+ };
191
+
192
+ export const ErrorState: Story = {
193
+ args: {
194
+ error: true,
195
+ errorMessage: "Value exceeds maximum allowed",
196
+ defaultValue: 150,
197
+ },
198
+ render: (args) => {
199
+ const props: typeof args = {
200
+ ...args,
201
+ };
202
+
203
+ return (
204
+ <div className="flex flex-row gap-4 w-full">
205
+ <NumberInput id="1" {...props} size="lg" />
206
+ <NumberInput id="2" {...props} size="md" />
207
+ <NumberInput id="3" {...props} size="sm" />
208
+ </div>
209
+ );
210
+ },
211
+ };
212
+
213
+ export const HelperText: Story = {
214
+ args: {
215
+ helperText: "Enter a number between 0 and 100",
216
+ min: 0,
217
+ max: 100,
218
+ },
219
+ render: (args) => {
220
+ const props: typeof args = {
221
+ ...args,
222
+ };
223
+
224
+ return (
225
+ <div className="flex flex-row gap-4 w-full">
226
+ <NumberInput id="1" {...props} size="lg" />
227
+ <NumberInput id="2" {...props} size="md" />
228
+ <NumberInput id="3" {...props} size="sm" />
229
+ </div>
230
+ );
231
+ },
232
+ };
233
+
234
+ export const Disabled: Story = {
235
+ args: {
236
+ disabled: true,
237
+ defaultValue: 50,
238
+ },
239
+ render: (args) => {
240
+ const props: typeof args = {
241
+ ...args,
242
+ };
243
+
244
+ return (
245
+ <div className="flex flex-row gap-4 w-full">
246
+ <NumberInput id="1" {...props} size="lg" />
247
+ <NumberInput id="2" {...props} size="md" />
248
+ <NumberInput id="3" {...props} size="sm" />
249
+ </div>
250
+ );
251
+ },
252
+ };
253
+
254
+ export const FormattedNumber: Story = {
255
+ args: {
256
+ label: "Amount",
257
+ formatDisplay: true,
258
+ precision: 2,
259
+ defaultValue: 1234567.89,
260
+ helperText: "Number with thousand separator",
261
+ },
262
+ render: (args) => {
263
+ const props: typeof args = {
264
+ ...args,
265
+ };
266
+
267
+ return (
268
+ <div className="flex flex-row gap-4 w-full">
269
+ <NumberInput id="1" {...props} size="lg" />
270
+ <NumberInput id="2" {...props} size="md" />
271
+ <NumberInput id="3" {...props} size="sm" />
272
+ </div>
273
+ );
274
+ },
275
+ };
276
+
277
+ export const CurrencyFormat: Story = {
278
+ args: {
279
+ label: "Price",
280
+ formatDisplay: true,
281
+ precision: 2,
282
+ prefix: "$",
283
+ defaultValue: 1230.0,
284
+ min: 0,
285
+ helperText: "Currency format with $ prefix",
286
+ },
287
+ render: (args) => {
288
+ const props: typeof args = {
289
+ ...args,
290
+ };
291
+
292
+ return (
293
+ <div className="flex flex-row gap-4 w-full">
294
+ <NumberInput id="1" {...props} size="lg" />
295
+ <NumberInput id="2" {...props} size="md" />
296
+ <NumberInput id="3" {...props} size="sm" />
297
+ </div>
298
+ );
299
+ },
300
+ };
301
+
302
+ export const CurrencyThailand: Story = {
303
+ args: {
304
+ label: "ราคา",
305
+ formatDisplay: true,
306
+ precision: 2,
307
+ suffix: " ฿",
308
+ defaultValue: 15000.5,
309
+ min: 0,
310
+ helperText: "Thai Baht format",
311
+ },
312
+ render: (args) => {
313
+ const props: typeof args = {
314
+ ...args,
315
+ };
316
+
317
+ return (
318
+ <div className="flex flex-row gap-4 w-full">
319
+ <NumberInput id="1" {...props} size="lg" />
320
+ <NumberInput id="2" {...props} size="md" />
321
+ <NumberInput id="3" {...props} size="sm" />
322
+ </div>
323
+ );
324
+ },
325
+ };
326
+
327
+ export const CustomSeparators: Story = {
328
+ args: {
329
+ label: "European Format",
330
+ formatDisplay: true,
331
+ precision: 2,
332
+ thousandSeparator: ".",
333
+ decimalSeparator: ",",
334
+ defaultValue: 9999.99,
335
+ helperText: "European number format (9.999,99)",
336
+ },
337
+ render: (args) => {
338
+ const props: typeof args = {
339
+ ...args,
340
+ };
341
+
342
+ return (
343
+ <div className="flex flex-row gap-4 w-full">
344
+ <NumberInput id="1" {...props} size="lg" />
345
+ <NumberInput id="2" {...props} size="md" />
346
+ <NumberInput id="3" {...props} size="sm" />
347
+ </div>
348
+ );
349
+ },
350
+ };