@cloudscape-design/components 3.0.1411 → 3.0.1412

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 (105) hide show
  1. package/action-card/internal.d.ts +10 -2
  2. package/action-card/internal.d.ts.map +1 -1
  3. package/action-card/internal.js +5 -5
  4. package/action-card/internal.js.map +1 -1
  5. package/action-card/styles.css.js +18 -17
  6. package/action-card/styles.scoped.css +274 -202
  7. package/action-card/styles.selectors.js +18 -17
  8. package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.d.ts.map +1 -1
  9. package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js +3 -1
  10. package/app-layout/visual-refresh-toolbar/skeleton/toolbar-container.js.map +1 -1
  11. package/button-dropdown/filter.d.ts +1 -1
  12. package/internal/base-component/styles.scoped.css +1 -1
  13. package/internal/components/listbox/interfaces.d.ts +12 -0
  14. package/internal/components/listbox/interfaces.d.ts.map +1 -0
  15. package/internal/components/listbox/interfaces.js +2 -0
  16. package/internal/components/listbox/interfaces.js.map +1 -0
  17. package/internal/components/listbox/parts/get-item-props.d.ts +1 -3
  18. package/internal/components/listbox/parts/get-item-props.d.ts.map +1 -1
  19. package/internal/components/listbox/parts/get-item-props.js +1 -2
  20. package/internal/components/listbox/parts/get-item-props.js.map +1 -1
  21. package/internal/components/listbox/parts/item.d.ts +43 -0
  22. package/internal/components/listbox/parts/item.d.ts.map +1 -0
  23. package/internal/components/listbox/parts/item.js +184 -0
  24. package/internal/components/listbox/parts/item.js.map +1 -0
  25. package/internal/components/listbox/parts/plain-list.d.ts +23 -0
  26. package/internal/components/listbox/parts/plain-list.d.ts.map +1 -0
  27. package/{select → internal/components/listbox}/parts/plain-list.js +9 -10
  28. package/internal/components/listbox/parts/plain-list.js.map +1 -0
  29. package/internal/components/listbox/parts/render-options.d.ts +3 -4
  30. package/internal/components/listbox/parts/render-options.d.ts.map +1 -1
  31. package/internal/components/listbox/parts/render-options.js +3 -6
  32. package/internal/components/listbox/parts/render-options.js.map +1 -1
  33. package/internal/components/listbox/use-listbox.d.ts +95 -0
  34. package/internal/components/listbox/use-listbox.d.ts.map +1 -0
  35. package/internal/components/listbox/use-listbox.js +117 -0
  36. package/internal/components/listbox/use-listbox.js.map +1 -0
  37. package/internal/components/listbox/use-type-ahead.d.ts +18 -0
  38. package/internal/components/listbox/use-type-ahead.d.ts.map +1 -0
  39. package/{select/utils/use-native-search.js → internal/components/listbox/use-type-ahead.js} +8 -8
  40. package/internal/components/listbox/use-type-ahead.js.map +1 -0
  41. package/internal/components/listbox/utils/navigation.d.ts +27 -0
  42. package/internal/components/listbox/utils/navigation.d.ts.map +1 -0
  43. package/internal/components/listbox/utils/navigation.js +22 -0
  44. package/internal/components/listbox/utils/navigation.js.map +1 -0
  45. package/internal/components/listbox/utils/option-props.d.ts +35 -0
  46. package/internal/components/listbox/utils/option-props.d.ts.map +1 -0
  47. package/internal/components/listbox/utils/option-props.js +51 -0
  48. package/internal/components/listbox/utils/option-props.js.map +1 -0
  49. package/internal/components/options-list/utils/use-keyboard.d.ts +1 -1
  50. package/internal/components/options-list/utils/use-keyboard.d.ts.map +1 -1
  51. package/internal/components/options-list/utils/use-keyboard.js +2 -2
  52. package/internal/components/options-list/utils/use-keyboard.js.map +1 -1
  53. package/internal/environment.js +2 -2
  54. package/internal/environment.json +2 -2
  55. package/internal/manifest.json +1 -1
  56. package/item-card/internal.d.ts +11 -1
  57. package/item-card/internal.d.ts.map +1 -1
  58. package/item-card/internal.js +4 -4
  59. package/item-card/internal.js.map +1 -1
  60. package/item-card/style.d.ts.map +1 -1
  61. package/item-card/style.js +6 -1
  62. package/item-card/style.js.map +1 -1
  63. package/item-card/styles.css.js +14 -14
  64. package/item-card/styles.scoped.css +125 -63
  65. package/item-card/styles.selectors.js +14 -14
  66. package/manifest.json +2 -2
  67. package/multiselect/embedded.d.ts.map +1 -1
  68. package/multiselect/embedded.js +2 -2
  69. package/multiselect/embedded.js.map +1 -1
  70. package/multiselect/internal.d.ts.map +1 -1
  71. package/multiselect/internal.js +2 -2
  72. package/multiselect/internal.js.map +1 -1
  73. package/multiselect/use-multiselect.d.ts +2 -3
  74. package/multiselect/use-multiselect.d.ts.map +1 -1
  75. package/multiselect/use-multiselect.js +7 -18
  76. package/multiselect/use-multiselect.js.map +1 -1
  77. package/package.json +1 -1
  78. package/select/internal.d.ts.map +1 -1
  79. package/select/internal.js +9 -19
  80. package/select/internal.js.map +1 -1
  81. package/select/parts/filter.d.ts +1 -1
  82. package/select/parts/virtual-list.d.ts +3 -2
  83. package/select/parts/virtual-list.d.ts.map +1 -1
  84. package/select/parts/virtual-list.js +7 -8
  85. package/select/parts/virtual-list.js.map +1 -1
  86. package/select/utils/use-select.d.ts +18 -11
  87. package/select/utils/use-select.d.ts.map +1 -1
  88. package/select/utils/use-select.js +41 -117
  89. package/select/utils/use-select.js.map +1 -1
  90. package/styling/action-card.scss +56 -0
  91. package/styling/item-card.scss +81 -0
  92. package/select/parts/item.d.ts +0 -33
  93. package/select/parts/item.d.ts.map +0 -1
  94. package/select/parts/item.js +0 -94
  95. package/select/parts/item.js.map +0 -1
  96. package/select/parts/multiselect-item.d.ts +0 -14
  97. package/select/parts/multiselect-item.d.ts.map +0 -1
  98. package/select/parts/multiselect-item.js +0 -112
  99. package/select/parts/multiselect-item.js.map +0 -1
  100. package/select/parts/plain-list.d.ts +0 -26
  101. package/select/parts/plain-list.d.ts.map +0 -1
  102. package/select/parts/plain-list.js.map +0 -1
  103. package/select/utils/use-native-search.d.ts +0 -18
  104. package/select/utils/use-native-search.d.ts.map +0 -1
  105. package/select/utils/use-native-search.js.map +0 -1
@@ -2,19 +2,19 @@
2
2
  // es-module interop with Babel and Typescript
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  module.exports.default = {
5
- "root": "awsui_root_n1fwt_1gs8v_13",
6
- "header-inner": "awsui_header-inner_n1fwt_1gs8v_45",
7
- "header": "awsui_header_n1fwt_1gs8v_45",
8
- "body": "awsui_body_n1fwt_1gs8v_54",
9
- "footer": "awsui_footer_n1fwt_1gs8v_62",
10
- "refresh": "awsui_refresh_n1fwt_1gs8v_128",
11
- "highlighted": "awsui_highlighted_n1fwt_1gs8v_131",
12
- "variant-embedded": "awsui_variant-embedded_n1fwt_1gs8v_138",
13
- "inner-card": "awsui_inner-card_n1fwt_1gs8v_138",
14
- "variant-default": "awsui_variant-default_n1fwt_1gs8v_138",
15
- "no-padding": "awsui_no-padding_n1fwt_1gs8v_144",
16
- "with-actions": "awsui_with-actions_n1fwt_1gs8v_169",
17
- "full-height": "awsui_full-height_n1fwt_1gs8v_215",
18
- "description": "awsui_description_n1fwt_1gs8v_219"
5
+ "root": "awsui_root_n1fwt_1phaf_13",
6
+ "header": "awsui_header_n1fwt_1phaf_66",
7
+ "header-inner": "awsui_header-inner_n1fwt_1phaf_69",
8
+ "body": "awsui_body_n1fwt_1phaf_78",
9
+ "footer": "awsui_footer_n1fwt_1phaf_86",
10
+ "refresh": "awsui_refresh_n1fwt_1phaf_158",
11
+ "highlighted": "awsui_highlighted_n1fwt_1phaf_161",
12
+ "variant-embedded": "awsui_variant-embedded_n1fwt_1phaf_168",
13
+ "inner-card": "awsui_inner-card_n1fwt_1phaf_168",
14
+ "variant-default": "awsui_variant-default_n1fwt_1phaf_168",
15
+ "no-padding": "awsui_no-padding_n1fwt_1phaf_174",
16
+ "with-actions": "awsui_with-actions_n1fwt_1phaf_215",
17
+ "full-height": "awsui_full-height_n1fwt_1phaf_277",
18
+ "description": "awsui_description_n1fwt_1phaf_281"
19
19
  };
