@elliemae/ds-form-combobox 3.50.1-next.9 → 3.51.0-beta.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.
- package/dist/cjs/ComboBoxCTX.js +4 -6
- package/dist/cjs/ComboBoxCTX.js.map +2 -2
- package/dist/cjs/ComboboxDataTestids.js +0 -4
- package/dist/cjs/ComboboxDataTestids.js.map +2 -2
- package/dist/cjs/{parts/header-list/index.js → config/useClickOutside.js} +22 -6
- package/dist/cjs/config/useClickOutside.js.map +7 -0
- package/dist/cjs/config/useComboBox.js +29 -42
- package/dist/cjs/config/useComboBox.js.map +2 -2
- package/dist/cjs/config/useCorrectOptions.js +3 -6
- package/dist/cjs/config/useCorrectOptions.js.map +2 -2
- package/dist/cjs/config/useOptionsPerSection.js +56 -0
- package/dist/cjs/config/useOptionsPerSection.js.map +7 -0
- package/dist/cjs/parts/Section.js +92 -0
- package/dist/cjs/parts/Section.js.map +7 -0
- package/dist/cjs/parts/container/Container.js +29 -14
- package/dist/cjs/parts/container/Container.js.map +2 -2
- package/dist/cjs/parts/controls/Controls.js +6 -4
- package/dist/cjs/parts/controls/Controls.js.map +2 -2
- package/dist/cjs/parts/controls/styled.js +21 -5
- package/dist/cjs/parts/controls/styled.js.map +2 -2
- package/dist/cjs/parts/controls/useOnPillsNavigation.js +3 -3
- package/dist/cjs/parts/controls/useOnPillsNavigation.js.map +2 -2
- package/dist/cjs/parts/controls-input/ControlsInput.js +21 -6
- package/dist/cjs/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/cjs/parts/controls-input/styled.js +3 -1
- package/dist/cjs/parts/controls-input/styled.js.map +2 -2
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js +17 -20
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js +4 -5
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/cjs/parts/menu-list/MenuList.js +20 -35
- package/dist/cjs/parts/menu-list/MenuList.js.map +2 -2
- package/dist/cjs/parts/menu-list/styled.js.map +2 -2
- package/dist/cjs/parts/menu-list/useItemRenderer.js +59 -40
- package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js +10 -2
- package/dist/cjs/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +3 -1
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/sharedTypes.js.map +2 -2
- package/dist/cjs/utils/listHelper.js +7 -23
- package/dist/cjs/utils/listHelper.js.map +2 -2
- package/dist/esm/ComboBoxCTX.js +4 -6
- package/dist/esm/ComboBoxCTX.js.map +2 -2
- package/dist/esm/ComboboxDataTestids.js +0 -4
- package/dist/esm/ComboboxDataTestids.js.map +2 -2
- package/dist/esm/config/useClickOutside.js +22 -0
- package/dist/esm/config/useClickOutside.js.map +7 -0
- package/dist/esm/config/useComboBox.js +30 -43
- package/dist/esm/config/useComboBox.js.map +2 -2
- package/dist/esm/config/useCorrectOptions.js +4 -7
- package/dist/esm/config/useCorrectOptions.js.map +2 -2
- package/dist/esm/config/useOptionsPerSection.js +26 -0
- package/dist/esm/config/useOptionsPerSection.js.map +7 -0
- package/dist/esm/parts/Section.js +62 -0
- package/dist/esm/parts/Section.js.map +7 -0
- package/dist/esm/parts/container/Container.js +30 -15
- package/dist/esm/parts/container/Container.js.map +2 -2
- package/dist/esm/parts/controls/Controls.js +6 -4
- package/dist/esm/parts/controls/Controls.js.map +2 -2
- package/dist/esm/parts/controls/styled.js +21 -5
- package/dist/esm/parts/controls/styled.js.map +2 -2
- package/dist/esm/parts/controls/useOnPillsNavigation.js +3 -3
- package/dist/esm/parts/controls/useOnPillsNavigation.js.map +2 -2
- package/dist/esm/parts/controls-input/ControlsInput.js +21 -6
- package/dist/esm/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/esm/parts/controls-input/styled.js +3 -1
- package/dist/esm/parts/controls-input/styled.js.map +2 -2
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js +17 -20
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/parts/controls-input/useMaskedOnChange.js +4 -5
- package/dist/esm/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/esm/parts/menu-list/MenuList.js +21 -36
- package/dist/esm/parts/menu-list/MenuList.js.map +2 -2
- package/dist/esm/parts/menu-list/styled.js.map +2 -2
- package/dist/esm/parts/menu-list/useItemRenderer.js +61 -42
- package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js +10 -2
- package/dist/esm/parts/multi-selected-values-container/RemovableSelectedValuePill.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +3 -1
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/sharedTypes.js.map +2 -2
- package/dist/esm/utils/listHelper.js +7 -23
- package/dist/esm/utils/listHelper.js.map +2 -2
- package/dist/types/ComboboxDataTestids.d.ts +0 -4
- package/dist/types/config/useClickOutside.d.ts +1 -0
- package/dist/types/config/useCorrectOptions.d.ts +1 -1
- package/dist/types/config/useOptionsPerSection.d.ts +2 -0
- package/dist/types/parts/DropdownIndicator.d.ts +1 -0
- package/dist/types/parts/Section.d.ts +14 -0
- package/dist/types/parts/container/Container.d.ts +1 -0
- package/dist/types/parts/controls/Controls.d.ts +1 -0
- package/dist/types/parts/controls/styled.d.ts +2 -0
- package/dist/types/parts/controls-input/ControlsInput.d.ts +1 -0
- package/dist/types/parts/controls-input/styled.d.ts +3 -1
- package/dist/types/parts/menu-list/MenuList.d.ts +1 -0
- package/dist/types/parts/menu-list/SkeletonContainer.d.ts +1 -0
- package/dist/types/parts/menu-list/styled.d.ts +0 -1
- package/dist/types/parts/menu-list/useItemRenderer.d.ts +1 -0
- package/dist/types/parts/multi-selected-values-container/MultiSelectedValuesContainer.d.ts +1 -0
- package/dist/types/react-desc-prop-types.d.ts +4 -1
- package/dist/types/sharedTypes.d.ts +1 -4
- package/dist/types/tests/read-only.test.d.ts +1 -0
- package/dist/types/utils/listHelper.d.ts +0 -1
- package/package.json +19 -19
- package/dist/cjs/parts/header-list/HeaderList.js +0 -104
- package/dist/cjs/parts/header-list/HeaderList.js.map +0 -7
- package/dist/cjs/parts/header-list/index.js.map +0 -7
- package/dist/cjs/parts/header-list/styled.js +0 -85
- package/dist/cjs/parts/header-list/styled.js.map +0 -7
- package/dist/cjs/parts/header-list/useHeaderListHandlers.js +0 -140
- package/dist/cjs/parts/header-list/useHeaderListHandlers.js.map +0 -7
- package/dist/esm/parts/header-list/HeaderList.js +0 -80
- package/dist/esm/parts/header-list/HeaderList.js.map +0 -7
- package/dist/esm/parts/header-list/index.js +0 -6
- package/dist/esm/parts/header-list/index.js.map +0 -7
- package/dist/esm/parts/header-list/styled.js +0 -55
- package/dist/esm/parts/header-list/styled.js.map +0 -7
- package/dist/esm/parts/header-list/useHeaderListHandlers.js +0 -110
- package/dist/esm/parts/header-list/useHeaderListHandlers.js.map +0 -7
- package/dist/types/parts/header-list/HeaderList.d.ts +0 -1
- package/dist/types/parts/header-list/index.d.ts +0 -1
- package/dist/types/parts/header-list/styled.d.ts +0 -6
- package/dist/types/parts/header-list/useHeaderListHandlers.d.ts +0 -11
package/dist/cjs/ComboBoxCTX.js
CHANGED
|
@@ -52,7 +52,8 @@ const defaultProps = {
|
|
|
52
52
|
onlySelectable: false,
|
|
53
53
|
isSkeleton: false,
|
|
54
54
|
// override in useCombobox to avoid ref duplications when more than one cb is used
|
|
55
|
-
applyAriaDisabled: false
|
|
55
|
+
applyAriaDisabled: false,
|
|
56
|
+
readOnly: false
|
|
56
57
|
};
|
|
57
58
|
const defaultContext = {
|
|
58
59
|
props: defaultProps,
|
|
@@ -61,25 +62,22 @@ const defaultContext = {
|
|
|
61
62
|
referenceElement: null,
|
|
62
63
|
inputValue: "",
|
|
63
64
|
focusOptionIdx: "",
|
|
64
|
-
showSelectedOptions: false,
|
|
65
65
|
pillGroupRef: (0, import_react.createRef)(),
|
|
66
66
|
listRef: (0, import_react.createRef)(),
|
|
67
67
|
wrapperListRef: (0, import_react.createRef)(),
|
|
68
68
|
controlsWrapperRef: (0, import_react.createRef)(),
|
|
69
69
|
selectedOptionsRef: (0, import_react.createRef)(),
|
|
70
|
-
selectAllCheckboxRef: (0, import_react.createRef)(),
|
|
71
|
-
toggleSelectionButtonRef: (0, import_react.createRef)(),
|
|
72
70
|
setShowPopover: noop,
|
|
73
71
|
scrollOptionIntoView: noop,
|
|
74
72
|
setHasFocus: noop,
|
|
75
73
|
setInputValue: noop,
|
|
76
74
|
setReferenceElement: noop,
|
|
77
75
|
setFocusOptionIdx: noop,
|
|
78
|
-
setShowSelectedOptions: noop,
|
|
79
76
|
setMenuState: noop,
|
|
80
77
|
internalRef: (0, import_react.createRef)(),
|
|
81
78
|
correctOptions: [],
|
|
82
|
-
instanceUid: ""
|
|
79
|
+
instanceUid: "",
|
|
80
|
+
optionsPerSection: []
|
|
83
81
|
};
|
|
84
82
|
const ComboBoxContext = (0, import_react.createContext)(defaultContext);
|
|
85
83
|
var ComboBoxCTX_default = ComboBoxContext;
|
|
@@ -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
|
|
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;
|
|
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 readOnly: 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 optionsPerSection: [],\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;AAAA,EACnB,UAAU;AACZ;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;AAAA,EACb,mBAAmB,CAAC;AACtB;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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,qBAAqB;AAAA,EAChC,
|
|
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
|
|
30
|
-
__export(
|
|
31
|
-
|
|
29
|
+
var useClickOutside_exports = {};
|
|
30
|
+
__export(useClickOutside_exports, {
|
|
31
|
+
useOnClickOutside: () => useOnClickOutside
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(useClickOutside_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
|
-
var
|
|
36
|
-
|
|
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
|
+
}
|
|
@@ -32,22 +32,21 @@ __export(useComboBox_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(useComboBox_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
35
36
|
var import_react = require("react");
|
|
36
37
|
var import_react_virtual = require("react-virtual");
|
|
37
38
|
var import_uid = require("uid");
|
|
38
|
-
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
39
39
|
var import_ComboBoxCTX = require("../ComboBoxCTX.js");
|
|
40
40
|
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
|
41
|
-
var import_useCorrectOptions = require("./useCorrectOptions.js");
|
|
42
|
-
var import_listHelper = require("../utils/listHelper.js");
|
|
43
41
|
var import_theming = require("../theming.js");
|
|
44
|
-
var
|
|
42
|
+
var import_listHelper = require("../utils/listHelper.js");
|
|
43
|
+
var import_useCorrectOptions = require("./useCorrectOptions.js");
|
|
44
|
+
var import_useOptionsPerSection = require("./useOptionsPerSection.js");
|
|
45
45
|
const useComboBox = (props) => {
|
|
46
46
|
const propsWithDefaults = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, import_ComboBoxCTX.defaultProps);
|
|
47
47
|
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefaults, import_react_desc_prop_types.ComboboxPropTypes, import_theming.DSComboBoxName);
|
|
48
48
|
const [showPopover, setShowPopover] = (0, import_react.useState)(false);
|
|
49
49
|
const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
|
|
50
|
-
const [showSelectedOptions, setShowSelectedOptions] = (0, import_react.useState)(false);
|
|
51
50
|
const [inputValue, setInputValue] = (0, import_react.useState)("");
|
|
52
51
|
const [hasFocus, setHasFocus] = (0, import_react.useState)(false);
|
|
53
52
|
const internalRef = (0, import_react.useRef)(null);
|
|
@@ -55,8 +54,6 @@ const useComboBox = (props) => {
|
|
|
55
54
|
const wrapperListRef = (0, import_react.useRef)(null);
|
|
56
55
|
const selectedOptionsRef = (0, import_react.useRef)(null);
|
|
57
56
|
const controlsWrapperRef = (0, import_react.useRef)(null);
|
|
58
|
-
const selectAllCheckboxRef = (0, import_react.useRef)(null);
|
|
59
|
-
const toggleSelectionButtonRef = (0, import_react.useRef)(null);
|
|
60
57
|
const pillGroupRef = (0, import_react.useRef)(null);
|
|
61
58
|
const { id, selectedValues, isMenuOpen, onMenuChange, applyAriaDisabled } = propsWithDefaults;
|
|
62
59
|
const instanceUid = (0, import_react.useMemo)(() => id || (0, import_uid.uid)(5), [id]);
|
|
@@ -64,17 +61,10 @@ const useComboBox = (props) => {
|
|
|
64
61
|
if (isMenuOpen !== void 0) return isMenuOpen;
|
|
65
62
|
return showPopover;
|
|
66
63
|
}, [showPopover, isMenuOpen]);
|
|
67
|
-
const
|
|
68
|
-
|
|
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);
|
|
64
|
+
const correctOptions = (0, import_useCorrectOptions.useCorrectOptions)(propsWithDefaults, inputValue);
|
|
65
|
+
const optionsPerSection = (0, import_useOptionsPerSection.useOptionsPerSection)(correctOptions);
|
|
76
66
|
const virtualListHelpers = (0, import_react_virtual.useVirtual)({
|
|
77
|
-
size:
|
|
67
|
+
size: optionsPerSection.length,
|
|
78
68
|
parentRef: listRef,
|
|
79
69
|
overscan: 15,
|
|
80
70
|
paddingStart: 0
|
|
@@ -89,24 +79,26 @@ const useComboBox = (props) => {
|
|
|
89
79
|
[correctOptions, virtualListHelpers]
|
|
90
80
|
);
|
|
91
81
|
const [focusOptionIdx, setFocusOptionIdx] = (0, import_react.useState)("");
|
|
82
|
+
const setMenuState = (0, import_react.useCallback)(
|
|
83
|
+
(newState, reason, e) => {
|
|
84
|
+
if (applyAriaDisabled) return;
|
|
85
|
+
if (onMenuChange !== void 0) onMenuChange(newState, reason, e);
|
|
86
|
+
setShowPopover(newState);
|
|
87
|
+
if (!inputValue && newState && !focusOptionIdx && !(0, import_listHelper.isSelectedValueEmpty)(selectedValues)) {
|
|
88
|
+
const focusedValue = (0, import_listHelper.getFirstOption)(correctOptions, selectedValues);
|
|
89
|
+
setFocusOptionIdx(focusedValue);
|
|
90
|
+
scrollOptionIntoView(focusedValue, { align: "center" });
|
|
91
|
+
} else {
|
|
92
|
+
setFocusOptionIdx("");
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[applyAriaDisabled, onMenuChange, inputValue, focusOptionIdx, selectedValues, correctOptions, scrollOptionIntoView]
|
|
96
|
+
);
|
|
92
97
|
(0, import_react.useEffect)(() => {
|
|
93
|
-
if (
|
|
94
|
-
|
|
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);
|
|
98
|
+
if (propsWithDefaults.inline) {
|
|
99
|
+
setMenuState(true, "inline");
|
|
108
100
|
}
|
|
109
|
-
}, [
|
|
101
|
+
}, []);
|
|
110
102
|
const ctx = (0, import_react.useMemo)(
|
|
111
103
|
() => ({
|
|
112
104
|
props: { ...propsWithDefaults },
|
|
@@ -117,16 +109,12 @@ const useComboBox = (props) => {
|
|
|
117
109
|
focusOptionIdx,
|
|
118
110
|
selectedOptionsRef,
|
|
119
111
|
controlsWrapperRef,
|
|
120
|
-
selectAllCheckboxRef,
|
|
121
112
|
inputValue,
|
|
122
113
|
setInputValue,
|
|
123
114
|
setMenuState,
|
|
124
115
|
hasFocus,
|
|
125
|
-
toggleSelectionButtonRef,
|
|
126
116
|
pillGroupRef,
|
|
127
|
-
showSelectedOptions,
|
|
128
117
|
wrapperListRef,
|
|
129
|
-
setShowSelectedOptions,
|
|
130
118
|
setHasFocus,
|
|
131
119
|
setFocusOptionIdx,
|
|
132
120
|
scrollOptionIntoView,
|
|
@@ -134,7 +122,8 @@ const useComboBox = (props) => {
|
|
|
134
122
|
setShowPopover,
|
|
135
123
|
internalRef,
|
|
136
124
|
correctOptions,
|
|
137
|
-
instanceUid
|
|
125
|
+
instanceUid,
|
|
126
|
+
optionsPerSection
|
|
138
127
|
}),
|
|
139
128
|
[
|
|
140
129
|
scrollOptionIntoView,
|
|
@@ -146,17 +135,15 @@ const useComboBox = (props) => {
|
|
|
146
135
|
inputValue,
|
|
147
136
|
focusOptionIdx,
|
|
148
137
|
wrapperListRef,
|
|
149
|
-
showSelectedOptions,
|
|
150
138
|
menuState,
|
|
151
139
|
pillGroupRef,
|
|
152
140
|
referenceElement,
|
|
153
141
|
selectedOptionsRef,
|
|
154
142
|
controlsWrapperRef,
|
|
155
|
-
selectAllCheckboxRef,
|
|
156
|
-
toggleSelectionButtonRef,
|
|
157
143
|
listRef,
|
|
158
144
|
internalRef,
|
|
159
|
-
instanceUid
|
|
145
|
+
instanceUid,
|
|
146
|
+
optionsPerSection
|
|
160
147
|
]
|
|
161
148
|
);
|
|
162
149
|
return ctx;
|
|
@@ -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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAkE;AAClE,2BAAsD;AACtD,iBAAoB;AACpB,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useVirtual, type ScrollToIndexOptions } from 'react-virtual';\nimport { uid } from 'uid';\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 { DSComboBoxName } from '../theming.js';\nimport { getFirstOption, isSelectedValueEmpty } from '../utils/listHelper.js';\nimport { useCorrectOptions } from './useCorrectOptions.js';\nimport { useOptionsPerSection } from './useOptionsPerSection.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 // ---------------------------------------------------------------------------\n // Options with creatable option + filtered by selected\n // ---------------------------------------------------------------------------\n\n const correctOptions = useCorrectOptions(propsWithDefaults, inputValue);\n\n const optionsPerSection = useOptionsPerSection(correctOptions);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: optionsPerSection.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 optionsPerSection,\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 optionsPerSection,\n ],\n );\n\n return ctx;\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
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
|
|
40
|
-
const { filteredOptions, allOptions,
|
|
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,
|
|
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 {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAwB;AACxB,iBAAoB;AAEpB,uBAAkC;AAClC,
|
|
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
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useOptionsPerSection_exports = {};
|
|
30
|
+
__export(useOptionsPerSection_exports, {
|
|
31
|
+
useOptionsPerSection: () => useOptionsPerSection
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useOptionsPerSection_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = require("react");
|
|
36
|
+
const useOptionsPerSection = (correctOptions) => (0, import_react.useMemo)(() => {
|
|
37
|
+
const result = [];
|
|
38
|
+
let currentSection = null;
|
|
39
|
+
correctOptions.forEach((item) => {
|
|
40
|
+
if (item.type === "section") {
|
|
41
|
+
currentSection = {
|
|
42
|
+
dsId: item.dsId,
|
|
43
|
+
type: item.type,
|
|
44
|
+
label: item.label,
|
|
45
|
+
options: []
|
|
46
|
+
};
|
|
47
|
+
result.push(currentSection);
|
|
48
|
+
} else if ((item.type === "option" || item.type === "separator") && currentSection) {
|
|
49
|
+
currentSection.options.push(item);
|
|
50
|
+
} else if (item.type === "option" || item.type === "creatable" || item.type === "separator") {
|
|
51
|
+
result.push(item);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
return result;
|
|
55
|
+
}, [correctOptions]);
|
|
56
|
+
//# sourceMappingURL=useOptionsPerSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useOptionsPerSection.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\n\nexport const useOptionsPerSection = (correctOptions: DSComboboxT.OptionTypes[]) =>\n useMemo(() => {\n const result: DSComboboxT.OptionTypes[] = [];\n let currentSection: DSComboboxT.ItemSectionOptions | null = null;\n\n correctOptions.forEach((item) => {\n if (item.type === 'section') {\n // Start a new section\n currentSection = {\n dsId: item.dsId,\n type: item.type,\n label: item.label,\n options: [],\n };\n result.push(currentSection);\n } else if ((item.type === 'option' || item.type === 'separator') && currentSection) {\n // Add option to the current section's options array\n currentSection.options.push(item);\n } else if (item.type === 'option' || item.type === 'creatable' || item.type === 'separator') {\n // If we encounter an option without a section, push it to the result array\n result.push(item);\n }\n });\n return result;\n }, [correctOptions]);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AAGjB,MAAM,uBAAuB,CAAC,uBACnC,sBAAQ,MAAM;AACZ,QAAM,SAAoC,CAAC;AAC3C,MAAI,iBAAwD;AAE5D,iBAAe,QAAQ,CAAC,SAAS;AAC/B,QAAI,KAAK,SAAS,WAAW;AAE3B,uBAAiB;AAAA,QACf,MAAM,KAAK;AAAA,QACX,MAAM,KAAK;AAAA,QACX,OAAO,KAAK;AAAA,QACZ,SAAS,CAAC;AAAA,MACZ;AACA,aAAO,KAAK,cAAc;AAAA,IAC5B,YAAY,KAAK,SAAS,YAAY,KAAK,SAAS,gBAAgB,gBAAgB;AAElF,qBAAe,QAAQ,KAAK,IAAI;AAAA,IAClC,WAAW,KAAK,SAAS,YAAY,KAAK,SAAS,eAAe,KAAK,SAAS,aAAa;AAE3F,aAAO,KAAK,IAAI;AAAA,IAClB;AAAA,EACF,CAAC;AACD,SAAO;AACT,GAAG,CAAC,cAAc,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Section_exports = {};
|
|
30
|
+
__export(Section_exports, {
|
|
31
|
+
Section: () => Section
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(Section_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = require("react");
|
|
37
|
+
var import_react2 = __toESM(require("react"));
|
|
38
|
+
var import_ds_system = require("@elliemae/ds-system");
|
|
39
|
+
var import_ds_menu_items = require("@elliemae/ds-menu-items");
|
|
40
|
+
var import_constants = require("../constants.js");
|
|
41
|
+
var import_ComboboxDataTestids = require("../ComboboxDataTestids.js");
|
|
42
|
+
var import_listHelper = require("../utils/listHelper.js");
|
|
43
|
+
const StyledSectionWrapper = (0, import_ds_system.styled)("section")`
|
|
44
|
+
list-style: none;
|
|
45
|
+
min-height: 24px;
|
|
46
|
+
display: grid;
|
|
47
|
+
align-items: center;
|
|
48
|
+
`;
|
|
49
|
+
const StyledSectionLabel = (0, import_ds_system.styled)("header")`
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
padding: 0px 16px;
|
|
53
|
+
min-height: 24px;
|
|
54
|
+
font-size: 1rem;
|
|
55
|
+
color: neutral-500;
|
|
56
|
+
`;
|
|
57
|
+
const Section = import_react2.default.memo((props) => {
|
|
58
|
+
const { label, wrapperStyles, focusOptionIdx, selectedValues, innerRef, handleOnMouseDown, options, handleClick } = props;
|
|
59
|
+
const id = `${label.replace(/ /g, "")}-section`;
|
|
60
|
+
const CBItem = Array.isArray(selectedValues) ? import_ds_menu_items.MultiMenuItem : import_ds_menu_items.SingleMenuItem;
|
|
61
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(StyledSectionWrapper, { role: "group", "aria-labelledby": id, style: wrapperStyles, innerRef, children: [
|
|
62
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledSectionLabel, { id, role: "presentation", children: label }),
|
|
63
|
+
options?.map((option) => {
|
|
64
|
+
const { dsId, type, value, label: optionLabel, readOnly, disabled, applyAriaDisabled, ...rest } = option;
|
|
65
|
+
if (type === import_constants.MENU_OPTION_TYPES.SEPARATOR) {
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ds_menu_items.Separator, {}, dsId);
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ (0, import_react.createElement)(
|
|
69
|
+
CBItem,
|
|
70
|
+
{
|
|
71
|
+
value,
|
|
72
|
+
label: optionLabel,
|
|
73
|
+
dataTestid: import_ComboboxDataTestids.ComboboxDataTestid.OPTION,
|
|
74
|
+
disabled,
|
|
75
|
+
applyAriaDisabled: applyAriaDisabled || readOnly,
|
|
76
|
+
onClick: (e) => {
|
|
77
|
+
if (applyAriaDisabled) return;
|
|
78
|
+
handleClick(option, e);
|
|
79
|
+
},
|
|
80
|
+
onMouseDown: handleOnMouseDown,
|
|
81
|
+
isActive: dsId === focusOptionIdx,
|
|
82
|
+
isSelected: (0, import_listHelper.isSelected)(selectedValues, option),
|
|
83
|
+
tabIndex: -1,
|
|
84
|
+
...rest,
|
|
85
|
+
key: option.dsId,
|
|
86
|
+
dsId: option.dsId
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
})
|
|
90
|
+
] });
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=Section.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/parts/Section.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { SingleMenuItem, MultiMenuItem, Separator } from '@elliemae/ds-menu-items';\nimport { MENU_OPTION_TYPES } from '../constants.js';\n\nimport { ComboboxDataTestid } from '../ComboboxDataTestids.js';\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { isSelected } from '../utils/listHelper.js';\n\ninterface SectionProps {\n label: string;\n wrapperStyles: React.CSSProperties;\n innerRef: (instance: HTMLDivElement | null) => void;\n options: DSComboboxT.ItemOption[] | DSComboboxT.ItemSeparatorOptions[];\n handleClick: (option: DSComboboxT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => void;\n handleOnMouseDown: (e: React.MouseEvent<HTMLLIElement>) => void;\n focusOptionIdx: string;\n selectedValues: DSComboboxT.SelectedOptionsT;\n}\n\nconst StyledSectionWrapper = styled('section')`\n list-style: none;\n min-height: 24px;\n display: grid;\n align-items: center;\n`;\n\nconst StyledSectionLabel = styled('header')`\n display: flex;\n align-items: center;\n padding: 0px 16px;\n min-height: 24px;\n font-size: 1rem;\n color: neutral-500;\n`;\n\nexport const Section = React.memo((props: SectionProps) => {\n const { label, wrapperStyles, focusOptionIdx, selectedValues, innerRef, handleOnMouseDown, options, handleClick } =\n props;\n const id = `${label.replace(/ /g, '')}-section`;\n\n const CBItem = Array.isArray(selectedValues) ? MultiMenuItem : SingleMenuItem;\n\n return (\n <StyledSectionWrapper role=\"group\" aria-labelledby={id} style={wrapperStyles} innerRef={innerRef}>\n <StyledSectionLabel id={id} role=\"presentation\">\n {label}\n </StyledSectionLabel>\n {options?.map((option) => {\n const { dsId, type, value, label: optionLabel, readOnly, disabled, applyAriaDisabled, ...rest } = option;\n\n if (type === MENU_OPTION_TYPES.SEPARATOR) {\n return <Separator key={dsId} />;\n }\n\n return (\n <CBItem\n value={value}\n label={optionLabel}\n dataTestid={ComboboxDataTestid.OPTION}\n disabled={disabled}\n applyAriaDisabled={applyAriaDisabled || readOnly}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => {\n if (applyAriaDisabled) return;\n handleClick(option, e);\n }}\n onMouseDown={handleOnMouseDown}\n isActive={dsId === focusOptionIdx}\n isSelected={isSelected(selectedValues, option)}\n tabIndex={-1}\n {...rest}\n key={option.dsId}\n dsId={option.dsId}\n />\n );\n })}\n </StyledSectionWrapper>\n );\n});\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD4CnB;AAYM;AAxDV,IAAAA,gBAAkB;AAClB,uBAAuB;AACvB,2BAAyD;AACzD,uBAAkC;AAElC,iCAAmC;AAEnC,wBAA2B;AAa3B,MAAM,2BAAuB,yBAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAO7C,MAAM,yBAAqB,yBAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASnC,MAAM,UAAU,cAAAC,QAAM,KAAK,CAAC,UAAwB;AACzD,QAAM,EAAE,OAAO,eAAe,gBAAgB,gBAAgB,UAAU,mBAAmB,SAAS,YAAY,IAC9G;AACF,QAAM,KAAK,GAAG,MAAM,QAAQ,MAAM,EAAE,CAAC;AAErC,QAAM,SAAS,MAAM,QAAQ,cAAc,IAAI,qCAAgB;AAE/D,SACE,6CAAC,wBAAqB,MAAK,SAAQ,mBAAiB,IAAI,OAAO,eAAe,UAC5E;AAAA,gDAAC,sBAAmB,IAAQ,MAAK,gBAC9B,iBACH;AAAA,IACC,SAAS,IAAI,CAAC,WAAW;AACxB,YAAM,EAAE,MAAM,MAAM,OAAO,OAAO,aAAa,UAAU,UAAU,mBAAmB,GAAG,KAAK,IAAI;AAElG,UAAI,SAAS,mCAAkB,WAAW;AACxC,eAAO,4CAAC,oCAAe,IAAM;AAAA,MAC/B;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,OAAO;AAAA,UACP,YAAY,8CAAmB;AAAA,UAC/B;AAAA,UACA,mBAAmB,qBAAqB;AAAA,UACxC,SAAS,CAAC,MAA0C;AAClD,gBAAI,kBAAmB;AACvB,wBAAY,QAAQ,CAAC;AAAA,UACvB;AAAA,UACA,aAAa;AAAA,UACb,UAAU,SAAS;AAAA,UACnB,gBAAY,8BAAW,gBAAgB,MAAM;AAAA,UAC7C,UAAU;AAAA,UACT,GAAG;AAAA,UACJ,KAAK,OAAO;AAAA,UACZ,MAAM,OAAO;AAAA;AAAA,MACf;AAAA,IAEJ,CAAC;AAAA,KACH;AAEJ,CAAC;",
|
|
6
|
+
"names": ["import_react", "React"]
|
|
7
|
+
}
|