@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
@@ -1,38 +1,37 @@
1
1
  import * as React from "react";
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
- import React2, { useCallback, useMemo, useEffect, useContext } from "react";
3
+ import React2, { useCallback, useMemo, useContext } from "react";
4
4
  import { DSPopperJS } from "@elliemae/ds-popperjs";
5
- import AutocompleteContext from "../../AutocompleteCTX";
6
- import { StyledContainer, StyledPopperWrapper } from "./styled";
7
- import { MenuList } from "../menu-list";
8
- import { useKeyboardNavigation } from "./useKeyboardNavigation";
9
- import { AutocompleteDataTestid } from "../../AutocompleteDataTestids";
10
- import { A11yFocusedOption } from "../A11yFocusedOption";
5
+ import AutocompleteContext from "../../AutocompleteCTX.js";
6
+ import { StyledContainer, StyledPopperWrapper } from "./styled.js";
7
+ import { MenuList } from "../menu-list/index.js";
8
+ import { useKeyboardNavigation } from "./useKeyboardNavigation.js";
9
+ import { AutocompleteDataTestid } from "../../AutocompleteDataTestids.js";
10
+ import { A11yFocusedOption } from "../A11yFocusedOption.js";
11
11
  const Container = () => {
12
12
  const {
13
13
  props: { id, startPlacementPreference, children, filter, placementOrderPreference },
14
- showPopover,
14
+ isShowingPopover,
15
15
  setReferenceElement,
16
- setShowPopover,
17
- focusOptionIdx,
16
+ setUserJustSelectedAnOption,
17
+ setUserTypedSomething,
18
+ setUserIsNavigatingWithArrows,
19
+ setForceClosePopover,
20
+ autoCompleteId,
18
21
  referenceElement
19
22
  } = useContext(AutocompleteContext);
20
- useEffect(() => {
21
- const closePopper = () => {
22
- setShowPopover(false);
23
- };
24
- window.addEventListener("blur", closePopper);
25
- return () => {
26
- window.removeEventListener("blur", closePopper);
27
- };
28
- }, [setShowPopover]);
29
23
  const handleCloseMenu = useCallback(() => {
30
- setShowPopover(false);
31
- }, [setShowPopover]);
24
+ setForceClosePopover(true);
25
+ }, [setForceClosePopover]);
32
26
  const { onInputKeyDown } = useKeyboardNavigation();
33
27
  const input = React2.Children.only(children);
34
- const childrenWithProps = React2.isValidElement(input) ? React2.cloneElement(input, { "aria-activedescendant": focusOptionIdx }) : input;
35
28
  const idList = useMemo(() => `${id ? `${id}-` : ""}listbox`, [id]);
