@wordpress/widget-dashboard 0.2.0 → 0.3.1-next.v.202607070741.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 (269) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +10 -16
  3. package/build/components/actions/actions.cjs +2 -19
  4. package/build/components/actions/actions.cjs.map +3 -3
  5. package/build/components/commands/commands.cjs +1 -60
  6. package/build/components/commands/commands.cjs.map +2 -2
  7. package/build/{utils/grid-model-change → components/widget-attribute-controls}/index.cjs +7 -9
  8. package/build/components/widget-attribute-controls/index.cjs.map +7 -0
  9. package/build/components/widget-attribute-controls/widget-attribute-controls.cjs +93 -0
  10. package/build/components/widget-attribute-controls/widget-attribute-controls.cjs.map +7 -0
  11. package/build/components/widget-chrome/widget-chrome.cjs +16 -63
  12. package/build/components/widget-chrome/widget-chrome.cjs.map +2 -2
  13. package/build/components/{layout-settings → widget-frame}/index.cjs +9 -7
  14. package/build/components/widget-frame/index.cjs.map +7 -0
  15. package/build/components/widget-frame/widget-frame.cjs +193 -0
  16. package/build/components/widget-frame/widget-frame.cjs.map +7 -0
  17. package/build/{utils/migrate-layout → components/widget-header}/index.cjs +7 -7
  18. package/build/components/widget-header/index.cjs.map +7 -0
  19. package/build/components/widget-header/widget-header-infotip.cjs +166 -0
  20. package/build/components/widget-header/widget-header-infotip.cjs.map +7 -0
  21. package/build/components/widget-header/widget-header.cjs +173 -0
  22. package/build/components/widget-header/widget-header.cjs.map +7 -0
  23. package/build/components/{widget-settings/utils/get-admin-menu-inset.cjs → widget-layout-controls/index.cjs} +8 -18
  24. package/build/components/widget-layout-controls/index.cjs.map +7 -0
  25. package/build/components/{widgets/widget-layout-toolbar.cjs → widget-layout-controls/widget-layout-controls.cjs} +9 -100
  26. package/build/components/widget-layout-controls/widget-layout-controls.cjs.map +7 -0
  27. package/build/components/widget-picker/widget-picker.cjs +5 -93
  28. package/build/components/widget-picker/widget-picker.cjs.map +3 -3
  29. package/build/components/widget-preview-chrome/index.cjs +31 -0
  30. package/build/components/widget-preview-chrome/index.cjs.map +7 -0
  31. package/build/components/{widget-settings/widget-settings-toolbar.cjs → widget-preview-chrome/widget-preview-chrome.cjs} +41 -23
  32. package/build/components/widget-preview-chrome/widget-preview-chrome.cjs.map +7 -0
  33. package/build/components/widget-settings/index.cjs +3 -3
  34. package/build/components/widget-settings/index.cjs.map +1 -1
  35. package/build/components/widget-settings/utils/index.cjs +0 -3
  36. package/build/components/widget-settings/utils/index.cjs.map +2 -2
  37. package/build/components/widget-settings/widget-settings-trigger.cjs +22 -28
  38. package/build/components/widget-settings/widget-settings-trigger.cjs.map +2 -2
  39. package/build/components/widget-settings/widget-settings.cjs +40 -57
  40. package/build/components/widget-settings/widget-settings.cjs.map +2 -2
  41. package/build/components/widget-toolbar/widget-toolbar.cjs +7 -4
  42. package/build/components/widget-toolbar/widget-toolbar.cjs.map +2 -2
  43. package/build/components/widgets/widgets.cjs +14 -7
  44. package/build/components/widgets/widgets.cjs.map +2 -2
  45. package/build/context/dashboard-context.cjs +31 -80
  46. package/build/context/dashboard-context.cjs.map +2 -2
  47. package/build/context/ui-context.cjs +2 -18
  48. package/build/context/ui-context.cjs.map +2 -2
  49. package/build/types.cjs.map +1 -1
  50. package/build/utils/index.cjs +2 -5
  51. package/build/utils/index.cjs.map +2 -2
  52. package/build/widget-dashboard.cjs +0 -4
  53. package/build/widget-dashboard.cjs.map +2 -2
  54. package/build-module/components/actions/actions.mjs +3 -20
  55. package/build-module/components/actions/actions.mjs.map +2 -2
  56. package/build-module/components/commands/commands.mjs +2 -67
  57. package/build-module/components/commands/commands.mjs.map +2 -2
  58. package/build-module/components/widget-attribute-controls/index.mjs +6 -0
  59. package/build-module/components/widget-attribute-controls/index.mjs.map +7 -0
  60. package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs +68 -0
  61. package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs.map +7 -0
  62. package/build-module/components/widget-chrome/widget-chrome.mjs +17 -70
  63. package/build-module/components/widget-chrome/widget-chrome.mjs.map +2 -2
  64. package/build-module/components/widget-frame/index.mjs +7 -0
  65. package/build-module/components/widget-frame/index.mjs.map +7 -0
  66. package/build-module/components/widget-frame/widget-frame.mjs +157 -0
  67. package/build-module/components/widget-frame/widget-frame.mjs.map +7 -0
  68. package/build-module/components/widget-header/index.mjs +6 -0
  69. package/build-module/components/widget-header/index.mjs.map +7 -0
  70. package/build-module/components/widget-header/widget-header-infotip.mjs +141 -0
  71. package/build-module/components/widget-header/widget-header-infotip.mjs.map +7 -0
  72. package/build-module/components/widget-header/widget-header.mjs +138 -0
  73. package/build-module/components/widget-header/widget-header.mjs.map +7 -0
  74. package/build-module/components/widget-layout-controls/index.mjs +6 -0
  75. package/build-module/components/widget-layout-controls/index.mjs.map +7 -0
  76. package/build-module/components/widget-layout-controls/widget-layout-controls.mjs +90 -0
  77. package/build-module/components/widget-layout-controls/widget-layout-controls.mjs.map +7 -0
  78. package/build-module/components/widget-picker/widget-picker.mjs +6 -94
  79. package/build-module/components/widget-picker/widget-picker.mjs.map +3 -3
  80. package/build-module/components/widget-preview-chrome/index.mjs +6 -0
  81. package/build-module/components/widget-preview-chrome/index.mjs.map +7 -0
  82. package/build-module/components/{widget-settings/widget-settings-toolbar.mjs → widget-preview-chrome/widget-preview-chrome.mjs} +37 -19
  83. package/build-module/components/widget-preview-chrome/widget-preview-chrome.mjs.map +7 -0
  84. package/build-module/components/widget-settings/index.mjs +2 -2
  85. package/build-module/components/widget-settings/index.mjs.map +1 -1
  86. package/build-module/components/widget-settings/utils/index.mjs +0 -2
  87. package/build-module/components/widget-settings/utils/index.mjs.map +2 -2
  88. package/build-module/components/widget-settings/widget-settings-trigger.mjs +23 -29
  89. package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +2 -2
  90. package/build-module/components/widget-settings/widget-settings.mjs +40 -57
  91. package/build-module/components/widget-settings/widget-settings.mjs.map +2 -2
  92. package/build-module/components/widget-toolbar/widget-toolbar.mjs +7 -4
  93. package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +2 -2
  94. package/build-module/components/widgets/widgets.mjs +14 -7
  95. package/build-module/components/widgets/widgets.mjs.map +2 -2
  96. package/build-module/context/dashboard-context.mjs +31 -80
  97. package/build-module/context/dashboard-context.mjs.map +2 -2
  98. package/build-module/context/ui-context.mjs +2 -18
  99. package/build-module/context/ui-context.mjs.map +2 -2
  100. package/build-module/types.mjs.map +1 -1
  101. package/build-module/utils/index.mjs +1 -3
  102. package/build-module/utils/index.mjs.map +2 -2
  103. package/build-module/widget-dashboard.mjs +0 -4
  104. package/build-module/widget-dashboard.mjs.map +2 -2
  105. package/build-types/components/actions/actions.d.ts.map +1 -1
  106. package/build-types/components/commands/commands.d.ts.map +1 -1
  107. package/build-types/components/widget-attribute-controls/index.d.ts +2 -0
  108. package/build-types/components/widget-attribute-controls/index.d.ts.map +1 -0
  109. package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts +23 -0
  110. package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts.map +1 -0
  111. package/build-types/components/widget-chrome/widget-chrome.d.ts +8 -8
  112. package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -1
  113. package/build-types/components/widget-frame/index.d.ts +3 -0
  114. package/build-types/components/widget-frame/index.d.ts.map +1 -0
  115. package/build-types/components/widget-frame/widget-frame.d.ts +25 -0
  116. package/build-types/components/widget-frame/widget-frame.d.ts.map +1 -0
  117. package/build-types/components/widget-header/index.d.ts +3 -0
  118. package/build-types/components/widget-header/index.d.ts.map +1 -0
  119. package/build-types/components/widget-header/widget-header-infotip.d.ts +20 -0
  120. package/build-types/components/widget-header/widget-header-infotip.d.ts.map +1 -0
  121. package/build-types/components/widget-header/widget-header.d.ts +38 -0
  122. package/build-types/components/widget-header/widget-header.d.ts.map +1 -0
  123. package/build-types/components/widget-layout-controls/index.d.ts +3 -0
  124. package/build-types/components/widget-layout-controls/index.d.ts.map +1 -0
  125. package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts +14 -0
  126. package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts.map +1 -0
  127. package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -1
  128. package/build-types/components/widget-preview-chrome/index.d.ts +3 -0
  129. package/build-types/components/widget-preview-chrome/index.d.ts.map +1 -0
  130. package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts +15 -0
  131. package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts.map +1 -0
  132. package/build-types/components/widget-settings/index.d.ts +2 -2
  133. package/build-types/components/widget-settings/utils/index.d.ts +0 -1
  134. package/build-types/components/widget-settings/utils/index.d.ts.map +1 -1
  135. package/build-types/components/widget-settings/widget-settings-trigger.d.ts +4 -3
  136. package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -1
  137. package/build-types/components/widget-settings/widget-settings.d.ts +2 -2
  138. package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -1
  139. package/build-types/components/widget-toolbar/widget-toolbar.d.ts +10 -7
  140. package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -1
  141. package/build-types/components/widgets/widgets.d.ts.map +1 -1
  142. package/build-types/context/dashboard-context.d.ts +23 -40
  143. package/build-types/context/dashboard-context.d.ts.map +1 -1
  144. package/build-types/context/ui-context.d.ts +0 -18
  145. package/build-types/context/ui-context.d.ts.map +1 -1
  146. package/build-types/types.d.ts +9 -15
  147. package/build-types/types.d.ts.map +1 -1
  148. package/build-types/utils/index.d.ts +0 -1
  149. package/build-types/utils/index.d.ts.map +1 -1
  150. package/build-types/widget-dashboard.d.ts +5 -5
  151. package/build-types/widget-dashboard.d.ts.map +1 -1
  152. package/package.json +17 -17
  153. package/src/components/actions/actions.tsx +2 -22
  154. package/src/components/commands/commands.tsx +3 -70
  155. package/src/components/widget-attribute-controls/index.ts +1 -0
  156. package/src/components/widget-attribute-controls/widget-attribute-controls.tsx +108 -0
  157. package/src/components/widget-chrome/widget-chrome.module.css +3 -68
  158. package/src/components/widget-chrome/widget-chrome.tsx +19 -130
  159. package/src/components/widget-frame/index.ts +2 -0
  160. package/src/components/widget-frame/widget-frame.module.css +17 -0
  161. package/src/components/widget-frame/widget-frame.tsx +138 -0
  162. package/src/components/widget-header/index.ts +2 -0
  163. package/src/components/widget-header/widget-header-infotip.tsx +82 -0
  164. package/src/components/widget-header/widget-header.module.css +76 -0
  165. package/src/components/widget-header/widget-header.tsx +101 -0
  166. package/src/components/widget-layout-controls/index.ts +2 -0
  167. package/src/components/{widgets/widget-layout-toolbar.tsx → widget-layout-controls/widget-layout-controls.tsx} +12 -13
  168. package/src/components/widget-picker/widget-picker.tsx +5 -10
  169. package/src/components/widget-preview-chrome/index.ts +2 -0
  170. package/src/components/widget-preview-chrome/widget-preview-chrome.module.css +22 -0
  171. package/src/components/widget-preview-chrome/widget-preview-chrome.tsx +65 -0
  172. package/src/components/widget-settings/index.ts +2 -2
  173. package/src/components/widget-settings/utils/index.ts +0 -1
  174. package/src/components/widget-settings/widget-settings-trigger.tsx +36 -43
  175. package/src/components/widget-settings/widget-settings.tsx +7 -26
  176. package/src/components/widget-toolbar/widget-toolbar.module.css +6 -9
  177. package/src/components/widget-toolbar/widget-toolbar.tsx +14 -8
  178. package/src/components/widgets/widgets.module.css +0 -1
  179. package/src/components/widgets/widgets.tsx +30 -8
  180. package/src/context/dashboard-context.tsx +70 -133
  181. package/src/context/ui-context.tsx +1 -39
  182. package/src/test/actions.test.tsx +7 -77
  183. package/src/test/commands.test.tsx +6 -45
  184. package/src/test/staging.test.tsx +82 -144
  185. package/src/test/widget-dashboard.test.tsx +24 -0
  186. package/src/types.ts +9 -16
  187. package/src/utils/index.ts +0 -1
  188. package/src/widget-dashboard.tsx +4 -8
  189. package/build/components/layout-settings/index.cjs.map +0 -7
  190. package/build/components/layout-settings/layout-model-edit-field/index.cjs +0 -186
  191. package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +0 -7
  192. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +0 -53
  193. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +0 -7
  194. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +0 -53
  195. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +0 -7
  196. package/build/components/layout-settings/layout-settings.cjs +0 -207
  197. package/build/components/layout-settings/layout-settings.cjs.map +0 -7
  198. package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +0 -7
  199. package/build/components/widget-settings/widget-settings-toolbar.cjs.map +0 -7
  200. package/build/components/widgets/widget-layout-toolbar.cjs.map +0 -7
  201. package/build/utils/grid-model-change/grid-model-change.cjs +0 -56
  202. package/build/utils/grid-model-change/grid-model-change.cjs.map +0 -7
  203. package/build/utils/grid-model-change/index.cjs.map +0 -7
  204. package/build/utils/migrate-layout/index.cjs.map +0 -7
  205. package/build/utils/migrate-layout/migrate-layout.cjs +0 -94
  206. package/build/utils/migrate-layout/migrate-layout.cjs.map +0 -7
  207. package/build-module/components/layout-settings/index.mjs +0 -6
  208. package/build-module/components/layout-settings/index.mjs.map +0 -7
  209. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +0 -151
  210. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +0 -7
  211. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +0 -28
  212. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +0 -7
  213. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +0 -28
  214. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +0 -7
  215. package/build-module/components/layout-settings/layout-settings.mjs +0 -187
  216. package/build-module/components/layout-settings/layout-settings.mjs.map +0 -7
  217. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +0 -16
  218. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +0 -7
  219. package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +0 -7
  220. package/build-module/components/widgets/widget-layout-toolbar.mjs +0 -181
  221. package/build-module/components/widgets/widget-layout-toolbar.mjs.map +0 -7
  222. package/build-module/utils/grid-model-change/grid-model-change.mjs +0 -30
  223. package/build-module/utils/grid-model-change/grid-model-change.mjs.map +0 -7
  224. package/build-module/utils/grid-model-change/index.mjs +0 -7
  225. package/build-module/utils/grid-model-change/index.mjs.map +0 -7
  226. package/build-module/utils/migrate-layout/index.mjs +0 -6
  227. package/build-module/utils/migrate-layout/index.mjs.map +0 -7
  228. package/build-module/utils/migrate-layout/migrate-layout.mjs +0 -69
  229. package/build-module/utils/migrate-layout/migrate-layout.mjs.map +0 -7
  230. package/build-types/components/layout-settings/index.d.ts +0 -2
  231. package/build-types/components/layout-settings/index.d.ts.map +0 -1
  232. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +0 -17
  233. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +0 -1
  234. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +0 -6
  235. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +0 -1
  236. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +0 -6
  237. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +0 -1
  238. package/build-types/components/layout-settings/layout-settings.d.ts +0 -14
  239. package/build-types/components/layout-settings/layout-settings.d.ts.map +0 -1
  240. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +0 -17
  241. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +0 -1
  242. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +0 -20
  243. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +0 -1
  244. package/build-types/components/widgets/widget-layout-toolbar.d.ts +0 -14
  245. package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +0 -1
  246. package/build-types/utils/grid-model-change/grid-model-change.d.ts +0 -20
  247. package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +0 -1
  248. package/build-types/utils/grid-model-change/index.d.ts +0 -2
  249. package/build-types/utils/grid-model-change/index.d.ts.map +0 -1
  250. package/build-types/utils/migrate-layout/index.d.ts +0 -2
  251. package/build-types/utils/migrate-layout/index.d.ts.map +0 -1
  252. package/build-types/utils/migrate-layout/migrate-layout.d.ts +0 -36
  253. package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +0 -1
  254. package/src/components/layout-settings/index.ts +0 -1
  255. package/src/components/layout-settings/layout-model-edit-field/index.tsx +0 -98
  256. package/src/components/layout-settings/layout-model-edit-field/style.module.css +0 -34
  257. package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +0 -28
  258. package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +0 -28
  259. package/src/components/layout-settings/layout-settings.tsx +0 -217
  260. package/src/components/widget-picker/widget-picker.module.css +0 -11
  261. package/src/components/widget-settings/utils/get-admin-menu-inset.ts +0 -30
  262. package/src/components/widget-settings/widget-settings-toolbar.module.css +0 -25
  263. package/src/components/widget-settings/widget-settings-toolbar.tsx +0 -45
  264. package/src/components/widgets/widget-layout-toolbar.module.css +0 -6
  265. package/src/utils/grid-model-change/grid-model-change.ts +0 -53
  266. package/src/utils/grid-model-change/index.ts +0 -1
  267. package/src/utils/migrate-layout/index.ts +0 -1
  268. package/src/utils/migrate-layout/migrate-layout.ts +0 -156
  269. package/src/utils/migrate-layout/test/migrate-layout.test.ts +0 -114