20
20
 
package/manifest.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "artifactId": "13464453318",
2
+ "artifactId": "13517858555",
3
3
  "repoName": "components",
4
- "commitSha": "f6f7a3344240c84397cb38a62b3cbd013462cb3e"
4
+ "commitSha": "d25043b390a04b3617641e16ef5f92fdbf69131b"
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../../src/multiselect/embedded.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,MAAM,MAAM,wBAAwB,GAAG,YAAY,CACjD,IAAI,CACF,gBAAgB,EACd,SAAS,GACT,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,mBAAmB,GACnB,eAAe,GACf,YAAY,GACZ,WAAW,GACX,UAAU,GACV,aAAa,GACb,aAAa,GACb,cAAc,GACd,WAAW,GACX,cAAc,GACd,OAAO,GACP,SAAS,CACZ,EACD,SAAS,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,CAC/D,GAAG;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/B,QAAA,MAAM,mBAAmB;;;;;;oBAFH,MAAM;8CA4D3B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"embedded.d.ts","sourceRoot":"","sources":["../../../src/multiselect/embedded.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAKhD,MAAM,MAAM,wBAAwB,GAAG,YAAY,CACjD,IAAI,CACF,gBAAgB,EACd,SAAS,GACT,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,mBAAmB,GACnB,eAAe,GACf,YAAY,GACZ,WAAW,GACX,UAAU,GACV,aAAa,GACb,aAAa,GACb,cAAc,GACd,WAAW,GACX,cAAc,GACd,OAAO,GACP,SAAS,CACZ,EACD,SAAS,GAAG,iBAAiB,GAAG,eAAe,GAAG,YAAY,CAC/D,GAAG;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/B,QAAA,MAAM,mBAAmB;;;;;;oBAFH,MAAM;8CA2D3B,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -4,8 +4,8 @@ import React from 'react';
4
4
  import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
5
5
  import { useFormFieldContext } from '../contexts/form-field';
6
6
  import DropdownFooter from '../internal/components/dropdown-footer';
7
+ import PlainList from '../internal/components/listbox/parts/plain-list';
7
8
  import ScreenreaderOnly from '../internal/components/screenreader-only';
8
- import PlainList from '../select/parts/plain-list';
9
9
  import VirtualList from '../select/parts/virtual-list';
10
10
  import { useMultiselect } from './use-multiselect';
11
11
  import styles from './styles.css.js';
@@ -31,7 +31,7 @@ const EmbeddedMultiselect = React.forwardRef(({ options, filteringType, ariaLabe
31
31
  const ListComponent = virtualScroll ? VirtualList : PlainList;
32
32
  const status = multiselectProps.dropdownStatus;
33
33
  return (React.createElement("div", { className: styles.embedded },
34
- React.createElement(ListComponent, { menuProps: multiselectProps.getMenuProps(), getOptionProps: multiselectProps.getOptionProps, filteredOptions: multiselectProps.filteredOptions, filteringValue: filteringText, ref: multiselectProps.scrollToIndex, hasDropdownStatus: status.content !== null, checkboxes: true, useInteractiveGroups: true, screenReaderContent: multiselectProps.announcement, highlightType: multiselectProps.highlightType, isMultiSelect: true }),
34
+ React.createElement(ListComponent, { listProps: multiselectProps.getMenuProps(), getOptionProps: multiselectProps.getOptionProps, filteredOptions: multiselectProps.filteredOptions, filteringValue: filteringText, ref: multiselectProps.scrollToIndex, hasDropdownStatus: status.content !== null, selectionType: "multi", screenReaderContent: multiselectProps.announcement, highlightType: multiselectProps.highlightType, isMultiSelect: true }),
35
35
  status.content && React.createElement(DropdownFooter, { content: status.content, id: footerId }),
36
36
  React.createElement(ScreenreaderOnly, { id: ariaLabelId }, ariaLabel)));
37
37
  });
@@ -1 +1 @@
1
- {"version":3,"file":"embedded.js","sourceRoot":"","sources":["../../../src/multiselect/embedded.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAs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AAM,CAAC,QAAQ;QAC7B,oBAAC,aAAa,IACZ,SAAS,EAAE,gBAAgB,CAAC,YAAY,EAAE,EAC1C,cAAc,EAAE,gBAAgB,CAAC,cAAc,EAC/C,eAAe,EAAE,gBAAgB,CAAC,eAAe,EACjD,cAAc,EAAE,aAAa,EAC7B,GAAG,EAAE,gBAAgB,CAAC,aAAa,EACnC,iBAAiB,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,EAC1C,UAAU,EAAE,IAAI,EAChB,oBAAoB,EAAE,IAAI,EAC1B,mBAAmB,EAAE,gBAAgB,CAAC,YAAY,EAClD,aAAa,EAAE,gBAAgB,CAAC,aAAa,EAC7C,aAAa,EAAE,IAAI,GACnB;QAED,MAAM,CAAC,OAAO,IAAI,oBAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,GAAI;QAE5E,oBAAC,gBAAgB,IAAC,EAAE,EAAE,WAAW,IAAG,SAAS,CAAoB,CAC7D,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useFormFieldContext } from '../contexts/form-field';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { SomeRequired } from '../internal/types';\nimport PlainList from '../select/parts/plain-list';\nimport VirtualList from '../select/parts/virtual-list';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\nexport type EmbeddedMultiselectProps = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'ariaLabel'\n | 'filteringType'\n | 'deselectAriaLabel'\n | 'virtualScroll'\n | 'statusType'\n | 'controlId'\n | 'onChange'\n | 'onLoadItems'\n | 'loadingText'\n | 'finishedText'\n | 'errorText'\n | 'recoveryText'\n | 'empty'\n | 'noMatch'\n >,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType'\n> & { filteringText?: string };\n\nconst EmbeddedMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n ariaLabel,\n selectedOptions,\n deselectAriaLabel,\n virtualScroll,\n filteringText = '',\n ...restProps\n }: EmbeddedMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const formFieldContext = useFormFieldContext(restProps);\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled: false,\n deselectAriaLabel,\n controlId: formFieldContext.controlId,\n ariaLabelId,\n footerId,\n filteringValue: filteringText,\n externalRef,\n keepOpen: true,\n embedded: true,\n ...restProps,\n });\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n const status = multiselectProps.dropdownStatus;\n\n return (\n <div className={styles.embedded}>\n <ListComponent\n menuProps={multiselectProps.getMenuProps()}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringText}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={status.content !== null}\n checkboxes={true}\n useInteractiveGroups={true}\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n isMultiSelect={true}\n />\n\n {status.content && <DropdownFooter content={status.content} id={footerId} />}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel}</ScreenreaderOnly>\n </div>\n );\n }\n);\n\nexport default EmbeddedMultiselect;\n"]}
1
+ {"version":3,"file":"embedded.js","sourceRoot":"","sources":["../../../src/multiselect/embedded.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,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AC1C,cAAc,EAAE,gBAAgB,CAAC,cAAc,EAC/C,eAAe,EAAE,gBAAgB,CAAC,eAAe,EACjD,cAAc,EAAE,aAAa,EAC7B,GAAG,EAAE,gBAAgB,CAAC,aAAa,EACnC,iBAAiB,EAAE,MAAM,CAAC,OAAO,KAAK,IAAI,EAC1C,aAAa,EAAC,OAAO,EACrB,mBAAmB,EAAE,gBAAgB,CAAC,YAAY,EAClD,aAAa,EAAE,gBAAgB,CAAC,aAAa,EAC7C,aAAa,EAAE,IAAI,GACnB;QAED,MAAM,CAAC,OAAO,IAAI,oBAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,GAAI;QAE5E,oBAAC,gBAAgB,IAAC,EAAE,EAAE,WAAW,IAAG,SAAS,CAAoB,CAC7D,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useFormFieldContext } from '../contexts/form-field';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport PlainList from '../internal/components/listbox/parts/plain-list';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { SomeRequired } from '../internal/types';\nimport VirtualList from '../select/parts/virtual-list';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\nexport type EmbeddedMultiselectProps = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'ariaLabel'\n | 'filteringType'\n | 'deselectAriaLabel'\n | 'virtualScroll'\n | 'statusType'\n | 'controlId'\n | 'onChange'\n | 'onLoadItems'\n | 'loadingText'\n | 'finishedText'\n | 'errorText'\n | 'recoveryText'\n | 'empty'\n | 'noMatch'\n >,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType'\n> & { filteringText?: string };\n\nconst EmbeddedMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n ariaLabel,\n selectedOptions,\n deselectAriaLabel,\n virtualScroll,\n filteringText = '',\n ...restProps\n }: EmbeddedMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const formFieldContext = useFormFieldContext(restProps);\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled: false,\n deselectAriaLabel,\n controlId: formFieldContext.controlId,\n ariaLabelId,\n footerId,\n filteringValue: filteringText,\n externalRef,\n keepOpen: true,\n embedded: true,\n ...restProps,\n });\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n const status = multiselectProps.dropdownStatus;\n\n return (\n <div className={styles.embedded}>\n <ListComponent\n listProps={multiselectProps.getMenuProps()}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringText}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={status.content !== null}\n selectionType=\"multi\"\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n isMultiSelect={true}\n />\n\n {status.content && <DropdownFooter content={status.content} id={footerId} />}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel}</ScreenreaderOnly>\n </div>\n );\n }\n);\n\nexport default EmbeddedMultiselect;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAQ5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAS3F,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAchD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAID,QAAA,MAAM,mBAAmB;;;;;;;;sBAdH,eAAe;8CA8QpC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAS5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAQ3F,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAchD,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,oBAAoB,CAAC;CAC9B;AAID,QAAA,MAAM,mBAAmB;;;;;;;;sBAdH,eAAe;8CA6QpC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
@@ -8,6 +8,7 @@ import { useInternalI18n } from '../i18n/context';
8
8
  import { getBaseProps } from '../internal/base-component';
9
9
  import { getBreakpointValue } from '../internal/breakpoints';
10
10
  import DropdownFooter from '../internal/components/dropdown-footer/index.js';
11
+ import PlainList from '../internal/components/listbox/parts/plain-list';
11
12
  import ScreenreaderOnly from '../internal/components/screenreader-only';
12
13
  import { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';
13
14
  import { useFormFieldContext } from '../internal/context/form-field-context';
@@ -15,7 +16,6 @@ import { warnOnUnsupportedGroupedControlProps } from '../internal/grouped-contro
15
16
  import { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';
16
17
  import { joinStrings } from '../internal/utils/strings';
17
18
  import Filter from '../select/parts/filter';
18
- import PlainList from '../select/parts/plain-list';
19
19
  import Trigger from '../select/parts/trigger';
20
20
  import VirtualList from '../select/parts/virtual-list';
21
21
  import { composeDropdownContent } from '../select/utils/dropdown-customization';
@@ -123,7 +123,7 @@ const InternalMultiselect = React.forwardRef(({ options, filteringType, filterin
123
123
  ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)
124
124
  : undefined, open: multiselectProps.isOpen, minWidth: getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth }), maxWidth: getBreakpointValue('xxs'), trigger: trigger, header: dropdownHeader, footer: dropdownFooter, expandToViewport: effectiveExpandToViewport,
125
125
  // Forces dropdown position recalculation when new options are loaded
126
- contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { renderOption: renderOption, listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: multiselectProps.isOpen ? dropdownStatus.content : null, id: footerId })) : null, menuProps: { ...multiselectProps.getMenuProps(), ariaRequired }, getOptionProps: multiselectProps.getOptionProps, filteredOptions: multiselectProps.filteredOptions, filteringValue: filteringValue, ref: multiselectProps.scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, checkboxes: true, useInteractiveGroups: true, screenReaderContent: multiselectProps.announcement, highlightType: multiselectProps.highlightType, firstOptionSticky: hasFilteredOptions && enableSelectAll, isMultiSelect: true }) }),
126
+ contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { renderOption: renderOption, listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: multiselectProps.isOpen ? dropdownStatus.content : null, id: footerId })) : null, listProps: { ...multiselectProps.getMenuProps(), ariaRequired }, getOptionProps: multiselectProps.getOptionProps, filteredOptions: multiselectProps.filteredOptions, filteringValue: filteringValue, ref: multiselectProps.scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, selectionType: "multi", screenReaderContent: multiselectProps.announcement, highlightType: multiselectProps.highlightType, firstOptionSticky: hasFilteredOptions && enableSelectAll, isMultiSelect: true }) }),
127
127
  showTokens && (React.createElement(InternalTokenGroup, { ...multiselectProps.getTokenProps(), className: styles.tokens, alignment: "horizontal", limit: tokenLimit, items: tokens, i18nStrings: tokenGroupI18nStrings, limitShowMoreAriaLabel: tokenLimitShowMoreAriaLabel, limitShowFewerAriaLabel: tokenLimitShowFewerAriaLabel, disableOuterPadding: true, readOnly: readOnly, isItemReadOnly: item => item._readOnly, styleClassNames: { token: styleClassNames === null || styleClassNames === void 0 ? void 0 : styleClassNames.token } })),
