@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.
Files changed (99) hide show
  1. package/dist/cjs/Autocomplete.js +11 -7
  2. package/dist/cjs/Autocomplete.js.map +2 -2
  3. package/dist/cjs/AutocompleteCTX.js +6 -22
  4. package/dist/cjs/AutocompleteCTX.js.map +2 -2
  5. package/dist/cjs/AutocompleteDataTestids.js +4 -0
  6. package/dist/cjs/AutocompleteDataTestids.js.map +1 -1
  7. package/dist/cjs/DSAutocompleteDefinitions.js +4 -0
  8. package/dist/cjs/DSAutocompleteDefinitions.js.map +1 -1
  9. package/dist/cjs/config/useAutocomplete.js +34 -47
  10. package/dist/cjs/config/useAutocomplete.js.map +3 -3
  11. package/dist/cjs/config/usePopoverLogic.js +113 -0
  12. package/dist/cjs/config/usePopoverLogic.js.map +7 -0
  13. package/dist/cjs/{sharedTypes.js → config/useRefs.js} +20 -3
  14. package/dist/cjs/config/useRefs.js.map +7 -0
  15. package/dist/cjs/config/useVirtualization.js +66 -0
  16. package/dist/cjs/config/useVirtualization.js.map +7 -0
  17. package/dist/cjs/index.js +6 -1
  18. package/dist/cjs/index.js.map +2 -2
  19. package/dist/cjs/package.json +7 -0
  20. package/dist/cjs/parts/A11yFocusedOption.js +9 -5
  21. package/dist/cjs/parts/A11yFocusedOption.js.map +2 -2
  22. package/dist/cjs/parts/container/Container.js +29 -25
  23. package/dist/cjs/parts/container/Container.js.map +2 -2
  24. package/dist/cjs/parts/container/index.js +5 -1
  25. package/dist/cjs/parts/container/index.js.map +2 -2
  26. package/dist/cjs/parts/container/styled.js +4 -0
  27. package/dist/cjs/parts/container/styled.js.map +1 -1
  28. package/dist/cjs/parts/container/useKeyboardNavigation.js +21 -20
  29. package/dist/cjs/parts/container/useKeyboardNavigation.js.map +2 -2
  30. package/dist/cjs/parts/menu-list/MenuList.js +23 -23
  31. package/dist/cjs/parts/menu-list/MenuList.js.map +2 -2
  32. package/dist/cjs/parts/menu-list/index.js +5 -1
  33. package/dist/cjs/parts/menu-list/index.js.map +2 -2
  34. package/dist/cjs/parts/menu-list/styled.js +4 -0
  35. package/dist/cjs/parts/menu-list/styled.js.map +1 -1
  36. package/dist/cjs/parts/menu-list/useItemRenderer.js +11 -5
  37. package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
  38. package/dist/cjs/react-desc-prop-types.js +16 -5
  39. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  40. package/dist/cjs/tests/utils.js +4 -0
  41. package/dist/cjs/tests/utils.js.map +1 -1
  42. package/dist/cjs/utils/listHelper.js +4 -0
  43. package/dist/cjs/utils/listHelper.js.map +2 -2
  44. package/dist/esm/Autocomplete.js +6 -6
  45. package/dist/esm/Autocomplete.js.map +1 -1
  46. package/dist/esm/AutocompleteCTX.js +3 -23
  47. package/dist/esm/AutocompleteCTX.js.map +2 -2
  48. package/dist/esm/config/useAutocomplete.js +27 -44
  49. package/dist/esm/config/useAutocomplete.js.map +3 -3
  50. package/dist/esm/config/usePopoverLogic.js +83 -0
  51. package/dist/esm/config/usePopoverLogic.js.map +7 -0
  52. package/dist/esm/config/useRefs.js +11 -0
  53. package/dist/esm/config/useRefs.js.map +7 -0
  54. package/dist/esm/config/useVirtualization.js +36 -0
  55. package/dist/esm/config/useVirtualization.js.map +7 -0
  56. package/dist/esm/index.js +2 -1
  57. package/dist/esm/index.js.map +2 -2
  58. package/dist/esm/package.json +7 -0
  59. package/dist/esm/parts/A11yFocusedOption.js +5 -5
  60. package/dist/esm/parts/A11yFocusedOption.js.map +2 -2
  61. package/dist/esm/parts/container/Container.js +26 -26
  62. package/dist/esm/parts/container/Container.js.map +2 -2
  63. package/dist/esm/parts/container/index.js +1 -1
  64. package/dist/esm/parts/container/index.js.map +1 -1
  65. package/dist/esm/parts/container/useKeyboardNavigation.js +17 -20
  66. package/dist/esm/parts/container/useKeyboardNavigation.js.map +2 -2
  67. package/dist/esm/parts/menu-list/MenuList.js +19 -23
  68. package/dist/esm/parts/menu-list/MenuList.js.map +2 -2
  69. package/dist/esm/parts/menu-list/index.js +1 -1
  70. package/dist/esm/parts/menu-list/index.js.map +1 -1
  71. package/dist/esm/parts/menu-list/useItemRenderer.js +7 -5
  72. package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
  73. package/dist/esm/react-desc-prop-types.js +8 -1
  74. package/dist/esm/react-desc-prop-types.js.map +2 -2
  75. package/dist/esm/utils/listHelper.js.map +2 -2
  76. package/package.json +12 -12
  77. package/dist/cjs/sharedTypes.js.map +0 -7
  78. package/dist/esm/sharedTypes.js +0 -2
  79. package/dist/esm/sharedTypes.js.map +0 -7
  80. package/dist/types/Autocomplete.d.ts +0 -5
  81. package/dist/types/AutocompleteCTX.d.ts +0 -7
  82. package/dist/types/AutocompleteDataTestids.d.ts +0 -5
  83. package/dist/types/DSAutocompleteDefinitions.d.ts +0 -1
  84. package/dist/types/config/useAutocomplete.d.ts +0 -3
  85. package/dist/types/index.d.ts +0 -1
  86. package/dist/types/parts/A11yFocusedOption.d.ts +0 -5
  87. package/dist/types/parts/container/Container.d.ts +0 -1
  88. package/dist/types/parts/container/index.d.ts +0 -1
  89. package/dist/types/parts/container/styled.d.ts +0 -2
  90. package/dist/types/parts/container/useKeyboardNavigation.d.ts +0 -4
  91. package/dist/types/parts/menu-list/MenuList.d.ts +0 -1
  92. package/dist/types/parts/menu-list/index.d.ts +0 -1
  93. package/dist/types/parts/menu-list/styled.d.ts +0 -7
  94. package/dist/types/parts/menu-list/useItemRenderer.d.ts +0 -1
  95. package/dist/types/react-desc-prop-types.d.ts +0 -44
  96. package/dist/types/sharedTypes.d.ts +0 -18
  97. package/dist/types/tests/general.test.d.ts +0 -1
  98. package/dist/types/tests/utils.d.ts +0 -5
  99. package/dist/types/utils/listHelper.d.ts +0 -7
