@elliemae/ds-form-combobox 3.1.4 → 3.1.5-rc.12
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 +3 -2
- package/dist/cjs/ComboBoxCTX.js.map +2 -2
- package/dist/cjs/config/useCorrectOptions.js +3 -2
- package/dist/cjs/config/useCorrectOptions.js.map +2 -2
- package/dist/cjs/constants.js +7 -0
- package/dist/cjs/constants.js.map +2 -2
- package/dist/cjs/parts/controls/Controls.js +0 -7
- package/dist/cjs/parts/controls/Controls.js.map +2 -2
- package/dist/cjs/parts/controls-input/ControlsInput.js +2 -2
- package/dist/cjs/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js +6 -10
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js +5 -4
- package/dist/cjs/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/cjs/parts/menu-list/useItemRenderer.js +11 -8
- package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/parts/styled.js +8 -2
- package/dist/cjs/parts/styled.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +2 -2
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/utils/listHelper.js +1 -1
- package/dist/cjs/utils/listHelper.js.map +2 -2
- package/dist/esm/ComboBoxCTX.js +3 -2
- package/dist/esm/ComboBoxCTX.js.map +2 -2
- package/dist/esm/config/useCorrectOptions.js +4 -3
- package/dist/esm/config/useCorrectOptions.js.map +2 -2
- package/dist/esm/constants.js +7 -0
- package/dist/esm/constants.js.map +2 -2
- package/dist/esm/parts/controls/Controls.js +0 -7
- package/dist/esm/parts/controls/Controls.js.map +2 -2
- package/dist/esm/parts/controls-input/ControlsInput.js +2 -2
- package/dist/esm/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js +8 -13
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/parts/controls-input/useMaskedOnChange.js +5 -4
- package/dist/esm/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/esm/parts/menu-list/useItemRenderer.js +11 -8
- package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/parts/styled.js +8 -2
- package/dist/esm/parts/styled.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +2 -2
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/utils/listHelper.js +1 -1
- package/dist/esm/utils/listHelper.js.map +2 -2
- package/package.json +12 -12
|
@@ -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": ["import { DSComboboxT } from '../react-desc-prop-types';\nimport { MENU_OPTION_TYPES } from '../constants';\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 const findInCircularList = (\n list: DSComboboxT.OptionTypes[],\n from: number,\n criteria: (item: DSComboboxT.OptionTypes) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n if (criteria(list[i])) return i;\n }\n return from; // return same item\n};\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 inputValue: string,\n): string => {\n if (!inputValue) {\n const lastValue = getLastValueSelected(selectedValues);\n if (lastValue) return lastValue.dsId;\n }\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
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAAkC;AAC3B,MAAM,uBAAuB,CAA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EO,MAAM,4BAA4B,CACvC,gBACA,gBACA,mBACG;AACH,MAAI,MAAM,QAAQ,cAAc,GAAG;AACjC,UAAM,UAAU,eAAe,KAAK,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,UAAU,eAAe,KAAK;AAC3G,QAAI,SAAS;AACX,UAAI;AAAgB,eAAO;AAC3B,aAAO,eAAe,OAAO,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,UAAU,eAAe,KAAK;AAAA,IACtG;AACA,WAAO,CAAC,GAAG,gBAAgB,cAAc;AAAA,EAC3C;AACA,MAAI,kBAAkB,eAAe,SAAS,eAAe,MAAM;AACjE,QAAI;AAAgB,aAAO;AAC3B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,MAAM,gBAAgB,CAAC,YAAoB,YAAuC;AACvF,MAAI,
|
|
4
|
+
"sourcesContent": ["import { DSComboboxT } from '../react-desc-prop-types';\nimport { MENU_OPTION_TYPES } from '../constants';\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 const findInCircularList = (\n list: DSComboboxT.OptionTypes[],\n from: number,\n criteria: (item: DSComboboxT.OptionTypes) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from > -1;\n i = (i + step + list.length) % list.length\n ) {\n if (criteria(list[i])) return i;\n }\n return from; // return same item\n};\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 inputValue: string,\n): string => {\n if (!inputValue) {\n const lastValue = getLastValueSelected(selectedValues);\n if (lastValue) return lastValue.dsId;\n }\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 selectedValuesWithSections = (\n optionsToParse: DSComboboxT.OptionTypes[],\n multiSelectedValue: DSComboboxT.ItemOption[],\n) => {\n const items = [] as DSComboboxT.OptionTypes[];\n\n if (optionsToParse)\n optionsToParse.forEach((option) => {\n // const isSelectedValue = multiSelectedValue.find((item) => item?.dsId === option.dsId);\n if (option.type === MENU_OPTION_TYPES.OPTION && isSelected(multiSelectedValue, option)) {\n items.push(option);\n }\n\n if (option.type === MENU_OPTION_TYPES.SECTION) {\n if (items[items.length - 1]?.type === MENU_OPTION_TYPES.SECTION) {\n items[items.length - 1] = option;\n } else {\n items.push(option);\n }\n }\n });\n if (items[items.length - 1]?.type === MENU_OPTION_TYPES.SECTION) {\n items.pop();\n }\n\n return items;\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": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,uBAAkC;AAC3B,MAAM,uBAAuB,CAAC,YACnC,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,mCAAkB,UAAU,CAAC,OAAO,QAAQ;AAElF,MAAM,aAAa,CAAC,YACzB,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,mCAAkB,MAAM;AAE9D,MAAM,uBAAuB,CAAC,UACnC,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,CAAC;AAExC,MAAM,0BAA0B,CAAC,UAAiD,MAAM,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AAU,QAAO,cAAc,SAAS,gBAAgB;AAGnE,SAAK,eAAe,OAAO;AAC/B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/ComboBoxCTX.js
CHANGED
|
@@ -10,9 +10,10 @@ const defaultProps = {
|
|
|
10
10
|
useMask: noop,
|
|
11
11
|
innerRef: createRef(),
|
|
12
12
|
startPlacementPreference: "bottom-start",
|
|
13
|
-
placementOrderPreference: ["bottom-start", "
|
|
13
|
+
placementOrderPreference: ["bottom-start", "top-start"],
|
|
14
14
|
noOptionsMessage: "No Matches Found",
|
|
15
|
-
isNonClearable: false
|
|
15
|
+
isNonClearable: false,
|
|
16
|
+
onlySelectable: false
|
|
16
17
|
};
|
|
17
18
|
const defaultContext = {
|
|
18
19
|
props: defaultProps,
|
|
@@ -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 { DSComboboxT } from './react-desc-prop-types';\nimport { DSComboboxInternalsT } from './sharedTypes';\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', '
|
|
5
|
-
"mappings": "AAAA;ACAA;AAMO,iBAAsC,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,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport { DSComboboxT } from './react-desc-prop-types';\nimport { DSComboboxInternalsT } from './sharedTypes';\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 // override in useCombobox to avoid ref duplications when more than one cb is used\n};\n\nconst defaultContext: DSComboboxInternalsT.ComboBoxContextT = {\n props: defaultProps as DSComboboxT.InternalProps,\n menuState: false,\n hasFocus: false,\n referenceElement: null,\n inputValue: '',\n focusOptionIdx: '',\n showSelectedOptions: false,\n pillGroupRef: createRef<HTMLDivElement>(),\n listRef: createRef<HTMLDivElement>(),\n wrapperListRef: createRef<HTMLDivElement>(),\n controlsWrapperRef: createRef<HTMLInputElement>(),\n selectedOptionsRef: createRef<HTMLInputElement>(),\n selectAllCheckboxRef: createRef<HTMLInputElement>(),\n toggleSelectionButtonRef: createRef<HTMLButtonElement>(),\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n setHasFocus: noop,\n setInputValue: noop,\n setReferenceElement: noop,\n setFocusOptionIdx: noop,\n setShowSelectedOptions: noop,\n setMenuState: noop,\n};\n/** Context for cross component communication */\nexport const ComboBoxContext = createContext(defaultContext);\n\nexport default ComboBoxContext;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAMO,iBAAsC,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;AAElB;AAEA,MAAM,iBAAwD;AAAA,EAC5D,OAAO;AAAA,EACP,WAAW;AAAA,EACX,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,cAAc,UAA0B;AAAA,EACxC,SAAS,UAA0B;AAAA,EACnC,gBAAgB,UAA0B;AAAA,EAC1C,oBAAoB,UAA4B;AAAA,EAChD,oBAAoB,UAA4B;AAAA,EAChD,sBAAsB,UAA4B;AAAA,EAClD,0BAA0B,UAA6B;AAAA,EACvD,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,cAAc;AAChB;AAEO,MAAM,kBAAkB,cAAc,cAAc;AAE3D,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,12 +2,13 @@ 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";
|
|
5
|
-
import { selectedValuesWithSections } from "../utils/listHelper";
|
|
5
|
+
import { selectedValuesWithSections, filterOptions } from "../utils/listHelper";
|
|
6
6
|
const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
|
|
7
7
|
const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;
|
|
8
8
|
return useMemo(() => {
|
|
9
|
-
if (!filteredOptions)
|
|
10
|
-
return
|
|
9
|
+
if (!filteredOptions) {
|
|
10
|
+
return filterOptions(inputValue, allOptions);
|
|
11
|
+
}
|
|
11
12
|
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
12
13
|
return selectedValuesWithSections(filteredOptions, selectedValues);
|
|
13
14
|
}
|
|
@@ -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", "import { useMemo } from 'react';\nimport { uid } from 'uid';\nimport { DSComboboxT } from '../react-desc-prop-types';\nimport { MENU_OPTION_TYPES } from '../constants';\nimport { selectedValuesWithSections } from '../utils/listHelper';\nconst useCorrectOptions = (propsWithDefaults: DSComboboxT.Props, inputValue: string, showSelectedOptions: boolean) => {\n const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;\n\n return useMemo(() => {\n // if filteredOptions is not passed we copy allOptions into the prop as default\n // this is useful when the user wants a combo with out filtering and only pass allOptions as its required\n if (!filteredOptions) return
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,iBAAiB,YAAY,gBAAgB,aAAa;AAElE,SAAO,QAAQ,MAAM;AAGnB,QAAI,CAAC;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { uid } from 'uid';\nimport { DSComboboxT } from '../react-desc-prop-types';\nimport { MENU_OPTION_TYPES } from '../constants';\nimport { selectedValuesWithSections, filterOptions } from '../utils/listHelper';\nconst useCorrectOptions = (propsWithDefaults: DSComboboxT.Props, inputValue: string, showSelectedOptions: boolean) => {\n const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;\n\n return useMemo(() => {\n // if filteredOptions is not passed we copy allOptions into the prop as default\n // this is useful when the user wants a combo with out filtering and only pass allOptions as its required\n if (!filteredOptions) {\n return filterOptions(inputValue, allOptions);\n }\n // when show selected toggle is on we return the selected value only as filteredOptions prop\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections(filteredOptions, selectedValues);\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 filteredOptions.findIndex((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 };\n return [creatableItem, ...filteredOptions];\n }\n return filteredOptions;\n }, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);\n};\n\nexport { useCorrectOptions };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,iBAAiB,YAAY,gBAAgB,aAAa;AAElE,SAAO,QAAQ,MAAM;AAGnB,QAAI,CAAC,iBAAiB;AACpB,aAAO,cAAc,YAAY,UAAU;AAAA,IAC7C;AAEA,QAAI,uBAAuB,MAAM,QAAQ,cAAc,KAAK,eAAe,SAAS,GAAG;AACrF,aAAO,2BAA2B,iBAAiB,cAAc;AAAA,IACnE;AAEA,QACE,YACA,cACA,gBAAgB,UAAU,CAAC,WAAW,OAAO,SAAS,kBAAkB,UAAU,OAAO,UAAU,UAAU,MAC3G,IACF;AACA,YAAM,gBAAgB,IAAI;AAC1B,YAAM,gBAAiD;AAAA,QACrD,MAAM,aAAa;AAAA,QACnB,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AACA,aAAO,CAAC,eAAe,GAAG,eAAe;AAAA,IAC3C;AACA,WAAO;AAAA,EACT,GAAG,CAAC,iBAAiB,YAAY,qBAAqB,gBAAgB,UAAU,UAAU,CAAC;AAC7F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/constants.js
CHANGED
|
@@ -7,8 +7,15 @@ const MENU_OPTION_TYPES = {
|
|
|
7
7
|
const INTERNAL_MENU_OPTION_TYPES = {
|
|
8
8
|
CREATABLE: "creatable"
|
|
9
9
|
};
|
|
10
|
+
const MENU_CONTROL_REASONS = {
|
|
11
|
+
SELECT_OPTION: "selectOption",
|
|
12
|
+
CLOSE: "close",
|
|
13
|
+
OPEN: "open",
|
|
14
|
+
BLUR: "blur"
|
|
15
|
+
};
|
|
10
16
|
export {
|
|
11
17
|
INTERNAL_MENU_OPTION_TYPES,
|
|
18
|
+
MENU_CONTROL_REASONS,
|
|
12
19
|
MENU_OPTION_TYPES
|
|
13
20
|
};
|
|
14
21
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/constants.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const MENU_OPTION_TYPES = {\n OPTION: 'option',\n SECTION: 'section',\n SEPARATOR: 'separator',\n} as const;\n\nexport const INTERNAL_MENU_OPTION_TYPES = {\n CREATABLE: 'creatable',\n} as const;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAO,MAAM,oBAAoB;AAAA,EAC/B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AACb;AAEO,MAAM,6BAA6B;AAAA,EACxC,WAAW;AACb;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const MENU_OPTION_TYPES = {\n OPTION: 'option',\n SECTION: 'section',\n SEPARATOR: 'separator',\n} as const;\n\nexport const INTERNAL_MENU_OPTION_TYPES = {\n CREATABLE: 'creatable',\n} as const;\n\nexport const MENU_CONTROL_REASONS = {\n SELECT_OPTION: 'selectOption',\n CLOSE: 'close',\n OPEN: 'open',\n BLUR: 'blur',\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,oBAAoB;AAAA,EAC/B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AACb;AAEO,MAAM,6BAA6B;AAAA,EACxC,WAAW;AACb;AAEO,MAAM,uBAAuB;AAAA,EAClC,eAAe;AAAA,EACf,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
StyledHeaderActionsWrapper,
|
|
10
10
|
StyledSelection
|
|
11
11
|
} from "./styled";
|
|
12
|
-
import { scrollIfNeeded } from "../../utils/listHelper";
|
|
13
12
|
import { MultiSelectedValuesContainer } from "../multi-selected-values-container";
|
|
14
13
|
import { ControlsInput } from "../controls-input/ControlsInput";
|
|
15
14
|
import { useOnPillsNavigation } from "./useOnPillsNavigation";
|
|
@@ -39,12 +38,6 @@ const Controls = () => {
|
|
|
39
38
|
}
|
|
40
39
|
innerRef.current?.focus();
|
|
41
40
|
setMenuState(true);
|
|
42
|
-
window.requestAnimationFrame(() => {
|
|
43
|
-
window.requestAnimationFrame(() => {
|
|
44
|
-
if (listRef.current)
|
|
45
|
-
scrollIfNeeded(listRef.current);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
41
|
}, [disabled, listRef, hasFocus, menuState, inline, innerRef, setMenuState, focusOptionIdx]);
|
|
49
42
|
const handleOnPillsClick = useCallback((e) => {
|
|
50
43
|
if (menuState || disabled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/controls/Controls.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport React, { useContext, useMemo, useCallback } from 'react';\nimport { DropdownIndicator } from '../DropdownIndicator';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport {\n StyledControlsWrapper,\n StyleHeaderActionsSeparator,\n StyledHeaderActionsWrapper,\n StyledSelection,\n} from './styled';\nimport { scrollIfNeeded } from '../../utils/listHelper';\nimport { MultiSelectedValuesContainer } from '../multi-selected-values-container';\nimport { ControlsInput } from '../controls-input/ControlsInput';\nimport { useOnPillsNavigation } from './useOnPillsNavigation';\nimport { A11yFocusedOption } from '../A11yFocusedOption';\nimport { A11ySelectedValues } from '../A11ySelectedValues';\nimport { RemovableSelectedValuePill } from '../multi-selected-values-container/RemovableSelectedValuePill';\nexport const Controls = (): JSX.Element => {\n const {\n props: { inline, disabled, inputMinWidth, hasError, selectedValues, innerRef },\n selectedOptionsRef,\n setMenuState,\n setFocusOptionIdx,\n hasFocus,\n listRef,\n focusOptionIdx,\n menuState,\n controlsWrapperRef,\n } = useContext(ComboBoxContext);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (hasFocus && menuState && !inline) {\n setMenuState(false);\n setFocusOptionIdx('');\n innerRef.current?.blur();\n return;\n }\n innerRef.current?.focus();\n setMenuState(true);\n
|
|
5
|
-
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport React, { useContext, useMemo, useCallback } from 'react';\nimport { DropdownIndicator } from '../DropdownIndicator';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport {\n StyledControlsWrapper,\n StyleHeaderActionsSeparator,\n StyledHeaderActionsWrapper,\n StyledSelection,\n} from './styled';\nimport { scrollIfNeeded } from '../../utils/listHelper';\nimport { MultiSelectedValuesContainer } from '../multi-selected-values-container';\nimport { ControlsInput } from '../controls-input/ControlsInput';\nimport { useOnPillsNavigation } from './useOnPillsNavigation';\nimport { A11yFocusedOption } from '../A11yFocusedOption';\nimport { A11ySelectedValues } from '../A11ySelectedValues';\nimport { RemovableSelectedValuePill } from '../multi-selected-values-container/RemovableSelectedValuePill';\nexport const Controls = (): JSX.Element => {\n const {\n props: { inline, disabled, inputMinWidth, hasError, selectedValues, innerRef },\n selectedOptionsRef,\n setMenuState,\n setFocusOptionIdx,\n hasFocus,\n listRef,\n focusOptionIdx,\n menuState,\n controlsWrapperRef,\n } = useContext(ComboBoxContext);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (hasFocus && menuState && !inline) {\n setMenuState(false);\n setFocusOptionIdx('');\n innerRef.current?.blur();\n return;\n }\n innerRef.current?.focus();\n setMenuState(true);\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [disabled, listRef, hasFocus, menuState, inline, innerRef, setMenuState, focusOptionIdx]);\n\n // this callback prevent to toggle the menu when clicking or removing pills\n const handleOnPillsClick: React.MouseEventHandler = useCallback(\n (e) => {\n if (menuState || disabled) {\n e.stopPropagation();\n } else {\n innerRef.current?.focus();\n setMenuState(true);\n }\n },\n [menuState, innerRef, disabled, setMenuState],\n );\n\n // callback to prevent onBlur on the input when clicking in all the wrapper\n const handleOnMouseDown: React.MouseEventHandler = useCallback(\n (e) => {\n if (document.activeElement === innerRef.current || inline) {\n e.preventDefault();\n }\n },\n [innerRef, inline],\n );\n\n const { onKeyDownPills } = useOnPillsNavigation();\n\n const cols = useMemo(\n () => (!inline ? ['minmax(0px,max-content)', 'minmax(20px, auto)', '29px'] : ['minmax(0px, auto)']),\n [inline],\n );\n return (\n <StyledControlsWrapper\n ref={controlsWrapperRef}\n cols={cols}\n disabled={disabled}\n minWidth={inputMinWidth}\n hasError={hasError}\n inline={inline}\n onClick={handleOnClick}\n onMouseDown={handleOnMouseDown}\n onKeyDown={onKeyDownPills}\n data-testid={ComboboxDataTestid.CONTROLS_WRAPPER}\n >\n {!inline && (\n <StyledSelection ref={selectedOptionsRef} onClick={handleOnPillsClick}>\n <A11ySelectedValues />\n {Array.isArray(selectedValues) ? (\n <MultiSelectedValuesContainer />\n ) : (\n <div data-testid={ComboboxDataTestid.SELECTED_VALUES}>\n {selectedValues && <RemovableSelectedValuePill pill={selectedValues} />}\n </div>\n )}\n </StyledSelection>\n )}\n <A11yFocusedOption />\n\n <ControlsInput />\n {!inline && (\n <StyledHeaderActionsWrapper justifyContent=\"center\" cols={['min-content', 'min-content']}>\n <StyleHeaderActionsSeparator disabled={disabled} />\n <DropdownIndicator />\n </StyledHeaderActionsWrapper>\n )}\n </StyledControlsWrapper>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,UAAU,eAAe,UAAU,gBAAgB;AAAA,IACpE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAE9B,QAAM,gBAAgB,YAAY,MAAM;AACtC,QAAI;AAAU;AACd,QAAI,YAAY,aAAa,CAAC,QAAQ;AACpC,mBAAa,KAAK;AAClB,wBAAkB,EAAE;AACpB,eAAS,SAAS,KAAK;AACvB;AAAA,IACF;AACA,aAAS,SAAS,MAAM;AACxB,iBAAa,IAAI;AAAA,EAGnB,GAAG,CAAC,UAAU,SAAS,UAAU,WAAW,QAAQ,UAAU,cAAc,cAAc,CAAC;AAG3F,QAAM,qBAA8C,YAClD,CAAC,MAAM;AACL,QAAI,aAAa,UAAU;AACzB,QAAE,gBAAgB;AAAA,IACpB,OAAO;AACL,eAAS,SAAS,MAAM;AACxB,mBAAa,IAAI;AAAA,IACnB;AAAA,EACF,GACA,CAAC,WAAW,UAAU,UAAU,YAAY,CAC9C;AAGA,QAAM,oBAA6C,YACjD,CAAC,MAAM;AACL,QAAI,SAAS,kBAAkB,SAAS,WAAW,QAAQ;AACzD,QAAE,eAAe;AAAA,IACnB;AAAA,EACF,GACA,CAAC,UAAU,MAAM,CACnB;AAEA,QAAM,EAAE,mBAAmB,qBAAqB;AAEhD,QAAM,OAAO,QACX,MAAO,CAAC,SAAS,CAAC,2BAA2B,sBAAsB,MAAM,IAAI,CAAC,mBAAmB,GACjG,CAAC,MAAM,CACT;AACA,SACE,qCAAC;AAAA,IACC,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,eAAa,mBAAmB;AAAA,KAE/B,CAAC,UACA,qCAAC;AAAA,IAAgB,KAAK;AAAA,IAAoB,SAAS;AAAA,KACjD,qCAAC,wBAAmB,GACnB,MAAM,QAAQ,cAAc,IAC3B,qCAAC,kCAA6B,IAE9B,qCAAC;AAAA,IAAI,eAAa,mBAAmB;AAAA,KAClC,kBAAkB,qCAAC;AAAA,IAA2B,MAAM;AAAA,GAAgB,CACvE,CAEJ,GAEF,qCAAC,uBAAkB,GAEnB,qCAAC,mBAAc,GACd,CAAC,UACA,qCAAC;AAAA,IAA2B,gBAAe;AAAA,IAAS,MAAM,CAAC,eAAe,aAAa;AAAA,KACrF,qCAAC;AAAA,IAA4B;AAAA,GAAoB,GACjD,qCAAC,uBAAkB,CACrB,CAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ import { useControlsInput } from "./useControlsInput";
|
|
|
8
8
|
import { ComboBoxContext } from "../../ComboBoxCTX";
|
|
9
9
|
const ControlsInput = () => {
|
|
10
10
|
const {
|
|
11
|
-
props: { autoFocus, placeholder, disabled, innerRef,
|
|
11
|
+
props: { autoFocus, placeholder, disabled, innerRef, onlySelectable },
|
|
12
12
|
focusOptionIdx,
|
|
13
13
|
inputValue,
|
|
14
14
|
menuState
|
|
@@ -38,7 +38,7 @@ const ControlsInput = () => {
|
|
|
38
38
|
onChange: handleOnChange,
|
|
39
39
|
onBlur: handleOnBlur,
|
|
40
40
|
onFocus: handleOnFocus,
|
|
41
|
-
withoutCaret:
|
|
41
|
+
withoutCaret: onlySelectable
|
|
42
42
|
}));
|
|
43
43
|
};
|
|
44
44
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/controls-input/ControlsInput.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\n\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { StyledInput, StyledInputWrapper, StyledInputPlaceHolder, StyledInputWidthReference } from './styled';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { useControlsInput } from './useControlsInput';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: { autoFocus, placeholder, disabled, innerRef,
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,aAAa,UAAU,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAC9B,QAAM,EAAE,mBAAmB,sBAAsB;AACjD,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,kBAC9F,iBAAiB;AACnB,SACE,qCAAC,0BACC,qCAAC;AAAA,IAA0B,KAAK;AAAA,KAAgB,iBAAkB,GACjE,mBACC,qCAAC,8BACC,qCAAC;AAAA,IAA2B,OAAO;AAAA,GAAiB,CACtD,GAGF,qCAAC;AAAA,IACC,eAAa,mBAAmB;AAAA,IAChC;AAAA,IACA;AAAA,IACA,iBAAc;AAAA,IACd,yBAAuB;AAAA,IACvB,iBAAe;AAAA,IACf,iBAAc;AAAA,IACd,oBAAiB;AAAA,IACjB,MAAK;AAAA,IACL;AAAA,IACA,OAAO,EAAE,MAAM;AAAA,IACf,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAK;AAAA,IACL,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\n\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { StyledInput, StyledInputWrapper, StyledInputPlaceHolder, StyledInputWidthReference } from './styled';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { useControlsInput } from './useControlsInput';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: { autoFocus, placeholder, disabled, innerRef, onlySelectable },\n focusOptionIdx,\n inputValue,\n menuState,\n } = useContext(ComboBoxContext);\n const { onInputKeyDown } = useKeyboardNavigation();\n const { spanReference, width, spanReferenceText, showPlaceholder, handleOnBlur, handleOnChange, handleOnFocus } =\n useControlsInput();\n return (\n <StyledInputWrapper>\n <StyledInputWidthReference ref={spanReference}>{spanReferenceText}</StyledInputWidthReference>\n {showPlaceholder && (\n <StyledInputPlaceHolder>\n <SimpleTruncatedTooltipText value={showPlaceholder}></SimpleTruncatedTooltipText>\n </StyledInputPlaceHolder>\n )}\n\n <StyledInput\n data-testid={ComboboxDataTestid.INPUT}\n autoFocus={autoFocus}\n placeholder={placeholder}\n aria-controls=\"combo-listbox\"\n aria-activedescendant={focusOptionIdx}\n aria-expanded={menuState}\n aria-haspopup=\"listbox\"\n aria-describedby=\"combobox-selected-items\"\n role=\"combobox\"\n disabled={disabled}\n style={{ width }}\n ref={innerRef}\n value={inputValue}\n type=\"text\"\n onKeyDown={onInputKeyDown}\n onChange={handleOnChange}\n onBlur={handleOnBlur}\n onFocus={handleOnFocus}\n withoutCaret={onlySelectable}\n />\n </StyledInputWrapper>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,aAAa,UAAU,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAC9B,QAAM,EAAE,mBAAmB,sBAAsB;AACjD,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,kBAC9F,iBAAiB;AACnB,SACE,qCAAC,0BACC,qCAAC;AAAA,IAA0B,KAAK;AAAA,KAAgB,iBAAkB,GACjE,mBACC,qCAAC,8BACC,qCAAC;AAAA,IAA2B,OAAO;AAAA,GAAiB,CACtD,GAGF,qCAAC;AAAA,IACC,eAAa,mBAAmB;AAAA,IAChC;AAAA,IACA;AAAA,IACA,iBAAc;AAAA,IACd,yBAAuB;AAAA,IACvB,iBAAe;AAAA,IACf,iBAAc;AAAA,IACd,oBAAiB;AAAA,IACjB,MAAK;AAAA,IACL;AAAA,IACA,OAAO,EAAE,MAAM;AAAA,IACf,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAK;AAAA,IACL,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc;AAAA,GAChB,CACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
findInCircularList,
|
|
6
6
|
getOptions,
|
|
7
7
|
getSuggestedValueOnChange,
|
|
8
|
-
getLastValueSelected
|
|
9
|
-
scrollIfNeeded
|
|
8
|
+
getLastValueSelected
|
|
10
9
|
} from "../../utils/listHelper";
|
|
11
|
-
import { INTERNAL_MENU_OPTION_TYPES, MENU_OPTION_TYPES } from "../../constants";
|
|
10
|
+
import { INTERNAL_MENU_OPTION_TYPES, MENU_OPTION_TYPES, MENU_CONTROL_REASONS } from "../../constants";
|
|
12
11
|
const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type) && !opt.disabled;
|
|
13
12
|
const useKeyboardNavigation = () => {
|
|
14
13
|
const {
|
|
@@ -46,10 +45,6 @@ const useKeyboardNavigation = () => {
|
|
|
46
45
|
onKeyDown(e, currentItem);
|
|
47
46
|
if ((["ArrowDown", "ArrowUp", "Enter", "Spacebar"].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) && !menuState) {
|
|
48
47
|
setMenuState(true);
|
|
49
|
-
window.requestAnimationFrame(() => {
|
|
50
|
-
if (listRef.current)
|
|
51
|
-
scrollIfNeeded(listRef.current);
|
|
52
|
-
});
|
|
53
48
|
}
|
|
54
49
|
if (e.key === "Escape") {
|
|
55
50
|
if (onCancel)
|
|
@@ -60,7 +55,7 @@ const useKeyboardNavigation = () => {
|
|
|
60
55
|
setInputValue("");
|
|
61
56
|
}
|
|
62
57
|
if (!inline)
|
|
63
|
-
setMenuState(false,
|
|
58
|
+
setMenuState(false, MENU_CONTROL_REASONS.CLOSE, e);
|
|
64
59
|
}
|
|
65
60
|
if (e.key === "Enter" && currentItem?.type === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
66
61
|
onCreate(inputValue);
|
|
@@ -78,7 +73,7 @@ const useKeyboardNavigation = () => {
|
|
|
78
73
|
onFilter(allOptions, "");
|
|
79
74
|
setInputValue("");
|
|
80
75
|
if (!multiple) {
|
|
81
|
-
setMenuState(false,
|
|
76
|
+
setMenuState(false, MENU_CONTROL_REASONS.SELECT_OPTION, e);
|
|
82
77
|
}
|
|
83
78
|
onChange(getSuggestedValueOnChange(currentItem, selectedValues, isNonClearable), currentItem, e);
|
|
84
79
|
}
|
|
@@ -111,7 +106,7 @@ const useKeyboardNavigation = () => {
|
|
|
111
106
|
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
112
107
|
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
113
108
|
} else {
|
|
114
|
-
setMenuState(true,
|
|
109
|
+
setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);
|
|
115
110
|
const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);
|
|
116
111
|
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
117
112
|
setTimeout(() => {
|
|
@@ -122,8 +117,8 @@ const useKeyboardNavigation = () => {
|
|
|
122
117
|
}
|
|
123
118
|
if (e.key === "Backspace" && e.currentTarget.value.length <= 0 && !inline) {
|
|
124
119
|
const lastValue = getLastValueSelected(selectedValues);
|
|
125
|
-
if (!e.currentTarget.value && lastValue) {
|
|
126
|
-
onChange(getSuggestedValueOnChange(lastValue, selectedValues
|
|
120
|
+
if (!e.currentTarget.value && lastValue && !isNonClearable) {
|
|
121
|
+
onChange(getSuggestedValueOnChange(lastValue, selectedValues), lastValue, e);
|
|
127
122
|
}
|
|
128
123
|
}
|
|
129
124
|
if (e.key === "Tab" && !inline && menuState) {
|
|
@@ -132,7 +127,7 @@ const useKeyboardNavigation = () => {
|
|
|
132
127
|
e.preventDefault();
|
|
133
128
|
element.focus();
|
|
134
129
|
} else {
|
|
135
|
-
setMenuState(false,
|
|
130
|
+
setMenuState(false, MENU_CONTROL_REASONS.BLUR, e);
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
133
|
}, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/controls-input/useKeyboardNavigation.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { DSComboboxT } from '../../react-desc-prop-types';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n findInCircularList,\n getOptions,\n getSuggestedValueOnChange,\n getLastValueSelected,\n
|
|
5
|
-
"mappings": "AAAA;ACIA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport { useCallback, useContext } from 'react';\nimport { DSComboboxT } from '../../react-desc-prop-types';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport {\n findInCircularList,\n getOptions,\n getSuggestedValueOnChange,\n getLastValueSelected,\n} from '../../utils/listHelper';\nimport { INTERNAL_MENU_OPTION_TYPES, MENU_OPTION_TYPES, MENU_CONTROL_REASONS } from '../../constants';\nconst isOptionFocuseable = (opt: DSComboboxT.OptionTypes): boolean =>\n !['section', 'separator'].includes(opt.type) && !opt.disabled;\n\nexport const useKeyboardNavigation = () => {\n const {\n props: {\n allOptions,\n isNonClearable,\n onCancel,\n onKeyDown,\n onChange,\n onCreate,\n onFilter,\n onSelectAll,\n inline,\n filteredOptions,\n selectedValues,\n withoutPortal,\n },\n inputValue,\n menuState,\n focusOptionIdx,\n listRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n setMenuState,\n setInputValue,\n scrollOptionIntoView,\n setFocusOptionIdx,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n const selectableOptions = getOptions(filteredOptions);\n const currentItemIndex = filteredOptions.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = filteredOptions.find((item) => item.dsId === focusOptionIdx);\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // =============================================================================\n // CUSTOM KEYS\n // =============================================================================\n if (onKeyDown && currentItem?.type === MENU_OPTION_TYPES.OPTION) onKeyDown(e, currentItem);\n\n if (\n (['ArrowDown', 'ArrowUp', 'Enter', 'Spacebar'].includes(e.key) || (e.keyCode >= 48 && e.keyCode <= 90)) &&\n !menuState\n ) {\n setMenuState(true);\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n if (onCancel) onCancel();\n if (inputValue) {\n if (onFilter) onFilter(allOptions, inputValue);\n setInputValue('');\n }\n if (!inline) setMenuState(false, MENU_CONTROL_REASONS.CLOSE, e);\n }\n // =============================================================================\n // ENTER KEY TO CREATE ELEMENTS\n // =============================================================================\n if (e.key === 'Enter' && currentItem?.type === INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {\n onCreate(inputValue);\n // blank active item to force search last one\n setFocusOptionIdx('');\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n return;\n }\n\n // =============================================================================\n // Enter and space on selection\n // =============================================================================\n if (e.key === 'Enter' || (e.keyCode === 32 && e.altKey)) {\n e.preventDefault();\n e.stopPropagation();\n\n if (\n focusOptionIdx !== '' &&\n (menuState || inline) &&\n currentItem?.type === MENU_OPTION_TYPES.OPTION &&\n !currentItem.disabled\n ) {\n if (onFilter) onFilter(allOptions, '');\n setInputValue('');\n if (!multiple) {\n setMenuState(false, MENU_CONTROL_REASONS.SELECT_OPTION, e);\n }\n onChange(getSuggestedValueOnChange(currentItem, selectedValues, isNonClearable), currentItem, e);\n }\n }\n\n if (e.key === 'Enter' && e.altKey) {\n setMenuState(false, 'selectOption', e);\n }\n\n if (e.key === 'a' && e.ctrlKey && multiple && onSelectAll) {\n onSelectAll(\n filteredOptions.filter((option) => option.type === 'option' && !option.disabled),\n e,\n );\n }\n // =============================================================================\n // ARROWS UP AND DOWN: LOGIC TO CALCULATE NEXT OR PREV ITEM TO PSEUDOFOCUS FROM INPUT\n // =============================================================================\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n if ((menuState || inline) && selectableOptions.length) {\n const nextItemIndexIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable);\n if (nextItemIndexIndex > -1) {\n setFocusOptionIdx(filteredOptions[nextItemIndexIndex].dsId);\n scrollOptionIntoView(filteredOptions[nextItemIndexIndex].dsId);\n }\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n if (!selectableOptions.length) return;\n const prevItemIndex = findInCircularList(filteredOptions, currentItemIndex, isOptionFocuseable, -1);\n if (prevItemIndex > -1) {\n if (menuState || inline) {\n setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);\n scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);\n } else {\n // open menu and search last item to focused\n setMenuState(true, MENU_CONTROL_REASONS.OPEN, e);\n const lastItemIndex = findInCircularList(filteredOptions, 0, isOptionFocuseable, -1);\n setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);\n setTimeout(() => {\n scrollOptionIntoView(filteredOptions[lastItemIndex].dsId);\n });\n }\n }\n }\n\n // =============================================================================\n // BACKSPACE\n // =============================================================================\n if (e.key === 'Backspace' && e.currentTarget.value.length <= 0 && !inline) {\n const lastValue = getLastValueSelected(selectedValues);\n if (!e.currentTarget.value && lastValue && !isNonClearable) {\n onChange(getSuggestedValueOnChange(lastValue, selectedValues), lastValue, e);\n }\n }\n\n if (e.key === 'Tab' && !inline && menuState) {\n const element = selectAllCheckboxRef.current ?? toggleSelectionButtonRef.current;\n if (element) {\n e.preventDefault();\n element.focus();\n } else {\n setMenuState(false, MENU_CONTROL_REASONS.BLUR, e);\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [\n onKeyDown,\n currentItem,\n onCreate,\n multiple,\n inputValue,\n inline,\n withoutPortal,\n setMenuState,\n onCancel,\n onFilter,\n setInputValue,\n listRef,\n focusOptionIdx,\n menuState,\n selectableOptions.length,\n filteredOptions,\n currentItemIndex,\n setFocusOptionIdx,\n selectedValues,\n onChange,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n isNonClearable,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
|
|
5
|
+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
|
|
|
4
4
|
import { filterOptions } from "../../utils/listHelper";
|
|
5
5
|
const useMaskedOnChange = () => {
|
|
6
6
|
const {
|
|
7
|
-
props: { useMask, onFilter, allOptions },
|
|
7
|
+
props: { useMask, onlySelectable, onFilter, allOptions },
|
|
8
8
|
setMenuState,
|
|
9
9
|
setInputValue,
|
|
10
10
|
setShowSelectedOptions
|
|
@@ -12,11 +12,12 @@ const useMaskedOnChange = () => {
|
|
|
12
12
|
const handleOnChange = useCallback((e) => {
|
|
13
13
|
setShowSelectedOptions(false);
|
|
14
14
|
setMenuState(true, "filter", e);
|
|
15
|
-
if (onFilter) {
|
|
15
|
+
if (onFilter && !onlySelectable) {
|
|
16
16
|
onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
17
|
-
setInputValue(e.currentTarget.value);
|
|
18
17
|
}
|
|
19
|
-
|
|
18
|
+
if (!onlySelectable)
|
|
19
|
+
setInputValue(e.currentTarget.value);
|
|
20
|
+
}, [allOptions, onlySelectable, onFilter, setInputValue, setMenuState, setShowSelectedOptions]);
|
|
20
21
|
const handleOnChangeMask = useCallback((e, mask) => {
|
|
21
22
|
setShowSelectedOptions(false);
|
|
22
23
|
setMenuState(true, "filter", e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/controls-input/useMaskedOnChange.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useCallback } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport { filterOptions } from '../../utils/listHelper';\n\nconst useMaskedOnChange = () => {\n const {\n props: { useMask, onFilter, allOptions },\n setMenuState,\n setInputValue,\n setShowSelectedOptions,\n } = useContext(ComboBoxContext);\n\n // default onchange when no mask provided\n const handleOnChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setShowSelectedOptions(false);\n setMenuState(true, 'filter', e);\n if (onFilter) {\n onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);\n
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,oBAAoB,MAAM;AAC9B,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,UAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useCallback } from 'react';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport { filterOptions } from '../../utils/listHelper';\n\nconst useMaskedOnChange = () => {\n const {\n props: { useMask, onlySelectable, onFilter, allOptions },\n setMenuState,\n setInputValue,\n setShowSelectedOptions,\n } = useContext(ComboBoxContext);\n\n // default onchange when no mask provided\n const handleOnChange = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setShowSelectedOptions(false);\n setMenuState(true, 'filter', e);\n if (onFilter && !onlySelectable) {\n // when filtering is controlled we suggest the basic filtering but let the user decide\n onFilter(filterOptions(e.currentTarget.value, allOptions), e.currentTarget.value);\n }\n if (!onlySelectable) setInputValue(e.currentTarget.value);\n },\n [allOptions, onlySelectable, onFilter, setInputValue, setMenuState, setShowSelectedOptions],\n );\n\n // onchange used when mask is provided\n const handleOnChangeMask = useCallback(\n (e: React.ChangeEvent<HTMLInputElement>, mask?: string) => {\n setShowSelectedOptions(false);\n setMenuState(true, 'filter', e);\n if (mask && onFilter) onFilter(filterOptions(mask, allOptions), mask);\n else if (!mask && onFilter) onFilter(allOptions, '');\n },\n [allOptions, onFilter, setMenuState, setShowSelectedOptions],\n );\n\n const onChangeMask = useMask({ valueSetter: setInputValue, onChange: handleOnChangeMask });\n\n return onChangeMask?.onChange || handleOnChange;\n};\n\nexport { useMaskedOnChange };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AAEA,MAAM,oBAAoB,MAAM;AAC9B,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,gBAAgB,UAAU;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAG9B,QAAM,iBAAiB,YACrB,CAAC,MAA2C;AAC1C,2BAAuB,KAAK;AAC5B,iBAAa,MAAM,UAAU,CAAC;AAC9B,QAAI,YAAY,CAAC,gBAAgB;AAE/B,eAAS,cAAc,EAAE,cAAc,OAAO,UAAU,GAAG,EAAE,cAAc,KAAK;AAAA,IAClF;AACA,QAAI,CAAC;AAAgB,oBAAc,EAAE,cAAc,KAAK;AAAA,EAC1D,GACA,CAAC,YAAY,gBAAgB,UAAU,eAAe,cAAc,sBAAsB,CAC5F;AAGA,QAAM,qBAAqB,YACzB,CAAC,GAAwC,SAAkB;AACzD,2BAAuB,KAAK;AAC5B,iBAAa,MAAM,UAAU,CAAC;AAC9B,QAAI,QAAQ;AAAU,eAAS,cAAc,MAAM,UAAU,GAAG,IAAI;AAAA,aAC3D,CAAC,QAAQ;AAAU,eAAS,YAAY,EAAE;AAAA,EACrD,GACA,CAAC,YAAY,UAAU,cAAc,sBAAsB,CAC7D;AAEA,QAAM,eAAe,QAAQ,EAAE,aAAa,eAAe,UAAU,mBAAmB,CAAC;AAEzF,SAAO,cAAc,YAAY;AACnC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -69,6 +69,7 @@ const useItemRenderer = () => {
|
|
|
69
69
|
}
|
|
70
70
|
return virtualListHelpers.virtualItems.map((vItem) => {
|
|
71
71
|
const option = filteredOptions[vItem.index];
|
|
72
|
+
const { dsId, type, disabled } = option;
|
|
72
73
|
const generalProps = {
|
|
73
74
|
wrapperStyles: {
|
|
74
75
|
position: "absolute",
|
|
@@ -77,7 +78,7 @@ const useItemRenderer = () => {
|
|
|
77
78
|
width: "100%",
|
|
78
79
|
transform: `translateY(${vItem.start}px)`
|
|
79
80
|
},
|
|
80
|
-
key: `${
|
|
81
|
+
key: `${dsId}`,
|
|
81
82
|
innerRef: vItem.measureRef
|
|
82
83
|
};
|
|
83
84
|
if (option.type === MENU_OPTION_TYPES.SECTION) {
|
|
@@ -93,25 +94,27 @@ const useItemRenderer = () => {
|
|
|
93
94
|
value: option.value,
|
|
94
95
|
label: option.label,
|
|
95
96
|
dataTestid: ComboboxDataTestid.OPTION,
|
|
96
|
-
disabled
|
|
97
|
-
onClick: (e) =>
|
|
97
|
+
disabled,
|
|
98
|
+
onClick: (e) => {
|
|
99
|
+
handleClick(option, e);
|
|
100
|
+
},
|
|
98
101
|
onMouseDown: handleOnMouseDown,
|
|
99
|
-
isActive:
|
|
102
|
+
isActive: dsId === focusOptionIdx,
|
|
100
103
|
isSelected: isSelected(selectedValues, option),
|
|
101
104
|
tabIndex: -1
|
|
102
105
|
}));
|
|
103
106
|
}
|
|
104
|
-
if (
|
|
107
|
+
if (type === INTERNAL_MENU_OPTION_TYPES.CREATABLE) {
|
|
105
108
|
return /* @__PURE__ */ React2.createElement(SingleMenuItem, __spreadProps(__spreadValues({
|
|
106
109
|
dataTestid: ComboboxDataTestid.OPTION,
|
|
107
|
-
isActive:
|
|
110
|
+
isActive: dsId === focusOptionIdx
|
|
108
111
|
}, generalProps), {
|
|
109
|
-
render: ({ label }) => /* @__PURE__ */ React2.createElement(Grid, {
|
|
112
|
+
render: ({ label: labelCreatable }) => /* @__PURE__ */ React2.createElement(Grid, {
|
|
110
113
|
p: "8px",
|
|
111
114
|
cols: ["min-content", "auto"],
|
|
112
115
|
gutter: "xxs",
|
|
113
116
|
alignItems: "center"
|
|
114
|
-
}, /* @__PURE__ */ React2.createElement(StyledCreatableLabel, null, "Add:"), /* @__PURE__ */ React2.createElement(StyledCreatableValue, null, `"${
|
|
117
|
+
}, /* @__PURE__ */ React2.createElement(StyledCreatableLabel, null, "Add:"), /* @__PURE__ */ React2.createElement(StyledCreatableValue, null, `"${labelCreatable}"`)),
|
|
115
118
|
label: option.label,
|
|
116
119
|
onClick: handleOnCreateClick
|
|
117
120
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/menu-list/useItemRenderer.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { SingleMenuItem, MultiMenuItem, Section, Separator } from '@elliemae/ds-common';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledCreatableLabel, StyledCreatableValue } from './styled';\nimport { isSelected, getSuggestedValueOnChange } from '../../utils/listHelper';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { DSComboboxT } from '../../react-desc-prop-types';\nimport { MENU_OPTION_TYPES, INTERNAL_MENU_OPTION_TYPES } from '../../constants';\nexport const useItemRenderer = (): Array<JSX.Element> | null => {\n const {\n props: { filteredOptions, onCreate, onChange, isNonClearable, selectedValues, onFilter, allOptions },\n setMenuState,\n inputValue,\n focusOptionIdx,\n setInputValue,\n virtualListHelpers,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n const CBItem = multiple ? MultiMenuItem : SingleMenuItem;\n\n const handleOnCreateClick = useCallback(() => {\n if (inputValue && onCreate) {\n onCreate(inputValue);\n setInputValue('');\n if (onFilter) onFilter(allOptions, inputValue);\n }\n }, [onFilter, onCreate, inputValue, allOptions, setInputValue]);\n const handleClick = useCallback(\n (option: DSComboboxT.ItemOption, e: React.MouseEvent) => {\n if (option.type === MENU_OPTION_TYPES.OPTION) {\n if (!option.disabled) {\n if (onFilter) onFilter(allOptions, inputValue);\n setInputValue('');\n if (!multiple) {\n setMenuState(false, 'selectOption', e);\n }\n onChange(getSuggestedValueOnChange(option, selectedValues, isNonClearable), option, e);\n }\n }\n // prevent for loosing focus on input control\n e.stopPropagation();\n e.preventDefault();\n },\n [onFilter, selectedValues, allOptions, onChange, setMenuState, multiple],\n );\n\n // prevent blur from controls input\n const handleOnMouseDown = useCallback((e: React.MouseEvent<HTMLLIElement>) => {\n e.preventDefault();\n }, []);\n\n return useMemo(() => {\n if (!virtualListHelpers) {\n return null;\n }\n return virtualListHelpers.virtualItems.map((vItem) => {\n const option = filteredOptions[vItem.index];\n const generalProps = {\n wrapperStyles: {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${vItem.start}px)`,\n },\n\n key: `${
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACO,MAAM,kBAAkB,MAAiC;AAC9D,QAAM;AAAA,IACJ,OAAO,EAAE,iBAAiB,UAAU,UAAU,gBAAgB,gBAAgB,UAAU;AAAA,IACxF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAE9B,QAAM,WAAW,MAAM,QAAQ,cAAc;AAC7C,QAAM,SAAS,WAAW,gBAAgB;AAE1C,QAAM,sBAAsB,YAAY,MAAM;AAC5C,QAAI,cAAc,UAAU;AAC1B,eAAS,UAAU;AACnB,oBAAc,EAAE;AAChB,UAAI;AAAU,iBAAS,YAAY,UAAU;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,UAAU,UAAU,YAAY,YAAY,aAAa,CAAC;AAC9D,QAAM,cAAc,YAClB,CAAC,QAAgC,MAAwB;AACvD,QAAI,OAAO,SAAS,kBAAkB,QAAQ;AAC5C,UAAI,CAAC,OAAO,UAAU;AACpB,YAAI;AAAU,mBAAS,YAAY,UAAU;AAC7C,sBAAc,EAAE;AAChB,YAAI,CAAC,UAAU;AACb,uBAAa,OAAO,gBAAgB,CAAC;AAAA,QACvC;AACA,iBAAS,0BAA0B,QAAQ,gBAAgB,cAAc,GAAG,QAAQ,CAAC;AAAA,MACvF;AAAA,IACF;AAEA,MAAE,gBAAgB;AAClB,MAAE,eAAe;AAAA,EACnB,GACA,CAAC,UAAU,gBAAgB,YAAY,UAAU,cAAc,QAAQ,CACzE;AAGA,QAAM,oBAAoB,YAAY,CAAC,MAAuC;AAC5E,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,oBAAoB;AACvB,aAAO;AAAA,IACT;AACA,WAAO,mBAAmB,aAAa,IAAI,CAAC,UAAU;AACpD,YAAM,SAAS,gBAAgB,MAAM;AACrC,YAAM,eAAe;AAAA,QACnB,eAAe;AAAA,UACb,UAAU;AAAA,UACV,KAAK;AAAA,UACL,MAAM;AAAA,UACN,OAAO;AAAA,UACP,WAAW,cAAc,MAAM;AAAA,QACjC;AAAA,QAEA,KAAK,GAAG
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { Grid } from '@elliemae/ds-grid';\nimport { SingleMenuItem, MultiMenuItem, Section, Separator } from '@elliemae/ds-common';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\nimport { StyledCreatableLabel, StyledCreatableValue } from './styled';\nimport { isSelected, getSuggestedValueOnChange } from '../../utils/listHelper';\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { DSComboboxT } from '../../react-desc-prop-types';\nimport { MENU_OPTION_TYPES, INTERNAL_MENU_OPTION_TYPES } from '../../constants';\nexport const useItemRenderer = (): Array<JSX.Element> | null => {\n const {\n props: { filteredOptions, onCreate, onChange, isNonClearable, selectedValues, onFilter, allOptions },\n setMenuState,\n inputValue,\n focusOptionIdx,\n setInputValue,\n virtualListHelpers,\n } = useContext(ComboBoxContext);\n\n const multiple = Array.isArray(selectedValues);\n const CBItem = multiple ? MultiMenuItem : SingleMenuItem;\n\n const handleOnCreateClick = useCallback(() => {\n if (inputValue && onCreate) {\n onCreate(inputValue);\n setInputValue('');\n if (onFilter) onFilter(allOptions, inputValue);\n }\n }, [onFilter, onCreate, inputValue, allOptions, setInputValue]);\n const handleClick = useCallback(\n (option: DSComboboxT.ItemOption, e: React.MouseEvent) => {\n if (option.type === MENU_OPTION_TYPES.OPTION) {\n if (!option.disabled) {\n if (onFilter) onFilter(allOptions, inputValue);\n setInputValue('');\n if (!multiple) {\n setMenuState(false, 'selectOption', e);\n }\n onChange(getSuggestedValueOnChange(option, selectedValues, isNonClearable), option, e);\n }\n }\n // prevent for loosing focus on input control\n e.stopPropagation();\n e.preventDefault();\n },\n [onFilter, selectedValues, allOptions, onChange, setMenuState, multiple],\n );\n\n // prevent blur from controls input\n const handleOnMouseDown = useCallback((e: React.MouseEvent<HTMLLIElement>) => {\n e.preventDefault();\n }, []);\n\n return useMemo(() => {\n if (!virtualListHelpers) {\n return null;\n }\n return virtualListHelpers.virtualItems.map((vItem) => {\n const option = filteredOptions[vItem.index];\n const { dsId, type, disabled } = option;\n const generalProps = {\n wrapperStyles: {\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n transform: `translateY(${vItem.start}px)`,\n },\n\n key: `${dsId}`,\n innerRef: vItem.measureRef,\n };\n if (option.type === MENU_OPTION_TYPES.SECTION) {\n return <Section label={option.label} {...generalProps} />;\n }\n if (option.type === MENU_OPTION_TYPES.SEPARATOR) {\n return <Separator {...generalProps} />;\n }\n if (option.type === MENU_OPTION_TYPES.OPTION) {\n return (\n <CBItem\n {...generalProps}\n value={option.value}\n label={option.label}\n dataTestid={ComboboxDataTestid.OPTION}\n disabled={disabled}\n onClick={(e: React.MouseEvent) => {\n handleClick(option, e);\n }}\n onMouseDown={handleOnMouseDown}\n isActive={dsId === focusOptionIdx}\n isSelected={isSelected(selectedValues, option)}\n tabIndex={-1}\n />\n );\n }\n if (type === INTERNAL_MENU_OPTION_TYPES.CREATABLE) {\n return (\n <SingleMenuItem\n dataTestid={ComboboxDataTestid.OPTION}\n isActive={dsId === focusOptionIdx}\n {...generalProps}\n render={({ label: labelCreatable }: { label: string }) => (\n <Grid p=\"8px\" cols={['min-content', 'auto']} gutter=\"xxs\" alignItems=\"center\">\n <StyledCreatableLabel>Add:</StyledCreatableLabel>\n <StyledCreatableValue>{`\"${labelCreatable}\"`}</StyledCreatableValue>\n </Grid>\n )}\n label={option.label}\n onClick={handleOnCreateClick}\n />\n );\n }\n return <></>;\n });\n }, [filteredOptions, focusOptionIdx, selectedValues, virtualListHelpers]);\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACO,MAAM,kBAAkB,MAAiC;AAC9D,QAAM;AAAA,IACJ,OAAO,EAAE,iBAAiB,UAAU,UAAU,gBAAgB,gBAAgB,UAAU;AAAA,IACxF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAE9B,QAAM,WAAW,MAAM,QAAQ,cAAc;AAC7C,QAAM,SAAS,WAAW,gBAAgB;AAE1C,QAAM,sBAAsB,YAAY,MAAM;AAC5C,QAAI,cAAc,UAAU;AAC1B,eAAS,UAAU;AACnB,oBAAc,EAAE;AAChB,UAAI;AAAU,iBAAS,YAAY,UAAU;AAAA,IAC/C;AAAA,EACF,GAAG,CAAC,UAAU,UAAU,YAAY,YAAY,aAAa,CAAC;AAC9D,QAAM,cAAc,YAClB,CAAC,QAAgC,MAAwB;AACvD,QAAI,OAAO,SAAS,kBAAkB,QAAQ;AAC5C,UAAI,CAAC,OAAO,UAAU;AACpB,YAAI;AAAU,mBAAS,YAAY,UAAU;AAC7C,sBAAc,EAAE;AAChB,YAAI,CAAC,UAAU;AACb,uBAAa,OAAO,gBAAgB,CAAC;AAAA,QACvC;AACA,iBAAS,0BAA0B,QAAQ,gBAAgB,cAAc,GAAG,QAAQ,CAAC;AAAA,MACvF;AAAA,IACF;AAEA,MAAE,gBAAgB;AAClB,MAAE,eAAe;AAAA,EACnB,GACA,CAAC,UAAU,gBAAgB,YAAY,UAAU,cAAc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,MAAM,CAAC,eAAe,MAAM;AAAA,YAAG,QAAO;AAAA,YAAM,YAAW;AAAA,aACnE,qCAAC,4BAAqB,MAAI,GAC1B,qCAAC,4BAAsB,IAAI,iBAAkB,CAC/C;AAAA,UAEF,OAAO,OAAO;AAAA,UACd,SAAS;AAAA,UACX;AAAA,MAEJ;AACA,aAAO,0DAAE;AAAA,IACX,CAAC;AAAA,EACH,GAAG,CAAC,iBAAiB,gBAAgB,gBAAgB,kBAAkB,CAAC;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/parts/styled.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { styled } from "@elliemae/ds-system";
|
|
3
3
|
const StyledA11ySelectedValues = styled.span`
|
|
4
|
+
position: absolute;
|
|
4
5
|
width: 1px;
|
|
5
6
|
height: 1px;
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
margin: -1px;
|
|
8
|
+
border: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
clip: rect(0 0 0 0);
|
|
12
|
+
clip-path: inset(100%);
|
|
13
|
+
white-space: nowrap;
|
|
8
14
|
`;
|
|
9
15
|
export {
|
|
10
16
|
StyledA11ySelectedValues
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\n\nexport const StyledA11ySelectedValues = styled.span`\n width: 1px;\n height: 1px;\n
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,2BAA2B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\n\nexport const StyledA11ySelectedValues = styled.span`\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n border: 0;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(100%);\n white-space: nowrap;\n`;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,2BAA2B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -30,7 +30,6 @@ const ComboboxPropTypes = __spreadProps(__spreadValues({}, globalAttributesPropT
|
|
|
30
30
|
autoFocus: PropTypes.bool.description("Whether the combo box uses auto focus or not").defaultValue("false"),
|
|
31
31
|
hasError: PropTypes.bool.description("Whether the combo box has error or not").defaultValue("false"),
|
|
32
32
|
noOptionsMessage: PropTypes.string.description("Custome message to be display when no matches found after filtering").defaultValue("No Matches Found"),
|
|
33
|
-
closeMenuOnScroll: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]).description("If true, close the select menu when the user scrolls the document/body.").defaultValue(false),
|
|
34
33
|
onChange: PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue("() => {}"),
|
|
35
34
|
onFilter: PropTypes.func.description("function triggered when user type in the combobox input").defaultValue(""),
|
|
36
35
|
onCreate: PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(""),
|
|
@@ -41,7 +40,8 @@ const ComboboxPropTypes = __spreadProps(__spreadValues({}, globalAttributesPropT
|
|
|
41
40
|
menuMaxHeight: PropTypes.any.description("Maximum height for the dropdown menu").defaultValue(void 0),
|
|
42
41
|
withoutPortal: PropTypes.bool.description("Whether the combobox menu is rendered in a portal or not").defaultValue(false),
|
|
43
42
|
zIndex: PropTypes.number.description("The z-index of the combobox menu").defaultValue(10),
|
|
44
|
-
innerRef: PropTypes.object.description("ref to the components container")
|
|
43
|
+
innerRef: PropTypes.object.description("ref to the components container"),
|
|
44
|
+
onlySelectable: PropTypes.bool.description("filtering is disabled")
|
|
45
45
|
});
|
|
46
46
|
export {
|
|
47
47
|
ComboboxPropTypes,
|