@wordpress/block-editor 12.19.3 → 12.20.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 (127) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-canvas/index.js +2 -0
  3. package/build/components/block-canvas/index.js.map +1 -1
  4. package/build/components/block-heading-level-dropdown/index.js +14 -17
  5. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  6. package/build/components/block-inspector/index.js +0 -3
  7. package/build/components/block-inspector/index.js.map +1 -1
  8. package/build/components/block-list/index.js +9 -9
  9. package/build/components/block-list/index.js.map +1 -1
  10. package/build/components/block-preview/index.js +4 -0
  11. package/build/components/block-preview/index.js.map +1 -1
  12. package/build/components/block-settings-menu/block-parent-selector-menu-item.js +54 -0
  13. package/build/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
  14. package/build/components/block-settings-menu/block-settings-dropdown.js +9 -37
  15. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  16. package/build/components/child-layout-control/index.js +37 -5
  17. package/build/components/child-layout-control/index.js.map +1 -1
  18. package/build/components/date-format-picker/index.js +0 -1
  19. package/build/components/date-format-picker/index.js.map +1 -1
  20. package/build/components/font-appearance-control/index.js +1 -2
  21. package/build/components/font-appearance-control/index.js.map +1 -1
  22. package/build/components/global-styles/dimensions-panel.js +30 -19
  23. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  24. package/build/components/inspector-controls-tabs/styles-tab.js +0 -4
  25. package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  26. package/build/components/observe-typing/index.js +5 -10
  27. package/build/components/observe-typing/index.js.map +1 -1
  28. package/build/components/rich-text/format-toolbar-container.js +1 -31
  29. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  30. package/build/components/rich-text/index.js +1 -2
  31. package/build/components/rich-text/index.js.map +1 -1
  32. package/build/components/skip-to-selected-block/index.js +7 -14
  33. package/build/components/skip-to-selected-block/index.js.map +1 -1
  34. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  35. package/build/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  36. package/build/components/url-input/index.js +5 -8
  37. package/build/components/url-input/index.js.map +1 -1
  38. package/build/hooks/layout-child.js +50 -1
  39. package/build/hooks/layout-child.js.map +1 -1
  40. package/build/hooks/position.js +0 -1
  41. package/build/hooks/position.js.map +1 -1
  42. package/build/layouts/grid.js +105 -12
  43. package/build/layouts/grid.js.map +1 -1
  44. package/build/store/actions.js +2 -30
  45. package/build/store/actions.js.map +1 -1
  46. package/build-module/components/block-canvas/index.js +2 -0
  47. package/build-module/components/block-canvas/index.js.map +1 -1
  48. package/build-module/components/block-heading-level-dropdown/index.js +14 -17
  49. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  50. package/build-module/components/block-inspector/index.js +1 -4
  51. package/build-module/components/block-inspector/index.js.map +1 -1
  52. package/build-module/components/block-list/index.js +9 -9
  53. package/build-module/components/block-list/index.js.map +1 -1
  54. package/build-module/components/block-preview/index.js +4 -0
  55. package/build-module/components/block-preview/index.js.map +1 -1
  56. package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js +46 -0
  57. package/build-module/components/block-settings-menu/block-parent-selector-menu-item.js.map +1 -0
  58. package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -40
  59. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  60. package/build-module/components/child-layout-control/index.js +38 -6
  61. package/build-module/components/child-layout-control/index.js.map +1 -1
  62. package/build-module/components/date-format-picker/index.js +0 -1
  63. package/build-module/components/date-format-picker/index.js.map +1 -1
  64. package/build-module/components/font-appearance-control/index.js +1 -2
  65. package/build-module/components/font-appearance-control/index.js.map +1 -1
  66. package/build-module/components/global-styles/dimensions-panel.js +30 -19
  67. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  68. package/build-module/components/inspector-controls-tabs/styles-tab.js +0 -4
  69. package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
  70. package/build-module/components/observe-typing/index.js +5 -10
  71. package/build-module/components/observe-typing/index.js.map +1 -1
  72. package/build-module/components/rich-text/format-toolbar-container.js +1 -31
  73. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  74. package/build-module/components/rich-text/index.js +1 -2
  75. package/build-module/components/rich-text/index.js.map +1 -1
  76. package/build-module/components/skip-to-selected-block/index.js +8 -14
  77. package/build-module/components/skip-to-selected-block/index.js.map +1 -1
  78. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  79. package/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js.map +1 -1
  80. package/build-module/components/url-input/index.js +5 -8
  81. package/build-module/components/url-input/index.js.map +1 -1
  82. package/build-module/hooks/layout-child.js +50 -1
  83. package/build-module/hooks/layout-child.js.map +1 -1
  84. package/build-module/hooks/position.js +0 -1
  85. package/build-module/hooks/position.js.map +1 -1
  86. package/build-module/layouts/grid.js +107 -14
  87. package/build-module/layouts/grid.js.map +1 -1
  88. package/build-module/store/actions.js +2 -30
  89. package/build-module/store/actions.js.map +1 -1
  90. package/build-style/style-rtl.css +12 -17
  91. package/build-style/style.css +12 -17
  92. package/package.json +31 -32
  93. package/src/components/block-canvas/index.js +2 -0
  94. package/src/components/block-heading-level-dropdown/index.js +17 -25
  95. package/src/components/block-inspector/index.js +0 -11
  96. package/src/components/block-list/index.js +55 -55
  97. package/src/components/block-preview/index.js +6 -1
  98. package/src/components/block-settings-menu/block-parent-selector-menu-item.js +50 -0
  99. package/src/components/block-settings-menu/block-settings-dropdown.js +9 -50
  100. package/src/components/block-styles/style.scss +0 -4
  101. package/src/components/block-toolbar/style.scss +11 -6
  102. package/src/components/child-layout-control/index.js +85 -44
  103. package/src/components/date-format-picker/index.js +0 -1
  104. package/src/components/font-appearance-control/index.js +0 -1
  105. package/src/components/global-styles/dimensions-panel.js +36 -24
  106. package/src/components/global-styles/test/use-global-styles-output.js +3 -2
  107. package/src/components/inspector-controls-tabs/styles-tab.js +0 -7
  108. package/src/components/observe-typing/index.js +7 -10
  109. package/src/components/rich-text/format-toolbar-container.js +1 -48
  110. package/src/components/rich-text/index.js +0 -1
  111. package/src/components/skip-to-selected-block/index.js +10 -13
  112. package/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +0 -1
  113. package/src/components/url-input/index.js +6 -15
  114. package/src/hooks/anchor.scss +1 -1
  115. package/src/hooks/layout-child.js +53 -1
  116. package/src/hooks/position.js +0 -1
  117. package/src/layouts/grid.js +131 -52
  118. package/src/layouts/test/grid.js +16 -2
  119. package/src/store/actions.js +2 -38
  120. package/src/store/test/actions.js +0 -101
  121. package/src/style.scss +0 -1
  122. package/build/components/default-style-picker/index.js +0 -70
  123. package/build/components/default-style-picker/index.js.map +0 -1
  124. package/build-module/components/default-style-picker/index.js +0 -63
  125. package/build-module/components/default-style-picker/index.js.map +0 -1
  126. package/src/components/block-settings-menu/style.scss +0 -3
  127. package/src/components/default-style-picker/index.js +0 -70
