@wordpress/block-library 7.0.1 → 7.0.2

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 (230) hide show
  1. package/README.md +16 -0
  2. package/build/button/edit.native.js +2 -2
  3. package/build/button/edit.native.js.map +1 -1
  4. package/build/columns/index.js +12 -0
  5. package/build/columns/index.js.map +1 -1
  6. package/build/comment-author-avatar/edit.js +17 -4
  7. package/build/comment-author-avatar/edit.js.map +1 -1
  8. package/build/comment-template/edit.js +94 -36
  9. package/build/comment-template/edit.js.map +1 -1
  10. package/build/comment-template/hooks.js +175 -0
  11. package/build/comment-template/hooks.js.map +1 -0
  12. package/build/comment-template/index.js +1 -1
  13. package/build/comment-template/util.js.map +1 -1
  14. package/build/comments-pagination-next/index.js +1 -1
  15. package/build/comments-pagination-numbers/index.js +1 -1
  16. package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  17. package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -19
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-query-loop/index.js +5 -0
  21. package/build/comments-query-loop/index.js.map +1 -1
  22. package/build/cover/edit.js +21 -22
  23. package/build/cover/edit.js.map +1 -1
  24. package/build/cover/edit.native.js +7 -5
  25. package/build/cover/edit.native.js.map +1 -1
  26. package/build/cover/overlay-color-settings.native.js +4 -3
  27. package/build/cover/overlay-color-settings.native.js.map +1 -1
  28. package/build/cover/transforms.js +4 -2
  29. package/build/cover/transforms.js.map +1 -1
  30. package/build/group/index.js +1 -0
  31. package/build/group/index.js.map +1 -1
  32. package/build/heading/edit.js +14 -2
  33. package/build/heading/edit.js.map +1 -1
  34. package/build/image/deprecated.js +89 -5
  35. package/build/image/deprecated.js.map +1 -1
  36. package/build/image/save.js +0 -7
  37. package/build/image/save.js.map +1 -1
  38. package/build/latest-posts/edit.js +1 -0
  39. package/build/latest-posts/edit.js.map +1 -1
  40. package/build/navigation/edit/index.js +17 -15
  41. package/build/navigation/edit/index.js.map +1 -1
  42. package/build/navigation/edit/navigation-menu-selector.js +44 -27
  43. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  44. package/build/navigation/edit/placeholder/index.js +8 -22
  45. package/build/navigation/edit/placeholder/index.js.map +1 -1
  46. package/build/navigation/use-navigation-menu.js +6 -6
  47. package/build/navigation/use-navigation-menu.js.map +1 -1
  48. package/build/navigation-submenu/edit.js +41 -9
  49. package/build/navigation-submenu/edit.js.map +1 -1
  50. package/build/page-list/edit.js +11 -17
  51. package/build/page-list/edit.js.map +1 -1
  52. package/build/social-links/deprecated.js +1 -62
  53. package/build/social-links/deprecated.js.map +1 -1
  54. package/build/template-part/edit/index.js +36 -64
  55. package/build/template-part/edit/index.js.map +1 -1
  56. package/build/template-part/edit/placeholder.js +64 -0
  57. package/build/template-part/edit/placeholder.js.map +1 -0
  58. package/build/template-part/edit/selection-modal.js +103 -0
  59. package/build/template-part/edit/selection-modal.js.map +1 -0
  60. package/build/template-part/edit/title-modal.js +54 -0
  61. package/build/template-part/edit/title-modal.js.map +1 -0
  62. package/build/template-part/edit/utils/hooks.js +156 -0
  63. package/build/template-part/edit/utils/hooks.js.map +1 -0
  64. package/build/template-part/index.js +3 -1
  65. package/build/template-part/index.js.map +1 -1
  66. package/build-module/button/edit.native.js +4 -4
  67. package/build-module/button/edit.native.js.map +1 -1
  68. package/build-module/columns/index.js +12 -0
  69. package/build-module/columns/index.js.map +1 -1
  70. package/build-module/comment-author-avatar/edit.js +18 -6
  71. package/build-module/comment-author-avatar/edit.js.map +1 -1
  72. package/build-module/comment-template/edit.js +95 -37
  73. package/build-module/comment-template/edit.js.map +1 -1
  74. package/build-module/comment-template/hooks.js +156 -0
  75. package/build-module/comment-template/hooks.js.map +1 -0
  76. package/build-module/comment-template/index.js +1 -1
  77. package/build-module/comment-template/util.js.map +1 -1
  78. package/build-module/comments-pagination-next/index.js +1 -1
  79. package/build-module/comments-pagination-numbers/index.js +1 -1
  80. package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
  81. package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
  82. package/build-module/comments-query-loop/edit.js +2 -19
  83. package/build-module/comments-query-loop/edit.js.map +1 -1
  84. package/build-module/comments-query-loop/index.js +5 -0
  85. package/build-module/comments-query-loop/index.js.map +1 -1
  86. package/build-module/cover/edit.js +23 -24
  87. package/build-module/cover/edit.js.map +1 -1
  88. package/build-module/cover/edit.native.js +10 -8
  89. package/build-module/cover/edit.native.js.map +1 -1
  90. package/build-module/cover/overlay-color-settings.native.js +4 -4
  91. package/build-module/cover/overlay-color-settings.native.js.map +1 -1
  92. package/build-module/cover/transforms.js +4 -2
  93. package/build-module/cover/transforms.js.map +1 -1
  94. package/build-module/group/index.js +1 -0
  95. package/build-module/group/index.js.map +1 -1
  96. package/build-module/heading/edit.js +15 -3
  97. package/build-module/heading/edit.js.map +1 -1
  98. package/build-module/image/deprecated.js +90 -7
  99. package/build-module/image/deprecated.js.map +1 -1
  100. package/build-module/image/save.js +0 -7
  101. package/build-module/image/save.js.map +1 -1
  102. package/build-module/latest-posts/edit.js +1 -0
  103. package/build-module/latest-posts/edit.js.map +1 -1
  104. package/build-module/navigation/edit/index.js +17 -15
  105. package/build-module/navigation/edit/index.js.map +1 -1
  106. package/build-module/navigation/edit/navigation-menu-selector.js +45 -27
  107. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  108. package/build-module/navigation/edit/placeholder/index.js +8 -21
  109. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  110. package/build-module/navigation/use-navigation-menu.js +6 -6
  111. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  112. package/build-module/navigation-submenu/edit.js +41 -10
  113. package/build-module/navigation-submenu/edit.js.map +1 -1
  114. package/build-module/page-list/edit.js +12 -18
  115. package/build-module/page-list/edit.js.map +1 -1
  116. package/build-module/social-links/deprecated.js +1 -62
  117. package/build-module/social-links/deprecated.js.map +1 -1
  118. package/build-module/template-part/edit/index.js +37 -65
  119. package/build-module/template-part/edit/index.js.map +1 -1
  120. package/build-module/template-part/edit/placeholder.js +52 -0
  121. package/build-module/template-part/edit/placeholder.js.map +1 -0
  122. package/build-module/template-part/edit/selection-modal.js +89 -0
  123. package/build-module/template-part/edit/selection-modal.js.map +1 -0
  124. package/build-module/template-part/edit/title-modal.js +46 -0
  125. package/build-module/template-part/edit/title-modal.js.map +1 -0
  126. package/build-module/template-part/edit/utils/hooks.js +135 -0
  127. package/build-module/template-part/edit/utils/hooks.js.map +1 -0
  128. package/build-module/template-part/index.js +2 -1
  129. package/build-module/template-part/index.js.map +1 -1
  130. package/build-style/comment-author-avatar/editor-rtl.css +83 -0
  131. package/build-style/comment-author-avatar/editor.css +83 -0
  132. package/build-style/cover/style-rtl.css +4 -0
  133. package/build-style/cover/style.css +4 -0
  134. package/build-style/editor-rtl.css +27 -81
  135. package/build-style/editor.css +27 -81
  136. package/build-style/image/editor-rtl.css +0 -16
  137. package/build-style/image/editor.css +0 -16
  138. package/build-style/image/style-rtl.css +2 -0
  139. package/build-style/image/style.css +2 -0
  140. package/build-style/navigation/style-rtl.css +14 -3
  141. package/build-style/navigation/style.css +14 -3
  142. package/build-style/page-list/editor-rtl.css +0 -9
  143. package/build-style/page-list/editor.css +0 -9
  144. package/build-style/style-rtl.css +20 -3
  145. package/build-style/style.css +20 -3
  146. package/build-style/template-part/editor-rtl.css +19 -56
  147. package/build-style/template-part/editor.css +19 -56
  148. package/package.json +15 -15
  149. package/src/archives/index.php +1 -1
  150. package/src/button/edit.native.js +3 -3
  151. package/src/columns/block.json +12 -0
  152. package/src/comment-author-avatar/edit.js +13 -8
  153. package/src/comment-author-avatar/editor.scss +7 -0
  154. package/src/comment-template/block.json +7 -1
  155. package/src/comment-template/edit.js +102 -40
  156. package/src/comment-template/hooks.js +151 -0
  157. package/src/comment-template/index.php +8 -0
  158. package/src/comment-template/util.js +1 -0
  159. package/src/comments-pagination-next/block.json +8 -1
  160. package/src/comments-pagination-next/index.php +6 -8
  161. package/src/comments-pagination-numbers/block.json +7 -1
  162. package/src/comments-pagination-numbers/index.php +3 -10
  163. package/src/comments-query-loop/block.json +5 -0
  164. package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
  165. package/src/comments-query-loop/edit.js +1 -16
  166. package/src/cover/edit.js +15 -28
  167. package/src/cover/edit.native.js +15 -7
  168. package/src/cover/overlay-color-settings.native.js +3 -4
  169. package/src/cover/style.scss +4 -0
  170. package/src/cover/transforms.js +2 -0
  171. package/src/editor.scss +1 -0
  172. package/src/gallery/index.php +1 -8
  173. package/src/group/block.json +1 -0
  174. package/src/heading/edit.js +18 -5
  175. package/src/home-link/index.php +1 -19
  176. package/src/image/deprecated.js +105 -1
  177. package/src/image/editor.scss +0 -18
  178. package/src/image/save.js +0 -8
  179. package/src/image/style.scss +3 -0
  180. package/src/image/test/edit.native.js +0 -10
  181. package/src/latest-posts/edit.js +1 -0
  182. package/src/latest-posts/index.php +1 -1
  183. package/src/navigation/edit/index.js +25 -26
  184. package/src/navigation/edit/navigation-menu-selector.js +73 -28
  185. package/src/navigation/edit/placeholder/index.js +8 -32
  186. package/src/navigation/index.php +4 -4
  187. package/src/navigation/style.scss +22 -3
  188. package/src/navigation/use-navigation-menu.js +6 -6
  189. package/src/navigation-link/index.php +3 -22
  190. package/src/navigation-submenu/edit.js +50 -12
  191. package/src/navigation-submenu/index.php +3 -21
  192. package/src/page-list/edit.js +21 -25
  193. package/src/page-list/editor.scss +0 -10
  194. package/src/page-list/index.php +4 -4
  195. package/src/post-navigation-link/index.php +3 -3
  196. package/src/search/index.php +6 -3
  197. package/src/site-logo/index.php +1 -1
  198. package/src/social-links/deprecated.js +0 -59
  199. package/src/template-part/edit/index.js +61 -71
  200. package/src/template-part/edit/placeholder.js +78 -0
  201. package/src/template-part/edit/selection-modal.js +115 -0
  202. package/src/template-part/edit/title-modal.js +59 -0
  203. package/src/template-part/edit/utils/hooks.js +158 -0
  204. package/src/template-part/editor.scss +16 -74
  205. package/src/template-part/index.js +4 -1
  206. package/build/navigation/edit/existing-menus-options.js +0 -62
  207. package/build/navigation/edit/existing-menus-options.js.map +0 -1
  208. package/build/template-part/edit/placeholder/index.js +0 -141
  209. package/build/template-part/edit/placeholder/index.js.map +0 -1
  210. package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
  211. package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  212. package/build/template-part/edit/selection/index.js +0 -45
  213. package/build/template-part/edit/selection/index.js.map +0 -1
  214. package/build/template-part/edit/selection/template-part-previews.js +0 -317
  215. package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
  216. package/build-module/navigation/edit/existing-menus-options.js +0 -53
  217. package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
  218. package/build-module/template-part/edit/placeholder/index.js +0 -124
  219. package/build-module/template-part/edit/placeholder/index.js.map +0 -1
  220. package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
  221. package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
  222. package/build-module/template-part/edit/selection/index.js +0 -35
  223. package/build-module/template-part/edit/selection/index.js.map +0 -1
  224. package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
  225. package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
  226. package/src/navigation/edit/existing-menus-options.js +0 -70
  227. package/src/template-part/edit/placeholder/index.js +0 -172
  228. package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
  229. package/src/template-part/edit/selection/index.js +0 -37
  230. package/src/template-part/edit/selection/template-part-previews.js +0 -372
