@wordpress/block-editor 11.6.0 → 11.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +4 -0
- package/build/components/block-list/block-html.js +1 -3
- package/build/components/block-list/block-html.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -23
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/editor-styles/index.js +20 -2
- package/build/components/editor-styles/index.js.map +1 -1
- package/build/components/global-styles/color-panel.js +583 -0
- package/build/components/global-styles/color-panel.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +8 -30
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-block-css-selector.js +129 -0
- package/build/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build/components/global-styles/hooks.js +53 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +18 -2
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +9 -35
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +160 -86
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -1
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/image-size-control/index.js +8 -5
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +43 -7
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/line-height-control/index.js +15 -1
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/list-view/appender.js +105 -0
- package/build/components/list-view/appender.js.map +1 -0
- package/build/components/list-view/block.js +5 -5
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +25 -5
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/index.js +37 -13
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +13 -4
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/format-edit.js +2 -30
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/writing-flow/use-input.js +4 -8
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +92 -229
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +4 -2
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/{color-panel.js → contrast-checker.js} +11 -49
- package/build/hooks/contrast-checker.js.map +1 -0
- package/build/hooks/dimensions.js +0 -1
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +3 -1
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +23 -26
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/typography.js +0 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +25 -76
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +165 -0
- package/build/layouts/grid.js.map +1 -0
- package/build/layouts/index.js +3 -1
- package/build/layouts/index.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/utils/object.js +76 -0
- package/build/utils/object.js.map +1 -0
- package/build-module/components/block-list/block-html.js +1 -3
- package/build-module/components/block-list/block-html.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -22
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/editor-styles/index.js +19 -2
- package/build-module/components/editor-styles/index.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +554 -0
- package/build-module/components/global-styles/color-panel.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +7 -30
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-block-css-selector.js +120 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +51 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +3 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +8 -35
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +161 -87
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -1
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/image-size-control/index.js +8 -5
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +42 -7
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/line-height-control/index.js +15 -1
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/list-view/appender.js +88 -0
- package/build-module/components/list-view/appender.js.map +1 -0
- package/build-module/components/list-view/block.js +5 -4
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +22 -5
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/index.js +32 -12
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +12 -4
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +3 -31
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +4 -8
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +90 -232
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +4 -2
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/{color-panel.js → contrast-checker.js} +10 -44
- package/build-module/hooks/contrast-checker.js.map +1 -0
- package/build-module/hooks/dimensions.js +0 -1
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +4 -2
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/position.js +3 -3
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +23 -26
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/typography.js +0 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +23 -73
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +151 -0
- package/build-module/layouts/grid.js.map +1 -0
- package/build-module/layouts/index.js +2 -1
- package/build-module/layouts/index.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/utils/object.js +69 -0
- package/build-module/utils/object.js.map +1 -0
- package/build-style/style-rtl.css +26 -6
- package/build-style/style.css +26 -6
- package/package.json +31 -31
- package/src/components/block-draggable/content.scss +1 -1
- package/src/components/block-list/block-html.js +1 -1
- package/src/components/block-preview/auto.js +2 -17
- package/src/components/colors-gradients/style.scss +8 -8
- package/src/components/editor-styles/index.js +29 -1
- package/src/components/global-styles/color-panel.js +706 -0
- package/src/components/global-styles/dimensions-panel.js +13 -42
- package/src/components/global-styles/get-block-css-selector.js +129 -0
- package/src/components/global-styles/hooks.js +80 -0
- package/src/components/global-styles/index.js +2 -1
- package/src/components/global-styles/test/use-global-styles-output.js +30 -1
- package/src/components/global-styles/typography-panel.js +26 -51
- package/src/components/global-styles/use-global-styles-output.js +163 -80
- package/src/components/global-styles/utils.js +3 -0
- package/src/components/image-size-control/index.js +4 -3
- package/src/components/image-size-control/test/index.js +2 -2
- package/src/components/inner-blocks/README.md +1 -1
- package/src/components/inspector-controls-tabs/position-controls-panel.js +40 -9
- package/src/components/line-height-control/index.js +10 -1
- package/src/components/list-view/appender.js +101 -0
- package/src/components/list-view/block.js +5 -4
- package/src/components/list-view/branch.js +30 -1
- package/src/components/list-view/index.js +43 -10
- package/src/components/list-view/style.scss +19 -0
- package/src/components/media-replace-flow/index.js +36 -24
- package/src/components/media-replace-flow/style.scss +5 -2
- package/src/components/rich-text/format-edit.js +2 -32
- package/src/components/writing-flow/use-input.js +4 -5
- package/src/hooks/border.js +0 -1
- package/src/hooks/color.js +120 -296
- package/src/hooks/content-lock-ui.js +6 -2
- package/src/hooks/{color-panel.js → contrast-checker.js} +10 -46
- package/src/hooks/dimensions.js +0 -1
- package/src/hooks/duotone.js +8 -5
- package/src/hooks/position.js +3 -3
- package/src/hooks/style.js +29 -28
- package/src/hooks/test/utils.js +0 -104
- package/src/hooks/typography.js +0 -1
- package/src/hooks/utils.js +27 -70
- package/src/layouts/grid.js +172 -0
- package/src/layouts/index.js +2 -1
- package/src/layouts/test/grid.js +21 -0
- package/src/private-apis.js +2 -0
- package/src/utils/object.js +69 -0
- package/src/utils/test/object.js +107 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/color-panel.js.map +0 -1
- package/build-module/hooks/color-panel.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/typography.js"],"names":["omit","object","keys","Object","fromEntries","entries","filter","key","includes","LETTER_SPACING_SUPPORT_KEY","TEXT_TRANSFORM_SUPPORT_KEY","TEXT_DECORATION_SUPPORT_KEY","TEXT_COLUMNS_SUPPORT_KEY","FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","LINE_HEIGHT_SUPPORT_KEY","FONT_SIZE_SUPPORT_KEY","FONT_FAMILY_SUPPORT_KEY","styleToAttributes","style","updatedStyle","fontSizeValue","typography","fontSize","fontFamilyValue","fontFamily","fontSizeSlug","startsWith","substring","length","undefined","fontFamilySlug","attributesToStyle","attributes","TypographyInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","TypographyPanel","clientId","name","setAttributes","__unstableParentLayout","settings","isEnabled","value","onChange","newStyle","defaultControls","h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FX;AAGC,IAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/typography.js"],"names":["omit","object","keys","Object","fromEntries","entries","filter","key","includes","LETTER_SPACING_SUPPORT_KEY","TEXT_TRANSFORM_SUPPORT_KEY","TEXT_DECORATION_SUPPORT_KEY","TEXT_COLUMNS_SUPPORT_KEY","FONT_STYLE_SUPPORT_KEY","FONT_WEIGHT_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEY","TYPOGRAPHY_SUPPORT_KEYS","LINE_HEIGHT_SUPPORT_KEY","FONT_SIZE_SUPPORT_KEY","FONT_FAMILY_SUPPORT_KEY","styleToAttributes","style","updatedStyle","fontSizeValue","typography","fontSize","fontFamilyValue","fontFamily","fontSizeSlug","startsWith","substring","length","undefined","fontFamilySlug","attributesToStyle","attributes","TypographyInspectorControl","children","resetAllFilter","attributesResetAllFilter","existingStyle","TypographyPanel","clientId","name","setAttributes","__unstableParentLayout","settings","isEnabled","value","onChange","newStyle","defaultControls","hasTypographySupport","blockName","some"],"mappings":";;;;;;;;;;;AAIA;;AADA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;;;;;AAlBA;AACA;AACA;;AAIA;AACA;AACA;AAYA,SAASA,IAAT,CAAeC,MAAf,EAAuBC,IAAvB,EAA8B;AAC7B,SAAOC,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,CAAgBJ,MAAhB,EAAyBK,MAAzB,CAAiC;AAAA,QAAE,CAAEC,GAAF,CAAF;AAAA,WAAe,CAAEL,IAAI,CAACM,QAAL,CAAeD,GAAf,CAAjB;AAAA,GAAjC,CADM,CAAP;AAGA;;AAED,MAAME,0BAA0B,GAAG,wCAAnC;AACA,MAAMC,0BAA0B,GAAG,wCAAnC;AACA,MAAMC,2BAA2B,GAAG,yCAApC;AACA,MAAMC,wBAAwB,GAAG,wBAAjC;AACA,MAAMC,sBAAsB,GAAG,oCAA/B;AACA,MAAMC,uBAAuB,GAAG,qCAAhC;AACO,M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AAE;AACzBb,MAAAA,KAAK,EAAEc,UAAU,CAACd,KADO;AAEzBM,MAAAA,UAAU,EAAEQ,UAAU,CAACR,UAFE;AAGzBF,MAAAA,QAAQ,EAAEU,UAAU,CAACV;AAHI,KAAF,CAAxB;AAKA,GANa,EAMX,CAAEU,UAAU,CAACd,KAAb,EAAoBc,UAAU,CAACV,QAA/B,EAAyCU,UAAU,CAACR,UAApD,CANW,CAAd;;AAQA,QAAMsB,QAAQ,GAAKC,QAAF,IAAgB;AAChCN,IAAAA,aAAa,CAAExB,iBAAiB,CAAE8B,QAAF,CAAnB,CAAb;AACA,GAFD;;AAIA,MAAK,CAAEH,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,QAAMI,eAAe,GAAG,6BAAiBR,IAAjB,EAAuB,CAC9C5B,sBAD8C,EAE9C,+BAF8C,CAAvB,CAAxB;AAKA,SACC,4BAAC,wBAAD;AACC,IAAA,EAAE,EAAGqB,0BADN;AAEC,IAAA,OAAO,EAAGM,QAFX;AAGC,IAAA,QAAQ,EAAGI,QAHZ;AAIC,IAAA,KAAK,EAAGE,KAJT;AAKC,IAAA,QAAQ,EAAGC,QALZ;AAMC,IAAA,eAAe,EAAGE;AANnB,IADD;AAUA;;AAEM,MAAMC,oBAAoB,GAAKC,SAAF,IAAiB;AACpD,SAAOrC,uBAAuB,CAACsC,IAAxB,CAAgC/C,GAAF,IACpC,6BAAiB8C,SAAjB,EAA4B9C,GAA5B,CADM,CAAP;AAGA,CAJM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tdefault as StylesTypographyPanel,\n\tuseHasTypographyPanel,\n} from '../components/global-styles/typography-panel';\n\nimport { LINE_HEIGHT_SUPPORT_KEY } from './line-height';\nimport { FONT_FAMILY_SUPPORT_KEY } from './font-family';\nimport { FONT_SIZE_SUPPORT_KEY } from './font-size';\nimport { cleanEmptyObject, useBlockSettings } from './utils';\n\nfunction omit( object, keys ) {\n\treturn Object.fromEntries(\n\t\tObject.entries( object ).filter( ( [ key ] ) => ! keys.includes( key ) )\n\t);\n}\n\nconst LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';\nconst TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';\nconst TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';\nconst TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';\nconst FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';\nconst FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';\nexport const TYPOGRAPHY_SUPPORT_KEY = 'typography';\nexport const TYPOGRAPHY_SUPPORT_KEYS = [\n\tLINE_HEIGHT_SUPPORT_KEY,\n\tFONT_SIZE_SUPPORT_KEY,\n\tFONT_STYLE_SUPPORT_KEY,\n\tFONT_WEIGHT_SUPPORT_KEY,\n\tFONT_FAMILY_SUPPORT_KEY,\n\tTEXT_COLUMNS_SUPPORT_KEY,\n\tTEXT_DECORATION_SUPPORT_KEY,\n\tTEXT_TRANSFORM_SUPPORT_KEY,\n\tLETTER_SPACING_SUPPORT_KEY,\n];\n\nfunction styleToAttributes( style ) {\n\tconst updatedStyle = { ...omit( style, [ 'fontFamily' ] ) };\n\tconst fontSizeValue = style?.typography?.fontSize;\n\tconst fontFamilyValue = style?.typography?.fontFamily;\n\tconst fontSizeSlug = fontSizeValue?.startsWith( 'var:preset|font-size|' )\n\t\t? fontSizeValue.substring( 'var:preset|font-size|'.length )\n\t\t: undefined;\n\tconst fontFamilySlug = fontFamilyValue?.startsWith(\n\t\t'var:preset|font-family|'\n\t)\n\t\t? fontFamilyValue.substring( 'var:preset|font-family|'.length )\n\t\t: undefined;\n\tupdatedStyle.typography = {\n\t\t...omit( updatedStyle.typography, [ 'fontFamily' ] ),\n\t\tfontSize: fontSizeSlug ? undefined : fontSizeValue,\n\t};\n\treturn {\n\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\tfontFamily: fontFamilySlug,\n\t\tfontSize: fontSizeSlug,\n\t};\n}\n\nfunction attributesToStyle( attributes ) {\n\treturn {\n\t\t...attributes.style,\n\t\ttypography: {\n\t\t\t...attributes.style?.typography,\n\t\t\tfontFamily: attributes.fontFamily\n\t\t\t\t? 'var:preset|font-family|' + attributes.fontFamily\n\t\t\t\t: undefined,\n\t\t\tfontSize: attributes.fontSize\n\t\t\t\t? 'var:preset|font-size|' + attributes.fontSize\n\t\t\t\t: attributes.style?.typography?.fontSize,\n\t\t},\n\t};\n}\n\nfunction TypographyInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributesToStyle( attributes );\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\t...styleToAttributes( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"typography\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function TypographyPanel( {\n\tclientId,\n\tname,\n\tattributes,\n\tsetAttributes,\n\t__unstableParentLayout,\n} ) {\n\tconst settings = useBlockSettings( name, __unstableParentLayout );\n\tconst isEnabled = useHasTypographyPanel( settings );\n\tconst value = useMemo( () => {\n\t\treturn attributesToStyle( {\n\t\t\tstyle: attributes.style,\n\t\t\tfontFamily: attributes.fontFamily,\n\t\t\tfontSize: attributes.fontSize,\n\t\t} );\n\t}, [ attributes.style, attributes.fontSize, attributes.fontFamily ] );\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( styleToAttributes( newStyle ) );\n\t};\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tTYPOGRAPHY_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesTypographyPanel\n\t\t\tas={ TypographyInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t/>\n\t);\n}\n\nexport const hasTypographySupport = ( blockName ) => {\n\treturn TYPOGRAPHY_SUPPORT_KEYS.some( ( key ) =>\n\t\thasBlockSupport( blockName, key )\n\t);\n};\n"]}
|
package/build/hooks/utils.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.cleanEmptyObject = void 0;
|
|
7
|
-
exports.immutableSet = immutableSet;
|
|
8
7
|
exports.shouldSkipSerialization = shouldSkipSerialization;
|
|
9
8
|
exports.transformStyles = transformStyles;
|
|
10
9
|
exports.useBlockSettings = useBlockSettings;
|
|
@@ -19,6 +18,8 @@ var _components = require("../components");
|
|
|
19
18
|
|
|
20
19
|
var _hooks = require("../components/global-styles/hooks");
|
|
21
20
|
|
|
21
|
+
var _object = require("../utils/object");
|
|
22
|
+
|
|
22
23
|
/**
|
|
23
24
|
* External dependencies
|
|
24
25
|
*/
|
|
@@ -48,79 +49,9 @@ const cleanEmptyObject = object => {
|
|
|
48
49
|
}));
|
|
49
50
|
return (0, _lodash.isEmpty)(cleanedNestedObjects) ? undefined : cleanedNestedObjects;
|
|
50
51
|
};
|
|
51
|
-
/**
|
|
52
|
-
* Converts a path to an array of its fragments.
|
|
53
|
-
* Supports strings, numbers and arrays:
|
|
54
|
-
*
|
|
55
|
-
* 'foo' => [ 'foo' ]
|
|
56
|
-
* 2 => [ '2' ]
|
|
57
|
-
* [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
|
|
58
|
-
*
|
|
59
|
-
* @param {string|number|Array} path Path
|
|
60
|
-
* @return {Array} Normalized path.
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
52
|
|
|
64
53
|
exports.cleanEmptyObject = cleanEmptyObject;
|
|
65
54
|
|
|
66
|
-
function normalizePath(path) {
|
|
67
|
-
if (Array.isArray(path)) {
|
|
68
|
-
return path;
|
|
69
|
-
} else if (typeof path === 'number') {
|
|
70
|
-
return [path.toString()];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return [path];
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Clones an object.
|
|
77
|
-
* Non-object values are returned unchanged.
|
|
78
|
-
*
|
|
79
|
-
* @param {*} object Object to clone.
|
|
80
|
-
* @return {*} Cloned object, or original literal non-object value.
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
function cloneObject(object) {
|
|
85
|
-
if (typeof object === 'object') {
|
|
86
|
-
return { ...Object.fromEntries(Object.entries(object).map(_ref2 => {
|
|
87
|
-
let [key, value] = _ref2;
|
|
88
|
-
return [key, cloneObject(value)];
|
|
89
|
-
}))
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return object;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Perform an immutable set.
|
|
97
|
-
* Handles nullish initial values.
|
|
98
|
-
* Clones all nested objects in the specified object.
|
|
99
|
-
*
|
|
100
|
-
* @param {Object} object Object to set a value in.
|
|
101
|
-
* @param {number|string|Array} path Path in the object to modify.
|
|
102
|
-
* @param {*} value New value to set.
|
|
103
|
-
* @return {Object} Cloned object with the new value set.
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
function immutableSet(object, path, value) {
|
|
108
|
-
const normalizedPath = normalizePath(path);
|
|
109
|
-
const newObject = object ? cloneObject(object) : {};
|
|
110
|
-
normalizedPath.reduce((acc, key, i) => {
|
|
111
|
-
if (acc[key] === undefined) {
|
|
112
|
-
acc[key] = {};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (i === normalizedPath.length - 1) {
|
|
116
|
-
acc[key] = value;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return acc[key];
|
|
120
|
-
}, newObject);
|
|
121
|
-
return newObject;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
55
|
function transformStyles(activeSupports, migrationPaths, result, source, index, results) {
|
|
125
56
|
var _source$;
|
|
126
57
|
|
|
@@ -154,8 +85,8 @@ function transformStyles(activeSupports, migrationPaths, result, source, index,
|
|
|
154
85
|
}
|
|
155
86
|
|
|
156
87
|
let returnBlock = result;
|
|
157
|
-
Object.entries(activeSupports).forEach(
|
|
158
|
-
let [support, isActive] =
|
|
88
|
+
Object.entries(activeSupports).forEach(_ref2 => {
|
|
89
|
+
let [support, isActive] = _ref2;
|
|
159
90
|
|
|
160
91
|
if (isActive) {
|
|
161
92
|
migrationPaths[support].forEach(path => {
|
|
@@ -163,7 +94,7 @@ function transformStyles(activeSupports, migrationPaths, result, source, index,
|
|
|
163
94
|
|
|
164
95
|
if (styleValue) {
|
|
165
96
|
returnBlock = { ...returnBlock,
|
|
166
|
-
attributes: immutableSet(returnBlock.attributes, path, styleValue)
|
|
97
|
+
attributes: (0, _object.immutableSet)(returnBlock.attributes, path, styleValue)
|
|
167
98
|
};
|
|
168
99
|
}
|
|
169
100
|
});
|
|
@@ -232,6 +163,14 @@ function useBlockSettings(name, parentLayout) {
|
|
|
232
163
|
const themeColors = (0, _components.useSetting)('color.palette.theme');
|
|
233
164
|
const defaultColors = (0, _components.useSetting)('color.palette.default');
|
|
234
165
|
const defaultPalette = (0, _components.useSetting)('color.defaultPalette');
|
|
166
|
+
const userGradientPalette = (0, _components.useSetting)('color.gradients.custom');
|
|
167
|
+
const themeGradientPalette = (0, _components.useSetting)('color.gradients.theme');
|
|
168
|
+
const defaultGradientPalette = (0, _components.useSetting)('color.gradients.default');
|
|
169
|
+
const defaultGradients = (0, _components.useSetting)('color.defaultGradients');
|
|
170
|
+
const areCustomGradientsEnabled = (0, _components.useSetting)('color.customGradient');
|
|
171
|
+
const isBackgroundEnabled = (0, _components.useSetting)('color.background');
|
|
172
|
+
const isLinkEnabled = (0, _components.useSetting)('color.link');
|
|
173
|
+
const isTextEnabled = (0, _components.useSetting)('color.text');
|
|
235
174
|
const rawSettings = (0, _element.useMemo)(() => {
|
|
236
175
|
return {
|
|
237
176
|
color: {
|
|
@@ -240,8 +179,18 @@ function useBlockSettings(name, parentLayout) {
|
|
|
240
179
|
theme: themeColors,
|
|
241
180
|
default: defaultColors
|
|
242
181
|
},
|
|
182
|
+
gradients: {
|
|
183
|
+
custom: userGradientPalette,
|
|
184
|
+
theme: themeGradientPalette,
|
|
185
|
+
default: defaultGradientPalette
|
|
186
|
+
},
|
|
187
|
+
defaultGradients,
|
|
243
188
|
defaultPalette,
|
|
244
|
-
custom: customColorsEnabled
|
|
189
|
+
custom: customColorsEnabled,
|
|
190
|
+
customGradient: areCustomGradientsEnabled,
|
|
191
|
+
background: isBackgroundEnabled,
|
|
192
|
+
link: isLinkEnabled,
|
|
193
|
+
text: isTextEnabled
|
|
245
194
|
},
|
|
246
195
|
typography: {
|
|
247
196
|
fontFamilies: {
|
|
@@ -280,7 +229,7 @@ function useBlockSettings(name, parentLayout) {
|
|
|
280
229
|
layout,
|
|
281
230
|
parentLayout
|
|
282
231
|
};
|
|
283
|
-
}, [fontFamilies, fontSizes, customFontSize, fontStyle, fontWeight, lineHeight, textColumns, textDecoration, textTransform, letterSpacing, padding, margin, blockGap, spacingSizes, units, minHeight, layout, parentLayout, borderColor, borderRadius, borderStyle, borderWidth, customColorsEnabled, customColors, themeColors, defaultColors, defaultPalette]);
|
|
232
|
+
}, [fontFamilies, fontSizes, customFontSize, fontStyle, fontWeight, lineHeight, textColumns, textDecoration, textTransform, letterSpacing, padding, margin, blockGap, spacingSizes, units, minHeight, layout, parentLayout, borderColor, borderRadius, borderStyle, borderWidth, customColorsEnabled, customColors, themeColors, defaultColors, defaultPalette, userGradientPalette, themeGradientPalette, defaultGradientPalette, defaultGradients, areCustomGradientsEnabled, isBackgroundEnabled, isLinkEnabled, isTextEnabled]);
|
|
284
233
|
return (0, _hooks.useSettingsForBlockElement)(rawSettings, name);
|
|
285
234
|
}
|
|
286
235
|
//# sourceMappingURL=utils.js.map
|
package/build/hooks/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","filter","value","Boolean","undefined","normalizePath","path","toString","cloneObject","map","key","immutableSet","normalizedPath","newObject","reduce","acc","i","length","transformStyles","activeSupports","migrationPaths","result","source","index","results","values","every","isActive","innerBlocks","referenceBlockAttributes","attributes","returnBlock","forEach","support","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes","useBlockSettings","name","parentLayout","fontFamilies","fontSizes","customFontSize","fontStyle","fontWeight","lineHeight","textColumns","textDecoration","textTransform","letterSpacing","padding","margin","blockGap","spacingSizes","units","minHeight","layout","borderColor","borderRadius","borderStyle","borderWidth","customColorsEnabled","customColors","themeColors","defaultColors","defaultPalette","rawSettings","color","palette","custom","theme","default","typography","spacing","border","radius","style","width","dimensions"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAKC,MAAF,IAAc;AAC7C,MACCA,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEAC,KAAK,CAACC,OAAN,CAAeF,MAAf,CAHD,EAIE;AACD,WAAOA,MAAP;AACA;;AACD,QAAMG,oBAAoB,GAAGC,MAAM,CAACC,WAAP,CAC5BD,MAAM,CAACE,OAAP,CAAgB,uBAAWN,MAA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AzBE,EA0BFC,aA1BE,EA2BFC,cA3BE,CAhDiB,CAApB;AA8EA,SAAO,uCAA4BC,WAA5B,EAAyC5B,IAAzC,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty, mapValues, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( mapValues( object, cleanEmptyObject ) ).filter(\n\t\t\t( [ , value ] ) => Boolean( value )\n\t\t)\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\n/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Clones an object.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Perform an immutable set.\n * Handles nullish initial values.\n * Clones all nested objects in the specified object.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function immutableSet( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tacc[ key ] = {};\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst customFontSize = useSetting( 'typography.customFontSize' );\n\tconst fontStyle = useSetting( 'typography.fontStyle' );\n\tconst fontWeight = useSetting( 'typography.fontWeight' );\n\tconst lineHeight = useSetting( 'typography.lineHeight' );\n\tconst textColumns = useSetting( 'typography.textColumns' );\n\tconst textDecoration = useSetting( 'typography.textDecoration' );\n\tconst textTransform = useSetting( 'typography.textTransform' );\n\tconst letterSpacing = useSetting( 'typography.letterSpacing' );\n\tconst padding = useSetting( 'spacing.padding' );\n\tconst margin = useSetting( 'spacing.margin' );\n\tconst blockGap = useSetting( 'spacing.blockGap' );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\tconst units = useSetting( 'spacing.units' );\n\tconst minHeight = useSetting( 'dimensions.minHeight' );\n\tconst layout = useSetting( 'layout' );\n\tconst borderColor = useSetting( 'border.color' );\n\tconst borderRadius = useSetting( 'border.radius' );\n\tconst borderStyle = useSetting( 'border.style' );\n\tconst borderWidth = useSetting( 'border.width' );\n\tconst customColorsEnabled = useSetting( 'color.custom' );\n\tconst customColors = useSetting( 'color.palette.custom' );\n\tconst themeColors = useSetting( 'color.palette.theme' );\n\tconst defaultColors = useSetting( 'color.palette.default' );\n\tconst defaultPalette = useSetting( 'color.defaultPalette' );\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tdefaultPalette,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: fontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: fontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: spacingSizes,\n\t\t\t\t},\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\tminHeight,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t};\n\t}, [\n\t\tfontFamilies,\n\t\tfontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tspacingSizes,\n\t\tunits,\n\t\tminHeight,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/utils.js"],"names":["cleanEmptyObject","object","Array","isArray","cleanedNestedObjects","Object","fromEntries","entries","filter","value","Boolean","undefined","transformStyles","activeSupports","migrationPaths","result","source","index","results","values","every","isActive","length","innerBlocks","referenceBlockAttributes","attributes","returnBlock","forEach","support","path","styleValue","shouldSkipSerialization","blockType","featureSet","feature","skipSerialization","__experimentalSkipSerialization","includes","useBlockSettings","name","parentLayout","fontFamilies","fontSizes","customFontSize","fontStyle","fontWeight","lineHeight","textColumns","textDecoration","textTransform","letterSpacing","padding","margin","blockGap","spacingSizes","units","minHeight","layout","borderColor","borderRadius","borderStyle","borderWidth","customColorsEnabled","customColors","themeColors","defaultColors","defaultPalette","userGradientPalette","themeGradientPalette","defaultGradientPalette","defaultGradients","areCustomGradientsEnabled","isBackgroundEnabled","isLinkEnabled","isTextEnabled","rawSettings","color","palette","custom","theme","default","gradients","customGradient","background","link","text","typography","spacing","border","radius","style","width","dimensions"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;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aXC,QAAAA,aAbW;AAcXC,QAAAA;AAdW,OApBN;AAoCNqC,MAAAA,OAAO,EAAE;AACRjC,QAAAA,YAAY,EAAE;AACbwB,UAAAA,MAAM,EAAExB;AADK,SADN;AAIRH,QAAAA,OAJQ;AAKRC,QAAAA,MALQ;AAMRC,QAAAA,QANQ;AAORE,QAAAA;AAPQ,OApCH;AA6CNiC,MAAAA,MAAM,EAAE;AACPZ,QAAAA,KAAK,EAAElB,WADA;AAEP+B,QAAAA,MAAM,EAAE9B,YAFD;AAGP+B,QAAAA,KAAK,EAAE9B,WAHA;AAIP+B,QAAAA,KAAK,EAAE9B;AAJA,OA7CF;AAmDN+B,MAAAA,UAAU,EAAE;AACXpC,QAAAA;AADW,OAnDN;AAsDNC,MAAAA,MAtDM;AAuDNjB,MAAAA;AAvDM,KAAP;AAyDA,GA1DmB,EA0DjB,CACFC,YADE,EAEFC,SAFE,EAGFC,cAHE,EAIFC,SAJE,EAKFC,UALE,EAMFC,UANE,EAOFC,WAPE,EAQFC,cARE,EASFC,aATE,EAUFC,aAVE,EAWFC,OAXE,EAYFC,MAZE,EAaFC,QAbE,EAcFC,YAdE,EAeFC,KAfE,EAgBFC,SAhBE,EAiBFC,MAjBE,EAkBFjB,YAlBE,EAmBFkB,WAnBE,EAoBFC,YApBE,EAqBFC,WArBE,EAsBFC,WAtBE,EAuBFC,mBAvBE,EAwBFC,YAxBE,EAyBFC,WAzBE,EA0BFC,aA1BE,EA2BFC,cA3BE,EA4BFC,mBA5BE,EA6BFC,oBA7BE,EA8BFC,sBA9BE,EA+BFC,gBA/BE,EAgCFC,yBAhCE,EAiCFC,mBAjCE,EAkCFC,aAlCE,EAmCFC,aAnCE,CA1DiB,CAApB;AAgGA,SAAO,uCAA4BC,WAA5B,EAAyCpC,IAAzC,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty, mapValues, get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSetting } from '../components';\nimport { useSettingsForBlockElement } from '../components/global-styles/hooks';\nimport { immutableSet } from '../utils/object';\n\n/**\n * Removed falsy values from nested object.\n *\n * @param {*} object\n * @return {*} Object cleaned from falsy values\n */\nexport const cleanEmptyObject = ( object ) => {\n\tif (\n\t\tobject === null ||\n\t\ttypeof object !== 'object' ||\n\t\tArray.isArray( object )\n\t) {\n\t\treturn object;\n\t}\n\tconst cleanedNestedObjects = Object.fromEntries(\n\t\tObject.entries( mapValues( object, cleanEmptyObject ) ).filter(\n\t\t\t( [ , value ] ) => Boolean( value )\n\t\t)\n\t);\n\treturn isEmpty( cleanedNestedObjects ) ? undefined : cleanedNestedObjects;\n};\n\nexport function transformStyles(\n\tactiveSupports,\n\tmigrationPaths,\n\tresult,\n\tsource,\n\tindex,\n\tresults\n) {\n\t// If there are no active supports return early.\n\tif (\n\t\tObject.values( activeSupports ?? {} ).every(\n\t\t\t( isActive ) => ! isActive\n\t\t)\n\t) {\n\t\treturn result;\n\t}\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the styles should not be transformed.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\t// For cases where we have a transform from one block to multiple blocks\n\t// or multiple blocks to one block we apply the styles of the first source block\n\t// to the result(s).\n\tlet referenceBlockAttributes = source[ 0 ]?.attributes;\n\t// If we are in presence of transform between more than one block in the source\n\t// that has more than one block in the result\n\t// we apply the styles on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( results.length > 1 && source.length > 1 ) {\n\t\tif ( source[ index ] ) {\n\t\t\treferenceBlockAttributes = source[ index ]?.attributes;\n\t\t} else {\n\t\t\treturn result;\n\t\t}\n\t}\n\tlet returnBlock = result;\n\tObject.entries( activeSupports ).forEach( ( [ support, isActive ] ) => {\n\t\tif ( isActive ) {\n\t\t\tmigrationPaths[ support ].forEach( ( path ) => {\n\t\t\t\tconst styleValue = get( referenceBlockAttributes, path );\n\t\t\t\tif ( styleValue ) {\n\t\t\t\t\treturnBlock = {\n\t\t\t\t\t\t...returnBlock,\n\t\t\t\t\t\tattributes: immutableSet(\n\t\t\t\t\t\t\treturnBlock.attributes,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tstyleValue\n\t\t\t\t\t\t),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t} );\n\treturn returnBlock;\n}\n\n/**\n * Check whether serialization of specific block support feature or set should\n * be skipped.\n *\n * @param {string|Object} blockType Block name or block type object.\n * @param {string} featureSet Name of block support feature set.\n * @param {string} feature Name of the individual feature to check.\n *\n * @return {boolean} Whether serialization should occur.\n */\nexport function shouldSkipSerialization( blockType, featureSet, feature ) {\n\tconst support = getBlockSupport( blockType, featureSet );\n\tconst skipSerialization = support?.__experimentalSkipSerialization;\n\n\tif ( Array.isArray( skipSerialization ) ) {\n\t\treturn skipSerialization.includes( feature );\n\t}\n\n\treturn skipSerialization;\n}\n\n/**\n * Based on the block and its context, returns an object of all the block settings.\n * This object can be passed as a prop to all the Styles UI components\n * (TypographyPanel, DimensionsPanel...).\n *\n * @param {string} name Block name.\n * @param {*} parentLayout Parent layout.\n *\n * @return {Object} Settings object.\n */\nexport function useBlockSettings( name, parentLayout ) {\n\tconst fontFamilies = useSetting( 'typography.fontFamilies' );\n\tconst fontSizes = useSetting( 'typography.fontSizes' );\n\tconst customFontSize = useSetting( 'typography.customFontSize' );\n\tconst fontStyle = useSetting( 'typography.fontStyle' );\n\tconst fontWeight = useSetting( 'typography.fontWeight' );\n\tconst lineHeight = useSetting( 'typography.lineHeight' );\n\tconst textColumns = useSetting( 'typography.textColumns' );\n\tconst textDecoration = useSetting( 'typography.textDecoration' );\n\tconst textTransform = useSetting( 'typography.textTransform' );\n\tconst letterSpacing = useSetting( 'typography.letterSpacing' );\n\tconst padding = useSetting( 'spacing.padding' );\n\tconst margin = useSetting( 'spacing.margin' );\n\tconst blockGap = useSetting( 'spacing.blockGap' );\n\tconst spacingSizes = useSetting( 'spacing.spacingSizes' );\n\tconst units = useSetting( 'spacing.units' );\n\tconst minHeight = useSetting( 'dimensions.minHeight' );\n\tconst layout = useSetting( 'layout' );\n\tconst borderColor = useSetting( 'border.color' );\n\tconst borderRadius = useSetting( 'border.radius' );\n\tconst borderStyle = useSetting( 'border.style' );\n\tconst borderWidth = useSetting( 'border.width' );\n\tconst customColorsEnabled = useSetting( 'color.custom' );\n\tconst customColors = useSetting( 'color.palette.custom' );\n\tconst themeColors = useSetting( 'color.palette.theme' );\n\tconst defaultColors = useSetting( 'color.palette.default' );\n\tconst defaultPalette = useSetting( 'color.defaultPalette' );\n\tconst userGradientPalette = useSetting( 'color.gradients.custom' );\n\tconst themeGradientPalette = useSetting( 'color.gradients.theme' );\n\tconst defaultGradientPalette = useSetting( 'color.gradients.default' );\n\tconst defaultGradients = useSetting( 'color.defaultGradients' );\n\tconst areCustomGradientsEnabled = useSetting( 'color.customGradient' );\n\tconst isBackgroundEnabled = useSetting( 'color.background' );\n\tconst isLinkEnabled = useSetting( 'color.link' );\n\tconst isTextEnabled = useSetting( 'color.text' );\n\n\tconst rawSettings = useMemo( () => {\n\t\treturn {\n\t\t\tcolor: {\n\t\t\t\tpalette: {\n\t\t\t\t\tcustom: customColors,\n\t\t\t\t\ttheme: themeColors,\n\t\t\t\t\tdefault: defaultColors,\n\t\t\t\t},\n\t\t\t\tgradients: {\n\t\t\t\t\tcustom: userGradientPalette,\n\t\t\t\t\ttheme: themeGradientPalette,\n\t\t\t\t\tdefault: defaultGradientPalette,\n\t\t\t\t},\n\t\t\t\tdefaultGradients,\n\t\t\t\tdefaultPalette,\n\t\t\t\tcustom: customColorsEnabled,\n\t\t\t\tcustomGradient: areCustomGradientsEnabled,\n\t\t\t\tbackground: isBackgroundEnabled,\n\t\t\t\tlink: isLinkEnabled,\n\t\t\t\ttext: isTextEnabled,\n\t\t\t},\n\t\t\ttypography: {\n\t\t\t\tfontFamilies: {\n\t\t\t\t\tcustom: fontFamilies,\n\t\t\t\t},\n\t\t\t\tfontSizes: {\n\t\t\t\t\tcustom: fontSizes,\n\t\t\t\t},\n\t\t\t\tcustomFontSize,\n\t\t\t\tfontStyle,\n\t\t\t\tfontWeight,\n\t\t\t\tlineHeight,\n\t\t\t\ttextColumns,\n\t\t\t\ttextDecoration,\n\t\t\t\ttextTransform,\n\t\t\t\tletterSpacing,\n\t\t\t},\n\t\t\tspacing: {\n\t\t\t\tspacingSizes: {\n\t\t\t\t\tcustom: spacingSizes,\n\t\t\t\t},\n\t\t\t\tpadding,\n\t\t\t\tmargin,\n\t\t\t\tblockGap,\n\t\t\t\tunits,\n\t\t\t},\n\t\t\tborder: {\n\t\t\t\tcolor: borderColor,\n\t\t\t\tradius: borderRadius,\n\t\t\t\tstyle: borderStyle,\n\t\t\t\twidth: borderWidth,\n\t\t\t},\n\t\t\tdimensions: {\n\t\t\t\tminHeight,\n\t\t\t},\n\t\t\tlayout,\n\t\t\tparentLayout,\n\t\t};\n\t}, [\n\t\tfontFamilies,\n\t\tfontSizes,\n\t\tcustomFontSize,\n\t\tfontStyle,\n\t\tfontWeight,\n\t\tlineHeight,\n\t\ttextColumns,\n\t\ttextDecoration,\n\t\ttextTransform,\n\t\tletterSpacing,\n\t\tpadding,\n\t\tmargin,\n\t\tblockGap,\n\t\tspacingSizes,\n\t\tunits,\n\t\tminHeight,\n\t\tlayout,\n\t\tparentLayout,\n\t\tborderColor,\n\t\tborderRadius,\n\t\tborderStyle,\n\t\tborderWidth,\n\t\tcustomColorsEnabled,\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tdefaultPalette,\n\t\tuserGradientPalette,\n\t\tthemeGradientPalette,\n\t\tdefaultGradientPalette,\n\t\tdefaultGradients,\n\t\tareCustomGradientsEnabled,\n\t\tisBackgroundEnabled,\n\t\tisLinkEnabled,\n\t\tisTextEnabled,\n\t] );\n\n\treturn useSettingsForBlockElement( rawSettings, name );\n}\n"]}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _utils = require("./utils");
|
|
15
|
+
|
|
16
|
+
var _gap = require("../hooks/gap");
|
|
17
|
+
|
|
18
|
+
var _utils2 = require("../hooks/utils");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
const RANGE_CONTROL_MAX_VALUES = {
|
|
28
|
+
px: 600,
|
|
29
|
+
'%': 100,
|
|
30
|
+
vw: 100,
|
|
31
|
+
vh: 100,
|
|
32
|
+
em: 38,
|
|
33
|
+
rem: 38
|
|
34
|
+
};
|
|
35
|
+
var _default = {
|
|
36
|
+
name: 'grid',
|
|
37
|
+
label: (0, _i18n.__)('Grid'),
|
|
38
|
+
inspectorControls: function GridLayoutInspectorControls(_ref) {
|
|
39
|
+
let {
|
|
40
|
+
layout = {},
|
|
41
|
+
onChange
|
|
42
|
+
} = _ref;
|
|
43
|
+
return (0, _element.createElement)(GridLayoutMinimumWidthControl, {
|
|
44
|
+
layout: layout,
|
|
45
|
+
onChange: onChange
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
toolBarControls: function DefaultLayoutToolbarControls() {
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
getLayoutStyle: function getLayoutStyle(_ref2) {
|
|
52
|
+
var _style$spacing, _style$spacing2;
|
|
53
|
+
|
|
54
|
+
let {
|
|
55
|
+
selector,
|
|
56
|
+
layout,
|
|
57
|
+
style,
|
|
58
|
+
blockName,
|
|
59
|
+
hasBlockGapSupport,
|
|
60
|
+
layoutDefinitions
|
|
61
|
+
} = _ref2;
|
|
62
|
+
const {
|
|
63
|
+
minimumColumnWidth = '12rem'
|
|
64
|
+
} = layout; // If a block's block.json skips serialization for spacing or spacing.blockGap,
|
|
65
|
+
// don't apply the user-defined value to the styles.
|
|
66
|
+
|
|
67
|
+
const blockGapValue = style !== null && style !== void 0 && (_style$spacing = style.spacing) !== null && _style$spacing !== void 0 && _style$spacing.blockGap && !(0, _utils2.shouldSkipSerialization)(blockName, 'spacing', 'blockGap') ? (0, _gap.getGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing2 = style.spacing) === null || _style$spacing2 === void 0 ? void 0 : _style$spacing2.blockGap, '0.5em') : undefined;
|
|
68
|
+
let output = '';
|
|
69
|
+
const rules = [];
|
|
70
|
+
|
|
71
|
+
if (minimumColumnWidth) {
|
|
72
|
+
rules.push(`grid-template-columns: repeat(auto-fill, minmax(min(${minimumColumnWidth}, 100%), 1fr))`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (rules.length) {
|
|
76
|
+
// Reason to disable: the extra line breaks added by prettier mess with the unit tests.
|
|
77
|
+
// eslint-disable-next-line prettier/prettier
|
|
78
|
+
output = `${(0, _utils.appendSelectors)(selector)} { ${rules.join('; ')}; }`;
|
|
79
|
+
} // Output blockGap styles based on rules contained in layout definitions in theme.json.
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
if (hasBlockGapSupport && blockGapValue) {
|
|
83
|
+
output += (0, _utils.getBlockGapCSS)(selector, layoutDefinitions, 'grid', blockGapValue);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return output;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
getOrientation() {
|
|
90
|
+
return 'horizontal';
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
getAlignments() {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
}; // Enables setting minimum width of grid items.
|
|
98
|
+
|
|
99
|
+
exports.default = _default;
|
|
100
|
+
|
|
101
|
+
function GridLayoutMinimumWidthControl(_ref3) {
|
|
102
|
+
let {
|
|
103
|
+
layout,
|
|
104
|
+
onChange
|
|
105
|
+
} = _ref3;
|
|
106
|
+
const {
|
|
107
|
+
minimumColumnWidth: value = '12rem'
|
|
108
|
+
} = layout;
|
|
109
|
+
const [quantity, unit] = (0, _components.__experimentalParseQuantityAndUnitFromRawValue)(value);
|
|
110
|
+
|
|
111
|
+
const handleSliderChange = next => {
|
|
112
|
+
onChange({ ...layout,
|
|
113
|
+
minimumColumnWidth: [next, unit].join('')
|
|
114
|
+
});
|
|
115
|
+
}; // Mostly copied from HeightControl.
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
const handleUnitChange = newUnit => {
|
|
119
|
+
// Attempt to smooth over differences between currentUnit and newUnit.
|
|
120
|
+
// This should slightly improve the experience of switching between unit types.
|
|
121
|
+
let newValue;
|
|
122
|
+
|
|
123
|
+
if (['em', 'rem'].includes(newUnit) && unit === 'px') {
|
|
124
|
+
// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.
|
|
125
|
+
newValue = (quantity / 16).toFixed(2) + newUnit;
|
|
126
|
+
} else if (['em', 'rem'].includes(unit) && newUnit === 'px') {
|
|
127
|
+
// Convert to pixel value assuming a root size of 16px.
|
|
128
|
+
newValue = Math.round(quantity * 16) + newUnit;
|
|
129
|
+
} else if (['vh', 'vw', '%'].includes(newUnit) && quantity > 100) {
|
|
130
|
+
// When converting to `vh`, `vw`, or `%` units, cap the new value at 100.
|
|
131
|
+
newValue = 100 + newUnit;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onChange({ ...layout,
|
|
135
|
+
minimumColumnWidth: newValue
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
return (0, _element.createElement)("fieldset", null, (0, _element.createElement)(_components.BaseControl.VisualLabel, {
|
|
140
|
+
as: "legend"
|
|
141
|
+
}, (0, _i18n.__)('Minimum column width')), (0, _element.createElement)(_components.Flex, {
|
|
142
|
+
gap: 4
|
|
143
|
+
}, (0, _element.createElement)(_components.FlexItem, {
|
|
144
|
+
isBlock: true
|
|
145
|
+
}, (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
146
|
+
size: '__unstable-large',
|
|
147
|
+
onChange: newValue => {
|
|
148
|
+
onChange({ ...layout,
|
|
149
|
+
minimumColumnWidth: newValue
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
onUnitChange: handleUnitChange,
|
|
153
|
+
value: value,
|
|
154
|
+
min: 0
|
|
155
|
+
})), (0, _element.createElement)(_components.FlexItem, {
|
|
156
|
+
isBlock: true
|
|
157
|
+
}, (0, _element.createElement)(_components.RangeControl, {
|
|
158
|
+
onChange: handleSliderChange,
|
|
159
|
+
value: quantity,
|
|
160
|
+
min: 0,
|
|
161
|
+
max: RANGE_CONTROL_MAX_VALUES[unit] || 600,
|
|
162
|
+
withInputField: false
|
|
163
|
+
}))));
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=grid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/grid.js"],"names":["RANGE_CONTROL_MAX_VALUES","px","vw","vh","em","rem","name","label","inspectorControls","GridLayoutInspectorControls","layout","onChange","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","minimumColumnWidth","blockGapValue","spacing","blockGap","undefined","output","rules","push","length","join","getOrientation","getAlignments","GridLayoutMinimumWidthControl","value","quantity","unit","handleSliderChange","next","handleUnitChange","newUnit","newValue","includes","toFixed","Math","round"],"mappings":";;;;;;;;;AAGA;;AAEA;;AAYA;;AACA;;AACA;;AAnBA;AACA;AACA;;AAYA;AACA;AACA;AAKA,MAAMA,wBAAwB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AAG,EAAGlC,wBAAwB,CAAEmC,IAAF,CAAxB,IAAoC,GAJ3C;AAKC,IAAA,cAAc,EAAG;AALlB,IADD,CAfD,CAJD,CADD;AAgCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\tBaseControl,\n\tFlex,\n\tFlexItem,\n\tRangeControl,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nconst RANGE_CONTROL_MAX_VALUES = {\n\tpx: 600,\n\t'%': 100,\n\tvw: 100,\n\tvh: 100,\n\tem: 38,\n\trem: 38,\n};\n\nexport default {\n\tname: 'grid',\n\tlabel: __( 'Grid' ),\n\tinspectorControls: function GridLayoutInspectorControls( {\n\t\tlayout = {},\n\t\tonChange,\n\t} ) {\n\t\treturn (\n\t\t\t<GridLayoutMinimumWidthControl\n\t\t\t\tlayout={ layout }\n\t\t\t\tonChange={ onChange }\n\t\t\t/>\n\t\t);\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst { minimumColumnWidth = '12rem' } = layout;\n\n\t\t// If a block's block.json skips serialization for spacing or spacing.blockGap,\n\t\t// don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tstyle?.spacing?.blockGap &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? getGapCSSValue( style?.spacing?.blockGap, '0.5em' )\n\t\t\t\t: undefined;\n\n\t\tlet output = '';\n\t\tconst rules = [];\n\n\t\tif ( minimumColumnWidth ) {\n\t\t\trules.push(\n\t\t\t\t`grid-template-columns: repeat(auto-fill, minmax(min(${ minimumColumnWidth }, 100%), 1fr))`\n\t\t\t);\n\t\t}\n\n\t\tif ( rules.length ) {\n\t\t\t// Reason to disable: the extra line breaks added by prettier mess with the unit tests.\n\t\t\t// eslint-disable-next-line prettier/prettier\n\t\t\toutput = `${ appendSelectors( selector ) } { ${ rules.join(\n\t\t\t\t'; '\n\t\t\t) }; }`;\n\t\t}\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'grid',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'horizontal';\n\t},\n\tgetAlignments() {\n\t\treturn [];\n\t},\n};\n\n// Enables setting minimum width of grid items.\nfunction GridLayoutMinimumWidthControl( { layout, onChange } ) {\n\tconst { minimumColumnWidth: value = '12rem' } = layout;\n\tconst [ quantity, unit ] = parseQuantityAndUnitFromRawValue( value );\n\n\tconst handleSliderChange = ( next ) => {\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tminimumColumnWidth: [ next, unit ].join( '' ),\n\t\t} );\n\t};\n\n\t// Mostly copied from HeightControl.\n\tconst handleUnitChange = ( newUnit ) => {\n\t\t// Attempt to smooth over differences between currentUnit and newUnit.\n\t\t// This should slightly improve the experience of switching between unit types.\n\t\tlet newValue;\n\n\t\tif ( [ 'em', 'rem' ].includes( newUnit ) && unit === 'px' ) {\n\t\t\t// Convert pixel value to an approximate of the new unit, assuming a root size of 16px.\n\t\t\tnewValue = ( quantity / 16 ).toFixed( 2 ) + newUnit;\n\t\t} else if ( [ 'em', 'rem' ].includes( unit ) && newUnit === 'px' ) {\n\t\t\t// Convert to pixel value assuming a root size of 16px.\n\t\t\tnewValue = Math.round( quantity * 16 ) + newUnit;\n\t\t} else if (\n\t\t\t[ 'vh', 'vw', '%' ].includes( newUnit ) &&\n\t\t\tquantity > 100\n\t\t) {\n\t\t\t// When converting to `vh`, `vw`, or `%` units, cap the new value at 100.\n\t\t\tnewValue = 100 + newUnit;\n\t\t}\n\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tminimumColumnWidth: newValue,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<fieldset>\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Minimum column width' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Flex gap={ 4 }>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<UnitControl\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tonChange( {\n\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\tminimumColumnWidth: newValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonUnitChange={ handleUnitChange }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t\t<FlexItem isBlock>\n\t\t\t\t\t<RangeControl\n\t\t\t\t\t\tonChange={ handleSliderChange }\n\t\t\t\t\t\tvalue={ quantity }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tmax={ RANGE_CONTROL_MAX_VALUES[ unit ] || 600 }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</fieldset>\n\t);\n}\n"]}
|
package/build/layouts/index.js
CHANGED
|
@@ -14,10 +14,12 @@ var _flow = _interopRequireDefault(require("./flow"));
|
|
|
14
14
|
|
|
15
15
|
var _constrained = _interopRequireDefault(require("./constrained"));
|
|
16
16
|
|
|
17
|
+
var _grid = _interopRequireDefault(require("./grid"));
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
20
|
-
const layoutTypes = [_flow.default, _flex.default, _constrained.default];
|
|
22
|
+
const layoutTypes = [_flow.default, _flex.default, _constrained.default, _grid.default];
|
|
21
23
|
/**
|
|
22
24
|
* Retrieves a layout type by name.
|
|
23
25
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/layouts/index.js"],"names":["layoutTypes","flow","flex","constrained","getLayoutType","name","find","layoutType","getLayoutTypes"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/layouts/index.js"],"names":["layoutTypes","flow","flex","constrained","grid","getLayoutType","name","find","layoutType","getLayoutTypes"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,WAAW,GAAG,CAAEC,aAAF,EAAQC,aAAR,EAAcC,oBAAd,EAA2BC,aAA3B,CAApB;AAEA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,aAAT,GAA2C;AAAA,MAAnBC,IAAmB,uEAAZ,SAAY;AACjD,SAAON,WAAW,CAACO,IAAZ,CAAoBC,UAAF,IAAkBA,UAAU,CAACF,IAAX,KAAoBA,IAAxD,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASG,cAAT,GAA0B;AAChC,SAAOT,WAAP;AACA","sourcesContent":["/**\n * Internal dependencies\n */\nimport flex from './flex';\nimport flow from './flow';\nimport constrained from './constrained';\nimport grid from './grid';\n\nconst layoutTypes = [ flow, flex, constrained, grid ];\n\n/**\n * Retrieves a layout type by name.\n *\n * @param {string} name - The name of the layout type.\n * @return {Object} Layout type.\n */\nexport function getLayoutType( name = 'default' ) {\n\treturn layoutTypes.find( ( layoutType ) => layoutType.name === name );\n}\n\n/**\n * Retrieves the available layout types.\n *\n * @return {Array} Layout types.\n */\nexport function getLayoutTypes() {\n\treturn layoutTypes;\n}\n"]}
|
package/build/private-apis.js
CHANGED
|
@@ -19,6 +19,8 @@ var _leafMoreMenu = _interopRequireDefault(require("./components/off-canvas-edit
|
|
|
19
19
|
|
|
20
20
|
var _inserter = require("./components/inserter");
|
|
21
21
|
|
|
22
|
+
var _listView = require("./components/list-view");
|
|
23
|
+
|
|
22
24
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
25
|
|
|
24
26
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -36,6 +38,7 @@ exports.privateApis = privateApis;
|
|
|
36
38
|
ExperimentalBlockEditorProvider: _provider.ExperimentalBlockEditorProvider,
|
|
37
39
|
LeafMoreMenu: _leafMoreMenu.default,
|
|
38
40
|
OffCanvasEditor: _offCanvasEditor.default,
|
|
39
|
-
PrivateInserter: _inserter.ComposedPrivateInserter
|
|
41
|
+
PrivateInserter: _inserter.ComposedPrivateInserter,
|
|
42
|
+
PrivateListView: _listView.PrivateListView
|
|
40
43
|
});
|
|
41
44
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","LeafMoreMenu","OffCanvasEditor","PrivateInserter"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","LeafMoreMenu","OffCanvasEditor","PrivateInserter","PrivateListView"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AATA;AACA;AACA;;AASA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB,EAClB,GAAGC,YADe;AAElBC,EAAAA,+BAA+B,EAA/BA,yCAFkB;AAGlBC,EAAAA,YAAY,EAAZA,qBAHkB;AAIlBC,EAAAA,eAAe,EAAfA,wBAJkB;AAKlBC,EAAAA,eAAe,EAAfA,iCALkB;AAMlBC,EAAAA,eAAe,EAAfA;AANkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport OffCanvasEditor from './components/off-canvas-editor';\nimport LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';\nimport { ComposedPrivateInserter as PrivateInserter } from './components/inserter';\nimport { PrivateListView } from './components/list-view';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockEditorProvider,\n\tLeafMoreMenu,\n\tOffCanvasEditor,\n\tPrivateInserter,\n\tPrivateListView,\n} );\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.immutableSet = immutableSet;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts a path to an array of its fragments.
|
|
10
|
+
* Supports strings, numbers and arrays:
|
|
11
|
+
*
|
|
12
|
+
* 'foo' => [ 'foo' ]
|
|
13
|
+
* 2 => [ '2' ]
|
|
14
|
+
* [ 'foo', 'bar' ] => [ 'foo', 'bar' ]
|
|
15
|
+
*
|
|
16
|
+
* @param {string|number|Array} path Path
|
|
17
|
+
* @return {Array} Normalized path.
|
|
18
|
+
*/
|
|
19
|
+
function normalizePath(path) {
|
|
20
|
+
if (Array.isArray(path)) {
|
|
21
|
+
return path;
|
|
22
|
+
} else if (typeof path === 'number') {
|
|
23
|
+
return [path.toString()];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return [path];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Clones an object.
|
|
30
|
+
* Non-object values are returned unchanged.
|
|
31
|
+
*
|
|
32
|
+
* @param {*} object Object to clone.
|
|
33
|
+
* @return {*} Cloned object, or original literal non-object value.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
function cloneObject(object) {
|
|
38
|
+
if (typeof object === 'object') {
|
|
39
|
+
return { ...Object.fromEntries(Object.entries(object).map(_ref => {
|
|
40
|
+
let [key, value] = _ref;
|
|
41
|
+
return [key, cloneObject(value)];
|
|
42
|
+
}))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return object;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Perform an immutable set.
|
|
50
|
+
* Handles nullish initial values.
|
|
51
|
+
* Clones all nested objects in the specified object.
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} object Object to set a value in.
|
|
54
|
+
* @param {number|string|Array} path Path in the object to modify.
|
|
55
|
+
* @param {*} value New value to set.
|
|
56
|
+
* @return {Object} Cloned object with the new value set.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
function immutableSet(object, path, value) {
|
|
61
|
+
const normalizedPath = normalizePath(path);
|
|
62
|
+
const newObject = object ? cloneObject(object) : {};
|
|
63
|
+
normalizedPath.reduce((acc, key, i) => {
|
|
64
|
+
if (acc[key] === undefined) {
|
|
65
|
+
acc[key] = {};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (i === normalizedPath.length - 1) {
|
|
69
|
+
acc[key] = value;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return acc[key];
|
|
73
|
+
}, newObject);
|
|
74
|
+
return newObject;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/utils/object.js"],"names":["normalizePath","path","Array","isArray","toString","cloneObject","object","Object","fromEntries","entries","map","key","value","immutableSet","normalizedPath","newObject","reduce","acc","i","undefined","length"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,CAAwBC,IAAxB,EAA+B;AAC9B,MAAKC,KAAK,CAACC,OAAN,CAAeF,IAAf,CAAL,EAA6B;AAC5B,WAAOA,IAAP;AACA,GAFD,MAEO,IAAK,OAAOA,IAAP,KAAgB,QAArB,EAAgC;AACtC,WAAO,CAAEA,IAAI,CAACG,QAAL,EAAF,CAAP;AACA;;AAED,SAAO,CAAEH,IAAF,CAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASI,WAAT,CAAsBC,MAAtB,EAA+B;AAC9B,MAAK,OAAOA,MAAP,KAAkB,QAAvB,EAAkC;AACjC,WAAO,EACN,GAAGC,MAAM,CAACC,WAAP,CACFD,MAAM,CAACE,OAAP,CAAgBH,MAAhB,EAAyBI,GAAzB,CAA8B;AAAA,YAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF;AAAA,eAAsB,CACnDD,GADmD,EAEnDN,WAAW,CAAEO,KAAF,CAFwC,CAAtB;AAAA,OAA9B,CADE;AADG,KAAP;AAQA;;AAED,SAAON,MAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASO,YAAT,CAAuBP,MAAvB,EAA+BL,IAA/B,EAAqCW,KAArC,EAA6C;AACnD,QAAME,cAAc,GAAGd,aAAa,CAAEC,IAAF,CAApC;AACA,QAAMc,SAAS,GAAGT,MAAM,GAAGD,WAAW,CAAEC,MAAF,CAAd,GAA2B,EAAnD;AAEAQ,EAAAA,cAAc,CAACE,MAAf,CAAuB,CAAEC,GAAF,EAAON,GAAP,EAAYO,CAAZ,KAAmB;AACzC,QAAKD,GAAG,CAAEN,GAAF,CAAH,KAAeQ,SAApB,EAAgC;AAC/BF,MAAAA,GAAG,CAAEN,GAAF,CAAH,GAAa,EAAb;AACA;;AACD,QAAKO,CAAC,KAAKJ,cAAc,CAACM,MAAf,GAAwB,CAAnC,EAAuC;AACtCH,MAAAA,GAAG,CAAEN,GAAF,CAAH,GAAaC,KAAb;AACA;;AACD,WAAOK,GAAG,CAAEN,GAAF,CAAV;AACA,GARD,EAQGI,SARH;AAUA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * Converts a path to an array of its fragments.\n * Supports strings, numbers and arrays:\n *\n * 'foo' => [ 'foo' ]\n * 2 => [ '2' ]\n * [ 'foo', 'bar' ] => [ 'foo', 'bar' ]\n *\n * @param {string|number|Array} path Path\n * @return {Array} Normalized path.\n */\nfunction normalizePath( path ) {\n\tif ( Array.isArray( path ) ) {\n\t\treturn path;\n\t} else if ( typeof path === 'number' ) {\n\t\treturn [ path.toString() ];\n\t}\n\n\treturn [ path ];\n}\n\n/**\n * Clones an object.\n * Non-object values are returned unchanged.\n *\n * @param {*} object Object to clone.\n * @return {*} Cloned object, or original literal non-object value.\n */\nfunction cloneObject( object ) {\n\tif ( typeof object === 'object' ) {\n\t\treturn {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( object ).map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\tcloneObject( value ),\n\t\t\t\t] )\n\t\t\t),\n\t\t};\n\t}\n\n\treturn object;\n}\n\n/**\n * Perform an immutable set.\n * Handles nullish initial values.\n * Clones all nested objects in the specified object.\n *\n * @param {Object} object Object to set a value in.\n * @param {number|string|Array} path Path in the object to modify.\n * @param {*} value New value to set.\n * @return {Object} Cloned object with the new value set.\n */\nexport function immutableSet( object, path, value ) {\n\tconst normalizedPath = normalizePath( path );\n\tconst newObject = object ? cloneObject( object ) : {};\n\n\tnormalizedPath.reduce( ( acc, key, i ) => {\n\t\tif ( acc[ key ] === undefined ) {\n\t\t\tacc[ key ] = {};\n\t\t}\n\t\tif ( i === normalizedPath.length - 1 ) {\n\t\t\tacc[ key ] = value;\n\t\t}\n\t\treturn acc[ key ];\n\t}, newObject );\n\n\treturn newObject;\n}\n"]}
|