@webiny/admin-ui 6.5.0-beta.9 → 6.5.1-beta.0

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 (36) hide show
  1. package/AutoComplete/primitives/AutoCompletePrimitive.d.ts +6 -0
  2. package/AutoComplete/primitives/AutoCompletePrimitive.js +1 -0
  3. package/AutoComplete/primitives/AutoCompletePrimitive.js.map +1 -1
  4. package/DatePicker/DatePicker.stories.d.ts +10 -0
  5. package/DatePicker/DatePicker.stories.js +44 -1
  6. package/DatePicker/DatePicker.stories.js.map +1 -1
  7. package/DatePicker/primitives/BirthdayPicker.d.ts +13 -0
  8. package/DatePicker/primitives/BirthdayPicker.js +355 -0
  9. package/DatePicker/primitives/BirthdayPicker.js.map +1 -0
  10. package/DatePicker/primitives/BirthdayPickerCell.d.ts +14 -0
  11. package/DatePicker/primitives/BirthdayPickerCell.js +19 -0
  12. package/DatePicker/primitives/BirthdayPickerCell.js.map +1 -0
  13. package/DatePicker/primitives/BirthdayPickerSegments.d.ts +9 -0
  14. package/DatePicker/primitives/BirthdayPickerSegments.js +43 -0
  15. package/DatePicker/primitives/BirthdayPickerSegments.js.map +1 -0
  16. package/DatePicker/primitives/DatePickerPrimitive.js +3 -0
  17. package/DatePicker/primitives/DatePickerPrimitive.js.map +1 -1
  18. package/DatePicker/utils/birthdayHelpers.d.ts +77 -0
  19. package/DatePicker/utils/birthdayHelpers.js +145 -0
  20. package/DatePicker/utils/birthdayHelpers.js.map +1 -0
  21. package/DatePicker/utils/birthdayHelpers.test.d.ts +1 -0
  22. package/DatePicker/utils/birthdayHelpers.test.js +394 -0
  23. package/DatePicker/utils/birthdayHelpers.test.js.map +1 -0
  24. package/DatePicker/utils/index.d.ts +1 -0
  25. package/DatePicker/utils/index.js +1 -0
  26. package/DatePicker/utils/types.d.ts +13 -2
  27. package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.d.ts +6 -0
  28. package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js +1 -0
  29. package/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js.map +1 -1
  30. package/Switch/Switch.d.ts +4 -4
  31. package/Switch/Switch.js +21 -7
  32. package/Switch/Switch.js.map +1 -1
  33. package/Switch/domains/SwitchItemDto.d.ts +1 -1
  34. package/Switch/primitives/SwitchPrimitive.js +4 -3
  35. package/Switch/primitives/SwitchPrimitive.js.map +1 -1
  36. package/package.json +18 -18
