@cloudscape-design/components-themeable 3.0.1175 → 3.0.1177

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 (87) hide show
  1. package/lib/internal/manifest.json +1 -1
  2. package/lib/internal/scss/internal/components/button-trigger/styles.scss +7 -0
  3. package/lib/internal/scss/internal/components/drag-handle-wrapper/styles.scss +28 -0
  4. package/lib/internal/scss/internal/components/option/styles.scss +4 -0
  5. package/lib/internal/scss/internal/components/selectable-item/styles.scss +1 -0
  6. package/lib/internal/scss/internal/generated/custom-css-properties/index.scss +1 -1
  7. package/lib/internal/template/autosuggest/internal.d.ts.map +1 -1
  8. package/lib/internal/template/autosuggest/internal.js +5 -1
  9. package/lib/internal/template/autosuggest/internal.js.map +1 -1
  10. package/lib/internal/template/internal/base-component/styles.scoped.css +1 -1
  11. package/lib/internal/template/internal/components/button-trigger/index.d.ts +1 -0
  12. package/lib/internal/template/internal/components/button-trigger/index.d.ts.map +1 -1
  13. package/lib/internal/template/internal/components/button-trigger/index.js +2 -2
  14. package/lib/internal/template/internal/components/button-trigger/index.js.map +1 -1
  15. package/lib/internal/template/internal/components/button-trigger/styles.css.js +14 -13
  16. package/lib/internal/template/internal/components/button-trigger/styles.scoped.css +32 -27
  17. package/lib/internal/template/internal/components/button-trigger/styles.selectors.js +14 -13
  18. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts +3 -1
  19. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.d.ts.map +1 -1
  20. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js +2 -2
  21. package/lib/internal/template/internal/components/drag-handle-wrapper/direction-button.js.map +1 -1
  22. package/lib/internal/template/internal/components/drag-handle-wrapper/index.d.ts.map +1 -1
  23. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js +30 -7
  24. package/lib/internal/template/internal/components/drag-handle-wrapper/index.js.map +1 -1
  25. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.css.js +30 -21
  26. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.scoped.css +75 -39
  27. package/lib/internal/template/internal/components/drag-handle-wrapper/styles.selectors.js +30 -21
  28. package/lib/internal/template/internal/components/option/index.d.ts +1 -1
  29. package/lib/internal/template/internal/components/option/index.d.ts.map +1 -1
  30. package/lib/internal/template/internal/components/option/index.js +5 -1
  31. package/lib/internal/template/internal/components/option/index.js.map +1 -1
  32. package/lib/internal/template/internal/components/option/interfaces.d.ts +2 -1
  33. package/lib/internal/template/internal/components/option/interfaces.d.ts.map +1 -1
  34. package/lib/internal/template/internal/components/option/interfaces.js.map +1 -1
  35. package/lib/internal/template/internal/components/option/styles.css.js +17 -16
  36. package/lib/internal/template/internal/components/option/styles.scoped.css +32 -28
  37. package/lib/internal/template/internal/components/option/styles.selectors.js +17 -16
  38. package/lib/internal/template/internal/environment.js +2 -2
  39. package/lib/internal/template/internal/environment.json +2 -2
  40. package/lib/internal/template/multiselect/index.d.ts.map +1 -1
  41. package/lib/internal/template/multiselect/index.js +2 -2
  42. package/lib/internal/template/multiselect/index.js.map +1 -1
  43. package/lib/internal/template/multiselect/interfaces.d.ts +37 -0
  44. package/lib/internal/template/multiselect/interfaces.d.ts.map +1 -1
  45. package/lib/internal/template/multiselect/interfaces.js.map +1 -1
  46. package/lib/internal/template/multiselect/internal.d.ts.map +1 -1
  47. package/lib/internal/template/multiselect/internal.js +8 -4
  48. package/lib/internal/template/multiselect/internal.js.map +1 -1
  49. package/lib/internal/template/select/index.d.ts.map +1 -1
  50. package/lib/internal/template/select/index.js +2 -2
  51. package/lib/internal/template/select/index.js.map +1 -1
  52. package/lib/internal/template/select/interfaces.d.ts +31 -1
  53. package/lib/internal/template/select/interfaces.d.ts.map +1 -1
  54. package/lib/internal/template/select/interfaces.js.map +1 -1
  55. package/lib/internal/template/select/internal.d.ts.map +1 -1
  56. package/lib/internal/template/select/internal.js +8 -4
  57. package/lib/internal/template/select/internal.js.map +1 -1
  58. package/lib/internal/template/select/parts/item.d.ts +13 -2
  59. package/lib/internal/template/select/parts/item.d.ts.map +1 -1
  60. package/lib/internal/template/select/parts/item.js +62 -6
  61. package/lib/internal/template/select/parts/item.js.map +1 -1
  62. package/lib/internal/template/select/parts/multiselect-item.d.ts +9 -2
  63. package/lib/internal/template/select/parts/multiselect-item.d.ts.map +1 -1
  64. package/lib/internal/template/select/parts/multiselect-item.js +79 -5
  65. package/lib/internal/template/select/parts/multiselect-item.js.map +1 -1
  66. package/lib/internal/template/select/parts/plain-list.d.ts +3 -0
  67. package/lib/internal/template/select/parts/plain-list.d.ts.map +1 -1
  68. package/lib/internal/template/select/parts/plain-list.js +2 -1
  69. package/lib/internal/template/select/parts/plain-list.js.map +1 -1
  70. package/lib/internal/template/select/parts/trigger.d.ts +1 -0
  71. package/lib/internal/template/select/parts/trigger.d.ts.map +1 -1
  72. package/lib/internal/template/select/parts/trigger.js +17 -3
  73. package/lib/internal/template/select/parts/trigger.js.map +1 -1
  74. package/lib/internal/template/select/parts/virtual-list.d.ts.map +1 -1
  75. package/lib/internal/template/select/parts/virtual-list.js +6 -2
  76. package/lib/internal/template/select/parts/virtual-list.js.map +1 -1
  77. package/lib/internal/template/select/utils/render-options.d.ts +4 -1
  78. package/lib/internal/template/select/utils/render-options.d.ts.map +1 -1
  79. package/lib/internal/template/select/utils/render-options.js +15 -4
  80. package/lib/internal/template/select/utils/render-options.js.map +1 -1
  81. package/lib/internal/template/test-utils/dom/internal/option.d.ts +4 -0
  82. package/lib/internal/template/test-utils/dom/internal/option.js +10 -1
  83. package/lib/internal/template/test-utils/dom/internal/option.js.map +1 -1
  84. package/lib/internal/template/test-utils/selectors/internal/option.d.ts +4 -0
  85. package/lib/internal/template/test-utils/selectors/internal/option.js +10 -1
  86. package/lib/internal/template/test-utils/selectors/internal/option.js.map +1 -1
  87. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { BaseComponentProps } from '../internal/base-component';
3
3
  import { BaseDropdownHostProps, OptionsFilteringType, OptionsLoadItemsDetail } from '../internal/components/dropdown/interfaces';
4
4
  import { DropdownStatusProps } from '../internal/components/dropdown-status/interfaces';
@@ -172,6 +172,12 @@ export interface SelectProps extends BaseSelectProps {
172
172
  * Automatically focuses the trigger when component is mounted.
173
173
  */
174
174
  autoFocus?: boolean;
175
+ /**
176
+ * Specifies a render function to render custom options in the dropdown menu or trigger.
177
+ *
178
+ * @awsuiSystem core
179
+ */
180
+ renderOption?: SelectProps.SelectOptionItemRenderer;
175
181
  }
