@konstructio/ui 0.1.2-alpha.20 → 0.1.2-alpha.21
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,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as X, useId as Y, useRef as T, useImperativeHandle as Z, useMemo as B, useEffect as
|
|
1
|
+
import { jsxs as h, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as X, useId as Y, useRef as T, useImperativeHandle as Z, useMemo as B, useEffect as L } from "react";
|
|
3
3
|
import { Loading as ee } from "../../Loading/Loading.js";
|
|
4
4
|
import { Typography as te } from "../../Typography/Typography.js";
|
|
5
5
|
import { cn as c } from "../../../utils/index.js";
|
|
@@ -28,98 +28,98 @@ const ue = [
|
|
|
28
28
|
({
|
|
29
29
|
additionalOptions: _,
|
|
30
30
|
className: $,
|
|
31
|
-
defaultValue:
|
|
31
|
+
defaultValue: v,
|
|
32
32
|
disabled: r = !1,
|
|
33
33
|
error: m,
|
|
34
34
|
iconClassName: D,
|
|
35
35
|
inputClassName: F,
|
|
36
|
-
isLoading:
|
|
37
|
-
isRequired:
|
|
38
|
-
label:
|
|
36
|
+
isLoading: z,
|
|
37
|
+
isRequired: w,
|
|
38
|
+
label: N,
|
|
39
39
|
labelClassName: M,
|
|
40
40
|
listClassName: A,
|
|
41
41
|
listItemClassName: H,
|
|
42
42
|
listItemSecondRowClassName: P,
|
|
43
43
|
name: i,
|
|
44
44
|
options: o,
|
|
45
|
-
placeholder:
|
|
46
|
-
searchable:
|
|
45
|
+
placeholder: k,
|
|
46
|
+
searchable: C = !1,
|
|
47
47
|
onSearchChange: U,
|
|
48
|
-
showSearchIcon:
|
|
48
|
+
showSearchIcon: g,
|
|
49
49
|
theme: W,
|
|
50
50
|
wrapperClassName: q,
|
|
51
|
-
onBlur:
|
|
52
|
-
...
|
|
51
|
+
onBlur: j,
|
|
52
|
+
...I
|
|
53
53
|
}, G) => {
|
|
54
|
-
const
|
|
55
|
-
ulRef:
|
|
54
|
+
const b = Y(), t = T(null), E = T(null), { wrapperRef: u, wrapperInputRef: O, handleOpen: y } = oe({
|
|
55
|
+
ulRef: E,
|
|
56
56
|
inputRef: t,
|
|
57
57
|
disabled: r
|
|
58
|
-
}), { isOpen: p, searchTerm: J, value: l, toggleOpen: K, setValue:
|
|
58
|
+
}), { isOpen: p, searchTerm: J, value: l, toggleOpen: K, setValue: x, setSearchTerm: R } = se(), f = i ? `${b}-${i}` : b;
|
|
59
59
|
Z(G, () => t.current, [t]);
|
|
60
60
|
const n = B(() => o.find(({ value: e }) => e === l), [o, l]);
|
|
61
|
-
|
|
62
|
-
t.current && (t.current.value = l
|
|
63
|
-
}, [n, l]),
|
|
64
|
-
if (
|
|
65
|
-
const e = o && o.find((s) => s.value ===
|
|
66
|
-
e &&
|
|
61
|
+
L(() => {
|
|
62
|
+
t.current && (t.current.value = l && n?.value || "");
|
|
63
|
+
}, [n, l]), L(() => {
|
|
64
|
+
if (v && !l) {
|
|
65
|
+
const e = o && o.find((s) => s.value === v);
|
|
66
|
+
e && x(e.value);
|
|
67
67
|
}
|
|
68
|
-
}, [
|
|
68
|
+
}, [v, o, x, l]), L(() => {
|
|
69
69
|
const e = new AbortController();
|
|
70
70
|
return u.current?.addEventListener("focusout", (s) => {
|
|
71
71
|
const d = s.relatedTarget;
|
|
72
|
-
(!d || !u.current?.contains(d)) && (
|
|
72
|
+
(!d || !u.current?.contains(d)) && (t.current?.value || j?.());
|
|
73
73
|
}), () => {
|
|
74
74
|
e.abort();
|
|
75
75
|
};
|
|
76
|
-
}, [K, u,
|
|
76
|
+
}, [K, u, R, j, l]);
|
|
77
77
|
const Q = (e) => {
|
|
78
78
|
const s = e.target.value;
|
|
79
|
-
U?.(s),
|
|
79
|
+
U?.(s), x(""), R(s || "");
|
|
80
80
|
const d = o.find(
|
|
81
81
|
(S) => S.value.toLocaleLowerCase() === s.toLocaleLowerCase()
|
|
82
82
|
);
|
|
83
|
-
d &&
|
|
83
|
+
d && x(d.value);
|
|
84
84
|
};
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
return /* @__PURE__ */ h(
|
|
86
86
|
"div",
|
|
87
87
|
{
|
|
88
88
|
ref: u,
|
|
89
89
|
className: c("flex flex-col w-full relative", q),
|
|
90
90
|
"data-theme": W,
|
|
91
91
|
children: [
|
|
92
|
-
|
|
92
|
+
N ? /* @__PURE__ */ h(
|
|
93
93
|
"label",
|
|
94
94
|
{
|
|
95
95
|
id: f,
|
|
96
96
|
className: c(ae({ className: M })),
|
|
97
97
|
htmlFor: f,
|
|
98
|
-
onClick: () => !r &&
|
|
98
|
+
onClick: () => !r && y(),
|
|
99
99
|
children: [
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
N,
|
|
101
|
+
w && /* @__PURE__ */ a("span", { className: "text-red-600 ml-1", children: "*" })
|
|
102
102
|
]
|
|
103
103
|
}
|
|
104
104
|
) : null,
|
|
105
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ h(
|
|
106
106
|
"div",
|
|
107
107
|
{
|
|
108
|
-
ref:
|
|
108
|
+
ref: O,
|
|
109
109
|
id: f,
|
|
110
110
|
className: c(
|
|
111
111
|
ne({ className: $, hasError: !!m, disabled: r })
|
|
112
112
|
),
|
|
113
113
|
role: "combobox",
|
|
114
|
-
onClick: () => !r &&
|
|
114
|
+
onClick: () => !r && y(),
|
|
115
115
|
"aria-expanded": p,
|
|
116
116
|
tabIndex: 0,
|
|
117
117
|
"aria-labelledby": f,
|
|
118
118
|
children: [
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
n?.leftIcon && !
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
/* @__PURE__ */ h("div", { className: "flex gap-2.5 items-center flex-1", children: [
|
|
120
|
+
n?.leftIcon && !g && /* @__PURE__ */ a("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: n.leftIcon }),
|
|
121
|
+
g && /* @__PURE__ */ a(fe, { className: "w-4 h-4 text-zinc-500 select-none dark:text-slate-300 dark:group-focus-within:text-slate-50 transition-colors duration-300" }),
|
|
122
|
+
C ? /* @__PURE__ */ a(
|
|
123
123
|
"input",
|
|
124
124
|
{
|
|
125
125
|
ref: t,
|
|
@@ -127,20 +127,20 @@ const ue = [
|
|
|
127
127
|
value: p ? J : n?.label || "",
|
|
128
128
|
name: i,
|
|
129
129
|
onChange: Q,
|
|
130
|
-
placeholder:
|
|
130
|
+
placeholder: k,
|
|
131
131
|
className: c(re({ className: F }), {
|
|
132
132
|
"text-red-700 placeholder:text-red-700": !!m
|
|
133
133
|
}),
|
|
134
134
|
onClick: (e) => {
|
|
135
|
-
e.stopPropagation(), r ||
|
|
135
|
+
e.stopPropagation(), r || y();
|
|
136
136
|
},
|
|
137
|
-
"aria-label":
|
|
137
|
+
"aria-label": N || k,
|
|
138
138
|
"aria-labelledby": f,
|
|
139
|
-
required:
|
|
139
|
+
required: w,
|
|
140
140
|
autoComplete: "off",
|
|
141
141
|
autoCapitalize: "words",
|
|
142
142
|
disabled: r,
|
|
143
|
-
...
|
|
143
|
+
...I
|
|
144
144
|
}
|
|
145
145
|
) : /* @__PURE__ */ a(
|
|
146
146
|
te,
|
|
@@ -155,11 +155,11 @@ const ue = [
|
|
|
155
155
|
"text-slate-400/50 dark:text-slate-50/50": r
|
|
156
156
|
}
|
|
157
157
|
),
|
|
158
|
-
children: n?.label ||
|
|
158
|
+
children: n?.label || k
|
|
159
159
|
}
|
|
160
160
|
)
|
|
161
161
|
] }),
|
|
162
|
-
|
|
162
|
+
z ? /* @__PURE__ */ a(ee, { className: "w-4 h-4 text-zinc-500 select-none" }) : !g && /* @__PURE__ */ a(
|
|
163
163
|
ie,
|
|
164
164
|
{
|
|
165
165
|
"data-state": p ? "open" : "closed",
|
|
@@ -176,7 +176,7 @@ const ue = [
|
|
|
176
176
|
]
|
|
177
177
|
}
|
|
178
178
|
),
|
|
179
|
-
!
|
|
179
|
+
!C && /* @__PURE__ */ a(
|
|
180
180
|
"input",
|
|
181
181
|
{
|
|
182
182
|
ref: t,
|
|
@@ -184,25 +184,25 @@ const ue = [
|
|
|
184
184
|
name: i,
|
|
185
185
|
className: "hidden",
|
|
186
186
|
"aria-hidden": "true",
|
|
187
|
-
required:
|
|
187
|
+
required: w,
|
|
188
188
|
inert: !0,
|
|
189
|
-
...
|
|
189
|
+
...I
|
|
190
190
|
}
|
|
191
191
|
),
|
|
192
192
|
p && /* @__PURE__ */ a(
|
|
193
193
|
le,
|
|
194
194
|
{
|
|
195
|
-
ref:
|
|
195
|
+
ref: E,
|
|
196
196
|
additionalOptions: _,
|
|
197
197
|
className: A,
|
|
198
198
|
itemClassName: H,
|
|
199
199
|
name: i,
|
|
200
200
|
wrapperRef: u,
|
|
201
|
-
wrapperInputRef:
|
|
201
|
+
wrapperInputRef: O,
|
|
202
202
|
inputRef: t,
|
|
203
203
|
options: o,
|
|
204
|
-
isLoading: !!
|
|
205
|
-
searchable:
|
|
204
|
+
isLoading: !!z,
|
|
205
|
+
searchable: C,
|
|
206
206
|
listItemSecondRowClassName: P
|
|
207
207
|
}
|
|
208
208
|
)
|
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.20",
|
|
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.21",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|