@konstructio/ui 0.1.2-alpha.13 → 0.1.2-alpha.15

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,165 +1,173 @@
1
- import { jsxs as p, jsx as a } from "react/jsx-runtime";
2
- import { forwardRef as K, useId as Q, useRef as R, useImperativeHandle as S, useMemo as X, useEffect as g } from "react";
3
- import { Loading as Y } from "../../Loading/Loading.js";
4
- import { Typography as Z } from "../../Typography/Typography.js";
5
- import { cn as s } from "../../../utils/index.js";
6
- import { labelVariants as B, inputVariants as ee, dropdownVariants as te } from "../Dropdown.variants.js";
7
- import { useDropdown as ae } from "../hooks/useDropdown.js";
8
- import { List as re } from "./List/List.js";
9
- import { c as T } from "../../../createLucideIcon-DnY-81vT.js";
10
- import { useDropdownContext as ne } from "../contexts/dropdown.hook.js";
1
+ import { jsxs as x, jsx as a } from "react/jsx-runtime";
2
+ import { forwardRef as S, useId as X, useRef as T, useImperativeHandle as Y, useMemo as Z, useEffect as z } from "react";
3
+ import { Loading as B } from "../../Loading/Loading.js";
4
+ import { Typography as ee } from "../../Typography/Typography.js";
5
+ import { cn as c } from "../../../utils/index.js";
6
+ import { labelVariants as te, inputVariants as ae, dropdownVariants as re } from "../Dropdown.variants.js";
7
+ import { useDropdown as ne } from "../hooks/useDropdown.js";
8
+ import { List as oe } from "./List/List.js";
9
+ import { c as V } from "../../../createLucideIcon-DGhJ8Z4k.js";
10
+ import { useDropdownContext as le } from "../contexts/dropdown.hook.js";
11
11
  /**
12
- * @license lucide-react v0.546.0 - ISC
12
+ * @license lucide-react v0.548.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */
17
- const le = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], oe = T("chevron-up", le);
17
+ const se = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], ce = V("chevron-up", se);
18
18
  /**
19
- * @license lucide-react v0.546.0 - ISC
19
+ * @license lucide-react v0.548.0 - ISC
20
20
  *
21
21
  * This source code is licensed under the ISC license.
22
22
  * See the LICENSE file in the root directory of this source tree.
23
23
  */
