@wordpress/edit-site 5.3.6 → 5.5.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 (217) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/new-template.js +1 -20
  3. package/build/components/add-new-template/new-template.js.map +1 -1
  4. package/build/components/app/index.js.map +1 -1
  5. package/build/components/block-editor/editor-canvas.js +1 -0
  6. package/build/components/block-editor/editor-canvas.js.map +1 -1
  7. package/build/components/editor/index.js +3 -1
  8. package/build/components/editor/index.js.map +1 -1
  9. package/build/components/global-styles/border-panel.js +5 -5
  10. package/build/components/global-styles/border-panel.js.map +1 -1
  11. package/build/components/global-styles/color-palette-panel.js +5 -2
  12. package/build/components/global-styles/color-palette-panel.js.map +1 -1
  13. package/build/components/global-styles/color-utils.js +1 -1
  14. package/build/components/global-styles/color-utils.js.map +1 -1
  15. package/build/components/global-styles/context-menu.js +22 -6
  16. package/build/components/global-styles/context-menu.js.map +1 -1
  17. package/build/components/global-styles/custom-css.js +1 -1
  18. package/build/components/global-styles/custom-css.js.map +1 -1
  19. package/build/components/global-styles/dimensions-panel.js +41 -486
  20. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  21. package/build/components/global-styles/duotone-panel.js +78 -0
  22. package/build/components/global-styles/duotone-panel.js.map +1 -0
  23. package/build/components/global-styles/filter-utils.js +17 -0
  24. package/build/components/global-styles/filter-utils.js.map +1 -0
  25. package/build/components/global-styles/gradients-palette-panel.js +8 -3
  26. package/build/components/global-styles/gradients-palette-panel.js.map +1 -1
  27. package/build/components/global-styles/header.js +3 -1
  28. package/build/components/global-styles/header.js.map +1 -1
  29. package/build/components/global-styles/hooks.js +14 -51
  30. package/build/components/global-styles/hooks.js.map +1 -1
  31. package/build/components/global-styles/palette.js +3 -1
  32. package/build/components/global-styles/palette.js.map +1 -1
  33. package/build/components/global-styles/preview.js +9 -5
  34. package/build/components/global-styles/preview.js.map +1 -1
  35. package/build/components/global-styles/screen-background-color.js +3 -2
  36. package/build/components/global-styles/screen-background-color.js.map +1 -1
  37. package/build/components/global-styles/screen-block-list.js +13 -6
  38. package/build/components/global-styles/screen-block-list.js.map +1 -1
  39. package/build/components/global-styles/screen-button-color.js +7 -5
  40. package/build/components/global-styles/screen-button-color.js.map +1 -1
  41. package/build/components/global-styles/screen-colors.js +8 -6
  42. package/build/components/global-styles/screen-colors.js.map +1 -1
  43. package/build/components/global-styles/screen-filters.js +46 -0
  44. package/build/components/global-styles/screen-filters.js.map +1 -0
  45. package/build/components/global-styles/screen-heading-color.js +8 -6
  46. package/build/components/global-styles/screen-heading-color.js.map +1 -1
  47. package/build/components/global-styles/screen-layout.js +13 -5
  48. package/build/components/global-styles/screen-layout.js.map +1 -1
  49. package/build/components/global-styles/screen-link-color.js +3 -2
  50. package/build/components/global-styles/screen-link-color.js.map +1 -1
  51. package/build/components/global-styles/screen-text-color.js +3 -2
  52. package/build/components/global-styles/screen-text-color.js.map +1 -1
  53. package/build/components/global-styles/screen-typography.js +3 -1
  54. package/build/components/global-styles/screen-typography.js.map +1 -1
  55. package/build/components/global-styles/shadow-panel.js +2 -3
  56. package/build/components/global-styles/shadow-panel.js.map +1 -1
  57. package/build/components/global-styles/subtitle.js +3 -2
  58. package/build/components/global-styles/subtitle.js.map +1 -1
  59. package/build/components/global-styles/typography-panel.js +23 -303
  60. package/build/components/global-styles/typography-panel.js.map +1 -1
  61. package/build/components/global-styles/ui.js +6 -0
  62. package/build/components/global-styles/ui.js.map +1 -1
  63. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  64. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  65. package/build/components/keyboard-shortcuts/index.js +67 -0
  66. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  67. package/build/components/navigation-inspector/index.js +0 -29
  68. package/build/components/navigation-inspector/index.js.map +1 -1
  69. package/build/components/navigation-inspector/navigation-menu.js +22 -5
  70. package/build/components/navigation-inspector/navigation-menu.js.map +1 -1
  71. package/build/components/sidebar-edit-mode/index.js +1 -1
  72. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  73. package/build/components/sidebar-edit-mode/template-card/index.js +9 -2
  74. package/build/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  75. package/build/components/sidebar-edit-mode/template-card/last-revision.js +84 -0
  76. package/build/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  77. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  78. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  79. package/build/components/start-template-options/index.js +175 -0
  80. package/build/components/start-template-options/index.js.map +1 -0
  81. package/build/hooks/push-changes-to-global-styles/index.js +5 -4
  82. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  83. package/build/store/actions.js +2 -2
  84. package/build/store/actions.js.map +1 -1
  85. package/build-module/components/add-new-template/new-template.js +1 -18
  86. package/build-module/components/add-new-template/new-template.js.map +1 -1
  87. package/build-module/components/app/index.js.map +1 -1
  88. package/build-module/components/block-editor/editor-canvas.js +1 -0
  89. package/build-module/components/block-editor/editor-canvas.js.map +1 -1
  90. package/build-module/components/editor/index.js +2 -1
  91. package/build-module/components/editor/index.js.map +1 -1
  92. package/build-module/components/global-styles/border-panel.js +6 -6
  93. package/build-module/components/global-styles/border-panel.js.map +1 -1
  94. package/build-module/components/global-styles/color-palette-panel.js +5 -2
  95. package/build-module/components/global-styles/color-palette-panel.js.map +1 -1
  96. package/build-module/components/global-styles/color-utils.js +2 -2
  97. package/build-module/components/global-styles/color-utils.js.map +1 -1
  98. package/build-module/components/global-styles/context-menu.js +20 -6
  99. package/build-module/components/global-styles/context-menu.js.map +1 -1
  100. package/build-module/components/global-styles/custom-css.js +1 -1
  101. package/build-module/components/global-styles/custom-css.js.map +1 -1
  102. package/build-module/components/global-styles/dimensions-panel.js +43 -479
  103. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  104. package/build-module/components/global-styles/duotone-panel.js +67 -0
  105. package/build-module/components/global-styles/duotone-panel.js.map +1 -0
  106. package/build-module/components/global-styles/filter-utils.js +9 -0
  107. package/build-module/components/global-styles/filter-utils.js.map +1 -0
  108. package/build-module/components/global-styles/gradients-palette-panel.js +8 -3
  109. package/build-module/components/global-styles/gradients-palette-panel.js.map +1 -1
  110. package/build-module/components/global-styles/header.js +3 -1
  111. package/build-module/components/global-styles/header.js.map +1 -1
  112. package/build-module/components/global-styles/hooks.js +12 -49
  113. package/build-module/components/global-styles/hooks.js.map +1 -1
  114. package/build-module/components/global-styles/palette.js +3 -1
  115. package/build-module/components/global-styles/palette.js.map +1 -1
  116. package/build-module/components/global-styles/preview.js +10 -6
  117. package/build-module/components/global-styles/preview.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background-color.js +4 -3
  119. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  120. package/build-module/components/global-styles/screen-block-list.js +12 -5
  121. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  122. package/build-module/components/global-styles/screen-button-color.js +8 -6
  123. package/build-module/components/global-styles/screen-button-color.js.map +1 -1
  124. package/build-module/components/global-styles/screen-colors.js +9 -7
  125. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  126. package/build-module/components/global-styles/screen-filters.js +33 -0
  127. package/build-module/components/global-styles/screen-filters.js.map +1 -0
  128. package/build-module/components/global-styles/screen-heading-color.js +9 -7
  129. package/build-module/components/global-styles/screen-heading-color.js.map +1 -1
  130. package/build-module/components/global-styles/screen-layout.js +11 -2
  131. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  132. package/build-module/components/global-styles/screen-link-color.js +4 -3
  133. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  134. package/build-module/components/global-styles/screen-text-color.js +4 -3
  135. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  136. package/build-module/components/global-styles/screen-typography.js +3 -1
  137. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  138. package/build-module/components/global-styles/shadow-panel.js +3 -4
  139. package/build-module/components/global-styles/shadow-panel.js.map +1 -1
  140. package/build-module/components/global-styles/subtitle.js +3 -2
  141. package/build-module/components/global-styles/subtitle.js.map +1 -1
  142. package/build-module/components/global-styles/typography-panel.js +24 -300
  143. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  144. package/build-module/components/global-styles/ui.js +5 -0
  145. package/build-module/components/global-styles/ui.js.map +1 -1
  146. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  147. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  148. package/build-module/components/keyboard-shortcuts/index.js +65 -0
  149. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  150. package/build-module/components/navigation-inspector/index.js +0 -27
  151. package/build-module/components/navigation-inspector/index.js.map +1 -1
  152. package/build-module/components/navigation-inspector/navigation-menu.js +25 -8
  153. package/build-module/components/navigation-inspector/navigation-menu.js.map +1 -1
  154. package/build-module/components/sidebar-edit-mode/index.js +1 -1
  155. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  156. package/build-module/components/sidebar-edit-mode/template-card/index.js +9 -4
  157. package/build-module/components/sidebar-edit-mode/template-card/index.js.map +1 -1
  158. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js +70 -0
  159. package/build-module/components/sidebar-edit-mode/template-card/last-revision.js.map +1 -0
  160. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +9 -1
  161. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  162. package/build-module/components/start-template-options/index.js +156 -0
  163. package/build-module/components/start-template-options/index.js.map +1 -0
  164. package/build-module/hooks/push-changes-to-global-styles/index.js +6 -5
  165. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  166. package/build-module/store/actions.js +2 -2
  167. package/build-module/store/actions.js.map +1 -1
  168. package/build-style/style-rtl.css +73 -4
  169. package/build-style/style.css +73 -4
  170. package/package.json +31 -31
  171. package/src/components/add-new-template/new-template.js +1 -16
  172. package/src/components/app/index.js +0 -1
  173. package/src/components/block-editor/editor-canvas.js +1 -0
  174. package/src/components/editor/index.js +2 -0
  175. package/src/components/global-styles/border-panel.js +6 -6
  176. package/src/components/global-styles/color-palette-panel.js +3 -0
  177. package/src/components/global-styles/color-utils.js +2 -3
  178. package/src/components/global-styles/context-menu.js +25 -4
  179. package/src/components/global-styles/custom-css.js +1 -1
  180. package/src/components/global-styles/dimensions-panel.js +43 -573
  181. package/src/components/global-styles/duotone-panel.js +82 -0
  182. package/src/components/global-styles/filter-utils.js +9 -0
  183. package/src/components/global-styles/gradients-palette-panel.js +4 -1
  184. package/src/components/global-styles/header.js +7 -1
  185. package/src/components/global-styles/hooks.js +17 -90
  186. package/src/components/global-styles/palette.js +1 -1
  187. package/src/components/global-styles/preview.js +155 -140
  188. package/src/components/global-styles/screen-background-color.js +3 -2
  189. package/src/components/global-styles/screen-block-list.js +16 -5
  190. package/src/components/global-styles/screen-button-color.js +8 -6
  191. package/src/components/global-styles/screen-colors.js +7 -7
  192. package/src/components/global-styles/screen-filters.js +27 -0
  193. package/src/components/global-styles/screen-heading-color.js +9 -7
  194. package/src/components/global-styles/screen-layout.js +9 -2
  195. package/src/components/global-styles/screen-link-color.js +3 -2
  196. package/src/components/global-styles/screen-text-color.js +3 -2
  197. package/src/components/global-styles/screen-typography.js +1 -1
  198. package/src/components/global-styles/shadow-panel.js +6 -3
  199. package/src/components/global-styles/style.scss +5 -0
  200. package/src/components/global-styles/subtitle.js +5 -2
  201. package/src/components/global-styles/typography-panel.js +29 -395
  202. package/src/components/global-styles/ui.js +5 -0
  203. package/src/components/keyboard-shortcut-help-modal/config.js +10 -0
  204. package/src/components/keyboard-shortcuts/index.js +70 -0
  205. package/src/components/navigation-inspector/index.js +0 -32
  206. package/src/components/navigation-inspector/navigation-menu.js +24 -6
  207. package/src/components/sidebar-edit-mode/index.js +1 -1
  208. package/src/components/sidebar-edit-mode/template-card/index.js +24 -14
  209. package/src/components/sidebar-edit-mode/template-card/last-revision.js +75 -0
  210. package/src/components/sidebar-edit-mode/template-card/style.scss +4 -0
  211. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +7 -1
  212. package/src/components/sidebar-navigation-screen-navigation-menus/style.scss +0 -4
  213. package/src/components/start-template-options/index.js +171 -0
  214. package/src/components/start-template-options/style.scss +76 -0
  215. package/src/hooks/push-changes-to-global-styles/index.js +26 -21
  216. package/src/store/actions.js +2 -2
  217. package/src/style.scss +1 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/custom-css.js"],"names":["useGlobalStyle","blockEditorPrivateApis","CustomCSSControl","blockName","block","customCSS","setCustomCSS","themeCSS","cssError","setCSSError","ignoreThemeCustomCSS","themeCustomCSS","undefined","handleOnChange","value","transformed","css","handleOnBlur","event","target","originalThemeCustomCSS","replace","info"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAiBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAqB,yBAAQC,wBAAR,CAA3B;;AACA,SAASC,gBAAT,OAA2C;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AAC1C;AACA;AACA,QAAMC,KAAK,GAAG,CAAC,CAAED,SAAH,GAAeA,SAAf,GAA2B,IAAzC;AAEA,QAAM,CAAEE,SAAF,EAAaC,YAAb,IAA8BN,cAAc,CAAE,KAAF,EAASI,KAAT,CAAlD;AACA,QAAM,CAAEG,QAAF,IAAeP,cAAc,CAAE,KAAF,EAASI,KAAT,EAAgB,MAAhB,CAAnC;AACA,QAAM,CAAEI,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,IAAV,CAAlC;AACA,QAAMC,oBAAoB,GAAG,4BAA7B,CAR0C,CAU1C;AACA;AACA;;AACA,QAAMC,cAAc,GACnB,CAAEN,SAAF,IAAeE,QAAf,GACI,MAAM,cACP,wBADO,CAEJ,QAAQA,QAAU,QAAQ,cAAI,sBAAJ,CAA8B,KAH9D,GAI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ACC,4BAAC,iBAAD,QAAY,cAAI,gBAAJ,CAAZ,CADD,EAEC,4BAAC,2BAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EACJ,CAAAf,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEgB,OAAX,CAAoBX,oBAApB,EAA0C,EAA1C,MACAC,cAJF;AAMC,IAAA,QAAQ,EAAKG,KAAF,IAAaD,cAAc,CAAEC,KAAF,CANvC;AAOC,IAAA,MAAM,EAAGG,YAPV;AAQC,IAAA,SAAS,EAAC,2CARX;AASC,IAAA,UAAU,EAAG;AATd,IAFD,EAaGT,QAAQ,IACT,4BAAC,mBAAD;AAAS,IAAA,IAAI,EAAGA;AAAhB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD;AACC,IAAA,IAAI,EAAGc,WADR;AAEC,IAAA,SAAS,EAAC;AAFX,IADD,CADD,CAdF,CAbD,CADD;AAwCA;;eAEcpB,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\tTextareaControl,\n\tPanel,\n\tPanelBody,\n\t__experimentalVStack as VStack,\n\tTooltip,\n\tIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\ttransformStyles,\n} from '@wordpress/block-editor';\nimport { info } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport Subtitle from './subtitle';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\nfunction CustomCSSControl( { blockName } ) {\n\t// If blockName is defined, we are customizing CSS at the block level:\n\t// styles.blocks.blockName.css\n\tconst block = !! blockName ? blockName : null;\n\n\tconst [ customCSS, setCustomCSS ] = useGlobalStyle( 'css', block );\n\tconst [ themeCSS ] = useGlobalStyle( 'css', block, 'base' );\n\tconst [ cssError, setCSSError ] = useState( null );\n\tconst ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */';\n\n\t// If there is custom css from theme.json show it in the edit box\n\t// so the user can selectively overwrite it, rather than have the user CSS\n\t// completely overwrite the theme CSS by default.\n\tconst themeCustomCSS =\n\t\t! customCSS && themeCSS\n\t\t\t? `/* ${ __(\n\t\t\t\t\t'Theme Custom CSS start'\n\t\t\t ) } */\\n${ themeCSS }\\n/* ${ __( 'Theme Custom CSS end' ) } */`\n\t\t\t: undefined;\n\n\tfunction handleOnChange( value ) {\n\t\t// If there is theme custom CSS, but the user clears the input box then save the\n\t\t// ignoreThemeCustomCSS string so that the theme custom CSS is not re-applied.\n\t\tif ( themeCSS && value === '' ) {\n\t\t\tsetCustomCSS( ignoreThemeCustomCSS );\n\t\t\treturn;\n\t\t}\n\t\tsetCustomCSS( value );\n\t\tif ( cssError ) {\n\t\t\tconst [ transformed ] = transformStyles(\n\t\t\t\t[ { css: value } ],\n\t\t\t\t'.editor-styles-wrapper'\n\t\t\t);\n\t\t\tif ( transformed ) {\n\t\t\t\tsetCSSError( null );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleOnBlur( event ) {\n\t\tif ( ! event?.target?.value ) {\n\t\t\tsetCSSError( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ transformed ] = transformStyles(\n\t\t\t[ { css: event.target.value } ],\n\t\t\t'.editor-styles-wrapper'\n\t\t);\n\n\t\tsetCSSError(\n\t\t\ttransformed === null\n\t\t\t\t? __( 'There is an error with your CSS structure.' )\n\t\t\t\t: null\n\t\t);\n\t}\n\n\tconst originalThemeCustomCSS =\n\t\tthemeCSS && customCSS && themeCustomCSS !== customCSS\n\t\t\t? themeCSS\n\t\t\t: undefined;\n\n\treturn (\n\t\t<>\n\t\t\t{ originalThemeCustomCSS && (\n\t\t\t\t<Panel>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Original Theme Custom CSS' ) }\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<pre className=\"edit-site-global-styles__custom-css-theme-css\">\n\t\t\t\t\t\t\t{ originalThemeCustomCSS }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</Panel>\n\t\t\t) }\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<Subtitle>{ __( 'ADDITIONAL CSS' ) }</Subtitle>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tcustomCSS?.replace( ignoreThemeCustomCSS, '' ) ||\n\t\t\t\t\t\tthemeCustomCSS\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( value ) => handleOnChange( value ) }\n\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-input\"\n\t\t\t\t\tspellCheck={ false }\n\t\t\t\t/>\n\t\t\t\t{ cssError && (\n\t\t\t\t\t<Tooltip text={ cssError }>\n\t\t\t\t\t\t<div className=\"edit-site-global-styles__custom-css-validation-wrapper\">\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ info }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-validation-icon\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CustomCSSControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/global-styles/custom-css.js"],"names":["useGlobalStyle","blockEditorPrivateApis","CustomCSSControl","blockName","block","customCSS","setCustomCSS","themeCSS","cssError","setCSSError","ignoreThemeCustomCSS","themeCustomCSS","undefined","handleOnChange","value","transformed","css","handleOnBlur","event","target","originalThemeCustomCSS","replace","info"],"mappings":";;;;;;;;;AAGA;;AACA;;AAQA;;AACA;;AAIA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAiBA;AACA;AACA;AAIA,MAAM;AAAEA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B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport {\n\tTextareaControl,\n\tPanel,\n\tPanelBody,\n\t__experimentalVStack as VStack,\n\tTooltip,\n\tIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tprivateApis as blockEditorPrivateApis,\n\ttransformStyles,\n} from '@wordpress/block-editor';\nimport { info } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../private-apis';\nimport Subtitle from './subtitle';\n\nconst { useGlobalStyle } = unlock( blockEditorPrivateApis );\nfunction CustomCSSControl( { blockName } ) {\n\t// If blockName is defined, we are customizing CSS at the block level:\n\t// styles.blocks.blockName.css\n\tconst block = !! blockName ? blockName : null;\n\n\tconst [ customCSS, setCustomCSS ] = useGlobalStyle( 'css', block );\n\tconst [ themeCSS ] = useGlobalStyle( 'css', block, 'base' );\n\tconst [ cssError, setCSSError ] = useState( null );\n\tconst ignoreThemeCustomCSS = '/* IgnoreThemeCustomCSS */';\n\n\t// If there is custom css from theme.json show it in the edit box\n\t// so the user can selectively overwrite it, rather than have the user CSS\n\t// completely overwrite the theme CSS by default.\n\tconst themeCustomCSS =\n\t\t! customCSS && themeCSS\n\t\t\t? `/* ${ __(\n\t\t\t\t\t'Theme Custom CSS start'\n\t\t\t ) } */\\n${ themeCSS }\\n/* ${ __( 'Theme Custom CSS end' ) } */`\n\t\t\t: undefined;\n\n\tfunction handleOnChange( value ) {\n\t\t// If there is theme custom CSS, but the user clears the input box then save the\n\t\t// ignoreThemeCustomCSS string so that the theme custom CSS is not re-applied.\n\t\tif ( themeCSS && value === '' ) {\n\t\t\tsetCustomCSS( ignoreThemeCustomCSS );\n\t\t\treturn;\n\t\t}\n\t\tsetCustomCSS( value );\n\t\tif ( cssError ) {\n\t\t\tconst [ transformed ] = transformStyles(\n\t\t\t\t[ { css: value } ],\n\t\t\t\t'.editor-styles-wrapper'\n\t\t\t);\n\t\t\tif ( transformed ) {\n\t\t\t\tsetCSSError( null );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction handleOnBlur( event ) {\n\t\tif ( ! event?.target?.value ) {\n\t\t\tsetCSSError( null );\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ transformed ] = transformStyles(\n\t\t\t[ { css: event.target.value } ],\n\t\t\t'.editor-styles-wrapper'\n\t\t);\n\n\t\tsetCSSError(\n\t\t\ttransformed === null\n\t\t\t\t? __( 'There is an error with your CSS structure.' )\n\t\t\t\t: null\n\t\t);\n\t}\n\n\tconst originalThemeCustomCSS =\n\t\tthemeCSS && customCSS && themeCustomCSS !== customCSS\n\t\t\t? themeCSS\n\t\t\t: undefined;\n\n\treturn (\n\t\t<>\n\t\t\t{ originalThemeCustomCSS && (\n\t\t\t\t<Panel>\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\ttitle={ __( 'Original Theme Custom CSS' ) }\n\t\t\t\t\t\tinitialOpen={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t<pre className=\"edit-site-global-styles__custom-css-theme-css\">\n\t\t\t\t\t\t\t{ originalThemeCustomCSS }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</PanelBody>\n\t\t\t\t</Panel>\n\t\t\t) }\n\t\t\t<VStack spacing={ 3 }>\n\t\t\t\t<Subtitle>{ __( 'Additional CSS' ) }</Subtitle>\n\t\t\t\t<TextareaControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tcustomCSS?.replace( ignoreThemeCustomCSS, '' ) ||\n\t\t\t\t\t\tthemeCustomCSS\n\t\t\t\t\t}\n\t\t\t\t\tonChange={ ( value ) => handleOnChange( value ) }\n\t\t\t\t\tonBlur={ handleOnBlur }\n\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-input\"\n\t\t\t\t\tspellCheck={ false }\n\t\t\t\t/>\n\t\t\t\t{ cssError && (\n\t\t\t\t\t<Tooltip text={ cssError }>\n\t\t\t\t\t\t<div className=\"edit-site-global-styles__custom-css-validation-wrapper\">\n\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\ticon={ info }\n\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles__custom-css-validation-icon\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Tooltip>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t</>\n\t);\n}\n\nexport default CustomCSSControl;\n"]}
