@konstructio/ui 0.1.2-alpha.3 → 0.1.2-alpha.30

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