@@ -23,7 +23,7 @@ var _coreData = require("@wordpress/core-data");
23
23
 
24
24
  var _placeholder = _interopRequireDefault(require("./placeholder"));
25
25
 
26
- var _selection = _interopRequireDefault(require("./selection"));
26
+ var _selectionModal = _interopRequireDefault(require("./selection-modal"));
27
27
 
28
28
  var _advancedControls = require("./advanced-controls");
29
29
 
@@ -31,6 +31,8 @@ var _innerBlocks = _interopRequireDefault(require("./inner-blocks"));
31
31
 
32
32
  var _createTemplatePartId = require("./utils/create-template-part-id");
33
33
 
34
+ var _hooks = require("./utils/hooks");
35
+
34
36
  /**
35
37
  * External dependencies
36
38
  */
@@ -55,7 +57,8 @@ function TemplatePartEdit(_ref) {
55
57
  layout = {}
56
58
  } = attributes;
57
59
  const templatePartId = (0, _createTemplatePartId.createTemplatePartId)(theme, slug);
58
- const [hasAlreadyRendered, RecursionProvider] = (0, _blockEditor.__experimentalUseNoRecursiveRenders)(templatePartId); // Set the postId block attribute if it did not exist,
60
+ const [hasAlreadyRendered, RecursionProvider] = (0, _blockEditor.__experimentalUseNoRecursiveRenders)(templatePartId);
61
+ const [isTemplatePartSelectionOpen, setIsTemplatePartSelectionOpen] = (0, _element.useState)(false); // Set the postId block attribute if it did not exist,
59
62
  // but wait until the inner blocks have loaded to allow
