@wordpress/widget-dashboard 0.1.1 → 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 +24 -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/widget-settings/utils/index.ts"],
4
- "sourcesContent": ["export { getAdminMenuInset } from './get-admin-menu-inset';\nexport { getWidgetSettingsTitle } from './get-widget-settings';\n"],
5
- "mappings": ";AAAA,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;",
4
+ "sourcesContent": ["export { getWidgetSettingsTitle } from './get-widget-settings';\n"],
5
+ "mappings": ";AAAA,SAAS,8BAA8B;",
6
6
  "names": []
7
7
  }
@@ -1,53 +1,47 @@
1
1
  // packages/widget-dashboard/src/components/widget-settings/widget-settings-trigger.tsx
2
2
  import { useCallback } from "@wordpress/element";
3
3
  import { __ } from "@wordpress/i18n";
4
- import { cog } from "@wordpress/icons";
4
+ import { moreVertical } from "@wordpress/icons";
5
5
  import { IconButton } from "@wordpress/ui";
6
+ import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
6
7
  import { useDashboardUIContext } from "../../context/ui-context.mjs";
7
- import { getAdminMenuInset } from "./utils/index.mjs";
8
8
  import { jsx } from "react/jsx-runtime";
9
9
  function WidgetSettingsTrigger({
10
10
  widget,
11
11
  widgetType
12
12
  }) {
13
- const {
13
+ const { settingsWidgetUuid, setSettingsWidgetUuid } = useDashboardUIContext();
14
+ const { cancel, flushAutoSave } = useDashboardInternalContext();
15
+ const toggle = useCallback(() => {
16
+ if (settingsWidgetUuid === widget.uuid) {
17
+ cancel();
18
+ setSettingsWidgetUuid(null);
19
+ return;
20
+ }
21
+ flushAutoSave();
22
+ setSettingsWidgetUuid(widget.uuid);
23
+ }, [
24
+ cancel,
25
+ flushAutoSave,
26
+ settingsWidgetUuid,
14
27
  setSettingsWidgetUuid,
15
- setSettingsDrawerSide,
16
- setSettingsDrawerInset
17
- } = useDashboardUIContext();
18
- const open = useCallback(
19
- (event) => {
20
- const adminMenuInset = getAdminMenuInset();
21
- const tile = event.currentTarget.closest(
22
- "[data-wp-grid-item-key]"
23
- );
24
- const rect = (tile ?? event.currentTarget).getBoundingClientRect();
25
- const widgetCenter = rect.left + rect.width / 2;
26
- const contentCenter = (adminMenuInset + window.innerWidth) / 2;
27
- const side = widgetCenter > contentCenter ? "left" : "right";
28
- setSettingsDrawerSide(side);
29
- setSettingsDrawerInset(side === "left" ? adminMenuInset : 0);
30
- setSettingsWidgetUuid(widget.uuid);
31
- },
32
- [
33
- setSettingsDrawerSide,
34
- setSettingsDrawerInset,
35
- setSettingsWidgetUuid,
36
- widget.uuid
37
- ]
28
+ widget.uuid
29
+ ]);
30
+ const hasNonPromotedAttributes = widgetType.attributes?.some(
31
+ (attribute) => attribute.relevance !== "high"
38
32
  );
39
- if (!widgetType.attributes?.length) {
33
+ if (!hasNonPromotedAttributes) {
40
34
  return null;
41
35
  }
42
36
  return /* @__PURE__ */ jsx(
43
37
  IconButton,
44
38
  {
45
- icon: cog,
39
+ icon: moreVertical,
46
40
  label: __("Widget settings"),
47
41
  variant: "minimal",
48
42
  tone: "neutral",
49
43
  size: "compact",
50
- onClick: open
44
+ onClick: toggle
51
45
  }
52
46
  );
53
47
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/widget-settings/widget-settings-trigger.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { cog } from '@wordpress/icons';\n// Dashboard is still experimental.\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { IconButton } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { getAdminMenuInset } from './utils';\nimport type { DashboardWidget } from '../../types';\n\nexport interface WidgetSettingsTriggerProps {\n\t/**\n\t * The instance whose settings drawer this gear opens.\n\t */\n\twidget: DashboardWidget< unknown >;\n\n\t/**\n\t * The instance's widget type, used for the accessible label and the\n\t * attributes guard.\n\t */\n\twidgetType: WidgetType;\n}\n\n/**\n * Per-instance gear that opens the shared settings drawer by writing the\n * instance `uuid` to the UI context; the single `WidgetSettings` at the root\n * reacts to it. Returns `null` when the type declares no attributes, so chrome\n * can mount it unconditionally.\n *\n * @param {WidgetSettingsTriggerProps} props Component props.\n */\nexport function WidgetSettingsTrigger( {\n\twidget,\n\twidgetType,\n}: WidgetSettingsTriggerProps ): React.ReactNode {\n\tconst {\n\t\tsetSettingsWidgetUuid,\n\t\tsetSettingsDrawerSide,\n\t\tsetSettingsDrawerInset,\n\t} = useDashboardUIContext();\n\n\tconst open = useCallback(\n\t\t( event: React.MouseEvent< HTMLElement > ) => {\n\t\t\t// Open the drawer on the side away from the widget: compare the\n\t\t\t// tile's center against the midpoint of the usable content area\n\t\t\t// (which starts after the admin menu). Past it opens left.\n\t\t\tconst adminMenuInset = getAdminMenuInset();\n\t\t\t// The gear sits in the grid slot, outside the card, so reach the\n\t\t\t// tile via the grid item's data hook.\n\t\t\tconst tile = event.currentTarget.closest(\n\t\t\t\t'[data-wp-grid-item-key]'\n\t\t\t);\n\t\t\tconst rect = (\n\t\t\t\ttile ?? event.currentTarget\n\t\t\t).getBoundingClientRect();\n\t\t\tconst widgetCenter = rect.left + rect.width / 2;\n\t\t\tconst contentCenter = ( adminMenuInset + window.innerWidth ) / 2;\n\t\t\tconst side = widgetCenter > contentCenter ? 'left' : 'right';\n\n\t\t\tsetSettingsDrawerSide( side );\n\t\t\t// A left drawer would otherwise slide over the fixed admin menu;\n\t\t\t// offset it by the menu width so it lands clear of it.\n\t\t\tsetSettingsDrawerInset( side === 'left' ? adminMenuInset : 0 );\n\t\t\tsetSettingsWidgetUuid( widget.uuid );\n\t\t},\n\t\t[\n\t\t\tsetSettingsDrawerSide,\n\t\t\tsetSettingsDrawerInset,\n\t\t\tsetSettingsWidgetUuid,\n\t\t\twidget.uuid,\n\t\t]\n\t);\n\n\tif ( ! widgetType.attributes?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<IconButton\n\t\t\ticon={ cog }\n\t\t\tlabel={ __( 'Widget settings' ) }\n\t\t\tvariant=\"minimal\"\n\t\t\ttone=\"neutral\"\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ open }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,WAAW;AAGpB,SAAS,kBAAkB;AAM3B,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAuEhC;AA/CK,SAAS,sBAAuB;AAAA,EACtC;AAAA,EACA;AACD,GAAiD;AAChD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,sBAAsB;AAE1B,QAAM,OAAO;AAAA,IACZ,CAAE,UAA4C;AAI7C,YAAM,iBAAiB,kBAAkB;AAGzC,YAAM,OAAO,MAAM,cAAc;AAAA,QAChC;AAAA,MACD;AACA,YAAM,QACL,QAAQ,MAAM,eACb,sBAAsB;AACxB,YAAM,eAAe,KAAK,OAAO,KAAK,QAAQ;AAC9C,YAAM,iBAAkB,iBAAiB,OAAO,cAAe;AAC/D,YAAM,OAAO,eAAe,gBAAgB,SAAS;AAErD,4BAAuB,IAAK;AAG5B,6BAAwB,SAAS,SAAS,iBAAiB,CAAE;AAC7D,4BAAuB,OAAO,IAAK;AAAA,IACpC;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACR;AAAA,EACD;AAEA,MAAK,CAAE,WAAW,YAAY,QAAS;AACtC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,OAAQ,GAAI,iBAAkB;AAAA,MAC9B,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAU;AAAA;AAAA,EACX;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { moreVertical } from '@wordpress/icons';\n// Dashboard is still experimental.\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { IconButton } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport type { DashboardWidget } from '../../types';\n\nexport interface WidgetSettingsTriggerProps {\n\t/**\n\t * The instance whose settings drawer this gear opens.\n\t */\n\twidget: DashboardWidget< unknown >;\n\n\t/**\n\t * The instance's widget type, used for the accessible label and the\n\t * attributes guard.\n\t */\n\twidgetType: WidgetType;\n}\n\n/**\n * Per-instance gear that toggles the shared settings drawer by writing the\n * instance `uuid` to the UI context; the single `WidgetSettings` at the root\n * reacts to it. Clicking the gear of the instance whose drawer is already\n * open closes it. Returns `null` when no attribute needs the drawer (none, or\n * all already promoted inline), so chrome can mount it unconditionally.\n *\n * @param {WidgetSettingsTriggerProps} props Component props.\n */\nexport function WidgetSettingsTrigger( {\n\twidget,\n\twidgetType,\n}: WidgetSettingsTriggerProps ): React.ReactNode {\n\tconst { settingsWidgetUuid, setSettingsWidgetUuid } =\n\t\tuseDashboardUIContext();\n\tconst { cancel, flushAutoSave } = useDashboardInternalContext();\n\n\tconst toggle = useCallback( () => {\n\t\t// Re-clicking the open instance's gear closes the drawer, discarding\n\t\t// staged edits like any other non-Save exit.\n\t\tif ( settingsWidgetUuid === widget.uuid ) {\n\t\t\tcancel();\n\t\t\tsetSettingsWidgetUuid( null );\n\t\t\treturn;\n\t\t}\n\t\t// Persist any pending inline edit before opening, so the drawer's edits\n\t\t// stay isolated and its Cancel discards only the drawer's own changes.\n\t\tflushAutoSave();\n\t\tsetSettingsWidgetUuid( widget.uuid );\n\t}, [\n\t\tcancel,\n\t\tflushAutoSave,\n\t\tsettingsWidgetUuid,\n\t\tsetSettingsWidgetUuid,\n\t\twidget.uuid,\n\t] );\n\n\t// Surface the drawer only when there are attributes not already promoted\n\t// inline; if every attribute is high-relevance, the drawer would just\n\t// repeat the toolbar.\n\tconst hasNonPromotedAttributes = widgetType.attributes?.some(\n\t\t( attribute ) => attribute.relevance !== 'high'\n\t);\n\tif ( ! hasNonPromotedAttributes ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<IconButton\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Widget settings' ) }\n\t\t\tvariant=\"minimal\"\n\t\t\ttone=\"neutral\"\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ toggle }\n\t\t/>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAG7B,SAAS,kBAAkB;AAM3B,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AAgEpC;AAvCK,SAAS,sBAAuB;AAAA,EACtC;AAAA,EACA;AACD,GAAiD;AAChD,QAAM,EAAE,oBAAoB,sBAAsB,IACjD,sBAAsB;AACvB,QAAM,EAAE,QAAQ,cAAc,IAAI,4BAA4B;AAE9D,QAAM,SAAS,YAAa,MAAM;AAGjC,QAAK,uBAAuB,OAAO,MAAO;AACzC,aAAO;AACP,4BAAuB,IAAK;AAC5B;AAAA,IACD;AAGA,kBAAc;AACd,0BAAuB,OAAO,IAAK;AAAA,EACpC,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,EACR,CAAE;AAKF,QAAM,2BAA2B,WAAW,YAAY;AAAA,IACvD,CAAE,cAAe,UAAU,cAAc;AAAA,EAC1C;AACA,MAAK,CAAE,0BAA2B;AACjC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,OAAQ,GAAI,iBAAkB;AAAA,MAC9B,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAU;AAAA;AAAA,EACX;AAEF;",
6
6
  "names": []
7
7
  }
@@ -106,12 +106,7 @@ function WidgetSettings() {
106
106
  cancel: cancelStaging,
107
107
  hasUncommittedChanges
108
108
  } = useDashboardInternalContext();
109
- const {
110
- settingsWidgetUuid,
111
- setSettingsWidgetUuid,
112
- settingsDrawerSide,
113
- settingsDrawerInset
114
- } = useDashboardUIContext();
109
+ const { settingsWidgetUuid, setSettingsWidgetUuid } = useDashboardUIContext();
115
110
  const open = settingsWidgetUuid !== null;
116
111
  const [lastWidgetUuid, setLastWidgetUuid] = useState(
117
112
  settingsWidgetUuid
@@ -171,10 +166,6 @@ function WidgetSettings() {
171
166
  },
172
167
  [cancelStaging, close]
173
168
  );
174
- const popupStyle = useMemo(
175
- () => settingsDrawerSide === "left" && settingsDrawerInset > 0 ? { marginLeft: settingsDrawerInset } : {},
176
- [settingsDrawerSide, settingsDrawerInset]
177
- );
178
169
  const hasForm = !!widget && !!widgetType && fields.length > 0;
179
170
  if (!hasForm) {
180
171
  return null;
@@ -186,55 +177,47 @@ function WidgetSettings() {
186
177
  {
187
178
  open,
188
179
  onOpenChange: handleOpenChange,
189
- swipeDirection: settingsDrawerSide,
180
+ swipeDirection: "right",
190
181
  modal: false,
191
182
  disablePointerDismissal: true,
192
- children: /* @__PURE__ */ jsxs(
193
- Drawer.Popup,
194
- {
195
- size: "medium",
196
- className: widget_settings_default.popup,
197
- style: popupStyle,
198
- children: [
199
- /* @__PURE__ */ jsxs(Drawer.Header, { children: [
200
- /* @__PURE__ */ jsx(Drawer.Title, { children: title }),
201
- /* @__PURE__ */ jsx(Drawer.CloseIcon, {})
202
- ] }),
203
- /* @__PURE__ */ jsx(Drawer.Content, { children: /* @__PURE__ */ jsx(
204
- DataForm,
205
- {
206
- data,
207
- fields,
208
- form,
209
- onChange: handleChange
210
- }
211
- ) }),
212
- /* @__PURE__ */ jsxs(Drawer.Footer, { children: [
213
- /* @__PURE__ */ jsx(
214
- Button,
215
- {
216
- variant: "minimal",
217
- tone: "brand",
218
- size: "compact",
219
- onClick: () => handleOpenChange(false),
220
- children: __("Cancel")
221
- }
222
- ),
223
- /* @__PURE__ */ jsx(
224
- Button,
225
- {
226
- variant: "solid",
227
- tone: "brand",
228
- size: "compact",
229
- onClick: handleSave,
230
- disabled: !hasUncommittedChanges,
231
- children: __("Save")
232
- }
233
- )
234
- ] })
235
- ]
236
- }
237
- )
183
+ children: /* @__PURE__ */ jsxs(Drawer.Popup, { size: "medium", className: widget_settings_default.popup, children: [
184
+ /* @__PURE__ */ jsxs(Drawer.Header, { children: [
185
+ /* @__PURE__ */ jsx(Drawer.Title, { children: title }),
186
+ /* @__PURE__ */ jsx(Drawer.CloseIcon, {})
187
+ ] }),
188
+ /* @__PURE__ */ jsx(Drawer.Content, { children: /* @__PURE__ */ jsx(
189
+ DataForm,
190
+ {
191
+ data,
192
+ fields,
193
+ form,
194
+ onChange: handleChange
195
+ }
196
+ ) }),
197
+ /* @__PURE__ */ jsxs(Drawer.Footer, { children: [
198
+ /* @__PURE__ */ jsx(
199
+ Button,
200
+ {
201
+ variant: "minimal",
202
+ tone: "brand",
203
+ size: "compact",
204
+ onClick: () => handleOpenChange(false),
205
+ children: __("Cancel")
206
+ }
207
+ ),
208
+ /* @__PURE__ */ jsx(
209
+ Button,
210
+ {
211
+ variant: "solid",
212
+ tone: "brand",
213
+ size: "compact",
214
+ onClick: handleSave,
215
+ disabled: !hasUncommittedChanges,
216
+ children: __("Save")
217
+ }
218
+ )
219
+ ] })
220
+ ] })
238
221
  }
239
222
  );
240
223
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/widget-settings/widget-settings.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-settings/widget-settings.module.css"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// Dashboard is still experimental.\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Drawer } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { getWidgetSettingsTitle } from './utils';\nimport styles from './widget-settings.module.css';\n\ntype WidgetAttributes = Record< string, unknown >;\n\n/**\n * Side drawer that edits one instance's attributes, mounted once at the\n * dashboard root. It resolves the active instance from `settingsWidgetUuid`\n * in the UI context (set by the per-instance gear), renders the type's\n * declarative `attributes` through `DataForm`, and enters from the edge away\n * from the widget.\n *\n * Edits write to the staging layer, so they preview live behind the drawer\n * and are published on Save or reverted on any other exit. Available in\n * normal mode only; the gear is hidden while the layout is being edited.\n */\nexport function WidgetSettings(): React.ReactNode {\n\tconst {\n\t\tlayout,\n\t\tonLayoutChange,\n\t\twidgetTypes,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t} = useDashboardInternalContext();\n\tconst {\n\t\tsettingsWidgetUuid,\n\t\tsetSettingsWidgetUuid,\n\t\tsettingsDrawerSide,\n\t\tsettingsDrawerInset,\n\t} = useDashboardUIContext();\n\n\tconst open = settingsWidgetUuid !== null;\n\n\t// Keep the last opened instance resolved while the drawer animates\n\t// closed so its form and title don't blank out mid-transition. While\n\t// open the live `settingsWidgetUuid` wins, so opening shows no stale\n\t// frame.\n\tconst [ lastWidgetUuid, setLastWidgetUuid ] = useState< string | null >(\n\t\tsettingsWidgetUuid\n\t);\n\tuseEffect( () => {\n\t\tif ( settingsWidgetUuid ) {\n\t\t\tsetLastWidgetUuid( settingsWidgetUuid );\n\t\t}\n\t}, [ settingsWidgetUuid ] );\n\n\tconst activeUuid = settingsWidgetUuid ?? lastWidgetUuid;\n\tconst widget = activeUuid\n\t\t? layout.find( ( instance ) => instance.uuid === activeUuid )\n\t\t: undefined;\n\tconst widgetType = widget\n\t\t? widgetTypes.find( ( type ) => type.name === widget.type )\n\t\t: undefined;\n\n\tconst fields = useMemo< Field< WidgetAttributes >[] >(\n\t\t() => ( widgetType?.attributes ?? [] ) as Field< WidgetAttributes >[],\n\t\t[ widgetType?.attributes ]\n\t);\n\n\tconst form = useMemo< Form >(\n\t\t() => ( {\n\t\t\tlayout: { type: 'regular', labelPosition: 'top' },\n\t\t\tfields: fields.map( ( field ) => field.id ),\n\t\t} ),\n\t\t[ fields ]\n\t);\n\n\tconst handleChange = useCallback(\n\t\t( edits: Record< string, unknown > ) => {\n\t\t\tif ( ! widget ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( instance ) =>\n\t\t\t\t\tinstance.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...instance,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( instance.attributes as object ),\n\t\t\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: instance\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ layout, onLayoutChange, widget ]\n\t);\n\n\tconst close = useCallback(\n\t\t() => setSettingsWidgetUuid( null ),\n\t\t[ setSettingsWidgetUuid ]\n\t);\n\n\tconst handleSave = useCallback( () => {\n\t\tcommit();\n\t\tclose();\n\t}, [ commit, close ] );\n\n\tconst handleOpenChange = useCallback(\n\t\t( nextOpen: boolean ) => {\n\t\t\t// Any path out of the drawer other than Save discards the\n\t\t\t// staged edits, matching the layout-settings drawer.\n\t\t\tif ( ! nextOpen ) {\n\t\t\t\tcancelStaging();\n\t\t\t\tclose();\n\t\t\t}\n\t\t},\n\t\t[ cancelStaging, close ]\n\t);\n\n\t// For a left drawer, clear the fixed admin menu on the inline-start\n\t// edge so the drawer lands beside it. The admin bar at the top is\n\t// cleared in the CSS module.\n\tconst popupStyle = useMemo< React.CSSProperties >(\n\t\t() =>\n\t\t\tsettingsDrawerSide === 'left' && settingsDrawerInset > 0\n\t\t\t\t? { marginLeft: settingsDrawerInset }\n\t\t\t\t: {},\n\t\t[ settingsDrawerSide, settingsDrawerInset ]\n\t);\n\n\tconst hasForm = !! widget && !! widgetType && fields.length > 0;\n\n\tif ( ! hasForm ) {\n\t\treturn null;\n\t}\n\n\tconst title = getWidgetSettingsTitle( widgetType );\n\tconst data = ( widget?.attributes ??\n\t\twidgetType?.example?.attributes ??\n\t\t{} ) as WidgetAttributes;\n\n\treturn (\n\t\t<Drawer.Root\n\t\t\topen={ open }\n\t\t\tonOpenChange={ handleOpenChange }\n\t\t\tswipeDirection={ settingsDrawerSide }\n\t\t\tmodal={ false }\n\t\t\tdisablePointerDismissal\n\t\t>\n\t\t\t<Drawer.Popup\n\t\t\t\tsize=\"medium\"\n\t\t\t\tclassName={ styles.popup }\n\t\t\t\tstyle={ popupStyle }\n\t\t\t>\n\t\t\t\t<Drawer.Header>\n\t\t\t\t\t<Drawer.Title>{ title }</Drawer.Title>\n\t\t\t\t\t<Drawer.CloseIcon />\n\t\t\t\t</Drawer.Header>\n\n\t\t\t\t<Drawer.Content>\n\t\t\t\t\t<DataForm< WidgetAttributes >\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t</Drawer.Content>\n\n\t\t\t\t<Drawer.Footer>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ () => handleOpenChange( false ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ handleSave }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Drawer.Footer>\n\t\t\t</Drawer.Popup>\n\t\t</Drawer.Root>\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(\"809494c486\", \"._34828f30ba41ad89__popup{margin-block-start:var(--wp-admin--admin-bar--height,0)}\");\n}\nexport default {\"popup\":\"_34828f30ba41ad89__popup\"};\n"],
5
- "mappings": ";AAGA,SAAS,gBAAgB;AAEzB,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAC1D,SAAS,UAAU;AAGnB,SAAS,QAAQ,cAAc;AAK/B,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;;;ACNvC,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,YAA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MAAK;AAAA,kBACL,SAAU,MAAM,iBAAkB,KAAM;AAAA,kBAEtC,aAAI,QAAS;AAAA;AAAA,cAChB;AAAA,cACA;AAAA,gBAAC;AAAA;AAAA,kBACA,SAAQ;AAAA,kBACR,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,SAAU;AAAA,kBACV,UAAW,CAAE;AAAA,kBAEX,aAAI,MAAO;AAAA;AAAA,cACd;AAAA,eACD;AAAA;AAAA;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// Dashboard is still experimental.\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Drawer } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { getWidgetSettingsTitle } from './utils';\nimport styles from './widget-settings.module.css';\n\ntype WidgetAttributes = Record< string, unknown >;\n\n/**\n * Side drawer that edits one instance's attributes, mounted once at the\n * dashboard root. It resolves the active instance from `settingsWidgetUuid`\n * in the UI context (set by the per-instance gear), renders the type's\n * declarative `attributes` through `DataForm`, and enters from the\n * inline-end edge.\n *\n * Edits write to the staging layer, so they preview live behind the drawer\n * and are published on Save or reverted on any other exit. Available in\n * normal mode only; the gear is hidden while the layout is being edited.\n */\nexport function WidgetSettings(): React.ReactNode {\n\tconst {\n\t\tlayout,\n\t\tonLayoutChange,\n\t\twidgetTypes,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t} = useDashboardInternalContext();\n\tconst { settingsWidgetUuid, setSettingsWidgetUuid } =\n\t\tuseDashboardUIContext();\n\n\tconst open = settingsWidgetUuid !== null;\n\n\t// Keep the last opened instance resolved while the drawer animates\n\t// closed so its form and title don't blank out mid-transition. While\n\t// open the live `settingsWidgetUuid` wins, so opening shows no stale\n\t// frame.\n\tconst [ lastWidgetUuid, setLastWidgetUuid ] = useState< string | null >(\n\t\tsettingsWidgetUuid\n\t);\n\tuseEffect( () => {\n\t\tif ( settingsWidgetUuid ) {\n\t\t\tsetLastWidgetUuid( settingsWidgetUuid );\n\t\t}\n\t}, [ settingsWidgetUuid ] );\n\n\tconst activeUuid = settingsWidgetUuid ?? lastWidgetUuid;\n\tconst widget = activeUuid\n\t\t? layout.find( ( instance ) => instance.uuid === activeUuid )\n\t\t: undefined;\n\tconst widgetType = widget\n\t\t? widgetTypes.find( ( type ) => type.name === widget.type )\n\t\t: undefined;\n\n\tconst fields = useMemo< Field< WidgetAttributes >[] >(\n\t\t() => ( widgetType?.attributes ?? [] ) as Field< WidgetAttributes >[],\n\t\t[ widgetType?.attributes ]\n\t);\n\n\tconst form = useMemo< Form >(\n\t\t() => ( {\n\t\t\tlayout: { type: 'regular', labelPosition: 'top' },\n\t\t\tfields: fields.map( ( field ) => field.id ),\n\t\t} ),\n\t\t[ fields ]\n\t);\n\n\tconst handleChange = useCallback(\n\t\t( edits: Record< string, unknown > ) => {\n\t\t\tif ( ! widget ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( instance ) =>\n\t\t\t\t\tinstance.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...instance,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( instance.attributes as object ),\n\t\t\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: instance\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ layout, onLayoutChange, widget ]\n\t);\n\n\tconst close = useCallback(\n\t\t() => setSettingsWidgetUuid( null ),\n\t\t[ setSettingsWidgetUuid ]\n\t);\n\n\tconst handleSave = useCallback( () => {\n\t\tcommit();\n\t\tclose();\n\t}, [ commit, close ] );\n\n\tconst handleOpenChange = useCallback(\n\t\t( nextOpen: boolean ) => {\n\t\t\t// Any path out of the drawer other than Save discards the\n\t\t\t// staged edits.\n\t\t\tif ( ! nextOpen ) {\n\t\t\t\tcancelStaging();\n\t\t\t\tclose();\n\t\t\t}\n\t\t},\n\t\t[ cancelStaging, close ]\n\t);\n\n\tconst hasForm = !! widget && !! widgetType && fields.length > 0;\n\n\tif ( ! hasForm ) {\n\t\treturn null;\n\t}\n\n\tconst title = getWidgetSettingsTitle( widgetType );\n\tconst data = ( widget?.attributes ??\n\t\twidgetType?.example?.attributes ??\n\t\t{} ) as WidgetAttributes;\n\n\treturn (\n\t\t<Drawer.Root\n\t\t\topen={ open }\n\t\t\tonOpenChange={ handleOpenChange }\n\t\t\tswipeDirection=\"right\"\n\t\t\tmodal={ false }\n\t\t\tdisablePointerDismissal\n\t\t>\n\t\t\t<Drawer.Popup size=\"medium\" className={ styles.popup }>\n\t\t\t\t<Drawer.Header>\n\t\t\t\t\t<Drawer.Title>{ title }</Drawer.Title>\n\t\t\t\t\t<Drawer.CloseIcon />\n\t\t\t\t</Drawer.Header>\n\n\t\t\t\t<Drawer.Content>\n\t\t\t\t\t<DataForm< WidgetAttributes >\n\t\t\t\t\t\tdata={ data }\n\t\t\t\t\t\tfields={ fields }\n\t\t\t\t\t\tform={ form }\n\t\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t\t/>\n\t\t\t\t</Drawer.Content>\n\n\t\t\t\t<Drawer.Footer>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ () => handleOpenChange( false ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ handleSave }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Drawer.Footer>\n\t\t\t</Drawer.Popup>\n\t\t</Drawer.Root>\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(\"809494c486\", \"._34828f30ba41ad89__popup{margin-block-start:var(--wp-admin--admin-bar--height,0)}\");\n}\nexport default {\"popup\":\"_34828f30ba41ad89__popup\"};\n"],
5
+ "mappings": ";AAGA,SAAS,gBAAgB;AAEzB,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAC1D,SAAS,UAAU;AAGnB,SAAS,QAAQ,cAAc;AAK/B,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;;;ACNvC,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;AAA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ACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,UAAW;AAAA;AAAA,QACZ,GACD;AAAA,QAEA,qBAAC,OAAO,QAAP,EACA;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,MAAK;AAAA,cACL,SAAU,MAAM,iBAAkB,KAAM;AAAA,cAEtC,aAAI,QAAS;AAAA;AAAA,UAChB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,MAAK;AAAA,cACL,SAAU;AAAA,cACV,UAAW,CAAE;AAAA,cAEX,aAAI,MAAO;AAAA;AAAA,UACd;AAAA,WACD;AAAA,SACD;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -86,15 +86,15 @@ function registerStyle(hash, css) {
86
86
 
87
87
  // packages/widget-dashboard/src/components/widget-toolbar/widget-toolbar.module.css
88
88
  if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
89
- registerStyle("c8afc26222", "._4a01b99834540429__widgetToolbar{border-radius:var(--wpds-border-radius-md,4px);inset-block-start:var(--wpds-dimension-padding-sm,8px);inset-inline-end:var(--wpds-dimension-padding-sm,8px);padding:var(--wpds-dimension-padding-xs,4px);position:absolute;z-index:1}");
89
+ registerStyle("e1a51f5597", "._4a01b99834540429__widgetToolbar{background:var(--wpds-color-background-surface-neutral-strong,#fff);padding:var(--wpds-dimension-padding-xs,4px)}._78bb9900d58f945e__elevated{border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);box-shadow:var(--wpds-elevation-xs,0 1px 1px 0 #00000008,0 1px 2px 0 #00000005,0 3px 3px 0 #00000005,0 4px 4px 0 #00000003)}");
90
90
  }
