@wordpress/components 25.14.0 → 25.15.0
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 +50 -0
- package/CONTRIBUTING.md +57 -115
- package/LICENSE.md +1 -1
- package/build/base-control/index.js +17 -13
- package/build/base-control/index.js.map +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build/border-control/border-control-style-picker/component.js +1 -1
- package/build/border-control/border-control-style-picker/component.js.map +1 -1
- package/build/box-control/index.js +1 -1
- package/build/box-control/index.js.map +1 -1
- package/build/box-control/linked-button.js +1 -1
- package/build/box-control/linked-button.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/color-picker/color-copy-button.js +1 -1
- package/build/color-picker/color-copy-button.js.map +1 -1
- package/build/context/wordpress-component.js.map +1 -1
- package/build/custom-select-control-v2/index.js +11 -10
- package/build/custom-select-control-v2/index.js.map +1 -1
- package/build/date-time/date/styles.js +8 -8
- package/build/date-time/date/styles.js.map +1 -1
- package/build/dropdown-menu-v2/index.js +205 -159
- package/build/dropdown-menu-v2/index.js.map +1 -1
- package/build/dropdown-menu-v2/styles.js +86 -77
- package/build/dropdown-menu-v2/styles.js.map +1 -1
- package/build/dropdown-menu-v2/types.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +4 -3
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/font-size-picker/index.js +4 -2
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/index.native.js +6 -3
- package/build/font-size-picker/index.native.js.map +1 -1
- package/build/form-token-field/index.js +10 -5
- package/build/form-token-field/index.js.map +1 -1
- package/build/form-token-field/token.js +1 -0
- package/build/form-token-field/token.js.map +1 -1
- package/build/gradient-picker/index.js +3 -2
- package/build/gradient-picker/index.js.map +1 -1
- package/build/index.native.js +20 -3
- package/build/index.native.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +32 -29
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/input-control/types.js.map +1 -1
- package/build/lock-unlock.js +18 -0
- package/build/lock-unlock.js.map +1 -0
- package/build/mobile/bottom-sheet/index.native.js +8 -0
- package/build/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +26 -13
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/image/constants.js +12 -0
- package/build/mobile/image/constants.js.map +1 -0
- package/build/mobile/image/index.native.js +26 -18
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.android.js +40 -8
- package/build/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/index.ios.js +44 -68
- package/build/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +39 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -29
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js +93 -0
- package/build/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js +302 -0
- package/build/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build/modal/index.js +18 -13
- package/build/modal/index.js.map +1 -1
- package/build/navigation/menu/menu-title.js +1 -1
- package/build/navigation/menu/menu-title.js.map +1 -1
- package/build/navigator/navigator-provider/component.js +13 -15
- package/build/navigator/navigator-provider/component.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +23 -63
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/navigator/styles.js +52 -0
- package/build/navigator/styles.js.map +1 -0
- package/build/number-control/index.js +4 -8
- package/build/number-control/index.js.map +1 -1
- package/build/number-control/types.js.map +1 -1
- package/build/palette-edit/index.js +15 -54
- package/build/palette-edit/index.js.map +1 -1
- package/build/private-apis.js +11 -26
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +21 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/radio-control/index.js +1 -0
- package/build/radio-control/index.js.map +1 -1
- package/build/range-control/index.js +1 -1
- package/build/range-control/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +15 -25
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/slot-fill/index.js +3 -2
- package/build/slot-fill/index.js.map +1 -1
- package/build/slot-fill/types.js.map +1 -1
- package/build/snackbar/types.js.map +1 -1
- package/build/tabs/styles.js +3 -3
- package/build/tabs/styles.js.map +1 -1
- package/build/tabs/tabpanel.js +9 -7
- package/build/tabs/tabpanel.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +4 -4
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/styles.js +29 -15
- package/build/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +3 -1
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +9 -8
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/types.js.map +1 -1
- package/build/tooltip/index.js +1 -1
- package/build/tooltip/index.js.map +1 -1
- package/build/truncate/hook.js +10 -4
- package/build/truncate/hook.js.map +1 -1
- package/build/truncate/types.js.map +1 -1
- package/build/unit-control/index.js +1 -1
- package/build/unit-control/index.js.map +1 -1
- package/build/utils/strings.js +34 -3
- package/build/utils/strings.js.map +1 -1
- package/build-module/base-control/index.js +16 -12
- package/build-module/base-control/index.js.map +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js +1 -1
- package/build-module/border-box-control/border-box-control-linked-button/component.js.map +1 -1
- package/build-module/border-control/border-control-style-picker/component.js +1 -1
- package/build-module/border-control/border-control-style-picker/component.js.map +1 -1
- package/build-module/box-control/index.js +1 -1
- package/build-module/box-control/index.js.map +1 -1
- package/build-module/box-control/linked-button.js +1 -1
- package/build-module/box-control/linked-button.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/color-picker/color-copy-button.js +1 -1
- package/build-module/color-picker/color-copy-button.js.map +1 -1
- package/build-module/context/wordpress-component.js.map +1 -1
- package/build-module/custom-select-control-v2/index.js +11 -10
- package/build-module/custom-select-control-v2/index.js.map +1 -1
- package/build-module/date-time/date/styles.js +8 -8
- package/build-module/date-time/date/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2/index.js +201 -154
- package/build-module/dropdown-menu-v2/index.js.map +1 -1
- package/build-module/dropdown-menu-v2/styles.js +68 -61
- package/build-module/dropdown-menu-v2/styles.js.map +1 -1
- package/build-module/dropdown-menu-v2/types.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +4 -3
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/font-size-picker/index.js +4 -2
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/index.native.js +5 -2
- package/build-module/font-size-picker/index.native.js.map +1 -1
- package/build-module/form-token-field/index.js +10 -5
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/form-token-field/token.js +1 -0
- package/build-module/form-token-field/token.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -2
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/index.native.js +6 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +31 -29
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/input-control/types.js.map +1 -1
- package/build-module/lock-unlock.js +9 -0
- package/build-module/lock-unlock.js.map +1 -0
- package/build-module/mobile/bottom-sheet/index.native.js +9 -1
- package/build-module/mobile/bottom-sheet/index.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +25 -13
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/image/constants.js +5 -0
- package/build-module/mobile/image/constants.js.map +1 -0
- package/build-module/mobile/image/index.native.js +25 -16
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js +40 -6
- package/build-module/mobile/keyboard-aware-flat-list/index.android.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js +46 -68
- package/build-module/mobile/keyboard-aware-flat-list/index.ios.js.map +1 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +33 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +21 -27
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-section.native.js.map +1 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js +86 -0
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll.native.js.map +1 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js +294 -0
- package/build-module/mobile/utils/get-px-from-css-unit.native.js.map +1 -0
- package/build-module/modal/index.js +18 -13
- package/build-module/modal/index.js.map +1 -1
- package/build-module/navigation/menu/menu-title.js +1 -1
- package/build-module/navigation/menu/menu-title.js.map +1 -1
- package/build-module/navigator/navigator-provider/component.js +3 -16
- package/build-module/navigator/navigator-provider/component.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +16 -70
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/navigator/styles.js +47 -0
- package/build-module/navigator/styles.js.map +1 -0
- package/build-module/number-control/index.js +4 -8
- package/build-module/number-control/index.js.map +1 -1
- package/build-module/number-control/types.js.map +1 -1
- package/build-module/palette-edit/index.js +15 -51
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/private-apis.js +10 -23
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +14 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/radio-control/index.js +1 -0
- package/build-module/radio-control/index.js.map +1 -1
- package/build-module/range-control/index.js +1 -1
- package/build-module/range-control/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +15 -25
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/slot-fill/index.js +3 -2
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/slot-fill/types.js.map +1 -1
- package/build-module/snackbar/types.js.map +1 -1
- package/build-module/tabs/styles.js +3 -3
- package/build-module/tabs/styles.js.map +1 -1
- package/build-module/tabs/tabpanel.js +9 -7
- package/build-module/tabs/tabpanel.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +4 -4
- 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 +29 -15
- package/build-module/toggle-group-control/toggle-group-control/styles.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +9 -9
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +3 -1
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +9 -8
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/types.js.map +1 -1
- package/build-module/tooltip/index.js +1 -1
- package/build-module/tooltip/index.js.map +1 -1
- package/build-module/truncate/hook.js +10 -4
- package/build-module/truncate/hook.js.map +1 -1
- package/build-module/truncate/types.js.map +1 -1
- package/build-module/unit-control/index.js +1 -1
- package/build-module/unit-control/index.js.map +1 -1
- package/build-module/utils/strings.js +32 -2
- package/build-module/utils/strings.js.map +1 -1
- package/build-style/style-rtl.css +29 -5
- package/build-style/style.css +29 -5
- package/build-types/base-control/index.d.ts +3 -27
- package/build-types/base-control/index.d.ts.map +1 -1
- package/build-types/base-control/stories/index.story.d.ts +4 -1
- package/build-types/base-control/stories/index.story.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/stories/index.story.d.ts.map +1 -1
- package/build-types/composite/test/index.d.ts.map +1 -0
- package/build-types/context/wordpress-component.d.ts +3 -3
- package/build-types/context/wordpress-component.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/index.d.ts +3 -2
- package/build-types/custom-select-control-v2/index.d.ts.map +1 -1
- package/build-types/custom-select-control-v2/stories/index.story.d.ts +4 -3
- package/build-types/custom-select-control-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown/index.d.ts +1 -1
- package/build-types/dropdown/index.d.ts.map +1 -1
- package/build-types/dropdown/stories/index.story.d.ts +3 -3
- package/build-types/dropdown/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu/index.d.ts +1 -1
- package/build-types/dropdown-menu/index.d.ts.map +1 -1
- package/build-types/dropdown-menu/stories/index.story.d.ts +2 -2
- package/build-types/dropdown-menu/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/index.d.ts +18 -15
- package/build-types/dropdown-menu-v2/index.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts +7 -2
- package/build-types/dropdown-menu-v2/stories/index.story.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/styles.d.ts +77 -23
- package/build-types/dropdown-menu-v2/styles.d.ts.map +1 -1
- package/build-types/dropdown-menu-v2/types.d.ts +89 -173
- package/build-types/dropdown-menu-v2/types.d.ts.map +1 -1
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -1
- package/build-types/font-size-picker/index.d.ts.map +1 -1
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/token.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +11 -0
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +1 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts +3 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/mobile/image/constants.d.ts +5 -0
- package/build-types/mobile/image/constants.d.ts.map +1 -0
- package/build-types/modal/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-provider/component.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts +1 -7
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/navigator/styles.d.ts +9 -0
- package/build-types/navigator/styles.d.ts.map +1 -0
- package/build-types/number-control/index.d.ts.map +1 -1
- package/build-types/number-control/types.d.ts +1 -1
- package/build-types/palette-edit/index.d.ts +3 -8
- package/build-types/palette-edit/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/stories/e2e/index.story.d.ts +1 -1
- package/build-types/private-apis.d.ts +0 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/radio-control/index.d.ts.map +1 -1
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -1
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/slot-fill/types.d.ts +4 -0
- package/build-types/slot-fill/types.d.ts.map +1 -1
- package/build-types/snackbar/index.d.ts +2 -2
- package/build-types/snackbar/stories/index.story.d.ts +0 -3
- package/build-types/snackbar/stories/index.story.d.ts.map +1 -1
- package/build-types/snackbar/types.d.ts +1 -1
- package/build-types/snackbar/types.d.ts.map +1 -1
- package/build-types/tabs/styles.d.ts.map +1 -1
- package/build-types/tabs/tabpanel.d.ts +1 -1
- package/build-types/tabs/tabpanel.d.ts.map +1 -1
- 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 +2 -2
- package/build-types/toggle-group-control/toggle-group-control/styles.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/component.d.ts +1 -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.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +1 -0
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +1 -0
- package/build-types/tools-panel/tools-panel-header/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +9 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +1 -1
- package/build-types/truncate/hook.d.ts.map +1 -1
- package/build-types/truncate/types.d.ts +4 -0
- package/build-types/truncate/types.d.ts.map +1 -1
- package/build-types/utils/strings.d.ts +14 -2
- package/build-types/utils/strings.d.ts.map +1 -1
- package/package.json +20 -21
- package/src/alignment-matrix-control/test/index.tsx +10 -16
- package/src/base-control/index.tsx +21 -16
- package/src/border-box-control/border-box-control-linked-button/component.tsx +1 -1
- package/src/border-control/border-control-style-picker/component.tsx +1 -1
- package/src/box-control/index.tsx +1 -1
- package/src/box-control/linked-button.tsx +1 -1
- package/src/button/README.md +32 -6
- package/src/button/index.tsx +1 -1
- package/src/button-group/README.md +0 -6
- package/src/card/card/README.md +1 -1
- package/src/checkbox-control/README.md +1 -9
- package/src/color-picker/color-copy-button.tsx +1 -1
- package/src/combobox-control/README.md +0 -6
- package/src/composite/test/index.tsx +576 -0
- package/src/context/wordpress-component.ts +11 -6
- package/src/custom-select-control/README.md +0 -6
- package/src/custom-select-control-v2/index.tsx +13 -12
- package/src/date-time/date/styles.ts +3 -3
- package/src/dropdown-menu/README.md +0 -5
- package/src/dropdown-menu-v2/README.md +75 -136
- package/src/dropdown-menu-v2/index.tsx +321 -231
- package/src/dropdown-menu-v2/stories/index.story.tsx +522 -126
- package/src/dropdown-menu-v2/styles.ts +226 -151
- package/src/dropdown-menu-v2/test/index.tsx +480 -188
- package/src/dropdown-menu-v2/types.ts +98 -184
- package/src/duotone-picker/duotone-picker.tsx +7 -3
- package/src/font-size-picker/index.native.js +8 -2
- package/src/font-size-picker/index.tsx +4 -2
- package/src/form-toggle/README.md +0 -6
- package/src/form-token-field/index.tsx +11 -7
- package/src/form-token-field/test/index.tsx +97 -0
- package/src/form-token-field/token.tsx +1 -0
- package/src/gradient-picker/index.tsx +2 -2
- package/src/index.native.js +6 -1
- package/src/input-control/styles/input-control-styles.tsx +10 -8
- package/src/input-control/types.ts +1 -1
- package/src/lock-unlock.js +10 -0
- package/src/menu-group/README.md +0 -8
- package/src/menu-items-choice/README.md +0 -7
- package/src/mobile/bottom-sheet/index.native.js +15 -1
- package/src/mobile/global-styles-context/test/fixtures/theme.native.js +0 -20
- package/src/mobile/global-styles-context/utils.native.js +28 -19
- package/src/mobile/image/constants.js +1 -0
- package/src/mobile/image/index.native.js +55 -18
- package/src/mobile/image/style.native.scss +35 -9
- package/src/mobile/keyboard-aware-flat-list/index.android.js +50 -5
- package/src/mobile/keyboard-aware-flat-list/index.ios.js +65 -91
- package/src/mobile/keyboard-aware-flat-list/test/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +27 -25
- package/src/mobile/keyboard-aware-flat-list/test/use-scroll.native.js +71 -0
- package/src/mobile/keyboard-aware-flat-list/use-scroll-to-element.native.js +41 -0
- package/src/mobile/keyboard-aware-flat-list/{use-scroll-to-text-input.native.js → use-scroll-to-section.native.js} +22 -27
- package/src/mobile/keyboard-aware-flat-list/use-scroll.native.js +100 -0
- package/src/mobile/utils/get-px-from-css-unit.native.js +329 -0
- package/src/mobile/utils/test/get-px-from-css-unit.native.js +172 -0
- package/src/modal/README.md +0 -6
- package/src/modal/index.tsx +18 -16
- package/src/modal/test/index.tsx +90 -1
- package/src/navigation/menu/menu-title.tsx +1 -1
- package/src/navigator/navigator-provider/component.tsx +3 -4
- package/src/navigator/navigator-screen/component.tsx +15 -93
- package/src/navigator/styles.ts +71 -0
- package/src/navigator/test/index.tsx +0 -64
- package/src/notice/README.md +0 -6
- package/src/number-control/README.md +2 -2
- package/src/number-control/index.tsx +4 -8
- package/src/number-control/types.ts +1 -1
- package/src/palette-edit/index.tsx +15 -58
- package/src/palette-edit/test/index.tsx +1 -75
- package/src/panel/README.md +0 -6
- package/src/private-apis.native.js +13 -0
- package/src/private-apis.ts +12 -37
- package/src/radio-control/README.md +0 -6
- package/src/radio-control/index.tsx +4 -1
- package/src/radio-control/style.scss +29 -2
- package/src/radio-group/README.md +0 -6
- package/src/range-control/README.md +1 -9
- package/src/range-control/index.tsx +1 -1
- package/src/search-control/README.md +0 -6
- package/src/select-control/README.md +0 -6
- package/src/select-control/styles/select-control-styles.ts +10 -28
- package/src/slot-fill/index.tsx +5 -2
- package/src/slot-fill/types.ts +5 -0
- package/src/snackbar/README.md +0 -6
- package/src/snackbar/stories/index.story.tsx +7 -5
- package/src/snackbar/style.scss +4 -3
- package/src/snackbar/types.ts +2 -1
- package/src/spacer/README.md +0 -2
- package/src/tab-panel/README.md +0 -5
- package/src/tab-panel/test/index.tsx +39 -56
- package/src/tabs/styles.ts +7 -1
- package/src/tabs/tabpanel.tsx +7 -6
- package/src/tabs/test/index.tsx +56 -0
- package/src/text-control/README.md +0 -6
- package/src/textarea-control/README.md +0 -6
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +12 -16
- package/src/toggle-group-control/test/index.tsx +58 -45
- package/src/toggle-group-control/toggle-group-control/component.tsx +5 -4
- package/src/toggle-group-control/toggle-group-control/styles.ts +13 -19
- package/src/toggle-group-control/toggle-group-control-option/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/README.md +1 -1
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +3 -2
- package/src/toggle-group-control/toggle-group-control-option-icon/README.md +1 -1
- package/src/toolbar/toolbar/README.md +0 -6
- package/src/tools-panel/test/index.tsx +12 -20
- package/src/tools-panel/tools-panel/README.md +7 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -0
- package/src/tools-panel/tools-panel-header/README.md +7 -0
- package/src/tools-panel/tools-panel-header/component.tsx +20 -13
- package/src/tools-panel/types.ts +9 -0
- package/src/tooltip/index.tsx +1 -1
- package/src/tooltip/test/index.tsx +360 -256
- package/src/tree-grid/README.md +0 -4
- package/src/truncate/README.md +8 -0
- package/src/truncate/hook.ts +17 -10
- package/src/truncate/test/index.tsx +54 -27
- package/src/truncate/types.ts +4 -0
- package/src/unit-control/index.tsx +1 -1
- package/src/utils/strings.ts +30 -2
- package/src/utils/test/strings.js +96 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/dropdown-menu-v2-ariakit/index.js +0 -256
- package/build/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/styles.js +0 -180
- package/build/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build/dropdown-menu-v2-ariakit/types.js +0 -6
- package/build/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/index.js +0 -237
- package/build-module/dropdown-menu-v2-ariakit/index.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/styles.js +0 -165
- package/build-module/dropdown-menu-v2-ariakit/styles.js.map +0 -1
- package/build-module/dropdown-menu-v2-ariakit/types.js +0 -2
- package/build-module/dropdown-menu-v2-ariakit/types.js.map +0 -1
- package/build-module/mobile/keyboard-aware-flat-list/use-scroll-to-text-input.native.js.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts +0 -20
- package/build-types/dropdown-menu-v2-ariakit/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts +0 -16
- package/build-types/dropdown-menu-v2-ariakit/stories/index.story.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts +0 -96
- package/build-types/dropdown-menu-v2-ariakit/styles.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/test/index.d.ts.map +0 -1
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts +0 -168
- package/build-types/dropdown-menu-v2-ariakit/types.d.ts.map +0 -1
- package/src/dropdown-menu-v2-ariakit/README.md +0 -331
- package/src/dropdown-menu-v2-ariakit/index.tsx +0 -383
- package/src/dropdown-menu-v2-ariakit/stories/index.story.tsx +0 -617
- package/src/dropdown-menu-v2-ariakit/styles.ts +0 -345
- package/src/dropdown-menu-v2-ariakit/test/index.tsx +0 -1108
- package/src/dropdown-menu-v2-ariakit/types.ts +0 -179
- /package/build-types/{dropdown-menu-v2-ariakit → composite}/test/index.d.ts +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
5
|
-
import
|
|
5
|
+
import { press, hover, click, sleep } from '@ariakit/test';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -15,321 +15,425 @@ import { shortcutAriaLabel } from '@wordpress/keycodes';
|
|
|
15
15
|
import Button from '../../button';
|
|
16
16
|
import Modal from '../../modal';
|
|
17
17
|
import Tooltip, { TOOLTIP_DELAY } from '..';
|
|
18
|
-
import cleanupTooltip from './utils/';
|
|
19
18
|
|
|
20
19
|
const props = {
|
|
21
|
-
children: <Button>
|
|
20
|
+
children: <Button>Tooltip anchor</Button>,
|
|
22
21
|
text: 'tooltip text',
|
|
23
22
|
};
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// @ts-expect-error
|
|
30
|
-
<Tooltip { ...props }>
|
|
31
|
-
<Button>This is a button</Button>
|
|
32
|
-
<Button>This is another button</Button>
|
|
33
|
-
</Tooltip>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
38
|
-
).not.toBeInTheDocument();
|
|
39
|
-
} );
|
|
24
|
+
const expectTooltipToBeVisible = () =>
|
|
25
|
+
expect(
|
|
26
|
+
screen.getByRole( 'tooltip', { name: 'tooltip text' } )
|
|
27
|
+
).toBeVisible();
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
const expectTooltipToBeHidden = () =>
|
|
30
|
+
expect(
|
|
31
|
+
screen.queryByRole( 'tooltip', { name: 'tooltip text' } )
|
|
32
|
+
).not.toBeInTheDocument();
|
|
43
33
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
).toBeVisible();
|
|
34
|
+
const waitExpectTooltipToShow = async ( timeout = TOOLTIP_DELAY ) =>
|
|
35
|
+
await waitFor( expectTooltipToBeVisible, { timeout } );
|
|
47
36
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
).not.toBeInTheDocument();
|
|
51
|
-
} );
|
|
37
|
+
const waitExpectTooltipToHide = async () =>
|
|
38
|
+
await waitFor( expectTooltipToBeHidden );
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
const hoverOutside = async () => {
|
|
41
|
+
await hover( document.body );
|
|
42
|
+
await hover( document.body, { clientX: 10, clientY: 10 } );
|
|
43
|
+
};
|
|
55
44
|
|
|
56
|
-
|
|
45
|
+
describe( 'Tooltip', () => {
|
|
46
|
+
// Wait enough time to make sure that tooltips don't show immediately, ignoring
|
|
47
|
+
// the showTimeout delay. For more context, see:
|
|
48
|
+
// - https://github.com/WordPress/gutenberg/pull/57345#discussion_r1435167187
|
|
49
|
+
// - https://ariakit.org/reference/tooltip-provider#skiptimeout
|
|
50
|
+
afterEach( async () => {
|
|
51
|
+
await sleep( 300 );
|
|
52
|
+
} );
|
|
57
53
|
|
|
58
|
-
|
|
54
|
+
describe( 'basic behavior', () => {
|
|
55
|
+
it( 'should not render the tooltip if multiple children are passed', async () => {
|
|
56
|
+
render(
|
|
57
|
+
// @ts-expect-error Tooltip cannot have more than one child element
|
|
58
|
+
<Tooltip { ...props }>
|
|
59
|
+
<Button>First button</Button>
|
|
60
|
+
<Button>Second button</Button>
|
|
61
|
+
</Tooltip>
|
|
62
|
+
);
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
expect(
|
|
65
|
+
screen.getByRole( 'button', { name: 'First button' } )
|
|
66
|
+
).toBeVisible();
|
|
67
|
+
expect(
|
|
68
|
+
screen.getByRole( 'button', { name: 'Second button' } )
|
|
69
|
+
).toBeVisible();
|
|
63
70
|
|
|
64
|
-
|
|
65
|
-
await screen.findByRole( 'tooltip', { name: /tooltip text/i } )
|
|
66
|
-
).toBeVisible();
|
|
71
|
+
await press.Tab();
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
expectTooltipToBeHidden();
|
|
74
|
+
} );
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
it( 'should associate the tooltip text with its anchor via the accessible description when visible', async () => {
|
|
77
|
+
render( <Tooltip { ...props } /> );
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
// The anchor can not be found by querying for its description,
|
|
80
|
+
// since that is present only when the tooltip is visible
|
|
81
|
+
expect(
|
|
82
|
+
screen.queryByRole( 'button', { description: 'tooltip text' } )
|
|
83
|
+
).not.toBeInTheDocument();
|
|
84
|
+
|
|
85
|
+
// Hover the anchor. The tooltip shows and its text is used to describe
|
|
86
|
+
// the tooltip anchor
|
|
87
|
+
await hover(
|
|
88
|
+
screen.getByRole( 'button', {
|
|
89
|
+
name: 'Tooltip anchor',
|
|
90
|
+
} )
|
|
91
|
+
);
|
|
92
|
+
expect(
|
|
93
|
+
await screen.findByRole( 'button', {
|
|
94
|
+
description: 'tooltip text',
|
|
95
|
+
} )
|
|
96
|
+
).toBeInTheDocument();
|
|
97
|
+
|
|
98
|
+
// Hover outside of the anchor, tooltip should hide
|
|
99
|
+
await hoverOutside();
|
|
100
|
+
await waitExpectTooltipToHide();
|
|
101
|
+
expect(
|
|
102
|
+
screen.queryByRole( 'button', { description: 'tooltip text' } )
|
|
103
|
+
).not.toBeInTheDocument();
|
|
104
|
+
} );
|
|
105
|
+
} );
|
|
75
106
|
|
|
76
|
-
|
|
107
|
+
describe( 'keyboard focus', () => {
|
|
108
|
+
it( 'should not render the tooltip if there is no focus', () => {
|
|
109
|
+
render( <Tooltip { ...props } /> );
|
|
77
110
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
111
|
+
expect(
|
|
112
|
+
screen.getByRole( 'button', { name: 'Tooltip anchor' } )
|
|
113
|
+
).toBeVisible();
|
|
114
|
+
|
|
115
|
+
expectTooltipToBeHidden();
|
|
116
|
+
} );
|
|
117
|
+
|
|
118
|
+
it( 'should show the tooltip when focusing on the tooltip anchor and hide it the anchor loses focus', async () => {
|
|
119
|
+
render(
|
|
120
|
+
<>
|
|
121
|
+
<Tooltip { ...props } />
|
|
122
|
+
<button>Focus me</button>
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
// Focus the anchor, tooltip should show
|
|
127
|
+
await press.Tab();
|
|
128
|
+
expect(
|
|
129
|
+
screen.getByRole( 'button', { name: 'Tooltip anchor' } )
|
|
130
|
+
).toHaveFocus();
|
|
131
|
+
await waitExpectTooltipToShow();
|
|
81
132
|
|
|
82
|
-
|
|
133
|
+
// Focus the other button, tooltip should hide
|
|
134
|
+
await press.Tab();
|
|
135
|
+
expect(
|
|
136
|
+
screen.getByRole( 'button', { name: 'Focus me' } )
|
|
137
|
+
).toHaveFocus();
|
|
138
|
+
await waitExpectTooltipToHide();
|
|
139
|
+
} );
|
|
140
|
+
|
|
141
|
+
it( 'should show tooltip when focussing a disabled (but focussable) anchor button', async () => {
|
|
142
|
+
render(
|
|
143
|
+
<>
|
|
144
|
+
<Tooltip { ...props }>
|
|
145
|
+
<Button disabled __experimentalIsFocusable>
|
|
146
|
+
Tooltip anchor
|
|
147
|
+
</Button>
|
|
148
|
+
</Tooltip>
|
|
149
|
+
<button>Focus me</button>
|
|
150
|
+
</>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
const anchor = screen.getByRole( 'button', {
|
|
154
|
+
name: 'Tooltip anchor',
|
|
155
|
+
} );
|
|
156
|
+
|
|
157
|
+
expect( anchor ).toBeVisible();
|
|
158
|
+
expect( anchor ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
159
|
+
|
|
160
|
+
// Focus anchor, tooltip should show
|
|
161
|
+
await press.Tab();
|
|
162
|
+
expect( anchor ).toHaveFocus();
|
|
163
|
+
await waitExpectTooltipToShow();
|
|
164
|
+
|
|
165
|
+
// Focus another button, tooltip should hide
|
|
166
|
+
await press.Tab();
|
|
167
|
+
expect(
|
|
168
|
+
screen.getByRole( 'button', {
|
|
169
|
+
name: 'Focus me',
|
|
170
|
+
} )
|
|
171
|
+
).toHaveFocus();
|
|
172
|
+
await waitExpectTooltipToHide();
|
|
173
|
+
} );
|
|
83
174
|
} );
|
|
84
175
|
|
|
85
|
-
|
|
86
|
-
|
|
176
|
+
describe( 'mouse hover', () => {
|
|
177
|
+
it( 'should show the tooltip when the tooltip anchor is hovered and hide it when the cursor stops hovering the anchor', async () => {
|
|
178
|
+
render( <Tooltip { ...props } /> );
|
|
179
|
+
|
|
180
|
+
const anchor = screen.getByRole( 'button', {
|
|
181
|
+
name: 'Tooltip anchor',
|
|
182
|
+
} );
|
|
183
|
+
|
|
184
|
+
expect( anchor ).toBeVisible();
|
|
185
|
+
|
|
186
|
+
// Hover over the anchor, tooltip should show
|
|
187
|
+
await hover( anchor );
|
|
188
|
+
await waitExpectTooltipToShow();
|
|
189
|
+
|
|
190
|
+
// Hover outside of the anchor, tooltip should hide
|
|
191
|
+
await hoverOutside();
|
|
192
|
+
await waitExpectTooltipToHide();
|
|
193
|
+
} );
|
|
194
|
+
|
|
195
|
+
it( 'should show tooltip when hovering over a disabled (but focussable) anchor button', async () => {
|
|
196
|
+
render(
|
|
197
|
+
<>
|
|
198
|
+
<Tooltip { ...props }>
|
|
199
|
+
<Button disabled __experimentalIsFocusable>
|
|
200
|
+
Tooltip anchor
|
|
201
|
+
</Button>
|
|
202
|
+
</Tooltip>
|
|
203
|
+
<button>Focus me</button>
|
|
204
|
+
</>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
const anchor = screen.getByRole( 'button', {
|
|
208
|
+
name: 'Tooltip anchor',
|
|
209
|
+
} );
|
|
210
|
+
|
|
211
|
+
expect( anchor ).toBeVisible();
|
|
212
|
+
expect( anchor ).toHaveAttribute( 'aria-disabled', 'true' );
|
|
213
|
+
|
|
214
|
+
// Hover over the anchor, tooltip should show
|
|
215
|
+
await hover( anchor );
|
|
216
|
+
await waitExpectTooltipToShow();
|
|
217
|
+
|
|
218
|
+
// Hover outside of the anchor, tooltip should hide
|
|
219
|
+
await hoverOutside();
|
|
220
|
+
await waitExpectTooltipToHide();
|
|
221
|
+
} );
|
|
222
|
+
} );
|
|
87
223
|
|
|
88
|
-
|
|
224
|
+
describe( 'mouse click', () => {
|
|
225
|
+
it( 'should hide tooltip when the tooltip anchor is clicked', async () => {
|
|
226
|
+
render( <Tooltip { ...props } /> );
|
|
89
227
|
|
|
90
|
-
|
|
228
|
+
const anchor = screen.getByRole( 'button', {
|
|
229
|
+
name: 'Tooltip anchor',
|
|
230
|
+
} );
|
|
91
231
|
|
|
92
|
-
|
|
93
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
94
|
-
).not.toBeInTheDocument();
|
|
232
|
+
expect( anchor ).toBeVisible();
|
|
95
233
|
|
|
96
|
-
|
|
97
|
-
|
|
234
|
+
// Hover over the anchor, tooltip should show
|
|
235
|
+
await hover( anchor );
|
|
236
|
+
await waitExpectTooltipToShow();
|
|
98
237
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
238
|
+
// Click the anchor, tooltip should hide
|
|
239
|
+
await click( anchor );
|
|
240
|
+
await waitExpectTooltipToHide();
|
|
241
|
+
} );
|
|
102
242
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
243
|
+
it( 'should not hide tooltip when the tooltip anchor is clicked and the `hideOnClick` prop is `false', async () => {
|
|
244
|
+
render(
|
|
245
|
+
<>
|
|
246
|
+
<Tooltip { ...props } hideOnClick={ false } />
|
|
247
|
+
<button>Click me</button>
|
|
248
|
+
</>
|
|
249
|
+
);
|
|
106
250
|
|
|
107
|
-
|
|
251
|
+
const anchor = screen.getByRole( 'button', {
|
|
252
|
+
name: 'Tooltip anchor',
|
|
253
|
+
} );
|
|
108
254
|
|
|
109
|
-
|
|
110
|
-
await new Promise( ( resolve ) =>
|
|
111
|
-
setTimeout( resolve, TOOLTIP_DELAY )
|
|
112
|
-
);
|
|
255
|
+
expect( anchor ).toBeVisible();
|
|
113
256
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
).not.toBeInTheDocument();
|
|
257
|
+
// Hover over the anchor, tooltip should show
|
|
258
|
+
await hover( anchor );
|
|
259
|
+
await waitExpectTooltipToShow();
|
|
118
260
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
()
|
|
122
|
-
new Promise( ( resolve ) =>
|
|
123
|
-
setTimeout( resolve, ADDITIONAL_DELAY )
|
|
124
|
-
)
|
|
125
|
-
);
|
|
261
|
+
// Click the anchor, tooltip should not hide
|
|
262
|
+
await click( anchor );
|
|
263
|
+
await waitExpectTooltipToShow();
|
|
126
264
|
|
|
127
|
-
|
|
128
|
-
screen.getByRole( '
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
await cleanupTooltip( user );
|
|
265
|
+
// Click another button, tooltip should hide
|
|
266
|
+
await click( screen.getByRole( 'button', { name: 'Click me' } ) );
|
|
267
|
+
await waitExpectTooltipToHide();
|
|
268
|
+
} );
|
|
132
269
|
} );
|
|
133
270
|
|
|
134
|
-
|
|
135
|
-
|
|
271
|
+
describe( 'delay', () => {
|
|
272
|
+
it( 'should respect custom delay prop when showing tooltip', async () => {
|
|
273
|
+
const ADDITIONAL_DELAY = 100;
|
|
136
274
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
275
|
+
render(
|
|
276
|
+
<Tooltip
|
|
277
|
+
{ ...props }
|
|
278
|
+
delay={ TOOLTIP_DELAY + ADDITIONAL_DELAY }
|
|
279
|
+
/>
|
|
280
|
+
);
|
|
142
281
|
|
|
143
|
-
|
|
282
|
+
const anchor = screen.getByRole( 'button', {
|
|
283
|
+
name: 'Tooltip anchor',
|
|
284
|
+
} );
|
|
285
|
+
expect( anchor ).toBeVisible();
|
|
144
286
|
|
|
145
|
-
|
|
146
|
-
|
|
287
|
+
// Hover over the anchor
|
|
288
|
+
await hover( anchor );
|
|
289
|
+
expectTooltipToBeHidden();
|
|
147
290
|
|
|
148
|
-
|
|
291
|
+
// Advance time by default delay
|
|
292
|
+
await sleep( TOOLTIP_DELAY );
|
|
149
293
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
).toBeVisible();
|
|
294
|
+
// Tooltip hasn't appeared yet
|
|
295
|
+
expectTooltipToBeHidden();
|
|
153
296
|
|
|
154
|
-
|
|
155
|
-
|
|
297
|
+
// Wait for additional delay for tooltip to appear
|
|
298
|
+
await sleep( ADDITIONAL_DELAY );
|
|
299
|
+
await waitExpectTooltipToShow();
|
|
156
300
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const MOUSE_LEAVE_DELAY = TOOLTIP_DELAY - 200;
|
|
301
|
+
// Hover outside of the anchor, tooltip should hide
|
|
302
|
+
await hoverOutside();
|
|
303
|
+
await waitExpectTooltipToHide();
|
|
304
|
+
} );
|
|
162
305
|
|
|
163
|
-
|
|
164
|
-
|
|
306
|
+
it( 'should not show tooltip if the mouse leaves the tooltip anchor before set delay', async () => {
|
|
307
|
+
const onMouseEnterMock = jest.fn();
|
|
308
|
+
const onMouseLeaveMock = jest.fn();
|
|
309
|
+
const HOVER_OUTSIDE_ANTICIPATION = 200;
|
|
310
|
+
|
|
311
|
+
render(
|
|
165
312
|
<Tooltip { ...props }>
|
|
166
313
|
<Button
|
|
167
314
|
onMouseEnter={ onMouseEnterMock }
|
|
168
315
|
onMouseLeave={ onMouseLeaveMock }
|
|
169
316
|
>
|
|
170
|
-
|
|
317
|
+
Tooltip anchor
|
|
171
318
|
</Button>
|
|
172
319
|
</Tooltip>
|
|
173
|
-
|
|
174
|
-
</>
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
await user.hover(
|
|
178
|
-
screen.getByRole( 'button', {
|
|
179
|
-
name: 'Button 1',
|
|
180
|
-
} )
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
// Tooltip hasn't appeared yet
|
|
184
|
-
expect(
|
|
185
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
186
|
-
).not.toBeInTheDocument();
|
|
187
|
-
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
188
|
-
|
|
189
|
-
// Advance time by MOUSE_LEAVE_DELAY time
|
|
190
|
-
await new Promise( ( resolve ) =>
|
|
191
|
-
setTimeout( resolve, MOUSE_LEAVE_DELAY )
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
expect(
|
|
195
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
196
|
-
).not.toBeInTheDocument();
|
|
197
|
-
|
|
198
|
-
// Hover the other button, meaning that the mouse will leave the tooltip anchor
|
|
199
|
-
await user.hover(
|
|
200
|
-
screen.getByRole( 'button', {
|
|
201
|
-
name: 'Button 2',
|
|
202
|
-
} )
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
// Tooltip still hasn't appeared yet
|
|
206
|
-
expect(
|
|
207
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
208
|
-
).not.toBeInTheDocument();
|
|
209
|
-
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
210
|
-
expect( onMouseLeaveMock ).toHaveBeenCalledTimes( 1 );
|
|
211
|
-
|
|
212
|
-
// Advance time again, so that we reach the full TOOLTIP_DELAY time
|
|
213
|
-
await new Promise( ( resolve ) =>
|
|
214
|
-
setTimeout( resolve, TOOLTIP_DELAY )
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
// Tooltip won't show, since the mouse has left the tooltip anchor
|
|
218
|
-
expect(
|
|
219
|
-
screen.queryByRole( 'tooltip', { name: /tooltip text/i } )
|
|
220
|
-
).not.toBeInTheDocument();
|
|
221
|
-
|
|
222
|
-
await cleanupTooltip( user );
|
|
223
|
-
} );
|
|
224
|
-
|
|
225
|
-
it( 'should render the shortcut display text when a string is passed as the shortcut', async () => {
|
|
226
|
-
const user = userEvent.setup();
|
|
320
|
+
);
|
|
227
321
|
|
|
228
|
-
|
|
322
|
+
const anchor = screen.getByRole( 'button', {
|
|
323
|
+
name: 'Tooltip anchor',
|
|
324
|
+
} );
|
|
325
|
+
expect( anchor ).toBeVisible();
|
|
229
326
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
await cleanupTooltip( user );
|
|
237
|
-
} );
|
|
327
|
+
// Hover over the anchor, tooltip hasn't appeared yet
|
|
328
|
+
await hover( anchor );
|
|
329
|
+
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
330
|
+
expectTooltipToBeHidden();
|
|
238
331
|
|
|
239
|
-
|
|
240
|
-
|
|
332
|
+
// Advance time, tooltip hasn't appeared yet because TOOLTIP_DELAY time
|
|
333
|
+
// hasn't passed yet
|
|
334
|
+
await sleep( TOOLTIP_DELAY - HOVER_OUTSIDE_ANTICIPATION );
|
|
335
|
+
expectTooltipToBeHidden();
|
|
241
336
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
shortcut={ {
|
|
246
|
-
display: '⇧⌘,',
|
|
247
|
-
ariaLabel: shortcutAriaLabel.primaryShift( ',' ),
|
|
248
|
-
} }
|
|
249
|
-
/>
|
|
250
|
-
);
|
|
337
|
+
// Hover outside of the anchor, tooltip still hasn't appeared yet
|
|
338
|
+
await hoverOutside();
|
|
339
|
+
expectTooltipToBeHidden();
|
|
251
340
|
|
|
252
|
-
|
|
341
|
+
expect( onMouseEnterMock ).toHaveBeenCalledTimes( 1 );
|
|
342
|
+
expect( onMouseLeaveMock ).toHaveBeenCalledTimes( 1 );
|
|
253
343
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
);
|
|
344
|
+
// Advance time again, so that we reach the full TOOLTIP_DELAY time
|
|
345
|
+
await sleep( HOVER_OUTSIDE_ANTICIPATION );
|
|
257
346
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
await cleanupTooltip( user );
|
|
347
|
+
// Tooltip won't show, since the mouse has left the tooltip anchor
|
|
348
|
+
expectTooltipToBeHidden();
|
|
349
|
+
} );
|
|
264
350
|
} );
|
|
265
351
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
352
|
+
describe( 'shortcut', () => {
|
|
353
|
+
it( 'should show the shortcut in the tooltip when a string is passed as the shortcut', async () => {
|
|
354
|
+
render( <Tooltip { ...props } shortcut="shortcut text" /> );
|
|
355
|
+
|
|
356
|
+
// Hover over the anchor, tooltip should show
|
|
357
|
+
await hover(
|
|
358
|
+
screen.getByRole( 'button', { name: 'Tooltip anchor' } )
|
|
359
|
+
);
|
|
360
|
+
await waitFor( () =>
|
|
361
|
+
expect(
|
|
362
|
+
screen.getByRole( 'tooltip', {
|
|
363
|
+
name: 'tooltip text shortcut text',
|
|
364
|
+
} )
|
|
365
|
+
).toBeVisible()
|
|
366
|
+
);
|
|
367
|
+
|
|
368
|
+
// Hover outside of the anchor, tooltip should hide
|
|
369
|
+
await hoverOutside();
|
|
370
|
+
await waitExpectTooltipToHide();
|
|
371
|
+
} );
|
|
372
|
+
|
|
373
|
+
it( 'should show the shortcut in the tooltip when an object is passed as the shortcut', async () => {
|
|
374
|
+
render(
|
|
375
|
+
<Tooltip
|
|
376
|
+
{ ...props }
|
|
377
|
+
shortcut={ {
|
|
378
|
+
display: '⇧⌘,',
|
|
379
|
+
ariaLabel: shortcutAriaLabel.primaryShift( ',' ),
|
|
380
|
+
} }
|
|
381
|
+
/>
|
|
382
|
+
);
|
|
383
|
+
|
|
384
|
+
// Hover over the anchor, tooltip should show
|
|
385
|
+
await hover(
|
|
386
|
+
screen.getByRole( 'button', { name: 'Tooltip anchor' } )
|
|
387
|
+
);
|
|
388
|
+
await waitFor( () =>
|
|
389
|
+
expect(
|
|
390
|
+
screen.getByRole( 'tooltip', {
|
|
391
|
+
name: 'tooltip text Control + Shift + Comma',
|
|
392
|
+
} )
|
|
393
|
+
).toBeVisible()
|
|
394
|
+
);
|
|
286
395
|
expect(
|
|
287
|
-
screen.getByRole( 'tooltip', {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
} );
|
|
297
|
-
|
|
298
|
-
it( 'should associate the tooltip text with its anchor via the accessible description when visible', async () => {
|
|
299
|
-
const user = userEvent.setup();
|
|
300
|
-
|
|
301
|
-
render( <Tooltip { ...props } /> );
|
|
302
|
-
|
|
303
|
-
await user.hover(
|
|
304
|
-
screen.getByRole( 'button', {
|
|
305
|
-
name: /Button/i,
|
|
306
|
-
} )
|
|
307
|
-
);
|
|
308
|
-
|
|
309
|
-
expect(
|
|
310
|
-
await screen.findByRole( 'button', { description: 'tooltip text' } )
|
|
311
|
-
).toBeInTheDocument();
|
|
396
|
+
screen.getByRole( 'tooltip', {
|
|
397
|
+
name: 'tooltip text Control + Shift + Comma',
|
|
398
|
+
} )
|
|
399
|
+
).toHaveTextContent( /⇧⌘,/i );
|
|
400
|
+
|
|
401
|
+
// Hover outside of the anchor, tooltip should hide
|
|
402
|
+
await hoverOutside();
|
|
403
|
+
await waitExpectTooltipToHide();
|
|
404
|
+
} );
|
|
312
405
|
} );
|
|
313
406
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
407
|
+
describe( 'event propagation', () => {
|
|
408
|
+
it( 'should close the parent dialog component when pressing the Escape key while the tooltip is visible', async () => {
|
|
409
|
+
const onRequestClose = jest.fn();
|
|
410
|
+
render(
|
|
411
|
+
<Modal onRequestClose={ onRequestClose }>
|
|
412
|
+
<p>Modal content</p>
|
|
413
|
+
</Modal>
|
|
414
|
+
);
|
|
415
|
+
|
|
416
|
+
expectTooltipToBeHidden();
|
|
417
|
+
|
|
418
|
+
const closeButton = screen.getByRole( 'button', {
|
|
419
|
+
name: /close/i,
|
|
420
|
+
} );
|
|
421
|
+
|
|
422
|
+
// Hover over the anchor, tooltip should show
|
|
423
|
+
await hover( closeButton );
|
|
424
|
+
await waitFor( () =>
|
|
425
|
+
expect(
|
|
426
|
+
screen.getByRole( 'tooltip', { name: /close/i } )
|
|
427
|
+
).toBeVisible()
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
// Press the Escape key, Modal should request to be closed
|
|
431
|
+
await press.Escape();
|
|
432
|
+
expect( onRequestClose ).toHaveBeenCalled();
|
|
433
|
+
|
|
434
|
+
// Hover outside of the anchor, tooltip should hide
|
|
435
|
+
await hoverOutside();
|
|
436
|
+
await waitExpectTooltipToHide();
|
|
437
|
+
} );
|
|
334
438
|
} );
|
|
335
439
|
} );
|