@jfrader/ui 0.1.2 → 0.2.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 (144) hide show
  1. package/README.md +1 -1
  2. package/dist/accordion-CkOZ-tvs.js +178 -0
  3. package/dist/accordion.js +1 -1
  4. package/dist/alert-Dsjx14UW.js +131 -0
  5. package/dist/alert.js +1 -1
  6. package/dist/avatar-BRGKkoSr.js +127 -0
  7. package/dist/avatar.js +1 -1
  8. package/dist/badge-DLxUMsCx.js +104 -0
  9. package/dist/badge.js +1 -1
  10. package/dist/breadcrumbs-694hF_hm.js +131 -0
  11. package/dist/breadcrumbs.js +1 -1
  12. package/dist/button-CoaIcykB.js +190 -0
  13. package/dist/button.js +1 -1
  14. package/dist/calendar-Doj7PTdG.js +379 -0
  15. package/dist/calendar.js +1 -1
  16. package/dist/card-2IM71XZj.js +134 -0
  17. package/dist/card.js +1 -1
  18. package/dist/checkbox-B7xGNFzp.js +136 -0
  19. package/dist/checkbox.js +1 -1
  20. package/dist/combobox-Bjhxv5U3.js +311 -0
  21. package/dist/combobox.js +1 -1
  22. package/dist/{command-palette-6c158eH1.js → command-palette-BhJwm6cS.js} +144 -129
  23. package/dist/command-palette.js +1 -1
  24. package/dist/container-BhnrGPu-.js +36 -0
  25. package/dist/container.js +1 -1
  26. package/dist/date-picker-Jk8SpoiO.js +245 -0
  27. package/dist/date-picker.js +1 -1
  28. package/dist/dialog-fhS07G41.js +187 -0
  29. package/dist/dialog.js +1 -1
  30. package/dist/divider-v_78HYF5.js +79 -0
  31. package/dist/divider.js +1 -1
  32. package/dist/flex-COZzFqI8.js +22 -0
  33. package/dist/flex.js +1 -1
  34. package/dist/index.js +36 -36
  35. package/dist/kbd-CeP8Kfvp.js +61 -0
  36. package/dist/kbd.js +1 -1
  37. package/dist/menu-B6KCbLCr.js +196 -0
  38. package/dist/menu.js +1 -1
  39. package/dist/navigation-BDht6S2-.js +182 -0
  40. package/dist/navigation.js +1 -1
  41. package/dist/{pagination-BIKYsxK1.js → pagination-B50PCaDU.js} +58 -56
  42. package/dist/pagination.js +1 -1
  43. package/dist/pill-2_XzBdkD.js +51 -0
  44. package/dist/pill.js +1 -1
  45. package/dist/popover-DRHbeIVq.js +103 -0
  46. package/dist/popover.js +1 -1
  47. package/dist/{progress-C8bgujFI.js → progress-CpsskKTD.js} +37 -36
  48. package/dist/progress.js +1 -1
  49. package/dist/radio-group-DPI5KUCj.js +136 -0
  50. package/dist/radio-group.js +1 -1
  51. package/dist/select-C1xGrOhT.js +266 -0
  52. package/dist/select.js +1 -1
  53. package/dist/skeleton-DitdP-yz.js +49 -0
  54. package/dist/skeleton.js +1 -1
  55. package/dist/{spinner-CSFiP0Oi.js → spinner-CFq5HPoo.js} +24 -23
  56. package/dist/spinner.js +1 -1
  57. package/dist/stack-D_g6NJzo.js +21 -0
  58. package/dist/stack.js +1 -1
  59. package/dist/switch-B5TTU-oJ.js +138 -0
  60. package/dist/switch.js +1 -1
  61. package/dist/tabs-C26PWl2c.js +183 -0
  62. package/dist/tabs.js +1 -1
  63. package/dist/text-field-8PQAqRpM.js +75 -0
  64. package/dist/text-field.js +1 -1
  65. package/dist/textarea-CcGWuntL.js +85 -0
  66. package/dist/textarea.js +1 -1
  67. package/dist/theme-root-BRLIA4eb.js +22 -0
  68. package/dist/theme-root.js +1 -1
  69. package/dist/toast-B1PXuwZ4.js +277 -0
  70. package/dist/toast.js +1 -1
  71. package/dist/toggle-group-N_owicT0.js +156 -0
  72. package/dist/toggle-group.js +1 -1
  73. package/dist/tooltip-BJPisf60.js +98 -0
  74. package/dist/tooltip.js +1 -1
  75. package/dist/types/components/accordion/accordion.d.ts +13 -9
  76. package/dist/types/components/alert/alert.d.ts +6 -3
  77. package/dist/types/components/avatar/avatar.d.ts +6 -3
  78. package/dist/types/components/badge/badge.d.ts +6 -3
  79. package/dist/types/components/breadcrumbs/breadcrumbs.d.ts +8 -5
  80. package/dist/types/components/button/button.d.ts +6 -3
  81. package/dist/types/components/calendar/calendar.d.ts +11 -7
  82. package/dist/types/components/card/card.d.ts +20 -13
  83. package/dist/types/components/checkbox/checkbox.d.ts +6 -3
  84. package/dist/types/components/combobox/combobox.d.ts +12 -8
  85. package/dist/types/components/command-palette/command-palette.d.ts +22 -15
  86. package/dist/types/components/container/container.d.ts +6 -3
  87. package/dist/types/components/date-picker/date-picker.d.ts +6 -4
  88. package/dist/types/components/dialog/dialog.d.ts +16 -11
  89. package/dist/types/components/divider/divider.d.ts +6 -3
  90. package/dist/types/components/flex/flex.d.ts +6 -3
  91. package/dist/types/components/kbd/kbd.d.ts +8 -5
  92. package/dist/types/components/menu/menu.d.ts +13 -9
  93. package/dist/types/components/navigation/navigation.d.ts +11 -7
  94. package/dist/types/components/pagination/pagination.d.ts +6 -3
  95. package/dist/types/components/pill/pill.d.ts +6 -3
  96. package/dist/types/components/popover/popover.d.ts +7 -5
  97. package/dist/types/components/progress/progress.d.ts +6 -3
  98. package/dist/types/components/radio-group/radio-group.d.ts +8 -5
  99. package/dist/types/components/select/select.d.ts +13 -9
  100. package/dist/types/components/skeleton/skeleton.d.ts +6 -3
  101. package/dist/types/components/spinner/spinner.d.ts +6 -3
  102. package/dist/types/components/stack/stack.d.ts +4 -1
  103. package/dist/types/components/switch/switch.d.ts +6 -3
  104. package/dist/types/components/tabs/tabs.d.ts +14 -9
  105. package/dist/types/components/text-field/text-field.d.ts +6 -3
  106. package/dist/types/components/textarea/textarea.d.ts +6 -3
  107. package/dist/types/components/theme-root/theme-root.d.ts +6 -3
  108. package/dist/types/components/toast/toast.d.ts +6 -4
  109. package/dist/types/components/toggle-group/toggle-group.d.ts +7 -5
  110. package/dist/types/components/tooltip/tooltip.d.ts +7 -5
  111. package/dist/types/overlay/use-native-dialog.d.ts +2 -2
  112. package/package.json +4 -4
  113. package/dist/accordion-C3YbYFBi.js +0 -169
  114. package/dist/alert-CA9ZlIZp.js +0 -130
  115. package/dist/avatar-IUW4yJl0.js +0 -125
  116. package/dist/badge-Bru30HEn.js +0 -103
  117. package/dist/breadcrumbs-CQaviWRc.js +0 -126
  118. package/dist/button-Cmixur4Q.js +0 -188
  119. package/dist/calendar-DUgS0xmp.js +0 -373
  120. package/dist/card-D9CHtouU.js +0 -121
  121. package/dist/checkbox-DKa5BCdy.js +0 -135
  122. package/dist/combobox-Dq3V88Zt.js +0 -302
  123. package/dist/container-xUEIoZzj.js +0 -35
  124. package/dist/date-picker-DrHJMt2p.js +0 -240
  125. package/dist/dialog-C2NSOOP-.js +0 -176
  126. package/dist/divider-yF5EmhhT.js +0 -77
  127. package/dist/flex-5-NI5SSy.js +0 -22
  128. package/dist/kbd-B03_qIwQ.js +0 -56
  129. package/dist/menu-bvKRJOhJ.js +0 -187
  130. package/dist/navigation-xPoqh_Iz.js +0 -175
  131. package/dist/pill-CrVqffKM.js +0 -50
  132. package/dist/popover-CVAZ_C1a.js +0 -98
  133. package/dist/radio-group-CvQ4x8ii.js +0 -131
  134. package/dist/select-CNNiUhKB.js +0 -257
  135. package/dist/skeleton-gJ4ImO5u.js +0 -48
  136. package/dist/stack-mEAryjKz.js +0 -21
  137. package/dist/switch-2hm2WnWt.js +0 -136
  138. package/dist/tabs-GBppQabg.js +0 -174
  139. package/dist/text-field-DDPqQu29.js +0 -74
  140. package/dist/textarea-OP8_3IUR.js +0 -84
  141. package/dist/theme-root-eLka0ZP1.js +0 -21
  142. package/dist/toast-D3Y6OAsg.js +0 -271
  143. package/dist/toggle-group-BxzJ-6Cp.js +0 -151
  144. package/dist/tooltip-CVl8HS4S.js +0 -93
