@elliemae/ds-form-combobox 3.1.4-rc.2 → 3.1.5-rc.11
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
package/dist/cjs/ComboBoxCTX.js
CHANGED
|
@@ -38,9 +38,10 @@ const defaultProps = {
|
|
|
38
38
|
useMask: noop,
|
|
39
39
|
innerRef: (0, import_react.createRef)(),
|
|
40
40
|
startPlacementPreference: "bottom-start",
|
|
41
|
-
placementOrderPreference: ["bottom-start", "
|
|
41
|
+
placementOrderPreference: ["bottom-start", "top-start"],
|
|
42
42
|
noOptionsMessage: "No Matches Found",
|
|
43
|
-
isNonClearable: false
|
|
43
|
+
isNonClearable: false,
|
|
44
|
+
onlySelectable: false
|
|
44
45
|
};
|
|
45
46
|
const defaultContext = {
|
|
46
47
|
props: defaultProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ComboBoxCTX.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { createContext, createRef } from 'react';\nimport { 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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AAMlC,iBAAsC,OAAgB;AAAC;AAEvD,MAAM,eAAyC;AAAA,EACpD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU,4BAAU;AAAA,EACpB,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyC;AAMlC,iBAAsC,OAAgB;AAAC;AAEvD,MAAM,eAAyC;AAAA,EACpD,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU,4BAAU;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,4BAA0B;AAAA,EACxC,SAAS,4BAA0B;AAAA,EACnC,gBAAgB,4BAA0B;AAAA,EAC1C,oBAAoB,4BAA4B;AAAA,EAChD,oBAAoB,4BAA4B;AAAA,EAChD,sBAAsB,4BAA4B;AAAA,EAClD,0BAA0B,4BAA6B;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,gCAAc,cAAc;AAE3D,IAAO,sBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -31,8 +31,9 @@ var import_listHelper = require("../utils/listHelper");
|
|
|
31
31
|
const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
|
|
32
32
|
const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;
|
|
33
33
|
return (0, import_react.useMemo)(() => {
|
|
34
|
-
if (!filteredOptions)
|
|
35
|
-
return
|
|
34
|
+
if (!filteredOptions) {
|
|
35
|
+
return (0, import_listHelper.filterOptions)(inputValue, allOptions);
|
|
36
|
+
}
|
|
36
37
|
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
37
38
|
return (0, import_listHelper.selectedValuesWithSections)(filteredOptions, selectedValues);
|
|
38
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/useCorrectOptions.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AACxB,iBAAoB;AAEpB,uBAAkC;AAClC,
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwB;AACxB,iBAAoB;AAEpB,uBAAkC;AAClC,wBAA0D;AAC1D,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,iBAAiB,YAAY,gBAAgB,aAAa;AAElE,SAAO,0BAAQ,MAAM;AAGnB,QAAI,CAAC,iBAAiB;AACpB,aAAO,qCAAc,YAAY,UAAU;AAAA,IAC7C;AAEA,QAAI,uBAAuB,MAAM,QAAQ,cAAc,KAAK,eAAe,SAAS,GAAG;AACrF,aAAO,kDAA2B,iBAAiB,cAAc;AAAA,IACnE;AAEA,QACE,YACA,cACA,gBAAgB,UAAU,CAAC,WAAW,OAAO,SAAS,mCAAkB,UAAU,OAAO,UAAU,UAAU,MAC3G,IACF;AACA,YAAM,gBAAgB,oBAAI;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/cjs/constants.js
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var constants_exports = {};
|
|
22
22
|
__export(constants_exports, {
|
|
23
23
|
INTERNAL_MENU_OPTION_TYPES: () => INTERNAL_MENU_OPTION_TYPES,
|
|
24
|
+
MENU_CONTROL_REASONS: () => MENU_CONTROL_REASONS,
|
|
24
25
|
MENU_OPTION_TYPES: () => MENU_OPTION_TYPES
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(constants_exports);
|
|
@@ -33,4 +34,10 @@ const MENU_OPTION_TYPES = {
|
|
|
33
34
|
const INTERNAL_MENU_OPTION_TYPES = {
|
|
34
35
|
CREATABLE: "creatable"
|
|
35
36
|
};
|
|
37
|
+
const MENU_CONTROL_REASONS = {
|
|
38
|
+
SELECT_OPTION: "selectOption",
|
|
39
|
+
CLOSE: "close",
|
|
40
|
+
OPEN: "open",
|
|
41
|
+
BLUR: "blur"
|
|
42
|
+
};
|
|
36
43
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/constants.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,oBAAoB;AAAA,EAC/B,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AACb;AAEO,MAAM,6BAA6B;AAAA,EACxC,WAAW;AACb;",
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,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
|
}
|
|
@@ -29,7 +29,6 @@ var import_DropdownIndicator = require("../DropdownIndicator");
|
|
|
29
29
|
var import_ComboboxDataTestids = require("../../ComboboxDataTestids");
|
|
30
30
|
var import_ComboBoxCTX = __toESM(require("../../ComboBoxCTX"));
|
|
31
31
|
var import_styled = require("./styled");
|
|
32
|
-
var import_listHelper = require("../../utils/listHelper");
|
|
33
32
|
var import_multi_selected_values_container = require("../multi-selected-values-container");
|
|
34
33
|
var import_ControlsInput = require("../controls-input/ControlsInput");
|
|
35
34
|
var import_useOnPillsNavigation = require("./useOnPillsNavigation");
|
|
@@ -59,12 +58,6 @@ const Controls = () => {
|
|
|
59
58
|
}
|
|
60
59
|
innerRef.current?.focus();
|
|
61
60
|
setMenuState(true);
|
|
62
|
-
window.requestAnimationFrame(() => {
|
|
63
|
-
window.requestAnimationFrame(() => {
|
|
64
|
-
if (listRef.current)
|
|
65
|
-
(0, import_listHelper.scrollIfNeeded)(listRef.current);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
61
|
}, [disabled, listRef, hasFocus, menuState, inline, innerRef, setMenuState, focusOptionIdx]);
|
|
69
62
|
const handleOnPillsClick = (0, import_react.useCallback)((e) => {
|
|
70
63
|
if (menuState || disabled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls/Controls.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* 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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAwD;AACxD,+BAAkC;AAClC,iCAAmC;AACnC,yBAA4B;AAC5B,oBAKO;
|
|
4
|
+
"sourcesContent": ["/* 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};\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B,sBAAsB,MAAM,IAAI,CAAC,mBAAmB,GACjG,CAAC,MAAM,CACT;AACA,SACE,mDAAC;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,8CAAmB;AAAA,KAE/B,CAAC,UACA,mDAAC;AAAA,IAAgB,KAAK;AAAA,IAAoB,SAAS;AAAA,KACjD,mDAAC,kDAAmB,GACnB,MAAM,QAAQ,cAAc,IAC3B,mDAAC,yEAA6B,IAE9B,mDAAC;AAAA,IAAI,eAAa,8CAAmB;AAAA,KAClC,kBAAkB,mDAAC;AAAA,IAA2B,MAAM;AAAA,GAAgB,CACvE,CAEJ,GAEF,mDAAC,gDAAkB,GAEnB,mDAAC,wCAAc,GACd,CAAC,UACA,mDAAC;AAAA,IAA2B,gBAAe;AAAA,IAAS,MAAM,CAAC,eAAe,aAAa;AAAA,KACrF,mDAAC;AAAA,IAA4B;AAAA,GAAoB,GACjD,mDAAC,gDAAkB,CACrB,CAEJ;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -33,7 +33,7 @@ var import_useControlsInput = require("./useControlsInput");
|
|
|
33
33
|
var import_ComboBoxCTX = require("../../ComboBoxCTX");
|
|
34
34
|
const ControlsInput = () => {
|
|
35
35
|
const {
|
|
36
|
-
props: { autoFocus, placeholder, disabled, innerRef,
|
|
36
|
+
props: { autoFocus, placeholder, disabled, innerRef, onlySelectable },
|
|
37
37
|
focusOptionIdx,
|
|
38
38
|
inputValue,
|
|
39
39
|
menuState
|
|
@@ -63,7 +63,7 @@ const ControlsInput = () => {
|
|
|
63
63
|
onChange: handleOnChange,
|
|
64
64
|
onBlur: handleOnBlur,
|
|
65
65
|
onFocus: handleOnFocus,
|
|
66
|
-
withoutCaret:
|
|
66
|
+
withoutCaret: onlySelectable
|
|
67
67
|
}));
|
|
68
68
|
};
|
|
69
69
|
//# sourceMappingURL=ControlsInput.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/ControlsInput.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import React, { useContext } 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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,uCAA2C;AAE3C,iCAAmC;AACnC,oBAAmG;AACnG,mCAAsC;AACtC,8BAAiC;AACjC,yBAAgC;AAEzB,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,aAAa,UAAU,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW,kCAAe;AAC9B,QAAM,EAAE,mBAAmB,wDAAsB;AACjD,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,kBAC9F,8CAAiB;AACnB,SACE,mDAAC,wCACC,mDAAC;AAAA,IAA0B,KAAK;AAAA,KAAgB,iBAAkB,GACjE,mBACC,mDAAC,4CACC,mDAAC;AAAA,IAA2B,OAAO;AAAA,GAAiB,CACtD,GAGF,mDAAC;AAAA,IACC,eAAa,8CAAmB;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 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAkC;AAClC,uCAA2C;AAE3C,iCAAmC;AACnC,oBAAmG;AACnG,mCAAsC;AACtC,8BAAiC;AACjC,yBAAgC;AAEzB,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,aAAa,UAAU,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW,kCAAe;AAC9B,QAAM,EAAE,mBAAmB,wDAAsB;AACjD,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,kBAC9F,8CAAiB;AACnB,SACE,mDAAC,wCACC,mDAAC;AAAA,IAA0B,KAAK;AAAA,KAAgB,iBAAkB,GACjE,mBACC,mDAAC,4CACC,mDAAC;AAAA,IAA2B,OAAO;AAAA,GAAiB,CACtD,GAGF,mDAAC;AAAA,IACC,eAAa,8CAAmB;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
|
}
|
|
@@ -65,10 +65,6 @@ const useKeyboardNavigation = () => {
|
|
|
65
65
|
onKeyDown(e, currentItem);
|
|
66
66
|
if ((["ArrowDown", "ArrowUp", "Enter", "Spacebar"].includes(e.key) || e.keyCode >= 48 && e.keyCode <= 90) && !menuState) {
|
|
67
67
|
setMenuState(true);
|
|
68
|
-
window.requestAnimationFrame(() => {
|
|
69
|
-
if (listRef.current)
|
|
70
|
-
(0, import_listHelper.scrollIfNeeded)(listRef.current);
|
|
71
|
-
});
|
|
72
68
|
}
|
|
73
69
|
if (e.key === "Escape") {
|
|
74
70
|
if (onCancel)
|
|
@@ -79,7 +75,7 @@ const useKeyboardNavigation = () => {
|
|
|
79
75
|
setInputValue("");
|
|
80
76
|
}
|
|
81
77
|
if (!inline)
|
|
82
|
-
setMenuState(false,
|
|
78
|
+
setMenuState(false, import_constants.MENU_CONTROL_REASONS.CLOSE, e);
|
|
83
79
|
}
|
|
84
80
|
if (e.key === "Enter" && currentItem?.type === import_constants.INTERNAL_MENU_OPTION_TYPES.CREATABLE && onCreate) {
|
|
85
81
|
onCreate(inputValue);
|
|
@@ -97,7 +93,7 @@ const useKeyboardNavigation = () => {
|
|
|
97
93
|
onFilter(allOptions, "");
|
|
98
94
|
setInputValue("");
|
|
99
95
|
if (!multiple) {
|
|
100
|
-
setMenuState(false,
|
|
96
|
+
setMenuState(false, import_constants.MENU_CONTROL_REASONS.SELECT_OPTION, e);
|
|
101
97
|
}
|
|
102
98
|
onChange((0, import_listHelper.getSuggestedValueOnChange)(currentItem, selectedValues, isNonClearable), currentItem, e);
|
|
103
99
|
}
|
|
@@ -130,7 +126,7 @@ const useKeyboardNavigation = () => {
|
|
|
130
126
|
setFocusOptionIdx(filteredOptions[prevItemIndex].dsId);
|
|
131
127
|
scrollOptionIntoView(filteredOptions[prevItemIndex].dsId);
|
|
132
128
|
} else {
|
|
133
|
-
setMenuState(true,
|
|
129
|
+
setMenuState(true, import_constants.MENU_CONTROL_REASONS.OPEN, e);
|
|
134
130
|
const lastItemIndex = (0, import_listHelper.findInCircularList)(filteredOptions, 0, isOptionFocuseable, -1);
|
|
135
131
|
setFocusOptionIdx(filteredOptions[lastItemIndex].dsId);
|
|
136
132
|
setTimeout(() => {
|
|
@@ -141,8 +137,8 @@ const useKeyboardNavigation = () => {
|
|
|
141
137
|
}
|
|
142
138
|
if (e.key === "Backspace" && e.currentTarget.value.length <= 0 && !inline) {
|
|
143
139
|
const lastValue = (0, import_listHelper.getLastValueSelected)(selectedValues);
|
|
144
|
-
if (!e.currentTarget.value && lastValue) {
|
|
145
|
-
onChange((0, import_listHelper.getSuggestedValueOnChange)(lastValue, selectedValues
|
|
140
|
+
if (!e.currentTarget.value && lastValue && !isNonClearable) {
|
|
141
|
+
onChange((0, import_listHelper.getSuggestedValueOnChange)(lastValue, selectedValues), lastValue, e);
|
|
146
142
|
}
|
|
147
143
|
}
|
|
148
144
|
if (e.key === "Tab" && !inline && menuState) {
|
|
@@ -151,7 +147,7 @@ const useKeyboardNavigation = () => {
|
|
|
151
147
|
e.preventDefault();
|
|
152
148
|
element.focus();
|
|
153
149
|
} else {
|
|
154
|
-
setMenuState(false,
|
|
150
|
+
setMenuState(false, import_constants.MENU_CONTROL_REASONS.BLUR, e);
|
|
155
151
|
}
|
|
156
152
|
}
|
|
157
153
|
}, [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/useKeyboardNavigation.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* 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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAwC;AAExC,yBAAgC;AAChC,
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,mBAAwC;AAExC,yBAAgC;AAChC,wBAKO;AACP,uBAAoF;AACpF,MAAM,qBAAqB,CAAC,QAC1B,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI,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,MAAM,CAAC;AAC/C,gBAAM,gBAAgB,0CAAmB,iBAAiB,GAAG,oBAAoB,EAAE;AACnF,4BAAkB,gBAAgB,eAAe,IAAI;AACrD,qBAAW,MAAM;AACf,iCAAqB,gBAAgB,eAAe,IAAI;AAAA,UAC1D,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAKA,QAAI,EAAE,QAAQ,eAAe,EAAE,cAAc,MAAM,UAAU,KAAK,CAAC,QAAQ;AACzE,YAAM,YAAY,4CAAqB,cAAc;AACrD,UAAI,CAAC,EAAE,cAAc,SAAS,aAAa,CAAC,gBAAgB;AAC1D,iBAAS,iDAA0B,WAAW,cAAc,GAAG,WAAW,CAAC;AAAA,MAC7E;AAAA,IACF;AAEA,QAAI,EAAE,QAAQ,SAAS,CAAC,UAAU,WAAW;AAC3C,YAAM,UAAU,qBAAqB,WAAW,yBAAyB;AACzE,UAAI,SAAS;AACX,UAAE,eAAe;AACjB,gBAAQ,MAAM;AAAA,MAChB,OAAO;AACL,qBAAa,OAAO,sCAAqB,MAAM,CAAC;AAAA,MAClD;AAAA,IACF;AAAA,EACF,GAEA;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,kBAAkB;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,7 +29,7 @@ var import_ComboBoxCTX = __toESM(require("../../ComboBoxCTX"));
|
|
|
29
29
|
var import_listHelper = require("../../utils/listHelper");
|
|
30
30
|
const useMaskedOnChange = () => {
|
|
31
31
|
const {
|
|
32
|
-
props: { useMask, onFilter, allOptions },
|
|
32
|
+
props: { useMask, onlySelectable, onFilter, allOptions },
|
|
33
33
|
setMenuState,
|
|
34
34
|
setInputValue,
|
|
35
35
|
setShowSelectedOptions
|
|
@@ -37,11 +37,12 @@ const useMaskedOnChange = () => {
|
|
|
37
37
|
const handleOnChange = (0, import_react.useCallback)((e) => {
|
|
38
38
|
setShowSelectedOptions(false);
|
|
39
39
|
setMenuState(true, "filter", e);
|
|
40
|
-
if (onFilter) {
|
|
40
|
+
if (onFilter && !onlySelectable) {
|
|
41
41
|
onFilter((0, import_listHelper.filterOptions)(e.currentTarget.value, allOptions), e.currentTarget.value);
|
|
42
|
-
setInputValue(e.currentTarget.value);
|
|
43
42
|
}
|
|
44
|
-
|
|
43
|
+
if (!onlySelectable)
|
|
44
|
+
setInputValue(e.currentTarget.value);
|
|
45
|
+
}, [allOptions, onlySelectable, onFilter, setInputValue, setMenuState, setShowSelectedOptions]);
|
|
45
46
|
const handleOnChangeMask = (0, import_react.useCallback)((e, mask) => {
|
|
46
47
|
setShowSelectedOptions(false);
|
|
47
48
|
setMenuState(true, "filter", e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/controls-input/useMaskedOnChange.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwC;AACxC,yBAA4B;AAC5B,wBAA8B;AAE9B,MAAM,oBAAoB,MAAM;AAC9B,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,UAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAwC;AACxC,yBAA4B;AAC5B,wBAA8B;AAE9B,MAAM,oBAAoB,MAAM;AAC9B,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,gBAAgB,UAAU;AAAA,IAC5C;AAAA,IACA;AAAA,IACA;AAAA,MACE,6BAAW,0BAAe;AAG9B,QAAM,iBAAiB,8BACrB,CAAC,MAA2C;AAC1C,2BAAuB,KAAK;AAC5B,iBAAa,MAAM,UAAU,CAAC;AAC9B,QAAI,YAAY,CAAC,gBAAgB;AAE/B,eAAS,qCAAc,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,8BACzB,CAAC,GAAwC,SAAkB;AACzD,2BAAuB,KAAK;AAC5B,iBAAa,MAAM,UAAU,CAAC;AAC9B,QAAI,QAAQ;AAAU,eAAS,qCAAc,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
|
}
|
|
@@ -92,6 +92,7 @@ const useItemRenderer = () => {
|
|
|
92
92
|
}
|
|
93
93
|
return virtualListHelpers.virtualItems.map((vItem) => {
|
|
94
94
|
const option = filteredOptions[vItem.index];
|
|
95
|
+
const { dsId, type, disabled } = option;
|
|
95
96
|
const generalProps = {
|
|
96
97
|
wrapperStyles: {
|
|
97
98
|
position: "absolute",
|
|
@@ -100,7 +101,7 @@ const useItemRenderer = () => {
|
|
|
100
101
|
width: "100%",
|
|
101
102
|
transform: `translateY(${vItem.start}px)`
|
|
102
103
|
},
|
|
103
|
-
key: `${
|
|
104
|
+
key: `${dsId}`,
|
|
104
105
|
innerRef: vItem.measureRef
|
|
105
106
|
};
|
|
106
107
|
if (option.type === import_constants.MENU_OPTION_TYPES.SECTION) {
|
|
@@ -116,25 +117,27 @@ const useItemRenderer = () => {
|
|
|
116
117
|
value: option.value,
|
|
117
118
|
label: option.label,
|
|
118
119
|
dataTestid: import_ComboboxDataTestids.ComboboxDataTestid.OPTION,
|
|
119
|
-
disabled
|
|
120
|
-
onClick: (e) =>
|
|
120
|
+
disabled,
|
|
121
|
+
onClick: (e) => {
|
|
122
|
+
handleClick(option, e);
|
|
123
|
+
},
|
|
121
124
|
onMouseDown: handleOnMouseDown,
|
|
122
|
-
isActive:
|
|
125
|
+
isActive: dsId === focusOptionIdx,
|
|
123
126
|
isSelected: (0, import_listHelper.isSelected)(selectedValues, option),
|
|
124
127
|
tabIndex: -1
|
|
125
128
|
}));
|
|
126
129
|
}
|
|
127
|
-
if (
|
|
130
|
+
if (type === import_constants.INTERNAL_MENU_OPTION_TYPES.CREATABLE) {
|
|
128
131
|
return /* @__PURE__ */ import_react.default.createElement(import_ds_common.SingleMenuItem, __spreadProps(__spreadValues({
|
|
129
132
|
dataTestid: import_ComboboxDataTestids.ComboboxDataTestid.OPTION,
|
|
130
|
-
isActive:
|
|
133
|
+
isActive: dsId === focusOptionIdx
|
|
131
134
|
}, generalProps), {
|
|
132
|
-
render: ({ label }) => /* @__PURE__ */ import_react.default.createElement(import_ds_grid.Grid, {
|
|
135
|
+
render: ({ label: labelCreatable }) => /* @__PURE__ */ import_react.default.createElement(import_ds_grid.Grid, {
|
|
133
136
|
p: "8px",
|
|
134
137
|
cols: ["min-content", "auto"],
|
|
135
138
|
gutter: "xxs",
|
|
136
139
|
alignItems: "center"
|
|
137
|
-
}, /* @__PURE__ */ import_react.default.createElement(import_styled.StyledCreatableLabel, null, "Add:"), /* @__PURE__ */ import_react.default.createElement(import_styled.StyledCreatableValue, null, `"${
|
|
140
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_styled.StyledCreatableLabel, null, "Add:"), /* @__PURE__ */ import_react.default.createElement(import_styled.StyledCreatableValue, null, `"${labelCreatable}"`)),
|
|
138
141
|
label: option.label,
|
|
139
142
|
onClick: handleOnCreateClick
|
|
140
143
|
}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/menu-list/useItemRenderer.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* 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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAwD;AACxD,qBAAqB;AACrB,uBAAkE;AAClE,yBAAgC;AAChC,oBAA2D;AAC3D,wBAAsD;AACtD,iCAAmC;AAEnC,uBAA8D;AACvD,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,6BAAW,kCAAe;AAE9B,QAAM,WAAW,MAAM,QAAQ,cAAc;AAC7C,QAAM,SAAS,WAAW,iCAAgB;AAE1C,QAAM,sBAAsB,8BAAY,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,8BAClB,CAAC,QAAgC,MAAwB;AACvD,QAAI,OAAO,SAAS,mCAAkB,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,iDAA0B,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,8BAAY,CAAC,MAAuC;AAC5E,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SAAO,0BAAQ,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": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,mBAAwD;AACxD,qBAAqB;AACrB,uBAAkE;AAClE,yBAAgC;AAChC,oBAA2D;AAC3D,wBAAsD;AACtD,iCAAmC;AAEnC,uBAA8D;AACvD,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,6BAAW,kCAAe;AAE9B,QAAM,WAAW,MAAM,QAAQ,cAAc;AAC7C,QAAM,SAAS,WAAW,iCAAgB;AAE1C,QAAM,sBAAsB,8BAAY,MAAM;AAC5C,QAAI,cAAc,UAAU;AAC1B,eAAS,UAAU;AACnB,oBAAc,EAAE;AAChB,UAAI;AAAU,iBAAS,YAAY,UAAU;AAAA,IAC/C;AAAA,EACF,GA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,UAEC,OAAO,OAAO;AAAA,UACd,OAAO,OAAO;AAAA,UACd,YAAY,8CAAmB;AAAA,UAC/B;AAAA,UACA,SAAS,CAAC,MAAwB;AAChC,wBAAY,QAAQ,CAAC;AAAA,UACvB;AAAA,UACA,aAAa;AAAA,UACb,UAAU,SAAS;AAAA,UACnB,YAAY,kCAAW,gBAAgB,MAAM;AAAA,UAC7C,UAAU;AAAA,UACZ;AAAA,MAEJ;AACA,UAAI,SAAS,4CAA2B,WAAW;AACjD,eACE,mDAAC;AAAA,UACC,YAAY,8CAAmB;AAAA,UAC/B,UAAU,SAAS;AAAA,WACf,eAHL;AAAA,UAIC,QAAQ,CAAC,EAAE,OAAO,qBAChB,mDAAC;AAAA,YAAK,GAAE;AAAA,YAAM,MAAM,CAAC,eAAe,MAAM;AAAA,YAAG,QAAO;AAAA,YAAM,YAAW;AAAA,aACnE,mDAAC,0CAAqB,MAAI,GAC1B,mDAAC,0CAAsB,IAAI,iBAAkB,CAC/C;AAAA,UAEF,OAAO,OAAO;AAAA,UACd,SAAS;AAAA,UACX;AAAA,MAEJ;AACA,aAAO,sFAAE;AAAA,IACX,CAAC;AAAA,EACH,GAAG,CAAC,iBAAiB,gBAAgB,gBAAgB,kBAAkB,CAAC;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/cjs/parts/styled.js
CHANGED
|
@@ -26,9 +26,15 @@ module.exports = __toCommonJS(styled_exports);
|
|
|
26
26
|
var React = __toESM(require("react"));
|
|
27
27
|
var import_ds_system = require("@elliemae/ds-system");
|
|
28
28
|
const StyledA11ySelectedValues = import_ds_system.styled.span`
|
|
29
|
+
position: absolute;
|
|
29
30
|
width: 1px;
|
|
30
31
|
height: 1px;
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
margin: -1px;
|
|
33
|
+
border: 0;
|
|
34
|
+
padding: 0;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
clip: rect(0 0 0 0);
|
|
37
|
+
clip-path: inset(100%);
|
|
38
|
+
white-space: nowrap;
|
|
33
39
|
`;
|
|
34
40
|
//# sourceMappingURL=styled.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/parts/styled.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { styled } from '@elliemae/ds-system';\n\nexport const StyledA11ySelectedValues = styled.span`\n width: 1px;\n height: 1px;\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAuB;AAEhB,MAAM,2BAA2B,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAuB;AAEhB,MAAM,2BAA2B,wBAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -54,7 +54,6 @@ const ComboboxPropTypes = __spreadProps(__spreadValues({}, import_ds_utilities.g
|
|
|
54
54
|
autoFocus: import_ds_utilities.PropTypes.bool.description("Whether the combo box uses auto focus or not").defaultValue("false"),
|
|
55
55
|
hasError: import_ds_utilities.PropTypes.bool.description("Whether the combo box has error or not").defaultValue("false"),
|
|
56
56
|
noOptionsMessage: import_ds_utilities.PropTypes.string.description("Custome message to be display when no matches found after filtering").defaultValue("No Matches Found"),
|
|
57
|
-
closeMenuOnScroll: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.func, import_ds_utilities.PropTypes.bool]).description("If true, close the select menu when the user scrolls the document/body.").defaultValue(false),
|
|
58
57
|
onChange: import_ds_utilities.PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue("() => {}"),
|
|
59
58
|
onFilter: import_ds_utilities.PropTypes.func.description("function triggered when user type in the combobox input").defaultValue(""),
|
|
60
59
|
onCreate: import_ds_utilities.PropTypes.func.description('function triggered when user select "create" a new item whenever is not a match in the all option list').defaultValue(""),
|
|
@@ -65,6 +64,7 @@ const ComboboxPropTypes = __spreadProps(__spreadValues({}, import_ds_utilities.g
|
|
|
65
64
|
menuMaxHeight: import_ds_utilities.PropTypes.any.description("Maximum height for the dropdown menu").defaultValue(void 0),
|
|
66
65
|
withoutPortal: import_ds_utilities.PropTypes.bool.description("Whether the combobox menu is rendered in a portal or not").defaultValue(false),
|
|
67
66
|
zIndex: import_ds_utilities.PropTypes.number.description("The z-index of the combobox menu").defaultValue(10),
|
|
68
|
-
innerRef: import_ds_utilities.PropTypes.object.description("ref to the components container")
|
|
67
|
+
innerRef: import_ds_utilities.PropTypes.object.description("ref to the components container"),
|
|
68
|
+
onlySelectable: import_ds_utilities.PropTypes.bool.description("filtering is disabled")
|
|
69
69
|
});
|
|
70
70
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport React from 'react';\nimport { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport { DSMaskT } from '@elliemae/ds-form-helpers-mask-hooks';\nexport function noop<T extends unknown[]>(..._args: T): void {}\n\nexport declare namespace DSComboboxT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n }\n\n export interface ItemCreatableOption extends CommonItemOptions {\n label: string;\n type: 'creatable';\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions | ItemCreatableOption;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n export interface PropsOptional {\n inputMinWidth?: number;\n menuMinWidth?: number;\n menuMaxHeight?: number;\n placeholder?: string;\n autoFocus?: boolean;\n filteredOptions: OptionTypes[];\n isMenuOpen?: boolean;\n onMenuChange?: (\n state: boolean,\n reason: string,\n e: React.KeyboardEvent | React.MouseEvent | React.ChangeEvent<HTMLInputElement>,\n ) => void;\n onCreate?: (label: string) => void;\n onFilter?: (newOptions: OptionTypes[], inputValue?: string) => void;\n onCancel?: () => void;\n onSelectAll?: (suggestedValue: OptionTypes[] | [], event: React.MouseEvent | React.KeyboardEvent) => null;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: ItemOption) => void;\n zIndex?: number;\n }\n\n export interface RequiredProps {\n allOptions: OptionTypes[];\n selectedValues: SelectedOptionsT;\n onChange: (\n suggestedValue: ItemOption | OptionTypes[] | null,\n selectedOption: ItemOption,\n event: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: string[];\n hasError: boolean;\n inline: boolean;\n withoutPortal: boolean;\n isNonClearable: boolean;\n disabled: boolean;\n noOptionsMessage: string;\n innerRef: React.RefObject<HTMLInputElement>;\n useMask: DSMaskT.Hook | typeof noop;\n }\n\n export interface Props extends Partial<DefaultProps>, RequiredProps, PropsOptional {}\n\n export interface InternalProps extends DefaultProps, RequiredProps, PropsOptional {}\n}\n\nexport const ComboboxPropTypes = {\n ...globalAttributesPropTypes,\n placeholder: PropTypes.string.description(\"input's placeholder value\").defaultValue(''),\n allOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of original options')\n .defaultValue([]),\n filteredOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .description('List of filtered options to show in the menu based on the current internal input filter value')\n .defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).isRequired.description(\n 'Array of option or single option selected',\n ),\n disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n noOptionsMessage: PropTypes.string\n .description('Custome message to be display when no matches found after filtering')\n .defaultValue('No Matches Found'),\n
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,0BAAqD;AAE9C,iBAAsC,OAAgB;AAAC;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport React from 'react';\nimport { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-utilities';\nimport { DSMaskT } from '@elliemae/ds-form-helpers-mask-hooks';\nexport function noop<T extends unknown[]>(..._args: T): void {}\n\nexport declare namespace DSComboboxT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n }\n\n export interface ItemCreatableOption extends CommonItemOptions {\n label: string;\n type: 'creatable';\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions | ItemCreatableOption;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n export interface PropsOptional {\n inputMinWidth?: number;\n menuMinWidth?: number;\n menuMaxHeight?: number;\n placeholder?: string;\n autoFocus?: boolean;\n filteredOptions: OptionTypes[];\n isMenuOpen?: boolean;\n onMenuChange?: (\n state: boolean,\n reason: string,\n e: React.KeyboardEvent | React.MouseEvent | React.ChangeEvent<HTMLInputElement>,\n ) => void;\n onCreate?: (label: string) => void;\n onFilter?: (newOptions: OptionTypes[], inputValue?: string) => void;\n onCancel?: () => void;\n onSelectAll?: (suggestedValue: OptionTypes[] | [], event: React.MouseEvent | React.KeyboardEvent) => null;\n onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>, value: ItemOption) => void;\n zIndex?: number;\n }\n\n export interface RequiredProps {\n allOptions: OptionTypes[];\n selectedValues: SelectedOptionsT;\n onChange: (\n suggestedValue: ItemOption | OptionTypes[] | null,\n selectedOption: ItemOption,\n event: React.MouseEvent | React.KeyboardEvent,\n ) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: string[];\n hasError: boolean;\n inline: boolean;\n withoutPortal: boolean;\n isNonClearable: boolean;\n disabled: boolean;\n noOptionsMessage: string;\n innerRef: React.RefObject<HTMLInputElement>;\n useMask: DSMaskT.Hook | typeof noop;\n onlySelectable: boolean;\n }\n\n export interface Props extends Partial<DefaultProps>, RequiredProps, PropsOptional {}\n\n export interface InternalProps extends DefaultProps, RequiredProps, PropsOptional {}\n}\n\nexport const ComboboxPropTypes = {\n ...globalAttributesPropTypes,\n placeholder: PropTypes.string.description(\"input's placeholder value\").defaultValue(''),\n allOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of original options')\n .defaultValue([]),\n filteredOptions: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .description('List of filtered options to show in the menu based on the current internal input filter value')\n .defaultValue([]),\n selectedValues: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.object]).isRequired.description(\n 'Array of option or single option selected',\n ),\n disabled: PropTypes.bool.description('wheter or not the input is disabled').defaultValue('false'),\n autoFocus: PropTypes.bool.description('Whether the combo box uses auto focus or not').defaultValue('false'),\n hasError: PropTypes.bool.description('Whether the combo box has error or not').defaultValue('false'),\n noOptionsMessage: PropTypes.string\n .description('Custome message to be display when no matches found after filtering')\n .defaultValue('No Matches Found'),\n onChange: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue('() => {}'),\n onFilter: PropTypes.func.description('function triggered when user type in the combobox input').defaultValue(''),\n onCreate: PropTypes.func\n .description(\n 'function triggered when user select \"create\" a new item whenever is not a match in the all option list',\n )\n .defaultValue(''),\n onCancel: PropTypes.func.description('function triggered when user press ESC key').defaultValue('() => {}'),\n onMenuChange: PropTypes.func\n .description('function triggered when user open or close the menu list')\n .defaultValue('() => {}'),\n inputMinWidth: PropTypes.any.description('Minimum width for the combo box input controller').defaultValue(undefined),\n menuMinWidth: PropTypes.any.description('Minimum width for the dropdown menu').defaultValue(undefined),\n menuMaxHeight: PropTypes.any.description('Maximum height for the dropdown menu').defaultValue(undefined),\n withoutPortal: PropTypes.bool\n .description('Whether the combobox menu is rendered in a portal or not')\n .defaultValue(false),\n zIndex: PropTypes.number.description('The z-index of the combobox menu').defaultValue(10),\n innerRef: PropTypes.object.description('ref to the components container'),\n onlySelectable: PropTypes.bool.description('filtering is disabled'),\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,0BAAqD;AAE9C,iBAAsC,OAAgB;AAAC;AAgFvD,MAAM,oBAAoB,iCAC5B,gDAD4B;AAAA,EAE/B,aAAa,8BAAU,OAAO,YAAY,2BAA2B,EAAE,aAAa,EAAE;AA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kCAAkC,EAAE,aAAa,EAAE;AAAA,EACxF,UAAU,8BAAU,OAAO,YAAY,iCAAiC;AAAA,EACxE,gBAAgB,8BAAU,KAAK,YAAY,uBAAuB;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -92,7 +92,7 @@ const getSuggestedValueOnChange = (selectedOption, selectedValues, isNonClearabl
|
|
|
92
92
|
return selectedOption;
|
|
93
93
|
};
|
|
94
94
|
const filterOptions = (inputValue, options) => {
|
|
95
|
-
if (inputValue
|
|
95
|
+
if (!inputValue)
|
|
96
96
|
return options;
|
|
97
97
|
return options.filter((option) => option.type === import_constants.MENU_OPTION_TYPES.OPTION && option.label.toLowerCase().includes(inputValue.toLowerCase()));
|
|
98
98
|
};
|