@cloudscape-design/components 3.0.994 → 3.0.996
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.
- package/alert/index.js +1 -1
- package/alert/index.js.map +1 -1
- package/annotation-context/annotation/annotation-popover.d.ts.map +1 -1
- package/annotation-context/annotation/annotation-popover.js +1 -1
- package/annotation-context/annotation/annotation-popover.js.map +1 -1
- package/app-layout/visual-refresh/context.d.ts.map +1 -1
- package/app-layout/visual-refresh/context.js +1 -2
- package/app-layout/visual-refresh/context.js.map +1 -1
- package/app-layout/visual-refresh-toolbar/index.d.ts.map +1 -1
- package/app-layout/visual-refresh-toolbar/index.js +1 -2
- package/app-layout/visual-refresh-toolbar/index.js.map +1 -1
- package/area-chart/elements/data-series.d.ts.map +1 -1
- package/area-chart/elements/data-series.js +1 -1
- package/area-chart/elements/data-series.js.map +1 -1
- package/attribute-editor/internal.d.ts.map +1 -1
- package/attribute-editor/internal.js +1 -2
- package/attribute-editor/internal.js.map +1 -1
- package/attribute-editor/row.d.ts.map +1 -1
- package/attribute-editor/row.js +1 -1
- package/attribute-editor/row.js.map +1 -1
- package/autosuggest/internal.d.ts.map +1 -1
- package/autosuggest/internal.js +1 -2
- package/autosuggest/internal.js.map +1 -1
- package/button/internal.d.ts.map +1 -1
- package/button/internal.js +1 -2
- package/button/internal.js.map +1 -1
- package/button-dropdown/internal.d.ts.map +1 -1
- package/button-dropdown/internal.js +1 -2
- package/button-dropdown/internal.js.map +1 -1
- package/calendar/internal.d.ts.map +1 -1
- package/calendar/internal.js +1 -1
- package/calendar/internal.js.map +1 -1
- package/code-editor/index.d.ts.map +1 -1
- package/code-editor/index.js +1 -2
- package/code-editor/index.js.map +1 -1
- package/collection-preferences/content-display/content-display-option.d.ts.map +1 -1
- package/collection-preferences/content-display/content-display-option.js +1 -1
- package/collection-preferences/content-display/content-display-option.js.map +1 -1
- package/collection-preferences/content-display/index.d.ts.map +1 -1
- package/collection-preferences/content-display/index.js +1 -1
- package/collection-preferences/content-display/index.js.map +1 -1
- package/collection-preferences/index.d.ts.map +1 -1
- package/collection-preferences/index.js +1 -2
- package/collection-preferences/index.js.map +1 -1
- package/collection-preferences/visible-content.d.ts.map +1 -1
- package/collection-preferences/visible-content.js +1 -1
- package/collection-preferences/visible-content.js.map +1 -1
- package/container/internal.d.ts.map +1 -1
- package/container/internal.js +1 -2
- package/container/internal.js.map +1 -1
- package/date-picker/index.d.ts.map +1 -1
- package/date-picker/index.js +1 -2
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/calendar/index.d.ts.map +1 -1
- package/date-range-picker/calendar/index.js +1 -1
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/index.d.ts.map +1 -1
- package/date-range-picker/index.js +1 -2
- package/date-range-picker/index.js.map +1 -1
- package/expandable-section/internal.d.ts.map +1 -1
- package/expandable-section/internal.js +1 -1
- package/expandable-section/internal.js.map +1 -1
- package/file-input/internal.d.ts.map +1 -1
- package/file-input/internal.js +1 -2
- package/file-input/internal.js.map +1 -1
- package/file-token-group/file-token.d.ts.map +1 -1
- package/file-token-group/file-token.js +1 -1
- package/file-token-group/file-token.js.map +1 -1
- package/file-upload/internal.d.ts.map +1 -1
- package/file-upload/internal.js +1 -2
- package/file-upload/internal.js.map +1 -1
- package/flashbar/collapsible-flashbar.js +1 -1
- package/flashbar/collapsible-flashbar.js.map +1 -1
- package/flashbar/flash.d.ts.map +1 -1
- package/flashbar/flash.js +1 -2
- package/flashbar/flash.js.map +1 -1
- package/form/index.d.ts.map +1 -1
- package/form/index.js +1 -1
- package/form/index.js.map +1 -1
- package/form-field/internal.d.ts.map +1 -1
- package/form-field/internal.js +1 -2
- package/form-field/internal.js.map +1 -1
- package/header/internal.d.ts.map +1 -1
- package/header/internal.js +1 -1
- package/header/internal.js.map +1 -1
- package/internal/analytics/components/analytics-funnel.d.ts.map +1 -1
- package/internal/analytics/components/analytics-funnel.js +1 -1
- package/internal/analytics/components/analytics-funnel.js.map +1 -1
- package/internal/components/abstract-switch/index.d.ts.map +1 -1
- package/internal/components/abstract-switch/index.js +1 -1
- package/internal/components/abstract-switch/index.js.map +1 -1
- package/internal/components/chart-plot/index.d.ts.map +1 -1
- package/internal/components/chart-plot/index.js +1 -1
- package/internal/components/chart-plot/index.js.map +1 -1
- package/internal/components/dropdown/index.d.ts.map +1 -1
- package/internal/components/dropdown/index.js +1 -2
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.d.ts +1 -0
- package/internal/components/options-list/utils/use-highlight-option.d.ts.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.js +1 -0
- package/internal/components/options-list/utils/use-highlight-option.js.map +1 -1
- package/internal/components/token-list/index.d.ts.map +1 -1
- package/internal/components/token-list/index.js +1 -1
- package/internal/components/token-list/index.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/environment.json +1 -1
- package/internal/hooks/use-hidden-description/index.js +1 -1
- package/internal/hooks/use-hidden-description/index.js.map +1 -1
- package/internal/hooks/use-performance-marks/index.d.ts.map +1 -1
- package/internal/hooks/use-performance-marks/index.js +1 -1
- package/internal/hooks/use-performance-marks/index.js.map +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.d.ts.map +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.js +1 -1
- package/internal/hooks/use-table-interaction-metrics/index.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/plugins/helpers/use-discovered-content.d.ts.map +1 -1
- package/internal/plugins/helpers/use-discovered-content.js +1 -1
- package/internal/plugins/helpers/use-discovered-content.js.map +1 -1
- package/key-value-pairs/internal.d.ts.map +1 -1
- package/key-value-pairs/internal.js +1 -1
- package/key-value-pairs/internal.js.map +1 -1
- package/link/internal.d.ts.map +1 -1
- package/link/internal.js +1 -2
- package/link/internal.js.map +1 -1
- package/mixed-line-bar-chart/data-series.d.ts.map +1 -1
- package/mixed-line-bar-chart/data-series.js +1 -1
- package/mixed-line-bar-chart/data-series.js.map +1 -1
- package/modal/index.d.ts.map +1 -1
- package/modal/index.js +1 -1
- package/modal/index.js.map +1 -1
- package/modal/internal.d.ts.map +1 -1
- package/modal/internal.js +1 -2
- package/modal/internal.js.map +1 -1
- package/multiselect/embedded.d.ts.map +1 -1
- package/multiselect/embedded.js +1 -1
- package/multiselect/embedded.js.map +1 -1
- package/multiselect/internal.d.ts.map +1 -1
- package/multiselect/internal.js +1 -1
- package/multiselect/internal.js.map +1 -1
- package/package.json +1 -1
- package/pie-chart/pie-chart.js +1 -1
- package/pie-chart/pie-chart.js.map +1 -1
- package/popover/body.js +1 -1
- package/popover/body.js.map +1 -1
- package/popover/internal.d.ts.map +1 -1
- package/popover/internal.js +1 -2
- package/popover/internal.js.map +1 -1
- package/progress-bar/index.d.ts.map +1 -1
- package/progress-bar/index.js +1 -2
- package/progress-bar/index.js.map +1 -1
- package/property-filter/internal.d.ts.map +1 -1
- package/property-filter/internal.js +1 -2
- package/property-filter/internal.js.map +1 -1
- package/property-filter/property-editor.d.ts.map +1 -1
- package/property-filter/property-editor.js +1 -1
- package/property-filter/property-editor.js.map +1 -1
- package/property-filter/property-filter-autosuggest.d.ts.map +1 -1
- package/property-filter/property-filter-autosuggest.js +1 -2
- package/property-filter/property-filter-autosuggest.js.map +1 -1
- package/property-filter/token-editor.d.ts.map +1 -1
- package/property-filter/token-editor.js +1 -1
- package/property-filter/token-editor.js.map +1 -1
- package/radio-group/internal.d.ts.map +1 -1
- package/radio-group/internal.js +1 -1
- package/radio-group/internal.js.map +1 -1
- package/select/internal.d.ts.map +1 -1
- package/select/internal.js +1 -2
- package/select/internal.js.map +1 -1
- package/select/parts/trigger.d.ts.map +1 -1
- package/select/parts/trigger.js +1 -2
- package/select/parts/trigger.js.map +1 -1
- package/select/utils/use-select.d.ts.map +1 -1
- package/select/utils/use-select.js +18 -5
- package/select/utils/use-select.js.map +1 -1
- package/slider/internal.d.ts.map +1 -1
- package/slider/internal.js +1 -2
- package/slider/internal.js.map +1 -1
- package/split-panel/implementation.d.ts.map +1 -1
- package/split-panel/implementation.js +1 -2
- package/split-panel/implementation.js.map +1 -1
- package/table/body-cell/inline-editor.d.ts.map +1 -1
- package/table/body-cell/inline-editor.js +15 -10
- package/table/body-cell/inline-editor.js.map +1 -1
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js +1 -2
- package/table/header-cell/index.js.map +1 -1
- package/table/interfaces.d.ts +10 -0
- package/table/interfaces.d.ts.map +1 -1
- package/table/interfaces.js.map +1 -1
- package/table/resizer/index.d.ts.map +1 -1
- package/table/resizer/index.js +1 -2
- package/table/resizer/index.js.map +1 -1
- package/table/selection/selection-control.js +1 -1
- package/table/selection/selection-control.js.map +1 -1
- package/table/selection/use-selection.d.ts.map +1 -1
- package/table/selection/use-selection.js +1 -1
- package/table/selection/use-selection.js.map +1 -1
- package/table/tools-header.d.ts.map +1 -1
- package/table/tools-header.js +1 -1
- package/table/tools-header.js.map +1 -1
- package/tabs/index.js +1 -1
- package/tabs/index.js.map +1 -1
- package/text-filter/internal.d.ts.map +1 -1
- package/text-filter/internal.js +1 -1
- package/text-filter/internal.js.map +1 -1
- package/tiles/internal.d.ts.map +1 -1
- package/tiles/internal.js +1 -2
- package/tiles/internal.js.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.js +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/submenu.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/views/submenu.js +1 -1
- package/top-navigation/parts/overflow-menu/views/submenu.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/utilities.d.ts.map +1 -1
- package/top-navigation/parts/overflow-menu/views/utilities.js +1 -1
- package/top-navigation/parts/overflow-menu/views/utilities.js.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.d.ts.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.js +1 -1
- package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
- package/wizard/wizard-form.d.ts.map +1 -1
- package/wizard/wizard-form.js +1 -2
- package/wizard/wizard-form.js.map +1 -1
- package/internal/hooks/use-unique-id/index.d.ts +0 -3
- package/internal/hooks/use-unique-id/index.d.ts.map +0 -1
- package/internal/hooks/use-unique-id/index.js +0 -17
- package/internal/hooks/use-unique-id/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAgC,MAAM,WAAW,CAAC;AA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C,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useUniqueId } from '../../hooks/use-unique-id/index.js';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { applyDropdownPositionRelativeToViewport, LogicalDOMRect } from './dropdown-position';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: LogicalDOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n applyDropdownPositionRelativeToViewport({\n position,\n dropdownElement: target,\n triggerRect: triggerBox,\n isMobile,\n });\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current && fixedPosition.current) {\n applyDropdownPositionRelativeToViewport({\n position: fixedPosition.current,\n dropdownElement: dropdownRef.current,\n triggerRect: getLogicalBoundingClientRect(triggerRef.current),\n isMobile,\n });\n }\n };\n\n updateDropdownPosition();\n\n const controller = new AbortController();\n window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });\n window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [open, expandToViewport, isMobile]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/dropdown/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAC7G,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAE7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAgC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AI,MAAA,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC5F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B;gBAEF,oBAAC,iBAAiB,IAChB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,GAAG,EAClB,eAAe,EAAE,eAAe,EAChC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,yBAAyB,EAAE,yBAAyB,EACpD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,WAAW,EACxB,oBAAoB,EAAE,oBAAoB,EAC1C,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,iBAAiB,EACrB,IAAI,EAAE,mBAAmB,EACzB,cAAc,EAAE,cAAc,EAC9B,eAAe,EAAE,eAAe,IAE/B,QAAQ,CACS;gBAEpB,oBAAC,OAAO,IACN,iBAAiB,EAAE,GAAG,EAAE,WAAC,OAAA,UAAU,CAAC,OAAO,KAAI,MAAA,iBAAiB,CAAC,UAAU,CAAC,OAAO,CAAC,0CAAE,KAAK,EAAE,CAAA,CAAA,EAAA,EAC7F,QAAQ,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,GAC7B,CACE,CACP,CACU,CACK,CAChB,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CACzB,QAAqD,EACf,EAAE,CAAE,QAAqC,CAAC,aAAa,KAAK,SAAS,CAAC;AAE9G,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\nimport clsx from 'clsx';\n\nimport { useMergeRefs, useResizeObserver, useUniqueId } from '@cloudscape-design/component-toolkit/internal';\nimport { getLogicalBoundingClientRect } from '@cloudscape-design/component-toolkit/internal';\n\nimport { fireNonCancelableEvent } from '../../events';\nimport customCssProps from '../../generated/custom-css-properties';\nimport { useMobile } from '../../hooks/use-mobile';\nimport { usePortalModeClasses } from '../../hooks/use-portal-mode-classes';\nimport { useVisualRefresh } from '../../hooks/use-visual-mode';\nimport { nodeBelongs } from '../../utils/node-belongs';\nimport { getFirstFocusable, getLastFocusable } from '../focus-lock/utils.js';\nimport TabTrap from '../tab-trap/index.js';\nimport { Transition, TransitionStatus } from '../transition';\nimport { DropdownContextProvider, DropdownContextProviderProps } from './context';\nimport {\n calculatePosition,\n defaultMaxDropdownWidth,\n DropdownPosition,\n hasEnoughSpaceToStretchBeyondTriggerWidth,\n InteriorDropdownPosition,\n} from './dropdown-fit-handler';\nimport { applyDropdownPositionRelativeToViewport, LogicalDOMRect } from './dropdown-position';\nimport { DropdownProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\ninterface DropdownContainerProps {\n triggerRef: React.RefObject<HTMLElement>;\n children?: React.ReactNode;\n renderWithPortal: boolean;\n id?: string;\n referrerId?: string;\n open?: boolean;\n}\n\nconst DropdownContainer = ({\n triggerRef,\n children,\n renderWithPortal,\n id,\n referrerId,\n open,\n}: DropdownContainerProps) => {\n if (!renderWithPortal) {\n return <>{children}</>;\n }\n if (!open) {\n return null;\n }\n const currentDocument = triggerRef.current?.ownerDocument ?? document;\n return createPortal(\n <div id={id} data-awsui-referrer-id={referrerId}>\n {children}\n </div>,\n currentDocument.body\n );\n};\n\ninterface TransitionContentProps {\n state: TransitionStatus;\n transitionRef: React.MutableRefObject<any>;\n dropdownClasses: string;\n stretchWidth: boolean;\n interior: boolean;\n isRefresh: boolean;\n dropdownRef: React.RefObject<HTMLDivElement>;\n verticalContainerRef: React.RefObject<HTMLDivElement>;\n expandToViewport?: boolean;\n stretchBeyondTriggerWidth?: boolean;\n header?: React.ReactNode;\n children?: React.ReactNode;\n footer?: React.ReactNode;\n position?: DropdownContextProviderProps['position'];\n open?: boolean;\n onMouseDown?: React.MouseEventHandler<Element>;\n id?: string;\n role?: string;\n ariaLabelledby?: string;\n ariaDescribedby?: string;\n}\n\nconst TransitionContent = ({\n state,\n transitionRef,\n dropdownClasses,\n stretchWidth,\n interior,\n isRefresh,\n dropdownRef,\n verticalContainerRef,\n expandToViewport,\n stretchBeyondTriggerWidth,\n header,\n children,\n footer,\n position,\n open,\n onMouseDown,\n id,\n role,\n ariaLabelledby,\n ariaDescribedby,\n}: TransitionContentProps) => {\n const contentRef = useMergeRefs(dropdownRef, transitionRef);\n return (\n <div\n className={clsx(styles.dropdown, dropdownClasses, {\n [styles.open]: open,\n [styles['with-limited-width']]: !stretchWidth,\n [styles['hide-block-border']]: stretchWidth,\n [styles.interior]: interior,\n [styles.refresh]: isRefresh,\n [styles['use-portal']]: expandToViewport && !interior,\n [styles['stretch-beyond-trigger-width']]: stretchBeyondTriggerWidth,\n })}\n ref={contentRef}\n id={id}\n role={role}\n aria-labelledby={ariaLabelledby}\n aria-describedby={ariaDescribedby}\n data-open={open}\n data-animating={state !== 'exited'}\n aria-hidden={!open}\n style={\n stretchBeyondTriggerWidth ? { [customCssProps.dropdownDefaultMaxWidth]: `${defaultMaxDropdownWidth}px` } : {}\n }\n onMouseDown={onMouseDown}\n >\n <div\n className={clsx(\n styles['dropdown-content-wrapper'],\n !header && !children && styles['is-empty'],\n isRefresh && styles.refresh\n )}\n >\n <div ref={verticalContainerRef} className={styles['dropdown-content']}>\n <DropdownContextProvider position={position}>\n {header}\n {children}\n {footer}\n </DropdownContextProvider>\n </div>\n </div>\n </div>\n );\n};\n\nconst Dropdown = ({\n children,\n trigger,\n open,\n onDropdownClose,\n onMouseDown,\n header,\n footer,\n dropdownId,\n stretchTriggerHeight = false,\n stretchWidth = true,\n stretchHeight = false,\n stretchToTriggerWidth = true,\n stretchBeyondTriggerWidth = false,\n expandToViewport = false,\n preferCenter = false,\n interior = false,\n minWidth,\n scrollable = true,\n loopFocus = expandToViewport,\n onFocus,\n onBlur,\n contentKey,\n dropdownContentId,\n dropdownContentRole,\n ariaLabelledby,\n ariaDescribedby,\n}: DropdownProps) => {\n const wrapperRef = useRef<HTMLDivElement | null>(null);\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n const dropdownContainerRef = useRef<HTMLDivElement | null>(null);\n const verticalContainerRef = useRef<HTMLDivElement>(null);\n // To keep track of the initial position (drop up/down) which is kept the same during fixed repositioning\n const fixedPosition = useRef<DropdownPosition | null>(null);\n\n const isRefresh = useVisualRefresh();\n\n const dropdownClasses = usePortalModeClasses(triggerRef);\n const [position, setPosition] = useState<DropdownContextProviderProps['position']>('bottom-right');\n\n const isMobile = useMobile();\n\n const setDropdownPosition = (\n position: DropdownPosition | InteriorDropdownPosition,\n triggerBox: LogicalDOMRect,\n target: HTMLDivElement,\n verticalContainer: HTMLDivElement\n ) => {\n const entireWidth = !interior && stretchWidth;\n if (!stretchWidth) {\n // 1px offset for dropdowns where the dropdown itself needs a border, rather than on the items\n verticalContainer.style.maxBlockSize = `${parseInt(position.blockSize) + 1}px`;\n } else {\n verticalContainer.style.maxBlockSize = position.blockSize;\n }\n\n if (entireWidth && !expandToViewport) {\n if (stretchToTriggerWidth) {\n target.classList.add(styles['occupy-entire-width']);\n }\n } else {\n target.style.inlineSize = position.inlineSize;\n }\n\n // Using styles for main dropdown to adjust its position as preferred alternative\n if (position.dropBlockStart && !interior) {\n target.classList.add(styles['dropdown-drop-up']);\n if (!expandToViewport) {\n target.style.insetBlockEnd = '100%';\n }\n } else {\n target.classList.remove(styles['dropdown-drop-up']);\n }\n target.classList.add(position.dropInlineStart ? styles['dropdown-drop-left'] : styles['dropdown-drop-right']);\n\n if (position.insetInlineStart && position.insetInlineStart !== 'auto') {\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n // Position normal overflow dropdowns with fixed positioning relative to viewport\n if (expandToViewport && !interior) {\n applyDropdownPositionRelativeToViewport({\n position,\n dropdownElement: target,\n triggerRect: triggerBox,\n isMobile,\n });\n // Keep track of the initial dropdown position and direction.\n // Dropdown direction doesn't need to change as the user scrolls, just needs to stay attached to the trigger.\n fixedPosition.current = position;\n return;\n }\n\n // For an interior dropdown (the fly out) we need exact values for positioning\n // and classes are not enough\n // usage of relative position is impossible due to overwrite of overflow-x\n if (interior && isInteriorPosition(position)) {\n if (position.dropBlockStart) {\n target.style.insetBlockEnd = position.insetBlockEnd;\n } else {\n target.style.insetBlockStart = position.insetBlockStart;\n }\n target.style.insetInlineStart = position.insetInlineStart;\n }\n\n if (position.dropBlockStart && position.dropInlineStart) {\n setPosition('top-left');\n } else if (position.dropBlockStart) {\n setPosition('top-right');\n } else if (position.dropInlineStart) {\n setPosition('bottom-left');\n } else {\n setPosition('bottom-right');\n }\n };\n\n const isOutsideDropdown = (element: Element) =>\n (!wrapperRef.current || !nodeBelongs(wrapperRef.current, element)) &&\n (!dropdownContainerRef.current || !nodeBelongs(dropdownContainerRef.current, element));\n\n const focusHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onFocus, event);\n }\n };\n\n const blurHandler = (event: React.FocusEvent) => {\n if (!event.relatedTarget || isOutsideDropdown(event.relatedTarget)) {\n fireNonCancelableEvent(onBlur, event);\n }\n };\n\n // Prevent the dropdown width from stretching beyond the trigger width\n // if that is going to cause the dropdown to be cropped because of overflow\n const fixStretching = () => {\n const classNameToRemove = styles['stretch-beyond-trigger-width'];\n if (\n open &&\n stretchBeyondTriggerWidth &&\n dropdownRef.current &&\n triggerRef.current &&\n dropdownRef.current.classList.contains(classNameToRemove) &&\n !hasEnoughSpaceToStretchBeyondTriggerWidth({\n triggerElement: triggerRef.current,\n dropdownElement: dropdownRef.current,\n desiredMinWidth: minWidth,\n expandToViewport,\n stretchWidth,\n stretchHeight,\n isMobile,\n })\n ) {\n dropdownRef.current.classList.remove(classNameToRemove);\n }\n };\n\n useResizeObserver(() => dropdownRef.current, fixStretching);\n\n useLayoutEffect(() => {\n const onDropdownOpen = () => {\n if (open && dropdownRef.current && triggerRef.current && verticalContainerRef.current) {\n // calculate scroll width only for dropdowns that has a scrollbar and ignore it for date picker components\n if (scrollable) {\n dropdownRef.current.classList.add(styles.nowrap);\n }\n setDropdownPosition(\n ...calculatePosition(\n dropdownRef.current,\n triggerRef.current,\n verticalContainerRef.current,\n interior,\n expandToViewport,\n preferCenter,\n stretchWidth,\n stretchHeight,\n isMobile,\n minWidth,\n stretchBeyondTriggerWidth\n ),\n dropdownRef.current,\n verticalContainerRef.current\n );\n if (scrollable) {\n dropdownRef.current.classList.remove(styles.nowrap);\n }\n }\n };\n onDropdownOpen();\n\n if (open) {\n // window may scroll when dropdown opens, for example when soft keyboard shows up\n window.addEventListener('scroll', onDropdownOpen);\n // only listen to window scroll within very short time after the dropdown opens\n // do not want to interfere dropdown position on scroll afterwards\n const timeoutId = setTimeout(() => {\n window.removeEventListener('scroll', onDropdownOpen);\n }, 500);\n\n return () => {\n clearTimeout(timeoutId);\n window.removeEventListener('scroll', onDropdownOpen);\n };\n }\n // See AWSUI-13040\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, dropdownRef, triggerRef, verticalContainerRef, interior, stretchWidth, isMobile, contentKey]);\n\n // subscribe to outside click\n useEffect(() => {\n if (!open) {\n return;\n }\n const clickListener = (event: MouseEvent) => {\n // Since the listener is registered on the window, `event.target` will incorrectly point at the\n // shadow root if the component is rendered inside shadow DOM.\n const target = event.composedPath ? event.composedPath()[0] : event.target;\n if (!nodeBelongs(dropdownRef.current, target) && !nodeBelongs(triggerRef.current, target)) {\n fireNonCancelableEvent(onDropdownClose);\n }\n };\n window.addEventListener('click', clickListener, true);\n\n return () => {\n window.removeEventListener('click', clickListener, true);\n };\n }, [open, onDropdownClose]);\n\n // sync dropdown position on scroll and resize\n useLayoutEffect(() => {\n if (!expandToViewport || !open) {\n return;\n }\n const updateDropdownPosition = () => {\n if (triggerRef.current && dropdownRef.current && verticalContainerRef.current && fixedPosition.current) {\n applyDropdownPositionRelativeToViewport({\n position: fixedPosition.current,\n dropdownElement: dropdownRef.current,\n triggerRect: getLogicalBoundingClientRect(triggerRef.current),\n isMobile,\n });\n }\n };\n\n updateDropdownPosition();\n\n const controller = new AbortController();\n window.addEventListener('scroll', updateDropdownPosition, { capture: true, signal: controller.signal });\n window.addEventListener('resize', updateDropdownPosition, { capture: true, signal: controller.signal });\n return () => {\n controller.abort();\n };\n }, [open, expandToViewport, isMobile]);\n\n const referrerId = useUniqueId();\n\n return (\n <div\n className={clsx(\n styles.root,\n interior && styles.interior,\n stretchTriggerHeight && styles['stretch-trigger-height']\n )}\n ref={wrapperRef}\n onFocus={focusHandler}\n onBlur={blurHandler}\n >\n <div id={referrerId} className={clsx(stretchTriggerHeight && styles['stretch-trigger-height'])} ref={triggerRef}>\n {trigger}\n </div>\n\n <TabTrap\n focusNextCallback={() => dropdownRef.current && getFirstFocusable(dropdownRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <DropdownContainer\n triggerRef={triggerRef}\n renderWithPortal={expandToViewport && !interior}\n id={dropdownId}\n referrerId={referrerId}\n open={open}\n >\n <Transition in={open ?? false} exit={false}>\n {(state, ref) => (\n <div ref={dropdownContainerRef}>\n <TabTrap\n focusNextCallback={() => triggerRef.current && getLastFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n\n <TransitionContent\n state={state}\n transitionRef={ref}\n dropdownClasses={dropdownClasses}\n open={open}\n stretchWidth={stretchWidth}\n interior={interior}\n header={header}\n expandToViewport={expandToViewport}\n stretchBeyondTriggerWidth={stretchBeyondTriggerWidth}\n footer={footer}\n onMouseDown={onMouseDown}\n isRefresh={isRefresh}\n dropdownRef={dropdownRef}\n verticalContainerRef={verticalContainerRef}\n position={position}\n id={dropdownContentId}\n role={dropdownContentRole}\n ariaLabelledby={ariaLabelledby}\n ariaDescribedby={ariaDescribedby}\n >\n {children}\n </TransitionContent>\n\n <TabTrap\n focusNextCallback={() => triggerRef.current && getFirstFocusable(triggerRef.current)?.focus()}\n disabled={!open || !loopFocus}\n />\n </div>\n )}\n </Transition>\n </DropdownContainer>\n </div>\n );\n};\n\nconst isInteriorPosition = (\n position: DropdownPosition | InteriorDropdownPosition\n): position is InteriorDropdownPosition => (position as InteriorDropdownPosition).insetBlockEnd !== undefined;\n\nexport default Dropdown;\n"]}
|
|
@@ -14,6 +14,7 @@ export interface HighlightedOptionState<OptionType> {
|
|
|
14
14
|
}
|
|
15
15
|
export interface HighlightedOptionHandlers<OptionType> {
|
|
16
16
|
setHighlightedIndexWithMouse(index: number, moveFocus?: boolean): void;
|
|
17
|
+
highlightFirstOptionWithMouse(): void;
|
|
17
18
|
moveHighlightWithKeyboard(direction: -1 | 1): void;
|
|
18
19
|
highlightOptionWithKeyboard(option: OptionType): void;
|
|
19
20
|
resetHighlightWithKeyboard(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-highlight-option.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IAEf,IAAI,EAAE,UAAU,GAAG,OAAO;IAC1B,SAAS,EAAE,OAAO;gBADlB,IAAI,EAAE,UAAU,GAAG,OAAO,EAC1B,SAAS,GAAE,OAA6B;CAElD;AAED,UAAU,sBAAsB,CAAC,UAAU;IACzC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,eAAe,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,sBAAsB,CAAC,UAAU;IAChD,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB,CAAC,UAAU;IAEnD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"use-highlight-option.d.ts","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IAEf,IAAI,EAAE,UAAU,GAAG,OAAO;IAC1B,SAAS,EAAE,OAAO;gBADlB,IAAI,EAAE,UAAU,GAAG,OAAO,EAC1B,SAAS,GAAE,OAA6B;CAElD;AAED,UAAU,sBAAsB,CAAC,UAAU;IACzC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,eAAe,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC;CAClD;AAED,MAAM,WAAW,sBAAsB,CAAC,UAAU;IAChD,aAAa,EAAE,aAAa,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAChC;AAED,MAAM,WAAW,yBAAyB,CAAC,UAAU;IAEnD,4BAA4B,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACvE,6BAA6B,IAAI,IAAI,CAAC;IAEtC,yBAAyB,CAAC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACnD,2BAA2B,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACtD,0BAA0B,IAAI,IAAI,CAAC;IACnC,kBAAkB,IAAI,IAAI,CAAC;IAC3B,iBAAiB,IAAI,IAAI,CAAC;CAC3B;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,EAC/C,OAAO,EACP,eAAe,GAChB,EAAE,sBAAsB,CAAC,UAAU,CAAC,GAAG,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC,CA+ClH"}
|
|
@@ -34,6 +34,7 @@ export function useHighlightedOption({ options, isHighlightable, }) {
|
|
|
34
34
|
{ highlightType, highlightedIndex, highlightedOption },
|
|
35
35
|
{
|
|
36
36
|
setHighlightedIndexWithMouse: (index, moveFocus = false) => setHighlightedIndex(index, new HighlightType('mouse', moveFocus)),
|
|
37
|
+
highlightFirstOptionWithMouse: () => moveHighlightFrom(1, -1, new HighlightType('mouse', true)),
|
|
37
38
|
moveHighlightWithKeyboard: (direction) => moveHighlight(direction, new HighlightType('keyboard')),
|
|
38
39
|
highlightOptionWithKeyboard: (option) => highlightOption(option, new HighlightType('keyboard')),
|
|
39
40
|
resetHighlightWithKeyboard: () => setHighlightedIndex(-1, new HighlightType('keyboard')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-highlight-option.js","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,OAAO,aAAa;IACxB,YACS,IAA0B,EAC1B,YAAqB,IAAI,KAAK,UAAU;QADxC,SAAI,GAAJ,IAAI,CAAsB;QAC1B,cAAS,GAAT,SAAS,CAA+B;IAC9C,CAAC;CACL;
|
|
1
|
+
{"version":3,"file":"use-highlight-option.js","sourceRoot":"","sources":["../../../../../../src/internal/components/options-list/utils/use-highlight-option.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE9C,MAAM,OAAO,aAAa;IACxB,YACS,IAA0B,EAC1B,YAAqB,IAAI,KAAK,UAAU;QADxC,SAAI,GAAJ,IAAI,CAAsB;QAC1B,cAAS,GAAT,SAAS,CAA+B;IAC9C,CAAC;CACL;AAyBD,MAAM,UAAU,oBAAoB,CAAa,EAC/C,OAAO,EACP,eAAe,GACoB;IACnC,MAAM,CAAC,g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E,OAAO,CAAC,MAAM,EAAE,IAAI,aAAa,CAAC,UAAU,CAAC,CAAC;SAC9F;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { useCallback, useState } from 'react';\n\nexport class HighlightType {\n constructor(\n public type: 'keyboard' | 'mouse',\n public moveFocus: boolean = type === 'keyboard'\n ) {}\n}\n\ninterface HighlightedOptionProps<OptionType> {\n options: readonly OptionType[];\n isHighlightable: (option: OptionType) => boolean;\n}\n\nexport interface HighlightedOptionState<OptionType> {\n highlightType: HighlightType;\n highlightedIndex: number;\n highlightedOption?: OptionType;\n}\n\nexport interface HighlightedOptionHandlers<OptionType> {\n // Mouse handlers\n setHighlightedIndexWithMouse(index: number, moveFocus?: boolean): void;\n highlightFirstOptionWithMouse(): void;\n // Keyboard handlers\n moveHighlightWithKeyboard(direction: -1 | 1): void;\n highlightOptionWithKeyboard(option: OptionType): void;\n resetHighlightWithKeyboard(): void;\n goHomeWithKeyboard(): void;\n goEndWithKeyboard(): void;\n}\n\nexport function useHighlightedOption<OptionType>({\n options,\n isHighlightable,\n}: HighlightedOptionProps<OptionType>): [HighlightedOptionState<OptionType>, HighlightedOptionHandlers<OptionType>] {\n const [highlightedIndex, setHighlightedIndexState] = useState(-1);\n const [highlightType, setHighlightType] = useState<HighlightType>(new HighlightType('keyboard'));\n const setHighlightedIndex = useCallback((index: number, newHighlightType: HighlightType) => {\n setHighlightedIndexState(index);\n setHighlightType(oldHighlight => (oldHighlight.type !== newHighlightType.type ? newHighlightType : oldHighlight));\n }, []);\n\n const highlightedOption =\n options[highlightedIndex] && isHighlightable(options[highlightedIndex]) ? options[highlightedIndex] : undefined;\n\n const moveHighlightFrom = (direction: -1 | 1, startIndex = highlightedIndex, highlightType: HighlightType) => {\n const fromBottomEnd = startIndex === -1 && direction === -1;\n let newIndex = fromBottomEnd ? options.length : startIndex;\n do {\n newIndex += direction;\n } while (options[newIndex] && !isHighlightable(options[newIndex]));\n\n if (options[newIndex]) {\n setHighlightedIndex(newIndex, highlightType);\n }\n };\n\n const moveHighlight = (direction: -1 | 1, highlightType: HighlightType) =>\n moveHighlightFrom(direction, highlightedIndex, highlightType);\n\n const highlightOption = useCallback(\n (option: OptionType, highlightType: HighlightType) => {\n const index = options.indexOf(option);\n setHighlightedIndex(index, highlightType);\n },\n [options, setHighlightedIndex]\n );\n\n return [\n { highlightType, highlightedIndex, highlightedOption },\n {\n setHighlightedIndexWithMouse: (index: number, moveFocus = false) =>\n setHighlightedIndex(index, new HighlightType('mouse', moveFocus)),\n highlightFirstOptionWithMouse: () => moveHighlightFrom(1, -1, new HighlightType('mouse', true)),\n moveHighlightWithKeyboard: (direction: -1 | 1) => moveHighlight(direction, new HighlightType('keyboard')),\n highlightOptionWithKeyboard: (option: OptionType) => highlightOption(option, new HighlightType('keyboard')),\n resetHighlightWithKeyboard: () => setHighlightedIndex(-1, new HighlightType('keyboard')),\n goHomeWithKeyboard: () => moveHighlightFrom(1, -1, new HighlightType('keyboard')),\n goEndWithKeyboard: () => moveHighlightFrom(-1, options.length, new HighlightType('keyboard')),\n },\n ];\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/token-list/index.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/components/token-list/index.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAK9C,OAAO,EAAE,cAAc,EAAE,CAAC;AAE1B,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,EACtC,KAAK,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,KAAK,EACL,WAAW,EACX,uBAAuB,EACvB,sBAAsB,EACtB,eAAiC,GAClC,EAAE,cAAc,CAAC,IAAI,CAAC,eA+EtB"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { useUniqueId } from '
|
|
5
|
+
import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
6
6
|
import TokenLimitToggle from './token-limit-toggle';
|
|
7
7
|
import styles from './styles.css.js';
|
|
8
8
|
export default function TokenList({ items, alignment, renderItem, limit, after, i18nStrings, limitShowFewerAriaLabel, limitShowMoreAriaLabel, onExpandedClick = () => undefined, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/token-list/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/components/token-list/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAG5E,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AAEpD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAIrC,MAAM,CAAC,OAAO,UAAU,SAAS,CAAO,EACtC,KAAK,EACL,SAAS,EACT,UAAU,EACV,KAAK,EACL,KAAK,EACL,WAAW,EACX,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,GAAG,GAAG,EAAE,CAAC,SAAS,GACZ;IACrB,MAAM,SAAS,GAAG,WAAW,EAAE,CAAC;IAEhC,MAAM,CAAC,QA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EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,IACtC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CACrC,4BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,kBAChB,KAAK,CAAC,MAAM,mBACX,SAAS,GAAG,CAAC,IAE3B,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CACzB,CACN,CAAC,CACC,CACN;YACA,MAAM;YACN,KAAK,IAAI,6BAAK,SAAS,EAAE,MAAM,CAAC,SAAS,GAAI;YAC7C,KAAK,CACF,CACP,CAAC;KACH;IAED,OAAO,CACL,6BAAK,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC;QAC/C,eAAe,IAAI,CAClB,4BACE,EAAE,EAAE,SAAS,EACb,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC3B,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,SAAS,KAAK,UAAU;gBAC3C,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,SAAS,KAAK,YAAY;gBAC/C,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,iBAAiB;aAC/C,CAAC,IAED,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CACrC,4BACE,GAAG,EAAE,SAAS,EACd,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,kBAChB,KAAK,CAAC,MAAM,mBACX,SAAS,GAAG,CAAC,IAE3B,UAAU,CAAC,IAAI,EAAE,SAAS,CAAC,CACzB,CACN,CAAC,CACC,CACN;QACA,MAAM;QACN,KAAK,CACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport React, { useState } from 'react';\nimport clsx from 'clsx';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { TokenListProps } from './interfaces';\nimport TokenLimitToggle from './token-limit-toggle';\n\nimport styles from './styles.css.js';\n\nexport { TokenListProps };\n\nexport default function TokenList<Item>({\n items,\n alignment,\n renderItem,\n limit,\n after,\n i18nStrings,\n limitShowFewerAriaLabel,\n limitShowMoreAriaLabel,\n onExpandedClick = () => undefined,\n}: TokenListProps<Item>) {\n const controlId = useUniqueId();\n\n const [expanded, setExpanded] = useState(false);\n const hasItems = items.length > 0;\n const hasHiddenItems = hasItems && limit !== undefined && items.length > limit;\n const visibleItems = hasHiddenItems && !expanded ? items.slice(0, limit) : items;\n const hasVisibleItems = visibleItems.length > 0;\n\n const toggle = hasHiddenItems ? (\n <div className={styles[`toggle-container-${alignment}`]}>\n <TokenLimitToggle\n controlId={hasVisibleItems ? controlId : undefined}\n allHidden={limit === 0}\n expanded={expanded}\n numberOfHiddenOptions={items.length - visibleItems.length}\n i18nStrings={i18nStrings}\n limitShowFewerAriaLabel={limitShowFewerAriaLabel}\n limitShowMoreAriaLabel={limitShowMoreAriaLabel}\n onClick={() => {\n const isExpanded = !expanded;\n setExpanded(isExpanded);\n onExpandedClick(isExpanded);\n }}\n />\n </div>\n ) : null;\n\n if (alignment === 'inline') {\n return (\n <div className={clsx(styles.root, styles.horizontal)}>\n {hasItems && (\n <ul id={controlId} className={styles.list}>\n {visibleItems.map((item, itemIndex) => (\n <li\n key={itemIndex}\n className={styles['list-item']}\n aria-setsize={items.length}\n aria-posinset={itemIndex + 1}\n >\n {renderItem(item, itemIndex)}\n </li>\n ))}\n </ul>\n )}\n {toggle}\n {after && <div className={styles.separator} />}\n {after}\n </div>\n );\n }\n\n return (\n <div className={clsx(styles.root, styles.vertical)}>\n {hasVisibleItems && (\n <ul\n id={controlId}\n className={clsx(styles.list, {\n [styles.vertical]: alignment === 'vertical',\n [styles.horizontal]: alignment === 'horizontal',\n [styles.grid]: alignment === 'horizontal-grid',\n })}\n >\n {visibleItems.map((item, itemIndex) => (\n <li\n key={itemIndex}\n className={styles['list-item']}\n aria-setsize={items.length}\n aria-posinset={itemIndex + 1}\n >\n {renderItem(item, itemIndex)}\n </li>\n ))}\n </ul>\n )}\n {toggle}\n {after}\n </div>\n );\n}\n"]}
|
package/internal/environment.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { useUniqueId } from '
|
|
4
|
+
import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
5
5
|
export default function useHiddenDescription(description) {
|
|
6
6
|
const id = useUniqueId();
|
|
7
7
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-hidden-description/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-hidden-description/index.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,WAAoB;IAC/D,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IACzB,OAAO;QACL,WAAW,EAAE;YACX,kBAAkB,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;SACjD;QACD,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,CAC3B,8BAAM,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,IACvB,WAAW,CACP,CACR,CAAC,CAAC,CAAC,IAAI;QACR,aAAa,EAAE,EAAE;KAClB,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 { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nexport default function useHiddenDescription(description?: string) {\n const id = useUniqueId();\n return {\n targetProps: {\n 'aria-describedby': description ? id : undefined,\n },\n descriptionEl: description ? (\n <span id={id} hidden={true}>\n {description}\n </span>\n ) : null,\n descriptionId: id,\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":";AAsCA;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,OAAO,EACtB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EACxC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,EACvE,YAAY,EAAE,KAAK,CAAC,cAAc;;EAuEnC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
|
+
import { useRandomId } from '@cloudscape-design/component-toolkit/internal';
|
|
4
5
|
import { useModalContext } from '../../context/modal-context';
|
|
5
6
|
import { useDOMAttribute } from '../use-dom-attribute';
|
|
6
7
|
import { useEffectOnUpdate } from '../use-effect-on-update';
|
|
7
|
-
import { useRandomId } from '../use-unique-id';
|
|
8
8
|
import { isInViewport } from './is-in-viewport';
|
|
9
9
|
const EVALUATE_COMPONENT_VISIBILITY_EVENT = 'awsui-evaluate-component-visibility';
|
|
10
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-performance-marks/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,mCAAmC,GAAG,qCAAqC,CAAC;AAElF;;;;;GAKG;AACH,MAAM,8BAA8B,GAAG,GAAG,EAAE;IAC1C,MAAM,CAAC,2BAA2B,EAAE,8BAA8B,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,iCAAiC,GAAG,GAAG,EAAE;YAC7C,8BAA8B,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QAChD,CAAC,CAAC;QAEF,QAAQ,CAAC,gBAAgB,CAAC,mCAAmC,EAAE,iCAAiC,CAAC,CAAC;QAElG,OAAO,GAAG,EAAE;YACV,QAAQ,CAAC,mBAAmB,CAAC,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EAAE,CAAC,CAAC;IAEP,iBAAiB,CAAC,GAAG,EAAE;QACrB,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,SAAS,EAAE;YAClD,OAAO;SACR;QACD,MAAM,cAAc,GAClB,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC;YAClC,UAAU,CAAC,OAAO,CAAC,YAAY,GAAG,CAAC;YACnC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,QAAQ,CAAC;QAE/D,IAAI,CAAC,cAAc,EAAE;YACnB,OAAO;SACR;QAED,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAEpC,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE;YAC5D,WAAW,CAAC,IAAI,CAAC,GAAG,IAAI,SAAS,EAAE;gBACjC,SAAS,EAAE,SAAS;gBACpB,MAAM,kBACJ,MAAM,EAAE,OAAO,EACf,kBAAkB,EAAE,EAAE,EACtB,UAAU,IACP,UAAU,EAAE,CAChB;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC;QAEf,uDAAuD;IACzD,CAAC,EAAE,CAAC,2BAA2B,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC;IAEnD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useState } from 'react';\n\nimport { useRandomId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { useModalContext } from '../../context/modal-context';\nimport { useDOMAttribute } from '../use-dom-attribute';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\nimport { isInViewport } from './is-in-viewport';\n\nconst EVALUATE_COMPONENT_VISIBILITY_EVENT = 'awsui-evaluate-component-visibility';\n\n/**\n * This hook manages a boolean state (`evaluateComponentVisibility`) that toggles\n * whenever a custom DOM event (`EVALUATE_COMPONENT_VISIBILITY_EVENT`) is triggered.\n *\n * @returns\n */\nconst useEvaluateComponentVisibility = () => {\n const [evaluateComponentVisibility, setEvaluateComponentVisibility] = useState(false);\n\n useEffect(() => {\n const handleEvaluateComponentVisibility = () => {\n setEvaluateComponentVisibility(prev => !prev);\n };\n\n document.addEventListener(EVALUATE_COMPONENT_VISIBILITY_EVENT, handleEvaluateComponentVisibility);\n\n return () => {\n document.removeEventListener(EVALUATE_COMPONENT_VISIBILITY_EVENT, handleEvaluateComponentVisibility);\n };\n }, []);\n\n return evaluateComponentVisibility;\n};\n\n/**\n * This function returns an object that needs to be spread onto the same\n * element as the `elementRef`, so that the data attribute is applied\n * correctly.\n */\nexport function usePerformanceMarks(\n name: string,\n enabled: () => boolean,\n elementRef: React.RefObject<HTMLElement>,\n getDetails: () => Record<string, string | boolean | number | undefined>,\n dependencies: React.DependencyList\n) {\n const id = useRandomId();\n const { isInModal } = useModalContext();\n const attributes = useDOMAttribute(elementRef, 'data-analytics-performance-mark', id);\n const evaluateComponentVisibility = useEvaluateComponentVisibility();\n\n useEffect(() => {\n if (!enabled() || !elementRef.current || isInModal) {\n return;\n }\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const timestamp = performance.now();\n\n const cleanup = isInViewport(elementRef.current, inViewport => {\n performance.mark(`${name}Rendered`, {\n startTime: timestamp,\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n inViewport,\n ...getDetails(),\n },\n });\n });\n\n return cleanup;\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffectOnUpdate(() => {\n if (!enabled() || !elementRef.current || isInModal) {\n return;\n }\n const elementVisible =\n elementRef.current.offsetWidth > 0 &&\n elementRef.current.offsetHeight > 0 &&\n getComputedStyle(elementRef.current).visibility !== 'hidden';\n\n if (!elementVisible) {\n return;\n }\n\n const timestamp = performance.now();\n\n const cleanup = isInViewport(elementRef.current, inViewport => {\n performance.mark(`${name}Updated`, {\n startTime: timestamp,\n detail: {\n source: 'awsui',\n instanceIdentifier: id,\n inViewport,\n ...getDetails(),\n },\n });\n });\n return cleanup;\n\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [evaluateComponentVisibility, ...dependencies]);\n\n return attributes;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAWxD,MAAM,WAAW,+BAA+B,CAAC,CAAC;IAChD,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,SAAS,CAAC,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,yBAAyB,EAAE,MAAM,UAAU,CAAC;IAC5C,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,EAC5C,UAAU,EACV,KAAK,EACL,SAAS,EACT,kBAAkB,EAClB,sBAAsB,EACtB,yBAAyB,EACzB,OAAe,EACf,mBAAmB,GACpB,EAAE,+BAA+B,CAAC,CAAC,CAAC;;;;8BA2EP,MAAM;EAEnC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
|
+
import { useRandomId } from '@cloudscape-design/component-toolkit/internal';
|
|
4
5
|
import { ComponentMetrics, PerformanceMetrics } from '../../analytics';
|
|
5
6
|
import { useFunnel } from '../../analytics/hooks/use-funnel';
|
|
6
7
|
import { useDebounceCallback } from '../use-debounce-callback';
|
|
7
8
|
import { useDOMAttribute } from '../use-dom-attribute';
|
|
8
9
|
import { useEffectOnUpdate } from '../use-effect-on-update';
|
|
9
|
-
import { useRandomId } from '../use-unique-id';
|
|
10
10
|
/*
|
|
11
11
|
If the last user interaction is more than this time ago, it is not considered
|
|
12
12
|
to be the cause of the current loading state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/internal/hooks/use-table-interaction-metrics/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAE5E,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBA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AC;YAChC,iBAAiB;YACjB,aAAa,EAAE,OAAO;YACtB,UAAU,EAAE,MAAA,MAAA,cAAc,CAAC,OAAO,0CAAE,IAAI,mCAAI,EAAE;YAC9C,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE;SACrE,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,iBAAiB,CAAC,GAAG,EAAE;QACrB,IAAI,UAAU,IAAI,OAAO,EAAE;YACzB,OAAO;SACR;QAED,gBAAgB,EAAE,CAAC;QACnB,4EAA4E;IAC9E,CAAC,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEtE,OAAO;QACL,0BAA0B;QAC1B,iBAAiB,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,CAAC;KACvG,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { useEffect, useRef } from 'react';\n\nimport { useRandomId } from '@cloudscape-design/component-toolkit/internal';\n\nimport { ComponentMetrics, PerformanceMetrics } from '../../analytics';\nimport { useFunnel } from '../../analytics/hooks/use-funnel';\nimport { JSONObject } from '../../analytics/interfaces';\nimport { useDebounceCallback } from '../use-debounce-callback';\nimport { useDOMAttribute } from '../use-dom-attribute';\nimport { useEffectOnUpdate } from '../use-effect-on-update';\n\n/*\nIf the last user interaction is more than this time ago, it is not considered\nto be the cause of the current loading state.\n*/\nconst USER_ACTION_TIME_LIMIT = 1_000;\n\nexport interface UseTableInteractionMetricsProps<T> {\n elementRef: React.RefObject<HTMLElement>;\n instanceIdentifier: string | undefined;\n loading: boolean | undefined;\n items: readonly T[];\n itemCount: number;\n getComponentIdentifier: () => string | undefined;\n getComponentConfiguration: () => JSONObject;\n interactionMetadata: () => string;\n}\n\nexport function useTableInteractionMetrics<T>({\n elementRef,\n items,\n itemCount,\n instanceIdentifier,\n getComponentIdentifier,\n getComponentConfiguration,\n loading = false,\n interactionMetadata,\n}: UseTableInteractionMetricsProps<T>) {\n const taskInteractionId = useRandomId();\n const tableInteractionAttributes = useDOMAttribute(\n elementRef,\n 'data-analytics-task-interaction-id',\n taskInteractionId\n );\n const { isInFunnel } = useFunnel();\n const lastUserAction = useRef<{ name: string; time: number } | null>(null);\n const capturedUserAction = useRef<string | null>(null);\n const loadingStartTime = useRef<number | null>(null);\n\n const metadata = useRef({ itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata });\n metadata.current = { itemCount, getComponentIdentifier, getComponentConfiguration, interactionMetadata };\n\n useEffect(() => {\n if (isInFunnel) {\n return;\n }\n\n ComponentMetrics.componentMounted({\n taskInteractionId,\n componentName: 'table',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n }, [taskInteractionId, isInFunnel]);\n\n useEffect(() => {\n if (loading) {\n loadingStartTime.current = performance.now();\n\n if (lastUserAction.current && lastUserAction.current.time > performance.now() - USER_ACTION_TIME_LIMIT) {\n capturedUserAction.current = lastUserAction.current.name;\n } else {\n capturedUserAction.current = null;\n }\n }\n }, [loading]);\n\n useEffectOnUpdate(() => {\n if (!loading && loadingStartTime.current !== null) {\n const loadingDuration = performance.now() - loadingStartTime.current;\n loadingStartTime.current = null;\n\n PerformanceMetrics.tableInteraction({\n userAction: capturedUserAction.current ?? '',\n interactionTime: Math.round(loadingDuration),\n interactionMetadata: metadata.current.interactionMetadata(),\n componentIdentifier: metadata.current.getComponentIdentifier(),\n instanceIdentifier,\n noOfResourcesInTable: metadata.current.itemCount,\n });\n }\n }, [instanceIdentifier, loading, taskInteractionId, isInFunnel]);\n\n const debouncedUpdated = useDebounceCallback(() => {\n ComponentMetrics.componentUpdated({\n taskInteractionId,\n componentName: 'table',\n actionType: lastUserAction.current?.name ?? '',\n componentConfiguration: metadata.current.getComponentConfiguration(),\n });\n });\n\n useEffectOnUpdate(() => {\n if (isInFunnel || loading) {\n return;\n }\n\n debouncedUpdated();\n // Note: items used as a dependency here to trigger updates as a side effect\n }, [taskInteractionId, isInFunnel, loading, items, debouncedUpdated]);\n\n return {\n tableInteractionAttributes,\n setLastUserAction: (name: string) => void (lastUserAction.current = { name, time: performance.now() }),\n };\n}\n"]}
|
package/internal/manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"use-discovered-content.d.ts","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAI3D,OAAO,EACL,4BAA4B,EAE5B,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAG5C,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,4BAA4B;UAMhG,MAAM;YACJ,MAAM,SAAS;cACb,MAAM,SAAS;;;;;;;;;EAiG5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { useUniqueId } from '
|
|
4
|
+
import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
5
5
|
import { reportRuntimeApiWarning } from './metrics';
|
|
6
6
|
export function createUseDiscoveredContent(componentName, controller) {
|
|
7
7
|
return function useDiscoveredContent({ type, header, children, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-discovered-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"use-discovered-content.js","sourceRoot":"","sources":["../../../../../src/internal/plugins/helpers/use-discovered-content.tsx"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,+CAA+C,CAAC;AAO5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,UAAU,0BAA0B,CAAC,aAAqB,EAAE,UAAwC;IACxG,OAAO,SAAS,oBAAoB,CAAC,EACnC,IAAI,EACJ,MAAM,EACN,QAAQ,GAKT;QACC,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,aAAa,qBAAqB,CAAC,CAAC;QACtE,MAAM,SAAS,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC/C,MAAM,UAAU,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAChD,MAAM,oBAAoB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC1D,MAAM,qBAAqB,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;QAC3D,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAC,GAAG,EAAE,CACtD,UAAU,CAAC,YAAY,CAAC;YACtB,UAAU;YACV,IAAI;YACJ,MAAM;YACN,OAAO,EAAE,QAAQ;SAClB,CAAC,CACH,CAAC;QACF,MAAM,CAAC,qBAAqB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAkB,UAAU,CAAC,CAAC;QACjG,MAAM,CAAC,sBAAsB,EAAE,0BAA0B,CAAC,GAAG,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ACxC;oBACH,CAAC;oBACD,cAAc,CAAC,QAA0C;wBACvD,IAAI,YAAY,CAAC,gBAAgB,CAAC,EAAE;4BAClC,QAAQ,CAAC,qBAAqB,CAAC,OAAQ,CAAC,CAAC;4BACzC,0BAA0B,CAAC,UAAU,CAAC,CAAC;yBACxC;oBACH,CAAC;iBACF,CAAC,CAAC;gBAEH,OAAO,GAAG,EAAE;;oBACV,MAAA,eAAe,CAAC,OAAO,0CAAE,OAAO,CAAC;wBAC/B,0BAA0B,EAAE,oBAAoB,CAAC,OAAQ;wBACzD,2BAA2B,EAAE,qBAAqB,CAAC,OAAQ;qBAC5D,CAAC,CAAC;oBACH,OAAO,GAAG,KAAK,CAAC;gBAClB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAEvB,SAAS,CAAC,GAAG,EAAE;;YACb,MAAA,eAAe,CAAC,OAAO,0CAAE,MAAM,EAAE,CAAC;QACpC,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE7B,OAAO;YACL,aAAa;YACb,qBAAqB;YACrB,sBAAsB;YACtB,SAAS,EAAE,SAAsC;YACjD,oBAAoB,EAAE,oBAAiD;YACvE,UAAU,EAAE,UAAuC;YACnD,qBAAqB,EAAE,qBAAkD;SAC1E,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useRef, useState } from 'react';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport {\n AlertFlashContentApiInternal,\n AlertFlashContentResult,\n ReplacementType,\n} from '../controllers/alert-flash-content';\nimport { reportRuntimeApiWarning } from './metrics';\n\nexport function createUseDiscoveredContent(componentName: string, controller: AlertFlashContentApiInternal) {\n return function useDiscoveredContent({\n type,\n header,\n children,\n }: {\n type: string;\n header: React.ReactNode;\n children: React.ReactNode;\n }) {\n const instanceId = useUniqueId(`${componentName}-discovered-content`);\n const headerRef = useRef<HTMLDivElement>(null);\n const contentRef = useRef<HTMLDivElement>(null);\n const replacementHeaderRef = useRef<HTMLDivElement>(null);\n const replacementContentRef = useRef<HTMLDivElement>(null);\n const [initialHidden, setInitialHidden] = useState(() =>\n controller.initialCheck({\n instanceId,\n type,\n header,\n content: children,\n })\n );\n const [headerReplacementType, setFoundHeaderReplacement] = useState<ReplacementType>('original');\n const [contentReplacementType, setFoundContentReplacement] = useState<ReplacementType>('original');\n const mountedProvider = useRef<AlertFlashContentResult | undefined>();\n\n useEffect(() => {\n const context = { instanceId, type, headerRef, contentRef };\n\n setInitialHidden(false);\n\n return controller.onContentRegistered(provider => {\n let mounted = true;\n\n function checkMounted(methodName: string) {\n if (!mounted) {\n reportRuntimeApiWarning(\n `${componentName}-content-replacer`,\n `\"${methodName}\" called after component unmounted`\n );\n return false;\n }\n return true;\n }\n\n mountedProvider.current = provider.runReplacer(context, {\n hideHeader() {\n if (checkMounted('hideHeader')) {\n setFoundHeaderReplacement('remove');\n }\n },\n restoreHeader() {\n if (checkMounted('restoreHeader')) {\n setFoundHeaderReplacement('original');\n }\n },\n replaceHeader(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceHeader')) {\n replacer(replacementHeaderRef.current!);\n setFoundHeaderReplacement('replaced');\n }\n },\n hideContent() {\n if (checkMounted('hideContent')) {\n setFoundContentReplacement('remove');\n }\n },\n restoreContent() {\n if (checkMounted('restoreContent')) {\n setFoundContentReplacement('original');\n }\n },\n replaceContent(replacer: (container: HTMLElement) => void) {\n if (checkMounted('replaceContent')) {\n replacer(replacementContentRef.current!);\n setFoundContentReplacement('replaced');\n }\n },\n });\n\n return () => {\n mountedProvider.current?.unmount({\n replacementHeaderContainer: replacementHeaderRef.current!,\n replacementContentContainer: replacementContentRef.current!,\n });\n mounted = false;\n };\n });\n }, [instanceId, type]);\n\n useEffect(() => {\n mountedProvider.current?.update();\n }, [type, header, children]);\n\n return {\n initialHidden,\n headerReplacementType,\n contentReplacementType,\n headerRef: headerRef as React.Ref<HTMLDivElement>,\n replacementHeaderRef: replacementHeaderRef as React.Ref<HTMLDivElement>,\n contentRef: contentRef as React.Ref<HTMLDivElement>,\n replacementContentRef: replacementContentRef as React.Ref<HTMLDivElement>,\n };\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA6BlD,QAAA,MAAM,qBAAqB,2IAoE1B,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -3,11 +3,11 @@ import { __rest } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
+
import { useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
6
7
|
import Box from '../box/internal';
|
|
7
8
|
import ColumnLayout from '../column-layout/internal';
|
|
8
9
|
import { InfoLinkLabelContext } from '../internal/context/info-link-label-context';
|
|
9
10
|
import { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';
|
|
10
|
-
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
11
11
|
import styles from './styles.css.js';
|
|
12
12
|
const InternalKeyValuePair = ({ label, info, value, id }) => {
|
|
13
13
|
const kvPairId = useUniqueId('kv-pair-');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/key-value-pairs/internal.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AAO,EAAC,GAAG,IAC1B,IAAI,CAAC,KAAK,CACP,CACP,EAEH,KAAK,EACH,4BAAI,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,IAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CACnC,6BAAK,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC;4BACvD,oBAAC,oBAAoB,oBAAK,IAAI,EAAI,CAC9B,CACP,CAAC,CACC,GAEP,CACH,CAAC;iBACH;gBAED,OAAO,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,KAAK,IAAM,IAAI,EAAI,CAAC;YACxD,CAAC,CAAC,CACW,CACX,CAC6B,CACtC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,qBAAqB,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React from 'react';\nimport clsx from 'clsx';\n\nimport { useUniqueId } from '@cloudscape-design/component-toolkit/internal';\n\nimport Box from '../box/internal';\nimport ColumnLayout from '../column-layout/internal';\nimport { InfoLinkLabelContext } from '../internal/context/info-link-label-context';\nimport { LinkDefaultVariantContext } from '../internal/context/link-default-variant-context';\nimport { KeyValuePairsProps } from './interfaces';\n\nimport styles from './styles.css.js';\n\nconst InternalKeyValuePair = ({ label, info, value, id }: KeyValuePairsProps.Pair) => {\n const kvPairId = useUniqueId('kv-pair-');\n\n return (\n <>\n <dt className={styles.term}>\n <label className={styles['key-label']} id={id || kvPairId}>\n {label}\n </label>\n <InfoLinkLabelContext.Provider value={id || kvPairId}>\n {info && <span className={styles.info}>{info}</span>}\n </InfoLinkLabelContext.Provider>\n </dt>\n <dd className={styles.detail}>{value}</dd>\n </>\n );\n};\n\nconst InternalKeyValuePairGroup = ({ label, value }: { label?: React.ReactNode; value: React.ReactNode }) => (\n <>\n {label && <dt className={styles['group-title']}>{label}</dt>}\n <dd className={styles.detail}>{value}</dd>\n </>\n);\n\nconst InternalKeyValuePairs = React.forwardRef(\n (\n {\n columns,\n items,\n className,\n ariaLabel,\n ariaLabelledby,\n minColumnWidth,\n ...rest\n }: KeyValuePairsProps & Required<Pick<KeyValuePairsProps, 'columns'>>,\n ref: React.Ref<HTMLDivElement>\n ) => {\n return (\n <LinkDefaultVariantContext.Provider value={{ defaultVariant: 'primary' }}>\n <div\n {...rest}\n className={clsx(styles['key-value-pairs'], className)}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledby}\n ref={ref}\n >\n {/*\n minColumnWidth={150} is set to use FlexibleColumnLayout which has only 1 nested div wrapper for column items,\n otherwise GridColumnLayout will be used, which has 2 nested div, therefore it is not a11y compatible for dl -> dt/dd relationship\n */}\n <ColumnLayout\n __tagOverride=\"dl\"\n columns={Math.min(columns, 4)}\n variant=\"text-grid\"\n minColumnWidth={minColumnWidth}\n >\n {items.map((pair, index) => {\n if (pair.type === 'group') {\n return (\n /* InternalKeyValuePairGroup tells react to treat the dt-dd pair as an individual layout item.\n * Otherwise, without this component, they will be rendered as a list, which ruins the html structure.\n * InternalKeyValuePairGroup is not wrapped by div tag, because it ruins a11y compatibility for dl -> dt/dd\n * */\n <InternalKeyValuePairGroup\n key={index}\n label={\n pair.title && (\n <Box variant=\"h3\" padding=\"n\">\n {pair.title}\n </Box>\n )\n }\n value={\n <dl className={styles['group-list']}>\n {pair.items.map((item, itemIndex) => (\n <div key={itemIndex} className={styles['group-list-item']}>\n <InternalKeyValuePair {...item} />\n </div>\n ))}\n </dl>\n }\n />\n );\n }\n\n return <InternalKeyValuePair key={index} {...pair} />;\n })}\n </ColumnLayout>\n </div>\n </LinkDefaultVariantContext.Provider>\n );\n }\n);\n\nexport default InternalKeyValuePairs;\n"]}
|
package/link/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/link/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAqBlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/link/internal.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAqBlD,OAAO,EAAE,0BAA0B,EAAE,MAAM,sCAAsC,CAAC;AAIlF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,QAAA,MAAM,YAAY;cAHJ,SAAS,CAAC,SAAS,CAAC,GAAG,gBAAgB,GAAG,MAAM,GAAG,UAAU;uCA4M1E,CAAC;AAqBF,eAAe,YAAY,CAAC"}
|
package/link/internal.js
CHANGED
|
@@ -3,7 +3,7 @@ import { __rest } from "tslib";
|
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React, { useContext, useRef } from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { useMergeRefs } from '@cloudscape-design/component-toolkit/internal';
|
|
6
|
+
import { useMergeRefs, useUniqueId } from '@cloudscape-design/component-toolkit/internal';
|
|
7
7
|
import { useInternalI18n } from '../i18n/context';
|
|
8
8
|
import InternalIcon from '../icon/internal';
|
|
9
9
|
import { FunnelMetrics } from '../internal/analytics';
|
|
@@ -15,7 +15,6 @@ import { LinkDefaultVariantContext } from '../internal/context/link-default-vari
|
|
|
15
15
|
import { useSingleTabStopNavigation } from '../internal/context/single-tab-stop-navigation-context';
|
|
16
16
|
import { fireCancelableEvent, fireNonCancelableEvent, isPlainLeftClick } from '../internal/events';
|
|
17
17
|
import useForwardFocus from '../internal/hooks/forward-focus';
|
|
18
|
-
import { useUniqueId } from '../internal/hooks/use-unique-id';
|
|
19
18
|
import { useVisualRefresh } from '../internal/hooks/use-visual-mode';
|
|
20
19
|
import { KeyCode } from '../internal/keycode';
|
|
21
20
|
import { checkSafeUrl } from '../internal/utils/check-safe-url';
|