@wordpress/components 19.1.2 → 19.2.1-next.33ec3857e2.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 +53 -4
- package/README.md +0 -1
- package/build/angle-picker-control/index.js +2 -0
- package/build/angle-picker-control/index.js.map +1 -1
- package/build/button/index.native.js +13 -3
- package/build/button/index.native.js.map +1 -1
- package/build/checkbox-control/index.js +1 -1
- package/build/checkbox-control/index.js.map +1 -1
- package/build/clipboard-button/index.js +1 -2
- package/build/clipboard-button/index.js.map +1 -1
- package/build/color-palette/index.js +36 -9
- package/build/color-palette/index.js.map +1 -1
- package/build/color-picker/color-display.js +4 -2
- package/build/color-picker/color-display.js.map +1 -1
- package/build/color-picker/hex-input.js +3 -1
- package/build/color-picker/hex-input.js.map +1 -1
- package/build/color-picker/input-with-slider.js +3 -1
- package/build/color-picker/input-with-slider.js.map +1 -1
- package/build/confirm-dialog/component.js +103 -0
- package/build/confirm-dialog/component.js.map +1 -0
- package/build/confirm-dialog/index.js +16 -0
- package/build/confirm-dialog/index.js.map +1 -0
- package/build/confirm-dialog/types.js +6 -0
- package/build/confirm-dialog/types.js.map +1 -0
- package/build/custom-gradient-bar/constants.js +1 -6
- package/build/custom-gradient-bar/constants.js.map +1 -1
- package/build/custom-gradient-bar/control-points.js +52 -21
- package/build/custom-gradient-bar/control-points.js.map +1 -1
- package/build/custom-gradient-bar/index.js +5 -1
- package/build/custom-gradient-bar/index.js.map +1 -1
- package/build/custom-gradient-picker/index.js +4 -1
- package/build/custom-gradient-picker/index.js.map +1 -1
- package/build/date-time/date.js +63 -86
- package/build/date-time/date.js.map +1 -1
- package/build/date-time/utils.js +32 -0
- package/build/date-time/utils.js.map +1 -0
- package/build/divider/component.js +8 -7
- package/build/divider/component.js.map +1 -1
- package/build/divider/styles.js +38 -13
- package/build/divider/styles.js.map +1 -1
- package/build/drop-zone/index.js +14 -6
- package/build/drop-zone/index.js.map +1 -1
- package/build/drop-zone/provider.js +1 -0
- package/build/drop-zone/provider.js.map +1 -1
- package/build/flyout/styles.js +2 -2
- package/build/flyout/styles.js.map +1 -1
- package/build/focusable-iframe/index.js +1 -0
- package/build/focusable-iframe/index.js.map +1 -1
- package/build/font-size-picker/index.js +10 -9
- package/build/font-size-picker/index.js.map +1 -1
- package/build/font-size-picker/utils.js +28 -17
- package/build/font-size-picker/utils.js.map +1 -1
- package/build/gradient-picker/index.js +3 -1
- package/build/gradient-picker/index.js.map +1 -1
- package/build/higher-order/with-focus-outside/index.js +2 -0
- package/build/higher-order/with-focus-outside/index.js.map +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/input-control/styles/input-control-styles.js +44 -32
- package/build/input-control/styles/input-control-styles.js.map +1 -1
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -3
- package/build/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build/mobile/color-settings/index.native.js +4 -2
- package/build/mobile/color-settings/index.native.js.map +1 -1
- package/build/mobile/color-settings/palette.screen.native.js +7 -6
- package/build/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build/mobile/global-styles-context/utils.native.js +1 -1
- package/build/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build/mobile/gridicons/index.native.js +3 -1
- package/build/mobile/gridicons/index.native.js.map +1 -1
- package/build/mobile/link-picker/index.native.js +45 -4
- package/build/mobile/link-picker/index.native.js.map +1 -1
- package/build/mobile/link-settings/index.native.js +10 -0
- package/build/mobile/link-settings/index.native.js.map +1 -1
- package/build/modal/aria-helper.js +2 -0
- package/build/modal/aria-helper.js.map +1 -1
- package/build/modal/index.js +17 -8
- package/build/modal/index.js.map +1 -1
- package/build/palette-edit/index.js +13 -11
- package/build/palette-edit/index.js.map +1 -1
- package/build/select-control/styles/select-control-styles.js +33 -9
- package/build/select-control/styles/select-control-styles.js.map +1 -1
- package/build/style-provider/index.js +2 -0
- package/build/style-provider/index.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/component.js +7 -2
- package/build/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +25 -14
- package/build/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
- package/build/tools-panel/styles.js +12 -10
- package/build/tools-panel/styles.js.map +1 -1
- package/build/tools-panel/tools-panel/component.js +6 -8
- package/build/tools-panel/tools-panel/component.js.map +1 -1
- package/build/tools-panel/tools-panel/hook.js +48 -17
- package/build/tools-panel/tools-panel/hook.js.map +1 -1
- package/build/tools-panel/tools-panel-item/hook.js +5 -1
- package/build/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build/unit-control/styles/unit-control-styles.js +23 -41
- package/build/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build/z-stack/component.js.map +1 -1
- package/build/z-stack/styles.js +10 -8
- package/build/z-stack/styles.js.map +1 -1
- package/build-module/angle-picker-control/index.js +2 -0
- package/build-module/angle-picker-control/index.js.map +1 -1
- package/build-module/button/index.native.js +13 -3
- package/build-module/button/index.native.js.map +1 -1
- package/build-module/checkbox-control/index.js +1 -1
- package/build-module/checkbox-control/index.js.map +1 -1
- package/build-module/clipboard-button/index.js +1 -2
- package/build-module/clipboard-button/index.js.map +1 -1
- package/build-module/color-palette/index.js +34 -10
- package/build-module/color-palette/index.js.map +1 -1
- package/build-module/color-picker/color-display.js +3 -2
- package/build-module/color-picker/color-display.js.map +1 -1
- package/build-module/color-picker/hex-input.js +2 -1
- package/build-module/color-picker/hex-input.js.map +1 -1
- package/build-module/color-picker/input-with-slider.js +2 -1
- package/build-module/color-picker/input-with-slider.js.map +1 -1
- package/build-module/confirm-dialog/component.js +84 -0
- package/build-module/confirm-dialog/component.js.map +1 -0
- package/build-module/confirm-dialog/index.js +6 -0
- package/build-module/confirm-dialog/index.js.map +1 -0
- package/build-module/confirm-dialog/types.js +2 -0
- package/build-module/confirm-dialog/types.js.map +1 -0
- package/build-module/custom-gradient-bar/constants.js +0 -4
- package/build-module/custom-gradient-bar/constants.js.map +1 -1
- package/build-module/custom-gradient-bar/control-points.js +54 -23
- package/build-module/custom-gradient-bar/control-points.js.map +1 -1
- package/build-module/custom-gradient-bar/index.js +5 -1
- package/build-module/custom-gradient-bar/index.js.map +1 -1
- package/build-module/custom-gradient-picker/index.js +4 -1
- package/build-module/custom-gradient-picker/index.js.map +1 -1
- package/build-module/date-time/date.js +63 -87
- package/build-module/date-time/date.js.map +1 -1
- package/build-module/date-time/utils.js +20 -0
- package/build-module/date-time/utils.js.map +1 -0
- package/build-module/divider/component.js +8 -7
- package/build-module/divider/component.js.map +1 -1
- package/build-module/divider/styles.js +37 -13
- package/build-module/divider/styles.js.map +1 -1
- package/build-module/drop-zone/index.js +14 -6
- package/build-module/drop-zone/index.js.map +1 -1
- package/build-module/drop-zone/provider.js +1 -0
- package/build-module/drop-zone/provider.js.map +1 -1
- package/build-module/flyout/styles.js +2 -2
- package/build-module/flyout/styles.js.map +1 -1
- package/build-module/focusable-iframe/index.js +1 -0
- package/build-module/focusable-iframe/index.js.map +1 -1
- package/build-module/font-size-picker/index.js +10 -9
- package/build-module/font-size-picker/index.js.map +1 -1
- package/build-module/font-size-picker/utils.js +28 -17
- package/build-module/font-size-picker/utils.js.map +1 -1
- package/build-module/gradient-picker/index.js +3 -1
- package/build-module/gradient-picker/index.js.map +1 -1
- package/build-module/higher-order/with-focus-outside/index.js +1 -0
- package/build-module/higher-order/with-focus-outside/index.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/input-control/styles/input-control-styles.js +44 -32
- package/build-module/input-control/styles/input-control-styles.js.map +1 -1
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js +10 -4
- package/build-module/mobile/bottom-sheet/link-suggestion-item-cell.native.js.map +1 -1
- package/build-module/mobile/color-settings/index.native.js +4 -2
- package/build-module/mobile/color-settings/index.native.js.map +1 -1
- package/build-module/mobile/color-settings/palette.screen.native.js +7 -6
- package/build-module/mobile/color-settings/palette.screen.native.js.map +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js +1 -1
- package/build-module/mobile/global-styles-context/utils.native.js.map +1 -1
- package/build-module/mobile/gridicons/index.native.js +1 -0
- package/build-module/mobile/gridicons/index.native.js.map +1 -1
- package/build-module/mobile/link-picker/index.native.js +50 -8
- package/build-module/mobile/link-picker/index.native.js.map +1 -1
- package/build-module/mobile/link-settings/index.native.js +10 -0
- package/build-module/mobile/link-settings/index.native.js.map +1 -1
- package/build-module/modal/aria-helper.js +2 -0
- package/build-module/modal/aria-helper.js.map +1 -1
- package/build-module/modal/index.js +15 -8
- package/build-module/modal/index.js.map +1 -1
- package/build-module/palette-edit/index.js +13 -11
- package/build-module/palette-edit/index.js.map +1 -1
- package/build-module/select-control/styles/select-control-styles.js +33 -9
- package/build-module/select-control/styles/select-control-styles.js.map +1 -1
- package/build-module/style-provider/index.js +1 -0
- package/build-module/style-provider/index.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/component.js +8 -3
- package/build-module/toggle-group-control/toggle-group-control/component.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js +25 -14
- package/build-module/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.js.map +1 -1
- package/build-module/toggle-group-control/toggle-group-control-option/styles.js +8 -8
- package/build-module/toggle-group-control/toggle-group-control-option/styles.js.map +1 -1
- package/build-module/tools-panel/styles.js +12 -11
- package/build-module/tools-panel/styles.js.map +1 -1
- package/build-module/tools-panel/tools-panel/component.js +5 -8
- package/build-module/tools-panel/tools-panel/component.js.map +1 -1
- package/build-module/tools-panel/tools-panel/hook.js +48 -17
- package/build-module/tools-panel/tools-panel/hook.js.map +1 -1
- package/build-module/tools-panel/tools-panel-item/hook.js +5 -1
- package/build-module/tools-panel/tools-panel-item/hook.js.map +1 -1
- package/build-module/unit-control/styles/unit-control-styles.js +23 -41
- package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
- package/build-module/z-stack/component.js.map +1 -1
- package/build-module/z-stack/styles.js +13 -8
- package/build-module/z-stack/styles.js.map +1 -1
- package/build-style/style-rtl.css +34 -12
- package/build-style/style.css +34 -12
- package/build-types/base-field/hook.d.ts +16 -16
- package/build-types/card/card/hook.d.ts +16 -16
- package/build-types/card/card-body/hook.d.ts +16 -16
- package/build-types/card/card-divider/hook.d.ts +18 -18
- package/build-types/card/card-footer/hook.d.ts +17 -17
- package/build-types/card/card-header/hook.d.ts +16 -16
- package/build-types/card/card-media/hook.d.ts +16 -16
- package/build-types/divider/component.d.ts +8 -7
- package/build-types/divider/component.d.ts.map +1 -1
- package/build-types/divider/styles.d.ts +2 -2
- package/build-types/divider/styles.d.ts.map +1 -1
- package/build-types/divider/types.d.ts +5 -5
- package/build-types/divider/types.d.ts.map +1 -1
- package/build-types/elevation/hook.d.ts +15 -15
- package/build-types/flex/flex/hook.d.ts +16 -16
- package/build-types/flex/flex-block/hook.d.ts +16 -16
- package/build-types/flex/flex-item/hook.d.ts +16 -16
- package/build-types/flyout/flyout/hook.d.ts +17 -17
- package/build-types/flyout/styles.d.ts +7 -9
- package/build-types/flyout/styles.d.ts.map +1 -1
- package/build-types/grid/hook.d.ts +16 -16
- package/build-types/h-stack/hook.d.ts +16 -16
- package/build-types/heading/hook.d.ts +16 -16
- package/build-types/input-control/index.d.ts +1 -1
- package/build-types/input-control/index.d.ts.map +1 -1
- package/build-types/input-control/input-field.d.ts +1 -1
- package/build-types/input-control/input-field.d.ts.map +1 -1
- package/build-types/input-control/styles/input-control-styles.d.ts +1 -2
- package/build-types/input-control/styles/input-control-styles.d.ts.map +1 -1
- package/build-types/input-control/types.d.ts +2 -1
- package/build-types/input-control/types.d.ts.map +1 -1
- package/build-types/item-group/item/hook.d.ts +16 -16
- package/build-types/item-group/item-group/hook.d.ts +16 -16
- package/build-types/number-control/styles/number-control-styles.d.ts +1 -1
- package/build-types/scrollable/hook.d.ts +16 -16
- package/build-types/select-control/styles/select-control-styles.d.ts.map +1 -1
- package/build-types/select-control/types.d.ts +1 -1
- package/build-types/select-control/types.d.ts.map +1 -1
- package/build-types/spacer/hook.d.ts +16 -16
- package/build-types/surface/hook.d.ts +16 -16
- package/build-types/text/hook.d.ts +16 -16
- package/build-types/toggle-group-control/toggle-group-control/component.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.d.ts.map +1 -1
- package/build-types/toggle-group-control/toggle-group-control-option/styles.d.ts.map +1 -1
- package/build-types/tools-panel/styles.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/component.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel/hook.d.ts.map +1 -1
- package/build-types/tools-panel/tools-panel-header/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts +16 -16
- package/build-types/tools-panel/tools-panel-item/hook.d.ts.map +1 -1
- package/build-types/tools-panel/types.d.ts +2 -1
- package/build-types/tools-panel/types.d.ts.map +1 -1
- package/build-types/truncate/hook.d.ts +16 -16
- package/build-types/ui/control-group/hook.d.ts +18 -18
- package/build-types/ui/control-label/hook.d.ts +16 -16
- package/build-types/ui/form-group/form-group.d.ts +4 -4
- package/build-types/ui/form-group/use-form-group.d.ts +55 -55
- package/build-types/unit-control/index.d.ts +1 -1
- package/build-types/unit-control/index.d.ts.map +1 -1
- package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -0
- package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
- package/build-types/unit-control/types.d.ts +2 -2
- package/build-types/unit-control/types.d.ts.map +1 -1
- package/build-types/v-stack/hook.d.ts +16 -16
- package/build-types/z-stack/component.d.ts +1 -1
- package/build-types/z-stack/styles.d.ts.map +1 -1
- package/package.json +21 -23
- package/src/alignment-matrix-control/stories/index.js +1 -1
- package/src/angle-picker-control/index.js +2 -0
- package/src/base-control/stories/index.js +1 -1
- package/src/button/index.native.js +15 -1
- package/src/button/stories/index.js +1 -1
- package/src/button/style.scss +14 -0
- package/src/card/card/README.md +3 -3
- package/src/card/stories/index.js +1 -1
- package/src/card/test/__snapshots__/index.js.snap +6 -6
- package/src/checkbox-control/index.js +1 -1
- package/src/checkbox-control/stories/index.js +1 -1
- package/src/clipboard-button/index.js +1 -2
- package/src/color-indicator/stories/index.js +1 -1
- package/src/color-indicator/style.scss +5 -8
- package/src/color-palette/index.js +37 -9
- package/src/color-palette/stories/index.js +1 -1
- package/src/color-palette/style.scss +10 -1
- package/src/color-palette/test/__snapshots__/index.js.snap +30 -21
- package/src/color-picker/color-display.tsx +3 -2
- package/src/color-picker/hex-input.tsx +2 -1
- package/src/color-picker/input-with-slider.tsx +2 -1
- package/src/color-picker/stories/index.js +1 -1
- package/src/combobox-control/README.md +2 -2
- package/src/confirm-dialog/README.md +128 -0
- package/src/confirm-dialog/component.tsx +114 -0
- package/src/confirm-dialog/index.tsx +6 -0
- package/src/confirm-dialog/stories/index.js +120 -0
- package/src/confirm-dialog/test/index.js +302 -0
- package/src/confirm-dialog/types.ts +26 -0
- package/src/custom-gradient-bar/constants.js +0 -5
- package/src/custom-gradient-bar/control-points.js +40 -9
- package/src/custom-gradient-bar/index.js +8 -0
- package/src/custom-gradient-picker/index.js +9 -1
- package/src/custom-gradient-picker/style.scss +0 -4
- package/src/date-time/README.md +7 -0
- package/src/date-time/date.js +67 -84
- package/src/date-time/stories/index.js +1 -1
- package/src/date-time/stories/time.js +1 -1
- package/src/date-time/test/date.js +3 -29
- package/src/date-time/test/utils.js +32 -0
- package/src/date-time/utils.js +18 -0
- package/src/dimension-control/README.md +1 -1
- package/src/divider/README.md +33 -5
- package/src/divider/component.tsx +8 -7
- package/src/divider/stories/index.js +43 -17
- package/src/divider/styles.ts +53 -16
- package/src/divider/test/__snapshots__/index.js.snap +11 -11
- package/src/divider/test/index.js +4 -4
- package/src/divider/types.ts +5 -5
- package/src/drop-zone/index.js +14 -6
- package/src/drop-zone/provider.js +1 -0
- package/src/dropdown-menu/stories/index.js +1 -1
- package/src/duotone-picker/README.md +1 -1
- package/src/elevation/stories/index.js +1 -1
- package/src/external-link/stories/index.js +1 -1
- package/src/flyout/styles.ts +4 -2
- package/src/focusable-iframe/index.js +1 -0
- package/src/font-size-picker/index.js +27 -13
- package/src/font-size-picker/stories/index.js +63 -1
- package/src/font-size-picker/test/index.js +87 -0
- package/src/font-size-picker/test/util.js +74 -0
- package/src/font-size-picker/utils.js +31 -17
- package/src/form-token-field/stories/index.js +1 -1
- package/src/gradient-picker/index.js +4 -0
- package/src/gradient-picker/stories/index.js +1 -1
- package/src/grid/stories/index.js +1 -1
- package/src/guide/stories/index.js +1 -1
- package/src/higher-order/with-focus-outside/index.js +2 -0
- package/src/icon/stories/index.js +1 -1
- package/src/index.js +1 -0
- package/src/input-control/stories/index.js +2 -1
- package/src/input-control/styles/input-control-styles.tsx +16 -6
- package/src/input-control/types.ts +3 -1
- package/src/item-group/stories/index.js +84 -2
- package/src/menu-item/README.md +2 -2
- package/src/mobile/bottom-sheet/link-suggestion-item-cell.native.js +6 -2
- package/src/mobile/color-settings/index.native.js +2 -0
- package/src/mobile/color-settings/palette.screen.native.js +8 -5
- package/src/mobile/color-settings/style.native.scss +1 -1
- package/src/mobile/global-styles-context/utils.native.js +1 -1
- package/src/mobile/gridicons/index.native.js +3 -3
- package/src/mobile/inserter-button/style.native.scss +1 -0
- package/src/mobile/link-picker/index.native.js +41 -7
- package/src/mobile/link-settings/index.native.js +11 -0
- package/src/mobile/link-settings/test/edit.native.js +432 -0
- package/src/modal/README.md +10 -0
- package/src/modal/aria-helper.js +2 -0
- package/src/modal/index.js +72 -55
- package/src/modal/stories/index.js +6 -1
- package/src/modal/style.scss +9 -0
- package/src/modal/test/index.js +11 -0
- package/src/navigation/README.md +0 -9
- package/src/notice/stories/index.js +1 -1
- package/src/number-control/stories/index.js +1 -1
- package/src/palette-edit/index.js +15 -16
- package/src/palette-edit/style.scss +5 -0
- package/src/panel/stories/index.js +1 -1
- package/src/placeholder/stories/index.js +1 -1
- package/src/popover/stories/index.js +1 -1
- package/src/query-controls/README.md +138 -6
- package/src/radio-group/README.md +4 -1
- package/src/range-control/stories/index.js +1 -1
- package/src/resizable-box/stories/index.js +1 -1
- package/src/scrollable/stories/index.js +1 -1
- package/src/search-control/stories/index.js +1 -1
- package/src/select-control/stories/index.js +2 -1
- package/src/select-control/styles/select-control-styles.ts +25 -2
- package/src/select-control/types.ts +1 -1
- package/src/slot-fill/stories/index.js +1 -1
- package/src/snackbar/stories/index.js +1 -1
- package/src/spacer/stories/index.js +1 -1
- package/src/style-provider/index.js +2 -0
- package/src/surface/stories/index.js +1 -1
- package/src/tab-panel/stories/index.js +1 -1
- package/src/text-control/stories/index.js +1 -1
- package/src/text-highlight/stories/index.js +1 -1
- package/src/textarea-control/stories/index.js +1 -1
- package/src/tip/stories/index.js +1 -1
- package/src/toggle-control/stories/index.js +1 -1
- package/src/toggle-group-control/stories/index.js +1 -1
- package/src/toggle-group-control/toggle-group-control/component.tsx +7 -2
- package/src/toggle-group-control/toggle-group-control/toggle-group-control-backdrop.tsx +24 -9
- package/src/toggle-group-control/toggle-group-control-option/styles.ts +3 -0
- package/src/toolbar-button/stories/index.js +1 -1
- package/src/tools-panel/stories/index.js +237 -0
- package/src/tools-panel/styles.ts +41 -1
- package/src/tools-panel/test/index.js +234 -1
- package/src/tools-panel/tools-panel/README.md +9 -0
- package/src/tools-panel/tools-panel/component.tsx +2 -5
- package/src/tools-panel/tools-panel/hook.ts +50 -18
- package/src/tools-panel/tools-panel-item/hook.ts +5 -1
- package/src/tools-panel/types.ts +5 -1
- package/src/tooltip/stories/index.js +1 -1
- package/src/tree-select/stories/index.js +1 -1
- package/src/truncate/stories/index.js +1 -1
- package/src/unit-control/stories/index.js +19 -1
- package/src/unit-control/styles/unit-control-styles.ts +33 -46
- package/src/unit-control/types.ts +5 -2
- package/src/z-stack/README.md +1 -1
- package/src/z-stack/component.tsx +1 -1
- package/src/z-stack/stories/index.js +1 -1
- package/src/z-stack/styles.ts +7 -2
- package/tsconfig.json +6 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -7,6 +7,10 @@ import styled from '@emotion/styled';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
|
+
import {
|
|
11
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
12
|
+
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
|
13
|
+
} from '@wordpress/components';
|
|
10
14
|
|
|
11
15
|
/**
|
|
12
16
|
* Internal dependencies
|
|
@@ -81,6 +85,56 @@ export const _default = () => {
|
|
|
81
85
|
);
|
|
82
86
|
};
|
|
83
87
|
|
|
88
|
+
export const WithNonToolsPanelItems = () => {
|
|
89
|
+
const [ height, setHeight ] = useState();
|
|
90
|
+
const [ width, setWidth ] = useState();
|
|
91
|
+
|
|
92
|
+
const resetAll = () => {
|
|
93
|
+
setHeight( undefined );
|
|
94
|
+
setWidth( undefined );
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<PanelWrapperView>
|
|
99
|
+
<Panel>
|
|
100
|
+
<ToolsPanel
|
|
101
|
+
label="ToolsPanel (with non-menu items)"
|
|
102
|
+
resetAll={ resetAll }
|
|
103
|
+
>
|
|
104
|
+
<IntroText>
|
|
105
|
+
This text illustrates not all items must be wrapped in a
|
|
106
|
+
ToolsPanelItem and represented in the panel menu.
|
|
107
|
+
</IntroText>
|
|
108
|
+
<SingleColumnItem
|
|
109
|
+
hasValue={ () => !! width }
|
|
110
|
+
label="Width"
|
|
111
|
+
onDeselect={ () => setWidth( undefined ) }
|
|
112
|
+
isShownByDefault={ true }
|
|
113
|
+
>
|
|
114
|
+
<UnitControl
|
|
115
|
+
label="Width"
|
|
116
|
+
value={ width }
|
|
117
|
+
onChange={ ( next ) => setWidth( next ) }
|
|
118
|
+
/>
|
|
119
|
+
</SingleColumnItem>
|
|
120
|
+
<SingleColumnItem
|
|
121
|
+
hasValue={ () => !! height }
|
|
122
|
+
label="Height"
|
|
123
|
+
onDeselect={ () => setHeight( undefined ) }
|
|
124
|
+
isShownByDefault={ true }
|
|
125
|
+
>
|
|
126
|
+
<UnitControl
|
|
127
|
+
label="Height"
|
|
128
|
+
value={ height }
|
|
129
|
+
onChange={ ( next ) => setHeight( next ) }
|
|
130
|
+
/>
|
|
131
|
+
</SingleColumnItem>
|
|
132
|
+
</ToolsPanel>
|
|
133
|
+
</Panel>
|
|
134
|
+
</PanelWrapperView>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
84
138
|
export const WithOptionalItemsPlusIcon = () => {
|
|
85
139
|
const [ height, setHeight ] = useState();
|
|
86
140
|
const [ width, setWidth ] = useState();
|
|
@@ -215,6 +269,185 @@ export const WithSlotFillItems = () => {
|
|
|
215
269
|
);
|
|
216
270
|
};
|
|
217
271
|
|
|
272
|
+
export const WithConditionalDefaultControl = () => {
|
|
273
|
+
const [ attributes, setAttributes ] = useState( {} );
|
|
274
|
+
const { height, scale } = attributes;
|
|
275
|
+
|
|
276
|
+
const resetAll = ( resetFilters = [] ) => {
|
|
277
|
+
let newAttributes = {};
|
|
278
|
+
|
|
279
|
+
resetFilters.forEach( ( resetFilter ) => {
|
|
280
|
+
newAttributes = {
|
|
281
|
+
...newAttributes,
|
|
282
|
+
...resetFilter( newAttributes ),
|
|
283
|
+
};
|
|
284
|
+
} );
|
|
285
|
+
|
|
286
|
+
setAttributes( newAttributes );
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const updateAttribute = ( name, value ) => {
|
|
290
|
+
setAttributes( {
|
|
291
|
+
...attributes,
|
|
292
|
+
[ name ]: value,
|
|
293
|
+
} );
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<SlotFillProvider>
|
|
298
|
+
<ToolsPanelItems>
|
|
299
|
+
<SingleColumnItem
|
|
300
|
+
hasValue={ () => !! height }
|
|
301
|
+
label="Injected Height"
|
|
302
|
+
onDeselect={ () => updateAttribute( 'height', undefined ) }
|
|
303
|
+
resetAllFilter={ () => ( { height: undefined } ) }
|
|
304
|
+
panelId={ panelId }
|
|
305
|
+
isShownByDefault={ true }
|
|
306
|
+
>
|
|
307
|
+
<UnitControl
|
|
308
|
+
label="Injected Height"
|
|
309
|
+
value={ height }
|
|
310
|
+
onChange={ ( next ) =>
|
|
311
|
+
updateAttribute( 'height', next )
|
|
312
|
+
}
|
|
313
|
+
/>
|
|
314
|
+
</SingleColumnItem>
|
|
315
|
+
<ToolsPanelItem
|
|
316
|
+
hasValue={ () => !! scale }
|
|
317
|
+
label="Scale"
|
|
318
|
+
onDeselect={ () => updateAttribute( 'scale', undefined ) }
|
|
319
|
+
resetAllFilter={ () => ( { scale: undefined } ) }
|
|
320
|
+
panelId={ panelId }
|
|
321
|
+
isShownByDefault={ !! height }
|
|
322
|
+
>
|
|
323
|
+
<ToggleGroupControl
|
|
324
|
+
label="Scale"
|
|
325
|
+
value={ scale }
|
|
326
|
+
onChange={ ( next ) =>
|
|
327
|
+
updateAttribute( 'scale', next )
|
|
328
|
+
}
|
|
329
|
+
isBlock
|
|
330
|
+
>
|
|
331
|
+
<ToggleGroupControlOption value="cover" label="Cover" />
|
|
332
|
+
<ToggleGroupControlOption
|
|
333
|
+
value="contain"
|
|
334
|
+
label="Contain"
|
|
335
|
+
/>
|
|
336
|
+
<ToggleGroupControlOption value="fill" label="Fill" />
|
|
337
|
+
</ToggleGroupControl>
|
|
338
|
+
</ToolsPanelItem>
|
|
339
|
+
</ToolsPanelItems>
|
|
340
|
+
<PanelWrapperView>
|
|
341
|
+
<Panel>
|
|
342
|
+
<ToolsPanel
|
|
343
|
+
label="Tools Panel With Conditional Default via SlotFill"
|
|
344
|
+
resetAll={ resetAll }
|
|
345
|
+
panelId={ panelId }
|
|
346
|
+
>
|
|
347
|
+
<Slot />
|
|
348
|
+
</ToolsPanel>
|
|
349
|
+
</Panel>
|
|
350
|
+
</PanelWrapperView>
|
|
351
|
+
</SlotFillProvider>
|
|
352
|
+
);
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export const WithConditionallyRenderedControl = () => {
|
|
356
|
+
const [ attributes, setAttributes ] = useState( {} );
|
|
357
|
+
const { height, scale } = attributes;
|
|
358
|
+
|
|
359
|
+
const resetAll = ( resetFilters = [] ) => {
|
|
360
|
+
let newAttributes = {};
|
|
361
|
+
|
|
362
|
+
resetFilters.forEach( ( resetFilter ) => {
|
|
363
|
+
newAttributes = {
|
|
364
|
+
...newAttributes,
|
|
365
|
+
...resetFilter( newAttributes ),
|
|
366
|
+
};
|
|
367
|
+
} );
|
|
368
|
+
|
|
369
|
+
setAttributes( newAttributes );
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const updateAttribute = ( name, value ) => {
|
|
373
|
+
setAttributes( {
|
|
374
|
+
...attributes,
|
|
375
|
+
[ name ]: value,
|
|
376
|
+
} );
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
return (
|
|
380
|
+
<SlotFillProvider>
|
|
381
|
+
<ToolsPanelItems>
|
|
382
|
+
<SingleColumnItem
|
|
383
|
+
hasValue={ () => !! height }
|
|
384
|
+
label="Injected Height"
|
|
385
|
+
onDeselect={ () => {
|
|
386
|
+
updateAttribute( 'scale', undefined );
|
|
387
|
+
updateAttribute( 'height', undefined );
|
|
388
|
+
} }
|
|
389
|
+
resetAllFilter={ () => ( { height: undefined } ) }
|
|
390
|
+
panelId={ panelId }
|
|
391
|
+
isShownByDefault={ true }
|
|
392
|
+
>
|
|
393
|
+
<UnitControl
|
|
394
|
+
label="Injected Height"
|
|
395
|
+
value={ height }
|
|
396
|
+
onChange={ ( next ) =>
|
|
397
|
+
updateAttribute( 'height', next )
|
|
398
|
+
}
|
|
399
|
+
/>
|
|
400
|
+
</SingleColumnItem>
|
|
401
|
+
{ !! height && (
|
|
402
|
+
<ToolsPanelItem
|
|
403
|
+
hasValue={ () => !! scale }
|
|
404
|
+
label="Scale"
|
|
405
|
+
onDeselect={ () =>
|
|
406
|
+
updateAttribute( 'scale', undefined )
|
|
407
|
+
}
|
|
408
|
+
resetAllFilter={ () => ( { scale: undefined } ) }
|
|
409
|
+
panelId={ panelId }
|
|
410
|
+
isShownByDefault={ true }
|
|
411
|
+
>
|
|
412
|
+
<ToggleGroupControl
|
|
413
|
+
label="Scale"
|
|
414
|
+
value={ scale }
|
|
415
|
+
onChange={ ( next ) =>
|
|
416
|
+
updateAttribute( 'scale', next )
|
|
417
|
+
}
|
|
418
|
+
isBlock
|
|
419
|
+
>
|
|
420
|
+
<ToggleGroupControlOption
|
|
421
|
+
value="cover"
|
|
422
|
+
label="Cover"
|
|
423
|
+
/>
|
|
424
|
+
<ToggleGroupControlOption
|
|
425
|
+
value="contain"
|
|
426
|
+
label="Contain"
|
|
427
|
+
/>
|
|
428
|
+
<ToggleGroupControlOption
|
|
429
|
+
value="fill"
|
|
430
|
+
label="Fill"
|
|
431
|
+
/>
|
|
432
|
+
</ToggleGroupControl>
|
|
433
|
+
</ToolsPanelItem>
|
|
434
|
+
) }
|
|
435
|
+
</ToolsPanelItems>
|
|
436
|
+
<PanelWrapperView>
|
|
437
|
+
<Panel>
|
|
438
|
+
<ToolsPanel
|
|
439
|
+
label="Tools Panel With Conditionally Rendered Item via SlotFill"
|
|
440
|
+
resetAll={ resetAll }
|
|
441
|
+
panelId={ panelId }
|
|
442
|
+
>
|
|
443
|
+
<Slot />
|
|
444
|
+
</ToolsPanel>
|
|
445
|
+
</Panel>
|
|
446
|
+
</PanelWrapperView>
|
|
447
|
+
</SlotFillProvider>
|
|
448
|
+
);
|
|
449
|
+
};
|
|
450
|
+
|
|
218
451
|
export { TypographyPanel } from './typography-panel';
|
|
219
452
|
|
|
220
453
|
const PanelWrapperView = styled.div`
|
|
@@ -229,3 +462,7 @@ const PanelWrapperView = styled.div`
|
|
|
229
462
|
const SingleColumnItem = styled( ToolsPanelItem )`
|
|
230
463
|
grid-column: span 1;
|
|
231
464
|
`;
|
|
465
|
+
|
|
466
|
+
const IntroText = styled.div`
|
|
467
|
+
grid-column: span 2;
|
|
468
|
+
`;
|
|
@@ -8,8 +8,11 @@ import { css } from '@emotion/react';
|
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
10
|
StyledField as BaseControlField,
|
|
11
|
+
StyledHelp as BaseControlHelp,
|
|
12
|
+
StyledLabel as BaseControlLabel,
|
|
11
13
|
Wrapper as BaseControlWrapper,
|
|
12
14
|
} from '../base-control/styles/base-control-styles';
|
|
15
|
+
import { LabelWrapper } from '../input-control/styles/input-control-styles';
|
|
13
16
|
import { COLORS, CONFIG } from '../utils';
|
|
14
17
|
import { space } from '../ui/utils/space';
|
|
15
18
|
|
|
@@ -69,6 +72,7 @@ export const ToolsPanelHeader = css`
|
|
|
69
72
|
*/
|
|
70
73
|
.components-dropdown-menu {
|
|
71
74
|
margin: ${ space( -1 ) } 0;
|
|
75
|
+
line-height: 0;
|
|
72
76
|
}
|
|
73
77
|
&&&& .components-dropdown-menu__toggle {
|
|
74
78
|
padding: 0;
|
|
@@ -103,10 +107,46 @@ export const ToolsPanelItem = css`
|
|
|
103
107
|
&& ${ BaseControlWrapper } {
|
|
104
108
|
margin-bottom: 0;
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
/**
|
|
111
|
+
* To maintain proper spacing within a base control, the field's bottom
|
|
112
|
+
* margin should only be removed when there is no help text included and
|
|
113
|
+
* it is therefore the last-child.
|
|
114
|
+
*/
|
|
115
|
+
${ BaseControlField }:last-child {
|
|
107
116
|
margin-bottom: 0;
|
|
108
117
|
}
|
|
109
118
|
}
|
|
119
|
+
|
|
120
|
+
${ BaseControlHelp } {
|
|
121
|
+
margin-bottom: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Standardize InputControl and BaseControl labels with other labels when
|
|
126
|
+
* inside ToolsPanel.
|
|
127
|
+
*
|
|
128
|
+
* This is a temporary fix until the different control components have their
|
|
129
|
+
* labels normalized.
|
|
130
|
+
*/
|
|
131
|
+
&& ${ LabelWrapper } {
|
|
132
|
+
label {
|
|
133
|
+
margin-bottom: ${ space( 2 ) };
|
|
134
|
+
padding-bottom: 0;
|
|
135
|
+
line-height: 1.4em;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The targeting of .components-custom-select-control__label here is a
|
|
141
|
+
* temporary measure only.
|
|
142
|
+
*
|
|
143
|
+
* It should be replaced once CustomSelectControl component has been
|
|
144
|
+
* refactored and can be targeted via component interpolation.
|
|
145
|
+
*/
|
|
146
|
+
.components-custom-select-control__label,
|
|
147
|
+
${ BaseControlLabel } {
|
|
148
|
+
line-height: 1.4em;
|
|
149
|
+
}
|
|
110
150
|
`;
|
|
111
151
|
|
|
112
152
|
export const ToolsPanelItemPlaceholder = css`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
|
+
import { render, screen, fireEvent, within } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -168,6 +168,7 @@ const selectMenuItem = async ( label ) => {
|
|
|
168
168
|
describe( 'ToolsPanel', () => {
|
|
169
169
|
afterEach( () => {
|
|
170
170
|
controlProps.attributes.value = true;
|
|
171
|
+
altControlProps.attributes.value = false;
|
|
171
172
|
} );
|
|
172
173
|
|
|
173
174
|
describe( 'basic rendering', () => {
|
|
@@ -348,6 +349,238 @@ describe( 'ToolsPanel', () => {
|
|
|
348
349
|
// there.
|
|
349
350
|
expect( optionalItem ).not.toBeInTheDocument();
|
|
350
351
|
} );
|
|
352
|
+
|
|
353
|
+
it( 'should render default controls with conditional isShownByDefault', async () => {
|
|
354
|
+
const linkedControlProps = {
|
|
355
|
+
attributes: { value: false },
|
|
356
|
+
hasValue: jest.fn().mockImplementation( () => {
|
|
357
|
+
return !! linkedControlProps.attributes.value;
|
|
358
|
+
} ),
|
|
359
|
+
label: 'Linked',
|
|
360
|
+
onDeselect: jest.fn(),
|
|
361
|
+
onSelect: jest.fn(),
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const TestPanel = () => (
|
|
365
|
+
<ToolsPanel { ...defaultProps }>
|
|
366
|
+
<ToolsPanelItem
|
|
367
|
+
{ ...altControlProps }
|
|
368
|
+
isShownByDefault={ true }
|
|
369
|
+
>
|
|
370
|
+
<div>Default control</div>
|
|
371
|
+
</ToolsPanelItem>
|
|
372
|
+
<ToolsPanelItem
|
|
373
|
+
{ ...linkedControlProps }
|
|
374
|
+
isShownByDefault={ !! altControlProps.attributes.value }
|
|
375
|
+
>
|
|
376
|
+
<div>Linked control</div>
|
|
377
|
+
</ToolsPanelItem>
|
|
378
|
+
</ToolsPanel>
|
|
379
|
+
);
|
|
380
|
+
|
|
381
|
+
const { rerender } = render( <TestPanel /> );
|
|
382
|
+
|
|
383
|
+
// The linked control should start out as an optional control and is
|
|
384
|
+
// not rendered because it does not have a value.
|
|
385
|
+
let linkedItem = screen.queryByText( 'Linked control' );
|
|
386
|
+
expect( linkedItem ).not.toBeInTheDocument();
|
|
387
|
+
|
|
388
|
+
openDropdownMenu();
|
|
389
|
+
|
|
390
|
+
// The linked control should initially appear in the optional controls
|
|
391
|
+
// menu group. There should be three menu groups: default controls,
|
|
392
|
+
// optional controls, and the group to reset all options.
|
|
393
|
+
let menuGroups = screen.getAllByRole( 'group' );
|
|
394
|
+
expect( menuGroups.length ).toEqual( 3 );
|
|
395
|
+
|
|
396
|
+
// The linked control should be in the second group, of optional controls.
|
|
397
|
+
let optionalItem = within( menuGroups[ 1 ] ).getByText( 'Linked' );
|
|
398
|
+
expect( optionalItem ).toBeInTheDocument();
|
|
399
|
+
|
|
400
|
+
// Simulate the main control having a value set which should
|
|
401
|
+
// trigger the linked control becoming a default control via the
|
|
402
|
+
// conditional `isShownByDefault` prop.
|
|
403
|
+
altControlProps.attributes.value = true;
|
|
404
|
+
|
|
405
|
+
rerender( <TestPanel /> );
|
|
406
|
+
|
|
407
|
+
// The linked control should now be a default control and rendered
|
|
408
|
+
// despite not having a value.
|
|
409
|
+
linkedItem = screen.getByText( 'Linked control' );
|
|
410
|
+
expect( linkedItem ).toBeInTheDocument();
|
|
411
|
+
|
|
412
|
+
// The linked control should now appear in the default controls
|
|
413
|
+
// menu group and have been removed from the optional group.
|
|
414
|
+
menuGroups = screen.getAllByRole( 'group' );
|
|
415
|
+
|
|
416
|
+
// There should now only be two groups. The default controls and
|
|
417
|
+
// and the group for the reset all option.
|
|
418
|
+
expect( menuGroups.length ).toEqual( 2 );
|
|
419
|
+
|
|
420
|
+
// The new default control item for the Linked control should be
|
|
421
|
+
// within the first menu group.
|
|
422
|
+
const defaultItem = within( menuGroups[ 0 ] ).getByText( 'Linked' );
|
|
423
|
+
expect( defaultItem ).toBeInTheDocument();
|
|
424
|
+
|
|
425
|
+
// Optional controls have an additional aria-label. This can be used
|
|
426
|
+
// to confirm the conditional default control has been removed from
|
|
427
|
+
// the optional menu item group.
|
|
428
|
+
optionalItem = screen.queryByRole( 'menuitemcheckbox', {
|
|
429
|
+
name: 'Show Linked',
|
|
430
|
+
} );
|
|
431
|
+
expect( optionalItem ).not.toBeInTheDocument();
|
|
432
|
+
} );
|
|
433
|
+
|
|
434
|
+
it( 'should handle conditionally rendered default control', async () => {
|
|
435
|
+
const conditionalControlProps = {
|
|
436
|
+
attributes: { value: false },
|
|
437
|
+
hasValue: jest.fn().mockImplementation( () => {
|
|
438
|
+
return !! conditionalControlProps.attributes.value;
|
|
439
|
+
} ),
|
|
440
|
+
label: 'Conditional',
|
|
441
|
+
onDeselect: jest.fn(),
|
|
442
|
+
onSelect: jest.fn(),
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
const TestPanel = () => (
|
|
446
|
+
<ToolsPanel { ...defaultProps }>
|
|
447
|
+
<ToolsPanelItem
|
|
448
|
+
{ ...altControlProps }
|
|
449
|
+
isShownByDefault={ true }
|
|
450
|
+
>
|
|
451
|
+
<div>Default control</div>
|
|
452
|
+
</ToolsPanelItem>
|
|
453
|
+
{ !! altControlProps.attributes.value && (
|
|
454
|
+
<ToolsPanelItem
|
|
455
|
+
{ ...conditionalControlProps }
|
|
456
|
+
isShownByDefault={ true }
|
|
457
|
+
>
|
|
458
|
+
<div>Conditional control</div>
|
|
459
|
+
</ToolsPanelItem>
|
|
460
|
+
) }
|
|
461
|
+
</ToolsPanel>
|
|
462
|
+
);
|
|
463
|
+
|
|
464
|
+
const { rerender } = render( <TestPanel /> );
|
|
465
|
+
|
|
466
|
+
// The conditional control should not yet be rendered.
|
|
467
|
+
let conditionalItem = screen.queryByText( 'Conditional control' );
|
|
468
|
+
expect( conditionalItem ).not.toBeInTheDocument();
|
|
469
|
+
|
|
470
|
+
// The conditional control should not yet appear in the default controls
|
|
471
|
+
// menu group.
|
|
472
|
+
openDropdownMenu();
|
|
473
|
+
let menuGroups = screen.getAllByRole( 'group' );
|
|
474
|
+
let defaultItem = within( menuGroups[ 0 ] ).queryByText(
|
|
475
|
+
'Conditional'
|
|
476
|
+
);
|
|
477
|
+
expect( defaultItem ).not.toBeInTheDocument();
|
|
478
|
+
|
|
479
|
+
// Simulate the main control having a value set which will now
|
|
480
|
+
// render the new default control into the ToolsPanel.
|
|
481
|
+
altControlProps.attributes.value = true;
|
|
482
|
+
|
|
483
|
+
rerender( <TestPanel /> );
|
|
484
|
+
|
|
485
|
+
// The conditional control should now be rendered and included in
|
|
486
|
+
// the panel's menu.
|
|
487
|
+
conditionalItem = screen.getByText( 'Conditional control' );
|
|
488
|
+
expect( conditionalItem ).toBeInTheDocument();
|
|
489
|
+
|
|
490
|
+
// The conditional control should now appear in the default controls
|
|
491
|
+
// menu group.
|
|
492
|
+
menuGroups = screen.getAllByRole( 'group' );
|
|
493
|
+
|
|
494
|
+
// The new default control item for the Conditional control should
|
|
495
|
+
// be within the first menu group.
|
|
496
|
+
defaultItem = within( menuGroups[ 0 ] ).getByText( 'Conditional' );
|
|
497
|
+
expect( defaultItem ).toBeInTheDocument();
|
|
498
|
+
} );
|
|
499
|
+
} );
|
|
500
|
+
|
|
501
|
+
describe( 'registration of panel items', () => {
|
|
502
|
+
it( 'should register and deregister items when panelId changes', () => {
|
|
503
|
+
// This test simulates switching block selection, which causes the
|
|
504
|
+
// `ToolsPanel` to rerender with a new panelId, necessitating the
|
|
505
|
+
// registration and deregistration of appropriate `ToolsPanelItem`
|
|
506
|
+
// children.
|
|
507
|
+
//
|
|
508
|
+
// When the `panelId` changes, only items matching the new ID register
|
|
509
|
+
// themselves, while those for the old panelId deregister.
|
|
510
|
+
//
|
|
511
|
+
// See: https://github.com/WordPress/gutenberg/pull/36588
|
|
512
|
+
|
|
513
|
+
const noop = () => undefined;
|
|
514
|
+
const context = {
|
|
515
|
+
panelId: '1234',
|
|
516
|
+
menuItems: {
|
|
517
|
+
default: {},
|
|
518
|
+
optional: { [ altControlProps.label ]: true },
|
|
519
|
+
},
|
|
520
|
+
hasMenuItems: false,
|
|
521
|
+
isResetting: false,
|
|
522
|
+
shouldRenderPlaceholderItems: false,
|
|
523
|
+
registerPanelItem: jest.fn(),
|
|
524
|
+
deregisterPanelItem: jest.fn(),
|
|
525
|
+
flagItemCustomization: noop,
|
|
526
|
+
areAllOptionalControlsHidden: true,
|
|
527
|
+
};
|
|
528
|
+
|
|
529
|
+
const TestPanel = () => (
|
|
530
|
+
<ToolsPanelContext.Provider value={ context }>
|
|
531
|
+
<ToolsPanelItem { ...altControlProps } panelId="1234">
|
|
532
|
+
<div>Item</div>
|
|
533
|
+
</ToolsPanelItem>
|
|
534
|
+
</ToolsPanelContext.Provider>
|
|
535
|
+
);
|
|
536
|
+
|
|
537
|
+
// On the initial render of the panel, the ToolsPanelItem should
|
|
538
|
+
// be registered.
|
|
539
|
+
const { rerender } = render( <TestPanel /> );
|
|
540
|
+
|
|
541
|
+
expect( context.registerPanelItem ).toHaveBeenCalledWith(
|
|
542
|
+
expect.objectContaining( {
|
|
543
|
+
label: altControlProps.label,
|
|
544
|
+
panelId: '1234',
|
|
545
|
+
} )
|
|
546
|
+
);
|
|
547
|
+
expect( context.deregisterPanelItem ).not.toHaveBeenCalled();
|
|
548
|
+
|
|
549
|
+
// Simulate a change in panel, e.g. a switch of block selection.
|
|
550
|
+
context.panelId = '4321';
|
|
551
|
+
context.menuItems.optional[ altControlProps.label ] = false;
|
|
552
|
+
|
|
553
|
+
// Rerender the panel item. Because we have a new panelId, this
|
|
554
|
+
// panelItem should NOT be registered, but it SHOULD be
|
|
555
|
+
// deregistered.
|
|
556
|
+
rerender( <TestPanel /> );
|
|
557
|
+
|
|
558
|
+
// registerPanelItem has still only been called once.
|
|
559
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
560
|
+
// deregisterPanelItem is called, given that we have switched panels.
|
|
561
|
+
expect( context.deregisterPanelItem ).toBeCalledWith(
|
|
562
|
+
altControlProps.label
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
// Simulate switching back to the original panelId, e.g. by selecting
|
|
566
|
+
// the original block again.
|
|
567
|
+
context.panelId = '1234';
|
|
568
|
+
context.menuItems.optional[ altControlProps.label ] = true;
|
|
569
|
+
|
|
570
|
+
// Rerender the panel and ensure that the panelItem is registered
|
|
571
|
+
// again, and it is not de-registered.
|
|
572
|
+
rerender( <TestPanel /> );
|
|
573
|
+
|
|
574
|
+
expect( context.registerPanelItem ).toHaveBeenCalledWith(
|
|
575
|
+
expect.objectContaining( {
|
|
576
|
+
label: altControlProps.label,
|
|
577
|
+
panelId: '1234',
|
|
578
|
+
} )
|
|
579
|
+
);
|
|
580
|
+
expect( context.registerPanelItem ).toHaveBeenCalledTimes( 2 );
|
|
581
|
+
// deregisterPanelItem has still only been called once.
|
|
582
|
+
expect( context.deregisterPanelItem ).toHaveBeenCalledTimes( 1 );
|
|
583
|
+
} );
|
|
351
584
|
} );
|
|
352
585
|
|
|
353
586
|
describe( 'callbacks on menu item selection', () => {
|
|
@@ -25,6 +25,11 @@ displaying by default through the `isShownByDefault` prop. Determining whether a
|
|
|
25
25
|
child has a value is done via the `hasValue` function provided through the
|
|
26
26
|
child's props.
|
|
27
27
|
|
|
28
|
+
Components that are not wrapped within a `ToolsPanelItem` are still rendered
|
|
29
|
+
however they will not be represented within, or controlled by, the `ToolsPanel`
|
|
30
|
+
menu. An example scenario that benefits from this could be displaying
|
|
31
|
+
introduction or help text within a panel.
|
|
32
|
+
|
|
28
33
|
## Usage
|
|
29
34
|
|
|
30
35
|
```jsx
|
|
@@ -51,6 +56,10 @@ export function DimensionPanel( props ) {
|
|
|
51
56
|
|
|
52
57
|
return (
|
|
53
58
|
<ToolsPanel label={ __( 'Dimensions' ) } resetAll={ resetAll }>
|
|
59
|
+
<p>
|
|
60
|
+
Select dimensions or spacing related settings from the menu for
|
|
61
|
+
additional controls.
|
|
62
|
+
</p>
|
|
54
63
|
{ ! isPaddingDisabled && (
|
|
55
64
|
<ToolsPanelItem
|
|
56
65
|
hasValue={ () => hasPaddingValue( props ) }
|
|
@@ -24,14 +24,11 @@ const ToolsPanel = (
|
|
|
24
24
|
panelContext,
|
|
25
25
|
resetAllItems,
|
|
26
26
|
toggleItem,
|
|
27
|
-
|
|
27
|
+
...toolsPanelProps
|
|
28
28
|
} = useToolsPanel( props );
|
|
29
29
|
|
|
30
|
-
// Props are not directly passed through to avoid exposing Grid props
|
|
31
|
-
// until agreement has been reached on how ToolsPanel layout should be
|
|
32
|
-
// handled.
|
|
33
30
|
return (
|
|
34
|
-
<Grid
|
|
31
|
+
<Grid { ...toolsPanelProps } columns={ 2 } ref={ forwardedRef }>
|
|
35
32
|
<ToolsPanelContext.Provider value={ panelContext }>
|
|
36
33
|
<ToolsPanelHeader
|
|
37
34
|
label={ label }
|