@wordpress/edit-site 4.9.0 → 4.10.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.
Files changed (105) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/add-new-template/add-custom-generic-template-modal.js +84 -0
  3. package/build/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
  4. package/build/components/add-new-template/add-custom-template-modal.js +92 -53
  5. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  6. package/build/components/add-new-template/new-template.js +77 -81
  7. package/build/components/add-new-template/new-template.js.map +1 -1
  8. package/build/components/add-new-template/utils.js +310 -44
  9. package/build/components/add-new-template/utils.js.map +1 -1
  10. package/build/components/code-editor/index.js +17 -4
  11. package/build/components/code-editor/index.js.map +1 -1
  12. package/build/components/editor/index.js +16 -0
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/error-boundary/index.js +6 -0
  15. package/build/components/error-boundary/index.js.map +1 -1
  16. package/build/components/global-styles/dimensions-panel.js +2 -6
  17. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  18. package/build/components/global-styles/global-styles-provider.js +4 -2
  19. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  20. package/build/components/global-styles/hooks.js +10 -1
  21. package/build/components/global-styles/hooks.js.map +1 -1
  22. package/build/components/global-styles/screen-color-palette.js +13 -17
  23. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  24. package/build/components/global-styles/screen-colors.js +9 -1
  25. package/build/components/global-styles/screen-colors.js.map +1 -1
  26. package/build/components/global-styles/screen-link-color.js +48 -14
  27. package/build/components/global-styles/screen-link-color.js.map +1 -1
  28. package/build/components/global-styles/use-global-styles-output.js +171 -33
  29. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  30. package/build/components/global-styles/utils.js +1 -1
  31. package/build/components/global-styles/utils.js.map +1 -1
  32. package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
  33. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  34. package/build/components/template-details/edit-template-title.js +11 -3
  35. package/build/components/template-details/edit-template-title.js.map +1 -1
  36. package/build/components/template-details/index.js +1 -20
  37. package/build/components/template-details/index.js.map +1 -1
  38. package/build/store/selectors.js +4 -1
  39. package/build/store/selectors.js.map +1 -1
  40. package/build-module/components/add-new-template/add-custom-generic-template-modal.js +77 -0
  41. package/build-module/components/add-new-template/add-custom-generic-template-modal.js.map +1 -0
  42. package/build-module/components/add-new-template/add-custom-template-modal.js +92 -53
  43. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  44. package/build-module/components/add-new-template/new-template.js +80 -83
  45. package/build-module/components/add-new-template/new-template.js.map +1 -1
  46. package/build-module/components/add-new-template/utils.js +286 -40
  47. package/build-module/components/add-new-template/utils.js.map +1 -1
  48. package/build-module/components/code-editor/index.js +18 -5
  49. package/build-module/components/code-editor/index.js.map +1 -1
  50. package/build-module/components/editor/index.js +16 -0
  51. package/build-module/components/editor/index.js.map +1 -1
  52. package/build-module/components/error-boundary/index.js +5 -0
  53. package/build-module/components/error-boundary/index.js.map +1 -1
  54. package/build-module/components/global-styles/dimensions-panel.js +2 -6
  55. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  56. package/build-module/components/global-styles/global-styles-provider.js +4 -2
  57. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  58. package/build-module/components/global-styles/hooks.js +10 -1
  59. package/build-module/components/global-styles/hooks.js.map +1 -1
  60. package/build-module/components/global-styles/screen-color-palette.js +14 -19
  61. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  62. package/build-module/components/global-styles/screen-colors.js +9 -1
  63. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  64. package/build-module/components/global-styles/screen-link-color.js +47 -14
  65. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  66. package/build-module/components/global-styles/use-global-styles-output.js +171 -35
  67. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  68. package/build-module/components/global-styles/utils.js +2 -2
  69. package/build-module/components/global-styles/utils.js.map +1 -1
  70. package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
  71. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  72. package/build-module/components/template-details/edit-template-title.js +12 -3
  73. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  74. package/build-module/components/template-details/index.js +2 -21
  75. package/build-module/components/template-details/index.js.map +1 -1
  76. package/build-module/store/selectors.js +5 -2
  77. package/build-module/store/selectors.js.map +1 -1
  78. package/build-style/style-rtl.css +21 -23
  79. package/build-style/style.css +21 -23
  80. package/package.json +29 -29
  81. package/src/components/add-new-template/add-custom-generic-template-modal.js +97 -0
  82. package/src/components/add-new-template/add-custom-template-modal.js +92 -58
  83. package/src/components/add-new-template/new-template.js +142 -94
  84. package/src/components/add-new-template/style.scss +21 -0
  85. package/src/components/add-new-template/utils.js +290 -46
  86. package/src/components/code-editor/index.js +15 -5
  87. package/src/components/editor/index.js +11 -0
  88. package/src/components/error-boundary/index.js +5 -0
  89. package/src/components/global-styles/dimensions-panel.js +2 -7
  90. package/src/components/global-styles/global-styles-provider.js +8 -9
  91. package/src/components/global-styles/hooks.js +15 -0
  92. package/src/components/global-styles/screen-color-palette.js +25 -27
  93. package/src/components/global-styles/screen-colors.js +9 -3
  94. package/src/components/global-styles/screen-link-color.js +65 -23
  95. package/src/components/global-styles/style.scss +7 -11
  96. package/src/components/global-styles/test/use-global-styles-output.js +168 -0
  97. package/src/components/global-styles/use-global-styles-output.js +234 -59
  98. package/src/components/global-styles/utils.js +2 -2
  99. package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
  100. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
  101. package/src/components/list/style.scss +0 -8
  102. package/src/components/template-details/edit-template-title.js +10 -2
  103. package/src/components/template-details/index.js +4 -21
  104. package/src/components/test/error-boundary.js +38 -0
  105. package/src/store/selectors.js +11 -5
