@wordpress/block-editor 11.7.0 → 12.0.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 +8 -0
- package/README.md +56 -57
- package/build/components/block-info-slot-fill/index.js +47 -0
- package/build/components/block-info-slot-fill/index.js.map +1 -0
- package/build/components/block-inspector/index.js +4 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/index.native.js +11 -21
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +3 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -9
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +1 -10
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-toolbar/index.js +2 -1
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +83 -9
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +11 -28
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/caption/index.native.js +0 -1
- package/build/components/caption/index.native.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/editor-styles/index.js +4 -3
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +21 -14
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +15 -59
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +12 -12
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.native.js +174 -0
- package/build/components/global-styles/color-panel.native.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +21 -20
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +244 -0
- package/build/components/global-styles/effects-panel.js.map +1 -0
- package/build/components/global-styles/filters-panel.js +215 -0
- package/build/components/global-styles/filters-panel.js.map +1 -0
- package/build/components/global-styles/get-block-css-selector.js +1 -12
- package/build/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build/components/global-styles/hooks.js +7 -0
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +28 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -9
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +100 -82
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +1 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-size-control/use-dimension-handler.js +5 -3
- package/build/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build/components/index.js +23 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -2
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +12 -7
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/index.js +2 -1
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/utils.js +5 -3
- package/build/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build/components/list-view/block-select-button.js +7 -2
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +13 -21
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +37 -10
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +31 -7
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -1
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-block-selection.js +1 -1
- package/build/components/list-view/use-block-selection.js.map +1 -1
- package/build/components/list-view/use-list-view-client-ids.js +7 -3
- package/build/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +8 -2
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-replace-flow/index.js +5 -5
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +12 -4
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +2 -7
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +6 -1
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +17 -14
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/resizable-box-popover/index.js +38 -0
- package/build/components/resizable-box-popover/index.js.map +1 -0
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +7 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/spacing-sizes-control/spacing-input-control.js +8 -0
- package/build/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build/hooks/anchor.js +1 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/duotone.js +121 -70
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/margin.js +27 -17
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +19 -9
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/utils.js +22 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/utils.js +3 -2
- package/build/layouts/utils.js.map +1 -1
- package/build/private-apis.js +13 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +8 -1
- package/build/store/actions.js.map +1 -1
- package/build/utils/object.js +6 -6
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -2
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build/utils/use-should-contextual-toolbar-show.js +68 -0
- package/build/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-module/components/block-info-slot-fill/index.js +34 -0
- package/build-module/components/block-info-slot-fill/index.js.map +1 -0
- package/build-module/components/block-inspector/index.js +3 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/index.native.js +11 -19
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +2 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -9
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +1 -9
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +2 -1
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +79 -9
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +10 -27
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/caption/index.native.js +0 -1
- package/build-module/components/caption/index.native.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/editor-styles/index.js +4 -3
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +21 -14
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +15 -59
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +13 -13
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.native.js +150 -0
- package/build-module/components/global-styles/color-panel.native.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +22 -21
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +228 -0
- package/build-module/components/global-styles/effects-panel.js.map +1 -0
- package/build-module/components/global-styles/filters-panel.js +201 -0
- package/build-module/components/global-styles/filters-panel.js.map +1 -0
- package/build-module/components/global-styles/get-block-css-selector.js +1 -12
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +7 -0
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +10 -10
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +101 -83
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/index.js +1 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-size-control/use-dimension-handler.js +5 -3
- package/build-module/components/image-size-control/use-dimension-handler.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +5 -2
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +12 -6
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -1
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +2 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/utils.js +4 -3
- package/build-module/components/inspector-controls-tabs/utils.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +7 -2
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +15 -22
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +36 -10
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +31 -8
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -1
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-block-selection.js +1 -1
- package/build-module/components/list-view/use-block-selection.js.map +1 -1
- package/build-module/components/list-view/use-list-view-client-ids.js +7 -3
- package/build-module/components/list-view/use-list-view-client-ids.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +8 -4
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +5 -5
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +12 -4
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +1 -5
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +5 -1
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +17 -14
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/resizable-box-popover/index.js +26 -0
- package/build-module/components/resizable-box-popover/index.js.map +1 -0
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +7 -10
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/spacing-sizes-control/spacing-input-control.js +7 -0
- package/build-module/components/spacing-sizes-control/spacing-input-control.js.map +1 -1
- package/build-module/hooks/anchor.js +1 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/duotone.js +118 -71
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/margin.js +29 -18
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +21 -10
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/utils.js +24 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/utils.js +3 -2
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/private-apis.js +9 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +8 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/utils/object.js +5 -5
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -2
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-module/utils/use-should-contextual-toolbar-show.js +56 -0
- package/build-module/utils/use-should-contextual-toolbar-show.js.map +1 -0
- package/build-style/content-rtl.css +9 -6
- package/build-style/content.css +9 -6
- package/build-style/style-rtl.css +272 -54
- package/build-style/style.css +272 -54
- package/package.json +32 -32
- package/src/components/block-info-slot-fill/index.js +24 -0
- package/src/components/block-inspector/index.js +3 -0
- package/src/components/block-inspector/style.scss +6 -4
- package/src/components/block-list/content.scss +16 -15
- package/src/components/block-list/index.native.js +19 -38
- package/src/components/block-list/use-in-between-inserter.js +4 -1
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +9 -9
- package/src/components/block-mover/style.scss +10 -4
- package/src/components/block-mover/test/index.native.js +4 -4
- package/src/components/block-popover/inbetween.js +2 -13
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -12
- package/src/components/block-toolbar/index.js +4 -3
- package/src/components/block-toolbar/style.scss +56 -33
- package/src/components/block-tools/block-contextual-toolbar.js +94 -11
- package/src/components/block-tools/selected-block-popover.js +11 -44
- package/src/components/block-tools/style.scss +157 -3
- package/src/components/caption/index.native.js +0 -1
- package/src/components/date-format-picker/index.js +1 -1
- package/src/components/editor-styles/index.js +9 -5
- package/src/components/font-sizes/fluid-utils.js +31 -14
- package/src/components/font-sizes/test/fluid-utils.js +5 -16
- package/src/components/global-styles/README.md +129 -16
- package/src/components/global-styles/border-panel.js +13 -61
- package/src/components/global-styles/color-panel.js +13 -13
- package/src/components/global-styles/color-panel.native.js +207 -0
- package/src/components/global-styles/dimensions-panel.js +47 -20
- package/src/components/global-styles/effects-panel.js +228 -0
- package/src/components/global-styles/filters-panel.js +230 -0
- package/src/components/global-styles/get-block-css-selector.js +0 -11
- package/src/components/global-styles/hooks.js +10 -0
- package/src/components/global-styles/index.js +2 -0
- package/src/components/global-styles/style.scss +43 -0
- package/src/components/global-styles/test/typography-utils.js +63 -22
- package/src/components/global-styles/test/use-global-styles-output.js +130 -8
- package/src/components/global-styles/typography-panel.js +37 -11
- package/src/components/global-styles/use-global-styles-output.js +88 -72
- package/src/components/iframe/index.js +1 -1
- package/src/components/image-size-control/use-dimension-handler.js +4 -3
- package/src/components/index.js +5 -1
- package/src/components/inserter/block-patterns-tab.js +3 -1
- package/src/components/inserter/block-types-tab.js +9 -6
- package/src/components/inserter/index.js +1 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/utils.js +4 -3
- package/src/components/list-view/README.md +2 -0
- package/src/components/list-view/block-select-button.js +6 -1
- package/src/components/list-view/block.js +24 -31
- package/src/components/list-view/drop-indicator.js +67 -22
- package/src/components/list-view/index.js +26 -3
- package/src/components/list-view/leaf.js +1 -0
- package/src/components/list-view/style.scss +18 -4
- package/src/components/list-view/test/use-list-view-drop-zone.js +188 -0
- package/src/components/list-view/use-block-selection.js +1 -1
- package/src/components/list-view/use-list-view-client-ids.js +5 -3
- package/src/components/list-view/use-list-view-drop-zone.js +9 -3
- package/src/components/media-replace-flow/README.md +3 -2
- package/src/components/media-replace-flow/index.js +4 -5
- package/src/components/navigable-toolbar/index.js +12 -3
- package/src/components/off-canvas-editor/appender.js +1 -4
- package/src/components/off-canvas-editor/block-contents.js +4 -0
- package/src/components/off-canvas-editor/index.js +15 -11
- package/src/components/resizable-box-popover/index.js +27 -0
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +2 -5
- package/src/components/spacing-sizes-control/spacing-input-control.js +10 -0
- package/src/components/spacing-sizes-control/style.scss +7 -7
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -3
- package/src/hooks/anchor.js +1 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/duotone.js +162 -99
- package/src/hooks/margin.js +31 -26
- package/src/hooks/padding.js +24 -18
- package/src/hooks/test/anchor.js +113 -0
- package/src/hooks/test/color.js +0 -9
- package/src/hooks/test/use-typography-props.js +2 -2
- package/src/hooks/test/utils.js +20 -101
- package/src/hooks/utils.js +23 -6
- package/src/layouts/utils.js +2 -2
- package/src/private-apis.js +8 -0
- package/src/store/actions.js +8 -1
- package/src/style.scss +1 -0
- package/src/utils/object.js +5 -5
- package/src/utils/test/object.js +53 -15
- package/src/utils/transform-styles/index.js +2 -2
- package/src/utils/use-should-contextual-toolbar-show.js +75 -0
- package/tsconfig.json +1 -0
- package/build/components/rich-text/use-native-props.js +0 -11
- package/build/components/rich-text/use-native-props.js.map +0 -1
- package/build/components/rich-text/use-native-props.native.js +0 -24
- package/build/components/rich-text/use-native-props.native.js.map +0 -1
- package/build/hooks/color-panel.native.js +0 -77
- package/build/hooks/color-panel.native.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.js +0 -4
- package/build-module/components/rich-text/use-native-props.js.map +0 -1
- package/build-module/components/rich-text/use-native-props.native.js +0 -15
- package/build-module/components/rich-text/use-native-props.native.js.map +0 -1
- package/build-module/hooks/color-panel.native.js +0 -62
- package/build-module/hooks/color-panel.native.js.map +0 -1
- package/src/components/rich-text/use-native-props.js +0 -3
- package/src/components/rich-text/use-native-props.native.js +0 -17
- package/src/hooks/color-panel.native.js +0 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/caption/index.native.js"],"names":["View","createBlock","RichText","__","Caption","accessibilityLabelCreator","accessible","inlineToolbar","isSelected","onBlur","onChange","onFocus","placeholder","placeholderTextColor","shouldDisplay","style","value","insertBlocksAfter","undefined","flex","display","fontSize"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,QAAT,QAAyB,yBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,MAAMC,OAAO,GAAG;AAAA,MAAE;AACjBC,IAAAA,yBADiB;AAEjBC,IAAAA,UAFiB;AAGjBC,IAAAA,aAHiB;AAIjBC,IAAAA,UAJiB;AAKjBC,IAAAA,MALiB;AAMjBC,IAAAA,QANiB;AAOjBC,IAAAA,OAPiB;AAQjBC,IAAAA,WAAW,GAAGT,EAAE,CAAE,aAAF,CARC;AASjBU,IAAAA,oBATiB;AAUjBC,IAAAA,aAAa,GAAG,IAVC;AAWjBC,IAAAA,KAXiB;AAYjBC,IAAAA,KAZiB;AAajBC,IAAAA,iBAAiB,GAAG,MAAM,CAAE;AAbX,GAAF;AAAA,SAef,cAAC,IAAD;AACC,IAAA,kBAAkB,EACjBZ,yBAAyB,GACtBA,yBAAyB,CAAEW,KAAF,CADH,GAEtBE,SAJL;AAMC,IAAA,iBAAiB,EAAC,QANnB;AAOC,IAAA,UAAU,EAAGZ,UAPd;AAQC,IAAA,KAAK,EAAG;AAAEa,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,OAAO,EAAEN,aAAa,GAAG,MAAH,GAAY;AAA7C;AART,KAUC,cAAC,QAAD;AACC,IAAA,8BAA8B,MAD/B;AAEC,IAAA,QAAQ,EAAGC,KAAK,IAAIA,KAAK,CAACM,QAAf,GAA0BN,KAAK,CAACM,QAAhC,GAA2C,EAFvD;AAGC,IAAA,aAAa,EAAGd,aAHjB;AAIC,IAAA,UAAU,EAAGC,UAJd;AAKC,IAAA,MAAM,EAAGC,MALV;AAMC,IAAA,QAAQ,EAAGC,QANZ;AAOC,IAAA,WAAW,EAAGE,WAPf;AAQC,IAAA,oBAAoB,EAAGC,oBARxB;AASC,IAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/caption/index.native.js"],"names":["View","createBlock","RichText","__","Caption","accessibilityLabelCreator","accessible","inlineToolbar","isSelected","onBlur","onChange","onFocus","placeholder","placeholderTextColor","shouldDisplay","style","value","insertBlocksAfter","undefined","flex","display","fontSize"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,QAAT,QAAyB,yBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;;AAEA,MAAMC,OAAO,GAAG;AAAA,MAAE;AACjBC,IAAAA,yBADiB;AAEjBC,IAAAA,UAFiB;AAGjBC,IAAAA,aAHiB;AAIjBC,IAAAA,UAJiB;AAKjBC,IAAAA,MALiB;AAMjBC,IAAAA,QANiB;AAOjBC,IAAAA,OAPiB;AAQjBC,IAAAA,WAAW,GAAGT,EAAE,CAAE,aAAF,CARC;AASjBU,IAAAA,oBATiB;AAUjBC,IAAAA,aAAa,GAAG,IAVC;AAWjBC,IAAAA,KAXiB;AAYjBC,IAAAA,KAZiB;AAajBC,IAAAA,iBAAiB,GAAG,MAAM,CAAE;AAbX,GAAF;AAAA,SAef,cAAC,IAAD;AACC,IAAA,kBAAkB,EACjBZ,yBAAyB,GACtBA,yBAAyB,CAAEW,KAAF,CADH,GAEtBE,SAJL;AAMC,IAAA,iBAAiB,EAAC,QANnB;AAOC,IAAA,UAAU,EAAGZ,UAPd;AAQC,IAAA,KAAK,EAAG;AAAEa,MAAAA,IAAI,EAAE,CAAR;AAAWC,MAAAA,OAAO,EAAEN,aAAa,GAAG,MAAH,GAAY;AAA7C;AART,KAUC,cAAC,QAAD;AACC,IAAA,8BAA8B,MAD/B;AAEC,IAAA,QAAQ,EAAGC,KAAK,IAAIA,KAAK,CAACM,QAAf,GAA0BN,KAAK,CAACM,QAAhC,GAA2C,EAFvD;AAGC,IAAA,aAAa,EAAGd,aAHjB;AAIC,IAAA,UAAU,EAAGC,UAJd;AAKC,IAAA,MAAM,EAAGC,MALV;AAMC,IAAA,QAAQ,EAAGC,QANZ;AAOC,IAAA,WAAW,EAAGE,WAPf;AAQC,IAAA,oBAAoB,EAAGC,oBARxB;AASC,IAAA,KAAK,EAAGE,KATT;AAUC,IAAA,OAAO,EAAC,GAVT;AAWC,IAAA,SAAS,EAAC,QAXX;AAYC,IAAA,qBAAqB,EAAC,aAZvB;AAaC,IAAA,eAAe,EAAGJ,OAbnB;AAcC,IAAA,KAAK,EAAGK,KAdT;AAeC,IAAA,sBAAsB,EAAG,MACxBC,iBAAiB,CAAEhB,WAAW,CAAE,gBAAF,CAAb,CAhBnB;AAkBC,IAAA,WAAW,EAAG;AAlBf,IAVD,CAfe;AAAA,CAAhB;;AAgDA,eAAeG,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { RichText } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\nconst Caption = ( {\n\taccessibilityLabelCreator,\n\taccessible,\n\tinlineToolbar,\n\tisSelected,\n\tonBlur,\n\tonChange,\n\tonFocus,\n\tplaceholder = __( 'Add caption' ),\n\tplaceholderTextColor,\n\tshouldDisplay = true,\n\tstyle,\n\tvalue,\n\tinsertBlocksAfter = () => {},\n} ) => (\n\t<View\n\t\taccessibilityLabel={\n\t\t\taccessibilityLabelCreator\n\t\t\t\t? accessibilityLabelCreator( value )\n\t\t\t\t: undefined\n\t\t}\n\t\taccessibilityRole=\"button\"\n\t\taccessible={ accessible }\n\t\tstyle={ { flex: 1, display: shouldDisplay ? 'flex' : 'none' } }\n\t>\n\t\t<RichText\n\t\t\t__unstableMobileNoFocusOnMount\n\t\t\tfontSize={ style && style.fontSize ? style.fontSize : 14 }\n\t\t\tinlineToolbar={ inlineToolbar }\n\t\t\tisSelected={ isSelected }\n\t\t\tonBlur={ onBlur }\n\t\t\tonChange={ onChange }\n\t\t\tplaceholder={ placeholder }\n\t\t\tplaceholderTextColor={ placeholderTextColor }\n\t\t\tstyle={ style }\n\t\t\ttagName=\"p\"\n\t\t\ttextAlign=\"center\"\n\t\t\tunderlineColorAndroid=\"transparent\"\n\t\t\tunstableOnFocus={ onFocus }\n\t\t\tvalue={ value }\n\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t}\n\t\t\tdeleteEnter={ true }\n\t\t/>\n\t</View>\n);\n\nexport default Caption;\n"]}
|
|
@@ -107,7 +107,7 @@ function NonDefaultControls(_ref2) {
|
|
|
107
107
|
hideLabelFromVision: true,
|
|
108
108
|
help: createInterpolateElement(__('Enter a date or time <Link>format string</Link>.'), {
|
|
109
109
|
Link: createElement(ExternalLink, {
|
|
110
|
-
href: __('https://wordpress.org/
|
|
110
|
+
href: __('https://wordpress.org/documentation/article/customize-date-and-time-format/')
|
|
111
111
|
})
|
|
112
112
|
}),
|
|
113
113
|
value: format,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/date-format-picker/index.js"],"names":["_x","__","dateI18n","useState","createInterpolateElement","TextControl","ExternalLink","VisuallyHidden","CustomSelectControl","ToggleControl","__experimentalVStack","VStack","EXAMPLE_DATE","Date","DateFormatPicker","format","defaultFormat","onChange","checked","NonDefaultControls","suggestedFormats","Set","suggestedOptions","map","suggestedFormat","index","key","name","customOption","className","__experimentalHint","isCustom","setIsCustom","includes","find","option","selectedItem","Link","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AACA,SAASC,QAAT,EAAmBC,wBAAnB,QAAmD,oBAAnD;AACA,SACCC,WADD,EAECC,Y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,IAAA,QAAQ,EAAG,SAAwB;AAAA,UAAtB;AAAEQ,QAAAA;AAAF,OAAsB;;AAClC,UAAKA,YAAY,KAAKR,YAAtB,EAAqC;AACpCI,QAAAA,WAAW,CAAE,IAAF,CAAX;AACA,OAFD,MAEO;AACNA,QAAAA,WAAW,CAAE,KAAF,CAAX;AACAf,QAAAA,QAAQ,CAAEmB,YAAY,CAACrB,MAAf,CAAR;AACA;AACD;AAlBF,IADD,EAqBGgB,QAAQ,IACT,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG9B,EAAE,CAAE,eAAF,CAFX;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,IAAI,EAAGG,wBAAwB,CAC9BH,EAAE,CACD,kDADC,CAD4B,EAI9B;AACCoC,MAAAA,IAAI,EACH,cAAC,YAAD;AACC,QAAA,IAAI,EAAGpC,EAAE,CACR,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/date-format-picker/index.js"],"names":["_x","__","dateI18n","useState","createInterpolateElement","TextControl","ExternalLink","VisuallyHidden","CustomSelectControl","ToggleControl","__experimentalVStack","VStack","EXAMPLE_DATE","Date","DateFormatPicker","format","defaultFormat","onChange","checked","NonDefaultControls","suggestedFormats","Set","suggestedOptions","map","suggestedFormat","index","key","name","customOption","className","__experimentalHint","isCustom","setIsCustom","includes","find","option","selectedItem","Link","value"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,QAAyB,iBAAzB;AACA,SAASC,QAAT,EAAmBC,wBAAnB,QAAmD,oBAAnD;AACA,SACCC,WADD,EAECC,YAFD,EAGCC,cAHD,EAICC,mBAJD,EAKCC,aALD,EAMCC,oBAAoB,IAAIC,MANzB,QAOO,uBAPP,C,CASA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,IAAIC,IAAJ,CAAU,IAAV,EAAgB,CAAhB,EAAmB,EAAnB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CAAE,KAAF,CAAX;AACAf,QAAAA,QAAQ,CAAEmB,YAAY,CAACrB,MAAf,CAAR;AACA;AACD;AAlBF,IADD,EAqBGgB,QAAQ,IACT,cAAC,WAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG9B,EAAE,CAAE,eAAF,CAFX;AAGC,IAAA,mBAAmB,MAHpB;AAIC,IAAA,IAAI,EAAGG,wBAAwB,CAC9BH,EAAE,CACD,kDADC,CAD4B,EAI9B;AACCoC,MAAAA,IAAI,EACH,cAAC,YAAD;AACC,QAAA,IAAI,EAAGpC,EAAE,CACR,6EADQ;AADV;AAFF,KAJ8B,CAJhC;AAkBC,IAAA,KAAK,EAAGc,MAlBT;AAmBC,IAAA,QAAQ,EAAKuB,KAAF,IAAarB,QAAQ,CAAEqB,KAAF;AAnBjC,IAtBF,CADD;AA+CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __ } from '@wordpress/i18n';\nimport { dateI18n } from '@wordpress/date';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport {\n\tTextControl,\n\tExternalLink,\n\tVisuallyHidden,\n\tCustomSelectControl,\n\tToggleControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n// So that we can illustrate the different formats in the dropdown properly,\n// show a date that has a day greater than 12 and a month with more than three\n// letters. Here we're using 2022-01-25 which is when WordPress 5.9 was\n// released.\nconst EXAMPLE_DATE = new Date( 2022, 0, 25 );\n\n/**\n * The `DateFormatPicker` component renders controls that let the user choose a\n * _date format_. That is, how they want their dates to be formatted.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md\n *\n * @param {Object} props\n * @param {string|null} props.format The selected date\n * format. If\n * `null`,\n * _Default_ is\n * selected.\n * @param {string} props.defaultFormat The date format that\n * will be used if the\n * user selects\n * 'Default'.\n * @param {( format: string|null ) => void} props.onChange Called when a\n * selection is\n * made. If `null`,\n * _Default_ is\n * selected.\n */\nexport default function DateFormatPicker( {\n\tformat,\n\tdefaultFormat,\n\tonChange,\n} ) {\n\treturn (\n\t\t<fieldset className=\"block-editor-date-format-picker\">\n\t\t\t<VisuallyHidden as=\"legend\">{ __( 'Date format' ) }</VisuallyHidden>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Default format' ) }\n\t\t\t\thelp={ `${ __( 'Example:' ) } ${ dateI18n(\n\t\t\t\t\tdefaultFormat,\n\t\t\t\t\tEXAMPLE_DATE\n\t\t\t\t) }` }\n\t\t\t\tchecked={ ! format }\n\t\t\t\tonChange={ ( checked ) =>\n\t\t\t\t\tonChange( checked ? null : defaultFormat )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ format && (\n\t\t\t\t<NonDefaultControls format={ format } onChange={ onChange } />\n\t\t\t) }\n\t\t</fieldset>\n\t);\n}\n\nfunction NonDefaultControls( { format, onChange } ) {\n\t// Suggest a short format, medium format, long format, and a standardised\n\t// (YYYY-MM-DD) format. The short, medium, and long formats are localised as\n\t// different languages have different ways of writing these. For example, 'F\n\t// j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April\n\t// 2022) in German (de). The resultant array is de-duplicated as some\n\t// languages will use the same format string for short, medium, and long\n\t// formats.\n\tconst suggestedFormats = [\n\t\t...new Set( [\n\t\t\t'Y-m-d',\n\t\t\t_x( 'n/j/Y', 'short date format' ),\n\t\t\t_x( 'n/j/Y g:i A', 'short date format with time' ),\n\t\t\t_x( 'M j, Y', 'medium date format' ),\n\t\t\t_x( 'M j, Y g:i A', 'medium date format with time' ),\n\t\t\t_x( 'F j, Y', 'long date format' ),\n\t\t\t_x( 'M j', 'short date format without the year' ),\n\t\t] ),\n\t];\n\n\tconst suggestedOptions = suggestedFormats.map(\n\t\t( suggestedFormat, index ) => ( {\n\t\t\tkey: `suggested-${ index }`,\n\t\t\tname: dateI18n( suggestedFormat, EXAMPLE_DATE ),\n\t\t\tformat: suggestedFormat,\n\t\t} )\n\t);\n\tconst customOption = {\n\t\tkey: 'custom',\n\t\tname: __( 'Custom' ),\n\t\tclassName:\n\t\t\t'block-editor-date-format-picker__custom-format-select-control__custom-option',\n\t\t__experimentalHint: __( 'Enter your own date format' ),\n\t};\n\n\tconst [ isCustom, setIsCustom ] = useState(\n\t\t() => !! format && ! suggestedFormats.includes( format )\n\t);\n\n\treturn (\n\t\t<VStack>\n\t\t\t<CustomSelectControl\n\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\tlabel={ __( 'Choose a format' ) }\n\t\t\t\toptions={ [ ...suggestedOptions, customOption ] }\n\t\t\t\tvalue={\n\t\t\t\t\tisCustom\n\t\t\t\t\t\t? customOption\n\t\t\t\t\t\t: suggestedOptions.find(\n\t\t\t\t\t\t\t\t( option ) => option.format === format\n\t\t\t\t\t\t ) ?? customOption\n\t\t\t\t}\n\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\tif ( selectedItem === customOption ) {\n\t\t\t\t\t\tsetIsCustom( true );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetIsCustom( false );\n\t\t\t\t\t\tonChange( selectedItem.format );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ isCustom && (\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Custom format' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Enter a date or time <Link>format string</Link>.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/customize-date-and-time-format/'\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}\n\t\t\t\t\t) }\n\t\t\t\t\tvalue={ format }\n\t\t\t\t\tonChange={ ( value ) => onChange( value ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"]}
|
|
@@ -63,10 +63,11 @@ export default function EditorStyles(_ref) {
|
|
|
63
63
|
let {
|
|
64
64
|
styles
|
|
65
65
|
} = _ref;
|
|
66
|
-
const
|
|
67
|
-
const
|
|
66
|
+
const stylesArray = useMemo(() => Object.values(styles !== null && styles !== void 0 ? styles : []), [styles]);
|
|
67
|
+
const transformedStyles = useMemo(() => transformStyles(stylesArray.filter(style => style === null || style === void 0 ? void 0 : style.css), EDITOR_STYLES_SELECTOR), [stylesArray]);
|
|
68
|
+
const transformedSvgs = useMemo(() => stylesArray.filter(style => style.__unstableType === 'svgs').map(style => style.assets).join(''), [stylesArray]);
|
|
68
69
|
return createElement(Fragment, null, createElement("style", {
|
|
69
|
-
ref: useDarkThemeBodyClassName(
|
|
70
|
+
ref: useDarkThemeBodyClassName(stylesArray)
|
|
70
71
|
}), transformedStyles.map((css, index) => createElement("style", {
|
|
71
72
|
key: index
|
|
72
73
|
}, css)), createElement(SVG, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;A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A,IAAI,CAACM,SAAL,CAAeS,MAAf,CAAuB,eAAvB;AACA,KALD,MAKO;AACNf,MAAAA,IAAI,CAACM,SAAL,CAAeC,GAAf,CAAoB,eAApB;AACA;AACD,GA1CgB,EA2CjB,CAAEX,MAAF,CA3CiB,CAAlB;AA6CA;;AAED,eAAe,SAASoB,YAAT,OAAoC;AAAA,MAAb;AAAEpB,IAAAA;AAAF,GAAa;AAClD,QAAMqB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","stylesArray","Object","values","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,8BAA5B;AAEA,MAAMC,sBAAsB,GAAG,wBAA/B;AACAP,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASM,yBAAT,CAAoCC,MAApC,EAA6C;AAC5C,SAAOL,WAAW,CACfM,IAAF,IAAY;AACX,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,IAA1B;AACA,UAAM;AAAEE,MAAAA,WAAF;AAAeC,MAAAA;AAAf,QAAwBF,aA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,MACCC,eAAe,CACdwB,WAAW,CAACI,MAAZ,CAAsBC,KAAF,IAAaA,KAAb,aAAaA,KAAb,uBAAaA,KAAK,CAAEC,GAAxC,CADc,EAEd7B,sBAFc,CAFgB,EAMhC,CAAEuB,WAAF,CANgC,CAAjC;AASA,QAAMO,eAAe,GAAGhC,OAAO,CAC9B,MACCyB,WAAW,CACTI,MADF,CACYC,KAAF,IAAaA,KAAK,CAACG,cAAN,KAAyB,MADhD,EAEEC,GAFF,CAESJ,KAAF,IAAaA,KAAK,CAACK,MAF1B,EAGEC,IAHF,CAGQ,EAHR,CAF6B,EAM9B,CAAEX,WAAF,CAN8B,CAA/B;AASA,SACC,8BAGC;AAAO,IAAA,GAAG,EAAGtB,yBAAyB,CAAEsB,WAAF;AAAtC,IAHD,EAIGG,iBAAiB,CAACM,GAAlB,CAAuB,CAAEH,GAAF,EAAOM,KAAP,KACxB;AAAO,IAAA,GAAG,EAAGA;AAAb,KAAuBN,GAAvB,CADC,CAJH,EAOC,cAAC,GAAD;AACC,IAAA,KAAK,EAAC,4BADP;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,KAAK,EAAC,GAHP;AAIC,IAAA,MAAM,EAAC,GAJR;AAKC,IAAA,IAAI,EAAC,MALN;AAMC,IAAA,KAAK,EAAG;AACPO,MAAAA,UAAU,EAAE,QADL;AAEPC,MAAAA,QAAQ,EAAE,UAFH;AAGPC,MAAAA,IAAI,EAAE,SAHC;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KANT;AAYC,IAAA,uBAAuB,EAAG;AAAEC,MAAAA,MAAM,EAAEV;AAAV;AAZ3B,IAPD,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { SVG } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport transformStyles from '../../utils/transform-styles';\n\nconst EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction useDarkThemeBodyClassName( styles ) {\n\treturn useCallback(\n\t\t( node ) => {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView, body } = ownerDocument;\n\t\t\tconst canvas = ownerDocument.querySelector(\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t);\n\n\t\t\tlet backgroundColor;\n\n\t\t\tif ( ! canvas ) {\n\t\t\t\t// The real .editor-styles-wrapper element might not exist in the\n\t\t\t\t// DOM, so calculate the background color by creating a fake\n\t\t\t\t// wrapper.\n\t\t\t\tconst tempCanvas = ownerDocument.createElement( 'div' );\n\t\t\t\ttempCanvas.classList.add( 'editor-styles-wrapper' );\n\t\t\t\tbody.appendChild( tempCanvas );\n\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t.getComputedStyle( tempCanvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\n\t\t\t\tbody.removeChild( tempCanvas );\n\t\t\t} else {\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t.getComputedStyle( canvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\t\t\t}\n\t\t\tconst colordBackgroundColor = colord( backgroundColor );\n\t\t\t// If background is transparent, it should be treated as light color.\n\t\t\tif (\n\t\t\t\tcolordBackgroundColor.luminance() > 0.5 ||\n\t\t\t\tcolordBackgroundColor.alpha() === 0\n\t\t\t) {\n\t\t\t\tbody.classList.remove( 'is-dark-theme' );\n\t\t\t} else {\n\t\t\t\tbody.classList.add( 'is-dark-theme' );\n\t\t\t}\n\t\t},\n\t\t[ styles ]\n\t);\n}\n\nexport default function EditorStyles( { styles } ) {\n\tconst stylesArray = useMemo(\n\t\t() => Object.values( styles ?? [] ),\n\t\t[ styles ]\n\t);\n\tconst transformedStyles = useMemo(\n\t\t() =>\n\t\t\ttransformStyles(\n\t\t\t\tstylesArray.filter( ( style ) => style?.css ),\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t),\n\t\t[ stylesArray ]\n\t);\n\n\tconst transformedSvgs = useMemo(\n\t\t() =>\n\t\t\tstylesArray\n\t\t\t\t.filter( ( style ) => style.__unstableType === 'svgs' )\n\t\t\t\t.map( ( style ) => style.assets )\n\t\t\t\t.join( '' ),\n\t\t[ stylesArray ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Use an empty style element to have a document reference,\n\t\t\t but this could be any element. */ }\n\t\t\t<style ref={ useDarkThemeBodyClassName( stylesArray ) } />\n\t\t\t{ transformedStyles.map( ( css, index ) => (\n\t\t\t\t<style key={ index }>{ css }</style>\n\t\t\t) ) }\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: transformedSvgs } }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -5,17 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
// Defaults.
|
|
7
7
|
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
|
|
8
|
-
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '
|
|
8
|
+
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';
|
|
9
9
|
const DEFAULT_SCALE_FACTOR = 1;
|
|
10
|
-
const
|
|
10
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
|
|
11
|
+
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
|
|
11
12
|
const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
12
13
|
/**
|
|
13
14
|
* Computes a fluid font-size value that uses clamp(). A minimum and maximum
|
|
14
15
|
* font size OR a single font size can be specified.
|
|
15
16
|
*
|
|
16
|
-
* If a single font size is specified, it is scaled up and down
|
|
17
|
-
* minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and
|
|
18
|
-
* maximum sizes.
|
|
17
|
+
* If a single font size is specified, it is scaled up and down using a logarithmic scale.
|
|
19
18
|
*
|
|
20
19
|
* @example
|
|
21
20
|
* ```js
|
|
@@ -31,14 +30,13 @@ const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
|
|
|
31
30
|
* ```
|
|
32
31
|
*
|
|
33
32
|
* @param {Object} args
|
|
34
|
-
* @param {?string} args.minimumViewPortWidth
|
|
35
|
-
* @param {?string} args.maximumViewPortWidth
|
|
36
|
-
* @param {string|number} [args.fontSize]
|
|
37
|
-
* @param {?string} args.maximumFontSize
|
|
38
|
-
* @param {?string} args.minimumFontSize
|
|
39
|
-
* @param {?number} args.scaleFactor
|
|
40
|
-
* @param {?
|
|
41
|
-
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
33
|
+
* @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
|
|
34
|
+
* @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
|
|
35
|
+
* @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
|
|
36
|
+
* @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
|
|
37
|
+
* @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
|
|
38
|
+
* @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
|
|
39
|
+
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
|
|
42
40
|
*
|
|
43
41
|
* @return {string|null} A font-size value using clamp().
|
|
44
42
|
*/
|
|
@@ -51,7 +49,6 @@ export function getComputedFluidTypographyValue(_ref) {
|
|
|
51
49
|
minimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
|
|
52
50
|
maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
|
|
53
51
|
scaleFactor = DEFAULT_SCALE_FACTOR,
|
|
54
|
-
minimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,
|
|
55
52
|
minimumFontSizeLimit
|
|
56
53
|
} = _ref;
|
|
57
54
|
// Validate incoming settings and set defaults.
|
|
@@ -96,6 +93,16 @@ export function getComputedFluidTypographyValue(_ref) {
|
|
|
96
93
|
|
|
97
94
|
|
|
98
95
|
if (!minimumFontSize) {
|
|
96
|
+
const fontSizeValueInPx = fontSizeParsed.unit === 'px' ? fontSizeParsed.value : fontSizeParsed.value * 16;
|
|
97
|
+
/*
|
|
98
|
+
* The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,
|
|
99
|
+
* that is, how quickly the size factor reaches 0 given increasing font size values.
|
|
100
|
+
* For a - b * log2(), lower values of b will make the curve move towards the minimum faster.
|
|
101
|
+
* The scale factor is constrained between min and max values.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
const minimumFontSizeFactor = Math.min(Math.max(1 - 0.075 * Math.log2(fontSizeValueInPx), DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN), DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX); // Calculates the minimum font size.
|
|
105
|
+
|
|
99
106
|
const calculatedMinimumFontSize = roundToPrecision(fontSizeParsed.value * minimumFontSizeFactor, 3); // Only use calculated min font size if it's > $minimum_font_size_limit value.
|
|
100
107
|
|
|
101
108
|
if (!!(minimumFontSizeLimitParsed !== null && minimumFontSizeLimitParsed !== void 0 && minimumFontSizeLimitParsed.value) && calculatedMinimumFontSize < (minimumFontSizeLimitParsed === null || minimumFontSizeLimitParsed === void 0 ? void 0 : minimumFontSizeLimitParsed.value)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","Math","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,gCAAgC,GAAG,IAAzC;AACA,MAAMC,+BAA+B,GAAG,MAAxC;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,OASH;AAAA,MAT6C;AAChDC,IAA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FM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASK,gBAAT,CAA2BF,KAA3B,EAA+C;AAAA,MAAb4B,MAAa,uEAAJ,CAAI;AACrD,QAAMC,IAAI,GAAGC,IAAI,CAACC,GAAL,CAAU,EAAV,EAAcH,MAAd,CAAb;AACA,SAAOI,MAAM,CAAChB,QAAP,CAAiBhB,KAAjB,IACJ2B,UAAU,CAAEG,IAAI,CAACG,KAAL,CAAYjC,KAAK,GAAG6B,IAApB,IAA6BA,IAA/B,CADN,GAEJK,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '768px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maximum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down by\n * minimumFontSizeFactor and maximumFontSizeFactor to arrive at the minimum and\n * maximum sizes.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?number} args.minimumFontSizeFactor How much to scale defaultFontSize by to derive minimumFontSize. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeFactor = DEFAULT_MINIMUM_FONT_SIZE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","fontSizeValueInPx","minimumFontSizeFactor","Math","min","max","log2","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,oCAAoC,GAAG,IAA7C;AACA,MAAMC,oCAAoC,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,QAAT,KAAuB,SAASF,IAAT,IAAiB,UAAUA,IAAlD,CAAL,EAAgE;AAC/DmC,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACA1B,IAAAA,IAAI,GAAGE,QAAP;AACA;;AAED,MAAK,SAASF,IAAT,KAAmB,SAASE,QAAT,IAAqB,UAAUA,QAAlD,CAAL,EAAoE;AACnEiC,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACA1B,IAAAA,IAAI,GAAGE,QAAP;AACA;AAED;AACD;AACA;AACA;AACA;;;AACC,MACC,CAAE,SAASA,QAAT,IAAqB,UAAUA,QAAjC,MACE,SAASF,IAAT,IAAiB,UAAUA,IAD7B,CADD,EAGE;AACDA,IAAAA,IAAI,GAAGE,QAAP;AACA;;AAED,SAAO;AACNC,IAAAA,KAAK,EAAEQ,gBAAgB,CAAEwB,WAAF,EAAe,CAAf,CADjB;AAENnC,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,gBAAT,CAA2BR,KAA3B,EAA+C;AAAA,MAAbkC,MAAa,uEAAJ,CAAI;AACrD,QAAMC,IAAI,GAAGhC,IAAI,CAACiC,GAAL,CAAU,EAAV,EAAcF,MAAd,CAAb;AACA,SAAOG,MAAM,CAACf,QAAP,CAAiBtB,KAAjB,IACJiC,UAAU,CAAE9B,IAAI,CAACmC,KAAL,CAAYtC,KAAK,GAAGmC,IAApB,IAA6BA,IAA/B,CADN,GAEJI,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maximum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down using a logarithmic scale.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst fontSizeValueInPx =\n\t\t\t\tfontSizeParsed.unit === 'px'\n\t\t\t\t\t? fontSizeParsed.value\n\t\t\t\t\t: fontSizeParsed.value * 16;\n\n\t\t\t/*\n\t\t\t * The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,\n\t\t\t * that is, how quickly the size factor reaches 0 given increasing font size values.\n\t\t\t * For a - b * log2(), lower values of b will make the curve move towards the minimum faster.\n\t\t\t * The scale factor is constrained between min and max values.\n\t\t\t */\n\t\t\tconst minimumFontSizeFactor = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1 - 0.075 * Math.log2( fontSizeValueInPx ),\n\t\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN\n\t\t\t\t),\n\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX\n\t\t\t);\n\n\t\t\t// Calculates the minimum font size.\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
|
|
@@ -42,37 +42,6 @@ function useHasBorderWidthControl(settings) {
|
|
|
42
42
|
return settings === null || settings === void 0 ? void 0 : (_settings$border4 = settings.border) === null || _settings$border4 === void 0 ? void 0 : _settings$border4.width;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function applyFallbackStyle(border) {
|
|
46
|
-
if (!border) {
|
|
47
|
-
return border;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (!border.style && (border.color || border.width)) {
|
|
51
|
-
return { ...border,
|
|
52
|
-
style: 'solid'
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return border;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function applyAllFallbackStyles(border) {
|
|
60
|
-
if (!border) {
|
|
61
|
-
return border;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (hasSplitBorders(border)) {
|
|
65
|
-
return {
|
|
66
|
-
top: applyFallbackStyle(border.top),
|
|
67
|
-
right: applyFallbackStyle(border.right),
|
|
68
|
-
bottom: applyFallbackStyle(border.bottom),
|
|
69
|
-
left: applyFallbackStyle(border.left)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return applyFallbackStyle(border);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
45
|
function BorderToolsPanel(_ref) {
|
|
77
46
|
let {
|
|
78
47
|
resetAllFilter,
|
|
@@ -209,39 +178,26 @@ export default function BorderPanel(_ref2) {
|
|
|
209
178
|
const onBorderChange = newBorder => {
|
|
210
179
|
// Ensure we have a visible border style when a border width or
|
|
211
180
|
// color is being selected.
|
|
212
|
-
const
|
|
213
|
-
// style properties have been set we need to force split border
|
|
214
|
-
// definitions for user set border styles. Border radius is derived
|
|
215
|
-
// from the same property i.e. `border.radius` if it is a string
|
|
216
|
-
// that is used. The longhand border radii styles are only generated
|
|
217
|
-
// if that property is an object.
|
|
218
|
-
//
|
|
219
|
-
// For borders (color, style, and width) those are all properties on
|
|
220
|
-
// the `border` style property. This means if the theme.json defined
|
|
221
|
-
// split borders and the user condenses them into a flat border or
|
|
222
|
-
// vice-versa we'd get both sets of styles which would conflict.
|
|
223
|
-
|
|
224
|
-
const updatedBorder = !hasSplitBorders(newBorderWithStyle) ? {
|
|
225
|
-
top: newBorderWithStyle,
|
|
226
|
-
right: newBorderWithStyle,
|
|
227
|
-
bottom: newBorderWithStyle,
|
|
228
|
-
left: newBorderWithStyle
|
|
229
|
-
} : {
|
|
230
|
-
color: null,
|
|
231
|
-
style: null,
|
|
232
|
-
width: null,
|
|
233
|
-
...newBorderWithStyle
|
|
181
|
+
const updatedBorder = { ...newBorder
|
|
234
182
|
};
|
|
235
|
-
['top', 'right', 'bottom', 'left'].forEach(side => {
|
|
236
|
-
var _updatedBorder$side;
|
|
237
183
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
184
|
+
if (hasSplitBorders(updatedBorder)) {
|
|
185
|
+
['top', 'right', 'bottom', 'left'].forEach(side => {
|
|
186
|
+
if (updatedBorder[side]) {
|
|
187
|
+
var _updatedBorder$side;
|
|
188
|
+
|
|
189
|
+
updatedBorder[side] = { ...updatedBorder[side],
|
|
190
|
+
color: encodeColorValue((_updatedBorder$side = updatedBorder[side]) === null || _updatedBorder$side === void 0 ? void 0 : _updatedBorder$side.color)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
} else if (updatedBorder) {
|
|
195
|
+
updatedBorder.color = encodeColorValue(updatedBorder.color);
|
|
196
|
+
} // As radius is maintained separately to color, style, and width
|
|
242
197
|
// maintain its value. Undefined values here will be cleaned when
|
|
243
198
|
// global styles are saved.
|
|
244
199
|
|
|
200
|
+
|
|
245
201
|
setBorder({
|
|
246
202
|
radius: border === null || border === void 0 ? void 0 : border.radius,
|
|
247
203
|
...updatedBorder
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","useMemo","__","BorderRadiusControl","useColorsPerOrigin","getValueFromVariable","useHasBorderPanel","settings","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","border","color","radius","style","width","applyFallbackStyle","applyAllFallbackStyles","top","right","bottom","left","BorderToolsPanel","resetAllFilter","onChange","value","panelId","children","resetAll","updatedValue","DEFAULT_CONTROLS","BorderPanel","as","Wrapper","inheritedValue","defaultControls","colors","decodeValue","rawValue","encodeColorValue","colorValue","allColors","flatMap","originColors","colorObject","find","slug","decodeColorValue","borderValue","forEach","side","undefined","setBorder","newBorder","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","newBorderRadius","hasBorderRadius","borderValues","Object","entries","resetBorder","onBorderChange","newBorderWithStyle","updatedBorder","previousValue","showBorderByDefault","newValue"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AACA,SAASC,kBAAT,QAAmC,SAAnC;AACA,SAASC,oBAAT,QAAqC,SAArC;AAEA,OAAO,SAASC,iBAAT,CAA4BC,QAA5B,EAAuC;AAC7C,QAAMC,QAAQ,GAAG,CAChBC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,mBAJpB;AAKC,IAAA,OAAO,EAAG5C;AALX,KAOC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGU,MADV;AAEC,IAAA,WAAW,EAAG,IAFf;AAGC,IAAA,WAAW,EAAGmB,eAHf;AAIC,IAAA,QAAQ,EAAGW,cAJZ;AAKC,IAAA,aAAa,EAAG,EALjB;AAMC,IAAA,gBAAgB,EAAC,YANlB;AAOC,IAAA,KAAK,EAAGvD,MAPT;AAQC,IAAA,iCAAiC,EAAG,IARrC;AASC,IAAA,IAAI,EAAG;AATR,IAPD,CAPF,EA2BG8C,gBAAgB,IACjB,cAAC,cAAD;AACC,IAAA,QAAQ,EAAGI,eADZ;AAEC,IAAA,KAAK,EAAG/D,EAAE,CAAE,QAAF,CAFX;AAGC,IAAA,UAAU,EAAG,MAAM6D,eAAe,CAAER,SAAF,CAHnC;AAIC,IAAA,gBAAgB,EAAGhB,eAAe,CAACtB,MAJpC;AAKC,IAAA,OAAO,EAAGa;AALX,KAOC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGgC,kBADV;AAEC,IAAA,QAAQ,EAAKa,QAAF,IAAgB;AAC1BZ,MAAAA,eAAe,CAAEY,QAAQ,IAAIpB,SAAd,CAAf;AACA;AAJF,IAPD,CA5BF,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalBorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { getValueFromVariable } from './utils';\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( settings ),\n\t\tuseHasBorderRadiusControl( settings ),\n\t\tuseHasBorderStyleControl( settings ),\n\t\tuseHasBorderWidthControl( settings ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction applyFallbackStyle( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( ! border.style && ( border.color || border.width ) ) {\n\t\treturn { ...border, style: 'solid' };\n\t}\n\n\treturn border;\n}\n\nfunction applyAllFallbackStyles( border ) {\n\tif ( ! border ) {\n\t\treturn border;\n\t}\n\n\tif ( hasSplitBorders( border ) ) {\n\t\treturn {\n\t\t\ttop: applyFallbackStyle( border.top ),\n\t\t\tright: applyFallbackStyle( border.right ),\n\t\t\tbottom: applyFallbackStyle( border.bottom ),\n\t\t\tleft: applyFallbackStyle( border.left ),\n\t\t};\n\t}\n\n\treturn applyFallbackStyle( border );\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n} ) {\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Border' ) }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\tconst decodeColorValue = useCallback(\n\t\t( colorValue ) => {\n\t\t\tconst allColors = colors.flatMap(\n\t\t\t\t( { colors: originColors } ) => originColors\n\t\t\t);\n\t\t\tconst colorObject = allColors.find(\n\t\t\t\t( { slug } ) => colorValue === 'var:preset|color|' + slug\n\t\t\t);\n\t\t\treturn colorObject ? colorObject.color : colorValue;\n\t\t},\n\t\t[ colors ]\n\t);\n\tconst border = useMemo( () => {\n\t\tif ( hasSplitBorders( inheritedValue?.border ) ) {\n\t\t\tconst borderValue = { ...inheritedValue?.border };\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tborderValue[ side ] = {\n\t\t\t\t\t...borderValue[ side ],\n\t\t\t\t\tcolor: decodeColorValue( borderValue[ side ]?.color ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn borderValue;\n\t\t}\n\t\treturn {\n\t\t\t...inheritedValue?.border,\n\t\t\tcolor: inheritedValue?.border?.color\n\t\t\t\t? decodeColorValue( inheritedValue?.border?.color )\n\t\t\t\t: undefined,\n\t\t};\n\t}, [ inheritedValue?.border, decodeColorValue ] );\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst borderRadiusValues = decodeValue( border?.radius );\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst newBorderWithStyle = applyAllFallbackStyles( newBorder );\n\n\t\t// As we can't conditionally generate styles based on if other\n\t\t// style properties have been set we need to force split border\n\t\t// definitions for user set border styles. Border radius is derived\n\t\t// from the same property i.e. `border.radius` if it is a string\n\t\t// that is used. The longhand border radii styles are only generated\n\t\t// if that property is an object.\n\t\t//\n\t\t// For borders (color, style, and width) those are all properties on\n\t\t// the `border` style property. This means if the theme.json defined\n\t\t// split borders and the user condenses them into a flat border or\n\t\t// vice-versa we'd get both sets of styles which would conflict.\n\t\tconst updatedBorder = ! hasSplitBorders( newBorderWithStyle )\n\t\t\t? {\n\t\t\t\t\ttop: newBorderWithStyle,\n\t\t\t\t\tright: newBorderWithStyle,\n\t\t\t\t\tbottom: newBorderWithStyle,\n\t\t\t\t\tleft: newBorderWithStyle,\n\t\t\t }\n\t\t\t: {\n\t\t\t\t\tcolor: null,\n\t\t\t\t\tstyle: null,\n\t\t\t\t\twidth: null,\n\t\t\t\t\t...newBorderWithStyle,\n\t\t\t };\n\n\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t...updatedBorder[ side ],\n\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t};\n\t\t} );\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/border-panel.js"],"names":["__experimentalBorderBoxControl","BorderBoxControl","__experimentalHasSplitBorders","hasSplitBorders","__experimentalIsDefinedBorder","isDefinedBorder","__experimentalToolsPanel","ToolsPanel","__experimentalToolsPanelItem","ToolsPanelItem","useCallback","useMemo","__","BorderRadiusControl","useColorsPerOrigin","getValueFromVariable","useHasBorderPanel","settings","controls","useHasBorderColorControl","useHasBorderRadiusControl","useHasBorderStyleControl","useHasBorderWidthControl","some","Boolean","border","color","radius","style","width","BorderToolsPanel","resetAllFilter","onChange","value","panelId","children","resetAll","updatedValue","DEFAULT_CONTROLS","BorderPanel","as","Wrapper","inheritedValue","defaultControls","colors","decodeValue","rawValue","encodeColorValue","colorValue","allColors","flatMap","originColors","colorObject","find","slug","decodeColorValue","borderValue","forEach","side","undefined","setBorder","newBorder","showBorderColor","showBorderStyle","showBorderWidth","showBorderRadius","borderRadiusValues","setBorderRadius","newBorderRadius","hasBorderRadius","borderValues","Object","entries","resetBorder","onBorderChange","updatedBorder","previousValue","showBorderByDefault","newValue"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,8BAA8B,IAAIC,gBADnC,EAECC,6BAA6B,IAAIC,eAFlC,EAGCC,6BAA6B,IAAIC,eAHlC,EAICC,wBAAwB,IAAIC,UAJ7B,EAKCC,4BAA4B,IAAIC,cALjC,QAMO,uBANP;AAOA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAC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BorderBoxControl as BorderBoxControl,\n\t__experimentalHasSplitBorders as hasSplitBorders,\n\t__experimentalIsDefinedBorder as isDefinedBorder,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BorderRadiusControl from '../border-radius-control';\nimport { useColorsPerOrigin } from './hooks';\nimport { getValueFromVariable } from './utils';\n\nexport function useHasBorderPanel( settings ) {\n\tconst controls = [\n\t\tuseHasBorderColorControl( settings ),\n\t\tuseHasBorderRadiusControl( settings ),\n\t\tuseHasBorderStyleControl( settings ),\n\t\tuseHasBorderWidthControl( settings ),\n\t];\n\n\treturn controls.some( Boolean );\n}\n\nfunction useHasBorderColorControl( settings ) {\n\treturn settings?.border?.color;\n}\n\nfunction useHasBorderRadiusControl( settings ) {\n\treturn settings?.border?.radius;\n}\n\nfunction useHasBorderStyleControl( settings ) {\n\treturn settings?.border?.style;\n}\n\nfunction useHasBorderWidthControl( settings ) {\n\treturn settings?.border?.width;\n}\n\nfunction BorderToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n} ) {\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Border' ) }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tradius: true,\n\tcolor: true,\n\twidth: true,\n};\n\nexport default function BorderPanel( {\n\tas: Wrapper = BorderToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst colors = useColorsPerOrigin( settings );\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\tconst encodeColorValue = ( colorValue ) => {\n\t\tconst allColors = colors.flatMap(\n\t\t\t( { colors: originColors } ) => originColors\n\t\t);\n\t\tconst colorObject = allColors.find(\n\t\t\t( { color } ) => color === colorValue\n\t\t);\n\t\treturn colorObject\n\t\t\t? 'var:preset|color|' + colorObject.slug\n\t\t\t: colorValue;\n\t};\n\tconst decodeColorValue = useCallback(\n\t\t( colorValue ) => {\n\t\t\tconst allColors = colors.flatMap(\n\t\t\t\t( { colors: originColors } ) => originColors\n\t\t\t);\n\t\t\tconst colorObject = allColors.find(\n\t\t\t\t( { slug } ) => colorValue === 'var:preset|color|' + slug\n\t\t\t);\n\t\t\treturn colorObject ? colorObject.color : colorValue;\n\t\t},\n\t\t[ colors ]\n\t);\n\tconst border = useMemo( () => {\n\t\tif ( hasSplitBorders( inheritedValue?.border ) ) {\n\t\t\tconst borderValue = { ...inheritedValue?.border };\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tborderValue[ side ] = {\n\t\t\t\t\t...borderValue[ side ],\n\t\t\t\t\tcolor: decodeColorValue( borderValue[ side ]?.color ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn borderValue;\n\t\t}\n\t\treturn {\n\t\t\t...inheritedValue?.border,\n\t\t\tcolor: inheritedValue?.border?.color\n\t\t\t\t? decodeColorValue( inheritedValue?.border?.color )\n\t\t\t\t: undefined,\n\t\t};\n\t}, [ inheritedValue?.border, decodeColorValue ] );\n\tconst setBorder = ( newBorder ) =>\n\t\tonChange( { ...value, border: newBorder } );\n\tconst showBorderColor = useHasBorderColorControl( settings );\n\tconst showBorderStyle = useHasBorderStyleControl( settings );\n\tconst showBorderWidth = useHasBorderWidthControl( settings );\n\n\t// Border radius.\n\tconst showBorderRadius = useHasBorderRadiusControl( settings );\n\tconst borderRadiusValues = decodeValue( border?.radius );\n\tconst setBorderRadius = ( newBorderRadius ) =>\n\t\tsetBorder( { ...border, radius: newBorderRadius } );\n\tconst hasBorderRadius = () => {\n\t\tconst borderValues = value?.border?.radius;\n\t\tif ( typeof borderValues === 'object' ) {\n\t\t\treturn Object.entries( borderValues ).some( Boolean );\n\t\t}\n\t\treturn !! borderValues;\n\t};\n\n\tconst resetBorder = () => {\n\t\tif ( hasBorderRadius() ) {\n\t\t\treturn setBorder( { radius: value?.border?.radius } );\n\t\t}\n\n\t\tsetBorder( undefined );\n\t};\n\n\tconst onBorderChange = ( newBorder ) => {\n\t\t// Ensure we have a visible border style when a border width or\n\t\t// color is being selected.\n\t\tconst updatedBorder = { ...newBorder };\n\n\t\tif ( hasSplitBorders( updatedBorder ) ) {\n\t\t\t[ 'top', 'right', 'bottom', 'left' ].forEach( ( side ) => {\n\t\t\t\tif ( updatedBorder[ side ] ) {\n\t\t\t\t\tupdatedBorder[ side ] = {\n\t\t\t\t\t\t...updatedBorder[ side ],\n\t\t\t\t\t\tcolor: encodeColorValue( updatedBorder[ side ]?.color ),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t} else if ( updatedBorder ) {\n\t\t\tupdatedBorder.color = encodeColorValue( updatedBorder.color );\n\t\t}\n\n\t\t// As radius is maintained separately to color, style, and width\n\t\t// maintain its value. Undefined values here will be cleaned when\n\t\t// global styles are saved.\n\t\tsetBorder( { radius: border?.radius, ...updatedBorder } );\n\t};\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tborder: undefined,\n\t\t};\n\t}, [] );\n\n\tconst showBorderByDefault =\n\t\tdefaultControls?.color || defaultControls?.width;\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ ( showBorderWidth || showBorderColor ) && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ () => isDefinedBorder( value?.border ) }\n\t\t\t\t\tlabel={ __( 'Border' ) }\n\t\t\t\t\tonDeselect={ () => resetBorder() }\n\t\t\t\t\tisShownByDefault={ showBorderByDefault }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderBoxControl\n\t\t\t\t\t\tcolors={ colors }\n\t\t\t\t\t\tenableAlpha={ true }\n\t\t\t\t\t\tenableStyle={ showBorderStyle }\n\t\t\t\t\t\tonChange={ onBorderChange }\n\t\t\t\t\t\tpopoverOffset={ 40 }\n\t\t\t\t\t\tpopoverPlacement=\"left-start\"\n\t\t\t\t\t\tvalue={ border }\n\t\t\t\t\t\t__experimentalIsRenderedInSidebar={ true }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ showBorderRadius && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\thasValue={ hasBorderRadius }\n\t\t\t\t\tlabel={ __( 'Radius' ) }\n\t\t\t\t\tonDeselect={ () => setBorderRadius( undefined ) }\n\t\t\t\t\tisShownByDefault={ defaultControls.radius }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<BorderRadiusControl\n\t\t\t\t\t\tvalues={ borderRadiusValues }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetBorderRadius( newValue || undefined );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"]}
|
|
@@ -19,7 +19,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
19
|
import ColorGradientControl from '../colors-gradients/control';
|
|
20
20
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
21
21
|
import { getValueFromVariable } from './utils';
|
|
22
|
-
import {
|
|
22
|
+
import { setImmutably } from '../../utils/object';
|
|
23
23
|
export function useHasColorPanel(settings) {
|
|
24
24
|
const hasTextPanel = useHasTextPanel(settings);
|
|
25
25
|
const hasBackgroundPanel = useHasBackgroundPanel(settings);
|
|
@@ -286,7 +286,7 @@ export default function ColorPanel(_ref7) {
|
|
|
286
286
|
const hasTextColor = () => !!userTextColor;
|
|
287
287
|
|
|
288
288
|
const setTextColor = newColor => {
|
|
289
|
-
onChange(
|
|
289
|
+
onChange(setImmutably(value, ['color', 'text'], encodeColorValue(newColor)));
|
|
290
290
|
};
|
|
291
291
|
|
|
292
292
|
const resetTextColor = () => setTextColor(undefined); // BackgroundColor
|
|
@@ -301,19 +301,19 @@ export default function ColorPanel(_ref7) {
|
|
|
301
301
|
const hasBackground = () => !!userBackgroundColor || !!userGradient;
|
|
302
302
|
|
|
303
303
|
const setBackgroundColor = newColor => {
|
|
304
|
-
const newValue =
|
|
304
|
+
const newValue = setImmutably(value, ['color', 'background'], encodeColorValue(newColor));
|
|
305
305
|
newValue.color.gradient = undefined;
|
|
306
306
|
onChange(newValue);
|
|
307
307
|
};
|
|
308
308
|
|
|
309
309
|
const setGradient = newGradient => {
|
|
310
|
-
const newValue =
|
|
310
|
+
const newValue = setImmutably(value, ['color', 'gradient'], encodeGradientValue(newGradient));
|
|
311
311
|
newValue.color.background = undefined;
|
|
312
312
|
onChange(newValue);
|
|
313
313
|
};
|
|
314
314
|
|
|
315
315
|
const resetBackground = () => {
|
|
316
|
-
const newValue =
|
|
316
|
+
const newValue = setImmutably(value, ['color', 'background'], undefined);
|
|
317
317
|
newValue.color.gradient = undefined;
|
|
318
318
|
onChange(newValue);
|
|
319
319
|
}; // Links
|
|
@@ -324,21 +324,21 @@ export default function ColorPanel(_ref7) {
|
|
|
324
324
|
const userLinkColor = decodeValue(value === null || value === void 0 ? void 0 : (_value$elements = value.elements) === null || _value$elements === void 0 ? void 0 : (_value$elements$link = _value$elements.link) === null || _value$elements$link === void 0 ? void 0 : (_value$elements$link$ = _value$elements$link.color) === null || _value$elements$link$ === void 0 ? void 0 : _value$elements$link$.text);
|
|
325
325
|
|
|
326
326
|
const setLinkColor = newColor => {
|
|
327
|
-
onChange(
|
|
327
|
+
onChange(setImmutably(value, ['elements', 'link', 'color', 'text'], encodeColorValue(newColor)));
|
|
328
328
|
};
|
|
329
329
|
|
|
330
330
|
const hoverLinkColor = decodeValue(inheritedValue === null || inheritedValue === void 0 ? void 0 : (_inheritedValue$eleme4 = inheritedValue.elements) === null || _inheritedValue$eleme4 === void 0 ? void 0 : (_inheritedValue$eleme5 = _inheritedValue$eleme4.link) === null || _inheritedValue$eleme5 === void 0 ? void 0 : (_inheritedValue$eleme6 = _inheritedValue$eleme5[':hover']) === null || _inheritedValue$eleme6 === void 0 ? void 0 : (_inheritedValue$eleme7 = _inheritedValue$eleme6.color) === null || _inheritedValue$eleme7 === void 0 ? void 0 : _inheritedValue$eleme7.text);
|
|
331
331
|
const userHoverLinkColor = decodeValue(value === null || value === void 0 ? void 0 : (_value$elements2 = value.elements) === null || _value$elements2 === void 0 ? void 0 : (_value$elements2$link = _value$elements2.link) === null || _value$elements2$link === void 0 ? void 0 : (_value$elements2$link2 = _value$elements2$link[':hover']) === null || _value$elements2$link2 === void 0 ? void 0 : (_value$elements2$link3 = _value$elements2$link2.color) === null || _value$elements2$link3 === void 0 ? void 0 : _value$elements2$link3.text);
|
|
332
332
|
|
|
333
333
|
const setHoverLinkColor = newColor => {
|
|
334
|
-
onChange(
|
|
334
|
+
onChange(setImmutably(value, ['elements', 'link', ':hover', 'color', 'text'], encodeColorValue(newColor)));
|
|
335
335
|
};
|
|
336
336
|
|
|
337
337
|
const hasLink = () => !!userLinkColor || !!userHoverLinkColor;
|
|
338
338
|
|
|
339
339
|
const resetLink = () => {
|
|
340
|
-
let newValue =
|
|
341
|
-
newValue =
|
|
340
|
+
let newValue = setImmutably(value, ['elements', 'link', ':hover', 'color', 'text'], undefined);
|
|
341
|
+
newValue = setImmutably(newValue, ['elements', 'link', 'color', 'text'], undefined);
|
|
342
342
|
onChange(newValue);
|
|
343
343
|
}; // Elements
|
|
344
344
|
|
|
@@ -479,24 +479,24 @@ export default function ColorPanel(_ref7) {
|
|
|
479
479
|
const hasElement = () => !!(elementTextUserColor || elementBackgroundUserColor || elementGradientUserColor);
|
|
480
480
|
|
|
481
481
|
const resetElement = () => {
|
|
482
|
-
const newValue =
|
|
482
|
+
const newValue = setImmutably(value, ['elements', name, 'color', 'background'], undefined);
|
|
483
483
|
newValue.elements[name].color.gradient = undefined;
|
|
484
484
|
newValue.elements[name].color.text = undefined;
|
|
485
485
|
onChange(newValue);
|
|
486
486
|
};
|
|
487
487
|
|
|
488
488
|
const setElementTextColor = newTextColor => {
|
|
489
|
-
onChange(
|
|
489
|
+
onChange(setImmutably(value, ['elements', name, 'color', 'text'], encodeColorValue(newTextColor)));
|
|
490
490
|
};
|
|
491
491
|
|
|
492
492
|
const setElementBackgroundColor = newBackgroundColor => {
|
|
493
|
-
const newValue =
|
|
493
|
+
const newValue = setImmutably(value, ['elements', name, 'color', 'background'], encodeColorValue(newBackgroundColor));
|
|
494
494
|
newValue.elements[name].color.gradient = undefined;
|
|
495
495
|
onChange(newValue);
|
|
496
496
|
};
|
|
497
497
|
|
|
498
498
|
const setElementGradient = newGradient => {
|
|
499
|
-
const newValue =
|
|
499
|
+
const newValue = setImmutably(value, ['elements', name, 'color', 'gradient'], encodeGradientValue(newGradient));
|
|
500
500
|
newValue.elements[name].color.background = undefined;
|
|
501
501
|
onChange(newValue);
|
|
502
502
|
};
|