@elliemae/ds-form-combobox 3.51.0-next.2 → 3.51.0-next.3

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 (88) hide show
  1. package/dist/cjs/ComboBoxCTX.js +0 -4
  2. package/dist/cjs/ComboBoxCTX.js.map +2 -2
  3. package/dist/cjs/ComboboxDataTestids.js +0 -4
  4. package/dist/cjs/ComboboxDataTestids.js.map +2 -2
  5. package/dist/cjs/{parts/header-list/index.js → config/useClickOutside.js} +22 -6
  6. package/dist/cjs/config/useClickOutside.js.map +7 -0
  7. package/dist/cjs/config/useComboBox.js +19 -36
  8. package/dist/cjs/config/useComboBox.js.map +2 -2
  9. package/dist/cjs/config/useCorrectOptions.js +3 -6
  10. package/dist/cjs/config/useCorrectOptions.js.map +2 -2
  11. package/dist/cjs/parts/container/Container.js +29 -14
  12. package/dist/cjs/parts/container/Container.js.map +2 -2
  13. package/dist/cjs/parts/controls-input/ControlsInput.js +10 -5
  14. package/dist/cjs/parts/controls-input/ControlsInput.js.map +2 -2
  15. package/dist/cjs/parts/controls-input/useKeyboardNavigation.js +13 -16
  16. package/dist/cjs/parts/controls-input/useKeyboardNavigation.js.map +2 -2
  17. package/dist/cjs/parts/controls-input/useMaskedOnChange.js +4 -5
  18. package/dist/cjs/parts/controls-input/useMaskedOnChange.js.map +2 -2
  19. package/dist/cjs/parts/menu-list/MenuList.js +20 -35
  20. package/dist/cjs/parts/menu-list/MenuList.js.map +2 -2
  21. package/dist/cjs/parts/menu-list/styled.js.map +2 -2
  22. package/dist/cjs/parts/menu-list/useItemRenderer.js +40 -33
  23. package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
  24. package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js +9 -1
  25. package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
  26. package/dist/cjs/react-desc-prop-types.js +3 -1
  27. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  28. package/dist/cjs/sharedTypes.js.map +2 -2
  29. package/dist/cjs/utils/listHelper.js +7 -23
  30. package/dist/cjs/utils/listHelper.js.map +2 -2
  31. package/dist/esm/ComboBoxCTX.js +0 -4
  32. package/dist/esm/ComboBoxCTX.js.map +2 -2
  33. package/dist/esm/ComboboxDataTestids.js +0 -4
  34. package/dist/esm/ComboboxDataTestids.js.map +2 -2
  35. package/dist/esm/config/useClickOutside.js +22 -0
  36. package/dist/esm/config/useClickOutside.js.map +7 -0
  37. package/dist/esm/config/useComboBox.js +20 -37
  38. package/dist/esm/config/useComboBox.js.map +2 -2
  39. package/dist/esm/config/useCorrectOptions.js +4 -7
  40. package/dist/esm/config/useCorrectOptions.js.map +2 -2
  41. package/dist/esm/parts/container/Container.js +30 -15
  42. package/dist/esm/parts/container/Container.js.map +2 -2
  43. package/dist/esm/parts/controls-input/ControlsInput.js +10 -5
  44. package/dist/esm/parts/controls-input/ControlsInput.js.map +2 -2
  45. package/dist/esm/parts/controls-input/useKeyboardNavigation.js +13 -16
  46. package/dist/esm/parts/controls-input/useKeyboardNavigation.js.map +2 -2
  47. package/dist/esm/parts/controls-input/useMaskedOnChange.js +4 -5
  48. package/dist/esm/parts/controls-input/useMaskedOnChange.js.map +2 -2
  49. package/dist/esm/parts/menu-list/MenuList.js +21 -36
  50. package/dist/esm/parts/menu-list/MenuList.js.map +2 -2
  51. package/dist/esm/parts/menu-list/styled.js.map +2 -2
  52. package/dist/esm/parts/menu-list/useItemRenderer.js +41 -34
  53. package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
  54. package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js +9 -1
  55. package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
  56. package/dist/esm/react-desc-prop-types.js +3 -1
  57. package/dist/esm/react-desc-prop-types.js.map +2 -2
  58. package/dist/esm/sharedTypes.js.map +2 -2
  59. package/dist/esm/utils/listHelper.js +7 -23
  60. package/dist/esm/utils/listHelper.js.map +2 -2
  61. package/dist/types/ComboboxDataTestids.d.ts +0 -4
  62. package/dist/types/config/useClickOutside.d.ts +1 -0
  63. package/dist/types/config/useCorrectOptions.d.ts +1 -1
  64. package/dist/types/parts/menu-list/styled.d.ts +0 -1
  65. package/dist/types/react-desc-prop-types.d.ts +3 -1
  66. package/dist/types/sharedTypes.d.ts +0 -4
  67. package/dist/types/tests/read-only.test.d.ts +1 -0
  68. package/dist/types/utils/listHelper.d.ts +0 -1
  69. package/package.json +14 -14
  70. package/dist/cjs/parts/header-list/HeaderList.js +0 -104
  71. package/dist/cjs/parts/header-list/HeaderList.js.map +0 -7
  72. package/dist/cjs/parts/header-list/index.js.map +0 -7
  73. package/dist/cjs/parts/header-list/styled.js +0 -85
  74. package/dist/cjs/parts/header-list/styled.js.map +0 -7
  75. package/dist/cjs/parts/header-list/useHeaderListHandlers.js +0 -140
  76. package/dist/cjs/parts/header-list/useHeaderListHandlers.js.map +0 -7
  77. package/dist/esm/parts/header-list/HeaderList.js +0 -80
  78. package/dist/esm/parts/header-list/HeaderList.js.map +0 -7
  79. package/dist/esm/parts/header-list/index.js +0 -6
  80. package/dist/esm/parts/header-list/index.js.map +0 -7
  81. package/dist/esm/parts/header-list/styled.js +0 -55
  82. package/dist/esm/parts/header-list/styled.js.map +0 -7
  83. package/dist/esm/parts/header-list/useHeaderListHandlers.js +0 -110
  84. package/dist/esm/parts/header-list/useHeaderListHandlers.js.map +0 -7
  85. package/dist/types/parts/header-list/HeaderList.d.ts +0 -2
  86. package/dist/types/parts/header-list/index.d.ts +0 -1
  87. package/dist/types/parts/header-list/styled.d.ts +0 -6
  88. package/dist/types/parts/header-list/useHeaderListHandlers.d.ts +0 -11
