@cascivo/react 0.16.0 → 0.17.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 +6 -1
- package/dist/accordion/accordion.js +5 -4
- package/dist/app-shell/app-shell.css +1 -1
- package/dist/app-shell/app-shell.js +28 -26
- package/dist/app-shell/app-shell.module.js +8 -8
- package/dist/badge/badge.js +1 -1
- package/dist/button/button.css +1 -1
- package/dist/button/button.js +4 -1
- package/dist/button/button.module.js +4 -1
- package/dist/calendar/calendar.js +67 -63
- package/dist/card/card.css +1 -1
- package/dist/card/card.module.js +8 -8
- package/dist/checkbox/checkbox.css +1 -1
- package/dist/checkbox/checkbox.module.js +4 -4
- package/dist/combobox/combobox.js +55 -54
- package/dist/context-menu/context-menu.js +42 -38
- package/dist/data-table/data-table.css +1 -1
- package/dist/data-table/data-table.js +155 -160
- package/dist/data-table/data-table.module.js +29 -29
- package/dist/date-picker/date-picker.js +90 -89
- package/dist/field/field.css +1 -1
- package/dist/field/field.module.js +3 -3
- package/dist/index.d.ts +307 -145
- package/dist/infinite-scroll/infinite-scroll.css +1 -0
- package/dist/infinite-scroll/infinite-scroll.js +49 -0
- package/dist/infinite-scroll/infinite-scroll.module.js +8 -0
- package/dist/large-title-header/large-title-header.css +1 -0
- package/dist/large-title-header/large-title-header.js +38 -0
- package/dist/large-title-header/large-title-header.module.js +13 -0
- package/dist/layouts/src/grid/grid.css +1 -1
- package/dist/layouts/src/grid/grid.module.js +3 -3
- package/dist/link/link.css +1 -1
- package/dist/link/link.module.js +1 -1
- package/dist/menu/menu.js +47 -43
- package/dist/node/accordion/accordion.js +5 -4
- package/dist/node/app-shell/app-shell.js +28 -26
- package/dist/node/app-shell/app-shell.module.js +8 -8
- package/dist/node/badge/badge.js +1 -1
- package/dist/node/button/button.js +4 -1
- package/dist/node/button/button.module.js +4 -1
- package/dist/node/calendar/calendar.js +67 -63
- package/dist/node/card/card.module.js +8 -8
- package/dist/node/checkbox/checkbox.module.js +4 -4
- package/dist/node/combobox/combobox.js +55 -54
- package/dist/node/context-menu/context-menu.js +42 -38
- package/dist/node/data-table/data-table.js +155 -160
- package/dist/node/data-table/data-table.module.js +29 -29
- package/dist/node/date-picker/date-picker.js +90 -89
- package/dist/node/field/field.module.js +3 -3
- package/dist/node/infinite-scroll/infinite-scroll.js +49 -0
- package/dist/node/infinite-scroll/infinite-scroll.module.js +7 -0
- package/dist/node/large-title-header/large-title-header.js +38 -0
- package/dist/node/large-title-header/large-title-header.module.js +12 -0
- package/dist/node/layouts/src/grid/grid.module.js +3 -3
- package/dist/node/link/link.module.js +1 -1
- package/dist/node/menu/menu.js +47 -43
- package/dist/node/react/src/index.js +27 -23
- package/dist/node/reorder-list/reorder-list.js +143 -0
- package/dist/node/reorder-list/reorder-list.module.js +11 -0
- package/dist/node/search/search.js +5 -4
- package/dist/node/side-nav/side-nav.js +90 -89
- package/dist/node/skip-nav/skip-nav.js +1 -0
- package/dist/node/swap/swap.js +2 -3
- package/dist/node/switcher/switcher.js +1 -1
- package/dist/node/tabs/tabs.js +41 -40
- package/dist/node/tag/tag.module.js +2 -2
- package/dist/node/toc/toc.js +5 -4
- package/dist/node/virtual-list/virtual-list.js +40 -0
- package/dist/node/virtual-list/virtual-list.module.js +7 -0
- package/dist/node/wheel-picker/wheel-picker.js +84 -0
- package/dist/node/wheel-picker/wheel-picker.module.js +8 -0
- package/dist/react/src/index.js +27 -23
- package/dist/reorder-list/reorder-list.css +1 -0
- package/dist/reorder-list/reorder-list.js +143 -0
- package/dist/reorder-list/reorder-list.module.js +12 -0
- package/dist/search/search.js +5 -4
- package/dist/side-nav/side-nav.js +90 -89
- package/dist/skip-nav/skip-nav.js +1 -0
- package/dist/styles.css +48 -11
- package/dist/swap/swap.js +2 -3
- package/dist/switcher/switcher.js +1 -1
- package/dist/tabs/tabs.js +41 -40
- package/dist/tag/tag.css +1 -1
- package/dist/tag/tag.module.js +2 -2
- package/dist/toc/toc.js +5 -4
- package/dist/virtual-list/virtual-list.css +1 -0
- package/dist/virtual-list/virtual-list.js +40 -0
- package/dist/virtual-list/virtual-list.module.js +8 -0
- package/dist/wheel-picker/wheel-picker.css +1 -0
- package/dist/wheel-picker/wheel-picker.js +84 -0
- package/dist/wheel-picker/wheel-picker.module.js +9 -0
- package/package.json +4 -4
- package/readme.body.md +6 -1
- package/dist/node/react/src/theme.js +0 -78
- package/dist/node/storage/src/drivers.js +0 -34
- package/dist/node/storage/src/persisted-signal.js +0 -41
- package/dist/react/src/theme.js +0 -78
- package/dist/storage/src/drivers.js +0 -34
- package/dist/storage/src/persisted-signal.js +0 -41
|
@@ -112,26 +112,30 @@ import { ColorPicker as Lt } from "../../color-picker/color-picker.js";
|
|
|
112
112
|
import { Carousel as Rt } from "../../carousel/carousel.js";
|
|
113
113
|
import { Resizable as zt } from "../../resizable/resizable.js";
|
|
114
114
|
import { Dock as Bt } from "../../dock/dock.js";
|
|
115
|
-
import {
|
|
116
|
-
import {
|
|
117
|
-
import {
|
|
118
|
-
import {
|
|
119
|
-
import {
|
|
120
|
-
import {
|
|
121
|
-
import {
|
|
122
|
-
import {
|
|
123
|
-
import {
|
|
124
|
-
import {
|
|
125
|
-
import {
|
|
126
|
-
import {
|
|
127
|
-
import {
|
|
128
|
-
import {
|
|
129
|
-
import {
|
|
130
|
-
import {
|
|
131
|
-
import {
|
|
132
|
-
import {
|
|
133
|
-
import {
|
|
134
|
-
import {
|
|
135
|
-
import {
|
|
136
|
-
import {
|
|
137
|
-
|
|
115
|
+
import { LargeTitleHeader as Vt } from "../../large-title-header/large-title-header.js";
|
|
116
|
+
import { InfiniteScroll as Ht } from "../../infinite-scroll/infinite-scroll.js";
|
|
117
|
+
import { ReorderList as Ut } from "../../reorder-list/reorder-list.js";
|
|
118
|
+
import { VirtualList as Wt } from "../../virtual-list/virtual-list.js";
|
|
119
|
+
import { WheelPicker as Gt } from "../../wheel-picker/wheel-picker.js";
|
|
120
|
+
import { Drawer as Kt } from "../../drawer/drawer.js";
|
|
121
|
+
import { NativeSelect as qt } from "../../native-select/native-select.js";
|
|
122
|
+
import { CodeSnippet as Jt } from "../../code-snippet/code-snippet.js";
|
|
123
|
+
import { Steps as Yt } from "../../steps/steps.js";
|
|
124
|
+
import { Tile as Xt } from "../../tile/tile.js";
|
|
125
|
+
import { Indicator as Zt } from "../../indicator/indicator.js";
|
|
126
|
+
import { Join as Qt } from "../../join/join.js";
|
|
127
|
+
import { Stack as $t } from "../../stack/stack.js";
|
|
128
|
+
import { AppShell as en } from "../../app-shell/app-shell.js";
|
|
129
|
+
import { ChatBubble as tn } from "../../chat-bubble/chat-bubble.js";
|
|
130
|
+
import { RadialProgress as nn } from "../../radial-progress/radial-progress.js";
|
|
131
|
+
import { Swap as rn } from "../../swap/swap.js";
|
|
132
|
+
import { SwipeItem as an } from "../../swipe-item/swipe-item.js";
|
|
133
|
+
import { Grid as on, GridItem as sn } from "../../layouts/src/grid/grid.js";
|
|
134
|
+
import { Flex as cn } from "../../layouts/src/flex/flex.js";
|
|
135
|
+
import { Columns as ln } from "../../layouts/src/columns/columns.js";
|
|
136
|
+
import { Center as un } from "../../layouts/src/center/center.js";
|
|
137
|
+
import { Spacer as dn } from "../../layouts/src/spacer/spacer.js";
|
|
138
|
+
import { AutoGrid as fn } from "../../layouts/src/auto-grid/auto-grid.js";
|
|
139
|
+
import { PageHeader as pn } from "../../layouts/src/page-header/page-header.js";
|
|
140
|
+
import { DismissableLayer as mn, ErrorBoundary as hn, FocusScope as gn, Portal as _n, Presence as vn, Slot as yn, SuspenseBoundary as bn, ThemeProvider as xn, VisuallyHidden as Sn, applyTheme as Cn, batch as wn, cn as Tn, composeRefs as En, computePosition as Dn, computed as On, createMachine as kn, createScope as An, createStreamBuffer as jn, effect as Mn, getLinkComponent as Nn, mergeProps as Pn, setLinkComponent as Fn, setTheme as In, signal as Ln, themePreloadScript as Rn, themeSignal as zn, useAnchorPosition as Bn, useClipboard as Vn, useComputed as Hn, useControllableSignal as Un, useDisclosure as Wn, useEffectPropSignal as Gn, useId as Kn, useMachine as qn, useMediaQuery as Jn, useRovingFocus as Yn, useScope as Xn, useScrollLock as Zn, useSignal as Qn, useSignalEffect as $n, useSignals as er, useStreamBuffer as tr, useTheme as nr, useTypeahead as rr } from "@cascivo/core";
|
|
141
|
+
export { M as Accordion, N as AccordionContent, P as AccordionItem, F as AccordionTrigger, I as ActionSheet, d as Alert, ye as AlertDialog, en as AppShell, _t as AspectRatio, fn as AutoGrid, f as Avatar, p as AvatarGroup, c as Badge, $e as Blockquote, xe as BottomSheet, z as Breadcrumb, t as Button, dt as ButtonGroup, Ft as Calendar, r as Card, i as CardContent, a as CardFooter, o as CardHeader, s as CardTitle, Rt as Carousel, un as Center, tn as ChatBubble, v as Checkbox, He as CheckboxCard, Qe as Code, Jt as CodeSnippet, gt as Collapsible, Lt as ColorPicker, ln as Columns, ce as Combobox, ne as CommandMenu, we as Comparison, Tt as ContainedList, Et as ContainedListItem, Se as ContextMenu, Ce as ContextMenuItem, Ue as CopyButton, Dt as DataList, te as DataTable, le as DatePicker, It as DateRangePicker, mn as DismissableLayer, Bt as Dock, Kt as Drawer, w as Dropdown, Ie as Editable, X as EmptyState, hn as ErrorBoundary, Z as Fab, ct as Field, ue as FileUploader, lt as Filter, cn as Flex, gn as FocusScope, ae as Form, on as Grid, sn as GridItem, H as Header, Be as HeaderPanel, Xe as Heading, Te as HoverCard, Ee as HoverCardContent, De as HoverCardTrigger, ut as IconButton, h as Image, Zt as Indicator, Ht as InfiniteScroll, pt as InlineLoading, n as Input, Ne as InputGroup, Pe as InputGroupAddon, kt as Item, At as ItemActions, jt as ItemContent, Mt as ItemDescription, Nt as ItemMedia, Pt as ItemTitle, Qt as Join, L as Kbd, st as Label, Vt as LargeTitleHeader, R as Link, et as List, tt as ListItem, nt as LogViewer, he as Menu, vt as MenuButton, ge as MenuItem, _e as MenuSeparator, ve as MenuTrigger, bt as Menubar, l as Modal, ke as MultiSelect, qt as NativeSelect, xt as NavigationMenu, mt as Notification, ee as NumberInput, je as OtpInput, Q as OverflowMenu, pn as PageHeader, G as Pagination, Oe as PasswordInput, fe as Popover, pe as PopoverContent, me as PopoverTrigger, _n as Portal, vn as Presence, Je as Progress, Y as ProgressBar, Ye as ProgressCircle, K as ProgressIndicator, rt as Prose, it as PullToRefresh, at as QrCode, nn as RadialProgress, y as Radio, Le as RadioCard, Re as RadioCardGroup, b as RadioGroup, Fe as RatingGroup, ot as RelativeTime, Ut as ReorderList, zt as Resizable, ht as ScrollArea, $ as Search, Me as SegmentedControl, _ as Select, u as Separator, be as Sheet, ze as ShellHeader, W as SideNav, J as Skeleton, Ke as SkipNavLink, qe as SkipNavTarget, S as Slider, yn as Slot, dn as Spacer, e as Spinner, $t as Stack, We as Stat, Ge as Status, Yt as Steps, wt as StructuredList, bn as SuspenseBoundary, rn as Swap, an as SwipeItem, Ve as Switcher, O as Tabs, k as TabsContent, A as TabsList, j as TabsTrigger, q as Tag, Ae as TagsInput, Ze as Text, g as Textarea, xn as ThemeProvider, Xt as Tile, de as TimePicker, Ot as Timeline, T as ToastProvider, B as Toc, x as Toggle, ft as ToggleGroup, yt as Toggletip, C as Tooltip, St as TreeView, m as User, Wt as VirtualList, Sn as VisuallyHidden, Gt as WheelPicker, Cn as applyTheme, wn as batch, Tn as cn, En as composeRefs, Dn as computePosition, On as computed, oe as createForm, kn as createMachine, An as createScope, jn as createStreamBuffer, E as dismissAllToasts, Mn as effect, re as fuzzyMatch, ie as fuzzyScore, Nn as getLinkComponent, Pn as mergeProps, Fn as setLinkComponent, In as setTheme, Ln as signal, Rn as themePreloadScript, zn as themeSignal, Ct as treeViewMessages, Bn as useAnchorPosition, Vn as useClipboard, Hn as useComputed, Un as useControllableSignal, Wn as useDisclosure, Gn as useEffectPropSignal, se as useForm, Kn as useId, qn as useMachine, Jn as useMediaQuery, U as usePopover, Yn as useRovingFocus, Xn as useScope, Zn as useScrollLock, Qn as useSignal, $n as useSignalEffect, er as useSignals, tr as useStreamBuffer, nr as useTheme, D as useToast, V as useTocFromRegion, rr as useTypeahead };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import e from "./reorder-list.module.js";
|
|
4
|
+
import { useRef as t } from "react";
|
|
5
|
+
import { cn as n, useSignal as r, useSignalEffect as i, useSignals as a } from "@cascivo/core";
|
|
6
|
+
import { builtin as o, t as s } from "@cascivo/i18n";
|
|
7
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
8
|
+
//#region ../components/src/reorder-list/reorder-list.tsx
|
|
9
|
+
function u(e) {
|
|
10
|
+
return e.name ?? (typeof e.label == "string" ? e.label : e.id);
|
|
11
|
+
}
|
|
12
|
+
function d(e, t, n) {
|
|
13
|
+
let r = e.slice(), [i] = r.splice(t, 1);
|
|
14
|
+
return i && r.splice(n, 0, i), r;
|
|
15
|
+
}
|
|
16
|
+
function f({ value: f, onValueChange: p, disabled: m = !1, labels: h, className: g }) {
|
|
17
|
+
a();
|
|
18
|
+
let _ = t(null), v = r(null), y = r(""), b = t(f);
|
|
19
|
+
b.current = f;
|
|
20
|
+
let x = t(p);
|
|
21
|
+
x.current = p;
|
|
22
|
+
let S = t(m);
|
|
23
|
+
S.current = m;
|
|
24
|
+
let C = t(null), w = (e, t, n) => {
|
|
25
|
+
y.value = e ? e.replace("{name}", n.name).replace("{position}", String(n.position)).replace("{total}", String(n.total)) : t;
|
|
26
|
+
}, T = (e, t) => {
|
|
27
|
+
let n = b.current, r = Math.max(0, Math.min(n.length - 1, t));
|
|
28
|
+
if (r === e) return;
|
|
29
|
+
let i = n[e];
|
|
30
|
+
if (!i) return;
|
|
31
|
+
x.current(d(n, e, r)), v.value = r;
|
|
32
|
+
let a = {
|
|
33
|
+
name: u(i),
|
|
34
|
+
position: r + 1,
|
|
35
|
+
total: n.length
|
|
36
|
+
};
|
|
37
|
+
w(h?.moved, s(o.reorderList.moved, a), a);
|
|
38
|
+
}, E = (e) => {
|
|
39
|
+
let t = b.current, n = t[e];
|
|
40
|
+
if (!n) return;
|
|
41
|
+
C.current = t, v.value = e;
|
|
42
|
+
let r = {
|
|
43
|
+
name: u(n),
|
|
44
|
+
position: e + 1,
|
|
45
|
+
total: t.length
|
|
46
|
+
};
|
|
47
|
+
w(h?.grabbed, s(o.reorderList.grabbed, r), r);
|
|
48
|
+
}, D = () => {
|
|
49
|
+
let e = v.value;
|
|
50
|
+
if (e === null) return;
|
|
51
|
+
let t = b.current, n = t[e];
|
|
52
|
+
if (C.current = null, v.value = null, !n) return;
|
|
53
|
+
let r = {
|
|
54
|
+
name: u(n),
|
|
55
|
+
position: e + 1,
|
|
56
|
+
total: t.length
|
|
57
|
+
};
|
|
58
|
+
w(h?.dropped, s(o.reorderList.dropped, r), r);
|
|
59
|
+
}, O = () => {
|
|
60
|
+
let e = C.current, t = v.value;
|
|
61
|
+
if (C.current = null, v.value = null, !e) return;
|
|
62
|
+
x.current(e);
|
|
63
|
+
let n = t === null ? void 0 : e[t], r = {
|
|
64
|
+
name: n ? u(n) : "",
|
|
65
|
+
position: (t ?? 0) + 1,
|
|
66
|
+
total: e.length
|
|
67
|
+
};
|
|
68
|
+
w(h?.cancelled, s(o.reorderList.cancelled, r), r);
|
|
69
|
+
}, k = (e, t) => {
|
|
70
|
+
if (m) return;
|
|
71
|
+
let n = v.value;
|
|
72
|
+
if (e.key === " " || e.key === "Enter") {
|
|
73
|
+
e.preventDefault(), n === t ? D() : E(t);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (e.key === "Escape" && n !== null) {
|
|
77
|
+
e.preventDefault(), O();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
n === t && (e.key === "ArrowUp" ? (e.preventDefault(), T(t, t - 1)) : e.key === "ArrowDown" && (e.preventDefault(), T(t, t + 1)));
|
|
81
|
+
};
|
|
82
|
+
return i(() => {
|
|
83
|
+
let e = _.current;
|
|
84
|
+
if (!e || typeof window > "u") return;
|
|
85
|
+
let t = (t) => {
|
|
86
|
+
let n = v.value;
|
|
87
|
+
if (n === null || S.current) return;
|
|
88
|
+
let r = [...e.querySelectorAll("[data-reorder-row]")].findIndex((e) => {
|
|
89
|
+
let n = e.getBoundingClientRect();
|
|
90
|
+
return t.clientY >= n.top && t.clientY <= n.bottom;
|
|
91
|
+
});
|
|
92
|
+
r !== -1 && r !== n && T(n, r);
|
|
93
|
+
}, n = () => {
|
|
94
|
+
v.value !== null && C.current && D();
|
|
95
|
+
};
|
|
96
|
+
return window.addEventListener("pointermove", t), window.addEventListener("pointerup", n), window.addEventListener("pointercancel", n), () => {
|
|
97
|
+
window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", n), window.removeEventListener("pointercancel", n);
|
|
98
|
+
};
|
|
99
|
+
}), /* @__PURE__ */ l("div", {
|
|
100
|
+
className: n(e.root, g),
|
|
101
|
+
children: [/* @__PURE__ */ c("ul", {
|
|
102
|
+
ref: _,
|
|
103
|
+
className: e.list,
|
|
104
|
+
children: f.map((t, n) => /* @__PURE__ */ l("li", {
|
|
105
|
+
"data-reorder-row": "",
|
|
106
|
+
"data-active": v.value === n ? "" : void 0,
|
|
107
|
+
className: e.row,
|
|
108
|
+
children: [/* @__PURE__ */ c("button", {
|
|
109
|
+
type: "button",
|
|
110
|
+
disabled: m,
|
|
111
|
+
"aria-label": h?.handle ? h.handle.replace("{name}", u(t)) : s(o.reorderList.handle, { name: u(t) }),
|
|
112
|
+
"aria-pressed": v.value === n,
|
|
113
|
+
className: e.handle,
|
|
114
|
+
onKeyDown: (e) => k(e, n),
|
|
115
|
+
onPointerDown: () => {
|
|
116
|
+
m || E(n);
|
|
117
|
+
},
|
|
118
|
+
children: /* @__PURE__ */ c("svg", {
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
viewBox: "0 0 16 16",
|
|
121
|
+
className: e.grip,
|
|
122
|
+
children: /* @__PURE__ */ c("path", {
|
|
123
|
+
d: "M6 4h.01M10 4h.01M6 8h.01M10 8h.01M6 12h.01M10 12h.01",
|
|
124
|
+
stroke: "currentColor",
|
|
125
|
+
strokeWidth: "2",
|
|
126
|
+
strokeLinecap: "round"
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
}), /* @__PURE__ */ c("span", {
|
|
130
|
+
className: e.label,
|
|
131
|
+
children: t.label
|
|
132
|
+
})]
|
|
133
|
+
}, t.id))
|
|
134
|
+
}), /* @__PURE__ */ c("span", {
|
|
135
|
+
role: "status",
|
|
136
|
+
"aria-live": "polite",
|
|
137
|
+
className: e.srOnly,
|
|
138
|
+
children: y.value
|
|
139
|
+
})]
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { f as ReorderList };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import e from "./search.module.js";
|
|
4
4
|
import { useRef as t } from "react";
|
|
5
|
-
import { cn as n, focusElement as r,
|
|
5
|
+
import { cn as n, focusElement as r, useControllableSignal as i, useId as a, useSignalEffect as o, useSignals as s } from "@cascivo/core";
|
|
6
6
|
import { builtin as c, t as l } from "@cascivo/i18n";
|
|
7
7
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
8
8
|
//#region ../components/src/search/search.tsx
|
|
@@ -30,9 +30,10 @@ function f() {
|
|
|
30
30
|
}
|
|
31
31
|
function p({ value: p, defaultValue: m = "", onValueChange: h, onChange: g, onSearch: _, debounceMs: v = 300, placeholder: y, size: b = "md", label: x, disabled: S = !1, clearLabel: C, id: w, className: T }) {
|
|
32
32
|
s();
|
|
33
|
-
let E = y ?? l(c.search.placeholder), D = x ?? l(c.search.label), O = C ?? l(c.search.clear), k = t(null), A =
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
let E = y ?? l(c.search.placeholder), D = x ?? l(c.search.label), O = C ?? l(c.search.clear), k = t(null), A = a("cascade-search"), j = w ?? A, M = p !== void 0, [N] = i({
|
|
34
|
+
value: p,
|
|
35
|
+
defaultValue: m
|
|
36
|
+
}), P = t(_);
|
|
36
37
|
P.current = _;
|
|
37
38
|
let F = t(null), I = () => {
|
|
38
39
|
F.current !== null && (clearTimeout(F.current), F.current = null);
|
|
@@ -4,21 +4,21 @@ import { Tooltip as e } from "../tooltip/tooltip.js";
|
|
|
4
4
|
import { usePopover as t } from "../popover/use-popover.js";
|
|
5
5
|
import n from "./side-nav.module.js";
|
|
6
6
|
import { Fragment as r, useId as i } from "react";
|
|
7
|
-
import { cn as a, focusElement as o, getLinkComponent as s,
|
|
8
|
-
import { builtin as
|
|
9
|
-
import { Fragment as
|
|
7
|
+
import { cn as a, focusElement as o, getLinkComponent as s, useControllableSignal as c, useSignal as l, useSignals as u } from "@cascivo/core";
|
|
8
|
+
import { builtin as d, t as f } from "@cascivo/i18n";
|
|
9
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
10
10
|
//#region ../components/src/side-nav/side-nav.tsx
|
|
11
|
-
function
|
|
11
|
+
function g(e) {
|
|
12
12
|
return !("type" in e);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
return /* @__PURE__ */
|
|
14
|
+
function _() {
|
|
15
|
+
return /* @__PURE__ */ m("svg", {
|
|
16
16
|
viewBox: "0 0 16 16",
|
|
17
17
|
width: "14",
|
|
18
18
|
height: "14",
|
|
19
19
|
"aria-hidden": "true",
|
|
20
20
|
className: n.checkMark,
|
|
21
|
-
children: /* @__PURE__ */
|
|
21
|
+
children: /* @__PURE__ */ m("path", {
|
|
22
22
|
d: "M3.5 8.5l3 3 6-7",
|
|
23
23
|
fill: "none",
|
|
24
24
|
stroke: "currentColor",
|
|
@@ -28,20 +28,20 @@ function g() {
|
|
|
28
28
|
})
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
let o = t ? "menuitem" : void 0, c = a(n.link, n.sublink, i), l = /* @__PURE__ */
|
|
33
|
-
e.icon ? /* @__PURE__ */
|
|
31
|
+
function v(e, { inMenu: t, onActivate: r, extraClass: i }) {
|
|
32
|
+
let o = t ? "menuitem" : void 0, c = a(n.link, n.sublink, i), l = /* @__PURE__ */ h(p, { children: [
|
|
33
|
+
e.icon ? /* @__PURE__ */ m("span", {
|
|
34
34
|
className: n.icon,
|
|
35
35
|
"aria-hidden": "true",
|
|
36
36
|
children: e.icon
|
|
37
37
|
}) : null,
|
|
38
|
-
/* @__PURE__ */
|
|
38
|
+
/* @__PURE__ */ m("span", {
|
|
39
39
|
className: n.label,
|
|
40
40
|
children: e.label
|
|
41
41
|
}),
|
|
42
|
-
e.selected ? /* @__PURE__ */
|
|
42
|
+
e.selected ? /* @__PURE__ */ m(_, {}) : null
|
|
43
43
|
] });
|
|
44
|
-
return e.onSelect && !e.href ? /* @__PURE__ */
|
|
44
|
+
return e.onSelect && !e.href ? /* @__PURE__ */ m("button", {
|
|
45
45
|
type: "button",
|
|
46
46
|
role: o,
|
|
47
47
|
"aria-current": e.active ? "page" : void 0,
|
|
@@ -53,7 +53,7 @@ function _(e, { inMenu: t, onActivate: r, extraClass: i }) {
|
|
|
53
53
|
e.onSelect?.(), r?.();
|
|
54
54
|
},
|
|
55
55
|
children: l
|
|
56
|
-
}) : /* @__PURE__ */
|
|
56
|
+
}) : /* @__PURE__ */ m(s(), {
|
|
57
57
|
href: e.disabled ? void 0 : e.href,
|
|
58
58
|
role: o,
|
|
59
59
|
"aria-current": e.active ? "page" : void 0,
|
|
@@ -72,16 +72,16 @@ function _(e, { inMenu: t, onActivate: r, extraClass: i }) {
|
|
|
72
72
|
children: l
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function y(e) {
|
|
76
76
|
if (typeof Intl < "u" && "Segmenter" in Intl) {
|
|
77
77
|
let t = new Intl.Segmenter(void 0, { granularity: "grapheme" });
|
|
78
78
|
for (let n of t.segment(e)) return n.segment;
|
|
79
79
|
}
|
|
80
80
|
return [...e][0] ?? "";
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
let { triggerRef: i, popoverRef: a, isOpen: s, anchorName: c, open: l, close: u, toggle: d } = t(),
|
|
84
|
-
return /* @__PURE__ */
|
|
82
|
+
function b({ item: e }) {
|
|
83
|
+
let { triggerRef: i, popoverRef: a, isOpen: s, anchorName: c, open: l, close: u, toggle: d } = t(), f = "[role=\"menuitem\"]:not([disabled]):not([aria-disabled=\"true\"])";
|
|
84
|
+
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("button", {
|
|
85
85
|
ref: i,
|
|
86
86
|
type: "button",
|
|
87
87
|
"aria-haspopup": "menu",
|
|
@@ -96,21 +96,21 @@ function y({ item: e }) {
|
|
|
96
96
|
e.preventDefault(), s.value || l();
|
|
97
97
|
let t = a.current;
|
|
98
98
|
t && setTimeout(() => {
|
|
99
|
-
t.querySelector(
|
|
99
|
+
t.querySelector(f)?.focus();
|
|
100
100
|
}, 0);
|
|
101
101
|
} else e.key === "Escape" && u();
|
|
102
102
|
},
|
|
103
|
-
children: e.icon ? /* @__PURE__ */
|
|
103
|
+
children: e.icon ? /* @__PURE__ */ m("span", {
|
|
104
104
|
className: n.icon,
|
|
105
105
|
"aria-hidden": "true",
|
|
106
106
|
children: e.icon
|
|
107
|
-
}) : /* @__PURE__ */
|
|
107
|
+
}) : /* @__PURE__ */ m("span", {
|
|
108
108
|
className: n.fallbackIcon,
|
|
109
109
|
"data-fallback-icon": !0,
|
|
110
110
|
"aria-hidden": "true",
|
|
111
|
-
children:
|
|
111
|
+
children: y(e.label)
|
|
112
112
|
})
|
|
113
|
-
}), /* @__PURE__ */
|
|
113
|
+
}), /* @__PURE__ */ h("div", {
|
|
114
114
|
ref: a,
|
|
115
115
|
popover: "auto",
|
|
116
116
|
role: "menu",
|
|
@@ -120,93 +120,94 @@ function y({ item: e }) {
|
|
|
120
120
|
onKeyDown: (e) => {
|
|
121
121
|
let t = a.current;
|
|
122
122
|
if (!t) return;
|
|
123
|
-
let n = Array.from(t.querySelectorAll(
|
|
123
|
+
let n = Array.from(t.querySelectorAll(f)), r = n.indexOf(e.target);
|
|
124
124
|
e.key === "ArrowDown" ? (e.preventDefault(), n[(r + 1) % n.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), n[(r - 1 + n.length) % n.length]?.focus()) : e.key === "Escape" && (e.preventDefault(), u(), o(i.current));
|
|
125
125
|
},
|
|
126
|
-
children: [/* @__PURE__ */
|
|
126
|
+
children: [/* @__PURE__ */ m("div", {
|
|
127
127
|
className: n.railFlyoutCaption,
|
|
128
128
|
"aria-hidden": "true",
|
|
129
129
|
children: e.label
|
|
130
|
-
}), e.items.map((e, t) =>
|
|
130
|
+
}), e.items.map((e, t) => g(e) ? /* @__PURE__ */ m(r, { children: v(e, {
|
|
131
131
|
inMenu: !0,
|
|
132
132
|
onActivate: u,
|
|
133
133
|
extraClass: n.flyoutItem
|
|
134
|
-
}) }, t) : e.type === "separator" ? /* @__PURE__ */
|
|
134
|
+
}) }, t) : e.type === "separator" ? /* @__PURE__ */ m("div", {
|
|
135
135
|
role: "separator",
|
|
136
136
|
className: n.flyoutSeparator
|
|
137
|
-
}, t) : /* @__PURE__ */
|
|
137
|
+
}, t) : /* @__PURE__ */ m("div", {
|
|
138
138
|
className: n.railFlyoutCaption,
|
|
139
139
|
"aria-hidden": "true",
|
|
140
140
|
children: e.label
|
|
141
141
|
}, t))]
|
|
142
142
|
})] });
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
let
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
"
|
|
158
|
-
"data-
|
|
159
|
-
|
|
144
|
+
function x({ items: t, groups: r, collapsed: o, defaultCollapsed: _ = !1, onCollapsedChange: x, ariaLabel: S, collapseLabel: C, expandLabel: w, expandOnHover: T = !1, showCollapseToggle: E = !0, header: D, footer: O, className: k }) {
|
|
145
|
+
u();
|
|
146
|
+
let A = S ?? f(d.sideNav.nav), j = C ?? f(d.sideNav.collapse), M = w ?? f(d.sideNav.expand), N = i(), [P] = c({
|
|
147
|
+
value: o,
|
|
148
|
+
defaultValue: _
|
|
149
|
+
}), F = r ?? (t ? [{ items: t }] : [{ items: [] }]), I = l(F.flatMap((e) => e.items).filter((e) => e.items?.some((e) => g(e) && e.active)).map((e) => e.label)), L = (e) => {
|
|
150
|
+
let t = I.value;
|
|
151
|
+
I.value = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
152
|
+
}, R = () => {
|
|
153
|
+
let e = !P.value;
|
|
154
|
+
o === void 0 && (P.value = e), x?.(e);
|
|
155
|
+
}, z = P.value;
|
|
156
|
+
return /* @__PURE__ */ h("nav", {
|
|
157
|
+
"aria-label": A,
|
|
158
|
+
"data-state": z ? "collapsed" : "expanded",
|
|
159
|
+
"data-expand-on-hover": z && T ? "" : void 0,
|
|
160
|
+
className: a(n.sideNav, k),
|
|
160
161
|
children: [
|
|
161
|
-
|
|
162
|
+
D && /* @__PURE__ */ m("div", {
|
|
162
163
|
className: n.header,
|
|
163
|
-
children:
|
|
164
|
+
children: D
|
|
164
165
|
}),
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
+
/* @__PURE__ */ m("ul", {
|
|
166
167
|
className: n.list,
|
|
167
|
-
children:
|
|
168
|
+
children: F.map((t, r) => /* @__PURE__ */ h("li", {
|
|
168
169
|
className: n.group,
|
|
169
|
-
children: [t.label && /* @__PURE__ */
|
|
170
|
+
children: [t.label && /* @__PURE__ */ m("h3", {
|
|
170
171
|
className: n.groupLabel,
|
|
171
172
|
children: t.label
|
|
172
|
-
}), /* @__PURE__ */
|
|
173
|
+
}), /* @__PURE__ */ m("ul", {
|
|
173
174
|
className: n.groupItems,
|
|
174
175
|
children: t.items.map((t, i) => {
|
|
175
176
|
let a = `${r}-${i}`;
|
|
176
177
|
if (t.items) {
|
|
177
|
-
if (
|
|
178
|
-
let e =
|
|
179
|
-
return /* @__PURE__ */
|
|
178
|
+
if (z && !T) return /* @__PURE__ */ m("li", { children: /* @__PURE__ */ m(b, { item: t }) }, t.id ?? a);
|
|
179
|
+
let e = I.value.includes(t.label), r = `${N}-group-${a}`;
|
|
180
|
+
return /* @__PURE__ */ h("li", { children: [/* @__PURE__ */ h("button", {
|
|
180
181
|
type: "button",
|
|
181
182
|
"aria-expanded": e,
|
|
182
183
|
"aria-controls": r,
|
|
183
|
-
"aria-label":
|
|
184
|
+
"aria-label": z ? t.label : void 0,
|
|
184
185
|
"data-state": e ? "open" : "closed",
|
|
185
186
|
className: n.groupTrigger,
|
|
186
|
-
onClick: () =>
|
|
187
|
+
onClick: () => L(t.label),
|
|
187
188
|
children: [
|
|
188
|
-
t.icon ? /* @__PURE__ */
|
|
189
|
+
t.icon ? /* @__PURE__ */ m("span", {
|
|
189
190
|
className: n.icon,
|
|
190
191
|
"aria-hidden": "true",
|
|
191
192
|
children: t.icon
|
|
192
|
-
}) :
|
|
193
|
+
}) : z ? /* @__PURE__ */ m("span", {
|
|
193
194
|
className: n.fallbackIcon,
|
|
194
195
|
"data-fallback-icon": !0,
|
|
195
196
|
"aria-hidden": "true",
|
|
196
|
-
children:
|
|
197
|
+
children: y(t.label)
|
|
197
198
|
}) : null,
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ m("span", {
|
|
199
200
|
className: n.label,
|
|
200
|
-
"data-rail-hidden":
|
|
201
|
+
"data-rail-hidden": z || void 0,
|
|
201
202
|
children: t.label
|
|
202
203
|
}),
|
|
203
|
-
/* @__PURE__ */
|
|
204
|
+
/* @__PURE__ */ m("svg", {
|
|
204
205
|
viewBox: "0 0 16 16",
|
|
205
206
|
width: "12",
|
|
206
207
|
height: "12",
|
|
207
208
|
"aria-hidden": "true",
|
|
208
209
|
className: n.groupIndicator,
|
|
209
|
-
children: /* @__PURE__ */
|
|
210
|
+
children: /* @__PURE__ */ m("path", {
|
|
210
211
|
d: "M4 6l4 4 4-4",
|
|
211
212
|
fill: "none",
|
|
212
213
|
stroke: "currentColor",
|
|
@@ -216,47 +217,47 @@ function b({ items: t, groups: r, collapsed: o, defaultCollapsed: g = !1, onColl
|
|
|
216
217
|
})
|
|
217
218
|
})
|
|
218
219
|
]
|
|
219
|
-
}), /* @__PURE__ */
|
|
220
|
+
}), /* @__PURE__ */ m("div", {
|
|
220
221
|
id: r,
|
|
221
222
|
"data-state": e ? "open" : "closed",
|
|
222
223
|
className: n.sublist,
|
|
223
|
-
children: /* @__PURE__ */
|
|
224
|
+
children: /* @__PURE__ */ m("ul", {
|
|
224
225
|
className: n.sublistInner,
|
|
225
|
-
children: t.items.map((e, t) =>
|
|
226
|
+
children: t.items.map((e, t) => g(e) ? /* @__PURE__ */ m("li", { children: v(e, { inMenu: !1 }) }, t) : e.type === "separator" ? /* @__PURE__ */ m("li", {
|
|
226
227
|
role: "separator",
|
|
227
228
|
className: n.subSeparator
|
|
228
|
-
}, t) : /* @__PURE__ */
|
|
229
|
+
}, t) : /* @__PURE__ */ m("li", {
|
|
229
230
|
className: n.subGroupLabel,
|
|
230
231
|
children: e.label
|
|
231
232
|
}, t))
|
|
232
233
|
})
|
|
233
234
|
})] }, t.id ?? a);
|
|
234
235
|
}
|
|
235
|
-
let o = /* @__PURE__ */
|
|
236
|
-
t.icon ? /* @__PURE__ */
|
|
236
|
+
let o = /* @__PURE__ */ h(p, { children: [
|
|
237
|
+
t.icon ? /* @__PURE__ */ m("span", {
|
|
237
238
|
className: n.icon,
|
|
238
239
|
"aria-hidden": "true",
|
|
239
240
|
children: t.icon
|
|
240
|
-
}) :
|
|
241
|
+
}) : z ? /* @__PURE__ */ m("span", {
|
|
241
242
|
className: n.fallbackIcon,
|
|
242
243
|
"data-fallback-icon": !0,
|
|
243
244
|
"aria-hidden": "true",
|
|
244
|
-
children:
|
|
245
|
+
children: y(t.label)
|
|
245
246
|
}) : null,
|
|
246
|
-
/* @__PURE__ */
|
|
247
|
+
/* @__PURE__ */ m("span", {
|
|
247
248
|
className: n.label,
|
|
248
|
-
"data-rail-hidden":
|
|
249
|
+
"data-rail-hidden": z || void 0,
|
|
249
250
|
children: t.label
|
|
250
251
|
}),
|
|
251
|
-
t.trailing == null ? null : /* @__PURE__ */
|
|
252
|
+
t.trailing == null ? null : /* @__PURE__ */ m("span", {
|
|
252
253
|
className: n.trailing,
|
|
253
|
-
"data-rail-hidden":
|
|
254
|
+
"data-rail-hidden": z || void 0,
|
|
254
255
|
children: t.trailing
|
|
255
256
|
})
|
|
256
257
|
] }), c = t.tone && t.tone !== "default" ? t.tone : void 0, l = {
|
|
257
258
|
href: t.disabled ? void 0 : t.href,
|
|
258
259
|
"aria-current": t.active ? "page" : void 0,
|
|
259
|
-
"aria-label":
|
|
260
|
+
"aria-label": z ? t.label : void 0,
|
|
260
261
|
"aria-disabled": t.disabled || void 0,
|
|
261
262
|
tabIndex: t.disabled ? -1 : void 0,
|
|
262
263
|
"data-state": t.active ? "active" : void 0,
|
|
@@ -270,29 +271,29 @@ function b({ items: t, groups: r, collapsed: o, defaultCollapsed: g = !1, onColl
|
|
|
270
271
|
t.onClick?.(e);
|
|
271
272
|
}
|
|
272
273
|
};
|
|
273
|
-
if (t.render) return /* @__PURE__ */
|
|
274
|
+
if (t.render) return /* @__PURE__ */ m("li", {
|
|
274
275
|
className: n.customItem,
|
|
275
276
|
children: t.render({
|
|
276
|
-
collapsed:
|
|
277
|
+
collapsed: z,
|
|
277
278
|
children: o,
|
|
278
279
|
linkProps: l
|
|
279
280
|
})
|
|
280
281
|
}, t.id ?? a);
|
|
281
|
-
let u = s(), d = t.onClick && !t.href ? /* @__PURE__ */
|
|
282
|
+
let u = s(), d = t.onClick && !t.href ? /* @__PURE__ */ m("button", {
|
|
282
283
|
type: "button",
|
|
283
284
|
"aria-current": t.active ? "page" : void 0,
|
|
284
|
-
"aria-label":
|
|
285
|
+
"aria-label": z ? t.label : void 0,
|
|
285
286
|
"data-state": t.active ? "active" : void 0,
|
|
286
287
|
"data-tone": c,
|
|
287
288
|
className: n.link,
|
|
288
289
|
disabled: t.disabled,
|
|
289
290
|
onClick: (e) => t.onClick?.(e),
|
|
290
291
|
children: o
|
|
291
|
-
}) : /* @__PURE__ */
|
|
292
|
+
}) : /* @__PURE__ */ m(u, {
|
|
292
293
|
...l,
|
|
293
294
|
children: o
|
|
294
295
|
});
|
|
295
|
-
return /* @__PURE__ */
|
|
296
|
+
return /* @__PURE__ */ m("li", { children: z && !T ? /* @__PURE__ */ m(e, {
|
|
296
297
|
content: t.label,
|
|
297
298
|
placement: "right",
|
|
298
299
|
children: d
|
|
@@ -301,22 +302,22 @@ function b({ items: t, groups: r, collapsed: o, defaultCollapsed: g = !1, onColl
|
|
|
301
302
|
})]
|
|
302
303
|
}, r))
|
|
303
304
|
}),
|
|
304
|
-
|
|
305
|
+
O && /* @__PURE__ */ m("div", {
|
|
305
306
|
className: n.footer,
|
|
306
|
-
children:
|
|
307
|
+
children: O
|
|
307
308
|
}),
|
|
308
|
-
|
|
309
|
+
E && /* @__PURE__ */ m("button", {
|
|
309
310
|
type: "button",
|
|
310
|
-
"aria-label":
|
|
311
|
+
"aria-label": z ? M : j,
|
|
311
312
|
className: n.collapseToggle,
|
|
312
|
-
onClick:
|
|
313
|
-
children: /* @__PURE__ */
|
|
313
|
+
onClick: R,
|
|
314
|
+
children: /* @__PURE__ */ m("svg", {
|
|
314
315
|
viewBox: "0 0 16 16",
|
|
315
316
|
width: "14",
|
|
316
317
|
height: "14",
|
|
317
318
|
"aria-hidden": "true",
|
|
318
319
|
className: n.collapseIcon,
|
|
319
|
-
children: /* @__PURE__ */
|
|
320
|
+
children: /* @__PURE__ */ m("path", {
|
|
320
321
|
d: "M10 4l-4 4 4 4",
|
|
321
322
|
fill: "none",
|
|
322
323
|
stroke: "currentColor",
|
|
@@ -330,4 +331,4 @@ function b({ items: t, groups: r, collapsed: o, defaultCollapsed: g = !1, onColl
|
|
|
330
331
|
});
|
|
331
332
|
}
|
|
332
333
|
//#endregion
|
|
333
|
-
export {
|
|
334
|
+
export { x as SideNav };
|