@wordpress/edit-widgets 6.57.0 → 7.1.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 (195) hide show
  1. package/build/blocks/widget-area/edit/index.cjs +106 -116
  2. package/build/blocks/widget-area/edit/index.cjs.map +1 -7
  3. package/build/blocks/widget-area/edit/inner-blocks.cjs +44 -62
  4. package/build/blocks/widget-area/edit/inner-blocks.cjs.map +1 -7
  5. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs +41 -53
  6. package/build/blocks/widget-area/edit/use-is-dragging-within.cjs.map +1 -7
  7. package/build/blocks/widget-area/index.cjs +40 -44
  8. package/build/blocks/widget-area/index.cjs.map +1 -7
  9. package/build/components/error-boundary/index.cjs +115 -155
  10. package/build/components/error-boundary/index.cjs.map +1 -7
  11. package/build/components/header/document-tools/index.cjs +80 -115
  12. package/build/components/header/document-tools/index.cjs.map +1 -7
  13. package/build/components/header/index.cjs +72 -80
  14. package/build/components/header/index.cjs.map +1 -7
  15. package/build/components/header/undo-redo/redo.cjs +30 -52
  16. package/build/components/header/undo-redo/redo.cjs.map +1 -7
  17. package/build/components/header/undo-redo/undo.cjs +29 -51
  18. package/build/components/header/undo-redo/undo.cjs.map +1 -7
  19. package/build/components/keyboard-shortcut-help-modal/config.cjs +88 -85
  20. package/build/components/keyboard-shortcut-help-modal/config.cjs.map +1 -7
  21. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs +40 -57
  22. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.cjs.map +1 -7
  23. package/build/components/keyboard-shortcut-help-modal/index.cjs +94 -161
  24. package/build/components/keyboard-shortcut-help-modal/index.cjs.map +1 -7
  25. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs +37 -75
  26. package/build/components/keyboard-shortcut-help-modal/shortcut.cjs.map +1 -7
  27. package/build/components/keyboard-shortcuts/index.cjs +107 -140
  28. package/build/components/keyboard-shortcuts/index.cjs.map +1 -7
  29. package/build/components/layout/index.cjs +65 -74
  30. package/build/components/layout/index.cjs.map +1 -7
  31. package/build/components/layout/interface.cjs +82 -102
  32. package/build/components/layout/interface.cjs.map +1 -7
  33. package/build/components/layout/unsaved-changes-warning.cjs +44 -48
  34. package/build/components/layout/unsaved-changes-warning.cjs.map +1 -7
  35. package/build/components/more-menu/index.cjs +125 -191
  36. package/build/components/more-menu/index.cjs.map +1 -7
  37. package/build/components/more-menu/tools-more-menu-group.cjs +9 -29
  38. package/build/components/more-menu/tools-more-menu-group.cjs.map +1 -7
  39. package/build/components/notices/index.cjs +19 -39
  40. package/build/components/notices/index.cjs.map +1 -7
  41. package/build/components/save-button/index.cjs +31 -58
  42. package/build/components/save-button/index.cjs.map +1 -7
  43. package/build/components/secondary-sidebar/index.cjs +38 -45
  44. package/build/components/secondary-sidebar/index.cjs.map +1 -7
  45. package/build/components/secondary-sidebar/inserter-sidebar.cjs +50 -51
  46. package/build/components/secondary-sidebar/inserter-sidebar.cjs.map +1 -7
  47. package/build/components/secondary-sidebar/list-view-sidebar.cjs +51 -82
  48. package/build/components/secondary-sidebar/list-view-sidebar.cjs.map +1 -7
  49. package/build/components/sidebar/index.cjs +117 -180
  50. package/build/components/sidebar/index.cjs.map +1 -7
  51. package/build/components/sidebar/widget-areas.cjs +43 -85
  52. package/build/components/sidebar/widget-areas.cjs.map +1 -7
  53. package/build/components/welcome-guide/index.cjs +110 -186
  54. package/build/components/welcome-guide/index.cjs.map +1 -7
  55. package/build/components/widget-areas-block-editor-content/index.cjs +59 -63
  56. package/build/components/widget-areas-block-editor-content/index.cjs.map +1 -7
  57. package/build/components/widget-areas-block-editor-provider/index.cjs +105 -140
  58. package/build/components/widget-areas-block-editor-provider/index.cjs.map +1 -7
  59. package/build/constants.cjs +11 -32
  60. package/build/constants.cjs.map +1 -7
  61. package/build/filters/index.cjs +7 -4
  62. package/build/filters/move-to-widget-area.cjs +38 -53
  63. package/build/filters/move-to-widget-area.cjs.map +1 -7
  64. package/build/filters/replace-media-upload.cjs +11 -9
  65. package/build/filters/replace-media-upload.cjs.map +1 -7
  66. package/build/hooks/use-last-selected-widget-area.cjs +28 -49
  67. package/build/hooks/use-last-selected-widget-area.cjs.map +1 -7
  68. package/build/hooks/use-widget-library-insertion-point.cjs +33 -67
  69. package/build/hooks/use-widget-library-insertion-point.cjs.map +1 -7
  70. package/build/index.cjs +96 -97
  71. package/build/index.cjs.map +1 -7
  72. package/build/lock-unlock.cjs +10 -35
  73. package/build/lock-unlock.cjs.map +1 -7
  74. package/build/store/actions.cjs +269 -278
  75. package/build/store/actions.cjs.map +1 -7
  76. package/build/store/constants.cjs +12 -29
  77. package/build/store/constants.cjs.map +1 -7
  78. package/build/store/index.cjs +61 -52
  79. package/build/store/index.cjs.map +1 -7
  80. package/build/store/private-selectors.cjs +11 -32
  81. package/build/store/private-selectors.cjs.map +1 -7
  82. package/build/store/reducer.cjs +107 -88
  83. package/build/store/reducer.cjs.map +1 -7
  84. package/build/store/resolvers.cjs +60 -91
  85. package/build/store/resolvers.cjs.map +1 -7
  86. package/build/store/selectors.cjs +196 -229
  87. package/build/store/selectors.cjs.map +1 -7
  88. package/build/store/transformers.cjs +51 -82
  89. package/build/store/transformers.cjs.map +1 -7
  90. package/build/store/utils.cjs +76 -63
  91. package/build/store/utils.cjs.map +1 -7
  92. package/build-module/blocks/widget-area/edit/index.mjs +82 -94
  93. package/build-module/blocks/widget-area/edit/index.mjs.map +1 -7
  94. package/build-module/blocks/widget-area/edit/inner-blocks.mjs +19 -35
  95. package/build-module/blocks/widget-area/edit/inner-blocks.mjs.map +1 -7
  96. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs +36 -33
  97. package/build-module/blocks/widget-area/edit/use-is-dragging-within.mjs.map +1 -7
  98. package/build-module/blocks/widget-area/index.mjs +12 -15
  99. package/build-module/blocks/widget-area/index.mjs.map +1 -7
  100. package/build-module/components/error-boundary/index.mjs +103 -128
  101. package/build-module/components/error-boundary/index.mjs.map +1 -7
  102. package/build-module/components/header/document-tools/index.mjs +51 -84
  103. package/build-module/components/header/document-tools/index.mjs.map +1 -7
  104. package/build-module/components/header/index.mjs +40 -47
  105. package/build-module/components/header/index.mjs.map +1 -7
  106. package/build-module/components/header/undo-redo/redo.mjs +20 -27
  107. package/build-module/components/header/undo-redo/redo.mjs.map +1 -7
  108. package/build-module/components/header/undo-redo/undo.mjs +19 -26
  109. package/build-module/components/header/undo-redo/undo.mjs.map +1 -7
  110. package/build-module/components/keyboard-shortcut-help-modal/config.mjs +83 -61
  111. package/build-module/components/keyboard-shortcut-help-modal/config.mjs.map +1 -7
  112. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs +19 -33
  113. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.mjs.map +1 -7
  114. package/build-module/components/keyboard-shortcut-help-modal/index.mjs +67 -136
  115. package/build-module/components/keyboard-shortcut-help-modal/index.mjs.map +1 -7
  116. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs +31 -54
  117. package/build-module/components/keyboard-shortcut-help-modal/shortcut.mjs.map +1 -7
  118. package/build-module/components/keyboard-shortcuts/index.mjs +99 -119
  119. package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -7
  120. package/build-module/components/layout/index.mjs +29 -40
  121. package/build-module/components/layout/index.mjs.map +1 -7
  122. package/build-module/components/layout/interface.mjs +53 -76
  123. package/build-module/components/layout/interface.mjs.map +1 -7
  124. package/build-module/components/layout/unsaved-changes-warning.mjs +37 -26
  125. package/build-module/components/layout/unsaved-changes-warning.mjs.map +1 -7
  126. package/build-module/components/more-menu/index.mjs +95 -162
  127. package/build-module/components/more-menu/index.mjs.map +1 -7
  128. package/build-module/components/more-menu/tools-more-menu-group.mjs +5 -9
  129. package/build-module/components/more-menu/tools-more-menu-group.mjs.map +1 -7
  130. package/build-module/components/notices/index.mjs +12 -17
  131. package/build-module/components/notices/index.mjs.map +1 -7
  132. package/build-module/components/save-button/index.mjs +23 -35
  133. package/build-module/components/save-button/index.mjs.map +1 -7
  134. package/build-module/components/secondary-sidebar/index.mjs +15 -20
  135. package/build-module/components/secondary-sidebar/index.mjs.map +1 -7
  136. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs +27 -25
  137. package/build-module/components/secondary-sidebar/inserter-sidebar.mjs.map +1 -7
  138. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs +39 -55
  139. package/build-module/components/secondary-sidebar/list-view-sidebar.mjs.map +1 -7
  140. package/build-module/components/sidebar/index.mjs +96 -162
  141. package/build-module/components/sidebar/index.mjs.map +1 -7
  142. package/build-module/components/sidebar/widget-areas.mjs +30 -57
  143. package/build-module/components/sidebar/widget-areas.mjs.map +1 -7
  144. package/build-module/components/welcome-guide/index.mjs +103 -164
  145. package/build-module/components/welcome-guide/index.mjs.map +1 -7
  146. package/build-module/components/widget-areas-block-editor-content/index.mjs +35 -44
  147. package/build-module/components/widget-areas-block-editor-content/index.mjs.map +1 -7
  148. package/build-module/components/widget-areas-block-editor-provider/index.mjs +76 -109
  149. package/build-module/components/widget-areas-block-editor-provider/index.mjs.map +1 -7
  150. package/build-module/constants.mjs +5 -7
  151. package/build-module/constants.mjs.map +1 -7
  152. package/build-module/filters/index.mjs +0 -2
  153. package/build-module/filters/move-to-widget-area.mjs +28 -48
  154. package/build-module/filters/move-to-widget-area.mjs.map +1 -7
  155. package/build-module/filters/replace-media-upload.mjs +5 -8
  156. package/build-module/filters/replace-media-upload.mjs.map +1 -7
  157. package/build-module/hooks/use-last-selected-widget-area.mjs +23 -29
  158. package/build-module/hooks/use-last-selected-widget-area.mjs.map +1 -7
  159. package/build-module/hooks/use-widget-library-insertion-point.mjs +28 -47
  160. package/build-module/hooks/use-widget-library-insertion-point.mjs.map +1 -7
  161. package/build-module/index.mjs +62 -79
  162. package/build-module/index.mjs.map +1 -7
  163. package/build-module/lock-unlock.mjs +5 -10
  164. package/build-module/lock-unlock.mjs.map +1 -7
  165. package/build-module/store/actions.mjs +250 -247
  166. package/build-module/store/actions.mjs.map +1 -7
  167. package/build-module/store/constants.mjs +7 -5
  168. package/build-module/store/constants.mjs.map +1 -7
  169. package/build-module/store/index.mjs +18 -16
  170. package/build-module/store/index.mjs.map +1 -7
  171. package/build-module/store/private-selectors.mjs +5 -7
  172. package/build-module/store/private-selectors.mjs.map +1 -7
  173. package/build-module/store/reducer.mjs +95 -58
  174. package/build-module/store/reducer.mjs.map +1 -7
  175. package/build-module/store/resolvers.mjs +52 -71
  176. package/build-module/store/resolvers.mjs.map +1 -7
  177. package/build-module/store/selectors.mjs +178 -199
  178. package/build-module/store/selectors.mjs.map +1 -7
  179. package/build-module/store/transformers.mjs +44 -56
  180. package/build-module/store/transformers.mjs.map +1 -7
  181. package/build-module/store/utils.mjs +64 -32
  182. package/build-module/store/utils.mjs.map +1 -7
  183. package/build-style/style-rtl.css +12 -12
  184. package/build-style/style.css +12 -12
  185. package/package.json +35 -36
  186. package/src/components/header/index.jsx +2 -2
  187. package/src/components/layout/interface.jsx +4 -1
  188. package/src/components/layout/style.scss +11 -0
  189. package/src/components/notices/style.scss +2 -2
  190. package/src/components/sidebar/index.jsx +18 -18
  191. package/src/components/welcome-guide/index.jsx +4 -2
  192. package/src/components/widget-areas-block-editor-content/index.jsx +4 -3
  193. package/CHANGELOG.md +0 -325
  194. package/build/filters/index.cjs.map +0 -7
  195. package/build-module/filters/index.mjs.map +0 -7
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/blocks/widget-area/index.js"],
4
- "sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\ticon,\n\tedit,\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,+BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,kBAAmB;AACnB,mBAA+B;AAC/B,mBAAqB;AACrB,kBAAiB;AAEjB,IAAM,EAAE,KAAK,IAAI,aAAAA;AAGV,IAAM,WAAW;AAAA,EACvB,WAAO,gBAAI,aAAc;AAAA,EACzB,iBAAa,gBAAI,0BAA2B;AAAA,EAC5C,qBAAqB,CAAE,EAAE,MAAM,MAAM,MAAO;AAAA,EAC5C,mBAAAC;AAAA,EACA,kBAAAC;AACD;",
6
- "names": ["metadata", "icon", "edit"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["metadata","__"],"sources":["../../../src/blocks/widget-area/index.js"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { layout as icon } from '@wordpress/icons';\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ttitle: __( 'Widget Area' ),\n\tdescription: __( 'A widget area container.' ),\n\t__experimentalLabel: ( { name: label } ) => label,\n\ticon,\n\tedit,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,EAAE,SAASA,aAAAA;AAGjB,MAAa,WAAW;CACvB,QAAA,GAAOC,gBAAAA,GAAAA,CAAI,aAAc;CACzB,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,0BAA2B;CAC5C,sBAAuB,EAAE,MAAM,YAAa;CAC5C,MAAA,iBAAA;CACA,MAAA,iBAAA;AACD"}
@@ -1,173 +1,133 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // packages/edit-widgets/src/components/error-boundary/index.jsx
20
- var error_boundary_exports = {};
21
- __export(error_boundary_exports, {
22
- default: () => ErrorBoundary
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
23
5
  });
24
- module.exports = __toCommonJS(error_boundary_exports);
25
- var import_element = require("@wordpress/element");
26
- var import_a11y = require("@wordpress/a11y");
27
- var import_i18n = require("@wordpress/i18n");
28
- var import_ui = require("@wordpress/ui");
29
- var import_compose = require("@wordpress/compose");
30
- var import_hooks = require("@wordpress/hooks");
31
- var import_jsx_runtime = require("react/jsx-runtime");
6
+ let _wordpress_element = require("@wordpress/element");
7
+ let _wordpress_a11y = require("@wordpress/a11y");
8
+ let _wordpress_i18n = require("@wordpress/i18n");
9
+ let _wordpress_ui = require("@wordpress/ui");
10
+ let _wordpress_compose = require("@wordpress/compose");
11
+ let _wordpress_hooks = require("@wordpress/hooks");
12
+ let react_jsx_runtime = require("react/jsx-runtime");
13
+ // packages/edit-widgets/src/components/error-boundary/index.jsx
32
14
  function getErrorNotice() {
33
- return {
34
- title: (0, import_i18n.__)("The editor has crashed"),
35
- description: (0, import_i18n.__)(
36
- "An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search."
37
- )
38
- };
15
+ return {
16
+ title: (0, _wordpress_i18n.__)("The editor has crashed"),
17
+ description: (0, _wordpress_i18n.__)("An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.")
18
+ };
39
19
  }
40
20
  function getErrorName(error) {
41
- return error instanceof Error && error.name || "Error";
21
+ return error instanceof Error && error.name || "Error";
42
22
  }
43
23
  function getErrorMessage(error) {
44
- if (typeof error === "string" && error) {
45
- return error;
46
- }
47
- if (typeof error?.message === "string" && error.message) {
48
- return error.message;
49
- }
50
- return "An unknown error occurred.";
24
+ if (typeof error === "string" && error) return error;
25
+ if (typeof error?.message === "string" && error.message) return error.message;
26
+ return "An unknown error occurred.";
51
27
  }
52
28
  function getErrorSections(error, componentStack) {
53
- const sections = [
54
- { label: getErrorName(error), content: getErrorMessage(error) }
55
- ];
56
- if (error?.stack) {
57
- sections.push({
58
- label: "Stack",
59
- content: error.stack.trim(),
60
- preformatted: true
61
- });
62
- }
63
- if (componentStack) {
64
- sections.push({
65
- label: "Component stack",
66
- content: componentStack.trim(),
67
- preformatted: true
68
- });
69
- }
70
- sections.push({
71
- label: "Environment",
72
- content: `User agent: ${window.navigator.userAgent}`,
73
- preformatted: true
74
- });
75
- return sections;
29
+ const sections = [{
30
+ label: getErrorName(error),
31
+ content: getErrorMessage(error)
32
+ }];
33
+ if (error?.stack) sections.push({
34
+ label: "Stack",
35
+ content: error.stack.trim(),
36
+ preformatted: true
37
+ });
38
+ if (componentStack) sections.push({
39
+ label: "Component stack",
40
+ content: componentStack.trim(),
41
+ preformatted: true
42
+ });
43
+ sections.push({
44
+ label: "Environment",
45
+ content: `User agent: ${window.navigator.userAgent}`,
46
+ preformatted: true
47
+ });
48
+ return sections;
76
49
  }
77
50
  function getErrorReport(error, componentStack) {
78
- const sections = getErrorSections(error, componentStack).map(
79
- ({ label, content, preformatted }) => `**${label}**
80
-
81
- ${preformatted ? `\`\`\`
82
- ${content}
83
- \`\`\`` : content}`
84
- );
85
- return ["### Error report", ...sections].join("\n\n");
51
+ return ["### Error report", ...getErrorSections(error, componentStack).map(({ label, content, preformatted }) => `**${label}**\n\n${preformatted ? `\`\`\`\n${content}\n\`\`\`` : content}`)].join("\n\n");
86
52
  }
87
53
  function CopyButton({ text, children, variant = "outline" }) {
88
- const ref = (0, import_compose.useCopyToClipboard)(text);
89
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.ActionButton, { variant, ref, children });
54
+ const ref = (0, _wordpress_compose.useCopyToClipboard)(text);
55
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.ActionButton, {
56
+ variant,
57
+ ref,
58
+ children
59
+ });
90
60
  }
91
61
  function ErrorReport({ error, componentStack }) {
92
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
93
- import_ui.Stack,
94
- {
95
- className: "edit-widgets-error-boundary__report",
96
- direction: "column",
97
- gap: "md",
98
- children: getErrorSections(error, componentStack).map(
99
- ({ label, content }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "xs", children: [
100
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, { variant: "heading-md", children: label }),
101
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "edit-widgets-error-boundary__report-section", children: content })
102
- ] }, label)
103
- )
104
- }
105
- );
62
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Stack, {
63
+ className: "edit-widgets-error-boundary__report",
64
+ direction: "column",
65
+ gap: "md",
66
+ children: getErrorSections(error, componentStack).map(({ label, content }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
67
+ direction: "column",
68
+ gap: "xs",
69
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Text, {
70
+ variant: "heading-md",
71
+ children: label
72
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
73
+ className: "edit-widgets-error-boundary__report-section",
74
+ children: content
75
+ })]
76
+ }, label))
77
+ });
106
78
  }
107
79
  function ErrorDetails({ error, componentStack }) {
108
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.CollapsibleCard.Root, { className: "edit-widgets-error-boundary__details", children: [
109
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.CollapsibleCard.Header, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Card.Title, { children: (0, import_i18n.__)("Error details") }) }),
110
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.CollapsibleCard.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
111
- ErrorReport,
112
- {
113
- error,
114
- componentStack
115
- }
116
- ) })
117
- ] });
80
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.CollapsibleCard.Root, {
81
+ className: "edit-widgets-error-boundary__details",
82
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.CollapsibleCard.Header, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Card.Title, { children: (0, _wordpress_i18n.__)("Error details") }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.CollapsibleCard.Content, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorReport, {
83
+ error,
84
+ componentStack
85
+ }) })]
86
+ });
118
87
  }
119
- var ErrorBoundary = class extends import_element.Component {
120
- constructor() {
121
- super(...arguments);
122
- this.state = {
123
- error: null,
124
- componentStack: null
125
- };
126
- }
127
- componentDidCatch(error, errorInfo) {
128
- const { title, description } = getErrorNotice();
129
- (0, import_a11y.speak)(`${title}. ${description}`, "assertive");
130
- this.setState({ componentStack: errorInfo?.componentStack });
131
- (0, import_hooks.doAction)("editor.ErrorBoundary.errorLogged", error, errorInfo);
132
- }
133
- static getDerivedStateFromError(error) {
134
- return { error };
135
- }
136
- render() {
137
- const { error, componentStack } = this.state;
138
- if (!error) {
139
- return this.props.children;
140
- }
141
- const { title, description } = getErrorNotice();
142
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
143
- import_ui.Stack,
144
- {
145
- className: "edit-widgets-error-boundary",
146
- direction: "column",
147
- gap: "lg",
148
- children: [
149
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Notice.Root, { intent: "error", children: [
150
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Title, { children: title }),
151
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Description, { children: description }),
152
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Notice.Actions, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
- CopyButton,
154
- {
155
- variant: "solid",
156
- text: () => getErrorReport(error, componentStack),
157
- children: (0, import_i18n.__)("Copy error")
158
- }
159
- ) })
160
- ] }),
161
- globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
162
- ErrorDetails,
163
- {
164
- error,
165
- componentStack
166
- }
167
- ) : null
168
- ]
169
- }
170
- );
171
- }
88
+ var ErrorBoundary = class extends _wordpress_element.Component {
89
+ constructor() {
90
+ super(...arguments);
91
+ this.state = {
92
+ error: null,
93
+ componentStack: null
94
+ };
95
+ }
96
+ componentDidCatch(error, errorInfo) {
97
+ const { title, description } = getErrorNotice();
98
+ (0, _wordpress_a11y.speak)(`${title}. ${description}`, "assertive");
99
+ this.setState({ componentStack: errorInfo?.componentStack });
100
+ (0, _wordpress_hooks.doAction)("editor.ErrorBoundary.errorLogged", error, errorInfo);
101
+ }
102
+ static getDerivedStateFromError(error) {
103
+ return { error };
104
+ }
105
+ render() {
106
+ const { error, componentStack } = this.state;
107
+ if (!error) return this.props.children;
108
+ const { title, description } = getErrorNotice();
109
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
110
+ className: "edit-widgets-error-boundary",
111
+ direction: "column",
112
+ gap: "lg",
113
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Notice.Root, {
114
+ intent: "error",
115
+ children: [
116
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Title, { children: title }),
117
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Description, { children: description }),
118
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Actions, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyButton, {
119
+ variant: "solid",
120
+ text: () => getErrorReport(error, componentStack),
121
+ children: (0, _wordpress_i18n.__)("Copy error")
122
+ }) })
123
+ ]
124
+ }), globalThis.SCRIPT_DEBUG ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ErrorDetails, {
125
+ error,
126
+ componentStack
127
+ }) : null]
128
+ });
129
+ }
172
130
  };
173
- //# sourceMappingURL=index.cjs.map
131
+ exports.default = ErrorBoundary;
132
+
133
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/error-boundary/index.jsx"],
4
- "sourcesContent": ["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t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;AACb,UAAO,GAAG,SAAU;AAEpB,SAAK,QAAQ;AAAA,MACZ,OAAO;AAAA,MACP,gBAAgB;AAAA,IACjB;AAAA,EACD;AAAA,EAEA,kBAAmB,OAAO,WAAY;AACrC,UAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAC9C,2BAAO,GAAI,KAAM,KAAM,WAAY,IAAI,WAAY;AACnD,SAAK,SAAU,EAAE,gBAAgB,WAAW,eAAe,CAAE;AAC7D,+BAAU,oCAAoC,OAAO,SAAU;AAAA,EAChE;AAAA,EAEA,OAAO,yBAA0B,OAAQ;AACxC,WAAO,EAAE,MAAM;AAAA,EAChB;AAAA,EAEA,SAAS;AACR,UAAM,EAAE,OAAO,eAAe,IAAI,KAAK;AACvC,QAAK,CAAE,OAAQ;AACd,aAAO,KAAK,MAAM;AAAA,IACnB;AAEA,UAAM,EAAE,OAAO,YAAY,IAAI,eAAe;AAE9C,WACC;AAAA,MAAC;AAAA;AAAA,QACA,WAAU;AAAA,QACV,WAAU;AAAA,QACV,KAAI;AAAA,QAEJ;AAAA,uDAAC,iBAAO,MAAP,EAAY,QAAO,SACnB;AAAA,wDAAC,iBAAO,OAAP,EAAe,iBAAO;AAAA,YACvB,4CAAC,iBAAO,aAAP,EAAqB,uBAAa;AAAA,YACnC,4CAAC,iBAAO,SAAP,EACA;AAAA,cAAC;AAAA;AAAA,gBACA,SAAQ;AAAA,gBACR,MAAO,MACN,eAAgB,OAAO,cAAe;AAAA,gBAGrC,8BAAI,YAAa;AAAA;AAAA,YACpB,GACD;AAAA,aACD;AAAA,UACE,WAAW,eACZ;AAAA,YAAC;AAAA;AAAA,cACA;AAAA,cACA;AAAA;AAAA,UACD,IACG;AAAA;AAAA;AAAA,IACL;AAAA,EAEF;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.cjs","names":["__","useCopyToClipboard","Notice","Stack","Text","CollapsibleCard","Card","Component"],"sources":["../../../src/components/error-boundary/index.jsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { __ } from '@wordpress/i18n';\nimport { Card, CollapsibleCard, Notice, Stack, Text } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { doAction } from '@wordpress/hooks';\n\nfunction getErrorNotice() {\n\treturn {\n\t\ttitle: __( 'The editor has crashed' ),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A boundary catches whatever was thrown, which is not always an `Error`.\nfunction getErrorName( error ) {\n\treturn ( error instanceof Error && error.name ) || 'Error';\n}\n\nfunction getErrorMessage( error ) {\n\tif ( typeof error === 'string' && error ) {\n\t\treturn error;\n\t}\n\n\tif ( typeof error?.message === 'string' && error.message ) {\n\t\treturn error.message;\n\t}\n\n\treturn 'An unknown error occurred.';\n}\n\n// The sections of the report, shared by the copied Markdown and the details\n// panel so that the two cannot drift apart. Deliberately untranslated: both\n// are developer-facing, and the report is pasted into a bug report.\nfunction getErrorSections( error, componentStack ) {\n\tconst sections = [\n\t\t{ label: getErrorName( error ), content: getErrorMessage( error ) },\n\t];\n\n\tif ( error?.stack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Stack',\n\t\t\tcontent: error.stack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tif ( componentStack ) {\n\t\tsections.push( {\n\t\t\tlabel: 'Component stack',\n\t\t\tcontent: componentStack.trim(),\n\t\t\tpreformatted: true,\n\t\t} );\n\t}\n\n\tsections.push( {\n\t\tlabel: 'Environment',\n\t\tcontent: `User agent: ${ window.navigator.userAgent }`,\n\t\tpreformatted: true,\n\t} );\n\n\treturn sections;\n}\n\n// Markdown, so the report stays readable as plain text and renders when pasted\n// into a bug report.\nfunction getErrorReport( error, componentStack ) {\n\tconst sections = getErrorSections( error, componentStack ).map(\n\t\t( { label, content, preformatted } ) =>\n\t\t\t`**${ label }**\\n\\n${\n\t\t\t\tpreformatted ? `\\`\\`\\`\\n${ content }\\n\\`\\`\\`` : content\n\t\t\t}`\n\t);\n\n\treturn [ '### Error report', ...sections ].join( '\\n\\n' );\n}\n\nfunction CopyButton( { text, children, variant = 'outline' } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Notice.ActionButton variant={ variant } ref={ ref }>\n\t\t\t{ children }\n\t\t</Notice.ActionButton>\n\t);\n}\n\nfunction ErrorReport( { error, componentStack } ) {\n\treturn (\n\t\t<Stack\n\t\t\tclassName=\"edit-widgets-error-boundary__report\"\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t>\n\t\t\t{ getErrorSections( error, componentStack ).map(\n\t\t\t\t( { label, content } ) => (\n\t\t\t\t\t<Stack key={ label } direction=\"column\" gap=\"xs\">\n\t\t\t\t\t\t<Text variant=\"heading-md\">{ label }</Text>\n\t\t\t\t\t\t<pre className=\"edit-widgets-error-boundary__report-section\">\n\t\t\t\t\t\t\t{ content }\n\t\t\t\t\t\t</pre>\n\t\t\t\t\t</Stack>\n\t\t\t\t)\n\t\t\t) }\n\t\t</Stack>\n\t);\n}\n\nfunction ErrorDetails( { error, componentStack } ) {\n\treturn (\n\t\t<CollapsibleCard.Root className=\"edit-widgets-error-boundary__details\">\n\t\t\t<CollapsibleCard.Header>\n\t\t\t\t<Card.Title>{ __( 'Error details' ) }</Card.Title>\n\t\t\t</CollapsibleCard.Header>\n\t\t\t<CollapsibleCard.Content>\n\t\t\t\t<ErrorReport\n\t\t\t\t\terror={ error }\n\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t/>\n\t\t\t</CollapsibleCard.Content>\n\t\t</CollapsibleCard.Root>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t\tcomponentStack: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error, errorInfo ) {\n\t\tconst { title, description } = getErrorNotice();\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t\tthis.setState( { componentStack: errorInfo?.componentStack } );\n\t\tdoAction( 'editor.ErrorBoundary.errorLogged', error, errorInfo );\n\t}\n\n\tstatic getDerivedStateFromError( error ) {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error, componentStack } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\tconst { title, description } = getErrorNotice();\n\n\t\treturn (\n\t\t\t<Stack\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tdirection=\"column\"\n\t\t\t\tgap=\"lg\"\n\t\t\t>\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t\t<Notice.Actions>\n\t\t\t\t\t\t<CopyButton\n\t\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\t\ttext={ () =>\n\t\t\t\t\t\t\t\tgetErrorReport( error, componentStack )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy error' ) }\n\t\t\t\t\t\t</CopyButton>\n\t\t\t\t\t</Notice.Actions>\n\t\t\t\t</Notice.Root>\n\t\t\t\t{ globalThis.SCRIPT_DEBUG ? (\n\t\t\t\t\t<ErrorDetails\n\t\t\t\t\t\terror={ error }\n\t\t\t\t\t\tcomponentStack={ componentStack }\n\t\t\t\t\t/>\n\t\t\t\t) : null }\n\t\t\t</Stack>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAOA,SAAS,iBAAiB;CACzB,OAAO;EACN,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,wBAAyB;EACpC,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,iHACD;CACD;AACD;AAGA,SAAS,aAAc,OAAQ;CAC9B,OAAS,iBAAiB,SAAS,MAAM,QAAU;AACpD;AAEA,SAAS,gBAAiB,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AAM;EAGnB,MAAM,EAAE,OAAO,gBAAgB,eAAe;EAE9C,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACJ,cAAAA,OAAD;GACC,WAAU;GACV,WAAU;GACV,KAAI;GAHL,UAAA,CAKC,iBAAA,GAAA,kBAAA,KAAA,CAACD,cAAAA,OAAO,MAAR;IAAa,QAAO;IAApB,UAAA;KACC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,OAAR,EAAA,UAAgB,MAAqB,CAAA;KACrC,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,aAAR,EAAA,UAAsB,YAAiC,CAAA;KACvD,iBAAA,GAAA,kBAAA,IAAA,CAACA,cAAAA,OAAO,SAAR,EAAA,UACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,YAAD;MACC,SAAQ;MACR,YACC,eAAgB,OAAO,cAAe;MAGrCF,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,YAAa;KACR,CAAA,EACG,CAAA;IACJ;GACX,CAAA,GAAA,WAAW,eACZ,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD;IACS;IACS;GACjB,CAAA,IACE,IACE;;CAET;AACD"}
@@ -1,126 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ // \0rolldown/runtime.js
1
7
  var __create = Object.create;
2
8
  var __defProp = Object.defineProperty;
3
9
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
10
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
11
  var __getProtoOf = Object.getPrototypeOf;
6
12
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
13
  var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
14
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
15
+ key = keys[i];
16
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: ((k) => from[k]).bind(null, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
18
22
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
27
+ let _wordpress_data = require("@wordpress/data");
28
+ let _wordpress_i18n = require("@wordpress/i18n");
29
+ let _wordpress_components = require("@wordpress/components");
30
+ let _wordpress_block_editor = require("@wordpress/block-editor");
31
+ let _wordpress_icons = require("@wordpress/icons");
32
+ let _wordpress_element = require("@wordpress/element");
33
+ let _wordpress_compose = require("@wordpress/compose");
34
+ let ___undo_redo_undo_jsx = require("../undo-redo/undo.cjs");
35
+ ___undo_redo_undo_jsx = __toESM(___undo_redo_undo_jsx);
36
+ let ___undo_redo_redo_jsx = require("../undo-redo/redo.cjs");
37
+ ___undo_redo_redo_jsx = __toESM(___undo_redo_redo_jsx);
38
+ let _________store_index_js = require("../../../store/index.cjs");
39
+ let _________lock_unlock_js = require("../../../lock-unlock.cjs");
40
+ let react_jsx_runtime = require("react/jsx-runtime");
29
41
  // packages/edit-widgets/src/components/header/document-tools/index.jsx
30
- var document_tools_exports = {};
31
- __export(document_tools_exports, {
32
- default: () => document_tools_default
33
- });
34
- module.exports = __toCommonJS(document_tools_exports);
35
- var import_data = require("@wordpress/data");
36
- var import_i18n = require("@wordpress/i18n");
37
- var import_components = require("@wordpress/components");
38
- var import_block_editor = require("@wordpress/block-editor");
39
- var import_icons = require("@wordpress/icons");
40
- var import_element = require("@wordpress/element");
41
- var import_compose = require("@wordpress/compose");
42
- var import_undo = __toESM(require("../undo-redo/undo.cjs"));
43
- var import_redo = __toESM(require("../undo-redo/redo.cjs"));
44
- var import_store = require("../../../store/index.cjs");
45
- var import_lock_unlock = require("../../../lock-unlock.cjs");
46
- var import_jsx_runtime = require("react/jsx-runtime");
47
42
  function DocumentTools() {
48
- const isMediumViewport = (0, import_compose.useViewportMatch)("medium");
49
- const {
50
- isInserterOpen,
51
- isListViewOpen,
52
- inserterSidebarToggleRef,
53
- listViewToggleRef
54
- } = (0, import_data.useSelect)((select) => {
55
- const {
56
- isInserterOpened,
57
- getInserterSidebarToggleRef,
58
- isListViewOpened,
59
- getListViewToggleRef
60
- } = (0, import_lock_unlock.unlock)(select(import_store.store));
61
- return {
62
- isInserterOpen: isInserterOpened(),
63
- isListViewOpen: isListViewOpened(),
64
- inserterSidebarToggleRef: getInserterSidebarToggleRef(),
65
- listViewToggleRef: getListViewToggleRef()
66
- };
67
- }, []);
68
- const { setIsInserterOpened, setIsListViewOpened } = (0, import_data.useDispatch)(import_store.store);
69
- const toggleListView = (0, import_element.useCallback)(
70
- () => setIsListViewOpened(!isListViewOpen),
71
- [setIsListViewOpened, isListViewOpen]
72
- );
73
- const toggleInserterSidebar = (0, import_element.useCallback)(
74
- () => setIsInserterOpened(!isInserterOpen),
75
- [setIsInserterOpened, isInserterOpen]
76
- );
77
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
78
- import_block_editor.NavigableToolbar,
79
- {
80
- className: "edit-widgets-header-toolbar",
81
- "aria-label": (0, import_i18n.__)("Document tools"),
82
- variant: "unstyled",
83
- children: [
84
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
- import_components.ToolbarItem,
86
- {
87
- ref: inserterSidebarToggleRef,
88
- as: import_components.Button,
89
- className: "edit-widgets-header-toolbar__inserter-toggle",
90
- variant: "primary",
91
- isPressed: isInserterOpen,
92
- onMouseDown: (event) => {
93
- event.preventDefault();
94
- },
95
- onClick: toggleInserterSidebar,
96
- icon: import_icons.plus,
97
- label: (0, import_i18n._x)(
98
- "Block Inserter",
99
- "Generic label for block inserter button"
100
- ),
101
- size: "compact"
102
- }
103
- ),
104
- isMediumViewport && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
105
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarItem, { as: import_undo.default }),
106
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.ToolbarItem, { as: import_redo.default }),
107
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
108
- import_components.ToolbarItem,
109
- {
110
- as: import_components.Button,
111
- className: "edit-widgets-header-toolbar__list-view-toggle",
112
- icon: import_icons.listView,
113
- isPressed: isListViewOpen,
114
- label: (0, import_i18n.__)("List View"),
115
- onClick: toggleListView,
116
- ref: listViewToggleRef,
117
- size: "compact"
118
- }
119
- )
120
- ] })
121
- ]
122
- }
123
- );
43
+ const isMediumViewport = (0, _wordpress_compose.useViewportMatch)("medium");
44
+ const { isInserterOpen, isListViewOpen, inserterSidebarToggleRef, listViewToggleRef } = (0, _wordpress_data.useSelect)((select) => {
45
+ const { isInserterOpened, getInserterSidebarToggleRef, isListViewOpened, getListViewToggleRef } = (0, _________lock_unlock_js.unlock)(select(_________store_index_js.store));
46
+ return {
47
+ isInserterOpen: isInserterOpened(),
48
+ isListViewOpen: isListViewOpened(),
49
+ inserterSidebarToggleRef: getInserterSidebarToggleRef(),
50
+ listViewToggleRef: getListViewToggleRef()
51
+ };
52
+ }, []);
53
+ const { setIsInserterOpened, setIsListViewOpened } = (0, _wordpress_data.useDispatch)(_________store_index_js.store);
54
+ const toggleListView = (0, _wordpress_element.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
55
+ const toggleInserterSidebar = (0, _wordpress_element.useCallback)(() => setIsInserterOpened(!isInserterOpen), [setIsInserterOpened, isInserterOpen]);
56
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_block_editor.NavigableToolbar, {
57
+ className: "edit-widgets-header-toolbar",
58
+ "aria-label": (0, _wordpress_i18n.__)("Document tools"),
59
+ variant: "unstyled",
60
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, {
61
+ ref: inserterSidebarToggleRef,
62
+ as: _wordpress_components.Button,
63
+ className: "edit-widgets-header-toolbar__inserter-toggle",
64
+ variant: "primary",
65
+ isPressed: isInserterOpen,
66
+ onMouseDown: (event) => {
67
+ event.preventDefault();
68
+ },
69
+ onClick: toggleInserterSidebar,
70
+ icon: _wordpress_icons.plus,
71
+ label: (0, _wordpress_i18n._x)("Block Inserter", "Generic label for block inserter button"),
72
+ size: "compact"
73
+ }), isMediumViewport && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
74
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, { as: ___undo_redo_undo_jsx.default }),
75
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, { as: ___undo_redo_redo_jsx.default }),
76
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToolbarItem, {
77
+ as: _wordpress_components.Button,
78
+ className: "edit-widgets-header-toolbar__list-view-toggle",
79
+ icon: _wordpress_icons.listView,
80
+ isPressed: isListViewOpen,
81
+ label: (0, _wordpress_i18n.__)("List View"),
82
+ onClick: toggleListView,
83
+ ref: listViewToggleRef,
84
+ size: "compact"
85
+ })
86
+ ] })]
87
+ });
124
88
  }
125
- var document_tools_default = DocumentTools;
126
- //# sourceMappingURL=index.cjs.map
89
+ exports.default = DocumentTools;
90
+
91
+ //# sourceMappingURL=index.cjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/components/header/document-tools/index.jsx"],
4
- "sourcesContent": ["import { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction DocumentTools() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tisListViewOpened,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editWidgetsStore ) );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserterSidebar = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpen ),\n\t\t[ setIsInserterOpened, isInserterOpen ]\n\t);\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ toggleInserterSidebar }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Block Inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolbarItem as={ UndoButton } />\n\t\t\t\t\t<ToolbarItem as={ RedoButton } />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n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oBAAM,eAAe;AAAA,YACtB;AAAA,YACA,SAAU;AAAA,YACV,MAAO;AAAA,YAGP,WAAQ;AAAA,cACP;AAAA,cACA;AAAA,YACD;AAAA,YACA,MAAK;AAAA;AAAA,QACN;AAAA,QACE,oBACD,4EACC;AAAA,sDAAC,iCAAY,IAAK,YAAAC,SAAa;AAAA,UAC/B,4CAAC,iCAAY,IAAK,YAAAC,SAAa;AAAA,UAC/B;AAAA,YAAC;AAAA;AAAA,cACA,IAAK;AAAA,cACL,WAAU;AAAA,cACV,MAAO;AAAA,cACP,WAAY;AAAA,cAEZ,WAAQ,gBAAI,WAAY;AAAA,cACxB,SAAU;AAAA,cACV,KAAM;AAAA,cACN,MAAK;AAAA;AAAA,UACN;AAAA,WACD;AAAA;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,yBAAQ;",
6
- "names": ["editWidgetsStore", "UndoButton", "RedoButton"]
7
- }
1
+ {"version":3,"file":"index.cjs","names":["useViewportMatch","useSelect","unlock","editWidgetsStore","useDispatch","useCallback","NavigableToolbar","__","ToolbarItem","Button","plus","_x","UndoButton","RedoButton","listView"],"sources":["../../../../src/components/header/document-tools/index.jsx"],"sourcesContent":["import { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { NavigableToolbar } from '@wordpress/block-editor';\nimport { listView, plus } from '@wordpress/icons';\nimport { useCallback } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport UndoButton from '../undo-redo/undo';\nimport RedoButton from '../undo-redo/redo';\nimport { store as editWidgetsStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction DocumentTools() {\n\tconst isMediumViewport = useViewportMatch( 'medium' );\n\n\tconst {\n\t\tisInserterOpen,\n\t\tisListViewOpen,\n\t\tinserterSidebarToggleRef,\n\t\tlistViewToggleRef,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisInserterOpened,\n\t\t\tgetInserterSidebarToggleRef,\n\t\t\tisListViewOpened,\n\t\t\tgetListViewToggleRef,\n\t\t} = unlock( select( editWidgetsStore ) );\n\t\treturn {\n\t\t\tisInserterOpen: isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editWidgetsStore );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserterSidebar = useCallback(\n\t\t() => setIsInserterOpened( ! isInserterOpen ),\n\t\t[ setIsInserterOpened, isInserterOpen ]\n\t);\n\n\treturn (\n\t\t<NavigableToolbar\n\t\t\tclassName=\"edit-widgets-header-toolbar\"\n\t\t\taria-label={ __( 'Document tools' ) }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<ToolbarItem\n\t\t\t\tref={ inserterSidebarToggleRef }\n\t\t\t\tas={ Button }\n\t\t\t\tclassName=\"edit-widgets-header-toolbar__inserter-toggle\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tisPressed={ isInserterOpen }\n\t\t\t\tonMouseDown={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t} }\n\t\t\t\tonClick={ toggleInserterSidebar }\n\t\t\t\ticon={ plus }\n\t\t\t\t/* translators: button label text should, if possible, be under 16\n\t\t\t\t\tcharacters. */\n\t\t\t\tlabel={ _x(\n\t\t\t\t\t'Block Inserter',\n\t\t\t\t\t'Generic label for block inserter button'\n\t\t\t\t) }\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t\t{ isMediumViewport && (\n\t\t\t\t<>\n\t\t\t\t\t<ToolbarItem as={ UndoButton } />\n\t\t\t\t\t<ToolbarItem as={ RedoButton } />\n\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\tclassName=\"edit-widgets-header-toolbar__list-view-toggle\"\n\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\tlabel={ __( 'List View' ) }\n\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,gBAAgB;CACxB,MAAM,oBAAA,GAAmBA,mBAAAA,iBAAAA,CAAkB,QAAS;CAEpD,MAAM,EACL,gBACA,gBACA,0BACA,uBAAA,GACGC,gBAAAA,UAAAA,EAAa,WAAY;EAC5B,MAAM,EACL,kBACA,6BACA,kBACA,0BAAA,GACGC,wBAAAA,OAAAA,CAAQ,OAAQC,wBAAAA,KAAiB,CAAE;EACvC,OAAO;GACN,gBAAgB,iBAAiB;GACjC,gBAAgB,iBAAiB;GACjC,0BAA0B,4BAA4B;GACtD,mBAAmB,qBAAqB;EACzC;CACD,GAAG,CAAC,CAAE;CACN,MAAM,EAAE,qBAAqB,yBAAA,GAC5BC,gBAAAA,YAAAA,CAAaD,wBAAAA,KAAiB;CAE/B,MAAM,kBAAA,GAAiBE,mBAAAA,YAAAA,OAChB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,MAAM,yBAAA,GAAwBA,mBAAAA,YAAAA,OACvB,oBAAqB,CAAE,cAAe,GAC5C,CAAE,qBAAqB,cAAe,CACvC;CAEA,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,wBAAAA,kBAAD;EACC,WAAU;EACV,eAAA,GAAaC,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