@box-kite/react 2.2.7 → 2.2.9

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 (96) hide show
  1. package/BOX_AI_CONTEXT.md +76 -0
  2. package/BOX_KITE_AI_CONTEXT.md +76 -0
  3. package/analytics.cjs +1 -0
  4. package/analytics.d.ts +10 -0
  5. package/analytics.mjs +121 -0
  6. package/behavior.cjs +1 -1
  7. package/behavior.mjs +42 -38
  8. package/box.cjs +1 -1
  9. package/box.d.ts +9 -0
  10. package/box.mjs +17 -16
  11. package/catalog.cjs +1 -1
  12. package/catalog.mjs +8 -0
  13. package/client.cjs +1 -1
  14. package/client.mjs +120 -120
  15. package/components/accordion.cjs +1 -1
  16. package/components/accordion.mjs +19 -10
  17. package/components/agent.cjs +1 -1
  18. package/components/agent.mjs +21 -8
  19. package/components/calendar.cjs +1 -1
  20. package/components/calendar.d.ts +3 -1
  21. package/components/calendar.mjs +154 -142
  22. package/components/combobox.cjs +1 -1
  23. package/components/combobox.mjs +184 -174
  24. package/components/dashboard.cjs +1 -1
  25. package/components/dashboard.mjs +183 -170
  26. package/components/dataGrid/models/columnModel.d.ts +1 -0
  27. package/components/dataGrid/models/gridModel.d.ts +18 -0
  28. package/components/dataGrid/models/rangeModel.d.ts +3 -0
  29. package/components/dataGrid.cjs +3 -3
  30. package/components/dataGrid.mjs +987 -896
  31. package/components/dateField.cjs +1 -1
  32. package/components/dateField.mjs +160 -149
  33. package/components/datePicker.cjs +1 -1
  34. package/components/datePicker.mjs +226 -206
  35. package/components/dialog.cjs +1 -1
  36. package/components/dialog.mjs +38 -33
  37. package/components/dropdown.cjs +1 -1
  38. package/components/dropdown.mjs +107 -93
  39. package/components/form.cjs +1 -1
  40. package/components/form.mjs +22 -18
  41. package/components/menu.cjs +1 -1
  42. package/components/menu.d.ts +2 -0
  43. package/components/menu.mjs +196 -175
  44. package/components/overlay.cjs +1 -1
  45. package/components/overlay.mjs +7 -7
  46. package/components/popover.cjs +1 -1
  47. package/components/popover.mjs +4 -0
  48. package/components/radioGroup.cjs +1 -1
  49. package/components/radioGroup.mjs +10 -5
  50. package/components/slider.cjs +1 -1
  51. package/components/slider.mjs +84 -83
  52. package/components/sortableList.cjs +1 -1
  53. package/components/sortableList.mjs +158 -150
  54. package/components/swipeItem.cjs +1 -1
  55. package/components/swipeItem.mjs +92 -84
  56. package/components/tabs.cjs +1 -1
  57. package/components/tabs.mjs +10 -5
  58. package/components/timeZoneSelect.cjs +1 -1
  59. package/components/timeZoneSelect.mjs +40 -35
  60. package/components/toaster.cjs +1 -1
  61. package/components/toaster.mjs +151 -113
  62. package/dataGridDateParts.cjs +1 -1
  63. package/dataGridDateParts.mjs +56 -55
  64. package/dataGridList.cjs +1 -1
  65. package/dataGridList.mjs +430 -429
  66. package/effects.cjs +1 -1
  67. package/effects.mjs +1 -1
  68. package/interactionListening.cjs +1 -0
  69. package/interactionListening.mjs +117 -0
  70. package/interactions.cjs +1 -0
  71. package/interactions.mjs +25 -0
  72. package/layer.cjs +1 -1
  73. package/layer.mjs +68 -66
  74. package/package.json +132 -68
  75. package/placement.cjs +1 -1
  76. package/placement.mjs +10 -10
  77. package/platform.cjs +1 -1
  78. package/platform.mjs +44 -25
  79. package/react/interactions/interactions.d.ts +30 -0
  80. package/react/popover/usePopoverLayer.d.ts +3 -0
  81. package/react/useStyles.d.ts +8 -1
  82. package/react-shared.cjs +1 -1
  83. package/react-shared.mjs +49 -48
  84. package/reporting.cjs +1 -0
  85. package/reporting.mjs +51 -0
  86. package/scrolling.cjs +1 -1
  87. package/scrolling.mjs +1 -1
  88. package/supabase/functions/collect/index.d.ts +30 -0
  89. package/supabase/functions/collect/index.test.d.ts +1 -0
  90. package/utils/analytics/analytics.d.ts +72 -0
  91. package/utils/analytics/analyticsIdentity.d.ts +13 -0
  92. package/utils/interactions/componentAttribute.d.ts +6 -0
  93. package/utils/interactions/interactionChannel.d.ts +35 -0
  94. package/utils/interactions/interactionJson.d.ts +6 -0
  95. package/utils/interactions/interactionListening.d.ts +6 -0
  96. package/utils/interactions/interactionTypes.d.ts +224 -0
