@devalok/shilp-sutra 0.8.3 → 0.9.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/_chunks/avatar.js +50 -0
- package/dist/_chunks/button.js +95 -0
- package/dist/_chunks/card.js +40 -0
- package/dist/_chunks/checkbox.js +14 -0
- package/dist/_chunks/form.js +27 -0
- package/dist/_chunks/primitives.js +6965 -0
- package/dist/_chunks/sidebar.js +592 -0
- package/dist/_chunks/spinner.js +34 -0
- package/dist/_chunks/tiptap.js +15254 -0
- package/dist/_chunks/tooltip.js +13 -0
- package/dist/_chunks/tree-view.js +304 -0
- package/dist/_chunks/use-calendar.js +990 -0
- package/dist/_chunks/utils.js +15 -0
- package/dist/_chunks/vendor.js +5823 -0
- package/dist/composed/avatar-group.js +20 -20
- package/dist/composed/command-palette.js +1 -1
- package/dist/composed/confirm-dialog.js +5 -5
- package/dist/composed/content-card.d.ts +1 -1
- package/dist/composed/content-card.js +6 -6
- package/dist/composed/date-picker/index.js +13 -0
- package/dist/composed/empty-state.js +10 -10
- package/dist/composed/error-boundary.js +2 -2
- package/dist/composed/global-loading.js +4 -4
- package/dist/composed/index.js +45 -53
- package/dist/composed/loading-skeleton.js +2 -2
- package/dist/composed/member-picker.js +5 -5
- package/dist/composed/page-header.js +4 -4
- package/dist/composed/page-skeletons.js +1 -1
- package/dist/composed/priority-indicator.js +6 -6
- package/dist/composed/rich-text-editor.js +422 -209
- package/dist/composed/schedule-view.js +1 -1
- package/dist/composed/simple-tooltip.js +6 -6
- package/dist/composed/status-badge.d.ts +1 -1
- package/dist/composed/status-badge.js +2 -2
- package/dist/shell/bottom-navbar.js +1 -1
- package/dist/shell/notification-center.js +2 -2
- package/dist/shell/notification-preferences.js +32 -33
- package/dist/shell/sidebar.js +24 -24
- package/dist/shell/top-bar.js +22 -22
- package/dist/ui/accordion.js +17 -17
- package/dist/ui/alert-dialog.js +29 -29
- package/dist/ui/alert.d.ts +2 -2
- package/dist/ui/alert.js +65 -44
- package/dist/ui/aspect-ratio.js +1 -1
- package/dist/ui/autocomplete.js +11 -11
- package/dist/ui/avatar.d.ts +1 -1
- package/dist/ui/avatar.js +67 -25
- package/dist/ui/badge.d.ts +2 -2
- package/dist/ui/badge.js +115 -91
- package/dist/ui/banner.d.ts +1 -1
- package/dist/ui/banner.js +5 -5
- package/dist/ui/breadcrumb.js +14 -14
- package/dist/ui/button-group.js +30 -15
- package/dist/ui/button.d.ts +2 -2
- package/dist/ui/button.js +114 -71
- package/dist/ui/card.js +66 -22
- package/dist/ui/charts/index.js +1221 -18
- package/dist/ui/checkbox.js +25 -5
- package/dist/ui/chip.d.ts +4 -4
- package/dist/ui/chip.js +2 -2
- package/dist/ui/code.js +1 -1
- package/dist/ui/collapsible.js +5 -5
- package/dist/ui/color-input.js +11 -11
- package/dist/ui/combobox.js +12 -12
- package/dist/ui/container.js +4 -4
- package/dist/ui/context-menu.js +37 -37
- package/dist/ui/data-table-toolbar.js +18 -18
- package/dist/ui/data-table.js +2 -2
- package/dist/ui/dialog.js +33 -33
- package/dist/ui/dropdown-menu.js +60 -60
- package/dist/ui/file-upload.js +1 -1
- package/dist/ui/form.js +36 -15
- package/dist/ui/hover-card.js +7 -7
- package/dist/ui/icon-button.js +9 -9
- package/dist/ui/index.js +523 -325
- package/dist/ui/input-otp.d.ts +2 -2
- package/dist/ui/input-otp.js +14 -14
- package/dist/ui/input.js +56 -28
- package/dist/ui/label.js +18 -4
- package/dist/ui/lib/utils.js +4 -5
- package/dist/ui/link.js +9 -9
- package/dist/ui/menubar.js +81 -81
- package/dist/ui/navigation-menu.js +42 -42
- package/dist/ui/number-input.js +13 -13
- package/dist/ui/pagination.js +5 -5
- package/dist/ui/popover.js +9 -9
- package/dist/ui/progress.d.ts +1 -1
- package/dist/ui/progress.js +15 -15
- package/dist/ui/radio.js +10 -10
- package/dist/ui/search-input.js +5 -5
- package/dist/ui/segmented-control.js +91 -83
- package/dist/ui/select.js +52 -52
- package/dist/ui/separator.js +20 -5
- package/dist/ui/sheet.js +28 -28
- package/dist/ui/sidebar.js +36 -560
- package/dist/ui/skeleton.d.ts +1 -1
- package/dist/ui/skeleton.js +9 -9
- package/dist/ui/slider.js +11 -11
- package/dist/ui/spinner.js +37 -2
- package/dist/ui/stack.js +1 -1
- package/dist/ui/stat-card.js +1 -1
- package/dist/ui/stepper.js +15 -15
- package/dist/ui/switch.js +22 -3
- package/dist/ui/table.js +1 -1
- package/dist/ui/tabs.js +59 -32
- package/dist/ui/text.js +2 -2
- package/dist/ui/textarea.js +7 -7
- package/dist/ui/toast.d.ts +1 -1
- package/dist/ui/toast.js +28 -28
- package/dist/ui/toggle-group.js +11 -11
- package/dist/ui/toggle.js +9 -9
- package/dist/ui/tooltip.js +17 -6
- package/dist/ui/transitions.js +68 -58
- package/dist/ui/tree-view/index.js +7 -0
- package/dist/ui/visually-hidden.js +3 -3
- package/llms-full.txt +1 -1
- package/llms.txt +7 -0
- package/package.json +656 -701
- package/dist/_virtual/client.js +0 -5
- package/dist/_virtual/index.js +0 -5
- package/dist/_virtual/react-dom-client.development.js +0 -5
- package/dist/_virtual/react-dom-client.production.js +0 -5
- package/dist/_virtual/scheduler.development.js +0 -5
- package/dist/_virtual/scheduler.production.js +0 -5
- package/dist/composed/date-picker/calendar-grid.js +0 -194
- package/dist/composed/date-picker/date-picker.js +0 -124
- package/dist/composed/date-picker/date-range-picker.js +0 -167
- package/dist/composed/date-picker/date-time-picker.js +0 -193
- package/dist/composed/date-picker/month-picker.js +0 -53
- package/dist/composed/date-picker/presets.js +0 -84
- package/dist/composed/date-picker/time-picker.js +0 -181
- package/dist/composed/date-picker/use-calendar.js +0 -17
- package/dist/composed/date-picker/year-picker.js +0 -45
- package/dist/composed/extensions/emoji-suggestion.js +0 -119
- package/dist/composed/extensions/file-attachment.js +0 -55
- package/dist/composed/extensions/mention-suggestion.js +0 -79
- package/dist/node_modules/.pnpm/@emoji-mart_data@1.2.1/node_modules/@emoji-mart/data/sets/15/native.json.js +0 -40141
- package/dist/node_modules/.pnpm/@emoji-mart_react@1.1.1_emoji-mart@5.6.0_react@19.2.4/node_modules/@emoji-mart/react/dist/module.js +0 -17
- package/dist/node_modules/.pnpm/emoji-mart@5.6.0/node_modules/emoji-mart/dist/module.js +0 -2958
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.development.js +0 -17062
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/cjs/react-dom-client.production.js +0 -9790
- package/dist/node_modules/.pnpm/react-dom@19.2.4_react@19.2.4/node_modules/react-dom/client.js +0 -20
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.development.js +0 -237
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/cjs/scheduler.production.js +0 -234
- package/dist/node_modules/.pnpm/scheduler@0.27.0/node_modules/scheduler/index.js +0 -11
- package/dist/primitives/_internal/number.js +0 -6
- package/dist/primitives/_internal/primitive.js +0 -9
- package/dist/primitives/_internal/react-arrow.js +0 -13
- package/dist/primitives/_internal/react-collection.js +0 -48
- package/dist/primitives/_internal/react-compose-refs.js +0 -29
- package/dist/primitives/_internal/react-context.js +0 -76
- package/dist/primitives/_internal/react-direction.js +0 -10
- package/dist/primitives/_internal/react-dismissable-layer.js +0 -103
- package/dist/primitives/_internal/react-focus-guards.js +0 -17
- package/dist/primitives/_internal/react-focus-scope.js +0 -137
- package/dist/primitives/_internal/react-id.js +0 -14
- package/dist/primitives/_internal/react-popper.js +0 -137
- package/dist/primitives/_internal/react-portal.js +0 -16
- package/dist/primitives/_internal/react-presence.js +0 -71
- package/dist/primitives/_internal/react-primitive.js +0 -36
- package/dist/primitives/_internal/react-use-callback-ref.js +0 -13
- package/dist/primitives/_internal/react-use-controllable-state.js +0 -44
- package/dist/primitives/_internal/react-use-escape-keydown.js +0 -14
- package/dist/primitives/_internal/react-use-is-hydrated.js +0 -15
- package/dist/primitives/_internal/react-use-layout-effect.js +0 -6
- package/dist/primitives/_internal/react-use-previous.js +0 -8
- package/dist/primitives/_internal/react-use-size.js +0 -27
- package/dist/primitives/react-accordion.js +0 -239
- package/dist/primitives/react-alert-dialog.js +0 -127
- package/dist/primitives/react-aspect-ratio.js +0 -43
- package/dist/primitives/react-avatar.js +0 -75
- package/dist/primitives/react-checkbox.js +0 -251
- package/dist/primitives/react-collapsible.js +0 -120
- package/dist/primitives/react-context-menu.js +0 -240
- package/dist/primitives/react-dialog.js +0 -262
- package/dist/primitives/react-dropdown-menu.js +0 -227
- package/dist/primitives/react-hover-card.js +0 -187
- package/dist/primitives/react-label.js +0 -20
- package/dist/primitives/react-menu.js +0 -652
- package/dist/primitives/react-menubar.js +0 -355
- package/dist/primitives/react-navigation-menu.js +0 -607
- package/dist/primitives/react-popover.js +0 -243
- package/dist/primitives/react-progress.js +0 -84
- package/dist/primitives/react-radio-group.js +0 -238
- package/dist/primitives/react-roving-focus.js +0 -183
- package/dist/primitives/react-select.js +0 -862
- package/dist/primitives/react-separator.js +0 -24
- package/dist/primitives/react-slider.js +0 -437
- package/dist/primitives/react-slot.js +0 -70
- package/dist/primitives/react-switch.js +0 -132
- package/dist/primitives/react-tabs.js +0 -163
- package/dist/primitives/react-toast.js +0 -446
- package/dist/primitives/react-toggle-group.js +0 -137
- package/dist/primitives/react-toggle.js +0 -33
- package/dist/primitives/react-tooltip.js +0 -338
- package/dist/primitives/react-visually-hidden.js +0 -32
- package/dist/ui/charts/_internal/animation.js +0 -18
- package/dist/ui/charts/_internal/axes.js +0 -42
- package/dist/ui/charts/_internal/colors.js +0 -21
- package/dist/ui/charts/_internal/grid-lines.js +0 -43
- package/dist/ui/charts/_internal/legend.js +0 -29
- package/dist/ui/charts/_internal/tooltip.js +0 -39
- package/dist/ui/charts/_internal/types.js +0 -10
- package/dist/ui/charts/area-chart.js +0 -245
- package/dist/ui/charts/bar-chart.js +0 -153
- package/dist/ui/charts/chart-container.js +0 -27
- package/dist/ui/charts/gauge-chart.js +0 -72
- package/dist/ui/charts/line-chart.js +0 -163
- package/dist/ui/charts/pie-chart.js +0 -132
- package/dist/ui/charts/radar-chart.js +0 -223
- package/dist/ui/charts/sparkline.js +0 -124
- package/dist/ui/lib/motion.js +0 -32
- package/dist/ui/lib/use-reduced-motion.js +0 -15
- package/dist/ui/lib/use-ripple.js +0 -14
- package/dist/ui/tree-view/tree-item.js +0 -139
- package/dist/ui/tree-view/tree-view.js +0 -140
- package/dist/ui/tree-view/use-tree.js +0 -38
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
3
|
+
import * as d from "react";
|
|
4
|
+
import { aO as r, aP as n, aQ as m, aR as l, aS as o } from "./primitives.js";
|
|
5
|
+
import { c as f } from "./utils.js";
|
|
6
|
+
const T = r, u = n, b = m, p = d.forwardRef(({ className: a, sideOffset: e = 4, ...s }, i) => t(l, { children: t(o, { ref: i, sideOffset: e, className: f("z-tooltip overflow-hidden rounded-ds-md bg-text-primary px-ds-04 py-ds-02b text-ds-sm text-text-inverse shadow-02 duration-fast-02 ease-productive-entrance animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", a), ...s }) }));
|
|
7
|
+
p.displayName = o.displayName;
|
|
8
|
+
export {
|
|
9
|
+
T,
|
|
10
|
+
u as a,
|
|
11
|
+
b,
|
|
12
|
+
p as c
|
|
13
|
+
};
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as I, jsx as c } from "react/jsx-runtime";
|
|
3
|
+
import * as l from "react";
|
|
4
|
+
import { useState as V, useCallback as P } from "react";
|
|
5
|
+
import { c as D } from "./utils.js";
|
|
6
|
+
import { IconChevronRight as q } from "@tabler/icons-react";
|
|
7
|
+
import { C as M } from "./checkbox.js";
|
|
8
|
+
function z(r = {}) {
|
|
9
|
+
const { defaultExpanded: m, defaultSelected: n, multiSelect: d, onSelect: h, onExpand: a } = r, [g, x] = V(
|
|
10
|
+
new Set(m ?? [])
|
|
11
|
+
), [y, E] = V(
|
|
12
|
+
new Set(n ?? [])
|
|
13
|
+
), s = P(
|
|
14
|
+
(t) => {
|
|
15
|
+
x((i) => {
|
|
16
|
+
const f = new Set(i);
|
|
17
|
+
return f.has(t) ? f.delete(t) : f.add(t), a == null || a(Array.from(f)), f;
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
[a]
|
|
21
|
+
), u = P(
|
|
22
|
+
(t, i) => {
|
|
23
|
+
E((f) => {
|
|
24
|
+
let p;
|
|
25
|
+
return d && (i != null && i.ctrlKey) ? (p = new Set(f), p.has(t) ? p.delete(t) : p.add(t)) : p = /* @__PURE__ */ new Set([t]), h == null || h(Array.from(p)), p;
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
[d, h]
|
|
29
|
+
);
|
|
30
|
+
return {
|
|
31
|
+
expanded: g,
|
|
32
|
+
selected: y,
|
|
33
|
+
toggle: s,
|
|
34
|
+
select: u,
|
|
35
|
+
isExpanded: (t) => g.has(t),
|
|
36
|
+
isSelected: (t) => y.has(t),
|
|
37
|
+
expandAll: (t) => x(new Set(t)),
|
|
38
|
+
collapseAll: () => x(/* @__PURE__ */ new Set())
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const K = l.forwardRef(
|
|
42
|
+
({
|
|
43
|
+
itemId: r,
|
|
44
|
+
label: m,
|
|
45
|
+
icon: n,
|
|
46
|
+
secondaryLabel: d,
|
|
47
|
+
actions: h,
|
|
48
|
+
disabled: a = !1,
|
|
49
|
+
children: g,
|
|
50
|
+
depth: x = 0,
|
|
51
|
+
className: y
|
|
52
|
+
}, E) => {
|
|
53
|
+
const s = G(), u = l.Children.count(g) > 0, t = s.tree.isExpanded(r), i = s.tree.isSelected(r), f = (e) => {
|
|
54
|
+
a || s.tree.select(r, e);
|
|
55
|
+
}, p = (e) => {
|
|
56
|
+
e.stopPropagation(), !a && s.tree.toggle(r);
|
|
57
|
+
}, k = (e) => {
|
|
58
|
+
a || ((e.key === "Enter" || e.key === " ") && (e.preventDefault(), s.tree.select(r)), e.key === "ArrowRight" && u && !t && (e.preventDefault(), e.stopPropagation(), s.tree.toggle(r)), e.key === "ArrowLeft" && u && t && (e.preventDefault(), e.stopPropagation(), s.tree.toggle(r)));
|
|
59
|
+
}, N = l.useMemo(() => {
|
|
60
|
+
if (!s.checkboxes || !u)
|
|
61
|
+
return { checked: i, indeterminate: !1 };
|
|
62
|
+
const e = [], w = (C) => {
|
|
63
|
+
l.Children.forEach(C, (b) => {
|
|
64
|
+
l.isValidElement(b) && b.props.itemId && (e.push(b.props.itemId), b.props.children && w(b.props.children));
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
w(g);
|
|
68
|
+
const S = e.filter(
|
|
69
|
+
(C) => s.tree.isSelected(C)
|
|
70
|
+
).length;
|
|
71
|
+
return S === 0 && !i ? { checked: !1, indeterminate: !1 } : S === e.length ? { checked: !0, indeterminate: !1 } : { checked: !1, indeterminate: !0 };
|
|
72
|
+
}, [s.checkboxes, u, g, i, s.tree]);
|
|
73
|
+
return /* @__PURE__ */ I(
|
|
74
|
+
"li",
|
|
75
|
+
{
|
|
76
|
+
ref: E,
|
|
77
|
+
role: "treeitem",
|
|
78
|
+
"aria-expanded": u ? t : void 0,
|
|
79
|
+
"aria-selected": i,
|
|
80
|
+
"aria-level": x + 1,
|
|
81
|
+
"aria-disabled": a || void 0,
|
|
82
|
+
className: "list-none",
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ I(
|
|
85
|
+
"div",
|
|
86
|
+
{
|
|
87
|
+
role: "presentation",
|
|
88
|
+
"data-tree-item": r,
|
|
89
|
+
tabIndex: a ? -1 : 0,
|
|
90
|
+
onClick: f,
|
|
91
|
+
onKeyDown: k,
|
|
92
|
+
style: { paddingLeft: x * 20 + 8 },
|
|
93
|
+
className: D(
|
|
94
|
+
"flex items-center gap-ds-02 py-ds-02 px-ds-02 rounded-ds-md cursor-pointer transition-colors duration-fast-01",
|
|
95
|
+
"hover:bg-layer-02",
|
|
96
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus",
|
|
97
|
+
i && "bg-interactive-selected text-text-interactive",
|
|
98
|
+
a && "opacity-[0.38] cursor-not-allowed pointer-events-none",
|
|
99
|
+
y
|
|
100
|
+
),
|
|
101
|
+
children: [
|
|
102
|
+
u ? /* @__PURE__ */ c(
|
|
103
|
+
"button",
|
|
104
|
+
{
|
|
105
|
+
type: "button",
|
|
106
|
+
tabIndex: -1,
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
onClick: p,
|
|
109
|
+
className: "flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer",
|
|
110
|
+
children: /* @__PURE__ */ c(
|
|
111
|
+
q,
|
|
112
|
+
{
|
|
113
|
+
size: 16,
|
|
114
|
+
className: D(
|
|
115
|
+
"transition-transform duration-moderate-02",
|
|
116
|
+
t && "rotate-90"
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
) : /* @__PURE__ */ c("span", { className: "inline-block w-4 shrink-0", "aria-hidden": "true" }),
|
|
122
|
+
s.checkboxes && /* @__PURE__ */ c(
|
|
123
|
+
M,
|
|
124
|
+
{
|
|
125
|
+
checked: N.checked,
|
|
126
|
+
indeterminate: N.indeterminate,
|
|
127
|
+
disabled: a,
|
|
128
|
+
tabIndex: -1,
|
|
129
|
+
onClick: (e) => e.stopPropagation(),
|
|
130
|
+
onCheckedChange: () => {
|
|
131
|
+
a || s.tree.select(r);
|
|
132
|
+
},
|
|
133
|
+
className: "shrink-0"
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
n && /* @__PURE__ */ c("span", { className: "flex shrink-0 items-center text-icon-secondary", children: n }),
|
|
137
|
+
/* @__PURE__ */ c("span", { className: "truncate text-ds-sm", children: m }),
|
|
138
|
+
d && /* @__PURE__ */ c("span", { className: "ml-auto truncate text-ds-xs text-text-secondary", children: d }),
|
|
139
|
+
h && /* @__PURE__ */ c(
|
|
140
|
+
"span",
|
|
141
|
+
{
|
|
142
|
+
className: "ml-auto flex shrink-0 items-center gap-ds-01",
|
|
143
|
+
onClick: (e) => e.stopPropagation(),
|
|
144
|
+
role: "presentation",
|
|
145
|
+
children: h
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
u && /* @__PURE__ */ c(
|
|
152
|
+
"div",
|
|
153
|
+
{
|
|
154
|
+
role: "group",
|
|
155
|
+
className: D(
|
|
156
|
+
"grid transition-[grid-template-rows] duration-moderate-02 ease-productive-standard",
|
|
157
|
+
t ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
|
|
158
|
+
),
|
|
159
|
+
children: /* @__PURE__ */ c("ul", { role: "group", className: "overflow-hidden m-0 p-0", children: l.Children.map(g, (e) => l.isValidElement(e) ? l.cloneElement(e, {
|
|
160
|
+
depth: x + 1
|
|
161
|
+
}) : e) })
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
K.displayName = "TreeItem";
|
|
170
|
+
const j = l.createContext(null);
|
|
171
|
+
function G() {
|
|
172
|
+
const r = l.useContext(j);
|
|
173
|
+
if (!r)
|
|
174
|
+
throw new Error("TreeItem must be used within a <TreeView>");
|
|
175
|
+
return r;
|
|
176
|
+
}
|
|
177
|
+
function L(r, m = 0) {
|
|
178
|
+
return r.map((n) => /* @__PURE__ */ c(
|
|
179
|
+
K,
|
|
180
|
+
{
|
|
181
|
+
itemId: n.id,
|
|
182
|
+
label: n.label,
|
|
183
|
+
icon: n.icon,
|
|
184
|
+
disabled: n.disabled,
|
|
185
|
+
depth: m,
|
|
186
|
+
children: n.children && n.children.length > 0 ? L(n.children, m + 1) : void 0
|
|
187
|
+
},
|
|
188
|
+
n.id
|
|
189
|
+
));
|
|
190
|
+
}
|
|
191
|
+
function H(r) {
|
|
192
|
+
return Array.from(
|
|
193
|
+
r.querySelectorAll("[data-tree-item]")
|
|
194
|
+
).filter((m) => {
|
|
195
|
+
let n = m.parentElement;
|
|
196
|
+
for (; n && n !== r; ) {
|
|
197
|
+
if (n.getAttribute("role") === "group") {
|
|
198
|
+
const d = n.parentElement;
|
|
199
|
+
if (d && d.classList.contains("grid-rows-[0fr]"))
|
|
200
|
+
return !1;
|
|
201
|
+
}
|
|
202
|
+
n = n.parentElement;
|
|
203
|
+
}
|
|
204
|
+
return !0;
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
const U = l.forwardRef(
|
|
208
|
+
({
|
|
209
|
+
items: r,
|
|
210
|
+
defaultExpanded: m,
|
|
211
|
+
defaultSelected: n,
|
|
212
|
+
multiSelect: d = !1,
|
|
213
|
+
checkboxes: h = !1,
|
|
214
|
+
onSelect: a,
|
|
215
|
+
onExpand: g,
|
|
216
|
+
className: x,
|
|
217
|
+
children: y
|
|
218
|
+
}, E) => {
|
|
219
|
+
const s = z({
|
|
220
|
+
defaultExpanded: m,
|
|
221
|
+
defaultSelected: n,
|
|
222
|
+
multiSelect: d,
|
|
223
|
+
onSelect: a,
|
|
224
|
+
onExpand: g
|
|
225
|
+
}), u = l.useRef(null), t = E ?? u, i = (k) => {
|
|
226
|
+
var S, C, b;
|
|
227
|
+
const N = t.current;
|
|
228
|
+
if (!N) return;
|
|
229
|
+
const e = H(N), w = e.findIndex(
|
|
230
|
+
(o) => o === document.activeElement
|
|
231
|
+
);
|
|
232
|
+
switch (k.key) {
|
|
233
|
+
case "ArrowDown": {
|
|
234
|
+
k.preventDefault();
|
|
235
|
+
const o = e[w + 1];
|
|
236
|
+
o == null || o.focus();
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
case "ArrowUp": {
|
|
240
|
+
k.preventDefault();
|
|
241
|
+
const o = e[w - 1];
|
|
242
|
+
o == null || o.focus();
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
case "ArrowRight": {
|
|
246
|
+
const o = e[w];
|
|
247
|
+
if (o) {
|
|
248
|
+
const A = o.getAttribute("data-tree-item");
|
|
249
|
+
if (A && s.isExpanded(A)) {
|
|
250
|
+
k.preventDefault();
|
|
251
|
+
const v = e[w + 1];
|
|
252
|
+
v == null || v.focus();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
case "ArrowLeft": {
|
|
258
|
+
const o = e[w];
|
|
259
|
+
if (o) {
|
|
260
|
+
const A = o.getAttribute("data-tree-item"), v = o.closest('[role="treeitem"]'), R = (S = v == null ? void 0 : v.parentElement) == null ? void 0 : S.closest(
|
|
261
|
+
'[role="treeitem"]'
|
|
262
|
+
);
|
|
263
|
+
if (A && !s.isExpanded(A) && R) {
|
|
264
|
+
k.preventDefault();
|
|
265
|
+
const T = R.querySelector(
|
|
266
|
+
"[data-tree-item]"
|
|
267
|
+
);
|
|
268
|
+
T == null || T.focus();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
case "Home": {
|
|
274
|
+
k.preventDefault(), (C = e[0]) == null || C.focus();
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
case "End": {
|
|
278
|
+
k.preventDefault(), (b = e[e.length - 1]) == null || b.focus();
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}, f = l.useMemo(
|
|
283
|
+
() => ({ tree: s, checkboxes: h }),
|
|
284
|
+
[s, h]
|
|
285
|
+
), p = r ? L(r) : y;
|
|
286
|
+
return /* @__PURE__ */ c(j.Provider, { value: f, children: /* @__PURE__ */ c(
|
|
287
|
+
"ul",
|
|
288
|
+
{
|
|
289
|
+
ref: t,
|
|
290
|
+
role: "tree",
|
|
291
|
+
"aria-multiselectable": d || void 0,
|
|
292
|
+
onKeyDown: i,
|
|
293
|
+
className: D("m-0 list-none p-0", x),
|
|
294
|
+
children: p
|
|
295
|
+
}
|
|
296
|
+
) });
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
U.displayName = "TreeView";
|
|
300
|
+
export {
|
|
301
|
+
K as T,
|
|
302
|
+
U as a,
|
|
303
|
+
z as u
|
|
304
|
+
};
|