@@ -0,0 +1,138 @@
1
+ // packages/widget-dashboard/src/components/widget-header/widget-header.tsx
2
+ import clsx from "clsx";
3
+ import { Card, Icon, Stack } from "@wordpress/ui";
4
+ import { WidgetInfotip } from "./widget-header-infotip.mjs";
5
+
6
+ // packages/style-runtime/src/index.ts
7
+ var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
8
+ function getRuntime() {
9
+ const globalScope = globalThis;
10
+ if (globalScope.__wpStyleRuntime) {
11
+ return globalScope.__wpStyleRuntime;
12
+ }
13
+ globalScope.__wpStyleRuntime = {
14
+ documents: /* @__PURE__ */ new Map(),
15
+ styles: /* @__PURE__ */ new Map(),
16
+ injectedStyles: /* @__PURE__ */ new WeakMap()
17
+ };
18
+ if (typeof document !== "undefined") {
19
+ registerDocument(document);
20
+ }
21
+ return globalScope.__wpStyleRuntime;
22
+ }
23
+ function documentContainsStyleHash(targetDocument, hash) {
24
+ if (!targetDocument.head) {
25
+ return false;
26
+ }
27
+ for (const style of targetDocument.head.querySelectorAll(
28
+ `style[${STYLE_HASH_ATTRIBUTE}]`
29
+ )) {
30
+ if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
31
+ return true;
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+ function injectStyle(targetDocument, hash, css) {
37
+ if (!targetDocument.head) {
38
+ return;
39
+ }
40
+ const runtime = getRuntime();
41
+ let injectedStyles = runtime.injectedStyles.get(targetDocument);
42
+ if (!injectedStyles) {
43
+ injectedStyles = /* @__PURE__ */ new Set();
44
+ runtime.injectedStyles.set(targetDocument, injectedStyles);
45
+ }
46
+ if (injectedStyles.has(hash)) {
47
+ return;
48
+ }
49
+ if (documentContainsStyleHash(targetDocument, hash)) {
50
+ injectedStyles.add(hash);
51
+ return;
52
+ }
53
+ const style = targetDocument.createElement("style");
54
+ style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
55
+ style.appendChild(targetDocument.createTextNode(css));
56
+ targetDocument.head.appendChild(style);
57
+ injectedStyles.add(hash);
58
+ }
59
+ function registerDocument(targetDocument) {
60
+ const runtime = getRuntime();
61
+ runtime.documents.set(
62
+ targetDocument,
63
+ (runtime.documents.get(targetDocument) ?? 0) + 1
64
+ );
65
+ for (const [hash, css] of runtime.styles) {
66
+ injectStyle(targetDocument, hash, css);
67
+ }
68
+ return () => {
69
+ const count = runtime.documents.get(targetDocument);
70
+ if (count === void 0) {
71
+ return;
72
+ }
73
+ if (count <= 1) {
74
+ runtime.documents.delete(targetDocument);
75
+ return;
76
+ }
77
+ runtime.documents.set(targetDocument, count - 1);
78
+ };
79
+ }
80
+ function registerStyle(hash, css) {
81
+ const runtime = getRuntime();
82
+ runtime.styles.set(hash, css);
83
+ for (const targetDocument of runtime.documents.keys()) {
84
+ injectStyle(targetDocument, hash, css);
85
+ }
86
+ }
87
+
88
+ // packages/widget-dashboard/src/components/widget-header/widget-header.module.css
89
+ if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
90
+ registerStyle("6bc1a11567", ".a7cf38a139398543__widgetHeader{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px)}._967cd798e5c37202__toolbar,.f41e4aad10324455__identity{align-items:center;display:flex;height:var(--wpds-dimension-size-lg,40px)}.f41e4aad10324455__identity{min-width:0}._53584a4927dfbcf1__icon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}._917a5a960220d44f__popoverPopup{max-width:300px}.d6f136cf92858182__help{align-items:center;background:none;border:0;color:var(--wpds-color-foreground-content-neutral-weak,#707070);cursor:var(--wpds-cursor-control,pointer);display:inline-flex;padding:0}._9bdac6051677514a__link+._9bdac6051677514a__link{border-inline-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);padding-inline-start:var(--wpds-dimension-gap-sm,8px)}._967cd798e5c37202__toolbar{margin-inline-start:auto}.f32f2cd669c9b4b0__overlay{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);inset-block-start:0;inset-inline:0;pointer-events:none;position:absolute;z-index:1}.f32f2cd669c9b4b0__overlay ._967cd798e5c37202__toolbar{pointer-events:auto}");
91
+ }
92
+ var widget_header_default = { "widgetHeader": "a7cf38a139398543__widgetHeader", "identity": "f41e4aad10324455__identity", "toolbar": "_967cd798e5c37202__toolbar", "icon": "_53584a4927dfbcf1__icon", "popoverPopup": "_917a5a960220d44f__popoverPopup", "help": "d6f136cf92858182__help", "link": "_9bdac6051677514a__link", "overlay": "f32f2cd669c9b4b0__overlay" };
93
+
94
+ // packages/widget-dashboard/src/components/widget-header/widget-header.tsx
95
+ import { jsx, jsxs } from "react/jsx-runtime";
96
+ function WidgetHeader({
97
+ widgetType,
98
+ titleId,
99
+ showIdentity = false,
100
+ overlay = false,
101
+ editMode = false,
102
+ children
103
+ }) {
104
+ return /* @__PURE__ */ jsxs(
105
+ Card.Header,
106
+ {
107
+ className: clsx(widget_header_default.widgetHeader, overlay && widget_header_default.overlay),
108
+ children: [
109
+ showIdentity && widgetType?.title && /* @__PURE__ */ jsxs(
110
+ Stack,
111
+ {
112
+ direction: "row",
113
+ align: "center",
114
+ gap: "sm",
115
+ className: widget_header_default.identity,
116
+ ...editMode ? { inert: "true" } : {},
117
+ children: [
118
+ widgetType.icon && /* @__PURE__ */ jsx("span", { className: widget_header_default.icon, "aria-hidden": "true", children: /* @__PURE__ */ jsx(Icon, { icon: widgetType.icon }) }),
119
+ /* @__PURE__ */ jsx(Card.Title, { id: titleId, render: /* @__PURE__ */ jsx("h2", {}), children: widgetType.title }),
120
+ widgetType.help && /* @__PURE__ */ jsx(
121
+ WidgetInfotip,
122
+ {
123
+ content: widgetType.help.content,
124
+ links: widgetType.help.links
125
+ }
126
+ )
127
+ ]
128
+ }
129
+ ),
130
+ children && /* @__PURE__ */ jsx("div", { className: widget_header_default.toolbar, children })
131
+ ]
132
+ }
133
+ );
134
+ }
135
+ export {
136
+ WidgetHeader
137
+ };
138
+ //# sourceMappingURL=widget-header.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/widget-header/widget-header.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-header/widget-header.module.css"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Card, Icon, Stack } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { WidgetInfotip } from './widget-header-infotip';\nimport styles from './widget-header.module.css';\n\nexport interface WidgetHeaderProps {\n\t/**\n\t * Widget type, source of the icon, title, and help note shown as\n\t * identity.\n\t */\n\twidgetType?: WidgetType;\n\n\t/**\n\t * Id linking the title to the tile's labelled region.\n\t */\n\ttitleId?: string;\n\n\t/**\n\t * Render the icon + title cluster on the leading edge.\n\t */\n\tshowIdentity?: boolean;\n\n\t/**\n\t * Float over the tile instead of sitting in the card flow.\n\t */\n\toverlay?: boolean;\n\n\t/**\n\t * Inert the identity while customizing, so it does not capture interaction.\n\t */\n\teditMode?: boolean;\n\n\t/**\n\t * Toolbar placed on the trailing edge.\n\t */\n\tchildren?: ReactNode;\n}\n\n/**\n * Tile header row: identity (icon + title) and a toolbar on one line. Rendered\n * in the card flow, or as an `overlay` in the grid slot for full-bleed widgets\n * that have no in-card header.\n *\n * @param {WidgetHeaderProps} props Component props.\n */\nexport function WidgetHeader( {\n\twidgetType,\n\ttitleId,\n\tshowIdentity = false,\n\toverlay = false,\n\teditMode = false,\n\tchildren,\n}: WidgetHeaderProps ): React.ReactNode {\n\treturn (\n\t\t<Card.Header\n\t\t\tclassName={ clsx( styles.widgetHeader, overlay && styles.overlay ) }\n\t\t>\n\t\t\t{ showIdentity && widgetType?.title && (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\talign=\"center\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={ styles.identity }\n\t\t\t\t\t{ ...( editMode ? { inert: 'true' } : {} ) }\n\t\t\t\t>\n\t\t\t\t\t{ widgetType.icon && (\n\t\t\t\t\t\t<span className={ styles.icon } aria-hidden=\"true\">\n\t\t\t\t\t\t\t<Icon icon={ widgetType.icon } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<Card.Title id={ titleId } render={ <h2 /> }>\n\t\t\t\t\t\t{ widgetType.title }\n\t\t\t\t\t</Card.Title>\n\n\t\t\t\t\t{ widgetType.help && (\n\t\t\t\t\t\t<WidgetInfotip\n\t\t\t\t\t\t\tcontent={ widgetType.help.content }\n\t\t\t\t\t\t\tlinks={ widgetType.help.links }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Stack>\n\t\t\t) }\n\n\t\t\t{ children && <div className={ styles.toolbar }>{ children }</div> }\n\t\t</Card.Header>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"6bc1a11567\", \".a7cf38a139398543__widgetHeader{align-items:center;display:flex;gap:var(--wpds-dimension-gap-sm,8px)}._967cd798e5c37202__toolbar,.f41e4aad10324455__identity{align-items:center;display:flex;height:var(--wpds-dimension-size-lg,40px)}.f41e4aad10324455__identity{min-width:0}._53584a4927dfbcf1__icon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}._917a5a960220d44f__popoverPopup{max-width:300px}.d6f136cf92858182__help{align-items:center;background:none;border:0;color:var(--wpds-color-foreground-content-neutral-weak,#707070);cursor:var(--wpds-cursor-control,pointer);display:inline-flex;padding:0}._9bdac6051677514a__link+._9bdac6051677514a__link{border-inline-start:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);padding-inline-start:var(--wpds-dimension-gap-sm,8px)}._967cd798e5c37202__toolbar{margin-inline-start:auto}.f32f2cd669c9b4b0__overlay{--wp-ui-card-padding:var(--wpds-dimension-padding-2xl,24px);inset-block-start:0;inset-inline:0;pointer-events:none;position:absolute;z-index:1}.f32f2cd669c9b4b0__overlay ._967cd798e5c37202__toolbar{pointer-events:auto}\");\n}\nexport default {\"widgetHeader\":\"a7cf38a139398543__widgetHeader\",\"identity\":\"f41e4aad10324455__identity\",\"toolbar\":\"_967cd798e5c37202__toolbar\",\"icon\":\"_53584a4927dfbcf1__icon\",\"popoverPopup\":\"_917a5a960220d44f__popoverPopup\",\"help\":\"d6f136cf92858182__help\",\"link\":\"_9bdac6051677514a__link\",\"overlay\":\"f32f2cd669c9b4b0__overlay\"};\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,MAAM,MAAM,aAAa;AAMlC,SAAS,qBAAqB;;;ACL9B,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;AAC3E,MAAK,CAAE,eAAe,MAAO;AAC5B;AAAA,EACD;AAEA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;AAEhE,MAAK,CAAE,gBAAiB;AACvB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAK,gBAAgB,cAAe;AAAA,EAC5D;AAEA,MAAK,eAAe,IAAK,IAAK,GAAI;AACjC;AAAA,EACD;AAKA,MAAK,0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AA,EACA,eAAe;AAAA,EACf,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AACD,GAAwC;AACvC,SACC;AAAA,IAAC,KAAK;AAAA,IAAL;AAAA,MACA,WAAY,KAAM,sBAAO,cAAc,WAAW,sBAAO,OAAQ;AAAA,MAE/D;AAAA,wBAAgB,YAAY,SAC7B;AAAA,UAAC;AAAA;AAAA,YACA,WAAU;AAAA,YACV,OAAM;AAAA,YACN,KAAI;AAAA,YACJ,WAAY,sBAAO;AAAA,YACjB,GAAK,WAAW,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,YAErC;AAAA,yBAAW,QACZ,oBAAC,UAAK,WAAY,sBAAO,MAAO,eAAY,QAC3C,8BAAC,QAAK,MAAO,WAAW,MAAO,GAChC;AAAA,cAGD,oBAAC,KAAK,OAAL,EAAW,IAAK,SAAU,QAAS,oBAAC,QAAG,GACrC,qBAAW,OACd;AAAA,cAEE,WAAW,QACZ;AAAA,gBAAC;AAAA;AAAA,kBACA,SAAU,WAAW,KAAK;AAAA,kBAC1B,OAAQ,WAAW,KAAK;AAAA;AAAA,cACzB;AAAA;AAAA;AAAA,QAEF;AAAA,QAGC,YAAY,oBAAC,SAAI,WAAY,sBAAO,SAAY,UAAU;AAAA;AAAA;AAAA,EAC7D;AAEF;",
6
+ "names": []
7
+ }
@@ -0,0 +1,6 @@
1
+ // packages/widget-dashboard/src/components/widget-layout-controls/index.ts
2
+ import { WidgetLayoutControls } from "./widget-layout-controls.mjs";
3
+ export {
4
+ WidgetLayoutControls
5
+ };
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/widget-layout-controls/index.ts"],
4
+ "sourcesContent": ["export { WidgetLayoutControls } from './widget-layout-controls';\nexport type { WidgetLayoutControlsProps } from './widget-layout-controls';\n"],
5
+ "mappings": ";AAAA,SAAS,4BAA4B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,90 @@
1
+ // packages/widget-dashboard/src/components/widget-layout-controls/widget-layout-controls.tsx
2
+ import { privateApis as componentsPrivateApis } from "@wordpress/components";
3
+ import { __ } from "@wordpress/i18n";
4
+ import { moreVertical, trash } from "@wordpress/icons";
5
+ import { IconButton } from "@wordpress/ui";
6
+ import { unlock } from "../../lock-unlock.mjs";
7
+ import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ var { Menu } = unlock(componentsPrivateApis);
10
+ function WidgetLayoutControls({
11
+ widget
12
+ }) {
13
+ const { layout, onLayoutChange } = useDashboardInternalContext();
14
+ const width = widget.placement?.width;
15
+ const updateWidth = (nextWidth) => {
16
+ const nextLayout = layout.map(
17
+ (currentWidget) => currentWidget.uuid === widget.uuid ? {
18
+ ...currentWidget,
19
+ placement: {
20
+ ...currentWidget.placement,
21
+ width: nextWidth
22
+ }
23
+ } : currentWidget
24
+ );
25
+ onLayoutChange(nextLayout);
26
+ };
27
+ const onNamedWidthChange = (nextWidth) => {
28
+ updateWidth(nextWidth);
29
+ };
30
+ const onRemove = () => {
31
+ onLayoutChange(
32
+ layout.filter(
33
+ (currentWidget) => currentWidget.uuid !== widget.uuid
34
+ )
35
+ );
36
+ };
37
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
38
+ /* @__PURE__ */ jsxs(Menu, { children: [
39
+ /* @__PURE__ */ jsx(
40
+ Menu.TriggerButton,
41
+ {
42
+ render: /* @__PURE__ */ jsx(
43
+ IconButton,
44
+ {
45
+ icon: moreVertical,
46
+ label: __("Widget options"),
47
+ size: "compact",
48
+ variant: "minimal",
49
+ tone: "neutral"
50
+ }
51
+ )
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(Menu.Popover, { children: /* @__PURE__ */ jsxs(Menu.Group, { children: [
55
+ /* @__PURE__ */ jsx(Menu.GroupLabel, { children: __("Width") }),
56
+ /* @__PURE__ */ jsx(
57
+ Menu.Item,
58
+ {
59
+ disabled: width === "fill",
60
+ onClick: () => onNamedWidthChange("fill"),
61
+ children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: __("Use available width") })
62
+ }
63
+ ),
64
+ /* @__PURE__ */ jsx(
65
+ Menu.Item,
66
+ {
67
+ disabled: width === "full",
68
+ onClick: () => onNamedWidthChange("full"),
69
+ children: /* @__PURE__ */ jsx(Menu.ItemLabel, { children: __("Make full width") })
70
+ }
71
+ )
72
+ ] }) })
73
+ ] }),
74
+ /* @__PURE__ */ jsx(
75
+ IconButton,
76
+ {
77
+ icon: trash,
78
+ label: __("Remove"),
79
+ size: "compact",
80
+ variant: "minimal",
81
+ tone: "neutral",
82
+ onClick: onRemove
83
+ }
84
+ )
85
+ ] });
86
+ }
87
+ export {
88
+ WidgetLayoutControls
89
+ };
90
+ //# sourceMappingURL=widget-layout-controls.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/widget-layout-controls/widget-layout-controls.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreVertical, trash } from '@wordpress/icons';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { IconButton } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport type { DashboardWidget, GridTilePlacement } from '../../types';\n\nconst { Menu } = unlock( componentsPrivateApis );\n\ntype NamedGridWidth = Exclude<\n\tNonNullable< GridTilePlacement[ 'width' ] >,\n\tnumber\n>;\n\nexport interface WidgetLayoutControlsProps {\n\t/**\n\t * The instance these controls manage within the layout.\n\t */\n\twidget: DashboardWidget< unknown >;\n}\n\n/**\n * Customize-mode controls: width menu and removal.\n *\n * @param {WidgetLayoutControlsProps} props Component props.\n */\nexport function WidgetLayoutControls( {\n\twidget,\n}: WidgetLayoutControlsProps ): React.ReactNode {\n\tconst { layout, onLayoutChange } = useDashboardInternalContext();\n\tconst width = widget.placement?.width;\n\n\tconst updateWidth = ( nextWidth: GridTilePlacement[ 'width' ] ) => {\n\t\tconst nextLayout = layout.map( ( currentWidget ) =>\n\t\t\tcurrentWidget.uuid === widget.uuid\n\t\t\t\t? {\n\t\t\t\t\t\t...currentWidget,\n\t\t\t\t\t\tplacement: {\n\t\t\t\t\t\t\t...currentWidget.placement,\n\t\t\t\t\t\t\twidth: nextWidth,\n\t\t\t\t\t\t},\n\t\t\t\t }\n\t\t\t\t: currentWidget\n\t\t);\n\t\tonLayoutChange( nextLayout );\n\t};\n\n\tconst onNamedWidthChange = ( nextWidth: NamedGridWidth ) => {\n\t\tupdateWidth( nextWidth );\n\t};\n\n\tconst onRemove = () => {\n\t\tonLayoutChange(\n\t\t\tlayout.filter(\n\t\t\t\t( currentWidget ) => currentWidget.uuid !== widget.uuid\n\t\t\t)\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<Menu>\n\t\t\t\t<Menu.TriggerButton\n\t\t\t\t\trender={\n\t\t\t\t\t\t<IconButton\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ __( 'Widget options' ) }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\t\ttone=\"neutral\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t/>\n\n\t\t\t\t<Menu.Popover>\n\t\t\t\t\t<Menu.Group>\n\t\t\t\t\t\t<Menu.GroupLabel>{ __( 'Width' ) }</Menu.GroupLabel>\n\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\tdisabled={ width === 'fill' }\n\t\t\t\t\t\t\tonClick={ () => onNamedWidthChange( 'fill' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t{ __( 'Use available width' ) }\n\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t\t<Menu.Item\n\t\t\t\t\t\t\tdisabled={ width === 'full' }\n\t\t\t\t\t\t\tonClick={ () => onNamedWidthChange( 'full' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>\n\t\t\t\t\t\t\t\t{ __( 'Make full width' ) }\n\t\t\t\t\t\t\t</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.Item>\n\t\t\t\t\t</Menu.Group>\n\t\t\t\t</Menu.Popover>\n\t\t\t</Menu>\n\n\t\t\t<IconButton\n\t\t\t\ticon={ trash }\n\t\t\t\tlabel={ __( 'Remove' ) }\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"minimal\"\n\t\t\t\ttone=\"neutral\"\n\t\t\t\tonClick={ onRemove }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,eAAe,6BAA6B;AACrD,SAAS,UAAU;AACnB,SAAS,cAAc,aAAa;AAEpC,SAAS,kBAAkB;AAK3B,SAAS,cAAc;AACvB,SAAS,mCAAmC;AAwD1C,mBAII,KAWD,YAfH;AArDF,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAmBxC,SAAS,qBAAsB;AAAA,EACrC;AACD,GAAgD;AAC/C,QAAM,EAAE,QAAQ,eAAe,IAAI,4BAA4B;AAC/D,QAAM,QAAQ,OAAO,WAAW;AAEhC,QAAM,cAAc,CAAE,cAA6C;AAClE,UAAM,aAAa,OAAO;AAAA,MAAK,CAAE,kBAChC,cAAc,SAAS,OAAO,OAC3B;AAAA,QACA,GAAG;AAAA,QACH,WAAW;AAAA,UACV,GAAG,cAAc;AAAA,UACjB,OAAO;AAAA,QACR;AAAA,MACA,IACA;AAAA,IACJ;AACA,mBAAgB,UAAW;AAAA,EAC5B;AAEA,QAAM,qBAAqB,CAAE,cAA+B;AAC3D,gBAAa,SAAU;AAAA,EACxB;AAEA,QAAM,WAAW,MAAM;AACtB;AAAA,MACC,OAAO;AAAA,QACN,CAAE,kBAAmB,cAAc,SAAS,OAAO;AAAA,MACpD;AAAA,IACD;AAAA,EACD;AAEA,SACC,iCACC;AAAA,yBAAC,QACA;AAAA;AAAA,QAAC,KAAK;AAAA,QAAL;AAAA,UACA,QACC;AAAA,YAAC;AAAA;AAAA,cACA,MAAO;AAAA,cACP,OAAQ,GAAI,gBAAiB;AAAA,cAC7B,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,MAAK;AAAA;AAAA,UACN;AAAA;AAAA,MAEF;AAAA,MAEA,oBAAC,KAAK,SAAL,EACA,+BAAC,KAAK,OAAL,EACA;AAAA,4BAAC,KAAK,YAAL,EAAkB,aAAI,OAAQ,GAAG;AAAA,QAClC;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACA,UAAW,UAAU;AAAA,YACrB,SAAU,MAAM,mBAAoB,MAAO;AAAA,YAE3C,8BAAC,KAAK,WAAL,EACE,aAAI,qBAAsB,GAC7B;AAAA;AAAA,QACD;AAAA,QACA;AAAA,UAAC,KAAK;AAAA,UAAL;AAAA,YACA,UAAW,UAAU;AAAA,YACrB,SAAU,MAAM,mBAAoB,MAAO;AAAA,YAE3C,8BAAC,KAAK,WAAL,EACE,aAAI,iBAAkB,GACzB;AAAA;AAAA,QACD;AAAA,SACD,GACD;AAAA,OACD;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP,OAAQ,GAAI,QAAS;AAAA,QACrB,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,SAAU;AAAA;AAAA,IACX;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -1,107 +1,19 @@
1
1
  // packages/widget-dashboard/src/components/widget-picker/widget-picker.tsx
