@pibit.ai/cure-design-system 0.6.57 → 0.6.59

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.
@@ -1,145 +1,145 @@
1
- import { jsxs as T, jsx as l } from "react/jsx-runtime";
2
- import { useState as P, useMemo as a, useEffect as R, useCallback as S } from "react";
1
+ import { jsxs as T, jsx as i } from "react/jsx-runtime";
2
+ import { useState as L, useMemo as a, useEffect as P, useCallback as S } from "react";
3
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";
4
+ import { HierarchicalSearchInput as W } from "./components/HierarchicalSearchInput.js";
5
+ import { getAllParentIds as X, toggleSelection as Y, getVisibleLeafIds as Z, getSelectAllState as z, toggleSelectAll as K, getSelectionState as ee } from "./utils/selection.js";
6
+ import { searchTree as te } from "./utils/search.js";
7
+ import { cx as f } from "../../utils/cn.js";
8
8
  import { Icon as se } from "../icon/icon.js";
9
- import { Checkbox as re } from "../checkbox/checkbox.js";
9
+ import { Checkbox as le } from "../checkbox/checkbox.js";
10
10
  const y = {
11
11
  xs: "text-xs",
12
12
  sm: "text-sm",
13
13
  md: "text-md",
14
14
  lg: "text-lg"
15
15
  };
