@konstructio/ui 0.1.2-alpha.34 → 0.1.2-alpha.35

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,24 +1,24 @@
1
1
  import { jsxs as d, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as Y, useId as Z, useRef as C, useMemo as ee, useImperativeHandle as te, useEffect as ae } from "react";
3
- import { Loading as re } from "../../Loading/Loading.js";
4
- import { Typography as ne } from "../../Typography/Typography.js";
5
- import { cn as s } from "../../../utils/index.js";
6
- import { labelVariants as oe, inputVariants as se, dropdownVariants as le } from "../Dropdown.variants.js";
7
- import { useDropdown as ie } from "../hooks/useDropdown.js";
8
- import { List as ce } from "./List/List.js";
9
- import { c as pe } from "../../../createLucideIcon-D4r5Phnh.js";
10
- import { C as ue } from "../../../chevron-up-DrQr2Fwd.js";
2
+ import { forwardRef as Z, useId as ee, useRef as C, useMemo as te, useImperativeHandle as ae, useEffect as re } from "react";
3
+ import { L as ne } from "../../../loader-H82RiE-I.js";
4
+ import { Typography as se } from "../../Typography/Typography.js";
5
+ import { cn as o } from "../../../utils/index.js";
6
+ import { labelVariants as oe, inputVariants as le, dropdownVariants as ie } from "../Dropdown.variants.js";
7
+ import { useDropdown as ce } from "../hooks/useDropdown.js";
8
+ import { List as pe } from "./List/List.js";
9
+ import { c as ue } from "../../../createLucideIcon-D4r5Phnh.js";
10
+ import { C as me } from "../../../chevron-up-DrQr2Fwd.js";
11
11
  import { useDropdownContext as fe } from "../contexts/dropdown.hook.js";
