@cloudscape-design/components 3.0.907 → 3.0.909

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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAqBtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAwC7C,eAAO,MAAM,cAAc,mEACf,WAAW,GAAG,IAAI,UAAU,MAAM,UAM7C,CAAC;AAEF,UAAU,UAAW,SAAQ,aAAa,CAAC,iBAAiB;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,eAAO,MAAM,KAAK,mFAyJjB,CAAC"}
1
+ {"version":3,"file":"flash.d.ts","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAiB,MAAM,OAAO,CAAC;AAqBtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAwC7C,eAAO,MAAM,cAAc,mEACf,WAAW,GAAG,IAAI,UAAU,MAAM,UAM7C,CAAC;AAEF,UAAU,UAAW,SAAQ,aAAa,CAAC,iBAAiB;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC;AAED,eAAO,MAAM,KAAK,mFA2JjB,CAAC"}
package/flashbar/flash.js CHANGED
@@ -80,7 +80,7 @@ export const Flash = React.forwardRef((_a, ref) => {
80
80
  [styles.exit]: transitionState === 'exit',
81
81
  [styles.exiting]: transitionState === 'exiting',
82
82
  [styles.exited]: transitionState === 'exited',
83
- }, getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar'), initialHidden && styles['initial-hidden']) }, analyticsAttributes),
83
+ }, getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar'), initialHidden && styles['initial-hidden']) }, (analyticsMetadata.suppressFlowMetricEvents ? undefined : analyticsAttributes)),
84
84
  React.createElement("div", { className: styles['flash-body'] },
85
85
  React.createElement("div", { className: styles['flash-focus-container'], tabIndex: -1 },
86
86
  React.createElement("div", { className: clsx(styles['flash-icon'], styles['flash-text']) }, icon),
@@ -1 +1 @@
1
- {"version":3,"file":"flash.js","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO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,CAAC,EAAE,qBAAqB,KAAK,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,EACpG,GAAG,EAAE,oBAAoB,GACpB;oBACP,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,eAAe,CAAC,EACvB,sBAAsB,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAC3F,EACD,GAAG,EAAE,UAAU,IAEd,OAAO,CACJ;oBACN,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,sBAAsB,KAAK,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,EACtG,GAAG,EAAE,qBAAqB,GACrB,CACH,CACF;YACN,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAC1C,eAAe,EAAE;oBACf,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;oBACjC,YAAY,EAAE,MAAM,CAAC,eAAe,CAAC;iBACtC,EACD,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACE;QACL,WAAW,IAAI,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC;QACrD,QAAQ,KAAK,QAAQ,IAAI,CACxB,oBAAC,kBAAkB,IAAC,OAAO,EAAE,CAAC,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,CAAC,GAAI,CAC1F,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useComponentMetadata, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { ActionsWrapper } from '../alert/actions-wrapper';\nimport { InternalButton } from '../button/internal';\nimport InternalIcon from '../icon/internal';\nimport { DATA_ATTR_ANALYTICS_FLASHBAR } from '../internal/analytics/selectors';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\nimport { PACKAGE_VERSION } from '../internal/environment';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { isDevelopment } from '../internal/is-development';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';\nimport { throttle } from '../internal/utils/throttle';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalSpinner from '../spinner/internal';\nimport { GeneratedAnalyticsMetadataFlashbarDismiss } from './analytics-metadata/interfaces';\nimport { FlashbarProps } from './interfaces';\nimport { FOCUS_THROTTLE_DELAY } from './utils';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nconst ICON_TYPES = {\n success: 'status-positive',\n warning: 'status-warning',\n info: 'status-info',\n error: 'status-negative',\n 'in-progress': 'status-in-progress',\n} as const;\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.flashbar.onActionRegistered);\nconst useDiscoveredContent = createUseDiscoveredContent('flash', awsuiPluginsInternal.flashContent);\n\nfunction dismissButton(\n dismissLabel: FlashbarProps.MessageDefinition['dismissLabel'],\n onDismiss: FlashbarProps.MessageDefinition['onDismiss']\n) {\n return (\n <div\n className={styles['dismiss-button-wrapper']}\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataFlashbarDismiss>)}\n >\n <InternalButton\n onClick={onDismiss}\n className={styles['dismiss-button']}\n variant=\"flashbar-icon\"\n iconName=\"close\"\n formAction=\"none\"\n ariaLabel={dismissLabel}\n />\n </div>\n );\n}\n\nexport const focusFlashById = throttle(\n (element: HTMLElement | null, itemId: string) => {\n const selector = `[data-itemid=\"${CSS.escape(itemId)}\"] .${styles['flash-focus-container']}`;\n element?.querySelector<HTMLElement>(selector)?.focus();\n },\n FOCUS_THROTTLE_DELAY,\n { trailing: false }\n);\n\ninterface FlashProps extends FlashbarProps.MessageDefinition {\n className: string;\n transitionState?: string;\n i18nStrings?: FlashbarProps.I18nStrings;\n}\n\nexport const Flash = React.forwardRef(\n (\n {\n id,\n header,\n content,\n dismissible,\n dismissLabel,\n loading,\n action,\n buttonText,\n onButtonClick,\n onDismiss,\n className,\n transitionState,\n ariaRole,\n i18nStrings,\n type = 'info',\n ...props\n }: FlashProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n if (isDevelopment) {\n if (buttonText && !onButtonClick) {\n warnOnce(\n 'Flashbar',\n `You provided a \\`buttonText\\` prop without an \\`onButtonClick\\` handler. This will render a non-interactive action button.`\n );\n }\n\n if (dismissible && !onDismiss) {\n warnOnce(\n 'Flashbar',\n `You have set the \\`dismissible\\` prop without an \\`onDismiss\\` handler. This will render a non-interactive dismiss button.`\n );\n }\n }\n\n const analyticsMetadata = getAnalyticsMetadataProps(props as BasePropsWithAnalyticsMetadata);\n const elementRef = useComponentMetadata('Flash', PACKAGE_VERSION, { ...analyticsMetadata });\n const mergedRef = useMergeRefs(ref, elementRef);\n\n const headerRefObject = useRef<HTMLDivElement>(null);\n const contentRefObject = useRef<HTMLDivElement>(null);\n const { discoveredActions, headerRef: headerRefAction, contentRef: contentRefAction } = useDiscoveredAction(type);\n const {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRefContent,\n contentRef: contentRefContent,\n replacementHeaderRef,\n replacementContentRef,\n } = useDiscoveredContent({ type, header, children: content });\n\n const headerRef = useMergeRefs(headerRefAction, headerRefContent, headerRefObject);\n const contentRef = useMergeRefs(contentRefAction, contentRefContent, contentRefObject);\n\n const statusIconAriaLabel =\n props.statusIconAriaLabel ||\n i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`];\n\n const iconType = ICON_TYPES[type];\n const icon = loading ? (\n <span role=\"img\" aria-label={statusIconAriaLabel}>\n <InternalSpinner />\n </span>\n ) : (\n <InternalIcon name={iconType} ariaLabel={statusIconAriaLabel} />\n );\n\n const effectiveType = loading ? 'info' : type;\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,\n };\n\n return (\n // We're not using \"polite\" or \"assertive\" here, just turning default behavior off.\n // eslint-disable-next-line @cloudscape-design/prefer-live-region\n <div\n ref={mergedRef}\n role={ariaRole}\n aria-live={ariaRole ? 'off' : undefined}\n data-itemid={id}\n className={clsx(\n styles.flash,\n styles[`flash-type-${effectiveType}`],\n className,\n transitionState && {\n [styles.enter]: transitionState === 'enter',\n [styles.entering]: transitionState === 'entering',\n [styles.entered]: transitionState === 'entered',\n [styles.exit]: transitionState === 'exit',\n [styles.exiting]: transitionState === 'exiting',\n [styles.exited]: transitionState === 'exited',\n },\n getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar'),\n initialHidden && styles['initial-hidden']\n )}\n {...analyticsAttributes}\n >\n <div className={styles['flash-body']}>\n <div className={styles['flash-focus-container']} tabIndex={-1}>\n <div className={clsx(styles['flash-icon'], styles['flash-text'])}>{icon}</div>\n <div className={clsx(styles['flash-message'], styles['flash-text'])}>\n <div\n className={clsx(\n styles['flash-header'],\n headerReplacementType !== 'original' ? styles.hidden : analyticsSelectors['flash-header']\n )}\n ref={headerRef}\n >\n {header}\n </div>\n <div\n className={clsx(styles['header-replacement'], headerReplacementType !== 'replaced' && styles.hidden)}\n ref={replacementHeaderRef}\n ></div>\n <div\n className={clsx(\n styles['flash-content'],\n contentReplacementType !== 'original' ? styles.hidden : analyticsSelectors['flash-header']\n )}\n ref={contentRef}\n >\n {content}\n </div>\n <div\n className={clsx(styles['content-replacement'], contentReplacementType !== 'replaced' && styles.hidden)}\n ref={replacementContentRef}\n ></div>\n </div>\n </div>\n <ActionsWrapper\n className={styles['action-button-wrapper']}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={onButtonClick}\n />\n </div>\n {dismissible && dismissButton(dismissLabel, onDismiss)}\n {ariaRole === 'status' && (\n <InternalLiveRegion sources={[statusIconAriaLabel, headerRefObject, contentRefObject]} />\n )}\n </div>\n );\n }\n);\n"]}
1
+ {"version":3,"file":"flash.js","sourceRoot":"","sources":["../../../src/flashbar/flash.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,+CAA+C,CAAC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,kEAAkE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAkC,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvG,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,kBA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C,MAAM,CAAC,EACpG,GAAG,EAAE,oBAAoB,GACpB;oBACP,6BACE,SAAS,EAAE,IAAI,CACb,MAAM,CAAC,eAAe,CAAC,EACvB,sBAAsB,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAC3F,EACD,GAAG,EAAE,UAAU,IAEd,OAAO,CACJ;oBACN,6BACE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,qBAAqB,CAAC,EAAE,sBAAsB,KAAK,UAAU,IAAI,MAAM,CAAC,MAAM,CAAC,EACtG,GAAG,EAAE,qBAAqB,GACrB,CACH,CACF;YACN,oBAAC,cAAc,IACb,SAAS,EAAE,MAAM,CAAC,uBAAuB,CAAC,EAC1C,eAAe,EAAE;oBACf,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC;oBACjC,YAAY,EAAE,MAAM,CAAC,eAAe,CAAC;iBACtC,EACD,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,iBAAiB,EACpC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,aAAa,GAC5B,CACE;QACL,WAAW,IAAI,aAAa,CAAC,YAAY,EAAE,SAAS,CAAC;QACrD,QAAQ,KAAK,QAAQ,IAAI,CACxB,oBAAC,kBAAkB,IAAC,OAAO,EAAE,CAAC,mBAAmB,EAAE,eAAe,EAAE,gBAAgB,CAAC,GAAI,CAC1F,CACG,CACP,CAAC;AACJ,CAAC,CACF,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useRef } from 'react';\nimport clsx from 'clsx';\n\nimport { useComponentMetadata, warnOnce } from '@cloudscape-design/component-toolkit/internal';\nimport { getAnalyticsMetadataAttribute } from '@cloudscape-design/component-toolkit/internal/analytics-metadata';\n\nimport { ActionsWrapper } from '../alert/actions-wrapper';\nimport { InternalButton } from '../button/internal';\nimport InternalIcon from '../icon/internal';\nimport { DATA_ATTR_ANALYTICS_FLASHBAR } from '../internal/analytics/selectors';\nimport { BasePropsWithAnalyticsMetadata, getAnalyticsMetadataProps } from '../internal/base-component';\nimport { getVisualContextClassname } from '../internal/components/visual-context';\nimport { PACKAGE_VERSION } from '../internal/environment';\nimport { useMergeRefs } from '../internal/hooks/use-merge-refs';\nimport { isDevelopment } from '../internal/is-development';\nimport { awsuiPluginsInternal } from '../internal/plugins/api';\nimport { createUseDiscoveredAction, createUseDiscoveredContent } from '../internal/plugins/helpers';\nimport { throttle } from '../internal/utils/throttle';\nimport InternalLiveRegion from '../live-region/internal';\nimport InternalSpinner from '../spinner/internal';\nimport { GeneratedAnalyticsMetadataFlashbarDismiss } from './analytics-metadata/interfaces';\nimport { FlashbarProps } from './interfaces';\nimport { FOCUS_THROTTLE_DELAY } from './utils';\n\nimport analyticsSelectors from './analytics-metadata/styles.css.js';\nimport styles from './styles.css.js';\n\nconst ICON_TYPES = {\n success: 'status-positive',\n warning: 'status-warning',\n info: 'status-info',\n error: 'status-negative',\n 'in-progress': 'status-in-progress',\n} as const;\n\nconst useDiscoveredAction = createUseDiscoveredAction(awsuiPluginsInternal.flashbar.onActionRegistered);\nconst useDiscoveredContent = createUseDiscoveredContent('flash', awsuiPluginsInternal.flashContent);\n\nfunction dismissButton(\n dismissLabel: FlashbarProps.MessageDefinition['dismissLabel'],\n onDismiss: FlashbarProps.MessageDefinition['onDismiss']\n) {\n return (\n <div\n className={styles['dismiss-button-wrapper']}\n {...getAnalyticsMetadataAttribute({\n action: 'dismiss',\n } as Partial<GeneratedAnalyticsMetadataFlashbarDismiss>)}\n >\n <InternalButton\n onClick={onDismiss}\n className={styles['dismiss-button']}\n variant=\"flashbar-icon\"\n iconName=\"close\"\n formAction=\"none\"\n ariaLabel={dismissLabel}\n />\n </div>\n );\n}\n\nexport const focusFlashById = throttle(\n (element: HTMLElement | null, itemId: string) => {\n const selector = `[data-itemid=\"${CSS.escape(itemId)}\"] .${styles['flash-focus-container']}`;\n element?.querySelector<HTMLElement>(selector)?.focus();\n },\n FOCUS_THROTTLE_DELAY,\n { trailing: false }\n);\n\ninterface FlashProps extends FlashbarProps.MessageDefinition {\n className: string;\n transitionState?: string;\n i18nStrings?: FlashbarProps.I18nStrings;\n}\n\nexport const Flash = React.forwardRef(\n (\n {\n id,\n header,\n content,\n dismissible,\n dismissLabel,\n loading,\n action,\n buttonText,\n onButtonClick,\n onDismiss,\n className,\n transitionState,\n ariaRole,\n i18nStrings,\n type = 'info',\n ...props\n }: FlashProps,\n ref: React.Ref<HTMLDivElement>\n ) => {\n if (isDevelopment) {\n if (buttonText && !onButtonClick) {\n warnOnce(\n 'Flashbar',\n `You provided a \\`buttonText\\` prop without an \\`onButtonClick\\` handler. This will render a non-interactive action button.`\n );\n }\n\n if (dismissible && !onDismiss) {\n warnOnce(\n 'Flashbar',\n `You have set the \\`dismissible\\` prop without an \\`onDismiss\\` handler. This will render a non-interactive dismiss button.`\n );\n }\n }\n\n const analyticsMetadata = getAnalyticsMetadataProps(\n props as BasePropsWithAnalyticsMetadata & FlashbarProps.MessageDefinition\n );\n const elementRef = useComponentMetadata('Flash', PACKAGE_VERSION, { ...analyticsMetadata });\n const mergedRef = useMergeRefs(ref, elementRef);\n\n const headerRefObject = useRef<HTMLDivElement>(null);\n const contentRefObject = useRef<HTMLDivElement>(null);\n const { discoveredActions, headerRef: headerRefAction, contentRef: contentRefAction } = useDiscoveredAction(type);\n const {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRefContent,\n contentRef: contentRefContent,\n replacementHeaderRef,\n replacementContentRef,\n } = useDiscoveredContent({ type, header, children: content });\n\n const headerRef = useMergeRefs(headerRefAction, headerRefContent, headerRefObject);\n const contentRef = useMergeRefs(contentRefAction, contentRefContent, contentRefObject);\n\n const statusIconAriaLabel =\n props.statusIconAriaLabel ||\n i18nStrings?.[`${loading || type === 'in-progress' ? 'inProgress' : type}IconAriaLabel`];\n\n const iconType = ICON_TYPES[type];\n const icon = loading ? (\n <span role=\"img\" aria-label={statusIconAriaLabel}>\n <InternalSpinner />\n </span>\n ) : (\n <InternalIcon name={iconType} ariaLabel={statusIconAriaLabel} />\n );\n\n const effectiveType = loading ? 'info' : type;\n\n const analyticsAttributes = {\n [DATA_ATTR_ANALYTICS_FLASHBAR]: effectiveType,\n };\n\n return (\n // We're not using \"polite\" or \"assertive\" here, just turning default behavior off.\n // eslint-disable-next-line @cloudscape-design/prefer-live-region\n <div\n ref={mergedRef}\n role={ariaRole}\n aria-live={ariaRole ? 'off' : undefined}\n data-itemid={id}\n className={clsx(\n styles.flash,\n styles[`flash-type-${effectiveType}`],\n className,\n transitionState && {\n [styles.enter]: transitionState === 'enter',\n [styles.entering]: transitionState === 'entering',\n [styles.entered]: transitionState === 'entered',\n [styles.exit]: transitionState === 'exit',\n [styles.exiting]: transitionState === 'exiting',\n [styles.exited]: transitionState === 'exited',\n },\n getVisualContextClassname(type === 'warning' && !loading ? 'flashbar-warning' : 'flashbar'),\n initialHidden && styles['initial-hidden']\n )}\n {...(analyticsMetadata.suppressFlowMetricEvents ? undefined : analyticsAttributes)}\n >\n <div className={styles['flash-body']}>\n <div className={styles['flash-focus-container']} tabIndex={-1}>\n <div className={clsx(styles['flash-icon'], styles['flash-text'])}>{icon}</div>\n <div className={clsx(styles['flash-message'], styles['flash-text'])}>\n <div\n className={clsx(\n styles['flash-header'],\n headerReplacementType !== 'original' ? styles.hidden : analyticsSelectors['flash-header']\n )}\n ref={headerRef}\n >\n {header}\n </div>\n <div\n className={clsx(styles['header-replacement'], headerReplacementType !== 'replaced' && styles.hidden)}\n ref={replacementHeaderRef}\n ></div>\n <div\n className={clsx(\n styles['flash-content'],\n contentReplacementType !== 'original' ? styles.hidden : analyticsSelectors['flash-header']\n )}\n ref={contentRef}\n >\n {content}\n </div>\n <div\n className={clsx(styles['content-replacement'], contentReplacementType !== 'replaced' && styles.hidden)}\n ref={replacementContentRef}\n ></div>\n </div>\n </div>\n <ActionsWrapper\n className={styles['action-button-wrapper']}\n testUtilClasses={{\n actionSlot: styles['action-slot'],\n actionButton: styles['action-button'],\n }}\n action={action}\n discoveredActions={discoveredActions}\n buttonText={buttonText}\n onButtonClick={onButtonClick}\n />\n </div>\n {dismissible && dismissButton(dismissLabel, onDismiss)}\n {ariaRole === 'status' && (\n <InternalLiveRegion sources={[statusIconAriaLabel, headerRefObject, contentRefObject]} />\n )}\n </div>\n );\n }\n);\n"]}
@@ -16,6 +16,10 @@ export declare namespace FlashbarProps {
16
16
  buttonText?: ButtonProps['children'];
17
17
  onButtonClick?: ButtonProps['onClick'];
18
18
  onDismiss?: ButtonProps['onClick'];
19
+ analyticsMetadata?: FlashbarProps.ItemAnalyticsMetadata;
20
+ }
21
+ interface ItemAnalyticsMetadata {
22
+ suppressFlowMetricEvents?: boolean;
19
23
  }
20
24
  interface I18nStrings {
21
25
  ariaLabel?: string;
@@ -58,6 +62,9 @@ export interface FlashbarProps extends BaseComponentProps {
58
62
  * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:
59
63
  * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.
60
64
  * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.
65
+ * * `analyticsMetadata` (FlashbarProps.ItemAnalyticsMetadata) - (Optional) Specifies additional analytics-related metadata.
66
+ * * `suppressFlowMetricEvents` - Prevent this item from generating events related to flow metrics.
67
+ * @analytics
61
68
  */
62
69
  items: ReadonlyArray<FlashbarProps.MessageDefinition>;
63
70
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/flashbar/interfaces.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,iBAAiB;QAChC,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CAAC;QAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,wBAAwB,CAAC,EAAE,MAAM,CAAC;QAClC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC/B;IAED,KAAY,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;IAC5E,KAAY,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC3C;AAED,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACH,KAAK,EAAE,aAAa,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAEtD;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC;CACzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/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 { ButtonProps } from '../button/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n statusIconAriaLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n ariaRole?: FlashbarProps.AriaRole;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n }\n\n export interface I18nStrings {\n ariaLabel?: string;\n errorIconAriaLabel?: string;\n infoIconAriaLabel?: string;\n inProgressIconAriaLabel?: string;\n notificationBarAriaLabel?: string;\n notificationBarText?: string;\n successIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error' | 'in-progress';\n export type AriaRole = 'alert' | 'status';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `statusIconAriaLabel` (string) - Specifies an `aria-label` for to the status icon for improved accessibility.\n * If not provided, `i18nStrings.{type}IconAriaLabel` will be used as a fallback.\n * * `ariaRole` (string) - For flash messages added after page load, specifies how this message is communicated to assistive\n * technology. Use \"status\" for status updates or informational content. Use \"alert\" for important messages that need the\n * user's attention.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called.\n * If the `action` property is set, this property is ignored. **Deprecated**, replaced by `action`.\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n\n /**\n * Specifies whether flash messages should be stacked.\n */\n stackItems?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component. The object should contain:\n *\n * * `ariaLabel` - Specifies the ARIA label for the list of notifications.\n *\n * If `stackItems` is set to `true`, it should also contain:\n *\n * * `notificationBarAriaLabel` - (optional) Specifies the ARIA label for the notification bar\n * * `notificationBarText` - (optional) Specifies the text shown in the notification bar\n * * `errorIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `error`.\n * * `warningIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `warning`.\n * * `infoIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `info`.\n * * `successIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `success`.\n * * `inProgressIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `in-progress` or with `loading` set to `true`.\n * @i18n\n */\n i18nStrings?: FlashbarProps.I18nStrings;\n}\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/flashbar/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 { ButtonProps } from '../button/interfaces';\nimport { BaseComponentProps } from '../internal/base-component';\n\nexport namespace FlashbarProps {\n export interface MessageDefinition {\n header?: React.ReactNode;\n content?: React.ReactNode;\n dismissible?: boolean;\n dismissLabel?: string;\n statusIconAriaLabel?: string;\n loading?: boolean;\n type?: FlashbarProps.Type;\n ariaRole?: FlashbarProps.AriaRole;\n action?: React.ReactNode;\n id?: string;\n buttonText?: ButtonProps['children'];\n onButtonClick?: ButtonProps['onClick'];\n onDismiss?: ButtonProps['onClick'];\n analyticsMetadata?: FlashbarProps.ItemAnalyticsMetadata;\n }\n\n export interface ItemAnalyticsMetadata {\n suppressFlowMetricEvents?: boolean;\n }\n\n export interface I18nStrings {\n ariaLabel?: string;\n errorIconAriaLabel?: string;\n infoIconAriaLabel?: string;\n inProgressIconAriaLabel?: string;\n notificationBarAriaLabel?: string;\n notificationBarText?: string;\n successIconAriaLabel?: string;\n warningIconAriaLabel?: string;\n }\n\n export type Type = 'success' | 'warning' | 'info' | 'error' | 'in-progress';\n export type AriaRole = 'alert' | 'status';\n}\n\nexport interface FlashbarProps extends BaseComponentProps {\n /**\n * Specifies flash messages that appear in the same order that they are listed.\n * The value is an array of flash message definition objects.\n *\n * A flash message object contains the following properties:\n * * `header` (ReactNode) - Specifies the heading text.\n * * `content` (ReactNode) - Specifies the primary text displayed in the flash element.\n * * `type` (string) - Indicates the type of the message to be displayed. Allowed values are as follows: `success, error, warning, info`. The default is `info`.\n * * `loading` (boolean) - Replaces the status icon with a spinner and forces the type to `info`.\n * * `dismissible` (boolean) - Determines whether the component includes a close button icon. By default, the close button is not included.\n * When a user clicks on this button the `onDismiss` handler is called.\n * * `dismissLabel` (string) - Specifies an `aria-label` for to the dismiss icon button for improved accessibility.\n * * `statusIconAriaLabel` (string) - Specifies an `aria-label` for to the status icon for improved accessibility.\n * If not provided, `i18nStrings.{type}IconAriaLabel` will be used as a fallback.\n * * `ariaRole` (string) - For flash messages added after page load, specifies how this message is communicated to assistive\n * technology. Use \"status\" for status updates or informational content. Use \"alert\" for important messages that need the\n * user's attention.\n * * `action` (ReactNode) - Specifies an action for the flash message. Although it is technically possible to insert any content,\n * our UX guidelines only allow you to add a button.\n * * `buttonText` (string) - Specifies that an action button should be displayed, with the specified text.\n * When a user clicks on this button the `onButtonClick` handler is called.\n * If the `action` property is set, this property is ignored. **Deprecated**, replaced by `action`.\n * * `onButtonClick` (event => void) - Called when a user clicks on the action button. This is not called if you create a custom button\n * using the `action` property. **Deprecated**, replaced by `action`.\n * * `id` (string) - Specifies a unique flash message identifier. This property is used in two ways:\n * 1. As a [keys](https://reactjs.org/docs/lists-and-keys.html#keys) source for React rendering.\n * 2. To identify which flash message will be removed from the DOM when it is dismissed, to animate it out.\n * * `analyticsMetadata` (FlashbarProps.ItemAnalyticsMetadata) - (Optional) Specifies additional analytics-related metadata.\n * * `suppressFlowMetricEvents` - Prevent this item from generating events related to flow metrics.\n * @analytics\n */\n items: ReadonlyArray<FlashbarProps.MessageDefinition>;\n\n /**\n * Specifies whether flash messages should be stacked.\n */\n stackItems?: boolean;\n\n /**\n * An object containing all the necessary localized strings required by the component. The object should contain:\n *\n * * `ariaLabel` - Specifies the ARIA label for the list of notifications.\n *\n * If `stackItems` is set to `true`, it should also contain:\n *\n * * `notificationBarAriaLabel` - (optional) Specifies the ARIA label for the notification bar\n * * `notificationBarText` - (optional) Specifies the text shown in the notification bar\n * * `errorIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `error`.\n * * `warningIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `warning`.\n * * `infoIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `info`.\n * * `successIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `success`.\n * * `inProgressIconAriaLabel` - (optional) Specifies the ARIA label for the icon displayed next to the number of items of type `in-progress` or with `loading` set to `true`.\n * @i18n\n */\n i18nStrings?: FlashbarProps.I18nStrings;\n}\n"]}
@@ -23,10 +23,5 @@ export interface BasePropsWithAnalyticsMetadata {
23
23
  * Helper function to merge beta analytics metadata with the public analytics metadata api.
24
24
  * Beta analytics metadata will override the public values to allow for safe migration.
25
25
  */
26
- export declare function getAnalyticsMetadataProps(props?: BasePropsWithAnalyticsMetadata): {
27
- instanceIdentifier?: string | undefined;
28
- flowType?: import("../analytics/interfaces").FlowType | undefined;
29
- errorContext?: string | undefined;
30
- resourceType?: string | undefined;
31
- };
26
+ export declare function getAnalyticsMetadataProps<T extends BasePropsWithAnalyticsMetadata>(props?: T): NonNullable<T['analyticsMetadata'] & T['__analyticsMetadata']>;
32
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,iBAAiB,CAAC;AAIzB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CAIb;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,sBAQrD;AAED,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,8BAA8B;;;;;EAE/E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,iBAAiB,CAAC;AAIzB,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CAIb;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,kBAAkB,sBAQrD;AAED,MAAM,WAAW,8BAA8B;IAC7C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,mBAAmB,CAAC,EAAE,iBAAiB,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,SAAS,8BAA8B,EAChF,KAAK,CAAC,EAAE,CAAC,GACR,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAEhE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,gEAAgE;AAChE,OAAO,iBAAiB,CAAC;AAEzB,iBAAiB,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAoBnD,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YACjE,SAAS,CAAC,IAAI,CAAC,GAAI,KAA6B,CAAC,IAAI,CAAC,CAAC;SACxD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAA+B,CAAC;AACzC,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAsC;IAC9E,uCAAY,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB,GAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,EAAG;AACxE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initAwsUiVersions } from '@cloudscape-design/component-toolkit/internal';\n\nimport { AnalyticsMetadata } from '../analytics/interfaces';\nimport { PACKAGE_SOURCE, PACKAGE_VERSION } from '../environment';\n\n// these styles needed to be imported for every public component\nimport './styles.css.js';\n\ninitAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);\n\nexport interface BaseComponentProps {\n /**\n * Adds the specified classes to the root element of the component.\n * @deprecated Custom CSS is not supported. For testing and other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).\n */\n className?: string;\n /**\n * Adds the specified ID to the root element of the component.\n * @deprecated The usage of the `id` attribute is reserved for internal use cases. For testing and other use cases,\n * use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). If you must\n * use the `id` attribute, consider setting it on a parent element instead.\n */\n id?: string;\n // we also support data-* attributes, but they are always implicitly allowed by typescript\n // http://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking\n // \"Note: If an attribute name is not a valid JS identifier (like a data-* attribute), it is not considered to be an error\"\n}\n\nexport function getBaseProps(props: BaseComponentProps) {\n const baseProps: Record<string, any> = {};\n Object.keys(props).forEach(prop => {\n if (prop === 'id' || prop === 'className' || prop.match(/^data-/)) {\n baseProps[prop] = (props as Record<string, any>)[prop];\n }\n });\n return baseProps as BaseComponentProps;\n}\n\nexport interface BasePropsWithAnalyticsMetadata {\n analyticsMetadata?: AnalyticsMetadata;\n __analyticsMetadata?: AnalyticsMetadata;\n}\n\n/**\n * Helper function to merge beta analytics metadata with the public analytics metadata api.\n * Beta analytics metadata will override the public values to allow for safe migration.\n */\nexport function getAnalyticsMetadataProps(props?: BasePropsWithAnalyticsMetadata) {\n return { ...props?.analyticsMetadata, ...props?.__analyticsMetadata };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/internal/base-component/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAGlF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjE,gEAAgE;AAChE,OAAO,iBAAiB,CAAC;AAEzB,iBAAiB,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC;AAoBnD,MAAM,UAAU,YAAY,CAAC,KAAyB;IACpD,MAAM,SAAS,GAAwB,EAAE,CAAC;IAC1C,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE;YACjE,SAAS,CAAC,IAAI,CAAC,GAAI,KAA6B,CAAC,IAAI,CAAC,CAAC;SACxD;IACH,CAAC,CAAC,CAAC;IACH,OAAO,SAA+B,CAAC;AACzC,CAAC;AAOD;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAS;IAET,uCAAY,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB,GAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,mBAAmB,EAAG;AACxE,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { initAwsUiVersions } from '@cloudscape-design/component-toolkit/internal';\n\nimport { AnalyticsMetadata } from '../analytics/interfaces';\nimport { PACKAGE_SOURCE, PACKAGE_VERSION } from '../environment';\n\n// these styles needed to be imported for every public component\nimport './styles.css.js';\n\ninitAwsUiVersions(PACKAGE_SOURCE, PACKAGE_VERSION);\n\nexport interface BaseComponentProps {\n /**\n * Adds the specified classes to the root element of the component.\n * @deprecated Custom CSS is not supported. For testing and other use cases, use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes).\n */\n className?: string;\n /**\n * Adds the specified ID to the root element of the component.\n * @deprecated The usage of the `id` attribute is reserved for internal use cases. For testing and other use cases,\n * use [data attributes](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes). If you must\n * use the `id` attribute, consider setting it on a parent element instead.\n */\n id?: string;\n // we also support data-* attributes, but they are always implicitly allowed by typescript\n // http://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking\n // \"Note: If an attribute name is not a valid JS identifier (like a data-* attribute), it is not considered to be an error\"\n}\n\nexport function getBaseProps(props: BaseComponentProps) {\n const baseProps: Record<string, any> = {};\n Object.keys(props).forEach(prop => {\n if (prop === 'id' || prop === 'className' || prop.match(/^data-/)) {\n baseProps[prop] = (props as Record<string, any>)[prop];\n }\n });\n return baseProps as BaseComponentProps;\n}\n\nexport interface BasePropsWithAnalyticsMetadata {\n analyticsMetadata?: AnalyticsMetadata;\n __analyticsMetadata?: AnalyticsMetadata;\n}\n\n/**\n * Helper function to merge beta analytics metadata with the public analytics metadata api.\n * Beta analytics metadata will override the public values to allow for safe migration.\n */\nexport function getAnalyticsMetadataProps<T extends BasePropsWithAnalyticsMetadata>(\n props?: T\n): NonNullable<T['analyticsMetadata'] & T['__analyticsMetadata']> {\n return { ...props?.analyticsMetadata, ...props?.__analyticsMetadata };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAGrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAgB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAuB,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAA8D,yBAAyB,EAAE,MAAM,cAAc,CAAC;AACrH,OAAO,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAK5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI1D,UAAU,qBACR,SAAQ,kBAAkB,EACxB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,+BAA+B,EAC/B,gBAAgB,EAChB,0BAA0B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,eAAe,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAClC,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,eAAe,CAAC,EAAE,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAClD,cAAc,CAAC,EAAE,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;IAC7D,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC;CAC9B;AAED,UAAU,4BAA4B;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB,CAAC,GAAG;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,IAAI,CAAC;IACpD,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;CACf;AAED,QAAA,MAAM,gBAAgB,mGAwPrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgE,MAAM,OAAO,CAAC;AAGrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,kBAAkB,EAAgB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAuB,MAAM,kCAAkC,CAAC;A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@ import { getBaseProps } from '../../base-component';
8
8
  import { useFormFieldContext } from '../../context/form-field-context';
9
9
  import { fireCancelableEvent, fireNonCancelableEvent } from '../../events';
10
10
  import { KeyCode } from '../../keycode';
11
- import { documentHasFocus } from '../../utils/dom';
12
11
  import { nodeBelongs } from '../../utils/node-belongs';
13
12
  import Dropdown from '../dropdown';
14
13
  import styles from './styles.css.js';
@@ -43,11 +42,6 @@ const AutosuggestInput = React.forwardRef((_a, ref) => {
43
42
  close: closeDropdown,
44
43
  }));
