@box-kite/react 2.2.14 → 2.2.16
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 +1 -1
- package/.claude/skills/box-kite/SKILL.md +1 -1
- package/.claude/skills/box-kite/references/styling.md +1 -1
- package/.cursor/rules/box-kite.mdc +1 -1
- package/AGENTS.md +1 -1
- package/BOX_AI_CONTEXT.md +16 -0
- package/BOX_KITE_AI_CONTEXT.md +16 -0
- package/behavior.cjs +1 -1
- package/behavior.mjs +16 -16
- package/catalog.cjs +1 -1
- package/catalog.mjs +1 -1
- package/client.cjs +1 -1
- package/client.mjs +10 -10
- package/components/accordion.cjs +1 -1
- package/components/accordion.mjs +95 -91
- package/components/calendar.cjs +1 -1
- package/components/calendar.mjs +212 -210
- package/components/chart.cjs +1 -1
- package/components/chart.d.ts +8 -3
- package/components/chart.mjs +70 -65
- package/components/combobox.cjs +1 -1
- package/components/combobox.mjs +187 -186
- package/components/dashboard.cjs +1 -1
- package/components/dashboard.d.ts +1 -44
- package/components/dashboard.mjs +202 -201
- package/components/dataGrid/components/dataGridListLayout.d.ts +1 -1
- package/components/dataGrid/contracts/dataGridContract.d.ts +1 -1
- package/components/dataGrid/models/gridModel.d.ts +1 -1
- package/components/dataGrid.cjs +2 -2
- package/components/dataGrid.mjs +10 -10
- package/components/dateField.cjs +1 -1
- package/components/dateField.mjs +96 -96
- package/components/datePicker.cjs +1 -1
- package/components/datePicker.mjs +177 -179
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +2 -64
- package/components/dialog.mjs +130 -126
- package/components/form.cjs +1 -1
- package/components/form.d.ts +4 -3
- package/components/form.mjs +25 -22
- package/components/menu.cjs +1 -1
- package/components/menu.d.ts +2 -73
- package/components/menu.mjs +222 -218
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +43 -43
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +1 -41
- package/components/popover.mjs +55 -51
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +59 -55
- package/components/slider.cjs +1 -1
- package/components/slider.d.ts +1 -55
- package/components/slider.mjs +92 -90
- package/components/sortableList.cjs +1 -1
- package/components/sortableList.mjs +149 -148
- package/components/swipeItem.cjs +1 -1
- package/components/swipeItem.mjs +100 -100
- package/components/tabs.cjs +1 -1
- package/components/tabs.mjs +135 -132
- package/components/toaster.cjs +1 -1
- package/components/toaster.d.ts +1 -37
- package/components/toaster.mjs +130 -128
- package/components/tooltip.cjs +1 -1
- package/components/tooltip.d.ts +1 -34
- package/components/tooltip.mjs +73 -69
- package/components/virtualList.cjs +1 -1
- package/components/virtualList.mjs +88 -87
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/package.json +31 -30
- package/placement.cjs +1 -1
- package/placement.mjs +1 -1
- package/platform.cjs +1 -1
- package/platform.mjs +17 -14
- package/react/componentsContext.d.ts +1 -1
- package/react-shared.cjs +1 -1
- package/react-shared.mjs +1 -1
- package/scrolling.cjs +1 -1
- package/scrolling.mjs +1 -1
- package/utils/chart/chartUtils.d.ts +3 -2
- package/utils/dashboard/dashboardUtils.d.ts +1 -1
- package/utils/dom/domUtils.d.ts +6 -0
- package/create/src/agents.d.ts +0 -22
- package/create/src/agents.test.d.ts +0 -1
- package/create/src/index.d.ts +0 -1
- package/create/src/options.d.ts +0 -31
- package/create/src/options.test.d.ts +0 -1
- package/create/src/packageManager.d.ts +0 -5
- package/create/src/project.d.ts +0 -27
- package/create/src/project.test.d.ts +0 -1
- package/create/templates/ts/designs/azure.d.ts +0 -5
- package/create/templates/ts/designs/ember.d.ts +0 -5
- package/create/templates/ts/designs/mono.d.ts +0 -5
- package/create/templates/ts/src/App.d.ts +0 -2
- package/create/templates/ts/src/design.d.ts +0 -5
- package/create/templates/ts/src/main.d.ts +0 -0
- package/mcp/src/data.d.ts +0 -90
- package/mcp/src/data.test.d.ts +0 -1
- package/mcp/src/engine.d.ts +0 -23
- package/mcp/src/index.d.ts +0 -1
- package/mcp/src/search.d.ts +0 -26
- package/mcp/src/search.test.d.ts +0 -1
- package/mcp/src/server.d.ts +0 -18
- package/mcp/src/server.test.d.ts +0 -1
- package/mcp/src/styles.d.ts +0 -27
- package/mcp/src/styles.test.d.ts +0 -1
- package/mcp/src/tools.d.ts +0 -18
- package/mcp/src/vocabulary.d.ts +0 -41
- package/registry/blocks/dashboard-shell/dashboard-shell.d.ts +0 -24
- package/registry/blocks/dashboard-shell/dashboard-stats.d.ts +0 -13
- package/registry/blocks/data-grid/invoice-rows.d.ts +0 -15
- package/registry/blocks/data-grid/invoices-grid.d.ts +0 -1
- package/registry/blocks/settings-form/settings-form.d.ts +0 -17
- package/registry/designs/store/address-form.d.ts +0 -11
- package/registry/designs/store/cart-items.d.ts +0 -10
- package/registry/designs/store/cart-page.d.ts +0 -4
- package/registry/designs/store/checkout-page.d.ts +0 -7
- package/registry/designs/store/credit-card-form.d.ts +0 -10
- package/registry/designs/store/form-field.d.ts +0 -19
- package/registry/designs/store/order-summary.d.ts +0 -18
- package/registry/designs/store/product-art.d.ts +0 -26
- package/registry/designs/store/product-card.d.ts +0 -11
- package/registry/designs/store/product-gallery.d.ts +0 -11
- package/registry/designs/store/product-grid.d.ts +0 -10
- package/registry/designs/store/product-page.d.ts +0 -5
- package/registry/designs/store/quantity-stepper.d.ts +0 -13
- package/registry/designs/store/shipping-method.d.ts +0 -14
- package/registry/designs/store/store-data.d.ts +0 -53
- package/registry/designs/store/store-design.d.ts +0 -63
- package/registry/designs/store/store-shell.d.ts +0 -12
- package/registry/designs/store/storefront-page.d.ts +0 -4
- package/registry/designs/store/variant-picker.d.ts +0 -15
- package/supabase/functions/collect/index.d.ts +0 -30
- package/supabase/functions/collect/index.test.d.ts +0 -1
package/components/tabs.mjs
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import n from "../
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { l as t, m as n } from "../platform.mjs";
|
|
4
|
+
import { n as r } from "../effects.mjs";
|
|
5
|
+
import i from "../box.mjs";
|
|
6
|
+
import { a } from "../behavior.mjs";
|
|
7
|
+
import { t as o } from "../identity.mjs";
|
|
8
|
+
import { a as s } from "../reporting.mjs";
|
|
9
|
+
import { n as c } from "../motion.mjs";
|
|
10
|
+
import { createContext as l, useCallback as u, useContext as d, useMemo as f, useRef as p, useState as m } from "react";
|
|
11
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
11
12
|
//#region src/utils/tabs/tabsUtils.ts
|
|
12
|
-
var
|
|
13
|
+
var _;
|
|
13
14
|
(function(e) {
|
|
14
15
|
let t = e.TAB_SELECTOR = "[role=\"tab\"]", n = e.LIST_SELECTOR = "[role=\"tablist\"]", r = e.PANEL_SELECTOR = "[role=\"tabpanel\"]";
|
|
15
16
|
function i(e, t) {
|
|
@@ -100,154 +101,155 @@ var m;
|
|
|
100
101
|
if (e) return [...e.querySelectorAll(r)].find((e) => !e.hasAttribute("hidden"));
|
|
101
102
|
}
|
|
102
103
|
e.visiblePanel = _;
|
|
103
|
-
})(
|
|
104
|
-
var
|
|
105
|
-
function
|
|
106
|
-
let t =
|
|
104
|
+
})(_ ||= {});
|
|
105
|
+
var v = _, y = l(null);
|
|
106
|
+
function b(e) {
|
|
107
|
+
let t = d(y);
|
|
107
108
|
if (!t) throw Error(`<${e}> has to be rendered inside a <Tabs>.`);
|
|
108
109
|
return t;
|
|
109
110
|
}
|
|
110
|
-
function
|
|
111
|
-
let { children:
|
|
112
|
-
value:
|
|
113
|
-
defaultValue:
|
|
111
|
+
function x(e) {
|
|
112
|
+
let { children: t, value: n, defaultValue: a, onValueChange: c, orientation: l = "horizontal", activation: u = "automatic", loop: d = !0, keepMounted: p = !1, indicator: g = "static", props: _, ...b } = e, x = o("tabs"), [S, C] = s({
|
|
113
|
+
value: n,
|
|
114
|
+
defaultValue: a,
|
|
114
115
|
onChange: c,
|
|
115
116
|
interaction: {
|
|
116
117
|
component: "tabs",
|
|
117
118
|
type: "valueChange"
|
|
118
119
|
}
|
|
119
|
-
}), [w, T] =
|
|
120
|
-
|
|
120
|
+
}), [w, T] = m(), [E, D] = m(!1);
|
|
121
|
+
r(() => {
|
|
121
122
|
S !== void 0 && T(S);
|
|
122
123
|
}, [S]);
|
|
123
|
-
let O =
|
|
124
|
+
let O = f(() => ({
|
|
124
125
|
identifier: x,
|
|
125
126
|
value: S,
|
|
126
|
-
orientation:
|
|
127
|
-
activation:
|
|
128
|
-
loop:
|
|
129
|
-
keepMounted:
|
|
130
|
-
indicator:
|
|
127
|
+
orientation: l,
|
|
128
|
+
activation: u,
|
|
129
|
+
loop: d,
|
|
130
|
+
keepMounted: p,
|
|
131
|
+
indicator: g,
|
|
131
132
|
indicatorLive: E,
|
|
132
133
|
setIndicatorLive: D,
|
|
133
134
|
tabStop: w ?? S,
|
|
134
135
|
setTabStop: T,
|
|
135
136
|
select: C,
|
|
136
|
-
tabId: (e) => `${x}-tab-${
|
|
137
|
-
panelId: (e) => `${x}-panel-${
|
|
137
|
+
tabId: (e) => `${x}-tab-${v.token(e)}`,
|
|
138
|
+
panelId: (e) => `${x}-panel-${v.token(e)}`
|
|
138
139
|
}), [
|
|
139
140
|
x,
|
|
140
141
|
S,
|
|
142
|
+
l,
|
|
141
143
|
u,
|
|
144
|
+
d,
|
|
142
145
|
p,
|
|
143
|
-
|
|
144
|
-
_,
|
|
145
|
-
v,
|
|
146
|
+
g,
|
|
146
147
|
E,
|
|
147
148
|
w,
|
|
148
149
|
C
|
|
149
150
|
]);
|
|
150
|
-
return /* @__PURE__ */
|
|
151
|
+
return /* @__PURE__ */ h(y.Provider, {
|
|
151
152
|
value: O,
|
|
152
|
-
children: /* @__PURE__ */
|
|
153
|
+
children: /* @__PURE__ */ h(i, {
|
|
153
154
|
component: "tabs",
|
|
154
155
|
...b,
|
|
155
|
-
variant: [b.variant, { vertical:
|
|
156
|
-
props:
|
|
157
|
-
children:
|
|
156
|
+
variant: [b.variant, { vertical: l === "vertical" }],
|
|
157
|
+
props: _,
|
|
158
|
+
children: t
|
|
158
159
|
})
|
|
159
160
|
});
|
|
160
161
|
}
|
|
161
|
-
function
|
|
162
|
-
let { children:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
function S(e, o) {
|
|
163
|
+
let { children: s, label: c, labelledBy: l, props: d, ...f } = e, { value: _, orientation: y, activation: x, loop: S, indicator: C, tabStop: w, setTabStop: T, setIndicatorLive: E, select: D } = b("Tabs.List"), O = p(null), k = u((e) => {
|
|
164
|
+
O.current = e, t(o, e);
|
|
165
|
+
}, [o]), [A, j] = m(), M = C === "sliding";
|
|
166
|
+
r(() => {
|
|
167
|
+
let e = O.current;
|
|
168
|
+
if (!M || !e) return;
|
|
166
169
|
let t = () => {
|
|
167
|
-
let t =
|
|
168
|
-
|
|
170
|
+
let t = v.selectedTab(e), n = t && v.bounds(e, t, y);
|
|
171
|
+
j((e) => v.sameBounds(e, n) ? e : n);
|
|
169
172
|
};
|
|
170
173
|
if (t(), typeof ResizeObserver > "u") return;
|
|
171
174
|
let n = new ResizeObserver(t);
|
|
172
175
|
n.observe(e);
|
|
173
|
-
for (let t of
|
|
176
|
+
for (let t of v.tabs(e)) n.observe(t);
|
|
174
177
|
return () => n.disconnect();
|
|
175
178
|
}, [
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
M,
|
|
180
|
+
y,
|
|
181
|
+
_
|
|
179
182
|
]);
|
|
180
|
-
let
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}, [
|
|
184
|
-
if (
|
|
185
|
-
let e =
|
|
186
|
-
t !== void 0 &&
|
|
187
|
-
}, [
|
|
188
|
-
let
|
|
189
|
-
let
|
|
190
|
-
if (!
|
|
191
|
-
let r =
|
|
183
|
+
let N = M && A && A.size > 0 ? A : void 0;
|
|
184
|
+
r(() => {
|
|
185
|
+
E(N !== void 0);
|
|
186
|
+
}, [N, E]), r(() => {
|
|
187
|
+
if (w !== void 0) return;
|
|
188
|
+
let e = v.edge(v.tabs(O.current), 1), t = e && v.valueOf(e);
|
|
189
|
+
t !== void 0 && T(t);
|
|
190
|
+
}, [w, T]);
|
|
191
|
+
let P = a((e) => {
|
|
192
|
+
let t = O.current;
|
|
193
|
+
if (!t || e.defaultPrevented || !v.owns(t, e.target)) return;
|
|
194
|
+
let r = v.tabs(t), i = v.indexOf(r, e.target);
|
|
192
195
|
if (i === -1) return;
|
|
193
|
-
if (
|
|
194
|
-
let
|
|
195
|
-
if (
|
|
196
|
-
|
|
196
|
+
if (x === "manual" && (e.key === "Enter" || e.key === " ")) {
|
|
197
|
+
let t = v.valueOf(r[i]);
|
|
198
|
+
if (t === void 0) return;
|
|
199
|
+
e.preventDefault(), D(t, {
|
|
197
200
|
reason: "keyboard",
|
|
198
|
-
event:
|
|
201
|
+
event: e
|
|
199
202
|
});
|
|
200
203
|
return;
|
|
201
204
|
}
|
|
202
|
-
let a =
|
|
205
|
+
let a = v.moveFor(e.key, y, n(t));
|
|
203
206
|
if (!a) return;
|
|
204
|
-
let o =
|
|
207
|
+
let o = v.target(r, i, a, S);
|
|
205
208
|
if (!o) return;
|
|
206
|
-
|
|
207
|
-
let s =
|
|
208
|
-
|
|
209
|
+
e.preventDefault(), o.focus();
|
|
210
|
+
let s = v.valueOf(o);
|
|
211
|
+
x === "automatic" && s !== void 0 && D(s, {
|
|
209
212
|
reason: "keyboard",
|
|
210
|
-
event:
|
|
213
|
+
event: e
|
|
211
214
|
});
|
|
212
215
|
});
|
|
213
|
-
return /* @__PURE__ */
|
|
214
|
-
ref:
|
|
216
|
+
return /* @__PURE__ */ g(i, {
|
|
217
|
+
ref: k,
|
|
215
218
|
component: "tabs.list",
|
|
216
|
-
...
|
|
217
|
-
variant: [
|
|
218
|
-
vertical:
|
|
219
|
-
sliding:
|
|
219
|
+
...f,
|
|
220
|
+
variant: [f.variant, {
|
|
221
|
+
vertical: y === "vertical",
|
|
222
|
+
sliding: M
|
|
220
223
|
}],
|
|
221
224
|
props: {
|
|
222
225
|
role: "tablist",
|
|
223
|
-
"aria-label":
|
|
224
|
-
"aria-labelledby":
|
|
225
|
-
"aria-orientation":
|
|
226
|
-
...
|
|
227
|
-
onKeyDown:
|
|
226
|
+
"aria-label": c,
|
|
227
|
+
"aria-labelledby": l,
|
|
228
|
+
"aria-orientation": y,
|
|
229
|
+
...d,
|
|
230
|
+
onKeyDown: P
|
|
228
231
|
},
|
|
229
|
-
children: [
|
|
232
|
+
children: [s, N && /* @__PURE__ */ h(i, {
|
|
230
233
|
tag: "span",
|
|
231
234
|
component: "tabs.indicator",
|
|
232
|
-
variant: { vertical:
|
|
233
|
-
style:
|
|
234
|
-
top: `${
|
|
235
|
-
height: `${
|
|
235
|
+
variant: { vertical: y === "vertical" },
|
|
236
|
+
style: y === "vertical" ? {
|
|
237
|
+
top: `${N.start}px`,
|
|
238
|
+
height: `${N.size}px`
|
|
236
239
|
} : {
|
|
237
|
-
left: `${
|
|
238
|
-
width: `${
|
|
240
|
+
left: `${N.start}px`,
|
|
241
|
+
width: `${N.size}px`
|
|
239
242
|
},
|
|
240
243
|
props: { "aria-hidden": !0 }
|
|
241
244
|
})]
|
|
242
245
|
});
|
|
243
246
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
let { value: t, children: i, disabled: a, props: o, ...s } = e, { value: c, orientation: l, keepMounted: u, indicatorLive: d, tabStop: p, setTabStop: m, select: h, tabId: g, panelId: v } = _("Tabs.Tab"), y = c === t, b = r((e) => h(t, {
|
|
247
|
+
function C(e) {
|
|
248
|
+
let { value: t, children: n, disabled: r, props: o, ...s } = e, { value: c, orientation: l, keepMounted: u, indicatorLive: d, tabStop: f, setTabStop: p, select: m, tabId: g, panelId: _ } = b("Tabs.Tab"), v = c === t, y = a((e) => m(t, {
|
|
247
249
|
reason: "click",
|
|
248
250
|
event: e
|
|
249
|
-
})), x =
|
|
250
|
-
return /* @__PURE__ */
|
|
251
|
+
})), x = a(() => p(t));
|
|
252
|
+
return /* @__PURE__ */ h(i, {
|
|
251
253
|
tag: "button",
|
|
252
254
|
component: "tabs.tab",
|
|
253
255
|
...s,
|
|
@@ -255,59 +257,60 @@ function b(e) {
|
|
|
255
257
|
vertical: l === "vertical",
|
|
256
258
|
underline: !d
|
|
257
259
|
}],
|
|
258
|
-
disabled:
|
|
260
|
+
disabled: r,
|
|
259
261
|
id: g(t),
|
|
260
262
|
props: {
|
|
261
263
|
type: "button",
|
|
262
264
|
role: "tab",
|
|
263
|
-
"aria-selected":
|
|
264
|
-
"aria-controls":
|
|
265
|
-
tabIndex:
|
|
265
|
+
"aria-selected": v,
|
|
266
|
+
"aria-controls": v || u ? _(t) : void 0,
|
|
267
|
+
tabIndex: f === t ? 0 : -1,
|
|
266
268
|
"data-value": t,
|
|
267
269
|
...o,
|
|
268
|
-
onClick:
|
|
270
|
+
onClick: y,
|
|
269
271
|
onFocus: x
|
|
270
272
|
},
|
|
271
|
-
children:
|
|
273
|
+
children: n
|
|
272
274
|
});
|
|
273
275
|
}
|
|
274
|
-
|
|
275
|
-
function
|
|
276
|
-
let { children:
|
|
277
|
-
|
|
276
|
+
C.displayName = "Tabs.Tab";
|
|
277
|
+
function w(e, n) {
|
|
278
|
+
let { children: o, props: s, ...l } = e, { value: d } = b("Tabs.Panels"), f = p(null), g = u((e) => {
|
|
279
|
+
f.current = e, t(n, e);
|
|
280
|
+
}, [n]), [_, y] = m(), [x, S] = m(!1), C = a(() => {
|
|
281
|
+
let e = f.current;
|
|
278
282
|
if (!e) return;
|
|
279
|
-
let t =
|
|
280
|
-
t !==
|
|
283
|
+
let t = v.visiblePanel(e)?.offsetHeight;
|
|
284
|
+
t !== _ && (_ !== void 0 && t !== void 0 && S(!0), y(t));
|
|
281
285
|
});
|
|
282
|
-
return
|
|
283
|
-
let e =
|
|
284
|
-
if (!e || (
|
|
285
|
-
let t =
|
|
286
|
+
return r(() => {
|
|
287
|
+
let e = f.current;
|
|
288
|
+
if (!e || (C(), typeof ResizeObserver > "u")) return;
|
|
289
|
+
let t = v.visiblePanel(e);
|
|
286
290
|
if (!t) return;
|
|
287
|
-
let n = new ResizeObserver(
|
|
291
|
+
let n = new ResizeObserver(C);
|
|
288
292
|
return n.observe(t), () => n.disconnect();
|
|
289
|
-
}, [
|
|
290
|
-
let e =
|
|
291
|
-
if (!e || !
|
|
292
|
-
let t = setTimeout(() =>
|
|
293
|
+
}, [d, C]), r(() => {
|
|
294
|
+
let e = f.current;
|
|
295
|
+
if (!e || !x) return;
|
|
296
|
+
let t = setTimeout(() => S(!1), c.activeDuration(getComputedStyle(e)) + c.SETTLE_FRAME);
|
|
293
297
|
return () => clearTimeout(t);
|
|
294
|
-
}, [
|
|
295
|
-
ref:
|
|
298
|
+
}, [x, _]), /* @__PURE__ */ h(i, {
|
|
299
|
+
ref: g,
|
|
296
300
|
component: "tabs.panels",
|
|
297
|
-
...
|
|
298
|
-
variant: [
|
|
301
|
+
...l,
|
|
302
|
+
variant: [l.variant, { resizing: x }],
|
|
299
303
|
style: {
|
|
300
|
-
height:
|
|
301
|
-
...
|
|
304
|
+
height: _ === void 0 ? void 0 : `${_}px`,
|
|
305
|
+
...l.style
|
|
302
306
|
},
|
|
303
|
-
props:
|
|
304
|
-
children:
|
|
307
|
+
props: s,
|
|
308
|
+
children: o
|
|
305
309
|
});
|
|
306
310
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return !u && !s ? null : /* @__PURE__ */ f(n, {
|
|
311
|
+
function T(e) {
|
|
312
|
+
let { value: t, children: n, props: r, ...a } = e, { value: o, keepMounted: s, tabId: c, panelId: l } = b("Tabs.Panel"), u = o === t;
|
|
313
|
+
return !u && !s ? null : /* @__PURE__ */ h(i, {
|
|
311
314
|
component: "tabs.panel",
|
|
312
315
|
...a,
|
|
313
316
|
variant: [a.variant, { hidden: !u }],
|
|
@@ -317,13 +320,13 @@ function S(e) {
|
|
|
317
320
|
"aria-labelledby": c(t),
|
|
318
321
|
hidden: !u || void 0,
|
|
319
322
|
tabIndex: 0,
|
|
320
|
-
...
|
|
323
|
+
...r
|
|
321
324
|
},
|
|
322
|
-
children:
|
|
325
|
+
children: n
|
|
323
326
|
});
|
|
324
327
|
}
|
|
325
|
-
|
|
326
|
-
var
|
|
327
|
-
|
|
328
|
+
T.displayName = "Tabs.Panel";
|
|
329
|
+
var E = x;
|
|
330
|
+
E.List = e(S, "Tabs.List"), E.Tab = C, E.Panels = e(w, "Tabs.Panels"), E.Panel = T, E.displayName = "Tabs";
|
|
328
331
|
//#endregion
|
|
329
|
-
export {
|
|
332
|
+
export { E 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("../react-shared.cjs"),t=require("../platform.cjs"),n=require("../client.cjs"),r=require("../effects.cjs"),i=require("../interactions.cjs"),a=require("../box.cjs"),o=require("../reporting.cjs"),s=require("../layer.cjs"),c=require("../motion.cjs");let l=require("react"),u=require("react/jsx-runtime"),d=require("react-dom"),f=require("use-sync-external-store/shim");var p=[`value`],m={toasts:[],overflow:0},h=0;function g(){return h+=1,`toast-${h}`}function _(e){let t=[],n=m,r=e?.limit??3,a=e?.duration??5e3,o=!1,s=new Set,c=new Map,l=e=>{let t=c.get(e);t?.handle&&clearTimeout(t.handle),c.delete(e)},u=()=>{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(),s.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=c.get(n.id)??{handle:null,remaining:n.duration,startedAt:0};c.set(n.id,t),!(o||t.handle)&&(t.startedAt=Date.now(),t.handle=setTimeout(()=>{c.delete(n.id),h(n.id,`timeout`)},t.remaining))}for(let t of[...c.keys()])e.has(t)||l(t)}let f=(e,t)=>t??(e===`loading`?1/0:a);function h(e,n=`imperative`){let r=[];t=t.map(t=>!t.open||e!==void 0&&t.id!==e?t:(r.push(t),l(t.id),{...t,open:!1})),r.length&&(u(),r.forEach(e=>{e.onDismiss?.(n),i.t({component:`toaster`,type:`dismiss`,reason:n,value:e.message,details:{id:e.id,kind:e.kind},content:p})}))}function _(e,n,r){let a=!1;t=t.map(t=>{if(t.id!==e)return t;a=!0,l(e);let i=r?.kind??t.kind;return{...t,...r,id:e,message:n,kind:i,duration:r?.duration??(r?.kind?f(i):t.duration),open:!0}}),a&&(u(),i.t({component:`toaster`,type:`update`,reason:r?.kind,value:n,details:{id:e},source:`app`,content:p}))}function v(e,n){let r=n?.id??g();if(n?.id&&t.some(e=>e.id===r))return _(r,e,n),r;let a=n?.kind??`default`;return t=[...t,{id:r,kind:a,message:e,description:n?.description,duration:f(a,n?.duration),action:n?.action,dismissible:n?.dismissible??!0,onDismiss:n?.onDismiss,open:!0,visible:!1}],u(),i.t({component:`toaster`,type:`show`,reason:a,value:e,details:{id:r,kind:a},source:`app`,content:p}),r}return{subscribe(e){return s.add(e),()=>s.delete(e)},getSnapshot:()=>n,getServerSnapshot:()=>m,add:v,update:_,dismiss:h,remove(e){let n=t.filter(t=>t.id!==e);n.length!==t.length&&(l(e),t=n,u())},setLimit(e){e!==r&&(r=e,u())},setDefaultDuration(e){a=e},pause(){if(!o){o=!0;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)))}},resume(){o&&(o=!1,d())},reset(){for(let e of[...c.keys()])l(e);t=[],n=m,s.forEach(e=>e())}}}var v=_(),y=e=>(t,n)=>v.add(t,{...n,kind:e}),b=Object.assign((e,t)=>v.add(e,t),{success:y(`success`),error:y(`error`),warning:y(`warning`),info:y(`info`),loading:y(`loading`),update:(e,t,n)=>v.update(e,t,n),dismiss:e=>v.dismiss(e,`imperative`),promise(e,t,n){let r=v.add(t.loading,{...n,id:n?.id,kind:`loading`}),i=(e,t)=>typeof e==`function`?e(t):e;return e.then(e=>v.update(r,i(t.success,e),{kind:`success`}),e=>v.update(r,i(t.error,e),{kind:`error`})),e}}),x={"top-start":`topStart`,"top-center":`topCenter`,"top-end":`topEnd`,"bottom-start":`bottomStart`,"bottom-center":`bottomCenter`,"bottom-end":`bottomEnd`};function S(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 C(e){let{toast:t,store:n,fromTop:i,closeLabel:s}=e,{mounted:l,ref:d,props:f}=c.t({present:t.open}),p=o.i(`toaster`);if(r.n(()=>{l||n.remove(t.id)},[l,n,t.id]),!l)return null;let m=t.action,h=()=>{m?.onClick(),m?.closeOnClick===!1?p(`action`,t.message,{reason:`action`,id:t.id,kind:t.kind,content:[`value`]}):n.dismiss(t.id,`action`)};return(0,u.jsxs)(a.default,{ref:d,component:`toaster.toast`,variant:{[t.kind]:t.kind!=="default",fromTop:i},props:{...t.kind===`error`?{role:`alert`}:{},"data-toast-id":t.id,...f},children:[(0,u.jsx)(a.default,{component:`toaster.message`,children:t.message}),t.description!==void 0&&(0,u.jsx)(a.default,{component:`toaster.description`,children:t.description}),m&&(0,u.jsx)(a.default,{tag:`button`,component:`toaster.action`,props:{type:`button`,onClick:h},children:m.label}),t.dismissible&&(0,u.jsx)(a.default,{tag:`button`,component:`toaster.close`,props:{type:`button`,"aria-label":s,onClick:()=>n.dismiss(t.id,`close`)}})]})}function w(e,i){let{position:o=`bottom-end`,limit:c=3,duration:p=5e3,label:m=`Notifications`,closeLabel:h=`Close`,overflowLabel:g=e=>`+${e} more`,hotkey:_=`F6`,store:y=v,props:b,...w}=e,T=(0,f.useSyncExternalStore)(y.subscribe,y.getSnapshot,y.getServerSnapshot),E=s.n(),D=n.t(!E),O=(0,l.useRef)(null),k=(0,l.useCallback)(e=>{O.current=e,t.l(i,e)},[i]),A=(0,l.useRef)(null),j=(0,l.useRef)({hovered:!1,focused:!1,hidden:!1}),M=(0,l.useCallback)(()=>{let{hovered:e,focused:t,hidden:n}=j.current;e||t||n?y.pause():y.resume()},[y]);r.n(()=>y.setLimit(c),[y,c]),r.n(()=>y.setDefaultDuration(p),[y,p]),r.n(()=>{let e=O.current;!E||!t.c()||!e||!e.isConnected||e.matches(`:popover-open`)||e.showPopover()}),r.n(()=>{let e=t.t();if(!e)return;let n=new AbortController;return e.addEventListener(`visibilitychange`,()=>{j.current.hidden=e.hidden,M()},{signal:n.signal}),()=>n.abort()},[M]),r.n(()=>{let e=t.t();if(!_||!e)return;let n=new AbortController;return e.addEventListener(`keydown`,t=>{!S(t,_)||!O.current||(t.preventDefault(),A.current=e.activeElement,O.current.focus())},{signal:n.signal}),()=>n.abort()},[_]);let N=e=>!!e&&!!O.current?.contains(e),P=()=>{j.current.hovered=!0,M()},F=e=>{N(e.relatedTarget)||(j.current.hovered=!1,M())},I=e=>{j.current.focused=!0,M(),N(e.relatedTarget)||(A.current=e.relatedTarget)},L=e=>{N(e.relatedTarget)||(j.current.focused=!1,M())},R=e=>{if(e.key!==`Escape`)return;let t=(e.target.closest?.(`[data-toast-id]`))?.getAttribute(`data-toast-id`);t&&y.dismiss(t,`close`),y.getSnapshot().toasts.some(e=>e.open)?O.current?.focus():A.current?.focus()},z=o.startsWith(`top`),B=T.toasts.filter(e=>e.visible),V=z?[...B].reverse():B,H=T.overflow>0&&(0,u.jsx)(a.default,{component:`toaster.overflow`,children:g(T.overflow)}),U=(0,u.jsxs)(a.default,{tag:`section`,ref:k,component:`toaster`,...w,variant:[w.variant,{[x[o]]:!0}],props:{...E?{popover:`manual`}:{},"aria-live":`polite`,"aria-atomic":`false`,"aria-relevant":`additions text`,"aria-label":m,tabIndex:-1,...b,onPointerOver:P,onPointerOut:F,onFocus:I,onBlur:L,onKeyDown:R},children:[!z&&H,V.map(e=>(0,u.jsx)(C,{toast:e,store:y,fromTop:z,closeLabel:h},e.id)),z&&H]});return E?U:D?(0,d.createPortal)(U,D):null}var T=e.f(w,`Toaster`);exports.createToastStore=_,exports.default=T,exports.defaultToastStore=v,exports.toast=b;
|
package/components/toaster.d.ts
CHANGED
|
@@ -66,41 +66,5 @@ export interface ToasterProps<TKey extends keyof ComponentsAndVariants = 'toaste
|
|
|
66
66
|
/** A store of your own — for a second, independent stack, or for a test that must not share state. */
|
|
67
67
|
store?: ToastStore<Content>;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
* The viewport every toast is drawn in, and the live region they are announced from. Render one, once,
|
|
71
|
-
* near the root of the app; everything after that is `toast()`, from wherever the message comes from.
|
|
72
|
-
*
|
|
73
|
-
* ```tsx
|
|
74
|
-
* <Toaster position="bottom-end" />
|
|
75
|
-
* // anywhere at all, React or not:
|
|
76
|
-
* toast.success('Saved');
|
|
77
|
-
* ```
|
|
78
|
-
*
|
|
79
|
-
* **It is in the top layer and there is no portal.** The viewport carries `popover="manual"` and is shown
|
|
80
|
-
* as soon as it mounts, so it paints over every stacking context and out of every clipped or transformed
|
|
81
|
-
* ancestor — and because it stays where it was declared, it inherits the theme, the custom properties and
|
|
82
|
-
* the text direction around it. `manual` rather than `auto` because a stack of messages owns no dismissal:
|
|
83
|
-
* a press outside must reach the page, not close the toasts.
|
|
84
|
-
*
|
|
85
|
-
* **A press in the gaps goes through to the page.** The viewport is a corner-sized box that would
|
|
86
|
-
* otherwise swallow every click in it, so it takes no pointer events at all and the toasts take them back.
|
|
87
|
-
*
|
|
88
|
-
* **The limit is a queue, not a cap.** A toast past it waits with its timer unstarted, so nothing expires
|
|
89
|
-
* that was never on screen, and the counter at the end of the stack says how many are waiting.
|
|
90
|
-
*
|
|
91
|
-
* @a11y The viewport is a polite live region that exists from the moment it mounts, **before there is
|
|
92
|
-
* anything in it** — an `aria-live` element inserted together with its content is not reliably announced.
|
|
93
|
-
* @a11y An error toast is `role="alert"`, which is assertive; every other kind is announced politely by
|
|
94
|
-
* the region around it. A toast is never focused on arrival, so nothing is taken away from the keyboard.
|
|
95
|
-
* @a11y Timers stop while the pointer is over the stack, while anything in it has focus, and while the
|
|
96
|
-
* tab is in the background — WCAG 2.2.1, and the reason a toast may carry a control at all.
|
|
97
|
-
* @a11y The accent bar says the kind a second time; it is never the only signal, since the message itself
|
|
98
|
-
* is what says what happened.
|
|
99
|
-
* @keyboard F6 — Moves focus to the stack from anywhere on the page. Configurable through `hotkey`.
|
|
100
|
-
* @keyboard Tab — Through the toasts and their controls, in the order they are on screen.
|
|
101
|
-
* @keyboard Escape — Dismisses the toast focus is in, and hands focus back to where it came from once
|
|
102
|
-
* the stack is empty.
|
|
103
|
-
*/
|
|
104
|
-
declare function ToasterImpl<TKey extends keyof ComponentsAndVariants = 'toaster'>(props: ToasterProps<TKey>): import("react").JSX.Element | null;
|
|
105
|
-
declare const Toaster: typeof ToasterImpl;
|
|
69
|
+
declare const Toaster: <TKey extends keyof ComponentsAndVariants = "toaster">(props: ToasterProps<TKey>) => React.ReactNode;
|
|
106
70
|
export default Toaster;
|