@elliemae/ds-controlled-form 3.0.0-next.14 → 3.0.0-next.18
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/autocomplete/Autocomplete.js +5 -6
- package/dist/cjs/autocomplete/Autocomplete.js.map +2 -2
- package/dist/cjs/autocomplete/AutocompleteCTX.js +3 -14
- package/dist/cjs/autocomplete/AutocompleteCTX.js.map +2 -2
- package/dist/cjs/autocomplete/AutocompleteDataTestids.js +1 -7
- package/dist/cjs/autocomplete/AutocompleteDataTestids.js.map +2 -2
- package/dist/cjs/autocomplete/config/useAutocomplete.js +23 -11
- package/dist/cjs/autocomplete/config/useAutocomplete.js.map +3 -3
- package/dist/cjs/autocomplete/parts/container/Container.js +27 -17
- package/dist/cjs/autocomplete/parts/container/Container.js.map +2 -2
- package/dist/cjs/autocomplete/parts/container/styled.js +0 -5
- package/dist/cjs/autocomplete/parts/container/styled.js.map +2 -2
- package/dist/cjs/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +18 -24
- package/dist/cjs/autocomplete/parts/container/useKeyboardNavigation.js.map +7 -0
- package/dist/cjs/autocomplete/parts/menu-list/MenuList.js +5 -25
- package/dist/cjs/autocomplete/parts/menu-list/MenuList.js.map +2 -2
- package/dist/cjs/autocomplete/parts/menu-list/styled.js +2 -4
- package/dist/cjs/autocomplete/parts/menu-list/styled.js.map +2 -2
- package/dist/cjs/autocomplete/parts/menu-list/useItemRenderer.js +33 -35
- package/dist/cjs/autocomplete/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/autocomplete/react-desc-prop-types.js +4 -9
- package/dist/cjs/autocomplete/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/autocomplete/sharedTypes.js.map +1 -1
- package/dist/cjs/autocomplete/{config/constants.js → tests/utils.js} +27 -13
- package/dist/cjs/autocomplete/tests/utils.js.map +7 -0
- package/dist/cjs/autocomplete/utils/listHelper.js +8 -12
- package/dist/cjs/autocomplete/utils/listHelper.js.map +2 -2
- package/dist/cjs/combobox/config/useComboBox.js +7 -1
- package/dist/cjs/combobox/config/useComboBox.js.map +2 -2
- package/dist/cjs/combobox/config/useCorrectOptions.js +10 -29
- package/dist/cjs/combobox/config/useCorrectOptions.js.map +2 -2
- package/dist/cjs/combobox/parts/A11yFocusedOption.js +3 -3
- package/dist/cjs/combobox/parts/A11yFocusedOption.js.map +2 -2
- package/dist/cjs/combobox/parts/controls/Controls.js +3 -1
- package/dist/cjs/combobox/parts/controls/Controls.js.map +2 -2
- package/dist/cjs/combobox/parts/controls-input/ControlsInput.js +2 -1
- package/dist/cjs/combobox/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/cjs/combobox/parts/controls-input/styled.js +3 -0
- package/dist/cjs/combobox/parts/controls-input/styled.js.map +2 -2
- package/dist/cjs/combobox/parts/controls-input/useControlsInput.js +4 -5
- package/dist/cjs/combobox/parts/controls-input/useControlsInput.js.map +2 -2
- package/dist/cjs/combobox/parts/controls-input/useKeyboardNavigation.js +32 -29
- package/dist/cjs/combobox/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/combobox/parts/controls-input/useMaskedOnChange.js +8 -5
- package/dist/cjs/combobox/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/cjs/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/dist/cjs/combobox/parts/header-list/useHeaderListHandlers.js.map +2 -2
- package/dist/cjs/combobox/parts/menu-list/MenuList.js +13 -10
- package/dist/cjs/combobox/parts/menu-list/MenuList.js.map +2 -2
- package/dist/cjs/combobox/parts/menu-list/styled.js +2 -1
- package/dist/cjs/combobox/parts/menu-list/styled.js.map +2 -2
- package/dist/cjs/combobox/parts/menu-list/useItemRenderer.js +7 -7
- package/dist/cjs/combobox/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js +7 -7
- package/dist/cjs/combobox/parts/menu-list/useMenuListSetFocusOption.js.map +2 -2
- package/dist/cjs/combobox/react-desc-prop-types.js +2 -1
- package/dist/cjs/combobox/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/combobox/utils/listHelper.js +34 -11
- package/dist/cjs/combobox/utils/listHelper.js.map +2 -2
- package/dist/cjs/mask-hook/hooks/index.js +1 -1
- package/dist/cjs/mask-hook/hooks/index.js.map +1 -1
- package/dist/cjs/mask-hook/hooks/useNumberMask.js +5 -0
- package/dist/cjs/mask-hook/hooks/useNumberMask.js.map +2 -2
- package/dist/cjs/mask-hook/hooks/usePhoneMask.js +5 -0
- package/dist/cjs/mask-hook/hooks/usePhoneMask.js.map +2 -2
- package/dist/cjs/mask-hook/hooks/useSSNMask.js +5 -0
- package/dist/cjs/mask-hook/hooks/useSSNMask.js.map +2 -2
- package/dist/cjs/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +13 -8
- package/dist/cjs/mask-hook/hooks/{useZipCode.js.map → useZipCodeMask.js.map} +3 -3
- package/dist/esm/autocomplete/Autocomplete.js +2 -3
- package/dist/esm/autocomplete/Autocomplete.js.map +2 -2
- package/dist/esm/autocomplete/AutocompleteCTX.js +3 -14
- package/dist/esm/autocomplete/AutocompleteCTX.js.map +2 -2
- package/dist/esm/autocomplete/AutocompleteDataTestids.js +1 -7
- package/dist/esm/autocomplete/AutocompleteDataTestids.js.map +2 -2
- package/dist/esm/autocomplete/config/useAutocomplete.js +24 -12
- package/dist/esm/autocomplete/config/useAutocomplete.js.map +3 -3
- package/dist/esm/autocomplete/parts/container/Container.js +28 -18
- package/dist/esm/autocomplete/parts/container/Container.js.map +2 -2
- package/dist/esm/autocomplete/parts/container/styled.js +0 -5
- package/dist/esm/autocomplete/parts/container/styled.js.map +2 -2
- package/dist/esm/autocomplete/parts/{controls → container}/useKeyboardNavigation.js +18 -24
- package/dist/esm/autocomplete/parts/container/useKeyboardNavigation.js.map +7 -0
- package/dist/esm/autocomplete/parts/menu-list/MenuList.js +6 -26
- package/dist/esm/autocomplete/parts/menu-list/MenuList.js.map +2 -2
- package/dist/esm/autocomplete/parts/menu-list/styled.js +2 -4
- package/dist/esm/autocomplete/parts/menu-list/styled.js.map +2 -2
- package/dist/esm/autocomplete/parts/menu-list/useItemRenderer.js +33 -35
- package/dist/esm/autocomplete/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/autocomplete/react-desc-prop-types.js +4 -9
- package/dist/esm/autocomplete/react-desc-prop-types.js.map +2 -2
- package/dist/esm/autocomplete/tests/utils.js +27 -0
- package/dist/esm/autocomplete/tests/utils.js.map +7 -0
- package/dist/esm/autocomplete/utils/listHelper.js +8 -12
- package/dist/esm/autocomplete/utils/listHelper.js.map +2 -2
- package/dist/esm/combobox/config/useComboBox.js +7 -1
- package/dist/esm/combobox/config/useComboBox.js.map +2 -2
- package/dist/esm/combobox/config/useCorrectOptions.js +11 -30
- package/dist/esm/combobox/config/useCorrectOptions.js.map +2 -2
- package/dist/esm/combobox/parts/A11yFocusedOption.js +3 -3
- package/dist/esm/combobox/parts/A11yFocusedOption.js.map +2 -2
- package/dist/esm/combobox/parts/controls/Controls.js +3 -1
- package/dist/esm/combobox/parts/controls/Controls.js.map +2 -2
- package/dist/esm/combobox/parts/controls-input/ControlsInput.js +2 -1
- package/dist/esm/combobox/parts/controls-input/ControlsInput.js.map +2 -2
- package/dist/esm/combobox/parts/controls-input/styled.js +3 -0
- package/dist/esm/combobox/parts/controls-input/styled.js.map +2 -2
- package/dist/esm/combobox/parts/controls-input/useControlsInput.js +4 -5
- package/dist/esm/combobox/parts/controls-input/useControlsInput.js.map +2 -2
- package/dist/esm/combobox/parts/controls-input/useKeyboardNavigation.js +32 -29
- package/dist/esm/combobox/parts/controls-input/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/combobox/parts/controls-input/useMaskedOnChange.js +8 -5
- package/dist/esm/combobox/parts/controls-input/useMaskedOnChange.js.map +2 -2
- package/dist/esm/combobox/parts/header-list/useHeaderListHandlers.js +4 -4
- package/dist/esm/combobox/parts/header-list/useHeaderListHandlers.js.map +2 -2
- package/dist/esm/combobox/parts/menu-list/MenuList.js +13 -10
- package/dist/esm/combobox/parts/menu-list/MenuList.js.map +2 -2
- package/dist/esm/combobox/parts/menu-list/styled.js +2 -1
- package/dist/esm/combobox/parts/menu-list/styled.js.map +2 -2
- package/dist/esm/combobox/parts/menu-list/useItemRenderer.js +7 -7
- package/dist/esm/combobox/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js +7 -7
- package/dist/esm/combobox/parts/menu-list/useMenuListSetFocusOption.js.map +2 -2
- package/dist/esm/combobox/react-desc-prop-types.js +2 -1
- package/dist/esm/combobox/react-desc-prop-types.js.map +2 -2
- package/dist/esm/combobox/utils/listHelper.js +34 -11
- package/dist/esm/combobox/utils/listHelper.js.map +2 -2
- package/dist/esm/mask-hook/hooks/index.js +1 -1
- package/dist/esm/mask-hook/hooks/index.js.map +1 -1
- package/dist/esm/mask-hook/hooks/useNumberMask.js +5 -0
- package/dist/esm/mask-hook/hooks/useNumberMask.js.map +2 -2
- package/dist/esm/mask-hook/hooks/usePhoneMask.js +5 -0
- package/dist/esm/mask-hook/hooks/usePhoneMask.js.map +2 -2
- package/dist/esm/mask-hook/hooks/useSSNMask.js +5 -0
- package/dist/esm/mask-hook/hooks/useSSNMask.js.map +2 -2
- package/dist/esm/mask-hook/hooks/{useZipCode.js → useZipCodeMask.js} +10 -5
- package/dist/esm/mask-hook/hooks/{useZipCode.js.map → useZipCodeMask.js.map} +3 -3
- package/package.json +15 -15
- package/dist/cjs/autocomplete/config/constants.js.map +0 -7
- package/dist/cjs/autocomplete/config/useGetPropsWithDefault.js +0 -37
- package/dist/cjs/autocomplete/config/useGetPropsWithDefault.js.map +0 -7
- package/dist/cjs/autocomplete/index.d.js +0 -27
- package/dist/cjs/autocomplete/index.d.js.map +0 -7
- package/dist/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -50
- package/dist/cjs/autocomplete/parts/a11y-messages/MultiAllyMessages.js.map +0 -7
- package/dist/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -48
- package/dist/cjs/autocomplete/parts/a11y-messages/SingleAllyMessages.js.map +0 -7
- package/dist/cjs/autocomplete/parts/a11y-messages/index.js +0 -37
- package/dist/cjs/autocomplete/parts/a11y-messages/index.js.map +0 -7
- package/dist/cjs/autocomplete/parts/a11y-messages/styled.js +0 -41
- package/dist/cjs/autocomplete/parts/a11y-messages/styled.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/Controls.js +0 -72
- package/dist/cjs/autocomplete/parts/controls/Controls.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/index.js +0 -35
- package/dist/cjs/autocomplete/parts/controls/index.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/styled.js +0 -108
- package/dist/cjs/autocomplete/parts/controls/styled.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/useControlsInput.js +0 -62
- package/dist/cjs/autocomplete/parts/controls/useControlsInput.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/useKeyboardNavigation.js.map +0 -7
- package/dist/cjs/autocomplete/parts/controls/useMaskedOnChange.js +0 -48
- package/dist/cjs/autocomplete/parts/controls/useMaskedOnChange.js.map +0 -7
- package/dist/cjs/autocomplete/parts/menu-list/useMenuList.js +0 -82
- package/dist/cjs/autocomplete/parts/menu-list/useMenuList.js.map +0 -7
- package/dist/cjs/autocomplete/propTypes.js +0 -56
- package/dist/cjs/autocomplete/propTypes.js.map +0 -7
- package/dist/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -108
- package/dist/cjs/autocomplete/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/dist/cjs/autocomplete/utils/hooks/useOnElementResize.js +0 -56
- package/dist/cjs/autocomplete/utils/hooks/useOnElementResize.js.map +0 -7
- package/dist/esm/autocomplete/config/constants.js +0 -13
- package/dist/esm/autocomplete/config/constants.js.map +0 -7
- package/dist/esm/autocomplete/config/useGetPropsWithDefault.js +0 -8
- package/dist/esm/autocomplete/config/useGetPropsWithDefault.js.map +0 -7
- package/dist/esm/autocomplete/index.d.js +0 -2
- package/dist/esm/autocomplete/index.d.js.map +0 -7
- package/dist/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js +0 -21
- package/dist/esm/autocomplete/parts/a11y-messages/MultiAllyMessages.js.map +0 -7
- package/dist/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js +0 -19
- package/dist/esm/autocomplete/parts/a11y-messages/SingleAllyMessages.js.map +0 -7
- package/dist/esm/autocomplete/parts/a11y-messages/index.js +0 -8
- package/dist/esm/autocomplete/parts/a11y-messages/index.js.map +0 -7
- package/dist/esm/autocomplete/parts/a11y-messages/styled.js +0 -12
- package/dist/esm/autocomplete/parts/a11y-messages/styled.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/Controls.js +0 -43
- package/dist/esm/autocomplete/parts/controls/Controls.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/index.js +0 -6
- package/dist/esm/autocomplete/parts/controls/index.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/styled.js +0 -79
- package/dist/esm/autocomplete/parts/controls/styled.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/useControlsInput.js +0 -33
- package/dist/esm/autocomplete/parts/controls/useControlsInput.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/useKeyboardNavigation.js.map +0 -7
- package/dist/esm/autocomplete/parts/controls/useMaskedOnChange.js +0 -19
- package/dist/esm/autocomplete/parts/controls/useMaskedOnChange.js.map +0 -7
- package/dist/esm/autocomplete/parts/menu-list/useMenuList.js +0 -53
- package/dist/esm/autocomplete/parts/menu-list/useMenuList.js.map +0 -7
- package/dist/esm/autocomplete/propTypes.js +0 -27
- package/dist/esm/autocomplete/propTypes.js.map +0 -7
- package/dist/esm/autocomplete/utils/hooks/useKeyboardNavigation.js +0 -79
- package/dist/esm/autocomplete/utils/hooks/useKeyboardNavigation.js.map +0 -7
- package/dist/esm/autocomplete/utils/hooks/useOnElementResize.js +0 -27
- package/dist/esm/autocomplete/utils/hooks/useOnElementResize.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/autocomplete/react-desc-prop-types.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport React from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\
|
|
5
|
-
"mappings": "AAAA;ACGA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport React from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAutocompleteT {\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 type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n children: React.ReactChild;\n filter: string;\n onSelect: (suggestedValue: string | number, e: React.KeyboardEvent<HTMLInputElement>) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: string[];\n withoutPortal: boolean;\n zIndex: number;\n }\n\n export interface Props extends Partial<DefaultProps>, RequiredProps {}\n\n export interface InternalProps extends DefaultProps, RequiredProps {}\n}\n\nexport const propTypes = {\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of options')\n .defaultValue([]),\n filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),\n onSelect: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n children: PropTypes.node.isRequired\n .description('React component to apply autocomplete functionality')\n .defaultValue(''),\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACGA;AA6CO,MAAM,YAAY;AAAA,EACvB,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,SACtD,WAAW,YAAY,mBACvB,aAAa;AAAA,EAChB,QAAQ,UAAU,OAAO,WAAW,YAAY,sCAAsC,aAAa;AAAA,EACnG,UAAU,UAAU,KAAK,WACtB,YAAY,mFACZ,aAAa;AAAA,EAChB,UAAU,UAAU,KAAK,WACtB,YAAY,uDACZ,aAAa;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const basicOptions = [
|
|
3
|
+
{
|
|
4
|
+
dsId: "12",
|
|
5
|
+
type: "section",
|
|
6
|
+
label: "Please Select the appropriate city"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
dsId: "1",
|
|
10
|
+
type: "option",
|
|
11
|
+
label: "44444-4444"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
dsId: "2",
|
|
15
|
+
type: "option",
|
|
16
|
+
label: "44444-5555"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
dsId: "3",
|
|
20
|
+
type: "option",
|
|
21
|
+
label: "44444-6666"
|
|
22
|
+
}
|
|
23
|
+
];
|
|
24
|
+
export {
|
|
25
|
+
basicOptions
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/autocomplete/tests/utils.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export const basicOptions = [\n {\n dsId: '12',\n type: 'section',\n label: 'Please Select the appropriate city',\n },\n {\n dsId: '1',\n type: 'option',\n label: '44444-4444',\n },\n {\n dsId: '2',\n type: 'option',\n label: '44444-5555',\n },\n {\n dsId: '3',\n type: 'option',\n label: '44444-6666',\n },\n];\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,EAET;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,EAET;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA,EAET;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,17 +3,6 @@ const getSelectableOptions = (options) => options ? options.filter((option) => o
|
|
|
3
3
|
const getOptions = (options) => options ? options.filter((option) => option.type === "option") : [];
|
|
4
4
|
const isSelectedValueEmpty = (value) => Array.isArray(value) ? value.length === 0 : !value;
|
|
5
5
|
const isSelectedValueMultiple = (value) => Array.isArray(value);
|
|
6
|
-
const isSelected = (value, activeOption) => {
|
|
7
|
-
if (isSelectedValueMultiple(value)) {
|
|
8
|
-
const multiValue = value;
|
|
9
|
-
return multiValue.some((item) => item?.value === activeOption?.value);
|
|
10
|
-
}
|
|
11
|
-
if (typeof value === "string") {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
const singleValue = value;
|
|
15
|
-
return singleValue?.value === activeOption.value;
|
|
16
|
-
};
|
|
17
6
|
const findInCircularList = (list, from, criteria, step = 1) => {
|
|
18
7
|
for (let i = (from + step + list.length) % list.length; i !== from; i = (i + step + list.length) % list.length) {
|
|
19
8
|
if (criteria(list[i]))
|
|
@@ -21,11 +10,18 @@ const findInCircularList = (list, from, criteria, step = 1) => {
|
|
|
21
10
|
}
|
|
22
11
|
return from;
|
|
23
12
|
};
|
|
13
|
+
const getFirstOption = (options) => {
|
|
14
|
+
for (let i = 0; i < options.length; i += 1)
|
|
15
|
+
if (!["section", "separator"].includes(options[i].type)) {
|
|
16
|
+
return options[i].dsId;
|
|
17
|
+
}
|
|
18
|
+
return "";
|
|
19
|
+
};
|
|
24
20
|
export {
|
|
25
21
|
findInCircularList,
|
|
22
|
+
getFirstOption,
|
|
26
23
|
getOptions,
|
|
27
24
|
getSelectableOptions,
|
|
28
|
-
isSelected,
|
|
29
25
|
isSelectedValueEmpty,
|
|
30
26
|
isSelectedValueMultiple
|
|
31
27
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/autocomplete/utils/listHelper.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import {
|
|
5
|
-
"mappings": "AAAA;ACEO,MAAM,uBAAuB,CAAC,YACnC,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,YAAY;AAEhF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY;AAE5D,MAAM,uBAAuB,CAAC,UACnC,MAAM,QAAQ,SAAS,MAAM,WAAW,IAAI,CAAC;AAExC,MAAM,0BAA0B,CAAC,UAAiD,MAAM,QAAQ;AAEhG,MAAM,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { DSAutocompleteT } from '../react-desc-prop-types';\n\nexport const getSelectableOptions = (options: Array<CBOptionT>): Array<CBOptionT> =>\n options ? options.filter((option) => option.type === 'option' && !option.disabled) : [];\n\nexport const getOptions = (options: Array<CBOptionT>): Array<CBOptionT> =>\n options ? options.filter((option) => option.type === 'option') : [];\n\nexport const isSelectedValueEmpty = (value: CBOptionT | Array<CBOptionT>): boolean =>\n Array.isArray(value) ? value.length === 0 : !value;\n\nexport const isSelectedValueMultiple = (value: CBOptionT | Array<CBOptionT>): boolean => Array.isArray(value);\n\nexport const findInCircularList = <T extends unknown>(\n list: T[],\n from: number,\n criteria: (item: T) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (let i = (from + step + list.length) % list.length; i !== from; i = (i + step + list.length) % list.length) {\n if (criteria(list[i])) return i;\n }\n return from; // return same item\n};\n\nexport const getFirstOption = (options: DSAutocompleteT.OptionTypes[]) => {\n for (let i = 0; i < options.length; i += 1)\n if (!['section', 'separator'].includes(options[i].type)) {\n return options[i].dsId;\n }\n return '';\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,uBAAuB,CAAC,YACnC,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,YAAY;AAEhF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY;AAE5D,MAAM,uBAAuB,CAAC,UACnC,MAAM,QAAQ,SAAS,MAAM,WAAW,IAAI,CAAC;AAExC,MAAM,0BAA0B,CAAC,UAAiD,MAAM,QAAQ;AAEhG,MAAM,qBAAqB,CAChC,MACA,MACA,UACA,OAAO,MAEI;AACX,WAAS,IAAK,QAAO,OAAO,KAAK,UAAU,KAAK,QAAQ,MAAM,MAAM,IAAK,KAAI,OAAO,KAAK,UAAU,KAAK,QAAQ;AAC9G,QAAI,SAAS,KAAK;AAAK,aAAO;AAAA;AAEhC,SAAO;AAAA;AAGF,MAAM,iBAAiB,CAAC,YAA2C;AACxE,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,CAAC,CAAC,WAAW,aAAa,SAAS,QAAQ,GAAG,OAAO;AACvD,aAAO,QAAQ,GAAG;AAAA;AAEtB,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -64,8 +64,14 @@ const useComboBox = (props) => {
|
|
|
64
64
|
if (!hasFocus)
|
|
65
65
|
setFocusOptionIdx("");
|
|
66
66
|
}, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (!showPopover) {
|
|
69
|
+
setFocusOptionIdx("");
|
|
70
|
+
setShowSelectedOptions(false);
|
|
71
|
+
}
|
|
72
|
+
}, [showPopover]);
|
|
67
73
|
const ctx = useMemo(() => ({
|
|
68
|
-
props: __spreadProps(__spreadValues({}, propsWithDefaults), {
|
|
74
|
+
props: __spreadProps(__spreadValues({}, propsWithDefaults), { filteredOptions: correctOptions }),
|
|
69
75
|
virtualListHelpers,
|
|
70
76
|
showPopover,
|
|
71
77
|
referenceElement,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/combobox/config/useComboBox.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback, useEffect } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from '../ComboBoxCTX';\nimport { DSComboboxT, ComboboxPropTypes } from '../react-desc-prop-types';\nimport { DSComboboxInternalsT } from '../sharedTypes';\nimport { useCorrectOptions } from './useCorrectOptions';\nimport { getFirstOption } from '../utils/listHelper';\nexport const useComboBox = (props: DSComboboxT.Props): DSComboboxInternalsT.ComboBoxContextT => {\n const defaultPropsWithInnerRef = {\n ...defaultProps,\n innerRef: useRef(null),\n };\n\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);\n useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes);\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const selectAllCheckboxRef = useRef<HTMLInputElement>(null);\n const toggleSelectionButtonRef = useRef<HTMLButtonElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const { selectedValues } = propsWithDefaults;\n // ---------------------------------------------------------------------------\n //
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACO,MAAM,cAAc,CAAC,UAAoE;AAC9F,QAAM,2BAA2B,iCAC5B,eAD4B;AAAA,IAE/B,UAAU,OAAO;AAAA;AAGnB,QAAM,oBAAoB,6BAA6B,OAAO;AAC9D,iCAA+B,mBAAmB;AAClD,QAAM,CAAC,aAAa,kBAAkB,SAAkB;AACxD,QAAM,CAAC,kBAAkB,uBAAuB,SAA6B;AAC7E,QAAM,CAAC,qBAAqB,0BAA0B,SAAkB;AAExE,QAAM,CAAC,YAAY,iBAAiB,SAAiB;AACrD,QAAM,CAAC,UAAU,eAAe,SAAkB;AAElD,QAAM,UAAU,OAAuB;AACvC,QAAM,iBAAiB,OAAuB;AAE9C,QAAM,qBAAqB,OAAuB;AAClD,QAAM,qBAAqB,OAAuB;AAClD,QAAM,uBAAuB,OAAyB;AACtD,QAAM,2BAA2B,OAA0B;AAC3D,QAAM,eAAe,OAAuB;AAE5C,QAAM,EAAE,mBAAmB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useRef, useCallback, useEffect } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { defaultProps } from '../ComboBoxCTX';\nimport { DSComboboxT, ComboboxPropTypes } from '../react-desc-prop-types';\nimport { DSComboboxInternalsT } from '../sharedTypes';\nimport { useCorrectOptions } from './useCorrectOptions';\nimport { getFirstOption } from '../utils/listHelper';\nexport const useComboBox = (props: DSComboboxT.Props): DSComboboxInternalsT.ComboBoxContextT => {\n const defaultPropsWithInnerRef = {\n ...defaultProps,\n innerRef: useRef(null),\n };\n\n const propsWithDefaults = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);\n useValidateTypescriptPropTypes(propsWithDefaults, ComboboxPropTypes);\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [showSelectedOptions, setShowSelectedOptions] = useState<boolean>(false);\n\n const [inputValue, setInputValue] = useState<string>('');\n const [hasFocus, setHasFocus] = useState<boolean>(false);\n\n const listRef = useRef<HTMLDivElement>(null);\n const wrapperListRef = useRef<HTMLDivElement>(null);\n\n const selectedOptionsRef = useRef<HTMLDivElement>(null);\n const controlsWrapperRef = useRef<HTMLDivElement>(null);\n const selectAllCheckboxRef = useRef<HTMLInputElement>(null);\n const toggleSelectionButtonRef = useRef<HTMLButtonElement>(null);\n const pillGroupRef = useRef<HTMLDivElement>(null);\n\n const { selectedValues } = propsWithDefaults;\n\n // ---------------------------------------------------------------------------\n // Options with creatable option + filtered by selected\n // ---------------------------------------------------------------------------\n\n const correctOptions = useCorrectOptions(propsWithDefaults, inputValue, showSelectedOptions);\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: correctOptions.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n correctOptions.findIndex((opt) => opt.dsId === dsId),\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n opts,\n );\n },\n [correctOptions, virtualListHelpers],\n );\n\n // ===========================================================================\n // Init focused option when opening the menu list\n // ===========================================================================\n\n const [focusOptionIdx, setFocusOptionIdx] = useState<string>('');\n\n useEffect(() => {\n // we are updating the focus option only when we have focus on the input and\n // we are in the selected option view or we are typing to force first option always\n if (hasFocus && (focusOptionIdx === '' || inputValue !== '' || showSelectedOptions)) {\n const focusedValue = getFirstOption(correctOptions, selectedValues, inputValue);\n setFocusOptionIdx(focusedValue);\n scrollOptionIntoView(focusedValue, { align: 'center' });\n }\n if (!hasFocus) setFocusOptionIdx('');\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showPopover, hasFocus, correctOptions, selectedValues, inputValue]);\n\n useEffect(() => {\n if (!showPopover) {\n setFocusOptionIdx('');\n setShowSelectedOptions(false);\n }\n }, [showPopover]);\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefaults, filteredOptions: correctOptions },\n virtualListHelpers,\n showPopover,\n referenceElement,\n listRef,\n focusOptionIdx,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n inputValue,\n setInputValue,\n hasFocus,\n toggleSelectionButtonRef,\n pillGroupRef,\n showSelectedOptions,\n wrapperListRef,\n setShowSelectedOptions,\n setHasFocus,\n setFocusOptionIdx,\n scrollOptionIntoView,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n correctOptions,\n hasFocus,\n propsWithDefaults,\n virtualListHelpers,\n inputValue,\n focusOptionIdx,\n wrapperListRef,\n showSelectedOptions,\n showPopover,\n pillGroupRef,\n referenceElement,\n selectedOptionsRef,\n controlsWrapperRef,\n selectAllCheckboxRef,\n toggleSelectionButtonRef,\n listRef,\n ],\n );\n\n return ctx;\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACO,MAAM,cAAc,CAAC,UAAoE;AAC9F,QAAM,2BAA2B,iCAC5B,eAD4B;AAAA,IAE/B,UAAU,OAAO;AAAA;AAGnB,QAAM,oBAAoB,6BAA6B,OAAO;AAC9D,iCAA+B,mBAAmB;AAClD,QAAM,CAAC,aAAa,kBAAkB,SAAkB;AACxD,QAAM,CAAC,kBAAkB,uBAAuB,SAA6B;AAC7E,QAAM,CAAC,qBAAqB,0BAA0B,SAAkB;AAExE,QAAM,CAAC,YAAY,iBAAiB,SAAiB;AACrD,QAAM,CAAC,UAAU,eAAe,SAAkB;AAElD,QAAM,UAAU,OAAuB;AACvC,QAAM,iBAAiB,OAAuB;AAE9C,QAAM,qBAAqB,OAAuB;AAClD,QAAM,qBAAqB,OAAuB;AAClD,QAAM,uBAAuB,OAAyB;AACtD,QAAM,2BAA2B,OAA0B;AAC3D,QAAM,eAAe,OAAuB;AAE5C,QAAM,EAAE,mBAAmB;AAM3B,QAAM,iBAAiB,kBAAkB,mBAAmB,YAAY;AAMxE,QAAM,qBAAoD,WAAW;AAAA,IACnE,MAAM,eAAe;AAAA,IACrB,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA;AAMhB,QAAM,uBAAuB,YAC3B,CAAC,MAAc,OAAO,EAAE,OAAO,eAAe;AAC5C,uBAAmB,cACjB,eAAe,UAAU,CAAC,QAAQ,IAAI,SAAS,OAE/C;AAAA,KAGJ,CAAC,gBAAgB;AAOnB,QAAM,CAAC,gBAAgB,qBAAqB,SAAiB;AAE7D,YAAU,MAAM;AAGd,QAAI,YAAa,oBAAmB,MAAM,eAAe,MAAM,sBAAsB;AACnF,YAAM,eAAe,eAAe,gBAAgB,gBAAgB;AACpE,wBAAkB;AAClB,2BAAqB,cAAc,EAAE,OAAO;AAAA;AAE9C,QAAI,CAAC;AAAU,wBAAkB;AAAA,KAEhC,CAAC,aAAa,UAAU,gBAAgB,gBAAgB;AAE3D,YAAU,MAAM;AACd,QAAI,CAAC,aAAa;AAChB,wBAAkB;AAClB,6BAAuB;AAAA;AAAA,KAExB,CAAC;AAEJ,QAAM,MAAM,QACV,MAAO;AAAA,IACL,OAAO,iCAAK,oBAAL,EAAwB,iBAAiB;AAAA,IAChD;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;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF;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;AAAA,IACA;AAAA,IACA;AAAA;AAIJ,SAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,46 +1,27 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo
|
|
2
|
+
import { useMemo } from "react";
|
|
3
3
|
import { uid } from "uid";
|
|
4
4
|
import { MENU_OPTION_TYPES } from "../constants";
|
|
5
|
+
import { selectedValuesWithSections } from "../utils/listHelper";
|
|
5
6
|
const useCorrectOptions = (propsWithDefaults, inputValue, showSelectedOptions) => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
options.forEach((option) => {
|
|
11
|
-
const isSelectedValue = multiSelectedValue.find((item) => item.dsId === option.dsId);
|
|
12
|
-
if (isSelectedValue) {
|
|
13
|
-
items.push(option);
|
|
14
|
-
}
|
|
15
|
-
if (option.type === MENU_OPTION_TYPES.SECTION) {
|
|
16
|
-
if (items[items.length - 1]?.type === MENU_OPTION_TYPES.SECTION) {
|
|
17
|
-
items[items.length - 1] = option;
|
|
18
|
-
} else {
|
|
19
|
-
items.push(option);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
if (items[items.length - 1]?.type === MENU_OPTION_TYPES.SECTION) {
|
|
24
|
-
items.pop();
|
|
25
|
-
}
|
|
26
|
-
return items;
|
|
27
|
-
}, [options, selectedValues]);
|
|
28
|
-
const correctOptions = useMemo(() => {
|
|
7
|
+
const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
if (!filteredOptions)
|
|
10
|
+
return [...allOptions];
|
|
29
11
|
if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {
|
|
30
|
-
return selectedValuesWithSections();
|
|
12
|
+
return selectedValuesWithSections(filteredOptions, selectedValues);
|
|
31
13
|
}
|
|
32
|
-
if (onCreate && inputValue &&
|
|
14
|
+
if (onCreate && inputValue && filteredOptions.findIndex((option) => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) === -1) {
|
|
33
15
|
const creatableUuid = uid();
|
|
34
16
|
const creatableItem = {
|
|
35
17
|
dsId: `creatable-${creatableUuid}`,
|
|
36
18
|
label: inputValue,
|
|
37
19
|
type: "creatable"
|
|
38
20
|
};
|
|
39
|
-
return [creatableItem, ...
|
|
21
|
+
return [creatableItem, ...filteredOptions];
|
|
40
22
|
}
|
|
41
|
-
return
|
|
42
|
-
}, [
|
|
43
|
-
return correctOptions;
|
|
23
|
+
return filteredOptions;
|
|
24
|
+
}, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);
|
|
44
25
|
};
|
|
45
26
|
export {
|
|
46
27
|
useCorrectOptions
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/combobox/config/useCorrectOptions.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA;AACA,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport { uid } from 'uid';\nimport { DSComboboxT } from '../react-desc-prop-types';\nimport { MENU_OPTION_TYPES } from '../constants';\nimport { selectedValuesWithSections } from '../utils/listHelper';\nconst useCorrectOptions = (propsWithDefaults: DSComboboxT.Props, inputValue: string, showSelectedOptions: boolean) => {\n const { filteredOptions, allOptions, selectedValues, onCreate } = propsWithDefaults;\n\n return useMemo(() => {\n // if filteredOptions is not passed we copy allOptions into the prop as default\n // this is useful when the user wants a combo with out filtering and only pass allOptions as its required\n if (!filteredOptions) return [...allOptions];\n // when show selected toggle is on we return the selected value only as filteredOptions prop\n if (showSelectedOptions && Array.isArray(selectedValues) && selectedValues.length > 0) {\n return selectedValuesWithSections(filteredOptions, selectedValues);\n }\n // whether oncreate is passed we add as first option the creatable action based on input value string\n if (\n onCreate &&\n inputValue &&\n filteredOptions.findIndex((option) => option.type === MENU_OPTION_TYPES.OPTION && option.label === inputValue) ===\n -1\n ) {\n const creatableUuid = uid();\n const creatableItem: DSComboboxT.ItemCreatableOption = {\n dsId: `creatable-${creatableUuid}`,\n label: inputValue,\n type: 'creatable',\n };\n return [creatableItem, ...filteredOptions];\n }\n return filteredOptions;\n }, [filteredOptions, allOptions, showSelectedOptions, selectedValues, onCreate, inputValue]);\n};\n\nexport { useCorrectOptions };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA,MAAM,oBAAoB,CAAC,mBAAsC,YAAoB,wBAAiC;AACpH,QAAM,EAAE,iBAAiB,YAAY,gBAAgB,aAAa;AAElE,SAAO,QAAQ,MAAM;AAGnB,QAAI,CAAC;AAAiB,aAAO,CAAC,GAAG;AAEjC,QAAI,uBAAuB,MAAM,QAAQ,mBAAmB,eAAe,SAAS,GAAG;AACrF,aAAO,2BAA2B,iBAAiB;AAAA;AAGrD,QACE,YACA,cACA,gBAAgB,UAAU,CAAC,WAAW,OAAO,SAAS,kBAAkB,UAAU,OAAO,UAAU,gBACjG,IACF;AACA,YAAM,gBAAgB;AACtB,YAAM,gBAAiD;AAAA,QACrD,MAAM,aAAa;AAAA,QACnB,OAAO;AAAA,QACP,MAAM;AAAA;AAER,aAAO,CAAC,eAAe,GAAG;AAAA;AAE5B,WAAO;AAAA,KACN,CAAC,iBAAiB,YAAY,qBAAqB,gBAAgB,UAAU;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -6,12 +6,12 @@ import { getSelectableOptions } from "../utils/listHelper";
|
|
|
6
6
|
import { isSeparator } from "../sharedTypes";
|
|
7
7
|
const A11yFocusedOption = () => {
|
|
8
8
|
const {
|
|
9
|
-
props: {
|
|
9
|
+
props: { filteredOptions },
|
|
10
10
|
focusOptionIdx,
|
|
11
11
|
showPopover
|
|
12
12
|
} = useContext(ComboBoxContext);
|
|
13
|
-
const selectabledOptions = getSelectableOptions(
|
|
14
|
-
const focusOption =
|
|
13
|
+
const selectabledOptions = getSelectableOptions(filteredOptions);
|
|
14
|
+
const focusOption = filteredOptions.find((option) => !isSeparator(option) && option.dsId === focusOptionIdx);
|
|
15
15
|
const focusSelectableOptionIdx = selectabledOptions.findIndex((option) => option.dsId === focusOptionIdx);
|
|
16
16
|
return useMemo(() => {
|
|
17
17
|
if (!isSeparator(focusOption) && showPopover && focusOption)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/combobox/parts/A11yFocusedOption.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport ComboBoxContext from '../ComboBoxCTX';\nimport { StyledA11ySelectedValues } from './styled';\nimport { getSelectableOptions } from '../utils/listHelper';\nimport { isSeparator } from '../sharedTypes';\n\nexport const A11yFocusedOption: React.ComponentType = () => {\n const {\n props: {
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAEO,MAAM,oBAAyC,MAAM;AAC1D,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,IACA;AAAA,MACE,WAAW;AACf,QAAM,qBAAqB,qBAAqB;AAChD,QAAM,cAAc,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport ComboBoxContext from '../ComboBoxCTX';\nimport { StyledA11ySelectedValues } from './styled';\nimport { getSelectableOptions } from '../utils/listHelper';\nimport { isSeparator } from '../sharedTypes';\n\nexport const A11yFocusedOption: React.ComponentType = () => {\n const {\n props: { filteredOptions },\n focusOptionIdx,\n showPopover,\n } = useContext(ComboBoxContext);\n const selectabledOptions = getSelectableOptions(filteredOptions);\n const focusOption = filteredOptions.find((option) => !isSeparator(option) && option.dsId === focusOptionIdx);\n\n const focusSelectableOptionIdx = selectabledOptions.findIndex((option) => option.dsId === focusOptionIdx);\n\n return useMemo(() => {\n if (!isSeparator(focusOption) && showPopover && focusOption)\n return (\n <StyledA11ySelectedValues aria-live=\"polite\" aria-atomic=\"false\" aria-relevant=\"additions text\">\n {`option ${focusOption?.label} focused.${focusSelectableOptionIdx + 1} of ${selectabledOptions.length} `}\n </StyledA11ySelectedValues>\n );\n\n return null;\n }, [showPopover, focusOption, focusSelectableOptionIdx, selectabledOptions]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AAEO,MAAM,oBAAyC,MAAM;AAC1D,QAAM;AAAA,IACJ,OAAO,EAAE;AAAA,IACT;AAAA,IACA;AAAA,MACE,WAAW;AACf,QAAM,qBAAqB,qBAAqB;AAChD,QAAM,cAAc,gBAAgB,KAAK,CAAC,WAAW,CAAC,YAAY,WAAW,OAAO,SAAS;AAE7F,QAAM,2BAA2B,mBAAmB,UAAU,CAAC,WAAW,OAAO,SAAS;AAE1F,SAAO,QAAQ,MAAM;AACnB,QAAI,CAAC,YAAY,gBAAgB,eAAe;AAC9C,aACE,qCAAC,0BAAD;AAAA,QAA0B,aAAU;AAAA,QAAS,eAAY;AAAA,QAAQ,iBAAc;AAAA,SAC5E,UAAU,aAAa,iBAAiB,2BAA2B,QAAQ,mBAAmB;AAIrG,WAAO;AAAA,KACN,CAAC,aAAa,aAAa,0BAA0B;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -21,6 +21,8 @@ const Controls = () => {
|
|
|
21
21
|
selectedOptionsRef,
|
|
22
22
|
setShowPopover,
|
|
23
23
|
hasFocus,
|
|
24
|
+
focusOptionIdx,
|
|
25
|
+
scrollOptionIntoView,
|
|
24
26
|
showPopover,
|
|
25
27
|
controlsWrapperRef
|
|
26
28
|
} = useContext(ComboBoxContext);
|
|
@@ -34,7 +36,7 @@ const Controls = () => {
|
|
|
34
36
|
}
|
|
35
37
|
innerRef.current?.focus();
|
|
36
38
|
setShowPopover(true);
|
|
37
|
-
}, [disabled, hasFocus,
|
|
39
|
+
}, [disabled, hasFocus, showPopover, inline, innerRef, setShowPopover, focusOptionIdx]);
|
|
38
40
|
const handleOnPillsClick = useCallback((e) => {
|
|
39
41
|
if (showPopover || disabled) {
|
|
40
42
|
e.stopPropagation();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/combobox/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 { 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 setShowPopover,\n hasFocus,\n showPopover,\n controlsWrapperRef,\n } = useContext(ComboBoxContext);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (hasFocus && showPopover && !inline) {\n setShowPopover(false);\n innerRef.current?.blur();\n return;\n }\n innerRef.current?.focus();\n setShowPopover(true);\n }, [disabled, hasFocus,
|
|
5
|
-
"mappings": "AAAA;ACEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,UAAU,eAAe,UAAU,gBAAgB;AAAA,IACpE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,gBAAgB,YAAY,MAAM;AACtC,QAAI;AAAU;AACd,QAAI,YAAY,eAAe,CAAC,QAAQ;AACtC,qBAAe;AACf,eAAS,SAAS;AAClB;AAAA;AAEF,aAAS,SAAS;AAClB,mBAAe;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 { 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 setShowPopover,\n hasFocus,\n focusOptionIdx,\n scrollOptionIntoView,\n showPopover,\n controlsWrapperRef,\n } = useContext(ComboBoxContext);\n\n const handleOnClick = useCallback(() => {\n if (disabled) return;\n if (hasFocus && showPopover && !inline) {\n setShowPopover(false);\n innerRef.current?.blur();\n return;\n }\n innerRef.current?.focus();\n setShowPopover(true);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [disabled, hasFocus, showPopover, inline, innerRef, setShowPopover, 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 (showPopover || disabled) {\n e.stopPropagation();\n } else {\n innerRef.current?.focus();\n setShowPopover(true);\n }\n },\n [showPopover, innerRef, disabled, setShowPopover],\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 <A11yFocusedOption />\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\n <ControlsInput />\n {!inline && (\n <StyledHeaderActionsWrapper justifyContent=\"center\" cols={['auto', 'auto']}>\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;AAMA;AACA;AACA;AACA;AACA;AACA;AACO,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ,UAAU,eAAe,UAAU,gBAAgB;AAAA,IACpE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,gBAAgB,YAAY,MAAM;AACtC,QAAI;AAAU;AACd,QAAI,YAAY,eAAe,CAAC,QAAQ;AACtC,qBAAe;AACf,eAAS,SAAS;AAClB;AAAA;AAEF,aAAS,SAAS;AAClB,mBAAe;AAAA,KAEd,CAAC,UAAU,UAAU,aAAa,QAAQ,UAAU,gBAAgB;AAGvE,QAAM,qBAA8C,YAClD,CAAC,MAAM;AACL,QAAI,eAAe,UAAU;AAC3B,QAAE;AAAA,WACG;AACL,eAAS,SAAS;AAClB,qBAAe;AAAA;AAAA,KAGnB,CAAC,aAAa,UAAU,UAAU;AAIpC,QAAM,oBAA6C,YACjD,CAAC,MAAM;AACL,QAAI,SAAS,kBAAkB,SAAS,WAAW,QAAQ;AACzD,QAAE;AAAA;AAAA,KAGN,CAAC,UAAU;AAGb,QAAM,EAAE,mBAAmB;AAE3B,QAAM,OAAO,QACX,MAAO,CAAC,SAAS,CAAC,2BAA2B,sBAAsB,UAAU,CAAC,sBAC9E,CAAC;AAEH,SACE,qCAAC,uBAAD;AAAA,IACE,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,eAAa,mBAAmB;AAAA,KAE/B,CAAC,UACA,qCAAC,iBAAD;AAAA,IAAiB,KAAK;AAAA,IAAoB,SAAS;AAAA,KACjD,qCAAC,oBAAD,OACA,qCAAC,mBAAD,OACC,MAAM,QAAQ,kBACb,qCAAC,8BAAD,QAEA,qCAAC,OAAD;AAAA,IAAK,eAAa,mBAAmB;AAAA,KAClC,kBAAkB,qCAAC,4BAAD;AAAA,IAA4B,MAAM;AAAA,QAM7D,qCAAC,eAAD,OACC,CAAC,UACA,qCAAC,4BAAD;AAAA,IAA4B,gBAAe;AAAA,IAAS,MAAM,CAAC,QAAQ;AAAA,KACjE,qCAAC,6BAAD;AAAA,IAA6B;AAAA,MAC7B,qCAAC,mBAAD;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,7 @@ import { useControlsInput } from "./useControlsInput";
|
|
|
8
8
|
import { ComboBoxContext } from "../../ComboBoxCTX";
|
|
9
9
|
const ControlsInput = () => {
|
|
10
10
|
const {
|
|
11
|
-
props: { autoFocus, disabled, innerRef, onFilter },
|
|
11
|
+
props: { autoFocus, placeholder, disabled, innerRef, onFilter },
|
|
12
12
|
focusOptionIdx,
|
|
13
13
|
inputValue,
|
|
14
14
|
showPopover
|
|
@@ -22,6 +22,7 @@ const ControlsInput = () => {
|
|
|
22
22
|
})), /* @__PURE__ */ React2.createElement(StyledInput, {
|
|
23
23
|
"data-testid": ComboboxDataTestid.INPUT,
|
|
24
24
|
autoFocus,
|
|
25
|
+
placeholder,
|
|
25
26
|
"aria-controls": "combo-listbox",
|
|
26
27
|
"aria-activedescendant": focusOptionIdx,
|
|
27
28
|
"aria-expanded": showPopover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/combobox/parts/controls-input/ControlsInput.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\n\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { StyledInput, StyledInputWrapper, StyledInputPlaceHolder, StyledInputWidthReference } from './styled';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { useControlsInput } from './useControlsInput';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: { autoFocus, disabled, innerRef, onFilter },\n focusOptionIdx,\n inputValue,\n showPopover,\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 <StyledInputPlaceHolder>\n <SimpleTruncatedTooltipText value={showPlaceholder}></SimpleTruncatedTooltipText>\n </StyledInputPlaceHolder>\n\n <StyledInput\n data-testid={ComboboxDataTestid.INPUT}\n autoFocus={autoFocus}\n aria-controls=\"combo-listbox\"\n aria-activedescendant={focusOptionIdx}\n aria-expanded={showPopover}\n aria-haspopup=\"true\"\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={!onFilter}\n />\n </StyledInputWrapper>\n );\n};\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,UAAU,UAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { SimpleTruncatedTooltipText } from '@elliemae/ds-truncated-tooltip-text';\n\nimport { ComboboxDataTestid } from '../../ComboboxDataTestids';\nimport { StyledInput, StyledInputWrapper, StyledInputPlaceHolder, StyledInputWidthReference } from './styled';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { useControlsInput } from './useControlsInput';\nimport { ComboBoxContext } from '../../ComboBoxCTX';\n\nexport const ControlsInput = (): JSX.Element => {\n const {\n props: { autoFocus, placeholder, disabled, innerRef, onFilter },\n focusOptionIdx,\n inputValue,\n showPopover,\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 <StyledInputPlaceHolder>\n <SimpleTruncatedTooltipText value={showPlaceholder}></SimpleTruncatedTooltipText>\n </StyledInputPlaceHolder>\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={showPopover}\n aria-haspopup=\"true\"\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={!onFilter}\n />\n </StyledInputWrapper>\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEO,MAAM,gBAAgB,MAAmB;AAC9C,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW,aAAa,UAAU,UAAU;AAAA,IACrD;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AACf,QAAM,EAAE,mBAAmB;AAC3B,QAAM,EAAE,eAAe,OAAO,mBAAmB,iBAAiB,cAAc,gBAAgB,kBAC9F;AACF,SACE,qCAAC,oBAAD,MACE,qCAAC,2BAAD;AAAA,IAA2B,KAAK;AAAA,KAAgB,oBAChD,qCAAC,wBAAD,MACE,qCAAC,4BAAD;AAAA,IAA4B,OAAO;AAAA,OAGrC,qCAAC,aAAD;AAAA,IACE,eAAa,mBAAmB;AAAA,IAChC;AAAA,IACA;AAAA,IACA,iBAAc;AAAA,IACd,yBAAuB;AAAA,IACvB,iBAAe;AAAA,IACf,iBAAc;AAAA,IACd,oBAAiB;AAAA,IACjB,MAAK;AAAA,IACL;AAAA,IACA,OAAO,EAAE;AAAA,IACT,KAAK;AAAA,IACL,OAAO;AAAA,IACP,MAAK;AAAA,IACL,WAAW;AAAA,IACX,UAAU;AAAA,IACV,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,cAAc,CAAC;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/combobox/parts/controls-input/styled.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\n\nexport const StyledInput = styled.input<{ withoutCaret: boolean }>`\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ${(props) => props.theme.colors.neutral[700]};\n &:focus {\n outline: none;\n }\n ${({ withoutCaret }) => withoutCaret && 'caret-color: transparent;'}\n`;\n\nexport const StyledInputPlaceHolder = styled.div`\n font-style: italic;\n color: ${(props) => props.theme.colors.neutral[500]};\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n & span {\n line-height: 13px;\n }\n`;\n\nexport const StyledInputWidthReference = styled.span`\n visibility: hidden;\n position: absolute;\n top: -9999px;\n`;\n\nexport const StyledInputWrapper = styled.div`\n position: relative;\n flex: 1;\n margin-right: 5px;\n display: flex;\n align-items: center;\n`;\n"],
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,cAAc,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAMvB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,IAI7C,CAAC,EAAE,mBAAmB,gBAAgB;AAAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { styled } from '@elliemae/ds-system';\n\nexport const StyledInput = styled.input<{ withoutCaret: boolean }>`\n font-size: 13px;\n line-height: 13px;\n border: none;\n padding: 0;\n outline: none;\n color: ${(props) => props.theme.colors.neutral[700]};\n &:focus {\n outline: none;\n }\n ${({ withoutCaret }) => withoutCaret && 'caret-color: transparent;'}\n &::placeholder {\n color: transparent;\n }\n`;\n\nexport const StyledInputPlaceHolder = styled.div`\n font-style: italic;\n color: ${(props) => props.theme.colors.neutral[500]};\n position: absolute;\n display: flex;\n align-items: center;\n width: 100%;\n user-select: none;\n height: 28px;\n & span {\n line-height: 13px;\n }\n`;\n\nexport const StyledInputWidthReference = styled.span`\n visibility: hidden;\n position: absolute;\n top: -9999px;\n`;\n\nexport const StyledInputWrapper = styled.div`\n position: relative;\n flex: 1;\n margin-right: 5px;\n display: flex;\n align-items: center;\n`;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,cAAc,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,WAMvB,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA,IAI7C,CAAC,EAAE,mBAAmB,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAMnC,MAAM,yBAAyB,OAAO;AAAA;AAAA,WAElC,CAAC,UAAU,MAAM,MAAM,OAAO,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAY1C,MAAM,4BAA4B,OAAO;AAAA;AAAA;AAAA;AAAA;AAMzC,MAAM,qBAAqB,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,7 @@ import ComboBoxContext from "../../ComboBoxCTX";
|
|
|
5
5
|
import { isSelectedValueEmpty } from "../../utils/listHelper";
|
|
6
6
|
const useControlsInput = () => {
|
|
7
7
|
const {
|
|
8
|
-
props: { selectedValues, placeholder, onFilter },
|
|
8
|
+
props: { selectedValues, allOptions, placeholder, onFilter },
|
|
9
9
|
setHasFocus,
|
|
10
10
|
inputValue,
|
|
11
11
|
setInputValue,
|
|
@@ -16,16 +16,15 @@ const useControlsInput = () => {
|
|
|
16
16
|
const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;
|
|
17
17
|
const spanReferenceText = inputValue.replace(/\s/g, "\xA0");
|
|
18
18
|
useEffect(() => {
|
|
19
|
-
setWidth(spanReference.current?.offsetWidth ? spanReference.current
|
|
19
|
+
setWidth(spanReference.current?.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);
|
|
20
20
|
}, [inputValue]);
|
|
21
21
|
const handleOnChange = useMaskedOnChange();
|
|
22
22
|
const handleOnBlur = useCallback(() => {
|
|
23
23
|
setInputValue("");
|
|
24
24
|
if (onFilter)
|
|
25
|
-
onFilter(
|
|
25
|
+
onFilter(allOptions, inputValue);
|
|
26
26
|
setHasFocus(false);
|
|
27
|
-
|
|
28
|
-
}, [setInputValue, setShowSelectedOptions, onFilter, setHasFocus]);
|
|
27
|
+
}, [setInputValue, onFilter, allOptions, inputValue, setHasFocus, setShowSelectedOptions]);
|
|
29
28
|
const handleOnFocus = useCallback(() => {
|
|
30
29
|
setHasFocus(true);
|
|
31
30
|
}, [setHasFocus]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/combobox/parts/controls-input/useControlsInput.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useEffect, useMemo, useRef, useCallback, useState } from 'react';\n\nimport { useMaskedOnChange } from './useMaskedOnChange';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport { isSelectedValueEmpty } from '../../utils/listHelper';\n\ninterface UseControlsInputT {\n handleOnBlur: () => void;\n handleOnChange?: React.ChangeEventHandler<HTMLInputElement>;\n handleOnFocus: React.FocusEventHandler<HTMLInputElement>;\n showPlaceholder: string | null | undefined;\n spanReferenceText: string | undefined;\n width: number;\n spanReference: React.Ref<HTMLSpanElement>;\n}\nconst useControlsInput = (): UseControlsInputT => {\n const {\n props: { selectedValues, placeholder, onFilter },\n setHasFocus,\n inputValue,\n setInputValue,\n setShowSelectedOptions,\n } = useContext(ComboBoxContext);\n\n const [width, setWidth] = useState(1);\n // use span reference to calculate the real width for the input\n const spanReference = useRef<HTMLSpanElement>(null);\n const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;\n const spanReferenceText = inputValue.replace(/\\s/g, '\\u00a0');\n\n useEffect(() => {\n setWidth(spanReference.current?.offsetWidth ? spanReference.current
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEA;AACA;AACA;AAWA,MAAM,mBAAmB,MAAyB;AAChD,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB,aAAa;AAAA,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useContext, useEffect, useMemo, useRef, useCallback, useState } from 'react';\n\nimport { useMaskedOnChange } from './useMaskedOnChange';\nimport ComboBoxContext from '../../ComboBoxCTX';\nimport { isSelectedValueEmpty } from '../../utils/listHelper';\n\ninterface UseControlsInputT {\n handleOnBlur: () => void;\n handleOnChange?: React.ChangeEventHandler<HTMLInputElement>;\n handleOnFocus: React.FocusEventHandler<HTMLInputElement>;\n showPlaceholder: string | null | undefined;\n spanReferenceText: string | undefined;\n width: number;\n spanReference: React.Ref<HTMLSpanElement>;\n}\nconst useControlsInput = (): UseControlsInputT => {\n const {\n props: { selectedValues, allOptions, placeholder, onFilter },\n setHasFocus,\n inputValue,\n setInputValue,\n setShowSelectedOptions,\n } = useContext(ComboBoxContext);\n\n const [width, setWidth] = useState(1);\n // use span reference to calculate the real width for the input\n const spanReference = useRef<HTMLSpanElement>(null);\n const showPlaceholder = !inputValue && isSelectedValueEmpty(selectedValues) ? placeholder : null;\n const spanReferenceText = inputValue.replace(/\\s/g, '\\u00a0');\n\n useEffect(() => {\n setWidth(spanReference.current?.offsetWidth ? spanReference.current.offsetWidth + 2 : 1);\n }, [inputValue]);\n\n // if we se an input mask we configure inside here the proper mask\n // or a stardard combobox onchange event\n const handleOnChange = useMaskedOnChange();\n\n const handleOnBlur = useCallback(() => {\n setInputValue('');\n if (onFilter) onFilter(allOptions, inputValue);\n setHasFocus(false);\n // setShowSelectedOptions(false);\n }, [setInputValue, onFilter, allOptions, inputValue, setHasFocus, setShowSelectedOptions]);\n\n const handleOnFocus = useCallback(() => {\n setHasFocus(true);\n }, [setHasFocus]);\n\n return useMemo(\n () => ({\n handleOnBlur,\n handleOnChange,\n handleOnFocus,\n showPlaceholder,\n spanReferenceText,\n width,\n spanReference,\n }),\n [handleOnBlur, handleOnChange, handleOnFocus, spanReferenceText, showPlaceholder, width, spanReference],\n );\n};\n\nexport { useControlsInput };\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEA;AACA;AACA;AAWA,MAAM,mBAAmB,MAAyB;AAChD,QAAM;AAAA,IACJ,OAAO,EAAE,gBAAgB,YAAY,aAAa;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MACE,WAAW;AAEf,QAAM,CAAC,OAAO,YAAY,SAAS;AAEnC,QAAM,gBAAgB,OAAwB;AAC9C,QAAM,kBAAkB,CAAC,cAAc,qBAAqB,kBAAkB,cAAc;AAC5F,QAAM,oBAAoB,WAAW,QAAQ,OAAO;AAEpD,YAAU,MAAM;AACd,aAAS,cAAc,SAAS,cAAc,cAAc,QAAQ,cAAc,IAAI;AAAA,KACrF,CAAC;AAIJ,QAAM,iBAAiB;AAEvB,QAAM,eAAe,YAAY,MAAM;AACrC,kBAAc;AACd,QAAI;AAAU,eAAS,YAAY;AACnC,gBAAY;AAAA,KAEX,CAAC,eAAe,UAAU,YAAY,YAAY,aAAa;AAElE,QAAM,gBAAgB,YAAY,MAAM;AACtC,gBAAY;AAAA,KACX,CAAC;AAEJ,SAAO,QACL,MAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,MAEF,CAAC,cAAc,gBAAgB,eAAe,mBAAmB,iBAAiB,OAAO;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|