@konstructio/ui 0.1.2-alpha.4 → 0.1.2-alpha.41

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 (179) hide show
  1. package/dist/{Combination-VYaRRJBZ.js → Combination-BtmnusWq.js} +141 -138
  2. package/dist/DatePicker.css +1 -1
  3. package/dist/Modal-CtAG97Ts.js +99 -0
  4. package/dist/_commonjsHelpers-DaMA6jEr.js +8 -0
  5. package/dist/chevron-down-DgT-uSF9.js +5 -0
  6. package/dist/chevron-left-C4LEg1fH.js +7 -0
  7. package/dist/chevron-up-CRyLc5Ml.js +54 -0
  8. package/dist/chevron-up-DrQr2Fwd.js +5 -0
  9. package/dist/components/Alert/Alert.js +2 -2
  10. package/dist/components/AlertDialog/AlertDialog.js +1 -1
  11. package/dist/components/AlertDialog/components/AlertDialogTrigger.js +1 -1
  12. package/dist/components/AlertDialog/components/index.js +1 -1
  13. package/dist/components/Badge/Badge.js +42 -44
  14. package/dist/components/Badge/Badge.variants.js +8 -6
  15. package/dist/components/Breadcrumb/Breadcrumb.js +1 -1
  16. package/dist/components/Breadcrumb/components/Item/Item.js +24 -23
  17. package/dist/components/Breadcrumb/hooks/useBreadcrumb.js +1 -1
  18. package/dist/components/Button/Button.js +1 -1
  19. package/dist/components/Button/Button.variants.js +1 -1
  20. package/dist/components/Card/Card.variants.js +5 -9
  21. package/dist/components/Checkbox/Checkbox.js +6 -6
  22. package/dist/components/Command/Command.js +2 -2
  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 +2 -2
  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 +2 -2
  31. package/dist/components/Command/components/DialogOverlay.js +1 -1
  32. package/dist/components/Datepicker/DatePicker.js +1243 -1191
  33. package/dist/components/Divider/Divider.variants.js +1 -1
  34. package/dist/components/Dropdown/Dropdown.js +37 -31
  35. package/dist/components/Dropdown/Dropdown.variants.js +9 -4
  36. package/dist/components/Dropdown/components/List/List.js +128 -59
  37. package/dist/components/Dropdown/components/ListItem/ListItem.js +90 -39
  38. package/dist/components/Dropdown/components/Wrapper.js +141 -134
  39. package/dist/components/Dropdown/constants/index.js +4 -0
  40. package/dist/components/Dropdown/constants/pagination.js +4 -0
  41. package/dist/components/Dropdown/contexts/dropdown.context.js +17 -0
  42. package/dist/components/Dropdown/contexts/dropdown.provider.js +48 -20
  43. package/dist/components/Dropdown/hooks/useDropdown.js +74 -29
  44. package/dist/components/Dropdown/hooks/useNavigationList.js +27 -39
  45. package/dist/components/DropdownButton/DropdownButton.js +1 -1
  46. package/dist/components/Filter/Filter.variants.js +2 -2
  47. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +1 -1
  48. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.js +1 -1
  49. package/dist/components/Input/Input.js +1 -1
  50. package/dist/components/Input/Input.variants.js +2 -1
  51. package/dist/components/Loading/Loading.js +1 -7
  52. package/dist/components/Modal/Modal.js +2 -2
  53. package/dist/components/Modal/components/Body/Body.js +1 -1
  54. package/dist/components/Modal/components/Footer/Footer.js +1 -1
  55. package/dist/components/Modal/components/Header/Header.js +1 -1
  56. package/dist/components/Modal/components/Wrapper/Wrapper.js +4 -4
  57. package/dist/components/Modal/components/index.js +1 -1
  58. package/dist/components/MultiSelectDropdown/MultiSelectDropdown.js +34 -0
  59. package/dist/components/MultiSelectDropdown/MultiSelectDropdown.variants.js +34 -0
  60. package/dist/components/MultiSelectDropdown/components/Item/Item.js +38 -0
  61. package/dist/components/MultiSelectDropdown/components/Item/Item.variants.js +38 -0
  62. package/dist/components/MultiSelectDropdown/components/List/List.js +37 -0
  63. package/dist/components/MultiSelectDropdown/components/List/List.variants.js +23 -0
  64. package/dist/components/MultiSelectDropdown/components/Wrapper/Wrapper.js +105 -0
  65. package/dist/components/MultiSelectDropdown/components/index.js +8 -0
  66. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.context.js +21 -0
  67. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.hook.js +13 -0
  68. package/dist/components/MultiSelectDropdown/contexts/MultiSelectDropdown.provider.js +138 -0
  69. package/dist/components/MultiSelectDropdown/contexts/index.js +6 -0
  70. package/dist/components/MultiSelectDropdown/hooks/useMultiSelectDropdown.js +32 -0
  71. package/dist/components/NumberInput/NumberInput.js +2 -2
  72. package/dist/components/PhoneNumberInput/PhoneNumberInput.js +8 -0
  73. package/dist/components/PhoneNumberInput/PhoneNumberInput.variants.js +46 -0
  74. package/dist/components/PhoneNumberInput/components/FlagContent/FlagContent.js +27 -0
  75. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +629 -0
  76. package/dist/components/PhoneNumberInput/components/FlagSelectorWrapper/FlagSelectorWrapper.js +36 -0
  77. package/dist/components/PhoneNumberInput/components/TruncateText/TruncateText.js +45 -0
  78. package/dist/components/PhoneNumberInput/components/Wrapper.js +625 -0
  79. package/dist/components/PhoneNumberInput/components/index.js +6 -0
  80. package/dist/components/PhoneNumberInput/contexts/index.js +8 -0
  81. package/dist/components/PhoneNumberInput/contexts/phone-number.context.js +28 -0
  82. package/dist/components/PhoneNumberInput/contexts/phone-number.hook.js +13 -0
  83. package/dist/components/PhoneNumberInput/contexts/phone-number.provider.js +6144 -0
  84. package/dist/components/PhoneNumberInput/utils/index.js +11 -0
  85. package/dist/components/PieChart/PieChart.js +647 -664
  86. package/dist/components/RadioCard/RadioCard.variants.js +1 -6
  87. package/dist/components/RadioGroup/RadioGroup.js +1 -1
  88. package/dist/components/Range/Range.js +1 -1
  89. package/dist/components/Sidebar/Sidebar.variants.js +2 -2
  90. package/dist/components/Sidebar/components/Wrapper/Wrapper.js +29 -28
  91. package/dist/components/Slider/Slider.js +1 -1
  92. package/dist/components/Switch/Switch.js +8 -8
  93. package/dist/components/Switch/Switch.variants.js +4 -4
  94. package/dist/components/Tabs/Tabs.js +1 -1
  95. package/dist/components/Tabs/Tabs.variants.js +1 -1
  96. package/dist/components/Tabs/components/Content.js +1 -1
  97. package/dist/components/Tabs/components/List.js +1 -1
  98. package/dist/components/Tabs/components/Trigger.js +1 -1
  99. package/dist/components/Tag/Tag.js +1 -1
  100. package/dist/components/Tag/Tag.variants.js +1 -0
  101. package/dist/components/TagSelect/components/Wrapper/Wrapper.js +49 -98
  102. package/dist/components/TimePicker/TimePicker.variants.js +2 -2
  103. package/dist/components/TimePicker/components/Wrapper/Wrapper.js +2 -2
  104. package/dist/components/Toast/Toast.js +283 -255
  105. package/dist/components/Toast/Toast.variants.js +37 -24
  106. package/dist/components/Tooltip/Tooltip.js +15 -14
  107. package/dist/components/Tooltip/Tooltip.variants.js +5 -4
  108. package/dist/components/Typography/Typography.variants.js +18 -23
  109. package/dist/components/VirtualizedTable/VirtualizedTable.js +121 -0
  110. package/dist/components/VirtualizedTable/VirtualizedTable.variants.js +5 -0
  111. package/dist/components/VirtualizedTable/assets/chevron-down.js +25 -0
  112. package/dist/components/VirtualizedTable/assets/chevron-up.js +25 -0
  113. package/dist/components/VirtualizedTable/assets/index.js +6 -0
  114. package/dist/components/VirtualizedTable/components/Actions/Actions.js +72 -0
  115. package/dist/components/VirtualizedTable/components/Body/Body.js +51 -0
  116. package/dist/components/VirtualizedTable/components/DotPaginate/DotPaginate.js +165 -0
  117. package/dist/components/VirtualizedTable/components/DropdownPaginate/DropdownPaginate.js +34 -0
  118. package/dist/components/VirtualizedTable/components/Filter/Filter.js +93 -0
  119. package/dist/components/VirtualizedTable/components/FormPaginate/FormPaginate.js +48 -0
  120. package/dist/components/VirtualizedTable/components/Header/Header.js +84 -0
  121. package/dist/components/VirtualizedTable/components/Pagination/Pagination.js +53 -0
  122. package/dist/components/VirtualizedTable/components/Skeleton/Skeleton.js +67 -0
  123. package/dist/components/VirtualizedTable/components/TruncateText/TruncateText.js +34 -0
  124. package/dist/components/VirtualizedTable/components/WrapperBody/WrapperBody.js +27 -0
  125. package/dist/components/VirtualizedTable/components/index.js +16 -0
  126. package/dist/components/VirtualizedTable/constants/index.js +5 -0
  127. package/dist/components/VirtualizedTable/constants/pagination.js +5 -0
  128. package/dist/components/VirtualizedTable/contexts/index.js +8 -0
  129. package/dist/components/VirtualizedTable/contexts/table.context.js +32 -0
  130. package/dist/components/VirtualizedTable/contexts/table.hook.js +11 -0
  131. package/dist/components/VirtualizedTable/contexts/table.provider.js +85 -0
  132. package/dist/components/index.js +88 -80
  133. package/dist/contexts/theme.provider.js +0 -1
  134. package/dist/{createLucideIcon-DbC6TvM5.js → createLucideIcon-D4r5Phnh.js} +0 -24
  135. package/dist/debounce-BFejQm9P.js +200 -0
  136. package/dist/ellipsis-vertical-BVPtjl5f.js +9 -0
  137. package/dist/{index-h-Ul0anl.js → index--V_ZsiQe.js} +1 -22
  138. package/dist/index-2hB40Iuc.js +1873 -0
  139. package/dist/index-BZPx6jYI.js +8 -0
  140. package/dist/{index-bwWKd82e.js → index-BbQkJE5L.js} +1 -1
  141. package/dist/index-BtQfgaSF.js +60 -0
  142. package/dist/index-C3tHPg8y.js +662 -0
  143. package/dist/index-C65LtGuU.js +137 -0
  144. package/dist/index-CIAmiWcw.js +200 -0
  145. package/dist/index-CSFe9uC5.js +14 -0
  146. package/dist/index-CSWGJT-v.js +1722 -0
  147. package/dist/{index-D3xzCzcO.js → index-CdwPV0FE.js} +4 -4
  148. package/dist/index-CigKKiZS.js +91 -0
  149. package/dist/{index-BAraV3ai.js → index-DH2Fnov1.js} +11 -12
  150. package/dist/index-DLcqcWxM.js +29 -0
  151. package/dist/index-Dbt2vBmS.js +136 -0
  152. package/dist/{index-DB2XhXHn.js → index-DpW9ExsS.js} +7 -7
  153. package/dist/index-DrWQH0QF.js +55 -0
  154. package/dist/index-Ds6U2x4Z.js +479 -0
  155. package/dist/{index-C1g_chDT.js → index-mPY_8Y5v.js} +2 -2
  156. package/dist/index-ohdbKsws.js +27 -0
  157. package/dist/index.d.ts +232 -23
  158. package/dist/index.js +112 -102
  159. package/dist/libphonenumber-_7ZyKWA7.js +11549 -0
  160. package/dist/loader-juvMSJ9L.js +5 -0
  161. package/dist/package.json +48 -34
  162. package/dist/styles.css +1 -1
  163. package/dist/ui/civo-theme.css +191 -167
  164. package/dist/{useBreadcrumb-B8DnuqkR.js → useBreadcrumb-BAHbGQ_O.js} +0 -10
  165. package/dist/utils/index.js +534 -501
  166. package/dist/{x-BPcqkRZd.js → x-DPU9OdYH.js} +1 -1
  167. package/package.json +48 -34
  168. package/dist/Modal-V67Uz78z.js +0 -98
  169. package/dist/_commonjsHelpers-C6fGbg64.js +0 -6
  170. package/dist/chevron-down-BLZPftpV.js +0 -11
  171. package/dist/index-BXuxPoz7.js +0 -435
  172. package/dist/index-BfXxHr_2.js +0 -125
  173. package/dist/index-C9T9HQaa.js +0 -423
  174. package/dist/index-CZnD2QxM.js +0 -32
  175. package/dist/index-CrBonFvu.js +0 -144
  176. package/dist/index-Cvx4lqTq.js +0 -47
  177. package/dist/index-DQH6odE9.js +0 -82
  178. package/dist/index-Oq5GlCHP.js +0 -131
  179. package/dist/index-iXyXtdgP.js +0 -31
