@cloudscape-design/components 3.0.220 → 3.0.222
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 +4 -4
- package/alert/index.js.map +1 -1
- package/alert/internal.js +14 -15
- package/alert/internal.js.map +1 -1
- package/annotation-context/annotation/annotation-icon.js +1 -2
- package/annotation-context/annotation/annotation-icon.js.map +1 -1
- package/annotation-context/annotation/annotation-popover.js +6 -7
- package/annotation-context/annotation/annotation-popover.js.map +1 -1
- package/annotation-context/annotation/annotation-trigger.js +4 -6
- package/annotation-context/annotation/annotation-trigger.js.map +1 -1
- package/annotation-context/annotation/closed-annotation.js +4 -5
- package/annotation-context/annotation/closed-annotation.js.map +1 -1
- package/annotation-context/annotation/open-annotation.js +2 -3
- package/annotation-context/annotation/open-annotation.js.map +1 -1
- package/annotation-context/context.js +7 -7
- package/annotation-context/context.js.map +1 -1
- package/annotation-context/index.js +62 -69
- package/annotation-context/index.js.map +1 -1
- package/app-layout/content-wrapper/index.js +2 -3
- package/app-layout/content-wrapper/index.js.map +1 -1
- package/app-layout/defaults.js +13 -14
- package/app-layout/defaults.js.map +1 -1
- package/app-layout/drawer.js +16 -18
- package/app-layout/drawer.js.map +1 -1
- package/app-layout/index.js +111 -113
- package/app-layout/index.js.map +1 -1
- package/app-layout/mobile-toolbar/index.js +7 -9
- package/app-layout/mobile-toolbar/index.js.map +1 -1
- package/app-layout/navigation-panel.js +5 -8
- package/app-layout/navigation-panel.js.map +1 -1
- package/app-layout/notifications/index.js +2 -2
- package/app-layout/notifications/index.js.map +1 -1
- package/app-layout/toggles/index.js +14 -22
- package/app-layout/toggles/index.js.map +1 -1
- package/app-layout/tools-and-split-panel.js +6 -9
- package/app-layout/tools-and-split-panel.js.map +1 -1
- package/app-layout/utils/use-content-height.js +14 -15
- package/app-layout/utils/use-content-height.js.map +1 -1
- package/app-layout/utils/use-content-width.js +8 -8
- package/app-layout/utils/use-content-width.js.map +1 -1
- package/app-layout/utils/use-focus-control.js +7 -8
- package/app-layout/utils/use-focus-control.js.map +1 -1
- package/app-layout/utils/use-observed-element.js +3 -3
- package/app-layout/utils/use-observed-element.js.map +1 -1
- package/app-layout/utils/use-window-width.js +4 -4
- package/app-layout/utils/use-window-width.js.map +1 -1
- package/app-layout/visual-refresh/app-bar.js +19 -20
- package/app-layout/visual-refresh/app-bar.js.map +1 -1
- package/app-layout/visual-refresh/background.js +9 -10
- package/app-layout/visual-refresh/background.js.map +1 -1
- package/app-layout/visual-refresh/context.js +101 -59
- package/app-layout/visual-refresh/context.js.map +1 -1
- package/app-layout/visual-refresh/header.js +6 -7
- package/app-layout/visual-refresh/header.js.map +1 -1
- package/app-layout/visual-refresh/index.js +3 -4
- package/app-layout/visual-refresh/index.js.map +1 -1
- package/app-layout/visual-refresh/layout.js +18 -21
- package/app-layout/visual-refresh/layout.js.map +1 -1
- package/app-layout/visual-refresh/main.js +17 -18
- package/app-layout/visual-refresh/main.js.map +1 -1
- package/app-layout/visual-refresh/navigation.js +22 -24
- package/app-layout/visual-refresh/navigation.js.map +1 -1
- package/app-layout/visual-refresh/notifications.js +6 -7
- package/app-layout/visual-refresh/notifications.js.map +1 -1
- package/app-layout/visual-refresh/split-panel.js +36 -43
- package/app-layout/visual-refresh/split-panel.js.map +1 -1
- package/app-layout/visual-refresh/tools.js +32 -34
- package/app-layout/visual-refresh/tools.js.map +1 -1
- package/app-layout/visual-refresh/trigger-button.js +5 -8
- package/app-layout/visual-refresh/trigger-button.js.map +1 -1
- package/area-chart/chart-container.js +18 -19
- package/area-chart/chart-container.js.map +1 -1
- package/area-chart/elements/area-chart-filter.js +7 -8
- package/area-chart/elements/area-chart-filter.js.map +1 -1
- package/area-chart/elements/area-chart-legend.js +6 -9
- package/area-chart/elements/area-chart-legend.js.map +1 -1
- package/area-chart/elements/area-series.js +12 -13
- package/area-chart/elements/area-series.js.map +1 -1
- package/area-chart/elements/chart-popover.js +4 -6
- package/area-chart/elements/chart-popover.js.map +1 -1
- package/area-chart/elements/data-series.js +14 -17
- package/area-chart/elements/data-series.js.map +1 -1
- package/area-chart/elements/highlighted-point.js +6 -7
- package/area-chart/elements/highlighted-point.js.map +1 -1
- package/area-chart/elements/threshold-series.js +5 -7
- package/area-chart/elements/threshold-series.js.map +1 -1
- package/area-chart/elements/use-highlight-details.js +28 -30
- package/area-chart/elements/use-highlight-details.js.map +1 -1
- package/area-chart/elements/vertical-marker.js +6 -7
- package/area-chart/elements/vertical-marker.js.map +1 -1
- package/area-chart/index.js +4 -4
- package/area-chart/index.js.map +1 -1
- package/area-chart/internal.js +40 -41
- package/area-chart/internal.js.map +1 -1
- package/area-chart/model/async-store.js +23 -30
- package/area-chart/model/async-store.js.map +1 -1
- package/area-chart/model/compute-chart-props.js +11 -12
- package/area-chart/model/compute-chart-props.js.map +1 -1
- package/area-chart/model/create-series-decorator.js +11 -13
- package/area-chart/model/create-series-decorator.js.map +1 -1
- package/area-chart/model/interactions-store.js +47 -54
- package/area-chart/model/interactions-store.js.map +1 -1
- package/area-chart/model/use-chart-model.js +85 -89
- package/area-chart/model/use-chart-model.js.map +1 -1
- package/area-chart/model/use-filter-props.js +6 -6
- package/area-chart/model/use-filter-props.js.map +1 -1
- package/area-chart/model/use-highlight-props.js +6 -6
- package/area-chart/model/use-highlight-props.js.map +1 -1
- package/area-chart/model/utils.js +46 -59
- package/area-chart/model/utils.js.map +1 -1
- package/attribute-editor/additional-info.js +2 -5
- package/attribute-editor/additional-info.js.map +1 -1
- package/attribute-editor/index.js +5 -5
- package/attribute-editor/index.js.map +1 -1
- package/attribute-editor/internal.js +20 -20
- package/attribute-editor/internal.js.map +1 -1
- package/attribute-editor/row.js +17 -25
- package/attribute-editor/row.js.map +1 -1
- package/autosuggest/autosuggest-option.js +12 -12
- package/autosuggest/autosuggest-option.js.map +1 -1
- package/autosuggest/index.js +6 -6
- package/autosuggest/index.js.map +1 -1
- package/autosuggest/internal.js +39 -39
- package/autosuggest/internal.js.map +1 -1
- package/autosuggest/load-more-controller.js +10 -14
- package/autosuggest/load-more-controller.js.map +1 -1
- package/autosuggest/options-controller.js +31 -32
- package/autosuggest/options-controller.js.map +1 -1
- package/autosuggest/options-list.js +12 -13
- package/autosuggest/options-list.js.map +1 -1
- package/autosuggest/plain-list.js +15 -17
- package/autosuggest/plain-list.js.map +1 -1
- package/autosuggest/utils/utils.js +12 -12
- package/autosuggest/utils/utils.js.map +1 -1
- package/autosuggest/virtual-list.js +14 -16
- package/autosuggest/virtual-list.js.map +1 -1
- package/badge/index.js +6 -6
- package/badge/index.js.map +1 -1
- package/bar-chart/index.js +6 -6
- package/bar-chart/index.js.map +1 -1
- package/box/index.js +4 -4
- package/box/index.js.map +1 -1
- package/box/internal.js +12 -12
- package/box/internal.js.map +1 -1
- package/breadcrumb-group/index.js +4 -4
- package/breadcrumb-group/index.js.map +1 -1
- package/breadcrumb-group/internal.js +24 -25
- package/breadcrumb-group/internal.js.map +1 -1
- package/breadcrumb-group/item/item.js +32 -34
- package/breadcrumb-group/item/item.js.map +1 -1
- package/button/icon-helper.js +6 -6
- package/button/icon-helper.js.map +1 -1
- package/button/index.js +6 -6
- package/button/index.js.map +1 -1
- package/button/internal.js +32 -33
- package/button/internal.js.map +1 -1
- package/button-dropdown/category-elements/category-element.js +3 -5
- package/button-dropdown/category-elements/category-element.js.map +1 -1
- package/button-dropdown/category-elements/expandable-category-element.js +23 -26
- package/button-dropdown/category-elements/expandable-category-element.js.map +1 -1
- package/button-dropdown/category-elements/mobile-expandable-category-element.js +27 -30
- package/button-dropdown/category-elements/mobile-expandable-category-element.js.map +1 -1
- package/button-dropdown/index.js +6 -6
- package/button-dropdown/index.js.map +1 -1
- package/button-dropdown/internal.js +28 -29
- package/button-dropdown/internal.js.map +1 -1
- package/button-dropdown/item-element/index.js +30 -36
- package/button-dropdown/item-element/index.js.map +1 -1
- package/button-dropdown/items-list.js +3 -4
- package/button-dropdown/items-list.js.map +1 -1
- package/button-dropdown/mobile-expandable-group/mobile-expandable-group.js +2 -4
- package/button-dropdown/mobile-expandable-group/mobile-expandable-group.js.map +1 -1
- package/button-dropdown/tooltip.js +22 -24
- package/button-dropdown/tooltip.js.map +1 -1
- package/button-dropdown/utils/create-items-tree.js +21 -23
- package/button-dropdown/utils/create-items-tree.js.map +1 -1
- package/button-dropdown/utils/menu-item.js +6 -9
- package/button-dropdown/utils/menu-item.js.map +1 -1
- package/button-dropdown/utils/move-highlight.js +3 -4
- package/button-dropdown/utils/move-highlight.js.map +1 -1
- package/button-dropdown/utils/use-button-dropdown.js +31 -33
- package/button-dropdown/utils/use-button-dropdown.js.map +1 -1
- package/button-dropdown/utils/use-hidden-description.js +3 -3
- package/button-dropdown/utils/use-hidden-description.js.map +1 -1
- package/button-dropdown/utils/use-highlighted-menu.js +40 -42
- package/button-dropdown/utils/use-highlighted-menu.js.map +1 -1
- package/button-dropdown/utils/utils.js +5 -9
- package/button-dropdown/utils/utils.js.map +1 -1
- package/calendar/grid/index.js +25 -28
- package/calendar/grid/index.js.map +1 -1
- package/calendar/header/header-button.js +4 -6
- package/calendar/header/header-button.js.map +1 -1
- package/calendar/header/index.js +1 -2
- package/calendar/header/index.js.map +1 -1
- package/calendar/index.js +4 -4
- package/calendar/index.js.map +1 -1
- package/calendar/internal.js +27 -27
- package/calendar/internal.js.map +1 -1
- package/calendar/utils/intl.js +12 -13
- package/calendar/utils/intl.js.map +1 -1
- package/calendar/utils/navigation.js +3 -3
- package/calendar/utils/navigation.js.map +1 -1
- package/cards/cards-layout-helper.js +12 -12
- package/cards/cards-layout-helper.js.map +1 -1
- package/cards/index.js +53 -63
- package/cards/index.js.map +1 -1
- package/checkbox/index.js +4 -4
- package/checkbox/index.js.map +1 -1
- package/checkbox/internal.d.ts +1 -0
- package/checkbox/internal.d.ts.map +1 -1
- package/checkbox/internal.js +9 -9
- package/checkbox/internal.js.map +1 -1
- package/code-editor/ace-modes.js +1 -1
- package/code-editor/ace-modes.js.map +1 -1
- package/code-editor/ace-themes.js +2 -2
- package/code-editor/ace-themes.js.map +1 -1
- package/code-editor/error-screen.js +3 -4
- package/code-editor/error-screen.js.map +1 -1
- package/code-editor/index.js +61 -65
- package/code-editor/index.js.map +1 -1
- package/code-editor/listeners.js +5 -5
- package/code-editor/listeners.js.map +1 -1
- package/code-editor/loading-screen.js +2 -2
- package/code-editor/loading-screen.js.map +1 -1
- package/code-editor/pane.js +21 -25
- package/code-editor/pane.js.map +1 -1
- package/code-editor/preferences-modal.js +12 -13
- package/code-editor/preferences-modal.js.map +1 -1
- package/code-editor/resizable-box/index.js +14 -15
- package/code-editor/resizable-box/index.js.map +1 -1
- package/code-editor/setup-editor.js +20 -20
- package/code-editor/setup-editor.js.map +1 -1
- package/code-editor/status-bar.js +19 -22
- package/code-editor/status-bar.js.map +1 -1
- package/code-editor/tab-button.js +7 -10
- package/code-editor/tab-button.js.map +1 -1
- package/code-editor/util.js +6 -6
- package/code-editor/util.js.map +1 -1
- package/collection-preferences/index.js +21 -23
- package/collection-preferences/index.js.map +1 -1
- package/collection-preferences/utils.js +25 -57
- package/collection-preferences/utils.js.map +1 -1
- package/collection-preferences/visible-content.js +23 -27
- package/collection-preferences/visible-content.js.map +1 -1
- package/column-layout/index.js +6 -6
- package/column-layout/index.js.map +1 -1
- package/column-layout/internal.js +20 -21
- package/column-layout/internal.js.map +1 -1
- package/column-layout/util.js +2 -2
- package/column-layout/util.js.map +1 -1
- package/container/index.js +5 -5
- package/container/index.js.map +1 -1
- package/container/internal.js +30 -31
- package/container/internal.js.map +1 -1
- package/container/use-sticky-header.js +25 -25
- package/container/use-sticky-header.js.map +1 -1
- package/content-layout/index.js +2 -3
- package/content-layout/index.js.map +1 -1
- package/content-layout/internal.js +15 -16
- package/content-layout/internal.js.map +1 -1
- package/date-input/index.js +3 -4
- package/date-input/index.js.map +1 -1
- package/date-input/internal.js +8 -8
- package/date-input/internal.js.map +1 -1
- package/date-picker/index.js +28 -28
- package/date-picker/index.js.map +1 -1
- package/date-range-picker/calendar/grids/grid.js +54 -57
- package/date-range-picker/calendar/grids/grid.js.map +1 -1
- package/date-range-picker/calendar/grids/index.js +27 -28
- package/date-range-picker/calendar/grids/index.js.map +1 -1
- package/date-range-picker/calendar/header/header-button.js +4 -6
- package/date-range-picker/calendar/header/header-button.js.map +1 -1
- package/date-range-picker/calendar/header/index.js +6 -7
- package/date-range-picker/calendar/header/index.js.map +1 -1
- package/date-range-picker/calendar/index.js +40 -45
- package/date-range-picker/calendar/index.js.map +1 -1
- package/date-range-picker/calendar/range-inputs.js +5 -6
- package/date-range-picker/calendar/range-inputs.js.map +1 -1
- package/date-range-picker/calendar/utils.js +2 -2
- package/date-range-picker/calendar/utils.js.map +1 -1
- package/date-range-picker/dropdown.js +29 -34
- package/date-range-picker/dropdown.js.map +1 -1
- package/date-range-picker/index.js +40 -43
- package/date-range-picker/index.js.map +1 -1
- package/date-range-picker/mode-switcher.js +2 -3
- package/date-range-picker/mode-switcher.js.map +1 -1
- package/date-range-picker/relative-range/index.js +36 -40
- package/date-range-picker/relative-range/index.js.map +1 -1
- package/date-range-picker/time-offset.js +5 -5
- package/date-range-picker/time-offset.js.map +1 -1
- package/date-range-picker/utils.js +4 -5
- package/date-range-picker/utils.js.map +1 -1
- package/expandable-section/expandable-section-container.js +5 -5
- package/expandable-section/expandable-section-container.js.map +1 -1
- package/expandable-section/expandable-section-header.js +18 -23
- package/expandable-section/expandable-section-header.js.map +1 -1
- package/expandable-section/index.js +4 -4
- package/expandable-section/index.js.map +1 -1
- package/expandable-section/internal.js +22 -22
- package/expandable-section/internal.js.map +1 -1
- package/flashbar/collapsible-flashbar.js +103 -118
- package/flashbar/collapsible-flashbar.js.map +1 -1
- package/flashbar/common.js +26 -35
- package/flashbar/common.js.map +1 -1
- package/flashbar/constant.js +1 -1
- package/flashbar/constant.js.map +1 -1
- package/flashbar/flash.js +23 -26
- package/flashbar/flash.js.map +1 -1
- package/flashbar/index.js +3 -4
- package/flashbar/index.js.map +1 -1
- package/flashbar/internal/analytics.js +12 -12
- package/flashbar/internal/analytics.js.map +1 -1
- package/flashbar/non-collapsible-flashbar.js +10 -10
- package/flashbar/non-collapsible-flashbar.js.map +1 -1
- package/flashbar/utils.js +25 -27
- package/flashbar/utils.js.map +1 -1
- package/form/index.js +4 -4
- package/form/index.js.map +1 -1
- package/form/internal.js +5 -6
- package/form/internal.js.map +1 -1
- package/form-field/index.js +4 -4
- package/form-field/index.js.map +1 -1
- package/form-field/internal.js +20 -23
- package/form-field/internal.js.map +1 -1
- package/form-field/util.js +9 -10
- package/form-field/util.js.map +1 -1
- package/grid/index.js +6 -6
- package/grid/index.js.map +1 -1
- package/grid/internal.js +14 -15
- package/grid/internal.js.map +1 -1
- package/header/index.js +4 -4
- package/header/index.js.map +1 -1
- package/header/internal.js +15 -15
- package/header/internal.js.map +1 -1
- package/help-panel/index.js +7 -7
- package/help-panel/index.js.map +1 -1
- package/hotspot/index.js +12 -12
- package/hotspot/index.js.map +1 -1
- package/icon/icons.js +1 -1
- package/icon/index.js +4 -4
- package/icon/index.js.map +1 -1
- package/icon/internal.js +18 -18
- package/icon/internal.js.map +1 -1
- package/input/index.js +36 -17
- package/input/index.js.map +1 -1
- package/input/internal.js +30 -25
- package/input/internal.js.map +1 -1
- package/input/utils.js +4 -5
- package/input/utils.js.map +1 -1
- package/internal/animate.js +27 -32
- package/internal/animate.js.map +1 -1
- package/internal/base-component/index.js +2 -2
- package/internal/base-component/index.js.map +1 -1
- package/internal/breakpoints.js +7 -12
- package/internal/breakpoints.js.map +1 -1
- package/internal/components/abstract-switch/index.d.ts +2 -1
- package/internal/components/abstract-switch/index.d.ts.map +1 -1
- package/internal/components/abstract-switch/index.js +19 -19
- package/internal/components/abstract-switch/index.js.map +1 -1
- package/internal/components/abstract-switch/styles.css.js +13 -12
- package/internal/components/abstract-switch/styles.scoped.css +21 -21
- package/internal/components/abstract-switch/styles.selectors.js +13 -12
- package/internal/components/autosuggest-input/index.js +38 -38
- package/internal/components/autosuggest-input/index.js.map +1 -1
- package/internal/components/button-trigger/index.js +7 -7
- package/internal/components/button-trigger/index.js.map +1 -1
- package/internal/components/cartesian-chart/axis-label.js +1 -2
- package/internal/components/cartesian-chart/axis-label.js.map +1 -1
- package/internal/components/cartesian-chart/bottom-labels.js +20 -26
- package/internal/components/cartesian-chart/bottom-labels.js.map +1 -1
- package/internal/components/cartesian-chart/constants.js +5 -5
- package/internal/components/cartesian-chart/constants.js.map +1 -1
- package/internal/components/cartesian-chart/emphasized-baseline.js +4 -5
- package/internal/components/cartesian-chart/emphasized-baseline.js.map +1 -1
- package/internal/components/cartesian-chart/highlighted-point.js +1 -2
- package/internal/components/cartesian-chart/highlighted-point.js.map +1 -1
- package/internal/components/cartesian-chart/label-utils.js +20 -24
- package/internal/components/cartesian-chart/label-utils.js.map +1 -1
- package/internal/components/cartesian-chart/labels-measure.js +6 -7
- package/internal/components/cartesian-chart/labels-measure.js.map +1 -1
- package/internal/components/cartesian-chart/left-labels.js +13 -17
- package/internal/components/cartesian-chart/left-labels.js.map +1 -1
- package/internal/components/cartesian-chart/scales.js +21 -26
- package/internal/components/cartesian-chart/scales.js.map +1 -1
- package/internal/components/cartesian-chart/ticks.js +9 -10
- package/internal/components/cartesian-chart/ticks.js.map +1 -1
- package/internal/components/cartesian-chart/vertical-grid-lines.js +3 -4
- package/internal/components/cartesian-chart/vertical-grid-lines.js.map +1 -1
- package/internal/components/cartesian-chart/vertical-marker.js +3 -4
- package/internal/components/cartesian-chart/vertical-marker.js.map +1 -1
- package/internal/components/chart-filter/index.js +13 -14
- package/internal/components/chart-filter/index.js.map +1 -1
- package/internal/components/chart-legend/index.js +26 -29
- package/internal/components/chart-legend/index.js.map +1 -1
- package/internal/components/chart-plot/application-controller.js +21 -25
- package/internal/components/chart-plot/application-controller.js.map +1 -1
- package/internal/components/chart-plot/focus-outline.js +7 -8
- package/internal/components/chart-plot/focus-outline.js.map +1 -1
- package/internal/components/chart-plot/index.js +33 -34
- package/internal/components/chart-plot/index.js.map +1 -1
- package/internal/components/chart-popover/index.js +11 -12
- package/internal/components/chart-popover/index.js.map +1 -1
- package/internal/components/chart-series-details/index.js +13 -17
- package/internal/components/chart-series-details/index.js.map +1 -1
- package/internal/components/chart-series-marker/index.js +2 -3
- package/internal/components/chart-series-marker/index.js.map +1 -1
- package/internal/components/chart-status-container/index.js +8 -10
- package/internal/components/chart-status-container/index.js.map +1 -1
- package/internal/components/checkbox-icon/index.js +18 -19
- package/internal/components/checkbox-icon/index.js.map +1 -1
- package/internal/components/dark-ribbon/index.js +13 -14
- package/internal/components/dark-ribbon/index.js.map +1 -1
- package/internal/components/dropdown/context.js +4 -5
- package/internal/components/dropdown/context.js.map +1 -1
- package/internal/components/dropdown/dropdown-fit-handler.js +74 -81
- package/internal/components/dropdown/dropdown-fit-handler.js.map +1 -1
- package/internal/components/dropdown/index.js +57 -65
- package/internal/components/dropdown/index.js.map +1 -1
- package/internal/components/dropdown-footer/index.js +2 -6
- package/internal/components/dropdown-footer/index.js.map +1 -1
- package/internal/components/dropdown-status/index.js +5 -7
- package/internal/components/dropdown-status/index.js.map +1 -1
- package/internal/components/filtering-token/index.js +4 -6
- package/internal/components/filtering-token/index.js.map +1 -1
- package/internal/components/focus-lock/index.js +10 -11
- package/internal/components/focus-lock/index.js.map +1 -1
- package/internal/components/focus-lock/utils.js +4 -4
- package/internal/components/focus-lock/utils.js.map +1 -1
- package/internal/components/live-region/index.js +10 -10
- package/internal/components/live-region/index.js.map +1 -1
- package/internal/components/masked-input/index.js +22 -24
- package/internal/components/masked-input/index.js.map +1 -1
- package/internal/components/masked-input/keyboard-handler.js +18 -18
- package/internal/components/masked-input/keyboard-handler.js.map +1 -1
- package/internal/components/masked-input/use-mask.js +24 -28
- package/internal/components/masked-input/use-mask.js.map +1 -1
- package/internal/components/masked-input/utils/keys.js +4 -6
- package/internal/components/masked-input/utils/keys.js.map +1 -1
- package/internal/components/masked-input/utils/mask-format.js +103 -113
- package/internal/components/masked-input/utils/mask-format.js.map +1 -1
- package/internal/components/masked-input/utils/strings.js +1 -4
- package/internal/components/masked-input/utils/strings.js.map +1 -1
- package/internal/components/menu-dropdown/index.js +10 -12
- package/internal/components/menu-dropdown/index.js.map +1 -1
- package/internal/components/option/highlight-match.js +14 -18
- package/internal/components/option/highlight-match.js.map +1 -1
- package/internal/components/option/index.js +13 -13
- package/internal/components/option/index.js.map +1 -1
- package/internal/components/option/option-announcer.js +1 -1
- package/internal/components/option/option-announcer.js.map +1 -1
- package/internal/components/option/option-parts.js +28 -45
- package/internal/components/option/option-parts.js.map +1 -1
- package/internal/components/option/utils/filter-options.js +16 -19
- package/internal/components/option/utils/filter-options.js.map +1 -1
- package/internal/components/option/utils/flatten-options.js +15 -15
- package/internal/components/option/utils/flatten-options.js.map +1 -1
- package/internal/components/option/utils/prepare-options.js +3 -3
- package/internal/components/option/utils/prepare-options.js.map +1 -1
- package/internal/components/options-list/index.js +19 -20
- package/internal/components/options-list/index.js.map +1 -1
- package/internal/components/options-list/utils/test-indexes.js +11 -11
- package/internal/components/options-list/utils/test-indexes.js.map +1 -1
- package/internal/components/options-list/utils/use-highlight-option.js +17 -21
- package/internal/components/options-list/utils/use-highlight-option.js.map +1 -1
- package/internal/components/options-list/utils/use-ids.js +2 -2
- package/internal/components/options-list/utils/use-ids.js.map +1 -1
- package/internal/components/options-list/utils/use-keyboard.js +6 -8
- package/internal/components/options-list/utils/use-keyboard.js.map +1 -1
- package/internal/components/options-list/utils/use-open-state.js +6 -7
- package/internal/components/options-list/utils/use-open-state.js.map +1 -1
- package/internal/components/portal/index.js +5 -6
- package/internal/components/portal/index.js.map +1 -1
- package/internal/components/screenreader-only/index.js +1 -2
- package/internal/components/screenreader-only/index.js.map +1 -1
- package/internal/components/selectable-item/index.js +25 -26
- package/internal/components/selectable-item/index.js.map +1 -1
- package/internal/components/tab-trap/index.js +1 -2
- package/internal/components/tab-trap/index.js.map +1 -1
- package/internal/components/transition/index.js +16 -16
- package/internal/components/transition/index.js.map +1 -1
- package/internal/components/visual-context/index.js +6 -7
- package/internal/components/visual-context/index.js.map +1 -1
- package/internal/context/app-layout-context.js +2 -2
- package/internal/context/app-layout-context.js.map +1 -1
- package/internal/context/form-field-context.js +4 -4
- package/internal/context/form-field-context.js.map +1 -1
- package/internal/context/split-panel-context.js +3 -3
- package/internal/context/split-panel-context.js.map +1 -1
- package/internal/debounce.js +6 -11
- package/internal/debounce.js.map +1 -1
- package/internal/environment.js +1 -1
- package/internal/events/index.js +12 -16
- package/internal/events/index.js.map +1 -1
- package/internal/focus-tracker.js +22 -27
- package/internal/focus-tracker.js.map +1 -1
- package/internal/generated/custom-css-properties/index.js +2 -2
- package/internal/generated/custom-css-properties/index.js.map +1 -1
- package/internal/hooks/check-controlled/index.js +1 -1
- package/internal/hooks/check-controlled/index.js.map +1 -1
- package/internal/hooks/container-queries/use-container-breakpoints.js +2 -2
- package/internal/hooks/container-queries/use-container-breakpoints.js.map +1 -1
- package/internal/hooks/container-queries/use-container-query.js +5 -6
- package/internal/hooks/container-queries/use-container-query.js.map +1 -1
- package/internal/hooks/container-queries/use-resize-observer.js +13 -13
- package/internal/hooks/container-queries/use-resize-observer.js.map +1 -1
- package/internal/hooks/focus-visible/index.js +8 -8
- package/internal/hooks/focus-visible/index.js.map +1 -1
- package/internal/hooks/forward-focus/index.js +5 -9
- package/internal/hooks/forward-focus/index.js.map +1 -1
- package/internal/hooks/forward-focus/radio-group.js +7 -7
- package/internal/hooks/forward-focus/radio-group.js.map +1 -1
- package/internal/hooks/use-base-component/component-metadata.js +5 -5
- package/internal/hooks/use-base-component/component-metadata.js.map +1 -1
- package/internal/hooks/use-base-component/index.js +1 -1
- package/internal/hooks/use-base-component/index.js.map +1 -1
- package/internal/hooks/use-controllable/index.js +16 -17
- package/internal/hooks/use-controllable/index.js.map +1 -1
- package/internal/hooks/use-date-cache/index.js +2 -2
- package/internal/hooks/use-date-cache/index.js.map +1 -1
- package/internal/hooks/use-debounce-callback/index.js +3 -7
- package/internal/hooks/use-debounce-callback/index.js.map +1 -1
- package/internal/hooks/use-dynamic-overlap/index.js +4 -4
- package/internal/hooks/use-dynamic-overlap/index.js.map +1 -1
- package/internal/hooks/use-effect-on-update.js +2 -2
- package/internal/hooks/use-effect-on-update.js.map +1 -1
- package/internal/hooks/use-focus-tracker.js +7 -8
- package/internal/hooks/use-focus-tracker.js.map +1 -1
- package/internal/hooks/use-has-rendered/index.js +6 -6
- package/internal/hooks/use-has-rendered/index.js.map +1 -1
- package/internal/hooks/use-merge-refs/index.js +5 -9
- package/internal/hooks/use-merge-refs/index.js.map +1 -1
- package/internal/hooks/use-mobile/index.js +7 -7
- package/internal/hooks/use-mobile/index.js.map +1 -1
- package/internal/hooks/use-mouse-down-target.js +5 -5
- package/internal/hooks/use-mouse-down-target.js.map +1 -1
- package/internal/hooks/use-mutation-observer/index.js +5 -5
- package/internal/hooks/use-mutation-observer/index.js.map +1 -1
- package/internal/hooks/use-portal-mode-classes/index.js +10 -12
- package/internal/hooks/use-portal-mode-classes/index.js.map +1 -1
- package/internal/hooks/use-previous/index.js +3 -3
- package/internal/hooks/use-previous/index.js.map +1 -1
- package/internal/hooks/use-scroll-sync/index.js +8 -9
- package/internal/hooks/use-scroll-sync/index.js.map +1 -1
- package/internal/hooks/use-singleton-handler/index.js +12 -14
- package/internal/hooks/use-singleton-handler/index.js.map +1 -1
- package/internal/hooks/use-stable-event-handler/index.js +3 -10
- package/internal/hooks/use-stable-event-handler/index.js.map +1 -1
- package/internal/hooks/use-telemetry/index.js +2 -2
- package/internal/hooks/use-telemetry/index.js.map +1 -1
- package/internal/hooks/use-telemetry/telemetry.js +3 -4
- package/internal/hooks/use-telemetry/telemetry.js.map +1 -1
- package/internal/hooks/use-unique-id/index.js +3 -3
- package/internal/hooks/use-unique-id/index.js.map +1 -1
- package/internal/hooks/use-visual-mode/index.js +11 -11
- package/internal/hooks/use-visual-mode/index.js.map +1 -1
- package/internal/is-development.js +1 -1
- package/internal/is-development.js.map +1 -1
- package/internal/logging.js +2 -2
- package/internal/logging.js.map +1 -1
- package/internal/manifest.json +1 -1
- package/internal/metrics/log-clients.js +18 -27
- package/internal/metrics/log-clients.js.map +1 -1
- package/internal/metrics/metrics-formatters.js +11 -14
- package/internal/metrics/metrics-formatters.js.map +1 -1
- package/internal/metrics/metrics.js +27 -33
- package/internal/metrics/metrics.js.map +1 -1
- package/internal/motion.js +2 -2
- package/internal/motion.js.map +1 -1
- package/internal/styles/colors.js +1 -1
- package/internal/styles/colors.js.map +1 -1
- package/internal/utils/browser-scrollbar-size.js +5 -5
- package/internal/utils/browser-scrollbar-size.js.map +1 -1
- package/internal/utils/calculate-once.js +2 -2
- package/internal/utils/calculate-once.js.map +1 -1
- package/internal/utils/check-safe-url.js +4 -4
- package/internal/utils/check-safe-url.js.map +1 -1
- package/internal/utils/create-category-color-scale.js +6 -9
- package/internal/utils/create-category-color-scale.js.map +1 -1
- package/internal/utils/date-time/format-date-range.js +3 -3
- package/internal/utils/date-time/format-date-range.js.map +1 -1
- package/internal/utils/date-time/format-date.js +4 -4
- package/internal/utils/date-time/format-date.js.map +1 -1
- package/internal/utils/date-time/format-time.js +5 -5
- package/internal/utils/date-time/format-time.js.map +1 -1
- package/internal/utils/date-time/format-timezone-offset.js +4 -4
- package/internal/utils/date-time/format-timezone-offset.js.map +1 -1
- package/internal/utils/date-time/is-iso-date-only.js +1 -1
- package/internal/utils/date-time/is-iso-date-only.js.map +1 -1
- package/internal/utils/date-time/join-date-time.js +3 -3
- package/internal/utils/date-time/join-date-time.js.map +1 -1
- package/internal/utils/date-time/parse-date.js +5 -6
- package/internal/utils/date-time/parse-date.js.map +1 -1
- package/internal/utils/date-time/parse-timezone-offset.js +5 -5
- package/internal/utils/date-time/parse-timezone-offset.js.map +1 -1
- package/internal/utils/date-time/shift-timezone-offset.js +6 -6
- package/internal/utils/date-time/shift-timezone-offset.js.map +1 -1
- package/internal/utils/dom.js +12 -12
- package/internal/utils/dom.js.map +1 -1
- package/internal/utils/external-props.js +3 -3
- package/internal/utils/external-props.js.map +1 -1
- package/internal/utils/focus-svg-element.js +1 -1
- package/internal/utils/focus-svg-element.js.map +1 -1
- package/internal/utils/locale/merge-locales.js +1 -1
- package/internal/utils/locale/merge-locales.js.map +1 -1
- package/internal/utils/locale/normalize-locale.js +3 -3
- package/internal/utils/locale/normalize-locale.js.map +1 -1
- package/internal/utils/promises.js +7 -11
- package/internal/utils/promises.js.map +1 -1
- package/internal/utils/scrollable-containers.js +14 -18
- package/internal/utils/scrollable-containers.js.map +1 -1
- package/internal/utils/strings/join-strings.js +1 -5
- package/internal/utils/strings/join-strings.js.map +1 -1
- package/internal/utils/strings/pad-left-zeros.js +1 -1
- package/internal/utils/strings/pad-left-zeros.js.map +1 -1
- package/internal/utils/throttle.js +10 -15
- package/internal/utils/throttle.js.map +1 -1
- package/internal/utils/use-container-width.js +3 -5
- package/internal/utils/use-container-width.js.map +1 -1
- package/line-chart/index.js +6 -6
- package/line-chart/index.js.map +1 -1
- package/link/index.js +5 -5
- package/link/index.js.map +1 -1
- package/link/internal.js +25 -25
- package/link/internal.js.map +1 -1
- package/mixed-line-bar-chart/bar-groups.js +3 -4
- package/mixed-line-bar-chart/bar-groups.js.map +1 -1
- package/mixed-line-bar-chart/bar-series.js +24 -33
- package/mixed-line-bar-chart/bar-series.js.map +1 -1
- package/mixed-line-bar-chart/chart-container.js +123 -138
- package/mixed-line-bar-chart/chart-container.js.map +1 -1
- package/mixed-line-bar-chart/chart-filters.js +10 -17
- package/mixed-line-bar-chart/chart-filters.js.map +1 -1
- package/mixed-line-bar-chart/chart-legend.js +9 -13
- package/mixed-line-bar-chart/chart-legend.js.map +1 -1
- package/mixed-line-bar-chart/chart-popover.js +3 -4
- package/mixed-line-bar-chart/chart-popover.js.map +1 -1
- package/mixed-line-bar-chart/data-series.js +13 -17
- package/mixed-line-bar-chart/data-series.js.map +1 -1
- package/mixed-line-bar-chart/domain.js +32 -39
- package/mixed-line-bar-chart/domain.js.map +1 -1
- package/mixed-line-bar-chart/format-highlighted.js +13 -14
- package/mixed-line-bar-chart/format-highlighted.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js +32 -34
- package/mixed-line-bar-chart/hooks/use-mouse-hover.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-navigation.js +48 -57
- package/mixed-line-bar-chart/hooks/use-navigation.js.map +1 -1
- package/mixed-line-bar-chart/hooks/use-popover.js +7 -7
- package/mixed-line-bar-chart/hooks/use-popover.js.map +1 -1
- package/mixed-line-bar-chart/index.js +4 -4
- package/mixed-line-bar-chart/index.js.map +1 -1
- package/mixed-line-bar-chart/internal.js +47 -49
- package/mixed-line-bar-chart/internal.js.map +1 -1
- package/mixed-line-bar-chart/line-series.js +19 -24
- package/mixed-line-bar-chart/line-series.js.map +1 -1
- package/mixed-line-bar-chart/make-scaled-bar-groups.js +10 -11
- package/mixed-line-bar-chart/make-scaled-bar-groups.js.map +1 -1
- package/mixed-line-bar-chart/make-scaled-series.js +30 -38
- package/mixed-line-bar-chart/make-scaled-series.js.map +1 -1
- package/mixed-line-bar-chart/utils.js +18 -21
- package/mixed-line-bar-chart/utils.js.map +1 -1
- package/modal/body-scroll.js +4 -4
- package/modal/body-scroll.js.map +1 -1
- package/modal/index.js +4 -4
- package/modal/index.js.map +1 -1
- package/modal/internal.js +24 -25
- package/modal/internal.js.map +1 -1
- package/multiselect/index.js +5 -5
- package/multiselect/index.js.map +1 -1
- package/multiselect/internal.js +81 -88
- package/multiselect/internal.js.map +1 -1
- package/package.json +1 -1
- package/pagination/index.js +2 -3
- package/pagination/index.js.map +1 -1
- package/pagination/internal.js +16 -17
- package/pagination/internal.js.map +1 -1
- package/pagination/utils.js +12 -12
- package/pagination/utils.js.map +1 -1
- package/pie-chart/index.js +38 -39
- package/pie-chart/index.js.map +1 -1
- package/pie-chart/labels.js +38 -42
- package/pie-chart/labels.js.map +1 -1
- package/pie-chart/pie-chart.js +65 -67
- package/pie-chart/pie-chart.js.map +1 -1
- package/pie-chart/responsive-text.js +9 -10
- package/pie-chart/responsive-text.js.map +1 -1
- package/pie-chart/segments.js +27 -31
- package/pie-chart/segments.js.map +1 -1
- package/pie-chart/utils.js +32 -35
- package/pie-chart/utils.js.map +1 -1
- package/popover/arrow.js +2 -2
- package/popover/arrow.js.map +1 -1
- package/popover/body.js +16 -19
- package/popover/body.js.map +1 -1
- package/popover/container.js +52 -55
- package/popover/container.js.map +1 -1
- package/popover/index.js +6 -6
- package/popover/index.js.map +1 -1
- package/popover/internal.js +28 -28
- package/popover/internal.js.map +1 -1
- package/popover/utils/positions.js +54 -66
- package/popover/utils/positions.js.map +1 -1
- package/progress-bar/index.js +17 -17
- package/progress-bar/index.js.map +1 -1
- package/progress-bar/internal.js +12 -16
- package/progress-bar/internal.js.map +1 -1
- package/property-filter/controller.js +117 -125
- package/property-filter/controller.js.map +1 -1
- package/property-filter/filter-options.js +8 -11
- package/property-filter/filter-options.js.map +1 -1
- package/property-filter/index.js +50 -50
- package/property-filter/index.js.map +1 -1
- package/property-filter/property-editor.js +4 -5
- package/property-filter/property-editor.js.map +1 -1
- package/property-filter/property-filter-autosuggest.js +39 -39
- package/property-filter/property-filter-autosuggest.js.map +1 -1
- package/property-filter/token-editor.js +55 -66
- package/property-filter/token-editor.js.map +1 -1
- package/property-filter/token.js +9 -11
- package/property-filter/token.js.map +1 -1
- package/property-filter/use-load-items.js +8 -12
- package/property-filter/use-load-items.js.map +1 -1
- package/property-filter/utils.js +13 -18
- package/property-filter/utils.js.map +1 -1
- package/radio-group/index.js +3 -4
- package/radio-group/index.js.map +1 -1
- package/radio-group/internal.js +9 -9
- package/radio-group/internal.js.map +1 -1
- package/radio-group/radio-button.js +12 -15
- package/radio-group/radio-button.js.map +1 -1
- package/s3-resource-selector/index.js +29 -29
- package/s3-resource-selector/index.js.map +1 -1
- package/s3-resource-selector/s3-in-context/index.js +16 -18
- package/s3-resource-selector/s3-in-context/index.js.map +1 -1
- package/s3-resource-selector/s3-in-context/search-input.js +3 -4
- package/s3-resource-selector/s3-in-context/search-input.js.map +1 -1
- package/s3-resource-selector/s3-in-context/use-versions-fetch.js +16 -16
- package/s3-resource-selector/s3-in-context/use-versions-fetch.js.map +1 -1
- package/s3-resource-selector/s3-in-context/validation.js +6 -6
- package/s3-resource-selector/s3-in-context/validation.js.map +1 -1
- package/s3-resource-selector/s3-modal/basic-table.js +19 -20
- package/s3-resource-selector/s3-modal/basic-table.js.map +1 -1
- package/s3-resource-selector/s3-modal/buckets-table.js +11 -13
- package/s3-resource-selector/s3-modal/buckets-table.js.map +1 -1
- package/s3-resource-selector/s3-modal/column-formats.js +5 -5
- package/s3-resource-selector/s3-modal/column-formats.js.map +1 -1
- package/s3-resource-selector/s3-modal/empty-state.js +1 -2
- package/s3-resource-selector/s3-modal/empty-state.js.map +1 -1
- package/s3-resource-selector/s3-modal/index.js +37 -43
- package/s3-resource-selector/s3-modal/index.js.map +1 -1
- package/s3-resource-selector/s3-modal/objects-table.js +12 -14
- package/s3-resource-selector/s3-modal/objects-table.js.map +1 -1
- package/s3-resource-selector/s3-modal/table-utils.js +9 -12
- package/s3-resource-selector/s3-modal/table-utils.js.map +1 -1
- package/s3-resource-selector/s3-modal/versions-table.js +10 -12
- package/s3-resource-selector/s3-modal/versions-table.js.map +1 -1
- package/s3-resource-selector/utils.js +1 -1
- package/s3-resource-selector/utils.js.map +1 -1
- package/segmented-control/index.js +2 -3
- package/segmented-control/index.js.map +1 -1
- package/segmented-control/internal-segmented-control.js +16 -17
- package/segmented-control/internal-segmented-control.js.map +1 -1
- package/segmented-control/internal.js +14 -14
- package/segmented-control/internal.js.map +1 -1
- package/segmented-control/segment.js +3 -6
- package/segmented-control/segment.js.map +1 -1
- package/select/index.js +6 -6
- package/select/index.js.map +1 -1
- package/select/internal.js +58 -58
- package/select/internal.js.map +1 -1
- package/select/parts/filter.js +4 -4
- package/select/parts/filter.js.map +1 -1
- package/select/parts/item.js +10 -10
- package/select/parts/item.js.map +1 -1
- package/select/parts/multiselect-item.js +13 -14
- package/select/parts/multiselect-item.js.map +1 -1
- package/select/parts/plain-list.js +13 -15
- package/select/parts/plain-list.js.map +1 -1
- package/select/parts/trigger.js +7 -9
- package/select/parts/trigger.js.map +1 -1
- package/select/parts/virtual-list.js +27 -33
- package/select/parts/virtual-list.js.map +1 -1
- package/select/utils/check-option-value-field.js +2 -2
- package/select/utils/check-option-value-field.js.map +1 -1
- package/select/utils/connect-options.js +6 -7
- package/select/utils/connect-options.js.map +1 -1
- package/select/utils/get-item-props.js +4 -7
- package/select/utils/get-item-props.js.map +1 -1
- package/select/utils/render-options.js +13 -15
- package/select/utils/render-options.js.map +1 -1
- package/select/utils/use-announcement.js +10 -11
- package/select/utils/use-announcement.js.map +1 -1
- package/select/utils/use-load-items.js +16 -19
- package/select/utils/use-load-items.js.map +1 -1
- package/select/utils/use-native-search.js +20 -29
- package/select/utils/use-native-search.js.map +1 -1
- package/select/utils/use-select.js +89 -96
- package/select/utils/use-select.js.map +1 -1
- package/side-navigation/index.js +10 -10
- package/side-navigation/index.js.map +1 -1
- package/side-navigation/internal.js +35 -46
- package/side-navigation/internal.js.map +1 -1
- package/side-navigation/util.js +9 -12
- package/side-navigation/util.js.map +1 -1
- package/space-between/index.js +4 -4
- package/space-between/index.js.map +1 -1
- package/space-between/internal.js +7 -7
- package/space-between/internal.js.map +1 -1
- package/spinner/index.js +4 -4
- package/spinner/index.js.map +1 -1
- package/spinner/internal.js +4 -4
- package/spinner/internal.js.map +1 -1
- package/split-panel/bottom.js +22 -25
- package/split-panel/bottom.js.map +1 -1
- package/split-panel/icons/bottom-icon-refresh.js +11 -13
- package/split-panel/icons/bottom-icon-refresh.js.map +1 -1
- package/split-panel/icons/bottom-icon.js +1 -1
- package/split-panel/icons/bottom-icon.js.map +1 -1
- package/split-panel/icons/resize-handler.js +3 -6
- package/split-panel/icons/resize-handler.js.map +1 -1
- package/split-panel/icons/side-position-refresh.js +12 -14
- package/split-panel/icons/side-position-refresh.js.map +1 -1
- package/split-panel/icons/side-position.js +1 -1
- package/split-panel/icons/side-position.js.map +1 -1
- package/split-panel/index.js +65 -65
- package/split-panel/index.js.map +1 -1
- package/split-panel/preferences-modal.js +9 -9
- package/split-panel/preferences-modal.js.map +1 -1
- package/split-panel/side.js +12 -15
- package/split-panel/side.js.map +1 -1
- package/split-panel/utils/size-utils.js +3 -3
- package/split-panel/utils/size-utils.js.map +1 -1
- package/split-panel/utils/use-keyboard-events.js +13 -17
- package/split-panel/utils/use-keyboard-events.js.map +1 -1
- package/split-panel/utils/use-pointer-events.js +12 -13
- package/split-panel/utils/use-pointer-events.js.map +1 -1
- package/status-indicator/index.js +4 -4
- package/status-indicator/index.js.map +1 -1
- package/status-indicator/internal.js +9 -10
- package/status-indicator/internal.js.map +1 -1
- package/table/body-cell/click-away.js +9 -10
- package/table/body-cell/click-away.js.map +1 -1
- package/table/body-cell/index.js +18 -18
- package/table/body-cell/index.js.map +1 -1
- package/table/body-cell/inline-editor.js +32 -46
- package/table/body-cell/inline-editor.js.map +1 -1
- package/table/body-cell/td-element.js +2 -4
- package/table/body-cell/td-element.js.map +1 -1
- package/table/body-cell/use-stable-scroll-position.js +10 -13
- package/table/body-cell/use-stable-scroll-position.js.map +1 -1
- package/table/header-cell/index.d.ts +4 -2
- package/table/header-cell/index.d.ts.map +1 -1
- package/table/header-cell/index.js +33 -34
- package/table/header-cell/index.js.map +1 -1
- package/table/header-cell/utils.js +10 -12
- package/table/header-cell/utils.js.map +1 -1
- package/table/index.js +5 -5
- package/table/index.js.map +1 -1
- package/table/internal.d.ts.map +1 -1
- package/table/internal.js +94 -118
- package/table/internal.js.map +1 -1
- package/table/resizer/index.d.ts +5 -1
- package/table/resizer/index.d.ts.map +1 -1
- package/table/resizer/index.js +40 -39
- package/table/resizer/index.js.map +1 -1
- package/table/selection-control/index.d.ts +4 -1
- package/table/selection-control/index.d.ts.map +1 -1
- package/table/selection-control/index.js +11 -11
- package/table/selection-control/index.js.map +1 -1
- package/table/sticky-header.d.ts +2 -2
- package/table/sticky-header.d.ts.map +1 -1
- package/table/sticky-header.js +16 -15
- package/table/sticky-header.js.map +1 -1
- package/table/sticky-scrollbar.js +5 -6
- package/table/sticky-scrollbar.js.map +1 -1
- package/table/sticky-scrolling.js +10 -10
- package/table/sticky-scrolling.js.map +1 -1
- package/table/thead.d.ts +11 -3
- package/table/thead.d.ts.map +1 -1
- package/table/thead.js +13 -13
- package/table/thead.js.map +1 -1
- package/table/tools-header.js +4 -5
- package/table/tools-header.js.map +1 -1
- package/table/use-column-widths.js +34 -44
- package/table/use-column-widths.js.map +1 -1
- package/table/use-row-events.js +10 -11
- package/table/use-row-events.js.map +1 -1
- package/table/use-selection.js +75 -81
- package/table/use-selection.js.map +1 -1
- package/table/use-sticky-header.js +16 -16
- package/table/use-sticky-header.js.map +1 -1
- package/table/use-sticky-scrollbar.js +42 -42
- package/table/use-sticky-scrollbar.js.map +1 -1
- package/table/use-table-focus-navigation.js +27 -28
- package/table/use-table-focus-navigation.js.map +1 -1
- package/table/utils.js +7 -7
- package/table/utils.js.map +1 -1
- package/tabs/index.js +30 -33
- package/tabs/index.js.map +1 -1
- package/tabs/scroll-utils.js +12 -13
- package/tabs/scroll-utils.js.map +1 -1
- package/tabs/smooth-scroll.js +17 -17
- package/tabs/smooth-scroll.js.map +1 -1
- package/tabs/tab-header-bar.js +61 -66
- package/tabs/tab-header-bar.js.map +1 -1
- package/tag-editor/index.js +59 -72
- package/tag-editor/index.js.map +1 -1
- package/tag-editor/internal.js +21 -29
- package/tag-editor/internal.js.map +1 -1
- package/tag-editor/utils.js +7 -8
- package/tag-editor/utils.js.map +1 -1
- package/tag-editor/validation.js +16 -18
- package/tag-editor/validation.js.map +1 -1
- package/text-content/index.js +6 -6
- package/text-content/index.js.map +1 -1
- package/text-filter/index.js +3 -4
- package/text-filter/index.js.map +1 -1
- package/text-filter/internal.js +10 -10
- package/text-filter/internal.js.map +1 -1
- package/textarea/index.js +23 -24
- package/textarea/index.js.map +1 -1
- package/theming/index.js +2 -3
- package/theming/index.js.map +1 -1
- package/tiles/index.js +3 -4
- package/tiles/index.js.map +1 -1
- package/tiles/internal.js +17 -17
- package/tiles/internal.js.map +1 -1
- package/tiles/tile.js +7 -9
- package/tiles/tile.js.map +1 -1
- package/time-input/index.js +5 -5
- package/time-input/index.js.map +1 -1
- package/time-input/internal.js +9 -9
- package/time-input/internal.js.map +1 -1
- package/toggle/index.js +3 -4
- package/toggle/index.js.map +1 -1
- package/toggle/internal.js +15 -16
- package/toggle/internal.js.map +1 -1
- package/token-group/dismiss-button.js +5 -7
- package/token-group/dismiss-button.js.map +1 -1
- package/token-group/index.js +4 -4
- package/token-group/index.js.map +1 -1
- package/token-group/internal.js +14 -14
- package/token-group/internal.js.map +1 -1
- package/token-group/toggle.js +7 -9
- package/token-group/toggle.js.map +1 -1
- package/top-navigation/1.0-beta/index.js +4 -4
- package/top-navigation/1.0-beta/index.js.map +1 -1
- package/top-navigation/1.0-beta/internal.js +43 -46
- package/top-navigation/1.0-beta/internal.js.map +1 -1
- package/top-navigation/1.0-beta/parts/overflow-menu.js +16 -17
- package/top-navigation/1.0-beta/parts/overflow-menu.js.map +1 -1
- package/top-navigation/1.0-beta/parts/utility.js +9 -12
- package/top-navigation/1.0-beta/parts/utility.js.map +1 -1
- package/top-navigation/1.0-beta/use-top-navigation.js +46 -54
- package/top-navigation/1.0-beta/use-top-navigation.js.map +1 -1
- package/top-navigation/index.js +4 -4
- package/top-navigation/index.js.map +1 -1
- package/top-navigation/internal.js +64 -71
- package/top-navigation/internal.js.map +1 -1
- package/top-navigation/parts/overflow-menu/header.js +3 -4
- package/top-navigation/parts/overflow-menu/header.js.map +1 -1
- package/top-navigation/parts/overflow-menu/index.js +4 -5
- package/top-navigation/parts/overflow-menu/index.js.map +1 -1
- package/top-navigation/parts/overflow-menu/menu-item.js +56 -61
- package/top-navigation/parts/overflow-menu/menu-item.js.map +1 -1
- package/top-navigation/parts/overflow-menu/router.js +11 -13
- package/top-navigation/parts/overflow-menu/router.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/submenu.js +6 -8
- package/top-navigation/parts/overflow-menu/views/submenu.js.map +1 -1
- package/top-navigation/parts/overflow-menu/views/utilities.js +5 -7
- package/top-navigation/parts/overflow-menu/views/utilities.js.map +1 -1
- package/top-navigation/parts/utility.js +12 -15
- package/top-navigation/parts/utility.js.map +1 -1
- package/top-navigation/use-top-navigation.js +52 -59
- package/top-navigation/use-top-navigation.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/congratulation-screen.js +5 -7
- package/tutorial-panel/components/tutorial-detail-view/congratulation-screen.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/index.js +6 -7
- package/tutorial-panel/components/tutorial-detail-view/index.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/task-list.js +8 -15
- package/tutorial-panel/components/tutorial-detail-view/task-list.js.map +1 -1
- package/tutorial-panel/components/tutorial-detail-view/task.js +5 -6
- package/tutorial-panel/components/tutorial-detail-view/task.js.map +1 -1
- package/tutorial-panel/components/tutorial-list/index.js +19 -22
- package/tutorial-panel/components/tutorial-list/index.js.map +1 -1
- package/tutorial-panel/index.js +8 -8
- package/tutorial-panel/index.js.map +1 -1
- package/wizard/index.js +28 -28
- package/wizard/index.js.map +1 -1
- package/wizard/internal/analytics.js +32 -42
- package/wizard/internal/analytics.js.map +1 -1
- package/wizard/unmount.js +6 -13
- package/wizard/unmount.js.map +1 -1
- package/wizard/wizard-actions.js +7 -8
- package/wizard/wizard-actions.js.map +1 -1
- package/wizard/wizard-form-header.js +2 -3
- package/wizard/wizard-form-header.js.map +1 -1
- package/wizard/wizard-form.js +14 -16
- package/wizard/wizard-form.js.map +1 -1
- package/wizard/wizard-navigation.js +19 -25
- package/wizard/wizard-navigation.js.map +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __spreadArray } from "tslib";
|
|
2
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
3
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -6,18 +5,17 @@ import { useMergeRefs } from '../../internal/hooks/use-merge-refs';
|
|
|
6
5
|
import { useContainerBreakpoints, useContainerQuery } from '../../internal/hooks/container-queries';
|
|
7
6
|
import styles from './styles.css.js';
|
|
8
7
|
// A small buffer to make calculations more lenient against browser lag or padding adjustments.
|
|
9
|
-
|
|
10
|
-
export function useTopNavigation(
|
|
11
|
-
var mainRef = _a.__internalRootRef, identity = _a.identity, search = _a.search, utilities = _a.utilities;
|
|
8
|
+
const RESPONSIVENESS_BUFFER = 20;
|
|
9
|
+
export function useTopNavigation({ __internalRootRef: mainRef, identity, search, utilities, }) {
|
|
12
10
|
// Refs and breakpoints
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
const virtualRef = useRef(null);
|
|
12
|
+
const [breakpoint, breakpointRef] = useContainerBreakpoints(['xxs', 's']);
|
|
15
13
|
// Responsiveness state
|
|
16
14
|
// The component works by calculating the possible resize states that it can
|
|
17
15
|
// be in, and having a state variable to track which state we're currently in.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
const hasSearch = !!search;
|
|
17
|
+
const hasTitleWithLogo = identity && !!identity.logo && !!identity.title;
|
|
18
|
+
const responsiveStates = useMemo(() => {
|
|
21
19
|
return generateResponsiveStateKeys(utilities, hasSearch, hasTitleWithLogo);
|
|
22
20
|
}, [utilities, hasSearch, hasTitleWithLogo]);
|
|
23
21
|
// To hide/show elements dynamically, we need to know how much space they take up,
|
|
@@ -31,40 +29,40 @@ export function useTopNavigation(_a) {
|
|
|
31
29
|
// spacing token values, icon sizes, text widths, etc.
|
|
32
30
|
//
|
|
33
31
|
// TODO: Some of these values can be memoized to improve perf.
|
|
34
|
-
|
|
32
|
+
const [responsiveState, containerQueryRef] = useContainerQuery(() => {
|
|
35
33
|
var _a, _b, _c, _d;
|
|
36
34
|
if (!(mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) || !virtualRef.current) {
|
|
37
35
|
return responsiveStates[0];
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
const sizeConfiguration = {
|
|
40
38
|
hasSearch: !!search,
|
|
41
39
|
// Get widths and paddings from the visible top navigation
|
|
42
|
-
availableWidth: getContentBoxWidth(mainRef.current.querySelector(
|
|
43
|
-
utilitiesLeftPadding: parseFloat(getComputedStyle(virtualRef.current.querySelector(
|
|
40
|
+
availableWidth: getContentBoxWidth(mainRef.current.querySelector(`.${styles['padding-box']}`)),
|
|
41
|
+
utilitiesLeftPadding: parseFloat(getComputedStyle(virtualRef.current.querySelector(`.${styles.utilities}`)).paddingLeft),
|
|
44
42
|
// Get widths from the hidden top navigation
|
|
45
|
-
fullIdentityWidth: virtualRef.current.querySelector(
|
|
46
|
-
titleWidth: (_b = (_a = virtualRef.current.querySelector(
|
|
47
|
-
searchSlotWidth: (_d = (_c = virtualRef.current.querySelector(
|
|
43
|
+
fullIdentityWidth: virtualRef.current.querySelector(`.${styles.identity}`).getBoundingClientRect().width,
|
|
44
|
+
titleWidth: (_b = (_a = virtualRef.current.querySelector(`.${styles.title}`)) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width) !== null && _b !== void 0 ? _b : 0,
|
|
45
|
+
searchSlotWidth: (_d = (_c = virtualRef.current.querySelector(`.${styles.search}`)) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().width) !== null && _d !== void 0 ? _d : 0,
|
|
48
46
|
searchUtilityWidth: virtualRef.current.querySelector('[data-utility-special="search"]').getBoundingClientRect()
|
|
49
47
|
.width,
|
|
50
48
|
utilityWithLabelWidths: Array.prototype.slice
|
|
51
|
-
.call(virtualRef.current.querySelectorAll(
|
|
52
|
-
.map(
|
|
49
|
+
.call(virtualRef.current.querySelectorAll(`[data-utility-hide="false"]`))
|
|
50
|
+
.map((element) => element.getBoundingClientRect().width),
|
|
53
51
|
utilityWithoutLabelWidths: Array.prototype.slice
|
|
54
|
-
.call(virtualRef.current.querySelectorAll(
|
|
55
|
-
.map(
|
|
52
|
+
.call(virtualRef.current.querySelectorAll(`[data-utility-hide="true"]`))
|
|
53
|
+
.map((element) => element.getBoundingClientRect().width),
|
|
56
54
|
menuTriggerUtilityWidth: virtualRef.current
|
|
57
55
|
.querySelector('[data-utility-special="menu-trigger"]')
|
|
58
|
-
.getBoundingClientRect().width
|
|
56
|
+
.getBoundingClientRect().width,
|
|
59
57
|
};
|
|
60
58
|
return determineBestResponsiveState(responsiveStates, sizeConfiguration);
|
|
61
|
-
}, [mainRef, search, responsiveStates])
|
|
59
|
+
}, [mainRef, search, responsiveStates]);
|
|
62
60
|
// Search slot expansion on small screens
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
const [isSearchMinimized, setSearchMinimized] = useState(true);
|
|
62
|
+
const isSearchExpanded = !isSearchMinimized && breakpoint !== 's' && hasSearch && (responsiveState === null || responsiveState === void 0 ? void 0 : responsiveState.hideSearch);
|
|
65
63
|
// If the search was expanded, and then the screen resized so that the
|
|
66
64
|
// expansion is no longer necessary. So we implicitly minimize it.
|
|
67
|
-
useEffect(
|
|
65
|
+
useEffect(() => {
|
|
68
66
|
if (!(responsiveState === null || responsiveState === void 0 ? void 0 : responsiveState.hideSearch)) {
|
|
69
67
|
setSearchMinimized(true);
|
|
70
68
|
}
|
|
@@ -72,51 +70,51 @@ export function useTopNavigation(_a) {
|
|
|
72
70
|
// If the search is expanded after clicking on the search utility, move
|
|
73
71
|
// the focus to the input. Since this is a user-controlled slot, we're just
|
|
74
72
|
// assuming that it contains an input, though it's a pretty safe guess.
|
|
75
|
-
useEffect(
|
|
73
|
+
useEffect(() => {
|
|
76
74
|
var _a, _b;
|
|
77
75
|
if (isSearchExpanded) {
|
|
78
|
-
(_b = (_a = mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(
|
|
76
|
+
(_b = (_a = mainRef === null || mainRef === void 0 ? void 0 : mainRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.${styles.search} input`)) === null || _b === void 0 ? void 0 : _b.focus();
|
|
79
77
|
}
|
|
80
78
|
}, [isSearchExpanded, mainRef]);
|
|
81
|
-
|
|
79
|
+
const mergedRef = useMergeRefs(...(mainRef ? [mainRef] : []), containerQueryRef, breakpointRef);
|
|
82
80
|
return {
|
|
83
81
|
ref: mergedRef,
|
|
84
82
|
virtualRef: virtualRef,
|
|
85
83
|
responsiveState: responsiveState !== null && responsiveState !== void 0 ? responsiveState : responsiveStates[0],
|
|
86
84
|
breakpoint: breakpoint !== null && breakpoint !== void 0 ? breakpoint : 'default',
|
|
87
85
|
isSearchExpanded: !!isSearchExpanded,
|
|
88
|
-
onSearchUtilityClick:
|
|
86
|
+
onSearchUtilityClick: () => setSearchMinimized(isSearchMinimized => !isSearchMinimized),
|
|
89
87
|
};
|
|
90
88
|
}
|
|
91
89
|
/**
|
|
92
90
|
* Get the width of the content box (assuming the element's box-sizing is border-box).
|
|
93
91
|
*/
|
|
94
92
|
function getContentBoxWidth(element) {
|
|
95
|
-
|
|
93
|
+
const style = getComputedStyle(element);
|
|
96
94
|
return parseFloat(style.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
97
95
|
}
|
|
98
96
|
/**
|
|
99
97
|
* Generates the series of responsive steps that can be performed on the header in order.
|
|
100
98
|
*/
|
|
101
99
|
export function generateResponsiveStateKeys(utilities, canHideSearch, canHideTitle) {
|
|
102
|
-
|
|
103
|
-
if (utilities.some(
|
|
100
|
+
const states = [{}];
|
|
101
|
+
if (utilities.some(utility => utility.text)) {
|
|
104
102
|
states.push({ hideUtilityText: true });
|
|
105
103
|
}
|
|
106
104
|
if (canHideSearch) {
|
|
107
105
|
states.push({
|
|
108
106
|
hideUtilityText: true,
|
|
109
|
-
hideSearch: true
|
|
107
|
+
hideSearch: true,
|
|
110
108
|
});
|
|
111
109
|
}
|
|
112
|
-
|
|
113
|
-
for (
|
|
110
|
+
const hiddenUtilties = [];
|
|
111
|
+
for (let i = 0; i < utilities.length; i++) {
|
|
114
112
|
if (!utilities[i].disableUtilityCollapse) {
|
|
115
113
|
hiddenUtilties.push(i);
|
|
116
114
|
states.push({
|
|
117
115
|
hideUtilityText: true,
|
|
118
116
|
hideSearch: canHideSearch || undefined,
|
|
119
|
-
hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined
|
|
117
|
+
hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,
|
|
120
118
|
});
|
|
121
119
|
}
|
|
122
120
|
}
|
|
@@ -125,7 +123,7 @@ export function generateResponsiveStateKeys(utilities, canHideSearch, canHideTit
|
|
|
125
123
|
hideUtilityText: true,
|
|
126
124
|
hideSearch: canHideSearch || undefined,
|
|
127
125
|
hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,
|
|
128
|
-
hideTitle: true
|
|
126
|
+
hideTitle: true,
|
|
129
127
|
});
|
|
130
128
|
}
|
|
131
129
|
return states;
|
|
@@ -135,25 +133,19 @@ export function generateResponsiveStateKeys(utilities, canHideSearch, canHideTit
|
|
|
135
133
|
* and the current sizes of all elements inside the navigation bar.
|
|
136
134
|
*/
|
|
137
135
|
export function determineBestResponsiveState(possibleStates, sizes) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
const { hasSearch, availableWidth, utilitiesLeftPadding, fullIdentityWidth, titleWidth, searchSlotWidth, searchUtilityWidth, utilityWithLabelWidths, utilityWithoutLabelWidths, menuTriggerUtilityWidth, } = sizes;
|
|
137
|
+
// Iterate through each state and calculate its expected required width.
|
|
138
|
+
for (const state of possibleStates) {
|
|
139
|
+
const searchWidth = hasSearch ? (state.hideSearch ? searchUtilityWidth : searchSlotWidth) : 0;
|
|
140
|
+
const utilitiesWidth = (state.hideUtilityText ? utilityWithoutLabelWidths : utilityWithLabelWidths)
|
|
141
|
+
.filter((_width, i) => !state.hideUtilities || state.hideUtilities.indexOf(i) === -1)
|
|
142
|
+
.reduce((sum, width) => sum + width, 0);
|
|
143
|
+
const menuTriggerWidth = state.hideUtilities ? menuTriggerUtilityWidth : 0;
|
|
144
|
+
const identityWidth = state.hideTitle ? fullIdentityWidth - titleWidth : fullIdentityWidth;
|
|
145
|
+
const expectedInnerWidth = identityWidth + searchWidth + utilitiesLeftPadding + utilitiesWidth + menuTriggerWidth;
|
|
147
146
|
if (expectedInnerWidth <= availableWidth - RESPONSIVENESS_BUFFER) {
|
|
148
|
-
return
|
|
147
|
+
return state;
|
|
149
148
|
}
|
|
150
|
-
};
|
|
151
|
-
// Iterate through each state and calculate its expected required width.
|
|
152
|
-
for (var _i = 0, possibleStates_1 = possibleStates; _i < possibleStates_1.length; _i++) {
|
|
153
|
-
var state = possibleStates_1[_i];
|
|
154
|
-
var state_1 = _loop_1(state);
|
|
155
|
-
if (typeof state_1 === "object")
|
|
156
|
-
return state_1.value;
|
|
157
149
|
}
|
|
158
150
|
// If nothing matches, pick the smallest possible state.
|
|
159
151
|
return possibleStates[possibleStates.length - 1];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-top-navigation.js","sourceRoot":"","sources":["../../../../src/top-navigation/1.0-beta/use-top-navigation.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEpG,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAuCrC,+FAA+F;AAC/F,IAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,UAAU,gBAAgB,CAAC,EAKR;QAJJ,OAAO,uBAAA,EAC1B,QAAQ,cAAA,EACR,MAAM,YAAA,EACN,SAAS,eAAA;IAET,uBAA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AK,CAAC,CAAC,EAA7D,CAA6D,CAAC;aACpF,MAAM,CAAC,UAAC,GAAG,EAAE,KAAK,IAAK,OAAA,GAAG,GAAG,KAAK,EAAX,CAAW,EAAE,CAAC,CAAC,CAAC;QAC1C,IAAM,gBAAgB,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3E,IAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAC3F,IAAM,kBAAkB,GAAG,aAAa,GAAG,WAAW,GAAG,oBAAoB,GAAG,cAAc,GAAG,gBAAgB,CAAC;QAClH,IAAI,kBAAkB,IAAI,cAAc,GAAG,qBAAqB,EAAE;4BACzD,KAAK;SACb;;IAXH,wEAAwE;IACxE,KAAoB,UAAc,EAAd,iCAAc,EAAd,4BAAc,EAAd,IAAc;QAA7B,IAAM,KAAK,uBAAA;8BAAL,KAAK;;;KAWf;IAED,wDAAwD;IACxD,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { useMergeRefs } from '../../internal/hooks/use-merge-refs';\n\nimport { useContainerBreakpoints, useContainerQuery } from '../../internal/hooks/container-queries';\nimport { TopNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\n\nexport interface UseTopNavigationParams {\n __internalRootRef?: React.MutableRefObject<HTMLElement> | null;\n identity: TopNavigationProps['identity'];\n search: TopNavigationProps['search'];\n utilities: NonNullable<TopNavigationProps['utilities']>;\n}\n\nexport interface ResponsiveState {\n hideUtilityText?: boolean;\n hideSearch?: boolean;\n hideUtilities?: number[];\n hideTitle?: boolean;\n}\n\nexport interface TopNavigationSizeConfiguration {\n hasSearch: boolean;\n availableWidth: number;\n utilitiesLeftPadding: number;\n fullIdentityWidth: number;\n titleWidth: number;\n searchSlotWidth: number;\n searchUtilityWidth: number;\n utilityWithLabelWidths: number[];\n utilityWithoutLabelWidths: number[];\n menuTriggerUtilityWidth: number;\n}\n\nexport interface UseTopNavigation {\n ref: React.Ref<HTMLDivElement>;\n virtualRef: React.Ref<HTMLDivElement>;\n\n responsiveState: ResponsiveState;\n breakpoint: 'default' | 'xxs' | 's';\n isSearchExpanded: boolean;\n onSearchUtilityClick: () => void;\n}\n\n// A small buffer to make calculations more lenient against browser lag or padding adjustments.\nconst RESPONSIVENESS_BUFFER = 20;\n\nexport function useTopNavigation({\n __internalRootRef: mainRef,\n identity,\n search,\n utilities,\n}: UseTopNavigationParams): UseTopNavigation {\n // Refs and breakpoints\n const virtualRef = useRef<HTMLDivElement | null>(null);\n const [breakpoint, breakpointRef] = useContainerBreakpoints(['xxs', 's']);\n\n // Responsiveness state\n // The component works by calculating the possible resize states that it can\n // be in, and having a state variable to track which state we're currently in.\n const hasSearch = !!search;\n const hasTitleWithLogo = identity && !!identity.logo && !!identity.title;\n const responsiveStates = useMemo<ReadonlyArray<ResponsiveState>>(() => {\n return generateResponsiveStateKeys(utilities, hasSearch, hasTitleWithLogo);\n }, [utilities, hasSearch, hasTitleWithLogo]);\n\n // To hide/show elements dynamically, we need to know how much space they take up,\n // even if they're not being rendered. The top navigation elements are hidden/resized\n // based on the available size or if a search bar is open, and they need to be available\n // for calculations so we know where to toggle them. So we render a second, more stable\n // top-nav off screen to do these calculations against.\n //\n // We can't \"affix\" these values to pixels because they can depend on spacing tokens.\n // It's easier to render all of these utilities separately rather than figuring out\n // spacing token values, icon sizes, text widths, etc.\n //\n // TODO: Some of these values can be memoized to improve perf.\n const [responsiveState, containerQueryRef] = useContainerQuery<ResponsiveState>(() => {\n if (!mainRef?.current || !virtualRef.current) {\n return responsiveStates[0];\n }\n\n const sizeConfiguration = {\n hasSearch: !!search,\n\n // Get widths and paddings from the visible top navigation\n availableWidth: getContentBoxWidth(mainRef.current.querySelector(`.${styles['padding-box']}`)!),\n utilitiesLeftPadding: parseFloat(\n getComputedStyle(virtualRef.current.querySelector(`.${styles.utilities}`)!).paddingLeft\n ),\n\n // Get widths from the hidden top navigation\n fullIdentityWidth: virtualRef.current.querySelector(`.${styles.identity}`)!.getBoundingClientRect().width,\n titleWidth: virtualRef.current.querySelector(`.${styles.title}`)?.getBoundingClientRect().width ?? 0,\n searchSlotWidth: virtualRef.current.querySelector(`.${styles.search}`)?.getBoundingClientRect().width ?? 0,\n searchUtilityWidth: virtualRef.current.querySelector('[data-utility-special=\"search\"]')!.getBoundingClientRect()\n .width,\n utilityWithLabelWidths: Array.prototype.slice\n .call(virtualRef.current.querySelectorAll(`[data-utility-hide=\"false\"]`))\n .map((element: Element) => element.getBoundingClientRect().width),\n utilityWithoutLabelWidths: Array.prototype.slice\n .call(virtualRef.current.querySelectorAll(`[data-utility-hide=\"true\"]`))\n .map((element: Element) => element.getBoundingClientRect().width),\n menuTriggerUtilityWidth: virtualRef.current\n .querySelector('[data-utility-special=\"menu-trigger\"]')!\n .getBoundingClientRect().width,\n };\n\n return determineBestResponsiveState(responsiveStates, sizeConfiguration);\n }, [mainRef, search, responsiveStates]);\n\n // Search slot expansion on small screens\n const [isSearchMinimized, setSearchMinimized] = useState(true);\n const isSearchExpanded = !isSearchMinimized && breakpoint !== 's' && hasSearch && responsiveState?.hideSearch;\n\n // If the search was expanded, and then the screen resized so that the\n // expansion is no longer necessary. So we implicitly minimize it.\n useEffect(() => {\n if (!responsiveState?.hideSearch) {\n setSearchMinimized(true);\n }\n }, [responsiveState]);\n\n // If the search is expanded after clicking on the search utility, move\n // the focus to the input. Since this is a user-controlled slot, we're just\n // assuming that it contains an input, though it's a pretty safe guess.\n useEffect(() => {\n if (isSearchExpanded) {\n mainRef?.current?.querySelector<HTMLInputElement>(`.${styles.search} input`)?.focus();\n }\n }, [isSearchExpanded, mainRef]);\n\n const mergedRef = useMergeRefs(...(mainRef ? [mainRef] : []), containerQueryRef, breakpointRef);\n\n return {\n ref: mergedRef,\n virtualRef: virtualRef,\n responsiveState: responsiveState ?? responsiveStates[0],\n breakpoint: breakpoint ?? 'default',\n isSearchExpanded: !!isSearchExpanded,\n onSearchUtilityClick: () => setSearchMinimized(isSearchMinimized => !isSearchMinimized),\n };\n}\n\n/**\n * Get the width of the content box (assuming the element's box-sizing is border-box).\n */\nfunction getContentBoxWidth(element: Element): number {\n const style = getComputedStyle(element);\n return parseFloat(style.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);\n}\n\n/**\n * Generates the series of responsive steps that can be performed on the header in order.\n */\nexport function generateResponsiveStateKeys(\n utilities: ReadonlyArray<TopNavigationProps.Utility>,\n canHideSearch: boolean,\n canHideTitle: boolean\n): ReadonlyArray<ResponsiveState> {\n const states: ResponsiveState[] = [{}];\n if (utilities.some(utility => utility.text)) {\n states.push({ hideUtilityText: true });\n }\n if (canHideSearch) {\n states.push({\n hideUtilityText: true,\n hideSearch: true,\n });\n }\n const hiddenUtilties = [];\n for (let i = 0; i < utilities.length; i++) {\n if (!utilities[i].disableUtilityCollapse) {\n hiddenUtilties.push(i);\n states.push({\n hideUtilityText: true,\n hideSearch: canHideSearch || undefined,\n hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,\n });\n }\n }\n if (canHideTitle) {\n states.push({\n hideUtilityText: true,\n hideSearch: canHideSearch || undefined,\n hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,\n hideTitle: true,\n });\n }\n return states;\n}\n\n/**\n * Determines the best responsive state configuration of the top navigation, based on the given list of possible responsive states\n * and the current sizes of all elements inside the navigation bar.\n */\nexport function determineBestResponsiveState(\n possibleStates: ReadonlyArray<ResponsiveState>,\n sizes: TopNavigationSizeConfiguration\n): ResponsiveState {\n const {\n hasSearch,\n availableWidth,\n utilitiesLeftPadding,\n fullIdentityWidth,\n titleWidth,\n searchSlotWidth,\n searchUtilityWidth,\n utilityWithLabelWidths,\n utilityWithoutLabelWidths,\n menuTriggerUtilityWidth,\n } = sizes;\n // Iterate through each state and calculate its expected required width.\n for (const state of possibleStates) {\n const searchWidth = hasSearch ? (state.hideSearch ? searchUtilityWidth : searchSlotWidth) : 0;\n const utilitiesWidth: number = (state.hideUtilityText ? utilityWithoutLabelWidths : utilityWithLabelWidths)\n .filter((_width, i) => !state.hideUtilities || state.hideUtilities.indexOf(i) === -1)\n .reduce((sum, width) => sum + width, 0);\n const menuTriggerWidth = state.hideUtilities ? menuTriggerUtilityWidth : 0;\n const identityWidth = state.hideTitle ? fullIdentityWidth - titleWidth : fullIdentityWidth;\n const expectedInnerWidth = identityWidth + searchWidth + utilitiesLeftPadding + utilitiesWidth + menuTriggerWidth;\n if (expectedInnerWidth <= availableWidth - RESPONSIVENESS_BUFFER) {\n return state;\n }\n }\n\n // If nothing matches, pick the smallest possible state.\n return possibleStates[possibleStates.length - 1];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-top-navigation.js","sourceRoot":"","sources":["../../../../src/top-navigation/1.0-beta/use-top-navigation.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAEnE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAEpG,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAuCrC,+FAA+F;AAC/F,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,MAAM,UAAU,gBAAgB,CAAC,EAC/B,iBAAiB,EAAE,OAAO,EAC1B,QAAQ,EACR,MAAM,EACN,SAAS,GACc;IACvB,uBAAuB;IACvB,MAAM,UAAU,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IACvD,MAAM,CAAC,UA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;QAC3E,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,GAAG,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC;QAC3F,MAAM,kBAAkB,GAAG,aAAa,GAAG,WAAW,GAAG,oBAAoB,GAAG,cAAc,GAAG,gBAAgB,CAAC;QAClH,IAAI,kBAAkB,IAAI,cAAc,GAAG,qBAAqB,EAAE;YAChE,OAAO,KAAK,CAAC;SACd;KACF;IAED,wDAAwD;IACxD,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC","sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { useMergeRefs } from '../../internal/hooks/use-merge-refs';\n\nimport { useContainerBreakpoints, useContainerQuery } from '../../internal/hooks/container-queries';\nimport { TopNavigationProps } from './interfaces';\nimport styles from './styles.css.js';\n\nexport interface UseTopNavigationParams {\n __internalRootRef?: React.MutableRefObject<HTMLElement> | null;\n identity: TopNavigationProps['identity'];\n search: TopNavigationProps['search'];\n utilities: NonNullable<TopNavigationProps['utilities']>;\n}\n\nexport interface ResponsiveState {\n hideUtilityText?: boolean;\n hideSearch?: boolean;\n hideUtilities?: number[];\n hideTitle?: boolean;\n}\n\nexport interface TopNavigationSizeConfiguration {\n hasSearch: boolean;\n availableWidth: number;\n utilitiesLeftPadding: number;\n fullIdentityWidth: number;\n titleWidth: number;\n searchSlotWidth: number;\n searchUtilityWidth: number;\n utilityWithLabelWidths: number[];\n utilityWithoutLabelWidths: number[];\n menuTriggerUtilityWidth: number;\n}\n\nexport interface UseTopNavigation {\n ref: React.Ref<HTMLDivElement>;\n virtualRef: React.Ref<HTMLDivElement>;\n\n responsiveState: ResponsiveState;\n breakpoint: 'default' | 'xxs' | 's';\n isSearchExpanded: boolean;\n onSearchUtilityClick: () => void;\n}\n\n// A small buffer to make calculations more lenient against browser lag or padding adjustments.\nconst RESPONSIVENESS_BUFFER = 20;\n\nexport function useTopNavigation({\n __internalRootRef: mainRef,\n identity,\n search,\n utilities,\n}: UseTopNavigationParams): UseTopNavigation {\n // Refs and breakpoints\n const virtualRef = useRef<HTMLDivElement | null>(null);\n const [breakpoint, breakpointRef] = useContainerBreakpoints(['xxs', 's']);\n\n // Responsiveness state\n // The component works by calculating the possible resize states that it can\n // be in, and having a state variable to track which state we're currently in.\n const hasSearch = !!search;\n const hasTitleWithLogo = identity && !!identity.logo && !!identity.title;\n const responsiveStates = useMemo<ReadonlyArray<ResponsiveState>>(() => {\n return generateResponsiveStateKeys(utilities, hasSearch, hasTitleWithLogo);\n }, [utilities, hasSearch, hasTitleWithLogo]);\n\n // To hide/show elements dynamically, we need to know how much space they take up,\n // even if they're not being rendered. The top navigation elements are hidden/resized\n // based on the available size or if a search bar is open, and they need to be available\n // for calculations so we know where to toggle them. So we render a second, more stable\n // top-nav off screen to do these calculations against.\n //\n // We can't \"affix\" these values to pixels because they can depend on spacing tokens.\n // It's easier to render all of these utilities separately rather than figuring out\n // spacing token values, icon sizes, text widths, etc.\n //\n // TODO: Some of these values can be memoized to improve perf.\n const [responsiveState, containerQueryRef] = useContainerQuery<ResponsiveState>(() => {\n if (!mainRef?.current || !virtualRef.current) {\n return responsiveStates[0];\n }\n\n const sizeConfiguration = {\n hasSearch: !!search,\n\n // Get widths and paddings from the visible top navigation\n availableWidth: getContentBoxWidth(mainRef.current.querySelector(`.${styles['padding-box']}`)!),\n utilitiesLeftPadding: parseFloat(\n getComputedStyle(virtualRef.current.querySelector(`.${styles.utilities}`)!).paddingLeft\n ),\n\n // Get widths from the hidden top navigation\n fullIdentityWidth: virtualRef.current.querySelector(`.${styles.identity}`)!.getBoundingClientRect().width,\n titleWidth: virtualRef.current.querySelector(`.${styles.title}`)?.getBoundingClientRect().width ?? 0,\n searchSlotWidth: virtualRef.current.querySelector(`.${styles.search}`)?.getBoundingClientRect().width ?? 0,\n searchUtilityWidth: virtualRef.current.querySelector('[data-utility-special=\"search\"]')!.getBoundingClientRect()\n .width,\n utilityWithLabelWidths: Array.prototype.slice\n .call(virtualRef.current.querySelectorAll(`[data-utility-hide=\"false\"]`))\n .map((element: Element) => element.getBoundingClientRect().width),\n utilityWithoutLabelWidths: Array.prototype.slice\n .call(virtualRef.current.querySelectorAll(`[data-utility-hide=\"true\"]`))\n .map((element: Element) => element.getBoundingClientRect().width),\n menuTriggerUtilityWidth: virtualRef.current\n .querySelector('[data-utility-special=\"menu-trigger\"]')!\n .getBoundingClientRect().width,\n };\n\n return determineBestResponsiveState(responsiveStates, sizeConfiguration);\n }, [mainRef, search, responsiveStates]);\n\n // Search slot expansion on small screens\n const [isSearchMinimized, setSearchMinimized] = useState(true);\n const isSearchExpanded = !isSearchMinimized && breakpoint !== 's' && hasSearch && responsiveState?.hideSearch;\n\n // If the search was expanded, and then the screen resized so that the\n // expansion is no longer necessary. So we implicitly minimize it.\n useEffect(() => {\n if (!responsiveState?.hideSearch) {\n setSearchMinimized(true);\n }\n }, [responsiveState]);\n\n // If the search is expanded after clicking on the search utility, move\n // the focus to the input. Since this is a user-controlled slot, we're just\n // assuming that it contains an input, though it's a pretty safe guess.\n useEffect(() => {\n if (isSearchExpanded) {\n mainRef?.current?.querySelector<HTMLInputElement>(`.${styles.search} input`)?.focus();\n }\n }, [isSearchExpanded, mainRef]);\n\n const mergedRef = useMergeRefs(...(mainRef ? [mainRef] : []), containerQueryRef, breakpointRef);\n\n return {\n ref: mergedRef,\n virtualRef: virtualRef,\n responsiveState: responsiveState ?? responsiveStates[0],\n breakpoint: breakpoint ?? 'default',\n isSearchExpanded: !!isSearchExpanded,\n onSearchUtilityClick: () => setSearchMinimized(isSearchMinimized => !isSearchMinimized),\n };\n}\n\n/**\n * Get the width of the content box (assuming the element's box-sizing is border-box).\n */\nfunction getContentBoxWidth(element: Element): number {\n const style = getComputedStyle(element);\n return parseFloat(style.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);\n}\n\n/**\n * Generates the series of responsive steps that can be performed on the header in order.\n */\nexport function generateResponsiveStateKeys(\n utilities: ReadonlyArray<TopNavigationProps.Utility>,\n canHideSearch: boolean,\n canHideTitle: boolean\n): ReadonlyArray<ResponsiveState> {\n const states: ResponsiveState[] = [{}];\n if (utilities.some(utility => utility.text)) {\n states.push({ hideUtilityText: true });\n }\n if (canHideSearch) {\n states.push({\n hideUtilityText: true,\n hideSearch: true,\n });\n }\n const hiddenUtilties = [];\n for (let i = 0; i < utilities.length; i++) {\n if (!utilities[i].disableUtilityCollapse) {\n hiddenUtilties.push(i);\n states.push({\n hideUtilityText: true,\n hideSearch: canHideSearch || undefined,\n hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,\n });\n }\n }\n if (canHideTitle) {\n states.push({\n hideUtilityText: true,\n hideSearch: canHideSearch || undefined,\n hideUtilities: hiddenUtilties.length > 0 ? hiddenUtilties.slice() : undefined,\n hideTitle: true,\n });\n }\n return states;\n}\n\n/**\n * Determines the best responsive state configuration of the top navigation, based on the given list of possible responsive states\n * and the current sizes of all elements inside the navigation bar.\n */\nexport function determineBestResponsiveState(\n possibleStates: ReadonlyArray<ResponsiveState>,\n sizes: TopNavigationSizeConfiguration\n): ResponsiveState {\n const {\n hasSearch,\n availableWidth,\n utilitiesLeftPadding,\n fullIdentityWidth,\n titleWidth,\n searchSlotWidth,\n searchUtilityWidth,\n utilityWithLabelWidths,\n utilityWithoutLabelWidths,\n menuTriggerUtilityWidth,\n } = sizes;\n // Iterate through each state and calculate its expected required width.\n for (const state of possibleStates) {\n const searchWidth = hasSearch ? (state.hideSearch ? searchUtilityWidth : searchSlotWidth) : 0;\n const utilitiesWidth: number = (state.hideUtilityText ? utilityWithoutLabelWidths : utilityWithLabelWidths)\n .filter((_width, i) => !state.hideUtilities || state.hideUtilities.indexOf(i) === -1)\n .reduce((sum, width) => sum + width, 0);\n const menuTriggerWidth = state.hideUtilities ? menuTriggerUtilityWidth : 0;\n const identityWidth = state.hideTitle ? fullIdentityWidth - titleWidth : fullIdentityWidth;\n const expectedInnerWidth = identityWidth + searchWidth + utilitiesLeftPadding + utilitiesWidth + menuTriggerWidth;\n if (expectedInnerWidth <= availableWidth - RESPONSIVENESS_BUFFER) {\n return state;\n }\n }\n\n // If nothing matches, pick the smallest possible state.\n return possibleStates[possibleStates.length - 1];\n}\n"]}
|
package/top-navigation/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React from 'react';
|
|
@@ -6,9 +6,9 @@ import { applyDisplayName } from '../internal/utils/apply-display-name';
|
|
|
6
6
|
import useBaseComponent from '../internal/hooks/use-base-component';
|
|
7
7
|
import InternalTopNavigation from './internal';
|
|
8
8
|
export default function TopNavigation(_a) {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
return React.createElement(InternalTopNavigation,
|
|
9
|
+
var { utilities = [] } = _a, restProps = __rest(_a, ["utilities"]);
|
|
10
|
+
const baseComponentProps = useBaseComponent('TopNavigation');
|
|
11
|
+
return React.createElement(InternalTopNavigation, Object.assign({}, baseComponentProps, { utilities: utilities }, restProps));
|
|
12
12
|
}
|
|
13
13
|
applyDisplayName(TopNavigation, 'TopNavigation');
|
|
14
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/top-navigation/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,qBAAqB,MAAM,YAAY,CAAC;AAI/C,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAoD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/top-navigation/index.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AAEpE,OAAO,qBAAqB,MAAM,YAAY,CAAC;AAI/C,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EAAoD;QAApD,EAAE,SAAS,GAAG,EAAE,OAAoC,EAA/B,SAAS,cAA9B,aAAgC,CAAF;IAClE,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC7D,OAAO,oBAAC,qBAAqB,oBAAK,kBAAkB,IAAE,SAAS,EAAE,SAAS,IAAM,SAAS,EAAI,CAAC;AAChG,CAAC;AAED,gBAAgB,CAAC,aAAa,EAAE,eAAe,CAAC,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 { applyDisplayName } from '../internal/utils/apply-display-name';\nimport useBaseComponent from '../internal/hooks/use-base-component';\nimport { TopNavigationProps } from './interfaces';\nimport InternalTopNavigation from './internal';\n\nexport { TopNavigationProps };\n\nexport default function TopNavigation({ utilities = [], ...restProps }: TopNavigationProps) {\n const baseComponentProps = useBaseComponent('TopNavigation');\n return <InternalTopNavigation {...baseComponentProps} utilities={utilities} {...restProps} />;\n}\n\napplyDisplayName(TopNavigation, 'TopNavigation');\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
2
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
@@ -16,29 +16,29 @@ import { ButtonTrigger } from '../internal/components/menu-dropdown';
|
|
|
16
16
|
import styles from './styles.css.js';
|
|
17
17
|
import { checkSafeUrl } from '../internal/utils/check-safe-url';
|
|
18
18
|
export default function InternalTopNavigation(_a) {
|
|
19
|
-
var
|
|
19
|
+
var { __internalRootRef, identity, i18nStrings, utilities, search } = _a, restProps = __rest(_a, ["__internalRootRef", "identity", "i18nStrings", "utilities", "search"]);
|
|
20
20
|
checkSafeUrl('TopNavigation', identity.href);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
const baseProps = getBaseProps(restProps);
|
|
22
|
+
const { mainRef, virtualRef, breakpoint, responsiveState, isSearchExpanded, onSearchUtilityClick } = useTopNavigation({ identity, search, utilities });
|
|
23
|
+
const [overflowMenuOpen, setOverflowMenuOpen] = useState(false);
|
|
24
|
+
const overflowMenuTriggerRef = useRef(null);
|
|
25
|
+
const isNarrowViewport = breakpoint === 'default';
|
|
26
|
+
const isMediumViewport = breakpoint === 'xxs';
|
|
27
|
+
const isLargeViewport = breakpoint === 's';
|
|
28
|
+
const onIdentityClick = (event) => {
|
|
29
29
|
if (isPlainLeftClick(event)) {
|
|
30
30
|
fireCancelableEvent(identity.onFollow, {}, event);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
setOverflowMenuOpen(
|
|
33
|
+
const toggleOverflowMenu = () => {
|
|
34
|
+
setOverflowMenuOpen(overflowMenuOpen => !overflowMenuOpen);
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
useEffect(
|
|
36
|
+
const focusVisible = useFocusVisible();
|
|
37
|
+
const menuTriggerVisible = !isSearchExpanded && responsiveState.hideUtilities;
|
|
38
|
+
useEffect(() => {
|
|
39
39
|
setOverflowMenuOpen(false);
|
|
40
40
|
}, [menuTriggerVisible]);
|
|
41
|
-
useEffectOnUpdate(
|
|
41
|
+
useEffectOnUpdate(() => {
|
|
42
42
|
var _a;
|
|
43
43
|
if (!overflowMenuOpen) {
|
|
44
44
|
(_a = overflowMenuTriggerRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
@@ -47,91 +47,84 @@ export default function InternalTopNavigation(_a) {
|
|
|
47
47
|
// Render the top nav twice; once as the top nav that users can see, and another
|
|
48
48
|
// "virtual" top nav used just for calculations. The virtual top nav doesn't react to
|
|
49
49
|
// layout changes and renders two sets of utilities: one with labels and one without.
|
|
50
|
-
|
|
51
|
-
var _a, _b
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var showMenuTrigger = isVirtual || menuTriggerVisible;
|
|
50
|
+
const content = (isVirtual) => {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const Wrapper = isVirtual ? 'div' : 'header';
|
|
53
|
+
const showIdentity = isVirtual || !isSearchExpanded;
|
|
54
|
+
const showTitle = isVirtual || !responsiveState.hideTitle;
|
|
55
|
+
const showSearchSlot = search && (isVirtual || !responsiveState.hideSearch || isSearchExpanded);
|
|
56
|
+
const showSearchUtility = isVirtual || (search && responsiveState.hideSearch);
|
|
57
|
+
const showUtilities = isVirtual || !isSearchExpanded;
|
|
58
|
+
const showMenuTrigger = isVirtual || menuTriggerVisible;
|
|
60
59
|
return (React.createElement(Wrapper, { ref: isVirtual ? virtualRef : mainRef, "aria-hidden": isVirtual ? true : undefined,
|
|
61
60
|
// Wrapper is an alias for "div" or "header".
|
|
62
61
|
// eslint-disable-next-line react/forbid-component-props
|
|
63
|
-
className: clsx(styles['top-navigation'],
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
className: clsx(styles['top-navigation'], {
|
|
63
|
+
[styles.virtual]: isVirtual,
|
|
64
|
+
[styles.hidden]: isVirtual,
|
|
65
|
+
[styles.narrow]: isNarrowViewport,
|
|
66
|
+
[styles.medium]: isMediumViewport,
|
|
67
|
+
}) },
|
|
69
68
|
React.createElement("div", { className: styles['padding-box'] },
|
|
70
69
|
showIdentity && (React.createElement("div", { className: clsx(styles.identity, !identity.logo && styles['no-logo']) },
|
|
71
|
-
React.createElement("a",
|
|
72
|
-
identity.logo && (React.createElement("img", { role: "img", src: (
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
React.createElement("a", Object.assign({}, focusVisible, { className: styles['identity-link'], href: identity.href, onClick: onIdentityClick }),
|
|
71
|
+
identity.logo && (React.createElement("img", { role: "img", src: (_a = identity.logo) === null || _a === void 0 ? void 0 : _a.src, alt: (_b = identity.logo) === null || _b === void 0 ? void 0 : _b.alt, className: clsx(styles.logo, {
|
|
72
|
+
[styles.narrow]: isNarrowViewport,
|
|
73
|
+
}) })),
|
|
75
74
|
showTitle && React.createElement("span", { className: styles.title }, identity.title)))),
|
|
76
75
|
showSearchSlot && (React.createElement("div", { className: styles.inputs },
|
|
77
76
|
React.createElement("div", { className: clsx(styles.search, !isVirtual && isSearchExpanded && styles['search-expanded']) }, search))),
|
|
78
77
|
React.createElement("div", { className: styles.utilities },
|
|
79
|
-
showSearchUtility && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-button'], styles['utility-type-button-link'],
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
78
|
+
showSearchUtility && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-button'], styles['utility-type-button-link'], {
|
|
79
|
+
[styles.narrow]: isNarrowViewport,
|
|
80
|
+
[styles.medium]: isMediumViewport,
|
|
81
|
+
}), "data-utility-special": "search" },
|
|
83
82
|
React.createElement(Utility, { hideText: true, definition: {
|
|
84
83
|
type: 'button',
|
|
85
84
|
iconName: isSearchExpanded ? 'close' : 'search',
|
|
86
85
|
ariaLabel: isSearchExpanded
|
|
87
86
|
? i18nStrings.searchDismissIconAriaLabel
|
|
88
87
|
: i18nStrings.searchIconAriaLabel,
|
|
89
|
-
onClick: onSearchUtilityClick
|
|
88
|
+
onClick: onSearchUtilityClick,
|
|
90
89
|
} }))),
|
|
91
90
|
showUtilities &&
|
|
92
91
|
utilities
|
|
93
|
-
.filter(
|
|
94
|
-
|
|
95
|
-
})
|
|
96
|
-
.map(function (utility, i) {
|
|
92
|
+
.filter((_utility, i) => isVirtual || !responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) === -1)
|
|
93
|
+
.map((utility, i) => {
|
|
97
94
|
var _a;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_a)), "data-utility-index": i, "data-utility-hide": "".concat(hideText) },
|
|
95
|
+
const hideText = !!responsiveState.hideUtilityText;
|
|
96
|
+
const isLast = (isVirtual || !showMenuTrigger) && i === utilities.length - 1;
|
|
97
|
+
const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;
|
|
98
|
+
return (React.createElement("div", { key: i, className: clsx(styles['utility-wrapper'], styles[`utility-type-${utility.type}`], utility.type === 'button' && styles[`utility-type-button-${(_a = utility.variant) !== null && _a !== void 0 ? _a : 'link'}`], {
|
|
99
|
+
[styles.narrow]: isNarrowViewport,
|
|
100
|
+
[styles.medium]: isMediumViewport,
|
|
101
|
+
}), "data-utility-index": i, "data-utility-hide": `${hideText}` },
|
|
106
102
|
React.createElement(Utility, { hideText: hideText, definition: utility, offsetRight: offsetRight })));
|
|
107
103
|
}),
|
|
108
104
|
isVirtual &&
|
|
109
|
-
utilities.map(
|
|
105
|
+
utilities.map((utility, i) => {
|
|
110
106
|
var _a;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
_a)), "data-utility-index": i, "data-utility-hide": "".concat(hideText) },
|
|
107
|
+
const hideText = !responsiveState.hideUtilityText;
|
|
108
|
+
const isLast = !showMenuTrigger && i === utilities.length - 1;
|
|
109
|
+
const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;
|
|
110
|
+
return (React.createElement("div", { key: i, className: clsx(styles['utility-wrapper'], styles[`utility-type-${utility.type}`], utility.type === 'button' && styles[`utility-type-button-${(_a = utility.variant) !== null && _a !== void 0 ? _a : 'link'}`], {
|
|
111
|
+
[styles.narrow]: isNarrowViewport,
|
|
112
|
+
[styles.medium]: isMediumViewport,
|
|
113
|
+
}), "data-utility-index": i, "data-utility-hide": `${hideText}` },
|
|
119
114
|
React.createElement(Utility, { hideText: hideText, definition: utility, offsetRight: offsetRight })));
|
|
120
115
|
}),
|
|
121
|
-
showMenuTrigger && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-menu-dropdown'],
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
showMenuTrigger && (React.createElement("div", { className: clsx(styles['utility-wrapper'], styles['utility-type-menu-dropdown'], {
|
|
117
|
+
[styles.narrow]: isNarrowViewport,
|
|
118
|
+
[styles.medium]: isMediumViewport,
|
|
119
|
+
}), "data-utility-special": "menu-trigger" },
|
|
125
120
|
React.createElement(ButtonTrigger, { expanded: overflowMenuOpen, onClick: toggleOverflowMenu, offsetRight: "l", ref: !isVirtual ? overflowMenuTriggerRef : undefined }, i18nStrings.overflowMenuTriggerText)))))));
|
|
126
121
|
};
|
|
127
|
-
return (React.createElement("div",
|
|
122
|
+
return (React.createElement("div", Object.assign({}, baseProps, { ref: __internalRootRef }),
|
|
128
123
|
React.createElement(VisualContext, { contextName: "top-navigation" },
|
|
129
124
|
content(false),
|
|
130
125
|
React.createElement(Portal, null, content(true)),
|
|
131
126
|
menuTriggerVisible && overflowMenuOpen && (React.createElement("div", { className: styles['overflow-menu-drawer'] },
|
|
132
|
-
React.createElement(OverflowMenu, { headerText: i18nStrings.overflowMenuTitleText, dismissIconAriaLabel: i18nStrings.overflowMenuDismissIconAriaLabel, backIconAriaLabel: i18nStrings.overflowMenuBackIconAriaLabel, items: utilities.filter(
|
|
133
|
-
|
|
134
|
-
!utility.disableUtilityCollapse;
|
|
135
|
-
}), onClose: toggleOverflowMenu }))))));
|
|
127
|
+
React.createElement(OverflowMenu, { headerText: i18nStrings.overflowMenuTitleText, dismissIconAriaLabel: i18nStrings.overflowMenuDismissIconAriaLabel, backIconAriaLabel: i18nStrings.overflowMenuBackIconAriaLabel, items: utilities.filter((utility, i) => (!responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) !== -1) &&
|
|
128
|
+
!utility.disableUtilityCollapse), onClose: toggleOverflowMenu }))))));
|
|
136
129
|
}
|
|
137
130
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/top-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAG3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,OAAO,MAAM,iBAAiB,CAAC;AACtC,OAAO,YAAY,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAErE,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,O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ACE,CACP,CACa,CACZ,CACP,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';\nimport clsx from 'clsx';\n\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport VisualContext from '../internal/components/visual-context';\nimport Portal from '../internal/components/portal';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\n\nimport { TopNavigationProps } from './interfaces';\nimport { useTopNavigation } from './use-top-navigation.js';\nimport Utility from './parts/utility';\nimport OverflowMenu from './parts/overflow-menu';\nimport { ButtonTrigger } from '../internal/components/menu-dropdown';\n\nimport styles from './styles.css.js';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { SomeRequired } from '../internal/types';\n\nexport type InternalTopNavigationProps = SomeRequired<TopNavigationProps, 'utilities'> & InternalBaseComponentProps;\n\nexport default function InternalTopNavigation({\n __internalRootRef,\n identity,\n i18nStrings,\n utilities,\n search,\n ...restProps\n}: InternalTopNavigationProps) {\n checkSafeUrl('TopNavigation', identity.href);\n const baseProps = getBaseProps(restProps);\n const { mainRef, virtualRef, breakpoint, responsiveState, isSearchExpanded, onSearchUtilityClick } = useTopNavigation(\n { identity, search, utilities }\n );\n const [overflowMenuOpen, setOverflowMenuOpen] = useState(false);\n const overflowMenuTriggerRef = useRef<HTMLButtonElement>(null);\n const isNarrowViewport = breakpoint === 'default';\n const isMediumViewport = breakpoint === 'xxs';\n const isLargeViewport = breakpoint === 's';\n\n const onIdentityClick = (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireCancelableEvent(identity.onFollow, {}, event);\n }\n };\n\n const toggleOverflowMenu = () => {\n setOverflowMenuOpen(overflowMenuOpen => !overflowMenuOpen);\n };\n\n const focusVisible = useFocusVisible();\n const menuTriggerVisible = !isSearchExpanded && responsiveState.hideUtilities;\n\n useEffect(() => {\n setOverflowMenuOpen(false);\n }, [menuTriggerVisible]);\n\n useEffectOnUpdate(() => {\n if (!overflowMenuOpen) {\n overflowMenuTriggerRef.current?.focus();\n }\n }, [overflowMenuOpen]);\n\n // Render the top nav twice; once as the top nav that users can see, and another\n // \"virtual\" top nav used just for calculations. The virtual top nav doesn't react to\n // layout changes and renders two sets of utilities: one with labels and one without.\n const content = (isVirtual: boolean) => {\n const Wrapper = isVirtual ? 'div' : 'header';\n const showIdentity = isVirtual || !isSearchExpanded;\n const showTitle = isVirtual || !responsiveState.hideTitle;\n const showSearchSlot = search && (isVirtual || !responsiveState.hideSearch || isSearchExpanded);\n const showSearchUtility = isVirtual || (search && responsiveState.hideSearch);\n const showUtilities = isVirtual || !isSearchExpanded;\n const showMenuTrigger = isVirtual || menuTriggerVisible;\n\n return (\n <Wrapper\n ref={isVirtual ? virtualRef : mainRef}\n aria-hidden={isVirtual ? true : undefined}\n // Wrapper is an alias for \"div\" or \"header\".\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(styles['top-navigation'], {\n [styles.virtual]: isVirtual,\n [styles.hidden]: isVirtual,\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n })}\n >\n <div className={styles['padding-box']}>\n {showIdentity && (\n <div className={clsx(styles.identity, !identity.logo && styles['no-logo'])}>\n <a {...focusVisible} className={styles['identity-link']} href={identity.href} onClick={onIdentityClick}>\n {identity.logo && (\n <img\n role=\"img\"\n src={identity.logo?.src}\n alt={identity.logo?.alt}\n className={clsx(styles.logo, {\n [styles.narrow]: isNarrowViewport,\n })}\n />\n )}\n {showTitle && <span className={styles.title}>{identity.title}</span>}\n </a>\n </div>\n )}\n\n {showSearchSlot && (\n <div className={styles.inputs}>\n <div className={clsx(styles.search, !isVirtual && isSearchExpanded && styles['search-expanded'])}>\n {search}\n </div>\n </div>\n )}\n\n <div className={styles.utilities}>\n {showSearchUtility && (\n <div\n className={clsx(\n styles['utility-wrapper'],\n styles['utility-type-button'],\n styles['utility-type-button-link'],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-special=\"search\"\n >\n <Utility\n hideText={true}\n definition={{\n type: 'button',\n iconName: isSearchExpanded ? 'close' : 'search',\n ariaLabel: isSearchExpanded\n ? i18nStrings.searchDismissIconAriaLabel\n : i18nStrings.searchIconAriaLabel,\n onClick: onSearchUtilityClick,\n }}\n />\n </div>\n )}\n\n {showUtilities &&\n utilities\n .filter(\n (_utility, i) =>\n isVirtual || !responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) === -1\n )\n .map((utility, i) => {\n const hideText = !!responsiveState.hideUtilityText;\n const isLast = (isVirtual || !showMenuTrigger) && i === utilities.length - 1;\n const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;\n\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility hideText={hideText} definition={utility} offsetRight={offsetRight} />\n </div>\n );\n })}\n\n {isVirtual &&\n utilities.map((utility, i) => {\n const hideText = !responsiveState.hideUtilityText;\n const isLast = !showMenuTrigger && i === utilities.length - 1;\n const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;\n\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility hideText={hideText} definition={utility} offsetRight={offsetRight} />\n </div>\n );\n })}\n\n {showMenuTrigger && (\n <div\n className={clsx(styles['utility-wrapper'], styles['utility-type-menu-dropdown'], {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n })}\n data-utility-special=\"menu-trigger\"\n >\n <ButtonTrigger\n expanded={overflowMenuOpen}\n onClick={toggleOverflowMenu}\n offsetRight=\"l\"\n ref={!isVirtual ? overflowMenuTriggerRef : undefined}\n >\n {i18nStrings.overflowMenuTriggerText}\n </ButtonTrigger>\n </div>\n )}\n </div>\n </div>\n </Wrapper>\n );\n };\n\n return (\n <div {...baseProps} ref={__internalRootRef}>\n <VisualContext contextName=\"top-navigation\">\n {content(false)}\n <Portal>{content(true)}</Portal>\n {menuTriggerVisible && overflowMenuOpen && (\n <div className={styles['overflow-menu-drawer']}>\n <OverflowMenu\n headerText={i18nStrings.overflowMenuTitleText}\n dismissIconAriaLabel={i18nStrings.overflowMenuDismissIconAriaLabel}\n backIconAriaLabel={i18nStrings.overflowMenuBackIconAriaLabel}\n items={utilities.filter(\n (utility, i) =>\n (!responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) !== -1) &&\n !utility.disableUtilityCollapse\n )}\n onClose={toggleOverflowMenu}\n />\n </div>\n )}\n </VisualContext>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/top-navigation/internal.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,sCAAsC;AACtC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,aAAa,MAAM,uCAAuC,CAAC;AAClE,OAAO,MAAM,MAAM,+BAA+B,CAAC;A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sB,CAAC;gBAC5C,oBAAC,YAAY,IACX,UAAU,EAAE,WAAW,CAAC,qBAAqB,EAC7C,oBAAoB,EAAE,WAAW,CAAC,gCAAgC,EAClE,iBAAiB,EAAE,WAAW,CAAC,6BAA6B,EAC5D,KAAK,EAAE,SAAS,CAAC,MAAM,CACrB,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CACb,CAAC,CAAC,eAAe,CAAC,aAAa,IAAI,eAAe,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;wBACnF,CAAC,OAAO,CAAC,sBAAsB,CAClC,EACD,OAAO,EAAE,kBAAkB,GAC3B,CACE,CACP,CACa,CACZ,CACP,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';\nimport clsx from 'clsx';\n\nimport { InternalBaseComponentProps } from '../internal/hooks/use-base-component';\nimport { getBaseProps } from '../internal/base-component';\nimport { fireCancelableEvent, isPlainLeftClick } from '../internal/events';\nimport VisualContext from '../internal/components/visual-context';\nimport Portal from '../internal/components/portal';\nimport useFocusVisible from '../internal/hooks/focus-visible';\nimport { useEffectOnUpdate } from '../internal/hooks/use-effect-on-update';\n\nimport { TopNavigationProps } from './interfaces';\nimport { useTopNavigation } from './use-top-navigation.js';\nimport Utility from './parts/utility';\nimport OverflowMenu from './parts/overflow-menu';\nimport { ButtonTrigger } from '../internal/components/menu-dropdown';\n\nimport styles from './styles.css.js';\nimport { checkSafeUrl } from '../internal/utils/check-safe-url';\nimport { SomeRequired } from '../internal/types';\n\nexport type InternalTopNavigationProps = SomeRequired<TopNavigationProps, 'utilities'> & InternalBaseComponentProps;\n\nexport default function InternalTopNavigation({\n __internalRootRef,\n identity,\n i18nStrings,\n utilities,\n search,\n ...restProps\n}: InternalTopNavigationProps) {\n checkSafeUrl('TopNavigation', identity.href);\n const baseProps = getBaseProps(restProps);\n const { mainRef, virtualRef, breakpoint, responsiveState, isSearchExpanded, onSearchUtilityClick } = useTopNavigation(\n { identity, search, utilities }\n );\n const [overflowMenuOpen, setOverflowMenuOpen] = useState(false);\n const overflowMenuTriggerRef = useRef<HTMLButtonElement>(null);\n const isNarrowViewport = breakpoint === 'default';\n const isMediumViewport = breakpoint === 'xxs';\n const isLargeViewport = breakpoint === 's';\n\n const onIdentityClick = (event: React.MouseEvent) => {\n if (isPlainLeftClick(event)) {\n fireCancelableEvent(identity.onFollow, {}, event);\n }\n };\n\n const toggleOverflowMenu = () => {\n setOverflowMenuOpen(overflowMenuOpen => !overflowMenuOpen);\n };\n\n const focusVisible = useFocusVisible();\n const menuTriggerVisible = !isSearchExpanded && responsiveState.hideUtilities;\n\n useEffect(() => {\n setOverflowMenuOpen(false);\n }, [menuTriggerVisible]);\n\n useEffectOnUpdate(() => {\n if (!overflowMenuOpen) {\n overflowMenuTriggerRef.current?.focus();\n }\n }, [overflowMenuOpen]);\n\n // Render the top nav twice; once as the top nav that users can see, and another\n // \"virtual\" top nav used just for calculations. The virtual top nav doesn't react to\n // layout changes and renders two sets of utilities: one with labels and one without.\n const content = (isVirtual: boolean) => {\n const Wrapper = isVirtual ? 'div' : 'header';\n const showIdentity = isVirtual || !isSearchExpanded;\n const showTitle = isVirtual || !responsiveState.hideTitle;\n const showSearchSlot = search && (isVirtual || !responsiveState.hideSearch || isSearchExpanded);\n const showSearchUtility = isVirtual || (search && responsiveState.hideSearch);\n const showUtilities = isVirtual || !isSearchExpanded;\n const showMenuTrigger = isVirtual || menuTriggerVisible;\n\n return (\n <Wrapper\n ref={isVirtual ? virtualRef : mainRef}\n aria-hidden={isVirtual ? true : undefined}\n // Wrapper is an alias for \"div\" or \"header\".\n // eslint-disable-next-line react/forbid-component-props\n className={clsx(styles['top-navigation'], {\n [styles.virtual]: isVirtual,\n [styles.hidden]: isVirtual,\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n })}\n >\n <div className={styles['padding-box']}>\n {showIdentity && (\n <div className={clsx(styles.identity, !identity.logo && styles['no-logo'])}>\n <a {...focusVisible} className={styles['identity-link']} href={identity.href} onClick={onIdentityClick}>\n {identity.logo && (\n <img\n role=\"img\"\n src={identity.logo?.src}\n alt={identity.logo?.alt}\n className={clsx(styles.logo, {\n [styles.narrow]: isNarrowViewport,\n })}\n />\n )}\n {showTitle && <span className={styles.title}>{identity.title}</span>}\n </a>\n </div>\n )}\n\n {showSearchSlot && (\n <div className={styles.inputs}>\n <div className={clsx(styles.search, !isVirtual && isSearchExpanded && styles['search-expanded'])}>\n {search}\n </div>\n </div>\n )}\n\n <div className={styles.utilities}>\n {showSearchUtility && (\n <div\n className={clsx(\n styles['utility-wrapper'],\n styles['utility-type-button'],\n styles['utility-type-button-link'],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-special=\"search\"\n >\n <Utility\n hideText={true}\n definition={{\n type: 'button',\n iconName: isSearchExpanded ? 'close' : 'search',\n ariaLabel: isSearchExpanded\n ? i18nStrings.searchDismissIconAriaLabel\n : i18nStrings.searchIconAriaLabel,\n onClick: onSearchUtilityClick,\n }}\n />\n </div>\n )}\n\n {showUtilities &&\n utilities\n .filter(\n (_utility, i) =>\n isVirtual || !responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) === -1\n )\n .map((utility, i) => {\n const hideText = !!responsiveState.hideUtilityText;\n const isLast = (isVirtual || !showMenuTrigger) && i === utilities.length - 1;\n const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;\n\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility hideText={hideText} definition={utility} offsetRight={offsetRight} />\n </div>\n );\n })}\n\n {isVirtual &&\n utilities.map((utility, i) => {\n const hideText = !responsiveState.hideUtilityText;\n const isLast = !showMenuTrigger && i === utilities.length - 1;\n const offsetRight = isLast && isLargeViewport ? 'xxl' : isLast ? 'l' : undefined;\n\n return (\n <div\n key={i}\n className={clsx(\n styles['utility-wrapper'],\n styles[`utility-type-${utility.type}`],\n utility.type === 'button' && styles[`utility-type-button-${utility.variant ?? 'link'}`],\n {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n }\n )}\n data-utility-index={i}\n data-utility-hide={`${hideText}`}\n >\n <Utility hideText={hideText} definition={utility} offsetRight={offsetRight} />\n </div>\n );\n })}\n\n {showMenuTrigger && (\n <div\n className={clsx(styles['utility-wrapper'], styles['utility-type-menu-dropdown'], {\n [styles.narrow]: isNarrowViewport,\n [styles.medium]: isMediumViewport,\n })}\n data-utility-special=\"menu-trigger\"\n >\n <ButtonTrigger\n expanded={overflowMenuOpen}\n onClick={toggleOverflowMenu}\n offsetRight=\"l\"\n ref={!isVirtual ? overflowMenuTriggerRef : undefined}\n >\n {i18nStrings.overflowMenuTriggerText}\n </ButtonTrigger>\n </div>\n )}\n </div>\n </div>\n </Wrapper>\n );\n };\n\n return (\n <div {...baseProps} ref={__internalRootRef}>\n <VisualContext contextName=\"top-navigation\">\n {content(false)}\n <Portal>{content(true)}</Portal>\n {menuTriggerVisible && overflowMenuOpen && (\n <div className={styles['overflow-menu-drawer']}>\n <OverflowMenu\n headerText={i18nStrings.overflowMenuTitleText}\n dismissIconAriaLabel={i18nStrings.overflowMenuDismissIconAriaLabel}\n backIconAriaLabel={i18nStrings.overflowMenuBackIconAriaLabel}\n items={utilities.filter(\n (utility, i) =>\n (!responsiveState.hideUtilities || responsiveState.hideUtilities.indexOf(i) !== -1) &&\n !utility.disableUtilityCollapse\n )}\n onClose={toggleOverflowMenu}\n />\n </div>\n )}\n </VisualContext>\n </div>\n );\n}\n"]}
|