@wordpress/block-editor 9.7.0 → 9.8.1-next.957ca95e4c.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 +2 -0
- package/build/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-edit-visually-button/index.js +46 -0
- package/build/components/block-edit-visually-button/index.js.map +1 -0
- package/build/components/block-list/block-list-compact.native.js +73 -0
- package/build/components/block-list/block-list-compact.native.js.map +1 -0
- package/build/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-popover/inbetween.js +4 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +11 -7
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-settings-menu/index.js +2 -6
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -16
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +10 -2
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +126 -0
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build/components/border-radius-control/all-input-control.js +31 -3
- package/build/components/border-radius-control/all-input-control.js.map +1 -1
- package/build/components/border-radius-control/index.js +20 -6
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/border-radius-control/input-controls.js +21 -6
- package/build/components/border-radius-control/input-controls.js.map +1 -1
- package/build/components/border-radius-control/utils.js +13 -16
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/colors/with-colors.js +17 -4
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +1 -0
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/copy-handler/index.js +6 -0
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +2 -7
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +5 -5
- package/build/components/duotone/components.js.map +1 -1
- package/build/components/font-family/index.js +1 -1
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +17 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/index.js +9 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +6 -2
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inserter/search-items.js +22 -4
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/link-control/link-preview.js +0 -1
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/list-view/block-select-button.js +5 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -7
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/rich-text/index.js +10 -0
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +0 -4
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +8 -11
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/spacing-sizes-control/all-input-control.js +53 -0
- package/build/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js +69 -0
- package/build/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/index.js +100 -0
- package/build/components/spacing-sizes-control/index.js.map +1 -0
- package/build/components/spacing-sizes-control/input-controls.js +52 -0
- package/build/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build/components/spacing-sizes-control/linked-button.js +38 -0
- package/build/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js +213 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +233 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/text-decoration-control/index.js +28 -17
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +21 -14
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-input/index.js +1 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/writing-flow/index.js +2 -0
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +4 -2
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-select-all.js +7 -10
- package/build/components/writing-flow/use-select-all.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +10 -2
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +3 -7
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border-radius.js +2 -7
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border.js +2 -2
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +4 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +15 -0
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +4 -4
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-appearance.js +2 -1
- package/build/hooks/font-appearance.js.map +1 -1
- package/build/hooks/font-family.js +3 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +3 -1
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +25 -6
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/generated-class-name.js +1 -7
- package/build/hooks/generated-class-name.js.map +1 -1
- package/build/hooks/layout.js +23 -13
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/letter-spacing.js +2 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/line-height.js +2 -1
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/lock.js +3 -7
- package/build/hooks/lock.js.map +1 -1
- package/build/hooks/margin.js +28 -12
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -8
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/style.js +4 -50
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/text-decoration.js +2 -1
- package/build/hooks/text-decoration.js.map +1 -1
- package/build/hooks/text-transform.js +2 -1
- package/build/hooks/text-transform.js.map +1 -1
- package/build/layouts/constrained.js +225 -0
- package/build/layouts/constrained.js.map +1 -0
- package/build/layouts/flex.js +1 -1
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +18 -152
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/layouts/utils.js +43 -0
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +25 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +4 -6
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-edit-visually-button/index.js +35 -0
- package/build-module/components/block-edit-visually-button/index.js.map +1 -0
- package/build-module/components/block-list/block-list-compact.native.js +58 -0
- package/build-module/components/block-list/block-list-compact.native.js.map +1 -0
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +4 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +9 -7
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +3 -6
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -16
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +4 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +8 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +114 -0
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -0
- package/build-module/components/border-radius-control/all-input-control.js +32 -4
- package/build-module/components/border-radius-control/all-input-control.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +20 -6
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/border-radius-control/input-controls.js +22 -7
- package/build-module/components/border-radius-control/input-controls.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js +13 -16
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/colors/with-colors.js +16 -3
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +1 -0
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/copy-handler/index.js +7 -1
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +2 -6
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +5 -5
- package/build-module/components/duotone/components.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -1
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +16 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +5 -2
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inserter/search-items.js +19 -5
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +0 -1
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +5 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -6
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/rich-text/index.js +10 -0
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +0 -4
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +8 -10
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/spacing-sizes-control/all-input-control.js +41 -0
- package/build-module/components/spacing-sizes-control/all-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js +57 -0
- package/build-module/components/spacing-sizes-control/axial-input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/index.js +83 -0
- package/build-module/components/spacing-sizes-control/index.js.map +1 -0
- package/build-module/components/spacing-sizes-control/input-controls.js +41 -0
- package/build-module/components/spacing-sizes-control/input-controls.js.map +1 -0
- package/build-module/components/spacing-sizes-control/linked-button.js +28 -0
- package/build-module/components/spacing-sizes-control/linked-button.js.map +1 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +197 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +203 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +25 -18
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +19 -15
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-input/index.js +1 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +2 -0
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +4 -2
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-select-all.js +7 -10
- package/build-module/components/writing-flow/use-select-all.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +10 -2
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +4 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +3 -6
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border-radius.js +2 -7
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border.js +2 -2
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +4 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +13 -0
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -4
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-appearance.js +2 -1
- package/build-module/hooks/font-appearance.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +3 -1
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +21 -4
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/generated-class-name.js +1 -6
- package/build-module/hooks/generated-class-name.js.map +1 -1
- package/build-module/hooks/layout.js +24 -14
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +2 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/line-height.js +2 -1
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/lock.js +3 -6
- package/build-module/hooks/lock.js.map +1 -1
- package/build-module/hooks/margin.js +26 -12
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +17 -8
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/style.js +7 -53
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/text-decoration.js +2 -1
- package/build-module/hooks/text-decoration.js.map +1 -1
- package/build-module/hooks/text-transform.js +2 -1
- package/build-module/hooks/text-transform.js.map +1 -1
- package/build-module/layouts/constrained.js +207 -0
- package/build-module/layouts/constrained.js.map +1 -0
- package/build-module/layouts/flex.js +1 -1
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +20 -147
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/layouts/utils.js +40 -0
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +25 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +5 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +157 -61
- package/build-style/style.css +157 -61
- package/package.json +30 -28
- package/src/components/block-alignment-control/use-available-alignments.js +1 -1
- package/src/components/block-edit-visually-button/index.js +39 -0
- package/src/components/block-list/block-list-compact.native.js +62 -0
- package/src/components/block-list/style.scss +29 -6
- package/src/components/block-list/use-block-props/use-focus-first-element.js +1 -1
- package/src/components/block-popover/inbetween.js +4 -1
- package/src/components/block-popover/index.js +22 -15
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-toolbar/index.js +2 -0
- package/src/components/block-tools/selected-block-popover.js +7 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +123 -0
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +25 -5
- package/src/components/border-radius-control/input-controls.js +40 -13
- package/src/components/border-radius-control/test/utils.js +22 -60
- package/src/components/border-radius-control/utils.js +12 -16
- package/src/components/button-block-appender/style.scss +23 -0
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/colors-gradients/control.js +1 -0
- package/src/components/copy-handler/index.js +18 -0
- package/src/components/date-format-picker/index.js +12 -14
- package/src/components/date-format-picker/style.scss +0 -4
- package/src/components/duotone/components.js +5 -5
- package/src/components/duotone-control/style.scss +0 -4
- package/src/components/font-appearance-control/style.scss +0 -2
- package/src/components/font-family/index.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +11 -1
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/index.native.js +5 -1
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/style.scss +11 -4
- package/src/components/list-view/use-block-selection.js +2 -8
- package/src/components/media-replace-flow/style.scss +1 -0
- package/src/components/rich-text/index.js +9 -0
- package/src/components/rich-text/use-enter.js +0 -3
- package/src/components/rich-text/use-format-types.js +6 -6
- package/src/components/spacing-sizes-control/all-input-control.js +40 -0
- package/src/components/spacing-sizes-control/axial-input-controls.js +62 -0
- package/src/components/spacing-sizes-control/index.js +91 -0
- package/src/components/spacing-sizes-control/input-controls.js +46 -0
- package/src/components/spacing-sizes-control/linked-button.js +25 -0
- package/src/components/spacing-sizes-control/spacing-input-control.js +285 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +182 -0
- package/src/components/spacing-sizes-control/utils.js +222 -0
- package/src/components/text-decoration-control/index.js +41 -30
- package/src/components/text-decoration-control/stories/index.js +37 -0
- package/src/components/text-transform-control/index.js +27 -27
- package/src/components/text-transform-control/stories/index.js +37 -0
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-select-all.js +10 -13
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- package/src/hooks/align.js +2 -2
- package/src/hooks/anchor.js +1 -6
- package/src/hooks/border-radius.js +2 -6
- package/src/hooks/border.js +2 -2
- package/src/hooks/color.js +13 -3
- package/src/hooks/dimensions.js +14 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/font-appearance.js +1 -0
- package/src/hooks/font-family.js +2 -0
- package/src/hooks/font-size.js +2 -0
- package/src/hooks/gap.js +42 -19
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +47 -16
- package/src/hooks/letter-spacing.js +1 -0
- package/src/hooks/line-height.js +1 -0
- package/src/hooks/lock.js +1 -6
- package/src/hooks/margin.js +49 -17
- package/src/hooks/padding.js +41 -14
- package/src/hooks/style.js +5 -56
- package/src/hooks/test/gap.js +16 -0
- package/src/hooks/text-decoration.js +1 -0
- package/src/hooks/text-transform.js +1 -0
- package/src/hooks/typography.scss +0 -7
- package/src/layouts/constrained.js +220 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +17 -173
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/constrained.js +21 -0
- package/src/layouts/utils.js +34 -0
- package/src/store/actions.js +32 -4
- package/src/store/selectors.js +5 -4
- package/src/style.scss +1 -2
- package/build/components/block-settings-menu/block-edit-visually-button.js +0 -70
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +0 -56
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
- package/src/components/text-decoration-control/style.scss +0 -18
- package/src/components/text-transform-control/style.scss +0 -18
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
.tools-panel-item-spacing {
|
|
2
|
+
display: grid;
|
|
3
|
+
grid-template-columns: auto 1fr auto;
|
|
4
|
+
grid-row-gap: $grid-unit-05;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.component-spacing-sizes-control {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
padding-bottom: 12px;
|
|
10
|
+
width: 100%;
|
|
11
|
+
display: contents;
|
|
12
|
+
|
|
13
|
+
legend {
|
|
14
|
+
padding: 0;
|
|
15
|
+
grid-column: 1 / 1;
|
|
16
|
+
grid-row: 1 / 1;
|
|
17
|
+
align-self: center;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.components-spacing-sizes-control__side-labels {
|
|
21
|
+
grid-column: 1 / 1;
|
|
22
|
+
min-height: 30px;
|
|
23
|
+
justify-content: left;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.components-spacing-sizes-control__hint-single {
|
|
27
|
+
margin-top: 0;
|
|
28
|
+
margin-left: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.components-spacing-sizes-control__hint-single,
|
|
32
|
+
.components-spacing-sizes-control__hint-all {
|
|
33
|
+
color: $gray-700;
|
|
34
|
+
font-size: 12px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.components-spacing-sizes-control__hint-all {
|
|
38
|
+
grid-column: 2 / 2;
|
|
39
|
+
justify-self: left;
|
|
40
|
+
grid-row: 1 / 1;
|
|
41
|
+
align-self: center;
|
|
42
|
+
margin-left: $grid-unit-05;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.components-spacing-sizes-control__custom-toggle-all {
|
|
46
|
+
grid-column: 2 / 2;
|
|
47
|
+
grid-row: 1 / 1;
|
|
48
|
+
justify-self: end;
|
|
49
|
+
margin-right: $grid-unit-05;
|
|
50
|
+
padding: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.components-spacing-sizes-control__custom-toggle-single {
|
|
54
|
+
grid-column: 3 / 3;
|
|
55
|
+
justify-self: end;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.components-spacing-sizes-control__custom-toggle-all,
|
|
59
|
+
.components-spacing-sizes-control__custom-toggle-single {
|
|
60
|
+
&.is-small.has-icon {
|
|
61
|
+
padding: 0;
|
|
62
|
+
min-width: $icon-size;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.component-spacing-sizes-control__linked-button {
|
|
67
|
+
grid-column: 3 / 3;
|
|
68
|
+
grid-row: 1 / 1;
|
|
69
|
+
justify-self: end;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.components-spacing-sizes-control__custom-value-range {
|
|
73
|
+
grid-column: span 2;
|
|
74
|
+
margin-left: $grid-unit-10;
|
|
75
|
+
padding-right: $grid-unit-10;
|
|
76
|
+
height: 30px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.components-spacing-sizes-control__custom-value-input {
|
|
80
|
+
width: 124px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.components-spacing-sizes-control__range-control {
|
|
84
|
+
grid-column: span 3;
|
|
85
|
+
padding-right: $grid-unit-10;
|
|
86
|
+
height: 30px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.components-range-control__wrapper {
|
|
90
|
+
margin-bottom: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.components-range-control__mark {
|
|
94
|
+
height: $grid-unit-05;
|
|
95
|
+
width: 3px;
|
|
96
|
+
background-color: #fff;
|
|
97
|
+
z-index: 1;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.components-range-control__marks {
|
|
101
|
+
margin-top: 17px;
|
|
102
|
+
|
|
103
|
+
:first-child {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[class*="ThumbWrapper-thumbColor"] {
|
|
109
|
+
z-index: 3;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.components-spacing-sizes-control__side-label {
|
|
113
|
+
margin-right: $grid-unit-05;
|
|
114
|
+
grid-column: 1 / 1;
|
|
115
|
+
justify-self: left;
|
|
116
|
+
font-size: 12px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.components-spacing-sizes-control__custom-select-control {
|
|
120
|
+
grid-column: span 3;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
isValueSpacingPreset,
|
|
6
|
+
getCustomValueFromPreset,
|
|
7
|
+
getPresetValueFromCustomValue,
|
|
8
|
+
getSpacingPresetCssVar,
|
|
9
|
+
getSpacingPresetSlug,
|
|
10
|
+
getSliderValueFromPreset,
|
|
11
|
+
getAllRawValue,
|
|
12
|
+
isValuesMixed,
|
|
13
|
+
isValuesDefined,
|
|
14
|
+
} from '../utils';
|
|
15
|
+
|
|
16
|
+
describe( 'isValueSpacingPreset', () => {
|
|
17
|
+
it( 'should return true if value is string in spacing presets var format', () => {
|
|
18
|
+
expect( isValueSpacingPreset( 'var:preset|spacing|20' ) ).toBe( true );
|
|
19
|
+
} );
|
|
20
|
+
it( 'should return false if value is not a string in spacing presets var format', () => {
|
|
21
|
+
expect( isValueSpacingPreset( '30px' ) ).toBe( false );
|
|
22
|
+
} );
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
describe( 'getCustomValueFromPreset', () => {
|
|
26
|
+
const spacingSizes = [ { name: 'Small', slug: 20, size: '8px' } ];
|
|
27
|
+
it( 'should return original value if not a string in spacing presets var format', () => {
|
|
28
|
+
expect( getCustomValueFromPreset( '20px', spacingSizes ) ).toBe(
|
|
29
|
+
'20px'
|
|
30
|
+
);
|
|
31
|
+
} );
|
|
32
|
+
it( 'should return value from matching spacingSizes array entry if string in spacing presets var format', () => {
|
|
33
|
+
expect(
|
|
34
|
+
getCustomValueFromPreset( 'var:preset|spacing|20', spacingSizes )
|
|
35
|
+
).toBe( '8px' );
|
|
36
|
+
} );
|
|
37
|
+
it( 'should return undefined if no matching preset in spacingSizes array', () => {
|
|
38
|
+
expect(
|
|
39
|
+
getCustomValueFromPreset( 'var:preset|spacing|30', spacingSizes )
|
|
40
|
+
).toBe( undefined );
|
|
41
|
+
} );
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
describe( 'getPresetValueFromCustomValue', () => {
|
|
45
|
+
const spacingSizes = [ { name: 'Small', slug: 20, size: '8px' } ];
|
|
46
|
+
it( 'should return original value if a string in spacing presets var format', () => {
|
|
47
|
+
expect(
|
|
48
|
+
getPresetValueFromCustomValue(
|
|
49
|
+
'var:preset|spacing|80',
|
|
50
|
+
spacingSizes
|
|
51
|
+
)
|
|
52
|
+
).toBe( 'var:preset|spacing|80' );
|
|
53
|
+
} );
|
|
54
|
+
it( 'should return value constructed from matching spacingSizes array entry if value matches sizes', () => {
|
|
55
|
+
expect( getPresetValueFromCustomValue( '8px', spacingSizes ) ).toBe(
|
|
56
|
+
'var:preset|spacing|20'
|
|
57
|
+
);
|
|
58
|
+
} );
|
|
59
|
+
it( 'should return values as-is if no matching preset in spacingSizes array', () => {
|
|
60
|
+
expect(
|
|
61
|
+
getPresetValueFromCustomValue( '1.125rem', spacingSizes )
|
|
62
|
+
).toBe( '1.125rem' );
|
|
63
|
+
} );
|
|
64
|
+
} );
|
|
65
|
+
|
|
66
|
+
describe( 'getSpacingPresetCssVar', () => {
|
|
67
|
+
it( 'should return original value if not a string in spacing presets var format', () => {
|
|
68
|
+
expect( getSpacingPresetCssVar( '20px' ) ).toBe( '20px' );
|
|
69
|
+
} );
|
|
70
|
+
it( 'should return a string in spacing presets css var format with slug from provided value', () => {
|
|
71
|
+
expect( getSpacingPresetCssVar( 'var:preset|spacing|20' ) ).toBe(
|
|
72
|
+
'var(--wp--preset--spacing--20)'
|
|
73
|
+
);
|
|
74
|
+
} );
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
describe( 'getSpacingPresetSlug', () => {
|
|
78
|
+
it( 'should return original value if 0 or default', () => {
|
|
79
|
+
expect( getSpacingPresetSlug( '0' ) ).toBe( '0' );
|
|
80
|
+
expect( getSpacingPresetSlug( 'default' ) ).toBe( 'default' );
|
|
81
|
+
} );
|
|
82
|
+
it( 'should return the int value of the slug portion of a valid preset var', () => {
|
|
83
|
+
expect( getSpacingPresetSlug( 'var:preset|spacing|20' ) ).toBe( '20' );
|
|
84
|
+
} );
|
|
85
|
+
} );
|
|
86
|
+
|
|
87
|
+
describe( 'getSliderValueFromPreset', () => {
|
|
88
|
+
const spacingSizes = [
|
|
89
|
+
{ name: 'Small', slug: 20, size: '8px' },
|
|
90
|
+
{ name: 'Large', slug: 30, size: '24px' },
|
|
91
|
+
];
|
|
92
|
+
it( 'should return NaN if no matching preset found - NaN makes range control go to start', () => {
|
|
93
|
+
expect( getSliderValueFromPreset( '10px', spacingSizes ) ).toBe( NaN );
|
|
94
|
+
} );
|
|
95
|
+
it( 'should return the int value of the slug portion of a valid preset var', () => {
|
|
96
|
+
expect(
|
|
97
|
+
getSliderValueFromPreset( 'var:preset|spacing|30', spacingSizes )
|
|
98
|
+
).toBe( 1 );
|
|
99
|
+
} );
|
|
100
|
+
} );
|
|
101
|
+
|
|
102
|
+
describe( 'getAllRawValue', () => {
|
|
103
|
+
const customValues = {
|
|
104
|
+
top: '5px',
|
|
105
|
+
bottom: '5px',
|
|
106
|
+
left: '6px',
|
|
107
|
+
right: '2px',
|
|
108
|
+
};
|
|
109
|
+
it( 'should return the most common custom value from the values object', () => {
|
|
110
|
+
expect( getAllRawValue( customValues ) ).toBe( '5px' );
|
|
111
|
+
} );
|
|
112
|
+
const presetValues = {
|
|
113
|
+
top: 'var:preset|spacing|30',
|
|
114
|
+
bottom: 'var:preset|spacing|20',
|
|
115
|
+
left: 'var:preset|spacing|10',
|
|
116
|
+
right: 'var:preset|spacing|30',
|
|
117
|
+
};
|
|
118
|
+
it( 'should return the most common preset value from the values object', () => {
|
|
119
|
+
expect( getAllRawValue( presetValues ) ).toBe(
|
|
120
|
+
'var:preset|spacing|30'
|
|
121
|
+
);
|
|
122
|
+
} );
|
|
123
|
+
} );
|
|
124
|
+
|
|
125
|
+
describe( 'isValuesMixed', () => {
|
|
126
|
+
const unmixedValues = {
|
|
127
|
+
top: '5px',
|
|
128
|
+
bottom: '5px',
|
|
129
|
+
left: '5px',
|
|
130
|
+
right: '5px',
|
|
131
|
+
};
|
|
132
|
+
it( 'should return false if all values are the same', () => {
|
|
133
|
+
expect( isValuesMixed( unmixedValues ) ).toBe( false );
|
|
134
|
+
} );
|
|
135
|
+
const mixedValues = {
|
|
136
|
+
top: 'var:preset|spacing|30',
|
|
137
|
+
bottom: 'var:preset|spacing|20',
|
|
138
|
+
left: 'var:preset|spacing|10',
|
|
139
|
+
right: 'var:preset|spacing|30',
|
|
140
|
+
};
|
|
141
|
+
it( 'should return true if all the values are not the same', () => {
|
|
142
|
+
expect( isValuesMixed( mixedValues ) ).toBe( true );
|
|
143
|
+
} );
|
|
144
|
+
const singleValue = {
|
|
145
|
+
top: 'var:preset|spacing|30',
|
|
146
|
+
};
|
|
147
|
+
it( 'should return true if only one side set', () => {
|
|
148
|
+
expect( isValuesMixed( singleValue ) ).toBe( true );
|
|
149
|
+
} );
|
|
150
|
+
const incompleteValues = {
|
|
151
|
+
top: 'var:preset|spacing|30',
|
|
152
|
+
bottom: 'var:preset|spacing|30',
|
|
153
|
+
left: 'var:preset|spacing|30',
|
|
154
|
+
};
|
|
155
|
+
it( 'should return true if all sides not set', () => {
|
|
156
|
+
expect( isValuesMixed( incompleteValues ) ).toBe( true );
|
|
157
|
+
} );
|
|
158
|
+
} );
|
|
159
|
+
|
|
160
|
+
describe( 'isValuesDefined', () => {
|
|
161
|
+
const undefinedValues = {
|
|
162
|
+
top: undefined,
|
|
163
|
+
bottom: undefined,
|
|
164
|
+
left: undefined,
|
|
165
|
+
right: undefined,
|
|
166
|
+
};
|
|
167
|
+
it( 'should return false if values are not defined', () => {
|
|
168
|
+
expect( isValuesDefined( undefinedValues ) ).toBe( false );
|
|
169
|
+
} );
|
|
170
|
+
it( 'should return false if values is passed in as null', () => {
|
|
171
|
+
expect( isValuesDefined( null ) ).toBe( false );
|
|
172
|
+
} );
|
|
173
|
+
const definedValues = {
|
|
174
|
+
top: 'var:preset|spacing|30',
|
|
175
|
+
bottom: 'var:preset|spacing|20',
|
|
176
|
+
left: 'var:preset|spacing|10',
|
|
177
|
+
right: 'var:preset|spacing|30',
|
|
178
|
+
};
|
|
179
|
+
it( 'should return true if all the values are not the same', () => {
|
|
180
|
+
expect( isValuesDefined( definedValues ) ).toBe( true );
|
|
181
|
+
} );
|
|
182
|
+
} );
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { isEmpty } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Checks is given value is a spacing preset.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} value Value to check
|
|
15
|
+
*
|
|
16
|
+
* @return {boolean} Return true if value is string in format var:preset|spacing|.
|
|
17
|
+
*/
|
|
18
|
+
export function isValueSpacingPreset( value ) {
|
|
19
|
+
if ( ! value?.includes ) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return value === '0' || value.includes( 'var:preset|spacing|' );
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Converts a spacing preset into a custom value.
|
|
27
|
+
*
|
|
28
|
+
* @param {string} value Value to convert
|
|
29
|
+
* @param {Array} spacingSizes Array of the current spacing preset objects
|
|
30
|
+
*
|
|
31
|
+
* @return {string} Mapping of the spacing preset to its equivalent custom value.
|
|
32
|
+
*/
|
|
33
|
+
export function getCustomValueFromPreset( value, spacingSizes ) {
|
|
34
|
+
if ( ! isValueSpacingPreset( value ) ) {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const slug = getSpacingPresetSlug( value );
|
|
39
|
+
const spacingSize = spacingSizes.find(
|
|
40
|
+
( size ) => String( size.slug ) === slug
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return spacingSize?.size;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Converts a custom value to preset value if one can be found.
|
|
48
|
+
*
|
|
49
|
+
* Returns value as-is if no match is found.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} value Value to convert
|
|
52
|
+
* @param {Array} spacingSizes Array of the current spacing preset objects
|
|
53
|
+
*
|
|
54
|
+
* @return {string} The preset value if it can be found.
|
|
55
|
+
*/
|
|
56
|
+
export function getPresetValueFromCustomValue( value, spacingSizes ) {
|
|
57
|
+
// Return value as-is if it is already a preset;
|
|
58
|
+
if ( isValueSpacingPreset( value ) ) {
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const spacingMatch = spacingSizes.find(
|
|
63
|
+
( size ) => String( size.size ) === String( value )
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if ( spacingMatch?.slug ) {
|
|
67
|
+
return `var:preset|spacing|${ spacingMatch.slug }`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Converts a spacing preset into a custom value.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} value Value to convert.
|
|
77
|
+
*
|
|
78
|
+
* @return {string} CSS var string for given spacing preset value.
|
|
79
|
+
*/
|
|
80
|
+
export function getSpacingPresetCssVar( value ) {
|
|
81
|
+
if ( ! value ) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const slug = value.match( /var:preset\|spacing\|(.+)/ );
|
|
86
|
+
|
|
87
|
+
if ( ! slug ) {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return `var(--wp--preset--spacing--${ slug[ 1 ] })`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Returns the slug section of the given spacing preset string.
|
|
96
|
+
*
|
|
97
|
+
* @param {string} value Value to extract slug from.
|
|
98
|
+
*
|
|
99
|
+
* @return {number} The int value of the slug from given spacing preset.
|
|
100
|
+
*/
|
|
101
|
+
export function getSpacingPresetSlug( value ) {
|
|
102
|
+
if ( ! value ) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if ( value === '0' || value === 'default' ) {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const slug = value.match( /var:preset\|spacing\|(.+)/ );
|
|
111
|
+
|
|
112
|
+
return slug ? slug[ 1 ] : undefined;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Converts spacing preset value into a Range component value .
|
|
117
|
+
*
|
|
118
|
+
* @param {string} presetValue Value to convert to Range value.
|
|
119
|
+
* @param {Array} spacingSizes Array of current spacing preset value objects.
|
|
120
|
+
*
|
|
121
|
+
* @return {number} The int value for use in Range control.
|
|
122
|
+
*/
|
|
123
|
+
export function getSliderValueFromPreset( presetValue, spacingSizes ) {
|
|
124
|
+
if ( presetValue === undefined ) {
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
const slug =
|
|
128
|
+
parseFloat( presetValue, 10 ) === 0
|
|
129
|
+
? '0'
|
|
130
|
+
: getSpacingPresetSlug( presetValue );
|
|
131
|
+
const sliderValue = spacingSizes.findIndex( ( spacingSize ) => {
|
|
132
|
+
return String( spacingSize.slug ) === slug;
|
|
133
|
+
} );
|
|
134
|
+
|
|
135
|
+
// Returning NaN rather than undefined as undefined makes range control thumb sit in center
|
|
136
|
+
return sliderValue !== -1 ? sliderValue : NaN;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const LABELS = {
|
|
140
|
+
all: __( 'All sides' ),
|
|
141
|
+
top: __( 'Top' ),
|
|
142
|
+
bottom: __( 'Bottom' ),
|
|
143
|
+
left: __( 'Left' ),
|
|
144
|
+
right: __( 'Right' ),
|
|
145
|
+
mixed: __( 'Mixed' ),
|
|
146
|
+
vertical: __( 'Vertical' ),
|
|
147
|
+
horizontal: __( 'Horizontal' ),
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const DEFAULT_VALUES = {
|
|
151
|
+
top: undefined,
|
|
152
|
+
right: undefined,
|
|
153
|
+
bottom: undefined,
|
|
154
|
+
left: undefined,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
export const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Gets an items with the most occurrence within an array
|
|
161
|
+
* https://stackoverflow.com/a/20762713
|
|
162
|
+
*
|
|
163
|
+
* @param {Array<any>} arr Array of items to check.
|
|
164
|
+
* @return {any} The item with the most occurrences.
|
|
165
|
+
*/
|
|
166
|
+
function mode( arr ) {
|
|
167
|
+
return arr
|
|
168
|
+
.sort(
|
|
169
|
+
( a, b ) =>
|
|
170
|
+
arr.filter( ( v ) => v === a ).length -
|
|
171
|
+
arr.filter( ( v ) => v === b ).length
|
|
172
|
+
)
|
|
173
|
+
.pop();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Gets the 'all' input value from values data.
|
|
178
|
+
*
|
|
179
|
+
* @param {Object} values Box spacing values
|
|
180
|
+
*
|
|
181
|
+
* @return {string} The most common value from all sides of box.
|
|
182
|
+
*/
|
|
183
|
+
export function getAllRawValue( values = {} ) {
|
|
184
|
+
return mode( Object.values( values ) );
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Checks to determine if values are mixed.
|
|
189
|
+
*
|
|
190
|
+
* @param {Object} values Box values.
|
|
191
|
+
* @param {Array} sides Sides that values relate to.
|
|
192
|
+
*
|
|
193
|
+
* @return {boolean} Whether values are mixed.
|
|
194
|
+
*/
|
|
195
|
+
export function isValuesMixed( values = {}, sides = ALL_SIDES ) {
|
|
196
|
+
return (
|
|
197
|
+
( Object.values( values ).length >= 1 &&
|
|
198
|
+
Object.values( values ).length < sides.length ) ||
|
|
199
|
+
new Set( Object.values( values ) ).size > 1
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Checks to determine if values are defined.
|
|
205
|
+
*
|
|
206
|
+
* @param {Object} values Box values.
|
|
207
|
+
*
|
|
208
|
+
* @return {boolean} Whether values are defined.
|
|
209
|
+
*/
|
|
210
|
+
export function isValuesDefined( values ) {
|
|
211
|
+
if ( values === undefined || values === null ) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
return ! isEmpty(
|
|
215
|
+
Object.values( values ).filter(
|
|
216
|
+
// Switching units when input is empty causes values only
|
|
217
|
+
// containing units. This gives false positive on mixed values
|
|
218
|
+
// unless filtered.
|
|
219
|
+
( value ) => !! value && /\d/.test( value )
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
}
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
__experimentalToggleGroupControl as ToggleGroupControl,
|
|
11
|
+
__experimentalToggleGroupControlOptionIcon as ToggleGroupControlOptionIcon,
|
|
12
|
+
} from '@wordpress/components';
|
|
5
13
|
import { formatStrikethrough, formatUnderline } from '@wordpress/icons';
|
|
6
14
|
import { __ } from '@wordpress/i18n';
|
|
7
15
|
|
|
@@ -21,38 +29,41 @@ const TEXT_DECORATIONS = [
|
|
|
21
29
|
/**
|
|
22
30
|
* Control to facilitate text decoration selections.
|
|
23
31
|
*
|
|
24
|
-
* @param {Object} props
|
|
25
|
-
* @param {string} props.value
|
|
26
|
-
* @param {Function} props.onChange
|
|
32
|
+
* @param {Object} props Component props.
|
|
33
|
+
* @param {string} props.value Currently selected text decoration.
|
|
34
|
+
* @param {Function} props.onChange Handles change in text decoration selection.
|
|
35
|
+
* @param {string} [props.className] Additional class name to apply.
|
|
27
36
|
*
|
|
28
37
|
* @return {WPElement} Text decoration control.
|
|
29
38
|
*/
|
|
30
|
-
export default function TextDecorationControl( {
|
|
39
|
+
export default function TextDecorationControl( {
|
|
40
|
+
value,
|
|
41
|
+
onChange,
|
|
42
|
+
className,
|
|
43
|
+
...props
|
|
44
|
+
} ) {
|
|
31
45
|
return (
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} ) }
|
|
55
|
-
</div>
|
|
56
|
-
</fieldset>
|
|
46
|
+
<ToggleGroupControl
|
|
47
|
+
{ ...props }
|
|
48
|
+
className={ classnames(
|
|
49
|
+
'block-editor-text-decoration-control',
|
|
50
|
+
className
|
|
51
|
+
) }
|
|
52
|
+
__experimentalIsIconGroup
|
|
53
|
+
label={ __( 'Decoration' ) }
|
|
54
|
+
value={ value }
|
|
55
|
+
onChange={ onChange }
|
|
56
|
+
>
|
|
57
|
+
{ TEXT_DECORATIONS.map( ( textDecoration ) => {
|
|
58
|
+
return (
|
|
59
|
+
<ToggleGroupControlOptionIcon
|
|
60
|
+
key={ textDecoration.value }
|
|
61
|
+
value={ textDecoration.value }
|
|
62
|
+
icon={ textDecoration.icon }
|
|
63
|
+
label={ textDecoration.name }
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
} ) }
|
|
67
|
+
</ToggleGroupControl>
|
|
57
68
|
);
|
|
58
69
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import TextDecorationControl from '../';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'BlockEditor/TextDecorationControl',
|
|
13
|
+
component: TextDecorationControl,
|
|
14
|
+
argTypes: {
|
|
15
|
+
onChange: { action: 'onChange' },
|
|
16
|
+
size: {
|
|
17
|
+
options: [ 'default', '__unstable-large' ],
|
|
18
|
+
control: { type: 'radio' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const Template = ( { onChange, ...args } ) => {
|
|
24
|
+
const [ value, setValue ] = useState();
|
|
25
|
+
return (
|
|
26
|
+
<TextDecorationControl
|
|
27
|
+
{ ...args }
|
|
28
|
+
onChange={ ( ...changeArgs ) => {
|
|
29
|
+
onChange( ...changeArgs );
|
|
30
|
+
setValue( ...changeArgs );
|
|
31
|
+
} }
|
|
32
|
+
value={ value }
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const Default = Template.bind( {} );
|