@@ -1,27 +1,29 @@
1
1
  "use client";
2
- import { t as e } from "../client.mjs";
3
- import { o as t, t as n } from "../platform.mjs";
2
+ import { c as e, t } from "../platform.mjs";
3
+ import { t as n } from "../client.mjs";
4
4
  import { n as r } from "../effects.mjs";
5
- import i from "../box.mjs";
6
- import { n as a } from "../layer.mjs";
7
- import { t as o } from "../motion.mjs";
8
- import { useCallback as s, useRef as c } from "react";
9
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
- import { createPortal as d } from "react-dom";
11
- import { useSyncExternalStore as f } from "use-sync-external-store/shim";
5
+ import { t as i } from "../interactions.mjs";
6
+ import a from "../box.mjs";
7
+ import { i as o } from "../reporting.mjs";
8
+ import { n as s } from "../layer.mjs";
9
+ import { t as c } from "../motion.mjs";
10
+ import { useCallback as l, useRef as u } from "react";
11
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
12
+ import { createPortal as p } from "react-dom";
13
+ import { useSyncExternalStore as m } from "use-sync-external-store/shim";
12
14
  //#region src/utils/toast/toastStore.ts
13
- var p = {
15
+ var h = ["value"], g = {
14
16
  toasts: [],
15
17
  overflow: 0
16
- }, m = 0;
17
- function h() {
18
- return m += 1, `toast-${m}`;
18
+ }, _ = 0;
19
+ function v() {
20
+ return _ += 1, `toast-${_}`;
19
21
  }
20
- function g(e) {
21
- let t = [], n = p, r = e?.limit ?? 3, i = e?.duration ?? 5e3, a = !1, o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map(), c = (e) => {
22
- let t = s.get(e);
23
- t?.handle && clearTimeout(t.handle), s.delete(e);
24
- }, l = () => {
22
+ function y(e) {
23
+ let t = [], n = g, r = e?.limit ?? 3, a = e?.duration ?? 5e3, o = !1, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = (e) => {
24
+ let t = c.get(e);
25
+ t?.handle && clearTimeout(t.handle), c.delete(e);
26
+ }, u = () => {
25
27
  let e = 0;
26
28
  t = t.map((t) => {
27
29
  let n = !t.open || e++ < r;
@@ -32,122 +34,153 @@ function g(e) {
32
34
  }), n = {
33
35
  toasts: t,
34
36
  overflow: Math.max(0, e - r)
35
- }, u(), o.forEach((e) => e());
37
+ }, d(), s.forEach((e) => e());
36
38
  };
37
- function u() {
39
+ function d() {
38
40
  let e = /* @__PURE__ */ new Set();
39
41
  for (let n of t) {
40
42
  if (!n.open || !n.visible || !Number.isFinite(n.duration)) continue;
41
43
  e.add(n.id);
42
- let t = s.get(n.id) ?? {
44
+ let t = c.get(n.id) ?? {
43
45
  handle: null,
44
46
  remaining: n.duration,
45
47
  startedAt: 0
46
48
  };
47
- s.set(n.id, t), !(a || t.handle) && (t.startedAt = Date.now(), t.handle = setTimeout(() => {
48
- s.delete(n.id), f(n.id, "timeout");
49
+ c.set(n.id, t), !(o || t.handle) && (t.startedAt = Date.now(), t.handle = setTimeout(() => {
50
+ c.delete(n.id), p(n.id, "timeout");
49
51
  }, t.remaining));
50
52
  }
51
- for (let t of [...s.keys()]) e.has(t) || c(t);
53
+ for (let t of [...c.keys()]) e.has(t) || l(t);
52
54
  }
53
- let d = (e, t) => t ?? (e === "loading" ? Infinity : i);
54
- function f(e, n = "imperative") {
55
+ let f = (e, t) => t ?? (e === "loading" ? Infinity : a);
56
+ function p(e, n = "imperative") {
55
57
  let r = [];
56
- t = t.map((t) => !t.open || e !== void 0 && t.id !== e ? t : (r.push(t), c(t.id), {
58
+ t = t.map((t) => !t.open || e !== void 0 && t.id !== e ? t : (r.push(t), l(t.id), {
57
59
  ...t,
58
60
  open: !1
59
- })), r.length && (l(), r.forEach((e) => e.onDismiss?.(n)));
61
+ })), r.length && (u(), r.forEach((e) => {
62
+ e.onDismiss?.(n), i({
63
+ component: "toaster",
64
+ type: "dismiss",
65
+ reason: n,
66
+ value: e.message,
67
+ details: {
68
+ id: e.id,
69
+ kind: e.kind
70
+ },
71
+ content: h
72
+ });
73
+ }));
60
74
  }
61
75
  function m(e, n, r) {
62
- let i = !1;
76
+ let a = !1;
63
77
  t = t.map((t) => {
64
78
  if (t.id !== e) return t;
65
- i = !0, c(e);
66
- let a = r?.kind ?? t.kind;
79
+ a = !0, l(e);
80
+ let i = r?.kind ?? t.kind;
67
81
  return {
68
82
  ...t,
69
83
  ...r,
70
84
  id: e,
71
85
  message: n,
72
- kind: a,
73
- duration: r?.duration ?? (r?.kind ? d(a) : t.duration),
86
+ kind: i,
87
+ duration: r?.duration ?? (r?.kind ? f(i) : t.duration),
74
88
  open: !0
75
89
  };
76
- }), i && l();
90
+ }), a && (u(), i({
91
+ component: "toaster",
92
+ type: "update",
93
+ reason: r?.kind,
94
+ value: n,
95
+ details: { id: e },
96
+ source: "app",
97
+ content: h
98
+ }));
77
99
  }
78
- function g(e, n) {
79
- let r = n?.id ?? h();
100
+ function _(e, n) {
101
+ let r = n?.id ?? v();
80
102
  if (n?.id && t.some((e) => e.id === r)) return m(r, e, n), r;
81
- let i = n?.kind ?? "default";
103
+ let a = n?.kind ?? "default";
82
104
  return t = [...t, {
83
105
  id: r,
84
- kind: i,
106
+ kind: a,
85
107
  message: e,
86
108
  description: n?.description,
87
- duration: d(i, n?.duration),
109
+ duration: f(a, n?.duration),
88
110
  action: n?.action,
89
111
  dismissible: n?.dismissible ?? !0,
90
112
  onDismiss: n?.onDismiss,
91
113
  open: !0,
92
114
  visible: !1
93
- }], l(), r;
115
+ }], u(), i({
116
+ component: "toaster",
117
+ type: "show",
118
+ reason: a,
119
+ value: e,
120
+ details: {
121
+ id: r,
122
+ kind: a
123
+ },
124
+ source: "app",
125
+ content: h
126
+ }), r;
94
127
  }
95
128
  return {
96
129
  subscribe(e) {
97
- return o.add(e), () => o.delete(e);
130
+ return s.add(e), () => s.delete(e);
98
131
  },
99
132
  getSnapshot: () => n,
100
- getServerSnapshot: () => p,
101
- add: g,
133
+ getServerSnapshot: () => g,
134
+ add: _,
102
135
  update: m,
103
- dismiss: f,
136
+ dismiss: p,
104
137
  remove(e) {
105
138
  let n = t.filter((t) => t.id !== e);
106
- n.length !== t.length && (c(e), t = n, l());
139
+ n.length !== t.length && (l(e), t = n, u());
107
140
  },
108
141
  setLimit(e) {
109
- e !== r && (r = e, l());
142
+ e !== r && (r = e, u());
110
143
  },
111
144
  setDefaultDuration(e) {
112
- i = e;
145
+ a = e;
113
146
  },
114
147
  pause() {
115
- if (!a) {
116
- a = !0;
117
- for (let e of s.values()) e.handle && (clearTimeout(e.handle), e.handle = null, e.remaining = Math.max(0, e.remaining - (Date.now() - e.startedAt)));
148
+ if (!o) {
149
+ o = !0;
150
+ for (let e of c.values()) e.handle && (clearTimeout(e.handle), e.handle = null, e.remaining = Math.max(0, e.remaining - (Date.now() - e.startedAt)));
118
151
  }
119
152
  },
120
153
  resume() {
121
- a && (a = !1, u());
154
+ o && (o = !1, d());
122
155
  },
123
156
  reset() {
124
- for (let e of [...s.keys()]) c(e);
125
- t = [], n = p, o.forEach((e) => e());
157
+ for (let e of [...c.keys()]) l(e);
158
+ t = [], n = g, s.forEach((e) => e());
126
159
  }
127
160
  };
128
161
  }
129
162
  //#endregion
130
163
  //#region src/components/toaster.tsx
131
- var _ = g(), v = (e) => (t, n) => _.add(t, {
164
+ var b = y(), x = (e) => (t, n) => b.add(t, {
132
165
  ...n,
133
166
  kind: e
134
- }), y = Object.assign((e, t) => _.add(e, t), {
135
- success: v("success"),
136
- error: v("error"),
137
- warning: v("warning"),
138
- info: v("info"),
139
- loading: v("loading"),
140
- update: (e, t, n) => _.update(e, t, n),
141
- dismiss: (e) => _.dismiss(e, "imperative"),
167
+ }), S = Object.assign((e, t) => b.add(e, t), {
168
+ success: x("success"),
169
+ error: x("error"),
170
+ warning: x("warning"),
171
+ info: x("info"),
172
+ loading: x("loading"),
173
+ update: (e, t, n) => b.update(e, t, n),
174
+ dismiss: (e) => b.dismiss(e, "imperative"),
142
175
  promise(e, t, n) {
143
- let r = _.add(t.loading, {
176
+ let r = b.add(t.loading, {
144
177
  ...n,
145
178
  id: n?.id,
146
179
  kind: "loading"
147
180
  }), i = (e, t) => typeof e == "function" ? e(t) : e;
148
- return e.then((e) => _.update(r, i(t.success, e), { kind: "success" }), (e) => _.update(r, i(t.error, e), { kind: "error" })), e;
181
+ return e.then((e) => b.update(r, i(t.success, e), { kind: "success" }), (e) => b.update(r, i(t.error, e), { kind: "error" })), e;
149
182
  }
150
- }), b = {
183
+ }), C = {
151
184
  "top-start": "topStart",
152
185
  "top-center": "topCenter",
153
186
  "top-end": "topEnd",
@@ -155,53 +188,58 @@ var _ = g(), v = (e) => (t, n) => _.add(t, {
155
188
  "bottom-center": "bottomCenter",
156
189
  "bottom-end": "bottomEnd"
157
190
  };
158
- function x(e, t) {
191
+ function w(e, t) {
159
192
  let n = t.toLowerCase().split("+"), r = n[n.length - 1], i = new Set(n.slice(0, -1));
160
193
  return e.key.toLowerCase() === r && e.altKey === i.has("alt") && e.ctrlKey === i.has("ctrl") && e.shiftKey === i.has("shift") && e.metaKey === i.has("meta");
161
194
  }
162
- function S(e) {
163
- let { toast: t, store: n, fromTop: a, closeLabel: s } = e, { mounted: c, ref: d, props: f } = o({ present: t.open });
195
+ function T(e) {
196
+ let { toast: t, store: n, fromTop: i, closeLabel: s } = e, { mounted: l, ref: u, props: p } = c({ present: t.open }), m = o("toaster");
164
197
  if (r(() => {
165
- c || n.remove(t.id);
198
+ l || n.remove(t.id);
166
199
  }, [
167
- c,
200
+ l,
168
201
  n,
169
202
  t.id
170
- ]), !c) return null;
171
- let p = t.action, m = () => {
172
- p?.onClick(), p?.closeOnClick !== !1 && n.dismiss(t.id, "action");
203
+ ]), !l) return null;
204
+ let h = t.action, g = () => {
205
+ h?.onClick(), h?.closeOnClick === !1 ? m("action", t.message, {
206
+ reason: "action",
207
+ id: t.id,
208
+ kind: t.kind,
209
+ content: ["value"]
210
+ }) : n.dismiss(t.id, "action");
173
211
  };
174
- return /* @__PURE__ */ u(i, {
175
- ref: d,
212
+ return /* @__PURE__ */ f(a, {
213
+ ref: u,
176
214
  component: "toaster.toast",
177
215
  variant: {
178
216
  [t.kind]: t.kind !== "default",
179
- fromTop: a
217
+ fromTop: i
180
218
  },
181
219
  props: {
182
220
  ...t.kind === "error" ? { role: "alert" } : {},
183
221
  "data-toast-id": t.id,
184
- ...f
222
+ ...p
185
223
  },
186
224
  children: [
187
- /* @__PURE__ */ l(i, {
225
+ /* @__PURE__ */ d(a, {
188
226
  component: "toaster.message",
189
227
  children: t.message
190
228
  }),
191
- t.description !== void 0 && /* @__PURE__ */ l(i, {
229
+ t.description !== void 0 && /* @__PURE__ */ d(a, {
192
230
  component: "toaster.description",
193
231
  children: t.description
194
232
  }),
195
- p && /* @__PURE__ */ l(i, {
233
+ h && /* @__PURE__ */ d(a, {
196
234
  tag: "button",
197
235
  component: "toaster.action",
198
236
  props: {
199
237
  type: "button",
200
- onClick: m
238
+ onClick: g
201
239
  },
202
- children: p.label
240
+ children: h.label
203
241
  }),
204
- t.dismissible && /* @__PURE__ */ l(i, {
242
+ t.dismissible && /* @__PURE__ */ d(a, {
205
243
  tag: "button",
206
244
  component: "toaster.close",
207
245
  props: {
@@ -213,33 +251,33 @@ function S(e) {
213
251
  ]
214
252
  });
215
253
  }
216
- function C(o) {
217
- let { position: p = "bottom-end", limit: m = 3, duration: h = 5e3, label: g = "Notifications", closeLabel: v = "Close", overflowLabel: y = (e) => `+${e} more`, hotkey: C = "F6", store: w = _, props: T, ...E } = o, D = f(w.subscribe, w.getSnapshot, w.getServerSnapshot), O = a(), k = e(!O), A = c(null), j = c(null), M = c({
254
+ function E(i) {
255
+ let { position: o = "bottom-end", limit: c = 3, duration: h = 5e3, label: g = "Notifications", closeLabel: _ = "Close", overflowLabel: v = (e) => `+${e} more`, hotkey: y = "F6", store: x = b, props: S, ...E } = i, D = m(x.subscribe, x.getSnapshot, x.getServerSnapshot), O = s(), k = n(!O), A = u(null), j = u(null), M = u({
218
256
  hovered: !1,
219
257
  focused: !1,
220
258
  hidden: !1
221
- }), N = s(() => {
259
+ }), N = l(() => {
222
260
  let { hovered: e, focused: t, hidden: n } = M.current;
223
- e || t || n ? w.pause() : w.resume();
224
- }, [w]);
225
- r(() => w.setLimit(m), [w, m]), r(() => w.setDefaultDuration(h), [w, h]), r(() => {
226
- let e = A.current;
227
- !O || !t() || !e || !e.isConnected || e.matches(":popover-open") || e.showPopover();
261
+ e || t || n ? x.pause() : x.resume();
262
+ }, [x]);
263
+ r(() => x.setLimit(c), [x, c]), r(() => x.setDefaultDuration(h), [x, h]), r(() => {
264
+ let t = A.current;
265
+ !O || !e() || !t || !t.isConnected || t.matches(":popover-open") || t.showPopover();
228
266
  }), r(() => {
229
- let e = n();
267
+ let e = t();
230
268
  if (!e) return;
231
- let t = new AbortController();
269
+ let n = new AbortController();
232
270
  return e.addEventListener("visibilitychange", () => {
233
271
  M.current.hidden = e.hidden, N();
234
- }, { signal: t.signal }), () => t.abort();
272
+ }, { signal: n.signal }), () => n.abort();
235
273
  }, [N]), r(() => {
236
- let e = n();
237
- if (!C || !e) return;
238
- let t = new AbortController();
274
+ let e = t();
275
+ if (!y || !e) return;
276
+ let n = new AbortController();
239
277
  return e.addEventListener("keydown", (t) => {
240
- !x(t, C) || !A.current || (t.preventDefault(), j.current = e.activeElement, A.current.focus());
241
- }, { signal: t.signal }), () => t.abort();
242
- }, [C]);
278
+ !w(t, y) || !A.current || (t.preventDefault(), j.current = e.activeElement, A.current.focus());
279
+ }, { signal: n.signal }), () => n.abort();
280
+ }, [y]);
243
281
  let P = (e) => !!e && !!A.current?.contains(e), F = () => {
244
282
  M.current.hovered = !0, N();
245
283
  }, I = (e) => {
@@ -251,16 +289,16 @@ function C(o) {
251
289
  }, z = (e) => {
252
290
  if (e.key !== "Escape") return;
253
291
  let t = (e.target.closest?.("[data-toast-id]"))?.getAttribute("data-toast-id");
254
- t && w.dismiss(t, "close"), w.getSnapshot().toasts.some((e) => e.open) ? A.current?.focus() : j.current?.focus();
255
- }, B = p.startsWith("top"), V = D.toasts.filter((e) => e.visible), H = B ? [...V].reverse() : V, U = D.overflow > 0 && /* @__PURE__ */ l(i, {
292
+ t && x.dismiss(t, "close"), x.getSnapshot().toasts.some((e) => e.open) ? A.current?.focus() : j.current?.focus();
293
+ }, B = o.startsWith("top"), V = D.toasts.filter((e) => e.visible), H = B ? [...V].reverse() : V, U = D.overflow > 0 && /* @__PURE__ */ d(a, {
256
294
  component: "toaster.overflow",
257
- children: y(D.overflow)
258
- }), W = /* @__PURE__ */ u(i, {
295
+ children: v(D.overflow)
296
+ }), W = /* @__PURE__ */ f(a, {
259
297
  tag: "section",
260
298
  ref: A,
261
299
  component: "toaster",
262
300
  ...E,
263
- variant: [E.variant, { [b[p]]: !0 }],
301
+ variant: [E.variant, { [C[o]]: !0 }],
264
302
  props: {
265
303
  ...O ? { popover: "manual" } : {},
266
304
  "aria-live": "polite",
@@ -268,7 +306,7 @@ function C(o) {
268
306
  "aria-relevant": "additions text",
269
307
  "aria-label": g,
270
308
  tabIndex: -1,
271
- ...T,
309
+ ...S,
272
310
  onPointerOver: F,
273
311
  onPointerOut: I,
274
312
  onFocus: L,
@@ -277,18 +315,18 @@ function C(o) {
277
315
  },
278
316
  children: [
279
317
  !B && U,
280
- H.map((e) => /* @__PURE__ */ l(S, {
318
+ H.map((e) => /* @__PURE__ */ d(T, {
281
319
  toast: e,
282
- store: w,
320
+ store: x,
283
321
  fromTop: B,
284
- closeLabel: v
322
+ closeLabel: _
285
323
  }, e.id)),
286
324
  B && U
287
325
  ]
288
326
  });
289
- return O ? W : k ? d(W, k) : null;
327
+ return O ? W : k ? p(W, k) : null;
290
328
  }
291
- var w = C;
292
- w.displayName = "Toaster";
329
+ var D = E;
330
+ D.displayName = "Toaster";
293
331
  //#endregion
294
- export { g as createToastStore, w as default, _ as defaultToastStore, y as toast };
332
+ export { y as createToastStore, D as default, b as defaultToastStore, S as toast };
@@ -1 +1 @@
1
- const e=require("./box.cjs"),t=require("./dates.cjs"),n=require("./date-math.cjs"),r=require("./date-input.cjs"),i=require("./date-environment.cjs"),a=require("./components/flex.cjs"),o=require("./components/dropdown.cjs"),s=require("./components/dateField.cjs"),c=require("./components/datePicker.cjs"),l=require("./dataGridListLayout.cjs");let u=require("react"),d=require("react/jsx-runtime");var f={date:{dateStyle:`medium`},time:{timeStyle:`short`},datetime:{dateStyle:`medium`,timeStyle:`short`}};function p(e){return e instanceof Date||typeof e==`string`||typeof e==`number`?e:null}function m(e){let{value:n,format:r}=e,{locale:a,zone:o}=i.n();if(r===`relative`)return(0,d.jsx)(d.Fragment,{children:t.r(p(n),{locale:a,zone:o})});let s=typeof r==`string`?f[r]:r;return(0,d.jsx)(d.Fragment,{children:t.t(p(n),{...s,locale:a,zone:s.zone??o})})}function h(e,t){return t===null?null:e instanceof Date?n.w(t):typeof e==`string`&&/z$/i.test(e)?n.j(t):t}function g(e){let{cell:t,label:r,errorId:i,onBlur:a}=e,{type:o,zone:c,min:l,max:u}=t.editor,f=t.draft instanceof Date||typeof t.draft==`string`?n.v(t.draft):null;return(0,d.jsx)(s.default,{type:o,value:f,zone:c,min:typeof l==`string`?l:void 0,max:typeof u==`string`?u:void 0,onValueChange:e=>t.setDraft(o===`datetime`?h(t.value,e):e),width:`fit`,variant:`compact`,b:0,bgColor:`transparent`,focus:{outline:0},invalid:i?!0:void 0,describedBy:i,autoFocus:!0,props:{"aria-label":r,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||a()}}})}function _(e){let t=e.currentFilter?.type===`date`?e.currentFilter:void 0,[n,r]=(0,u.useState)(t?.operator??`on`),[i,a]=(0,u.useState)(t?.valueTo??null),o=t?.value??null;return{operator:n,value:o,valueTo:i,setOperator:t=>{r(t),e.setDateFilter(t,o,i)},setValue:t=>e.setDateFilter(n,t,i),setValueTo:t=>{a(t),e.setDateFilter(n,o,t)},clear:()=>{a(null),e.clearFilter()}}}var v=[{value:`on`,label:`=`},{value:`before`,label:`<`},{value:`after`,label:`>`},{value:`between`,label:`↔`}];function y(e,t){let n=e.filterConfig,r=typeof n?.min==`string`?n.min:void 0,i=typeof n?.max==`string`?n.max:void 0;return{from:{min:r,max:t.operator===`between`&&t.valueTo||i},to:{min:t.value??r,max:i}}}function b(e){let{column:t}=e,n=String(t.header??t.key),r=t.grid.localeText,i=_(t),s=y(t,i),l=(e,t,i,a,o=!1)=>(0,d.jsx)(c.default,{value:e,onValueChange:i,min:a.min,max:a.max,clearable:o,clearLabel:r.clearFilter(n),variant:`compact`,width:`fit`,minWidth:0,b:0,bgColor:`transparent`,focus:{outline:0},tabIndex:-1,props:{"aria-label":t}});return(0,d.jsxs)(a.default,{component:`${t.grid.componentName}.filter.cell.input`,ai:i.operator===`between`?`start`:`center`,gap:1,children:[(0,d.jsx)(o.default,{value:i.operator,variant:`compact`,onChange:e=>e&&i.setOperator(e),minWidth:6,hideIcon:!0,b:0,bgColor:`transparent`,focus:{outline:0},props:{tabIndex:-1,"aria-label":r.filterComparison(n)},children:v.map(e=>(0,d.jsx)(o.default.Item,{value:e.value,children:e.label},e.value))}),(0,d.jsxs)(a.default,{d:`column`,gap:1,flex1:!0,minWidth:0,children:[l(i.value,i.operator===`between`?r.filterFrom(n):r.filterColumn(n),(e,t)=>t.reason===`clear`?i.clear():i.setValue(e),s.from,!0),i.operator===`between`&&l(i.valueTo,r.filterTo(n),i.setValueTo,s.to)]})]})}function x(t){let{column:n}=t,r=n.grid.componentName,i=n.grid.localeText,o=String(n.header??n.key),s=_(n),u=y(n,s);return(0,d.jsxs)(a.default,{gap:2,ai:`center`,flexWrap:`wrap`,children:[(0,d.jsx)(e.default,{tag:`select`,component:`${r}.list.sheet.input`,...l.t.INPUT,width:18,flexShrink:0,props:{value:s.operator,"aria-label":i.filterComparison(o),onChange:e=>s.setOperator(e.target.value)},children:v.map(e=>(0,d.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,d.jsx)(c.default,{value:s.value,onValueChange:s.setValue,min:u.from.min,max:u.from.max,flex1:!0,props:{"aria-label":s.operator===`between`?i.filterFrom(o):i.filterColumn(o)}}),s.operator===`between`&&(0,d.jsx)(c.default,{value:s.valueTo,onValueChange:s.setValueTo,min:u.to.min,max:u.to.max,flex1:!0,props:{"aria-label":i.filterTo(o)}})]})}function S(e,t){let n=e.type===`datetime`?e.zone===`none`?`datetime`:`instant`:e.type;return r.m(t,{kind:n,zone:e.zone===`none`?void 0:e.zone})}function C(e,n){return n===void 0?t.t(e):t.n(e,n)}var w={DateValue:m,DateEditor:g,DateFilter:b,ListDateFilter:x,parsePasted:S,describeDay:C};exports.default=w;
1
+ const e=require("./box.cjs"),t=require("./dates.cjs"),n=require("./date-math.cjs"),r=require("./date-input.cjs"),i=require("./reporting.cjs"),a=require("./date-environment.cjs"),o=require("./components/flex.cjs"),s=require("./components/dropdown.cjs"),c=require("./components/dateField.cjs"),l=require("./components/datePicker.cjs"),u=require("./dataGridListLayout.cjs");let d=require("react"),f=require("react/jsx-runtime");var p={date:{dateStyle:`medium`},time:{timeStyle:`short`},datetime:{dateStyle:`medium`,timeStyle:`short`}};function m(e){return e instanceof Date||typeof e==`string`||typeof e==`number`?e:null}function h(e){let{value:n,format:r}=e,{locale:i,zone:o}=a.n();if(r===`relative`)return(0,f.jsx)(f.Fragment,{children:t.r(m(n),{locale:i,zone:o})});let s=typeof r==`string`?p[r]:r;return(0,f.jsx)(f.Fragment,{children:t.t(m(n),{...s,locale:i,zone:s.zone??o})})}function g(e,t){return t===null?null:e instanceof Date?n.w(t):typeof e==`string`&&/z$/i.test(e)?n.j(t):t}function _(e){let{cell:t,label:r,errorId:a,onBlur:o}=e,{type:s,zone:l,min:u,max:d}=t.editor,p=t.draft instanceof Date||typeof t.draft==`string`?n.v(t.draft):null;return(0,f.jsx)(i.t,{children:(0,f.jsx)(c.default,{type:s,value:p,zone:l,min:typeof u==`string`?u:void 0,max:typeof d==`string`?d:void 0,onValueChange:e=>t.setDraft(s===`datetime`?g(t.value,e):e),width:`fit`,variant:`compact`,b:0,bgColor:`transparent`,focus:{outline:0},invalid:a?!0:void 0,describedBy:a,autoFocus:!0,props:{"aria-label":r,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||o()}}})})}function v(e){let t=e.currentFilter?.type===`date`?e.currentFilter:void 0,[n,r]=(0,d.useState)(t?.operator??`on`),[i,a]=(0,d.useState)(t?.valueTo??null),o=t?.value??null;return{operator:n,value:o,valueTo:i,setOperator:t=>{r(t),e.setDateFilter(t,o,i)},setValue:t=>e.setDateFilter(n,t,i),setValueTo:t=>{a(t),e.setDateFilter(n,o,t)},clear:()=>{a(null),e.clearFilter()}}}var y=[{value:`on`,label:`=`},{value:`before`,label:`<`},{value:`after`,label:`>`},{value:`between`,label:`↔`}];function b(e,t){let n=e.filterConfig,r=typeof n?.min==`string`?n.min:void 0,i=typeof n?.max==`string`?n.max:void 0;return{from:{min:r,max:t.operator===`between`&&t.valueTo||i},to:{min:t.value??r,max:i}}}function x(e){let{column:t}=e,n=String(t.header??t.key),r=t.grid.localeText,a=v(t),c=b(t,a),u=(e,t,a,o,s=!1)=>(0,f.jsx)(i.t,{children:(0,f.jsx)(l.default,{value:e,onValueChange:a,min:o.min,max:o.max,clearable:s,clearLabel:r.clearFilter(n),variant:`compact`,width:`fit`,minWidth:0,b:0,bgColor:`transparent`,focus:{outline:0},tabIndex:-1,props:{"aria-label":t}})});return(0,f.jsxs)(o.default,{component:`${t.grid.componentName}.filter.cell.input`,ai:a.operator===`between`?`start`:`center`,gap:1,children:[(0,f.jsx)(i.t,{children:(0,f.jsx)(s.default,{value:a.operator,variant:`compact`,onChange:e=>e&&a.setOperator(e),minWidth:6,hideIcon:!0,b:0,bgColor:`transparent`,focus:{outline:0},props:{tabIndex:-1,"aria-label":r.filterComparison(n)},children:y.map(e=>(0,f.jsx)(s.default.Item,{value:e.value,children:e.label},e.value))})}),(0,f.jsxs)(o.default,{d:`column`,gap:1,flex1:!0,minWidth:0,children:[u(a.value,a.operator===`between`?r.filterFrom(n):r.filterColumn(n),(e,t)=>t.reason===`clear`?a.clear():a.setValue(e),c.from,!0),a.operator===`between`&&u(a.valueTo,r.filterTo(n),a.setValueTo,c.to)]})]})}function S(t){let{column:n}=t,r=n.grid.componentName,a=n.grid.localeText,s=String(n.header??n.key),c=v(n),d=b(n,c);return(0,f.jsxs)(o.default,{gap:2,ai:`center`,flexWrap:`wrap`,children:[(0,f.jsx)(e.default,{tag:`select`,component:`${r}.list.sheet.input`,...u.t.INPUT,width:18,flexShrink:0,props:{value:c.operator,"aria-label":a.filterComparison(s),onChange:e=>c.setOperator(e.target.value)},children:y.map(e=>(0,f.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,f.jsx)(i.t,{children:(0,f.jsx)(l.default,{value:c.value,onValueChange:c.setValue,min:d.from.min,max:d.from.max,flex1:!0,props:{"aria-label":c.operator===`between`?a.filterFrom(s):a.filterColumn(s)}})}),c.operator===`between`&&(0,f.jsx)(i.t,{children:(0,f.jsx)(l.default,{value:c.valueTo,onValueChange:c.setValueTo,min:d.to.min,max:d.to.max,flex1:!0,props:{"aria-label":a.filterTo(s)}})})]})}function C(e,t){let n=e.type===`datetime`?e.zone===`none`?`datetime`:`instant`:e.type;return r.m(t,{kind:n,zone:e.zone===`none`?void 0:e.zone})}function w(e,n){return n===void 0?t.t(e):t.n(e,n)}var T={DateValue:h,DateEditor:_,DateFilter:x,ListDateFilter:S,parsePasted:C,describeDay:w};exports.default=T;