@@ -61,21 +61,17 @@ const defaultContext = {
61
61
  referenceElement: null,
62
62
  inputValue: "",
63
63
  focusOptionIdx: "",
64
- showSelectedOptions: false,
65
64
  pillGroupRef: (0, import_react.createRef)(),
66
65
  listRef: (0, import_react.createRef)(),
67
66
  wrapperListRef: (0, import_react.createRef)(),
68
67
  controlsWrapperRef: (0, import_react.createRef)(),
69
68
  selectedOptionsRef: (0, import_react.createRef)(),
70
- selectAllCheckboxRef: (0, import_react.createRef)(),
71
- toggleSelectionButtonRef: (0, import_react.createRef)(),
72
69
  setShowPopover: noop,
73
70
  scrollOptionIntoView: noop,
74
71
  setHasFocus: noop,
75
72
  setInputValue: noop,
76
73
  setReferenceElement: noop,
77
74
  setFocusOptionIdx: noop,
78
- setShowSelectedOptions: noop,
79
75
  setMenuState: noop,
80
76
  internalRef: (0, import_react.createRef)(),
81
77
  correctOptions: [],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ComboBoxCTX.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { createContext, createRef } from 'react';\nimport type { DSComboboxT } from './react-desc-prop-types.js';\nimport type { DSComboboxInternalsT } from './sharedTypes.js';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nexport function noop<T extends unknown[]>(..._args: T): void {}\n\nexport const defaultProps: DSComboboxT.DefaultProps = {\n hasError: false,\n inline: false,\n withoutPortal: false,\n disabled: false,\n useMask: noop,\n innerRef: createRef(),\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'top-start'],\n noOptionsMessage: 'No Matches Found',\n isNonClearable: false,\n onlySelectable: false,\n isSkeleton: false,\n // override in useCombobox to avoid ref duplications when more than one cb is used\n applyAriaDisabled: false,\n};\n\nconst defaultContext: DSComboboxInternalsT.ComboBoxContextT = {\n props: defaultProps as DSComboboxT.InternalProps,\n menuState: false,\n hasFocus: false,\n referenceElement: null,\n inputValue: '',\n focusOptionIdx: '',\n showSelectedOptions: false,\n pillGroupRef: createRef<HTMLDivElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n selectAllCheckboxRef: createRef<HTMLInputElement>(),\n toggleSelectionButtonRef: createRef<HTMLButtonElement>(),\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n setHasFocus: noop,\n setInputValue: noop,\n setReferenceElement: noop,\n setFocusOptionIdx: noop,\n setShowSelectedOptions: noop,\n setMenuState: noop,\n internalRef: createRef<HTMLInputElement>(),\n correctOptions: [],\n instanceUid: '',\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext(defaultContext);\n\nexport default ComboBoxContext;\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AAMlC,SAAS,QAA6B,OAAgB;AAAC;AAEvD,MAAM,eAAyC;AAAA,EACpD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAU,wBAAU;AAAA,EACpB,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,WAAW;AAAA,EACtD,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,YAAY;AAAA;AAAA,EAEZ,mBAAmB;AACrB;AAEA,MAAM,iBAAwD;AAAA,EAC5D,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,kBAAc,wBAA0B;AAAA,EACxC,aAAS,wBAA0B;AAAA,EACnC,oBAAgB,wBAA0B;AAAA,EAC1C,wBAAoB,wBAA4B;AAAA,EAChD,wBAAoB,wBAA4B;AAAA,EAChD,0BAAsB,wBAA4B;AAAA,EAClD,8BAA0B,wBAA6B;AAAA,EACvD,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,cAAc;AAAA,EACd,iBAAa,wBAA4B;AAAA,EACzC,gBAAgB,CAAC;AAAA,EACjB,aAAa;AACf;AAEO,MAAM,sBAAkB,4BAAc,cAAc;AAE3D,IAAO,sBAAQ;",
4
+ "sourcesContent": ["import { createContext, createRef } from 'react';\nimport type { DSComboboxT } from './react-desc-prop-types.js';\nimport type { DSComboboxInternalsT } from './sharedTypes.js';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nexport function noop<T extends unknown[]>(..._args: T): void {}\n\nexport const defaultProps: DSComboboxT.DefaultProps = {\n hasError: false,\n inline: false,\n withoutPortal: false,\n disabled: false,\n useMask: noop,\n innerRef: createRef(),\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'top-start'],\n noOptionsMessage: 'No Matches Found',\n isNonClearable: false,\n onlySelectable: false,\n isSkeleton: false,\n // override in useCombobox to avoid ref duplications when more than one cb is used\n applyAriaDisabled: false,\n};\n\nconst defaultContext: DSComboboxInternalsT.ComboBoxContextT = {\n props: defaultProps as DSComboboxT.InternalProps,\n menuState: false,\n hasFocus: false,\n referenceElement: null,\n inputValue: '',\n focusOptionIdx: '',\n pillGroupRef: createRef<HTMLDivElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n setHasFocus: noop,\n setInputValue: noop,\n setReferenceElement: noop,\n setFocusOptionIdx: noop,\n setMenuState: noop,\n internalRef: createRef<HTMLInputElement>(),\n correctOptions: [],\n instanceUid: '',\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext(defaultContext);\n\nexport default ComboBoxContext;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AAMlC,SAAS,QAA6B,OAAgB;AAAC;AAEvD,MAAM,eAAyC;AAAA,EACpD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,SAAS;AAAA,EACT,cAAU,wBAAU;AAAA,EACpB,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,WAAW;AAAA,EACtD,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,YAAY;AAAA;AAAA,EAEZ,mBAAmB;AACrB;AAEA,MAAM,iBAAwD;AAAA,EAC5D,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,kBAAc,wBAA0B;AAAA,EACxC,aAAS,wBAA0B;AAAA,EACnC,oBAAgB,wBAA0B;AAAA,EAC1C,wBAAoB,wBAA4B;AAAA,EAChD,wBAAoB,wBAA4B;AAAA,EAChD,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,iBAAa,wBAA4B;AAAA,EACzC,gBAAgB,CAAC;AAAA,EACjB,aAAa;AACf;AAEO,MAAM,sBAAkB,4BAAc,cAAc;AAE3D,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -33,10 +33,6 @@ __export(ComboboxDataTestids_exports, {
33
33
  module.exports = __toCommonJS(ComboboxDataTestids_exports);
34
34
  var React = __toESM(require("react"));
35
35
  const ComboboxDataTestid = {
36
- MULTISELECT: {
37
- HEADER_LIST: "combobox-header-list",
38
- SHOW_SELECTED_OPTIONS_TOGGLE: "combobox-selected-options-toggle"
39
- },
40
36
  CONTROLS_WRAPPER: "combobox-controls-wrapper",
41
37
  CONTAINER: "combobox-container",
42
38
  INPUT: "combobox-input",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ComboboxDataTestids.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["export const ComboboxDataTestid = {\n MULTISELECT: {\n HEADER_LIST: 'combobox-header-list',\n SHOW_SELECTED_OPTIONS_TOGGLE: 'combobox-selected-options-toggle',\n },\n CONTROLS_WRAPPER: 'combobox-controls-wrapper',\n CONTAINER: 'combobox-container',\n INPUT: 'combobox-input',\n LIST: 'combobox-menu-list',\n NO_MATCHES_FOUND: 'combobox-no-matches-found',\n SELECTED_VALUES: 'combobox-selected-values',\n DROPDOWN: 'combobox-dropdown-btn',\n OPTION: 'combobox-option',\n ALLY_SELECTED_VALUES: 'combobox-ally-selected-values',\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,qBAAqB;AAAA,EAChC,aAAa;AAAA,IACX,aAAa;AAAA,IACb,8BAA8B;AAAA,EAChC;AAAA,EACA,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,sBAAsB;AACxB;",
4
+ "sourcesContent": ["export const ComboboxDataTestid = {\n CONTROLS_WRAPPER: 'combobox-controls-wrapper',\n CONTAINER: 'combobox-container',\n INPUT: 'combobox-input',\n LIST: 'combobox-menu-list',\n NO_MATCHES_FOUND: 'combobox-no-matches-found',\n SELECTED_VALUES: 'combobox-selected-values',\n DROPDOWN: 'combobox-dropdown-btn',\n OPTION: 'combobox-option',\n ALLY_SELECTED_VALUES: 'combobox-ally-selected-values',\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,qBAAqB;AAAA,EAChC,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,OAAO;AAAA,EACP,MAAM;AAAA,EACN,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,sBAAsB;AACxB;",
6
6
  "names": []
7
7
  }
@@ -26,11 +26,27 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var header_list_exports = {};
30
- __export(header_list_exports, {
31
- HeaderList: () => import_HeaderList.HeaderList
29
+ var useClickOutside_exports = {};
30
+ __export(useClickOutside_exports, {
31
+ useOnClickOutside: () => useOnClickOutside
32
32
  });
33
- module.exports = __toCommonJS(header_list_exports);
33
+ module.exports = __toCommonJS(useClickOutside_exports);
34
34
  var React = __toESM(require("react"));
35
- var import_HeaderList = require("./HeaderList.js");
36
- //# sourceMappingURL=index.js.map
35
+ var import_react = require("react");
36
+ function useOnClickOutside(ref, cb, excludeNode) {
37
+ (0, import_react.useEffect)(() => {
38
+ const listener = (event) => {
39
+ if (!ref || ref?.contains?.(event.target) || excludeNode && excludeNode.contains(event.target)) {
40
+ return;
41
+ }
42
+ cb(event);
43
+ };
44
+ document.addEventListener("mousedown", listener);
45
+ document.addEventListener("touchstart", listener);
46
+ return () => {
47
+ document.removeEventListener("mousedown", listener);
48
+ document.removeEventListener("touchstart", listener);
49
+ };
50
+ }, [ref, cb, excludeNode]);
51
+ }
52
+ //# sourceMappingURL=useClickOutside.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/config/useClickOutside.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { useEffect } from 'react';\n\nexport function useOnClickOutside<T extends Node, CbT extends (event: Event) => void, Z extends Node>(\n ref: T | null,\n cb: CbT,\n excludeNode: Z | null,\n): void {\n useEffect(() => {\n const listener = (event: MouseEvent | TouchEvent) => {\n if (\n !ref ||\n ref?.contains?.(event.target as Node) ||\n (excludeNode && excludeNode.contains(event.target as Node))\n ) {\n return;\n }\n cb(event);\n };\n document.addEventListener('mousedown', listener);\n document.addEventListener('touchstart', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n document.removeEventListener('touchstart', listener);\n };\n }, [ref, cb, excludeNode]);\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA0B;AAEnB,SAAS,kBACd,KACA,IACA,aACM;AACN,8BAAU,MAAM;AACd,UAAM,WAAW,CAAC,UAAmC;AACnD,UACE,CAAC,OACD,KAAK,WAAW,MAAM,MAAc,KACnC,eAAe,YAAY,SAAS,MAAM,MAAc,GACzD;AACA;AAAA,MACF;AACA,SAAG,KAAK;AAAA,IACV;AACA,aAAS,iBAAiB,aAAa,QAAQ;AAC/C,aAAS,iBAAiB,cAAc,QAAQ;AAChD,WAAO,MAAM;AACX,eAAS,oBAAoB,aAAa,QAAQ;AAClD,eAAS,oBAAoB,cAAc,QAAQ;AAAA,IACrD;AAAA,EACF,GAAG,CAAC,KAAK,IAAI,WAAW,CAAC;AAC3B;",
6
+ "names": []
7
+ }
@@ -41,13 +41,11 @@ var import_react_desc_prop_types = require("../react-desc-prop-types.js");
41
41
  var import_useCorrectOptions = require("./useCorrectOptions.js");
42
42
  var import_listHelper = require("../utils/listHelper.js");
43
43
  var import_theming = require("../theming.js");
44
- var import_useMakeMutable = require("./useMakeMutable.js");
45
44
  const useComboBox = (props) => {
46
45
  const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_ComboBoxCTX.defaultProps);
47
46
  (0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefaults, import_react_desc_prop_types.ComboboxPropTypes, import_theming.DSComboBoxName);
48
47
  const [showPopover, setShowPopover] = (0, import_react.useState)(false);
49
48
  const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
50
- const [showSelectedOptions, setShowSelectedOptions] = (0, import_react.useState)(false);
51
49
  const [inputValue, setInputValue] = (0, import_react.useState)("");
52
50
  const [hasFocus, setHasFocus] = (0, import_react.useState)(false);
53
51
  const internalRef = (0, import_react.useRef)(null);
@@ -55,8 +53,6 @@ const useComboBox = (props) => {
55
53
  const wrapperListRef = (0, import_react.useRef)(null);
56
54
  const selectedOptionsRef = (0, import_react.useRef)(null);
57
55
  const controlsWrapperRef = (0, import_react.useRef)(null);
58
- const selectAllCheckboxRef = (0, import_react.useRef)(null);
59
- const toggleSelectionButtonRef = (0, import_react.useRef)(null);
60
56
  const pillGroupRef = (0, import_react.useRef)(null);
61
57
  const { id, selectedValues, isMenuOpen, onMenuChange, applyAriaDisabled } = propsWithDefaults;
62
58
  const instanceUid = (0, import_react.useMemo)(() => id || (0, import_uid.uid)(5), [id]);
@@ -64,15 +60,7 @@ const useComboBox = (props) => {
64
60
  if (isMenuOpen !== void 0) return isMenuOpen;
65
61
  return showPopover;
66
62
  }, [showPopover, isMenuOpen]);
67
- const setMenuState = (0, import_react.useCallback)(
68
- (newState, reason, e) => {
69
- if (applyAriaDisabled) return;
70
- if (onMenuChange !== void 0) onMenuChange(newState, reason, e);
71
- setShowPopover(newState);
72
- },
73
- [onMenuChange, applyAriaDisabled]
74
- );
75
- const correctOptions = (0, import_useCorrectOptions.useCorrectOptions)(propsWithDefaults, inputValue, showSelectedOptions);
63
+ const correctOptions = (0, import_useCorrectOptions.useCorrectOptions)(propsWithDefaults, inputValue);
76
64
  const virtualListHelpers = (0, import_react_virtual.useVirtual)({
77
65
  size: correctOptions.length,
78
66
  parentRef: listRef,
@@ -89,24 +77,26 @@ const useComboBox = (props) => {
89
77
  [correctOptions, virtualListHelpers]
90
78
  );
91
79
  const [focusOptionIdx, setFocusOptionIdx] = (0, import_react.useState)("");
80
+ const setMenuState = (0, import_react.useCallback)(
81
+ (newState, reason, e) => {
82
+ if (applyAriaDisabled) return;
83
+ if (onMenuChange !== void 0) onMenuChange(newState, reason, e);
84
+ setShowPopover(newState);
85
+ if (!inputValue && newState && !focusOptionIdx && !(0, import_listHelper.isSelectedValueEmpty)(selectedValues)) {
86
+ const focusedValue = (0, import_listHelper.getFirstOption)(correctOptions, selectedValues);
87
+ setFocusOptionIdx(focusedValue);
88
+ scrollOptionIntoView(focusedValue, { align: "center" });
89
+ } else {
90
+ setFocusOptionIdx("");
91
+ }
92
+ },
93
+ [applyAriaDisabled, onMenuChange, inputValue, focusOptionIdx, selectedValues, correctOptions, scrollOptionIntoView]
94
+ );
92
95
  (0, import_react.useEffect)(() => {
93
- if (!hasFocus) setFocusOptionIdx("");
94
- if (hasFocus && (!focusOptionIdx || showSelectedOptions)) {
95
- const focusedValue = (0, import_listHelper.getFirstOption)(correctOptions, selectedValues);
96
- setFocusOptionIdx(focusedValue);
97
- scrollOptionIntoView(focusedValue, { align: "center" });
98
- }
99
- }, [showPopover, hasFocus, correctOptions, selectedValues]);
100
- const correctOptionsRef = (0, import_useMakeMutable.useMakeMutable)(correctOptions);
101
- (0, import_react.useEffect)(() => {
102
- setFocusOptionIdx(correctOptionsRef.current?.[0]?.dsId ?? "");
103
- }, [correctOptionsRef, inputValue]);
104
- (0, import_react.useEffect)(() => {
105
- if (!showPopover) {
106
- setFocusOptionIdx("");
107
- setShowSelectedOptions(false);
96
+ if (propsWithDefaults.inline) {
97
+ setMenuState(true, "inline");
108
98
  }
109
- }, [showPopover]);
99
+ }, []);
110
100
  const ctx = (0, import_react.useMemo)(
111
101
  () => ({
112
102
  props: { ...propsWithDefaults },
@@ -117,16 +107,12 @@ const useComboBox = (props) => {
117
107
  focusOptionIdx,
118
108
  selectedOptionsRef,
119
109
  controlsWrapperRef,
120
- selectAllCheckboxRef,
121
110
  inputValue,
122
111
  setInputValue,
123
112
  setMenuState,
124
113
  hasFocus,
125
- toggleSelectionButtonRef,
126
114
  pillGroupRef,
127
- showSelectedOptions,
128
115
  wrapperListRef,
129
- setShowSelectedOptions,
130
116
  setHasFocus,
131
117
  setFocusOptionIdx,
132
118
  scrollOptionIntoView,
@@ -146,14 +132,11 @@ const useComboBox = (props) => {
146
132
  inputValue,
147
133
  focusOptionIdx,
148
134
  wrapperListRef,
149
- showSelectedOptions,
150
135
  menuState,
151
136
  pillGroupRef,
152
137
  referenceElement,
153
138
  selectedOptionsRef,
154
139
  controlsWrapperRef,
155
- selectAllCheckboxRef,
156
- toggleSelectionButtonRef,
157
140
  listRef,
158
141
  internalRef,
159
142
  instanceUid
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/config/useComboBox.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback, useEffect } from 'react';\nimport { useVirtual, type ScrollToIndexOptions } from 'react-virtual';\nimport { uid } from 'uid';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from '../ComboBoxCTX.js';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { ComboboxPropTypes } from '../react-desc-prop-types.js';\nimport type { DSComboboxInternalsT } from '../sharedTypes.js';\nimport { useCorrectOptions } from './useCorrectOptions.js';\nimport { getFirstOption } from '../utils/listHelper.js';\nimport { DSComboBoxName } from '../theming.js';\nimport { useMakeMutable } from './useMakeMutable.js';\n\nexport const useComboBox = (props: DSComboboxT.Props): DSComboboxInternalsT.ComboBoxContextT => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSComboboxT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes, DSComboBoxName);\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const internalRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const selectAllCheckboxRef = useRef<HTMLInputElement>(null);\n const toggleSelectionButtonRef = useRef<HTMLButtonElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const { id, selectedValues, isMenuOpen, onMenuChange, applyAriaDisabled } = propsWithDefaults;\n\n const instanceUid = useMemo(() => id || uid(5), [id]);\n\n const menuState = useMemo(() => {\n if (isMenuOpen !== undefined) return isMenuOpen;\n return showPopover;\n }, [showPopover, isMenuOpen]);\n\n const setMenuState = useCallback(\n (\n newState: boolean,\n reason: string,\n e?: React.KeyboardEvent | React.MouseEvent | React.ChangeEvent<HTMLInputElement>,\n ) => {\n if (applyAriaDisabled) return;\n if (onMenuChange !== undefined) onMenuChange(newState, reason, e);\n setShowPopover(newState);\n },\n [onMenuChange, applyAriaDisabled],\n );\n // ---------------------------------------------------------------------------\n // Options with creatable option + filtered by selected\n // ---------------------------------------------------------------------------\n\n const correctOptions = useCorrectOptions(propsWithDefaults, inputValue, showSelectedOptions);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts: ScrollToIndexOptions = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n // ===========================================================================\n // Init focused option when opening the menu list\n // ===========================================================================\n\n const [focusOptionIdx, setFocusOptionIdx] = useState<string>('');\n\n useEffect(() => {\n // this code calculate the option to be focused when opening the menu\n // when losing focus we remove the focused one\n // when focus adquired again getFirstOption calculate the correct one\n if (!hasFocus) setFocusOptionIdx('');\n if (hasFocus && (!focusOptionIdx || showSelectedOptions)) {\n const focusedValue = getFirstOption(correctOptions, selectedValues);\n setFocusOptionIdx(focusedValue);\n scrollOptionIntoView(focusedValue, { align: 'center' });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showPopover, hasFocus, correctOptions, selectedValues]);\n\n const correctOptionsRef = useMakeMutable(correctOptions);\n\n // focus first option when typing\n useEffect(() => {\n setFocusOptionIdx(correctOptionsRef.current?.[0]?.dsId ?? '');\n }, [correctOptionsRef, inputValue]);\n\n useEffect(() => {\n if (!showPopover) {\n setFocusOptionIdx('');\n setShowSelectedOptions(false);\n }\n }, [showPopover]);\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults },\n virtualListHelpers,\n menuState,\n referenceElement,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n inputValue,\n setInputValue,\n setMenuState,\n hasFocus,\n toggleSelectionButtonRef,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setFocusOptionIdx,\n scrollOptionIntoView,\n setReferenceElement,\n setShowPopover,\n internalRef,\n correctOptions,\n instanceUid,\n }),\n [\n scrollOptionIntoView,\n setMenuState,\n correctOptions,\n hasFocus,\n propsWithDefaults,\n virtualListHelpers,\n inputValue,\n focusOptionIdx,\n wrapperListRef,\n showSelectedOptions,\n menuState,\n pillGroupRef,\n referenceElement,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n listRef,\n internalRef,\n instanceUid,\n ],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAkE;AAClE,2BAAsD;AACtD,iBAAoB;AACpB,8BAA6E;AAC7E,yBAA6B;AAE7B,mCAAkC;AAElC,+BAAkC;AAClC,wBAA+B;AAC/B,qBAA+B;AAC/B,4BAA+B;AAExB,MAAM,cAAc,CAAC,UAAoE;AAC9F,QAAM,wBAAoB,sDAAwD,OAAO,+BAAY;AACrG,8DAA+B,mBAAmB,gDAAmB,6BAAc;AACnF,QAAM,CAAC,aAAa,cAAc,QAAI,uBAAkB,KAAK;AAC7D,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAA6B,IAAI;AACjF,QAAM,CAAC,qBAAqB,sBAAsB,QAAI,uBAAkB,KAAK;AAE7E,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAiB,EAAE;AACvD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAkB,KAAK;AAEvD,QAAM,kBAAc,qBAAyB,IAAI;AACjD,QAAM,cAAU,qBAAuB,IAAI;AAC3C,QAAM,qBAAiB,qBAAuB,IAAI;AAElD,QAAM,yBAAqB,qBAAuB,IAAI;AACtD,QAAM,yBAAqB,qBAAuB,IAAI;AACtD,QAAM,2BAAuB,qBAAyB,IAAI;AAC1D,QAAM,+BAA2B,qBAA0B,IAAI;AAC/D,QAAM,mBAAe,qBAAuB,IAAI;AAEhD,QAAM,EAAE,IAAI,gBAAgB,YAAY,cAAc,kBAAkB,IAAI;AAE5E,QAAM,kBAAc,sBAAQ,MAAM,UAAM,gBAAI,CAAC,GAAG,CAAC,EAAE,CAAC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,CAAC,aAAa;AAChB,wBAAkB,EAAE;AACpB,6BAAuB,KAAK;AAAA,IAC9B;AAAA,EACF,GAAG,CAAC,WAAW,CAAC;AAEhB,QAAM,UAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO,EAAE,GAAG,kBAAkB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
4
+ "sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback, useEffect } from 'react';\nimport { useVirtual, type ScrollToIndexOptions } from 'react-virtual';\nimport { uid } from 'uid';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from '../ComboBoxCTX.js';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { ComboboxPropTypes } from '../react-desc-prop-types.js';\nimport type { DSComboboxInternalsT } from '../sharedTypes.js';\nimport { useCorrectOptions } from './useCorrectOptions.js';\nimport { getFirstOption, isSelectedValueEmpty } from '../utils/listHelper.js';\nimport { DSComboBoxName } from '../theming.js';\n\nexport const useComboBox = (props: DSComboboxT.Props): DSComboboxInternalsT.ComboBoxContextT => {\n const propsWithDefaults = useMemoMergePropsWithDefault<DSComboboxT.InternalProps>(props, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes, DSComboBoxName);\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const internalRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const { id, selectedValues, isMenuOpen, onMenuChange, applyAriaDisabled } = propsWithDefaults;\n\n const instanceUid = useMemo(() => id || uid(5), [id]);\n\n const menuState = useMemo(() => {\n if (isMenuOpen !== undefined) return isMenuOpen;\n return showPopover;\n }, [showPopover, isMenuOpen]);\n\n // ---------------------------------------------------------------------------\n // Options with creatable option + filtered by selected\n // ---------------------------------------------------------------------------\n\n const correctOptions = useCorrectOptions(propsWithDefaults, inputValue);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts: ScrollToIndexOptions = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n // ===========================================================================\n // Init focused option when opening the menu list\n // ===========================================================================\n\n const [focusOptionIdx, setFocusOptionIdx] = useState<string>('');\n\n const setMenuState = useCallback(\n (\n newState: boolean,\n reason: string,\n e?: React.KeyboardEvent | React.MouseEvent | React.ChangeEvent<HTMLInputElement>,\n ) => {\n if (applyAriaDisabled) return;\n if (onMenuChange !== undefined) onMenuChange(newState, reason, e);\n setShowPopover(newState);\n\n if (!inputValue && newState && !focusOptionIdx && !isSelectedValueEmpty(selectedValues)) {\n const focusedValue = getFirstOption(correctOptions, selectedValues);\n setFocusOptionIdx(focusedValue);\n scrollOptionIntoView(focusedValue, { align: 'center' });\n } else {\n setFocusOptionIdx('');\n }\n },\n [applyAriaDisabled, onMenuChange, inputValue, focusOptionIdx, selectedValues, correctOptions, scrollOptionIntoView],\n );\n\n // We need to force the auto focus for the inline since we dont control the floating wrapper.\n useEffect(() => {\n if (propsWithDefaults.inline) {\n setMenuState(true, 'inline');\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults },\n virtualListHelpers,\n menuState,\n referenceElement,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n inputValue,\n setInputValue,\n setMenuState,\n hasFocus,\n pillGroupRef,\n wrapperListRef,\n setHasFocus,\n setFocusOptionIdx,\n scrollOptionIntoView,\n setReferenceElement,\n setShowPopover,\n internalRef,\n correctOptions,\n instanceUid,\n }),\n [\n scrollOptionIntoView,\n setMenuState,\n correctOptions,\n hasFocus,\n propsWithDefaults,\n virtualListHelpers,\n inputValue,\n focusOptionIdx,\n wrapperListRef,\n menuState,\n pillGroupRef,\n referenceElement,\n selectedOptionsRef,\n controlsWrapperRef,\n listRef,\n internalRef,\n instanceUid,\n ],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAkE;AAClE,2BAAsD;AACtD,iBAAoB;AACpB,8BAA6E;AAC7E,yBAA6B;AAE7B,mCAAkC;AAElC,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AC,gBAAgB,iBAAiB,QAAI,uBAAiB,EAAE;AAE/D,QAAM,mBAAe;AAAA,IACnB,CACE,UACA,QACA,MACG;AACH,UAAI,kBAAmB;AACvB,UAAI,iBAAiB,OAAW,cAAa,UAAU,QAAQ,CAAC;AAChE,qBAAe,QAAQ;AAEvB,UAAI,CAAC,cAAc,YAAY,CAAC,kBAAkB,KAAC,wCAAqB,cAAc,GAAG;AACvF,cAAM,mBAAe,kCAAe,gBAAgB,cAAc;AAClE,0BAAkB,YAAY;AAC9B,6BAAqB,cAAc,EAAE,OAAO,SAAS,CAAC;AAAA,MACxD,OAAO;AACL,0BAAkB,EAAE;AAAA,MACtB;AAAA,IACF;AAAA,IACA,CAAC,mBAAmB,cAAc,YAAY,gBAAgB,gBAAgB,gBAAgB,oBAAoB;AAAA,EACpH;AAGA,8BAAU,MAAM;AACd,QAAI,kBAAkB,QAAQ;AAC5B,mBAAa,MAAM,QAAQ;AAAA,IAC7B;AAAA,EAEF,GAAG,CAAC,CAAC;AAEL,QAAM,UAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO,EAAE,GAAG,kBAAkB;AAAA,MAC9B;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -36,8 +36,8 @@ var import_react = require("react");
36
36
  var import_uid = require("uid");
37
37
  var import_constants = require("../constants.js");
38
38
  var import_listHelper = require("../utils/listHelper.js");
39
- const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
40
- const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;
39
+ const useCorrectOptions = (propsWithDefaults, inputValue) => {
40
+ const { filteredOptions, allOptions, onCreate } = propsWithDefaults;
41
41
  return (0, import_react.useMemo)(() => {
42
42
  let correctAllOptions = allOptions;
43
43
  if (allOptions?.every((option) => typeof option === "string")) {
@@ -49,9 +49,6 @@ const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) =
49
49
  }));
50
50
  }
51
51
  const correctFilterOptions = filteredOptions ?? (0, import_listHelper.filterOptions)(inputValue, correctAllOptions);
52
- if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
53
- return (0, import_listHelper.selectedValuesWithSections)(correctFilterOptions, selectedValues);
54
- }
55
52
  if (onCreate && inputValue && correctFilterOptions.findIndex(
56
53
  (option) => option.type === import_constants.MENU_OPTION_TYPES.OPTION && option.label === inputValue
57
54
  ) === -1) {
@@ -65,6 +62,6 @@ const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) =
65
62
  return [creatableItem, ...correctFilterOptions];
66
63
  }
67
64
  return correctFilterOptions;
68
- }, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);
65
+ }, [filteredOptions, allOptions, onCreate, inputValue]);
69
66
  };
70
67
  //# sourceMappingURL=useCorrectOptions.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/config/useCorrectOptions.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\nimport { useMemo } from 'react';\nimport { uid } from 'uid';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { MENU_OPTION_TYPES } from '../constants.js';\nimport { selectedValuesWithSections, filterOptions } from '../utils/listHelper.js';\nconst useCorrectOptions = (propsWithDefaults: DSComboboxT.Props, inputValue: string, showSelectedOptions: boolean) => {\n const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;\n\n return useMemo(() => {\n let correctAllOptions = allOptions;\n if (allOptions?.every((option) => typeof option === 'string')) {\n correctAllOptions = allOptions.map((option, index) => ({\n dsId: index.toString(),\n label: option as unknown as string,\n type: MENU_OPTION_TYPES.OPTION,\n value: option as unknown as string,\n }));\n }\n const correctFilterOptions = filteredOptions ?? filterOptions(inputValue, correctAllOptions);\n // when show selected toggle is on we return the selected value only as filteredOptions prop\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections(correctFilterOptions, selectedValues);\n }\n\n // whether oncreate is passed we add as first option the creatable action based on input value string\n if (\n onCreate &&\n inputValue &&\n correctFilterOptions.findIndex(\n (option) => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue,\n ) === -1\n ) {\n const creatableUuid = uid();\n const creatableItem: DSComboboxT.ItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputValue,\n type: 'creatable',\n 'aria-describedby': `aria-creatable`,\n };\n\n return [creatableItem, ...correctFilterOptions];\n }\n\n return correctFilterOptions;\n }, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);\n};\n\nexport { useCorrectOptions };\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAwB;AACxB,iBAAoB;AAEpB,uBAAkC;AAClC,wBAA0D;AAC1D,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,iBAAiB,YAAY,gBAAgB,SAAS,IAAI;AAElE,aAAO,sBAAQ,MAAM;AACnB,QAAI,oBAAoB;AACxB,QAAI,YAAY,MAAM,CAAC,WAAW,OAAO,WAAW,QAAQ,GAAG;AAC7D,0BAAoB,WAAW,IAAI,CAAC,QAAQ,WAAW;AAAA,QACrD,MAAM,MAAM,SAAS;AAAA,QACrB,OAAO;AAAA,QACP,MAAM,mCAAkB;AAAA,QACxB,OAAO;AAAA,MACT,EAAE;AAAA,IACJ;AACA,UAAM,uBAAuB,uBAAmB,iCAAc,YAAY,iBAAiB;AAE3F,QAAI,uBAAuB,MAAM,QAAQ,cAAc,KAAK,eAAe,SAAS,GAAG;AACrF,iBAAO,8CAA2B,sBAAsB,cAAc;AAAA,IACxE;AAGA,QACE,YACA,cACA,qBAAqB;AAAA,MACnB,CAAC,WAAW,OAAO,SAAS,mCAAkB,UAAU,OAAO,UAAU;AAAA,IAC3E,MAAM,IACN;AACA,YAAM,oBAAgB,gBAAI;AAC1B,YAAM,gBAAiD;AAAA,QACrD,MAAM,aAAa,aAAa;AAAA,QAChC,OAAO;AAAA,QACP,MAAM;AAAA,QACN,oBAAoB;AAAA,MACtB;AAEA,aAAO,CAAC,eAAe,GAAG,oBAAoB;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,iBAAiB,YAAY,qBAAqB,gBAAgB,UAAU,UAAU,CAAC;AAC7F;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\nimport { useMemo } from 'react';\nimport { uid } from 'uid';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { MENU_OPTION_TYPES } from '../constants.js';\nimport { filterOptions } from '../utils/listHelper.js';\nconst useCorrectOptions = (propsWithDefaults: DSComboboxT.Props, inputValue: string) => {\n const { filteredOptions, allOptions, onCreate } = propsWithDefaults;\n\n return useMemo(() => {\n let correctAllOptions = allOptions;\n if (allOptions?.every((option) => typeof option === 'string')) {\n correctAllOptions = allOptions.map((option, index) => ({\n dsId: index.toString(),\n label: option as unknown as string,\n type: MENU_OPTION_TYPES.OPTION,\n value: option as unknown as string,\n }));\n }\n const correctFilterOptions = filteredOptions ?? filterOptions(inputValue, correctAllOptions);\n\n // whether oncreate is passed we add as first option the creatable action based on input value string\n if (\n onCreate &&\n inputValue &&\n correctFilterOptions.findIndex(\n (option) => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue,\n ) === -1\n ) {\n const creatableUuid = uid();\n const creatableItem: DSComboboxT.ItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputValue,\n type: 'creatable',\n 'aria-describedby': `aria-creatable`,\n };\n\n return [creatableItem, ...correctFilterOptions];\n }\n\n return correctFilterOptions;\n }, [filteredOptions, allOptions, onCreate, inputValue]);\n};\n\nexport { useCorrectOptions };\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAwB;AACxB,iBAAoB;AAEpB,uBAAkC;AAClC,wBAA8B;AAC9B,MAAM,oBAAoB,CAAC,mBAAsC,eAAuB;AACtF,QAAM,EAAE,iBAAiB,YAAY,SAAS,IAAI;AAElD,aAAO,sBAAQ,MAAM;AACnB,QAAI,oBAAoB;AACxB,QAAI,YAAY,MAAM,CAAC,WAAW,OAAO,WAAW,QAAQ,GAAG;AAC7D,0BAAoB,WAAW,IAAI,CAAC,QAAQ,WAAW;AAAA,QACrD,MAAM,MAAM,SAAS;AAAA,QACrB,OAAO;AAAA,QACP,MAAM,mCAAkB;AAAA,QACxB,OAAO;AAAA,MACT,EAAE;AAAA,IACJ;AACA,UAAM,uBAAuB,uBAAmB,iCAAc,YAAY,iBAAiB;AAG3F,QACE,YACA,cACA,qBAAqB;AAAA,MACnB,CAAC,WAAW,OAAO,SAAS,mCAAkB,UAAU,OAAO,UAAU;AAAA,IAC3E,MAAM,IACN;AACA,YAAM,oBAAgB,gBAAI;AAC1B,YAAM,gBAAiD;AAAA,QACrD,MAAM,aAAa,aAAa;AAAA,QAChC,OAAO;AAAA,QACP,MAAM;AAAA,QACN,oBAAoB;AAAA,MACtB;AAEA,aAAO,CAAC,eAAe,GAAG,oBAAoB;AAAA,IAChD;AAEA,WAAO;AAAA,EACT,GAAG,CAAC,iBAAiB,YAAY,UAAU,UAAU,CAAC;AACxD;",
6
6
  "names": []
7
7
  }
