@wordpress/block-editor 9.6.0 → 9.8.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 +4 -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.js +12 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/index.native.js +1 -1
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-popover/inbetween.js +5 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +10 -4
- 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-styles/index.js +3 -6
- package/build/components/block-styles/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/block-types-list/index.js +1 -1
- package/build/components/block-types-list/index.js.map +1 -1
- 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 +23 -7
- 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/utils.js +6 -2
- package/build/components/colors/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 +7 -4
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +5 -2
- package/build/components/colors-gradients/dropdown.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-appearance-control/index.js +10 -4
- package/build/components/font-appearance-control/index.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/image-size-control/index.js +3 -1
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +22 -6
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +11 -4
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/index.native.js +8 -3
- package/build/components/inserter/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/inserter-list-item/index.js +2 -19
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/line-height-control/index.js +6 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/is-url-like.js +1 -7
- package/build/components/link-control/is-url-like.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/link-control/use-search-handler.js +1 -7
- package/build/components/link-control/use-search-handler.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/expander.js +3 -1
- package/build/components/list-view/expander.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/media-upload/index.native.js +8 -3
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/preview-options/index.js +2 -2
- package/build/components/preview-options/index.js.map +1 -1
- package/build/components/{use-no-recursive-renders → recursion-provider}/index.js +40 -18
- package/build/components/recursion-provider/index.js.map +1 -0
- package/build/components/rich-text/index.js +6 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +110 -0
- package/build/components/rich-text/use-before-input-rules.js.map +1 -0
- 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 +208 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build/components/spacing-sizes-control/utils.js +202 -0
- package/build/components/spacing-sizes-control/utils.js.map +1 -0
- package/build/components/text-decoration-control/index.js +3 -1
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +3 -1
- 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/url-popover/image-url-input-ui.js +4 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +4 -25
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-drag-selection.js +9 -2
- package/build/components/writing-flow/use-drag-selection.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 +3 -1
- 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/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/gap.js +6 -4
- 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 +29 -14
- package/build/hooks/layout.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/layouts/constrained.js +215 -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 +7 -151
- 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/utils/block-variation-transforms.js +15 -9
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/pasting.js +9 -1
- package/build/utils/pasting.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.js +13 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/index.native.js +1 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +5 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +8 -4
- 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-styles/index.js +4 -7
- package/build-module/components/block-styles/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/block-types-list/index.js +1 -1
- package/build-module/components/block-types-list/index.js.map +1 -1
- 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 +24 -8
- 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/utils.js +7 -3
- package/build-module/components/colors/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 +7 -4
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +5 -2
- package/build-module/components/colors-gradients/dropdown.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-appearance-control/index.js +7 -4
- package/build-module/components/font-appearance-control/index.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/image-size-control/index.js +3 -1
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +2 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/index.native.js +9 -2
- package/build-module/components/inserter/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/inserter-list-item/index.js +1 -17
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +5 -3
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +5 -3
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/is-url-like.js +1 -6
- package/build-module/components/link-control/is-url-like.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/link-control/use-search-handler.js +1 -6
- package/build-module/components/link-control/use-search-handler.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/expander.js +3 -2
- package/build-module/components/list-view/expander.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/media-upload/index.native.js +9 -2
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/preview-options/index.js +2 -2
- package/build-module/components/preview-options/index.js.map +1 -1
- package/build-module/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -19
- package/build-module/components/recursion-provider/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +5 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +96 -0
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -0
- 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 +192 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -0
- package/build-module/components/spacing-sizes-control/utils.js +174 -0
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -0
- package/build-module/components/text-decoration-control/index.js +4 -2
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +4 -2
- 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/url-popover/image-url-input-ui.js +4 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +5 -26
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-drag-selection.js +9 -2
- package/build-module/components/writing-flow/use-drag-selection.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 +3 -1
- 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/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/gap.js +3 -2
- 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 +29 -14
- package/build-module/hooks/layout.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/layouts/constrained.js +197 -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 +8 -145
- 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-module/utils/block-variation-transforms.js +14 -7
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/pasting.js +9 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/style-rtl.css +154 -27
- package/build-style/style.css +154 -27
- 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.js +13 -2
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-popover/inbetween.js +5 -1
- package/src/components/block-popover/index.js +22 -13
- package/src/components/block-popover/style.scss +25 -2
- package/src/components/block-settings-menu/index.js +11 -15
- package/src/components/block-styles/index.js +4 -7
- package/src/components/block-styles/style.scss +10 -0
- package/src/components/block-switcher/index.js +9 -13
- package/src/components/block-switcher/test/index.js +1 -0
- 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/block-types-list/index.js +1 -1
- package/src/components/border-radius-control/all-input-control.js +41 -4
- package/src/components/border-radius-control/index.js +29 -6
- 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/color-palette/test/__snapshots__/control.js.snap +93 -77
- package/src/components/colors/utils.js +5 -2
- package/src/components/colors/with-colors.js +11 -1
- package/src/components/colors-gradients/control.js +12 -8
- package/src/components/colors-gradients/dropdown.js +7 -2
- package/src/components/colors-gradients/style.scss +27 -5
- package/src/components/colors-gradients/test/control.js +3 -3
- 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/index.js +3 -0
- 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/image-size-control/README.md +7 -0
- package/src/components/image-size-control/index.js +2 -0
- package/src/components/index.js +5 -1
- package/src/components/index.native.js +4 -1
- package/src/components/inserter/index.native.js +7 -2
- package/src/components/inserter/search-items.js +17 -5
- package/src/components/inserter-list-item/index.js +1 -17
- package/src/components/letter-spacing-control/index.js +2 -0
- package/src/components/line-height-control/index.js +2 -0
- package/src/components/link-control/is-url-like.js +1 -6
- package/src/components/link-control/link-preview.js +0 -1
- package/src/components/link-control/test/index.js +540 -893
- package/src/components/link-control/use-search-handler.js +1 -6
- package/src/components/list-view/block-select-button.js +7 -2
- package/src/components/list-view/expander.js +4 -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/media-upload/index.native.js +7 -3
- package/src/components/preview-options/index.js +2 -2
- package/src/components/{use-no-recursive-renders → recursion-provider}/index.js +39 -28
- package/src/components/{use-no-recursive-renders/test/use-no-recursive-renders.js → recursion-provider/test/index.js} +5 -6
- package/src/components/rich-text/README.md +13 -1
- package/src/components/rich-text/index.js +2 -0
- package/src/components/rich-text/index.native.js +2 -0
- package/src/components/rich-text/use-before-input-rules.js +91 -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 +280 -0
- package/src/components/spacing-sizes-control/style.scss +122 -0
- package/src/components/spacing-sizes-control/test/utils.js +156 -0
- package/src/components/spacing-sizes-control/utils.js +195 -0
- package/src/components/text-decoration-control/index.js +4 -2
- package/src/components/text-transform-control/index.js +4 -2
- package/src/components/url-input/index.js +1 -1
- package/src/components/url-input/style.scss +2 -2
- package/src/components/url-popover/image-url-input-ui.js +3 -0
- package/src/components/url-popover/style.scss +0 -3
- package/src/components/writing-flow/use-arrow-nav.js +4 -33
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-multi-selection.js +4 -1
- package/src/components/writing-flow/use-select-all.js +2 -1
- package/src/components/writing-flow/use-selection-observer.js +10 -2
- 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 +15 -0
- package/src/hooks/duotone.js +4 -4
- package/src/hooks/gap.js +7 -2
- package/src/hooks/generated-class-name.js +6 -9
- package/src/hooks/layout.js +53 -16
- 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 +22 -0
- package/src/hooks/typography.scss +0 -1
- package/src/layouts/constrained.js +217 -0
- package/src/layouts/flex.js +1 -1
- package/src/layouts/flow.js +6 -164
- 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 -0
- package/src/utils/block-variation-transforms.js +13 -6
- package/src/utils/pasting.js +10 -1
- package/src/utils/test/block-variation-transforms.js +24 -0
- package/src/utils/test/pasting.js +10 -0
- 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/components/use-no-recursive-renders/index.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/build-module/components/use-no-recursive-renders/index.js.map +0 -1
- package/src/components/block-settings-menu/block-edit-visually-button.js +0 -52
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { useCallback, useLayoutEffect, useState } from '@wordpress/element';
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs'; // By default the toolbar sets the `shift` prop. If the user scrolls the page
|
|
13
|
+
// down the toolbar will stay on screen by adopting a sticky position at the
|
|
14
|
+
// top of the viewport.
|
|
15
|
+
|
|
16
|
+
const DEFAULT_PROPS = {
|
|
17
|
+
__unstableForcePosition: true,
|
|
18
|
+
__unstableShift: true
|
|
19
|
+
}; // When there isn't enough height between the top of the block and the editor
|
|
20
|
+
// canvas, the `shift` prop is set to `false`, as it will cause the block to be
|
|
21
|
+
// obscured. The `flip` behavior is enabled (by setting `forcePosition` to
|
|
22
|
+
// `false`), which positions the toolbar below the block.
|
|
23
|
+
|
|
24
|
+
const RESTRICTED_HEIGHT_PROPS = {
|
|
25
|
+
__unstableForcePosition: false,
|
|
26
|
+
__unstableShift: false
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
|
|
30
|
+
*
|
|
31
|
+
* @param {Element} contentElement The DOM element that represents the editor content or canvas.
|
|
32
|
+
* @param {Element} selectedBlockElement The outer DOM element of the first selected block.
|
|
33
|
+
* @param {number} toolbarHeight The height of the toolbar in pixels.
|
|
34
|
+
*
|
|
35
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
function getProps(contentElement, selectedBlockElement, toolbarHeight) {
|
|
39
|
+
if (!contentElement || !selectedBlockElement) {
|
|
40
|
+
return DEFAULT_PROPS;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const blockRect = selectedBlockElement.getBoundingClientRect();
|
|
44
|
+
const contentRect = contentElement.getBoundingClientRect();
|
|
45
|
+
|
|
46
|
+
if (blockRect.top - contentRect.top > toolbarHeight) {
|
|
47
|
+
return DEFAULT_PROPS;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return RESTRICTED_HEIGHT_PROPS;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Determines the desired popover positioning behavior, returning a set of appropriate props.
|
|
54
|
+
*
|
|
55
|
+
* @param {Object} elements
|
|
56
|
+
* @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
|
|
57
|
+
* @param {string} elements.clientId The clientId of the first selected block.
|
|
58
|
+
*
|
|
59
|
+
* @return {Object} The popover props used to determine the position of the toolbar.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export default function useBlockToolbarPopoverProps(_ref) {
|
|
64
|
+
let {
|
|
65
|
+
contentElement,
|
|
66
|
+
clientId
|
|
67
|
+
} = _ref;
|
|
68
|
+
const selectedBlockElement = useBlockElement(clientId);
|
|
69
|
+
const [toolbarHeight, setToolbarHeight] = useState(0);
|
|
70
|
+
const [props, setProps] = useState(() => getProps(contentElement, selectedBlockElement, toolbarHeight));
|
|
71
|
+
const blockIndex = useSelect(select => select(blockEditorStore).getBlockIndex(clientId), [clientId]);
|
|
72
|
+
const popoverRef = useRefEffect(popoverNode => {
|
|
73
|
+
setToolbarHeight(popoverNode.offsetHeight);
|
|
74
|
+
}, []);
|
|
75
|
+
const updateProps = useCallback(() => setProps(getProps(contentElement, selectedBlockElement, toolbarHeight)), [contentElement, selectedBlockElement, toolbarHeight]); // Update props when the block is moved. This also ensures the props are
|
|
76
|
+
// correct on initial mount, and when the selected block or content element
|
|
77
|
+
// changes (since the callback ref will update).
|
|
78
|
+
|
|
79
|
+
useLayoutEffect(updateProps, [blockIndex, updateProps]); // Update props when the viewport is resized or the block is resized.
|
|
80
|
+
|
|
81
|
+
useLayoutEffect(() => {
|
|
82
|
+
var _contentElement$owner, _contentView$addEvent, _selectedBlockElement;
|
|
83
|
+
|
|
84
|
+
if (!contentElement || !selectedBlockElement) {
|
|
85
|
+
return;
|
|
86
|
+
} // Update the toolbar props on viewport resize.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
const contentView = contentElement === null || contentElement === void 0 ? void 0 : (_contentElement$owner = contentElement.ownerDocument) === null || _contentElement$owner === void 0 ? void 0 : _contentElement$owner.defaultView;
|
|
90
|
+
contentView === null || contentView === void 0 ? void 0 : (_contentView$addEvent = contentView.addEventHandler) === null || _contentView$addEvent === void 0 ? void 0 : _contentView$addEvent.call(contentView, 'resize', updateProps); // Update the toolbar props on block resize.
|
|
91
|
+
|
|
92
|
+
let resizeObserver;
|
|
93
|
+
const blockView = selectedBlockElement === null || selectedBlockElement === void 0 ? void 0 : (_selectedBlockElement = selectedBlockElement.ownerDocument) === null || _selectedBlockElement === void 0 ? void 0 : _selectedBlockElement.defaultView;
|
|
94
|
+
|
|
95
|
+
if (blockView.ResizeObserver) {
|
|
96
|
+
resizeObserver = new blockView.ResizeObserver(updateProps);
|
|
97
|
+
resizeObserver.observe(selectedBlockElement);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return () => {
|
|
101
|
+
var _contentView$removeEv;
|
|
102
|
+
|
|
103
|
+
contentView === null || contentView === void 0 ? void 0 : (_contentView$removeEv = contentView.removeEventHandler) === null || _contentView$removeEv === void 0 ? void 0 : _contentView$removeEv.call(contentView, 'resize', updateProps);
|
|
104
|
+
|
|
105
|
+
if (resizeObserver) {
|
|
106
|
+
resizeObserver.disconnect();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}, [updateProps, contentElement, selectedBlockElement]);
|
|
110
|
+
return { ...props,
|
|
111
|
+
ref: popoverRef
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=use-block-toolbar-popover-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["useRefEffect","useSelect","useCallback","useLayoutEffect","useState","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","DEFAULT_PROPS","__unstableForcePosition","__unstableShift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","top","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","ownerDocument","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,EAAsBC,eAAtB,EAAuCC,QAAvC,QAAuD,oBAAvD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D,C,CAEA;AACA;AACA;;AACA,MAAMC,aAAa,GAAG;AAAEC,EAAAA,uBAAuB,EAAE,IAA3B;AAAiCC,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CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBc,EAwBZ,CAAEV,WAAF,EAAelB,cAAf,EAA+BC,oBAA/B,CAxBY,CAAf;AA0BA,SAAO,EACN,GAAGS,KADG;AAENmB,IAAAA,GAAG,EAAEd;AAFC,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = { __unstableForcePosition: true, __unstableShift: true };\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled (by setting `forcePosition` to\n// `false`), which positions the toolbar below the block.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t__unstableForcePosition: false,\n\t__unstableShift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps( contentElement, selectedBlockElement, toolbarHeight ) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\tconst blockRect = selectedBlockElement.getBoundingClientRect();\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\tif ( blockRect.top - contentRect.top > toolbarHeight ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t);\n\tconst blockIndex = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"]}
|
|
@@ -41,7 +41,7 @@ function BlockTypesList(_ref) {
|
|
|
41
41
|
className: getBlockMenuDefaultClassName(item.id),
|
|
42
42
|
onSelect: onSelect,
|
|
43
43
|
onHover: onHover,
|
|
44
|
-
isDraggable: isDraggable,
|
|
44
|
+
isDraggable: isDraggable && !item.isDisabled,
|
|
45
45
|
isFirst: i === 0 && j === 0
|
|
46
46
|
})))), children);
|
|
47
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.js"],"names":["getBlockMenuDefaultClassName","InserterListItem","InserterListboxGroup","InserterListboxRow","chunk","array","size","chunks","i","j","length","push","slice","BlockTypesList","items","onSelect","onHover","children","label","isDraggable","map","row","item","id"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,4BAAT,QAA6C,mBAA7C;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AACA,SAASC,oBAAT,EAA+BC,kBAA/B,QAAyD,qBAAzD;;AAEA,SAASC,KAAT,CAAgBC,KAAhB,EAAuBC,IAAvB,EAA8B;AAC7B,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGJ,KAAK,CAACK,MAA3B,EAAmCF,CAAC,GAAGC,CAAvC,EAA0CD,CAAC,IAAIF,IAA/C,EAAsD;AACrDC,IAAAA,MAAM,CAACI,IAAP,CAAaN,KAAK,CAACO,KAAN,CAAaJ,CAAb,EAAgBA,CAAC,GAAGF,IAApB,CAAb;AACA;;AACD,SAAOC,MAAP;AACA;;AAED,SAASM,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,KAAK,GAAG,EADgB;AAExBC,IAAAA,QAFwB;AAGxBC,IAAAA,OAAO,GAAG,MAAM,CAAE,CAHM;AAIxBC,IAAAA,QAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA,WAAW,GAAG;AANU,GAOrB;AACH,SACC,cAAC,oBAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,kBAAaD;AAFd,KAIGd,KAAK,CAAEU,KAAF,EAAS,CAAT,CAAL,CAAkBM,GAAlB,CAAuB,CAAEC,GAAF,EAAOb,CAAP,KACxB,cAAC,kBAAD;AAAoB,IAAA,GAAG,EAAGA;AAA1B,KACGa,GAAG,CAACD,GAAJ,CAAS,CAAEE,IAAF,EAAQb,CAAR,KACV,cAAC,gBAAD;AACC,IAAA,GAAG,EAAGa,IAAI,CAACC,EADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,SAAS,EAAGtB,4BAA4B,CACvCsB,IAAI,CAACC,EADkC,CAHzC;AAMC,IAAA,QAAQ,EAAGR,QANZ;AAOC,IAAA,OAAO,EAAGC,OAPX;AAQC,IAAA,WAAW,EAAGG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-types-list/index.js"],"names":["getBlockMenuDefaultClassName","InserterListItem","InserterListboxGroup","InserterListboxRow","chunk","array","size","chunks","i","j","length","push","slice","BlockTypesList","items","onSelect","onHover","children","label","isDraggable","map","row","item","id","isDisabled"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,4BAAT,QAA6C,mBAA7C;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,uBAA7B;AACA,SAASC,oBAAT,EAA+BC,kBAA/B,QAAyD,qBAAzD;;AAEA,SAASC,KAAT,CAAgBC,KAAhB,EAAuBC,IAAvB,EAA8B;AAC7B,QAAMC,MAAM,GAAG,EAAf;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAR,EAAWC,CAAC,GAAGJ,KAAK,CAACK,MAA3B,EAAmCF,CAAC,GAAGC,CAAvC,EAA0CD,CAAC,IAAIF,IAA/C,EAAsD;AACrDC,IAAAA,MAAM,CAACI,IAAP,CAAaN,KAAK,CAACO,KAAN,CAAaJ,CAAb,EAAgBA,CAAC,GAAGF,IAApB,CAAb;AACA;;AACD,SAAOC,MAAP;AACA;;AAED,SAASM,cAAT,OAOI;AAAA,MAPqB;AACxBC,IAAAA,KAAK,GAAG,EADgB;AAExBC,IAAAA,QAFwB;AAGxBC,IAAAA,OAAO,GAAG,MAAM,CAAE,CAHM;AAIxBC,IAAAA,QAJwB;AAKxBC,IAAAA,KALwB;AAMxBC,IAAAA,WAAW,GAAG;AANU,GAOrB;AACH,SACC,cAAC,oBAAD;AACC,IAAA,SAAS,EAAC,+BADX;AAEC,kBAAaD;AAFd,KAIGd,KAAK,CAAEU,KAAF,EAAS,CAAT,CAAL,CAAkBM,GAAlB,CAAuB,CAAEC,GAAF,EAAOb,CAAP,KACxB,cAAC,kBAAD;AAAoB,IAAA,GAAG,EAAGA;AAA1B,KACGa,GAAG,CAACD,GAAJ,CAAS,CAAEE,IAAF,EAAQb,CAAR,KACV,cAAC,gBAAD;AACC,IAAA,GAAG,EAAGa,IAAI,CAACC,EADZ;AAEC,IAAA,IAAI,EAAGD,IAFR;AAGC,IAAA,SAAS,EAAGtB,4BAA4B,CACvCsB,IAAI,CAACC,EADkC,CAHzC;AAMC,IAAA,QAAQ,EAAGR,QANZ;AAOC,IAAA,OAAO,EAAGC,OAPX;AAQC,IAAA,WAAW,EAAGG,WAAW,IAAI,CAAEG,IAAI,CAACE,UARrC;AASC,IAAA,OAAO,EAAGhB,CAAC,KAAK,CAAN,IAAWC,CAAC,KAAK;AAT5B,IADC,CADH,CADC,CAJH,EAqBGQ,QArBH,CADD;AAyBA;;AAED,eAAeJ,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockMenuDefaultClassName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport InserterListItem from '../inserter-list-item';\nimport { InserterListboxGroup, InserterListboxRow } from '../inserter-listbox';\n\nfunction chunk( array, size ) {\n\tconst chunks = [];\n\tfor ( let i = 0, j = array.length; i < j; i += size ) {\n\t\tchunks.push( array.slice( i, i + size ) );\n\t}\n\treturn chunks;\n}\n\nfunction BlockTypesList( {\n\titems = [],\n\tonSelect,\n\tonHover = () => {},\n\tchildren,\n\tlabel,\n\tisDraggable = true,\n} ) {\n\treturn (\n\t\t<InserterListboxGroup\n\t\t\tclassName=\"block-editor-block-types-list\"\n\t\t\taria-label={ label }\n\t\t>\n\t\t\t{ chunk( items, 3 ).map( ( row, i ) => (\n\t\t\t\t<InserterListboxRow key={ i }>\n\t\t\t\t\t{ row.map( ( item, j ) => (\n\t\t\t\t\t\t<InserterListItem\n\t\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\t\titem={ item }\n\t\t\t\t\t\t\tclassName={ getBlockMenuDefaultClassName(\n\t\t\t\t\t\t\t\titem.id\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\t\tisDraggable={ isDraggable && ! item.isDisabled }\n\t\t\t\t\t\t\tisFirst={ i === 0 && j === 0 }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) ) }\n\t\t\t\t</InserterListboxRow>\n\t\t\t) ) }\n\t\t\t{ children }\n\t\t</InserterListboxGroup>\n\t);\n}\n\nexport default BlockTypesList;\n"]}
|
|
@@ -10,23 +10,51 @@ import { __ } from '@wordpress/i18n';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import { getAllValue, hasMixedValues, hasDefinedValues } from './utils';
|
|
13
|
+
import { getAllValue, getAllUnit, hasMixedValues, hasDefinedValues } from './utils';
|
|
14
14
|
export default function AllInputControl(_ref) {
|
|
15
15
|
let {
|
|
16
16
|
onChange,
|
|
17
|
+
selectedUnits,
|
|
18
|
+
setSelectedUnits,
|
|
17
19
|
values,
|
|
18
20
|
...props
|
|
19
21
|
} = _ref;
|
|
20
|
-
|
|
22
|
+
let allValue = getAllValue(values);
|
|
23
|
+
|
|
24
|
+
if (allValue === undefined) {
|
|
25
|
+
// If we don't have any value set the unit to any current selection
|
|
26
|
+
// or the most common unit from the individual radii values.
|
|
27
|
+
allValue = getAllUnit(selectedUnits);
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
const hasValues = hasDefinedValues(values);
|
|
22
31
|
const isMixed = hasValues && hasMixedValues(values);
|
|
23
|
-
const allPlaceholder = isMixed ? __('Mixed') : null;
|
|
32
|
+
const allPlaceholder = isMixed ? __('Mixed') : null; // Filter out CSS-unit-only values to prevent invalid styles.
|
|
33
|
+
|
|
34
|
+
const handleOnChange = next => {
|
|
35
|
+
const isNumeric = !isNaN(parseFloat(next));
|
|
36
|
+
const nextValue = isNumeric ? next : undefined;
|
|
37
|
+
onChange(nextValue);
|
|
38
|
+
}; // Store current unit selection for use as fallback for individual
|
|
39
|
+
// radii controls.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const handleOnUnitChange = unit => {
|
|
43
|
+
setSelectedUnits({
|
|
44
|
+
topLeft: unit,
|
|
45
|
+
topRight: unit,
|
|
46
|
+
bottomLeft: unit,
|
|
47
|
+
bottomRight: unit
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
24
51
|
return createElement(UnitControl, _extends({}, props, {
|
|
25
52
|
"aria-label": __('Border radius'),
|
|
26
53
|
disableUnits: isMixed,
|
|
27
54
|
isOnly: true,
|
|
28
55
|
value: allValue,
|
|
29
|
-
onChange:
|
|
56
|
+
onChange: handleOnChange,
|
|
57
|
+
onUnitChange: handleOnUnitChange,
|
|
30
58
|
placeholder: allPlaceholder
|
|
31
59
|
}));
|
|
32
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/all-input-control.js"],"names":["__experimentalUnitControl","UnitControl","__","getAllValue","hasMixedValues","hasDefinedValues","AllInputControl","onChange","values","props","allValue","hasValues","isMixed","allPlaceholder"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/all-input-control.js"],"names":["__experimentalUnitControl","UnitControl","__","getAllValue","getAllUnit","hasMixedValues","hasDefinedValues","AllInputControl","onChange","selectedUnits","setSelectedUnits","values","props","allValue","undefined","hasValues","isMixed","allPlaceholder","handleOnChange","next","isNumeric","isNaN","parseFloat","nextValue","handleOnUnitChange","unit","topLeft","topRight","bottomLeft","bottomRight"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,yBAAyB,IAAIC,WAAtC,QAAyD,uBAAzD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,SACCC,WADD,EAECC,UAFD,EAGCC,cAHD,EAICC,gBAJD,QAKO,SALP;AAOA,eAAe,SAASC,eAAT,OAMX;AAAA,MANqC;AACxCC,IAAAA,QADwC;AAExCC,IAAAA,aAFwC;AAGxCC,IAAAA,gBAHwC;AAIxCC,IAAAA,MAJwC;AAKxC,OAAGC;AALqC,GAMrC;AACH,MAAIC,QAAQ,GAAGV,WAAW,CAAEQ,MAAF,CAA1B;;AAEA,MAAKE,QAAQ,KAAKC,SAAlB,EAA8B;AAC7B;AACA;AACAD,IAAAA,QAAQ,GAAGT,UAAU,CAAEK,aAAF,CAArB;AACA;;AAED,QAAMM,SAAS,GAAGT,gBAAgB,CAAEK,MAAF,CAAlC;AACA,QAAMK,OAAO,GAAGD,SAAS,IAAIV,cAAc,CAAEM,MAAF,CAA3C;AACA,QAAMM,cAAc,GAAGD,OAAO,GAAGd,EAAE,CAAE,OAAF,CAAL,GAAmB,IAAjD,CAXG,CAaH;;AACA,QAAMgB,cAAc,GAAKC,IAAF,IAAY;AAClC,UAAMC,SAAS,GAAG,CAAEC,KAAK,CAAEC,UAAU,CAAEH,IAAF,CAAZ,CAAzB;AACA,UAAMI,SAAS,GAAGH,SAAS,GAAGD,IAAH,GAAUL,SAArC;AACAN,IAAAA,QAAQ,CAAEe,SAAF,CAAR;AACA,GAJD,CAdG,CAoBH;AACA;;;AACA,QAAMC,kBAAkB,GAAKC,IAAF,IAAY;AACtCf,IAAAA,gBAAgB,CAAE;AACjBgB,MAAAA,OAAO,EAAED,IADQ;AAEjBE,MAAAA,QAAQ,EAAEF,IAFO;AAGjBG,MAAAA,UAAU,EAAEH,IAHK;AAIjBI,MAAAA,WAAW,EAAEJ;AAJI,KAAF,CAAhB;AAMA,GAPD;;AASA,SACC,cAAC,WAAD,eACMb,KADN;AAEC,kBAAaV,EAAE,CAAE,eAAF,CAFhB;AAGC,IAAA,YAAY,EAAGc,OAHhB;AAIC,IAAA,MAAM,MAJP;AAKC,IAAA,KAAK,EAAGH,QALT;AAMC,IAAA,QAAQ,EAAGK,cANZ;AAOC,IAAA,YAAY,EAAGM,kBAPhB;AAQC,IAAA,WAAW,EAAGP;AARf,KADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalUnitControl as UnitControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetAllValue,\n\tgetAllUnit,\n\thasMixedValues,\n\thasDefinedValues,\n} from './utils';\n\nexport default function AllInputControl( {\n\tonChange,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tvalues,\n\t...props\n} ) {\n\tlet allValue = getAllValue( values );\n\n\tif ( allValue === undefined ) {\n\t\t// If we don't have any value set the unit to any current selection\n\t\t// or the most common unit from the individual radii values.\n\t\tallValue = getAllUnit( selectedUnits );\n\t}\n\n\tconst hasValues = hasDefinedValues( values );\n\tconst isMixed = hasValues && hasMixedValues( values );\n\tconst allPlaceholder = isMixed ? __( 'Mixed' ) : null;\n\n\t// Filter out CSS-unit-only values to prevent invalid styles.\n\tconst handleOnChange = ( next ) => {\n\t\tconst isNumeric = ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\t\tonChange( nextValue );\n\t};\n\n\t// Store current unit selection for use as fallback for individual\n\t// radii controls.\n\tconst handleOnUnitChange = ( unit ) => {\n\t\tsetSelectedUnits( {\n\t\t\ttopLeft: unit,\n\t\t\ttopRight: unit,\n\t\t\tbottomLeft: unit,\n\t\t\tbottomRight: unit,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<UnitControl\n\t\t\t{ ...props }\n\t\t\taria-label={ __( 'Border radius' ) }\n\t\t\tdisableUnits={ isMixed }\n\t\t\tisOnly\n\t\t\tvalue={ allValue }\n\t\t\tonChange={ handleOnChange }\n\t\t\tonUnitChange={ handleOnUnitChange }\n\t\t\tplaceholder={ allPlaceholder }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { RangeControl, __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, __experimentalUseCustomUnits as useCustomUnits } from '@wordpress/components';
|
|
6
|
+
import { BaseControl, RangeControl, __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, __experimentalUseCustomUnits as useCustomUnits } from '@wordpress/components';
|
|
7
7
|
import { useState } from '@wordpress/element';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
/**
|
|
@@ -16,10 +16,10 @@ import LinkedButton from './linked-button';
|
|
|
16
16
|
import useSetting from '../use-setting';
|
|
17
17
|
import { getAllValue, getAllUnit, hasDefinedValues, hasMixedValues } from './utils';
|
|
18
18
|
const DEFAULT_VALUES = {
|
|
19
|
-
topLeft:
|
|
20
|
-
topRight:
|
|
21
|
-
bottomLeft:
|
|
22
|
-
bottomRight:
|
|
19
|
+
topLeft: undefined,
|
|
20
|
+
topRight: undefined,
|
|
21
|
+
bottomLeft: undefined,
|
|
22
|
+
bottomRight: undefined
|
|
23
23
|
};
|
|
24
24
|
const MIN_BORDER_RADIUS_VALUE = 0;
|
|
25
25
|
const MAX_BORDER_RADIUS_VALUES = {
|
|
@@ -42,11 +42,21 @@ export default function BorderRadiusControl(_ref) {
|
|
|
42
42
|
onChange,
|
|
43
43
|
values
|
|
44
44
|
} = _ref;
|
|
45
|
-
const [isLinked, setIsLinked] = useState(!hasDefinedValues(values) || !hasMixedValues(values));
|
|
45
|
+
const [isLinked, setIsLinked] = useState(!hasDefinedValues(values) || !hasMixedValues(values)); // Tracking selected units via internal state allows filtering of CSS unit
|
|
46
|
+
// only values from being saved while maintaining preexisting unit selection
|
|
47
|
+
// behaviour. Filtering CSS unit only values prevents invalid style values.
|
|
48
|
+
|
|
49
|
+
const [selectedUnits, setSelectedUnits] = useState({
|
|
50
|
+
flat: typeof values === 'string' ? parseQuantityAndUnitFromRawValue(values)[1] : undefined,
|
|
51
|
+
topLeft: parseQuantityAndUnitFromRawValue(values === null || values === void 0 ? void 0 : values.topLeft)[1],
|
|
52
|
+
topRight: parseQuantityAndUnitFromRawValue(values === null || values === void 0 ? void 0 : values.topRight)[1],
|
|
53
|
+
bottomLeft: parseQuantityAndUnitFromRawValue(values === null || values === void 0 ? void 0 : values.bottomLeft)[1],
|
|
54
|
+
bottomRight: parseQuantityAndUnitFromRawValue(values === null || values === void 0 ? void 0 : values.bottomRight)[1]
|
|
55
|
+
});
|
|
46
56
|
const units = useCustomUnits({
|
|
47
57
|
availableUnits: useSetting('spacing.units') || ['px', 'em', 'rem']
|
|
48
58
|
});
|
|
49
|
-
const unit = getAllUnit(
|
|
59
|
+
const unit = getAllUnit(selectedUnits);
|
|
50
60
|
const unitConfig = units && units.find(item => item.value === unit);
|
|
51
61
|
const step = (unitConfig === null || unitConfig === void 0 ? void 0 : unitConfig.step) || 1;
|
|
52
62
|
const [allValue] = parseQuantityAndUnitFromRawValue(getAllValue(values));
|
|
@@ -59,13 +69,17 @@ export default function BorderRadiusControl(_ref) {
|
|
|
59
69
|
|
|
60
70
|
return createElement("fieldset", {
|
|
61
71
|
className: "components-border-radius-control"
|
|
62
|
-
}, createElement(
|
|
72
|
+
}, createElement(BaseControl.VisualLabel, {
|
|
73
|
+
as: "legend"
|
|
74
|
+
}, __('Radius')), createElement("div", {
|
|
63
75
|
className: "components-border-radius-control__wrapper"
|
|
64
76
|
}, isLinked ? createElement(Fragment, null, createElement(AllInputControl, {
|
|
65
77
|
className: "components-border-radius-control__unit-control",
|
|
66
78
|
values: values,
|
|
67
79
|
min: MIN_BORDER_RADIUS_VALUE,
|
|
68
80
|
onChange: onChange,
|
|
81
|
+
selectedUnits: selectedUnits,
|
|
82
|
+
setSelectedUnits: setSelectedUnits,
|
|
69
83
|
units: units
|
|
70
84
|
}), createElement(RangeControl, {
|
|
71
85
|
label: __('Border radius'),
|
|
@@ -81,6 +95,8 @@ export default function BorderRadiusControl(_ref) {
|
|
|
81
95
|
})) : createElement(InputControls, {
|
|
82
96
|
min: MIN_BORDER_RADIUS_VALUE,
|
|
83
97
|
onChange: onChange,
|
|
98
|
+
selectedUnits: selectedUnits,
|
|
99
|
+
setSelectedUnits: setSelectedUnits,
|
|
84
100
|
values: values || DEFAULT_VALUES,
|
|
85
101
|
units: units
|
|
86
102
|
}), createElement(LinkedButton, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/index.js"],"names":["RangeControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUseCustomUnits","useCustomUnits","useState","__","AllInputControl","InputControls","LinkedButton","useSetting","getAllValue","getAllUnit","hasDefinedValues","hasMixedValues","DEFAULT_VALUES","topLeft","topRight","bottomLeft","bottomRight","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUES","px","em","rem","BorderRadiusControl","onChange","values","isLinked","setIsLinked","units","availableUnits","unit","unitConfig","find","item","value","step","allValue","toggleLinked","handleSliderChange","next"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/index.js"],"names":["BaseControl","RangeControl","__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUseCustomUnits","useCustomUnits","useState","__","AllInputControl","InputControls","LinkedButton","useSetting","getAllValue","getAllUnit","hasDefinedValues","hasMixedValues","DEFAULT_VALUES","topLeft","undefined","topRight","bottomLeft","bottomRight","MIN_BORDER_RADIUS_VALUE","MAX_BORDER_RADIUS_VALUES","px","em","rem","BorderRadiusControl","onChange","values","isLinked","setIsLinked","selectedUnits","setSelectedUnits","flat","units","availableUnits","unit","unitConfig","find","item","value","step","allValue","toggleLinked","handleSliderChange","next"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,YAFD,EAGCC,8CAA8C,IAAIC,gCAHnD,EAICC,4BAA4B,IAAIC,cAJjC,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,SACCC,WADD,EAECC,UAFD,EAGCC,gBAHD,EAICC,cAJD,QAKO,SALP;AAOA,MAAMC,cAAc,GAAG;AACtBC,EAAAA,OAAO,EAAEC,SADa;AAEtBC,EAAAA,QAAQ,EAAED,SAFY;AAGtBE,EAAAA,UAAU,EAAEF,SAHU;AAItBG,EAAAA,WAAW,EAAEH;AAJS,CAAvB;AAMA,MAAMI,uBAAuB,GAAG,CAAhC;AACA,MAAMC,wBAAwB,GAAG;AAChCC,EAAAA,EAAE,EAAE,GAD4B;AAEhCC,EAAAA,EAAE,EAAE,EAF4B;AAGhCC,EAAAA,GAAG,EAAE;AAH2B,CAAjC;A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AAF,CAN/B;AAOC,IAAA,eAAe,EAAG,CAPnB;AAQC,IAAA,cAAc,EAAG,KARlB;AASC,IAAA,QAAQ,EAAGQ,kBATZ;AAUC,IAAA,IAAI,EAAGH;AAVR,IAVD,CADS,GAyBT,cAAC,aAAD;AACC,IAAA,GAAG,EAAGpB,uBADP;AAEC,IAAA,QAAQ,EAAGM,QAFZ;AAGC,IAAA,aAAa,EAAGI,aAHjB;AAIC,IAAA,gBAAgB,EAAGC,gBAJpB;AAKC,IAAA,MAAM,EAAGJ,MAAM,IAAIb,cALpB;AAMC,IAAA,KAAK,EAAGmB;AANT,IA1BF,EAmCC,cAAC,YAAD;AAAc,IAAA,OAAO,EAAGS,YAAxB;AAAuC,IAAA,QAAQ,EAAGd;AAAlD,IAnCD,CAJD,CADD;AA4CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBaseControl,\n\tRangeControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUseCustomUnits as useCustomUnits,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport AllInputControl from './all-input-control';\nimport InputControls from './input-controls';\nimport LinkedButton from './linked-button';\nimport useSetting from '../use-setting';\nimport {\n\tgetAllValue,\n\tgetAllUnit,\n\thasDefinedValues,\n\thasMixedValues,\n} from './utils';\n\nconst DEFAULT_VALUES = {\n\ttopLeft: undefined,\n\ttopRight: undefined,\n\tbottomLeft: undefined,\n\tbottomRight: undefined,\n};\nconst MIN_BORDER_RADIUS_VALUE = 0;\nconst MAX_BORDER_RADIUS_VALUES = {\n\tpx: 100,\n\tem: 20,\n\trem: 20,\n};\n\n/**\n * Control to display border radius options.\n *\n * @param {Object} props Component props.\n * @param {Function} props.onChange Callback to handle onChange.\n * @param {Object} props.values Border radius values.\n *\n * @return {WPElement} Custom border radius control.\n */\nexport default function BorderRadiusControl( { onChange, values } ) {\n\tconst [ isLinked, setIsLinked ] = useState(\n\t\t! hasDefinedValues( values ) || ! hasMixedValues( values )\n\t);\n\n\t// Tracking selected units via internal state allows filtering of CSS unit\n\t// only values from being saved while maintaining preexisting unit selection\n\t// behaviour. Filtering CSS unit only values prevents invalid style values.\n\tconst [ selectedUnits, setSelectedUnits ] = useState( {\n\t\tflat:\n\t\t\ttypeof values === 'string'\n\t\t\t\t? parseQuantityAndUnitFromRawValue( values )[ 1 ]\n\t\t\t\t: undefined,\n\t\ttopLeft: parseQuantityAndUnitFromRawValue( values?.topLeft )[ 1 ],\n\t\ttopRight: parseQuantityAndUnitFromRawValue( values?.topRight )[ 1 ],\n\t\tbottomLeft: parseQuantityAndUnitFromRawValue( values?.bottomLeft )[ 1 ],\n\t\tbottomRight: parseQuantityAndUnitFromRawValue(\n\t\t\tvalues?.bottomRight\n\t\t)[ 1 ],\n\t} );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [ 'px', 'em', 'rem' ],\n\t} );\n\n\tconst unit = getAllUnit( selectedUnits );\n\tconst unitConfig = units && units.find( ( item ) => item.value === unit );\n\tconst step = unitConfig?.step || 1;\n\n\tconst [ allValue ] = parseQuantityAndUnitFromRawValue(\n\t\tgetAllValue( values )\n\t);\n\n\tconst toggleLinked = () => setIsLinked( ! isLinked );\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( next !== undefined ? `${ next }${ unit }` : undefined );\n\t};\n\n\treturn (\n\t\t<fieldset className=\"components-border-radius-control\">\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Radius' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<div className=\"components-border-radius-control__wrapper\">\n\t\t\t\t{ isLinked ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<AllInputControl\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__unit-control\"\n\t\t\t\t\t\t\tvalues={ values }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Border radius' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tclassName=\"components-border-radius-control__range-control\"\n\t\t\t\t\t\t\tvalue={ allValue ?? '' }\n\t\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\t\tmax={ MAX_BORDER_RADIUS_VALUES[ unit ] }\n\t\t\t\t\t\t\tinitialPosition={ 0 }\n\t\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\t\tstep={ step }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<InputControls\n\t\t\t\t\t\tmin={ MIN_BORDER_RADIUS_VALUE }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\tselectedUnits={ selectedUnits }\n\t\t\t\t\t\tsetSelectedUnits={ setSelectedUnits }\n\t\t\t\t\t\tvalues={ values || DEFAULT_VALUES }\n\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<LinkedButton onClick={ toggleLinked } isLinked={ isLinked } />\n\t\t\t</div>\n\t\t</fieldset>\n\t);\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* WordPress dependencies
|
|
6
6
|
*/
|
|
7
|
-
import { __experimentalUnitControl as UnitControl, Tooltip } from '@wordpress/components';
|
|
7
|
+
import { __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue, __experimentalUnitControl as UnitControl, Tooltip } from '@wordpress/components';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
9
|
const CORNERS = {
|
|
10
10
|
topLeft: __('Top left'),
|
|
@@ -15,6 +15,8 @@ const CORNERS = {
|
|
|
15
15
|
export default function BoxInputControls(_ref) {
|
|
16
16
|
let {
|
|
17
17
|
onChange,
|
|
18
|
+
selectedUnits,
|
|
19
|
+
setSelectedUnits,
|
|
18
20
|
values: valuesProp,
|
|
19
21
|
...props
|
|
20
22
|
} = _ref;
|
|
@@ -22,11 +24,21 @@ export default function BoxInputControls(_ref) {
|
|
|
22
24
|
const createHandleOnChange = corner => next => {
|
|
23
25
|
if (!onChange) {
|
|
24
26
|
return;
|
|
25
|
-
}
|
|
27
|
+
} // Filter out CSS-unit-only values to prevent invalid styles.
|
|
26
28
|
|
|
29
|
+
|
|
30
|
+
const isNumeric = !isNaN(parseFloat(next));
|
|
31
|
+
const nextValue = isNumeric ? next : undefined;
|
|
27
32
|
onChange({ ...values,
|
|
28
|
-
[corner]:
|
|
33
|
+
[corner]: nextValue
|
|
29
34
|
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const createHandleOnUnitChange = side => next => {
|
|
38
|
+
const newUnits = { ...selectedUnits
|
|
39
|
+
};
|
|
40
|
+
newUnits[side] = next;
|
|
41
|
+
setSelectedUnits(newUnits);
|
|
30
42
|
}; // For shorthand style & backwards compatibility, handle flat string value.
|
|
31
43
|
|
|
32
44
|
|
|
@@ -42,17 +54,20 @@ export default function BoxInputControls(_ref) {
|
|
|
42
54
|
return createElement("div", {
|
|
43
55
|
className: "components-border-radius-control__input-controls-wrapper"
|
|
44
56
|
}, Object.entries(CORNERS).map(_ref2 => {
|
|
45
|
-
let [
|
|
57
|
+
let [corner, label] = _ref2;
|
|
58
|
+
const [parsedQuantity, parsedUnit] = parseQuantityAndUnitFromRawValue(values[corner]);
|
|
59
|
+
const computedUnit = values[corner] ? parsedUnit : selectedUnits[corner] || selectedUnits.flat;
|
|
46
60
|
return createElement(Tooltip, {
|
|
47
61
|
text: label,
|
|
48
62
|
position: "top",
|
|
49
|
-
key:
|
|
63
|
+
key: corner
|
|
50
64
|
}, createElement("div", {
|
|
51
65
|
className: "components-border-radius-control__tooltip-wrapper"
|
|
52
66
|
}, createElement(UnitControl, _extends({}, props, {
|
|
53
67
|
"aria-label": label,
|
|
54
|
-
value:
|
|
55
|
-
onChange: createHandleOnChange(
|
|
68
|
+
value: [parsedQuantity, computedUnit].join(''),
|
|
69
|
+
onChange: createHandleOnChange(corner),
|
|
70
|
+
onUnitChange: createHandleOnUnitChange(corner)
|
|
56
71
|
}))));
|
|
57
72
|
}));
|
|
58
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/input-controls.js"],"names":["__experimentalUnitControl","UnitControl","Tooltip","__","CORNERS","topLeft","topRight","bottomLeft","bottomRight","BoxInputControls","onChange","values","valuesProp","props","createHandleOnChange","corner","next","undefined","Object","entries","map","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/input-controls.js"],"names":["__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","__experimentalUnitControl","UnitControl","Tooltip","__","CORNERS","topLeft","topRight","bottomLeft","bottomRight","BoxInputControls","onChange","selectedUnits","setSelectedUnits","values","valuesProp","props","createHandleOnChange","corner","next","isNumeric","isNaN","parseFloat","nextValue","undefined","createHandleOnUnitChange","side","newUnits","Object","entries","map","label","parsedQuantity","parsedUnit","computedUnit","flat","join"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,8CAA8C,IAAIC,gCADnD,EAECC,yBAAyB,IAAIC,WAF9B,EAGCC,OAHD,QAIO,uBAJP;AAKA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,MAAMC,OAAO,GAAG;AACfC,EAAAA,OAAO,EAAEF,EAAE,CAAE,UAAF,CADI;AAEfG,EAAAA,QAAQ,EAAEH,EAAE,CAAE,WAAF,CAF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AAEZ,MAAF,EAAUa,KAAV,CAAuB;AACzD,UAAM,CAAEC,cAAF,EAAkBC,UAAlB,IACLjC,gCAAgC,CAAEc,MAAM,CAAEI,MAAF,CAAR,CADjC;AAGA,UAAMgB,YAAY,GAAGpB,MAAM,CAAEI,MAAF,CAAN,GAClBe,UADkB,GAElBrB,aAAa,CAAEM,MAAF,CAAb,IAA2BN,aAAa,CAACuB,IAF5C;AAIA,WACC,cAAC,OAAD;AAAS,MAAA,IAAI,EAAGJ,KAAhB;AAAwB,MAAA,QAAQ,EAAC,KAAjC;AAAuC,MAAA,GAAG,EAAGb;AAA7C,OACC;AAAK,MAAA,SAAS,EAAC;AAAf,OACC,cAAC,WAAD,eACMF,KADN;AAEC,oBAAae,KAFd;AAGC,MAAA,KAAK,EAAG,CAAEC,cAAF,EAAkBE,YAAlB,EAAiCE,IAAjC,CACP,EADO,CAHT;AAMC,MAAA,QAAQ,EAAGnB,oBAAoB,CAAEC,MAAF,CANhC;AAOC,MAAA,YAAY,EAAGO,wBAAwB,CACtCP,MADsC;AAPxC,OADD,CADD,CADD;AAiBA,GAzBC,CADH,CADD;AA8BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n\t__experimentalUnitControl as UnitControl,\n\tTooltip,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nconst CORNERS = {\n\ttopLeft: __( 'Top left' ),\n\ttopRight: __( 'Top right' ),\n\tbottomLeft: __( 'Bottom left' ),\n\tbottomRight: __( 'Bottom right' ),\n};\n\nexport default function BoxInputControls( {\n\tonChange,\n\tselectedUnits,\n\tsetSelectedUnits,\n\tvalues: valuesProp,\n\t...props\n} ) {\n\tconst createHandleOnChange = ( corner ) => ( next ) => {\n\t\tif ( ! onChange ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Filter out CSS-unit-only values to prevent invalid styles.\n\t\tconst isNumeric = ! isNaN( parseFloat( next ) );\n\t\tconst nextValue = isNumeric ? next : undefined;\n\n\t\tonChange( {\n\t\t\t...values,\n\t\t\t[ corner ]: nextValue,\n\t\t} );\n\t};\n\n\tconst createHandleOnUnitChange = ( side ) => ( next ) => {\n\t\tconst newUnits = { ...selectedUnits };\n\t\tnewUnits[ side ] = next;\n\t\tsetSelectedUnits( newUnits );\n\t};\n\n\t// For shorthand style & backwards compatibility, handle flat string value.\n\tconst values =\n\t\ttypeof valuesProp !== 'string'\n\t\t\t? valuesProp\n\t\t\t: {\n\t\t\t\t\ttopLeft: valuesProp,\n\t\t\t\t\ttopRight: valuesProp,\n\t\t\t\t\tbottomLeft: valuesProp,\n\t\t\t\t\tbottomRight: valuesProp,\n\t\t\t };\n\n\t// Controls are wrapped in tooltips as visible labels aren't desired here.\n\t// Tooltip rendering also requires the UnitControl to be wrapped. See:\n\t// https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026\n\treturn (\n\t\t<div className=\"components-border-radius-control__input-controls-wrapper\">\n\t\t\t{ Object.entries( CORNERS ).map( ( [ corner, label ] ) => {\n\t\t\t\tconst [ parsedQuantity, parsedUnit ] =\n\t\t\t\t\tparseQuantityAndUnitFromRawValue( values[ corner ] );\n\n\t\t\t\tconst computedUnit = values[ corner ]\n\t\t\t\t\t? parsedUnit\n\t\t\t\t\t: selectedUnits[ corner ] || selectedUnits.flat;\n\n\t\t\t\treturn (\n\t\t\t\t\t<Tooltip text={ label } position=\"top\" key={ corner }>\n\t\t\t\t\t\t<div className=\"components-border-radius-control__tooltip-wrapper\">\n\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\t\t\tvalue={ [ parsedQuantity, computedUnit ].join(\n\t\t\t\t\t\t\t\t\t''\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChange={ createHandleOnChange( corner ) }\n\t\t\t\t\t\t\t\tonUnitChange={ createHandleOnUnitChange(\n\t\t\t\t\t\t\t\t\tcorner\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -21,26 +21,23 @@ export function mode(inputArray) {
|
|
|
21
21
|
return arr.sort((a, b) => inputArray.filter(v => v === b).length - inputArray.filter(v => v === a).length).shift();
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Returns the most common CSS unit
|
|
25
|
-
* Falls back to `px` as a default unit.
|
|
24
|
+
* Returns the most common CSS unit from the current CSS unit selections.
|
|
26
25
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* - If a single flat border radius is set, its unit will be used
|
|
27
|
+
* - If individual corner selections, the most common of those will be used
|
|
28
|
+
* - Failing any unit selections a default of 'px' is returned.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} selectedUnits Unit selections for flat radius & each corner.
|
|
31
|
+
* @return {string} Most common CSS unit from current selections. Default: `px`.
|
|
29
32
|
*/
|
|
30
33
|
|
|
31
34
|
export function getAllUnit() {
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const allUnits = Object.values(values).map(value => {
|
|
40
|
-
const [, unit] = parseQuantityAndUnitFromRawValue(value);
|
|
41
|
-
return unit;
|
|
42
|
-
});
|
|
43
|
-
return mode(allUnits) || 'px';
|
|
35
|
+
let selectedUnits = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
36
|
+
const {
|
|
37
|
+
flat,
|
|
38
|
+
...cornerUnits
|
|
39
|
+
} = selectedUnits;
|
|
40
|
+
return flat || mode(Object.values(cornerUnits).filter(Boolean)) || 'px';
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
46
43
|
* Gets the 'all' input value and unit from values data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/utils.js"],"names":["__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","mode","inputArray","arr","sort","a","b","filter","v","length","shift","getAllUnit","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/border-radius-control/utils.js"],"names":["__experimentalParseQuantityAndUnitFromRawValue","parseQuantityAndUnitFromRawValue","mode","inputArray","arr","sort","a","b","filter","v","length","shift","getAllUnit","selectedUnits","flat","cornerUnits","Object","values","Boolean","getAllValue","parsedQuantitiesAndUnits","map","value","allValues","allUnits","every","unit","allValue","undefined","hasMixedValues","isMixed","isNaN","parseFloat","hasDefinedValues","filteredValues"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,8CAA8C,IAAIC,gCAA3D,QAAmG,uBAAnG;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,IAAT,CAAeC,UAAf,EAA4B;AAClC,QAAMC,GAAG,GAAG,CAAE,GAAGD,UAAL,CAAZ;AACA,SAAOC,GAAG,CACRC,IADK,CAEL,CAAEC,CAAF,EAAKC,CAAL,KACCJ,UAAU,CAACK,MAAX,CAAqBC,CAAF,IAASA,CAAC,KAAKF,CAAlC,EAAsCG,MAAtC,GACAP,UAAU,CAACK,MAAX,CAAqBC,CAAF,IAASA,CAAC,KAAKH,CAAlC,EAAsCI,MAJlC,EAMLC,KANK,EAAP;AAOA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,UAAT,GAA0C;AAAA,MAArBC,aAAqB,uEAAL,EAAK;AAChD,QAAM;AAAEC,IAAAA,IAAF;AAAQ,OAAGC;AAAX,MAA2BF,aAAjC;AACA,SACCC,IAAI,IAAIZ,IAAI,CAAEc,MAAM,CAACC,MAAP,CAAeF,WAAf,EAA6BP,MAA7B,CAAqCU,OAArC,CAAF,CAAZ,IAAkE,I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AACA;AACA;AACA;;AACA,OAAO,SAASG,gBAAT,CAA2BhB,MAA3B,EAAoC;AAC1C,MAAK,CAAEA,MAAP,EAAgB;AACf,WAAO,KAAP;AACA,GAHyC,CAK1C;;;AACA,MAAK,OAAOA,MAAP,KAAkB,QAAvB,EAAkC;AACjC,WAAO,IAAP;AACA,GARyC,CAU1C;AACA;;;AACA,QAAMiB,cAAc,GAAGlB,MAAM,CAACC,MAAP,CAAeA,MAAf,EAAwBT,MAAxB,CAAkCc,KAAF,IAAa;AACnE,WAAO,CAAC,CAAEA,KAAH,IAAYA,KAAK,KAAK,CAA7B;AACA,GAFsB,CAAvB;AAIA,SAAO,CAAC,CAAEY,cAAc,CAACxB,MAAzB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue } from '@wordpress/components';\n\n/**\n * Gets the (non-undefined) item with the highest occurrence within an array\n * Based in part on: https://stackoverflow.com/a/20762713\n *\n * Undefined values are always sorted to the end by `sort`, so this function\n * returns the first element, to always prioritize real values over undefined\n * values.\n *\n * See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#description\n *\n * @param {Array<any>} inputArray Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nexport function mode( inputArray ) {\n\tconst arr = [ ...inputArray ];\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tinputArray.filter( ( v ) => v === b ).length -\n\t\t\t\tinputArray.filter( ( v ) => v === a ).length\n\t\t)\n\t\t.shift();\n}\n\n/**\n * Returns the most common CSS unit from the current CSS unit selections.\n *\n * - If a single flat border radius is set, its unit will be used\n * - If individual corner selections, the most common of those will be used\n * - Failing any unit selections a default of 'px' is returned.\n *\n * @param {Object} selectedUnits Unit selections for flat radius & each corner.\n * @return {string} Most common CSS unit from current selections. Default: `px`.\n */\nexport function getAllUnit( selectedUnits = {} ) {\n\tconst { flat, ...cornerUnits } = selectedUnits;\n\treturn (\n\t\tflat || mode( Object.values( cornerUnits ).filter( Boolean ) ) || 'px'\n\t);\n}\n\n/**\n * Gets the 'all' input value and unit from values data.\n *\n * @param {Object|string} values Radius values.\n * @return {string} A value + unit for the 'all' input.\n */\nexport function getAllValue( values = {} ) {\n\t/**\n\t * Border radius support was originally a single pixel value.\n\t *\n\t * To maintain backwards compatibility treat this case as the all value.\n\t */\n\tif ( typeof values === 'string' ) {\n\t\treturn values;\n\t}\n\n\tconst parsedQuantitiesAndUnits = Object.values( values ).map( ( value ) =>\n\t\tparseQuantityAndUnitFromRawValue( value )\n\t);\n\n\tconst allValues = parsedQuantitiesAndUnits.map(\n\t\t( value ) => value[ 0 ] ?? ''\n\t);\n\tconst allUnits = parsedQuantitiesAndUnits.map( ( value ) => value[ 1 ] );\n\n\tconst value = allValues.every( ( v ) => v === allValues[ 0 ] )\n\t\t? allValues[ 0 ]\n\t\t: '';\n\tconst unit = mode( allUnits );\n\n\tconst allValue = value === 0 || value ? `${ value }${ unit }` : undefined;\n\n\treturn allValue;\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Radius values.\n * @return {boolean} Whether values are mixed.\n */\nexport function hasMixedValues( values = {} ) {\n\tconst allValue = getAllValue( values );\n\tconst isMixed =\n\t\ttypeof values === 'string' ? false : isNaN( parseFloat( allValue ) );\n\n\treturn isMixed;\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Radius values.\n * @return {boolean} Whether values are mixed.\n */\nexport function hasDefinedValues( values ) {\n\tif ( ! values ) {\n\t\treturn false;\n\t}\n\n\t// A string value represents a shorthand value.\n\tif ( typeof values === 'string' ) {\n\t\treturn true;\n\t}\n\n\t// An object represents longhand border radius values, if any are set\n\t// flag values as being defined.\n\tconst filteredValues = Object.values( values ).filter( ( value ) => {\n\t\treturn !! value || value === 0;\n\t} );\n\n\treturn !! filteredValues.length;\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { find, kebabCase
|
|
4
|
+
import { find, kebabCase } from 'lodash';
|
|
5
5
|
import { colord, extend } from 'colord';
|
|
6
6
|
import namesPlugin from 'colord/plugins/names';
|
|
7
7
|
import a11yPlugin from 'colord/plugins/a11y';
|
|
@@ -77,11 +77,15 @@ export function getColorClassName(colorContextName, colorSlug) {
|
|
|
77
77
|
|
|
78
78
|
export function getMostReadableColor(colors, colorValue) {
|
|
79
79
|
const colordColor = colord(colorValue);
|
|
80
|
-
|
|
80
|
+
|
|
81
|
+
const getColorContrast = _ref => {
|
|
81
82
|
let {
|
|
82
83
|
color
|
|
83
84
|
} = _ref;
|
|
84
85
|
return colordColor.contrast(color);
|
|
85
|
-
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const maxContrast = Math.max(...colors.map(getColorContrast));
|
|
89
|
+
return colors.find(color => getColorContrast(color) === maxContrast).color;
|
|
86
90
|
}
|
|
87
91
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/colors/utils.js"],"names":["find","kebabCase","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/colors/utils.js"],"names":["find","kebabCase","colord","extend","namesPlugin","a11yPlugin","getColorObjectByAttributeValues","colors","definedColor","customColor","colorObj","slug","color","getColorObjectByColorValue","colorValue","getColorClassName","colorContextName","colorSlug","undefined","getMostReadableColor","colordColor","getColorContrast","contrast","maxContrast","Math","max","map"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,SAAf,QAAgC,QAAhC;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEAF,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;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AOd,MAAM,CAACP,IAAP,CAAeY,KAAF,IAAaS,gBAAgB,CAAET,KAAF,CAAhB,KAA8BW,WAAxD,EACLX,KADF;AAEA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\n/**\n * Provided an array of color objects as set by the theme or by the editor defaults,\n * and the values of the defined color or custom color returns a color object describing the color.\n *\n * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.\n * @param {?string} definedColor A string containing the color slug.\n * @param {?string} customColor A string containing the customColor value.\n *\n * @return {?Object} If definedColor is passed and the name is found in colors,\n * the color object exactly as set by the theme or editor defaults is returned.\n * Otherwise, an object that just sets the color is defined.\n */\nexport const getColorObjectByAttributeValues = (\n\tcolors,\n\tdefinedColor,\n\tcustomColor\n) => {\n\tif ( definedColor ) {\n\t\tconst colorObj = find( colors, { slug: definedColor } );\n\n\t\tif ( colorObj ) {\n\t\t\treturn colorObj;\n\t\t}\n\t}\n\treturn {\n\t\tcolor: customColor,\n\t};\n};\n\n/**\n * Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined.\n *\n * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.\n * @param {?string} colorValue A string containing the color value.\n *\n * @return {?Object} Color object included in the colors array whose color property equals colorValue.\n * Returns undefined if no color object matches this requirement.\n */\nexport const getColorObjectByColorValue = ( colors, colorValue ) => {\n\treturn find( colors, { color: colorValue } );\n};\n\n/**\n * Returns a class based on the context a color is being used and its slug.\n *\n * @param {string} colorContextName Context/place where color is being used e.g: background, text etc...\n * @param {string} colorSlug Slug of the color.\n *\n * @return {?string} String with the class corresponding to the color in the provided context.\n * Returns undefined if either colorContextName or colorSlug are not provided.\n */\nexport function getColorClassName( colorContextName, colorSlug ) {\n\tif ( ! colorContextName || ! colorSlug ) {\n\t\treturn undefined;\n\t}\n\n\treturn `has-${ kebabCase( colorSlug ) }-${ colorContextName }`;\n}\n\n/**\n * Given an array of color objects and a color value returns the color value of the most readable color in the array.\n *\n * @param {Array} colors Array of color objects as set by the theme or by the editor defaults.\n * @param {?string} colorValue A string containing the color value.\n *\n * @return {string} String with the color value of the most readable color.\n */\nexport function getMostReadableColor( colors, colorValue ) {\n\tconst colordColor = colord( colorValue );\n\tconst getColorContrast = ( { color } ) => colordColor.contrast( color );\n\n\tconst maxContrast = Math.max( ...colors.map( getColorContrast ) );\n\treturn colors.find( ( color ) => getColorContrast( color ) === maxContrast )\n\t\t.color;\n}\n"]}
|