@wordpress/block-editor 13.0.3 → 13.2.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 (141) hide show
  1. package/CHANGELOG.md +21 -17
  2. package/README.md +1 -1
  3. package/build/components/block-lock/modal.js +67 -67
  4. package/build/components/block-lock/modal.js.map +1 -1
  5. package/build/components/block-mover/index.js +12 -6
  6. package/build/components/block-mover/index.js.map +1 -1
  7. package/build/components/child-layout-control/index.js +185 -127
  8. package/build/components/child-layout-control/index.js.map +1 -1
  9. package/build/components/date-format-picker/index.js +18 -10
  10. package/build/components/date-format-picker/index.js.map +1 -1
  11. package/build/components/grid/grid-item-movers.js +97 -0
  12. package/build/components/grid/grid-item-movers.js.map +1 -0
  13. package/build/components/{grid-visualizer → grid}/grid-item-resizer.js +18 -56
  14. package/build/components/grid/grid-item-resizer.js.map +1 -0
  15. package/build/components/grid/grid-visualizer.js +225 -0
  16. package/build/components/grid/grid-visualizer.js.map +1 -0
  17. package/build/components/{grid-visualizer → grid}/index.js +14 -0
  18. package/build/components/grid/index.js.map +1 -0
  19. package/build/components/grid/use-get-number-of-blocks-before-cell.js +40 -0
  20. package/build/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  21. package/build/components/grid/use-grid-layout-sync.js +162 -0
  22. package/build/components/grid/use-grid-layout-sync.js.map +1 -0
  23. package/build/components/grid/utils.js +145 -0
  24. package/build/components/grid/utils.js.map +1 -0
  25. package/build/components/inner-blocks/index.js +1 -1
  26. package/build/components/inner-blocks/index.js.map +1 -1
  27. package/build/components/inserter/block-types-tab.native.js +1 -1
  28. package/build/components/inserter/block-types-tab.native.js.map +1 -1
  29. package/build/components/link-control/link-preview.js +12 -1
  30. package/build/components/link-control/link-preview.js.map +1 -1
  31. package/build/components/provider/use-block-sync.js +1 -7
  32. package/build/components/provider/use-block-sync.js.map +1 -1
  33. package/build/components/rich-text/event-listeners/input-rules.js +1 -0
  34. package/build/components/rich-text/event-listeners/input-rules.js.map +1 -1
  35. package/build/components/rich-text/index.native.js +14 -4
  36. package/build/components/rich-text/index.native.js.map +1 -1
  37. package/build/components/rich-text/native/index.native.js +20 -4
  38. package/build/components/rich-text/native/index.native.js.map +1 -1
  39. package/build/hooks/block-style-variation.js +2 -2
  40. package/build/hooks/block-style-variation.js.map +1 -1
  41. package/build/hooks/layout-child.js +29 -21
  42. package/build/hooks/layout-child.js.map +1 -1
  43. package/build/layouts/grid.js +24 -47
  44. package/build/layouts/grid.js.map +1 -1
  45. package/build/store/private-actions.js +0 -34
  46. package/build/store/private-actions.js.map +1 -1
  47. package/build-module/components/block-lock/modal.js +67 -67
  48. package/build-module/components/block-lock/modal.js.map +1 -1
  49. package/build-module/components/block-mover/index.js +12 -6
  50. package/build-module/components/block-mover/index.js.map +1 -1
  51. package/build-module/components/child-layout-control/index.js +185 -127
  52. package/build-module/components/child-layout-control/index.js.map +1 -1
  53. package/build-module/components/date-format-picker/index.js +19 -11
  54. package/build-module/components/date-format-picker/index.js.map +1 -1
  55. package/build-module/components/grid/grid-item-movers.js +90 -0
  56. package/build-module/components/grid/grid-item-movers.js.map +1 -0
  57. package/build-module/components/{grid-visualizer → grid}/grid-item-resizer.js +13 -51
  58. package/build-module/components/grid/grid-item-resizer.js.map +1 -0
  59. package/build-module/components/grid/grid-visualizer.js +217 -0
  60. package/build-module/components/grid/grid-visualizer.js.map +1 -0
  61. package/build-module/components/grid/index.js +5 -0
  62. package/build-module/components/grid/index.js.map +1 -0
  63. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js +33 -0
  64. package/build-module/components/grid/use-get-number-of-blocks-before-cell.js.map +1 -0
  65. package/build-module/components/grid/use-grid-layout-sync.js +155 -0
  66. package/build-module/components/grid/use-grid-layout-sync.js.map +1 -0
  67. package/build-module/components/grid/utils.js +131 -0
  68. package/build-module/components/grid/utils.js.map +1 -0
  69. package/build-module/components/inner-blocks/index.js +1 -1
  70. package/build-module/components/inner-blocks/index.js.map +1 -1
  71. package/build-module/components/inserter/block-types-tab.native.js +1 -1
  72. package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
  73. package/build-module/components/link-control/link-preview.js +14 -1
  74. package/build-module/components/link-control/link-preview.js.map +1 -1
  75. package/build-module/components/provider/use-block-sync.js +1 -7
  76. package/build-module/components/provider/use-block-sync.js.map +1 -1
  77. package/build-module/components/rich-text/event-listeners/input-rules.js +1 -1
  78. package/build-module/components/rich-text/event-listeners/input-rules.js.map +1 -1
  79. package/build-module/components/rich-text/index.native.js +15 -5
  80. package/build-module/components/rich-text/index.native.js.map +1 -1
  81. package/build-module/components/rich-text/native/index.native.js +20 -4
  82. package/build-module/components/rich-text/native/index.native.js.map +1 -1
  83. package/build-module/hooks/block-style-variation.js +2 -2
  84. package/build-module/hooks/block-style-variation.js.map +1 -1
  85. package/build-module/hooks/layout-child.js +27 -19
  86. package/build-module/hooks/layout-child.js.map +1 -1
  87. package/build-module/layouts/grid.js +24 -47
  88. package/build-module/layouts/grid.js.map +1 -1
  89. package/build-module/store/private-actions.js +0 -33
  90. package/build-module/store/private-actions.js.map +1 -1
  91. package/build-style/style-rtl.css +38 -16
  92. package/build-style/style.css +38 -16
  93. package/package.json +31 -31
  94. package/src/components/block-lock/modal.js +95 -82
  95. package/src/components/block-lock/style.scss +11 -1
  96. package/src/components/block-mover/index.js +37 -24
  97. package/src/components/child-layout-control/index.js +224 -159
  98. package/src/components/date-format-picker/index.js +25 -13
  99. package/src/components/grid/grid-item-movers.js +128 -0
  100. package/src/components/{grid-visualizer → grid}/grid-item-resizer.js +14 -52
  101. package/src/components/grid/grid-visualizer.js +267 -0
  102. package/src/components/grid/index.js +4 -0
  103. package/src/components/grid/style.scss +63 -0
  104. package/src/components/grid/use-get-number-of-blocks-before-cell.js +30 -0
  105. package/src/components/grid/use-grid-layout-sync.js +167 -0
  106. package/src/components/grid/utils.js +178 -0
  107. package/src/components/inner-blocks/index.js +3 -1
  108. package/src/components/inserter/block-types-tab.native.js +2 -1
  109. package/src/components/link-control/link-preview.js +18 -1
  110. package/src/components/provider/use-block-sync.js +0 -6
  111. package/src/components/rich-text/event-listeners/input-rules.js +1 -1
  112. package/src/components/rich-text/index.native.js +14 -8
  113. package/src/components/rich-text/native/index.native.js +20 -1
  114. package/src/hooks/block-style-variation.js +2 -2
  115. package/src/hooks/layout-child.js +34 -14
  116. package/src/layouts/grid.js +54 -62
  117. package/src/store/private-actions.js +0 -29
  118. package/src/style.scss +1 -1
  119. package/build/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  120. package/build/components/grid-visualizer/grid-visualizer.js +0 -92
  121. package/build/components/grid-visualizer/grid-visualizer.js.map +0 -1
  122. package/build/components/grid-visualizer/index.js.map +0 -1
  123. package/build/components/grid-visualizer/utils.js +0 -10
  124. package/build/components/grid-visualizer/utils.js.map +0 -1
  125. package/build/store/undo-ignore.js +0 -11
  126. package/build/store/undo-ignore.js.map +0 -1
  127. package/build-module/components/grid-visualizer/grid-item-resizer.js.map +0 -1
  128. package/build-module/components/grid-visualizer/grid-visualizer.js +0 -84
  129. package/build-module/components/grid-visualizer/grid-visualizer.js.map +0 -1
  130. package/build-module/components/grid-visualizer/index.js +0 -3
  131. package/build-module/components/grid-visualizer/index.js.map +0 -1
  132. package/build-module/components/grid-visualizer/utils.js +0 -4
  133. package/build-module/components/grid-visualizer/utils.js.map +0 -1
  134. package/build-module/store/undo-ignore.js +0 -5
  135. package/build-module/store/undo-ignore.js.map +0 -1
  136. package/src/components/grid-visualizer/grid-visualizer.js +0 -101
  137. package/src/components/grid-visualizer/index.js +0 -2
  138. package/src/components/grid-visualizer/style.scss +0 -34
  139. package/src/components/grid-visualizer/utils.js +0 -5
  140. package/src/store/undo-ignore.js +0 -4
  141. /package/src/components/font-sizes/{README.MD → README.md} +0 -0
