@wordpress/components 23.6.0 → 23.7.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 +32 -4
- package/build/angle-picker-control/angle-circle.js +1 -4
- package/build/angle-picker-control/angle-circle.js.map +1 -1
- package/build/angle-picker-control/index.js +10 -22
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/angle-picker-control/styles/angle-picker-control-styles.js +24 -15
- package/build/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build/animate/index.js +27 -19
- package/build/animate/index.js.map +1 -1
- package/build/animate/types.js.map +1 -0
- package/build/box-control/axial-input-controls.js.map +1 -1
- package/build/color-picker/color-input.js +0 -4
- package/build/color-picker/color-input.js.map +1 -1
- package/build/color-picker/component.js +5 -4
- package/build/color-picker/component.js.map +1 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/hsl-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/color-picker/legacy-adapter.js.map +1 -1
- package/build/color-picker/picker.js.map +1 -1
- package/build/color-picker/rgb-input.js.map +1 -1
- package/build/color-picker/use-deprecated-props.js.map +1 -1
- package/build/custom-gradient-picker/constants.js +1 -1
- package/build/custom-gradient-picker/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/control-points.js +9 -5
- package/build/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/index.js +14 -9
- package/build/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build/custom-gradient-picker/index.js +45 -16
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/custom-gradient-picker/serializer.js +14 -4
- package/build/custom-gradient-picker/serializer.js.map +1 -1
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build/custom-gradient-picker/types.js +6 -0
- package/build/custom-gradient-picker/types.js.map +1 -0
- package/build/custom-gradient-picker/utils.js +17 -12
- package/build/custom-gradient-picker/utils.js.map +1 -1
- package/build/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build/duotone-picker/color-list-picker/types.js +6 -0
- package/build/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build/duotone-picker/duotone-picker.js +39 -2
- package/build/duotone-picker/duotone-picker.js.map +1 -1
- package/build/duotone-picker/duotone-swatch.js.map +1 -1
- package/build/duotone-picker/index.js.map +1 -1
- package/build/duotone-picker/types.js +6 -0
- package/build/duotone-picker/types.js.map +1 -0
- package/build/duotone-picker/utils.js +13 -11
- package/build/duotone-picker/utils.js.map +1 -1
- package/build/form-token-field/index.js +9 -3
- package/build/form-token-field/index.js.map +1 -1
- package/build/gradient-picker/index.js +61 -9
- package/build/gradient-picker/index.js.map +1 -1
- package/build/gradient-picker/types.js +6 -0
- package/build/gradient-picker/types.js.map +1 -0
- package/build/palette-edit/index.js +1 -2
- package/build/palette-edit/index.js.map +1 -1
- package/build/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build/sandbox/index.native.js +80 -67
- package/build/sandbox/index.native.js.map +1 -1
- package/build/tab-panel/index.js +1 -1
- package/build/tab-panel/index.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +45 -6
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/utils/input/input-control.js +1 -1
- package/build/utils/input/input-control.js.map +1 -1
- package/build-module/angle-picker-control/angle-circle.js +1 -4
- package/build-module/angle-picker-control/angle-circle.js.map +1 -1
- package/build-module/angle-picker-control/index.js +12 -21
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js +20 -13
- package/build-module/angle-picker-control/styles/angle-picker-control-styles.js.map +1 -1
- package/build-module/animate/index.js +25 -17
- package/build-module/animate/index.js.map +1 -1
- package/build-module/box-control/axial-input-controls.js.map +1 -1
- package/build-module/color-picker/color-input.js +0 -4
- package/build-module/color-picker/color-input.js.map +1 -1
- package/build-module/color-picker/component.js +3 -3
- package/build-module/color-picker/component.js.map +1 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/hsl-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/color-picker/legacy-adapter.js.map +1 -1
- package/build-module/color-picker/picker.js +4 -0
- package/build-module/color-picker/picker.js.map +1 -1
- package/build-module/color-picker/rgb-input.js.map +1 -1
- package/build-module/color-picker/use-deprecated-props.js.map +1 -1
- package/build-module/custom-gradient-picker/constants.js +1 -1
- package/build-module/custom-gradient-picker/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/constants.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js +9 -4
- package/build-module/custom-gradient-picker/gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/index.js +14 -8
- package/build-module/custom-gradient-picker/gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/gradient-bar/utils.js +34 -54
- package/build-module/custom-gradient-picker/gradient-bar/utils.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +44 -17
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/custom-gradient-picker/serializer.js +14 -4
- package/build-module/custom-gradient-picker/serializer.js.map +1 -1
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js +6 -6
- package/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js.map +1 -1
- package/build-module/custom-gradient-picker/types.js +2 -0
- package/build-module/custom-gradient-picker/utils.js +17 -12
- package/build-module/custom-gradient-picker/utils.js.map +1 -1
- package/build-module/{color-list-picker → duotone-picker/color-list-picker}/index.js +5 -5
- package/build-module/duotone-picker/color-list-picker/index.js.map +1 -0
- package/build-module/duotone-picker/color-list-picker/types.js +2 -0
- package/build-module/duotone-picker/color-list-picker/types.js.map +1 -0
- package/build-module/duotone-picker/custom-duotone-bar.js.map +1 -1
- package/build-module/duotone-picker/duotone-picker.js +38 -2
- package/build-module/duotone-picker/duotone-picker.js.map +1 -1
- package/build-module/duotone-picker/duotone-swatch.js.map +1 -1
- package/build-module/duotone-picker/index.js.map +1 -1
- package/build-module/duotone-picker/types.js +2 -0
- package/build-module/duotone-picker/types.js.map +1 -0
- package/build-module/duotone-picker/utils.js +17 -11
- package/build-module/duotone-picker/utils.js.map +1 -1
- package/build-module/form-token-field/index.js +9 -4
- package/build-module/form-token-field/index.js.map +1 -1
- package/build-module/gradient-picker/index.js +61 -10
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/gradient-picker/types.js +2 -0
- package/build-module/gradient-picker/types.js.map +1 -0
- package/build-module/palette-edit/index.js +1 -2
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/resizable-box/resize-tooltip/utils.js.map +1 -1
- package/build-module/sandbox/index.native.js +70 -58
- package/build-module/sandbox/index.native.js.map +1 -1
- package/build-module/tab-panel/index.js +2 -2
- package/build-module/tab-panel/index.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +45 -6
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/utils/input/input-control.js +1 -1
- package/build-module/utils/input/input-control.js.map +1 -1
- package/build-style/style-rtl.css +40 -28
- package/build-style/style.css +42 -28
- package/build-types/angle-picker-control/angle-circle.d.ts.map +1 -1
- package/build-types/angle-picker-control/index.d.ts.map +1 -1
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts +5 -0
- package/build-types/angle-picker-control/styles/angle-picker-control-styles.d.ts.map +1 -1
- package/build-types/animate/index.d.ts +27 -22
- package/build-types/animate/index.d.ts.map +1 -1
- package/build-types/animate/stories/index.d.ts +18 -0
- package/build-types/animate/stories/index.d.ts.map +1 -0
- package/build-types/animate/types.d.ts +30 -0
- package/build-types/animate/types.d.ts.map +1 -0
- package/build-types/color-picker/color-input.d.ts +1 -11
- package/build-types/color-picker/color-input.d.ts.map +1 -1
- package/build-types/color-picker/component.d.ts +8 -9
- package/build-types/color-picker/component.d.ts.map +1 -1
- package/build-types/color-picker/hex-input.d.ts +1 -10
- package/build-types/color-picker/hex-input.d.ts.map +1 -1
- package/build-types/color-picker/hsl-input.d.ts +1 -10
- package/build-types/color-picker/hsl-input.d.ts.map +1 -1
- package/build-types/color-picker/input-with-slider.d.ts +1 -9
- package/build-types/color-picker/input-with-slider.d.ts.map +1 -1
- package/build-types/color-picker/legacy-adapter.d.ts +1 -3
- package/build-types/color-picker/legacy-adapter.d.ts.map +1 -1
- package/build-types/color-picker/picker.d.ts +4 -7
- package/build-types/color-picker/picker.d.ts.map +1 -1
- package/build-types/color-picker/rgb-input.d.ts +1 -10
- package/build-types/color-picker/rgb-input.d.ts.map +1 -1
- package/build-types/color-picker/stories/index.d.ts +19 -0
- package/build-types/color-picker/stories/index.d.ts.map +1 -0
- package/build-types/color-picker/test/index.d.ts +2 -0
- package/build-types/color-picker/test/index.d.ts.map +1 -0
- package/build-types/color-picker/types.d.ts +105 -1
- package/build-types/color-picker/types.d.ts.map +1 -1
- package/build-types/color-picker/use-deprecated-props.d.ts +1 -44
- package/build-types/color-picker/use-deprecated-props.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/constants.d.ts +8 -8
- package/build-types/custom-gradient-picker/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts +7 -7
- package/build-types/custom-gradient-picker/gradient-bar/constants.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts +5 -22
- package/build-types/custom-gradient-picker/gradient-bar/control-points.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts +3 -9
- package/build-types/custom-gradient-picker/gradient-bar/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts +2 -0
- package/build-types/custom-gradient-picker/gradient-bar/test/utils.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts +44 -92
- package/build-types/custom-gradient-picker/gradient-bar/utils.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/index.d.ts +27 -6
- package/build-types/custom-gradient-picker/index.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/serializer.d.ts +13 -16
- package/build-types/custom-gradient-picker/serializer.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/stories/index.d.ts +12 -0
- package/build-types/custom-gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts +3 -2
- package/build-types/custom-gradient-picker/styles/custom-gradient-picker-styles.d.ts.map +1 -1
- package/build-types/custom-gradient-picker/test/serializer.d.ts +2 -0
- package/build-types/custom-gradient-picker/test/serializer.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/types.d.ts +120 -0
- package/build-types/custom-gradient-picker/types.d.ts.map +1 -0
- package/build-types/custom-gradient-picker/utils.d.ts +12 -4
- package/build-types/custom-gradient-picker/utils.d.ts.map +1 -1
- package/build-types/duotone-picker/color-list-picker/index.d.ts.map +1 -0
- package/build-types/{color-list-picker → duotone-picker/color-list-picker}/types.d.ts +2 -2
- package/build-types/duotone-picker/color-list-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts +6 -0
- package/build-types/duotone-picker/custom-duotone-bar.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-picker.d.ts +38 -0
- package/build-types/duotone-picker/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts +5 -0
- package/build-types/duotone-picker/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/index.d.ts +3 -0
- package/build-types/duotone-picker/index.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts +12 -0
- package/build-types/duotone-picker/stories/duotone-picker.d.ts.map +1 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts +14 -0
- package/build-types/duotone-picker/stories/duotone-swatch.d.ts.map +1 -0
- package/build-types/duotone-picker/types.d.ts +60 -0
- package/build-types/duotone-picker/types.d.ts.map +1 -0
- package/build-types/duotone-picker/utils.d.ts +52 -0
- package/build-types/duotone-picker/utils.d.ts.map +1 -0
- package/build-types/form-token-field/index.d.ts.map +1 -1
- package/build-types/form-token-field/types.d.ts +6 -0
- package/build-types/form-token-field/types.d.ts.map +1 -1
- package/build-types/gradient-picker/index.d.ts +49 -11
- package/build-types/gradient-picker/index.d.ts.map +1 -1
- package/build-types/gradient-picker/stories/index.d.ts +14 -0
- package/build-types/gradient-picker/stories/index.d.ts.map +1 -0
- package/build-types/gradient-picker/types.d.ts +87 -0
- package/build-types/gradient-picker/types.d.ts.map +1 -0
- package/build-types/palette-edit/index.d.ts.map +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts +1 -1
- package/build-types/resizable-box/resize-tooltip/utils.d.ts.map +1 -1
- package/build-types/tab-panel/index.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/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/build-types/utils/input/input-control.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/angle-picker-control/angle-circle.tsx +0 -1
- package/src/angle-picker-control/index.tsx +14 -27
- package/src/angle-picker-control/styles/angle-picker-control-styles.tsx +16 -9
- package/src/animate/index.tsx +75 -0
- package/src/animate/stories/index.tsx +102 -0
- package/src/animate/types.ts +32 -0
- package/src/border-box-control/stories/index.tsx +1 -1
- package/src/box-control/axial-input-controls.tsx +1 -1
- package/src/circular-option-picker/style.scss +10 -0
- package/src/color-indicator/style.scss +1 -0
- package/src/color-picker/README.md +2 -2
- package/src/color-picker/color-input.tsx +1 -12
- package/src/color-picker/component.tsx +9 -18
- package/src/color-picker/hex-input.tsx +2 -7
- package/src/color-picker/hsl-input.tsx +2 -7
- package/src/color-picker/input-with-slider.tsx +1 -9
- package/src/color-picker/legacy-adapter.tsx +1 -2
- package/src/color-picker/picker.tsx +5 -6
- package/src/color-picker/rgb-input.tsx +2 -7
- package/src/color-picker/stories/index.tsx +51 -0
- package/src/color-picker/test/{index.js → index.tsx} +36 -18
- package/src/color-picker/types.ts +128 -1
- package/src/color-picker/use-deprecated-props.ts +2 -53
- package/src/combobox-control/stories/index.tsx +1 -1
- package/src/custom-gradient-picker/{constants.js → constants.ts} +2 -2
- package/src/custom-gradient-picker/gradient-bar/{control-points.js → control-points.tsx} +171 -134
- package/src/custom-gradient-picker/gradient-bar/{index.js → index.tsx} +32 -10
- package/src/custom-gradient-picker/gradient-bar/test/{utils.js → utils.ts} +58 -31
- package/src/custom-gradient-picker/gradient-bar/utils.ts +193 -0
- package/src/custom-gradient-picker/{index.js → index.tsx} +63 -22
- package/src/custom-gradient-picker/serializer.ts +82 -0
- package/src/custom-gradient-picker/stories/index.tsx +45 -0
- package/src/custom-gradient-picker/style.scss +25 -4
- package/src/custom-gradient-picker/test/{serializer.js → serializer.ts} +39 -33
- package/src/custom-gradient-picker/types.ts +137 -0
- package/src/custom-gradient-picker/{utils.js → utils.ts} +37 -22
- package/src/custom-select-control/test/index.js +6 -4
- package/src/{color-list-picker → duotone-picker/color-list-picker}/index.tsx +7 -6
- package/src/{color-list-picker → duotone-picker/color-list-picker}/types.ts +2 -2
- package/src/duotone-picker/{custom-duotone-bar.js → custom-duotone-bar.tsx} +7 -1
- package/src/duotone-picker/{duotone-picker.js → duotone-picker.tsx} +39 -2
- package/src/duotone-picker/{duotone-swatch.js → duotone-swatch.tsx} +2 -1
- package/src/duotone-picker/stories/{duotone-picker.js → duotone-picker.tsx} +15 -8
- package/src/duotone-picker/stories/{duotone-swatch.js → duotone-swatch.tsx} +9 -3
- package/src/duotone-picker/types.ts +61 -0
- package/src/duotone-picker/{utils.js → utils.ts} +29 -14
- package/src/flex/flex-item/README.md +1 -1
- package/src/form-token-field/README.md +1 -0
- package/src/form-token-field/index.tsx +10 -3
- package/src/form-token-field/style.scss +0 -7
- package/src/form-token-field/test/index.tsx +1 -0
- package/src/form-token-field/types.ts +6 -0
- package/src/gradient-picker/README.md +16 -23
- package/src/gradient-picker/{index.js → index.tsx} +70 -16
- package/src/gradient-picker/stories/{index.js → index.tsx} +19 -8
- package/src/gradient-picker/types.ts +89 -0
- package/src/item-group/test/index.js +5 -3
- package/src/palette-edit/index.tsx +4 -5
- package/src/resizable-box/resize-tooltip/utils.ts +1 -1
- package/src/sandbox/index.native.js +71 -78
- package/src/slot-fill/test/slot.js +8 -6
- package/src/style.scss +1 -1
- package/src/tab-panel/index.tsx +7 -2
- package/src/tools-panel/test/index.tsx +86 -0
- package/src/tools-panel/tools-panel/hook.ts +44 -4
- package/src/tools-panel/types.ts +1 -0
- package/src/tooltip/test/index.js +251 -301
- package/src/utils/input/input-control.js +1 -0
- package/tsconfig.json +1 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/build/color-list-picker/index.js.map +0 -1
- package/build-module/color-list-picker/index.js.map +0 -1
- package/build-types/color-list-picker/index.d.ts.map +0 -1
- package/build-types/color-list-picker/types.d.ts.map +0 -1
- package/src/animate/index.js +0 -60
- package/src/animate/stories/index.js +0 -53
- package/src/color-picker/stories/index.js +0 -41
- package/src/custom-gradient-picker/gradient-bar/utils.js +0 -189
- package/src/custom-gradient-picker/serializer.js +0 -48
- package/src/custom-gradient-picker/stories/index.js +0 -33
- /package/build/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js +0 -0
- /package/build-module/{color-list-picker → animate}/types.js.map +0 -0
- /package/{build/color-list-picker → build-module/custom-gradient-picker}/types.js.map +0 -0
- /package/build-types/{color-list-picker → duotone-picker/color-list-picker}/index.d.ts +0 -0
- /package/src/custom-gradient-picker/gradient-bar/{constants.js → constants.ts} +0 -0
- /package/src/custom-gradient-picker/styles/{custom-gradient-picker-styles.js → custom-gradient-picker-styles.tsx} +0 -0
- /package/src/{color-list-picker → duotone-picker/color-list-picker}/style.scss +0 -0
- /package/src/duotone-picker/{index.js → index.ts} +0 -0
|
@@ -22,85 +22,85 @@ import { usePreferredColorScheme } from '@wordpress/compose';
|
|
|
22
22
|
*/
|
|
23
23
|
import sandboxStyles from './style.scss';
|
|
24
24
|
|
|
25
|
-
const observeAndResizeJS =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
// https://github.com/facebook/hermes/issues/114#issuecomment-887106990
|
|
29
|
-
'show source';
|
|
30
|
-
const { MutationObserver } = window;
|
|
31
|
-
|
|
32
|
-
if ( ! MutationObserver || ! document.body || ! window.parent ) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
25
|
+
const observeAndResizeJS = `
|
|
26
|
+
(function() {
|
|
27
|
+
const { MutationObserver } = window;
|
|
35
28
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// The function postMessage is exposed by the react-native-webview library
|
|
40
|
-
// to communicate between React Native and the WebView, in this case,
|
|
41
|
-
// we use it for notifying resize changes.
|
|
42
|
-
window.ReactNativeWebView.postMessage(
|
|
43
|
-
JSON.stringify( {
|
|
44
|
-
action: 'resize',
|
|
45
|
-
width: clientBoundingRect.width,
|
|
46
|
-
height: clientBoundingRect.height,
|
|
47
|
-
} )
|
|
48
|
-
);
|
|
49
|
-
}
|
|
29
|
+
if ( ! MutationObserver || ! document.body || ! window.parent ) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
50
32
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
33
|
+
function sendResize() {
|
|
34
|
+
const clientBoundingRect = document.body.getBoundingClientRect();
|
|
35
|
+
|
|
36
|
+
// The function postMessage is exposed by the react-native-webview library
|
|
37
|
+
// to communicate between React Native and the WebView, in this case,
|
|
38
|
+
// we use it for notifying resize changes.
|
|
39
|
+
window.ReactNativeWebView.postMessage(
|
|
40
|
+
JSON.stringify( {
|
|
41
|
+
action: 'resize',
|
|
42
|
+
width: clientBoundingRect.width,
|
|
43
|
+
height: clientBoundingRect.height,
|
|
44
|
+
} )
|
|
45
|
+
);
|
|
46
|
+
}
|
|
60
47
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
48
|
+
const observer = new MutationObserver( sendResize );
|
|
49
|
+
observer.observe( document.body, {
|
|
50
|
+
attributes: true,
|
|
51
|
+
attributeOldValue: false,
|
|
52
|
+
characterData: true,
|
|
53
|
+
characterDataOldValue: false,
|
|
54
|
+
childList: true,
|
|
55
|
+
subtree: true,
|
|
56
|
+
} );
|
|
57
|
+
|
|
58
|
+
window.addEventListener( 'load', sendResize, true );
|
|
59
|
+
|
|
60
|
+
// Hack: Remove viewport unit styles, as these are relative
|
|
61
|
+
// the iframe root and interfere with our mechanism for
|
|
62
|
+
// determining the unconstrained page bounds.
|
|
63
|
+
function removeViewportStyles( ruleOrNode ) {
|
|
64
|
+
if ( ruleOrNode.style ) {
|
|
65
|
+
[ 'width', 'height', 'minHeight', 'maxHeight' ].forEach( function (
|
|
66
|
+
style
|
|
73
67
|
) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
if (
|
|
69
|
+
/^\\d+(vmin|vmax|vh|vw)$/.test( ruleOrNode.style[ style ] )
|
|
70
|
+
) {
|
|
71
|
+
ruleOrNode.style[ style ] = '';
|
|
72
|
+
}
|
|
73
|
+
} );
|
|
74
|
+
}
|
|
77
75
|
}
|
|
78
|
-
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
77
|
+
Array.prototype.forEach.call(
|
|
78
|
+
document.querySelectorAll( '[style]' ),
|
|
79
|
+
removeViewportStyles
|
|
80
|
+
);
|
|
81
|
+
Array.prototype.forEach.call(
|
|
82
|
+
document.styleSheets,
|
|
83
|
+
function ( stylesheet ) {
|
|
84
|
+
Array.prototype.forEach.call(
|
|
85
|
+
stylesheet.cssRules || stylesheet.rules,
|
|
86
|
+
removeViewportStyles
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
);
|
|
93
90
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
document.body.style.position = 'absolute';
|
|
92
|
+
document.body.style.width = '100%';
|
|
93
|
+
document.body.setAttribute( 'data-resizable-iframe-connected', '' );
|
|
97
94
|
|
|
98
|
-
|
|
95
|
+
sendResize();
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
// Resize events can change the width of elements with 100% width, but we don't
|
|
98
|
+
// get an DOM mutations for that, so do the resize when the window is resized, too.
|
|
99
|
+
window.addEventListener( 'resize', sendResize, true );
|
|
100
|
+
window.addEventListener( 'orientationchange', sendResize, true );
|
|
101
|
+
widow.addEventListener( 'click', sendResize, true );
|
|
102
|
+
})();
|
|
103
|
+
`;
|
|
104
104
|
|
|
105
105
|
const style = `
|
|
106
106
|
body {
|
|
@@ -230,14 +230,6 @@ function Sandbox( {
|
|
|
230
230
|
className={ type }
|
|
231
231
|
>
|
|
232
232
|
<div dangerouslySetInnerHTML={ { __html: html } } />
|
|
233
|
-
<script
|
|
234
|
-
type="text/javascript"
|
|
235
|
-
dangerouslySetInnerHTML={ {
|
|
236
|
-
__html:
|
|
237
|
-
customJS ||
|
|
238
|
-
`(${ observeAndResizeJS.toString() })();`,
|
|
239
|
-
} }
|
|
240
|
-
/>
|
|
241
233
|
{ scripts.map( ( src ) => (
|
|
242
234
|
<script key={ src } src={ src } />
|
|
243
235
|
) ) }
|
|
@@ -322,6 +314,7 @@ function Sandbox( {
|
|
|
322
314
|
sandboxStyles[ 'sandbox-webview__container' ],
|
|
323
315
|
containerStyle,
|
|
324
316
|
] }
|
|
317
|
+
injectedJavaScript={ customJS || observeAndResizeJS }
|
|
325
318
|
key={ key }
|
|
326
319
|
ref={ ref }
|
|
327
320
|
source={ { baseUrl: providerUrl, html: contentHtml } }
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render,
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -92,9 +93,9 @@ describe( 'Slot', () => {
|
|
|
92
93
|
expect( container ).toMatchSnapshot();
|
|
93
94
|
} );
|
|
94
95
|
|
|
95
|
-
it( 'calls the functions passed as the Slot’s fillProps in the Fill', () => {
|
|
96
|
+
it( 'calls the functions passed as the Slot’s fillProps in the Fill', async () => {
|
|
96
97
|
const onClose = jest.fn();
|
|
97
|
-
|
|
98
|
+
const user = userEvent.setup();
|
|
98
99
|
render(
|
|
99
100
|
<Provider>
|
|
100
101
|
<Slot name="chicken" fillProps={ { onClose } } />
|
|
@@ -108,7 +109,7 @@ describe( 'Slot', () => {
|
|
|
108
109
|
</Provider>
|
|
109
110
|
);
|
|
110
111
|
|
|
111
|
-
|
|
112
|
+
await user.click( screen.getByText( 'Click me' ) );
|
|
112
113
|
|
|
113
114
|
expect( onClose ).toHaveBeenCalledTimes( 1 );
|
|
114
115
|
} );
|
|
@@ -149,7 +150,8 @@ describe( 'Slot', () => {
|
|
|
149
150
|
expect( container ).toMatchSnapshot();
|
|
150
151
|
} );
|
|
151
152
|
|
|
152
|
-
it( 'should re-render Slot when not bubbling virtually', () => {
|
|
153
|
+
it( 'should re-render Slot when not bubbling virtually', async () => {
|
|
154
|
+
const user = userEvent.setup();
|
|
153
155
|
const { container } = render(
|
|
154
156
|
<Provider>
|
|
155
157
|
<div>
|
|
@@ -161,7 +163,7 @@ describe( 'Slot', () => {
|
|
|
161
163
|
|
|
162
164
|
expect( container ).toMatchSnapshot();
|
|
163
165
|
|
|
164
|
-
|
|
166
|
+
await user.click( screen.getByRole( 'button' ) );
|
|
165
167
|
|
|
166
168
|
expect( container ).toMatchSnapshot();
|
|
167
169
|
} );
|
package/src/style.scss
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
@import "./palette-edit/style.scss";
|
|
12
12
|
@import "./color-indicator/style.scss";
|
|
13
13
|
@import "./combobox-control/style.scss";
|
|
14
|
-
@import "./color-list-picker/style.scss";
|
|
15
14
|
@import "./color-palette/style.scss";
|
|
16
15
|
@import "./custom-gradient-picker/style.scss";
|
|
17
16
|
@import "./custom-select-control/style.scss";
|
|
@@ -21,6 +20,7 @@
|
|
|
21
20
|
@import "./dropdown/style.scss";
|
|
22
21
|
@import "./dropdown-menu/style.scss";
|
|
23
22
|
@import "./duotone-picker/style.scss";
|
|
23
|
+
@import "./duotone-picker/color-list-picker/style.scss";
|
|
24
24
|
@import "./form-toggle/style.scss";
|
|
25
25
|
@import "./form-token-field/style.scss";
|
|
26
26
|
@import "./guide/style.scss";
|
package/src/tab-panel/index.tsx
CHANGED
|
@@ -6,7 +6,12 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
useState,
|
|
11
|
+
useEffect,
|
|
12
|
+
useLayoutEffect,
|
|
13
|
+
useCallback,
|
|
14
|
+
} from '@wordpress/element';
|
|
10
15
|
import { useInstanceId } from '@wordpress/compose';
|
|
11
16
|
|
|
12
17
|
/**
|
|
@@ -104,7 +109,7 @@ export function TabPanel( {
|
|
|
104
109
|
const selectedId = `${ instanceId }-${ selectedTab?.name ?? 'none' }`;
|
|
105
110
|
|
|
106
111
|
// Handle selecting the initial tab.
|
|
107
|
-
|
|
112
|
+
useLayoutEffect( () => {
|
|
108
113
|
// If there's a selected tab, don't override it.
|
|
109
114
|
if ( selectedTab ) {
|
|
110
115
|
return;
|
|
@@ -954,6 +954,92 @@ describe( 'ToolsPanel', () => {
|
|
|
954
954
|
expect( items[ 1 ] ).toHaveTextContent( 'Item 2' );
|
|
955
955
|
} );
|
|
956
956
|
|
|
957
|
+
it( 'should maintain menu item order', async () => {
|
|
958
|
+
const InconsistentItems = () => (
|
|
959
|
+
<ToolsPanelItems>
|
|
960
|
+
<ToolsPanelItem
|
|
961
|
+
label="Item 1"
|
|
962
|
+
hasValue={ () => false }
|
|
963
|
+
isShownByDefault
|
|
964
|
+
>
|
|
965
|
+
<div>Item 1</div>
|
|
966
|
+
</ToolsPanelItem>
|
|
967
|
+
<ToolsPanelItem
|
|
968
|
+
label="Item 2"
|
|
969
|
+
hasValue={ () => false }
|
|
970
|
+
isShownByDefault
|
|
971
|
+
>
|
|
972
|
+
<div>Item 2</div>
|
|
973
|
+
</ToolsPanelItem>
|
|
974
|
+
</ToolsPanelItems>
|
|
975
|
+
);
|
|
976
|
+
|
|
977
|
+
const { rerender } = render(
|
|
978
|
+
<SlotFillProvider>
|
|
979
|
+
<InconsistentItems key="order-test-step-1" />
|
|
980
|
+
<ToolsPanelItems>
|
|
981
|
+
<ToolsPanelItem
|
|
982
|
+
label="Item 3"
|
|
983
|
+
hasValue={ () => false }
|
|
984
|
+
isShownByDefault
|
|
985
|
+
>
|
|
986
|
+
<div>Item 3</div>
|
|
987
|
+
</ToolsPanelItem>
|
|
988
|
+
</ToolsPanelItems>
|
|
989
|
+
<ToolsPanel { ...defaultProps }>
|
|
990
|
+
<Slot />
|
|
991
|
+
</ToolsPanel>
|
|
992
|
+
</SlotFillProvider>
|
|
993
|
+
);
|
|
994
|
+
|
|
995
|
+
// Open dropdown menu.
|
|
996
|
+
const user = userEvent.setup();
|
|
997
|
+
let menuButton = getMenuButton();
|
|
998
|
+
await user.click( menuButton );
|
|
999
|
+
|
|
1000
|
+
// Confirm all the existing menu items are present and in the
|
|
1001
|
+
// expected order.
|
|
1002
|
+
let menuItems = await screen.findAllByRole( 'menuitemcheckbox' );
|
|
1003
|
+
|
|
1004
|
+
expect( menuItems.length ).toEqual( 3 );
|
|
1005
|
+
expect( menuItems[ 0 ] ).toHaveTextContent( 'Item 1' );
|
|
1006
|
+
expect( menuItems[ 1 ] ).toHaveTextContent( 'Item 2' );
|
|
1007
|
+
expect( menuItems[ 2 ] ).toHaveTextContent( 'Item 3' );
|
|
1008
|
+
|
|
1009
|
+
// Close the dropdown menu.
|
|
1010
|
+
await user.click( menuButton );
|
|
1011
|
+
|
|
1012
|
+
rerender(
|
|
1013
|
+
<SlotFillProvider>
|
|
1014
|
+
<InconsistentItems key="order-test-step-2" />
|
|
1015
|
+
<ToolsPanelItems>
|
|
1016
|
+
<ToolsPanelItem
|
|
1017
|
+
label="Item 3"
|
|
1018
|
+
hasValue={ () => false }
|
|
1019
|
+
isShownByDefault
|
|
1020
|
+
>
|
|
1021
|
+
<div>Item 3</div>
|
|
1022
|
+
</ToolsPanelItem>
|
|
1023
|
+
</ToolsPanelItems>
|
|
1024
|
+
<ToolsPanel { ...defaultProps }>
|
|
1025
|
+
<Slot />
|
|
1026
|
+
</ToolsPanel>
|
|
1027
|
+
</SlotFillProvider>
|
|
1028
|
+
);
|
|
1029
|
+
|
|
1030
|
+
// Reopen dropdown menu.
|
|
1031
|
+
menuButton = getMenuButton();
|
|
1032
|
+
await user.click( menuButton );
|
|
1033
|
+
|
|
1034
|
+
// Confirm the menu item order has been maintained.
|
|
1035
|
+
menuItems = await screen.findAllByRole( 'menuitemcheckbox' );
|
|
1036
|
+
|
|
1037
|
+
expect( menuItems.length ).toEqual( 3 );
|
|
1038
|
+
expect( menuItems[ 0 ] ).toHaveTextContent( 'Item 1' );
|
|
1039
|
+
expect( menuItems[ 1 ] ).toHaveTextContent( 'Item 2' );
|
|
1040
|
+
expect( menuItems[ 2 ] ).toHaveTextContent( 'Item 3' );
|
|
1041
|
+
} );
|
|
1042
|
+
|
|
957
1043
|
it( 'should not trigger callback when fill has not updated yet when panel has', () => {
|
|
958
1044
|
// Fill provided controls can update independently to the panel.
|
|
959
1045
|
// A `panelId` prop was added to both panels and items
|
|
@@ -30,7 +30,9 @@ const generateMenuItems = ( {
|
|
|
30
30
|
panelItems,
|
|
31
31
|
shouldReset,
|
|
32
32
|
currentMenuItems,
|
|
33
|
+
menuItemOrder,
|
|
33
34
|
}: ToolsPanelMenuItemsConfig ) => {
|
|
35
|
+
const newMenuItems: ToolsPanelMenuItems = { default: {}, optional: {} };
|
|
34
36
|
const menuItems: ToolsPanelMenuItems = { default: {}, optional: {} };
|
|
35
37
|
|
|
36
38
|
panelItems.forEach( ( { hasValue, isShownByDefault, label } ) => {
|
|
@@ -42,7 +44,31 @@ const generateMenuItems = ( {
|
|
|
42
44
|
const existingItemValue = currentMenuItems?.[ group ]?.[ label ];
|
|
43
45
|
const value = existingItemValue ? existingItemValue : hasValue();
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
newMenuItems[ group ][ label ] = shouldReset ? false : value;
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
// Loop the known, previously registered items first to maintain menu order.
|
|
51
|
+
menuItemOrder.forEach( ( key ) => {
|
|
52
|
+
if ( newMenuItems.default.hasOwnProperty( key ) ) {
|
|
53
|
+
menuItems.default[ key ] = newMenuItems.default[ key ];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if ( newMenuItems.optional.hasOwnProperty( key ) ) {
|
|
57
|
+
menuItems.optional[ key ] = newMenuItems.optional[ key ];
|
|
58
|
+
}
|
|
59
|
+
} );
|
|
60
|
+
|
|
61
|
+
// Loop newMenuItems object adding any that aren't in the known items order.
|
|
62
|
+
Object.keys( newMenuItems.default ).forEach( ( key ) => {
|
|
63
|
+
if ( ! menuItems.default.hasOwnProperty( key ) ) {
|
|
64
|
+
menuItems.default[ key ] = newMenuItems.default[ key ];
|
|
65
|
+
}
|
|
66
|
+
} );
|
|
67
|
+
|
|
68
|
+
Object.keys( newMenuItems.optional ).forEach( ( key ) => {
|
|
69
|
+
if ( ! menuItems.optional.hasOwnProperty( key ) ) {
|
|
70
|
+
menuItems.optional[ key ] = newMenuItems.optional[ key ];
|
|
71
|
+
}
|
|
46
72
|
} );
|
|
47
73
|
|
|
48
74
|
return menuItems;
|
|
@@ -82,12 +108,14 @@ export function useToolsPanel(
|
|
|
82
108
|
|
|
83
109
|
// Allow panel items to register themselves.
|
|
84
110
|
const [ panelItems, setPanelItems ] = useState< ToolsPanelItem[] >( [] );
|
|
111
|
+
const [ menuItemOrder, setMenuItemOrder ] = useState< string[] >( [] );
|
|
85
112
|
const [ resetAllFilters, setResetAllFilters ] = useState<
|
|
86
113
|
ResetAllFilter[]
|
|
87
114
|
>( [] );
|
|
88
115
|
|
|
89
116
|
const registerPanelItem = useCallback(
|
|
90
117
|
( item: ToolsPanelItem ) => {
|
|
118
|
+
// Add item to panel items.
|
|
91
119
|
setPanelItems( ( items ) => {
|
|
92
120
|
const newItems = [ ...items ];
|
|
93
121
|
// If an item with this label has already been registered, remove it
|
|
@@ -101,8 +129,18 @@ export function useToolsPanel(
|
|
|
101
129
|
}
|
|
102
130
|
return [ ...newItems, item ];
|
|
103
131
|
} );
|
|
132
|
+
|
|
133
|
+
// Track the initial order of item registration. This is used for
|
|
134
|
+
// maintaining menu item order later.
|
|
135
|
+
setMenuItemOrder( ( items ) => {
|
|
136
|
+
if ( items.includes( item.label ) ) {
|
|
137
|
+
return items;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return [ ...items, item.label ];
|
|
141
|
+
} );
|
|
104
142
|
},
|
|
105
|
-
[ setPanelItems ]
|
|
143
|
+
[ setPanelItems, setMenuItemOrder ]
|
|
106
144
|
);
|
|
107
145
|
|
|
108
146
|
// Panels need to deregister on unmount to avoid orphans in menu state.
|
|
@@ -160,10 +198,11 @@ export function useToolsPanel(
|
|
|
160
198
|
panelItems,
|
|
161
199
|
shouldReset: false,
|
|
162
200
|
currentMenuItems: prevState,
|
|
201
|
+
menuItemOrder,
|
|
163
202
|
} );
|
|
164
203
|
return items;
|
|
165
204
|
} );
|
|
166
|
-
}, [ panelItems, setMenuItems ] );
|
|
205
|
+
}, [ panelItems, setMenuItems, menuItemOrder ] );
|
|
167
206
|
|
|
168
207
|
// Force a menu item to be checked.
|
|
169
208
|
// This is intended for use with default panel items. They are displayed
|
|
@@ -267,10 +306,11 @@ export function useToolsPanel(
|
|
|
267
306
|
// Turn off display of all non-default items.
|
|
268
307
|
const resetMenuItems = generateMenuItems( {
|
|
269
308
|
panelItems,
|
|
309
|
+
menuItemOrder,
|
|
270
310
|
shouldReset: true,
|
|
271
311
|
} );
|
|
272
312
|
setMenuItems( resetMenuItems );
|
|
273
|
-
}, [ panelItems, resetAllFilters, resetAll, setMenuItems ] );
|
|
313
|
+
}, [ panelItems, resetAllFilters, resetAll, setMenuItems, menuItemOrder ] );
|
|
274
314
|
|
|
275
315
|
// Assist ItemGroup styling when there are potentially hidden placeholder
|
|
276
316
|
// items by identifying first & last items that are toggled on for display.
|