@@ -1,165 +1,167 @@
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-DbC6TvM5.js";
10
- import { useDropdownContext as ne } from "../contexts/dropdown.hook.js";
11
- /**
12
- * @license lucide-react v0.544.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */
17
- const le = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]], oe = T("chevron-up", le);
18
- /**
19
- * @license lucide-react v0.544.0 - ISC
20
- *
21
- * This source code is licensed under the ISC license.
22
- * See the LICENSE file in the root directory of this source tree.
23
- */
24
- const se = [
1
+ import { jsxs as m, jsx as r } from "react/jsx-runtime";
2
+ import { forwardRef as Z, useId as ee, useRef as C, useMemo as te, useImperativeHandle as ae, useEffect as re } from "react";
3
+ import { S as ne } from "../../../loader-juvMSJ9L.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
+ import { useDropdownContext as fe } from "../contexts/dropdown.hook.js";
12
+ const de = [
25
13
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
26
14
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
27
- ], ce = T("search", se), we = K(
15
+ ], xe = ue("search", de), je = Z(
28
16
  ({
29
- additionalOptions: V,
30
- className: _,
17
+ additionalOptions: b,
18
+ className: z,
31
19
  defaultValue: x,
20
+ disabled: t = !1,
32
21
  error: f,
33
- iconClassName: $,
34
- inputClassName: D,
35
- isLoading: L,
22
+ iconClassName: R,
23
+ inputClassName: F,
24
+ isLoading: g,
36
25
  isRequired: h,
37
26
  label: v,
38
- labelClassName: F,
39
- listClassName: M,
40
- listItemClassName: A,
41
- name: c,
42
- options: n,
43
- placeholder: N,
44
- searchable: w = !1,
45
- 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);
62
- e && y(e.value);
27
+ labelClassName: S,
28
+ listClassName: T,
29
+ listItemClassName: D,
30
+ listItemSecondRowClassName: E,
31
+ name: d,
32
+ placeholder: w,
33
+ searchable: k = !1,
34
+ showSearchIcon: N,
35
+ theme: M,
36
+ wrapperClassName: W,
37
+ isInfiniteScrollEnabled: _ = !1,
38
+ onFetchMoreOptions: $,
39
+ onBlur: H,
40
+ onSearchChange: P,
41
+ noOptionsText: U,
42
+ ...y
43
+ }, q) => {
44
+ const I = ee(), l = C(null), L = C(null), A = C(0), {
45
+ isOpen: i,
46
+ searchTerm: B,
47
+ value: s,
48
+ options: n,
49
+ setValue: c,
50
+ setSearchTerm: G,
51
+ setCanFilter: J,
52
+ toggleOpen: K
53
+ } = fe(), e = te(() => n.find(({ value: a }) => a === s), [n, s]), { wrapperRef: Q, wrapperInputRef: V, handleOpen: j } = ce({
54
+ ulRef: L,
55
+ inputRef: l,
56
+ disabled: t,
57
+ internalValue: e,
58
+ onBlur: H
59
+ }), p = d ? `${I}-${d}` : I;
60
+ ae(q, () => l.current, [l]), re(() => {
61
+ if (x && !s) {
62
+ const a = n && n.find((u) => u.value === x);
63
+ a && c(a.value);
63
64
  }
64
- }, [x, n, y, l]), g(() => {
65
- 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
- }), () => {
70
- e.abort();
71
- };
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()
65
+ }, [x, n, c, s]);
66
+ const X = (a) => {
67
+ const u = a.target.value;
68
+ J(!0), c(""), G(u ?? ""), P?.(u);
69
+ const O = n.find(
70
+ (Y) => Y.value.toLocaleLowerCase() === u.toLocaleLowerCase()
78
71
  );
79
- u && y(u.value);
72
+ c(O ? O.value : e?.value ?? "");
80
73
  };
