@elliemae/ds-form-layout-autocomplete 3.52.0-rc.9 → 3.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Autocomplete.js +1 -1
- package/dist/cjs/Autocomplete.js.map +2 -2
- package/dist/cjs/config/useAutocomplete.js +9 -13
- package/dist/cjs/config/useAutocomplete.js.map +2 -2
- package/dist/cjs/config/useHandleFocusOnPopoverOpenLogic.js +53 -0
- package/dist/cjs/config/useHandleFocusOnPopoverOpenLogic.js.map +7 -0
- package/dist/cjs/config/usePopoverLogic.js +41 -46
- package/dist/cjs/config/usePopoverLogic.js.map +2 -2
- package/dist/cjs/parts/container/useKeyboardNavigation.js +2 -3
- package/dist/cjs/parts/container/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +14 -4
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/typescript-testing/typescript-autocomplete-valid.js +2 -1
- package/dist/cjs/typescript-testing/typescript-autocomplete-valid.js.map +2 -2
- package/dist/cjs/utils/listHelper.js +2 -0
- package/dist/cjs/utils/listHelper.js.map +2 -2
- package/dist/esm/Autocomplete.js +2 -2
- package/dist/esm/Autocomplete.js.map +2 -2
- package/dist/esm/config/useAutocomplete.js +9 -13
- package/dist/esm/config/useAutocomplete.js.map +2 -2
- package/dist/esm/config/useHandleFocusOnPopoverOpenLogic.js +23 -0
- package/dist/esm/config/useHandleFocusOnPopoverOpenLogic.js.map +7 -0
- package/dist/esm/config/usePopoverLogic.js +41 -46
- package/dist/esm/config/usePopoverLogic.js.map +2 -2
- package/dist/esm/parts/container/useKeyboardNavigation.js +1 -2
- package/dist/esm/parts/container/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +15 -5
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/typescript-testing/typescript-autocomplete-valid.js +2 -1
- package/dist/esm/typescript-testing/typescript-autocomplete-valid.js.map +2 -2
- package/dist/esm/utils/listHelper.js +2 -0
- package/dist/esm/utils/listHelper.js.map +2 -2
- package/dist/types/config/useAutocomplete.d.ts +2 -2
- package/dist/types/config/useHandleFocusOnPopoverOpenLogic.d.ts +8 -0
- package/dist/types/react-desc-prop-types.d.ts +5 -382
- package/dist/types/tests/keyboard-interactions/composition-keyboard-interactions.test.d.ts +1 -0
- package/dist/types/utils/listHelper.d.ts +1 -0
- package/package.json +12 -12
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { useMemo, useState, useRef } from "react";
|
|
3
|
-
import { uid } from "uid";
|
|
4
|
-
import { cloneDeep } from "lodash";
|
|
5
2
|
import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
|
|
6
|
-
import {
|
|
3
|
+
import { cloneDeep } from "lodash-es";
|
|
4
|
+
import { useMemo, useState } from "react";
|
|
5
|
+
import { uid } from "uid";
|
|
7
6
|
import { DSAutocompleteName } from "../DSAutocompleteDefinitions.js";
|
|
7
|
+
import { DSAutocompletePropTypes, defaultProps } from "../react-desc-prop-types.js";
|
|
8
|
+
import { usePopoverLogic } from "./usePopoverLogic.js";
|
|
8
9
|
import { useRefs } from "./useRefs.js";
|
|
9
10
|
import { useVirtualization } from "./useVirtualization.js";
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
...defaultProps,
|
|
14
|
-
innerRef: useRef(null)
|
|
15
|
-
};
|
|
16
|
-
const propsWithDefault = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);
|
|
17
|
-
useValidateTypescriptPropTypes(propsWithDefault, propTypes, DSAutocompleteName);
|
|
11
|
+
const useAutocomplete = (propsFromUser) => {
|
|
12
|
+
const propsWithDefault = useMemoMergePropsWithDefault(propsFromUser, defaultProps);
|
|
13
|
+
useValidateTypescriptPropTypes(propsWithDefault, DSAutocompletePropTypes, DSAutocompleteName);
|
|
18
14
|
const { options } = propsWithDefault;
|
|
19
15
|
const [referenceElement, setReferenceElement] = useState(null);
|
|
20
16
|
const [focusOptionIdx, setCurrentOption] = useState("");
|
|
@@ -48,7 +44,7 @@ const useAutocomplete = (props) => {
|
|
|
48
44
|
const popoverManager = usePopoverLogic(propsWithDefault, setCurrentOption);
|
|
49
45
|
const ctx = useMemo(
|
|
50
46
|
() => ({
|
|
51
|
-
props:
|
|
47
|
+
props: propsWithDefault,
|
|
52
48
|
referenceElement,
|
|
53
49
|
focusOptionIdx,
|
|
54
50
|
setCurrentOption,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useAutocomplete.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { cloneDeep } from 'lodash-es';\nimport { useMemo, useState } from 'react';\nimport { uid } from 'uid';\nimport { DSAutocompleteName } from '../DSAutocompleteDefinitions.js';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport { DSAutocompletePropTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { usePopoverLogic } from './usePopoverLogic.js';\nimport { useRefs } from './useRefs.js';\nimport { useVirtualization } from './useVirtualization.js';\n\nexport type AutocompleteContextT = ReturnType<typeof useRefs> &\n ReturnType<typeof useVirtualization> &\n ReturnType<typeof usePopoverLogic> & {\n props: DSAutocompleteT.InternalProps;\n referenceElement: HTMLElement | null;\n focusOptionIdx: string;\n autoCompleteId: string;\n optionsPerSection: DSAutocompleteT.InternalProps['options'];\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n };\n\nexport const useAutocomplete = (propsFromUser: DSAutocompleteT.Props): AutocompleteContextT => {\n // =============================================================================\n // MERGE WITH DEFAULT AND VALIDATE PROPS\n // =============================================================================\n const propsWithDefault = useMemoMergePropsWithDefault<DSAutocompleteT.InternalProps>(propsFromUser, defaultProps);\n useValidateTypescriptPropTypes(propsWithDefault, DSAutocompletePropTypes, DSAutocompleteName);\n\n const { options } = propsWithDefault;\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n\n const references = useRefs();\n\n // Why are we cloning the options?\n // TODO - confirm, is this to solve the \"redux\" frozen object issue?\n // if yes, why do we need to mutate the options in the first place?\n const clonedOptions = useMemo(() => cloneDeep(options), [options]);\n\n // we need to group the options by sections to render them in the correct HTML sementic order\n const optionsPerSection = useMemo(() => {\n const result: DSAutocompleteT.OptionTypes[] = [];\n let currentSection: DSAutocompleteT.ItemSectionOptions | null = null;\n\n clonedOptions.forEach((item) => {\n if (item.type === 'section') {\n // Start a new section\n currentSection = {\n dsId: item.dsId,\n type: item.type,\n label: item.label,\n options: [],\n };\n result.push(currentSection);\n } else if (item.type === 'option' && currentSection) {\n // Add option to the current section's options array\n currentSection.options.push(item);\n } else if (item.type === 'option') {\n // If we encounter an option without a section, push it to the result array\n result.push(item);\n }\n });\n return result;\n }, [clonedOptions]);\n\n const virtualizationManager = useVirtualization({\n references,\n options: optionsPerSection,\n });\n\n const autoCompleteId = useMemo(() => uid(4), []);\n const popoverManager = usePopoverLogic(propsWithDefault, setCurrentOption);\n\n const ctx = useMemo(\n () => ({\n props: propsWithDefault,\n referenceElement,\n focusOptionIdx,\n setCurrentOption,\n setReferenceElement,\n autoCompleteId,\n optionsPerSection,\n ...references,\n ...popoverManager,\n ...virtualizationManager,\n }),\n [\n propsWithDefault,\n autoCompleteId,\n referenceElement,\n focusOptionIdx,\n popoverManager,\n references,\n virtualizationManager,\n optionsPerSection,\n ],\n );\n\n return ctx;\n};\n"],
|
|
5
|
+
"mapp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/C,QAAM,iBAAiB,gBAAgB,kBAAkB,gBAAgB;AAEzE,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG;AAAA,IACL;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useEffect } from "react";
|
|
3
|
+
import { getFirstOption } from "../utils/listHelper.js";
|
|
4
|
+
const useHandleFocusOnPopoverOpenLogic = ({
|
|
5
|
+
options,
|
|
6
|
+
forceFocusFirstOptionOnType,
|
|
7
|
+
isShowingPopover,
|
|
8
|
+
setCurrentOption
|
|
9
|
+
}) => {
|
|
10
|
+
const firstOptionId = getFirstOption(options);
|
|
11
|
+
const firstOptionIdRef = React2.useRef(firstOptionId);
|
|
12
|
+
firstOptionIdRef.current = firstOptionId ?? "";
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (isShowingPopover) {
|
|
15
|
+
if (forceFocusFirstOptionOnType) setCurrentOption(firstOptionIdRef.current);
|
|
16
|
+
else setCurrentOption("");
|
|
17
|
+
}
|
|
18
|
+
}, [forceFocusFirstOptionOnType, isShowingPopover, setCurrentOption]);
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
useHandleFocusOnPopoverOpenLogic
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=useHandleFocusOnPopoverOpenLogic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useHandleFocusOnPopoverOpenLogic.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useEffect } from 'react';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport { getFirstOption } from '../utils/listHelper.js';\n\nexport const useHandleFocusOnPopoverOpenLogic = ({\n options,\n forceFocusFirstOptionOnType,\n isShowingPopover,\n setCurrentOption,\n}: {\n options: DSAutocompleteT.OptionTypes[];\n forceFocusFirstOptionOnType: boolean;\n isShowingPopover: boolean;\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n}) => {\n // on opening the popover, we have a flag to force focus on the first option\n // to handle the scenario since we are completely state-agnostic(we read the state from the props)\n // we need to sync with an external source of truth, in this scenario the useEffect is \"okay\"\n // (even if useEffect should be avoided in general)\n const firstOptionId = getFirstOption(options);\n // the useEffect is to be executed strictly when the popover is about to open\n // the first option Id is to be readed only at time of execution of the side-effect to \"opening\"\n // to achieve this, we use a ref to store the value of the first option Id\n // this is to avoid re-executing the useEffect when the first option Id changes if the popover is not about to open\n const firstOptionIdRef = React.useRef(firstOptionId);\n firstOptionIdRef.current = firstOptionId ?? '';\n useEffect(() => {\n if (isShowingPopover) {\n if (forceFocusFirstOptionOnType) setCurrentOption(firstOptionIdRef.current);\n else setCurrentOption('');\n }\n }, [forceFocusFirstOptionOnType, isShowingPopover, setCurrentOption]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,iBAAiB;AAEjC,SAAS,sBAAsB;AAExB,MAAM,mCAAmC,CAAC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AAKJ,QAAM,gBAAgB,eAAe,OAAO;AAK5C,QAAM,mBAAmBA,OAAM,OAAO,aAAa;AACnD,mBAAiB,UAAU,iBAAiB;AAC5C,YAAU,MAAM;AACd,QAAI,kBAAkB;AACpB,UAAI,4BAA6B,kBAAiB,iBAAiB,OAAO;AAAA,UACrE,kBAAiB,EAAE;AAAA,IAC1B;AAAA,EACF,GAAG,CAAC,6BAA6B,kBAAkB,gBAAgB,CAAC;AACtE;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React2, { useState, useEffect } from "react";
|
|
3
|
+
import { useHandleFocusOnPopoverOpenLogic } from "./useHandleFocusOnPopoverOpenLogic.js";
|
|
3
4
|
const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
4
|
-
const { options, filter } = propsWithDefault;
|
|
5
|
+
const { options, filter, forceFocusFirstOptionOnType } = propsWithDefault;
|
|
5
6
|
const [forceClosePopover, setForceClosePopover] = useState(false);
|
|
6
7
|
const [userTypedSomething, setUserTypedSomething] = useState(false);
|
|
7
8
|
const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = useState(false);
|
|
@@ -13,39 +14,32 @@ const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
|
13
14
|
!userSelectedAndDidNotType && // user just selected an option --> hide popover
|
|
14
15
|
(userTypedSomething || // user typed something --> show popover
|
|
15
16
|
userIsNavigatingWithArrows);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const { key } = e;
|
|
43
|
-
if (key === "Enter" && isShowingPopover) {
|
|
44
|
-
setUserJustSelectedAnOption(true);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
[isShowingPopover]
|
|
48
|
-
);
|
|
17
|
+
const isShowingRef = React2.useRef(isShowingPopover);
|
|
18
|
+
isShowingRef.current = isShowingPopover;
|
|
19
|
+
const trackUserTyping = React2.useCallback((e) => {
|
|
20
|
+
const { key } = e;
|
|
21
|
+
if ([...e.key].length === 1 || key === "Backspace" || key === "Delete") {
|
|
22
|
+
setUserTypedSomething(true);
|
|
23
|
+
setForceClosePopover(false);
|
|
24
|
+
setUserJustSelectedAnOption(false);
|
|
25
|
+
} else {
|
|
26
|
+
setUserTypedSomething(false);
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
const trackUserNavigatingWithArrows = React2.useCallback((e) => {
|
|
30
|
+
const { key } = e;
|
|
31
|
+
if (isShowingRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
|
|
32
|
+
setUserIsNavigatingWithArrows(true);
|
|
33
|
+
} else {
|
|
34
|
+
setUserIsNavigatingWithArrows(false);
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
const trackUserSelectingAnOption = React2.useCallback((e) => {
|
|
38
|
+
const { key } = e;
|
|
39
|
+
if (key === "Enter" && isShowingRef.current) {
|
|
40
|
+
setUserJustSelectedAnOption(true);
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
49
43
|
const trackUserInteractingViaKeyboard = React2.useCallback(
|
|
50
44
|
(e) => {
|
|
51
45
|
trackUserTyping(e);
|
|
@@ -54,21 +48,22 @@ const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
|
54
48
|
},
|
|
55
49
|
[trackUserTyping, trackUserNavigatingWithArrows, trackUserSelectingAnOption]
|
|
56
50
|
);
|
|
51
|
+
const closePopover = React2.useCallback(() => {
|
|
52
|
+
setForceClosePopover(true);
|
|
53
|
+
setCurrentOption("");
|
|
54
|
+
}, [setCurrentOption]);
|
|
57
55
|
useEffect(() => {
|
|
58
|
-
|
|
59
|
-
setForceClosePopover(true);
|
|
60
|
-
setCurrentOption("");
|
|
61
|
-
};
|
|
62
|
-
window.addEventListener("blur", closePopper);
|
|
56
|
+
window.addEventListener("blur", closePopover);
|
|
63
57
|
return () => {
|
|
64
|
-
window.removeEventListener("blur",
|
|
58
|
+
window.removeEventListener("blur", closePopover);
|
|
65
59
|
};
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
}, [closePopover]);
|
|
61
|
+
useHandleFocusOnPopoverOpenLogic({
|
|
62
|
+
options,
|
|
63
|
+
forceFocusFirstOptionOnType,
|
|
64
|
+
isShowingPopover,
|
|
65
|
+
setCurrentOption
|
|
66
|
+
});
|
|
72
67
|
return React2.useMemo(
|
|
73
68
|
() => ({
|
|
74
69
|
isShowingPopover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/usePopoverLogic.ts"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect } from 'react';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\n// we want to own all the popover logic in a single place\n// we handle global events via window.addEventListener/RemoveEventListener\n// the logic to show/hide the popover accounts for\n// show:\n// - the user just typed something (excluding special keys like arrows, enter, etc)\n// - any options are available\n// - the user did not just select an option\n// N.B. this must react to options.length changing in an async way\n// hide:\n// - the user just selected an option and did not type anything after\n// - no options are available\n// - the focus is not on the input\n// - the user pressed the escape key\nexport const usePopoverLogic = (\n propsWithDefault: DSAutocompleteT.InternalProps,\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>,\n) => {\n const { options, filter } = propsWithDefault;\n\n const [forceClosePopover, setForceClosePopover] = useState<boolean>(false);\n\n const [userTypedSomething, setUserTypedSomething] = useState<boolean>(false);\n const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = useState<boolean>(false);\n const [userJustSelectedAnOption, setUserJustSelectedAnOption] = useState<boolean>(false);\n\n const userSelectedAndDidNotType = userJustSelectedAnOption && !userTypedSomething;\n const popoverHasAnythingToShow = options.length > 0 && filter.length > 0;\n\n const isShowingPopover =\n !forceClosePopover && // user pressed escape (or other interaction that forces close) --> hide popover\n popoverHasAnythingToShow && // nothing to show --> hide popover\n !userSelectedAndDidNotType && // user just selected an option --> hide popover\n (userTypedSomething || // user typed something --> show popover\n userIsNavigatingWithArrows); // user is navigating with arrows --> show popover\n\n const trackUserTyping: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback(
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,UAAU,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect } from 'react';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport { useHandleFocusOnPopoverOpenLogic } from './useHandleFocusOnPopoverOpenLogic.js';\n\n// we want to own all the popover logic in a single place\n// we handle global events via window.addEventListener/RemoveEventListener\n// the logic to show/hide the popover accounts for\n// show:\n// - the user just typed something (excluding special keys like arrows, enter, etc)\n// - any options are available\n// - the user did not just select an option\n// N.B. this must react to options.length changing in an async way\n// hide:\n// - the user just selected an option and did not type anything after\n// - no options are available\n// - the focus is not on the input\n// - the user pressed the escape key\nexport const usePopoverLogic = (\n propsWithDefault: DSAutocompleteT.InternalProps,\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>,\n) => {\n const { options, filter, forceFocusFirstOptionOnType } = propsWithDefault;\n\n const [forceClosePopover, setForceClosePopover] = useState<boolean>(false);\n\n const [userTypedSomething, setUserTypedSomething] = useState<boolean>(false);\n const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = useState<boolean>(false);\n const [userJustSelectedAnOption, setUserJustSelectedAnOption] = useState<boolean>(false);\n\n const userSelectedAndDidNotType = userJustSelectedAnOption && !userTypedSomething;\n const popoverHasAnythingToShow = options.length > 0 && filter.length > 0;\n\n const isShowingPopover =\n !forceClosePopover && // user pressed escape (or other interaction that forces close) --> hide popover\n popoverHasAnythingToShow && // nothing to show --> hide popover\n !userSelectedAndDidNotType && // user just selected an option --> hide popover\n (userTypedSomething || // user typed something --> show popover\n userIsNavigatingWithArrows); // user is navigating with arrows --> show popover\n\n // we don't want to redeclar all the functions when the flag changes, the flag is relevant on invocation only\n // so we use a ref to store the value of the flag and use it in the functions\n const isShowingRef = React.useRef(isShowingPopover);\n isShowingRef.current = isShowingPopover;\n\n const trackUserTyping: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback((e) => {\n const { key } = e;\n // [...e.key].length === 1 -> \"printable\" characters including https://mathiasbynens.be/notes/javascript-unicode\n if ([...e.key].length === 1 || key === 'Backspace' || key === 'Delete') {\n setUserTypedSomething(true);\n setForceClosePopover(false);\n setUserJustSelectedAnOption(false);\n } else {\n setUserTypedSomething(false);\n }\n }, []);\n const trackUserNavigatingWithArrows: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback((e) => {\n const { key } = e;\n if (isShowingRef.current && (key === 'ArrowUp' || key === 'ArrowDown')) {\n setUserIsNavigatingWithArrows(true);\n } else {\n setUserIsNavigatingWithArrows(false);\n }\n }, []);\n const trackUserSelectingAnOption: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback((e) => {\n const { key } = e;\n if (key === 'Enter' && isShowingRef.current) {\n setUserJustSelectedAnOption(true);\n }\n }, []);\n\n const trackUserInteractingViaKeyboard: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback(\n (e) => {\n trackUserTyping(e);\n trackUserNavigatingWithArrows(e);\n trackUserSelectingAnOption(e);\n },\n [trackUserTyping, trackUserNavigatingWithArrows, trackUserSelectingAnOption],\n );\n const closePopover = React.useCallback(() => {\n setForceClosePopover(true);\n setCurrentOption('');\n }, [setCurrentOption]);\n\n // when the webpage is blurred, we want to close the popover\n // should be fixing iframes interactions?\n useEffect(() => {\n window.addEventListener('blur', closePopover);\n return () => {\n window.removeEventListener('blur', closePopover);\n };\n }, [closePopover]);\n\n useHandleFocusOnPopoverOpenLogic({\n options,\n forceFocusFirstOptionOnType,\n isShowingPopover,\n setCurrentOption,\n });\n\n return React.useMemo(\n () => ({\n isShowingPopover,\n forceClosePopover,\n setForceClosePopover,\n userTypedSomething,\n setUserTypedSomething,\n setUserJustSelectedAnOption,\n userIsNavigatingWithArrows,\n setUserIsNavigatingWithArrows,\n trackUserInteractingViaKeyboard,\n }),\n [\n isShowingPopover,\n forceClosePopover,\n userTypedSomething,\n userIsNavigatingWithArrows,\n trackUserInteractingViaKeyboard,\n ],\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,UAAU,iBAAiB;AAE3C,SAAS,wCAAwC;AAe1C,MAAM,kBAAkB,CAC7B,kBACA,qBACG;AACH,QAAM,EAAE,SAAS,QAAQ,4BAA4B,IAAI;AAEzD,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAkB,KAAK;AAEzE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAkB,KAAK;AAC3E,QAAM,CAAC,4BAA4B,6BAA6B,IAAI,SAAkB,KAAK;AAC3F,QAAM,CAAC,0BAA0B,2BAA2B,IAAI,SAAkB,KAAK;AAEvF,QAAM,4BAA4B,4BAA4B,CAAC;AAC/D,QAAM,2BAA2B,QAAQ,SAAS,KAAK,OAAO,SAAS;AAEvE,QAAM,mBACJ,CAAC;AAAA,EACD;AAAA,EACA,CAAC;AAAA,GACA;AAAA,EACC;AAIJ,QAAM,eAAeA,OAAM,OAAO,gBAAgB;AAClD,eAAa,UAAU;AAEvB,QAAM,kBAAgEA,OAAM,YAAY,CAAC,MAAM;AAC7F,UAAM,EAAE,IAAI,IAAI;AAEhB,QAAI,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,KAAK,QAAQ,eAAe,QAAQ,UAAU;AACtE,4BAAsB,IAAI;AAC1B,2BAAqB,KAAK;AAC1B,kCAA4B,KAAK;AAAA,IACnC,OAAO;AACL,4BAAsB,KAAK;AAAA,IAC7B;AAAA,EACF,GAAG,CA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@@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback, useContext } from "react";
|
|
3
3
|
import AutocompleteContext from "../../AutocompleteCTX.js";
|
|
4
|
-
import { findInCircularList } from "../../utils/listHelper.js";
|
|
5
|
-
const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
|
|
4
|
+
import { findInCircularList, isOptionFocuseable } from "../../utils/listHelper.js";
|
|
6
5
|
const useKeyboardNavigation = () => {
|
|
7
6
|
const {
|
|
8
7
|
props: { onSelect, options },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/container/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 type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { findInCircularList } from '../../utils/listHelper.js';\n\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACKvB,SAAS,aAAa,kBAAkB;AAExC,OAAO,yBAAyB;AAChC,SAAS,0BAA0B;
|
|
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 type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { findInCircularList, isOptionFocuseable } from '../../utils/listHelper.js';\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { onSelect, options },\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(AutocompleteContext);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find(\n (item) => item.type === 'option' && item.dsId === focusOptionIdx,\n ) as DSAutocompleteT.ItemOption;\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // =============================================================================\n // TRACK STATE OF POPOVER SHOWING OR NOT\n // =============================================================================\n trackUserInteractingViaKeyboard(e);\n\n if (e.key === 'Tab' || e.key === 'Escape') setForceClosePopover(true);\n\n // =============================================================================\n // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER\n // AFTER https://jira.elliemae.io/browse/PUI-14625\n // AUTOFOCUS ON FIRST OPTION WAS REMOVED\n // pressing Enter now is not necessarily selecting the first option (if popover is open)\n // now to ensure the first option is selected, the user has to press ArrowDown\n // so, if no focus (so no currentItem) is set, this is not a \"onSelect\" event\n // =============================================================================\n if (e.key === 'Enter' && isShowingPopover && currentItem?.label !== undefined) {\n e.preventDefault();\n onSelect(currentItem?.label, e);\n }\n\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n },\n [\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n onSelect,\n currentItem?.label,\n options,\n currentItemIndex,\n setCurrentOption,\n scrollOptionIntoView,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;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ACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { globalAttributesPropTypes, PropTypes } from "@elliemae/ds-props-helpers";
|
|
2
|
+
import { globalAttributesPropTypes, PropTypes, xstyledPropTypes } from "@elliemae/ds-props-helpers";
|
|
3
3
|
const defaultProps = {
|
|
4
4
|
zIndex: 10,
|
|
5
5
|
withoutPortal: false,
|
|
6
|
+
forceFocusFirstOptionOnType: false,
|
|
6
7
|
startPlacementPreference: "bottom-start",
|
|
7
8
|
placementOrderPreference: ["bottom-start", "bottom-end"]
|
|
8
9
|
};
|
|
9
|
-
const
|
|
10
|
+
const DSAutocompletePropTypes = {
|
|
10
11
|
...globalAttributesPropTypes,
|
|
12
|
+
...xstyledPropTypes,
|
|
11
13
|
options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired.description("List of options").defaultValue([]),
|
|
12
14
|
filter: PropTypes.string.isRequired.description("String value to filter the options").defaultValue(""),
|
|
13
15
|
onSelect: PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue(""),
|
|
14
16
|
children: PropTypes.node.description("React component to apply autocomplete functionality").defaultValue("").deprecated({ version: "3.x" }),
|
|
15
17
|
inputProps: PropTypes.object.description("Props to pass to the input component").defaultValue({}),
|
|
16
18
|
onValueChange: PropTypes.func.description("Function triggered when the value of the input changes").defaultValue(""),
|
|
17
|
-
renderInput: PropTypes.func.description("Function to render the input").defaultValue("")
|
|
19
|
+
renderInput: PropTypes.func.description("Function to render the input").defaultValue(""),
|
|
20
|
+
startPlacementPreference: PropTypes.string.description("Ideal preference for context placement").defaultValue("bottom-start"),
|
|
21
|
+
placementOrderPreference: PropTypes.arrayOf(PropTypes.string).description("Placement preferences for the context menu in order of most preferred to least preferred").defaultValue("['bottom-start', 'bottom-end']"),
|
|
22
|
+
withoutPortal: PropTypes.bool.description("Whether to render the context menu in a react portal or next to the input DOM element").defaultValue("false (next to the input)"),
|
|
23
|
+
forceFocusFirstOptionOnType: PropTypes.bool.description(
|
|
24
|
+
"Whether to focus the first option when typing (NOT RECOMMENDED AND BREAKING A11Y STANDARDS + ALL USERS USABILITY)"
|
|
25
|
+
).defaultValue("false")
|
|
18
26
|
};
|
|
27
|
+
const DSAutocompletePropTypesSchema = DSAutocompletePropTypes;
|
|
19
28
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
DSAutocompletePropTypes,
|
|
30
|
+
DSAutocompletePropTypesSchema,
|
|
31
|
+
defaultProps
|
|
22
32
|
};
|
|
23
33
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/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 type React from 'react';\nimport type { GlobalAttributesT, XstyledProps } from '@elliemae/ds-props-helpers';\nimport { globalAttributesPropTypes, PropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSInputTextT } from '@elliemae/ds-form-input-text';\
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,2BAA2B,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport { globalAttributesPropTypes, PropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSInputTextT } from '@elliemae/ds-form-input-text';\n\nexport declare namespace DSAutocompleteT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n // this was never implemented?\n // packages/forms/ds-form-layout-autocomplete/src/parts/menu-list/useItemRenderer.tsx\n // only have code for ItemOption and ItemSectionOptions...\n // export interface ItemSeparatorOptions extends CommonItemOptions {\n // type: 'separator';\n // }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n options: ItemOption[];\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;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n filter: string;\n onSelect: (\n suggestedValue: string,\n e: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement>,\n ) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: string[];\n withoutPortal: boolean;\n zIndex: number;\n forceFocusFirstOptionOnType: boolean;\n }\n\n export interface OptionalProps {\n children?: React.ReactNode;\n inputProps?: DSInputTextT.Props;\n onValueChange?: (nextValue: string | number, e: React.ChangeEvent<HTMLInputElement>) => void;\n renderInput?: (props: React.InputHTMLAttributes<HTMLInputElement>) => React.ReactNode;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n\n export interface InternalProps\n extends DefaultProps,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n}\n\nexport const defaultProps: DSAutocompleteT.DefaultProps = {\n zIndex: 10,\n withoutPortal: false,\n forceFocusFirstOptionOnType: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n};\n\nexport const DSAutocompletePropTypes: DSPropTypesSchema<DSAutocompleteT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\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\n .description('React component to apply autocomplete functionality')\n .defaultValue('')\n .deprecated({ version: '3.x' }),\n inputProps: PropTypes.object.description('Props to pass to the input component').defaultValue({}),\n onValueChange: PropTypes.func.description('Function triggered when the value of the input changes').defaultValue(''),\n renderInput: PropTypes.func.description('Function to render the input').defaultValue(''),\n startPlacementPreference: PropTypes.string\n .description('Ideal preference for context placement')\n .defaultValue('bottom-start'),\n placementOrderPreference: PropTypes.arrayOf(PropTypes.string)\n .description('Placement preferences for the context menu in order of most preferred to least preferred')\n .defaultValue(\"['bottom-start', 'bottom-end']\"),\n withoutPortal: PropTypes.bool\n .description('Whether to render the context menu in a react portal or next to the input DOM element')\n .defaultValue('false (next to the input)'),\n forceFocusFirstOptionOnType: PropTypes.bool\n .description(\n 'Whether to focus the first option when typing (NOT RECOMMENDED AND BREAKING A11Y STANDARDS + ALL USERS USABILITY)',\n )\n .defaultValue('false'),\n};\n\nexport const DSAutocompletePropTypesSchema = DSAutocompletePropTypes as unknown as ValidationMap<DSAutocompleteT.Props>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,2BAA2B,WAAW,wBAAwB;AA0EhE,MAAM,eAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,6BAA6B;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,YAAY;AACzD;AAEO,MAAM,0BAAoE;AAAA,EAC/E,GAAG;AAAA,EACH,GAAG;AAAA,EACH,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,UAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,UAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,UAAU,KACjB,YAAY,qDAAqD,EACjE,aAAa,EAAE,EACf,WAAW,EAAE,SAAS,MAAM,CAAC;AAAA,EAChC,YAAY,UAAU,OAAO,YAAY,sCAAsC,EAAE,aAAa,CAAC,CAAC;AAAA,EAChG,eAAe,UAAU,KAAK,YAAY,wDAAwD,EAAE,aAAa,EAAE;AAAA,EACnH,aAAa,UAAU,KAAK,YAAY,8BAA8B,EAAE,aAAa,EAAE;AAAA,EACvF,0BAA0B,UAAU,OACjC,YAAY,wCAAwC,EACpD,aAAa,cAAc;AAAA,EAC9B,0BAA0B,UAAU,QAAQ,UAAU,MAAM,EACzD,YAAY,0FAA0F,EACtG,aAAa,gCAAgC;AAAA,EAChD,eAAe,UAAU,KACtB,YAAY,uFAAuF,EACnG,aAAa,2BAA2B;AAAA,EAC3C,6BAA6B,UAAU,KACpC;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AACzB;AAEO,MAAM,gCAAgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -23,7 +23,8 @@ const testCompleteDefaults = {
|
|
|
23
23
|
startPlacementPreference: "bottom",
|
|
24
24
|
placementOrderPreference: ["bottom", "top"],
|
|
25
25
|
withoutPortal: false,
|
|
26
|
-
zIndex: 1e3
|
|
26
|
+
zIndex: 1e3,
|
|
27
|
+
forceFocusFirstOptionOnType: false
|
|
27
28
|
};
|
|
28
29
|
const testInternalProps = {
|
|
29
30
|
...testRequiredProps,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/typescript-testing/typescript-autocomplete-valid.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSAutocomplete } from '../index.js';\nimport type { DSAutocompleteT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSAutocompleteT.Props;\ntype ComponentPropsInternals = DSAutocompleteT.InternalProps;\ntype ComponentPropsDefaultProps = DSAutocompleteT.DefaultProps;\ntype ComponentPropsRequiredProps = DSAutocompleteT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n options: [],\n onSelect: () => {},\n filter: '',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: <div />,\n options: [],\n onSelect: () => {},\n filter: '',\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: <div />,\n options: [],\n onSelect: () => {},\n filter: '',\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSAutocomplete {...testExplicitDefinition} />\n <DSAutocomplete {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSAutocomplete\n options={[]}\n onSelect={() => {}}\n filter=\"\"\n startPlacementPreference=\"bottom\"\n placementOrderPreference={['bottom', 'top']}\n withoutPortal={false}\n zIndex={1000}\n >\n <input />\n </DSAutocomplete>\n </>\n);\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars, no-unused-vars */\nimport { DSAutocomplete } from '../index.js';\nimport type { DSAutocompleteT } from '../index.js';\n\n// test we expose the namespace and the namespace follows our deliverable conventions\ntype ComponentPropsForApp = DSAutocompleteT.Props;\ntype ComponentPropsInternals = DSAutocompleteT.InternalProps;\ntype ComponentPropsDefaultProps = DSAutocompleteT.DefaultProps;\ntype ComponentPropsRequiredProps = DSAutocompleteT.RequiredProps;\n\nconst testRequiredProps: ComponentPropsRequiredProps = {\n options: [],\n onSelect: () => {},\n filter: '',\n};\n\n// difference Props and InternalProps is that InternalProps has all the default props filled in\n// Props allows for partial defaults\nconst testPartialDefaults: Partial<ComponentPropsDefaultProps> = {\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n};\n\nconst testProps: ComponentPropsForApp = {\n ...testRequiredProps,\n ...testPartialDefaults,\n};\nconst testPropsAsSyntax = {\n ...testRequiredProps,\n ...testPartialDefaults,\n} as ComponentPropsForApp;\n// InternalProps requires all defaults to be filled in\nconst testCompleteDefaults: Required<ComponentPropsDefaultProps> = {\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n forceFocusFirstOptionOnType: false,\n};\nconst testInternalProps: ComponentPropsInternals = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n};\nconst testInternalPropsAsSyntax = {\n ...testRequiredProps,\n ...testCompleteDefaults,\n} as ComponentPropsInternals;\n\n// using the explicit type definition, if there is an error, it will be marked on the key that is wrong\nconst testExplicitDefinition: ComponentPropsForApp = {\n children: <div />,\n options: [],\n onSelect: () => {},\n filter: '',\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n};\n\n// using the \"as\" syntax, if there is an error, it will be marking the whole object as wrong because it is not compatible with the type\nconst testInferedTypeCompatibility = {\n children: <div />,\n options: [],\n onSelect: () => {},\n filter: '',\n startPlacementPreference: 'bottom',\n placementOrderPreference: ['bottom', 'top'],\n withoutPortal: false,\n zIndex: 1000,\n} as ComponentPropsForApp;\n\nconst ExampleUsageComponent = () => (\n <>\n {/* works with explicitly casted props, all syntaxes */}\n <DSAutocomplete {...testExplicitDefinition} />\n <DSAutocomplete {...testInferedTypeCompatibility} />\n {/* works with inline values */}\n <DSAutocomplete\n options={[]}\n onSelect={() => {}}\n filter=\"\"\n startPlacementPreference=\"bottom\"\n placementOrderPreference={['bottom', 'top']}\n withoutPortal={false}\n zIndex={1000}\n >\n <input />\n </DSAutocomplete>\n </>\n);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACkDX,SAuBV,UAvBU,KAuBV,YAvBU;AAjDZ,SAAS,sBAAsB;AAS/B,MAAM,oBAAiD;AAAA,EACrD,SAAS,CAAC;AAAA,EACV,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,QAAQ;AACV;AAIA,MAAM,sBAA2D;AAAA,EAC/D,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,UAAU,KAAK;AAC5C;AAEA,MAAM,YAAkC;AAAA,EACtC,G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 const getFirstOption = (options) => {
|
|
|
16
16
|
}
|
|
17
17
|
return "";
|
|
18
18
|
};
|
|
19
|
+
const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
|
|
19
20
|
export {
|
|
20
21
|
findInCircularList,
|
|
21
22
|
getFirstOption,
|
|
22
23
|
getOptions,
|
|
23
24
|
getSelectableOptions,
|
|
25
|
+
isOptionFocuseable,
|
|
24
26
|
isSelectedValueEmpty,
|
|
25
27
|
isSelectedValueMultiple
|
|
26
28
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/listHelper.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\nexport const getSelectableOptions = (\n options: Array<DSAutocompleteT.OptionTypes>,\n): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option' && !option.disabled) : [];\n\nexport const getOptions = (options: Array<DSAutocompleteT.OptionTypes>): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option') : [];\n\nexport const isSelectedValueEmpty = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => (Array.isArray(value) ? value.length === 0 : !value);\n\nexport const isSelectedValueMultiple = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => Array.isArray(value);\n\nexport const findInCircularList = (\n list: DSAutocompleteT.OptionTypes[],\n from: number,\n criteria: (item: DSAutocompleteT.OptionTypes) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from >= -1;\n i = (i + step + list.length) % list.length\n ) {\n if (criteria(list[i])) return i;\n }\n return from; // return same item\n};\n\nexport const 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,YAAY,WAAW;ACEhB,MAAM,uBAAuB,CAClC,YAEA,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,QAAQ,IAAI,CAAC;AAEjF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,QAAQ,IAAI,CAAC;AAE7D,MAAM,uBAAuB,CAClC,UACa,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,CAAC;AAErD,MAAM,0BAA0B,CACrC,UACY,MAAM,QAAQ,KAAK;AAE1B,MAAM,qBAAqB,CAChC,MACA,MACA,UACA,OAAO,MAEI;AACX,WACM,KAAK,OAAO,OAAO,KAAK,UAAU,KAAK,QAC3C,MAAM,QAAQ,QAAQ,IACtB,KAAK,IAAI,OAAO,KAAK,UAAU,KAAK,QACpC;AACA,QAAI,SAAS,KAAK,CAAC,CAAC,EAAG,QAAO;AAAA,EAChC;AACA,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,YAA2C;AACxE,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,QAAQ,CAAC,EAAE,IAAI,GAAG;AACvD,aAAO,QAAQ,CAAC,EAAE;AAAA,IACpB;AACF,SAAO;AACT;",
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\nexport const getSelectableOptions = (\n options: Array<DSAutocompleteT.OptionTypes>,\n): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option' && !option.disabled) : [];\n\nexport const getOptions = (options: Array<DSAutocompleteT.OptionTypes>): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option') : [];\n\nexport const isSelectedValueEmpty = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => (Array.isArray(value) ? value.length === 0 : !value);\n\nexport const isSelectedValueMultiple = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => Array.isArray(value);\n\nexport const findInCircularList = (\n list: DSAutocompleteT.OptionTypes[],\n from: number,\n criteria: (item: DSAutocompleteT.OptionTypes) => boolean,\n step = 1,\n // eslint-disable-next-line max-params\n): number => {\n for (\n let i = (from + step + list.length) % list.length;\n i !== from && from >= -1;\n i = (i + step + list.length) % list.length\n ) {\n if (criteria(list[i])) return i;\n }\n return from; // return same item\n};\n\nexport const 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\nexport const isOptionFocuseable = (opt: DSAutocompleteT.OptionTypes): boolean =>\n !['section', 'separator'].includes(opt.type);\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACEhB,MAAM,uBAAuB,CAClC,YAEA,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,QAAQ,IAAI,CAAC;AAEjF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,QAAQ,IAAI,CAAC;AAE7D,MAAM,uBAAuB,CAClC,UACa,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,CAAC;AAErD,MAAM,0BAA0B,CACrC,UACY,MAAM,QAAQ,KAAK;AAE1B,MAAM,qBAAqB,CAChC,MACA,MACA,UACA,OAAO,MAEI;AACX,WACM,KAAK,OAAO,OAAO,KAAK,UAAU,KAAK,QAC3C,MAAM,QAAQ,QAAQ,IACtB,KAAK,IAAI,OAAO,KAAK,UAAU,KAAK,QACpC;AACA,QAAI,SAAS,KAAK,CAAC,CAAC,EAAG,QAAO;AAAA,EAChC;AACA,SAAO;AACT;AAEO,MAAM,iBAAiB,CAAC,YAA2C;AACxE,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,QAAQ,CAAC,EAAE,IAAI,GAAG;AACvD,aAAO,QAAQ,CAAC,EAAE;AAAA,IACpB;AACF,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,QACjC,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DSAutocompleteT } from '../react-desc-prop-types.js';
|
|
3
|
+
import { usePopoverLogic } from './usePopoverLogic.js';
|
|
3
4
|
import { useRefs } from './useRefs.js';
|
|
4
5
|
import { useVirtualization } from './useVirtualization.js';
|
|
5
|
-
import { usePopoverLogic } from './usePopoverLogic.js';
|
|
6
6
|
export type AutocompleteContextT = ReturnType<typeof useRefs> & ReturnType<typeof useVirtualization> & ReturnType<typeof usePopoverLogic> & {
|
|
7
7
|
props: DSAutocompleteT.InternalProps;
|
|
8
8
|
referenceElement: HTMLElement | null;
|
|
@@ -12,4 +12,4 @@ export type AutocompleteContextT = ReturnType<typeof useRefs> & ReturnType<typeo
|
|
|
12
12
|
setCurrentOption: React.Dispatch<React.SetStateAction<string>>;
|
|
13
13
|
setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
|
14
14
|
};
|
|
15
|
-
export declare const useAutocomplete: (
|
|
15
|
+
export declare const useAutocomplete: (propsFromUser: DSAutocompleteT.Props) => AutocompleteContextT;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DSAutocompleteT } from '../react-desc-prop-types.js';
|
|
3
|
+
export declare const useHandleFocusOnPopoverOpenLogic: ({ options, forceFocusFirstOptionOnType, isShowingPopover, setCurrentOption, }: {
|
|
4
|
+
options: DSAutocompleteT.OptionTypes[];
|
|
5
|
+
forceFocusFirstOptionOnType: boolean;
|
|
6
|
+
isShowingPopover: boolean;
|
|
7
|
+
setCurrentOption: React.Dispatch<React.SetStateAction<string>>;
|
|
8
|
+
}) => void;
|