@@ -1,302 +0,0 @@
1
- 'use client';
2
- import { t as e } from "./css-Cgj6sCHn.js";
3
- import { n as t, t as n } from "./use-controlled-state-CVXDa-qM.js";
4
- import { t as r } from "./renderable-DzcIj1Lo.js";
5
- import { a as i, c as a, d as o, f as s, l as c, o as l, r as u, s as d, t as f, u as p } from "./collection-registry-1l9f3XJZ.js";
6
- import { t as m } from "./use-overlay-floating-efeqppiw.js";
7
- import { t as h } from "./text-field-DDPqQu29.js";
8
- import { createContext as g, forwardRef as _, useCallback as v, useContext as y, useId as ee, useLayoutEffect as b, useMemo as x, useRef as S, useState as C } from "react";
9
- import { vars as w } from "@jfrader/tokens/vars";
10
- import { jsx as T, jsxs as E } from "@emotion/react/jsx-runtime";
11
- import { FloatingList as D, FloatingPortal as O, useDismiss as te, useInteractions as k, useListNavigation as A, useMergeRefs as j } from "@floating-ui/react";
12
- //#region src/components/combobox/combobox.tsx
13
- var M = "bottom-start", N = "✓", P = "No results", F = (e, t) => e.toLocaleLowerCase().includes(t.toLocaleLowerCase()), I = g(null), L = g(!1);
14
- function R(e) {
15
- let t = y(I);
16
- if (!t) throw Error(`Combobox.${e} must be rendered inside <Combobox>.`);
17
- return t;
18
- }
19
- function z(e) {
20
- let t = R(e);
21
- if (!y(L)) throw Error(`Combobox.${e} must be rendered inside <Combobox.List>.`);
22
- return t;
23
- }
24
- var B = e({ "&[hidden]": { display: "none" } }), V = e({
25
- paddingBlock: w.space[1],
26
- paddingInline: w.space[2],
27
- fontSize: w.textSize.sm,
28
- color: w.color.textMuted
29
- });
30
- function H({ value: e, defaultValue: r, onValueChange: a, open: o, defaultOpen: s = !1, onOpenChange: c, name: l, filter: u = F, onInputChange: d, children: f }) {
31
- let p = ee(), [h, g] = C(`${p}-listbox`), [_, y] = C(!1), [b = null, w] = n(e, r ?? null, a), [D = !1, O] = n(o, s, c), [j, N] = C(null), [P, L] = C(""), [R, z] = i(), [B, V] = C(null), H = S([]), U = S(null), W = t(d), G = v((e, t) => t === "" || u(e, t), [u]), { valuesByIndex: K, skippedIndices: q, matchCount: J } = x(() => {
32
- let e = [], t = /* @__PURE__ */ new Set(), n = 0;
33
- return R.forEach((r, i) => {
34
- if (r.index === -1) return;
35
- e[r.index] = i;
36
- let a = G(r.label, P);
37
- a && (n += 1), (r.disabled || !a) && t.add(r.index);
38
- }), {
39
- valuesByIndex: e,
40
- skippedIndices: t,
41
- matchCount: n
42
- };
43
- }, [
44
- R,
45
- P,
46
- G
47
- ]), { refs: Y, floatingStyles: X, context: Z } = m({
48
- open: D,
49
- placement: M,
50
- onOpenChange: (e) => O(e)
51
- }), ne = te(Z, {
52
- escapeKey: !0,
53
- outsidePress: !0
54
- }), re = A(Z, {
55
- listRef: H,
56
- activeIndex: j,
57
- onNavigate: N,
58
- virtual: !0,
59
- loop: !0,
60
- disabledIndices: (e) => q.has(e)
61
- }), { getReferenceProps: Q, getFloatingProps: $, getItemProps: ie } = k([ne, re]), ae = x(() => {
62
- let e = (e) => {
63
- w(e), O(!1), U.current?.commitLabel(R.get(e)?.label ?? "");
64
- };
65
- return {
66
- baseId: p,
67
- listId: h,
68
- setListId: g,
69
- setInputDisabled: y,
70
- open: D,
71
- selectedValue: b,
72
- activeIndex: j,
73
- options: R,
74
- matchCount: J,
75
- inputLabelling: B,
76
- inputHandleRef: U,
77
- refs: Y,
78
- floatingStyles: X,
79
- elementsRef: H,
80
- getReferenceProps: Q,
81
- getFloatingProps: $,
82
- getItemProps: ie,
83
- onInputChange: W,
84
- isVisible: (e) => G(e, P),
85
- findMatches: (e) => {
86
- let t = 0, n = null, r = null;
87
- return R.forEach((i) => {
88
- i.index !== -1 && G(i.label, e) && (t += 1, !i.disabled && ((n === null || i.index < n) && (n = i.index), (r === null || i.index > r) && (r = i.index)));
89
- }), {
90
- count: t,
91
- first: n,
92
- last: r
93
- };
94
- },
95
- setQuery: L,
96
- setActiveIndex: N,
97
- selectValue: e,
98
- selectIndex: (t) => {
99
- let n = K[t];
100
- n === void 0 || q.has(t) || e(n);
101
- },
102
- clearValue: () => w(null),
103
- requestOpenChange: O,
104
- registration: z,
105
- setInputLabelling: V
106
- };
107
- }, [
108
- p,
109
- h,
110
- D,
111
- b,
112
- j,
113
- R,
114
- P,
115
- J,
116
- B,
117
- Y,
118
- X,
119
- Q,
120
- $,
121
- ie,
122
- W,
123
- G,
124
- K,
125
- q,
126
- w,
127
- O,
128
- z
129
- ]);
130
- return /* @__PURE__ */ E(I.Provider, {
131
- value: ae,
132
- children: [f, l !== void 0 && /* @__PURE__ */ T("input", {
133
- type: "hidden",
134
- name: l,
135
- value: b ?? "",
136
- disabled: _
137
- })]
138
- });
139
- }
140
- var U = _(function({ inputValue: e, defaultInputValue: t, label: i, description: a, error: o, size: s, slotProps: c, className: l, id: u, onChange: d, onKeyDown: f, onBlur: p, disabled: m = !1, ...g }, _) {
141
- let { listId: v, open: y, selectedValue: x, activeIndex: S, options: w, inputHandleRef: E, refs: D, getReferenceProps: O, onInputChange: te, findMatches: k, setQuery: A, setActiveIndex: M, selectIndex: N, clearValue: P, requestOpenChange: F, setInputLabelling: I, setInputDisabled: L } = R("Input"), z = j([D.setReference, _]), B = ee(), V = u ?? B, H = `${V}-label`, U = r(i), W = g["aria-labelledby"], G = g["aria-label"], [K, q] = C(t), [J, Y] = C(() => (e ?? t) !== void 0), X = x === null ? void 0 : w.get(x)?.label, Z = e ?? (J ? K ?? "" : X ?? K ?? ""), [, ne] = n(Z, void 0, te), re = (t) => {
142
- ne(t), e === void 0 && q(t);
143
- }, Q = e !== void 0 || J ? Z : "", $ = (e) => {
144
- Y(!1), re(e);
145
- };
146
- b(() => {
147
- A(Q);
148
- }, [Q, A]), b(() => (L(m), () => L(!1)), [m, L]), b(() => (E.current = { commitLabel: $ }, () => {
149
- E.current = null;
150
- })), b(() => (I(W !== void 0 || !U ? {
151
- labelledBy: W,
152
- label: G
153
- } : { labelledBy: H }), () => I(null)), [
154
- W,
155
- G,
156
- U,
157
- H,
158
- I
159
- ]);
160
- let ie = (t) => {
161
- d?.(t);
162
- let n = t.currentTarget.value;
163
- Y(!0), re(n), n === "" && P();
164
- let r = e ?? n;
165
- if (r === "") {
166
- M(null), F(!1);
167
- return;
168
- }
169
- let i = k(r);
170
- M(i.first), i.count > 0 && F(!0);
171
- }, ae = (e) => {
172
- if (f?.(e), !e.defaultPrevented) {
173
- if (e.key === "Escape") J && X !== void 0 && $(X);
174
- else if (y) {
175
- if (e.key === "Enter" && S !== null) e.preventDefault(), N(S);
176
- else if (e.key === "Home" || e.key === "End") {
177
- let t = k(Q), n = e.key === "Home" ? t.first : t.last;
178
- if (n === null) return;
179
- e.preventDefault(), M(n);
180
- }
181
- }
182
- }
183
- }, oe = (e) => {
184
- p?.(e), y && F(!1);
185
- };
186
- return /* @__PURE__ */ T(h, {
187
- ...O({
188
- ...g,
189
- onKeyDown: ae,
190
- onBlur: oe
191
- }),
192
- ref: z,
193
- id: V,
194
- label: U ? /* @__PURE__ */ T("span", {
195
- id: H,
196
- children: i
197
- }) : i,
198
- description: a,
199
- error: o,
200
- size: s,
201
- slotProps: c,
202
- className: l,
203
- value: Z,
204
- disabled: m,
205
- onChange: ie,
206
- role: "combobox",
207
- autoComplete: "off",
208
- "aria-autocomplete": "list",
209
- "aria-expanded": y,
210
- "aria-controls": y ? v : void 0,
211
- "data-state": y ? "open" : "closed",
212
- "data-ui": "combobox-input"
213
- });
214
- }), W = _(function({ id: e, style: t, onMouseDown: n, children: r, ...i }, a) {
215
- let { baseId: c, setListId: l, open: u, inputLabelling: d, refs: f, floatingStyles: p, elementsRef: m, getFloatingProps: h } = R("List"), g = e ?? `${c}-listbox`;
216
- b(() => (l(g), () => l(`${c}-listbox`)), [
217
- c,
218
- g,
219
- l
220
- ]);
221
- let _ = j([u ? f.setFloating : null, a]), v = i["aria-labelledby"] !== void 0 || i["aria-label"] !== void 0 ? {} : d?.labelledBy === void 0 ? { "aria-label": d?.label } : { "aria-labelledby": d.labelledBy }, y = (e) => {
222
- n?.(e), e.preventDefault();
223
- };
224
- return /* @__PURE__ */ T(O, { children: /* @__PURE__ */ T("div", {
225
- ...h({
226
- id: g,
227
- ...v,
228
- ...i,
229
- onMouseDown: y
230
- }),
231
- ref: _,
232
- role: "listbox",
233
- hidden: !u,
234
- "data-state": u ? "open" : "closed",
235
- "data-ui": "combobox-list",
236
- style: {
237
- ...t,
238
- ...p
239
- },
240
- css: [s, o],
241
- children: /* @__PURE__ */ T(D, {
242
- elementsRef: m,
243
- children: /* @__PURE__ */ T(L.Provider, {
244
- value: !0,
245
- children: r
246
- })
247
- })
248
- }) });
249
- }), G = _(function({ value: e, disabled: t = !1, onClick: n, children: r, ...i }, o) {
250
- let { baseId: s, selectedValue: m, activeIndex: h, options: g, isVisible: _, getItemProps: v, selectValue: y, registration: ee } = z("Item"), b = S(null), { ref: x, index: C } = u(e, ee, b, (e, n) => ({
251
- index: e,
252
- label: n,
253
- disabled: t
254
- })), w = j([x, o]), D = g.get(e)?.label, O = D !== void 0 && !_(D), te = C !== -1 && h === C, k = m === e, A = (r) => {
255
- n?.(r), !(t || r.defaultPrevented) && y(e);
256
- };
257
- return /* @__PURE__ */ E("div", {
258
- ...v({
259
- id: f(s, e),
260
- ...i,
261
- onClick: A
262
- }),
263
- ref: w,
264
- role: "option",
265
- hidden: O,
266
- "aria-selected": k,
267
- "aria-disabled": t || void 0,
268
- "data-active": te || void 0,
269
- "data-ui": "combobox-item",
270
- css: [
271
- d,
272
- l,
273
- c,
274
- B
275
- ],
276
- children: [/* @__PURE__ */ T("span", {
277
- ref: b,
278
- css: p,
279
- children: r
280
- }), k && /* @__PURE__ */ T("span", {
281
- "aria-hidden": "true",
282
- css: a,
283
- children: N
284
- })]
285
- });
286
- }), K = _(function({ children: e, ...t }, n) {
287
- let { matchCount: i } = z("Empty");
288
- return i > 0 ? null : /* @__PURE__ */ T("div", {
289
- ...t,
290
- ref: n,
291
- "data-ui": "combobox-empty",
292
- css: V,
293
- children: r(e) ? e : P
294
- });
295
- }), q = Object.assign(H, {
296
- Input: U,
297
- List: W,
298
- Item: G,
299
- Empty: K
300
- });
301
- //#endregion
302
- export { q as t };
@@ -1,35 +0,0 @@
1
- 'use client';
2
- import { t as e } from "./css-Cgj6sCHn.js";
3
- import { n as t } from "./layout-style-7ZTOiWGR.js";
4
- import { forwardRef as n } from "react";
5
- import { jsx as r } from "@emotion/react/jsx-runtime";
6
- //#region src/components/container/container.tsx
7
- var i = {
8
- sm: "640px",
9
- md: "768px",
10
- lg: "1024px",
11
- xl: "1280px"
12
- }, a = e({
13
- boxSizing: "border-box",
14
- inlineSize: "100%",
15
- marginInline: "auto"
16
- }), o = {
17
- sm: e({ maxInlineSize: i.sm }),
18
- md: e({ maxInlineSize: i.md }),
19
- lg: e({ maxInlineSize: i.lg }),
20
- xl: e({ maxInlineSize: i.xl })
21
- }, s = t("paddingInline"), c = n(function({ size: e = "lg", paddingInline: t = "md", ...n }, i) {
22
- return /* @__PURE__ */ r("div", {
23
- ...n,
24
- ref: i,
25
- "data-ui": "container",
26
- "data-size": e,
27
- css: [
28
- a,
29
- o[e],
30
- s[t]
31
- ]
32
- });
33
- });
34
- //#endregion
35
- export { c as t };
@@ -1,240 +0,0 @@
1
- 'use client';
2
- import { t as e } from "./css-Cgj6sCHn.js";
3
- import { t } from "./use-controlled-state-CVXDa-qM.js";
4
- import { t as n } from "./renderable-DzcIj1Lo.js";
5
- import { t as r } from "./calendar-DUgS0xmp.js";
6
- import { n as i } from "./surface-DZ4d-2aL.js";
7
- import { t as a } from "./use-overlay-floating-efeqppiw.js";
8
- import { t as o } from "./text-field-DDPqQu29.js";
9
- import { createContext as s, forwardRef as c, useContext as l, useEffect as u, useId as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
10
- import { vars as g } from "@jfrader/tokens/vars";
11
- import { jsx as _, jsxs as v } from "@emotion/react/jsx-runtime";
12
- import { FloatingFocusManager as y, FloatingPortal as b, useClick as x, useDismiss as S, useInteractions as C, useMergeRefs as w, useRole as T } from "@floating-ui/react";
13
- //#region src/components/date-picker/date-picker.tsx
14
- var E = "bottom-start", D = /* @__PURE__ */ new Set(["Enter", "ArrowDown"]), O = " ", k = "[data-ui=\"calendar-day\"][tabindex=\"0\"]", A = "[data-ui=\"calendar-day\"]", j = /^\d{4}-\d{2}-\d{2}$/, M = {
15
- calendar: "gregory",
16
- timeZone: "UTC",
17
- dateStyle: "medium"
18
- }, N = s(null);
19
- function P(e) {
20
- let t = l(N);
21
- if (!t) throw Error(`DatePicker.${e} must be rendered inside <DatePicker>.`);
22
- return t;
23
- }
24
- var F = (e, t) => String(e).padStart(t, "0"), I = (e, t, n) => `${F(e, 4)}-${F(t, 2)}-${F(n, 2)}`;
25
- function L(e) {
26
- if (e === void 0 || !j.test(e)) return;
27
- let [t = NaN, n = NaN, r = NaN] = e.split("-").map(Number), i = new Date(Date.UTC(0, 0, 1));
28
- return i.setUTCFullYear(t, n - 1, r), I(i.getUTCFullYear(), i.getUTCMonth() + 1, i.getUTCDate()) === e ? i : void 0;
29
- }
30
- var R = (e) => L(e) ? e : void 0;
31
- function ee(e, t, n) {
32
- return t !== void 0 && e < t ? t : n !== void 0 && e > n ? n : e;
33
- }
34
- function te() {
35
- let e = /* @__PURE__ */ new Date();
36
- return I(e.getFullYear(), e.getMonth() + 1, e.getDate());
37
- }
38
- var ne = () => typeof navigator > "u" ? void 0 : navigator.language;
39
- function re(e, t) {
40
- let n = new Intl.DisplayNames(t, { type: "dateTimeField" });
41
- return e.formatToParts(/* @__PURE__ */ new Date(0)).map((e) => e.type === "literal" ? e.value : n.of(e.type) ?? e.value).join("");
42
- }
43
- function z(e) {
44
- let t = e?.querySelector(k) ?? null;
45
- return t?.focus({ preventScroll: !0 }), t;
46
- }
47
- var B = e({
48
- cursor: "pointer",
49
- "&:disabled": { cursor: "not-allowed" }
50
- }), V = e({
51
- ...i,
52
- borderRadius: g.radius.md,
53
- boxShadow: g.shadow.overlay,
54
- padding: g.space[3]
55
- });
56
- function H({ value: e, defaultValue: n, onValueChange: r, open: i, defaultOpen: o = !1, onOpenChange: s, min: c, max: l, locale: d, firstDayOfWeek: f, disabled: g = !1, name: y, placeholder: b, children: w }) {
57
- let [D, O] = t(e, n, r), [k = !1, A] = t(i, o, s), [j, P] = h(!1), F = g || j, I = k && !F, [z, B] = h(null), V = m(null), H = m(!1), U = p(() => new Intl.DateTimeFormat(d ?? ne()).resolvedOptions().locale, [d]), W = p(() => new Intl.DateTimeFormat(U, M), [U]), G = p(() => re(W, U), [W, U]), K = L(D), q = K ? W.format(K) : "", J = R(c), Y = R(l), X = ee(R(D) ?? te(), J, Y).slice(0, 7), { refs: Z, floatingStyles: Q, context: $ } = a({
58
- open: I,
59
- placement: E,
60
- onOpenChange: (e, t, n) => {
61
- F && e || (e || (H.current = n === "escape-key"), A(e));
62
- }
63
- });
64
- u(() => {
65
- F && (H.current = !1, k && A(!1));
66
- }, [
67
- F,
68
- k,
69
- A
70
- ]), u(() => {
71
- !F && !I && H.current && (H.current = !1, Z.domReference.current?.focus());
72
- }, [
73
- F,
74
- I,
75
- Z
76
- ]);
77
- let ie = x($, {
78
- enabled: !F,
79
- keyboardHandlers: !1
80
- }), ae = S($, {
81
- escapeKey: !0,
82
- outsidePress: !0
83
- }), oe = T($, { role: "dialog" }), { getReferenceProps: se, getFloatingProps: ce } = C([
84
- ie,
85
- ae,
86
- oe
87
- ]), le = p(() => ({
88
- open: I,
89
- disabled: F,
90
- value: D,
91
- displayValue: q,
92
- placeholder: b ?? G,
93
- initialMonth: X,
94
- min: J,
95
- max: Y,
96
- locale: U,
97
- firstDayOfWeek: f,
98
- inputLabelling: z,
99
- gridRef: V,
100
- refs: Z,
101
- floatingContext: $,
102
- floatingStyles: Q,
103
- getReferenceProps: se,
104
- getFloatingProps: ce,
105
- requestOpenChange: (e) => {
106
- F && e || A(e);
107
- },
108
- selectDate: (e) => {
109
- F || (O(e), H.current = !0, A(!1));
110
- },
111
- setInputLabelling: B,
112
- setInputDisabled: P
113
- }), [
114
- I,
115
- F,
116
- D,
117
- q,
118
- b,
119
- G,
120
- X,
121
- J,
122
- Y,
123
- U,
124
- f,
125
- z,
126
- Z,
127
- $,
128
- Q,
129
- se,
130
- ce,
131
- A,
132
- O
133
- ]);
134
- return /* @__PURE__ */ v(N.Provider, {
135
- value: le,
136
- children: [w, y !== void 0 && /* @__PURE__ */ _("input", {
137
- type: "hidden",
138
- name: y,
139
- value: D ?? "",
140
- disabled: F
141
- })]
142
- });
143
- }
144
- var U = c(function({ label: e, id: t, disabled: r, slotProps: i, onKeyDown: a, onKeyUp: s, ...c }, l) {
145
- let { open: u, disabled: p, displayValue: m, placeholder: h, gridRef: g, refs: v, getReferenceProps: y, requestOpenChange: b, setInputLabelling: x, setInputDisabled: S } = P("Input"), C = w([v.setReference, l]), T = d(), E = t ?? T, k = `${E}-label`, A = n(e), j = c["aria-labelledby"], M = c["aria-label"], N = M ?? (typeof e == "string" ? e : void 0), F = p || r === !0;
146
- f(() => (S(r === !0), () => S(!1)), [r, S]), f(() => (x(j === void 0 ? M === void 0 ? typeof e == "string" ? { label: e } : { labelledBy: A ? k : void 0 } : { label: M } : { labelledBy: j }), () => x(null)), [
147
- j,
148
- M,
149
- e,
150
- A,
151
- k,
152
- x
153
- ]);
154
- let I = () => {
155
- F || (u ? z(g.current) : b(!0));
156
- }, L = (e) => {
157
- a?.(e), !(e.defaultPrevented || F) && (e.key === O ? e.preventDefault() : D.has(e.key) && (e.preventDefault(), I()));
158
- }, R = (e) => {
159
- s?.(e), !(e.defaultPrevented || F || e.key !== O) && I();
160
- };
161
- return /* @__PURE__ */ _(o, {
162
- ...y({
163
- ...c,
164
- onKeyDown: L,
165
- onKeyUp: R
166
- }),
167
- ref: C,
168
- id: E,
169
- label: A ? /* @__PURE__ */ _("span", {
170
- id: k,
171
- children: e
172
- }) : e,
173
- slotProps: {
174
- ...i,
175
- control: {
176
- ...i?.control,
177
- css: [B, i?.control?.css]
178
- }
179
- },
180
- value: m,
181
- placeholder: h,
182
- disabled: F,
183
- readOnly: !0,
184
- role: "combobox",
185
- "aria-label": N,
186
- "aria-autocomplete": "none",
187
- "data-state": u ? "open" : "closed",
188
- "data-ui": "date-picker-input"
189
- });
190
- }), W = c(function({ style: e, ...t }, n) {
191
- let { open: i, value: a, initialMonth: o, min: s, max: c, locale: l, firstDayOfWeek: u, inputLabelling: d, gridRef: f, refs: p, floatingContext: h, floatingStyles: g, getFloatingProps: x, selectDate: S } = P("Popup"), C = w([p.setFloating, n]), T = m(null), E = w([(e) => {
192
- f.current = e, T.current = z(e);
193
- }]);
194
- if (!i) return null;
195
- let D = t["aria-labelledby"] !== void 0 || t["aria-label"] !== void 0 ? {} : d?.labelledBy === void 0 ? { "aria-label": d?.label } : { "aria-labelledby": d.labelledBy }, O = (e) => {
196
- let t = e.target.closest(A);
197
- if (t?.disabled) return;
198
- let n = t?.dataset.date;
199
- n !== void 0 && S(n);
200
- }, k = (e) => {
201
- e.target.closest(A)?.disabled && e.preventDefault();
202
- };
203
- return /* @__PURE__ */ _(b, { children: /* @__PURE__ */ _(y, {
204
- context: h,
205
- modal: !1,
206
- initialFocus: T,
207
- returnFocus: !1,
208
- children: /* @__PURE__ */ _("div", {
209
- ...x({
210
- ...D,
211
- ...t
212
- }),
213
- ref: C,
214
- "data-ui": "date-picker-popup",
215
- style: {
216
- ...e,
217
- ...g
218
- },
219
- css: V,
220
- children: /* @__PURE__ */ v(r, {
221
- value: a ?? "",
222
- defaultVisibleMonth: o,
223
- min: s,
224
- max: c,
225
- locale: l,
226
- firstDayOfWeek: u,
227
- children: [/* @__PURE__ */ _(r.Header, {}), /* @__PURE__ */ _(r.Grid, {
228
- ref: E,
229
- onClick: O,
230
- onPointerDownCapture: k
231
- })]
232
- })
233
- })
234
- }) });
235
- }), G = Object.assign(H, {
236
- Input: U,
237
- Popup: W
238
- });
239
- //#endregion
240
- export { G as t };