@konstructio/ui 0.1.2-alpha.58 → 0.1.2-alpha.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.
|
@@ -87,6 +87,7 @@ export type SelectProps = VariantProps<typeof selectVariants> & Omit<InputHTMLAt
|
|
|
87
87
|
isLoading?: boolean;
|
|
88
88
|
isRequired?: boolean;
|
|
89
89
|
label?: string;
|
|
90
|
+
labelAction?: ReactNode;
|
|
90
91
|
labelClassName?: string;
|
|
91
92
|
labelWrapperClassName?: string;
|
|
92
93
|
listClassName?: string;
|
|
@@ -1,117 +1,130 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Typography as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { labelVariants as oe, inputVariants as
|
|
6
|
-
import { useSelect as
|
|
7
|
-
import { List as
|
|
8
|
-
import { c as
|
|
9
|
-
import { LoaderIcon as
|
|
10
|
-
import { C as
|
|
11
|
-
import { useSelectContext as
|
|
12
|
-
const
|
|
1
|
+
import { jsxs as o, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as te, useId as ae, useRef as w, useMemo as re, useImperativeHandle as ne, useEffect as le } from "react";
|
|
3
|
+
import { Typography as se } from "../../Typography/Typography.js";
|
|
4
|
+
import { cn as n } from "../../../utils/index.js";
|
|
5
|
+
import { labelVariants as oe, inputVariants as ce, selectVariants as ie } from "../Select.variants.js";
|
|
6
|
+
import { useSelect as me } from "../hooks/useSelect.js";
|
|
7
|
+
import { List as pe } from "./List/List.js";
|
|
8
|
+
import { c as ue } from "../../../createLucideIcon-CP-mMPfa.js";
|
|
9
|
+
import { LoaderIcon as fe } from "../../../assets/icons/components/Loader.js";
|
|
10
|
+
import { C as de } from "../../../chevron-up-IlDPxR7j.js";
|
|
11
|
+
import { useSelectContext as xe } from "../contexts/select.hook.js";
|
|
12
|
+
const he = [
|
|
13
13
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
14
14
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
15
|
-
],
|
|
15
|
+
], ve = ue("search", he), ze = te(
|
|
16
16
|
({
|
|
17
|
-
additionalOptions:
|
|
18
|
-
className:
|
|
17
|
+
additionalOptions: z,
|
|
18
|
+
className: O,
|
|
19
19
|
defaultValue: x,
|
|
20
|
-
disabled:
|
|
20
|
+
disabled: t = !1,
|
|
21
21
|
error: f,
|
|
22
22
|
iconClassName: R,
|
|
23
23
|
inputClassName: F,
|
|
24
24
|
isInfiniteScrollEnabled: S = !1,
|
|
25
|
-
isLoading:
|
|
25
|
+
isLoading: g,
|
|
26
26
|
isRequired: h,
|
|
27
27
|
label: v,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
labelAction: T,
|
|
29
|
+
labelClassName: E,
|
|
30
|
+
labelWrapperClassName: M,
|
|
31
|
+
listClassName: W,
|
|
32
|
+
listItemClassName: _,
|
|
33
|
+
listItemSecondRowClassName: $,
|
|
33
34
|
name: d,
|
|
34
|
-
noOptionsText:
|
|
35
|
+
noOptionsText: H,
|
|
35
36
|
placeholder: N,
|
|
36
|
-
searchable:
|
|
37
|
+
searchable: k = !1,
|
|
37
38
|
showSearchIcon: C,
|
|
38
|
-
theme:
|
|
39
|
-
wrapperClassName:
|
|
40
|
-
onFetchMoreOptions:
|
|
41
|
-
onBlur:
|
|
42
|
-
onSearchChange:
|
|
39
|
+
theme: P,
|
|
40
|
+
wrapperClassName: U,
|
|
41
|
+
onFetchMoreOptions: q,
|
|
42
|
+
onBlur: A,
|
|
43
|
+
onSearchChange: B,
|
|
43
44
|
...y
|
|
44
|
-
},
|
|
45
|
-
const I =
|
|
46
|
-
isOpen:
|
|
47
|
-
options:
|
|
48
|
-
searchTerm:
|
|
49
|
-
value:
|
|
50
|
-
setCanFilter:
|
|
51
|
-
setSearchTerm:
|
|
52
|
-
setValue:
|
|
53
|
-
toggleOpen:
|
|
54
|
-
} =
|
|
55
|
-
ulRef:
|
|
56
|
-
inputRef:
|
|
57
|
-
disabled:
|
|
45
|
+
}, D) => {
|
|
46
|
+
const I = ae(), c = w(null), j = w(null), G = w(0), {
|
|
47
|
+
isOpen: i,
|
|
48
|
+
options: l,
|
|
49
|
+
searchTerm: J,
|
|
50
|
+
value: s,
|
|
51
|
+
setCanFilter: K,
|
|
52
|
+
setSearchTerm: Q,
|
|
53
|
+
setValue: m,
|
|
54
|
+
toggleOpen: X
|
|
55
|
+
} = xe(), e = re(() => l.find(({ value: a }) => a === s), [l, s]), { wrapperRef: Y, wrapperInputRef: L, handleOpen: V } = me({
|
|
56
|
+
ulRef: j,
|
|
57
|
+
inputRef: c,
|
|
58
|
+
disabled: t,
|
|
58
59
|
internalValue: e,
|
|
59
|
-
onBlur:
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
if (x && !
|
|
63
|
-
const
|
|
64
|
-
|
|
60
|
+
onBlur: A
|
|
61
|
+
}), p = d ? `${I}-${d}` : I;
|
|
62
|
+
ne(D, () => c.current, [c]), le(() => {
|
|
63
|
+
if (x && !s) {
|
|
64
|
+
const a = l && l.find((u) => u.value === x);
|
|
65
|
+
a && m(a.value);
|
|
65
66
|
}
|
|
66
|
-
}, [x,
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
(
|
|
67
|
+
}, [x, l, m, s]);
|
|
68
|
+
const Z = (a) => {
|
|
69
|
+
const u = a.target.value;
|
|
70
|
+
K(!0), m(""), Q(u ?? ""), B?.(u);
|
|
71
|
+
const b = l.find(
|
|
72
|
+
(ee) => ee.value.toLocaleLowerCase() === u.toLocaleLowerCase()
|
|
72
73
|
);
|
|
73
|
-
|
|
74
|
+
m(b ? b.value : e?.value ?? "");
|
|
74
75
|
};
|
|
75
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ o(
|
|
76
77
|
"div",
|
|
77
78
|
{
|
|
78
|
-
ref:
|
|
79
|
-
className:
|
|
80
|
-
"data-theme":
|
|
79
|
+
ref: Y,
|
|
80
|
+
className: n("flex flex-col gap-2 w-full relative", U),
|
|
81
|
+
"data-theme": P,
|
|
81
82
|
children: [
|
|
82
|
-
v ? /* @__PURE__ */
|
|
83
|
-
"
|
|
83
|
+
v ? /* @__PURE__ */ o(
|
|
84
|
+
"div",
|
|
84
85
|
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
className: n(
|
|
87
|
+
"flex items-center justify-between",
|
|
88
|
+
M
|
|
89
|
+
),
|
|
89
90
|
children: [
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
/* @__PURE__ */ o(
|
|
92
|
+
"label",
|
|
93
|
+
{
|
|
94
|
+
id: p,
|
|
95
|
+
className: n(oe({ className: E })),
|
|
96
|
+
htmlFor: p,
|
|
97
|
+
onClick: () => !t && V(),
|
|
98
|
+
children: [
|
|
99
|
+
v,
|
|
100
|
+
h && /* @__PURE__ */ r("span", { className: "text-red-600 dark:text-red-500 ml-1", children: "*" })
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
),
|
|
104
|
+
T
|
|
92
105
|
]
|
|
93
106
|
}
|
|
94
|
-
)
|
|
95
|
-
/* @__PURE__ */
|
|
107
|
+
) : null,
|
|
108
|
+
/* @__PURE__ */ o(
|
|
96
109
|
"div",
|
|
97
110
|
{
|
|
98
|
-
ref:
|
|
99
|
-
id:
|
|
100
|
-
className:
|
|
101
|
-
|
|
111
|
+
ref: L,
|
|
112
|
+
id: p,
|
|
113
|
+
className: n(
|
|
114
|
+
ie({ className: O, hasError: !!f, disabled: t })
|
|
102
115
|
),
|
|
103
116
|
role: "combobox",
|
|
104
|
-
onClick: () => !
|
|
105
|
-
"aria-expanded":
|
|
106
|
-
tabIndex:
|
|
107
|
-
"aria-labelledby":
|
|
117
|
+
onClick: () => !t && X(!i),
|
|
118
|
+
"aria-expanded": i,
|
|
119
|
+
tabIndex: G.current,
|
|
120
|
+
"aria-labelledby": p,
|
|
108
121
|
children: [
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
e?.leftIcon && !C && /* @__PURE__ */
|
|
111
|
-
C && /* @__PURE__ */
|
|
112
|
-
|
|
122
|
+
/* @__PURE__ */ o("div", { className: "flex gap-2.5 items-center flex-1", children: [
|
|
123
|
+
e?.leftIcon && !C && /* @__PURE__ */ r("span", { className: "w-4 h-4 flex justify-center items-center dark:text-metal-50", children: e.leftIcon }),
|
|
124
|
+
C && /* @__PURE__ */ r(
|
|
125
|
+
ve,
|
|
113
126
|
{
|
|
114
|
-
className:
|
|
127
|
+
className: n(
|
|
115
128
|
"w-4",
|
|
116
129
|
"h-4",
|
|
117
130
|
"text-zinc-500",
|
|
@@ -123,39 +136,39 @@ const xe = [
|
|
|
123
136
|
)
|
|
124
137
|
}
|
|
125
138
|
),
|
|
126
|
-
|
|
139
|
+
k ? /* @__PURE__ */ r(
|
|
127
140
|
"input",
|
|
128
141
|
{
|
|
129
142
|
type: "text",
|
|
130
|
-
value:
|
|
131
|
-
onChange:
|
|
143
|
+
value: i ? J : e?.label ?? s ?? "",
|
|
144
|
+
onChange: Z,
|
|
132
145
|
placeholder: N,
|
|
133
|
-
className:
|
|
146
|
+
className: n(ce({ className: F }), {
|
|
134
147
|
"text-red-700 placeholder:text-red-700": !!f
|
|
135
148
|
}),
|
|
136
|
-
onClick: (
|
|
137
|
-
|
|
149
|
+
onClick: (a) => {
|
|
150
|
+
a.stopPropagation(), t || V();
|
|
138
151
|
},
|
|
139
152
|
"aria-label": v || N,
|
|
140
|
-
"aria-labelledby":
|
|
153
|
+
"aria-labelledby": p,
|
|
141
154
|
required: h,
|
|
142
155
|
autoComplete: "off",
|
|
143
156
|
autoCapitalize: "words",
|
|
144
|
-
disabled:
|
|
157
|
+
disabled: t,
|
|
145
158
|
tabIndex: -1,
|
|
146
159
|
...y
|
|
147
160
|
}
|
|
148
|
-
) : /* @__PURE__ */
|
|
149
|
-
|
|
161
|
+
) : /* @__PURE__ */ o(
|
|
162
|
+
se,
|
|
150
163
|
{
|
|
151
164
|
variant: "body2",
|
|
152
|
-
className:
|
|
165
|
+
className: n(
|
|
153
166
|
"flex-1 text-zinc-400 text-sm dark:text-metal-400 flex gap-2 items-center",
|
|
154
167
|
{
|
|
155
168
|
"text-red-700": !!f,
|
|
156
169
|
"select-none": !e,
|
|
157
170
|
"text-metal-800 dark:text-metal-50": e,
|
|
158
|
-
"text-metal-400/50 dark:text-metal-50/50":
|
|
171
|
+
"text-metal-400/50 dark:text-metal-50/50": t
|
|
159
172
|
},
|
|
160
173
|
e?.wrapperClassNameOnSelectedValue
|
|
161
174
|
),
|
|
@@ -167,22 +180,22 @@ const xe = [
|
|
|
167
180
|
}
|
|
168
181
|
)
|
|
169
182
|
] }),
|
|
170
|
-
|
|
171
|
-
|
|
183
|
+
g ? /* @__PURE__ */ r(
|
|
184
|
+
fe,
|
|
172
185
|
{
|
|
173
186
|
size: 16,
|
|
174
187
|
className: "text-metal-400 animate-spin select-none"
|
|
175
188
|
}
|
|
176
|
-
) : !C && /* @__PURE__ */
|
|
177
|
-
|
|
189
|
+
) : !C && /* @__PURE__ */ r(
|
|
190
|
+
de,
|
|
178
191
|
{
|
|
179
|
-
"data-state":
|
|
180
|
-
className:
|
|
192
|
+
"data-state": i ? "open" : "closed",
|
|
193
|
+
className: n(
|
|
181
194
|
"w-4 h-4 text-zinc-500 transition-all duration-100 data-[state=open]:rotate-0 data-[state=closed]:rotate-180 select-none dark:group-focus-within:text-metal-50",
|
|
182
195
|
R,
|
|
183
196
|
{
|
|
184
197
|
"text-red-700": !!f,
|
|
185
|
-
"text-metal-400/50 dark:group-focus-within:text-zinc-500":
|
|
198
|
+
"text-metal-400/50 dark:group-focus-within:text-zinc-500": t
|
|
186
199
|
}
|
|
187
200
|
)
|
|
188
201
|
}
|
|
@@ -190,37 +203,37 @@ const xe = [
|
|
|
190
203
|
]
|
|
191
204
|
}
|
|
192
205
|
),
|
|
193
|
-
/* @__PURE__ */
|
|
206
|
+
/* @__PURE__ */ r(
|
|
194
207
|
"input",
|
|
195
208
|
{
|
|
196
|
-
ref:
|
|
209
|
+
ref: c,
|
|
197
210
|
type: "text",
|
|
198
211
|
name: d,
|
|
199
212
|
className: "hidden",
|
|
200
213
|
"aria-hidden": "true",
|
|
201
214
|
required: h,
|
|
202
215
|
inert: !0,
|
|
203
|
-
defaultValue: e?.value ??
|
|
216
|
+
defaultValue: e?.value ?? s ?? void 0,
|
|
204
217
|
...y
|
|
205
218
|
}
|
|
206
219
|
),
|
|
207
|
-
|
|
208
|
-
|
|
220
|
+
i && /* @__PURE__ */ r(
|
|
221
|
+
pe,
|
|
209
222
|
{
|
|
210
|
-
ref:
|
|
211
|
-
additionalOptions:
|
|
212
|
-
className:
|
|
213
|
-
itemClassName:
|
|
223
|
+
ref: j,
|
|
224
|
+
additionalOptions: z,
|
|
225
|
+
className: W,
|
|
226
|
+
itemClassName: _,
|
|
214
227
|
name: d,
|
|
215
|
-
wrapperInputRef:
|
|
216
|
-
inputRef:
|
|
217
|
-
options:
|
|
218
|
-
isLoading: !!
|
|
219
|
-
searchable:
|
|
220
|
-
listItemSecondRowClassName:
|
|
228
|
+
wrapperInputRef: L,
|
|
229
|
+
inputRef: c,
|
|
230
|
+
options: l,
|
|
231
|
+
isLoading: !!g,
|
|
232
|
+
searchable: k,
|
|
233
|
+
listItemSecondRowClassName: $,
|
|
221
234
|
isInfiniteScrollEnabled: S,
|
|
222
|
-
onFetchMoreOptions:
|
|
223
|
-
noOptionsText:
|
|
235
|
+
onFetchMoreOptions: q,
|
|
236
|
+
noOptionsText: H
|
|
224
237
|
}
|
|
225
238
|
)
|
|
226
239
|
]
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.58",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.2-alpha.
|
|
5
|
+
"version": "0.1.2-alpha.59",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|