@konstructio/ui 0.0.12-alpha.19 → 0.0.12-alpha.20

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,25 +1,51 @@
1
- import { jsx as e } from "react/jsx-runtime";
2
- import { forwardRef as a, useRef as p, useImperativeHandle as u } from "react";
3
- import { cn as c } from "../../../../utils/index.js";
4
- import { useNavigationUlList as d } from "../../hooks/useNavigationList.js";
5
- import { ListItem as x } from "../ListItem/ListItem.js";
6
- import { listVariants as v } from "./List.variants.js";
7
- import { useDropdownContext as L } from "../../contexts/dropdown.hook.js";
8
- const j = a(
9
- ({ options: i, theme: t, wrapperRef: m, wrapperInputRef: s, name: l }, n) => {
10
- const r = p(null), { isOpen: f } = L();
11
- return u(n, () => r.current, [r]), d({ ulRef: r, wrapperRef: m, wrapperInputRef: s }), /* @__PURE__ */ e(
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { forwardRef as c, useRef as d, useImperativeHandle as b } from "react";
3
+ import { cn as v } from "../../../../utils/index.js";
4
+ import { useNavigationUlList as x } from "../../hooks/useNavigationList.js";
5
+ import { ListItem as l } from "../ListItem/ListItem.js";
6
+ import { listVariants as L } from "./List.variants.js";
7
+ import { useDropdownContext as g } from "../../contexts/dropdown.hook.js";
8
+ const y = c(
9
+ ({ isLoading: s, options: r, theme: o, wrapperRef: a, wrapperInputRef: n, name: m }, f) => {
10
+ const e = d(null), { isOpen: p } = g();
11
+ b(f, () => e.current, [e]), x({ ulRef: e, wrapperRef: a, wrapperInputRef: n });
12
+ const u = r.length === 0;
13
+ return /* @__PURE__ */ i(
12
14
  "ul",
13
15
  {
14
- ref: r,
15
- title: l,
16
+ ref: e,
17
+ title: m,
16
18
  role: "listbox",
17
- className: c(v({ theme: t }), f ? "flex" : "hidden"),
18
- children: i.map((o) => /* @__PURE__ */ e(x, { theme: t, ...o }, o.value))
19
+ className: v(L({ theme: o }), p ? "flex" : "hidden"),
20
+ children: s ? /* @__PURE__ */ i(
21
+ l,
22
+ {
23
+ theme: o,
24
+ isClickable: !1,
25
+ value: "Loading...",
26
+ label: "Loading..."
27
+ }
28
+ ) : u ? /* @__PURE__ */ i(
29
+ l,
30
+ {
31
+ theme: o,
32
+ isClickable: !1,
33
+ value: "No options",
34
+ label: "No options"
35
+ }
36
+ ) : r.map((t) => /* @__PURE__ */ i(
37
+ l,
38
+ {
39
+ theme: o,
40
+ isClickable: !0,
41
+ ...t
42
+ },
43
+ t.value
44
+ ))
19
45
  }
20
46
  );
21
47
  }
22
48
  );
23
49
  export {
24
- j as List
50
+ y as List
25
51
  };
@@ -1,37 +1,41 @@
1
- import { jsxs as f, jsx as o } from "react/jsx-runtime";
2
- import { useRef as p, useCallback as s } from "react";
3
- import { cn as u } from "../../../../utils/index.js";
4
- import { listItemVariants as d } from "./ListItem.variants.js";
5
- import { Typography as h } from "../../../Typography/Typography.js";
6
- import { useDropdownContext as x } from "../../contexts/dropdown.hook.js";
7
- const g = ({ theme: a, ...e }) => {
8
- const { setValue: n, toggleOpen: r } = x(), c = p(null), l = s(
1
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
2
+ import { useRef as u, useCallback as s } from "react";
3
+ import { cn as d } from "../../../../utils/index.js";
4
+ import { listItemVariants as h } from "./ListItem.variants.js";
5
+ import { Typography as x } from "../../../Typography/Typography.js";
6
+ import { useDropdownContext as y } from "../../contexts/dropdown.hook.js";
7
+ const j = ({
8
+ isClickable: a,
9
+ theme: c,
10
+ ...e
11
+ }) => {
12
+ const { setValue: n, toggleOpen: r } = y(), i = u(null), l = s(
9
13
  (t) => {
10
14
  n(t.value), r(!1);
11
15
  },
12
16
  [n, r]
13
- ), i = s(
14
- (t, m) => {
15
- t.key === "Enter" && l(m);
17
+ ), m = s(
18
+ (t, f) => {
19
+ t.key === "Enter" && l(f);
16
20
  },
17
21
  [l]
18
22
  );
19
- return /* @__PURE__ */ f(
23
+ return /* @__PURE__ */ p(
20
24
  "li",
21
25
  {
22
- ref: c,
26
+ ref: i,
23
27
  role: "option",
24
- className: u(d({ theme: a })),
28
+ className: d(h({ theme: c })),
25
29
  tabIndex: 0,
26
- onClick: () => l(e),
27
- onKeyDown: (t) => i(t, e),
30
+ onClick: () => a && l(e),
31
+ onKeyDown: (t) => m(t, e),
28
32
  children: [
29
33
  e.leftIcon ? /* @__PURE__ */ o("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null,
30
- /* @__PURE__ */ o(h, { variant: "body2", className: "text-zinc-700", children: e.label })
34
+ /* @__PURE__ */ o(x, { variant: "body2", className: "text-zinc-700", children: e.label })
31
35
  ]
32
36
  }
33
37
  );
34
38
  };
35
39
  export {
36
- g as ListItem
40
+ j as ListItem
37
41
  };
@@ -1,27 +1,27 @@
1
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";
2
+ import { forwardRef as H, useId as M, useRef as O, useImperativeHandle as U, useMemo as W, useEffect as p } from "react";
3
3
  import { cn as u } from "../../../utils/index.js";
4
4
  import { labelVariants as B, dropdownVariants as G } from "../Dropdown.variants.js";
5
5
  import { useDropdown as J } from "../hooks/useDropdown.js";
6
6
  import { List as K } from "./List/List.js";
7
- import { Typography as O } from "../../Typography/Typography.js";
7
+ import { Typography as z } from "../../Typography/Typography.js";
8
8
  import { Loading as P } from "../../Loading/Loading.js";
9
9
  import { C as Q } from "../../../chevron-up-DgLBQCKD.js";
10
10
  import { useDropdownContext as S } from "../contexts/dropdown.hook.js";
11
11
  import { useTheme as X } from "../../../contexts/theme.hook.js";
12
12
  const ae = H(
13
13
  ({
14
- theme: z,
14
+ theme: T,
15
15
  label: h,
16
- labelClassName: T,
17
- placeholder: j,
16
+ labelClassName: j,
17
+ placeholder: E,
18
18
  name: l,
19
19
  options: n,
20
20
  required: x,
21
21
  defaultValue: f,
22
- isLoading: E
22
+ isLoading: v
23
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;
24
+ const b = M(), s = O(null), w = O(null), { wrapperRef: a, wrapperInputRef: N, handleOpen: k, handleOpenIfClosed: D } = J({ ulRef: w }), { isOpen: g, toggleOpen: C, value: r, setValue: I } = S(), { theme: F } = X(), d = T ?? F, c = l ? `${b}-${l}` : b;
25
25
  U(L, () => s.current, [s]);
26
26
  const e = W(() => n.find(({ value: o }) => o === r), [n, r]);
27
27
  p(() => {
@@ -29,19 +29,19 @@ const ae = H(
29
29
  }, [e, r]), p(() => {
30
30
  if (f && !r) {
31
31
  const o = n && n.find((i) => i.value === f);
32
- o && C(o.value);
32
+ o && I(o.value);
33
33
  }
34
- }, [f, n, C, r]), p(() => {
34
+ }, [f, n, I, r]), p(() => {
35
35
  var i;
36
36
  const o = new AbortController();
37
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);
38
+ var R;
39
+ const y = A.relatedTarget;
40
+ (!y || !((R = a.current) != null && R.contains(y))) && C(!1);
41
41
  }), () => {
42
42
  o.abort();
43
43
  };
44
- }, [g, a]);
44
+ }, [C, a]);
45
45
  const $ = () => e != null && e.leftIcon ? /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null;
46
46
  return /* @__PURE__ */ m("div", { ref: a, className: "flex flex-col w-full relative", children: [
47
47
  h ? /* @__PURE__ */ m(
@@ -50,7 +50,7 @@ const ae = H(
50
50
  id: c,
51
51
  className: u(
52
52
  B({ theme: d }),
53
- T
53
+ j
54
54
  ),
55
55
  htmlFor: c,
56
56
  onClick: D,
@@ -63,17 +63,17 @@ const ae = H(
63
63
  /* @__PURE__ */ m(
64
64
  "div",
65
65
  {
66
- ref: w,
66
+ ref: N,
67
67
  id: c,
68
68
  className: u(G({ theme: d })),
69
69
  role: "combobox",
70
70
  onClick: k,
71
- "aria-expanded": N,
71
+ "aria-expanded": g,
72
72
  tabIndex: 0,
73
73
  "aria-labelledby": c,
74
74
  children: [
75
75
  /* @__PURE__ */ t("span", { className: "text-base text-inherit", children: r ? /* @__PURE__ */ m(
76
- O,
76
+ z,
77
77
  {
78
78
  variant: "body2",
79
79
  className: "flex gap-3 items-center text-zinc-700",
@@ -83,19 +83,19 @@ const ae = H(
83
83
  ]
84
84
  }
85
85
  ) : /* @__PURE__ */ t(
86
- O,
86
+ z,
87
87
  {
88
88
  variant: "body2",
89
89
  className: "flex gap-3 items-center text-zinc-700",
90
- children: j
90
+ children: E
91
91
  }
92
92
  ) }),
93
- E ? /* @__PURE__ */ t(P, { className: "w-4 h-4 text-zinc-500" }) : /* @__PURE__ */ t(
93
+ v ? /* @__PURE__ */ t(P, { className: "w-4 h-4 text-zinc-500" }) : /* @__PURE__ */ t(
94
94
  Q,
95
95
  {
96
96
  className: u(
97
97
  "w-4 h-4 text-zinc-500 transition-all duration-50",
98
- N ? "rotate-0" : "rotate-180"
98
+ g ? "rotate-0" : "rotate-180"
99
99
  )
100
100
  }
101
101
  )
@@ -116,11 +116,12 @@ const ae = H(
116
116
  /* @__PURE__ */ t(
117
117
  K,
118
118
  {
119
- ref: b,
119
+ ref: w,
120
120
  name: l,
121
121
  wrapperRef: a,
122
- wrapperInputRef: w,
122
+ wrapperInputRef: N,
123
123
  options: n,
124
+ isLoading: !!v,
124
125
  theme: d
125
126
  }
126
127
  )
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.18",
5
+ "version": "0.0.12-alpha.19",
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.19",
5
+ "version": "0.0.12-alpha.20",
6
6
  "type": "module",
7
7
  "license": "MIT",
8
8
  "main": "dist/index.js",