2
2
  import { DataViewsPicker, filterSortAndPaginate } from "@wordpress/dataviews";
3
- import { Suspense, useMemo, useState } from "@wordpress/element";
3
+ import { useMemo, useState } from "@wordpress/element";
4
4
  import { __ } from "@wordpress/i18n";
5
5
  import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
6
6
  import { createDashboardWidget } from "../../utils/create-dashboard-widget/index.mjs";
7
- import { WidgetRender } from "../widget-render/index.mjs";
8
-
9
- // packages/style-runtime/src/index.ts
10
- var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
11
- function getRuntime() {
12
- const globalScope = globalThis;
13
- if (globalScope.__wpStyleRuntime) {
14
- return globalScope.__wpStyleRuntime;
15
- }
16
- globalScope.__wpStyleRuntime = {
17
- documents: /* @__PURE__ */ new Map(),
18
- styles: /* @__PURE__ */ new Map(),
19
- injectedStyles: /* @__PURE__ */ new WeakMap()
20
- };
21
- if (typeof document !== "undefined") {
22
- registerDocument(document);
23
- }
24
- return globalScope.__wpStyleRuntime;
25
- }
26
- function documentContainsStyleHash(targetDocument, hash) {
27
- if (!targetDocument.head) {
28
- return false;
29
- }
30
- for (const style of targetDocument.head.querySelectorAll(
31
- `style[${STYLE_HASH_ATTRIBUTE}]`
32
- )) {
33
- if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
34
- return true;
35
- }
36
- }
37
- return false;
38
- }
39
- function injectStyle(targetDocument, hash, css) {
40
- if (!targetDocument.head) {
41
- return;
42
- }
43
- const runtime = getRuntime();
44
- let injectedStyles = runtime.injectedStyles.get(targetDocument);
45
- if (!injectedStyles) {
46
- injectedStyles = /* @__PURE__ */ new Set();
47
- runtime.injectedStyles.set(targetDocument, injectedStyles);
48
- }
49
- if (injectedStyles.has(hash)) {
50
- return;
51
- }
52
- if (documentContainsStyleHash(targetDocument, hash)) {
53
- injectedStyles.add(hash);
54
- return;
55
- }
56
- const style = targetDocument.createElement("style");
57
- style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
58
- style.appendChild(targetDocument.createTextNode(css));
59
- targetDocument.head.appendChild(style);
60
- injectedStyles.add(hash);
61
- }
62
- function registerDocument(targetDocument) {
63
- const runtime = getRuntime();
64
- runtime.documents.set(
65
- targetDocument,
66
- (runtime.documents.get(targetDocument) ?? 0) + 1
67
- );
68
- for (const [hash, css] of runtime.styles) {
69
- injectStyle(targetDocument, hash, css);
70
- }
71
- return () => {
72
- const count = runtime.documents.get(targetDocument);
73
- if (count === void 0) {
74
- return;
75
- }
76
- if (count <= 1) {
77
- runtime.documents.delete(targetDocument);
78
- return;
79
- }
80
- runtime.documents.set(targetDocument, count - 1);
81
- };
82
- }
83
- function registerStyle(hash, css) {
84
- const runtime = getRuntime();
85
- runtime.styles.set(hash, css);
86
- for (const targetDocument of runtime.documents.keys()) {
87
- injectStyle(targetDocument, hash, css);
88
- }
89
- }
90
-
91
- // packages/widget-dashboard/src/components/widget-picker/widget-picker.module.css
92
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
93
- registerStyle("93a9ea86b0", "._623aa9eba189276f__preview{height:125%;overflow:hidden;padding:0;pointer-events:none;transform:scale(.8);transform-origin:top left;user-select:none;width:125%}");
94
- }
95
- var widget_picker_default = { "preview": "_623aa9eba189276f__preview" };
96
-
97
- // packages/widget-dashboard/src/components/widget-picker/widget-picker.tsx
7
+ import { WidgetPreviewChrome } from "../widget-preview-chrome/index.mjs";
98
8
  import { jsx } from "react/jsx-runtime";