@@ -2,17 +2,21 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { _x, __ } from '@wordpress/i18n';
5
- import { dateI18n } from '@wordpress/date';
5
+ import { dateI18n, humanTimeDiff } from '@wordpress/date';
6
6
  import { useState, createInterpolateElement } from '@wordpress/element';
7
7
  import { TextControl, ExternalLink, VisuallyHidden, CustomSelectControl, ToggleControl, __experimentalVStack as VStack } from '@wordpress/components';
8
8
 
9
- // So that we can illustrate the different formats in the dropdown properly,
10
- // show a date that has a day greater than 12 and a month with more than three
11
- // letters. Here we're using 2022-01-25 which is when WordPress 5.9 was
12
- // released.
9
+ // So that we illustrate the different formats in the dropdown properly, show a date that is
10
+ // somwhat recent, has a day greater than 12, and a month with more than three letters.
13
11
  import { jsx as _jsx } from "react/jsx-runtime";
14
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- const EXAMPLE_DATE = new Date(2022, 0, 25);
13
+ const exampleDate = new Date();
14
+ exampleDate.setDate(20);
15
+ exampleDate.setMonth(exampleDate.getMonth() - 3);
16
+ if (exampleDate.getMonth() === 4) {
17
+ // May has three letters, so use March.
18
+ exampleDate.setMonth(3);
19
+ }
16
20
 
