@box-kite/react 2.2.9 → 2.2.10

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.
@@ -3,26 +3,26 @@ import { f as e } from "../react-shared.mjs";
3
3
  import t from "../box.mjs";
4
4
  import { a as n, t as r } from "../behavior.mjs";
5
5
  import { t as i } from "../placement.mjs";
6
- import { n as a, t as o } from "../dates.mjs";
7
- import { A as s, N as c, O as l, i as u, r as d, x as f } from "../date-math.mjs";
8
- import { l as p, s as m } from "../date-input.mjs";
9
- import { a as h, t as g } from "../reporting.mjs";
10
- import { Path as _, Svg as v } from "./svg.mjs";
11
- import { n as ee } from "../date-environment.mjs";
12
- import te from "./calendar.mjs";
13
- import { t as y } from "../layer.mjs";
14
- import b from "./overlay.mjs";
15
- import x from "./dateField.mjs";
16
- import { useCallback as S, useEffect as C, useMemo as w, useState as T } from "react";
17
- import { Fragment as ne, jsx as E, jsxs as D } from "react/jsx-runtime";
6
+ import { n as a, s as o, t as s } from "../dates.mjs";
7
+ import { A as c, N as l, O as u, i as d, r as f, x as p } from "../date-math.mjs";
8
+ import { l as m, s as h } from "../date-input.mjs";
9
+ import { a as g, t as _ } from "../reporting.mjs";
10
+ import { Path as v, Svg as y } from "./svg.mjs";
11
+ import { n as b } from "../date-environment.mjs";
12
+ import ee from "./calendar.mjs";
13
+ import { t as x } from "../layer.mjs";
14
+ import S from "./overlay.mjs";
15
+ import C from "./dateField.mjs";
16
+ import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as O } from "react";
17
+ import { Fragment as te, jsx as k, jsxs as A } from "react/jsx-runtime";
18
18
  //#region src/components/datePicker.tsx
