@konstructio/ui 0.0.12-alpha.15 → 0.0.12-alpha.16
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/components/Dropdown/Dropdown.js +6 -6
- package/dist/components/Dropdown/components/ListItem/ListItem.js +4 -4
- package/dist/components/Dropdown/components/Wrapper.js +73 -71
- package/dist/components/Dropdown/contexts/dropdown.provider.js +14 -14
- package/dist/index.d.ts +4 -3
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { DropdownProvider as
|
|
4
|
-
import { Wrapper as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { DropdownProvider as d } from "./contexts/dropdown.provider.js";
|
|
4
|
+
import { Wrapper as e } from "./components/Wrapper.js";
|
|
5
|
+
const x = t(({ onChange: p, value: m, name: r, ...f }, i) => /* @__PURE__ */ o(d, { onChange: p, value: m, name: r, children: /* @__PURE__ */ o(e, { name: r, ref: i, ...f }) }));
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
x as Dropdown
|
|
8
8
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as f, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import { useRef as p, useCallback as s } from "react";
|
|
3
|
-
import { cn as
|
|
4
|
-
import { listItemVariants as
|
|
3
|
+
import { cn as u } from "../../../../utils/index.js";
|
|
4
|
+
import { listItemVariants as d } from "./ListItem.variants.js";
|
|
5
5
|
import { Typography as h } from "../../../Typography/Typography.js";
|
|
6
6
|
import { useDropdownContext as x } from "../../contexts/dropdown.hook.js";
|
|
7
7
|
const g = ({ theme: a, ...e }) => {
|
|
8
8
|
const { setValue: n, toggleOpen: r } = x(), c = p(null), l = s(
|
|
9
9
|
(t) => {
|
|
10
|
-
n(t), r(!1);
|
|
10
|
+
n(t.value), r(!1);
|
|
11
11
|
},
|
|
12
12
|
[n, r]
|
|
13
13
|
), i = s(
|
|
@@ -21,7 +21,7 @@ const g = ({ theme: a, ...e }) => {
|
|
|
21
21
|
{
|
|
22
22
|
ref: c,
|
|
23
23
|
role: "option",
|
|
24
|
-
className: d(
|
|
24
|
+
className: u(d({ theme: a })),
|
|
25
25
|
tabIndex: 0,
|
|
26
26
|
onClick: () => l(e),
|
|
27
27
|
onKeyDown: (t) => i(t, e),
|
|
@@ -1,97 +1,99 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { labelVariants as
|
|
5
|
-
import { useDropdown as
|
|
6
|
-
import { List as
|
|
7
|
-
import { Typography as
|
|
8
|
-
import { Loading as
|
|
9
|
-
import { C as
|
|
10
|
-
import { useDropdownContext as
|
|
11
|
-
import { useTheme as
|
|
12
|
-
const
|
|
1
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as H, useId as M, useRef as R, useImperativeHandle as U, useMemo as W, useEffect as p } from "react";
|
|
3
|
+
import { cn as u } from "../../../utils/index.js";
|
|
4
|
+
import { labelVariants as B, dropdownVariants as G } from "../Dropdown.variants.js";
|
|
5
|
+
import { useDropdown as J } from "../hooks/useDropdown.js";
|
|
6
|
+
import { List as K } from "./List/List.js";
|
|
7
|
+
import { Typography as O } from "../../Typography/Typography.js";
|
|
8
|
+
import { Loading as P } from "../../Loading/Loading.js";
|
|
9
|
+
import { C as Q } from "../../../chevron-up-DgLBQCKD.js";
|
|
10
|
+
import { useDropdownContext as S } from "../contexts/dropdown.hook.js";
|
|
11
|
+
import { useTheme as X } from "../../../contexts/theme.hook.js";
|
|
12
|
+
const ae = H(
|
|
13
13
|
({
|
|
14
|
-
theme:
|
|
15
|
-
label:
|
|
16
|
-
labelClassName:
|
|
17
|
-
placeholder:
|
|
18
|
-
name:
|
|
19
|
-
options:
|
|
20
|
-
required:
|
|
21
|
-
defaultValue:
|
|
22
|
-
isLoading:
|
|
23
|
-
},
|
|
24
|
-
const
|
|
25
|
-
U(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
theme: z,
|
|
15
|
+
label: h,
|
|
16
|
+
labelClassName: T,
|
|
17
|
+
placeholder: j,
|
|
18
|
+
name: l,
|
|
19
|
+
options: n,
|
|
20
|
+
required: x,
|
|
21
|
+
defaultValue: f,
|
|
22
|
+
isLoading: E
|
|
23
|
+
}, L) => {
|
|
24
|
+
const v = M(), s = R(null), b = R(null), { wrapperRef: a, wrapperInputRef: w, handleOpen: k, handleOpenIfClosed: D } = J({ ulRef: b }), { isOpen: N, toggleOpen: g, value: r, setValue: C } = S(), { theme: F } = X(), d = z ?? F, c = l ? `${v}-${l}` : v;
|
|
25
|
+
U(L, () => s.current, [s]);
|
|
26
|
+
const e = W(() => n.find(({ value: o }) => o === r), [n, r]);
|
|
27
|
+
p(() => {
|
|
28
|
+
s.current && (s.current.value = r ? e == null ? void 0 : e.value : "");
|
|
29
|
+
}, [e, r]), p(() => {
|
|
30
|
+
if (f && !r) {
|
|
31
|
+
const o = n && n.find((i) => i.value === f);
|
|
32
|
+
o && C(o.value);
|
|
31
33
|
}
|
|
32
|
-
}, [
|
|
34
|
+
}, [f, n, C, r]), p(() => {
|
|
33
35
|
var i;
|
|
34
|
-
const
|
|
35
|
-
return (i =
|
|
36
|
-
var
|
|
37
|
-
const
|
|
38
|
-
(!
|
|
36
|
+
const o = new AbortController();
|
|
37
|
+
return (i = a.current) == null || i.addEventListener("focusout", (A) => {
|
|
38
|
+
var y;
|
|
39
|
+
const I = A.relatedTarget;
|
|
40
|
+
(!I || !((y = a.current) != null && y.contains(I))) && g(!1);
|
|
39
41
|
}), () => {
|
|
40
|
-
|
|
42
|
+
o.abort();
|
|
41
43
|
};
|
|
42
|
-
}, [
|
|
43
|
-
const
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
|
|
44
|
+
}, [g, a]);
|
|
45
|
+
const $ = () => e != null && e.leftIcon ? /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null;
|
|
46
|
+
return /* @__PURE__ */ m("div", { ref: a, className: "flex flex-col w-full relative", children: [
|
|
47
|
+
h ? /* @__PURE__ */ m(
|
|
46
48
|
"label",
|
|
47
49
|
{
|
|
48
|
-
id:
|
|
49
|
-
className:
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
id: c,
|
|
51
|
+
className: u(
|
|
52
|
+
B({ theme: d }),
|
|
53
|
+
T
|
|
52
54
|
),
|
|
53
|
-
htmlFor:
|
|
54
|
-
onClick:
|
|
55
|
+
htmlFor: c,
|
|
56
|
+
onClick: D,
|
|
55
57
|
children: [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
h,
|
|
59
|
+
x ? /* @__PURE__ */ t("span", { className: "text-red-500 ml-1", children: "*" }) : null
|
|
58
60
|
]
|
|
59
61
|
}
|
|
60
62
|
) : null,
|
|
61
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ m(
|
|
62
64
|
"div",
|
|
63
65
|
{
|
|
64
66
|
ref: w,
|
|
65
|
-
id:
|
|
66
|
-
className:
|
|
67
|
+
id: c,
|
|
68
|
+
className: u(G({ theme: d })),
|
|
67
69
|
role: "combobox",
|
|
68
|
-
onClick:
|
|
70
|
+
onClick: k,
|
|
69
71
|
"aria-expanded": N,
|
|
70
72
|
tabIndex: 0,
|
|
71
|
-
"aria-labelledby":
|
|
73
|
+
"aria-labelledby": c,
|
|
72
74
|
children: [
|
|
73
|
-
/* @__PURE__ */ t("span", { className: "text-base text-inherit", children:
|
|
74
|
-
|
|
75
|
+
/* @__PURE__ */ t("span", { className: "text-base text-inherit", children: r ? /* @__PURE__ */ m(
|
|
76
|
+
O,
|
|
75
77
|
{
|
|
76
78
|
variant: "body2",
|
|
77
79
|
className: "flex gap-3 items-center text-zinc-700",
|
|
78
80
|
children: [
|
|
79
|
-
|
|
80
|
-
e.label
|
|
81
|
+
$(),
|
|
82
|
+
e == null ? void 0 : e.label
|
|
81
83
|
]
|
|
82
84
|
}
|
|
83
85
|
) : /* @__PURE__ */ t(
|
|
84
|
-
|
|
86
|
+
O,
|
|
85
87
|
{
|
|
86
88
|
variant: "body2",
|
|
87
89
|
className: "flex gap-3 items-center text-zinc-700",
|
|
88
|
-
children:
|
|
90
|
+
children: j
|
|
89
91
|
}
|
|
90
92
|
) }),
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
E ? /* @__PURE__ */ t(P, { className: "w-4 h-4 text-zinc-500" }) : /* @__PURE__ */ t(
|
|
94
|
+
Q,
|
|
93
95
|
{
|
|
94
|
-
className:
|
|
96
|
+
className: u(
|
|
95
97
|
"w-4 h-4 text-zinc-500 transition-all duration-50",
|
|
96
98
|
N ? "rotate-0" : "rotate-180"
|
|
97
99
|
)
|
|
@@ -103,28 +105,28 @@ const oe = A(
|
|
|
103
105
|
/* @__PURE__ */ t(
|
|
104
106
|
"input",
|
|
105
107
|
{
|
|
106
|
-
ref:
|
|
108
|
+
ref: s,
|
|
107
109
|
type: "text",
|
|
108
|
-
name:
|
|
110
|
+
name: l,
|
|
109
111
|
className: "hidden",
|
|
110
112
|
"aria-hidden": "true",
|
|
111
|
-
required:
|
|
113
|
+
required: x
|
|
112
114
|
}
|
|
113
115
|
),
|
|
114
116
|
/* @__PURE__ */ t(
|
|
115
|
-
|
|
117
|
+
K,
|
|
116
118
|
{
|
|
117
119
|
ref: b,
|
|
118
|
-
name:
|
|
119
|
-
wrapperRef:
|
|
120
|
+
name: l,
|
|
121
|
+
wrapperRef: a,
|
|
120
122
|
wrapperInputRef: w,
|
|
121
|
-
options:
|
|
122
|
-
theme:
|
|
123
|
+
options: n,
|
|
124
|
+
theme: d
|
|
123
125
|
}
|
|
124
126
|
)
|
|
125
127
|
] });
|
|
126
128
|
}
|
|
127
129
|
);
|
|
128
130
|
export {
|
|
129
|
-
|
|
131
|
+
ae as Wrapper
|
|
130
132
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { DropdownContext as
|
|
4
|
-
import { useToggle as
|
|
5
|
-
const
|
|
6
|
-
const [
|
|
7
|
-
(
|
|
8
|
-
r == null || r({ target: { value:
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as u } from "react";
|
|
3
|
+
import { DropdownContext as d } from "./dropdown.context.js";
|
|
4
|
+
import { useToggle as f } from "../../../hooks/useToggle.js";
|
|
5
|
+
const w = ({ children: t, onChange: r, value: e, name: o }) => {
|
|
6
|
+
const [l, p] = f(!1), s = u(
|
|
7
|
+
(m) => {
|
|
8
|
+
r == null || r({ target: { value: m, name: o ?? "" } });
|
|
9
9
|
},
|
|
10
|
-
[r]
|
|
10
|
+
[r, o]
|
|
11
11
|
);
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
|
|
12
|
+
return /* @__PURE__ */ i(
|
|
13
|
+
d.Provider,
|
|
14
14
|
{
|
|
15
|
-
value: { value:
|
|
16
|
-
children:
|
|
15
|
+
value: { value: e, isOpen: l, setValue: s, toggleOpen: p },
|
|
16
|
+
children: t
|
|
17
17
|
}
|
|
18
18
|
);
|
|
19
19
|
};
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
w as DropdownProvider
|
|
22
22
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -142,15 +142,16 @@ export declare const Divider: FunctionComponent<HTMLAttributes<HTMLDivElement>>;
|
|
|
142
142
|
export declare const Dropdown: FC<DropdownProps>;
|
|
143
143
|
|
|
144
144
|
declare interface DropdownProps extends VariantProps<typeof dropdownVariants>, Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'onChange'> {
|
|
145
|
-
onChange?: ({ target: { value } }: {
|
|
145
|
+
onChange?: ({ target: { value, name }, }: {
|
|
146
146
|
target: {
|
|
147
|
-
value:
|
|
147
|
+
value: string;
|
|
148
|
+
name: string;
|
|
148
149
|
};
|
|
149
150
|
}) => void;
|
|
150
151
|
label?: string;
|
|
151
152
|
options: Option_3[];
|
|
152
153
|
labelClassName?: string;
|
|
153
|
-
value?:
|
|
154
|
+
value?: string;
|
|
154
155
|
isLoading?: boolean;
|
|
155
156
|
}
|
|
156
157
|
|
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.0.12-alpha.
|
|
5
|
+
"version": "0.0.12-alpha.15",
|
|
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.0.12-alpha.
|
|
5
|
+
"version": "0.0.12-alpha.16",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|