@wordpress/edit-widgets 6.32.0 → 6.32.1-next.ff1cebbba.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 (202) hide show
  1. package/build/blocks/widget-area/block.json +26 -0
  2. package/build/blocks/widget-area/edit/index.js +94 -87
  3. package/build/blocks/widget-area/edit/index.js.map +7 -1
  4. package/build/blocks/widget-area/edit/inner-blocks.js +68 -50
  5. package/build/blocks/widget-area/edit/inner-blocks.js.map +7 -1
  6. package/build/blocks/widget-area/edit/use-is-dragging-within.js +34 -40
  7. package/build/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
  8. package/build/blocks/widget-area/index.js +49 -52
  9. package/build/blocks/widget-area/index.js.map +7 -1
  10. package/build/components/error-boundary/index.js +49 -51
  11. package/build/components/error-boundary/index.js.map +7 -1
  12. package/build/components/header/document-tools/index.js +104 -74
  13. package/build/components/header/document-tools/index.js.map +7 -1
  14. package/build/components/header/index.js +81 -62
  15. package/build/components/header/index.js.map +7 -1
  16. package/build/components/header/undo-redo/redo.js +50 -38
  17. package/build/components/header/undo-redo/redo.js.map +7 -1
  18. package/build/components/header/undo-redo/undo.js +49 -37
  19. package/build/components/header/undo-redo/undo.js.map +7 -1
  20. package/build/components/keyboard-shortcut-help-modal/config.js +74 -71
  21. package/build/components/keyboard-shortcut-help-modal/config.js.map +7 -1
  22. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +61 -44
  23. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
  24. package/build/components/keyboard-shortcut-help-modal/index.js +154 -103
  25. package/build/components/keyboard-shortcut-help-modal/index.js.map +7 -1
  26. package/build/components/keyboard-shortcut-help-modal/shortcut.js +74 -56
  27. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
  28. package/build/components/keyboard-shortcuts/index.js +89 -82
  29. package/build/components/keyboard-shortcuts/index.js.map +7 -1
  30. package/build/components/layout/index.js +75 -49
  31. package/build/components/layout/index.js.map +7 -1
  32. package/build/components/layout/interface.js +89 -75
  33. package/build/components/layout/interface.js.map +7 -1
  34. package/build/components/layout/unsaved-changes-warning.js +35 -42
  35. package/build/components/layout/unsaved-changes-warning.js.map +7 -1
  36. package/build/components/more-menu/index.js +189 -108
  37. package/build/components/more-menu/index.js.map +7 -1
  38. package/build/components/more-menu/tools-more-menu-group.js +29 -23
  39. package/build/components/more-menu/tools-more-menu-group.js.map +7 -1
  40. package/build/components/notices/index.js +62 -48
  41. package/build/components/notices/index.js.map +7 -1
  42. package/build/components/save-button/index.js +55 -47
  43. package/build/components/save-button/index.js.map +7 -1
  44. package/build/components/secondary-sidebar/index.js +41 -34
  45. package/build/components/secondary-sidebar/index.js.map +7 -1
  46. package/build/components/secondary-sidebar/inserter-sidebar.js +55 -46
  47. package/build/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
  48. package/build/components/secondary-sidebar/list-view-sidebar.js +76 -67
  49. package/build/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
  50. package/build/components/sidebar/index.js +149 -138
  51. package/build/components/sidebar/index.js.map +7 -1
  52. package/build/components/sidebar/widget-areas.js +73 -57
  53. package/build/components/sidebar/widget-areas.js.map +7 -1
  54. package/build/components/welcome-guide/index.js +182 -137
  55. package/build/components/welcome-guide/index.js.map +7 -1
  56. package/build/components/widget-areas-block-editor-content/index.js +64 -43
  57. package/build/components/widget-areas-block-editor-content/index.js.map +7 -1
  58. package/build/components/widget-areas-block-editor-provider/index.js +115 -92
  59. package/build/components/widget-areas-block-editor-provider/index.js.map +7 -1
  60. package/build/constants.js +30 -8
  61. package/build/constants.js.map +7 -1
  62. package/build/filters/index.js +3 -5
  63. package/build/filters/index.js.map +7 -1
  64. package/build/filters/move-to-widget-area.js +52 -59
  65. package/build/filters/move-to-widget-area.js.map +7 -1
  66. package/build/filters/replace-media-upload.js +9 -11
  67. package/build/filters/replace-media-upload.js.map +7 -1
  68. package/build/hooks/use-last-selected-widget-area.js +38 -44
  69. package/build/hooks/use-last-selected-widget-area.js.map +7 -1
  70. package/build/hooks/use-widget-library-insertion-point.js +60 -55
  71. package/build/hooks/use-widget-library-insertion-point.js.map +7 -1
  72. package/build/index.js +86 -93
  73. package/build/index.js.map +7 -1
  74. package/build/lock-unlock.js +31 -15
  75. package/build/lock-unlock.js.map +7 -1
  76. package/build/store/actions.js +181 -313
  77. package/build/store/actions.js.map +7 -1
  78. package/build/store/constants.js +27 -10
  79. package/build/store/constants.js.map +7 -1
  80. package/build/store/index.js +51 -51
  81. package/build/store/index.js.map +7 -1
  82. package/build/store/private-selectors.js +28 -7
  83. package/build/store/private-selectors.js.map +7 -1
  84. package/build/store/reducer.js +65 -118
  85. package/build/store/reducer.js.map +7 -1
  86. package/build/store/resolvers.js +64 -63
  87. package/build/store/resolvers.js.map +7 -1
  88. package/build/store/selectors.js +194 -231
  89. package/build/store/selectors.js.map +7 -1
  90. package/build/store/transformers.js +47 -41
  91. package/build/store/transformers.js.map +7 -1
  92. package/build/store/utils.js +47 -70
  93. package/build/store/utils.js.map +7 -1
  94. package/build-module/blocks/widget-area/block.json +26 -0
  95. package/build-module/blocks/widget-area/edit/index.js +63 -75
  96. package/build-module/blocks/widget-area/edit/index.js.map +7 -1
  97. package/build-module/blocks/widget-area/edit/inner-blocks.js +38 -41
  98. package/build-module/blocks/widget-area/edit/inner-blocks.js.map +7 -1
  99. package/build-module/blocks/widget-area/edit/use-is-dragging-within.js +14 -33
  100. package/build-module/blocks/widget-area/edit/use-is-dragging-within.js.map +7 -1
  101. package/build-module/blocks/widget-area/index.js +14 -46
  102. package/build-module/blocks/widget-area/index.js.map +7 -1
  103. package/build-module/components/error-boundary/index.js +30 -43
  104. package/build-module/components/error-boundary/index.js.map +7 -1
  105. package/build-module/components/header/document-tools/index.js +75 -66
  106. package/build-module/components/header/document-tools/index.js.map +7 -1
  107. package/build-module/components/header/index.js +52 -54
  108. package/build-module/components/header/index.js.map +7 -1
  109. package/build-module/components/header/undo-redo/redo.js +32 -32
  110. package/build-module/components/header/undo-redo/redo.js.map +7 -1
  111. package/build-module/components/header/undo-redo/undo.js +31 -31
  112. package/build-module/components/header/undo-redo/undo.js.map +7 -1
  113. package/build-module/components/keyboard-shortcut-help-modal/config.js +62 -75
  114. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +7 -1
  115. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +33 -37
  116. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +7 -1
  117. package/build-module/components/keyboard-shortcut-help-modal/index.js +130 -97
  118. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +7 -1
  119. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +56 -50
  120. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +7 -1
  121. package/build-module/components/keyboard-shortcuts/index.js +73 -75
  122. package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
  123. package/build-module/components/layout/index.js +46 -41
  124. package/build-module/components/layout/index.js.map +7 -1
  125. package/build-module/components/layout/interface.js +63 -66
  126. package/build-module/components/layout/interface.js.map +7 -1
  127. package/build-module/components/layout/unsaved-changes-warning.js +17 -37
  128. package/build-module/components/layout/unsaved-changes-warning.js.map +7 -1
  129. package/build-module/components/more-menu/index.js +167 -102
  130. package/build-module/components/more-menu/index.js.map +7 -1
  131. package/build-module/components/more-menu/tools-more-menu-group.js +11 -17
  132. package/build-module/components/more-menu/tools-more-menu-group.js.map +7 -1
  133. package/build-module/components/notices/index.js +43 -42
  134. package/build-module/components/notices/index.js.map +7 -1
  135. package/build-module/components/save-button/index.js +37 -41
  136. package/build-module/components/save-button/index.js.map +7 -1
  137. package/build-module/components/secondary-sidebar/index.js +14 -27
  138. package/build-module/components/secondary-sidebar/index.js.map +7 -1
  139. package/build-module/components/secondary-sidebar/inserter-sidebar.js +26 -38
  140. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +7 -1
  141. package/build-module/components/secondary-sidebar/list-view-sidebar.js +57 -60
  142. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +7 -1
  143. package/build-module/components/sidebar/index.js +129 -127
  144. package/build-module/components/sidebar/index.js.map +7 -1
  145. package/build-module/components/sidebar/widget-areas.js +53 -49
  146. package/build-module/components/sidebar/widget-areas.js.map +7 -1
  147. package/build-module/components/welcome-guide/index.js +165 -132
  148. package/build-module/components/welcome-guide/index.js.map +7 -1
  149. package/build-module/components/widget-areas-block-editor-content/index.js +43 -36
  150. package/build-module/components/widget-areas-block-editor-content/index.js.map +7 -1
  151. package/build-module/components/widget-areas-block-editor-provider/index.js +85 -83
  152. package/build-module/components/widget-areas-block-editor-provider/index.js.map +7 -1
  153. package/build-module/constants.js +7 -3
  154. package/build-module/constants.js.map +7 -1
  155. package/build-module/filters/index.js +3 -6
  156. package/build-module/filters/index.js.map +7 -1
  157. package/build-module/filters/move-to-widget-area.js +52 -57
  158. package/build-module/filters/move-to-widget-area.js.map +7 -1
  159. package/build-module/filters/replace-media-upload.js +8 -7
  160. package/build-module/filters/replace-media-upload.js.map +7 -1
  161. package/build-module/hooks/use-last-selected-widget-area.js +20 -39
  162. package/build-module/hooks/use-last-selected-widget-area.js.map +7 -1
  163. package/build-module/hooks/use-widget-library-insertion-point.js +42 -49
  164. package/build-module/hooks/use-widget-library-insertion-point.js.map +7 -1
  165. package/build-module/index.js +60 -72
  166. package/build-module/index.js.map +7 -1
  167. package/build-module/lock-unlock.js +8 -7
  168. package/build-module/lock-unlock.js.map +7 -1
  169. package/build-module/store/actions.js +153 -293
  170. package/build-module/store/actions.js.map +7 -1
  171. package/build-module/store/constants.js +5 -5
  172. package/build-module/store/constants.js.map +7 -1
  173. package/build-module/store/index.js +16 -40
  174. package/build-module/store/index.js.map +7 -1
  175. package/build-module/store/private-selectors.js +7 -3
  176. package/build-module/store/private-selectors.js.map +7 -1
  177. package/build-module/store/reducer.js +42 -111
  178. package/build-module/store/reducer.js.map +7 -1
  179. package/build-module/store/resolvers.js +43 -51
  180. package/build-module/store/resolvers.js.map +7 -1
  181. package/build-module/store/selectors.js +171 -224
  182. package/build-module/store/selectors.js.map +7 -1
  183. package/build-module/store/transformers.js +23 -34
  184. package/build-module/store/transformers.js.map +7 -1
  185. package/build-module/store/utils.js +22 -63
  186. package/build-module/store/utils.js.map +7 -1
  187. package/build-style/style-rtl.css +216 -88
  188. package/build-style/style.css +216 -88
  189. package/package.json +36 -29
  190. package/src/blocks/widget-area/editor.scss +3 -0
  191. package/src/components/customizer-edit-widgets-initializer/style.scss +3 -0
  192. package/src/components/error-boundary/style.scss +2 -0
  193. package/src/components/header/style.scss +5 -0
  194. package/src/components/keyboard-shortcut-help-modal/style.scss +2 -0
  195. package/src/components/layout/style.scss +3 -0
  196. package/src/components/more-menu/style.scss +2 -0
  197. package/src/components/notices/style.scss +3 -0
  198. package/src/components/secondary-sidebar/style.scss +4 -0
  199. package/src/components/sidebar/style.scss +2 -0
  200. package/src/components/welcome-guide/style.scss +2 -0
  201. package/src/components/widget-areas-block-editor-content/style.scss +2 -0
  202. package/src/style.scss +16 -13
