@wordpress/components 25.7.0 → 25.8.1
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/CHANGELOG.md +66 -1
- package/build/animation/index.js +6 -0
- package/build/animation/index.js.map +1 -1
- package/build/border-control/border-control-dropdown/component.js +1 -1
- package/build/border-control/border-control-dropdown/component.js.map +1 -1
- package/build/border-control/styles.js +20 -20
- package/build/border-control/styles.js.map +1 -1
- package/build/box-control/unit-control.js +1 -1
- package/build/box-control/unit-control.js.map +1 -1
- package/build/button/index.js +9 -1
- package/build/button/index.js.map +1 -1
- package/build/button/types.js.map +1 -1
- package/build/circular-option-picker/circular-option-picker-actions.js +53 -0
- package/build/circular-option-picker/circular-option-picker-actions.js.map +1 -0
- package/build/circular-option-picker/circular-option-picker-context.js +14 -0
- package/build/circular-option-picker/circular-option-picker-context.js.map +1 -0
- package/build/circular-option-picker/circular-option-picker-option-group.js +26 -0
- package/build/circular-option-picker/circular-option-picker-option-group.js.map +1 -0
- package/build/circular-option-picker/circular-option-picker-option.js +122 -0
- package/build/circular-option-picker/circular-option-picker-option.js.map +1 -0
- package/build/circular-option-picker/circular-option-picker.js +172 -0
- package/build/circular-option-picker/circular-option-picker.js.map +1 -0
- package/build/circular-option-picker/index.js +29 -137
- package/build/circular-option-picker/index.js.map +1 -1
- package/build/circular-option-picker/types.js.map +1 -1
- package/build/color-palette/index.js +58 -19
- package/build/color-palette/index.js.map +1 -1
- package/build/color-palette/types.js.map +1 -1
- package/build/combobox-control/index.js +0 -3
- package/build/combobox-control/index.js.map +1 -1
- package/build/composite/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/date-time/time/index.js +6 -1
- package/build/date-time/time/index.js.map +1 -1
- package/build/date-time/time/timezone.js +1 -1
- package/build/date-time/time/timezone.js.map +1 -1
- package/build/dropdown/index.js +11 -23
- package/build/dropdown/index.js.map +1 -1
- package/build/dropdown/types.js.map +1 -1
- package/build/dropdown-menu/index.js +7 -1
- package/build/dropdown-menu/index.js.map +1 -1
- package/build/dropdown-menu/types.js.map +1 -1
- package/build/dropdown-menu-v2/styles.js +16 -16
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/duotone-picker/color-list-picker/index.js +18 -3
- package/build/duotone-picker/color-list-picker/index.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +33 -1
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/duotone-picker/types.js.map +1 -1
- package/build/focusable-iframe/index.js +0 -4
- package/build/focusable-iframe/index.js.map +1 -1
- package/build/focusable-iframe/types.js +6 -0
- package/build/focusable-iframe/types.js.map +1 -0
- package/build/form-token-field/index.js +6 -2
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/types.js.map +1 -1
- package/build/gradient-picker/index.js +57 -15
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js.map +1 -1
- package/build/higher-order/navigate-regions/index.js.map +1 -1
- package/build/higher-order/with-focus-outside/index.js +1 -2
- package/build/higher-order/with-focus-outside/index.js.map +1 -1
- package/build/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +22 -22
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/index.native.js +1 -0
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/index.native.js.map +1 -1
- package/build/modal/index.js +12 -3
- package/build/modal/index.js.map +1 -1
- package/build/modal/types.js.map +1 -1
- package/build/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build/notice/index.js +19 -7
- package/build/notice/index.js.map +1 -1
- package/build/palette-edit/styles.js +10 -10
- package/build/palette-edit/styles.js.map +1 -1
- package/build/placeholder/index.js +10 -4
- package/build/placeholder/index.js.map +1 -1
- package/build/popover/index.js +37 -83
- package/build/popover/index.js.map +1 -1
- package/build/popover/types.js.map +1 -1
- package/build/popover/utils.js +9 -41
- package/build/popover/utils.js.map +1 -1
- package/build/search-control/index.js +12 -3
- package/build/search-control/index.js.map +1 -1
- package/build/search-control/types.js.map +1 -1
- package/build/text/styles.js +7 -7
- package/build/text/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-button-group.js +30 -45
- package/build/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js +40 -41
- package/build/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +10 -5
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +9 -16
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/utils.js +44 -0
- package/build/toggle-group-control/toggle-group-control/utils.js.map +1 -0
- package/build/toggle-group-control/toggle-group-control-option-base/component.js +36 -17
- package/build/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +10 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/toggle-group-control/types.js.map +1 -1
- package/build/toolbar/toolbar/index.js +7 -1
- package/build/toolbar/toolbar/index.js.map +1 -1
- package/build/toolbar/toolbar-dropdown-menu/index.js +1 -3
- package/build/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
- package/build/toolbar/toolbar-group/index.js +16 -12
- package/build/toolbar/toolbar-group/index.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js +0 -2
- package/build/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
- package/build/toolbar/toolbar-group/toolbar-group-container.js +3 -1
- package/build/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
- package/build/toolbar/toolbar-group/types.js +6 -0
- package/build/toolbar/toolbar-group/types.js.map +1 -0
- package/build/toolbar/toolbar-item/index.js +1 -1
- package/build/toolbar/toolbar-item/index.js.map +1 -1
- package/build/tooltip/index.js +51 -225
- package/build/tooltip/index.js.map +1 -1
- package/build/tooltip/types.js +6 -0
- package/build/tooltip/types.js.map +1 -0
- package/build/ui/context/context-connect.js.map +1 -1
- package/build/ui/context/wordpress-component.js.map +1 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +7 -7
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/utils/colors-values.js +1 -1
- package/build/utils/colors-values.js.map +1 -1
- package/build/utils/use-deprecated-props.js.map +1 -1
- package/build-module/animation/index.js +1 -1
- package/build-module/animation/index.js.map +1 -1
- package/build-module/border-control/border-control-dropdown/component.js +1 -1
- package/build-module/border-control/border-control-dropdown/component.js.map +1 -1
- package/build-module/border-control/styles.js +20 -20
- package/build-module/border-control/styles.js.map +1 -1
- package/build-module/box-control/unit-control.js +1 -1
- package/build-module/box-control/unit-control.js.map +1 -1
- package/build-module/button/index.js +9 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/types.js.map +1 -1
- package/build-module/circular-option-picker/circular-option-picker-actions.js +44 -0
- package/build-module/circular-option-picker/circular-option-picker-actions.js.map +1 -0
- package/build-module/circular-option-picker/circular-option-picker-context.js +11 -0
- package/build-module/circular-option-picker/circular-option-picker-context.js.map +1 -0
- package/build-module/circular-option-picker/circular-option-picker-option-group.js +23 -0
- package/build-module/circular-option-picker/circular-option-picker-option-group.js.map +1 -0
- package/build-module/circular-option-picker/circular-option-picker-option.js +114 -0
- package/build-module/circular-option-picker/circular-option-picker-option.js.map +1 -0
- package/build-module/circular-option-picker/circular-option-picker.js +165 -0
- package/build-module/circular-option-picker/circular-option-picker.js.map +1 -0
- package/build-module/circular-option-picker/index.js +4 -132
- package/build-module/circular-option-picker/index.js.map +1 -1
- package/build-module/circular-option-picker/types.js.map +1 -1
- package/build-module/color-palette/index.js +58 -19
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-palette/types.js.map +1 -1
- package/build-module/combobox-control/index.js +0 -3
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/composite/index.js +2 -0
- package/build-module/composite/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/date-time/time/index.js +6 -1
- package/build-module/date-time/time/index.js.map +1 -1
- package/build-module/date-time/time/timezone.js +1 -1
- package/build-module/date-time/time/timezone.js.map +1 -1
- package/build-module/dropdown/index.js +12 -24
- package/build-module/dropdown/index.js.map +1 -1
- package/build-module/dropdown/types.js.map +1 -1
- package/build-module/dropdown-menu/index.js +7 -1
- package/build-module/dropdown-menu/index.js.map +1 -1
- package/build-module/dropdown-menu/types.js.map +1 -1
- package/build-module/dropdown-menu-v2/styles.js +16 -16
- package/build-module/dropdown-menu-v2/styles.js.map +1 -1
- package/build-module/duotone-picker/color-list-picker/index.js +18 -3
- package/build-module/duotone-picker/color-list-picker/index.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +33 -1
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/duotone-picker/types.js.map +1 -1
- package/build-module/focusable-iframe/index.js +2 -3
- package/build-module/focusable-iframe/index.js.map +1 -1
- package/build-module/focusable-iframe/types.js +2 -0
- package/build-module/focusable-iframe/types.js.map +1 -0
- package/build-module/form-token-field/index.js +6 -2
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/types.js.map +1 -1
- package/build-module/gradient-picker/index.js +57 -15
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js.map +1 -1
- package/build-module/higher-order/navigate-regions/index.js.map +1 -1
- package/build-module/higher-order/with-focus-outside/index.js +1 -3
- package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
- package/build-module/higher-order/with-spoken-messages/index.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +23 -23
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/index.native.js +1 -0
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/index.native.js.map +1 -1
- package/build-module/modal/index.js +12 -3
- package/build-module/modal/index.js.map +1 -1
- package/build-module/modal/types.js.map +1 -1
- package/build-module/navigation/use-navigation-tree-nodes.js.map +1 -1
- package/build-module/notice/index.js +19 -7
- package/build-module/notice/index.js.map +1 -1
- package/build-module/palette-edit/styles.js +10 -10
- package/build-module/palette-edit/styles.js.map +1 -1
- package/build-module/placeholder/index.js +11 -4
- package/build-module/placeholder/index.js.map +1 -1
- package/build-module/popover/index.js +38 -84
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/types.js.map +1 -1
- package/build-module/popover/utils.js +8 -39
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/search-control/index.js +12 -3
- package/build-module/search-control/index.js.map +1 -1
- package/build-module/search-control/types.js.map +1 -1
- package/build-module/text/styles.js +7 -7
- package/build-module/text/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.js +32 -47
- package/build-module/toggle-group-control/toggle-group-control/as-button-group.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js +41 -42
- package/build-module/toggle-group-control/toggle-group-control/as-radio-group.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +10 -6
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/styles.js +8 -14
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/utils.js +42 -0
- package/build-module/toggle-group-control/toggle-group-control/utils.js.map +1 -0
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js +35 -16
- package/build-module/toggle-group-control/toggle-group-control-option-base/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +8 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/toggle-group-control/types.js.map +1 -1
- package/build-module/toolbar/toolbar/index.js +7 -1
- package/build-module/toolbar/toolbar/index.js.map +1 -1
- package/build-module/toolbar/toolbar-dropdown-menu/index.js +5 -3
- package/build-module/toolbar/toolbar-dropdown-menu/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/index.js +15 -12
- package/build-module/toolbar/toolbar-group/index.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js +0 -2
- package/build-module/toolbar/toolbar-group/toolbar-group-collapsed.js.map +1 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js +3 -1
- package/build-module/toolbar/toolbar-group/toolbar-group-container.js.map +1 -1
- package/build-module/toolbar/toolbar-group/types.js +2 -0
- package/build-module/toolbar/toolbar-group/types.js.map +1 -0
- package/build-module/toolbar/toolbar-item/index.js +1 -1
- package/build-module/toolbar/toolbar-item/index.js.map +1 -1
- package/build-module/tooltip/index.js +53 -224
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/tooltip/types.js +2 -0
- package/build-module/tooltip/types.js.map +1 -0
- package/build-module/ui/context/context-connect.js.map +1 -1
- package/build-module/ui/context/wordpress-component.js.map +1 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +7 -7
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/utils/colors-values.js +1 -1
- package/build-module/utils/colors-values.js.map +1 -1
- package/build-module/utils/use-deprecated-props.js.map +1 -1
- package/build-style/style-rtl.css +35 -73
- package/build-style/style.css +35 -73
- package/build-types/animation/index.d.ts +1 -1
- package/build-types/animation/index.d.ts.map +1 -1
- package/build-types/base-control/hooks.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control/hook.d.ts +46 -46
- package/build-types/border-box-control/border-box-control-linked-button/hook.d.ts +51 -51
- package/build-types/border-box-control/border-box-control-split-controls/component.d.ts +1 -1
- package/build-types/border-box-control/border-box-control-split-controls/hook.d.ts +46 -46
- package/build-types/border-box-control/border-box-control-visualizer/hook.d.ts +46 -46
- package/build-types/border-box-control/stories/index.story.d.ts +2 -2
- package/build-types/border-control/border-control/hook.d.ts +45 -45
- package/build-types/border-control/border-control-dropdown/hook.d.ts +45 -45
- package/build-types/border-control/border-control-style-picker/hook.d.ts +45 -45
- package/build-types/border-control/stories/index.story.d.ts +6 -6
- package/build-types/box-control/styles/box-control-styles.d.ts +1 -1
- package/build-types/button/deprecated.d.ts +16 -22
- package/build-types/button/deprecated.d.ts.map +1 -1
- package/build-types/button/index.d.ts.map +1 -1
- package/build-types/button/types.d.ts +0 -4
- package/build-types/button/types.d.ts.map +1 -1
- package/build-types/card/card/hook.d.ts +46 -46
- package/build-types/card/card-body/hook.d.ts +46 -46
- package/build-types/card/card-divider/hook.d.ts +47 -47
- package/build-types/card/card-footer/hook.d.ts +46 -46
- package/build-types/card/card-header/hook.d.ts +46 -46
- package/build-types/card/card-media/hook.d.ts +46 -46
- package/build-types/card/stories/index.story.d.ts +2 -2
- package/build-types/circular-option-picker/circular-option-picker-actions.d.ts +7 -0
- package/build-types/circular-option-picker/circular-option-picker-actions.d.ts.map +1 -0
- package/build-types/circular-option-picker/circular-option-picker-context.d.ts +7 -0
- package/build-types/circular-option-picker/circular-option-picker-context.d.ts.map +1 -0
- package/build-types/circular-option-picker/circular-option-picker-option-group.d.ts +7 -0
- package/build-types/circular-option-picker/circular-option-picker-option-group.d.ts.map +1 -0
- package/build-types/circular-option-picker/circular-option-picker-option.d.ts +4 -0
- package/build-types/circular-option-picker/circular-option-picker-option.d.ts.map +1 -0
- package/build-types/circular-option-picker/circular-option-picker.d.ts +11 -0
- package/build-types/circular-option-picker/circular-option-picker.d.ts.map +1 -0
- package/build-types/circular-option-picker/index.d.ts +5 -56
- package/build-types/circular-option-picker/index.d.ts.map +1 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts +3 -1
- package/build-types/circular-option-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/circular-option-picker/test/index.d.ts +2 -0
- package/build-types/circular-option-picker/test/index.d.ts.map +1 -0
- package/build-types/circular-option-picker/types.d.ts +53 -1
- package/build-types/circular-option-picker/types.d.ts.map +1 -1
- package/build-types/color-palette/index.d.ts +3 -19
- package/build-types/color-palette/index.d.ts.map +1 -1
- package/build-types/color-palette/stories/index.story.d.ts +3 -36
- package/build-types/color-palette/stories/index.story.d.ts.map +1 -1
- package/build-types/color-palette/styles.d.ts +1 -1
- package/build-types/color-palette/types.d.ts +31 -1
- package/build-types/color-palette/types.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts +1 -1
- package/build-types/color-picker/stories/index.story.d.ts +1 -1
- package/build-types/color-picker/styles.d.ts +6 -6
- package/build-types/combobox-control/index.d.ts.map +1 -1
- package/build-types/combobox-control/stories/index.story.d.ts +2 -2
- package/build-types/composite/index.d.ts +14 -1
- package/build-types/composite/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +2 -2
- package/build-types/date-time/date/styles.d.ts +3 -3
- package/build-types/date-time/date-time/styles.d.ts +2 -2
- package/build-types/date-time/time/index.d.ts.map +1 -1
- package/build-types/date-time/time/styles.d.ts +12 -12
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown/types.d.ts +12 -4
- package/build-types/dropdown/types.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/types.d.ts +22 -5
- package/build-types/dropdown-menu/types.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/duotone-picker/types.d.ts +31 -1
- package/build-types/duotone-picker/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +46 -46
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/flex/flex/hook.d.ts +46 -46
- package/build-types/flex/flex-block/hook.d.ts +46 -46
- package/build-types/flex/flex-item/hook.d.ts +46 -46
- package/build-types/focal-point-picker/stories/index.story.d.ts +8 -8
- package/build-types/focal-point-picker/styles/focal-point-picker-style.d.ts +1 -1
- package/build-types/focusable-iframe/index.d.ts +4 -5
- package/build-types/focusable-iframe/index.d.ts.map +1 -1
- package/build-types/focusable-iframe/types.d.ts +8 -0
- package/build-types/focusable-iframe/types.d.ts.map +1 -0
- package/build-types/font-size-picker/styles.d.ts +2 -2
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +6 -0
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +1 -1
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.story.d.ts +3 -36
- package/build-types/gradient-picker/stories/index.story.d.ts.map +1 -1
- package/build-types/gradient-picker/types.d.ts +31 -1
- package/build-types/gradient-picker/types.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +46 -46
- package/build-types/h-stack/component.d.ts +1 -1
- package/build-types/h-stack/hook.d.ts +46 -46
- package/build-types/heading/hook.d.ts +45 -45
- package/build-types/higher-order/navigate-regions/index.d.ts.map +1 -1
- package/build-types/higher-order/with-focus-outside/index.d.ts +1 -0
- package/build-types/higher-order/with-focus-outside/index.d.ts.map +1 -1
- package/build-types/higher-order/with-focus-outside/test/index.d.ts +2 -0
- package/build-types/higher-order/with-focus-outside/test/index.d.ts.map +1 -0
- package/build-types/higher-order/with-spoken-messages/index.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/index.d.ts.map +1 -1
- package/build-types/isolated-event-container/test/index.d.ts +2 -0
- package/build-types/isolated-event-container/test/index.d.ts.map +1 -0
- package/build-types/item-group/item/hook.d.ts +46 -46
- package/build-types/item-group/item-group/hook.d.ts +46 -46
- package/build-types/menu-item/index.d.ts +1 -1
- package/build-types/menu-item/stories/index.story.d.ts +4 -4
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/modal/stories/index.story.d.ts.map +1 -1
- package/build-types/modal/types.d.ts +1 -1
- package/build-types/modal/types.d.ts.map +1 -1
- package/build-types/navigable-container/menu.d.ts +1 -1
- package/build-types/navigation/back-button/index.d.ts +1 -1
- package/build-types/navigation/styles/navigation-styles.d.ts +5 -3
- package/build-types/navigation/styles/navigation-styles.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/component.d.ts +2 -3
- package/build-types/navigator/navigator-back-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-back-button/hook.d.ts +53 -54
- package/build-types/navigator/navigator-back-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/component.d.ts +2 -3
- package/build-types/navigator/navigator-button/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-button/hook.d.ts +53 -54
- package/build-types/navigator/navigator-button/hook.d.ts.map +1 -1
- package/build-types/navigator/navigator-to-parent-button/component.d.ts +2 -3
- package/build-types/navigator/navigator-to-parent-button/component.d.ts.map +1 -1
- package/build-types/notice/index.d.ts.map +1 -1
- package/build-types/number-control/index.d.ts +3 -3
- package/build-types/number-control/stories/index.story.d.ts +3 -3
- package/build-types/palette-edit/styles.d.ts +4 -4
- package/build-types/palette-edit/styles.d.ts.map +1 -1
- package/build-types/placeholder/index.d.ts.map +1 -1
- package/build-types/popover/index.d.ts +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/overlay-middlewares.d.ts +1 -1
- package/build-types/popover/stories/e2e/index.story.d.ts +1 -1
- package/build-types/popover/types.d.ts +0 -4
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts +2 -6
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/range-control/index.d.ts +1 -1
- package/build-types/range-control/styles/range-control-styles.d.ts +3 -3
- package/build-types/resizable-box/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/index.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/label.d.ts +1 -1
- package/build-types/resizable-box/stories/index.story.d.ts +2 -2
- package/build-types/scrollable/hook.d.ts +46 -46
- package/build-types/search-control/index.d.ts +4 -2
- package/build-types/search-control/index.d.ts.map +1 -1
- package/build-types/search-control/stories/index.story.d.ts +8 -4
- package/build-types/search-control/stories/index.story.d.ts.map +1 -1
- package/build-types/search-control/types.d.ts +12 -0
- package/build-types/search-control/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +46 -46
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/surface/hook.d.ts +46 -46
- package/build-types/text/hook.d.ts +46 -46
- package/build-types/text/styles.d.ts.map +1 -1
- package/build-types/text-control/index.d.ts +3 -3
- package/build-types/toggle-control/stories/index.story.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts +2 -4
- package/build-types/toggle-group-control/toggle-group-control/as-button-group.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts +2 -4
- package/build-types/toggle-group-control/toggle-group-control/as-radio-group.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts +2 -2
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts +1 -5
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts +18 -0
- package/build-types/toggle-group-control/toggle-group-control/utils.d.ts.map +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option/component.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +5 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -0
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-icon/component.d.ts +1 -1
- package/build-types/toggle-group-control/types.d.ts +13 -24
- package/build-types/toggle-group-control/types.d.ts.map +1 -1
- package/build-types/toolbar/stories/index.story.d.ts.map +1 -1
- package/build-types/toolbar/toolbar/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-button/index.d.ts +16 -22
- package/build-types/toolbar/toolbar-button/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts +3 -1
- package/build-types/toolbar/toolbar-dropdown-menu/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-group/index.d.ts +10 -14
- package/build-types/toolbar/toolbar-group/index.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts +3 -5
- package/build-types/toolbar/toolbar-group/toolbar-group-collapsed.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts +7 -5
- package/build-types/toolbar/toolbar-group/toolbar-group-container.d.ts.map +1 -1
- package/build-types/toolbar/toolbar-group/types.d.ts +77 -0
- package/build-types/toolbar/toolbar-group/types.d.ts.map +1 -0
- package/build-types/toolbar/toolbar-item/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +46 -46
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +46 -46
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +46 -46
- package/build-types/tooltip/index.d.ts +8 -5
- package/build-types/tooltip/index.d.ts.map +1 -1
- package/build-types/tooltip/stories/index.story.d.ts +13 -0
- package/build-types/tooltip/stories/index.story.d.ts.map +1 -0
- package/build-types/tooltip/test/index.d.ts +2 -0
- package/build-types/tooltip/test/index.d.ts.map +1 -0
- package/build-types/tooltip/test/utils/index.d.ts +11 -0
- package/build-types/tooltip/test/utils/index.d.ts.map +1 -0
- package/build-types/tooltip/types.d.ts +61 -0
- package/build-types/tooltip/types.d.ts.map +1 -0
- package/build-types/truncate/hook.d.ts +46 -46
- package/build-types/ui/tooltip/content.d.ts +1 -1
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +3 -3
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/unit-select-control.d.ts +1 -1
- package/build-types/utils/use-deprecated-props.d.ts +1 -1
- package/build-types/v-stack/component.d.ts +1 -1
- package/build-types/v-stack/hook.d.ts +46 -46
- package/build-types/v-stack/stories/index.story.d.ts +2 -2
- package/package.json +20 -20
- package/src/animation/index.tsx +1 -0
- package/src/border-control/border-control/README.md +2 -2
- package/src/border-control/border-control-dropdown/component.tsx +1 -1
- package/src/border-control/styles.ts +7 -7
- package/src/border-control/test/index.js +79 -69
- package/src/box-control/unit-control.tsx +1 -1
- package/src/button/README.md +0 -6
- package/src/button/index.tsx +9 -1
- package/src/button/test/index.tsx +19 -0
- package/src/button/types.ts +0 -4
- package/src/circular-option-picker/README.md +14 -0
- package/src/circular-option-picker/circular-option-picker-actions.tsx +60 -0
- package/src/circular-option-picker/circular-option-picker-context.tsx +12 -0
- package/src/circular-option-picker/circular-option-picker-option-group.tsx +34 -0
- package/src/circular-option-picker/circular-option-picker-option.tsx +139 -0
- package/src/circular-option-picker/circular-option-picker.tsx +202 -0
- package/src/circular-option-picker/index.tsx +7 -174
- package/src/circular-option-picker/stories/index.story.tsx +34 -9
- package/src/circular-option-picker/style.scss +11 -7
- package/src/circular-option-picker/test/index.tsx +133 -0
- package/src/circular-option-picker/types.ts +64 -1
- package/src/color-palette/README.md +14 -0
- package/src/color-palette/index.tsx +69 -28
- package/src/color-palette/stories/index.story.tsx +16 -2
- package/src/color-palette/test/index.tsx +32 -30
- package/src/color-palette/types.ts +34 -1
- package/src/combobox-control/index.tsx +7 -5
- package/src/composite/{index.js → index.ts} +3 -0
- package/src/confirm-dialog/stories/index.story.js +13 -14
- package/src/confirm-dialog/test/index.js +10 -18
- package/src/custom-gradient-picker/gradient-bar/control-points.tsx +1 -1
- package/src/custom-gradient-picker/gradient-bar/test/utils.ts +5 -5
- package/src/date-time/time/index.tsx +8 -1
- package/src/date-time/time/timezone.tsx +1 -1
- package/src/dropdown/README.md +13 -3
- package/src/dropdown/index.tsx +16 -34
- package/src/dropdown/stories/index.story.tsx +10 -7
- package/src/dropdown/types.ts +12 -4
- package/src/dropdown-menu/README.md +18 -0
- package/src/dropdown-menu/index.tsx +8 -1
- package/src/dropdown-menu/stories/index.story.tsx +5 -0
- package/src/dropdown-menu/types.ts +23 -6
- package/src/dropdown-menu-v2/styles.ts +1 -1
- package/src/duotone-picker/README.md +14 -0
- package/src/duotone-picker/color-list-picker/index.tsx +28 -12
- package/src/duotone-picker/duotone-picker.tsx +33 -0
- package/src/duotone-picker/types.ts +34 -1
- package/src/focusable-iframe/{index.js → index.tsx} +7 -4
- package/src/focusable-iframe/types.ts +9 -0
- package/src/form-token-field/README.md +1 -0
- package/src/form-token-field/index.tsx +5 -1
- package/src/form-token-field/style.scss +5 -9
- package/src/form-token-field/test/index.tsx +36 -1
- package/src/form-token-field/types.ts +7 -1
- package/src/gradient-picker/README.md +14 -0
- package/src/gradient-picker/index.tsx +60 -11
- package/src/gradient-picker/types.ts +34 -1
- package/src/higher-order/navigate-regions/index.tsx +5 -6
- package/src/higher-order/with-filters/test/index.tsx +36 -43
- package/src/higher-order/with-focus-outside/{index.js → index.tsx} +8 -5
- package/src/higher-order/with-focus-outside/test/{index.js → index.tsx} +13 -11
- package/src/higher-order/with-notices/test/index.tsx +1 -1
- package/src/higher-order/with-spoken-messages/index.tsx +7 -8
- package/src/index.ts +5 -1
- package/src/input-control/styles/input-control-styles.tsx +2 -2
- package/src/isolated-event-container/test/{index.js → index.tsx} +1 -1
- package/src/mobile/bottom-sheet/index.native.js +1 -0
- package/src/mobile/global-styles-context/index.native.js +7 -8
- package/src/modal/README.md +7 -1
- package/src/modal/index.tsx +27 -3
- package/src/modal/stories/index.story.tsx +2 -1
- package/src/modal/test/index.tsx +231 -0
- package/src/modal/types.ts +3 -1
- package/src/navigation/use-navigation-tree-nodes.tsx +1 -1
- package/src/notice/index.tsx +18 -6
- package/src/notice/style.scss +0 -1
- package/src/notice/test/__snapshots__/index.tsx.snap +9 -1
- package/src/palette-edit/styles.js +2 -1
- package/src/placeholder/index.tsx +16 -8
- package/src/placeholder/style.scss +2 -16
- package/src/placeholder/test/index.tsx +34 -15
- package/src/popover/index.tsx +47 -110
- package/src/popover/test/index.tsx +3 -3
- package/src/popover/types.ts +0 -5
- package/src/popover/utils.ts +19 -67
- package/src/search-control/README.md +7 -0
- package/src/search-control/index.tsx +10 -1
- package/src/search-control/style.scss +14 -7
- package/src/search-control/types.ts +12 -0
- package/src/tab-panel/test/index.tsx +5 -0
- package/src/text/styles.js +2 -1
- package/src/theme/README.md +5 -5
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +567 -59
- package/src/toggle-group-control/test/index.tsx +110 -56
- package/src/toggle-group-control/toggle-group-control/README.md +0 -1
- package/src/toggle-group-control/toggle-group-control/as-button-group.tsx +39 -57
- package/src/toggle-group-control/toggle-group-control/as-radio-group.tsx +52 -48
- package/src/toggle-group-control/toggle-group-control/component.tsx +12 -6
- package/src/toggle-group-control/toggle-group-control/styles.ts +2 -19
- package/src/toggle-group-control/toggle-group-control/utils.ts +50 -0
- package/src/toggle-group-control/toggle-group-control-option-base/component.tsx +70 -20
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +17 -3
- package/src/toggle-group-control/types.ts +14 -32
- package/src/toolbar/stories/index.story.tsx +3 -5
- package/src/toolbar/test/toolbar-group.tsx +13 -7
- package/src/toolbar/toolbar/index.tsx +9 -1
- package/src/toolbar/toolbar-dropdown-menu/{index.js → index.tsx} +11 -4
- package/src/toolbar/toolbar-group/README.md +2 -2
- package/src/toolbar/toolbar-group/{index.js → index.tsx} +19 -14
- package/src/toolbar/toolbar-group/{toolbar-group-collapsed.js → toolbar-group-collapsed.tsx} +10 -4
- package/src/toolbar/toolbar-group/toolbar-group-container.tsx +16 -0
- package/src/toolbar/toolbar-group/types.ts +92 -0
- package/src/toolbar/toolbar-item/index.tsx +3 -1
- package/src/tooltip/README.md +31 -28
- package/src/tooltip/index.tsx +106 -0
- package/src/tooltip/stories/index.story.tsx +59 -0
- package/src/tooltip/style.scss +2 -27
- package/src/tooltip/test/index.tsx +335 -0
- package/src/tooltip/test/utils/index.tsx +20 -0
- package/src/tooltip/types.ts +61 -0
- package/src/ui/context/context-connect.ts +3 -3
- package/src/ui/context/wordpress-component.ts +4 -4
- package/src/unit-control/index.tsx +9 -4
- package/src/unit-control/styles/unit-control-styles.ts +3 -1
- package/src/unit-control/test/utils.ts +1 -1
- package/src/utils/colors-values.js +1 -1
- package/src/utils/use-deprecated-props.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -78
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +0 -76
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +0 -1
- package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts +0 -9
- package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +0 -1
- package/src/color-palette/test/__snapshots__/index.tsx.snap +0 -288
- package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +0 -84
- package/src/toolbar/toolbar-group/toolbar-group-container.js +0 -8
- package/src/tooltip/index.js +0 -293
- package/src/tooltip/stories/index.story.js +0 -85
- package/src/tooltip/test/index.js +0 -323
package/src/tooltip/index.js
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* WordPress dependencies
|
|
10
|
-
*/
|
|
11
|
-
import {
|
|
12
|
-
Children,
|
|
13
|
-
cloneElement,
|
|
14
|
-
concatChildren,
|
|
15
|
-
useEffect,
|
|
16
|
-
useState,
|
|
17
|
-
} from '@wordpress/element';
|
|
18
|
-
import { useDebounce, useMergeRefs } from '@wordpress/compose';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
import Popover from '../popover';
|
|
24
|
-
import Shortcut from '../shortcut';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Time over children to wait before showing tooltip
|
|
28
|
-
*
|
|
29
|
-
* @type {number}
|
|
30
|
-
*/
|
|
31
|
-
export const TOOLTIP_DELAY = 700;
|
|
32
|
-
|
|
33
|
-
const eventCatcher = <div className="event-catcher" />;
|
|
34
|
-
|
|
35
|
-
const getDisabledElement = ( {
|
|
36
|
-
eventHandlers,
|
|
37
|
-
child,
|
|
38
|
-
childrenWithPopover,
|
|
39
|
-
mergedRefs,
|
|
40
|
-
} ) => {
|
|
41
|
-
return cloneElement(
|
|
42
|
-
<span className="disabled-element-wrapper">
|
|
43
|
-
{ cloneElement( eventCatcher, eventHandlers ) }
|
|
44
|
-
{ cloneElement( child, {
|
|
45
|
-
children: childrenWithPopover,
|
|
46
|
-
ref: mergedRefs,
|
|
47
|
-
} ) }
|
|
48
|
-
</span>,
|
|
49
|
-
{ ...eventHandlers }
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const getRegularElement = ( {
|
|
54
|
-
child,
|
|
55
|
-
eventHandlers,
|
|
56
|
-
childrenWithPopover,
|
|
57
|
-
mergedRefs,
|
|
58
|
-
} ) => {
|
|
59
|
-
return cloneElement( child, {
|
|
60
|
-
...eventHandlers,
|
|
61
|
-
children: childrenWithPopover,
|
|
62
|
-
ref: mergedRefs,
|
|
63
|
-
} );
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const addPopoverToGrandchildren = ( {
|
|
67
|
-
anchor,
|
|
68
|
-
grandchildren,
|
|
69
|
-
isOver,
|
|
70
|
-
offset,
|
|
71
|
-
position,
|
|
72
|
-
shortcut,
|
|
73
|
-
text,
|
|
74
|
-
className,
|
|
75
|
-
...props
|
|
76
|
-
} ) =>
|
|
77
|
-
concatChildren(
|
|
78
|
-
grandchildren,
|
|
79
|
-
isOver && (
|
|
80
|
-
<Popover
|
|
81
|
-
focusOnMount={ false }
|
|
82
|
-
position={ position }
|
|
83
|
-
className={ classNames( 'components-tooltip', className ) }
|
|
84
|
-
aria-hidden="true"
|
|
85
|
-
animate={ false }
|
|
86
|
-
offset={ offset }
|
|
87
|
-
anchor={ anchor }
|
|
88
|
-
shift
|
|
89
|
-
{ ...props }
|
|
90
|
-
>
|
|
91
|
-
{ text }
|
|
92
|
-
<Shortcut
|
|
93
|
-
className="components-tooltip__shortcut"
|
|
94
|
-
shortcut={ shortcut }
|
|
95
|
-
/>
|
|
96
|
-
</Popover>
|
|
97
|
-
)
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const emitToChild = ( children, eventName, event ) => {
|
|
101
|
-
if ( Children.count( children ) !== 1 ) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const child = Children.only( children );
|
|
106
|
-
|
|
107
|
-
// If the underlying element is disabled, do not emit the event.
|
|
108
|
-
if ( child.props.disabled ) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if ( typeof child.props[ eventName ] === 'function' ) {
|
|
113
|
-
child.props[ eventName ]( event );
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
function Tooltip( props ) {
|
|
118
|
-
const {
|
|
119
|
-
children,
|
|
120
|
-
position = 'bottom middle',
|
|
121
|
-
text,
|
|
122
|
-
shortcut,
|
|
123
|
-
delay = TOOLTIP_DELAY,
|
|
124
|
-
...popoverProps
|
|
125
|
-
} = props;
|
|
126
|
-
/**
|
|
127
|
-
* Whether a mouse is currently pressed, used in determining whether
|
|
128
|
-
* to handle a focus event as displaying the tooltip immediately.
|
|
129
|
-
*
|
|
130
|
-
* @type {boolean}
|
|
131
|
-
*/
|
|
132
|
-
const [ isMouseDown, setIsMouseDown ] = useState( false );
|
|
133
|
-
const [ isOver, setIsOver ] = useState( false );
|
|
134
|
-
const delayedSetIsOver = useDebounce( setIsOver, delay );
|
|
135
|
-
// Using internal state (instead of a ref) for the popover anchor to make sure
|
|
136
|
-
// that the component re-renders when the anchor updates.
|
|
137
|
-
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
138
|
-
|
|
139
|
-
// Create a reference to the Tooltip's child, to be passed to the Popover
|
|
140
|
-
// so that the Tooltip can be correctly positioned. Also, merge with the
|
|
141
|
-
// existing ref for the first child, so that its ref is preserved.
|
|
142
|
-
const existingChildRef = Children.toArray( children )[ 0 ]?.ref;
|
|
143
|
-
const mergedChildRefs = useMergeRefs( [
|
|
144
|
-
setPopoverAnchor,
|
|
145
|
-
existingChildRef,
|
|
146
|
-
] );
|
|
147
|
-
|
|
148
|
-
const createMouseDown = ( event ) => {
|
|
149
|
-
// In firefox, the mouse down event is also fired when the select
|
|
150
|
-
// list is chosen.
|
|
151
|
-
// Cancel further processing because re-rendering of child components
|
|
152
|
-
// causes onChange to be triggered with the old value.
|
|
153
|
-
// See https://github.com/WordPress/gutenberg/pull/42483
|
|
154
|
-
if ( event.target.tagName === 'OPTION' ) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Preserve original child callback behavior.
|
|
159
|
-
emitToChild( children, 'onMouseDown', event );
|
|
160
|
-
|
|
161
|
-
// On mouse down, the next `mouseup` should revert the value of the
|
|
162
|
-
// instance property and remove its own event handler. The bind is
|
|
163
|
-
// made on the document since the `mouseup` might not occur within
|
|
164
|
-
// the bounds of the element.
|
|
165
|
-
document.addEventListener( 'mouseup', cancelIsMouseDown );
|
|
166
|
-
setIsMouseDown( true );
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const createMouseUp = ( event ) => {
|
|
170
|
-
// In firefox, the mouse up event is also fired when the select
|
|
171
|
-
// list is chosen.
|
|
172
|
-
// Cancel further processing because re-rendering of child components
|
|
173
|
-
// causes onChange to be triggered with the old value.
|
|
174
|
-
// See https://github.com/WordPress/gutenberg/pull/42483
|
|
175
|
-
if ( event.target.tagName === 'OPTION' ) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
emitToChild( children, 'onMouseUp', event );
|
|
180
|
-
document.removeEventListener( 'mouseup', cancelIsMouseDown );
|
|
181
|
-
setIsMouseDown( false );
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const createMouseEvent = ( type ) => {
|
|
185
|
-
if ( type === 'mouseUp' ) return createMouseUp;
|
|
186
|
-
if ( type === 'mouseDown' ) return createMouseDown;
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Prebound `isInMouseDown` handler, created as a constant reference to
|
|
191
|
-
* assure ability to remove in component unmount.
|
|
192
|
-
*
|
|
193
|
-
* @type {Function}
|
|
194
|
-
*/
|
|
195
|
-
const cancelIsMouseDown = createMouseEvent( 'mouseUp' );
|
|
196
|
-
|
|
197
|
-
const createToggleIsOver = ( eventName, isDelayed ) => {
|
|
198
|
-
return ( event ) => {
|
|
199
|
-
// Preserve original child callback behavior.
|
|
200
|
-
emitToChild( children, eventName, event );
|
|
201
|
-
|
|
202
|
-
// Mouse events behave unreliably in React for disabled elements,
|
|
203
|
-
// firing on mouseenter but not mouseleave. Further, the default
|
|
204
|
-
// behavior for disabled elements in some browsers is to ignore
|
|
205
|
-
// mouse events. Don't bother trying to handle them.
|
|
206
|
-
//
|
|
207
|
-
// See: https://github.com/facebook/react/issues/4251
|
|
208
|
-
if ( event.currentTarget.disabled ) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// A focus event will occur as a result of a mouse click, but it
|
|
213
|
-
// should be disambiguated between interacting with the button and
|
|
214
|
-
// using an explicit focus shift as a cue to display the tooltip.
|
|
215
|
-
if ( 'focus' === event.type && isMouseDown ) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Needed in case unsetting is over while delayed set pending, i.e.
|
|
220
|
-
// quickly blur/mouseleave before delayedSetIsOver is called.
|
|
221
|
-
delayedSetIsOver.cancel();
|
|
222
|
-
|
|
223
|
-
const _isOver = [ 'focus', 'mouseenter' ].includes( event.type );
|
|
224
|
-
if ( _isOver === isOver ) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if ( isDelayed ) {
|
|
229
|
-
delayedSetIsOver( _isOver );
|
|
230
|
-
} else {
|
|
231
|
-
setIsOver( _isOver );
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
};
|
|
235
|
-
const clearOnUnmount = () => {
|
|
236
|
-
delayedSetIsOver.cancel();
|
|
237
|
-
document.removeEventListener( 'mouseup', cancelIsMouseDown );
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
// Ignore reason: updating the deps array here could cause unexpected changes in behavior.
|
|
241
|
-
// Deferring until a more detailed investigation/refactor can be performed.
|
|
242
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
243
|
-
useEffect( () => clearOnUnmount, [] );
|
|
244
|
-
|
|
245
|
-
if ( Children.count( children ) !== 1 ) {
|
|
246
|
-
if ( 'development' === process.env.NODE_ENV ) {
|
|
247
|
-
// eslint-disable-next-line no-console
|
|
248
|
-
console.error(
|
|
249
|
-
'Tooltip should be called with only a single child element.'
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
return children;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
const eventHandlers = {
|
|
257
|
-
onMouseEnter: createToggleIsOver( 'onMouseEnter', true ),
|
|
258
|
-
onMouseLeave: createToggleIsOver( 'onMouseLeave' ),
|
|
259
|
-
onClick: createToggleIsOver( 'onClick' ),
|
|
260
|
-
onFocus: createToggleIsOver( 'onFocus' ),
|
|
261
|
-
onBlur: createToggleIsOver( 'onBlur' ),
|
|
262
|
-
onMouseDown: createMouseEvent( 'mouseDown' ),
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const child = Children.only( children );
|
|
266
|
-
const { children: grandchildren, disabled } = child.props;
|
|
267
|
-
const getElementWithPopover = disabled
|
|
268
|
-
? getDisabledElement
|
|
269
|
-
: getRegularElement;
|
|
270
|
-
|
|
271
|
-
const popoverData = {
|
|
272
|
-
anchor: popoverAnchor,
|
|
273
|
-
isOver,
|
|
274
|
-
offset: 4,
|
|
275
|
-
position,
|
|
276
|
-
shortcut,
|
|
277
|
-
text,
|
|
278
|
-
};
|
|
279
|
-
const childrenWithPopover = addPopoverToGrandchildren( {
|
|
280
|
-
grandchildren,
|
|
281
|
-
...popoverData,
|
|
282
|
-
...popoverProps,
|
|
283
|
-
} );
|
|
284
|
-
|
|
285
|
-
return getElementWithPopover( {
|
|
286
|
-
child,
|
|
287
|
-
eventHandlers,
|
|
288
|
-
childrenWithPopover,
|
|
289
|
-
mergedRefs: mergedChildRefs,
|
|
290
|
-
} );
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export default Tooltip;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import Tooltip from '../';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/ToolTip',
|
|
8
|
-
component: Tooltip,
|
|
9
|
-
argTypes: {
|
|
10
|
-
delay: { control: 'number' },
|
|
11
|
-
position: {
|
|
12
|
-
control: {
|
|
13
|
-
type: 'select',
|
|
14
|
-
options: [
|
|
15
|
-
'top left',
|
|
16
|
-
'top center',
|
|
17
|
-
'top right',
|
|
18
|
-
'bottom left',
|
|
19
|
-
'bottom center',
|
|
20
|
-
'bottom right',
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
text: { control: 'text' },
|
|
25
|
-
},
|
|
26
|
-
parameters: {
|
|
27
|
-
docs: { canvas: { sourceState: 'shown' } },
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const Template = ( args ) => {
|
|
32
|
-
return <Tooltip { ...args } />;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const Default = Template.bind( {} );
|
|
36
|
-
Default.args = {
|
|
37
|
-
text: 'More information',
|
|
38
|
-
children: (
|
|
39
|
-
<div
|
|
40
|
-
style={ {
|
|
41
|
-
margin: '50px auto',
|
|
42
|
-
width: '200px',
|
|
43
|
-
padding: '20px',
|
|
44
|
-
textAlign: 'center',
|
|
45
|
-
border: '1px solid #ccc',
|
|
46
|
-
} }
|
|
47
|
-
>
|
|
48
|
-
Hover for more information
|
|
49
|
-
</div>
|
|
50
|
-
),
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const SmallTarget = Template.bind( {} );
|
|
54
|
-
SmallTarget.args = {
|
|
55
|
-
...Default.args,
|
|
56
|
-
children: (
|
|
57
|
-
<div
|
|
58
|
-
style={ {
|
|
59
|
-
margin: '50px auto',
|
|
60
|
-
width: 'min-content',
|
|
61
|
-
padding: '4px',
|
|
62
|
-
textAlign: 'center',
|
|
63
|
-
border: '1px solid #ccc',
|
|
64
|
-
} }
|
|
65
|
-
>
|
|
66
|
-
Small target
|
|
67
|
-
</div>
|
|
68
|
-
),
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const DisabledChild = Template.bind( {} );
|
|
72
|
-
DisabledChild.args = {
|
|
73
|
-
...Default.args,
|
|
74
|
-
children: (
|
|
75
|
-
<button
|
|
76
|
-
disabled
|
|
77
|
-
onClick={ () =>
|
|
78
|
-
// eslint-disable-next-line no-alert
|
|
79
|
-
window.alert( 'This alert should not be triggered' )
|
|
80
|
-
}
|
|
81
|
-
>
|
|
82
|
-
Hover me, but I am disabled
|
|
83
|
-
</button>
|
|
84
|
-
),
|
|
85
|
-
};
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import Tooltip from '../';
|
|
11
|
-
import Button from '../../button';
|
|
12
|
-
import { TOOLTIP_DELAY } from '../index.js';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* WordPress dependencies
|
|
16
|
-
*/
|
|
17
|
-
import { shortcutAriaLabel } from '@wordpress/keycodes';
|
|
18
|
-
|
|
19
|
-
const props = {
|
|
20
|
-
text: 'tooltip text',
|
|
21
|
-
delay: TOOLTIP_DELAY,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
function getWrappingPopoverElement( element ) {
|
|
25
|
-
return element.closest( '.components-popover' );
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
describe( 'Tooltip', () => {
|
|
29
|
-
it( 'should not render the tooltip if multiple children are passed', async () => {
|
|
30
|
-
const user = userEvent.setup();
|
|
31
|
-
|
|
32
|
-
render(
|
|
33
|
-
<Tooltip { ...props }>
|
|
34
|
-
<Button>Button 1</Button>
|
|
35
|
-
<Button>Button 2</Button>
|
|
36
|
-
</Tooltip>
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
await user.tab();
|
|
40
|
-
|
|
41
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
|
-
it( 'should not render the tooltip if there is no focus', () => {
|
|
45
|
-
render(
|
|
46
|
-
<Tooltip { ...props }>
|
|
47
|
-
<Button>Hover Me!</Button>
|
|
48
|
-
</Tooltip>
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
expect(
|
|
52
|
-
screen.getByRole( 'button', { name: 'Hover Me!' } )
|
|
53
|
-
).toBeVisible();
|
|
54
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
55
|
-
} );
|
|
56
|
-
|
|
57
|
-
it( 'should render the tooltip when focusing the tooltip anchor via tab', async () => {
|
|
58
|
-
const user = userEvent.setup();
|
|
59
|
-
|
|
60
|
-
render(
|
|
61
|
-
<Tooltip { ...props }>
|
|
62
|
-
<Button>Hover Me!</Button>
|
|
63
|
-
</Tooltip>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
await user.tab();
|
|
67
|
-
|
|
68
|
-
expect(
|
|
69
|
-
screen.getByRole( 'button', { name: /Hover me!/i } )
|
|
70
|
-
).toHaveFocus();
|
|
71
|
-
|
|
72
|
-
await waitFor( () =>
|
|
73
|
-
expect( screen.getByText( 'tooltip text' ) ).toBeVisible()
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
77
|
-
await waitFor( () =>
|
|
78
|
-
expect(
|
|
79
|
-
getWrappingPopoverElement( screen.getByText( 'tooltip text' ) )
|
|
80
|
-
).toBePositionedPopover()
|
|
81
|
-
);
|
|
82
|
-
} );
|
|
83
|
-
|
|
84
|
-
it( 'should render the tooltip when the tooltip anchor is hovered', async () => {
|
|
85
|
-
const user = userEvent.setup();
|
|
86
|
-
|
|
87
|
-
render(
|
|
88
|
-
<Tooltip { ...props }>
|
|
89
|
-
<Button>Hover Me!</Button>
|
|
90
|
-
</Tooltip>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const button = screen.getByRole( 'button', { name: 'Hover Me!' } );
|
|
94
|
-
|
|
95
|
-
await user.hover( button );
|
|
96
|
-
|
|
97
|
-
await waitFor( () =>
|
|
98
|
-
expect( screen.getByText( 'tooltip text' ) ).toBeVisible()
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
102
|
-
await waitFor( () =>
|
|
103
|
-
expect(
|
|
104
|
-
getWrappingPopoverElement( screen.getByText( 'tooltip text' ) )
|
|
105
|
-
).toBePositionedPopover()
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
await user.unhover( button );
|
|
109
|
-
|
|
110
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
111
|
-
} );
|
|
112
|
-
|
|
113
|
-
it( 'should not show tooltip on focus as result of mouse click', async () => {
|
|
114
|
-
const user = userEvent.setup();
|
|
115
|
-
|
|
116
|
-
render(
|
|
117
|
-
<Tooltip { ...props }>
|
|
118
|
-
<Button>Hover Me!</Button>
|
|
119
|
-
</Tooltip>
|
|
120
|
-
);
|
|
121
|
-
|
|
122
|
-
await user.click( screen.getByRole( 'button', { text: 'Hover Me!' } ) );
|
|
123
|
-
|
|
124
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
125
|
-
} );
|
|
126
|
-
|
|
127
|
-
it( 'should respect custom delay prop when showing tooltip', async () => {
|
|
128
|
-
const user = userEvent.setup( { delay: TOOLTIP_DELAY } );
|
|
129
|
-
const CUSTOM_DELAY = TOOLTIP_DELAY + 25;
|
|
130
|
-
|
|
131
|
-
render(
|
|
132
|
-
<Tooltip { ...props } delay={ CUSTOM_DELAY }>
|
|
133
|
-
<Button>Hover Me!</Button>
|
|
134
|
-
</Tooltip>
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
const button = screen.getByRole( 'button', { name: 'Hover Me!' } );
|
|
138
|
-
|
|
139
|
-
await user.hover( button );
|
|
140
|
-
|
|
141
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
142
|
-
|
|
143
|
-
await waitFor( () =>
|
|
144
|
-
expect( screen.getByText( 'tooltip text' ) ).toBeVisible()
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
148
|
-
await waitFor( () =>
|
|
149
|
-
expect(
|
|
150
|
-
getWrappingPopoverElement( screen.getByText( 'tooltip text' ) )
|
|
151
|
-
).toBePositionedPopover()
|
|
152
|
-
);
|
|
153
|
-
} );
|
|
154
|
-
|
|
155
|
-
it( 'should show tooltip when an element is disabled', async () => {
|
|
156
|
-
const user = userEvent.setup();
|
|
157
|
-
|
|
158
|
-
render(
|
|
159
|
-
<Tooltip { ...props }>
|
|
160
|
-
<Button disabled>Click me</Button>
|
|
161
|
-
</Tooltip>
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
const button = screen.getByRole( 'button', { name: /Click me/i } );
|
|
165
|
-
|
|
166
|
-
expect( button ).toBeVisible();
|
|
167
|
-
expect( button ).toBeDisabled();
|
|
168
|
-
|
|
169
|
-
await user.hover( button );
|
|
170
|
-
|
|
171
|
-
await waitFor( () =>
|
|
172
|
-
expect( screen.getByText( 'tooltip text' ) ).toBeVisible()
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
176
|
-
await waitFor( () =>
|
|
177
|
-
expect(
|
|
178
|
-
getWrappingPopoverElement( screen.getByText( 'tooltip text' ) )
|
|
179
|
-
).toBePositionedPopover()
|
|
180
|
-
);
|
|
181
|
-
} );
|
|
182
|
-
|
|
183
|
-
it( 'should not emit events back to children when they are disabled', async () => {
|
|
184
|
-
const user = userEvent.setup();
|
|
185
|
-
const onClickMock = jest.fn();
|
|
186
|
-
|
|
187
|
-
const { container } = render(
|
|
188
|
-
<Tooltip { ...props }>
|
|
189
|
-
<Button disabled onClick={ onClickMock }>
|
|
190
|
-
Click me
|
|
191
|
-
</Button>
|
|
192
|
-
</Tooltip>
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
// Note: this is testing for implementation details,
|
|
196
|
-
// but couldn't find a better way.
|
|
197
|
-
const buttonRect = screen
|
|
198
|
-
.getByRole( 'button', { name: 'Click me' } )
|
|
199
|
-
.getBoundingClientRect();
|
|
200
|
-
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
|
|
201
|
-
const eventCatcher = container.querySelector( '.event-catcher' );
|
|
202
|
-
await user.click( eventCatcher );
|
|
203
|
-
expect( onClickMock ).not.toHaveBeenCalled();
|
|
204
|
-
|
|
205
|
-
const eventCatcherRect = eventCatcher.getBoundingClientRect();
|
|
206
|
-
expect( buttonRect ).toEqual( eventCatcherRect );
|
|
207
|
-
} );
|
|
208
|
-
|
|
209
|
-
it( 'should not show tooltip if the mouse leaves the tooltip anchor before set delay', async () => {
|
|
210
|
-
const user = userEvent.setup();
|
|
211
|
-
const onMouseEnterMock = jest.fn();
|
|
212
|
-
const onMouseLeaveMock = jest.fn();
|
|
213
|
-
const MOUSE_LEAVE_DELAY = TOOLTIP_DELAY - 200;
|
|
214
|
-
|
|
215
|
-
render(
|
|
216
|
-
<>
|
|
217
|
-
<Tooltip { ...props }>
|
|
218
|
-
<Button
|
|
219
|
-
onMouseEnter={ onMouseEnterMock }
|
|
220
|
-
onMouseLeave={ onMouseLeaveMock }
|
|
221
|
-
>
|
|
222
|
-
Hover Me!
|
|
223
|
-
</Button>
|
|
224
|
-
</Tooltip>
|
|
225
|
-
<Button>Hover me instead!</Button>
|
|
226
|
-
</>
|
|
227
|
-
);
|
|
228
|
-
|
|
229
|
-
await user.hover(
|
|
230
|
-
screen.getByRole( 'button', {
|
|
231
|
-
name: 'Hover Me!',
|
|
232
|
-
} )
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
// Tooltip hasn't appeared yet
|
|
236
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
237
|
-
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
238
|
-
|
|
239
|
-
// Advance time by MOUSE_LEAVE_DELAY time
|
|
240
|
-
await new Promise( ( resolve ) =>
|
|
241
|
-
setTimeout( resolve, MOUSE_LEAVE_DELAY )
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
245
|
-
|
|
246
|
-
// Hover the other button, meaning that the mouse will leave the tooltip anchor
|
|
247
|
-
await user.hover(
|
|
248
|
-
screen.getByRole( 'button', {
|
|
249
|
-
name: 'Hover me instead!',
|
|
250
|
-
} )
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
// Tooltip still hasn't appeared yet
|
|
254
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
255
|
-
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
256
|
-
expect( onMouseLeaveMock ).toHaveBeenCalledTimes( 1 );
|
|
257
|
-
|
|
258
|
-
// Advance time again, so that we reach the full TOOLTIP_DELAY time
|
|
259
|
-
await new Promise( ( resolve ) =>
|
|
260
|
-
setTimeout( resolve, TOOLTIP_DELAY )
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
// Tooltip won't show, since the mouse has left the tooltip anchor
|
|
264
|
-
expect( screen.queryByText( 'tooltip text' ) ).not.toBeInTheDocument();
|
|
265
|
-
} );
|
|
266
|
-
|
|
267
|
-
it( 'should render the shortcut display text when a string is passed as the shortcut', async () => {
|
|
268
|
-
const user = userEvent.setup();
|
|
269
|
-
|
|
270
|
-
render(
|
|
271
|
-
<Tooltip { ...props } shortcut="shortcut text">
|
|
272
|
-
<Button>Hover Me!</Button>
|
|
273
|
-
</Tooltip>
|
|
274
|
-
);
|
|
275
|
-
|
|
276
|
-
await user.hover( screen.getByRole( 'button', { name: 'Hover Me!' } ) );
|
|
277
|
-
|
|
278
|
-
await waitFor( () =>
|
|
279
|
-
expect( screen.getByText( 'shortcut text' ) ).toBeVisible()
|
|
280
|
-
);
|
|
281
|
-
|
|
282
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
283
|
-
await waitFor( () =>
|
|
284
|
-
expect(
|
|
285
|
-
getWrappingPopoverElement( screen.getByText( 'shortcut text' ) )
|
|
286
|
-
).toBePositionedPopover()
|
|
287
|
-
);
|
|
288
|
-
} );
|
|
289
|
-
|
|
290
|
-
it( 'should render the shortcut display text and aria-label when an object is passed as the shortcut with the correct properties', async () => {
|
|
291
|
-
const user = userEvent.setup();
|
|
292
|
-
|
|
293
|
-
render(
|
|
294
|
-
<Tooltip
|
|
295
|
-
{ ...props }
|
|
296
|
-
shortcut={ {
|
|
297
|
-
display: '⇧⌘,',
|
|
298
|
-
ariaLabel: shortcutAriaLabel.primaryShift( ',' ),
|
|
299
|
-
} }
|
|
300
|
-
>
|
|
301
|
-
<Button>Hover Me!</Button>
|
|
302
|
-
</Tooltip>
|
|
303
|
-
);
|
|
304
|
-
|
|
305
|
-
await user.hover( screen.getByRole( 'button', { name: 'Hover Me!' } ) );
|
|
306
|
-
|
|
307
|
-
await waitFor( () =>
|
|
308
|
-
expect( screen.getByText( '⇧⌘,' ) ).toBeVisible()
|
|
309
|
-
);
|
|
310
|
-
|
|
311
|
-
expect( screen.getByText( '⇧⌘,' ) ).toHaveAttribute(
|
|
312
|
-
'aria-label',
|
|
313
|
-
'Control + Shift + Comma'
|
|
314
|
-
);
|
|
315
|
-
|
|
316
|
-
// Wait for the tooltip element to be positioned (aligned with the button)
|
|
317
|
-
await waitFor( () =>
|
|
318
|
-
expect(
|
|
319
|
-
getWrappingPopoverElement( screen.getByText( '⇧⌘,' ) )
|
|
320
|
-
).toBePositionedPopover()
|
|
321
|
-
);
|
|
322
|
-
} );
|
|
323
|
-
} );
|