@@ -18,21 +18,32 @@ 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
  ));
24
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
29
  var react_desc_prop_types_exports = {};
26
30
  __export(react_desc_prop_types_exports, {
31
+ defaultProps: () => defaultProps,
27
32
  propTypes: () => propTypes
28
33
  });
29
34
  module.exports = __toCommonJS(react_desc_prop_types_exports);
30
35
  var React = __toESM(require("react"));
31
- var import_ds_utilities = require("@elliemae/ds-utilities");
36
+ var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
37
+ const defaultProps = {
38
+ zIndex: 10,
39
+ withoutPortal: false,
40
+ startPlacementPreference: "bottom-start",
41
+ placementOrderPreference: ["bottom-start", "bottom-end"]
42
+ };
32
43
  const propTypes = {
33
- options: import_ds_utilities.PropTypes.oneOfType([import_ds_utilities.PropTypes.array, import_ds_utilities.PropTypes.object]).isRequired.description("List of options").defaultValue([]),
34
- filter: import_ds_utilities.PropTypes.string.isRequired.description("String value to filter the options").defaultValue(""),
35
- onSelect: import_ds_utilities.PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue(""),
36
- children: import_ds_utilities.PropTypes.node.isRequired.description("React component to apply autocomplete functionality").defaultValue("")
44
+ 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([]),
45
+ filter: import_ds_props_helpers.PropTypes.string.isRequired.description("String value to filter the options").defaultValue(""),
46
+ onSelect: import_ds_props_helpers.PropTypes.func.isRequired.description("function triggered when an option is selected it will send the options selected").defaultValue(""),
47
+ children: import_ds_props_helpers.PropTypes.node.isRequired.description("React component to apply autocomplete functionality").defaultValue("")
37
48
  };
38
49
  //# 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 { PropTypes } from '@elliemae/ds-utilities';\n\nexport declare namespace DSAutocompleteT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n children: React.ReactChild;\n filter: string;\n onSelect: (suggestedValue: string | number, e: React.KeyboardEvent<HTMLInputElement>) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: string[];\n withoutPortal: boolean;\n zIndex: number;\n }\n\n export interface Props extends Partial<DefaultProps>, RequiredProps {}\n\n export interface InternalProps extends DefaultProps, RequiredProps {}\n}\n\nexport const propTypes = {\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of options')\n .defaultValue([]),\n filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),\n onSelect: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n children: PropTypes.node.isRequired\n .description('React component to apply autocomplete functionality')\n .defaultValue(''),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,0BAA0B;AA6CnB,MAAM,YAAY;AAAA,EACvB,SAAS,8BAAU,UAAU,CAAC,8BAAU,OAAO,8BAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,8BAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,8BAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,8BAAU,KAAK,WACtB,YAAY,qDAAqD,EACjE,aAAa,EAAE;AACpB;",
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport { PropTypes } from '@elliemae/ds-props-helpers';\n\nexport declare namespace DSAutocompleteT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions | ItemSeparatorOptions;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n children: React.ReactChild;\n filter: string;\n onSelect: (\n suggestedValue: string | number,\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 }\n\n export interface Props extends Partial<DefaultProps>, RequiredProps {}\n\n export interface InternalProps extends DefaultProps, RequiredProps {}\n}\n\nexport const defaultProps: DSAutocompleteT.DefaultProps = {\n zIndex: 10,\n withoutPortal: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n};\n\nexport const propTypes = {\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of options')\n .defaultValue([]),\n filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),\n onSelect: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n children: PropTypes.node.isRequired\n .description('React component to apply autocomplete functionality')\n .defaultValue(''),\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGvB,8BAA0B;AAgDnB,MAAM,eAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,YAAY;AACzD;AAEO,MAAM,YAAY;AAAA,EACvB,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,KAAK,WACtB,YAAY,qDAAqD,EACjE,aAAa,EAAE;AACpB;",
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/tests/utils.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
4
  "sourcesContent": ["export const basicOptions = [\n {\n dsId: '12',\n type: 'section',\n label: 'Please Select the appropriate city',\n },\n {\n dsId: '1',\n type: 'option',\n label: '44444-4444',\n },\n {\n dsId: '2',\n type: 'option',\n label: '44444-5555',\n },\n {\n dsId: '3',\n type: 'option',\n label: '44444-6666',\n },\n];\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAhB,MAAM,eAAe;AAAA,EAC1B;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,OAAO;AAAA,EACT;AACF;",
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
  ));
