@wordpress/components 21.1.0 → 21.2.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 +31 -0
- package/build/border-box-control/utils.js +42 -2
- package/build/border-box-control/utils.js.map +1 -1
- package/build/combobox-control/index.js +0 -1
- package/build/combobox-control/index.js.map +1 -1
- package/build/custom-select-control/index.js +4 -2
- package/build/custom-select-control/index.js.map +1 -1
- package/build/draggable/index.js +3 -6
- package/build/draggable/index.js.map +1 -1
- package/build/font-size-picker/index.js +46 -55
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/styles.js +73 -0
- package/build/font-size-picker/styles.js.map +1 -0
- package/build/font-size-picker/types.js +6 -0
- package/build/font-size-picker/types.js.map +1 -0
- package/build/font-size-picker/utils.js +17 -15
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/form-token-field/token-input.js +20 -1
- package/build/form-token-field/token-input.js.map +1 -1
- package/build/index.js +12 -0
- package/build/index.js.map +1 -1
- package/build/menu-item/index.js +4 -3
- package/build/menu-item/index.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
- package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +3 -1
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/picker-screen.native.js +3 -1
- package/build/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build/mobile/image/index.native.js +3 -1
- package/build/mobile/image/index.native.js.map +1 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +3 -1
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +24 -6
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build/mobile/segmented-control/index.native.js +6 -2
- package/build/mobile/segmented-control/index.native.js.map +1 -1
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build/navigator/navigator-screen/component.js +8 -1
- package/build/navigator/navigator-screen/component.js.map +1 -1
- package/build/notice/index.native.js +15 -19
- package/build/notice/index.native.js.map +1 -1
- package/build/notice/list.native.js +2 -3
- package/build/notice/list.native.js.map +1 -1
- package/build/palette-edit/index.js +1 -1
- package/build/palette-edit/index.js.map +1 -1
- package/build/popover/index.js +29 -32
- package/build/popover/index.js.map +1 -1
- package/build/popover/limit-shift.js +145 -0
- package/build/popover/limit-shift.js.map +1 -0
- package/build/popover/utils.js +55 -15
- package/build/popover/utils.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js +12 -14
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.js +13 -8
- package/build/sandbox/index.js.map +1 -1
- package/build/sandbox/index.native.js +3 -1
- package/build/sandbox/index.native.js.map +1 -1
- package/build/search-control/index.native.js +6 -2
- package/build/search-control/index.native.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js +8 -2
- package/build/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js +31 -41
- package/build/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js +39 -0
- package/build/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build/slot-fill/bubbles-virtually/use-slot.js +13 -4
- package/build/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build/slot-fill/index.js +8 -0
- package/build/slot-fill/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build/tools-panel/styles.js +27 -12
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel-header/component.js +19 -6
- package/build/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build/tools-panel/tools-panel-header/hook.js +4 -0
- package/build/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-module/border-box-control/utils.js +36 -1
- package/build-module/border-box-control/utils.js.map +1 -1
- package/build-module/combobox-control/index.js +0 -1
- package/build-module/combobox-control/index.js.map +1 -1
- package/build-module/custom-select-control/index.js +2 -1
- package/build-module/custom-select-control/index.js.map +1 -1
- package/build-module/draggable/index.js +2 -5
- package/build-module/draggable/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +45 -53
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/styles.js +62 -0
- package/build-module/font-size-picker/styles.js.map +1 -0
- package/build-module/font-size-picker/types.js +2 -0
- package/build-module/font-size-picker/types.js.map +1 -0
- package/build-module/font-size-picker/utils.js +21 -15
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/form-token-field/token-input.js +21 -2
- package/build-module/form-token-field/token-input.js.map +1 -1
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +1 -1
- package/build-module/menu-item/index.js +4 -3
- package/build-module/menu-item/index.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +10 -3
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +12 -3
- package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js +4 -1
- package/build-module/mobile/bottom-sheet/sub-sheet/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +3 -1
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/picker-screen.native.js +3 -1
- package/build-module/mobile/color-settings/picker-screen.native.js.map +1 -1
- package/build-module/mobile/image/index.native.js +3 -1
- package/build-module/mobile/image/index.native.js.map +1 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js +3 -1
- package/build-module/mobile/keyboard-avoiding-view/index.ios.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +3 -1
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js +3 -1
- package/build-module/mobile/link-picker/link-picker-screen.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +24 -6
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js +3 -1
- package/build-module/mobile/link-settings/link-settings-screen.native.js.map +1 -1
- package/build-module/mobile/segmented-control/index.native.js +6 -2
- package/build-module/mobile/segmented-control/index.native.js.map +1 -1
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js +6 -2
- package/build-module/mobile/utils/use-unit-converter-to-mobile.native.js.map +1 -1
- package/build-module/navigator/navigator-screen/component.js +8 -1
- package/build-module/navigator/navigator-screen/component.js.map +1 -1
- package/build-module/notice/index.native.js +16 -21
- package/build-module/notice/index.native.js.map +1 -1
- package/build-module/notice/list.native.js +3 -3
- package/build-module/notice/list.native.js.map +1 -1
- package/build-module/palette-edit/index.js +1 -1
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/popover/index.js +31 -35
- package/build-module/popover/index.js.map +1 -1
- package/build-module/popover/limit-shift.js +136 -0
- package/build-module/popover/limit-shift.js.map +1 -0
- package/build-module/popover/utils.js +55 -15
- package/build-module/popover/utils.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js +13 -15
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.js +13 -8
- package/build-module/sandbox/index.js.map +1 -1
- package/build-module/sandbox/index.native.js +3 -1
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/search-control/index.native.js +6 -2
- package/build-module/search-control/index.native.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js +7 -2
- package/build-module/slot-fill/bubbles-virtually/slot-fill-context.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js +30 -42
- package/build-module/slot-fill/bubbles-virtually/slot-fill-provider.js.map +1 -1
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js +27 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot-fills.js.map +1 -0
- package/build-module/slot-fill/bubbles-virtually/use-slot.js +13 -5
- package/build-module/slot-fill/bubbles-virtually/use-slot.js.map +1 -1
- package/build-module/slot-fill/index.js +1 -0
- package/build-module/slot-fill/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js +7 -7
- package/build-module/toggle-group-control/toggle-group-control-option-base/styles.js.map +1 -1
- package/build-module/tools-panel/styles.js +23 -12
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/component.js +19 -7
- package/build-module/tools-panel/tools-panel-header/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel-header/hook.js +4 -0
- package/build-module/tools-panel/tools-panel-header/hook.js.map +1 -1
- package/build-style/style-rtl.css +14 -100
- package/build-style/style.css +14 -100
- package/build-types/border-box-control/utils.d.ts +1 -3
- package/build-types/border-box-control/utils.d.ts.map +1 -1
- package/build-types/custom-select-control/index.d.ts +13 -0
- package/build-types/custom-select-control/index.d.ts.map +1 -0
- package/build-types/custom-select-control/styles.d.ts +9 -0
- package/build-types/custom-select-control/styles.d.ts.map +1 -0
- package/build-types/draggable/index.d.ts.map +1 -1
- package/build-types/external-link/styles/external-link-styles.d.ts +1 -1
- package/build-types/focal-point-picker/styles/focal-point-style.d.ts +3 -3
- package/build-types/font-size-picker/index.d.ts +5 -0
- package/build-types/font-size-picker/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts +16 -0
- package/build-types/font-size-picker/stories/e2e/index.d.ts.map +1 -0
- package/build-types/font-size-picker/stories/index.d.ts +31 -0
- package/build-types/font-size-picker/stories/index.d.ts.map +1 -0
- package/build-types/font-size-picker/styles.d.ts +27 -0
- package/build-types/font-size-picker/styles.d.ts.map +1 -0
- package/build-types/font-size-picker/test/index.d.ts +2 -0
- package/build-types/font-size-picker/test/index.d.ts.map +1 -0
- package/build-types/font-size-picker/test/utils.d.ts +2 -0
- package/build-types/font-size-picker/test/utils.d.ts.map +1 -0
- package/build-types/font-size-picker/types.d.ts +93 -0
- package/build-types/font-size-picker/types.d.ts.map +1 -0
- package/build-types/font-size-picker/utils.d.ts +41 -0
- package/build-types/font-size-picker/utils.d.ts.map +1 -0
- package/build-types/form-token-field/token-input.d.ts.map +1 -1
- package/build-types/menu-item/index.d.ts.map +1 -1
- package/build-types/navigator/navigator-screen/component.d.ts.map +1 -1
- package/build-types/popover/index.d.ts.map +1 -1
- package/build-types/popover/limit-shift.d.ts +87 -0
- package/build-types/popover/limit-shift.d.ts.map +1 -0
- package/build-types/popover/test/index.d.ts +2 -0
- package/build-types/popover/test/index.d.ts.map +1 -0
- package/build-types/popover/types.d.ts +1 -1
- package/build-types/popover/types.d.ts.map +1 -1
- package/build-types/popover/utils.d.ts.map +1 -1
- package/build-types/range-control/types.d.ts +0 -32
- package/build-types/range-control/types.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts +2 -2
- package/build-types/slot-fill/bubbles-virtually/slot-fill-context.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/slot-fill-provider.d.ts.map +1 -1
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts +2 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot-fills.d.ts.map +1 -0
- package/build-types/slot-fill/bubbles-virtually/use-slot.d.ts.map +1 -1
- package/build-types/slot-fill/index.d.ts +1 -0
- package/build-types/slot-fill/index.d.ts.map +1 -1
- package/build-types/spinner/index.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option-base/styles.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts +6 -0
- package/build-types/tools-panel/styles.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 +1 -0
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/package.json +19 -18
- package/src/alignment-matrix-control/test/index.js +17 -62
- package/src/border-box-control/test/utils.js +48 -0
- package/src/border-box-control/utils.ts +44 -1
- package/src/combobox-control/index.js +0 -5
- package/src/custom-select-control/index.js +2 -1
- package/src/draggable/index.js +2 -5
- package/src/font-size-picker/{index.js → index.tsx} +113 -79
- package/src/font-size-picker/stories/e2e/{index.js → index.tsx} +13 -4
- package/src/font-size-picker/stories/{index.js → index.tsx} +42 -36
- package/src/font-size-picker/styles.ts +44 -0
- package/src/font-size-picker/test/{index.js → index.tsx} +1 -1
- package/src/font-size-picker/test/{utils.js → utils.ts} +6 -2
- package/src/font-size-picker/types.ts +98 -0
- package/src/font-size-picker/{utils.js → utils.ts} +51 -27
- package/src/form-token-field/test/index.tsx +22 -1
- package/src/form-token-field/token-input.tsx +25 -3
- package/src/index.js +2 -1
- package/src/menu-item/README.md +7 -0
- package/src/menu-item/index.js +11 -5
- package/src/menu-item/style.scss +1 -0
- package/src/menu-item/test/index.js +36 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-container.native.js +9 -0
- package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +11 -0
- package/src/mobile/bottom-sheet/sub-sheet/index.native.js +3 -0
- package/src/mobile/color-settings/index.native.js +3 -0
- package/src/mobile/color-settings/picker-screen.native.js +3 -0
- package/src/mobile/image/index.native.js +3 -0
- package/src/mobile/keyboard-avoiding-view/index.ios.js +3 -0
- package/src/mobile/link-picker/index.native.js +3 -0
- package/src/mobile/link-picker/link-picker-results.native.js +3 -0
- package/src/mobile/link-picker/link-picker-screen.native.js +3 -0
- package/src/mobile/link-settings/index.native.js +18 -0
- package/src/mobile/link-settings/link-settings-screen.native.js +3 -0
- package/src/mobile/segmented-control/index.native.js +6 -0
- package/src/mobile/utils/use-unit-converter-to-mobile.native.js +6 -0
- package/src/navigator/navigator-screen/component.tsx +8 -1
- package/src/navigator/test/index.js +119 -54
- package/src/notice/index.native.js +17 -20
- package/src/notice/list.native.js +7 -3
- package/src/palette-edit/index.js +1 -1
- package/src/placeholder/style.scss +3 -3
- package/src/popover/index.tsx +26 -42
- package/src/popover/limit-shift.ts +205 -0
- package/src/popover/test/index.tsx +230 -0
- package/src/popover/types.ts +1 -0
- package/src/popover/utils.ts +58 -16
- package/src/range-control/types.ts +0 -33
- package/src/resizable-box/resize-tooltip/utils.ts +13 -13
- package/src/sandbox/index.js +13 -7
- package/src/sandbox/index.native.js +3 -0
- package/src/search-control/index.native.js +6 -0
- package/src/slot-fill/bubbles-virtually/slot-fill-context.js +6 -2
- package/src/slot-fill/bubbles-virtually/slot-fill-provider.js +51 -58
- package/src/slot-fill/bubbles-virtually/use-slot-fills.js +24 -0
- package/src/slot-fill/bubbles-virtually/use-slot.js +11 -6
- package/src/slot-fill/index.js +1 -0
- package/src/style.scss +0 -1
- package/src/toggle-group-control/test/__snapshots__/index.tsx.snap +1 -0
- package/src/toggle-group-control/toggle-group-control-option-base/styles.ts +9 -7
- package/src/tools-panel/stories/index.js +27 -0
- package/src/tools-panel/styles.ts +28 -1
- package/src/tools-panel/tools-panel-header/component.tsx +12 -5
- package/src/tools-panel/tools-panel-header/hook.ts +5 -0
- package/src/tools-panel/types.ts +1 -0
- package/tsconfig.json +0 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/src/font-size-picker/style.scss +0 -78
- package/src/popover/test/__snapshots__/index.js.snap +0 -34
- package/src/popover/test/index.js +0 -164
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
.components-font-size-picker__header {
|
|
2
|
-
&__hint {
|
|
3
|
-
margin-left: $grid-unit-05;
|
|
4
|
-
color: $gray-700;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.components-base-control__label {
|
|
8
|
-
margin-bottom: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// This button is inheriting padding and min-width.
|
|
12
|
-
// @todo: we should refactor it to not need to unset this.
|
|
13
|
-
.components-button.is-small.has-icon:not(.has-text) {
|
|
14
|
-
min-width: $icon-size;
|
|
15
|
-
padding: 0;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.components-font-size-picker__controls {
|
|
20
|
-
max-width: $sidebar-width - ( 2 * $grid-unit-20 );
|
|
21
|
-
align-items: center;
|
|
22
|
-
margin-top: $grid-unit-10;
|
|
23
|
-
|
|
24
|
-
&:not(.is-next-has-no-margin-bottom) {
|
|
25
|
-
margin-bottom: $grid-unit-30;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.components-unit-control-wrapper {
|
|
29
|
-
.components-input-control__label {
|
|
30
|
-
font-weight: 300;
|
|
31
|
-
padding-bottom: 0 !important;
|
|
32
|
-
margin-bottom: $grid-unit-10 !important;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Apply the same height as the isSmall Reset button.
|
|
37
|
-
.components-font-size-picker__number {
|
|
38
|
-
@include input-control;
|
|
39
|
-
display: inline-block;
|
|
40
|
-
font-weight: 500;
|
|
41
|
-
height: 30px;
|
|
42
|
-
margin-bottom: 0;
|
|
43
|
-
margin-left: 0;
|
|
44
|
-
margin-right: $grid-unit-10;
|
|
45
|
-
margin-top: $grid-unit-10;
|
|
46
|
-
width: 54px;
|
|
47
|
-
|
|
48
|
-
// Show the reset button as disabled until a value is entered.
|
|
49
|
-
&[value=""] + .components-button {
|
|
50
|
-
cursor: default;
|
|
51
|
-
opacity: 0.3;
|
|
52
|
-
pointer-events: none;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
&-container {
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: column;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.components-color-palette__clear {
|
|
62
|
-
height: 30px;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.components-font-size-picker__custom-input {
|
|
67
|
-
.components-range-control__slider + .dashicon {
|
|
68
|
-
width: 30px;
|
|
69
|
-
height: 30px;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.components-font-size-picker {
|
|
74
|
-
border: 0;
|
|
75
|
-
padding: 0;
|
|
76
|
-
margin: 0;
|
|
77
|
-
}
|
|
78
|
-
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`Popover Component should pass additional props to portaled element 1`] = `
|
|
4
|
-
<span>
|
|
5
|
-
<div
|
|
6
|
-
class="components-popover"
|
|
7
|
-
role="tooltip"
|
|
8
|
-
style="position: absolute; opacity: 0; transform: translateY(-2em) scale(0) translateZ(0); transform-origin: 0% 0% 0;"
|
|
9
|
-
tabindex="-1"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
class="components-popover__content"
|
|
13
|
-
>
|
|
14
|
-
Hello
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
</span>
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
exports[`Popover Component should render content 1`] = `
|
|
21
|
-
<span>
|
|
22
|
-
<div
|
|
23
|
-
class="components-popover"
|
|
24
|
-
style="position: absolute; opacity: 0; transform: translateY(-2em) scale(0) translateZ(0); transform-origin: 0% 0% 0;"
|
|
25
|
-
tabindex="-1"
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
class="components-popover__content"
|
|
29
|
-
>
|
|
30
|
-
Hello
|
|
31
|
-
</div>
|
|
32
|
-
</div>
|
|
33
|
-
</span>
|
|
34
|
-
`;
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { act, render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { useState } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import Popover from '../';
|
|
15
|
-
|
|
16
|
-
import { positionToPlacement, placementToMotionAnimationProps } from '../utils';
|
|
17
|
-
|
|
18
|
-
describe( 'Popover', () => {
|
|
19
|
-
describe( 'Component', () => {
|
|
20
|
-
afterEach( () => {
|
|
21
|
-
if ( document.activeElement ) {
|
|
22
|
-
document.activeElement.blur();
|
|
23
|
-
}
|
|
24
|
-
} );
|
|
25
|
-
|
|
26
|
-
it( 'should allow focus-on-open behavior to be disabled', () => {
|
|
27
|
-
expect( document.activeElement ).toBe( document.body );
|
|
28
|
-
|
|
29
|
-
act( () => {
|
|
30
|
-
render( <Popover focusOnMount={ false } /> );
|
|
31
|
-
|
|
32
|
-
jest.advanceTimersByTime( 1 );
|
|
33
|
-
} );
|
|
34
|
-
|
|
35
|
-
expect( document.activeElement ).toBe( document.body );
|
|
36
|
-
} );
|
|
37
|
-
|
|
38
|
-
it( 'should render content', () => {
|
|
39
|
-
let result;
|
|
40
|
-
act( () => {
|
|
41
|
-
result = render( <Popover>Hello</Popover> );
|
|
42
|
-
} );
|
|
43
|
-
|
|
44
|
-
expect(
|
|
45
|
-
result.container.querySelector( 'span' )
|
|
46
|
-
).toMatchSnapshot();
|
|
47
|
-
} );
|
|
48
|
-
|
|
49
|
-
it( 'should pass additional props to portaled element', () => {
|
|
50
|
-
let result;
|
|
51
|
-
act( () => {
|
|
52
|
-
result = render( <Popover role="tooltip">Hello</Popover> );
|
|
53
|
-
} );
|
|
54
|
-
|
|
55
|
-
expect(
|
|
56
|
-
result.container.querySelector( 'span' )
|
|
57
|
-
).toMatchSnapshot();
|
|
58
|
-
} );
|
|
59
|
-
|
|
60
|
-
it( 'should render correctly when anchor is provided', () => {
|
|
61
|
-
const PopoverWithAnchor = ( args ) => {
|
|
62
|
-
// Use internal state instead of a ref to make sure that the component
|
|
63
|
-
// re-renders when the popover's anchor updates.
|
|
64
|
-
const [ anchor, setAnchor ] = useState( null );
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div>
|
|
68
|
-
<p ref={ setAnchor }>Anchor</p>
|
|
69
|
-
<Popover { ...args } anchor={ anchor } />
|
|
70
|
-
</div>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
render( <PopoverWithAnchor>Popover content</PopoverWithAnchor> );
|
|
75
|
-
|
|
76
|
-
expect( screen.getByText( 'Popover content' ) ).toBeInTheDocument();
|
|
77
|
-
} );
|
|
78
|
-
} );
|
|
79
|
-
|
|
80
|
-
describe( 'positionToPlacement', () => {
|
|
81
|
-
it.each( [
|
|
82
|
-
[ 'top left', 'top-end' ],
|
|
83
|
-
[ 'top center', 'top' ],
|
|
84
|
-
[ 'top right', 'top-start' ],
|
|
85
|
-
[ 'middle left', 'left' ],
|
|
86
|
-
[ 'middle center', 'center' ],
|
|
87
|
-
[ 'middle right', 'right' ],
|
|
88
|
-
[ 'bottom left', 'bottom-end' ],
|
|
89
|
-
[ 'bottom center', 'bottom' ],
|
|
90
|
-
[ 'bottom right', 'bottom-start' ],
|
|
91
|
-
] )( 'converts `%s` to `%s`', ( inputPosition, expectedPlacement ) => {
|
|
92
|
-
expect( positionToPlacement( inputPosition ) ).toEqual(
|
|
93
|
-
expectedPlacement
|
|
94
|
-
);
|
|
95
|
-
} );
|
|
96
|
-
} );
|
|
97
|
-
|
|
98
|
-
describe( 'placementToMotionAnimationProps', () => {
|
|
99
|
-
describe( 'animation origin', () => {
|
|
100
|
-
it.each( [
|
|
101
|
-
[ 'top', 0.5, 1 ],
|
|
102
|
-
[ 'top-start', 0, 1 ],
|
|
103
|
-
[ 'top-end', 1, 1 ],
|
|
104
|
-
[ 'right', 0, 0.5 ],
|
|
105
|
-
[ 'right-start', 0, 0 ],
|
|
106
|
-
[ 'right-end', 0, 1 ],
|
|
107
|
-
[ 'bottom', 0.5, 0 ],
|
|
108
|
-
[ 'bottom-start', 0, 0 ],
|
|
109
|
-
[ 'bottom-end', 1, 0 ],
|
|
110
|
-
[ 'left', 1, 0.5 ],
|
|
111
|
-
[ 'left-start', 1, 0 ],
|
|
112
|
-
[ 'left-end', 1, 1 ],
|
|
113
|
-
] )(
|
|
114
|
-
'for the `%s` placement computes an animation origin of (%d, %d)',
|
|
115
|
-
( inputPlacement, expectedOriginX, expectedOriginY ) => {
|
|
116
|
-
expect(
|
|
117
|
-
placementToMotionAnimationProps( inputPlacement )
|
|
118
|
-
).toEqual(
|
|
119
|
-
expect.objectContaining( {
|
|
120
|
-
style: expect.objectContaining( {
|
|
121
|
-
originX: expectedOriginX,
|
|
122
|
-
originY: expectedOriginY,
|
|
123
|
-
} ),
|
|
124
|
-
} )
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
);
|
|
128
|
-
} );
|
|
129
|
-
describe( 'initial translation', () => {
|
|
130
|
-
it.each( [
|
|
131
|
-
[ 'top', 'translateY', '2em' ],
|
|
132
|
-
[ 'top-start', 'translateY', '2em' ],
|
|
133
|
-
[ 'top-end', 'translateY', '2em' ],
|
|
134
|
-
[ 'right', 'translateX', '-2em' ],
|
|
135
|
-
[ 'right-start', 'translateX', '-2em' ],
|
|
136
|
-
[ 'right-end', 'translateX', '-2em' ],
|
|
137
|
-
[ 'bottom', 'translateY', '-2em' ],
|
|
138
|
-
[ 'bottom-start', 'translateY', '-2em' ],
|
|
139
|
-
[ 'bottom-end', 'translateY', '-2em' ],
|
|
140
|
-
[ 'left', 'translateX', '2em' ],
|
|
141
|
-
[ 'left-start', 'translateX', '2em' ],
|
|
142
|
-
[ 'left-end', 'translateX', '2em' ],
|
|
143
|
-
] )(
|
|
144
|
-
'for the `%s` placement computes an initial `%s` of `%s',
|
|
145
|
-
(
|
|
146
|
-
inputPlacement,
|
|
147
|
-
expectedTranslationProp,
|
|
148
|
-
expectedTranslationValue
|
|
149
|
-
) => {
|
|
150
|
-
expect(
|
|
151
|
-
placementToMotionAnimationProps( inputPlacement )
|
|
152
|
-
).toEqual(
|
|
153
|
-
expect.objectContaining( {
|
|
154
|
-
initial: expect.objectContaining( {
|
|
155
|
-
[ expectedTranslationProp ]:
|
|
156
|
-
expectedTranslationValue,
|
|
157
|
-
} ),
|
|
158
|
-
} )
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
} );
|
|
163
|
-
} );
|
|
164
|
-
} );
|