@pibit.ai/cure-design-system 0.6.39 → 0.6.41

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 (31) hide show
  1. package/dist/index.d.ts +2 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +707 -691
  4. package/dist/node_modules/framer-motion/dist/es/components/Reorder/namespace.js +6 -0
  5. package/dist/patterns/filter-group/index.d.ts +1 -0
  6. package/dist/patterns/filter-group/index.d.ts.map +1 -1
  7. package/dist/primitives/hierarchical-select/HierarchicalSelect.d.ts +6 -0
  8. package/dist/primitives/hierarchical-select/HierarchicalSelect.d.ts.map +1 -0
  9. package/dist/primitives/hierarchical-select/HierarchicalSelect.js +156 -0
  10. package/dist/primitives/hierarchical-select/components/HierarchicalItem.d.ts +6 -0
  11. package/dist/primitives/hierarchical-select/components/HierarchicalItem.d.ts.map +1 -0
  12. package/dist/primitives/hierarchical-select/components/HierarchicalItem.js +102 -0
  13. package/dist/primitives/hierarchical-select/components/HighlightedText.d.ts +6 -0
  14. package/dist/primitives/hierarchical-select/components/HighlightedText.d.ts.map +1 -0
  15. package/dist/primitives/hierarchical-select/components/HighlightedText.js +22 -0
  16. package/dist/primitives/hierarchical-select/components/index.d.ts +6 -0
  17. package/dist/primitives/hierarchical-select/components/index.d.ts.map +1 -0
  18. package/dist/primitives/hierarchical-select/index.d.ts +11 -0
  19. package/dist/primitives/hierarchical-select/index.d.ts.map +1 -0
  20. package/dist/primitives/hierarchical-select/types/index.d.ts +109 -0
  21. package/dist/primitives/hierarchical-select/types/index.d.ts.map +1 -0
  22. package/dist/primitives/hierarchical-select/utils/normalize.d.ts +18 -0
  23. package/dist/primitives/hierarchical-select/utils/normalize.d.ts.map +1 -0
  24. package/dist/primitives/hierarchical-select/utils/search.d.ts +17 -0
  25. package/dist/primitives/hierarchical-select/utils/search.d.ts.map +1 -0
  26. package/dist/primitives/hierarchical-select/utils/search.js +24 -0
  27. package/dist/primitives/hierarchical-select/utils/selection.d.ts +37 -0
  28. package/dist/primitives/hierarchical-select/utils/selection.d.ts.map +1 -0
  29. package/dist/primitives/hierarchical-select/utils/selection.js +126 -0
  30. package/dist/styles/components.css +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,6 @@