@@ -0,0 +1,394 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { birthdayYears, daysInMonth, formatBirthdayValue, isDayDisabled, isMonthDisabled, isYearDisabled, nextBirthdayStep, parseBirthdayValue, pickDay, pickMonth, pickYear } from "./birthdayHelpers.js";
3
+ describe("birthdayHelpers", ()=>{
4
+ it("should read the parts of a date-only value", ()=>{
5
+ expect(parseBirthdayValue("1990-02-09")).toEqual({
6
+ day: 9,
7
+ month: 2,
8
+ year: 1990
9
+ });
10
+ });
11
+ it("should read the date part of a value that carries a time", ()=>{
12
+ expect(parseBirthdayValue("1990-02-09T00:00:00.000Z")).toEqual({
13
+ day: 9,
14
+ month: 2,
15
+ year: 1990
16
+ });
17
+ });
18
+ it("should read no parts from an empty or impossible value", ()=>{
19
+ expect(parseBirthdayValue(void 0)).toEqual({});
20
+ expect(parseBirthdayValue("")).toEqual({});
21
+ expect(parseBirthdayValue("not a date")).toEqual({});
22
+ expect(parseBirthdayValue("1990-02-30")).toEqual({});
23
+ });
24
+ it("should write a value only once every part is set", ()=>{
25
+ expect(formatBirthdayValue({
26
+ day: 9,
27
+ month: 2,
28
+ year: 1990
29
+ })).toBe("1990-02-09");
30
+ expect(formatBirthdayValue({
31
+ day: 9,
32
+ month: 2
33
+ })).toBeUndefined();
34
+ });
35
+ it("should give February 29 days until a non-leap year is known", ()=>{
36
+ expect(daysInMonth(2)).toBe(29);
37
+ expect(daysInMonth(2, 2000)).toBe(29);
38
+ expect(daysInMonth(2, 1900)).toBe(28);
39
+ expect(daysInMonth(2, 1990)).toBe(28);
40
+ });
41
+ it("should dim the months that can't hold the 31st", ()=>{
42
+ const dimmed = Array.from({
43
+ length: 12
44
+ }, (_, i)=>i + 1).filter((month)=>isMonthDisabled(month, {
45
+ day: 31
46
+ }));
47
+ expect(dimmed).toEqual([
48
+ 2,
49
+ 4,
50
+ 6,
51
+ 9,
52
+ 11
53
+ ]);
54
+ });
55
+ it("should dim no month before a day is picked", ()=>{
56
+ expect(isMonthDisabled(2, {})).toBe(false);
57
+ });
58
+ it("should clear a month that can't hold the newly picked day and keep the year", ()=>{
59
+ expect(pickDay({
60
+ day: 9,
61
+ month: 2,
62
+ year: 1990
63
+ }, 31)).toEqual({
64
+ day: 31,
65
+ month: void 0,
66
+ year: 1990
67
+ });
68
+ });
69
+ it("should keep a month that holds the newly picked day", ()=>{
70
+ expect(pickDay({
71
+ day: 9,
72
+ month: 8,
73
+ year: 1990
74
+ }, 31)).toEqual({
75
+ day: 31,
76
+ month: 8,
77
+ year: 1990
78
+ });
79
+ });
80
+ it("should clear a non-leap year when 29 February is picked", ()=>{
81
+ expect(pickDay({
82
+ day: 9,
83
+ month: 2,
84
+ year: 1990
85
+ }, 29)).toEqual({
86
+ day: 29,
87
+ month: 2,
88
+ year: void 0
89
+ });
90
+ expect(pickMonth({
91
+ day: 29,
92
+ month: 1,
93
+ year: 1990
94
+ }, 2)).toEqual({
95
+ day: 29,
96
+ month: 2,
97
+ year: void 0
98
+ });
99
+ expect(pickMonth({
100
+ day: 29,
101
+ month: 1,
102
+ year: 1992
103
+ }, 2)).toEqual({
104
+ day: 29,
105
+ month: 2,
106
+ year: 1992
107
+ });
108
+ });
109
+ it("should dim non-leap years for 29 February only", ()=>{
110
+ expect(isYearDisabled(1990, {
111
+ day: 29,
112
+ month: 2
113
+ })).toBe(true);
114
+ expect(isYearDisabled(1992, {
115
+ day: 29,
116
+ month: 2
117
+ })).toBe(false);
118
+ expect(isYearDisabled(1990, {
119
+ day: 28,
120
+ month: 2
121
+ })).toBe(false);
122
+ expect(isYearDisabled(1990, {
123
+ day: 29
124
+ })).toBe(false);
125
+ });
126
+ it("should set the year", ()=>{
127
+ expect(pickYear({
128
+ day: 31,
129
+ month: 8
130
+ }, 1990)).toEqual({
131
+ day: 31,
132
+ month: 8,
133
+ year: 1990
134
+ });
135
+ });
136
+ it("should list years newest first", ()=>{
137
+ expect(birthdayYears([
138
+ 1985,
139
+ 1990
140
+ ])).toEqual([
141
+ 1990,
142
+ 1989,
143
+ 1988,
144
+ 1987,
145
+ 1986,
146
+ 1985
147
+ ]);
148
+ expect(birthdayYears([
149
+ 1990,
150
+ 1985
151
+ ])).toEqual([
152
+ 1990,
153
+ 1989,
154
+ 1988,
155
+ 1987,
156
+ 1986,
157
+ 1985
158
+ ]);
159
+ });
160
+ it("should default to this year back 120 years", ()=>{
161
+ const currentYear = new Date().getFullYear();
162
+ const years = birthdayYears();
163
+ expect(years[0]).toBe(currentYear);
164
+ expect(years[years.length - 1]).toBe(currentYear - 120);
165
+ });
166
+ it("should include a set year that falls outside the range", ()=>{
167
+ expect(birthdayYears([
168
+ 1985,
169
+ 1987
170
+ ], 1980)).toEqual([
171
+ 1987,
172
+ 1986,
173
+ 1985,
174
+ 1984,
175
+ 1983,
176
+ 1982,
177
+ 1981,
178
+ 1980
179
+ ]);
180
+ });
181
+ describe("within minDate and maxDate", ()=>{
182
+ const range = {
183
+ years: birthdayYears([
184
+ 2000,
185
+ 2026
186
+ ]),
187
+ minDate: new Date(2000, 2, 10),
188
+ maxDate: new Date(2026, 9, 15)
189
+ };
190
+ it("should dim the years outside the limits", ()=>{
191
+ const wide = {
192
+ ...range,
193
+ years: birthdayYears([
194
+ 1995,
195
+ 2030
196
+ ])
197
+ };
198
+ expect(isYearDisabled(1999, {}, wide)).toBe(true);
199
+ expect(isYearDisabled(2000, {}, wide)).toBe(false);
200
+ expect(isYearDisabled(2026, {}, wide)).toBe(false);
201
+ expect(isYearDisabled(2027, {}, wide)).toBe(true);
202
+ });
203
+ it("should dim the last year when the picked day and month fall after maxDate", ()=>{
204
+ expect(isYearDisabled(2026, {
205
+ day: 16,
206
+ month: 10
207
+ }, range)).toBe(true);
208
+ expect(isYearDisabled(2026, {
209
+ day: 15,
210
+ month: 10
211
+ }, range)).toBe(false);
212
+ expect(isYearDisabled(2026, {
213
+ day: 1,
214
+ month: 11
215
+ }, range)).toBe(true);
216
+ expect(isYearDisabled(2025, {
217
+ day: 1,
218
+ month: 11
219
+ }, range)).toBe(false);
220
+ });
221
+ it("should dim the first year when the picked day and month fall before minDate", ()=>{
222
+ expect(isYearDisabled(2000, {
223
+ day: 9,
224
+ month: 3
225
+ }, range)).toBe(true);
226
+ expect(isYearDisabled(2000, {
227
+ day: 10,
228
+ month: 3
229
+ }, range)).toBe(false);
230
+ });
231
+ it("should dim the months and days that no date in range has", ()=>{
232
+ const oneYear = {
233
+ ...range,
234
+ years: [
235
+ 2026
236
+ ]
237
+ };
238
+ expect(isMonthDisabled(10, {}, oneYear)).toBe(false);
239
+ expect(isMonthDisabled(11, {}, oneYear)).toBe(true);
240
+ expect(isMonthDisabled(10, {
241
+ day: 16
242
+ }, oneYear)).toBe(true);
243
+ const oneMonth = {
244
+ years: [
245
+ 2026
246
+ ],
247
+ minDate: new Date(2026, 9, 1),
248
+ maxDate: new Date(2026, 9, 15)
249
+ };
250
+ expect(isDayDisabled(15, oneMonth)).toBe(false);
251
+ expect(isDayDisabled(16, oneMonth)).toBe(true);
252
+ expect(isDayDisabled(16, range)).toBe(false);
253
+ });
254
+ it("should keep 29 February when the range offers a leap year", ()=>{
255
+ expect(isMonthDisabled(2, {
256
+ day: 29
257
+ }, range)).toBe(false);
258
+ expect(isMonthDisabled(2, {
259
+ day: 29
260
+ }, {
261
+ ...range,
262
+ years: [
263
+ 2025
264
+ ]
265
+ })).toBe(true);
266
+ });
267
+ it("should clear a year the newly picked part puts past a limit", ()=>{
268
+ expect(pickDay({
269
+ day: 1,
270
+ month: 10,
271
+ year: 2026
272
+ }, 20, range)).toEqual({
273
+ day: 20,
274
+ month: 10,
275
+ year: void 0
276
+ });
277
+ expect(pickMonth({
278
+ day: 1,
279
+ month: 10,
280
+ year: 2026
281
+ }, 12, range)).toEqual({
282
+ day: 1,
283
+ month: 12,
284
+ year: void 0
285
+ });
286
+ expect(pickDay({
287
+ day: 1,
288
+ month: 10,
289
+ year: 2026
290
+ }, 15, range)).toEqual({
291
+ day: 15,
292
+ month: 10,
293
+ year: 2026
294
+ });
295
+ });
296
+ it("should end the default years at maxDate and start them at minDate", ()=>{
297
+ const years = birthdayYears(void 0, void 0, {
298
+ maxDate: new Date(2000, 0, 1)
299
+ });
300
+ expect(years[0]).toBe(2000);
301
+ expect(years[years.length - 1]).toBe(1880);
302
+ expect(birthdayYears(void 0, void 0, {
303
+ minDate: new Date(1990, 0, 1),
304
+ maxDate: new Date(1995, 0, 1)
305
+ })).toEqual([
306
+ 1995,
307
+ 1994,
308
+ 1993,
309
+ 1992,
310
+ 1991,
311
+ 1990
312
+ ]);
313
+ });
314
+ it("should start the default years at a maxDate in the future", ()=>{
315
+ const currentYear = new Date().getFullYear();
316
+ const years = birthdayYears(void 0, void 0, {
317
+ maxDate: new Date(currentYear + 2, 0, 1)
318
+ });
319
+ expect(years[0]).toBe(currentYear + 2);
320
+ expect(years[years.length - 1]).toBe(currentYear + 2 - 120);
321
+ });
322
+ it("should run the default years from this year down to an old minDate", ()=>{
323
+ const currentYear = new Date().getFullYear();
324
+ const years = birthdayYears(void 0, void 0, {
325
+ minDate: new Date(1850, 0, 1)
326
+ });
327
+ expect(years[0]).toBe(currentYear);
328
+ expect(years[years.length - 1]).toBe(1850);
329
+ });
330
+ it("should start the default years at a minDate in the future", ()=>{
331
+ const currentYear = new Date().getFullYear();
332
+ const years = birthdayYears(void 0, void 0, {
333
+ minDate: new Date(currentYear + 3, 0, 1)
334
+ });
335
+ expect(years).toEqual([
336
+ currentYear + 3
337
+ ]);
338
+ });
339
+ it("should ignore an invalid limit", ()=>{
340
+ expect(isYearDisabled(2026, {}, {
341
+ years: [
342
+ 2026
343
+ ],
344
+ maxDate: new Date("nope")
345
+ })).toBe(false);
346
+ });
347
+ });
348
+ it("should go to the next missing part after a pick", ()=>{
349
+ expect(nextBirthdayStep({
350
+ day: 9
351
+ }, "day", new Set([
352
+ "day"
353
+ ]))).toBe("month");
354
+ expect(nextBirthdayStep({
355
+ month: 2,
356
+ year: 1990
357
+ }, "year", new Set([
358
+ "year"
359
+ ]))).toBe("day");
360
+ });
361
+ it("should close once a pick out of order completes the date", ()=>{
362
+ const picked = new Set([
363
+ "year",
364
+ "day",
365
+ "month"
366
+ ]);
367
+ expect(nextBirthdayStep({
368
+ day: 9,
369
+ month: 2,
370
+ year: 1990
371
+ }, "month", picked)).toBe(void 0);
372
+ });
373
+ it("should walk on through the later steps when editing a saved date", ()=>{
374
+ const date = {
375
+ day: 9,
376
+ month: 2,
377
+ year: 1990
378
+ };
379
+ expect(nextBirthdayStep(date, "day", new Set([
380
+ "day"
381
+ ]))).toBe("month");
382
+ expect(nextBirthdayStep(date, "month", new Set([
383
+ "day",
384
+ "month"
385
+ ]))).toBe("year");
386
+ expect(nextBirthdayStep(date, "year", new Set([
387
+ "day",
388
+ "month",
389
+ "year"
390
+ ]))).toBe(void 0);
391
+ });
392
+ });
393
+
394
+ //# sourceMappingURL=birthdayHelpers.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DatePicker/utils/birthdayHelpers.test.js","sources":["../../../src/DatePicker/utils/birthdayHelpers.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport {\n birthdayYears,\n daysInMonth,\n formatBirthdayValue,\n isDayDisabled,\n isMonthDisabled,\n isYearDisabled,\n nextBirthdayStep,\n parseBirthdayValue,\n pickDay,\n pickMonth,\n pickYear\n} from \"./birthdayHelpers.js\";\n\ndescribe(\"birthdayHelpers\", () => {\n it(\"should read the parts of a date-only value\", () => {\n expect(parseBirthdayValue(\"1990-02-09\")).toEqual({ day: 9, month: 2, year: 1990 });\n });\n\n it(\"should read the date part of a value that carries a time\", () => {\n expect(parseBirthdayValue(\"1990-02-09T00:00:00.000Z\")).toEqual({\n day: 9,\n month: 2,\n year: 1990\n });\n });\n\n it(\"should read no parts from an empty or impossible value\", () => {\n expect(parseBirthdayValue(undefined)).toEqual({});\n expect(parseBirthdayValue(\"\")).toEqual({});\n expect(parseBirthdayValue(\"not a date\")).toEqual({});\n expect(parseBirthdayValue(\"1990-02-30\")).toEqual({});\n });\n\n it(\"should write a value only once every part is set\", () => {\n expect(formatBirthdayValue({ day: 9, month: 2, year: 1990 })).toBe(\"1990-02-09\");\n expect(formatBirthdayValue({ day: 9, month: 2 })).toBeUndefined();\n });\n\n it(\"should give February 29 days until a non-leap year is known\", () => {\n expect(daysInMonth(2)).toBe(29);\n expect(daysInMonth(2, 2000)).toBe(29);\n expect(daysInMonth(2, 1900)).toBe(28);\n expect(daysInMonth(2, 1990)).toBe(28);\n });\n\n it(\"should dim the months that can't hold the 31st\", () => {\n const dimmed = Array.from({ length: 12 }, (_, i) => i + 1).filter(month =>\n isMonthDisabled(month, { day: 31 })\n );\n expect(dimmed).toEqual([2, 4, 6, 9, 11]);\n });\n\n it(\"should dim no month before a day is picked\", () => {\n expect(isMonthDisabled(2, {})).toBe(false);\n });\n\n it(\"should clear a month that can't hold the newly picked day and keep the year\", () => {\n expect(pickDay({ day: 9, month: 2, year: 1990 }, 31)).toEqual({\n day: 31,\n month: undefined,\n year: 1990\n });\n });\n\n it(\"should keep a month that holds the newly picked day\", () => {\n expect(pickDay({ day: 9, month: 8, year: 1990 }, 31)).toEqual({\n day: 31,\n month: 8,\n year: 1990\n });\n });\n\n it(\"should clear a non-leap year when 29 February is picked\", () => {\n expect(pickDay({ day: 9, month: 2, year: 1990 }, 29)).toEqual({\n day: 29,\n month: 2,\n year: undefined\n });\n expect(pickMonth({ day: 29, month: 1, year: 1990 }, 2)).toEqual({\n day: 29,\n month: 2,\n year: undefined\n });\n expect(pickMonth({ day: 29, month: 1, year: 1992 }, 2)).toEqual({\n day: 29,\n month: 2,\n year: 1992\n });\n });\n\n it(\"should dim non-leap years for 29 February only\", () => {\n expect(isYearDisabled(1990, { day: 29, month: 2 })).toBe(true);\n expect(isYearDisabled(1992, { day: 29, month: 2 })).toBe(false);\n expect(isYearDisabled(1990, { day: 28, month: 2 })).toBe(false);\n expect(isYearDisabled(1990, { day: 29 })).toBe(false);\n });\n\n it(\"should set the year\", () => {\n expect(pickYear({ day: 31, month: 8 }, 1990)).toEqual({ day: 31, month: 8, year: 1990 });\n });\n\n it(\"should list years newest first\", () => {\n expect(birthdayYears([1985, 1990])).toEqual([1990, 1989, 1988, 1987, 1986, 1985]);\n expect(birthdayYears([1990, 1985])).toEqual([1990, 1989, 1988, 1987, 1986, 1985]);\n });\n\n it(\"should default to this year back 120 years\", () => {\n const currentYear = new Date().getFullYear();\n const years = birthdayYears();\n expect(years[0]).toBe(currentYear);\n expect(years[years.length - 1]).toBe(currentYear - 120);\n });\n\n it(\"should include a set year that falls outside the range\", () => {\n expect(birthdayYears([1985, 1987], 1980)).toEqual([\n 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980\n ]);\n });\n\n describe(\"within minDate and maxDate\", () => {\n const range = {\n years: birthdayYears([2000, 2026]),\n minDate: new Date(2000, 2, 10),\n maxDate: new Date(2026, 9, 15)\n };\n\n it(\"should dim the years outside the limits\", () => {\n const wide = { ...range, years: birthdayYears([1995, 2030]) };\n expect(isYearDisabled(1999, {}, wide)).toBe(true);\n expect(isYearDisabled(2000, {}, wide)).toBe(false);\n expect(isYearDisabled(2026, {}, wide)).toBe(false);\n expect(isYearDisabled(2027, {}, wide)).toBe(true);\n });\n\n it(\"should dim the last year when the picked day and month fall after maxDate\", () => {\n expect(isYearDisabled(2026, { day: 16, month: 10 }, range)).toBe(true);\n expect(isYearDisabled(2026, { day: 15, month: 10 }, range)).toBe(false);\n expect(isYearDisabled(2026, { day: 1, month: 11 }, range)).toBe(true);\n expect(isYearDisabled(2025, { day: 1, month: 11 }, range)).toBe(false);\n });\n\n it(\"should dim the first year when the picked day and month fall before minDate\", () => {\n expect(isYearDisabled(2000, { day: 9, month: 3 }, range)).toBe(true);\n expect(isYearDisabled(2000, { day: 10, month: 3 }, range)).toBe(false);\n });\n\n it(\"should dim the months and days that no date in range has\", () => {\n const oneYear = { ...range, years: [2026] };\n expect(isMonthDisabled(10, {}, oneYear)).toBe(false);\n expect(isMonthDisabled(11, {}, oneYear)).toBe(true);\n expect(isMonthDisabled(10, { day: 16 }, oneYear)).toBe(true);\n\n const oneMonth = {\n years: [2026],\n minDate: new Date(2026, 9, 1),\n maxDate: new Date(2026, 9, 15)\n };\n expect(isDayDisabled(15, oneMonth)).toBe(false);\n expect(isDayDisabled(16, oneMonth)).toBe(true);\n expect(isDayDisabled(16, range)).toBe(false);\n });\n\n it(\"should keep 29 February when the range offers a leap year\", () => {\n expect(isMonthDisabled(2, { day: 29 }, range)).toBe(false);\n expect(isMonthDisabled(2, { day: 29 }, { ...range, years: [2025] })).toBe(true);\n });\n\n it(\"should clear a year the newly picked part puts past a limit\", () => {\n expect(pickDay({ day: 1, month: 10, year: 2026 }, 20, range)).toEqual({\n day: 20,\n month: 10,\n year: undefined\n });\n expect(pickMonth({ day: 1, month: 10, year: 2026 }, 12, range)).toEqual({\n day: 1,\n month: 12,\n year: undefined\n });\n expect(pickDay({ day: 1, month: 10, year: 2026 }, 15, range)).toEqual({\n day: 15,\n month: 10,\n year: 2026\n });\n });\n\n it(\"should end the default years at maxDate and start them at minDate\", () => {\n const years = birthdayYears(undefined, undefined, { maxDate: new Date(2000, 0, 1) });\n expect(years[0]).toBe(2000);\n expect(years[years.length - 1]).toBe(1880);\n expect(\n birthdayYears(undefined, undefined, {\n minDate: new Date(1990, 0, 1),\n maxDate: new Date(1995, 0, 1)\n })\n ).toEqual([1995, 1994, 1993, 1992, 1991, 1990]);\n });\n\n it(\"should start the default years at a maxDate in the future\", () => {\n const currentYear = new Date().getFullYear();\n const years = birthdayYears(undefined, undefined, {\n maxDate: new Date(currentYear + 2, 0, 1)\n });\n expect(years[0]).toBe(currentYear + 2);\n expect(years[years.length - 1]).toBe(currentYear + 2 - 120);\n });\n\n it(\"should run the default years from this year down to an old minDate\", () => {\n const currentYear = new Date().getFullYear();\n const years = birthdayYears(undefined, undefined, { minDate: new Date(1850, 0, 1) });\n expect(years[0]).toBe(currentYear);\n expect(years[years.length - 1]).toBe(1850);\n });\n\n it(\"should start the default years at a minDate in the future\", () => {\n const currentYear = new Date().getFullYear();\n const years = birthdayYears(undefined, undefined, {\n minDate: new Date(currentYear + 3, 0, 1)\n });\n expect(years).toEqual([currentYear + 3]);\n });\n\n it(\"should ignore an invalid limit\", () => {\n expect(isYearDisabled(2026, {}, { years: [2026], maxDate: new Date(\"nope\") })).toBe(\n false\n );\n });\n });\n\n it(\"should go to the next missing part after a pick\", () => {\n expect(nextBirthdayStep({ day: 9 }, \"day\", new Set([\"day\"]))).toBe(\"month\");\n expect(nextBirthdayStep({ month: 2, year: 1990 }, \"year\", new Set([\"year\"]))).toBe(\"day\");\n });\n\n it(\"should close once a pick out of order completes the date\", () => {\n const picked = new Set([\"year\", \"day\", \"month\"] as const);\n expect(nextBirthdayStep({ day: 9, month: 2, year: 1990 }, \"month\", picked)).toBe(undefined);\n });\n\n it(\"should walk on through the later steps when editing a saved date\", () => {\n const date = { day: 9, month: 2, year: 1990 };\n expect(nextBirthdayStep(date, \"day\", new Set([\"day\"]))).toBe(\"month\");\n expect(nextBirthdayStep(date, \"month\", new Set([\"day\", \"month\"]))).toBe(\"year\");\n expect(nextBirthdayStep(date, \"year\", new Set([\"day\", \"month\", \"year\"]))).toBe(undefined);\n });\n});\n"],"names":["describe","it","expect","parseBirthdayValue","undefined","formatBirthdayValue","daysInMonth","dimmed","Array","_","i","month","isMonthDisabled","pickDay","pickMonth","isYearDisabled","pickYear","birthdayYears","currentYear","Date","years","range","wide","oneYear","oneMonth","isDayDisabled","nextBirthdayStep","Set","picked","date"],"mappings":";;AAeAA,SAAS,mB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AOwB,iBAAiBG,MAAM,QAAQ,IAAIF,IAAI;YAAC;YAAO;YAAS;SAAO,IAAI,IAAI,CAACvB;IACnF;AACJ"}
@@ -1,3 +1,4 @@
1
1
  export * from "./types.js";