@@ -13,6 +13,8 @@ var _i18n = require("@wordpress/i18n");
13
13
 
14
14
  var _blockEditor = require("@wordpress/block-editor");
15
15
 
16
+ var _components = require("@wordpress/components");
17
+
16
18
  var _header = _interopRequireDefault(require("./header"));
17
19
 
18
20
  var _hooks = require("./hooks");
@@ -34,27 +36,59 @@ function ScreenLinkColor(_ref) {
34
36
  const colorsPerOrigin = (0, _hooks.useColorsPerOrigin)(name);
35
37
  const [isLinkEnabled] = (0, _hooks.useSetting)('color.link', name);
36
38
  const hasLinkColor = supports.includes('linkColor') && isLinkEnabled && (solids.length > 0 || areCustomSolidsEnabled);
37
- const [linkColor, setLinkColor] = (0, _hooks.useStyle)('elements.link.color.text', name);
38
- const [userLinkColor] = (0, _hooks.useStyle)('elements.link.color.text', name, 'user');
39
+ const pseudoStates = {
40
+ default: {
41
+ label: (0, _i18n.__)('Default'),
42
+ value: (0, _hooks.useStyle)('elements.link.color.text', name)[0],
43
+ handler: (0, _hooks.useStyle)('elements.link.color.text', name)[1],
44
+ userValue: (0, _hooks.useStyle)('elements.link.color.text', name, 'user')[0]
45
+ },
46
+ hover: {
47
+ label: (0, _i18n.__)('Hover'),
48
+ value: (0, _hooks.useStyle)('elements.link.:hover.color.text', name)[0],
49
+ handler: (0, _hooks.useStyle)('elements.link.:hover.color.text', name)[1],
50
+ userValue: (0, _hooks.useStyle)('elements.link.:hover.color.text', name, 'user')[0]
51
+ }
52
+ };
39
53
 
40
54
  if (!hasLinkColor) {
41
55
  return null;
42
56
  }
43
57
 
58
+ const tabs = Object.entries(pseudoStates).map(_ref2 => {
59
+ let [selector, config] = _ref2;
60
+ return {
61
+ name: selector,
62
+ title: config.label,
63
+ className: `color-text-${selector}`
64
+ };
65
+ });
44
66
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_header.default, {
45
67
  title: (0, _i18n.__)('Links'),
46
- description: (0, _i18n.__)('Set the default color used for links across the site.')
47
- }), (0, _element.createElement)(_blockEditor.__experimentalColorGradientControl, {
48
- className: "edit-site-screen-link-color__control",
49
- colors: colorsPerOrigin,
50
- disableCustomColors: !areCustomSolidsEnabled,
51
- __experimentalHasMultipleOrigins: true,
52
- showTitle: false,
53
- enableAlpha: true,
54
- __experimentalIsRenderedInSidebar: true,
55
- colorValue: linkColor,
56
- onColorChange: setLinkColor,
57
- clearable: linkColor === userLinkColor
68
+ description: (0, _i18n.__)('Set the colors used for links across the site.')
69
+ }), (0, _element.createElement)(_components.TabPanel, {
70
+ tabs: tabs
71
+ }, tab => {
72
+ var _pseudoStates$tab$nam;
73
+
74
+ const pseudoSelectorConfig = (_pseudoStates$tab$nam = pseudoStates[tab.name]) !== null && _pseudoStates$tab$nam !== void 0 ? _pseudoStates$tab$nam : null;
75
+
76
+ if (!pseudoSelectorConfig) {
77
+ return null;
78
+ }
79
+
80
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.__experimentalColorGradientControl, {
81
+ className: "edit-site-screen-link-color__control",
82
+ colors: colorsPerOrigin,
83
+ disableCustomColors: !areCustomSolidsEnabled,
84
+ __experimentalHasMultipleOrigins: true,
85
+ showTitle: false,
86
+ enableAlpha: true,
87
+ __experimentalIsRenderedInSidebar: true,
88
+ colorValue: pseudoSelectorConfig.value,
89
+ onColorChange: pseudoSelectorConfig.handler,
90
+ clearable: pseudoSelectorConfig.value === pseudoSelectorConfig.userValue
91
+ }));
58
92
  }));
