@elliemae/ds-form-layout-autocomplete 3.80.0-next.8 → 3.80.0-next.81

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 (35) hide show
  1. package/dist/cjs/config/useVirtualization.js +15 -5
  2. package/dist/cjs/config/useVirtualization.js.map +2 -2
  3. package/dist/cjs/parts/Section.js +31 -18
  4. package/dist/cjs/parts/Section.js.map +2 -2
  5. package/dist/cjs/parts/container/Container.js +1 -1
  6. package/dist/cjs/parts/container/Container.js.map +2 -2
  7. package/dist/cjs/parts/container/useKeyboardNavigation.js +2 -2
  8. package/dist/cjs/parts/container/useKeyboardNavigation.js.map +2 -2
  9. package/dist/cjs/parts/menu-list/MenuList.js +7 -6
  10. package/dist/cjs/parts/menu-list/MenuList.js.map +2 -2
  11. package/dist/cjs/parts/menu-list/useItemRenderer.js +49 -46
  12. package/dist/cjs/parts/menu-list/useItemRenderer.js.map +2 -2
  13. package/dist/cjs/react-desc-prop-types.js.map +2 -2
  14. package/dist/cjs/utils/listHelper.js +2 -0
  15. package/dist/cjs/utils/listHelper.js.map +2 -2
  16. package/dist/esm/config/useVirtualization.js +15 -5
  17. package/dist/esm/config/useVirtualization.js.map +2 -2
  18. package/dist/esm/parts/Section.js +31 -18
  19. package/dist/esm/parts/Section.js.map +2 -2
  20. package/dist/esm/parts/container/Container.js +2 -2
  21. package/dist/esm/parts/container/Container.js.map +2 -2
  22. package/dist/esm/parts/container/useKeyboardNavigation.js +3 -3
  23. package/dist/esm/parts/container/useKeyboardNavigation.js.map +2 -2
  24. package/dist/esm/parts/menu-list/MenuList.js +7 -6
  25. package/dist/esm/parts/menu-list/MenuList.js.map +2 -2
  26. package/dist/esm/parts/menu-list/useItemRenderer.js +49 -46
  27. package/dist/esm/parts/menu-list/useItemRenderer.js.map +2 -2
  28. package/dist/esm/react-desc-prop-types.js.map +2 -2
  29. package/dist/esm/utils/listHelper.js +2 -0
  30. package/dist/esm/utils/listHelper.js.map +2 -2
  31. package/dist/types/config/useVirtualization.d.ts +3 -3
  32. package/dist/types/parts/Section.d.ts +2 -1
  33. package/dist/types/react-desc-prop-types.d.ts +1 -0
  34. package/dist/types/utils/listHelper.d.ts +1 -0
  35. package/package.json +15 -15
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
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, type ScrollToIndexOptions } from 'react-virtual';\n\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport type { useRefs } from './useRefs.js';\n\nexport const useVirtualization = ({\n references,\n options,\n}: {\n references: ReturnType<typeof useRefs>;\n options: DSAutocompleteT.InternalProps['options'];\n}): {\n virtualListHelpers: ReturnType<typeof useVirtual>;\n scrollOptionIntoView: (dsId: string, opts?: ScrollToIndexOptions) => void;\n} => {\n const { listRef } = references;\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: ScrollToIndexOptions = { 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,kBAA6C;AAK/C,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AACF,MAMK;AACH,QAAM,EAAE,QAAQ,IAAI;AAIpB,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,OAA6B,EAAE,OAAO,SAAS,MAAM;AAClE,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;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useCallback } from 'react';\nimport { useVirtualizer, type ScrollToOptions } from '@tanstack/react-virtual';\n\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\nimport type { useRefs } from './useRefs.js';\n\n// Mirrors ds-menu-items-commons's MENU_ITEM_ROW_HEIGHT (32px) \u2014 not importable, that constant is\n// private to that package (same duplication already tracked for Section.tsx's StyledSectionWrapper\n// min-height in KNOWN_INTENTIONAL_DEVIATIONS.md). A \"section\" virtual item renders its own header\n// plus all of its sub-options inline (see Section.tsx), so its estimate must account for that.\nconst OPTION_ROW_HEIGHT_PX = 32;\n\nexport const useVirtualization = ({\n references,\n options,\n}: {\n references: ReturnType<typeof useRefs>;\n options: DSAutocompleteT.InternalProps['options'];\n}): {\n // TItemElement is HTMLElement, not HTMLDivElement: rendered items are a mix of <li> roots\n // (StyledMenuItemAction/DSMenuItemsAction, an HTMLLIElement) and <section> roots (Section.tsx's\n // StyledSectionWrapper) \u2014 HTMLElement is their common base.\n virtualListHelpers: ReturnType<typeof useVirtualizer<HTMLDivElement, HTMLElement>>;\n scrollOptionIntoView: (dsId: string, opts?: ScrollToOptions) => void;\n} => {\n const { listRef } = references;\n // ===========================================================================\n // Virtualization setup\n // ===========================================================================\n const estimateSize = useCallback(\n (index: number) => {\n const option = options[index];\n // v3 has no internal default for estimateSize (v2 silently defaulted to 50) \u2014 omitting it\n // silently zeroes out getVirtualItems()/getTotalSize() with real data present, no thrown error.\n if (option.type === 'section') return OPTION_ROW_HEIGHT_PX * (1 + option.options.length);\n return OPTION_ROW_HEIGHT_PX;\n },\n [options],\n );\n\n const virtualListHelpers = useVirtualizer<HTMLDivElement, HTMLElement>({\n count: options.length,\n getScrollElement: () => listRef.current,\n overscan: 15,\n paddingStart: 0,\n estimateSize,\n });\n\n // ===========================================================================\n // Scroll into view function\n // ===========================================================================\n const scrollOptionIntoView = useCallback(\n (dsId: string, opts: ScrollToOptions = { 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,sBAA4C;AASrD,MAAM,uBAAuB;AAEtB,MAAM,oBAAoB,CAAC;AAAA,EAChC;AAAA,EACA;AACF,MASK;AACH,QAAM,EAAE,QAAQ,IAAI;AAIpB,QAAM,eAAe;AAAA,IACnB,CAAC,UAAkB;AACjB,YAAM,SAAS,QAAQ,KAAK;AAG5B,UAAI,OAAO,SAAS,UAAW,QAAO,wBAAwB,IAAI,OAAO,QAAQ;AACjF,aAAO;AAAA,IACT;AAAA,IACA,CAAC,OAAO;AAAA,EACV;AAEA,QAAM,qBAAqB,eAA4C;AAAA,IACrE,OAAO,QAAQ;AAAA,IACf,kBAAkB,MAAM,QAAQ;AAAA,IAChC,UAAU;AAAA,IACV,cAAc;AAAA,IACd;AAAA,EACF,CAAC;AAKD,QAAM,uBAAuB;AAAA,IAC3B,CAAC,MAAc,OAAwB,EAAE,OAAO,SAAS,MAAM;AAC7D,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
6
  "names": ["React"]
7
7
  }
@@ -18,25 +18,38 @@ const StyledSectionLabel = styled(DSTypography)`
18
18
  `;
19
19
  const Section = React2.memo((props) => {
20
20
  const { label, wrapperStyles, focusOptionIdx, innerRef, options, handleClick } = props;
21
+ const dataIndex = props["data-index"];
21
22
  const id = `${label.replace(/ /g, "")}-section`;
22
- return /* @__PURE__ */ jsxs(StyledSectionWrapper, { role: "group", "aria-labelledby": id, style: wrapperStyles, innerRef, children: [
23
- /* @__PURE__ */ jsx(StyledSectionLabel, { variant: "b3-strong", component: "header", id, role: "presentation", children: label }),
24
- options?.map((option) => /* @__PURE__ */ jsx(
25
- DSMenuItemsAction,
26
- {
27
- as: "div",
28
- dsId: option.dsId,
29
- id: option.dsId,
30
- label: option.label,
31
- "data-testid": AutocompleteDataTestid.OPTION,
32
- disabled: option.disabled,
33
- onClick: (e) => handleClick(option, e),
34
- isActive: option.dsId === focusOptionIdx,
35
- "aria-selected": "false"
36
- },
37
- option.dsId
38
- ))
39
- ] });
23
+ return /* @__PURE__ */ jsxs(
24
+ StyledSectionWrapper,
25
+ {
26
+ role: "group",
27
+ "aria-labelledby": id,
28
+ style: wrapperStyles,
29
+ innerRef,
30
+ "data-index": dataIndex,
31
+ children: [
32
+ /* @__PURE__ */ jsx(StyledSectionLabel, { variant: "b3-strong", component: "header", id, role: "presentation", children: label }),
33
+ options?.map((option) => /* @__PURE__ */ jsx(
34
+ DSMenuItemsAction,
35
+ {
36
+ as: "div",
37
+ dsId: option.dsId,
38
+ id: option.dsId,
39
+ label: option.label,
40
+ "data-testid": AutocompleteDataTestid.OPTION,
41
+ disabled: option.disabled,
42
+ applyAriaDisabled: option.applyAriaDisabled,
43
+ onClick: (e) => handleClick(option, e),
44
+ isActive: option.dsId === focusOptionIdx,
45
+ "aria-selected": "false",
46
+ tabIndex: 0
47
+ },
48
+ option.dsId
49
+ ))
50
+ ]
51
+ }
52
+ );
40
53
  });
