@pibit.ai/cure-design-system 0.6.22 → 0.6.24

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.
@@ -102,7 +102,7 @@ const T = ({
102
102
  /* @__PURE__ */ r("nav", { className: "flex-1 pb-4 pr-2 overflow-y-auto overflow-x-hidden", children: i.sections.map((a) => /* @__PURE__ */ r(u, { children: h(
103
103
  (a == null ? void 0 : a.permissions) || [],
104
104
  /* @__PURE__ */ o("div", { className: n("mb-6"), children: [
105
- /* @__PURE__ */ r("div", { className: "py-0.5 px-2", children: /* @__PURE__ */ r("p", { className: "font-medium text-[10px] text-[var(--color-text-tertiary)] uppercase tracking-[1.3px] whitespace-nowrap", children: a.label }) }),
105
+ /* @__PURE__ */ r("div", { className: "py-0.5 px-2", children: /* @__PURE__ */ r("p", { className: "font-medium text-3xs text-[var(--color-text-tertiary)] uppercase tracking-[1.3px] whitespace-nowrap", children: a.label }) }),
106
106
  /* @__PURE__ */ r("ul", { className: "space-y-1", children: a.items.map((e) => {
107
107
  const t = e.href || e.label, l = E.has(t), N = e.items && e.items.length > 0, p = v(e);
108
108
  return N ? /* @__PURE__ */ r(u, { children: h(
@@ -255,7 +255,7 @@ const T = ({
255
255
  }) })
256
256
  ] }),
257
257
  a.showDisabled ? /* @__PURE__ */ o("div", { className: n("mb-6"), children: [
258
- /* @__PURE__ */ r("div", { className: "py-0.5 px-2", children: /* @__PURE__ */ r("p", { className: "font-medium text-[10px] text-[var(--color-text-tertiary)] uppercase tracking-[1.3px] whitespace-nowrap", children: a.label }) }),
258
+ /* @__PURE__ */ r("div", { className: "py-0.5 px-2", children: /* @__PURE__ */ r("p", { className: "font-medium text-3xs text-[var(--color-text-tertiary)] uppercase tracking-[1.3px] whitespace-nowrap", children: a.label }) }),
259
259
  /* @__PURE__ */ r("ul", { className: "", children: a.items.map((e) => {
260
260
  const t = e.href || e.label, l = v(e);
261
261
  return /* @__PURE__ */ r(
@@ -4,10 +4,10 @@ import { AlignLeft as Z, AlignCenter as B, AlignRight as G, ChevronDown as K, Ey
4
4
  import { Button as j } from "react-aria-components";
5
5
  import { cx as m } from "../../../utils/cn.js";
6
6
  import { Dropdown as N } from "../../../primitives/dropdown/dropdown.js";
7
- const a = ({
7
+ const s = ({
8
8
  icon: o,
9
9
  label: c,
10
- danger: s,
10
+ danger: a,
11
11
  submenu: f,
12
12
  selected: p,
13
13
  disabled: r,
@@ -25,7 +25,7 @@ const a = ({
25
25
  "flex items-center gap-2 rounded-md px-2 py-2 text-xs font-medium transition-colors w-full text-left",
26
26
  r ? "cursor-not-allowed text-disabled" : m(
27
27
  "cursor-pointer",
28
- s ? "text-error-primary hover:bg-error-primary" : p ? "bg-utility-brand-25 text-secondary" : "text-secondary hover:bg-primary_hover"
28
+ a ? "text-error-primary hover:bg-error-primary" : p ? "bg-utility-brand-25 text-secondary" : "text-secondary hover:bg-primary_hover"
29
29
  )
30
30
  ),
31
31
  children: [
@@ -35,7 +35,7 @@ const a = ({
35
35
  size: 16,
36
36
  className: m(
37
37
  "shrink-0",
38
- r ? "text-fg-disabled" : s ? "text-error-primary" : "text-fg-quaternary"
38
+ r ? "text-fg-disabled" : a ? "text-error-primary" : "text-fg-quaternary"
39
39
  )
40
40
  }
41
41
  ),
@@ -44,7 +44,7 @@ const a = ({
44
44
  f && /* @__PURE__ */ e(E, { size: 14, className: "shrink-0 text-fg-quaternary" })
45
45
  ]
46
46
  }
47
- ), i = () => /* @__PURE__ */ e("div", { className: "my-1 h-px w-full bg-secondary" }), M = ({ children: o }) => /* @__PURE__ */ e("span", { className: "text-[10px] font-medium uppercase tracking-wider text-tertiary", children: o }), le = ({ label: o, suffix: c }) => /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5 rounded-md border border-secondary bg-primary px-1.5 py-0.5", children: [
47
+ ), i = () => /* @__PURE__ */ e("div", { className: "my-1 h-px w-full bg-secondary" }), M = ({ children: o }) => /* @__PURE__ */ e("span", { className: "text-3xs font-medium uppercase tracking-wider text-tertiary", children: o }), le = ({ label: o, suffix: c }) => /* @__PURE__ */ n("span", { className: "inline-flex items-center gap-1.5 rounded-md border border-secondary bg-primary px-1.5 py-0.5", children: [
48
48
  /* @__PURE__ */ e("span", { className: "flex h-4 w-4 items-center justify-center rounded-sm border border-secondary text-[9px] font-semibold text-tertiary", children: "T" }),
49
49
  /* @__PURE__ */ e("span", { className: "text-xs font-semibold text-primary", children: o }),
50
50
  c && /* @__PURE__ */ e("span", { className: "text-xs text-tertiary", children: c })
@@ -55,7 +55,7 @@ const a = ({
55
55
  ], pe = ({
56
56
  column: o,
57
57
  columnLabel: c,
58
- fieldDef: s,
58
+ fieldDef: a,
59
59
  currentAlignment: f,
60
60
  textWrapped: p = !1,
61
61
  capabilities: r,
@@ -66,7 +66,7 @@ const a = ({
66
66
  isHeaderHovered: H = !1
67
67
  }) => {
68
68
  var _, q;
69
- const F = (s == null ? void 0 : s.data_type) ?? o.dataType, y = F === "LOOKUP" || o.variant === "lookup", L = F === "DERIVED" || o.variant === "derived", I = y ? "Hide field" : "Hide column", x = (r == null ? void 0 : r.sort) ?? !0, v = (r == null ? void 0 : r.align) ?? !0, k = (r == null ? void 0 : r.textWrap) ?? !1, w = (r == null ? void 0 : r.filter) ?? !0, b = (r == null ? void 0 : r.hide) ?? !0, [P, R] = z(!1), [U, A] = z(!1), V = !T || P || H, l = (t) => {
69
+ const F = (a == null ? void 0 : a.data_type) ?? o.dataType, y = F === "LOOKUP" || o.variant === "lookup", L = F === "DERIVED" || o.variant === "derived", I = y ? "Hide field" : "Hide column", x = (r == null ? void 0 : r.sort) ?? !0, v = (r == null ? void 0 : r.align) ?? !0, k = (r == null ? void 0 : r.textWrap) ?? !1, w = (r == null ? void 0 : r.filter) ?? !0, b = (r == null ? void 0 : r.hide) ?? !0, [P, R] = z(!1), [U, A] = z(!1), V = !T || P || H, l = (t) => {
70
70
  u(t), A(!1), R(!1);
71
71
  }, S = O.find((t) => t.id === f) ?? O[0], W = S.icon, C = h == null ? void 0 : h(o);
72
72
  return /* @__PURE__ */ n(
@@ -104,11 +104,11 @@ const a = ({
104
104
  /* @__PURE__ */ e(le, { label: c, suffix: "Object name" })
105
105
  ] }),
106
106
  /* @__PURE__ */ e(i, {}),
107
- /* @__PURE__ */ e(a, { icon: $, label: "View Field", onClick: () => l({ type: "lookup-view" }) }),
108
- /* @__PURE__ */ e(a, { icon: J, label: "Edit field", onClick: () => l({ type: "lookup-edit" }) }),
107
+ /* @__PURE__ */ e(s, { icon: $, label: "View Field", onClick: () => l({ type: "lookup-view" }) }),
108
+ /* @__PURE__ */ e(s, { icon: J, label: "Edit field", onClick: () => l({ type: "lookup-edit" }) }),
109
109
  /* @__PURE__ */ e(i, {}),
110
110
  /* @__PURE__ */ e(
111
- a,
111
+ s,
112
112
  {
113
113
  icon: Q,
114
114
  label: "Add field to right",
@@ -116,7 +116,7 @@ const a = ({
116
116
  }
117
117
  ),
118
118
  /* @__PURE__ */ e(
119
- a,
119
+ s,
120
120
  {
121
121
  icon: X,
122
122
  label: "Add field to left",
@@ -128,7 +128,7 @@ const a = ({
128
128
  L && /* @__PURE__ */ n(d, { children: [
129
129
  /* @__PURE__ */ n("div", { className: "flex flex-col gap-1.5 px-2 py-2", children: [
130
130
  /* @__PURE__ */ e(M, { children: "Formula" }),
131
- /* @__PURE__ */ e("div", { className: "text-xs font-medium text-secondary break-words", children: ((_ = s == null ? void 0 : s.formula) == null ? void 0 : _.trim()) || ((q = o.formula) == null ? void 0 : q.trim()) || c })
131
+ /* @__PURE__ */ e("div", { className: "text-xs font-medium text-secondary break-words", children: ((_ = a == null ? void 0 : a.formula) == null ? void 0 : _.trim()) || ((q = o.formula) == null ? void 0 : q.trim()) || c })
132
132
  ] }),
133
133
  /* @__PURE__ */ e(i, {})
134
134
  ] }),
@@ -139,7 +139,7 @@ const a = ({
139
139
  C && (x || v || k || w || b) && /* @__PURE__ */ e(i, {}),
140
140
  x && /* @__PURE__ */ n(d, { children: [
141
141
  /* @__PURE__ */ e(
142
- a,
142
+ s,
143
143
  {
144
144
  icon: Y,
145
145
  label: "Sort A to Z",
@@ -147,7 +147,7 @@ const a = ({
147
147
  }
148
148
  ),
149
149
  /* @__PURE__ */ e(
150
- a,
150
+ s,
151
151
  {
152
152
  icon: D,
153
153
  label: "Sort Z to A",
@@ -180,7 +180,7 @@ const a = ({
180
180
  placement: "right top",
181
181
  className: "w-44",
182
182
  children: /* @__PURE__ */ e("div", { className: "flex flex-col py-1 px-1.5", children: O.map((t) => /* @__PURE__ */ e(
183
- a,
183
+ s,
184
184
  {
185
185
  icon: t.icon,
186
186
  label: t.label,
@@ -196,7 +196,7 @@ const a = ({
196
196
  k && /* @__PURE__ */ n(d, { children: [
197
197
  (x || v) && /* @__PURE__ */ e(i, {}),
198
198
  /* @__PURE__ */ e(
199
- a,
199
+ s,
200
200
  {
201
201
  icon: ee,
202
202
  label: "Text wrap",
@@ -207,9 +207,9 @@ const a = ({
207
207
  ] }),
208
208
  (w || b) && /* @__PURE__ */ n(d, { children: [
209
209
  (x || v) && !k && /* @__PURE__ */ e(i, {}),
210
- w && /* @__PURE__ */ e(a, { icon: re, label: "Filter by", onClick: () => l({ type: "filter" }) }),
210
+ w && /* @__PURE__ */ e(s, { icon: re, label: "Filter by", onClick: () => l({ type: "filter" }) }),
211
211
  b && /* @__PURE__ */ e(
212
- a,
212
+ s,
213
213
  {
214
214
  icon: te,
215
215
  label: I,
@@ -222,7 +222,7 @@ const a = ({
222
222
  y && /* @__PURE__ */ n(d, { children: [
223
223
  /* @__PURE__ */ e(i, {}),
224
224
  /* @__PURE__ */ e(
225
- a,
225
+ s,
226
226
  {
227
227
  icon: ne,
228
228
  label: "Delete fields",
@@ -180,7 +180,7 @@ const L = ({ config: e, isDisabled: r }) => {
180
180
  o.id
181
181
  )),
182
182
  d.length > 0 && /* @__PURE__ */ s(f, { children: [
183
- /* @__PURE__ */ t("div", { className: "px-2.5 pb-1 pt-2 text-[10px] font-semibold tracking-wide text-tertiary uppercase", children: "Shared with me" }),
183
+ /* @__PURE__ */ t("div", { className: "px-2.5 pb-1 pt-2 text-3xs font-semibold tracking-wide text-tertiary uppercase", children: "Shared with me" }),
184
184
  d.map((o) => /* @__PURE__ */ t(
185
185
  h,
186
186
  {
@@ -0,0 +1,23 @@
1
+ import { TreeViewNode } from './tree-view';
2
+ type CustomNode = React.FC<{
3
+ node: TreeViewNode;
4
+ isSelected: boolean;
5
+ }>;
6
+ export interface IndentedTreeProps {
7
+ tree: TreeViewNode[];
8
+ onToggle: (path: string) => void;
9
+ CustomNode: CustomNode;
10
+ onNodeClick?: (node: TreeViewNode) => void;
11
+ selectedNodeId?: string | null;
12
+ keyboardNavigation: boolean;
13
+ canSelectNode?: (node: TreeViewNode) => boolean;
14
+ "aria-label"?: string;
15
+ }
16
+ /**
17
+ * The `indented` TreeView variant: spaced rows, a 24px indent with one guide line per level, an
18
+ * animated chevron and children. The chevron only expands/collapses; clicking a row's content
19
+ * selects it, for parents and leaves alike.
20
+ */
21
+ export declare const IndentedTree: ({ tree, onToggle, CustomNode, onNodeClick, selectedNodeId, keyboardNavigation, canSelectNode, "aria-label": ariaLabel, }: IndentedTreeProps) => import("react/jsx-runtime").JSX.Element;
22
+ export {};
23
+ //# sourceMappingURL=indented-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indented-tree.d.ts","sourceRoot":"","sources":["../../../src/patterns/tree-view/indented-tree.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,KAAK,UAAU,GAAG,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAC3C,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,0HAS1B,iBAAiB,4CA8GnB,CAAC"}
@@ -0,0 +1,232 @@
1
+ import { jsx as n, jsxs as b } from "react/jsx-runtime";
2
+ import { useRef as I, useMemo as $ } from "react";
3
+ import { ChevronRight as P } from "@untitledui/icons";
4
+ import { motion as A } from "../../node_modules/framer-motion/dist/es/render/components/motion/proxy.js";
5
+ import { AnimatePresence as D } from "../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.js";
6
+ const _ = ({
7
+ tree: s,
8
+ onToggle: p,
9
+ CustomNode: x,
10
+ onNodeClick: c,
11
+ selectedNodeId: v,
12
+ keyboardNavigation: e,
13
+ canSelectNode: d,
14
+ "aria-label": m
15
+ }) => {
16
+ const f = I(null), l = $(() => {
17
+ const t = [];
18
+ function i(a, r = "", h) {
19
+ a.forEach((u, g) => {
20
+ const O = r ? `${r}-${g}` : String(g);
21
+ t.push({ node: u, path: O, parentId: h }), u.isOpen && i(u.children, O, u.id);
22
+ });
23
+ }
24
+ return i(s), t;
25
+ }, [s]);
26
+ function o(t) {
27
+ var a;
28
+ const i = (a = f.current) == null ? void 0 : a.querySelector(
29
+ `[data-tree-node-id="${CSS.escape(t)}"]`
30
+ );
31
+ i == null || i.focus({ preventScroll: !0 }), i == null || i.scrollIntoView({ block: "nearest", behavior: "instant" });
32
+ }
33
+ function w(t) {
34
+ if (!e || t.nativeEvent.isComposing) return;
35
+ const i = t.target.closest(
36
+ "[data-tree-node-id]"
37
+ ), a = l.findIndex(
38
+ ({ node: g }) => g.id === (i == null ? void 0 : i.dataset.treeNodeId)
39
+ );
40
+ if (a < 0) return;
41
+ const { node: r, path: h, parentId: u } = l[a];
42
+ if ([
43
+ "ArrowDown",
44
+ "ArrowUp",
45
+ "ArrowRight",
46
+ "ArrowLeft",
47
+ "Home",
48
+ "End",
49
+ "Enter",
50
+ " "
51
+ ].includes(t.key) && !((t.key === "Enter" || t.key === " ") && t.target.closest("button")))
52
+ switch (t.preventDefault(), t.stopPropagation(), t.key) {
53
+ case "ArrowDown":
54
+ o(l[(a + 1) % l.length].node.id);
55
+ break;
56
+ case "ArrowUp":
57
+ o(
58
+ l[(a - 1 + l.length) % l.length].node.id
59
+ );
60
+ break;
61
+ case "Home":
62
+ o(l[0].node.id);
63
+ break;
64
+ case "End":
65
+ o(l[l.length - 1].node.id);
66
+ break;
67
+ case "ArrowRight":
68
+ r.children.length && !r.isOpen ? p(h) : r.children.length && o(r.children[0].id);
69
+ break;
70
+ case "ArrowLeft":
71
+ r.children.length && r.isOpen ? p(h) : u && o(u);
72
+ break;
73
+ default:
74
+ (!d || d(r)) && (c == null || c(r));
75
+ }
76
+ }
77
+ return /* @__PURE__ */ n(
78
+ "div",
79
+ {
80
+ ref: f,
81
+ role: e ? "tree" : void 0,
82
+ "aria-label": e ? m : void 0,
83
+ onKeyDown: w,
84
+ children: /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: s.map((t, i) => /* @__PURE__ */ n(
85
+ E,
86
+ {
87
+ node: t,
88
+ path: String(i),
89
+ onToggle: p,
90
+ onNodeClick: c,
91
+ CustomNode: x,
92
+ keyboardNavigation: e,
93
+ selectedNodeId: v,
94
+ canSelectNode: d,
95
+ level: 1,
96
+ position: i + 1,
97
+ siblingCount: s.length
98
+ },
99
+ t.id || i
100
+ )) })
101
+ }
102
+ );
103
+ }, E = ({
104
+ node: s,
105
+ path: p,
106
+ onToggle: x,
107
+ onNodeClick: c,
108
+ CustomNode: v,
109
+ keyboardNavigation: e,
110
+ selectedNodeId: d,
111
+ canSelectNode: m,
112
+ level: f,
113
+ position: l,
114
+ siblingCount: o
115
+ }) => {
116
+ const w = s.children.length > 0, t = d != null && s.id === d, i = (r) => {
117
+ r.stopPropagation(), x(p);
118
+ }, a = (r) => {
119
+ r.stopPropagation(), c == null || c(s);
120
+ };
121
+ return /* @__PURE__ */ b("div", { className: "relative", children: [
122
+ /* @__PURE__ */ b(
123
+ "div",
124
+ {
125
+ className: `flex items-center gap-2 py-0.5 ${e ? "rounded-md outline-none hover:bg-primary_hover focus:bg-primary_hover" : ""}`,
126
+ "data-tree-node-id": s.id,
127
+ role: e ? "treeitem" : void 0,
128
+ tabIndex: e ? f === 1 && l === 1 ? 0 : -1 : void 0,
129
+ "aria-label": e ? s.label : void 0,
130
+ "aria-level": e ? f : void 0,
131
+ "aria-posinset": e ? l : void 0,
132
+ "aria-setsize": e ? o : void 0,
133
+ "aria-expanded": e && w ? !!s.isOpen : void 0,
134
+ "aria-selected": e && (!m || m(s)) ? t : void 0,
135
+ children: [
136
+ /* @__PURE__ */ n(
137
+ "div",
138
+ {
139
+ className: "w-4 h-4 flex-shrink-0",
140
+ onClick: (r) => r.stopPropagation(),
141
+ children: w && /* @__PURE__ */ n(
142
+ "button",
143
+ {
144
+ type: "button",
145
+ tabIndex: e ? -1 : void 0,
146
+ onClick: i,
147
+ className: "cursor-pointer hover:bg-secondary_subtle rounded p-0.5 transition-colors flex items-center justify-center",
148
+ "aria-label": s.isOpen ? "Collapse" : "Expand",
149
+ children: /* @__PURE__ */ n(
150
+ A.div,
151
+ {
152
+ initial: !1,
153
+ animate: { rotate: s.isOpen ? 90 : 0 },
154
+ transition: { duration: 0.2, ease: "easeOut" },
155
+ children: /* @__PURE__ */ n(P, { className: "w-4 h-4 text-[var(--color-gray-400)]" })
156
+ }
157
+ )
158
+ }
159
+ )
160
+ }
161
+ ),
162
+ /* @__PURE__ */ n(
163
+ "div",
164
+ {
165
+ onClick: a,
166
+ className: "flex-1 min-w-0 cursor-pointer",
167
+ children: /* @__PURE__ */ n(v, { node: s, isSelected: t })
168
+ }
169
+ )
170
+ ]
171
+ }
172
+ ),
173
+ /* @__PURE__ */ n(D, { initial: !1, children: w && s.isOpen && /* @__PURE__ */ n(
174
+ A.div,
175
+ {
176
+ initial: e ? !1 : { opacity: 0, height: 0 },
177
+ animate: {
178
+ opacity: 1,
179
+ height: "auto",
180
+ transition: {
181
+ height: {
182
+ duration: e ? 0 : 0.1,
183
+ ease: "easeOut"
184
+ },
185
+ opacity: {
186
+ duration: e ? 0 : 0.1,
187
+ ease: "easeOut"
188
+ }
189
+ }
190
+ },
191
+ exit: {
192
+ opacity: 0,
193
+ height: 0,
194
+ transition: {
195
+ height: {
196
+ duration: e ? 0 : 0.3,
197
+ ease: "easeIn"
198
+ },
199
+ opacity: {
200
+ duration: e ? 0 : 0.2,
201
+ ease: "easeIn"
202
+ }
203
+ }
204
+ },
205
+ style: { overflow: "clip" },
206
+ children: /* @__PURE__ */ b("div", { className: "ml-6 relative", children: [
207
+ /* @__PURE__ */ n("div", { className: "absolute left-[-17px] top-[-6px] bottom-0 w-px bg-[var(--color-gray-200)]" }),
208
+ /* @__PURE__ */ n("div", { className: "flex flex-col gap-2", children: s.children.map((r, h) => /* @__PURE__ */ n(
209
+ E,
210
+ {
211
+ node: r,
212
+ path: `${p}-${h}`,
213
+ onToggle: x,
214
+ onNodeClick: c,
215
+ CustomNode: v,
216
+ keyboardNavigation: e,
217
+ selectedNodeId: d,
218
+ canSelectNode: m,
219
+ level: f + 1,
220
+ position: h + 1,
221
+ siblingCount: s.children.length
222
+ },
223
+ r.id || `${p}-${h}`
224
+ )) })
225
+ ] })
226
+ }
227
+ ) })
228
+ ] });
229
+ };
230
+ export {
231
+ _ as IndentedTree
232
+ };
@@ -7,17 +7,14 @@ export interface TreeViewNode {
7
7
  isOpen?: boolean;
8
8
  [key: string]: any;
9
9
  }
10
- export interface TreeViewProps {
11
- /** Raw data array. The component converts it internally using `config`. */
12
- data: Record<string, any>[];
13
- /** Config that tells the component how to read your raw data. */
14
- config: TreeViewBuildConfig;
10
+ interface TreeViewBaseProps {
15
11
  /** Component to render the content area of each row (icon, label, etc.) */
16
12
  CustomNode: React.FC<{
17
13
  node: TreeViewNode;
18
14
  isSelected: boolean;
19
15
  }>;
20
- /** Called when a parent row (with children) is clicked */
16
+ /** Called when a parent row (with children) is clicked, or a leaf that `isLeafClickable` allows.
17
+ * In the `indented` variant it fires for any row's content. */
21
18
  onNodeClick?: (node: TreeViewNode) => void;
22
19
  /** ID of the currently selected node */
23
20
  selectedNodeId?: string | null;
@@ -32,7 +29,39 @@ export interface TreeViewProps {
32
29
  /** When true, every node starts expanded. Per-node `isOpen` on the
33
30
  * source data, if present, still wins. Default false. */
34
31
  defaultExpanded?: boolean;
32
+ /** Built node ids (paths such as `"doc.field"`) that start expanded; every other node starts
33
+ * collapsed. Wins over `defaultExpanded`; per-node `isOpen` on the source data still wins. */
34
+ defaultExpandedIds?: Iterable<string>;
35
+ /** Rebuild the tree when `data`, `config`, `nodes` or `defaultExpandedIds` change, which
36
+ * resets expansion to those inputs. Off by default: the tree is built once on mount.
37
+ * Pass stable (memoised) inputs when this is on. */
38
+ syncWithData?: boolean;
39
+ /** `nested` (default): 28px rows with a guide line per ancestor; a parent row click toggles it.
40
+ * `indented`: spaced rows, 24px indent and animated chevrons; the chevron toggles and a row's
41
+ * content selects. Search (`showSearch`) is only available in `nested`. */
42
+ variant?: "nested" | "indented";
43
+ /** `nested` variant: leaf rows for which this returns true are clickable and fire `onNodeClick`. */
44
+ isLeafClickable?: (node: TreeViewNode) => boolean;
45
+ /** `indented` variant: arrow/Home/End navigation, Enter/Space to select, and tree/treeitem roles. */
46
+ keyboardNavigation?: boolean;
47
+ /** `indented` variant: rows for which this returns false are not selected by Enter/Space and get
48
+ * no `aria-selected`. Mouse clicks still reach `onNodeClick`, so check it there as well. */
49
+ canSelectNode?: (node: TreeViewNode) => boolean;
50
+ /** Accessible name of the tree; used with `keyboardNavigation`. */
51
+ "aria-label"?: string;
35
52
  }
53
+ export type TreeViewProps = TreeViewBaseProps & ({
54
+ /** Raw data array. The component converts it internally using `config`. */
55
+ data: Record<string, any>[];
56
+ /** Config that tells the component how to read your raw data. */
57
+ config: TreeViewBuildConfig;
58
+ nodes?: never;
59
+ } | {
60
+ /** Already-built nodes, used as they are (ids, `isOpen` and extra keys kept). */
61
+ nodes: TreeViewNode[];
62
+ data?: never;
63
+ config?: never;
64
+ });
36
65
  /**
37
66
  * Config for building TreeViewNode[] from arbitrary data.
38
67
  * Tells the build function which keys to use for label, children, and where to store the original node data.
@@ -53,6 +82,9 @@ export interface TreeViewBuildConfig {
53
82
  /** When true, every built node starts with `isOpen: true`. Per-node
54
83
  * `isOpen` on source data overrides this (source data always wins). */
55
84
  defaultExpanded?: boolean;
85
+ /** Built node ids that start expanded; every other node starts collapsed. Wins over
86
+ * `defaultExpanded`; per-node `isOpen` on source data still wins. */
87
+ expandedIds?: ReadonlySet<string>;
56
88
  }
57
89
  /**
58
90
  * Converts any array of items into TreeViewNode[] using the given config.
@@ -61,7 +93,8 @@ export interface TreeViewBuildConfig {
61
93
  */
62
94
  export declare function buildTreeViewNodes<T extends Record<string, any>>(data: T[], config: TreeViewBuildConfig, parentPath?: string): TreeViewNode[];
63
95
  export declare const TreeView: {
64
- ({ data, config, CustomNode, onNodeClick, selectedNodeId, showSearch, searchPlaceholder, searchClassName, searchInputClassName, defaultExpanded, }: TreeViewProps): import("react/jsx-runtime").JSX.Element;
96
+ ({ data, config, nodes, CustomNode, onNodeClick, selectedNodeId, showSearch, searchPlaceholder, searchClassName, searchInputClassName, defaultExpanded, defaultExpandedIds, syncWithData, variant, isLeafClickable, keyboardNavigation, canSelectNode, "aria-label": ariaLabel, }: TreeViewProps): import("react/jsx-runtime").JSX.Element;
65
97
  displayName: string;
66
98
  };
99
+ export {};
67
100
  //# sourceMappingURL=tree-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree-view.d.ts","sourceRoot":"","sources":["../../../src/patterns/tree-view/t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