@@ -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';\n\nexport const getSelectableOptions = (options: Array<DSAutocompleteT.OptionTypes>): 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,CAAC,YACnC,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,OAAO,IACrB,KAAK,IAAI,OAAO,KAAK,UAAU,KAAK,QACpC;AACA,QAAI,SAAS,KAAK,EAAE;AAAG,aAAO;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,GAAG,IAAI,GAAG;AACvD,aAAO,QAAQ,GAAG;AAAA,IACpB;AACF,SAAO;AACT;",
4
+ "sourcesContent": ["import type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\nexport const getSelectableOptions = (options: Array<DSAutocompleteT.OptionTypes>): 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,CAAC,YACnC,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,OAAO,IACrB,KAAK,IAAI,OAAO,KAAK,UAAU,KAAK,QACpC;AACA,QAAI,SAAS,KAAK,CAAC,CAAC;AAAG,aAAO;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;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,11 @@
1
1
  import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { describe } from "@elliemae/ds-utilities";
4
- import { useAutocomplete } from "./config/useAutocomplete";
5
- import { Container } from "./parts/container";
6
- import { AutocompleteContext } from "./AutocompleteCTX";
7
- import { propTypes } from "./react-desc-prop-types";
8
- import { DSAutocompleteName } from "./DSAutocompleteDefinitions";
3
+ import { describe } from "@elliemae/ds-props-helpers";
4
+ import { useAutocomplete } from "./config/useAutocomplete.js";
5
+ import { Container } from "./parts/container/index.js";
6
+ import { AutocompleteContext } from "./AutocompleteCTX.js";
7
+ import { propTypes } from "./react-desc-prop-types.js";
8
+ import { DSAutocompleteName } from "./DSAutocompleteDefinitions.js";
9
9
  const DSAutocomplete = (props) => {
10
10
  const ctx = useAutocomplete(props);
11
11
  return /* @__PURE__ */ jsx(AutocompleteContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(Container, {}) });
@@ -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 type { WeakValidationMap } from 'react';\nimport React from 'react';\nimport { describe } from '@elliemae/ds-utilities';\nimport { useAutocomplete } from './config/useAutocomplete';\nimport { Container } from './parts/container';\nimport { AutocompleteContext } from './AutocompleteCTX';\nimport type { DSAutocompleteT } from './react-desc-prop-types';\nimport { propTypes } from './react-desc-prop-types';\nimport { DSAutocompleteName } from './DSAutocompleteDefinitions';\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"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACcjB;AAZN,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAChC,SAAS,iBAAiB;AAC1B,SAAS,2BAA2B;AAEpC,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AAEnC,MAAM,iBAA6D,CAAC,UAAU;AAC5E,QAAM,MAAM,gBAAgB,KAAK;AACjC,SACE,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,KACnC,8BAAC,aAAU,GACb;AAEJ;AACA,eAAe,YAAY;AAC3B,eAAe,cAAc;AAC7B,MAAM,2BAA2B,SAAS,cAAc;AACxD,yBAAyB,YAAY;",
6
6
  "names": []
7
7
  }
@@ -1,30 +1,10 @@
1
1
  import * as React from "react";
2
- import { createContext, createRef } from "react";
3
- const noop = () => {
4
- };
5
- const defaultProps = {
6
- zIndex: 10,
7
- withoutPortal: false,
8
- startPlacementPreference: "bottom-start",
9
- placementOrderPreference: ["bottom-start", "bottom-end"]
10
- };
11
- const defaultContext = {
12
- props: defaultProps,
13
- showPopover: false,
14
- setShowPopover: noop,
15
- scrollOptionIntoView: noop,
16
- referenceElement: null,
17
- setReferenceElement: noop,
18
- inputRef: createRef(),
19
- listRef: createRef(),
20
- focusOptionIdx: "",
21
- setCurrentOption: noop
22
- };
2
+ import { createContext } from "react";
3
+ const defaultContext = {};
23
4
  const AutocompleteContext = createContext(defaultContext);
24
5
  var AutocompleteCTX_default = AutocompleteContext;
25
6
  export {
26
7
  AutocompleteContext,
27
- AutocompleteCTX_default as default,
28
- defaultProps
8
+ AutocompleteCTX_default as default
29
9
  };