2
2
  export * from "./dateHelpers.js";
3
3
  export * from "./constants.js";
4
+ export * from "./birthdayHelpers.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./types.js";
2
2
  export * from "./dateHelpers.js";
3
3
  export * from "./constants.js";
4
+ export * from "./birthdayHelpers.js";
@@ -23,6 +23,17 @@ interface DateOnlyPickerProps extends DatePickerBaseProps {
23
23
  onChange?: (value: string | undefined) => void;
24
24
  presets?: DatePickerPreset[];
25
25
  }
26
+ /**
27
+ * Picks a date as day, then month, then year. The value is a `YYYY-MM-DD` string, the same as
28
+ * the `date` picker's. `yearRange` sets the years offered. By default they run from `maxDate`'s
29
+ * year (or this year) down to `minDate`'s year (or 120 years back). Days, months and years that
30
+ * can't make a date between `minDate` and `maxDate` can't be picked.
31
+ */
32
+ interface BirthdayPickerProps extends DatePickerBaseProps {
33
+ type: "birthday";
34
+ value?: string;
35
+ onChange?: (value: string | undefined) => void;
36
+ }
26
37
  interface TimeOnlyPickerProps extends DatePickerBaseProps {
27
38
  type: "time";
28
39
  value?: string;
@@ -79,5 +90,5 @@ interface MultipleYearsPickerProps extends DatePickerBaseProps {
79
90
  value?: number[];
80
91
  onChange?: (value: number[]) => void;
81
92
  }
82
- type DatePickerPrimitiveProps = DateOnlyPickerProps | TimeOnlyPickerProps | DateTimeLocalPickerProps | DateTimeTzPickerProps | MonthPickerProps | WeekPickerProps | YearPickerProps | DateRangePickerProps | MultipleDatesPickerProps | MultipleMonthsPickerProps | MultipleYearsPickerProps;
83
- export { type DatePickerPreset, type DatePickerBaseProps, type DatePickerPrimitiveProps, type DateOnlyPickerProps, type TimeOnlyPickerProps, type DateTimeLocalPickerProps, type DateTimeTzPickerProps, type MonthPickerProps, type WeekPickerProps, type YearPickerProps, type DateRangePickerProps, type MultipleDatesPickerProps, type MultipleMonthsPickerProps, type MultipleYearsPickerProps };
93
+ type DatePickerPrimitiveProps = DateOnlyPickerProps | BirthdayPickerProps | TimeOnlyPickerProps | DateTimeLocalPickerProps | DateTimeTzPickerProps | MonthPickerProps | WeekPickerProps | YearPickerProps | DateRangePickerProps | MultipleDatesPickerProps | MultipleMonthsPickerProps | MultipleYearsPickerProps;
94
+ export { type DatePickerPreset, type DatePickerBaseProps, type DatePickerPrimitiveProps, type DateOnlyPickerProps, type BirthdayPickerProps, type TimeOnlyPickerProps, type DateTimeLocalPickerProps, type DateTimeTzPickerProps, type MonthPickerProps, type WeekPickerProps, type YearPickerProps, type DateRangePickerProps, type MultipleDatesPickerProps, type MultipleMonthsPickerProps, type MultipleYearsPickerProps };
@@ -82,6 +82,12 @@ interface MultiAutoCompletePrimitiveProps {
82
82
  * Custom renderer for the selected options.
83
83
  */
84
84
  selectedOptionRenderer?: (item: any, index: number) => React.ReactNode;
85
+ /**
86
+ * Filter the options by the typed text on the client. Defaults to `true`.
87
+ * Set to `false` when `onValueSearch` already returns the matching options,
88
+ * so options matched on data other than their label are not dropped.
89
+ */
90
+ shouldFilter?: boolean;
85
91
  /**
86
92
  * Icon to be displayed at the start of the input field.
87
93
  */
@@ -35,6 +35,7 @@ const DecoratableMultiAutoCompletePrimitive = (props)=>{
35
35
  onOpenChange: ()=>setListOpenState(true)
36
36
  }, /*#__PURE__*/ react.createElement(Command, {
37
37
  label: String(props.label),
38
+ shouldFilter: props.shouldFilter,
38
39
  onKeyDown: handleKeyDown
39
40
  }, /*#__PURE__*/ react.createElement(PopoverPrimitive.Trigger, {
40
41
  asChild: true
@@ -1 +1 @@
1
- {"version":3,"file":"MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js","sources":["../../../src/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.tsx"],"sourcesContent":["import type { KeyboardEvent } from \"react\";\nimport React from \"react\";\nimport { Command } from \"~/Command/index.js\";\nimport { PopoverPrimitive } from \"~/Popover/index.js\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport { useMultiAutoComplete } from \"./useMultiAutoComplete.js\";\nimport {\n MultiAutoCompleteInput,\n MultiAutoCompleteInputIcons,\n MultiAutoCompleteList\n} from \"./components/index.js\";\nimport type { MultiAutoCompleteOption } from \"../domains/index.js\";\nimport type { Icon } from \"~/Icon/index.js\";\n\ninterface MultiAutoCompletePrimitiveProps {\n /**\n * Allows free input of values not present in the options.\n */\n allowFreeInput?: boolean;\n /**\n * Indicates if the reset action should be displayed.\n */\n displayResetAction?: boolean;\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Message to display when there are no options.\n */\n emptyMessage?: React.ReactNode;\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Message to display when there are no options loaded or selected.\n * Use it to invite the user to interact with the autocomplete by typing a value.\n */\n initialMessage?: React.ReactNode;\n /**\n * Reference to the input element.\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Accessible label for the command menu. Not shown visibly.\n */\n label?: React.ReactNode;\n /**\n * Indicates if the autocomplete is loading options.\n */\n loading?: boolean;\n /**\n * Message to display while loading options.\n */\n loadingMessage?: React.ReactNode;\n /**\n * Callback triggered when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Callback triggered when a value has been searched by the user.\n */\n onValueSearch?: (value: string) => void;\n /**\n * Callback triggered when the values change.\n */\n onValuesChange: (values: string[]) => void;\n /**\n * Callback triggered to reset the values.\n */\n onValuesReset?: () => void;\n /**\n * List of options for the autocomplete.\n */\n options?: MultiAutoCompleteOption[];\n /**\n * Custom renderer for the options.\n */\n optionRenderer?: (item: any, index: number) => React.ReactNode;\n /**\n * Placeholder text for the input field.\n */\n placeholder?: string;\n /**\n * Size of the input field.\n * Refer to `InputPrimitiveProps[\"size\"]` for possible values.\n */\n size?: InputPrimitiveProps[\"size\"];\n /**\n * Custom renderer for the selected options.\n */\n selectedOptionRenderer?: (item: any, index: number) => React.ReactNode;\n /**\n * Icon to be displayed at the start of the input field.\n */\n startIcon?: React.ReactElement<typeof Icon> | React.ReactElement;\n /**\n * Ensures that each value is unique.\n */\n uniqueValues?: boolean;\n /**\n * Variant of the input field.\n * Refer to `InputPrimitiveProps[\"variant\"]` for possible values.\n */\n variant?: InputPrimitiveProps[\"variant\"];\n /**\n * Optional selected items.\n */\n values?: string[];\n}\n\nconst DecoratableMultiAutoCompletePrimitive = (props: MultiAutoCompletePrimitiveProps) => {\n const {\n vm,\n setListOpenState,\n setSelectedOption,\n searchOption,\n removeSelectedOption,\n resetSelectedOptions,\n createOption\n } = useMultiAutoComplete(props);\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (props.disabled) {\n return;\n }\n\n if (!vm.optionsListVm.open) {\n setListOpenState(true);\n }\n\n if (event.key.toLowerCase() === \"escape\") {\n setListOpenState(false);\n }\n },\n [props.disabled, setListOpenState, setSelectedOption, vm.optionsListVm.open]\n );\n\n const handleSelectOption = React.useCallback(\n (value: string) => {\n setSelectedOption(value);\n setListOpenState(false);\n },\n [setSelectedOption, setListOpenState]\n );\n\n const handleCreateOption = React.useCallback(\n (value: string) => {\n createOption(value);\n setListOpenState(false);\n },\n [createOption, setListOpenState]\n );\n\n return (\n <PopoverPrimitive open={vm.optionsListVm.open} onOpenChange={() => setListOpenState(true)}>\n <Command label={String(props.label)} onKeyDown={handleKeyDown}>\n <PopoverPrimitive.Trigger asChild>\n <span>\n <MultiAutoCompleteInput\n inputRef={props.inputRef}\n value={vm.inputVm.value}\n placeholder={vm.inputVm.placeholder}\n changeValue={searchOption}\n closeList={() => setListOpenState(false)}\n openList={() => setListOpenState(true)}\n variant={props.variant}\n size={props.size}\n invalid={props.invalid}\n removeSelectedOption={removeSelectedOption}\n selectedOptionRenderer={props.selectedOptionRenderer}\n selectedOptions={vm.selectedOptionsVm.options}\n disabled={props.disabled}\n startIcon={props.startIcon}\n endIcon={\n <MultiAutoCompleteInputIcons\n inputSize={props.size}\n inputVariant={props.variant}\n displayResetAction={\n !vm.selectedOptionsVm.empty && vm.inputVm.displayResetAction\n }\n disabled={props.disabled}\n loading={props.loading}\n onResetValue={resetSelectedOptions}\n onOpenChange={() => setListOpenState(!vm.optionsListVm.open)}\n />\n }\n />\n </span>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content\n style={{ width: \"var(--radix-popover-trigger-width)\" }}\n onOpenAutoFocus={e => e.preventDefault()}\n >\n <MultiAutoCompleteList\n emptyMessage={vm.optionsListVm.emptyMessage}\n empty={vm.optionsListVm.empty}\n loading={props.loading}\n loadingMessage={vm.optionsListVm.loadingMessage}\n onOptionCreate={handleCreateOption}\n onOptionSelect={handleSelectOption}\n optionRenderer={props.optionRenderer}\n options={vm.optionsListVm.options}\n temporaryOption={vm.temporaryOptionVm.option}\n />\n </PopoverPrimitive.Content>\n </Command>\n </PopoverPrimitive>\n );\n};\n\nconst MultiAutoCompletePrimitive = makeDecoratable(\n \"MultiAutoCompletePrimitive\",\n DecoratableMultiAutoCompletePrimitive\n);\n\nexport { MultiAutoCompletePrimitive, type MultiAutoCompletePrimitiveProps };\n"],"names":["DecoratableMultiAutoCompletePrimitive","props","vm","setListOpenState","setSelectedOption","searchOption","removeSelectedOption","resetSelectedOptions","createOption","useMultiAutoComplete","handleKeyDown","React","event","handleSelectOption","value","handleCreateOption","PopoverPrimitive","Command","String","MultiAutoCompleteInput","MultiAutoCompleteInputIcons","e","MultiAutoCompleteList","MultiAutoCompletePrimitive","makeDecoratable"],"mappings":";;;;;;AAkHA,MAAMA,wCAAwC,CAACC;IAC3C,MAAM,EACFC,EAAE,EACFC,gBAAgB,EAChBC,iBAAiB,EACjBC,YAAY,EACZC,oBAAoB,EACpBC,oBAAoB,EACpBC,YAAY,EACf,GAAGC,qBAAqBR;IAEzB,MAAMS,gBAAg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,GAAG,iBAAiB,CAAC,KAAK,IAAIA,GAAG,OAAO,CAAC,kBAAkB;YAEhE,UAAUD,MAAM,QAAQ;YACxB,SAASA,MAAM,OAAO;YACtB,cAAcM;YACd,cAAc,IAAMJ,iBAAiB,CAACD,GAAG,aAAa,CAAC,IAAI;;wBAM/E,oBAACc,iBAAiB,OAAO;QACrB,OAAO;YAAE,OAAO;QAAqC;QACrD,iBAAiBK,CAAAA,IAAKA,EAAE,cAAc;qBAEtC,oBAACC,uBAAqBA;QAClB,cAAcpB,GAAG,aAAa,CAAC,YAAY;QAC3C,OAAOA,GAAG,aAAa,CAAC,KAAK;QAC7B,SAASD,MAAM,OAAO;QACtB,gBAAgBC,GAAG,aAAa,CAAC,cAAc;QAC/C,gBAAgBa;QAChB,gBAAgBF;QAChB,gBAAgBZ,MAAM,cAAc;QACpC,SAASC,GAAG,aAAa,CAAC,OAAO;QACjC,iBAAiBA,GAAG,iBAAiB,CAAC,MAAM;;AAMpE;AAEA,MAAMqB,6BAA6BC,gBAC/B,8BACAxB"}
1
+ {"version":3,"file":"MultiAutoComplete/primitives/MultiAutoCompletePrimitive.js","sources":["../../../src/MultiAutoComplete/primitives/MultiAutoCompletePrimitive.tsx"],"sourcesContent":["import type { KeyboardEvent } from \"react\";\nimport React from \"react\";\nimport { Command } from \"~/Command/index.js\";\nimport { PopoverPrimitive } from \"~/Popover/index.js\";\nimport type { InputPrimitiveProps } from \"~/Input/index.js\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport { useMultiAutoComplete } from \"./useMultiAutoComplete.js\";\nimport {\n MultiAutoCompleteInput,\n MultiAutoCompleteInputIcons,\n MultiAutoCompleteList\n} from \"./components/index.js\";\nimport type { MultiAutoCompleteOption } from \"../domains/index.js\";\nimport type { Icon } from \"~/Icon/index.js\";\n\ninterface MultiAutoCompletePrimitiveProps {\n /**\n * Allows free input of values not present in the options.\n */\n allowFreeInput?: boolean;\n /**\n * Indicates if the reset action should be displayed.\n */\n displayResetAction?: boolean;\n /**\n * Indicates if the field is disabled.\n */\n disabled?: boolean;\n /**\n * Message to display when there are no options.\n */\n emptyMessage?: React.ReactNode;\n /**\n * Indicates if the input field is invalid.\n * Refer to `InputPrimitiveProps[\"invalid\"]` for possible values.\n */\n invalid?: InputPrimitiveProps[\"invalid\"];\n /**\n * Message to display when there are no options loaded or selected.\n * Use it to invite the user to interact with the autocomplete by typing a value.\n */\n initialMessage?: React.ReactNode;\n /**\n * Reference to the input element.\n */\n inputRef?: React.Ref<HTMLInputElement>;\n /**\n * Accessible label for the command menu. Not shown visibly.\n */\n label?: React.ReactNode;\n /**\n * Indicates if the autocomplete is loading options.\n */\n loading?: boolean;\n /**\n * Message to display while loading options.\n */\n loadingMessage?: React.ReactNode;\n /**\n * Callback triggered when the open state changes.\n */\n onOpenChange?: (open: boolean) => void;\n /**\n * Callback triggered when a value has been searched by the user.\n */\n onValueSearch?: (value: string) => void;\n /**\n * Callback triggered when the values change.\n */\n onValuesChange: (values: string[]) => void;\n /**\n * Callback triggered to reset the values.\n */\n onValuesReset?: () => void;\n /**\n * List of options for the autocomplete.\n */\n options?: MultiAutoCompleteOption[];\n /**\n * Custom renderer for the options.\n */\n optionRenderer?: (item: any, index: number) => React.ReactNode;\n /**\n * Placeholder text for the input field.\n */\n placeholder?: string;\n /**\n * Size of the input field.\n * Refer to `InputPrimitiveProps[\"size\"]` for possible values.\n */\n size?: InputPrimitiveProps[\"size\"];\n /**\n * Custom renderer for the selected options.\n */\n selectedOptionRenderer?: (item: any, index: number) => React.ReactNode;\n /**\n * Filter the options by the typed text on the client. Defaults to `true`.\n * Set to `false` when `onValueSearch` already returns the matching options,\n * so options matched on data other than their label are not dropped.\n */\n shouldFilter?: boolean;\n /**\n * Icon to be displayed at the start of the input field.\n */\n startIcon?: React.ReactElement<typeof Icon> | React.ReactElement;\n /**\n * Ensures that each value is unique.\n */\n uniqueValues?: boolean;\n /**\n * Variant of the input field.\n * Refer to `InputPrimitiveProps[\"variant\"]` for possible values.\n */\n variant?: InputPrimitiveProps[\"variant\"];\n /**\n * Optional selected items.\n */\n values?: string[];\n}\n\nconst DecoratableMultiAutoCompletePrimitive = (props: MultiAutoCompletePrimitiveProps) => {\n const {\n vm,\n setListOpenState,\n setSelectedOption,\n searchOption,\n removeSelectedOption,\n resetSelectedOptions,\n createOption\n } = useMultiAutoComplete(props);\n\n const handleKeyDown = React.useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (props.disabled) {\n return;\n }\n\n if (!vm.optionsListVm.open) {\n setListOpenState(true);\n }\n\n if (event.key.toLowerCase() === \"escape\") {\n setListOpenState(false);\n }\n },\n [props.disabled, setListOpenState, setSelectedOption, vm.optionsListVm.open]\n );\n\n const handleSelectOption = React.useCallback(\n (value: string) => {\n setSelectedOption(value);\n setListOpenState(false);\n },\n [setSelectedOption, setListOpenState]\n );\n\n const handleCreateOption = React.useCallback(\n (value: string) => {\n createOption(value);\n setListOpenState(false);\n },\n [createOption, setListOpenState]\n );\n\n return (\n <PopoverPrimitive open={vm.optionsListVm.open} onOpenChange={() => setListOpenState(true)}>\n <Command\n label={String(props.label)}\n shouldFilter={props.shouldFilter}\n onKeyDown={handleKeyDown}\n >\n <PopoverPrimitive.Trigger asChild>\n <span>\n <MultiAutoCompleteInput\n inputRef={props.inputRef}\n value={vm.inputVm.value}\n placeholder={vm.inputVm.placeholder}\n changeValue={searchOption}\n closeList={() => setListOpenState(false)}\n openList={() => setListOpenState(true)}\n variant={props.variant}\n size={props.size}\n invalid={props.invalid}\n removeSelectedOption={removeSelectedOption}\n selectedOptionRenderer={props.selectedOptionRenderer}\n selectedOptions={vm.selectedOptionsVm.options}\n disabled={props.disabled}\n startIcon={props.startIcon}\n endIcon={\n <MultiAutoCompleteInputIcons\n inputSize={props.size}\n inputVariant={props.variant}\n displayResetAction={\n !vm.selectedOptionsVm.empty && vm.inputVm.displayResetAction\n }\n disabled={props.disabled}\n loading={props.loading}\n onResetValue={resetSelectedOptions}\n onOpenChange={() => setListOpenState(!vm.optionsListVm.open)}\n />\n }\n />\n </span>\n </PopoverPrimitive.Trigger>\n <PopoverPrimitive.Content\n style={{ width: \"var(--radix-popover-trigger-width)\" }}\n onOpenAutoFocus={e => e.preventDefault()}\n >\n <MultiAutoCompleteList\n emptyMessage={vm.optionsListVm.emptyMessage}\n empty={vm.optionsListVm.empty}\n loading={props.loading}\n loadingMessage={vm.optionsListVm.loadingMessage}\n onOptionCreate={handleCreateOption}\n onOptionSelect={handleSelectOption}\n optionRenderer={props.optionRenderer}\n options={vm.optionsListVm.options}\n temporaryOption={vm.temporaryOptionVm.option}\n />\n </PopoverPrimitive.Content>\n </Command>\n </PopoverPrimitive>\n );\n};\n\nconst MultiAutoCompletePrimitive = makeDecoratable(\n \"MultiAutoCompletePrimitive\",\n DecoratableMultiAutoCompletePrimitive\n);\n\nexport { MultiAutoCompletePrimitive, type MultiAutoCompletePrimitiveProps };\n"],"names":["DecoratableMultiAutoCompletePrimitive","props","vm","setListOpenState","setSelectedOption","searchOption","removeSelectedOption","resetSelectedOptions","createOption","useMultiAutoComplete","handleKeyDown","React","event","handleSelectOption","value","handleCreateOption","PopoverPrimitive","Command","String","MultiAutoCompleteInput","MultiAutoCompleteInputIcons","e","MultiAutoCompleteList","MultiAutoCompletePrimitive","makeDecoratable"],"mappings":";;;;;;AAwHA,MAAMA,wCAAwC,CAACC;IAC3C,MAAM,EACFC,EAAE,EACFC,gBAAgB,EAChBC,iBAAiB,EACjBC,YAAY,EACZC,oBAAoB,EACpBC,oBAAoB,EACpBC,YAAY,EACf,GAAGC,qBAAqBR;IAEzB,MAAMS,gBAAgBC,MAAAA,WAAiB,CACnC,CAACC;QACG,IAAIX,MAAM,QAAQ,EACd;QAGJ,IAAI,CAACC,GAAG,aAAa,CAAC,IAAI,EACtBC,iBAAiB;QAGrB,IAAIS,AAA4B,aAA5BA,MAAM,GAAG,CAAC,WAAW,IACrBT,iBAAiB;IAEzB,GACA;QAACF,MAAM,QAAQ;QAAEE;QAAkBC;QAAmB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rB,OAAO;YAAE,OAAO;QAAqC;QACrD,iBAAiBK,CAAAA,IAAKA,EAAE,cAAc;qBAEtC,oBAACC,uBAAqBA;QAClB,cAAcpB,GAAG,aAAa,CAAC,YAAY;QAC3C,OAAOA,GAAG,aAAa,CAAC,KAAK;QAC7B,SAASD,MAAM,OAAO;QACtB,gBAAgBC,GAAG,aAAa,CAAC,cAAc;QAC/C,gBAAgBa;QAChB,gBAAgBF;QAChB,gBAAgBZ,MAAM,cAAc;QACpC,SAASC,GAAG,aAAa,CAAC,OAAO;QACjC,iBAAiBA,GAAG,iBAAiB,CAAC,MAAM;;AAMpE;AAEA,MAAMqB,6BAA6BC,gBAC/B,8BACAxB"}
@@ -1,8 +1,8 @@
1
1
  import React from "react";
2
2
  import type { SwitchPrimitiveProps } from "./primitives/index.js";
3
- import type { FormComponentProps } from "../FormComponent/index.js";
4
- type SwitchProps = SwitchPrimitiveProps & FormComponentProps;
5
- declare const DecoratableSwitch: ({ note, validation, ...props }: SwitchProps) => React.JSX.Element;
3
+ import { type FormComponentProps } from "../FormComponent/index.js";
4
+ type SwitchProps = Omit<SwitchPrimitiveProps, "label"> & FormComponentProps;
5
+ declare const DecoratableSwitch: ({ label, description, hint, note, required, disabled, validation, ...props }: SwitchProps) => React.JSX.Element;
6
6
  declare const Switch: typeof DecoratableSwitch & {
7
7
  original: typeof DecoratableSwitch;
8
8
  originalName: string;
@@ -22,4 +22,4 @@ declare const Switch: typeof DecoratableSwitch & {
22
22
  displayName: string;
23
23
  }>) => (props: unknown) => React.JSX.Element;
24
24
  };
25
- export { Switch };
25
+ export { Switch, type SwitchProps };
package/Switch/Switch.js CHANGED
@@ -1,24 +1,38 @@
1
1
  import react, { useMemo } from "react";
2
- import { makeDecoratable } from "../utils.js";
2
+ import { generateId, makeDecoratable } from "../utils.js";
3
3
  import { SwitchPrimitive } from "./primitives/index.js";
4
- import { FormComponentErrorMessage, FormComponentNote } from "../FormComponent/index.js";
5
- const DecoratableSwitch = ({ note, validation, ...props })=>{
4
+ import { FormComponentDescription, FormComponentErrorMessage, FormComponentLabel, FormComponentNote } from "../FormComponent/index.js";
5
+ const DecoratableSwitch = ({ label, description, hint, note, required, disabled, validation, ...props })=>{
6
6
  const { isValid: validationIsValid, message: validationMessage } = validation || {};
7
+ const id = useMemo(()=>generateId(props.id), [
8
+ props.id
9
+ ]);
7
10
  const invalid = useMemo(()=>false === validationIsValid, [
8
11
  validationIsValid
9
12
  ]);
10
13
  return /*#__PURE__*/ react.createElement("div", {
11
14
  className: "w-full"
12
- }, /*#__PURE__*/ react.createElement(SwitchPrimitive, {
15
+ }, /*#__PURE__*/ react.createElement(FormComponentLabel, {
16
+ htmlFor: id,
17
+ text: label,
18
+ required: required,
19
+ disabled: disabled,
20
+ invalid: invalid,
21
+ hint: hint
22
+ }), /*#__PURE__*/ react.createElement(FormComponentDescription, {
23
+ text: description,
24
+ disabled: disabled
25
+ }), /*#__PURE__*/ react.createElement(SwitchPrimitive, {
13
26
  ...props,
14
- disabled: props.disabled
27
+ id: id,
28
+ disabled: disabled
15
29
  }), /*#__PURE__*/ react.createElement(FormComponentErrorMessage, {
16
30
  text: validationMessage,
17
31
  invalid: invalid,
18
- disabled: props.disabled
32
+ disabled: disabled
19
33
  }), /*#__PURE__*/ react.createElement(FormComponentNote, {
20
34
  text: note,
21
- disabled: props.disabled
35
+ disabled: disabled
22
36
  }));
23
37
  };
24
38
  const Switch = makeDecoratable("Switch", DecoratableSwitch);
@@ -1 +1 @@
1
- {"version":3,"file":"Switch/Switch.js","sources":["../../src/Switch/Switch.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { makeDecoratable } from \"~/utils.js\";\nimport type { SwitchPrimitiveProps } from \"./primitives/index.js\";\nimport { SwitchPrimitive } from \"./primitives/index.js\";\nimport type { FormComponentProps } from \"~/FormComponent/index.js\";\nimport { FormComponentErrorMessage, FormComponentNote } from \"~/FormComponent/index.js\";\n\ntype SwitchProps = SwitchPrimitiveProps & FormComponentProps;\n\nconst DecoratableSwitch = ({ note, validation, ...props }: SwitchProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n\n return (\n <div className={\"w-full\"}>\n <SwitchPrimitive {...props} disabled={props.disabled} />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={props.disabled}\n />\n <FormComponentNote text={note} disabled={props.disabled} />\n </div>\n );\n};\n\nconst Switch = makeDecoratable(\"Switch\", DecoratableSwitch);\n\nexport { Switch };\n"],"names":["DecoratableSwitch","note","validation","props","validationIsValid","validationMessage","invalid","useMemo","SwitchPrimitive","FormComponentErrorMessage","FormComponentNote","Switch","makeDecoratable"],"mappings":";;;;AASA,MAAMA,oBAAoB,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAE,GAAGC,OAAoB;IAClE,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGH,cAAc,CAAC;IAClF,MAAMI,UAAUC,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACI,iBAAeA;QAAE,GAAGL,KAAK;QAAE,UAAUA,MAAM,QAAQ;sBACpD,oBAACM,2BAAyBA;QACtB,MAAMJ;QACN,SAASC;QACT,UAAUH,MAAM,QAAQ;sBAE5B,oBAACO,mBAAiBA;QAAC,MAAMT;QAAM,UAAUE,MAAM,QAAQ;;AAGnE;AAEA,MAAMQ,SAASC,gBAAgB,UAAUZ"}
1
+ {"version":3,"file":"Switch/Switch.js","sources":["../../src/Switch/Switch.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { generateId, makeDecoratable } from \"~/utils.js\";\nimport type { SwitchPrimitiveProps } from \"./primitives/index.js\";\nimport { SwitchPrimitive } from \"./primitives/index.js\";\nimport {\n FormComponentDescription,\n FormComponentErrorMessage,\n FormComponentLabel,\n FormComponentNote,\n type FormComponentProps\n} from \"~/FormComponent/index.js\";\n\ntype SwitchProps = Omit<SwitchPrimitiveProps, \"label\"> & FormComponentProps;\n\nconst DecoratableSwitch = ({\n label,\n description,\n hint,\n note,\n required,\n disabled,\n validation,\n ...props\n}: SwitchProps) => {\n const { isValid: validationIsValid, message: validationMessage } = validation || {};\n const id = useMemo(() => generateId(props.id), [props.id]);\n const invalid = useMemo(() => validationIsValid === false, [validationIsValid]);\n\n return (\n <div className={\"w-full\"}>\n <FormComponentLabel\n htmlFor={id}\n text={label}\n required={required}\n disabled={disabled}\n invalid={invalid}\n hint={hint}\n />\n <FormComponentDescription text={description} disabled={disabled} />\n <SwitchPrimitive {...props} id={id} disabled={disabled} />\n <FormComponentErrorMessage\n text={validationMessage}\n invalid={invalid}\n disabled={disabled}\n />\n <FormComponentNote text={note} disabled={disabled} />\n </div>\n );\n};\n\nconst Switch = makeDecoratable(\"Switch\", DecoratableSwitch);\n\nexport { Switch, type SwitchProps };\n"],"names":["DecoratableSwitch","label","description","hint","note","required","disabled","validation","props","validationIsValid","validationMessage","id","useMemo","generateId","invalid","FormComponentLabel","FormComponentDescription","SwitchPrimitive","FormComponentErrorMessage","FormComponentNote","Switch","makeDecoratable"],"mappings":";;;;AAcA,MAAMA,oBAAoB,CAAC,EACvBC,KAAK,EACLC,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,QAAQ,EACRC,QAAQ,EACRC,UAAU,EACV,GAAGC,OACO;IACV,MAAM,EAAE,SAASC,iBAAiB,EAAE,SAASC,iBAAiB,EAAE,GAAGH,cAAc,CAAC;IAClF,MAAMI,KAAKC,QAAQ,IAAMC,WAAWL,MAAM,EAAE,GAAG;QAACA,MAAM,EAAE;KAAC;IACzD,MAAMM,UAAUF,QAAQ,IAAMH,AAAsB,UAAtBA,mBAA6B;QAACA;KAAkB;IAE9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAW;qBACZ,oBAACM,oBAAkBA;QACf,SAASJ;QACT,MAAMV;QACN,UAAUI;QACV,UAAUC;QACV,SAASQ;QACT,MAAMX;sBAEV,oBAACa,0BAAwBA;QAAC,MAAMd;QAAa,UAAUI;sBACvD,oBAACW,iBAAeA;QAAE,GAAGT,KAAK;QAAE,IAAIG;QAAI,UAAUL;sBAC9C,oBAACY,2BAAyBA;QACtB,MAAMR;QACN,SAASI;QACT,UAAUR;sBAEd,oBAACa,mBAAiBA;QAAC,MAAMf;QAAM,UAAUE;;AAGrD;AAEA,MAAMc,SAASC,gBAAgB,UAAUrB"}
@@ -1,7 +1,7 @@
1
1
  import type React from "react";
2
2
  export interface SwitchItemDto {
3
3
  id?: string;
4
- label: React.ReactNode;
4
+ label?: React.ReactNode;
5
5
  value?: number | string | boolean;
6
6
  checked?: boolean;
7
7
  disabled?: boolean;