60
63
  // new edits to trigger this.
61
64
 
@@ -63,16 +66,10 @@ function TemplatePartEdit(_ref) {
63
66
  isResolved,
64
67
  innerBlocks,
65
68
  isMissing,
66
- defaultWrapper,
67
- area,
68
- enableSelection,
69
- hasResolvedReplacements
69
+ area
70
70
  } = (0, _data.useSelect)(select => {
71
- var _select$__experimenta;
72
-
73
71
  const {
74
72
  getEditedEntityRecord,
75
- getEntityRecords,
76
73
  hasFinishedResolution
77
74
  } = select(_coreData.store);
78
75
  const {
@@ -81,40 +78,26 @@ function TemplatePartEdit(_ref) {
81
78
  const getEntityArgs = ['postType', 'wp_template_part', templatePartId];
82
79
  const entityRecord = templatePartId ? getEditedEntityRecord(...getEntityArgs) : null;
83
80
 
84
- const _area = (entityRecord === null || entityRecord === void 0 ? void 0 : entityRecord.area) || attributes.area; // Check whether other entities exist for switching/selection.
85
-
86
-
87
- const availableReplacementArgs = ['postType', 'wp_template_part', _area && 'uncategorized' !== _area && {
88
- area: _area
89
- }];
90
- const matchingReplacements = getEntityRecords(...availableReplacementArgs);
91
-
92
- const _enableSelection = templatePartId ? (matchingReplacements === null || matchingReplacements === void 0 ? void 0 : matchingReplacements.length) > 1 : (matchingReplacements === null || matchingReplacements === void 0 ? void 0 : matchingReplacements.length) > 0;
93
-
94
- const hasResolvedEntity = templatePartId ? hasFinishedResolution('getEditedEntityRecord', getEntityArgs) : false; // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
95
- // Blocks can be loaded into a *non-post* block editor.
96
- // eslint-disable-next-line @wordpress/data-no-store-string-literals
81
+ const _area = (entityRecord === null || entityRecord === void 0 ? void 0 : entityRecord.area) || attributes.area;
97
82
 
98
- const defaultWrapperElement = (_select$__experimenta = select('core/editor').__experimentalGetDefaultTemplatePartAreas().find(_ref2 => {
99
- let {
100
- area: value
101
- } = _ref2;
102
- return value === _area;
103
- })) === null || _select$__experimenta === void 0 ? void 0 : _select$__experimenta.area_tag;
83
+ const hasResolvedEntity = templatePartId ? hasFinishedResolution('getEditedEntityRecord', getEntityArgs) : false;
104
84
  return {
105
85
  innerBlocks: getBlocks(clientId),
106
86
  isResolved: hasResolvedEntity,
107
87
  isMissing: hasResolvedEntity && (0, _lodash.isEmpty)(entityRecord),
108
- defaultWrapper: defaultWrapperElement || 'div',
109
- area: _area,
110
- enableSelection: _enableSelection,
111
- hasResolvedReplacements: hasFinishedResolution('getEntityRecords', availableReplacementArgs)
88
+ area: _area
112
89
  };
113
90
  }, [templatePartId, clientId]);
91
+ const {
92
+ templateParts
93
+ } = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId);
94
+ const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
95
+ const hasReplacements = !!templateParts.length || !!blockPatterns.length;
96
+ const areaObject = (0, _hooks.useTemplatePartArea)(area);
114
97
  const blockProps = (0, _blockEditor.useBlockProps)();
115
98
  const isPlaceholder = !slug;
116
99
  const isEntityAvailable = !isPlaceholder && !isMissing && isResolved;
117
- const TagName = tagName || defaultWrapper; // We don't want to render a missing state if we have any inner blocks.
100
+ const TagName = tagName || areaObject.tagName; // We don't want to render a missing state if we have any inner blocks.
118
101
  // A new template part is automatically created if we have any inner blocks but no entity.
119
102
 
120
103
  if (innerBlocks.length === 0 && (slug && !theme || slug && isMissing)) {
@@ -132,47 +115,36 @@ function TemplatePartEdit(_ref) {
132
115
  setAttributes: setAttributes,
133
116
  isEntityAvailable: isEntityAvailable,
134
117
  templatePartId: templatePartId,
135
- defaultWrapper: defaultWrapper
118
+ defaultWrapper: areaObject.tagName
136
119
  }), isPlaceholder && (0, _element.createElement)(TagName, blockProps, (0, _element.createElement)(_placeholder.default, {
137
120
  area: attributes.area,
121
+ templatePartId: templatePartId,
138
122
  clientId: clientId,
139
123
  setAttributes: setAttributes,
140
- enableSelection: enableSelection,
141
- hasResolvedReplacements: hasResolvedReplacements
142
- })), isEntityAvailable && enableSelection && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, {
124
+ onOpenSelectionModal: () => setIsTemplatePartSelectionOpen(true)
125
+ })), isEntityAvailable && hasReplacements && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, {
143
126
  className: "wp-block-template-part__block-control-group"
144
- }, (0, _element.createElement)(_components.Dropdown, {
145
- className: "wp-block-template-part__preview-dropdown-button",
146
- contentClassName: "wp-block-template-part__preview-dropdown-content",
147
- position: "bottom right left",
148
- renderToggle: _ref3 => {
149
- let {
150
- isOpen,
151
- onToggle
152
- } = _ref3;
153
- return (0, _element.createElement)(_components.ToolbarButton, {
154
- "aria-expanded": isOpen,
155
- onClick: onToggle
156
- }, (0, _i18n.__)('Replace'));
157
- },
158
- renderContent: _ref4 => {
159
- let {
160
- onClose
161
- } = _ref4;
162
- return (0, _element.createElement)(_selection.default, {
163
- setAttributes: setAttributes,
164
- onClose: onClose,
165
- area: area,
166
- templatePartId: templatePartId
167
- });
168
- }
169
- }))), isEntityAvailable && (0, _element.createElement)(_innerBlocks.default, {
127
+ }, (0, _element.createElement)(_components.ToolbarButton, {
128
+ onClick: () => setIsTemplatePartSelectionOpen(true)
129
+ }, (0, _i18n.__)('Replace')))), isEntityAvailable && (0, _element.createElement)(_innerBlocks.default, {
170
130
  clientId: clientId,
171
131
  tagName: TagName,
172
132
  blockProps: blockProps,
173
133
  postId: templatePartId,
174
134
  hasInnerBlocks: innerBlocks.length > 0,
175
135
  layout: layout
176
- }), !isPlaceholder && !isResolved && (0, _element.createElement)(TagName, blockProps, (0, _element.createElement)(_components.Spinner, null)));
136
+ }), !isPlaceholder && !isResolved && (0, _element.createElement)(TagName, blockProps, (0, _element.createElement)(_components.Spinner, null)), isTemplatePartSelectionOpen && (0, _element.createElement)(_components.Modal, {
137
+ className: "block-editor-template-part__selection-modal",
138
+ title: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
139
+ (0, _i18n.__)('Choose a %s'), areaObject.label.toLowerCase()),
140
+ closeLabel: (0, _i18n.__)('Cancel'),
141
+ onRequestClose: () => setIsTemplatePartSelectionOpen(false)
142
+ }, (0, _element.createElement)(_selectionModal.default, {
143
+ templatePartId: templatePartId,
144
+ clientId: clientId,
145
+ area: area,
146
+ setAttributes: setAttributes,
147
+ onClose: () => setIsTemplatePartSelectionOpen(false)
148
+ })));
177
149
  }