@@ -275,7 +275,6 @@ function PositionPanelPure({
275
275
  __nextHasNoMarginBottom: true,
276
276
  help: stickyHelpText
277
277
  }, (0, _react.createElement)(CustomSelectControl, {
278
- __nextUnconstrainedWidth: true,
279
278
  __next40pxDefaultSize: true,
280
279
  className: "block-editor-hooks__position-selection__select-control",
281
280
  label: (0, _i18n.__)('Position'),
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_lockUnlock","_store","CustomSelectControl","unlock","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","__","className","STICKY_OPTION","_x","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","_react","createElement","default","group","BaseControl","__nextHasNoMarginBottom","help","__nextUnconstrainedWidth","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","classnames","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__nextUnconstrainedWidth\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = classnames( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,QAAA,GAAAJ,OAAA;AACA,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IAAEvC;EAAK,CAAE,CAAC;EAC5D,MAAMmG,mBAAmB,GAAGD,uBAAuB,IAAI,CAAEL,kBAAkB;EAE3E,MAAMO,EAAE,GAAG,IAAAC,sBAAa,EAAEP,aAAc,CAAC;;EAEzC;EACA,MAAMQ,gBAAgB,GAAI,iBAAiBF,EAAI,iBAAiBA,EAAI,EAAC;;EAErE;EACA,IAAIG,GAAG;EACP,IAAKJ,mBAAmB,EAAG;IAC1BI,GAAG,GACF9F,cAAc,CAAE;MACfC,QAAQ,EAAE4F,gBAAgB;MAC1B3F;IACD,CAAE,CAAC,IAAI,EAAE;EACX;;EAEA;EACA,MAAMT,SAAS,GAAG,IAAAsG,mBAAU,EAAE;IAC7B,CAAG,gBAAgBJ,EAAI,EAAC,GAAID,mBAAmB,IAAI,CAAC,CAAEI,GAAG;IAAE;IAC3D,CAAG,eAAe5F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCsF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE5F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA4F,uBAAgB,EAAE;IAAEF;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAErG;EAAU,CAAC;AACrB"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_blocks","_components","_compose","_data","_element","_useSettings","_inspectorControls","_useBlockDisplayInformation","_utils","_lockUnlock","_store","CustomSelectControl","unlock","componentsPrivateApis","POSITION_SUPPORT_KEY","OPTION_CLASSNAME","DEFAULT_OPTION","key","value","name","__","className","STICKY_OPTION","_x","__experimentalHint","FIXED_OPTION","POSITION_SIDES","VALID_POSITION_TYPES","getPositionCSS","selector","style","output","type","positionType","position","includes","forEach","side","undefined","hasStickyPositionSupport","blockType","support","getBlockSupport","sticky","hasFixedPositionSupport","fixed","hasPositionSupport","hasPositionValue","props","attributes","hasStickyOrFixedPositionValue","resetPosition","setAttributes","cleanEmptyObject","top","right","bottom","left","useIsPositionDisabled","blockName","allowFixed","allowSticky","useSettings","isDisabled","PositionPanelPure","clientId","firstParentClientId","useSelect","select","getBlockParents","blockEditorStore","parents","length","blockInformation","useBlockDisplayInformation","stickyHelpText","sprintf","title","options","useMemo","availableOptions","push","onChangeType","next","placementValue","newStyle","selectedOption","find","option","Platform","web","_react","createElement","default","group","BaseControl","__nextHasNoMarginBottom","help","__next40pxDefaultSize","label","hideLabelFromVision","describedBy","__experimentalShowSelectedHint","onChange","selectedItem","size","native","_default","exports","edit","Edit","isPositionDisabled","useBlockProps","attributeKeys","hasSupport","hasBlockSupport","hasPositionBlockSupport","allowPositionStyles","id","useInstanceId","positionSelector","css","classnames","useStyleOverride"],"sources":["@wordpress/block-editor/src/hooks/position.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tBaseControl,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo, Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useSettings } from '../components/use-settings';\nimport InspectorControls from '../components/inspector-controls';\nimport useBlockDisplayInformation from '../components/use-block-display-information';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\nimport { store as blockEditorStore } from '../store';\n\nconst { CustomSelectControl } = unlock( componentsPrivateApis );\n\nconst POSITION_SUPPORT_KEY = 'position';\n\nconst OPTION_CLASSNAME =\n\t'block-editor-hooks__position-selection__select-control__option';\n\nconst DEFAULT_OPTION = {\n\tkey: 'default',\n\tvalue: '',\n\tname: __( 'Default' ),\n\tclassName: OPTION_CLASSNAME,\n};\n\nconst STICKY_OPTION = {\n\tkey: 'sticky',\n\tvalue: 'sticky',\n\tname: _x( 'Sticky', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will stick to the top of the window instead of scrolling.'\n\t),\n};\n\nconst FIXED_OPTION = {\n\tkey: 'fixed',\n\tvalue: 'fixed',\n\tname: _x( 'Fixed', 'Name for the value of the CSS position property' ),\n\tclassName: OPTION_CLASSNAME,\n\t__experimentalHint: __(\n\t\t'The block will not move when the page is scrolled.'\n\t),\n};\n\nconst POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nconst VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];\n\n/**\n * Get calculated position CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.selector Selector to use.\n * @param {Object} props.style Style object.\n * @return {string} The generated CSS rules.\n */\nexport function getPositionCSS( { selector, style } ) {\n\tlet output = '';\n\n\tconst { type: positionType } = style?.position || {};\n\n\tif ( ! VALID_POSITION_TYPES.includes( positionType ) ) {\n\t\treturn output;\n\t}\n\n\toutput += `${ selector } {`;\n\toutput += `position: ${ positionType };`;\n\n\tPOSITION_SIDES.forEach( ( side ) => {\n\t\tif ( style?.position?.[ side ] !== undefined ) {\n\t\t\toutput += `${ side }: ${ style.position[ side ] };`;\n\t\t}\n\t} );\n\n\tif ( positionType === 'sticky' || positionType === 'fixed' ) {\n\t\t// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.\n\t\toutput += `z-index: 10`;\n\t}\n\toutput += `}`;\n\n\treturn output;\n}\n\n/**\n * Determines if there is sticky position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasStickyPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.sticky );\n}\n\n/**\n * Determines if there is fixed position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasFixedPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! ( true === support || support?.fixed );\n}\n\n/**\n * Determines if there is position support.\n *\n * @param {string|Object} blockType Block name or Block Type object.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasPositionSupport( blockType ) {\n\tconst support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );\n\treturn !! support;\n}\n\n/**\n * Checks if there is a current value in the position block support attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a position value set.\n */\nexport function hasPositionValue( props ) {\n\treturn props.attributes.style?.position?.type !== undefined;\n}\n\n/**\n * Checks if the block is currently set to a sticky or fixed position.\n * This check is helpful for determining how to position block toolbars or other elements.\n *\n * @param {Object} attributes Block attributes.\n * @return {boolean} Whether or not the block is set to a sticky or fixed position.\n */\nexport function hasStickyOrFixedPositionValue( attributes ) {\n\tconst positionType = attributes.style?.position?.type;\n\treturn positionType === 'sticky' || positionType === 'fixed';\n}\n\n/**\n * Resets the position block support attributes. This can be used when disabling\n * the position support controls for a block via a `ToolsPanel`.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block's attributes.\n * @param {Object} props.setAttributes Function to set block's attributes.\n */\nexport function resetPosition( { attributes = {}, setAttributes } ) {\n\tconst { style = {} } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: cleanEmptyObject( {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: undefined,\n\t\t\t\ttop: undefined,\n\t\t\t\tright: undefined,\n\t\t\t\tbottom: undefined,\n\t\t\t\tleft: undefined,\n\t\t\t},\n\t\t} ),\n\t} );\n}\n\n/**\n * Custom hook that checks if position settings have been disabled.\n *\n * @param {string} name The name of the block.\n *\n * @return {boolean} Whether padding setting is disabled.\n */\nexport function useIsPositionDisabled( { name: blockName } = {} ) {\n\tconst [ allowFixed, allowSticky ] = useSettings(\n\t\t'position.fixed',\n\t\t'position.sticky'\n\t);\n\tconst isDisabled = ! allowFixed && ! allowSticky;\n\n\treturn ! hasPositionSupport( blockName ) || isDisabled;\n}\n\n/*\n * Position controls rendered in an inspector control panel.\n *\n * @param {Object} props\n *\n * @return {Element} Position panel.\n */\nexport function PositionPanelPure( {\n\tstyle = {},\n\tclientId,\n\tname: blockName,\n\tsetAttributes,\n} ) {\n\tconst allowFixed = hasFixedPositionSupport( blockName );\n\tconst allowSticky = hasStickyPositionSupport( blockName );\n\tconst value = style?.position?.type;\n\n\tconst { firstParentClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockParents } = select( blockEditorStore );\n\t\t\tconst parents = getBlockParents( clientId );\n\t\t\treturn { firstParentClientId: parents[ parents.length - 1 ] };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst blockInformation = useBlockDisplayInformation( firstParentClientId );\n\tconst stickyHelpText =\n\t\tallowSticky && value === STICKY_OPTION.value && blockInformation\n\t\t\t? sprintf(\n\t\t\t\t\t/* translators: %s: the name of the parent block. */\n\t\t\t\t\t__(\n\t\t\t\t\t\t'The block will stick to the scrollable area of the parent %s block.'\n\t\t\t\t\t),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: null;\n\n\tconst options = useMemo( () => {\n\t\tconst availableOptions = [ DEFAULT_OPTION ];\n\t\t// Display options if they are allowed, or if a block already has a valid value set.\n\t\t// This allows for a block to be switched off from a position type that is not allowed.\n\t\tif ( allowSticky || value === STICKY_OPTION.value ) {\n\t\t\tavailableOptions.push( STICKY_OPTION );\n\t\t}\n\t\tif ( allowFixed || value === FIXED_OPTION.value ) {\n\t\t\tavailableOptions.push( FIXED_OPTION );\n\t\t}\n\t\treturn availableOptions;\n\t}, [ allowFixed, allowSticky, value ] );\n\n\tconst onChangeType = ( next ) => {\n\t\t// For now, use a hard-coded `0px` value for the position.\n\t\t// `0px` is preferred over `0` as it can be used in `calc()` functions.\n\t\t// In the future, it could be useful to allow for an offset value.\n\t\tconst placementValue = '0px';\n\n\t\tconst newStyle = {\n\t\t\t...style,\n\t\t\tposition: {\n\t\t\t\t...style?.position,\n\t\t\t\ttype: next,\n\t\t\t\ttop:\n\t\t\t\t\tnext === 'sticky' || next === 'fixed'\n\t\t\t\t\t\t? placementValue\n\t\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t};\n\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst selectedOption = value\n\t\t? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION\n\t\t: DEFAULT_OPTION;\n\n\t// Only display position controls if there is at least one option to choose from.\n\treturn Platform.select( {\n\t\tweb:\n\t\t\toptions.length > 1 ? (\n\t\t\t\t<InspectorControls group=\"position\">\n\t\t\t\t\t<BaseControl\n\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\thelp={ stickyHelpText }\n\t\t\t\t\t>\n\t\t\t\t\t\t<CustomSelectControl\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tclassName=\"block-editor-hooks__position-selection__select-control\"\n\t\t\t\t\t\t\tlabel={ __( 'Position' ) }\n\t\t\t\t\t\t\thideLabelFromVision\n\t\t\t\t\t\t\tdescribedBy={ sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Currently selected position.\n\t\t\t\t\t\t\t\t__( 'Currently selected position: %s' ),\n\t\t\t\t\t\t\t\tselectedOption.name\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\toptions={ options }\n\t\t\t\t\t\t\tvalue={ selectedOption }\n\t\t\t\t\t\t\t__experimentalShowSelectedHint\n\t\t\t\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\t\t\t\tonChangeType( selectedItem.value );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BaseControl>\n\t\t\t\t</InspectorControls>\n\t\t\t) : null,\n\t\tnative: null,\n\t} );\n}\n\nexport default {\n\tedit: function Edit( props ) {\n\t\tconst isPositionDisabled = useIsPositionDisabled( props );\n\t\tif ( isPositionDisabled ) {\n\t\t\treturn null;\n\t\t}\n\t\treturn <PositionPanelPure { ...props } />;\n\t},\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, POSITION_SUPPORT_KEY );\n\t},\n};\n\nfunction useBlockProps( { name, style } ) {\n\tconst hasPositionBlockSupport = hasBlockSupport(\n\t\tname,\n\t\tPOSITION_SUPPORT_KEY\n\t);\n\tconst isPositionDisabled = useIsPositionDisabled( { name } );\n\tconst allowPositionStyles = hasPositionBlockSupport && ! isPositionDisabled;\n\n\tconst id = useInstanceId( useBlockProps );\n\n\t// Higher specificity to override defaults in editor UI.\n\tconst positionSelector = `.wp-container-${ id }.wp-container-${ id }`;\n\n\t// Get CSS string for the current position values.\n\tlet css;\n\tif ( allowPositionStyles ) {\n\t\tcss =\n\t\t\tgetPositionCSS( {\n\t\t\t\tselector: positionSelector,\n\t\t\t\tstyle,\n\t\t\t} ) || '';\n\t}\n\n\t// Attach a `wp-container-` id-based class name.\n\tconst className = classnames( {\n\t\t[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t[ `is-position-${ style?.position?.type }` ]:\n\t\t\tallowPositionStyles && !! css && !! style?.position?.type,\n\t} );\n\n\tuseStyleOverride( { css } );\n\n\treturn { className };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAKA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAT,sBAA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c,CAAC;;EAEzC;EACA,MAAMQ,gBAAgB,GAAI,iBAAiBF,EAAI,iBAAiBA,EAAI,EAAC;;EAErE;EACA,IAAIG,GAAG;EACP,IAAKJ,mBAAmB,EAAG;IAC1BI,GAAG,GACF7F,cAAc,CAAE;MACfC,QAAQ,EAAE2F,gBAAgB;MAC1B1F;IACD,CAAE,CAAC,IAAI,EAAE;EACX;;EAEA;EACA,MAAMT,SAAS,GAAG,IAAAqG,mBAAU,EAAE;IAC7B,CAAG,gBAAgBJ,EAAI,EAAC,GAAID,mBAAmB,IAAI,CAAC,CAAEI,GAAG;IAAE;IAC3D,CAAG,eAAe3F,KAAK,EAAEI,QAAQ,EAAEF,IAAM,EAAC,GACzCqF,mBAAmB,IAAI,CAAC,CAAEI,GAAG,IAAI,CAAC,CAAE3F,KAAK,EAAEI,QAAQ,EAAEF;EACvD,CAAE,CAAC;EAEH,IAAA2F,uBAAgB,EAAE;IAAEF;EAAI,CAAE,CAAC;EAE3B,OAAO;IAAEpG;EAAU,CAAC;AACrB"}
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _i18n = require("@wordpress/i18n");
9
9
  var _components = require("@wordpress/components");
10
+ var _element = require("@wordpress/element");
10
11
  var _utils = require("./utils");
11
12
  var _gap = require("../hooks/gap");
12
13
  var _utils2 = require("../hooks/utils");
@@ -49,6 +50,19 @@ const RANGE_CONTROL_MAX_VALUES = {
49
50
  lvmax: 100,
50
51
  dvmax: 100
51
52
  };
53
+ const units = [{
54
+ value: 'px',
55
+ label: 'px',
56
+ default: 0
57
+ }, {
58
+ value: 'rem',
59
+ label: 'rem',
60
+ default: 0
61
+ }, {
62
+ value: 'em',
63
+ label: 'em',
64
+ default: 0
65
+ }];
52
66
  var _default = exports.default = {
53
67
  name: 'grid',
54
68
  label: (0, _i18n.__)('Grid'),
@@ -56,13 +70,16 @@ var _default = exports.default = {
56
70
  layout = {},
57
71
  onChange
58
72
  }) {
59
- return layout?.columnCount ? (0, _react.createElement)(GridLayoutColumnsControl, {
73
+ return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(GridLayoutTypeControl, {
74
+ layout: layout,
75
+ onChange: onChange
76
+ }), layout?.columnCount ? (0, _react.createElement)(GridLayoutColumnsControl, {
60
77
  layout: layout,
61
78
  onChange: onChange
62
79
  }) : (0, _react.createElement)(GridLayoutMinimumWidthControl, {
63
80
  layout: layout,
64
81
  onChange: onChange
65
- });
82
+ }));
66
83
  },
67
84
  toolBarControls: function DefaultLayoutToolbarControls() {
68
85
  return null;
@@ -88,7 +105,7 @@ var _default = exports.default = {
88
105
  if (columnCount) {
89
106
  rules.push(`grid-template-columns: repeat(${columnCount}, minmax(0, 1fr))`);
90
107
  } else if (minimumColumnWidth) {
91
- rules.push(`grid-template-columns: repeat(auto-fill, minmax(min(${minimumColumnWidth}, 100%), 1fr))`);
108
+ rules.push(`grid-template-columns: repeat(auto-fill, minmax(min(${minimumColumnWidth}, 100%), 1fr))`, `container-type: inline-size`);
92
109
  }
93
110
  if (rules.length) {
94
111
  // Reason to disable: the extra line breaks added by prettier mess with the unit tests.
@@ -135,9 +152,6 @@ function GridLayoutMinimumWidthControl({
135
152
  } else if (['em', 'rem'].includes(unit) && newUnit === 'px') {
136
153
  // Convert to pixel value assuming a root size of 16px.
137
154
  newValue = Math.round(quantity * 16) + newUnit;
138
- } else if (['vh', 'vw', '%', 'svw', 'lvw', 'dvw', 'svh', 'lvh', 'dvh', 'vi', 'svi', 'lvi', 'dvi', 'vb', 'svb', 'lvb', 'dvb', 'vmin', 'svmin', 'lvmin', 'dvmin', 'vmax', 'svmax', 'lvmax', 'dvmax'].includes(newUnit) && quantity > 100) {
139
- // When converting to `%` or viewport-relative units, cap the new value at 100.
140
- newValue = 100 + newUnit;
141
155
  }
142
156
  onChange({
143
157
  ...layout,
@@ -160,7 +174,10 @@ function GridLayoutMinimumWidthControl({
160
174
  },
161
175
  onUnitChange: handleUnitChange,
162
176
  value: value,
163
- min: 0
177
+ units: units,
178
+ min: 0,
179
+ label: (0, _i18n.__)('Minimum column width'),
180
+ hideLabelFromVision: true
164
181
  })), (0, _react.createElement)(_components.FlexItem, {
165
182
  isBlock: true
166
183
  }, (0, _react.createElement)(_components.RangeControl, {
@@ -168,7 +185,9 @@ function GridLayoutMinimumWidthControl({
168
185
  value: quantity,
169
186
  min: 0,
170
187
  max: RANGE_CONTROL_MAX_VALUES[unit] || 600,
171
- withInputField: false
188
+ withInputField: false,
189
+ label: (0, _i18n.__)('Minimum column width'),
190
+ hideLabelFromVision: true
172
191
  }))));
173
192
  }
174
193
 
@@ -180,15 +199,89 @@ function GridLayoutColumnsControl({
180
199
  const {
181
200
  columnCount = 3
182
201
  } = layout;
183
- return (0, _react.createElement)(_components.RangeControl, {
184
- label: (0, _i18n.__)('Columns'),
202
+ return (0, _react.createElement)("fieldset", null, (0, _react.createElement)(_components.BaseControl.VisualLabel, {
203
+ as: "legend"
204
+ }, (0, _i18n.__)('Columns')), (0, _react.createElement)(_components.Flex, {
205
+ gap: 4
206
+ }, (0, _react.createElement)(_components.FlexItem, {
207
+ isBlock: true
208
+ }, (0, _react.createElement)(_components.__experimentalNumberControl, {
209
+ size: '__unstable-large',
210
+ onChange: value => {
211
+ /**
212
+ * If the input is cleared, avoid switching
213
+ * back to "Auto" by setting a value of "1".
214
+ */
215
+ const validValue = value !== '' ? value : '1';
216
+ onChange({
217
+ ...layout,
218
+ columnCount: validValue
219
+ });
220
+ },
185
221
  value: columnCount,
222
+ min: 1,
223
+ label: (0, _i18n.__)('Columns'),
224
+ hideLabelFromVision: true
225
+ })), (0, _react.createElement)(_components.FlexItem, {
226
+ isBlock: true
227
+ }, (0, _react.createElement)(_components.RangeControl, {
228
+ value: parseInt(columnCount, 10) // RangeControl can't deal with strings.
229
+ ,
186
230
  onChange: value => onChange({
187
231
  ...layout,
188
232
  columnCount: value
189
233
  }),
190
234
  min: 1,
191
- max: 6
192
- });
235
+ max: 16,
236
+ withInputField: false,
237
+ label: (0, _i18n.__)('Columns'),
238
+ hideLabelFromVision: true
239
+ }))));
240
+ }
241
+
242
+ // Enables switching between grid types
243
+ function GridLayoutTypeControl({
244
+ layout,
245
+ onChange
246
+ }) {
247
+ const {
248
+ columnCount,
249
+ minimumColumnWidth
250
+ } = layout;
251
+
252
+ /**
253
+ * When switching, temporarily save any custom values set on the
254
+ * previous type so we can switch back without loss.
255
+ */
256
+ const [tempColumnCount, setTempColumnCount] = (0, _element.useState)(columnCount || 3);
257
+ const [tempMinimumColumnWidth, setTempMinimumColumnWidth] = (0, _element.useState)(minimumColumnWidth || '12rem');
258
+ const isManual = !!columnCount ? 'manual' : 'auto';
259
+ const onChangeType = value => {
260
+ if (value === 'manual') {
261
+ setTempMinimumColumnWidth(minimumColumnWidth || '12rem');
262
+ } else {
263
+ setTempColumnCount(columnCount || 3);
264
+ }
265
+ onChange({
266
+ ...layout,
267
+ columnCount: value === 'manual' ? tempColumnCount : null,
268
+ minimumColumnWidth: value === 'auto' ? tempMinimumColumnWidth : null
269
+ });
270
+ };
271
+ return (0, _react.createElement)(_components.__experimentalToggleGroupControl, {
272
+ __nextHasNoMarginBottom: true,
273
+ label: (0, _i18n.__)('Type'),
274
+ value: isManual,
275
+ onChange: onChangeType,
276
+ isBlock: true
277
+ }, (0, _react.createElement)(_components.__experimentalToggleGroupControlOption, {
278
+ key: 'auto',
279
+ value: "auto",
280
+ label: (0, _i18n.__)('Auto')
281
+ }), (0, _react.createElement)(_components.__experimentalToggleGroupControlOption, {
282
+ key: 'manual',
283
+ value: "manual",
284
+ label: (0, _i18n.__)('Manual')
285
+ }));
193
286
  }
194
287
  //# sourceMappingURL=grid.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_components","_utils","_gap","_utils2","_definitions","RANGE_CONTROL_MAX_VALUES","px","vw","vh","em","rem","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","_default","exports","default","name","label","__","inspectorControls","GridLayoutInspectorControls","layout","onChange","columnCount","_react","createElement","GridLayoutColumnsControl","GridLayoutMinimumWidthControl","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","LAYOUT_DEFINITIONS","minimumColumnWidth","blockGapValue","spacing","blockGap","shouldSkipSerialization","getGapCSSValue","undefined","output","rules","push","length","appendSelectors","join","getBlockGapCSS","getOrientation","getAlignments","value","quantity","unit","parseQuantityAndUnitFromRawValue","handleSliderChange","next","handleUnitChange","newUnit","newValue","includes","toFixed","Math","round","BaseControl","VisualLabel","as","Flex","gap","FlexItem","isBlock","__experimentalUnitControl","size","onUnitChange","min","RangeControl","max","withInputField"],"sources":["@wordpress/block-editor/src/layouts/grid.js"],"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';\nimport { LAYOUT_DEFINITIONS } from './definitions';\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\tsvw: 100,\n\tlvw: 100,\n\tdvw: 100,\n\tsvh: 100,\n\tlvh: 100,\n\tdvh: 100,\n\tvi: 100,\n\tsvi: 100,\n\tlvi: 100,\n\tdvi: 100,\n\tvb: 100,\n\tsvb: 100,\n\tlvb: 100,\n\tdvb: 100,\n\tvmin: 100,\n\tsvmin: 100,\n\tlvmin: 100,\n\tdvmin: 100,\n\tvmax: 100,\n\tsvmax: 100,\n\tlvmax: 100,\n\tdvmax: 100,\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 layout?.columnCount ? (\n\t\t\t<GridLayoutColumnsControl layout={ layout } onChange={ onChange } />\n\t\t) : (\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 = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { minimumColumnWidth = '12rem', columnCount = null } = 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 ( columnCount ) {\n\t\t\trules.push(\n\t\t\t\t`grid-template-columns: repeat(${ columnCount }, minmax(0, 1fr))`\n\t\t\t);\n\t\t} else if ( 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[\n\t\t\t\t'vh',\n\t\t\t\t'vw',\n\t\t\t\t'%',\n\t\t\t\t'svw',\n\t\t\t\t'lvw',\n\t\t\t\t'dvw',\n\t\t\t\t'svh',\n\t\t\t\t'lvh',\n\t\t\t\t'dvh',\n\t\t\t\t'vi',\n\t\t\t\t'svi',\n\t\t\t\t'lvi',\n\t\t\t\t'dvi',\n\t\t\t\t'vb',\n\t\t\t\t'svb',\n\t\t\t\t'lvb',\n\t\t\t\t'dvb',\n\t\t\t\t'vmin',\n\t\t\t\t'svmin',\n\t\t\t\t'lvmin',\n\t\t\t\t'dvmin',\n\t\t\t\t'vmax',\n\t\t\t\t'svmax',\n\t\t\t\t'lvmax',\n\t\t\t\t'dvmax',\n\t\t\t].includes( newUnit ) &&\n\t\t\tquantity > 100\n\t\t) {\n\t\t\t// When converting to `%` or viewport-relative 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\n// Enables setting number of grid columns\nfunction GridLayoutColumnsControl( { layout, onChange } ) {\n\tconst { columnCount = 3 } = layout;\n\n\treturn (\n\t\t<RangeControl\n\t\t\tlabel={ __( 'Columns' ) }\n\t\t\tvalue={ columnCount }\n\t\t\tonChange={ ( value ) =>\n\t\t\t\tonChange( {\n\t\t\t\t\t...layout,\n\t\t\t\t\tcolumnCount: value,\n\t\t\t\t} )\n\t\t\t}\n\t\t\tmin={ 1 }\n\t\t\tmax={ 6 }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAYA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AApBA;AACA;AACA;;AAYA;AACA;AACA;;AAMA,MAAMM,wBAAwB,GAAG;EAChCC,EAAE,EAAE,GAAG;EACP,GAAG,EAAE,GAAG;EACRC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,EAAE;EACNC,GAAG,EAAE,EAAE;EACPC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,EAAE,EAAE,GAAG;EACPC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,EAAE,EAAE,GAAG;EACPC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,GAAG,EAAE,GAAG;EACRC,IAAI,EAAE,GAAG;EACTC,KAAK,EAAE,GAAG;EACVC,KAAK,EAAE,GAAG;EACVC,KAAK,EAAE,GAAG;EACVC,IAAI,EAAE,GAAG;EACTC,KAAK,EAAE,GAAG;EACVC,KAAK,EAAE,GAAG;EACVC,KAAK,EAAE;AACR,CAAC;AAAC,IAAAC,QAAA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CAAE,CAAC;IACJ,CAAG;IACHc,YAAY,EAAGhB,gBAAkB;IACjCN,KAAK,EAAGA,KAAO;IACfuB,GAAG,EAAG;EAAG,CACT,CACQ,CAAC,EACX,IAAApD,MAAA,CAAAC,aAAA,EAAC7C,WAAA,CAAA2F,QAAQ;IAACC,OAAO;EAAA,GAChB,IAAAhD,MAAA,CAAAC,aAAA,EAAC7C,WAAA,CAAAiG,YAAY;IACZvD,QAAQ,EAAGmC,kBAAoB;IAC/BJ,KAAK,EAAGC,QAAU;IAClBsB,GAAG,EAAG,CAAG;IACTE,GAAG,EAAG7F,wBAAwB,CAAEsE,IAAI,CAAE,IAAI,GAAK;IAC/CwB,cAAc,EAAG;EAAO,CACxB,CACQ,CACL,CACG,CAAC;AAEb;;AAEA;AACA,SAASrD,wBAAwBA,CAAE;EAAEL,MAAM;EAAEC;AAAS,CAAC,EAAG;EACzD,MAAM;IAAEC,WAAW,GAAG;EAAE,CAAC,GAAGF,MAAM;EAElC,OACC,IAAAG,MAAA,CAAAC,aAAA,EAAC7C,WAAA,CAAAiG,YAAY;IACZ5D,KAAK,EAAG,IAAAC,QAAE,EAAE,SAAU,CAAG;IACzBmC,KAAK,EAAG9B,WAAa;IACrBD,QAAQ,EAAK+B,KAAK,IACjB/B,QAAQ,CAAE;MACT,GAAGD,MAAM;MACTE,WAAW,EAAE8B;IACd,CAAE,CACF;IACDuB,GAAG,EAAG,CAAG;IACTE,GAAG,EAAG;EAAG,CACT,CAAC;AAEJ"}
1
+ {"version":3,"names":["_i18n","require","_components","_element","_utils","_gap","_utils2","_definitions","RANGE_CONTROL_MAX_VALUES","px","vw","vh","em","rem","svw","lvw","dvw","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","units","value","label","default","_default","exports","name","__","inspectorControls","GridLayoutInspectorControls","layout","onChange","_react","createElement","Fragment","GridLayoutTypeControl","columnCount","GridLayoutColumnsControl","GridLayoutMinimumWidthControl","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","LAYOUT_DEFINITIONS","minimumColumnWidth","blockGapValue","spacing","blockGap","shouldSkipSerialization","getGapCSSValue","undefined","output","rules","push","length","appendSelectors","join","getBlockGapCSS","getOrientation","getAlignments","quantity","unit","parseQuantityAndUnitFromRawValue","handleSliderChange","next","handleUnitChange","newUnit","newValue","includes","toFixed","Math","round","BaseControl","VisualLabel","as","Flex","gap","FlexItem","isBlock","__experimentalUnitControl","size","onUnitChange","min","hideLabelFromVision","RangeControl","max","withInputField","__experimentalNumberControl","validValue","parseInt","tempColumnCount","setTempColumnCount","useState","tempMinimumColumnWidth","setTempMinimumColumnWidth","isManual","onChangeType","__experimentalToggleGroupControl","__nextHasNoMarginBottom","__experimentalToggleGroupControlOption","key"],"sources":["@wordpress/block-editor/src/layouts/grid.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\tBaseControl,\n\tFlex,\n\tFlexItem,\n\tRangeControl,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n\t__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { appendSelectors, getBlockGapCSS } from './utils';\nimport { getGapCSSValue } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\nimport { LAYOUT_DEFINITIONS } from './definitions';\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\tsvw: 100,\n\tlvw: 100,\n\tdvw: 100,\n\tsvh: 100,\n\tlvh: 100,\n\tdvh: 100,\n\tvi: 100,\n\tsvi: 100,\n\tlvi: 100,\n\tdvi: 100,\n\tvb: 100,\n\tsvb: 100,\n\tlvb: 100,\n\tdvb: 100,\n\tvmin: 100,\n\tsvmin: 100,\n\tlvmin: 100,\n\tdvmin: 100,\n\tvmax: 100,\n\tsvmax: 100,\n\tlvmax: 100,\n\tdvmax: 100,\n};\n\nconst units = [\n\t{ value: 'px', label: 'px', default: 0 },\n\t{ value: 'rem', label: 'rem', default: 0 },\n\t{ value: 'em', label: 'em', default: 0 },\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<>\n\t\t\t\t<GridLayoutTypeControl\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t/>\n\t\t\t\t{ layout?.columnCount ? (\n\t\t\t\t\t<GridLayoutColumnsControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) : (\n\t\t\t\t\t<GridLayoutMinimumWidthControl\n\t\t\t\t\t\tlayout={ layout }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t) }\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 = LAYOUT_DEFINITIONS,\n\t} ) {\n\t\tconst { minimumColumnWidth = '12rem', columnCount = null } = 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 ( columnCount ) {\n\t\t\trules.push(\n\t\t\t\t`grid-template-columns: repeat(${ columnCount }, minmax(0, 1fr))`\n\t\t\t);\n\t\t} else if ( 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\t`container-type: inline-size`\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}\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\tunits={ units }\n\t\t\t\t\t\tmin={ 0 }\n\t\t\t\t\t\tlabel={ __( 'Minimum column width' ) }\n\t\t\t\t\t\thideLabelFromVision\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\tlabel={ __( 'Minimum column width' ) }\n\t\t\t\t\t\thideLabelFromVision\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\n// Enables setting number of grid columns\nfunction GridLayoutColumnsControl( { layout, onChange } ) {\n\tconst { columnCount = 3 } = layout;\n\n\treturn (\n\t\t<fieldset>\n\t\t\t<BaseControl.VisualLabel as=\"legend\">\n\t\t\t\t{ __( 'Columns' ) }\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<NumberControl\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * If the input is cleared, avoid switching\n\t\t\t\t\t\t\t * back to \"Auto\" by setting a value of \"1\".\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\tconst validValue = value !== '' ? value : '1';\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\tcolumnCount: validValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tvalue={ columnCount }\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\thideLabelFromVision\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\tvalue={ parseInt( columnCount, 10 ) } // RangeControl can't deal with strings.\n\t\t\t\t\t\tonChange={ ( value ) =>\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\tcolumnCount: value,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\tmax={ 16 }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\thideLabelFromVision\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\n// Enables switching between grid types\nfunction GridLayoutTypeControl( { layout, onChange } ) {\n\tconst { columnCount, minimumColumnWidth } = layout;\n\n\t/**\n\t * When switching, temporarily save any custom values set on the\n\t * previous type so we can switch back without loss.\n\t */\n\tconst [ tempColumnCount, setTempColumnCount ] = useState(\n\t\tcolumnCount || 3\n\t);\n\tconst [ tempMinimumColumnWidth, setTempMinimumColumnWidth ] = useState(\n\t\tminimumColumnWidth || '12rem'\n\t);\n\n\tconst isManual = !! columnCount ? 'manual' : 'auto';\n\n\tconst onChangeType = ( value ) => {\n\t\tif ( value === 'manual' ) {\n\t\t\tsetTempMinimumColumnWidth( minimumColumnWidth || '12rem' );\n\t\t} else {\n\t\t\tsetTempColumnCount( columnCount || 3 );\n\t\t}\n\t\tonChange( {\n\t\t\t...layout,\n\t\t\tcolumnCount: value === 'manual' ? tempColumnCount : null,\n\t\t\tminimumColumnWidth:\n\t\t\t\tvalue === 'auto' ? tempMinimumColumnWidth : null,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__nextHasNoMarginBottom={ true }\n\t\t\tlabel={ __( 'Type' ) }\n\t\t\tvalue={ isManual }\n\t\t\tonChange={ onChangeType }\n\t\t\tisBlock={ true }\n\t\t>\n\t\t\t<ToggleGroupControlOption\n\t\t\t\tkey={ 'auto' }\n\t\t\t\tvalue=\"auto\"\n\t\t\t\tlabel={ __( 'Auto' ) }\n\t\t\t/>\n\t\t\t<ToggleGroupControlOption\n\t\t\t\tkey={ 'manual' }\n\t\t\t\tvalue=\"manual\"\n\t\t\t\tlabel={ __( 'Manual' ) }\n\t\t\t/>\n\t\t</ToggleGroupControl>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAWA,IAAAE,QAAA,GAAAF,OAAA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QAAQ,CAAE;MACT,GAAGD,MAAM;MACTM,WAAW,EAAEf,KAAK,KAAK,QAAQ,GAAGyE,eAAe,GAAG,IAAI;MACxD9C,kBAAkB,EACjB3B,KAAK,KAAK,MAAM,GAAG4E,sBAAsB,GAAG;IAC9C,CAAE,CAAC;EACJ,CAAC;EAED,OACC,IAAAjE,MAAA,CAAAC,aAAA,EAAC/C,WAAA,CAAAmH,gCAAkB;IAClBC,uBAAuB,EAAG,IAAM;IAChChF,KAAK,EAAG,IAAAK,QAAE,EAAE,MAAO,CAAG;IACtBN,KAAK,EAAG8E,QAAU;IAClBpE,QAAQ,EAAGqE,YAAc;IACzBlB,OAAO,EAAG;EAAM,GAEhB,IAAAlD,MAAA,CAAAC,aAAA,EAAC/C,WAAA,CAAAqH,sCAAwB;IACxBC,GAAG,EAAG,MAAQ;IACdnF,KAAK,EAAC,MAAM;IACZC,KAAK,EAAG,IAAAK,QAAE,EAAE,MAAO;EAAG,CACtB,CAAC,EACF,IAAAK,MAAA,CAAAC,aAAA,EAAC/C,WAAA,CAAAqH,sCAAwB;IACxBC,GAAG,EAAG,QAAU;IAChBnF,KAAK,EAAC,QAAQ;IACdC,KAAK,EAAG,IAAAK,QAAE,EAAE,QAAS;EAAG,CACxB,CACkB,CAAC;AAEvB"}
@@ -357,34 +357,6 @@ function toggleSelection(isSelectionEnabled = true) {
357
357
  isSelectionEnabled
358
358
  };
359
359
  }
360
- function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
361
- var _blockEditorSettings$;
362
- const preferredStyleVariations = (_blockEditorSettings$ = blockEditorSettings?.__experimentalPreferredStyleVariations?.value) !== null && _blockEditorSettings$ !== void 0 ? _blockEditorSettings$ : {};
363
- return blocks.map(block => {
364
- const blockName = block.name;
365
- if (!(0, _blocks.hasBlockSupport)(blockName, 'defaultStylePicker', true)) {
366
- return block;
367
- }
368
- if (!preferredStyleVariations[blockName]) {
369
- return block;
370
- }
371
- const className = block.attributes?.className;
372
- if (className?.includes('is-style-')) {
373
- return block;
374
- }
375
- const {
376
- attributes = {}
377
- } = block;
378
- const blockStyle = preferredStyleVariations[blockName];
379
- return {
380
- ...block,
381
- attributes: {
382
- ...attributes,
383
- className: `${className || ''} is-style-${blockStyle}`.trim()
384
- }
385
- };
386
- });
387
- }
388
360
 
389
361
  /* eslint-disable jsdoc/valid-types */
390
362
  /**
@@ -405,7 +377,7 @@ const replaceBlocks = (clientIds, blocks, indexToSelect, initialPosition = 0, me
405
377
  }) => {
406
378
  /* eslint-enable jsdoc/valid-types */
407
379
  clientIds = castArray(clientIds);
408
- blocks = getBlocksWithDefaultStylesApplied(castArray(blocks), select.getSettings());
380
+ blocks = castArray(blocks);
409
381
  const rootClientId = select.getBlockRootClientId(clientIds[0]);
410
382
  // Replace is valid if the new blocks can be inserted in the root block.
411
383
  for (let index = 0; index < blocks.length; index++) {
@@ -576,7 +548,7 @@ const insertBlocks = (blocks, index, rootClientId, updateSelection = true, initi
576
548
  hint: 'The meta argument is now the 6th argument of the function'
577
549
  });
578
550
  }
579
- blocks = getBlocksWithDefaultStylesApplied(castArray(blocks), select.getSettings());
551
+ blocks = castArray(blocks);
580
552
  const allowedBlocks = [];
581
553
  for (const block of blocks) {
582
554
  const isValid = select.canInsertBlockType(block.name, rootClientId);