128
128
  React.createElement(ScreenreaderOnly, { id: ariaLabelId }, ariaLabel || inlineLabelText))));
129
129
  });
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE/F,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,cAAc,MAAM,iDAAiD,CAAC;AAC7E,OAAO,gBAAgB,MAAM,0CAA0C,CA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,KAAK,IAAI,EAClD,UAAU,EAAE,IAAI,EAChB,oBAAoB,EAAE,IAAI,EAC1B,mBAAmB,EAAE,gBAAgB,CAAC,YAAY,EAClD,aAAa,EAAE,gBAAgB,CAAC,aAAa,EAC7C,iBAAiB,EAAE,kBAAkB,IAAI,eAAe,EACxD,aAAa,EAAE,IAAI,GACnB,GAEJ;YAED,UAAU,IAAI,CACb,oBAAC,kBAAkB,OACb,gBAAgB,CAAC,aAAa,EAAE,EACpC,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,qBAAqB,EAClC,sBAAsB,EAAE,2BAA2B,EACnD,uBAAuB,EAAE,4BAA4B,EACrD,mBAAmB,EAAE,IAAI,EACzB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,IAAI,CAAC,EAAE,CAAE,IAAsB,CAAC,SAAS,EACzD,eAAe,EAAE,EAAE,KAAK,EAAE,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,EAAE,GAClD,CACH;YAED,oBAAC,gBAAgB,IAAC,EAAE,EAAE,WAAW,IAAG,SAAS,IAAI,eAAe,CAAoB,CAChF,CACqB,CAC9B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useResizeObserver, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport Dropdown from '../dropdown/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StyleClassNames as InputStyleClassNames } from '../input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { getBreakpointValue } from '../internal/breakpoints';\nimport DropdownFooter from '../internal/components/dropdown-footer/index.js';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { warnOnUnsupportedGroupedControlProps } from '../internal/grouped-control/dev-warnings';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { SomeRequired } from '../internal/types';\nimport { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';\nimport { joinStrings } from '../internal/utils/strings';\nimport Filter from '../select/parts/filter';\nimport PlainList from '../select/parts/plain-list';\nimport Trigger from '../select/parts/trigger';\nimport VirtualList from '../select/parts/virtual-list';\nimport { composeDropdownContent } from '../select/utils/dropdown-customization';\nimport { StyleClassNames as TokenStyleClassNames } from '../token/internal';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport InternalTokenGroup from '../token-group/internal';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\ntype InternalMultiselectProps = SomeRequired<\n MultiselectProps,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen' | 'hideTokens'\n> &\n InternalBaseComponentProps & {\n styleClassNames?: StyleClassNames;\n };\n\n// Style API v2\nexport interface StyleClassNames {\n trigger?: string;\n inlineLabel?: string;\n filter?: InputStyleClassNames;\n dropdown?: string;\n token?: TokenStyleClassNames;\n}\n\ntype ExtendedToken = TokenGroupProps.Item & { _readOnly: boolean };\n\nconst InternalMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n inlineLabelText,\n selectedOptions,\n deselectAriaLabel,\n tokenLimit,\n i18nStrings,\n virtualScroll,\n inlineTokens,\n hideTokens,\n expandToViewport,\n tokenLimitShowFewerAriaLabel,\n tokenLimitShowMoreAriaLabel,\n __internalRootRef,\n autoFocus,\n enableSelectAll,\n renderOption,\n renderDropdownHeader,\n renderDropdownFooter,\n dropdownRole,\n dropdownAriaDescribedby,\n styleClassNames,\n ...restProps\n }: InternalMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const groupedControlProps = useGroupedControlContext();\n const i18n = useInternalI18n('multiselect');\n\n const isGrouped = !!groupedControlProps.position;\n\n warnOnUnsupportedGroupedControlProps({\n isGrouped,\n componentName: 'Multiselect',\n invalid: formFieldContext.invalid,\n warning: formFieldContext.warning,\n readOnly,\n inlineTokens,\n expandToViewport,\n });\n\n // When rendered inside a control group, tokens are always shown inline in the\n // trigger regardless of the `inlineTokens` prop, since there is no room to\n // display tokens below the control within a group.\n const showTokensInline = inlineTokens || isGrouped;\n\n // When grouped, the dropdown is portaled regardless of the public\n // `expandToViewport` prop so it escapes the control slot's stacking context\n // and paints over the group's inline label (which the focus ring stays under).\n const effectiveExpandToViewport = expandToViewport || isGrouped;\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n\n const [filteringValue, setFilteringValue] = useState('');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled,\n deselectAriaLabel,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n enableSelectAll,\n i18nStrings,\n dropdownRole,\n dropdownAriaDescribedby,\n ...restProps,\n });\n\n const dropdownContentProps: MultiselectProps.DropdownContentProps = {\n filterText: filteringValue,\n closeDropdown: multiselectProps.closeDropdown,\n };\n const customDropdownHeader = renderDropdownHeader?.(dropdownContentProps);\n const customDropdownFooter = renderDropdownFooter?.(dropdownContentProps);\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n styleClassNames={styleClassNames?.filter}\n {...multiselectProps.getFilterProps()}\n />\n );\n\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [triggerWidth, setTriggerWidth] = useState<number | null>(null);\n useResizeObserver(\n () => triggerRef.current,\n entry => setTriggerWidth(entry.borderBoxWidth)\n );\n\n const trigger = (\n <Trigger\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerProps={multiselectProps.getTriggerProps(disabled, autoFocus)}\n selectedOption={null}\n selectedOptions={selectedOptions}\n triggerVariant={showTokensInline ? 'tokens' : 'placeholder'}\n isOpen={multiselectProps.isOpen}\n groupedControlProps={groupedControlProps}\n inlineLabelText={inlineLabelText}\n styleClassNames={{\n trigger: styleClassNames?.trigger,\n inlineLabel: styleClassNames?.inlineLabel,\n token: styleClassNames?.token,\n }}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, ariaLabelId)}\n />\n );\n\n const tokens: Array<ExtendedToken> = selectedOptions.map(option => ({\n label: option.label,\n disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n _readOnly: !!option.disabled,\n }));\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const showTokens = !hideTokens && !showTokensInline && tokens.length > 0;\n\n const tokenGroupI18nStrings: TokenGroupProps.I18nStrings = {\n limitShowFewer: i18nStrings?.tokenLimitShowFewer,\n limitShowMore: i18nStrings?.tokenLimitShowMore,\n };\n\n const dropdownStatus = multiselectProps.dropdownStatus;\n const dropdownProps = multiselectProps.getDropdownProps();\n const hasFilteredOptions = multiselectProps.filteredOptions.length > 0;\n\n const statusFooter = dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null;\n const { header: dropdownHeader, footer: dropdownFooter } = composeDropdownContent({\n filter,\n customDropdownHeader,\n customDropdownFooter,\n statusFooter,\n dropdownHeaderClass: styles['dropdown-header'],\n dropdownFooterClass: styles['dropdown-footer'],\n });\n\n const hasOptions = useRef(options.length > 0);\n hasOptions.current = hasOptions.current || options.length > 0;\n\n return (\n <ResetGroupedControlContext>\n <div\n {...baseProps}\n ref={__internalRootRef}\n className={clsx(styles.root, baseProps.className)}\n {...multiselectProps.getWrapperProps()}\n >\n <Dropdown\n {...dropdownProps}\n styleClassNames={{ container: styleClassNames?.dropdown }}\n ariaLabelledby={dropdownProps.ariaRole ? joinStrings(ariaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.ariaRole\n ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)\n : undefined\n }\n open={multiselectProps.isOpen}\n minWidth={getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth })}\n maxWidth={getBreakpointValue('xxs')} // AWSUI-19898\n trigger={trigger}\n header={dropdownHeader}\n footer={dropdownFooter}\n expandToViewport={effectiveExpandToViewport}\n // Forces dropdown position recalculation when new options are loaded\n contentKey={hasOptions.current.toString()}\n content={\n <ListComponent\n renderOption={renderOption}\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n menuProps={{ ...multiselectProps.getMenuProps(), ariaRequired }}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringValue}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n checkboxes={true}\n useInteractiveGroups={true}\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n firstOptionSticky={hasFilteredOptions && enableSelectAll}\n isMultiSelect={true}\n />\n }\n />\n\n {showTokens && (\n <InternalTokenGroup\n {...multiselectProps.getTokenProps()}\n className={styles.tokens}\n alignment=\"horizontal\"\n limit={tokenLimit}\n items={tokens}\n i18nStrings={tokenGroupI18nStrings}\n limitShowMoreAriaLabel={tokenLimitShowMoreAriaLabel}\n limitShowFewerAriaLabel={tokenLimitShowFewerAriaLabel}\n disableOuterPadding={true}\n readOnly={readOnly}\n isItemReadOnly={item => (item as ExtendedToken)._readOnly}\n styleClassNames={{ token: styleClassNames?.token }}\n />\n )}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel || inlineLabelText}</ScreenreaderOnly>\n </div>\n </ResetGroupedControlContext>\n );\n }\n);\n\nexport default InternalMultiselect;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/multiselect/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE/F,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,cAAc,MAAM,iDAAiD,CAAC;AAC7E,OAAO,SAAS,MAAM,iDAAiD,CAAC;AACxE,OAAO,gBAAgB,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACjH,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,oCAAoC,EAAE,MAAM,0CAA0C,CAAC;AAGhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CA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pC,SAAS,EAAE,MAAM,CAAC,MAAM,EACxB,SAAS,EAAC,YAAY,EACtB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,qBAAqB,EAClC,sBAAsB,EAAE,2BAA2B,EACnD,uBAAuB,EAAE,4BAA4B,EACrD,mBAAmB,EAAE,IAAI,EACzB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,IAAI,CAAC,EAAE,CAAE,IAAsB,CAAC,SAAS,EACzD,eAAe,EAAE,EAAE,KAAK,EAAE,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,KAAK,EAAE,GAClD,CACH;YAED,oBAAC,gBAAgB,IAAC,EAAE,EAAE,WAAW,IAAG,SAAS,IAAI,eAAe,CAAoB,CAChF,CACqB,CAC9B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useResizeObserver, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport Dropdown from '../dropdown/internal';\nimport { useInternalI18n } from '../i18n/context';\nimport { StyleClassNames as InputStyleClassNames } from '../input/internal';\nimport { getBaseProps } from '../internal/base-component';\nimport { getBreakpointValue } from '../internal/breakpoints';\nimport DropdownFooter from '../internal/components/dropdown-footer/index.js';\nimport PlainList from '../internal/components/listbox/parts/plain-list';\nimport ScreenreaderOnly from '../internal/components/screenreader-only';\nimport { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { warnOnUnsupportedGroupedControlProps } from '../internal/grouped-control/dev-warnings';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component/index.js';\nimport { SomeRequired } from '../internal/types';\nimport { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';\nimport { joinStrings } from '../internal/utils/strings';\nimport Filter from '../select/parts/filter';\nimport Trigger from '../select/parts/trigger';\nimport VirtualList from '../select/parts/virtual-list';\nimport { composeDropdownContent } from '../select/utils/dropdown-customization';\nimport { StyleClassNames as TokenStyleClassNames } from '../token/internal';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport InternalTokenGroup from '../token-group/internal';\nimport { MultiselectProps } from './interfaces';\nimport { useMultiselect } from './use-multiselect';\n\nimport styles from './styles.css.js';\n\ntype InternalMultiselectProps = SomeRequired<\n MultiselectProps,\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen' | 'hideTokens'\n> &\n InternalBaseComponentProps & {\n styleClassNames?: StyleClassNames;\n };\n\n// Style API v2\nexport interface StyleClassNames {\n trigger?: string;\n inlineLabel?: string;\n filter?: InputStyleClassNames;\n dropdown?: string;\n token?: TokenStyleClassNames;\n}\n\ntype ExtendedToken = TokenGroupProps.Item & { _readOnly: boolean };\n\nconst InternalMultiselect = React.forwardRef(\n (\n {\n options,\n filteringType,\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n inlineLabelText,\n selectedOptions,\n deselectAriaLabel,\n tokenLimit,\n i18nStrings,\n virtualScroll,\n inlineTokens,\n hideTokens,\n expandToViewport,\n tokenLimitShowFewerAriaLabel,\n tokenLimitShowMoreAriaLabel,\n __internalRootRef,\n autoFocus,\n enableSelectAll,\n renderOption,\n renderDropdownHeader,\n renderDropdownFooter,\n dropdownRole,\n dropdownAriaDescribedby,\n styleClassNames,\n ...restProps\n }: InternalMultiselectProps,\n externalRef: React.Ref<MultiselectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n const groupedControlProps = useGroupedControlContext();\n const i18n = useInternalI18n('multiselect');\n\n const isGrouped = !!groupedControlProps.position;\n\n warnOnUnsupportedGroupedControlProps({\n isGrouped,\n componentName: 'Multiselect',\n invalid: formFieldContext.invalid,\n warning: formFieldContext.warning,\n readOnly,\n inlineTokens,\n expandToViewport,\n });\n\n // When rendered inside a control group, tokens are always shown inline in the\n // trigger regardless of the `inlineTokens` prop, since there is no room to\n // display tokens below the control within a group.\n const showTokensInline = inlineTokens || isGrouped;\n\n // When grouped, the dropdown is portaled regardless of the public\n // `expandToViewport` prop so it escapes the control slot's stacking context\n // and paints over the group's inline label (which the focus ring stays under).\n const effectiveExpandToViewport = expandToViewport || isGrouped;\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\n const ariaLabelId = useUniqueId('multiselect-ariaLabel-');\n const footerId = useUniqueId('multiselect-footer-');\n\n const [filteringValue, setFilteringValue] = useState('');\n const multiselectProps = useMultiselect({\n options,\n selectedOptions,\n filteringType,\n disabled,\n deselectAriaLabel,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n enableSelectAll,\n i18nStrings,\n dropdownRole,\n dropdownAriaDescribedby,\n ...restProps,\n });\n\n const dropdownContentProps: MultiselectProps.DropdownContentProps = {\n filterText: filteringValue,\n closeDropdown: multiselectProps.closeDropdown,\n };\n const customDropdownHeader = renderDropdownHeader?.(dropdownContentProps);\n const customDropdownFooter = renderDropdownFooter?.(dropdownContentProps);\n\n const filter = (\n <Filter\n clearAriaLabel={filteringClearAriaLabel}\n filteringType={filteringType}\n placeholder={filteringPlaceholder}\n ariaLabel={filteringAriaLabel}\n ariaRequired={ariaRequired}\n value={filteringValue}\n styleClassNames={styleClassNames?.filter}\n {...multiselectProps.getFilterProps()}\n />\n );\n\n const triggerRef = useRef<HTMLButtonElement>(null);\n const [triggerWidth, setTriggerWidth] = useState<number | null>(null);\n useResizeObserver(\n () => triggerRef.current,\n entry => setTriggerWidth(entry.borderBoxWidth)\n );\n\n const trigger = (\n <Trigger\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerProps={multiselectProps.getTriggerProps(disabled, autoFocus)}\n selectedOption={null}\n selectedOptions={selectedOptions}\n triggerVariant={showTokensInline ? 'tokens' : 'placeholder'}\n isOpen={multiselectProps.isOpen}\n groupedControlProps={groupedControlProps}\n inlineLabelText={inlineLabelText}\n styleClassNames={{\n trigger: styleClassNames?.trigger,\n inlineLabel: styleClassNames?.inlineLabel,\n token: styleClassNames?.token,\n }}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, ariaLabelId)}\n />\n );\n\n const tokens: Array<ExtendedToken> = selectedOptions.map(option => ({\n label: option.label,\n disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n _readOnly: !!option.disabled,\n }));\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const showTokens = !hideTokens && !showTokensInline && tokens.length > 0;\n\n const tokenGroupI18nStrings: TokenGroupProps.I18nStrings = {\n limitShowFewer: i18nStrings?.tokenLimitShowFewer,\n limitShowMore: i18nStrings?.tokenLimitShowMore,\n };\n\n const dropdownStatus = multiselectProps.dropdownStatus;\n const dropdownProps = multiselectProps.getDropdownProps();\n const hasFilteredOptions = multiselectProps.filteredOptions.length > 0;\n\n const statusFooter = dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null;\n const { header: dropdownHeader, footer: dropdownFooter } = composeDropdownContent({\n filter,\n customDropdownHeader,\n customDropdownFooter,\n statusFooter,\n dropdownHeaderClass: styles['dropdown-header'],\n dropdownFooterClass: styles['dropdown-footer'],\n });\n\n const hasOptions = useRef(options.length > 0);\n hasOptions.current = hasOptions.current || options.length > 0;\n\n return (\n <ResetGroupedControlContext>\n <div\n {...baseProps}\n ref={__internalRootRef}\n className={clsx(styles.root, baseProps.className)}\n {...multiselectProps.getWrapperProps()}\n >\n <Dropdown\n {...dropdownProps}\n styleClassNames={{ container: styleClassNames?.dropdown }}\n ariaLabelledby={dropdownProps.ariaRole ? joinStrings(ariaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.ariaRole\n ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)\n : undefined\n }\n open={multiselectProps.isOpen}\n minWidth={getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth })}\n maxWidth={getBreakpointValue('xxs')} // AWSUI-19898\n trigger={trigger}\n header={dropdownHeader}\n footer={dropdownFooter}\n expandToViewport={effectiveExpandToViewport}\n // Forces dropdown position recalculation when new options are loaded\n contentKey={hasOptions.current.toString()}\n content={\n <ListComponent\n renderOption={renderOption}\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={multiselectProps.isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n listProps={{ ...multiselectProps.getMenuProps(), ariaRequired }}\n getOptionProps={multiselectProps.getOptionProps}\n filteredOptions={multiselectProps.filteredOptions}\n filteringValue={filteringValue}\n ref={multiselectProps.scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n selectionType=\"multi\"\n screenReaderContent={multiselectProps.announcement}\n highlightType={multiselectProps.highlightType}\n firstOptionSticky={hasFilteredOptions && enableSelectAll}\n isMultiSelect={true}\n />\n }\n />\n\n {showTokens && (\n <InternalTokenGroup\n {...multiselectProps.getTokenProps()}\n className={styles.tokens}\n alignment=\"horizontal\"\n limit={tokenLimit}\n items={tokens}\n i18nStrings={tokenGroupI18nStrings}\n limitShowMoreAriaLabel={tokenLimitShowMoreAriaLabel}\n limitShowFewerAriaLabel={tokenLimitShowFewerAriaLabel}\n disableOuterPadding={true}\n readOnly={readOnly}\n isItemReadOnly={item => (item as ExtendedToken)._readOnly}\n styleClassNames={{ token: styleClassNames?.token }}\n />\n )}\n\n <ScreenreaderOnly id={ariaLabelId}>{ariaLabel || inlineLabelText}</ScreenreaderOnly>\n </div>\n </ResetGroupedControlContext>\n );\n }\n);\n\nexport default InternalMultiselect;\n"]}
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { DropdownOption } from '../internal/components/option/interfaces';
3
3
  import { SomeRequired } from '../internal/types';
4
- import { SelectListProps } from '../select/parts/plain-list';
5
4
  import { TokenGroupProps } from '../token-group/interfaces';
6
5
  import { DropdownStatusProps } from '../types/dropdown-status';
7
6
  import { MultiselectProps } from './interfaces';
@@ -54,7 +53,7 @@ export declare function useMultiselect({
54
53
  filteringValue: string;
55
54
  filteredOptions: readonly DropdownOption[];
56
55
  highlightType: import("../internal/components/options-list/utils/use-highlight-option").HighlightType;
57
- scrollToIndex: React.RefObject<SelectListProps.SelectListRef>;
56
+ scrollToIndex: React.RefObject<import("../internal/components/listbox/interfaces").ScrollToIndexRef>;
58
57
  getFilterProps: () => Partial<import("../select/parts/filter").FilterProps>;
59
58
  getTriggerProps: (disabled?: boolean, autoFocus?: boolean) => import("../select/utils/use-select").SelectTriggerProps;
60
59
  getMenuProps: () => {
@@ -85,7 +84,7 @@ export declare function useMultiselect({
85
84
  customProperties?: React.CSSProperties | undefined;
86
85
  ref: React.RefObject<HTMLDivElement>;
87
86
  };
88
- getOptionProps: (option: DropdownOption, index: number) => any;
87
+ getOptionProps: (option: DropdownOption, index: number) => ReturnType<typeof import("../internal/components/listbox/utils/option-props").getListboxOptionProps>;
89
88
  getTokenProps: () => {
90
89
  onDismiss: import("../types/events").NonCancelableEventHandler<TokenGroupProps.DismissDetail>;
91
90
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-multiselect.d.ts","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAGA,OAAO,KAA4B,MAAM,OAAO,CAAC;AASjD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAI1E,OAAO,EAAE,YAAY,EAAE,MAAM,mBA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UAAU,CAC5E,GAAG;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3B,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,QAAQ,EACR,SAAS,EACT,WAAW,EACX,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,eAAe,EACf,WAAW,EACX,YAAY,EACZ,uBAAuB,EACvB,GAAG,SAAS,EACb,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAqIc,KAAK,CAAC,UAAU;;;;;;;;;;;EA2CrD"}
@@ -1,17 +1,15 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { useEffect, useRef } from 'react';
4
3
  import { warnOnce } from '@cloudscape-design/component-toolkit/internal';
5
4
  import { useInternalI18n } from '../i18n/context';
6
5
  import { useDropdownStatus } from '../internal/components/dropdown-status';
7
6
  import { multiSelection } from '../internal/components/listbox/selection/multi-selection';
8
- import { useAnnouncement } from '../internal/components/listbox/use-announcement';
7
+ import { useTypeAhead } from '../internal/components/listbox/use-type-ahead';
9
8
  import { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field.js';
10
9
  import { prepareOptions } from '../internal/components/option/utils/prepare-options';
11
10
  import { fireNonCancelableEvent } from '../internal/events';
12
11
  import { useLoadItems } from '../internal/hooks/use-load-items';
13
12
  import { joinStrings } from '../internal/utils/strings';
14
- import { useNativeSearch } from '../select/utils/use-native-search';
15
13
  import { useSelect } from '../select/utils/use-select';
16
14
  export function useMultiselect({ options, filteringType, filteringResultsText, disabled, statusType, empty, loadingText, finishedText, errorText, noMatch, renderHighlightedAriaLive, selectedOptions, deselectAriaLabel, keepOpen, onBlur, onFocus, onLoadItems, onChange, controlId, ariaLabelId, footerId, filteringValue, setFilteringValue, externalRef, embedded, enableSelectAll, i18nStrings, dropdownRole, dropdownAriaDescribedby, ...restProps }) {
17
15
  checkOptionValueField('Multiselect', 'options', options);
@@ -48,8 +46,7 @@ export function useMultiselect({ options, filteringType, filteringResultsText, d
48
46
  const updateSelectedOption = (option) => {
49
47
  fireNonCancelableEvent(onChange, { selectedOptions: selection.getNextSelection({ option }) });
50
48
  };
51
- const scrollToIndex = useRef(null);
52
- const { isOpen, highlightType, highlightedOption, highlightedIndex, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, announceSelected, focusActiveRef, closeDropdown, } = useSelect({
49
+ const { isOpen, highlightType, highlightedOption, highlightedIndex, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, announcement, scrollToIndex, focusActiveRef, closeDropdown, } = useSelect({
53
50
  selectedOptions,
54
51
  updateSelectedOption,
55
52
  options: visibleOptions,
@@ -66,13 +63,16 @@ export function useMultiselect({ options, filteringType, filteringResultsText, d
66
63
  selection,
67
64
  toggleAll,
68
65
  dropdownRole,
66
+ getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
67
+ selectedAriaLabel,
68
+ renderHighlightedAriaLive,
69
69
  });
70
- const wrapperOnKeyDown = useNativeSearch({
70
+ const wrapperOnKeyDown = useTypeAhead({
71
71
  isEnabled: filteringType === 'none' && isOpen,
72
72
  options: visibleOptions,
73
73
  highlightOption: highlightOption,
74
74
  highlightedOption: highlightedOption === null || highlightedOption === void 0 ? void 0 : highlightedOption.option,
75
- useInteractiveGroups,
75
+ interactiveGroups: useInteractiveGroups,
76
76
  });
77
77
  const isEmpty = !options || options.length === 0;
78
78
  const isNoMatch = filteredOptions && filteredOptions.length === 0;
@@ -96,13 +96,6 @@ export function useMultiselect({ options, filteringType, filteringResultsText, d
96
96
  errorIconAriaLabel: errorIconAriaLabel,
97
97
  hasRecoveryCallback: !!onLoadItems,
98
98
  });
99
- const announcement = useAnnouncement({
100
- announceSelected,
101
- highlightedOption,
102
- getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
103
- selectedAriaLabel,
104
- renderHighlightedAriaLive,
105
- });
106
99
  const tokens = selectedOptions.map(option => ({
107
100
  label: option.label,
108
101
  disabled: disabled || option.disabled,
@@ -115,10 +108,6 @@ export function useMultiselect({ options, filteringType, filteringResultsText, d
115
108
  tags: option.tags,
116
109
  dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel === null || deselectAriaLabel === void 0 ? void 0 : deselectAriaLabel(option), format => { var _a; return format({ option__label: (_a = option.label) !== null && _a !== void 0 ? _a : '' }); }),
117
110
  }));
118
- useEffect(() => {
119
- var _a;
120
- (_a = scrollToIndex.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndex, highlightedIndex);
121
- }, [highlightedIndex]);
122
111
  const dropdownOnMouseDown = (event) => {
123
112
  const target = event.target;
124
113
  if (target !== document.activeElement) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-multiselect.js","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kEAAkE,CAAC;AAEz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E,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;QACrF,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;QACxD,gBAAgB;QAChB,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useEffect, useRef } from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport { multiSelection } from '../internal/components/listbox/selection/multi-selection';\nimport { useAnnouncement } from '../internal/components/listbox/use-announcement';\nimport { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field.js';\nimport { DropdownOption } from '../internal/components/option/interfaces';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useLoadItems } from '../internal/hooks/use-load-items';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport { SelectListProps } from '../select/parts/plain-list';\nimport { useNativeSearch } from '../select/utils/use-native-search';\nimport { useSelect } from '../select/utils/use-select';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport { DropdownStatusProps } from '../types/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../types/option';\nimport { MultiselectProps } from './interfaces';\n\ntype UseMultiselectOptions = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'filteringType'\n | 'filteringResultsText'\n | 'disabled'\n | 'noMatch'\n | 'renderHighlightedAriaLive'\n | 'deselectAriaLabel'\n | 'keepOpen'\n | 'onBlur'\n | 'onFocus'\n | 'onLoadItems'\n | 'onChange'\n | 'selectedAriaLabel'\n | 'enableSelectAll'\n | 'i18nStrings'\n | 'dropdownRole'\n | 'dropdownAriaDescribedby'\n > &\n DropdownStatusProps & {\n controlId?: string;\n ariaLabelId: string;\n footerId: string;\n filteringValue: string;\n setFilteringValue?: (value: string) => void;\n externalRef: React.Ref<MultiselectProps.Ref>;\n },\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen'\n> & { embedded?: boolean };\n\nexport function useMultiselect({\n options,\n filteringType,\n filteringResultsText,\n disabled,\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n renderHighlightedAriaLive,\n selectedOptions,\n deselectAriaLabel,\n keepOpen,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n embedded,\n enableSelectAll,\n i18nStrings,\n dropdownRole,\n dropdownAriaDescribedby,\n ...restProps\n}: UseMultiselectOptions) {\n checkOptionValueField('Multiselect', 'options', options);\n\n const i18n = useInternalI18n('multiselect');\n const i18nCommon = useInternalI18n('select');\n const recoveryText = i18nCommon('recoveryText', restProps.recoveryText);\n const errorIconAriaLabel = i18nCommon('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18nCommon('selectedAriaLabel', restProps.selectedAriaLabel);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Multiselect', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n isEmpty: options.length === 0,\n statusType,\n });\n const useInteractiveGroups = true;\n const { flatOptions, filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const selectAllOption: DropdownOption = {\n type: 'select-all',\n afterHeader: filteringType !== 'none',\n option: { label: i18n('i18nStrings.selectAllText', i18nStrings?.selectAllText) },\n };\n\n const visibleOptions =\n enableSelectAll && filteredOptions.length ? [selectAllOption, ...filteredOptions] : filteredOptions;\n\n const selection = multiSelection(selectedOptions, {\n options: filteredOptions,\n // Includes visible and non-visible (filtered out) options\n allOptions: flatOptions,\n interactiveGroups: useInteractiveGroups,\n });\n\n const toggleAll = () => {\n fireNonCancelableEvent(onChange, { selectedOptions: selection.getNextSelection(selectAllOption) });\n };\n\n const updateSelectedOption = (option: OptionDefinition | OptionGroup) => {\n fireNonCancelableEvent(onChange, { selectedOptions: selection.getNextSelection({ option }) });\n };\n\n const scrollToIndex = useRef<SelectListProps.SelectListRef>(null);\n const {\n isOpen,\n highlightType,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n announceSelected,\n focusActiveRef,\n closeDropdown,\n } = useSelect({\n selectedOptions,\n updateSelectedOption,\n options: visibleOptions,\n filteringType,\n onFocus,\n onBlur,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups,\n statusType,\n embedded,\n selection,\n toggleAll,\n dropdownRole,\n });\n\n const wrapperOnKeyDown = useNativeSearch({\n isEnabled: filteringType === 'none' && isOpen,\n options: visibleOptions,\n highlightOption: highlightOption,\n highlightedOption: highlightedOption?.option,\n useInteractiveGroups,\n });\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n filteringResultsText: filteredText,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n errorIconAriaLabel: errorIconAriaLabel,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const announcement = useAnnouncement({\n announceSelected,\n highlightedOption,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\n\n const dropdownOnMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const tokenOnDismiss: TokenGroupProps['onDismiss'] = ({ detail }) => {\n const optionToDeselect = selectedOptions[detail.itemIndex];\n updateSelectedOption(optionToDeselect);\n const targetRef = getTriggerProps().ref;\n if (targetRef.current) {\n targetRef.current.focus();\n }\n };\n\n return {\n isOpen,\n tokens,\n announcement,\n dropdownStatus,\n filteringValue,\n filteredOptions: visibleOptions,\n highlightType,\n scrollToIndex,\n getFilterProps,\n getTriggerProps,\n getMenuProps: () => ({\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(ariaLabelId, controlId),\n ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),\n embedded,\n }),\n getOptionProps,\n getTokenProps: () => ({ onDismiss: tokenOnDismiss }),\n getDropdownProps: () => ({ ...getDropdownProps(), onMouseDown: dropdownOnMouseDown }),\n getWrapperProps: () => ({ onKeyDown: wrapperOnKeyDown }),\n highlightedIndex,\n closeDropdown,\n };\n}\n"]}
1
+ {"version":3,"file":"use-multiselect.js","sourceRoot":"","sources":["../../../src/multiselect/use-multiselect.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAItC,OAAO,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;A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AS,EAAE,gBAAgB,EAAE,CAAC;QACxD,gBAAgB;QAChB,aAAa;KACd,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React from 'react';\n\nimport { warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport { multiSelection } from '../internal/components/listbox/selection/multi-selection';\nimport { useTypeAhead } from '../internal/components/listbox/use-type-ahead';\nimport { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field.js';\nimport { DropdownOption } from '../internal/components/option/interfaces';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport { useLoadItems } from '../internal/hooks/use-load-items';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings';\nimport { useSelect } from '../select/utils/use-select';\nimport { TokenGroupProps } from '../token-group/interfaces';\nimport { DropdownStatusProps } from '../types/dropdown-status';\nimport { OptionDefinition, OptionGroup } from '../types/option';\nimport { MultiselectProps } from './interfaces';\n\ntype UseMultiselectOptions = SomeRequired<\n Pick<\n MultiselectProps,\n | 'options'\n | 'selectedOptions'\n | 'filteringType'\n | 'filteringResultsText'\n | 'disabled'\n | 'noMatch'\n | 'renderHighlightedAriaLive'\n | 'deselectAriaLabel'\n | 'keepOpen'\n | 'onBlur'\n | 'onFocus'\n | 'onLoadItems'\n | 'onChange'\n | 'selectedAriaLabel'\n | 'enableSelectAll'\n | 'i18nStrings'\n | 'dropdownRole'\n | 'dropdownAriaDescribedby'\n > &\n DropdownStatusProps & {\n controlId?: string;\n ariaLabelId: string;\n footerId: string;\n filteringValue: string;\n setFilteringValue?: (value: string) => void;\n externalRef: React.Ref<MultiselectProps.Ref>;\n },\n 'options' | 'selectedOptions' | 'filteringType' | 'statusType' | 'keepOpen'\n> & { embedded?: boolean };\n\nexport function useMultiselect({\n options,\n filteringType,\n filteringResultsText,\n disabled,\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n renderHighlightedAriaLive,\n selectedOptions,\n deselectAriaLabel,\n keepOpen,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n controlId,\n ariaLabelId,\n footerId,\n filteringValue,\n setFilteringValue,\n externalRef,\n embedded,\n enableSelectAll,\n i18nStrings,\n dropdownRole,\n dropdownAriaDescribedby,\n ...restProps\n}: UseMultiselectOptions) {\n checkOptionValueField('Multiselect', 'options', options);\n\n const i18n = useInternalI18n('multiselect');\n const i18nCommon = useInternalI18n('select');\n const recoveryText = i18nCommon('recoveryText', restProps.recoveryText);\n const errorIconAriaLabel = i18nCommon('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18nCommon('selectedAriaLabel', restProps.selectedAriaLabel);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Multiselect', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n isEmpty: options.length === 0,\n statusType,\n });\n const useInteractiveGroups = true;\n const { flatOptions, filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const selectAllOption: DropdownOption = {\n type: 'select-all',\n afterHeader: filteringType !== 'none',\n option: { label: i18n('i18nStrings.selectAllText', i18nStrings?.selectAllText) },\n };\n\n const visibleOptions =\n enableSelectAll && filteredOptions.length ? [selectAllOption, ...filteredOptions] : filteredOptions;\n\n const selection = multiSelection(selectedOptions, {\n options: filteredOptions,\n // Includes visible and non-visible (filtered out) options\n allOptions: flatOptions,\n interactiveGroups: useInteractiveGroups,\n });\n\n const toggleAll = () => {\n fireNonCancelableEvent(onChange, { selectedOptions: selection.getNextSelection(selectAllOption) });\n };\n\n const updateSelectedOption = (option: OptionDefinition | OptionGroup) => {\n fireNonCancelableEvent(onChange, { selectedOptions: selection.getNextSelection({ option }) });\n };\n\n const {\n isOpen,\n highlightType,\n highlightedOption,\n highlightedIndex,\n getTriggerProps,\n getDropdownProps,\n getFilterProps,\n getMenuProps,\n getOptionProps,\n highlightOption,\n announcement,\n scrollToIndex,\n focusActiveRef,\n closeDropdown,\n } = useSelect({\n selectedOptions,\n updateSelectedOption,\n options: visibleOptions,\n filteringType,\n onFocus,\n onBlur,\n externalRef,\n keepOpen,\n fireLoadItems,\n setFilteringValue,\n useInteractiveGroups,\n statusType,\n embedded,\n selection,\n toggleAll,\n dropdownRole,\n getParent: option => parentMap.get(option)?.option as undefined | OptionGroup,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n const wrapperOnKeyDown = useTypeAhead({\n isEnabled: filteringType === 'none' && isOpen,\n options: visibleOptions,\n highlightOption: highlightOption,\n highlightedOption: highlightedOption?.option,\n interactiveGroups: useInteractiveGroups,\n });\n\n const isEmpty = !options || options.length === 0;\n const isNoMatch = filteredOptions && filteredOptions.length === 0;\n const isFiltered =\n filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;\n const filteredText = isFiltered ? filteringResultsText?.(matchesCount, totalCount) : undefined;\n const dropdownStatus = useDropdownStatus({\n statusType,\n empty,\n loadingText,\n finishedText,\n errorText,\n recoveryText,\n isEmpty,\n isNoMatch,\n noMatch,\n filteringResultsText: filteredText,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n errorIconAriaLabel: errorIconAriaLabel,\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const tokens: TokenGroupProps['items'] = selectedOptions.map(option => ({\n label: option.label,\n disabled: disabled || option.disabled,\n labelTag: option.labelTag,\n description: option.description,\n iconAlt: option.iconAlt,\n iconName: option.iconName,\n iconUrl: option.iconUrl,\n iconSvg: option.iconSvg,\n tags: option.tags,\n dismissLabel: i18n('deselectAriaLabel', deselectAriaLabel?.(option), format =>\n format({ option__label: option.label ?? '' })\n ),\n }));\n\n const dropdownOnMouseDown = (event: React.MouseEvent) => {\n const target = event.target as HTMLElement;\n\n if (target !== document.activeElement) {\n // prevent currently focused element from losing it\n event.preventDefault();\n }\n };\n\n const tokenOnDismiss: TokenGroupProps['onDismiss'] = ({ detail }) => {\n const optionToDeselect = selectedOptions[detail.itemIndex];\n updateSelectedOption(optionToDeselect);\n const targetRef = getTriggerProps().ref;\n if (targetRef.current) {\n targetRef.current.focus();\n }\n };\n\n return {\n isOpen,\n tokens,\n announcement,\n dropdownStatus,\n filteringValue,\n filteredOptions: visibleOptions,\n highlightType,\n scrollToIndex,\n getFilterProps,\n getTriggerProps,\n getMenuProps: () => ({\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(ariaLabelId, controlId),\n ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),\n embedded,\n }),\n getOptionProps,\n getTokenProps: () => ({ onDismiss: tokenOnDismiss }),\n getDropdownProps: () => ({ ...getDropdownProps(), onMouseDown: dropdownOnMouseDown }),\n getWrapperProps: () => ({ onKeyDown: wrapperOnKeyDown }),\n highlightedIndex,\n closeDropdown,\n };\n}\n"]}
package/package.json CHANGED
@@ -380,7 +380,7 @@
380
380
  "./internal/base-theme/styles.css.js",
381
381
  "./internal/base-component/styles.css.js"
382
382
  ],
383
- "version": "3.0.1411",
383
+ "version": "3.0.1412",
384
384
  "repository": {
385
385
  "type": "git",
386
386
  "url": "https://github.com/cloudscape-design/components.git"
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAO3D,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAc5E,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAElF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD,OAAO,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6 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import React, { useEffect, useRef, useState } from 'react';
3
+ import React, { useRef, useState } from 'react';
4
4
  import clsx from 'clsx';
5
5
  import { useMergeRefs, useResizeObserver, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';
6
6
  import Dropdown from '../dropdown/internal';
@@ -9,8 +9,9 @@ import { getBaseProps } from '../internal/base-component';
9
9
  import { getBreakpointValue } from '../internal/breakpoints';
10
10
  import DropdownFooter from '../internal/components/dropdown-footer';
11
11
  import { useDropdownStatus } from '../internal/components/dropdown-status';
12
+ import PlainList from '../internal/components/listbox/parts/plain-list';
12
13
  import { singleSelection } from '../internal/components/listbox/selection/single-selection';
13
- import { useAnnouncement } from '../internal/components/listbox/use-announcement';
14
+ import { useTypeAhead } from '../internal/components/listbox/use-type-ahead';
14
15
  import { checkOptionValueField } from '../internal/components/listbox/utils/check-option-value-field';
15
16
  import { prepareOptions } from '../internal/components/option/utils/prepare-options.js';
16
17
  import { ResetGroupedControlContext, useGroupedControlContext } from '../internal/context/control-group-context';
@@ -22,11 +23,9 @@ import { useLoadItems } from '../internal/hooks/use-load-items';
22
23
  import { getDropdownMinWidth } from '../internal/utils/get-dropdown-min-width';
23
24
  import { joinStrings } from '../internal/utils/strings/join-strings.js';
24
25
  import Filter from './parts/filter';
25
- import PlainList from './parts/plain-list';
26
26
  import Trigger from './parts/trigger';
27
27
  import VirtualList from './parts/virtual-list';
28
28
  import { composeDropdownContent } from './utils/dropdown-customization';
29
- import { useNativeSearch } from './utils/use-native-search';
30
29
  import { useSelect } from './utils/use-select';
31
30
  import styles from './styles.css.js';
32
31
  const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filteringPlaceholder, filteringAriaLabel, filteringClearAriaLabel, filteringResultsText, inlineLabelText, ariaRequired, placeholder, disabled, readOnly, ariaLabel, statusType = 'finished', empty, loadingText, finishedText, errorText, noMatch, triggerVariant = 'label', renderHighlightedAriaLive, selectedOption, onBlur, onFocus, onLoadItems, onChange, virtualScroll, expandToViewport, autoFocus, __inFilteringToken, __internalRootRef, renderOption, renderDropdownHeader, renderDropdownFooter, dropdownRole, dropdownAriaDescribedby, styleClassNames, ...restProps }, externalRef) => {
@@ -68,9 +67,8 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
68
67
  useResizeObserver(() => triggerRef.current, entry => setTriggerWidth(entry.borderBoxWidth));
69
68
  const selfControlId = useUniqueId('trigger');
70
69
  const controlId = (_a = formFieldContext.controlId) !== null && _a !== void 0 ? _a : selfControlId;
71
- const scrollToIndex = useRef(null);
72
70
  const selectedOptions = selectedOption ? [selectedOption] : [];
73
- const { isOpen, highlightType, highlightedOption, highlightedIndex, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, selectOption, announceSelected, focusActiveRef, closeDropdown, } = useSelect({
71
+ const { isOpen, highlightType, highlightedOption, getTriggerProps, getDropdownProps, getFilterProps, getMenuProps, getOptionProps, highlightOption, selectOption, announcement, scrollToIndex, focusActiveRef, closeDropdown, } = useSelect({
74
72
  selectedOptions,
75
73
  selection: singleSelection(selectedOptions),
76
74
  updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),
@@ -83,8 +81,11 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
83
81
  setFilteringValue,
84
82
  statusType,
85
83
  dropdownRole,
84
+ getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
85
+ selectedAriaLabel,
86
+ renderHighlightedAriaLive,
86
87
  });
87
- const handleNativeSearch = useNativeSearch({
88
+ const handleNativeSearch = useTypeAhead({
88
89
  isEnabled: filteringType === 'none' && !readOnly,
89
90
  options: filteredOptions,
90
91
  highlightOption: !isOpen ? selectOption : highlightOption,
@@ -92,10 +93,6 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
92
93
  });
93
94
  const selectAriaLabelId = useUniqueId('select-arialabel-');
94
95
  const footerId = useUniqueId('footer');
95
- useEffect(() => {
96
- var _a;
97
- (_a = scrollToIndex.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndex, highlightedIndex);
98
- }, [highlightedIndex]);
99
96
  const dropdownContentProps = { filterText: filteringValue, closeDropdown };
100
97
  const customDropdownHeader = renderDropdownHeader === null || renderDropdownHeader === void 0 ? void 0 : renderDropdownHeader(dropdownContentProps);
101
98
  const customDropdownFooter = renderDropdownFooter === null || renderDropdownFooter === void 0 ? void 0 : renderDropdownFooter(dropdownContentProps);
@@ -139,13 +136,6 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
139
136
  ariaDescribedby: joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby),
140
137
  ariaRequired,
141
138
  };
142
- const announcement = useAnnouncement({
143
- announceSelected,
144
- highlightedOption,
145
- getParent: option => { var _a; return (_a = parentMap.get(option)) === null || _a === void 0 ? void 0 : _a.option; },
146
- selectedAriaLabel,
147
- renderHighlightedAriaLive,
148
- });
149
139
  const ListComponent = virtualScroll ? VirtualList : PlainList;
150
140
  const handleMouseDown = (event) => {
151
141
  const target = event.target;
@@ -164,7 +154,7 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
164
154
  ? joinStrings(dropdownStatus.content ? footerId : undefined, dropdownAriaDescribedby)
165
155
  : undefined, open: isOpen, stretchTriggerHeight: !!__inFilteringToken, minWidth: getDropdownMinWidth({ expandToViewport: effectiveExpandToViewport, triggerWidth }), maxWidth: getBreakpointValue('xxs'), trigger: trigger, header: dropdownHeader, onMouseDown: handleMouseDown, footer: dropdownFooter, expandToViewport: effectiveExpandToViewport,
166
156
  // Forces dropdown position recalculation when new options are loaded
167
- contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, renderOption: renderOption, menuProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, screenReaderContent: announcement, highlightType: highlightType }) }),
157
+ contentKey: hasOptions.current.toString(), content: React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, renderOption: renderOption, listProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, screenReaderContent: announcement, highlightType: highlightType }) }),
168
158
  React.createElement("div", { hidden: true, id: selectAriaLabelId }, ariaLabel || inlineLabelText))));
169
159
  });
170
160
  export default InternalSelect;