@konstructio/ui 0.0.12-alpha.9 → 0.0.13-alpha.1

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.
Files changed (144) hide show
  1. package/dist/{Modal-B-E9uaA6.js → Modal-i7eolhYH.js} +311 -307
  2. package/dist/components/Alert/Alert.js +24 -29
  3. package/dist/components/Alert/Alert.variants.js +9 -15
  4. package/dist/components/AlertDialog/AlertDialog.js +59 -46
  5. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +2 -2
  6. package/dist/components/AlertDialog/components/index.js +1 -1
  7. package/dist/components/Autocomplete/Autocomplete.js +76 -72
  8. package/dist/components/Autocomplete/Autocomplete.variants.js +11 -20
  9. package/dist/components/Autocomplete/components/List/List.js +28 -30
  10. package/dist/components/Autocomplete/components/List/List.variants.js +34 -40
  11. package/dist/components/Breadcrumb/Breadcrumb.js +47 -56
  12. package/dist/components/Breadcrumb/Breadcrumb.variants.js +6 -26
  13. package/dist/components/Breadcrumb/components/Item/Item.js +29 -41
  14. package/dist/components/Breadcrumb/components/Item/Item.variants.js +2 -20
  15. package/dist/components/Button/Button.js +33 -37
  16. package/dist/components/Button/Button.variants.js +138 -195
  17. package/dist/components/Card/Card.js +32 -37
  18. package/dist/components/Card/Card.variants.js +18 -53
  19. package/dist/components/Checkbox/Checkbox.js +65 -68
  20. package/dist/components/Checkbox/Checkbox.variants.js +11 -35
  21. package/dist/components/Command/Command.js +33 -25
  22. package/dist/components/Command/Command.variants.js +47 -94
  23. package/dist/components/Command/components/Command.js +1 -1
  24. package/dist/components/Command/components/CommandEmpty.js +1 -1
  25. package/dist/components/Command/components/CommandGroup.js +1 -1
  26. package/dist/components/Command/components/CommandInput.js +1 -1
  27. package/dist/components/Command/components/CommandItem.js +1 -1
  28. package/dist/components/Command/components/CommandList.js +1 -1
  29. package/dist/components/Command/components/CommandSeparator.js +1 -1
  30. package/dist/components/Command/components/DialogContent.js +1 -1
  31. package/dist/components/Command/components/DialogOverlay.js +8 -8
  32. package/dist/components/Divider/Divider.js +3 -2
  33. package/dist/components/Divider/Divider.variants.js +12 -9
  34. package/dist/components/Dropdown/Dropdown.js +6 -6
  35. package/dist/components/Dropdown/Dropdown.variants.js +31 -38
  36. package/dist/components/Dropdown/components/List/List.js +17 -15
  37. package/dist/components/Dropdown/components/List/List.variants.js +22 -32
  38. package/dist/components/Dropdown/components/ListItem/ListItem.js +20 -19
  39. package/dist/components/Dropdown/components/ListItem/ListItem.variants.js +18 -30
  40. package/dist/components/Dropdown/components/Wrapper.js +127 -90
  41. package/dist/components/Dropdown/contexts/dropdown.context.js +1 -1
  42. package/dist/components/Dropdown/contexts/dropdown.provider.js +9 -9
  43. package/dist/components/Input/Input.js +37 -37
  44. package/dist/components/Input/Input.variants.js +8 -13
  45. package/dist/components/Loading/Loading.js +60 -58
  46. package/dist/components/Loading/Loading.variants.js +9 -15
  47. package/dist/components/Modal/Modal.js +2 -2
  48. package/dist/components/Modal/components/Body/Body.js +1 -1
  49. package/dist/components/Modal/components/Footer/Footer.js +2 -2
  50. package/dist/components/Modal/components/Header/Header.js +3 -3
  51. package/dist/components/Modal/components/Wrapper/Wrapper.js +3 -4
  52. package/dist/components/Modal/components/Wrapper/Wrapper.variants.js +32 -46
  53. package/dist/components/Modal/components/index.js +1 -1
  54. package/dist/components/NumberInput/NumberInput.js +93 -111
  55. package/dist/components/NumberInput/NumberInput.variants.js +30 -51
  56. package/dist/components/ProgressBar/ProgressBar.js +25 -29
  57. package/dist/components/ProgressBar/ProgressBar.variants.js +10 -31
  58. package/dist/components/Radio/Radio.js +45 -46
  59. package/dist/components/Radio/Radio.variants.js +4 -13
  60. package/dist/components/RadioCard/RadioCard.js +31 -37
  61. package/dist/components/RadioCard/RadioCard.variants.js +8 -17
  62. package/dist/components/RadioCardGroup/RadioCardGroup.js +22 -23
  63. package/dist/components/RadioCardGroup/RadioCardGroup.variants.js +3 -9
  64. package/dist/components/RadioGroup/RadioGroup.js +30 -31
  65. package/dist/components/RadioGroup/RadioGroup.variants.js +2 -8
  66. package/dist/components/Range/Range.js +28 -34
  67. package/dist/components/Range/Range.variants.js +21 -53
  68. package/dist/components/Sidebar/Sidebar.js +12 -13
  69. package/dist/components/Sidebar/Sidebar.variants.js +30 -56
  70. package/dist/components/Sidebar/components/Footer/Footer.js +5 -17
  71. package/dist/components/Sidebar/components/Footer/Footer.variants.js +9 -16
  72. package/dist/components/Sidebar/components/Logo/Logo.js +5 -15
  73. package/dist/components/Sidebar/components/Logo/Logo.variants.js +20 -36
  74. package/dist/components/Sidebar/components/Navigation/Navigation.js +15 -28
  75. package/dist/components/Sidebar/components/Navigation/Navigation.variants.js +3 -17
  76. package/dist/components/Sidebar/components/NavigationGroup/NavigationGroup.js +21 -34
  77. package/dist/components/Sidebar/components/NavigationGroup/NavigationGroup.variants.js +2 -13
  78. package/dist/components/Sidebar/components/NavigationOption/NavigationOption.js +21 -27
  79. package/dist/components/Sidebar/components/NavigationOption/NavigationOption.variants.js +7 -17
  80. package/dist/components/Sidebar/components/NavigationSeparator/NavigationSeparator.js +7 -19
  81. package/dist/components/Sidebar/components/NavigationSeparator/NavigationSeparator.variants.js +6 -16
  82. package/dist/components/Sidebar/components/NavigationTitle/NavigationTitle.js +8 -21
  83. package/dist/components/Sidebar/components/NavigationTitle/NavigationTitle.variants.js +11 -20
  84. package/dist/components/Sidebar/components/Wrapper/Wrapper.js +41 -44
  85. package/dist/components/Slider/Slider.js +26 -27
  86. package/dist/components/Slider/Slider.variants.js +22 -34
  87. package/dist/components/Switch/Switch.js +103 -106
  88. package/dist/components/Switch/Switch.variants.js +28 -53
  89. package/dist/components/Table/Table.js +27 -0
  90. package/dist/components/Table/Table.variants.js +40 -0
  91. package/dist/components/Table/components/Body.js +18 -0
  92. package/dist/components/Table/components/Filter.js +9 -0
  93. package/dist/components/Table/components/Head.js +18 -0
  94. package/dist/components/Table/components/Row.js +28 -0
  95. package/dist/components/Table/components/index.js +10 -0
  96. package/dist/components/Tag/Tag.js +1 -1
  97. package/dist/components/TagSelect/TagSelect.variants.js +23 -55
  98. package/dist/components/TagSelect/components/Item/Item.js +12 -14
  99. package/dist/components/TagSelect/components/Item/Item.variants.js +11 -10
  100. package/dist/components/TagSelect/components/List/List.js +9 -10
  101. package/dist/components/TagSelect/components/List/List.variants.js +21 -35
  102. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +46 -48
  103. package/dist/components/TextArea/TextArea.js +20 -23
  104. package/dist/components/TextArea/TextArea.variants.js +19 -31
  105. package/dist/components/Toast/Toast.js +110 -116
  106. package/dist/components/Toast/Toast.variants.js +42 -70
  107. package/dist/components/Tooltip/Tooltip.js +21 -27
  108. package/dist/components/Tooltip/Tooltip.variants.js +61 -62
  109. package/dist/components/Typography/Typography.js +23 -19
  110. package/dist/components/Typography/Typography.variants.js +1 -7
  111. package/dist/components/index.js +22 -20
  112. package/dist/contexts/theme.provider.js +37 -39
  113. package/dist/domain/theme.js +0 -0
  114. package/dist/index-AM3avohj.js +133 -0
  115. package/dist/{index-BzaHYXkt.js → index-BOx5P4tS.js} +5 -5
  116. package/dist/index-Bk324h27.js +82 -0
  117. package/dist/{index-4ecjw_Aj.js → index-Bry5AFQ2.js} +1 -1
  118. package/dist/{index-CbTU3cnP.js → index-CWKdynYu.js} +1 -1
  119. package/dist/index-D9BbbgUq.js +47 -0
  120. package/dist/{index-DyKo5ZJT.js → index-DvFiic6N.js} +45 -45
  121. package/dist/{index-Dj1pom3_.js → index-G_6jG4Qc.js} +2 -2
  122. package/dist/{index-D_76wh4w.js → index-YaQrdkGE.js} +3 -3
  123. package/dist/{index-Cva-e5M4.js → index-bYyfdsls.js} +9 -9
  124. package/dist/index-dRxIWVBr.js +313 -0
  125. package/dist/{index-D7QNmo_D.js → index-g-TFwd6Y.js} +41 -41
  126. package/dist/index.d.ts +115 -98
  127. package/dist/index.js +30 -30
  128. package/dist/package.json +37 -36
  129. package/dist/styles.css +1 -1
  130. package/dist/ui/kubefirst-theme.css +296 -0
  131. package/dist/ui/theme.css +6 -0
  132. package/dist/ui/utilities.css +165 -0
  133. package/dist/utils/index.js +675 -424
  134. package/package.json +37 -36
  135. package/dist/components/AlertDialog/AlertDialog.variants.js +0 -15
  136. package/dist/index-B_6_jmOO.js +0 -68
  137. package/dist/index-BbsJ0VIJ.js +0 -47
  138. package/dist/index-CzSBQN5S.js +0 -432
  139. package/dist/index-DUA6Y_AE.js +0 -126
  140. package/dist/plugins/index.js +0 -4
  141. package/dist/plugins/konstruct.js +0 -118
  142. package/dist/plugins/utils/animation.styles.js +0 -162
  143. package/dist/plugins/utils/colors.js +0 -331
  144. package/dist/plugins/utils/index.js +0 -7
