@cloudscape-design/components 3.0.908 → 3.0.910

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.
@@ -1 +1 @@
1
- {"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIvF,UAAU,2BACR,SAAQ,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CAAC;IACnG,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AASD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,UAAU,EACV,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,eAAe,GAChB,EAAE,2BAA2B,eAiC7B"}
1
+ {"version":3,"file":"options-list.d.ts","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAIvF,UAAU,2BACR,SAAQ,IAAI,CAAC,gBAAgB,EAAE,eAAe,GAAG,mBAAmB,GAAG,2BAA2B,CAAC;IACnG,UAAU,EAAE,gBAAgB,CAAC,UAAU,CAAC;IACxC,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AASD,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,UAAU,EACV,qBAAqB,EACrB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,SAAS,EACT,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,eAAe,GAChB,EAAE,2BAA2B,eAkC7B"}
@@ -16,6 +16,7 @@ export default function AutosuggestOptionsList({ statusType, autosuggestItemsSta
16
16
  const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);
17
17
  const ListComponent = virtualScroll ? VirtualList : PlainList;
18
18
  const announcement = useAnnouncement({
19
+ highlightText,
19
20
  announceSelected: ((_a = autosuggestItemsState.highlightedOption) === null || _a === void 0 ? void 0 : _a.value) === highlightText,
20
21
  highlightedOption: autosuggestItemsState.highlightedOption,
21
22
  getParent: option => autosuggestItemsState.getItemGroup(option),
@@ -1 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AEH,OAAO,CACL,oBAAC,aAAa,IACZ,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa,EAC5B,oBAAoB,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,EAC5E,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE;YACT,EAAE,EAAE,MAAM;YACV,cAAc,EAAE,SAAS;YACzB,SAAS,EAAE,aAAa;YACxB,WAAW,EAAE,eAAe;YAC5B,eAAe;YACf,UAAU;SACX,EACD,mBAAmB,EAAE,YAAY,GACjC,CACH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\n\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { AutosuggestProps } from './interfaces';\nimport { AutosuggestItemsHandlers, AutosuggestItemsState } from './options-controller';\nimport PlainList from './plain-list';\nimport VirtualList from './virtual-list';\n\ninterface AutosuggestOptionsListProps\n extends Pick<AutosuggestProps, 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {\n statusType: AutosuggestProps.StatusType;\n autosuggestItemsState: AutosuggestItemsState;\n autosuggestItemsHandlers: AutosuggestItemsHandlers;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n ariaDescribedby?: string;\n}\n\nconst createMouseEventHandler = (handler: (index: number) => void) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n};\n\nexport default function AutosuggestOptionsList({\n statusType,\n autosuggestItemsState,\n autosuggestItemsHandlers,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n ariaDescribedby,\n}: AutosuggestOptionsListProps) {\n const handleMouseUp = createMouseEventHandler(autosuggestItemsHandlers.selectVisibleOptionWithMouse);\n const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n announceSelected: autosuggestItemsState.highlightedOption?.value === highlightText,\n highlightedOption: autosuggestItemsState.highlightedOption,\n getParent: option => autosuggestItemsState.getItemGroup(option),\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <ListComponent\n listBottom={listBottom}\n handleLoadMore={handleLoadMore}\n autosuggestItemsState={autosuggestItemsState}\n highlightText={highlightText}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{\n id: listId,\n ariaLabelledby: controlId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaDescribedby,\n statusType,\n }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"options-list.js","sourceRoot":"","sources":["../../../src/autosuggest/options-list.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAGnE,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,WAAW,MAAM,gBAAgB,CAAC;AAiBzC,MAAM,uBAAuB,GAAG,CAAC,OAAgC,EAAE,EAAE,CAAC,CAAC,SAAiB,EAAE,EAAE;IAC1F,4DAA4D;IAC5D,IAAI,SAAS,GAAG,CAAC,CAAC,EAAE;QAClB,OAAO,CAAC,SAAS,CAAC,CAAC;KACpB;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,UAA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identifier: Apache-2.0\nimport React from 'react';\n\nimport { useAnnouncement } from '../select/utils/use-announcement';\nimport { AutosuggestProps } from './interfaces';\nimport { AutosuggestItemsHandlers, AutosuggestItemsState } from './options-controller';\nimport PlainList from './plain-list';\nimport VirtualList from './virtual-list';\n\ninterface AutosuggestOptionsListProps\n extends Pick<AutosuggestProps, 'virtualScroll' | 'selectedAriaLabel' | 'renderHighlightedAriaLive'> {\n statusType: AutosuggestProps.StatusType;\n autosuggestItemsState: AutosuggestItemsState;\n autosuggestItemsHandlers: AutosuggestItemsHandlers;\n highlightedOptionId?: string;\n highlightText: string;\n listId: string;\n controlId: string;\n handleLoadMore: () => void;\n hasDropdownStatus?: boolean;\n listBottom?: React.ReactNode;\n ariaDescribedby?: string;\n}\n\nconst createMouseEventHandler = (handler: (index: number) => void) => (itemIndex: number) => {\n // prevent mouse events to avoid losing focus from the input\n if (itemIndex > -1) {\n handler(itemIndex);\n }\n};\n\nexport default function AutosuggestOptionsList({\n statusType,\n autosuggestItemsState,\n autosuggestItemsHandlers,\n highlightedOptionId,\n highlightText,\n listId,\n controlId,\n handleLoadMore,\n hasDropdownStatus,\n virtualScroll,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n listBottom,\n ariaDescribedby,\n}: AutosuggestOptionsListProps) {\n const handleMouseUp = createMouseEventHandler(autosuggestItemsHandlers.selectVisibleOptionWithMouse);\n const handleMouseMove = createMouseEventHandler(autosuggestItemsHandlers.highlightVisibleOptionWithMouse);\n\n const ListComponent = virtualScroll ? VirtualList : PlainList;\n\n const announcement = useAnnouncement({\n highlightText,\n announceSelected: autosuggestItemsState.highlightedOption?.value === highlightText,\n highlightedOption: autosuggestItemsState.highlightedOption,\n getParent: option => autosuggestItemsState.getItemGroup(option),\n selectedAriaLabel,\n renderHighlightedAriaLive,\n });\n\n return (\n <ListComponent\n listBottom={listBottom}\n handleLoadMore={handleLoadMore}\n autosuggestItemsState={autosuggestItemsState}\n highlightText={highlightText}\n highlightedA11yProps={highlightedOptionId ? { id: highlightedOptionId } : {}}\n hasDropdownStatus={hasDropdownStatus}\n menuProps={{\n id: listId,\n ariaLabelledby: controlId,\n onMouseUp: handleMouseUp,\n onMouseMove: handleMouseMove,\n ariaDescribedby,\n statusType,\n }}\n screenReaderContent={announcement}\n />\n );\n}\n"]}
@@ -121,7 +121,7 @@ export interface ButtonProps extends BaseComponentProps, BaseButtonProps {
121
121
  **/
122
122
  download?: boolean | string;
123
123
  /** The id of the <form> element to associate with the button. The value of this attribute must be the id of a <form> in the same document.
124
- * Use when a button is not the ancestor of a form element, such as when used in a modal.
124
+ * Use when a button is not the descendant of a form element, such as when used in a modal.
125
125
  */
126
126
  form?: string;
127
127
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button/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 { IconProps } from '../icon/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler, ClickDetail as _ClickDetail } from '../internal/events';\n\nexport interface BaseButtonProps {\n /**\n * Renders the button as disabled and prevents clicks.\n */\n disabled?: boolean;\n /**\n * Provides a reason why the button is disabled (only when `disabled` is `true`).\n * If provided, the button becomes focusable.\n * Applicable for all button variants, except link and icon.\n */\n disabledReason?: string;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents users from clicking the button, but it can still be focused.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button is in a loading state.\n */\n loadingText?: string;\n /**\n * Displays an icon next to the text. You can use the `iconAlign` property to position the icon.\n */\n iconName?: IconProps.Name;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n */\n iconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n iconSvg?: React.ReactNode;\n\n /**\n * Adds `aria-label` to the button element. Use this to provide an accessible name for buttons\n * that don't have visible text, and to distinguish between multiple buttons with identical visible text.\n * The text will also be added to the `title` attribute of the button.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-describedby` to the button.\n */\n ariaDescribedby?: string;\n\n /**\n * Specifies if the `text` content wraps. If you set it to `false`, it prevents the text from wrapping.\n */\n wrapText?: boolean;\n\n /**\n * Text displayed in the button element.\n * @displayname text\n */\n children?: React.ReactNode;\n\n /**\n * Adds `aria-controls` to the button. Use when the button controls the contents or presence of an element.\n */\n ariaControls?: string;\n\n /**\n * Adds an external icon after the button label text.\n * If an href is provided, it opens the link in a new tab.\n */\n external?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component. The object should contain:\n *\n * * `externalIconAriaLabel` - (optional) Specifies the aria-label for the external icon when `external` is set to `true`.\n * @i18n\n */\n i18nStrings?: ButtonProps.I18nStrings;\n}\n\nexport interface ButtonProps extends BaseComponentProps, BaseButtonProps {\n /**\n * Specifies the alignment of the icon.\n */\n iconAlign?: ButtonProps.IconAlign;\n\n /**\n * The form action that is performed by a button click.\n */\n formAction?: ButtonProps.FormAction;\n\n /**\n * Applies button styling to a link. Use this property if you need a link styled as a button (`variant=link`).\n * For example, if you have a 'help' button that links to a documentation page.\n */\n href?: string;\n\n /**\n * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).\n * This property only applies when an `href` is provided.\n */\n target?: string;\n\n /**\n * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`.\n * If the `rel` property is provided, it overrides the default behavior.\n */\n rel?: string;\n\n /**\n * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.\n * You can specify a string value that will be suggested as the name of the downloaded file.\n * This property only applies when an `href` is provided.\n **/\n download?: boolean | string;\n\n /** The id of the <form> element to associate with the button. The value of this attribute must be the id of a <form> in the same document.\n * Use when a button is not the ancestor of a form element, such as when used in a modal.\n */\n form?: string;\n\n /**\n * Adds aria-expanded to the button element. Use when the button controls an expandable element.\n */\n ariaExpanded?: boolean;\n\n /**\n * Called when the user clicks on the button and the button is not disabled or in loading state.\n */\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n\n /**\n * Called when the user clicks on the button with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the button has an `href` set.\n */\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n\n /**\n * Sets the button width to be 100% of the parent container width. Button content is centered.\n */\n fullWidth?: boolean;\n\n /** Determines the general styling of the button as follows:\n * * `primary` for primary buttons.\n * * `normal` for secondary buttons.\n * * `link` for tertiary buttons.\n * * `icon` to display an icon only (no text).\n * * `inline-icon` to display an icon-only (no text) button within a text context.\n * * `inline-link` to display a tertiary button with no outer padding.\n */\n variant?: ButtonProps.Variant;\n\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n iconAlt?: string;\n}\n\nexport namespace ButtonProps {\n export type Variant = 'normal' | 'primary' | 'link' | 'icon' | 'inline-icon' | 'inline-link';\n export type ClickDetail = _ClickDetail;\n export type FollowDetail = BaseNavigationDetail;\n\n export type FormAction = 'submit' | 'none';\n\n export type IconAlign = 'left' | 'right';\n\n export interface I18nStrings {\n /**\n * Specifies the aria-label for the external icon when `external` is set to `true`.\n */\n externalIconAriaLabel?: string;\n }\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(options?: FocusOptions): void;\n }\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/button/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 { IconProps } from '../icon/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\nimport { BaseNavigationDetail, CancelableEventHandler, ClickDetail as _ClickDetail } from '../internal/events';\n\nexport interface BaseButtonProps {\n /**\n * Renders the button as disabled and prevents clicks.\n */\n disabled?: boolean;\n /**\n * Provides a reason why the button is disabled (only when `disabled` is `true`).\n * If provided, the button becomes focusable.\n * Applicable for all button variants, except link and icon.\n */\n disabledReason?: string;\n /**\n * Renders the button as being in a loading state. It takes precedence over the `disabled` if both are set to `true`.\n * It prevents users from clicking the button, but it can still be focused.\n */\n loading?: boolean;\n /**\n * Specifies the text that screen reader announces when the button is in a loading state.\n */\n loadingText?: string;\n /**\n * Displays an icon next to the text. You can use the `iconAlign` property to position the icon.\n */\n iconName?: IconProps.Name;\n /**\n * Specifies the URL of a custom icon. Use this property if the icon you want isn't available.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n */\n iconUrl?: string;\n /**\n * Specifies the SVG of a custom icon.\n *\n * Use this property if you want your custom icon to inherit colors dictated by variant or hover states.\n * When this property is set, the component will be decorated with `aria-hidden=\"true\"`. Ensure that the `svg` element:\n * - has attribute `focusable=\"false\"`.\n * - has `viewBox=\"0 0 16 16\"`.\n *\n * If you set the `svg` element as the root node of the slot, the component will automatically\n * - set `stroke=\"currentColor\"`, `fill=\"none\"`, and `vertical-align=\"top\"`.\n * - set the stroke width based on the size of the icon.\n * - set the width and height of the SVG element based on the size of the icon.\n *\n * If you don't want these styles to be automatically set, wrap the `svg` element into a `span`.\n * You can still set the stroke to `currentColor` to inherit the color of the surrounding elements.\n *\n * If you set both `iconUrl` and `iconSvg`, `iconSvg` will take precedence.\n *\n * *Note:* Remember to remove any additional elements (for example: `defs`) and related CSS classes from SVG files exported from design software.\n * In most cases, they aren't needed, as the `svg` element inherits styles from the icon component.\n */\n iconSvg?: React.ReactNode;\n\n /**\n * Adds `aria-label` to the button element. Use this to provide an accessible name for buttons\n * that don't have visible text, and to distinguish between multiple buttons with identical visible text.\n * The text will also be added to the `title` attribute of the button.\n */\n ariaLabel?: string;\n\n /**\n * Adds `aria-describedby` to the button.\n */\n ariaDescribedby?: string;\n\n /**\n * Specifies if the `text` content wraps. If you set it to `false`, it prevents the text from wrapping.\n */\n wrapText?: boolean;\n\n /**\n * Text displayed in the button element.\n * @displayname text\n */\n children?: React.ReactNode;\n\n /**\n * Adds `aria-controls` to the button. Use when the button controls the contents or presence of an element.\n */\n ariaControls?: string;\n\n /**\n * Adds an external icon after the button label text.\n * If an href is provided, it opens the link in a new tab.\n */\n external?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component. The object should contain:\n *\n * * `externalIconAriaLabel` - (optional) Specifies the aria-label for the external icon when `external` is set to `true`.\n * @i18n\n */\n i18nStrings?: ButtonProps.I18nStrings;\n}\n\nexport interface ButtonProps extends BaseComponentProps, BaseButtonProps {\n /**\n * Specifies the alignment of the icon.\n */\n iconAlign?: ButtonProps.IconAlign;\n\n /**\n * The form action that is performed by a button click.\n */\n formAction?: ButtonProps.FormAction;\n\n /**\n * Applies button styling to a link. Use this property if you need a link styled as a button (`variant=link`).\n * For example, if you have a 'help' button that links to a documentation page.\n */\n href?: string;\n\n /**\n * Specifies where to open the linked URL (for example, to open in a new browser window or tab use `_blank`).\n * This property only applies when an `href` is provided.\n */\n target?: string;\n\n /**\n * Adds a `rel` attribute to the link. By default, the component sets the `rel` attribute to \"noopener noreferrer\" when `target` is `\"_blank\"`.\n * If the `rel` property is provided, it overrides the default behavior.\n */\n rel?: string;\n\n /**\n * Specifies whether the linked URL, when selected, will prompt the user to download instead of navigate.\n * You can specify a string value that will be suggested as the name of the downloaded file.\n * This property only applies when an `href` is provided.\n **/\n download?: boolean | string;\n\n /** The id of the <form> element to associate with the button. The value of this attribute must be the id of a <form> in the same document.\n * Use when a button is not the descendant of a form element, such as when used in a modal.\n */\n form?: string;\n\n /**\n * Adds aria-expanded to the button element. Use when the button controls an expandable element.\n */\n ariaExpanded?: boolean;\n\n /**\n * Called when the user clicks on the button and the button is not disabled or in loading state.\n */\n onClick?: CancelableEventHandler<ButtonProps.ClickDetail>;\n\n /**\n * Called when the user clicks on the button with the left mouse button without pressing\n * modifier keys (that is, CTRL, ALT, SHIFT, META), and the button has an `href` set.\n */\n onFollow?: CancelableEventHandler<ButtonProps.FollowDetail>;\n\n /**\n * Sets the button width to be 100% of the parent container width. Button content is centered.\n */\n fullWidth?: boolean;\n\n /** Determines the general styling of the button as follows:\n * * `primary` for primary buttons.\n * * `normal` for secondary buttons.\n * * `link` for tertiary buttons.\n * * `icon` to display an icon only (no text).\n * * `inline-icon` to display an icon-only (no text) button within a text context.\n * * `inline-link` to display a tertiary button with no outer padding.\n */\n variant?: ButtonProps.Variant;\n\n /**\n * Specifies alternate text for a custom icon. We recommend that you provide this for accessibility.\n * This property is ignored if you use a predefined icon or if you set your custom icon using the `iconSvg` slot.\n */\n iconAlt?: string;\n}\n\nexport namespace ButtonProps {\n export type Variant = 'normal' | 'primary' | 'link' | 'icon' | 'inline-icon' | 'inline-link';\n export type ClickDetail = _ClickDetail;\n export type FollowDetail = BaseNavigationDetail;\n\n export type FormAction = 'submit' | 'none';\n\n export type IconAlign = 'left' | 'right';\n\n export interface I18nStrings {\n /**\n * Specifies the aria-label for the external icon when `external` is set to `true`.\n */\n externalIconAriaLabel?: string;\n }\n\n export interface Ref {\n /**\n * Focuses the underlying native button.\n */\n focus(options?: FocusOptions): void;\n }\n}\n"]}
@@ -1,4 +1,9 @@
1
1
  import { OptionDefinition, OptionGroup } from './interfaces';
2
- declare function defaultOptionDescription(option: OptionDefinition, parentGroup: OptionGroup | undefined): string;
2
+ interface DefaultOptionDescriptionProps {
3
+ option: OptionDefinition;
4
+ parentGroup?: OptionGroup;
5
+ highlightText?: string;
6
+ }
7
+ declare function defaultOptionDescription({ option, parentGroup, highlightText }: DefaultOptionDescriptionProps): string;
3
8
  export default defaultOptionDescription;
4
9
  //# sourceMappingURL=option-announcer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"option-announcer.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/option/option-announcer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE7D,iBAAS,wBAAwB,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,WAAW,GAAG,SAAS,UAW/F;AAED,eAAe,wBAAwB,CAAC"}
1
+ {"version":3,"file":"option-announcer.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/option/option-announcer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG7D,UAAU,6BAA6B;IACrC,MAAM,EAAE,gBAAgB,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD,iBAAS,wBAAwB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,6BAA6B,UAYtG;AAED,eAAe,wBAAwB,CAAC"}
@@ -1,4 +1,11 @@
1
- function defaultOptionDescription(option, parentGroup) {
1
+ import { matchesString } from './utils/filter-options';
2
+ function getMatchingFilteringTags(filteringTags, highlightText) {
3
+ if (!highlightText || !filteringTags) {
4
+ return [];
5
+ }
6
+ return filteringTags.filter(filteringTag => matchesString(filteringTag, highlightText, false));
7
+ }
8
+ function defaultOptionDescription({ option, parentGroup, highlightText }) {
2
9
  return [
3
10
  parentGroup && parentGroup.label,
4
11
  option.__labelPrefix,
@@ -7,6 +14,7 @@ function defaultOptionDescription(option, parentGroup) {
7
14
  option.labelTag,
8
15
  ]
9
16
  .concat(option.tags)
17
+ .concat(getMatchingFilteringTags(option.filteringTags, highlightText))
10
18
  .filter(el => !!el)
11
19
  .join(' ');
12
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"option-announcer.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/option-announcer.ts"],"names":[],"mappings":"AAIA,SAAS,wBAAwB,CAAC,MAAwB,EAAE,WAAoC;IAC9F,OAAO;QACL,WAAW,IAAI,WAAW,CAAC,KAAK;QAChC,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK;QAC5B,MAAM,CAAC,WAAW;QAClB,MAAM,CAAC,QAAQ;KAChB;SACE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;SACnB,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,eAAe,wBAAwB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { OptionDefinition, OptionGroup } from './interfaces';\n\nfunction defaultOptionDescription(option: OptionDefinition, parentGroup: OptionGroup | undefined) {\n return [\n parentGroup && parentGroup.label,\n option.__labelPrefix,\n option.label || option.value,\n option.description,\n option.labelTag,\n ]\n .concat(option.tags)\n .filter(el => !!el)\n .join(' ');\n}\n\nexport default defaultOptionDescription;\n"]}
1
+ {"version":3,"file":"option-announcer.js","sourceRoot":"","sources":["../../../../../src/internal/components/option/option-announcer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAQvD,SAAS,wBAAwB,CAAC,aAAiC,EAAE,aAAsB;IACzF,IAAI,CAAC,aAAa,IAAI,CAAC,aAAa,EAAE;QACpC,OAAO,EAAE,CAAC;KACX;IAED,OAAO,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,aAAa,CAAC,YAAY,EAAE,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;AACjG,CAAC;AAED,SAAS,wBAAwB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,EAAiC;IACrG,OAAO;QACL,WAAW,IAAI,WAAW,CAAC,KAAK;QAChC,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK;QAC5B,MAAM,CAAC,WAAW;QAClB,MAAM,CAAC,QAAQ;KAChB;SACE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;SACnB,MAAM,CAAC,wBAAwB,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;SACrE,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAED,eAAe,wBAAwB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { OptionDefinition, OptionGroup } from './interfaces';\nimport { matchesString } from './utils/filter-options';\n\ninterface DefaultOptionDescriptionProps {\n option: OptionDefinition;\n parentGroup?: OptionGroup;\n highlightText?: string;\n}\n\nfunction getMatchingFilteringTags(filteringTags?: readonly string[], highlightText?: string): string[] {\n if (!highlightText || !filteringTags) {\n return [];\n }\n\n return filteringTags.filter(filteringTag => matchesString(filteringTag, highlightText, false));\n}\n\nfunction defaultOptionDescription({ option, parentGroup, highlightText }: DefaultOptionDescriptionProps) {\n return [\n parentGroup && parentGroup.label,\n option.__labelPrefix,\n option.label || option.value,\n option.description,\n option.labelTag,\n ]\n .concat(option.tags)\n .concat(getMatchingFilteringTags(option.filteringTags, highlightText))\n .filter(el => !!el)\n .join(' ');\n}\n\nexport default defaultOptionDescription;\n"]}
@@ -1,4 +1,4 @@
1
1
  export var PACKAGE_SOURCE = "components";
2
- export var PACKAGE_VERSION = "3.0.0 (06e47df8)";
2
+ export var PACKAGE_VERSION = "3.0.0 (3dc3aef2)";
3
3
  export var THEME = "open-source-visual-refresh";
4
4
  export var ALWAYS_VISUAL_REFRESH = true;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "PACKAGE_SOURCE": "components",
3
- "PACKAGE_VERSION": "3.0.0 (06e47df8)",
3
+ "PACKAGE_VERSION": "3.0.0 (3dc3aef2)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "06e47df82b5844795ade3b9916906e6445f45b2c"
2
+ "commit": "3dc3aef2b9d01bab46b2f10fd20e5735f4d144ea"
3
3
  }
