@pibit.ai/cure-design-system 0.6.1 → 0.6.3
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/applications/progressive-loading-indicator/index.d.ts +2 -0
- package/dist/applications/progressive-loading-indicator/index.d.ts.map +1 -0
- package/dist/applications/progressive-loading-indicator/progressive-loading-indicator.d.ts +26 -0
- package/dist/applications/progressive-loading-indicator/progressive-loading-indicator.d.ts.map +1 -0
- package/dist/applications/progressive-loading-indicator/progressive-loading-indicator.js +77 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +124 -122
- package/dist/node_modules/framer-motion/dist/es/utils/reduced-motion/use-reduced-motion.js +12 -0
- package/dist/primitives/button/button.d.ts.map +1 -1
- package/dist/primitives/button/button.js +3 -4
- package/dist/primitives/select/multi-select.d.ts.map +1 -1
- package/dist/primitives/select/multi-select.js +428 -387
- package/dist/primitives/select/searchable-select.d.ts +3 -1
- package/dist/primitives/select/searchable-select.d.ts.map +1 -1
- package/dist/primitives/select/searchable-select.js +254 -229
- package/dist/primitives/select/select-item.d.ts.map +1 -1
- package/dist/primitives/select/select-item.js +19 -18
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -54,6 +54,8 @@ export interface SearchableSelectProps extends Omit<AriaSelectProps<SelectItemTy
|
|
|
54
54
|
endAdornment?: ReactNode;
|
|
55
55
|
/** Rendered before the selected label in the trigger. */
|
|
56
56
|
leadingAdornment?: ReactNode;
|
|
57
|
+
/** When true, the trigger shows the selected item's supporting text beside the label, as the options do. */
|
|
58
|
+
inlineSupportingText?: boolean;
|
|
57
59
|
}
|
|
58
|
-
export declare const SearchableSelect: ({ placeholder, placeholderIcon, size, items, label, hint, tooltip, className, footer, textStyles, popoverClassName, onSearchChange, onSelectionChange, isLoading, isClearable, openOnClear, isDeselectable, searchPlaceholder, selectedDisplayValue, renderItem, endAdornment, leadingAdornment, shouldFilterItems, filterItem, ...rest }: SearchableSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
export declare const SearchableSelect: ({ placeholder, placeholderIcon, size, items, label, hint, tooltip, className, footer, textStyles, popoverClassName, onSearchChange, onSelectionChange, isLoading, isClearable, openOnClear, isDeselectable, searchPlaceholder, selectedDisplayValue, renderItem, endAdornment, leadingAdornment, inlineSupportingText, shouldFilterItems, filterItem, ...rest }: SearchableSelectProps) => import("react/jsx-runtime").JSX.Element;
|
|
59
61
|
//# sourceMappingURL=searchable-select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"searchable-select.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/searchable-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1D,OAAO,KAAK,EAEV,WAAW,IAAI,eAAe,EAC/B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAwBzB,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,eAAe,CAAC,cAAc,CAAC,EAC/B,UAAU,GAAG,OAAO,GAAG,mBAAmB,CAC3C;IACC,mGAAmG;IACnG,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9D,mDAAmD;IACnD,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,eAAe,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IACjC,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACjD,2GAA2G;IAC3G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2GAA2G;IAC3G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,CAAC;IACjD,6DAA6D;IAC7D,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"searchable-select.d.ts","sourceRoot":"","sources":["../../../src/primitives/select/searchable-select.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAG1D,OAAO,KAAK,EAEV,WAAW,IAAI,eAAe,EAC/B,MAAM,uBAAuB,CAAC;AAW/B,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AAwBzB,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,eAAe,CAAC,cAAc,CAAC,EAC/B,UAAU,GAAG,OAAO,GAAG,mBAAmB,CAC3C;IACC,mGAAmG;IACnG,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAC9D,mDAAmD;IACnD,cAAc,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4BAA4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wCAAwC;IACxC,eAAe,CAAC,EAAE,EAAE,GAAG,SAAS,CAAC;IACjC,gCAAgC;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACjD,2GAA2G;IAC3G,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2GAA2G;IAC3G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mCAAmC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,8CAA8C;IAC9C,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,KAAK,SAAS,CAAC;IACjD,6DAA6D;IAC7D,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,SAAS,CAAC;IAC7B,4GAA4G;IAC5G,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAiPD,eAAO,MAAM,gBAAgB,GAAI,iWA2B9B,qBAAqB,4CAsQvB,CAAC"}
|
|
@@ -1,162 +1,185 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { Select as
|
|
5
|
-
import { Avatar as
|
|
6
|
-
import { Popover as
|
|
7
|
-
import { SelectItem as
|
|
8
|
-
import { SelectContext as ye, fontSizes as
|
|
9
|
-
import { HintText as
|
|
10
|
-
import { Label as
|
|
11
|
-
import { cx as
|
|
12
|
-
import { isReactComponent as
|
|
13
|
-
import { LoadingIndicator as
|
|
14
|
-
import
|
|
15
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as h, Fragment as _ } from "react/jsx-runtime";
|
|
2
|
+
import { useState as Y, useRef as Z, useCallback as R, useMemo as $, isValidElement as pe } from "react";
|
|
3
|
+
import { ChevronDown as I, XClose as me } from "@untitledui/icons";
|
|
4
|
+
import { Select as xe, ListBox as he, Button as be, SelectValue as ge, ButtonContext as ve } from "react-aria-components";
|
|
5
|
+
import { Avatar as we } from "../avatar/avatar.js";
|
|
6
|
+
import { Popover as Ne } from "./popover.js";
|
|
7
|
+
import { SelectItem as ke } from "./select-item.js";
|
|
8
|
+
import { SelectContext as ye, fontSizes as k, sizes as Pe } from "./select-shared.js";
|
|
9
|
+
import { HintText as Te } from "../input/hint-text.js";
|
|
10
|
+
import { Label as qe } from "../input/label.js";
|
|
11
|
+
import { cx as o } from "../../utils/cn.js";
|
|
12
|
+
import { isReactComponent as Be } from "../../utils/is-react-component.js";
|
|
13
|
+
import { LoadingIndicator as Ke } from "../../applications/loading-indicator/loading-indicator.js";
|
|
14
|
+
import Re from "./SearchInput.js";
|
|
15
|
+
const De = {
|
|
16
16
|
sm: "rounded-md",
|
|
17
17
|
md: "rounded-md",
|
|
18
18
|
lg: "rounded-lg"
|
|
19
|
-
},
|
|
19
|
+
}, Se = {
|
|
20
20
|
sm: "text-xs",
|
|
21
21
|
md: "text-sm",
|
|
22
22
|
lg: "text-md"
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
const u = String(
|
|
27
|
-
return u.includes(
|
|
28
|
-
},
|
|
23
|
+
}, je = "relative flex w-full cursor-pointer items-center bg-primary ring-1 outline-hidden transition duration-100 ease-linear ring-inset", Oe = (m, y) => {
|
|
24
|
+
const i = y.trim().toLowerCase();
|
|
25
|
+
if (!i) return !0;
|
|
26
|
+
const u = String(m.label ?? "").toLowerCase(), b = String(m.supportingText ?? "").toLowerCase(), l = String(m.id ?? "").toLowerCase();
|
|
27
|
+
return u.includes(i) || b.includes(i) || l.includes(i);
|
|
28
|
+
}, Ue = {
|
|
29
29
|
sm: "size-4",
|
|
30
30
|
md: "size-4",
|
|
31
31
|
lg: "size-5"
|
|
32
|
-
},
|
|
33
|
-
isOpen:
|
|
34
|
-
isFocused:
|
|
35
|
-
isDisabled:
|
|
32
|
+
}, Fe = ({
|
|
33
|
+
isOpen: m,
|
|
34
|
+
isFocused: y,
|
|
35
|
+
isDisabled: i,
|
|
36
36
|
isInvalid: u,
|
|
37
|
-
isLoading:
|
|
38
|
-
size:
|
|
39
|
-
placeholder:
|
|
40
|
-
placeholderIcon:
|
|
41
|
-
textStyles:
|
|
42
|
-
selectedDisplayValue:
|
|
43
|
-
isClearable:
|
|
44
|
-
onClear:
|
|
45
|
-
hasSelection:
|
|
37
|
+
isLoading: b,
|
|
38
|
+
size: l = "sm",
|
|
39
|
+
placeholder: V,
|
|
40
|
+
placeholderIcon: P,
|
|
41
|
+
textStyles: g,
|
|
42
|
+
selectedDisplayValue: T,
|
|
43
|
+
isClearable: z = !1,
|
|
44
|
+
onClear: a,
|
|
45
|
+
hasSelection: s = !1,
|
|
46
46
|
endAdornment: d,
|
|
47
|
-
triggerSelectedItem:
|
|
48
|
-
hasSupportingText:
|
|
49
|
-
leadingAdornment:
|
|
47
|
+
triggerSelectedItem: D = null,
|
|
48
|
+
hasSupportingText: q = !1,
|
|
49
|
+
leadingAdornment: x,
|
|
50
|
+
inlineSupportingText: M = !1
|
|
50
51
|
}) => {
|
|
51
|
-
const
|
|
52
|
-
return /* @__PURE__ */
|
|
53
|
-
|
|
52
|
+
const S = z && s && !i && a;
|
|
53
|
+
return /* @__PURE__ */ e(
|
|
54
|
+
be,
|
|
54
55
|
{
|
|
55
|
-
className:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
u ? "ring-error" :
|
|
59
|
-
|
|
56
|
+
className: o(
|
|
57
|
+
je,
|
|
58
|
+
De[l],
|
|
59
|
+
u ? "ring-error" : y || m ? "ring-brand" : "ring-secondary",
|
|
60
|
+
i && "cursor-not-allowed bg-disabled_subtle text-disabled"
|
|
60
61
|
),
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
-
|
|
62
|
+
children: /* @__PURE__ */ e(
|
|
63
|
+
ge,
|
|
63
64
|
{
|
|
64
|
-
className:
|
|
65
|
+
className: o(
|
|
65
66
|
"flex h-max w-full items-center justify-start gap-2 text-left align-middle",
|
|
66
|
-
|
|
67
|
+
q ? "px-2 pt-3 pb-3" : o("truncate", Pe[l].root),
|
|
67
68
|
"*:data-icon:size-5 *:data-icon:shrink-0 *:data-icon:text-fg-quaternary in-disabled:*:data-icon:text-fg-disabled"
|
|
68
69
|
),
|
|
69
|
-
children: (
|
|
70
|
-
const
|
|
71
|
-
return
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
70
|
+
children: (j) => {
|
|
71
|
+
const r = D ?? j.selectedItem, v = (r == null ? void 0 : r.icon) || P, f = !!r, w = !f && !!T;
|
|
72
|
+
return b && !f && !w ? /* @__PURE__ */ h(_, { children: [
|
|
73
|
+
/* @__PURE__ */ e("div", { className: "h-3.5 min-w-0 flex-1 animate-pulse rounded bg-secondary" }),
|
|
74
|
+
/* @__PURE__ */ e(
|
|
75
|
+
I,
|
|
75
76
|
{
|
|
76
77
|
"aria-hidden": "true",
|
|
77
|
-
className:
|
|
78
|
+
className: o(
|
|
78
79
|
"shrink-0 text-fg-quaternary",
|
|
79
|
-
|
|
80
|
+
l === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
|
|
80
81
|
)
|
|
81
82
|
}
|
|
82
83
|
)
|
|
83
|
-
] }) : /* @__PURE__ */
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
] }) : /* @__PURE__ */ h(_, { children: [
|
|
85
|
+
r != null && r.avatarUrl ? /* @__PURE__ */ e(
|
|
86
|
+
we,
|
|
86
87
|
{
|
|
87
88
|
size: "xs",
|
|
88
|
-
src:
|
|
89
|
-
alt:
|
|
89
|
+
src: r.avatarUrl,
|
|
90
|
+
alt: r.label
|
|
90
91
|
}
|
|
91
|
-
) :
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/* @__PURE__ */
|
|
92
|
+
) : Be(v) ? /* @__PURE__ */ e(v, { "data-icon": !0, "aria-hidden": "true" }) : pe(v) ? v : null,
|
|
93
|
+
x && (f || w) ? /* @__PURE__ */ e("div", { className: "flex shrink-0 items-center self-center", children: x }) : null,
|
|
94
|
+
f && M ? /* @__PURE__ */ h("section", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
95
|
+
/* @__PURE__ */ e(
|
|
96
|
+
"p",
|
|
97
|
+
{
|
|
98
|
+
className: o(
|
|
99
|
+
"shrink-0 truncate font-medium text-primary",
|
|
100
|
+
k[l],
|
|
101
|
+
g
|
|
102
|
+
),
|
|
103
|
+
children: r == null ? void 0 : r.label
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
(r == null ? void 0 : r.supportingText) && /* @__PURE__ */ e(
|
|
95
107
|
"p",
|
|
96
108
|
{
|
|
97
|
-
className:
|
|
109
|
+
className: o(
|
|
110
|
+
"min-w-0 truncate text-tertiary",
|
|
111
|
+
k[l]
|
|
112
|
+
),
|
|
113
|
+
children: r == null ? void 0 : r.supportingText
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
] }) : f ? /* @__PURE__ */ h("section", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
117
|
+
/* @__PURE__ */ e(
|
|
118
|
+
"p",
|
|
119
|
+
{
|
|
120
|
+
className: o(
|
|
98
121
|
"truncate font-medium text-primary",
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
k[l],
|
|
123
|
+
g
|
|
101
124
|
),
|
|
102
|
-
children:
|
|
125
|
+
children: r == null ? void 0 : r.label
|
|
103
126
|
}
|
|
104
127
|
),
|
|
105
|
-
(
|
|
128
|
+
(r == null ? void 0 : r.supportingText) && /* @__PURE__ */ e(
|
|
106
129
|
"p",
|
|
107
130
|
{
|
|
108
|
-
className:
|
|
131
|
+
className: o(
|
|
109
132
|
"truncate text-xs",
|
|
110
|
-
(
|
|
133
|
+
(r == null ? void 0 : r.supportingTextClassName) ?? "text-[#818792]"
|
|
111
134
|
),
|
|
112
|
-
children:
|
|
135
|
+
children: r == null ? void 0 : r.supportingText
|
|
113
136
|
}
|
|
114
137
|
)
|
|
115
|
-
] }) :
|
|
138
|
+
] }) : w ? /* @__PURE__ */ e("section", { className: "flex min-w-0 flex-1 gap-2 truncate", children: /* @__PURE__ */ e(
|
|
116
139
|
"p",
|
|
117
140
|
{
|
|
118
|
-
className:
|
|
141
|
+
className: o(
|
|
119
142
|
"truncate font-medium text-primary",
|
|
120
|
-
|
|
121
|
-
|
|
143
|
+
k[l],
|
|
144
|
+
g
|
|
122
145
|
),
|
|
123
|
-
children:
|
|
146
|
+
children: T
|
|
124
147
|
}
|
|
125
|
-
) }) : /* @__PURE__ */
|
|
148
|
+
) }) : /* @__PURE__ */ e(
|
|
126
149
|
"p",
|
|
127
150
|
{
|
|
128
|
-
className:
|
|
151
|
+
className: o(
|
|
129
152
|
"min-w-0 flex-1 text-placeholder_subtle",
|
|
130
|
-
|
|
131
|
-
|
|
153
|
+
k[l],
|
|
154
|
+
i && "text-disabled"
|
|
132
155
|
),
|
|
133
|
-
children:
|
|
156
|
+
children: V
|
|
134
157
|
}
|
|
135
158
|
),
|
|
136
|
-
d ? /* @__PURE__ */
|
|
137
|
-
|
|
159
|
+
d ? /* @__PURE__ */ e(ve.Provider, { value: null, children: /* @__PURE__ */ e("div", { className: "flex shrink-0 items-center self-center", children: d }) }) : null,
|
|
160
|
+
S ? /* @__PURE__ */ e(
|
|
138
161
|
"button",
|
|
139
162
|
{
|
|
140
163
|
type: "button",
|
|
141
164
|
tabIndex: -1,
|
|
142
165
|
"aria-label": "Clear selection",
|
|
143
|
-
onPointerDown: (
|
|
144
|
-
|
|
166
|
+
onPointerDown: (N) => {
|
|
167
|
+
N.stopPropagation();
|
|
145
168
|
},
|
|
146
|
-
onClick: (
|
|
147
|
-
|
|
169
|
+
onClick: (N) => {
|
|
170
|
+
N.preventDefault(), N.stopPropagation(), a == null || a();
|
|
148
171
|
},
|
|
149
172
|
className: "flex shrink-0 cursor-pointer items-center justify-center rounded-md p-1 text-fg-quaternary outline-hidden transition hover:bg-primary_hover focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-focus-ring",
|
|
150
|
-
children: /* @__PURE__ */
|
|
173
|
+
children: /* @__PURE__ */ e(me, { "aria-hidden": !0, className: Ue[l] })
|
|
151
174
|
}
|
|
152
175
|
) : null,
|
|
153
|
-
/* @__PURE__ */
|
|
154
|
-
|
|
176
|
+
/* @__PURE__ */ e(
|
|
177
|
+
I,
|
|
155
178
|
{
|
|
156
179
|
"aria-hidden": "true",
|
|
157
|
-
className:
|
|
180
|
+
className: o(
|
|
158
181
|
"shrink-0 text-fg-quaternary",
|
|
159
|
-
|
|
182
|
+
l === "sm" ? "size-4 stroke-[2.5px]" : "size-5"
|
|
160
183
|
)
|
|
161
184
|
}
|
|
162
185
|
)
|
|
@@ -166,190 +189,192 @@ const Ke = {
|
|
|
166
189
|
)
|
|
167
190
|
}
|
|
168
191
|
);
|
|
169
|
-
},
|
|
170
|
-
placeholder:
|
|
171
|
-
placeholderIcon:
|
|
172
|
-
size:
|
|
192
|
+
}, Ze = ({
|
|
193
|
+
placeholder: m = "Select",
|
|
194
|
+
placeholderIcon: y,
|
|
195
|
+
size: i = "sm",
|
|
173
196
|
items: u,
|
|
174
|
-
label:
|
|
175
|
-
hint:
|
|
176
|
-
tooltip:
|
|
177
|
-
className:
|
|
178
|
-
footer:
|
|
179
|
-
textStyles:
|
|
180
|
-
popoverClassName:
|
|
181
|
-
onSearchChange:
|
|
182
|
-
onSelectionChange:
|
|
197
|
+
label: b,
|
|
198
|
+
hint: l,
|
|
199
|
+
tooltip: V,
|
|
200
|
+
className: P,
|
|
201
|
+
footer: g,
|
|
202
|
+
textStyles: T,
|
|
203
|
+
popoverClassName: z,
|
|
204
|
+
onSearchChange: a,
|
|
205
|
+
onSelectionChange: s,
|
|
183
206
|
isLoading: d = !1,
|
|
184
|
-
isClearable:
|
|
185
|
-
openOnClear:
|
|
186
|
-
isDeselectable:
|
|
187
|
-
searchPlaceholder:
|
|
188
|
-
selectedDisplayValue:
|
|
189
|
-
renderItem:
|
|
190
|
-
endAdornment:
|
|
191
|
-
leadingAdornment:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
207
|
+
isClearable: D = !1,
|
|
208
|
+
openOnClear: q = !1,
|
|
209
|
+
isDeselectable: x = !1,
|
|
210
|
+
searchPlaceholder: M = "Search...",
|
|
211
|
+
selectedDisplayValue: S,
|
|
212
|
+
renderItem: j,
|
|
213
|
+
endAdornment: r,
|
|
214
|
+
leadingAdornment: v,
|
|
215
|
+
inlineSupportingText: f = !1,
|
|
216
|
+
shouldFilterItems: w = !0,
|
|
217
|
+
filterItem: N,
|
|
218
|
+
...C
|
|
195
219
|
}) => {
|
|
196
|
-
const [
|
|
197
|
-
selectedKey:
|
|
198
|
-
isOpen:
|
|
199
|
-
onOpenChange:
|
|
200
|
-
...
|
|
201
|
-
} =
|
|
202
|
-
(
|
|
203
|
-
|
|
220
|
+
const [A, W] = Y(""), [ee, re] = Y(!1), E = Z(!1), X = Z(null), {
|
|
221
|
+
selectedKey: H,
|
|
222
|
+
isOpen: G,
|
|
223
|
+
onOpenChange: O,
|
|
224
|
+
...te
|
|
225
|
+
} = C, c = H == null || String(H) === "" ? null : H, U = G !== void 0, F = q || U, ne = U ? G : F ? ee : void 0, le = R(
|
|
226
|
+
(n) => {
|
|
227
|
+
W(n), a == null || a(n);
|
|
204
228
|
},
|
|
205
|
-
[
|
|
206
|
-
),
|
|
207
|
-
if (!
|
|
208
|
-
const
|
|
209
|
-
return
|
|
210
|
-
}, [
|
|
211
|
-
var
|
|
212
|
-
if (
|
|
213
|
-
const
|
|
229
|
+
[a]
|
|
230
|
+
), J = N ?? Oe, B = $(() => {
|
|
231
|
+
if (!w) return u;
|
|
232
|
+
const n = A.trim();
|
|
233
|
+
return n ? u.filter((t) => J(t, n)) : u;
|
|
234
|
+
}, [J, A, u, w]), se = (n) => {
|
|
235
|
+
var Q;
|
|
236
|
+
if (n.key !== "ArrowDown" && n.key !== "ArrowUp" || n.nativeEvent.isComposing || !(n.target instanceof HTMLInputElement) || (n.preventDefault(), n.stopPropagation(), d || B.length === 0)) return;
|
|
237
|
+
const t = (Q = X.current) == null ? void 0 : Q.querySelectorAll(
|
|
214
238
|
'[role="option"]:not([aria-disabled="true"])'
|
|
215
|
-
),
|
|
216
|
-
|
|
217
|
-
},
|
|
218
|
-
(
|
|
219
|
-
!
|
|
239
|
+
), p = n.key === "ArrowDown" ? t == null ? void 0 : t[0] : t == null ? void 0 : t[t.length - 1];
|
|
240
|
+
p == null || p.focus({ preventScroll: !0 }), p == null || p.scrollIntoView({ block: "nearest" });
|
|
241
|
+
}, K = R(
|
|
242
|
+
(n) => {
|
|
243
|
+
!U && F && re(n), n || (W(""), a == null || a("")), O == null || O(n);
|
|
220
244
|
},
|
|
221
|
-
[
|
|
222
|
-
),
|
|
223
|
-
|
|
224
|
-
}, [
|
|
225
|
-
!
|
|
226
|
-
|
|
245
|
+
[U, F, O, a]
|
|
246
|
+
), oe = R(() => {
|
|
247
|
+
s == null || s(null), q && K(!0);
|
|
248
|
+
}, [q, s, K]), ie = R(() => {
|
|
249
|
+
!x || c == null || (E.current = !0, s == null || s(null), K(!1), queueMicrotask(() => {
|
|
250
|
+
E.current = !1;
|
|
227
251
|
}));
|
|
228
|
-
}, [
|
|
229
|
-
(
|
|
230
|
-
if (
|
|
231
|
-
const
|
|
232
|
-
|
|
252
|
+
}, [K, x, s, c]), ae = R(
|
|
253
|
+
(n) => {
|
|
254
|
+
if (E.current) return;
|
|
255
|
+
const t = n == null || String(n) === "" ? null : String(n), p = c == null || String(c) === "" ? null : String(c);
|
|
256
|
+
t !== p && (s == null || s(t));
|
|
233
257
|
},
|
|
234
|
-
[
|
|
235
|
-
),
|
|
236
|
-
() => c == null ? null : u.find((
|
|
258
|
+
[s, c]
|
|
259
|
+
), ce = c != null || !!S, L = $(
|
|
260
|
+
() => c == null ? null : u.find((n) => String(n.id) === String(c)) ?? null,
|
|
237
261
|
[u, c]
|
|
238
|
-
),
|
|
239
|
-
return /* @__PURE__ */
|
|
262
|
+
), ue = !f && !!(L != null && L.supportingText), de = [{ id: "none", label: "none" }], fe = B.length > 0 ? B : de;
|
|
263
|
+
return /* @__PURE__ */ e(
|
|
240
264
|
ye.Provider,
|
|
241
265
|
{
|
|
242
266
|
value: {
|
|
243
|
-
size:
|
|
244
|
-
isDeselectable:
|
|
267
|
+
size: i,
|
|
268
|
+
isDeselectable: x,
|
|
245
269
|
selectedKey: c,
|
|
246
|
-
onReselectCurrent:
|
|
270
|
+
onReselectCurrent: x ? ie : void 0
|
|
247
271
|
},
|
|
248
|
-
children: /* @__PURE__ */
|
|
249
|
-
|
|
272
|
+
children: /* @__PURE__ */ e(
|
|
273
|
+
xe,
|
|
250
274
|
{
|
|
251
|
-
...
|
|
275
|
+
...te,
|
|
252
276
|
selectedKey: c,
|
|
253
|
-
...
|
|
254
|
-
onOpenChange:
|
|
255
|
-
onSelectionChange:
|
|
256
|
-
className: (
|
|
277
|
+
...F ? { isOpen: ne } : {},
|
|
278
|
+
onOpenChange: K,
|
|
279
|
+
onSelectionChange: ae,
|
|
280
|
+
className: (n) => o(
|
|
257
281
|
"flex flex-col gap-1.5",
|
|
258
|
-
typeof
|
|
282
|
+
typeof P == "function" ? P(n) : P
|
|
259
283
|
),
|
|
260
|
-
children: (
|
|
261
|
-
|
|
262
|
-
|
|
284
|
+
children: (n) => /* @__PURE__ */ h(_, { children: [
|
|
285
|
+
b && /* @__PURE__ */ e(
|
|
286
|
+
qe,
|
|
263
287
|
{
|
|
264
|
-
isRequired:
|
|
265
|
-
tooltip:
|
|
266
|
-
className:
|
|
267
|
-
children:
|
|
288
|
+
isRequired: n.isRequired,
|
|
289
|
+
tooltip: V,
|
|
290
|
+
className: Se[i],
|
|
291
|
+
children: b
|
|
268
292
|
}
|
|
269
293
|
),
|
|
270
|
-
/* @__PURE__ */
|
|
271
|
-
|
|
294
|
+
/* @__PURE__ */ e(
|
|
295
|
+
Fe,
|
|
272
296
|
{
|
|
273
|
-
...
|
|
274
|
-
size:
|
|
297
|
+
...n,
|
|
298
|
+
size: i,
|
|
275
299
|
isLoading: d,
|
|
276
|
-
placeholder:
|
|
277
|
-
placeholderIcon:
|
|
278
|
-
textStyles:
|
|
279
|
-
selectedDisplayValue:
|
|
280
|
-
isClearable:
|
|
281
|
-
hasSelection:
|
|
282
|
-
hasSupportingText:
|
|
283
|
-
triggerSelectedItem:
|
|
284
|
-
leadingAdornment:
|
|
285
|
-
|
|
286
|
-
|
|
300
|
+
placeholder: m,
|
|
301
|
+
placeholderIcon: y,
|
|
302
|
+
textStyles: T,
|
|
303
|
+
selectedDisplayValue: S,
|
|
304
|
+
isClearable: D,
|
|
305
|
+
hasSelection: ce,
|
|
306
|
+
hasSupportingText: ue,
|
|
307
|
+
triggerSelectedItem: L,
|
|
308
|
+
leadingAdornment: v,
|
|
309
|
+
inlineSupportingText: f,
|
|
310
|
+
onClear: D && s ? oe : void 0,
|
|
311
|
+
endAdornment: r
|
|
287
312
|
}
|
|
288
313
|
),
|
|
289
|
-
/* @__PURE__ */
|
|
290
|
-
|
|
314
|
+
/* @__PURE__ */ h(
|
|
315
|
+
Ne,
|
|
291
316
|
{
|
|
292
|
-
size:
|
|
293
|
-
className:
|
|
317
|
+
size: i,
|
|
318
|
+
className: o("flex flex-col overflow-hidden", z),
|
|
294
319
|
children: [
|
|
295
|
-
/* @__PURE__ */
|
|
320
|
+
/* @__PURE__ */ e(
|
|
296
321
|
"div",
|
|
297
322
|
{
|
|
298
323
|
className: "z-10 shrink-0 border-b border-tertiary bg-primary p-1.5",
|
|
299
|
-
onMouseDown: (
|
|
300
|
-
onPointerDown: (
|
|
301
|
-
onClick: (
|
|
302
|
-
onKeyDownCapture:
|
|
303
|
-
children: /* @__PURE__ */
|
|
304
|
-
|
|
324
|
+
onMouseDown: (t) => t.stopPropagation(),
|
|
325
|
+
onPointerDown: (t) => t.stopPropagation(),
|
|
326
|
+
onClick: (t) => t.stopPropagation(),
|
|
327
|
+
onKeyDownCapture: se,
|
|
328
|
+
children: /* @__PURE__ */ e(
|
|
329
|
+
Re,
|
|
305
330
|
{
|
|
306
331
|
size: "sm",
|
|
307
|
-
placeholder:
|
|
308
|
-
value:
|
|
309
|
-
onChange: (
|
|
310
|
-
onKeyDown: (
|
|
332
|
+
placeholder: M,
|
|
333
|
+
value: A,
|
|
334
|
+
onChange: (t) => le(t),
|
|
335
|
+
onKeyDown: (t) => t.stopPropagation(),
|
|
311
336
|
className: "w-full ring-0 outline-hidden bg-secondary rounded-lg",
|
|
312
337
|
autoFocus: !0
|
|
313
338
|
}
|
|
314
339
|
)
|
|
315
340
|
}
|
|
316
341
|
),
|
|
317
|
-
/* @__PURE__ */
|
|
318
|
-
d && /* @__PURE__ */
|
|
319
|
-
!d &&
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
|
|
342
|
+
/* @__PURE__ */ h("div", { className: "flex min-h-0 flex-1 flex-col overflow-hidden", children: [
|
|
343
|
+
d && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e(Ke, { size: "xs", type: "line-simple" }) }),
|
|
344
|
+
!d && B.length === 0 && /* @__PURE__ */ e("div", { className: "flex items-center justify-center py-6", children: /* @__PURE__ */ e("p", { className: o("text-tertiary", k[i]), children: "No results" }) }),
|
|
345
|
+
/* @__PURE__ */ e(
|
|
346
|
+
he,
|
|
322
347
|
{
|
|
323
|
-
ref:
|
|
324
|
-
items:
|
|
348
|
+
ref: X,
|
|
349
|
+
items: fe,
|
|
325
350
|
shouldFocusOnHover: !1,
|
|
326
351
|
shouldFocusWrap: !0,
|
|
327
|
-
className:
|
|
352
|
+
className: o(
|
|
328
353
|
"min-h-0 overflow-y-auto outline-hidden px-1",
|
|
329
|
-
(d ||
|
|
354
|
+
(d || B.length === 0) && "hidden"
|
|
330
355
|
),
|
|
331
|
-
children: (
|
|
332
|
-
|
|
356
|
+
children: (t) => j ? j(t) : /* @__PURE__ */ e(
|
|
357
|
+
ke,
|
|
333
358
|
{
|
|
334
|
-
id:
|
|
335
|
-
label:
|
|
336
|
-
avatarUrl:
|
|
337
|
-
supportingText:
|
|
338
|
-
supportingTextClassName:
|
|
339
|
-
isDisabled:
|
|
340
|
-
icon:
|
|
341
|
-
textStyles:
|
|
359
|
+
id: t.id,
|
|
360
|
+
label: t.label,
|
|
361
|
+
avatarUrl: t.avatarUrl,
|
|
362
|
+
supportingText: t.supportingText,
|
|
363
|
+
supportingTextClassName: t.supportingTextClassName,
|
|
364
|
+
isDisabled: t.isDisabled,
|
|
365
|
+
icon: t.icon,
|
|
366
|
+
textStyles: T
|
|
342
367
|
},
|
|
343
|
-
|
|
368
|
+
t.id
|
|
344
369
|
)
|
|
345
370
|
}
|
|
346
371
|
)
|
|
347
372
|
] }),
|
|
348
|
-
|
|
373
|
+
g && /* @__PURE__ */ e("div", { className: "shrink-0 border-t border-tertiary bg-primary p-1.5", children: g })
|
|
349
374
|
]
|
|
350
375
|
}
|
|
351
376
|
),
|
|
352
|
-
|
|
377
|
+
l && /* @__PURE__ */ e(Te, { isInvalid: n.isInvalid, children: l })
|
|
353
378
|
] })
|
|
354
379
|
}
|
|
355
380
|
)
|
|
@@ -357,5 +382,5 @@ const Ke = {
|
|
|
357
382
|
);
|
|
358
383
|
};
|
|
359
384
|
export {
|
|
360
|
-
|
|
385
|
+
Ze as SearchableSelect
|
|
361
386
|
};
|