178
150
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isResolved","innerBlocks","isMissing","defaultWrapper","area","enableSelection","hasResolvedReplacements","select","getEditedEntityRecord","getEntityRecords","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","availableReplacementArgs","matchingReplacements","_enableSelection","length","hasResolvedEntity","defaultWrapperElement","__experimentalGetDefaultTemplatePartAreas","find","value","area_tag","blockProps","isPlaceholder","isEntityAvailable","TagName","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAOA;;AAMA;;AACA;;AAKA;;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UC,QAAAA;AAAV,OAAF;AAAA,aACd,4BAAC,yBAAD;AACC,yBAAgBD,MADjB;AAEC,QAAA,OAAO,EAAGC;AAFX,SAIG,cAAI,SAAJ,CAJH,CADc;AAAA,KAJhB;AAYC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,4BAAC,kBAAD;AACC,QAAA,aAAa,EAAG1C,aADjB;AAEC,QAAA,OAAO,EAAG0C,OAFX;AAGC,QAAA,IAAI,EAAG7B,IAHR;AAIC,QAAA,cAAc,EAAGP;AAJlB,QADe;AAAA;AAZjB,IADD,CADD,CApBF,EA8CGgC,iBAAiB,IAClB,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGrC,QADZ;AAEC,IAAA,OAAO,EAAGsC,OAFX;AAGC,IAAA,UAAU,EAAGH,UAHd;AAIC,IAAA,MAAM,EAAG9B,cAJV;AAKC,IAAA,cAAc,EAAGI,WAAW,CAACmB,MAAZ,GAAqB,CALvC;AAMC,IAAA,MAAM,EAAGxB;AANV,IA/CF,EAwDG,CAAEgC,aAAF,IAAmB,CAAE5B,UAArB,IACD,4BAAC,OAAD,EAAc2B,UAAd,EACC,4BAAC,mBAAD,OADD,CAzDF,CADD;AAgEA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\t__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tSpinner,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelection from './selection';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\n\tconst [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(\n\t\ttemplatePartId\n\t);\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst {\n\t\tisResolved,\n\t\tinnerBlocks,\n\t\tisMissing,\n\t\tdefaultWrapper,\n\t\tarea,\n\t\tenableSelection,\n\t\thasResolvedReplacements,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\n\t\t\t// Check whether other entities exist for switching/selection.\n\t\t\tconst availableReplacementArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t_area && 'uncategorized' !== _area && { area: _area },\n\t\t\t];\n\t\t\tconst matchingReplacements = getEntityRecords(\n\t\t\t\t...availableReplacementArgs\n\t\t\t);\n\t\t\tconst _enableSelection = templatePartId\n\t\t\t\t? matchingReplacements?.length > 1\n\t\t\t\t: matchingReplacements?.length > 0;\n\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst defaultWrapperElement = select( 'core/editor' )\n\t\t\t\t.__experimentalGetDefaultTemplatePartAreas()\n\t\t\t\t.find( ( { area: value } ) => value === _area )?.area_tag;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tdefaultWrapper: defaultWrapperElement || 'div',\n\t\t\t\tarea: _area,\n\t\t\t\tenableSelection: _enableSelection,\n\t\t\t\thasResolvedReplacements: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tavailableReplacementArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || defaultWrapper;\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider>\n\t\t\t<TemplatePartAdvancedControls\n\t\t\t\ttagName={ tagName }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\tdefaultWrapper={ defaultWrapper }\n\t\t\t/>\n\t\t\t{ isPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tenableSelection={ enableSelection }\n\t\t\t\t\t\thasResolvedReplacements={ hasResolvedReplacements }\n\t\t\t\t\t/>\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && enableSelection && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tclassName=\"wp-block-template-part__preview-dropdown-button\"\n\t\t\t\t\t\t\tcontentClassName=\"wp-block-template-part__preview-dropdown-content\"\n\t\t\t\t\t\t\tposition=\"bottom right left\"\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<TemplatePartSelection\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\t\t\t\ttemplatePartId={ templatePartId }\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</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","label","toLowerCase"],"mappings":";;;;;;;;;AAwBA;;AArBA;;AAKA;;AACA;;AAOA;;AAMA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAYe,SAASA,gBAAT,OAIX;AAAA,MAJsC;AACzCC,IAAA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GL,QAFZ;AAGC,IAAA,IAAI,EAAGa,IAHR;AAIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAZD,CAlDF,CADD;AA4EA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\t__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tSpinner,\n\tModal,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(\n\t\ttemplatePartId\n\t);\n\tconst [\n\t\tisTemplatePartSelectionOpen,\n\t\tsetIsTemplatePartSelectionOpen,\n\t] = useState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider>\n\t\t\t<TemplatePartAdvancedControls\n\t\t\t\ttagName={ tagName }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t/>\n\t\t\t{ isPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && hasReplacements && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-template-part__selection-modal\"\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = TemplatePartPlaceholder;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _i18n = require("@wordpress/i18n");
13
+
14
+ var _components = require("@wordpress/components");
15
+
16
+ var _hooks = require("./utils/hooks");
17
+
18
+ var _titleModal = _interopRequireDefault(require("./title-modal"));
19
+
20
+ /**
21
+ * WordPress dependencies
22
+ */
23
+
24
+ /**
25
+ * Internal dependencies
26
+ */
27
+ function TemplatePartPlaceholder(_ref) {
28
+ let {
29
+ area,
30
+ clientId,
31
+ templatePartId,
32
+ onOpenSelectionModal,
33
+ setAttributes
34
+ } = _ref;
35
+ const {
36
+ templateParts,
37
+ isResolving
38
+ } = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId);
39
+ const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
40
+ const [showTitleModal, setShowTitleModal] = (0, _element.useState)(false);
41
+ const areaObject = (0, _hooks.useTemplatePartArea)(area);
42
+ const createFromBlocks = (0, _hooks.useCreateTemplatePartFromBlocks)(area, setAttributes);
43
+ return (0, _element.createElement)(_components.Placeholder, {
44
+ icon: areaObject.icon,
45
+ label: areaObject.label,
46
+ instructions: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
47
+ (0, _i18n.__)('Choose an existing %s or create a new one.'), areaObject.label.toLowerCase())
48
+ }, isResolving && (0, _element.createElement)(_components.Spinner, null), !isResolving && !!(templateParts.length || blockPatterns.length) && (0, _element.createElement)(_components.Button, {
49
+ variant: "primary",
50
+ onClick: onOpenSelectionModal
51
+ }, (0, _i18n.__)('Choose')), !isResolving && (0, _element.createElement)(_components.Button, {
52
+ variant: "secondary",
53
+ onClick: () => {
54
+ setShowTitleModal(true);
55
+ }
56
+ }, (0, _i18n.__)('Start blank')), showTitleModal && (0, _element.createElement)(_titleModal.default, {
57
+ areaLabel: areaObject.label,
58
+ onClose: () => setShowTitleModal(false),
59
+ onSubmit: title => {
60
+ createFromBlocks([], title);
61
+ }
62
+ }));
63
+ }
64
+ //# sourceMappingURL=placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"names":["TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","blockPatterns","showTitleModal","setShowTitleModal","areaObject","createFromBlocks","icon","label","toLowerCase","length","title"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAMA;;AAMA;;AAhBA;AACA;AACA;;AAKA;AACA;AACA;AASe,SAASA,uBAAT,OAMX;AAAA,MAN6C;AAChDC,IAAAA,IADgD;AAEhDC,IAAAA,QAFgD;AAGhDC,IAAAA,cAHgD;AAIhDC,IAAAA,oBAJgD;AAKhDC,IAAAA;AALgD,GAM7C;AACH,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAiC,wCACtCN,IADsC,EAEtCE,cAFsC,CAAvC;AAIA,QAAMK,aAAa,GAAG,wCAA6BP,IAA7B,EAAmCC,QAAnC,CAAtB;AACA,QAAM,CAAEO,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAU,KAAV,CAA9C;AACA,QAAMC,UAAU,GAAG,gCAAqBV,IAArB,CAAnB;AACA,QAAMW,gBAAgB,GAAG,4CACxBX,IADwB,EAExBI,aAFwB,CAAzB;AAKA,SACC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAGM,UAAU,CAACE,IADnB;AAEC,IAAA,KAAK,EAAGF,UAAU,CAACG,KAFpB;AAGC,IAAA,YAAY,EAAG,oBACd;AACA,kBAAI,4CAAJ,CAFc,EAGdH,UAAU,CAACG,KAAX,CAAiBC,WAAjB,EAHc;AAHhB,KASGR,WAAW,IAAI,4BAAC,mBAAD,OATlB,EAWG,CAAEA,WAAF,IACD,CAAC,EAAID,aAAa,CAACU,MAAd,IAAwBR,aAAa,CAACQ,MAA1C,CADA,IAEA,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,OAAO,EAAGZ;AAApC,KACG,cAAI,QAAJ,CADH,CAbH,EAkBG,CAAEG,WAAF,IACD,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,iBAAiB,CAAE,IAAF,CAAjB;AACA;AAJF,KAMG,cAAI,aAAJ,CANH,CAnBF,EA4BGD,cAAc,IACf,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAGE,UAAU,CAACG,KADxB;AAEC,IAAA,OAAO,EAAG,MAAMJ,iBAAiB,CAAE,KAAF,CAFlC;AAGC,IAAA,QAAQ,EAAKO,KAAF,IAAa;AACvBL,MAAAA,gBAAgB,CAAE,EAAF,EAAMK,KAAN,CAAhB;AACA;AALF,IA7BF,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, Button, Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n\tuseTemplatePartArea,\n} from './utils/hooks';\nimport TitleModal from './title-modal';\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tonOpenSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst { templateParts, isResolving } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst [ showTitleModal, setShowTitleModal ] = useState( false );\n\tconst areaObject = useTemplatePartArea( area );\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ areaObject.icon }\n\t\t\tlabel={ areaObject.label }\n\t\t\tinstructions={ sprintf(\n\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t__( 'Choose an existing %s or create a new one.' ),\n\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t) }\n\t\t>\n\t\t\t{ isResolving && <Spinner /> }\n\n\t\t\t{ ! isResolving &&\n\t\t\t\t!! ( templateParts.length || blockPatterns.length ) && (\n\t\t\t\t\t<Button variant=\"primary\" onClick={ onOpenSelectionModal }>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t{ ! isResolving && (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowTitleModal( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showTitleModal && (\n\t\t\t\t<TitleModal\n\t\t\t\t\tareaLabel={ areaObject.label }\n\t\t\t\t\tonClose={ () => setShowTitleModal( false ) }\n\t\t\t\t\tonSubmit={ ( title ) => {\n\t\t\t\t\t\tcreateFromBlocks( [], title );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"]}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = TemplatePartSelectionModal;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _i18n = require("@wordpress/i18n");
11
+
12
+ var _notices = require("@wordpress/notices");
13
+
14
+ var _data = require("@wordpress/data");
15
+
16
+ var _blocks = require("@wordpress/blocks");
17
+
18
+ var _compose = require("@wordpress/compose");
19
+
20
+ var _blockEditor = require("@wordpress/block-editor");
21
+
22
+ var _hooks = require("./utils/hooks");
23
+
24
+ var _createTemplatePartId = require("./utils/create-template-part-id");
25
+
26
+ /**
27
+ * WordPress dependencies
28
+ */
29
+
30
+ /**
31
+ * Internal dependencies
32
+ */
33
+ function TemplatePartSelectionModal(_ref) {
34
+ let {
35
+ setAttributes,
36
+ onClose,
37
+ templatePartId = null,
38
+ area,
39
+ clientId
40
+ } = _ref;
41
+ // When the templatePartId is undefined,
42
+ // it means the user is creating a new one from the placeholder.
43
+ const isReplacingTemplatePartContent = !!templatePartId;
44
+ const {
45
+ templateParts
46
+ } = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId); // We can map template parts to block patters to reuse the BlockPatternsList UI
47
+
48
+ const templartPartsAsBlockPatterns = (0, _element.useMemo)(() => {
49
+ return templateParts.map(templatePart => ({
50
+ name: (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug),
51
+ title: templatePart.title.rendered,
52
+ blocks: (0, _blocks.parse)(templatePart.content.raw),
53
+ templatePart
54
+ }));
55
+ }, [templateParts]);
56
+ const shownTemplateParts = (0, _compose.useAsyncList)(templartPartsAsBlockPatterns);
57
+ const {
58
+ createSuccessNotice
59
+ } = (0, _data.useDispatch)(_notices.store);
60
+ const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
61
+ const shownBlockPatterns = (0, _compose.useAsyncList)(blockPatterns);
62
+ const {
63
+ replaceInnerBlocks
64
+ } = (0, _data.useDispatch)(_blockEditor.store);
65
+ const onTemplatePartSelect = (0, _element.useCallback)(templatePart => {
66
+ var _templatePart$title;
67
+
68
+ setAttributes({
69
+ slug: templatePart.slug,
70
+ theme: templatePart.theme,
71
+ area: undefined
72
+ });
73
+ createSuccessNotice((0, _i18n.sprintf)(
74
+ /* translators: %s: template part title. */
75
+ (0, _i18n.__)('Template Part "%s" inserted.'), ((_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered) || templatePart.slug), {
76
+ type: 'snackbar'
77
+ });
78
+ onClose();
79
+ }, []);
80
+ const createFromBlocks = (0, _hooks.useCreateTemplatePartFromBlocks)(area, setAttributes);
81
+ return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
82
+ className: "block-library-template-part__selection-content"
83
+ }, !!templartPartsAsBlockPatterns.length && (0, _element.createElement)("div", null, (0, _element.createElement)("h2", null, (0, _i18n.__)('Existing template parts')), (0, _element.createElement)(_blockEditor.__experimentalBlockPatternsList, {
84
+ blockPatterns: templartPartsAsBlockPatterns,
85
+ shownPatterns: shownTemplateParts,
86
+ onClickPattern: pattern => {
87
+ onTemplatePartSelect(pattern.templatePart);
88
+ }
89
+ })), !!blockPatterns.length && (0, _element.createElement)("div", null, (0, _element.createElement)("h2", null, (0, _i18n.__)('Patterns')), (0, _element.createElement)(_blockEditor.__experimentalBlockPatternsList, {
90
+ blockPatterns: blockPatterns,
91
+ shownPatterns: shownBlockPatterns,
92
+ onClickPattern: (pattern, blocks) => {
93
+ if (isReplacingTemplatePartContent) {
94
+ replaceInnerBlocks(clientId, blocks);
95
+ } else {
96
+ createFromBlocks(blocks, pattern.title);
97
+ }
98
+
99
+ onClose();
100
+ }
101
+ }))));
102
+ }
103
+ //# sourceMappingURL=selection-modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection-modal.js"],"names":["TemplatePartSelectionModal","setAttributes","onClose","templatePartId","area","clientId","isReplacingTemplatePartContent","templateParts","templartPartsAsBlockPatterns","map","templatePart","name","theme","slug","title","rendered","blocks","content","raw","shownTemplateParts","createSuccessNotice","noticesStore","blockPatterns","shownBlockPatterns","replaceInnerBlocks","blockEditorStore","onTemplatePartSelect","undefined","type","createFromBlocks","length","pattern"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAKA;;AAtBA;AACA;AACA;;AAYA;AACA;AACA;AAQe,SAASA,0BAAT,OAMX;AAAA,MANgD;AACnDC,IAAAA,aADmD;AAEnDC,IAAAA,OAFmD;AAGnDC,IAAAA,cAAc,GAAG,IAHkC;AAInDC,IAAAA,IAJmD;AAKnDC,IAAAA;AALmD,GAMhD;AACH;AACA;AACA,QAAMC,8BAA8B,GAAG,CAAC,CAAEH,cAA1C;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAoB,wC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M2B,gBAAgB,GAAG,4CACxBzB,IADwB,EAExBH,aAFwB,CAAzB;AAKA,SACC,qDACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAC,CAAEO,4BAA4B,CAACsB,MAAhC,IACD,yCACC,wCAAM,cAAI,yBAAJ,CAAN,CADD,EAEC,4BAAC,4CAAD;AACC,IAAA,aAAa,EAAGtB,4BADjB;AAEC,IAAA,aAAa,EAAGW,kBAFjB;AAGC,IAAA,cAAc,EAAKY,OAAF,IAAe;AAC/BL,MAAAA,oBAAoB,CAAEK,OAAO,CAACrB,YAAV,CAApB;AACA;AALF,IAFD,CAFF,EAcG,CAAC,CAAEY,aAAa,CAACQ,MAAjB,IACD,yCACC,wCAAM,cAAI,UAAJ,CAAN,CADD,EAEC,4BAAC,4CAAD;AACC,IAAA,aAAa,EAAGR,aADjB;AAEC,IAAA,aAAa,EAAGC,kBAFjB;AAGC,IAAA,cAAc,EAAG,CAAEQ,OAAF,EAAWf,MAAX,KAAuB;AACvC,UAAKV,8BAAL,EAAsC;AACrCkB,QAAAA,kBAAkB,CAAEnB,QAAF,EAAYW,MAAZ,CAAlB;AACA,OAFD,MAEO;AACNa,QAAAA,gBAAgB,CAAEb,MAAF,EAAUe,OAAO,CAACjB,KAAlB,CAAhB;AACA;;AAEDZ,MAAAA,OAAO;AACP;AAXF,IAFD,CAfF,CADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { useAsyncList } from '@wordpress/compose';\nimport {\n\t__experimentalBlockPatternsList as BlockPatternsList,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n} from './utils/hooks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\n\nexport default function TemplatePartSelectionModal( {\n\tsetAttributes,\n\tonClose,\n\ttemplatePartId = null,\n\tarea,\n\tclientId,\n} ) {\n\t// When the templatePartId is undefined,\n\t// it means the user is creating a new one from the placeholder.\n\tconst isReplacingTemplatePartContent = !! templatePartId;\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\t// We can map template parts to block patters to reuse the BlockPatternsList UI\n\tconst templartPartsAsBlockPatterns = useMemo( () => {\n\t\treturn templateParts.map( ( templatePart ) => ( {\n\t\t\tname: createTemplatePartId( templatePart.theme, templatePart.slug ),\n\t\t\ttitle: templatePart.title.rendered,\n\t\t\tblocks: parse( templatePart.content.raw ),\n\t\t\ttemplatePart,\n\t\t} ) );\n\t}, [ templateParts ] );\n\tconst shownTemplateParts = useAsyncList( templartPartsAsBlockPatterns );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\n\tconst onTemplatePartSelect = useCallback( ( templatePart ) => {\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: template part title. */\n\t\t\t\t__( 'Template Part \"%s\" inserted.' ),\n\t\t\t\ttemplatePart.title?.rendered || templatePart.slug\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\tonClose();\n\t}, [] );\n\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-library-template-part__selection-content\">\n\t\t\t\t{ !! templartPartsAsBlockPatterns.length && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h2>{ __( 'Existing template parts' ) }</h2>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ templartPartsAsBlockPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplateParts }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern ) => {\n\t\t\t\t\t\t\t\tonTemplatePartSelect( pattern.templatePart );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\n\t\t\t\t{ !! blockPatterns.length && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h2>{ __( 'Patterns' ) }</h2>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ blockPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\t\tif ( isReplacingTemplatePartContent ) {\n\t\t\t\t\t\t\t\t\treplaceInnerBlocks( clientId, blocks );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcreateFromBlocks( blocks, pattern.title );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = TitleModal;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _i18n = require("@wordpress/i18n");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+ function TitleModal(_ref) {
18
+ let {
19
+ areaLabel,
20
+ onClose,
21
+ onSubmit
22
+ } = _ref;
23
+ // Restructure onCreate to set the blocks on local state.
24
+ // Add modal to confirm title and trigger onCreate.
25
+ const [title, setTitle] = (0, _element.useState)((0, _i18n.__)('Untitled Template Part'));
26
+
27
+ const submitForCreation = event => {
28
+ event.preventDefault();
29
+ onSubmit(title);
30
+ };
31
+
32
+ return (0, _element.createElement)(_components.Modal, {
33
+ title: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
34
+ (0, _i18n.__)('Name and create your new %s'), areaLabel.toLowerCase()),
35
+ closeLabel: (0, _i18n.__)('Cancel'),
36
+ overlayClassName: "wp-block-template-part__placeholder-create-new__title-form",
37
+ onRequestClose: onClose
38
+ }, (0, _element.createElement)("form", {
39
+ onSubmit: submitForCreation
40
+ }, (0, _element.createElement)(_components.TextControl, {
41
+ label: (0, _i18n.__)('Name'),
42
+ value: title,
43
+ onChange: setTitle
44
+ }), (0, _element.createElement)(_components.Flex, {
45
+ className: "wp-block-template-part__placeholder-create-new__title-form-actions",
46
+ justify: "flex-end"
47
+ }, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
48
+ variant: "primary",
49
+ type: "submit",
50
+ disabled: !title.length,
51
+ "aria-disabled": !title.length
52
+ }, (0, _i18n.__)('Create'))))));
53
+ }
54
+ //# sourceMappingURL=title-modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/template-part/edit/title-modal.js"],"names":["TitleModal","areaLabel","onClose","onSubmit","title","setTitle","submitForCreation","event","preventDefault","toLowerCase","length"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAWe,SAASA,UAAT,OAAwD;AAAA,MAAnC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA;AAAtB,GAAmC;AACtE;AACA;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,cAAI,wBAAJ,CAAV,CAA5B;;AAEA,QAAMC,iBAAiB,GAAKC,KAAF,IAAa;AACtCA,IAAAA,KAAK,CAACC,cAAN;AACAL,IAAAA,QAAQ,CAAEC,KAAF,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,oBACP;AACA,kBAAI,6BAAJ,CAFO,EAGPH,SAAS,CAACQ,WAAV,EAHO,CADT;AAMC,IAAA,UAAU,EAAG,cAAI,QAAJ,CANd;AAOC,IAAA,gBAAgB,EAAC,4DAPlB;AAQC,IAAA,cAAc,EAAGP;AARlB,KAUC;AAAM,IAAA,QAAQ,EAAGI;AAAjB,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,MAAJ,CADT;AAEC,IAAA,KAAK,EAAGF,KAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,EAMC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAED,KAAK,CAACM,MAHpB;AAIC,qBAAgB,CAAEN,KAAK,CAACM;AAJzB,KAMG,cAAI,QAAJ,CANH,CADD,CAJD,CAND,CAVD,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tModal,\n} from '@wordpress/components';\n\nexport default function TitleModal( { areaLabel, onClose, onSubmit } ) {\n\t// Restructure onCreate to set the blocks on local state.\n\t// Add modal to confirm title and trigger onCreate.\n\tconst [ title, setTitle ] = useState( __( 'Untitled Template Part' ) );\n\n\tconst submitForCreation = ( event ) => {\n\t\tevent.preventDefault();\n\t\tonSubmit( title );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t__( 'Name and create your new %s' ),\n\t\t\t\tareaLabel.toLowerCase()\n\t\t\t) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\toverlayClassName=\"wp-block-template-part__placeholder-create-new__title-form\"\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form onSubmit={ submitForCreation }>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t/>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"wp-block-template-part__placeholder-create-new__title-form-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! title.length }\n\t\t\t\t\t\t\taria-disabled={ ! title.length }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAlternativeBlockPatterns = useAlternativeBlockPatterns;
7
+ exports.useAlternativeTemplateParts = useAlternativeTemplateParts;
8
+ exports.useCreateTemplatePartFromBlocks = useCreateTemplatePartFromBlocks;
9
+ exports.useTemplatePartArea = useTemplatePartArea;
10
+
11
+ var _lodash = require("lodash");
12
+
13
+ var _data = require("@wordpress/data");
14
+
15
+ var _coreData = require("@wordpress/core-data");
16
+
17
+ var _blockEditor = require("@wordpress/block-editor");
18
+
19
+ var _element = require("@wordpress/element");
20
+
21
+ var _blocks = require("@wordpress/blocks");
22
+
23
+ var _i18n = require("@wordpress/i18n");
24
+
25
+ var _createTemplatePartId = require("./create-template-part-id");
26
+
27
+ /**
28
+ * External dependencies
29
+ */
30
+
31
+ /**
32
+ * WordPress dependencies
33
+ */
34
+
35
+ /**
36
+ * Internal dependencies
37
+ */
38
+
39
+ /**
40
+ * Retrieves the available template parts for the given area.
41
+ *
42
+ * @param {string} area Template part area.
43
+ * @param {string} excludedId Template part ID to exclude.
44
+ *
45
+ * @return {{ templateParts: Array, isResolving: boolean }} array of template parts.
46
+ */
47
+ function useAlternativeTemplateParts(area, excludedId) {
48
+ const {
49
+ templateParts,
50
+ isResolving
51
+ } = (0, _data.useSelect)(select => {
52
+ const {
53
+ getEntityRecords,
54
+ isResolving: _isResolving
55
+ } = select(_coreData.store);
56
+ const query = {
57
+ per_page: -1
58
+ };
59
+ return {
60
+ templateParts: getEntityRecords('postType', 'wp_template_part', query),
61
+ isLoading: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
62
+ };
63
+ }, []);
64
+ const filteredTemplateParts = (0, _element.useMemo)(() => {
65
+ if (!templateParts) {
66
+ return [];
67
+ }
68
+
69
+ return templateParts.filter(templatePart => (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug) !== excludedId && (!area || 'uncategorized' === area || templatePart.area === area)) || [];
70
+ }, [templateParts, area]);
71
+ return {
72
+ templateParts: filteredTemplateParts,
73
+ isResolving
74
+ };
75
+ }
76
+ /**
77
+ * Retrieves the available block patterns for the given area.
78
+ *
79
+ * @param {string} area Template part area.
80
+ * @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).
81
+ *
82
+ * @return {Array} array of block patterns.
83
+ */
84
+
85
+
86
+ function useAlternativeBlockPatterns(area, clientId) {
87
+ return (0, _data.useSelect)(select => {
88
+ const blockNameWithArea = area ? `core/template-part/${area}` : 'core/template-part';
89
+ const {
90
+ getBlockRootClientId,
91
+ __experimentalGetPatternsByBlockTypes
92
+ } = select(_blockEditor.store);
93
+ const rootClientId = getBlockRootClientId(clientId);
94
+ return __experimentalGetPatternsByBlockTypes(blockNameWithArea, rootClientId);
95
+ }, [area, clientId]);
96
+ }
97
+
98
+ function useCreateTemplatePartFromBlocks(area, setAttributes) {
99
+ const {
100
+ saveEntityRecord
101
+ } = (0, _data.useDispatch)(_coreData.store);
102
+ return async function () {
103
+ let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
104
+ let title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _i18n.__)('Untitled Template Part');
105
+ // If we have `area` set from block attributes, means an exposed
106
+ // block variation was inserted. So add this prop to the template
107
+ // part entity on creation. Afterwards remove `area` value from
108
+ // block attributes.
109
+ const record = {
110
+ title,
111
+ slug: (0, _lodash.kebabCase)(title),
112
+ content: (0, _blocks.serialize)(blocks),
113
+ // `area` is filterable on the server and defaults to `UNCATEGORIZED`
114
+ // if provided value is not allowed.
115
+ area
116
+ };
117
+ const templatePart = await saveEntityRecord('postType', 'wp_template_part', record);
118
+ setAttributes({
119
+ slug: templatePart.slug,
120
+ theme: templatePart.theme,
121
+ area: undefined
122
+ });
123
+ };
124
+ }
125
+ /**
126
+ * Retrieves the template part area object.
127
+ *
128
+ * @param {string} area Template part area identifier.
129
+ *
130
+ * @return {{icon: Object, label: string, tagName: string}} Template Part area.
131
+ */
132
+
133
+
134
+ function useTemplatePartArea(area) {
135
+ return (0, _data.useSelect)(select => {
136
+ var _selectedArea$area_ta;
137
+
138
+ // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
139
+ // Blocks can be loaded into a *non-post* block editor.
140
+ // eslint-disable-next-line @wordpress/data-no-store-string-literals
141
+ const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
142
+
143
+ const selectedArea = (0, _lodash.find)(definedAreas, {
144
+ area
145
+ });
146
+ const defaultArea = (0, _lodash.find)(definedAreas, {
147
+ area: 'uncategorized'
148
+ });
149
+ return {
150
+ icon: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.icon) || (defaultArea === null || defaultArea === void 0 ? void 0 : defaultArea.icon),
151
+ label: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.label) || (0, _i18n.__)('Template Part'),
152
+ tagName: (_selectedArea$area_ta = selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.area_tag) !== null && _selectedArea$area_ta !== void 0 ? _selectedArea$area_ta : 'div'
153
+ };
154
+ }, [area]);
155
+ }
156
+ //# sourceMappingURL=hooks.js.map