29
+ const onFocusPopoverStatusSync = useCallback(() => {
30
+ setForceClosePopover(false);
31
+ setUserJustSelectedAnOption(false);
32
+ setUserTypedSomething(false);
33
+ setUserIsNavigatingWithArrows(false);
34
+ }, [setForceClosePopover, setUserIsNavigatingWithArrows, setUserJustSelectedAnOption, setUserTypedSomething]);
36
35
  return /* @__PURE__ */ jsxs(Fragment, { children: [
37
36
  /* @__PURE__ */ jsx(A11yFocusedOption, {}),
38
37
  /* @__PURE__ */ jsxs(
@@ -42,21 +41,22 @@ const Container = () => {
42
41
  ref: setReferenceElement,
43
42
  role: "combobox",
44
43
  "aria-autocomplete": "list",
45
- "aria-controls": "autocomplete-listbox",
46
- "aria-expanded": showPopover,
44
+ "aria-controls": `menu-list-${autoCompleteId}`,
45
+ "aria-expanded": isShowingPopover,
47
46
  "aria-haspopup": "listbox",
48
47
  "aria-owns": idList,
49
48
  onKeyDown: onInputKeyDown,
49
+ onFocus: onFocusPopoverStatusSync,
50
50
  "data-testid": AutocompleteDataTestid.CONTAINER,
51
51
  children: [
52
- childrenWithProps,
52
+ input,
53
53
  filter && /* @__PURE__ */ jsx(
54
54
  DSPopperJS,
55
55
  {
56
56
  customOffset: [0, 5],
57
57
  closeContextMenu: handleCloseMenu,
58
58
  referenceElement,
59
- showPopover,
59
+ showPopover: isShowingPopover,
60
60
  startPlacementPreference,
61
61
  placementOrderPreference,
62
62
  withoutPortal: true,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/container/Container.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useCallback, useMemo, useEffect, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport AutocompleteContext from '../../AutocompleteCTX';\nimport { StyledContainer, StyledPopperWrapper } from './styled';\nimport { MenuList } from '../menu-list';\nimport { useKeyboardNavigation } from './useKeyboardNavigation';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids';\nimport { A11yFocusedOption } from '../A11yFocusedOption';\nexport const Container = (): JSX.Element => {\n const {\n props: { id, startPlacementPreference, children, filter, placementOrderPreference },\n showPopover,\n setReferenceElement,\n setShowPopover,\n focusOptionIdx,\n referenceElement,\n } = useContext(AutocompleteContext);\n\n useEffect(() => {\n const closePopper = () => {\n setShowPopover(false);\n };\n window.addEventListener('blur', closePopper);\n\n return () => {\n window.removeEventListener('blur', closePopper);\n };\n }, [setShowPopover]);\n\n const handleCloseMenu = useCallback(() => {\n setShowPopover(false);\n }, [setShowPopover]);\n\n const { onInputKeyDown } = useKeyboardNavigation();\n\n const input = React.Children.only(children);\n\n const childrenWithProps = React.isValidElement(input)\n ? React.cloneElement(input, { 'aria-activedescendant': focusOptionIdx })\n : input;\n\n const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);\n\n return (\n <>\n <A11yFocusedOption />\n\n <StyledContainer\n id={id}\n ref={setReferenceElement}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls=\"autocomplete-listbox\"\n aria-expanded={showPopover}\n aria-haspopup=\"listbox\"\n aria-owns={idList}\n onKeyDown={onInputKeyDown}\n data-testid={AutocompleteDataTestid.CONTAINER}\n >\n {childrenWithProps}\n {filter && (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={showPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal\n withoutArrow\n withoutAnimation\n zIndex={10}\n >\n <StyledPopperWrapper tabIndex={-1}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n )}\n </StyledContainer>\n </>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;AC6CnB,mBACE,KAEA,YAHF;AA5CJ,OAAOA,UAAS,aAAa,SAAS,WAAW,kBAAkB;AACnE,SAAS,kBAAkB;AAC3B,OAAO,yBAAyB;AAChC,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAC3B,MAAM,YAAY,MAAmB;AAC1C,QAAM;AAAA,IACJ,OAAO,EAAE,IAAI,0BAA0B,UAAU,QAAQ,yBAAyB;AAAA,IAClF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,YAAU,MAAM;AACd,UAAM,cAAc,MAAM;AACxB,qBAAe,KAAK;AAAA,IACtB;AACA,WAAO,iBAAiB,QAAQ,WAAW;AAE3C,WAAO,MAAM;AACX,aAAO,oBAAoB,QAAQ,WAAW;AAAA,IAChD;AAAA,EACF,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,kBAAkB,YAAY,MAAM;AACxC,mBAAe,KAAK;AAAA,EACtB,GAAG,CAAC,cAAc,CAAC;AAEnB,QAAM,EAAE,eAAe,IAAI,sBAAsB;AAEjD,QAAM,QAAQA,OAAM,SAAS,KAAK,QAAQ;AAE1C,QAAM,oBAAoBA,OAAM,eAAe,KAAK,IAChDA,OAAM,aAAa,OAAO,EAAE,yBAAyB,eAAe,CAAC,IACrE;AAEJ,QAAM,SAAS,QAAQ,MAAM,GAAG,KAAK,GAAG,QAAQ,aAAa,CAAC,EAAE,CAAC;AAEjE,SACE,iCACE;AAAA,wBAAC,qBAAkB;AAAA,IAEnB;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,KAAK;AAAA,QACL,MAAK;AAAA,QACL,qBAAkB;AAAA,QAClB,iBAAc;AAAA,QACd,iBAAe;AAAA,QACf,iBAAc;AAAA,QACd,aAAW;AAAA,QACX,WAAW;AAAA,QACX,eAAa,uBAAuB;AAAA,QAEnC;AAAA;AAAA,UACA,UACC;AAAA,YAAC;AAAA;AAAA,cACC,cAAc,CAAC,GAAG,CAAC;AAAA,cACnB,kBAAkB;AAAA,cAClB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA,eAAa;AAAA,cACb,cAAY;AAAA,cACZ,kBAAgB;AAAA,cAChB,QAAQ;AAAA,cAER,8BAAC,uBAAoB,UAAU,IAC7B,8BAAC,YAAS,GACZ;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport React, { useCallback, useMemo, useContext } from 'react';\nimport { DSPopperJS } from '@elliemae/ds-popperjs';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { StyledContainer, StyledPopperWrapper } from './styled.js';\nimport { MenuList } from '../menu-list/index.js';\nimport { useKeyboardNavigation } from './useKeyboardNavigation.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport { A11yFocusedOption } from '../A11yFocusedOption.js';\nexport const Container = (): JSX.Element => {\n const {\n props: { id, startPlacementPreference, children, filter, placementOrderPreference },\n isShowingPopover,\n setReferenceElement,\n setUserJustSelectedAnOption,\n setUserTypedSomething,\n setUserIsNavigatingWithArrows,\n setForceClosePopover,\n autoCompleteId,\n referenceElement,\n } = useContext(AutocompleteContext);\n\n const handleCloseMenu = useCallback(() => {\n setForceClosePopover(true);\n }, [setForceClosePopover]);\n\n const { onInputKeyDown } = useKeyboardNavigation();\n\n const input = React.Children.only(children);\n\n const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);\n\n const onFocusPopoverStatusSync = useCallback(() => {\n setForceClosePopover(false);\n setUserJustSelectedAnOption(false);\n setUserTypedSomething(false);\n setUserIsNavigatingWithArrows(false);\n }, [setForceClosePopover, setUserIsNavigatingWithArrows, setUserJustSelectedAnOption, setUserTypedSomething]);\n\n return (\n <>\n <A11yFocusedOption />\n\n <StyledContainer\n id={id}\n ref={setReferenceElement}\n role=\"combobox\"\n aria-autocomplete=\"list\"\n aria-controls={`menu-list-${autoCompleteId}`}\n aria-expanded={isShowingPopover}\n aria-haspopup=\"listbox\"\n aria-owns={idList}\n onKeyDown={onInputKeyDown}\n onFocus={onFocusPopoverStatusSync}\n data-testid={AutocompleteDataTestid.CONTAINER}\n >\n {input}\n {filter && (\n <DSPopperJS\n customOffset={[0, 5]}\n closeContextMenu={handleCloseMenu}\n referenceElement={referenceElement}\n showPopover={isShowingPopover}\n startPlacementPreference={startPlacementPreference}\n placementOrderPreference={placementOrderPreference}\n withoutPortal\n withoutArrow\n withoutAnimation\n zIndex={10}\n >\n <StyledPopperWrapper tabIndex={-1}>\n <MenuList />\n </StyledPopperWrapper>\n </DSPopperJS>\n )}\n </StyledContainer>\n </>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACwCnB,mBACE,KAEA,YAHF;AAvCJ,OAAOA,UAAS,aAAa,SAAS,kBAAkB;AACxD,SAAS,kBAAkB;AAC3B,OAAO,yBAAyB;AAChC,SAAS,iBAAiB,2BAA2B;AACrD,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAC3B,MAAM,YAAY,MAAmB;AAC1C,QAAM;AAAA,IACJ,OAAO,EAAE,IAAI,0BAA0B,UAAU,QAAQ,yBAAyB;AAAA,IAClF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,QAAM,kBAAkB,YAAY,MAAM;AACxC,yBAAqB,IAAI;AAAA,EAC3B,GAAG,CAAC,oBAAoB,CAAC;AAEzB,QAAM,EAAE,eAAe,IAAI,sBAAsB;AAEjD,QAAM,QAAQA,OAAM,SAAS,KAAK,QAAQ;AAE1C,QAAM,SAAS,QAAQ,MAAM,GAAG,KAAK,GAAG,QAAQ,aAAa,CAAC,EAAE,CAAC;AAEjE,QAAM,2BAA2B,YAAY,MAAM;AACjD,yBAAqB,KAAK;AAC1B,gCAA4B,KAAK;AACjC,0BAAsB,KAAK;AAC3B,kCAA8B,KAAK;AAAA,EACrC,GAAG,CAAC,sBAAsB,+BAA+B,6BAA6B,qBAAqB,CAAC;AAE5G,SACE,iCACE;AAAA,wBAAC,qBAAkB;AAAA,IAEnB;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,KAAK;AAAA,QACL,MAAK;AAAA,QACL,qBAAkB;AAAA,QAClB,iBAAe,aAAa;AAAA,QAC5B,iBAAe;AAAA,QACf,iBAAc;AAAA,QACd,aAAW;AAAA,QACX,WAAW;AAAA,QACX,SAAS;AAAA,QACT,eAAa,uBAAuB;AAAA,QAEnC;AAAA;AAAA,UACA,UACC;AAAA,YAAC;AAAA;AAAA,cACC,cAAc,CAAC,GAAG,CAAC;AAAA,cACnB,kBAAkB;AAAA,cAClB;AAAA,cACA,aAAa;AAAA,cACb;AAAA,cACA;AAAA,cACA,eAAa;AAAA,cACb,cAAY;AAAA,cACZ,kBAAgB;AAAA,cAChB,QAAQ;AAAA,cAER,8BAAC,uBAAoB,UAAU,IAC7B,8BAAC,YAAS,GACZ;AAAA;AAAA,UACF;AAAA;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { Container } from "./Container";
2
+ import { Container } from "./Container.js";
3
3
  export {
4
4
  Container
5
5
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/container/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { Container } from './Container';\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { Container } from './Container.js';\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,iBAAiB;",
6
6
  "names": []
7
7
  }
@@ -1,13 +1,14 @@
1
1
  import * as React from "react";
2
2
  import { useCallback, useContext } from "react";
3
- import AutocompleteContext from "../../AutocompleteCTX";
4
- import { findInCircularList } from "../../utils/listHelper";
3
+ import AutocompleteContext from "../../AutocompleteCTX.js";
4
+ import { findInCircularList } from "../../utils/listHelper.js";
5
5
  const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
6
6
  const useKeyboardNavigation = () => {
7
7
  const {
8
8
  props: { onSelect, options },
9
- setShowPopover,
10
- showPopover,
9
+ trackUserInteractingViaKeyboard,
10
+ setForceClosePopover,
11
+ isShowingPopover,
11
12
  focusOptionIdx,
12
13
  setCurrentOption,
13
14
  scrollOptionIntoView
@@ -18,18 +19,16 @@ const useKeyboardNavigation = () => {
18
19
  );
19
20
  const onInputKeyDown = useCallback(
20
21
  (e) => {
21
- if ((e.keyCode >= 48 && e.keyCode <= 90 || e.key === "Backspace") && !showPopover) {
22
- setShowPopover(true);
23
- } else if (e.key === "Tab")
24
- setShowPopover(false);
25
- if (e.key === "Enter" && showPopover) {
22
+ trackUserInteractingViaKeyboard(e);
23
+ if (e.key === "Tab" || e.key === "Escape")
24
+ setForceClosePopover(true);
25
+ if (e.key === "Enter" && isShowingPopover) {
26
26
  e.preventDefault();
27
27
  onSelect(currentItem?.label, e);
28
- setShowPopover(false);
29
28
  }
30
29
  if (e.key === "ArrowDown") {
31
30
  e.preventDefault();
32
- if (showPopover) {
31
+ if (isShowingPopover) {
33
32
  const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);
34
33
  setCurrentOption(options[nextItemIndex].dsId);
35
34
  scrollOptionIntoView(options[nextItemIndex].dsId);
@@ -37,25 +36,23 @@ const useKeyboardNavigation = () => {
37
36
  }
38
37
  if (e.key === "ArrowUp") {
39
38
  e.preventDefault();
40
- if (showPopover) {
39
+ if (isShowingPopover) {
41
40
  const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);
42
41
  setCurrentOption(options[nextItemIndex].dsId);
43
42
  scrollOptionIntoView(options[nextItemIndex].dsId);
44
43
  }
45
44
  }
46
- if (e.key === "Escape") {
47
- setShowPopover(false);
48
- }
49
45
  },
50
46
  [
51
- currentItem?.label,
52
- currentItemIndex,
47
+ trackUserInteractingViaKeyboard,
48
+ setForceClosePopover,
49
+ isShowingPopover,
53
50
  onSelect,
51
+ currentItem?.label,
54
52
  options,
55
- scrollOptionIntoView,
53
+ currentItemIndex,
56
54
  setCurrentOption,
57
- setShowPopover,
58
- showPopover
55
+ scrollOptionIntoView
59
56
  ]
60
57
  );
61
58
  return { onInputKeyDown };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/container/useKeyboardNavigation.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types';\nimport AutocompleteContext from '../../AutocompleteCTX';\nimport { findInCircularList } from '../../utils/listHelper';\n\nconst isOptionFocuseable = (opt: DSAutocompleteT.OptionTypes): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { onSelect, options },\n setShowPopover,\n showPopover,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(AutocompleteContext);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find(\n (item) => item.type === 'option' && item.dsId === focusOptionIdx,\n ) as DSAutocompleteT.ItemOption;\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n if (((e.keyCode >= 48 && e.keyCode <= 90) || e.key === 'Backspace') && !showPopover) {\n setShowPopover(true);\n } else if (e.key === 'Tab') setShowPopover(false);\n\n // =============================================================================\n // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER\n // =============================================================================\n if (e.key === 'Enter' && showPopover) {\n e.preventDefault();\n onSelect(currentItem?.label, e);\n setShowPopover(false);\n }\n\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (showPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (showPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n // =============================================================================\n // ESCAPE\n // =============================================================================\n if (e.key === 'Escape') {\n setShowPopover(false);\n }\n },\n [\n currentItem?.label,\n currentItemIndex,\n onSelect,\n options,\n scrollOptionIntoView,\n setCurrentOption,\n setShowPopover,\n showPopover,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACKvB,SAAS,aAAa,kBAAkB;AAExC,OAAO,yBAAyB;AAChC,SAAS,0BAA0B;AAEnC,MAAM,qBAAqB,CAAC,QAA8C,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI;AAE9G,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,UAAU,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,QAAM,mBAAmB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS,cAAc;AAC/E,QAAM,cAAc,QAAQ;AAAA,IAC1B,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS;AAAA,EACpD;AAEA,QAAM,iBAA+D;AAAA,IACnE,CAAC,MAAM;AACL,WAAM,EAAE,WAAW,MAAM,EAAE,WAAW,MAAO,EAAE,QAAQ,gBAAgB,CAAC,aAAa;AACnF,uBAAe,IAAI;AAAA,MACrB,WAAW,EAAE,QAAQ;AAAO,uBAAe,KAAK;AAKhD,UAAI,EAAE,QAAQ,WAAW,aAAa;AACpC,UAAE,eAAe;AACjB,iBAAS,aAAa,OAAO,CAAC;AAC9B,uBAAe,KAAK;AAAA,MACtB;AAKA,UAAI,EAAE,QAAQ,aAAa;AACzB,UAAE,eAAe;AACjB,YAAI,aAAa;AACf,gBAAM,gBAAgB,mBAAmB,SAAS,kBAAkB,kBAAkB;AACtF,2BAAiB,QAAQ,eAAe,IAAI;AAC5C,+BAAqB,QAAQ,eAAe,IAAI;AAAA,QAClD;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,WAAW;AACvB,UAAE,eAAe;AACjB,YAAI,aAAa;AACf,gBAAM,gBAAgB,mBAAmB,SAAS,kBAAkB,oBAAoB,EAAE;AAC1F,2BAAiB,QAAQ,eAAe,IAAI;AAC5C,+BAAqB,QAAQ,eAAe,IAAI;AAAA,QAClD;AAAA,MACF;AAIA,UAAI,EAAE,QAAQ,UAAU;AACtB,uBAAe,KAAK;AAAA,MACtB;AAAA,IACF;AAAA,IACA;AAAA,MACE,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { findInCircularList } from '../../utils/listHelper.js';\n\nconst isOptionFocuseable = (opt: DSAutocompleteT.OptionTypes): boolean => !['section', 'separator'].includes(opt.type);\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { onSelect, options },\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(AutocompleteContext);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find(\n (item) => item.type === 'option' && item.dsId === focusOptionIdx,\n ) as DSAutocompleteT.ItemOption;\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // =============================================================================\n // TRACK STATE OF POPOVER SHOWING OR NOT\n // =============================================================================\n trackUserInteractingViaKeyboard(e);\n\n if (e.key === 'Tab' || e.key === 'Escape') setForceClosePopover(true);\n\n // =============================================================================\n // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER\n // =============================================================================\n if (e.key === 'Enter' && isShowingPopover) {\n e.preventDefault();\n onSelect(currentItem?.label, e);\n }\n\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n },\n [\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n onSelect,\n currentItem?.label,\n options,\n currentItemIndex,\n setCurrentOption,\n scrollOptionIntoView,\n ],\n );\n\n return { onInputKeyDown };\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACKvB,SAAS,aAAa,kBAAkB;AAExC,OAAO,yBAAyB;AAChC,SAAS,0BAA0B;AAEnC,MAAM,qBAAqB,CAAC,QAA8C,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI;AAE9G,MAAM,wBAAwB,MAAM;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,UAAU,QAAQ;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,QAAM,mBAAmB,QAAQ,UAAU,CAAC,QAAQ,IAAI,SAAS,cAAc;AAC/E,QAAM,cAAc,QAAQ;AAAA,IAC1B,CAAC,SAAS,KAAK,SAAS,YAAY,KAAK,SAAS;AAAA,EACpD;AAEA,QAAM,iBAA+D;AAAA,IACnE,CAAC,MAAM;AAIL,sCAAgC,CAAC;AAEjC,UAAI,EAAE,QAAQ,SAAS,EAAE,QAAQ;AAAU,6BAAqB,IAAI;AAKpE,UAAI,EAAE,QAAQ,WAAW,kBAAkB;AACzC,UAAE,eAAe;AACjB,iBAAS,aAAa,OAAO,CAAC;AAAA,MAChC;AAKA,UAAI,EAAE,QAAQ,aAAa;AACzB,UAAE,eAAe;AACjB,YAAI,kBAAkB;AACpB,gBAAM,gBAAgB,mBAAmB,SAAS,kBAAkB,kBAAkB;AACtF,2BAAiB,QAAQ,aAAa,EAAE,IAAI;AAC5C,+BAAqB,QAAQ,aAAa,EAAE,IAAI;AAAA,QAClD;AAAA,MACF;AACA,UAAI,EAAE,QAAQ,WAAW;AACvB,UAAE,eAAe;AACjB,YAAI,kBAAkB;AACpB,gBAAM,gBAAgB,mBAAmB,SAAS,kBAAkB,oBAAoB,EAAE;AAC1F,2BAAiB,QAAQ,aAAa,EAAE,IAAI;AAC5C,+BAAqB,QAAQ,aAAa,EAAE,IAAI;AAAA,QAClD;AAAA,MACF;AAAA,IACF;AAAA,IACA;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,aAAa;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
6
6
  "names": []
7
7
  }
@@ -1,17 +1,18 @@
1
1
  import * as React from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { useContext, useMemo, useCallback } from "react";
4
- import { StyledListWrapper, StyledList, StyledVirtualListWrapper } from "./styled";
5
- import { AutocompleteDataTestid } from "../../AutocompleteDataTestids";
6
- import AutocompleteContext from "../../AutocompleteCTX";
7
- import { useItemRenderer } from "./useItemRenderer";
4
+ import { StyledListWrapper, StyledList, StyledVirtualListWrapper } from "./styled.js";
5
+ import { AutocompleteDataTestid } from "../../AutocompleteDataTestids.js";
6
+ import AutocompleteContext from "../../AutocompleteCTX.js";
7
+ import { useItemRenderer } from "./useItemRenderer.js";
8
8
  const MenuList = () => {
9
9
  const {
10
10
  props: { options, id },
11
11
  referenceElement,
12
12
  inputRef,
13
13
  listRef,
14
- showPopover,
14
+ autoCompleteId,
15
+ isShowingPopover,
15
16
  virtualListHelpers: { totalSize }
16
17
  } = useContext(AutocompleteContext);
17
18
  const ItemRenderer = useItemRenderer();
@@ -19,27 +20,22 @@ const MenuList = () => {
19
20
  inputRef.current?.focus();
20
21
  }, [inputRef]);
21
22
  const idList = useMemo(() => `${id ? `${id}-` : ""}listbox`, [id]);
22
- return /* @__PURE__ */ jsx(
23
- StyledListWrapper,
23
+ const preventMouseDown = useCallback((e) => {
24
+ e.preventDefault();
25
+ }, []);
26
+ return /* @__PURE__ */ jsx(StyledListWrapper, { onMouseDown: preventMouseDown, minWidth: referenceElement?.offsetWidth, id: idList, children: options.length > 0 && /* @__PURE__ */ jsx(StyledVirtualListWrapper, { tabIndex: -1, ref: listRef, children: /* @__PURE__ */ jsx(
27
+ StyledList,
24
28
  {
25
- tabIndex: -1,
26
- onMouseDown: (e) => e.preventDefault(),
27
- minWidth: referenceElement?.offsetWidth,
28
- id: idList,
29
29
  role: "listbox",
30
- children: options.length > 0 && /* @__PURE__ */ jsx(StyledVirtualListWrapper, { tabIndex: -1, ref: listRef, children: /* @__PURE__ */ jsx(
31
- StyledList,
32
- {
33
- tabIndex: -1,
34
- "aria-expanded": showPopover,
35
- onFocus: handleOnFocus,
36
- "data-testid": AutocompleteDataTestid.LIST,
37
- style: { height: totalSize, margin: "8px 0px" },
38
- children: ItemRenderer
39
- }
40
- ) })
30
+ id: `menu-list-${autoCompleteId}`,
31
+ "aria-label": "autocomplete option lists",
32
+ "aria-expanded": isShowingPopover,
33
+ onFocus: handleOnFocus,
34
+ "data-testid": AutocompleteDataTestid.LIST,
35
+ style: { height: totalSize, margin: "8px 0px" },
36
+ children: ItemRenderer
41
37
  }
42
- );
38
+ ) }) });
43
39
  };
44
40
  export {
45
41
  MenuList
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/menu-list/MenuList.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useCallback } from 'react';\nimport { StyledListWrapper, StyledList, StyledVirtualListWrapper } from './styled';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids';\nimport AutocompleteContext from '../../AutocompleteCTX';\nimport { useItemRenderer } from './useItemRenderer';\nimport { A11yFocusedOption } from '../A11yFocusedOption';\n\nexport const MenuList = (): JSX.Element => {\n const {\n props: { options, id },\n referenceElement,\n inputRef,\n listRef,\n showPopover,\n virtualListHelpers: { totalSize },\n } = useContext(AutocompleteContext);\n\n const ItemRenderer = useItemRenderer();\n\n const handleOnFocus = useCallback(() => {\n inputRef.current?.focus();\n }, [inputRef]);\n\n const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);\n return (\n <StyledListWrapper\n tabIndex={-1}\n onMouseDown={(e) => e.preventDefault()}\n minWidth={referenceElement?.offsetWidth}\n id={idList}\n role=\"listbox\"\n >\n {options.length > 0 && (\n <StyledVirtualListWrapper tabIndex={-1} ref={listRef}>\n <StyledList\n tabIndex={-1}\n aria-expanded={showPopover}\n onFocus={handleOnFocus}\n data-testid={AutocompleteDataTestid.LIST}\n style={{ height: totalSize, margin: '8px 0px' }}\n >\n {ItemRenderer}\n </StyledList>\n </StyledVirtualListWrapper>\n )}\n </StyledListWrapper>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACkCb;AAlCV,SAAgB,YAAY,SAAS,mBAAmB;AACxD,SAAS,mBAAmB,YAAY,gCAAgC;AACxE,SAAS,8BAA8B;AACvC,OAAO,yBAAyB;AAChC,SAAS,uBAAuB;AAGzB,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,GAAG;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE,UAAU;AAAA,EAClC,IAAI,WAAW,mBAAmB;AAElC,QAAM,eAAe,gBAAgB;AAErC,QAAM,gBAAgB,YAAY,MAAM;AACtC,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,SAAS,QAAQ,MAAM,GAAG,KAAK,GAAG,QAAQ,aAAa,CAAC,EAAE,CAAC;AACjE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,UAAU;AAAA,MACV,aAAa,CAAC,MAAM,EAAE,eAAe;AAAA,MACrC,UAAU,kBAAkB;AAAA,MAC5B,IAAI;AAAA,MACJ,MAAK;AAAA,MAEJ,kBAAQ,SAAS,KAChB,oBAAC,4BAAyB,UAAU,IAAI,KAAK,SAC3C;AAAA,QAAC;AAAA;AAAA,UACC,UAAU;AAAA,UACV,iBAAe;AAAA,UACf,SAAS;AAAA,UACT,eAAa,uBAAuB;AAAA,UACpC,OAAO,EAAE,QAAQ,WAAW,QAAQ,UAAU;AAAA,UAE7C;AAAA;AAAA,MACH,GACF;AAAA;AAAA,EAEJ;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useMemo, useCallback } from 'react';\nimport { StyledListWrapper, StyledList, StyledVirtualListWrapper } from './styled.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { useItemRenderer } from './useItemRenderer.js';\n\nexport const MenuList = (): JSX.Element => {\n const {\n props: { options, id },\n referenceElement,\n inputRef,\n listRef,\n autoCompleteId,\n isShowingPopover,\n virtualListHelpers: { totalSize },\n } = useContext(AutocompleteContext);\n\n const ItemRenderer = useItemRenderer();\n\n const handleOnFocus = useCallback(() => {\n inputRef.current?.focus();\n }, [inputRef]);\n\n const idList = useMemo(() => `${id ? `${id}-` : ''}listbox`, [id]);\n const preventMouseDown: React.MouseEventHandler<HTMLDivElement> = useCallback((e) => {\n e.preventDefault();\n }, []);\n\n return (\n <StyledListWrapper onMouseDown={preventMouseDown} minWidth={referenceElement?.offsetWidth} id={idList}>\n {options.length > 0 && (\n <StyledVirtualListWrapper tabIndex={-1} ref={listRef}>\n <StyledList\n role=\"listbox\"\n id={`menu-list-${autoCompleteId}`}\n // default aria label until we integrate the aria props on autocomplete\n // this is for the axe core to pass\n aria-label=\"autocomplete option lists\"\n aria-expanded={isShowingPopover}\n onFocus={handleOnFocus}\n data-testid={AutocompleteDataTestid.LIST}\n style={{ height: totalSize, margin: '8px 0px' }}\n >\n {ItemRenderer}\n </StyledList>\n </StyledVirtualListWrapper>\n )}\n </StyledListWrapper>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACgCb;AAhCV,SAAgB,YAAY,SAAS,mBAAmB;AACxD,SAAS,mBAAmB,YAAY,gCAAgC;AACxE,SAAS,8BAA8B;AACvC,OAAO,yBAAyB;AAChC,SAAS,uBAAuB;AAEzB,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,GAAG;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE,UAAU;AAAA,EAClC,IAAI,WAAW,mBAAmB;AAElC,QAAM,eAAe,gBAAgB;AAErC,QAAM,gBAAgB,YAAY,MAAM;AACtC,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,SAAS,QAAQ,MAAM,GAAG,KAAK,GAAG,QAAQ,aAAa,CAAC,EAAE,CAAC;AACjE,QAAM,mBAA4D,YAAY,CAAC,MAAM;AACnF,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,SACE,oBAAC,qBAAkB,aAAa,kBAAkB,UAAU,kBAAkB,aAAa,IAAI,QAC5F,kBAAQ,SAAS,KAChB,oBAAC,4BAAyB,UAAU,IAAI,KAAK,SAC3C;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,IAAI,aAAa;AAAA,MAGjB,cAAW;AAAA,MACX,iBAAe;AAAA,MACf,SAAS;AAAA,MACT,eAAa,uBAAuB;AAAA,MACpC,OAAO,EAAE,QAAQ,WAAW,QAAQ,UAAU;AAAA,MAE7C;AAAA;AAAA,EACH,GACF,GAEJ;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { MenuList } from "./MenuList";
2
+ import { MenuList } from "./MenuList.js";
3
3
  export {
4
4
  MenuList
5
5
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/menu-list/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { MenuList } from './MenuList';\n"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { MenuList } from './MenuList.js';\n"],
5
5
  "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,gBAAgB;",
6
6
  "names": []
7
7
  }
@@ -2,24 +2,26 @@ import * as React from "react";
2
2
  import { Fragment, jsx } from "react/jsx-runtime";
3
3
  import { useMemo, useContext, useCallback } from "react";
4
4
  import { SingleMenuItem, Section } from "@elliemae/ds-menu-items";
5
- import AutocompleteContext from "../../AutocompleteCTX";
6
- import { AutocompleteDataTestid } from "../../AutocompleteDataTestids";
5
+ import AutocompleteContext from "../../AutocompleteCTX.js";
6
+ import { AutocompleteDataTestid } from "../../AutocompleteDataTestids.js";
7
7
  const useItemRenderer = () => {
8
8
  const {
9
9
  props: { options, onSelect },
10
10
  inputRef,
11
- setShowPopover,
11
+ setUserTypedSomething,
12
+ setUserJustSelectedAnOption,
12
13
  focusOptionIdx,
13
14
  virtualListHelpers
14
15
  } = useContext(AutocompleteContext);
15
16
  const handleClick = useCallback(
16
17
  (option, e) => {
17
18
  onSelect(option.label, e);
18
- setShowPopover(false);
19
+ setUserJustSelectedAnOption(true);
20
+ setUserTypedSomething(false);
19
21
  e.stopPropagation();
20
22
  e.preventDefault();
21
23
  },
22
- [onSelect, setShowPopover]
24
+ [onSelect, setUserTypedSomething, setUserJustSelectedAnOption]
23
25
  );
24
26
  return useMemo(() => {
25
27
  if (virtualListHelpers) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/menu-list/useItemRenderer.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { SingleMenuItem, Section } from '@elliemae/ds-menu-items';\nimport AutocompleteContext from '../../AutocompleteCTX';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types';\n\nexport const useItemRenderer = (): Array<JSX.Element> | null => {\n const {\n props: { options, onSelect },\n inputRef,\n setShowPopover,\n focusOptionIdx,\n virtualListHelpers,\n } = useContext(AutocompleteContext);\n\n const handleClick = useCallback(\n (option: DSAutocompleteT.ItemOption, e: React.ChangeEvent<HTMLInputElement>) => {\n onSelect(option.label, e);\n setShowPopover(false);\n e.stopPropagation();\n e.preventDefault();\n },\n [onSelect, setShowPopover],\n );\n\n return useMemo(() => {\n if (virtualListHelpers) {\n return virtualListHelpers.virtualItems.map((vItem) => {\n const option = options[vItem.index];\n const generalProps = {\n wrapperStyles: { position: 'absolute', top: vItem.start, left: 0, width: '100%' },\n key: `${option.dsId}`,\n innerRef: vItem.measureRef,\n };\n if (option.type === 'section') {\n return <Section label={option.label} {...generalProps} />;\n }\n if (option.type === 'option') {\n return (\n <SingleMenuItem\n {...generalProps}\n value={option.value}\n label={option.label}\n dataTestid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n onClick={(e: React.ChangeEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n />\n );\n }\n return <></>;\n });\n }\n return null;\n }, [options, focusOptionIdx, inputRef, virtualListHelpers]);\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACoCN,SAeF,UAfE;AAnCjB,SAAgB,SAAS,YAAY,mBAAmB;AACxD,SAAS,gBAAgB,eAAe;AACxC,OAAO,yBAAyB;AAChC,SAAS,8BAA8B;AAGhC,MAAM,kBAAkB,MAAiC;AAC9D,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,SAAS;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,QAAM,cAAc;AAAA,IAClB,CAAC,QAAoC,MAA2C;AAC9E,eAAS,OAAO,OAAO,CAAC;AACxB,qBAAe,KAAK;AACpB,QAAE,gBAAgB;AAClB,QAAE,eAAe;AAAA,IACnB;AAAA,IACA,CAAC,UAAU,cAAc;AAAA,EAC3B;AAEA,SAAO,QAAQ,MAAM;AACnB,QAAI,oBAAoB;AACtB,aAAO,mBAAmB,aAAa,IAAI,CAAC,UAAU;AACpD,cAAM,SAAS,QAAQ,MAAM;AAC7B,cAAM,eAAe;AAAA,UACnB,eAAe,EAAE,UAAU,YAAY,KAAK,MAAM,OAAO,MAAM,GAAG,OAAO,OAAO;AAAA,UAChF,KAAK,GAAG,OAAO;AAAA,UACf,UAAU,MAAM;AAAA,QAClB;AACA,YAAI,OAAO,SAAS,WAAW;AAC7B,iBAAO,oBAAC,WAAQ,OAAO,OAAO,OAAQ,GAAG,cAAc;AAAA,QACzD;AACA,YAAI,OAAO,SAAS,UAAU;AAC5B,iBACE;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,OAAO,OAAO;AAAA,cACd,YAAY,uBAAuB;AAAA,cACnC,UAAU,OAAO;AAAA,cACjB,SAAS,CAAC,MAA2C,YAAY,QAAQ,CAAC;AAAA,cAC1E,UAAU,OAAO,SAAS;AAAA;AAAA,UAC5B;AAAA,QAEJ;AACA,eAAO,gCAAE;AAAA,MACX,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT,GAAG,CAAC,SAAS,gBAAgB,UAAU,kBAAkB,CAAC;AAC5D;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { SingleMenuItem, Section } from '@elliemae/ds-menu-items';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\n\nexport const useItemRenderer = (): Array<JSX.Element> | null => {\n const {\n props: { options, onSelect },\n inputRef,\n setUserTypedSomething,\n setUserJustSelectedAnOption,\n focusOptionIdx,\n virtualListHelpers,\n } = useContext(AutocompleteContext);\n\n const handleClick = useCallback(\n (option: DSAutocompleteT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => {\n onSelect(option.label, e);\n setUserJustSelectedAnOption(true);\n setUserTypedSomething(false);\n e.stopPropagation();\n e.preventDefault();\n },\n [onSelect, setUserTypedSomething, setUserJustSelectedAnOption],\n );\n\n return useMemo(() => {\n if (virtualListHelpers) {\n return virtualListHelpers.virtualItems.map((vItem) => {\n const option = options[vItem.index];\n const generalProps = {\n wrapperStyles: { position: 'absolute', top: vItem.start, left: 0, width: '100%' },\n key: `${option.dsId}`,\n innerRef: vItem.measureRef,\n };\n if (option.type === 'section') {\n return <Section label={option.label} {...generalProps} />;\n }\n if (option.type === 'option') {\n return (\n <SingleMenuItem\n {...generalProps}\n value={option.value}\n label={option.label}\n dataTestid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n />\n );\n }\n return <></>;\n });\n }\n return null;\n }, [options, focusOptionIdx, inputRef, virtualListHelpers]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACsCN,SAeF,UAfE;AArCjB,SAAgB,SAAS,YAAY,mBAAmB;AACxD,SAAS,gBAAgB,eAAe;AACxC,OAAO,yBAAyB;AAChC,SAAS,8BAA8B;AAGhC,MAAM,kBAAkB,MAAiC;AAC9D,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,SAAS;AAAA,IAC3B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAElC,QAAM,cAAc;AAAA,IAClB,CAAC,QAAoC,MAA0C;AAC7E,eAAS,OAAO,OAAO,CAAC;AACxB,kCAA4B,IAAI;AAChC,4BAAsB,KAAK;AAC3B,QAAE,gBAAgB;AAClB,QAAE,eAAe;AAAA,IACnB;AAAA,IACA,CAAC,UAAU,uBAAuB,2BAA2B;AAAA,EAC/D;AAEA,SAAO,QAAQ,MAAM;AACnB,QAAI,oBAAoB;AACtB,aAAO,mBAAmB,aAAa,IAAI,CAAC,UAAU;AACpD,cAAM,SAAS,QAAQ,MAAM,KAAK;AAClC,cAAM,eAAe;AAAA,UACnB,eAAe,EAAE,UAAU,YAAY,KAAK,MAAM,OAAO,MAAM,GAAG,OAAO,OAAO;AAAA,UAChF,KAAK,GAAG,OAAO;AAAA,UACf,UAAU,MAAM;AAAA,QAClB;AACA,YAAI,OAAO,SAAS,WAAW;AAC7B,iBAAO,oBAAC,WAAQ,OAAO,OAAO,OAAQ,GAAG,cAAc;AAAA,QACzD;AACA,YAAI,OAAO,SAAS,UAAU;AAC5B,iBACE;AAAA,YAAC;AAAA;AAAA,cACE,GAAG;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,OAAO,OAAO;AAAA,cACd,YAAY,uBAAuB;AAAA,cACnC,UAAU,OAAO;AAAA,cACjB,SAAS,CAAC,MAA0C,YAAY,QAAQ,CAAC;AAAA,cACzE,UAAU,OAAO,SAAS;AAAA;AAAA,UAC5B;AAAA,QAEJ;AACA,eAAO,gCAAE;AAAA,MACX,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT,GAAG,CAAC,SAAS,gBAAgB,UAAU,kBAAkB,CAAC;AAC5D;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,11 @@
1
1
  import * as React from "react";
2
- import { PropTypes } from "@elliemae/ds-utilities";
2
+ import { PropTypes } from "@elliemae/ds-props-helpers";
3
+ const defaultProps = {
4
+ zIndex: 10,
5
+ withoutPortal: false,
6
+ startPlacementPreference: "bottom-start",
7
+ placementOrderPreference: ["bottom-start", "bottom-end"]
8
+ };
3
9
  const propTypes = {
4
10
  options: PropTypes.oneOfType([PropTypes.array, PropTypes.object]).isRequired.description("List of options").defaultValue([]),
5
11
  filter: PropTypes.string.isRequired.description("String value to filter the options").defaultValue(""),
@@ -7,6 +13,7 @@ const propTypes = {
7
13
  children: PropTypes.node.isRequired.description("React component to apply autocomplete functionality").defaultValue("")
8
14
  };
9
15
  export {
16
+ defaultProps,
10
17
  propTypes
11
18
  };
12
19
  //# sourceMappingURL=react-desc-prop-types.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/react-desc-prop-types.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport { 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"],
5
- "mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,iBAAiB;AA6CnB,MAAM,YAAY;AAAA,EACvB,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,UAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,UAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,UAAU,KAAK,WACtB,YAAY,qDAAqD,EACjE,aAAa,EAAE;AACpB;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport { 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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACGvB,SAAS,iBAAiB;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,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,UAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,UAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,UAAU,KAAK,WACtB,YAAY,qDAAqD,EACjE,aAAa,EAAE;AACpB;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/utils/listHelper.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "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"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEhB,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 * as React from 'react';\nexport { React };\n", "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"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEhB,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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/ds-form-layout-autocomplete",
3
- "version": "3.16.0-next.2",
3
+ "version": "3.16.0-next.21",
4
4
  "license": "MIT",
5
5
  "description": "ICE MT - Dimsum - Form Layout - Autocomplete",
6
6
  "files": [
@@ -36,24 +36,24 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "react-virtual": "~2.10.4",
39
- "styled-components": "~5.3.6",
40
- "@elliemae/ds-menu-items": "3.16.0-next.2",
41
- "@elliemae/ds-popperjs": "3.16.0-next.2",
42
- "@elliemae/ds-system": "3.16.0-next.2",
43
- "@elliemae/ds-utilities": "3.16.0-next.2"
39
+ "styled-components": "~5.3.9",
40
+ "@elliemae/ds-menu-items": "3.16.0-next.21",
41
+ "@elliemae/ds-props-helpers": "3.16.0-next.21",
42
+ "@elliemae/ds-system": "3.16.0-next.21",
43
+ "@elliemae/ds-popperjs": "3.16.0-next.21"
44
44
  },
45
45
  "devDependencies": {
46
- "@elliemae/pui-theme": "~2.6.0",
46
+ "@elliemae/pui-theme": "~2.7.0",
47
47
  "@testing-library/dom": "~8.19.0",
48
- "@testing-library/jest-dom": "~5.16.4",
48
+ "@testing-library/jest-dom": "~5.16.5",
49
49
  "@testing-library/react": "~12.1.3",
50
50
  "@testing-library/user-event": "~13.5.0",
51
- "styled-components": "~5.3.6",
51
+ "styled-components": "~5.3.9",
52
52
  "styled-system": "~5.1.5",
53
- "@elliemae/ds-form-input-text": "3.16.0-next.2"
53
+ "@elliemae/ds-form-input-text": "3.16.0-next.21"
54
54
  },
55
55
  "peerDependencies": {
56
- "@elliemae/pui-theme": "~2.6.0",
56
+ "@elliemae/pui-theme": "~2.7.0",
57
57
  "react": "^17.0.2",
58
58
  "react-dom": "^17.0.2",
59
59
  "styled-components": "~5.3.6",
@@ -70,7 +70,7 @@
70
70
  "eslint:fix": "eslint --ext='.js,.jsx,.test.js,.ts,.tsx' --fix --config='../../.eslintrc.js' src/",
71
71
  "dts": "node ../../scripts/dts.mjs",
72
72
  "build": "cross-env NODE_ENV=production node ../../scripts/build/build.mjs",
73
- "dev:build": "pnpm --filter {.}... build && pnpm --filter {.}... dts",
73
+ "dev:build": "pnpm --filter {.}... build",
74
74
  "dev:install": "pnpm --filter {.}... i --no-lockfile && pnpm run dev:build",
75
75
  "checkDeps": "npx -yes ../ds-codemods check-missing-packages --projectFolderPath=\"./\" --ignorePackagesGlobPattern=\"\" --ignoreFilesGlobPattern=\"**/test-ables/*,**/tests/*\""
76
76
  }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/sharedTypes.ts", "../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import type React from 'react';\nimport type { useVirtual } from 'react-virtual';\nimport type { DSAutocompleteT } from './react-desc-prop-types';\n\nexport declare namespace DSAutoCompleteInternalsT {\n export interface AutocompleteContext {\n props: DSAutocompleteT.InternalProps;\n virtualListHelpers?: ReturnType<typeof useVirtual>;\n showPopover: boolean;\n setShowPopover: React.Dispatch<React.SetStateAction<boolean>>;\n referenceElement: HTMLElement | null;\n setReferenceElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n scrollOptionIntoView: (dsId: string, opts?: any) => void;\n inputRef: React.RefObject<HTMLInputElement>;\n listRef: React.RefObject<HTMLDivElement>;\n focusOptionIdx: string;\n setCurrentOption: React.Dispatch<React.SetStateAction<string>>;\n }\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
- "names": []
7
- }
@@ -1,2 +0,0 @@
1
- import * as React from "react";
2
- //# sourceMappingURL=sharedTypes.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
- "mappings": "AAAA,YAAY,WAAW;",
6
- "names": []
7
- }
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import type { DSAutocompleteT } from './react-desc-prop-types';
3
- declare const DSAutocomplete: React.ComponentType<DSAutocompleteT.Props>;
4
- declare const DSAutocompleteWithSchema: import("@elliemae/ds-utilities/dist/types/props-helpers/propTypes/types").DocumentedReactComponent<DSAutocompleteT.Props>;
5
- export { DSAutocomplete, DSAutocompleteWithSchema };
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import type { DSAutocompleteT } from './react-desc-prop-types';
3
- import type { DSAutoCompleteInternalsT } from './sharedTypes';
4
- export declare const defaultProps: DSAutocompleteT.DefaultProps;
5
- /** Context for cross component communication */
6
- export declare const AutocompleteContext: import("react").Context<DSAutoCompleteInternalsT.AutocompleteContext>;
7
- export default AutocompleteContext;
@@ -1,5 +0,0 @@
1
- export declare const AutocompleteDataTestid: {
2
- LIST: string;
3
- OPTION: string;
4
- CONTAINER: string;
5
- };
@@ -1 +0,0 @@
1
- export declare const DSAutocompleteName = "DSAutocomplete";
@@ -1,3 +0,0 @@
1
- import type { DSAutocompleteT } from '../react-desc-prop-types';
2
- import type { DSAutoCompleteInternalsT } from '../sharedTypes';
3
- export declare const useAutocomplete: (props: DSAutocompleteT.Props) => DSAutoCompleteInternalsT.AutocompleteContext;
@@ -1 +0,0 @@
1
- export * from './Autocomplete';
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import type { DSAutocompleteT } from '../react-desc-prop-types';
3
- export declare const isSeparator: (el: DSAutocompleteT.OptionTypes | undefined) => el is DSAutocompleteT.ItemSeparatorOptions;
4
- export declare const StyledA11ySelectedValues: import("styled-components").StyledComponent<keyof JSX.IntrinsicElements, import("@elliemae/ds-system").Theme, Record<string, unknown> & object, never>;
5
- export declare const A11yFocusedOption: React.ComponentType;
@@ -1 +0,0 @@
1
- export declare const Container: () => JSX.Element;
@@ -1 +0,0 @@
1
- export { Container } from './Container';
@@ -1,2 +0,0 @@
1
- export declare const StyledContainer: import("styled-components").StyledComponent<keyof JSX.IntrinsicElements, import("@elliemae/ds-system").Theme, Record<string, unknown> & object, never>;
2
- export declare const StyledPopperWrapper: import("styled-components").StyledComponent<keyof JSX.IntrinsicElements, import("@elliemae/ds-system").Theme, Record<string, unknown> & object, never>;
@@ -1,4 +0,0 @@
1
- import type React from 'react';
2
- export declare const useKeyboardNavigation: () => {
3
- onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement>;
4
- };
@@ -1 +0,0 @@
1
- export declare const MenuList: () => JSX.Element;