176
182
  export declare namespace SelectProps {
177
183
  type FilteringType = OptionsFilteringType;
@@ -179,6 +185,30 @@ export declare namespace SelectProps {
179
185
  type Option = OptionDefinition;
180
186
  type OptionGroup = OptionGroupDefinition;
181
187
  type Options = ReadonlyArray<Option | OptionGroup>;
188
+ interface SelectOptionItem {
189
+ type: 'item';
190
+ index: number;
191
+ option: Option;
192
+ highlighted: boolean;
193
+ selected: boolean;
194
+ disabled: boolean;
195
+ parent: SelectOptionGroupItem | null;
196
+ }
197
+ interface SelectOptionGroupItem {
198
+ type: 'group';
199
+ index: number;
200
+ option: OptionGroup;
201
+ disabled: boolean;
202
+ }
203
+ interface SelectTriggerOptionItem {
204
+ type: 'trigger';
205
+ option: Option;
206
+ }
207
+ type SelectItem = SelectOptionItem | SelectOptionGroupItem | SelectTriggerOptionItem;
208
+ type SelectOptionItemRenderer = (props: {
209
+ item: SelectItem;
210
+ filterText?: string;
211
+ }) => ReactNode | null;
182
212
  type LoadItemsDetail = OptionsLoadItemsDetail;
183
213
  interface ChangeDetail {
184
214
  selectedOption: Option;
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/select/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,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EAAE,OAAO,CAAC;QAClB,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;KACtC;IACD,UAAiB,qBAAqB;QACpC,IAAI,EAAE,OAAO,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,WAAW,CAAC;QACpB,QAAQ,EAAE,OAAO,CAAC;KACnB;IACD,UAAiB,uBAAuB;QACtC,IAAI,EAAE,SAAS,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB;IACD,KAAY,UAAU,GAAG,gBAAgB,GAAG,qBAAqB,GAAG,uBAAuB,CAAC;IAC5F,KAAY,wBAAwB,GAAG,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,GAAG,IAAI,CAAC;IAE9G,KAAY,eAAe,GAAG,sBAAsB,CAAC;IAErD,UAAiB,YAAY;QAC3B,cAAc,EAAE,MAAM,CAAC;KACxB;IAED,UAAiB,8BAA8B;QAC7C,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;KAC/C;IAED,UAAiB,GAAG;QAClB;;WAEG;QACH,KAAK,IAAI,IAAI,CAAC;KACf;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/select/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport {\n BaseDropdownHostProps,\n OptionsFilteringType,\n OptionsLoadItemsDetail,\n} from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status/interfaces';\nimport { OptionDefinition, OptionGroup as OptionGroupDefinition } from '../internal/components/option/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface BaseSelectProps\n extends BaseDropdownHostProps,\n BaseComponentProps,\n FormFieldValidationControlProps,\n DropdownStatusProps {\n /**\n * Specifies an array of options that are displayed to the user as a dropdown list.\n * The options can be grouped using `OptionGroup` objects.\n *\n * #### Option\n * - `value` (string) - The returned value of the option when selected.\n *\n * #### OptionGroup\n * - `value` (string) - Used to locate option group in test utils.\n * - `options` (Option[]) - (Optional) The options under this group.\n *\n * #### Shared Option and OptionGroup properties\n * - `label` (string) - (Optional) Option or group text displayed to the user.\n * - `lang` (string) - (Optional) The language of the option or group, provided as a BCP 47 language tag.\n * - `description` (string) - (Optional) Further information about the option or group that appears below the label.\n * - `disabled` (boolean) - (Optional) Determines whether the option or group is disabled.\n * - `disabledReason` (string) - (Optional) Displays tooltip near the item when disabled. Use to provide additional context.\n * - `labelTag` (string) - (Optional) A label tag that provides additional guidance, shown next to the label.\n * - `tags` [string[]] - (Optional) A list of tags giving further guidance about the option or group.\n * - `filteringTags` [string[]] - (Optional) A list of additional tags used for automatic filtering.\n * - `iconName` (string) - (Optional) Specifies the name of an [icon](/components/icon/) to display in the option or group.\n * - `iconAriaLabel` (string) - (Optional) Specifies alternate text for the icon. We recommend that you provide this for accessibility.\n * - `iconAlt` (string) - (Optional) **Deprecated**, replaced by \\`iconAriaLabel\\`. Specifies alternate text for a custom icon, for use with `iconUrl`.\n * - `iconUrl` (string) - (Optional) URL of a custom icon.\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n *\n * Note: Only one level of option nesting is supported.\n *\n * If you want to use the built-in filtering capabilities of this component, provide\n * a list of all valid options here and they will be automatically filtered based on the user's filtering input.\n *\n * Alternatively, you can listen to the `onChange` or `onLoadItems` event and set new options\n * on your own.\n **/\n options?: SelectProps.Options;\n /**\n * Determines how filtering is applied to the list of `options`:\n *\n * * `auto` - The component will automatically filter options based on user input.\n * * `manual` - You will set up `onChange` or `onLoadItems` event listeners and filter options on your side or request\n * them from server.\n *\n * By default the component will filter the provided `options` based on the value of the filtering input field.\n * Only options that have a `value`, `label`, `description` or `labelTag` that contains the input value as a substring\n * are displayed in the list of options.\n *\n * If you set this property to `manual`, this default filtering mechanism is disabled and all provided `options` are\n * displayed in the dropdown list. In that case make sure that you use the `onChange` or `onLoadItems` events in order\n * to set the `options` property to the options that are relevant for the user, given the filtering input value.\n *\n * Note: Manual filtering doesn't disable match highlighting.\n **/\n filteringType?: OptionsFilteringType;\n\n /**\n * Determines whether the whole select component is disabled.\n */\n disabled?: boolean;\n /**\n * Specifies the placeholder to display in the filtering input if filtering is enabled.\n */\n filteringPlaceholder?: string;\n\n /**\n * Specifies the text to display with the number of matches at the bottom of the dropdown menu while filtering.\n */\n filteringResultsText?: (matchesCount: number, totalCount: number) => string;\n /**\n * Adds an `aria-label` on the built-in filtering input if filtering is enabled.\n */\n filteringAriaLabel?: string;\n /**\n * Adds an `aria-label` to the clear button inside the search input.\n * @i18n\n */\n filteringClearAriaLabel?: string;\n /**\n * @deprecated Has no effect.\n */\n name?: string;\n /**\n * Specifies the hint text that's displayed in the field when no option has been selected.\n */\n placeholder?: string;\n /**\n * Specifies the ID for the trigger component. It uses an automatically generated ID by default.\n */\n controlId?: string;\n /**\n * Adds `aria-required` to the native input element.\n */\n ariaRequired?: boolean;\n /**\n * Adds `aria-label` to the select element.\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n /**\n * Specifies the localized string that describes an option as being selected.\n * This is required to provide a good screen reader experience. For more information, see the\n * [accessibility guidelines](/components/select/?tabId=usage#accessibility-guidelines).\n * @i18n\n */\n selectedAriaLabel?: string;\n /**\n * Overrides the element that is announced to screen readers\n * when the highlighted option changes. By default, this announces\n * the option's name and properties, and its selected state if\n * the `selectedAriaLabel` property is defined.\n * The highlighted option is provided, and its group (if groups\n * are used and it differs from the group of the previously highlighted option).\n *\n * For more information, see the\n * [accessibility guidelines](/components/select/?tabId=usage#accessibility-guidelines).\n */\n renderHighlightedAriaLive?: SelectProps.ContainingOptionAndGroupString;\n /**\n * Displayed for `filteringType=\"auto\"` when there are no matches for the filtering.\n */\n noMatch?: React.ReactNode;\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler;\n /**\n * Called when input focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler;\n\n /**\n * Specifies if the control is read-only, which prevents the\n * user from both modifying the value and opening the dropdown. A read-only control is still focusable.\n */\n readOnly?: boolean;\n}\n\nexport interface SelectProps extends BaseSelectProps {\n /**\n * Adds a small label inline with the input for saving vertical space in the UI.\n * For use with collection select filters only.\n */\n inlineLabelText?: string;\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't using `inlineLabelText` and isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n /**\n * Defines the variant of the trigger. You can use a simple label or the entire option (`label | option`)\n */\n triggerVariant?: SelectProps.TriggerVariant;\n /**\n * Specifies the currently selected option.\n * If you want to clear the selection, use `null`.\n */\n selectedOption: SelectProps.Option | null;\n /**\n * Called when the user selects an option.\n * The event `detail` contains the current `selectedOption`.\n */\n onChange?: NonCancelableEventHandler<SelectProps.ChangeDetail>;\n\n /**\n * Automatically focuses the trigger when component is mounted.\n */\n autoFocus?: boolean;\n}\n\nexport namespace SelectProps {\n export type FilteringType = OptionsFilteringType;\n export type TriggerVariant = 'label' | 'option';\n\n export type Option = OptionDefinition;\n export type OptionGroup = OptionGroupDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n\n export type LoadItemsDetail = OptionsLoadItemsDetail;\n\n export interface ChangeDetail {\n selectedOption: Option;\n }\n\n export interface ContainingOptionAndGroupString {\n (option: Option, group?: OptionGroup): string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the element without opening the dropdown or showing a visual focus indicator.\n */\n focus(): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/select/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { ReactNode } from 'react';\n\nimport { BaseComponentProps } from '../internal/base-component';\nimport {\n BaseDropdownHostProps,\n OptionsFilteringType,\n OptionsLoadItemsDetail,\n} from '../internal/components/dropdown/interfaces';\nimport { DropdownStatusProps } from '../internal/components/dropdown-status/interfaces';\nimport { OptionDefinition, OptionGroup as OptionGroupDefinition } from '../internal/components/option/interfaces';\nimport { FormFieldValidationControlProps } from '../internal/context/form-field-context';\nimport { NonCancelableEventHandler } from '../internal/events';\n\nexport interface BaseSelectProps\n extends BaseDropdownHostProps,\n BaseComponentProps,\n FormFieldValidationControlProps,\n DropdownStatusProps {\n /**\n * Specifies an array of options that are displayed to the user as a dropdown list.\n * The options can be grouped using `OptionGroup` objects.\n *\n * #### Option\n * - `value` (string) - The returned value of the option when selected.\n *\n * #### OptionGroup\n * - `value` (string) - Used to locate option group in test utils.\n * - `options` (Option[]) - (Optional) The options under this group.\n *\n * #### Shared Option and OptionGroup properties\n * - `label` (string) - (Optional) Option or group text displayed to the user.\n * - `lang` (string) - (Optional) The language of the option or group, provided as a BCP 47 language tag.\n * - `description` (string) - (Optional) Further information about the option or group that appears below the label.\n * - `disabled` (boolean) - (Optional) Determines whether the option or group is disabled.\n * - `disabledReason` (string) - (Optional) Displays tooltip near the item when disabled. Use to provide additional context.\n * - `labelTag` (string) - (Optional) A label tag that provides additional guidance, shown next to the label.\n * - `tags` [string[]] - (Optional) A list of tags giving further guidance about the option or group.\n * - `filteringTags` [string[]] - (Optional) A list of additional tags used for automatic filtering.\n * - `iconName` (string) - (Optional) Specifies the name of an [icon](/components/icon/) to display in the option or group.\n * - `iconAriaLabel` (string) - (Optional) Specifies alternate text for the icon. We recommend that you provide this for accessibility.\n * - `iconAlt` (string) - (Optional) **Deprecated**, replaced by \\`iconAriaLabel\\`. Specifies alternate text for a custom icon, for use with `iconUrl`.\n * - `iconUrl` (string) - (Optional) URL of a custom icon.\n * - `iconSvg` (ReactNode) - (Optional) Custom SVG icon. Equivalent to the `svg` slot of the [icon component](/components/icon/).\n *\n * Note: Only one level of option nesting is supported.\n *\n * If you want to use the built-in filtering capabilities of this component, provide\n * a list of all valid options here and they will be automatically filtered based on the user's filtering input.\n *\n * Alternatively, you can listen to the `onChange` or `onLoadItems` event and set new options\n * on your own.\n **/\n options?: SelectProps.Options;\n\n /**\n * Determines how filtering is applied to the list of `options`:\n *\n * * `auto` - The component will automatically filter options based on user input.\n * * `manual` - You will set up `onChange` or `onLoadItems` event listeners and filter options on your side or request\n * them from server.\n *\n * By default the component will filter the provided `options` based on the value of the filtering input field.\n * Only options that have a `value`, `label`, `description` or `labelTag` that contains the input value as a substring\n * are displayed in the list of options.\n *\n * If you set this property to `manual`, this default filtering mechanism is disabled and all provided `options` are\n * displayed in the dropdown list. In that case make sure that you use the `onChange` or `onLoadItems` events in order\n * to set the `options` property to the options that are relevant for the user, given the filtering input value.\n *\n * Note: Manual filtering doesn't disable match highlighting.\n **/\n filteringType?: OptionsFilteringType;\n\n /**\n * Determines whether the whole select component is disabled.\n */\n disabled?: boolean;\n /**\n * Specifies the placeholder to display in the filtering input if filtering is enabled.\n */\n filteringPlaceholder?: string;\n\n /**\n * Specifies the text to display with the number of matches at the bottom of the dropdown menu while filtering.\n */\n filteringResultsText?: (matchesCount: number, totalCount: number) => string;\n /**\n * Adds an `aria-label` on the built-in filtering input if filtering is enabled.\n */\n filteringAriaLabel?: string;\n /**\n * Adds an `aria-label` to the clear button inside the search input.\n * @i18n\n */\n filteringClearAriaLabel?: string;\n /**\n * @deprecated Has no effect.\n */\n name?: string;\n /**\n * Specifies the hint text that's displayed in the field when no option has been selected.\n */\n placeholder?: string;\n /**\n * Specifies the ID for the trigger component. It uses an automatically generated ID by default.\n */\n controlId?: string;\n /**\n * Adds `aria-required` to the native input element.\n */\n ariaRequired?: boolean;\n /**\n * Adds `aria-label` to the select element.\n * Use this if you don't have a visible label for this control.\n */\n ariaLabel?: string;\n /**\n * Specifies the localized string that describes an option as being selected.\n * This is required to provide a good screen reader experience. For more information, see the\n * [accessibility guidelines](/components/select/?tabId=usage#accessibility-guidelines).\n * @i18n\n */\n selectedAriaLabel?: string;\n /**\n * Overrides the element that is announced to screen readers\n * when the highlighted option changes. By default, this announces\n * the option's name and properties, and its selected state if\n * the `selectedAriaLabel` property is defined.\n * The highlighted option is provided, and its group (if groups\n * are used and it differs from the group of the previously highlighted option).\n *\n * For more information, see the\n * [accessibility guidelines](/components/select/?tabId=usage#accessibility-guidelines).\n */\n renderHighlightedAriaLive?: SelectProps.ContainingOptionAndGroupString;\n /**\n * Displayed for `filteringType=\"auto\"` when there are no matches for the filtering.\n */\n noMatch?: React.ReactNode;\n /**\n * Called when input focus is removed from the UI control.\n */\n onBlur?: NonCancelableEventHandler;\n /**\n * Called when input focus is set onto the UI control.\n */\n onFocus?: NonCancelableEventHandler;\n\n /**\n * Specifies if the control is read-only, which prevents the\n * user from both modifying the value and opening the dropdown. A read-only control is still focusable.\n */\n readOnly?: boolean;\n}\n\nexport interface SelectProps extends BaseSelectProps {\n /**\n * Adds a small label inline with the input for saving vertical space in the UI.\n * For use with collection select filters only.\n */\n inlineLabelText?: string;\n /**\n * Adds `aria-labelledby` to the component. If you're using this component within a form field,\n * don't set this property because the form field component automatically sets it.\n *\n * Use this property if the component isn't using `inlineLabelText` and isn't surrounded by a form field, or you want to override the value\n * automatically set by the form field (for example, if you have two components within a single form field).\n *\n * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.\n */\n ariaLabelledby?: string;\n /**\n * Defines the variant of the trigger. You can use a simple label or the entire option (`label | option`)\n */\n triggerVariant?: SelectProps.TriggerVariant;\n /**\n * Specifies the currently selected option.\n * If you want to clear the selection, use `null`.\n */\n selectedOption: SelectProps.Option | null;\n /**\n * Called when the user selects an option.\n * The event `detail` contains the current `selectedOption`.\n */\n onChange?: NonCancelableEventHandler<SelectProps.ChangeDetail>;\n\n /**\n * Automatically focuses the trigger when component is mounted.\n */\n autoFocus?: boolean;\n /**\n * Specifies a render function to render custom options in the dropdown menu or trigger.\n *\n * @awsuiSystem core\n */\n renderOption?: SelectProps.SelectOptionItemRenderer;\n}\n\nexport namespace SelectProps {\n export type FilteringType = OptionsFilteringType;\n export type TriggerVariant = 'label' | 'option';\n\n export type Option = OptionDefinition;\n export type OptionGroup = OptionGroupDefinition;\n export type Options = ReadonlyArray<Option | OptionGroup>;\n\n export interface SelectOptionItem {\n type: 'item';\n index: number;\n option: Option;\n highlighted: boolean;\n selected: boolean;\n disabled: boolean;\n parent: SelectOptionGroupItem | null;\n }\n export interface SelectOptionGroupItem {\n type: 'group';\n index: number;\n option: OptionGroup;\n disabled: boolean;\n }\n export interface SelectTriggerOptionItem {\n type: 'trigger';\n option: Option;\n }\n export type SelectItem = SelectOptionItem | SelectOptionGroupItem | SelectTriggerOptionItem;\n export type SelectOptionItemRenderer = (props: { item: SelectItem; filterText?: string }) => ReactNode | null;\n\n export type LoadItemsDetail = OptionsLoadItemsDetail;\n\n export interface ChangeDetail {\n selectedOption: Option;\n }\n\n export interface ContainingOptionAndGroupString {\n (option: Option, group?: OptionGroup): string;\n }\n\n export interface Ref {\n /**\n * Sets focus on the element without opening the dropdown or showing a visual focus indicator.\n */\n focus(): void;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAa3C,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IAC3G,kBAAkB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CACxC;AAED,QAAA,MAAM,cAAc,6FAwPnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAe3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAa3C,MAAM,WAAW,mBAAoB,SAAQ,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,EAAE,0BAA0B;IAC3G,kBAAkB,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;CACxC;AAED,QAAA,MAAM,cAAc,6FAgQnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -23,7 +23,7 @@ import { useLoadItems } from './utils/use-load-items';
23
23
  import { useNativeSearch } from './utils/use-native-search';
24
24
  import { useSelect } from './utils/use-select';
25
25
  import styles from './styles.css.js';
26
- 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, ...restProps }, externalRef) => {
26
+ 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, ...restProps }, externalRef) => {
27
27
  var _a;
28
28
  const baseProps = getBaseProps(restProps);
29
29
  const formFieldContext = useFormFieldContext(restProps);
@@ -73,7 +73,7 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
73
73
  (_a = scrollToIndex.current) === null || _a === void 0 ? void 0 : _a.call(scrollToIndex, highlightedIndex);
74
74
  }, [highlightedIndex]);
75
75
  const filter = (React.createElement(Filter, { clearAriaLabel: filteringClearAriaLabel, filteringType: filteringType, placeholder: filteringPlaceholder, ariaLabel: filteringAriaLabel, ariaRequired: ariaRequired, value: filteringValue, ...getFilterProps() }));
76
- const trigger = (React.createElement(Trigger, { ref: triggerRef, placeholder: placeholder, disabled: disabled, readOnly: readOnly, triggerVariant: triggerVariant, triggerProps: getTriggerProps(disabled, autoFocus), selectedOption: selectedOption, isOpen: isOpen, inFilteringToken: __inFilteringToken, inlineLabelText: inlineLabelText, ...formFieldContext, controlId: controlId, ariaLabelledby: joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId) }));
76
+ const trigger = (React.createElement(Trigger, { renderOption: renderOption, ref: triggerRef, placeholder: placeholder, disabled: disabled, readOnly: readOnly, triggerVariant: triggerVariant, triggerProps: getTriggerProps(disabled, autoFocus), selectedOption: selectedOption, isOpen: isOpen, inFilteringToken: __inFilteringToken, inlineLabelText: inlineLabelText, ...formFieldContext, controlId: controlId, ariaLabelledby: joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId) }));
77
77
  const isEmpty = !options || options.length === 0;
