@elliemae/ds-form-combobox 3.50.1-next.8 → 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
|
@@ -41,8 +41,7 @@ __export(listHelper_exports, {
|
|
|
41
41
|
isSelected: () => isSelected,
|
|
42
42
|
isSelectedValueEmpty: () => isSelectedValueEmpty,
|
|
43
43
|
isSelectedValueMultiple: () => isSelectedValueMultiple,
|
|
44
|
-
scrollIfNeeded: () => scrollIfNeeded
|
|
45
|
-
selectedValuesWithSections: () => selectedValuesWithSections
|
|
44
|
+
scrollIfNeeded: () => scrollIfNeeded
|
|
46
45
|
});
|
|
47
46
|
module.exports = __toCommonJS(listHelper_exports);
|
|
48
47
|
var React = __toESM(require("react"));
|
|
@@ -64,8 +63,13 @@ function isArrayOfItems(value) {
|
|
|
64
63
|
}
|
|
65
64
|
const isItem = (value) => !Array.isArray(value) && value !== null && typeof value === "object";
|
|
66
65
|
const findInCircularList = (list, from, criteria, step = 1) => {
|
|
67
|
-
|
|
66
|
+
if (list.length === 0) return from;
|
|
67
|
+
let i = (from + step + list.length) % list.length;
|
|
68
|
+
let iterations = 0;
|
|
69
|
+
while (iterations < list.length) {
|
|
68
70
|
if (criteria(list[i])) return i;
|
|
71
|
+
i = (i + step + list.length) % list.length;
|
|
72
|
+
iterations += 1;
|
|
69
73
|
}
|
|
70
74
|
return from;
|
|
71
75
|
};
|
|
@@ -105,26 +109,6 @@ const filterOptions = (inputValue, options) => {
|
|
|
105
109
|
(option) => option.type === import_constants.MENU_OPTION_TYPES.OPTION && option.label.toLowerCase().includes(inputValue.toLowerCase())
|
|
106
110
|
);
|
|
107
111
|
};
|
|
108
|
-
const selectedValuesWithSections = (optionsToParse, multiSelectedValue) => {
|
|
109
|
-
const items = [];
|
|
110
|
-
if (optionsToParse)
|
|
111
|
-
optionsToParse.forEach((option) => {
|
|
112
|
-
if (option.type === import_constants.MENU_OPTION_TYPES.OPTION && isSelected(multiSelectedValue, option)) {
|
|
113
|
-
items.push(option);
|
|
114
|
-
}
|
|
115
|
-
if (option.type === import_constants.MENU_OPTION_TYPES.SECTION) {
|
|
116
|
-
if (items[items.length - 1]?.type === import_constants.MENU_OPTION_TYPES.SECTION) {
|
|
117
|
-
items[items.length - 1] = option;
|
|
118
|
-
} else {
|
|
119
|
-
items.push(option);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
if (items[items.length - 1]?.type === import_constants.MENU_OPTION_TYPES.SECTION) {
|
|
124
|
-
items.pop();
|
|
125
|
-
}
|
|
126
|
-
return items;
|
|
127
|
-
};
|
|
128
112
|
const getFilteredOptionsSelected = (filteredOption, selectedValues) => filteredOption.filter((option) => option.type === import_constants.MENU_OPTION_TYPES.OPTION && isSelected(selectedValues, option));
|
|
129
113
|
const scrollIfNeeded = (elem, options = { behavior: "smooth", block: "end", inline: "nearest" }) => {
|
|
130
114
|
const bounding = elem.getBoundingClientRect();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/listHelper.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-params */\nimport type { DSComboboxT } from '../react-desc-prop-types.js';\nimport { MENU_OPTION_TYPES } from '../constants.js';\nexport const getSelectableOptions = (options: Array<DSComboboxT.OptionTypes>): Array<DSComboboxT.OptionTypes> =>\n options.filter((option) => option.type === MENU_OPTION_TYPES.OPTION && !option.disabled);\n\nexport const getOptions = (options: Array<DSComboboxT.OptionTypes>): Array<DSComboboxT.OptionTypes> =>\n options.filter((option) => option.type === MENU_OPTION_TYPES.OPTION);\n\nexport const isSelectedValueEmpty = (value: DSComboboxT.SelectedOptionsT): boolean =>\n Array.isArray(value) ? value.length === 0 : !value;\n\nexport const isSelectedValueMultiple = (value: DSComboboxT.SelectedOptionsT): boolean => Array.isArray(value);\n\nexport const isSelected = (value: DSComboboxT.SelectedOptionsT, activeOption: DSComboboxT.ItemOption): boolean => {\n if (isSelectedValueMultiple(value)) {\n const multiValue = value as DSComboboxT.ItemOption[];\n return multiValue.some((item) => item?.value === activeOption?.value);\n }\n const singleValue = value as DSComboboxT.ItemOption;\n return singleValue?.value === activeOption.value;\n};\n\nexport function isArrayOfItems(value: DSComboboxT.SelectedOptionsT): value is DSComboboxT.ItemOption[] {\n return Array.isArray(value) && value.length > 0;\n}\n\nexport const isItem = (value: DSComboboxT.SelectedOptionsT): value is DSComboboxT.ItemOption =>\n !Array.isArray(value) && value !== null && typeof value === 'object';\n\nexport const findInCircularList = (\n list: DSComboboxT.OptionTypes[],\n from: number,\n criteria: (item: DSComboboxT.OptionTypes) => boolean,\n step = 1,\n): number => {\n if (list.length === 0) return from;\n\n let i = (from + step + list.length) % list.length;\n let iterations = 0;\n\n while (iterations < list.length) {\n if (criteria(list[i])) return i;\n\n i = (i + step + list.length) % list.length;\n iterations += 1;\n }\n\n return from; // Return the original index if no match is found\n};\nexport const getLastValueSelected = (selectedValues: DSComboboxT.SelectedOptionsT) => {\n if (Array.isArray(selectedValues)) {\n return selectedValues[selectedValues.length - 1];\n }\n return selectedValues;\n};\n\nexport const getFirstOption = (\n options: DSComboboxT.OptionTypes[],\n selectedValues: DSComboboxT.SelectedOptionsT,\n): string => {\n const lastValue = getLastValueSelected(selectedValues);\n if (lastValue) return lastValue.dsId;\n\n for (let i = 0; i < options.length; i += 1)\n if (!['section', 'separator'].includes(options[i].type) && !options[i].disabled) {\n return options[i].dsId;\n }\n // list of disabled item results return ''\n return '';\n};\n\nexport const getSuggestedValueOnChange = (\n selectedOption: DSComboboxT.ItemOption,\n selectedValues: DSComboboxT.SelectedOptionsT,\n isNonClearable?: boolean,\n) => {\n if (Array.isArray(selectedValues)) {\n const isFound = selectedValues.find((item) => item.type === 'option' && item.value === selectedOption.value);\n if (isFound) {\n if (isNonClearable) return selectedValues;\n return selectedValues.filter((item) => item.type === 'option' && item.value !== selectedOption.value);\n }\n return [...selectedValues, selectedOption];\n }\n if (selectedValues && selectedValues.dsId === selectedOption.dsId) {\n if (isNonClearable) return selectedOption;\n return null;\n }\n return selectedOption;\n};\n\nexport const filterOptions = (inputValue: string, options: DSComboboxT.OptionTypes[]) => {\n if (!inputValue) return options;\n return options.filter(\n (option) =>\n option.type === MENU_OPTION_TYPES.OPTION && option.label.toLowerCase().includes(inputValue.toLowerCase()),\n );\n};\n\nexport const getFilteredOptionsSelected = (\n filteredOption: DSComboboxT.OptionTypes[],\n selectedValues: DSComboboxT.ItemOption[],\n) => filteredOption.filter((option) => option.type === MENU_OPTION_TYPES.OPTION && isSelected(selectedValues, option));\n\nexport const scrollIfNeeded = (\n elem: HTMLElement,\n options = { behavior: 'smooth', block: 'end', inline: 'nearest' } as ScrollIntoViewOptions | undefined,\n) => {\n const bounding = elem.getBoundingClientRect();\n if (\n !(\n bounding.top >= 0 &&\n bounding.left >= 0 &&\n bounding.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&\n bounding.right <= (window.innerWidth || document.documentElement.clientWidth)\n )\n )\n elem.scrollIntoView(options);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ComboBoxCTX.js
CHANGED
|
@@ -16,7 +16,8 @@ const defaultProps = {
|
|
|
16
16
|
onlySelectable: false,
|
|
17
17
|
isSkeleton: false,
|
|
18
18
|
// override in useCombobox to avoid ref duplications when more than one cb is used
|
|
19
|
-
applyAriaDisabled: false
|
|
19
|
+
applyAriaDisabled: false,
|
|
20
|
+
readOnly: false
|
|
20
21
|
};
|
|
21
22
|
const defaultContext = {
|
|
22
23
|
props: defaultProps,
|
|
@@ -25,25 +26,22 @@ const defaultContext = {
|
|
|
25
26
|
referenceElement: null,
|
|
26
27
|
inputValue: "",
|
|
27
28
|
focusOptionIdx: "",
|
|
28
|
-
showSelectedOptions: false,
|
|
29
29
|
pillGroupRef: createRef(),
|
|
30
30
|
listRef: createRef(),
|
|
31
31
|
wrapperListRef: createRef(),
|
|
32
32
|
controlsWrapperRef: createRef(),
|
|
33
33
|
selectedOptionsRef: createRef(),
|
|
34
|
-
selectAllCheckboxRef: createRef(),
|
|
35
|
-
toggleSelectionButtonRef: createRef(),
|
|
36
34
|
setShowPopover: noop,
|
|
37
35
|
scrollOptionIntoView: noop,
|
|
38
36
|
setHasFocus: noop,
|
|
39
37
|
setInputValue: noop,
|
|
40
38
|
setReferenceElement: noop,
|
|
41
39
|
setFocusOptionIdx: noop,
|
|
42
|
-
setShowSelectedOptions: noop,
|
|
43
40
|
setMenuState: noop,
|
|
44
41
|
internalRef: createRef(),
|
|
45
42
|
correctOptions: [],
|
|
46
|
-
instanceUid: ""
|
|
43
|
+
instanceUid: "",
|
|
44
|
+
optionsPerSection: []
|
|
47
45
|
};
|
|
48
46
|
const ComboBoxContext = createContext(defaultContext);
|
|
49
47
|
var ComboBoxCTX_default = ComboBoxContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/ComboBoxCTX.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;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,UAAU,UAAU;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 * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;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,UAAU,UAAU;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,cAAc,UAA0B;AAAA,EACxC,SAAS,UAA0B;AAAA,EACnC,gBAAgB,UAA0B;AAAA,EAC1C,oBAAoB,UAA4B;AAAA,EAChD,oBAAoB,UAA4B;AAAA,EAChD,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,cAAc;AAAA,EACd,aAAa,UAA4B;AAAA,EACzC,gBAAgB,CAAC;AAAA,EACjB,aAAa;AAAA,EACb,mBAAmB,CAAC;AACtB;AAEO,MAAM,kBAAkB,cAAc,cAAc;AAE3D,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
const ComboboxDataTestid = {
|
|
3
|
-
MULTISELECT: {
|
|
4
|
-
HEADER_LIST: "combobox-header-list",
|
|
5
|
-
SHOW_SELECTED_OPTIONS_TOGGLE: "combobox-selected-options-toggle"
|
|
6
|
-
},
|
|
7
3
|
CONTROLS_WRAPPER: "combobox-controls-wrapper",
|
|
8
4
|
CONTAINER: "combobox-container",
|
|
9
5
|
INPUT: "combobox-input",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/ComboboxDataTestids.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const ComboboxDataTestid = {\n
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAhB,MAAM,qBAAqB;AAAA,EAChC,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAhB,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
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
function useOnClickOutside(ref, cb, excludeNode) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
const listener = (event) => {
|
|
6
|
+
if (!ref || ref?.contains?.(event.target) || excludeNode && excludeNode.contains(event.target)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
cb(event);
|
|
10
|
+
};
|
|
11
|
+
document.addEventListener("mousedown", listener);
|
|
12
|
+
document.addEventListener("touchstart", listener);
|
|
13
|
+
return () => {
|
|
14
|
+
document.removeEventListener("mousedown", listener);
|
|
15
|
+
document.removeEventListener("touchstart", listener);
|
|
16
|
+
};
|
|
17
|
+
}, [ref, cb, excludeNode]);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
useOnClickOutside
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=useClickOutside.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useClickOutside.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,iBAAiB;AAEnB,SAAS,kBACd,KACA,IACA,aACM;AACN,YAAU,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
|
+
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
4
|
import { useVirtual } from "react-virtual";
|
|
4
5
|
import { uid } from "uid";
|
|
5
|
-
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
6
6
|
import { defaultProps } from "../ComboBoxCTX.js";
|
|
7
7
|
import { ComboboxPropTypes } from "../react-desc-prop-types.js";
|
|
8
|
-
import { useCorrectOptions } from "./useCorrectOptions.js";
|
|
9
|
-
import { getFirstOption } from "../utils/listHelper.js";
|
|
10
8
|
import { DSComboBoxName } from "../theming.js";
|
|
11
|
-
import {
|
|
9
|
+
import { getFirstOption, isSelectedValueEmpty } from "../utils/listHelper.js";
|
|
10
|
+
import { useCorrectOptions } from "./useCorrectOptions.js";
|
|
11
|
+
import { useOptionsPerSection } from "./useOptionsPerSection.js";
|
|
12
12
|
const useComboBox = (props) => {
|
|
13
13
|
const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultProps);
|
|
14
14
|
useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes, DSComboBoxName);
|
|
15
15
|
const [showPopover, setShowPopover] = useState(false);
|
|
16
16
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
17
|
-
const [showSelectedOptions, setShowSelectedOptions] = useState(false);
|
|
18
17
|
const [inputValue, setInputValue] = useState("");
|
|
19
18
|
const [hasFocus, setHasFocus] = useState(false);
|
|
20
19
|
const internalRef = useRef(null);
|
|
@@ -22,8 +21,6 @@ const useComboBox = (props) => {
|
|
|
22
21
|
const wrapperListRef = useRef(null);
|
|
23
22
|
const selectedOptionsRef = useRef(null);
|
|
24
23
|
const controlsWrapperRef = useRef(null);
|
|
25
|
-
const selectAllCheckboxRef = useRef(null);
|
|
26
|
-
const toggleSelectionButtonRef = useRef(null);
|
|
27
24
|
const pillGroupRef = useRef(null);
|
|
28
25
|
const { id, selectedValues, isMenuOpen, onMenuChange, applyAriaDisabled } = propsWithDefaults;
|
|
29
26
|
const instanceUid = useMemo(() => id || uid(5), [id]);
|
|
@@ -31,17 +28,10 @@ const useComboBox = (props) => {
|
|
|
31
28
|
if (isMenuOpen !== void 0) return isMenuOpen;
|
|
32
29
|
return showPopover;
|
|
33
30
|
}, [showPopover, isMenuOpen]);
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
if (applyAriaDisabled) return;
|
|
37
|
-
if (onMenuChange !== void 0) onMenuChange(newState, reason, e);
|
|
38
|
-
setShowPopover(newState);
|
|
39
|
-
},
|
|
40
|
-
[onMenuChange, applyAriaDisabled]
|
|
41
|
-
);
|
|
42
|
-
const correctOptions = useCorrectOptions(propsWithDefaults, inputValue, showSelectedOptions);
|
|
31
|
+
const correctOptions = useCorrectOptions(propsWithDefaults, inputValue);
|
|
32
|
+
const optionsPerSection = useOptionsPerSection(correctOptions);
|
|
43
33
|
const virtualListHelpers = useVirtual({
|
|
44
|
-
size:
|
|
34
|
+
size: optionsPerSection.length,
|
|
45
35
|
parentRef: listRef,
|
|
46
36
|
overscan: 15,
|
|
47
37
|
paddingStart: 0
|
|
@@ -56,24 +46,26 @@ const useComboBox = (props) => {
|
|
|
56
46
|
[correctOptions, virtualListHelpers]
|
|
57
47
|
);
|
|
58
48
|
const [focusOptionIdx, setFocusOptionIdx] = useState("");
|
|
49
|
+
const setMenuState = useCallback(
|
|
50
|
+
(newState, reason, e) => {
|
|
51
|
+
if (applyAriaDisabled) return;
|
|
52
|
+
if (onMenuChange !== void 0) onMenuChange(newState, reason, e);
|
|
53
|
+
setShowPopover(newState);
|
|
54
|
+
if (!inputValue && newState && !focusOptionIdx && !isSelectedValueEmpty(selectedValues)) {
|
|
55
|
+
const focusedValue = getFirstOption(correctOptions, selectedValues);
|
|
56
|
+
setFocusOptionIdx(focusedValue);
|
|
57
|
+
scrollOptionIntoView(focusedValue, { align: "center" });
|
|
58
|
+
} else {
|
|
59
|
+
setFocusOptionIdx("");
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
[applyAriaDisabled, onMenuChange, inputValue, focusOptionIdx, selectedValues, correctOptions, scrollOptionIntoView]
|
|
63
|
+
);
|
|
59
64
|
useEffect(() => {
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
const focusedValue = getFirstOption(correctOptions, selectedValues);
|
|
63
|
-
setFocusOptionIdx(focusedValue);
|
|
64
|
-
scrollOptionIntoView(focusedValue, { align: "center" });
|
|
65
|
-
}
|
|
66
|
-
}, [showPopover, hasFocus, correctOptions, selectedValues]);
|
|
67
|
-
const correctOptionsRef = useMakeMutable(correctOptions);
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
setFocusOptionIdx(correctOptionsRef.current?.[0]?.dsId ?? "");
|
|
70
|
-
}, [correctOptionsRef, inputValue]);
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (!showPopover) {
|
|
73
|
-
setFocusOptionIdx("");
|
|
74
|
-
setShowSelectedOptions(false);
|
|
65
|
+
if (propsWithDefaults.inline) {
|
|
66
|
+
setMenuState(true, "inline");
|
|
75
67
|
}
|
|
76
|
-
}, [
|
|
68
|
+
}, []);
|
|
77
69
|
const ctx = useMemo(
|
|
78
70
|
() => ({
|
|
79
71
|
props: { ...propsWithDefaults },
|
|
@@ -84,16 +76,12 @@ const useComboBox = (props) => {
|
|
|
84
76
|
focusOptionIdx,
|
|
85
77
|
selectedOptionsRef,
|
|
86
78
|
controlsWrapperRef,
|
|
87
|
-
selectAllCheckboxRef,
|
|
88
79
|
inputValue,
|
|
89
80
|
setInputValue,
|
|
90
81
|
setMenuState,
|
|
91
82
|
hasFocus,
|
|
92
|
-
toggleSelectionButtonRef,
|
|
93
83
|
pillGroupRef,
|
|
94
|
-
showSelectedOptions,
|
|
95
84
|
wrapperListRef,
|
|
96
|
-
setShowSelectedOptions,
|
|
97
85
|
setHasFocus,
|
|
98
86
|
setFocusOptionIdx,
|
|
99
87
|
scrollOptionIntoView,
|
|
@@ -101,7 +89,8 @@ const useComboBox = (props) => {
|
|
|
101
89
|
setShowPopover,
|
|
102
90
|
internalRef,
|
|
103
91
|
correctOptions,
|
|
104
|
-
instanceUid
|
|
92
|
+
instanceUid,
|
|
93
|
+
optionsPerSection
|
|
105
94
|
}),
|
|
106
95
|
[
|
|
107
96
|
scrollOptionIntoView,
|
|
@@ -113,17 +102,15 @@ const useComboBox = (props) => {
|
|
|
113
102
|
inputValue,
|
|
114
103
|
focusOptionIdx,
|
|
115
104
|
wrapperListRef,
|
|
116
|
-
showSelectedOptions,
|
|
117
105
|
menuState,
|
|
118
106
|
pillGroupRef,
|
|
119
107
|
referenceElement,
|
|
120
108
|
selectedOptionsRef,
|
|
121
109
|
controlsWrapperRef,
|
|
122
|
-
selectAllCheckboxRef,
|
|
123
|
-
toggleSelectionButtonRef,
|
|
124
110
|
listRef,
|
|
125
111
|
internalRef,
|
|
126
|
-
instanceUid
|
|
112
|
+
instanceUid,
|
|
113
|
+
optionsPerSection
|
|
127
114
|
]
|
|
128
115
|
);
|
|
129
116
|
return ctx;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useComboBox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport {
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,9 +2,9 @@ import * as React from "react";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { uid } from "uid";
|
|
4
4
|
import { MENU_OPTION_TYPES } from "../constants.js";
|
|
5
|
-
import {
|
|
6
|
-
const useCorrectOptions = (propsWithDefaults, inputValue
|
|
7
|
-
const { filteredOptions, allOptions,
|
|
5
|
+
import { filterOptions } from "../utils/listHelper.js";
|
|
6
|
+
const useCorrectOptions = (propsWithDefaults, inputValue) => {
|
|
7
|
+
const { filteredOptions, allOptions, onCreate } = propsWithDefaults;
|
|
8
8
|
return useMemo(() => {
|
|
9
9
|
let correctAllOptions = allOptions;
|
|
10
10
|
if (allOptions?.every((option) => typeof option === "string")) {
|
|
@@ -16,9 +16,6 @@ const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) =
|
|
|
16
16
|
}));
|
|
17
17
|
}
|
|
18
18
|
const correctFilterOptions = filteredOptions ?? filterOptions(inputValue, correctAllOptions);
|
|
19
|
-
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
20
|
-
return selectedValuesWithSections(correctFilterOptions, selectedValues);
|
|
21
|
-
}
|
|
22
19
|
if (onCreate && inputValue && correctFilterOptions.findIndex(
|
|
23
20
|
(option) => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue
|
|
24
21
|
) === -1) {
|
|
@@ -32,7 +29,7 @@ const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) =
|
|
|
32
29
|
return [creatableItem, ...correctFilterOptions];
|
|
33
30
|
}
|
|
34
31
|
return correctFilterOptions;
|
|
35
|
-
}, [filteredOptions, allOptions,
|
|
32
|
+
}, [filteredOptions, allOptions, onCreate, inputValue]);
|
|
36
33
|
};
|
|
37
34
|
export {
|
|
38
35
|
useCorrectOptions
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useCorrectOptions.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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,YAAY,WAAW;ACCvB,SAAS,eAAe;AACxB,SAAS,WAAW;AAEpB,SAAS,yBAAyB;AAClC,SAAS,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* 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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACCvB,SAAS,eAAe;AACxB,SAAS,WAAW;AAEpB,SAAS,yBAAyB;AAClC,SAAS,qBAAqB;AAC9B,MAAM,oBAAoB,CAAC,mBAAsC,eAAuB;AACtF,QAAM,EAAE,iBAAiB,YAAY,SAAS,IAAI;AAElD,SAAO,QAAQ,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,kBAAkB;AAAA,QACxB,OAAO;AAAA,MACT,EAAE;AAAA,IACJ;AACA,UAAM,uBAAuB,mBAAmB,cAAc,YAAY,iBAAiB;AAG3F,QACE,YACA,cACA,qBAAqB;AAAA,MACnB,CAAC,WAAW,OAAO,SAAS,kBAAkB,UAAU,OAAO,UAAU;AAAA,IAC3E,MAAM,IACN;AACA,YAAM,gBAAgB,IAAI;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,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
const useOptionsPerSection = (correctOptions) => useMemo(() => {
|
|
4
|
+
const result = [];
|
|
5
|
+
let currentSection = null;
|
|
6
|
+
correctOptions.forEach((item) => {
|
|
7
|
+
if (item.type === "section") {
|
|
8
|
+
currentSection = {
|
|
9
|
+
dsId: item.dsId,
|
|
10
|
+
type: item.type,
|
|
11
|
+
label: item.label,
|
|
12
|
+
options: []
|
|
13
|
+
};
|
|
14
|
+
result.push(currentSection);
|
|
15
|
+
} else if ((item.type === "option" || item.type === "separator") && currentSection) {
|
|
16
|
+
currentSection.options.push(item);
|
|
17
|
+
} else if (item.type === "option" || item.type === "creatable" || item.type === "separator") {
|
|
18
|
+
result.push(item);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return result;
|
|
22
|
+
}, [correctOptions]);
|
|
23
|
+
export {
|
|
24
|
+
useOptionsPerSection
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=useOptionsPerSection.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useOptionsPerSection.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe;AAGjB,MAAM,uBAAuB,CAAC,mBACnC,QAAQ,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,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createElement } from "react";
|
|
4
|
+
import React2 from "react";
|
|
5
|
+
import { styled } from "@elliemae/ds-system";
|
|
6
|
+
import { SingleMenuItem, MultiMenuItem, Separator } from "@elliemae/ds-menu-items";
|
|
7
|
+
import { MENU_OPTION_TYPES } from "../constants.js";
|
|
8
|
+
import { ComboboxDataTestid } from "../ComboboxDataTestids.js";
|
|
9
|
+
import { isSelected } from "../utils/listHelper.js";
|
|
10
|
+
const StyledSectionWrapper = styled("section")`
|
|
11
|
+
list-style: none;
|
|
12
|
+
min-height: 24px;
|
|
13
|
+
display: grid;
|
|
14
|
+
align-items: center;
|
|
15
|
+
`;
|
|
16
|
+
const StyledSectionLabel = styled("header")`
|
|
17
|
+
display: flex;
|
|
18
|
+
align-items: center;
|
|
19
|
+
padding: 0px 16px;
|
|
20
|
+
min-height: 24px;
|
|
21
|
+
font-size: 1rem;
|
|
22
|
+
color: neutral-500;
|
|
23
|
+
`;
|
|
24
|
+
const Section = React2.memo((props) => {
|
|
25
|
+
const { label, wrapperStyles, focusOptionIdx, selectedValues, innerRef, handleOnMouseDown, options, handleClick } = props;
|
|
26
|
+
const id = `${label.replace(/ /g, "")}-section`;
|
|
27
|
+
const CBItem = Array.isArray(selectedValues) ? MultiMenuItem : SingleMenuItem;
|
|
28
|
+
return /* @__PURE__ */ jsxs(StyledSectionWrapper, { role: "group", "aria-labelledby": id, style: wrapperStyles, innerRef, children: [
|
|
29
|
+
/* @__PURE__ */ jsx(StyledSectionLabel, { id, role: "presentation", children: label }),
|
|
30
|
+
options?.map((option) => {
|
|
31
|
+
const { dsId, type, value, label: optionLabel, readOnly, disabled, applyAriaDisabled, ...rest } = option;
|
|
32
|
+
if (type === MENU_OPTION_TYPES.SEPARATOR) {
|
|
33
|
+
return /* @__PURE__ */ jsx(Separator, {}, dsId);
|
|
34
|
+
}
|
|
35
|
+
return /* @__PURE__ */ createElement(
|
|
36
|
+
CBItem,
|
|
37
|
+
{
|
|
38
|
+
value,
|
|
39
|
+
label: optionLabel,
|
|
40
|
+
dataTestid: ComboboxDataTestid.OPTION,
|
|
41
|
+
disabled,
|
|
42
|
+
applyAriaDisabled: applyAriaDisabled || readOnly,
|
|
43
|
+
onClick: (e) => {
|
|
44
|
+
if (applyAriaDisabled) return;
|
|
45
|
+
handleClick(option, e);
|
|
46
|
+
},
|
|
47
|
+
onMouseDown: handleOnMouseDown,
|
|
48
|
+
isActive: dsId === focusOptionIdx,
|
|
49
|
+
isSelected: isSelected(selectedValues, option),
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
...rest,
|
|
52
|
+
key: option.dsId,
|
|
53
|
+
dsId: option.dsId
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
})
|
|
57
|
+
] });
|
|
58
|
+
});
|
|
59
|
+
export {
|
|
60
|
+
Section
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=Section.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Section.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;AC4CnB,SACE,KADF;AAYM;AAxDV,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,gBAAgB,eAAe,iBAAiB;AACzD,SAAS,yBAAyB;AAElC,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAa3B,MAAM,uBAAuB,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAO7C,MAAM,qBAAqB,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASnC,MAAM,UAAUA,OAAM,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,gBAAgB;AAE/D,SACE,qBAAC,wBAAqB,MAAK,SAAQ,mBAAiB,IAAI,OAAO,eAAe,UAC5E;AAAA,wBAAC,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,kBAAkB,WAAW;AACxC,eAAO,oBAAC,eAAe,IAAM;AAAA,MAC/B;AAEA,aACE;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,OAAO;AAAA,UACP,YAAY,mBAAmB;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,YAAY,WAAW,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": ["React"]
|
|
7
|
+
}
|