@wordpress/block-editor 12.11.1 → 12.12.2-next.f8d8eceb.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 +14 -10
- package/README.md +35 -3
- package/build/components/block-alignment-control/use-available-alignments.js +30 -28
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-controls/hook.js +4 -1
- package/build/components/block-controls/hook.js.map +1 -1
- package/build/components/block-list/block-outline.native.js +1 -1
- package/build/components/block-list/block-outline.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -0
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +4 -4
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/layout.js +2 -3
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-styles/index.js +1 -2
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/border-radius-control/index.js +3 -2
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +6 -6
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/colors/with-colors.js +2 -8
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +6 -7
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -13
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/dimensions-tool/index.js +22 -22
- package/build/components/dimensions-tool/index.js.map +1 -1
- package/build/components/dimensions-tool/scale-tool.js +1 -1
- package/build/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build/components/font-family/index.js +2 -3
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +3 -5
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +3 -4
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +7 -8
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/image-settings-panel.js +2 -2
- package/build/components/global-styles/image-settings-panel.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +1 -1
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -5
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/height-control/index.js +93 -5
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +9 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/index.js +9 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +17 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inner-blocks/index.js +2 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +3 -3
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +5 -2
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-item.js +11 -0
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -1
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/link-control/use-internal-value.js +14 -8
- package/build/components/link-control/use-internal-value.js.map +1 -1
- package/build/components/link-control/use-search-handler.js +10 -5
- package/build/components/link-control/use-search-handler.js.map +1 -1
- package/build/components/list-view/index.js +6 -5
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +2 -2
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +14 -3
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-delete.js +1 -1
- package/build/components/rich-text/use-delete.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -22
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -3
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -3
- package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build/components/tool-selector/index.js +1 -2
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/unit-control/index.js +3 -3
- package/build/components/unit-control/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +96 -47
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/components/use-settings/index.js +212 -0
- package/build/components/use-settings/index.js.map +1 -0
- package/build/components/writing-flow/use-arrow-nav.js +4 -0
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/align.js +51 -35
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/anchor.js +37 -32
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +4 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-rename-ui.js +5 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/{metadata-name.js → block-renaming.js} +3 -7
- package/build/hooks/block-renaming.js.map +1 -0
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +28 -21
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +33 -8
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/font-size.js +4 -4
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +16 -17
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/line-height.js +3 -3
- package/build/hooks/line-height.js.map +1 -1
- package/build/hooks/metadata.js +6 -27
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +2 -3
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-color-props.js +3 -11
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/hooks/utils.js +2 -43
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/constrained.js +3 -3
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/grid.js +25 -3
- package/build/layouts/grid.js.map +1 -1
- package/build/layouts/utils.js +1 -1
- package/build/layouts/utils.js.map +1 -1
- package/build/lock-unlock.js +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +13 -5
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +4 -1
- package/build/utils/object.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +20 -0
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/pasting.js +1 -1
- package/build/utils/pasting.js.map +1 -1
- package/build/utils/transform-styles/index.js +19 -24
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +30 -28
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-controls/hook.js +4 -1
- package/build-module/components/block-controls/hook.js.map +1 -1
- package/build-module/components/block-list/block-outline.native.js +1 -1
- package/build-module/components/block-list/block-outline.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -0
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +4 -4
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +2 -2
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +1 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +2 -4
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -0
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +3 -2
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +6 -5
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -7
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +6 -7
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +5 -12
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/dimensions-tool/index.js +22 -22
- package/build-module/components/dimensions-tool/index.js.map +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js +1 -1
- package/build-module/components/dimensions-tool/scale-tool.js.map +1 -1
- package/build-module/components/font-family/index.js +2 -2
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +3 -4
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +3 -3
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +7 -8
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/image-settings-panel.js +2 -2
- package/build-module/components/global-styles/image-settings-panel.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +1 -1
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -4
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/height-control/index.js +93 -4
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +9 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +0 -6
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +2 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +3 -2
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +6 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-item.js +12 -1
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -1
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/link-control/use-internal-value.js +14 -9
- package/build-module/components/link-control/use-internal-value.js.map +1 -1
- package/build-module/components/link-control/use-search-handler.js +10 -5
- package/build-module/components/link-control/use-search-handler.js.map +1 -1
- package/build-module/components/list-view/index.js +7 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +3 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +2 -2
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +15 -4
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +1 -1
- package/build-module/components/rich-text/use-delete.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -22
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +6 -2
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +91 -2
- package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
- package/build-module/components/tool-selector/index.js +1 -2
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/unit-control/index.js +3 -2
- package/build-module/components/unit-control/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +95 -47
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/components/use-settings/index.js +203 -0
- package/build-module/components/use-settings/index.js.map +1 -0
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -0
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/align.js +51 -35
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/anchor.js +37 -32
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +4 -4
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +6 -6
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/{metadata-name.js → block-renaming.js} +3 -6
- package/build-module/hooks/block-renaming.js.map +1 -0
- package/build-module/hooks/color.js +2 -4
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +28 -21
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +34 -9
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -4
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +16 -17
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/line-height.js +3 -3
- package/build-module/hooks/line-height.js.map +1 -1
- package/build-module/hooks/metadata.js +6 -25
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +2 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-color-props.js +3 -11
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/hooks/utils.js +3 -44
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/constrained.js +3 -2
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/grid.js +25 -3
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/layouts/utils.js +1 -1
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/lock-unlock.js +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +14 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +3 -1
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +20 -0
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/pasting.js +1 -1
- package/build-module/utils/pasting.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +20 -24
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/style-rtl.css +24 -12
- package/build-style/style.css +24 -12
- package/package.json +36 -34
- package/src/components/block-alignment-control/use-available-alignments.js +49 -34
- package/src/components/block-controls/hook.js +6 -3
- package/src/components/block-list/block-outline.native.js +1 -1
- package/src/components/block-list/block.js +2 -0
- package/src/components/block-list/block.native.js +4 -4
- package/src/components/block-list/layout.js +2 -2
- package/src/components/block-preview/index.js +7 -1
- package/src/components/block-styles/index.js +1 -4
- package/src/components/block-styles/style.scss +1 -1
- package/src/components/block-switcher/pattern-transformations-menu.js +1 -4
- package/src/components/block-switcher/style.scss +6 -0
- package/src/components/block-tools/block-contextual-toolbar.js +1 -0
- package/src/components/block-tools/style.scss +0 -1
- package/src/components/border-radius-control/index.js +3 -2
- package/src/components/color-palette/test/__snapshots__/control.js.snap +3 -1
- package/src/components/color-palette/with-color-context.js +9 -9
- package/src/components/colors/with-colors.js +6 -7
- package/src/components/colors-gradients/control.js +10 -7
- package/src/components/colors-gradients/style.scss +4 -2
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +29 -15
- package/src/components/dimensions-tool/index.js +25 -25
- package/src/components/dimensions-tool/scale-tool.js +1 -1
- package/src/components/font-family/index.js +2 -2
- package/src/components/font-sizes/font-size-picker.js +6 -4
- package/src/components/font-sizes/with-font-sizes.js +3 -5
- package/src/components/global-styles/filters-panel.js +9 -15
- package/src/components/global-styles/image-settings-panel.js +2 -2
- package/src/components/global-styles/typography-panel.js +1 -1
- package/src/components/gradients/use-gradient.js +10 -4
- package/src/components/height-control/index.js +53 -4
- package/src/components/iframe/index.js +8 -1
- package/src/components/image-editor/aspect-ratio-dropdown.js +0 -8
- package/src/components/index.js +1 -1
- package/src/components/index.native.js +2 -1
- package/src/components/inner-blocks/index.js +2 -2
- package/src/components/inserter/style.scss +9 -1
- package/src/components/letter-spacing-control/index.js +3 -2
- package/src/components/link-control/README.md +43 -0
- package/src/components/link-control/link-preview.js +11 -5
- package/src/components/link-control/search-item.js +14 -0
- package/src/components/link-control/search-results.js +1 -0
- package/src/components/link-control/style.scss +3 -3
- package/src/components/link-control/test/index.js +19 -0
- package/src/components/link-control/use-internal-value.js +14 -10
- package/src/components/link-control/use-search-handler.js +22 -15
- package/src/components/list-view/index.js +13 -3
- package/src/components/media-replace-flow/index.js +9 -14
- package/src/components/provider/test/use-block-sync.js +1 -1
- package/src/components/provider/use-block-sync.js +2 -2
- package/src/components/rich-text/index.js +1 -1
- package/src/components/rich-text/index.native.js +19 -3
- package/src/components/rich-text/use-delete.js +1 -1
- package/src/components/rich-text/use-paste-handler.js +27 -24
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +7 -5
- package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +25 -2
- package/src/components/tool-selector/index.js +1 -1
- package/src/components/unit-control/index.js +3 -8
- package/src/components/use-block-commands/index.js +93 -47
- package/src/components/{use-setting → use-settings}/README.md +9 -10
- package/src/components/use-settings/index.js +272 -0
- package/src/components/{use-setting → use-settings}/test/index.js +47 -5
- package/src/components/writing-flow/use-arrow-nav.js +4 -0
- package/src/hooks/align.js +79 -54
- package/src/hooks/anchor.js +75 -65
- package/src/hooks/background.js +7 -9
- package/src/hooks/block-rename-ui.js +5 -14
- package/src/hooks/{metadata-name.js → block-renaming.js} +4 -7
- package/src/hooks/color.js +7 -4
- package/src/hooks/custom-class-name.js +36 -31
- package/src/hooks/duotone.js +51 -14
- package/src/hooks/font-size.js +4 -4
- package/src/hooks/index.js +1 -1
- package/src/hooks/layout.js +17 -17
- package/src/hooks/line-height.js +3 -3
- package/src/hooks/metadata.js +6 -38
- package/src/hooks/position.js +5 -3
- package/src/hooks/use-color-props.js +21 -14
- package/src/hooks/utils.js +90 -43
- package/src/layouts/constrained.js +3 -8
- package/src/layouts/grid.js +50 -2
- package/src/layouts/utils.js +2 -1
- package/src/lock-unlock.js +1 -1
- package/src/store/actions.js +25 -8
- package/src/utils/object.js +4 -1
- package/src/utils/parse-css-unit-to-px.js +20 -0
- package/src/utils/pasting.js +1 -4
- package/src/utils/test/__snapshots__/transform-styles.js.snap +103 -0
- package/src/utils/test/pasting.js +12 -19
- package/src/utils/test/transform-styles.js +217 -0
- package/src/utils/transform-styles/index.js +25 -25
- package/build/components/use-setting/index.js +0 -159
- package/build/components/use-setting/index.js.map +0 -1
- package/build/hooks/metadata-name.js.map +0 -1
- package/build/utils/transform-styles/ast/index.js +0 -21
- package/build/utils/transform-styles/ast/index.js.map +0 -1
- package/build/utils/transform-styles/ast/parse.js +0 -660
- package/build/utils/transform-styles/ast/parse.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/compiler.js +0 -52
- package/build/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/compress.js +0 -178
- package/build/utils/transform-styles/ast/stringify/compress.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/identity.js +0 -207
- package/build/utils/transform-styles/ast/stringify/identity.js.map +0 -1
- package/build/utils/transform-styles/ast/stringify/index.js +0 -36
- package/build/utils/transform-styles/ast/stringify/index.js.map +0 -1
- package/build/utils/transform-styles/transforms/url-rewrite.js +0 -130
- package/build/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
- package/build/utils/transform-styles/transforms/wrap.js +0 -59
- package/build/utils/transform-styles/transforms/wrap.js.map +0 -1
- package/build/utils/transform-styles/traverse.js +0 -37
- package/build/utils/transform-styles/traverse.js.map +0 -1
- package/build-module/components/use-setting/index.js +0 -152
- package/build-module/components/use-setting/index.js.map +0 -1
- package/build-module/hooks/metadata-name.js.map +0 -1
- package/build-module/utils/transform-styles/ast/index.js +0 -6
- package/build-module/utils/transform-styles/ast/index.js.map +0 -1
- package/build-module/utils/transform-styles/ast/parse.js +0 -654
- package/build-module/utils/transform-styles/ast/parse.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/compiler.js +0 -49
- package/build-module/utils/transform-styles/ast/stringify/compiler.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/compress.js +0 -176
- package/build-module/utils/transform-styles/ast/stringify/compress.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/identity.js +0 -206
- package/build-module/utils/transform-styles/ast/stringify/identity.js.map +0 -1
- package/build-module/utils/transform-styles/ast/stringify/index.js +0 -29
- package/build-module/utils/transform-styles/ast/stringify/index.js.map +0 -1
- package/build-module/utils/transform-styles/transforms/url-rewrite.js +0 -123
- package/build-module/utils/transform-styles/transforms/url-rewrite.js.map +0 -1
- package/build-module/utils/transform-styles/transforms/wrap.js +0 -52
- package/build-module/utils/transform-styles/transforms/wrap.js.map +0 -1
- package/build-module/utils/transform-styles/traverse.js +0 -28
- package/build-module/utils/transform-styles/traverse.js.map +0 -1
- package/src/components/use-setting/index.js +0 -213
- package/src/utils/transform-styles/ast/index.js +0 -5
- package/src/utils/transform-styles/ast/parse.js +0 -732
- package/src/utils/transform-styles/ast/stringify/compiler.js +0 -50
- package/src/utils/transform-styles/ast/stringify/compress.js +0 -238
- package/src/utils/transform-styles/ast/stringify/identity.js +0 -286
- package/src/utils/transform-styles/ast/stringify/index.js +0 -32
- package/src/utils/transform-styles/test/__snapshots__/traverse.js.snap +0 -7
- package/src/utils/transform-styles/test/traverse.js +0 -24
- package/src/utils/transform-styles/transforms/test/__snapshots__/url-rewrite.js.snap +0 -25
- package/src/utils/transform-styles/transforms/test/__snapshots__/wrap.js.snap +0 -64
- package/src/utils/transform-styles/transforms/test/url-rewrite.js +0 -39
- package/src/utils/transform-styles/transforms/test/wrap.js +0 -95
- package/src/utils/transform-styles/transforms/url-rewrite.js +0 -139
- package/src/utils/transform-styles/transforms/wrap.js +0 -56
- package/src/utils/transform-styles/traverse.js +0 -32
|
@@ -7,13 +7,14 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { useSettings } from '../use-settings';
|
|
11
11
|
export default createHigherOrderComponent(WrappedComponent => {
|
|
12
12
|
return props => {
|
|
13
|
-
const colorsFeature =
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
const [colorsFeature, enableCustomColors] = useSettings('color.palette', 'color.custom');
|
|
14
|
+
const {
|
|
15
|
+
colors = colorsFeature,
|
|
16
|
+
disableCustomColors = !enableCustomColors
|
|
17
|
+
} = props;
|
|
17
18
|
const hasColorsToChoose = colors && colors.length > 0 || !disableCustomColors;
|
|
18
19
|
return createElement(WrappedComponent, {
|
|
19
20
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createHigherOrderComponent","
|
|
1
|
+
{"version":3,"names":["createHigherOrderComponent","useSettings","WrappedComponent","props","colorsFeature","enableCustomColors","colors","disableCustomColors","hasColorsToChoose","length","createElement"],"sources":["@wordpress/block-editor/src/components/color-palette/with-color-context.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default createHigherOrderComponent( ( WrappedComponent ) => {\n\treturn ( props ) => {\n\t\tconst [ colorsFeature, enableCustomColors ] = useSettings(\n\t\t\t'color.palette',\n\t\t\t'color.custom'\n\t\t);\n\t\tconst {\n\t\t\tcolors = colorsFeature,\n\t\t\tdisableCustomColors = ! enableCustomColors,\n\t\t} = props;\n\t\tconst hasColorsToChoose =\n\t\t\t( colors && colors.length > 0 ) || ! disableCustomColors;\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\t{ ...{\n\t\t\t\t\t...props,\n\t\t\t\t\tcolors,\n\t\t\t\t\tdisableCustomColors,\n\t\t\t\t\thasColorsToChoose,\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t};\n}, 'withColorContext' );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,0BAA0B,QAAQ,oBAAoB;;AAE/D;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,eAAeD,0BAA0B,CAAIE,gBAAgB,IAAM;EAClE,OAASC,KAAK,IAAM;IACnB,MAAM,CAAEC,aAAa,EAAEC,kBAAkB,CAAE,GAAGJ,WAAW,CACxD,eAAe,EACf,cACD,CAAC;IACD,MAAM;MACLK,MAAM,GAAGF,aAAa;MACtBG,mBAAmB,GAAG,CAAEF;IACzB,CAAC,GAAGF,KAAK;IACT,MAAMK,iBAAiB,GACpBF,MAAM,IAAIA,MAAM,CAACG,MAAM,GAAG,CAAC,IAAM,CAAEF,mBAAmB;IACzD,OACCG,aAAA,CAACR,gBAAgB;MAEf,GAAGC,KAAK;MACRG,MAAM;MACNC,mBAAmB;MACnBC;IAAiB,CAElB,CAAC;EAEJ,CAAC;AACF,CAAC,EAAE,kBAAmB,CAAC"}
|
|
@@ -9,7 +9,7 @@ import { compose, createHigherOrderComponent } from '@wordpress/compose';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { getColorClassName, getColorObjectByColorValue, getColorObjectByAttributeValues, getMostReadableColor } from './utils';
|
|
12
|
-
import
|
|
12
|
+
import { useSettings } from '../use-settings';
|
|
13
13
|
import { kebabCase } from '../../utils/object';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -41,12 +41,7 @@ const withCustomColorPalette = colorsArray => createHigherOrderComponent(Wrapped
|
|
|
41
41
|
* @return {Function} The higher order component.
|
|
42
42
|
*/
|
|
43
43
|
const withEditorColorPalette = () => createHigherOrderComponent(WrappedComponent => props => {
|
|
44
|
-
|
|
45
|
-
// so we can't unwrap them by doing const { ... } = useSetting('color')
|
|
46
|
-
// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.
|
|
47
|
-
const userPalette = useSetting('color.palette.custom');
|
|
48
|
-
const themePalette = useSetting('color.palette.theme');
|
|
49
|
-
const defaultPalette = useSetting('color.palette.default');
|
|
44
|
+
const [userPalette, themePalette, defaultPalette] = useSettings('color.palette.custom', 'color.palette.theme', 'color.palette.default');
|
|
50
45
|
const allColors = useMemo(() => [...(userPalette || []), ...(themePalette || []), ...(defaultPalette || [])], [userPalette, themePalette, defaultPalette]);
|
|
51
46
|
return createElement(WrappedComponent, {
|
|
52
47
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSetting","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport useSetting from '../use-setting';\nimport { kebabCase } from '../../utils/object';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => (\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />\n\t\t),\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\t// Some color settings have a special handling for deprecated flags in `useSetting`,\n\t\t\t// so we can't unwrap them by doing const { ... } = useSetting('color')\n\t\t\t// until https://github.com/WordPress/gutenberg/issues/37094 is fixed.\n\t\t\tconst userPalette = useSetting( 'color.palette.custom' );\n\t\t\tconst themePalette = useSetting( 'color.palette.theme' );\n\t\t\tconst defaultPalette = useSetting( 'color.palette.default' );\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {Component} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = colorTypes.reduce( ( colorObject, colorType ) => {\n\t\treturn {\n\t\t\t...colorObject,\n\t\t\t...( typeof colorType === 'string'\n\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t: colorType ),\n\t\t};\n\t}, {} );\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn Object.keys( colorMap ).reduce(\n\t\t\t\t\t\t( settersAccumulator, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn Object.entries( colorMap ).reduce(\n\t\t\t\t\t\t( newState, [ colorAttributeName, colorContext ] ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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);\n\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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}\n\t\t\t\t\t\t\treturn newState;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t] );\n}\n\n/**\n * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAAEC,0BAA0B,QAAQ,oBAAoB;;AAExE;AACA;AACA;AACA,SACCC,iBAAiB,EACjBC,0BAA0B,EAC1BC,+BAA+B,EAC/BC,oBAAoB,QACd,SAAS;AAChB,O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AAC,CACF,CAAC;MACF;MAEAM,MAAMA,CAAA,EAAG;QACR,OACCzC,aAAA,CAACF,gBAAgB;UAEf,GAAG,IAAI,CAACC,KAAK;UACbE,MAAM,EAAE6B,SAAS;UACjB,GAAG,IAAI,CAACX,KAAK;UACb,GAAG,IAAI,CAACJ,OAAO;UACfE,UAAU,EAAE,IAAI,CAACA;QAAU,CAE5B,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,CACA,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,qBAAqBA,CAAE7C,WAAW,EAAG;EACpD,OAAO,CAAE,GAAGW,UAAU,KAAM;IAC3B,MAAMC,gBAAgB,GAAGb,sBAAsB,CAAEC,WAAY,CAAC;IAC9D,OAAOb,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,kBACD,CAAC;EACF,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASkC,UAAUA,CAAE,GAAGnC,UAAU,EAAG;EACnD,MAAMC,gBAAgB,GAAGP,sBAAsB,CAAC,CAAC;EACjD,OAAOlB,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
|
|
1
|
+
{"version":3,"names":["useMemo","Component","compose","createHigherOrderComponent","getColorClassName","getColorObjectByColorValue","getColorObjectByAttributeValues","getMostReadableColor","useSettings","kebabCase","upperFirst","firstLetter","rest","toUpperCase","join","withCustomColorPalette","colorsArray","WrappedComponent","props","createElement","colors","withEditorColorPalette","userPalette","themePalette","defaultPalette","allColors","createColorHOC","colorTypes","withColorPalette","colorMap","reduce","colorObject","colorType","constructor","setters","createSetters","colorUtils","bind","state","colorValue","Object","keys","settersAccumulator","colorAttributeName","upperFirstColorAttributeName","customColorAttributeName","createSetColor","setAttributes","slug","undefined","getDerivedStateFromProps","attributes","previousState","entries","newState","colorContext","previousColorObject","previousColor","color","class","render","createCustomColorsHOC","withColors"],"sources":["@wordpress/block-editor/src/components/colors/with-colors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, Component } from '@wordpress/element';\nimport { compose, createHigherOrderComponent } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tgetColorClassName,\n\tgetColorObjectByColorValue,\n\tgetColorObjectByAttributeValues,\n\tgetMostReadableColor,\n} from './utils';\nimport { useSettings } from '../use-settings';\nimport { kebabCase } from '../../utils/object';\n\n/**\n * Capitalizes the first letter in a string.\n *\n * @param {string} str The string whose first letter the function will capitalize.\n *\n * @return {string} Capitalized string.\n */\nconst upperFirst = ( [ firstLetter, ...rest ] ) =>\n\tfirstLetter.toUpperCase() + rest.join( '' );\n\n/**\n * Higher order component factory for injecting the `colorsArray` argument as\n * the colors prop in the `withCustomColors` HOC.\n *\n * @param {Array} colorsArray An array of color objects.\n *\n * @return {Function} The higher order component.\n */\nconst withCustomColorPalette = ( colorsArray ) =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => (\n\t\t\t<WrappedComponent { ...props } colors={ colorsArray } />\n\t\t),\n\t\t'withCustomColorPalette'\n\t);\n\n/**\n * Higher order component factory for injecting the editor colors as the\n * `colors` prop in the `withColors` HOC.\n *\n * @return {Function} The higher order component.\n */\nconst withEditorColorPalette = () =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\tconst [ userPalette, themePalette, defaultPalette ] = useSettings(\n\t\t\t\t'color.palette.custom',\n\t\t\t\t'color.palette.theme',\n\t\t\t\t'color.palette.default'\n\t\t\t);\n\t\t\tconst allColors = useMemo(\n\t\t\t\t() => [\n\t\t\t\t\t...( userPalette || [] ),\n\t\t\t\t\t...( themePalette || [] ),\n\t\t\t\t\t...( defaultPalette || [] ),\n\t\t\t\t],\n\t\t\t\t[ userPalette, themePalette, defaultPalette ]\n\t\t\t);\n\t\t\treturn <WrappedComponent { ...props } colors={ allColors } />;\n\t\t},\n\t\t'withEditorColorPalette'\n\t);\n\n/**\n * Helper function used with `createHigherOrderComponent` to create\n * higher order components for managing color logic.\n *\n * @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).\n * @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.\n *\n * @return {Component} The component that can be used as a HOC.\n */\nfunction createColorHOC( colorTypes, withColorPalette ) {\n\tconst colorMap = colorTypes.reduce( ( colorObject, colorType ) => {\n\t\treturn {\n\t\t\t...colorObject,\n\t\t\t...( typeof colorType === 'string'\n\t\t\t\t? { [ colorType ]: kebabCase( colorType ) }\n\t\t\t\t: colorType ),\n\t\t};\n\t}, {} );\n\n\treturn compose( [\n\t\twithColorPalette,\n\t\t( WrappedComponent ) => {\n\t\t\treturn class extends Component {\n\t\t\t\tconstructor( props ) {\n\t\t\t\t\tsuper( props );\n\n\t\t\t\t\tthis.setters = this.createSetters();\n\t\t\t\t\tthis.colorUtils = {\n\t\t\t\t\t\tgetMostReadableColor:\n\t\t\t\t\t\t\tthis.getMostReadableColor.bind( this ),\n\t\t\t\t\t};\n\n\t\t\t\t\tthis.state = {};\n\t\t\t\t}\n\n\t\t\t\tgetMostReadableColor( colorValue ) {\n\t\t\t\t\tconst { colors } = this.props;\n\t\t\t\t\treturn getMostReadableColor( colors, colorValue );\n\t\t\t\t}\n\n\t\t\t\tcreateSetters() {\n\t\t\t\t\treturn Object.keys( colorMap ).reduce(\n\t\t\t\t\t\t( settersAccumulator, colorAttributeName ) => {\n\t\t\t\t\t\t\tconst upperFirstColorAttributeName =\n\t\t\t\t\t\t\t\tupperFirst( colorAttributeName );\n\t\t\t\t\t\t\tconst customColorAttributeName = `custom${ upperFirstColorAttributeName }`;\n\t\t\t\t\t\t\tsettersAccumulator[\n\t\t\t\t\t\t\t\t`set${ upperFirstColorAttributeName }`\n\t\t\t\t\t\t\t] = this.createSetColor(\n\t\t\t\t\t\t\t\tcolorAttributeName,\n\t\t\t\t\t\t\t\tcustomColorAttributeName\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn settersAccumulator;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tcreateSetColor( colorAttributeName, customColorAttributeName ) {\n\t\t\t\t\treturn ( colorValue ) => {\n\t\t\t\t\t\tconst colorObject = getColorObjectByColorValue(\n\t\t\t\t\t\t\tthis.props.colors,\n\t\t\t\t\t\t\tcolorValue\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.props.setAttributes( {\n\t\t\t\t\t\t\t[ colorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? colorObject.slug\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\t[ customColorAttributeName ]:\n\t\t\t\t\t\t\t\tcolorObject && colorObject.slug\n\t\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t\t: colorValue,\n\t\t\t\t\t\t} );\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tstatic getDerivedStateFromProps(\n\t\t\t\t\t{ attributes, colors },\n\t\t\t\t\tpreviousState\n\t\t\t\t) {\n\t\t\t\t\treturn Object.entries( colorMap ).reduce(\n\t\t\t\t\t\t( newState, [ colorAttributeName, colorContext ] ) => {\n\t\t\t\t\t\t\tconst colorObject = getColorObjectByAttributeValues(\n\t\t\t\t\t\t\t\tcolors,\n\t\t\t\t\t\t\t\tattributes[ colorAttributeName ],\n\t\t\t\t\t\t\t\tattributes[\n\t\t\t\t\t\t\t\t\t`custom${ upperFirst(\n\t\t\t\t\t\t\t\t\t\tcolorAttributeName\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);\n\n\t\t\t\t\t\t\tconst previousColorObject =\n\t\t\t\t\t\t\t\tpreviousState[ colorAttributeName ];\n\t\t\t\t\t\t\tconst previousColor = previousColorObject?.color;\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * The \"and previousColorObject\" condition checks that a previous color object was already computed.\n\t\t\t\t\t\t\t * At the start previousColorObject and colorValue are both equal to undefined\n\t\t\t\t\t\t\t * bus as previousColorObject does not exist we should compute the object.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tpreviousColor === colorObject.color &&\n\t\t\t\t\t\t\t\tpreviousColorObject\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] =\n\t\t\t\t\t\t\t\t\tpreviousColorObject;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tnewState[ colorAttributeName ] = {\n\t\t\t\t\t\t\t\t\t...colorObject,\n\t\t\t\t\t\t\t\t\tclass: getColorClassName(\n\t\t\t\t\t\t\t\t\t\tcolorContext,\n\t\t\t\t\t\t\t\t\t\tcolorObject.slug\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}\n\t\t\t\t\t\t\treturn newState;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\trender() {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t\t{ ...{\n\t\t\t\t\t\t\t\t...this.props,\n\t\t\t\t\t\t\t\tcolors: undefined,\n\t\t\t\t\t\t\t\t...this.state,\n\t\t\t\t\t\t\t\t...this.setters,\n\t\t\t\t\t\t\t\tcolorUtils: this.colorUtils,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t},\n\t] );\n}\n\n/**\n * A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic\n * for class generation color value, retrieval and color attribute setting.\n *\n * Use this higher-order component to work with a custom set of colors.\n *\n * @example\n *\n * ```jsx\n * const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];\n * const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );\n * // ...\n * export default compose(\n * withCustomColors( 'backgroundColor', 'borderColor' ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).\n *\n * @return {Function} Higher-order component.\n */\nexport function createCustomColorsHOC( colorsArray ) {\n\treturn ( ...colorTypes ) => {\n\t\tconst withColorPalette = withCustomColorPalette( colorsArray );\n\t\treturn createHigherOrderComponent(\n\t\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t\t'withCustomColors'\n\t\t);\n\t};\n}\n\n/**\n * A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.\n *\n * For use with the default editor/theme color palette.\n *\n * @example\n *\n * ```jsx\n * export default compose(\n * withColors( 'backgroundColor', { textColor: 'color' } ),\n * MyColorfulComponent,\n * );\n * ```\n *\n * @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,\n * it should contain the color attribute name as key and the color context as value.\n * If the argument is a string the value should be the color attribute name,\n * the color context is computed by applying a kebab case transform to the value.\n * Color context represents the context/place where the color is going to be used.\n * The class name of the color is generated using 'has' followed by the color name\n * and ending with the color context all in kebab case e.g: has-green-background-color.\n *\n * @return {Function} Higher-order component.\n */\nexport default function withColors( ...colorTypes ) {\n\tconst withColorPalette = withEditorColorPalette();\n\treturn createHigherOrderComponent(\n\t\tcreateColorHOC( colorTypes, withColorPalette ),\n\t\t'withColors'\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACvD,SAASC,OAAO,EAA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B,WAAW,CAACiB,IACb;YACD,CAAC;UACF;UACA,OAAOM,QAAQ;QAChB,CAAC,EACD,CAAC,CACF,CAAC;MACF;MAEAM,MAAMA,CAAA,EAAG;QACR,OACCzC,aAAA,CAACF,gBAAgB;UAEf,GAAG,IAAI,CAACC,KAAK;UACbE,MAAM,EAAE6B,SAAS;UACjB,GAAG,IAAI,CAACX,KAAK;UACb,GAAG,IAAI,CAACJ,OAAO;UACfE,UAAU,EAAE,IAAI,CAACA;QAAU,CAE5B,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,CACA,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASyB,qBAAqBA,CAAE7C,WAAW,EAAG;EACpD,OAAO,CAAE,GAAGW,UAAU,KAAM;IAC3B,MAAMC,gBAAgB,GAAGb,sBAAsB,CAAEC,WAAY,CAAC;IAC9D,OAAOb,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,kBACD,CAAC;EACF,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASkC,UAAUA,CAAE,GAAGnC,UAAU,EAAG;EACnD,MAAMC,gBAAgB,GAAGP,sBAAsB,CAAC,CAAC;EACjD,OAAOlB,0BAA0B,CAChCuB,cAAc,CAAEC,UAAU,EAAEC,gBAAiB,CAAC,EAC9C,YACD,CAAC;AACF"}
|
|
@@ -13,7 +13,7 @@ import { BaseControl, __experimentalVStack as VStack, TabPanel, ColorPalette, Gr
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
-
import
|
|
16
|
+
import { useSettings } from '../use-settings';
|
|
17
17
|
const colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
|
|
18
18
|
const TAB_COLOR = {
|
|
19
19
|
name: 'color',
|
|
@@ -95,13 +95,12 @@ function ColorGradientControlInner({
|
|
|
95
95
|
}, tab => renderPanelType(tab.value)), !canChooseAGradient && renderPanelType(TAB_COLOR.value), !canChooseAColor && renderPanelType(TAB_GRADIENT.value))));
|
|
96
96
|
}
|
|
97
97
|
function ColorGradientControlSelect(props) {
|
|
98
|
-
const
|
|
99
|
-
colorGradientSettings.colors = useSetting('color.palette');
|
|
100
|
-
colorGradientSettings.gradients = useSetting('color.gradients');
|
|
101
|
-
colorGradientSettings.disableCustomColors = !useSetting('color.custom');
|
|
102
|
-
colorGradientSettings.disableCustomGradients = !useSetting('color.customGradient');
|
|
98
|
+
const [colors, gradients, customColors, customGradients] = useSettings('color.palette', 'color.gradients', 'color.custom', 'color.customGradient');
|
|
103
99
|
return createElement(ColorGradientControlInner, {
|
|
104
|
-
|
|
100
|
+
colors: colors,
|
|
101
|
+
gradients: gradients,
|
|
102
|
+
disableCustomColors: !customColors,
|
|
103
|
+
disableCustomGradients: !customGradients,
|
|
105
104
|
...props
|
|
106
105
|
});
|
|
107
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","
|
|
1
|
+
{"version":3,"names":["classnames","__","BaseControl","__experimentalVStack","VStack","TabPanel","ColorPalette","GradientPicker","useSettings","colorsAndGradientKeys","TAB_COLOR","name","title","value","TAB_GRADIENT","TABS_SETTINGS","ColorGradientControlInner","colors","gradients","disableCustomColors","disableCustomGradients","__experimentalIsRenderedInSidebar","className","label","onColorChange","onGradientChange","colorValue","gradientValue","clearable","showTitle","enableAlpha","headingLevel","canChooseAColor","length","canChooseAGradient","tabPanels","createElement","onChange","newColor","__nextHasNoMargin","newGradient","renderPanelType","type","__nextHasNoMarginBottom","spacing","VisualLabel","tabs","initialTabName","tab","ColorGradientControlSelect","props","customColors","customGradients","ColorGradientControl","every","key","hasOwnProperty"],"sources":["@wordpress/block-editor/src/components/colors-gradients/control.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBaseControl,\n\t__experimentalVStack as VStack,\n\tTabPanel,\n\tColorPalette,\n\tGradientPicker,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nconst colorsAndGradientKeys = [\n\t'colors',\n\t'disableCustomColors',\n\t'gradients',\n\t'disableCustomGradients',\n];\n\nconst TAB_COLOR = {\n\tname: 'color',\n\ttitle: __( 'Solid' ),\n\tvalue: 'color',\n};\nconst TAB_GRADIENT = {\n\tname: 'gradient',\n\ttitle: __( 'Gradient' ),\n\tvalue: 'gradient',\n};\n\nconst TABS_SETTINGS = [ TAB_COLOR, TAB_GRADIENT ];\n\nfunction ColorGradientControlInner( {\n\tcolors,\n\tgradients,\n\tdisableCustomColors,\n\tdisableCustomGradients,\n\t__experimentalIsRenderedInSidebar,\n\tclassName,\n\tlabel,\n\tonColorChange,\n\tonGradientChange,\n\tcolorValue,\n\tgradientValue,\n\tclearable,\n\tshowTitle = true,\n\tenableAlpha,\n\theadingLevel,\n} ) {\n\tconst canChooseAColor =\n\t\tonColorChange &&\n\t\t( ( colors && colors.length > 0 ) || ! disableCustomColors );\n\tconst canChooseAGradient =\n\t\tonGradientChange &&\n\t\t( ( gradients && gradients.length > 0 ) || ! disableCustomGradients );\n\n\tif ( ! canChooseAColor && ! canChooseAGradient ) {\n\t\treturn null;\n\t}\n\n\tconst tabPanels = {\n\t\t[ TAB_COLOR.value ]: (\n\t\t\t<ColorPalette\n\t\t\t\tvalue={ colorValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAGradient\n\t\t\t\t\t\t? ( newColor ) => {\n\t\t\t\t\t\t\t\tonColorChange( newColor );\n\t\t\t\t\t\t\t\tonGradientChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onColorChange\n\t\t\t\t}\n\t\t\t\t{ ...{ colors, disableCustomColors } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\tenableAlpha={ enableAlpha }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t\t[ TAB_GRADIENT.value ]: (\n\t\t\t<GradientPicker\n\t\t\t\t__nextHasNoMargin\n\t\t\t\tvalue={ gradientValue }\n\t\t\t\tonChange={\n\t\t\t\t\tcanChooseAColor\n\t\t\t\t\t\t? ( newGradient ) => {\n\t\t\t\t\t\t\t\tonGradientChange( newGradient );\n\t\t\t\t\t\t\t\tonColorChange();\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: onGradientChange\n\t\t\t\t}\n\t\t\t\t{ ...{ gradients, disableCustomGradients } }\n\t\t\t\t__experimentalIsRenderedInSidebar={\n\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t}\n\t\t\t\tclearable={ clearable }\n\t\t\t\theadingLevel={ headingLevel }\n\t\t\t/>\n\t\t),\n\t};\n\n\tconst renderPanelType = ( type ) => (\n\t\t<div className=\"block-editor-color-gradient-control__panel\">\n\t\t\t{ tabPanels[ type ] }\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<BaseControl\n\t\t\t__nextHasNoMarginBottom\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-color-gradient-control',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<fieldset className=\"block-editor-color-gradient-control__fieldset\">\n\t\t\t\t<VStack spacing={ 1 }>\n\t\t\t\t\t{ showTitle && (\n\t\t\t\t\t\t<legend>\n\t\t\t\t\t\t\t<div className=\"block-editor-color-gradient-control__color-indicator\">\n\t\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</legend>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canChooseAColor && canChooseAGradient && (\n\t\t\t\t\t\t<TabPanel\n\t\t\t\t\t\t\tclassName=\"block-editor-color-gradient-control__tabs\"\n\t\t\t\t\t\t\ttabs={ TABS_SETTINGS }\n\t\t\t\t\t\t\tinitialTabName={\n\t\t\t\t\t\t\t\tgradientValue\n\t\t\t\t\t\t\t\t\t? TAB_GRADIENT.value\n\t\t\t\t\t\t\t\t\t: !! canChooseAColor && TAB_COLOR.value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ( tab ) => renderPanelType( tab.value ) }\n\t\t\t\t\t\t</TabPanel>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! canChooseAGradient &&\n\t\t\t\t\t\trenderPanelType( TAB_COLOR.value ) }\n\t\t\t\t\t{ ! canChooseAColor &&\n\t\t\t\t\t\trenderPanelType( TAB_GRADIENT.value ) }\n\t\t\t\t</VStack>\n\t\t\t</fieldset>\n\t\t</BaseControl>\n\t);\n}\n\nfunction ColorGradientControlSelect( props ) {\n\tconst [ colors, gradients, customColors, customGradients ] = useSettings(\n\t\t'color.palette',\n\t\t'color.gradients',\n\t\t'color.custom',\n\t\t'color.customGradient'\n\t);\n\n\treturn (\n\t\t<ColorGradientControlInner\n\t\t\tcolors={ colors }\n\t\t\tgradients={ gradients }\n\t\t\tdisableCustomColors={ ! customColors }\n\t\t\tdisableCustomGradients={ ! customGradients }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n\nfunction ColorGradientControl( props ) {\n\tif (\n\t\tcolorsAndGradientKeys.every( ( key ) => props.hasOwnProperty( key ) )\n\t) {\n\t\treturn <ColorGradientControlInner { ...props } />;\n\t}\n\treturn <ColorGradientControlSelect { ...props } />;\n}\n\nexport default ColorGradientControl;\n"],"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AC,2CAA2C;IACrDwB,IAAI,EAAG/B,aAAe;IACtBgC,cAAc,EACbpB,aAAa,GACVb,YAAY,CAACD,KAAK,GAClB,CAAC,CAAEmB,eAAe,IAAItB,SAAS,CAACG;EACnC,GAEGmC,GAAG,IAAMP,eAAe,CAAEO,GAAG,CAACnC,KAAM,CAC/B,CACV,EACC,CAAEqB,kBAAkB,IACrBO,eAAe,CAAE/B,SAAS,CAACG,KAAM,CAAC,EACjC,CAAEmB,eAAe,IAClBS,eAAe,CAAE3B,YAAY,CAACD,KAAM,CAC9B,CACC,CACE,CAAC;AAEhB;AAEA,SAASoC,0BAA0BA,CAAEC,KAAK,EAAG;EAC5C,MAAM,CAAEjC,MAAM,EAAEC,SAAS,EAAEiC,YAAY,EAAEC,eAAe,CAAE,GAAG5C,WAAW,CACvE,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,sBACD,CAAC;EAED,OACC4B,aAAA,CAACpB,yBAAyB;IACzBC,MAAM,EAAGA,MAAQ;IACjBC,SAAS,EAAGA,SAAW;IACvBC,mBAAmB,EAAG,CAAEgC,YAAc;IACtC/B,sBAAsB,EAAG,CAAEgC,eAAiB;IAAA,GACvCF;EAAK,CACV,CAAC;AAEJ;AAEA,SAASG,oBAAoBA,CAAEH,KAAK,EAAG;EACtC,IACCzC,qBAAqB,CAAC6C,KAAK,CAAIC,GAAG,IAAML,KAAK,CAACM,cAAc,CAAED,GAAI,CAAE,CAAC,EACpE;IACD,OAAOnB,aAAA,CAACpB,yBAAyB;MAAA,GAAMkC;IAAK,CAAI,CAAC;EAClD;EACA,OAAOd,aAAA,CAACa,0BAA0B;IAAA,GAAMC;EAAK,CAAI,CAAC;AACnD;AAEA,eAAeG,oBAAoB"}
|
package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js
CHANGED
|
@@ -7,7 +7,7 @@ import { _x } from '@wordpress/i18n';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { useSettings } from '../use-settings';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Retrieves color and gradient related settings.
|
|
@@ -18,14 +18,11 @@ import useSetting from '../use-setting';
|
|
|
18
18
|
* @return {Object} Color and gradient related settings.
|
|
19
19
|
*/
|
|
20
20
|
export default function useMultipleOriginColorsAndGradients() {
|
|
21
|
+
const [enableCustomColors, customColors, themeColors, defaultColors, shouldDisplayDefaultColors, enableCustomGradients, customGradients, themeGradients, defaultGradients, shouldDisplayDefaultGradients] = useSettings('color.custom', 'color.palette.custom', 'color.palette.theme', 'color.palette.default', 'color.defaultPalette', 'color.customGradient', 'color.gradients.custom', 'color.gradients.theme', 'color.gradients.default', 'color.defaultGradients');
|
|
21
22
|
const colorGradientSettings = {
|
|
22
|
-
disableCustomColors: !
|
|
23
|
-
disableCustomGradients: !
|
|
23
|
+
disableCustomColors: !enableCustomColors,
|
|
24
|
+
disableCustomGradients: !enableCustomGradients
|
|
24
25
|
};
|
|
25
|
-
const customColors = useSetting('color.palette.custom');
|
|
26
|
-
const themeColors = useSetting('color.palette.theme');
|
|
27
|
-
const defaultColors = useSetting('color.palette.default');
|
|
28
|
-
const shouldDisplayDefaultColors = useSetting('color.defaultPalette');
|
|
29
26
|
colorGradientSettings.colors = useMemo(() => {
|
|
30
27
|
const result = [];
|
|
31
28
|
if (themeColors && themeColors.length) {
|
|
@@ -47,11 +44,7 @@ export default function useMultipleOriginColorsAndGradients() {
|
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
46
|
return result;
|
|
50
|
-
}, [
|
|
51
|
-
const customGradients = useSetting('color.gradients.custom');
|
|
52
|
-
const themeGradients = useSetting('color.gradients.theme');
|
|
53
|
-
const defaultGradients = useSetting('color.gradients.default');
|
|
54
|
-
const shouldDisplayDefaultGradients = useSetting('color.defaultGradients');
|
|
47
|
+
}, [customColors, themeColors, defaultColors, shouldDisplayDefaultColors]);
|
|
55
48
|
colorGradientSettings.gradients = useMemo(() => {
|
|
56
49
|
const result = [];
|
|
57
50
|
if (themeGradients && themeGradients.length) {
|
package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","_x","
|
|
1
|
+
{"version":3,"names":["useMemo","_x","useSettings","useMultipleOriginColorsAndGradients","enableCustomColors","customColors","themeColors","defaultColors","shouldDisplayDefaultColors","enableCustomGradients","customGradients","themeGradients","defaultGradients","shouldDisplayDefaultGradients","colorGradientSettings","disableCustomColors","disableCustomGradients","colors","result","length","push","name","gradients","hasColorsOrGradients"],"sources":["@wordpress/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\n/**\n * Retrieves color and gradient related settings.\n *\n * The arrays for colors and gradients are made up of color palettes from each\n * origin i.e. \"Core\", \"Theme\", and \"User\".\n *\n * @return {Object} Color and gradient related settings.\n */\nexport default function useMultipleOriginColorsAndGradients() {\n\tconst [\n\t\tenableCustomColors,\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t\tenableCustomGradients,\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] = useSettings(\n\t\t'color.custom',\n\t\t'color.palette.custom',\n\t\t'color.palette.theme',\n\t\t'color.palette.default',\n\t\t'color.defaultPalette',\n\t\t'color.customGradient',\n\t\t'color.gradients.custom',\n\t\t'color.gradients.theme',\n\t\t'color.gradients.default',\n\t\t'color.defaultGradients'\n\t);\n\n\tconst colorGradientSettings = {\n\t\tdisableCustomColors: ! enableCustomColors,\n\t\tdisableCustomGradients: ! enableCustomGradients,\n\t};\n\n\tcolorGradientSettings.colors = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n\n\tcolorGradientSettings.gradients = useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n\n\tcolorGradientSettings.hasColorsOrGradients =\n\t\t!! colorGradientSettings.colors.length ||\n\t\t!! colorGradientSettings.gradients.length;\n\n\treturn colorGradientSettings;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mCAAmCA,CAAA,EAAG;EAC7D,MAAM,CACLC,kBAAkB,EAClBC,YAAY,EACZC,WAAW,EACXC,aAAa,EACbC,0BAA0B,EAC1BC,qBAAqB,EACrBC,eAAe,EACfC,cAAc,EACdC,gBAAgB,EAChBC,6BAA6B,CAC7B,GAAGX,WAAW,CACd,cAAc,EACd,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,wBACD,CAAC;EAED,MAAMY,qBAAqB,GAAG;IAC7BC,mBAAmB,EAAE,CAAEX,kBAAkB;IACzCY,sBAAsB,EAAE,CAAEP;EAC3B,CAAC;EAEDK,qBAAqB,CAACG,MAAM,GAAGjB,OAAO,CAAE,MAAM;IAC7C,MAAMkB,MAAM,GAAG,EAAE;IACjB,IAAKZ,WAAW,IAAIA,WAAW,CAACa,MAAM,EAAG;MACxCD,MAAM,CAACE,IAAI,CAAE;QACZC,IAAI,EAAEpB,EAAE,CACP,OAAO,EACP,8CACD,CAAC;QACDgB,MAAM,EAAEX;MACT,CAAE,CAAC;IACJ;IACA,IACCE,0BAA0B,IAC1BD,aAA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AC,CAAET,qBAAqB,CAACG,MAAM,CAACE,MAAM,IACtC,CAAC,CAAEL,qBAAqB,CAACQ,SAAS,CAACH,MAAM;EAE1C,OAAOL,qBAAqB;AAC7B"}
|
|
@@ -118,28 +118,6 @@ function DimensionsTool({
|
|
|
118
118
|
}
|
|
119
119
|
onChange(nextValue);
|
|
120
120
|
}
|
|
121
|
-
}), showScaleControl && createElement(ScaleTool, {
|
|
122
|
-
panelId: panelId,
|
|
123
|
-
options: scaleOptions,
|
|
124
|
-
defaultValue: defaultScale,
|
|
125
|
-
value: lastScale,
|
|
126
|
-
onChange: nextScale => {
|
|
127
|
-
const nextValue = {
|
|
128
|
-
...value
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// 'fill' is CSS default, so it gets treated as null.
|
|
132
|
-
nextScale = nextScale === 'fill' ? null : nextScale;
|
|
133
|
-
setLastScale(nextScale);
|
|
134
|
-
|
|
135
|
-
// Update scale.
|
|
136
|
-
if (!nextScale) {
|
|
137
|
-
delete nextValue.scale;
|
|
138
|
-
} else {
|
|
139
|
-
nextValue.scale = nextScale;
|
|
140
|
-
}
|
|
141
|
-
onChange(nextValue);
|
|
142
|
-
}
|
|
143
121
|
}), createElement(WidthHeightTool, {
|
|
144
122
|
panelId: panelId,
|
|
145
123
|
units: unitsOptions,
|
|
@@ -195,6 +173,28 @@ function DimensionsTool({
|
|
|
195
173
|
}
|
|
196
174
|
onChange(nextValue);
|
|
197
175
|
}
|
|
176
|
+
}), showScaleControl && createElement(ScaleTool, {
|
|
177
|
+
panelId: panelId,
|
|
178
|
+
options: scaleOptions,
|
|
179
|
+
defaultValue: defaultScale,
|
|
180
|
+
value: lastScale,
|
|
181
|
+
onChange: nextScale => {
|
|
182
|
+
const nextValue = {
|
|
183
|
+
...value
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// 'fill' is CSS default, so it gets treated as null.
|
|
187
|
+
nextScale = nextScale === 'fill' ? null : nextScale;
|
|
188
|
+
setLastScale(nextScale);
|
|
189
|
+
|
|
190
|
+
// Update scale.
|
|
191
|
+
if (!nextScale) {
|
|
192
|
+
delete nextValue.scale;
|
|
193
|
+
} else {
|
|
194
|
+
nextValue.scale = nextScale;
|
|
195
|
+
}
|
|
196
|
+
onChange(nextValue);
|
|
197
|
+
}
|
|
198
198
|
}));
|
|
199
199
|
}
|
|
200
200
|
export default DimensionsTool;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","AspectRatioTool","ScaleTool","WidthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","createElement","Fragment","options","defaultValue","nextAspectRatio","nextValue","nextScale","units","nextWidth","nextHeight"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAE;EACxBC,OAAO;EACPC,KAAK,GAAG,CAAC,CAAC;EACVC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB;EAAE;EACpBC,kBAAkB,GAAG,MAAM;EAAE;EAC7BC,YAAY;EAAE;EACdC,YAAY,GAAG,MAAM;EAAE;EACvBC,YAAY,CAAE;AACf,CAAC,EAAG;EACH;EACA,MAAMC,KAAK,GACVP,KAAK,CAACO,KAAK,KAAKC,SAAS,IAAIR,KAAK,CAACO,KAAK,KAAK,MAAM,GAChD,IAAI,GACJP,KAAK,CAACO,KAAK;EACf,MAAME,MAAM,GACXT,KAAK,CAACS,MAAM,KAAKD,SAAS,IAAIR,KAAK,CAACS,MAAM,KAAK,MAAM,GAClD,IAAI,GACJT,KAAK,CAACS,MAAM;EAChB,MAAMC,WAAW,GAChBV,KAAK,CAACU,WAAW,KAAKF,SAAS,IAAIR,KAAK,CAACU,WAAW,KAAK,MAAM,GAC5D,IAAI,GACJV,KAAK,CAACU,WAAW;EACrB,MAAMC,KAAK,GACVX,KAAK,CAACW,KAAK,KAAKH,SAAS,IAAIR,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AS,CAACd,MAAM;MACxB,CAAC,MAAM;QACNc,SAAS,CAACd,MAAM,GAAGkB,UAAU;MAC9B;;MAEA;MACA,IAAKD,SAAS,IAAIC,UAAU,EAAG;QAC9B,OAAOJ,SAAS,CAACb,WAAW;MAC7B,CAAC,MAAM,IAAKI,eAAe,EAAG;QAC7BS,SAAS,CAACb,WAAW,GAAGI,eAAe;MACxC,CAAC,MAAM;QACN;QACA;QACA;MAAA;;MAGD;MACA,IAAK,CAAEA,eAAe,IAAI,CAAC,CAAEY,SAAS,KAAK,CAAC,CAAEC,UAAU,EAAG;QAC1D,OAAOJ,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM,IAAKC,SAAS,EAAG;QACvBW,SAAS,CAACZ,KAAK,GAAGC,SAAS;MAC5B,CAAC,MAAM;QACNW,SAAS,CAACZ,KAAK,GAAGN,YAAY;QAC9BQ,YAAY,CAAER,YAAa,CAAC;MAC7B;MAEAJ,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CACA,CAAC;AAEL;AAEA,eAAezB,cAAc"}
|
|
1
|
+
{"version":3,"names":["useState","AspectRatioTool","ScaleTool","WidthHeightTool","DimensionsTool","panelId","value","onChange","aspectRatioOptions","defaultAspectRatio","scaleOptions","defaultScale","unitsOptions","width","undefined","height","aspectRatio","scale","lastScale","setLastScale","lastAspectRatio","setLastAspectRatio","aspectRatioValue","showScaleControl","createElement","Fragment","options","defaultValue","nextAspectRatio","nextValue","units","nextWidth","nextHeight","nextScale"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport AspectRatioTool from './aspect-ratio-tool';\nimport ScaleTool from './scale-tool';\nimport WidthHeightTool from './width-height-tool';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * @typedef {import('@wordpress/components/build-types/unit-control/types').WPUnitControlUnit} WPUnitControlUnit\n */\n\n/**\n * @typedef {Object} Dimensions\n * @property {string} [width] CSS width property.\n * @property {string} [height] CSS height property.\n * @property {string} [scale] CSS object-fit property.\n * @property {string} [aspectRatio] CSS aspect-ratio property.\n */\n\n/**\n * @callback DimensionsControlsOnChange\n * @param {Dimensions} nextValue\n * @return {void}\n */\n\n/**\n * @typedef {Object} DimensionsControlsProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {Dimensions} [value] Current dimensions values.\n * @property {DimensionsControlsOnChange} [onChange] Callback to update the dimensions values.\n * @property {SelectControlProps[]} [aspectRatioOptions] Aspect ratio options.\n * @property {SelectControlProps[]} [scaleOptions] Scale options.\n * @property {WPUnitControlUnit[]} [unitsOptions] Units options.\n */\n\n/**\n * Component that renders controls to edit the dimensions of an image or container.\n *\n * @param {DimensionsControlsProps} props The component props.\n *\n * @return {Element} The dimensions controls.\n */\nfunction DimensionsTool( {\n\tpanelId,\n\tvalue = {},\n\tonChange = () => {},\n\taspectRatioOptions, // Default options handled by AspectRatioTool.\n\tdefaultAspectRatio = 'auto', // Match CSS default value for aspect-ratio.\n\tscaleOptions, // Default options handled by ScaleTool.\n\tdefaultScale = 'fill', // Match CSS default value for object-fit.\n\tunitsOptions, // Default options handled by UnitControl.\n} ) {\n\t// Coerce undefined and CSS default values to be null.\n\tconst width =\n\t\tvalue.width === undefined || value.width === 'auto'\n\t\t\t? null\n\t\t\t: value.width;\n\tconst height =\n\t\tvalue.height === undefined || value.height === 'auto'\n\t\t\t? null\n\t\t\t: value.height;\n\tconst aspectRatio =\n\t\tvalue.aspectRatio === undefined || value.aspectRatio === 'auto'\n\t\t\t? null\n\t\t\t: value.aspectRatio;\n\tconst scale =\n\t\tvalue.scale === undefined || value.scale === 'fill'\n\t\t\t? null\n\t\t\t: value.scale;\n\n\t// Keep track of state internally, so when the value is cleared by means\n\t// other than directly editing that field, it's easier to restore the\n\t// previous value.\n\tconst [ lastScale, setLastScale ] = useState( scale );\n\tconst [ lastAspectRatio, setLastAspectRatio ] = useState( aspectRatio );\n\n\t// 'custom' is not a valid value for CSS aspect-ratio, but it is used in the\n\t// dropdown to indicate that setting both the width and height is the same\n\t// as a custom aspect ratio.\n\tconst aspectRatioValue = width && height ? 'custom' : lastAspectRatio;\n\n\tconst showScaleControl = aspectRatio || ( width && height );\n\n\treturn (\n\t\t<>\n\t\t\t<AspectRatioTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\toptions={ aspectRatioOptions }\n\t\t\t\tdefaultValue={ defaultAspectRatio }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ ( nextAspectRatio ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextAspectRatio =\n\t\t\t\t\t\tnextAspectRatio === 'auto' ? null : nextAspectRatio;\n\n\t\t\t\t\tsetLastAspectRatio( nextAspectRatio );\n\n\t\t\t\t\t// Update aspectRatio.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.aspectRatio = nextAspectRatio;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! nextAspectRatio ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update width and height.\n\t\t\t\t\tif ( 'custom' !== nextAspectRatio && width && height ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<WidthHeightTool\n\t\t\t\tpanelId={ panelId }\n\t\t\t\tunits={ unitsOptions }\n\t\t\t\tvalue={ { width, height } }\n\t\t\t\tonChange={ ( { width: nextWidth, height: nextHeight } ) => {\n\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t// 'auto' is CSS default, so it gets treated as null.\n\t\t\t\t\tnextWidth = nextWidth === 'auto' ? null : nextWidth;\n\t\t\t\t\tnextHeight = nextHeight === 'auto' ? null : nextHeight;\n\n\t\t\t\t\t// Update width.\n\t\t\t\t\tif ( ! nextWidth ) {\n\t\t\t\t\t\tdelete nextValue.width;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.width = nextWidth;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Update height.\n\t\t\t\t\tif ( ! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.height;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.height = nextHeight;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update aspectRatio.\n\t\t\t\t\tif ( nextWidth && nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.aspectRatio;\n\t\t\t\t\t} else if ( lastAspectRatio ) {\n\t\t\t\t\t\tnextValue.aspectRatio = lastAspectRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// No setting defaultAspectRatio here, because\n\t\t\t\t\t\t// aspectRatio is optional in this scenario,\n\t\t\t\t\t\t// unlike scale.\n\t\t\t\t\t}\n\n\t\t\t\t\t// Auto-update scale.\n\t\t\t\t\tif ( ! lastAspectRatio && !! nextWidth !== !! nextHeight ) {\n\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t} else if ( lastScale ) {\n\t\t\t\t\t\tnextValue.scale = lastScale;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnextValue.scale = defaultScale;\n\t\t\t\t\t\tsetLastScale( defaultScale );\n\t\t\t\t\t}\n\n\t\t\t\t\tonChange( nextValue );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ showScaleControl && (\n\t\t\t\t<ScaleTool\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t\toptions={ scaleOptions }\n\t\t\t\t\tdefaultValue={ defaultScale }\n\t\t\t\t\tvalue={ lastScale }\n\t\t\t\t\tonChange={ ( nextScale ) => {\n\t\t\t\t\t\tconst nextValue = { ...value };\n\n\t\t\t\t\t\t// 'fill' is CSS default, so it gets treated as null.\n\t\t\t\t\t\tnextScale = nextScale === 'fill' ? null : nextScale;\n\n\t\t\t\t\t\tsetLastScale( nextScale );\n\n\t\t\t\t\t\t// Update scale.\n\t\t\t\t\t\tif ( ! nextScale ) {\n\t\t\t\t\t\t\tdelete nextValue.scale;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnextValue.scale = nextScale;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tonChange( nextValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default DimensionsTool;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,SAAS,MAAM,cAAc;AACpC,OAAOC,eAAe,MAAM,qBAAqB;;AAEjD;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,cAAcA,CAAE;EACxBC,OAAO;EACPC,KAAK,GAAG,CAAC,CAAC;EACVC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB;EAAE;EACpBC,kBAAkB,GAAG,MAAM;EAAE;EAC7BC,YAAY;EAAE;EACdC,YAAY,GAAG,MAAM;EAAE;EACvBC,YAAY,CAAE;AACf,CAAC,EAAG;EACH;EACA,MAAMC,KAAK,GACVP,KAAK,CAACO,KAAK,KAA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OH,SAAS,CAACb,WAAW;MAC7B,CAAC,MAAM,IAAKI,eAAe,EAAG;QAC7BS,SAAS,CAACb,WAAW,GAAGI,eAAe;MACxC,CAAC,MAAM;QACN;QACA;QACA;MAAA;;MAGD;MACA,IAAK,CAAEA,eAAe,IAAI,CAAC,CAAEW,SAAS,KAAK,CAAC,CAAEC,UAAU,EAAG;QAC1D,OAAOH,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM,IAAKC,SAAS,EAAG;QACvBW,SAAS,CAACZ,KAAK,GAAGC,SAAS;MAC5B,CAAC,MAAM;QACNW,SAAS,CAACZ,KAAK,GAAGN,YAAY;QAC9BQ,YAAY,CAAER,YAAa,CAAC;MAC7B;MAEAJ,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CAAC,EACAN,gBAAgB,IACjBC,aAAA,CAACtB,SAAS;IACTG,OAAO,EAAGA,OAAS;IACnBqB,OAAO,EAAGhB,YAAc;IACxBiB,YAAY,EAAGhB,YAAc;IAC7BL,KAAK,EAAGY,SAAW;IACnBX,QAAQ,EAAK0B,SAAS,IAAM;MAC3B,MAAMJ,SAAS,GAAG;QAAE,GAAGvB;MAAM,CAAC;;MAE9B;MACA2B,SAAS,GAAGA,SAAS,KAAK,MAAM,GAAG,IAAI,GAAGA,SAAS;MAEnDd,YAAY,CAAEc,SAAU,CAAC;;MAEzB;MACA,IAAK,CAAEA,SAAS,EAAG;QAClB,OAAOJ,SAAS,CAACZ,KAAK;MACvB,CAAC,MAAM;QACNY,SAAS,CAACZ,KAAK,GAAGgB,SAAS;MAC5B;MAEA1B,QAAQ,CAAEsB,SAAU,CAAC;IACtB;EAAG,CACH,CAED,CAAC;AAEL;AAEA,eAAezB,cAAc"}
|
|
@@ -93,7 +93,7 @@ export default function ScaleTool({
|
|
|
93
93
|
help: scaleHelp[displayValue],
|
|
94
94
|
value: displayValue,
|
|
95
95
|
onChange: onChange,
|
|
96
|
-
|
|
96
|
+
size: '__unstable-large'
|
|
97
97
|
}, options.map(option => createElement(ToggleGroupControlOption, {
|
|
98
98
|
key: option.value,
|
|
99
99
|
...option
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__experimentalToolsPanelItem","ToolsPanelItem","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useMemo","__","_x","DEFAULT_SCALE_OPTIONS","value","label","help","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","reduce","acc","option","createElement","hasValue","onDeselect","isBlock","
|
|
1
|
+
{"version":3,"names":["__experimentalToolsPanelItem","ToolsPanelItem","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","useMemo","__","_x","DEFAULT_SCALE_OPTIONS","value","label","help","ScaleTool","panelId","onChange","options","defaultValue","isShownByDefault","displayValue","scaleHelp","reduce","acc","option","createElement","hasValue","onDeselect","isBlock","size","map","key"],"sources":["@wordpress/block-editor/src/components/dimensions-tool/scale-tool.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useMemo } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * @typedef {import('@wordpress/components/build-types/select-control/types').SelectControlProps} SelectControlProps\n */\n\n/**\n * The descriptions are purposely made generic as object-fit could be used for\n * any replaced element. Provide your own set of options if you need different\n * help text or labels.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/CSS/Replaced_element\n *\n * @type {SelectControlProps[]}\n */\nconst DEFAULT_SCALE_OPTIONS = [\n\t{\n\t\tvalue: 'fill',\n\t\tlabel: _x( 'Fill', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fill the space by stretching the content.' ),\n\t},\n\t{\n\t\tvalue: 'contain',\n\t\tlabel: _x( 'Contain', 'Scale option for dimensions control' ),\n\t\thelp: __( 'Fit the content to the space without clipping.' ),\n\t},\n\t{\n\t\tvalue: 'cover',\n\t\tlabel: _x( 'Cover', 'Scale option for dimensions control' ),\n\t\thelp: __( \"Fill the space by clipping what doesn't fit.\" ),\n\t},\n\t{\n\t\tvalue: 'none',\n\t\tlabel: _x( 'None', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding.'\n\t\t),\n\t},\n\t{\n\t\tvalue: 'scale-down',\n\t\tlabel: _x( 'Scale down', 'Scale option for dimensions control' ),\n\t\thelp: __(\n\t\t\t'Scale down the content to fit the space if it is too big. Content that is too small will have additional padding.'\n\t\t),\n\t},\n];\n\n/**\n * @callback ScaleToolPropsOnChange\n * @param {string} nextValue New scale value.\n * @return {void}\n */\n\n/**\n * @typedef {Object} ScaleToolProps\n * @property {string} [panelId] ID of the panel that contains the controls.\n * @property {string} [value] Current scale value.\n * @property {ScaleToolPropsOnChange} [onChange] Callback to update the scale value.\n * @property {SelectControlProps[]} [options] Scale options.\n * @property {string} [defaultValue] Default scale value.\n * @property {boolean} [showControl=true] Whether to show the control.\n * @property {boolean} [isShownByDefault=true] Whether the tool panel is shown by default.\n */\n\n/**\n * A tool to select the CSS object-fit property for the image.\n *\n * @param {ScaleToolProps} props\n *\n * @return {import('react').ReactElement} The scale tool.\n */\nexport default function ScaleTool( {\n\tpanelId,\n\tvalue,\n\tonChange,\n\toptions = DEFAULT_SCALE_OPTIONS,\n\tdefaultValue = DEFAULT_SCALE_OPTIONS[ 0 ].value,\n\tisShownByDefault = true,\n} ) {\n\t// Match the CSS default so if the value is used directly in CSS it will look correct in the control.\n\tconst displayValue = value ?? 'fill';\n\n\tconst scaleHelp = useMemo( () => {\n\t\treturn options.reduce( ( acc, option ) => {\n\t\t\tacc[ option.value ] = option.help;\n\t\t\treturn acc;\n\t\t}, {} );\n\t}, [ options ] );\n\n\treturn (\n\t\t<ToolsPanelItem\n\t\t\tlabel={ __( 'Scale' ) }\n\t\t\tisShownByDefault={ isShownByDefault }\n\t\t\thasValue={ () => displayValue !== defaultValue }\n\t\t\tonDeselect={ () => onChange( defaultValue ) }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t<ToggleGroupControl\n\t\t\t\tlabel={ __( 'Scale' ) }\n\t\t\t\tisBlock\n\t\t\t\thelp={ scaleHelp[ displayValue ] }\n\t\t\t\tvalue={ displayValue }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t>\n\t\t\t\t{ options.map( ( option ) => (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ option.value }\n\t\t\t\t\t\t{ ...option }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ToggleGroupControl>\n\t\t</ToolsPanelItem>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,4BAA4B,IAAIC,cAAc,EAC9CC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,QAC5D,uBAAuB;AAC9B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;;AAExC;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,qBAAqB,GAAG,CAC7B;EACCC,KAAK,EAAE,MAAM;EACbC,KAAK,EAAEH,EAAE,CAAE,MAAM,EAAE,qCAAsC,CAAC;EAC1DI,IAAI,EAAEL,EAAE,CAAE,2CAA4C;AACvD,CAAC,EACD;EACCG,KAAK,EAAE,SAAS;EAChBC,KAAK,EAAEH,EAAE,CAAE,SAAS,EAAE,qCAAsC,CAAC;EAC7DI,IAAI,EAAEL,EAAE,CAAE,gDAAiD;AAC5D,CAAC,EACD;EACCG,KAAK,EAAE,OAAO;EACdC,KAAK,EAAEH,EAAE,CAAE,OAAO,EAAE,qCAAsC,CAAC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OAAO,EAAGA;EAAS,GAEnBU,aAAA,CAACrB,kBAAkB;IAClBQ,KAAK,EAAGJ,EAAE,CAAE,OAAQ,CAAG;IACvBoB,OAAO;IACPf,IAAI,EAAGQ,SAAS,CAAED,YAAY,CAAI;IAClCT,KAAK,EAAGS,YAAc;IACtBJ,QAAQ,EAAGA,QAAU;IACrBa,IAAI,EAAG;EAAoB,GAEzBZ,OAAO,CAACa,GAAG,CAAIN,MAAM,IACtBC,aAAA,CAACnB,wBAAwB;IACxByB,GAAG,EAAGP,MAAM,CAACb,KAAO;IAAA,GACfa;EAAM,CACX,CACA,CACiB,CACL,CAAC;AAEnB"}
|
|
@@ -8,14 +8,14 @@ import { __ } from '@wordpress/i18n';
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
|
-
import
|
|
11
|
+
import { useSettings } from '../use-settings';
|
|
12
12
|
export default function FontFamilyControl({
|
|
13
13
|
value = '',
|
|
14
14
|
onChange,
|
|
15
15
|
fontFamilies,
|
|
16
16
|
...props
|
|
17
17
|
}) {
|
|
18
|
-
const blockLevelFontFamilies =
|
|
18
|
+
const [blockLevelFontFamilies] = useSettings('typography.fontFamilies');
|
|
19
19
|
if (!fontFamilies) {
|
|
20
20
|
fontFamilies = blockLevelFontFamilies;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SelectControl","__","
|
|
1
|
+
{"version":3,"names":["SelectControl","__","useSettings","FontFamilyControl","value","onChange","fontFamilies","props","blockLevelFontFamilies","length","options","label","map","fontFamily","name","createElement","labelPosition"],"sources":["@wordpress/block-editor/src/components/font-family/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nexport default function FontFamilyControl( {\n\tvalue = '',\n\tonChange,\n\tfontFamilies,\n\t...props\n} ) {\n\tconst [ blockLevelFontFamilies ] = useSettings( 'typography.fontFamilies' );\n\tif ( ! fontFamilies ) {\n\t\tfontFamilies = blockLevelFontFamilies;\n\t}\n\n\tif ( ! fontFamilies || fontFamilies.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst options = [\n\t\t{ value: '', label: __( 'Default' ) },\n\t\t...fontFamilies.map( ( { fontFamily, name } ) => {\n\t\t\treturn {\n\t\t\t\tvalue: fontFamily,\n\t\t\t\tlabel: name || fontFamily,\n\t\t\t};\n\t\t} ),\n\t];\n\treturn (\n\t\t<SelectControl\n\t\t\tlabel={ __( 'Font' ) }\n\t\t\toptions={ options }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tlabelPosition=\"top\"\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,eAAe,SAASC,iBAAiBA,CAAE;EAC1CC,KAAK,GAAG,EAAE;EACVC,QAAQ;EACRC,YAAY;EACZ,GAAGC;AACJ,CAAC,EAAG;EACH,MAAM,CAAEC,sBAAsB,CAAE,GAAGN,WAAW,CAAE,yBAA0B,CAAC;EAC3E,IAAK,CAAEI,YAAY,EAAG;IACrBA,YAAY,GAAGE,sBAAsB;EACtC;EAEA,IAAK,CAAEF,YAAY,IAAIA,YAAY,CAACG,MAAM,KAAK,CAAC,EAAG;IAClD,OAAO,IAAI;EACZ;EAEA,MAAMC,OAAO,GAAG,CACf;IAAEN,KAAK,EAAE,EAAE;IAAEO,KAAK,EAAEV,EAAE,CAAE,SAAU;EAAE,CAAC,EACrC,GAAGK,YAAY,CAACM,GAAG,CAAE,CAAE;IAAEC,UAAU;IAAEC;EAAK,CAAC,KAAM;IAChD,OAAO;MACNV,KAAK,EAAES,UAAU;MACjBF,KAAK,EAAEG,IAAI,IAAID;IAChB,CAAC;EACF,CAAE,CAAC,CACH;EACD,OACCE,aAAA,CAACf,aAAa;IACbW,KAAK,EAAGV,EAAE,CAAE,MAAO,CAAG;IACtBS,OAAO,EAAGA,OAAS;IACnBN,KAAK,EAAGA,KAAO;IACfC,QAAQ,EAAGA,QAAU;IACrBW,aAAa,EAAC,KAAK;IAAA,GACdT;EAAK,CACV,CAAC;AAEJ"}
|
|
@@ -7,14 +7,13 @@ import { FontSizePicker as BaseFontSizePicker } from '@wordpress/components';
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
|
-
import
|
|
10
|
+
import { useSettings } from '../use-settings';
|
|
11
11
|
function FontSizePicker(props) {
|
|
12
|
-
const fontSizes =
|
|
13
|
-
const disableCustomFontSizes = !useSetting('typography.customFontSize');
|
|
12
|
+
const [fontSizes, customFontSize] = useSettings('typography.fontSizes', 'typography.customFontSize');
|
|
14
13
|
return createElement(BaseFontSizePicker, {
|
|
15
14
|
...props,
|
|
16
15
|
fontSizes: fontSizes,
|
|
17
|
-
disableCustomFontSizes:
|
|
16
|
+
disableCustomFontSizes: !customFontSize
|
|
18
17
|
});
|
|
19
18
|
}
|
|
20
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["FontSizePicker","BaseFontSizePicker","
|
|
1
|
+
{"version":3,"names":["FontSizePicker","BaseFontSizePicker","useSettings","props","fontSizes","customFontSize","createElement","disableCustomFontSizes"],"sources":["@wordpress/block-editor/src/components/font-sizes/font-size-picker.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FontSizePicker as BaseFontSizePicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../use-settings';\n\nfunction FontSizePicker( props ) {\n\tconst [ fontSizes, customFontSize ] = useSettings(\n\t\t'typography.fontSizes',\n\t\t'typography.customFontSize'\n\t);\n\n\treturn (\n\t\t<BaseFontSizePicker\n\t\t\t{ ...props }\n\t\t\tfontSizes={ fontSizes }\n\t\t\tdisableCustomFontSizes={ ! customFontSize }\n\t\t/>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/font-sizes/README.md\n */\nexport default FontSizePicker;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,cAAc,IAAIC,kBAAkB,QAAQ,uBAAuB;;AAE5E;AACA;AACA;AACA,SAASC,WAAW,QAAQ,iBAAiB;AAE7C,SAASF,cAAcA,CAAEG,KAAK,EAAG;EAChC,MAAM,CAAEC,SAAS,EAAEC,cAAc,CAAE,GAAGH,WAAW,CAChD,sBAAsB,EACtB,2BACD,CAAC;EAED,OACCI,aAAA,CAACL,kBAAkB;IAAA,GACbE,KAAK;IACVC,SAAS,EAAGA,SAAW;IACvBG,sBAAsB,EAAG,CAAEF;EAAgB,CAC3C,CAAC;AAEJ;;AAEA;AACA;AACA;AACA,eAAeL,cAAc"}
|
|
@@ -9,7 +9,7 @@ import { Component } from '@wordpress/element';
|
|
|
9
9
|
* Internal dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { getFontSize, getFontSizeClass } from './utils';
|
|
12
|
-
import
|
|
12
|
+
import { useSettings } from '../use-settings';
|
|
13
13
|
const DEFAULT_FONT_SIZES = [];
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -42,10 +42,10 @@ export default ((...fontSizeNames) => {
|
|
|
42
42
|
return fontSizeAttributeNamesAccumulator;
|
|
43
43
|
}, {});
|
|
44
44
|
return createHigherOrderComponent(compose([createHigherOrderComponent(WrappedComponent => props => {
|
|
45
|
-
const fontSizes =
|
|
45
|
+
const [fontSizes] = useSettings('typography.fontSizes');
|
|
46
46
|
return createElement(WrappedComponent, {
|
|
47
47
|
...props,
|
|
48
|
-
fontSizes: fontSizes
|
|
48
|
+
fontSizes: fontSizes || DEFAULT_FONT_SIZES
|
|
49
49
|
});
|
|
50
50
|
}, 'withFontSizes'), WrappedComponent => {
|
|
51
51
|
return class extends Component {
|