78
78
  const isNoMatch = filteredOptions && filteredOptions.length === 0;
79
79
  const isFiltered = filteringType !== 'none' && filteringValue.length > 0 && filteredOptions && filteredOptions.length > 0;
@@ -119,9 +119,13 @@ const InternalSelect = React.forwardRef(({ options, filteringType = 'none', filt
119
119
  };
120
120
  const mergedRef = useMergeRefs(rootRef, __internalRootRef);
121
121
  const dropdownProps = getDropdownProps();
122
+ const hasOptions = useRef(options.length > 0);
123
+ hasOptions.current = hasOptions.current || options.length > 0;
122
124
  return (React.createElement("div", { ...baseProps, ref: mergedRef, className: clsx(styles.root, baseProps.className), onKeyDown: handleNativeSearch },
123
- React.createElement(Dropdown, { ...dropdownProps, ariaLabelledby: dropdownProps.dropdownContentRole ? joinStrings(selectAriaLabelId, controlId) : undefined, ariaDescribedby: dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined, open: isOpen, stretchTriggerHeight: !!__inFilteringToken, stretchBeyondTriggerWidth: true, trigger: trigger, header: filter, onMouseDown: handleMouseDown, footer: dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, expandToViewport: expandToViewport },
124
- React.createElement(ListComponent, { listBottom: !dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, menuProps: menuProps, getOptionProps: getOptionProps, filteredOptions: filteredOptions, filteringValue: filteringValue, ref: scrollToIndex, hasDropdownStatus: dropdownStatus.content !== null, screenReaderContent: announcement, highlightType: highlightType })),
125
+ React.createElement(Dropdown, { ...dropdownProps, ariaLabelledby: dropdownProps.dropdownContentRole ? joinStrings(selectAriaLabelId, controlId) : undefined, ariaDescribedby: dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined, open: isOpen, stretchTriggerHeight: !!__inFilteringToken, stretchBeyondTriggerWidth: true, trigger: trigger, header: filter, onMouseDown: handleMouseDown, footer: dropdownStatus.isSticky ? (React.createElement(DropdownFooter, { content: isOpen ? dropdownStatus.content : null, id: footerId })) : null, expandToViewport: expandToViewport,
126
+ // Forces dropdown position recalculation when new options are loaded
127
+ contentKey: hasOptions.current.toString() },
128
+ 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 })),
125
129
  React.createElement("div", { hidden: true, id: selectAriaLabelId }, ariaLabel || inlineLabelText)));
126
130
  });
127
131
  export default InternalSelect;