30
10
  //# sourceMappingURL=AutocompleteCTX.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/AutocompleteCTX.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { createContext, createRef } from 'react';\nimport type { DSAutocompleteT } from './react-desc-prop-types';\nimport type { DSAutoCompleteInternalsT } from './sharedTypes';\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nconst noop = () => {};\nexport const defaultProps: DSAutocompleteT.DefaultProps = {\n zIndex: 10,\n withoutPortal: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'bottom-end'],\n};\nconst defaultContext = {\n props: defaultProps as DSAutocompleteT.InternalProps,\n showPopover: false,\n setShowPopover: noop,\n scrollOptionIntoView: noop,\n referenceElement: null,\n setReferenceElement: noop,\n inputRef: createRef<HTMLInputElement>(),\n listRef: createRef<HTMLDivElement>(),\n focusOptionIdx: '',\n setCurrentOption: noop,\n};\n/** Context for cross component communication */\nexport const AutocompleteContext = createContext<DSAutoCompleteInternalsT.AutocompleteContext>(defaultContext);\n\nexport default AutocompleteContext;\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,eAAe,iBAAiB;AAIzC,MAAM,OAAO,MAAM;AAAC;AACb,MAAM,eAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,YAAY;AACzD;AACA,MAAM,iBAAiB;AAAA,EACrB,OAAO;AAAA,EACP,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,UAAU,UAA4B;AAAA,EACtC,SAAS,UAA0B;AAAA,EACnC,gBAAgB;AAAA,EAChB,kBAAkB;AACpB;AAEO,MAAM,sBAAsB,cAA4D,cAAc;AAE7G,IAAO,0BAAQ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,qBAAqB;AAG9B,MAAM,iBAAiB,CAAC;AAEjB,MAAM,sBAAsB,cAAoC,cAAc;AAErF,IAAO,0BAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,11 +1,13 @@
1
1
  import * as React from "react";