19
- function re() {
20
- return /* @__PURE__ */ E(v, {
19
+ function ne() {
20
+ return /* @__PURE__ */ k(y, {
21
21
  viewBox: "0 0 16 16",
22
22
  width: "1rem",
23
23
  height: "1rem",
24
24
  props: { fill: "none" },
25
- children: /* @__PURE__ */ E(_, {
25
+ children: /* @__PURE__ */ k(v, {
26
26
  d: "M3 3.5h10a1 1 0 0 1 1 1V13a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5a1 1 0 0 1 1-1ZM2 7h12M5.5 2v3M10.5 2v3",
27
27
  stroke: "currentColor",
28
28
  strokeWidth: 1.5,
@@ -30,13 +30,13 @@ function re() {
30
30
  })
31
31
  });
32
32
  }
33
- function ie() {
34
- return /* @__PURE__ */ E(v, {
33
+ function re() {
34
+ return /* @__PURE__ */ k(y, {
35
35
  viewBox: "0 0 16 16",
36
36
  width: "1rem",
37
37
  height: "1rem",
38
38
  props: { fill: "none" },
39
- children: /* @__PURE__ */ E(_, {
39
+ children: /* @__PURE__ */ k(v, {
40
40
  d: "M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12ZM8 5v3l2 1.5",
41
41
  stroke: "currentColor",
42
42
  strokeWidth: 1.5,
@@ -45,13 +45,13 @@ function ie() {
45
45
  })
46
46
  });
47
47
  }
48
- function ae() {
49
- return /* @__PURE__ */ E(v, {
48
+ function ie() {
49
+ return /* @__PURE__ */ k(y, {
50
50
  viewBox: "0 0 16 16",
51
51
  width: "0.875rem",
52
52
  height: "0.875rem",
53
53
  props: { fill: "none" },
54
- children: /* @__PURE__ */ E(_, {
54
+ children: /* @__PURE__ */ k(v, {
55
55
  d: "m4.5 4.5 7 7m0-7-7 7",
56
56
  stroke: "currentColor",
57
57
  strokeWidth: 1.5,
@@ -59,12 +59,12 @@ function ae() {
59
59
  })
60
60
  });
61
61
  }
62
- function O(e, t) {
62
+ function j(e, t) {
63
63
  typeof e == "function" ? e(t) : e && (e.current = t);
64
64
  }
65
- function oe(e) {
66
- let [r, a] = T(null), o = e.ref, s = S((e) => {
67
- a(e), O(o, e);
65
+ function ae(e) {
66
+ let [r, a] = O(null), o = e.ref, s = w((e) => {
67
+ a(e), j(o, e);
68
68
  }, [o]), c = (e) => {
69
69
  if (!e || e.contains(document.activeElement) && document.activeElement !== e) return;
70
70
  let t = [
@@ -73,7 +73,7 @@ function oe(e) {
73
73
  "button:not([disabled])"
74
74
  ].map((t) => e.querySelector(t)).find(Boolean), n = e.querySelector("[role=\"listbox\"]"), r = n?.querySelector("[role=\"option\"][tabindex=\"0\"]");
75
75
  n && r && (n.scrollTop = r.offsetTop - n.clientHeight / 2 + r.offsetHeight / 2), (t ?? e).focus({ preventScroll: !0 });
76
- }, l = n((e) => c(e)), { platform: u, isOpen: d, id: f, setPanel: p, setOpen: m, trigger: h, triggerElement: g, panelElement: _ } = y({
76
+ }, l = n((e) => c(e)), { platform: u, isOpen: d, id: f, setPanel: p, setOpen: m, trigger: h, triggerElement: g, panelElement: _ } = x({
77
77
  haspopup: "dialog",
78
78
  idPrefix: "date-picker",
79
79
  open: e.open,
@@ -92,13 +92,15 @@ function oe(e) {
92
92
  align: e.align,
93
93
  offset: 1,
94
94
  flip: !0,
95
+ matchWidth: e.matchWidth,
95
96
  anchor: r
96
97
  });
97
- return C(() => {
98
+ return T(() => {
98
99
  d && c(_);
99
100
  }, [d, _]), {
100
101
  attachTrigger: h.ref,
101
102
  triggerAttributes: h.props,
103
+ triggerElement: g,
102
104
  closeOnChoice: (e) => {
103
105
  g?.focus(), m(!1, {
104
106
  reason: "select",
@@ -113,7 +115,7 @@ function oe(e) {
113
115
  "aria-label": e.label,
114
116
  tabIndex: -1
115
117
  };
116
- return u ? /* @__PURE__ */ E(t, {
118
+ return u ? /* @__PURE__ */ k(t, {
117
119
  ref: p,
118
120
  component: "popover",
119
121
  variant: { topLayer: !0 },
@@ -125,12 +127,13 @@ function oe(e) {
125
127
  ...i
126
128
  },
127
129
  children: d ? n : null
128
- }) : d && /* @__PURE__ */ E(b, {
130
+ }) : d && /* @__PURE__ */ k(S, {
129
131
  contentRef: p,
130
132
  anchor: r,
131
133
  side: e.side,
132
134
  align: e.align,
133
135
  offset: 1,
136
+ matchWidth: e.matchWidth,
134
137
  component: "popover",
135
138
  p: 3,
136
139
  id: f,
@@ -140,31 +143,51 @@ function oe(e) {
140
143
  }
141
144
  };
142
145
  }
143
- function se(e) {
144
- let { value: n, step: i, locale: a, hourCycle: s, onSelect: c, label: l } = e, u = w(() => p(i), [i]), d = m(n, i), f = Math.max(0, d ? u.indexOf(d) : u.indexOf("09:00:00")), h = r({
145
- count: u.length,
146
- defaultActiveIndex: f,
146
+ function oe(e) {
147
+ let { value: n, step: i, locale: a, hourCycle: o, onSelect: c, label: l, min: u, max: d, emptyLabel: f, separated: p } = e, g = E(() => m(i, {
148
+ min: u,
149
+ max: d
150
+ }), [
151
+ i,
152
+ u,
153
+ d
154
+ ]), _ = h(n, i), v = Math.max(0, _ ? g.indexOf(_) : g.indexOf("09:00:00")), y = r({
155
+ count: g.length,
156
+ defaultActiveIndex: v,
147
157
  loop: !1,
148
- onSelect: (e, t) => c(u[e], t)
149
- });
150
- return /* @__PURE__ */ E(t, {
158
+ onSelect: (e, t) => c(g[e], t)
159
+ }), b = p ? {
160
+ ps: 2,
161
+ bs: 1
162
+ } : {};
163
+ return g.length === 0 ? /* @__PURE__ */ k(t, {
164
+ component: "datePicker.empty",
165
+ flexGrow: 1,
166
+ px: 3,
167
+ py: 1.5,
168
+ fontSize: 14,
169
+ ...b,
170
+ props: { role: "status" },
171
+ children: f
172
+ }) : /* @__PURE__ */ k(t, {
151
173
  component: "datePicker.times",
152
174
  position: "relative",
153
175
  display: "flex",
154
176
  d: "column",
177
+ flexGrow: 1,
155
178
  gap: .5,
156
179
  maxHeight: 72,
157
180
  overflowY: "auto",
158
- ps: 2,
159
- bs: 1,
181
+ p: 1,
182
+ ...b,
160
183
  props: {
161
184
  role: "listbox",
162
185
  "aria-label": l,
163
- onKeyDown: h.onKeyDown
186
+ onKeyDown: y.onKeyDown
164
187
  },
165
- children: u.map((e, n) => /* @__PURE__ */ E(t, {
188
+ children: g.map((e, n) => /* @__PURE__ */ k(t, {
166
189
  component: "datePicker.time",
167
- variant: { selected: e === d },
190
+ variant: { selected: e === _ },
168
191
  px: 3,
169
192
  py: 1.5,
170
193
  borderRadius: 2,
@@ -174,21 +197,21 @@ function se(e) {
174
197
  css: { fontVariantNumeric: "tabular-nums" },
175
198
  props: {
176
199
  role: "option",
177
- "aria-selected": e === d,
178
- ...h.itemProps(n),
200
+ "aria-selected": e === _,
201
+ ...y.itemProps(n),
179
202
  onClick: (t) => c(e, t)
180
203
  },
181
- children: o(e, {
204
+ children: s(e, {
182
205
  locale: a,
183
206
  hour: "numeric",
184
207
  minute: "2-digit",
185
- hourCycle: s === void 0 ? void 0 : s === 12 ? "h12" : "h23"
208
+ hourCycle: o === void 0 ? void 0 : o === 12 ? "h12" : "h23"
186
209
  })
187
210
  }, e))
188
211
  });
189
212
  }
190
- function ce(e) {
191
- return /* @__PURE__ */ E(t, {
213
+ function se(e) {
214
+ return /* @__PURE__ */ k(t, {
192
215
  component: "datePicker.presets",
193
216
  display: "flex",
194
217
  d: "column",
@@ -196,7 +219,7 @@ function ce(e) {
196
219
  pe: 2,
197
220
  be: 1,
198
221
  props: { role: "group" },
199
- children: e.presets.map((n) => /* @__PURE__ */ E(t, {
222
+ children: e.presets.map((n) => /* @__PURE__ */ k(t, {
200
223
  tag: "button",
201
224
  component: "datePicker.preset",
202
225
  variant: { selected: e.isSelected(n.value) },
@@ -214,56 +237,162 @@ function ce(e) {
214
237
  }, n.label))
215
238
  });
216
239
  }
217
- function k(e, n) {
218
- let { type: r = "date", value: i, defaultValue: a = null, onValueChange: p, zone: m, locale: _, hourCycle: v, granularity: y, disambiguation: b, min: S, max: C, isDateUnavailable: w, disabled: T = !1, readOnly: O = !1, required: k, invalid: A, name: j, label: M, labelledBy: le, describedBy: ue, open: N, defaultOpen: P, onOpenChange: de, closeOnSelect: F = !0, firstDayOfWeek: I, weekNumbers: fe, side: L = "bottom", align: pe = "start", clearable: R = !1, triggerLabel: z, clearLabel: B = "Clear", tabIndex: V, step: H = 30, defaultTime: U = "00:00", presets: W, showZone: me, ...he } = e, G = ee({
219
- locale: _,
220
- zone: m === "none" ? void 0 : m
221
- }), { locale: K } = G, q = r === "datetime" && m !== "none" ? G.zone : null, J = q ?? G.zone, [Y, X] = h({
240
+ function ce(e) {
241
+ let { frame: r, attachField: i, attachTrigger: a, triggerAttributes: o, triggerElement: s, id: c, label: l, labelledBy: u, describedBy: d } = e, { text: f, placeholder: p, icon: m, clear: h, disabled: g, invalid: _, required: v = !1, tabIndex: y, inputs: b, onReset: ee } = e, x = D(null), S = l === void 0 ? void 0 : `${c}-label`, C = `${c}-value`, w = n(ee);
242
+ return T(() => {
243
+ let e = x.current?.form;
244
+ if (e) return e.addEventListener("reset", w), () => e.removeEventListener("reset", w);
245
+ }, [w]), /* @__PURE__ */ A(te, { children: [l !== void 0 && /* @__PURE__ */ k(t, {
246
+ component: "dateField.label",
247
+ display: "block",
248
+ mb: 1.5,
249
+ fontSize: 14,
250
+ id: S,
251
+ props: { onClick: () => s?.focus() },
252
+ children: l
253
+ }), /* @__PURE__ */ A(t, {
254
+ ref: i,
255
+ component: "dateField",
256
+ display: "inline-flex",
257
+ ai: "center",
258
+ position: "relative",
259
+ cursor: "pointer",
260
+ css: { fontVariantNumeric: "tabular-nums" },
261
+ ...r,
262
+ variant: [r.variant, {
263
+ disabled: g,
264
+ invalid: _
265
+ }],
266
+ children: [
267
+ /* @__PURE__ */ k(t, {
268
+ tag: "button",
269
+ ref: a,
270
+ component: "datePicker.value",
271
+ variant: { placeholder: !f },
272
+ flexGrow: 1,
273
+ textAlign: "start",
274
+ whiteSpace: "nowrap",
275
+ css: { font: "inherit" },
276
+ after: {
277
+ position: "absolute",
278
+ inset: 0
279
+ },
280
+ disabled: g,
281
+ props: {
282
+ type: "button",
283
+ tabIndex: y,
284
+ "aria-labelledby": [
285
+ S,
286
+ u,
287
+ C
288
+ ].filter(Boolean).join(" "),
289
+ "aria-describedby": d,
290
+ "aria-invalid": _ || void 0,
291
+ ...o
292
+ },
293
+ children: /* @__PURE__ */ k("span", {
294
+ id: C,
295
+ children: f || p
296
+ })
297
+ }),
298
+ /* @__PURE__ */ A(t, {
299
+ display: "inline-flex",
300
+ ai: "center",
301
+ gap: 1,
302
+ ms: 2,
303
+ children: [h, /* @__PURE__ */ k(t, {
304
+ component: "datePicker.icon",
305
+ display: "inline-flex",
306
+ ai: "center",
307
+ jc: "center",
308
+ width: 7,
309
+ height: 7,
310
+ me: -1.5,
311
+ props: { "aria-hidden": !0 },
312
+ children: m
313
+ })]
314
+ }),
315
+ b.map((e, n) => v ? /* @__PURE__ */ k(t, {
316
+ tag: "input",
317
+ ref: n === 0 ? x : void 0,
318
+ component: "dateField.validation",
319
+ required: !0,
320
+ disabled: g,
321
+ props: {
322
+ type: "text",
323
+ name: e.name,
324
+ value: e.value,
325
+ tabIndex: -1,
326
+ "aria-hidden": !0,
327
+ onChange: () => {},
328
+ onFocus: () => s?.focus()
329
+ }
330
+ }, n) : e.name === void 0 ? null : /* @__PURE__ */ k("input", {
331
+ ref: n === 0 ? x : void 0,
332
+ type: "hidden",
333
+ name: e.name,
334
+ value: e.value,
335
+ disabled: g
336
+ }, n))
337
+ ]
338
+ })] });
339
+ }
340
+ function M(e, n) {
341
+ let { type: r = "date", value: i, defaultValue: a = null, onValueChange: m, zone: h, locale: v, hourCycle: y, granularity: x, disambiguation: S, min: w, max: T, isDateUnavailable: E, disabled: D = !1, readOnly: O = !1, required: j, invalid: M, name: N, label: P, labelledBy: le, describedBy: ue, open: de, defaultOpen: fe, onOpenChange: pe, closeOnSelect: F = !0, firstDayOfWeek: I, weekNumbers: me, side: L = "bottom", align: R = "start", matchWidth: he = r === "time", emptyTimesLabel: z = "No times available", clearable: ge = !1, pickOnly: B = !1, triggerLabel: _e, clearLabel: ve = "Clear", tabIndex: V, step: H = 30, defaultTime: U = "00:00", presets: W, showZone: G, ...ye } = e, K = b({
342
+ locale: v,
343
+ zone: h === "none" ? void 0 : h
344
+ }), { locale: q } = K, J = r === "datetime" && h !== "none" ? K.zone : null, Y = J ?? K.zone, [X, Z] = g({
222
345
  value: i,
223
346
  defaultValue: a,
224
- onChange: (e, t) => p?.(e, {
347
+ onChange: (e, t) => m?.(e, {
225
348
  ...t,
226
- ...f(e, J)
349
+ ...p(e, Y)
227
350
  }),
228
351
  interaction: {
229
352
  component: "datePicker",
230
353
  type: "valueChange",
231
354
  content: ["value"]
232
355
  }
233
- }), Z = z ?? (r === "time" ? "Choose time" : "Choose date"), Q = typeof M == "string" ? M : Z, { attachTrigger: ge, triggerAttributes: _e, closeOnChoice: ve, attachField: ye, panel: be } = oe({
356
+ }), Q = _e ?? (r === "time" ? "Choose time" : "Choose date"), be = typeof P == "string" ? P : Q, { attachTrigger: xe, triggerAttributes: Se, triggerElement: Ce, closeOnChoice: we, id: Te, attachField: Ee, panel: De } = ae({
234
357
  ref: n,
235
- open: N,
236
- defaultOpen: P,
237
- onOpenChange: de,
358
+ open: de,
359
+ defaultOpen: fe,
360
+ onOpenChange: pe,
238
361
  side: L,
239
- align: pe,
240
- label: Q
241
- }), xe = Y && r !== "time" ? l(Y, { zone: J }) : null, Se = Y && r !== "date" ? s(Y, { zone: J }) : null, Ce = Y ? o(Y, {
242
- locale: K,
243
- zone: J,
362
+ align: R,
363
+ matchWidth: he,
364
+ label: be
365
+ }), $ = X && r !== "time" ? u(X, { zone: Y }) : null, Oe = X && r !== "date" ? c(X, { zone: Y }) : null, ke = r === "datetime" ? $ ?? l(Y) : null, Ae = (e) => e && (ke === null || u(e, { zone: Y }) === ke) ? c(e, { zone: Y }) : null, je = X ? s(X, {
366
+ locale: q,
367
+ zone: Y,
368
+ hourCycle: y === void 0 ? void 0 : y === 12 ? "h12" : "h23",
244
369
  ...r === "date" ? { dateStyle: "medium" } : r === "time" ? { timeStyle: "short" } : {
245
370
  dateStyle: "medium",
246
371
  timeStyle: "short"
247
372
  }
248
- }) : "", $ = ve, we = (e, t) => d(e, t, q ? {
249
- zone: q,
250
- disambiguation: b
251
- } : {}), Te = (e, t) => {
252
- e && (r === "date" ? (X(e, {
373
+ }) : "", Me = B && X && J && (G ?? J !== K.readerZone) ? o(J, {
374
+ locale: q,
375
+ style: "short",
376
+ at: X
377
+ }) : null, Ne = we, Pe = (e, t) => f(e, t, J ? {
378
+ zone: J,
379
+ disambiguation: S
380
+ } : {}), Fe = (e, t) => {
381
+ e && (r === "date" ? (Z(e, {
253
382
  reason: "select",
254
383
  event: t
255
- }), F && $(t)) : X(we(e, Se ?? U), {
384
+ }), F && Ne(t)) : Z(Pe(e, Oe ?? U), {
256
385
  reason: "select",
257
386
  event: t
258
387
  }));
259
- }, Ee = (e, t) => {
260
- X(r === "time" ? e : we(xe ?? c(J), e), {
388
+ }, Ie = (e, t) => {
389
+ Z(r === "time" ? e : Pe($ ?? l(Y), e), {
261
390
  reason: "select",
262
391
  event: t
263
- }), F && $(t);
264
- }, De = /* @__PURE__ */ E(t, {
392
+ }), F && Ne(t);
393
+ }, Le = /* @__PURE__ */ k(t, {
265
394
  tag: "button",
266
- ref: ge,
395
+ ref: xe,
267
396
  component: "datePicker.trigger",
268
397
  display: "inline-flex",
269
398
  ai: "center",
@@ -273,15 +402,15 @@ function k(e, n) {
273
402
  ms: 2,
274
403
  me: -1.5,
275
404
  borderRadius: 1.5,
276
- disabled: T || O,
405
+ disabled: D || O,
277
406
  props: {
278
407
  type: "button",
279
- "aria-label": Ce ? `${Z}, ${Ce}` : Z,
408
+ "aria-label": je ? `${Q}, ${je}` : Q,
280
409
  tabIndex: V,
281
- ..._e
410
+ ...Se
282
411
  },
283
- children: E(r === "time" ? ie : re, {})
284
- }), Oe = R && Y && !T && !O && /* @__PURE__ */ E(t, {
412
+ children: k(r === "time" ? re : ne, {})
413
+ }), Re = ge && X && !D && !O && /* @__PURE__ */ k(t, {
285
414
  tag: "button",
286
415
  component: "datePicker.clear",
287
416
  display: "inline-flex",
@@ -291,84 +420,116 @@ function k(e, n) {
291
420
  height: 6,
292
421
  ms: 1,
293
422
  borderRadius: 999,
423
+ position: "relative",
424
+ zIndex: 1,
294
425
  props: {
295
426
  type: "button",
296
- "aria-label": B,
427
+ "aria-label": ve,
297
428
  tabIndex: V,
298
- onClick: (e) => X(null, {
429
+ onClick: (e) => Z(null, {
299
430
  reason: "clear",
300
431
  event: e
301
432
  })
302
433
  },
303
- children: /* @__PURE__ */ E(ae, {})
304
- });
305
- return /* @__PURE__ */ D(g, { children: [/* @__PURE__ */ E(x, {
306
- ref: ye,
307
- ...he,
434
+ children: /* @__PURE__ */ k(ie, {})
435
+ }), ze = X !== null && (w != null && d(X, w) < 0 || T != null && d(X, T) > 0), Be = B ? /* @__PURE__ */ k(ce, {
436
+ frame: ye,
437
+ attachField: Ee,
438
+ attachTrigger: O ? void 0 : xe,
439
+ triggerAttributes: O ? void 0 : Se,
440
+ triggerElement: Ce,
441
+ id: Te,
442
+ label: P,
443
+ labelledBy: le,
444
+ describedBy: ue,
445
+ text: Me ? `${je} ${Me}` : je,
446
+ placeholder: Q,
447
+ icon: k(r === "time" ? re : ne, {}),
448
+ clear: Re,
449
+ disabled: D,
450
+ invalid: M ?? (ze || $ !== null && !!E?.($)),
451
+ required: j,
452
+ tabIndex: V,
453
+ inputs: [{
454
+ name: N,
455
+ value: X ?? ""
456
+ }],
457
+ onReset: (e) => Z(a, {
458
+ reason: "reset",
459
+ event: e
460
+ })
461
+ }) : /* @__PURE__ */ k(C, {
462
+ ref: Ee,
463
+ ...ye,
308
464
  type: r,
309
- value: Y,
310
- onValueChange: (e, t) => X(e, {
465
+ value: X,
466
+ onValueChange: (e, t) => Z(e, {
311
467
  reason: t.reason,
312
468
  event: t.event
313
469
  }),
314
- zone: m,
315
- locale: _,
316
- hourCycle: v,
317
- granularity: y,
318
- disambiguation: b,
319
- min: S,
320
- max: C,
321
- isDateUnavailable: w,
322
- disabled: T,
470
+ zone: h,
471
+ locale: v,
472
+ hourCycle: y,
473
+ granularity: x,
474
+ disambiguation: S,
475
+ min: w,
476
+ max: T,
477
+ isDateUnavailable: E,
478
+ disabled: D,
323
479
  readOnly: O,
324
- required: k,
325
- invalid: A,
326
- name: j,
327
- label: M,
480
+ required: j,
481
+ invalid: M,
482
+ name: N,
483
+ label: P,
328
484
  labelledBy: le,
329
485
  describedBy: ue,
330
- showZone: me,
486
+ showZone: G,
331
487
  tabIndex: V,
332
- end: /* @__PURE__ */ D(ne, { children: [Oe, De] })
333
- }), be(/* @__PURE__ */ D(t, {
488
+ end: /* @__PURE__ */ A(te, { children: [Re, Le] })
489
+ });
490
+ return /* @__PURE__ */ A(_, { children: [Be, De(/* @__PURE__ */ A(t, {
334
491
  display: "flex",
335
492
  gap: 3,
336
493
  ai: "stretch",
337
494
  children: [
338
- W && W.length > 0 && /* @__PURE__ */ E(ce, {
495
+ W && W.length > 0 && /* @__PURE__ */ k(se, {
339
496
  presets: W,
340
- isSelected: (e) => Y !== null && u(e, Y, { zone: J }) === 0,
497
+ isSelected: (e) => X !== null && d(e, X, { zone: Y }) === 0,
341
498
  onSelect: (e, t) => {
342
- X(e, {
499
+ Z(e, {
343
500
  reason: "preset",
344
501
  event: t
345
- }), F && $(t);
502
+ }), F && Ne(t);
346
503
  }
347
504
  }),
348
- r !== "time" && /* @__PURE__ */ E(te, {
349
- value: xe,
350
- onValueChange: (e, t) => Te(e, t.event),
351
- min: S ? l(S, { zone: J }) : void 0,
352
- max: C ? l(C, { zone: J }) : void 0,
353
- isDateUnavailable: w,
354
- locale: _,
355
- zone: m === "none" ? void 0 : m,
505
+ r !== "time" && /* @__PURE__ */ k(ee, {
506
+ value: $,
507
+ onValueChange: (e, t) => Fe(e, t.event),
508
+ min: w ? u(w, { zone: Y }) : void 0,
509
+ max: T ? u(T, { zone: Y }) : void 0,
510
+ isDateUnavailable: E,
511
+ locale: v,
512
+ zone: h === "none" ? void 0 : h,
356
513
  firstDayOfWeek: I,
357
- weekNumbers: fe
514
+ weekNumbers: me
358
515
  }),
359
- r !== "date" && /* @__PURE__ */ E(se, {
360
- value: Se,
516
+ r !== "date" && /* @__PURE__ */ k(oe, {
517
+ value: Oe,
361
518
  step: H,
362
- locale: K,
363
- hourCycle: v,
364
- label: r === "time" ? Q : "Time",
365
- onSelect: Ee
519
+ locale: q,
520
+ hourCycle: y,
521
+ label: r === "time" ? be : "Time",
522
+ min: Ae(w),
523
+ max: Ae(T),
524
+ emptyLabel: z,
525
+ separated: r === "datetime",
526
+ onSelect: Ie
366
527
  })
367
528
  ]
368
529
  }))] });
369
530
  }
370
- function A(e, n) {
371
- let { value: r, defaultValue: i = null, onValueChange: o, locale: s, min: c, max: l, isDateUnavailable: d, disabled: f = !1, readOnly: p = !1, required: m, invalid: _, startName: v, endName: y, label: b, labelledBy: S, describedBy: C, startLabel: w = "Start date", endLabel: ne = "End date", open: ie, defaultOpen: O, onOpenChange: se, closeOnSelect: k = !0, firstDayOfWeek: A, weekNumbers: j, months: M = 2, side: le = "bottom", align: ue = "start", clearable: N = !1, triggerLabel: P = "Choose dates", clearLabel: de = "Clear", tabIndex: F, presets: I, props: fe, ...L } = e, { locale: pe } = ee({ locale: s }), [R, z] = h({
531
+ function N(e, n) {
532
+ let { value: r, defaultValue: i = null, onValueChange: o, locale: s, min: c, max: l, isDateUnavailable: u, disabled: f = !1, readOnly: p = !1, required: m, invalid: h, startName: v, endName: y, label: x, labelledBy: S, describedBy: w, startLabel: T = "Start date", endLabel: E = "End date", open: D, defaultOpen: re, onOpenChange: j, closeOnSelect: oe = !0, firstDayOfWeek: M, weekNumbers: N, months: P = 2, side: le = "bottom", align: ue = "start", matchWidth: de = !1, emptyTimesLabel: fe, clearable: pe = !1, pickOnly: F = !1, triggerLabel: I = "Choose dates", clearLabel: me = "Clear", tabIndex: L, presets: R, props: he, ...z } = e, { locale: ge } = b({ locale: s }), [B, _e] = g({
372
533
  value: r,
373
534
  defaultValue: i,
374
535
  onChange: o,
@@ -377,26 +538,27 @@ function A(e, n) {
377
538
  type: "valueChange",
378
539
  content: ["value"]
379
540
  }
380
- }), [B, V] = T({
381
- start: R?.start ?? null,
382
- end: R?.end ?? null,
383
- source: R
384
- }), { start: H, end: U } = B;
385
- B.source !== R && (H = R?.start ?? null, U = R?.end ?? null, V({
541
+ }), [ve, V] = O({
542
+ start: B?.start ?? null,
543
+ end: B?.end ?? null,
544
+ source: B
545
+ }), { start: H, end: U } = ve;
546
+ ve.source !== B && (H = B?.start ?? null, U = B?.end ?? null, V({
386
547
  start: H,
387
548
  end: U,
388
- source: R
549
+ source: B
389
550
  }));
390
- let { attachTrigger: W, triggerAttributes: me, closeOnChoice: he, id: G, attachField: K, panel: q } = oe({
551
+ let { attachTrigger: W, triggerAttributes: G, triggerElement: ye, closeOnChoice: K, id: q, attachField: J, panel: Y } = ae({
391
552
  ref: n,
392
- open: ie,
393
- defaultOpen: O,
394
- onOpenChange: se,
553
+ open: D,
554
+ defaultOpen: re,
555
+ onOpenChange: j,
395
556
  side: le,
396
557
  align: ue,
397
- label: typeof b == "string" ? b : P
398
- }), J = R ? a(R.start, R.end, { locale: pe }) : "", Y = H !== null && U !== null && u(H, U) > 0, X = (e, t, n, r) => {
399
- let i = e && t && u(e, t) <= 0 ? {
558
+ matchWidth: de,
559
+ label: typeof x == "string" ? x : I
560
+ }), X = B ? a(B.start, B.end, { locale: ge }) : "", Z = H !== null && U !== null && d(H, U) > 0, Q = (e, t, n, r) => {
561
+ let i = e && t && d(e, t) <= 0 ? {
400
562
  start: e,
401
563
  end: t
402
564
  } : null;
@@ -404,146 +566,173 @@ function A(e, n) {
404
566
  start: e,
405
567
  end: t,
406
568
  source: i
407
- }), z(i, {
569
+ }), _e(i, {
408
570
  reason: n,
409
571
  event: r
410
572
  });
411
- }, Z = he, Q = {
573
+ }, be = K, xe = {
412
574
  locale: s,
413
575
  min: c,
414
576
  max: l,
415
- isDateUnavailable: d,
577
+ isDateUnavailable: u,
416
578
  disabled: f,
417
579
  readOnly: p,
418
580
  required: m,
419
581
  component: "datePicker.part",
420
582
  px: 0,
421
583
  py: 0,
422
- tabIndex: F
423
- };
424
- return /* @__PURE__ */ D(g, { children: [
425
- b !== void 0 && /* @__PURE__ */ E(t, {
426
- component: "dateField.label",
427
- display: "block",
428
- mb: 1.5,
429
- fontSize: 14,
430
- id: `${G}-label`,
431
- children: b
432
- }),
433
- /* @__PURE__ */ D(t, {
434
- ref: K,
435
- component: "dateField",
436
- display: "inline-flex",
437
- ai: "center",
438
- gap: 2,
439
- px: 3,
440
- py: 2,
441
- ...L,
442
- variant: [L.variant, {
443
- disabled: f,
444
- invalid: _ ?? Y
445
- }],
446
- props: {
447
- role: "group",
448
- "aria-labelledby": [b === void 0 ? void 0 : `${G}-label`, S].filter(Boolean).join(" ") || void 0,
449
- "aria-invalid": (_ ?? Y) || void 0,
450
- "aria-describedby": C,
451
- ...fe
452
- },
453
- children: [
454
- /* @__PURE__ */ E(x, {
455
- ...Q,
456
- value: H,
457
- onValueChange: (e, t) => X(e, U, t.reason, t.event),
458
- name: v,
459
- props: { "aria-label": w },
460
- invalid: _ ?? Y
461
- }),
462
- /* @__PURE__ */ E(t, {
463
- component: "dateField.literal",
464
- props: { "aria-hidden": !0 },
465
- children: "–"
466
- }),
467
- /* @__PURE__ */ E(x, {
468
- ...Q,
469
- value: U,
470
- onValueChange: (e, t) => X(H, e, t.reason, t.event),
471
- name: y,
472
- props: { "aria-label": ne },
473
- invalid: _ ?? Y
474
- }),
475
- /* @__PURE__ */ D(t, {
584
+ tabIndex: L
585
+ }, Se = pe && B && !f && !p && /* @__PURE__ */ k(t, {
586
+ tag: "button",
587
+ component: "datePicker.clear",
588
+ display: "inline-flex",
589
+ ai: "center",
590
+ jc: "center",
591
+ width: 6,
592
+ height: 6,
593
+ borderRadius: 999,
594
+ position: "relative",
595
+ zIndex: 1,
596
+ props: {
597
+ type: "button",
598
+ "aria-label": me,
599
+ tabIndex: L,
600
+ onClick: (e) => Q(null, null, "clear", e)
601
+ },
602
+ children: /* @__PURE__ */ k(ie, {})
603
+ }), Ce = B !== null && (c != null && d(B.start, c) < 0 || l != null && d(B.end, l) > 0), we = F ? /* @__PURE__ */ k(ce, {
604
+ frame: {
605
+ ...z,
606
+ props: he
607
+ },
608
+ attachField: J,
609
+ attachTrigger: p ? void 0 : W,
610
+ triggerAttributes: p ? void 0 : G,
611
+ triggerElement: ye,
612
+ id: q,
613
+ label: x,
614
+ labelledBy: S,
615
+ describedBy: w,
616
+ text: X,
617
+ placeholder: I,
618
+ icon: /* @__PURE__ */ k(ne, {}),
619
+ clear: Se,
620
+ disabled: f,
621
+ invalid: h ?? Ce,
622
+ required: m,
623
+ tabIndex: L,
624
+ inputs: [{
625
+ name: v,
626
+ value: B?.start ?? ""
627
+ }, {
628
+ name: y,
629
+ value: B?.end ?? ""
630
+ }],
631
+ onReset: (e) => Q(i?.start ?? null, i?.end ?? null, "reset", e)
632
+ }) : /* @__PURE__ */ A(te, { children: [x !== void 0 && /* @__PURE__ */ k(t, {
633
+ component: "dateField.label",
634
+ display: "block",
635
+ mb: 1.5,
636
+ fontSize: 14,
637
+ id: `${q}-label`,
638
+ children: x
639
+ }), /* @__PURE__ */ A(t, {
640
+ ref: J,
641
+ component: "dateField",
642
+ display: "inline-flex",
643
+ ai: "center",
644
+ gap: 2,
645
+ px: 3,
646
+ py: 2,
647
+ ...z,
648
+ variant: [z.variant, {
649
+ disabled: f,
650
+ invalid: h ?? Z
651
+ }],
652
+ props: {
653
+ role: "group",
654
+ "aria-labelledby": [x === void 0 ? void 0 : `${q}-label`, S].filter(Boolean).join(" ") || void 0,
655
+ "aria-invalid": (h ?? Z) || void 0,
656
+ "aria-describedby": w,
657
+ ...he
658
+ },
659
+ children: [
660
+ /* @__PURE__ */ k(C, {
661
+ ...xe,
662
+ value: H,
663
+ onValueChange: (e, t) => Q(e, U, t.reason, t.event),
664
+ name: v,
665
+ props: { "aria-label": T },
666
+ invalid: h ?? Z
667
+ }),
668
+ /* @__PURE__ */ k(t, {
669
+ component: "dateField.literal",
670
+ props: { "aria-hidden": !0 },
671
+ children: "–"
672
+ }),
673
+ /* @__PURE__ */ k(C, {
674
+ ...xe,
675
+ value: U,
676
+ onValueChange: (e, t) => Q(H, e, t.reason, t.event),
677
+ name: y,
678
+ props: { "aria-label": E },
679
+ invalid: h ?? Z
680
+ }),
681
+ /* @__PURE__ */ A(t, {
682
+ display: "inline-flex",
683
+ ai: "center",
684
+ gap: 2,
685
+ ms: "auto",
686
+ children: [Se, /* @__PURE__ */ k(t, {
687
+ tag: "button",
688
+ ref: W,
689
+ component: "datePicker.trigger",
476
690
  display: "inline-flex",
477
691
  ai: "center",
478
- gap: 2,
479
- ms: "auto",
480
- children: [N && R && !f && !p && /* @__PURE__ */ E(t, {
481
- tag: "button",
482
- component: "datePicker.clear",
483
- display: "inline-flex",
484
- ai: "center",
485
- jc: "center",
486
- width: 6,
487
- height: 6,
488
- borderRadius: 999,
489
- props: {
490
- type: "button",
491
- "aria-label": de,
492
- tabIndex: F,
493
- onClick: (e) => X(null, null, "clear", e)
494
- },
495
- children: /* @__PURE__ */ E(ae, {})
496
- }), /* @__PURE__ */ E(t, {
497
- tag: "button",
498
- ref: W,
499
- component: "datePicker.trigger",
500
- display: "inline-flex",
501
- ai: "center",
502
- jc: "center",
503
- width: 7,
504
- height: 7,
505
- me: -1.5,
506
- borderRadius: 1.5,
507
- disabled: f || p,
508
- props: {
509
- type: "button",
510
- "aria-label": J ? `${P}, ${J}` : P,
511
- tabIndex: F,
512
- ...me
513
- },
514
- children: /* @__PURE__ */ E(re, {})
515
- })]
516
- })
517
- ]
518
- }),
519
- q(/* @__PURE__ */ D(t, {
520
- display: "flex",
521
- gap: 3,
522
- ai: "stretch",
523
- children: [I && I.length > 0 && /* @__PURE__ */ E(ce, {
524
- presets: I,
525
- isSelected: (e) => R !== null && e.start === R.start && e.end === R.end,
526
- onSelect: (e, t) => {
527
- X(e.start, e.end, "preset", t), k && Z(t);
528
- }
529
- }), /* @__PURE__ */ E(te, {
530
- mode: "range",
531
- months: M,
532
- value: R,
533
- defaultFocusedDate: H ?? void 0,
534
- onValueChange: (e, t) => {
535
- X(e?.start ?? null, e?.end ?? null, "select", t.event), k && e && t.event && Z(t.event);
536
- },
537
- min: c,
538
- max: l,
539
- isDateUnavailable: d,
540
- locale: s,
541
- firstDayOfWeek: A,
542
- weekNumbers: j
543
- })]
544
- }))
545
- ] });
692
+ jc: "center",
693
+ width: 7,
694
+ height: 7,
695
+ me: -1.5,
696
+ borderRadius: 1.5,
697
+ disabled: f || p,
698
+ props: {
699
+ type: "button",
700
+ "aria-label": X ? `${I}, ${X}` : I,
701
+ tabIndex: L,
702
+ ...G
703
+ },
704
+ children: /* @__PURE__ */ k(ne, {})
705
+ })]
706
+ })
707
+ ]
708
+ })] });
709
+ return /* @__PURE__ */ A(_, { children: [we, Y(/* @__PURE__ */ A(t, {
710
+ display: "flex",
711
+ gap: 3,
712
+ ai: "stretch",
713
+ children: [R && R.length > 0 && /* @__PURE__ */ k(se, {
714
+ presets: R,
715
+ isSelected: (e) => B !== null && e.start === B.start && e.end === B.end,
716
+ onSelect: (e, t) => {
717
+ Q(e.start, e.end, "preset", t), oe && be(t);
718
+ }
719
+ }), /* @__PURE__ */ k(ee, {
720
+ mode: "range",
721
+ months: P,
722
+ value: B,
723
+ defaultFocusedDate: H ?? void 0,
724
+ onValueChange: (e, t) => {
725
+ Q(e?.start ?? null, e?.end ?? null, "select", t.event), oe && e && t.event && be(t.event);
726
+ },
727
+ min: c,
728
+ max: l,
729
+ isDateUnavailable: u,
730
+ locale: s,
731
+ firstDayOfWeek: M,
732
+ weekNumbers: N
733
+ })]
734
+ }))] });
546
735
  }
547
- var j = e(k, "DatePicker"), M = e(A, "DateRangePicker");
736
+ var P = e(M, "DatePicker"), le = e(N, "DateRangePicker");
548
737
  //#endregion
549
- export { M as DateRangePicker, j as default };
738
+ export { le as DateRangePicker, P as default };