@wordpress/widget-dashboard 0.2.0 → 0.3.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 (283) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +29 -16
  3. package/build/components/actions/actions.cjs +6 -23
  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 +28 -69
  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 +176 -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/widget-resize-handle.cjs +4 -4
  44. package/build/components/widgets/widget-resize-handle.cjs.map +2 -2
  45. package/build/components/widgets/widgets.cjs +18 -11
  46. package/build/components/widgets/widgets.cjs.map +2 -2
  47. package/build/context/dashboard-context.cjs +31 -80
  48. package/build/context/dashboard-context.cjs.map +2 -2
  49. package/build/context/ui-context.cjs +2 -18
  50. package/build/context/ui-context.cjs.map +2 -2
  51. package/build/types.cjs.map +1 -1
  52. package/build/utils/index.cjs +2 -5
  53. package/build/utils/index.cjs.map +2 -2
  54. package/build/widget-dashboard.cjs +0 -4
  55. package/build/widget-dashboard.cjs.map +2 -2
  56. package/build-module/components/actions/actions.mjs +7 -24
  57. package/build-module/components/actions/actions.mjs.map +2 -2
  58. package/build-module/components/commands/commands.mjs +2 -67
  59. package/build-module/components/commands/commands.mjs.map +2 -2
  60. package/build-module/components/widget-attribute-controls/index.mjs +6 -0
  61. package/build-module/components/widget-attribute-controls/index.mjs.map +7 -0
  62. package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs +68 -0
  63. package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs.map +7 -0
  64. package/build-module/components/widget-chrome/widget-chrome.mjs +29 -76
  65. package/build-module/components/widget-chrome/widget-chrome.mjs.map +2 -2
  66. package/build-module/components/widget-frame/index.mjs +7 -0
  67. package/build-module/components/widget-frame/index.mjs.map +7 -0
  68. package/build-module/components/widget-frame/widget-frame.mjs +157 -0
  69. package/build-module/components/widget-frame/widget-frame.mjs.map +7 -0
  70. package/build-module/components/widget-header/index.mjs +6 -0
  71. package/build-module/components/widget-header/index.mjs.map +7 -0
  72. package/build-module/components/widget-header/widget-header-infotip.mjs +141 -0
  73. package/build-module/components/widget-header/widget-header-infotip.mjs.map +7 -0
  74. package/build-module/components/widget-header/widget-header.mjs +141 -0
  75. package/build-module/components/widget-header/widget-header.mjs.map +7 -0
  76. package/build-module/components/widget-layout-controls/index.mjs +6 -0
  77. package/build-module/components/widget-layout-controls/index.mjs.map +7 -0
  78. package/build-module/components/widget-layout-controls/widget-layout-controls.mjs +90 -0
  79. package/build-module/components/widget-layout-controls/widget-layout-controls.mjs.map +7 -0
  80. package/build-module/components/widget-picker/widget-picker.mjs +6 -94
  81. package/build-module/components/widget-picker/widget-picker.mjs.map +3 -3
  82. package/build-module/components/widget-preview-chrome/index.mjs +6 -0
  83. package/build-module/components/widget-preview-chrome/index.mjs.map +7 -0
  84. package/build-module/components/{widget-settings/widget-settings-toolbar.mjs → widget-preview-chrome/widget-preview-chrome.mjs} +37 -19
  85. package/build-module/components/widget-preview-chrome/widget-preview-chrome.mjs.map +7 -0
  86. package/build-module/components/widget-settings/index.mjs +2 -2
  87. package/build-module/components/widget-settings/index.mjs.map +1 -1
  88. package/build-module/components/widget-settings/utils/index.mjs +0 -2
  89. package/build-module/components/widget-settings/utils/index.mjs.map +2 -2
  90. package/build-module/components/widget-settings/widget-settings-trigger.mjs +23 -29
  91. package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +2 -2
  92. package/build-module/components/widget-settings/widget-settings.mjs +40 -57
  93. package/build-module/components/widget-settings/widget-settings.mjs.map +2 -2
  94. package/build-module/components/widget-toolbar/widget-toolbar.mjs +7 -4
  95. package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +2 -2
  96. package/build-module/components/widgets/widget-resize-handle.mjs +4 -4
  97. package/build-module/components/widgets/widget-resize-handle.mjs.map +2 -2
  98. package/build-module/components/widgets/widgets.mjs +18 -11
  99. package/build-module/components/widgets/widgets.mjs.map +2 -2
  100. package/build-module/context/dashboard-context.mjs +31 -80
  101. package/build-module/context/dashboard-context.mjs.map +2 -2
  102. package/build-module/context/ui-context.mjs +2 -18
  103. package/build-module/context/ui-context.mjs.map +2 -2
  104. package/build-module/types.mjs.map +1 -1
  105. package/build-module/utils/index.mjs +1 -3
  106. package/build-module/utils/index.mjs.map +2 -2
  107. package/build-module/widget-dashboard.mjs +0 -4
  108. package/build-module/widget-dashboard.mjs.map +2 -2
  109. package/build-types/components/actions/actions.d.ts.map +1 -1
  110. package/build-types/components/commands/commands.d.ts.map +1 -1
  111. package/build-types/components/commands/use-pending-when-edit-mode.d.ts +1 -1
  112. package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -1
  113. package/build-types/components/no-widgets-state/no-widgets-state.d.ts +1 -1
  114. package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -1
  115. package/build-types/components/widget-attribute-controls/index.d.ts +2 -0
  116. package/build-types/components/widget-attribute-controls/index.d.ts.map +1 -0
  117. package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts +23 -0
  118. package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts.map +1 -0
  119. package/build-types/components/widget-chrome/widget-chrome.d.ts +8 -8
  120. package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -1
  121. package/build-types/components/widget-frame/index.d.ts +3 -0
  122. package/build-types/components/widget-frame/index.d.ts.map +1 -0
  123. package/build-types/components/widget-frame/widget-frame.d.ts +25 -0
  124. package/build-types/components/widget-frame/widget-frame.d.ts.map +1 -0
  125. package/build-types/components/widget-header/index.d.ts +3 -0
  126. package/build-types/components/widget-header/index.d.ts.map +1 -0
  127. package/build-types/components/widget-header/widget-header-infotip.d.ts +20 -0
  128. package/build-types/components/widget-header/widget-header-infotip.d.ts.map +1 -0
  129. package/build-types/components/widget-header/widget-header.d.ts +38 -0
  130. package/build-types/components/widget-header/widget-header.d.ts.map +1 -0
  131. package/build-types/components/widget-layout-controls/index.d.ts +3 -0
  132. package/build-types/components/widget-layout-controls/index.d.ts.map +1 -0
  133. package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts +14 -0
  134. package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts.map +1 -0
  135. package/build-types/components/widget-picker/widget-picker.d.ts +1 -1
  136. package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -1
  137. package/build-types/components/widget-preview-chrome/index.d.ts +3 -0
  138. package/build-types/components/widget-preview-chrome/index.d.ts.map +1 -0
  139. package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts +15 -0
  140. package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts.map +1 -0
  141. package/build-types/components/widget-settings/index.d.ts +2 -2
  142. package/build-types/components/widget-settings/utils/index.d.ts +0 -1
  143. package/build-types/components/widget-settings/utils/index.d.ts.map +1 -1
  144. package/build-types/components/widget-settings/widget-settings-trigger.d.ts +7 -5
  145. package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -1
  146. package/build-types/components/widget-settings/widget-settings.d.ts +5 -4
  147. package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -1
  148. package/build-types/components/widget-toolbar/widget-toolbar.d.ts +10 -7
  149. package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -1
  150. package/build-types/components/widgets/widgets.d.ts.map +1 -1
  151. package/build-types/context/dashboard-context.d.ts +23 -40
  152. package/build-types/context/dashboard-context.d.ts.map +1 -1
  153. package/build-types/context/ui-context.d.ts +0 -18
  154. package/build-types/context/ui-context.d.ts.map +1 -1
  155. package/build-types/context/widget-context.d.ts +1 -1
  156. package/build-types/context/widget-context.d.ts.map +1 -1
  157. package/build-types/types.d.ts +9 -15
  158. package/build-types/types.d.ts.map +1 -1
  159. package/build-types/utils/index.d.ts +0 -1
  160. package/build-types/utils/index.d.ts.map +1 -1
  161. package/build-types/widget-dashboard.d.ts +5 -5
  162. package/build-types/widget-dashboard.d.ts.map +1 -1
  163. package/package.json +20 -20
  164. package/src/components/actions/actions.module.css +7 -7
  165. package/src/components/actions/actions.tsx +5 -25
  166. package/src/components/commands/commands.tsx +3 -70
  167. package/src/components/widget-attribute-controls/index.ts +1 -0
  168. package/src/components/widget-attribute-controls/widget-attribute-controls.tsx +108 -0
  169. package/src/components/widget-chrome/widget-chrome.module.css +6 -71
  170. package/src/components/widget-chrome/widget-chrome.tsx +31 -136
  171. package/src/components/widget-frame/index.ts +2 -0
  172. package/src/components/widget-frame/widget-frame.module.css +17 -0
  173. package/src/components/widget-frame/widget-frame.tsx +138 -0
  174. package/src/components/widget-header/index.ts +2 -0
  175. package/src/components/widget-header/widget-header-infotip.tsx +82 -0
  176. package/src/components/widget-header/widget-header.module.css +59 -0
  177. package/src/components/widget-header/widget-header.tsx +104 -0
  178. package/src/components/widget-layout-controls/index.ts +2 -0
  179. package/src/components/{widgets/widget-layout-toolbar.tsx → widget-layout-controls/widget-layout-controls.tsx} +12 -13
  180. package/src/components/widget-picker/widget-picker.tsx +5 -10
  181. package/src/components/widget-preview-chrome/index.ts +2 -0
  182. package/src/components/widget-preview-chrome/widget-preview-chrome.module.css +22 -0
  183. package/src/components/widget-preview-chrome/widget-preview-chrome.tsx +65 -0
  184. package/src/components/widget-settings/index.ts +2 -2
  185. package/src/components/widget-settings/utils/index.ts +0 -1
  186. package/src/components/widget-settings/widget-settings-trigger.tsx +39 -44
  187. package/src/components/widget-settings/widget-settings.tsx +10 -28
  188. package/src/components/widget-toolbar/widget-toolbar.module.css +13 -10
  189. package/src/components/widget-toolbar/widget-toolbar.tsx +14 -8
  190. package/src/components/widgets/widget-resize-handle.module.css +21 -21
  191. package/src/components/widgets/widget-resize-handle.tsx +2 -2
  192. package/src/components/widgets/widgets.module.css +20 -11
  193. package/src/components/widgets/widgets.tsx +33 -10
  194. package/src/context/dashboard-context.tsx +70 -133
  195. package/src/context/ui-context.tsx +1 -39
  196. package/src/test/actions.test.tsx +7 -77
  197. package/src/test/commands.test.tsx +6 -45
  198. package/src/test/staging.test.tsx +82 -144
  199. package/src/test/widget-dashboard.test.tsx +24 -0
  200. package/src/types.ts +9 -16
  201. package/src/utils/index.ts +0 -1
  202. package/src/widget-dashboard.tsx +4 -8
  203. package/build/components/layout-settings/index.cjs.map +0 -7
  204. package/build/components/layout-settings/layout-model-edit-field/index.cjs +0 -186
  205. package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +0 -7
  206. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +0 -53
  207. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +0 -7
  208. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +0 -53
  209. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +0 -7
  210. package/build/components/layout-settings/layout-settings.cjs +0 -207
  211. package/build/components/layout-settings/layout-settings.cjs.map +0 -7
  212. package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +0 -7
  213. package/build/components/widget-settings/widget-settings-toolbar.cjs.map +0 -7
  214. package/build/components/widgets/widget-layout-toolbar.cjs.map +0 -7
  215. package/build/utils/grid-model-change/grid-model-change.cjs +0 -56
  216. package/build/utils/grid-model-change/grid-model-change.cjs.map +0 -7
  217. package/build/utils/grid-model-change/index.cjs.map +0 -7
  218. package/build/utils/migrate-layout/index.cjs.map +0 -7
  219. package/build/utils/migrate-layout/migrate-layout.cjs +0 -94
  220. package/build/utils/migrate-layout/migrate-layout.cjs.map +0 -7
  221. package/build-module/components/layout-settings/index.mjs +0 -6
  222. package/build-module/components/layout-settings/index.mjs.map +0 -7
  223. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +0 -151
  224. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +0 -7
  225. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +0 -28
  226. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +0 -7
  227. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +0 -28
  228. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +0 -7
  229. package/build-module/components/layout-settings/layout-settings.mjs +0 -187
  230. package/build-module/components/layout-settings/layout-settings.mjs.map +0 -7
  231. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +0 -16
  232. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +0 -7
  233. package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +0 -7
  234. package/build-module/components/widgets/widget-layout-toolbar.mjs +0 -181
  235. package/build-module/components/widgets/widget-layout-toolbar.mjs.map +0 -7
  236. package/build-module/utils/grid-model-change/grid-model-change.mjs +0 -30
  237. package/build-module/utils/grid-model-change/grid-model-change.mjs.map +0 -7
  238. package/build-module/utils/grid-model-change/index.mjs +0 -7
  239. package/build-module/utils/grid-model-change/index.mjs.map +0 -7
  240. package/build-module/utils/migrate-layout/index.mjs +0 -6
  241. package/build-module/utils/migrate-layout/index.mjs.map +0 -7
  242. package/build-module/utils/migrate-layout/migrate-layout.mjs +0 -69
  243. package/build-module/utils/migrate-layout/migrate-layout.mjs.map +0 -7
  244. package/build-types/components/layout-settings/index.d.ts +0 -2
  245. package/build-types/components/layout-settings/index.d.ts.map +0 -1
  246. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +0 -17
  247. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +0 -1
  248. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +0 -6
  249. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +0 -1
  250. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +0 -6
  251. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +0 -1
  252. package/build-types/components/layout-settings/layout-settings.d.ts +0 -14
  253. package/build-types/components/layout-settings/layout-settings.d.ts.map +0 -1
  254. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +0 -17
  255. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +0 -1
  256. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +0 -20
  257. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +0 -1
  258. package/build-types/components/widgets/widget-layout-toolbar.d.ts +0 -14
  259. package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +0 -1
  260. package/build-types/utils/grid-model-change/grid-model-change.d.ts +0 -20
  261. package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +0 -1
  262. package/build-types/utils/grid-model-change/index.d.ts +0 -2
  263. package/build-types/utils/grid-model-change/index.d.ts.map +0 -1
  264. package/build-types/utils/migrate-layout/index.d.ts +0 -2
  265. package/build-types/utils/migrate-layout/index.d.ts.map +0 -1
  266. package/build-types/utils/migrate-layout/migrate-layout.d.ts +0 -36
  267. package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +0 -1
  268. package/src/components/layout-settings/index.ts +0 -1
  269. package/src/components/layout-settings/layout-model-edit-field/index.tsx +0 -98
  270. package/src/components/layout-settings/layout-model-edit-field/style.module.css +0 -34
  271. package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +0 -28
  272. package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +0 -28
  273. package/src/components/layout-settings/layout-settings.tsx +0 -217
  274. package/src/components/widget-picker/widget-picker.module.css +0 -11
  275. package/src/components/widget-settings/utils/get-admin-menu-inset.ts +0 -30
  276. package/src/components/widget-settings/widget-settings-toolbar.module.css +0 -25
  277. package/src/components/widget-settings/widget-settings-toolbar.tsx +0 -45
  278. package/src/components/widgets/widget-layout-toolbar.module.css +0 -6
  279. package/src/utils/grid-model-change/grid-model-change.ts +0 -53
  280. package/src/utils/grid-model-change/index.ts +0 -1
  281. package/src/utils/migrate-layout/index.ts +0 -1
  282. package/src/utils/migrate-layout/migrate-layout.ts +0 -156
  283. package/src/utils/migrate-layout/test/migrate-layout.test.ts +0 -114