99
9
  var DEFAULT_VIEW = {
100
10
  type: "pickerGrid",
101
11
  page: 1,
102
12
  search: "",
103
13
  mediaField: "preview",
104
- titleField: "title"
14
+ titleField: "title",
15
+ // Larger default tile than the built-in 230.
16
+ layout: { previewSize: 290 }
105
17
  };
106
18
  var getItemId = (item) => item.name;
107
19
  function WidgetPreview({ item }) {
@@ -109,7 +21,7 @@ function WidgetPreview({ item }) {
109
21
  () => createDashboardWidget(item, item.example?.attributes),
110
22
  [item]
111
23
  );
112
- return /* @__PURE__ */ jsx("div", { className: widget_picker_default.preview, ...{ inert: "" }, children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(WidgetRender, { widget: exampleWidget, widgetType: item }) }) });
24
+ return /* @__PURE__ */ jsx(WidgetPreviewChrome, { widget: exampleWidget, widgetType: item });
113
25
  }
114
26
  var fields = [
115
27
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../../src/components/widget-picker/widget-picker.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-picker/widget-picker.module.css"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataViewsPicker, filterSortAndPaginate } from '@wordpress/dataviews';\nimport type { Field, View } from '@wordpress/dataviews';\nimport { Suspense, useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { createDashboardWidget } from '../../utils/create-dashboard-widget';\nimport { WidgetRender } from '../widget-render';\nimport styles from './widget-picker.module.css';\n\nconst DEFAULT_VIEW: View = {\n\ttype: 'pickerGrid',\n\tpage: 1,\n\tsearch: '',\n\tmediaField: 'preview',\n\ttitleField: 'title',\n};\n\nconst getItemId = ( item: WidgetType ) => item.name;\n\nfunction WidgetPreview( { item }: { item: WidgetType } ) {\n\tconst exampleWidget = useMemo(\n\t\t() => createDashboardWidget( item, item.example?.attributes ),\n\t\t[ item ]\n\t);\n\n\treturn (\n\t\t<div className={ styles.preview } { ...{ inert: '' } }>\n\t\t\t<Suspense fallback={ null }>\n\t\t\t\t<WidgetRender widget={ exampleWidget } widgetType={ item } />\n\t\t\t</Suspense>\n\t\t</div>\n\t);\n}\n\nconst fields: Field< WidgetType >[] = [\n\t{\n\t\tid: 'title',\n\t\ttype: 'text',\n\t\tlabel: __( 'Title' ),\n\t\tfilterBy: false,\n\t},\n\t{\n\t\tid: 'preview',\n\t\ttype: 'media',\n\t\trender: WidgetPreview,\n\t},\n\t{\n\t\tid: 'name',\n\t\ttype: 'text',\n\t\tenableGlobalSearch: true,\n\t\tenableHiding: false,\n\t\tenableSorting: false,\n\t\tfilterBy: false,\n\t\tgetValue: ( { item } ) =>\n\t\t\t`${ item.name.replace( /[\\/,\\-_]/g, ' ' ) } ${ item.title }`,\n\t},\n];\n\ninterface WidgetPickerProps {\n\t/**\n\t * Called with the widget types selected by the user. The picker keeps\n\t * its own selection state; consumers receive the resolved list when\n\t * the \"Select\" action fires.\n\t */\n\tonSelect: ( widgetTypes: WidgetType[] ) => void;\n\n\t/**\n\t * Accessible label for the picker's item list.\n\t *\n\t * @default __( 'Widget list' )\n\t */\n\titemListLabel?: string;\n}\n\n/**\n * DataViews-driven widget type picker. Lists `widgetTypes` from the dashboard\n * context as a grid of live previews, supports search via `name`/`title`, and\n * exposes a single \"Select\" action with bulk support so users can insert one\n * or several widgets at once.\n *\n * @param {WidgetPickerProps} props Component props.\n */\nexport function WidgetPicker( {\n\tonSelect,\n\titemListLabel = __( 'Widget list' ),\n}: WidgetPickerProps ) {\n\tconst { widgetTypes: registeredTypes } = useDashboardInternalContext();\n\tconst [ selection, setSelection ] = useState< string[] >( [] );\n\tconst [ view, setView ] = useState< View >( DEFAULT_VIEW );\n\n\tconst { data: widgetTypes } = filterSortAndPaginate(\n\t\tregisteredTypes,\n\t\tview,\n\t\tfields\n\t);\n\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: __( 'Select' ),\n\t\t\t\tisPrimary: true,\n\t\t\t\tsupportsBulk: true,\n\t\t\t\tcallback: ( items: WidgetType[] ) => onSelect( items ),\n\t\t\t},\n\t\t],\n\t\t[ onSelect ]\n\t);\n\n\treturn (\n\t\t<DataViewsPicker\n\t\t\tdata={ widgetTypes }\n\t\t\tfields={ fields }\n\t\t\tview={ view }\n\t\t\tactions={ actions }\n\t\t\tdefaultLayouts={ { pickerGrid: {} } }\n\t\t\tonChangeView={ setView }\n\t\t\tisLoading={ false }\n\t\t\tpaginationInfo={ {\n\t\t\t\ttotalItems: widgetTypes.length,\n\t\t\t\ttotalPages: 1,\n\t\t\t} }\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ setSelection }\n\t\t\tgetItemId={ getItemId }\n\t\t\titemListLabel={ itemListLabel }\n\t\t/>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"93a9ea86b0\", \"._623aa9eba189276f__preview{height:125%;overflow:hidden;padding:0;pointer-events:none;transform:scale(.8);transform-origin:top left;user-select:none;width:125%}\");\n}\nexport default {\"preview\":\"_623aa9eba189276f__preview\"};\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB,6BAA6B;AAEvD,SAAS,UAAU,SAAS,gBAAgB;AAC5C,SAAS,UAAU;AAMnB,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,oBAAoB;;;ACJ7B,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;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WAAW,YAAa,IAAI,SAAsB,CAAC,CAAE;AAC7D,QAAM,CAAE,MAAM,OAAQ,IAAI,SAAkB,YAAa;AAEzD,QAAM,EAAE,MAAM,YAAY,IAAI;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,UAAU;AAAA,IACf,MAAM;AAAA,MACL;AAAA,QACC,IAAI;AAAA,QACJ,OAAO,GAAI,QAAS;AAAA,QACpB,WAAW;AAAA,QACX,cAAc;AAAA,QACd,UAAU,CAAE,UAAyB,SAAU,KAAM;AAAA,MACtD;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,gBAAiB,EAAE,YAAY,CAAC,EAAE;AAAA,MAClC,cAAe;AAAA,MACf,WAAY;AAAA,MACZ,gBAAiB;AAAA,QAChB,YAAY,YAAY;AAAA,QACxB,YAAY;AAAA,MACb;AAAA,MACA;AAAA,MACA,mBAAoB;AAAA,MACpB;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
3
+ "sources": ["../../../src/components/widget-picker/widget-picker.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataViewsPicker, filterSortAndPaginate } from '@wordpress/dataviews';\nimport type { Field, View } from '@wordpress/dataviews';\nimport { useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { createDashboardWidget } from '../../utils/create-dashboard-widget';\nimport { WidgetPreviewChrome } from '../widget-preview-chrome';\n\nconst DEFAULT_VIEW: View = {\n\ttype: 'pickerGrid',\n\tpage: 1,\n\tsearch: '',\n\tmediaField: 'preview',\n\ttitleField: 'title',\n\t// Larger default tile than the built-in 230.\n\tlayout: { previewSize: 290 },\n};\n\nconst getItemId = ( item: WidgetType ) => item.name;\n\nfunction WidgetPreview( { item }: { item: WidgetType } ) {\n\tconst exampleWidget = useMemo(\n\t\t() => createDashboardWidget( item, item.example?.attributes ),\n\t\t[ item ]\n\t);\n\n\treturn <WidgetPreviewChrome widget={ exampleWidget } widgetType={ item } />;\n}\n\nconst fields: Field< WidgetType >[] = [\n\t{\n\t\tid: 'title',\n\t\ttype: 'text',\n\t\tlabel: __( 'Title' ),\n\t\tfilterBy: false,\n\t},\n\t{\n\t\tid: 'preview',\n\t\ttype: 'media',\n\t\trender: WidgetPreview,\n\t},\n\t{\n\t\tid: 'name',\n\t\ttype: 'text',\n\t\tenableGlobalSearch: true,\n\t\tenableHiding: false,\n\t\tenableSorting: false,\n\t\tfilterBy: false,\n\t\tgetValue: ( { item } ) =>\n\t\t\t`${ item.name.replace( /[\\/,\\-_]/g, ' ' ) } ${ item.title }`,\n\t},\n];\n\ninterface WidgetPickerProps {\n\t/**\n\t * Called with the widget types selected by the user. The picker keeps\n\t * its own selection state; consumers receive the resolved list when\n\t * the \"Select\" action fires.\n\t */\n\tonSelect: ( widgetTypes: WidgetType[] ) => void;\n\n\t/**\n\t * Accessible label for the picker's item list.\n\t *\n\t * @default __( 'Widget list' )\n\t */\n\titemListLabel?: string;\n}\n\n/**\n * DataViews-driven widget type picker. Lists `widgetTypes` from the dashboard\n * context as a grid of live previews, supports search via `name`/`title`, and\n * exposes a single \"Select\" action with bulk support so users can insert one\n * or several widgets at once.\n *\n * @param {WidgetPickerProps} props Component props.\n */\nexport function WidgetPicker( {\n\tonSelect,\n\titemListLabel = __( 'Widget list' ),\n}: WidgetPickerProps ) {\n\tconst { widgetTypes: registeredTypes } = useDashboardInternalContext();\n\tconst [ selection, setSelection ] = useState< string[] >( [] );\n\tconst [ view, setView ] = useState< View >( DEFAULT_VIEW );\n\n\tconst { data: widgetTypes } = filterSortAndPaginate(\n\t\tregisteredTypes,\n\t\tview,\n\t\tfields\n\t);\n\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: __( 'Select' ),\n\t\t\t\tisPrimary: true,\n\t\t\t\tsupportsBulk: true,\n\t\t\t\tcallback: ( items: WidgetType[] ) => onSelect( items ),\n\t\t\t},\n\t\t],\n\t\t[ onSelect ]\n\t);\n\n\treturn (\n\t\t<DataViewsPicker\n\t\t\tdata={ widgetTypes }\n\t\t\tfields={ fields }\n\t\t\tview={ view }\n\t\t\tactions={ actions }\n\t\t\tdefaultLayouts={ { pickerGrid: {} } }\n\t\t\tonChangeView={ setView }\n\t\t\tisLoading={ false }\n\t\t\tpaginationInfo={ {\n\t\t\t\ttotalItems: widgetTypes.length,\n\t\t\t\ttotalPages: 1,\n\t\t\t} }\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ setSelection }\n\t\t\tgetItemId={ getItemId }\n\t\t\titemListLabel={ itemListLabel }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB,6BAA6B;AAEvD,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU;AAMnB,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAoB5B;AAlBR,IAAM,eAAqB;AAAA,EAC1B,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,YAAY;AAAA;AAAA,EAEZ,QAAQ,EAAE,aAAa,IAAI;AAC5B;AAEA,IAAM,YAAY,CAAE,SAAsB,KAAK;AAE/C,SAAS,cAAe,EAAE,KAAK,GAA0B;AACxD,QAAM,gBAAgB;AAAA,IACrB,MAAM,sBAAuB,MAAM,KAAK,SAAS,UAAW;AAAA,IAC5D,CAAE,IAAK;AAAA,EACR;AAEA,SAAO,oBAAC,uBAAoB,QAAS,eAAgB,YAAa,MAAO;AAC1E;AAEA,IAAM,SAAgC;AAAA,EACrC;AAAA,IACC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,OAAO,G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1,6 @@
1
+ // packages/widget-dashboard/src/components/widget-preview-chrome/index.ts
2
+ import { WidgetPreviewChrome } from "./widget-preview-chrome.mjs";
3
+ export {
4
+ WidgetPreviewChrome
5
+ };
6
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/widget-preview-chrome/index.ts"],
4
+ "sourcesContent": ["export { WidgetPreviewChrome } from './widget-preview-chrome';\nexport type { WidgetPreviewChromeProps } from './widget-preview-chrome';\n"],
5
+ "mappings": ";AAAA,SAAS,2BAA2B;",
6
+ "names": []
7
+ }
@@ -1,6 +1,8 @@
1
- // packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.tsx
2
- import { WidgetToolbar } from "../widget-toolbar/index.mjs";
3
- import { WidgetSettingsTrigger } from "./widget-settings-trigger.mjs";
1
+ // packages/widget-dashboard/src/components/widget-preview-chrome/widget-preview-chrome.tsx
2
+ import { useId, useMemo } from "@wordpress/element";
3
+ import { Card } from "@wordpress/ui";
4
+ import { WidgetContextProvider } from "../../context/widget-context.mjs";
5
+ import { WidgetFrame } from "../widget-frame/index.mjs";
4
6
 
5
7
  // packages/style-runtime/src/index.ts
6
8
  var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
@@ -84,30 +86,46 @@ function registerStyle(hash, css) {
84
86
  }
85
87
  }
