@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
|
@@ -115,6 +115,9 @@ function SearchControl( {
|
|
|
115
115
|
mergeFutureStyles( activeDarkStyles, [ isActive, isDark ] );
|
|
116
116
|
|
|
117
117
|
setCurrentStyles( futureStyles );
|
|
118
|
+
// Disable reason: deferring this refactor to the native team.
|
|
119
|
+
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
118
121
|
}, [ isActive, isDark ] );
|
|
119
122
|
|
|
120
123
|
useEffect( () => {
|
|
@@ -130,6 +133,9 @@ function SearchControl( {
|
|
|
130
133
|
clearTimeout( onCancelTimer.current );
|
|
131
134
|
keyboardHideSubscription.remove();
|
|
132
135
|
};
|
|
136
|
+
// Disable reason: deferring this refactor to the native team.
|
|
137
|
+
// see https://github.com/WordPress/gutenberg/pull/41166
|
|
138
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
133
139
|
}, [] );
|
|
134
140
|
|
|
135
141
|
const {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { proxyMap } from 'valtio/utils';
|
|
2
6
|
/**
|
|
3
7
|
* WordPress dependencies
|
|
4
8
|
*/
|
|
@@ -6,8 +10,8 @@ import { createContext } from '@wordpress/element';
|
|
|
6
10
|
import warning from '@wordpress/warning';
|
|
7
11
|
|
|
8
12
|
const SlotFillContext = createContext( {
|
|
9
|
-
slots:
|
|
10
|
-
fills:
|
|
13
|
+
slots: proxyMap(),
|
|
14
|
+
fills: proxyMap(),
|
|
11
15
|
registerSlot: () => {
|
|
12
16
|
warning(
|
|
13
17
|
'Components must be wrapped within `SlotFillProvider`. ' +
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { ref as valRef } from 'valtio';
|
|
6
|
+
import { proxyMap } from 'valtio/utils';
|
|
7
|
+
|
|
2
8
|
/**
|
|
3
9
|
* WordPress dependencies
|
|
4
10
|
*/
|
|
5
|
-
import { useMemo, useCallback,
|
|
11
|
+
import { useMemo, useCallback, useRef } from '@wordpress/element';
|
|
6
12
|
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
7
13
|
|
|
8
14
|
/**
|
|
@@ -11,79 +17,68 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
|
11
17
|
import SlotFillContext from './slot-fill-context';
|
|
12
18
|
|
|
13
19
|
function useSlotRegistry() {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
20
|
+
const slots = useRef( proxyMap() );
|
|
21
|
+
const fills = useRef( proxyMap() );
|
|
16
22
|
|
|
17
23
|
const registerSlot = useCallback( ( name, ref, fillProps ) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
} );
|
|
24
|
+
const slot = slots.current.get( name ) || {};
|
|
25
|
+
slots.current.set(
|
|
26
|
+
name,
|
|
27
|
+
valRef( {
|
|
28
|
+
...slot,
|
|
29
|
+
ref: ref || slot.ref,
|
|
30
|
+
fillProps: fillProps || slot.fillProps || {},
|
|
31
|
+
} )
|
|
32
|
+
);
|
|
29
33
|
}, [] );
|
|
30
34
|
|
|
31
35
|
const unregisterSlot = useCallback( ( name, ref ) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return nextSlots;
|
|
38
|
-
}
|
|
39
|
-
return prevSlots;
|
|
40
|
-
} );
|
|
36
|
+
// Make sure we're not unregistering a slot registered by another element
|
|
37
|
+
// See https://github.com/WordPress/gutenberg/pull/19242#issuecomment-590295412
|
|
38
|
+
if ( slots.current.get( name )?.ref === ref ) {
|
|
39
|
+
slots.current.delete( name );
|
|
40
|
+
}
|
|
41
41
|
}, [] );
|
|
42
42
|
|
|
43
|
-
const updateSlot = useCallback(
|
|
44
|
-
( name
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
43
|
+
const updateSlot = useCallback( ( name, fillProps ) => {
|
|
44
|
+
const slot = slots.current.get( name );
|
|
45
|
+
if ( ! slot ) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if ( ! isShallowEqual( slot.fillProps, fillProps ) ) {
|
|
50
|
+
slot.fillProps = fillProps;
|
|
51
|
+
const slotFills = fills.current.get( name );
|
|
52
|
+
if ( slotFills ) {
|
|
53
|
+
// Force update fills.
|
|
54
|
+
slotFills.map( ( fill ) => fill.current.rerender() );
|
|
56
55
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
);
|
|
56
|
+
}
|
|
57
|
+
}, [] );
|
|
60
58
|
|
|
61
59
|
const registerFill = useCallback( ( name, ref ) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
fills.current.set(
|
|
61
|
+
name,
|
|
62
|
+
valRef( [ ...( fills.current.get( name ) || [] ), ref ] )
|
|
63
|
+
);
|
|
66
64
|
}, [] );
|
|
67
65
|
|
|
68
66
|
const unregisterFill = useCallback( ( name, ref ) => {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
return prevFills;
|
|
79
|
-
} );
|
|
67
|
+
if ( fills.current.get( name ) ) {
|
|
68
|
+
fills.current.set(
|
|
69
|
+
name,
|
|
70
|
+
fills.current
|
|
71
|
+
.get( name )
|
|
72
|
+
.filter( ( fillRef ) => fillRef !== ref )
|
|
73
|
+
);
|
|
74
|
+
}
|
|
80
75
|
}, [] );
|
|
81
76
|
|
|
82
77
|
// Memoizing the return value so it can be directly passed to Provider value
|
|
83
78
|
const registry = useMemo(
|
|
84
79
|
() => ( {
|
|
85
|
-
slots,
|
|
86
|
-
fills,
|
|
80
|
+
slots: slots.current,
|
|
81
|
+
fills: fills.current,
|
|
87
82
|
registerSlot,
|
|
88
83
|
updateSlot,
|
|
89
84
|
unregisterSlot,
|
|
@@ -91,8 +86,6 @@ function useSlotRegistry() {
|
|
|
91
86
|
unregisterFill,
|
|
92
87
|
} ),
|
|
93
88
|
[
|
|
94
|
-
slots,
|
|
95
|
-
fills,
|
|
96
89
|
registerSlot,
|
|
97
90
|
updateSlot,
|
|
98
91
|
unregisterSlot,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSnapshot } from 'valtio';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useContext } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import SlotFillContext from './slot-fill-context';
|
|
16
|
+
|
|
17
|
+
export default function useSlotFills( name ) {
|
|
18
|
+
const registry = useContext( SlotFillContext );
|
|
19
|
+
const fills = useSnapshot( registry.fills, { sync: true } );
|
|
20
|
+
// The important bit here is that this call ensures that the hook
|
|
21
|
+
// only causes a re-render if the "fills" of a given slot name
|
|
22
|
+
// change change, not any fills.
|
|
23
|
+
return fills.get( name );
|
|
24
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* External dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useSnapshot } from 'valtio';
|
|
6
|
+
|
|
2
7
|
/**
|
|
3
8
|
* WordPress dependencies
|
|
4
9
|
*/
|
|
5
|
-
import { useCallback, useContext
|
|
10
|
+
import { useCallback, useContext } from '@wordpress/element';
|
|
6
11
|
|
|
7
12
|
/**
|
|
8
13
|
* Internal dependencies
|
|
@@ -11,10 +16,11 @@ import SlotFillContext from './slot-fill-context';
|
|
|
11
16
|
|
|
12
17
|
export default function useSlot( name ) {
|
|
13
18
|
const registry = useContext( SlotFillContext );
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
const slots = useSnapshot( registry.slots, { sync: true } );
|
|
20
|
+
// The important bit here is that this call ensures
|
|
21
|
+
// the hook only causes a re-render if the slot
|
|
22
|
+
// with the given name change, not any other slot.
|
|
23
|
+
const slot = slots.get( name );
|
|
18
24
|
|
|
19
25
|
const updateSlot = useCallback(
|
|
20
26
|
( fillProps ) => {
|
|
@@ -48,7 +54,6 @@ export default function useSlot( name ) {
|
|
|
48
54
|
...slot,
|
|
49
55
|
updateSlot,
|
|
50
56
|
unregisterSlot,
|
|
51
|
-
fills,
|
|
52
57
|
registerFill,
|
|
53
58
|
unregisterFill,
|
|
54
59
|
};
|
package/src/slot-fill/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import BubblesVirtuallySlot from './bubbles-virtually/slot';
|
|
|
14
14
|
import BubblesVirtuallySlotFillProvider from './bubbles-virtually/slot-fill-provider';
|
|
15
15
|
import SlotFillProvider from './provider';
|
|
16
16
|
import useSlot from './bubbles-virtually/use-slot';
|
|
17
|
+
export { default as useSlotFills } from './bubbles-virtually/use-slot-fills';
|
|
17
18
|
|
|
18
19
|
export function Fill( props ) {
|
|
19
20
|
// We're adding both Fills here so they can register themselves before
|
package/src/style.scss
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
@import "./dropdown/style.scss";
|
|
18
18
|
@import "./dropdown-menu/style.scss";
|
|
19
19
|
@import "./duotone-picker/style.scss";
|
|
20
|
-
@import "./font-size-picker/style.scss";
|
|
21
20
|
@import "./form-toggle/style.scss";
|
|
22
21
|
@import "./form-token-field/style.scss";
|
|
23
22
|
@import "./guide/style.scss";
|
|
@@ -55,13 +55,6 @@ export const buttonView = css`
|
|
|
55
55
|
}
|
|
56
56
|
`;
|
|
57
57
|
|
|
58
|
-
export const buttonActive = css`
|
|
59
|
-
color: ${ COLORS.white };
|
|
60
|
-
&:active {
|
|
61
|
-
background: transparent;
|
|
62
|
-
}
|
|
63
|
-
`;
|
|
64
|
-
|
|
65
58
|
export const ButtonContentView = styled.div`
|
|
66
59
|
font-size: ${ CONFIG.fontSize };
|
|
67
60
|
line-height: 1;
|
|
@@ -82,8 +75,17 @@ export const isIcon = ( {
|
|
|
82
75
|
};
|
|
83
76
|
|
|
84
77
|
return css`
|
|
78
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
85
79
|
width: ${ iconButtonSizes[ size ] };
|
|
86
80
|
padding-left: 0;
|
|
87
81
|
padding-right: 0;
|
|
88
82
|
`;
|
|
89
83
|
};
|
|
84
|
+
|
|
85
|
+
export const buttonActive = css`
|
|
86
|
+
color: ${ COLORS.white };
|
|
87
|
+
|
|
88
|
+
&:active {
|
|
89
|
+
background: transparent;
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
@@ -29,11 +29,13 @@ export const _default = () => {
|
|
|
29
29
|
const [ height, setHeight ] = useState();
|
|
30
30
|
const [ minHeight, setMinHeight ] = useState();
|
|
31
31
|
const [ width, setWidth ] = useState();
|
|
32
|
+
const [ scale, setScale ] = useState();
|
|
32
33
|
|
|
33
34
|
const resetAll = () => {
|
|
34
35
|
setHeight( undefined );
|
|
35
36
|
setWidth( undefined );
|
|
36
37
|
setMinHeight( undefined );
|
|
38
|
+
setScale( undefined );
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
return (
|
|
@@ -79,6 +81,31 @@ export const _default = () => {
|
|
|
79
81
|
onChange={ ( next ) => setMinHeight( next ) }
|
|
80
82
|
/>
|
|
81
83
|
</ToolsPanelItem>
|
|
84
|
+
<ToolsPanelItem
|
|
85
|
+
hasValue={ () => !! scale }
|
|
86
|
+
label="Scale"
|
|
87
|
+
onDeselect={ () => setScale( undefined ) }
|
|
88
|
+
>
|
|
89
|
+
<ToggleGroupControl
|
|
90
|
+
label="Scale"
|
|
91
|
+
value={ scale }
|
|
92
|
+
onChange={ ( next ) => setScale( next ) }
|
|
93
|
+
isBlock
|
|
94
|
+
>
|
|
95
|
+
<ToggleGroupControlOption
|
|
96
|
+
value="cover"
|
|
97
|
+
label="Cover"
|
|
98
|
+
/>
|
|
99
|
+
<ToggleGroupControlOption
|
|
100
|
+
value="contain"
|
|
101
|
+
label="Contain"
|
|
102
|
+
/>
|
|
103
|
+
<ToggleGroupControlOption
|
|
104
|
+
value="fill"
|
|
105
|
+
label="Fill"
|
|
106
|
+
/>
|
|
107
|
+
</ToggleGroupControl>
|
|
108
|
+
</ToolsPanelItem>
|
|
82
109
|
</ToolsPanel>
|
|
83
110
|
</Panel>
|
|
84
111
|
</PanelWrapperView>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
+
import styled from '@emotion/styled';
|
|
4
5
|
import { css } from '@emotion/react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -12,7 +13,7 @@ import {
|
|
|
12
13
|
Wrapper as BaseControlWrapper,
|
|
13
14
|
} from '../base-control/styles/base-control-styles';
|
|
14
15
|
import { LabelWrapper } from '../input-control/styles/input-control-styles';
|
|
15
|
-
import { COLORS, CONFIG } from '../utils';
|
|
16
|
+
import { COLORS, CONFIG, rtl } from '../utils';
|
|
16
17
|
import { space } from '../ui/utils/space';
|
|
17
18
|
|
|
18
19
|
const toolsPanelGrid = {
|
|
@@ -145,3 +146,29 @@ export const ToolsPanelItemPlaceholder = css`
|
|
|
145
146
|
export const DropdownMenu = css`
|
|
146
147
|
min-width: 200px;
|
|
147
148
|
`;
|
|
149
|
+
|
|
150
|
+
export const ResetLabel = styled.span`
|
|
151
|
+
color: var( --wp-admin-theme-color-darker-10 );
|
|
152
|
+
font-size: 11px;
|
|
153
|
+
font-weight: 500;
|
|
154
|
+
line-height: 1.4;
|
|
155
|
+
${ rtl( { marginLeft: space( 3 ) } ) }
|
|
156
|
+
text-transform: uppercase;
|
|
157
|
+
`;
|
|
158
|
+
|
|
159
|
+
export const DefaultControlsItem = css`
|
|
160
|
+
color: ${ COLORS.gray[ 900 ] };
|
|
161
|
+
|
|
162
|
+
&&[aria-disabled='true'] {
|
|
163
|
+
color: ${ COLORS.gray[ 700 ] };
|
|
164
|
+
opacity: 1;
|
|
165
|
+
|
|
166
|
+
&:hover {
|
|
167
|
+
color: ${ COLORS.gray[ 700 ] };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
${ ResetLabel } {
|
|
171
|
+
opacity: 0.3;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`;
|
|
@@ -7,7 +7,7 @@ import type { ForwardedRef } from 'react';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { speak } from '@wordpress/a11y';
|
|
10
|
-
import { check,
|
|
10
|
+
import { check, moreVertical, plus } from '@wordpress/icons';
|
|
11
11
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -20,12 +20,14 @@ import { HStack } from '../../h-stack';
|
|
|
20
20
|
import { Heading } from '../../heading';
|
|
21
21
|
import { useToolsPanelHeader } from './hook';
|
|
22
22
|
import { contextConnect, WordPressComponentProps } from '../../ui/context';
|
|
23
|
+
import { ResetLabel } from '../styles';
|
|
23
24
|
import type {
|
|
24
25
|
ToolsPanelControlsGroupProps,
|
|
25
26
|
ToolsPanelHeaderProps,
|
|
26
27
|
} from '../types';
|
|
27
28
|
|
|
28
29
|
const DefaultControlsGroup = ( {
|
|
30
|
+
itemClassName,
|
|
29
31
|
items,
|
|
30
32
|
toggleItem,
|
|
31
33
|
}: ToolsPanelControlsGroupProps ) => {
|
|
@@ -33,15 +35,17 @@ const DefaultControlsGroup = ( {
|
|
|
33
35
|
return null;
|
|
34
36
|
}
|
|
35
37
|
|
|
38
|
+
const resetSuffix = <ResetLabel aria-hidden>{ __( 'Reset' ) }</ResetLabel>;
|
|
39
|
+
|
|
36
40
|
return (
|
|
37
|
-
<MenuGroup>
|
|
41
|
+
<MenuGroup label={ __( 'Defaults' ) }>
|
|
38
42
|
{ items.map( ( [ label, hasValue ] ) => {
|
|
39
43
|
if ( hasValue ) {
|
|
40
44
|
return (
|
|
41
45
|
<MenuItem
|
|
42
46
|
key={ label }
|
|
47
|
+
className={ itemClassName }
|
|
43
48
|
role="menuitem"
|
|
44
|
-
icon={ reset }
|
|
45
49
|
label={ sprintf(
|
|
46
50
|
// translators: %s: The name of the control being reset e.g. "Padding".
|
|
47
51
|
__( 'Reset %s' ),
|
|
@@ -58,6 +62,7 @@ const DefaultControlsGroup = ( {
|
|
|
58
62
|
'assertive'
|
|
59
63
|
);
|
|
60
64
|
} }
|
|
65
|
+
suffix={ resetSuffix }
|
|
61
66
|
>
|
|
62
67
|
{ label }
|
|
63
68
|
</MenuItem>
|
|
@@ -67,8 +72,8 @@ const DefaultControlsGroup = ( {
|
|
|
67
72
|
return (
|
|
68
73
|
<MenuItem
|
|
69
74
|
key={ label }
|
|
75
|
+
className={ itemClassName }
|
|
70
76
|
role="menuitemcheckbox"
|
|
71
|
-
icon={ check }
|
|
72
77
|
isSelected
|
|
73
78
|
aria-disabled
|
|
74
79
|
>
|
|
@@ -89,7 +94,7 @@ const OptionalControlsGroup = ( {
|
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
return (
|
|
92
|
-
<MenuGroup>
|
|
97
|
+
<MenuGroup label={ __( 'Tools' ) }>
|
|
93
98
|
{ items.map( ( [ label, isSelected ] ) => {
|
|
94
99
|
const itemLabel = isSelected
|
|
95
100
|
? sprintf(
|
|
@@ -147,6 +152,7 @@ const ToolsPanelHeader = (
|
|
|
147
152
|
) => {
|
|
148
153
|
const {
|
|
149
154
|
areAllOptionalControlsHidden,
|
|
155
|
+
defaultControlsItemClassName,
|
|
150
156
|
dropdownMenuClassName,
|
|
151
157
|
hasMenuItems,
|
|
152
158
|
headingClassName,
|
|
@@ -197,6 +203,7 @@ const ToolsPanelHeader = (
|
|
|
197
203
|
<DefaultControlsGroup
|
|
198
204
|
items={ defaultItems }
|
|
199
205
|
toggleItem={ toggleItem }
|
|
206
|
+
itemClassName={ defaultControlsItemClassName }
|
|
200
207
|
/>
|
|
201
208
|
<OptionalControlsGroup
|
|
202
209
|
items={ optionalItems }
|
|
@@ -33,12 +33,17 @@ export function useToolsPanelHeader(
|
|
|
33
33
|
return cx( styles.ToolsPanelHeading );
|
|
34
34
|
}, [ cx ] );
|
|
35
35
|
|
|
36
|
+
const defaultControlsItemClassName = useMemo( () => {
|
|
37
|
+
return cx( styles.DefaultControlsItem );
|
|
38
|
+
}, [ cx ] );
|
|
39
|
+
|
|
36
40
|
const { menuItems, hasMenuItems, areAllOptionalControlsHidden } =
|
|
37
41
|
useToolsPanelContext();
|
|
38
42
|
|
|
39
43
|
return {
|
|
40
44
|
...otherProps,
|
|
41
45
|
areAllOptionalControlsHidden,
|
|
46
|
+
defaultControlsItemClassName,
|
|
42
47
|
dropdownMenuClassName,
|
|
43
48
|
hasMenuItems,
|
|
44
49
|
headingClassName,
|
package/src/tools-panel/types.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -47,10 +47,8 @@
|
|
|
47
47
|
"src/color-list-picker",
|
|
48
48
|
"src/combobox-control",
|
|
49
49
|
"src/custom-gradient-picker",
|
|
50
|
-
"src/custom-select-control",
|
|
51
50
|
"src/dimension-control",
|
|
52
51
|
"src/duotone-picker",
|
|
53
|
-
"src/font-size-picker",
|
|
54
52
|
"src/gradient-picker",
|
|
55
53
|
"src/guide",
|
|
56
54
|
"src/higher-order/navigate-regions",
|