@@ -1,33 +1,16 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
8
6
  exports.default = DimensionsPanel;
9
- exports.useHasDimensionsPanel = useHasDimensionsPanel;
10
7
 
11
8
  var _element = require("@wordpress/element");
12
9
 
13
- var _classnames = _interopRequireDefault(require("classnames"));
14
-
15
- var _i18n = require("@wordpress/i18n");
16
-
17
- var _components = require("@wordpress/components");
18
-
19
10
  var _blockEditor = require("@wordpress/block-editor");
20
11
 
21
- var _icons = require("@wordpress/icons");
22
-
23
- var _hooks = require("./hooks");
24
-
25
12
  var _privateApis = require("../../private-apis");
26
13
 
27
- /**
28
- * External dependencies
29
- */
30
-
31
14
  /**
32
15
  * WordPress dependencies
33
16
  */
@@ -36,490 +19,62 @@ var _privateApis = require("../../private-apis");
36
19
  * Internal dependencies
37
20
  */
38
21
  const {
22
+ useGlobalStyle,
39
23
  useGlobalSetting,
40
- useGlobalStyle
24
+ useSettingsForBlockElement,
25
+ DimensionsPanel: StylesDimensionsPanel
41
26
  } = (0, _privateApis.unlock)(_blockEditor.privateApis);