86
88
 
87
- // packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.module.css
89
+ // packages/widget-dashboard/src/components/widget-preview-chrome/widget-preview-chrome.module.css
88
90
  if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
89
- registerStyle("76555dc7e2", "._931c420497181bdb__widgetSettingsToolbar{background:color-mix(in srgb,var(--wpds-color-background-surface-neutral,#fcfcfc) 40%,transparent);opacity:0;pointer-events:none}[data-wp-grid-item-key]:focus-within ._931c420497181bdb__widgetSettingsToolbar,[data-wp-grid-item-key]:hover ._931c420497181bdb__widgetSettingsToolbar{opacity:1;pointer-events:auto}@media not (prefers-reduced-motion){._931c420497181bdb__widgetSettingsToolbar{transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}");
91
+ registerStyle("c47f6c464f", "._23cdee3dfcd79c9c__viewport{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border-radius:var(--wpds-border-radius-md,4px);inset:0;overflow:hidden;pointer-events:none;position:absolute;user-select:none}._5312b3880a174b72__canvas{display:grid;height:100%;width:100%}._8b8693cb129db8d2__card{height:100%;min-height:0}");
90
92
  }
91
- var widget_settings_toolbar_default = { "widgetSettingsToolbar": "_931c420497181bdb__widgetSettingsToolbar" };
93
+ var widget_preview_chrome_default = { "viewport": "_23cdee3dfcd79c9c__viewport", "canvas": "_5312b3880a174b72__canvas", "card": "_8b8693cb129db8d2__card" };
92
94
 