@@ -1 +1 @@
1
- {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEpG,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,eAAe,MAAM,oCAAoC,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,SAA8B,MAAM,oBAAoB,CAAC;AAChE,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,WAAW,MAAM,sBAAsB,CAAC;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,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,eAAe,EAC5B,MAAM,EACJ,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CACxB,oBAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAI,CAClF,CAAC,CAAC,CAAC,IAAI,EAEV,gBAAgB,EAAE,gBAAgB;YAElC,oBAAC,aAAa,IACZ,UAAU,EACR,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CACzB,oBAAC,cAAc,IAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,QAAQ,GAAI,CAClF,CAAC,CAAC,CAAC,IAAI,EAEV,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,aAAa,EAClB,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,mBAAmB,EAAE,YAAY,EACjC,aAAa,EAAE,aAAa,GAC5B,CACO;QACX,6BAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,IACrC,SAAS,IAAI,eAAe,CACzB,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context.js';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport { OptionGroup } from '../internal/components/option/interfaces.js';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options.js';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings/join-strings.js';\nimport { SelectProps } from './interfaces';\nimport Filter from './parts/filter';\nimport PlainList, { SelectListProps } from './parts/plain-list';\nimport Trigger from './parts/trigger';\nimport VirtualList from './parts/virtual-list';\nimport { checkOptionValueField } from './utils/check-option-value-field';\nimport { useAnnouncement } from './utils/use-announcement';\nimport { useLoadItems } from './utils/use-load-items';\nimport { useNativeSearch } from './utils/use-native-search';\nimport { useSelect } from './utils/use-select';\n\nimport styles from './styles.css.js';\n\nexport interface InternalSelectProps extends SomeRequired<SelectProps, 'options'>, InternalBaseComponentProps {\n __inFilteringToken?: 'root' | 'nested';\n}\n\nconst InternalSelect = React.forwardRef(\n (\n {\n options,\n filteringType = 'none',\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n filteringResultsText,\n inlineLabelText,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n statusType = 'finished',\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n triggerVariant = 'label',\n renderHighlightedAriaLive,\n selectedOption,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n virtualScroll,\n expandToViewport,\n autoFocus,\n __inFilteringToken,\n __internalRootRef,\n ...restProps\n }: InternalSelectProps,\n externalRef: React.Ref<SelectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const i18n = useInternalI18n('select');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Select', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n options,\n statusType,\n });\n\n checkControlled('Select', 'selectedOption', selectedOption, 'onChange', onChange);\n\n checkOptionValueField('Select', 'options', options);\n\n const [filteringValue, setFilteringValue] = useState('');\n\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\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 selectOption,\n announceSelected,\n focusActiveRef,\n } = useSelect({\n selectedOptions: selectedOption ? [selectedOption] : [],\n updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),\n options: filteredOptions,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n fireLoadItems,\n setFilteringValue,\n statusType,\n });\n\n const handleNativeSearch = useNativeSearch({\n isEnabled: filteringType === 'none' && !readOnly,\n options: filteredOptions,\n highlightOption: !isOpen ? selectOption : highlightOption,\n highlightedOption: !isOpen ? selectedOption : highlightedOption?.option,\n });\n\n const selectAriaLabelId = useUniqueId('select-arialabel-');\n const footerId = useUniqueId('footer');\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\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 {...getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerVariant={triggerVariant}\n triggerProps={getTriggerProps(disabled, autoFocus)}\n selectedOption={selectedOption}\n isOpen={isOpen}\n inFilteringToken={__inFilteringToken}\n inlineLabelText={inlineLabelText}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId)}\n />\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\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 errorIconAriaLabel,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const menuProps = {\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(selectAriaLabelId, controlId),\n ariaDescribedby: dropdownStatus.content ? footerId : undefined,\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 ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (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 mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n const dropdownProps = getDropdownProps();\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(styles.root, baseProps.className)}\n onKeyDown={handleNativeSearch}\n >\n <Dropdown\n {...dropdownProps}\n ariaLabelledby={dropdownProps.dropdownContentRole ? joinStrings(selectAriaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined\n }\n open={isOpen}\n stretchTriggerHeight={!!__inFilteringToken}\n stretchBeyondTriggerWidth={true}\n trigger={trigger}\n header={filter}\n onMouseDown={handleMouseDown}\n footer={\n dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n expandToViewport={expandToViewport}\n >\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n menuProps={menuProps}\n getOptionProps={getOptionProps}\n filteredOptions={filteredOptions}\n filteringValue={filteringValue}\n ref={scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n screenReaderContent={announcement}\n highlightType={highlightType}\n />\n </Dropdown>\n <div hidden={true} id={selectAriaLabelId}>\n {ariaLabel || inlineLabelText}\n </div>\n </div>\n );\n }\n);\n\nexport default InternalSelect;\n"]}
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/select/internal.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAEpG,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AACvD,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MA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,IAAI,EAEV,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAC9B,GAAG,EAAE,aAAa,EAClB,iBAAiB,EAAE,cAAc,CAAC,OAAO,KAAK,IAAI,EAClD,mBAAmB,EAAE,YAAY,EACjC,aAAa,EAAE,aAAa,GAC5B,CACO;QACX,6BAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,iBAAiB,IACrC,SAAS,IAAI,eAAe,CACzB,CACF,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useUniqueId, warnOnce } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useInternalI18n } from '../i18n/context.js';\nimport { getBaseProps } from '../internal/base-component';\nimport Dropdown from '../internal/components/dropdown';\nimport DropdownFooter from '../internal/components/dropdown-footer';\nimport { useDropdownStatus } from '../internal/components/dropdown-status';\nimport { OptionGroup } from '../internal/components/option/interfaces.js';\nimport { prepareOptions } from '../internal/components/option/utils/prepare-options.js';\nimport { useFormFieldContext } from '../internal/context/form-field-context';\nimport { fireNonCancelableEvent } from '../internal/events';\nimport checkControlled from '../internal/hooks/check-controlled';\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { SomeRequired } from '../internal/types';\nimport { joinStrings } from '../internal/utils/strings/join-strings.js';\nimport { SelectProps } from './interfaces';\nimport Filter from './parts/filter';\nimport PlainList, { SelectListProps } from './parts/plain-list';\nimport Trigger from './parts/trigger';\nimport VirtualList from './parts/virtual-list';\nimport { checkOptionValueField } from './utils/check-option-value-field';\nimport { useAnnouncement } from './utils/use-announcement';\nimport { useLoadItems } from './utils/use-load-items';\nimport { useNativeSearch } from './utils/use-native-search';\nimport { useSelect } from './utils/use-select';\n\nimport styles from './styles.css.js';\n\nexport interface InternalSelectProps extends SomeRequired<SelectProps, 'options'>, InternalBaseComponentProps {\n __inFilteringToken?: 'root' | 'nested';\n}\n\nconst InternalSelect = React.forwardRef(\n (\n {\n options,\n filteringType = 'none',\n filteringPlaceholder,\n filteringAriaLabel,\n filteringClearAriaLabel,\n filteringResultsText,\n inlineLabelText,\n ariaRequired,\n placeholder,\n disabled,\n readOnly,\n ariaLabel,\n statusType = 'finished',\n empty,\n loadingText,\n finishedText,\n errorText,\n noMatch,\n triggerVariant = 'label',\n renderHighlightedAriaLive,\n selectedOption,\n onBlur,\n onFocus,\n onLoadItems,\n onChange,\n virtualScroll,\n expandToViewport,\n autoFocus,\n __inFilteringToken,\n __internalRootRef,\n renderOption,\n ...restProps\n }: InternalSelectProps,\n externalRef: React.Ref<SelectProps.Ref>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const i18n = useInternalI18n('select');\n const errorIconAriaLabel = i18n('errorIconAriaLabel', restProps.errorIconAriaLabel);\n const selectedAriaLabel = i18n('selectedAriaLabel', restProps.selectedAriaLabel);\n const recoveryText = i18n('recoveryText', restProps.recoveryText);\n\n if (restProps.recoveryText && !onLoadItems) {\n warnOnce('Select', '`onLoadItems` must be provided for `recoveryText` to be displayed.');\n }\n\n const { handleLoadMore, handleRecoveryClick, fireLoadItems } = useLoadItems({\n onLoadItems,\n options,\n statusType,\n });\n\n checkControlled('Select', 'selectedOption', selectedOption, 'onChange', onChange);\n\n checkOptionValueField('Select', 'options', options);\n\n const [filteringValue, setFilteringValue] = useState('');\n\n const { filteredOptions, parentMap, totalCount, matchesCount } = prepareOptions(\n options,\n filteringType,\n filteringValue\n );\n\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n\n const selfControlId = useUniqueId('trigger');\n const controlId = formFieldContext.controlId ?? selfControlId;\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 selectOption,\n announceSelected,\n focusActiveRef,\n } = useSelect({\n selectedOptions: selectedOption ? [selectedOption] : [],\n updateSelectedOption: option => fireNonCancelableEvent(onChange, { selectedOption: option }),\n options: filteredOptions,\n filteringType,\n onBlur,\n onFocus,\n externalRef,\n fireLoadItems,\n setFilteringValue,\n statusType,\n });\n\n const handleNativeSearch = useNativeSearch({\n isEnabled: filteringType === 'none' && !readOnly,\n options: filteredOptions,\n highlightOption: !isOpen ? selectOption : highlightOption,\n highlightedOption: !isOpen ? selectedOption : highlightedOption?.option,\n });\n\n const selectAriaLabelId = useUniqueId('select-arialabel-');\n const footerId = useUniqueId('footer');\n\n useEffect(() => {\n scrollToIndex.current?.(highlightedIndex);\n }, [highlightedIndex]);\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 {...getFilterProps()}\n />\n );\n\n const trigger = (\n <Trigger\n renderOption={renderOption}\n ref={triggerRef}\n placeholder={placeholder}\n disabled={disabled}\n readOnly={readOnly}\n triggerVariant={triggerVariant}\n triggerProps={getTriggerProps(disabled, autoFocus)}\n selectedOption={selectedOption}\n isOpen={isOpen}\n inFilteringToken={__inFilteringToken}\n inlineLabelText={inlineLabelText}\n {...formFieldContext}\n controlId={controlId}\n ariaLabelledby={joinStrings(formFieldContext.ariaLabelledby, selectAriaLabelId)}\n />\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\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 errorIconAriaLabel,\n onRecoveryClick: () => {\n handleRecoveryClick();\n focusActiveRef();\n },\n hasRecoveryCallback: !!onLoadItems,\n });\n\n const menuProps = {\n ...getMenuProps(),\n onLoadMore: handleLoadMore,\n ariaLabelledby: joinStrings(selectAriaLabelId, controlId),\n ariaDescribedby: dropdownStatus.content ? footerId : undefined,\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 ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const handleMouseDown = (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 mergedRef = useMergeRefs(rootRef, __internalRootRef);\n\n const dropdownProps = getDropdownProps();\n\n const hasOptions = useRef(options.length > 0);\n hasOptions.current = hasOptions.current || options.length > 0;\n\n return (\n <div\n {...baseProps}\n ref={mergedRef}\n className={clsx(styles.root, baseProps.className)}\n onKeyDown={handleNativeSearch}\n >\n <Dropdown\n {...dropdownProps}\n ariaLabelledby={dropdownProps.dropdownContentRole ? joinStrings(selectAriaLabelId, controlId) : undefined}\n ariaDescribedby={\n dropdownProps.dropdownContentRole ? (dropdownStatus.content ? footerId : undefined) : undefined\n }\n open={isOpen}\n stretchTriggerHeight={!!__inFilteringToken}\n stretchBeyondTriggerWidth={true}\n trigger={trigger}\n header={filter}\n onMouseDown={handleMouseDown}\n footer={\n dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n expandToViewport={expandToViewport}\n // Forces dropdown position recalculation when new options are loaded\n contentKey={hasOptions.current.toString()}\n >\n <ListComponent\n listBottom={\n !dropdownStatus.isSticky ? (\n <DropdownFooter content={isOpen ? dropdownStatus.content : null} id={footerId} />\n ) : null\n }\n renderOption={renderOption}\n menuProps={menuProps}\n getOptionProps={getOptionProps}\n filteredOptions={filteredOptions}\n filteringValue={filteringValue}\n ref={scrollToIndex}\n hasDropdownStatus={dropdownStatus.content !== null}\n screenReaderContent={announcement}\n highlightType={highlightType}\n />\n </Dropdown>\n <div hidden={true} id={selectAriaLabelId}>\n {ariaLabel || inlineLabelText}\n </div>\n </div>\n );\n }\n);\n\nexport default InternalSelect;\n"]}
@@ -1,7 +1,10 @@
1
1
  import React from 'react';
2
2
  import { DropdownOption } from '../../internal/components/option/interfaces';
3
3
  import { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option.js';
4
- export interface ItemProps {
4
+ import { SelectProps } from '../interfaces';
5
+ export interface ItemProps<T = SelectProps.SelectOptionItemRenderer> {
6
+ index: number;
7
+ virtualIndex?: number;
5
8
  option: DropdownOption;
6
9
  highlighted?: boolean;
7
10
  selected?: boolean;
@@ -17,7 +20,15 @@ export interface ItemProps {
17
20
  highlightType?: HighlightType['type'];
18
21
  withScrollbar?: boolean;
19
22
  sticky?: boolean;
23
+ renderOption?: T;
24
+ parentProps?: ItemParentProps;
20
25
  }
21
- declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ItemProps & React.RefAttributes<HTMLDivElement>>>;
26
+ export interface ItemParentProps {
27
+ index: number;
28
+ virtualIndex?: number;
29
+ option: DropdownOption;
30
+ disabled: boolean;
31
+ }
32
+ declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<ItemProps<SelectProps.SelectOptionItemRenderer> & React.RefAttributes<HTMLDivElement>>>;
22
33
  export default _default;
23
34
  //# sourceMappingURL=item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../../../../src/select/parts/item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAS3D,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,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,CAAC,CAAC;IACjB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;;AA0KD,wBAAkD"}
@@ -11,7 +11,35 @@ import SelectableItem from '../../internal/components/selectable-item';
11
11
  import Tooltip from '../../internal/components/tooltip';
12
12
  import useHiddenDescription from '../../internal/hooks/use-hidden-description';
13
13
  import styles from './styles.css.js';
14
- const Item = ({ option, highlighted, selected, filteringValue, hasCheckbox, virtualPosition, padBottom, isNextSelected, isPreviousSelected, screenReaderContent, ariaPosinset, ariaSetsize, highlightType, withScrollbar, sticky, ...restProps }, ref) => {
14
+ const toSelectOptionGroupItem = (props) => {
15
+ var _a;
16
+ return {
17
+ type: 'group',
18
+ index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
19
+ option: props.option.option,
20
+ disabled: props.disabled,
21
+ };
22
+ };
23
+ const toSelectOptionItem = (props) => {
24
+ var _a, _b, _c, _d;
25
+ return {
26
+ type: 'item',
27
+ index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
28
+ option: props.option.option,
29
+ selected: props.selected,
30
+ highlighted: props.highlighted,
31
+ disabled: props.disabled,
32
+ parent: props.parentProps
33
+ ? toSelectOptionGroupItem({
34
+ index: (_b = props.parentProps) === null || _b === void 0 ? void 0 : _b.index,
35
+ virtualIndex: (_c = props.parentProps) === null || _c === void 0 ? void 0 : _c.virtualIndex,
36
+ option: (_d = props.parentProps) === null || _d === void 0 ? void 0 : _d.option,
37
+ disabled: props.disabled,
38
+ })
39
+ : null,
40
+ };
41
+ };
42
+ const Item = ({ index, virtualIndex, option, highlighted, selected, filteringValue, hasCheckbox, virtualPosition, padBottom, isNextSelected, isPreviousSelected, screenReaderContent, ariaPosinset, ariaSetsize, highlightType, withScrollbar, sticky, renderOption, parentProps, ...restProps }, ref) => {
15
43
  const baseProps = getBaseProps(restProps);
16
44
  const isParent = option.type === 'parent';
17
45
  const isChild = option.type === 'child';
@@ -23,14 +51,42 @@ const Item = ({ option, highlighted, selected, filteringValue, hasCheckbox, virt
23
51
  const { descriptionEl, descriptionId } = useHiddenDescription(disabledReason);
24
52
  const [canShowTooltip, setCanShowTooltip] = useState(true);
25
53
  useEffect(() => setCanShowTooltip(true), [highlighted]);
26
- return (React.createElement(SelectableItem, { ariaSelected: Boolean(selected), selected: selected, isNextSelected: isNextSelected, isPreviousSelected: isPreviousSelected, highlighted: highlighted, disabled: option.disabled, isParent: isParent, isChild: isChild, ref: useMergeRefs(ref, internalRef), virtualPosition: virtualPosition, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaPosinset: ariaPosinset, ariaSetsize: ariaSetsize, highlightType: highlightType, ariaDescribedby: isDisabledWithReason ? descriptionId : '', value: option.option.value, withScrollbar: withScrollbar, sticky: sticky, ...baseProps },
54
+ const getSelectItemProps = (option) => {
55
+ if (option.type === 'parent') {
56
+ return toSelectOptionGroupItem({
57
+ option: option,
58
+ index: index,
59
+ virtualIndex: virtualIndex,
60
+ disabled: !!disabled,
61
+ });
62
+ }
63
+ else {
64
+ return toSelectOptionItem({
65
+ option: option,
66
+ index: index,
67
+ virtualIndex: virtualIndex,
68
+ disabled: !!disabled,
69
+ highlighted: !!highlighted,
70
+ selected: !!selected,
71
+ parentProps: parentProps,
72
+ });
73
+ }
74
+ };
75
+ const renderOptionWrapper = (option) => {
76
+ if (!renderOption) {
77
+ return null;
78
+ }
79
+ return renderOption({ item: getSelectItemProps(option), filterText: filteringValue });
80
+ };
81
+ const renderResult = renderOptionWrapper(option);
82
+ return (React.createElement(SelectableItem, { disableContentStyling: !!renderResult, ariaSelected: Boolean(selected), selected: selected, isNextSelected: isNextSelected, isPreviousSelected: isPreviousSelected, highlighted: highlighted, disabled: option.disabled, isParent: isParent, isChild: isChild, ref: useMergeRefs(ref, internalRef), virtualPosition: virtualPosition, padBottom: padBottom, screenReaderContent: screenReaderContent, ariaPosinset: ariaPosinset, ariaSetsize: ariaSetsize, highlightType: highlightType, ariaDescribedby: isDisabledWithReason ? descriptionId : '', value: option.option.value, withScrollbar: withScrollbar, sticky: sticky, ...baseProps },
27
83
  React.createElement("div", { className: clsx(styles.item, !isParent && wrappedOption.labelTag && styles['show-label-tag']) },
28
- hasCheckbox && !isParent && (React.createElement("div", { className: styles.checkbox },
84
+ !renderResult && hasCheckbox && !isParent && (React.createElement("div", { className: styles.checkbox },
29
85
  React.createElement(CheckboxIcon, { checked: selected || false, disabled: option.disabled }))),
30
- React.createElement(Option, { option: { ...wrappedOption, disabled }, highlightedOption: highlighted, selectedOption: selected, highlightText: filteringValue, isGroupOption: isParent }),
31
- !hasCheckbox && !isParent && selected && (React.createElement("div", { className: styles['selected-icon'] },
86
+ React.createElement(Option, { customContent: renderResult, option: { ...wrappedOption, disabled }, highlightedOption: highlighted, selectedOption: selected, highlightText: filteringValue, isGroupOption: isParent }),
87
+ !renderResult && !hasCheckbox && !isParent && selected && (React.createElement("div", { className: styles['selected-icon'] },
32
88
  React.createElement(InternalIcon, { name: "check" }))),
33
- isDisabledWithReason && (React.createElement(React.Fragment, null,
89
+ !renderResult && isDisabledWithReason && (React.createElement(React.Fragment, null,
34
90
  descriptionEl,
35
91
  highlighted && canShowTooltip && (React.createElement(Tooltip, { className: styles['disabled-reason-tooltip'], trackRef: internalRef, value: disabledReason, position: "right", hideOnOverscroll: true, onDismiss: () => setCanShowTooltip(false) })))))));
36
92
  };
@@ -1 +1 @@
1
- {"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/select/parts/item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAGtD,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,OAAO,MAAM,mCAAmC,CAAC;AACxD,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAE/E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAoBrC,MAAM,IAAI,GAAG,CACX,EACE,MAAM,EACN,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,EACf,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,MAAM,EACN,GAAG,SAAS,EACF,EACZ,GAA8B,EAC9B,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE1C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,K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served.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalIcon from '../../icon/internal.js';\nimport { getBaseProps } from '../../internal/base-component';\nimport CheckboxIcon from '../../internal/components/checkbox-icon';\nimport Option from '../../internal/components/option';\nimport { DropdownOption, OptionDefinition } from '../../internal/components/option/interfaces';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option.js';\nimport SelectableItem from '../../internal/components/selectable-item';\nimport Tooltip from '../../internal/components/tooltip';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\n\nimport styles from './styles.css.js';\n\nexport interface ItemProps {\n option: DropdownOption;\n highlighted?: boolean;\n selected?: boolean;\n filteringValue?: string;\n hasCheckbox?: boolean;\n virtualPosition?: number;\n padBottom?: boolean;\n isNextSelected?: boolean;\n isPreviousSelected?: boolean;\n screenReaderContent?: string;\n ariaPosinset?: number;\n ariaSetsize?: number;\n highlightType?: HighlightType['type'];\n withScrollbar?: boolean;\n sticky?: boolean;\n}\n\nconst Item = (\n {\n option,\n highlighted,\n selected,\n filteringValue,\n hasCheckbox,\n virtualPosition,\n padBottom,\n isNextSelected,\n isPreviousSelected,\n screenReaderContent,\n ariaPosinset,\n ariaSetsize,\n highlightType,\n withScrollbar,\n sticky,\n ...restProps\n }: ItemProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(restProps);\n\n const isParent = option.type === 'parent';\n const isChild = option.type === 'child';\n const wrappedOption: OptionDefinition = option.option;\n const disabled = option.disabled || wrappedOption.disabled;\n const disabledReason = disabled && wrappedOption.disabledReason ? wrappedOption.disabledReason : '';\n const isDisabledWithReason = !!disabledReason;\n const internalRef = useRef<HTMLDivElement>(null);\n\n const { descriptionEl, descriptionId } = useHiddenDescription(disabledReason);\n\n const [canShowTooltip, setCanShowTooltip] = useState(true);\n useEffect(() => setCanShowTooltip(true), [highlighted]);\n\n return (\n <SelectableItem\n ariaSelected={Boolean(selected)}\n selected={selected}\n isNextSelected={isNextSelected}\n isPreviousSelected={isPreviousSelected}\n highlighted={highlighted}\n disabled={option.disabled}\n isParent={isParent}\n isChild={isChild}\n ref={useMergeRefs(ref, internalRef)}\n virtualPosition={virtualPosition}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={ariaPosinset}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType}\n ariaDescribedby={isDisabledWithReason ? descriptionId : ''}\n value={option.option.value}\n withScrollbar={withScrollbar}\n sticky={sticky}\n {...baseProps}\n >\n <div className={clsx(styles.item, !isParent && wrappedOption.labelTag && styles['show-label-tag'])}>\n {hasCheckbox && !isParent && (\n <div className={styles.checkbox}>\n <CheckboxIcon checked={selected || false} disabled={option.disabled} />\n </div>\n )}\n <Option\n option={{ ...wrappedOption, disabled }}\n highlightedOption={highlighted}\n selectedOption={selected}\n highlightText={filteringValue}\n isGroupOption={isParent}\n />\n {!hasCheckbox && !isParent && selected && (\n <div className={styles['selected-icon']}>\n <InternalIcon name=\"check\" />\n </div>\n )}\n {isDisabledWithReason && (\n <>\n {descriptionEl}\n {highlighted && canShowTooltip && (\n <Tooltip\n className={styles['disabled-reason-tooltip']}\n trackRef={internalRef}\n value={disabledReason!}\n position=\"right\"\n hideOnOverscroll={true}\n onDismiss={() => setCanShowTooltip(false)}\n />\n )}\n </>\n )}\n </div>\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(Item));\n"]}
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../src/select/parts/item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,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E,IAAI,EACtB,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GACzC,CACH,CACA,CACJ,CACG,CACS,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport InternalIcon from '../../icon/internal.js';\nimport { getBaseProps } from '../../internal/base-component';\nimport CheckboxIcon from '../../internal/components/checkbox-icon';\nimport Option from '../../internal/components/option';\nimport { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport { HighlightType } from '../../internal/components/options-list/utils/use-highlight-option.js';\nimport SelectableItem from '../../internal/components/selectable-item';\nimport Tooltip from '../../internal/components/tooltip';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport { SelectProps } from '../interfaces';\n\nimport styles from './styles.css.js';\n\nexport interface ItemProps<T = SelectProps.SelectOptionItemRenderer> {\n index: number;\n virtualIndex?: number;\n option: DropdownOption;\n highlighted?: boolean;\n selected?: boolean;\n filteringValue?: string;\n hasCheckbox?: boolean;\n virtualPosition?: number;\n padBottom?: boolean;\n isNextSelected?: boolean;\n isPreviousSelected?: boolean;\n screenReaderContent?: string;\n ariaPosinset?: number;\n ariaSetsize?: number;\n highlightType?: HighlightType['type'];\n withScrollbar?: boolean;\n sticky?: boolean;\n renderOption?: T;\n parentProps?: ItemParentProps;\n}\n\nexport interface ItemParentProps {\n index: number;\n virtualIndex?: number;\n option: DropdownOption;\n disabled: boolean;\n}\nconst toSelectOptionGroupItem = (props: ItemParentProps): SelectProps.SelectOptionGroupItem => {\n return {\n type: 'group',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionGroup,\n disabled: props.disabled,\n };\n};\n\nconst toSelectOptionItem = (props: {\n index: number;\n virtualIndex?: number;\n option: DropdownOption;\n disabled: boolean;\n selected: boolean;\n highlighted: boolean;\n parentProps?: ItemParentProps;\n}): SelectProps.SelectOptionItem => {\n return {\n type: 'item',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionDefinition,\n selected: props.selected,\n highlighted: props.highlighted,\n disabled: props.disabled,\n parent: props.parentProps\n ? toSelectOptionGroupItem({\n index: props.parentProps?.index,\n virtualIndex: props.parentProps?.virtualIndex,\n option: props.parentProps?.option,\n disabled: props.disabled,\n })\n : null,\n };\n};\n\nconst Item = (\n {\n index,\n virtualIndex,\n option,\n highlighted,\n selected,\n filteringValue,\n hasCheckbox,\n virtualPosition,\n padBottom,\n isNextSelected,\n isPreviousSelected,\n screenReaderContent,\n ariaPosinset,\n ariaSetsize,\n highlightType,\n withScrollbar,\n sticky,\n renderOption,\n parentProps,\n ...restProps\n }: ItemProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(restProps);\n\n const isParent = option.type === 'parent';\n const isChild = option.type === 'child';\n const wrappedOption: OptionDefinition = option.option;\n const disabled = option.disabled || wrappedOption.disabled;\n const disabledReason = disabled && wrappedOption.disabledReason ? wrappedOption.disabledReason : '';\n const isDisabledWithReason = !!disabledReason;\n const internalRef = useRef<HTMLDivElement>(null);\n\n const { descriptionEl, descriptionId } = useHiddenDescription(disabledReason);\n\n const [canShowTooltip, setCanShowTooltip] = useState(true);\n useEffect(() => setCanShowTooltip(true), [highlighted]);\n\n const getSelectItemProps = (option: DropdownOption): SelectProps.SelectItem => {\n if (option.type === 'parent') {\n return toSelectOptionGroupItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!disabled,\n });\n } else {\n return toSelectOptionItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!disabled,\n highlighted: !!highlighted,\n selected: !!selected,\n parentProps: parentProps,\n });\n }\n };\n\n const renderOptionWrapper = (option: DropdownOption) => {\n if (!renderOption) {\n return null;\n }\n\n return renderOption({ item: getSelectItemProps(option), filterText: filteringValue });\n };\n const renderResult = renderOptionWrapper(option);\n\n return (\n <SelectableItem\n disableContentStyling={!!renderResult}\n ariaSelected={Boolean(selected)}\n selected={selected}\n isNextSelected={isNextSelected}\n isPreviousSelected={isPreviousSelected}\n highlighted={highlighted}\n disabled={option.disabled}\n isParent={isParent}\n isChild={isChild}\n ref={useMergeRefs(ref, internalRef)}\n virtualPosition={virtualPosition}\n padBottom={padBottom}\n screenReaderContent={screenReaderContent}\n ariaPosinset={ariaPosinset}\n ariaSetsize={ariaSetsize}\n highlightType={highlightType}\n ariaDescribedby={isDisabledWithReason ? descriptionId : ''}\n value={option.option.value}\n withScrollbar={withScrollbar}\n sticky={sticky}\n {...baseProps}\n >\n <div className={clsx(styles.item, !isParent && wrappedOption.labelTag && styles['show-label-tag'])}>\n {!renderResult && hasCheckbox && !isParent && (\n <div className={styles.checkbox}>\n <CheckboxIcon checked={selected || false} disabled={option.disabled} />\n </div>\n )}\n <Option\n customContent={renderResult}\n option={{ ...wrappedOption, disabled }}\n highlightedOption={highlighted}\n selectedOption={selected}\n highlightText={filteringValue}\n isGroupOption={isParent}\n />\n {!renderResult && !hasCheckbox && !isParent && selected && (\n <div className={styles['selected-icon']}>\n <InternalIcon name=\"check\" />\n </div>\n )}\n {!renderResult && isDisabledWithReason && (\n <>\n {descriptionEl}\n {highlighted && canShowTooltip && (\n <Tooltip\n className={styles['disabled-reason-tooltip']}\n trackRef={internalRef}\n value={disabledReason!}\n position=\"right\"\n hideOnOverscroll={true}\n onDismiss={() => setCanShowTooltip(false)}\n />\n )}\n </>\n )}\n </div>\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(Item));\n"]}
@@ -1,7 +1,14 @@
1
1
  import React from 'react';
2
- import { ItemProps } from './item';
3
- interface MultiselectItemProps extends ItemProps {
2
+ import { MultiselectProps } from '../../multiselect/interfaces';
3
+ import { ItemParentProps, ItemProps } from './item';
4
+ interface MultiselectItemProps extends ItemProps<MultiselectProps.MultiselectOptionItemRenderer> {
4
5
  indeterminate?: boolean;
6
+ parentProps?: MultiselectItemParentProps;
7
+ }
8
+ export interface MultiselectItemParentProps extends ItemParentProps {
9
+ indeterminate: boolean;
10
+ highlighted: boolean;
11
+ selected: boolean;
5
12
  }
6
13
  declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<MultiselectItemProps & React.RefAttributes<HTMLDivElement>>>;
7
14
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"multiselect-item.d.ts","sourceRoot":"","sources":["../../../../src/select/parts/multiselect-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAW3D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGnC,UAAU,oBAAqB,SAAQ,SAAS;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;;AA0GD,wBAA6D"}
1
+ {"version":3,"file":"multiselect-item.d.ts","sourceRoot":"","sources":["../../../../src/select/parts/multiselect-item.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAW3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAGpD,UAAU,oBAAqB,SAAQ,SAAS,CAAC,gBAAgB,CAAC,6BAA6B,CAAC;IAC9F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,0BAA0B,CAAC;CAC1C;AAED,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;;AAqMD,wBAA6D"}
@@ -9,7 +9,41 @@ import SelectableItem from '../../internal/components/selectable-item';
9
9
  import Tooltip from '../../internal/components/tooltip';
10
10
  import useHiddenDescription from '../../internal/hooks/use-hidden-description';
11
11
  import styles from './styles.css.js';
12
- const MultiSelectItem = ({ option, highlighted, selected, filteringValue, hasCheckbox, virtualPosition, padBottom, isNextSelected, isPreviousSelected, indeterminate, screenReaderContent, ariaPosinset, ariaSetsize, highlightType, withScrollbar, sticky, ...restProps }, ref) => {
12
+ const toMultiselectOptionGroupItem = (props) => {
13
+ var _a, _b;
14
+ return {
15
+ type: 'group',
16
+ index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
17
+ option: props.option.option,
18
+ indeterminate: (_b = props.indeterminate) !== null && _b !== void 0 ? _b : false,
19
+ selected: props.selected,
20
+ highlighted: props.highlighted,
21
+ disabled: props.disabled,
22
+ };
23
+ };
24
+ const toMultiselectOptionItem = (props) => {
25
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
26
+ return {
27
+ type: 'item',
28
+ index: (_a = props.virtualIndex) !== null && _a !== void 0 ? _a : props.index,
29
+ option: props.option.option,
30
+ selected: props.selected,
31
+ highlighted: props.highlighted,
32
+ disabled: props.disabled,
33
+ parent: props.parentProps
34
+ ? toMultiselectOptionGroupItem({
35
+ index: (_b = props.parentProps) === null || _b === void 0 ? void 0 : _b.index,
36
+ virtualIndex: (_c = props.parentProps) === null || _c === void 0 ? void 0 : _c.virtualIndex,
37
+ option: (_d = props.parentProps) === null || _d === void 0 ? void 0 : _d.option,
38
+ disabled: props.disabled,
39
+ highlighted: (_f = (_e = props.parentProps) === null || _e === void 0 ? void 0 : _e.highlighted) !== null && _f !== void 0 ? _f : false,
40
+ indeterminate: (_h = (_g = props.parentProps) === null || _g === void 0 ? void 0 : _g.indeterminate) !== null && _h !== void 0 ? _h : false,
41
+ selected: (_k = (_j = props.parentProps) === null || _j === void 0 ? void 0 : _j.selected) !== null && _k !== void 0 ? _k : false,
42
+ })
43
+ : null,
44
+ };
45
+ };
46
+ const MultiSelectItem = ({ index, virtualIndex, option, highlighted, selected, filteringValue, hasCheckbox, virtualPosition, padBottom, isNextSelected, isPreviousSelected, indeterminate, screenReaderContent, ariaPosinset, ariaSetsize, highlightType, withScrollbar, sticky, renderOption, parentProps, ...restProps }, ref) => {
13
47
  const baseProps = getBaseProps(restProps);
14
48
  const isParent = option.type === 'parent';
15
49
  const isChild = option.type === 'child';
@@ -25,12 +59,52 @@ const MultiSelectItem = ({ option, highlighted, selected, filteringValue, hasChe
25
59
  const { descriptionId, descriptionEl } = useHiddenDescription(disabledReason);
26
60
  const [canShowTooltip, setCanShowTooltip] = useState(true);
27
61
  useEffect(() => setCanShowTooltip(true), [highlighted]);
28
- return (React.createElement(SelectableItem, { ariaChecked: isParent && indeterminate ? 'mixed' : Boolean(selected), selected: selected, isNextSelected: isNextSelected, isPreviousSelected: isPreviousSelected, highlighted: highlighted, disabled: disabled, isParent: isParent, isChild: isChild, isSelectAll: isSelectAll, highlightType: highlightType, ref: useMergeRefs(ref, internalRef), virtualPosition: virtualPosition, padBottom: padBottom, useInteractiveGroups: true, screenReaderContent: screenReaderContent, ariaPosinset: ariaPosinset, ariaSetsize: ariaSetsize, ariaDescribedby: isDisabledWithReason ? descriptionId : '', value: option.option.value, afterHeader: option.afterHeader, withScrollbar: withScrollbar, sticky: sticky, ...baseProps },
62
+ const getMultiselectItemProps = (option) => {
63
+ if (option.type === 'parent') {
64
+ return toMultiselectOptionGroupItem({
65
+ option: option,
66
+ index: index,
67
+ virtualIndex: virtualIndex,
68
+ disabled: !!disabled,
69
+ highlighted: !!highlighted,
70
+ selected: !!selected,
71
+ indeterminate: indeterminate !== null && indeterminate !== void 0 ? indeterminate : false,
72
+ });
73
+ }
74
+ else if (option.type === 'select-all') {
75
+ return {
76
+ type: 'select-all',
77
+ option: option.option,
78
+ indeterminate: indeterminate !== null && indeterminate !== void 0 ? indeterminate : false,
79
+ selected: !!selected,
80
+ highlighted: !!highlighted,
81
+ };
82
+ }
83
+ else {
84
+ return toMultiselectOptionItem({
85
+ option: option,
86
+ index: index,
87
+ virtualIndex: virtualIndex,
88
+ disabled: !!disabled,
89
+ highlighted: !!highlighted,
90
+ selected: !!selected,
91
+ parentProps: parentProps,
92
+ });
93
+ }
94
+ };
95
+ const renderOptionWrapper = (option) => {
96
+ if (!renderOption) {
97
+ return null;
98
+ }
99
+ return renderOption({ item: getMultiselectItemProps(option), filterText: filteringValue });
100
+ };
101
+ const renderResult = renderOptionWrapper(option);
102
+ return (React.createElement(SelectableItem, { disableContentStyling: !!renderResult, ariaChecked: isParent && indeterminate ? 'mixed' : Boolean(selected), selected: selected, isNextSelected: isNextSelected, isPreviousSelected: isPreviousSelected, highlighted: highlighted, disabled: disabled, isParent: isParent, isChild: isChild, isSelectAll: isSelectAll, highlightType: highlightType, ref: useMergeRefs(ref, internalRef), virtualPosition: virtualPosition, padBottom: padBottom, useInteractiveGroups: true, screenReaderContent: screenReaderContent, ariaPosinset: ariaPosinset, ariaSetsize: ariaSetsize, ariaDescribedby: isDisabledWithReason ? descriptionId : '', value: option.option.value, afterHeader: option.afterHeader, withScrollbar: withScrollbar, sticky: sticky, ...baseProps },
29
103
  React.createElement("div", { className: className },
30
- hasCheckbox && (React.createElement("div", { className: styles.checkbox },
104
+ !renderResult && hasCheckbox && (React.createElement("div", { className: styles.checkbox },
31
105
  React.createElement(CheckboxIcon, { checked: selected, indeterminate: (isParent || isSelectAll) && indeterminate, disabled: disabled }))),
32
- React.createElement(Option, { option: { ...wrappedOption, disabled }, highlightedOption: highlighted, selectedOption: selected, highlightText: filteringValue, isGroupOption: isParent })),
33
- isDisabledWithReason && (React.createElement(React.Fragment, null,
106
+ React.createElement(Option, { customContent: renderResult, option: { ...wrappedOption, disabled }, highlightedOption: highlighted, selectedOption: selected, highlightText: filteringValue, isGroupOption: isParent })),
107
+ !renderResult && isDisabledWithReason && (React.createElement(React.Fragment, null,
34
108
  descriptionEl,
35
109
  highlighted && canShowTooltip && (React.createElement(Tooltip, { className: styles['disabled-reason-tooltip'], trackRef: internalRef, value: disabledReason, position: "right", hideOnOverscroll: true, onDismiss: () => setCanShowTooltip(false) }))))));
36
110
  };
@@ -1 +1 @@
1
- {"version":3,"file":"multiselect-item.js","sourceRoot":"","sources":["../../../../src/select/parts/multiselect-item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAEtD,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,OAAO,MAAM,mCAAmC,CAAC;AACxD,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAG/E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAKrC,MAAM,eAAe,GAAG,CACtB,EACE,MAAM,EACN,WAAW,EACX,QAAQ,EACR,cAAc,EACd,WAAW,EACX,eAAe,EACf,SAAS,EACT,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,MAAM,EACN,GAAG,SAAS,EACS,EACvB,GAA8B,EAC9B,EAAE;IACF,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAE1C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;IAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;IACxC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;IACjD,MAAM,aAAa,GAAqB,MAAM,CAAC,MAAM,CAAC;IACtD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,aAAa,CAAC,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aAAa,CAAC,CAAC,CAAC,EAAE,EAC1D,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,EAC1B,WAAW,EAAE,MAAM,CAAC,WAAW,EAC/B,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,MAAM,KACV,SAAS;QAEb,6BAAK,SAAS,EAAE,SAAS;YACtB,WAAW,IAAI,CACd,6BAAK,SAAS,EAAE,MAAM,CAAC,QAAQ;gBAC7B,oBAAC,YAAY,IACX,OAAO,EAAE,QAAQ,EACjB,aAAa,EAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,IAAI,aAAa,EACzD,QAAQ,EAAE,QAAQ,GAClB,CACE,CACP;YACD,oBAAC,MAAM,IACL,MAAM,EAAE,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE,EACtC,iBAAiB,EAAE,WAAW,EAC9B,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,cAAc,EAC7B,aAAa,EAAE,QAAQ,GACvB,CACE;QACL,oBAAoB,IAAI,CACvB;YACG,aAAa;YACb,WAAW,IAAI,cAAc,IAAI,CAChC,oBAAC,OAAO,IACN,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,EAC5C,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,cAAe,EACtB,QAAQ,EAAC,OAAO,EAChB,gBAAgB,EAAE,IAAI,EACtB,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GACzC,CACH,CACA,CACJ,CACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../../internal/base-component';\nimport CheckboxIcon from '../../internal/components/checkbox-icon';\nimport Option from '../../internal/components/option';\nimport { OptionDefinition } from '../../internal/components/option/interfaces';\nimport SelectableItem from '../../internal/components/selectable-item';\nimport Tooltip from '../../internal/components/tooltip';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport { ItemProps } from './item';\n\nimport styles from './styles.css.js';\ninterface MultiselectItemProps extends ItemProps {\n indeterminate?: boolean;\n}\n\nconst MultiSelectItem = (\n {\n option,\n highlighted,\n selected,\n filteringValue,\n hasCheckbox,\n virtualPosition,\n padBottom,\n isNextSelected,\n isPreviousSelected,\n indeterminate,\n screenReaderContent,\n ariaPosinset,\n ariaSetsize,\n highlightType,\n withScrollbar,\n sticky,\n ...restProps\n }: MultiselectItemProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(restProps);\n\n const isParent = option.type === 'parent';\n const isChild = option.type === 'child';\n const isSelectAll = option.type === 'select-all';\n const wrappedOption: OptionDefinition = option.option;\n const disabled = option.disabled || wrappedOption.disabled;\n const disabledReason =\n disabled && (option.disabledReason || wrappedOption.disabledReason)\n ? option.disabledReason || wrappedOption.disabledReason\n : '';\n const isDisabledWithReason = !!disabledReason;\n const internalRef = useRef<HTMLDivElement>(null);\n const className = styles.item;\n\n const { descriptionId, descriptionEl } = useHiddenDescription(disabledReason);\n\n const [canShowTooltip, setCanShowTooltip] = useState(true);\n useEffect(() => setCanShowTooltip(true), [highlighted]);\n return (\n <SelectableItem\n ariaChecked={isParent && indeterminate ? 'mixed' : Boolean(selected)}\n selected={selected}\n isNextSelected={isNextSelected}\n isPreviousSelected={isPreviousSelected}\n highlighted={highlighted}\n disabled={disabled}\n isParent={isParent}\n isChild={isChild}\n isSelectAll={isSelectAll}\n highlightType={highlightType}\n ref={useMergeRefs(ref, internalRef)}\n virtualPosition={virtualPosition}\n padBottom={padBottom}\n useInteractiveGroups={true}\n screenReaderContent={screenReaderContent}\n ariaPosinset={ariaPosinset}\n ariaSetsize={ariaSetsize}\n ariaDescribedby={isDisabledWithReason ? descriptionId : ''}\n value={option.option.value}\n afterHeader={option.afterHeader}\n withScrollbar={withScrollbar}\n sticky={sticky}\n {...baseProps}\n >\n <div className={className}>\n {hasCheckbox && (\n <div className={styles.checkbox}>\n <CheckboxIcon\n checked={selected}\n indeterminate={(isParent || isSelectAll) && indeterminate}\n disabled={disabled}\n />\n </div>\n )}\n <Option\n option={{ ...wrappedOption, disabled }}\n highlightedOption={highlighted}\n selectedOption={selected}\n highlightText={filteringValue}\n isGroupOption={isParent}\n />\n </div>\n {isDisabledWithReason && (\n <>\n {descriptionEl}\n {highlighted && canShowTooltip && (\n <Tooltip\n className={styles['disabled-reason-tooltip']}\n trackRef={internalRef}\n value={disabledReason!}\n position=\"right\"\n hideOnOverscroll={true}\n onDismiss={() => setCanShowTooltip(false)}\n />\n )}\n </>\n )}\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(MultiSelectItem));\n"]}
1
+ {"version":3,"file":"multiselect-item.js","sourceRoot":"","sources":["../../../../src/select/parts/multiselect-item.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,+CAA+C,CAAC;AAE7E,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,YAAY,MAAM,yCAAyC,CAAC;AACnE,OAAO,MAAM,MAAM,kCAAkC,CAAC;AAEtD,OAAO,cAAc,MAAM,2CAA2C,CAAC;AACvE,OAAO,OAAO,MAAM,mCAAmC,CAAC;AACxD,OAAO,oBAAoB,MAAM,6CAA6C,CAAC;AAI/E,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAWrC,MAAM,4BAA4B,GAAG,CACnC,KAAiC,EACY,EAAE;;IAC/C,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,MA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AY,EAC3B,MAAM,EAAE,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE,EACtC,iBAAiB,EAAE,WAAW,EAC9B,cAAc,EAAE,QAAQ,EACxB,aAAa,EAAE,cAAc,EAC7B,aAAa,EAAE,QAAQ,GACvB,CACE;QACL,CAAC,YAAY,IAAI,oBAAoB,IAAI,CACxC;YACG,aAAa;YACb,WAAW,IAAI,cAAc,IAAI,CAChC,oBAAC,OAAO,IACN,SAAS,EAAE,MAAM,CAAC,yBAAyB,CAAC,EAC5C,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,cAAe,EACtB,QAAQ,EAAC,OAAO,EAChB,gBAAgB,EAAE,IAAI,EACtB,SAAS,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,GACzC,CACH,CACA,CACJ,CACc,CAClB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';\n\nimport { getBaseProps } from '../../internal/base-component';\nimport CheckboxIcon from '../../internal/components/checkbox-icon';\nimport Option from '../../internal/components/option';\nimport { DropdownOption, OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport SelectableItem from '../../internal/components/selectable-item';\nimport Tooltip from '../../internal/components/tooltip';\nimport useHiddenDescription from '../../internal/hooks/use-hidden-description';\nimport { MultiselectProps } from '../../multiselect/interfaces';\nimport { ItemParentProps, ItemProps } from './item';\n\nimport styles from './styles.css.js';\ninterface MultiselectItemProps extends ItemProps<MultiselectProps.MultiselectOptionItemRenderer> {\n indeterminate?: boolean;\n parentProps?: MultiselectItemParentProps;\n}\n\nexport interface MultiselectItemParentProps extends ItemParentProps {\n indeterminate: boolean;\n highlighted: boolean;\n selected: boolean;\n}\nconst toMultiselectOptionGroupItem = (\n props: MultiselectItemParentProps\n): MultiselectProps.MultiselectOptionGroupItem => {\n return {\n type: 'group',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionGroup,\n indeterminate: props.indeterminate ?? false,\n selected: props.selected,\n highlighted: props.highlighted,\n disabled: props.disabled,\n };\n};\nconst toMultiselectOptionItem = (props: {\n index: number;\n virtualIndex?: number;\n option: DropdownOption;\n disabled: boolean;\n selected: boolean;\n highlighted: boolean;\n parentProps?: MultiselectItemParentProps;\n}): MultiselectProps.MultiselectOptionItem => {\n return {\n type: 'item',\n index: props.virtualIndex ?? props.index,\n option: props.option.option as OptionDefinition,\n selected: props.selected,\n highlighted: props.highlighted,\n disabled: props.disabled,\n parent: props.parentProps\n ? toMultiselectOptionGroupItem({\n index: props.parentProps?.index,\n virtualIndex: props.parentProps?.virtualIndex,\n option: props.parentProps?.option,\n disabled: props.disabled,\n highlighted: props.parentProps?.highlighted ?? false,\n indeterminate: props.parentProps?.indeterminate ?? false,\n selected: props.parentProps?.selected ?? false,\n })\n : null,\n };\n};\n\nconst MultiSelectItem = (\n {\n index,\n virtualIndex,\n option,\n highlighted,\n selected,\n filteringValue,\n hasCheckbox,\n virtualPosition,\n padBottom,\n isNextSelected,\n isPreviousSelected,\n indeterminate,\n screenReaderContent,\n ariaPosinset,\n ariaSetsize,\n highlightType,\n withScrollbar,\n sticky,\n renderOption,\n parentProps,\n ...restProps\n }: MultiselectItemProps,\n ref: React.Ref<HTMLDivElement>\n) => {\n const baseProps = getBaseProps(restProps);\n\n const isParent = option.type === 'parent';\n const isChild = option.type === 'child';\n const isSelectAll = option.type === 'select-all';\n const wrappedOption: OptionDefinition = option.option;\n const disabled = option.disabled || wrappedOption.disabled;\n const disabledReason =\n disabled && (option.disabledReason || wrappedOption.disabledReason)\n ? option.disabledReason || wrappedOption.disabledReason\n : '';\n const isDisabledWithReason = !!disabledReason;\n const internalRef = useRef<HTMLDivElement>(null);\n const className = styles.item;\n\n const { descriptionId, descriptionEl } = useHiddenDescription(disabledReason);\n\n const [canShowTooltip, setCanShowTooltip] = useState(true);\n useEffect(() => setCanShowTooltip(true), [highlighted]);\n\n const getMultiselectItemProps = (option: DropdownOption): MultiselectProps.MultiselectItem => {\n if (option.type === 'parent') {\n return toMultiselectOptionGroupItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!disabled,\n highlighted: !!highlighted,\n selected: !!selected,\n indeterminate: indeterminate ?? false,\n });\n } else if (option.type === 'select-all') {\n return {\n type: 'select-all',\n option: option.option as OptionDefinition,\n indeterminate: indeterminate ?? false,\n selected: !!selected,\n highlighted: !!highlighted,\n };\n } else {\n return toMultiselectOptionItem({\n option: option,\n index: index,\n virtualIndex: virtualIndex,\n disabled: !!disabled,\n highlighted: !!highlighted,\n selected: !!selected,\n parentProps: parentProps,\n });\n }\n };\n\n const renderOptionWrapper = (option: DropdownOption) => {\n if (!renderOption) {\n return null;\n }\n\n return renderOption({ item: getMultiselectItemProps(option), filterText: filteringValue });\n };\n\n const renderResult = renderOptionWrapper(option);\n\n return (\n <SelectableItem\n disableContentStyling={!!renderResult}\n ariaChecked={isParent && indeterminate ? 'mixed' : Boolean(selected)}\n selected={selected}\n isNextSelected={isNextSelected}\n isPreviousSelected={isPreviousSelected}\n highlighted={highlighted}\n disabled={disabled}\n isParent={isParent}\n isChild={isChild}\n isSelectAll={isSelectAll}\n highlightType={highlightType}\n ref={useMergeRefs(ref, internalRef)}\n virtualPosition={virtualPosition}\n padBottom={padBottom}\n useInteractiveGroups={true}\n screenReaderContent={screenReaderContent}\n ariaPosinset={ariaPosinset}\n ariaSetsize={ariaSetsize}\n ariaDescribedby={isDisabledWithReason ? descriptionId : ''}\n value={option.option.value}\n afterHeader={option.afterHeader}\n withScrollbar={withScrollbar}\n sticky={sticky}\n {...baseProps}\n >\n <div className={className}>\n {!renderResult && hasCheckbox && (\n <div className={styles.checkbox}>\n <CheckboxIcon\n checked={selected}\n indeterminate={(isParent || isSelectAll) && indeterminate}\n disabled={disabled}\n />\n </div>\n )}\n <Option\n customContent={renderResult}\n option={{ ...wrappedOption, disabled }}\n highlightedOption={highlighted}\n selectedOption={selected}\n highlightText={filteringValue}\n isGroupOption={isParent}\n />\n </div>\n {!renderResult && isDisabledWithReason && (\n <>\n {descriptionEl}\n {highlighted && canShowTooltip && (\n <Tooltip\n className={styles['disabled-reason-tooltip']}\n trackRef={internalRef}\n value={disabledReason!}\n position=\"right\"\n hideOnOverscroll={true}\n onDismiss={() => setCanShowTooltip(false)}\n />\n )}\n </>\n )}\n </SelectableItem>\n );\n};\n\nexport default React.memo(React.forwardRef(MultiSelectItem));\n"]}