@craftzbay/ui 0.11.2 → 0.11.4

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 (164) hide show
  1. package/dist-lib/_virtual/_rolldown/runtime.js +11 -0
  2. package/dist-lib/components/ui/Accordion.js +42 -67
  3. package/dist-lib/components/ui/Accordion.js.map +1 -1
  4. package/dist-lib/components/ui/Alert.js +71 -77
  5. package/dist-lib/components/ui/Alert.js.map +1 -1
  6. package/dist-lib/components/ui/Avatar.js +67 -92
  7. package/dist-lib/components/ui/Avatar.js.map +1 -1
  8. package/dist-lib/components/ui/Badge.js +119 -74
  9. package/dist-lib/components/ui/Badge.js.map +1 -1
  10. package/dist-lib/components/ui/Breadcrumbs.js +62 -50
  11. package/dist-lib/components/ui/Breadcrumbs.js.map +1 -1
  12. package/dist-lib/components/ui/Button.js +129 -127
  13. package/dist-lib/components/ui/Button.js.map +1 -1
  14. package/dist-lib/components/ui/Calendar.d.ts +1 -1
  15. package/dist-lib/components/ui/Calendar.js +99 -136
  16. package/dist-lib/components/ui/Calendar.js.map +1 -1
  17. package/dist-lib/components/ui/Card.js +88 -94
  18. package/dist-lib/components/ui/Card.js.map +1 -1
  19. package/dist-lib/components/ui/Carousel.js +125 -170
  20. package/dist-lib/components/ui/Carousel.js.map +1 -1
  21. package/dist-lib/components/ui/Chart.d.ts +3 -3
  22. package/dist-lib/components/ui/Chart.js +435 -464
  23. package/dist-lib/components/ui/Chart.js.map +1 -1
  24. package/dist-lib/components/ui/Checkbox.js +60 -69
  25. package/dist-lib/components/ui/Checkbox.js.map +1 -1
  26. package/dist-lib/components/ui/Combobox.js +179 -192
  27. package/dist-lib/components/ui/Combobox.js.map +1 -1
  28. package/dist-lib/components/ui/CommandPalette.d.ts +2 -2
  29. package/dist-lib/components/ui/CommandPalette.js +106 -167
  30. package/dist-lib/components/ui/CommandPalette.js.map +1 -1
  31. package/dist-lib/components/ui/ContextMenu.d.ts +1 -1
  32. package/dist-lib/components/ui/ContextMenu.js +89 -154
  33. package/dist-lib/components/ui/ContextMenu.js.map +1 -1
  34. package/dist-lib/components/ui/DataGrid.d.ts +1 -1
  35. package/dist-lib/components/ui/DataGrid.js +99 -96
  36. package/dist-lib/components/ui/DataGrid.js.map +1 -1
  37. package/dist-lib/components/ui/DatePicker.js +151 -188
  38. package/dist-lib/components/ui/DatePicker.js.map +1 -1
  39. package/dist-lib/components/ui/DesignSystemProvider.d.ts +1 -1
  40. package/dist-lib/components/ui/DesignSystemProvider.js +120 -130
  41. package/dist-lib/components/ui/DesignSystemProvider.js.map +1 -1
  42. package/dist-lib/components/ui/Dialog.d.ts +3 -3
  43. package/dist-lib/components/ui/Dialog.js +108 -156
  44. package/dist-lib/components/ui/Dialog.js.map +1 -1
  45. package/dist-lib/components/ui/Drawer.d.ts +3 -3
  46. package/dist-lib/components/ui/Drawer.js +90 -124
  47. package/dist-lib/components/ui/Drawer.js.map +1 -1
  48. package/dist-lib/components/ui/DropdownMenu.d.ts +1 -1
  49. package/dist-lib/components/ui/DropdownMenu.js +92 -158
  50. package/dist-lib/components/ui/DropdownMenu.js.map +1 -1
  51. package/dist-lib/components/ui/EmptyState.js +31 -44
  52. package/dist-lib/components/ui/EmptyState.js.map +1 -1
  53. package/dist-lib/components/ui/ErrorState.js +57 -67
  54. package/dist-lib/components/ui/ErrorState.js.map +1 -1
  55. package/dist-lib/components/ui/FileUpload.js +113 -107
  56. package/dist-lib/components/ui/FileUpload.js.map +1 -1
  57. package/dist-lib/components/ui/Form.d.ts +6 -4
  58. package/dist-lib/components/ui/Form.js +117 -122
  59. package/dist-lib/components/ui/Form.js.map +1 -1
  60. package/dist-lib/components/ui/Icon.d.ts +1 -1
  61. package/dist-lib/components/ui/Icon.js +30 -29
  62. package/dist-lib/components/ui/Icon.js.map +1 -1
  63. package/dist-lib/components/ui/IconButton.js +61 -61
  64. package/dist-lib/components/ui/IconButton.js.map +1 -1
  65. package/dist-lib/components/ui/Input.js +133 -156
  66. package/dist-lib/components/ui/Input.js.map +1 -1
  67. package/dist-lib/components/ui/Kbd.js +14 -21
  68. package/dist-lib/components/ui/Kbd.js.map +1 -1
  69. package/dist-lib/components/ui/MultiSelect.js +176 -208
  70. package/dist-lib/components/ui/MultiSelect.js.map +1 -1
  71. package/dist-lib/components/ui/Pagination.js +152 -149
  72. package/dist-lib/components/ui/Pagination.js.map +1 -1
  73. package/dist-lib/components/ui/Popover.js +18 -33
  74. package/dist-lib/components/ui/Popover.js.map +1 -1
  75. package/dist-lib/components/ui/Progress.js +77 -99
  76. package/dist-lib/components/ui/Progress.js.map +1 -1
  77. package/dist-lib/components/ui/RadioGroup.js +51 -80
  78. package/dist-lib/components/ui/RadioGroup.js.map +1 -1
  79. package/dist-lib/components/ui/RelativeTime.js +22 -29
  80. package/dist-lib/components/ui/RelativeTime.js.map +1 -1
  81. package/dist-lib/components/ui/ScrollArea.js +39 -58
  82. package/dist-lib/components/ui/ScrollArea.js.map +1 -1
  83. package/dist-lib/components/ui/Select.js +108 -131
  84. package/dist-lib/components/ui/Select.js.map +1 -1
  85. package/dist-lib/components/ui/Separator.js +18 -24
  86. package/dist-lib/components/ui/Separator.js.map +1 -1
  87. package/dist-lib/components/ui/Sheet.d.ts +2 -2
  88. package/dist-lib/components/ui/Sheet.js +77 -129
  89. package/dist-lib/components/ui/Sheet.js.map +1 -1
  90. package/dist-lib/components/ui/Sidebar.d.ts +1 -1
  91. package/dist-lib/components/ui/Sidebar.js +168 -207
  92. package/dist-lib/components/ui/Sidebar.js.map +1 -1
  93. package/dist-lib/components/ui/Skeleton.js +17 -27
  94. package/dist-lib/components/ui/Skeleton.js.map +1 -1
  95. package/dist-lib/components/ui/Slider.js +45 -62
  96. package/dist-lib/components/ui/Slider.js.map +1 -1
  97. package/dist-lib/components/ui/Snackbar.js +75 -55
  98. package/dist-lib/components/ui/Snackbar.js.map +1 -1
  99. package/dist-lib/components/ui/Spinner.js +45 -52
  100. package/dist-lib/components/ui/Spinner.js.map +1 -1
  101. package/dist-lib/components/ui/Stepper.js +56 -108
  102. package/dist-lib/components/ui/Stepper.js.map +1 -1
  103. package/dist-lib/components/ui/Switch.js +46 -79
  104. package/dist-lib/components/ui/Switch.js.map +1 -1
  105. package/dist-lib/components/ui/Table.js +108 -169
  106. package/dist-lib/components/ui/Table.js.map +1 -1
  107. package/dist-lib/components/ui/Tabs.js +57 -88
  108. package/dist-lib/components/ui/Tabs.js.map +1 -1
  109. package/dist-lib/components/ui/TagInput.js +76 -109
  110. package/dist-lib/components/ui/TagInput.js.map +1 -1
  111. package/dist-lib/components/ui/Textarea.js +74 -86
  112. package/dist-lib/components/ui/Textarea.js.map +1 -1
  113. package/dist-lib/components/ui/Timeline.d.ts +3 -3
  114. package/dist-lib/components/ui/Timeline.js +61 -49
  115. package/dist-lib/components/ui/Timeline.js.map +1 -1
  116. package/dist-lib/components/ui/Toast.d.ts +1 -1
  117. package/dist-lib/components/ui/Toast.js +136 -150
  118. package/dist-lib/components/ui/Toast.js.map +1 -1
  119. package/dist-lib/components/ui/Tooltip.d.ts +2 -2
  120. package/dist-lib/components/ui/Tooltip.js +35 -56
  121. package/dist-lib/components/ui/Tooltip.js.map +1 -1
  122. package/dist-lib/components/ui/TopNav.js +46 -66
  123. package/dist-lib/components/ui/TopNav.js.map +1 -1
  124. package/dist-lib/components/ui/Tree.js +134 -168
  125. package/dist-lib/components/ui/Tree.js.map +1 -1
  126. package/dist-lib/hooks/use-debounce.js +27 -33
  127. package/dist-lib/hooks/use-debounce.js.map +1 -1
  128. package/dist-lib/hooks/use-delayed-loading.js +19 -18
  129. package/dist-lib/hooks/use-delayed-loading.js.map +1 -1
  130. package/dist-lib/hooks/use-field-ids.js +14 -16
  131. package/dist-lib/hooks/use-field-ids.js.map +1 -1
  132. package/dist-lib/hooks/use-media-query.js +15 -19
  133. package/dist-lib/hooks/use-media-query.js.map +1 -1
  134. package/dist-lib/hooks/use-modifier-key.js +20 -15
  135. package/dist-lib/hooks/use-modifier-key.js.map +1 -1
  136. package/dist-lib/hooks/use-strings.js +10 -10
  137. package/dist-lib/hooks/use-strings.js.map +1 -1
  138. package/dist-lib/hooks/use-toast.js +73 -62
  139. package/dist-lib/hooks/use-toast.js.map +1 -1
  140. package/dist-lib/icon.js +2 -6
  141. package/dist-lib/icons/index.js +166 -163
  142. package/dist-lib/icons/index.js.map +1 -1
  143. package/dist-lib/illustrations/index.d.ts +7 -7
  144. package/dist-lib/illustrations/index.js +255 -106
  145. package/dist-lib/illustrations/index.js.map +1 -1
  146. package/dist-lib/index.js +69 -291
  147. package/dist-lib/lib/cva.js +2 -0
  148. package/dist-lib/lib/format.js +71 -87
  149. package/dist-lib/lib/format.js.map +1 -1
  150. package/dist-lib/lib/return-focus.js +11 -11
  151. package/dist-lib/lib/return-focus.js.map +1 -1
  152. package/dist-lib/lib/strings.js +167 -135
  153. package/dist-lib/lib/strings.js.map +1 -1
  154. package/dist-lib/lib/strings.mn.js +150 -113
  155. package/dist-lib/lib/strings.mn.js.map +1 -1
  156. package/dist-lib/lib/utils.js +9 -9
  157. package/dist-lib/lib/utils.js.map +1 -1
  158. package/dist-lib/styles.css +3 -1
  159. package/dist-lib/theme.css +18 -5
  160. package/package.json +50 -50
  161. package/dist-lib/__tests__/helpers/color.d.ts +0 -9
  162. package/dist-lib/__tests__/helpers/theme.d.ts +0 -18
  163. package/dist-lib/icon.js.map +0 -1
  164. package/dist-lib/index.js.map +0 -1
