@devalok/shilp-sutra 0.33.2 → 0.34.1

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.
Files changed (175) hide show
  1. package/dist/_chunks/badge-group.js +306 -246
  2. package/dist/_chunks/chat.js +513 -0
  3. package/dist/_chunks/date-picker.js +748 -0
  4. package/dist/_chunks/document-preview.js +109 -90
  5. package/dist/_chunks/file-preview.js +492 -504
  6. package/dist/_chunks/framer.js +5564 -5613
  7. package/dist/_chunks/image-preview.js +127 -88
  8. package/dist/_chunks/keybinding.js +12 -14
  9. package/dist/_chunks/link-context.js +19 -16
  10. package/dist/_chunks/mention-suggestion.js +353 -350
  11. package/dist/_chunks/motion-provider.js +26 -20
  12. package/dist/_chunks/popover.js +127 -0
  13. package/dist/_chunks/primitives.js +7584 -6425
  14. package/dist/_chunks/rich-chat-input.js +2070 -0
  15. package/dist/_chunks/rolldown-runtime.js +21 -0
  16. package/dist/_chunks/shared.js +126 -0
  17. package/dist/_chunks/sonner.js +605 -734
  18. package/dist/_chunks/stat-row.js +418 -440
  19. package/dist/_chunks/tiptap.js +15850 -19964
  20. package/dist/_chunks/tree-view.js +231 -290
  21. package/dist/_chunks/use-calendar.js +161 -208
  22. package/dist/_chunks/vendor-client.js +314 -2199
  23. package/dist/_chunks/vendor-utils.js +1721 -2978
  24. package/dist/ai/ai-command-provider.js +23 -17
  25. package/dist/ai/block-renderer.js +68 -51
  26. package/dist/ai/blocks/index.js +2 -12
  27. package/dist/ai/command-bar.js +470 -519
  28. package/dist/ai/conversation.js +241 -227
  29. package/dist/ai/index.js +181 -167
  30. package/dist/ai/types.js +0 -1
  31. package/dist/composed/activity-feed.js +232 -202
  32. package/dist/composed/avatar-group.js +164 -222
  33. package/dist/composed/bulk-action-bar.js +174 -165
  34. package/dist/composed/command-palette.js +290 -308
  35. package/dist/composed/confirm-dialog.js +28 -48
  36. package/dist/composed/content-card.js +69 -108
  37. package/dist/composed/date-picker/index.js +3 -13
  38. package/dist/composed/deadline-indicator.js +68 -74
  39. package/dist/composed/emoji-picker.js +83 -110
  40. package/dist/composed/empty-state.js +64 -103
  41. package/dist/composed/error-boundary.js +129 -127
  42. package/dist/composed/file-preview.js +2 -12
  43. package/dist/composed/filter-bar.js +98 -130
  44. package/dist/composed/form-section.js +61 -45
  45. package/dist/composed/global-loading.js +34 -47
  46. package/dist/composed/index.js +34 -92
  47. package/dist/composed/inline-edit.js +92 -107
  48. package/dist/composed/lib/string-utils.js +8 -8
  49. package/dist/composed/loading-skeleton.js +103 -171
  50. package/dist/composed/markdown-viewer.js +187 -139
  51. package/dist/composed/master-detail.js +147 -156
  52. package/dist/composed/member-picker.js +46 -49
  53. package/dist/composed/multi-select-popover.js +181 -179
  54. package/dist/composed/page-header.js +54 -76
  55. package/dist/composed/page-skeletons.js +143 -127
  56. package/dist/composed/priority-indicator.js +105 -111
  57. package/dist/composed/responsive-overlay.js +36 -41
  58. package/dist/composed/rich-chat-input.js +2 -1860
  59. package/dist/composed/rich-text-editor.js +561 -424
  60. package/dist/composed/schedule-view.js +134 -185
  61. package/dist/composed/simple-tooltip.js +21 -21
  62. package/dist/composed/status-badge.js +133 -137
  63. package/dist/hooks/index.js +7 -12
  64. package/dist/hooks/use-color-mode.js +28 -25
  65. package/dist/hooks/use-mobile.js +13 -13
  66. package/dist/hooks/use-toast.js +2 -4
  67. package/dist/hooks/use-touch-device.js +9 -11
  68. package/dist/hooks/use-viewport-height.js +14 -14
  69. package/dist/motion/index.js +3 -11
  70. package/dist/motion/primitives-index.js +226 -186
  71. package/dist/shell/app-command-palette.js +203 -234
  72. package/dist/shell/bottom-navbar.js +150 -190
  73. package/dist/shell/command-registry.js +13 -14
  74. package/dist/shell/index.js +10 -20
  75. package/dist/shell/link-context.js +2 -5
  76. package/dist/shell/notification-center.js +238 -259
  77. package/dist/shell/notification-preferences.js +241 -184
  78. package/dist/shell/sidebar.js +251 -281
  79. package/dist/shell/top-bar.js +203 -237
  80. package/dist/tailwind/index.cjs +426 -451
  81. package/dist/tailwind/index.js +2 -4
  82. package/dist/tailwind/preset.d.ts.map +1 -1
  83. package/dist/tailwind/preset.js +443 -468
  84. package/dist/ui/accordion.js +52 -60
  85. package/dist/ui/alert-dialog.js +111 -156
  86. package/dist/ui/alert.js +177 -99
  87. package/dist/ui/aspect-ratio.js +13 -16
  88. package/dist/ui/autocomplete.js +112 -148
  89. package/dist/ui/avatar.js +196 -169
  90. package/dist/ui/badge-group.js +2 -7
  91. package/dist/ui/badge-indicator.js +42 -51
  92. package/dist/ui/badge.js +2 -15
  93. package/dist/ui/banner.js +76 -68
  94. package/dist/ui/breadcrumb.js +65 -84
  95. package/dist/ui/button-group.js +109 -102
  96. package/dist/ui/button-processing.js +69 -73
  97. package/dist/ui/button.js +393 -279
  98. package/dist/ui/card.js +151 -157
  99. package/dist/ui/charts/index.js +1002 -1319
  100. package/dist/ui/chat/index.js +2 -11
  101. package/dist/ui/checkbox.js +77 -100
  102. package/dist/ui/code.js +18 -32
  103. package/dist/ui/collapsible.js +21 -29
  104. package/dist/ui/color-input.js +453 -372
  105. package/dist/ui/color-swatch.js +60 -90
  106. package/dist/ui/combobox.js +244 -293
  107. package/dist/ui/container.js +18 -24
  108. package/dist/ui/context-menu.js +154 -203
  109. package/dist/ui/data-table-body.js +116 -213
  110. package/dist/ui/data-table-bulk-actions.js +43 -59
  111. package/dist/ui/data-table-card.js +84 -71
  112. package/dist/ui/data-table-context.js +39 -42
  113. package/dist/ui/data-table-header.js +98 -139
  114. package/dist/ui/data-table-pagination.js +69 -82
  115. package/dist/ui/data-table-toolbar.js +104 -130
  116. package/dist/ui/data-table.js +278 -354
  117. package/dist/ui/devalok-grain.js +77 -66
  118. package/dist/ui/dialog.js +122 -151
  119. package/dist/ui/dropdown-menu.js +152 -203
  120. package/dist/ui/file-upload.js +242 -266
  121. package/dist/ui/form.js +60 -56
  122. package/dist/ui/hover-card.js +54 -54
  123. package/dist/ui/icon-button.js +21 -26
  124. package/dist/ui/icon-context.js +17 -17
  125. package/dist/ui/icon-group.js +22 -29
  126. package/dist/ui/icon.js +201 -121
  127. package/dist/ui/index.js +74 -350
  128. package/dist/ui/input-otp.d.ts.map +1 -1
  129. package/dist/ui/input-otp.js +44 -48
  130. package/dist/ui/input.js +92 -169
  131. package/dist/ui/label.js +17 -22
  132. package/dist/ui/lib/date-utils.js +14 -11
  133. package/dist/ui/lib/motion.js +77 -36
  134. package/dist/ui/lib/utils.js +39 -16
  135. package/dist/ui/link.js +13 -24
  136. package/dist/ui/menubar.js +132 -210
  137. package/dist/ui/navigation-menu.js +164 -194
  138. package/dist/ui/number-input.js +72 -95
  139. package/dist/ui/pagination.js +122 -159
  140. package/dist/ui/popover.js +2 -131
  141. package/dist/ui/progress-ring.js +133 -143
  142. package/dist/ui/progress.js +51 -95
  143. package/dist/ui/radio.js +41 -50
  144. package/dist/ui/search-input.js +51 -53
  145. package/dist/ui/segmented-control.js +93 -114
  146. package/dist/ui/select.js +131 -157
  147. package/dist/ui/separator.js +15 -25
  148. package/dist/ui/sheet.js +135 -163
  149. package/dist/ui/sidebar.js +357 -600
  150. package/dist/ui/skeleton.js +179 -231
  151. package/dist/ui/slider.js +24 -34
  152. package/dist/ui/spinner.js +226 -205
  153. package/dist/ui/split-button.js +227 -276
  154. package/dist/ui/stack.js +56 -70
  155. package/dist/ui/stat-card.js +259 -251
  156. package/dist/ui/status-dot.js +67 -63
  157. package/dist/ui/stepper.js +119 -168
  158. package/dist/ui/switch.js +51 -54
  159. package/dist/ui/table.js +57 -90
  160. package/dist/ui/tabs.js +139 -156
  161. package/dist/ui/text.js +52 -59
  162. package/dist/ui/textarea.js +40 -57
  163. package/dist/ui/toast-types.js +0 -1
  164. package/dist/ui/toast.js +554 -536
  165. package/dist/ui/toaster.js +23 -33
  166. package/dist/ui/toggle-group.js +37 -41
  167. package/dist/ui/toggle.js +36 -40
  168. package/dist/ui/tooltip.js +80 -65
  169. package/dist/ui/tree-view/index.js +2 -6
  170. package/dist/ui/visually-hidden.js +12 -10
  171. package/llms-full.txt +1 -1
  172. package/llms.txt +12 -0
  173. package/package.json +3 -3
  174. package/dist/_chunks/date-time-picker.js +0 -851
  175. package/dist/_chunks/typing-indicator.js +0 -565
