@alphakits/ui 2.3.0 → 2.4.0

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 (217) hide show
  1. package/dist/__internal/utils/index.d.ts +1 -1
  2. package/dist/__internal/utils/index.js +4 -4
  3. package/dist/amount-input/component.js +41 -41
  4. package/dist/avatar/component.js +2 -18
  5. package/dist/badge/component.d.ts +1 -1
  6. package/dist/base-card/component.js +1 -7
  7. package/dist/bottom-sheet/component.d.ts +1 -1
  8. package/dist/bottom-sheet/component.js +9 -13
  9. package/dist/box/component.d.ts +2 -2
  10. package/dist/box/component.js +4 -4
  11. package/dist/button/component.js +9 -9
  12. package/dist/button-arrow/component.js +6 -1
  13. package/dist/calendar/component.d.ts +1 -2
  14. package/dist/calendar/component.js +77 -74
  15. package/dist/calendar/components/days-table/component.js +46 -43
  16. package/dist/calendar/components/header/{/321/201omponent.js → component.js} +3 -12
  17. package/dist/calendar/components/header/index.d.ts +1 -1
  18. package/dist/calendar/components/header/index.js +1 -1
  19. package/dist/calendar/components/months-table/{/321/201omponent.js → component.js} +7 -7
  20. package/dist/calendar/components/months-table/index.d.ts +1 -1
  21. package/dist/calendar/components/months-table/index.js +1 -1
  22. package/dist/calendar/components/select-button/{/321/201omponent.d.ts → component.d.ts} +3 -3
  23. package/dist/calendar/components/select-button/{/321/201omponent.js → component.js} +5 -11
  24. package/dist/calendar/components/select-button/index.d.ts +1 -1
  25. package/dist/calendar/components/select-button/index.js +1 -1
  26. package/dist/calendar/components/years-table/{/321/201omponent.js → component.js} +14 -14
  27. package/dist/calendar/components/years-table/index.d.ts +1 -1
  28. package/dist/calendar/components/years-table/index.js +1 -1
  29. package/dist/calendar/index.d.ts +2 -2
  30. package/dist/calendar/index.js +4 -4
  31. package/dist/calendar/use-calendar.js +51 -47
  32. package/dist/calendar/utils.js +7 -9
  33. package/dist/calendar-input/component.js +22 -22
  34. package/dist/card/component.js +2 -18
  35. package/dist/cell/base/component.js +31 -31
  36. package/dist/cell/pure/component.js +2 -2
  37. package/dist/checkbox/component.js +11 -11
  38. package/dist/checkbox-group/component.js +23 -24
  39. package/dist/checkbox-lists/component.d.ts +1 -2
  40. package/dist/checkbox-lists/component.js +59 -61
  41. package/dist/collapsable-row/addons.d.ts +3 -4
  42. package/dist/collapsable-row/addons.js +6 -9
  43. package/dist/collapsable-row/component.d.ts +1 -1
  44. package/dist/collapsable-row/component.js +7 -7
  45. package/dist/collapse/component.js +45 -54
  46. package/dist/copy-button/component.d.ts +1 -2
  47. package/dist/copy-button/component.js +1 -5
  48. package/dist/date/component.js +1 -1
  49. package/dist/date-switcher/component.d.ts +1 -2
  50. package/dist/date-switcher/component.js +8 -8
  51. package/dist/decorated-item/component.js +10 -20
  52. package/dist/dot/component.js +1 -4
  53. package/dist/empty-page/component.js +1 -9
  54. package/dist/filter-tag/component.d.ts +1 -1
  55. package/dist/flex/component.d.ts +2 -2
  56. package/dist/footer/component.js +57 -53
  57. package/dist/form/component.d.ts +1 -2
  58. package/dist/form/component.js +2 -12
  59. package/dist/form/templates/base-form/index.d.ts +3 -3
  60. package/dist/form/templates/base-form/index.js +26 -26
  61. package/dist/form/templates/filters-form/index.d.ts +1 -1
  62. package/dist/form/templates/filters-form/index.js +20 -23
  63. package/dist/form/templates/rest-form/form.d.ts +1 -2
  64. package/dist/form/templates/rest-form/form.js +51 -56
  65. package/dist/form/templates/rest-form/index.d.ts +3 -3
  66. package/dist/form/templates/rest-form/index.js +16 -27
  67. package/dist/form/utils/get-default-values.js +3 -6
  68. package/dist/form/utils/remove-undefined-from-object.js +1 -3
  69. package/dist/form-control/component.js +1 -1
  70. package/dist/formik/index.d.ts +2 -2
  71. package/dist/header-search/component.js +1 -6
  72. package/dist/hooks/index.d.ts +2 -2
  73. package/dist/hooks/index.js +10 -10
  74. package/dist/hooks/use-get-one/index.js +16 -16
  75. package/dist/icon-button/component.d.ts +3 -3
  76. package/dist/icon-button/component.js +2 -8
  77. package/dist/image/component.js +52 -30
  78. package/dist/image/image-base.js +1 -7
  79. package/dist/image/use-image-render-component.d.ts +1 -1
  80. package/dist/image/use-image-render-component.js +11 -14
  81. package/dist/image-gallery/component.js +40 -45
  82. package/dist/image-uploader/component.js +56 -53
  83. package/dist/index.js +41 -41
  84. package/dist/info-block-wrapper/component.d.ts +1 -1
  85. package/dist/input/component.js +1 -1
  86. package/dist/input-autocomplete/autocomplete-field/index.d.ts +1 -2
  87. package/dist/input-autocomplete/autocomplete-field/index.js +6 -6
  88. package/dist/input-autocomplete/component.d.ts +26 -26
  89. package/dist/input-ghost/component.d.ts +1 -1
  90. package/dist/link/component.d.ts +2 -2
  91. package/dist/link/component.js +1 -1
  92. package/dist/loader/component.js +6 -5
  93. package/dist/masked-input/component.js +7 -16
  94. package/dist/menu/component.js +12 -17
  95. package/dist/menu/components/content-header/index.js +1 -9
  96. package/dist/menu/components/menu-avatar/index.js +1 -6
  97. package/dist/menu/components/menu-button/index.js +1 -10
  98. package/dist/menu/components/menu-buttons-list/index.d.ts +1 -1
  99. package/dist/menu/components/menu-buttons-list/index.js +1 -7
  100. package/dist/menu/hooks/use-menu.js +12 -12
  101. package/dist/message/component.js +33 -14
  102. package/dist/modal/components/modals/modal.d.ts +1 -2
  103. package/dist/modal/components/modals/modal.js +30 -33
  104. package/dist/modal/context.js +12 -9
  105. package/dist/modal/hooks/use-modal.d.ts +1 -1
  106. package/dist/mq/component.js +1 -6
  107. package/dist/notification/component.js +14 -12
  108. package/dist/page-container/component.js +1 -6
  109. package/dist/page-loading/component.d.ts +1 -2
  110. package/dist/page-with-controls/component.js +4 -7
  111. package/dist/picker-button/common/labeled-button/index.js +18 -12
  112. package/dist/picker-button/component.js +5 -5
  113. package/dist/picker-button/field/{Component.d.ts → component.d.ts} +1 -2
  114. package/dist/picker-button/field/index.d.ts +1 -1
  115. package/dist/picker-button/field/index.js +1 -1
  116. package/dist/picker-button/index.d.ts +1 -1
  117. package/dist/picker-button/index.js +4 -4
  118. package/dist/popover/component.d.ts +2 -2
  119. package/dist/popover/component.js +69 -63
  120. package/dist/radio/component.js +7 -7
  121. package/dist/radio-groups/component.d.ts +1 -2
  122. package/dist/radio-groups/component.js +9 -7
  123. package/dist/select/component.d.ts +8 -9
  124. package/dist/select/component.js +1 -9
  125. package/dist/select/components/arrow/component.d.ts +1 -2
  126. package/dist/select/components/base-select/component.js +97 -90
  127. package/dist/select/components/checkmark/component.d.ts +1 -2
  128. package/dist/select/components/field/component.d.ts +1 -2
  129. package/dist/select/components/field/component.js +8 -5
  130. package/dist/select/components/native-select/component.js +4 -11
  131. package/dist/select/components/optgroup/component.d.ts +1 -2
  132. package/dist/select/components/optgroup/component.js +4 -4
  133. package/dist/select/components/option/component.js +1 -1
  134. package/dist/select/components/options-list/component.d.ts +1 -2
  135. package/dist/select/components/options-list/component.js +25 -23
  136. package/dist/select/components/select-search/index.d.ts +1 -1
  137. package/dist/select/components/select-search/index.js +28 -26
  138. package/dist/select/components/virtual-options-list/component.d.ts +1 -2
  139. package/dist/select/components/virtual-options-list/component.js +52 -45
  140. package/dist/select/index.js +4 -4
  141. package/dist/select/presets/index.d.ts +1 -1
  142. package/dist/select/presets/index.js +4 -4
  143. package/dist/select/presets/use-lazy-loading/index.d.ts +3 -4
  144. package/dist/select/presets/use-lazy-loading/index.js +45 -43
  145. package/dist/select/presets/use-select-with-loading/hook.d.ts +1 -2
  146. package/dist/select/presets/use-select-with-loading/hook.js +8 -1
  147. package/dist/select/utils.js +32 -32
  148. package/dist/sidepanel/component.js +21 -15
  149. package/dist/sidepanel-header/component.js +17 -16
  150. package/dist/skeleton/component.js +4 -4
  151. package/dist/space/component.d.ts +2 -2
  152. package/dist/space/component.js +42 -45
  153. package/dist/space/{Item.d.ts → item.d.ts} +2 -2
  154. package/dist/spinner/component.js +6 -5
  155. package/dist/stack/index.d.ts +1 -1
  156. package/dist/stack/index.js +5 -5
  157. package/dist/stepped-progress-bar/components/step-bar.js +3 -3
  158. package/dist/stepped-progress-bar/index.d.ts +2 -2
  159. package/dist/stepped-progress-bar/index.js +37 -22
  160. package/dist/sticker/component.js +1 -17
  161. package/dist/suffix-input/component.js +13 -13
  162. package/dist/switch/component.js +7 -7
  163. package/dist/table/components/cells/index.d.ts +1 -2
  164. package/dist/table/components/empty-list/index.d.ts +1 -2
  165. package/dist/table/components/error/index.d.ts +2 -3
  166. package/dist/table/components/error/index.js +1 -1
  167. package/dist/table/components/loading/index.d.ts +1 -1
  168. package/dist/table/components/loading/index.js +18 -12
  169. package/dist/table/components/pagination/index.js +56 -53
  170. package/dist/table/components/table-header/index.js +59 -56
  171. package/dist/table/hooks/use-table-data.js +63 -60
  172. package/dist/table/table.d.ts +1 -1
  173. package/dist/table/table.js +73 -73
  174. package/dist/table/types.d.ts +3 -3
  175. package/dist/table/utils/get-query-from-url.js +1 -8
  176. package/dist/table/utils/get-tags.d.ts +1 -1
  177. package/dist/table/utils/get-tags.js +9 -12
  178. package/dist/table/utils/index.d.ts +1 -1
  179. package/dist/table/utils/index.js +4 -4
  180. package/dist/table/utils/parse-query-params.js +5 -1
  181. package/dist/table/utils/prepare-rows.d.ts +1 -2
  182. package/dist/table/utils/prepare-rows.js +4 -3
  183. package/dist/table/utils/query-adapter.d.ts +1 -1
  184. package/dist/table/utils/query-adapter.js +5 -5
  185. package/dist/table/utils/remove-query-param.js +3 -1
  186. package/dist/table/utils/reset-query-param.js +16 -9
  187. package/dist/table-status/component.js +5 -1
  188. package/dist/textarea/component.js +36 -28
  189. package/dist/theme-provider/component.js +33 -29
  190. package/dist/toast/component.d.ts +7 -8
  191. package/dist/toast/component.js +65 -63
  192. package/dist/toast-notifier/component.js +13 -13
  193. package/dist/toast-notifier/use-timer.d.ts +1 -1
  194. package/dist/toast-notifier/use-timer.js +5 -5
  195. package/dist/toast-plate/component.d.ts +3 -3
  196. package/dist/toast-plate/component.js +7 -7
  197. package/dist/tooltip/component.js +35 -35
  198. package/dist/tooltip/node-resolver.js +7 -7
  199. package/dist/typings/api.d.ts +3 -5
  200. package/dist/typography/colors.d.ts +1 -1
  201. package/dist/typography/title/component.d.ts +3 -3
  202. package/dist/typography/title/index.d.ts +1 -1
  203. package/dist/typography/title/index.js +3 -3
  204. package/dist/utils/date/index.js +12 -2
  205. package/dist/utils/index.d.ts +2 -2
  206. package/dist/utils/index.js +14 -14
  207. package/dist/utils/split-amount/util.js +4 -4
  208. package/dist/with-suffix/component.d.ts +13 -13
  209. package/dist/with-suffix/component.js +8 -8
  210. package/package.json +9 -34
  211. /package/dist/__internal/utils/{getDataTestId.d.ts → get-data-test-id.d.ts} +0 -0
  212. /package/dist/__internal/utils/{getDataTestId.js → get-data-test-id.js} +0 -0
  213. /package/dist/calendar/components/header/{/321/201omponent.d.ts" → component.d.ts} +0 -0
  214. /package/dist/calendar/components/months-table/{/321/201omponent.d.ts" → component.d.ts} +0 -0
  215. /package/dist/calendar/components/years-table/{/321/201omponent.d.ts" → component.d.ts} +0 -0
  216. /package/dist/picker-button/field/{Component.js → component.js} +0 -0
  217. /package/dist/space/{Item.js → item.js} +0 -0
@@ -1,25 +1,25 @@
1
1
  import { jsxs as k, jsx as s } from "react/jsx-runtime";
2
- import a, { useEffect as v, useState as L, useRef as P, useCallback as p, useMemo as b } from "react";
3
- import j from "@alphakits/icons/dist/SearchS";
4
- import { useClickOutside as E } from "../../../hooks/useClickOutside/index.js";
2
+ import v from "@alphakits/icons/dist/SearchS";
3
+ import a, { useEffect as P, useState as C, useRef as b, useCallback as p, useMemo as j } from "react";
5
4
  import "../../../toast-notifier/component.js";
5
+ import { useClickOutside as E } from "../../../hooks/useClickOutside/index.js";
6
6
  import { safeStringify as I } from "../../../utils/safe-stringify.js";
7
7
  import { Input as z } from "../../../input/component.js";
8
8
  import { BaseSelect as A } from "../base-select/component.js";
9
9
  import { OptionsList as B } from "../options-list/component.js";
10
10
  import F from "./index.module.css.js";
11
11
  const M = a.forwardRef(
12
- ({ inputProps: e, ...o }, n) => {
12
+ ({ inputProps: t, ...o }, n) => {
13
13
  const i = a.useRef(null), c = a.useRef(null);
14
- return v(() => {
14
+ return P(() => {
15
15
  i.current?.focus();
16
16
  }, []), /* @__PURE__ */ k("div", { ref: n, children: [
17
17
  /* @__PURE__ */ s("div", { style: { padding: "5px 20px" }, children: /* @__PURE__ */ s(
18
18
  z,
19
19
  {
20
20
  size: "s",
21
- leftAddons: /* @__PURE__ */ s(j, {}),
22
- ...e,
21
+ leftAddons: /* @__PURE__ */ s(v, {}),
22
+ ...t,
23
23
  fieldClassName: F.innerInput,
24
24
  block: !0,
25
25
  ref: i
@@ -29,37 +29,39 @@ const M = a.forwardRef(
29
29
  ] });
30
30
  }
31
31
  ), V = ({
32
- options: e,
32
+ options: t,
33
33
  searchType: o = "text",
34
34
  onChange: n,
35
35
  selected: i = "",
36
36
  ...c
37
37
  }) => {
38
- const [O, f] = L(e), [m, d] = L(""), h = P(null), S = p(
38
+ const [L, f] = C(t), [m, d] = C(""), h = b(null), S = p(
39
39
  (x, { value: l }) => {
40
40
  d(l);
41
41
  try {
42
- if (!l) return f(e);
43
- const C = String(l).toLowerCase(), g = e.reduce(
42
+ if (!l) return f(t);
43
+ const y = String(l).toLowerCase(), g = t.reduce(
44
44
  (u, r) => u.concat(r.options ? r.options : [r]),
45
45
  []
46
- ).filter(({ key: u, value: r, content: w }) => I({ key: u, value: r, content: w }).toLowerCase().includes(C));
46
+ ).filter(
47
+ ({ key: u, value: r, content: w }) => I({ key: u, value: r, content: w }).toLowerCase().includes(y)
48
+ );
47
49
  return f(g);
48
50
  } catch {
49
51
  return [];
50
52
  }
51
53
  },
52
- [e]
53
- ), t = p(() => {
54
- d(""), f(e);
55
- }, [e]), R = p(
54
+ [t]
55
+ ), e = p(() => {
56
+ d(""), f(t);
57
+ }, [t]), O = p(
56
58
  (x) => {
57
- n?.(x), t();
59
+ n?.(x), e();
58
60
  },
59
- [n, t]
61
+ [n, e]
60
62
  );
61
- E(h, t);
62
- const y = b(
63
+ E(h, e);
64
+ const R = j(
63
65
  () => ({
64
66
  ref: h,
65
67
  inputProps: {
@@ -67,22 +69,22 @@ const M = a.forwardRef(
67
69
  value: m,
68
70
  type: o,
69
71
  clear: !0,
70
- onClear: t
72
+ onClear: e
71
73
  }
72
74
  }),
73
- [S, m, o, t]
75
+ [S, m, o, e]
74
76
  );
75
77
  return /* @__PURE__ */ s(
76
78
  A,
77
79
  {
78
80
  ...c,
79
81
  selected: i,
80
- onChange: R,
82
+ onChange: O,
81
83
  showEmptyOptionsList: !0,
82
84
  OptionsList: M,
83
- filteredOptions: O,
84
- options: e,
85
- optionsListProps: y
85
+ filteredOptions: L,
86
+ options: t,
87
+ optionsListProps: R
86
88
  }
87
89
  );
88
90
  };
@@ -1,6 +1,5 @@
1
- import { default as React } from 'react';
2
1
  import { OptionsListProps } from '../../typings';
3
2
  export type VirtualOptionsList = OptionsListProps & {
4
3
  overscan?: number;
5
4
  };
6
- export declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, }: VirtualOptionsList) => React.JSX.Element;
5
+ export declare const VirtualOptionsList: ({ size, flatOptions, highlightedIndex, className, Option, open, options, overscan, Optgroup, dataTestId, emptyPlaceholder, visibleOptions, }: VirtualOptionsList) => import("react/jsx-runtime").JSX.Element;
@@ -1,88 +1,95 @@
1
1
  import { jsxs as v, jsx as f } from "react/jsx-runtime";
2
- import { useRef as b, useState as O, useEffect as a, useMemo as $ } from "react";
3
- import { useVirtual as E } from "react-virtual";
4
- import y from "classnames";
5
- import { usePrevious as G } from "../../../hooks/usePrevious/index.js";
2
+ import I from "classnames";
3
+ import { useRef as b, useState as g, useEffect as m, useMemo as E } from "react";
4
+ import { useVirtual as G } from "react-virtual";
6
5
  import "../../../toast-notifier/component.js";
7
- import { lastIndexOf as H, useVisibleOptions as M, isGroup as I } from "../../utils.js";
8
- import { Optgroup as P } from "../optgroup/component.js";
9
- import l from "./index.module.css.js";
10
- const R = ({
11
- size: N = "s",
12
- flatOptions: n = [],
6
+ import { usePrevious as H } from "../../../hooks/usePrevious/index.js";
7
+ import { lastIndexOf as M, useVisibleOptions as P, isGroup as T } from "../../utils.js";
8
+ import { Optgroup as Y } from "../optgroup/component.js";
9
+ import o from "./index.module.css.js";
10
+ const U = ({
11
+ size: y = "s",
12
+ flatOptions: t = [],
13
13
  highlightedIndex: s = -1,
14
- className: T,
14
+ className: N,
15
15
  Option: V,
16
- open: m,
17
- options: o = [],
16
+ open: a,
17
+ options: i = [],
18
18
  overscan: z = 10,
19
- Optgroup: D = P,
19
+ Optgroup: D = Y,
20
20
  dataTestId: S,
21
- emptyPlaceholder: p,
22
- visibleOptions: g = 5
21
+ emptyPlaceholder: x,
22
+ visibleOptions: j = 5
23
23
  }) => {
24
- const x = b(null), c = b(null), [j, K] = O(0), u = G(s) || -1, r = E({
25
- size: n.length,
24
+ const p = b(null), c = b(null), [K, L] = g(0), u = H(s) || -1, r = G({
25
+ size: t.length,
26
26
  parentRef: c,
27
27
  overscan: z
28
28
  });
29
- a(() => {
30
- m && r.scrollToIndex(s, { align: "end" });
31
- }, [m]), a(() => {
29
+ m(() => {
30
+ a && r.scrollToIndex(s, { align: "end" });
31
+ }, [a, r.scrollToIndex, s]), m(() => {
32
32
  s !== -1 && (r.virtualItems.some((e) => e.index === s) || r.scrollToIndex(s, { align: "end" }));
33
- }, [s]), a(() => {
34
- const e = (d) => !d.disabled, i = n.findIndex(e), t = H(n, e);
35
- u <= i && s === n.length - 1 && r.scrollToIndex(t), u >= t && s === 0 && r.scrollToIndex(0);
36
- }, [u, s]), a(() => {
37
- K(
33
+ }, [s, r.scrollToIndex, r.virtualItems.some]), m(() => {
34
+ const e = (d) => !d.disabled, l = t.findIndex(e), n = M(t, e);
35
+ u <= l && s === t.length - 1 && r.scrollToIndex(n), u >= n && s === 0 && r.scrollToIndex(0);
36
+ }, [
37
+ u,
38
+ s,
39
+ r.scrollToIndex,
40
+ t.length,
41
+ t.findIndex,
42
+ t
43
+ ]), m(() => {
44
+ L(
38
45
  /**
39
46
  * react-virtual может несколько раз отрендерить список с одним элементом,
40
47
  * поэтому нужно еще раз пересчитать высоту, когда список ВИДИМЫХ пунктов будет отрендерен полностью
41
48
  * Также, высоту нужно пересчитывать при изменении ОБЩЕГО кол-ва пунктов меню
42
49
  */
43
- r.virtualItems.length > 1 ? n.length : 1
50
+ r.virtualItems.length > 1 ? t.length : 1
44
51
  );
45
- }, [r.virtualItems.length, n.length]), M({
46
- visibleOptions: g,
47
- invalidate: j,
48
- listRef: x,
52
+ }, [r.virtualItems.length, t.length]), P({
53
+ visibleOptions: j,
54
+ invalidate: K,
55
+ listRef: p,
49
56
  styleTargetRef: c,
50
- open: m
57
+ open: a
51
58
  });
52
- const L = $(() => {
59
+ const $ = E(() => {
53
60
  let e = 0;
54
- return o.reduce((i, t, d) => (I(t) ? (i[e] = d, e += t.options.length) : e += 1, i), {});
55
- }, [o]);
61
+ return i.reduce((l, n, d) => (T(n) ? (l[e] = d, e += n.options.length) : e += 1, l), {});
62
+ }, [i]);
56
63
  return /* @__PURE__ */ v(
57
64
  "div",
58
65
  {
59
- className: y(l.virtualOptionsList, l[N], T),
66
+ className: I(o.virtualOptionsList, o[y], N),
60
67
  ref: c,
61
68
  "data-test-id": S,
62
69
  children: [
63
70
  /* @__PURE__ */ f(
64
71
  "div",
65
72
  {
66
- className: l.inner,
73
+ className: o.inner,
67
74
  style: {
68
75
  height: `${r.totalSize}px`
69
76
  },
70
- ref: x,
77
+ ref: p,
71
78
  children: r.virtualItems.map((e) => {
72
- const i = n[e.index], t = o[L[e.index]];
79
+ const l = t[e.index], n = i[$[e.index]];
73
80
  return /* @__PURE__ */ v(
74
81
  "div",
75
82
  {
76
83
  ref: e.measureRef,
77
- className: y(l.virtualRow, {
78
- [l.highlighted]: s === e.index
84
+ className: I(o.virtualRow, {
85
+ [o.highlighted]: s === e.index
79
86
  }),
80
87
  style: {
81
88
  transform: `translateY(${e.start}px)`
82
89
  },
83
90
  children: [
84
- t && /* @__PURE__ */ f(D, { label: t.label }),
85
- !I(i) && V({ option: i, index: e.index })
91
+ n && /* @__PURE__ */ f(D, { label: n.label }),
92
+ !T(l) && V({ option: l, index: e.index })
86
93
  ]
87
94
  },
88
95
  e.index
@@ -90,11 +97,11 @@ const R = ({
90
97
  })
91
98
  }
92
99
  ),
93
- p && o.length === 0 && /* @__PURE__ */ f("div", { className: l.emptyPlaceholder, children: p })
100
+ x && i.length === 0 && /* @__PURE__ */ f("div", { className: o.emptyPlaceholder, children: x })
94
101
  ]
95
102
  }
96
103
  );
97
104
  };
98
105
  export {
99
- R as VirtualOptionsList
106
+ U as VirtualOptionsList
100
107
  };
@@ -6,8 +6,8 @@ import { Optgroup as m } from "./components/optgroup/component.js";
6
6
  import { Option as l } from "./components/option/component.js";
7
7
  import { OptionsList as c } from "./components/options-list/component.js";
8
8
  import { VirtualOptionsList as L } from "./components/virtual-options-list/component.js";
9
- import { useSelectWithLoading as d } from "./presets/use-select-with-loading/hook.js";
10
- import { useLazyLoading as h } from "./presets/use-lazy-loading/index.js";
9
+ import { useLazyLoading as d } from "./presets/use-lazy-loading/index.js";
10
+ import { useSelectWithLoading as h } from "./presets/use-select-with-loading/hook.js";
11
11
  import { convertToOptions as b, isGroup as j, isOptionShape as v, joinOptions as w, lastIndexOf as y, processOptions as z, useVisibleOptions as A } from "./utils.js";
12
12
  export {
13
13
  p as Arrow,
@@ -24,7 +24,7 @@ export {
24
24
  w as joinOptions,
25
25
  y as lastIndexOf,
26
26
  z as processOptions,
27
- h as useLazyLoading,
28
- d as useSelectWithLoading,
27
+ d as useLazyLoading,
28
+ h as useSelectWithLoading,
29
29
  A as useVisibleOptions
30
30
  };
@@ -1,2 +1,2 @@
1
- export * from './use-select-with-loading/hook';
2
1
  export * from './use-lazy-loading';
2
+ export * from './use-select-with-loading/hook';
@@ -1,6 +1,6 @@
1
- import { useSelectWithLoading as r } from "./use-select-with-loading/hook.js";
2
- import { useLazyLoading as a } from "./use-lazy-loading/index.js";
1
+ import { useLazyLoading as r } from "./use-lazy-loading/index.js";
2
+ import { useSelectWithLoading as a } from "./use-select-with-loading/hook.js";
3
3
  export {
4
- a as useLazyLoading,
5
- r as useSelectWithLoading
4
+ r as useLazyLoading,
5
+ a as useSelectWithLoading
6
6
  };
@@ -1,4 +1,3 @@
1
- import { default as React } from 'react';
2
1
  import { OptionProps, OptionShape } from '../../typings';
3
2
  type OptionsFetcherResponse = {
4
3
  items: Array<{
@@ -24,12 +23,12 @@ type UseLazyLoadingProps = {
24
23
  };
25
24
  export declare function useLazyLoading({ limit, initialPage, optionsFetcher, }: UseLazyLoadingProps): {
26
25
  optionsProps: {
27
- Option: (props: OptionProps) => React.JSX.Element;
26
+ Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
28
27
  options: OptionShape[];
29
28
  optionsListProps: {
30
- ref: React.RefObject<HTMLDivElement | null>;
29
+ ref: import('react').RefObject<HTMLDivElement | null>;
31
30
  inputProps: {
32
- onChange: (event: React.ChangeEvent<HTMLInputElement, Element>, payload: {
31
+ onChange: (event: import('react').ChangeEvent<HTMLInputElement, Element>, payload: {
33
32
  value: string;
34
33
  }) => void;
35
34
  value: string;
@@ -1,9 +1,9 @@
1
1
  import { jsx as x } from "react/jsx-runtime";
2
- import { useReducer as b, useRef as u, useCallback as p, useEffect as m, useMemo as A } from "react";
2
+ import { useReducer as b, useRef as u, useCallback as p, useEffect as I, useMemo as A } from "react";
3
3
  import { Option as F } from "../../components/option/component.js";
4
4
  import { convertToOptions as H } from "../../utils.js";
5
5
  import "intersection-observer";
6
- const U = 300, c = {
6
+ const U = 300, a = {
7
7
  fetchOptionsStart() {
8
8
  return { type: "FETCH_OPTIONS_START" };
9
9
  },
@@ -25,12 +25,12 @@ const U = 300, c = {
25
25
  };
26
26
  function G({
27
27
  limit: n = 10,
28
- initialPage: E = 0,
29
- optionsFetcher: _
28
+ initialPage: m = 0,
29
+ optionsFetcher: S
30
30
  }) {
31
31
  const d = [], O = {
32
32
  opened: !1,
33
- page: E,
33
+ page: m,
34
34
  options: d,
35
35
  loading: !1,
36
36
  allOptionsLoaded: !1,
@@ -75,37 +75,36 @@ function G({
75
75
  default:
76
76
  return e;
77
77
  }
78
- }, [
79
- {
80
- opened: y,
81
- page: f,
82
- options: g,
83
- loading: o,
84
- allOptionsLoaded: R,
85
- searchText: T
86
- },
87
- r
88
- ] = b(C, O), a = u(void 0), s = p(() => {
89
- r(c.fetchOptionsStart()), new Promise((e, t) => {
90
- a.current?.(), a.current = t, _({ page: f, limit: n, searchText: T }).then((i) => {
78
+ }, [{ opened: E, page: _, options: f, loading: o, allOptionsLoaded: y, searchText: g }, r] = b(
79
+ C,
80
+ O
81
+ ), c = u(void 0), s = p(() => {
82
+ r(a.fetchOptionsStart()), new Promise((e, t) => {
83
+ c.current?.(), c.current = t, S({ page: _, limit: n, searchText: g }).then((i) => {
91
84
  e(i);
92
85
  });
93
86
  }).then((e) => {
94
- const t = H(e.items), { meta: { totalPages: i, currentPage: S } } = e;
95
- r(c.fetchOptionsSuccess({ options: t, hasMore: S < i })), a.current = void 0;
87
+ const t = H(e.items), {
88
+ meta: { totalPages: i, currentPage: h }
89
+ } = e;
90
+ r(
91
+ a.fetchOptionsSuccess({
92
+ options: t,
93
+ hasMore: h < i
94
+ })
95
+ ), c.current = void 0;
96
96
  }).catch(
97
97
  // eslint-disable-next-line @typescript-eslint/no-empty-function
98
98
  (e) => {
99
- console.log(e);
100
99
  }
101
100
  );
102
- }, [f, n, T, _]), l = u(null);
103
- m(() => {
101
+ }, [_, n, g, S]), l = u(null);
102
+ I(() => {
104
103
  let e;
105
- if (y && !o && !R) {
104
+ if (E && !o && !y) {
106
105
  e = new IntersectionObserver(
107
- ([S]) => {
108
- S.isIntersecting && (e && e.disconnect(), s());
106
+ ([h]) => {
107
+ h.isIntersecting && (e && e.disconnect(), s());
109
108
  },
110
109
  {
111
110
  root: l.current
@@ -117,30 +116,33 @@ function G({
117
116
  return () => {
118
117
  e && e.disconnect();
119
118
  };
120
- }, [f, y, R, E, o, s]);
119
+ }, [E, y, o, s]);
121
120
  const N = p(
122
121
  (e) => {
123
- e.open ? g.length === d.length && s() : (a.current?.(), r(c.fetchOptionsBreak())), r(c.setIsOpened(e.open ?? !1));
122
+ e.open ? f.length === d.length && s() : (c.current?.(), r(a.fetchOptionsBreak())), r(a.setIsOpened(e.open ?? !1));
124
123
  },
125
- [d.length, g.length, s]
126
- ), I = u(void 0), h = u(void 0);
127
- m(() => {
128
- I.current = s;
124
+ [d.length, f.length, s]
125
+ ), R = u(void 0), T = u(void 0);
126
+ I(() => {
127
+ R.current = s;
129
128
  }, [s]);
130
129
  const P = p(
131
130
  (e, t) => {
132
- r(c.setQueryString(t.value)), a.current?.(), l.current?.scrollTo({ top: 0 }), h.current && clearTimeout(h.current), h.current = setTimeout(() => {
133
- I.current?.();
131
+ r(a.setQueryString(t.value)), c.current?.(), l.current?.scrollTo({ top: 0 }), T.current && clearTimeout(T.current), T.current = setTimeout(() => {
132
+ R.current?.();
134
133
  }, U);
135
134
  },
136
135
  []
137
- ), v = A(() => Array(o ? n : 0).fill(0).map((e, t) => ({
138
- key: t,
139
- disabled: !0,
140
- content: "",
141
- loading: !0
142
- })), [o, n]), L = p(() => {
143
- r(c.reset());
136
+ ), v = A(
137
+ () => Array(o ? n : 0).fill(0).map((e, t) => ({
138
+ key: t,
139
+ disabled: !0,
140
+ content: "",
141
+ loading: !0
142
+ })),
143
+ [o, n]
144
+ ), L = p(() => {
145
+ r(a.reset());
144
146
  }, []);
145
147
  return {
146
148
  optionsProps: {
@@ -148,12 +150,12 @@ function G({
148
150
  (e) => /* @__PURE__ */ x(F, { ...e, highlighted: o ? !1 : e.highlighted }),
149
151
  [o]
150
152
  ),
151
- options: [...g, ...v],
153
+ options: [...f, ...v],
152
154
  optionsListProps: {
153
155
  ref: l,
154
156
  inputProps: {
155
157
  onChange: P,
156
- value: T
158
+ value: g
157
159
  }
158
160
  },
159
161
  onOpen: N
@@ -1,11 +1,10 @@
1
- import { default as React } from 'react';
2
1
  import { BaseSelectProps, OptionProps, OptionShape } from '../../typings';
3
2
  type useSelectWithLoadingProps = {
4
3
  loading?: boolean;
5
4
  visibleOptions?: BaseSelectProps['visibleOptions'];
6
5
  };
7
6
  export declare function useSelectWithLoading({ loading, visibleOptions, }: useSelectWithLoadingProps): {
8
- Option: (props: OptionProps) => React.JSX.Element;
7
+ Option: (props: OptionProps) => import("react/jsx-runtime").JSX.Element;
9
8
  options: OptionShape[];
10
9
  } | null;
11
10
  export {};
@@ -8,7 +8,14 @@ function k({
8
8
  visibleOptions: r = 6
9
9
  }) {
10
10
  const i = s(
11
- (e) => /* @__PURE__ */ o(f, { ...e, Checkmark: void 0, highlighted: t ? !1 : e.highlighted }),
11
+ (e) => /* @__PURE__ */ o(
12
+ f,
13
+ {
14
+ ...e,
15
+ Checkmark: void 0,
16
+ highlighted: t ? !1 : e.highlighted
17
+ }
18
+ ),
12
19
  [t]
13
20
  ), l = Array(r).fill(0).map((e, n) => ({
14
21
  key: n,
@@ -1,55 +1,55 @@
1
- import { useEffect as p, isValidElement as f, cloneElement as y } from "react";
2
- const a = (t) => Object.prototype.hasOwnProperty.call(t, "options"), g = (t) => !!t && Object.prototype.hasOwnProperty.call(t, "key"), O = ({
3
- selected: t,
1
+ import { useEffect as f, isValidElement as p, cloneElement as a } from "react";
2
+ const y = (e) => Object.hasOwn(e, "options"), d = (e) => typeof e == "object" && e !== null && Object.hasOwn(e, "key"), O = ({
3
+ selected: e,
4
4
  selectedMultiple: s
5
5
  }) => {
6
- const e = s || (t ? [t] : []);
7
- return e.length ? e.reduce((r, o, c) => (f(o.content) ? r.push(y(o.content, { key: o.key })) : r.push(o.content), c < e.length - 1 && r.push(", "), r), []) : null;
6
+ const t = s || (e ? [e] : []);
7
+ return t.length ? t.reduce((r, c, o) => (p(c.content) ? r.push(a(c.content, { key: c.key })) : r.push(c.content), o < t.length - 1 && r.push(", "), r), []) : null;
8
8
  };
9
- function k(t, s = []) {
10
- const e = [], r = Array.isArray(s) ? s : [s], o = r.filter(g), c = new Set(
9
+ function k(e, s = []) {
10
+ const t = [], r = Array.isArray(s) ? s : [s], c = r.filter(d), o = new Set(
11
11
  r.filter(
12
12
  (n) => typeof n == "string" || typeof n == "number"
13
13
  )
14
- ), h = (n) => c.has(n.key), l = (n) => {
15
- e.push(n), h(n) && o.push(n);
14
+ ), h = (n) => o.has(n.key), l = (n) => {
15
+ t.push(n), h(n) && c.push(n);
16
16
  };
17
- return t.forEach((n) => {
18
- a(n) ? n.options.forEach(l) : l(n);
19
- }), { flatOptions: e, selectedOptions: o };
17
+ return e.forEach((n) => {
18
+ y(n) ? n.options.forEach(l) : l(n);
19
+ }), { flatOptions: t, selectedOptions: c };
20
20
  }
21
21
  function E({
22
- visibleOptions: t,
22
+ visibleOptions: e,
23
23
  listRef: s,
24
- styleTargetRef: e = s,
24
+ styleTargetRef: t = s,
25
25
  open: r,
26
- invalidate: o
26
+ invalidate: c
27
27
  }) {
28
- p(() => {
29
- const c = s.current, h = e.current;
30
- if (r && c && h) {
28
+ f(() => {
29
+ const o = s.current, h = t.current;
30
+ if (r && o && h) {
31
31
  const l = [].slice.call(
32
- c.children,
32
+ o.children,
33
33
  0,
34
- t + 1
34
+ e + 1
35
35
  );
36
- let n = l.slice(0, t).reduce((i, u) => i + u.clientHeight, 0);
37
- t < c.children.length && (n += Math.round(l[l.length - 1].clientHeight / 2)), h.style.height = `${n}px`;
36
+ let n = l.slice(0, e).reduce((i, u) => i + u.clientHeight, 0);
37
+ e < o.children.length && (n += Math.round(l[l.length - 1].clientHeight / 2)), h.style.height = `${n}px`;
38
38
  }
39
- }, [s, r, e, t, o]);
39
+ }, [s, r, t, e]);
40
40
  }
41
- const j = (t, s) => {
42
- for (let e = t.length - 1; e >= 0; e--)
43
- if (s(t[e])) return e;
41
+ const j = (e, s) => {
42
+ for (let t = e.length - 1; t >= 0; t--)
43
+ if (s(e[t])) return t;
44
44
  return -1;
45
- }, m = (t, s) => t.map((e) => ({
46
- key: e.id,
47
- content: s && e[s] || e.title || e.name
45
+ }, w = (e, s) => e.map((t) => ({
46
+ key: t.id,
47
+ content: s && t[s] || t.title || t.name
48
48
  }));
49
49
  export {
50
- m as convertToOptions,
51
- a as isGroup,
52
- g as isOptionShape,
50
+ w as convertToOptions,
51
+ y as isGroup,
52
+ d as isOptionShape,
53
53
  O as joinOptions,
54
54
  j as lastIndexOf,
55
55
  k as processOptions,