2
- import { useMemo, useState, useEffect, useRef, useCallback } from "react";
3
- import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-utilities";
4
- import { useVirtual } from "react-virtual";
5
- import { propTypes } from "../react-desc-prop-types";
6
- import { defaultProps } from "../AutocompleteCTX";
7
- import { getFirstOption } from "../utils/listHelper";
8
- import { DSAutocompleteName } from "../DSAutocompleteDefinitions";
2
+ import React2, { useMemo, useState, useRef } from "react";
3
+ import { uid } from "uid";
4
+ import { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from "@elliemae/ds-props-helpers";
5
+ import { propTypes, defaultProps } from "../react-desc-prop-types.js";
6
+ import { getFirstOption } from "../utils/listHelper.js";
7
+ import { DSAutocompleteName } from "../DSAutocompleteDefinitions.js";
8
+ import { useRefs } from "./useRefs.js";
9
+ import { useVirtualization } from "./useVirtualization.js";
10
+ import { usePopoverLogic } from "./usePopoverLogic.js";
9
11
  const useAutocomplete = (props) => {
10
12
  const defaultPropsWithInnerRef = {
11
13
  ...defaultProps,
@@ -13,58 +15,39 @@ const useAutocomplete = (props) => {
13
15
  };
14
16
  const propsWithDefault = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);
15
17
  useValidateTypescriptPropTypes(propsWithDefault, propTypes, DSAutocompleteName);
16
- const [showPopover, setShowPopover] = useState(false);
18
+ const { options } = propsWithDefault;
17
19
  const [referenceElement, setReferenceElement] = useState(null);
18
20
  const [focusOptionIdx, setCurrentOption] = useState("");
19
- const inputRef = useRef(null);
20
- const listRef = useRef(null);
21
- const { options, filter } = propsWithDefault;
22
- const virtualListHelpers = useVirtual({
23
- size: options.length,
24
- parentRef: listRef,
25
- overscan: 15,
26
- paddingStart: 0
21
+ const references = useRefs();
22
+ const virtualizationManager = useVirtualization({
23
+ references,
24
+ propsWithDefault
27
25
  });
28
- const scrollOptionIntoView = useCallback(
29
- (dsId, opts = { align: "center" }) => {
30
- virtualListHelpers.scrollToIndex(
31
- options.findIndex((opt) => opt.dsId === dsId),
32
- opts
33
- );
34
- },
35
- [options, virtualListHelpers]
36
- );
37
- useEffect(() => {
38
- if (filter.length === 0 || options.length === 0) {
39
- setShowPopover(false);
40
- }
41
- }, [filter, options.length, setShowPopover]);
42
- useEffect(() => {
26
+ const autoCompleteId = uid(4);
27
+ const popoverManager = usePopoverLogic(propsWithDefault);
28
+ React2.useEffect(() => {
43
29
  setCurrentOption(getFirstOption(options));
44
- }, [options, showPopover]);
30
+ }, [options]);
45
31
  const ctx = useMemo(
46
32
  () => ({
47
33
  props: { ...propsWithDefault },
48
- virtualListHelpers,
49
- showPopover,
50
34
  referenceElement,
51
- inputRef,
52
- listRef,
53
35
  focusOptionIdx,
54
36
  setCurrentOption,
55
- scrollOptionIntoView,
56
37
  setReferenceElement,
57
- setShowPopover
38
+ autoCompleteId,
39
+ ...references,
40
+ ...popoverManager,
41
+ ...virtualizationManager
58
42
  }),
59
43
  [
60
- scrollOptionIntoView,
61
44
  propsWithDefault,
62
- virtualListHelpers,
63
- focusOptionIdx,
64
- showPopover,
45
+ autoCompleteId,
65
46
  referenceElement,
66
- inputRef,
67
- listRef
47
+ focusOptionIdx,
48
+ popoverManager,
49
+ references,
50
+ virtualizationManager
68
51
  ]
69
52
  );
70
53
  return ctx;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useAutocomplete.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport { useMemo, useState, useEffect, useRef, useCallback } from 'react';\nimport { useMemoMergePropsWithDefault, useValidateTypescriptPropTypes } from '@elliemae/ds-utilities';\n\nimport { useVirtual } from 'react-virtual';\nimport type { DSAutocompleteT } from '../react-desc-prop-types';\nimport { propTypes } from '../react-desc-prop-types';\nimport type { DSAutoCompleteInternalsT } from '../sharedTypes';\nimport { defaultProps } from '../AutocompleteCTX';\nimport { getFirstOption } from '../utils/listHelper';\nimport { DSAutocompleteName } from '../DSAutocompleteDefinitions';\n\nexport const useAutocomplete = (props: DSAutocompleteT.Props): DSAutoCompleteInternalsT.AutocompleteContext => {\n const defaultPropsWithInnerRef = {\n ...defaultProps,\n innerRef: useRef(null),\n };\n const propsWithDefault = useMemoMergePropsWithDefault(props, defaultPropsWithInnerRef);\n useValidateTypescriptPropTypes(propsWithDefault, propTypes, DSAutocompleteName);\n const [showPopover, setShowPopover] = useState<boolean>(false);\n const [referenceElement, setReferenceElement] = useState<HTMLElement | null>(null);\n\n const [focusOptionIdx, setCurrentOption] = useState<string>('');\n\n const inputRef = useRef<HTMLInputElement>(null);\n const listRef = useRef<HTMLDivElement>(null);\n\n const { options, filter } = propsWithDefault;\n\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\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 useEffect(() => {\n if (filter.length === 0 || options.length === 0) {\n setShowPopover(false);\n }\n }, [filter, options.length, setShowPopover]);\n\n useEffect(() => {\n setCurrentOption(getFirstOption(options));\n }, [options, showPopover]);\n\n const ctx = useMemo(\n () => ({\n props: { ...propsWithDefault },\n virtualListHelpers,\n showPopover,\n referenceElement,\n inputRef,\n listRef,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n setReferenceElement,\n setShowPopover,\n }),\n [\n scrollOptionIntoView,\n propsWithDefault,\n virtualListHelpers,\n focusOptionIdx,\n showPopover,\n referenceElement,\n inputRef,\n listRef,\n ],\n );\n\n return ctx;\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACIvB,SAAS,SAAS,UAAU,WAAW,QAAQ,mBAAmB;AAClE,SAAS,8BAA8B,sCAAsC;AAE7E,SAAS,kBAAkB;AAE3B,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AAE5B,MAAM,kBAAkB,CAAC,UAA+E;AAC7G,QAAM,2BAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,OAAO,IAAI;AAAA,EACvB;AACA,QAAM,mBAAmB,6BAA6B,OAAO,wBAAwB;AACrF,iCAA+B,kBAAkB,WAAW,kBAAkB;AAC9E,QAAM,CAAC,aAAa,cAAc,IAAI,SAAkB,KAAK;AAC7D,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAA6B,IAAI;AAEjF,QAAM,CAAC,gBAAgB,gBAAgB,IAAI,SAAiB,EAAE;AAE9D,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,UAAU,OAAuB,IAAI;AAE3C,QAAM,EAAE,SAAS,OAAO,IAAI;AAM5B,QAAM,qBAAoD,WAAW;AAAA,IACnE,MAAM,QAAQ;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAKD,QAAM,uBAAuB;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,YAAU,MAAM;AACd,QAAI,OAAO,WAAW,KAAK,QAAQ,WAAW,GAAG;AAC/C,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF,GAAG,CAAC,QAAQ,QAAQ,QAAQ,cAAc,CAAC;AAE3C,YAAU,MAAM;AACd,qBAAiB,eAAe,OAAO,CAAC;AAAA,EAC1C,GAAG,CAAC,SAAS,WAAW,CAAC;AAEzB,QAAM,MAAM;AAAA,IACV,OAAO;AAAA,MACL,OAAO,EAAE,GAAG,iBAAiB;AAAA,MAC7B;AAAA,MACA;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,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;",
6
- "names": []
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable import/prefer-default-export */\n/* eslint-disable complexity */\n/* eslint-disable max-statements */\nimport 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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACIvB,OAAOA,UAAS,SAAS,UAAU,cAAc;AACjD,SAAS,WAAW;AAEpB,SAAS,8BAA8B,sCAAsC;AAE7E,SAAS,WAAW,oBAAoB;AACxC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,uBAAuB;AAazB,MAAM,kBAAkB,CAAC,UAAuD;AACrF,QAAM,2BAA2B;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,OAAO,IAAI;AAAA,EACvB;AACA,QAAM,mBAAmB,6BAA6B,OAAO,wBAAwB;AACrF,iCAA+B,kBAAkB,WAAW,kBAAkB;AAE9E,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAA6B,IAAI;AACjF,QAAM,CAAC,gBAAgB,gBAAgB,IAAI,SAAiB,EAAE;AAE9D,QAAM,aAAa,QAAQ;AAE3B,QAAM,wBAAwB,kBAAkB;AAAA,IAC9C;AAAA,IACA;AAAA,EACF,CAAC;AAED,QAAM,iBAAiB,IAAI,CAAC;AAC5B,QAAM,iBAAiB,gBAAgB,gBAAgB;AAEvD,EAAAA,OAAM,UAAU,MAAM;AACpB,qBAAiB,eAAe,OAAO,CAAC;AAAA,EAC1C,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,MAAM;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,83 @@
1
+ import * as React from "react";
2
+ import React2, { useState, useEffect } from "react";
3
+ const usePopoverLogic = (propsWithDefault) => {
4
+ const { options, filter } = propsWithDefault;
5
+ const [forceClosePopover, setForceClosePopover] = useState(false);
6
+ const [userTypedSomething, setUserTypedSomething] = useState(false);
7
+ const [userIsNavigatingWithArrows, setUserIsNavigatingWithArrows] = useState(false);
8
+ const [userJustSelectedAnOption, setUserJustSelectedAnOption] = useState(false);
9
+ const userSelectedAndDidNotType = userJustSelectedAnOption && !userTypedSomething;
10
+ const popoverHasAnythingToShow = options.length > 0 && filter.length > 0;
11
+ const isShowingPopover = !forceClosePopover && // user pressed escape (or other interaction that forces close) --> hide popover
12
+ popoverHasAnythingToShow && // nothing to show --> hide popover
13
+ !userSelectedAndDidNotType && // user just selected an option --> hide popover
14
+ (userTypedSomething || // user typed something --> show popover
15
+ userIsNavigatingWithArrows);
16
+ const trackUserTyping = React2.useCallback(
17
+ (e) => {
18
+ const { key } = e;
19
+ if ([...e.key].length === 1 || key === "Backspace" || key === "Delete") {
20
+ setUserTypedSomething(true);
21
+ setForceClosePopover(false);
22
+ setUserJustSelectedAnOption(false);
23
+ } else {
24
+ setUserTypedSomething(false);
25
+ }
26
+ },
27
+ [setUserTypedSomething]
28
+ );
29
+ const trackUserNavigatingWithArrows = React2.useCallback(
30
+ (e) => {
31
+ const { key } = e;
32
+ if (isShowingPopover && (key === "ArrowUp" || key === "ArrowDown")) {
33
+ setUserIsNavigatingWithArrows(true);
34
+ } else {
35
+ setUserIsNavigatingWithArrows(false);
36
+ }
37
+ },
38
+ [isShowingPopover]
39
+ );
40
+ const trackUserSelectingAnOption = React2.useCallback(
41
+ (e) => {
42
+ const { key } = e;
43
+ if (key === "Enter" && isShowingPopover) {
44
+ setUserJustSelectedAnOption(true);
45
+ }
46
+ },
47
+ [isShowingPopover]
48
+ );
49
+ const trackUserInteractingViaKeyboard = React2.useCallback(
50
+ (e) => {
51
+ trackUserTyping(e);
52
+ trackUserNavigatingWithArrows(e);
53
+ trackUserSelectingAnOption(e);
54
+ },
55
+ [trackUserTyping, trackUserNavigatingWithArrows, trackUserSelectingAnOption]
56
+ );
57
+ useEffect(() => {
58
+ const closePopper = () => {
59
+ setForceClosePopover(true);
60
+ };
61
+ window.addEventListener("blur", closePopper);
62
+ return () => {
63
+ window.removeEventListener("blur", closePopper);
64
+ };
65
+ }, []);
66
+ return React2.useMemo(
67
+ () => ({
68
+ isShowingPopover,
69
+ forceClosePopover,
70
+ setForceClosePopover,
71
+ userTypedSomething,
72
+ setUserTypedSomething,
73
+ setUserJustSelectedAnOption,
74
+ setUserIsNavigatingWithArrows,
75
+ trackUserInteractingViaKeyboard
76
+ }),
77
+ [isShowingPopover, forceClosePopover, userTypedSomething, trackUserInteractingViaKeyboard]
78
+ );
79
+ };
80
+ export {
81
+ usePopoverLogic
82
+ };
83
+ //# sourceMappingURL=usePopoverLogic.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/usePopoverLogic.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useState, useEffect } from 'react';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\n// we want to own all the popover logic in a single place\n// we handle global events via window.addEventListener/RemoveEventListener\n// the logic to show/hide the popover accounts for\n// show:\n// - the user just typed something (excluding special keys like arrows, enter, etc)\n// - any options are available\n// - the user did not just select an option\n// N.B. this must react to options.length changing in an async way\n// hide:\n// - the user just selected an option and did not type anything after\n// - no options are available\n// - the focus is not on the input\n// - the user pressed the escape key\nexport const usePopoverLogic = (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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,UAAU,iBAAiB;AAgBpC,MAAM,kBAAkB,CAAC,qBAAoD;AAClF,QAAM,EAAE,SAAS,OAAO,IAAI;AAE5B,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAkB,KAAK;AAEzE,QAAM,CAAC,oBAAoB,qBAAqB,IAAI,SAAkB,KAAK;AAC3E,QAAM,CAAC,4BAA4B,6BAA6B,IAAI,SAAkB,KAAK;AAC3F,QAAM,CAAC,0BAA0B,2BAA2B,IAAI,SAAkB,KAAK;AAEvF,QAAM,4BAA4B,4BAA4B,CAAC;AAC/D,QAAM,2BAA2B,QAAQ,SAAS,KAAK,OAAO,SAAS;AAEvE,QAAM,mBACJ,CAAC;AAAA,EACD;AAAA,EACA,CAAC;AAAA,GACA;AAAA,EACC;AAEJ,QAAM,kBAAgEA,OAAM;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,gCAA8EA,OAAM;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,6BAA2EA,OAAM;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,kCAAgFA,OAAM;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,YAAU,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,SAAOA,OAAM;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
+ }
@@ -0,0 +1,11 @@
1
+ import * as React from "react";
2
+ import React2, { useRef } from "react";
3
+ const useRefs = () => {
4
+ const inputRef = useRef(null);
5
+ const listRef = useRef(null);
6
+ return React2.useMemo(() => ({ inputRef, listRef }), [inputRef, listRef]);
7
+ };
8
+ export {
9
+ useRefs
10
+ };
11
+ //# sourceMappingURL=useRefs.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useRefs.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,cAAc;AAEvB,MAAM,UAAU,MAAM;AAC3B,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,UAAU,OAAuB,IAAI;AAC3C,SAAOA,OAAM,QAAQ,OAAO,EAAE,UAAU,QAAQ,IAAI,CAAC,UAAU,OAAO,CAAC;AACzE;",
6
+ "names": ["React"]
7
+ }
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import React2, { useCallback } from "react";
3
+ import { useVirtual } from "react-virtual";
4
+ const useVirtualization = ({
5
+ references,
6
+ propsWithDefault
7
+ }) => {
8
+ const { options } = propsWithDefault;
9
+ const { listRef } = references;
10
+ const virtualListHelpers = useVirtual({
11
+ size: options.length,
12
+ parentRef: listRef,
13
+ overscan: 15,
14
+ paddingStart: 0
15
+ });
16
+ const scrollOptionIntoView = useCallback(
17
+ (dsId, opts = { align: "center" }) => {
18
+ virtualListHelpers.scrollToIndex(
19
+ options.findIndex((opt) => opt.dsId === dsId),
20
+ opts
21
+ );
22
+ },
23
+ [options, virtualListHelpers]
24
+ );
25
+ return React2.useMemo(
26
+ () => ({
27
+ virtualListHelpers,
28
+ scrollOptionIntoView
29
+ }),
30
+ [virtualListHelpers, scrollOptionIntoView]
31
+ );
32
+ };
33
+ export {
34
+ useVirtualization
35
+ };
36
+ //# sourceMappingURL=useVirtualization.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/config/useVirtualization.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,OAAOA,UAAS,mBAAmB;AACnC,SAAS,kBAAkB;AAKpB,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AACF,MAGM;AACJ,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,EAAE,QAAQ,IAAI;AAKpB,QAAM,qBAAoD,WAAW;AAAA,IACnE,MAAM,QAAQ;AAAA,IACd,WAAW;AAAA,IACX,UAAU;AAAA,IACV,cAAc;AAAA,EAChB,CAAC;AAKD,QAAM,uBAAuB;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,SAAOA,OAAM;AAAA,IACX,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IACF;AAAA,IACA,CAAC,oBAAoB,oBAAoB;AAAA,EAC3C;AACF;",
6
+ "names": ["React"]
7
+ }
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import * as React from "react";
2
- export * from "./Autocomplete";
2
+ export * from "./Autocomplete.js";
3
+ export * from "./AutocompleteDataTestids.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// export { CBContainer, CBContainerWithSchema } from './parts/cb-container';\nexport * from './Autocomplete';\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACCvB,cAAc;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "// export { CBContainer, CBContainerWithSchema } from './parts/cb-container';\nexport * from './Autocomplete.js';\nexport * from './AutocompleteDataTestids.js';\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACCvB,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "module",
3
+ "sideEffects": [
4
+ "*.css",
5
+ "*.scss"
6
+ ]
7
+ }
@@ -2,8 +2,8 @@ import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useContext, useMemo } from "react";
4
4
  import { styled } from "@elliemae/ds-system";