42
- const AXIAL_SIDES = ['horizontal', 'vertical'];
43
-
44
- function useHasDimensionsPanel(name) {
45
- const hasContentSize = useHasContentSize(name);
46
- const hasWideSize = useHasWideSize(name);
47
- const hasPadding = useHasPadding(name);
48
- const hasMargin = useHasMargin(name);
49
- const hasGap = useHasGap(name);
50
- const hasMinHeight = useHasMinHeight(name);
51
- return hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasMinHeight;
52
- }
53
-
54
- function useHasContentSize(name) {
55
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
56
- const [settings] = useGlobalSetting('layout.contentSize', name);
57
- return settings && supports.includes('contentSize');
58
- }
59
-
60
- function useHasWideSize(name) {
61
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
62
- const [settings] = useGlobalSetting('layout.wideSize', name);
63
- return settings && supports.includes('wideSize');
64
- }
65
-
66
- function useHasPadding(name) {
67
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
68
- const [settings] = useGlobalSetting('spacing.padding', name);
69
- return settings && supports.includes('padding');
70
- }
71
-
72
- function useHasMargin(name) {
73
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
74
- const [settings] = useGlobalSetting('spacing.margin', name);
75
- return settings && supports.includes('margin');
76
- }
77
-
78
- function useHasGap(name) {
79
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
80
- const [settings] = useGlobalSetting('spacing.blockGap', name);
81
- return settings && supports.includes('blockGap');
82
- }
83
-
84
- function useHasMinHeight(name) {
85
- const supports = (0, _hooks.getSupportedGlobalStylesPanels)(name);
86
- const [settings] = useGlobalSetting('dimensions.minHeight', name);
87
- return settings && supports.includes('minHeight');
88
- }
89
-
90
- function useHasSpacingPresets() {
91
- var _ref, _ref2;
92
-
93
- const [settings] = useGlobalSetting('spacing.spacingSizes');
94
- const {
95
- custom,
96
- theme,
97
- default: defaultPresets
98
- } = settings || {};
99
- const presets = (_ref = (_ref2 = custom !== null && custom !== void 0 ? custom : theme) !== null && _ref2 !== void 0 ? _ref2 : defaultPresets) !== null && _ref !== void 0 ? _ref : [];
100
- return settings && presets.length > 0;
101
- }
102
-
103
- function filterValuesBySides(values, sides) {
104
- if (!sides) {
105
- // If no custom side configuration all sides are opted into by default.
106
- return values;
107
- } // Only include sides opted into within filtered values.
108
27
 
28
+ function DimensionsPanel(_ref) {
29
+ let {
30
+ name,
31
+ variation = ''
32
+ } = _ref;
33
+ let prefixParts = [];
109
34
 
110
- const filteredValues = {};
111
- sides.forEach(side => {
112
- if (side === 'vertical') {
113
- filteredValues.top = values.top;
114
- filteredValues.bottom = values.bottom;
115
- }
116
-
117
- if (side === 'horizontal') {
118
- filteredValues.left = values.left;
119
- filteredValues.right = values.right;
120
- }
35
+ if (variation) {
36
+ prefixParts = ['variations', variation].concat(prefixParts);
37
+ }
121
38
 
122
- filteredValues[side] = values[side];
39
+ const prefix = prefixParts.join('.');
40
+ const [style] = useGlobalStyle(prefix, name, 'user', false);
41
+ const [inheritedStyle, setStyle] = useGlobalStyle(prefix, name, 'all', {
42
+ shouldDecodeEncode: false
123
43
  });
124
- return filteredValues;
125
- }
44
+ const [rawSettings, setSettings] = useGlobalSetting('', name);
45
+ const settings = useSettingsForBlockElement(rawSettings, name); // These intermediary objects are needed because the "layout" property is stored
46
+ // in settings rather than styles.
126
47
 
127
- function splitStyleValue(value) {
128
- // Check for shorthand value (a string value).
129
- if (value && typeof value === 'string') {
130
- // Convert to value for individual sides for BoxControl.
131
- return {
132
- top: value,
133
- right: value,
134
- bottom: value,
135
- left: value
48
+ const inheritedStyleWithLayout = (0, _element.useMemo)(() => {
49
+ return { ...inheritedStyle,
50
+ layout: settings.layout
136
51
  };
137
- }
138
-
139
- return value;
140
- }
141
-
142
- function splitGapValue(value) {
143
- // Check for shorthand value (a string value).
144
- if (value && typeof value === 'string') {
145
- // If the value is a string, treat it as a single side (top) for the spacing controls.
146
- return {
147
- top: value
52
+ }, [inheritedStyle, settings.layout]);
53
+ const styleWithLayout = (0, _element.useMemo)(() => {
54
+ return { ...style,
55
+ layout: settings.layout
148
56
  };
149
- }
57
+ }, [style, settings.layout]);
150
58
 
151
- if (value) {
152
- return { ...value,
153
- right: value === null || value === void 0 ? void 0 : value.left,
154
- bottom: value === null || value === void 0 ? void 0 : value.top
59
+ const onChange = newStyle => {
60
+ const updatedStyle = { ...newStyle
155
61
  };
156
- }
157
-
158
- return value;
159
- } // Props for managing `layout.contentSize`.
160
-
161
-
162
- function useContentSizeProps(name) {
163
- const [contentSizeValue, setContentSizeValue] = useGlobalSetting('layout.contentSize', name);
164
- const [userSetContentSizeValue] = useGlobalSetting('layout.contentSize', name, 'user');
165
-
166
- const hasUserSetContentSizeValue = () => !!userSetContentSizeValue;
167
-
168
- const resetContentSizeValue = () => setContentSizeValue('');
169
-
170
- return {
171
- contentSizeValue,
172
- setContentSizeValue,
173
- hasUserSetContentSizeValue,
174
- resetContentSizeValue
175
- };
176
- } // Props for managing `layout.wideSize`.
177
-
178
-
179
- function useWideSizeProps(name) {
180
- const [wideSizeValue, setWideSizeValue] = useGlobalSetting('layout.wideSize', name);
181
- const [userSetWideSizeValue] = useGlobalSetting('layout.wideSize', name, 'user');
62
+ delete updatedStyle.layout;
63
+ setStyle(updatedStyle);
182
64
 
183
- const hasUserSetWideSizeValue = () => !!userSetWideSizeValue;
184
-
185
- const resetWideSizeValue = () => setWideSizeValue('');
186
-
187
- return {
188
- wideSizeValue,
189
- setWideSizeValue,
190
- hasUserSetWideSizeValue,
191
- resetWideSizeValue
192
- };
193
- } // Props for managing `spacing.padding`.
194
-
195
-
196
- function usePaddingProps(name) {
197
- let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
198
- const prefix = variation ? `variations.${variation}.` : '';
199
- const [rawPadding, setRawPadding] = useGlobalStyle(prefix + 'spacing.padding', name);
200
- const paddingValues = splitStyleValue(rawPadding);
201
- const paddingSides = (0, _blockEditor.__experimentalUseCustomSides)(name, 'padding');
202
- const isAxialPadding = paddingSides && paddingSides.some(side => AXIAL_SIDES.includes(side));
203
-
204
- const setPaddingValues = newPaddingValues => {
205
- const padding = filterValuesBySides(newPaddingValues, paddingSides);
206
- setRawPadding(padding);
207
- };
208
-
209
- const resetPaddingValue = () => setPaddingValues({});
210
-
211
- const [userSetPaddingValue] = useGlobalStyle(prefix + 'spacing.padding', name, 'user'); // The `hasPaddingValue` check does not need a parsed value, as `userSetPaddingValue` will be `undefined` if not set.
212
-
213
- const hasPaddingValue = () => !!userSetPaddingValue;
214
-
215
- return {
216
- paddingValues,
217
- paddingSides,
218
- isAxialPadding,
219
- setPaddingValues,
220
- resetPaddingValue,
221
- hasPaddingValue
222
- };
223
- } // Props for managing `spacing.margin`.
224
-
225
-
226
- function useMarginProps(name) {
227
- let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
228
- const prefix = variation ? `variations.${variation}.` : '';
229
- const [rawMargin, setRawMargin] = useGlobalStyle(prefix + 'spacing.margin', name);
230
- const marginValues = splitStyleValue(rawMargin);
231
- const marginSides = (0, _blockEditor.__experimentalUseCustomSides)(name, 'margin');
232
- const isAxialMargin = marginSides && marginSides.some(side => AXIAL_SIDES.includes(side));
233
-
234
- const setMarginValues = newMarginValues => {
235
- const margin = filterValuesBySides(newMarginValues, marginSides);
236
- setRawMargin(margin);
237
- };
238
-
239
- const resetMarginValue = () => setMarginValues({});
240
-
241
- const hasMarginValue = () => !!marginValues && Object.keys(marginValues).length;
242
-
243
- return {
244
- marginValues,
245
- marginSides,
246
- isAxialMargin,
247
- setMarginValues,
248
- resetMarginValue,
249
- hasMarginValue
250
- };
251
- } // Props for managing `spacing.blockGap`.
252
-
253
-
254
- function useBlockGapProps(name) {
255
- let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
256
- const prefix = variation ? `variations.${variation}.` : '';
257
- const [gapValue, setGapValue] = useGlobalStyle(prefix + 'spacing.blockGap', name);
258
- const gapValues = splitGapValue(gapValue);
259
- const gapSides = (0, _blockEditor.__experimentalUseCustomSides)(name, 'blockGap');
260
- const isAxialGap = gapSides && gapSides.some(side => AXIAL_SIDES.includes(side));
261
-
262
- const resetGapValue = () => setGapValue(undefined);
263
-
264
- const [userSetGapValue] = useGlobalStyle(prefix + 'spacing.blockGap', name, 'user');
265
-
266
- const hasGapValue = () => !!userSetGapValue;
267
-
268
- const setGapValues = nextBoxGapValue => {
269
- if (!nextBoxGapValue) {
270
- setGapValue(null);
271
- } // If axial gap is not enabled, treat the 'top' value as the shorthand gap value.
272
-
273
-
274
- if (!isAxialGap && nextBoxGapValue !== null && nextBoxGapValue !== void 0 && nextBoxGapValue.hasOwnProperty('top')) {
275
- setGapValue(nextBoxGapValue.top);
276
- } else {
277
- setGapValue({
278
- top: nextBoxGapValue === null || nextBoxGapValue === void 0 ? void 0 : nextBoxGapValue.top,
279
- left: nextBoxGapValue === null || nextBoxGapValue === void 0 ? void 0 : nextBoxGapValue.left
65
+ if (newStyle.layout !== settings.layout) {
66
+ setSettings({ ...rawSettings,
67
+ layout: newStyle.layout
280
68
  });
281
69
  }
282
70
  };
283
71
 
284
- return {
285
- gapValue,
286
- gapValues,
287
- gapSides,
288
- isAxialGap,
289
- setGapValue,
290
- setGapValues,
291
- resetGapValue,
292
- hasGapValue
293
- };
294
- } // Props for managing `dimensions.minHeight`.
295
-
296
-
297
- function useMinHeightProps(name) {
298
- let variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
299
- const prefix = variation ? `variations.${variation}.` : '';
300
- const [minHeightValue, setMinHeightValue] = useGlobalStyle(prefix + 'dimensions.minHeight', name);
301
-
302
- const resetMinHeightValue = () => setMinHeightValue(undefined);
303
-
304
- const hasMinHeightValue = () => !!minHeightValue;
305
-
306
- return {
307
- minHeightValue,
308
- setMinHeightValue,
309
- resetMinHeightValue,
310
- hasMinHeightValue
311
- };
312
- }
313
-
314
- function DimensionsPanel(_ref3) {
315
- let {
316
- name,
317
- variation = ''
318
- } = _ref3;
319
- const showContentSizeControl = useHasContentSize(name);
320
- const showWideSizeControl = useHasWideSize(name);
321
- const showPaddingControl = useHasPadding(name);
322
- const showMarginControl = useHasMargin(name);
323
- const showGapControl = useHasGap(name);
324
- const showMinHeightControl = useHasMinHeight(name);
325
- const showSpacingPresetsControl = useHasSpacingPresets();
326
- const units = (0, _components.__experimentalUseCustomUnits)({
327
- availableUnits: useGlobalSetting('spacing.units', name)[0] || ['%', 'px', 'em', 'rem', 'vw']
328
- }); // Props for managing `layout.contentSize`.
329
-
330
- const {
331
- contentSizeValue,
332
- setContentSizeValue,
333
- hasUserSetContentSizeValue,
334
- resetContentSizeValue
335
- } = useContentSizeProps(name); // Props for managing `layout.wideSize`.
336
-
337
- const {
338
- wideSizeValue,
339
- setWideSizeValue,
340
- hasUserSetWideSizeValue,
341
- resetWideSizeValue
342
- } = useWideSizeProps(name); // Props for managing `spacing.padding`.
343
-
344
- const {
345
- paddingValues,
346
- paddingSides,
347
- isAxialPadding,
348
- setPaddingValues,
349
- resetPaddingValue,
350
- hasPaddingValue
351
- } = usePaddingProps(name, variation); // Props for managing `spacing.margin`.
352
-
353
- const {
354
- marginValues,
355
- marginSides,
356
- isAxialMargin,
357
- setMarginValues,
358
- resetMarginValue,
359
- hasMarginValue
360
- } = useMarginProps(name, variation); // Props for managing `spacing.blockGap`.
361
-
362
- const {
363
- gapValue,
364
- gapValues,
365
- gapSides,
366
- isAxialGap,
367
- setGapValue,
368
- setGapValues,
369
- resetGapValue,
370
- hasGapValue
371
- } = useBlockGapProps(name, variation); // Props for managing `dimensions.minHeight`.
372
-
373
- const {
374
- minHeightValue,
375
- setMinHeightValue,
376
- resetMinHeightValue,
377
- hasMinHeightValue
378
- } = useMinHeightProps(name, variation);
379
-
380
- const resetAll = () => {
381
- resetPaddingValue();
382
- resetMarginValue();
383
- resetGapValue();
384
- resetContentSizeValue();
385
- resetWideSizeValue();
386
- };
387
-
388
- return (0, _element.createElement)(_components.__experimentalToolsPanel, {
389
- label: (0, _i18n.__)('Dimensions'),
390
- resetAll: resetAll
391
- }, (showContentSizeControl || showWideSizeControl) && (0, _element.createElement)("span", {
392
- className: "span-columns"
393
- }, (0, _i18n.__)('Set the width of the main content area.')), showContentSizeControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
394
- className: "single-column",
395
- label: (0, _i18n.__)('Content size'),
396
- hasValue: hasUserSetContentSizeValue,
397
- onDeselect: resetContentSizeValue,
398
- isShownByDefault: true
399
- }, (0, _element.createElement)(_components.__experimentalHStack, {
400
- alignment: "flex-end",
401
- justify: "flex-start"
402
- }, (0, _element.createElement)(_components.__experimentalUnitControl, {
403
- label: (0, _i18n.__)('Content'),
404
- labelPosition: "top",
405
- __unstableInputWidth: "80px",
406
- value: contentSizeValue || '',
407
- onChange: nextContentSize => {
408
- setContentSizeValue(nextContentSize);
409
- },
410
- units: units
411
- }), (0, _element.createElement)(_components.__experimentalView, null, (0, _element.createElement)(_icons.Icon, {
412
- icon: _icons.positionCenter
413
- })))), showWideSizeControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
414
- className: "single-column",
415
- label: (0, _i18n.__)('Wide size'),
416
- hasValue: hasUserSetWideSizeValue,
417
- onDeselect: resetWideSizeValue,
418
- isShownByDefault: true
419
- }, (0, _element.createElement)(_components.__experimentalHStack, {
420
- alignment: "flex-end",
421
- justify: "flex-start"
422
- }, (0, _element.createElement)(_components.__experimentalUnitControl, {
423
- label: (0, _i18n.__)('Wide'),
424
- labelPosition: "top",
425
- __unstableInputWidth: "80px",
426
- value: wideSizeValue || '',
427
- onChange: nextWideSize => {
428
- setWideSizeValue(nextWideSize);
429
- },
430
- units: units
431
- }), (0, _element.createElement)(_components.__experimentalView, null, (0, _element.createElement)(_icons.Icon, {
432
- icon: _icons.stretchWide
433
- })))), showPaddingControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
434
- hasValue: hasPaddingValue,
435
- label: (0, _i18n.__)('Padding'),
436
- onDeselect: resetPaddingValue,
437
- isShownByDefault: true,
438
- className: (0, _classnames.default)({
439
- 'tools-panel-item-spacing': showSpacingPresetsControl
440
- })
441
- }, !showSpacingPresetsControl && (0, _element.createElement)(_components.__experimentalBoxControl, {
442
- values: paddingValues,
443
- onChange: setPaddingValues,
444
- label: (0, _i18n.__)('Padding'),
445
- sides: paddingSides,
446
- units: units,
447
- allowReset: false,
448
- splitOnAxis: isAxialPadding
449
- }), showSpacingPresetsControl && (0, _element.createElement)(_blockEditor.__experimentalSpacingSizesControl, {
450
- values: paddingValues,
451
- onChange: setPaddingValues,
452
- label: (0, _i18n.__)('Padding'),
453
- sides: paddingSides,
454
- units: units,
455
- allowReset: false,
456
- splitOnAxis: isAxialPadding
457
- })), showMarginControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
458
- hasValue: hasMarginValue,
459
- label: (0, _i18n.__)('Margin'),
460
- onDeselect: resetMarginValue,
461
- isShownByDefault: true,
462
- className: (0, _classnames.default)({
463
- 'tools-panel-item-spacing': showSpacingPresetsControl
464
- })
465
- }, !showSpacingPresetsControl && (0, _element.createElement)(_components.__experimentalBoxControl, {
466
- values: marginValues,
467
- onChange: setMarginValues,
468
- label: (0, _i18n.__)('Margin'),
469
- sides: marginSides,
470
- units: units,
471
- allowReset: false,
472
- splitOnAxis: isAxialMargin
473
- }), showSpacingPresetsControl && (0, _element.createElement)(_blockEditor.__experimentalSpacingSizesControl, {
474
- values: marginValues,
475
- onChange: setMarginValues,
476
- label: (0, _i18n.__)('Margin'),
477
- sides: marginSides,
478
- units: units,
479
- allowReset: false,
480
- splitOnAxis: isAxialMargin
481
- })), showGapControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
482
- hasValue: hasGapValue,
483
- label: (0, _i18n.__)('Block spacing'),
484
- onDeselect: resetGapValue,
485
- isShownByDefault: true,
486
- className: (0, _classnames.default)({
487
- 'tools-panel-item-spacing': showSpacingPresetsControl
488
- })
489
- }, !showSpacingPresetsControl && (isAxialGap ? (0, _element.createElement)(_components.__experimentalBoxControl, {
490
- label: (0, _i18n.__)('Block spacing'),
491
- min: 0,
492
- onChange: setGapValues,
493
- units: units,
494
- sides: gapSides,
495
- values: gapValues,
496
- allowReset: false,
497
- splitOnAxis: isAxialGap
498
- }) : (0, _element.createElement)(_components.__experimentalUnitControl, {
499
- label: (0, _i18n.__)('Block spacing'),
500
- __unstableInputWidth: "80px",
501
- min: 0,
502
- onChange: setGapValue,
503
- units: units,
504
- value: gapValue
505
- })), showSpacingPresetsControl && (0, _element.createElement)(_blockEditor.__experimentalSpacingSizesControl, {
506
- label: (0, _i18n.__)('Block spacing'),
507
- min: 0,
508
- onChange: setGapValues,
509
- sides: isAxialGap ? gapSides : ['top'] // Use 'top' as the shorthand property in non-axial configurations.
510
- ,
511
- values: gapValues,
512
- allowReset: false,
513
- splitOnAxis: isAxialGap
514
- })), showMinHeightControl && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
515
- hasValue: hasMinHeightValue,
516
- label: (0, _i18n.__)('Min. height'),
517
- onDeselect: resetMinHeightValue,
518
- isShownByDefault: true
519
- }, (0, _element.createElement)(_blockEditor.HeightControl, {
520
- label: (0, _i18n.__)('Min. height'),
521
- value: minHeightValue,
522
- onChange: setMinHeightValue
523
- })));
72
+ return (0, _element.createElement)(StylesDimensionsPanel, {
73
+ inheritedValue: inheritedStyleWithLayout,
74
+ value: styleWithLayout,
75
+ onChange: onChange,
76
+ settings: settings,
77
+ includeLayoutControls: true
78
+ });
524
79
  }
525
80
  //# sourceMappingURL=dimensions-panel.js.map