@box-kite/react 2.2.5 → 2.2.7
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.
- package/.claude/rules/box-kite-rules.md +5 -1
- package/.claude/skills/box-kite/SKILL.md +5 -1
- package/.claude/skills/box-kite/references/components.md +34 -0
- package/.claude/skills/box-kite/references/extending.md +10 -0
- package/.claude/skills/box-kite/references/styling.md +3 -2
- package/.cursor/rules/box-kite.mdc +5 -1
- package/AGENTS.md +5 -1
- package/BOX_AI_CONTEXT.md +147 -7
- package/BOX_KITE_AI_CONTEXT.md +147 -7
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +7 -7
- package/catalog.cjs +1 -1
- package/catalog.mjs +521 -0
- package/client.cjs +1 -1
- package/client.mjs +136 -117
- package/components/calendar.cjs +1 -0
- package/components/calendar.d.ts +77 -0
- package/components/calendar.mjs +483 -0
- package/components/dataGrid/components/dataGridBooleanValue.d.ts +11 -0
- package/components/dataGrid/components/dataGridDateParts.d.ts +40 -0
- package/components/dataGrid/components/dataGridDateValue.d.ts +14 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +38 -11
- package/components/dataGrid/models/columnModel.d.ts +3 -1
- package/components/dataGrid/models/editModel.d.ts +3 -1
- package/components/dataGrid/models/headerCellModel.d.ts +1 -0
- package/components/dataGrid/models/localeText.d.ts +4 -0
- package/components/dataGrid/useDateParts.d.ts +17 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +824 -690
- package/components/dateField.cjs +1 -0
- package/components/dateField.d.ts +78 -0
- package/components/dateField.mjs +313 -0
- package/components/datePicker.cjs +1 -0
- package/components/datePicker.d.ts +120 -0
- package/components/datePicker.mjs +529 -0
- package/components/dateTime.cjs +1 -0
- package/components/dateTime.d.ts +23 -0
- package/components/dateTime.mjs +34 -0
- package/components/dialog.cjs +1 -1
- package/components/dialog.mjs +87 -75
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +1 -1
- package/components/semantics.d.ts +29 -29
- package/components/timeZoneSelect.cjs +1 -0
- package/components/timeZoneSelect.d.ts +52 -0
- package/components/timeZoneSelect.mjs +74 -0
- package/components/toaster.cjs +1 -1
- package/components/toaster.mjs +1 -1
- package/create/src/index.d.ts +1 -0
- package/create/src/options.d.ts +27 -0
- package/create/src/options.test.d.ts +1 -0
- package/create/src/packageManager.d.ts +5 -0
- package/create/src/project.d.ts +25 -0
- package/create/src/project.test.d.ts +1 -0
- package/create/templates/ts/designs/azure.d.ts +5 -0
- package/create/templates/ts/designs/ember.d.ts +5 -0
- package/create/templates/ts/designs/mono.d.ts +5 -0
- package/create/templates/ts/src/App.d.ts +2 -0
- package/create/templates/ts/src/design.d.ts +5 -0
- package/create/templates/ts/src/main.d.ts +0 -0
- package/dataGridDateParts.cjs +1 -0
- package/dataGridDateParts.mjs +223 -0
- package/dataGridList.cjs +1 -1
- package/dataGridList.mjs +335 -372
- package/dataGridListLayout.cjs +1 -0
- package/dataGridListLayout.mjs +49 -0
- package/date-environment.cjs +1 -0
- package/date-environment.mjs +29 -0
- package/date-input.cjs +1 -0
- package/date-input.mjs +346 -0
- package/date-math.cjs +1 -0
- package/date-math.mjs +317 -0
- package/date.cjs +1 -0
- package/date.d.ts +40 -0
- package/date.mjs +4 -0
- package/dates.cjs +1 -0
- package/dates.mjs +689 -0
- package/docs/components.md +6 -1
- package/docs/props.md +19 -19
- package/package.json +124 -27
- package/react/boxComponent.d.ts +1 -1
- package/react/date/dateChange.d.ts +18 -0
- package/react/date/dateEnvironment.d.ts +34 -0
- package/react/theme/theme.d.ts +9 -0
- package/react/theme/themeContext.d.ts +2 -0
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/rsc.cjs +1 -1
- package/rsc.d.ts +3 -0
- package/rsc.mjs +1 -1
- package/ssg.cjs +1 -1
- package/ssg.mjs +1 -1
- package/utils/date/calendar.d.ts +44 -0
- package/utils/date/calendarModel.d.ts +46 -0
- package/utils/date/dateTime.d.ts +144 -0
- package/utils/date/fieldModel.d.ts +74 -0
- package/utils/date/format.d.ts +39 -0
- package/utils/date/iso.d.ts +40 -0
- package/utils/date/locale.d.ts +17 -0
- package/utils/date/parse.d.ts +20 -0
- package/utils/date/settings.d.ts +26 -0
- package/utils/date/value.d.ts +43 -0
- package/utils/date/zoneOptions.d.ts +19 -0
- package/utils/date/zones.d.ts +32 -0
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import t from "../box.mjs";
|
|
4
|
+
import { a as n, i as r, t as i } from "../behavior.mjs";
|
|
5
|
+
import { t as a } from "../placement.mjs";
|
|
6
|
+
import { n 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 { Path as g, Svg as _ } from "./svg.mjs";
|
|
10
|
+
import { n as v } from "../date-environment.mjs";
|
|
11
|
+
import ee from "./calendar.mjs";
|
|
12
|
+
import { t as y } from "../layer.mjs";
|
|
13
|
+
import b from "./overlay.mjs";
|
|
14
|
+
import x from "./dateField.mjs";
|
|
15
|
+
import { useCallback as S, useEffect as C, useMemo as w, useState as T } from "react";
|
|
16
|
+
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
17
|
+
//#region src/components/datePicker.tsx
|
|
18
|
+
function te() {
|
|
19
|
+
return /* @__PURE__ */ D(_, {
|
|
20
|
+
viewBox: "0 0 16 16",
|
|
21
|
+
width: "1rem",
|
|
22
|
+
height: "1rem",
|
|
23
|
+
props: { fill: "none" },
|
|
24
|
+
children: /* @__PURE__ */ D(g, {
|
|
25
|
+
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",
|
|
26
|
+
stroke: "currentColor",
|
|
27
|
+
strokeWidth: 1.5,
|
|
28
|
+
strokeLinecap: "round"
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function ne() {
|
|
33
|
+
return /* @__PURE__ */ D(_, {
|
|
34
|
+
viewBox: "0 0 16 16",
|
|
35
|
+
width: "1rem",
|
|
36
|
+
height: "1rem",
|
|
37
|
+
props: { fill: "none" },
|
|
38
|
+
children: /* @__PURE__ */ D(g, {
|
|
39
|
+
d: "M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12ZM8 5v3l2 1.5",
|
|
40
|
+
stroke: "currentColor",
|
|
41
|
+
strokeWidth: 1.5,
|
|
42
|
+
strokeLinecap: "round",
|
|
43
|
+
strokeLinejoin: "round"
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function re() {
|
|
48
|
+
return /* @__PURE__ */ D(_, {
|
|
49
|
+
viewBox: "0 0 16 16",
|
|
50
|
+
width: "0.875rem",
|
|
51
|
+
height: "0.875rem",
|
|
52
|
+
props: { fill: "none" },
|
|
53
|
+
children: /* @__PURE__ */ D(g, {
|
|
54
|
+
d: "m4.5 4.5 7 7m0-7-7 7",
|
|
55
|
+
stroke: "currentColor",
|
|
56
|
+
strokeWidth: 1.5,
|
|
57
|
+
strokeLinecap: "round"
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function k(e, t) {
|
|
62
|
+
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
63
|
+
}
|
|
64
|
+
function ie(e) {
|
|
65
|
+
let [r, i] = T(null), o = e.ref, s = S((e) => {
|
|
66
|
+
i(e), k(o, e);
|
|
67
|
+
}, [o]), c = (e) => {
|
|
68
|
+
if (!e || e.contains(document.activeElement) && document.activeElement !== e) return;
|
|
69
|
+
let t = [
|
|
70
|
+
"[data-date][tabindex=\"0\"]",
|
|
71
|
+
"[role=\"option\"][tabindex=\"0\"]",
|
|
72
|
+
"button:not([disabled])"
|
|
73
|
+
].map((t) => e.querySelector(t)).find(Boolean), n = e.querySelector("[role=\"listbox\"]"), r = n?.querySelector("[role=\"option\"][tabindex=\"0\"]");
|
|
74
|
+
n && r && (n.scrollTop = r.offsetTop - n.clientHeight / 2 + r.offsetHeight / 2), (t ?? e).focus({ preventScroll: !0 });
|
|
75
|
+
}, l = n((e) => c(e)), { platform: u, isOpen: d, id: f, setPanel: p, setOpen: m, trigger: h, triggerElement: g, panelElement: _ } = y({
|
|
76
|
+
haspopup: "dialog",
|
|
77
|
+
idPrefix: "date-picker",
|
|
78
|
+
open: e.open,
|
|
79
|
+
defaultOpen: e.defaultOpen,
|
|
80
|
+
onOpenChange: e.onOpenChange,
|
|
81
|
+
onOpened: l,
|
|
82
|
+
onClosing: (e, t) => {
|
|
83
|
+
e && t?.focus();
|
|
84
|
+
}
|
|
85
|
+
}), v = a({
|
|
86
|
+
side: e.side,
|
|
87
|
+
align: e.align,
|
|
88
|
+
offset: 1,
|
|
89
|
+
flip: !0,
|
|
90
|
+
anchor: r
|
|
91
|
+
});
|
|
92
|
+
return C(() => {
|
|
93
|
+
d && c(_);
|
|
94
|
+
}, [d, _]), {
|
|
95
|
+
attachTrigger: h.ref,
|
|
96
|
+
triggerAttributes: h.props,
|
|
97
|
+
closeOnChoice: (e) => {
|
|
98
|
+
g?.focus(), m(!1, {
|
|
99
|
+
reason: "select",
|
|
100
|
+
event: e
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
id: f,
|
|
104
|
+
attachField: s,
|
|
105
|
+
panel: (n) => {
|
|
106
|
+
let i = {
|
|
107
|
+
role: "dialog",
|
|
108
|
+
"aria-label": e.label,
|
|
109
|
+
tabIndex: -1
|
|
110
|
+
};
|
|
111
|
+
return u ? /* @__PURE__ */ D(t, {
|
|
112
|
+
ref: p,
|
|
113
|
+
component: "popover",
|
|
114
|
+
variant: { topLayer: !0 },
|
|
115
|
+
p: 3,
|
|
116
|
+
...v.layerProps,
|
|
117
|
+
id: f,
|
|
118
|
+
props: {
|
|
119
|
+
popover: "auto",
|
|
120
|
+
...i
|
|
121
|
+
},
|
|
122
|
+
children: d ? n : null
|
|
123
|
+
}) : d && /* @__PURE__ */ D(b, {
|
|
124
|
+
contentRef: p,
|
|
125
|
+
anchor: r,
|
|
126
|
+
side: e.side,
|
|
127
|
+
align: e.align,
|
|
128
|
+
offset: 1,
|
|
129
|
+
component: "popover",
|
|
130
|
+
p: 3,
|
|
131
|
+
id: f,
|
|
132
|
+
props: i,
|
|
133
|
+
children: n
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function ae(e) {
|
|
139
|
+
let { value: n, step: r, locale: a, hourCycle: o, onSelect: c, label: l } = e, u = w(() => m(r), [r]), d = h(n, r), f = Math.max(0, d ? u.indexOf(d) : u.indexOf("09:00:00")), p = i({
|
|
140
|
+
count: u.length,
|
|
141
|
+
defaultActiveIndex: f,
|
|
142
|
+
loop: !1,
|
|
143
|
+
onSelect: (e, t) => c(u[e], t)
|
|
144
|
+
});
|
|
145
|
+
return /* @__PURE__ */ D(t, {
|
|
146
|
+
component: "datePicker.times",
|
|
147
|
+
position: "relative",
|
|
148
|
+
display: "flex",
|
|
149
|
+
d: "column",
|
|
150
|
+
gap: .5,
|
|
151
|
+
maxHeight: 72,
|
|
152
|
+
overflowY: "auto",
|
|
153
|
+
ps: 2,
|
|
154
|
+
bs: 1,
|
|
155
|
+
props: {
|
|
156
|
+
role: "listbox",
|
|
157
|
+
"aria-label": l,
|
|
158
|
+
onKeyDown: p.onKeyDown
|
|
159
|
+
},
|
|
160
|
+
children: u.map((e, n) => /* @__PURE__ */ D(t, {
|
|
161
|
+
component: "datePicker.time",
|
|
162
|
+
variant: { selected: e === d },
|
|
163
|
+
px: 3,
|
|
164
|
+
py: 1.5,
|
|
165
|
+
borderRadius: 2,
|
|
166
|
+
fontSize: 14,
|
|
167
|
+
textAlign: "start",
|
|
168
|
+
whiteSpace: "nowrap",
|
|
169
|
+
css: { fontVariantNumeric: "tabular-nums" },
|
|
170
|
+
props: {
|
|
171
|
+
role: "option",
|
|
172
|
+
"aria-selected": e === d,
|
|
173
|
+
...p.itemProps(n),
|
|
174
|
+
onClick: (t) => c(e, t)
|
|
175
|
+
},
|
|
176
|
+
children: s(e, {
|
|
177
|
+
locale: a,
|
|
178
|
+
hour: "numeric",
|
|
179
|
+
minute: "2-digit",
|
|
180
|
+
hourCycle: o === void 0 ? void 0 : o === 12 ? "h12" : "h23"
|
|
181
|
+
})
|
|
182
|
+
}, e))
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function oe(e) {
|
|
186
|
+
return /* @__PURE__ */ D(t, {
|
|
187
|
+
component: "datePicker.presets",
|
|
188
|
+
display: "flex",
|
|
189
|
+
d: "column",
|
|
190
|
+
gap: .5,
|
|
191
|
+
pe: 2,
|
|
192
|
+
be: 1,
|
|
193
|
+
props: { role: "group" },
|
|
194
|
+
children: e.presets.map((n) => /* @__PURE__ */ D(t, {
|
|
195
|
+
tag: "button",
|
|
196
|
+
component: "datePicker.preset",
|
|
197
|
+
variant: { selected: e.isSelected(n.value) },
|
|
198
|
+
px: 3,
|
|
199
|
+
py: 1.5,
|
|
200
|
+
borderRadius: 2,
|
|
201
|
+
fontSize: 14,
|
|
202
|
+
textAlign: "start",
|
|
203
|
+
whiteSpace: "nowrap",
|
|
204
|
+
props: {
|
|
205
|
+
type: "button",
|
|
206
|
+
onClick: (t) => e.onSelect(n.value, t)
|
|
207
|
+
},
|
|
208
|
+
children: n.label
|
|
209
|
+
}, n.label))
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function A(e, n) {
|
|
213
|
+
let { type: i = "date", value: a, defaultValue: o = null, onValueChange: m, zone: h, locale: g, hourCycle: _, granularity: y, disambiguation: b, min: S, max: C, isDateUnavailable: w, disabled: T = !1, readOnly: k = !1, required: A, invalid: j, name: M, label: N, labelledBy: se, describedBy: ce, open: le, defaultOpen: ue, onOpenChange: P, closeOnSelect: F = !0, firstDayOfWeek: I, weekNumbers: L, side: de = "bottom", align: R = "start", clearable: fe = !1, triggerLabel: z, clearLabel: pe = "Clear", tabIndex: B, step: V = 30, defaultTime: H = "00:00", presets: U, showZone: me, ...he } = e, W = v({
|
|
214
|
+
locale: g,
|
|
215
|
+
zone: h === "none" ? void 0 : h
|
|
216
|
+
}), { locale: G } = W, K = i === "datetime" && h !== "none" ? W.zone : null, q = K ?? W.zone, [J, Y] = r({
|
|
217
|
+
value: a,
|
|
218
|
+
defaultValue: o,
|
|
219
|
+
onChange: (e, t) => m?.(e, {
|
|
220
|
+
...t,
|
|
221
|
+
...p(e, q)
|
|
222
|
+
})
|
|
223
|
+
}), X = z ?? (i === "time" ? "Choose time" : "Choose date"), Z = typeof N == "string" ? N : X, { attachTrigger: Q, triggerAttributes: ge, closeOnChoice: _e, attachField: ve, panel: ye } = ie({
|
|
224
|
+
ref: n,
|
|
225
|
+
open: le,
|
|
226
|
+
defaultOpen: ue,
|
|
227
|
+
onOpenChange: P,
|
|
228
|
+
side: de,
|
|
229
|
+
align: R,
|
|
230
|
+
label: Z
|
|
231
|
+
}), be = J && i !== "time" ? u(J, { zone: q }) : null, xe = J && i !== "date" ? c(J, { zone: q }) : null, Se = J ? s(J, {
|
|
232
|
+
locale: G,
|
|
233
|
+
zone: q,
|
|
234
|
+
...i === "date" ? { dateStyle: "medium" } : i === "time" ? { timeStyle: "short" } : {
|
|
235
|
+
dateStyle: "medium",
|
|
236
|
+
timeStyle: "short"
|
|
237
|
+
}
|
|
238
|
+
}) : "", $ = _e, Ce = (e, t) => f(e, t, K ? {
|
|
239
|
+
zone: K,
|
|
240
|
+
disambiguation: b
|
|
241
|
+
} : {}), we = (e, t) => {
|
|
242
|
+
e && (i === "date" ? (Y(e, {
|
|
243
|
+
reason: "select",
|
|
244
|
+
event: t
|
|
245
|
+
}), F && $(t)) : Y(Ce(e, xe ?? H), {
|
|
246
|
+
reason: "select",
|
|
247
|
+
event: t
|
|
248
|
+
}));
|
|
249
|
+
}, Te = (e, t) => {
|
|
250
|
+
Y(i === "time" ? e : Ce(be ?? l(q), e), {
|
|
251
|
+
reason: "select",
|
|
252
|
+
event: t
|
|
253
|
+
}), F && $(t);
|
|
254
|
+
}, Ee = /* @__PURE__ */ D(t, {
|
|
255
|
+
tag: "button",
|
|
256
|
+
ref: Q,
|
|
257
|
+
component: "datePicker.trigger",
|
|
258
|
+
display: "inline-flex",
|
|
259
|
+
ai: "center",
|
|
260
|
+
jc: "center",
|
|
261
|
+
width: 7,
|
|
262
|
+
height: 7,
|
|
263
|
+
ms: 2,
|
|
264
|
+
me: -1.5,
|
|
265
|
+
borderRadius: 1.5,
|
|
266
|
+
disabled: T || k,
|
|
267
|
+
props: {
|
|
268
|
+
type: "button",
|
|
269
|
+
"aria-label": Se ? `${X}, ${Se}` : X,
|
|
270
|
+
tabIndex: B,
|
|
271
|
+
...ge
|
|
272
|
+
},
|
|
273
|
+
children: D(i === "time" ? ne : te, {})
|
|
274
|
+
}), De = fe && J && !T && !k && /* @__PURE__ */ D(t, {
|
|
275
|
+
tag: "button",
|
|
276
|
+
component: "datePicker.clear",
|
|
277
|
+
display: "inline-flex",
|
|
278
|
+
ai: "center",
|
|
279
|
+
jc: "center",
|
|
280
|
+
width: 6,
|
|
281
|
+
height: 6,
|
|
282
|
+
ms: 1,
|
|
283
|
+
borderRadius: 999,
|
|
284
|
+
props: {
|
|
285
|
+
type: "button",
|
|
286
|
+
"aria-label": pe,
|
|
287
|
+
tabIndex: B,
|
|
288
|
+
onClick: (e) => Y(null, {
|
|
289
|
+
reason: "clear",
|
|
290
|
+
event: e
|
|
291
|
+
})
|
|
292
|
+
},
|
|
293
|
+
children: /* @__PURE__ */ D(re, {})
|
|
294
|
+
});
|
|
295
|
+
return /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(x, {
|
|
296
|
+
ref: ve,
|
|
297
|
+
...he,
|
|
298
|
+
type: i,
|
|
299
|
+
value: J,
|
|
300
|
+
onValueChange: (e, t) => Y(e, {
|
|
301
|
+
reason: t.reason,
|
|
302
|
+
event: t.event
|
|
303
|
+
}),
|
|
304
|
+
zone: h,
|
|
305
|
+
locale: g,
|
|
306
|
+
hourCycle: _,
|
|
307
|
+
granularity: y,
|
|
308
|
+
disambiguation: b,
|
|
309
|
+
min: S,
|
|
310
|
+
max: C,
|
|
311
|
+
isDateUnavailable: w,
|
|
312
|
+
disabled: T,
|
|
313
|
+
readOnly: k,
|
|
314
|
+
required: A,
|
|
315
|
+
invalid: j,
|
|
316
|
+
name: M,
|
|
317
|
+
label: N,
|
|
318
|
+
labelledBy: se,
|
|
319
|
+
describedBy: ce,
|
|
320
|
+
showZone: me,
|
|
321
|
+
tabIndex: B,
|
|
322
|
+
end: /* @__PURE__ */ O(E, { children: [De, Ee] })
|
|
323
|
+
}), ye(/* @__PURE__ */ O(t, {
|
|
324
|
+
display: "flex",
|
|
325
|
+
gap: 3,
|
|
326
|
+
ai: "stretch",
|
|
327
|
+
children: [
|
|
328
|
+
U && U.length > 0 && /* @__PURE__ */ D(oe, {
|
|
329
|
+
presets: U,
|
|
330
|
+
isSelected: (e) => J !== null && d(e, J, { zone: q }) === 0,
|
|
331
|
+
onSelect: (e, t) => {
|
|
332
|
+
Y(e, {
|
|
333
|
+
reason: "preset",
|
|
334
|
+
event: t
|
|
335
|
+
}), F && $(t);
|
|
336
|
+
}
|
|
337
|
+
}),
|
|
338
|
+
i !== "time" && /* @__PURE__ */ D(ee, {
|
|
339
|
+
value: be,
|
|
340
|
+
onValueChange: (e, t) => we(e, t.event),
|
|
341
|
+
min: S ? u(S, { zone: q }) : void 0,
|
|
342
|
+
max: C ? u(C, { zone: q }) : void 0,
|
|
343
|
+
isDateUnavailable: w,
|
|
344
|
+
locale: g,
|
|
345
|
+
zone: h === "none" ? void 0 : h,
|
|
346
|
+
firstDayOfWeek: I,
|
|
347
|
+
weekNumbers: L
|
|
348
|
+
}),
|
|
349
|
+
i !== "date" && /* @__PURE__ */ D(ae, {
|
|
350
|
+
value: xe,
|
|
351
|
+
step: V,
|
|
352
|
+
locale: G,
|
|
353
|
+
hourCycle: _,
|
|
354
|
+
label: i === "time" ? Z : "Time",
|
|
355
|
+
onSelect: Te
|
|
356
|
+
})
|
|
357
|
+
]
|
|
358
|
+
}))] });
|
|
359
|
+
}
|
|
360
|
+
function j(e, n) {
|
|
361
|
+
let { value: i, defaultValue: a = null, onValueChange: s, locale: c, min: l, max: u, isDateUnavailable: f, disabled: p = !1, readOnly: m = !1, required: h, invalid: g, startName: _, endName: y, label: b, labelledBy: S, describedBy: C, startLabel: w = "Start date", endLabel: ne = "End date", open: k, defaultOpen: ae, onOpenChange: A, closeOnSelect: j = !0, firstDayOfWeek: M, weekNumbers: N, months: se = 2, side: ce = "bottom", align: le = "start", clearable: ue = !1, triggerLabel: P = "Choose dates", clearLabel: F = "Clear", tabIndex: I, presets: L, props: de, ...R } = e, { locale: fe } = v({ locale: c }), [z, pe] = r({
|
|
362
|
+
value: i,
|
|
363
|
+
defaultValue: a,
|
|
364
|
+
onChange: s
|
|
365
|
+
}), [B, V] = T({
|
|
366
|
+
start: z?.start ?? null,
|
|
367
|
+
end: z?.end ?? null,
|
|
368
|
+
source: z
|
|
369
|
+
}), { start: H, end: U } = B;
|
|
370
|
+
B.source !== z && (H = z?.start ?? null, U = z?.end ?? null, V({
|
|
371
|
+
start: H,
|
|
372
|
+
end: U,
|
|
373
|
+
source: z
|
|
374
|
+
}));
|
|
375
|
+
let { attachTrigger: me, triggerAttributes: he, closeOnChoice: W, id: G, attachField: K, panel: q } = ie({
|
|
376
|
+
ref: n,
|
|
377
|
+
open: k,
|
|
378
|
+
defaultOpen: ae,
|
|
379
|
+
onOpenChange: A,
|
|
380
|
+
side: ce,
|
|
381
|
+
align: le,
|
|
382
|
+
label: typeof b == "string" ? b : P
|
|
383
|
+
}), J = z ? o(z.start, z.end, { locale: fe }) : "", Y = H !== null && U !== null && d(H, U) > 0, X = (e, t, n, r) => {
|
|
384
|
+
let i = e && t && d(e, t) <= 0 ? {
|
|
385
|
+
start: e,
|
|
386
|
+
end: t
|
|
387
|
+
} : null;
|
|
388
|
+
V({
|
|
389
|
+
start: e,
|
|
390
|
+
end: t,
|
|
391
|
+
source: i
|
|
392
|
+
}), pe(i, {
|
|
393
|
+
reason: n,
|
|
394
|
+
event: r
|
|
395
|
+
});
|
|
396
|
+
}, Z = W, Q = {
|
|
397
|
+
locale: c,
|
|
398
|
+
min: l,
|
|
399
|
+
max: u,
|
|
400
|
+
isDateUnavailable: f,
|
|
401
|
+
disabled: p,
|
|
402
|
+
readOnly: m,
|
|
403
|
+
required: h,
|
|
404
|
+
component: "datePicker.part",
|
|
405
|
+
px: 0,
|
|
406
|
+
py: 0,
|
|
407
|
+
tabIndex: I
|
|
408
|
+
};
|
|
409
|
+
return /* @__PURE__ */ O(E, { children: [
|
|
410
|
+
b !== void 0 && /* @__PURE__ */ D(t, {
|
|
411
|
+
component: "dateField.label",
|
|
412
|
+
display: "block",
|
|
413
|
+
mb: 1.5,
|
|
414
|
+
fontSize: 14,
|
|
415
|
+
id: `${G}-label`,
|
|
416
|
+
children: b
|
|
417
|
+
}),
|
|
418
|
+
/* @__PURE__ */ O(t, {
|
|
419
|
+
ref: K,
|
|
420
|
+
component: "dateField",
|
|
421
|
+
display: "inline-flex",
|
|
422
|
+
ai: "center",
|
|
423
|
+
gap: 2,
|
|
424
|
+
px: 3,
|
|
425
|
+
py: 2,
|
|
426
|
+
...R,
|
|
427
|
+
variant: [R.variant, {
|
|
428
|
+
disabled: p,
|
|
429
|
+
invalid: g ?? Y
|
|
430
|
+
}],
|
|
431
|
+
props: {
|
|
432
|
+
role: "group",
|
|
433
|
+
"aria-labelledby": [b === void 0 ? void 0 : `${G}-label`, S].filter(Boolean).join(" ") || void 0,
|
|
434
|
+
"aria-invalid": (g ?? Y) || void 0,
|
|
435
|
+
"aria-describedby": C,
|
|
436
|
+
...de
|
|
437
|
+
},
|
|
438
|
+
children: [
|
|
439
|
+
/* @__PURE__ */ D(x, {
|
|
440
|
+
...Q,
|
|
441
|
+
value: H,
|
|
442
|
+
onValueChange: (e, t) => X(e, U, t.reason, t.event),
|
|
443
|
+
name: _,
|
|
444
|
+
props: { "aria-label": w },
|
|
445
|
+
invalid: g ?? Y
|
|
446
|
+
}),
|
|
447
|
+
/* @__PURE__ */ D(t, {
|
|
448
|
+
component: "dateField.literal",
|
|
449
|
+
props: { "aria-hidden": !0 },
|
|
450
|
+
children: "–"
|
|
451
|
+
}),
|
|
452
|
+
/* @__PURE__ */ D(x, {
|
|
453
|
+
...Q,
|
|
454
|
+
value: U,
|
|
455
|
+
onValueChange: (e, t) => X(H, e, t.reason, t.event),
|
|
456
|
+
name: y,
|
|
457
|
+
props: { "aria-label": ne },
|
|
458
|
+
invalid: g ?? Y
|
|
459
|
+
}),
|
|
460
|
+
ue && z && !p && !m && /* @__PURE__ */ D(t, {
|
|
461
|
+
tag: "button",
|
|
462
|
+
component: "datePicker.clear",
|
|
463
|
+
display: "inline-flex",
|
|
464
|
+
ai: "center",
|
|
465
|
+
jc: "center",
|
|
466
|
+
width: 6,
|
|
467
|
+
height: 6,
|
|
468
|
+
borderRadius: 999,
|
|
469
|
+
props: {
|
|
470
|
+
type: "button",
|
|
471
|
+
"aria-label": F,
|
|
472
|
+
tabIndex: I,
|
|
473
|
+
onClick: (e) => X(null, null, "clear", e)
|
|
474
|
+
},
|
|
475
|
+
children: /* @__PURE__ */ D(re, {})
|
|
476
|
+
}),
|
|
477
|
+
/* @__PURE__ */ D(t, {
|
|
478
|
+
tag: "button",
|
|
479
|
+
ref: me,
|
|
480
|
+
component: "datePicker.trigger",
|
|
481
|
+
display: "inline-flex",
|
|
482
|
+
ai: "center",
|
|
483
|
+
jc: "center",
|
|
484
|
+
width: 7,
|
|
485
|
+
height: 7,
|
|
486
|
+
me: -1.5,
|
|
487
|
+
borderRadius: 1.5,
|
|
488
|
+
disabled: p || m,
|
|
489
|
+
props: {
|
|
490
|
+
type: "button",
|
|
491
|
+
"aria-label": J ? `${P}, ${J}` : P,
|
|
492
|
+
tabIndex: I,
|
|
493
|
+
...he
|
|
494
|
+
},
|
|
495
|
+
children: /* @__PURE__ */ D(te, {})
|
|
496
|
+
})
|
|
497
|
+
]
|
|
498
|
+
}),
|
|
499
|
+
q(/* @__PURE__ */ O(t, {
|
|
500
|
+
display: "flex",
|
|
501
|
+
gap: 3,
|
|
502
|
+
ai: "stretch",
|
|
503
|
+
children: [L && L.length > 0 && /* @__PURE__ */ D(oe, {
|
|
504
|
+
presets: L,
|
|
505
|
+
isSelected: (e) => z !== null && e.start === z.start && e.end === z.end,
|
|
506
|
+
onSelect: (e, t) => {
|
|
507
|
+
X(e.start, e.end, "preset", t), j && Z(t);
|
|
508
|
+
}
|
|
509
|
+
}), /* @__PURE__ */ D(ee, {
|
|
510
|
+
mode: "range",
|
|
511
|
+
months: se,
|
|
512
|
+
value: z,
|
|
513
|
+
defaultFocusedDate: H ?? void 0,
|
|
514
|
+
onValueChange: (e, t) => {
|
|
515
|
+
X(e?.start ?? null, e?.end ?? null, "select", t.event), j && e && t.event && Z(t.event);
|
|
516
|
+
},
|
|
517
|
+
min: l,
|
|
518
|
+
max: u,
|
|
519
|
+
isDateUnavailable: f,
|
|
520
|
+
locale: c,
|
|
521
|
+
firstDayOfWeek: M,
|
|
522
|
+
weekNumbers: N
|
|
523
|
+
})]
|
|
524
|
+
}))
|
|
525
|
+
] });
|
|
526
|
+
}
|
|
527
|
+
var M = e(A, "DatePicker"), N = e(j, "DateRangePicker");
|
|
528
|
+
//#endregion
|
|
529
|
+
export { N as DateRangePicker, M as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../react-shared.cjs"),t=require("../box.cjs"),n=require("../dates.cjs"),r=require("../date-environment.cjs");function i(e,i){let{value:a,zone:o,locale:s,format:c,relative:l,props:u,...d}=e,f=r.n({locale:s,zone:o}),p=n.f(a),m=p&&n.E(p),h=m?l?n.r(m,{...l===!0?{}:l,locale:f.locale,zone:f.zone}):n.t(m,{...c,locale:f.locale,zone:f.zone}):``;return t.useBoxElement({tag:`time`,display:`inline`,...d,props:{dateTime:m??void 0,suppressHydrationWarning:l?!0:void 0,...u},children:h},i)}var a=e.f(i,`DateTime`);exports.DateProvider=r.t,exports.default=a;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RefAttributes } from 'react';
|
|
2
|
+
import { BoxProps } from '../box';
|
|
3
|
+
import { DateProvider, DateProviderProps } from '../react/date/dateEnvironment';
|
|
4
|
+
import { ComponentsAndVariants } from '@box-kite/core/types';
|
|
5
|
+
import { FormatOptions, RelativeOptions } from '../utils/date/format';
|
|
6
|
+
import { ZoneInput } from '../utils/date/zones';
|
|
7
|
+
export { DateProvider };
|
|
8
|
+
export type { DateProviderProps };
|
|
9
|
+
type DateTimeBoxProps<TKey extends keyof ComponentsAndVariants> = Omit<BoxProps<'time', TKey>, 'tag' | 'children'>;
|
|
10
|
+
export interface DateTimeProps<TKey extends keyof ComponentsAndVariants = never> extends DateTimeBoxProps<TKey> {
|
|
11
|
+
/** What to show: any ISO string, a `Date` or epoch milliseconds. Nothing is rendered for a non-value. */
|
|
12
|
+
value: string | number | Date | null | undefined;
|
|
13
|
+
/** Whose wall clock an instant is shown on. Default `'local'`, the reader's. A date or a time has no zone. */
|
|
14
|
+
zone?: ZoneInput;
|
|
15
|
+
/** The reader's language. Default the reader's own. */
|
|
16
|
+
locale?: string;
|
|
17
|
+
/** How to write it — `{ dateStyle: 'long' }`, `{ month: 'short', day: 'numeric' }`. Default by kind. */
|
|
18
|
+
format?: Omit<FormatOptions, 'locale' | 'zone'>;
|
|
19
|
+
/** `3 minutes ago`, `tomorrow` instead of the date. An object passes `now`, `numeric` and `style`. */
|
|
20
|
+
relative?: boolean | Omit<RelativeOptions, 'locale' | 'zone'>;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: <TKey extends keyof ComponentsAndVariants = never>(props: DateTimeProps<TKey> & RefAttributes<HTMLTimeElement>) => React.ReactNode;
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { useBoxElement as t } from "../box.mjs";
|
|
4
|
+
import { E as n, f as r, r as i, t as a } from "../dates.mjs";
|
|
5
|
+
import { n as o, t as s } from "../date-environment.mjs";
|
|
6
|
+
//#region src/components/dateTime.tsx
|
|
7
|
+
function c(e, s) {
|
|
8
|
+
let { value: c, zone: l, locale: u, format: d, relative: f, props: p, ...m } = e, h = o({
|
|
9
|
+
locale: u,
|
|
10
|
+
zone: l
|
|
11
|
+
}), g = r(c), _ = g && n(g), v = _ ? f ? i(_, {
|
|
12
|
+
...f === !0 ? {} : f,
|
|
13
|
+
locale: h.locale,
|
|
14
|
+
zone: h.zone
|
|
15
|
+
}) : a(_, {
|
|
16
|
+
...d,
|
|
17
|
+
locale: h.locale,
|
|
18
|
+
zone: h.zone
|
|
19
|
+
}) : "";
|
|
20
|
+
return t({
|
|
21
|
+
tag: "time",
|
|
22
|
+
display: "inline",
|
|
23
|
+
...m,
|
|
24
|
+
props: {
|
|
25
|
+
dateTime: _ ?? void 0,
|
|
26
|
+
suppressHydrationWarning: f ? !0 : void 0,
|
|
27
|
+
...p
|
|
28
|
+
},
|
|
29
|
+
children: v
|
|
30
|
+
}, s);
|
|
31
|
+
}
|
|
32
|
+
var l = e(c, "DateTime");
|
|
33
|
+
//#endregion
|
|
34
|
+
export { s as DateProvider, l as default };
|
package/components/dialog.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../client.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../identity.cjs"),o=require("./semantics.cjs");let s=require("react"),c=require("react/jsx-runtime");var l=(0,s.createContext)(null);function
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../client.cjs"),t=require("../platform.cjs"),n=require("../effects.cjs"),r=require("../box.cjs"),i=require("../behavior.cjs"),a=require("../identity.cjs"),o=require("./semantics.cjs");let s=require("react"),c=require("react/jsx-runtime");var l=0;function u(r){let{classNames:i,styleElements:a}=e.i({overflow:`hidden`},!1),o=i.slice(1).join(` `);return n.n(()=>{let e=t.n();if(!(!r||!e||!o))return l+=1,e.classList.add(o),()=>{--l,l===0&&e.classList.remove(o)}},[r,o]),a}var d=(0,s.createContext)(null);function f(e){let t=(0,s.useContext)(d);if(!t)throw Error(`<${e}> must be rendered inside a <Dialog>.`);return t}function p(e){return(0,c.jsx)(h,{role:`dialog`,...e})}function m(e){return(0,c.jsx)(h,{role:`alertdialog`,...e,modal:!0,dismissible:!1})}function h(e){let{role:o,trigger:l,children:f,open:p,defaultOpen:m=!1,onOpenChange:h,label:_,labelledBy:v,describedBy:y,modal:b=!0,dismissible:x=!0,lockScroll:S=b,initialFocus:C,props:w,...T}=e,E=a.t(`dialog`),D=T.id??E,[O,k]=i.i({value:p,defaultValue:m,onChange:h}),[A,j]=(0,s.useState)(null),[M,N]=(0,s.useState)(null),[P,F]=(0,s.useState)(!1),[I,L]=(0,s.useState)({title:0,description:0}),R=u(O&&S);i.n({enabled:O,returnTo:M});let z=(0,s.useCallback)(e=>(L(t=>({...t,[e]:t[e]+1})),()=>L(t=>({...t,[e]:t[e]-1}))),[]),B=(0,s.useMemo)(()=>({titleId:`${D}-title`,descriptionId:`${D}-description`,register:z}),[D,z]);g({dialog:A,isOpen:O,domOpen:P,setDomOpen:F,setOpen:k,modal:b,dismissible:x,triggerElement:M}),n.n(()=>{let e=t.l(C);!O||!e||e.focus()},[O,C]);let V=i.a(e=>{k(e=>!e,{reason:`trigger`,event:e})}),H=(0,s.useMemo)(()=>({ref:N,props:{"aria-expanded":O,"aria-haspopup":`dialog`,"aria-controls":O?D:void 0,onClick:V}}),[D,V,O]),U=T;return(0,c.jsxs)(c.Fragment,{children:[R,l?.(H),(0,c.jsx)(d.Provider,{value:B,children:(0,c.jsx)(r.default,{ref:j,tag:`dialog`,component:`dialog`,...U,id:D,props:{role:o,"aria-label":I.title||v?void 0:_,"aria-labelledby":v??(I.title?B.titleId:void 0),"aria-describedby":y??(I.description?B.descriptionId:void 0),...w},children:f})})]})}function g(e){let{dialog:r,isOpen:a,domOpen:o,setDomOpen:c,setOpen:l,modal:u,dismissible:d,triggerElement:f}=e,p=(0,s.useRef)(`imperative`),m=t.a(),h=d?`any`:`closerequest`;n.n(()=>{!r||a===o||(c(a),a?u?r.showModal():r.show():r.close())},[r,a,o,u,c]),n.n(()=>{if(!r)return;let e=new AbortController;return r.addEventListener(`close`,e=>{c(!1),l(!1,{reason:p.current,event:e}),p.current=`imperative`},{signal:e.signal}),()=>e.abort()},[r,c,l]),n.n(()=>{if(!(!r||!m))return r.setAttribute(`closedby`,h),()=>r.removeAttribute(`closedby`)},[r,m,h]),n.n(()=>{if(!a||!r)return;let e=new AbortController,n=(t,n)=>document.addEventListener(t,n,{signal:e.signal,capture:!0});return n(`keydown`,e=>{e.key===`Escape`&&(p.current=`escape`)}),n(`pointerdown`,e=>{t.u(e,[f])?p.current=`trigger`:!t.u(e,[r])||_(r,e)?p.current=`outside-pointer`:p.current=`imperative`}),()=>e.abort()},[a,r,f]),i.r({enabled:a&&!u&&!m,inside:[r],escapeKey:!0,outsidePointer:!1,onDismiss:(e,t)=>l(!1,{reason:`escape`,event:t})}),n.n(()=>{if(!r||!a||!d||m)return;let e=new AbortController;return document.addEventListener(`pointerdown`,e=>{t.u(e,[f])||t.u(e,[r])&&!_(r,e)||l(!1,{reason:`outside-pointer`,event:e})},{signal:e.signal,capture:!0}),()=>e.abort()},[r,a,d,m,f,l])}function _(e,t){let n=e.getBoundingClientRect();return t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom}function v(e){let t=f(`Dialog.Title`);return n.n(()=>t.register(`title`),[t]),(0,c.jsx)(o.H2,{id:t.titleId,component:`dialog.title`,...e})}function y(e){let t=f(`Dialog.Description`);return n.n(()=>t.register(`description`),[t]),(0,c.jsx)(o.P,{id:t.descriptionId,component:`dialog.description`,...e})}v.displayName=`Dialog.Title`,y.displayName=`Dialog.Description`;var b={Title:v,Description:y},x=Object.assign(p,b),S=Object.assign(m,b);p.displayName=`Dialog`,m.displayName=`AlertDialog`,exports.AlertDialog=S,exports.default=x;
|