@elliemae/ds-form-combobox 3.1.4-rc.2 → 3.1.5-rc.2
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 +1 -1
- package/dist/cjs/ComboBoxCTX.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/useKeyboardNavigation.js +4 -8
- package/dist/cjs/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/parts/styled.js +8 -2
- package/dist/cjs/parts/styled.js.map +2 -2
- package/dist/esm/ComboBoxCTX.js +1 -1
- package/dist/esm/ComboBoxCTX.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/useKeyboardNavigation.js +6 -11
- package/dist/esm/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/parts/styled.js +8 -2
- package/dist/esm/parts/styled.js.map +2 -2
- package/package.json +12 -12
package/dist/cjs/ComboBoxCTX.js
CHANGED
|
@@ -38,7 +38,7 @@ 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
43
|
isNonClearable: false
|
|
44
44
|
};
|
|
@@ -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 // 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;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
|
}
|
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};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEvB,mBAAwD;AACxD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A,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
|
}
|
|
@@ -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(() => {
|
|
@@ -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) {\n onChange(getSuggestedValueOnChange(lastValue, selectedValues, isNonClearable), 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 isNonClear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ACA;AAAA,EACF,CACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
|
|
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
|
}
|
package/dist/esm/ComboBoxCTX.js
CHANGED
|
@@ -10,7 +10,7 @@ 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
15
|
isNonClearable: false
|
|
16
16
|
};
|
|
@@ -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 // 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;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
|
}
|
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,OAA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,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
|
}
|
|
@@ -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(() => {
|
|
@@ -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) {\n onChange(getSuggestedValueOnChange(lastValue, selectedValues, isNonClearable), 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
|
+
"mappings": "AAAA;ACIA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA,MAAM,qBAAqB,CAAC,QAC1B,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI,KAAK,CAAC,IAAI;AAEhD,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IAEF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW,eAAe;AAE9B,QAAM,WAAW,MAAM,QAAQ,cAAc;AAC7C,QAAM,oBAAoB,WAAW,eAAe;AACpD,QAAM,mBAAmB,gBAAgB,UAAU,CAAC,QAAQ,IAAI,SAAS,cAAc;AACvF,QAAM,cAAc,gBAAgB,KAAK,CAAC,SAAS,KAAK,SAAS,cAAc;AAE/E,QAAM,iBAA+D,YACnE,CAAC,MAAM;AAIL,QAAI,aAAa,aAAa,SAAS,kBAAkB;AAAQ,gBAAU,GAAG,WAAW;AAEzF,QACG,EAAC,aAAa,WAAW,SAAS,UAAU,EAAE,SAAS,EAAE,GAAG,KAAM,EAAE,WAAW,MAAM,EAAE,WAAW,OACnG,CAAC,WACD;AACA,mBAAa,IAAI;AAAA,IACnB;AAIA,QAAI,EAAE,QAAQ,UAAU;AACtB,UAAI;AAAU,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BAAkB;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
|
}
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-form-combobox",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.5-rc.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Controlled Form Combobox",
|
|
6
6
|
"files": [
|
|
@@ -35,21 +35,21 @@
|
|
|
35
35
|
"indent": 4
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@elliemae/ds-button": "3.1.
|
|
39
|
-
"@elliemae/ds-common": "3.1.
|
|
40
|
-
"@elliemae/ds-form-checkbox": "3.1.
|
|
41
|
-
"@elliemae/ds-grid": "3.1.
|
|
42
|
-
"@elliemae/ds-icons": "3.1.
|
|
43
|
-
"@elliemae/ds-pills": "3.1.
|
|
44
|
-
"@elliemae/ds-popperjs": "3.1.
|
|
45
|
-
"@elliemae/ds-system": "3.1.
|
|
46
|
-
"@elliemae/ds-truncated-tooltip-text": "3.1.
|
|
47
|
-
"@elliemae/ds-utilities": "3.1.
|
|
38
|
+
"@elliemae/ds-button": "3.1.5-rc.2",
|
|
39
|
+
"@elliemae/ds-common": "3.1.5-rc.2",
|
|
40
|
+
"@elliemae/ds-form-checkbox": "3.1.5-rc.2",
|
|
41
|
+
"@elliemae/ds-grid": "3.1.5-rc.2",
|
|
42
|
+
"@elliemae/ds-icons": "3.1.5-rc.2",
|
|
43
|
+
"@elliemae/ds-pills": "3.1.5-rc.2",
|
|
44
|
+
"@elliemae/ds-popperjs": "3.1.5-rc.2",
|
|
45
|
+
"@elliemae/ds-system": "3.1.5-rc.2",
|
|
46
|
+
"@elliemae/ds-truncated-tooltip-text": "3.1.5-rc.2",
|
|
47
|
+
"@elliemae/ds-utilities": "3.1.5-rc.2",
|
|
48
48
|
"react-virtual": "~2.8.2",
|
|
49
49
|
"uid": "~2.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@elliemae/ds-form-helpers-mask-hooks": "3.1.
|
|
52
|
+
"@elliemae/ds-form-helpers-mask-hooks": "3.1.5-rc.2",
|
|
53
53
|
"@elliemae/pui-theme": "~2.6.0",
|
|
54
54
|
"@testing-library/dom": "~8.11.3",
|
|
55
55
|
"@testing-library/jest-dom": "~5.16.2",
|