@@ -1,9 +1,10 @@
1
- import { jsx as e } from "react/jsx-runtime";
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import { cn as o } from "../../utils/index.js";
2
3
  import { dividerVariants as a } from "./Divider.variants.js";
3
4
  const d = ({
4
5
  className: i,
5
6
  ...r
6
- }) => /* @__PURE__ */ e("div", { className: a({ className: i }), ...r });
7
+ }) => /* @__PURE__ */ m("div", { className: o(a({ className: i })), ...r });
7
8
  d.displayName = "Divider";
8
9
  export {
9
10
  d as Divider
@@ -1,14 +1,17 @@
1
1
  import { c as a } from "../../index-BNmRGtA6.js";
2
- const i = a(["h-[1px]", "bg-zinc-200", "w-full"], {
3
- variants: {
4
- variant: {
5
- default: ""
2
+ const t = a(
3
+ ["h-[1px]", "bg-zinc-200", "w-full", "border-gray-200"],
4
+ {
5
+ variants: {
6
+ variant: {
7
+ default: ""
8
+ }
9
+ },
10
+ defaultVariants: {
11
+ variant: "default"
6
12
  }
7
- },
8
- defaultVariants: {
9
- variant: "default"
10
13
  }
11
- });
14
+ );
12
15
  export {
13
- i as dividerVariants
16
+ t as dividerVariants
14
17
  };
@@ -1,8 +1,8 @@
1
- import { jsx as r } from "react/jsx-runtime";
2
- import { forwardRef as f } from "react";
3
- import { DropdownProvider as i } from "./contexts/dropdown.provider.js";
4
- import { Wrapper as t } from "./components/Wrapper.js";
5
- const a = f(({ onChange: o, ...p }, m) => /* @__PURE__ */ r(i, { onChange: o, children: /* @__PURE__ */ r(t, { ref: m, ...p }) }));
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
- a as Dropdown
7
+ x as Dropdown
8
8
  };
@@ -1,41 +1,34 @@
1
1
  import { c as e } from "../../index-BNmRGtA6.js";
2
- const a = e(
3
- [
4
- "border",
5
- "cursor-pointer",
6
- "ease-in-out",
7
- "flex",
8
- "items-center",
9
- "justify-between",
10
- "px-3",
11
- "py-1",
12
- "relative",
13
- "rounded-md",
14
- "transition-all",
15
- "w-full",
16
- "outline-none"
17
- ],
18
- {
19
- variants: {
20
- theme: {
21
- kubefirst: [
22
- "aria-expanded:border-kubefirst-primary",
23
- "aria-expanded:text-kubefirst-secondary",
24
- "focus-visible:bg-purple-100"
25
- ],
26
- colony: [
27
- "aria-expanded:border-red-400",
28
- "aria-expanded:text-red-400",
29
- "focus-visible:bg-red-100"
30
- ],
31
- civo: ""
32
- }
33
- },
34
- defaultVariants: {
35
- theme: "kubefirst"
36
- }
37
- }
38
- );
2
+ const o = e([
3
+ "border",
4
+ "cursor-pointer",
5
+ "ease-in-out",
6
+ "flex",
7
+ "items-center",
8
+ "justify-between",
9
+ "px-3",
10
+ "py-1",
11
+ "relative",
12
+ "rounded-md",
13
+ "transition-all",
14
+ "w-full",
15
+ "outline-none",
16
+ "h-9",
17
+ "border-gray-200",
18
+ "aria-expanded:border-kubefirst-primary",
19
+ "aria-expanded:text-kubefirst-secondary",
20
+ "focus-visible:bg-zinc-50",
21
+ "colony:aria-expanded:border-red-400",
22
+ "colony:aria-expanded:text-red-400",
23
+ "colony:focus-visible:bg-red-100"
24
+ ]), a = e([
25
+ "mb-1",
26
+ "cursor-pointer",
27
+ "text-[14px]",
28
+ "leading-[20px]",
29
+ "tracking-[0.1px]"
30
+ ]);
39
31
  export {
40
- a as dropdownVariants
32
+ o as dropdownVariants,
33
+ a as labelVariants
41
34
  };
@@ -1,25 +1,27 @@
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";
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as u, useRef as c, useImperativeHandle as d } from "react";
3
+ import { cn as b } from "../../../../utils/index.js";
4
+ import { useNavigationUlList as v } from "../../hooks/useNavigationList.js";
5
+ import { ListItem as t } from "../ListItem/ListItem.js";
6
+ import { listVariants as x } from "./List.variants.js";
7
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(
8
+ const I = u(
9
+ ({ isLoading: r, options: i, wrapperRef: s, wrapperInputRef: a, name: m }, n) => {
10
+ const e = c(null), { isOpen: f } = L();
11
+ d(n, () => e.current, [e]), v({ ulRef: e, wrapperRef: s, wrapperInputRef: a });
12
+ const p = i.length === 0;
13
+ return /* @__PURE__ */ o(
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: b(x(), f ? "flex" : "hidden"),
20
+ children: r ? /* @__PURE__ */ o(t, { isClickable: !1, value: "Loading...", label: "Loading..." }) : p ? /* @__PURE__ */ o(t, { isClickable: !1, value: "No options", label: "No options" }) : i.map((l) => /* @__PURE__ */ o(t, { isClickable: !0, ...l }, l.value))
19
21
  }
20
22
  );
21
23
  }
22
24
  );
23
25
  export {
24
- j as List
26
+ I as List
25
27
  };
@@ -1,34 +1,24 @@
1
- import { c as t } from "../../../../index-BNmRGtA6.js";
2
- const o = t(
3
- [
4
- "absolute",
5
- "bg-white",
6
- "border",
7
- "duration-100",
8
- "ease-in-out",
9
- "flex-col",
10
- "mt-1",
11
- "overflow-hidden",
12
- "rounded-md",
13
- "shadow-sm",
14
- "top-full",
15
- "transition-all",
16
- "w-full",
17
- "z-10"
18
- ],
19
- {
20
- variants: {
21
- theme: {
22
- colony: ["border-red-400"],
23
- kubefirst: [""],
24
- civo: ""
25
- }
26
- },
27
- defaultVariants: {
28
- theme: "kubefirst"
29
- }
30
- }
31
- );
1
+ import { c as o } from "../../../../index-BNmRGtA6.js";
2
+ const r = o([
3
+ "absolute",
4
+ "bg-white",
5
+ "border",
6
+ "duration-100",
7
+ "ease-in-out",
8
+ "flex-col",
9
+ "mt-1",
10
+ "overflow-hidden",
11
+ "rounded-md",
12
+ "shadow-2xs",
13
+ "top-full",
14
+ "transition-all",
15
+ "w-full",
16
+ "z-10",
17
+ "max-h-[185px]",
18
+ "overflow-y-auto",
19
+ "border-gray-200",
20
+ "text-zinc-700"
21
+ ]);
32
22
  export {
33
- o as listVariants
23
+ r as listVariants
34
24
  };
@@ -1,36 +1,37 @@
1
- import { jsxs as f, jsx as i } from "react/jsx-runtime";
2
- import { useRef as u, useCallback as r } from "react";
3
- import { cn as d } from "../../../../utils/index.js";
4
- import { listItemVariants as p } from "./ListItem.variants.js";
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";
5
6
  import { useDropdownContext as x } from "../../contexts/dropdown.hook.js";
6
- const C = ({ theme: o, ...e }) => {
7
- const { setValue: n, toggleOpen: s } = x(), c = u(null), t = r(
8
- (l) => {
9
- n(l), s(!1);
7
+ const g = ({ isClickable: a, ...e }) => {
8
+ const { setValue: n, toggleOpen: r } = x(), c = p(null), l = s(
9
+ (t) => {
10
+ n(t.value), r(!1);
10
11
  },
11
- [n, s]
12
- ), a = r(
13
- (l, m) => {
14
- l.key === "Enter" && t(m);
12
+ [n, r]
13
+ ), i = s(
14
+ (t, m) => {
15
+ t.key === "Enter" && l(m);
15
16
  },
16
- [t]
17
+ [l]
17
18
  );
18
19
  return /* @__PURE__ */ f(
19
20
  "li",
20
21
  {
21
22
  ref: c,
22
23
  role: "option",
23
- className: d(p({ theme: o })),
24
+ className: u(d()),
24
25
  tabIndex: 0,
25
- onClick: () => t(e),
26
- onKeyDown: (l) => a(l, e),
26
+ onClick: () => a && l(e),
27
+ onKeyDown: (t) => i(t, e),
27
28
  children: [
28
- e.leftIcon ? /* @__PURE__ */ i("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null,
29
- e.label
29
+ 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 })
30
31
  ]
31
32
  }
32
33
  );
33
34
  };
34
35
  export {
35
- C as ListItem
36
+ g as ListItem
36
37
  };
@@ -1,32 +1,20 @@
1
- import { c as e } from "../../../../index-BNmRGtA6.js";
2
- const o = e(
3
- [
4
- "cursor-pointer",
5
- "py-2",
6
- "px-2",
7
- "h-full",
8
- "focus-visible:outline-none",
9
- "m-0",
10
- "w-full",
11
- "flex",
12
- "items-center",
13
- "gap-3",
14
- "hover:bg-slate-50",
15
- "focus:bg-slate-50"
16
- ],
17
- {
18
- variants: {
19
- theme: {
20
- kubefirst: [""],
21
- colony: ["focus:bg-red-100", "hover:bg-red-100"],
22
- civo: ""
23
- }
24
- },
25
- defaultVariants: {
26
- theme: "kubefirst"
27
- }
28
- }
29
- );
1
+ import { c as o } from "../../../../index-BNmRGtA6.js";
2
+ const l = o([
3
+ "cursor-pointer",
4
+ "py-2",
5
+ "px-2",
6
+ "h-full",
7
+ "focus-visible:outline-none",
8
+ "m-0",
9
+ "w-full",
10
+ "flex",
11
+ "items-center",
12
+ "gap-3",
13
+ "hover:bg-slate-50",
14
+ "focus:bg-slate-50",
15
+ "colony:focus:bg-red-100",
16
+ "colony:hover:bg-red-100"
17
+ ]);
30
18
  export {
31
- o as listItemVariants
19
+ l as listItemVariants
32
20
  };
@@ -1,99 +1,136 @@
1
- import { jsxs as f, jsx as t } from "react/jsx-runtime";
2
- import { forwardRef as F, useId as L, useRef as N, useImperativeHandle as $, useEffect as m } from "react";
3
- import { cn as R } from "../../../utils/index.js";
4
- import { dropdownVariants as A } from "../Dropdown.variants.js";
5
- import { useDropdown as H } from "../hooks/useDropdown.js";
6
- import { List as U } from "./List/List.js";
7
- import { C as W } from "../../../chevron-up-DgLBQCKD.js";
8
- import { useDropdownContext as q } from "../contexts/dropdown.hook.js";
9
- import { useTheme as z } from "../../../contexts/theme.hook.js";
10
- const X = F(
11
- ({ theme: g, label: p, placeholder: O, name: o, options: a, defaultValue: c }, j) => {
12
- const d = L(), r = N(null), u = N(null), { wrapperRef: n, wrapperInputRef: h, handleOpen: y, handleOpenIfClosed: E } = H({ ulRef: u }), { isOpen: x, value: e, setValue: w, toggleOpen: b } = q(), { theme: T } = z(), v = g ?? T, s = o ? `${d}-${o}` : d;
13
- $(j, () => r.current, [r]), m(() => {
14
- r.current && (r.current.value = e ? e.value : "");
15
- }, [e]), m(() => {
16
- if (c) {
17
- const l = a.find(
18
- (i) => i.value === c
19
- );
20
- l && w(l);
1
+ import { jsxs as f, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as $, useId as A, useRef as R, useImperativeHandle as H, useMemo as M, useEffect as m } from "react";
3
+ import { Loading as U } from "../../Loading/Loading.js";
4
+ import { Typography as O } from "../../Typography/Typography.js";
5
+ import { cn as p } from "../../../utils/index.js";
6
+ import { labelVariants as W, dropdownVariants as B } from "../Dropdown.variants.js";
7
+ import { useDropdown as G } from "../hooks/useDropdown.js";
8
+ import { List as J } from "./List/List.js";
9
+ import { C as K } from "../../../chevron-up-DgLBQCKD.js";
10
+ import { useDropdownContext as P } from "../contexts/dropdown.hook.js";
11
+ const re = $(
12
+ ({
13
+ theme: z,
14
+ label: u,
15
+ labelClassName: j,
16
+ placeholder: E,
17
+ name: s,
18
+ options: n,
19
+ required: x,
20
+ defaultValue: d,
21
+ isLoading: h
22
+ }, L) => {
23
+ const v = A(), a = R(null), b = R(null), { wrapperRef: l, wrapperInputRef: w, handleOpen: k, handleOpenIfClosed: D } = G({ ulRef: b }), { isOpen: N, toggleOpen: g, value: t, setValue: I } = P(), c = s ? `${v}-${s}` : v;
24
+ H(L, () => a.current, [a]);
25
+ const e = M(() => n.find(({ value: o }) => o === t), [n, t]);
26
+ m(() => {
27
+ a.current && (a.current.value = t ? e == null ? void 0 : e.value : "");
28
+ }, [e, t]), m(() => {
29
+ if (d && !t) {
30
+ const o = n && n.find((i) => i.value === d);
31
+ o && I(o.value);
21
32
  }
22
- }, [c, a, w]), m(() => {
33
+ }, [d, n, I, t]), m(() => {
23
34
  var i;
24
- const l = new AbortController();
25
- return (i = n.current) == null || i.addEventListener("focusout", (D) => {
26
- var I;
27
- const C = D.relatedTarget;
28
- (!C || !((I = n.current) != null && I.contains(C))) && b(!1);
35
+ const o = new AbortController();
36
+ return (i = l.current) == null || i.addEventListener("focusout", (T) => {
37
+ var C;
38
+ const y = T.relatedTarget;
39
+ (!y || !((C = l.current) != null && C.contains(y))) && g(!1);
29
40
  }), () => {
30
- l.abort();
41
+ o.abort();
31
42
  };
32
- }, [b, n]);
33
- const k = () => e != null && e.leftIcon ? /* @__PURE__ */ t("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null;
34
- return /* @__PURE__ */ f("div", { ref: n, className: "flex flex-col w-full relative", children: [
35
- p ? /* @__PURE__ */ t(
36
- "label",
37
- {
38
- id: s,
39
- className: "mb-2 cursor-pointer",
40
- htmlFor: s,
41
- onClick: E,
42
- children: p
43
- }
44
- ) : null,
45
- /* @__PURE__ */ f(
46
- "div",
47
- {
48
- ref: h,
49
- id: s,
50
- className: R(A({ theme: v })),
51
- role: "combobox",
52
- onClick: y,
53
- "aria-expanded": x,
54
- tabIndex: 0,
55
- "aria-labelledby": s,
56
- children: [
57
- /* @__PURE__ */ t("span", { className: "text-base text-inherit", children: e ? /* @__PURE__ */ f("span", { className: "flex gap-3 items-center", children: [
58
- k(),
59
- e.label
60
- ] }) : O }),
61
- /* @__PURE__ */ t(
62
- W,
63
- {
64
- className: R(
65
- "w-4 h-4 text-inherit transition-all duration-50",
66
- x ? "rotate-0" : "rotate-180"
43
+ }, [g, l]);
44
+ const F = () => e != null && e.leftIcon ? /* @__PURE__ */ r("span", { className: "w-4 h-4 flex justify-center items-center", children: e.leftIcon }) : null;
45
+ return /* @__PURE__ */ f(
46
+ "div",
47
+ {
48
+ ref: l,
49
+ className: "flex flex-col w-full relative",
50
+ "data-theme": z,
51
+ children: [
52
+ u ? /* @__PURE__ */ f(
53
+ "label",
54
+ {
55
+ id: c,
56
+ className: p(W({ className: j })),
57
+ htmlFor: c,
58
+ onClick: D,
59
+ children: [
60
+ u,
61
+ x ? /* @__PURE__ */ r("span", { className: "text-red-500 ml-1", children: "*" }) : null
62
+ ]
63
+ }
64
+ ) : null,
65
+ /* @__PURE__ */ f(
66
+ "div",
67
+ {
68
+ ref: w,
69
+ id: c,
70
+ className: p(B()),
71
+ role: "combobox",
72
+ onClick: k,
73
+ "aria-expanded": N,
74
+ tabIndex: 0,
75
+ "aria-labelledby": c,
76
+ children: [
77
+ t ? /* @__PURE__ */ f(
78
+ O,
79
+ {
80
+ variant: "body2",
81
+ className: "flex gap-3 items-center text-zinc-700 text-base",
82
+ children: [
83
+ F(),
84
+ e == null ? void 0 : e.label
85
+ ]
86
+ }
87
+ ) : /* @__PURE__ */ r(
88
+ O,
89
+ {
90
+ variant: "body2",
91
+ className: "flex gap-3 items-center text-zinc-700 text-base",
92
+ children: E
93
+ }
94
+ ),
95
+ h ? /* @__PURE__ */ r(U, { className: "w-4 h-4 text-zinc-500" }) : /* @__PURE__ */ r(
96
+ K,
97
+ {
98
+ className: p(
99
+ "w-4 h-4 text-zinc-500 transition-all duration-50",
100
+ N ? "rotate-0" : "rotate-180"
101
+ )
102
+ }
67
103
  )
68
- }
69
- )
70
- ]
71
- }
72
- ),
73
- /* @__PURE__ */ t(
74
- "input",
75
- {
76
- ref: r,
77
- type: "text",
78
- name: o,
79
- className: "hidden",
80
- "aria-hidden": "true"
81
- }
82
- ),
83
- /* @__PURE__ */ t(
84
- U,
85
- {
86
- ref: u,
87
- name: o,
88
- wrapperRef: n,
89
- wrapperInputRef: h,
90
- options: a,
91
- theme: v
92
- }
93
- )
94
- ] });
104
+ ]
105
+ }
106
+ ),
107
+ /* @__PURE__ */ r(
108
+ "input",
109
+ {
110
+ ref: a,
111
+ type: "text",
112
+ name: s,
113
+ className: "hidden",
114
+ "aria-hidden": "true",
115
+ required: x
116
+ }
117
+ ),
118
+ /* @__PURE__ */ r(
119
+ J,
120
+ {
121
+ ref: b,
122
+ name: s,
123
+ wrapperRef: l,
124
+ wrapperInputRef: w,
125
+ options: n,
126
+ isLoading: !!h
127
+ }
128
+ )
129
+ ]
130
+ }
131
+ );
95
132
  }
96
133
  );
97
134
  export {
98
- X as Wrapper
135
+ re as Wrapper
99
136
  };
@@ -1,10 +1,10 @@
1
1
  import { createContext as e } from "react";
2
2
  const t = e({
3
- value: null,
4
3
  isOpen: !1,
5
4
  toggleOpen() {
6
5
  throw new Error("toggleOpen function must be overridden");
7
6
  },
7
+ value: void 0,
8
8
  setValue() {
9
9
  throw new Error("setValue function must be overridden");
10
10
  }
@@ -1,18 +1,18 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { useState as i, useCallback as c } from "react";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useCallback as u } from "react";
3
3
  import { DropdownContext as d } from "./dropdown.context.js";
4
4
  import { useToggle as f } from "../../../hooks/useToggle.js";
5
- const w = ({ children: t, onChange: o }) => {
6
- const [e, s] = f(!1), [l, p] = i(null), m = c(
7
- (r) => {
8
- o == null || o(r), p(r);
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
- [o]
10
+ [r, o]
11
11
  );
12
- return /* @__PURE__ */ u(
12
+ return /* @__PURE__ */ i(
13
13
  d.Provider,
14
14
  {
15
- value: { value: l, isOpen: e, setValue: m, toggleOpen: s },
15
+ value: { value: e, isOpen: l, setValue: s, toggleOpen: p },
16
16
  children: t
17
17
  }
18
18
  );