@@ -1,5 +1,5 @@
1
- /**
2
- * Module Constants
3
- */
4
- export const STORE_NAME = 'core/edit-widgets';
5
- //# sourceMappingURL=constants.js.map
1
+ const STORE_NAME = "core/edit-widgets";
2
+ export {
3
+ STORE_NAME
4
+ };
5
+ //# sourceMappingURL=constants.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["STORE_NAME"],"sources":["@wordpress/edit-widgets/src/store/constants.js"],"sourcesContent":["/**\n * Module Constants\n */\nexport const STORE_NAME = 'core/edit-widgets';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,GAAG,mBAAmB","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/constants.js"],
4
+ "sourcesContent": ["/**\n * Module Constants\n */\nexport const STORE_NAME = 'core/edit-widgets';\n"],
5
+ "mappings": "AAGO,MAAM,aAAa;",
6
+ "names": []
7
+ }
@@ -1,52 +1,28 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import apiFetch from '@wordpress/api-fetch';
5
- import { createReduxStore, register } from '@wordpress/data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import reducer from './reducer';
11
- import * as resolvers from './resolvers';
12
- import * as selectors from './selectors';
13
- import * as actions from './actions';
14
- import * as privateSelectors from './private-selectors';
15
- import { STORE_NAME } from './constants';
16
- import { unlock } from '../lock-unlock';
17
-
18
- /**
19
- * Block editor data store configuration.
20
- *
21
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register
22
- *
23
- * @type {Object}
24
- */
1
+ import apiFetch from "@wordpress/api-fetch";
2
+ import { createReduxStore, register } from "@wordpress/data";
3
+ import reducer from "./reducer";
4
+ import * as resolvers from "./resolvers";
5
+ import * as selectors from "./selectors";
6
+ import * as actions from "./actions";
7
+ import * as privateSelectors from "./private-selectors";
8
+ import { STORE_NAME } from "./constants";
9
+ import { unlock } from "../lock-unlock";
25
10
  const storeConfig = {
26
11
  reducer,
27
12
  selectors,
28
13
  resolvers,
29
14
  actions
30
15
  };