@@ -1,193 +1,156 @@
1
1
  "use client";
2
- import { jsx as n, jsxs as $ } from "react/jsx-runtime";
3
- import { forwardRef as O, useId as R, useState as S, useMemo as F } from "react";
4
- import * as f from "@radix-ui/react-popover";
5
- import { Calendar as A } from "../../icons/index.js";
6
- import { Calendar as D } from "./Calendar.js";
7
- import { cn as C } from "../../lib/utils.js";
8
- import { useStrings as w } from "../../hooks/use-strings.js";
9
- function z(t, e) {
10
- if (e != null && e.code)
11
- return t.toLocaleDateString(e.code, { year: "numeric", month: "short", day: "numeric" });
12
- const o = (r) => String(r).padStart(2, "0");
13
- return `${t.getFullYear()}-${o(t.getMonth() + 1)}-${o(t.getDate())}`;
2
+ import { cn as e } from "../../lib/utils.js";
3
+ import { useStrings as t } from "../../hooks/use-strings.js";
4
+ import { Calendar as n } from "../../icons/index.js";
5
+ import { Calendar as r } from "./Calendar.js";
6
+ import { forwardRef as i, useId as a, useMemo as o, useState as s } from "react";
7
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
8
+ import * as u from "@radix-ui/react-popover";
9
+ //#region src/components/ui/DatePicker.tsx
10
+ function d(e, t) {
11
+ if (t?.code) return e.toLocaleDateString(t.code, {
12
+ year: "numeric",
13
+ month: "short",
14
+ day: "numeric"
15
+ });
16
+ let n = (e) => String(e).padStart(2, "0");
17
+ return `${e.getFullYear()}-${n(e.getMonth() + 1)}-${n(e.getDate())}`;
14
18
  }
15
- function v(t, e, o) {
16
- return F(() => {
17
- const r = [];
18
- return t && r.push({ before: t }), e && r.push({ after: e }), o && r.push(...Array.isArray(o) ? o : [o]), r.length ? r : void 0;
19
- }, [t, e, o]);
19
+ function f(e, t, n) {
20
+ return o(() => {
21
+ let r = [];
22
+ return e && r.push({ before: e }), t && r.push({ after: t }), n && r.push(...Array.isArray(n) ? n : [n]), r.length ? r : void 0;
23
+ }, [
24
+ e,
25
+ t,
26
+ n
27
+ ]);
20
28
  }
21
- function B({
22
- label: t,
23
- placeholder: e,
24
- hasValue: o,
25
- children: r,
26
- error: s,
27
- fieldId: i,
28
- disabled: g,
29
- open: d
30
- }) {
31
- const a = `${i}-error`, p = `${i}-calendar`, c = o ? r : e;
32
- return /* @__PURE__ */ $("div", { className: "flex flex-col gap-1.5", children: [
33
- t && /* @__PURE__ */ n(
34
- "label",
35
- {
36
- id: `${i}-label`,
37
- htmlFor: i,
38
- className: "text-foreground text-sm font-medium",
39
- children: t
40
- }
41
- ),
42
- /* @__PURE__ */ n(f.Trigger, { asChild: !0, children: /* @__PURE__ */ $(
43
- "button",
44
- {
45
- id: i,
46
- type: "button",
47
- role: "combobox",
48
- "aria-expanded": d,
49
- "aria-controls": p,
50
- "aria-labelledby": t ? `${i}-label` : void 0,
51
- "aria-label": t ? void 0 : e,
52
- disabled: g,
53
- "aria-invalid": !!s || void 0,
54
- "aria-describedby": s ? a : void 0,
55
- className: C(
56
- "bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm",
57
- "transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]",
58
- "focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
59
- "disabled:cursor-not-allowed disabled:opacity-50",
60
- s ? "border-danger focus-visible:border-danger focus-visible:ring-danger" : "border-border-input focus-visible:border-accent focus-visible:ring-ring",
61
- !o && "text-foreground-subtle"
62
- ),
63
- children: [
64
- /* @__PURE__ */ n(A, { className: "text-foreground-subtle size-4", "aria-hidden": !0 }),
65
- /* @__PURE__ */ n("span", { className: "truncate", title: typeof c == "string" ? c : void 0, children: c })
66
- ]
67
- }
68
- ) }),
69
- s && /* @__PURE__ */ n("p", { id: a, className: "text-danger-text text-xs", children: s })
70
- ] });
29
+ function p({ label: t, placeholder: r, hasValue: i, children: a, error: o, fieldId: s, disabled: d, open: f }) {
30
+ let p = `${s}-error`, m = `${s}-calendar`, h = i ? a : r;
31
+ return /* @__PURE__ */ l("div", {
32
+ className: "flex flex-col gap-1.5",
33
+ children: [
34
+ t && /* @__PURE__ */ c("label", {
35
+ id: `${s}-label`,
36
+ htmlFor: s,
37
+ className: "text-foreground text-sm font-medium",
38
+ children: t
39
+ }),
40
+ /* @__PURE__ */ c(u.Trigger, {
41
+ asChild: !0,
42
+ children: /* @__PURE__ */ l("button", {
43
+ id: s,
44
+ type: "button",
45
+ role: "combobox",
46
+ "aria-expanded": f,
47
+ "aria-controls": m,
48
+ "aria-labelledby": t ? `${s}-label` : void 0,
49
+ "aria-label": t ? void 0 : r,
50
+ disabled: d,
51
+ "aria-invalid": !!o || void 0,
52
+ "aria-describedby": o ? p : void 0,
53
+ className: e("bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm", "transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]", "focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2", "disabled:cursor-not-allowed disabled:opacity-50", o ? "border-danger focus-visible:border-danger focus-visible:ring-danger" : "border-border-input focus-visible:border-accent focus-visible:ring-ring", !i && "text-foreground-subtle"),
54
+ children: [/* @__PURE__ */ c(n, {
55
+ className: "text-foreground-subtle size-4",
56
+ "aria-hidden": !0
57
+ }), /* @__PURE__ */ c("span", {
58
+ className: "truncate",
59
+ title: typeof h == "string" ? h : void 0,
60
+ children: h
61
+ })]
62
+ })
63
+ }),
64
+ o && /* @__PURE__ */ c("p", {
65
+ id: p,
66
+ className: "text-danger-text text-xs",
67
+ children: o
68
+ })
69
+ ]
70
+ });
71
71
  }
72
- const T = O(function({
73
- value: e,
74
- onChange: o,
75
- label: r,
76
- placeholder: s,
77
- error: i,
78
- disabled: g,
79
- fromDate: d,
80
- toDate: a,
81
- disabledDays: p,
82
- formatDate: c,
83
- locale: h,
84
- className: P
85
- }, k) {
86
- const N = w(), u = c ?? ((m) => z(m, h)), b = s ?? N.datePicker.pickDate, l = R(), [x, y] = S(!1), M = v(d, a, p);
87
- return /* @__PURE__ */ n("div", { ref: k, className: C(P), children: /* @__PURE__ */ $(f.Root, { open: x, onOpenChange: y, children: [
88
- /* @__PURE__ */ n(
89
- B,
90
- {
91
- label: r,
92
- placeholder: b,
93
- hasValue: !!e,
94
- error: i,
95
- fieldId: l,
96
- disabled: g,
97
- open: x,
98
- children: e ? u(e) : ""
99
- }
100
- ),
101
- /* @__PURE__ */ n(f.Portal, { children: /* @__PURE__ */ n(
102
- f.Content,
103
- {
104
- id: `${l}-calendar`,
105
- "aria-labelledby": r ? `${l}-label` : void 0,
106
- "aria-label": r ? void 0 : b,
107
- align: "start",
108
- sideOffset: 4,
109
- className: "text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md",
110
- children: /* @__PURE__ */ n(
111
- D,
112
- {
113
- mode: "single",
114
- selected: e,
115
- defaultMonth: e,
116
- onSelect: (m) => {
117
- o(m ?? void 0), m && y(!1);
118
- },
119
- startMonth: d,
120
- endMonth: a,
121
- disabled: M,
122
- locale: h
123
- }
124
- )
125
- }
126
- ) })
127
- ] }) });
72
+ var m = i(function({ value: n, onChange: i, label: o, placeholder: m, error: h, disabled: g, fromDate: _, toDate: v, disabledDays: y, formatDate: b, locale: x, className: S }, C) {
73
+ let w = t(), T = b ?? ((e) => d(e, x)), E = m ?? w.datePicker.pickDate, D = a(), [O, k] = s(!1), A = f(_, v, y);
74
+ return /* @__PURE__ */ c("div", {
75
+ ref: C,
76
+ className: e(S),
77
+ children: /* @__PURE__ */ l(u.Root, {
78
+ open: O,
79
+ onOpenChange: k,
80
+ children: [/* @__PURE__ */ c(p, {
81
+ label: o,
82
+ placeholder: E,
83
+ hasValue: !!n,
84
+ error: h,
85
+ fieldId: D,
86
+ disabled: g,
87
+ open: O,
88
+ children: n ? T(n) : ""
89
+ }), /* @__PURE__ */ c(u.Portal, { children: /* @__PURE__ */ c(u.Content, {
90
+ id: `${D}-calendar`,
91
+ "aria-labelledby": o ? `${D}-label` : void 0,
92
+ "aria-label": o ? void 0 : E,
93
+ align: "start",
94
+ sideOffset: 4,
95
+ className: "text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md",
96
+ children: /* @__PURE__ */ c(r, {
97
+ mode: "single",
98
+ selected: n,
99
+ defaultMonth: n,
100
+ onSelect: (e) => {
101
+ i(e ?? void 0), e && k(!1);
102
+ },
103
+ startMonth: _,
104
+ endMonth: v,
105
+ disabled: A,
106
+ locale: x
107
+ })
108
+ }) })]
109
+ })
110
+ });
128
111
  });
129
- T.displayName = "DatePicker";
130
- const L = O(
131
- function({
132
- value: e,
133
- onChange: o,
134
- label: r,
135
- placeholder: s,
136
- error: i,
137
- disabled: g,
138
- fromDate: d,
139
- toDate: a,
140
- disabledDays: p,
141
- formatDate: c,
142
- locale: h,
143
- className: P
144
- }, k) {
145
- const N = w(), u = c ?? ((j) => z(j, h)), b = s ?? N.datePicker.pickRange, l = R(), [x, y] = S(!1), M = !!(e != null && e.from), m = v(d, a, p);
146
- return /* @__PURE__ */ n("div", { ref: k, className: C(P), children: /* @__PURE__ */ $(f.Root, { open: x, onOpenChange: y, children: [
147
- /* @__PURE__ */ n(
148
- B,
149
- {
150
- label: r,
151
- placeholder: b,
152
- hasValue: M,
153
- error: i,
154
- fieldId: l,
155
- disabled: g,
156
- open: x,
157
- children: e != null && e.from && e.to ? `${u(e.from)} – ${u(e.to)}` : e != null && e.from ? u(e.from) : ""
158
- }
159
- ),
160
- /* @__PURE__ */ n(f.Portal, { children: /* @__PURE__ */ n(
161
- f.Content,
162
- {
163
- id: `${l}-calendar`,
164
- "aria-labelledby": r ? `${l}-label` : void 0,
165
- "aria-label": r ? void 0 : b,
166
- align: "start",
167
- sideOffset: 4,
168
- className: "text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md",
169
- children: /* @__PURE__ */ n(
170
- D,
171
- {
172
- mode: "range",
173
- selected: e,
174
- defaultMonth: e == null ? void 0 : e.from,
175
- onSelect: o,
176
- numberOfMonths: 2,
177
- startMonth: d,
178
- endMonth: a,
179
- disabled: m,
180
- locale: h
181
- }
182
- )
183
- }
184
- ) })
185
- ] }) });
186
- }
187
- );
188
- L.displayName = "DateRangePicker";
189
- export {
190
- T as DatePicker,
191
- L as DateRangePicker
192
- };
193
- //# sourceMappingURL=DatePicker.js.map
112
+ m.displayName = "DatePicker";
113
+ var h = i(function({ value: n, onChange: i, label: o, placeholder: m, error: h, disabled: g, fromDate: _, toDate: v, disabledDays: y, formatDate: b, locale: x, className: S }, C) {
114
+ let w = t(), T = b ?? ((e) => d(e, x)), E = m ?? w.datePicker.pickRange, D = a(), [O, k] = s(!1), A = !!n?.from, j = f(_, v, y);
115
+ return /* @__PURE__ */ c("div", {
116
+ ref: C,
117
+ className: e(S),
118
+ children: /* @__PURE__ */ l(u.Root, {
119
+ open: O,
120
+ onOpenChange: k,
121
+ children: [/* @__PURE__ */ c(p, {
122
+ label: o,
123
+ placeholder: E,
124
+ hasValue: A,
125
+ error: h,
126
+ fieldId: D,
127
+ disabled: g,
128
+ open: O,
129
+ children: n?.from && n.to ? `${T(n.from)} – ${T(n.to)}` : n?.from ? T(n.from) : ""
130
+ }), /* @__PURE__ */ c(u.Portal, { children: /* @__PURE__ */ c(u.Content, {
131
+ id: `${D}-calendar`,
132
+ "aria-labelledby": o ? `${D}-label` : void 0,
133
+ "aria-label": o ? void 0 : E,
134
+ align: "start",
135
+ sideOffset: 4,
136
+ className: "text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md",
137
+ children: /* @__PURE__ */ c(r, {
138
+ mode: "range",
139
+ selected: n,
140
+ defaultMonth: n?.from,
141
+ onSelect: i,
142
+ numberOfMonths: 2,
143
+ startMonth: _,
144
+ endMonth: v,
145
+ disabled: j,
146
+ locale: x
147
+ })
148
+ }) })]
149
+ })
150
+ });
151
+ });
152
+ h.displayName = "DateRangePicker";
153
+ //#endregion
154
+ export { m as DatePicker, h as DateRangePicker };
155
+
156
+ //# sourceMappingURL=DatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sources":["../../../src/components/ui/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useMemo, useState, type ReactNode } from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport type { DateRange, DayPickerProps, Matcher } from 'react-day-picker';\nimport { Calendar as CalendarIcon } from '@/icons';\nimport { Calendar } from './Calendar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\n/* -----------------------------------------------------------------------------\n * Two related components share the same trigger shell:\n *\n * <DatePicker value={date} onChange={setDate} /> // single date\n * <DateRangePicker value={range} onChange={setRange} /> // {from,to}\n * --------------------------------------------------------------------------- */\n\ntype CalendarLocale = DayPickerProps['locale'];\n\n/**\n * Default trigger text. With a date-fns `locale` the date is rendered in that\n * locale; without one it is the canonical `yyyy-MM-dd` — deterministic on\n * server and client, so SSR output never depends on the host's locale.\n */\nfunction defaultFormatDate(d: Date, locale?: CalendarLocale): string {\n if (locale?.code) {\n return d.toLocaleDateString(locale.code, { year: 'numeric', month: 'short', day: 'numeric' });\n }\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n}\n\n/** Merge the fromDate/toDate bounds with any consumer-supplied RDP matcher. */\nfunction useBounds(fromDate?: Date, toDate?: Date, disabled?: Matcher | Matcher[]) {\n return useMemo<Matcher[] | undefined>(() => {\n const list: Matcher[] = [];\n if (fromDate) list.push({ before: fromDate });\n if (toDate) list.push({ after: toDate });\n if (disabled) list.push(...(Array.isArray(disabled) ? disabled : [disabled]));\n return list.length ? list : undefined;\n }, [fromDate, toDate, disabled]);\n}\n\nfunction PickerTrigger({\n label,\n placeholder,\n hasValue,\n children,\n error,\n fieldId,\n disabled,\n open,\n}: {\n label?: ReactNode;\n placeholder: string;\n hasValue: boolean;\n children: ReactNode;\n error?: ReactNode;\n fieldId: string;\n disabled?: boolean;\n open: boolean;\n}) {\n const errorId = `${fieldId}-error`;\n const calendarId = `${fieldId}-calendar`;\n const text = hasValue ? children : placeholder;\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <label\n id={`${fieldId}-label`}\n htmlFor={fieldId}\n className=\"text-foreground text-sm font-medium\"\n >\n {label}\n </label>\n )}\n <PopoverPrimitive.Trigger asChild>\n <button\n id={fieldId}\n type=\"button\"\n // combobox-with-dialog pattern: lets the field carry aria-invalid like other inputs.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={calendarId}\n // role=combobox takes no name from content; expose the placeholder.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n disabled={disabled}\n aria-invalid={Boolean(error) || undefined}\n aria-describedby={error ? errorId : undefined}\n className={cn(\n 'bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error\n ? 'border-danger focus-visible:border-danger focus-visible:ring-danger'\n : 'border-border-input focus-visible:border-accent focus-visible:ring-ring',\n !hasValue && 'text-foreground-subtle',\n )}\n >\n <CalendarIcon className=\"text-foreground-subtle size-4\" aria-hidden />\n <span className=\"truncate\" title={typeof text === 'string' ? text : undefined}>\n {text}\n </span>\n </button>\n </PopoverPrimitive.Trigger>\n {error && (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n )}\n </div>\n );\n}\n\ninterface PickerCommonProps {\n label?: ReactNode;\n placeholder?: string;\n error?: ReactNode;\n disabled?: boolean;\n /** Restrict to a date range. Days outside are not selectable. */\n fromDate?: Date;\n toDate?: Date;\n /** Extra RDP matcher(s) for disabled days, merged with `fromDate`/`toDate`. */\n disabledDays?: Matcher | Matcher[];\n /** Custom display formatter for the trigger text. */\n formatDate?: (d: Date) => string;\n /** date-fns locale object passed through to react-day-picker. */\n locale?: CalendarLocale;\n className?: string;\n}\n\nexport interface DatePickerProps extends PickerCommonProps {\n value?: Date;\n onChange: (date: Date | undefined) => void;\n}\n\n/**\n * Single-date picker.\n *\n * @example\n * <DatePicker label=\"Date of birth\" value={dob} onChange={setDob} />\n *\n * @do Use locale-aware formatting via `formatDate` / `locale`.\n * @dont Roll a custom calendar — Radix Popover + react-day-picker handles a11y.\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickDate;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={Boolean(value)}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value ? formatDate(value) : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n // Radix gives the popover role=\"dialog\"; name it after the field.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"single\"\n selected={value}\n // RDP 9 ignores `selected` for the initial month; open on the value.\n defaultMonth={value}\n onSelect={(d) => {\n onChange(d ?? undefined);\n if (d) setOpen(false);\n }}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n});\nDatePicker.displayName = 'DatePicker';\n\nexport interface DateRangePickerProps extends PickerCommonProps {\n value?: DateRange;\n onChange: (range: DateRange | undefined) => void;\n}\n\n/**\n * Two-date range picker. `value` is `{from, to}`.\n *\n * @example\n * <DateRangePicker label=\"Reporting period\" value={range} onChange={setRange} />\n */\nexport const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(\n function DateRangePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n ) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickRange;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const hasValue = Boolean(value?.from);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={hasValue}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value?.from && value.to\n ? `${formatDate(value.from)} – ${formatDate(value.to)}`\n : value?.from\n ? formatDate(value.from)\n : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"range\"\n selected={value}\n defaultMonth={value?.from}\n onSelect={onChange}\n numberOfMonths={2}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n },\n);\nDateRangePicker.displayName = 'DateRangePicker';\n"],"names":["defaultFormatDate","d","locale","pad","n","useBounds","fromDate","toDate","disabled","useMemo","list","PickerTrigger","label","placeholder","hasValue","children","error","fieldId","open","errorId","calendarId","text","jsxs","jsx","PopoverPrimitive","cn","CalendarIcon","DatePicker","forwardRef","value","onChange","placeholderProp","disabledDays","formatDateProp","className","ref","strings","useStrings","formatDate","useId","setOpen","useState","bounds","Calendar","DateRangePicker"],"mappings":";;;;;;;;AAwBA,SAASA,EAAkBC,GAASC,GAAiC;AACnE,MAAIA,KAAA,QAAAA,EAAQ;AACV,WAAOD,EAAE,mBAAmBC,EAAO,MAAM,EAAE,MAAM,WAAW,OAAO,SAAS,KAAK,UAAA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AA,cACrB,UAAUC;AAAA,cACV,gBAAgB;AAAA,cAChB,YAAYxB;AAAA,cACZ,UAAUC;AAAA,cACV,UAAUmC;AAAA,cACV,QAAAxC;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA,EACF,CACF;AAAA,IAAA,EAAA,CACF,EAAA,CACF;AAAA,EAEJ;AACF;AACA0C,EAAgB,cAAc;"}
1
+ {"version":3,"file":"DatePicker.js","names":[],"sources":["../../../src/components/ui/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useMemo, useState, type ReactNode } from 'react';\nimport * as PopoverPrimitive from '@radix-ui/react-popover';\nimport type { DateRange, DayPickerProps, Matcher } from 'react-day-picker';\nimport { Calendar as CalendarIcon } from '@/icons';\nimport { Calendar } from './Calendar';\nimport { cn } from '@/lib/utils';\nimport { useStrings } from '@/hooks/use-strings';\n\n/* -----------------------------------------------------------------------------\n * Two related components share the same trigger shell:\n *\n * <DatePicker value={date} onChange={setDate} /> // single date\n * <DateRangePicker value={range} onChange={setRange} /> // {from,to}\n * --------------------------------------------------------------------------- */\n\ntype CalendarLocale = DayPickerProps['locale'];\n\n/**\n * Default trigger text. With a date-fns `locale` the date is rendered in that\n * locale; without one it is the canonical `yyyy-MM-dd` — deterministic on\n * server and client, so SSR output never depends on the host's locale.\n */\nfunction defaultFormatDate(d: Date, locale?: CalendarLocale): string {\n if (locale?.code) {\n return d.toLocaleDateString(locale.code, { year: 'numeric', month: 'short', day: 'numeric' });\n }\n const pad = (n: number) => String(n).padStart(2, '0');\n return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\n}\n\n/** Merge the fromDate/toDate bounds with any consumer-supplied RDP matcher. */\nfunction useBounds(fromDate?: Date, toDate?: Date, disabled?: Matcher | Matcher[]) {\n return useMemo<Matcher[] | undefined>(() => {\n const list: Matcher[] = [];\n if (fromDate) list.push({ before: fromDate });\n if (toDate) list.push({ after: toDate });\n if (disabled) list.push(...(Array.isArray(disabled) ? disabled : [disabled]));\n return list.length ? list : undefined;\n }, [fromDate, toDate, disabled]);\n}\n\nfunction PickerTrigger({\n label,\n placeholder,\n hasValue,\n children,\n error,\n fieldId,\n disabled,\n open,\n}: {\n label?: ReactNode;\n placeholder: string;\n hasValue: boolean;\n children: ReactNode;\n error?: ReactNode;\n fieldId: string;\n disabled?: boolean;\n open: boolean;\n}) {\n const errorId = `${fieldId}-error`;\n const calendarId = `${fieldId}-calendar`;\n const text = hasValue ? children : placeholder;\n return (\n <div className=\"flex flex-col gap-1.5\">\n {label && (\n <label\n id={`${fieldId}-label`}\n htmlFor={fieldId}\n className=\"text-foreground text-sm font-medium\"\n >\n {label}\n </label>\n )}\n <PopoverPrimitive.Trigger asChild>\n <button\n id={fieldId}\n type=\"button\"\n // combobox-with-dialog pattern: lets the field carry aria-invalid like other inputs.\n role=\"combobox\"\n aria-expanded={open}\n aria-controls={calendarId}\n // role=combobox takes no name from content; expose the placeholder.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n disabled={disabled}\n aria-invalid={Boolean(error) || undefined}\n aria-describedby={error ? errorId : undefined}\n className={cn(\n 'bg-card inline-flex h-9 w-full items-center justify-start gap-2 rounded-md border px-3 text-left text-lg md:text-sm',\n 'transition-colors duration-[var(--duration-fast)] ease-[var(--ease-out)]',\n 'focus-visible:ring-offset-background outline-none focus-visible:ring-2 focus-visible:ring-offset-2',\n 'disabled:cursor-not-allowed disabled:opacity-50',\n error\n ? 'border-danger focus-visible:border-danger focus-visible:ring-danger'\n : 'border-border-input focus-visible:border-accent focus-visible:ring-ring',\n !hasValue && 'text-foreground-subtle',\n )}\n >\n <CalendarIcon className=\"text-foreground-subtle size-4\" aria-hidden />\n <span className=\"truncate\" title={typeof text === 'string' ? text : undefined}>\n {text}\n </span>\n </button>\n </PopoverPrimitive.Trigger>\n {error && (\n <p id={errorId} className=\"text-danger-text text-xs\">\n {error}\n </p>\n )}\n </div>\n );\n}\n\ninterface PickerCommonProps {\n label?: ReactNode;\n placeholder?: string;\n error?: ReactNode;\n disabled?: boolean;\n /** Restrict to a date range. Days outside are not selectable. */\n fromDate?: Date;\n toDate?: Date;\n /** Extra RDP matcher(s) for disabled days, merged with `fromDate`/`toDate`. */\n disabledDays?: Matcher | Matcher[];\n /** Custom display formatter for the trigger text. */\n formatDate?: (d: Date) => string;\n /** date-fns locale object passed through to react-day-picker. */\n locale?: CalendarLocale;\n className?: string;\n}\n\nexport interface DatePickerProps extends PickerCommonProps {\n value?: Date;\n onChange: (date: Date | undefined) => void;\n}\n\n/**\n * Single-date picker.\n *\n * @example\n * <DatePicker label=\"Date of birth\" value={dob} onChange={setDob} />\n *\n * @do Use locale-aware formatting via `formatDate` / `locale`.\n * @dont Roll a custom calendar — Radix Popover + react-day-picker handles a11y.\n */\nexport const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(function DatePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickDate;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={Boolean(value)}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value ? formatDate(value) : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n // Radix gives the popover role=\"dialog\"; name it after the field.\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"single\"\n selected={value}\n // RDP 9 ignores `selected` for the initial month; open on the value.\n defaultMonth={value}\n onSelect={(d) => {\n onChange(d ?? undefined);\n if (d) setOpen(false);\n }}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n});\nDatePicker.displayName = 'DatePicker';\n\nexport interface DateRangePickerProps extends PickerCommonProps {\n value?: DateRange;\n onChange: (range: DateRange | undefined) => void;\n}\n\n/**\n * Two-date range picker. `value` is `{from, to}`.\n *\n * @example\n * <DateRangePicker label=\"Reporting period\" value={range} onChange={setRange} />\n */\nexport const DateRangePicker = forwardRef<HTMLDivElement, DateRangePickerProps>(\n function DateRangePicker(\n {\n value,\n onChange,\n label,\n placeholder: placeholderProp,\n error,\n disabled,\n fromDate,\n toDate,\n disabledDays,\n formatDate: formatDateProp,\n locale,\n className,\n },\n ref,\n ) {\n const strings = useStrings();\n const formatDate = formatDateProp ?? ((d: Date) => defaultFormatDate(d, locale));\n const placeholder = placeholderProp ?? strings.datePicker.pickRange;\n const fieldId = useId();\n const [open, setOpen] = useState(false);\n const hasValue = Boolean(value?.from);\n const bounds = useBounds(fromDate, toDate, disabledDays);\n\n return (\n <div ref={ref} className={cn(className)}>\n <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>\n <PickerTrigger\n label={label}\n placeholder={placeholder}\n hasValue={hasValue}\n error={error}\n fieldId={fieldId}\n disabled={disabled}\n open={open}\n >\n {value?.from && value.to\n ? `${formatDate(value.from)} – ${formatDate(value.to)}`\n : value?.from\n ? formatDate(value.from)\n : ''}\n </PickerTrigger>\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Content\n id={`${fieldId}-calendar`}\n aria-labelledby={label ? `${fieldId}-label` : undefined}\n aria-label={label ? undefined : placeholder}\n align=\"start\"\n sideOffset={4}\n className=\"text-popover-foreground z-[var(--z-popover)] rounded-lg shadow-md\"\n >\n <Calendar\n mode=\"range\"\n selected={value}\n defaultMonth={value?.from}\n onSelect={onChange}\n numberOfMonths={2}\n startMonth={fromDate}\n endMonth={toDate}\n disabled={bounds}\n locale={locale}\n />\n </PopoverPrimitive.Content>\n </PopoverPrimitive.Portal>\n </PopoverPrimitive.Root>\n </div>\n );\n },\n);\nDateRangePicker.displayName = 'DateRangePicker';\n"],"mappings":";;;;;;;;;AAwBA,SAAS,EAAkB,GAAS,GAAiC;CACnE,IAAI,GAAQ,MACV,OAAO,EAAE,mBAAmB,EAAO,MAAM;EAAE,MAAM;EAAW,OAAO;EAAS,KAAK;CAAU,CAAC;CAE9F,IAAM,KAAO,MAAc,OAAO,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG;CACpD,OAAO,GAAG,EAAE,YAAY,EAAE,GAAG,EAAI,EAAE,SAAS,IAAI,CAAC,EAAE,GAAG,EAAI,EAAE,QAAQ,CAAC;AACvE;AAGA,SAAS,EAAU,GAAiB,GAAe,GAAgC;CACjF,OAAO,QAAqC;EAC1C,IAAM,IAAkB,CAAC;EAIzB,OAHI,KAAU,EAAK,KAAK,EAAE,QAAQ,EAAS,CAAC,GACxC,KAAQ,EAAK,KAAK,EAAE,OAAO,EAAO,CAAC,GACnC,KAAU,EAAK,KAAK,GAAI,MAAM,QAAQ,CAAQ,IAAI,IAAW,CAAC,CAAQ,CAAE,GACrE,EAAK,SAAS,IAAO,KAAA;CAC9B,GAAG;EAAC;EAAU;EAAQ;CAAQ,CAAC;AACjC;AAEA,SAAS,EAAc,EACrB,UACA,gBACA,aACA,aACA,UACA,YACA,aACA,WAUC;CACD,IAAM,IAAU,GAAG,EAAQ,SACrB,IAAa,GAAG,EAAQ,YACxB,IAAO,IAAW,IAAW;CACnC,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG,KACC,kBAAC,SAAD;IACE,IAAI,GAAG,EAAQ;IACf,SAAS;IACT,WAAU;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AAM;IACN,YAAY;IACZ,WAAU;IAEV,UAAA,kBAAC,GAAD;KACE,MAAK;KACL,UAAU;KACV,cAAc,GAAO;KACrB,UAAU;KACV,gBAAgB;KAChB,YAAY;KACZ,UAAU;KACV,UAAU;KACF;IACT,CAAA;GACuB,CAAA,EACH,CAAA,CACJ;;CACpB,CAAA;AAET,CACF;AACA,EAAgB,cAAc"}
@@ -40,7 +40,7 @@ export interface DesignSystemProviderProps extends HTMLAttributes<HTMLDivElement
40
40
  /** Children to scope this brand to. */
41
41
  children: ReactNode;
42
42
  }
43
- export declare function DesignSystemProvider({ tokens, strings, className, children, style, ...props }: DesignSystemProviderProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function DesignSystemProvider({ tokens, strings, className, children, style, ...props }: DesignSystemProviderProps): import("react").JSX.Element;
44
44
  /**
45
45
  * Built-in accent presets — swap the system's single accent colour without
46
46
  * touching anything else.