@rinzai/zen 0.11.0 → 0.13.0
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/README.md +37 -7
- package/dist/accordion/index.d.ts +41 -0
- package/dist/accordion/index.d.ts.map +1 -0
- package/dist/accordion/index.js +81 -0
- package/dist/animated-number/index.d.ts +3 -2
- package/dist/animated-number/index.d.ts.map +1 -1
- package/dist/animated-number/index.js +40 -38
- package/dist/avatar/index.d.ts +7 -2
- package/dist/avatar/index.d.ts.map +1 -1
- package/dist/avatar/index.js +17 -11
- package/dist/backdrop/index.d.ts +4 -4
- package/dist/backdrop/index.d.ts.map +1 -1
- package/dist/backdrop/index.js +41 -39
- package/dist/badge/index.d.ts +4 -2
- package/dist/badge/index.d.ts.map +1 -1
- package/dist/badge/index.js +20 -11
- package/dist/base.css +4 -0
- package/dist/breadcrumbs/index.d.ts +1 -1
- package/dist/breadcrumbs/index.d.ts.map +1 -1
- package/dist/breadcrumbs/index.js +25 -24
- package/dist/button/index.d.ts +3 -3
- package/dist/button/index.d.ts.map +1 -1
- package/dist/button/index.js +16 -11
- package/dist/button-group/index.d.ts +13 -0
- package/dist/button-group/index.d.ts.map +1 -0
- package/dist/button-group/index.js +14 -0
- package/dist/calendar/index.d.ts +15 -8
- package/dist/calendar/index.d.ts.map +1 -1
- package/dist/calendar/index.js +97 -91
- package/dist/calendar-heatmap/index.d.ts +7 -5
- package/dist/calendar-heatmap/index.d.ts.map +1 -1
- package/dist/calendar-heatmap/index.js +32 -30
- package/dist/canvas/geometry.js +0 -1
- package/dist/canvas/index.d.ts +6 -6
- package/dist/canvas/index.d.ts.map +1 -1
- package/dist/canvas/index.js +135 -133
- package/dist/carousel/index.d.ts +27 -0
- package/dist/carousel/index.d.ts.map +1 -0
- package/dist/carousel/index.js +162 -0
- package/dist/chart/index.d.ts +5 -4
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.js +137 -135
- package/dist/chart/palette.js +0 -1
- package/dist/checkbox/index.d.ts +3 -3
- package/dist/checkbox/index.d.ts.map +1 -1
- package/dist/checkbox/index.js +33 -30
- package/dist/chip/index.js +1 -1
- package/dist/code-block/index.d.ts.map +1 -1
- package/dist/code-block/index.js +27 -25
- package/dist/code-input/index.d.ts.map +1 -1
- package/dist/code-input/index.js +30 -24
- package/dist/collapse/index.d.ts +4 -3
- package/dist/collapse/index.d.ts.map +1 -1
- package/dist/collapse/index.js +42 -39
- package/dist/color-picker/index.d.ts +14 -7
- package/dist/color-picker/index.d.ts.map +1 -1
- package/dist/color-picker/index.js +139 -128
- package/dist/combobox/index.d.ts +14 -6
- package/dist/combobox/index.d.ts.map +1 -1
- package/dist/combobox/index.js +158 -146
- package/dist/command-palette/index.d.ts +4 -3
- package/dist/command-palette/index.d.ts.map +1 -1
- package/dist/command-palette/index.js +60 -57
- package/dist/confirm-dialog/index.d.ts +6 -7
- package/dist/confirm-dialog/index.d.ts.map +1 -1
- package/dist/confirm-dialog/index.js +20 -16
- package/dist/date-picker/index.d.ts +23 -14
- package/dist/date-picker/index.d.ts.map +1 -1
- package/dist/date-picker/index.js +109 -93
- package/dist/dialog/index.d.ts +3 -4
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +58 -55
- package/dist/disclosure/index.d.ts +8 -0
- package/dist/disclosure/index.d.ts.map +1 -1
- package/dist/disclosure/index.js +31 -32
- package/dist/editable-cell/index.d.ts +4 -5
- package/dist/editable-cell/index.d.ts.map +1 -1
- package/dist/editable-cell/index.js +23 -22
- package/dist/field/index.d.ts +8 -8
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +20 -18
- package/dist/filter-bar/index.d.ts +2 -2
- package/dist/filter-bar/index.d.ts.map +1 -1
- package/dist/filter-bar/index.js +38 -36
- package/dist/header/index.d.ts +1 -1
- package/dist/header/index.d.ts.map +1 -1
- package/dist/header/index.js +13 -11
- package/dist/hover-card/index.d.ts +32 -0
- package/dist/hover-card/index.d.ts.map +1 -0
- package/dist/hover-card/index.js +84 -0
- package/dist/icon-picker/index.d.ts +16 -5
- package/dist/icon-picker/index.d.ts.map +1 -1
- package/dist/icon-picker/index.js +42 -47
- package/dist/icons/micro/plus.d.ts +3 -0
- package/dist/icons/micro/plus.d.ts.map +1 -0
- package/dist/icons/micro/plus.js +17 -0
- package/dist/index.d.ts +37 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/input/index.d.ts +5 -1
- package/dist/input/index.d.ts.map +1 -1
- package/dist/input/index.js +9 -9
- package/dist/input-group/index.d.ts +4 -1
- package/dist/input-group/index.d.ts.map +1 -1
- package/dist/input-group/index.js +14 -14
- package/dist/keypad/index.d.ts +9 -7
- package/dist/keypad/index.d.ts.map +1 -1
- package/dist/keypad/index.js +22 -19
- package/dist/lib.js +112 -97
- package/dist/load-more/index.d.ts +4 -2
- package/dist/load-more/index.d.ts.map +1 -1
- package/dist/load-more/index.js +26 -23
- package/dist/locale-provider/index.d.ts +23 -0
- package/dist/locale-provider/index.d.ts.map +1 -0
- package/dist/locale-provider/index.js +35 -0
- package/dist/menu/index.d.ts +62 -9
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +371 -128
- package/dist/meter/index.d.ts +2 -2
- package/dist/meter/index.d.ts.map +1 -1
- package/dist/meter/index.js +4 -4
- package/dist/money-input/index.d.ts +20 -10
- package/dist/money-input/index.d.ts.map +1 -1
- package/dist/money-input/index.js +199 -190
- package/dist/month-picker/index.d.ts +17 -10
- package/dist/month-picker/index.d.ts.map +1 -1
- package/dist/month-picker/index.js +97 -86
- package/dist/navigation-menu/index.d.ts +42 -0
- package/dist/navigation-menu/index.d.ts.map +1 -0
- package/dist/navigation-menu/index.js +144 -0
- package/dist/number-field/index.d.ts +34 -0
- package/dist/number-field/index.d.ts.map +1 -0
- package/dist/number-field/index.js +119 -0
- package/dist/page-header/index.d.ts +4 -3
- package/dist/page-header/index.d.ts.map +1 -1
- package/dist/page-header/index.js +2 -1
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/index.d.ts.map +1 -1
- package/dist/pagination/index.js +35 -33
- package/dist/progress-ring/index.d.ts +4 -3
- package/dist/progress-ring/index.d.ts.map +1 -1
- package/dist/progress-ring/index.js +11 -10
- package/dist/radio-cards/index.d.ts +9 -5
- package/dist/radio-cards/index.d.ts.map +1 -1
- package/dist/radio-cards/index.js +26 -24
- package/dist/radio-group/index.d.ts +9 -8
- package/dist/radio-group/index.d.ts.map +1 -1
- package/dist/radio-group/index.js +35 -34
- package/dist/range-slider/index.d.ts +10 -4
- package/dist/range-slider/index.d.ts.map +1 -1
- package/dist/range-slider/index.js +43 -31
- package/dist/repeat-picker/index.d.ts +13 -6
- package/dist/repeat-picker/index.d.ts.map +1 -1
- package/dist/repeat-picker/index.js +73 -61
- package/dist/resizable/index.d.ts +29 -0
- package/dist/resizable/index.d.ts.map +1 -0
- package/dist/resizable/index.js +135 -0
- package/dist/segmented/index.d.ts +8 -5
- package/dist/segmented/index.d.ts.map +1 -1
- package/dist/segmented/index.js +36 -34
- package/dist/select/index.d.ts +9 -3
- package/dist/select/index.d.ts.map +1 -1
- package/dist/select/index.js +99 -96
- package/dist/separator/index.d.ts +14 -0
- package/dist/separator/index.d.ts.map +1 -0
- package/dist/separator/index.js +15 -0
- package/dist/side-nav/index.js +1 -1
- package/dist/skeleton/index.d.ts +4 -4
- package/dist/skeleton/index.d.ts.map +1 -1
- package/dist/skeleton/index.js +4 -3
- package/dist/slider/index.d.ts +6 -3
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +29 -23
- package/dist/sortable/index.d.ts +10 -20
- package/dist/sortable/index.d.ts.map +1 -1
- package/dist/sortable/index.js +72 -134
- package/dist/sortable/shared.d.ts +56 -0
- package/dist/sortable/shared.d.ts.map +1 -0
- package/dist/sortable/shared.js +104 -0
- package/dist/sortable/tree-model.d.ts +46 -0
- package/dist/sortable/tree-model.d.ts.map +1 -0
- package/dist/sortable/tree-model.js +87 -0
- package/dist/sortable/tree.d.ts +31 -0
- package/dist/sortable/tree.d.ts.map +1 -0
- package/dist/sortable/tree.js +150 -0
- package/dist/sparkline/index.d.ts +1 -1
- package/dist/sparkline/index.d.ts.map +1 -1
- package/dist/sparkline/index.js +26 -25
- package/dist/spinner/index.d.ts +4 -3
- package/dist/spinner/index.d.ts.map +1 -1
- package/dist/spinner/index.js +2 -1
- package/dist/status-pill/index.d.ts.map +1 -1
- package/dist/status-pill/index.js +1 -1
- package/dist/stepper/index.d.ts +1 -1
- package/dist/stepper/index.d.ts.map +1 -1
- package/dist/stepper/index.js +31 -30
- package/dist/tab-bar/index.js +1 -1
- package/dist/table/index.d.ts +5 -5
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +66 -64
- package/dist/table/selection.d.ts +2 -2
- package/dist/table/selection.d.ts.map +1 -1
- package/dist/table/selection.js +41 -38
- package/dist/table/swipe.d.ts +1 -1
- package/dist/table/swipe.d.ts.map +1 -1
- package/dist/table/swipe.js +1 -1
- package/dist/table-of-contents/index.d.ts +4 -2
- package/dist/table-of-contents/index.d.ts.map +1 -1
- package/dist/table-of-contents/index.js +27 -25
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +90 -88
- package/dist/tag-input/index.d.ts +3 -1
- package/dist/tag-input/index.d.ts.map +1 -1
- package/dist/tag-input/index.js +61 -52
- package/dist/theme-toggle/index.d.ts +9 -8
- package/dist/theme-toggle/index.d.ts.map +1 -1
- package/dist/theme-toggle/index.js +30 -28
- package/dist/theme.css +90 -12
- package/dist/time-field/index.d.ts +31 -0
- package/dist/time-field/index.d.ts.map +1 -0
- package/dist/time-field/index.js +175 -0
- package/dist/timeline/index.js +1 -1
- package/dist/toast/index.d.ts +1 -1
- package/dist/toast/index.d.ts.map +1 -1
- package/dist/toast/index.js +127 -125
- package/dist/toggle/index.d.ts +2 -2
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toggle/index.js +8 -6
- package/dist/toggle-group/index.d.ts +35 -0
- package/dist/toggle-group/index.d.ts.map +1 -0
- package/dist/toggle-group/index.js +53 -0
- package/dist/toolbar/index.d.ts +19 -0
- package/dist/toolbar/index.d.ts.map +1 -0
- package/dist/toolbar/index.js +36 -0
- package/dist/tooltip/index.d.ts.map +1 -1
- package/dist/tooltip/index.js +40 -74
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +105 -102
- package/dist/trend/index.d.ts +2 -2
- package/dist/trend/index.d.ts.map +1 -1
- package/dist/trend/index.js +20 -19
- package/dist/utils/color.js +0 -1
- package/dist/utils/cva.js +0 -1
- package/dist/utils/cx.js +0 -1
- package/dist/utils/date.d.ts +6 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +1 -2
- package/dist/utils/direction.d.ts +7 -0
- package/dist/utils/direction.d.ts.map +1 -0
- package/dist/utils/direction.js +6 -0
- package/dist/utils/form-value.d.ts +15 -0
- package/dist/utils/form-value.d.ts.map +1 -0
- package/dist/utils/form-value.js +29 -0
- package/dist/utils/fx.js +0 -1
- package/dist/utils/merge.js +0 -1
- package/dist/utils/messages.d.ts +137 -0
- package/dist/utils/messages.d.ts.map +1 -0
- package/dist/utils/messages.js +133 -0
- package/dist/utils/money.js +0 -1
- package/dist/utils/month.js +0 -1
- package/dist/utils/motion.js +0 -1
- package/dist/utils/refs.d.ts +6 -0
- package/dist/utils/refs.d.ts.map +1 -0
- package/dist/utils/refs.js +13 -0
- package/dist/utils/repeat.d.ts +3 -1
- package/dist/utils/repeat.d.ts.map +1 -1
- package/dist/utils/repeat.js +28 -25
- package/dist/utils/roving.d.ts +17 -0
- package/dist/utils/roving.d.ts.map +1 -0
- package/dist/utils/roving.js +35 -0
- package/dist/utils/section-link.js +0 -1
- package/dist/utils/slot.d.ts.map +1 -1
- package/dist/utils/slot.js +7 -11
- package/dist/utils/status-icons.js +7 -7
- package/dist/utils/styles.d.ts +9 -2
- package/dist/utils/styles.d.ts.map +1 -1
- package/dist/utils/styles.js +6 -3
- package/dist/utils/theme-wave.js +0 -1
- package/dist/utils/theme.js +0 -1
- package/dist/utils/useAnchoredPopup.d.ts +7 -4
- package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopup.js +18 -11
- package/dist/utils/useControllable.d.ts +9 -0
- package/dist/utils/useControllable.d.ts.map +1 -0
- package/dist/utils/useControllable.js +15 -0
- package/dist/utils/useHoverPopup.d.ts +39 -0
- package/dist/utils/useHoverPopup.d.ts.map +1 -0
- package/dist/utils/useHoverPopup.js +64 -0
- package/dist/zen.css +1 -1
- package/package.json +1 -1
package/dist/toast/index.js
CHANGED
|
@@ -1,98 +1,100 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx as e } from "../utils/cx.js";
|
|
3
3
|
import { useGraphicsMode as t } from "../utils/graphics.js";
|
|
4
|
-
import {
|
|
5
|
-
import a from "../
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
4
|
+
import { useMessages as n } from "../locale-provider/index.js";
|
|
5
|
+
import { AlertIcon as r, CheckIcon as i, InfoIcon as a } from "../utils/status-icons.js";
|
|
6
|
+
import o from "../icons/micro/x-mark.js";
|
|
7
|
+
import { createContext as s, useCallback as c, useContext as l, useEffect as u, useRef as d, useState as f } from "react";
|
|
8
8
|
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
+
import { createPortal as g } from "react-dom";
|
|
9
10
|
//#region packages/toast/index.tsx
|
|
10
|
-
var
|
|
11
|
-
function
|
|
11
|
+
var _ = 5e3, v = 3, y = 300, b = 14, x = .05, S = 10, C = 60, w = .45, T = s(null), E = s(null);
|
|
12
|
+
function D({ children: r, offset: i, viewportClassName: a }) {
|
|
13
|
+
let o = n();
|
|
12
14
|
t();
|
|
13
|
-
let [
|
|
14
|
-
|
|
15
|
-
let
|
|
15
|
+
let [s, l] = f([]), p = d(0), C = d(/* @__PURE__ */ new Map()), w = d(/* @__PURE__ */ new Set()), [D, O] = f([]), [A, j] = f(!1);
|
|
16
|
+
u(() => j(!0), []);
|
|
17
|
+
let N = c((e) => (O((t) => [...t, e]), () => O((t) => t.filter((t) => t !== e))), []), P = D.at(-1) ?? (A ? document.body : null), [F, I] = f({}), L = c((e, t) => I((n) => n[e] === t ? n : {
|
|
16
18
|
...n,
|
|
17
19
|
[e]: t
|
|
18
|
-
}), []), [
|
|
19
|
-
|
|
20
|
+
}), []), [R, z] = f(!1), [B, V] = f(!1), H = d(null), U = c((e) => {
|
|
21
|
+
H.current = e, k(e);
|
|
20
22
|
}, []);
|
|
21
|
-
|
|
23
|
+
u(() => {
|
|
22
24
|
let e = (e) => {
|
|
23
|
-
e.key === "F8" &&
|
|
25
|
+
e.key === "F8" && H.current?.querySelector(".zen__toast:not([inert])") && (e.preventDefault(), H.current.focus());
|
|
24
26
|
};
|
|
25
27
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
26
28
|
}, []);
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
+
let W = c((e, t = "fade") => {
|
|
30
|
+
l((n) => n.map((n) => n.id === e ? {
|
|
29
31
|
...n,
|
|
30
32
|
leaving: t
|
|
31
33
|
} : n)), setTimeout(() => {
|
|
32
|
-
|
|
34
|
+
l((t) => {
|
|
33
35
|
let n = t.filter((t) => t.id !== e);
|
|
34
|
-
return n.length ||
|
|
35
|
-
}),
|
|
36
|
-
},
|
|
37
|
-
}, []),
|
|
38
|
-
let a =
|
|
36
|
+
return n.length || z(!1), n;
|
|
37
|
+
}), I(({ [e]: t, ...n }) => n), C.current.delete(e), w.current.delete(e);
|
|
38
|
+
}, y);
|
|
39
|
+
}, []), G = c((e, { description: t, tone: n = "default", action: r, timeout: i } = {}) => {
|
|
40
|
+
let a = p.current++, o = {
|
|
39
41
|
id: a,
|
|
40
42
|
title: e,
|
|
41
43
|
description: t,
|
|
42
44
|
tone: n,
|
|
43
45
|
action: r,
|
|
44
|
-
timeout: i ?? (r ? 1e4 :
|
|
46
|
+
timeout: i ?? (r ? 1e4 : _)
|
|
45
47
|
};
|
|
46
|
-
return
|
|
47
|
-
}, []),
|
|
48
|
-
let t =
|
|
48
|
+
return l((e) => [...e, o]), a;
|
|
49
|
+
}, []), K = s.filter((e) => !e.leaving), q = (R || B) && K.length > 0, J = K.at(-1), Y = J ? F[J.id] : void 0, X = K.slice(-3), Z = q ? X.reduce((e, t) => e + (F[t.id] ?? 0), 0) + S * (X.length - 1) : (Y ?? 0) + b * (X.length - 1), Q = (e) => {
|
|
50
|
+
let t = K.filter((t) => t.id > e.id), n = t.length;
|
|
49
51
|
return {
|
|
50
52
|
index: n,
|
|
51
53
|
front: n === 0,
|
|
52
|
-
hidden: n >=
|
|
53
|
-
y:
|
|
54
|
-
scale:
|
|
55
|
-
height: !
|
|
54
|
+
hidden: n >= v,
|
|
55
|
+
y: q ? -(t.reduce((e, t) => e + (F[t.id] ?? 0), 0) + S * n) : -14 * Math.min(n, 2),
|
|
56
|
+
scale: q ? 1 : 1 - x * Math.min(n, 2),
|
|
57
|
+
height: !q && n > 0 ? Y : void 0
|
|
56
58
|
};
|
|
57
59
|
};
|
|
58
|
-
return /* @__PURE__ */ h(
|
|
59
|
-
value:
|
|
60
|
-
children: [/* @__PURE__ */ m(
|
|
61
|
-
value:
|
|
62
|
-
children:
|
|
63
|
-
}),
|
|
64
|
-
ref:
|
|
60
|
+
return /* @__PURE__ */ h(T.Provider, {
|
|
61
|
+
value: G,
|
|
62
|
+
children: [/* @__PURE__ */ m(E.Provider, {
|
|
63
|
+
value: N,
|
|
64
|
+
children: r
|
|
65
|
+
}), P && g(/* @__PURE__ */ m("section", {
|
|
66
|
+
ref: U,
|
|
65
67
|
popover: "manual",
|
|
66
68
|
tabIndex: -1,
|
|
67
|
-
"aria-label":
|
|
68
|
-
"data-expanded":
|
|
69
|
-
onMouseEnter: () =>
|
|
70
|
-
onMouseLeave: () =>
|
|
71
|
-
onFocus: () =>
|
|
69
|
+
"aria-label": o.notifications,
|
|
70
|
+
"data-expanded": q || void 0,
|
|
71
|
+
onMouseEnter: () => z(!0),
|
|
72
|
+
onMouseLeave: () => z(!1),
|
|
73
|
+
onFocus: () => V(!0),
|
|
72
74
|
onBlur: (e) => {
|
|
73
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
75
|
+
e.currentTarget.contains(e.relatedTarget) || V(!1);
|
|
74
76
|
},
|
|
75
|
-
className: e("zen__toast-viewport fixed top-auto
|
|
77
|
+
className: e("zen__toast-viewport fixed top-auto end-4 bottom-[calc(var(--zen-toast-offset,1rem)+env(safe-area-inset-bottom))] start-auto z-50 m-0 w-[calc(100vw-2rem)] overflow-visible border-0 bg-transparent p-0 text-inherit outline-hidden md:bottom-5 md:w-[24rem]", "ease-out-soft transition-[height] duration-300", a),
|
|
76
78
|
style: {
|
|
77
|
-
height:
|
|
78
|
-
...
|
|
79
|
+
height: Z,
|
|
80
|
+
...i && { "--zen-toast-offset": i }
|
|
79
81
|
},
|
|
80
|
-
children:
|
|
82
|
+
children: s.map((e, t) => /* @__PURE__ */ m(M, {
|
|
81
83
|
toast: e,
|
|
82
|
-
layout:
|
|
84
|
+
layout: Q(e),
|
|
83
85
|
z: t + 1,
|
|
84
|
-
paused:
|
|
85
|
-
onDismiss:
|
|
86
|
-
onHeight:
|
|
87
|
-
clocks:
|
|
88
|
-
entered:
|
|
86
|
+
paused: q,
|
|
87
|
+
onDismiss: W,
|
|
88
|
+
onHeight: L,
|
|
89
|
+
clocks: C.current,
|
|
90
|
+
entered: w.current
|
|
89
91
|
}, e.id))
|
|
90
|
-
}),
|
|
92
|
+
}), P)]
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
|
-
function
|
|
94
|
-
let n =
|
|
95
|
-
|
|
95
|
+
function O(e, t) {
|
|
96
|
+
let n = l(E);
|
|
97
|
+
u(() => {
|
|
96
98
|
let r = e.current;
|
|
97
99
|
if (n && t && r) return n(r);
|
|
98
100
|
}, [
|
|
@@ -101,116 +103,116 @@ function D(e, t) {
|
|
|
101
103
|
e
|
|
102
104
|
]);
|
|
103
105
|
}
|
|
104
|
-
function
|
|
106
|
+
function k(e) {
|
|
105
107
|
if (e?.showPopover) try {
|
|
106
108
|
e.showPopover();
|
|
107
109
|
} catch {}
|
|
108
110
|
}
|
|
109
|
-
function
|
|
110
|
-
let e =
|
|
111
|
+
function A() {
|
|
112
|
+
let e = l(T);
|
|
111
113
|
if (!e) throw Error("useToast() needs a <ToastProvider> above it");
|
|
112
114
|
return e;
|
|
113
115
|
}
|
|
114
|
-
var
|
|
115
|
-
|
|
116
|
-
icon:
|
|
116
|
+
var j = {
|
|
117
|
+
positive: {
|
|
118
|
+
icon: i,
|
|
117
119
|
ring: "border-primary/30",
|
|
118
120
|
badge: "bg-primary/15 text-primary",
|
|
119
121
|
bar: "bg-primary",
|
|
120
122
|
glow: "shadow-[0_18px_50px_-18px_oklch(var(--glow)/calc(0.55*var(--glow-k)))]"
|
|
121
123
|
},
|
|
122
|
-
|
|
123
|
-
icon:
|
|
124
|
+
negative: {
|
|
125
|
+
icon: r,
|
|
124
126
|
ring: "border-destructive/40",
|
|
125
127
|
badge: "bg-destructive/10 text-destructive",
|
|
126
128
|
bar: "bg-destructive",
|
|
127
129
|
glow: "shadow-[0_18px_50px_-18px_oklch(var(--destructive)/calc(0.55*var(--glow-k)))]"
|
|
128
130
|
},
|
|
129
|
-
|
|
130
|
-
icon:
|
|
131
|
+
default: {
|
|
132
|
+
icon: a,
|
|
131
133
|
ring: "border-tint/10",
|
|
132
134
|
badge: "bg-tint/[0.08] text-foreground",
|
|
133
135
|
bar: "bg-muted-foreground",
|
|
134
136
|
glow: "shadow-[var(--toast-shadow)]"
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
|
-
function
|
|
138
|
-
let
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}, [
|
|
142
|
-
let [
|
|
143
|
-
|
|
144
|
-
if (!
|
|
145
|
-
let e = requestAnimationFrame(() => e = requestAnimationFrame(() =>
|
|
139
|
+
function M({ toast: t, layout: r, z: i, paused: a, onDismiss: s, onHeight: c, clocks: l, entered: g }) {
|
|
140
|
+
let _ = n(), v = j[t.tone] ?? j.default, y = v.icon, b = d(null), x = d(null), [S] = f(() => !g.has(t.id));
|
|
141
|
+
u(() => {
|
|
142
|
+
b.current?.isConnected && g.add(t.id);
|
|
143
|
+
}, [g, t.id]);
|
|
144
|
+
let [T, E] = f(!1);
|
|
145
|
+
u(() => {
|
|
146
|
+
if (!S) return;
|
|
147
|
+
let e = requestAnimationFrame(() => e = requestAnimationFrame(() => E(!0)));
|
|
146
148
|
return () => cancelAnimationFrame(e);
|
|
147
|
-
}, [
|
|
149
|
+
}, [S]), l.has(t.id) || l.set(t.id, {
|
|
148
150
|
spent: 0,
|
|
149
151
|
since: null
|
|
150
152
|
});
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
let e =
|
|
153
|
+
let D = l.get(t.id), [O] = f(() => D.spent + (D.since === null ? 0 : Date.now() - D.since));
|
|
154
|
+
u(() => {
|
|
155
|
+
let e = x.current;
|
|
154
156
|
if (!e) return;
|
|
155
|
-
let n = () =>
|
|
157
|
+
let n = () => c(t.id, e.offsetHeight);
|
|
156
158
|
n();
|
|
157
159
|
let r = new ResizeObserver(n);
|
|
158
160
|
return r.observe(e), () => r.disconnect();
|
|
159
|
-
}, [
|
|
160
|
-
if (!t.timeout ||
|
|
161
|
-
|
|
162
|
-
let e = setTimeout(() =>
|
|
161
|
+
}, [c, t.id]), u(() => {
|
|
162
|
+
if (!t.timeout || a || t.leaving) return;
|
|
163
|
+
D.since = Date.now();
|
|
164
|
+
let e = setTimeout(() => s(t.id), Math.max(0, t.timeout - D.spent));
|
|
163
165
|
return () => {
|
|
164
|
-
clearTimeout(e),
|
|
166
|
+
clearTimeout(e), D.since !== null && (D.spent += Date.now() - D.since), D.since = null;
|
|
165
167
|
};
|
|
166
168
|
}, [
|
|
167
|
-
|
|
169
|
+
a,
|
|
168
170
|
t.id,
|
|
169
171
|
t.timeout,
|
|
170
172
|
t.leaving,
|
|
171
|
-
|
|
172
|
-
|
|
173
|
+
s,
|
|
174
|
+
D
|
|
173
175
|
]);
|
|
174
|
-
let
|
|
175
|
-
t.leaving || e.button !== 0 || e.target.closest("button") || (
|
|
176
|
+
let k = d(null), A = (e) => {
|
|
177
|
+
t.leaving || e.button !== 0 || e.target.closest("button") || (k.current = {
|
|
176
178
|
x: e.clientX,
|
|
177
179
|
dx: 0,
|
|
178
180
|
t: e.timeStamp,
|
|
179
181
|
speed: 0
|
|
180
182
|
}, e.currentTarget.setPointerCapture(e.pointerId), e.currentTarget.dataset.swiping = "");
|
|
181
|
-
},
|
|
182
|
-
if (!
|
|
183
|
-
let t =
|
|
183
|
+
}, M = (e) => {
|
|
184
|
+
if (!k.current) return;
|
|
185
|
+
let t = k.current, n = e.clientX - t.x;
|
|
184
186
|
t.speed = (n - t.dx) / Math.max(1, e.timeStamp - t.t), t.dx = n, t.t = e.timeStamp, e.currentTarget.style.setProperty("--zen-swipe", `${n > 0 ? n : n / 6}px`);
|
|
185
|
-
},
|
|
186
|
-
let n =
|
|
187
|
-
n && (
|
|
187
|
+
}, N = (e) => {
|
|
188
|
+
let n = k.current;
|
|
189
|
+
n && (k.current = null, delete e.currentTarget.dataset.swiping, n.dx > C || n.dx > 0 && n.speed > w ? s(t.id, "swipe") : e.currentTarget.style.setProperty("--zen-swipe", "0px"));
|
|
188
190
|
};
|
|
189
191
|
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ h("div", {
|
|
190
|
-
ref:
|
|
191
|
-
role: t.tone === "
|
|
192
|
+
ref: b,
|
|
193
|
+
role: t.tone === "negative" ? "alert" : "status",
|
|
192
194
|
"aria-live": "off",
|
|
193
|
-
"data-front":
|
|
194
|
-
"data-behind": !
|
|
195
|
-
inert:
|
|
196
|
-
onPointerDown:
|
|
197
|
-
onPointerMove:
|
|
198
|
-
onPointerUp:
|
|
199
|
-
onPointerCancel:
|
|
200
|
-
className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "ease-out-soft transition-[transform,translate,opacity,height] duration-400 data-swiping:transition-none",
|
|
195
|
+
"data-front": r.front || void 0,
|
|
196
|
+
"data-behind": !r.front && r.height !== void 0 || void 0,
|
|
197
|
+
inert: r.hidden || !!t.leaving,
|
|
198
|
+
onPointerDown: A,
|
|
199
|
+
onPointerMove: M,
|
|
200
|
+
onPointerUp: N,
|
|
201
|
+
onPointerCancel: N,
|
|
202
|
+
className: e("zen__toast group glass glass-blur glow-edge text-card-foreground absolute! inset-x-0 bottom-0 origin-bottom touch-pan-y overflow-hidden rounded-2xl border select-none", "ease-out-soft transition-[transform,translate,opacity,height] duration-400 data-swiping:transition-none", S && "starting:translate-y-full starting:opacity-0", r.hidden && "opacity-0", t.leaving === "fade" && "translate-y-[35%] opacity-0", t.leaving === "swipe" && "translate-x-full opacity-0", v.ring, v.glow),
|
|
201
203
|
style: {
|
|
202
|
-
zIndex:
|
|
203
|
-
height:
|
|
204
|
-
transform: `translateX(var(--zen-swipe, 0px)) translateY(${
|
|
204
|
+
zIndex: i,
|
|
205
|
+
height: r.height,
|
|
206
|
+
transform: `translateX(var(--zen-swipe, 0px)) translateY(${r.y}px) scale(${r.scale})`
|
|
205
207
|
},
|
|
206
208
|
children: [/* @__PURE__ */ h("div", {
|
|
207
|
-
ref:
|
|
208
|
-
className: "flex items-start gap-3 p-3.5
|
|
209
|
+
ref: x,
|
|
210
|
+
className: "flex items-start gap-3 p-3.5 pe-10 transition-opacity duration-300 group-data-behind:opacity-0",
|
|
209
211
|
children: [
|
|
210
212
|
/* @__PURE__ */ m("span", {
|
|
211
|
-
className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full",
|
|
213
|
+
className: e("mt-0.5 grid size-8 shrink-0 place-items-center rounded-full", v.badge),
|
|
212
214
|
"aria-hidden": !0,
|
|
213
|
-
children: /* @__PURE__ */ m(
|
|
215
|
+
children: /* @__PURE__ */ m(y, { className: "size-4" })
|
|
214
216
|
}),
|
|
215
217
|
/* @__PURE__ */ h("div", {
|
|
216
218
|
className: "flex min-w-0 flex-1 flex-col gap-0.5 pt-0.5",
|
|
@@ -226,36 +228,36 @@ function j({ toast: t, layout: n, z: r, paused: i, onDismiss: o, onHeight: s, cl
|
|
|
226
228
|
t.action && /* @__PURE__ */ m("button", {
|
|
227
229
|
type: "button",
|
|
228
230
|
onClick: () => {
|
|
229
|
-
t.action?.onClick(),
|
|
231
|
+
t.action?.onClick(), s(t.id);
|
|
230
232
|
},
|
|
231
|
-
className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-
|
|
233
|
+
className: "border-tint/10 bg-tint/[0.06] hover:bg-tint/[0.12] focus-ring mt-2 cursor-pointer self-start rounded-lg border px-3 py-1 text-xs font-medium outline-hidden transition-colors",
|
|
232
234
|
children: t.action.label
|
|
233
235
|
})
|
|
234
236
|
]
|
|
235
237
|
}),
|
|
236
238
|
/* @__PURE__ */ m("button", {
|
|
237
239
|
type: "button",
|
|
238
|
-
"aria-label":
|
|
239
|
-
onClick: () =>
|
|
240
|
-
className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-
|
|
241
|
-
children: /* @__PURE__ */ m(
|
|
240
|
+
"aria-label": _.dismiss,
|
|
241
|
+
onClick: () => s(t.id),
|
|
242
|
+
className: "text-muted-foreground hover:bg-tint/[0.07] hover:text-foreground focus-ring absolute end-2.5 top-2.5 grid size-7 cursor-pointer place-items-center rounded-lg outline-hidden transition-colors",
|
|
243
|
+
children: /* @__PURE__ */ m(o, { className: "size-3.5" })
|
|
242
244
|
})
|
|
243
245
|
]
|
|
244
246
|
}), t.timeout > 0 && /* @__PURE__ */ m("span", {
|
|
245
247
|
"aria-hidden": !0,
|
|
246
|
-
className: e("zen__toast-timer absolute
|
|
248
|
+
className: e("zen__toast-timer absolute start-0 bottom-0 h-0.5 w-full origin-left opacity-60 rtl:origin-right transition-opacity group-data-behind:opacity-0", v.bar),
|
|
247
249
|
style: {
|
|
248
250
|
animationDuration: `${t.timeout}ms`,
|
|
249
|
-
animationDelay: `${-
|
|
250
|
-
animationPlayState:
|
|
251
|
+
animationDelay: `${-O}ms`,
|
|
252
|
+
animationPlayState: a ? "paused" : void 0
|
|
251
253
|
}
|
|
252
254
|
})]
|
|
253
255
|
}), /* @__PURE__ */ m("span", {
|
|
254
256
|
className: "sr-only",
|
|
255
|
-
"aria-live": t.tone === "
|
|
257
|
+
"aria-live": t.tone === "negative" ? "assertive" : "polite",
|
|
256
258
|
"aria-atomic": "true",
|
|
257
|
-
children:
|
|
259
|
+
children: T && [t.title, t.description].filter(Boolean).join(". ")
|
|
258
260
|
})] });
|
|
259
261
|
}
|
|
260
262
|
//#endregion
|
|
261
|
-
export {
|
|
263
|
+
export { D as default, A as useToast, O as useToastHost };
|
package/dist/toggle/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentProps } from 'react';
|
|
2
|
-
export interface ToggleProps extends Omit<ComponentProps<'input'>, '
|
|
3
|
-
|
|
2
|
+
export interface ToggleProps extends Omit<ComponentProps<'input'>, 'type'> {
|
|
3
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* On/off switch. A native checkbox with the switch role underneath, so forms
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/toggle/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/toggle/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,WAAY,SAAQ,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IACtE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,WAAW,+BA4ChD"}
|
package/dist/toggle/index.js
CHANGED
|
@@ -3,19 +3,21 @@ import { cx as e } from "../utils/cx.js";
|
|
|
3
3
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
4
4
|
//#region packages/toggle/index.tsx
|
|
5
5
|
function r(r) {
|
|
6
|
-
let { className: i, onChange: a,
|
|
6
|
+
let { className: i, onChange: a, onCheckedChange: o, onKeyDown: s, disabled: c, ...l } = r;
|
|
7
7
|
return /* @__PURE__ */ n("span", {
|
|
8
|
-
className: e("zen__toggle bg-tint/[0.06] relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-[color:oklch(var(--tint)/var(--zen-control-edge))] p-0.5", "has-
|
|
8
|
+
className: e("zen__toggle bg-tint/[0.06] relative inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border border-[color:oklch(var(--tint)/var(--zen-control-edge))] p-0.5", "has- transition-[background-color,box-shadow,border-color] duration-300 has-focus-ring", "has-checked:border-glow/60 has-checked:bg-glow/40 has-checked:shadow-[0_0_18px_-2px_oklch(var(--glow)/calc(0.8*var(--glow-k)))]", "has-disabled:cursor-not-allowed has-disabled:opacity-50", i),
|
|
9
9
|
children: [/* @__PURE__ */ t("input", {
|
|
10
10
|
type: "checkbox",
|
|
11
11
|
role: "switch",
|
|
12
12
|
className: "peer absolute inset-0 z-10 m-0 size-full cursor-pointer appearance-none rounded-full opacity-0 disabled:cursor-not-allowed",
|
|
13
|
-
disabled:
|
|
14
|
-
onChange: (e) =>
|
|
13
|
+
disabled: c,
|
|
14
|
+
onChange: (e) => {
|
|
15
|
+
a?.(e), o?.(e.target.checked);
|
|
16
|
+
},
|
|
15
17
|
onKeyDown: (e) => {
|
|
16
|
-
|
|
18
|
+
s?.(e), e.key === "Enter" && !e.defaultPrevented && (e.preventDefault(), e.currentTarget.click());
|
|
17
19
|
},
|
|
18
|
-
...
|
|
20
|
+
...l
|
|
19
21
|
}), /* @__PURE__ */ t("span", {
|
|
20
22
|
"aria-hidden": !0,
|
|
21
23
|
className: e("size-[1.125rem] rounded-full bg-[var(--zen-thumb-off)] shadow-md", "zen__toggle-thumb ease-out-soft transition-[translate,background-color] duration-300", "peer-checked:translate-x-5 peer-checked:bg-white")
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Buttons that stay pressed, in a row: any number of them (`multiple`, e.g.
|
|
4
|
+
* filters), or at most one, which can be released again. For exactly one
|
|
5
|
+
* always chosen, use Segmented. ←→ move between them, Home and End jump to
|
|
6
|
+
* the ends; Space or Enter presses.
|
|
7
|
+
*/
|
|
8
|
+
export default function ToggleGroup(props: ToggleGroupProps): import('react').JSX.Element;
|
|
9
|
+
/** One button of a ToggleGroup: text, an icon (give it an aria-label), or both. */
|
|
10
|
+
export declare function ToggleGroupItem({ value, className, onClick, ...rest }: ToggleGroupItemProps): import('react').JSX.Element;
|
|
11
|
+
interface ToggleGroupBaseProps extends Omit<ComponentProps<'div'>, 'defaultValue'> {
|
|
12
|
+
/** Form field name: each pressed item's value is submitted under it. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** The ToggleGroupItems. */
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export type ToggleGroupProps = ToggleGroupBaseProps & ({
|
|
18
|
+
/** At most one pressed (the default); pressing another releases it. */
|
|
19
|
+
multiple?: false;
|
|
20
|
+
/** The pressed item's value, or null for none, when you keep it. */
|
|
21
|
+
value?: string | null;
|
|
22
|
+
defaultValue?: string | null;
|
|
23
|
+
onValueChange?: (value: string | null) => void;
|
|
24
|
+
} | {
|
|
25
|
+
/** Any number pressed. */
|
|
26
|
+
multiple: true;
|
|
27
|
+
value?: readonly string[];
|
|
28
|
+
defaultValue?: readonly string[];
|
|
29
|
+
onValueChange?: (value: readonly string[]) => void;
|
|
30
|
+
});
|
|
31
|
+
export interface ToggleGroupItemProps extends ComponentProps<'button'> {
|
|
32
|
+
value: string;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/toggle-group/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAiB,SAAS,EAAsB,MAAM,OAAO,CAAC;AAWrF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,gBAAgB,+BAyD1D;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,oBAAoB,+BAqB3F;AAED,UAAU,oBAAqB,SAAQ,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,cAAc,CAAC;IAC9E,wEAAwE;IACxE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAED,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GAC/C,CACM;IACI,uEAAuE;IACvE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CAClD,GACD;IACI,0BAA0B;IAC1B,QAAQ,EAAE,IAAI,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;CACtD,CACN,CAAC;AAEN,MAAM,WAAW,oBAAqB,SAAQ,cAAc,CAAC,QAAQ,CAAC;IAClE,KAAK,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useMergedRefs as t } from "../utils/refs.js";
|
|
4
|
+
import { moveFocus as n, useRovingTabIndex as r } from "../utils/roving.js";
|
|
5
|
+
import { useControllable as i } from "../utils/useControllable.js";
|
|
6
|
+
import { FormValue as a } from "../utils/form-value.js";
|
|
7
|
+
import { useToolbarOrientation as o } from "../toolbar/index.js";
|
|
8
|
+
import { createContext as s, useContext as c, useRef as l } from "react";
|
|
9
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
10
|
+
//#region packages/toggle-group/index.tsx
|
|
11
|
+
var f = ".zen__toggle-group-item", p = s(null);
|
|
12
|
+
function m(s) {
|
|
13
|
+
let { multiple: c, value: m, defaultValue: h, onValueChange: g, name: _, className: v, onKeyDown: y, children: b, ref: x, ...S } = s, [C, w, T] = i(m, h ?? (c ? [] : null), g), E = typeof C == "string" ? [C] : C ?? [], D = {
|
|
14
|
+
isPressed: (e) => E.includes(e),
|
|
15
|
+
setPressed: (e, t) => {
|
|
16
|
+
w(c ? t ? [...E, e] : E.filter((t) => t !== e) : t ? e : null);
|
|
17
|
+
}
|
|
18
|
+
}, O = l(null), k = t(O, x), A = o(), j = !A;
|
|
19
|
+
return r(O, f, "[aria-pressed=true]", j), /* @__PURE__ */ d(p.Provider, {
|
|
20
|
+
value: D,
|
|
21
|
+
children: [/* @__PURE__ */ u("div", {
|
|
22
|
+
role: "group",
|
|
23
|
+
"data-zen-roving": j ? "" : void 0,
|
|
24
|
+
...S,
|
|
25
|
+
ref: k,
|
|
26
|
+
onKeyDown: (e) => {
|
|
27
|
+
y?.(e), j && n(e, f);
|
|
28
|
+
},
|
|
29
|
+
className: e("zen__toggle-group relative inline-flex w-fit flex-wrap gap-1", j && "glow-edge border-tint/10 bg-tint/[0.03] rounded-xl border p-1", A === "vertical" && "flex-col", v),
|
|
30
|
+
children: b
|
|
31
|
+
}), /* @__PURE__ */ u(a, {
|
|
32
|
+
name: _,
|
|
33
|
+
value: E,
|
|
34
|
+
onReset: T
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function h({ value: t, className: n, onClick: r, ...i }) {
|
|
39
|
+
let a = c(p);
|
|
40
|
+
if (!a) throw Error("<ToggleGroupItem> must be inside <ToggleGroup>");
|
|
41
|
+
let o = a.isPressed(t);
|
|
42
|
+
return /* @__PURE__ */ u("button", {
|
|
43
|
+
type: "button",
|
|
44
|
+
"aria-pressed": o,
|
|
45
|
+
onClick: (e) => {
|
|
46
|
+
r?.(e), e.defaultPrevented || a.setPressed(t, !o);
|
|
47
|
+
},
|
|
48
|
+
className: e("zen__toggle-group-item text-muted-foreground hover:text-foreground focus-ring inline-flex h-8 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 text-sm whitespace-nowrap transition-[color,background-color,box-shadow] duration-300 select-none", "aria-pressed:bg-primary/15 aria-pressed:text-foreground aria-pressed:shadow-[inset_0_0_0_1px_oklch(var(--primary)/0.4)]", "disabled:hover:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", n),
|
|
49
|
+
...i
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { h as ToggleGroupItem, m as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SeparatorProps } from '../separator';
|
|
2
|
+
import { ComponentProps } from 'react';
|
|
3
|
+
/** Whether this is inside a Toolbar, which then moves focus through its items (a ToggleGroup's too). */
|
|
4
|
+
/** Which way the Toolbar this is in runs, or null outside one. */
|
|
5
|
+
export declare const useToolbarOrientation: () => "horizontal" | "vertical" | null;
|
|
6
|
+
export declare const useInToolbar: () => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* A row of controls for one thing, e.g. a table's or an editor's: buttons,
|
|
9
|
+
* ToggleGroups, Selects, a search field. Tab enters it once; ←→ (↑↓ when
|
|
10
|
+
* `orientation="vertical"`) move between its controls, Home and End jump to
|
|
11
|
+
* the ends. Divide it with ToolbarSeparator. Give it an aria-label.
|
|
12
|
+
*/
|
|
13
|
+
export default function Toolbar({ orientation, className, onKeyDown, ref: refProp, ...rest }: ToolbarProps): import('react').JSX.Element;
|
|
14
|
+
/** A hairline between groups of a Toolbar's controls, across its direction. */
|
|
15
|
+
export declare function ToolbarSeparator({ className, ...rest }: Omit<SeparatorProps, 'orientation'>): import('react').JSX.Element;
|
|
16
|
+
export interface ToolbarProps extends ComponentProps<'div'> {
|
|
17
|
+
orientation?: 'horizontal' | 'vertical';
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/toolbar/index.tsx"],"names":[],"mappings":"AAAA,OAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhE,OAAO,EAAE,cAAc,EAAqC,MAAM,OAAO,CAAC;AAI1E,wGAAwG;AACxG,kEAAkE;AAClE,eAAO,MAAM,qBAAqB,wCAAmC,CAAC;AACtE,eAAO,MAAM,YAAY,eAAyC,CAAC;AAMnE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC5B,WAA0B,EAC1B,SAAS,EACT,SAAS,EACT,GAAG,EAAE,OAAO,EACZ,GAAG,IAAI,EACV,EAAE,YAAY,+BA+Bd;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,+BAS3F;AAED,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACvD,WAAW,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CAC3C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import { useMergedRefs as t } from "../utils/refs.js";
|
|
4
|
+
import { moveFocus as n, useRovingTabIndex as r } from "../utils/roving.js";
|
|
5
|
+
import i from "../separator/index.js";
|
|
6
|
+
import { createContext as a, useContext as o, useRef as s } from "react";
|
|
7
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
8
|
+
//#region packages/toolbar/index.tsx
|
|
9
|
+
var l = a(null), u = () => o(l), d = () => u() !== null, f = "button, a[href], input:not([type=hidden]), select, textarea, [role=button], [role=combobox]", p = "input:not([type=checkbox], [type=radio], [type=range], [type=button]), textarea, [contenteditable]";
|
|
10
|
+
function m({ orientation: i = "horizontal", className: a, onKeyDown: o, ref: u, ...d }) {
|
|
11
|
+
let m = s(null), h = t(m, u);
|
|
12
|
+
return r(m, f), /* @__PURE__ */ c(l.Provider, {
|
|
13
|
+
value: i,
|
|
14
|
+
children: /* @__PURE__ */ c("div", {
|
|
15
|
+
role: "toolbar",
|
|
16
|
+
"aria-orientation": i === "vertical" ? "vertical" : void 0,
|
|
17
|
+
"data-zen-roving": "",
|
|
18
|
+
ref: h,
|
|
19
|
+
onKeyDown: (e) => {
|
|
20
|
+
o?.(e), !(i !== "vertical" && e.target.matches(p) && /^Arrow(Left|Right)$|^Home$|^End$/.test(e.key)) && n(e, f, i);
|
|
21
|
+
},
|
|
22
|
+
className: e("zen__toolbar glow-edge border-tint/10 bg-tint/[0.03] relative flex w-fit items-center gap-1 rounded-xl border p-1", i === "vertical" && "flex-col", a),
|
|
23
|
+
...d
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function h({ className: t, ...n }) {
|
|
28
|
+
let r = o(l) === "vertical";
|
|
29
|
+
return /* @__PURE__ */ c(i, {
|
|
30
|
+
orientation: r ? "horizontal" : "vertical",
|
|
31
|
+
className: e(r ? "my-0.5 w-auto self-stretch mx-1.5" : "mx-0.5 my-1.5", t),
|
|
32
|
+
...n
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { h as ToolbarSeparator, m as default, d as useInToolbar, u as useToolbarOrientation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tooltip/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/tooltip/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAiB,SAAS,EAAsB,MAAM,OAAO,CAAC;AAUrF;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+BAIrE;AAED,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,EAC3B,OAAO,EACP,KAAK,EACL,cAAc,EACd,cAAc,EACd,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,mBAAmB,+BAerB;AAED,kGAAkG;AAClG,wBAAgB,cAAc,CAAC,EAC3B,KAAgB,EAChB,MAAU,EACV,SAAS,EACT,KAAK,EACL,cAAc,EACd,cAAc,EACd,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,mBAAmB,+BAmBrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,QAAQ,CAAC;IACjE,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAC9D,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB"}
|