@rinzai/zen 0.8.6 → 0.10.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/dist/animated-number/index.d.ts +6 -2
- package/dist/animated-number/index.d.ts.map +1 -1
- package/dist/animated-number/index.js +69 -17
- package/dist/breadcrumbs/index.d.ts +15 -0
- package/dist/breadcrumbs/index.d.ts.map +1 -0
- package/dist/breadcrumbs/index.js +39 -0
- package/dist/calendar-heatmap/index.d.ts +25 -0
- package/dist/calendar-heatmap/index.d.ts.map +1 -0
- package/dist/calendar-heatmap/index.js +48 -0
- package/dist/card/index.d.ts +3 -1
- package/dist/card/index.d.ts.map +1 -1
- package/dist/card/index.js +3 -2
- package/dist/chart/allocation.d.ts +30 -0
- package/dist/chart/allocation.d.ts.map +1 -0
- package/dist/chart/allocation.js +69 -0
- package/dist/chart/donut.d.ts.map +1 -1
- package/dist/chart/donut.js +72 -70
- package/dist/chart/index.d.ts +1 -0
- package/dist/chart/index.d.ts.map +1 -1
- package/dist/chart/index.js +182 -178
- package/dist/code-block/index.d.ts +1 -1
- package/dist/code-block/index.d.ts.map +1 -1
- package/dist/code-block/index.js +31 -22
- package/dist/code-input/index.d.ts +20 -0
- package/dist/code-input/index.d.ts.map +1 -0
- package/dist/code-input/index.js +44 -0
- package/dist/collapse/index.d.ts +3 -2
- package/dist/collapse/index.d.ts.map +1 -1
- package/dist/collapse/index.js +1 -1
- package/dist/command-palette/index.d.ts +37 -0
- package/dist/command-palette/index.d.ts.map +1 -0
- package/dist/command-palette/index.js +120 -0
- package/dist/date-picker/index.d.ts +10 -2
- package/dist/date-picker/index.d.ts.map +1 -1
- package/dist/date-picker/index.js +43 -21
- package/dist/dialog/index.d.ts +13 -3
- package/dist/dialog/index.d.ts.map +1 -1
- package/dist/dialog/index.js +84 -44
- package/dist/editable-cell/index.d.ts +2 -1
- package/dist/editable-cell/index.d.ts.map +1 -1
- package/dist/editable-cell/index.js +24 -17
- package/dist/empty-state/index.d.ts +14 -0
- package/dist/empty-state/index.d.ts.map +1 -0
- package/dist/empty-state/index.js +31 -0
- package/dist/file-drop/index.d.ts +18 -0
- package/dist/file-drop/index.d.ts.map +1 -0
- package/dist/file-drop/index.js +49 -0
- package/dist/filter-bar/index.d.ts +21 -0
- package/dist/filter-bar/index.d.ts.map +1 -0
- package/dist/filter-bar/index.js +90 -0
- package/dist/icon-picker/index.d.ts +38 -0
- package/dist/icon-picker/index.d.ts.map +1 -0
- package/dist/icon-picker/index.js +112 -0
- package/dist/icons/arrow-left.js +23 -0
- package/dist/icons/micro/arrow-trending-down.d.ts +3 -0
- package/dist/icons/micro/arrow-trending-down.d.ts.map +1 -0
- package/dist/icons/micro/arrow-trending-down.js +21 -0
- package/dist/icons/micro/arrow-trending-up.d.ts +3 -0
- package/dist/icons/micro/arrow-trending-up.d.ts.map +1 -0
- package/dist/icons/micro/arrow-trending-up.js +21 -0
- package/dist/index.d.ts +30 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/kbd/index.d.ts +4 -0
- package/dist/kbd/index.d.ts.map +1 -0
- package/dist/kbd/index.js +12 -0
- package/dist/keypad/index.d.ts +20 -0
- package/dist/keypad/index.d.ts.map +1 -0
- package/dist/keypad/index.js +42 -0
- package/dist/lib.js +92 -65
- package/dist/load-more/index.d.ts +19 -0
- package/dist/load-more/index.d.ts.map +1 -0
- package/dist/load-more/index.js +37 -0
- package/dist/menu/index.d.ts +22 -3
- package/dist/menu/index.d.ts.map +1 -1
- package/dist/menu/index.js +132 -45
- package/dist/meter/index.d.ts +3 -1
- package/dist/meter/index.d.ts.map +1 -1
- package/dist/meter/index.js +19 -14
- package/dist/money-input/index.d.ts +3 -3
- package/dist/page-transition/index.d.ts +10 -0
- package/dist/page-transition/index.d.ts.map +1 -0
- package/dist/page-transition/index.js +16 -0
- package/dist/pagination/index.d.ts +26 -0
- package/dist/pagination/index.d.ts.map +1 -0
- package/dist/pagination/index.js +62 -0
- package/dist/progress-ring/index.d.ts +4 -1
- package/dist/progress-ring/index.d.ts.map +1 -1
- package/dist/progress-ring/index.js +47 -38
- package/dist/range-slider/index.d.ts +26 -0
- package/dist/range-slider/index.d.ts.map +1 -0
- package/dist/range-slider/index.js +44 -0
- package/dist/repeat-picker/index.d.ts +22 -0
- package/dist/repeat-picker/index.d.ts.map +1 -0
- package/dist/repeat-picker/index.js +115 -0
- package/dist/skeleton/index.d.ts +12 -2
- package/dist/skeleton/index.d.ts.map +1 -1
- package/dist/skeleton/index.js +11 -5
- package/dist/slider/index.d.ts +2 -0
- package/dist/slider/index.d.ts.map +1 -1
- package/dist/slider/index.js +19 -18
- package/dist/sortable/index.d.ts +33 -0
- package/dist/sortable/index.d.ts.map +1 -0
- package/dist/sortable/index.js +147 -0
- package/dist/sparkline/index.d.ts +15 -0
- package/dist/sparkline/index.d.ts.map +1 -0
- package/dist/sparkline/index.js +56 -0
- package/dist/stepper/index.d.ts +19 -0
- package/dist/stepper/index.d.ts.map +1 -0
- package/dist/stepper/index.js +53 -0
- package/dist/table/index.d.ts +11 -2
- package/dist/table/index.d.ts.map +1 -1
- package/dist/table/index.js +117 -53
- package/dist/table/selection.d.ts +55 -0
- package/dist/table/selection.d.ts.map +1 -0
- package/dist/table/selection.js +83 -0
- package/dist/table/swipe.d.ts +18 -0
- package/dist/table/swipe.d.ts.map +1 -0
- package/dist/table/swipe.js +53 -0
- package/dist/table-of-contents/index.d.ts +1 -0
- package/dist/table-of-contents/index.d.ts.map +1 -1
- package/dist/table-of-contents/index.js +25 -23
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js +101 -51
- package/dist/tag-input/index.d.ts +19 -0
- package/dist/tag-input/index.d.ts.map +1 -0
- package/dist/tag-input/index.js +61 -0
- package/dist/theme-toggle/index.js +6 -6
- package/dist/theme.css +340 -8
- package/dist/timeline/index.d.ts +18 -0
- package/dist/timeline/index.d.ts.map +1 -0
- package/dist/timeline/index.js +45 -0
- package/dist/toast/index.js +25 -25
- package/dist/toggle/index.d.ts.map +1 -1
- package/dist/toggle/index.js +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/tree/index.js +68 -67
- package/dist/trend/index.d.ts +19 -0
- package/dist/trend/index.d.ts.map +1 -0
- package/dist/trend/index.js +27 -0
- package/dist/utils/date.d.ts +34 -0
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/date.js +45 -12
- package/dist/utils/indicator.d.ts.map +1 -1
- package/dist/utils/indicator.js +1 -1
- package/dist/utils/money.d.ts +3 -1
- package/dist/utils/money.d.ts.map +1 -1
- package/dist/utils/money.js +24 -1
- package/dist/utils/motion.d.ts +3 -0
- package/dist/utils/motion.d.ts.map +1 -0
- package/dist/utils/motion.js +7 -0
- package/dist/utils/repeat.d.ts +17 -0
- package/dist/utils/repeat.d.ts.map +1 -0
- package/dist/utils/repeat.js +38 -0
- package/dist/utils/section-link.d.ts +9 -0
- package/dist/utils/section-link.d.ts.map +1 -0
- package/dist/utils/section-link.js +10 -0
- package/dist/utils/swipe.d.ts +29 -0
- package/dist/utils/swipe.d.ts.map +1 -0
- package/dist/utils/swipe.js +85 -0
- package/dist/utils/theme-wave.d.ts.map +1 -1
- package/dist/utils/theme-wave.js +72 -71
- package/dist/utils/useAnchoredPopup.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopup.js +3 -4
- package/dist/utils/useSeen.d.ts +4 -0
- package/dist/utils/useSeen.d.ts.map +1 -0
- package/dist/utils/useSeen.js +17 -0
- package/dist/zen.css +1 -1
- package/package.json +3 -1
package/dist/tree/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cx as e } from "../utils/cx.js";
|
|
3
|
-
import {
|
|
4
|
-
import r from "../
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { reducedMotion as t } from "../utils/motion.js";
|
|
4
|
+
import { TableCell as n, TableRow as r } from "../table/index.js";
|
|
5
|
+
import i from "../icons/micro/chevron-right.js";
|
|
6
|
+
import { useCallback as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
8
|
//#region packages/tree/index.tsx
|
|
8
|
-
function
|
|
9
|
-
let [
|
|
10
|
-
let e = [],
|
|
11
|
-
|
|
12
|
-
let l =
|
|
9
|
+
function d({ items: n, getKey: r, getChildren: i, defaultExpanded: l = !0, rowHeight: u = 36 }) {
|
|
10
|
+
let [d, f] = c(() => /* @__PURE__ */ new Set()), [p, m] = c(null), [h, g] = c(null), _ = s(null), v = a((e) => d.has(e) !== l, [d, l]), y = o(() => {
|
|
11
|
+
let e = [], t = (n, a, o) => {
|
|
12
|
+
n.forEach((s, c) => {
|
|
13
|
+
let l = r(s), u = i(s), d = !!u?.length, f = d && v(l);
|
|
13
14
|
e.push({
|
|
14
15
|
item: s,
|
|
15
16
|
key: l,
|
|
@@ -18,65 +19,65 @@ function u({ items: t, getKey: n, getChildren: r, defaultExpanded: c = !0, rowHe
|
|
|
18
19
|
hasChildren: d,
|
|
19
20
|
expanded: f,
|
|
20
21
|
position: c + 1,
|
|
21
|
-
siblings:
|
|
22
|
-
}), f &&
|
|
22
|
+
siblings: n.length
|
|
23
|
+
}), f && t(u, a + 1, l);
|
|
23
24
|
});
|
|
24
25
|
};
|
|
25
|
-
return
|
|
26
|
+
return t(n, 0, null), e;
|
|
26
27
|
}, [
|
|
27
|
-
t,
|
|
28
28
|
n,
|
|
29
29
|
r,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
i,
|
|
31
|
+
v
|
|
32
|
+
]), b = () => {
|
|
33
|
+
let e = [], t = (n) => {
|
|
34
|
+
for (let a of n) {
|
|
35
|
+
let n = i(a);
|
|
36
|
+
n?.length && (e.push(r(a)), t(n));
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
return
|
|
39
|
-
},
|
|
39
|
+
return t(n), e;
|
|
40
|
+
}, x = a((e, t) => f((n) => {
|
|
40
41
|
let r = new Set(n);
|
|
41
|
-
return t ===
|
|
42
|
-
}), [
|
|
43
|
-
let
|
|
42
|
+
return t === l ? r.delete(e) : r.add(e), r;
|
|
43
|
+
}), [l]), S = (e) => {
|
|
44
|
+
let n = () => {
|
|
44
45
|
let t = Date.now();
|
|
45
|
-
|
|
46
|
+
m({
|
|
46
47
|
key: e,
|
|
47
48
|
at: t
|
|
48
|
-
}), setTimeout(() =>
|
|
49
|
+
}), setTimeout(() => m((e) => e?.at === t ? null : e), 320);
|
|
49
50
|
};
|
|
50
|
-
if (
|
|
51
|
-
else if (!
|
|
52
|
-
else if (
|
|
51
|
+
if (h === e) _.current = null, g(null), n();
|
|
52
|
+
else if (!v(e)) n(), x(e, !0);
|
|
53
|
+
else if (t()) x(e, !1);
|
|
53
54
|
else {
|
|
54
|
-
|
|
55
|
+
g(e);
|
|
55
56
|
let t = () => {
|
|
56
|
-
|
|
57
|
+
_.current === t && (x(e, !1), g((t) => t === e ? null : t), _.current = null);
|
|
57
58
|
};
|
|
58
|
-
|
|
59
|
+
_.current = t, setTimeout(t, 500);
|
|
59
60
|
}
|
|
60
|
-
}, [C, w] =
|
|
61
|
+
}, [C, w] = c(null), T = y.some((e) => e.key === C) ? C : y[0]?.key ?? null, E = (e) => e.expanded && h !== e.key, D = (e, t) => {
|
|
61
62
|
if (t.target !== t.currentTarget) return;
|
|
62
|
-
let n =
|
|
63
|
-
if (t.key === "ArrowDown") r =
|
|
64
|
-
else if (t.key === "ArrowUp") r =
|
|
65
|
-
else if (t.key === "Home") r =
|
|
66
|
-
else if (t.key === "End") r =
|
|
67
|
-
else if (t.key === "ArrowRight" && e.hasChildren) E(e) ? r =
|
|
68
|
-
else if (t.key === "ArrowLeft") E(e) ? S(e.key) : r =
|
|
63
|
+
let n = y.indexOf(e), r;
|
|
64
|
+
if (t.key === "ArrowDown") r = y[n + 1];
|
|
65
|
+
else if (t.key === "ArrowUp") r = y[n - 1];
|
|
66
|
+
else if (t.key === "Home") r = y[0];
|
|
67
|
+
else if (t.key === "End") r = y.at(-1);
|
|
68
|
+
else if (t.key === "ArrowRight" && e.hasChildren) E(e) ? r = y[n + 1] : S(e.key);
|
|
69
|
+
else if (t.key === "ArrowLeft") E(e) ? S(e.key) : r = y.find((t) => t.key === e.parentKey);
|
|
69
70
|
else return;
|
|
70
71
|
t.preventDefault(), r && t.currentTarget.closest("[role=\"treegrid\"], table")?.querySelector(`[data-tree-key="${CSS.escape(r.key)}"]`)?.focus();
|
|
71
72
|
};
|
|
72
73
|
return {
|
|
73
|
-
rows:
|
|
74
|
+
rows: y,
|
|
74
75
|
toggle: S,
|
|
75
|
-
isExpanded:
|
|
76
|
-
expand: (e) =>
|
|
77
|
-
collapse: (e) =>
|
|
78
|
-
expandAll: () =>
|
|
79
|
-
collapseAll: () =>
|
|
76
|
+
isExpanded: v,
|
|
77
|
+
expand: (e) => x(e, !0),
|
|
78
|
+
collapse: (e) => x(e, !1),
|
|
79
|
+
expandAll: () => f(l ? /* @__PURE__ */ new Set() : new Set(b())),
|
|
80
|
+
collapseAll: () => f(l ? new Set(b()) : /* @__PURE__ */ new Set()),
|
|
80
81
|
tableProps: { role: "treegrid" },
|
|
81
82
|
rowProps: (t) => ({
|
|
82
83
|
"aria-level": t.depth + 1,
|
|
@@ -90,10 +91,10 @@ function u({ items: t, getKey: n, getChildren: r, defaultExpanded: c = !0, rowHe
|
|
|
90
91
|
e.target === e.currentTarget && w(t.key);
|
|
91
92
|
},
|
|
92
93
|
onKeyDown: (e) => D(t, e),
|
|
93
|
-
className: e("outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring/60",
|
|
94
|
-
style: { "--row-h": `${
|
|
94
|
+
className: e("outline-hidden focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring/60", p && t.parentKey === p.key && "zen__tree-row-enter", h && t.parentKey === h && "zen__tree-row-exit"),
|
|
95
|
+
style: { "--row-h": `${u - 1}px` },
|
|
95
96
|
onAnimationEnd: (e) => {
|
|
96
|
-
e.animationName === "zen-row-close" &&
|
|
97
|
+
e.animationName === "zen-row-close" && h && t.parentKey === h && _.current?.();
|
|
97
98
|
}
|
|
98
99
|
}),
|
|
99
100
|
toggleProps: (e) => ({
|
|
@@ -101,13 +102,13 @@ function u({ items: t, getKey: n, getChildren: r, defaultExpanded: c = !0, rowHe
|
|
|
101
102
|
onToggle: () => S(e.key),
|
|
102
103
|
tabIndex: -1
|
|
103
104
|
}),
|
|
104
|
-
rowHeight:
|
|
105
|
+
rowHeight: u
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
-
let u =
|
|
109
|
-
return /* @__PURE__ */
|
|
110
|
-
...
|
|
108
|
+
function f({ row: t, tree: n, className: i, style: a, onFocus: o, onKeyDown: s, ...c }) {
|
|
109
|
+
let u = n.rowProps(t);
|
|
110
|
+
return /* @__PURE__ */ l(r, {
|
|
111
|
+
...c,
|
|
111
112
|
...u,
|
|
112
113
|
onFocus: (e) => {
|
|
113
114
|
o?.(e), u.onFocus(e);
|
|
@@ -122,34 +123,34 @@ function d({ row: t, tree: r, className: i, style: a, onFocus: o, onKeyDown: s,
|
|
|
122
123
|
}
|
|
123
124
|
});
|
|
124
125
|
}
|
|
125
|
-
function
|
|
126
|
-
return /* @__PURE__ */
|
|
127
|
-
numeric:
|
|
126
|
+
function p({ numeric: t, className: r, children: i, ...a }) {
|
|
127
|
+
return /* @__PURE__ */ l(n, {
|
|
128
|
+
numeric: t,
|
|
128
129
|
className: e("py-0 whitespace-nowrap", r),
|
|
129
130
|
...a,
|
|
130
|
-
children: /* @__PURE__ */
|
|
131
|
-
className: e("zen__tree-cell flex h-[var(--row-h)] items-center",
|
|
131
|
+
children: /* @__PURE__ */ l("div", {
|
|
132
|
+
className: e("zen__tree-cell flex h-[var(--row-h)] items-center", t && "justify-end"),
|
|
132
133
|
children: i
|
|
133
134
|
})
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
-
return /* @__PURE__ */
|
|
137
|
+
function m({ row: t, tree: n, indent: r = 20, children: i, className: a }) {
|
|
138
|
+
return /* @__PURE__ */ u("div", {
|
|
138
139
|
className: e("flex min-w-0 flex-1 items-center gap-1", a),
|
|
139
140
|
style: { paddingLeft: t.depth * r },
|
|
140
|
-
children: [t.hasChildren ? /* @__PURE__ */
|
|
141
|
+
children: [t.hasChildren ? /* @__PURE__ */ l(h, { ...n.toggleProps(t) }) : /* @__PURE__ */ l("span", { className: "-ml-1 w-6 shrink-0" }), i]
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
-
return /* @__PURE__ */
|
|
144
|
+
function h({ expanded: t, onToggle: n, className: r, ...a }) {
|
|
145
|
+
return /* @__PURE__ */ l("button", {
|
|
145
146
|
type: "button",
|
|
146
147
|
onClick: n,
|
|
147
148
|
"aria-label": t ? "Collapse" : "Expand",
|
|
148
149
|
"aria-expanded": t,
|
|
149
|
-
className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 cursor-pointer place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2",
|
|
150
|
+
className: e("text-muted-foreground hover:bg-tint/[0.08] hover:text-foreground focus-visible:ring-ring/50 -ml-1 grid size-6 shrink-0 cursor-pointer place-items-center rounded-md outline-hidden transition-colors focus-visible:ring-2", r),
|
|
150
151
|
...a,
|
|
151
|
-
children: /* @__PURE__ */
|
|
152
|
+
children: /* @__PURE__ */ l(i, { className: e("zen__tree-chevron size-4 transition-transform duration-200 ease-out", t && "rotate-90") })
|
|
152
153
|
});
|
|
153
154
|
}
|
|
154
155
|
//#endregion
|
|
155
|
-
export {
|
|
156
|
+
export { p as TreeCell, m as TreeLabel, f as TreeRow, h as TreeToggle, d as useTree };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ComponentProps } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A change, e.g. "+12%" with an arrow, coloured by whether it's good news:
|
|
4
|
+
* savings going up is, spending going up isn't (`good="down"`). `value` is
|
|
5
|
+
* the change as a fraction (0.12 for 12%); children follow it, muted, e.g.
|
|
6
|
+
* "vs last month".
|
|
7
|
+
*/
|
|
8
|
+
export default function Trend({ value, good, locale, format, className, children, ...rest }: TrendProps): import('react').JSX.Element;
|
|
9
|
+
export interface TrendProps extends ComponentProps<'span'> {
|
|
10
|
+
/** The change as a fraction: 0.12 is 12% up, -0.05 is 5% down. */
|
|
11
|
+
value: number;
|
|
12
|
+
/** Which way is good news (default `up`); spending would be `down`. */
|
|
13
|
+
good?: 'up' | 'down';
|
|
14
|
+
/** For the default percent format. */
|
|
15
|
+
locale?: string;
|
|
16
|
+
/** How the change reads, e.g. as money instead of a percent. */
|
|
17
|
+
format?: (value: number) => string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/trend/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,EAC1B,KAAK,EACL,IAAW,EACX,MAAM,EACN,MAGK,EACL,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACV,EAAE,UAAU,+BAsBZ;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAC,MAAM,CAAC;IACtD,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IACrB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACtC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx as e } from "../utils/cx.js";
|
|
3
|
+
import t from "../icons/micro/arrow-trending-down.js";
|
|
4
|
+
import n from "../icons/micro/arrow-trending-up.js";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region packages/trend/index.tsx
|
|
7
|
+
function a({ value: a, good: o = "up", locale: s, format: c = (e) => new Intl.NumberFormat(s, {
|
|
8
|
+
style: "percent",
|
|
9
|
+
maximumFractionDigits: 1,
|
|
10
|
+
signDisplay: "exceptZero"
|
|
11
|
+
}).format(e), className: l, children: u, ...d }) {
|
|
12
|
+
let f = a > 0 ? "up" : a < 0 ? "down" : "flat", p = f === "up" ? n : f === "down" ? t : null;
|
|
13
|
+
return /* @__PURE__ */ i("span", {
|
|
14
|
+
className: e("zen__trend inline-flex items-center gap-1.5 text-xs", l),
|
|
15
|
+
...d,
|
|
16
|
+
children: [/* @__PURE__ */ i("span", {
|
|
17
|
+
"data-direction": f,
|
|
18
|
+
className: e("inline-flex items-center gap-0.5 rounded-md border px-1.5 py-0.5 font-medium whitespace-nowrap tabular-nums", f === "flat" ? "border-tint/10 bg-tint/[0.06] text-muted-foreground" : f === o ? "border-glow/30 bg-glow/10 text-primary" : "border-destructive/40 bg-destructive/10 text-destructive"),
|
|
19
|
+
children: [p && /* @__PURE__ */ r(p, { className: "size-3.5" }), c(a)]
|
|
20
|
+
}), u && /* @__PURE__ */ r("span", {
|
|
21
|
+
className: "text-muted-foreground",
|
|
22
|
+
children: u
|
|
23
|
+
})]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { a as default };
|
package/dist/utils/date.d.ts
CHANGED
|
@@ -21,6 +21,40 @@ export declare function daysInMonth(month: Month): number;
|
|
|
21
21
|
export declare function dayOfWeek(date: DateString): number;
|
|
22
22
|
/** Today in the user's time zone. */
|
|
23
23
|
export declare function today(now?: Date): DateString;
|
|
24
|
+
/**
|
|
25
|
+
* The ranges people pick most, up to `today`: label them yourself, e.g. for
|
|
26
|
+
* DateRangePicker's presets. Weeks start on `weekStartsOn` (0 for Sunday).
|
|
27
|
+
*/
|
|
28
|
+
export declare function commonRanges(today: DateString, weekStartsOn?: number): {
|
|
29
|
+
today: {
|
|
30
|
+
start: string;
|
|
31
|
+
end: string;
|
|
32
|
+
};
|
|
33
|
+
thisWeek: {
|
|
34
|
+
start: string;
|
|
35
|
+
end: string;
|
|
36
|
+
};
|
|
37
|
+
last7Days: {
|
|
38
|
+
start: string;
|
|
39
|
+
end: string;
|
|
40
|
+
};
|
|
41
|
+
last30Days: {
|
|
42
|
+
start: string;
|
|
43
|
+
end: string;
|
|
44
|
+
};
|
|
45
|
+
thisMonth: {
|
|
46
|
+
start: string;
|
|
47
|
+
end: string;
|
|
48
|
+
};
|
|
49
|
+
lastMonth: {
|
|
50
|
+
start: string;
|
|
51
|
+
end: string;
|
|
52
|
+
};
|
|
53
|
+
thisYear: {
|
|
54
|
+
start: string;
|
|
55
|
+
end: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
24
58
|
/** Days from `from` to `to` (negative if `to` is earlier). */
|
|
25
59
|
export declare function daysBetween(from: DateString, to: DateString): number;
|
|
26
60
|
/** How much of a date to show; `day` is the day and month without the year ("Sep 3"), for dates within the year. */
|
package/dist/utils/date.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../packages/utils/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,6EAA6E;AAC7E,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,UAAU,CAAC;IAClB,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1B;AAID,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAI1D;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AK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAQrE;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,SAAoB,GAAG,MAAM,CAEhG;AAED,sDAAsD;AACtD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,GAAE,QAAQ,GAAG,OAAO,GAAG,MAAgB,GAAG,MAAM,EAAE,CAGnG;AAUD,0FAA0F;AAC1F,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAahD;AAED,kGAAkG;AAClG,wBAAgB,eAAe,CAC3B,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,UAAU,EACf,MAAM,EAAE,MAAM,EACd,KAAK,GAAE,OAAO,CAAC,SAAS,EAAE,MAAM,CAAY,GAC7C,MAAM,CAER"}
|
package/dist/utils/date.js
CHANGED
|
@@ -30,10 +30,43 @@ function s(e) {
|
|
|
30
30
|
function c(e = /* @__PURE__ */ new Date()) {
|
|
31
31
|
return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
|
|
32
32
|
}
|
|
33
|
-
function l(e, t) {
|
|
33
|
+
function l(e, t = 1) {
|
|
34
|
+
let n = e.slice(0, 7), r = a(`${n}-01`, -1);
|
|
35
|
+
return {
|
|
36
|
+
today: {
|
|
37
|
+
start: e,
|
|
38
|
+
end: e
|
|
39
|
+
},
|
|
40
|
+
thisWeek: {
|
|
41
|
+
start: i(e, -((s(e) - t + 7) % 7)),
|
|
42
|
+
end: e
|
|
43
|
+
},
|
|
44
|
+
last7Days: {
|
|
45
|
+
start: i(e, -6),
|
|
46
|
+
end: e
|
|
47
|
+
},
|
|
48
|
+
last30Days: {
|
|
49
|
+
start: i(e, -29),
|
|
50
|
+
end: e
|
|
51
|
+
},
|
|
52
|
+
thisMonth: {
|
|
53
|
+
start: `${n}-01`,
|
|
54
|
+
end: e
|
|
55
|
+
},
|
|
56
|
+
lastMonth: {
|
|
57
|
+
start: r,
|
|
58
|
+
end: i(`${n}-01`, -1)
|
|
59
|
+
},
|
|
60
|
+
thisYear: {
|
|
61
|
+
start: `${e.slice(0, 4)}-01-01`,
|
|
62
|
+
end: e
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function u(e, t) {
|
|
34
67
|
return n(t) - n(e);
|
|
35
68
|
}
|
|
36
|
-
var
|
|
69
|
+
var d = (e, t) => new Intl.DateTimeFormat(e, t === "day" ? {
|
|
37
70
|
day: "numeric",
|
|
38
71
|
month: "short",
|
|
39
72
|
timeZone: "UTC"
|
|
@@ -41,30 +74,30 @@ var u = (e, t) => new Intl.DateTimeFormat(e, t === "day" ? {
|
|
|
41
74
|
dateStyle: t,
|
|
42
75
|
timeZone: "UTC"
|
|
43
76
|
});
|
|
44
|
-
function
|
|
45
|
-
return
|
|
77
|
+
function f(e, t, r = "medium") {
|
|
78
|
+
return v(d(t, r).format(n(e) * 864e5));
|
|
46
79
|
}
|
|
47
|
-
function
|
|
80
|
+
function p(e, t = "short") {
|
|
48
81
|
let n = new Intl.DateTimeFormat(e, {
|
|
49
82
|
weekday: t,
|
|
50
83
|
timeZone: "UTC"
|
|
51
84
|
});
|
|
52
85
|
return Array.from({ length: 7 }, (e, t) => n.format(Date.UTC(2023, 0, 1 + t)));
|
|
53
86
|
}
|
|
54
|
-
var
|
|
55
|
-
function
|
|
87
|
+
var m = new Set("AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" ")), h = new Set("AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
|
|
88
|
+
function g(e) {
|
|
56
89
|
try {
|
|
57
90
|
let t = new Intl.Locale(e), n = t.getWeekInfo?.() ?? t.weekInfo;
|
|
58
91
|
if (n) return n.firstDay % 7;
|
|
59
92
|
let r = t.maximize().region ?? "";
|
|
60
|
-
return
|
|
93
|
+
return m.has(r) ? 0 : h.has(r) ? 6 : 1;
|
|
61
94
|
} catch {
|
|
62
95
|
return 1;
|
|
63
96
|
}
|
|
64
97
|
}
|
|
65
|
-
function
|
|
66
|
-
return
|
|
98
|
+
function _(e, t, r, i = "medium") {
|
|
99
|
+
return v(d(r, i).formatRange(n(e) * 864e5, n(t) * 864e5));
|
|
67
100
|
}
|
|
68
|
-
var
|
|
101
|
+
var v = (e) => e.replace(/[\u2009\u202f]/g, " ");
|
|
69
102
|
//#endregion
|
|
70
|
-
export { i as addDays, a as addMonthsToDate, n as dayIndex, s as dayOfWeek,
|
|
103
|
+
export { i as addDays, a as addMonthsToDate, l as commonRanges, n as dayIndex, s as dayOfWeek, u as daysBetween, o as daysInMonth, f as formatDate, _ as formatDateRange, r as fromDayIndex, t as isDate, c as today, g as weekStart, p as weekdayNames };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../../packages/utils/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CACxB,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,cAAmB,GAC1B,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"indicator.d.ts","sourceRoot":"","sources":["../../packages/utils/indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAA6B,MAAM,OAAO,CAAC;AAE7E,uEAAuE;AACvE,MAAM,WAAW,YAAY;IACzB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CACxB,QAAQ,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,cAAmB,GAC1B,YAAY,GAAG,IAAI,CAkCrB"}
|
package/dist/utils/indicator.js
CHANGED
|
@@ -7,7 +7,7 @@ function n(n, r, i = []) {
|
|
|
7
7
|
let e = n.current;
|
|
8
8
|
if (!e) return;
|
|
9
9
|
let t = () => {
|
|
10
|
-
let t = e.querySelector(r), n = t && {
|
|
10
|
+
let t = e.checkVisibility?.() === !1 ? null : e.querySelector(r), n = t && {
|
|
11
11
|
x: t.offsetLeft,
|
|
12
12
|
y: t.offsetTop,
|
|
13
13
|
w: t.offsetWidth,
|
package/dist/utils/money.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ export declare class MoneyParseError extends Error {
|
|
|
24
24
|
export declare function parseMoney(input: string, currency: string): Money;
|
|
25
25
|
/**
|
|
26
26
|
* Like parseMoney, plus shorthand: "1.5L" (lakh), "2cr" (crore), "10k",
|
|
27
|
-
* "1.2m"
|
|
27
|
+
* "1.2m", and sums: "120 + 45.50 - 10", "3 * 12.99", "1200 / 4" (× and ÷
|
|
28
|
+
* too). Amounts add exactly; times and divide take plain numbers and round
|
|
29
|
+
* to the currency's smallest unit (halves away from zero).
|
|
28
30
|
*/
|
|
29
31
|
export declare function parseMoneyInput(input: string, currency: string): Money;
|
|
30
32
|
//# sourceMappingURL=money.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"money.d.ts","sourceRoot":"","sources":["../../packages/utils/money.ts"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AQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAOpF;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMvE;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,KAAK,EAAE,MAAM;CAI5B;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAajE;AAiBD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAmBtE"}
|
package/dist/utils/money.js
CHANGED
|
@@ -56,7 +56,30 @@ var o = {
|
|
|
56
56
|
mn: 6,
|
|
57
57
|
million: 6
|
|
58
58
|
};
|
|
59
|
-
function s(
|
|
59
|
+
function s(e, t) {
|
|
60
|
+
let n = e.trim().split(/(?<=[\d.a-z])\s*([+\-−*/×÷])\s*/i);
|
|
61
|
+
if (n.length === 1) return l(e, t);
|
|
62
|
+
let r = 0, a = 0;
|
|
63
|
+
for (; a < n.length;) {
|
|
64
|
+
let i = a === 0 || n[a - 1] === "+" ? 1 : -1, o = l(n[a], t);
|
|
65
|
+
for (a += 2; a < n.length && /[*/×÷]/.test(n[a - 1]);) {
|
|
66
|
+
let t = n[a - 1] === "*" || n[a - 1] === "×";
|
|
67
|
+
o = c(o, n[a], t, e), a += 2;
|
|
68
|
+
}
|
|
69
|
+
r += i * o;
|
|
70
|
+
}
|
|
71
|
+
if (!Number.isSafeInteger(r)) throw new i(e);
|
|
72
|
+
return r;
|
|
73
|
+
}
|
|
74
|
+
function c(e, t, n, r) {
|
|
75
|
+
let a = /^(\d*)(?:\.(\d+))?$/.exec(t.trim());
|
|
76
|
+
if (!a || a[1] === "" && !a[2]) throw new i(r);
|
|
77
|
+
let o = (a[2] ?? "").length, s = BigInt((a[1] || "0") + (a[2] ?? "")), c = 10n ** BigInt(o), [l, u] = n ? [BigInt(e) * s, c] : [BigInt(e) * c, s];
|
|
78
|
+
if (u === 0n) throw new i(r);
|
|
79
|
+
let d = l < 0n, f = ((d ? -l : l) * 2n + u) / (u * 2n);
|
|
80
|
+
return Number(d ? -f : f);
|
|
81
|
+
}
|
|
82
|
+
function l(t, n) {
|
|
60
83
|
let r = /^\s*(.*?)\s*([a-z]+)\s*$/i.exec(t), s = o[r ? r[2].toLowerCase() : ""];
|
|
61
84
|
if (!r || s === void 0) return a(t, n);
|
|
62
85
|
let c = e(n), l = /^([+-]?)[^\d.+-]*([\d,\s_]*)(?:\.(\d*))?$/.exec(r[1]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../packages/utils/motion.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,wBAAgB,aAAa,IAAI,OAAO,CAMvC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region packages/utils/motion.ts
|
|
3
|
+
function e() {
|
|
4
|
+
return typeof window < "u" && (!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || document.documentElement.classList.contains("reduce-motion"));
|
|
5
|
+
}
|
|
6
|
+
//#endregion
|
|
7
|
+
export { e as reducedMotion };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DateString } from './date';
|
|
2
|
+
/**
|
|
3
|
+
* How often something comes round: every `every` days, weeks, months or
|
|
4
|
+
* years. Weekly can name `weekdays` (0 for Sunday … 6); monthly a `day` of the
|
|
5
|
+
* month (-1 for the last). Otherwise it falls on the start date's.
|
|
6
|
+
*/
|
|
7
|
+
export interface Repeat {
|
|
8
|
+
every: number;
|
|
9
|
+
unit: 'day' | 'week' | 'month' | 'year';
|
|
10
|
+
weekdays?: number[];
|
|
11
|
+
day?: number;
|
|
12
|
+
}
|
|
13
|
+
/** "Every 2 weeks on Mon, Thu", "Every month on day 5", "Every year on Sep 3" (from `start`). */
|
|
14
|
+
export declare function describeRepeat(repeat: Repeat, locale: string, start?: DateString): string;
|
|
15
|
+
/** The next `count` dates it falls on, from `start` (which sets the cycle) onwards, not before `from`. */
|
|
16
|
+
export declare function nextOccurrences(repeat: Repeat, start: DateString, count: number, from?: string): DateString[];
|
|
17
|
+
//# sourceMappingURL=repeat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repeat.d.ts","sourceRoot":"","sources":["../../packages/utils/repeat.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,KAAK,UAAU,EAMlB,MAAM,QAAQ,CAAC;AAEhB;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAezF;AAED,0GAA0G;AAC1G,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,UAAU,EAAE,CAW5G"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { addDays as e, addMonthsToDate as t, dayOfWeek as n, daysBetween as r, daysInMonth as i, formatDate as a, weekdayNames as o } from "./date.js";
|
|
3
|
+
//#region packages/utils/repeat.ts
|
|
4
|
+
function s(e, t, n) {
|
|
5
|
+
let { every: r, unit: i } = e, s = r === 1 ? `Every ${i}` : `Every ${r} ${i}s`;
|
|
6
|
+
if (i === "week" && e.weekdays?.length) {
|
|
7
|
+
let n = o(t);
|
|
8
|
+
return `${s} on ${[...e.weekdays].sort((e, t) => e - t).map((e) => n[e]).join(", ")}`;
|
|
9
|
+
}
|
|
10
|
+
return i === "month" && e.day !== void 0 ? `${s} on ${e.day === -1 ? "the last day" : `day ${e.day}`}` : i === "year" && n ? `${s} on ${a(n, t, "day")}` : s;
|
|
11
|
+
}
|
|
12
|
+
function c(e, t, n, r = t) {
|
|
13
|
+
let i = [], a = Math.max(1, Math.floor(e.every)), o = Math.max(0, Math.floor(l(e.unit, t, r) / a) - 1);
|
|
14
|
+
for (let s = o; i.length < n && s < o + n + 2; s++) for (let o of u(e, t, s * a)) o >= t && o >= r && i.length < n && i.push(o);
|
|
15
|
+
return i;
|
|
16
|
+
}
|
|
17
|
+
function l(e, t, n) {
|
|
18
|
+
if (e === "day") return r(t, n);
|
|
19
|
+
if (e === "week") return Math.floor(r(t, n) / 7);
|
|
20
|
+
let i = (Number(n.slice(0, 4)) - Number(t.slice(0, 4))) * 12 + Number(n.slice(5, 7)) - Number(t.slice(5, 7));
|
|
21
|
+
return e === "month" ? i : Math.floor(i / 12);
|
|
22
|
+
}
|
|
23
|
+
function u(r, a, o) {
|
|
24
|
+
switch (r.unit) {
|
|
25
|
+
case "day": return [e(a, o)];
|
|
26
|
+
case "week": {
|
|
27
|
+
let t = r.weekdays?.length ? [...new Set(r.weekdays)].sort((e, t) => e - t) : [n(a)], i = e(a, -n(a) + o * 7);
|
|
28
|
+
return t.map((t) => e(i, t));
|
|
29
|
+
}
|
|
30
|
+
case "month": {
|
|
31
|
+
let e = t(`${a.slice(0, 7)}-01`, o).slice(0, 7), n = i(e), s = r.day ?? Number(a.slice(8));
|
|
32
|
+
return [`${e}-${String(s === -1 ? n : Math.min(s, n)).padStart(2, "0")}`];
|
|
33
|
+
}
|
|
34
|
+
case "year": return [t(a, o * 12)];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { s as describeRepeat, c as nextOccurrences };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Makes an in-page link (`<a href="#id">`) scroll smoothly, as an onClick. The
|
|
4
|
+
* address gets the #id and focus moves to the section, so the keyboard and
|
|
5
|
+
* screen readers carry on from there. Opening in a new tab or window, and
|
|
6
|
+
* links to nothing on the page, are left to the browser.
|
|
7
|
+
*/
|
|
8
|
+
export declare function followSectionLink(event: MouseEvent<HTMLAnchorElement>): void;
|
|
9
|
+
//# sourceMappingURL=section-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section-link.d.ts","sourceRoot":"","sources":["../../packages/utils/section-link.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIxC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAoB5E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { reducedMotion as e } from "./motion.js";
|
|
3
|
+
//#region packages/utils/section-link.ts
|
|
4
|
+
function t(t) {
|
|
5
|
+
if (t.defaultPrevented || t.button !== 0 || t.metaKey || t.ctrlKey || t.shiftKey || t.altKey) return;
|
|
6
|
+
let { hash: n } = t.currentTarget, r = n && document.getElementById(decodeURIComponent(n.slice(1)));
|
|
7
|
+
r && (t.preventDefault(), r.scrollIntoView({ behavior: e() ? "instant" : "smooth" }), history.replaceState(history.state, "", n), r.hasAttribute("tabindex") || r.setAttribute("tabindex", "-1"), r.focus({ preventScroll: !0 }));
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as followSectionLink };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/** A flick at least this fast (px/ms) counts, however short. */
|
|
3
|
+
export declare const FLICK_SPEED = 0.5;
|
|
4
|
+
export interface SwipeDirection {
|
|
5
|
+
/** `inline` is x along the text: flipped in right-to-left layouts. */
|
|
6
|
+
axis: 'x' | 'y' | 'inline';
|
|
7
|
+
/** 1 for right or down (or the inline end), -1 for left or up (or the inline start). */
|
|
8
|
+
sign: 1 | -1;
|
|
9
|
+
}
|
|
10
|
+
export interface SwipeHandlers {
|
|
11
|
+
/** The finger moved; `d` is how far along the direction (negative once it's come back past the start). */
|
|
12
|
+
move: (d: number) => void;
|
|
13
|
+
/** Let go `d` along, moving at `speed` (px/ms) just before. */
|
|
14
|
+
release: (d: number, speed: number) => void;
|
|
15
|
+
/** Interrupted (a second finger, or the browser took the touch): put things back. */
|
|
16
|
+
cancel: () => void;
|
|
17
|
+
/** How far along letting go would act (close, open…); crossing it, either way, gives a light tap where phones can vibrate. */
|
|
18
|
+
threshold?: () => number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A finger swiping `ref` in `direction`. Only a deliberate swipe: one finger,
|
|
22
|
+
* mostly along the direction, not starting in a text field or on something
|
|
23
|
+
* that handles its own touch gestures (its touch-action says so), and not
|
|
24
|
+
* while what's under the finger can still scroll that way. While swiping, the
|
|
25
|
+
* element has data-swiping, the page doesn't scroll, and the click that ends
|
|
26
|
+
* it is swallowed.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useSwipe(ref: RefObject<HTMLElement | null>, direction: SwipeDirection | undefined, handlers: SwipeHandlers): void;
|
|
29
|
+
//# sourceMappingURL=swipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swipe.d.ts","sourceRoot":"","sources":["../../packages/utils/swipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AAErD,gEAAgE;AAChE,eAAO,MAAM,WAAW,MAAM,CAAC;AAM/B,MAAM,WAAW,cAAc;IAC3B,sEAAsE;IACtE,IAAI,EAAE,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC;IAC3B,wFAAwF;IACxF,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC1B,0GAA0G;IAC1G,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1B,+DAA+D;IAC/D,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,qFAAqF;IACrF,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,8HAA8H;IAC9H,SAAS,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACpB,GAAG,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,EAClC,SAAS,EAAE,cAAc,GAAG,SAAS,EACrC,QAAQ,EAAE,aAAa,QAkG1B"}
|