5
- import AutocompleteContext from "../AutocompleteCTX";
6
- import { getSelectableOptions } from "../utils/listHelper";
5
+ import AutocompleteContext from "../AutocompleteCTX.js";
6
+ import { getSelectableOptions } from "../utils/listHelper.js";
7
7
  const isSeparator = (el) => el?.type === "separator";
8
8
  const StyledA11ySelectedValues = styled.span`
9
9
  width: 1px;
@@ -15,15 +15,15 @@ const A11yFocusedOption = () => {
15
15
  const {
16
16
  props: { options },
17
17
  focusOptionIdx,
18
- showPopover
18
+ isShowingPopover
19
19
  } = useContext(AutocompleteContext);
20
20
  return useMemo(() => {
21
21
  const selectabledOptions = getSelectableOptions(options);
22
22
  const focusOption = options.find((option) => !isSeparator(option) && option.dsId === focusOptionIdx);
23
23
  const focusSelectableOptionIdx = selectabledOptions.findIndex((option) => option.dsId === focusOptionIdx);
24
- return /* @__PURE__ */ jsx(StyledA11ySelectedValues, { "aria-live": "polite", children: !isSeparator(focusOption) && showPopover && focusOption && `option ${focusOption.label} focused.${focusSelectableOptionIdx + 1} of ${selectabledOptions.length}
24
+ return /* @__PURE__ */ jsx(StyledA11ySelectedValues, { "aria-live": "polite", children: !isSeparator(focusOption) && isShowingPopover && focusOption && `option ${focusOption.label} focused.${focusSelectableOptionIdx + 1} of ${selectabledOptions.length}
25
25
  ` });
