@box-kite/react 2.2.4 → 2.2.6
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 +11 -1
- package/.claude/skills/box-kite/SKILL.md +11 -1
- package/.claude/skills/box-kite/references/components.md +83 -3
- package/.cursor/rules/box-kite.mdc +11 -1
- package/AGENTS.md +11 -1
- package/BOX_AI_CONTEXT.md +371 -25
- package/BOX_KITE_AI_CONTEXT.md +371 -25
- package/behavior.cjs +1 -1
- package/behavior.mjs +57 -57
- package/box.cjs +1 -1
- package/box.d.ts +5 -0
- package/box.mjs +15 -15
- package/catalog.cjs +1 -1
- package/catalog.mjs +906 -0
- package/client.cjs +1 -1
- package/client.mjs +94 -80
- package/components/calendar.cjs +1 -0
- package/components/calendar.d.ts +77 -0
- package/components/calendar.mjs +483 -0
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.mjs +1 -1
- 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/components/dataGridList.d.ts +12 -0
- package/components/dataGrid/components/dataGridListAggregate.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilter.d.ts +7 -0
- package/components/dataGrid/components/dataGridListFilterSheet.d.ts +11 -0
- package/components/dataGrid/components/dataGridListFooter.d.ts +13 -0
- package/components/dataGrid/components/dataGridListGroup.d.ts +13 -0
- package/components/dataGrid/components/dataGridListItem.d.ts +21 -0
- package/components/dataGrid/components/dataGridListLayout.d.ts +20 -0
- package/components/dataGrid/components/dataGridListRecord.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSelectionBar.d.ts +11 -0
- package/components/dataGrid/components/dataGridListSheet.d.ts +30 -0
- package/components/dataGrid/components/dataGridListSortSheet.d.ts +10 -0
- package/components/dataGrid/components/dataGridListToolbar.d.ts +10 -0
- package/components/dataGrid/components/dataGridListValue.d.ts +12 -0
- package/components/dataGrid/contracts/dataGridContract.d.ts +70 -11
- package/components/dataGrid/models/columnModel.d.ts +3 -1
- package/components/dataGrid/models/editModel.d.ts +3 -1
- package/components/dataGrid/models/gridModel.d.ts +3 -0
- package/components/dataGrid/models/listModel.d.ts +129 -0
- package/components/dataGrid/models/localeText.d.ts +36 -0
- package/components/dataGrid/models/viewportModel.d.ts +0 -2
- package/components/dataGrid/useDateParts.d.ts +17 -0
- package/components/dataGrid/useListLayout.d.ts +13 -0
- package/components/dataGrid.cjs +3 -3
- package/components/dataGrid.mjs +1251 -854
- 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 +29 -29
- package/components/list/listItemParts.d.ts +9 -0
- package/components/list.cjs +1 -0
- package/components/list.d.ts +118 -0
- package/components/list.mjs +391 -0
- package/components/menu.cjs +1 -1
- package/components/menu.mjs +25 -25
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +12 -12
- package/components/semantics.d.ts +29 -29
- package/components/slider.cjs +1 -1
- package/components/slider.mjs +1 -1
- package/components/sortableList.cjs +1 -0
- package/components/sortableList.d.ts +49 -0
- package/components/sortableList.mjs +384 -0
- package/components/swipeItem.cjs +1 -0
- package/components/swipeItem.d.ts +52 -0
- package/components/swipeItem.mjs +321 -0
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +1 -1
- 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 +24 -24
- package/components/virtualList.cjs +1 -0
- package/components/virtualList.d.ts +32 -0
- package/components/virtualList.mjs +188 -0
- package/dataGridDateParts.cjs +1 -0
- package/dataGridDateParts.mjs +223 -0
- package/dataGridList.cjs +1 -0
- package/dataGridList.mjs +1314 -0
- 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 +10 -1
- package/icons/closeIcon.d.ts +2 -0
- package/icons/filterIcon.d.ts +2 -0
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/mcp/src/data.d.ts +2 -0
- package/package.json +178 -22
- package/placement.cjs +1 -1
- package/placement.mjs +10 -10
- package/platform.cjs +1 -1
- package/platform.mjs +4 -1
- package/react/a11y/useControllableState.d.ts +2 -1
- package/react/boxComponent.d.ts +1 -1
- package/react/componentsContext.d.ts +4 -0
- package/react/componentsProvider.d.ts +10 -0
- package/react/date/dateChange.d.ts +18 -0
- package/react/date/dateEnvironment.d.ts +34 -0
- package/react/resolveStyles.d.ts +2 -1
- package/react/theme/theme.d.ts +6 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +6 -6
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +3 -1
- package/registry/designs/store/address-form.d.ts +11 -0
- package/registry/designs/store/cart-items.d.ts +10 -0
- package/registry/designs/store/cart-page.d.ts +4 -0
- package/registry/designs/store/checkout-page.d.ts +7 -0
- package/registry/designs/store/credit-card-form.d.ts +10 -0
- package/registry/designs/store/form-field.d.ts +19 -0
- package/registry/designs/store/order-summary.d.ts +18 -0
- package/registry/designs/store/product-art.d.ts +26 -0
- package/registry/designs/store/product-card.d.ts +11 -0
- package/registry/designs/store/product-gallery.d.ts +11 -0
- package/registry/designs/store/product-grid.d.ts +10 -0
- package/registry/designs/store/product-page.d.ts +5 -0
- package/registry/designs/store/quantity-stepper.d.ts +13 -0
- package/registry/designs/store/shipping-method.d.ts +14 -0
- package/registry/designs/store/store-data.d.ts +53 -0
- package/registry/designs/store/store-design.d.ts +63 -0
- package/registry/designs/store/store-shell.d.ts +12 -0
- package/registry/designs/store/storefront-page.d.ts +4 -0
- package/registry/designs/store/variant-picker.d.ts +15 -0
- package/rsc.cjs +1 -1
- package/rsc.d.ts +2 -0
- package/rsc.mjs +1 -1
- package/scrolling.cjs +1 -0
- package/scrolling.mjs +22 -0
- 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
- package/utils/scroll/scrollUtils.d.ts +6 -0
- package/utils/sortable/sortableUtils.d.ts +25 -0
- package/utils/swipe/swipeUtils.d.ts +53 -0
- package/utils/virtual/measuredWindow.d.ts +28 -0
- package/utils/virtual/rowSearch.d.ts +11 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { d as t, s as n, t as r, u as i } from "../platform.mjs";
|
|
4
|
+
import { n as a } from "../effects.mjs";
|
|
5
|
+
import { useBoxElement as o } from "../box.mjs";
|
|
6
|
+
import { a as s, i as c, o as l } from "../behavior.mjs";
|
|
7
|
+
import { n as u } from "../motion.mjs";
|
|
8
|
+
import d, { i as f, n as p, r as m, t as h } from "./list.mjs";
|
|
9
|
+
import { createContext as g, useCallback as ee, useContext as _, useEffect as v, useRef as y, useState as b } from "react";
|
|
10
|
+
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
11
|
+
//#region src/utils/swipe/swipeUtils.ts
|
|
12
|
+
var w;
|
|
13
|
+
(function(e) {
|
|
14
|
+
let t = e.SLOP = 8, n = e.FLICK = .4, r = e.FULL_RATIO = .6;
|
|
15
|
+
function i(e, n) {
|
|
16
|
+
return Math.max(Math.abs(e), Math.abs(n)) < t ? null : Math.abs(e) > Math.abs(n) ? "swipe" : "scroll";
|
|
17
|
+
}
|
|
18
|
+
e.intent = i;
|
|
19
|
+
function a(e, t) {
|
|
20
|
+
return (1 - 1 / (e * .55 / t + 1)) * t;
|
|
21
|
+
}
|
|
22
|
+
function o(e, t, n, r, i) {
|
|
23
|
+
let o = e + t, s = o < 0 ? -1 : 1, c = o < 0 ? n.end : n.start, l = Math.abs(o);
|
|
24
|
+
return c === 0 ? 0 : l <= c ? o : i ? s * Math.min(l, r) : s * (c + a(l - c, Math.max(r, 1)));
|
|
25
|
+
}
|
|
26
|
+
e.offsetFor = o;
|
|
27
|
+
function s(e, n, i, a) {
|
|
28
|
+
if (!a || e === 0) return null;
|
|
29
|
+
let o = e > 0 ? "start" : "end", s = n[o];
|
|
30
|
+
return s === 0 ? null : Math.abs(e) >= Math.max(s + t * 4, i * r) ? o : null;
|
|
31
|
+
}
|
|
32
|
+
e.armed = s;
|
|
33
|
+
function c(e, t, r, i, a) {
|
|
34
|
+
let o = s(e, r, i, a);
|
|
35
|
+
if (o) return {
|
|
36
|
+
open: null,
|
|
37
|
+
full: o
|
|
38
|
+
};
|
|
39
|
+
if (e === 0) return {
|
|
40
|
+
open: null,
|
|
41
|
+
full: null
|
|
42
|
+
};
|
|
43
|
+
let c = e > 0 ? "start" : "end", l = r[c];
|
|
44
|
+
return l === 0 ? {
|
|
45
|
+
open: null,
|
|
46
|
+
full: null
|
|
47
|
+
} : Math.abs(t) >= n ? {
|
|
48
|
+
open: Math.sign(t) === Math.sign(e) ? c : null,
|
|
49
|
+
full: null
|
|
50
|
+
} : {
|
|
51
|
+
open: Math.abs(e) >= l / 2 ? c : null,
|
|
52
|
+
full: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
e.settle = c;
|
|
56
|
+
let l = e.VELOCITY_WINDOW = 100;
|
|
57
|
+
function u(e, t) {
|
|
58
|
+
return [...e.filter((e) => t.t - e.t <= l), t];
|
|
59
|
+
}
|
|
60
|
+
e.track = u;
|
|
61
|
+
function d(e) {
|
|
62
|
+
let t = e[0], n = e[e.length - 1];
|
|
63
|
+
return !t || !n || n.t - t.t < 16 ? 0 : (n.x - t.x) / (n.t - t.t);
|
|
64
|
+
}
|
|
65
|
+
e.velocity = d;
|
|
66
|
+
function f(e, t) {
|
|
67
|
+
return e === "start" ? t.start : e === "end" ? -t.end : 0;
|
|
68
|
+
}
|
|
69
|
+
e.restOffset = f;
|
|
70
|
+
})(w ||= {});
|
|
71
|
+
var T = w, E = g(null), te = {
|
|
72
|
+
start: 0,
|
|
73
|
+
end: 0
|
|
74
|
+
};
|
|
75
|
+
function D(e, p) {
|
|
76
|
+
let { size: m = "md", wrap: g = !1, selected: _ = !1, chevron: w = !1, startActions: D, endActions: O, fullSwipe: k = !1, open: A, defaultOpen: ie = null, onOpenChange: ae, variant: oe, children: se, props: ce, ...le } = e, j = y(null), M = y(null), N = y(null), P = y(null), F = y(!1), [I, L] = c({
|
|
77
|
+
value: A,
|
|
78
|
+
defaultValue: ie,
|
|
79
|
+
onChange: ae
|
|
80
|
+
}), [R, z] = b(null), [B, V] = b(null), [H, U] = b({
|
|
81
|
+
trays: te,
|
|
82
|
+
width: 0,
|
|
83
|
+
rtl: !1
|
|
84
|
+
}), W = l(H), ue = ee((e) => {
|
|
85
|
+
j.current = e, typeof p == "function" ? p(e) : p && (p.current = e);
|
|
86
|
+
}, [p]), G = s(() => {
|
|
87
|
+
let e = (e) => e?.firstElementChild?.offsetWidth ?? 0, n = {
|
|
88
|
+
trays: {
|
|
89
|
+
start: D ? e(M.current) : 0,
|
|
90
|
+
end: O ? e(N.current) : 0
|
|
91
|
+
},
|
|
92
|
+
width: j.current?.offsetWidth ?? 0,
|
|
93
|
+
rtl: t(j.current)
|
|
94
|
+
}, r = W.current;
|
|
95
|
+
return (r.trays.start !== n.trays.start || r.trays.end !== n.trays.end || r.width !== n.width || r.rtl !== n.rtl) && U(n), n;
|
|
96
|
+
});
|
|
97
|
+
a(() => {
|
|
98
|
+
I && G();
|
|
99
|
+
}, [I, G]);
|
|
100
|
+
let K = s((e) => L(null, e));
|
|
101
|
+
v(() => {
|
|
102
|
+
let e = r();
|
|
103
|
+
if (!I || !e) return;
|
|
104
|
+
let t = (e) => {
|
|
105
|
+
i(e, [j]) || K({
|
|
106
|
+
reason: "outside-pointer",
|
|
107
|
+
event: e
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
return e.addEventListener("pointerdown", t, !0), () => e.removeEventListener("pointerdown", t, !0);
|
|
111
|
+
}, [I, K]), v(() => {
|
|
112
|
+
if (!B) return;
|
|
113
|
+
let e = (B === "start" ? M : N).current, t = j.current?.firstElementChild, n = t && typeof getComputedStyle == "function" ? u.activeDuration(getComputedStyle(t)) : 0, r = setTimeout(() => {
|
|
114
|
+
V(null), e?.querySelector("[data-swipe-action]")?.click();
|
|
115
|
+
}, n + u.SETTLE_FRAME);
|
|
116
|
+
return () => clearTimeout(r);
|
|
117
|
+
}, [B]);
|
|
118
|
+
let de = s((e) => {
|
|
119
|
+
if (F.current = !1, e.button !== 0 || B || !D && !O) return;
|
|
120
|
+
let { trays: t } = G();
|
|
121
|
+
P.current = {
|
|
122
|
+
pointerId: e.pointerId,
|
|
123
|
+
x: e.clientX,
|
|
124
|
+
y: e.clientY,
|
|
125
|
+
rest: T.restOffset(I, t),
|
|
126
|
+
intent: null,
|
|
127
|
+
samples: [{
|
|
128
|
+
t: e.timeStamp,
|
|
129
|
+
x: e.clientX
|
|
130
|
+
}]
|
|
131
|
+
};
|
|
132
|
+
}), fe = s((e) => {
|
|
133
|
+
let t = P.current;
|
|
134
|
+
if (!t || t.pointerId !== e.pointerId || t.intent === "scroll") return;
|
|
135
|
+
let r = e.clientX - t.x;
|
|
136
|
+
if (!t.intent) {
|
|
137
|
+
if (t.intent = T.intent(r, e.clientY - t.y), t.intent !== "swipe") return;
|
|
138
|
+
e.currentTarget.setPointerCapture?.(e.pointerId), n(e.currentTarget);
|
|
139
|
+
}
|
|
140
|
+
let { trays: i, width: a, rtl: o } = W.current;
|
|
141
|
+
t.samples = T.track(t.samples, {
|
|
142
|
+
t: e.timeStamp,
|
|
143
|
+
x: e.clientX
|
|
144
|
+
}), z(T.offsetFor(t.rest, o ? -r : r, i, a, k));
|
|
145
|
+
}), q = s((e) => {
|
|
146
|
+
let t = P.current;
|
|
147
|
+
if (!t || t.pointerId !== e.pointerId || (P.current = null, t.intent !== "swipe" || R === null)) return;
|
|
148
|
+
e.currentTarget.releasePointerCapture?.(e.pointerId), F.current = !0;
|
|
149
|
+
let { trays: n, width: r, rtl: i } = W.current, a = T.velocity(t.samples) * (i ? -1 : 1), o = e.type === "pointercancel" ? {
|
|
150
|
+
open: I,
|
|
151
|
+
full: null
|
|
152
|
+
} : T.settle(R, a, n, r, k);
|
|
153
|
+
z(null), o.full ? (V(o.full), L(null, {
|
|
154
|
+
reason: "swipe",
|
|
155
|
+
event: e
|
|
156
|
+
})) : L(o.open, {
|
|
157
|
+
reason: "swipe",
|
|
158
|
+
event: e
|
|
159
|
+
});
|
|
160
|
+
}), pe = s((e) => {
|
|
161
|
+
if (F.current) {
|
|
162
|
+
F.current = !1, e.preventDefault(), e.stopPropagation();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
I && (e.preventDefault(), e.stopPropagation(), K({
|
|
166
|
+
reason: "outside-pointer",
|
|
167
|
+
event: e
|
|
168
|
+
}));
|
|
169
|
+
}), me = s((e) => {
|
|
170
|
+
let t = M.current?.contains(e.target) ? "start" : N.current?.contains(e.target) ? "end" : null;
|
|
171
|
+
t && t !== I && (G(), L(t, {
|
|
172
|
+
reason: "focus",
|
|
173
|
+
event: e
|
|
174
|
+
}));
|
|
175
|
+
}), he = s((e) => {
|
|
176
|
+
let t = e.relatedTarget;
|
|
177
|
+
I && (!t || !j.current?.contains(t)) && K({
|
|
178
|
+
reason: "focus",
|
|
179
|
+
event: e
|
|
180
|
+
});
|
|
181
|
+
}), ge = s((e) => {
|
|
182
|
+
e.key !== "Escape" || !I || e.defaultPrevented || (e.preventDefault(), K({
|
|
183
|
+
reason: "escape",
|
|
184
|
+
event: e
|
|
185
|
+
}), j.current?.querySelector("[data-list-action]")?.focus());
|
|
186
|
+
}), { trays: J, width: Y, rtl: X } = H, Z = R ?? (B ? B === "start" ? Y : -Y : T.restOffset(I, J)), _e = R === null ? B : T.armed(R, J, Y, k), Q = R !== null, $ = (e, t) => /* @__PURE__ */ S(re, {
|
|
187
|
+
side: e,
|
|
188
|
+
trayRef: e === "start" ? M : N,
|
|
189
|
+
width: e === "start" ? Math.max(0, Z) : Math.max(0, -Z),
|
|
190
|
+
dragging: Q,
|
|
191
|
+
children: /* @__PURE__ */ S(E.Provider, {
|
|
192
|
+
value: {
|
|
193
|
+
side: e,
|
|
194
|
+
armed: _e === e,
|
|
195
|
+
close: K
|
|
196
|
+
},
|
|
197
|
+
children: t
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
return o({
|
|
201
|
+
tag: "li",
|
|
202
|
+
component: "list.item",
|
|
203
|
+
...f({
|
|
204
|
+
...h,
|
|
205
|
+
css: {
|
|
206
|
+
...h.css,
|
|
207
|
+
overflow: "clip"
|
|
208
|
+
}
|
|
209
|
+
}, le),
|
|
210
|
+
variant: [oe, { selected: _ }],
|
|
211
|
+
props: {
|
|
212
|
+
...ce,
|
|
213
|
+
onFocus: me,
|
|
214
|
+
onBlur: he,
|
|
215
|
+
onKeyDown: ge
|
|
216
|
+
},
|
|
217
|
+
children: /* @__PURE__ */ C(x, { children: [
|
|
218
|
+
/* @__PURE__ */ C(ne, {
|
|
219
|
+
size: m,
|
|
220
|
+
wrap: g,
|
|
221
|
+
dragging: Q,
|
|
222
|
+
translate: Z === 0 ? void 0 : `${Math.round(X ? -Z : Z)}px`,
|
|
223
|
+
handlers: {
|
|
224
|
+
onPointerDown: de,
|
|
225
|
+
onPointerMove: fe,
|
|
226
|
+
onPointerUp: q,
|
|
227
|
+
onPointerCancel: q,
|
|
228
|
+
onClickCapture: pe,
|
|
229
|
+
onDragStart: (e) => e.preventDefault()
|
|
230
|
+
},
|
|
231
|
+
children: [se, w && /* @__PURE__ */ S(d.Chevron, {})]
|
|
232
|
+
}),
|
|
233
|
+
D ? $("start", D) : null,
|
|
234
|
+
O ? $("end", O) : null
|
|
235
|
+
] })
|
|
236
|
+
}, ue);
|
|
237
|
+
}
|
|
238
|
+
function ne({ size: e, wrap: t, dragging: n, translate: r, handlers: i, children: a }) {
|
|
239
|
+
return o({
|
|
240
|
+
component: "swipeItem.row",
|
|
241
|
+
...p,
|
|
242
|
+
...m[e],
|
|
243
|
+
...t ? { flexWrap: "wrap" } : {},
|
|
244
|
+
position: "relative",
|
|
245
|
+
css: { touchAction: "pan-y" },
|
|
246
|
+
variant: { dragging: n },
|
|
247
|
+
style: r ? { translate: r } : void 0,
|
|
248
|
+
props: i,
|
|
249
|
+
children: a
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function re({ side: e, trayRef: t, width: n, dragging: r, children: i }) {
|
|
253
|
+
let a = o({
|
|
254
|
+
display: "flex",
|
|
255
|
+
d: e === "end" ? "row-reverse" : "row",
|
|
256
|
+
position: "absolute",
|
|
257
|
+
top: 0,
|
|
258
|
+
bottom: 0,
|
|
259
|
+
...e === "start" ? { insetStart: 0 } : { insetEnd: 0 },
|
|
260
|
+
minWidth: "fit",
|
|
261
|
+
css: { width: "max-content" },
|
|
262
|
+
children: i
|
|
263
|
+
});
|
|
264
|
+
return o({
|
|
265
|
+
component: "swipeItem.tray",
|
|
266
|
+
position: "absolute",
|
|
267
|
+
top: 0,
|
|
268
|
+
bottom: 0,
|
|
269
|
+
...e === "start" ? { insetStart: 0 } : { insetEnd: 0 },
|
|
270
|
+
overflow: "hidden",
|
|
271
|
+
variant: { dragging: r },
|
|
272
|
+
style: { width: `${Math.round(n)}px` },
|
|
273
|
+
children: a
|
|
274
|
+
}, t);
|
|
275
|
+
}
|
|
276
|
+
function O(e, t) {
|
|
277
|
+
let { icon: n, onClick: r, closeOnSelect: i = !0, variant: a, children: s, props: c, ...l } = e, u = _(E), d = (e) => {
|
|
278
|
+
r?.(e), i && !e.defaultPrevented && u?.close({
|
|
279
|
+
reason: "action",
|
|
280
|
+
event: e
|
|
281
|
+
});
|
|
282
|
+
};
|
|
283
|
+
return o({
|
|
284
|
+
tag: "button",
|
|
285
|
+
component: "swipeItem.action",
|
|
286
|
+
display: "flex",
|
|
287
|
+
d: "column",
|
|
288
|
+
ai: "center",
|
|
289
|
+
jc: "center",
|
|
290
|
+
gap: 1,
|
|
291
|
+
px: 4,
|
|
292
|
+
minWidth: 18,
|
|
293
|
+
flexGrow: 1,
|
|
294
|
+
flexShrink: 0,
|
|
295
|
+
fontSize: 14,
|
|
296
|
+
lineHeight: 18,
|
|
297
|
+
fontWeight: 500,
|
|
298
|
+
cursor: "pointer",
|
|
299
|
+
...l,
|
|
300
|
+
variant: [a, { armed: u?.armed ?? !1 }],
|
|
301
|
+
props: {
|
|
302
|
+
type: "button",
|
|
303
|
+
"data-swipe-action": "",
|
|
304
|
+
...c,
|
|
305
|
+
onClick: d
|
|
306
|
+
},
|
|
307
|
+
children: n ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(k, { children: n }), s] }) : s
|
|
308
|
+
}, t);
|
|
309
|
+
}
|
|
310
|
+
function k({ children: e }) {
|
|
311
|
+
return o({
|
|
312
|
+
tag: "span",
|
|
313
|
+
display: "flex",
|
|
314
|
+
props: { "aria-hidden": !0 },
|
|
315
|
+
children: e
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
var A = e(D, "SwipeItem");
|
|
319
|
+
A.Action = e(O, "SwipeItem.Action");
|
|
320
|
+
//#endregion
|
|
321
|
+
export { T as SwipeUtils, A as default };
|
package/components/tabs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../effects.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.TAB_SELECTOR=`[role="tab"]`,n=e.LIST_SELECTOR=`[role="tablist"]`,r=e.PANEL_SELECTOR=`[role="tabpanel"]`;function i(e,t){return t instanceof Element&&t.closest(n)===e}e.owns=i;function a(e){return e?[...e.querySelectorAll(t)].filter(t=>i(e,t)):[]}e.tabs=a;function o(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=o;function s(e){return e.dataset.value}e.valueOf=s;function c(e){return e.replace(/[^A-Za-z0-9-]/g,e=>`_${e.codePointAt(0).toString(36)}_`)}e.token=c;function l(e,t,n,r){let i=e.length;if(i===0)return;let a=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(a+=n,a<0||a>=i){if(!r)return;a=(a%i+i)%i}if(!o(e[a]))return e[a]}}e.step=l;function u(e,t){return l(e,t===1?-1:e.length,t,!1)}e.edge=u;function d(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=d;function f(e,t,n=!1){if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1};let r=t===`vertical`,i=r?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`,a=r?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`;if(e===i)return{kind:`step`,delta:1};if(e===a)return{kind:`step`,delta:-1}}e.moveFor=f;function p(e,t,n,r){return n.kind===`edge`?u(e,n.delta):l(e,t,n.delta,r)}e.target=p;function m(e){if(e)return a(e).find(e=>e.getAttribute(`aria-selected`)===`true`)}e.selectedTab=m;function h(e,t,n){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();return n===`vertical`?{start:i.top-r.top+e.scrollTop,size:i.height}:{start:i.left-r.left+e.scrollLeft,size:i.width}}e.bounds=h;function g(e,t){return!e||!t?e===t:e.start===t.start&&e.size===t.size}e.sameBounds=g;function _(e){if(e)return[...e.querySelectorAll(r)].find(e=>!e.hasAttribute(`hidden`))}e.visiblePanel=_})(c||={});var l=c,u=(0,o.createContext)(null);function d(e){let t=(0,o.useContext)(u);if(!t)throw Error(`<${e}> has to be rendered inside a <Tabs>.`);return t}function f(e){let{children:a,value:c,defaultValue:d,onValueChange:f,orientation:p=`horizontal`,activation:m=`automatic`,loop:h=!0,keepMounted:g=!1,indicator:_=`static`,props:v,...y}=e,b=i.t(`tabs`),[x,S]=r.i({value:c,defaultValue:d,onChange:f}),[C,w]=(0,o.useState)(),[T,E]=(0,o.useState)(!1);t.n(()=>{x!==void 0&&w(x)},[x]);let D=(0,o.useMemo)(()=>({identifier:b,value:x,orientation:p,activation:m,loop:h,keepMounted:g,indicator:_,indicatorLive:T,setIndicatorLive:E,tabStop:C??x,setTabStop:w,select:S,tabId:e=>`${b}-tab-${l.token(e)}`,panelId:e=>`${b}-panel-${l.token(e)}`}),[b,x,p,m,h,g,_,T,C,S]);return(0,s.jsx)(u.Provider,{value:D,children:(0,s.jsx)(n.default,{component:`tabs`,...y,variant:[y.variant,{vertical:p===`vertical`}],props:v,children:a})})}function p(i){let{children:a,label:c,labelledBy:u,props:f,...p}=i,{value:m,orientation:h,activation:g,loop:_,indicator:v,tabStop:y,setTabStop:b,setIndicatorLive:x,select:S}=d(`Tabs.List`),C=(0,o.useRef)(null),[w,T]=(0,o.useState)(),E=v===`sliding`;t.n(()=>{let e=C.current;if(!E||!e)return;let t=()=>{let t=l.selectedTab(e),n=t&&l.bounds(e,t,h);T(e=>l.sameBounds(e,n)?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of l.tabs(e))n.observe(t);return()=>n.disconnect()},[E,h,m]);let D=E&&w&&w.size>0?w:void 0;t.n(()=>{x(D!==void 0)},[D,x]),t.n(()=>{if(y!==void 0)return;let e=l.edge(l.tabs(C.current),1),t=e&&l.valueOf(e);t!==void 0&&b(t)},[y,b]);let O=r.a(t=>{let n=C.current;if(!n||t.defaultPrevented||!l.owns(n,t.target))return;let r=l.tabs(n),i=l.indexOf(r,t.target);if(i===-1)return;if(g===`manual`&&(t.key===`Enter`||t.key===` `)){let e=l.valueOf(r[i]);if(e===void 0)return;t.preventDefault(),S(e,{reason:`keyboard`,event:t});return}let a=l.moveFor(t.key,h,e.
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../platform.cjs"),t=require("../effects.cjs"),n=require("../box.cjs"),r=require("../behavior.cjs"),i=require("../identity.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime");var c;(function(e){let t=e.TAB_SELECTOR=`[role="tab"]`,n=e.LIST_SELECTOR=`[role="tablist"]`,r=e.PANEL_SELECTOR=`[role="tabpanel"]`;function i(e,t){return t instanceof Element&&t.closest(n)===e}e.owns=i;function a(e){return e?[...e.querySelectorAll(t)].filter(t=>i(e,t)):[]}e.tabs=a;function o(e){return e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}e.isDisabled=o;function s(e){return e.dataset.value}e.valueOf=s;function c(e){return e.replace(/[^A-Za-z0-9-]/g,e=>`_${e.codePointAt(0).toString(36)}_`)}e.token=c;function l(e,t,n,r){let i=e.length;if(i===0)return;let a=t<0||t>=i?n>0?-1:i:t;for(let t=0;t<i;t++){if(a+=n,a<0||a>=i){if(!r)return;a=(a%i+i)%i}if(!o(e[a]))return e[a]}}e.step=l;function u(e,t){return l(e,t===1?-1:e.length,t,!1)}e.edge=u;function d(e,t){return t instanceof HTMLElement?e.indexOf(t):-1}e.indexOf=d;function f(e,t,n=!1){if(e===`Home`)return{kind:`edge`,delta:1};if(e===`End`)return{kind:`edge`,delta:-1};let r=t===`vertical`,i=r?`ArrowDown`:n?`ArrowLeft`:`ArrowRight`,a=r?`ArrowUp`:n?`ArrowRight`:`ArrowLeft`;if(e===i)return{kind:`step`,delta:1};if(e===a)return{kind:`step`,delta:-1}}e.moveFor=f;function p(e,t,n,r){return n.kind===`edge`?u(e,n.delta):l(e,t,n.delta,r)}e.target=p;function m(e){if(e)return a(e).find(e=>e.getAttribute(`aria-selected`)===`true`)}e.selectedTab=m;function h(e,t,n){let r=e.getBoundingClientRect(),i=t.getBoundingClientRect();return n===`vertical`?{start:i.top-r.top+e.scrollTop,size:i.height}:{start:i.left-r.left+e.scrollLeft,size:i.width}}e.bounds=h;function g(e,t){return!e||!t?e===t:e.start===t.start&&e.size===t.size}e.sameBounds=g;function _(e){if(e)return[...e.querySelectorAll(r)].find(e=>!e.hasAttribute(`hidden`))}e.visiblePanel=_})(c||={});var l=c,u=(0,o.createContext)(null);function d(e){let t=(0,o.useContext)(u);if(!t)throw Error(`<${e}> has to be rendered inside a <Tabs>.`);return t}function f(e){let{children:a,value:c,defaultValue:d,onValueChange:f,orientation:p=`horizontal`,activation:m=`automatic`,loop:h=!0,keepMounted:g=!1,indicator:_=`static`,props:v,...y}=e,b=i.t(`tabs`),[x,S]=r.i({value:c,defaultValue:d,onChange:f}),[C,w]=(0,o.useState)(),[T,E]=(0,o.useState)(!1);t.n(()=>{x!==void 0&&w(x)},[x]);let D=(0,o.useMemo)(()=>({identifier:b,value:x,orientation:p,activation:m,loop:h,keepMounted:g,indicator:_,indicatorLive:T,setIndicatorLive:E,tabStop:C??x,setTabStop:w,select:S,tabId:e=>`${b}-tab-${l.token(e)}`,panelId:e=>`${b}-panel-${l.token(e)}`}),[b,x,p,m,h,g,_,T,C,S]);return(0,s.jsx)(u.Provider,{value:D,children:(0,s.jsx)(n.default,{component:`tabs`,...y,variant:[y.variant,{vertical:p===`vertical`}],props:v,children:a})})}function p(i){let{children:a,label:c,labelledBy:u,props:f,...p}=i,{value:m,orientation:h,activation:g,loop:_,indicator:v,tabStop:y,setTabStop:b,setIndicatorLive:x,select:S}=d(`Tabs.List`),C=(0,o.useRef)(null),[w,T]=(0,o.useState)(),E=v===`sliding`;t.n(()=>{let e=C.current;if(!E||!e)return;let t=()=>{let t=l.selectedTab(e),n=t&&l.bounds(e,t,h);T(e=>l.sameBounds(e,n)?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e);for(let t of l.tabs(e))n.observe(t);return()=>n.disconnect()},[E,h,m]);let D=E&&w&&w.size>0?w:void 0;t.n(()=>{x(D!==void 0)},[D,x]),t.n(()=>{if(y!==void 0)return;let e=l.edge(l.tabs(C.current),1),t=e&&l.valueOf(e);t!==void 0&&b(t)},[y,b]);let O=r.a(t=>{let n=C.current;if(!n||t.defaultPrevented||!l.owns(n,t.target))return;let r=l.tabs(n),i=l.indexOf(r,t.target);if(i===-1)return;if(g===`manual`&&(t.key===`Enter`||t.key===` `)){let e=l.valueOf(r[i]);if(e===void 0)return;t.preventDefault(),S(e,{reason:`keyboard`,event:t});return}let a=l.moveFor(t.key,h,e.d(n));if(!a)return;let o=l.target(r,i,a,_);if(!o)return;t.preventDefault(),o.focus();let s=l.valueOf(o);g===`automatic`&&s!==void 0&&S(s,{reason:`keyboard`,event:t})});return(0,s.jsxs)(n.default,{ref:C,component:`tabs.list`,...p,variant:[p.variant,{vertical:h===`vertical`,sliding:E}],props:{role:`tablist`,"aria-label":c,"aria-labelledby":u,"aria-orientation":h,...f,onKeyDown:O},children:[a,D&&(0,s.jsx)(n.default,{tag:`span`,component:`tabs.indicator`,variant:{vertical:h===`vertical`},style:h===`vertical`?{top:`${D.start}px`,height:`${D.size}px`}:{left:`${D.start}px`,width:`${D.size}px`},props:{"aria-hidden":!0}})]})}p.displayName=`Tabs.List`;function m(e){let{value:t,children:i,disabled:a,props:o,...c}=e,{value:l,orientation:u,keepMounted:f,indicatorLive:p,tabStop:m,setTabStop:h,select:g,tabId:_,panelId:v}=d(`Tabs.Tab`),y=l===t,b=r.a(e=>g(t,{reason:`click`,event:e})),x=r.a(()=>h(t));return(0,s.jsx)(n.default,{tag:`button`,component:`tabs.tab`,...c,variant:[c.variant,{vertical:u===`vertical`,underline:!p}],disabled:a,id:_(t),props:{type:`button`,role:`tab`,"aria-selected":y,"aria-controls":y||f?v(t):void 0,tabIndex:m===t?0:-1,"data-value":t,...o,onClick:b,onFocus:x},children:i})}m.displayName=`Tabs.Tab`;function h(e){let{children:i,props:c,...u}=e,{value:f}=d(`Tabs.Panels`),p=(0,o.useRef)(null),[m,h]=(0,o.useState)(),[g,_]=(0,o.useState)(!1),v=r.a(()=>{let e=p.current;if(!e)return;let t=l.visiblePanel(e)?.offsetHeight;t!==m&&(m!==void 0&&t!==void 0&&_(!0),h(t))});return t.n(()=>{let e=p.current;if(!e||(v(),typeof ResizeObserver>`u`))return;let t=l.visiblePanel(e);if(!t)return;let n=new ResizeObserver(v);return n.observe(t),()=>n.disconnect()},[f,v]),t.n(()=>{let e=p.current;if(!e||!g)return;let t=setTimeout(()=>_(!1),a.n.activeDuration(getComputedStyle(e))+a.n.SETTLE_FRAME);return()=>clearTimeout(t)},[g,m]),(0,s.jsx)(n.default,{ref:p,component:`tabs.panels`,...u,variant:[u.variant,{resizing:g}],style:{height:m===void 0?void 0:`${m}px`,...u.style},props:c,children:i})}h.displayName=`Tabs.Panels`;function g(e){let{value:t,children:r,props:i,...a}=e,{value:o,keepMounted:c,tabId:l,panelId:u}=d(`Tabs.Panel`),f=o===t;return!f&&!c?null:(0,s.jsx)(n.default,{component:`tabs.panel`,...a,variant:[a.variant,{hidden:!f}],id:u(t),props:{role:`tabpanel`,"aria-labelledby":l(t),hidden:!f||void 0,tabIndex:0,...i},children:r})}g.displayName=`Tabs.Panel`;var _=f;_.List=p,_.Tab=m,_.Panels=h,_.Panel=g,_.displayName=`Tabs`,exports.default=_;
|
package/components/tabs.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../box.cjs"),t=require("../behavior.cjs"),n=require("../dates.cjs"),r=require("../date-environment.cjs"),i=require("./combobox.cjs");let a=require("react"),o=require("react/jsx-runtime");function s(e=n.M(),t=Date.now()){return e.map(e=>{let r=e===`UTC`?0:n.A(e,t),i=e.split(`/`),a=i[i.length-1].replace(/_/g,` `),o=`UTC${r===0?``:n.D(r)}`;return{id:e,city:a,region:i.length>1?i.slice(0,-1).join(`/`).replace(/_/g,` `):``,offset:r,offsetText:o,label:`${a} (${o})`}}).sort((e,t)=>e.offset-t.offset||e.city.localeCompare(t.city))}function c(e,t){let n=t.trim().toLowerCase().replace(/\s+/g,` `);if(!n)return!0;let r=e.offsetText.replace(/:00$/,``).replace(/([+-])0/,`$1`);return`${e.id} ${e.city} ${e.region} ${e.offsetText} ${r} gmt${e.offsetText.slice(3)}`.toLowerCase().replace(/_/g,` `).includes(n)}function l(l){let{value:u,defaultValue:d,onValueChange:f,zones:p,label:m,placeholder:h,name:g,disabled:_,props:v,emptyText:y=`No time zone matches`,...b}=l,x=r.n(),S=(0,a.useMemo)(()=>s(p),[p]),C=(0,a.useMemo)(()=>new Map(S.map(e=>[e.id,e])),[S]),[w,T]=t.i({value:u===void 0?void 0:u&&(n.k(u)??u),defaultValue:d===void 0?x.readerZone:d,onChange:f});return(0,o.jsx)(i.default,{...b,data:S,def:{label:`label`,key:`id`,display:t=>(0,o.jsxs)(e.default,{display:`flex`,jc:`space-between`,gap:4,width:`fit`,children:[(0,o.jsx)(e.default,{tag:`span`,children:t.city}),(0,o.jsxs)(e.default,{tag:`span`,opacity:.7,fontSize:12,css:{fontVariantNumeric:`tabular-nums`},children:[t.region?`${t.region} · `:``,t.offsetText]})]})},value:(w?C.get(w):void 0)??null,onValueChange:(e,t)=>T(e?.id??null,t),filter:(e,t)=>e.filter(e=>c(e,t)),label:m,placeholder:h,name:g,disabled:_,emptyText:y,props:v})}var u=l;u.displayName=`TimeZoneSelect`,exports.default=u;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { BoxProps } from '../box';
|
|
2
|
+
import { ChangeHandler } from '../react/a11y/useControllableState';
|
|
3
|
+
import { ZoneOption } from '../utils/date/zoneOptions';
|
|
4
|
+
import { ComboboxValueReason } from './combobox';
|
|
5
|
+
export type { ZoneOption };
|
|
6
|
+
type TimeZoneSelectBoxProps = Omit<BoxProps<'div', 'combobox'>, 'ref' | 'tag' | 'children' | 'defaultValue' | 'onChange' | 'disabled' | 'placeholder' | 'open' | 'props'>;
|
|
7
|
+
export interface TimeZoneSelectProps extends TimeZoneSelectBoxProps {
|
|
8
|
+
/** The chosen IANA zone (`Europe/Chisinau`, `UTC`), or `null`. Controlled. */
|
|
9
|
+
value?: string | null;
|
|
10
|
+
/** The zone it starts with when it owns its state. Default the reader's own. */
|
|
11
|
+
defaultValue?: string | null;
|
|
12
|
+
/** Fires with the zone's IANA name. */
|
|
13
|
+
onValueChange?: ChangeHandler<string | null, ComboboxValueReason>;
|
|
14
|
+
/** Only these zones, in IANA names. Default every zone the runtime knows, UTC first. */
|
|
15
|
+
zones?: readonly string[];
|
|
16
|
+
/** The select's visible name. */
|
|
17
|
+
label?: React.ReactNode;
|
|
18
|
+
/** The field's placeholder. Not a name — it is gone on the first keystroke. */
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** What the zone posts under in a form. */
|
|
21
|
+
name?: string;
|
|
22
|
+
/** Not editable and not openable, but still read out. */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Attributes for the `<input>` itself — an `aria-label`, an `id`. */
|
|
25
|
+
props?: Record<string, unknown>;
|
|
26
|
+
/** What the list says when nothing matches. Default `'No time zone matches'`. */
|
|
27
|
+
emptyText?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Picks a time zone by place, region or offset — `chis`, `europe` and `+3` all find Chisinau — out of every zone
|
|
31
|
+
* the runtime knows, each with the offset it is at now.
|
|
32
|
+
*
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const [zone, setZone] = useState('Europe/Chisinau');
|
|
35
|
+
* <TimeZoneSelect label="Time zone" value={zone} onValueChange={setZone} />
|
|
36
|
+
* <DateField type="datetime" zone={zone} label="Meeting" />
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* It is a `Combobox` over the runtime's own list (`Intl.supportedValuesOf('timeZone')`), so it ships no zone
|
|
40
|
+
* database, and the value is the IANA name every date component and every server takes.
|
|
41
|
+
*
|
|
42
|
+
* @pattern https://www.w3.org/WAI/ARIA/apg/patterns/combobox/
|
|
43
|
+
* @a11y The APG editable combobox: `role="combobox"` on the field, a `role="listbox"` of options, the active one
|
|
44
|
+
* named by `aria-activedescendant`. A thousand-odd options are windowed, so it opens in one frame.
|
|
45
|
+
* @keyboard A printable character — Searches by place, region, IANA name or offset.
|
|
46
|
+
* @keyboard Down / Up — Opens, or moves through what the search left.
|
|
47
|
+
* @keyboard Enter — Chooses the highlighted zone.
|
|
48
|
+
* @keyboard Escape — Closes the list, then clears what was typed.
|
|
49
|
+
*/
|
|
50
|
+
declare function TimeZoneSelectImpl(props: TimeZoneSelectProps): import("react").JSX.Element;
|
|
51
|
+
declare const TimeZoneSelect: typeof TimeZoneSelectImpl;
|
|
52
|
+
export default TimeZoneSelect;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "../box.mjs";
|
|
3
|
+
import { i as t } from "../behavior.mjs";
|
|
4
|
+
import { A as n, D as r, M as i, k as a } from "../dates.mjs";
|
|
5
|
+
import { n as o } from "../date-environment.mjs";
|
|
6
|
+
import s from "./combobox.mjs";
|
|
7
|
+
import { useMemo as c } from "react";
|
|
8
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
9
|
+
//#region src/utils/date/zoneOptions.ts
|
|
10
|
+
function d(e = i(), t = Date.now()) {
|
|
11
|
+
return e.map((e) => {
|
|
12
|
+
let i = e === "UTC" ? 0 : n(e, t), a = e.split("/"), o = a[a.length - 1].replace(/_/g, " "), s = `UTC${i === 0 ? "" : r(i)}`;
|
|
13
|
+
return {
|
|
14
|
+
id: e,
|
|
15
|
+
city: o,
|
|
16
|
+
region: a.length > 1 ? a.slice(0, -1).join("/").replace(/_/g, " ") : "",
|
|
17
|
+
offset: i,
|
|
18
|
+
offsetText: s,
|
|
19
|
+
label: `${o} (${s})`
|
|
20
|
+
};
|
|
21
|
+
}).sort((e, t) => e.offset - t.offset || e.city.localeCompare(t.city));
|
|
22
|
+
}
|
|
23
|
+
function f(e, t) {
|
|
24
|
+
let n = t.trim().toLowerCase().replace(/\s+/g, " ");
|
|
25
|
+
if (!n) return !0;
|
|
26
|
+
let r = e.offsetText.replace(/:00$/, "").replace(/([+-])0/, "$1");
|
|
27
|
+
return `${e.id} ${e.city} ${e.region} ${e.offsetText} ${r} gmt${e.offsetText.slice(3)}`.toLowerCase().replace(/_/g, " ").includes(n);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/timeZoneSelect.tsx
|
|
31
|
+
function p(n) {
|
|
32
|
+
let { value: r, defaultValue: i, onValueChange: p, zones: m, label: h, placeholder: g, name: _, disabled: v, props: y, emptyText: b = "No time zone matches", ...x } = n, S = o(), C = c(() => d(m), [m]), w = c(() => new Map(C.map((e) => [e.id, e])), [C]), [T, E] = t({
|
|
33
|
+
value: r === void 0 ? void 0 : r && (a(r) ?? r),
|
|
34
|
+
defaultValue: i === void 0 ? S.readerZone : i,
|
|
35
|
+
onChange: p
|
|
36
|
+
});
|
|
37
|
+
return /* @__PURE__ */ l(s, {
|
|
38
|
+
...x,
|
|
39
|
+
data: C,
|
|
40
|
+
def: {
|
|
41
|
+
label: "label",
|
|
42
|
+
key: "id",
|
|
43
|
+
display: (t) => /* @__PURE__ */ u(e, {
|
|
44
|
+
display: "flex",
|
|
45
|
+
jc: "space-between",
|
|
46
|
+
gap: 4,
|
|
47
|
+
width: "fit",
|
|
48
|
+
children: [/* @__PURE__ */ l(e, {
|
|
49
|
+
tag: "span",
|
|
50
|
+
children: t.city
|
|
51
|
+
}), /* @__PURE__ */ u(e, {
|
|
52
|
+
tag: "span",
|
|
53
|
+
opacity: .7,
|
|
54
|
+
fontSize: 12,
|
|
55
|
+
css: { fontVariantNumeric: "tabular-nums" },
|
|
56
|
+
children: [t.region ? `${t.region} · ` : "", t.offsetText]
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
},
|
|
60
|
+
value: (T ? w.get(T) : void 0) ?? null,
|
|
61
|
+
onValueChange: (e, t) => E(e?.id ?? null, t),
|
|
62
|
+
filter: (e, t) => e.filter((e) => f(e, t)),
|
|
63
|
+
label: h,
|
|
64
|
+
placeholder: g,
|
|
65
|
+
name: _,
|
|
66
|
+
disabled: v,
|
|
67
|
+
emptyText: b,
|
|
68
|
+
props: y
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
var m = p;
|
|
72
|
+
m.displayName = "TimeZoneSelect";
|
|
73
|
+
//#endregion
|
|
74
|
+
export { m as default };
|
package/components/toaster.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../
|
|
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("../layer.cjs"),a=require("../motion.cjs");let o=require("react"),s=require("react/jsx-runtime"),c=require("react-dom"),l=require("use-sync-external-store/shim");var u={toasts:[],overflow:0},d=0;function f(){return d+=1,`toast-${d}`}function p(e){let t=[],n=u,r=e?.limit??3,i=e?.duration??5e3,a=!1,o=new Set,s=new Map,c=e=>{let t=s.get(e);t?.handle&&clearTimeout(t.handle),s.delete(e)},l=()=>{let e=0;t=t.map(t=>{let n=!t.open||e++<r;return t.visible===n?t:{...t,visible:n}}),n={toasts:t,overflow:Math.max(0,e-r)},d(),o.forEach(e=>e())};function d(){let e=new Set;for(let n of t){if(!n.open||!n.visible||!Number.isFinite(n.duration))continue;e.add(n.id);let t=s.get(n.id)??{handle:null,remaining:n.duration,startedAt:0};s.set(n.id,t),!(a||t.handle)&&(t.startedAt=Date.now(),t.handle=setTimeout(()=>{s.delete(n.id),m(n.id,`timeout`)},t.remaining))}for(let t of[...s.keys()])e.has(t)||c(t)}let p=(e,t)=>t??(e===`loading`?1/0:i);function m(e,n=`imperative`){let r=[];t=t.map(t=>!t.open||e!==void 0&&t.id!==e?t:(r.push(t),c(t.id),{...t,open:!1})),r.length&&(l(),r.forEach(e=>e.onDismiss?.(n)))}function h(e,n,r){let i=!1;t=t.map(t=>{if(t.id!==e)return t;i=!0,c(e);let a=r?.kind??t.kind;return{...t,...r,id:e,message:n,kind:a,duration:r?.duration??(r?.kind?p(a):t.duration),open:!0}}),i&&l()}function g(e,n){let r=n?.id??f();if(n?.id&&t.some(e=>e.id===r))return h(r,e,n),r;let i=n?.kind??`default`;return t=[...t,{id:r,kind:i,message:e,description:n?.description,duration:p(i,n?.duration),action:n?.action,dismissible:n?.dismissible??!0,onDismiss:n?.onDismiss,open:!0,visible:!1}],l(),r}return{subscribe(e){return o.add(e),()=>o.delete(e)},getSnapshot:()=>n,getServerSnapshot:()=>u,add:g,update:h,dismiss:m,remove(e){let n=t.filter(t=>t.id!==e);n.length!==t.length&&(c(e),t=n,l())},setLimit(e){e!==r&&(r=e,l())},setDefaultDuration(e){i=e},pause(){if(!a){a=!0;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)))}},resume(){a&&(a=!1,d())},reset(){for(let e of[...s.keys()])c(e);t=[],n=u,o.forEach(e=>e())}}}var m=p(),h=e=>(t,n)=>m.add(t,{...n,kind:e}),g=Object.assign((e,t)=>m.add(e,t),{success:h(`success`),error:h(`error`),warning:h(`warning`),info:h(`info`),loading:h(`loading`),update:(e,t,n)=>m.update(e,t,n),dismiss:e=>m.dismiss(e,`imperative`),promise(e,t,n){let r=m.add(t.loading,{...n,id:n?.id,kind:`loading`}),i=(e,t)=>typeof e==`function`?e(t):e;return e.then(e=>m.update(r,i(t.success,e),{kind:`success`}),e=>m.update(r,i(t.error,e),{kind:`error`})),e}}),_={"top-start":`topStart`,"top-center":`topCenter`,"top-end":`topEnd`,"bottom-start":`bottomStart`,"bottom-center":`bottomCenter`,"bottom-end":`bottomEnd`};function v(e,t){let n=t.toLowerCase().split(`+`),r=n[n.length-1],i=new Set(n.slice(0,-1));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`)}function y(e){let{toast:t,store:i,fromTop:o,closeLabel:c}=e,{mounted:l,ref:u,props:d}=a.t({present:t.open});if(n.n(()=>{l||i.remove(t.id)},[l,i,t.id]),!l)return null;let f=t.action,p=()=>{f?.onClick(),f?.closeOnClick!==!1&&i.dismiss(t.id,`action`)};return(0,s.jsxs)(r.default,{ref:u,component:`toaster.toast`,variant:{[t.kind]:t.kind!=="default",fromTop:o},props:{...t.kind===`error`?{role:`alert`}:{},"data-toast-id":t.id,...d},children:[(0,s.jsx)(r.default,{component:`toaster.message`,children:t.message}),t.description!==void 0&&(0,s.jsx)(r.default,{component:`toaster.description`,children:t.description}),f&&(0,s.jsx)(r.default,{tag:`button`,component:`toaster.action`,props:{type:`button`,onClick:p},children:f.label}),t.dismissible&&(0,s.jsx)(r.default,{tag:`button`,component:`toaster.close`,props:{type:`button`,"aria-label":c,onClick:()=>i.dismiss(t.id,`close`)}})]})}function b(a){let{position:u=`bottom-end`,limit:d=3,duration:f=5e3,label:p=`Notifications`,closeLabel:h=`Close`,overflowLabel:g=e=>`+${e} more`,hotkey:b=`F6`,store:x=m,props:S,...C}=a,w=(0,l.useSyncExternalStore)(x.subscribe,x.getSnapshot,x.getServerSnapshot),T=i.n(),E=e.t(!T),D=(0,o.useRef)(null),O=(0,o.useRef)(null),k=(0,o.useRef)({hovered:!1,focused:!1,hidden:!1}),A=(0,o.useCallback)(()=>{let{hovered:e,focused:t,hidden:n}=k.current;e||t||n?x.pause():x.resume()},[x]);n.n(()=>x.setLimit(d),[x,d]),n.n(()=>x.setDefaultDuration(f),[x,f]),n.n(()=>{let e=D.current;!T||!t.o()||!e||!e.isConnected||e.matches(`:popover-open`)||e.showPopover()}),n.n(()=>{let e=t.t();if(!e)return;let n=new AbortController;return e.addEventListener(`visibilitychange`,()=>{k.current.hidden=e.hidden,A()},{signal:n.signal}),()=>n.abort()},[A]),n.n(()=>{let e=t.t();if(!b||!e)return;let n=new AbortController;return e.addEventListener(`keydown`,t=>{!v(t,b)||!D.current||(t.preventDefault(),O.current=e.activeElement,D.current.focus())},{signal:n.signal}),()=>n.abort()},[b]);let j=e=>!!e&&!!D.current?.contains(e),M=()=>{k.current.hovered=!0,A()},N=e=>{j(e.relatedTarget)||(k.current.hovered=!1,A())},P=e=>{k.current.focused=!0,A(),j(e.relatedTarget)||(O.current=e.relatedTarget)},F=e=>{j(e.relatedTarget)||(k.current.focused=!1,A())},I=e=>{if(e.key!==`Escape`)return;let t=(e.target.closest?.(`[data-toast-id]`))?.getAttribute(`data-toast-id`);t&&x.dismiss(t,`close`),x.getSnapshot().toasts.some(e=>e.open)?D.current?.focus():O.current?.focus()},L=u.startsWith(`top`),R=w.toasts.filter(e=>e.visible),z=L?[...R].reverse():R,B=w.overflow>0&&(0,s.jsx)(r.default,{component:`toaster.overflow`,children:g(w.overflow)}),V=(0,s.jsxs)(r.default,{tag:`section`,ref:D,component:`toaster`,...C,variant:[C.variant,{[_[u]]:!0}],props:{...T?{popover:`manual`}:{},"aria-live":`polite`,"aria-atomic":`false`,"aria-relevant":`additions text`,"aria-label":p,tabIndex:-1,...S,onPointerOver:M,onPointerOut:N,onFocus:P,onBlur:F,onKeyDown:I},children:[!L&&B,z.map(e=>(0,s.jsx)(y,{toast:e,store:x,fromTop:L,closeLabel:h},e.id)),L&&B]});return T?V:E?(0,c.createPortal)(V,E):null}var x=b;x.displayName=`Toaster`,exports.createToastStore=p,exports.default=x,exports.defaultToastStore=m,exports.toast=g;
|
package/components/toaster.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { t as n } from "../
|
|
2
|
+
import { t as e } from "../client.mjs";
|
|
3
|
+
import { o as t, t as n } from "../platform.mjs";
|
|
4
4
|
import { n as r } from "../effects.mjs";
|
|
5
5
|
import i from "../box.mjs";
|
|
6
6
|
import { n as a } from "../layer.mjs";
|
|
7
7
|
import { t as o } from "../motion.mjs";
|
|
8
8
|
import { useCallback as s, useRef as c } from "react";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
import { createPortal as d } from "react-dom";
|
|
11
11
|
import { useSyncExternalStore as f } from "use-sync-external-store/shim";
|
|
12
12
|
//#region src/utils/toast/toastStore.ts
|
|
13
13
|
var p = {
|
|
@@ -160,7 +160,7 @@ function x(e, t) {
|
|
|
160
160
|
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
161
|
}
|
|
162
162
|
function S(e) {
|
|
163
|
-
let { toast: t, store: n, fromTop: a, closeLabel: s } = e, { mounted: c, ref:
|
|
163
|
+
let { toast: t, store: n, fromTop: a, closeLabel: s } = e, { mounted: c, ref: d, props: f } = o({ present: t.open });
|
|
164
164
|
if (r(() => {
|
|
165
165
|
c || n.remove(t.id);
|
|
166
166
|
}, [
|
|
@@ -171,8 +171,8 @@ function S(e) {
|
|
|
171
171
|
let p = t.action, m = () => {
|
|
172
172
|
p?.onClick(), p?.closeOnClick !== !1 && n.dismiss(t.id, "action");
|
|
173
173
|
};
|
|
174
|
-
return /* @__PURE__ */
|
|
175
|
-
ref:
|
|
174
|
+
return /* @__PURE__ */ u(i, {
|
|
175
|
+
ref: d,
|
|
176
176
|
component: "toaster.toast",
|
|
177
177
|
variant: {
|
|
178
178
|
[t.kind]: t.kind !== "default",
|
|
@@ -184,15 +184,15 @@ function S(e) {
|
|
|
184
184
|
...f
|
|
185
185
|
},
|
|
186
186
|
children: [
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ l(i, {
|
|
188
188
|
component: "toaster.message",
|
|
189
189
|
children: t.message
|
|
190
190
|
}),
|
|
191
|
-
t.description !== void 0 && /* @__PURE__ */
|
|
191
|
+
t.description !== void 0 && /* @__PURE__ */ l(i, {
|
|
192
192
|
component: "toaster.description",
|
|
193
193
|
children: t.description
|
|
194
194
|
}),
|
|
195
|
-
p && /* @__PURE__ */
|
|
195
|
+
p && /* @__PURE__ */ l(i, {
|
|
196
196
|
tag: "button",
|
|
197
197
|
component: "toaster.action",
|
|
198
198
|
props: {
|
|
@@ -201,7 +201,7 @@ function S(e) {
|
|
|
201
201
|
},
|
|
202
202
|
children: p.label
|
|
203
203
|
}),
|
|
204
|
-
t.dismissible && /* @__PURE__ */
|
|
204
|
+
t.dismissible && /* @__PURE__ */ l(i, {
|
|
205
205
|
tag: "button",
|
|
206
206
|
component: "toaster.close",
|
|
207
207
|
props: {
|
|
@@ -214,7 +214,7 @@ function S(e) {
|
|
|
214
214
|
});
|
|
215
215
|
}
|
|
216
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 =
|
|
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({
|
|
218
218
|
hovered: !1,
|
|
219
219
|
focused: !1,
|
|
220
220
|
hidden: !1
|
|
@@ -223,22 +223,22 @@ function C(o) {
|
|
|
223
223
|
e || t || n ? w.pause() : w.resume();
|
|
224
224
|
}, [w]);
|
|
225
225
|
r(() => w.setLimit(m), [w, m]), r(() => w.setDefaultDuration(h), [w, h]), r(() => {
|
|
226
|
-
let
|
|
227
|
-
!O || !
|
|
226
|
+
let e = A.current;
|
|
227
|
+
!O || !t() || !e || !e.isConnected || e.matches(":popover-open") || e.showPopover();
|
|
228
228
|
}), r(() => {
|
|
229
|
-
let e =
|
|
229
|
+
let e = n();
|
|
230
230
|
if (!e) return;
|
|
231
|
-
let
|
|
231
|
+
let t = new AbortController();
|
|
232
232
|
return e.addEventListener("visibilitychange", () => {
|
|
233
233
|
M.current.hidden = e.hidden, N();
|
|
234
|
-
}, { signal:
|
|
234
|
+
}, { signal: t.signal }), () => t.abort();
|
|
235
235
|
}, [N]), r(() => {
|
|
236
|
-
let e =
|
|
236
|
+
let e = n();
|
|
237
237
|
if (!C || !e) return;
|
|
238
|
-
let
|
|
238
|
+
let t = new AbortController();
|
|
239
239
|
return e.addEventListener("keydown", (t) => {
|
|
240
240
|
!x(t, C) || !A.current || (t.preventDefault(), j.current = e.activeElement, A.current.focus());
|
|
241
|
-
}, { signal:
|
|
241
|
+
}, { signal: t.signal }), () => t.abort();
|
|
242
242
|
}, [C]);
|
|
243
243
|
let P = (e) => !!e && !!A.current?.contains(e), F = () => {
|
|
244
244
|
M.current.hovered = !0, N();
|
|
@@ -252,10 +252,10 @@ function C(o) {
|
|
|
252
252
|
if (e.key !== "Escape") return;
|
|
253
253
|
let t = (e.target.closest?.("[data-toast-id]"))?.getAttribute("data-toast-id");
|
|
254
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__ */
|
|
255
|
+
}, B = p.startsWith("top"), V = D.toasts.filter((e) => e.visible), H = B ? [...V].reverse() : V, U = D.overflow > 0 && /* @__PURE__ */ l(i, {
|
|
256
256
|
component: "toaster.overflow",
|
|
257
257
|
children: y(D.overflow)
|
|
258
|
-
}), W = /* @__PURE__ */
|
|
258
|
+
}), W = /* @__PURE__ */ u(i, {
|
|
259
259
|
tag: "section",
|
|
260
260
|
ref: A,
|
|
261
261
|
component: "toaster",
|
|
@@ -277,7 +277,7 @@ function C(o) {
|
|
|
277
277
|
},
|
|
278
278
|
children: [
|
|
279
279
|
!B && U,
|
|
280
|
-
H.map((e) => /* @__PURE__ */
|
|
280
|
+
H.map((e) => /* @__PURE__ */ l(S, {
|
|
281
281
|
toast: e,
|
|
282
282
|
store: w,
|
|
283
283
|
fromTop: B,
|
|
@@ -286,7 +286,7 @@ function C(o) {
|
|
|
286
286
|
B && U
|
|
287
287
|
]
|
|
288
288
|
});
|
|
289
|
-
return O ? W : k ?
|
|
289
|
+
return O ? W : k ? d(W, k) : null;
|
|
290
290
|
}
|
|
291
291
|
var w = C;
|
|
292
292
|
w.displayName = "Toaster";
|