17
21
  /**
18
22
  * The `DateFormatPicker` component renders controls that let the user choose a
@@ -49,7 +53,7 @@ export default function DateFormatPicker({
49
53
  }), /*#__PURE__*/_jsx(ToggleControl, {
50
54
  __nextHasNoMarginBottom: true,
51
55
  label: __('Default format'),
52
- help: `${__('Example:')} ${dateI18n(defaultFormat, EXAMPLE_DATE)}`,
56
+ help: `${__('Example:')} ${dateI18n(defaultFormat, exampleDate)}`,
53
57
  checked: !format,
54
58
  onChange: checked => onChange(checked ? null : defaultFormat)
55
59
  }), format && /*#__PURE__*/_jsx(NonDefaultControls, {
@@ -78,18 +82,22 @@ function NonDefaultControls({
78
82
  _x('M j, Y g:i A', 'medium date format with time'), /* translators: See https://www.php.net/manual/datetime.format.php */
79
83
  _x('F j, Y', 'long date format'), /* translators: See https://www.php.net/manual/datetime.format.php */
80
84
  _x('M j', 'short date format without the year')])];
81
- const suggestedOptions = suggestedFormats.map((suggestedFormat, index) => ({
85
+ const suggestedOptions = [...suggestedFormats.map((suggestedFormat, index) => ({
82
86
  key: `suggested-${index}`,
83
- name: dateI18n(suggestedFormat, EXAMPLE_DATE),
87
+ name: dateI18n(suggestedFormat, exampleDate),
84
88
  format: suggestedFormat
85
- }));
89
+ })), {
90
+ key: 'human-diff',
91
+ name: humanTimeDiff(exampleDate),
92
+ format: 'human-diff'
93
+ }];
86
94
  const customOption = {
87
95
  key: 'custom',
88
96
  name: __('Custom'),
89
97
  className: 'block-editor-date-format-picker__custom-format-select-control__custom-option',
90
98
  __experimentalHint: __('Enter your own date format')
91
99
  };
92
- const [isCustom, setIsCustom] = useState(() => !!format && !suggestedFormats.includes(format));
100
+ const [isCustom, setIsCustom] = useState(() => !!format && !suggestedOptions.some(option => option.format === format));
93
101
  return /*#__PURE__*/_jsxs(VStack, {
94
102
  children: [/*#__PURE__*/_jsx(CustomSelectControl, {
95
103
  label: __('Choose a format'),
@@ -1 +1 @@
1
- {"version":3,"names":["_x","__","dateI18n","useState","createInterpolateElement","TextControl","ExternalLink","VisuallyHidden","CustomSelectControl","ToggleControl","__experimentalVStack","VStack","jsx","_jsx","jsxs","_jsxs","EXAMPLE_DATE","Date","DateFormatPicker","format","defaultFormat","onChange","className","children","as","__nextHasNoMarginBottom","label","help","checked","NonDefaultControls","_suggestedOptions$fin","suggestedFormats","Set","suggestedOptions","map","suggestedFormat","index","key","name","customOption","__experimentalHint","isCustom","setIsCustom","includes","options","value","find","option","selectedItem","hideLabelFromVision","Link","href"],"sources":["@wordpress/block-editor/src/components/date-format-picker/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __ } from '@wordpress/i18n';\nimport { dateI18n } from '@wordpress/date';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport {\n\tTextControl,\n\tExternalLink,\n\tVisuallyHidden,\n\tCustomSelectControl,\n\tToggleControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n// So that we can illustrate the different formats in the dropdown properly,\n// show a date that has a day greater than 12 and a month with more than three\n// letters. Here we're using 2022-01-25 which is when WordPress 5.9 was\n// released.\nconst EXAMPLE_DATE = new Date( 2022, 0, 25 );\n\n/**\n * The `DateFormatPicker` component renders controls that let the user choose a\n * _date format_. That is, how they want their dates to be formatted.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md\n *\n * @param {Object} props\n * @param {string|null} props.format The selected date\n * format. If\n * `null`,\n * _Default_ is\n * selected.\n * @param {string} props.defaultFormat The date format that\n * will be used if the\n * user selects\n * 'Default'.\n * @param {( format: string|null ) => void} props.onChange Called when a\n * selection is\n * made. If `null`,\n * _Default_ is\n * selected.\n */\nexport default function DateFormatPicker( {\n\tformat,\n\tdefaultFormat,\n\tonChange,\n} ) {\n\treturn (\n\t\t<fieldset className=\"block-editor-date-format-picker\">\n\t\t\t<VisuallyHidden as=\"legend\">{ __( 'Date format' ) }</VisuallyHidden>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Default format' ) }\n\t\t\t\thelp={ `${ __( 'Example:' ) } ${ dateI18n(\n\t\t\t\t\tdefaultFormat,\n\t\t\t\t\tEXAMPLE_DATE\n\t\t\t\t) }` }\n\t\t\t\tchecked={ ! format }\n\t\t\t\tonChange={ ( checked ) =>\n\t\t\t\t\tonChange( checked ? null : defaultFormat )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ format && (\n\t\t\t\t<NonDefaultControls format={ format } onChange={ onChange } />\n\t\t\t) }\n\t\t</fieldset>\n\t);\n}\n\nfunction NonDefaultControls( { format, onChange } ) {\n\t// Suggest a short format, medium format, long format, and a standardised\n\t// (YYYY-MM-DD) format. The short, medium, and long formats are localised as\n\t// different languages have different ways of writing these. For example, 'F\n\t// j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April\n\t// 2022) in German (de). The resultant array is de-duplicated as some\n\t// languages will use the same format string for short, medium, and long\n\t// formats.\n\tconst suggestedFormats = [\n\t\t...new Set( [\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t'Y-m-d',\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'n/j/Y', 'short date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'n/j/Y g:i A', 'short date format with time' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j, Y', 'medium date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j, Y g:i A', 'medium date format with time' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'F j, Y', 'long date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j', 'short date format without the year' ),\n\t\t] ),\n\t];\n\n\tconst suggestedOptions = suggestedFormats.map(\n\t\t( suggestedFormat, index ) => ( {\n\t\t\tkey: `suggested-${ index }`,\n\t\t\tname: dateI18n( suggestedFormat, EXAMPLE_DATE ),\n\t\t\tformat: suggestedFormat,\n\t\t} )\n\t);\n\tconst customOption = {\n\t\tkey: 'custom',\n\t\tname: __( 'Custom' ),\n\t\tclassName:\n\t\t\t'block-editor-date-format-picker__custom-format-select-control__custom-option',\n\t\t__experimentalHint: __( 'Enter your own date format' ),\n\t};\n\n\tconst [ isCustom, setIsCustom ] = useState(\n\t\t() => !! format && ! suggestedFormats.includes( format )\n\t);\n\n\treturn (\n\t\t<VStack>\n\t\t\t<CustomSelectControl\n\t\t\t\tlabel={ __( 'Choose a format' ) }\n\t\t\t\toptions={ [ ...suggestedOptions, customOption ] }\n\t\t\t\tvalue={\n\t\t\t\t\tisCustom\n\t\t\t\t\t\t? customOption\n\t\t\t\t\t\t: suggestedOptions.find(\n\t\t\t\t\t\t\t\t( option ) => option.format === format\n\t\t\t\t\t\t ) ?? customOption\n\t\t\t\t}\n\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\tif ( selectedItem === customOption ) {\n\t\t\t\t\t\tsetIsCustom( true );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetIsCustom( false );\n\t\t\t\t\t\tonChange( selectedItem.format );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ isCustom && (\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Custom format' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Enter a date or time <Link>format string</Link>.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/customize-date-and-time-format/'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvalue={ format }\n\t\t\t\t\tonChange={ ( value ) => onChange( value ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,QAAQ,QAAQ,iBAAiB;AAC1C,SAASC,QAAQ,EAAEC,wBAAwB,QAAQ,oBAAoB;AACvE,SACCC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,mBAAmB,EACnBC,aAAa,EACbC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;;AAE9B;AACA;AACA;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AACA,MAAMC,YAAY,GAAG,IAAIC,IAAI,CAAE,IAAI,EAAE,CAAC,EAAE,EAAG,CAAC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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D;IAAG,CACH,CAAC,EACAsB,QAAQ,iBACT5B,IAAA,CAACR,WAAW;MACXoB,uBAAuB;MACvBC,KAAK,EAAGzB,EAAE,CAAE,eAAgB,CAAG;MAC/BgD,mBAAmB;MACnBtB,IAAI,EAAGvB,wBAAwB,CAC9BH,EAAE,CACD,kDACD,CAAC,EACD;QACCiD,IAAI,eACHrC,IAAA,CAACP,YAAY;UACZ6C,IAAI,EAAGlD,EAAE,CACR,6EACD;QAAG,CACH;MAEH,CACD,CAAG;MACH4C,KAAK,EAAG1B,MAAQ;MAChBE,QAAQ,EAAKwB,KAAK,IAAMxB,QAAQ,CAAEwB,KAAM;IAAG,CAC3C,CACD;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
1
+ {"version":3,"names":["_x","__","dateI18n","humanTimeDiff","useState","createInterpolateElement","TextControl","ExternalLink","VisuallyHidden","CustomSelectControl","ToggleControl","__experimentalVStack","VStack","jsx","_jsx","jsxs","_jsxs","exampleDate","Date","setDate","setMonth","getMonth","DateFormatPicker","format","defaultFormat","onChange","className","children","as","__nextHasNoMarginBottom","label","help","checked","NonDefaultControls","_suggestedOptions$fin","suggestedFormats","Set","suggestedOptions","map","suggestedFormat","index","key","name","customOption","__experimentalHint","isCustom","setIsCustom","some","option","options","value","find","selectedItem","hideLabelFromVision","Link","href"],"sources":["@wordpress/block-editor/src/components/date-format-picker/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _x, __ } from '@wordpress/i18n';\nimport { dateI18n, humanTimeDiff } from '@wordpress/date';\nimport { useState, createInterpolateElement } from '@wordpress/element';\nimport {\n\tTextControl,\n\tExternalLink,\n\tVisuallyHidden,\n\tCustomSelectControl,\n\tToggleControl,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\n\n// So that we illustrate the different formats in the dropdown properly, show a date that is\n// somwhat recent, has a day greater than 12, and a month with more than three letters.\nconst exampleDate = new Date();\nexampleDate.setDate( 20 );\nexampleDate.setMonth( exampleDate.getMonth() - 3 );\nif ( exampleDate.getMonth() === 4 ) {\n\t// May has three letters, so use March.\n\texampleDate.setMonth( 3 );\n}\n\n/**\n * The `DateFormatPicker` component renders controls that let the user choose a\n * _date format_. That is, how they want their dates to be formatted.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/date-format-picker/README.md\n *\n * @param {Object} props\n * @param {string|null} props.format The selected date\n * format. If\n * `null`,\n * _Default_ is\n * selected.\n * @param {string} props.defaultFormat The date format that\n * will be used if the\n * user selects\n * 'Default'.\n * @param {( format: string|null ) => void} props.onChange Called when a\n * selection is\n * made. If `null`,\n * _Default_ is\n * selected.\n */\nexport default function DateFormatPicker( {\n\tformat,\n\tdefaultFormat,\n\tonChange,\n} ) {\n\treturn (\n\t\t<fieldset className=\"block-editor-date-format-picker\">\n\t\t\t<VisuallyHidden as=\"legend\">{ __( 'Date format' ) }</VisuallyHidden>\n\t\t\t<ToggleControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Default format' ) }\n\t\t\t\thelp={ `${ __( 'Example:' ) } ${ dateI18n(\n\t\t\t\t\tdefaultFormat,\n\t\t\t\t\texampleDate\n\t\t\t\t) }` }\n\t\t\t\tchecked={ ! format }\n\t\t\t\tonChange={ ( checked ) =>\n\t\t\t\t\tonChange( checked ? null : defaultFormat )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ format && (\n\t\t\t\t<NonDefaultControls format={ format } onChange={ onChange } />\n\t\t\t) }\n\t\t</fieldset>\n\t);\n}\n\nfunction NonDefaultControls( { format, onChange } ) {\n\t// Suggest a short format, medium format, long format, and a standardised\n\t// (YYYY-MM-DD) format. The short, medium, and long formats are localised as\n\t// different languages have different ways of writing these. For example, 'F\n\t// j, Y' (April 20, 2022) in American English (en_US) is 'j. F Y' (20. April\n\t// 2022) in German (de). The resultant array is de-duplicated as some\n\t// languages will use the same format string for short, medium, and long\n\t// formats.\n\tconst suggestedFormats = [\n\t\t...new Set( [\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t'Y-m-d',\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'n/j/Y', 'short date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'n/j/Y g:i A', 'short date format with time' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j, Y', 'medium date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j, Y g:i A', 'medium date format with time' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'F j, Y', 'long date format' ),\n\t\t\t/* translators: See https://www.php.net/manual/datetime.format.php */\n\t\t\t_x( 'M j', 'short date format without the year' ),\n\t\t] ),\n\t];\n\n\tconst suggestedOptions = [\n\t\t...suggestedFormats.map( ( suggestedFormat, index ) => ( {\n\t\t\tkey: `suggested-${ index }`,\n\t\t\tname: dateI18n( suggestedFormat, exampleDate ),\n\t\t\tformat: suggestedFormat,\n\t\t} ) ),\n\t\t{\n\t\t\tkey: 'human-diff',\n\t\t\tname: humanTimeDiff( exampleDate ),\n\t\t\tformat: 'human-diff',\n\t\t},\n\t];\n\n\tconst customOption = {\n\t\tkey: 'custom',\n\t\tname: __( 'Custom' ),\n\t\tclassName:\n\t\t\t'block-editor-date-format-picker__custom-format-select-control__custom-option',\n\t\t__experimentalHint: __( 'Enter your own date format' ),\n\t};\n\n\tconst [ isCustom, setIsCustom ] = useState(\n\t\t() =>\n\t\t\t!! format &&\n\t\t\t! suggestedOptions.some( ( option ) => option.format === format )\n\t);\n\n\treturn (\n\t\t<VStack>\n\t\t\t<CustomSelectControl\n\t\t\t\tlabel={ __( 'Choose a format' ) }\n\t\t\t\toptions={ [ ...suggestedOptions, customOption ] }\n\t\t\t\tvalue={\n\t\t\t\t\tisCustom\n\t\t\t\t\t\t? customOption\n\t\t\t\t\t\t: suggestedOptions.find(\n\t\t\t\t\t\t\t\t( option ) => option.format === format\n\t\t\t\t\t\t ) ?? customOption\n\t\t\t\t}\n\t\t\t\tonChange={ ( { selectedItem } ) => {\n\t\t\t\t\tif ( selectedItem === customOption ) {\n\t\t\t\t\t\tsetIsCustom( true );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsetIsCustom( false );\n\t\t\t\t\t\tonChange( selectedItem.format );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t{ isCustom && (\n\t\t\t\t<TextControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Custom format' ) }\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\thelp={ createInterpolateElement(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Enter a date or time <Link>format string</Link>.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tLink: (\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/customize-date-and-time-format/'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t\tvalue={ format }\n\t\t\t\t\tonChange={ ( value ) => onChange( value ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</VStack>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,QAAQ,iBAAiB;AACxC,SAASC,QAAQ,EAAEC,aAAa,QAAQ,iBAAiB;AACzD,SAASC,QAAQ,EAAEC,wBAAwB,QAAQ,oBAAoB;AACvE,SACCC,WAAW,EACXC,YAAY,EACZC,cAAc,EACdC,mBAAmB,EACnBC,aAAa,EACbC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;;AAE9B;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAA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ACnBqB,KAAK,EAAG7B,EAAE,CAAE,iBAAkB,CAAG;MACjCgD,OAAO,EAAG,CAAE,GAAGZ,gBAAgB,EAAEM,YAAY,CAAI;MACjDO,KAAK,EACJL,QAAQ,GACLF,YAAY,IAAAT,qBAAA,GACZG,gBAAgB,CAACc,IAAI,CACnBH,MAAM,IAAMA,MAAM,CAACzB,MAAM,KAAKA,MAChC,CAAC,cAAAW,qBAAA,cAAAA,qBAAA,GAAIS,YACR;MACDlB,QAAQ,EAAGA,CAAE;QAAE2B;MAAa,CAAC,KAAM;QAClC,IAAKA,YAAY,KAAKT,YAAY,EAAG;UACpCG,WAAW,CAAE,IAAK,CAAC;QACpB,CAAC,MAAM;UACNA,WAAW,CAAE,KAAM,CAAC;UACpBrB,QAAQ,CAAE2B,YAAY,CAAC7B,MAAO,CAAC;QAChC;MACD;IAAG,CACH,CAAC,EACAsB,QAAQ,iBACT/B,IAAA,CAACR,WAAW;MACXuB,uBAAuB;MACvBC,KAAK,EAAG7B,EAAE,CAAE,eAAgB,CAAG;MAC/BoD,mBAAmB;MACnBtB,IAAI,EAAG1B,wBAAwB,CAC9BJ,EAAE,CACD,kDACD,CAAC,EACD;QACCqD,IAAI,eACHxC,IAAA,CAACP,YAAY;UACZgD,IAAI,EAAGtD,EAAE,CACR,6EACD;QAAG,CACH;MAEH,CACD,CAAG;MACHiD,KAAK,EAAG3B,MAAQ;MAChBE,QAAQ,EAAKyB,KAAK,IAAMzB,QAAQ,CAAEyB,KAAM;IAAG,CAC3C,CACD;EAAA,CACM,CAAC;AAEX","ignoreList":[]}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { ToolbarButton } from '@wordpress/components';
6
+ import { arrowLeft, arrowUp, arrowDown, arrowRight } from '@wordpress/icons';
7
+ import { useDispatch } from '@wordpress/data';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import BlockControls from '../block-controls';
13
+ import { useGetNumberOfBlocksBeforeCell } from './use-get-number-of-blocks-before-cell';
14
+ import { store as blockEditorStore } from '../../store';
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ export function GridItemMovers({
18
+ layout,
19
+ parentLayout,
20
+ onChange,
21
+ gridClientId,
22
+ blockClientId
23
+ }) {
24
+ var _layout$columnStart, _layout$rowStart, _layout$columnSpan, _layout$rowSpan;
25
+ const {
26
+ moveBlocksToPosition,
27
+ __unstableMarkNextChangeAsNotPersistent
28
+ } = useDispatch(blockEditorStore);
29
+ const columnStart = (_layout$columnStart = layout?.columnStart) !== null && _layout$columnStart !== void 0 ? _layout$columnStart : 1;
30
+ const rowStart = (_layout$rowStart = layout?.rowStart) !== null && _layout$rowStart !== void 0 ? _layout$rowStart : 1;
31
+ const columnSpan = (_layout$columnSpan = layout?.columnSpan) !== null && _layout$columnSpan !== void 0 ? _layout$columnSpan : 1;
32
+ const rowSpan = (_layout$rowSpan = layout?.rowSpan) !== null && _layout$rowSpan !== void 0 ? _layout$rowSpan : 1;
33
+ const columnEnd = columnStart + columnSpan - 1;
34
+ const rowEnd = rowStart + rowSpan - 1;
35
+ const columnCount = parentLayout?.columnCount;
36
+ const rowCount = parentLayout?.rowCount;
37
+ const columnCountNumber = parseInt(columnCount, 10);
38
+ const rowStartNumber = parseInt(rowStart, 10);
39
+ const columnStartNumber = parseInt(columnStart, 10);
40
+ const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(gridClientId, columnCountNumber);
41
+ return /*#__PURE__*/_jsxs(BlockControls, {
42
+ group: "parent",
43
+ children: [/*#__PURE__*/_jsx(ToolbarButton, {
44
+ icon: arrowUp,
45
+ label: __('Move block up'),
46
+ isDisabled: rowStart <= 1,
47
+ onClick: () => {
48
+ onChange({
49
+ rowStart: rowStart - 1
50
+ });
51
+ __unstableMarkNextChangeAsNotPersistent();
52
+ moveBlocksToPosition([blockClientId], gridClientId, gridClientId, getNumberOfBlocksBeforeCell(columnStartNumber, rowStartNumber - 1));
53
+ }
54
+ }), /*#__PURE__*/_jsx(ToolbarButton, {
55
+ icon: arrowDown,
56
+ label: __('Move block down'),
57
+ isDisabled: rowCount && rowEnd >= rowCount,
58
+ onClick: () => {
59
+ onChange({
60
+ rowStart: rowStart + 1
61
+ });
62
+ __unstableMarkNextChangeAsNotPersistent();
63
+ moveBlocksToPosition([blockClientId], gridClientId, gridClientId, getNumberOfBlocksBeforeCell(columnStartNumber, rowStartNumber + 1));
64
+ }
65
+ }), /*#__PURE__*/_jsx(ToolbarButton, {
66
+ icon: arrowLeft,
67
+ label: __('Move block left'),
68
+ isDisabled: columnStart <= 1,
69
+ onClick: () => {
70
+ onChange({
71
+ columnStart: columnStartNumber - 1
72
+ });
73
+ __unstableMarkNextChangeAsNotPersistent();
74
+ moveBlocksToPosition([blockClientId], gridClientId, gridClientId, getNumberOfBlocksBeforeCell(columnStartNumber - 1, rowStartNumber));
75
+ }
76
+ }), /*#__PURE__*/_jsx(ToolbarButton, {
77
+ icon: arrowRight,
78
+ label: __('Move block right'),
79
+ isDisabled: columnCount && columnEnd >= columnCount,
80
+ onClick: () => {
81
+ onChange({
82
+ columnStart: columnStartNumber + 1
83
+ });
84
+ __unstableMarkNextChangeAsNotPersistent();
85
+ moveBlocksToPosition([blockClientId], gridClientId, gridClientId, getNumberOfBlocksBeforeCell(columnStartNumber + 1, rowStartNumber));
86
+ }
87
+ })]
88
+ });
89
+ }
90
+ //# sourceMappingURL=grid-item-movers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","ToolbarButton","arrowLeft","arrowUp","arrowDown","arrowRight","useDispatch","BlockControls","useGetNumberOfBlocksBeforeCell","store","blockEditorStore","jsx","_jsx","jsxs","_jsxs","GridItemMovers","layout","parentLayout","onChange","gridClientId","blockClientId","_layout$columnStart","_layout$rowStart","_layout$columnSpan","_layout$rowSpan","moveBlocksToPosition","__unstableMarkNextChangeAsNotPersistent","columnStart","rowStart","columnSpan","rowSpan","columnEnd","rowEnd","columnCount","rowCount","columnCountNumber","parseInt","rowStartNumber","columnStartNumber","getNumberOfBlocksBeforeCell","group","children","icon","label","isDisabled","onClick"],"sources":["@wordpress/block-editor/src/components/grid/grid-item-movers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport { arrowLeft, arrowUp, arrowDown, arrowRight } from '@wordpress/icons';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockControls from '../block-controls';\nimport { useGetNumberOfBlocksBeforeCell } from './use-get-number-of-blocks-before-cell';\nimport { store as blockEditorStore } from '../../store';\n\nexport function GridItemMovers( {\n\tlayout,\n\tparentLayout,\n\tonChange,\n\tgridClientId,\n\tblockClientId,\n} ) {\n\tconst { moveBlocksToPosition, __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst columnStart = layout?.columnStart ?? 1;\n\tconst rowStart = layout?.rowStart ?? 1;\n\tconst columnSpan = layout?.columnSpan ?? 1;\n\tconst rowSpan = layout?.rowSpan ?? 1;\n\tconst columnEnd = columnStart + columnSpan - 1;\n\tconst rowEnd = rowStart + rowSpan - 1;\n\tconst columnCount = parentLayout?.columnCount;\n\tconst rowCount = parentLayout?.rowCount;\n\n\tconst columnCountNumber = parseInt( columnCount, 10 );\n\tconst rowStartNumber = parseInt( rowStart, 10 );\n\tconst columnStartNumber = parseInt( columnStart, 10 );\n\n\tconst getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(\n\t\tgridClientId,\n\t\tcolumnCountNumber\n\t);\n\n\treturn (\n\t\t<BlockControls group=\"parent\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ arrowUp }\n\t\t\t\tlabel={ __( 'Move block up' ) }\n\t\t\t\tisDisabled={ rowStart <= 1 }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\trowStart: rowStart - 1,\n\t\t\t\t\t} );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ blockClientId ],\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\tcolumnStartNumber,\n\t\t\t\t\t\t\trowStartNumber - 1\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ arrowDown }\n\t\t\t\tlabel={ __( 'Move block down' ) }\n\t\t\t\tisDisabled={ rowCount && rowEnd >= rowCount }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\trowStart: rowStart + 1,\n\t\t\t\t\t} );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ blockClientId ],\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\tcolumnStartNumber,\n\t\t\t\t\t\t\trowStartNumber + 1\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ arrowLeft }\n\t\t\t\tlabel={ __( 'Move block left' ) }\n\t\t\t\tisDisabled={ columnStart <= 1 }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tcolumnStart: columnStartNumber - 1,\n\t\t\t\t\t} );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ blockClientId ],\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\tcolumnStartNumber - 1,\n\t\t\t\t\t\t\trowStartNumber\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ arrowRight }\n\t\t\t\tlabel={ __( 'Move block right' ) }\n\t\t\t\tisDisabled={ columnCount && columnEnd >= columnCount }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tcolumnStart: columnStartNumber + 1,\n\t\t\t\t\t} );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\t\t[ blockClientId ],\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgridClientId,\n\t\t\t\t\t\tgetNumberOfBlocksBeforeCell(\n\t\t\t\t\t\t\tcolumnStartNumber + 1,\n\t\t\t\t\t\t\trowStartNumber\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,SAAS,EAAEC,OAAO,EAAEC,SAAS,EAAEC,UAAU,QAAQ,kBAAkB;AAC5E,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,8BAA8B,QAAQ,wCAAwC;AACvF,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAExD,OAAO,SAASC,cAAcA,CAAE;EAC/BC,MAAM;EACNC,YAAY;EACZC,QAAQ;EACRC,YAAY;EACZC;AACD,CAAC,EAAG;EAAA,IAAAC,mBAAA,EAAAC,gBAAA,EAAAC,kBAAA,EA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AAE,kBAAmB,CAAG;MAClC4C,UAAU,EAAGX,WAAW,IAAIF,SAAS,IAAIE,WAAa;MACtDY,OAAO,EAAGA,CAAA,KAAM;QACf3B,QAAQ,CAAE;UACTS,WAAW,EAAEW,iBAAiB,GAAG;QAClC,CAAE,CAAC;QACHZ,uCAAuC,CAAC,CAAC;QACzCD,oBAAoB,CACnB,CAAEL,aAAa,CAAE,EACjBD,YAAY,EACZA,YAAY,EACZoB,2BAA2B,CAC1BD,iBAAiB,GAAG,CAAC,EACrBD,cACD,CACD,CAAC;MACF;IAAG,CACH,CAAC;EAAA,CACY,CAAC;AAElB","ignoreList":[]}
@@ -9,15 +9,19 @@ import { useState, useEffect } from '@wordpress/element';
9
9
  */
10
10
  import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
11
11
  import BlockPopoverCover from '../block-popover/cover';
12
- import { getComputedCSS } from './utils';
12
+ import { getComputedCSS, getGridTracks, getClosestTrack } from './utils';
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  export function GridItemResizer({
15
15
  clientId,
16
16
  bounds,
17
- onChange
17
+ onChange,
18
+ parentLayout
18
19
  }) {
19
20
  const blockElement = useBlockElement(clientId);
20
21
  const rootBlockElement = blockElement?.parentElement;
22
+ const {
23
+ columnCount
24
+ } = parentLayout;
21
25
  if (!blockElement || !rootBlockElement) {
22
26
  return null;
23
27
  }
@@ -26,7 +30,8 @@ export function GridItemResizer({
26
30
  bounds: bounds,
27
31
  blockElement: blockElement,
28
32
  rootBlockElement: rootBlockElement,
29
- onChange: onChange
33
+ onChange: onChange,
34
+ isManualGrid: !!columnCount && window.__experimentalEnableGridInteractivity
30
35
  });
31
36
  }
32
37
  function GridItemResizerInner({
@@ -34,7 +39,8 @@ function GridItemResizerInner({
34
39
  bounds,
35
40
  blockElement,
36
41
  rootBlockElement,
37
- onChange
42
+ onChange,
43
+ isManualGrid
38
44
  }) {
39
45
  const [resizeDirection, setResizeDirection] = useState(null);
40
46
  const [enableSide, setEnableSide] = useState({
@@ -132,56 +138,12 @@ function GridItemResizerInner({
132
138
  const rowEnd = getClosestTrack(gridRowTracks, rect.bottom, 'end') + 1;
133
139
  onChange({
134
140
  columnSpan: columnEnd - columnStart + 1,
135
- rowSpan: rowEnd - rowStart + 1
141
+ rowSpan: rowEnd - rowStart + 1,
142
+ columnStart: isManualGrid ? columnStart : undefined,
143
+ rowStart: isManualGrid ? rowStart : undefined
136
144
  });
137
145
  }
138
146
  })
139
147
  });
140
148
  }
141
-
142
- /**
143
- * Given a grid-template-columns or grid-template-rows CSS property value, gets the start and end
144
- * position in pixels of each grid track.
145
- *
146
- * https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track
147
- *
148
- * @param {string} template The grid-template-columns or grid-template-rows CSS property value.
149
- * Only supports fixed sizes in pixels.
150
- * @param {number} gap The gap between grid tracks in pixels.
151
- *
152
- * @return {Array<{start: number, end: number}>} An array of objects with the start and end
153
- * position in pixels of each grid track.
154
- */
155
- function getGridTracks(template, gap) {
156
- const tracks = [];
157
- for (const size of template.split(' ')) {
158
- const previousTrack = tracks[tracks.length - 1];
159
- const start = previousTrack ? previousTrack.end + gap : 0;
160
- const end = start + parseFloat(size);
161
- tracks.push({
162
- start,
163
- end
164
- });
165
- }
166
- return tracks;
167
- }
168
-
169
- /**
170
- * Given an array of grid tracks and a position in pixels, gets the index of the closest track to
171
- * that position.
172
- *
173
- * https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track
174
- *
175
- * @param {Array<{start: number, end: number}>} tracks An array of objects with the start and end
176
- * position in pixels of each grid track.
177
- * @param {number} position The position in pixels.
178
- * @param {string} edge The edge of the track to compare the
179
- * position to. Either 'start' or 'end'.
180
- *
181
- * @return {number} The index of the closest track to the position. 0-based, unlike CSS grid which
182
- * is 1-based.
183
- */
184
- function getClosestTrack(tracks, position, edge = 'start') {
185
- return tracks.reduce((closest, track, index) => Math.abs(track[edge] - position) < Math.abs(tracks[closest][edge] - position) ? index : closest, 0);
186
- }
187
149
  //# sourceMappingURL=grid-item-resizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ResizableBox","useState","useEffect","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","getComputedCSS","getGridTracks","getClosestTrack","jsx","_jsx","GridItemResizer","clientId","bounds","onChange","parentLayout","blockElement","rootBlockElement","parentElement","columnCount","GridItemResizerInner","isManualGrid","window","__experimentalEnableGridInteractivity","resizeDirection","setResizeDirection","enableSide","setEnableSide","top","bottom","left","right","observer","ResizeObserver","blockClientRect","getBoundingClientRect","rootBlockClientRect","observe","disconnect","justification","alignment","styles","display","justifyContent","alignItems","className","__unstablePopoverSlot","additionalStyles","children","size","width","height","enable","bottomLeft","bottomRight","topLeft","topRight","boundsByDirection","onResizeStart","event","direction","ownerDocument","addEventListener","target","dispatchEvent","Event","bubbles","once","onResizeStop","boxElement","columnGap","parseFloat","rowGap","gridColumnTracks","gridRowTracks","rect","DOMRect","offsetLeft","offsetTop","offsetWidth","offsetHeight","columnStart","rowStart","columnEnd","rowEnd","columnSpan","rowSpan","undefined"],"sources":["@wordpress/block-editor/src/components/grid/grid-item-resizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { getComputedCSS, getGridTracks, getClosestTrack } from './utils';\n\nexport function GridItemResizer( {\n\tclientId,\n\tbounds,\n\tonChange,\n\tparentLayout,\n} ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst rootBlockElement = blockElement?.parentElement;\n\tconst { columnCount } = parentLayout;\n\n\tif ( ! blockElement || ! rootBlockElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GridItemResizerInner\n\t\t\tclientId={ clientId }\n\t\t\tbounds={ bounds }\n\t\t\tblockElement={ blockElement }\n\t\t\trootBlockElement={ rootBlockElement }\n\t\t\tonChange={ onChange }\n\t\t\tisManualGrid={\n\t\t\t\t!! columnCount && window.__experimentalEnableGridInteractivity\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction GridItemResizerInner( {\n\tclientId,\n\tbounds,\n\tblockElement,\n\trootBlockElement,\n\tonChange,\n\tisManualGrid,\n} ) {\n\tconst [ resizeDirection, setResizeDirection ] = useState( null );\n\tconst [ enableSide, setEnableSide ] = useState( {\n\t\ttop: false,\n\t\tbottom: false,\n\t\tleft: false,\n\t\tright: false,\n\t} );\n\n\tuseEffect( () => {\n\t\tconst observer = new window.ResizeObserver( () => {\n\t\t\tconst blockClientRect = blockElement.getBoundingClientRect();\n\t\t\tconst rootBlockClientRect =\n\t\t\t\trootBlockElement.getBoundingClientRect();\n\t\t\tsetEnableSide( {\n\t\t\t\ttop: blockClientRect.top > rootBlockClientRect.top,\n\t\t\t\tbottom: blockClientRect.bottom < rootBlockClientRect.bottom,\n\t\t\t\tleft: blockClientRect.left > rootBlockClientRect.left,\n\t\t\t\tright: blockClientRect.right < rootBlockClientRect.right,\n\t\t\t} );\n\t\t} );\n\t\tobserver.observe( blockElement );\n\t\treturn () => observer.disconnect();\n\t}, [ blockElement, rootBlockElement ] );\n\n\tconst justification = {\n\t\tright: 'flex-start',\n\t\tleft: 'flex-end',\n\t};\n\n\tconst alignment = {\n\t\ttop: 'flex-end',\n\t\tbottom: 'flex-start',\n\t};\n\n\tconst styles = {\n\t\tdisplay: 'flex',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\t...( justification[ resizeDirection ] && {\n\t\t\tjustifyContent: justification[ resizeDirection ],\n\t\t} ),\n\t\t...( alignment[ resizeDirection ] && {\n\t\t\talignItems: alignment[ resizeDirection ],\n\t\t} ),\n\t};\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclassName=\"block-editor-grid-item-resizer\"\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t\tadditionalStyles={ styles }\n\t\t>\n\t\t\t<ResizableBox\n\t\t\t\tclassName=\"block-editor-grid-item-resizer__box\"\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t} }\n\t\t\t\tenable={ {\n\t\t\t\t\tbottom: enableSide.bottom,\n\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\tbottomRight: false,\n\t\t\t\t\tleft: enableSide.left,\n\t\t\t\t\tright: enableSide.right,\n\t\t\t\t\ttop: enableSide.top,\n\t\t\t\t\ttopLeft: false,\n\t\t\t\t\ttopRight: false,\n\t\t\t\t} }\n\t\t\t\tbounds={ bounds }\n\t\t\t\tboundsByDirection\n\t\t\t\tonResizeStart={ ( event, direction ) => {\n\t\t\t\t\t/*\n\t\t\t\t\t * The container justification and alignment need to be set\n\t\t\t\t\t * according to the direction the resizer is being dragged in,\n\t\t\t\t\t * so that it resizes in the right direction.\n\t\t\t\t\t */\n\t\t\t\t\tsetResizeDirection( direction );\n\n\t\t\t\t\t/*\n\t\t\t\t\t * The mouseup event on the resize handle doesn't trigger if the mouse\n\t\t\t\t\t * isn't directly above the handle, so we try to detect if it happens\n\t\t\t\t\t * outside the grid and dispatch a mouseup event on the handle.\n\t\t\t\t\t */\n\t\t\t\t\tblockElement.ownerDocument.addEventListener(\n\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tevent.target.dispatchEvent(\n\t\t\t\t\t\t\t\tnew Event( 'mouseup', { bubbles: true } )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ once: true }\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, boxElement ) => {\n\t\t\t\t\tconst columnGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( rootBlockElement, 'column-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst rowGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( rootBlockElement, 'row-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst gridColumnTracks = getGridTracks(\n\t\t\t\t\t\tgetComputedCSS(\n\t\t\t\t\t\t\trootBlockElement,\n\t\t\t\t\t\t\t'grid-template-columns'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcolumnGap\n\t\t\t\t\t);\n\t\t\t\t\tconst gridRowTracks = getGridTracks(\n\t\t\t\t\t\tgetComputedCSS(\n\t\t\t\t\t\t\trootBlockElement,\n\t\t\t\t\t\t\t'grid-template-rows'\n\t\t\t\t\t\t),\n\t\t\t\t\t\trowGap\n\t\t\t\t\t);\n\t\t\t\t\tconst rect = new window.DOMRect(\n\t\t\t\t\t\tblockElement.offsetLeft + boxElement.offsetLeft,\n\t\t\t\t\t\tblockElement.offsetTop + boxElement.offsetTop,\n\t\t\t\t\t\tboxElement.offsetWidth,\n\t\t\t\t\t\tboxElement.offsetHeight\n\t\t\t\t\t);\n\t\t\t\t\tconst columnStart =\n\t\t\t\t\t\tgetClosestTrack( gridColumnTracks, rect.left ) + 1;\n\t\t\t\t\tconst rowStart =\n\t\t\t\t\t\tgetClosestTrack( gridRowTracks, rect.top ) + 1;\n\t\t\t\t\tconst columnEnd =\n\t\t\t\t\t\tgetClosestTrack( gridColumnTracks, rect.right, 'end' ) +\n\t\t\t\t\t\t1;\n\t\t\t\t\tconst rowEnd =\n\t\t\t\t\t\tgetClosestTrack( gridRowTracks, rect.bottom, 'end' ) +\n\t\t\t\t\t\t1;\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tcolumnSpan: columnEnd - columnStart + 1,\n\t\t\t\t\t\trowSpan: rowEnd - rowStart + 1,\n\t\t\t\t\t\tcolumnStart: isManualGrid ? columnStart : undefined,\n\t\t\t\t\t\trowStart: isManualGrid ? rowStart : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockPopoverCover>\n\t);\n}\n"],"mappings":"AAAA;AAC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,cAAc,CACbW,gBAAgB,EAChB,uBACD,CAAC,EACDqD,SACD,CAAC;QACD,MAAMI,aAAa,GAAGnE,aAAa,CAClCD,cAAc,CACbW,gBAAgB,EAChB,oBACD,CAAC,EACDuD,MACD,CAAC;QACD,MAAMG,IAAI,GAAG,IAAIrD,MAAM,CAACsD,OAAO,CAC9B5D,YAAY,CAAC6D,UAAU,GAAGR,UAAU,CAACQ,UAAU,EAC/C7D,YAAY,CAAC8D,SAAS,GAAGT,UAAU,CAACS,SAAS,EAC7CT,UAAU,CAACU,WAAW,EACtBV,UAAU,CAACW,YACZ,CAAC;QACD,MAAMC,WAAW,GAChBzE,eAAe,CAAEiE,gBAAgB,EAAEE,IAAI,CAAC7C,IAAK,CAAC,GAAG,CAAC;QACnD,MAAMoD,QAAQ,GACb1E,eAAe,CAAEkE,aAAa,EAAEC,IAAI,CAAC/C,GAAI,CAAC,GAAG,CAAC;QAC/C,MAAMuD,SAAS,GACd3E,eAAe,CAAEiE,gBAAgB,EAAEE,IAAI,CAAC5C,KAAK,EAAE,KAAM,CAAC,GACtD,CAAC;QACF,MAAMqD,MAAM,GACX5E,eAAe,CAAEkE,aAAa,EAAEC,IAAI,CAAC9C,MAAM,EAAE,KAAM,CAAC,GACpD,CAAC;QACFf,QAAQ,CAAE;UACTuE,UAAU,EAAEF,SAAS,GAAGF,WAAW,GAAG,CAAC;UACvCK,OAAO,EAAEF,MAAM,GAAGF,QAAQ,GAAG,CAAC;UAC9BD,WAAW,EAAE5D,YAAY,GAAG4D,WAAW,GAAGM,SAAS;UACnDL,QAAQ,EAAE7D,YAAY,GAAG6D,QAAQ,GAAGK;QACrC,CAAE,CAAC;MACJ;IAAG,CACH;EAAC,CACgB,CAAC;AAEtB","ignoreList":[]}
@@ -0,0 +1,217 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useState, useEffect, forwardRef } from '@wordpress/element';
10
+ import { useSelect, useDispatch } from '@wordpress/data';
11
+ import { __experimentalUseDropZone as useDropZone } from '@wordpress/compose';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
17
+ import BlockPopoverCover from '../block-popover/cover';
18
+ import { range, GridRect, getGridInfo } from './utils';
19
+ import { store as blockEditorStore } from '../../store';
20
+ import { useGetNumberOfBlocksBeforeCell } from './use-get-number-of-blocks-before-cell';
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ export function GridVisualizer({
23
+ clientId,
24
+ contentRef,
25
+ parentLayout
26
+ }) {
27
+ const isDistractionFree = useSelect(select => select(blockEditorStore).getSettings().isDistractionFree, []);
28
+ const gridElement = useBlockElement(clientId);
29
+ if (isDistractionFree || !gridElement) {
30
+ return null;
31
+ }
32
+ const isManualGrid = parentLayout?.columnCount && window.__experimentalEnableGridInteractivity;
33
+ return /*#__PURE__*/_jsx(GridVisualizerGrid, {
34
+ clientId: clientId,
35
+ gridElement: gridElement,
36
+ isManualGrid: isManualGrid,
37
+ ref: contentRef
38
+ });
39
+ }
40
+ const GridVisualizerGrid = forwardRef(({
41
+ clientId,
42
+ gridElement,
43
+ isManualGrid
44
+ }, ref) => {
45
+ const [gridInfo, setGridInfo] = useState(() => getGridInfo(gridElement));
46
+ const [isDroppingAllowed, setIsDroppingAllowed] = useState(false);
47
+ const [highlightedRect, setHighlightedRect] = useState(null);
48
+ useEffect(() => {
49
+ const observers = [];
50
+ for (const element of [gridElement, ...gridElement.children]) {
51
+ const observer = new window.ResizeObserver(() => {
52
+ setGridInfo(getGridInfo(gridElement));
53
+ });
54
+ observer.observe(element);
55
+ observers.push(observer);
56
+ }
57
+ return () => {
58
+ for (const observer of observers) {
59
+ observer.disconnect();
60
+ }
61
+ };
62
+ }, [gridElement]);
63
+ useEffect(() => {
64
+ function onGlobalDrag() {
65
+ setIsDroppingAllowed(true);
66
+ }
67
+ function onGlobalDragEnd() {
68
+ setIsDroppingAllowed(false);
69
+ }
70
+ document.addEventListener('drag', onGlobalDrag);
71
+ document.addEventListener('dragend', onGlobalDragEnd);
72
+ return () => {
73
+ document.removeEventListener('drag', onGlobalDrag);
74
+ document.removeEventListener('dragend', onGlobalDragEnd);
75
+ };
76
+ }, []);
77
+ return /*#__PURE__*/_jsx(BlockPopoverCover, {
78
+ className: clsx('block-editor-grid-visualizer', {
79
+ 'is-dropping-allowed': isDroppingAllowed
80
+ }),
81
+ clientId: clientId,
82
+ __unstablePopoverSlot: "block-toolbar",
83
+ children: /*#__PURE__*/_jsx("div", {
84
+ ref: ref,
85
+ className: "block-editor-grid-visualizer__grid",
86
+ style: gridInfo.style,
87
+ children: isManualGrid ? range(1, gridInfo.numRows).map(row => range(1, gridInfo.numColumns).map(column => /*#__PURE__*/_jsx(GridVisualizerCell, {
88
+ color: gridInfo.currentColor,
89
+ children: /*#__PURE__*/_jsx(GridVisualizerDropZone, {
90
+ column: column,
91
+ row: row,
92
+ gridClientId: clientId,
93
+ gridInfo: gridInfo,
94
+ highlightedRect: highlightedRect,
95
+ setHighlightedRect: setHighlightedRect
96
+ })
97
+ }, `${row}-${column}`))) : Array.from({
98
+ length: gridInfo.numItems
99
+ }, (_, i) => /*#__PURE__*/_jsx(GridVisualizerCell, {
100
+ color: gridInfo.currentColor
101
+ }, i))
102
+ })
103
+ });
104
+ });
105
+ function GridVisualizerCell({
106
+ color,
107
+ children
108
+ }) {
109
+ return /*#__PURE__*/_jsx("div", {
110
+ className: "block-editor-grid-visualizer__cell",
111
+ style: {
112
+ boxShadow: `inset 0 0 0 1px color-mix(in srgb, ${color} 20%, #0000)`
113
+ },
114
+ children: children
115
+ });
116
+ }
117
+ function GridVisualizerDropZone({
118
+ column,
119
+ row,
120
+ gridClientId,
121
+ gridInfo,
122
+ highlightedRect,
123
+ setHighlightedRect
124
+ }) {
125
+ var _highlightedRect$cont;
126
+ const {
127
+ getBlockAttributes
128
+ } = useSelect(blockEditorStore);
129
+ const {
130
+ updateBlockAttributes,
131
+ moveBlocksToPosition,
132
+ __unstableMarkNextChangeAsNotPersistent
133
+ } = useDispatch(blockEditorStore);
134
+ const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(gridClientId, gridInfo.numColumns);
135
+ const ref = useDropZoneWithValidation({
136
+ validateDrag(srcClientId) {
137
+ const attributes = getBlockAttributes(srcClientId);
138
+ const rect = new GridRect({
139
+ columnStart: column,
140
+ rowStart: row,
141
+ columnSpan: attributes.style?.layout?.columnSpan,
142
+ rowSpan: attributes.style?.layout?.rowSpan
143
+ });
144
+ const isInBounds = new GridRect({
145
+ columnSpan: gridInfo.numColumns,
146
+ rowSpan: gridInfo.numRows
147
+ }).containsRect(rect);
148
+ return isInBounds;
149
+ },
150
+ onDragEnter(srcClientId) {
151
+ const attributes = getBlockAttributes(srcClientId);
152
+ setHighlightedRect(new GridRect({
153
+ columnStart: column,
154
+ rowStart: row,
155
+ columnSpan: attributes.style?.layout?.columnSpan,
156
+ rowSpan: attributes.style?.layout?.rowSpan
157
+ }));
158
+ },
159
+ onDragLeave() {
160
+ // onDragEnter can be called before onDragLeave if the user moves
161
+ // their mouse quickly, so only clear the highlight if it was set
162
+ // by this cell.
163
+ setHighlightedRect(prevHighlightedRect => prevHighlightedRect?.columnStart === column && prevHighlightedRect?.rowStart === row ? null : prevHighlightedRect);
164
+ },
165
+ onDrop(srcClientId) {
166
+ setHighlightedRect(null);
167
+ const attributes = getBlockAttributes(srcClientId);
168
+ updateBlockAttributes(srcClientId, {
169
+ style: {
170
+ ...attributes.style,
171
+ layout: {
172
+ ...attributes.style?.layout,
173
+ columnStart: column,
174
+ rowStart: row
175
+ }
176
+ }
177
+ });
178
+ __unstableMarkNextChangeAsNotPersistent();
179
+ moveBlocksToPosition([srcClientId], gridClientId, gridClientId, getNumberOfBlocksBeforeCell(column, row));
180
+ }
181
+ });
182
+ const isHighlighted = (_highlightedRect$cont = highlightedRect?.contains(column, row)) !== null && _highlightedRect$cont !== void 0 ? _highlightedRect$cont : false;
183
+ return /*#__PURE__*/_jsx("div", {
184
+ ref: ref,
185
+ className: clsx('block-editor-grid-visualizer__drop-zone', {
186
+ 'is-highlighted': isHighlighted
187
+ })
188
+ });
189
+ }
190
+ function useDropZoneWithValidation({
191
+ validateDrag,
192
+ onDragEnter,
193
+ onDragLeave,
194
+ onDrop
195
+ }) {
196
+ const {
197
+ getDraggedBlockClientIds
198
+ } = useSelect(blockEditorStore);
199
+ return useDropZone({
200
+ onDragEnter() {
201
+ const [srcClientId] = getDraggedBlockClientIds();
202
+ if (srcClientId && validateDrag(srcClientId)) {
203
+ onDragEnter(srcClientId);
204
+ }
205
+ },
206
+ onDragLeave() {
207
+ onDragLeave();
208
+ },
209
+ onDrop() {
210
+ const [srcClientId] = getDraggedBlockClientIds();
211
+ if (srcClientId && validateDrag(srcClientId)) {
212
+ onDrop(srcClientId);
213
+ }
214
+ }
215
+ });
216
+ }
217
+ //# sourceMappingURL=grid-visualizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["clsx","useState","useEffect","forwardRef","useSelect","useDispatch","__experimentalUseDropZone","useDropZone","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","range","GridRect","getGridInfo","store","blockEditorStore","useGetNumberOfBlocksBeforeCell","jsx","_jsx","GridVisualizer","clientId","contentRef","parentLayout","isDistractionFree","select","getSettings","gridElement","isManualGrid","columnCount","window","__experimentalEnableGridInteractivity","GridVisualizerGrid","ref","gridInfo","setGridInfo","isDroppingAllowed","setIsDroppingAllowed","highlightedRect","setHighlightedRect","observers","element","children","observer","ResizeObserver","observe","push","disconnect","onGlobalDrag","onGlobalDragEnd","document","addEventListener","removeEventListener","className","__unstablePopoverSlot","style","numRows","map","row","numColumns","column","GridVisualizerCell","color","currentColor","GridVisualizerDropZone","gridClientId","Array","from","length","numItems","_","i","boxShadow","_highlightedRect$cont","getBlockAttributes","updateBlockAttributes","moveBlocksToPosition","__unstableMarkNextChangeAsNotPersistent","getNumberOfBlocksBeforeCell","useDropZoneWithValidation","validateDrag","srcClientId","attributes","rect","columnStart","rowStart","columnSpan","layout","rowSpan","isInBounds","containsRect","onDragEnter","onDragLeave","prevHighlightedRect","onDrop","isHighlighted","contains","getDraggedBlockClientIds"],"sources":["@wordpress/block-editor/src/components/grid/grid-visualizer.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, forwardRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __experimentalUseDropZone as useDropZone } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { range, GridRect, getGridInfo } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport { useGetNumberOfBlocksBeforeCell } from './use-get-number-of-blocks-before-cell';\n\nexport function GridVisualizer( { clientId, contentRef, parentLayout } ) {\n\tconst isDistractionFree = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().isDistractionFree,\n\t\t[]\n\t);\n\tconst gridElement = useBlockElement( clientId );\n\n\tif ( isDistractionFree || ! gridElement ) {\n\t\treturn null;\n\t}\n\n\tconst isManualGrid =\n\t\tparentLayout?.columnCount &&\n\t\twindow.__experimentalEnableGridInteractivity;\n\treturn (\n\t\t<GridVisualizerGrid\n\t\t\tclientId={ clientId }\n\t\t\tgridElement={ gridElement }\n\t\t\tisManualGrid={ isManualGrid }\n\t\t\tref={ contentRef }\n\t\t/>\n\t);\n}\n\nconst GridVisualizerGrid = forwardRef(\n\t( { clientId, gridElement, isManualGrid }, ref ) => {\n\t\tconst [ gridInfo, setGridInfo ] = useState( () =>\n\t\t\tgetGridInfo( gridElement )\n\t\t);\n\t\tconst [ isDroppingAllowed, setIsDroppingAllowed ] = useState( false );\n\t\tconst [ highlightedRect, setHighlightedRect ] = useState( null );\n\n\t\tuseEffect( () => {\n\t\t\tconst observers = [];\n\t\t\tfor ( const element of [ gridElement, ...gridElement.children ] ) {\n\t\t\t\tconst observer = new window.ResizeObserver( () => {\n\t\t\t\t\tsetGridInfo( getGridInfo( gridElement ) );\n\t\t\t\t} );\n\t\t\t\tobserver.observe( element );\n\t\t\t\tobservers.push( observer );\n\t\t\t}\n\t\t\treturn () => {\n\t\t\t\tfor ( const observer of observers ) {\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t};\n\t\t}, [ gridElement ] );\n\n\t\tuseEffect( () => {\n\t\t\tfunction onGlobalDrag() {\n\t\t\t\tsetIsDroppingAllowed( true );\n\t\t\t}\n\t\t\tfunction onGlobalDragEnd() {\n\t\t\t\tsetIsDroppingAllowed( false );\n\t\t\t}\n\t\t\tdocument.addEventListener( 'drag', onGlobalDrag );\n\t\t\tdocument.addEventListener( 'dragend', onGlobalDragEnd );\n\t\t\treturn () => {\n\t\t\t\tdocument.removeEventListener( 'drag', onGlobalDrag );\n\t\t\t\tdocument.removeEventListener( 'dragend', onGlobalDragEnd );\n\t\t\t};\n\t\t}, [] );\n\n\t\treturn (\n\t\t\t<BlockPopoverCover\n\t\t\t\tclassName={ clsx( 'block-editor-grid-visualizer', {\n\t\t\t\t\t'is-dropping-allowed': isDroppingAllowed,\n\t\t\t\t} ) }\n\t\t\t\tclientId={ clientId }\n\t\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t\t>\n\t\t\t\t<div\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tclassName=\"block-editor-grid-visualizer__grid\"\n\t\t\t\t\tstyle={ gridInfo.style }\n\t\t\t\t>\n\t\t\t\t\t{ isManualGrid\n\t\t\t\t\t\t? range( 1, gridInfo.numRows ).map( ( row ) =>\n\t\t\t\t\t\t\t\trange( 1, gridInfo.numColumns ).map(\n\t\t\t\t\t\t\t\t\t( column ) => (\n\t\t\t\t\t\t\t\t\t\t<GridVisualizerCell\n\t\t\t\t\t\t\t\t\t\t\tkey={ `${ row }-${ column }` }\n\t\t\t\t\t\t\t\t\t\t\tcolor={ gridInfo.currentColor }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t<GridVisualizerDropZone\n\t\t\t\t\t\t\t\t\t\t\t\tcolumn={ column }\n\t\t\t\t\t\t\t\t\t\t\t\trow={ row }\n\t\t\t\t\t\t\t\t\t\t\t\tgridClientId={ clientId }\n\t\t\t\t\t\t\t\t\t\t\t\tgridInfo={ gridInfo }\n\t\t\t\t\t\t\t\t\t\t\t\thighlightedRect={\n\t\t\t\t\t\t\t\t\t\t\t\t\thighlightedRect\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\tsetHighlightedRect={\n\t\t\t\t\t\t\t\t\t\t\t\t\tsetHighlightedRect\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</GridVisualizerCell>\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: Array.from(\n\t\t\t\t\t\t\t\t{ length: gridInfo.numItems },\n\t\t\t\t\t\t\t\t( _, i ) => (\n\t\t\t\t\t\t\t\t\t<GridVisualizerCell\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tcolor={ gridInfo.currentColor }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t ) }\n\t\t\t\t</div>\n\t\t\t</BlockPopoverCover>\n\t\t);\n\t}\n);\n\nfunction GridVisualizerCell( { color, children } ) {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-grid-visualizer__cell\"\n\t\t\tstyle={ {\n\t\t\t\tboxShadow: `inset 0 0 0 1px color-mix(in srgb, ${ color } 20%, #0000)`,\n\t\t\t} }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nfunction GridVisualizerDropZone( {\n\tcolumn,\n\trow,\n\tgridClientId,\n\tgridInfo,\n\thighlightedRect,\n\tsetHighlightedRect,\n} ) {\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst {\n\t\tupdateBlockAttributes,\n\t\tmoveBlocksToPosition,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\n\tconst getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell(\n\t\tgridClientId,\n\t\tgridInfo.numColumns\n\t);\n\n\tconst ref = useDropZoneWithValidation( {\n\t\tvalidateDrag( srcClientId ) {\n\t\t\tconst attributes = getBlockAttributes( srcClientId );\n\t\t\tconst rect = new GridRect( {\n\t\t\t\tcolumnStart: column,\n\t\t\t\trowStart: row,\n\t\t\t\tcolumnSpan: attributes.style?.layout?.columnSpan,\n\t\t\t\trowSpan: attributes.style?.layout?.rowSpan,\n\t\t\t} );\n\t\t\tconst isInBounds = new GridRect( {\n\t\t\t\tcolumnSpan: gridInfo.numColumns,\n\t\t\t\trowSpan: gridInfo.numRows,\n\t\t\t} ).containsRect( rect );\n\t\t\treturn isInBounds;\n\t\t},\n\t\tonDragEnter( srcClientId ) {\n\t\t\tconst attributes = getBlockAttributes( srcClientId );\n\t\t\tsetHighlightedRect(\n\t\t\t\tnew GridRect( {\n\t\t\t\t\tcolumnStart: column,\n\t\t\t\t\trowStart: row,\n\t\t\t\t\tcolumnSpan: attributes.style?.layout?.columnSpan,\n\t\t\t\t\trowSpan: attributes.style?.layout?.rowSpan,\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\tonDragLeave() {\n\t\t\t// onDragEnter can be called before onDragLeave if the user moves\n\t\t\t// their mouse quickly, so only clear the highlight if it was set\n\t\t\t// by this cell.\n\t\t\tsetHighlightedRect( ( prevHighlightedRect ) =>\n\t\t\t\tprevHighlightedRect?.columnStart === column &&\n\t\t\t\tprevHighlightedRect?.rowStart === row\n\t\t\t\t\t? null\n\t\t\t\t\t: prevHighlightedRect\n\t\t\t);\n\t\t},\n\t\tonDrop( srcClientId ) {\n\t\t\tsetHighlightedRect( null );\n\t\t\tconst attributes = getBlockAttributes( srcClientId );\n\t\t\tupdateBlockAttributes( srcClientId, {\n\t\t\t\tstyle: {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...attributes.style?.layout,\n\t\t\t\t\t\tcolumnStart: column,\n\t\t\t\t\t\trowStart: row,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tmoveBlocksToPosition(\n\t\t\t\t[ srcClientId ],\n\t\t\t\tgridClientId,\n\t\t\t\tgridClientId,\n\t\t\t\tgetNumberOfBlocksBeforeCell( column, row )\n\t\t\t);\n\t\t},\n\t} );\n\n\tconst isHighlighted = highlightedRect?.contains( column, row ) ?? false;\n\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName={ clsx( 'block-editor-grid-visualizer__drop-zone', {\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t} ) }\n\t\t/>\n\t);\n}\n\nfunction useDropZoneWithValidation( {\n\tvalidateDrag,\n\tonDragEnter,\n\tonDragLeave,\n\tonDrop,\n} ) {\n\tconst { getDraggedBlockClientIds } = useSelect( blockEditorStore );\n\treturn useDropZone( {\n\t\tonDragEnter() {\n\t\t\tconst [ srcClientId ] = getDraggedBlockClientIds();\n\t\t\tif ( srcClientId && validateDrag( srcClientId ) ) {\n\t\t\t\tonDragEnter( srcClientId );\n\t\t\t}\n\t\t},\n\t\tonDragLeave() {\n\t\t\tonDragLeave();\n\t\t},\n\t\tonDrop() {\n\t\t\tconst [ srcClientId ] = getDraggedBlockClientIds();\n\t\t\tif ( srcClientId && validateDrag( srcClientId ) ) {\n\t\t\t\tonDrop( srcClientId );\n\t\t\t}\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA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AC;AAEJ;AAEA,SAAShB,yBAAyBA,CAAE;EACnCC,YAAY;EACZW,WAAW;EACXC,WAAW;EACXE;AACD,CAAC,EAAG;EACH,MAAM;IAAEG;EAAyB,CAAC,GAAG5F,SAAS,CAAEW,gBAAiB,CAAC;EAClE,OAAOR,WAAW,CAAE;IACnBmF,WAAWA,CAAA,EAAG;MACb,MAAM,CAAEV,WAAW,CAAE,GAAGgB,wBAAwB,CAAC,CAAC;MAClD,IAAKhB,WAAW,IAAID,YAAY,CAAEC,WAAY,CAAC,EAAG;QACjDU,WAAW,CAAEV,WAAY,CAAC;MAC3B;IACD,CAAC;IACDW,WAAWA,CAAA,EAAG;MACbA,WAAW,CAAC,CAAC;IACd,CAAC;IACDE,MAAMA,CAAA,EAAG;MACR,MAAM,CAAEb,WAAW,CAAE,GAAGgB,wBAAwB,CAAC,CAAC;MAClD,IAAKhB,WAAW,IAAID,YAAY,CAAEC,WAAY,CAAC,EAAG;QACjDa,MAAM,CAAEb,WAAY,CAAC;MACtB;IACD;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ export { GridVisualizer } from './grid-visualizer';
2
+ export { GridItemResizer } from './grid-item-resizer';
3
+ export { GridItemMovers } from './grid-item-movers';
4
+ export { useGridLayoutSync } from './use-grid-layout-sync';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["GridVisualizer","GridItemResizer","GridItemMovers","useGridLayoutSync"],"sources":["@wordpress/block-editor/src/components/grid/index.js"],"sourcesContent":["export { GridVisualizer } from './grid-visualizer';\nexport { GridItemResizer } from './grid-item-resizer';\nexport { GridItemMovers } from './grid-item-movers';\nexport { useGridLayoutSync } from './use-grid-layout-sync';\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,mBAAmB;AAClD,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,iBAAiB,QAAQ,wBAAwB","ignoreList":[]}