91
- var widget_toolbar_default = { "widgetToolbar": "_4a01b99834540429__widgetToolbar" };
91
+ var widget_toolbar_default = { "widgetToolbar": "_4a01b99834540429__widgetToolbar", "elevated": "_78bb9900d58f945e__elevated" };
92
92
 
93
93
  // packages/widget-dashboard/src/components/widget-toolbar/widget-toolbar.tsx
94
94
  import { jsx } from "react/jsx-runtime";
95
95
  function WidgetToolbar({
96
96
  children,
97
- className
97
+ editMode = false
98
98
  }) {
99
99
  return /* @__PURE__ */ jsx(
100
100
  Stack,
@@ -102,7 +102,10 @@ function WidgetToolbar({
102
102
  direction: "row",
103
103
  align: "center",
104
104
  gap: "xs",
105
- className: clsx(widget_toolbar_default.widgetToolbar, className),
105
+ className: clsx(
106
+ widget_toolbar_default.widgetToolbar,
107
+ editMode && widget_toolbar_default.elevated
108
+ ),
106
109
  children
107
110
  }
108
111
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/widget-toolbar/widget-toolbar.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-toolbar/widget-toolbar.module.css"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport styles from './widget-toolbar.module.css';\n\nexport interface WidgetToolbarProps {\n\t/** Toolbar controls, laid out in one row. */\n\tchildren: ReactNode;\n\n\t/** Variant surface class (background, reveal). */\n\tclassName?: string;\n}\n\n/**\n * Shared shell for the per-tile action toolbars. Anchors to the tile's\n * top-right corner and lays controls out in the row the header also uses, so\n * a toolbar lines up with the title when they overlap.\n *\n * @param {WidgetToolbarProps} props Component props.\n */\nexport function WidgetToolbar( {\n\tchildren,\n\tclassName,\n}: WidgetToolbarProps ): React.ReactNode {\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"row\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"xs\"\n\t\t\tclassName={ clsx( styles.widgetToolbar, className ) }\n\t\t>\n\t\t\t{ children }\n\t\t</Stack>\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(\"c8afc26222\", \"._4a01b99834540429__widgetToolbar{border-radius:var(--wpds-border-radius-md,4px);inset-block-start:var(--wpds-dimension-padding-sm,8px);inset-inline-end:var(--wpds-dimension-padding-sm,8px);padding:var(--wpds-dimension-padding-xs,4px);position:absolute;z-index:1}\");\n}\nexport default {\"widgetToolbar\":\"_4a01b99834540429__widgetToolbar\"};\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,aAAa;;;ACCtB,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,C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;AALK,SAAS,cAAe;AAAA,EAC9B;AAAA,EACA;AACD,GAAyC;AACxC,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,OAAM;AAAA,MACN,KAAI;AAAA,MACJ,WAAY,KAAM,uBAAO,eAAe,SAAU;AAAA,MAEhD;AAAA;AAAA,EACH;AAEF;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport styles from './widget-toolbar.module.css';\n\nexport interface WidgetToolbarProps {\n\t/**\n\t * The active mode's controls.\n\t */\n\tchildren: ReactNode;\n\n\t/**\n\t * Lift the toolbar with a shadow while customizing.\n\t */\n\teditMode?: boolean;\n}\n\n/**\n * The per-tile toolbar chip holding the active mode's controls.\n * Always visible; lifted with a shadow only while customizing.\n *\n * @param {WidgetToolbarProps} props Component props.\n */\nexport function WidgetToolbar( {\n\tchildren,\n\teditMode = false,\n}: WidgetToolbarProps ): React.ReactNode {\n\treturn (\n\t\t<Stack\n\t\t\tdirection=\"row\"\n\t\t\talign=\"center\"\n\t\t\tgap=\"xs\"\n\t\t\tclassName={ clsx(\n\t\t\t\tstyles.widgetToolbar,\n\t\t\t\teditMode && styles.elevated\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</Stack>\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(\"e1a51f5597\", \"._4a01b99834540429__widgetToolbar{background:var(--wpds-color-background-surface-neutral-strong,#fff);padding:var(--wpds-dimension-padding-xs,4px)}._78bb9900d58f945e__elevated{border:1px solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);box-shadow:var(--wpds-elevation-xs,0 1px 1px 0 #00000008,0 1px 2px 0 #00000005,0 3px 3px 0 #00000005,0 4px 4px 0 #00000003)}\");\n}\nexport default {\"widgetToolbar\":\"_4a01b99834540429__widgetToolbar\",\"elevated\":\"_78bb9900d58f945e__elevated\"};\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,aAAa;;;ACCtB,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;AA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,KAAI;AAAA,MACJ,WAAY;AAAA,QACX,uBAAO;AAAA,QACP,YAAY,uBAAO;AAAA,MACpB;AAAA,MAEE;AAAA;AAAA,EACH;AAEF;",
6
6
  "names": []
7
7
  }
@@ -4,9 +4,11 @@ import { forwardRef, useCallback, useMemo } from "@wordpress/element";
4
4
  import { DashboardGrid, DashboardLanes } from "@wordpress/grid";
5
5
  import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
6
6
  import { useDashboardContainerColumnCount } from "../../hooks/use-dashboard-container-column-count.mjs";
7
+ import { WidgetAttributeControls } from "../widget-attribute-controls/index.mjs";
7
8
  import { WidgetChrome } from "../widget-chrome/index.mjs";
8
- import { WidgetSettingsToolbar } from "../widget-settings/index.mjs";
9
- import { WidgetLayoutToolbar } from "./widget-layout-toolbar.mjs";
9
+ import { WidgetHeader } from "../widget-header/index.mjs";
10
+ import { WidgetLayoutControls } from "../widget-layout-controls/index.mjs";
11
+ import { WidgetToolbar } from "../widget-toolbar/index.mjs";
10
12
  import { WidgetResizeHandle } from "./widget-resize-handle.mjs";
11
13
 
12
14
  // packages/style-runtime/src/index.ts
@@ -171,18 +173,22 @@ var Widgets = forwardRef(
171
173
  (type) => type.name === widget.type
172
174
  );
173
175
  const hasSettings = !!widgetType?.attributes?.length;
174
- let actionableArea;
176
+ const isFullBleed = widgetType?.presentation === "full-bleed";
177
+ let controls;
175
178
  if (editMode) {
176
- actionableArea = /* @__PURE__ */ jsx(WidgetLayoutToolbar, { widget });
179
+ controls = /* @__PURE__ */ jsx(WidgetLayoutControls, { widget });
177
180
  } else if (hasSettings && widgetType) {
178
- actionableArea = /* @__PURE__ */ jsx(
179
- WidgetSettingsToolbar,
181
+ controls = /* @__PURE__ */ jsx(
182
+ WidgetAttributeControls,
180
183
  {
181
184
  widget,
182
185
  widgetType
183
186
  }
184
187
  );
185
188
  }
189
+ const toolbar = controls ? /* @__PURE__ */ jsx(WidgetToolbar, { editMode, children: controls }) : void 0;
190
+ const inSlot = editMode || isFullBleed;
191
+ const actionableArea = inSlot && toolbar ? /* @__PURE__ */ jsx(WidgetHeader, { overlay: true, children: toolbar }) : void 0;
186
192
  return /* @__PURE__ */ jsx(
187
193
  WidgetChrome,
188
194
  {
@@ -191,7 +197,8 @@ var Widgets = forwardRef(
191
197
  className: clsx(widgets_default.tile, {
192
198
  [widgets_default.tileEditMode]: editMode
193
199
  }),
194
- actionableArea
200
+ actionableArea,
201
+ headerToolbar: !inSlot ? toolbar : void 0
195
202
  },
196
203
  widget.uuid
197
204
  );
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/widgets/widgets.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widgets/widgets.module.css"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useCallback, useMemo } from '@wordpress/element';\nimport { DashboardGrid, DashboardLanes } from '@wordpress/grid';\nimport type {\n\tDashboardGridLayoutItem,\n\tDashboardLanesLayoutItem,\n\tDragPreviewRenderProps,\n\tResizeHandleRenderProps,\n} from '@wordpress/grid';\nimport type { WidgetName } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardContainerColumnCount } from '../../hooks/use-dashboard-container-column-count';\nimport { WidgetChrome } from '../widget-chrome';\nimport { WidgetSettingsToolbar } from '../widget-settings';\nimport { WidgetLayoutToolbar } from './widget-layout-toolbar';\nimport { WidgetResizeHandle } from './widget-resize-handle';\nimport styles from './widgets.module.css';\nimport type {\n\tDashboardWidget,\n\tGridTilePlacement,\n\tMasonryTilePlacement,\n} from '../../types';\n\nfunction toGridLayout( widgets: DashboardWidget[] ): DashboardGridLayoutItem[] {\n\treturn widgets.map( ( w ) => ( {\n\t\tkey: w.uuid,\n\t\t...( w.placement as GridTilePlacement | undefined ),\n\t} ) );\n}\n\nfunction toMasonryLayout(\n\twidgets: DashboardWidget[]\n): DashboardLanesLayoutItem[] {\n\treturn widgets.map( ( w ) => ( {\n\t\tkey: w.uuid,\n\t\t...( w.placement as MasonryTilePlacement | undefined ),\n\t} ) );\n}\n\nfunction applyGridChange(\n\twidgets: DashboardWidget[],\n\tgridLayout: DashboardGridLayoutItem[]\n): DashboardWidget[] {\n\treturn gridLayout.map( ( { key, ...placement } ) => {\n\t\tconst existing = widgets.find( ( w ) => w.uuid === key );\n\t\tif ( ! existing ) {\n\t\t\treturn {\n\t\t\t\tuuid: key,\n\t\t\t\ttype: '' as WidgetName,\n\t\t\t\tplacement,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...existing,\n\t\t\tplacement,\n\t\t};\n\t} );\n}\n\nfunction applyMasonryChange(\n\twidgets: DashboardWidget[],\n\tmasonryLayout: DashboardLanesLayoutItem[]\n): DashboardWidget[] {\n\treturn masonryLayout.map( ( { key, ...placement } ) => {\n\t\tconst existing = widgets.find( ( w ) => w.uuid === key );\n\t\tif ( ! existing ) {\n\t\t\treturn {\n\t\t\t\tuuid: key,\n\t\t\t\ttype: '' as WidgetName,\n\t\t\t\tplacement,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...existing,\n\t\t\tplacement,\n\t\t};\n\t} );\n}\n\nexport interface WidgetsProps {\n\tclassName?: string;\n}\n\n/**\n * Iterates `layout`, delegates each entry to `WidgetDashboard.WidgetChrome`, and\n * feeds the resulting tree into the active `@wordpress/grid` surface (2D grid\n * or masonry, picked from `gridSettings.model`).\n */\nexport const Widgets = forwardRef< HTMLDivElement, WidgetsProps >(\n\tfunction Widgets( { className }, ref ) {\n\t\tconst { layout, onLayoutChange, editMode, gridSettings, widgetTypes } =\n\t\t\tuseDashboardInternalContext();\n\t\tconst { containerRef, columnCount } =\n\t\t\tuseDashboardContainerColumnCount( ref );\n\t\tconst isMasonry = gridSettings.model === 'masonry';\n\n\t\tconst gridLayout = useMemo(\n\t\t\t() =>\n\t\t\t\tisMasonry ? toMasonryLayout( layout ) : toGridLayout( layout ),\n\t\t\t[ layout, isMasonry ]\n\t\t);\n\n\t\tconst handleGridChange = useCallback(\n\t\t\t( newGridLayout: DashboardGridLayoutItem[] ) => {\n\t\t\t\tonLayoutChange( applyGridChange( layout, newGridLayout ) );\n\t\t\t},\n\t\t\t[ layout, onLayoutChange ]\n\t\t);\n\n\t\tconst handleMasonryChange = useCallback(\n\t\t\t( newMasonryLayout: DashboardLanesLayoutItem[] ) => {\n\t\t\t\tonLayoutChange(\n\t\t\t\t\tapplyMasonryChange( layout, newMasonryLayout )\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ layout, onLayoutChange ]\n\t\t);\n\n\t\tconst children = layout.map( ( widget, index ) => {\n\t\t\tconst widgetType = widgetTypes.find(\n\t\t\t\t( type ) => type.name === widget.type\n\t\t\t);\n\t\t\tconst hasSettings = !! widgetType?.attributes?.length;\n\n\t\t\t// One slot, chosen by mode: layout toolbar while customizing,\n\t\t\t// settings toolbar otherwise (undefined when nothing to configure).\n\t\t\tlet actionableArea: React.ReactNode;\n\t\t\tif ( editMode ) {\n\t\t\t\tactionableArea = <WidgetLayoutToolbar widget={ widget } />;\n\t\t\t} else if ( hasSettings && widgetType ) {\n\t\t\t\tactionableArea = (\n\t\t\t\t\t<WidgetSettingsToolbar\n\t\t\t\t\t\twidget={ widget }\n\t\t\t\t\t\twidgetType={ widgetType }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<WidgetChrome\n\t\t\t\t\tkey={ widget.uuid }\n\t\t\t\t\twidget={ widget }\n\t\t\t\t\tindex={ index }\n\t\t\t\t\tclassName={ clsx( styles.tile, {\n\t\t\t\t\t\t[ styles.tileEditMode ]: editMode,\n\t\t\t\t\t} ) }\n\t\t\t\t\tactionableArea={ actionableArea }\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\n\t\tconst renderDragPreview = useCallback(\n\t\t\t( { children: clone }: DragPreviewRenderProps ) => (\n\t\t\t\t<div className={ styles.dragPreview }>{ clone }</div>\n\t\t\t),\n\t\t\t[]\n\t\t);\n\n\t\tconst sharedRenderProps = {\n\t\t\teditMode,\n\t\t\trenderDragPreview,\n\t\t\trenderResizeHandle:\n\t\t\t\tWidgetResizeHandle as React.ComponentType< ResizeHandleRenderProps >,\n\t\t};\n\n\t\tconst surface: React.ReactNode = isMasonry ? (\n\t\t\t<DashboardLanes\n\t\t\t\tlayout={ gridLayout as DashboardLanesLayoutItem[] }\n\t\t\t\tcolumns={ columnCount }\n\t\t\t\tflowTolerance={ gridSettings.flowTolerance }\n\t\t\t\tonChangeLayout={ handleMasonryChange }\n\t\t\t\t{ ...sharedRenderProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</DashboardLanes>\n\t\t) : (\n\t\t\t<DashboardGrid\n\t\t\t\tlayout={ gridLayout as DashboardGridLayoutItem[] }\n\t\t\t\tcolumns={ columnCount }\n\t\t\t\trowHeight={ gridSettings.rowHeight }\n\t\t\t\tonChangeLayout={ handleGridChange }\n\t\t\t\t{ ...sharedRenderProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</DashboardGrid>\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName={ clsx( styles.grid, className ) }\n\t\t\t>\n\t\t\t\t{ surface }\n\t\t\t</div>\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(\"8516d4e5b3\", \"._942bbd7b48da810c__grid{--wp-grid-placeholder-radius:var(--wpds-border-radius-lg,8px);--wp-grid-drag-preview-radius:var(--wpds-border-radius-lg,8px);container-name:widget-dashboard;container-type:inline-size;width:100%}.a87790b3d11e7d7d__tile{border-radius:var(--wpds-border-radius-lg,8px);height:100%}._5315dd1c30ef4e77__tileEditMode{box-shadow:var(--wpds-elevation-xs,0 1px 1px 0 #00000008,0 1px 2px 0 #00000005,0 3px 3px 0 #00000005,0 4px 4px 0 #00000003)}._5315dd1c30ef4e77__tileEditMode:focus-visible{outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:2px}._6b2daa817d860e6e__dragPreview{height:100%}._6b2daa817d860e6e__dragPreview .a87790b3d11e7d7d__tile{box-shadow:none}\");\n}\nexport default {\"grid\":\"_942bbd7b48da810c__grid\",\"tile\":\"a87790b3d11e7d7d__tile\",\"tileEditMode\":\"_5315dd1c30ef4e77__tileEditMode\",\"dragPreview\":\"_6b2daa817d860e6e__dragPreview\"};\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,YAAY,aAAa,eAAe;AACjD,SAAS,eAAe,sBAAsB;AAY9C,SAAS,mCAAmC;AAC5C,SAAS,wCAAwC;AACjD,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;;;AChBnC,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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;AAAA,MAOd;AAAA,IAEF,CAAE;AAEF,UAAM,oBAAoB;AAAA,MACzB,CAAE,EAAE,UAAU,MAAM,MACnB,oBAAC,SAAI,WAAY,gBAAO,aAAgB,iBAAO;AAAA,MAEhD,CAAC;AAAA,IACF;AAEA,UAAM,oBAAoB;AAAA,MACzB;AAAA,MACA;AAAA,MACA,oBACC;AAAA,IACF;AAEA,UAAM,UAA2B,YAChC;AAAA,MAAC;AAAA;AAAA,QACA,QAAS;AAAA,QACT,SAAU;AAAA,QACV,eAAgB,aAAa;AAAA,QAC7B,gBAAiB;AAAA,QACf,GAAG;AAAA,QAEH;AAAA;AAAA,IACH,IAEA;AAAA,MAAC;AAAA;AAAA,QACA,QAAS;AAAA,QACT,SAAU;AAAA,QACV,WAAY,aAAa;AAAA,QACzB,gBAAiB;AAAA,QACf,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAGD,WACC;AAAA,MAAC;AAAA;AAAA,QACA,KAAM;AAAA,QACN,WAAY,KAAM,gBAAO,MAAM,SAAU;AAAA,QAEvC;AAAA;AAAA,IACH;AAAA,EAEF;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useCallback, useMemo } from '@wordpress/element';\nimport { DashboardGrid, DashboardLanes } from '@wordpress/grid';\nimport type {\n\tDashboardGridLayoutItem,\n\tDashboardLanesLayoutItem,\n\tDragPreviewRenderProps,\n\tResizeHandleRenderProps,\n} from '@wordpress/grid';\nimport type { WidgetName } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardContainerColumnCount } from '../../hooks/use-dashboard-container-column-count';\nimport { WidgetAttributeControls } from '../widget-attribute-controls';\nimport { WidgetChrome } from '../widget-chrome';\nimport { WidgetHeader } from '../widget-header';\nimport { WidgetLayoutControls } from '../widget-layout-controls';\nimport { WidgetToolbar } from '../widget-toolbar';\nimport { WidgetResizeHandle } from './widget-resize-handle';\nimport styles from './widgets.module.css';\nimport type {\n\tDashboardWidget,\n\tGridTilePlacement,\n\tMasonryTilePlacement,\n} from '../../types';\n\nfunction toGridLayout( widgets: DashboardWidget[] ): DashboardGridLayoutItem[] {\n\treturn widgets.map( ( w ) => ( {\n\t\tkey: w.uuid,\n\t\t...( w.placement as GridTilePlacement | undefined ),\n\t} ) );\n}\n\nfunction toMasonryLayout(\n\twidgets: DashboardWidget[]\n): DashboardLanesLayoutItem[] {\n\treturn widgets.map( ( w ) => ( {\n\t\tkey: w.uuid,\n\t\t...( w.placement as MasonryTilePlacement | undefined ),\n\t} ) );\n}\n\nfunction applyGridChange(\n\twidgets: DashboardWidget[],\n\tgridLayout: DashboardGridLayoutItem[]\n): DashboardWidget[] {\n\treturn gridLayout.map( ( { key, ...placement } ) => {\n\t\tconst existing = widgets.find( ( w ) => w.uuid === key );\n\t\tif ( ! existing ) {\n\t\t\treturn {\n\t\t\t\tuuid: key,\n\t\t\t\ttype: '' as WidgetName,\n\t\t\t\tplacement,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...existing,\n\t\t\tplacement,\n\t\t};\n\t} );\n}\n\nfunction applyMasonryChange(\n\twidgets: DashboardWidget[],\n\tmasonryLayout: DashboardLanesLayoutItem[]\n): DashboardWidget[] {\n\treturn masonryLayout.map( ( { key, ...placement } ) => {\n\t\tconst existing = widgets.find( ( w ) => w.uuid === key );\n\t\tif ( ! existing ) {\n\t\t\treturn {\n\t\t\t\tuuid: key,\n\t\t\t\ttype: '' as WidgetName,\n\t\t\t\tplacement,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...existing,\n\t\t\tplacement,\n\t\t};\n\t} );\n}\n\nexport interface WidgetsProps {\n\tclassName?: string;\n}\n\n/**\n * Iterates `layout`, delegates each entry to `WidgetDashboard.WidgetChrome`, and\n * feeds the resulting tree into the active `@wordpress/grid` surface (2D grid\n * or masonry, picked from `gridSettings.model`).\n */\nexport const Widgets = forwardRef< HTMLDivElement, WidgetsProps >(\n\tfunction Widgets( { className }, ref ) {\n\t\tconst { layout, onLayoutChange, editMode, gridSettings, widgetTypes } =\n\t\t\tuseDashboardInternalContext();\n\t\tconst { containerRef, columnCount } =\n\t\t\tuseDashboardContainerColumnCount( ref );\n\t\tconst isMasonry = gridSettings.model === 'masonry';\n\n\t\tconst gridLayout = useMemo(\n\t\t\t() =>\n\t\t\t\tisMasonry ? toMasonryLayout( layout ) : toGridLayout( layout ),\n\t\t\t[ layout, isMasonry ]\n\t\t);\n\n\t\tconst handleGridChange = useCallback(\n\t\t\t( newGridLayout: DashboardGridLayoutItem[] ) => {\n\t\t\t\tonLayoutChange( applyGridChange( layout, newGridLayout ) );\n\t\t\t},\n\t\t\t[ layout, onLayoutChange ]\n\t\t);\n\n\t\tconst handleMasonryChange = useCallback(\n\t\t\t( newMasonryLayout: DashboardLanesLayoutItem[] ) => {\n\t\t\t\tonLayoutChange(\n\t\t\t\t\tapplyMasonryChange( layout, newMasonryLayout )\n\t\t\t\t);\n\t\t\t},\n\t\t\t[ layout, onLayoutChange ]\n\t\t);\n\n\t\tconst children = layout.map( ( widget, index ) => {\n\t\t\tconst widgetType = widgetTypes.find(\n\t\t\t\t( type ) => type.name === widget.type\n\t\t\t);\n\t\t\tconst hasSettings = !! widgetType?.attributes?.length;\n\t\t\tconst isFullBleed = widgetType?.presentation === 'full-bleed';\n\n\t\t\t// The active mode's controls: layout while customizing, the\n\t\t\t// attribute controls (high-relevance fields plus the gear)\n\t\t\t// otherwise.\n\t\t\tlet controls: React.ReactNode;\n\t\t\tif ( editMode ) {\n\t\t\t\tcontrols = <WidgetLayoutControls widget={ widget } />;\n\t\t\t} else if ( hasSettings && widgetType ) {\n\t\t\t\tcontrols = (\n\t\t\t\t\t<WidgetAttributeControls\n\t\t\t\t\t\twidget={ widget }\n\t\t\t\t\t\twidgetType={ widgetType }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst toolbar = controls ? (\n\t\t\t\t<WidgetToolbar editMode={ editMode }>\n\t\t\t\t\t{ controls }\n\t\t\t\t</WidgetToolbar>\n\t\t\t) : undefined;\n\n\t\t\t// Normal mode hosts the toolbar in the in-card header, beside the\n\t\t\t// identity. Customize controls and full-bleed widgets need it in\n\t\t\t// the grid's actionable-area slot instead: the slot sits outside\n\t\t\t// the draggable card, so the controls stay clickable (in-card they\n\t\t\t// would be captured by the drag listeners).\n\t\t\tconst inSlot = editMode || isFullBleed;\n\t\t\tconst actionableArea =\n\t\t\t\tinSlot && toolbar ? (\n\t\t\t\t\t<WidgetHeader overlay>{ toolbar }</WidgetHeader>\n\t\t\t\t) : undefined;\n\n\t\t\treturn (\n\t\t\t\t<WidgetChrome\n\t\t\t\t\tkey={ widget.uuid }\n\t\t\t\t\twidget={ widget }\n\t\t\t\t\tindex={ index }\n\t\t\t\t\tclassName={ clsx( styles.tile, {\n\t\t\t\t\t\t[ styles.tileEditMode ]: editMode,\n\t\t\t\t\t} ) }\n\t\t\t\t\tactionableArea={ actionableArea }\n\t\t\t\t\theaderToolbar={ ! inSlot ? toolbar : undefined }\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\n\t\tconst renderDragPreview = useCallback(\n\t\t\t( { children: clone }: DragPreviewRenderProps ) => (\n\t\t\t\t<div className={ styles.dragPreview }>{ clone }</div>\n\t\t\t),\n\t\t\t[]\n\t\t);\n\n\t\tconst sharedRenderProps = {\n\t\t\teditMode,\n\t\t\trenderDragPreview,\n\t\t\trenderResizeHandle:\n\t\t\t\tWidgetResizeHandle as React.ComponentType< ResizeHandleRenderProps >,\n\t\t};\n\n\t\tconst surface: React.ReactNode = isMasonry ? (\n\t\t\t<DashboardLanes\n\t\t\t\tlayout={ gridLayout as DashboardLanesLayoutItem[] }\n\t\t\t\tcolumns={ columnCount }\n\t\t\t\tflowTolerance={ gridSettings.flowTolerance }\n\t\t\t\tonChangeLayout={ handleMasonryChange }\n\t\t\t\t{ ...sharedRenderProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</DashboardLanes>\n\t\t) : (\n\t\t\t<DashboardGrid\n\t\t\t\tlayout={ gridLayout as DashboardGridLayoutItem[] }\n\t\t\t\tcolumns={ columnCount }\n\t\t\t\trowHeight={ gridSettings.rowHeight }\n\t\t\t\tonChangeLayout={ handleGridChange }\n\t\t\t\t{ ...sharedRenderProps }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</DashboardGrid>\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tref={ containerRef }\n\t\t\t\tclassName={ clsx( styles.grid, className ) }\n\t\t\t>\n\t\t\t\t{ surface }\n\t\t\t</div>\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(\"8516d4e5b3\", \"._942bbd7b48da810c__grid{--wp-grid-placeholder-radius:var(--wpds-border-radius-lg,8px);--wp-grid-drag-preview-radius:var(--wpds-border-radius-lg,8px);container-name:widget-dashboard;container-type:inline-size;width:100%}.a87790b3d11e7d7d__tile{border-radius:var(--wpds-border-radius-lg,8px);height:100%}._5315dd1c30ef4e77__tileEditMode{box-shadow:var(--wpds-elevation-xs,0 1px 1px 0 #00000008,0 1px 2px 0 #00000005,0 3px 3px 0 #00000005,0 4px 4px 0 #00000003)}._5315dd1c30ef4e77__tileEditMode:focus-visible{outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:2px}._6b2daa817d860e6e__dragPreview{height:100%}._6b2daa817d860e6e__dragPreview .a87790b3d11e7d7d__tile{box-shadow:none}\");\n}\nexport default {\"grid\":\"_942bbd7b48da810c__grid\",\"tile\":\"a87790b3d11e7d7d__tile\",\"tileEditMode\":\"_5315dd1c30ef4e77__tileEditMode\",\"dragPreview\":\"_6b2daa817d860e6e__dragPreview\"};\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,YAAY,aAAa,eAAe;AACjD,SAAS,eAAe,sBAAsB;AAY9C,SAAS,mCAAmC;AAC5C,SAAS,wCAAwC;AACjD,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAC7B,SAAS,oBAAoB;AAC7B,SAAS,4BAA4B;AACrC,SAAS,qBAAqB;AAC9B,SAAS,0BAA0B;;;AClBnC,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,IA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