12
- const me = [
12
+ const de = [
13
13
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
14
14
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
15
- ], de = pe("search", me), je = Y(
15
+ ], xe = ue("search", de), be = Z(
16
16
  ({
17
17
  additionalOptions: V,
18
18
  className: O,
19
19
  defaultValue: x,
20
20
  disabled: a = !1,
21
- error: f,
21
+ error: m,
22
22
  iconClassName: R,
23
23
  inputClassName: F,
24
24
  isLoading: k,
@@ -28,9 +28,9 @@ const me = [
28
28
  listClassName: D,
29
29
  listItemClassName: E,
30
30
  listItemSecondRowClassName: M,
31
- name: m,
31
+ name: f,
32
32
  placeholder: N,
33
- searchable: g = !1,
33
+ searchable: y = !1,
34
34
  showSearchIcon: w,
35
35
  theme: W,
36
36
  wrapperClassName: _,
@@ -38,52 +38,53 @@ const me = [
38
38
  onFetchMoreOptions: H,
39
39
  onBlur: P,
40
40
  onSearchChange: U,
41
- ...y
42
- }, q) => {
43
- const I = Z(), l = C(null), L = C(null), A = C(0), {
41
+ noOptionsText: q,
42
+ ...g
43
+ }, A) => {
44
+ const I = ee(), l = C(null), L = C(null), B = C(0), {
44
45
  isOpen: i,
45
- searchTerm: B,
46
- value: o,
46
+ searchTerm: G,
47
+ value: s,
47
48
  options: n,
48
49
  setValue: c,
49
- setSearchTerm: G,
50
- setCanFilter: J,
51
- toggleOpen: K
52
- } = fe(), e = ee(() => n.find(({ value: r }) => r === o), [n, o]), { wrapperRef: Q, wrapperInputRef: j, handleOpen: z } = ie({
50
+ setSearchTerm: J,
51
+ setCanFilter: K,
52
+ toggleOpen: Q
53
+ } = fe(), e = te(() => n.find(({ value: r }) => r === s), [n, s]), { wrapperRef: S, wrapperInputRef: j, handleOpen: b } = ce({
53
54
  ulRef: L,
54
55
  inputRef: l,
55
56
  disabled: a,
56
57
  internalValue: e,
57
58
  onBlur: P
58
- }), p = m ? `${I}-${m}` : I;
59
- te(q, () => l.current, [l]), ae(() => {
60
- if (x && !o) {
59
+ }), p = f ? `${I}-${f}` : I;
60
+ ae(A, () => l.current, [l]), re(() => {
61
+ if (x && !s) {
61
62
  const r = n && n.find((u) => u.value === x);
62
63
  r && c(r.value);
63
64
  }
64
- }, [x, n, c, o]);
65
- const S = (r) => {
65
+ }, [x, n, c, s]);
66
+ const X = (r) => {
66
67
  const u = r.target.value;
67
- J(!0), c(""), G(u ?? ""), U?.(u);
68
- const b = n.find(
69
- (X) => X.value.toLocaleLowerCase() === u.toLocaleLowerCase()
68
+ K(!0), c(""), J(u ?? ""), U?.(u);
69
+ const z = n.find(
70
+ (Y) => Y.value.toLocaleLowerCase() === u.toLocaleLowerCase()
70
71
  );
71
- c(b ? b.value : e?.value ?? "");
72
+ c(z ? z.value : e?.value ?? "");
72
73
  };
73
74
  return /* @__PURE__ */ d(
74
75
  "div",
75
76
  {
76
- ref: Q,
77
- className: s("flex flex-col w-full relative", _),
77
+ ref: S,
78
+ className: o("flex flex-col w-full relative", _),
78
79
  "data-theme": W,
79
80
  children: [
80
81
  v ? /* @__PURE__ */ d(
81
82
  "label",
82
83
  {
83
84
  id: p,
84
- className: s(oe({ className: T })),
85
+ className: o(oe({ className: T })),
85
86
  htmlFor: p,
86
- onClick: () => !a && z(),
87
+ onClick: () => !a && b(),
87
88
  children: [
88
89
  v,
89
90
  h && /* @__PURE__ */ t("span", { className: "text-red-600 ml-1", children: "*" })
@@ -95,30 +96,30 @@ const me = [
95
96
  {
96
97
  ref: j,
97
98
  id: p,
98
- className: s(
99
- le({ className: O, hasError: !!f, disabled: a })
99
+ className: o(
100
+ ie({ className: O, hasError: !!m, disabled: a })
100
101
  ),
101
102
  role: "combobox",
102
- onClick: () => !a && K(!i),
103
+ onClick: () => !a && Q(!i),
103
104
  "aria-expanded": i,
104
- tabIndex: A.current,
105
+ tabIndex: B.current,
105
106
  "aria-labelledby": p,
106
107
  children: [
107
108
  /* @__PURE__ */ d("div", { className: "flex gap-2.5 items-center flex-1", children: [
108
109
  e?.leftIcon && !w && /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: e.leftIcon }),
109
- w && /* @__PURE__ */ t(de, { 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" }),
110
- g ? /* @__PURE__ */ t(
110
+ w && /* @__PURE__ */ t(xe, { 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" }),
111
+ y ? /* @__PURE__ */ t(
111
112
  "input",
112
113
  {
113
114
  type: "text",
114
- value: i ? B : e?.label ?? o ?? "",
115
- onChange: S,
115
+ value: i ? G : e?.label ?? s ?? "",
116
+ onChange: X,
116
117
  placeholder: N,
117
- className: s(se({ className: F }), {
118
- "text-red-700 placeholder:text-red-700": !!f
118
+ className: o(le({ className: F }), {
119
+ "text-red-700 placeholder:text-red-700": !!m
119
120
  }),
120
121
  onClick: (r) => {
121
- r.stopPropagation(), a || z();
122
+ r.stopPropagation(), a || b();
122
123
  },
123
124
  "aria-label": v || N,
124
125
  "aria-labelledby": p,
@@ -127,16 +128,16 @@ const me = [
127
128
  autoCapitalize: "words",
128
129
  disabled: a,
129
130
  tabIndex: -1,
130
- ...y
131
+ ...g
131
132
  }
132
133
  ) : /* @__PURE__ */ t(
133
- ne,
134
+ se,
134
135
  {
135
136
  variant: "body2",
136
- className: s(
137
+ className: o(
137
138
  "flex-1 text-zinc-400 text-sm dark:text-slate-400",
138
139
  {
139
- "text-red-700": !!f,
140
+ "text-red-700": !!m,
140
141
  "select-none": !e,
141
142
  "text-slate-800 dark:text-slate-50": e,
142
143
  "text-slate-400/50 dark:text-slate-50/50": a
@@ -146,15 +147,15 @@ const me = [
146
147
  }
147
148
  )
148
149
  ] }),
149
- k ? /* @__PURE__ */ t(re, { className: "w-4 h-4 text-zinc-500 select-none" }) : !w && /* @__PURE__ */ t(
150
- ue,
150
+ k ? /* @__PURE__ */ t(ne, { className: "w-4 h-4 text-slate-400 animate-spin select-none" }) : !w && /* @__PURE__ */ t(
151
+ me,
151
152
  {
152
153
  "data-state": i ? "open" : "closed",
153
- className: s(
154
+ className: o(
154
155
  "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",
155
156
  R,
156
157
  {
157
- "text-red-700": !!f,
158
+ "text-red-700": !!m,
158
159
  "text-slate-400/50 dark:group-focus-within:text-zinc-500": a
159
160
  }
160
161
  )
@@ -168,31 +169,32 @@ const me = [
168
169
  {
169
170
  ref: l,
170
171
  type: "text",
171
- name: m,
172
+ name: f,
172
173
  className: "hidden",
173
174
  "aria-hidden": "true",
174
175
  required: h,
175
176
  inert: !0,
176
- defaultValue: e?.value ?? o ?? void 0,
177
- ...y
177
+ defaultValue: e?.value ?? s ?? void 0,
178
+ ...g
178
179
  }
179
180
  ),
180
181
  i && /* @__PURE__ */ t(
181
- ce,
182
+ pe,
182
183
  {
183
184
  ref: L,
184
185
  additionalOptions: V,
185
186
  className: D,
186
187
  itemClassName: E,
187
- name: m,
188
+ name: f,
188
189
  wrapperInputRef: j,
189
190
  inputRef: l,
190
191
  options: n,
191
192
  isLoading: !!k,
192
- searchable: g,
193
+ searchable: y,
193
194
  listItemSecondRowClassName: M,
194
195
  isInfiniteScrollEnabled: $,
195
- onFetchMoreOptions: H
196
+ onFetchMoreOptions: H,
197
+ noOptionsText: q
196
198
  }
197
199
  )
198
200
  ]
@@ -201,5 +203,5 @@ const me = [
201
203
  }
202
204
  );
203
205
  export {
204
- je as Wrapper
206
+ be as Wrapper
205
207
  };