45
44
  const handleBlur = () => {
46
- // When the document in not in focus it means the focus moved outside the page. In that case the dropdown shall stay open
47
- // so that when the user comes back it does not re-open unexpectedly when the focus is restored by the browser.
48
- if (!documentHasFocus()) {
49
- return;
50
- }
51
45
  if (!preventCloseOnBlurRef.current) {
52
46
  closeDropdown();
53
47
  fireNonCancelableEvent(onBlur, null);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,aAAqC,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAmC,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAAiB,mBAAmB,EAAE,sBAAsB,EAA6B,MAAM,cAAc,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,MAAM,MAAM,iB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CAAC,eAAe,IAAI,CAAC,CAAC,cAAc,CAAC,EACrD,MAAM,EACJ,iBAAiB,IAAI,CACnB,6BAAK,GAAG,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,IAC9D,cAAc,CACX,CACP,EAEH,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,IAEnB,IAAI,IAAI,eAAe,CAAC,CAAC,CAAC,CACzB,6BAAK,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,CAAC,kBAAkB,CAAC,IAChE,eAAe,CACZ,CACP,CAAC,CAAC,CAAC,IAAI,CACC,CACP,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { AutosuggestProps } from '../../../autosuggest/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoCorrect,\n InputClearLabel,\n InputKeyEvents,\n} from '../../../input/interfaces';\nimport InternalInput, { InternalInputProps } from '../../../input/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { FormFieldValidationControlProps, useFormFieldContext } from '../../context/form-field-context';\nimport { BaseKeyDetail, fireCancelableEvent, fireNonCancelableEvent, NonCancelableEventHandler } from '../../events';\nimport { InternalBaseComponentProps } from '../../hooks/use-base-component';\nimport { KeyCode } from '../../keycode';\nimport { documentHasFocus } from '../../utils/dom';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport Dropdown from '../dropdown';\nimport { ExpandToViewport } from '../dropdown/interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestInputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n ExpandToViewport,\n InternalBaseComponentProps {\n ariaControls?: string;\n ariaActivedescendant?: string;\n dropdownExpanded?: boolean;\n dropdownContentKey?: string;\n dropdownContentFocusable?: boolean;\n dropdownContent?: React.ReactNode;\n dropdownFooter?: React.ReactNode;\n dropdownWidth?: number;\n loopFocus?: boolean;\n onCloseDropdown?: NonCancelableEventHandler<null>;\n onDelayedInput?: NonCancelableEventHandler<BaseChangeDetail>;\n onPressArrowDown?: () => void;\n onPressArrowUp?: () => void;\n onPressEnter?: () => boolean;\n}\n\ninterface AutosuggestInputFocusOptions {\n preventDropdown?: boolean;\n}\n\nexport interface AutosuggestInputRef extends AutosuggestProps.Ref {\n focus(options?: AutosuggestInputFocusOptions): void;\n open(): void;\n close(): void;\n}\n\nconst AutosuggestInput = React.forwardRef(\n (\n {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onKeyDown,\n name,\n placeholder,\n disabled,\n readOnly,\n autoFocus,\n ariaLabel,\n ariaRequired,\n disableBrowserAutocorrect = false,\n expandToViewport,\n ariaControls,\n ariaActivedescendant,\n clearAriaLabel,\n dropdownExpanded = true,\n dropdownContentKey,\n dropdownContentFocusable = false,\n dropdownContent = null,\n dropdownFooter = null,\n dropdownWidth,\n loopFocus,\n onCloseDropdown,\n onDelayedInput,\n onPressArrowDown,\n onPressArrowUp,\n onPressEnter,\n __internalRootRef,\n ...restProps\n }: AutosuggestInputProps,\n ref: Ref<AutosuggestInputRef>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownContentRef = useRef<HTMLDivElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n const preventOpenOnFocusRef = useRef(false);\n const preventCloseOnBlurRef = useRef(false);\n\n const [open, setOpen] = useState(false);\n\n const openDropdown = () => !readOnly && setOpen(true);\n\n const closeDropdown = () => {\n setOpen(false);\n fireNonCancelableEvent(onCloseDropdown, null);\n };\n\n useImperativeHandle(ref, () => ({\n focus(options?: AutosuggestInputFocusOptions) {\n if (options?.preventDropdown) {\n preventOpenOnFocusRef.current = true;\n }\n inputRef.current?.focus();\n },\n select() {\n inputRef.current?.select();\n },\n open: openDropdown,\n close: closeDropdown,\n }));\n\n const handleBlur = () => {\n // When the document in not in focus it means the focus moved outside the page. In that case the dropdown shall stay open\n // so that when the user comes back it does not re-open unexpectedly when the focus is restored by the browser.\n if (!documentHasFocus()) {\n return;\n }\n if (!preventCloseOnBlurRef.current) {\n closeDropdown();\n fireNonCancelableEvent(onBlur, null);\n }\n };\n\n const handleFocus = () => {\n if (!preventOpenOnFocusRef.current) {\n openDropdown();\n fireNonCancelableEvent(onFocus, null);\n }\n preventOpenOnFocusRef.current = false;\n };\n\n const fireKeydown = (event: CustomEvent<BaseKeyDetail>) => fireCancelableEvent(onKeyDown, event.detail, event);\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n switch (event.detail.keyCode) {\n case KeyCode.down: {\n onPressArrowDown?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n onPressArrowUp?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.enter: {\n if (open) {\n if (!onPressEnter?.()) {\n closeDropdown();\n }\n event.preventDefault();\n }\n fireKeydown(event);\n break;\n }\n case KeyCode.escape: {\n if (open) {\n event.stopPropagation();\n closeDropdown();\n } else if (value) {\n event.stopPropagation();\n fireNonCancelableEvent(onChange, { value: '' });\n }\n event.preventDefault();\n fireKeydown(event);\n break;\n }\n default: {\n fireKeydown(event);\n }\n }\n };\n\n const handleChange = (value: string) => {\n openDropdown();\n fireNonCancelableEvent(onChange, { value });\n };\n\n const handleDelayedInput = (value: string) => {\n fireNonCancelableEvent(onDelayedInput, { value });\n };\n\n const handleDropdownMouseDown: React.MouseEventHandler = event => {\n // Prevent currently focused element from losing focus.\n if (!dropdownContentFocusable) {\n event.preventDefault();\n }\n // Prevent closing dropdown on click inside.\n else {\n preventCloseOnBlurRef.current = true;\n requestAnimationFrame(() => {\n preventCloseOnBlurRef.current = false;\n });\n }\n };\n\n const expanded = open && dropdownExpanded;\n const nativeAttributes: InternalInputProps['__nativeAttributes'] = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': open ? ariaControls : undefined,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': open ? ariaControls : undefined,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': ariaActivedescendant,\n };\n\n // Closes dropdown when outside click is detected.\n // Similar to the internal dropdown implementation but includes the target as well.\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const clickListener = (event: MouseEvent) => {\n if (\n !nodeBelongs(inputRef.current, event.target) &&\n !nodeBelongs(dropdownContentRef.current, event.target) &&\n !nodeBelongs(dropdownFooterRef.current, event.target)\n ) {\n closeDropdown();\n }\n };\n\n window.addEventListener('mousedown', clickListener);\n\n return () => {\n window.removeEventListener('mousedown', clickListener);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <Dropdown\n minWidth={dropdownWidth}\n stretchWidth={!dropdownWidth}\n stretchBeyondTriggerWidth={true}\n contentKey={dropdownContentKey}\n onFocus={handleFocus}\n onBlur={handleBlur}\n trigger={\n <InternalInput\n type=\"visualSearch\"\n value={value}\n onChange={event => handleChange(event.detail.value)}\n __onDelayedInput={event => handleDelayedInput(event.detail.value)}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n />\n }\n onMouseDown={handleDropdownMouseDown}\n open={open && (!!dropdownContent || !!dropdownFooter)}\n footer={\n dropdownFooterRef && (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n {dropdownFooter}\n </div>\n )\n }\n expandToViewport={expandToViewport}\n loopFocus={loopFocus}\n >\n {open && dropdownContent ? (\n <div ref={dropdownContentRef} className={styles['dropdown-content']}>\n {dropdownContent}\n </div>\n ) : null}\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default AutosuggestInput;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/autosuggest-input/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;;AAEtC,OAAO,KAAK,EAAE,EAAO,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrF,OAAO,IAAI,MAAM,MAAM,CAAC;AAUxB,OAAO,aAAqC,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAsB,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAmC,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACxG,OAAO,EAAiB,mBAAmB,EAAE,sBAAsB,EAA6B,MAAM,cAAc,CAAC;AAErH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,QAAQ,MAAM,aAAa,CAAC;AAGnC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAqCrC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CACvC,CACE,EAiCwB,EACxB,GAA6B,EAC7B,EAAE;QAnCF,EACE,KAAK,EACL,QAAQ,EACR,MAAM,EACN,OAAO,EACP,OAAO,EACP,SAAS,EACT,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,yBAAyB,GAAG,KAAK,EACjC,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,EACpB,cAAc,E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,CAAC,CACF,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { Ref, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport clsx from 'clsx';\n\nimport { AutosuggestProps } from '../../../autosuggest/interfaces';\nimport {\n BaseChangeDetail,\n BaseInputProps,\n InputAutoCorrect,\n InputClearLabel,\n InputKeyEvents,\n} from '../../../input/interfaces';\nimport InternalInput, { InternalInputProps } from '../../../input/internal';\nimport { BaseComponentProps, getBaseProps } from '../../base-component';\nimport { FormFieldValidationControlProps, useFormFieldContext } from '../../context/form-field-context';\nimport { BaseKeyDetail, fireCancelableEvent, fireNonCancelableEvent, NonCancelableEventHandler } from '../../events';\nimport { InternalBaseComponentProps } from '../../hooks/use-base-component';\nimport { KeyCode } from '../../keycode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport Dropdown from '../dropdown';\nimport { ExpandToViewport } from '../dropdown/interfaces';\n\nimport styles from './styles.css.js';\n\ninterface AutosuggestInputProps\n extends BaseComponentProps,\n BaseInputProps,\n InputAutoCorrect,\n InputKeyEvents,\n InputClearLabel,\n FormFieldValidationControlProps,\n ExpandToViewport,\n InternalBaseComponentProps {\n ariaControls?: string;\n ariaActivedescendant?: string;\n dropdownExpanded?: boolean;\n dropdownContentKey?: string;\n dropdownContentFocusable?: boolean;\n dropdownContent?: React.ReactNode;\n dropdownFooter?: React.ReactNode;\n dropdownWidth?: number;\n loopFocus?: boolean;\n onCloseDropdown?: NonCancelableEventHandler<null>;\n onDelayedInput?: NonCancelableEventHandler<BaseChangeDetail>;\n onPressArrowDown?: () => void;\n onPressArrowUp?: () => void;\n onPressEnter?: () => boolean;\n}\n\ninterface AutosuggestInputFocusOptions {\n preventDropdown?: boolean;\n}\n\nexport interface AutosuggestInputRef extends AutosuggestProps.Ref {\n focus(options?: AutosuggestInputFocusOptions): void;\n open(): void;\n close(): void;\n}\n\nconst AutosuggestInput = React.forwardRef(\n (\n {\n value,\n onChange,\n onBlur,\n onFocus,\n onKeyUp,\n onKeyDown,\n name,\n placeholder,\n disabled,\n readOnly,\n autoFocus,\n ariaLabel,\n ariaRequired,\n disableBrowserAutocorrect = false,\n expandToViewport,\n ariaControls,\n ariaActivedescendant,\n clearAriaLabel,\n dropdownExpanded = true,\n dropdownContentKey,\n dropdownContentFocusable = false,\n dropdownContent = null,\n dropdownFooter = null,\n dropdownWidth,\n loopFocus,\n onCloseDropdown,\n onDelayedInput,\n onPressArrowDown,\n onPressArrowUp,\n onPressEnter,\n __internalRootRef,\n ...restProps\n }: AutosuggestInputProps,\n ref: Ref<AutosuggestInputRef>\n ) => {\n const baseProps = getBaseProps(restProps);\n const formFieldContext = useFormFieldContext(restProps);\n\n const inputRef = useRef<HTMLInputElement>(null);\n const dropdownContentRef = useRef<HTMLDivElement>(null);\n const dropdownFooterRef = useRef<HTMLDivElement>(null);\n const preventOpenOnFocusRef = useRef(false);\n const preventCloseOnBlurRef = useRef(false);\n\n const [open, setOpen] = useState(false);\n\n const openDropdown = () => !readOnly && setOpen(true);\n\n const closeDropdown = () => {\n setOpen(false);\n fireNonCancelableEvent(onCloseDropdown, null);\n };\n\n useImperativeHandle(ref, () => ({\n focus(options?: AutosuggestInputFocusOptions) {\n if (options?.preventDropdown) {\n preventOpenOnFocusRef.current = true;\n }\n inputRef.current?.focus();\n },\n select() {\n inputRef.current?.select();\n },\n open: openDropdown,\n close: closeDropdown,\n }));\n\n const handleBlur = () => {\n if (!preventCloseOnBlurRef.current) {\n closeDropdown();\n fireNonCancelableEvent(onBlur, null);\n }\n };\n\n const handleFocus = () => {\n if (!preventOpenOnFocusRef.current) {\n openDropdown();\n fireNonCancelableEvent(onFocus, null);\n }\n preventOpenOnFocusRef.current = false;\n };\n\n const fireKeydown = (event: CustomEvent<BaseKeyDetail>) => fireCancelableEvent(onKeyDown, event.detail, event);\n\n const handleKeyDown = (event: CustomEvent<BaseKeyDetail>) => {\n switch (event.detail.keyCode) {\n case KeyCode.down: {\n onPressArrowDown?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.up: {\n onPressArrowUp?.();\n openDropdown();\n event.preventDefault();\n break;\n }\n case KeyCode.enter: {\n if (open) {\n if (!onPressEnter?.()) {\n closeDropdown();\n }\n event.preventDefault();\n }\n fireKeydown(event);\n break;\n }\n case KeyCode.escape: {\n if (open) {\n event.stopPropagation();\n closeDropdown();\n } else if (value) {\n event.stopPropagation();\n fireNonCancelableEvent(onChange, { value: '' });\n }\n event.preventDefault();\n fireKeydown(event);\n break;\n }\n default: {\n fireKeydown(event);\n }\n }\n };\n\n const handleChange = (value: string) => {\n openDropdown();\n fireNonCancelableEvent(onChange, { value });\n };\n\n const handleDelayedInput = (value: string) => {\n fireNonCancelableEvent(onDelayedInput, { value });\n };\n\n const handleDropdownMouseDown: React.MouseEventHandler = event => {\n // Prevent currently focused element from losing focus.\n if (!dropdownContentFocusable) {\n event.preventDefault();\n }\n // Prevent closing dropdown on click inside.\n else {\n preventCloseOnBlurRef.current = true;\n requestAnimationFrame(() => {\n preventCloseOnBlurRef.current = false;\n });\n }\n };\n\n const expanded = open && dropdownExpanded;\n const nativeAttributes: InternalInputProps['__nativeAttributes'] = {\n name,\n placeholder,\n autoFocus,\n onClick: openDropdown,\n role: 'combobox',\n 'aria-autocomplete': 'list',\n 'aria-expanded': expanded,\n 'aria-controls': open ? ariaControls : undefined,\n // 'aria-owns' needed for safari+vo to announce activedescendant content\n 'aria-owns': open ? ariaControls : undefined,\n 'aria-label': ariaLabel,\n 'aria-activedescendant': ariaActivedescendant,\n };\n\n // Closes dropdown when outside click is detected.\n // Similar to the internal dropdown implementation but includes the target as well.\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const clickListener = (event: MouseEvent) => {\n if (\n !nodeBelongs(inputRef.current, event.target) &&\n !nodeBelongs(dropdownContentRef.current, event.target) &&\n !nodeBelongs(dropdownFooterRef.current, event.target)\n ) {\n closeDropdown();\n }\n };\n\n window.addEventListener('mousedown', clickListener);\n\n return () => {\n window.removeEventListener('mousedown', clickListener);\n };\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open]);\n\n return (\n <div {...baseProps} className={clsx(baseProps.className, styles.root)} ref={__internalRootRef}>\n <Dropdown\n minWidth={dropdownWidth}\n stretchWidth={!dropdownWidth}\n stretchBeyondTriggerWidth={true}\n contentKey={dropdownContentKey}\n onFocus={handleFocus}\n onBlur={handleBlur}\n trigger={\n <InternalInput\n type=\"visualSearch\"\n value={value}\n onChange={event => handleChange(event.detail.value)}\n __onDelayedInput={event => handleDelayedInput(event.detail.value)}\n onKeyDown={handleKeyDown}\n onKeyUp={onKeyUp}\n disabled={disabled}\n disableBrowserAutocorrect={disableBrowserAutocorrect}\n readOnly={readOnly}\n ariaRequired={ariaRequired}\n clearAriaLabel={clearAriaLabel}\n ref={inputRef}\n autoComplete={false}\n __nativeAttributes={nativeAttributes}\n {...formFieldContext}\n />\n }\n onMouseDown={handleDropdownMouseDown}\n open={open && (!!dropdownContent || !!dropdownFooter)}\n footer={\n dropdownFooterRef && (\n <div ref={dropdownFooterRef} className={styles['dropdown-footer']}>\n {dropdownFooter}\n </div>\n )\n }\n expandToViewport={expandToViewport}\n loopFocus={loopFocus}\n >\n {open && dropdownContent ? (\n <div ref={dropdownContentRef} className={styles['dropdown-content']}>\n {dropdownContent}\n </div>\n ) : null}\n </Dropdown>\n </div>\n );\n }\n);\n\nexport default AutosuggestInput;\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 (e3098456)";
2
+ export var PACKAGE_VERSION = "3.0.0 (ca702403)";
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 (e3098456)",
3
+ "PACKAGE_VERSION": "3.0.0 (ca702403)",
4
4
  "THEME": "default",
5
5
  "ALWAYS_VISUAL_REFRESH": false
6
6
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "commit": "e30984564d0899802df1265b4831228d46cea7bc"
2
+ "commit": "ca7024038c115c28b1d1b464c8d9e0a2b9a1a838"
3
3
  }
