@wordpress/block-editor 15.22.1-next.v.202606191442.0 → 15.23.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 +3 -1
- package/README.md +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +50 -51
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +0 -3
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +75 -31
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/link-control/index.cjs +1 -2
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/use-resize-canvas/index.cjs +16 -53
- package/build/components/use-resize-canvas/index.cjs.map +3 -3
- package/build/hooks/anchor.cjs +0 -1
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +38 -8
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/states.cjs +15 -23
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +8 -4
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +0 -1
- package/build/private-apis.cjs.map +2 -2
- package/build/store/private-actions.cjs +16 -0
- package/build/store/private-actions.cjs.map +2 -2
- package/build/store/private-keys.cjs +0 -3
- package/build/store/private-keys.cjs.map +2 -2
- package/build/store/private-selectors.cjs +24 -6
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +19 -3
- package/build/store/reducer.cjs.map +2 -2
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +2 -1
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +50 -51
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +0 -3
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +75 -31
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/link-control/index.mjs +1 -2
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/use-resize-canvas/index.mjs +6 -53
- package/build-module/components/use-resize-canvas/index.mjs.map +2 -2
- package/build-module/hooks/anchor.mjs +0 -1
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +41 -8
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/states.mjs +15 -23
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +9 -5
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +14 -0
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-keys.mjs +0 -2
- package/build-module/store/private-keys.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +22 -6
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +17 -3
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +2 -1
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +40 -39
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +43 -53
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +0 -3
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +74 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -17
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/components/use-resize-canvas/index.js +10 -71
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +51 -12
- package/src/hooks/layout.js +6 -3
- package/src/hooks/states.js +32 -28
- package/src/hooks/style.js +11 -7
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +8 -8
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +0 -2
- package/src/store/private-actions.js +31 -0
- package/src/store/private-keys.js +0 -1
- package/src/store/private-selectors.js +43 -7
- package/src/store/reducer.js +37 -2
- package/src/store/test/private-selectors.js +39 -14
- package/src/store/test/reducer.js +91 -12
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/components/use-resize-canvas/README.md +0 -37
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
const DEFAULT_ATTRIBUTE = '__default';
|
|
2
|
-
const PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Checks if the block has the `__default` binding for pattern overrides.
|
|
6
|
-
*
|
|
7
|
-
* @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.
|
|
8
|
-
*
|
|
9
|
-
* @return {boolean} Whether the block has the `__default` binding for pattern overrides.
|
|
10
|
-
*/
|
|
11
|
-
export function hasPatternOverridesDefaultBinding( bindings ) {
|
|
12
|
-
return bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Returns the bindings with the `__default` binding for pattern overrides
|
|
17
|
-
* replaced with the full-set of supported attributes. e.g.:
|
|
18
|
-
*
|
|
19
|
-
* - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`
|
|
20
|
-
* - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`
|
|
21
|
-
*
|
|
22
|
-
* @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.
|
|
23
|
-
* @param {string[]} supportedAttributes The block's attributes which are supported by block bindings.
|
|
24
|
-
*
|
|
25
|
-
* @return {Object} The bindings with default replaced for pattern overrides.
|
|
26
|
-
*/
|
|
27
|
-
export function replacePatternOverridesDefaultBinding(
|
|
28
|
-
bindings,
|
|
29
|
-
supportedAttributes
|
|
30
|
-
) {
|
|
31
|
-
// The `__default` binding currently only works for pattern overrides.
|
|
32
|
-
if ( hasPatternOverridesDefaultBinding( bindings ) ) {
|
|
33
|
-
const bindingsWithDefaults = {};
|
|
34
|
-
for ( const attributeName of supportedAttributes ) {
|
|
35
|
-
// If the block has mixed binding sources, retain any non pattern override bindings.
|
|
36
|
-
const bindingSource = bindings[ attributeName ]
|
|
37
|
-
? bindings[ attributeName ]
|
|
38
|
-
: { source: PATTERN_OVERRIDES_SOURCE };
|
|
39
|
-
bindingsWithDefaults[ attributeName ] = bindingSource;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return bindingsWithDefaults;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return bindings;
|
|
46
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts the palette slug from a style value for any preset type, supporting
|
|
3
|
-
* both the user preset format and the theme CSS-variable format:
|
|
4
|
-
*
|
|
5
|
-
* - User format: `var:preset|<type>|slug`
|
|
6
|
-
* - Theme format: `var(--wp--preset--<type>--slug)`
|
|
7
|
-
*
|
|
8
|
-
* Returns `undefined` for plain values, non-strings, or any other
|
|
9
|
-
* unrecognised format.
|
|
10
|
-
*
|
|
11
|
-
* @param {*} rawValue Raw style value stored in the style object.
|
|
12
|
-
* @param {'color'|'gradient'} type Preset type, e.g. `'color'` or `'gradient'`.
|
|
13
|
-
* @return {string|undefined} The palette slug, or undefined.
|
|
14
|
-
*/
|
|
15
|
-
export function extractPresetSlug( rawValue, type ) {
|
|
16
|
-
if ( typeof rawValue !== 'string' ) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const userPrefix = `var:preset|${ type }|`;
|
|
20
|
-
if ( rawValue.startsWith( userPrefix ) ) {
|
|
21
|
-
return rawValue.slice( userPrefix.length );
|
|
22
|
-
}
|
|
23
|
-
const cssVarPrefix = `--wp--preset--${ type }--`;
|
|
24
|
-
const themeFormatMatch = rawValue.match(
|
|
25
|
-
new RegExp( `^var\\(${ cssVarPrefix }([^)]+)\\)$` )
|
|
26
|
-
);
|
|
27
|
-
return themeFormatMatch?.[ 1 ];
|
|
28
|
-
}
|
package/src/utils/object.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Immutably sets a value inside an object. Like `lodash#set`, but returning a
|
|
3
|
-
* new object. Treats nullish initial values as empty objects. Clones any
|
|
4
|
-
* nested objects. Supports arrays, too.
|
|
5
|
-
*
|
|
6
|
-
* @param {Object} object Object to set a value in.
|
|
7
|
-
* @param {number|string|Array} path Path in the object to modify.
|
|
8
|
-
* @param {*} value New value to set.
|
|
9
|
-
* @return {Object} Cloned object with the new value set.
|
|
10
|
-
*/
|
|
11
|
-
export function setImmutably( object, path, value ) {
|
|
12
|
-
// Normalize path
|
|
13
|
-
path = Array.isArray( path ) ? [ ...path ] : [ path ];
|
|
14
|
-
|
|
15
|
-
// Shallowly clone the base of the object
|
|
16
|
-
object = Array.isArray( object ) ? [ ...object ] : { ...object };
|
|
17
|
-
|
|
18
|
-
const leaf = path.pop();
|
|
19
|
-
|
|
20
|
-
// Traverse object from root to leaf, shallowly cloning at each level
|
|
21
|
-
let prev = object;
|
|
22
|
-
for ( const key of path ) {
|
|
23
|
-
const lvl = prev[ key ];
|
|
24
|
-
prev = prev[ key ] = Array.isArray( lvl ) ? [ ...lvl ] : { ...lvl };
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
prev[ leaf ] = value;
|
|
28
|
-
|
|
29
|
-
return object;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Helper util to return a value from a certain path of the object.
|
|
34
|
-
* Path is specified as either:
|
|
35
|
-
* - a string of properties, separated by dots, for example: "x.y".
|
|
36
|
-
* - an array of properties, for example `[ 'x', 'y' ]`.
|
|
37
|
-
* You can also specify a default value in case the result is nullish.
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} object Input object.
|
|
40
|
-
* @param {string|Array} path Path to the object property.
|
|
41
|
-
* @param {*} defaultValue Default value if the value at the specified path is nullish.
|
|
42
|
-
* @return {*} Value of the object property at the specified path.
|
|
43
|
-
*/
|
|
44
|
-
export const getValueFromObjectPath = ( object, path, defaultValue ) => {
|
|
45
|
-
const arrayPath = Array.isArray( path ) ? path : path.split( '.' );
|
|
46
|
-
let value = object;
|
|
47
|
-
arrayPath.forEach( ( fieldName ) => {
|
|
48
|
-
value = value?.[ fieldName ];
|
|
49
|
-
} );
|
|
50
|
-
return value ?? defaultValue;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Helper util to filter out objects with duplicate values for a given property.
|
|
55
|
-
*
|
|
56
|
-
* @param {Object[]} array Array of objects to filter.
|
|
57
|
-
* @param {string} property Property to filter unique values by.
|
|
58
|
-
*
|
|
59
|
-
* @return {Object[]} Array of objects with unique values for the specified property.
|
|
60
|
-
*/
|
|
61
|
-
export function uniqByProperty( array, property ) {
|
|
62
|
-
const seen = new Set();
|
|
63
|
-
return array.filter( ( item ) => {
|
|
64
|
-
const value = item[ property ];
|
|
65
|
-
return seen.has( value ) ? false : seen.add( value );
|
|
66
|
-
} );
|
|
67
|
-
}
|
package/src/utils/sorting.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recursive stable sorting comparator function.
|
|
3
|
-
*
|
|
4
|
-
* @param {string|Function} field Field to sort by.
|
|
5
|
-
* @param {Array} items Items to sort.
|
|
6
|
-
* @param {string} order Order, 'asc' or 'desc'.
|
|
7
|
-
* @return {Function} Comparison function to be used in a `.sort()`.
|
|
8
|
-
*/
|
|
9
|
-
const comparator = ( field, items, order ) => {
|
|
10
|
-
return ( a, b ) => {
|
|
11
|
-
let cmpA, cmpB;
|
|
12
|
-
|
|
13
|
-
if ( typeof field === 'function' ) {
|
|
14
|
-
cmpA = field( a );
|
|
15
|
-
cmpB = field( b );
|
|
16
|
-
} else {
|
|
17
|
-
cmpA = a[ field ];
|
|
18
|
-
cmpB = b[ field ];
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if ( cmpA > cmpB ) {
|
|
22
|
-
return order === 'asc' ? 1 : -1;
|
|
23
|
-
} else if ( cmpB > cmpA ) {
|
|
24
|
-
return order === 'asc' ? -1 : 1;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const orderA = items.findIndex( ( item ) => item === a );
|
|
28
|
-
const orderB = items.findIndex( ( item ) => item === b );
|
|
29
|
-
|
|
30
|
-
// Stable sort: maintaining original array order
|
|
31
|
-
if ( orderA > orderB ) {
|
|
32
|
-
return 1;
|
|
33
|
-
} else if ( orderB > orderA ) {
|
|
34
|
-
return -1;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return 0;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Order items by a certain key.
|
|
43
|
-
* Supports decorator functions that allow complex picking of a comparison field.
|
|
44
|
-
* Sorts in ascending order by default, but supports descending as well.
|
|
45
|
-
* Stable sort - maintains original order of equal items.
|
|
46
|
-
*
|
|
47
|
-
* @param {Array} items Items to order.
|
|
48
|
-
* @param {string|Function} field Field to order by.
|
|
49
|
-
* @param {string} order Sorting order, `asc` or `desc`.
|
|
50
|
-
* @return {Array} Sorted items.
|
|
51
|
-
*/
|
|
52
|
-
export function orderBy( items, field, order = 'asc' ) {
|
|
53
|
-
return items.concat().sort( comparator( field, items, order ) );
|
|
54
|
-
}
|
|
File without changes
|
|
File without changes
|