59
93
  }
60
94
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-link-color.js"],"names":["ScreenLinkColor","name","supports","solids","areCustomSolidsEnabled","colorsPerOrigin","isLinkEnabled","hasLinkColor","includes","length","linkColor","setLinkColor","userLinkColor"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AASA,SAASA,eAAT,OAAqC;AAAA,MAAX;AAAEC,IAAAA;AAAF,GAAW;AACpC,QAAMC,QAAQ,GAAG,2CAAgCD,IAAhC,CAAjB;AACA,QAAM,CAAEE,MAAF,IAAa,uBAAY,eAAZ,EAA6BF,IAA7B,CAAnB;AACA,QAAM,CAAEG,sBAAF,IAA6B,uBAAY,cAAZ,EAA4BH,IAA5B,CAAnC;AAEA,QAAMI,eAAe,GAAG,+BAAoBJ,IAApB,CAAxB;AAEA,QAAM,CAAEK,aAAF,IAAoB,uBAAY,YAAZ,EAA0BL,IAA1B,CAA1B;AAEA,QAAMM,YAAY,GACjBL,QAAQ,CAACM,QAAT,CAAmB,WAAnB,KACAF,aADA,KAEEH,MAAM,CAACM,MAAP,GAAgB,CAAhB,IAAqBL,sBAFvB,CADD;AAKA,QAAM,CAAEM,SAAF,EAAaC,YAAb,IAA8B,qBACnC,0BADmC,EAEnCV,IAFmC,CAApC;AAIA,QAAM,CAAEW,aAAF,IAAoB,qBACzB,0BADyB,EAEzBX,IAFyB,EAGzB,MAHyB,CAA1B;;AAMA,MAAK,CAAEM,YAAP,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,eAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,WAAW,EAAG,cACb,uDADa;AAFf,IADD,EAOC,4BAAC,+CAAD;AACC,IAAA,SAAS,EAAC,sCADX;AAEC,IAAA,MAAM,EAAGF,eAFV;AAGC,IAAA,mBAAmB,EAAG,CAAED,sBAHzB;AAIC,IAAA,gCAAgC,MAJjC;AAKC,IAAA,SAAS,EAAG,KALb;AAMC,IAAA,WAAW,MANZ;AAOC,IAAA,iCAAiC,MAPlC;AAQC,IAAA,UAAU,EAAGM,SARd;AASC,IAAA,aAAa,EAAGC,YATjB;AAUC,IAAA,SAAS,EAAGD,SAAS,KAAKE;AAV3B,IAPD,CADD;AAsBA;;eAEcZ,e","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport ScreenHeader from './header';\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseSetting,\n\tuseStyle,\n\tuseColorsPerOrigin,\n} from './hooks';\n\nfunction ScreenLinkColor( { name } ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ solids ] = useSetting( 'color.palette', name );\n\tconst [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );\n\n\tconst colorsPerOrigin = useColorsPerOrigin( name );\n\n\tconst [ isLinkEnabled ] = useSetting( 'color.link', name );\n\n\tconst hasLinkColor =\n\t\tsupports.includes( 'linkColor' ) &&\n\t\tisLinkEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\n\tconst [ linkColor, setLinkColor ] = useStyle(\n\t\t'elements.link.color.text',\n\t\tname\n\t);\n\tconst [ userLinkColor ] = useStyle(\n\t\t'elements.link.color.text',\n\t\tname,\n\t\t'user'\n\t);\n\n\tif ( ! hasLinkColor ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Links' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Set the default color used for links across the site.'\n\t\t\t\t) }\n\t\t\t/>\n\t\t\t<ColorGradientControl\n\t\t\t\tclassName=\"edit-site-screen-link-color__control\"\n\t\t\t\tcolors={ colorsPerOrigin }\n\t\t\t\tdisableCustomColors={ ! areCustomSolidsEnabled }\n\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\tshowTitle={ false }\n\t\t\t\tenableAlpha\n\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\tcolorValue={ linkColor }\n\t\t\t\tonColorChange={ setLinkColor }\n\t\t\t\tclearable={ linkColor === userLinkColor }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ScreenLinkColor;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/screen-link-color.js"],"names":["ScreenLinkColor","name","supports","solids","areCustomSolidsEnabled","colorsPerOrigin","isLinkEnabled","hasLinkColor","includes","length","pseudoStates","default","label","value","handler","userValue","hover","tabs","Object","entries","map","selector","config","title","className","tab","pseudoSelectorConfig"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor';\nimport { TabPanel } from '@wordpress/components';\n/**\n * Internal dependencies\n */\nimport ScreenHeader from './header';\nimport {\n\tgetSupportedGlobalStylesPanels,\n\tuseSetting,\n\tuseStyle,\n\tuseColorsPerOrigin,\n} from './hooks';\n\nfunction ScreenLinkColor( { name } ) {\n\tconst supports = getSupportedGlobalStylesPanels( name );\n\tconst [ solids ] = useSetting( 'color.palette', name );\n\tconst [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );\n\n\tconst colorsPerOrigin = useColorsPerOrigin( name );\n\n\tconst [ isLinkEnabled ] = useSetting( 'color.link', name );\n\n\tconst hasLinkColor =\n\t\tsupports.includes( 'linkColor' ) &&\n\t\tisLinkEnabled &&\n\t\t( solids.length > 0 || areCustomSolidsEnabled );\n\n\tconst pseudoStates = {\n\t\tdefault: {\n\t\t\tlabel: __( 'Default' ),\n\t\t\tvalue: useStyle( 'elements.link.color.text', name )[ 0 ],\n\t\t\thandler: useStyle( 'elements.link.color.text', name )[ 1 ],\n\t\t\tuserValue: useStyle(\n\t\t\t\t'elements.link.color.text',\n\t\t\t\tname,\n\t\t\t\t'user'\n\t\t\t)[ 0 ],\n\t\t},\n\t\thover: {\n\t\t\tlabel: __( 'Hover' ),\n\t\t\tvalue: useStyle( 'elements.link.:hover.color.text', name )[ 0 ],\n\t\t\thandler: useStyle( 'elements.link.:hover.color.text', name )[ 1 ],\n\t\t\tuserValue: useStyle(\n\t\t\t\t'elements.link.:hover.color.text',\n\t\t\t\tname,\n\t\t\t\t'user'\n\t\t\t)[ 0 ],\n\t\t},\n\t};\n\n\tif ( ! hasLinkColor ) {\n\t\treturn null;\n\t}\n\n\tconst tabs = Object.entries( pseudoStates ).map(\n\t\t( [ selector, config ] ) => {\n\t\t\treturn {\n\t\t\t\tname: selector,\n\t\t\t\ttitle: config.label,\n\t\t\t\tclassName: `color-text-${ selector }`,\n\t\t\t};\n\t\t}\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<ScreenHeader\n\t\t\t\ttitle={ __( 'Links' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'Set the colors used for links across the site.'\n\t\t\t\t) }\n\t\t\t/>\n\n\t\t\t<TabPanel tabs={ tabs }>\n\t\t\t\t{ ( tab ) => {\n\t\t\t\t\tconst pseudoSelectorConfig =\n\t\t\t\t\t\tpseudoStates[ tab.name ] ?? null;\n\n\t\t\t\t\tif ( ! pseudoSelectorConfig ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ColorGradientControl\n\t\t\t\t\t\t\t\tclassName=\"edit-site-screen-link-color__control\"\n\t\t\t\t\t\t\t\tcolors={ colorsPerOrigin }\n\t\t\t\t\t\t\t\tdisableCustomColors={ ! areCustomSolidsEnabled }\n\t\t\t\t\t\t\t\t__experimentalHasMultipleOrigins\n\t\t\t\t\t\t\t\tshowTitle={ false }\n\t\t\t\t\t\t\t\tenableAlpha\n\t\t\t\t\t\t\t\t__experimentalIsRenderedInSidebar\n\t\t\t\t\t\t\t\tcolorValue={ pseudoSelectorConfig.value }\n\t\t\t\t\t\t\t\tonColorChange={ pseudoSelectorConfig.handler }\n\t\t\t\t\t\t\t\tclearable={\n\t\t\t\t\t\t\t\t\tpseudoSelectorConfig.value ===\n\t\t\t\t\t\t\t\t\tpseudoSelectorConfig.userValue\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t</TabPanel>\n\t\t</>\n\t);\n}\n\nexport default ScreenLinkColor;\n"]}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getLayoutStyles = getLayoutStyles;
6
7
  exports.toStyles = exports.toCustomProperties = exports.getNodesWithStyles = exports.getNodesWithSettings = void 0;
7
8
  exports.toSvgFilters = toSvgFilters;
8
9
  exports.useGlobalStylesOutput = useGlobalStylesOutput;
@@ -181,7 +182,7 @@ function getStylesDeclarations() {
181
182
 
182
183
  const styleValue = (0, _lodash.get)(blockStyles, pathToValue);
183
184
 
184
- if (!!properties && !(0, _lodash.isString)(styleValue)) {
185
+ if (!!properties && typeof styleValue !== 'string') {
185
186
  Object.entries(properties).forEach(entry => {
186
187
  const [name, prop] = entry;
187
188
 
@@ -210,6 +211,117 @@ function getStylesDeclarations() {
210
211
  });
211
212
  return output;
212
213
  }
214
+ /**
215
+ * Get generated CSS for layout styles by looking up layout definitions provided
216
+ * in theme.json, and outputting common layout styles, and specific blockGap values.
217
+ *
218
+ * @param {Object} props
219
+ * @param {Object} props.tree A theme.json tree containing layout definitions.
220
+ * @param {Object} props.style A style object containing spacing values.
221
+ * @param {string} props.selector Selector used to group together layout styling rules.
222
+ * @param {boolean} props.hasBlockGapSupport Whether or not the theme opts-in to blockGap support.
223
+ * @param {boolean} props.hasFallbackGapSupport Whether or not the theme allows fallback gap styles.
224
+ * @param {?string} props.fallbackGapValue An optional fallback gap value if no real gap value is available.
225
+ * @return {string} Generated CSS rules for the layout styles.
226
+ */
227
+
228
+
229
+ function getLayoutStyles(_ref6) {
230
+ var _style$spacing, _tree$settings, _tree$settings$layout, _tree$settings2, _tree$settings2$layou;
231
+
232
+ let {
233
+ tree,
234
+ style,
235
+ selector,
236
+ hasBlockGapSupport,
237
+ hasFallbackGapSupport,
238
+ fallbackGapValue
239
+ } = _ref6;
240
+ let ruleset = '';
241
+ let gapValue = hasBlockGapSupport ? (0, _blockEditor.__experimentalGetGapCSSValue)(style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.blockGap) : ''; // Ensure a fallback gap value for the root layout definitions,
242
+ // and use a fallback value if one is provided for the current block.
243
+
244
+ if (hasFallbackGapSupport) {
245
+ if (selector === _utils.ROOT_BLOCK_SELECTOR) {
246
+ gapValue = !gapValue ? '0.5em' : gapValue;
247
+ } else if (!hasBlockGapSupport && fallbackGapValue) {
248
+ gapValue = fallbackGapValue;
249
+ }
250
+ }
251
+
252
+ if (gapValue && tree !== null && tree !== void 0 && (_tree$settings = tree.settings) !== null && _tree$settings !== void 0 && (_tree$settings$layout = _tree$settings.layout) !== null && _tree$settings$layout !== void 0 && _tree$settings$layout.definitions) {
253
+ Object.values(tree.settings.layout.definitions).forEach(_ref7 => {
254
+ let {
255
+ className,
256
+ name,
257
+ spacingStyles
258
+ } = _ref7;
259
+
260
+ // Allow skipping default layout for themes that opt-in to block styles, but opt-out of blockGap.
261
+ if (!hasBlockGapSupport && 'default' === name) {
262
+ return;
263
+ }
264
+
265
+ if (spacingStyles !== null && spacingStyles !== void 0 && spacingStyles.length) {
266
+ spacingStyles.forEach(spacingStyle => {
267
+ const declarations = [];
268
+
269
+ if (spacingStyle.rules) {
270
+ Object.entries(spacingStyle.rules).forEach(_ref8 => {
271
+ let [cssProperty, cssValue] = _ref8;
272
+ declarations.push(`${cssProperty}: ${cssValue ? cssValue : gapValue}`);
273
+ });
274
+ }
275
+
276
+ if (declarations.length) {
277
+ const combinedSelector = selector === _utils.ROOT_BLOCK_SELECTOR ? `${selector} .${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}` : `${selector}.${className}${(spacingStyle === null || spacingStyle === void 0 ? void 0 : spacingStyle.selector) || ''}`;
278
+ ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
279
+ }
280
+ });
281
+ }
282
+ }); // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
283
+
284
+ if (selector === _utils.ROOT_BLOCK_SELECTOR && hasBlockGapSupport) {
285
+ ruleset += `${selector} { --wp--style--block-gap: ${gapValue}; }`;
286
+ }
287
+ } // Output base styles
288
+
289
+
290
+ if (selector === _utils.ROOT_BLOCK_SELECTOR && tree !== null && tree !== void 0 && (_tree$settings2 = tree.settings) !== null && _tree$settings2 !== void 0 && (_tree$settings2$layou = _tree$settings2.layout) !== null && _tree$settings2$layou !== void 0 && _tree$settings2$layou.definitions) {
291
+ const validDisplayModes = ['block', 'flex', 'grid'];
292
+ Object.values(tree.settings.layout.definitions).forEach(_ref9 => {
293
+ let {
294
+ className,
295
+ displayMode,
296
+ baseStyles
297
+ } = _ref9;
298
+
299
+ if (displayMode && validDisplayModes.includes(displayMode)) {
300
+ ruleset += `${selector} .${className} { display:${displayMode}; }`;
301
+ }
302
+
303
+ if (baseStyles !== null && baseStyles !== void 0 && baseStyles.length) {
304
+ baseStyles.forEach(baseStyle => {
305
+ const declarations = [];
306
+
307
+ if (baseStyle.rules) {
308
+ Object.entries(baseStyle.rules).forEach(_ref10 => {
309
+ let [cssProperty, cssValue] = _ref10;
310
+ declarations.push(`${cssProperty}: ${cssValue}`);
311
+ });
312
+ }
313
+
314
+ if (declarations.length) {
315
+ const combinedSelector = `${selector} .${className}${(baseStyle === null || baseStyle === void 0 ? void 0 : baseStyle.selector) || ''}`;
316
+ ruleset += `${combinedSelector} { ${declarations.join('; ')}; }`;
317
+ }
318
+ });
319
+ }
320
+ });
321
+ }
322
+
323
+ return ruleset;
324
+ }
213
325
 
214
326
  const getNodesWithStyles = (tree, blockSelectors) => {
215
327
  var _tree$styles, _tree$styles2;
@@ -248,9 +360,11 @@ const getNodesWithStyles = (tree, blockSelectors) => {
248
360
 
249
361
  if (!!blockStyles && !!(blockSelectors !== null && blockSelectors !== void 0 && (_blockSelectors$block = blockSelectors[blockName]) !== null && _blockSelectors$block !== void 0 && _blockSelectors$block.selector)) {
250
362
  nodes.push({
251
- styles: blockStyles,
363
+ duotoneSelector: blockSelectors[blockName].duotoneSelector,
364
+ fallbackGapValue: blockSelectors[blockName].fallbackGapValue,
365
+ hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport,
252
366
  selector: blockSelectors[blockName].selector,
253
- duotoneSelector: blockSelectors[blockName].duotoneSelector
367
+ styles: blockStyles
254
368
  });
255
369
  }
256
370
 
@@ -273,7 +387,7 @@ const getNodesWithStyles = (tree, blockSelectors) => {
273
387
  exports.getNodesWithStyles = getNodesWithStyles;
274
388
 
275
389
  const getNodesWithSettings = (tree, blockSelectors) => {
276
- var _tree$settings, _tree$settings2;
390
+ var _tree$settings3, _tree$settings4;
277
391
 
278
392
  const nodes = [];
279
393
 
@@ -284,10 +398,10 @@ const getNodesWithSettings = (tree, blockSelectors) => {
284
398
  const pickPresets = treeToPickFrom => {
285
399
  const presets = {};
286
400
 
287
- _utils.PRESET_METADATA.forEach(_ref6 => {
401
+ _utils.PRESET_METADATA.forEach(_ref11 => {
288
402
  let {
289
403
  path
290
- } = _ref6;
404
+ } = _ref11;
291
405
  const value = (0, _lodash.get)(treeToPickFrom, path, false);
292
406
 
293
407
  if (value !== false) {
@@ -300,7 +414,7 @@ const getNodesWithSettings = (tree, blockSelectors) => {
300
414
 
301
415
 
302
416
  const presets = pickPresets(tree.settings);
303
- const custom = (_tree$settings = tree.settings) === null || _tree$settings === void 0 ? void 0 : _tree$settings.custom;
417
+ const custom = (_tree$settings3 = tree.settings) === null || _tree$settings3 === void 0 ? void 0 : _tree$settings3.custom;
304
418
 
305
419
  if (!(0, _lodash.isEmpty)(presets) || !!custom) {
306
420
  nodes.push({
@@ -311,7 +425,7 @@ const getNodesWithSettings = (tree, blockSelectors) => {
311
425
  } // Blocks.
312
426
 
313
427
 
314
- (0, _lodash.forEach)((_tree$settings2 = tree.settings) === null || _tree$settings2 === void 0 ? void 0 : _tree$settings2.blocks, (node, blockName) => {
428
+ (0, _lodash.forEach)((_tree$settings4 = tree.settings) === null || _tree$settings4 === void 0 ? void 0 : _tree$settings4.blocks, (node, blockName) => {
315
429
  const blockPresets = pickPresets(node);
316
430
  const blockCustom = node.custom;
317
431
 
@@ -331,12 +445,12 @@ exports.getNodesWithSettings = getNodesWithSettings;
331
445
  const toCustomProperties = (tree, blockSelectors) => {
332
446
  const settings = getNodesWithSettings(tree, blockSelectors);
333
447
  let ruleset = '';
334
- settings.forEach(_ref7 => {
448
+ settings.forEach(_ref12 => {
335
449
  let {
336
450
  presets,
337
451
  custom,
338
452
  selector
339
- } = _ref7;
453
+ } = _ref12;
340
454
  const declarations = getPresetsDeclarations(presets);
341
455
  const customProps = flattenTree(custom, '--wp--custom--', '--');
342
456
 
@@ -353,7 +467,7 @@ const toCustomProperties = (tree, blockSelectors) => {
353
467
 
354
468
  exports.toCustomProperties = toCustomProperties;
355
469
 
356
- const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
470
+ const toStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport) => {
357
471
  const nodesWithStyles = getNodesWithStyles(tree, blockSelectors);
358
472
  const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
359
473
  /*
@@ -366,12 +480,14 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
366
480
  */
367
481
 
368
482
  let ruleset = 'body {margin: 0;}';
369
- nodesWithStyles.forEach(_ref8 => {
483
+ nodesWithStyles.forEach(_ref13 => {
370
484
  let {
371
485
  selector,
372
486
  duotoneSelector,
373
- styles
374
- } = _ref8;
487
+ styles,
488
+ fallbackGapValue,
489
+ hasLayoutSupport
490
+ } = _ref13;
375
491
  const duotoneStyles = {};
376
492
 
377
493
  if (styles !== null && styles !== void 0 && styles.filter) {
@@ -388,7 +504,19 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
388
504
  }
389
505
 
390
506
  ruleset = ruleset + `${duotoneSelector}{${duotoneDeclarations.join(';')};}`;
391
- } // Process the remaning block styles (they use either normal block class or __experimentalSelector).
507
+ } // Process blockGap and layout styles.
508
+
509
+
510
+ if (_utils.ROOT_BLOCK_SELECTOR === selector || hasLayoutSupport) {
511
+ ruleset += getLayoutStyles({
512
+ tree,
513
+ style: styles,
514
+ selector,
515
+ hasBlockGapSupport,
516
+ hasFallbackGapSupport,
517
+ fallbackGapValue
518
+ });
519
+ } // Process the remaining block styles (they use either normal block class or __experimentalSelector).
392
520
 
393
521
 
394
522
  const declarations = getStylesDeclarations(styles);
@@ -398,15 +526,15 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
398
526
  } // Check for pseudo selector in `styles` and handle separately.
399
527
 
400
528
 
401
- const psuedoSelectorStyles = Object.entries(styles).filter(_ref9 => {
402
- let [key] = _ref9;
529
+ const pseudoSelectorStyles = Object.entries(styles).filter(_ref14 => {
530
+ let [key] = _ref14;
403
531
  return key.startsWith(':');
404
532
  });
405
533
 
406
- if (psuedoSelectorStyles !== null && psuedoSelectorStyles !== void 0 && psuedoSelectorStyles.length) {
407
- psuedoSelectorStyles.forEach(_ref10 => {
408
- let [pseudoKey, pseudoRule] = _ref10;
409
- const pseudoDeclarations = getStylesDeclarations(pseudoRule);
534
+ if (pseudoSelectorStyles !== null && pseudoSelectorStyles !== void 0 && pseudoSelectorStyles.length) {
535
+ pseudoSelectorStyles.forEach(_ref15 => {
536
+ let [pseudoKey, pseudoStyle] = _ref15;
537
+ const pseudoDeclarations = getStylesDeclarations(pseudoStyle);
410
538
 
411
539
  if (!(pseudoDeclarations !== null && pseudoDeclarations !== void 0 && pseudoDeclarations.length)) {
412
540
  return;
@@ -421,8 +549,8 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
421
549
 
422
550
  const _selector = selector.split(',').map(sel => sel + pseudoKey).join(',');
423
551
 
424
- const psuedoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
425
- ruleset = ruleset + psuedoRule;
552
+ const pseudoRule = `${_selector}{${pseudoDeclarations.join(';')};}`;
553
+ ruleset = ruleset + pseudoRule;
426
554
  });
427
555
  }
428
556
  });
@@ -433,15 +561,19 @@ const toStyles = (tree, blockSelectors, hasBlockGapSupport) => {
433
561
  ruleset = ruleset + '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }';
434
562
 
435
563
  if (hasBlockGapSupport) {
564
+ var _tree$styles3, _tree$styles3$spacing;
565
+
566
+ // Use fallback of `0.5em` just in case, however if there is blockGap support, there should nearly always be a real value.
567
+ const gapValue = (0, _blockEditor.__experimentalGetGapCSSValue)(tree === null || tree === void 0 ? void 0 : (_tree$styles3 = tree.styles) === null || _tree$styles3 === void 0 ? void 0 : (_tree$styles3$spacing = _tree$styles3.spacing) === null || _tree$styles3$spacing === void 0 ? void 0 : _tree$styles3$spacing.blockGap) || '0.5em';
436
568
  ruleset = ruleset + '.wp-site-blocks > * { margin-block-start: 0; margin-block-end: 0; }';
437
- ruleset = ruleset + '.wp-site-blocks > * + * { margin-block-start: var( --wp--style--block-gap ); }';
569
+ ruleset = ruleset + `.wp-site-blocks > * + * { margin-block-start: ${gapValue}; }`;
438
570
  }
439
571
 
440
- nodesWithSettings.forEach(_ref11 => {
572
+ nodesWithSettings.forEach(_ref16 => {
441
573
  let {
442
574
  selector,
443
575
  presets
444
- } = _ref11;
576
+ } = _ref16;
445
577
 
446
578
  if (_utils.ROOT_BLOCK_SELECTOR === selector) {
447
579
  // Do not add extra specificity for top-level classes.
@@ -461,10 +593,10 @@ exports.toStyles = toStyles;
461
593
 
462
594
  function toSvgFilters(tree, blockSelectors) {
463
595
  const nodesWithSettings = getNodesWithSettings(tree, blockSelectors);
464
- return nodesWithSettings.flatMap(_ref12 => {
596
+ return nodesWithSettings.flatMap(_ref17 => {
465
597
  let {
466
598
  presets
467
- } = _ref12;
599
+ } = _ref17;
468
600
  return getPresetsSvgFilters(presets);
469
601
  });
470
602
  }
@@ -472,15 +604,19 @@ function toSvgFilters(tree, blockSelectors) {
472
604
  const getBlockSelectors = blockTypes => {
473
605
  const result = {};
474
606
  blockTypes.forEach(blockType => {
475
- var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$;
607
+ var _blockType$supports$_, _blockType$supports, _blockType$supports$c, _blockType$supports2, _blockType$supports2$, _blockType$supports3, _blockType$supports4, _blockType$supports4$, _blockType$supports4$2;
476
608
 
477
609
  const name = blockType.name;
478
610
  const selector = (_blockType$supports$_ = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports = blockType.supports) === null || _blockType$supports === void 0 ? void 0 : _blockType$supports.__experimentalSelector) !== null && _blockType$supports$_ !== void 0 ? _blockType$supports$_ : '.wp-block-' + name.replace('core/', '').replace('/', '-');
479
611
  const duotoneSelector = (_blockType$supports$c = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports2 = blockType.supports) === null || _blockType$supports2 === void 0 ? void 0 : (_blockType$supports2$ = _blockType$supports2.color) === null || _blockType$supports2$ === void 0 ? void 0 : _blockType$supports2$.__experimentalDuotone) !== null && _blockType$supports$c !== void 0 ? _blockType$supports$c : null;
612
+ const hasLayoutSupport = !!(blockType !== null && blockType !== void 0 && (_blockType$supports3 = blockType.supports) !== null && _blockType$supports3 !== void 0 && _blockType$supports3.__experimentalLayout);
613
+ const fallbackGapValue = blockType === null || blockType === void 0 ? void 0 : (_blockType$supports4 = blockType.supports) === null || _blockType$supports4 === void 0 ? void 0 : (_blockType$supports4$ = _blockType$supports4.spacing) === null || _blockType$supports4$ === void 0 ? void 0 : (_blockType$supports4$2 = _blockType$supports4$.blockGap) === null || _blockType$supports4$2 === void 0 ? void 0 : _blockType$supports4$2.__experimentalDefault;
480
614
  result[name] = {
615
+ duotoneSelector,
616
+ fallbackGapValue,
617
+ hasLayoutSupport,
481
618
  name,
482
- selector,
483
- duotoneSelector
619
+ selector
484
620
  };
485
621
  });
486
622
  return result;
@@ -495,6 +631,8 @@ function useGlobalStylesOutput() {
495
631
  } = (0, _element.useContext)(_context.GlobalStylesContext);
496
632
  const [blockGap] = (0, _hooks.useSetting)('spacing.blockGap');
497
633
  const hasBlockGapSupport = blockGap !== null;
634
+ const hasFallbackGapSupport = !hasBlockGapSupport; // This setting isn't useful yet: it exists as a placeholder for a future explicit fallback styles support.
635
+
498
636
  (0, _element.useEffect)(() => {
499
637
  if (!(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.styles) || !(mergedConfig !== null && mergedConfig !== void 0 && mergedConfig.settings)) {
500
638
  return;
@@ -502,7 +640,7 @@ function useGlobalStylesOutput() {
502
640
 
503
641
  const blockSelectors = getBlockSelectors((0, _blocks.getBlockTypes)());
504
642
  const customProperties = toCustomProperties(mergedConfig, blockSelectors);
505
- const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport);
643
+ const globalStyles = toStyles(mergedConfig, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport);
506
644
  const filters = toSvgFilters(mergedConfig, blockSelectors);
507
645
  setStylesheets([{
508
646
  css: customProperties,
@@ -513,7 +651,7 @@ function useGlobalStylesOutput() {
513
651
  }]);
514
652
  setSettings(mergedConfig.settings);
515
653
  setSvgFilters(filters);
516
- }, [mergedConfig]);
654
+ }, [hasBlockGapSupport, hasFallbackGapSupport, mergedConfig]);
517
655
  return [stylesheets, settings, svgFilters, hasBlockGapSupport];
518
656
  }
519
657
  //# sourceMappingURL=use-global-styles-output.js.map