@@ -1,295 +1,236 @@
1
1
  "use client";
2
- import { jsxs as A, jsx as i } from "react/jsx-runtime";
3
- import * as l from "react";
4
- import { useState as D, useCallback as I } from "react";
5
- import { cn as E } from "../ui/lib/utils.js";
6
- import { IconChevronRight as K } from "@tabler/icons-react";
7
- import { Icon as j } from "../ui/icon.js";
8
- import { Checkbox as L } from "../ui/checkbox.js";
9
- function q(t = {}) {
10
- const { defaultExpanded: x, defaultSelected: r, multiSelect: f, onSelect: v, onExpand: c } = t, [w, k] = D(
11
- new Set(x ?? [])
12
- ), [y, C] = D(
13
- new Set(r ?? [])
14
- ), s = I(
15
- (n) => {
16
- k((d) => {
17
- const p = new Set(d);
18
- return p.has(n) ? p.delete(n) : p.add(n), c?.(Array.from(p)), p;
19
- });
20
- },
21
- [c]
22
- ), o = I(
23
- (n, d) => {
24
- C((p) => {
25
- let m;
26
- return f && d?.ctrlKey ? (m = new Set(p), m.has(n) ? m.delete(n) : m.add(n)) : m = /* @__PURE__ */ new Set([n]), v?.(Array.from(m)), m;
27
- });
28
- },
29
- [f, v]
30
- );
31
- return {
32
- expanded: w,
33
- selected: y,
34
- toggle: s,
35
- select: o,
36
- isExpanded: (n) => w.has(n),
37
- isSelected: (n) => y.has(n),
38
- expandAll: (n) => k(new Set(n)),
39
- collapseAll: () => k(/* @__PURE__ */ new Set())
40
- };
2
+ import { cn as e } from "../ui/lib/utils.js";
3
+ import { Icon as t } from "../ui/icon.js";
4
+ import { Checkbox as n } from "../ui/checkbox.js";
5
+ import * as r from "react";
6
+ import { useCallback as i, useState as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
+ import { IconChevronRight as c } from "@tabler/icons-react";
9
+ //#region src/ui/tree-view/use-tree.ts
10
+ function l(e = {}) {
11
+ let { defaultExpanded: t, defaultSelected: n, multiSelect: r, onSelect: o, onExpand: s } = e, [c, l] = a(new Set(t ?? [])), [u, d] = a(new Set(n ?? []));
12
+ return {
13
+ expanded: c,
14
+ selected: u,
15
+ toggle: i((e) => {
16
+ l((t) => {
17
+ let n = new Set(t);
18
+ return n.has(e) ? n.delete(e) : n.add(e), s?.(Array.from(n)), n;
19
+ });
20
+ }, [s]),
21
+ select: i((e, t) => {
22
+ d((n) => {
23
+ let i;
24
+ return r && t?.ctrlKey ? (i = new Set(n), i.has(e) ? i.delete(e) : i.add(e)) : i = new Set([e]), o?.(Array.from(i)), i;
25
+ });
26
+ }, [r, o]),
27
+ isExpanded: (e) => c.has(e),
28
+ isSelected: (e) => u.has(e),
29
+ expandAll: (e) => l(new Set(e)),
30
+ collapseAll: () => l(/* @__PURE__ */ new Set())
31
+ };
41
32
  }
42
- const R = l.forwardRef(
43
- ({
44
- itemId: t,
45
- label: x,
46
- icon: r,
47
- secondaryLabel: f,
48
- actions: v,
49
- disabled: c = !1,
50
- children: w,
51
- depth: k = 0,
52
- className: y
53
- }, C) => {
54
- const s = M(), o = l.Children.count(w) > 0, n = s.tree.isExpanded(t), d = s.tree.isSelected(t), p = (e) => {
55
- c || s.tree.select(t, e);
56
- }, m = (e) => {
57
- e.stopPropagation(), !c && s.tree.toggle(t);
58
- }, S = (e) => {
59
- c || ((e.key === "Enter" || e.key === " ") && (e.preventDefault(), s.tree.select(t)), e.key === "ArrowRight" && o && !n && (e.preventDefault(), e.stopPropagation(), s.tree.toggle(t)), e.key === "ArrowLeft" && o && n && (e.preventDefault(), e.stopPropagation(), s.tree.toggle(t)));
60
- }, g = l.useMemo(() => {
61
- if (!s.checkboxes || !o)
62
- return { checked: d, indeterminate: !1 };
63
- const e = [], u = (a) => {
64
- l.Children.forEach(a, (h) => {
65
- l.isValidElement(h) && h.props.itemId && (e.push(h.props.itemId), h.props.children && u(h.props.children));
66
- });
67
- };
68
- u(w);
69
- const b = e.filter(
70
- (a) => s.tree.isSelected(a)
71
- ).length;
72
- return b === 0 && !d ? { checked: !1, indeterminate: !1 } : b === e.length ? { checked: !0, indeterminate: !1 } : { checked: !1, indeterminate: !0 };
73
- }, [s.checkboxes, o, w, d, s.tree]);
74
- return /* @__PURE__ */ A(
75
- "li",
76
- {
77
- ref: C,
78
- role: "treeitem",
79
- "aria-expanded": o ? n : void 0,
80
- "aria-selected": d,
81
- "aria-level": k + 1,
82
- "aria-disabled": c || void 0,
83
- className: "list-none",
84
- children: [
85
- /* @__PURE__ */ A(
86
- "div",
87
- {
88
- role: "presentation",
89
- "data-tree-item": t,
90
- tabIndex: c ? -1 : 0,
91
- onClick: p,
92
- onKeyDown: S,
93
- style: { paddingLeft: k * 20 + 8 },
94
- className: E(
95
- "flex items-center gap-ds-02 py-ds-02 px-ds-02 rounded-ds-md cursor-pointer transition-colors duration-fast-01",
96
- "hover:bg-surface-raised",
97
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-9",
98
- d && "bg-accent-3 text-accent-11",
99
- c && "opacity-action-disabled cursor-not-allowed pointer-events-none",
100
- y
101
- ),
102
- children: [
103
- o ? /* @__PURE__ */ i(
104
- "button",
105
- {
106
- type: "button",
107
- tabIndex: -1,
108
- "aria-hidden": "true",
109
- onClick: m,
110
- className: "flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer",
111
- children: /* @__PURE__ */ i(
112
- j,
113
- {
114
- icon: K,
115
- size: "sm",
116
- className: E(
117
- "transition-transform duration-moderate-02",
118
- n && "rotate-90"
119
- )
120
- }
121
- )
122
- }
123
- ) : /* @__PURE__ */ i("span", { className: "inline-block w-4 shrink-0", "aria-hidden": "true" }),
124
- s.checkboxes && /* @__PURE__ */ i(
125
- L,
126
- {
127
- checked: g.checked,
128
- indeterminate: g.indeterminate,
129
- disabled: c,
130
- tabIndex: -1,
131
- onClick: (e) => e.stopPropagation(),
132
- onCheckedChange: () => {
133
- c || s.tree.select(t);
134
- },
135
- className: "shrink-0"
136
- }
137
- ),
138
- r && /* @__PURE__ */ i("span", { className: "flex shrink-0 items-center text-surface-fg-subtle", children: r }),
139
- /* @__PURE__ */ i("span", { className: "truncate text-ds-sm", children: x }),
140
- f && /* @__PURE__ */ i("span", { className: "ml-auto truncate text-ds-xs text-surface-fg-muted", children: f }),
141
- v && /* @__PURE__ */ i(
142
- "span",
143
- {
144
- className: "ml-auto flex shrink-0 items-center gap-ds-01",
145
- onClick: (e) => e.stopPropagation(),
146
- role: "presentation",
147
- children: v
148
- }
149
- )
150
- ]
151
- }
152
- ),
153
- o && /* @__PURE__ */ i(
154
- "div",
155
- {
156
- role: "group",
157
- className: E(
158
- "grid transition-[grid-template-rows] duration-moderate-02 ease-productive-standard",
159
- n ? "grid-rows-[1fr]" : "grid-rows-[0fr]"
160
- ),
161
- children: /* @__PURE__ */ i("ul", { role: "group", className: "overflow-hidden m-0 p-0", children: l.Children.map(w, (e) => l.isValidElement(e) ? l.cloneElement(e, {
162
- depth: k + 1
163
- }) : e) })
164
- }
165
- )
166
- ]
167
- }
168
- );
169
- }
170
- );
171
- R.displayName = "TreeItem";
172
- const T = l.createContext(null);
173
- function M() {
174
- const t = l.useContext(T);
175
- if (!t)
176
- throw new Error("TreeItem must be used within a <TreeView>");
177
- return t;
33
+ //#endregion
34
+ //#region src/ui/tree-view/tree-item.tsx
35
+ var u = r.forwardRef(({ itemId: i, label: a, icon: l, secondaryLabel: u, actions: d, disabled: p = !1, children: m, depth: h = 0, className: g }, _) => {
36
+ let v = f(), y = r.Children.count(m) > 0, b = v.tree.isExpanded(i), x = v.tree.isSelected(i), S = (e) => {
37
+ p || v.tree.select(i, e);
38
+ }, C = (e) => {
39
+ e.stopPropagation(), !p && v.tree.toggle(i);
40
+ }, w = (e) => {
41
+ p || ((e.key === "Enter" || e.key === " ") && (e.preventDefault(), v.tree.select(i)), e.key === "ArrowRight" && y && !b && (e.preventDefault(), e.stopPropagation(), v.tree.toggle(i)), e.key === "ArrowLeft" && y && b && (e.preventDefault(), e.stopPropagation(), v.tree.toggle(i)));
42
+ }, T = r.useMemo(() => {
43
+ if (!v.checkboxes || !y) return {
44
+ checked: x,
45
+ indeterminate: !1
46
+ };
47
+ let e = [], t = (n) => {
48
+ r.Children.forEach(n, (n) => {
49
+ r.isValidElement(n) && n.props.itemId && (e.push(n.props.itemId), n.props.children && t(n.props.children));
50
+ });
51
+ };
52
+ t(m);
53
+ let n = e.filter((e) => v.tree.isSelected(e)).length;
54
+ return n === 0 && !x ? {
55
+ checked: !1,
56
+ indeterminate: !1
57
+ } : n === e.length ? {
58
+ checked: !0,
59
+ indeterminate: !1
60
+ } : {
61
+ checked: !1,
62
+ indeterminate: !0
63
+ };
64
+ }, [
65
+ v.checkboxes,
66
+ y,
67
+ m,
68
+ x,
69
+ v.tree
70
+ ]);
71
+ return /* @__PURE__ */ s("li", {
72
+ ref: _,
73
+ role: "treeitem",
74
+ "aria-expanded": y ? b : void 0,
75
+ "aria-selected": x,
76
+ "aria-level": h + 1,
77
+ "aria-disabled": p || void 0,
78
+ className: "list-none",
79
+ children: [/* @__PURE__ */ s("div", {
80
+ role: "presentation",
81
+ "data-tree-item": i,
82
+ tabIndex: p ? -1 : 0,
83
+ onClick: S,
84
+ onKeyDown: w,
85
+ style: { paddingLeft: h * 20 + 8 },
86
+ className: e("flex items-center gap-ds-02 py-ds-02 px-ds-02 rounded-ds-md cursor-pointer transition-colors duration-fast-01", "hover:bg-surface-raised", "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-accent-9", x && "bg-accent-3 text-accent-11", p && "opacity-action-disabled cursor-not-allowed pointer-events-none", g),
87
+ children: [
88
+ y ? /* @__PURE__ */ o("button", {
89
+ type: "button",
90
+ tabIndex: -1,
91
+ "aria-hidden": "true",
92
+ onClick: C,
93
+ className: "flex shrink-0 items-center justify-center p-0 border-0 bg-transparent cursor-pointer",
94
+ children: /* @__PURE__ */ o(t, {
95
+ icon: c,
96
+ size: "sm",
97
+ className: e("transition-transform duration-moderate-02", b && "rotate-90")
98
+ })
99
+ }) : /* @__PURE__ */ o("span", {
100
+ className: "inline-block w-4 shrink-0",
101
+ "aria-hidden": "true"
102
+ }),
103
+ v.checkboxes && /* @__PURE__ */ o(n, {
104
+ checked: T.checked,
105
+ indeterminate: T.indeterminate,
106
+ disabled: p,
107
+ tabIndex: -1,
108
+ onClick: (e) => e.stopPropagation(),
109
+ onCheckedChange: () => {
110
+ p || v.tree.select(i);
111
+ },
112
+ className: "shrink-0"
113
+ }),
114
+ l && /* @__PURE__ */ o("span", {
115
+ className: "flex shrink-0 items-center text-surface-fg-subtle",
116
+ children: l
117
+ }),
118
+ /* @__PURE__ */ o("span", {
119
+ className: "truncate text-ds-sm",
120
+ children: a
121
+ }),
122
+ u && /* @__PURE__ */ o("span", {
123
+ className: "ml-auto truncate text-ds-xs text-surface-fg-muted",
124
+ children: u
125
+ }),
126
+ d && /* @__PURE__ */ o("span", {
127
+ className: "ml-auto flex shrink-0 items-center gap-ds-01",
128
+ onClick: (e) => e.stopPropagation(),
129
+ role: "presentation",
130
+ children: d
131
+ })
132
+ ]
133
+ }), y && /* @__PURE__ */ o("div", {
134
+ role: "group",
135
+ className: e("grid transition-[grid-template-rows] duration-moderate-02 ease-productive-standard", b ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
136
+ children: /* @__PURE__ */ o("ul", {
137
+ role: "group",
138
+ className: "overflow-hidden m-0 p-0",
139
+ children: r.Children.map(m, (e) => r.isValidElement(e) ? r.cloneElement(e, { depth: h + 1 }) : e)
140
+ })
141
+ })]
142
+ });
143
+ });
144
+ u.displayName = "TreeItem";
145
+ //#endregion
146
+ //#region src/ui/tree-view/tree-view.tsx
147
+ var d = r.createContext(null);
148
+ function f() {
149
+ let e = r.useContext(d);
150
+ if (!e) throw Error("TreeItem must be used within a <TreeView>");
151
+ return e;
178
152
  }
179
- function V(t, x = 0) {
180
- return t.map((r) => /* @__PURE__ */ i(
181
- R,
182
- {
183
- itemId: r.id,
184
- label: r.label,
185
- icon: r.icon,
186
- disabled: r.disabled,
187
- depth: x,
188
- children: r.children && r.children.length > 0 ? V(r.children, x + 1) : void 0
189
- },
190
- r.id
191
- ));
153
+ function p(e, t = 0) {
154
+ return e.map((e) => /* @__PURE__ */ o(u, {
155
+ itemId: e.id,
156
+ label: e.label,
157
+ icon: e.icon,
158
+ disabled: e.disabled,
159
+ depth: t,
160
+ children: e.children && e.children.length > 0 ? p(e.children, t + 1) : void 0
161
+ }, e.id));
192
162
  }
193
- function z(t) {
194
- return Array.from(
195
- t.querySelectorAll("[data-tree-item]")
196
- ).filter((x) => {
197
- let r = x.parentElement;
198
- for (; r && r !== t; ) {
199
- if (r.getAttribute("role") === "group") {
200
- const f = r.parentElement;
201
- if (f && f.classList.contains("grid-rows-[0fr]"))
202
- return !1;
203
- }
204
- r = r.parentElement;
205
- }
206
- return !0;
207
- });
163
+ function m(e) {
164
+ return Array.from(e.querySelectorAll("[data-tree-item]")).filter((t) => {
165
+ let n = t.parentElement;
166
+ for (; n && n !== e;) {
167
+ if (n.getAttribute("role") === "group") {
168
+ let e = n.parentElement;
169
+ if (e && e.classList.contains("grid-rows-[0fr]")) return !1;
170
+ }
171
+ n = n.parentElement;
172
+ }
173
+ return !0;
174
+ });
208
175
  }
209
- const G = l.forwardRef(
210
- ({
211
- items: t,
212
- defaultExpanded: x,
213
- defaultSelected: r,
214
- multiSelect: f = !1,
215
- checkboxes: v = !1,
216
- onSelect: c,
217
- onExpand: w,
218
- className: k,
219
- children: y,
220
- ...C
221
- }, s) => {
222
- const o = q({
223
- defaultExpanded: x,
224
- defaultSelected: r,
225
- multiSelect: f,
226
- onSelect: c,
227
- onExpand: w
228
- }), n = l.useRef(null), d = s ?? n, p = (g) => {
229
- const e = d.current;
230
- if (!e) return;
231
- const u = z(e), b = u.findIndex(
232
- (a) => a === document.activeElement
233
- );
234
- switch (g.key) {
235
- case "ArrowDown": {
236
- g.preventDefault(), u[b + 1]?.focus();
237
- break;
238
- }
239
- case "ArrowUp": {
240
- g.preventDefault(), u[b - 1]?.focus();
241
- break;
242
- }
243
- case "ArrowRight": {
244
- const a = u[b];
245
- if (a) {
246
- const h = a.getAttribute("data-tree-item");
247
- h && o.isExpanded(h) && (g.preventDefault(), u[b + 1]?.focus());
248
- }
249
- break;
250
- }
251
- case "ArrowLeft": {
252
- const a = u[b];
253
- if (a) {
254
- const h = a.getAttribute("data-tree-item"), N = a.closest('[role="treeitem"]')?.parentElement?.closest(
255
- '[role="treeitem"]'
256
- );
257
- h && !o.isExpanded(h) && N && (g.preventDefault(), N.querySelector(
258
- "[data-tree-item]"
259
- )?.focus());
260
- }
261
- break;
262
- }
263
- case "Home": {
264
- g.preventDefault(), u[0]?.focus();
265
- break;
266
- }
267
- case "End": {
268
- g.preventDefault(), u[u.length - 1]?.focus();
269
- break;
270
- }
271
- }
272
- }, m = l.useMemo(
273
- () => ({ tree: o, checkboxes: v }),
274
- [o, v]
275
- ), S = t ? V(t) : y;
276
- return /* @__PURE__ */ i(T.Provider, { value: m, children: /* @__PURE__ */ i(
277
- "ul",
278
- {
279
- ref: d,
280
- role: "tree",
281
- "aria-multiselectable": f || void 0,
282
- onKeyDown: p,
283
- className: E("m-0 list-none p-0", k),
284
- ...C,
285
- children: S
286
- }
287
- ) });
288
- }
289
- );
290
- G.displayName = "TreeView";
291
- export {
292
- R as T,
293
- G as a,
294
- q as u
295
- };
176
+ var h = r.forwardRef(({ items: t, defaultExpanded: n, defaultSelected: i, multiSelect: a = !1, checkboxes: s = !1, onSelect: c, onExpand: u, className: f, children: h, ...g }, _) => {
177
+ let v = l({
178
+ defaultExpanded: n,
179
+ defaultSelected: i,
180
+ multiSelect: a,
181
+ onSelect: c,
182
+ onExpand: u
183
+ }), y = r.useRef(null), b = _ ?? y, x = (e) => {
184
+ let t = b.current;
185
+ if (!t) return;
186
+ let n = m(t), r = n.findIndex((e) => e === document.activeElement);
187
+ switch (e.key) {
188
+ case "ArrowDown":
189
+ e.preventDefault(), n[r + 1]?.focus();
190
+ break;
191
+ case "ArrowUp":
192
+ e.preventDefault(), n[r - 1]?.focus();
193
+ break;
194
+ case "ArrowRight": {
195
+ let t = n[r];
196
+ if (t) {
197
+ let i = t.getAttribute("data-tree-item");
198
+ i && v.isExpanded(i) && (e.preventDefault(), n[r + 1]?.focus());
199
+ }
200
+ break;
201
+ }
202
+ case "ArrowLeft": {
203
+ let t = n[r];
204
+ if (t) {
205
+ let n = t.getAttribute("data-tree-item"), r = t.closest("[role=\"treeitem\"]")?.parentElement?.closest("[role=\"treeitem\"]");
206
+ n && !v.isExpanded(n) && r && (e.preventDefault(), r.querySelector("[data-tree-item]")?.focus());
207
+ }
208
+ break;
209
+ }
210
+ case "Home":
211
+ e.preventDefault(), n[0]?.focus();
212
+ break;
213
+ case "End":
214
+ e.preventDefault(), n[n.length - 1]?.focus();
215
+ break;
216
+ }
217
+ }, S = r.useMemo(() => ({
218
+ tree: v,
219
+ checkboxes: s
220
+ }), [v, s]), C = t ? p(t) : h;
221
+ return /* @__PURE__ */ o(d.Provider, {
222
+ value: S,
223
+ children: /* @__PURE__ */ o("ul", {
224
+ ref: b,
225
+ role: "tree",
226
+ "aria-multiselectable": a || void 0,
227
+ onKeyDown: x,
228
+ className: e("m-0 list-none p-0", f),
229
+ ...g,
230
+ children: C
231
+ })
232
+ });
233
+ });
234
+ h.displayName = "TreeView";
235
+ //#endregion
236
+ export { u as n, l as r, h as t };