41
54
  export {
42
55
  Section
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../src/parts/Section.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { DSMenuItemsAction } from '@elliemae/ds-menu-items';\nimport { AutocompleteDataTestid } from '../AutocompleteDataTestids.js';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\ninterface SectionProps {\n label: string;\n wrapperStyles: React.CSSProperties;\n innerRef: (instance: HTMLDivElement | null) => void;\n options: DSAutocompleteT.ItemOption[];\n handleClick: (option: DSAutocompleteT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => void;\n focusOptionIdx: string;\n}\n\nconst StyledSectionWrapper = styled('section')`\n list-style: none;\n min-height: 32px;\n display: grid;\n align-items: center;\n`;\n\n/**\n * Group-label styling aligned with its siblings (PUI-18609 / PUI-15487): b3-strong typography,\n * 32px row (8px+8px padding + b3-strong line-height, mirrored by the wrapper min-height above).\n *\n * This is one of four independent reimplementations of the section/group-label row\n * (ds-menu-items-commons, ds-form-combobox, ds-menu-button being the others). The duplication \u2014\n * and the fact that these styled calls remain slot-less here \u2014 is tracked in\n * KNOWN_INTENTIONAL_DEVIATIONS.md.\n */\nconst StyledSectionLabel = styled(DSTypography)`\n display: flex;\n align-items: center;\n padding: 8px 16px;\n`;\n\nexport const Section = React.memo((props: SectionProps) => {\n const { label, wrapperStyles, focusOptionIdx, innerRef, options, handleClick } = props;\n const id = `${label.replace(/ /g, '')}-section`;\n return (\n <StyledSectionWrapper role=\"group\" aria-labelledby={id} style={wrapperStyles} innerRef={innerRef}>\n <StyledSectionLabel variant=\"b3-strong\" component=\"header\" id={id} role=\"presentation\">\n {label}\n </StyledSectionLabel>\n {options?.map((option) => (\n <DSMenuItemsAction\n as=\"div\"\n key={option.dsId}\n dsId={option.dsId}\n id={option.dsId}\n label={option.label}\n data-testid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n aria-selected=\"false\"\n />\n ))}\n </StyledSectionWrapper>\n );\n});\n"],
5
- "mappings": "AAAA,YAAY,WAAW;AC0CnB,SACE,KADF;AA1CJ,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAYvC,MAAM,uBAAuB,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAgB7C,MAAM,qBAAqB,OAAO,YAAY;AAAA;AAAA;AAAA;AAAA;AAMvC,MAAM,UAAUA,OAAM,KAAK,CAAC,UAAwB;AACzD,QAAM,EAAE,OAAO,eAAe,gBAAgB,UAAU,SAAS,YAAY,IAAI;AACjF,QAAM,KAAK,GAAG,MAAM,QAAQ,MAAM,EAAE,CAAC;AACrC,SACE,qBAAC,wBAAqB,MAAK,SAAQ,mBAAiB,IAAI,OAAO,eAAe,UAC5E;AAAA,wBAAC,sBAAmB,SAAQ,aAAY,WAAU,UAAS,IAAQ,MAAK,gBACrE,iBACH;AAAA,IACC,SAAS,IAAI,CAAC,WACb;AAAA,MAAC;AAAA;AAAA,QACC,IAAG;AAAA,QAEH,MAAM,OAAO;AAAA,QACb,IAAI,OAAO;AAAA,QACX,OAAO,OAAO;AAAA,QACd,eAAa,uBAAuB;AAAA,QACpC,UAAU,OAAO;AAAA,QACjB,SAAS,CAAC,MAA0C,YAAY,QAAQ,CAAC;AAAA,QACzE,UAAU,OAAO,SAAS;AAAA,QAC1B,iBAAc;AAAA;AAAA,MART,OAAO;AAAA,IASd,CACD;AAAA,KACH;AAEJ,CAAC;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSTypography } from '@elliemae/ds-typography';\nimport { DSMenuItemsAction } from '@elliemae/ds-menu-items';\nimport { AutocompleteDataTestid } from '../AutocompleteDataTestids.js';\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\ninterface SectionProps {\n label: string;\n wrapperStyles: React.CSSProperties;\n // Root is StyledSectionWrapper (styled('section')) \u2014 HTMLElement, not HTMLDivElement.\n innerRef: (instance: HTMLElement | null) => void;\n 'data-index': number;\n options: DSAutocompleteT.ItemOption[];\n handleClick: (option: DSAutocompleteT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => void;\n focusOptionIdx: string;\n}\n\nconst StyledSectionWrapper = styled('section')`\n list-style: none;\n min-height: 32px;\n display: grid;\n align-items: center;\n`;\n\n/**\n * Group-label styling aligned with its siblings (PUI-18609 / PUI-15487): b3-strong typography,\n * 32px row (8px+8px padding + b3-strong line-height, mirrored by the wrapper min-height above).\n *\n * This is one of four independent reimplementations of the section/group-label row\n * (ds-menu-items-commons, ds-form-combobox, ds-menu-button being the others). The duplication \u2014\n * and the fact that these styled calls remain slot-less here \u2014 is tracked in\n * KNOWN_INTENTIONAL_DEVIATIONS.md.\n */\nconst StyledSectionLabel = styled(DSTypography)`\n display: flex;\n align-items: center;\n padding: 8px 16px;\n`;\n\nexport const Section = React.memo((props: SectionProps) => {\n const { label, wrapperStyles, focusOptionIdx, innerRef, options, handleClick } = props;\n const dataIndex = props['data-index'];\n const id = `${label.replace(/ /g, '')}-section`;\n return (\n <StyledSectionWrapper\n role=\"group\"\n aria-labelledby={id}\n style={wrapperStyles}\n innerRef={innerRef}\n data-index={dataIndex}\n >\n <StyledSectionLabel variant=\"b3-strong\" component=\"header\" id={id} role=\"presentation\">\n {label}\n </StyledSectionLabel>\n {options?.map((option) => (\n <DSMenuItemsAction\n as=\"div\"\n key={option.dsId}\n dsId={option.dsId}\n id={option.dsId}\n label={option.label}\n data-testid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n applyAriaDisabled={option.applyAriaDisabled}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n aria-selected=\"false\"\n // the item atom sets no tab stop of its own: the autocomplete decides, and every option stays focusable\n tabIndex={0}\n />\n ))}\n </StyledSectionWrapper>\n );\n});\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;AC6CnB,SAOE,KAPF;AA7CJ,OAAOA,YAAW;AAClB,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AAcvC,MAAM,uBAAuB,OAAO,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAgB7C,MAAM,qBAAqB,OAAO,YAAY;AAAA;AAAA;AAAA;AAAA;AAMvC,MAAM,UAAUA,OAAM,KAAK,CAAC,UAAwB;AACzD,QAAM,EAAE,OAAO,eAAe,gBAAgB,UAAU,SAAS,YAAY,IAAI;AACjF,QAAM,YAAY,MAAM,YAAY;AACpC,QAAM,KAAK,GAAG,MAAM,QAAQ,MAAM,EAAE,CAAC;AACrC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,mBAAiB;AAAA,MACjB,OAAO;AAAA,MACP;AAAA,MACA,cAAY;AAAA,MAEZ;AAAA,4BAAC,sBAAmB,SAAQ,aAAY,WAAU,UAAS,IAAQ,MAAK,gBACrE,iBACH;AAAA,QACC,SAAS,IAAI,CAAC,WACb;AAAA,UAAC;AAAA;AAAA,YACC,IAAG;AAAA,YAEH,MAAM,OAAO;AAAA,YACb,IAAI,OAAO;AAAA,YACX,OAAO,OAAO;AAAA,YACd,eAAa,uBAAuB;AAAA,YACpC,UAAU,OAAO;AAAA,YACjB,mBAAmB,OAAO;AAAA,YAC1B,SAAS,CAAC,MAA0C,YAAY,QAAQ,CAAC;AAAA,YACzE,UAAU,OAAO,SAAS;AAAA,YAC1B,iBAAc;AAAA,YAEd,UAAU;AAAA;AAAA,UAXL,OAAO;AAAA,QAYd,CACD;AAAA;AAAA;AAAA,EACH;AAEJ,CAAC;",
6
6
  "names": ["React"]
7
7
  }
@@ -4,7 +4,7 @@ import React2, { useCallback, useMemo, useContext } from "react";
4
4
  import { styled } from "@elliemae/ds-system";
5
5
  import { DSInputText } from "@elliemae/ds-form-input-text";
6
6
  import { useFloatingContext, FloatingWrapper } from "@elliemae/ds-floating-context";
7
- import { useGetGlobalAttributes, useGetXstyledProps } from "@elliemae/ds-props-helpers";
7
+ import { omitLockAttributes, useGetGlobalAttributes, useGetXstyledProps } from "@elliemae/ds-props-helpers";
8
8
  import AutocompleteContext from "../../AutocompleteCTX.js";
9
9
  import { StyledContainer, StyledPopperWrapper } from "./styled.js";
10
10
  import { MenuList } from "../menu-list/index.js";
@@ -78,7 +78,7 @@ const Container = () => {
78
78
  onFocus: onFocusPopoverStatusSync,
79
79
  "data-testid": AutocompleteDataTestid.CONTAINER,
80
80
  getOwnerProps,
81
- ...globalsAttrs,
81
+ ...omitLockAttributes(globalsAttrs),
82
82
  ...xStyledProps,
83
83
  children: [
84
84
  input || renderInput && renderInput({
@@ -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 no-unused-vars */\n/* eslint-disable complexity */\nimport React, { useCallback, useMemo, useContext } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSInputText } from '@elliemae/ds-form-input-text';\nimport { useFloatingContext, FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\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 { DSAutocompleteName, DSAutocompleteSlots } from '../../constants/index.js';\n\nconst StyledInputText = styled(DSInputText, {\n name: DSAutocompleteName,\n slot: DSAutocompleteSlots.INPUT,\n})``;\n\nexport const Container = (): JSX.Element => {\n const {\n props: {\n startPlacementPreference,\n onValueChange,\n inputProps,\n children,\n filter,\n placementOrderPreference,\n renderInput,\n zIndex,\n ...restProps\n },\n isShowingPopover,\n referenceElement,\n getOwnerProps,\n setReferenceElement,\n setUserJustSelectedAnOption,\n setUserTypedSomething,\n setUserIsNavigatingWithArrows,\n setForceClosePopover,\n autoCompleteId,\n focusOptionIdx,\n } = useContext(AutocompleteContext);\n\n const { onSelect, id, ...globalsAttrs } = useGetGlobalAttributes(restProps);\n const xStyledProps = useGetXstyledProps(restProps);\n const { onInputKeyDown } = useKeyboardNavigation();\n\n const input = !onValueChange && !renderInput ? React.Children.only(children) : null;\n\n const hideTooltip = useCallback(() => {\n setForceClosePopover(true);\n }, [setForceClosePopover]);\n\n const config = useMemo(\n () => ({\n placement: 'bottom' as const,\n withoutAnimation: true,\n startPlacementPreference,\n placementOrderPreference,\n zIndex,\n customOffset: [0, 5] as [number, number],\n externallyControlledIsOpen: isShowingPopover,\n // referenceElement comes from context as state \u2014 pass it directly so position can be\n // computed on the first render (no useEffect round-trip, no visibility:hidden race).\n externalReferenceElement: referenceElement,\n onClickOutside: hideTooltip,\n }),\n [startPlacementPreference, placementOrderPreference, zIndex, isShowingPopover, referenceElement, hideTooltip],\n );\n\n const { refs, floatingStyles, context } = useFloatingContext(config);\n\n const onFocusPopoverStatusSync = useCallback(() => {\n setForceClosePopover(false);\n setUserJustSelectedAnOption(false);\n setUserTypedSomething(false);\n setUserIsNavigatingWithArrows(false);\n }, [setForceClosePopover, setUserIsNavigatingWithArrows, setUserJustSelectedAnOption, setUserTypedSomething]);\n return (\n <>\n {/* The purpose of this div is to always have the 'menu-list-{autoCompleteId}' present in the DOM */}\n {/* Fix for PUI-11627 */}\n {/* {isShowingPopover === false ? <StyledHiddenDiv id={`menu-list-${autoCompleteId}`} /> : null} */}\n\n <StyledContainer\n id={id}\n innerRef={setReferenceElement}\n onKeyDown={onInputKeyDown}\n onFocus={onFocusPopoverStatusSync}\n // aria-owns={`menu-list-${autoCompleteId}`}\n data-testid={AutocompleteDataTestid.CONTAINER}\n getOwnerProps={getOwnerProps}\n {...globalsAttrs}\n {...xStyledProps}\n >\n {input ||\n (renderInput &&\n renderInput({\n value: filter,\n role: 'combobox',\n 'aria-expanded': isShowingPopover,\n 'aria-controls': `menu-list-${autoCompleteId}`,\n 'aria-activedescendant': isShowingPopover ? focusOptionIdx : undefined,\n 'aria-autocomplete': 'list',\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n ...inputProps,\n })) || (\n <StyledInputText\n onValueChange={onValueChange}\n value={filter}\n role=\"combobox\"\n aria-expanded={isShowingPopover}\n aria-controls={`menu-list-${autoCompleteId}`}\n aria-activedescendant={isShowingPopover ? focusOptionIdx : undefined}\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck=\"false\"\n {...inputProps}\n getOwnerProps={getOwnerProps}\n />\n )}\n {filter && (\n <FloatingWrapper\n innerRef={refs.setFloating}\n floatingStyles={floatingStyles}\n isOpen={isShowingPopover}\n context={context}\n >\n <StyledPopperWrapper tabIndex={-1}>\n <MenuList />\n </StyledPopperWrapper>\n </FloatingWrapper>\n )}\n </StyledContainer>\n </>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACgFnB,mBA8BQ,KAzBN,YALF;AA9EJ,OAAOA,UAAS,aAAa,SAAS,kBAAkB;AACxD,SAAS,cAAc;A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slint-disable complexity */\nimport React, { useCallback, useMemo, useContext } from 'react';\nimport { styled } from '@elliemae/ds-system';\nimport { DSInputText } from '@elliemae/ds-form-input-text';\nimport { useFloatingContext, FloatingWrapper } from '@elliemae/ds-floating-context';\nimport { omitLockAttributes, useGetGlobalAttributes, useGetXstyledProps } from '@elliemae/ds-props-helpers';\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 { DSAutocompleteName, DSAutocompleteSlots } from '../../constants/index.js';\n\nconst StyledInputText = styled(DSInputText, {\n name: DSAutocompleteName,\n slot: DSAutocompleteSlots.INPUT,\n})``;\n\nexport const Container = (): JSX.Element => {\n const {\n props: {\n startPlacementPreference,\n onValueChange,\n inputProps,\n children,\n filter,\n placementOrderPreference,\n renderInput,\n zIndex,\n ...restProps\n },\n isShowingPopover,\n referenceElement,\n getOwnerProps,\n setReferenceElement,\n setUserJustSelectedAnOption,\n setUserTypedSomething,\n setUserIsNavigatingWithArrows,\n setForceClosePopover,\n autoCompleteId,\n focusOptionIdx,\n } = useContext(AutocompleteContext);\n\n const { onSelect, id, ...globalsAttrs } = useGetGlobalAttributes(restProps);\n const xStyledProps = useGetXstyledProps(restProps);\n const { onInputKeyDown } = useKeyboardNavigation();\n\n const input = !onValueChange && !renderInput ? React.Children.only(children) : null;\n\n const hideTooltip = useCallback(() => {\n setForceClosePopover(true);\n }, [setForceClosePopover]);\n\n const config = useMemo(\n () => ({\n placement: 'bottom' as const,\n withoutAnimation: true,\n startPlacementPreference,\n placementOrderPreference,\n zIndex,\n customOffset: [0, 5] as [number, number],\n externallyControlledIsOpen: isShowingPopover,\n // referenceElement comes from context as state \u2014 pass it directly so position can be\n // computed on the first render (no useEffect round-trip, no visibility:hidden race).\n externalReferenceElement: referenceElement,\n onClickOutside: hideTooltip,\n }),\n [startPlacementPreference, placementOrderPreference, zIndex, isShowingPopover, referenceElement, hideTooltip],\n );\n\n const { refs, floatingStyles, context } = useFloatingContext(config);\n\n const onFocusPopoverStatusSync = useCallback(() => {\n setForceClosePopover(false);\n setUserJustSelectedAnOption(false);\n setUserTypedSomething(false);\n setUserIsNavigatingWithArrows(false);\n }, [setForceClosePopover, setUserIsNavigatingWithArrows, setUserJustSelectedAnOption, setUserTypedSomething]);\n return (\n <>\n {/* The purpose of this div is to always have the 'menu-list-{autoCompleteId}' present in the DOM */}\n {/* Fix for PUI-11627 */}\n {/* {isShowingPopover === false ? <StyledHiddenDiv id={`menu-list-${autoCompleteId}`} /> : null} */}\n\n <StyledContainer\n id={id}\n innerRef={setReferenceElement}\n onKeyDown={onInputKeyDown}\n onFocus={onFocusPopoverStatusSync}\n // aria-owns={`menu-list-${autoCompleteId}`}\n data-testid={AutocompleteDataTestid.CONTAINER}\n getOwnerProps={getOwnerProps}\n {...omitLockAttributes(globalsAttrs)}\n {...xStyledProps}\n >\n {input ||\n (renderInput &&\n renderInput({\n value: filter,\n role: 'combobox',\n 'aria-expanded': isShowingPopover,\n 'aria-controls': `menu-list-${autoCompleteId}`,\n 'aria-activedescendant': isShowingPopover ? focusOptionIdx : undefined,\n 'aria-autocomplete': 'list',\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n ...inputProps,\n })) || (\n <StyledInputText\n onValueChange={onValueChange}\n value={filter}\n role=\"combobox\"\n aria-expanded={isShowingPopover}\n aria-controls={`menu-list-${autoCompleteId}`}\n aria-activedescendant={isShowingPopover ? focusOptionIdx : undefined}\n aria-autocomplete=\"list\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck=\"false\"\n {...inputProps}\n getOwnerProps={getOwnerProps}\n />\n )}\n {filter && (\n <FloatingWrapper\n innerRef={refs.setFloating}\n floatingStyles={floatingStyles}\n isOpen={isShowingPopover}\n context={context}\n >\n <StyledPopperWrapper tabIndex={-1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;AAAA,YACf;AAAA,YACA,QAAQ;AAAA,YACR;AAAA,YAEA,8BAAC,uBAAoB,UAAU,IAC7B,8BAAC,YAAS,GACZ;AAAA;AAAA,QACF;AAAA;AAAA;AAAA,EAEJ,GACF;AAEJ;",
6
6
  "names": ["React"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useCallback, useContext } from "react";
3
3
  import AutocompleteContext from "../../AutocompleteCTX.js";
4
- import { findInCircularList, isOptionFocuseable } from "../../utils/listHelper.js";
4
+ import { findInCircularList, isOptionFocuseable, isOptionLocked } from "../../utils/listHelper.js";
5
5
  const useKeyboardNavigation = () => {
6
6
  const {
7
7
  props: { onSelect, options },
@@ -22,7 +22,7 @@ const useKeyboardNavigation = () => {
22
22
  if (e.key === "Tab" || e.key === "Escape") setForceClosePopover(true);
23
23
  if (e.key === "Enter" && isShowingPopover && currentItem?.label !== void 0) {
24
24
  e.preventDefault();
25
- onSelect(currentItem?.label, e);
25
+ if (!isOptionLocked(currentItem)) onSelect(currentItem.label, e);
26
26
  }
27
27
  if (e.key === "ArrowDown") {
28
28
  e.preventDefault();
@@ -46,7 +46,7 @@ const useKeyboardNavigation = () => {
46
46
  setForceClosePopover,
47
47
  isShowingPopover,
48
48
  onSelect,
49
- currentItem?.label,
49
+ currentItem,
50
50
  options,
51
51
  currentItemIndex,
52
52
  setCurrentOption,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/parts/container/useKeyboardNavigation.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { findInCircularList, isOptionFocuseable } from '../../utils/listHelper.js';\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { onSelect, options },\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(AutocompleteContext);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find(\n (item) => item.type === 'option' && item.dsId === focusOptionIdx,\n ) as DSAutocompleteT.ItemOption;\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // =============================================================================\n // TRACK STATE OF POPOVER SHOWING OR NOT\n // =============================================================================\n trackUserInteractingViaKeyboard(e);\n\n if (e.key === 'Tab' || e.key === 'Escape') setForceClosePopover(true);\n\n // =============================================================================\n // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER\n // AFTER https://jira.elliemae.io/browse/PUI-14625\n // AUTOFOCUS ON FIRST OPTION WAS REMOVED\n // pressing Enter now is not necessarily selecting the first option (if popover is open)\n // now to ensure the first option is selected, the user has to press ArrowDown\n // so, if no focus (so no currentItem) is set, this is not a \"onSelect\" event\n // =============================================================================\n if (e.key === 'Enter' && isShowingPopover && currentItem?.label !== undefined) {\n e.preventDefault();\n onSelect(currentItem?.label, e);\n }\n\n // =============================================================================\n // ARROWS UP AND DOWN\n // =============================================================================\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n if (e.key === 'ArrowUp') {\n e.preventDefault();\n if (isShowingPopover) {\n const nextItemIndex = findInCircularList(options, currentItemIndex, isOptionFocuseable, -1);\n setCurrentOption(options[nextItemIndex].dsId);\n scrollOptionIntoView(options[nextItemIndex].dsId);\n }\n }\n },\n [\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n onSel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ClD;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;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\n/* eslint-disable max-depth */\n/* eslint-disable max-statements */\n/* eslint-disable complexity */\nimport type React from 'react';\nimport { useCallback, useContext } from 'react';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { findInCircularList, isOptionFocuseable, isOptionLocked } from '../../utils/listHelper.js';\n\nexport const useKeyboardNavigation = () => {\n const {\n props: { onSelect, options },\n trackUserInteractingViaKeyboard,\n setForceClosePopover,\n isShowingPopover,\n focusOptionIdx,\n setCurrentOption,\n scrollOptionIntoView,\n } = useContext(AutocompleteContext);\n\n const currentItemIndex = options.findIndex((opt) => opt.dsId === focusOptionIdx);\n const currentItem = options.find(\n (item) => item.type === 'option' && item.dsId === focusOptionIdx,\n ) as DSAutocompleteT.ItemOption;\n\n const onInputKeyDown: React.KeyboardEventHandler<HTMLInputElement> = useCallback(\n (e) => {\n // =============================================================================\n // TRACK STATE OF POPOVER SHOWING OR NOT\n // =============================================================================\n trackUserInteractingViaKeyboard(e);\n\n if (e.key === 'Tab' || e.key === 'Escape') setForceClosePopover(true);\n\n // =============================================================================\n // ENTER AND SPACE KEY SELECT OPTIONS AND OPEN CLOSE THE POPOVER\n // AFTER https://jira.elliemae.io/browse/PUI-14625\n // AUTOFOCUS ON FIRST OPTION WAS REMOVED\n // pressing Enter now is not necessarily selecting the first option (if popover is open)\n // now to ensure the first option is selected, the user has to press ArrowDown\n // so, if no focus (so no currentItem) is set, this is not a \"onSelect\" event\n // =============================================================================\n if (e.key === 'Enter' && isShowingPopover && currentItem?.label !== undefined) {\n // Enter on an active option never submits an enclosing form; a locked option only withholds the selection\n e.preventDefault();\n if (!isOptionLocked(currentItem)) 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,\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,oBAAoB,oBAAoB,sBAAsB;AAEhE,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,SAAU,sBAAqB,IAAI;AAUpE,UAAI,EAAE,QAAQ,WAAW,oBAAoB,aAAa,UAAU,QAAW;AAE7E,UAAE,eAAe;AACjB,YAAI,CAAC,eAAe,WAAW,EAAG,UAAS,YAAY,OAAO,CAAC;AAAA,MACjE;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,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,eAAe;AAC1B;",
6
6
  "names": []
7
7
  }
@@ -16,21 +16,22 @@ const MenuList = () => {
16
16
  listRef,
17
17
  autoCompleteId,
18
18
  getOwnerProps,
19
- virtualListHelpers: { totalSize, measure }
19
+ virtualListHelpers
20
20
  } = useContext(AutocompleteContext);
21
+ const { measure } = virtualListHelpers;
22
+ const totalSize = virtualListHelpers.getTotalSize();
21
23
  const ItemRenderer = useItemRenderer();
22
24
  const { width } = useOnElementResize(referenceElement);
25
+ useEffect(() => {
26
+ if (!measure) return;
27
+ measure();
28
+ }, [width, measure]);
23
29
  const handleOnFocus = useCallback(() => {
24
30
  inputRef.current?.focus();
25
31
  }, [inputRef]);
26
32
  const preventMouseDown = useCallback((e) => {
27
33
  e.preventDefault();
28
34
  }, []);
29
- useEffect(() => {
30
- if (!measure) return void 0;
31
- const rafId = requestAnimationFrame(() => measure());
32
- return () => cancelAnimationFrame(rafId);
33
- }, [width]);
34
35
  const renderMenuContent = () => {
35
36
  if (isSkeleton) return /* @__PURE__ */ jsx(SkeletonContainer, { autoCompleteId, getOwnerProps });
36
37
  if (isLoading) return /* @__PURE__ */ jsx(LoadingContainer, { autoCompleteId, getOwnerProps });
@@ -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, useCallback, useEffect } from 'react';\nimport { StyledListWrapper, StyledList, StyledVirtualListWrapper } from './styled.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { useItemRenderer } from './useItemRenderer.js';\nimport { useOnElementResize } from '../../utils/useOnElementResize.js';\nimport { LoadingContainer } from './LoadingContainer.js';\nimport { SkeletonContainer } from './SkeletonContainer.js';\n\nexport const MenuList = (): JSX.Element => {\n const {\n props: { options, isLoading, isSkeleton },\n referenceElement,\n inputRef,\n listRef,\n autoCompleteId,\n getOwnerProps,\n virtualListHelpers: { totalSize, measure },\n } = useContext(AutocompleteContext);\n\n const ItemRenderer = useItemRenderer();\n const { width } = useOnElementResize(referenceElement);\n\n const handleOnFocus = useCallback(() => {\n inputRef.current?.focus();\n }, [inputRef]);\n\n const preventMouseDown: React.MouseEventHandler<HTMLDivElement> = useCallback((e) => {\n e.preventDefault();\n }, []);\n\n useEffect(() => {\n if (!measure) return undefined;\n // Defer measure() to the next animation frame so it never runs inside an active\n // React sync flush (React 17 / legacy mode). Without the deferral, the call chain\n // outputsize \u2192 setWidth \u2192 [flushSyncCallbackQueue] \u2192 commit \u2192 measureRef \u2192\n // setMeasuredCache \u2192 [new syncQueue entry] \u2192 commit \u2192 measureRef \u2192 \u2026\n // keeps adding entries to the live syncQueue array that flushSyncCallbackQueue\n // is iterating over, producing 25+ nested commits and the\n // \"Maximum update depth exceeded\" crash. requestAnimationFrame breaks that chain\n // by scheduling measure() for after the current flush completes.\n const rafId = requestAnimationFrame(() => measure());\n return () => cancelAnimationFrame(rafId);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [width]);\n\n const renderMenuContent = () => {\n // Loading/skeleton own the listbox id + role + aria-busy while options are being fetched;\n // only one of skeleton / loading / list is ever mounted at a time (see the containers).\n if (isSkeleton) return <SkeletonContainer autoCompleteId={autoCompleteId} getOwnerProps={getOwnerProps} />;\n if (isLoading) return <LoadingContainer autoCompleteId={autoCompleteId} getOwnerProps={getOwnerProps} />;\n if (options.length === 0) return null;\n return (\n <StyledVirtualListWrapper tabIndex={-1} innerRef={listRef}>\n <StyledList\n // recalculate the key to force the re-render of the list and update virtualization\n key={options.length}\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 onFocus={handleOnFocus}\n data-testid={AutocompleteDataTestid.LIST}\n style={{ height: totalSize, margin: '8px 0px' }}\n getOwnerProps={getOwnerProps}\n >\n {ItemRenderer}\n </StyledList>\n </StyledVirtualListWrapper>\n );\n };\n\n return (\n <StyledListWrapper onMouseDown={preventMouseDown} minWidth={referenceElement?.offsetWidth}>\n {renderMenuContent()}\n </StyledListWrapper>\n );\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACiDI;AAjD3B,SAAgB,YAAY,aAAa,iBAAiB;AAC1D,SAAS,mBAAmB,YAAY,gCAAgC;AACxE,SAAS,8BAA8B;AACvC,OAAO,yBAAyB;AAChC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAE3B,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,WAAW,WAAW;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB,EAAE,WAAW,QAAQ;AAAA,EAC3C,IAAI,WAAW,mBAAmB;AAElC,QAAM,eAAe,gBAAgB;AACrC,QAAM,EAAE,MAAM,IAAI,mBAAmB,gBAAgB;AAErD,QAAM,gBAAgB,YAAY,MAAM;AACtC,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,mBAA4D,YAAY,CAAC,MAAM;AACnF,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,YAAU,MAAM;AACd,QAAI,CAAC,QAAS,QAAO;AASrB,UAAM,QAAQ,sBAAsB,MAAM,QAAQ,CAAC;AACnD,WAAO,MAAM,qBAAqB,KAAK;AAAA,EAEzC,GAAG,CAAC,KAAK,CAAC;AAEV,QAAM,oBAAoB,MAAM;AAG9B,QAAI,WAAY,QAAO,oBAAC,qBAAkB,gBAAgC,eAA8B;AACxG,QAAI,UAAW,QAAO,oBAAC,oBAAiB,gBAAgC,eAA8B;AACtG,QAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,WACE,oBAAC,4BAAyB,UAAU,IAAI,UAAU,SAChD;AAAA,MAAC;AAAA;AAAA,QAGC,MAAK;AAAA,QACL,IAAI,aAAa,cAAc;AAAA,QAG/B,cAAW;AAAA,QACX,SAAS;AAAA,QACT,eAAa,uBAAuB;AAAA,QACpC,OAAO,EAAE,QAAQ,WAAW,QAAQ,UAAU;AAAA,QAC9C;AAAA,QAEC;AAAA;AAAA,MAXI,QAAQ;AAAA,IAYf,GACF;AAAA,EAEJ;AAEA,SACE,oBAAC,qBAAkB,aAAa,kBAAkB,UAAU,kBAAkB,aAC3E,4BAAkB,GACrB;AAEJ;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext, useCallback, useEffect } from 'react';\nimport { StyledListWrapper, StyledList, StyledVirtualListWrapper } from './styled.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { useItemRenderer } from './useItemRenderer.js';\nimport { useOnElementResize } from '../../utils/useOnElementResize.js';\nimport { LoadingContainer } from './LoadingContainer.js';\nimport { SkeletonContainer } from './SkeletonContainer.js';\n\nexport const MenuList = (): JSX.Element => {\n const {\n props: { options, isLoading, isSkeleton },\n referenceElement,\n inputRef,\n listRef,\n autoCompleteId,\n getOwnerProps,\n virtualListHelpers,\n } = useContext(AutocompleteContext);\n const { measure } = virtualListHelpers;\n const totalSize = virtualListHelpers.getTotalSize();\n\n const ItemRenderer = useItemRenderer();\n const { width } = useOnElementResize(referenceElement);\n\n useEffect(() => {\n if (!measure) return;\n // v2 deferred this call to the next animation frame to avoid a setMeasuredCache\n // re-entrancy bug during a React legacy-mode sync flush (measureRef \u2192 setMeasuredCache \u2192\n // new commit \u2192 measureRef \u2192 ... \u2192 \"Maximum update depth exceeded\"). @tanstack/react-virtual\n // v3 has no such state setter in its measurement path \u2014 per-item sizing is driven by\n // ResizeObserver instead \u2014 so the bug this deferral guarded against no longer applies.\n // Verified empirically (PUI-19077): removing the deferral does not reproduce the crash,\n // including under a hardened stress test (24 oscillating widths, 16ms apart, 30 repeated\n // headless Playwright CT runs).\n //\n // NOTE: a follow-up \"callback coordination\" refactor (calling measure() directly from\n // useOnElementResize's ResizeObserver callback instead of via this width-effect) was tried\n // and reverted \u2014 it broke DSAutocomplete.variableHeightLayout.test.playwright.jsx\n // deterministically (15/15 runs, same 3.6875px gap). Calling measure() from inside the native\n // ResizeObserver callback fires earlier/differently relative to @tanstack/react-virtual's own\n // per-item measureElement ResizeObserver than calling it from a React effect reacting to\n // width state does. Routing through width state is load-bearing here \u2014 do not \"simplify\" it\n // away again without re-running the variable-height layout test.\n measure();\n }, [width, measure]);\n\n const handleOnFocus = useCallback(() => {\n inputRef.current?.focus();\n }, [inputRef]);\n\n const preventMouseDown: React.MouseEventHandler<HTMLDivElement> = useCallback((e) => {\n e.preventDefault();\n }, []);\n\n const renderMenuContent = () => {\n // Loading/skeleton own the listbox id + role + aria-busy while options are being fetched;\n // only one of skeleton / loading / list is ever mounted at a time (see the containers).\n if (isSkeleton) return <SkeletonContainer autoCompleteId={autoCompleteId} getOwnerProps={getOwnerProps} />;\n if (isLoading) return <LoadingContainer autoCompleteId={autoCompleteId} getOwnerProps={getOwnerProps} />;\n if (options.length === 0) return null;\n return (\n <StyledVirtualListWrapper tabIndex={-1} innerRef={listRef}>\n <StyledList\n // recalculate the key to force the re-render of the list and update virtualization\n key={options.length}\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 onFocus={handleOnFocus}\n data-testid={AutocompleteDataTestid.LIST}\n style={{ height: totalSize, margin: '8px 0px' }}\n getOwnerProps={getOwnerProps}\n >\n {ItemRenderer}\n </StyledList>\n </StyledVirtualListWrapper>\n );\n };\n\n return (\n <StyledListWrapper onMouseDown={preventMouseDown} minWidth={referenceElement?.offsetWidth}>\n {renderMenuContent()}\n </StyledListWrapper>\n );\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;AC0DI;AA1D3B,SAAgB,YAAY,aAAa,iBAAiB;AAC1D,SAAS,mBAAmB,YAAY,gCAAgC;AACxE,SAAS,8BAA8B;AACvC,OAAO,yBAAyB;AAChC,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAE3B,MAAM,WAAW,MAAmB;AACzC,QAAM;AAAA,IACJ,OAAO,EAAE,SAAS,WAAW,WAAW;AAAA,IACxC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI,WAAW,mBAAmB;AAClC,QAAM,EAAE,QAAQ,IAAI;AACpB,QAAM,YAAY,mBAAmB,aAAa;AAElD,QAAM,eAAe,gBAAgB;AACrC,QAAM,EAAE,MAAM,IAAI,mBAAmB,gBAAgB;AAErD,YAAU,MAAM;AACd,QAAI,CAAC,QAAS;AAkBd,YAAQ;AAAA,EACV,GAAG,CAAC,OAAO,OAAO,CAAC;AAEnB,QAAM,gBAAgB,YAAY,MAAM;AACtC,aAAS,SAAS,MAAM;AAAA,EAC1B,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,mBAA4D,YAAY,CAAC,MAAM;AACnF,MAAE,eAAe;AAAA,EACnB,GAAG,CAAC,CAAC;AAEL,QAAM,oBAAoB,MAAM;AAG9B,QAAI,WAAY,QAAO,oBAAC,qBAAkB,gBAAgC,eAA8B;AACxG,QAAI,UAAW,QAAO,oBAAC,oBAAiB,gBAAgC,eAA8B;AACtG,QAAI,QAAQ,WAAW,EAAG,QAAO;AACjC,WACE,oBAAC,4BAAyB,UAAU,IAAI,UAAU,SAChD;AAAA,MAAC;AAAA;AAAA,QAGC,MAAK;AAAA,QACL,IAAI,aAAa,cAAc;AAAA,QAG/B,cAAW;AAAA,QACX,SAAS;AAAA,QACT,eAAa,uBAAuB;AAAA,QACpC,OAAO,EAAE,QAAQ,WAAW,QAAQ,UAAU;AAAA,QAC9C;AAAA,QAEC;AAAA;AAAA,MAXI,QAAQ;AAAA,IAYf,GACF;AAAA,EAEJ;AAEA,SACE,oBAAC,qBAAkB,aAAa,kBAAkB,UAAU,kBAAkB,aAC3E,4BAAkB,GACrB;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -6,6 +6,7 @@ import { styled } from "@elliemae/ds-system";
6
6
  import { DSAutocompleteName, DSAutocompleteSlots } from "../../constants/index.js";
7
7
  import AutocompleteContext from "../../AutocompleteCTX.js";
8
8
  import { AutocompleteDataTestid } from "../../AutocompleteDataTestids.js";
9
+ import { isOptionLocked } from "../../utils/listHelper.js";
9
10
  import { Section } from "../Section.js";
10
11
  const StyledMenuItemAction = styled(DSMenuItemsAction, {
11
12
  name: DSAutocompleteName,
@@ -14,7 +15,6 @@ const StyledMenuItemAction = styled(DSMenuItemsAction, {
14
15
  const useItemRenderer = () => {
15
16
  const {
16
17
  props: { onSelect },
17
- inputRef,
18
18
  setUserTypedSomething,
19
19
  setUserJustSelectedAnOption,
20
20
  focusOptionIdx,
@@ -24,6 +24,7 @@ const useItemRenderer = () => {
24
24
  } = useContext(AutocompleteContext);
25
25
  const handleClick = useCallback(
26
26
  (option, e) => {
27
+ if (isOptionLocked(option)) return;
27
28
  onSelect(option.label, e);
28
29
  setUserJustSelectedAnOption(true);
29
30
  setUserTypedSomething(false);
@@ -32,52 +33,54 @@ const useItemRenderer = () => {
32
33
  },
33
34
  [onSelect, setUserTypedSomething, setUserJustSelectedAnOption]
34
35
  );
36
+ const virtualItems = virtualListHelpers?.getVirtualItems();
37
+ const { measureElement } = virtualListHelpers ?? {};
35
38
  return useMemo(() => {
36
- if (virtualListHelpers) {
37
- return virtualListHelpers.virtualItems.map((vItem) => {
38
- const option = options[vItem.index];
39
- const generalProps = {
40
- wrapperStyles: { position: "absolute", top: vItem.start, left: 0, width: "100%" },
41
- key: `${option.dsId}`,
42
- innerRef: vItem.measureRef,
43
- dsId: option.dsId
44
- };
45
- const getOwnerPropsArguments = () => option;
46
- if (option.type === "section") {
47
- return /* @__PURE__ */ jsx(
48
- Section,
49
- {
50
- label: option.label,
51
- ...generalProps,
52
- options: option.options,
53
- handleClick,
54
- focusOptionIdx
55
- }
56
- );
57
- }
58
- if (option.type === "option") {
59
- return /* @__PURE__ */ jsx(
60
- StyledMenuItemAction,
61
- {
62
- id: option.dsId,
63
- label: option.label,
64
- "data-testid": AutocompleteDataTestid.OPTION,
65
- disabled: option.disabled,
66
- tabIndex: 0,
67
- onClick: (e) => handleClick(option, e),
68
- isActive: option.dsId === focusOptionIdx,
69
- "aria-selected": "false",
70
- ...generalProps,
71
- getOwnerProps,
72
- getOwnerPropsArguments
73
- }
74
- );
75
- }
76
- return null;
77
- });
78
- }
79
- return null;
80
- }, [options, focusOptionIdx, inputRef, virtualListHelpers]);
39
+ if (!virtualItems) return null;
40
+ return virtualItems.map((vItem) => {
41
+ const option = options[vItem.index];
42
+ const generalProps = {
43
+ wrapperStyles: { position: "absolute", top: vItem.start, left: 0, width: "100%" },
44
+ key: `${option.dsId}`,
45
+ innerRef: measureElement,
46
+ "data-index": vItem.index,
47
+ dsId: option.dsId
48
+ };
49
+ const getOwnerPropsArguments = () => option;
50
+ if (option.type === "section") {
51
+ return /* @__PURE__ */ jsx(
52
+ Section,
53
+ {
54
+ label: option.label,
55
+ ...generalProps,
56
+ options: option.options,
57
+ handleClick,
58
+ focusOptionIdx
59
+ }
60
+ );
61
+ }
62
+ if (option.type === "option") {
63
+ return /* @__PURE__ */ jsx(
64
+ StyledMenuItemAction,
65
+ {
66
+ id: option.dsId,
67
+ label: option.label,
68
+ "data-testid": AutocompleteDataTestid.OPTION,
69
+ disabled: option.disabled,
70
+ applyAriaDisabled: option.applyAriaDisabled,
71
+ tabIndex: 0,
72
+ onClick: (e) => handleClick(option, e),
73
+ isActive: option.dsId === focusOptionIdx,
74
+ "aria-selected": "false",
75
+ ...generalProps,
76
+ getOwnerProps,
77
+ getOwnerPropsArguments
78
+ }
79
+ );
80
+ }
81
+ return null;
82
+ });
83
+ }, [virtualItems, options, focusOptionIdx, measureElement, handleClick, getOwnerProps]);
81
84
  };
82
85
  export {
83
86
  useItemRenderer
@@ -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 @typescript-eslint/no-use-before-define */\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { DSMenuItemsAction } from '@elliemae/ds-menu-items';\nimport { styled } from '@elliemae/ds-system';\nimport { DSAutocompleteName, DSAutocompleteSlots } from '../../constants/index.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport { Section } from '../Section.js';\n\nconst StyledMenuItemAction = styled(DSMenuItemsAction, {\n name: DSAutocompleteName,\n slot: DSAutocompleteSlots.OPTION,\n})``;\n\nexport const useItemRenderer = () => {\n const {\n props: { onSelect },\n inputRef,\n setUserTypedSomething,\n setUserJustSelectedAnOption,\n focusOptionIdx,\n optionsPerSection: options,\n virtualListHelpers,\n getOwnerProps,\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%' } as React.CSSProperties,\n key: `${option.dsId}`,\n innerRef: vItem.measureRef,\n dsId: option.dsId,\n };\n const getOwnerPropsArguments = () => option;\n\n if (option.type === 'section') {\n return (\n <Section\n label={option.label}\n {...generalProps}\n options={option.options}\n handleClick={handleClick}\n focusOptionIdx={focusOptionIdx}\n />\n );\n }\n if (option.type === 'option') {\n return (\n <StyledMenuItemAction\n id={option.dsId}\n label={option.label}\n data-testid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n tabIndex={0}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n aria-selected=\"false\"\n {...generalProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n );\n }\n return null;\n });\n }\n return null;\n }, [options, focusOptionIdx, inputRef, virtualListHelpers]);\n};\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACqDX;AAnDZ,SAA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;AAAA;AAAA,cACC,IAAI,OAAO;AAAA,cACX,OAAO,OAAO;AAAA,cACd,eAAa,uBAAuB;AAAA,cACpC,UAAU,OAAO;AAAA,cACjB,UAAU;AAAA,cACV,SAAS,CAAC,MAA0C,YAAY,QAAQ,CAAC;AAAA,cACzE,UAAU,OAAO,SAAS;AAAA,cAC1B,iBAAc;AAAA,cACb,GAAG;AAAA,cACJ;AAAA,cACA;AAAA;AAAA,UACF;AAAA,QAEJ;AACA,eAAO;AAAA,MACT,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 @typescript-eslint/no-use-before-define */\n/* eslint-disable react-hooks/exhaustive-deps */\nimport React, { useMemo, useContext, useCallback } from 'react';\nimport { DSMenuItemsAction } from '@elliemae/ds-menu-items';\nimport { styled } from '@elliemae/ds-system';\nimport { DSAutocompleteName, DSAutocompleteSlots } from '../../constants/index.js';\nimport AutocompleteContext from '../../AutocompleteCTX.js';\nimport { AutocompleteDataTestid } from '../../AutocompleteDataTestids.js';\nimport type { DSAutocompleteT } from '../../react-desc-prop-types.js';\nimport { isOptionLocked } from '../../utils/listHelper.js';\nimport { Section } from '../Section.js';\n\nconst StyledMenuItemAction = styled(DSMenuItemsAction, {\n name: DSAutocompleteName,\n slot: DSAutocompleteSlots.OPTION,\n})``;\n\nexport const useItemRenderer = () => {\n const {\n props: { onSelect },\n setUserTypedSomething,\n setUserJustSelectedAnOption,\n focusOptionIdx,\n optionsPerSection: options,\n virtualListHelpers,\n getOwnerProps,\n } = useContext(AutocompleteContext);\n\n const handleClick = useCallback(\n (option: DSAutocompleteT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => {\n // disabled and applyAriaDisabled options are not selectable: no selection and no consumer onSelect\n if (isOptionLocked(option)) return;\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 // v3's useVirtualizer returns the SAME Virtualizer class instance across renders (mutated in\n // place), unlike v2's useVirtual which returned a fresh object with a plain `virtualItems` array\n // property every render. Memoizing on `virtualListHelpers` itself (the stable instance) instead\n // of on the actual getVirtualItems() result means this would never recompute past the first\n // render \u2014 getVirtualItems() has its own internal memoization and returns a fresh array\n // reference only when the range/measurements genuinely change, so that's the correct dependency.\n const virtualItems = virtualListHelpers?.getVirtualItems();\n const { measureElement } = virtualListHelpers ?? {};\n\n return useMemo(() => {\n if (!virtualItems) return null;\n return virtualItems.map((vItem) => {\n const option = options[vItem.index];\n const generalProps = {\n wrapperStyles: { position: 'absolute', top: vItem.start, left: 0, width: '100%' } as React.CSSProperties,\n key: `${option.dsId}`,\n innerRef: measureElement,\n 'data-index': vItem.index,\n dsId: option.dsId,\n };\n const getOwnerPropsArguments = () => option;\n\n if (option.type === 'section') {\n return (\n <Section\n label={option.label}\n {...generalProps}\n options={option.options}\n handleClick={handleClick}\n focusOptionIdx={focusOptionIdx}\n />\n );\n }\n if (option.type === 'option') {\n return (\n <StyledMenuItemAction\n id={option.dsId}\n label={option.label}\n data-testid={AutocompleteDataTestid.OPTION}\n disabled={option.disabled}\n applyAriaDisabled={option.applyAriaDisabled}\n // every option, disabled or applyAriaDisabled included, stays focusable (navigation pattern)\n tabIndex={0}\n onClick={(e: React.MouseEvent<HTMLInputElement>) => handleClick(option, e)}\n isActive={option.dsId === focusOptionIdx}\n aria-selected=\"false\"\n {...generalProps}\n getOwnerProps={getOwnerProps}\n getOwnerPropsArguments={getOwnerPropsArguments}\n />\n );\n }\n return null;\n });\n }, [virtualItems, options, focusOptionIdx, measureElement, handleClick, getOwnerProps]);\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACiEb;AA/DV,SAAgB,SAAS,YAAY,mBAAmB;AACxD,SAAS,yBAAyB;AAClC,SAAS,cAAc;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AAAA,QACF;AAAA,MAEJ;AACA,UAAI,OAAO,SAAS,UAAU;AAC5B,eACE;AAAA,UAAC;AAAA;AAAA,YACC,IAAI,OAAO;AAAA,YACX,OAAO,OAAO;AAAA,YACd,eAAa,uBAAuB;AAAA,YACpC,UAAU,OAAO;AAAA,YACjB,mBAAmB,OAAO;AAAA,YAE1B,UAAU;AAAA,YACV,SAAS,CAAC,MAA0C,YAAY,QAAQ,CAAC;AAAA,YACzE,UAAU,OAAO,SAAS;AAAA,YAC1B,iBAAc;AAAA,YACb,GAAG;AAAA,YACJ;AAAA,YACA;AAAA;AAAA,QACF;AAAA,MAEJ;AACA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAAG,CAAC,cAAc,SAAS,gBAAgB,gBAAgB,aAAa,aAAa,CAAC;AACxF;",
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/react-desc-prop-types.ts"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport type { DSHookFloatingContextT } from '@elliemae/ds-floating-context';\n\nimport { globalAttributesPropTypes, PropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSInputTextT } from '@elliemae/ds-form-input-text';\n\nexport declare namespace DSAutocompleteT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n // this was never implemented?\n // packages/forms/ds-form-layout-autocomplete/src/parts/menu-list/useItemRenderer.tsx\n // only have code for ItemOption and ItemSectionOptions...\n // export interface ItemSeparatorOptions extends CommonItemOptions {\n // type: 'separator';\n // }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n options: ItemOption[];\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n filter: string;\n onSelect: (\n suggestedValue: string,\n e: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement>,\n ) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: DSHookFloatingContextT.PopperPlacementsT[];\n withoutPortal: boolean;\n zIndex: number;\n forceFocusFirstOptionOnType: boolean;\n }\n\n export interface OptionalProps {\n children?: React.ReactNode;\n inputProps?: DSInputTextT.Props;\n onValueChange?: (nextValue: string | number, e: React.ChangeEvent<HTMLInputElement>) => void;\n renderInput?: (props: React.InputHTMLAttributes<HTMLInputElement>) => React.ReactNode;\n isLoading?: boolean;\n isSkeleton?: boolean;\n }\n\n export interface Props\n extends Partial<DefaultProps>,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n\n export interface InternalProps\n extends DefaultProps,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n}\n\nexport const defaultProps: DSAutocompleteT.DefaultProps = {\n zIndex: 10,\n withoutPortal: false,\n forceFocusFirstOptionOnType: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'top-start'],\n};\n\nexport const DSAutocompletePropTypes: DSPropTypesSchema<DSAutocompleteT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of options')\n .defaultValue([]),\n filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),\n onSelect: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n children: PropTypes.node\n .description('React component to apply autocomplete functionality')\n .defaultValue('')\n .deprecated({ version: '3.x' }),\n inputProps: PropTypes.object.description('Props to pass to the input component').defaultValue({}),\n onValueChange: PropTypes.func.description('Function triggered when the value of the input changes').defaultValue(''),\n renderInput: PropTypes.func.description('Function to render the input').defaultValue(''),\n isLoading: PropTypes.bool\n .description('Shows a loading spinner in the menu while options are being fetched.')\n .defaultValue('false'),\n isSkeleton: PropTypes.bool.description('Displays the menu in skeleton loading mode.').defaultValue('false'),\n startPlacementPreference: PropTypes.string\n .description('Ideal preference for context placement')\n .defaultValue('bottom-start'),\n placementOrderPreference: PropTypes.arrayOf(PropTypes.string)\n .description('Placement preferences for the context menu in order of most preferred to least preferred')\n .defaultValue(\"['bottom-start', 'bottom-end']\"),\n withoutPortal: PropTypes.bool\n .description('Whether to render the context menu in a react portal or next to the input DOM element')\n .defaultValue('false (next to the input)'),\n forceFocusFirstOptionOnType: PropTypes.bool\n .description(\n 'Whether to focus the first option when typing (NOT RECOMMENDED AND BREAKING A11Y STANDARDS + ALL USERS USABILITY)',\n )\n .defaultValue('false'),\n};\n\nexport const DSAutocompletePropTypesSchema = DSAutocompletePropTypes as unknown as ValidationMap<DSAutocompleteT.Props>;\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACMvB,SAAS,2BAA2B,WAAW,wBAAwB;AA4EhE,MAAM,eAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,6BAA6B;AAAA,EAC7B,0BAA0B;AAAA,EAC1B,0BAA0B,CAAC,gBAAgB,WAAW;AACxD;AAEO,MAAM,0BAAoE;AAAA,EAC/E,GAAG;AAAA,EACH,GAAG;AAAA,EACH,SAAS,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC,EAC7D,WAAW,YAAY,iBAAiB,EACxC,aAAa,CAAC,CAAC;AAAA,EAClB,QAAQ,UAAU,OAAO,WAAW,YAAY,oCAAoC,EAAE,aAAa,EAAE;AAAA,EACrG,UAAU,UAAU,KAAK,WACtB,YAAY,iFAAiF,EAC7F,aAAa,EAAE;AAAA,EAClB,UAAU,UAAU,KACjB,YAAY,qDAAqD,EACjE,aAAa,EAAE,EACf,WAAW,EAAE,SAAS,MAAM,CAAC;AAAA,EAChC,YAAY,UAAU,OAAO,YAAY,sCAAsC,EAAE,aAAa,CAAC,CAAC;AAAA,EAChG,eAAe,UAAU,KAAK,YAAY,wDAAwD,EAAE,aAAa,EAAE;AAAA,EACnH,aAAa,UAAU,KAAK,YAAY,8BAA8B,EAAE,aAAa,EAAE;AAAA,EACvF,WAAW,UAAU,KAClB,YAAY,sEAAsE,EAClF,aAAa,OAAO;AAAA,EACvB,YAAY,UAAU,KAAK,YAAY,6CAA6C,EAAE,aAAa,OAAO;AAAA,EAC1G,0BAA0B,UAAU,OACjC,YAAY,wCAAwC,EACpD,aAAa,cAAc;AAAA,EAC9B,0BAA0B,UAAU,QAAQ,UAAU,MAAM,EACzD,YAAY,0FAA0F,EACtG,aAAa,gCAAgC;AAAA,EAChD,eAAe,UAAU,KACtB,YAAY,uFAAuF,EACnG,aAAa,2BAA2B;AAAA,EAC3C,6BAA6B,UAAU,KACpC;AAAA,IACC;AAAA,EACF,EACC,aAAa,OAAO;AACzB;AAEO,MAAM,gCAAgC;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable no-unused-vars */\nimport type React from 'react';\nimport type { GlobalAttributesT, XstyledProps, DSPropTypesSchema, ValidationMap } from '@elliemae/ds-props-helpers';\nimport type { DSHookFloatingContextT } from '@elliemae/ds-floating-context';\n\nimport { globalAttributesPropTypes, PropTypes, xstyledPropTypes } from '@elliemae/ds-props-helpers';\nimport type { DSInputTextT } from '@elliemae/ds-form-input-text';\n\nexport declare namespace DSAutocompleteT {\n export interface CommonItemOptions {\n dsId: string;\n disabled?: boolean;\n render?: React.ComponentType<unknown>;\n }\n\n export interface ItemSeparatorOptions extends CommonItemOptions {\n type: 'separator';\n }\n // this was never implemented?\n // packages/forms/ds-form-layout-autocomplete/src/parts/menu-list/useItemRenderer.tsx\n // only have code for ItemOption and ItemSectionOptions...\n // export interface ItemSeparatorOptions extends CommonItemOptions {\n // type: 'separator';\n // }\n\n export interface ItemSectionOptions extends CommonItemOptions {\n type: 'section';\n label: string;\n options: ItemOption[];\n }\n\n export interface ItemOption extends CommonItemOptions {\n value: string;\n label: string;\n type: 'option';\n applyAriaDisabled?: boolean;\n }\n\n export type OptionTypes = ItemOption | ItemSectionOptions;\n\n export type SelectedOptionsT = ItemOption[] | ItemOption | null;\n\n export interface RequiredProps {\n options: OptionTypes[];\n filter: string;\n onSelect: (\n suggestedValue: string,\n e: React.KeyboardEvent<HTMLInputElement> | React.MouseEvent<HTMLInputElement>,\n ) => void;\n }\n export interface DefaultProps {\n startPlacementPreference: string;\n placementOrderPreference: DSHookFloatingContextT.PopperPlacementsT[];\n withoutPortal: boolean;\n zIndex: number;\n forceFocusFirstOptionOnType: boolean;\n }\n\n export interface OptionalProps {\n children?: React.ReactNode;\n inputProps?: DSInputTextT.Props;\n onValueChange?: (nextValue: string | number, e: React.ChangeEvent<HTMLInputElement>) => void;\n renderInput?: (props: React.InputHTMLAttributes<HTMLInputElement>) => React.ReactNode;\n isLoading?: boolean;\n isSkeleton?: boolean;\n }\n\n export interface Props\n extends\n Partial<DefaultProps>,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n\n export interface InternalProps\n extends\n DefaultProps,\n RequiredProps,\n OptionalProps,\n Omit<GlobalAttributesT, keyof DefaultProps | keyof RequiredProps | keyof OptionalProps>,\n Omit<XstyledProps, keyof DefaultProps> {}\n}\n\nexport const defaultProps: DSAutocompleteT.DefaultProps = {\n zIndex: 10,\n withoutPortal: false,\n forceFocusFirstOptionOnType: false,\n startPlacementPreference: 'bottom-start',\n placementOrderPreference: ['bottom-start', 'top-start'],\n};\n\nexport const DSAutocompletePropTypes: DSPropTypesSchema<DSAutocompleteT.Props> = {\n ...globalAttributesPropTypes,\n ...xstyledPropTypes,\n options: PropTypes.oneOfType([PropTypes.array, PropTypes.object])\n .isRequired.description('List of options')\n .defaultValue([]),\n filter: PropTypes.string.isRequired.description('String value to filter the options').defaultValue(''),\n onSelect: PropTypes.func.isRequired\n .description('function triggered when an option is selected it will send the options selected')\n .defaultValue(''),\n children: PropTypes.node\n .description('React component to apply autocomplete functionality')\n .defaultValue('')\n .deprecated({ version: '3.x' }),\n inputProps: PropTypes.object.description('Props to pass to the input component').defaultValue({}),\n onValueChange: PropTypes.func.description('Function triggered when the value of the input changes').defaultValue(''),\n renderInput: PropTypes.func.description('Function to render the input').defaultValue(''),\n isLoading: PropTypes.bool\n .description('Shows a loading spinner in the menu while options are being fetched.')\n .defaultValue('false'),\n isSkeleton: PropTypes.bool.description('Displays the menu in skeleton loading mode.').defaultValue('false'),\n startPlacementPreference: PropTypes.string\n .description('Ideal preference for context placement')\n .defaultValue('bottom-start'),\n placementOrderPreference: PropTypes.arrayOf(PropTypes.string)\n .description('Placement preferences for the context menu in order of most preferred to least preferred')\n .defaultValue(\"['bottom-start', 'bottom-end']\"),\n withoutPortal: PropTypes.bool\n .description('Whether to render the context menu in a react portal or next to the input DOM element')\n .defaultValue('false (next to the input)'),\n forceFocusFirstOptionOnType: PropTypes.bool\n .description(\n 'Whether to focus the first option when typing (NOT RECOMMENDED AND BREAKING A11Y STANDARDS + ALL USERS USABILITY)',\n )\n .defaultValue('false'),\n};\n\nexport const DSAutocompletePropTypesSchema = DSAutocompletePropTypes as unknown as ValidationMap<DSAutocompleteT.Props>;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACMvB,SAAS,2BAA2B,WAAW,wBAAwB;AA+EhE,MA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ption = (options) => {
19
19
  return "";
20
20
  };
21
21
  const isOptionFocuseable = (opt) => !["section", "separator"].includes(opt.type);
22
+ const isOptionLocked = (opt) => opt.type === "option" && Boolean(opt.disabled || opt.applyAriaDisabled);
22
23
  export {
23
24
  findInCircularList,
24
25
  getFirstOption,
25
26
  getOptions,
26
27
  getSelectableOptions,
27
28
  isOptionFocuseable,
29
+ isOptionLocked,
28
30
  isSelectedValueEmpty,
29
31
  isSelectedValueMultiple
30
32
  };
@@ -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", "/* eslint-disable max-params */\n/* eslint-disable no-nested-ternary */\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\nexport const getSelectableOptions = (\n options: Array<DSAutocompleteT.OptionTypes>,\n): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option' && !option.disabled) : [];\n\nexport const getOptions = (options: Array<DSAutocompleteT.OptionTypes>): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option') : [];\n\nexport const isSelectedValueEmpty = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => (Array.isArray(value) ? value.length === 0 : !value);\n\nexport const isSelectedValueMultiple = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => Array.isArray(value);\n\nexport const findInCircularList = (\n list: DSAutocompleteT.OptionTypes[],\n from: number,\n criteria: (item: DSAutocompleteT.OptionTypes) => boolean,\n step = 1,\n): number => {\n let i = from === -1 ? (step > 0 ? 0 : list.length - 1) : (from + step + list.length) % list.length;\n\n while (i !== from) {\n if (criteria(list[i])) return i;\n i = (i + step + list.length) % list.length;\n }\n return from;\n};\nexport const getFirstOption = (options: DSAutocompleteT.OptionTypes[]) => {\n for (let i = 0; i < options.length; i += 1)\n if (!['section', 'separator'].includes(options[i].type)) {\n return options[i].dsId;\n }\n return '';\n};\n\nexport const isOptionFocuseable = (opt: DSAutocompleteT.OptionTypes): boolean =>\n !['section', 'separator'].includes(opt.type);\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACIhB,MAAM,uBAAuB,CAClC,YAEA,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,QAAQ,IAAI,CAAC;AAEjF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,QAAQ,IAAI,CAAC;AAE7D,MAAM,uBAAuB,CAClC,UACa,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,CAAC;AAErD,MAAM,0BAA0B,CACrC,UACY,MAAM,QAAQ,KAAK;AAE1B,MAAM,qBAAqB,CAChC,MACA,MACA,UACA,OAAO,MACI;AACX,MAAI,IAAI,SAAS,KAAM,OAAO,IAAI,IAAI,KAAK,SAAS,KAAM,OAAO,OAAO,KAAK,UAAU,KAAK;AAE5F,SAAO,MAAM,MAAM;AACjB,QAAI,SAAS,KAAK,CAAC,CAAC,EAAG,QAAO;AAC9B,SAAK,IAAI,OAAO,KAAK,UAAU,KAAK;AAAA,EACtC;AACA,SAAO;AACT;AACO,MAAM,iBAAiB,CAAC,YAA2C;AACxE,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK;AACvC,QAAI,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,QAAQ,CAAC,EAAE,IAAI,GAAG;AACvD,aAAO,QAAQ,CAAC,EAAE;AAAA,IACpB;AACF,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,QACjC,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\n/* eslint-disable no-nested-ternary */\nimport type { DSAutocompleteT } from '../react-desc-prop-types.js';\n\nexport const getSelectableOptions = (\n options: Array<DSAutocompleteT.OptionTypes>,\n): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option' && !option.disabled) : [];\n\nexport const getOptions = (options: Array<DSAutocompleteT.OptionTypes>): Array<DSAutocompleteT.OptionTypes> =>\n options ? options.filter((option) => option.type === 'option') : [];\n\nexport const isSelectedValueEmpty = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => (Array.isArray(value) ? value.length === 0 : !value);\n\nexport const isSelectedValueMultiple = (\n value: DSAutocompleteT.OptionTypes | Array<DSAutocompleteT.OptionTypes>,\n): boolean => Array.isArray(value);\n\nexport const findInCircularList = (\n list: DSAutocompleteT.OptionTypes[],\n from: number,\n criteria: (item: DSAutocompleteT.OptionTypes) => boolean,\n step = 1,\n): number => {\n let i = from === -1 ? (step > 0 ? 0 : list.length - 1) : (from + step + list.length) % list.length;\n\n while (i !== from) {\n if (criteria(list[i])) return i;\n i = (i + step + list.length) % list.length;\n }\n return from;\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\n// options are a navigation pattern: every option, disabled or applyAriaDisabled included, stays reachable by arrow\n// navigation and focus; only the activation (click, Enter) is withheld (see isOptionLocked)\nexport const isOptionFocuseable = (opt: DSAutocompleteT.OptionTypes): boolean =>\n !['section', 'separator'].includes(opt.type);\n\n// disabled and applyAriaDisabled options are never selectable\nexport const isOptionLocked = (opt: DSAutocompleteT.OptionTypes): boolean =>\n opt.type === 'option' && Boolean(opt.disabled || opt.applyAriaDisabled);\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACIhB,MAAM,uBAAuB,CAClC,YAEA,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,YAAY,CAAC,OAAO,QAAQ,IAAI,CAAC;AAEjF,MAAM,aAAa,CAAC,YACzB,UAAU,QAAQ,OAAO,CAAC,WAAW,OAAO,SAAS,QAAQ,IAAI,CAAC;AAE7D,MAAM,uBAAuB,CAClC,UACa,MAAM,QAAQ,KAAK,IAAI,MAAM,WAAW,IAAI,CAAC;AAErD,MAAM,0BAA0B,CACrC,UACY,MAAM,QAAQ,KAAK;AAE1B,MAAM,qBAAqB,CAChC,MACA,MACA,UACA,OAAO,MACI;AACX,MAAI,IAAI,SAAS,KAAM,OAAO,IAAI,IAAI,KAAK,SAAS,KAAM,OAAO,OAAO,KAAK,UAAU,KAAK;AAE5F,SAAO,MAAM,MAAM;AACjB,QAAI,SAAS,KAAK,CAAC,CAAC,EAAG,QAAO;AAC9B,SAAK,IAAI,OAAO,KAAK,UAAU,KAAK;AAAA,EACtC;AACA,SAAO;AACT;AACO,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;AAIO,MAAM,qBAAqB,CAAC,QACjC,CAAC,CAAC,WAAW,WAAW,EAAE,SAAS,IAAI,IAAI;AAGtC,MAAM,iBAAiB,CAAC,QAC7B,IAAI,SAAS,YAAY,QAAQ,IAAI,YAAY,IAAI,iBAAiB;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,10 @@
1
- import { useVirtual, type ScrollToIndexOptions } from 'react-virtual';
1
+ import { useVirtualizer, type ScrollToOptions } from '@tanstack/react-virtual';
2
2
  import type { DSAutocompleteT } from '../react-desc-prop-types.js';
3
3
  import type { useRefs } from './useRefs.js';
4
4
  export declare const useVirtualization: ({ references, options, }: {
5
5
  references: ReturnType<typeof useRefs>;
6
6
  options: DSAutocompleteT.InternalProps["options"];
7
7
  }) => {
8
- virtualListHelpers: ReturnType<typeof useVirtual>;
9
- scrollOptionIntoView: (dsId: string, opts?: ScrollToIndexOptions) => void;
8
+ virtualListHelpers: ReturnType<typeof useVirtualizer<HTMLDivElement, HTMLElement>>;
9
+ scrollOptionIntoView: (dsId: string, opts?: ScrollToOptions) => void;
10
10
  };
@@ -3,7 +3,8 @@ import type { DSAutocompleteT } from '../react-desc-prop-types.js';
3
3
  interface SectionProps {
4
4
  label: string;
5
5
  wrapperStyles: React.CSSProperties;
6
- innerRef: (instance: HTMLDivElement | null) => void;
6
+ innerRef: (instance: HTMLElement | null) => void;
7
+ 'data-index': number;
7
8
  options: DSAutocompleteT.ItemOption[];
8
9
  handleClick: (option: DSAutocompleteT.ItemOption, e: React.MouseEvent<HTMLInputElement>) => void;
9
10
  focusOptionIdx: string;
@@ -20,6 +20,7 @@ export declare namespace DSAutocompleteT {
20
20
  value: string;
21
21
  label: string;
22
22
  type: 'option';
23
+ applyAriaDisabled?: boolean;
23
24
  }
24
25
  type OptionTypes = ItemOption | ItemSectionOptions;
25
26
  type SelectedOptionsT = ItemOption[] | ItemOption | null;
@@ -6,3 +6,4 @@ export declare const isSelectedValueMultiple: (value: DSAutocompleteT.OptionType
6
6
  export declare const findInCircularList: (list: DSAutocompleteT.OptionTypes[], from: number, criteria: (item: DSAutocompleteT.OptionTypes) => boolean, step?: number) => number;
7
7
  export declare const getFirstOption: (options: DSAutocompleteT.OptionTypes[]) => string;
8
8
  export declare const isOptionFocuseable: (opt: DSAutocompleteT.OptionTypes) => boolean;
9
+ export declare const isOptionLocked: (opt: DSAutocompleteT.OptionTypes) => boolean;