@@ -1,12 +1,12 @@
1
- .editActionsEnter,
2
- .editActionsExit {
1
+ .edit-actions-enter,
2
+ .edit-actions-exit {
3
3
  display: inline-flex;
4
4
  align-items: center;
5
5
  gap: var(--wp--preset--spacing--20);
6
6
  transform-origin: right center;
7
7
  }
8
8
 
9
- .editActionsDivider {
9
+ .edit-actions-divider {
10
10
  flex-shrink: 0;
11
11
  align-self: center;
12
12
  width: 1px;
@@ -15,16 +15,16 @@
15
15
  }
16
16
 
17
17
  @media not ( prefers-reduced-motion ) {
18
- .editActionsEnter,
19
- .editActionsExit {
18
+ .edit-actions-enter,
19
+ .edit-actions-exit {
20
20
  will-change: opacity, transform;
21
21
  }
22
22
 
23
- .editActionsEnter {
23
+ .edit-actions-enter {
24
24
  animation: actions-slide-in var(--wpds-motion-duration-md) var(--wpds-motion-easing-expressive) forwards;
25
25
  }
26
26
 
27
- .editActionsExit {
27
+ .edit-actions-exit {
28
28
  animation: actions-fold-out var(--wpds-motion-duration-sm) var(--wpds-motion-easing-balanced) forwards;
29
29
  }
30
30
 
@@ -4,7 +4,7 @@
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { useCallback, useEffect, useState } from '@wordpress/element';
6
6
  import { __ } from '@wordpress/i18n';
7
- import { layout as layoutIcon, plus } from '@wordpress/icons';
7
+ import { plus } from '@wordpress/icons';
8
8
  import { store as viewportStore } from '@wordpress/viewport';
9
9
  // eslint-disable-next-line @wordpress/use-recommended-components
10
10
  import { Button, Stack } from '@wordpress/ui';
@@ -35,7 +35,6 @@ export function Actions(): React.ReactNode {
35
35
  commit,
36
36
  cancel: cancelStaging,
37
37
  hasUncommittedChanges,
38
- canEditGridSettings,
39
38
  } = useDashboardInternalContext();
40
39
 
41
40
  const [ isEditActionsMounted, setIsEditActionsMounted ] =
@@ -62,8 +61,7 @@ export function Actions(): React.ReactNode {
62
61
  return () => clearTimeout( exitTimeout );
63
62
  }, [ editMode, isEditActionsMounted ] );
64
63
 
65
- const { setInserterOpen, setLayoutSettingsOpen, setResetDialogOpen } =
66
- useDashboardUIContext();
64
+ const { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();
67
65
  // @TODO: switch to using Admin UI declaratively for mobile viewport support once available.
68
66
  // https://github.com/WordPress/gutenberg/issues/77628
69
67
  const isMobileViewport = useSelect(
@@ -87,10 +85,6 @@ export function Actions(): React.ReactNode {
87
85
  commit();
88
86
  }, [ commit ] );
89
87
 
90
- const openLayoutSettings = useCallback( () => {
91
- setLayoutSettingsOpen( true );
92
- }, [ setLayoutSettingsOpen ] );
93
-
94
88
  const menuItems: ActionsMenuItem[] = [
95
89
  {
96
90
  label: __( 'Reset to default' ),
@@ -111,8 +105,8 @@ export function Actions(): React.ReactNode {
111
105
  gap="sm"
112
106
  className={
113
107
  isExitingEditActions
114
- ? styles.editActionsExit
115
- : styles.editActionsEnter
108
+ ? styles[ 'edit-actions-exit' ]
109
+ : styles[ 'edit-actions-enter' ]
116
110
  }
117
111
  >
118
112
  <Button
@@ -125,22 +119,8 @@ export function Actions(): React.ReactNode {
125
119
  { __( 'Add widget' ) }
126
120
  </Button>
127
121
 
128
- { canEditGridSettings && (
129
- <Button
130
- variant="minimal"
131
- tone="brand"
132
- size="compact"
133
- onClick={ openLayoutSettings }
134
- >
135
- { ! isMobileViewport && (
136
- <Button.Icon icon={ layoutIcon } />
137
- ) }
138
- { __( 'Layout settings' ) }
139
- </Button>
140
- ) }
141
-
142
122
  <div
143
- className={ styles.editActionsDivider }
123
+ className={ styles[ 'edit-actions-divider' ] }
144
124
  aria-hidden="true"
145
125
  />
146
126
 
@@ -7,13 +7,7 @@ import {
7
7
  useCommands,
8
8
  privateApis as commandsPrivateApis,
9
9
  } from '@wordpress/commands';
10
- import {
11
- columns,
12
- grid,
13
- layout as layoutIcon,
14
- plus,
15
- trash,
16
- } from '@wordpress/icons';
10
+ import { layout as layoutIcon, plus, trash } from '@wordpress/icons';
17
11
 
18
12
  /**
19
13
  * Internal dependencies
@@ -21,7 +15,6 @@ import {
21
15
  import { unlock } from '../../lock-unlock';
22
16
  import { useDashboardInternalContext } from '../../context/dashboard-context';
23
17
  import { useDashboardUIContext } from '../../context/ui-context';
24
- import { getGridModel } from '../../utils/grid-model-change';
25
18
  import { usePendingWhenEditMode } from './use-pending-when-edit-mode';
26
19
 
27
20
  const { useCommandContext } = unlock( commandsPrivateApis );
@@ -35,14 +28,8 @@ type CommandCallback = ( options: { close: () => void } ) => void;
35
28
  * active command context so they surface under Suggestions by default.
36
29
  */
37
30
  export function Commands() {
38
- const {
39
- editMode,
40
- onEditChange,
41
- onLayoutReset,
42
- gridSettings,
43
- canEditGridSettings,
44
- commitGridModelChange,
45
- } = useDashboardInternalContext();
31
+ const { editMode, onEditChange, onLayoutReset } =
32
+ useDashboardInternalContext();
46
33
 
47
34
  const { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();
48
35
 
@@ -53,26 +40,6 @@ export function Commands() {
53
40
  onEditChange,
54
41
  } );
55
42
 
56
- const gridModel = getGridModel( gridSettings );
57
- const isGridLayout = gridModel === 'grid';
58
- const isMasonryLayout = gridModel === 'masonry';
59
-
60
- const switchToMasonry = useCallback< CommandCallback >(
61
- ( { close } ) => {
62
- close();
63
- commitGridModelChange( 'masonry' );
64
- },
65
- [ commitGridModelChange ]
66
- );
67
-
68
- const switchToGrid = useCallback< CommandCallback >(
69
- ( { close } ) => {
70
- close();
71
- commitGridModelChange( 'grid' );
72
- },
73
- [ commitGridModelChange ]
74
- );
75
-
76
43
  const resetToDefault = useCallback< CommandCallback >(
77
44
  ( { close } ) => {
78
45
  close();
@@ -121,35 +88,6 @@ export function Commands() {
121
88
  disabled: ! onEditChange,
122
89
  callback: addWidgets,
123
90
  },
124
- {
125
- name: 'core/dashboard/switch-to-masonry-layout',
126
- label: __( 'Switch dashboard to masonry layout' ),
127
- icon: columns,
128
- category: 'command',
129
- context: DASHBOARD_COMMAND_CONTEXT,
130
- keywords: [
131
- __( 'layout' ),
132
- __( 'layout model' ),
133
- __( 'masonry' ),
134
- ],
135
- disabled: ! canEditGridSettings || isMasonryLayout || editMode,
136
- callback: switchToMasonry,
137
- },
138
- {
139
- name: 'core/dashboard/switch-to-grid-layout',
140
- label: __( 'Switch dashboard to grid layout' ),
141
- icon: grid,
142
- category: 'command',
143
- context: DASHBOARD_COMMAND_CONTEXT,
144
- keywords: [
145
- __( 'layout' ),
146
- __( 'layout model' ),
147
- __( 'grid' ),
148
- __( 'standard grid' ),
149
- ],
150
- disabled: ! canEditGridSettings || isGridLayout || editMode,
151
- callback: switchToGrid,
152
- },
153
91
  {
154
92
  name: 'core/dashboard/reset-to-default',
155
93
  label: __( 'Reset dashboard widgets to default' ),
@@ -166,11 +104,6 @@ export function Commands() {
166
104
  editMode,
167
105
  customize,
168
106
  addWidgets,
169
- canEditGridSettings,
170
- isMasonryLayout,
171
- isGridLayout,
172
- switchToMasonry,
173
- switchToGrid,
174
107
  onLayoutReset,
175
108
  resetToDefault,
176
109
  ]
@@ -0,0 +1 @@
1
+ export { WidgetAttributeControls } from './widget-attribute-controls';
@@ -0,0 +1,108 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { DataForm } from '@wordpress/dataviews';
5
+ import type { Field, Form } from '@wordpress/dataviews';
6
+ import { useCallback, useMemo } from '@wordpress/element';
7
+ import type { WidgetType } from '@wordpress/widget-primitives';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { useDashboardInternalContext } from '../../context/dashboard-context';
13
+ import { WidgetSettingsTrigger } from '../widget-settings';
14
+ import type { DashboardWidget } from '../../types';
15
+
16
+ type WidgetAttributes = Record< string, unknown >;
17
+
18
+ type WidgetAttributeControlsProps = {
19
+ /**
20
+ * The instance whose attributes these controls edit.
21
+ */
22
+ widget: DashboardWidget< unknown >;
23
+
24
+ /**
25
+ * The instance's widget type, source of the attribute schema.
26
+ */
27
+ widgetType: WidgetType;
28
+ };
29
+
30
+ /**
31
+ * Normal-mode controls: the `relevance: 'high'` attributes on a prominent
32
+ * surface, plus a settings entry point when needed. Inline controls appear
33
+ * only for the high-relevance fields; edits stage live and auto-save on the
34
+ * dashboard's shared debounce.
35
+ *
36
+ * @param {WidgetAttributeControlsProps} props Component props.
37
+ */
38
+ export function WidgetAttributeControls( {
39
+ widget,
40
+ widgetType,
41
+ }: WidgetAttributeControlsProps ): React.ReactNode {
42
+ const { layout, onLayoutChange, scheduleAutoSave } =
43
+ useDashboardInternalContext();
44
+
45
+ const fields = useMemo< Field< WidgetAttributes >[] >(
46
+ () =>
47
+ ( widgetType.attributes ?? [] ).filter(
48
+ ( attribute ) => attribute.relevance === 'high'
49
+ ) as Field< WidgetAttributes >[],
50
+ [ widgetType.attributes ]
51
+ );
52
+
53
+ // A `row` top-level layout lays the controls out horizontally; each field
54
+ // carries `labelPosition: 'none'` so the control renders bare.
55
+ const form = useMemo< Form >(
56
+ () => ( {
57
+ layout: { type: 'row', alignment: 'center' },
58
+ fields: fields.map( ( field ) => ( {
59
+ id: field.id,
60
+ layout: { type: 'regular', labelPosition: 'none' },
61
+ } ) ),
62
+ } ),
63
+ [ fields ]
64
+ );
65
+
66
+ const handleChange = useCallback(
67
+ ( edits: Record< string, unknown > ) => {
68
+ onLayoutChange(
69
+ layout.map( ( instance ) =>
70
+ instance.uuid === widget.uuid
71
+ ? {
72
+ ...instance,
73
+ attributes: {
74
+ ...( instance.attributes as object ),
75
+ ...edits,
76
+ },
77
+ }
78
+ : instance
79
+ )
80
+ );
81
+
82
+ scheduleAutoSave();
83
+ },
84
+ [ layout, onLayoutChange, widget.uuid, scheduleAutoSave ]
85
+ );
86
+
87
+ const data = ( widget.attributes ??
88
+ widgetType.example?.attributes ??
89
+ {} ) as WidgetAttributes;
90
+
91
+ return (
92
+ <>
93
+ { fields.length > 0 && (
94
+ <DataForm< WidgetAttributes >
95
+ data={ data }
96
+ fields={ fields }
97
+ form={ form }
98
+ onChange={ handleChange }
99
+ />
100
+ ) }
101
+
102
+ <WidgetSettingsTrigger
103
+ widget={ widget }
104
+ widgetType={ widgetType }
105
+ />
106
+ </>
107
+ );
108
+ }
@@ -1,87 +1,22 @@
1
- .widgetChrome {
2
- height: 100%;
3
-
4
- /*
5
- * Isolate the widget body from the surrounding layout. In a fixed-row
6
- * grid the tile height comes from its row span, but a body taller than
7
- * the tile lets its intrinsic size feed the grid item's `min-height: auto`
8
- * and overflow the cell, adding scroll space below the grid. Layout
9
- * containment severs that propagation so the body stays within the tile
10
- * and scrolls internally. It contains layout only, not size or paint, so
11
- * the masonry surface still measures the tile from its content and the
12
- * tile elevation is not clipped.
13
- */
14
- contain: layout;
15
- }
16
-
17
- /*
18
- * When keyboard focus lands on the widget's own content (a link or control
19
- * the render module draws), outline the whole tile so Tab users can tell
20
- * which widget holds focus, since an inner ring alone is easy to miss. Scoped
21
- * to content focus, and to `:focus-visible` so a mouse click doesn't draw it.
22
- */
23
- .widgetChrome:has(.widgetChromeContent :focus-visible) {
1
+ /* Outward tile focus ring; paint space reserved on `.grid`. */
2
+ .widget-chrome:has(:focus-visible) {
24
3
  outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
25
- outline-offset: 2px;
4
+ outline-offset: var(--wp-widget-dashboard-tile-focus-offset, 2px);
26
5
  }
27
6
 
28
- .widgetChromeHeaderIcon {
7
+ .widget-chrome-header-icon {
29
8
  display: inline-flex;
30
9
  color: var(--wpds-color-foreground-content-neutral);
31
10
  }
32
11
 
33
- /*
34
- * Scroll container for the widget body. The card root clips its own overflow
35
- * and the header is a fixed-size flex sibling, so confining the scroll to this
36
- * element is what keeps the header pinned while the body scrolls.
37
- */
38
- .widgetChromeContent {
12
+ /* Fill the tile so placeholder states center in the full height. */
13
+ .widget-chrome-content {
39
14
  flex: 1;
40
15
  height: 100%;
41
- overflow-y: auto;
42
-
43
- /*
44
- * As a flex item, the content area defaults to `min-height: auto`, which
45
- * lets tall widget content expand it past the height the card allots
46
- * instead of staying bounded. Pinning the min sizes to 0 keeps the area
47
- * within its slot so a widget's own `overflow` scrolls internally rather
48
- * than pushing past the card.
49
- */
50
16
  min-width: 0;
51
17
  min-height: 0;
52
18
  }
53
19
 
54
- /*
55
- * Bleed block edges: zero the content's block padding so the body fills the
56
- * card top to bottom. The top is ours to flush (a full-bleed widget hides its
57
- * header in a position:absolute VisuallyHidden node that stays the card's
58
- * :first-child and blocks Card.FullBleed's top-flush rule). The bottom pairs
59
- * with the `margin-block-end: 0` on the bleed scroll wrapper below.
60
- */
61
- .widgetChromeContentBleed {
62
- padding-block: 0;
63
- }
64
-
65
- /*
66
- * Scroll container for a bleeding body. Card.FullBleed only does the edge
67
- * breakout (negative margins) and declares no height or overflow, so the scroll
68
- * container must be re-established here, on the wrapper that spans the card
69
- * edges, so the scrollbar tracks the edge and the header stays pinned.
70
- *
71
- * Card.FullBleed also adds `margin-block-end: calc(var(--wp-ui-card-padding) *
72
- * -1)` to cancel the content's bottom padding; that padding is zeroed above, so
73
- * neutralize the margin. Left in, it pulls the wrapper's box short of the body,
74
- * surfacing as a phantom scrollbar on a content-driven tile or a bottom inset
75
- * on a fixed-height one.
76
- */
77
- .widgetChromeBleedScroll {
78
- height: 100%;
79
- overflow-y: auto;
80
- margin-block-end: 0;
81
- }
82
-
83
- .loading,
84
20
  .unavailable {
85
21
  height: 100%;
86
22
  }
87
-
@@ -7,69 +7,20 @@ import type { ReactNode } from 'react';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
- import { Spinner } from '@wordpress/components';
11
- import {
12
- Component,
13
- Suspense,
14
- forwardRef,
15
- useId,
16
- useMemo,
17
- } from '@wordpress/element';
10
+ import { forwardRef, useId, useMemo } from '@wordpress/element';
18
11
  import { __ } from '@wordpress/i18n';
19
12
  import { plugins } from '@wordpress/icons';
20
- // eslint-disable-next-line @wordpress/use-recommended-components
21
- import { Card, Icon, Stack, Notice, Text, VisuallyHidden } from '@wordpress/ui';
22
- import type { WidgetType } from '@wordpress/widget-primitives';
13
+ import { Card, Icon, Stack, Text } from '@wordpress/ui';
23
14
 
24
15
  /**
25
16
  * Internal dependencies
26
17
  */
27
18
  import { useDashboardInternalContext } from '../../context/dashboard-context';
28
19
  import { WidgetContextProvider } from '../../context/widget-context';
29
- import { WidgetRender } from '../widget-render';
20
+ import { LoadingOverlay, WidgetFrame } from '../widget-frame';
30
21
  import styles from './widget-chrome.module.css';
31
22
  import type { DashboardWidget } from '../../types';
32
23
 
33
- interface ErrorBoundaryProps {
34
- children: ReactNode;
35
- }
36
-
37
- interface ErrorBoundaryState {
38
- hasError: boolean;
39
- }
40
-
41
- class WidgetErrorBoundary extends Component<
42
- ErrorBoundaryProps,
43
- ErrorBoundaryState
44
- > {
45
- state: ErrorBoundaryState = { hasError: false };
46
-
47
- static getDerivedStateFromError(): ErrorBoundaryState {
48
- return { hasError: true };
49
- }
50
-
51
- render() {
52
- if ( this.state.hasError ) {
53
- return (
54
- <Notice.Root intent="error">
55
- <Notice.Description>
56
- { __( 'This widget encountered an error.' ) }
57
- </Notice.Description>
58
- </Notice.Root>
59
- );
60
- }
61
- return this.props.children;
62
- }
63
- }
64
-
65
- function LoadingOverlay() {
66
- return (
67
- <Stack justify="center" align="center" className={ styles.loading }>
68
- <Spinner />
69
- </Stack>
70
- );
71
- }
72
-
73
24
  interface UnavailableWidgetProps {
74
25
  widgetTypeName: string;
75
26
  }
@@ -79,13 +30,13 @@ function UnavailableWidget( { widgetTypeName }: UnavailableWidgetProps ) {
79
30
  <>
80
31
  <Card.Header>
81
32
  <span
82
- className={ styles.widgetChromeHeaderIcon }
33
+ className={ styles[ 'widget-chrome-header-icon' ] }
83
34
  aria-hidden="true"
84
35
  >
85
36
  <Icon icon={ plugins } />
86
37
  </span>
87
38
  </Card.Header>
88
- <Card.Content className={ styles.widgetChromeContent }>
39
+ <Card.Content className={ styles[ 'widget-chrome-content' ] }>
89
40
  <Stack
90
41
  direction="column"
91
42
  justify="center"
@@ -101,56 +52,27 @@ function UnavailableWidget( { widgetTypeName }: UnavailableWidgetProps ) {
101
52
  );
102
53
  }
103
54
 
104
- interface HeaderProps {
105
- titleId: string;
106
- widgetType: WidgetType;
107
- }
108
-
109
- function Header( { titleId, widgetType }: HeaderProps ) {
110
- if ( ! widgetType.title ) {
111
- return null;
112
- }
113
-
114
- return (
115
- <Card.Header>
116
- <Stack direction="row" align="center" gap="sm">
117
- { widgetType.icon && (
118
- <span
119
- className={ styles.widgetChromeHeaderIcon }
120
- aria-hidden="true"
121
- >
122
- <Icon icon={ widgetType.icon } />
123
- </span>
124
- ) }
125
- <Card.Title id={ titleId } render={ <h2 /> }>
126
- { widgetType.title }
127
- </Card.Title>
128
- </Stack>
129
- </Card.Header>
130
- );
131
- }
132
-
133
55
  export interface WidgetChromeProps {
134
56
  widget: DashboardWidget< unknown >;
135
57
  index: number;
136
58
  /**
137
- * Lifted by the surrounding `@wordpress/grid` surface into a sibling
138
- * slot of the grid item; not rendered by `WidgetChrome` itself.
139
- * Living outside `Card.Root` is what keeps these controls interactive
140
- * while edit mode applies `inert` to the chrome.
59
+ * Lifted by `@wordpress/grid` into a sibling slot outside `Card.Root`,
60
+ * for full-bleed widgets with no in-card header to host the toolbar.
141
61
  */
142
62
  actionableArea?: ReactNode;
63
+ /**
64
+ * Toolbar rendered in the in-card header (framed and content-bleed).
65
+ */
66
+ headerToolbar?: ReactNode;
143
67
  className?: string;
144
68
  }
145
69
 
146
70
  /**
147
- * Per-instance wrapper. Owns the chrome around a widget instance: identity
148
- * context, header (title + icon), edit-mode `inert` attribute, and the
149
- * error/loading boundaries that keep neighbours mounted when one widget fails
150
- * or is still resolving.
71
+ * Dashboard chrome: wraps `WidgetFrame` in the grid tile's `Card.Root`, owning
72
+ * the missing and resolving states.
151
73
  */
152
74
  export const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(
153
- function WidgetChrome( { widget, index, className }, ref ) {
75
+ function WidgetChrome( { widget, index, className, headerToolbar }, ref ) {
154
76
  const { widgetTypes, isResolvingWidgetTypes, editMode } =
155
77
  useDashboardInternalContext();
156
78
  const widgetType = widgetTypes.find( ( t ) => t.name === widget.type );
@@ -172,12 +94,15 @@ export const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(
172
94
  <Card.Root
173
95
  render={ <section /> }
174
96
  ref={ ref }
175
- className={ clsx( styles.widgetChrome, className ) }
97
+ className={ clsx(
98
+ styles[ 'widget-chrome' ],
99
+ className
100
+ ) }
176
101
  aria-busy="true"
177
102
  aria-label={ __( 'Loading' ) }
178
103
  >
179
104
  <Card.Content
180
- className={ styles.widgetChromeContent }
105
+ className={ styles[ 'widget-chrome-content' ] }
181
106
  >
182
107
  <LoadingOverlay />
183
108
  </Card.Content>
@@ -191,7 +116,10 @@ export const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(
191
116
  <Card.Root
192
117
  render={ <section /> }
193
118
  ref={ ref }
194
- className={ clsx( styles.widgetChrome, className ) }
119
+ className={ clsx(
120
+ styles[ 'widget-chrome' ],
121
+ className
122
+ ) }
195
123
  aria-label={ __( 'Missing widget' ) }
196
124
  >
197
125
  <UnavailableWidget widgetTypeName={ widget.type } />
@@ -200,54 +128,21 @@ export const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(
200
128
  );
201
129
  }
202
130
 
203
- // `presentation` encodes two independent axes. `full-bleed` hides
204
- // the header; both `full-bleed` and `content-bleed` let the body
205
- // break out of the content padding.
206
- const { presentation } = widgetType;
207
- const isHeaderHidden = presentation === 'full-bleed';
208
- const isBodyBleeding =
209
- presentation === 'full-bleed' || presentation === 'content-bleed';
210
- const header = <Header titleId={ titleId } widgetType={ widgetType } />;
211
-
212
- const body = (
213
- <WidgetErrorBoundary>
214
- <Suspense fallback={ <LoadingOverlay /> }>
215
- <WidgetRender widget={ widget } widgetType={ widgetType } />
216
- </Suspense>
217
- </WidgetErrorBoundary>
218
- );
219
-
220
131
  return (
221
132
  <WidgetContextProvider value={ contextValue }>
222
133
  <Card.Root
223
134
  render={ <section /> }
224
135
  ref={ ref }
225
- className={ clsx( styles.widgetChrome, className ) }
136
+ className={ clsx( styles[ 'widget-chrome' ], className ) }
226
137
  aria-labelledby={ widgetType.title ? titleId : undefined }
227
- { ...( editMode ? { inert: 'true' } : {} ) }
228
138
  >
229
- { isHeaderHidden ? (
230
- <VisuallyHidden>{ header }</VisuallyHidden>
231
- ) : (
232
- header
233
- ) }
234
-
235
- <Card.Content
236
- className={ clsx(
237
- styles.widgetChromeContent,
238
- isBodyBleeding && styles.widgetChromeContentBleed
239
- ) }
240
- >
241
- { isBodyBleeding ? (
242
- <Card.FullBleed
243
- className={ styles.widgetChromeBleedScroll }
244
- >
245
- { body }
246
- </Card.FullBleed>
247
- ) : (
248
- body
249
- ) }
250
- </Card.Content>
139
+ <WidgetFrame
140
+ widget={ widget }
141
+ widgetType={ widgetType }
142
+ titleId={ titleId }
143
+ editMode={ editMode }
144
+ headerToolbar={ headerToolbar }
145
+ />
251
146
  </Card.Root>
252
147
  </WidgetContextProvider>
253
148
  );
@@ -0,0 +1,2 @@
1
+ export { WidgetFrame, LoadingOverlay } from './widget-frame';
2
+ export type { WidgetFrameProps } from './widget-frame';
@@ -0,0 +1,17 @@
1
+ /* Scroll viewport that fills the tile height; min:0 bounds tall content. */
2
+ .content {
3
+ flex: 1;
4
+ height: 100%;
5
+ overflow-y: auto;
6
+ min-width: 0;
7
+ min-height: 0;
8
+ }
9
+
10
+ /* Bleeding body reaches the card borders. Card exposes no padding-less section. */
11
+ .bleed-content {
12
+ padding: 0;
13
+ }
14
+
15
+ .loading {
16
+ height: 100%;
17
+ }