@@ -18,5 +18,4 @@ export declare function parseCssVariable(value: string): string;
18
18
  export declare function isNode(target: unknown): target is Node;
19
19
  export declare function isHTMLElement(target: unknown): target is HTMLElement;
20
20
  export declare function isSVGElement(target: unknown): target is SVGElement;
21
- export declare function documentHasFocus(): boolean;
22
21
  //# sourceMappingURL=dom.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/dom.ts"],"names":[],"mappings":"AAOA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAQ/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAMhF;AAOD,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,KAAK,GACN,EAAE;IACD,YAAY,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC;CACrD,+BAmBA;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,UAqB7C;AAKD,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,IAAI,CAYtD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,WAAW,CAUpE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,UAAU,CAQlE;AAED,wBAAgB,gBAAgB,YAM/B"}
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../../src/internal/utils/dom.ts"],"names":[],"mappings":"AAOA,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAQ/D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,WAAW,GAAG,WAAW,GAAG,IAAI,CAMhF;AAOD,wBAAgB,mBAAmB,CAAC,EAClC,YAAY,EACZ,KAAK,GACN,EAAE;IACD,YAAY,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC;CACrD,+BAmBA;AAID;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,UAqB7C;AAKD,wBAAgB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,IAAI,CAYtD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,WAAW,CAUpE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,UAAU,CAQlE"}
@@ -99,12 +99,4 @@ export function isSVGElement(target) {
99
99
  'ownerSVGElement' in target &&
100
100
  typeof target.ownerSVGElement === 'object'));
