@box-kite/react 2.2.15 → 2.2.17
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 +286 -285
- package/components/dialog.cjs +1 -1
- package/components/dialog.d.ts +2 -64
- package/components/dialog.mjs +131 -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 +220 -215
- package/components/overlay.cjs +1 -1
- package/components/overlay.mjs +44 -43
- package/components/popover.cjs +1 -1
- package/components/popover.d.ts +1 -41
- package/components/popover.mjs +56 -51
- package/components/presence.cjs +1 -1
- package/components/presence.mjs +1 -1
- package/components/radioGroup.cjs +1 -1
- package/components/radioGroup.mjs +59 -55
- package/components/semantics.d.ts +29 -29
- 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/docs/props.md +2 -2
- package/interactionListening.cjs +1 -1
- package/interactionListening.mjs +3 -3
- package/layer.cjs +1 -1
- package/layer.mjs +1 -1
- package/motion.cjs +1 -1
- package/motion.mjs +30 -20
- package/package.json +41 -40
- package/placement.cjs +1 -1
- package/placement.mjs +1 -1
- package/platform.cjs +1 -1
- package/platform.mjs +17 -14
- package/react/animation/useHeldContent.d.ts +6 -0
- package/react/animation/usePresence.d.ts +4 -0
- 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 -38
- 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/toaster.mjs
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { t as n } from "../
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
2
|
+
import { f as e } from "../react-shared.mjs";
|
|
3
|
+
import { c as t, l as n, t as r } from "../platform.mjs";
|
|
4
|
+
import { t as i } from "../client.mjs";
|
|
5
|
+
import { n as a } from "../effects.mjs";
|
|
6
|
+
import { t as o } from "../interactions.mjs";
|
|
7
|
+
import s from "../box.mjs";
|
|
8
|
+
import { i as c } from "../reporting.mjs";
|
|
9
|
+
import { n as l } from "../layer.mjs";
|
|
10
|
+
import { r as u } from "../motion.mjs";
|
|
11
|
+
import { useCallback as d, useRef as f } from "react";
|
|
12
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
13
|
+
import { createPortal as h } from "react-dom";
|
|
14
|
+
import { useSyncExternalStore as g } from "use-sync-external-store/shim";
|
|
14
15
|
//#region src/utils/toast/toastStore.ts
|
|
15
|
-
var
|
|
16
|
+
var _ = ["value"], v = {
|
|
16
17
|
toasts: [],
|
|
17
18
|
overflow: 0
|
|
18
|
-
},
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
}, y = 0;
|
|
20
|
+
function b() {
|
|
21
|
+
return y += 1, `toast-${y}`;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
let t = [], n =
|
|
23
|
+
function x(e) {
|
|
24
|
+
let t = [], n = v, r = e?.limit ?? 3, i = e?.duration ?? 5e3, a = !1, s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Map(), l = (e) => {
|
|
24
25
|
let t = c.get(e);
|
|
25
26
|
t?.handle && clearTimeout(t.handle), c.delete(e);
|
|
26
27
|
}, u = () => {
|
|
@@ -46,20 +47,20 @@ function y(e) {
|
|
|
46
47
|
remaining: n.duration,
|
|
47
48
|
startedAt: 0
|
|
48
49
|
};
|
|
49
|
-
c.set(n.id, t), !(
|
|
50
|
+
c.set(n.id, t), !(a || t.handle) && (t.startedAt = Date.now(), t.handle = setTimeout(() => {
|
|
50
51
|
c.delete(n.id), p(n.id, "timeout");
|
|
51
52
|
}, t.remaining));
|
|
52
53
|
}
|
|
53
54
|
for (let t of [...c.keys()]) e.has(t) || l(t);
|
|
54
55
|
}
|
|
55
|
-
let f = (e, t) => t ?? (e === "loading" ? Infinity :
|
|
56
|
+
let f = (e, t) => t ?? (e === "loading" ? Infinity : i);
|
|
56
57
|
function p(e, n = "imperative") {
|
|
57
58
|
let r = [];
|
|
58
59
|
t = t.map((t) => !t.open || e !== void 0 && t.id !== e ? t : (r.push(t), l(t.id), {
|
|
59
60
|
...t,
|
|
60
61
|
open: !1
|
|
61
62
|
})), r.length && (u(), r.forEach((e) => {
|
|
62
|
-
e.onDismiss?.(n),
|
|
63
|
+
e.onDismiss?.(n), o({
|
|
63
64
|
component: "toaster",
|
|
64
65
|
type: "dismiss",
|
|
65
66
|
reason: n,
|
|
@@ -68,61 +69,61 @@ function y(e) {
|
|
|
68
69
|
id: e.id,
|
|
69
70
|
kind: e.kind
|
|
70
71
|
},
|
|
71
|
-
content:
|
|
72
|
+
content: _
|
|
72
73
|
});
|
|
73
74
|
}));
|
|
74
75
|
}
|
|
75
76
|
function m(e, n, r) {
|
|
76
|
-
let
|
|
77
|
+
let i = !1;
|
|
77
78
|
t = t.map((t) => {
|
|
78
79
|
if (t.id !== e) return t;
|
|
79
|
-
|
|
80
|
-
let
|
|
80
|
+
i = !0, l(e);
|
|
81
|
+
let a = r?.kind ?? t.kind;
|
|
81
82
|
return {
|
|
82
83
|
...t,
|
|
83
84
|
...r,
|
|
84
85
|
id: e,
|
|
85
86
|
message: n,
|
|
86
|
-
kind:
|
|
87
|
-
duration: r?.duration ?? (r?.kind ? f(
|
|
87
|
+
kind: a,
|
|
88
|
+
duration: r?.duration ?? (r?.kind ? f(a) : t.duration),
|
|
88
89
|
open: !0
|
|
89
90
|
};
|
|
90
|
-
}),
|
|
91
|
+
}), i && (u(), o({
|
|
91
92
|
component: "toaster",
|
|
92
93
|
type: "update",
|
|
93
94
|
reason: r?.kind,
|
|
94
95
|
value: n,
|
|
95
96
|
details: { id: e },
|
|
96
97
|
source: "app",
|
|
97
|
-
content:
|
|
98
|
+
content: _
|
|
98
99
|
}));
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
let r = n?.id ??
|
|
101
|
+
function h(e, n) {
|
|
102
|
+
let r = n?.id ?? b();
|
|
102
103
|
if (n?.id && t.some((e) => e.id === r)) return m(r, e, n), r;
|
|
103
|
-
let
|
|
104
|
+
let i = n?.kind ?? "default";
|
|
104
105
|
return t = [...t, {
|
|
105
106
|
id: r,
|
|
106
|
-
kind:
|
|
107
|
+
kind: i,
|
|
107
108
|
message: e,
|
|
108
109
|
description: n?.description,
|
|
109
|
-
duration: f(
|
|
110
|
+
duration: f(i, n?.duration),
|
|
110
111
|
action: n?.action,
|
|
111
112
|
dismissible: n?.dismissible ?? !0,
|
|
112
113
|
onDismiss: n?.onDismiss,
|
|
113
114
|
open: !0,
|
|
114
115
|
visible: !1
|
|
115
|
-
}], u(),
|
|
116
|
+
}], u(), o({
|
|
116
117
|
component: "toaster",
|
|
117
118
|
type: "show",
|
|
118
|
-
reason:
|
|
119
|
+
reason: i,
|
|
119
120
|
value: e,
|
|
120
121
|
details: {
|
|
121
122
|
id: r,
|
|
122
|
-
kind:
|
|
123
|
+
kind: i
|
|
123
124
|
},
|
|
124
125
|
source: "app",
|
|
125
|
-
content:
|
|
126
|
+
content: _
|
|
126
127
|
}), r;
|
|
127
128
|
}
|
|
128
129
|
return {
|
|
@@ -130,8 +131,8 @@ function y(e) {
|
|
|
130
131
|
return s.add(e), () => s.delete(e);
|
|
131
132
|
},
|
|
132
133
|
getSnapshot: () => n,
|
|
133
|
-
getServerSnapshot: () =>
|
|
134
|
-
add:
|
|
134
|
+
getServerSnapshot: () => v,
|
|
135
|
+
add: h,
|
|
135
136
|
update: m,
|
|
136
137
|
dismiss: p,
|
|
137
138
|
remove(e) {
|
|
@@ -142,45 +143,45 @@ function y(e) {
|
|
|
142
143
|
e !== r && (r = e, u());
|
|
143
144
|
},
|
|
144
145
|
setDefaultDuration(e) {
|
|
145
|
-
|
|
146
|
+
i = e;
|
|
146
147
|
},
|
|
147
148
|
pause() {
|
|
148
|
-
if (!
|
|
149
|
-
|
|
149
|
+
if (!a) {
|
|
150
|
+
a = !0;
|
|
150
151
|
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)));
|
|
151
152
|
}
|
|
152
153
|
},
|
|
153
154
|
resume() {
|
|
154
|
-
|
|
155
|
+
a && (a = !1, d());
|
|
155
156
|
},
|
|
156
157
|
reset() {
|
|
157
158
|
for (let e of [...c.keys()]) l(e);
|
|
158
|
-
t = [], n =
|
|
159
|
+
t = [], n = v, s.forEach((e) => e());
|
|
159
160
|
}
|
|
160
161
|
};
|
|
161
162
|
}
|
|
162
163
|
//#endregion
|
|
163
164
|
//#region src/components/toaster.tsx
|
|
164
|
-
var
|
|
165
|
+
var S = x(), C = (e) => (t, n) => S.add(t, {
|
|
165
166
|
...n,
|
|
166
167
|
kind: e
|
|
167
|
-
}),
|
|
168
|
-
success:
|
|
169
|
-
error:
|
|
170
|
-
warning:
|
|
171
|
-
info:
|
|
172
|
-
loading:
|
|
173
|
-
update: (e, t, n) =>
|
|
174
|
-
dismiss: (e) =>
|
|
168
|
+
}), w = Object.assign((e, t) => S.add(e, t), {
|
|
169
|
+
success: C("success"),
|
|
170
|
+
error: C("error"),
|
|
171
|
+
warning: C("warning"),
|
|
172
|
+
info: C("info"),
|
|
173
|
+
loading: C("loading"),
|
|
174
|
+
update: (e, t, n) => S.update(e, t, n),
|
|
175
|
+
dismiss: (e) => S.dismiss(e, "imperative"),
|
|
175
176
|
promise(e, t, n) {
|
|
176
|
-
let r =
|
|
177
|
+
let r = S.add(t.loading, {
|
|
177
178
|
...n,
|
|
178
179
|
id: n?.id,
|
|
179
180
|
kind: "loading"
|
|
180
181
|
}), i = (e, t) => typeof e == "function" ? e(t) : e;
|
|
181
|
-
return e.then((e) =>
|
|
182
|
+
return e.then((e) => S.update(r, i(t.success, e), { kind: "success" }), (e) => S.update(r, i(t.error, e), { kind: "error" })), e;
|
|
182
183
|
}
|
|
183
|
-
}),
|
|
184
|
+
}), T = {
|
|
184
185
|
"top-start": "topStart",
|
|
185
186
|
"top-center": "topCenter",
|
|
186
187
|
"top-end": "topEnd",
|
|
@@ -188,49 +189,49 @@ var b = y(), x = (e) => (t, n) => b.add(t, {
|
|
|
188
189
|
"bottom-center": "bottomCenter",
|
|
189
190
|
"bottom-end": "bottomEnd"
|
|
190
191
|
};
|
|
191
|
-
function
|
|
192
|
+
function E(e, t) {
|
|
192
193
|
let n = t.toLowerCase().split("+"), r = n[n.length - 1], i = new Set(n.slice(0, -1));
|
|
193
194
|
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");
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
-
let { toast: t, store: n, fromTop:
|
|
197
|
-
if (
|
|
198
|
-
|
|
196
|
+
function D(e) {
|
|
197
|
+
let { toast: t, store: n, fromTop: r, closeLabel: i } = e, { mounted: o, ref: l, props: d } = u({ present: t.open }), f = c("toaster");
|
|
198
|
+
if (a(() => {
|
|
199
|
+
o || n.remove(t.id);
|
|
199
200
|
}, [
|
|
200
|
-
|
|
201
|
+
o,
|
|
201
202
|
n,
|
|
202
203
|
t.id
|
|
203
|
-
]), !
|
|
204
|
+
]), !o) return null;
|
|
204
205
|
let h = t.action, g = () => {
|
|
205
|
-
h?.onClick(), h?.closeOnClick === !1 ?
|
|
206
|
+
h?.onClick(), h?.closeOnClick === !1 ? f("action", t.message, {
|
|
206
207
|
reason: "action",
|
|
207
208
|
id: t.id,
|
|
208
209
|
kind: t.kind,
|
|
209
210
|
content: ["value"]
|
|
210
211
|
}) : n.dismiss(t.id, "action");
|
|
211
212
|
};
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
ref:
|
|
213
|
+
return /* @__PURE__ */ m(s, {
|
|
214
|
+
ref: l,
|
|
214
215
|
component: "toaster.toast",
|
|
215
216
|
variant: {
|
|
216
217
|
[t.kind]: t.kind !== "default",
|
|
217
|
-
fromTop:
|
|
218
|
+
fromTop: r
|
|
218
219
|
},
|
|
219
220
|
props: {
|
|
220
221
|
...t.kind === "error" ? { role: "alert" } : {},
|
|
221
222
|
"data-toast-id": t.id,
|
|
222
|
-
...
|
|
223
|
+
...d
|
|
223
224
|
},
|
|
224
225
|
children: [
|
|
225
|
-
/* @__PURE__ */
|
|
226
|
+
/* @__PURE__ */ p(s, {
|
|
226
227
|
component: "toaster.message",
|
|
227
228
|
children: t.message
|
|
228
229
|
}),
|
|
229
|
-
t.description !== void 0 && /* @__PURE__ */
|
|
230
|
+
t.description !== void 0 && /* @__PURE__ */ p(s, {
|
|
230
231
|
component: "toaster.description",
|
|
231
232
|
children: t.description
|
|
232
233
|
}),
|
|
233
|
-
h && /* @__PURE__ */
|
|
234
|
+
h && /* @__PURE__ */ p(s, {
|
|
234
235
|
tag: "button",
|
|
235
236
|
component: "toaster.action",
|
|
236
237
|
props: {
|
|
@@ -239,94 +240,95 @@ function T(e) {
|
|
|
239
240
|
},
|
|
240
241
|
children: h.label
|
|
241
242
|
}),
|
|
242
|
-
t.dismissible && /* @__PURE__ */
|
|
243
|
+
t.dismissible && /* @__PURE__ */ p(s, {
|
|
243
244
|
tag: "button",
|
|
244
245
|
component: "toaster.close",
|
|
245
246
|
props: {
|
|
246
247
|
type: "button",
|
|
247
|
-
"aria-label":
|
|
248
|
+
"aria-label": i,
|
|
248
249
|
onClick: () => n.dismiss(t.id, "close")
|
|
249
250
|
}
|
|
250
251
|
})
|
|
251
252
|
]
|
|
252
253
|
});
|
|
253
254
|
}
|
|
254
|
-
function
|
|
255
|
-
let { position:
|
|
255
|
+
function O(e, o) {
|
|
256
|
+
let { position: c = "bottom-end", limit: u = 3, duration: _ = 5e3, label: v = "Notifications", closeLabel: y = "Close", overflowLabel: b = (e) => `+${e} more`, hotkey: x = "F6", store: C = S, props: w, ...O } = e, k = g(C.subscribe, C.getSnapshot, C.getServerSnapshot), A = l(), j = i(!A), M = f(null), N = d((e) => {
|
|
257
|
+
M.current = e, n(o, e);
|
|
258
|
+
}, [o]), P = f(null), F = f({
|
|
256
259
|
hovered: !1,
|
|
257
260
|
focused: !1,
|
|
258
261
|
hidden: !1
|
|
259
|
-
}),
|
|
260
|
-
let { hovered: e, focused: t, hidden: n } =
|
|
261
|
-
e || t || n ?
|
|
262
|
-
}, [
|
|
263
|
-
|
|
264
|
-
let
|
|
265
|
-
!
|
|
266
|
-
}),
|
|
267
|
-
let e =
|
|
262
|
+
}), I = d(() => {
|
|
263
|
+
let { hovered: e, focused: t, hidden: n } = F.current;
|
|
264
|
+
e || t || n ? C.pause() : C.resume();
|
|
265
|
+
}, [C]);
|
|
266
|
+
a(() => C.setLimit(u), [C, u]), a(() => C.setDefaultDuration(_), [C, _]), a(() => {
|
|
267
|
+
let e = M.current;
|
|
268
|
+
!A || !t() || !e || !e.isConnected || e.matches(":popover-open") || e.showPopover();
|
|
269
|
+
}), a(() => {
|
|
270
|
+
let e = r();
|
|
268
271
|
if (!e) return;
|
|
269
|
-
let
|
|
272
|
+
let t = new AbortController();
|
|
270
273
|
return e.addEventListener("visibilitychange", () => {
|
|
271
|
-
|
|
272
|
-
}, { signal:
|
|
273
|
-
}, [
|
|
274
|
-
let e =
|
|
275
|
-
if (!
|
|
276
|
-
let
|
|
274
|
+
F.current.hidden = e.hidden, I();
|
|
275
|
+
}, { signal: t.signal }), () => t.abort();
|
|
276
|
+
}, [I]), a(() => {
|
|
277
|
+
let e = r();
|
|
278
|
+
if (!x || !e) return;
|
|
279
|
+
let t = new AbortController();
|
|
277
280
|
return e.addEventListener("keydown", (t) => {
|
|
278
|
-
!
|
|
279
|
-
}, { signal:
|
|
280
|
-
}, [
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
}, I = (e) => {
|
|
284
|
-
P(e.relatedTarget) || (M.current.hovered = !1, N());
|
|
285
|
-
}, L = (e) => {
|
|
286
|
-
M.current.focused = !0, N(), P(e.relatedTarget) || (j.current = e.relatedTarget);
|
|
287
|
-
}, R = (e) => {
|
|
288
|
-
P(e.relatedTarget) || (M.current.focused = !1, N());
|
|
281
|
+
!E(t, x) || !M.current || (t.preventDefault(), P.current = e.activeElement, M.current.focus());
|
|
282
|
+
}, { signal: t.signal }), () => t.abort();
|
|
283
|
+
}, [x]);
|
|
284
|
+
let L = (e) => !!e && !!M.current?.contains(e), R = () => {
|
|
285
|
+
F.current.hovered = !0, I();
|
|
289
286
|
}, z = (e) => {
|
|
287
|
+
L(e.relatedTarget) || (F.current.hovered = !1, I());
|
|
288
|
+
}, B = (e) => {
|
|
289
|
+
F.current.focused = !0, I(), L(e.relatedTarget) || (P.current = e.relatedTarget);
|
|
290
|
+
}, V = (e) => {
|
|
291
|
+
L(e.relatedTarget) || (F.current.focused = !1, I());
|
|
292
|
+
}, H = (e) => {
|
|
290
293
|
if (e.key !== "Escape") return;
|
|
291
294
|
let t = (e.target.closest?.("[data-toast-id]"))?.getAttribute("data-toast-id");
|
|
292
|
-
t &&
|
|
293
|
-
},
|
|
295
|
+
t && C.dismiss(t, "close"), C.getSnapshot().toasts.some((e) => e.open) ? M.current?.focus() : P.current?.focus();
|
|
296
|
+
}, U = c.startsWith("top"), W = k.toasts.filter((e) => e.visible), G = U ? [...W].reverse() : W, K = k.overflow > 0 && /* @__PURE__ */ p(s, {
|
|
294
297
|
component: "toaster.overflow",
|
|
295
|
-
children:
|
|
296
|
-
}),
|
|
298
|
+
children: b(k.overflow)
|
|
299
|
+
}), q = /* @__PURE__ */ m(s, {
|
|
297
300
|
tag: "section",
|
|
298
|
-
ref:
|
|
301
|
+
ref: N,
|
|
299
302
|
component: "toaster",
|
|
300
|
-
...
|
|
301
|
-
variant: [
|
|
303
|
+
...O,
|
|
304
|
+
variant: [O.variant, { [T[c]]: !0 }],
|
|
302
305
|
props: {
|
|
303
|
-
...
|
|
306
|
+
...A ? { popover: "manual" } : {},
|
|
304
307
|
"aria-live": "polite",
|
|
305
308
|
"aria-atomic": "false",
|
|
306
309
|
"aria-relevant": "additions text",
|
|
307
|
-
"aria-label":
|
|
310
|
+
"aria-label": v,
|
|
308
311
|
tabIndex: -1,
|
|
309
|
-
...
|
|
310
|
-
onPointerOver:
|
|
311
|
-
onPointerOut:
|
|
312
|
-
onFocus:
|
|
313
|
-
onBlur:
|
|
314
|
-
onKeyDown:
|
|
312
|
+
...w,
|
|
313
|
+
onPointerOver: R,
|
|
314
|
+
onPointerOut: z,
|
|
315
|
+
onFocus: B,
|
|
316
|
+
onBlur: V,
|
|
317
|
+
onKeyDown: H
|
|
315
318
|
},
|
|
316
319
|
children: [
|
|
317
|
-
!
|
|
318
|
-
|
|
320
|
+
!U && K,
|
|
321
|
+
G.map((e) => /* @__PURE__ */ p(D, {
|
|
319
322
|
toast: e,
|
|
320
|
-
store:
|
|
321
|
-
fromTop:
|
|
322
|
-
closeLabel:
|
|
323
|
+
store: C,
|
|
324
|
+
fromTop: U,
|
|
325
|
+
closeLabel: y
|
|
323
326
|
}, e.id)),
|
|
324
|
-
|
|
327
|
+
U && K
|
|
325
328
|
]
|
|
326
329
|
});
|
|
327
|
-
return
|
|
330
|
+
return A ? q : j ? h(q, j) : null;
|
|
328
331
|
}
|
|
329
|
-
var
|
|
330
|
-
D.displayName = "Toaster";
|
|
332
|
+
var k = e(O, "Toaster");
|
|
331
333
|
//#endregion
|
|
332
|
-
export {
|
|
334
|
+
export { x as createToastStore, k as default, S as defaultToastStore, w as toast };
|
package/components/tooltip.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("../behavior.cjs"),r=require("../identity.cjs"),i=require("./overlay.cjs"),a=require("./presence.cjs");let o=require("react"),s=require("react/jsx-runtime");function c(e,c){let{content:l,children:u,open:d,defaultOpen:f=!1,onOpenChange:p,openDelay:m=300,closeDelay:h=150,side:g=`bottom`,align:_=`center`,offset:v=1,flip:y=!0,props:b,...x}=e,S=r.t(`tooltip`),C=x.id??S,[w,T]=n.i({value:d,defaultValue:f,onChange:p}),[E,D]=(0,o.useState)(null),O=(0,o.useRef)(null),k=(0,o.useCallback)(e=>{O.current=e,t.l(c,e)},[c]),A=(0,o.useRef)(void 0),j=(0,o.useRef)(!1),M=(0,o.useRef)(!1),N=(0,o.useRef)(!1),P=(0,o.useRef)(!1),F=(0,o.useCallback)(()=>{clearTimeout(A.current),A.current=void 0},[]),I=(0,o.useCallback)((e,t)=>{if(F(),e<=0){t();return}A.current=setTimeout(()=>{A.current=void 0,t()},e)},[F]),L=(0,o.useCallback)((e,t)=>{I(h,()=>{j.current||M.current||N.current||T(!1,{reason:e,event:t})})},[h,I,T]);n.r({enabled:w,outsidePointer:!1,inside:[O],onDismiss:(e,t)=>{F(),P.current=!0,T(!1,{reason:e,event:t})}}),(0,o.useEffect)(()=>F,[F]);let R=w&&l!=null,z=n.a(e=>{j.current=!0,!P.current&&I(m,()=>T(!0,{reason:`hover`,event:e}))}),B=n.a(e=>{j.current=!1,P.current=!1,L(`pointer-leave`,e)}),V=n.a(e=>{N.current=!0,F(),T(!0,{reason:`focus`,event:e})}),H=n.a(e=>{N.current=!1,P.current=!1,L(`blur`,e)}),U=n.a(()=>{M.current=!0,F()}),W=n.a(e=>{M.current=!1,L(`pointer-leave`,e)}),G=(0,o.useMemo)(()=>({ref:D,props:{"aria-describedby":R?C:void 0,onPointerEnter:z,onPointerLeave:B,onFocus:V,onBlur:H}}),[H,z,V,B,R,C]);return(0,s.jsxs)(s.Fragment,{children:[u(G),(0,s.jsx)(a.default,{present:R,children:e=>(0,s.jsx)(i.default,{ref:k,contentRef:e.ref,anchor:E,side:g,align:_,offset:v,flip:y,matchWidth:!1,component:`tooltip`,...x,variant:[x.variant,{closed:!e.present}],id:C,props:{role:`tooltip`,...e.props,...b,onPointerEnter:U,onPointerLeave:W},children:l})})]})}var l=e.f(c,`Tooltip`);exports.default=l;
|
package/components/tooltip.d.ts
CHANGED
|
@@ -61,38 +61,5 @@ interface Props<TKey extends keyof ComponentsAndVariants> extends TooltipBoxProp
|
|
|
61
61
|
/** Whether a side with no room may be swapped for its opposite. Default `true`. */
|
|
62
62
|
flip?: boolean;
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
* The APG tooltip: a description that appears on hover *and* on focus and stays until the user is done
|
|
66
|
-
* with it.
|
|
67
|
-
*
|
|
68
|
-
* ```tsx
|
|
69
|
-
* <Tooltip content="Deletes the row for good">{(trigger) => <Button {...trigger}>Delete</Button>}</Tooltip>
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* The trigger is a render prop rather than a cloned child: cloning would have to guess where a child
|
|
73
|
-
* wants its DOM attributes (Box takes a `props` bag, a `<button>` takes them on top), and guessing wrong
|
|
74
|
-
* on `aria-describedby` costs the thing the pattern is for. The component owns `role="tooltip"`, the
|
|
75
|
-
* `aria-describedby`, and WCAG 1.4.13's three obligations — dismissible with Escape without moving focus,
|
|
76
|
-
* hoverable, and never closed on a timer. Focus never enters it: a focusable tooltip is a mislabelled dialog.
|
|
77
|
-
*
|
|
78
|
-
* @pattern https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/
|
|
79
|
-
* @a11y `role="tooltip"` on the bubble and `aria-describedby` on the trigger, so the description is read
|
|
80
|
-
* as part of the control rather than as text that happens to be nearby.
|
|
81
|
-
* @a11y WCAG 1.4.13, all three parts: Escape dismisses it without moving focus, the pointer can travel
|
|
82
|
-
* onto the bubble and read it, and nothing hides it on a timer.
|
|
83
|
-
* @a11y The bubble is never in the tab order — a focusable tooltip is a dialog with the wrong role — and
|
|
84
|
-
* it renders nothing at all while `content` is empty.
|
|
85
|
-
* @keyboard Tab — Shows it as soon as the trigger has focus, ignoring `openDelay`: a keyboard user asked
|
|
86
|
-
* for it by arriving.
|
|
87
|
-
* @keyboard Escape — Hides it, leaving focus on the trigger. It stays hidden until the pointer or focus
|
|
88
|
-
* leaves and comes back.
|
|
89
|
-
* @keyboard Tab, again — Reaches the next control, and the tooltip closes behind it.
|
|
90
|
-
* @keyboard (Pointer) Resting on the trigger — Shows it after `openDelay`, 300 ms by default: sweeping
|
|
91
|
-
* across a toolbar should not light every control up.
|
|
92
|
-
* @keyboard (Pointer) Leaving the trigger — Hides it after `closeDelay`, 150 ms — unless the pointer
|
|
93
|
-
* lands on the tooltip itself.
|
|
94
|
-
* @keyboard (Pointer) Moving onto the tooltip — Keeps it open for as long as the pointer is there, so a
|
|
95
|
-
* long description can be read or selected.
|
|
96
|
-
*/
|
|
97
|
-
declare function Tooltip<TKey extends keyof ComponentsAndVariants = 'tooltip'>(props: Props<TKey>): import("react").JSX.Element;
|
|
64
|
+
declare const Tooltip: <TKey extends keyof ComponentsAndVariants = "tooltip">(props: Props<TKey>) => React.ReactNode;
|
|
98
65
|
export default Tooltip;
|