93
- // packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.tsx
95
+ // packages/widget-dashboard/src/components/widget-preview-chrome/widget-preview-chrome.tsx
94
96
  import { jsx } from "react/jsx-runtime";
95
- function WidgetSettingsToolbar({
97
+ function WidgetPreviewChrome({
96
98
  widget,
97
- widgetType
99
+ widgetType,
100
+ index = 0
98
101
  }) {
99
- if (!widgetType.attributes?.length) {
100
- return null;
101
- }
102
- return /* @__PURE__ */ jsx(WidgetToolbar, { className: widget_settings_toolbar_default.widgetSettingsToolbar, children: /* @__PURE__ */ jsx(
103
- WidgetSettingsTrigger,
102
+ const titleId = useId();
103
+ const contextValue = useMemo(
104
+ () => ({
105
+ uuid: widget.uuid,
106
+ name: widget.type,
107
+ index
108
+ }),
109
+ [widget.uuid, widget.type, index]
110
+ );
111
+ return /* @__PURE__ */ jsx(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { className: widget_preview_chrome_default.viewport, ...{ inert: "" }, children: /* @__PURE__ */ jsx("div", { className: widget_preview_chrome_default.canvas, children: /* @__PURE__ */ jsx(
112
+ Card.Root,
104
113
  {
105
- widget,
106
- widgetType
114
+ render: /* @__PURE__ */ jsx("section", {}),
115
+ className: widget_preview_chrome_default.card,
116
+ "aria-labelledby": widgetType.title ? titleId : void 0,
117
+ children: /* @__PURE__ */ jsx(
118
+ WidgetFrame,
119
+ {
120
+ widget,
121
+ widgetType,
122
+ titleId
123
+ }
124
+ )
107
125
  }
108
- ) });
126
+ ) }) }) });
109
127
  }