1
+ import { ReorderGroup as o } from "./Group.js";
2
+ import { ReorderItem as p } from "./Item.js";
3
+ export {
4
+ o as Group,
5
+ p as Item
6
+ };
@@ -8,4 +8,5 @@ export type { FilterGroupBuilderProps, FilterGroup, FilterCondition, FilterNode,
8
8
  export { DEFAULT_OPERATORS, generateId, createEmptyCondition, createEmptyGroup } from './types';
9
9
  export { validateFilterGroup, isFilterGroupValid } from './validation';
10
10
  export { defaultFilterDateAdapter, parseFilterDate, parseFilterTimestamp, formatFilterTimestamp, type FilterDateAdapter, } from './date-adapter';
11
+ export { Reorder, useDragControls } from 'framer-motion';
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGtF,YAAY,EACR,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhG,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACH,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,iBAAiB,GACzB,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/patterns/filter-group/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAGvF,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGtF,YAAY,EACR,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGhG,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGvE,OAAO,EACH,wBAAwB,EACxB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,KAAK,iBAAiB,GACzB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { HierarchicalSelectProps } from './types';
2
+ export declare function HierarchicalSelect<T>({ size, data, selectionKey, transformData, reconstructData, onChange, searchPlaceholder, maxHeight, className, showSelectAll, childCountLabel, }: HierarchicalSelectProps<T>): import("react/jsx-runtime").JSX.Element;
3
+ export declare namespace HierarchicalSelect {
4
+ var displayName: string;
5
+ }
6
+ //# sourceMappingURL=HierarchicalSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchicalSelect.d.ts","sourceRoot":"","sources":["../../../src/primitives/hierarchical-select/HierarchicalSelect.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,uBAAuB,EAAgD,MAAM,SAAS,CAAC;AAuBrG,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAClC,IAAW,EACX,IAAI,EACJ,YAAY,EACZ,aAAa,EACb,eAAe,EACf,QAAQ,EACR,iBAA8C,EAC9C,SAAe,EACf,SAAS,EACT,aAAoB,EACpB,eAAe,GAClB,EAAE,uBAAuB,CAAC,CAAC,CAAC,2CAyO5B;yBArPe,kBAAkB"}
@@ -0,0 +1,156 @@
1
+ import { jsxs as T, jsx as i } from "react/jsx-runtime";
2
+ import { useState as R, useMemo as a, useEffect as $, useCallback as S } from "react";
3
+ import { HierarchicalItem as U } from "./components/HierarchicalItem.js";
4
+ import { getAllParentIds as W, toggleSelection as X, getVisibleLeafIds as Y, getSelectAllState as Z, toggleSelectAll as z, getSelectionState as K } from "./utils/selection.js";
5
+ import { searchTree as ee } from "./utils/search.js";
6
+ import { cx as b } from "../../utils/cn.js";
7
+ import te from "../select/SearchInput.js";
8
+ import { Icon as se } from "../icon/icon.js";
9
+ import { Checkbox as re } from "../checkbox/checkbox.js";
10
+ const y = {
11
+ xs: "text-xs",
12
+ sm: "text-sm",
13
+ md: "text-md",
14
+ lg: "text-lg"
15
+ };
16
+ function le({
17
+ size: d = "md",
18
+ data: h,
19
+ selectionKey: m,
20
+ transformData: E,
21
+ reconstructData: v,
22
+ onChange: I,
23
+ searchPlaceholder: D = "Search objects or fields",
24
+ maxHeight: N = 400,
25
+ className: H,
26
+ showSelectAll: P = !0,
27
+ childCountLabel: Q
28
+ }) {
29
+ const [u, V] = R(""), [A, w] = R(() => /* @__PURE__ */ new Set()), t = a(() => E(h, m), [h, m, E]), f = a(() => W(t), [t]), q = a(() => Array.from(f).sort().join("\0"), [f]);
30
+ $(() => {
31
+ w(new Set(f));
32
+ }, [q]);
33
+ const l = a(() => ee(t, u), [t, u]), n = !!u.trim();
34
+ $(() => {
35
+ n && w((e) => {
36
+ const s = new Set(e);
37
+ return l.visibleIds.forEach((r) => {
38
+ let o = t.parentMap.get(r);
39
+ for (; o; )
40
+ s.add(o), o = t.parentMap.get(o) ?? null;
41
+ }), s;
42
+ });
43
+ }, [n, l.visibleIds, t]);
44
+ const B = S(
45
+ (e) => {
46
+ const r = u.trim().length > 0 && e.trim().length === 0;
47
+ V(e), r && w(new Set(f));
48
+ },
49
+ [u, f]
50
+ ), p = a(() => n ? l.visibleIds : void 0, [n, l.visibleIds]), _ = S(
51
+ (e) => {
52
+ const s = n ? l.visibleIds : void 0, r = X(e, t, s), o = v(r, h, m);
53
+ I(o);
54
+ },
55
+ [t, n, l.visibleIds, v, h, m, I]
56
+ ), F = a(() => Y(t, p).length, [t, p]), j = a(() => Z(t, p), [t, p]), g = F === 0, M = S(() => {
57
+ if (g) return;
58
+ const e = z(t, p), s = v(e, h, m);
59
+ I(s);
60
+ }, [g, t, p, v, h, m, I]), G = S((e) => {
61
+ w((s) => {
62
+ const r = new Set(s);
63
+ return r.has(e) ? r.delete(e) : r.add(e), r;
64
+ });
65
+ }, []), C = a(() => {
66
+ const e = [], s = (r) => {
67
+ (r === null ? t.rootIds : t.childrenMap.get(r) || []).forEach((c) => {
68
+ if (n && !l.visibleIds.has(c))
69
+ return;
70
+ const x = t.items.get(c);
71
+ x && (e.push({
72
+ id: c,
73
+ item: x,
74
+ isMatched: l.matchedIds.has(c)
75
+ }), x.hasChildren && A.has(c) && s(c));
76
+ });
77
+ };
78
+ return s(null), e;
79
+ }, [t, n, l.visibleIds, l.matchedIds, A]), J = S(
80
+ (e) => {
81
+ if (!n) return null;
82
+ const s = l.resultCounts.get(e);
83
+ return s === void 0 ? null : `${s} ${s === 1 ? "result" : "results"}`;
84
+ },
85
+ [n, l.resultCounts]
86
+ ), k = t.items.size > 0, O = P && k && (!n || C.length > 0), L = n ? "Select all results" : "Select All";
87
+ return /* @__PURE__ */ T("div", { className: b("flex flex-col border border-primary rounded-lg bg-primary overflow-hidden", H), children: [
88
+ /* @__PURE__ */ i("div", { className: "border-b border-secondary p-2", children: /* @__PURE__ */ i(
89
+ te,
90
+ {
91
+ size: d == "xs" ? "sm" : d,
92
+ value: u,
93
+ onChange: B,
94
+ placeholder: D
95
+ }
96
+ ) }),
97
+ O && /* @__PURE__ */ T(
98
+ "div",
99
+ {
100
+ className: b(
101
+ "flex shrink-0 items-center gap-2 border-b border-secondary px-3 py-2.5",
102
+ g ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-secondary_subtle transition-colors"
103
+ ),
104
+ onClick: M,
105
+ "aria-disabled": g,
106
+ children: [
107
+ j === "indeterminate" ? /* @__PURE__ */ i(se, { name: "MinusSquare", className: "size-4 text-utility-brand-600" }) : /* @__PURE__ */ i(
108
+ re,
109
+ {
110
+ isSelected: j === "selected",
111
+ isDisabled: g,
112
+ onChange: M,
113
+ "aria-label": L
114
+ }
115
+ ),
116
+ /* @__PURE__ */ i("span", { className: b("font-medium text-primary", y[d]), children: L })
117
+ ]
118
+ }
119
+ ),
120
+ /* @__PURE__ */ i(
121
+ "div",
122
+ {
123
+ className: "overflow-y-auto",
124
+ style: { maxHeight: typeof N == "number" ? `${N}px` : N },
125
+ role: "listbox",
126
+ "aria-multiselectable": "true",
127
+ children: k ? C.length === 0 ? /* @__PURE__ */ i("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No results found" }) : C.map(({ id: e, item: s, isMatched: r }) => {
128
+ const o = s.depth === 0 ? J(e) : null, c = K(e, t), x = s.disabled === !0;
129
+ return /* @__PURE__ */ i("div", { children: /* @__PURE__ */ T("div", { className: "flex items-center", children: [
130
+ /* @__PURE__ */ i("div", { className: "flex-1", children: /* @__PURE__ */ i(
131
+ U,
132
+ {
133
+ size: d,
134
+ item: s,
135
+ selectionState: c,
136
+ isMatched: r,
137
+ searchQuery: u,
138
+ onToggle: _,
139
+ isExpandable: s.hasChildren,
140
+ isExpanded: A.has(e),
141
+ onExpandToggle: () => G(e),
142
+ isDisabled: x,
143
+ childCountLabel: Q
144
+ }
145
+ ) }),
146
+ o && /* @__PURE__ */ i("span", { className: b("text-tertiary pr-3 whitespace-nowrap", y[d]), children: o })
147
+ ] }) }, e);
148
+ }) : /* @__PURE__ */ i("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No items available" })
149
+ }
150
+ )
151
+ ] });
152
+ }
153
+ le.displayName = "HierarchicalSelect";
154
+ export {
155
+ le as HierarchicalSelect
156
+ };
@@ -0,0 +1,6 @@
1
+ import { HierarchicalItemProps } from '../types';
2
+ export declare const HierarchicalItem: {
3
+ ({ size, item, selectionState, searchQuery, onToggle, isExpandable, isExpanded, onExpandToggle, isDisabled, childCountLabel, }: HierarchicalItemProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ //# sourceMappingURL=HierarchicalItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchicalItem.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/HierarchicalItem.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAkBtD,eAAO,MAAM,gBAAgB;oIAW1B,qBAAqB;;CA8EvB,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
+ import { useCallback as u } from "react";
3
+ import { ChevronDown as g } from "@untitledui/icons";
4
+ import { HighlightedText as w } from "./HighlightedText.js";
5
+ import { cx as s } from "../../../utils/cn.js";
6
+ import { Icon as _ } from "../../icon/icon.js";
7
+ import { Checkbox as I } from "../../checkbox/checkbox.js";
8
+ import { ButtonUtility as L } from "../../button/button-utility.js";
9
+ const k = 24, x = {
10
+ xs: "text-xs",
11
+ sm: "text-sm",
12
+ md: "text-md",
13
+ lg: "text-lg"
14
+ }, v = { singular: "subfield", plural: "subfields" }, H = ({
15
+ size: i = "md",
16
+ item: t,
17
+ selectionState: n,
18
+ searchQuery: c,
19
+ onToggle: m,
20
+ isExpandable: y = !1,
21
+ isExpanded: o = !1,
22
+ onExpandToggle: a,
23
+ isDisabled: e = !1,
24
+ childCountLabel: d = v
25
+ }) => {
26
+ const p = u(() => {
27
+ e || m(t.id);
28
+ }, [e, t.id, m]), C = u(
29
+ (b) => {
30
+ b.stopPropagation(), a == null || a();
31
+ },
32
+ [a]
33
+ ), h = n === "selected", N = n === "indeterminate", f = t.depth === 0;
34
+ return /* @__PURE__ */ l(
35
+ "div",
36
+ {
37
+ className: s(
38
+ "flex items-center justify-between gap-2 py-2.5 px-3 transition-colors",
39
+ e ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-secondary_subtle/50",
40
+ f && "bg-secondary_subtle/30"
41
+ ),
42
+ style: { paddingLeft: `${12 + t.depth * k}px` },
43
+ onClick: p,
44
+ role: "option",
45
+ "aria-selected": h,
46
+ "aria-disabled": e,
47
+ children: [
48
+ /* @__PURE__ */ l("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
49
+ N && !e ? /* @__PURE__ */ r(_, { name: "MinusSquare", className: "size-4 shrink-0 text-utility-brand-600" }) : /* @__PURE__ */ r(
50
+ I,
51
+ {
52
+ isSelected: h,
53
+ isDisabled: e,
54
+ onChange: p,
55
+ "aria-label": t.label
56
+ }
57
+ ),
58
+ /* @__PURE__ */ l("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
59
+ /* @__PURE__ */ r(
60
+ "span",
61
+ {
62
+ className: s(
63
+ "text-secondary truncate",
64
+ f && "font-semibold text-primary",
65
+ x[i]
66
+ ),
67
+ children: c ? /* @__PURE__ */ r(w, { text: t.label, highlight: c }) : t.label
68
+ }
69
+ ),
70
+ t.hasChildren && t.childCount > 0 && /* @__PURE__ */ l("span", { className: s("text-tertiary whitespace-nowrap", x[i]), children: [
71
+ t.childCount,
72
+ " ",
73
+ t.childCount === 1 ? d.singular : d.plural
74
+ ] })
75
+ ] })
76
+ ] }),
77
+ y ? /* @__PURE__ */ r(
78
+ L,
79
+ {
80
+ size: "3xs",
81
+ color: "tertiary",
82
+ icon: /* @__PURE__ */ r(
83
+ g,
84
+ {
85
+ "data-icon": !0,
86
+ size: 16,
87
+ className: s("transition-transform duration-200", o && "rotate-180")
88
+ }
89
+ ),
90
+ tooltip: o ? "Collapse" : "Expand",
91
+ "aria-expanded": o,
92
+ onClick: C
93
+ }
94
+ ) : null
95
+ ]
96
+ }
97
+ );
98
+ };
99
+ H.displayName = "HierarchicalItem";
100
+ export {
101
+ H as HierarchicalItem
102
+ };
@@ -0,0 +1,6 @@
1
+ import { HighlightedTextProps } from '../types';
2
+ export declare const HighlightedText: {
3
+ ({ text, highlight, highlightClassName }: HighlightedTextProps): import("react/jsx-runtime").JSX.Element;
4
+ displayName: string;
5
+ };
6
+ //# sourceMappingURL=HighlightedText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HighlightedText.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/HighlightedText.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAIrD,eAAO,MAAM,eAAe;8CAA6C,oBAAoB;;CAmC5F,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { jsx as i, Fragment as n } from "react/jsx-runtime";
2
+ import { useMemo as o } from "react";
3
+ import { escapeRegExp as p } from "../utils/search.js";
4
+ import { cx as l } from "../../../utils/cn.js";
5
+ const f = ({ text: e, highlight: r, highlightClassName: a }) => {
6
+ const c = o(() => {
7
+ if (!r.trim())
8
+ return [{ text: e, isMatch: !1 }];
9
+ const t = new RegExp(`(${p(r)})`, "gi");
10
+ return e.split(t).filter((s) => s !== "").map((s) => ({
11
+ text: s,
12
+ isMatch: t.test(s)
13
+ }));
14
+ }, [e, r]);
15
+ return r.trim() ? /* @__PURE__ */ i(n, { children: c.map(
16
+ (t, m) => t.isMatch ? /* @__PURE__ */ i("span", { className: l("text-utility-brand-600", a), children: t.text }, m) : /* @__PURE__ */ i("span", { children: t.text }, m)
17
+ ) }) : /* @__PURE__ */ i(n, { children: e });
18
+ };
19
+ f.displayName = "HighlightedText";
20
+ export {
21
+ f as HighlightedText
22
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Component exports for HierarchicalSelect
3
+ */
4
+ export { HighlightedText } from './HighlightedText';
5
+ export { HierarchicalItem } from './HierarchicalItem';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * HierarchicalSelect - Hierarchical Multi-Select Component
3
+ *
4
+ * A reusable component for displaying and selecting items in a hierarchical tree structure
5
+ * with tri-state checkboxes, cascading selection, and search functionality.
6
+ */
7
+ export { HierarchicalSelect } from './HierarchicalSelect';
8
+ export type { NormalizedTree, NormalizedItem, SelectionState, SearchResult, HierarchicalSelectProps, HierarchicalItemProps, HighlightedTextProps, } from './types';
9
+ export { getSelectionState, toggleSelection, toggleSelectAll, getSelectAllState, getAllParentIds, countSelectedItems, } from './utils/selection';
10
+ export { searchTree, escapeRegExp } from './utils/search';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/primitives/hierarchical-select/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,YAAY,EACR,cAAc,EACd,cAAc,EACd,cAAc,EACd,YAAY,EACZ,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,GACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACH,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Type definitions for HierarchicalSelect component
3
+ */
4
+ /**
5
+ * Normalized item for internal use
6
+ * Represents a flattened tree node with precomputed metadata
7
+ */
8
+ export interface NormalizedItem {
9
+ id: string;
10
+ label: string;
11
+ selected: boolean;
12
+ depth: number;
13
+ hasChildren: boolean;
14
+ childCount: number;
15
+ parentId: string | null;
16
+ /** Path to reconstruct original data structure */
17
+ originalPath: string[];
18
+ /** When true, item cannot be toggled and is excluded from select-all */
19
+ disabled?: boolean;
20
+ }
21
+ /**
22
+ * Normalized tree structure for efficient operations
23
+ * Provides O(1) lookups for items, children, and parents
24
+ */
25
+ export interface NormalizedTree {
26
+ /** O(1) lookup by ID */
27
+ items: Map<string, NormalizedItem>;
28
+ /** Parent ID → Child IDs mapping */
29
+ childrenMap: Map<string, string[]>;
30
+ /** Child ID → Parent ID mapping */
31
+ parentMap: Map<string, string | null>;
32
+ /** Root level item IDs */
33
+ rootIds: string[];
34
+ /** Item ID → depth mapping */
35
+ depthMap: Map<string, number>;
36
+ /** Key used for selection in original data */
37
+ selectionKey: string;
38
+ }
39
+ /**
40
+ * Selection state for an item
41
+ */
42
+ export type SelectionState = "selected" | "unselected" | "indeterminate";
43
+ /**
44
+ * Search result containing visibility and match information
45
+ */
46
+ export interface SearchResult {
47
+ /** IDs of items that should be visible */
48
+ visibleIds: Set<string>;
49
+ /** IDs of items that directly match the search query */
50
+ matchedIds: Set<string>;
51
+ /** Section ID → count of matches within */
52
+ resultCounts: Map<string, number>;
53
+ }
54
+ export interface ChildCountLabel {
55
+ singular: string;
56
+ plural: string;
57
+ }
58
+ /**
59
+ * Props for HierarchicalSelect component
60
+ */
61
+ export interface HierarchicalSelectProps<T> {
62
+ /** Size of the component */
63
+ size?: "xs" | "sm" | "md" | "lg";
64
+ /** Data to display */
65
+ data: T;
66
+ /** Key used for selection state (e.g., "enabled", "selected", "checked") */
67
+ selectionKey: string;
68
+ /** Transform function to normalize data */
69
+ transformData: (data: T, selectionKey: string) => NormalizedTree;
70
+ /** Reconstruct output data from normalized state */
71
+ reconstructData: (tree: NormalizedTree, originalData: T, selectionKey: string) => T;
72
+ /** Callback when selection changes */
73
+ onChange: (updatedData: T) => void;
74
+ /** Placeholder text for search input */
75
+ searchPlaceholder?: string;
76
+ /** Maximum height of the list */
77
+ maxHeight?: string | number;
78
+ /** Additional CSS classes */
79
+ className?: string;
80
+ /** Show "Select All" row below search. Default true. */
81
+ showSelectAll?: boolean;
82
+ /** Noun for a parent's child count, e.g. "3 subfields". Default subfield/subfields. */
83
+ childCountLabel?: ChildCountLabel;
84
+ }
85
+ /**
86
+ * Props for HierarchicalItem component
87
+ */
88
+ export interface HierarchicalItemProps {
89
+ size?: "xs" | "sm" | "md" | "lg";
90
+ item: NormalizedItem;
91
+ selectionState: SelectionState;
92
+ isMatched: boolean;
93
+ searchQuery: string;
94
+ onToggle: (id: string) => void;
95
+ isExpandable?: boolean;
96
+ isExpanded?: boolean;
97
+ onExpandToggle?: () => void;
98
+ isDisabled?: boolean;
99
+ childCountLabel?: ChildCountLabel;
100
+ }
101
+ /**
102
+ * Props for HighlightedText component
103
+ */
104
+ export interface HighlightedTextProps {
105
+ text: string;
106
+ highlight: string;
107
+ highlightClassName?: string;
108
+ }
109
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/types/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,18 @@
1
+ import { NormalizedTree, NormalizedItem } from '../types';
2
+ /**
3
+ * Creates an empty normalized tree structure
4
+ */
5
+ export declare function createEmptyTree(selectionKey: string): NormalizedTree;
6
+ /**
7
+ * Adds an item to the normalized tree
8
+ */
9
+ export declare function addItemToTree(tree: NormalizedTree, item: NormalizedItem, parentId: string | null): void;
10
+ /**
11
+ * Creates a normalized item
12
+ */
13
+ export declare function createNormalizedItem(id: string, label: string, selected: boolean, depth: number, parentId: string | null, originalPath: string[], hasChildren?: boolean, childCount?: number): NormalizedItem;
14
+ /**
15
+ * Clones a normalized tree with new items map
16
+ */
17
+ export declare function cloneTreeWithItems(tree: NormalizedTree, newItems: Map<string, NormalizedItem>): NormalizedTree;
18
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/utils/normalize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/D;;GAEG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CASpE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAYvG;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAChC,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,OAAO,EACjB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,YAAY,EAAE,MAAM,EAAE,EACtB,WAAW,GAAE,OAAe,EAC5B,UAAU,GAAE,MAAU,GACvB,cAAc,CAWhB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,cAAc,CAK9G"}
@@ -0,0 +1,17 @@
1
+ import { NormalizedTree, SearchResult } from '../types';
2
+ /**
3
+ * Escapes special regex characters in a string
4
+ */
5
+ export declare function escapeRegExp(string: string): string;
6
+ /**
7
+ * Searches the tree and returns visibility/match information
8
+ * @param tree - The normalized tree to search
9
+ * @param query - The search query
10
+ * @returns SearchResult with visible IDs, matched IDs, and counts
11
+ */
12
+ export declare function searchTree(tree: NormalizedTree, query: string): SearchResult;
13
+ /**
14
+ * Checks if an item or any of its descendants match the search query
15
+ */
16
+ export declare function hasMatchingDescendant(itemId: string, tree: NormalizedTree, matchedIds: Set<string>): boolean;
17
+ //# sourceMappingURL=search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/utils/search.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAmD5E;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,OAAO,CAK5G"}
@@ -0,0 +1,24 @@
1
+ function d(t) {
2
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3
+ }
4
+ function p(t, h) {
5
+ const l = h.toLowerCase().trim(), r = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
6
+ return l ? (t.items.forEach((a, e) => {
7
+ if (a.label.toLowerCase().includes(l)) {
8
+ c.add(e), r.add(e);
9
+ let n = t.parentMap.get(e);
10
+ for (; n; )
11
+ r.add(n), n = t.parentMap.get(n) ?? null;
12
+ }
13
+ }), t.rootIds.forEach((a) => {
14
+ let e = 0;
15
+ const n = (s) => {
16
+ c.has(s) && s !== a && e++, (t.childrenMap.get(s) || []).forEach(n);
17
+ };
18
+ n(a), (e > 0 || c.has(a)) && o.set(a, e);
19
+ }), { visibleIds: r, matchedIds: c, resultCounts: o }) : (t.items.forEach((a, e) => r.add(e)), { visibleIds: r, matchedIds: c, resultCounts: o });
20
+ }
21
+ export {
22
+ d as escapeRegExp,
23
+ p as searchTree
24
+ };
@@ -0,0 +1,37 @@
1
+ import { NormalizedTree, SelectionState } from '../types';
2
+ /**
3
+ * Computes the selection state for an item based on its children
4
+ * @param itemId - The item to compute state for
5
+ * @param tree - The normalized tree
6
+ * @param visibleIds - Optional set of visible IDs (for search filtering)
7
+ */
8
+ export declare function getSelectionState(itemId: string, tree: NormalizedTree, visibleIds?: Set<string>): SelectionState;
9
+ /**
10
+ * Toggles selection for an item and cascades to children/ancestors
11
+ * @param itemId - The item to toggle
12
+ * @param tree - The normalized tree
13
+ * @param visibleIds - Optional set of visible IDs (for search filtering)
14
+ * @returns New tree with updated selection states
15
+ */
16
+ export declare function toggleSelection(itemId: string, tree: NormalizedTree, visibleIds?: Set<string>): NormalizedTree;
17
+ /**
18
+ * Returns IDs of all items that have children
19
+ */
20
+ export declare function getAllParentIds(tree: NormalizedTree): Set<string>;
21
+ /**
22
+ * Returns leaf item IDs, optionally filtered to a visible set
23
+ */
24
+ export declare function getVisibleLeafIds(tree: NormalizedTree, visibleIds?: Set<string>): string[];
25
+ /**
26
+ * Computes select-all state for a set of visible leaf items
27
+ */
28
+ export declare function getSelectAllState(tree: NormalizedTree, visibleIds?: Set<string>): SelectionState;
29
+ /**
30
+ * Toggles all visible leaf items and recomputes parent states
31
+ */
32
+ export declare function toggleSelectAll(tree: NormalizedTree, visibleIds?: Set<string>): NormalizedTree;
33
+ /**
34
+ * Counts the total number of selected leaf items
35
+ */
36
+ export declare function countSelectedItems(tree: NormalizedTree): number;
37
+ //# sourceMappingURL=selection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/utils/selection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU/D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CAkChH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CA+F9G;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,CAQjE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAQ1F;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CAYhG;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,cAAc,CAyC9F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,CAS/D"}