@rio-cloud/rio-uikit 2.4.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,66 +1,62 @@
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 { isEmpty as V } from "es-toolkit/compat";
4
- import { noop as N } from "es-toolkit/function";
1
+ import { jsx as c, jsxs as y, Fragment as Q } from "react/jsx-runtime";
2
+ import { useState as E, useRef as R, useEffect as D, useLayoutEffect as Y } from "react";
3
+ import { isEmpty as _ } from "es-toolkit/compat";
4
+ import { noop as b } from "es-toolkit/function";
5
5
  import C from "../../utils/classNames.js";
6
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 se from "./NoItemMessage.js";
12
- import re from "../spinner/Spinner.js";
13
- const B = "data-item-id", ne = 0, H = "focus", L = O, be = (h) => {
7
+ import { DOWN as g, scrollItemIntoView as T, UP as N } from "../../utils/scrollItemIntoView.js";
8
+ import $ from "../../hooks/useKey.js";
9
+ import ee from "./DropdownHeader.js";
10
+ import te from "./NoItemMessage.js";
11
+ import se from "../spinner/Spinner.js";
12
+ const B = "data-item-id", re = 0, H = "focus", L = g, Ie = (h) => {
14
13
  const {
15
14
  isOpen: s = !1,
16
15
  isLoading: l = !1,
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), r = _(null);
31
- b(() => {
16
+ updateDOMValues: O = b,
17
+ onOpen: i = b,
18
+ onSelect: u = b,
19
+ onClose: w = b,
20
+ options: n = [],
21
+ autoDropDirection: V = !0,
22
+ dropup: j = !1,
23
+ pullRight: K = !1,
24
+ useActiveClass: G = !1,
25
+ focusedItemIndex: p,
26
+ keyboardUsed: m,
27
+ noItemMessage: P,
28
+ dropdownClassName: W
29
+ } = h, [o, k] = E(p || re), [X, A] = E(m), x = R(L), r = R(null);
30
+ D(() => {
32
31
  s && r.current && (r.current.scrollTop = 0);
33
- }, [s]), b(() => {
34
- typeof m == "number" && k(m), typeof f == "boolean" && A(f), s || (w.current = L);
35
- }, [m, f, s]), $(() => {
36
- const e = F();
37
- u(e);
38
- });
39
- const I = Z({ pullRight: G, dropup: K, autoDropDirection: j, dropdownMenuRef: r }, [s]);
32
+ }, [s]), D(() => {
33
+ typeof p == "number" && k(p), typeof m == "boolean" && A(m), s || (x.current = L);
34
+ }, [p, m, s]);
35
+ const f = Z({ pullRight: K, dropup: j, autoDropDirection: V, dropdownMenuRef: r }, [s]);
40
36
  Y(() => {
41
37
  if (r.current) {
42
38
  const e = r.current.parentElement;
43
- I.dropup ? e?.classList.add("dropup") : e?.classList.remove("dropup");
39
+ f.dropup ? e?.classList.add("dropup") : e?.classList.remove("dropup");
44
40
  }
45
- }, [I, r]), b(() => {
46
- r.current && u(F());
47
- }, [r.current]), b(() => {
41
+ }, [f, r]), D(() => {
42
+ O(q());
43
+ }, [n]), D(() => {
48
44
  s && T(
49
- w.current || L,
45
+ x.current || L,
50
46
  r.current,
51
- D()
47
+ I()
52
48
  );
53
- }, [n, s]);
54
- const [v, U] = y(s);
55
- s && !v ? (i(I.dropup), U(s)) : !s && v && (E(), U(s)), ee((e) => {
49
+ }, [o, s]);
50
+ const [v, U] = E(s);
51
+ s && !v ? (i(f.dropup), U(s)) : !s && v && (w(), U(s)), $((e) => {
56
52
  if (s)
57
53
  switch (e.key) {
58
54
  case "Escape": {
59
- E();
55
+ w();
60
56
  break;
61
57
  }
62
58
  case "Tab": {
63
- E();
59
+ w();
64
60
  break;
65
61
  }
66
62
  case "Enter": {
@@ -68,65 +64,65 @@ const B = "data-item-id", ne = 0, H = "focus", L = O, be = (h) => {
68
64
  break;
69
65
  }
70
66
  case "ArrowUp": {
71
- e.preventDefault(), M(g), T(g, r.current, D());
67
+ e.preventDefault(), S(N), T(N, r.current, I());
72
68
  break;
73
69
  }
74
70
  case "ArrowDown": {
75
- e.preventDefault(), M(O), T(O, r.current, D());
71
+ e.preventDefault(), S(g), T(g, r.current, I());
76
72
  break;
77
73
  }
78
74
  }
79
75
  });
80
- const M = (e) => {
76
+ const S = (e) => {
81
77
  let t = 0;
82
78
  switch (e) {
83
- case g: {
84
- t = n <= 0 ? n : n - 1;
79
+ case N: {
80
+ t = o <= 0 ? o : o - 1;
85
81
  break;
86
82
  }
87
- case O: {
88
- t = n === o.length - 1 ? n : n + 1;
83
+ case g: {
84
+ t = o === n.length - 1 ? o : o + 1;
89
85
  break;
90
86
  }
91
87
  }
92
- w.current = e;
93
- const a = e === g ? o.length - 1 : 0;
88
+ x.current = e;
89
+ const a = e === N ? n.length - 1 : 0;
94
90
  k(t < 0 ? a : t), A(!0);
95
- }, S = () => r.current?.getElementsByTagName("a") || [], F = () => {
91
+ }, F = () => r.current?.getElementsByTagName("a") || [], q = () => {
96
92
  if (r.current)
97
- return [...S()].map(
93
+ return [...F()].map(
98
94
  (t) => ({
99
95
  id: t.getAttribute(B),
100
96
  text: t.textContent
101
97
  })
102
98
  );
103
- }, D = () => [...S()].find((t) => t.className.includes(H)), z = (e) => {
104
- if (e.preventDefault(), V(o))
99
+ }, I = () => [...F()].find((t) => t.className.includes(H)), z = (e) => {
100
+ if (e.preventDefault(), _(n))
105
101
  return;
106
- const t = D();
102
+ const t = I();
107
103
  if (t) {
108
- const a = o.find((d) => d.id === t.getAttribute(B));
109
- p(a);
104
+ const a = n.find((d) => d.id === t.getAttribute(B));
105
+ u(a);
110
106
  }
111
107
  }, J = (e) => {
112
108
  e.preventDefault();
113
- const t = e.currentTarget.getElementsByTagName("input")[0].value, a = o.find((d) => d.id === t);
114
- p(a);
115
- }, R = C("dropdown-menu", I.pullRight && "pull-right", X);
116
- return V(o) ? /* @__PURE__ */ c(se, { noItemMessage: W, className: R }) : /* @__PURE__ */ x("ul", { className: R, ref: r, role: "menu", children: [
117
- l && /* @__PURE__ */ c("div", { className: "display-flex justify-content-center padding-10", children: /* @__PURE__ */ c(re, {}) }),
118
- !l && o.map((e, t) => {
109
+ const t = e.currentTarget.getElementsByTagName("input")[0].value, a = n.find((d) => d.id === t);
110
+ u(a);
111
+ }, M = C("dropdown-menu", f.pullRight && "pull-right", W);
112
+ return _(n) ? /* @__PURE__ */ c(te, { noItemMessage: P, className: M }) : /* @__PURE__ */ y("ul", { className: M, ref: r, role: "menu", children: [
113
+ l && /* @__PURE__ */ c("div", { className: "display-flex justify-content-center padding-10", children: /* @__PURE__ */ c(se, {}) }),
114
+ !l && n.map((e, t) => {
119
115
  if (e.header)
120
- return /* @__PURE__ */ c(te, { icon: e.icon, label: e.label }, e.id);
116
+ return /* @__PURE__ */ c(ee, { icon: e.icon, label: e.label }, e.id);
121
117
  const a = C(
122
- q && n === t ? H : "",
118
+ X && o === t ? H : "",
123
119
  e.disabled && "pointer-events-none",
124
120
  "display-flex align-items-center gap-3"
125
121
  ), d = C(
126
122
  e.disabled && "disabled",
127
- P && e.selected && "active"
123
+ G && e.selected && "active"
128
124
  );
129
- return /* @__PURE__ */ c("li", { className: d, role: "listitem", children: /* @__PURE__ */ x(
125
+ return /* @__PURE__ */ c("li", { className: d, role: "listitem", children: /* @__PURE__ */ y(
130
126
  "a",
131
127
  {
132
128
  role: "menuitem",
@@ -135,7 +131,7 @@ const B = "data-item-id", ne = 0, H = "focus", L = O, be = (h) => {
135
131
  "data-item-index": t,
136
132
  onClick: e.disabled ? void 0 : J,
137
133
  children: [
138
- /* @__PURE__ */ x("span", { className: "selected-option-dropdown-item", children: [
134
+ /* @__PURE__ */ y("span", { className: "selected-option-dropdown-item", children: [
139
135
  e.icon && /* @__PURE__ */ c(Q, { children: e.icon }),
140
136
  e.label
141
137
  ] }),
@@ -145,12 +141,12 @@ const B = "data-item-id", ne = 0, H = "focus", L = O, be = (h) => {
145
141
  ) }, e.id);
146
142
  })
147
143
  ] });
148
- }, Ne = (h, s, l) => {
149
- const u = h.filter((i) => i.text.toLowerCase().includes(s.toLowerCase()));
150
- return l.filter((i) => u.find((p) => p.id === i.id));
144
+ }, De = (h, s, l) => {
145
+ const O = h.filter((i) => i.text.toLowerCase().includes(s.toLowerCase()));
146
+ return l.filter((i) => O.find((u) => u.id === i.id));
151
147
  };
152
148
  export {
153
- be as default,
154
- Ne as filterOptions
149
+ Ie as default,
150
+ De as filterOptions
155
151
  };
156
152
  //# 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 { isEmpty } from 'es-toolkit/compat';\nimport { noop } from 'es-toolkit/function';\n\nimport classNames from '../../utils/classNames';\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(\n item =>\n ({\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 => filteredDOMValues.find(domValue => domValue.id === option.id));\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,QAAAC,IAAS;AAAA,IACT,WAAAC,IAAY;AAAA,IACZ,gBAAAC,IAAiB;AAAA,IACjB,kBAAkBC;AAAA,IAClB,cAAcC;AAAA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src/components/selects/BaseSelectDropdown.tsx"],"sourcesContent":["import type React from 'react';\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { isEmpty } from 'es-toolkit/compat';\nimport { noop } from 'es-toolkit/function';\n\nimport classNames from '../../utils/classNames';\nimport { useDropDirection } from '../../utils/useDropDirection';\nimport { DOWN, scrollItemIntoView, UP } from '../../utils/scrollItemIntoView';\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 // 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 // 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 updateDOMValues(updateItemDOMValues());\n }, [options]);\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(\n item =>\n ({\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 => filteredDOMValues.find(domValue => domValue.id === option.id));\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","dropDirection","useDropDirection","useLayoutEffect","parent","updateItemDOMValues","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":";;;;;;;;;;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