@elliemae/ds-form-layout-autocomplete 3.16.0-next.2 → 3.16.0-next.21
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 +11 -7
- package/dist/cjs/Autocomplete.js.map +2 -2
- package/dist/cjs/AutocompleteCTX.js +6 -22
- package/dist/cjs/AutocompleteCTX.js.map +2 -2
- package/dist/cjs/AutocompleteDataTestids.js +4 -0
- package/dist/cjs/AutocompleteDataTestids.js.map +1 -1
- package/dist/cjs/DSAutocompleteDefinitions.js +4 -0
- package/dist/cjs/DSAutocompleteDefinitions.js.map +1 -1
- package/dist/cjs/config/useAutocomplete.js +34 -47
- package/dist/cjs/config/useAutocomplete.js.map +3 -3
- package/dist/cjs/config/usePopoverLogic.js +113 -0
- package/dist/cjs/config/usePopoverLogic.js.map +7 -0
- package/dist/cjs/{sharedTypes.js → config/useRefs.js} +20 -3
- package/dist/cjs/config/useRefs.js.map +7 -0
- package/dist/cjs/config/useVirtualization.js +66 -0
- package/dist/cjs/config/useVirtualization.js.map +7 -0
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/parts/A11yFocusedOption.js +9 -5
- package/dist/cjs/parts/A11yFocusedOption.js.map +2 -2
- package/dist/cjs/parts/container/Container.js +29 -25
- package/dist/cjs/parts/container/Container.js.map +2 -2
- package/dist/cjs/parts/container/index.js +5 -1
- package/dist/cjs/parts/container/index.js.map +2 -2
- package/dist/cjs/parts/container/styled.js +4 -0
- package/dist/cjs/parts/container/styled.js.map +1 -1
- package/dist/cjs/parts/container/useKeyboardNavigation.js +21 -20
- package/dist/cjs/parts/container/useKeyboardNavigation.js.map +2 -2
- package/dist/cjs/parts/menu-list/MenuList.js +23 -23
- package/dist/cjs/parts/menu-list/MenuList.js.map +2 -2
- package/dist/cjs/parts/menu-list/index.js +5 -1
- package/dist/cjs/parts/menu-list/index.js.map +2 -2
- package/dist/cjs/parts/menu-list/styled.js +4 -0
- package/dist/cjs/parts/menu-list/styled.js.map +1 -1
- package/dist/cjs/parts/menu-list/useItemRenderer.js +11 -5
- package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/cjs/react-desc-prop-types.js +16 -5
- package/dist/cjs/react-desc-prop-types.js.map +2 -2
- package/dist/cjs/tests/utils.js +4 -0
- package/dist/cjs/tests/utils.js.map +1 -1
- package/dist/cjs/utils/listHelper.js +4 -0
- package/dist/cjs/utils/listHelper.js.map +2 -2
- package/dist/esm/Autocomplete.js +6 -6
- package/dist/esm/Autocomplete.js.map +1 -1
- package/dist/esm/AutocompleteCTX.js +3 -23
- package/dist/esm/AutocompleteCTX.js.map +2 -2
- package/dist/esm/config/useAutocomplete.js +27 -44
- package/dist/esm/config/useAutocomplete.js.map +3 -3
- package/dist/esm/config/usePopoverLogic.js +83 -0
- package/dist/esm/config/usePopoverLogic.js.map +7 -0
- package/dist/esm/config/useRefs.js +11 -0
- package/dist/esm/config/useRefs.js.map +7 -0
- package/dist/esm/config/useVirtualization.js +36 -0
- package/dist/esm/config/useVirtualization.js.map +7 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/package.json +7 -0
- package/dist/esm/parts/A11yFocusedOption.js +5 -5
- package/dist/esm/parts/A11yFocusedOption.js.map +2 -2
- package/dist/esm/parts/container/Container.js +26 -26
- package/dist/esm/parts/container/Container.js.map +2 -2
- package/dist/esm/parts/container/index.js +1 -1
- package/dist/esm/parts/container/index.js.map +1 -1
- package/dist/esm/parts/container/useKeyboardNavigation.js +17 -20
- package/dist/esm/parts/container/useKeyboardNavigation.js.map +2 -2
- package/dist/esm/parts/menu-list/MenuList.js +19 -23
- package/dist/esm/parts/menu-list/MenuList.js.map +2 -2
- package/dist/esm/parts/menu-list/index.js +1 -1
- package/dist/esm/parts/menu-list/index.js.map +1 -1
- package/dist/esm/parts/menu-list/useItemRenderer.js +7 -5
- package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
- package/dist/esm/react-desc-prop-types.js +8 -1
- package/dist/esm/react-desc-prop-types.js.map +2 -2
- package/dist/esm/utils/listHelper.js.map +2 -2
- package/package.json +12 -12
- package/dist/cjs/sharedTypes.js.map +0 -7
- package/dist/esm/sharedTypes.js +0 -2
- package/dist/esm/sharedTypes.js.map +0 -7
- package/dist/types/Autocomplete.d.ts +0 -5
- package/dist/types/AutocompleteCTX.d.ts +0 -7
- package/dist/types/AutocompleteDataTestids.d.ts +0 -5
- package/dist/types/DSAutocompleteDefinitions.d.ts +0 -1
- package/dist/types/config/useAutocomplete.d.ts +0 -3
- package/dist/types/index.d.ts +0 -1
- package/dist/types/parts/A11yFocusedOption.d.ts +0 -5
- package/dist/types/parts/container/Container.d.ts +0 -1
- package/dist/types/parts/container/index.d.ts +0 -1
- package/dist/types/parts/container/styled.d.ts +0 -2
- package/dist/types/parts/container/useKeyboardNavigation.d.ts +0 -4
- package/dist/types/parts/menu-list/MenuList.d.ts +0 -1
- package/dist/types/parts/menu-list/index.d.ts +0 -1
- package/dist/types/parts/menu-list/styled.d.ts +0 -7
- package/dist/types/parts/menu-list/useItemRenderer.d.ts +0 -1
- package/dist/types/react-desc-prop-types.d.ts +0 -44
- package/dist/types/sharedTypes.d.ts +0 -18
- package/dist/types/tests/general.test.d.ts +0 -1
- package/dist/types/tests/utils.d.ts +0 -5
- package/dist/types/utils/listHelper.d.ts +0 -7
package/dist/cjs/Autocomplete.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -30,18 +34,18 @@ __export(Autocomplete_exports, {
|
|
|
30
34
|
module.exports = __toCommonJS(Autocomplete_exports);
|
|
31
35
|
var React = __toESM(require("react"));
|
|
32
36
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var
|
|
34
|
-
var import_useAutocomplete = require("./config/useAutocomplete");
|
|
35
|
-
var import_container = require("./parts/container");
|
|
36
|
-
var import_AutocompleteCTX = require("./AutocompleteCTX");
|
|
37
|
-
var import_react_desc_prop_types = require("./react-desc-prop-types");
|
|
38
|
-
var import_DSAutocompleteDefinitions = require("./DSAutocompleteDefinitions");
|
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
38
|
+
var import_useAutocomplete = require("./config/useAutocomplete.js");
|
|
39
|
+
var import_container = require("./parts/container/index.js");
|
|
40
|
+
var import_AutocompleteCTX = require("./AutocompleteCTX.js");
|
|
41
|
+
var import_react_desc_prop_types = require("./react-desc-prop-types.js");
|
|
42
|
+
var import_DSAutocompleteDefinitions = require("./DSAutocompleteDefinitions.js");
|
|
39
43
|
const DSAutocomplete = (props) => {
|
|
40
44
|
const ctx = (0, import_useAutocomplete.useAutocomplete)(props);
|
|
41
45
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_AutocompleteCTX.AutocompleteContext.Provider, { value: ctx, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_container.Container, {}) });
|
|
42
46
|
};
|
|
43
47
|
DSAutocomplete.propTypes = import_react_desc_prop_types.propTypes;
|
|
44
48
|
DSAutocomplete.displayName = import_DSAutocompleteDefinitions.DSAutocompleteName;
|
|
45
|
-
const DSAutocompleteWithSchema = (0,
|
|
49
|
+
const DSAutocompleteWithSchema = (0, import_ds_props_helpers.describe)(DSAutocomplete);
|
|
46
50
|
DSAutocompleteWithSchema.propTypes = import_react_desc_prop_types.propTypes;
|
|
47
51
|
//# 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 type { WeakValidationMap } from 'react';\nimport React from 'react';\nimport { describe } from '@elliemae/ds-
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { WeakValidationMap } from 'react';\nimport 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 { propTypes } 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};\nDSAutocomplete.propTypes = propTypes as WeakValidationMap<unknown>;\nDSAutocomplete.displayName = DSAutocompleteName;\nconst DSAutocompleteWithSchema = describe(DSAutocomplete);\nDSAutocompleteWithSchema.propTypes = propTypes as WeakValidationMap<unknown>;\n\nexport { DSAutocomplete, DSAutocompleteWithSchema };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADcjB;AAZN,8BAAyB;AACzB,6BAAgC;AAChC,uBAA0B;AAC1B,6BAAoC;AAEpC,mCAA0B;AAC1B,uCAAmC;AAEnC,MAAM,iBAA6D,CAAC,UAAU;AAC5E,QAAM,UAAM,wCAAgB,KAAK;AACjC,SACE,4CAAC,2CAAoB,UAApB,EAA6B,OAAO,KACnC,sDAAC,8BAAU,GACb;AAEJ;AACA,eAAe,YAAY;AAC3B,eAAe,cAAc;AAC7B,MAAM,+BAA2B,kCAAS,cAAc;AACxD,yBAAyB,YAAY;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -25,32 +29,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
25
29
|
var AutocompleteCTX_exports = {};
|
|
26
30
|
__export(AutocompleteCTX_exports, {
|
|
27
31
|
AutocompleteContext: () => AutocompleteContext,
|
|
28
|
-
default: () => AutocompleteCTX_default
|
|
29
|
-
defaultProps: () => defaultProps
|
|
32
|
+
default: () => AutocompleteCTX_default
|
|
30
33
|
});
|
|
31
34
|
module.exports = __toCommonJS(AutocompleteCTX_exports);
|
|
32
35
|
var React = __toESM(require("react"));
|
|
33
36
|
var import_react = require("react");
|
|
34
|
-
const
|
|
35
|
-
};
|
|
36
|
-
const defaultProps = {
|
|
37
|
-
zIndex: 10,
|
|
38
|
-
withoutPortal: false,
|
|
39
|
-
startPlacementPreference: "bottom-start",
|
|
40
|
-
placementOrderPreference: ["bottom-start", "bottom-end"]
|
|
41
|
-
};
|
|
42
|
-
const defaultContext = {
|
|
43
|
-
props: defaultProps,
|
|
44
|
-
showPopover: false,
|
|
45
|
-
setShowPopover: noop,
|
|
46
|
-
scrollOptionIntoView: noop,
|
|
47
|
-
referenceElement: null,
|
|
48
|
-
setReferenceElement: noop,
|
|
49
|
-
inputRef: (0, import_react.createRef)(),
|
|
50
|
-
listRef: (0, import_react.createRef)(),
|
|
51
|
-
focusOptionIdx: "",
|
|
52
|
-
setCurrentOption: noop
|
|
53
|
-
};
|
|
37
|
+
const defaultContext = {};
|
|
54
38
|
const AutocompleteContext = (0, import_react.createContext)(defaultContext);
|
|
55
39
|
var AutocompleteCTX_default = AutocompleteContext;
|
|
56
40
|
//# sourceMappingURL=AutocompleteCTX.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AutocompleteCTX.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { createContext
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { createContext } from 'react';\nimport type { AutocompleteContextT } from './config/useAutocomplete.js';\n\nconst defaultContext = {} as AutocompleteContextT;\n/** Context for cross component communication */\nexport const AutocompleteContext = createContext<AutocompleteContextT>(defaultContext);\n\nexport default AutocompleteContext;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAG9B,MAAM,iBAAiB,CAAC;AAEjB,MAAM,0BAAsB,4BAAoC,cAAc;AAErF,IAAO,0BAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AutocompleteDataTestids.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export const AutocompleteDataTestid = {\n LIST: 'autocomplete-menu-list',\n OPTION: 'autocomplete-option',\n CONTAINER: 'autocomplete-container',\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,yBAAyB;AAAA,EACpC,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,WAAW;AACb;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSAutocompleteDefinitions.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
4
|
"sourcesContent": ["export const DSAutocompleteName = 'DSAutocomplete';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,qBAAqB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
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.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -28,72 +32,55 @@ __export(useAutocomplete_exports, {
|
|
|
28
32
|
});
|
|
29
33
|
module.exports = __toCommonJS(useAutocomplete_exports);
|
|
30
34
|
var React = __toESM(require("react"));
|
|
31
|
-
var import_react = require("react");
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var import_react_desc_prop_types = require("../react-desc-prop-types");
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_uid = require("uid");
|
|
37
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
38
|
+
var import_react_desc_prop_types = require("../react-desc-prop-types.js");
|
|
39
|
+
var import_listHelper = require("../utils/listHelper.js");
|
|
40
|
+
var import_DSAutocompleteDefinitions = require("../DSAutocompleteDefinitions.js");
|
|
41
|
+
var import_useRefs = require("./useRefs.js");
|
|
42
|
+
var import_useVirtualization = require("./useVirtualization.js");
|
|
43
|
+
var import_usePopoverLogic = require("./usePopoverLogic.js");
|
|
38
44
|
const useAutocomplete = (props) => {
|
|
39
45
|
const defaultPropsWithInnerRef = {
|
|
40
|
-
...
|
|
46
|
+
...import_react_desc_prop_types.defaultProps,
|
|
41
47
|
innerRef: (0, import_react.useRef)(null)
|
|
42
48
|
};
|
|
43
|
-
const propsWithDefault = (0,
|
|
44
|
-
(0,
|
|
45
|
-
const
|
|
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);
|
|
51
|
+
const { options } = propsWithDefault;
|
|
46
52
|
const [referenceElement, setReferenceElement] = (0, import_react.useState)(null);
|
|
47
53
|
const [focusOptionIdx, setCurrentOption] = (0, import_react.useState)("");
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
size: options.length,
|
|
53
|
-
parentRef: listRef,
|
|
54
|
-
overscan: 15,
|
|
55
|
-
paddingStart: 0
|
|
54
|
+
const references = (0, import_useRefs.useRefs)();
|
|
55
|
+
const virtualizationManager = (0, import_useVirtualization.useVirtualization)({
|
|
56
|
+
references,
|
|
57
|
+
propsWithDefault
|
|
56
58
|
});
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
options.findIndex((opt) => opt.dsId === dsId),
|
|
61
|
-
opts
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
[options, virtualListHelpers]
|
|
65
|
-
);
|
|
66
|
-
(0, import_react.useEffect)(() => {
|
|
67
|
-
if (filter.length === 0 || options.length === 0) {
|
|
68
|
-
setShowPopover(false);
|
|
69
|
-
}
|
|
70
|
-
}, [filter, options.length, setShowPopover]);
|
|
71
|
-
(0, import_react.useEffect)(() => {
|
|
59
|
+
const autoCompleteId = (0, import_uid.uid)(4);
|
|
60
|
+
const popoverManager = (0, import_usePopoverLogic.usePopoverLogic)(propsWithDefault);
|
|
61
|
+
import_react.default.useEffect(() => {
|
|
72
62
|
setCurrentOption((0, import_listHelper.getFirstOption)(options));
|
|
73
|
-
}, [options
|
|
63
|
+
}, [options]);
|
|
74
64
|
const ctx = (0, import_react.useMemo)(
|
|
75
65
|
() => ({
|
|
76
66
|
props: { ...propsWithDefault },
|
|
77
|
-
virtualListHelpers,
|
|
78
|
-
showPopover,
|
|
79
67
|
referenceElement,
|
|
80
|
-
inputRef,
|
|
81
|
-
listRef,
|
|
82
68
|
focusOptionIdx,
|
|
83
69
|
setCurrentOption,
|
|
84
|
-
scrollOptionIntoView,
|
|
85
70
|
setReferenceElement,
|
|
86
|
-
|
|
71
|
+
autoCompleteId,
|
|
72
|
+
...references,
|
|
73
|
+
...popoverManager,
|
|
74
|
+
...virtualizationManager
|
|
87
75
|
}),
|
|
88
76
|
[
|
|
89
|
-
scrollOptionIntoView,
|
|
90
77
|
propsWithDefault,
|
|
91
|
-
|
|
92
|
-
focusOptionIdx,
|
|
93
|
-
showPopover,
|
|
78
|
+
autoCompleteId,
|
|
94
79
|
referenceElement,
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
focusOptionIdx,
|
|
81
|
+
popoverManager,
|
|
82
|
+
references,
|
|
83
|
+
virtualizationManager
|
|
97
84
|
]
|
|
98
85
|
);
|
|
99
86
|
return ctx;
|
|
@@ -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": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState,
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport React, { useMemo, useState, useRef } from 'react';\nimport { uid } from 'uid';\n\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport { propTypes, defaultProps } from '../react-desc-prop-types.js';\nimport { getFirstOption } from '../utils/listHelper.js';\nimport { DSAutocompleteName } from '../DSAutocompleteDefinitions.js';\nimport { useRefs } from './useRefs.js';\nimport { useVirtualization } from './useVirtualization.js';\nimport { usePopoverLogic } from './usePopoverLogic.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 setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n };\n\nexport const useAutocomplete = (props: DSAutocompleteT.Props): AutocompleteContextT => {\n const defaultPropsWithInnerRef = {\n ...defaultProps,\n innerRef: useRef(null),\n };\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);\n useValidateTypescriptPropTypes(propsWithDefault, propTypes, 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 const virtualizationManager = useVirtualization({\n references,\n propsWithDefault,\n });\n\n const autoCompleteId = uid(4);\n const popoverManager = usePopoverLogic(propsWithDefault);\n\n React.useEffect(() => {\n setCurrentOption(getFirstOption(options));\n }, [options]);\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefault },\n referenceElement,\n focusOptionIdx,\n setCurrentOption,\n setReferenceElement,\n autoCompleteId,\n ...references,\n ...popoverManager,\n ...virtualizationManager,\n }),\n [\n propsWithDefault,\n autoCompleteId,\n referenceElement,\n focusOptionIdx,\n popoverManager,\n references,\n virtualizationManager,\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;ADIvB,mBAAiD;AACjD,iBAAoB;AAEpB,8BAA6E;AAE7E,mCAAwC;AACxC,wBAA+B;AAC/B,uCAAmC;AACnC,qBAAwB;AACxB,+BAAkC;AAClC,6BAAgC;AAazB,MAAM,kBAAkB,CAAC,UAAuD;AACrF,QAAM,2BAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,cAAU,qBAAO,IAAI;AAAA,EACvB;AACA,QAAM,uBAAmB,sDAA6B,OAAO,wBAAwB;AACrF,8DAA+B,kBAAkB,wCAAW,mDAAkB;AAE9E,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAC,kBAAkB,mBAAmB,QAAI,uBAA6B,IAAI;AACjF,QAAM,CAAC,gBAAgB,gBAAgB,QAAI,uBAAiB,EAAE;AAE9D,QAAM,iBAAa,wBAAQ;AAE3B,QAAM,4BAAwB,4CAAkB;AAAA,IAC9C;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,qBAAiB,gBAAI,CAAC;AAC5B,QAAM,qBAAiB,wCAAgB,gBAAgB;AAEvD,eAAAA,QAAM,UAAU,MAAM;AACpB,yBAAiB,kCAAe,OAAO,CAAC;AAAA,EAC1C,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,UAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO,EAAE,GAAG,iBAAiB;AAAA,MAC7B;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,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
|
|
6
|
+
"names": ["React"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
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 usePopoverLogic_exports = {};
|
|
30
|
+
__export(usePopoverLogic_exports, {
|
|
31
|
+
usePopoverLogic: () => usePopoverLogic
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(usePopoverLogic_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const usePopoverLogic = (propsWithDefault) => {
|
|
37
|
+
const { options, filter } = propsWithDefault;
|
|
38
|
+
const [forceClosePopover, setForceClosePopover] = (0, import_react.useState)(false);
|
|
39
|
+
const [userTypedSomething, setUserTypedSomething] = (0, import_react.useState)(false);
|
|
40
|
+
const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = (0, import_react.useState)(false);
|
|
41
|
+
const [userJustSelectedAnOption, setUserJustSelectedAnOption] = (0, import_react.useState)(false);
|
|
42
|
+
const userSelectedAndDidNotType = userJustSelectedAnOption && !userTypedSomething;
|
|
43
|
+
const popoverHasAnythingToShow = options.length > 0 && filter.length > 0;
|
|
44
|
+
const isShowingPopover = !forceClosePopover && // user pressed escape (or other interaction that forces close) --> hide popover
|
|
45
|
+
popoverHasAnythingToShow && // nothing to show --> hide popover
|
|
46
|
+
!userSelectedAndDidNotType && // user just selected an option --> hide popover
|
|
47
|
+
(userTypedSomething || // user typed something --> show popover
|
|
48
|
+
userIsNavigatingWithArrows);
|
|
49
|
+
const trackUserTyping = import_react.default.useCallback(
|
|
50
|
+
(e) => {
|
|
51
|
+
const { key } = e;
|
|
52
|
+
if ([...e.key].length === 1 || key === "Backspace" || key === "Delete") {
|
|
53
|
+
setUserTypedSomething(true);
|
|
54
|
+
setForceClosePopover(false);
|
|
55
|
+
setUserJustSelectedAnOption(false);
|
|
56
|
+
} else {
|
|
57
|
+
setUserTypedSomething(false);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[setUserTypedSomething]
|
|
61
|
+
);
|
|
62
|
+
const trackUserNavigatingWithArrows = import_react.default.useCallback(
|
|
63
|
+
(e) => {
|
|
64
|
+
const { key } = e;
|
|
65
|
+
if (isShowingPopover && (key === "ArrowUp" || key === "ArrowDown")) {
|
|
66
|
+
setUserIsNavigatingWithArrows(true);
|
|
67
|
+
} else {
|
|
68
|
+
setUserIsNavigatingWithArrows(false);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
[isShowingPopover]
|
|
72
|
+
);
|
|
73
|
+
const trackUserSelectingAnOption = import_react.default.useCallback(
|
|
74
|
+
(e) => {
|
|
75
|
+
const { key } = e;
|
|
76
|
+
if (key === "Enter" && isShowingPopover) {
|
|
77
|
+
setUserJustSelectedAnOption(true);
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[isShowingPopover]
|
|
81
|
+
);
|
|
82
|
+
const trackUserInteractingViaKeyboard = import_react.default.useCallback(
|
|
83
|
+
(e) => {
|
|
84
|
+
trackUserTyping(e);
|
|
85
|
+
trackUserNavigatingWithArrows(e);
|
|
86
|
+
trackUserSelectingAnOption(e);
|
|
87
|
+
},
|
|
88
|
+
[trackUserTyping, trackUserNavigatingWithArrows, trackUserSelectingAnOption]
|
|
89
|
+
);
|
|
90
|
+
(0, import_react.useEffect)(() => {
|
|
91
|
+
const closePopper = () => {
|
|
92
|
+
setForceClosePopover(true);
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("blur", closePopper);
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener("blur", closePopper);
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
return import_react.default.useMemo(
|
|
100
|
+
() => ({
|
|
101
|
+
isShowingPopover,
|
|
102
|
+
forceClosePopover,
|
|
103
|
+
setForceClosePopover,
|
|
104
|
+
userTypedSomething,
|
|
105
|
+
setUserTypedSomething,
|
|
106
|
+
setUserJustSelectedAnOption,
|
|
107
|
+
setUserIsNavigatingWithArrows,
|
|
108
|
+
trackUserInteractingViaKeyboard
|
|
109
|
+
}),
|
|
110
|
+
[isShowingPopover, forceClosePopover, userTypedSomething, trackUserInteractingViaKeyboard]
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=usePopoverLogic.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 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 = (propsWithDefault: DSAutocompleteT.InternalProps) => {\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(\n (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 [setUserTypedSomething],\n );\n const trackUserNavigatingWithArrows: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback(\n (e) => {\n const { key } = e;\n if (isShowingPopover && (key === 'ArrowUp' || key === 'ArrowDown')) {\n setUserIsNavigatingWithArrows(true);\n } else {\n setUserIsNavigatingWithArrows(false);\n }\n },\n [isShowingPopover],\n );\n\n const trackUserSelectingAnOption: React.KeyboardEventHandler<HTMLInputElement> = React.useCallback(\n (e) => {\n const { key } = e;\n if (key === 'Enter' && isShowingPopover) {\n setUserJustSelectedAnOption(true);\n }\n },\n [isShowingPopover],\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\n // when the webpage is blurred, we want to close the popover\n // should be fixing iframes interactions?\n useEffect(() => {\n const closePopper = () => {\n setForceClosePopover(true);\n };\n window.addEventListener('blur', closePopper);\n\n return () => {\n window.removeEventListener('blur', closePopper);\n };\n }, []);\n\n return React.useMemo(\n () => ({\n isShowingPopover,\n forceClosePopover,\n setForceClosePopover,\n userTypedSomething,\n setUserTypedSomething,\n setUserJustSelectedAnOption,\n setUserIsNavigatingWithArrows,\n trackUserInteractingViaKeyboard,\n }),\n [isShowingPopover, forceClosePopover, userTypedSomething, trackUserInteractingViaKeyboard],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA2C;AAgBpC,MAAM,kBAAkB,CAAC,qBAAoD;AAClF,QAAM,EAAE,SAAS,OAAO,IAAI;AAE5B,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;AAEJ,QAAM,kBAAgE,aAAAA,QAAM;AAAA,IAC1E,CAAC,MAAM;AACL,YAAM,EAAE,IAAI,IAAI;AAEhB,UAAI,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,KAAK,QAAQ,eAAe,QAAQ,UAAU;AACtE,8BAAsB,IAAI;AAC1B,6BAAqB,KAAK;AAC1B,oCAA4B,KAAK;AAAA,MACnC,OAAO;AACL,8BAAsB,KAAK;AAAA,MAC7B;AAAA,IACF;AAAA,IACA,CAAC,qBAAqB;AAAA,EACxB;AACA,QAAM,gCAA8E,aAAAA,QAAM;AAAA,IACxF,CAAC,MAAM;AACL,YAAM,EAAE,IAAI,IAAI;AAChB,UAAI,qBAAqB,QAAQ,aAAa,QAAQ,cAAc;AAClE,sCAA8B,IAAI;AAAA,MACpC,OAAO;AACL,sCAA8B,KAAK;AAAA,MACrC;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB;AAAA,EACnB;AAEA,QAAM,6BAA2E,aAAAA,QAAM;AAAA,IACrF,CAAC,MAAM;AACL,YAAM,EAAE,IAAI,IAAI;AAChB,UAAI,QAAQ,WAAW,kBAAkB;AACvC,oCAA4B,IAAI;AAAA,MAClC;AAAA,IACF;AAAA,IACA,CAAC,gBAAgB;AAAA,EACnB;AAEA,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;AAIA,8BAAU,MAAM;AACd,UAAM,cAAc,MAAM;AACxB,2BAAqB,IAAI;AAAA,IAC3B;AACA,WAAO,iBAAiB,QAAQ,WAAW;AAE3C,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,WAAW;AAAA,IAChD;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,kBAAkB,mBAAmB,oBAAoB,+BAA+B;AAAA,EAC3F;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -5,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
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
|
+
};
|
|
8
12
|
var __copyProps = (to, from, except, desc) => {
|
|
9
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
14
|
for (let key of __getOwnPropNames(from))
|
|
@@ -14,11 +18,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
18
|
return to;
|
|
15
19
|
};
|
|
16
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.
|
|
17
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
26
|
mod
|
|
19
27
|
));
|
|
20
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
-
var
|
|
22
|
-
|
|
29
|
+
var useRefs_exports = {};
|
|
30
|
+
__export(useRefs_exports, {
|
|
31
|
+
useRefs: () => useRefs
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useRefs_exports);
|
|
23
34
|
var React = __toESM(require("react"));
|
|
24
|
-
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const useRefs = () => {
|
|
37
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
38
|
+
const listRef = (0, import_react.useRef)(null);
|
|
39
|
+
return import_react.default.useMemo(() => ({ inputRef, listRef }), [inputRef, listRef]);
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=useRefs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useRefs.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useRef } from 'react';\n\nexport const useRefs = () => {\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n return React.useMemo(() => ({ inputRef, listRef }), [inputRef, listRef]);\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAA8B;AAEvB,MAAM,UAAU,MAAM;AAC3B,QAAM,eAAW,qBAAyB,IAAI;AAC9C,QAAM,cAAU,qBAAuB,IAAI;AAC3C,SAAO,aAAAA,QAAM,QAAQ,OAAO,EAAE,UAAU,QAAQ,IAAI,CAAC,UAAU,OAAO,CAAC;AACzE;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 useVirtualization_exports = {};
|
|
30
|
+
__export(useVirtualization_exports, {
|
|
31
|
+
useVirtualization: () => useVirtualization
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(useVirtualization_exports);
|
|
34
|
+
var React = __toESM(require("react"));
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_react_virtual = require("react-virtual");
|
|
37
|
+
const useVirtualization = ({
|
|
38
|
+
references,
|
|
39
|
+
propsWithDefault
|
|
40
|
+
}) => {
|
|
41
|
+
const { options } = propsWithDefault;
|
|
42
|
+
const { listRef } = references;
|
|
43
|
+
const virtualListHelpers = (0, import_react_virtual.useVirtual)({
|
|
44
|
+
size: options.length,
|
|
45
|
+
parentRef: listRef,
|
|
46
|
+
overscan: 15,
|
|
47
|
+
paddingStart: 0
|
|
48
|
+
});
|
|
49
|
+
const scrollOptionIntoView = (0, import_react.useCallback)(
|
|
50
|
+
(dsId, opts = { align: "center" }) => {
|
|
51
|
+
virtualListHelpers.scrollToIndex(
|
|
52
|
+
options.findIndex((opt) => opt.dsId === dsId),
|
|
53
|
+
opts
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
[options, virtualListHelpers]
|
|
57
|
+
);
|
|
58
|
+
return import_react.default.useMemo(
|
|
59
|
+
() => ({
|
|
60
|
+
virtualListHelpers,
|
|
61
|
+
scrollOptionIntoView
|
|
62
|
+
}),
|
|
63
|
+
[virtualListHelpers, scrollOptionIntoView]
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=useVirtualization.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/config/useVirtualization.ts", "../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import React, { useCallback } from 'react';\nimport { useVirtual } from 'react-virtual';\nimport type {} from 'react-virtual';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport type { useRefs } from './useRefs.js';\n\nexport const useVirtualization = ({\n references,\n propsWithDefault,\n}: {\n references: ReturnType<typeof useRefs>;\n propsWithDefault: DSAutocompleteT.InternalProps;\n}) => {\n const { options } = propsWithDefault;\n const { listRef } = references;\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n const virtualListHelpers: ReturnType<typeof useVirtual> = useVirtual({\n size: options.length,\n parentRef: listRef,\n overscan: 15,\n paddingStart: 0,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts = { align: 'center' }) => {\n virtualListHelpers.scrollToIndex(\n options.findIndex((opt) => opt.dsId === dsId),\n opts,\n );\n },\n [options, virtualListHelpers],\n );\n\n return React.useMemo(\n () => ({\n virtualListHelpers,\n scrollOptionIntoView,\n }),\n [virtualListHelpers, scrollOptionIntoView],\n );\n};\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAmC;AACnC,2BAA2B;AAKpB,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,EAAE,QAAQ,IAAI;AAKpB,QAAM,yBAAoD,iCAAW;AAAA,IACnE,MAAM,QAAQ;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAKD,QAAM,2BAAuB;AAAA,IAC3B,CAAC,MAAc,OAAO,EAAE,OAAO,SAAS,MAAM;AAC5C,yBAAmB;AAAA,QACjB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS,IAAI;AAAA,QAC5C;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,SAAS,kBAAkB;AAAA,EAC9B;AAEA,SAAO,aAAAA,QAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,oBAAoB,oBAAoB;AAAA,EAC3C;AACF;",
|
|
6
|
+
"names": ["React"]
|
|
7
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,6 +15,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
};
|
|
16
16
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
17
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
18
22
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
19
23
|
mod
|
|
20
24
|
));
|
|
@@ -22,5 +26,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
26
|
var src_exports = {};
|
|
23
27
|
module.exports = __toCommonJS(src_exports);
|
|
24
28
|
var React = __toESM(require("react"));
|
|
25
|
-
__reExport(src_exports, require("./Autocomplete"), module.exports);
|
|
29
|
+
__reExport(src_exports, require("./Autocomplete.js"), module.exports);
|
|
30
|
+
__reExport(src_exports, require("./AutocompleteDataTestids.js"), module.exports);
|
|
26
31
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["// export { CBContainer, CBContainerWithSchema } from './parts/cb-container';\nexport * from './Autocomplete';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// export { CBContainer, CBContainerWithSchema } from './parts/cb-container';\nexport * from './Autocomplete.js';\nexport * from './AutocompleteDataTestids.js';\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;ADCvB,wBAAc,8BADd;AAEA,wBAAc,yCAFd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|