@@ -35,16 +35,18 @@ var React = __toESM(require("react"));
35
35
  var import_jsx_runtime = require("react/jsx-runtime");
36
36
  var import_react = require("react");
37
37
  var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
38
- var import_ds_popperjs = require("@elliemae/ds-popperjs");
38
+ var import_ds_system = require("@elliemae/ds-system");
39
+ var import_ds_floating_context = require("@elliemae/ds-floating-context");
39
40
  var import_ComboBoxCTX = __toESM(require("../../ComboBoxCTX.js"));
40
41
  var import_styled = require("./styled.js");
41
42
  var import_controls = require("../controls/index.js");
42
43
  var import_menu_list = require("../menu-list/index.js");
43
44
  var import_ComboboxDataTestids = require("../../ComboboxDataTestids.js");
44
45
  var import_LiveRegion = require("../LiveRegion.js");
46
+ var import_useClickOutside = require("../../config/useClickOutside.js");
45
47
  const Container = () => {
46
48
  const { props, internalRef, setMenuState, menuState, setReferenceElement, referenceElement } = (0, import_react.useContext)(import_ComboBoxCTX.default);
47
- const { inline, startPlacementPreference, placementOrderPreference, withoutPortal, applyAriaDisabled } = props;
49
+ const { inline, startPlacementPreference, placementOrderPreference, applyAriaDisabled } = props;
48
50
  const globalAttributes = (0, import_ds_props_helpers.useGetGlobalAttributes)(props);
49
51
  const { zIndex, ...xStyledProps } = (0, import_ds_props_helpers.useGetXstyledProps)(props);
50
52
  const correctZIndex = zIndex ? parseInt(zIndex, 10) : void 0;
@@ -65,13 +67,32 @@ const Container = () => {
65
67
  window.removeEventListener("blur", closeMenuOnWindowBlur);
66
68
  };
67
69
  }, [menuState, setMenuState]);
70
+ const config = (0, import_react.useMemo)(
71
+ () => ({
72
+ placement: "bottom",
73
+ withoutAnimation: true,
74
+ startPlacementPreference,
75
+ placementOrderPreference,
76
+ zIndex: correctZIndex,
77
+ customOffset: [0, 5],
78
+ handleCloseMenu,
79
+ portalDOMContainer: document.body
80
+ }),
81
+ [startPlacementPreference, placementOrderPreference, correctZIndex, handleCloseMenu]
82
+ );
83
+ const { refs, floatingStyles, context } = (0, import_ds_floating_context.useFloatingContext)(config);
84
+ const comboboxRef = (0, import_ds_system.mergeRefs)(setReferenceElement, refs.setReference);
85
+ const hideTooltip = (0, import_react.useCallback)(() => {
86
+ setMenuState(false, "blur");
87
+ }, [setMenuState]);
88
+ (0, import_useClickOutside.useOnClickOutside)(referenceElement, hideTooltip, refs.floating);
68
89
  return (
69
90
  // eslint-disable-next-line react/jsx-no-useless-fragment
70
91
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
71
92
  import_styled.StyledContainer,
72
93
  {
73
94
  "data-testid": dataTestId ?? import_ComboboxDataTestids.ComboboxDataTestid.CONTAINER,
74
- innerRef: setReferenceElement,
95
+ innerRef: comboboxRef,
75
96
  className,
76
97
  applyAriaDisabled,
77
98
  ...xStyledProps,
@@ -83,18 +104,12 @@ const Container = () => {
83
104
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
84
105
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_controls.Controls, {}),
85
106
  referenceElement ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
- import_ds_popperjs.DSPopperJS,
107
+ import_ds_floating_context.FloatingWrapper,
87
108
  {
88
- customOffset: [0, 5],
89
- referenceElement,
90
- showPopover: menuState,
91
- closeContextMenu: handleCloseMenu,
92
- startPlacementPreference,
93
- placementOrderPreference,
94
- withoutPortal,
95
- withoutArrow: true,
96
- withoutAnimation: true,
97
- zIndex: correctZIndex,
109
+ innerRef: refs.setFloating,
110
+ floatingStyles,
111
+ isOpen: menuState,
112
+ context,
98
113
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyledPopperWrapper, { tabIndex: -1, onMouseDown: handleMouseDown, applyAriaDisabled, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_menu_list.MenuList, {}) })
99
114
  }
100
115
  ) : null
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/parts/container/Container.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useCallback, useEffect, useContext } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\nimport { StyledContainer, StyledPopperWrapper } from './styled.js';\nimport { Controls } from '../controls/index.js';\nimport { MenuList } from '../menu-list/index.js';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport { LiveRegion } from '../LiveRegion.js';\n\nexport const Container = (): JSX.Element => {\n const { props, internalRef, setMenuState, menuState, setReferenceElement, referenceElement } =\n useContext(ComboBoxContext);\n\n const { inline, startPlacementPreference, placementOrderPreference, withoutPortal, applyAriaDisabled } = props;\n const globalAttributes = useGetGlobalAttributes(props) as ReturnType<typeof useGetGlobalAttributes> & {\n 'data-testid'?: string;\n };\n const { zIndex, ...xStyledProps } = useGetXstyledProps(props);\n\n const correctZIndex = zIndex ? parseInt(zIndex as string, 10) : undefined;\n // Removing possible collisionable props\n const { className, 'data-testid': dataTestId } = globalAttributes;\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleCloseMenu = useCallback(() => {\n setMenuState(false, 'blur');\n if (internalRef?.current) internalRef.current.blur();\n }, [internalRef, setMenuState]);\n\n useEffect(() => {\n const closeMenuOnWindowBlur = () => {\n if (menuState) setMenuState(false, 'blur');\n };\n\n window.addEventListener('blur', closeMenuOnWindowBlur);\n\n return () => {\n window.removeEventListener('blur', closeMenuOnWindowBlur);\n };\n }, [menuState, setMenuState]);\n\n return (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>\n <StyledContainer\n data-testid={dataTestId ?? ComboboxDataTestid.CONTAINER}\n innerRef={setReferenceElement}\n className={className}\n applyAriaDisabled={applyAriaDisabled}\n {...xStyledProps}\n >\n <LiveRegion />\n\n {inline ? (\n <>\n <Controls />\n <MenuList />\n </>\n ) : (\n <>\n <Controls />\n {referenceElement ? (\n <DSPopperJS\n customOffset={[0, 5]}\n referenceElement={referenceElement}\n showPopover={menuState}\n closeContextMenu={handleCloseMenu}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal={withoutPortal}\n withoutArrow\n withoutAnimation\n zIndex={correctZIndex}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown} applyAriaDisabled={applyAriaDisabled}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n ) : null}\n </>\n )}\n </StyledContainer>\n </>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADuDf;AAtDR,mBAA0D;AAC1D,8BAA2D;AAC3D,yBAA2B;AAC3B,yBAA4B;AAC5B,oBAAqD;AACrD,sBAAyB;AACzB,uBAAyB;AACzB,iCAAmC;AACnC,wBAA2B;AAEpB,MAAM,YAAY,MAAmB;AAC1C,QAAM,EAAE,OAAO,aAAa,cAAc,WAAW,qBAAqB,iBAAiB,QACzF,yBAAW,mBAAAA,OAAe;AAE5B,QAAM,EAAE,QAAQ,0BAA0B,0BAA0B,eAAe,kBAAkB,IAAI;AACzG,QAAM,uBAAmB,gDAAuB,KAAK;AAGrD,QAAM,EAAE,QAAQ,GAAG,aAAa,QAAI,4CAAmB,KAAK;AAE5D,QAAM,gBAAgB,SAAS,SAAS,QAAkB,EAAE,IAAI;AAEhE,QAAM,EAAE,WAAW,eAAe,WAAW,IAAI;AACjD,QAAM,sBAAkB,0BAAY,CAAC,MAAwB;AAC3D,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,sBAAkB,0BAAY,MAAM;AACxC,iBAAa,OAAO,MAAM;AAC1B,QAAI,aAAa,QAAS,aAAY,QAAQ,KAAK;AAAA,EACrD,GAAG,CAAC,aAAa,YAAY,CAAC;AAE9B,8BAAU,MAAM;AACd,UAAM,wBAAwB,MAAM;AAClC,UAAI,UAAW,cAAa,OAAO,MAAM;AAAA,IAC3C;AAEA,WAAO,iBAAiB,QAAQ,qBAAqB;AAErD,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,qBAAqB;AAAA,IAC1D;AAAA,EACF,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B;AAAA;AAAA,IAEE,2EACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAa,cAAc,8CAAmB;AAAA,QAC9C,UAAU;AAAA,QACV;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QAEJ;AAAA,sDAAC,gCAAW;AAAA,UAEX,SACC,4EACE;AAAA,wDAAC,4BAAS;AAAA,YACV,4CAAC,6BAAS;AAAA,aACZ,IAEA,4EACE;AAAA,wDAAC,4BAAS;AAAA,YACT,mBACC;AAAA,cAAC;AAAA;AAAA,gBACC,cAAc,CAAC,GAAG,CAAC;AAAA,gBACnB;AAAA,gBACA,aAAa;AAAA,gBACb,kBAAkB;AAAA,gBAClB;AAAA,gBACA;AAAA,gBACA;AAAA,gBACA,cAAY;AAAA,gBACZ,kBAAgB;AAAA,gBAChB,QAAQ;AAAA,gBAER,sDAAC,qCAAoB,UAAU,IAAI,aAAa,iBAAiB,mBAC/D,sDAAC,6BAAS,GACZ;AAAA;AAAA,YACF,IACE;AAAA,aACN;AAAA;AAAA;AAAA,IAEJ,GACF;AAAA;AAEJ;",
4
+ "sourcesContent": ["/* eslint-disable complexity */\nimport React, { useCallback, useMemo, useEffect, useContext } from 'react';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { useFloatingContext, FloatingWrapper, type DSHookFloatingContextT } from '@elliemae/ds-floating-context';\nimport ComboBoxContext from '../../ComboBoxCTX.js';\nimport { StyledContainer, StyledPopperWrapper } from './styled.js';\nimport { Controls } from '../controls/index.js';\nimport { MenuList } from '../menu-list/index.js';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport { LiveRegion } from '../LiveRegion.js';\nimport { useOnClickOutside } from '../../config/useClickOutside.js';\n\nexport const Container = (): JSX.Element => {\n const { props, internalRef, setMenuState, menuState, setReferenceElement, referenceElement } =\n useContext(ComboBoxContext);\n\n const { inline, startPlacementPreference, placementOrderPreference, applyAriaDisabled } = props;\n const globalAttributes = useGetGlobalAttributes(props) as ReturnType<typeof useGetGlobalAttributes> & {\n 'data-testid'?: string;\n };\n const { zIndex, ...xStyledProps } = useGetXstyledProps(props);\n\n const correctZIndex = zIndex ? parseInt(zIndex as string, 10) : undefined;\n // Removing possible collisionable props\n const { className, 'data-testid': dataTestId } = globalAttributes;\n const handleMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n }, []);\n\n const handleCloseMenu = useCallback(() => {\n setMenuState(false, 'blur');\n if (internalRef?.current) internalRef.current.blur();\n }, [internalRef, setMenuState]);\n\n useEffect(() => {\n const closeMenuOnWindowBlur = () => {\n if (menuState) setMenuState(false, 'blur');\n };\n\n window.addEventListener('blur', closeMenuOnWindowBlur);\n\n return () => {\n window.removeEventListener('blur', closeMenuOnWindowBlur);\n };\n }, [menuState, setMenuState]);\n\n const config = useMemo(\n () => ({\n placement: 'bottom' as DSHookFloatingContextT.PopperPlacementsT,\n withoutAnimation: true,\n startPlacementPreference,\n placementOrderPreference,\n zIndex: correctZIndex,\n customOffset: [0, 5] as [number, number],\n handleCloseMenu,\n portalDOMContainer: document.body,\n }),\n [startPlacementPreference, placementOrderPreference, correctZIndex, handleCloseMenu],\n );\n\n const { refs, floatingStyles, context } = useFloatingContext(config);\n\n const comboboxRef = mergeRefs(setReferenceElement, refs.setReference);\n\n const hideTooltip = useCallback(() => {\n setMenuState(false, 'blur');\n }, [setMenuState]);\n\n useOnClickOutside(referenceElement, hideTooltip, refs.floating);\n\n return (\n // eslint-disable-next-line react/jsx-no-useless-fragment\n <>\n <StyledContainer\n data-testid={dataTestId ?? ComboboxDataTestid.CONTAINER}\n innerRef={comboboxRef}\n className={className}\n applyAriaDisabled={applyAriaDisabled}\n {...xStyledProps}\n >\n <LiveRegion />\n\n {inline ? (\n <>\n <Controls />\n <MenuList />\n </>\n ) : (\n <>\n <Controls />\n {referenceElement ? (\n <FloatingWrapper\n innerRef={refs.setFloating}\n floatingStyles={floatingStyles}\n isOpen={menuState}\n context={context}\n >\n <StyledPopperWrapper tabIndex={-1} onMouseDown={handleMouseDown} applyAriaDisabled={applyAriaDisabled}>\n <MenuList />\n </StyledPopperWrapper>\n </FloatingWrapper>\n ) : null}\n </>\n )}\n </StyledContainer>\n </>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADiFf;AAhFR,mBAAmE;AACnE,8BAA2D;AAC3D,uBAA0B;AAC1B,iCAAiF;AACjF,yBAA4B;AAC5B,oBAAqD;AACrD,sBAAyB;AACzB,uBAAyB;AACzB,iCAAmC;AACnC,wBAA2B;AAC3B,6BAAkC;AAE3B,MAAM,YAAY,MAAmB;AAC1C,QAAM,EAAE,OAAO,aAAa,cAAc,WAAW,qBAAqB,iBAAiB,QACzF,yBAAW,mBAAAA,OAAe;AAE5B,QAAM,EAAE,QAAQ,0BAA0B,0BAA0B,kBAAkB,IAAI;AAC1F,QAAM,uBAAmB,gDAAuB,KAAK;AAGrD,QAAM,EAAE,QAAQ,GAAG,aAAa,QAAI,4CAAmB,KAAK;AAE5D,QAAM,gBAAgB,SAAS,SAAS,QAAkB,EAAE,IAAI;AAEhE,QAAM,EAAE,WAAW,eAAe,WA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A,aACZ,IAEA,4EACE;AAAA,wDAAC,4BAAS;AAAA,YACT,mBACC;AAAA,cAAC;AAAA;AAAA,gBACC,UAAU,KAAK;AAAA,gBACf;AAAA,gBACA,QAAQ;AAAA,gBACR;AAAA,gBAEA,sDAAC,qCAAoB,UAAU,IAAI,aAAa,iBAAiB,mBAC/D,sDAAC,6BAAS,GACZ;AAAA;AAAA,YACF,IACE;AAAA,aACN;AAAA;AAAA;AAAA,IAEJ,GACF;AAAA;AAEJ;",
6
6
  "names": ["ComboBoxContext"]
7
7
  }
@@ -55,6 +55,7 @@ const ControlsInput = () => {
55
55
  isLoading,
56
56
  onlySelectable,
57
57
  applyAriaDisabled,
58
+ readOnly,
58
59
  ...restProps
59
60
  },
60
61
  focusOptionIdx,
@@ -84,13 +85,16 @@ const ControlsInput = () => {
84
85
  }, [ariaDescribedBy, id]);
85
86
  const currentPlaceholder = (0, import_react.useMemo)(() => {
86
87
  if ((0, import_listHelper.isArrayOfItems)(selectedValues)) {
87
- return `options ${selectedValues.map((item) => item.label).join(", ")} selected`;
88
+ return `options ${selectedValues.map((item) => item.label).join(", ")} selected. ${readOnly ? "Read only" : ""}`;
88
89
  }
89
90
  if (typeof selectedValues?.label === "string") {
90
- return `option ${selectedValues.label} selected`;
91
+ return `option ${selectedValues.label} selected. ${readOnly ? "Read only" : ""}`;
92
+ }
93
+ if (readOnly) {
94
+ return `${placeholder}. Read only`;
91
95
  }
92
96
  return placeholder;
93
- }, [placeholder, selectedValues]);
97
+ }, [placeholder, selectedValues, readOnly]);
94
98
  const activeDescendant = (0, import_react.useMemo)(() => {
95
99
  if (!isLoading && hasFocus && menuState) {
96
100
  return focusOptionIdx;
@@ -112,7 +116,7 @@ const ControlsInput = () => {
112
116
  {
113
117
  onBlur: handleOnBlur,
114
118
  onFocus: handleOnFocus,
115
- readOnly: onlySelectable,
119
+ readOnly: readOnly || onlySelectable,
116
120
  ...globalAttrs,
117
121
  id,
118
122
  "data-testid": import_ComboboxDataTestids.ComboboxDataTestid.INPUT,
@@ -134,7 +138,8 @@ const ControlsInput = () => {
134
138
  onChange: handleOnChange,
135
139
  tabIndex,
136
140
  withoutCaret: onlySelectable,
137
- autoComplete: "off"
141
+ autoComplete: "off",
142
+ "aria-readonly": readOnly
138
143
  }
139
144
  ),
140
145
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_styled.StyleHiddenInput, { type: "text", name: "hidden", tabIndex: -1, onPaste: handleOnPaste, "aria-hidden": "true" })
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/parts/controls-input/ControlsInput.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport {\n StyledInput,\n StyledInputWrapper,\n StyledInputPlaceHolder,\n StyledInputWidthReference,\n StyledHiddenDiv,\n StyleHiddenInput,\n} from './styled.js';\nimport { useKeyboardNavigation } from './useKeyboardNavigation.js';\nimport { useControlsInput } from './useControlsInput.js';\nimport { ComboBoxContext } from '../../ComboBoxCTX.js';\nimport { isArrayOfItems } from '../../utils/listHelper.js';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: {\n autoFocus,\n inline,\n selectedValues,\n placeholder,\n disabled,\n innerRef,\n isLoading,\n onlySelectable,\n applyAriaDisabled,\n ...restProps\n },\n focusOptionIdx,\n hasFocus,\n internalRef,\n inputValue,\n setInputValue,\n menuState,\n instanceUid,\n } = useContext(ComboBoxContext);\n const { onInputKeyDown } = useKeyboardNavigation();\n const { spanReference, width, spanReferenceText, showPlaceholder, handleOnBlur, handleOnChange, handleOnFocus } =\n useControlsInput();\n\n const {\n tabIndex,\n id,\n 'aria-describedby': ariaDescribedBy,\n ...globalAttrs\n } = useGetGlobalAttributes(restProps, {\n onFocus: handleOnFocus,\n onBlur: handleOnBlur,\n });\n\n const actualAriaDescribedBy = useMemo(() => {\n if (id) {\n return `${ariaDescribedBy ?? ''} ${id}_current_placeholder ${id}_feedback_message ${id}_error_message`;\n }\n return ariaDescribedBy;\n }, [ariaDescribedBy, id]);\n\n const currentPlaceholder = useMemo(() => {\n if (isArrayOfItems(selectedValues)) {\n return `options ${selectedValues.map((item) => item.label).join(', ')} selected`;\n }\n if (typeof selectedValues?.label === 'string') {\n return `option ${selectedValues.label} selected`;\n }\n return placeholder;\n }, [placeholder, selectedValues]);\n\n const activeDescendant = useMemo(() => {\n if (!isLoading && hasFocus && menuState) {\n return focusOptionIdx;\n }\n return undefined;\n }, [focusOptionIdx, hasFocus, isLoading, menuState]);\n\n const handleOnPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n setInputValue(e.clipboardData.getData('text/plain'));\n internalRef.current?.focus();\n };\n return (\n <StyledInputWrapper>\n <StyledInputWidthReference innerRef={spanReference}>{spanReferenceText}</StyledInputWidthReference>\n {showPlaceholder && (\n <StyledInputPlaceHolder aria-hidden=\"true\">\n <SimpleTruncatedTooltipText value={showPlaceholder}></SimpleTruncatedTooltipText>\n </StyledInputPlaceHolder>\n )}\n\n {/* The purpose of this div is to always have the 'combo-listbox-{uid}' present in the DOM */}\n {/* Fix for PUI-11597 */}\n {menuState === false && !inline ? <StyledHiddenDiv id={`combo-listbox-${instanceUid}`}></StyledHiddenDiv> : null}\n\n {/* The announcement of currentPlaceholder is being overridden by the value of actualAriaDescribedBy */}\n {/* and since this variable is necessary for the annoucement of FormLayoutBlockItem error and feedback */}\n {/* messages, we concatenate the value of actualPlaceholder with that aria description */}\n {/* Fix for PUI-9609 */}\n <StyledHiddenDiv id={`${id}_current_placeholder`}>{currentPlaceholder}</StyledHiddenDiv>\n\n <StyledInput\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n readOnly={onlySelectable}\n {...globalAttrs}\n id={id}\n data-testid={ComboboxDataTestid.INPUT}\n autoFocus={autoFocus}\n placeholder={currentPlaceholder}\n aria-activedescendant={activeDescendant}\n aria-expanded={menuState}\n aria-controls={`combo-listbox-${instanceUid}`}\n aria-describedby={actualAriaDescribedBy}\n aria-autocomplete=\"list\"\n role=\"combobox\"\n disabled={disabled}\n applyAriaDisabled={applyAriaDisabled}\n style={{ width }}\n innerRef={mergeRefs(innerRef, internalRef)}\n value={inputValue}\n type=\"text\"\n onKeyDown={onInputKeyDown}\n onChange={handleOnChange}\n tabIndex={tabIndex}\n withoutCaret={onlySelectable}\n autoComplete=\"off\"\n />\n {/* This input is used to handle the paste event */}\n <StyleHiddenInput type=\"text\" name=\"hidden\" tabIndex={-1} onPaste={handleOnPaste} aria-hidden=\"true\" />\n </StyledInputWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADoFnB;AApFJ,mBAA2C;AAC3C,uCAA2C;AAC3C,uBAA0B;AAC1B,8BAAuC;AACvC,iCAAmC;AACnC,oBAOO;AACP,mCAAsC;AACtC,8BAAiC;AACjC,yBAAgC;AAChC,wBAA+B;AAExB,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,kCAAe;AAC9B,QAAM,EAAE,eAAe,QAAI,oDAAsB;AACjD,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,cAAc,QAC5G,0CAAiB;AAEnB,QAAM;AAAA,IACJ;A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AAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,UAAU;AAAA,QACT,GAAG;AAAA,QACJ;AAAA,QACA,eAAa,8CAAmB;AAAA,QAChC;AAAA,QACA,aAAa;AAAA,QACb,yBAAuB;AAAA,QACvB,iBAAe;AAAA,QACf,iBAAe,iBAAiB,WAAW;AAAA,QAC3C,oBAAkB;AAAA,QAClB,qBAAkB;AAAA,QAClB,MAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA,OAAO,EAAE,MAAM;AAAA,QACf,cAAU,4BAAU,UAAU,WAAW;AAAA,QACzC,OAAO;AAAA,QACP,MAAK;AAAA,QACL,WAAW;AAAA,QACX,UAAU;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,cAAa;AAAA;AAAA,IACf;AAAA,IAEA,4CAAC,kCAAiB,MAAK,QAAO,MAAK,UAAS,UAAU,IAAI,SAAS,eAAe,eAAY,QAAO;AAAA,KACvG;AAEJ;",
4
+ "sourcesContent": ["import React, { useContext, useMemo } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\nimport { mergeRefs } from '@elliemae/ds-system';\nimport { useGetGlobalAttributes } from '@elliemae/ds-props-helpers';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids.js';\nimport {\n StyledInput,\n StyledInputWrapper,\n StyledInputPlaceHolder,\n StyledInputWidthReference,\n StyledHiddenDiv,\n StyleHiddenInput,\n} from './styled.js';\nimport { useKeyboardNavigation } from './useKeyboardNavigation.js';\nimport { useControlsInput } from './useControlsInput.js';\nimport { ComboBoxContext } from '../../ComboBoxCTX.js';\nimport { isArrayOfItems } from '../../utils/listHelper.js';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: {\n autoFocus,\n inline,\n selectedValues,\n placeholder,\n disabled,\n innerRef,\n isLoading,\n onlySelectable,\n applyAriaDisabled,\n readOnly,\n ...restProps\n },\n focusOptionIdx,\n hasFocus,\n internalRef,\n inputValue,\n setInputValue,\n menuState,\n instanceUid,\n } = useContext(ComboBoxContext);\n const { onInputKeyDown } = useKeyboardNavigation();\n const { spanReference, width, spanReferenceText, showPlaceholder, handleOnBlur, handleOnChange, handleOnFocus } =\n useControlsInput();\n\n const {\n tabIndex,\n id,\n 'aria-describedby': ariaDescribedBy,\n ...globalAttrs\n } = useGetGlobalAttributes(restProps, {\n onFocus: handleOnFocus,\n onBlur: handleOnBlur,\n });\n\n const actualAriaDescribedBy = useMemo(() => {\n if (id) {\n return `${ariaDescribedBy ?? ''} ${id}_current_placeholder ${id}_feedback_message ${id}_error_message`;\n }\n return ariaDescribedBy;\n }, [ariaDescribedBy, id]);\n\n const currentPlaceholder = useMemo(() => {\n if (isArrayOfItems(selectedValues)) {\n return `options ${selectedValues.map((item) => item.label).join(', ')} selected. ${readOnly ? 'Read only' : ''}`;\n }\n if (typeof selectedValues?.label === 'string') {\n return `option ${selectedValues.label} selected. ${readOnly ? 'Read only' : ''}`;\n }\n if (readOnly) {\n return `${placeholder}. Read only`;\n }\n return placeholder;\n }, [placeholder, selectedValues, readOnly]);\n\n const activeDescendant = useMemo(() => {\n if (!isLoading && hasFocus && menuState) {\n return focusOptionIdx;\n }\n return undefined;\n }, [focusOptionIdx, hasFocus, isLoading, menuState]);\n\n const handleOnPaste = (e: React.ClipboardEvent<HTMLInputElement>) => {\n e.preventDefault();\n setInputValue(e.clipboardData.getData('text/plain'));\n internalRef.current?.focus();\n };\n return (\n <StyledInputWrapper>\n <StyledInputWidthReference innerRef={spanReference}>{spanReferenceText}</StyledInputWidthReference>\n {showPlaceholder && (\n <StyledInputPlaceHolder aria-hidden=\"true\">\n <SimpleTruncatedTooltipText value={showPlaceholder}></SimpleTruncatedTooltipText>\n </StyledInputPlaceHolder>\n )}\n\n {/* The purpose of this div is to always have the 'combo-listbox-{uid}' present in the DOM */}\n {/* Fix for PUI-11597 */}\n {menuState === false && !inline ? <StyledHiddenDiv id={`combo-listbox-${instanceUid}`}></StyledHiddenDiv> : null}\n\n {/* The announcement of currentPlaceholder is being overridden by the value of actualAriaDescribedBy */}\n {/* and since this variable is necessary for the annoucement of FormLayoutBlockItem error and feedback */}\n {/* messages, we concatenate the value of actualPlaceholder with that aria description */}\n {/* Fix for PUI-9609 */}\n <StyledHiddenDiv id={`${id}_current_placeholder`}>{currentPlaceholder}</StyledHiddenDiv>\n\n <StyledInput\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n readOnly={readOnly || onlySelectable}\n {...globalAttrs}\n id={id}\n data-testid={ComboboxDataTestid.INPUT}\n autoFocus={autoFocus}\n placeholder={currentPlaceholder}\n aria-activedescendant={activeDescendant}\n aria-expanded={menuState}\n aria-controls={`combo-listbox-${instanceUid}`}\n aria-describedby={actualAriaDescribedBy}\n aria-autocomplete=\"list\"\n role=\"combobox\"\n disabled={disabled}\n applyAriaDisabled={applyAriaDisabled}\n style={{ width }}\n innerRef={mergeRefs(innerRef, internalRef)}\n value={inputValue}\n type=\"text\"\n onKeyDown={onInputKeyDown}\n onChange={handleOnChange}\n tabIndex={tabIndex}\n withoutCaret={onlySelectable}\n autoComplete=\"off\"\n aria-readonly={readOnly}\n />\n {/* This input is used to handle the paste event */}\n <StyleHiddenInput type=\"text\" name=\"hidden\" tabIndex={-1} onPaste={handleOnPaste} aria-hidden=\"true\" />\n </StyledInputWrapper>\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADwFnB;AAxFJ,mBAA2C;AAC3C,uCAA2C;AAC3C,uBAA0B;AAC1B,8BAAuC;AACvC,iCAAmC;AACnC,oBAOO;AACP,mCAAsC;AACtC,8BAAiC;AACjC,yBAAgC;AAChC,wBAA+B;AAExB,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;A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;AACnE,MAAE,eAAe;AACjB,kBAAc,EAAE,cAAc,QAAQ,YAAY,CAAC;AACnD,gBAAY,SAAS,MAAM;AAAA,EAC7B;AACA,SACE,6CAAC,oCACC;AAAA,gDAAC,2CAA0B,UAAU,eAAgB,6BAAkB;AAAA,IACtE,mBACC,4CAAC,wCAAuB,eAAY,QAClC,sDAAC,+DAA2B,OAAO,iBAAiB,GACtD;AAAA,IAKD,cAAc,SAAS,CAAC,SAAS,4CAAC,iCAAgB,IAAI,iBAAiB,WAAW,IAAI,IAAqB;AAAA,IAM5G,4CAAC,iCAAgB,IAAI,GAAG,EAAE,wBAAyB,8BAAmB;AAAA,IAEtE;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,UAAU,YAAY;AAAA,QACrB,GAAG;AAAA,QACJ;AAAA,QACA,eAAa,8CAAmB;AAAA,QAChC;AAAA,QACA,aAAa;AAAA,QACb,yBAAuB;AAAA,QACvB,iBAAe;AAAA,QACf,iBAAe,iBAAiB,WAAW;AAAA,QAC3C,oBAAkB;AAAA,QAClB,qBAAkB;AAAA,QAClB,MAAK;AAAA,QACL;AAAA,QACA;AAAA,QACA,OAAO,EAAE,MAAM;AAAA,QACf,cAAU,4BAAU,UAAU,WAAW;AAAA,QACzC,OAAO;AAAA,QACP,MAAK;AAAA,QACL,WAAW;AAAA,QACX,UAAU;AAAA,QACV;AAAA,QACA,cAAc;AAAA,QACd,cAAa;AAAA,QACb,iBAAe;AAAA;AAAA,IACjB;AAAA,IAEA,4CAAC,kCAAiB,MAAK,QAAO,MAAK,UAAS,UAAU,IAAI,SAAS,eAAe,eAAY,QAAO;AAAA,KACvG;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -36,7 +36,7 @@ var import_react = require("react");
36
36
  var import_ComboBoxCTX = require("../../ComboBoxCTX.js");
37
37
  var import_listHelper = require("../../utils/listHelper.js");
38
38
  var import_constants = require("../../constants.js");
39
- const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type) && !opt.disabled;
39
+ const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
40
40
  const optionHasFirstLetter = (opt, letter) => opt.label !== void 0 && opt.label.toLowerCase().startsWith(letter.toLowerCase());
41
41
  const useKeyboardNavigation = () => {
42
42
  const {
@@ -53,15 +53,14 @@ const useKeyboardNavigation = () => {
53
53
  selectedValues,
54
54
  withoutPortal,
55
55
  onlySelectable,
56
- applyAriaDisabled
56
+ applyAriaDisabled,
57
+ readOnly
57
58
  },
58
59
  inputValue,
59
60
  correctOptions: filteredOptions,
60
61
  menuState,
61
62
  focusOptionIdx,
62
63
  listRef,
63
- selectAllCheckboxRef,
64
- toggleSelectionButtonRef,
65
64
  setMenuState,
66
65
  setInputValue,
67
66
  scrollOptionIntoView,
@@ -118,7 +117,7 @@ const useKeyboardNavigation = () => {
118
117
  if (e.key === "ArrowDown") {
119
118
  e.preventDefault();
120
119
  e.stopPropagation();
121
- if ((menuState || inline) && selectableOptions.length) {
120
+ if ((menuState || inline) && (selectableOptions.length || onCreate)) {
122
121
  const nextItemIndexIndex = (0, import_listHelper.findInCircularList)(filteredOptions, currentItemIndex, isOptionFocuseable);
123
122
  if (nextItemIndexIndex > -1) {
124
123
  setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);
@@ -129,8 +128,13 @@ const useKeyboardNavigation = () => {
129
128
  if (e.key === "ArrowUp") {
130
129
  e.preventDefault();
131
130
  e.stopPropagation();
132
- if (!selectableOptions.length) return;
133
- const prevItemIndex = (0, import_listHelper.findInCircularList)(filteredOptions, currentItemIndex, isOptionFocuseable, -1);
131
+ if (!selectableOptions.length && !onCreate) return;
132
+ const prevItemIndex = (0, import_listHelper.findInCircularList)(
133
+ filteredOptions,
134
+ currentItemIndex === -1 ? 0 : currentItemIndex,
135
+ isOptionFocuseable,
136
+ -1
137
+ );
134
138
  if (prevItemIndex > -1) {
135
139
  if (menuState || inline) {
136
140
  setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
@@ -146,19 +150,14 @@ const useKeyboardNavigation = () => {
146
150
  }
147
151
  }
148
152
  if (e.key === "Backspace" && e.currentTarget.value.length <= 0 && !inline) {
153
+ if (readOnly) return;
149
154
  const lastValue = (0, import_listHelper.getLastValueSelected)(selectedValues);
150
155
  if (!e.currentTarget.value && lastValue && !isNonClearable && !lastValue.applyAriaDisabled) {
151
156
  onChange((0, import_listHelper.getSuggestedValueOnChange)(lastValue, selectedValues), lastValue, e);
152
157
  }
153
158
  }
154
159
  if (e.key === "Tab" && !inline && menuState) {
155
- const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;
156
- if (element) {
157
- e.preventDefault();
158
- element.focus();
159
- } else {
160
- setMenuState(false, import_constants.MENU_CONTROL_REASONS.BLUR, e);
161
- }
160
+ setMenuState(false, import_constants.MENU_CONTROL_REASONS.BLUR, e);
162
161
  }
163
162
  if (onlySelectable && /^[a-zA-Z\d]$/.test(e.key)) {
164
163
  if (!menuState) {
@@ -194,8 +193,6 @@ const useKeyboardNavigation = () => {
194
193
  setFocusOptionIdx,
195
194
  selectedValues,
196
195
  onChange,
197
- selectAllCheckboxRef,
198
- toggleSelectionButtonRef,
199
196
  isNonClearable
200
197
  ]
201
198
  );