@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 u, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as ee, useId as te, useRef as g, useMemo as ae, useImperativeHandle as re, useEffect as le } from "react";
3
- import { Typography as ne } from "../../Typography/Typography.js";
4
- import { cn as l } from "../../../utils/index.js";
5
- import { labelVariants as oe, inputVariants as se, selectVariants as ce } from "../Select.variants.js";
6
- import { useSelect as ie } from "../hooks/useSelect.js";
7
- import { List as me } from "./List/List.js";
8
- import { c as pe } from "../../../createLucideIcon-CP-mMPfa.js";
9
- import { LoaderIcon as ue } from "../../../assets/icons/components/Loader.js";
10
- import { C as fe } from "../../../chevron-up-IlDPxR7j.js";
11
- import { useSelectContext as de } from "../contexts/select.hook.js";
12
- const xe = [
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
- ], he = pe("search", xe), ze = ee(
15
+ ], ve = ue("search", he), ze = te(
16
16
  ({
17
- additionalOptions: O,
18
- className: b,
17
+ additionalOptions: z,
18
+ className: O,
19
19
  defaultValue: x,
20
- disabled: a = !1,
20
+ disabled: t = !1,
21
21
  error: f,
22
22
  iconClassName: R,
23
23
  inputClassName: F,
24
24
  isInfiniteScrollEnabled: S = !1,
25
- isLoading: k,
25
+ isLoading: g,
26
26
  isRequired: h,
27
27
  label: v,
28
- labelClassName: T,
29
- labelWrapperClassName: E,
30
- listClassName: M,
31
- listItemClassName: W,
32
- listItemSecondRowClassName: _,
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: w = !1,
37
+ searchable: k = !1,
37
38
  showSearchIcon: C,
38
- theme: H,
39
- wrapperClassName: P,
40
- onFetchMoreOptions: U,
41
- onBlur: q,
42
- onSearchChange: A,
39
+ theme: P,
40
+ wrapperClassName: U,
41
+ onFetchMoreOptions: q,
42
+ onBlur: A,
43
+ onSearchChange: B,
43
44
  ...y
44
- }, B) => {
45
- const I = te(), s = g(null), L = g(null), D = g(0), {
46
- isOpen: c,
47
- options: n,
48
- searchTerm: G,
49
- value: o,
50
- setCanFilter: J,
51
- setSearchTerm: K,
52
- setValue: i,
53
- toggleOpen: Q
54
- } = de(), e = ae(() => n.find(({ value: r }) => r === o), [n, o]), { wrapperRef: X, wrapperInputRef: V, handleOpen: j } = ie({
55
- ulRef: L,
56
- inputRef: s,
57
- disabled: a,
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: q
60
- }), m = d ? `${I}-${d}` : I;
61
- re(B, () => s.current, [s]), le(() => {
62
- if (x && !o) {
63
- const r = n && n.find((p) => p.value === x);
64
- r && i(r.value);
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, n, i, o]);
67
- const Y = (r) => {
68
- const p = r.target.value;
69
- J(!0), i(""), K(p ?? ""), A?.(p);
70
- const z = n.find(
71
- (Z) => Z.value.toLocaleLowerCase() === p.toLocaleLowerCase()
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
- i(z ? z.value : e?.value ?? "");
74
+ m(b ? b.value : e?.value ?? "");
74
75
  };
75
- return /* @__PURE__ */ u(
76
+ return /* @__PURE__ */ o(
76
77
  "div",
77
78
  {
78
- ref: X,
79
- className: l("flex flex-col gap-2 w-full relative", P),
80
- "data-theme": H,
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__ */ t("div", { className: l(E), children: /* @__PURE__ */ u(
83
- "label",
83
+ v ? /* @__PURE__ */ o(
84
+ "div",
84
85
  {
85
- id: m,
86
- className: l(oe({ className: T })),
87
- htmlFor: m,
88
- onClick: () => !a && j(),
86
+ className: n(
87
+ "flex items-center justify-between",
88
+ M
89
+ ),
89
90
  children: [
90
- v,
91
- h && /* @__PURE__ */ t("span", { className: "text-red-600 dark:text-red-500 ml-1", children: "*" })
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
- ) }) : null,
95
- /* @__PURE__ */ u(
107
+ ) : null,
108
+ /* @__PURE__ */ o(
96
109
  "div",
97
110
  {
98
- ref: V,
99
- id: m,
100
- className: l(
101
- ce({ className: b, hasError: !!f, disabled: a })
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: () => !a && Q(!c),
105
- "aria-expanded": c,
106
- tabIndex: D.current,
107
- "aria-labelledby": m,
117
+ onClick: () => !t && X(!i),
118
+ "aria-expanded": i,
119
+ tabIndex: G.current,
120
+ "aria-labelledby": p,
108
121
  children: [
109
- /* @__PURE__ */ u("div", { className: "flex gap-2.5 items-center flex-1", children: [
110
- e?.leftIcon && !C && /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center dark:text-metal-50", children: e.leftIcon }),
111
- C && /* @__PURE__ */ t(
112
- he,
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: l(
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
- w ? /* @__PURE__ */ t(
139
+ k ? /* @__PURE__ */ r(
127
140
  "input",
128
141
  {
129
142
  type: "text",
130
- value: c ? G : e?.label ?? o ?? "",
131
- onChange: Y,
143
+ value: i ? J : e?.label ?? s ?? "",
144
+ onChange: Z,
132
145
  placeholder: N,
133
- className: l(se({ className: F }), {
146
+ className: n(ce({ className: F }), {
134
147
  "text-red-700 placeholder:text-red-700": !!f
135
148
  }),
136
- onClick: (r) => {
137
- r.stopPropagation(), a || j();
149
+ onClick: (a) => {
150
+ a.stopPropagation(), t || V();
138
151
  },
139
152
  "aria-label": v || N,
140
- "aria-labelledby": m,
153
+ "aria-labelledby": p,
141
154
  required: h,
142
155
  autoComplete: "off",
143
156
  autoCapitalize: "words",
144
- disabled: a,
157
+ disabled: t,
145
158
  tabIndex: -1,
146
159
  ...y
147
160
  }
148
- ) : /* @__PURE__ */ u(
149
- ne,
161
+ ) : /* @__PURE__ */ o(
162
+ se,
150
163
  {
151
164
  variant: "body2",
152
- className: l(
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": a
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
- k ? /* @__PURE__ */ t(
171
- ue,
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__ */ t(
177
- fe,
189
+ ) : !C && /* @__PURE__ */ r(
190
+ de,
178
191
  {
179
- "data-state": c ? "open" : "closed",
180
- className: l(
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": a
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__ */ t(
206
+ /* @__PURE__ */ r(
194
207
  "input",
195
208
  {
196
- ref: s,
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 ?? o ?? void 0,
216
+ defaultValue: e?.value ?? s ?? void 0,
204
217
  ...y
205
218
  }
206
219
  ),
207
- c && /* @__PURE__ */ t(
208
- me,
220
+ i && /* @__PURE__ */ r(
221
+ pe,
209
222
  {
210
- ref: L,
211
- additionalOptions: O,
212
- className: M,
213
- itemClassName: W,
223
+ ref: j,
224
+ additionalOptions: z,
225
+ className: W,
226
+ itemClassName: _,
214
227
  name: d,
215
- wrapperInputRef: V,
216
- inputRef: s,
217
- options: n,
218
- isLoading: !!k,
219
- searchable: w,
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: U,
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.57",
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.58",
5
+ "version": "0.1.2-alpha.59",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",