26
- }, [options, showPopover, focusOptionIdx]);
26
+ }, [options, isShowingPopover, focusOptionIdx]);
27
27
  };
28
28
  export {
29
29
  A11yFocusedOption,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/A11yFocusedOption.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport AutocompleteContext from '../AutocompleteCTX';\nimport { getSelectableOptions } from '../utils/listHelper';\nimport type { DSAutocompleteT } from '../react-desc-prop-types';\nexport const isSeparator = (el: DSAutocompleteT.OptionTypes | undefined): el is DSAutocompleteT.ItemSeparatorOptions =>\n el?.type === 'separator';\n\nexport const StyledA11ySelectedValues = styled.span`\n width: 1px;\n height: 1px;\n position: absolute;\n clip: rect(1px, 1px, 1px, 1px);\n`;\n\nexport const A11yFocusedOption: React.ComponentType = () => {\n const {\n props: { options },\n focusOptionIdx,\n showPopover,\n } = useContext(AutocompleteContext);\n\n return useMemo(() => {\n const selectabledOptions = getSelectableOptions(options);\n const focusOption = options.find((option) => !isSeparator(option) && option.dsId === focusOptionIdx);\n const focusSelectableOptionIdx = selectabledOptions.findIndex((option) => option.dsId === focusOptionIdx);\n\n return (\n <StyledA11ySelectedValues aria-live=\"polite\">\n {!isSeparator(focusOption) &&\n showPopover &&\n focusOption &&\n `option ${focusOption.label} focused.${focusSelectableOptionIdx + 1} of ${selectabledOptions.length}\n `}\n </StyledA11ySelectedValues>\n );\n }, [options, showPopover, focusOptionIdx]);\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;AC4BjB;AA5BN,SAAgB,YAAY,eAAe;AAC3C,SAAS,cAAc;AACvB,OAAO,yBAAyB;AAChC,SAAS,4BAA4B;AAE9B,MAAM,cAAc,CAAC,OAC1B,IAAI,SAAS;AAER,MAAM,2BAA2B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOxC,MAAM,oBAAyC,MAAM;AAC1D,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,SAAO,QAAQ,MAAM;AACnB,UAAM,qBAAqB,qBAAqB,OAAO;AACvD,UAAM,cAAc,QAAQ,KAAK,CAAC,WAAW,CAAC,YAAY,MAAM,KAAK,OAAO,SAAS,cAAc;AACnG,UAAM,2BAA2B,mBAAmB,UAAU,CAAC,WAAW,OAAO,SAAS,cAAc;AAExG,WACE,oBAAC,4BAAyB,aAAU,UACjC,WAAC,YAAY,WAAW,KACvB,eACA,eACA,UAAU,YAAY,iBAAiB,2BAA2B,QAAQ,mBAAmB;AAAA,cAEjG;AAAA,EAEJ,GAAG,CAAC,SAAS,aAAa,cAAc,CAAC;AAC3C;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport AutocompleteContext from '../AutocompleteCTX.js';\nimport { getSelectableOptions } from '../utils/listHelper.js';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nexport const isSeparator = (el: DSAutocompleteT.OptionTypes | undefined): el is DSAutocompleteT.ItemSeparatorOptions =>\n el?.type === 'separator';\n\nexport const StyledA11ySelectedValues = styled.span`\n width: 1px;\n height: 1px;\n position: absolute;\n clip: rect(1px, 1px, 1px, 1px);\n`;\n\nexport const A11yFocusedOption: React.ComponentType = () => {\n const {\n props: { options },\n focusOptionIdx,\n isShowingPopover,\n } = useContext(AutocompleteContext);\n\n return useMemo(() => {\n const selectabledOptions = getSelectableOptions(options);\n const focusOption = options.find((option) => !isSeparator(option) && option.dsId === focusOptionIdx);\n const focusSelectableOptionIdx = selectabledOptions.findIndex((option) => option.dsId === focusOptionIdx);\n\n return (\n <StyledA11ySelectedValues aria-live=\"polite\">\n {!isSeparator(focusOption) &&\n isShowingPopover &&\n focusOption &&\n `option ${focusOption.label} focused.${focusSelectableOptionIdx + 1} of ${selectabledOptions.length}\n `}\n </StyledA11ySelectedValues>\n );\n }, [options, isShowingPopover, focusOptionIdx]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;AC4BjB;AA5BN,SAAgB,YAAY,eAAe;AAC3C,SAAS,cAAc;AACvB,OAAO,yBAAyB;AAChC,SAAS,4BAA4B;AAE9B,MAAM,cAAc,CAAC,OAC1B,IAAI,SAAS;AAER,MAAM,2BAA2B,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAOxC,MAAM,oBAAyC,MAAM;AAC1D,QAAM;AAAA,IACJ,OAAO,EAAE,QAAQ;AAAA,IACjB;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,SAAO,QAAQ,MAAM;AACnB,UAAM,qBAAqB,qBAAqB,OAAO;AACvD,UAAM,cAAc,QAAQ,KAAK,CAAC,WAAW,CAAC,YAAY,MAAM,KAAK,OAAO,SAAS,cAAc;AACnG,UAAM,2BAA2B,mBAAmB,UAAU,CAAC,WAAW,OAAO,SAAS,cAAc;AAExG,WACE,oBAAC,4BAAyB,aAAU,UACjC,WAAC,YAAY,WAAW,KACvB,oBACA,eACA,UAAU,YAAY,iBAAiB,2BAA2B,QAAQ,mBAAmB;AAAA,cAEjG;AAAA,EAEJ,GAAG,CAAC,SAAS,kBAAkB,cAAc,CAAC;AAChD;",
6
6
  "names": []
7
7
  }