31
-
32
- /**
33
- * Store definition for the edit widgets namespace.
34
- *
35
- * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
36
- *
37
- * @type {Object}
38
- */
39
- export const store = createReduxStore(STORE_NAME, storeConfig);
16
+ const store = createReduxStore(STORE_NAME, storeConfig);
40
17
  register(store);
41
-
42
- // This package uses a few in-memory post types as wrappers for convenience.
43
- // This middleware prevents any network requests related to these types as they are
44
- // bound to fail anyway.
45
- apiFetch.use(function (options, next) {
46
- if (options.path?.indexOf('/wp/v2/types/widget-area') === 0) {
18
+ apiFetch.use(function(options, next) {
19
+ if (options.path?.indexOf("/wp/v2/types/widget-area") === 0) {
47
20
  return Promise.resolve({});
48
21
  }
49
22
  return next(options);
50
23
  });
51
24
  unlock(store).registerPrivateSelectors(privateSelectors);
52
- //# sourceMappingURL=index.js.map
25
+ export {
26
+ store
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["apiFetch","createReduxStore","register","reducer","resolvers","selectors","actions","privateSelectors","STORE_NAME","unlock","storeConfig","store","use","options","next","path","indexOf","Promise","resolve","registerPrivateSelectors"],"sources":["@wordpress/edit-widgets/src/store/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register\n *\n * @type {Object}\n */\nconst storeConfig = {\n\treducer,\n\tselectors,\n\tresolvers,\n\tactions,\n};\n\n/**\n * Store definition for the edit widgets namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\n\n// This package uses a few in-memory post types as wrappers for convenience.\n// This middleware prevents any network requests related to these types as they are\n// bound to fail anyway.\napiFetch.use( function ( options, next ) {\n\tif ( options.path?.indexOf( '/wp/v2/types/widget-area' ) === 0 ) {\n\t\treturn Promise.resolve( {} );\n\t}\n\n\treturn next( options );\n} );\n\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,gBAAgB,EAAEC,QAAQ,QAAQ,iBAAiB;;AAE5D;AACA;AACA;AACA,OAAOC,OAAO,MAAM,WAAW;AAC/B,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,SAAS,MAAM,aAAa;AACxC,OAAO,KAAKC,OAAO,MAAM,WAAW;AACpC,OAAO,KAAKC,gBAAgB,MAAM,qBAAqB;AACvD,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAG;EACnBP,OAAO;EACPE,SAAS;EACTD,SAAS;EACTE;AACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,KAAK,GAAGV,gBAAgB,CAAEO,UAAU,EAAEE,WAAY,CAAC;AAChER,QAAQ,CAAES,KAAM,CAAC;;AAEjB;AACA;AACA;AACAX,QAAQ,CAACY,GAAG,CAAE,UAAWC,OAAO,EAAEC,IAAI,EAAG;EACxC,IAAKD,OAAO,CAACE,IAAI,EAAEC,OAAO,CAAE,0BAA2B,CAAC,KAAK,CAAC,EAAG;IAChE,OAAOC,OAAO,CAACC,OAAO,CAAE,CAAC,CAAE,CAAC;EAC7B;EAEA,OAAOJ,IAAI,CAAED,OAAQ,CAAC;AACvB,CAAE,CAAC;AAEHJ,MAAM,CAAEE,KAAM,CAAC,CAACQ,wBAAwB,CAAEZ,gBAAiB,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/index.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as resolvers from './resolvers';\nimport * as selectors from './selectors';\nimport * as actions from './actions';\nimport * as privateSelectors from './private-selectors';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#register\n *\n * @type {Object}\n */\nconst storeConfig = {\n\treducer,\n\tselectors,\n\tresolvers,\n\tactions,\n};\n\n/**\n * Store definition for the edit widgets namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig );\nregister( store );\n\n// This package uses a few in-memory post types as wrappers for convenience.\n// This middleware prevents any network requests related to these types as they are\n// bound to fail anyway.\napiFetch.use( function ( options, next ) {\n\tif ( options.path?.indexOf( '/wp/v2/types/widget-area' ) === 0 ) {\n\t\treturn Promise.resolve( {} );\n\t}\n\n\treturn next( options );\n} );\n\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"],
5
+ "mappings": "AAGA,OAAO,cAAc;AACrB,SAAS,kBAAkB,gBAAgB;AAK3C,OAAO,aAAa;AACpB,YAAY,eAAe;AAC3B,YAAY,eAAe;AAC3B,YAAY,aAAa;AACzB,YAAY,sBAAsB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AASvB,MAAM,cAAc;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AASO,MAAM,QAAQ,iBAAkB,YAAY,WAAY;AAC/D,SAAU,KAAM;AAKhB,SAAS,IAAK,SAAW,SAAS,MAAO;AACxC,MAAK,QAAQ,MAAM,QAAS,0BAA2B,MAAM,GAAI;AAChE,WAAO,QAAQ,QAAS,CAAC,CAAE;AAAA,EAC5B;AAEA,SAAO,KAAM,OAAQ;AACtB,CAAE;AAEF,OAAQ,KAAM,EAAE,yBAA0B,gBAAiB;",
6
+ "names": []
7
+ }
@@ -1,7 +1,11 @@
1
- export function getListViewToggleRef(state) {
1
+ function getListViewToggleRef(state) {
2
2
  return state.listViewToggleRef;
3
3
  }
4
- export function getInserterSidebarToggleRef(state) {
4
+ function getInserterSidebarToggleRef(state) {
5
5
  return state.inserterSidebarToggleRef;
6
6
  }
7
- //# sourceMappingURL=private-selectors.js.map
7
+ export {
8
+ getInserterSidebarToggleRef,
9
+ getListViewToggleRef
10
+ };
11
+ //# sourceMappingURL=private-selectors.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["getListViewToggleRef","state","listViewToggleRef","getInserterSidebarToggleRef","inserterSidebarToggleRef"],"sources":["@wordpress/edit-widgets/src/store/private-selectors.js"],"sourcesContent":["export function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\n\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\n"],"mappings":"AAAA,OAAO,SAASA,oBAAoBA,CAAEC,KAAK,EAAG;EAC7C,OAAOA,KAAK,CAACC,iBAAiB;AAC/B;AAEA,OAAO,SAASC,2BAA2BA,CAAEF,KAAK,EAAG;EACpD,OAAOA,KAAK,CAACG,wBAAwB;AACtC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/private-selectors.js"],
4
+ "sourcesContent": ["export function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\n\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\n"],
5
+ "mappings": "AAAO,SAAS,qBAAsB,OAAQ;AAC7C,SAAO,MAAM;AACd;AAEO,SAAS,4BAA6B,OAAQ;AACpD,SAAO,MAAM;AACd;",
6
+ "names": []
7
+ }
@@ -1,136 +1,58 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { combineReducers } from '@wordpress/data';
5
-
6
- /**
7
- * Controls the open state of the widget areas.
8
- *
9
- * @param {Object} state Redux state.
10
- * @param {Object} action Redux action.
11
- *
12
- * @return {Array} Updated state.
13
- */
14
- export function widgetAreasOpenState(state = {}, action) {
15
- const {
16
- type
17
- } = action;
1
+ import { combineReducers } from "@wordpress/data";
2
+ function widgetAreasOpenState(state = {}, action) {
3
+ const { type } = action;
18
4
  switch (type) {
19
- case 'SET_WIDGET_AREAS_OPEN_STATE':
20
- {
21
- return action.widgetAreasOpenState;
22
- }
23
- case 'SET_IS_WIDGET_AREA_OPEN':
24
- {
25
- const {
26
- clientId,
27
- isOpen
28
- } = action;
29
- return {
30
- ...state,
31
- [clientId]: isOpen
32
- };
33
- }
34
- default:
35
- {
36
- return state;
37
- }
5
+ case "SET_WIDGET_AREAS_OPEN_STATE": {
6
+ return action.widgetAreasOpenState;
7
+ }
8
+ case "SET_IS_WIDGET_AREA_OPEN": {
9
+ const { clientId, isOpen } = action;
10
+ return {
11
+ ...state,
12
+ [clientId]: isOpen
13
+ };
14
+ }
15
+ default: {
16
+ return state;
17
+ }
38
18
  }
39
19
  }
40
-
41
- /**
42
- * Reducer to set the block inserter panel open or closed.
43
- *
44
- * Note: this reducer interacts with the list view panel reducer
45
- * to make sure that only one of the two panels is open at the same time.
46
- *
47
- * @param {Object} state Current state.
48
- * @param {Object} action Dispatched action.
49
- */
50
- export function blockInserterPanel(state = false, action) {
20
+ function blockInserterPanel(state = false, action) {
51
21
  switch (action.type) {
52
- case 'SET_IS_LIST_VIEW_OPENED':
22
+ case "SET_IS_LIST_VIEW_OPENED":
53
23
  return action.isOpen ? false : state;
54
- case 'SET_IS_INSERTER_OPENED':
24
+ case "SET_IS_INSERTER_OPENED":
55
25
  return action.value;
56
26
  }
57
27
  return state;
58
28
  }
59
-
60
- /**
61
- * Reducer to set the list view panel open or closed.
62
- *
63
- * Note: this reducer interacts with the inserter panel reducer
64
- * to make sure that only one of the two panels is open at the same time.
65
- *
66
- * @param {Object} state Current state.
67
- * @param {Object} action Dispatched action.
68
- */
69
- export function listViewPanel(state = false, action) {
29
+ function listViewPanel(state = false, action) {
70
30
  switch (action.type) {
71
- case 'SET_IS_INSERTER_OPENED':
31
+ case "SET_IS_INSERTER_OPENED":
72
32
  return action.value ? false : state;
73
- case 'SET_IS_LIST_VIEW_OPENED':
33
+ case "SET_IS_LIST_VIEW_OPENED":
74
34
  return action.isOpen;
75
35
  }
76
36
  return state;
77
37
  }
78
-
79
- /**
80
- * This reducer does nothing aside initializing a ref to the list view toggle.
81
- * We will have a unique ref per "editor" instance.
82
- *
83
- * @param {Object} state
84
- * @return {Object} Reference to the list view toggle button.
85
- */
86
- export function listViewToggleRef(state = {
87
- current: null
88
- }) {
38
+ function listViewToggleRef(state = { current: null }) {
89
39
  return state;
90
40
  }
91
-
92
- /**
93
- * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
94
- * We will have a unique ref per "editor" instance.
95
- *
96
- * @param {Object} state
97
- * @return {Object} Reference to the inserter sidebar toggle button.
98
- */
99
- export function inserterSidebarToggleRef(state = {
100
- current: null
101
- }) {
41
+ function inserterSidebarToggleRef(state = { current: null }) {
102
42
  return state;
103
43
  }
104
-
105
- /**
106
- * Widget saving lock.
107
- *
108
- * When widget saving is locked, the widget cannot be updated.
109
- *
110
- * @param {Object} state Current state.
111
- * @param {Object} action Dispatched action.
112
- *
113
- * @return {Object} Updated state.
114
- */
115
- export function widgetSavingLock(state = {}, action) {
44
+ function widgetSavingLock(state = {}, action) {
116
45
  switch (action.type) {
117
- case 'LOCK_WIDGET_SAVING':
118
- return {
119
- ...state,
120
- [action.lockName]: true
121
- };
122
- case 'UNLOCK_WIDGET_SAVING':
123
- {
124
- const {
125
- [action.lockName]: removedLockName,
126
- ...restState
127
- } = state;
128
- return restState;
129
- }
46
+ case "LOCK_WIDGET_SAVING":
47
+ return { ...state, [action.lockName]: true };
48
+ case "UNLOCK_WIDGET_SAVING": {
49
+ const { [action.lockName]: removedLockName, ...restState } = state;
50
+ return restState;
51
+ }
130
52
  }
131
53
  return state;
132
54
  }
133
- export default combineReducers({
55
+ var reducer_default = combineReducers({
134
56
  blockInserterPanel,
135
57
  inserterSidebarToggleRef,
136
58
  listViewPanel,
@@ -138,4 +60,13 @@ export default combineReducers({
138
60
  widgetAreasOpenState,
139
61
  widgetSavingLock
140
62
  });
141
- //# sourceMappingURL=reducer.js.map
63
+ export {
64
+ blockInserterPanel,
65
+ reducer_default as default,
66
+ inserterSidebarToggleRef,
67
+ listViewPanel,
68
+ listViewToggleRef,
69
+ widgetAreasOpenState,
70
+ widgetSavingLock
71
+ };
72
+ //# sourceMappingURL=reducer.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["combineReducers","widgetAreasOpenState","state","action","type","clientId","isOpen","blockInserterPanel","value","listViewPanel","listViewToggleRef","current","inserterSidebarToggleRef","widgetSavingLock","lockName","removedLockName","restState"],"sources":["@wordpress/edit-widgets/src/store/reducer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Controls the open state of the widget areas.\n *\n * @param {Object} state Redux state.\n * @param {Object} action Redux action.\n *\n * @return {Array} Updated state.\n */\nexport function widgetAreasOpenState( state = {}, action ) {\n\tconst { type } = action;\n\tswitch ( type ) {\n\t\tcase 'SET_WIDGET_AREAS_OPEN_STATE': {\n\t\t\treturn action.widgetAreasOpenState;\n\t\t}\n\t\tcase 'SET_IS_WIDGET_AREA_OPEN': {\n\t\t\tconst { clientId, isOpen } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ clientId ]: isOpen,\n\t\t\t};\n\t\t}\n\t\tdefault: {\n\t\t\treturn state;\n\t\t}\n\t}\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * Widget saving lock.\n *\n * When widget saving is locked, the widget cannot be updated.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function widgetSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_WIDGET_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_WIDGET_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\twidgetAreasOpenState,\n\twidgetSavingLock,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,iBAAiB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAAEC,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EAC1D,MAAM;IAAEC;EAAK,CAAC,GAAGD,MAAM;EACvB,QAASC,IAAI;IACZ,KAAK,6BAA6B;MAAE;QACnC,OAAOD,MAAM,CAACF,oBAAoB;MACnC;IACA,KAAK,yBAAyB;MAAE;QAC/B,MAAM;UAAEI,QAAQ;UAAEC;QAAO,CAAC,GAAGH,MAAM;QACnC,OAAO;UACN,GAAGD,KAAK;UACR,CAAEG,QAAQ,GAAIC;QACf,CAAC;MACF;IACA;MAAS;QACR,OAAOJ,KAAK;MACb;EACD;AACD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,kBAAkBA,CAAEL,KAAK,GAAG,KAAK,EAAEC,MAAM,EAAG;EAC3D,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,yBAAyB;MAC7B,OAAOD,MAAM,CAACG,MAAM,GAAG,KAAK,GAAGJ,KAAK;IACrC,KAAK,wBAAwB;MAC5B,OAAOC,MAAM,CAACK,KAAK;EACrB;EACA,OAAON,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAAEP,KAAK,GAAG,KAAK,EAAEC,MAAM,EAAG;EACtD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,wBAAwB;MAC5B,OAAOD,MAAM,CAACK,KAAK,GAAG,KAAK,GAAGN,KAAK;IACpC,KAAK,yBAAyB;MAC7B,OAAOC,MAAM,CAACG,MAAM;EACtB;EACA,OAAOJ,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,iBAAiBA,CAAER,KAAK,GAAG;EAAES,OAAO,EAAE;AAAK,CAAC,EAAG;EAC9D,OAAOT,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASU,wBAAwBA,CAAEV,KAAK,GAAG;EAAES,OAAO,EAAE;AAAK,CAAC,EAAG;EACrE,OAAOT,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,gBAAgBA,CAAEX,KAAK,GAAG,CAAC,CAAC,EAAEC,MAAM,EAAG;EACtD,QAASA,MAAM,CAACC,IAAI;IACnB,KAAK,oBAAoB;MACxB,OAAO;QAAE,GAAGF,KAAK;QAAE,CAAEC,MAAM,CAACW,QAAQ,GAAI;MAAK,CAAC;IAE/C,KAAK,sBAAsB;MAAE;QAC5B,MAAM;UAAE,CAAEX,MAAM,CAACW,QAAQ,GAAIC,eAAe;UAAE,GAAGC;QAAU,CAAC,GAC3Dd,KAAK;QACN,OAAOc,SAAS;MACjB;EACD;EAEA,OAAOd,KAAK;AACb;AAEA,eAAeF,eAAe,CAAE;EAC/BO,kBAAkB;EAClBK,wBAAwB;EACxBH,aAAa;EACbC,iBAAiB;EACjBT,oBAAoB;EACpBY;AACD,CAAE,CAAC","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/reducer.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { combineReducers } from '@wordpress/data';\n\n/**\n * Controls the open state of the widget areas.\n *\n * @param {Object} state Redux state.\n * @param {Object} action Redux action.\n *\n * @return {Array} Updated state.\n */\nexport function widgetAreasOpenState( state = {}, action ) {\n\tconst { type } = action;\n\tswitch ( type ) {\n\t\tcase 'SET_WIDGET_AREAS_OPEN_STATE': {\n\t\t\treturn action.widgetAreasOpenState;\n\t\t}\n\t\tcase 'SET_IS_WIDGET_AREA_OPEN': {\n\t\t\tconst { clientId, isOpen } = action;\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\t[ clientId ]: isOpen,\n\t\t\t};\n\t\t}\n\t\tdefault: {\n\t\t\treturn state;\n\t\t}\n\t}\n}\n\n/**\n * Reducer to set the block inserter panel open or closed.\n *\n * Note: this reducer interacts with the list view panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function blockInserterPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen ? false : state;\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value;\n\t}\n\treturn state;\n}\n\n/**\n * Reducer to set the list view panel open or closed.\n *\n * Note: this reducer interacts with the inserter panel reducer\n * to make sure that only one of the two panels is open at the same time.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n */\nexport function listViewPanel( state = false, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'SET_IS_INSERTER_OPENED':\n\t\t\treturn action.value ? false : state;\n\t\tcase 'SET_IS_LIST_VIEW_OPENED':\n\t\t\treturn action.isOpen;\n\t}\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the list view toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the list view toggle button.\n */\nexport function listViewToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.\n * We will have a unique ref per \"editor\" instance.\n *\n * @param {Object} state\n * @return {Object} Reference to the inserter sidebar toggle button.\n */\nexport function inserterSidebarToggleRef( state = { current: null } ) {\n\treturn state;\n}\n\n/**\n * Widget saving lock.\n *\n * When widget saving is locked, the widget cannot be updated.\n *\n * @param {Object} state Current state.\n * @param {Object} action Dispatched action.\n *\n * @return {Object} Updated state.\n */\nexport function widgetSavingLock( state = {}, action ) {\n\tswitch ( action.type ) {\n\t\tcase 'LOCK_WIDGET_SAVING':\n\t\t\treturn { ...state, [ action.lockName ]: true };\n\n\t\tcase 'UNLOCK_WIDGET_SAVING': {\n\t\t\tconst { [ action.lockName ]: removedLockName, ...restState } =\n\t\t\t\tstate;\n\t\t\treturn restState;\n\t\t}\n\t}\n\n\treturn state;\n}\n\nexport default combineReducers( {\n\tblockInserterPanel,\n\tinserterSidebarToggleRef,\n\tlistViewPanel,\n\tlistViewToggleRef,\n\twidgetAreasOpenState,\n\twidgetSavingLock,\n} );\n"],
5
+ "mappings": "AAGA,SAAS,uBAAuB;AAUzB,SAAS,qBAAsB,QAAQ,CAAC,GAAG,QAAS;AAC1D,QAAM,EAAE,KAAK,IAAI;AACjB,UAAS,MAAO;AAAA,IACf,KAAK,+BAA+B;AACnC,aAAO,OAAO;AAAA,IACf;AAAA,IACA,KAAK,2BAA2B;AAC/B,YAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,aAAO;AAAA,QACN,GAAG;AAAA,QACH,CAAE,QAAS,GAAG;AAAA,MACf;AAAA,IACD;AAAA,IACA,SAAS;AACR,aAAO;AAAA,IACR;AAAA,EACD;AACD;AAWO,SAAS,mBAAoB,QAAQ,OAAO,QAAS;AAC3D,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO,SAAS,QAAQ;AAAA,IAChC,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACR;AAWO,SAAS,cAAe,QAAQ,OAAO,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,OAAO,QAAQ,QAAQ;AAAA,IAC/B,KAAK;AACJ,aAAO,OAAO;AAAA,EAChB;AACA,SAAO;AACR;AASO,SAAS,kBAAmB,QAAQ,EAAE,SAAS,KAAK,GAAI;AAC9D,SAAO;AACR;AASO,SAAS,yBAA0B,QAAQ,EAAE,SAAS,KAAK,GAAI;AACrE,SAAO;AACR;AAYO,SAAS,iBAAkB,QAAQ,CAAC,GAAG,QAAS;AACtD,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK;AACJ,aAAO,EAAE,GAAG,OAAO,CAAE,OAAO,QAAS,GAAG,KAAK;AAAA,IAE9C,KAAK,wBAAwB;AAC5B,YAAM,EAAE,CAAE,OAAO,QAAS,GAAG,iBAAiB,GAAG,UAAU,IAC1D;AACD,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAEA,IAAO,kBAAQ,gBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -1,72 +1,56 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createBlock } from '@wordpress/blocks';
5
- import { store as coreStore } from '@wordpress/core-data';
6
-
7
- /**
8
- * Internal dependencies
9
- */
10
- import { persistStubPost, setWidgetAreasOpenState } from './actions';
11
- import { KIND, WIDGET_AREA_ENTITY_TYPE, buildWidgetsQuery, buildWidgetAreasQuery, buildWidgetAreaPostId, buildWidgetAreasPostId } from './utils';
12
- import { transformWidgetToBlock } from './transformers';
13
-
14
- /**
15
- * Creates a "stub" widgets post reflecting all available widget areas. The
16
- * post is meant as a convenient to only exists in runtime and should never be saved. It
17
- * enables a convenient way of editing the widgets by using a regular post editor.
18
- *
19
- * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.
20
- *
21
- * @return {Function} An action creator.
22
- */
23
- export const getWidgetAreas = () => async ({
24
- dispatch,
25
- registry
26
- }) => {
1
+ import { createBlock } from "@wordpress/blocks";
2
+ import { store as coreStore } from "@wordpress/core-data";
3
+ import { persistStubPost, setWidgetAreasOpenState } from "./actions";
4
+ import {
5
+ KIND,
6
+ WIDGET_AREA_ENTITY_TYPE,
7
+ buildWidgetsQuery,
8
+ buildWidgetAreasQuery,
9
+ buildWidgetAreaPostId,
10
+ buildWidgetAreasPostId
11
+ } from "./utils";
12
+ import { transformWidgetToBlock } from "./transformers";
13
+ const getWidgetAreas = () => async ({ dispatch, registry }) => {
27
14
  const query = buildWidgetAreasQuery();
28
15
  const widgetAreas = await registry.resolveSelect(coreStore).getEntityRecords(KIND, WIDGET_AREA_ENTITY_TYPE, query);
29
16
  const widgetAreaBlocks = [];
30
17
  const sortedWidgetAreas = widgetAreas.sort((a, b) => {
31
- if (a.id === 'wp_inactive_widgets') {
18
+ if (a.id === "wp_inactive_widgets") {
32
19
  return 1;
33
20
  }
34
- if (b.id === 'wp_inactive_widgets') {
21
+ if (b.id === "wp_inactive_widgets") {
35
22
  return -1;
36
23
  }
37
24
  return 0;
38
25
  });
39
26
  for (const widgetArea of sortedWidgetAreas) {
40
- widgetAreaBlocks.push(createBlock('core/widget-area', {
41
- id: widgetArea.id,
42
- name: widgetArea.name
43
- }));
27
+ widgetAreaBlocks.push(
28
+ createBlock("core/widget-area", {
29
+ id: widgetArea.id,
30
+ name: widgetArea.name
31
+ })
32
+ );
44
33
  if (!widgetArea.widgets.length) {
45
- // If this widget area has no widgets, it won't get a post setup by
46
- // the getWidgets resolver.
47
- dispatch(persistStubPost(buildWidgetAreaPostId(widgetArea.id), []));
34
+ dispatch(
35
+ persistStubPost(
36
+ buildWidgetAreaPostId(widgetArea.id),
37
+ []
38
+ )
39
+ );
48
40
  }
49
41
  }
50
42
  const widgetAreasOpenState = {};
51
43
  widgetAreaBlocks.forEach((widgetAreaBlock, index) => {
52
- // Defaults to open the first widget area.
53
44
  widgetAreasOpenState[widgetAreaBlock.clientId] = index === 0;
54
45
  });
55
46
  dispatch(setWidgetAreasOpenState(widgetAreasOpenState));
56
- dispatch(persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks));
47
+ dispatch(
48
+ persistStubPost(buildWidgetAreasPostId(), widgetAreaBlocks)
49
+ );
57
50
  };
58
-
59
- /**
60
- * Fetches all widgets from all widgets ares, and groups them by widget area Id.
61
- *
62
- * @return {Function} An action creator.
63
- */
64
- export const getWidgets = () => async ({
65
- dispatch,
66
- registry
67
- }) => {
51
+ const getWidgets = () => async ({ dispatch, registry }) => {
68
52
  const query = buildWidgetsQuery();
69
- const widgets = await registry.resolveSelect(coreStore).getEntityRecords('root', 'widget', query);
53
+ const widgets = await registry.resolveSelect(coreStore).getEntityRecords("root", "widget", query);
70
54
  const groupedBySidebar = {};
71
55
  for (const widget of widgets) {
72
56
  const block = transformWidgetToBlock(widget);
@@ -75,9 +59,17 @@ export const getWidgets = () => async ({
75
59
  }
76
60
  for (const sidebarId in groupedBySidebar) {
77
61
  if (groupedBySidebar.hasOwnProperty(sidebarId)) {
78
- // Persist the actual post containing the widget block
79
- dispatch(persistStubPost(buildWidgetAreaPostId(sidebarId), groupedBySidebar[sidebarId]));
62
+ dispatch(
63
+ persistStubPost(
64
+ buildWidgetAreaPostId(sidebarId),
65
+ groupedBySidebar[sidebarId]
66
+ )
67
+ );
80
68
  }
81
69
  }
82
70
  };
83
- //# sourceMappingURL=resolvers.js.map
71
+ export {
72
+ getWidgetAreas,
73
+ getWidgets
74
+ };
75
+ //# sourceMappingURL=resolvers.js.map
@@ -1 +1,7 @@
1
- {"version":3,"names":["createBlock","store","coreStore","persistStubPost","setWidgetAreasOpenState","KIND","WIDGET_AREA_ENTITY_TYPE","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","buildWidgetAreasPostId","transformWidgetToBlock","getWidgetAreas","dispatch","registry","query","widgetAreas","resolveSelect","getEntityRecords","widgetAreaBlocks","sortedWidgetAreas","sort","a","b","id","widgetArea","push","name","widgets","length","widgetAreasOpenState","forEach","widgetAreaBlock","index","clientId","getWidgets","groupedBySidebar","widget","block","sidebar","sidebarId","hasOwnProperty"],"sources":["@wordpress/edit-widgets/src/store/resolvers.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\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}\n\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"],"mappings":"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","ignoreList":[]}
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/store/resolvers.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { persistStubPost, setWidgetAreasOpenState } from './actions';\nimport {\n\tKIND,\n\tWIDGET_AREA_ENTITY_TYPE,\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasPostId,\n} from './utils';\nimport { transformWidgetToBlock } from './transformers';\n\n/**\n * Creates a \"stub\" widgets post reflecting all available widget areas. The\n * post is meant as a convenient to only exists in runtime and should never be saved. It\n * enables a convenient way of editing the widgets by using a regular post editor.\n *\n * Fetches all widgets from all widgets aras, converts them into blocks, and hydrates a new post with them.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgetAreas =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetAreasQuery();\n\t\tconst widgetAreas = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( KIND, WIDGET_AREA_ENTITY_TYPE, query );\n\n\t\tconst widgetAreaBlocks = [];\n\t\tconst sortedWidgetAreas = widgetAreas.sort( ( a, b ) => {\n\t\t\tif ( a.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tif ( b.id === 'wp_inactive_widgets' ) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t} );\n\t\tfor ( const widgetArea of sortedWidgetAreas ) {\n\t\t\twidgetAreaBlocks.push(\n\t\t\t\tcreateBlock( 'core/widget-area', {\n\t\t\t\t\tid: widgetArea.id,\n\t\t\t\t\tname: widgetArea.name,\n\t\t\t\t} )\n\t\t\t);\n\n\t\t\tif ( ! widgetArea.widgets.length ) {\n\t\t\t\t// If this widget area has no widgets, it won't get a post setup by\n\t\t\t\t// the getWidgets resolver.\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( widgetArea.id ),\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}\n\n\t\tconst widgetAreasOpenState = {};\n\t\twidgetAreaBlocks.forEach( ( widgetAreaBlock, index ) => {\n\t\t\t// Defaults to open the first widget area.\n\t\t\twidgetAreasOpenState[ widgetAreaBlock.clientId ] = index === 0;\n\t\t} );\n\t\tdispatch( setWidgetAreasOpenState( widgetAreasOpenState ) );\n\n\t\tdispatch(\n\t\t\tpersistStubPost( buildWidgetAreasPostId(), widgetAreaBlocks )\n\t\t);\n\t};\n\n/**\n * Fetches all widgets from all widgets ares, and groups them by widget area Id.\n *\n * @return {Function} An action creator.\n */\nexport const getWidgets =\n\t() =>\n\tasync ( { dispatch, registry } ) => {\n\t\tconst query = buildWidgetsQuery();\n\t\tconst widgets = await registry\n\t\t\t.resolveSelect( coreStore )\n\t\t\t.getEntityRecords( 'root', 'widget', query );\n\n\t\tconst groupedBySidebar = {};\n\n\t\tfor ( const widget of widgets ) {\n\t\t\tconst block = transformWidgetToBlock( widget );\n\t\t\tgroupedBySidebar[ widget.sidebar ] =\n\t\t\t\tgroupedBySidebar[ widget.sidebar ] || [];\n\t\t\tgroupedBySidebar[ widget.sidebar ].push( block );\n\t\t}\n\n\t\tfor ( const sidebarId in groupedBySidebar ) {\n\t\t\tif ( groupedBySidebar.hasOwnProperty( sidebarId ) ) {\n\t\t\t\t// Persist the actual post containing the widget block\n\t\t\t\tdispatch(\n\t\t\t\t\tpersistStubPost(\n\t\t\t\t\t\tbuildWidgetAreaPostId( sidebarId ),\n\t\t\t\t\t\tgroupedBySidebar[ sidebarId ]\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t};\n"],
5
+ "mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,iBAAiB,+BAA+B;AACzD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AAWhC,MAAM,iBACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,QAAQ,sBAAsB;AACpC,QAAM,cAAc,MAAM,SACxB,cAAe,SAAU,EACzB,iBAAkB,MAAM,yBAAyB,KAAM;AAEzD,QAAM,mBAAmB,CAAC;AAC1B,QAAM,oBAAoB,YAAY,KAAM,CAAE,GAAG,MAAO;AACvD,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,QAAK,EAAE,OAAO,uBAAwB;AACrC,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR,CAAE;AACF,aAAY,cAAc,mBAAoB;AAC7C,qBAAiB;AAAA,MAChB,YAAa,oBAAoB;AAAA,QAChC,IAAI,WAAW;AAAA,QACf,MAAM,WAAW;AAAA,MAClB,CAAE;AAAA,IACH;AAEA,QAAK,CAAE,WAAW,QAAQ,QAAS;AAGlC;AAAA,QACC;AAAA,UACC,sBAAuB,WAAW,EAAG;AAAA,UACrC,CAAC;AAAA,QACF;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAEA,QAAM,uBAAuB,CAAC;AAC9B,mBAAiB,QAAS,CAAE,iBAAiB,UAAW;AAEvD,yBAAsB,gBAAgB,QAAS,IAAI,UAAU;AAAA,EAC9D,CAAE;AACF,WAAU,wBAAyB,oBAAqB,CAAE;AAE1D;AAAA,IACC,gBAAiB,uBAAuB,GAAG,gBAAiB;AAAA,EAC7D;AACD;AAOM,MAAM,aACZ,MACA,OAAQ,EAAE,UAAU,SAAS,MAAO;AACnC,QAAM,QAAQ,kBAAkB;AAChC,QAAM,UAAU,MAAM,SACpB,cAAe,SAAU,EACzB,iBAAkB,QAAQ,UAAU,KAAM;AAE5C,QAAM,mBAAmB,CAAC;AAE1B,aAAY,UAAU,SAAU;AAC/B,UAAM,QAAQ,uBAAwB,MAAO;AAC7C,qBAAkB,OAAO,OAAQ,IAChC,iBAAkB,OAAO,OAAQ,KAAK,CAAC;AACxC,qBAAkB,OAAO,OAAQ,EAAE,KAAM,KAAM;AAAA,EAChD;AAEA,aAAY,aAAa,kBAAmB;AAC3C,QAAK,iBAAiB,eAAgB,SAAU,GAAI;AAEnD;AAAA,QACC;AAAA,UACC,sBAAuB,SAAU;AAAA,UACjC,iBAAkB,SAAU;AAAA,QAC7B;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }