@rio-cloud/rio-uikit 2.0.1 → 2.1.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 (202) hide show
  1. package/components/actionBarItem/ActionBarItem.d.ts +2 -2
  2. package/components/actionBarItem/ActionBarItem.js.map +1 -1
  3. package/components/applicationHeader/ApplicationHeader.d.ts +6 -7
  4. package/components/applicationHeader/ApplicationHeader.js.map +1 -1
  5. package/components/applicationLayout/SubNavigation.d.ts +7 -0
  6. package/components/applicationLayout/SubNavigation.js.map +1 -1
  7. package/components/assetTree/AssetTree.d.ts +7 -0
  8. package/components/assetTree/AssetTree.js.map +1 -1
  9. package/components/assetTree/Tree.d.ts +15 -0
  10. package/components/assetTree/Tree.js.map +1 -1
  11. package/components/assetTree/TreeIcon.d.ts +30 -0
  12. package/components/assetTree/TreeIcon.js +16 -0
  13. package/components/assetTree/TreeIcon.js.map +1 -0
  14. package/components/assetTree/TreeLeaf.js +22 -22
  15. package/components/assetTree/TreeLeaf.js.map +1 -1
  16. package/components/assetTree/TreeNode.js +25 -25
  17. package/components/assetTree/TreeNode.js.map +1 -1
  18. package/components/assetTree/TreeSearch.d.ts +2 -0
  19. package/components/assetTree/TreeSearch.js.map +1 -1
  20. package/components/barList/BarList.d.ts +26 -0
  21. package/components/barList/BarList.js.map +1 -1
  22. package/components/bottomSheet/BottomSheet.d.ts +17 -3
  23. package/components/bottomSheet/BottomSheet.js.map +1 -1
  24. package/components/bottomSheet/TimedBottomSheet.d.ts +10 -0
  25. package/components/bottomSheet/TimedBottomSheet.js.map +1 -1
  26. package/components/calendarStripe/CalendarStripe.d.ts +1 -1
  27. package/components/calendarStripe/CalendarStripe.js +34 -36
  28. package/components/calendarStripe/CalendarStripe.js.map +1 -1
  29. package/components/charts/Area.d.ts +2 -2
  30. package/components/charts/Area.js.map +1 -1
  31. package/components/charts/Line.d.ts +2 -2
  32. package/components/charts/Line.js.map +1 -1
  33. package/components/checkbox/Checkbox.d.ts +0 -3
  34. package/components/checkbox/Checkbox.js.map +1 -1
  35. package/components/clearableInput/ClearableInput.d.ts +21 -20
  36. package/components/clearableInput/ClearableInput.js.map +1 -1
  37. package/components/collapse/Collapse.d.ts +3 -0
  38. package/components/collapse/Collapse.js +12 -12
  39. package/components/collapse/Collapse.js.map +1 -1
  40. package/components/contentLoader/ContentLoader.d.ts +10 -2
  41. package/components/contentLoader/ContentLoader.js.map +1 -1
  42. package/components/dataTabs/DataTabs.d.ts +6 -0
  43. package/components/dataTabs/DataTabs.js.map +1 -1
  44. package/components/dialog/ConfirmationDialog.d.ts +22 -0
  45. package/components/dialog/ConfirmationDialog.js.map +1 -1
  46. package/components/dialog/Dialog.d.ts +13 -1
  47. package/components/dialog/Dialog.js.map +1 -1
  48. package/components/dialog/ReleaseNotesDialog.d.ts +3 -3
  49. package/components/dialog/ReleaseNotesDialog.js.map +1 -1
  50. package/components/dropdown/ButtonDropdown.d.ts +4 -0
  51. package/components/dropdown/ButtonDropdown.js +51 -51
  52. package/components/dropdown/ButtonDropdown.js.map +1 -1
  53. package/components/dropdown/DropdownSubmenu.d.ts +4 -0
  54. package/components/dropdown/DropdownSubmenu.js.map +1 -1
  55. package/components/editableContent/EditableContent.d.ts +6 -0
  56. package/components/editableContent/EditableContent.js.map +1 -1
  57. package/components/expander/ExpanderList.d.ts +3 -0
  58. package/components/expander/ExpanderList.js.map +1 -1
  59. package/components/expander/ExpanderPanel.d.ts +14 -4
  60. package/components/expander/ExpanderPanel.js.map +1 -1
  61. package/components/fade/Fade.d.ts +1 -1
  62. package/components/fade/Fade.js.map +1 -1
  63. package/components/filepicker/FilePicker.d.ts +0 -2
  64. package/components/filepicker/FilePicker.js.map +1 -1
  65. package/components/groupedItemList/GroupedItemList.d.ts +10 -7
  66. package/components/groupedItemList/GroupedItemList.js.map +1 -1
  67. package/components/listMenu/ListMenu.js.map +1 -1
  68. package/components/listMenu/ListMenuGroup.d.ts +2 -1
  69. package/components/listMenu/ListMenuGroup.js.map +1 -1
  70. package/components/map/components/Map.js.map +1 -1
  71. package/components/map/components/constants.js.map +1 -1
  72. package/components/map/components/features/ContextMenuItem.d.ts +1 -1
  73. package/components/map/components/features/ContextMenuItem.js +2 -17
  74. package/components/map/components/features/ContextMenuItem.js.map +1 -1
  75. package/components/map/components/features/basics/Polyline.d.ts +4 -1
  76. package/components/map/components/features/basics/Polyline.js +1 -1
  77. package/components/map/components/features/basics/Polyline.js.map +1 -1
  78. package/components/map/components/features/layers/MarkerLayer.d.ts +3 -1
  79. package/components/map/components/features/layers/MarkerLayer.js.map +1 -1
  80. package/components/map/components/features/layers/clustering/ClusterLayer.js +1 -1
  81. package/components/map/components/features/layers/clustering/ClusterLayer.js.map +1 -1
  82. package/components/map/components/features/layers/clustering/SimpleClusterLayer.d.ts +3 -2
  83. package/components/map/components/features/layers/clustering/SimpleClusterLayer.js.map +1 -1
  84. package/components/map/components/features/layers/overlayLayers/RoadRestrictionLayer.js +7 -7
  85. package/components/map/components/features/layers/overlayLayers/RoadRestrictionLayer.js.map +1 -1
  86. package/components/map/components/features/layers/overlayLayers/TrafficLayer.js +4 -4
  87. package/components/map/components/features/layers/overlayLayers/TrafficLayer.js.map +1 -1
  88. package/components/map/utils/clustering.d.ts +6 -1
  89. package/components/map/utils/clustering.js +25 -19
  90. package/components/map/utils/clustering.js.map +1 -1
  91. package/components/map/utils/rendering.d.ts +1 -1
  92. package/components/map/utils/rendering.js +23 -23
  93. package/components/map/utils/rendering.js.map +1 -1
  94. package/components/menuItems/MenuItem.d.ts +23 -0
  95. package/components/menuItems/MenuItem.js.map +1 -1
  96. package/components/notification/Notification.js +4 -4
  97. package/components/notification/Notification.js.map +1 -1
  98. package/components/onboarding/OnboardingTip.d.ts +18 -12
  99. package/components/onboarding/OnboardingTip.js.map +1 -1
  100. package/components/overlay/OverlayTrigger.d.ts +43 -1
  101. package/components/overlay/OverlayTrigger.js.map +1 -1
  102. package/components/pager/Pager.d.ts +3 -0
  103. package/components/pager/Pager.js.map +1 -1
  104. package/components/popover/Popover.d.ts +1 -0
  105. package/components/popover/Popover.js.map +1 -1
  106. package/components/preloader/ImagePreloader.d.ts +1 -1
  107. package/components/preloader/ImagePreloader.js.map +1 -1
  108. package/components/radiobutton/RadioButton.d.ts +9 -5
  109. package/components/radiobutton/RadioButton.js.map +1 -1
  110. package/components/releaseNotes/ReleaseNotes.d.ts +0 -3
  111. package/components/releaseNotes/ReleaseNotes.js.map +1 -1
  112. package/components/resizer/Resizer.d.ts +17 -3
  113. package/components/resizer/Resizer.js.map +1 -1
  114. package/components/rioglyph/Rioglyph.d.ts +20 -8
  115. package/components/rioglyph/Rioglyph.js.map +1 -1
  116. package/components/rules/RulesWrapper.js +1 -1
  117. package/components/rules/RulesWrapper.js.map +1 -1
  118. package/components/saveableInput/SaveableDateInput.d.ts +20 -2
  119. package/components/saveableInput/SaveableDateInput.js.map +1 -1
  120. package/components/saveableInput/SaveableInput.d.ts +10 -2
  121. package/components/saveableInput/SaveableInput.js.map +1 -1
  122. package/components/selects/BaseSelectDropdown.js +90 -79
  123. package/components/selects/BaseSelectDropdown.js.map +1 -1
  124. package/components/selects/Select.d.ts +5 -0
  125. package/components/selects/Select.js +94 -94
  126. package/components/selects/Select.js.map +1 -1
  127. package/components/sidebars/Sidebar.d.ts +19 -3
  128. package/components/sidebars/Sidebar.js.map +1 -1
  129. package/components/slider/RangeSlider.d.ts +15 -0
  130. package/components/slider/RangeSlider.js.map +1 -1
  131. package/components/slider/Slider.d.ts +9 -0
  132. package/components/slider/Slider.js.map +1 -1
  133. package/components/smoothScrollbars/SmoothScrollbars.d.ts +44 -0
  134. package/components/smoothScrollbars/SmoothScrollbars.js.map +1 -1
  135. package/components/spinner/Spinner.d.ts +3 -3
  136. package/components/spinner/Spinner.js.map +1 -1
  137. package/components/states/BaseStateProps.d.ts +6 -2
  138. package/components/states/StateIcon.d.ts +14 -1
  139. package/components/states/StateIcon.js.map +1 -1
  140. package/components/statsWidget/StatsWidget.d.ts +2 -0
  141. package/components/statsWidget/StatsWidget.js.map +1 -1
  142. package/components/statsWidget/StatsWidgetBody.d.ts +1 -0
  143. package/components/statsWidget/StatsWidgetBody.js.map +1 -1
  144. package/components/statsWidget/StatsWidgetNumber.d.ts +2 -0
  145. package/components/statsWidget/StatsWidgetNumber.js.map +1 -1
  146. package/components/statusBar/StatusBar.d.ts +2 -31
  147. package/components/statusBar/StatusBar.js.map +1 -1
  148. package/components/statusBar/StatusBarIcon.d.ts +2 -2
  149. package/components/statusBar/StatusBarIcon.js.map +1 -1
  150. package/components/statusBar/StatusBarLabel.d.ts +2 -2
  151. package/components/statusBar/StatusBarLabel.js.map +1 -1
  152. package/components/statusBar/StatusBarProgressBar.d.ts +1 -1
  153. package/components/statusBar/StatusBarProgressBar.js.map +1 -1
  154. package/components/statusBar/{StatusBar.types.d.ts → StatusBarProps.d.ts} +44 -2
  155. package/components/steppedProgressBar/SteppedProgressBar.d.ts +1 -1
  156. package/components/steppedProgressBar/SteppedProgressBar.js.map +1 -1
  157. package/components/switch/Switch.d.ts +13 -1
  158. package/components/switch/Switch.js.map +1 -1
  159. package/components/table/SortArrowDown.d.ts +1 -1
  160. package/components/table/SortArrowDown.js.map +1 -1
  161. package/components/table/SortArrowUp.d.ts +1 -1
  162. package/components/table/SortArrowUp.js.map +1 -1
  163. package/components/table/TableSettingsDialog.d.ts +5 -0
  164. package/components/table/TableSettingsDialog.js +119 -109
  165. package/components/table/TableSettingsDialog.js.map +1 -1
  166. package/components/table/TableSettingsDialogFooter.js +9 -9
  167. package/components/table/TableSettingsDialogFooter.js.map +1 -1
  168. package/components/table/TableViewToggles.d.ts +21 -1
  169. package/components/table/TableViewToggles.js.map +1 -1
  170. package/components/tag/Tag.d.ts +7 -2
  171. package/components/tag/Tag.js.map +1 -1
  172. package/components/tagManager/TagManager.d.ts +15 -0
  173. package/components/tagManager/TagManager.js.map +1 -1
  174. package/components/tagManager/TagManagerTag.d.ts +9 -0
  175. package/components/teaser/Teaser.d.ts +57 -55
  176. package/components/teaser/Teaser.js.map +1 -1
  177. package/components/teaser/TeaserContainer.d.ts +1 -1
  178. package/components/teaser/TeaserContainer.js.map +1 -1
  179. package/components/tooltip/SimpleTooltip.d.ts +22 -4
  180. package/components/tooltip/SimpleTooltip.js.map +1 -1
  181. package/components/tooltip/Tooltip.d.ts +22 -2
  182. package/components/tooltip/Tooltip.js.map +1 -1
  183. package/components/video/ResponsiveVideo.d.ts +8 -3
  184. package/components/video/ResponsiveVideo.js.map +1 -1
  185. package/hooks/useKey.d.ts +1 -1
  186. package/hooks/useKey.js.map +1 -1
  187. package/hooks/useOnboarding.d.ts +86 -80
  188. package/hooks/useOnboarding.js.map +1 -1
  189. package/hooks/useTableExport.js.map +1 -1
  190. package/hooks/useUncontrollable.d.ts +1 -1
  191. package/hooks/useUncontrollable.js.map +1 -1
  192. package/package.json +12 -14
  193. package/utils/colorScheme.js +14 -13
  194. package/utils/colorScheme.js.map +1 -1
  195. package/utils/cssuseragent.js.map +1 -1
  196. package/utils/scrollItemIntoView.js +12 -11
  197. package/utils/scrollItemIntoView.js.map +1 -1
  198. package/utils/urlFeatureToggles.js +19 -20
  199. package/utils/urlFeatureToggles.js.map +1 -1
  200. package/version.d.ts +1 -1
  201. package/version.js +1 -1
  202. package/version.js.map +1 -1
@@ -1,143 +1,154 @@
1
- import { jsx as i, jsxs as b, Fragment as X } from "react/jsx-runtime";
2
- import { useState as h, useRef as q, useLayoutEffect as z, useEffect as J } from "react";
3
- import O from "classnames";
4
- import { isEmpty as v } from "es-toolkit/compat";
5
- import { noop as f } from "es-toolkit/function";
6
- import { useDropDirection as Q } from "../../utils/useDropDirection.js";
7
- import { scrollItemIntoView as A, DOWN as w, UP as I } from "../../utils/scrollItemIntoView.js";
8
- import Y from "../../hooks/useEffectOnce.js";
9
- import Z from "../../hooks/useKey.js";
10
- import $ from "./DropdownHeader.js";
11
- import ee from "./NoItemMessage.js";
12
- import te from "../spinner/Spinner.js";
13
- const L = "data-item-id", se = 0, M = "focus", Ie = (g) => {
1
+ import { jsx as c, jsxs as x, Fragment as Q } from "react/jsx-runtime";
2
+ import { useState as y, useRef as _, useEffect as b, useLayoutEffect as Y } from "react";
3
+ import C from "classnames";
4
+ import { isEmpty as V } from "es-toolkit/compat";
5
+ import { noop as N } from "es-toolkit/function";
6
+ import { useDropDirection as Z } from "../../utils/useDropDirection.js";
7
+ import { DOWN as O, scrollItemIntoView as T, UP as g } from "../../utils/scrollItemIntoView.js";
8
+ import $ from "../../hooks/useEffectOnce.js";
9
+ import ee from "../../hooks/useKey.js";
10
+ import te from "./DropdownHeader.js";
11
+ import re from "./NoItemMessage.js";
12
+ import se from "../spinner/Spinner.js";
13
+ const B = "data-item-id", ne = 0, H = "focus", L = O, be = (h) => {
14
14
  const {
15
15
  isOpen: r = !1,
16
16
  isLoading: l = !1,
17
- updateDOMValues: u = f,
18
- onOpen: c = f,
19
- onSelect: m = f,
20
- onClose: D = f,
21
- options: n = [],
22
- autoDropDirection: U = !0,
23
- dropup: F = !1,
24
- pullRight: S = !1,
25
- useActiveClass: _ = !1,
26
- focusedItemIndex: R,
27
- keyboardUsed: V,
28
- noItemMessage: B,
29
- dropdownClassName: H
30
- } = g, [o, j] = h(R || se), [K, G] = h(V), s = q(null);
31
- Y(() => {
32
- const e = k();
17
+ updateDOMValues: u = N,
18
+ onOpen: i = N,
19
+ onSelect: p = N,
20
+ onClose: E = N,
21
+ options: o = [],
22
+ autoDropDirection: j = !0,
23
+ dropup: K = !1,
24
+ pullRight: G = !1,
25
+ useActiveClass: P = !1,
26
+ focusedItemIndex: m,
27
+ keyboardUsed: f,
28
+ noItemMessage: W,
29
+ dropdownClassName: X
30
+ } = h, [n, k] = y(m || ne), [q, A] = y(f), w = _(L), s = _(null);
31
+ b(() => {
32
+ r && s.current && (s.current.scrollTop = 0);
33
+ }, [r]), b(() => {
34
+ typeof m == "number" && k(m), typeof f == "boolean" && A(f), r || (w.current = L);
35
+ }, [m, f, r]), $(() => {
36
+ const e = F();
33
37
  u(e);
34
38
  });
35
- const p = Q({ pullRight: S, dropup: F, autoDropDirection: U, dropdownMenuRef: s }, [r]);
36
- z(() => {
39
+ const I = Z({ pullRight: G, dropup: K, autoDropDirection: j, dropdownMenuRef: s }, [r]);
40
+ Y(() => {
37
41
  if (s.current) {
38
42
  const e = s.current.parentElement;
39
- p.dropup ? e?.classList.add("dropup") : e?.classList.remove("dropup");
43
+ I.dropup ? e?.classList.add("dropup") : e?.classList.remove("dropup");
40
44
  }
41
- }, [p, s]), J(() => {
42
- s.current && u(k());
43
- }, [s.current]);
44
- const [x, E] = h(r);
45
- r && !x ? (c(p.dropup), E(r)) : !r && x && (D(), E(r)), Z((e) => {
45
+ }, [I, s]), b(() => {
46
+ s.current && u(F());
47
+ }, [s.current]), b(() => {
48
+ r && T(
49
+ w.current || L,
50
+ s.current,
51
+ D()
52
+ );
53
+ }, [n, r]);
54
+ const [v, U] = y(r);
55
+ r && !v ? (i(I.dropup), U(r)) : !r && v && (E(), U(r)), ee((e) => {
46
56
  if (r)
47
57
  switch (e.key) {
48
58
  case "Escape": {
49
- D();
59
+ E();
50
60
  break;
51
61
  }
52
62
  case "Tab": {
53
- D();
63
+ E();
54
64
  break;
55
65
  }
56
66
  case "Enter": {
57
- P(e);
67
+ z(e);
58
68
  break;
59
69
  }
60
70
  case "ArrowUp": {
61
- e.preventDefault(), y(I), A(I, s.current, N());
71
+ e.preventDefault(), M(g), T(g, s.current, D());
62
72
  break;
63
73
  }
64
74
  case "ArrowDown": {
65
- e.preventDefault(), y(w), A(w, s.current, N());
75
+ e.preventDefault(), M(O), T(O, s.current, D());
66
76
  break;
67
77
  }
68
78
  }
69
79
  });
70
- const y = (e) => {
80
+ const M = (e) => {
71
81
  let t = 0;
72
82
  switch (e) {
73
- case I: {
74
- t = o <= 0 ? o : o - 1;
83
+ case g: {
84
+ t = n <= 0 ? n : n - 1;
75
85
  break;
76
86
  }
77
- case w: {
78
- t = o === n.length - 1 ? o : o + 1;
87
+ case O: {
88
+ t = n === o.length - 1 ? n : n + 1;
79
89
  break;
80
90
  }
81
91
  }
82
- const a = e === I ? n.length - 1 : 0;
83
- j(t < 0 ? a : t), G(!0);
84
- }, C = () => s.current?.getElementsByTagName("a") || [], k = () => {
92
+ w.current = e;
93
+ const a = e === g ? o.length - 1 : 0;
94
+ k(t < 0 ? a : t), A(!0);
95
+ }, S = () => s.current?.getElementsByTagName("a") || [], F = () => {
85
96
  if (s.current)
86
- return [...C()].map((t) => ({
87
- id: t.getAttribute(L),
97
+ return [...S()].map((t) => ({
98
+ id: t.getAttribute(B),
88
99
  text: t.textContent
89
100
  }));
90
- }, N = () => [...C()].find((t) => t.className.includes(M)), P = (e) => {
91
- if (e.preventDefault(), v(n))
101
+ }, D = () => [...S()].find((t) => t.className.includes(H)), z = (e) => {
102
+ if (e.preventDefault(), V(o))
92
103
  return;
93
- const t = N();
104
+ const t = D();
94
105
  if (t) {
95
- const a = n.find((d) => d.id === t.getAttribute(L));
96
- m(a);
106
+ const a = o.find((d) => d.id === t.getAttribute(B));
107
+ p(a);
97
108
  }
98
- }, W = (e) => {
109
+ }, J = (e) => {
99
110
  e.preventDefault();
100
- const t = e.currentTarget.getElementsByTagName("input")[0].value, a = n.find((d) => d.id === t);
101
- m(a);
102
- }, T = O("dropdown-menu", p.pullRight && "pull-right", H);
103
- return v(n) ? /* @__PURE__ */ i(ee, { noItemMessage: B, className: T }) : /* @__PURE__ */ b("ul", { className: T, ref: s, role: "menu", children: [
104
- l && /* @__PURE__ */ i("div", { className: "display-flex justify-content-center padding-10", children: /* @__PURE__ */ i(te, {}) }),
105
- !l && n.map((e, t) => {
111
+ const t = e.currentTarget.getElementsByTagName("input")[0].value, a = o.find((d) => d.id === t);
112
+ p(a);
113
+ }, R = C("dropdown-menu", I.pullRight && "pull-right", X);
114
+ return V(o) ? /* @__PURE__ */ c(re, { noItemMessage: W, className: R }) : /* @__PURE__ */ x("ul", { className: R, ref: s, role: "menu", children: [
115
+ l && /* @__PURE__ */ c("div", { className: "display-flex justify-content-center padding-10", children: /* @__PURE__ */ c(se, {}) }),
116
+ !l && o.map((e, t) => {
106
117
  if (e.header)
107
- return /* @__PURE__ */ i($, { icon: e.icon, label: e.label }, e.id);
108
- const a = O(
109
- K && o === t ? M : "",
118
+ return /* @__PURE__ */ c(te, { icon: e.icon, label: e.label }, e.id);
119
+ const a = C(
120
+ q && n === t ? H : "",
110
121
  e.disabled && "pointer-events-none",
111
122
  "display-flex align-items-center gap-3"
112
- ), d = O(
123
+ ), d = C(
113
124
  e.disabled && "disabled",
114
- _ && e.selected && "active"
125
+ P && e.selected && "active"
115
126
  );
116
- return /* @__PURE__ */ i("li", { className: d, role: "listitem", children: /* @__PURE__ */ b(
127
+ return /* @__PURE__ */ c("li", { className: d, role: "listitem", children: /* @__PURE__ */ x(
117
128
  "a",
118
129
  {
119
130
  role: "menuitem",
120
131
  className: a,
121
132
  "data-item-id": e.id,
122
133
  "data-item-index": t,
123
- onClick: e.disabled ? void 0 : W,
134
+ onClick: e.disabled ? void 0 : J,
124
135
  children: [
125
- /* @__PURE__ */ b("span", { className: "selected-option-dropdown-item", children: [
126
- e.icon && /* @__PURE__ */ i(X, { children: e.icon }),
136
+ /* @__PURE__ */ x("span", { className: "selected-option-dropdown-item", children: [
137
+ e.icon && /* @__PURE__ */ c(Q, { children: e.icon }),
127
138
  e.label
128
139
  ] }),
129
- /* @__PURE__ */ i("input", { type: "hidden", value: e.id })
140
+ /* @__PURE__ */ c("input", { type: "hidden", value: e.id })
130
141
  ]
131
142
  }
132
143
  ) }, e.id);
133
144
  })
134
145
  ] });
135
- }, ge = (g, r, l) => {
136
- const u = g.filter((c) => c.text.toLowerCase().includes(r.toLowerCase()));
137
- return l.filter((c) => u.find((m) => m.id === c.id));
146
+ }, Ne = (h, r, l) => {
147
+ const u = h.filter((i) => i.text.toLowerCase().includes(r.toLowerCase()));
148
+ return l.filter((i) => u.find((p) => p.id === i.id));
138
149
  };
139
150
  export {
140
- Ie as default,
141
- ge as filterOptions
151
+ be as default,
152
+ Ne as filterOptions
142
153
  };
143
154
  //# sourceMappingURL=BaseSelectDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseSelectDropdown.js","sources":["../../../src/components/selects/BaseSelectDropdown.tsx"],"sourcesContent":["import type React from 'react';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { noop } from 'es-toolkit/function';\n\nimport { useDropDirection } from '../../utils/useDropDirection';\nimport { DOWN, scrollItemIntoView, UP } from '../../utils/scrollItemIntoView';\nimport useEffectOnce from '../../hooks/useEffectOnce';\nimport useKey from '../../useKey';\nimport DropdownHeader from './DropdownHeader';\nimport NoItemMessage from './NoItemMessage';\nimport Spinner from '../spinner/Spinner';\n\nconst DATA_ATTRIBUTE_ID = 'data-item-id';\nconst DEFAULT_FOCUSED_ITEM_INDEX = 0;\nconst HIGHLIGHT_CLASS = 'focus';\n\nexport type OptionDOMValue = {\n id: string;\n text: string;\n};\n\nexport type SelectOption = {\n /**\n * Used to identify an option.\n */\n id: string;\n\n /**\n * The option item text.\n */\n label: string | React.ReactNode;\n\n /**\n * Icon to be displayed in front of the label.\n */\n icon?: React.ReactNode;\n\n /**\n * Defines whether the menu item is selected.\n *\n * @default false\n */\n selected?: boolean;\n\n /**\n * Setting \"disabled\" to true will disable the respective item.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Will treat the given value as a menu header\n */\n header?: boolean;\n};\n\nexport type BaseSelectDropdownProps<T extends SelectOption> = {\n options?: T[];\n isOpen?: boolean;\n isLoading?: boolean;\n updateDOMValues?: (values: OptionDOMValue[] | undefined) => void;\n onOpen?: (hasDropup: boolean) => void;\n onSelect?: (selectedItem: T | undefined) => void;\n onClose?: () => void;\n placeholder?: string | React.ReactNode;\n dropup?: boolean;\n pullRight?: boolean;\n autoDropDirection?: boolean;\n noItemMessage?: string | React.ReactNode;\n focusedItemIndex?: number;\n dropdownClassName?: string;\n keyboardUsed?: boolean;\n useActiveClass?: boolean;\n};\n\nconst BaseSelectDropdown = <T extends SelectOption>(props: BaseSelectDropdownProps<T>) => {\n const {\n isOpen = false,\n isLoading = false,\n updateDOMValues = noop,\n onOpen = noop,\n onSelect = noop,\n onClose = noop,\n options = [],\n autoDropDirection = true,\n dropup = false,\n pullRight = false,\n useActiveClass = false,\n focusedItemIndex: externalFocusedItemIndex,\n keyboardUsed: externalKeyboardUsed,\n noItemMessage,\n dropdownClassName,\n } = props;\n\n const [focusedItemIndex, setFocusedItemIndex] = useState(externalFocusedItemIndex || DEFAULT_FOCUSED_ITEM_INDEX);\n const [keyboardUsed, setKeyboardUsed] = useState(externalKeyboardUsed);\n\n const dropdownMenuRef = useRef<HTMLUListElement>(null);\n\n useEffectOnce(() => {\n // all available items need to be rendered in order to know their DOM value\n // which will be used for filtering in the parent component\n const currentItemDOMValues = updateItemDOMValues();\n updateDOMValues(currentItemDOMValues);\n });\n\n // Overwrite position of dropdown menu in case auto drop is enabled\n const dropDirection = useDropDirection({ pullRight, dropup, autoDropDirection, dropdownMenuRef }, [isOpen]);\n\n // Add or remove the \"dropup\" class from the parent Select/Multiselect component to position\n // the dropdown element accordingly via CSS\n useLayoutEffect(() => {\n if (dropdownMenuRef.current) {\n const parent = dropdownMenuRef.current.parentElement;\n if (dropDirection.dropup) {\n parent?.classList.add('dropup');\n } else {\n parent?.classList.remove('dropup');\n }\n }\n }, [dropDirection, dropdownMenuRef]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>\n useEffect(() => {\n if (dropdownMenuRef.current) {\n updateDOMValues(updateItemDOMValues());\n }\n }, [dropdownMenuRef.current]);\n\n // update internal state for isOpen\n const [previousIsOpen, setPreviousIsOpen] = useState(isOpen);\n if (isOpen && !previousIsOpen) {\n onOpen(dropDirection.dropup);\n setPreviousIsOpen(isOpen);\n } else if (!isOpen && previousIsOpen) {\n onClose();\n setPreviousIsOpen(isOpen);\n }\n\n useKey(event => {\n if (isOpen) {\n switch (event.key) {\n case 'Escape': {\n // close dropdown on esc\n onClose();\n break;\n }\n case 'Tab': {\n // close dropdown on tab\n onClose();\n break;\n }\n case 'Enter': {\n // select item on enter\n selectOptionOnEnter(event);\n break;\n }\n case 'ArrowUp': {\n // prevent scrolling the page when dropdown menu is open\n event.preventDefault();\n\n // select item above on arrow up key\n focusOption(UP);\n scrollItemIntoView(UP, dropdownMenuRef.current, getFocusedOptionNode());\n break;\n }\n case 'ArrowDown': {\n // prevent scrolling the page when dropdown menu is open\n event.preventDefault();\n\n // select item below on arrow down key\n focusOption(DOWN);\n scrollItemIntoView(DOWN, dropdownMenuRef.current, getFocusedOptionNode());\n break;\n }\n default:\n break;\n }\n }\n });\n\n const focusOption = (direction: typeof UP | typeof DOWN) => {\n let nextFocusedItem = 0;\n\n switch (direction) {\n case UP: {\n nextFocusedItem = focusedItemIndex <= 0 ? focusedItemIndex : focusedItemIndex - 1;\n break;\n }\n case DOWN: {\n nextFocusedItem = focusedItemIndex === options.length - 1 ? focusedItemIndex : focusedItemIndex + 1;\n break;\n }\n default:\n break;\n }\n\n // In case the next item index is negative, means outside the bounds of the items,\n // reset it depending on the current direction\n const indexLimit = direction === UP ? options.length - 1 : 0;\n\n setFocusedItemIndex(nextFocusedItem < 0 ? indexLimit : nextFocusedItem);\n setKeyboardUsed(true);\n };\n\n const getOptionNodes = () => {\n const node = dropdownMenuRef.current;\n return node?.getElementsByTagName('a') || [];\n };\n\n const updateItemDOMValues = () => {\n if (dropdownMenuRef.current) {\n const optionNodes = getOptionNodes();\n return [...optionNodes].map(item => {\n return {\n id: item.getAttribute(DATA_ATTRIBUTE_ID),\n text: item.textContent,\n } as OptionDOMValue;\n });\n }\n };\n\n const getFocusedOptionNode = () => {\n const optionNodes = getOptionNodes();\n return [...optionNodes].find(item => item.className.includes(HIGHLIGHT_CLASS));\n };\n\n const selectOptionOnEnter = (event: KeyboardEvent) => {\n event.preventDefault();\n\n // When no filter result was found, avoid selecting anything\n if (isEmpty(options)) {\n return;\n }\n\n const match = getFocusedOptionNode();\n\n if (match) {\n const selectedItem = options.find(option => option.id === match.getAttribute(DATA_ATTRIBUTE_ID));\n onSelect(selectedItem);\n }\n };\n\n const handleOptionChange = (event: React.MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n\n const optionId = event.currentTarget.getElementsByTagName('input')[0].value;\n const selectedItem = options.find(option => option.id === optionId);\n\n onSelect(selectedItem);\n };\n\n const dropdownMenuClasses = classNames('dropdown-menu', dropDirection.pullRight && 'pull-right', dropdownClassName);\n\n // Don't show the dropdown, when no match are found when filtering unless there is a not found message\n if (isEmpty(options)) {\n return <NoItemMessage noItemMessage={noItemMessage} className={dropdownMenuClasses} />;\n }\n\n return (\n <ul className={dropdownMenuClasses} ref={dropdownMenuRef} role='menu'>\n {isLoading && (\n <div className='display-flex justify-content-center padding-10'>\n <Spinner />\n </div>\n )}\n {!isLoading &&\n options.map((option, index) => {\n if (option.header) {\n return <DropdownHeader key={option.id} icon={option.icon} label={option.label} />;\n }\n\n // Show focused style only when keyboard is in use\n const anchorClassNames = classNames(\n keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '',\n option.disabled && 'pointer-events-none',\n 'display-flex align-items-center gap-3'\n );\n\n const wrapperClassNames = classNames(\n option.disabled && 'disabled',\n useActiveClass && option.selected && 'active'\n );\n\n return (\n <li key={option.id} className={wrapperClassNames} role='listitem'>\n <a\n role='menuitem'\n className={anchorClassNames}\n data-item-id={option.id}\n data-item-index={index}\n // Note, we need to assign the click callback only when it's not disabled\n // otherwise the functions is still triggered\n // biome-ignore lint/a11y/useValidAnchor: due to old structure + backwards compatibility\n onClick={option.disabled ? undefined : handleOptionChange}\n >\n <span className='selected-option-dropdown-item'>\n {option.icon && <>{option.icon}</>}\n {option.label}\n </span>\n <input type='hidden' value={option.id} />\n </a>\n </li>\n );\n })}\n </ul>\n );\n};\n\nexport const filterOptions = <T extends SelectOption>(\n itemDOMValues: OptionDOMValue[],\n filterValue: string,\n options: T[]\n) => {\n const filteredDOMValues = itemDOMValues.filter(item => item.text.toLowerCase().includes(filterValue.toLowerCase()));\n\n // Filter the options according to the filtered DOM values and map the IDs since the filter cannot be done\n // on the options itself as they might contain arbitrary components\n return options.filter(option => {\n return filteredDOMValues.find(domValue => domValue.id === option.id);\n });\n};\n\nexport default BaseSelectDropdown;\n"],"names":["DATA_ATTRIBUTE_ID","DEFAULT_FOCUSED_ITEM_INDEX","HIGHLIGHT_CLASS","BaseSelectDropdown","props","isOpen","isLoading","updateDOMValues","noop","onOpen","onSelect","onClose","options","autoDropDirection","dropup","pullRight","useActiveClass","externalFocusedItemIndex","externalKeyboardUsed","noItemMessage","dropdownClassName","focusedItemIndex","setFocusedItemIndex","useState","keyboardUsed","setKeyboardUsed","dropdownMenuRef","useRef","useEffectOnce","currentItemDOMValues","updateItemDOMValues","dropDirection","useDropDirection","useLayoutEffect","parent","useEffect","previousIsOpen","setPreviousIsOpen","useKey","event","selectOptionOnEnter","focusOption","UP","scrollItemIntoView","getFocusedOptionNode","DOWN","direction","nextFocusedItem","indexLimit","getOptionNodes","item","isEmpty","match","selectedItem","option","handleOptionChange","optionId","dropdownMenuClasses","classNames","jsx","NoItemMessage","Spinner","index","DropdownHeader","anchorClassNames","wrapperClassNames","jsxs","Fragment","filterOptions","itemDOMValues","filterValue","filteredDOMValues","domValue"],"mappings":";;;;;;;;;;;;AAcA,MAAMA,IAAoB,gBACpBC,KAA6B,GAC7BC,IAAkB,SA8DlBC,KAAqB,CAAyBC,MAAsC;AACtF,QAAM;AAAA,IACF,QAAAC,IAAS;AAAA,IACT,WAAAC,IAAY;AAAA,IACZ,iBAAAC,IAAkBC;AAAA,IAClB,QAAAC,IAASD;AAAA,IACT,UAAAE,IAAWF;AAAA,IACX,SAAAG,IAAUH;AAAA,IACV,SAAAI,IAAU,CAAA;AAAA,IACV,mBAAAC,IAAoB;AAAA,IACpB,QAAAC,IAAS;AAAA,IACT,WAAAC,IAAY;AAAA,IACZ,gBA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BAAcV,EAAO;AAAA,UACrB,mBAAiBQ;AAAA,UAIjB,SAASR,EAAO,WAAW,SAAYC;AAAA,UAEvC,UAAA;AAAA,YAAA,gBAAAW,EAAC,QAAA,EAAK,WAAU,iCACX,UAAA;AAAA,cAAAZ,EAAO,QAAQ,gBAAAK,EAAAQ,GAAA,EAAG,UAAAb,EAAO,MAAK;AAAA,cAC9BA,EAAO;AAAA,YAAA,GACZ;AAAA,8BACC,SAAA,EAAM,MAAK,UAAS,OAAOA,EAAO,GAAA,CAAI;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EAC3C,GAhBKA,EAAO,EAiBhB;AAAA,IAER,CAAC;AAAA,EAAA,GACT;AAER,GAEac,KAAgB,CACzBC,GACAC,GACA1D,MACC;AACD,QAAM2D,IAAoBF,EAAc,OAAO,CAAAnB,MAAQA,EAAK,KAAK,YAAA,EAAc,SAASoB,EAAY,YAAA,CAAa,CAAC;AAIlH,SAAO1D,EAAQ,OAAO,CAAA0C,MACXiB,EAAkB,KAAK,CAAAC,MAAYA,EAAS,OAAOlB,EAAO,EAAE,CACtE;AACL;"}
1
+ {"version":3,"file":"BaseSelectDropdown.js","sources":["../../../src/components/selects/BaseSelectDropdown.tsx"],"sourcesContent":["import type React from 'react';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport classNames from 'classnames';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { noop } from 'es-toolkit/function';\n\nimport { useDropDirection } from '../../utils/useDropDirection';\nimport { DOWN, scrollItemIntoView, UP } from '../../utils/scrollItemIntoView';\nimport useEffectOnce from '../../hooks/useEffectOnce';\nimport useKey from '../../useKey';\nimport DropdownHeader from './DropdownHeader';\nimport NoItemMessage from './NoItemMessage';\nimport Spinner from '../spinner/Spinner';\n\nconst DATA_ATTRIBUTE_ID = 'data-item-id';\nconst DEFAULT_FOCUSED_ITEM_INDEX = 0;\nconst HIGHLIGHT_CLASS = 'focus';\nconst DEFAULT_SCROLL_DIRECTION = DOWN;\n\nexport type OptionDOMValue = {\n id: string;\n text: string;\n};\n\nexport type SelectOption = {\n /**\n * Used to identify an option.\n */\n id: string;\n\n /**\n * The option item text.\n */\n label: string | React.ReactNode;\n\n /**\n * Icon to be displayed in front of the label.\n */\n icon?: React.ReactNode;\n\n /**\n * Defines whether the menu item is selected.\n *\n * @default false\n */\n selected?: boolean;\n\n /**\n * Setting \"disabled\" to true will disable the respective item.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Will treat the given value as a menu header\n */\n header?: boolean;\n};\n\nexport type BaseSelectDropdownProps<T extends SelectOption> = {\n options?: T[];\n isOpen?: boolean;\n isLoading?: boolean;\n updateDOMValues?: (values: OptionDOMValue[] | undefined) => void;\n onOpen?: (hasDropup: boolean) => void;\n onSelect?: (selectedItem: T | undefined) => void;\n onClose?: () => void;\n placeholder?: string | React.ReactNode;\n dropup?: boolean;\n pullRight?: boolean;\n autoDropDirection?: boolean;\n noItemMessage?: string | React.ReactNode;\n focusedItemIndex?: number;\n dropdownClassName?: string;\n keyboardUsed?: boolean;\n useActiveClass?: boolean;\n};\n\nconst BaseSelectDropdown = <T extends SelectOption>(props: BaseSelectDropdownProps<T>) => {\n const {\n isOpen = false,\n isLoading = false,\n updateDOMValues = noop,\n onOpen = noop,\n onSelect = noop,\n onClose = noop,\n options = [],\n autoDropDirection = true,\n dropup = false,\n pullRight = false,\n useActiveClass = false,\n focusedItemIndex: externalFocusedItemIndex,\n keyboardUsed: externalKeyboardUsed,\n noItemMessage,\n dropdownClassName,\n } = props;\n\n const [focusedItemIndex, setFocusedItemIndex] = useState(externalFocusedItemIndex || DEFAULT_FOCUSED_ITEM_INDEX);\n const [keyboardUsed, setKeyboardUsed] = useState(externalKeyboardUsed);\n const lastScrollDirectionRef = useRef<typeof UP | typeof DOWN>(DEFAULT_SCROLL_DIRECTION);\n\n const dropdownMenuRef = useRef<HTMLUListElement>(null);\n\n // Reset scroll position whenever the menu opens to avoid retaining old scroll offsets\n useEffect(() => {\n if (isOpen && dropdownMenuRef.current) {\n dropdownMenuRef.current.scrollTop = 0;\n }\n }, [isOpen]);\n\n // Keep internal focus state in sync when the dropdown opens/closes or when parent-controlled values change\n useEffect(() => {\n if (typeof externalFocusedItemIndex === 'number') {\n setFocusedItemIndex(externalFocusedItemIndex);\n }\n\n if (typeof externalKeyboardUsed === 'boolean') {\n setKeyboardUsed(externalKeyboardUsed);\n }\n\n if (!isOpen) {\n lastScrollDirectionRef.current = DEFAULT_SCROLL_DIRECTION;\n }\n }, [externalFocusedItemIndex, externalKeyboardUsed, isOpen]);\n\n useEffectOnce(() => {\n // all available items need to be rendered in order to know their DOM value\n // which will be used for filtering in the parent component\n const currentItemDOMValues = updateItemDOMValues();\n updateDOMValues(currentItemDOMValues);\n });\n\n // Overwrite position of dropdown menu in case auto drop is enabled\n const dropDirection = useDropDirection({ pullRight, dropup, autoDropDirection, dropdownMenuRef }, [isOpen]);\n\n // Add or remove the \"dropup\" class from the parent Select/Multiselect component to position\n // the dropdown element accordingly via CSS\n useLayoutEffect(() => {\n if (dropdownMenuRef.current) {\n const parent = dropdownMenuRef.current.parentElement;\n if (dropDirection.dropup) {\n parent?.classList.add('dropup');\n } else {\n parent?.classList.remove('dropup');\n }\n }\n }, [dropDirection, dropdownMenuRef]);\n\n useEffect(() => {\n if (dropdownMenuRef.current) {\n updateDOMValues(updateItemDOMValues());\n }\n }, [dropdownMenuRef.current]);\n\n // Scroll the focused item into view whenever focus changes\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n scrollItemIntoView(\n lastScrollDirectionRef.current || DEFAULT_SCROLL_DIRECTION,\n dropdownMenuRef.current,\n getFocusedOptionNode()\n );\n }, [focusedItemIndex, isOpen]);\n\n // update internal state for isOpen\n const [previousIsOpen, setPreviousIsOpen] = useState(isOpen);\n if (isOpen && !previousIsOpen) {\n onOpen(dropDirection.dropup);\n setPreviousIsOpen(isOpen);\n } else if (!isOpen && previousIsOpen) {\n onClose();\n setPreviousIsOpen(isOpen);\n }\n\n useKey(event => {\n if (isOpen) {\n switch (event.key) {\n case 'Escape': {\n // close dropdown on esc\n onClose();\n break;\n }\n case 'Tab': {\n // close dropdown on tab\n onClose();\n break;\n }\n case 'Enter': {\n // select item on enter\n selectOptionOnEnter(event);\n break;\n }\n case 'ArrowUp': {\n // prevent scrolling the page when dropdown menu is open\n event.preventDefault();\n\n // select item above on arrow up key\n focusOption(UP);\n scrollItemIntoView(UP, dropdownMenuRef.current, getFocusedOptionNode());\n break;\n }\n case 'ArrowDown': {\n // prevent scrolling the page when dropdown menu is open\n event.preventDefault();\n\n // select item below on arrow down key\n focusOption(DOWN);\n scrollItemIntoView(DOWN, dropdownMenuRef.current, getFocusedOptionNode());\n break;\n }\n default:\n break;\n }\n }\n });\n\n const focusOption = (direction: typeof UP | typeof DOWN) => {\n let nextFocusedItem = 0;\n\n switch (direction) {\n case UP: {\n nextFocusedItem = focusedItemIndex <= 0 ? focusedItemIndex : focusedItemIndex - 1;\n break;\n }\n case DOWN: {\n nextFocusedItem = focusedItemIndex === options.length - 1 ? focusedItemIndex : focusedItemIndex + 1;\n break;\n }\n default:\n break;\n }\n\n lastScrollDirectionRef.current = direction;\n\n // In case the next item index is negative, means outside the bounds of the items,\n // reset it depending on the current direction\n const indexLimit = direction === UP ? options.length - 1 : 0;\n\n setFocusedItemIndex(nextFocusedItem < 0 ? indexLimit : nextFocusedItem);\n setKeyboardUsed(true);\n };\n\n const getOptionNodes = () => {\n const node = dropdownMenuRef.current;\n return node?.getElementsByTagName('a') || [];\n };\n\n const updateItemDOMValues = () => {\n if (dropdownMenuRef.current) {\n const optionNodes = getOptionNodes();\n return [...optionNodes].map(item => {\n return {\n id: item.getAttribute(DATA_ATTRIBUTE_ID),\n text: item.textContent,\n } as OptionDOMValue;\n });\n }\n };\n\n const getFocusedOptionNode = () => {\n const optionNodes = getOptionNodes();\n return [...optionNodes].find(item => item.className.includes(HIGHLIGHT_CLASS));\n };\n\n const selectOptionOnEnter = (event: KeyboardEvent) => {\n event.preventDefault();\n\n // When no filter result was found, avoid selecting anything\n if (isEmpty(options)) {\n return;\n }\n\n const match = getFocusedOptionNode();\n\n if (match) {\n const selectedItem = options.find(option => option.id === match.getAttribute(DATA_ATTRIBUTE_ID));\n onSelect(selectedItem);\n }\n };\n\n const handleOptionChange = (event: React.MouseEvent<HTMLAnchorElement>) => {\n event.preventDefault();\n\n const optionId = event.currentTarget.getElementsByTagName('input')[0].value;\n const selectedItem = options.find(option => option.id === optionId);\n\n onSelect(selectedItem);\n };\n\n const dropdownMenuClasses = classNames('dropdown-menu', dropDirection.pullRight && 'pull-right', dropdownClassName);\n\n // Don't show the dropdown, when no match are found when filtering unless there is a not found message\n if (isEmpty(options)) {\n return <NoItemMessage noItemMessage={noItemMessage} className={dropdownMenuClasses} />;\n }\n\n return (\n <ul className={dropdownMenuClasses} ref={dropdownMenuRef} role='menu'>\n {isLoading && (\n <div className='display-flex justify-content-center padding-10'>\n <Spinner />\n </div>\n )}\n {!isLoading &&\n options.map((option, index) => {\n if (option.header) {\n return <DropdownHeader key={option.id} icon={option.icon} label={option.label} />;\n }\n\n // Show focused style only when keyboard is in use\n const anchorClassNames = classNames(\n keyboardUsed && focusedItemIndex === index ? HIGHLIGHT_CLASS : '',\n option.disabled && 'pointer-events-none',\n 'display-flex align-items-center gap-3'\n );\n\n const wrapperClassNames = classNames(\n option.disabled && 'disabled',\n useActiveClass && option.selected && 'active'\n );\n\n return (\n <li key={option.id} className={wrapperClassNames} role='listitem'>\n <a\n role='menuitem'\n className={anchorClassNames}\n data-item-id={option.id}\n data-item-index={index}\n // Note, we need to assign the click callback only when it's not disabled\n // otherwise the functions is still triggered\n onClick={option.disabled ? undefined : handleOptionChange}\n >\n <span className='selected-option-dropdown-item'>\n {option.icon && <>{option.icon}</>}\n {option.label}\n </span>\n <input type='hidden' value={option.id} />\n </a>\n </li>\n );\n })}\n </ul>\n );\n};\n\nexport const filterOptions = <T extends SelectOption>(\n itemDOMValues: OptionDOMValue[],\n filterValue: string,\n options: T[]\n) => {\n const filteredDOMValues = itemDOMValues.filter(item => item.text.toLowerCase().includes(filterValue.toLowerCase()));\n\n // Filter the options according to the filtered DOM values and map the IDs since the filter cannot be done\n // on the options itself as they might contain arbitrary components\n return options.filter(option => {\n return filteredDOMValues.find(domValue => domValue.id === option.id);\n });\n};\n\nexport default BaseSelectDropdown;\n"],"names":["DATA_ATTRIBUTE_ID","DEFAULT_FOCUSED_ITEM_INDEX","HIGHLIGHT_CLASS","DEFAULT_SCROLL_DIRECTION","DOWN","BaseSelectDropdown","props","isOpen","isLoading","updateDOMValues","noop","onOpen","onSelect","onClose","options","autoDropDirection","dropup","pullRight","useActiveClass","externalFocusedItemIndex","externalKeyboardUsed","noItemMessage","dropdownClassName","focusedItemIndex","setFocusedItemIndex","useState","keyboardUsed","setKeyboardUsed","lastScrollDirectionRef","useRef","dropdownMenuRef","useEffect","useEffectOnce","currentItemDOMValues","updateItemDOMValues","dropDirection","useDropDirection","useLayoutEffect","parent","scrollItemIntoView","getFocusedOptionNode","previousIsOpen","setPreviousIsOpen","useKey","event","selectOptionOnEnter","focusOption","UP","direction","nextFocusedItem","indexLimit","getOptionNodes","item","isEmpty","match","selectedItem","option","handleOptionChange","optionId","dropdownMenuClasses","classNames","jsx","NoItemMessage","Spinner","index","DropdownHeader","anchorClassNames","wrapperClassNames","jsxs","Fragment","filterOptions","itemDOMValues","filterValue","filteredDOMValues","domValue"],"mappings":";;;;;;;;;;;;AAcA,MAAMA,IAAoB,gBACpBC,KAA6B,GAC7BC,IAAkB,SAClBC,IAA2BC,GA8D3BC,KAAqB,CAAyBC,MAAsC;AACtF,QAAM;AAAA,IACF,QAAAC,IAAS;AAAA,IACT,WAAAC,IAAY;AAAA,IACZ,iBAAAC,IAAkBC;AAAA,IAClB,QAAAC,IAASD;AAAA,IACT,UAAAE,IAAWF;AAAA,IACX,SAAAG,IAAUH;AAAA,IACV,SAAAI,IAAU,CAAA;AAAA,IACV,mBAAAC,IAAoB;AAAA,IACpB,QAA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AK,CAAAC,MAAYA,EAAS,OAAOlB,EAAO,EAAE,CACtE;AACL;"}
@@ -2,6 +2,10 @@ import { default as React } from 'react';
2
2
  import { SelectOption } from './BaseSelectDropdown';
3
3
  import { WithFeedbackAndAddonProps } from './WithFeedbackAndAddon';
4
4
  export type { SelectOption } from './BaseSelectDropdown';
5
+ /**
6
+ * Note: Even with a pre-selected item, when it first opens the dropdown it renders the full options list,
7
+ * not just the selected one. The filter is only usable while the dropdown is open.
8
+ */
5
9
  export type SelectProps<T extends SelectOption> = Omit<WithFeedbackAndAddonProps, 'bsSize'> & {
6
10
  /**
7
11
  * Passed through as HTML attribute to the toggle button.
@@ -105,6 +109,7 @@ export type SelectProps<T extends SelectOption> = Omit<WithFeedbackAndAddonProps
105
109
  useClear?: boolean;
106
110
  /**
107
111
  * Shows a loading spinner instead of the menu items if set to true.
112
+ *
108
113
  * @default false
109
114
  */
110
115
  isLoading?: boolean;
@@ -1,71 +1,71 @@
1
- import { jsxs as y, jsx as a } from "react/jsx-runtime";
2
- import { useState as o, useRef as U } from "react";
3
- import V from "classnames";
4
- import { isEqual as k } from "es-toolkit/predicate";
5
- import { noop as Se, isEmpty as xe } from "es-toolkit/compat";
6
- import be, { filterOptions as we } from "./BaseSelectDropdown.js";
7
- import ve from "../../hooks/useClickOutside.js";
1
+ import { jsxs as U, jsx as i } from "react/jsx-runtime";
2
+ import { useState as o, useRef as V } from "react";
3
+ import k from "classnames";
4
+ import { isEqual as K } from "es-toolkit/predicate";
5
+ import { noop as Oe, isEmpty as be } from "es-toolkit/compat";
6
+ import ve, { filterOptions as xe } from "./BaseSelectDropdown.js";
7
+ import we from "../../hooks/useClickOutside.js";
8
8
  import De from "../../hooks/useEffectOnce.js";
9
9
  import Me from "../../hooks/useMergeRefs.js";
10
10
  import Ee from "./ClearButton.js";
11
11
  import Ne from "./SelectFilter.js";
12
12
  import Ae from "./SelectedOption.js";
13
13
  import Te from "./WithFeedbackAndAddon.js";
14
- const p = -1, ze = (R) => {
14
+ const u = -1, ze = (R) => {
15
15
  const {
16
16
  name: F,
17
17
  id: B = F,
18
- label: P,
19
- options: s = [],
18
+ label: _,
19
+ options: t = [],
20
20
  value: n,
21
- onChange: O = Se,
22
- placeholder: _,
23
- isLoading: j = !1,
24
- dropup: K = !1,
25
- pullRight: L = !1,
26
- autoDropDirection: W = !0,
21
+ onChange: O = Oe,
22
+ placeholder: j,
23
+ isLoading: L = !1,
24
+ dropup: W = !1,
25
+ pullRight: q = !1,
26
+ autoDropDirection: z = !0,
27
27
  bsSize: g = "md",
28
- disabled: S = !1,
29
- tabIndex: q = 0,
30
- hasError: z = !1,
31
- useFilter: X = !1,
32
- useClear: G = !1,
33
- noItemMessage: H,
34
- selectedOptionText: x,
35
- showSelectedItemIcon: J = !1,
36
- showUnselectedItemIcons: Q = !1,
37
- dropdownClassName: Y,
38
- btnClassName: b,
28
+ disabled: b = !1,
29
+ tabIndex: X = 0,
30
+ hasError: G = !1,
31
+ useFilter: H = !1,
32
+ useClear: J = !1,
33
+ noItemMessage: Q,
34
+ selectedOptionText: v,
35
+ showSelectedItemIcon: Y = !1,
36
+ showUnselectedItemIcons: Z = !1,
37
+ dropdownClassName: $,
38
+ btnClassName: x,
39
39
  className: w,
40
- inputAddon: v,
41
- errorMessage: D,
42
- warningMessage: M,
43
- messageWhiteSpace: Z = "normal",
44
- ...$
45
- } = R, [r, E] = o(!1), [f, u] = o(null), [N, i] = o(!1), [ee, c] = o(""), [te, d] = o(s), [se, oe] = o([]), [ne, I] = o(p), [A, m] = o(!1), re = U(), T = U(null), le = ve(() => C()), ae = Me(re, le), h = (e, t) => {
46
- t && !xe(t) ? u(e.find((l) => l.id === t[0]) || null) : e && u(e.find((l) => l.selected) || null);
40
+ inputAddon: D,
41
+ errorMessage: M,
42
+ warningMessage: E,
43
+ messageWhiteSpace: ee = "normal",
44
+ ...te
45
+ } = R, [r, N] = o(!1), [h, p] = o(null), [I, c] = o(!1), [A, d] = o(""), [se, l] = o(t), [T, oe] = o([]), [ne, m] = o(u), [y, f] = o(!1), re = V(), P = V(null), le = we(() => S()), ae = Me(re, le), C = (e, s) => {
46
+ s && !be(s) ? p(e.find((a) => a.id === s[0]) || null) : e && p(e.find((a) => a.selected) || null);
47
47
  };
48
48
  De(() => {
49
- h(s, n);
49
+ C(t, n);
50
50
  });
51
- const [ie, ce] = o(s);
52
- k(s, ie) || (h(s, n), d(s), ce(s));
51
+ const [ie, ce] = o(t);
52
+ K(t, ie) || (C(t, n), l(t), ce(t));
53
53
  const [de, fe] = o(n);
54
- k(n, de) || (h(s, n), fe(n));
54
+ K(n, de) || (C(t, n), fe(n));
55
55
  const ue = (e = []) => {
56
- oe((t) => e.length ? e : t);
57
- }, me = () => {
58
- u(null), i(!1), c(""), O(void 0);
56
+ !e.length || (I || A) && T.length > 0 || oe(e);
59
57
  }, pe = () => {
60
- const e = V(
58
+ p(null), c(!1), d(""), l(t), f(!1), m(u), O(void 0);
59
+ }, me = () => {
60
+ const e = k(
61
61
  "dropdown-toggle",
62
62
  "form-control",
63
63
  "text-left",
64
- b && b,
64
+ x && x,
65
65
  g === "sm" && "input-sm",
66
66
  g === "lg" && "input-lg",
67
- S && "disabled"
68
- ), t = /* @__PURE__ */ y(
67
+ b && "disabled"
68
+ ), s = /* @__PURE__ */ U(
69
69
  "button",
70
70
  {
71
71
  type: "button",
@@ -73,88 +73,88 @@ const p = -1, ze = (R) => {
73
73
  name: F,
74
74
  className: e,
75
75
  "data-toggle": "dropdown",
76
- tabIndex: q,
76
+ tabIndex: X,
77
77
  "aria-haspopup": "true",
78
78
  "aria-expanded": r,
79
79
  onClick: Ce,
80
- ref: T,
80
+ ref: P,
81
81
  children: [
82
- X && r && /* @__PURE__ */ a(
82
+ H && r && /* @__PURE__ */ i(
83
83
  Ne,
84
84
  {
85
- isFilterActive: N,
86
- filterValue: ee,
87
- onChange: Ie
85
+ isFilterActive: I,
86
+ filterValue: A,
87
+ onChange: he
88
88
  }
89
89
  ),
90
- x || /* @__PURE__ */ a(
90
+ v || /* @__PURE__ */ i(
91
91
  Ae,
92
92
  {
93
- label: P,
94
- placeholder: _,
95
- selectedItem: f,
96
- options: s,
97
- showSelectedItemIcon: J,
98
- showUnselectedItemIcons: Q
93
+ label: _,
94
+ placeholder: j,
95
+ selectedItem: h,
96
+ options: t,
97
+ showSelectedItemIcon: Y,
98
+ showUnselectedItemIcons: Z
99
99
  }
100
100
  ),
101
- /* @__PURE__ */ a(Ee, { showClear: G, selectedItem: f, onClear: me }),
102
- /* @__PURE__ */ a("span", { className: "caret" })
101
+ /* @__PURE__ */ i(Ee, { showClear: J, selectedItem: h, onClear: pe }),
102
+ /* @__PURE__ */ i("span", { className: "caret" })
103
103
  ]
104
104
  }
105
105
  );
106
- return !v && !D && !M ? t : /* @__PURE__ */ a(
106
+ return !D && !M && !E ? s : /* @__PURE__ */ i(
107
107
  Te,
108
108
  {
109
109
  bsSize: g,
110
- inputAddon: v,
111
- errorMessage: D,
112
- warningMessage: M,
113
- messageWhiteSpace: Z,
114
- children: t
110
+ inputAddon: D,
111
+ errorMessage: M,
112
+ warningMessage: E,
113
+ messageWhiteSpace: ee,
114
+ children: s
115
115
  }
116
116
  );
117
117
  }, ge = () => {
118
118
  let e = ne;
119
- return f ? e = s.findIndex((t) => t.id === f.id) : A && (e = 0), /* @__PURE__ */ a(
120
- be,
119
+ return y && !h && (e = 0), /* @__PURE__ */ i(
120
+ ve,
121
121
  {
122
122
  isOpen: r,
123
- isLoading: j,
124
- options: te,
123
+ isLoading: L,
124
+ options: se,
125
125
  focusedItemIndex: e,
126
- keyboardUsed: A,
126
+ keyboardUsed: y,
127
127
  updateDOMValues: ue,
128
- onSelect: he,
129
- onClose: C,
130
- noItemMessage: H,
131
- pullRight: L,
132
- dropup: K,
133
- autoDropDirection: W,
134
- dropdownClassName: Y
128
+ onSelect: Ie,
129
+ onClose: S,
130
+ noItemMessage: Q,
131
+ pullRight: q,
132
+ dropup: W,
133
+ autoDropDirection: z,
134
+ dropdownClassName: $
135
135
  }
136
136
  );
137
- }, Ie = (e) => {
137
+ }, he = (e) => {
138
138
  e.preventDefault();
139
- const t = e.currentTarget.value;
140
- if (t === "") {
141
- i(!1), c(""), d(s), m(!1), I(p);
139
+ const s = e.currentTarget.value;
140
+ if (s === "") {
141
+ c(!1), d(""), l(t), f(!1), m(u);
142
142
  return;
143
143
  }
144
- const l = we(se, t, s), Oe = l.length > 0 ? 0 : p;
145
- i(!0), c(t), d(l), m(!0), I(Oe);
146
- }, he = (e) => {
147
- u(e || null), i(!1), c(""), d(s), O(e), C();
144
+ const a = xe(T, s, t), Fe = a.length > 0 ? 0 : u;
145
+ c(!0), d(s), l(a), f(!0), m(Fe);
146
+ }, Ie = (e) => {
147
+ p(e || null), c(!1), d(""), l(t), O(e), S();
148
148
  }, Ce = (e) => {
149
- if (S || N)
149
+ if (b || I)
150
150
  return;
151
- const t = e.detail === 0;
152
- E(!r), m(t);
153
- }, C = () => {
154
- r && (E(!1), i(!1), c(""), d(s), m(!1), I(p), T.current?.focus());
155
- }, Fe = V("select", "dropdown", r && "open", z && "has-error", w && w);
156
- return /* @__PURE__ */ y("div", { ...$, className: Fe, ref: ae, children: [
157
- pe(),
151
+ const s = e.detail === 0;
152
+ N(!r), f(s);
153
+ }, S = () => {
154
+ r && (N(!1), c(!1), d(""), l(t), f(!1), m(u), P.current?.focus());
155
+ }, Se = k("select", "dropdown", r && "open", G && "has-error", w && w);
156
+ return /* @__PURE__ */ U("div", { ...te, className: Se, ref: ae, children: [
157
+ me(),
158
158
  ge()
159
159
  ] });
160
160
  };