24
- const se = [
24
+ const ie = [
25
25
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
26
26
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
27
- ], ce = T("search", se), we = K(
27
+ ], ue = V("search", ie), Ce = S(
28
28
  ({
29
- additionalOptions: V,
30
- className: _,
31
- defaultValue: x,
32
- error: f,
33
- iconClassName: $,
34
- inputClassName: D,
35
- isLoading: L,
36
- isRequired: h,
37
- label: v,
38
- labelClassName: F,
39
- listClassName: M,
40
- listItemClassName: A,
41
- name: c,
42
- options: n,
29
+ additionalOptions: _,
30
+ className: $,
31
+ defaultValue: h,
32
+ disabled: r = !1,
33
+ error: m,
34
+ iconClassName: D,
35
+ inputClassName: F,
36
+ isLoading: j,
37
+ isRequired: v,
38
+ label: w,
39
+ labelClassName: M,
40
+ listClassName: A,
41
+ listItemClassName: H,
42
+ listItemSecondRowClassName: P,
43
+ name: i,
44
+ options: o,
43
45
  placeholder: N,
44
- searchable: w = !1,
46
+ searchable: k = !1,
45
47
  showSearchIcon: C,
46
- theme: H,
47
- wrapperClassName: P,
48
- onBlur: j,
49
- ...z
50
- }, U) => {
51
- const I = Q(), t = R(null), E = R(null), { wrapperRef: i, wrapperInputRef: O, handleOpen: k } = ae({
52
- ulRef: E,
53
- inputRef: t
54
- }), { isOpen: m, searchTerm: W, value: l, toggleOpen: q, setValue: y, setSearchTerm: b } = ne(), d = c ? `${I}-${c}` : I;
55
- S(U, () => t.current, [t]);
56
- const r = X(() => n.find(({ value: e }) => e === l), [n, l]);
57
- g(() => {
58
- t.current && (t.current.value = l ? r?.value : "");
59
- }, [r, l]), g(() => {
60
- if (x && !l) {
61
- const e = n && n.find((o) => o.value === x);
48
+ theme: U,
49
+ wrapperClassName: W,
50
+ onBlur: I,
51
+ ...b
52
+ }, q) => {
53
+ const E = X(), t = T(null), O = T(null), { wrapperRef: u, wrapperInputRef: R, handleOpen: g } = ne({
54
+ ulRef: O,
55
+ inputRef: t,
56
+ disabled: r
57
+ }), { isOpen: p, searchTerm: G, value: l, toggleOpen: J, setValue: y, setSearchTerm: L } = le(), f = i ? `${E}-${i}` : E;
58
+ Y(q, () => t.current, [t]);
59
+ const n = Z(() => o.find(({ value: e }) => e === l), [o, l]);
60
+ z(() => {
61
+ t.current && (t.current.value = l ? n?.value : "");
62
+ }, [n, l]), z(() => {
63
+ if (h && !l) {
64
+ const e = o && o.find((s) => s.value === h);
62
65
  e && y(e.value);
63
66
  }
64
- }, [x, n, y, l]), g(() => {
67
+ }, [h, o, y, l]), z(() => {
65
68
  const e = new AbortController();
66
- return i.current?.addEventListener("focusout", (o) => {
67
- const u = o.relatedTarget;
68
- (!u || !i.current?.contains(u)) && (b(""), t.current?.value || j?.());
69
+ return u.current?.addEventListener("focusout", (s) => {
70
+ const d = s.relatedTarget;
71
+ (!d || !u.current?.contains(d)) && (L(""), t.current?.value || I?.());
69
72
  }), () => {
70
73
  e.abort();
71
74
  };
72
- }, [q, i, b, j, l]);
73
- const G = (e) => {
74
- const o = e.target.value;
75
- b(o);
76
- const u = n.find(
77
- (J) => J.value.toLocaleLowerCase() === o.toLocaleLowerCase()
75
+ }, [J, u, L, I, l]);
76
+ const K = (e) => {
77
+ const s = e.target.value;
78
+ L(s);
79
+ const d = o.find(
80
+ (Q) => Q.value.toLocaleLowerCase() === s.toLocaleLowerCase()
78
81
  );
79
- u && y(u.value);
82
+ d && y(d.value);
80
83
  };
81
- return /* @__PURE__ */ p(
84
+ return /* @__PURE__ */ x(
82
85
  "div",
83
86
  {
84
- ref: i,
85
- className: s("flex flex-col w-full relative", P),
86
- "data-theme": H,
87
+ ref: u,
88
+ className: c("flex flex-col w-full relative", W),
89
+ "data-theme": U,
87
90
  children: [
88
- v ? /* @__PURE__ */ p(
91
+ w ? /* @__PURE__ */ x(
89
92
  "label",
90
93
  {
91
- id: d,
92
- className: s(B({ className: F })),
93
- htmlFor: d,
94
- onClick: k,
94
+ id: f,
95
+ className: c(te({ className: M })),
96
+ htmlFor: f,
97
+ onClick: () => !r && g(),
95
98
  children: [
96
- v,
97
- h && /* @__PURE__ */ a("span", { className: "text-red-600 ml-1", children: "*" })
99
+ w,
100
+ v && /* @__PURE__ */ a("span", { className: "text-red-600 ml-1", children: "*" })
98
101
  ]
99
102
  }
100
103
  ) : null,
101
- /* @__PURE__ */ p(
104
+ /* @__PURE__ */ x(
102
105
  "div",
103
106
  {
104
- ref: O,
105
- id: d,
106
- className: s(te({ className: _, hasError: !!f })),
107
+ ref: R,
108
+ id: f,
109
+ className: c(
110
+ re({ className: $, hasError: !!m, disabled: r })
111
+ ),
107
112
  role: "combobox",
108
- onClick: k,
109
- "aria-expanded": m,
113
+ onClick: () => !r && g(),
114
+ "aria-expanded": p,
110
115
  tabIndex: 0,
111
- "aria-labelledby": d,
116
+ "aria-labelledby": f,
112
117
  children: [
113
- /* @__PURE__ */ p("div", { className: "flex gap-2.5 items-center flex-1", children: [
114
- r?.leftIcon && !C && /* @__PURE__ */ a("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: r.leftIcon }),
115
- C && /* @__PURE__ */ a(ce, { 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" }),
116
- w ? /* @__PURE__ */ a(
118
+ /* @__PURE__ */ x("div", { className: "flex gap-2.5 items-center flex-1", children: [
119
+ n?.leftIcon && !C && /* @__PURE__ */ a("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: n.leftIcon }),
120
+ C && /* @__PURE__ */ a(ue, { 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" }),
121
+ k ? /* @__PURE__ */ a(
117
122
  "input",
118
123
  {
119
124
  ref: t,
120
125
  type: "text",
121
- value: m ? W : r?.label || "",
122
- name: c,
123
- onChange: G,
126
+ value: p ? G : n?.label || "",
127
+ name: i,
128
+ onChange: K,
124
129
  placeholder: N,
125
- className: s(ee({ className: D }), {
126
- "text-red-700 placeholder:text-red-700": !!f
130
+ className: c(ae({ className: F }), {
131
+ "text-red-700 placeholder:text-red-700": !!m
127
132
  }),
128
133
  onClick: (e) => {
129
- e.stopPropagation(), k();
134
+ e.stopPropagation(), r || g();
130
135
  },
131
- "aria-label": v || N,
132
- "aria-labelledby": d,
133
- required: h,
136
+ "aria-label": w || N,
137
+ "aria-labelledby": f,
138
+ required: v,
134
139
  autoComplete: "off",
135
140
  autoCapitalize: "words",
136
- ...z
141
+ disabled: r,
142
+ ...b
137
143
  }
138
144
  ) : /* @__PURE__ */ a(
139
- Z,
145
+ ee,
140
146
  {
141
147
  variant: "body2",
142
- className: s(
148
+ className: c(
143
149
  "flex-1 text-zinc-400 text-sm dark:text-slate-400",
144
150
  {
145
- "text-red-700": !!f,
146
- "select-none": !r,
147
- "text-slate-800 dark:text-slate-50": r
151
+ "text-red-700": !!m,
152
+ "select-none": !n,
153
+ "text-slate-800 dark:text-slate-50": n,
154
+ "text-slate-400/50 dark:text-slate-50/50": r
148
155
  }
149
156
  ),
150
- children: r?.label || N
157
+ children: n?.label || N
151
158
  }
152
159
  )
153
160
  ] }),
154
- L ? /* @__PURE__ */ a(Y, { className: "w-4 h-4 text-zinc-500 select-none" }) : !C && /* @__PURE__ */ a(
155
- oe,
161
+ j ? /* @__PURE__ */ a(B, { className: "w-4 h-4 text-zinc-500 select-none" }) : !C && /* @__PURE__ */ a(
162
+ ce,
156
163
  {
157
- "data-state": m ? "open" : "closed",
158
- className: s(
164
+ "data-state": p ? "open" : "closed",
165
+ className: c(
159
166
  "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-slate-50",
160
- $,
167
+ D,
161
168
  {
162
- "text-red-700": !!f
169
+ "text-red-700": !!m,
170
+ "text-slate-400/50 dark:group-focus-within:text-zinc-500": r
163
171
  }
164
172
  )
165
173
  }
@@ -167,32 +175,34 @@ const se = [
167
175
  ]
168
176
  }
169
177
  ),
170
- !w && /* @__PURE__ */ a(
178
+ !k && /* @__PURE__ */ a(
171
179
  "input",
172
180
  {
173
181
  ref: t,
174
182
  type: "text",
175
- name: c,
183
+ name: i,
176
184
  className: "hidden",
177
185
  "aria-hidden": "true",
178
- required: h,
179
- ...z
186
+ required: v,
187
+ inert: !0,
188
+ ...b
180
189
  }
181
190
  ),
182
- m && /* @__PURE__ */ a(
183
- re,
191
+ p && /* @__PURE__ */ a(
192
+ oe,
184
193
  {
185
- ref: E,
186
- additionalOptions: V,
187
- className: M,
188
- itemClassName: A,
189
- name: c,
190
- wrapperRef: i,
191
- wrapperInputRef: O,
194
+ ref: O,
195
+ additionalOptions: _,
196
+ className: A,
197
+ itemClassName: H,
198
+ name: i,
199
+ wrapperRef: u,
200
+ wrapperInputRef: R,
192
201
  inputRef: t,
193
- options: n,
194
- isLoading: !!L,
195
- searchable: w
202
+ options: o,
203
+ isLoading: !!j,
204
+ searchable: k,
205
+ listItemSecondRowClassName: P
196
206
  }
197
207
  )
198
208
  ]
@@ -201,5 +211,5 @@ const se = [
201
211
  }
202
212
  );
203
213
  export {
204
- we as Wrapper
214
+ Ce as Wrapper
205
215
  };
@@ -1,7 +1,11 @@
1
- import { useRef as c, useEffect as u, useCallback as f } from "react";
2
- import { useDropdownContext as g } from "../contexts/dropdown.hook.js";
3
- const w = ({ ulRef: l, inputRef: i }) => {
4
- const o = c(null), t = c(null), { toggleOpen: n } = g();
1
+ import { useRef as c, useEffect as u, useCallback as g } from "react";
2
+ import { useDropdownContext as m } from "../contexts/dropdown.hook.js";
3
+ const b = ({
4
+ ulRef: i,
5
+ inputRef: l,
6
+ disabled: d
7
+ }) => {
8
+ const o = c(null), t = c(null), { toggleOpen: n } = m();
5
9
  u(() => {
6
10
  const e = new AbortController(), s = (a) => {
7
11
  a.key === "Escape" && n(!1);
@@ -23,7 +27,7 @@ const w = ({ ulRef: l, inputRef: i }) => {
23
27
  ), t.current?.addEventListener(
24
28
  "focus",
25
29
  () => {
26
- n(!0);
30
+ d || n(!0);
27
31
  },
28
32
  { signal: e.signal }
29
33
  ), () => {
@@ -35,7 +39,7 @@ const w = ({ ulRef: l, inputRef: i }) => {
35
39
  "keydown",
36
40
  (s) => {
37
41
  if (s.key === "ArrowDown") {
38
- const r = l.current?.querySelector("li");
42
+ const r = i.current?.querySelector("li");
39
43
  r && r.focus();
40
44
  }
41
45
  },
@@ -43,16 +47,16 @@ const w = ({ ulRef: l, inputRef: i }) => {
43
47
  ), () => {
44
48
  e.abort();
45
49
  };
46
- }, [t, l]);
47
- const d = f(() => {
48
- n(!0), requestAnimationFrame(() => i?.current?.focus());
49
- }, [i, n]);
50
+ }, [t, i]);
51
+ const f = g(() => {
52
+ n(!0), requestAnimationFrame(() => l?.current?.focus());
53
+ }, [l, n]);
50
54
  return {
51
55
  wrapperRef: o,
52
56
  wrapperInputRef: t,
53
- handleOpen: d
57
+ handleOpen: f
54
58
  };
55
59
  };
56
60
  export {
57
- w as useDropdown
61
+ b as useDropdown
58
62
  };
@@ -5,7 +5,7 @@ import { Checkbox as C } from "../../../Checkbox/Checkbox.js";
5
5
  import { cn as n } from "../../../../utils/index.js";
6
6
  import { filterButtonIconVariants as y, filterButtonVariants as N } from "../../Filter.variants.js";
7
7
  import { useBadgeMultiSelect as B } from "./BadgeMultiSelect.hook.js";
8
- import { C as O } from "../../../../chevron-down-Cx07rtLP.js";
8
+ import { C as O } from "../../../../chevron-down-J5nS1Tu0.js";
9
9
  const $ = ({
10
10
  options: i,
11
11
  label: p,
@@ -5,7 +5,7 @@ import { DatePicker as w } from "../../../Datepicker/DatePicker.js";
5
5
  import { cn as o } from "../../../../utils/index.js";
6
6
  import { filterButtonIconVariants as x, filterButtonVariants as y } from "../../Filter.variants.js";
7
7
  import { useDateFilterDropdown as D } from "./DateFilterDropdown.hook.js";
8
- import { C as N } from "../../../../chevron-down-Cx07rtLP.js";
8
+ import { C as N } from "../../../../chevron-down-J5nS1Tu0.js";
9
9
  const R = ({
10
10
  label: s,
11
11
  position: l = "left",
@@ -1,9 +1,9 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { cn as c } from "../../utils/index.js";
3
3
  import { loadingVariants as i } from "./Loading.variants.js";
4
- import { c as t } from "../../createLucideIcon-DnY-81vT.js";
4
+ import { c as t } from "../../createLucideIcon-DGhJ8Z4k.js";
5
5
  /**
6
- * @license lucide-react v0.546.0 - ISC
6
+ * @license lucide-react v0.548.0 - ISC
7
7
  *
8
8
  * This source code is licensed under the ISC license.
9
9
  * See the LICENSE file in the root directory of this source tree.