@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.
- package/dist/_virtual/index.js +2 -3
- package/dist/_virtual/index2.js +3 -2
- package/dist/code-editor/chrome.d.ts +3 -3
- package/dist/code-editor/chrome.d.ts.map +1 -1
- package/dist/code-editor/chrome.js +6 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.d.ts +14 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.js +246 -77
- package/dist/patterns/confirm-dialog/index.d.ts +1 -1
- package/dist/patterns/confirm-dialog/index.d.ts.map +1 -1
- package/dist/primitives/hierarchical-select/HierarchicalSelect.d.ts.map +1 -1
- package/dist/primitives/hierarchical-select/HierarchicalSelect.js +65 -65
- package/dist/primitives/hierarchical-select/components/HierarchicalSearchInput.d.ts +19 -0
- package/dist/primitives/hierarchical-select/components/HierarchicalSearchInput.d.ts.map +1 -0
- package/dist/primitives/hierarchical-select/components/HierarchicalSearchInput.js +60 -0
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import { jsxs as T, jsx as
|
|
2
|
-
import { useState as
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
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
|
|
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
|
|
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:
|
|
23
|
+
searchPlaceholder: R = "Search objects or fields",
|
|
24
24
|
maxHeight: N = 400,
|
|
25
|
-
className:
|
|
26
|
-
showSelectAll:
|
|
25
|
+
className: $,
|
|
26
|
+
showSelectAll: D = !0,
|
|
27
27
|
childCountLabel: Q
|
|
28
28
|
}) {
|
|
29
|
-
const [u, V] =
|
|
30
|
-
|
|
31
|
-
w(new Set(
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
38
|
-
let o = t.parentMap.get(
|
|
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
|
-
}, [
|
|
43
|
+
}, [n, r.visibleIds, t]);
|
|
44
44
|
const B = S(
|
|
45
45
|
(e) => {
|
|
46
|
-
const
|
|
47
|
-
V(e),
|
|
46
|
+
const l = u.trim().length > 0 && e.trim().length === 0;
|
|
47
|
+
V(e), l && w(new Set(g));
|
|
48
48
|
},
|
|
49
|
-
[u,
|
|
50
|
-
), p = a(() =>
|
|
49
|
+
[u, g]
|
|
50
|
+
), p = a(() => n ? r.visibleIds : void 0, [n, r.visibleIds]), _ = S(
|
|
51
51
|
(e) => {
|
|
52
|
-
const s =
|
|
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,
|
|
56
|
-
), F = a(() =>
|
|
57
|
-
if (
|
|
58
|
-
const e =
|
|
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
|
-
}, [
|
|
60
|
+
}, [b, t, p, v, h, m, I]), G = S((e) => {
|
|
61
61
|
w((s) => {
|
|
62
|
-
const
|
|
63
|
-
return
|
|
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 = (
|
|
67
|
-
(
|
|
68
|
-
if (
|
|
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:
|
|
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,
|
|
79
|
+
}, [t, n, r.visibleIds, r.matchedIds, C]), J = S(
|
|
80
80
|
(e) => {
|
|
81
|
-
if (!
|
|
82
|
-
const s =
|
|
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
|
-
[
|
|
86
|
-
), k = t.items.size > 0, O =
|
|
87
|
-
return /* @__PURE__ */ T("div", { className:
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
|
|
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:
|
|
100
|
+
className: f(
|
|
101
101
|
"flex shrink-0 items-center gap-2 border-b border-secondary px-3 py-2.5",
|
|
102
|
-
|
|
102
|
+
b ? "cursor-not-allowed opacity-50" : "cursor-pointer hover:bg-secondary_subtle transition-colors"
|
|
103
103
|
),
|
|
104
104
|
onClick: M,
|
|
105
|
-
"aria-disabled":
|
|
105
|
+
"aria-disabled": b,
|
|
106
106
|
children: [
|
|
107
|
-
j === "indeterminate" ? /* @__PURE__ */
|
|
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__ */
|
|
112
|
-
|
|
111
|
+
children: /* @__PURE__ */ i(
|
|
112
|
+
le,
|
|
113
113
|
{
|
|
114
114
|
isSelected: j === "selected",
|
|
115
|
-
isDisabled:
|
|
115
|
+
isDisabled: b,
|
|
116
116
|
onChange: M,
|
|
117
|
-
"aria-label":
|
|
117
|
+
"aria-label": H
|
|
118
118
|
}
|
|
119
119
|
)
|
|
120
120
|
}
|
|
121
121
|
),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ i("span", { className: f("font-medium text-primary", y[d]), children: H })
|
|
123
123
|
]
|
|
124
124
|
}
|
|
125
125
|
),
|
|
126
|
-
/* @__PURE__ */
|
|
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__ */
|
|
134
|
-
const o = s.depth === 0 ? J(e) : null, c =
|
|
135
|
-
return /* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
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:
|
|
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__ */
|
|
152
|
+
o && /* @__PURE__ */ i("span", { className: f("text-tertiary pr-3 whitespace-nowrap", y[d]), children: o })
|
|
153
153
|
] }) }, e);
|
|
154
|
-
}) : /* @__PURE__ */
|
|
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
|
-
|
|
159
|
+
re.displayName = "HierarchicalSelect";
|
|
160
160
|
export {
|
|
161
|
-
|
|
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
|
+
};
|