package/package.json CHANGED
@@ -132,7 +132,7 @@
132
132
  "./internal/base-component/index.js",
133
133
  "./internal/base-component/styles.css.js"
134
134
  ],
135
- "version": "3.0.908",
135
+ "version": "3.0.910",
136
136
  "repository": {
137
137
  "type": "git",
138
138
  "url": "https://github.com/cloudscape-design/components.git"
@@ -9,7 +9,8 @@ interface OptionHolder {
9
9
  *
10
10
  * If the testing reveals no issues with the native announcements the live-region can be removed.
11
11
  */
12
- export declare function useAnnouncement<Option extends OptionHolder>({ announceSelected, highlightedOption, getParent, selectedAriaLabel, renderHighlightedAriaLive, }: {
12
+ export declare function useAnnouncement<Option extends OptionHolder>({ highlightText, announceSelected, highlightedOption, getParent, selectedAriaLabel, renderHighlightedAriaLive, }: {
13
+ highlightText?: string;
13
14
  announceSelected: boolean;
14
15
  highlightedOption?: Option;
15
16
  getParent: (option: Option) => undefined | OptionGroup;
@@ -1 +1 @@
1
- {"version":3,"file":"use-announcement.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/use-announcement.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,YAAY,EAAE,EAC3D,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GAC1B,EAAE;IACD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,GAAG,WAAW,CAAC;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yBAAyB,CAAC,EAAE,WAAW,CAAC,8BAA8B,CAAC;CACxE,UA+BA"}
1
+ {"version":3,"file":"use-announcement.d.ts","sourceRoot":"","sources":["../../../../src/select/utils/use-announcement.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAE5F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,UAAU,YAAY;IACpB,MAAM,CAAC,EAAE,gBAAgB,GAAG,WAAW,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,SAAS,YAAY,EAAE,EAC3D,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GAC1B,EAAE;IACD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,GAAG,WAAW,CAAC;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,yBAAyB,CAAC,EAAE,WAAW,CAAC,8BAA8B,CAAC;CACxE,UA+BA"}
@@ -8,7 +8,7 @@ import defaultOptionDescription from '../../internal/components/option/option-an
8
8
  *
9
9
  * If the testing reveals no issues with the native announcements the live-region can be removed.
10
10
  */
11
- export function useAnnouncement({ announceSelected, highlightedOption, getParent, selectedAriaLabel, renderHighlightedAriaLive, }) {
11
+ export function useAnnouncement({ highlightText, announceSelected, highlightedOption, getParent, selectedAriaLabel, renderHighlightedAriaLive, }) {
12
12
  const prevAnnouncedGroup = useRef(undefined);
13
13
  // Record previously announced group with a delay to account for possible re-renders of the hook.
14
14
  useEffect(() => {
@@ -32,7 +32,7 @@ export function useAnnouncement({ announceSelected, highlightedOption, getParent
32
32
  }
33
33
  // Use default renderer with selected ARIA label if defined and relevant.
34
34
  const selectedAnnouncement = announceSelected && selectedAriaLabel ? selectedAriaLabel : '';
35
- const defaultDescription = defaultOptionDescription(option, group);
35
+ const defaultDescription = defaultOptionDescription({ option, parentGroup: group, highlightText });
36
36
  return [selectedAnnouncement, defaultDescription].filter(Boolean).join(' ');
37
37
  }
38
38
  //# sourceMappingURL=use-announcement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-announcement.js","sourceRoot":"","sources":["../../../../src/select/utils/use-announcement.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,wBAAwB,MAAM,mDAAmD,CAAC;AAOzF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAA8B,EAC3D,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,GAO1B;IACC,MAAM,kBAAkB,GAAG,MAAM,CAA0B,SAAS,CAAC,CAAC;IAEtE,iGAAiG;IACjG,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,iBAAiB,EAAE;YACrB,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,EAAE;gBACzC,kBAAkB,CAAC,OAAO,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;YACH,OAAO,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;SAC5C;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,iBAAiB,EAAE;QACtB,OAAO,EAAE,CAAC;KACX;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAA0B,CAAC;IAC5D,MAAM,MAAM,GAAG,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAC5C,0EAA0E;IAC1E,MAAM,KAAK,GAAG,MAAM,IAAI,MAAM,KAAK,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAEnF,mCAAmC;IACnC,IAAI,yBAAyB,EAAE;QAC7B,OAAO,yBAAyB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;KACjD;IAED,yEAAyE;IACzE,MAAM,oBAAoB,GAAG,gBAAgB,IAAI,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5F,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACnE,OAAO,CAAC,oBAAoB,EAAE,kBAAkB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useRef } from 'react';\n\nimport { OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport defaultOptionDescription from '../../internal/components/option/option-announcer';\nimport { SelectProps } from '../interfaces';\n\ninterface OptionHolder {\n option?: OptionDefinition | OptionGroup;\n}\n\n/**\n * The hook produces the live region string to be announced when an option is highlighted.\n * This is a workaround to account for the issues with assistive technologies.\n *\n * If the testing reveals no issues with the native announcements the live-region can be removed.\n */\nexport function useAnnouncement<Option extends OptionHolder>({\n announceSelected,\n highlightedOption,\n getParent,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n}: {\n announceSelected: boolean;\n highlightedOption?: Option;\n getParent: (option: Option) => undefined | OptionGroup;\n selectedAriaLabel?: string;\n renderHighlightedAriaLive?: SelectProps.ContainingOptionAndGroupString;\n}) {\n const prevAnnouncedGroup = useRef<OptionGroup | undefined>(undefined);\n\n // Record previously announced group with a delay to account for possible re-renders of the hook.\n useEffect(() => {\n if (highlightedOption) {\n const frameId = requestAnimationFrame(() => {\n prevAnnouncedGroup.current = getParent(highlightedOption);\n });\n return () => cancelAnimationFrame(frameId);\n }\n });\n\n if (!highlightedOption) {\n return '';\n }\n\n const option = highlightedOption.option as OptionDefinition;\n const parent = getParent(highlightedOption);\n // Only announce parent group if it wasn't announced with previous option.\n const group = parent && parent !== prevAnnouncedGroup.current ? parent : undefined;\n\n // Use custom renderer if provided.\n if (renderHighlightedAriaLive) {\n return renderHighlightedAriaLive(option, group);\n }\n\n // Use default renderer with selected ARIA label if defined and relevant.\n const selectedAnnouncement = announceSelected && selectedAriaLabel ? selectedAriaLabel : '';\n const defaultDescription = defaultOptionDescription(option, group);\n return [selectedAnnouncement, defaultDescription].filter(Boolean).join(' ');\n}\n"]}
1
+ {"version":3,"file":"use-announcement.js","sourceRoot":"","sources":["../../../../src/select/utils/use-announcement.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,wBAAwB,MAAM,mDAAmD,CAAC;AAOzF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAA8B,EAC3D,aAAa,EACb,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affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useEffect, useRef } from 'react';\n\nimport { OptionDefinition, OptionGroup } from '../../internal/components/option/interfaces';\nimport defaultOptionDescription from '../../internal/components/option/option-announcer';\nimport { SelectProps } from '../interfaces';\n\ninterface OptionHolder {\n option?: OptionDefinition | OptionGroup;\n}\n\n/**\n * The hook produces the live region string to be announced when an option is highlighted.\n * This is a workaround to account for the issues with assistive technologies.\n *\n * If the testing reveals no issues with the native announcements the live-region can be removed.\n */\nexport function useAnnouncement<Option extends OptionHolder>({\n highlightText,\n announceSelected,\n highlightedOption,\n getParent,\n selectedAriaLabel,\n renderHighlightedAriaLive,\n}: {\n highlightText?: string;\n announceSelected: boolean;\n highlightedOption?: Option;\n getParent: (option: Option) => undefined | OptionGroup;\n selectedAriaLabel?: string;\n renderHighlightedAriaLive?: SelectProps.ContainingOptionAndGroupString;\n}) {\n const prevAnnouncedGroup = useRef<OptionGroup | undefined>(undefined);\n\n // Record previously announced group with a delay to account for possible re-renders of the hook.\n useEffect(() => {\n if (highlightedOption) {\n const frameId = requestAnimationFrame(() => {\n prevAnnouncedGroup.current = getParent(highlightedOption);\n });\n return () => cancelAnimationFrame(frameId);\n }\n });\n\n if (!highlightedOption) {\n return '';\n }\n\n const option = highlightedOption.option as OptionDefinition;\n const parent = getParent(highlightedOption);\n // Only announce parent group if it wasn't announced with previous option.\n const group = parent && parent !== prevAnnouncedGroup.current ? parent : undefined;\n\n // Use custom renderer if provided.\n if (renderHighlightedAriaLive) {\n return renderHighlightedAriaLive(option, group);\n }\n\n // Use default renderer with selected ARIA label if defined and relevant.\n const selectedAnnouncement = announceSelected && selectedAriaLabel ? selectedAriaLabel : '';\n const defaultDescription = defaultOptionDescription({ option, parentGroup: group, highlightText });\n return [selectedAnnouncement, defaultDescription].filter(Boolean).join(' ');\n}\n"]}