110
128
  export {
111
- WidgetSettingsToolbar
129
+ WidgetPreviewChrome
112
130
  };
113
- //# sourceMappingURL=widget-settings-toolbar.mjs.map
131
+ //# sourceMappingURL=widget-preview-chrome.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/widget-preview-chrome/widget-preview-chrome.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-preview-chrome/widget-preview-chrome.module.css"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useId, useMemo } from '@wordpress/element';\nimport { Card } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { WidgetContextProvider } from '../../context/widget-context';\nimport { WidgetFrame } from '../widget-frame';\nimport styles from './widget-preview-chrome.module.css';\nimport type { DashboardWidget } from '../../types';\n\nexport interface WidgetPreviewChromeProps {\n\twidget: DashboardWidget< unknown >;\n\twidgetType: WidgetType;\n\tindex?: number;\n}\n\n/**\n * Catalog host-chrome: the faithful `WidgetFrame` in a viewport that scales the\n * card to fill the tile at any zoom; inert so the picker owns selection.\n *\n * @param {WidgetPreviewChromeProps} props Component props.\n */\nexport function WidgetPreviewChrome( {\n\twidget,\n\twidgetType,\n\tindex = 0,\n}: WidgetPreviewChromeProps ) {\n\tconst titleId = useId();\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tuuid: widget.uuid,\n\t\t\tname: widget.type,\n\t\t\tindex,\n\t\t} ),\n\t\t[ widget.uuid, widget.type, index ]\n\t);\n\n\treturn (\n\t\t<WidgetContextProvider value={ contextValue }>\n\t\t\t<div className={ styles.viewport } { ...{ inert: '' } }>\n\t\t\t\t<div className={ styles.canvas }>\n\t\t\t\t\t<Card.Root\n\t\t\t\t\t\trender={ <section /> }\n\t\t\t\t\t\tclassName={ styles.card }\n\t\t\t\t\t\taria-labelledby={\n\t\t\t\t\t\t\twidgetType.title ? titleId : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<WidgetFrame\n\t\t\t\t\t\t\twidget={ widget }\n\t\t\t\t\t\t\twidgetType={ widgetType }\n\t\t\t\t\t\t\ttitleId={ titleId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Card.Root>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</WidgetContextProvider>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"c47f6c464f\", \"._23cdee3dfcd79c9c__viewport{background:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);border-radius:var(--wpds-border-radius-md,4px);inset:0;overflow:hidden;pointer-events:none;position:absolute;user-select:none}._5312b3880a174b72__canvas{display:grid;height:100%;width:100%}._8b8693cb129db8d2__card{height:100%;min-height:0}\");\n}\nexport default {\"viewport\":\"_23cdee3dfcd79c9c__viewport\",\"canvas\":\"_5312b3880a174b72__canvas\",\"card\":\"_8b8693cb129db8d2__card\"};\n"],
5
+ "mappings": ";AAGA,SAAS,OAAO,eAAe;AAC/B,SAAS,YAAY;AAMrB,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;;;ACD5B,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY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AAU;AAAA,MAG9B;AAAA,QAAC;AAAA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA;AAAA,MACD;AAAA;AAAA,EACD,GACD,GACD,GACD;AAEF;",
6
+ "names": []
7
+ }
@@ -1,10 +1,10 @@
1
1
  // packages/widget-dashboard/src/components/widget-settings/index.ts
