@elliemae/ds-form-layout-autocomplete 3.52.0-rc.15 → 3.52.0-rc.16
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 +8 -12
- 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 +9 -9
package/dist/cjs/Autocomplete.js
CHANGED
|
@@ -46,5 +46,5 @@ const DSAutocomplete = (props) => {
|
|
|
46
46
|
};
|
|
47
47
|
DSAutocomplete.displayName = import_DSAutocompleteDefinitions.DSAutocompleteName;
|
|
48
48
|
const DSAutocompleteWithSchema = (0, import_ds_props_helpers.describe)(DSAutocomplete);
|
|
49
|
-
DSAutocompleteWithSchema.propTypes = import_react_desc_prop_types.
|
|
49
|
+
DSAutocompleteWithSchema.propTypes = import_react_desc_prop_types.DSAutocompletePropTypesSchema;
|
|
50
50
|
//# sourceMappingURL=Autocomplete.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Autocomplete.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useAutocomplete } from './config/useAutocomplete.js';\nimport { Container } from './parts/container/index.js';\nimport { AutocompleteContext } from './AutocompleteCTX.js';\nimport type { DSAutocompleteT } from './react-desc-prop-types.js';\nimport { DSAutocompletePropTypesSchema } from './react-desc-prop-types.js';\nimport { DSAutocompleteName } from './DSAutocompleteDefinitions.js';\n\nconst DSAutocomplete: React.ComponentType<DSAutocompleteT.Props> = (props) => {\n const ctx = useAutocomplete(props);\n return (\n <AutocompleteContext.Provider value={ctx}>\n <Container />\n </AutocompleteContext.Provider>\n );\n};\n\nDSAutocomplete.displayName = DSAutocompleteName;\nconst DSAutocompleteWithSchema = describe(DSAutocomplete);\nDSAutocompleteWithSchema.propTypes = DSAutocompletePropTypesSchema;\n\nexport { DSAutocomplete, DSAutocompleteWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADajB;AAZN,8BAAyB;AACzB,6BAAgC;AAChC,uBAA0B;AAC1B,6BAAoC;AAEpC,mCAA8C;AAC9C,uCAAmC;AAEnC,MAAM,iBAA6D,CAAC,UAAU;AAC5E,QAAM,UAAM,wCAAgB,KAAK;AACjC,SACE,4CAAC,2CAAoB,UAApB,EAA6B,OAAO,KACnC,sDAAC,8BAAU,GACb;AAEJ;AAEA,eAAe,cAAc;AAC7B,MAAM,+BAA2B,kCAAS,cAAc;AACxD,yBAAyB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,22 +32,18 @@ __export(useAutocomplete_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(useAutocomplete_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
35
37
|
var import_react = require("react");
|
|
36
38
|
var import_uid = require("uid");
|
|
37
|
-
var import_lodash = require("lodash");
|
|
38
|
-
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
39
|
-
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
|
40
39
|
var import_DSAutocompleteDefinitions = require("../DSAutocompleteDefinitions.js");
|
|
40
|
+
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
|
41
|
+
var import_usePopoverLogic = require("./usePopoverLogic.js");
|
|
41
42
|
var import_useRefs = require("./useRefs.js");
|
|
42
43
|
var import_useVirtualization = require("./useVirtualization.js");
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
...import_react_desc_prop_types.defaultProps,
|
|
47
|
-
innerRef: (0, import_react.useRef)(null)
|
|
48
|
-
};
|
|
49
|
-
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(props, defaultPropsWithInnerRef);
|
|
50
|
-
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.propTypes, import_DSAutocompleteDefinitions.DSAutocompleteName);
|
|
44
|
+
const useAutocomplete = (propsFromUser) => {
|
|
45
|
+
const propsWithDefault = (0, import_ds_props_helpers.useMemoMergePropsWithDefault)(propsFromUser, import_react_desc_prop_types.defaultProps);
|
|
46
|
+
(0, import_ds_props_helpers.useValidateTypescriptPropTypes)(propsWithDefault, import_react_desc_prop_types.DSAutocompletePropTypes, import_DSAutocompleteDefinitions.DSAutocompleteName);
|
|
51
47
|
const { options } = propsWithDefault;
|
|
52
48
|
const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
|
|
53
49
|
const [focusOptionIdx, setCurrentOption] = (0, import_react.useState)("");
|
|
@@ -81,7 +77,7 @@ const useAutocomplete = (props) => {
|
|
|
81
77
|
const popoverManager = (0, import_usePopoverLogic.usePopoverLogic)(propsWithDefault, setCurrentOption);
|
|
82
78
|
const ctx = (0, import_react.useMemo)(
|
|
83
79
|
() => ({
|
|
84
|
-
props:
|
|
80
|
+
props: propsWithDefault,
|
|
85
81
|
referenceElement,
|
|
86
82
|
focusOptionIdx,
|
|
87
83
|
setCurrentOption,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/useAutocomplete.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;
|
|
4
|
+
"sourcesContent": ["import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport { cloneDeep } from 'lodash';\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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,8BAA6E;AAC7E,oBAA0B;AAC1B,mBAAkC;AAClC,iBAAoB;AACpB,uCAAmC;AAEnC,mCAAsD;AACtD,6BAAgC;AAChC,qBAAwB;AACxB,+BAAkC;AAc3B,MAAM,kBAAkB,CAAC,kBAA+D;AAI7F,QAAM,uBAAmB,sDAA4D,eAAe,yCAAY;AAChH,8DAA+B,kBAAkB,sDAAyB,mDAAkB;AAE5F,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAA6B,IAAI;AACjF,QAAM,CAAC,gBAAgB,gBAAgB,QAAI,uBAAiB,EAAE;AAE9D,QAAM,iBAAa,wBAAQ;AAK3B,QAAM,oBAAgB,sBAAQ,UAAM,yBAAU,OAAO,GAAG,CAAC,OAAO,CAAC;AAGjE,QAAM,wBAAoB,sBAAQ,MAAM;AACtC,UAAM,SAAwC,CAAC;AAC/C,QAAI,iBAA4D;AAEhE,kBAAc,QAAQ,CAAC,SAAS;AAC9B,UAAI,KAAK,SAAS,WAAW;AAE3B,yBAAiB;AAAA,UACf,MAAM,KAAK;AAAA,UACX,MAAM,KAAK;AAAA,UACX,OAAO,KAAK;AAAA,UACZ,SAAS,CAAC;AAAA,QACZ;AACA,eAAO,KAAK,cAAc;AAAA,MAC5B,WAAW,KAAK,SAAS,YAAY,gBAAgB;AAEnD,uBAAe,QAAQ,KAAK,IAAI;AAAA,MAClC,WAAW,KAAK,SAAS,UAAU;AAEjC,eAAO,KAAK,IAAI;AAAA,MAClB;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,aAAa,CAAC;AAElB,QAAM,4BAAwB,4CAAkB;AAAA,IAC9C;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AAED,QAAM,qBAAiB,sBAAQ,UAAM,gBAAI,CAAC,GAAG,CAAC,CAAC;AAC/C,QAAM,qBAAiB,wCAAgB,kBAAkB,gBAAgB;AAEzE,QAAM,UAAM;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,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useHandleFocusOnPopoverOpenLogic_exports = {};
|
|
30
|
+
__export(useHandleFocusOnPopoverOpenLogic_exports, {
|
|
31
|
+
useHandleFocusOnPopoverOpenLogic: () => useHandleFocusOnPopoverOpenLogic
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useHandleFocusOnPopoverOpenLogic_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_listHelper = require("../utils/listHelper.js");
|
|
37
|
+
const useHandleFocusOnPopoverOpenLogic = ({
|
|
38
|
+
options,
|
|
39
|
+
forceFocusFirstOptionOnType,
|
|
40
|
+
isShowingPopover,
|
|
41
|
+
setCurrentOption
|
|
42
|
+
}) => {
|
|
43
|
+
const firstOptionId = (0, import_listHelper.getFirstOption)(options);
|
|
44
|
+
const firstOptionIdRef = import_react.default.useRef(firstOptionId);
|
|
45
|
+
firstOptionIdRef.current = firstOptionId ?? "";
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
if (isShowingPopover) {
|
|
48
|
+
if (forceFocusFirstOptionOnType) setCurrentOption(firstOptionIdRef.current);
|
|
49
|
+
else setCurrentOption("");
|
|
50
|
+
}
|
|
51
|
+
}, [forceFocusFirstOptionOnType, isShowingPopover, setCurrentOption]);
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=useHandleFocusOnPopoverOpenLogic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useHandleFocusOnPopoverOpenLogic.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAiC;AAEjC,wBAA+B;AAExB,MAAM,mCAAmC,CAAC;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AAKJ,QAAM,oBAAgB,kCAAe,OAAO;AAK5C,QAAM,mBAAmB,aAAAA,QAAM,OAAO,aAAa;AACnD,mBAAiB,UAAU,iBAAiB;AAC5C,8BAAU,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
|
+
}
|
|
@@ -33,8 +33,9 @@ __export(usePopoverLogic_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(usePopoverLogic_exports);
|
|
34
34
|
var React = __toESM(require("react"));
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_useHandleFocusOnPopoverOpenLogic = require("./useHandleFocusOnPopoverOpenLogic.js");
|
|
36
37
|
const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
37
|
-
const { options, filter } = propsWithDefault;
|
|
38
|
+
const { options, filter, forceFocusFirstOptionOnType } = propsWithDefault;
|
|
38
39
|
const [forceClosePopover, setForceClosePopover] = (0, import_react.useState)(false);
|
|
39
40
|
const [userTypedSomething, setUserTypedSomething] = (0, import_react.useState)(false);
|
|
40
41
|
const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = (0, import_react.useState)(false);
|
|
@@ -46,39 +47,32 @@ const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
|
46
47
|
!userSelectedAndDidNotType && // user just selected an option --> hide popover
|
|
47
48
|
(userTypedSomething || // user typed something --> show popover
|
|
48
49
|
userIsNavigatingWithArrows);
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const { key } = e;
|
|
76
|
-
if (key === "Enter" && isShowingPopover) {
|
|
77
|
-
setUserJustSelectedAnOption(true);
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
[isShowingPopover]
|
|
81
|
-
);
|
|
50
|
+
const isShowingRef = import_react.default.useRef(isShowingPopover);
|
|
51
|
+
isShowingRef.current = isShowingPopover;
|
|
52
|
+
const trackUserTyping = import_react.default.useCallback((e) => {
|
|
53
|
+
const { key } = e;
|
|
54
|
+
if ([...e.key].length === 1 || key === "Backspace" || key === "Delete") {
|
|
55
|
+
setUserTypedSomething(true);
|
|
56
|
+
setForceClosePopover(false);
|
|
57
|
+
setUserJustSelectedAnOption(false);
|
|
58
|
+
} else {
|
|
59
|
+
setUserTypedSomething(false);
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
const trackUserNavigatingWithArrows = import_react.default.useCallback((e) => {
|
|
63
|
+
const { key } = e;
|
|
64
|
+
if (isShowingRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
|
|
65
|
+
setUserIsNavigatingWithArrows(true);
|
|
66
|
+
} else {
|
|
67
|
+
setUserIsNavigatingWithArrows(false);
|
|
68
|
+
}
|
|
69
|
+
}, []);
|
|
70
|
+
const trackUserSelectingAnOption = import_react.default.useCallback((e) => {
|
|
71
|
+
const { key } = e;
|
|
72
|
+
if (key === "Enter" && isShowingRef.current) {
|
|
73
|
+
setUserJustSelectedAnOption(true);
|
|
74
|
+
}
|
|
75
|
+
}, []);
|
|
82
76
|
const trackUserInteractingViaKeyboard = import_react.default.useCallback(
|
|
83
77
|
(e) => {
|
|
84
78
|
trackUserTyping(e);
|
|
@@ -87,21 +81,22 @@ const usePopoverLogic = (propsWithDefault, setCurrentOption) => {
|
|
|
87
81
|
},
|
|
88
82
|
[trackUserTyping, trackUserNavigatingWithArrows, trackUserSelectingAnOption]
|
|
89
83
|
);
|
|
84
|
+
const closePopover = import_react.default.useCallback(() => {
|
|
85
|
+
setForceClosePopover(true);
|
|
86
|
+
setCurrentOption("");
|
|
87
|
+
}, [setCurrentOption]);
|
|
90
88
|
(0, import_react.useEffect)(() => {
|
|
91
|
-
|
|
92
|
-
setForceClosePopover(true);
|
|
93
|
-
setCurrentOption("");
|
|
94
|
-
};
|
|
95
|
-
window.addEventListener("blur", closePopper);
|
|
89
|
+
window.addEventListener("blur", closePopover);
|
|
96
90
|
return () => {
|
|
97
|
-
window.removeEventListener("blur",
|
|
91
|
+
window.removeEventListener("blur", closePopover);
|
|
98
92
|
};
|
|
99
|
-
}, [
|
|
100
|
-
(0,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
}, [closePopover]);
|
|
94
|
+
(0, import_useHandleFocusOnPopoverOpenLogic.useHandleFocusOnPopoverOpenLogic)({
|
|
95
|
+
options,
|
|
96
|
+
forceFocusFirstOptionOnType,
|
|
97
|
+
isShowingPopover,
|
|
98
|
+
setCurrentOption
|
|
99
|
+
});
|
|
105
100
|
return import_react.default.useMemo(
|
|
106
101
|
() => ({
|
|
107
102
|
isShowingPopover,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/config/usePopoverLogic.ts", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2C;
|
|
4
|
+
"sourcesContent": ["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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2C;AAE3C,8CAAiD;AAe1C,MAAM,kBAAkB,CAC7B,kBACA,qBACG;AACH,QAAM,EAAE,SAAS,QAAQ,4BAA4B,IAAI;AAEzD,QAAM,CAAC,mBAAmB,oBAAoB,QAAI,uBAAkB,KAAK;AAEzE,QAAM,CAAC,oBAAoB,qBAAqB,QAAI,uBAAkB,KAAK;AAC3E,QAAM,CAAC,4BAA4B,6BAA6B,QAAI,uBAAkB,KAAK;AAC3F,QAAM,CAAC,0BAA0B,2BAA2B,QAAI,uBAAkB,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,eAAe,aAAAA,QAAM,OAAO,gBAAgB;AAClD,eAAa,UAAU;AAEvB,QAAM,kBAAgE,aAAAA,QAAM,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,CAAC,CAAC;AACL,QAAM,gCAA8E,aAAAA,QAAM,YAAY,CAAC,MAAM;AAC3G,UAAM,EAAE,IAAI,IAAI;AAChB,QAAI,aAAa,YAAY,QAAQ,aAAa,QAAQ,cAAc;AACtE,oCAA8B,IAAI;AAAA,IACpC,OAAO;AACL,oCAA8B,KAAK;AAAA,IACrC;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,6BAA2E,aAAAA,QAAM,YAAY,CAAC,MAAM;AACxG,UAAM,EAAE,IAAI,IAAI;AAChB,QAAI,QAAQ,WAAW,aAAa,SAAS;AAC3C,kCAA4B,IAAI;AAAA,IAClC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,QAAM,kCAAgF,aAAAA,QAAM;AAAA,IAC1F,CAAC,MAAM;AACL,sBAAgB,CAAC;AACjB,oCAA8B,CAAC;AAC/B,iCAA2B,CAAC;AAAA,IAC9B;AAAA,IACA,CAAC,iBAAiB,+BAA+B,0BAA0B;AAAA,EAC7E;AACA,QAAM,eAAe,aAAAA,QAAM,YAAY,MAAM;AAC3C,yBAAqB,IAAI;AACzB,qBAAiB,EAAE;AAAA,EACrB,GAAG,CAAC,gBAAgB,CAAC;AAIrB,8BAAU,MAAM;AACd,WAAO,iBAAiB,QAAQ,YAAY;AAC5C,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,YAAY;AAAA,IACjD;AAAA,EACF,GAAG,CAAC,YAAY,CAAC;AAEjB,gFAAiC;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -35,7 +35,6 @@ var React = __toESM(require("react"));
|
|
|
35
35
|
var import_react = require("react");
|
|
36
36
|
var import_AutocompleteCTX = __toESM(require("../../AutocompleteCTX.js"));
|
|
37
37
|
var import_listHelper = require("../../utils/listHelper.js");
|
|
38
|
-
const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
|
|
39
38
|
const useKeyboardNavigation = () => {
|
|
40
39
|
const {
|
|
41
40
|
props: { onSelect, options },
|
|
@@ -61,7 +60,7 @@ const useKeyboardNavigation = () => {
|
|
|
61
60
|
if (e.key === "ArrowDown") {
|
|
62
61
|
e.preventDefault();
|
|
63
62
|
if (isShowingPopover) {
|
|
64
|
-
const nextItemIndex = (0, import_listHelper.findInCircularList)(options, currentItemIndex, isOptionFocuseable);
|
|
63
|
+
const nextItemIndex = (0, import_listHelper.findInCircularList)(options, currentItemIndex, import_listHelper.isOptionFocuseable);
|
|
65
64
|
setCurrentOption(options[nextItemIndex].dsId);
|
|
66
65
|
scrollOptionIntoView(options[nextItemIndex].dsId);
|
|
67
66
|
}
|
|
@@ -69,7 +68,7 @@ const useKeyboardNavigation = () => {
|
|
|
69
68
|
if (e.key === "ArrowUp") {
|
|
70
69
|
e.preventDefault();
|
|
71
70
|
if (isShowingPopover) {
|
|
72
|
-
const nextItemIndex = (0, import_listHelper.findInCircularList)(options, currentItemIndex, isOptionFocuseable, -1);
|
|
71
|
+
const nextItemIndex = (0, import_listHelper.findInCircularList)(options, currentItemIndex, import_listHelper.isOptionFocuseable, -1);
|
|
73
72
|
setCurrentOption(options[nextItemIndex].dsId);
|
|
74
73
|
scrollOptionIntoView(options[nextItemIndex].dsId);
|
|
75
74
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/parts/container/useKeyboardNavigation.tsx", "../../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport 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;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,mBAAwC;AAExC,6BAAgC;AAChC,
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADKvB,mBAAwC;AAExC,6BAAgC;AAChC,wBAAuD;AAEhD,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,UAAU,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,QAAI,yBAAW,uBAAAA,OAAmB;AAElC,QAAM,mBAAmB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS,cAAc;AAC/E,QAAM,cAAc,QAAQ;AAAA,IAC1B,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS;AAAA,EACpD;AAEA,QAAM,qBAA+D;AAAA,IACnE,CAAC,MAAM;AAIL,sCAAgC,CAAC;AAEjC,UAAI,EAAE,QAAQ,SAAS,EAAE,QAAQ,SAAU,sBAAqB,IAAI;AAUpE,UAAI,EAAE,QAAQ,WAAW,oBAAoB,aAAa,UAAU,QAAW;AAC7E,UAAE,eAAe;AACjB,iBAAS,aAAa,OAAO,CAAC;AAAA,MAChC;AAKA,UAAI,EAAE,QAAQ,aAAa;AACzB,UAAE,eAAe;AACjB,YAAI,kBAAkB;AACpB,gBAAM,oBAAgB,sCAAmB,SAAS,kBAAkB,oCAAkB;AACtF,2BAAiB,QAAQ,aAAa,EAAE,IAAI;AAC5C,+BAAqB,QAAQ,aAAa,EAAE,IAAI;AAAA,QAClD;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,WAAW;AACvB,UAAE,eAAe;AACjB,YAAI,kBAAkB;AACpB,gBAAM,oBAAgB,sCAAmB,SAAS,kBAAkB,sCAAoB,EAAE;AAC1F,2BAAiB,QAAQ,aAAa,EAAE,IAAI;AAC5C,+BAAqB,QAAQ,aAAa,EAAE,IAAI;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
|
|
6
6
|
"names": ["AutocompleteContext"]
|
|
7
7
|
}
|
|
@@ -28,8 +28,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var react_desc_prop_types_exports = {};
|
|
30
30
|
__export(react_desc_prop_types_exports, {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
DSAutocompletePropTypes: () => DSAutocompletePropTypes,
|
|
32
|
+
DSAutocompletePropTypesSchema: () => DSAutocompletePropTypesSchema,
|
|
33
|
+
defaultProps: () => defaultProps
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(react_desc_prop_types_exports);
|
|
35
36
|
var React = __toESM(require("react"));
|
|
@@ -37,17 +38,26 @@ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
|
37
38
|
const defaultProps = {
|
|
38
39
|
zIndex: 10,
|
|
39
40
|
withoutPortal: false,
|
|
41
|
+
forceFocusFirstOptionOnType: false,
|
|
40
42
|
startPlacementPreference: "bottom-start",
|
|
41
43
|
placementOrderPreference: ["bottom-start", "bottom-end"]
|
|
42
44
|
};
|
|
43
|
-
const
|
|
45
|
+
const DSAutocompletePropTypes = {
|
|
44
46
|
...import_ds_props_helpers.globalAttributesPropTypes,
|
|
47
|
+
...import_ds_props_helpers.xstyledPropTypes,
|
|
45
48
|
options: import_ds_props_helpers.PropTypes.oneOfType([import_ds_props_helpers.PropTypes.array, import_ds_props_helpers.PropTypes.object]).isRequired.description("List of options").defaultValue([]),
|
|
46
49
|
filter: import_ds_props_helpers.PropTypes.string.isRequired.description("String value to filter the options").defaultValue(""),
|
|
47
50
|
onSelect: import_ds_props_helpers.PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue(""),
|
|
48
51
|
children: import_ds_props_helpers.PropTypes.node.description("React component to apply autocomplete functionality").defaultValue("").deprecated({ version: "3.x" }),
|
|
49
52
|
inputProps: import_ds_props_helpers.PropTypes.object.description("Props to pass to the input component").defaultValue({}),
|
|
50
53
|
onValueChange: import_ds_props_helpers.PropTypes.func.description("Function triggered when the value of the input changes").defaultValue(""),
|
|
51
|
-
renderInput: import_ds_props_helpers.PropTypes.func.description("Function to render the input").defaultValue("")
|
|
54
|
+
renderInput: import_ds_props_helpers.PropTypes.func.description("Function to render the input").defaultValue(""),
|
|
55
|
+
startPlacementPreference: import_ds_props_helpers.PropTypes.string.description("Ideal preference for context placement").defaultValue("bottom-start"),
|
|
56
|
+
placementOrderPreference: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.string).description("Placement preferences for the context menu in order of most preferred to least preferred").defaultValue("['bottom-start', 'bottom-end']"),
|
|
57
|
+
withoutPortal: import_ds_props_helpers.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)"),
|
|
58
|
+
forceFocusFirstOptionOnType: import_ds_props_helpers.PropTypes.bool.description(
|
|
59
|
+
"Whether to focus the first option when typing (NOT RECOMMENDED AND BREAKING A11Y STANDARDS + ALL USERS USABILITY)"
|
|
60
|
+
).defaultValue("false")
|
|
52
61
|
};
|
|
62
|
+
const DSAutocompletePropTypesSchema = DSAutocompletePropTypes;
|
|
53
63
|
//# sourceMappingURL=react-desc-prop-types.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/react-desc-prop-types.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* 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;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,
|
|
4
|
+
"sourcesContent": ["/* 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADIvB,8BAAuE;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,kCAAU,UAAU,CAAC,kCAAU,OAAO,kCAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,kCAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,kCAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,kCAAU,KACjB,YAAY,qDAAqD,EACjE,aAAa,EAAE,EACf,WAAW,EAAE,SAAS,MAAM,CAAC;AAAA,EAChC,YAAY,kCAAU,OAAO,YAAY,sCAAsC,EAAE,aAAa,CAAC,CAAC;AAAA,EAChG,eAAe,kCAAU,KAAK,YAAY,wDAAwD,EAAE,aAAa,EAAE;AAAA,EACnH,aAAa,kCAAU,KAAK,YAAY,8BAA8B,EAAE,aAAa,EAAE;AAAA,EACvF,0BAA0B,kCAAU,OACjC,YAAY,wCAAwC,EACpD,aAAa,cAAc;AAAA,EAC9B,0BAA0B,kCAAU,QAAQ,kCAAU,MAAM,EACzD,YAAY,0FAA0F,EACtG,aAAa,gCAAgC;AAAA,EAChD,eAAe,kCAAU,KACtB,YAAY,uFAAuF,EACnG,aAAa,2BAA2B;AAAA,EAC3C,6BAA6B,kCAAU,KACpC;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AACzB;AAEO,MAAM,gCAAgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -46,7 +46,8 @@ const testCompleteDefaults = {
|
|
|
46
46
|
startPlacementPreference: "bottom",
|
|
47
47
|
placementOrderPreference: ["bottom", "top"],
|
|
48
48
|
withoutPortal: false,
|
|
49
|
-
zIndex: 1e3
|
|
49
|
+
zIndex: 1e3,
|
|
50
|
+
forceFocusFirstOptionOnType: false
|
|
50
51
|
};
|
|
51
52
|
const testInternalProps = {
|
|
52
53
|
...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,YAAuB;
|
|
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,YAAuB;ACkDX;AAjDZ,eAA+B;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,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,oBAAoB;AAAA,EACxB,GAAG;AAAA,EACH,GAAG;AACL;AAEA,MAAM,uBAA6D;AAAA,EACjE,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,UAAU,KAAK;AAAA,EAC1C,eAAe;AAAA,EACf,QAAQ;AAAA,EACR,6BAA6B;AAC/B;AACA,MAAM,oBAA6C;AAAA,EACjD,GAAG;AAAA,EACH,GAAG;AACL;AACA,MAAM,4BAA4B;AAAA,EAChC,GAAG;AAAA,EACH,GAAG;AACL;AAGA,MAAM,yBAA+C;AAAA,EACnD,UAAU,4CAAC,SAAI;AAAA,EACf,SAAS,CAAC;AAAA,EACV,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,QAAQ;AAAA,EACR,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,UAAU,KAAK;AAAA,EAC1C,eAAe;AAAA,EACf,QAAQ;AACV;AAGA,MAAM,+BAA+B;AAAA,EACnC,UAAU,4CAAC,SAAI;AAAA,EACf,SAAS,CAAC;AAAA,EACV,UAAU,MAAM;AAAA,EAAC;AAAA,EACjB,QAAQ;AAAA,EACR,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,UAAU,KAAK;AAAA,EAC1C,eAAe;AAAA,EACf,QAAQ;AACV;AAEA,MAAM,wBAAwB,MAC5B,4EAEE;AAAA,8CAAC,2BAAgB,GAAG,wBAAwB;AAAA,EAC5C,4CAAC,2BAAgB,GAAG,8BAA8B;AAAA,EAElD;AAAA,IAAC;AAAA;AAAA,MACC,SAAS,CAAC;AAAA,MACV,UAAU,MAAM;AAAA,MAAC;AAAA,MACjB,QAAO;AAAA,MACP,0BAAyB;AAAA,MACzB,0BAA0B,CAAC,UAAU,KAAK;AAAA,MAC1C,eAAe;AAAA,MACf,QAAQ;AAAA,MAER,sDAAC,WAAM;AAAA;AAAA,EACT;AAAA,GACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -32,6 +32,7 @@ __export(listHelper_exports, {
|
|
|
32
32
|
getFirstOption: () => getFirstOption,
|
|
33
33
|
getOptions: () => getOptions,
|
|
34
34
|
getSelectableOptions: () => getSelectableOptions,
|
|
35
|
+
isOptionFocuseable: () => isOptionFocuseable,
|
|
35
36
|
isSelectedValueEmpty: () => isSelectedValueEmpty,
|
|
36
37
|
isSelectedValueMultiple: () => isSelectedValueMultiple
|
|
37
38
|
});
|
|
@@ -54,4 +55,5 @@ const getFirstOption = (options) => {
|
|
|
54
55
|
}
|
|
55
56
|
return "";
|
|
56
57
|
};
|
|
58
|
+
const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
|
|
57
59
|
//# sourceMappingURL=listHelper.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/listHelper.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,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 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", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADEhB,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
|
}
|
package/dist/esm/Autocomplete.js
CHANGED
|
@@ -4,7 +4,7 @@ import { describe } from "@elliemae/ds-props-helpers";
|
|
|
4
4
|
import { useAutocomplete } from "./config/useAutocomplete.js";
|
|
5
5
|
import { Container } from "./parts/container/index.js";
|
|
6
6
|
import { AutocompleteContext } from "./AutocompleteCTX.js";
|
|
7
|
-
import {
|
|
7
|
+
import { DSAutocompletePropTypesSchema } from "./react-desc-prop-types.js";
|
|
8
8
|
import { DSAutocompleteName } from "./DSAutocompleteDefinitions.js";
|
|
9
9
|
const DSAutocomplete = (props) => {
|
|
10
10
|
const ctx = useAutocomplete(props);
|
|
@@ -12,7 +12,7 @@ const DSAutocomplete = (props) => {
|
|
|
12
12
|
};
|
|
13
13
|
DSAutocomplete.displayName = DSAutocompleteName;
|
|
14
14
|
const DSAutocompleteWithSchema = describe(DSAutocomplete);
|
|
15
|
-
DSAutocompleteWithSchema.propTypes =
|
|
15
|
+
DSAutocompleteWithSchema.propTypes = DSAutocompletePropTypesSchema;
|
|
16
16
|
export {
|
|
17
17
|
DSAutocomplete,
|
|
18
18
|
DSAutocompleteWithSchema
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/Autocomplete.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import
|
|
5
|
-
"mappings": "AAAA,YAAY,WAAW;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { describe } from '@elliemae/ds-props-helpers';\nimport { useAutocomplete } from './config/useAutocomplete.js';\nimport { Container } from './parts/container/index.js';\nimport { AutocompleteContext } from './AutocompleteCTX.js';\nimport type { DSAutocompleteT } from './react-desc-prop-types.js';\nimport { DSAutocompletePropTypesSchema } from './react-desc-prop-types.js';\nimport { DSAutocompleteName } from './DSAutocompleteDefinitions.js';\n\nconst DSAutocomplete: React.ComponentType<DSAutocompleteT.Props> = (props) => {\n const ctx = useAutocomplete(props);\n return (\n <AutocompleteContext.Provider value={ctx}>\n <Container />\n </AutocompleteContext.Provider>\n );\n};\n\nDSAutocomplete.displayName = DSAutocompleteName;\nconst DSAutocompleteWithSchema = describe(DSAutocomplete);\nDSAutocompleteWithSchema.propTypes = DSAutocompletePropTypesSchema;\n\nexport { DSAutocomplete, DSAutocompleteWithSchema };\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,WAAW;ACajB;AAZN,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAEpC,SAAS,qCAAqC;AAC9C,SAAS,0BAA0B;AAEnC,MAAM,iBAA6D,CAAC,UAAU;AAC5E,QAAM,MAAM,gBAAgB,KAAK;AACjC,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,KACnC,8BAAC,aAAU,GACb;AAEJ;AAEA,eAAe,cAAc;AAC7B,MAAM,2BAA2B,SAAS,cAAc;AACxD,yBAAyB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|