101
101
  }
102
- export function documentHasFocus() {
103
- var _a;
104
- // In JSDOM the hasFocus() always returns false which differs from the in-browser experience, see: https://github.com/jsdom/jsdom/issues/3794.
105
- // Thus, when detecting JSDOM environment we return true here explicitly for the tests to work expectedly.
106
- // The detection depends on the default userAgent set in JSDOM, see: https://github.com/jsdom/jsdom?tab=readme-ov-file#advanced-configuration.
107
- const isJSDOM = typeof navigator !== 'undefined' && ((_a = navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes('jsdom'));
108
- return isJSDOM || (typeof document !== undefined && document.hasFocus());
109
- }
110
102
  //# sourceMappingURL=dom.js.map
@@ -1 +1 @@
1
- {"version":3,"file":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AQ,CAAC,OAAO,CAAC,CAAA,CAAC;IAC3F,OAAO,OAAO,IAAI,CAAC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport balanced from 'balanced-match';\n\nimport { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\n\nexport function isContainingBlock(element: HTMLElement): boolean {\n const computedStyle = getComputedStyle(element);\n return (\n (!!computedStyle.transform && computedStyle.transform !== 'none') ||\n (!!computedStyle.perspective && computedStyle.perspective !== 'none') ||\n (!!computedStyle.containerType && computedStyle.containerType !== 'normal') ||\n computedStyle.contain?.split(' ').some(s => ['layout', 'paint', 'strict', 'content'].includes(s))\n );\n}\n\n/**\n * Returns an element that is used to position the given element.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block\n */\nexport function getContainingBlock(startElement: HTMLElement): HTMLElement | null {\n if (!startElement.parentElement) {\n return null;\n }\n\n return findUpUntil(startElement.parentElement, isContainingBlock) as HTMLElement;\n}\n\n/*\n * Allows to find multiple elements in the page each according to a specific test function,\n * but traversing the DOM only once.\n */\n\nexport function findUpUntilMultiple({\n startElement,\n tests,\n}: {\n startElement: HTMLElement;\n tests: Record<string, (el: HTMLElement) => boolean>;\n}) {\n const keys = Object.keys(tests);\n const elements: Record<string, HTMLElement> = {};\n let current: HTMLElement | null = startElement;\n while (current && Object.keys(elements).length < keys.length) {\n current = current.parentElement;\n // If a component is used within an svg (i.e. as foreignObject), then it will\n // have some ancestor nodes that are SVGElement. We want to skip those,\n // as they have very different properties to HTMLElements.\n while (current && !isHTMLElement(current)) {\n current = (current as Element).parentElement;\n }\n for (const key of keys) {\n if (!elements[key] && current && tests[key](current)) {\n elements[key] = current;\n }\n }\n }\n return elements;\n}\n\nconst cssVariableExpression = /--.+?\\s*,\\s*(.+)/;\n\n/**\n * Parses a CSS color value that might contain CSS Custom Properties\n * and returns a value that will be understood by the browser, no matter of support level.\n * If the browser support CSS Custom Properties, the value will be return as is. Otherwise,\n * the fallback value will be extracted and returned instead.\n */\nexport function parseCssVariable(value: string) {\n if (typeof window === 'undefined') {\n return value;\n }\n\n if (window.CSS?.supports?.('color', 'var(--dummy, #000)') ?? false) {\n return value;\n }\n\n const varIndex = value.lastIndexOf('var(');\n if (varIndex === -1) {\n return value;\n }\n\n const expr = balanced('(', ')', value.substr(varIndex));\n if (!expr) {\n return value;\n }\n\n const match = expr.body.match(cssVariableExpression);\n return match ? match[1] : value;\n}\n\n// The instanceof Node/HTMLElement/SVGElement checks can fail if the target element\n// belongs to a different window than the respective type.\n\nexport function isNode(target: unknown): target is Node {\n return (\n target instanceof Node ||\n (target !== null &&\n typeof target === 'object' &&\n 'nodeType' in target &&\n typeof target.nodeType === 'number' &&\n 'nodeName' in target &&\n typeof target.nodeName === 'string' &&\n 'parentNode' in target &&\n typeof target.parentNode === 'object')\n );\n}\n\nexport function isHTMLElement(target: unknown): target is HTMLElement {\n return (\n target instanceof HTMLElement ||\n (isNode(target) &&\n target.nodeType === Node.ELEMENT_NODE &&\n 'style' in target &&\n typeof target.style === 'object' &&\n typeof target.ownerDocument === 'object' &&\n !isSVGElement(target))\n );\n}\n\nexport function isSVGElement(target: unknown): target is SVGElement {\n return (\n target instanceof SVGElement ||\n (isNode(target) &&\n target.nodeType === Node.ELEMENT_NODE &&\n 'ownerSVGElement' in target &&\n typeof target.ownerSVGElement === 'object')\n );\n}\n\nexport function documentHasFocus() {\n // In JSDOM the hasFocus() always returns false which differs from the in-browser experience, see: https://github.com/jsdom/jsdom/issues/3794.\n // Thus, when detecting JSDOM environment we return true here explicitly for the tests to work expectedly.\n // The detection depends on the default userAgent set in JSDOM, see: https://github.com/jsdom/jsdom?tab=readme-ov-file#advanced-configuration.\n const isJSDOM = typeof navigator !== 'undefined' && navigator.userAgent?.includes('jsdom');\n return isJSDOM || (typeof document !== undef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AAqB,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAClC,CAAC;AAED,mFAAmF;AACnF,0DAA0D;AAE1D,MAAM,UAAU,MAAM,CAAC,MAAe;IACpC,OAAO,CACL,MAAM,YAAY,IAAI;QACtB,CAAC,MAAM,KAAK,IAAI;YACd,OAAO,MAAM,KAAK,QAAQ;YAC1B,UAAU,IAAI,MAAM;YACpB,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;YACnC,UAAU,IAAI,MAAM;YACpB,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ;YACnC,YAAY,IAAI,MAAM;YACtB,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,CAAC,CACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAe;IAC3C,OAAO,CACL,MAAM,YAAY,WAAW;QAC7B,CAAC,MAAM,CAAC,MAAM,CAAC;YACb,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;YACrC,OAAO,IAAI,MAAM;YACjB,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ;YAChC,OAAO,MAAM,CAAC,aAAa,KAAK,QAAQ;YACxC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CACzB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,CACL,MAAM,YAAY,UAAU;QAC5B,CAAC,MAAM,CAAC,MAAM,CAAC;YACb,MAAM,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY;YACrC,iBAAiB,IAAI,MAAM;YAC3B,OAAO,MAAM,CAAC,eAAe,KAAK,QAAQ,CAAC,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport balanced from 'balanced-match';\n\nimport { findUpUntil } from '@cloudscape-design/component-toolkit/dom';\n\nexport function isContainingBlock(element: HTMLElement): boolean {\n const computedStyle = getComputedStyle(element);\n return (\n (!!computedStyle.transform && computedStyle.transform !== 'none') ||\n (!!computedStyle.perspective && computedStyle.perspective !== 'none') ||\n (!!computedStyle.containerType && computedStyle.containerType !== 'normal') ||\n computedStyle.contain?.split(' ').some(s => ['layout', 'paint', 'strict', 'content'].includes(s))\n );\n}\n\n/**\n * Returns an element that is used to position the given element.\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block\n */\nexport function getContainingBlock(startElement: HTMLElement): HTMLElement | null {\n if (!startElement.parentElement) {\n return null;\n }\n\n return findUpUntil(startElement.parentElement, isContainingBlock) as HTMLElement;\n}\n\n/*\n * Allows to find multiple elements in the page each according to a specific test function,\n * but traversing the DOM only once.\n */\n\nexport function findUpUntilMultiple({\n startElement,\n tests,\n}: {\n startElement: HTMLElement;\n tests: Record<string, (el: HTMLElement) => boolean>;\n}) {\n const keys = Object.keys(tests);\n const elements: Record<string, HTMLElement> = {};\n let current: HTMLElement | null = startElement;\n while (current && Object.keys(elements).length < keys.length) {\n current = current.parentElement;\n // If a component is used within an svg (i.e. as foreignObject), then it will\n // have some ancestor nodes that are SVGElement. We want to skip those,\n // as they have very different properties to HTMLElements.\n while (current && !isHTMLElement(current)) {\n current = (current as Element).parentElement;\n }\n for (const key of keys) {\n if (!elements[key] && current && tests[key](current)) {\n elements[key] = current;\n }\n }\n }\n return elements;\n}\n\nconst cssVariableExpression = /--.+?\\s*,\\s*(.+)/;\n\n/**\n * Parses a CSS color value that might contain CSS Custom Properties\n * and returns a value that will be understood by the browser, no matter of support level.\n * If the browser support CSS Custom Properties, the value will be return as is. Otherwise,\n * the fallback value will be extracted and returned instead.\n */\nexport function parseCssVariable(value: string) {\n if (typeof window === 'undefined') {\n return value;\n }\n\n if (window.CSS?.supports?.('color', 'var(--dummy, #000)') ?? false) {\n return value;\n }\n\n const varIndex = value.lastIndexOf('var(');\n if (varIndex === -1) {\n return value;\n }\n\n const expr = balanced('(', ')', value.substr(varIndex));\n if (!expr) {\n return value;\n }\n\n const match = expr.body.match(cssVariableExpression);\n return match ? match[1] : value;\n}\n\n// The instanceof Node/HTMLElement/SVGElement checks can fail if the target element\n// belongs to a different window than the respective type.\n\nexport function isNode(target: unknown): target is Node {\n return (\n target instanceof Node ||\n (target !== null &&\n typeof target === 'object' &&\n 'nodeType' in target &&\n typeof target.nodeType === 'number' &&\n 'nodeName' in target &&\n typeof target.nodeName === 'string' &&\n 'parentNode' in target &&\n typeof target.parentNode === 'object')\n );\n}\n\nexport function isHTMLElement(target: unknown): target is HTMLElement {\n return (\n target instanceof HTMLElement ||\n (isNode(target) &&\n target.nodeType === Node.ELEMENT_NODE &&\n 'style' in target &&\n typeof target.style === 'object' &&\n typeof target.ownerDocument === 'object' &&\n !isSVGElement(target))\n );\n}\n\nexport function isSVGElement(target: unknown): target is SVGElement {\n return (\n target instanceof SVGElement ||\n (isNode(target) &&\n target.nodeType === Node.ELEMENT_NODE &&\n 'ownerSVGElement' in target &&\n typeof target.ownerSVGElement === 'object')\n );\n}\n"]}
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.907",
135
+ "version": "3.0.909",
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,aAA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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 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"]}