16
- function le({
16
+ function re({
17
17
  size: d = "md",
18
18
  data: h,
19
19
  selectionKey: m,
20
20
  transformData: E,
21
21
  reconstructData: v,
22
22
  onChange: I,
23
- searchPlaceholder: $ = "Search objects or fields",
23
+ searchPlaceholder: R = "Search objects or fields",
24
24
  maxHeight: N = 400,
25
- className: D,
26
- showSelectAll: H = !0,
25
+ className: $,
26
+ showSelectAll: D = !0,
27
27
  childCountLabel: Q
28
28
  }) {
29
- const [u, V] = P(""), [C, w] = P(() => /* @__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
- R(() => {
31
- w(new Set(f));
29
+ const [u, V] = L(""), [C, w] = L(() => /* @__PURE__ */ new Set()), t = a(() => E(h, m), [h, m, E]), g = a(() => X(t), [t]), q = a(() => Array.from(g).sort().join("\0"), [g]);
30
+ P(() => {
31
+ w(new Set(g));
32
32
  }, [q]);
33
- const n = a(() => ee(t, u), [t, u]), i = !!u.trim();
34
- R(() => {
35
- i && w((e) => {
33
+ const r = a(() => te(t, u), [t, u]), n = !!u.trim();
34
+ P(() => {
35
+ n && w((e) => {
36
36
  const s = new Set(e);
37
- return n.visibleIds.forEach((r) => {
38
- let o = t.parentMap.get(r);
37
+ return r.visibleIds.forEach((l) => {
38
+ let o = t.parentMap.get(l);
39
39
  for (; o; )
40
40
  s.add(o), o = t.parentMap.get(o) ?? null;
41
41
  }), s;
42
42
  });
43
- }, [i, n.visibleIds, t]);
43
+ }, [n, r.visibleIds, t]);
44
44
  const B = S(
45
45
  (e) => {
46
- const r = u.trim().length > 0 && e.trim().length === 0;
47
- V(e), r && w(new Set(f));
46
+ const l = u.trim().length > 0 && e.trim().length === 0;
47
+ V(e), l && w(new Set(g));
48
48
  },
49
- [u, f]
50
- ), p = a(() => i ? n.visibleIds : void 0, [i, n.visibleIds]), _ = S(
49
+ [u, g]
50
+ ), p = a(() => n ? r.visibleIds : void 0, [n, r.visibleIds]), _ = S(
51
51
  (e) => {
52
- const s = i ? n.visibleIds : void 0, r = X(e, t, s), o = v(r, h, m);
52
+ const s = n ? r.visibleIds : void 0, l = Y(e, t, s), o = v(l, h, m);
53
53
  I(o);
54
54
  },
55
- [t, i, n.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);
55
+ [t, n, r.visibleIds, v, h, m, I]
56
+ ), F = a(() => Z(t, p).length, [t, p]), j = a(() => z(t, p), [t, p]), b = F === 0, M = S(() => {
57
+ if (b) return;
58
+ const e = K(t, p), s = v(e, h, m);
59
59
  I(s);
60
- }, [g, t, p, v, h, m, I]), G = S((e) => {
60
+ }, [b, t, p, v, h, m, I]), G = S((e) => {
61
61
  w((s) => {
62
- const r = new Set(s);
63
- return r.has(e) ? r.delete(e) : r.add(e), r;
62
+ const l = new Set(s);
63
+ return l.has(e) ? l.delete(e) : l.add(e), l;
64
64
  });
65
65
  }, []), A = a(() => {
66
- const e = [], s = (r) => {
67
- (r === null ? t.rootIds : t.childrenMap.get(r) || []).forEach((c) => {
68
- if (i && !n.visibleIds.has(c))
66
+ const e = [], s = (l) => {
67
+ (l === null ? t.rootIds : t.childrenMap.get(l) || []).forEach((c) => {
68
+ if (n && !r.visibleIds.has(c))
69
69
  return;
70
70
  const x = t.items.get(c);
71
71
  x && (e.push({
72
72
  id: c,
73
73
  item: x,
74
- isMatched: n.matchedIds.has(c)
74
+ isMatched: r.matchedIds.has(c)
75
75
  }), x.hasChildren && C.has(c) && s(c));
76
76
  });
77
77
  };
78
78
  return s(null), e;
79
- }, [t, i, n.visibleIds, n.matchedIds, C]), J = S(
79
+ }, [t, n, r.visibleIds, r.matchedIds, C]), J = S(
80
80
  (e) => {
81
- if (!i) return null;
82
- const s = n.resultCounts.get(e);
81
+ if (!n) return null;
82
+ const s = r.resultCounts.get(e);
83
83
  return s === void 0 ? null : `${s} ${s === 1 ? "result" : "results"}`;
84
84
  },
85
- [i, n.resultCounts]
86
- ), k = t.items.size > 0, O = H && k && (!i || A.length > 0), L = i ? "Select all results" : "Select All";
87
- return /* @__PURE__ */ T("div", { className: b("flex flex-col border border-primary rounded-lg bg-primary overflow-hidden", D), children: [
88
- /* @__PURE__ */ l("div", { className: "border-b border-secondary p-2", children: /* @__PURE__ */ l(
89
- te,
85
+ [n, r.resultCounts]
86
+ ), k = t.items.size > 0, O = D && k && (!n || A.length > 0), H = n ? "Select all results" : "Select All";
87
+ return /* @__PURE__ */ T("div", { className: f("flex flex-col border border-primary rounded-lg bg-primary overflow-hidden", $), children: [
88
+ /* @__PURE__ */ i(
89
+ W,
90
90
  {
91
91
  size: d == "xs" ? "sm" : d,
92
92
  value: u,
93
93
  onChange: B,
94
- placeholder: $
94
+ placeholder: R
95
95
  }
96
- ) }),
96
+ ),
97
97
  O && /* @__PURE__ */ T(
98
98
  "div",
99
99
  {
100
- className: b(
100
+ className: f(
101
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"
102
+ b ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-secondary_subtle transition-colors"
103
103
  ),
104
104
  onClick: M,
105
- "aria-disabled": g,
105
+ "aria-disabled": b,
106
106
  children: [
107
- j === "indeterminate" ? /* @__PURE__ */ l(se, { name: "MinusSquare", className: "size-4 text-utility-brand-600" }) : /* @__PURE__ */ l(
107
+ j === "indeterminate" ? /* @__PURE__ */ i(se, { name: "MinusSquare", className: "size-4 text-utility-brand-600" }) : /* @__PURE__ */ i(
108
108
  "span",
109
109
  {
110
110
  onClick: (e) => e.stopPropagation(),
111
- children: /* @__PURE__ */ l(
112
- re,
111
+ children: /* @__PURE__ */ i(
112
+ le,
113
113
  {
114
114
  isSelected: j === "selected",
115
- isDisabled: g,
115
+ isDisabled: b,
116
116
  onChange: M,
117
- "aria-label": L
117
+ "aria-label": H
118
118
  }
119
119
  )
120
120
  }
121
121
  ),
122
- /* @__PURE__ */ l("span", { className: b("font-medium text-primary", y[d]), children: L })
122
+ /* @__PURE__ */ i("span", { className: f("font-medium text-primary", y[d]), children: H })
123
123
  ]
124
124
  }
125
125
  ),
126
- /* @__PURE__ */ l(
126
+ /* @__PURE__ */ i(
127
127
  "div",
128
128
  {
129
129
  className: "overflow-y-auto",
130
130
  style: { maxHeight: typeof N == "number" ? `${N}px` : N },
131
131
  role: "listbox",
132
132
  "aria-multiselectable": "true",
133
- children: k ? A.length === 0 ? /* @__PURE__ */ l("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No results found" }) : A.map(({ id: e, item: s, isMatched: r }) => {
134
- const o = s.depth === 0 ? J(e) : null, c = K(e, t), x = s.disabled === !0;
135
- return /* @__PURE__ */ l("div", { children: /* @__PURE__ */ T("div", { className: "flex items-center", children: [
136
- /* @__PURE__ */ l("div", { className: "flex-1", children: /* @__PURE__ */ l(
133
+ children: k ? A.length === 0 ? /* @__PURE__ */ i("div", { className: f("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No results found" }) : A.map(({ id: e, item: s, isMatched: l }) => {
134
+ const o = s.depth === 0 ? J(e) : null, c = ee(e, t), x = s.disabled === !0;
135
+ return /* @__PURE__ */ i("div", { children: /* @__PURE__ */ T("div", { className: "flex items-center", children: [
136
+ /* @__PURE__ */ i("div", { className: "flex-1", children: /* @__PURE__ */ i(
137
137
  U,
138
138
  {
139
139
  size: d,
140
140
  item: s,
141
141
  selectionState: c,
142
- isMatched: r,
142
+ isMatched: l,
143
143
  searchQuery: u,
144
144
  onToggle: _,
145
145
  isExpandable: s.hasChildren,
@@ -149,14 +149,14 @@ function le({
149
149
  childCountLabel: Q
150
150
  }
151
151
  ) }),
152
- o && /* @__PURE__ */ l("span", { className: b("text-tertiary pr-3 whitespace-nowrap", y[d]), children: o })
152
+ o && /* @__PURE__ */ i("span", { className: f("text-tertiary pr-3 whitespace-nowrap", y[d]), children: o })
153
153
  ] }) }, e);
154
- }) : /* @__PURE__ */ l("div", { className: b("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No items available" })
154
+ }) : /* @__PURE__ */ i("div", { className: f("flex items-center justify-center py-8 text-tertiary", y[d]), children: "No items available" })
155
155
  }
156
156
  )
157
157
  ] });
158
158
  }
159
- le.displayName = "HierarchicalSelect";
159
+ re.displayName = "HierarchicalSelect";
160
160
  export {
161
- le as HierarchicalSelect
161
+ re as HierarchicalSelect
162
162
  };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HierarchicalSearchInput
3
+ * The tree's header search: a borderless input on the panel's top edge, with a clear button.
4
+ * Frozen to platform-ui's base/hierarchical-select SearchInput; the Select SearchInput is a
5
+ * bordered field and renders a taller row with smaller text.
6
+ */
7
+ interface HierarchicalSearchInputProps {
8
+ size?: "xs" | "sm" | "md" | "lg";
9
+ value: string;
10
+ onChange: (value: string) => void;
11
+ placeholder?: string;
12
+ className?: string;
13
+ }
14
+ export declare const HierarchicalSearchInput: {
15
+ ({ value, onChange, placeholder, className, size, }: HierarchicalSearchInputProps): import("react/jsx-runtime").JSX.Element;
16
+ displayName: string;
17
+ };
18
+ export {};
19
+ //# sourceMappingURL=HierarchicalSearchInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HierarchicalSearchInput.d.ts","sourceRoot":"","sources":["../../../../src/primitives/hierarchical-select/components/HierarchicalSearchInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,UAAU,4BAA4B;IAClC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAgBD,eAAO,MAAM,uBAAuB;yDAMjC,4BAA4B;;CAqC9B,CAAC"}
@@ -0,0 +1,60 @@
1
+ import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
+ import { useCallback as s } from "react";
3
+ import { SearchMd as x, XClose as h } from "@untitledui/icons";
4
+ import { cx as c } from "../../../utils/cn.js";
5
+ const l = {
6
+ xs: 12,
7
+ sm: 14,
8
+ md: 16,
9
+ lg: 18
10
+ }, u = {
11
+ xs: "text-xs",
12
+ sm: "text-sm",
13
+ md: "text-md",
14
+ lg: "text-lg"
15
+ }, b = ({
16
+ value: a,
17
+ onChange: e,
18
+ placeholder: o = "Search...",
19
+ className: n,
20
+ size: r = "md"
21
+ }) => {
22
+ const i = s(
23
+ (p) => {
24
+ e(p.target.value);
25
+ },
26
+ [e]
27
+ ), m = s(() => {
28
+ e("");
29
+ }, [e]);
30
+ return /* @__PURE__ */ d("div", { className: c("flex items-center gap-2 px-3 py-2 border-b border-secondary", n), children: [
31
+ /* @__PURE__ */ t(x, { size: l[r], className: "text-tertiary shrink-0" }),
32
+ /* @__PURE__ */ t(
33
+ "input",
34
+ {
35
+ type: "text",
36
+ value: a,
37
+ onChange: i,
38
+ placeholder: o,
39
+ className: c(
40
+ "flex-1 bg-transparent outline-none placeholder:text-placeholder text-primary",
41
+ u[r]
42
+ )
43
+ }
44
+ ),
45
+ a && /* @__PURE__ */ t(
46
+ "button",
47
+ {
48
+ type: "button",
49
+ onClick: m,
50
+ className: "p-0.5 rounded hover:bg-secondary_subtle transition-colors",
51
+ "aria-label": "Clear search",
52
+ children: /* @__PURE__ */ t(h, { size: l[r], className: "text-tertiary" })
53
+ }
54
+ )
55
+ ] });
56
+ };
57
+ b.displayName = "HierarchicalSearchInput";
58
+ export {
59
+ b as HierarchicalSearchInput
60
+ };