2
2
  import { WidgetSettings } from "./widget-settings.mjs";
3
3
  import { getWidgetSettingsTitle } from "./utils/index.mjs";
4
- import { WidgetSettingsToolbar } from "./widget-settings-toolbar.mjs";
4
+ import { WidgetSettingsTrigger } from "./widget-settings-trigger.mjs";
5
5
  export {
6
6
  WidgetSettings,
7
- WidgetSettingsToolbar,
7
+ WidgetSettingsTrigger,
8
8
  getWidgetSettingsTitle
9
9
  };
10
10
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/widget-settings/index.ts"],
4
- "sourcesContent": ["export { WidgetSettings } from './widget-settings';\nexport { getWidgetSettingsTitle } from './utils';\nexport { WidgetSettingsToolbar } from './widget-settings-toolbar';\nexport type { WidgetSettingsToolbarProps } from './widget-settings-toolbar';\n"],
4
+ "sourcesContent": ["export { WidgetSettings } from './widget-settings';\nexport { getWidgetSettingsTitle } from './utils';\nexport { WidgetSettingsTrigger } from './widget-settings-trigger';\nexport type { WidgetSettingsTriggerProps } from './widget-settings-trigger';\n"],
5
5
  "mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,6BAA6B;",
6
6
  "names": []
7
7
  }
@@ -1,8 +1,6 @@
1
1
  // packages/widget-dashboard/src/components/widget-settings/utils/index.ts
2
- import { getAdminMenuInset } from "./get-admin-menu-inset.mjs";
3
2
  import { getWidgetSettingsTitle } from "./get-widget-settings.mjs";
4
3
  export {
5
- getAdminMenuInset,
6
4
  getWidgetSettingsTitle
7
5
  };
8
6
  //# sourceMappingURL=index.mjs.map