81
- return /* @__PURE__ */ p(
74
+ return /* @__PURE__ */ m(
82
75
  "div",
83
76
  {
84
- ref: i,
85
- className: s("flex flex-col w-full relative", P),
86
- "data-theme": H,
77
+ ref: Q,
78
+ className: o("flex flex-col w-full relative", W),
79
+ "data-theme": M,
87
80
  children: [
88
- v ? /* @__PURE__ */ p(
81
+ v ? /* @__PURE__ */ m(
89
82
  "label",
90
83
  {
91
- id: d,
92
- className: s(B({ className: F })),
93
- htmlFor: d,
94
- onClick: k,
84
+ id: p,
85
+ className: o(oe({ className: S })),
86
+ htmlFor: p,
87
+ onClick: () => !t && j(),
95
88
  children: [
96
89
  v,
97
- h && /* @__PURE__ */ a("span", { className: "text-red-600 ml-1", children: "*" })
90
+ h && /* @__PURE__ */ r("span", { className: "text-red-600 ml-1", children: "*" })
98
91
  ]
99
92
  }
100
93
  ) : null,
101
- /* @__PURE__ */ p(
94
+ /* @__PURE__ */ m(
102
95
  "div",
103
96
  {
104
- ref: O,
105
- id: d,
106
- className: s(te({ className: _, hasError: !!f })),
97
+ ref: V,
98
+ id: p,
99
+ className: o(
100
+ ie({ className: z, hasError: !!f, disabled: t })
101
+ ),
107
102
  role: "combobox",
108
- onClick: k,
109
- "aria-expanded": m,
110
- tabIndex: 0,
111
- "aria-labelledby": d,
103
+ onClick: () => !t && K(!i),
104
+ "aria-expanded": i,
105
+ tabIndex: A.current,
106
+ "aria-labelledby": p,
112
107
  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(
108
+ /* @__PURE__ */ m("div", { className: "flex gap-2.5 items-center flex-1", children: [
109
+ e?.leftIcon && !N && /* @__PURE__ */ r("span", { className: "w-4 h-4 flex justify-center items-center dark:text-slate-50", children: e.leftIcon }),
110
+ N && /* @__PURE__ */ r(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
+ k ? /* @__PURE__ */ r(
117
112
  "input",
118
113
  {
119
- ref: t,
120
114
  type: "text",
121
- value: m ? W : r?.label || "",
122
- name: c,
123
- onChange: G,
124
- placeholder: N,
125
- className: s(ee({ className: D }), {
115
+ value: i ? B : e?.label ?? s ?? "",
116
+ onChange: X,
117
+ placeholder: w,
118
+ className: o(le({ className: F }), {
126
119
  "text-red-700 placeholder:text-red-700": !!f
127
120
  }),
128
- onClick: (e) => {
129
- e.stopPropagation(), k();
121
+ onClick: (a) => {
122
+ a.stopPropagation(), t || j();
130
123
  },
131
- "aria-label": v || N,
132
- "aria-labelledby": d,
124
+ "aria-label": v || w,
125
+ "aria-labelledby": p,
133
126
  required: h,
134
127
  autoComplete: "off",
135
128
  autoCapitalize: "words",
136
- ...z
129
+ disabled: t,
130
+ tabIndex: -1,
131
+ ...y
137
132
  }
138
- ) : /* @__PURE__ */ a(
139
- Z,
133
+ ) : /* @__PURE__ */ m(
134
+ se,
140
135
  {
141
136
  variant: "body2",
142
- className: s(
143
- "flex-1 text-zinc-400 text-sm dark:text-slate-400",
137
+ className: o(
138
+ "flex-1 text-zinc-400 text-sm dark:text-slate-400 flex gap-2 items-center",
144
139
  {
145
140
  "text-red-700": !!f,
146
- "select-none": !r,
147
- "text-slate-800 dark:text-slate-50": r
148
- }
141
+ "select-none": !e,
142
+ "text-slate-800 dark:text-slate-50": e,
143
+ "text-slate-400/50 dark:text-slate-50/50": t
144
+ },
145
+ e?.wrapperClassNameOnSelectedValue
149
146
  ),
150
- children: r?.label || N
147
+ children: [
148
+ e?.label || w,
149
+ " ",
150
+ e?.showRightComponentOnselectedValue ? e?.rightComponent : null
151
+ ]
151
152
  }
152
153
  )
153
154
  ] }),
154
- L ? /* @__PURE__ */ a(Y, { className: "w-4 h-4 text-zinc-500 select-none" }) : !C && /* @__PURE__ */ a(
155
- oe,
155
+ g ? /* @__PURE__ */ r(ne, { className: "w-4 h-4 text-slate-400 animate-spin select-none" }) : !N && /* @__PURE__ */ r(
156
+ me,
156
157
  {
157
- "data-state": m ? "open" : "closed",
158
- className: s(
158
+ "data-state": i ? "open" : "closed",
159
+ className: o(
159
160
  "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
- $,
161
+ R,
161
162
  {
162
- "text-red-700": !!f
163
+ "text-red-700": !!f,
164
+ "text-slate-400/50 dark:group-focus-within:text-zinc-500": t
163
165
  }
164
166
  )
165
167
  }
@@ -167,32 +169,37 @@ const se = [
167
169
  ]
168
170
  }
169
171
  ),
170
- !w && /* @__PURE__ */ a(
172
+ /* @__PURE__ */ r(
171
173
  "input",
172
174
  {
173
- ref: t,
175
+ ref: l,
174
176
  type: "text",
175
- name: c,
177
+ name: d,
176
178
  className: "hidden",
177
179
  "aria-hidden": "true",
178
180
  required: h,
179
- ...z
181
+ inert: !0,
182
+ defaultValue: e?.value ?? s ?? void 0,
183
+ ...y
180
184
  }
181
185
  ),
182
- m && /* @__PURE__ */ a(
183
- re,
186
+ i && /* @__PURE__ */ r(
187
+ pe,
184
188
  {
185
- ref: E,
186
- additionalOptions: V,
187
- className: M,
188
- itemClassName: A,
189
- name: c,
190
- wrapperRef: i,
191
- wrapperInputRef: O,
192
- inputRef: t,
189
+ ref: L,
190
+ additionalOptions: b,
191
+ className: T,
192
+ itemClassName: D,
193
+ name: d,
194
+ wrapperInputRef: V,
195
+ inputRef: l,
193
196
  options: n,
194
- isLoading: !!L,
195
- searchable: w
197
+ isLoading: !!g,
198
+ searchable: k,
199
+ listItemSecondRowClassName: E,
200
+ isInfiniteScrollEnabled: _,
201
+ onFetchMoreOptions: $,
202
+ noOptionsText: U
196
203
  }
197
204
  )
198
205
  ]
@@ -201,5 +208,5 @@ const se = [
201
208
  }
202
209
  );
203
210
  export {
204
- we as Wrapper
211
+ je as Wrapper
205
212
  };
@@ -0,0 +1,4 @@
1
+ import { DEFAULT_LIST_SIZE as E } from "./pagination.js";
2
+ export {
3
+ E as DEFAULT_LIST_SIZE
4
+ };
@@ -0,0 +1,4 @@
1
+ const o = 10;
2
+ export {
3
+ o as DEFAULT_LIST_SIZE
4
+ };
@@ -4,6 +4,23 @@ const t = e({
4
4
  isOpen: !1,
5
5
  searchTerm: "",
6
6
  value: void 0,
7
+ canFilter: !0,
8
+ canContinueFetching: !0,
9
+ page: 1,
10
+ options: [],
11
+ isTyping: !1,
12
+ setOptions() {
13
+ throw new Error("setOptions function must be overridden");
14
+ },
15
+ setPage() {
16
+ throw new Error("setPage function must be overridden");
17
+ },
18
+ setCanContinueFetching() {
19
+ throw new Error("setCanContinueFetching function must be overridden");
20
+ },
21
+ setCanFilter() {
22
+ throw new Error("setCanFilter function must be overridden");
23
+ },
7
24
  setSearchTerm() {
8
25
  throw new Error("setSearchTerm function must be overridden");
9
26
  },
@@ -1,30 +1,58 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { useRef as u, useState as d, useCallback as f } from "react";
3
- import { DropdownContext as v } from "./dropdown.context.js";
4
- import { useToggle as S } from "../../../hooks/useToggle.js";
5
- const C = ({ children: o, value: a, name: e, highlightSearch: s = !1, onChange: r, onBlur: t }) => {
6
- const l = u(s), [n, c] = S(!1), [h, i] = d(""), m = f(
7
- (g) => {
8
- r?.({ target: { value: g, name: e ?? "" } }), t?.();
1
+ import { jsx as G } from "react/jsx-runtime";
2
+ import { useState as e, useRef as f, useCallback as p, useEffect as T } from "react";
3
+ import { DropdownContext as L } from "./dropdown.context.js";
4
+ import { useToggle as N } from "../../../hooks/useToggle.js";
5
+ const c = 1, O = 300, U = ({
6
+ children: d,
7
+ value: C,
8
+ name: i,
9
+ highlightSearch: E = !1,
10
+ options: n,
11
+ onChange: a,
12
+ onBlur: u
13
+ }) => {
14
+ const [v, l] = e(n), F = f(E), [P, g] = N(!1), [D, I] = e(""), [S, b] = e(!0), [x, o] = e(!0), [A, s] = e(c), [_, h] = e(!1), t = f(void 0), w = p(
15
+ (r, m) => {
16
+ m?.current && (m.current.value = r), t.current && clearTimeout(t.current), h(!0), o(!0), s(c), a?.({ target: { value: r, name: i ?? "" } }), u?.(), t.current = setTimeout(() => {
17
+ h(!1);
18
+ }, O);
9
19
  },
10
- [r, e, t]
20
+ [a, i, u]
21
+ ), y = p(
22
+ (r) => {
23
+ g(r), o(!0), s(c);
24
+ },
25
+ [g]
11
26
  );
12
- return /* @__PURE__ */ p(
13
- v.Provider,
27
+ return T(() => {
28
+ l(n);
29
+ }, [n.length]), T(() => () => {
30
+ t.current && clearTimeout(t.current);
31
+ }, []), /* @__PURE__ */ G(
32
+ L.Provider,
14
33
  {
15
34
  value: {
16
- highlightSearchEnabled: l.current,
17
- isOpen: n,
18
- searchTerm: h,
19
- value: a,
20
- setSearchTerm: i,
21
- setValue: m,
22
- toggleOpen: c
35
+ highlightSearchEnabled: F.current,
36
+ isOpen: P,
37
+ searchTerm: D,
38
+ value: C,
39
+ canFilter: S,
40
+ canContinueFetching: x,
41
+ page: A,
42
+ options: v,
43
+ isTyping: _,
44
+ setOptions: l,
45
+ setPage: s,
46
+ setCanContinueFetching: o,
47
+ setCanFilter: b,
48
+ setSearchTerm: I,
49
+ setValue: w,
50
+ toggleOpen: y
23
51
  },
24
- children: o
52
+ children: d
25
53
  }
26
54
  );
27
55
  };
28
56
  export {
29
- C as DropdownProvider
57
+ U as DropdownProvider
30
58
  };
@@ -1,16 +1,22 @@
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();
5
- u(() => {
6
- const e = new AbortController(), s = (a) => {
7
- a.key === "Escape" && n(!1);
8
- }, r = (a) => {
9
- o.current?.contains(a.target) || n(!1);
1
+ import { useRef as m, useEffect as c, useCallback as b } from "react";
2
+ import { useDropdownContext as L } from "../contexts/dropdown.hook.js";
3
+ const p = ({
4
+ ulRef: f,
5
+ inputRef: t,
6
+ disabled: w,
7
+ internalValue: u,
8
+ onBlur: g
9
+ }) => {
10
+ const r = m(null), a = m(null), { value: i, setSearchTerm: v, setCanFilter: d, toggleOpen: n } = L();
11
+ c(() => {
12
+ const e = new AbortController(), o = (l) => {
13
+ l.key === "Escape" && n(!1);
14
+ }, s = (l) => {
15
+ r.current?.contains(l.target) || n(!1);
10
16
  };
11
- return document.addEventListener("keydown", s, {
17
+ return document.addEventListener("keydown", o, {
12
18
  signal: e.signal
13
- }), document.addEventListener("mousedown", r, {
19
+ }), document.addEventListener("mousedown", s, {
14
20
  signal: e.signal
15
21
  }), document.addEventListener(
16
22
  "visibilitychange",
@@ -20,39 +26,78 @@ const w = ({ ulRef: l, inputRef: i }) => {
20
26
  {
21
27
  signal: e.signal
22
28
  }
23
- ), t.current?.addEventListener(
24
- "focus",
25
- () => {
26
- n(!0);
29
+ ), a.current?.addEventListener(
30
+ "focusin",
31
+ (l) => {
32
+ !w && l.target?.matches(":focus-visible") && n(!0);
27
33
  },
28
34
  { signal: e.signal }
29
35
  ), () => {
30
36
  e.abort();
31
37
  };
32
- }, [n, o]), u(() => {
38
+ }, [n, r]), c(() => {
33
39
  const e = new AbortController();
34
- return t.current?.addEventListener(
40
+ return a.current?.addEventListener(
35
41
  "keydown",
36
- (s) => {
37
- if (s.key === "ArrowDown") {
38
- const r = l.current?.querySelector("li");
39
- r && r.focus();
42
+ (o) => {
43
+ if (o.key === "ArrowDown") {
44
+ const s = f.current?.querySelector("li");
45
+ s && s.focus();
40
46
  }
41
47
  },
42
48
  { signal: e.signal }
43
49
  ), () => {
44
50
  e.abort();
45
51
  };
46
- }, [t, l]);
47
- const d = f(() => {
48
- n(!0), requestAnimationFrame(() => i?.current?.focus());
49
- }, [i, n]);
52
+ }, [a, f]), c(() => {
53
+ const e = new AbortController();
54
+ return t?.current?.addEventListener(
55
+ "focusin",
56
+ () => {
57
+ v(u?.value ?? ""), d(!1);
58
+ },
59
+ { signal: e.signal }
60
+ ), t?.current?.addEventListener(
61
+ "focusout",
62
+ () => {
63
+ d(!0);
64
+ },
65
+ { signal: e.signal }
66
+ ), a.current?.addEventListener(
67
+ "focus",
68
+ () => {
69
+ d(!1);
70
+ },
71
+ { signal: e.signal }
72
+ ), r.current?.addEventListener(
73
+ "focusout",
74
+ (o) => {
75
+ r.current?.contains(o.relatedTarget) || n(!1);
76
+ },
77
+ { signal: e.signal }
78
+ ), () => {
79
+ e.abort();
80
+ };
81
+ }, [i]), c(() => {
82
+ t?.current && (t.current.value = i && u?.value || "");
83
+ }, [u, i]), c(() => {
84
+ const e = new AbortController();
85
+ return r.current?.addEventListener("focusout", (o) => {
86
+ const s = o.relatedTarget;
87
+ (!s || !r.current?.contains(s)) && (t?.current?.value || g?.());
88
+ }), () => {
89
+ e.abort();
90
+ };
91
+ }, [n, r, v, g, i]);
92
+ const E = b(() => {
93
+ n(!0), requestAnimationFrame(() => t?.current?.focus());
94
+ }, [t, n]);
50
95
  return {
51
- wrapperRef: o,
52
- wrapperInputRef: t,
53
- handleOpen: d
96
+ wrapperRef: r,
97
+ wrapperInputRef: a,
98
+ handleOpen: E
54
99
  };
55
100
  };
56
101
  export {
57
- w as useDropdown
102
+ p as useDropdown
58
103
  };