@wordpress/widget-dashboard 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +788 -0
  3. package/README.md +241 -0
  4. package/build/components/actions/actions.cjs +265 -0
  5. package/build/components/actions/actions.cjs.map +7 -0
  6. package/build/components/actions/index.cjs +31 -0
  7. package/build/components/actions/index.cjs.map +7 -0
  8. package/build/components/actions-menu/actions-menu.cjs +92 -0
  9. package/build/components/actions-menu/actions-menu.cjs.map +7 -0
  10. package/build/components/actions-menu/index.cjs +31 -0
  11. package/build/components/actions-menu/index.cjs.map +7 -0
  12. package/build/components/commands/commands.cjs +177 -0
  13. package/build/components/commands/commands.cjs.map +7 -0
  14. package/build/components/commands/index.cjs +33 -0
  15. package/build/components/commands/index.cjs.map +7 -0
  16. package/build/components/commands/use-pending-when-edit-mode.cjs +57 -0
  17. package/build/components/commands/use-pending-when-edit-mode.cjs.map +7 -0
  18. package/build/components/layout-settings/index.cjs +31 -0
  19. package/build/components/layout-settings/index.cjs.map +7 -0
  20. package/build/components/layout-settings/layout-model-edit-field/index.cjs +186 -0
  21. package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +7 -0
  22. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +53 -0
  23. package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +7 -0
  24. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +53 -0
  25. package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +7 -0
  26. package/build/components/layout-settings/layout-settings.cjs +207 -0
  27. package/build/components/layout-settings/layout-settings.cjs.map +7 -0
  28. package/build/components/no-widgets-state/index.cjs +31 -0
  29. package/build/components/no-widgets-state/index.cjs.map +7 -0
  30. package/build/components/no-widgets-state/no-widgets-state.cjs +140 -0
  31. package/build/components/no-widgets-state/no-widgets-state.cjs.map +7 -0
  32. package/build/components/reset-confirmation/index.cjs +31 -0
  33. package/build/components/reset-confirmation/index.cjs.map +7 -0
  34. package/build/components/reset-confirmation/reset-confirmation.cjs +62 -0
  35. package/build/components/reset-confirmation/reset-confirmation.cjs.map +7 -0
  36. package/build/components/widget-chrome/index.cjs +31 -0
  37. package/build/components/widget-chrome/index.cjs.map +7 -0
  38. package/build/components/widget-chrome/widget-chrome.cjs +277 -0
  39. package/build/components/widget-chrome/widget-chrome.cjs.map +7 -0
  40. package/build/components/widget-inserter/index.cjs +31 -0
  41. package/build/components/widget-inserter/index.cjs.map +7 -0
  42. package/build/components/widget-inserter/widget-inserter.cjs +78 -0
  43. package/build/components/widget-inserter/widget-inserter.cjs.map +7 -0
  44. package/build/components/widget-picker/index.cjs +31 -0
  45. package/build/components/widget-picker/index.cjs.map +7 -0
  46. package/build/components/widget-picker/widget-picker.cjs +209 -0
  47. package/build/components/widget-picker/widget-picker.cjs.map +7 -0
  48. package/build/components/widget-render/index.cjs +31 -0
  49. package/build/components/widget-render/index.cjs.map +7 -0
  50. package/build/components/widget-render/widget-render.cjs +62 -0
  51. package/build/components/widget-render/widget-render.cjs.map +7 -0
  52. package/build/components/widget-settings/index.cjs +37 -0
  53. package/build/components/widget-settings/index.cjs.map +7 -0
  54. package/build/components/widget-settings/utils/get-admin-menu-inset.cjs +41 -0
  55. package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +7 -0
  56. package/build/components/widget-settings/utils/get-widget-settings.cjs +38 -0
  57. package/build/components/widget-settings/utils/get-widget-settings.cjs.map +7 -0
  58. package/build/components/widget-settings/utils/index.cjs +34 -0
  59. package/build/components/widget-settings/utils/index.cjs.map +7 -0
  60. package/build/components/widget-settings/widget-settings-toolbar.cjs +138 -0
  61. package/build/components/widget-settings/widget-settings-toolbar.cjs.map +7 -0
  62. package/build/components/widget-settings/widget-settings-trigger.cjs +82 -0
  63. package/build/components/widget-settings/widget-settings-trigger.cjs.map +7 -0
  64. package/build/components/widget-settings/widget-settings.cjs +269 -0
  65. package/build/components/widget-settings/widget-settings.cjs.map +7 -0
  66. package/build/components/widget-toolbar/index.cjs +31 -0
  67. package/build/components/widget-toolbar/index.cjs.map +7 -0
  68. package/build/components/widget-toolbar/widget-toolbar.cjs +148 -0
  69. package/build/components/widget-toolbar/widget-toolbar.cjs.map +7 -0
  70. package/build/components/widgets/index.cjs +31 -0
  71. package/build/components/widgets/index.cjs.map +7 -0
  72. package/build/components/widgets/widget-layout-toolbar.cjs +206 -0
  73. package/build/components/widgets/widget-layout-toolbar.cjs.map +7 -0
  74. package/build/components/widgets/widget-resize-handle.cjs +163 -0
  75. package/build/components/widgets/widget-resize-handle.cjs.map +7 -0
  76. package/build/components/widgets/widgets.cjs +277 -0
  77. package/build/components/widgets/widgets.cjs.map +7 -0
  78. package/build/context/dashboard-context.cjs +234 -0
  79. package/build/context/dashboard-context.cjs.map +7 -0
  80. package/build/context/ui-context.cjs +77 -0
  81. package/build/context/ui-context.cjs.map +7 -0
  82. package/build/context/widget-context.cjs +44 -0
  83. package/build/context/widget-context.cjs.map +7 -0
  84. package/build/hooks/use-dashboard-container-column-count.cjs +61 -0
  85. package/build/hooks/use-dashboard-container-column-count.cjs.map +7 -0
  86. package/build/index.cjs +45 -0
  87. package/build/index.cjs.map +7 -0
  88. package/build/lock-unlock.cjs +37 -0
  89. package/build/lock-unlock.cjs.map +7 -0
  90. package/build/types.cjs +31 -0
  91. package/build/types.cjs.map +7 -0
  92. package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs +44 -0
  93. package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs.map +7 -0
  94. package/build/utils/create-dashboard-widget/index.cjs +31 -0
  95. package/build/utils/create-dashboard-widget/index.cjs.map +7 -0
  96. package/build/utils/default-grid/default-grid.cjs +37 -0
  97. package/build/utils/default-grid/default-grid.cjs.map +7 -0
  98. package/build/utils/default-grid/index.cjs +31 -0
  99. package/build/utils/default-grid/index.cjs.map +7 -0
  100. package/build/utils/grid-model-change/grid-model-change.cjs +56 -0
  101. package/build/utils/grid-model-change/grid-model-change.cjs.map +7 -0
  102. package/build/utils/grid-model-change/index.cjs +33 -0
  103. package/build/utils/grid-model-change/index.cjs.map +7 -0
  104. package/build/utils/index.cjs +34 -0
  105. package/build/utils/index.cjs.map +7 -0
  106. package/build/utils/migrate-layout/index.cjs +31 -0
  107. package/build/utils/migrate-layout/index.cjs.map +7 -0
  108. package/build/utils/migrate-layout/migrate-layout.cjs +94 -0
  109. package/build/utils/migrate-layout/migrate-layout.cjs.map +7 -0
  110. package/build/utils/normalize-grid-settings/index.cjs +31 -0
  111. package/build/utils/normalize-grid-settings/index.cjs.map +7 -0
  112. package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs +46 -0
  113. package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs.map +7 -0
  114. package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs +49 -0
  115. package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs.map +7 -0
  116. package/build/utils/row-height-presets/index.cjs +39 -0
  117. package/build/utils/row-height-presets/index.cjs.map +7 -0
  118. package/build/utils/row-height-presets/row-height-presets.cjs +63 -0
  119. package/build/utils/row-height-presets/row-height-presets.cjs.map +7 -0
  120. package/build/widget-dashboard.cjs +86 -0
  121. package/build/widget-dashboard.cjs.map +7 -0
  122. package/build/wordpress-commands.d.cjs +2 -0
  123. package/build/wordpress-commands.d.cjs.map +7 -0
  124. package/build-module/components/actions/actions.mjs +240 -0
  125. package/build-module/components/actions/actions.mjs.map +7 -0
  126. package/build-module/components/actions/index.mjs +6 -0
  127. package/build-module/components/actions/index.mjs.map +7 -0
  128. package/build-module/components/actions-menu/actions-menu.mjs +67 -0
  129. package/build-module/components/actions-menu/actions-menu.mjs.map +7 -0
  130. package/build-module/components/actions-menu/index.mjs +6 -0
  131. package/build-module/components/actions-menu/index.mjs.map +7 -0
  132. package/build-module/components/commands/commands.mjs +160 -0
  133. package/build-module/components/commands/commands.mjs.map +7 -0
  134. package/build-module/components/commands/index.mjs +7 -0
  135. package/build-module/components/commands/index.mjs.map +7 -0
  136. package/build-module/components/commands/use-pending-when-edit-mode.mjs +32 -0
  137. package/build-module/components/commands/use-pending-when-edit-mode.mjs.map +7 -0
  138. package/build-module/components/layout-settings/index.mjs +6 -0
  139. package/build-module/components/layout-settings/index.mjs.map +7 -0
  140. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +151 -0
  141. package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +7 -0
  142. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +28 -0
  143. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +7 -0
  144. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +28 -0
  145. package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +7 -0
  146. package/build-module/components/layout-settings/layout-settings.mjs +187 -0
  147. package/build-module/components/layout-settings/layout-settings.mjs.map +7 -0
  148. package/build-module/components/no-widgets-state/index.mjs +6 -0
  149. package/build-module/components/no-widgets-state/index.mjs.map +7 -0
  150. package/build-module/components/no-widgets-state/no-widgets-state.mjs +115 -0
  151. package/build-module/components/no-widgets-state/no-widgets-state.mjs.map +7 -0
  152. package/build-module/components/reset-confirmation/index.mjs +6 -0
  153. package/build-module/components/reset-confirmation/index.mjs.map +7 -0
  154. package/build-module/components/reset-confirmation/reset-confirmation.mjs +37 -0
  155. package/build-module/components/reset-confirmation/reset-confirmation.mjs.map +7 -0
  156. package/build-module/components/widget-chrome/index.mjs +6 -0
  157. package/build-module/components/widget-chrome/index.mjs.map +7 -0
  158. package/build-module/components/widget-chrome/widget-chrome.mjs +248 -0
  159. package/build-module/components/widget-chrome/widget-chrome.mjs.map +7 -0
  160. package/build-module/components/widget-inserter/index.mjs +6 -0
  161. package/build-module/components/widget-inserter/index.mjs.map +7 -0
  162. package/build-module/components/widget-inserter/widget-inserter.mjs +53 -0
  163. package/build-module/components/widget-inserter/widget-inserter.mjs.map +7 -0
  164. package/build-module/components/widget-picker/index.mjs +6 -0
  165. package/build-module/components/widget-picker/index.mjs.map +7 -0
  166. package/build-module/components/widget-picker/widget-picker.mjs +184 -0
  167. package/build-module/components/widget-picker/widget-picker.mjs.map +7 -0
  168. package/build-module/components/widget-render/index.mjs +6 -0
  169. package/build-module/components/widget-render/index.mjs.map +7 -0
  170. package/build-module/components/widget-render/widget-render.mjs +37 -0
  171. package/build-module/components/widget-render/widget-render.mjs.map +7 -0
  172. package/build-module/components/widget-settings/index.mjs +10 -0
  173. package/build-module/components/widget-settings/index.mjs.map +7 -0
  174. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +16 -0
  175. package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +7 -0
  176. package/build-module/components/widget-settings/utils/get-widget-settings.mjs +13 -0
  177. package/build-module/components/widget-settings/utils/get-widget-settings.mjs.map +7 -0
  178. package/build-module/components/widget-settings/utils/index.mjs +8 -0
  179. package/build-module/components/widget-settings/utils/index.mjs.map +7 -0
  180. package/build-module/components/widget-settings/widget-settings-toolbar.mjs +113 -0
  181. package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +7 -0
  182. package/build-module/components/widget-settings/widget-settings-trigger.mjs +57 -0
  183. package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +7 -0
  184. package/build-module/components/widget-settings/widget-settings.mjs +244 -0
  185. package/build-module/components/widget-settings/widget-settings.mjs.map +7 -0
  186. package/build-module/components/widget-toolbar/index.mjs +6 -0
  187. package/build-module/components/widget-toolbar/index.mjs.map +7 -0
  188. package/build-module/components/widget-toolbar/widget-toolbar.mjs +113 -0
  189. package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +7 -0
  190. package/build-module/components/widgets/index.mjs +6 -0
  191. package/build-module/components/widgets/index.mjs.map +7 -0
  192. package/build-module/components/widgets/widget-layout-toolbar.mjs +181 -0
  193. package/build-module/components/widgets/widget-layout-toolbar.mjs.map +7 -0
  194. package/build-module/components/widgets/widget-resize-handle.mjs +128 -0
  195. package/build-module/components/widgets/widget-resize-handle.mjs.map +7 -0
  196. package/build-module/components/widgets/widgets.mjs +242 -0
  197. package/build-module/components/widgets/widgets.mjs.map +7 -0
  198. package/build-module/context/dashboard-context.mjs +205 -0
  199. package/build-module/context/dashboard-context.mjs.map +7 -0
  200. package/build-module/context/ui-context.mjs +56 -0
  201. package/build-module/context/ui-context.mjs.map +7 -0
  202. package/build-module/context/widget-context.mjs +18 -0
  203. package/build-module/context/widget-context.mjs.map +7 -0
  204. package/build-module/hooks/use-dashboard-container-column-count.mjs +40 -0
  205. package/build-module/hooks/use-dashboard-container-column-count.mjs.map +7 -0
  206. package/build-module/index.mjs +18 -0
  207. package/build-module/index.mjs.map +7 -0
  208. package/build-module/lock-unlock.mjs +11 -0
  209. package/build-module/lock-unlock.mjs.map +7 -0
  210. package/build-module/types.mjs +6 -0
  211. package/build-module/types.mjs.map +7 -0
  212. package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs +19 -0
  213. package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs.map +7 -0
  214. package/build-module/utils/create-dashboard-widget/index.mjs +6 -0
  215. package/build-module/utils/create-dashboard-widget/index.mjs.map +7 -0
  216. package/build-module/utils/default-grid/default-grid.mjs +12 -0
  217. package/build-module/utils/default-grid/default-grid.mjs.map +7 -0
  218. package/build-module/utils/default-grid/index.mjs +6 -0
  219. package/build-module/utils/default-grid/index.mjs.map +7 -0
  220. package/build-module/utils/grid-model-change/grid-model-change.mjs +30 -0
  221. package/build-module/utils/grid-model-change/grid-model-change.mjs.map +7 -0
  222. package/build-module/utils/grid-model-change/index.mjs +7 -0
  223. package/build-module/utils/grid-model-change/index.mjs.map +7 -0
  224. package/build-module/utils/index.mjs +8 -0
  225. package/build-module/utils/index.mjs.map +7 -0
  226. package/build-module/utils/migrate-layout/index.mjs +6 -0
  227. package/build-module/utils/migrate-layout/index.mjs.map +7 -0
  228. package/build-module/utils/migrate-layout/migrate-layout.mjs +69 -0
  229. package/build-module/utils/migrate-layout/migrate-layout.mjs.map +7 -0
  230. package/build-module/utils/normalize-grid-settings/index.mjs +6 -0
  231. package/build-module/utils/normalize-grid-settings/index.mjs.map +7 -0
  232. package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs +21 -0
  233. package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs.map +7 -0
  234. package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs +22 -0
  235. package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs.map +7 -0
  236. package/build-module/utils/row-height-presets/index.mjs +16 -0
  237. package/build-module/utils/row-height-presets/index.mjs.map +7 -0
  238. package/build-module/utils/row-height-presets/row-height-presets.mjs +34 -0
  239. package/build-module/utils/row-height-presets/row-height-presets.mjs.map +7 -0
  240. package/build-module/widget-dashboard.mjs +61 -0
  241. package/build-module/widget-dashboard.mjs.map +7 -0
  242. package/build-module/wordpress-commands.d.mjs +1 -0
  243. package/build-module/wordpress-commands.d.mjs.map +7 -0
  244. package/build-types/components/actions/actions.d.ts +11 -0
  245. package/build-types/components/actions/actions.d.ts.map +1 -0
  246. package/build-types/components/actions/index.d.ts +2 -0
  247. package/build-types/components/actions/index.d.ts.map +1 -0
  248. package/build-types/components/actions-menu/actions-menu.d.ts +22 -0
  249. package/build-types/components/actions-menu/actions-menu.d.ts.map +1 -0
  250. package/build-types/components/actions-menu/index.d.ts +3 -0
  251. package/build-types/components/actions-menu/index.d.ts.map +1 -0
  252. package/build-types/components/commands/commands.d.ts +7 -0
  253. package/build-types/components/commands/commands.d.ts.map +1 -0
  254. package/build-types/components/commands/index.d.ts +2 -0
  255. package/build-types/components/commands/index.d.ts.map +1 -0
  256. package/build-types/components/commands/use-pending-when-edit-mode.d.ts +15 -0
  257. package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -0
  258. package/build-types/components/layout-settings/index.d.ts +2 -0
  259. package/build-types/components/layout-settings/index.d.ts.map +1 -0
  260. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +17 -0
  261. package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +1 -0
  262. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +6 -0
  263. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +1 -0
  264. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +6 -0
  265. package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +1 -0
  266. package/build-types/components/layout-settings/layout-settings.d.ts +14 -0
  267. package/build-types/components/layout-settings/layout-settings.d.ts.map +1 -0
  268. package/build-types/components/no-widgets-state/index.d.ts +2 -0
  269. package/build-types/components/no-widgets-state/index.d.ts.map +1 -0
  270. package/build-types/components/no-widgets-state/no-widgets-state.d.ts +17 -0
  271. package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -0
  272. package/build-types/components/reset-confirmation/index.d.ts +2 -0
  273. package/build-types/components/reset-confirmation/index.d.ts.map +1 -0
  274. package/build-types/components/reset-confirmation/reset-confirmation.d.ts +8 -0
  275. package/build-types/components/reset-confirmation/reset-confirmation.d.ts.map +1 -0
  276. package/build-types/components/widget-chrome/index.d.ts +2 -0
  277. package/build-types/components/widget-chrome/index.d.ts.map +1 -0
  278. package/build-types/components/widget-chrome/widget-chrome.d.ts +22 -0
  279. package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -0
  280. package/build-types/components/widget-inserter/index.d.ts +2 -0
  281. package/build-types/components/widget-inserter/index.d.ts.map +1 -0
  282. package/build-types/components/widget-inserter/widget-inserter.d.ts +7 -0
  283. package/build-types/components/widget-inserter/widget-inserter.d.ts.map +1 -0
  284. package/build-types/components/widget-picker/index.d.ts +2 -0
  285. package/build-types/components/widget-picker/index.d.ts.map +1 -0
  286. package/build-types/components/widget-picker/widget-picker.d.ts +26 -0
  287. package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -0
  288. package/build-types/components/widget-render/index.d.ts +2 -0
  289. package/build-types/components/widget-render/index.d.ts.map +1 -0
  290. package/build-types/components/widget-render/widget-render.d.ts +17 -0
  291. package/build-types/components/widget-render/widget-render.d.ts.map +1 -0
  292. package/build-types/components/widget-settings/index.d.ts +5 -0
  293. package/build-types/components/widget-settings/index.d.ts.map +1 -0
  294. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +17 -0
  295. package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +1 -0
  296. package/build-types/components/widget-settings/utils/get-widget-settings.d.ts +10 -0
  297. package/build-types/components/widget-settings/utils/get-widget-settings.d.ts.map +1 -0
  298. package/build-types/components/widget-settings/utils/index.d.ts +3 -0
  299. package/build-types/components/widget-settings/utils/index.d.ts.map +1 -0
  300. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +20 -0
  301. package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +1 -0
  302. package/build-types/components/widget-settings/widget-settings-trigger.d.ts +23 -0
  303. package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -0
  304. package/build-types/components/widget-settings/widget-settings.d.ts +13 -0
  305. package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -0
  306. package/build-types/components/widget-toolbar/index.d.ts +3 -0
  307. package/build-types/components/widget-toolbar/index.d.ts.map +1 -0
  308. package/build-types/components/widget-toolbar/widget-toolbar.d.ts +16 -0
  309. package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -0
  310. package/build-types/components/widgets/index.d.ts +2 -0
  311. package/build-types/components/widgets/index.d.ts.map +1 -0
  312. package/build-types/components/widgets/widget-layout-toolbar.d.ts +14 -0
  313. package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +1 -0
  314. package/build-types/components/widgets/widget-resize-handle.d.ts +12 -0
  315. package/build-types/components/widgets/widget-resize-handle.d.ts.map +1 -0
  316. package/build-types/components/widgets/widgets.d.ts +10 -0
  317. package/build-types/components/widgets/widgets.d.ts.map +1 -0
  318. package/build-types/context/dashboard-context.d.ts +111 -0
  319. package/build-types/context/dashboard-context.d.ts.map +1 -0
  320. package/build-types/context/ui-context.d.ts +54 -0
  321. package/build-types/context/ui-context.d.ts.map +1 -0
  322. package/build-types/context/widget-context.d.ts +25 -0
  323. package/build-types/context/widget-context.d.ts.map +1 -0
  324. package/build-types/hooks/use-dashboard-container-column-count.d.ts +15 -0
  325. package/build-types/hooks/use-dashboard-container-column-count.d.ts.map +1 -0
  326. package/build-types/index.d.ts +7 -0
  327. package/build-types/index.d.ts.map +1 -0
  328. package/build-types/lock-unlock.d.ts +2 -0
  329. package/build-types/lock-unlock.d.ts.map +1 -0
  330. package/build-types/types.d.ts +222 -0
  331. package/build-types/types.d.ts.map +1 -0
  332. package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts +20 -0
  333. package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts.map +1 -0
  334. package/build-types/utils/create-dashboard-widget/index.d.ts +2 -0
  335. package/build-types/utils/create-dashboard-widget/index.d.ts.map +1 -0
  336. package/build-types/utils/default-grid/default-grid.d.ts +11 -0
  337. package/build-types/utils/default-grid/default-grid.d.ts.map +1 -0
  338. package/build-types/utils/default-grid/index.d.ts +2 -0
  339. package/build-types/utils/default-grid/index.d.ts.map +1 -0
  340. package/build-types/utils/grid-model-change/grid-model-change.d.ts +20 -0
  341. package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +1 -0
  342. package/build-types/utils/grid-model-change/index.d.ts +2 -0
  343. package/build-types/utils/grid-model-change/index.d.ts.map +1 -0
  344. package/build-types/utils/index.d.ts +3 -0
  345. package/build-types/utils/index.d.ts.map +1 -0
  346. package/build-types/utils/migrate-layout/index.d.ts +2 -0
  347. package/build-types/utils/migrate-layout/index.d.ts.map +1 -0
  348. package/build-types/utils/migrate-layout/migrate-layout.d.ts +36 -0
  349. package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +1 -0
  350. package/build-types/utils/normalize-grid-settings/index.d.ts +2 -0
  351. package/build-types/utils/normalize-grid-settings/index.d.ts.map +1 -0
  352. package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts +11 -0
  353. package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts.map +1 -0
  354. package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts +21 -0
  355. package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts.map +1 -0
  356. package/build-types/utils/row-height-presets/index.d.ts +3 -0
  357. package/build-types/utils/row-height-presets/index.d.ts.map +1 -0
  358. package/build-types/utils/row-height-presets/row-height-presets.d.ts +17 -0
  359. package/build-types/utils/row-height-presets/row-height-presets.d.ts.map +1 -0
  360. package/build-types/widget-dashboard.d.ts +51 -0
  361. package/build-types/widget-dashboard.d.ts.map +1 -0
  362. package/package.json +90 -0
  363. package/src/components/actions/actions.module.css +54 -0
  364. package/src/components/actions/actions.tsx +180 -0
  365. package/src/components/actions/index.ts +1 -0
  366. package/src/components/actions-menu/actions-menu.tsx +104 -0
  367. package/src/components/actions-menu/index.ts +2 -0
  368. package/src/components/commands/commands.tsx +182 -0
  369. package/src/components/commands/index.ts +1 -0
  370. package/src/components/commands/use-pending-when-edit-mode.ts +48 -0
  371. package/src/components/layout-settings/index.ts +1 -0
  372. package/src/components/layout-settings/layout-model-edit-field/index.tsx +98 -0
  373. package/src/components/layout-settings/layout-model-edit-field/style.module.css +34 -0
  374. package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +28 -0
  375. package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +28 -0
  376. package/src/components/layout-settings/layout-settings.tsx +217 -0
  377. package/src/components/no-widgets-state/index.ts +1 -0
  378. package/src/components/no-widgets-state/no-widgets-state.module.css +3 -0
  379. package/src/components/no-widgets-state/no-widgets-state.tsx +56 -0
  380. package/src/components/reset-confirmation/index.ts +1 -0
  381. package/src/components/reset-confirmation/reset-confirmation.tsx +44 -0
  382. package/src/components/widget-chrome/index.ts +1 -0
  383. package/src/components/widget-chrome/widget-chrome.module.css +87 -0
  384. package/src/components/widget-chrome/widget-chrome.tsx +255 -0
  385. package/src/components/widget-inserter/index.ts +1 -0
  386. package/src/components/widget-inserter/widget-inserter.tsx +70 -0
  387. package/src/components/widget-picker/index.ts +1 -0
  388. package/src/components/widget-picker/widget-picker.module.css +11 -0
  389. package/src/components/widget-picker/widget-picker.tsx +137 -0
  390. package/src/components/widget-render/index.ts +1 -0
  391. package/src/components/widget-render/widget-render.tsx +58 -0
  392. package/src/components/widget-settings/index.ts +4 -0
  393. package/src/components/widget-settings/utils/get-admin-menu-inset.ts +30 -0
  394. package/src/components/widget-settings/utils/get-widget-settings.ts +22 -0
  395. package/src/components/widget-settings/utils/index.ts +2 -0
  396. package/src/components/widget-settings/widget-settings-toolbar.module.css +25 -0
  397. package/src/components/widget-settings/widget-settings-toolbar.tsx +45 -0
  398. package/src/components/widget-settings/widget-settings-trigger.tsx +96 -0
  399. package/src/components/widget-settings/widget-settings.module.css +8 -0
  400. package/src/components/widget-settings/widget-settings.tsx +200 -0
  401. package/src/components/widget-toolbar/index.ts +2 -0
  402. package/src/components/widget-toolbar/widget-toolbar.module.css +12 -0
  403. package/src/components/widget-toolbar/widget-toolbar.tsx +46 -0
  404. package/src/components/widgets/index.ts +1 -0
  405. package/src/components/widgets/widget-layout-toolbar.module.css +6 -0
  406. package/src/components/widgets/widget-layout-toolbar.tsx +118 -0
  407. package/src/components/widgets/widget-resize-handle.module.css +135 -0
  408. package/src/components/widgets/widget-resize-handle.tsx +60 -0
  409. package/src/components/widgets/widgets.module.css +43 -0
  410. package/src/components/widgets/widgets.tsx +208 -0
  411. package/src/context/dashboard-context.tsx +386 -0
  412. package/src/context/ui-context.tsx +118 -0
  413. package/src/context/widget-context.tsx +45 -0
  414. package/src/hooks/use-dashboard-container-column-count.ts +63 -0
  415. package/src/index.ts +9 -0
  416. package/src/lock-unlock.ts +10 -0
  417. package/src/test/actions.test.tsx +228 -0
  418. package/src/test/commands.test.tsx +176 -0
  419. package/src/test/create-dashboard-widget.test.ts +59 -0
  420. package/src/test/dashboard-context.test.tsx +26 -0
  421. package/src/test/staging.test.tsx +476 -0
  422. package/src/test/widget-dashboard.test.tsx +204 -0
  423. package/src/test/widget-inserter.test.tsx +210 -0
  424. package/src/test/widget-settings.test.tsx +199 -0
  425. package/src/types.ts +260 -0
  426. package/src/utils/create-dashboard-widget/create-dashboard-widget.ts +43 -0
  427. package/src/utils/create-dashboard-widget/index.ts +1 -0
  428. package/src/utils/default-grid/default-grid.ts +17 -0
  429. package/src/utils/default-grid/index.ts +1 -0
  430. package/src/utils/grid-model-change/grid-model-change.ts +53 -0
  431. package/src/utils/grid-model-change/index.ts +1 -0
  432. package/src/utils/index.ts +2 -0
  433. package/src/utils/migrate-layout/index.ts +1 -0
  434. package/src/utils/migrate-layout/migrate-layout.ts +156 -0
  435. package/src/utils/migrate-layout/test/migrate-layout.test.ts +114 -0
  436. package/src/utils/normalize-grid-settings/index.ts +1 -0
  437. package/src/utils/normalize-grid-settings/normalize-grid-settings.ts +38 -0
  438. package/src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts +41 -0
  439. package/src/utils/resolve-dashboard-column-count/test/resolve-dashboard-column-count.test.ts +44 -0
  440. package/src/utils/row-height-presets/index.ts +8 -0
  441. package/src/utils/row-height-presets/row-height-presets.ts +43 -0
  442. package/src/widget-dashboard.tsx +102 -0
  443. package/src/wordpress-commands.d.ts +12 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type { WidgetGridSettings } from '../../types';
5
+ import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
6
+ import { DEFAULT_ROW_HEIGHT } from '../row-height-presets';
7
+
8
+ /**
9
+ * Canonical default grid settings. Applied by the dashboard when the
10
+ * consumer omits `gridSettings`, and the baseline hosts should treat as
11
+ * the factory default when persisting their own copy.
12
+ */
13
+ export const DEFAULT_GRID: WidgetGridSettings = {
14
+ model: 'grid',
15
+ columns: WIDGET_DASHBOARD_COLUMN_COUNT,
16
+ rowHeight: DEFAULT_ROW_HEIGHT,
17
+ };
@@ -0,0 +1 @@
1
+ export { DEFAULT_GRID } from './default-grid';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { migrateLayout } from '../migrate-layout';
5
+ import type {
6
+ DashboardWidget,
7
+ WidgetGridModel,
8
+ WidgetGridSettings,
9
+ } from '../../types';
10
+ import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
11
+
12
+ export function getGridModel( settings: WidgetGridSettings ): WidgetGridModel {
13
+ return settings.model ?? 'grid';
14
+ }
15
+
16
+ type ComputeGridModelChangeProps = {
17
+ layout: DashboardWidget[];
18
+ gridSettings: WidgetGridSettings;
19
+ targetModel: WidgetGridModel;
20
+ };
21
+
22
+ type ComputeGridModelChangeResult = {
23
+ layout: DashboardWidget[];
24
+ gridSettings: WidgetGridSettings;
25
+ } | null;
26
+
27
+ /**
28
+ * Computes the staged layout and grid settings after a layout-model change.
29
+ *
30
+ * @param {ComputeGridModelChangeProps} params Layout, current settings, and target model.
31
+ * @return {ComputeGridModelChangeResult} Migrated layout and settings, or `null` when the model is unchanged.
32
+ */
33
+ export function computeGridModelChange( {
34
+ layout,
35
+ gridSettings,
36
+ targetModel,
37
+ }: ComputeGridModelChangeProps ): ComputeGridModelChangeResult {
38
+ const currentModel = getGridModel( gridSettings );
39
+
40
+ if ( currentModel === targetModel ) {
41
+ return null;
42
+ }
43
+
44
+ return {
45
+ layout: migrateLayout( layout, currentModel, targetModel, {
46
+ columns: WIDGET_DASHBOARD_COLUMN_COUNT,
47
+ } ),
48
+ gridSettings: {
49
+ ...gridSettings,
50
+ model: targetModel,
51
+ } as WidgetGridSettings,
52
+ };
53
+ }
@@ -0,0 +1 @@
1
+ export { computeGridModelChange, getGridModel } from './grid-model-change';
@@ -0,0 +1,2 @@
1
+ export { createDashboardWidget } from './create-dashboard-widget';
2
+ export { migrateLayout } from './migrate-layout';
@@ -0,0 +1 @@
1
+ export { migrateLayout } from './migrate-layout';
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import type {
5
+ DashboardWidget,
6
+ GridTilePlacement,
7
+ MasonryTilePlacement,
8
+ WidgetGridModel,
9
+ } from '../../types';
10
+
11
+ interface MigrationContext {
12
+ /**
13
+ * Column count of the currently-mounted grid surface. Used to
14
+ * resolve `'full'` widths to a concrete numeric span when going
15
+ * from the 2D grid model to masonry. When the surface is in
16
+ * responsive mode and the runtime column count is unknown,
17
+ * callers should pass a sensible fallback (e.g., the default of
18
+ * 6 used by `@wordpress/grid`).
19
+ */
20
+ columns: number;
21
+ }
22
+
23
+ const FALLBACK_COLUMNS = 6;
24
+
25
+ /**
26
+ * Coerces a `'fill'`/`'full'`/numeric width into a concrete numeric
27
+ * span when migrating from `'grid'` to `'masonry'`. `'fill'` collapses
28
+ * to a single column; resolving it against per-row remainder would
29
+ * require either DOM measurement or replicating CSS-Grid's auto-flow
30
+ * placement, both of which were judged not worth the complexity for
31
+ * a one-shot migration the user can correct visually in staging.
32
+ *
33
+ * @param width Source width from a grid placement.
34
+ * @param targetColumns Column count to use for `'full'` widths.
35
+ */
36
+ function gridWidthToMasonryWidth(
37
+ width: GridTilePlacement[ 'width' ],
38
+ targetColumns: number
39
+ ): number {
40
+ if ( width === 'full' ) {
41
+ return targetColumns;
42
+ }
43
+ if ( width === 'fill' || width === undefined ) {
44
+ return 1;
45
+ }
46
+ return width;
47
+ }
48
+
49
+ /**
50
+ * Transforms a single placement from the 2D grid shape to the masonry
51
+ * shape. Drops `height` (masonry derives heights from content),
52
+ * preserves `order`, leaves `lane` unset so the auto-flow placer
53
+ * arranges items by source order.
54
+ *
55
+ * @param placement Source grid placement.
56
+ * @param context Migration context (column count).
57
+ */
58
+ function migratePlacementGridToMasonry(
59
+ placement: GridTilePlacement | undefined,
60
+ context: MigrationContext
61
+ ): MasonryTilePlacement {
62
+ if ( ! placement ) {
63
+ return {};
64
+ }
65
+
66
+ const next: MasonryTilePlacement = {};
67
+ const width = gridWidthToMasonryWidth( placement.width, context.columns );
68
+ if ( width !== 1 ) {
69
+ next.width = width;
70
+ }
71
+ if ( placement.order !== undefined ) {
72
+ next.order = placement.order;
73
+ }
74
+ return next;
75
+ }
76
+
77
+ /**
78
+ * Transforms a single placement from the masonry shape to the 2D grid
79
+ * shape. Preserves the numeric width, drops `lane` (the 2D grid
80
+ * auto-packs and has no pin-to-column concept), and seeds `height: 1`
81
+ * since masonry never persisted a height. The user is expected to
82
+ * resize tiles vertically after the migration.
83
+ *
84
+ * @param placement Source masonry placement.
85
+ */
86
+ function migratePlacementMasonryToGrid(
87
+ placement: MasonryTilePlacement | undefined
88
+ ): GridTilePlacement {
89
+ if ( ! placement ) {
90
+ return { height: 1 };
91
+ }
92
+
93
+ const next: GridTilePlacement = { height: 1 };
94
+ if ( placement.width !== undefined ) {
95
+ next.width = placement.width;
96
+ }
97
+ if ( placement.order !== undefined ) {
98
+ next.order = placement.order;
99
+ }
100
+ return next;
101
+ }
102
+
103
+ /**
104
+ * Migrates every widget's `placement` between grid models.
105
+ *
106
+ * The two storage shapes overlap on `width` and `order` but diverge
107
+ * on the rest: 2D grid carries `height` and discriminated string
108
+ * widths (`'fill'`/`'full'`), lanes carries `lane` and only numeric
109
+ * widths. Each conversion loses information that the target model
110
+ * cannot represent. The caller is responsible for surfacing the
111
+ * result to the user in a way that lets them correct visually.
112
+ *
113
+ * When `from === to`, the input is returned unchanged.
114
+ *
115
+ * @param widgets Widgets to migrate.
116
+ * @param from Source model. `undefined` is treated as `'grid'`.
117
+ * @param to Target model.
118
+ * @param context Information that depends on the live render (today
119
+ * only `columns`).
120
+ */
121
+ export function migrateLayout(
122
+ widgets: DashboardWidget[],
123
+ from: WidgetGridModel | undefined,
124
+ to: WidgetGridModel,
125
+ context: Partial< MigrationContext > = {}
126
+ ): DashboardWidget[] {
127
+ const resolvedFrom: WidgetGridModel = from ?? 'grid';
128
+ if ( resolvedFrom === to ) {
129
+ return widgets;
130
+ }
131
+
132
+ const resolvedContext: MigrationContext = {
133
+ columns: context.columns ?? FALLBACK_COLUMNS,
134
+ };
135
+
136
+ if ( resolvedFrom === 'grid' && to === 'masonry' ) {
137
+ return widgets.map( ( widget ) => ( {
138
+ ...widget,
139
+ placement: migratePlacementGridToMasonry(
140
+ widget.placement as GridTilePlacement | undefined,
141
+ resolvedContext
142
+ ),
143
+ } ) );
144
+ }
145
+
146
+ if ( resolvedFrom === 'masonry' && to === 'grid' ) {
147
+ return widgets.map( ( widget ) => ( {
148
+ ...widget,
149
+ placement: migratePlacementMasonryToGrid(
150
+ widget.placement as MasonryTilePlacement | undefined
151
+ ),
152
+ } ) );
153
+ }
154
+
155
+ return widgets;
156
+ }
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { migrateLayout } from '../migrate-layout';
5
+ import type { DashboardWidget } from '../../../types';
6
+
7
+ function widget( uuid: string, placement: object | undefined = undefined ) {
8
+ return {
9
+ uuid,
10
+ type: 'core/test' as const,
11
+ placement,
12
+ } as DashboardWidget;
13
+ }
14
+
15
+ describe( 'migrateLayout', () => {
16
+ it( 'returns input unchanged when source and target match', () => {
17
+ const layout: DashboardWidget[] = [
18
+ widget( 'a', { width: 2, height: 1 } ),
19
+ ];
20
+ expect( migrateLayout( layout, 'grid', 'grid' ) ).toBe( layout );
21
+ } );
22
+
23
+ it( 'treats undefined source as grid', () => {
24
+ const layout: DashboardWidget[] = [
25
+ widget( 'a', { width: 'full', height: 1 } ),
26
+ ];
27
+ const migrated = migrateLayout( layout, undefined, 'masonry', {
28
+ columns: 4,
29
+ } );
30
+ expect( migrated[ 0 ].placement ).toEqual( { width: 4 } );
31
+ } );
32
+
33
+ describe( 'grid to masonry', () => {
34
+ it( "expands 'full' to the target column count", () => {
35
+ const layout: DashboardWidget[] = [
36
+ widget( 'a', { width: 'full', height: 1 } ),
37
+ ];
38
+ const migrated = migrateLayout( layout, 'grid', 'masonry', {
39
+ columns: 6,
40
+ } );
41
+ expect( migrated[ 0 ].placement ).toEqual( { width: 6 } );
42
+ } );
43
+
44
+ it( "collapses 'fill' to a single column", () => {
45
+ const layout: DashboardWidget[] = [
46
+ widget( 'a', { width: 'fill', height: 2 } ),
47
+ ];
48
+ const migrated = migrateLayout( layout, 'grid', 'masonry', {
49
+ columns: 6,
50
+ } );
51
+ expect( migrated[ 0 ].placement ).toEqual( {} );
52
+ } );
53
+
54
+ it( 'preserves numeric width and drops height and explicit width=1', () => {
55
+ const layout: DashboardWidget[] = [
56
+ widget( 'a', { width: 3, height: 2, order: 5 } ),
57
+ widget( 'b', { width: 1, height: 1 } ),
58
+ ];
59
+ const migrated = migrateLayout( layout, 'grid', 'masonry', {
60
+ columns: 6,
61
+ } );
62
+ expect( migrated[ 0 ].placement ).toEqual( {
63
+ width: 3,
64
+ order: 5,
65
+ } );
66
+ expect( migrated[ 1 ].placement ).toEqual( {} );
67
+ } );
68
+
69
+ it( 'falls back to a default column count when not provided', () => {
70
+ const layout: DashboardWidget[] = [
71
+ widget( 'a', { width: 'full', height: 1 } ),
72
+ ];
73
+ const migrated = migrateLayout( layout, 'grid', 'masonry' );
74
+ expect( migrated[ 0 ].placement ).toEqual( { width: 6 } );
75
+ } );
76
+
77
+ it( 'handles widgets without a placement', () => {
78
+ const layout: DashboardWidget[] = [ widget( 'a' ) ];
79
+ const migrated = migrateLayout( layout, 'grid', 'masonry' );
80
+ expect( migrated[ 0 ].placement ).toEqual( {} );
81
+ } );
82
+ } );
83
+
84
+ describe( 'masonry to grid', () => {
85
+ it( 'seeds height=1 and preserves width and order', () => {
86
+ const layout: DashboardWidget[] = [
87
+ widget( 'a', { width: 2, order: 1 } ),
88
+ ];
89
+ const migrated = migrateLayout( layout, 'masonry', 'grid' );
90
+ expect( migrated[ 0 ].placement ).toEqual( {
91
+ width: 2,
92
+ height: 1,
93
+ order: 1,
94
+ } );
95
+ } );
96
+
97
+ it( 'drops the lane field', () => {
98
+ const layout: DashboardWidget[] = [
99
+ widget( 'a', { width: 1, lane: 2 } ),
100
+ ];
101
+ const migrated = migrateLayout( layout, 'masonry', 'grid' );
102
+ expect( migrated[ 0 ].placement ).toEqual( {
103
+ width: 1,
104
+ height: 1,
105
+ } );
106
+ } );
107
+
108
+ it( 'handles widgets without a placement', () => {
109
+ const layout: DashboardWidget[] = [ widget( 'a' ) ];
110
+ const migrated = migrateLayout( layout, 'masonry', 'grid' );
111
+ expect( migrated[ 0 ].placement ).toEqual( { height: 1 } );
112
+ } );
113
+ } );
114
+ } );
@@ -0,0 +1 @@
1
+ export { normalizeGridSettings } from './normalize-grid-settings';
@@ -0,0 +1,38 @@
1
+ import type { WidgetGridLayoutSettings, WidgetGridSettings } from '../../types';
2
+ import { snapRowHeight } from '../row-height-presets';
3
+
4
+ /**
5
+ * Coerces legacy grid row heights to a dashboard preset. Standard grid
6
+ * rows always use uniform track sizing so tiles align with the masonry
7
+ * model boundary.
8
+ *
9
+ * @param settings Grid settings to normalize.
10
+ * @param defaultRowHeight Fallback row height when none is set.
11
+ */
12
+ export function normalizeGridSettings(
13
+ settings: WidgetGridSettings,
14
+ defaultRowHeight: number
15
+ ): WidgetGridSettings {
16
+ if ( ( settings.model ?? 'grid' ) === 'masonry' ) {
17
+ return settings;
18
+ }
19
+
20
+ // The guard above cannot narrow the union for TypeScript: `model` is
21
+ // optional and the check goes through `??`.
22
+ const gridSettings = settings as WidgetGridLayoutSettings;
23
+
24
+ const rowHeight = gridSettings.rowHeight;
25
+ const resolved =
26
+ typeof rowHeight === 'number'
27
+ ? snapRowHeight( rowHeight )
28
+ : defaultRowHeight;
29
+
30
+ if ( rowHeight === resolved ) {
31
+ return settings;
32
+ }
33
+
34
+ return {
35
+ ...gridSettings,
36
+ rowHeight: resolved,
37
+ };
38
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
5
+
6
+ /**
7
+ * Container width (px) below which the dashboard uses a single column.
8
+ * Matches `@container widget-dashboard (max-width: …)` in widgets CSS.
9
+ */
10
+ export const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN = 600;
11
+
12
+ /**
13
+ * Container width (px) below which the dashboard drops from four columns
14
+ * to two. Above this threshold (and below the four-column cap) the
15
+ * grid uses {@link WIDGET_DASHBOARD_COLUMN_COUNT}.
16
+ */
17
+ export const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS = 960;
18
+
19
+ /**
20
+ * Resolves the dashboard grid column count from the widget surface
21
+ * container width. Uses discrete steps (4 → 2 → 1), not viewport
22
+ * media queries.
23
+ *
24
+ * @param containerWidth Measured inline size of the dashboard grid container.
25
+ * @return Column count for {@link @wordpress/grid} surfaces.
26
+ */
27
+ export function resolveDashboardColumnCount( containerWidth: number ): number {
28
+ if ( containerWidth <= 0 ) {
29
+ return WIDGET_DASHBOARD_COLUMN_COUNT;
30
+ }
31
+
32
+ if ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN ) {
33
+ return 1;
34
+ }
35
+
36
+ if ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS ) {
37
+ return 2;
38
+ }
39
+
40
+ return WIDGET_DASHBOARD_COLUMN_COUNT;
41
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import {
5
+ resolveDashboardColumnCount,
6
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN,
7
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS,
8
+ } from '../resolve-dashboard-column-count';
9
+
10
+ describe( 'resolveDashboardColumnCount', () => {
11
+ it( 'defaults to four columns before measurement', () => {
12
+ expect( resolveDashboardColumnCount( 0 ) ).toBe( 4 );
13
+ } );
14
+
15
+ it( 'uses four columns at wide container sizes', () => {
16
+ expect(
17
+ resolveDashboardColumnCount(
18
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS
19
+ )
20
+ ).toBe( 4 );
21
+ expect( resolveDashboardColumnCount( 1200 ) ).toBe( 4 );
22
+ } );
23
+
24
+ it( 'uses two columns between mobile and wide breakpoints', () => {
25
+ expect(
26
+ resolveDashboardColumnCount(
27
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN
28
+ )
29
+ ).toBe( 2 );
30
+ expect(
31
+ resolveDashboardColumnCount(
32
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS - 1
33
+ )
34
+ ).toBe( 2 );
35
+ } );
36
+
37
+ it( 'uses one column below the mobile container breakpoint', () => {
38
+ expect(
39
+ resolveDashboardColumnCount(
40
+ WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN - 1
41
+ )
42
+ ).toBe( 1 );
43
+ } );
44
+ } );
@@ -0,0 +1,8 @@
1
+ export {
2
+ DEFAULT_ROW_HEIGHT,
3
+ ROW_HEIGHT_PRESETS,
4
+ presetToRowHeight,
5
+ rowHeightToPreset,
6
+ snapRowHeight,
7
+ } from './row-height-presets';
8
+ export type { RowHeightPreset } from './row-height-presets';
@@ -0,0 +1,43 @@
1
+ export const ROW_HEIGHT_PRESETS = {
2
+ small: 200,
3
+ medium: 300,
4
+ large: 400,
5
+ } as const;
6
+
7
+ export type RowHeightPreset = keyof typeof ROW_HEIGHT_PRESETS;
8
+
9
+ export const DEFAULT_ROW_HEIGHT = ROW_HEIGHT_PRESETS.medium;
10
+
11
+ const PRESET_ENTRIES = Object.entries( ROW_HEIGHT_PRESETS ) as [
12
+ RowHeightPreset,
13
+ number,
14
+ ][];
15
+
16
+ /**
17
+ * Maps a stored pixel height to the nearest preset so legacy freeform
18
+ * values still resolve to a valid toggle option.
19
+ *
20
+ * @param rowHeight Row height in pixels.
21
+ */
22
+ export function rowHeightToPreset( rowHeight: number ): RowHeightPreset {
23
+ let closest: RowHeightPreset = 'medium';
24
+ let minDistance = Infinity;
25
+
26
+ for ( const [ preset, value ] of PRESET_ENTRIES ) {
27
+ const distance = Math.abs( rowHeight - value );
28
+ if ( distance < minDistance ) {
29
+ minDistance = distance;
30
+ closest = preset;
31
+ }
32
+ }
33
+
34
+ return closest;
35
+ }
36
+
37
+ export function presetToRowHeight( preset: RowHeightPreset ): number {
38
+ return ROW_HEIGHT_PRESETS[ preset ];
39
+ }
40
+
41
+ export function snapRowHeight( rowHeight: number ): number {
42
+ return presetToRowHeight( rowHeightToPreset( rowHeight ) );
43
+ }
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { WidgetDashboardProvider } from './context/dashboard-context';
5
+ import { WidgetDashboardUIProvider } from './context/ui-context';
6
+ import { Actions } from './components/actions';
7
+ import { Commands } from './components/commands';
8
+ import { LayoutSettings } from './components/layout-settings';
9
+ import { NoWidgetsState } from './components/no-widgets-state';
10
+ import { ResetConfirmation } from './components/reset-confirmation';
11
+ import { WidgetChrome } from './components/widget-chrome';
12
+ import { WidgetInserter } from './components/widget-inserter';
13
+ import { WidgetSettings } from './components/widget-settings';
14
+ import { Widgets } from './components/widgets';
15
+ import type { WidgetDashboardProps } from './types';
16
+
17
+ /**
18
+ * Stateless rendering engine for widget dashboards.
19
+ *
20
+ * The consumer owns `layout` and `editMode` state; every mutation fires
21
+ * `onLayoutChange` with the fully updated array. The engine never queries a
22
+ * widget store; types flow in via the `widgetTypes` prop.
23
+ *
24
+ * ```tsx
25
+ * import { WidgetDashboard } from '@wordpress/widget-dashboard';
26
+ *
27
+ * function MyDashboard() {
28
+ * const [ layout, setLayout ] = useState( defaultLayout );
29
+ * const [ editMode, setEditMode ] = useState( false );
30
+ * return (
31
+ * <WidgetDashboard
32
+ * layout={ layout }
33
+ * onLayoutChange={ setLayout }
34
+ * widgetTypes={ widgetTypes }
35
+ * editMode={ editMode }
36
+ * onEditChange={ setEditMode }
37
+ * >
38
+ * <WidgetDashboard.NoWidgetsState>
39
+ * <p>No widgets yet.</p>
40
+ * </WidgetDashboard.NoWidgetsState>
41
+ * <WidgetDashboard.Actions />
42
+ * <WidgetDashboard.Widgets />
43
+ * <WidgetDashboard.Commands />
44
+ * </WidgetDashboard>
45
+ * );
46
+ * }
47
+ * ```
48
+ *
49
+ * Children compose the dashboard's triggers and chrome: `Actions`,
50
+ * `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the
51
+ * widget inserter, the layout and widget settings editors, the reset
52
+ * confirmation) are mounted by the engine and driven by shared UI state, so
53
+ * a trigger works wherever it is composed without a matching target in the
54
+ * tree. Omitting `children` renders the default arrangement.
55
+ */
56
+ export const WidgetDashboard = Object.assign(
57
+ function WidgetDashboard( {
58
+ layout,
59
+ onLayoutChange,
60
+ onLayoutReset,
61
+ widgetTypes,
62
+ isResolvingWidgetTypes,
63
+ editMode,
64
+ onEditChange,
65
+ resolveWidgetModule,
66
+ gridSettings,
67
+ onGridSettingsChange,
68
+ children,
69
+ }: WidgetDashboardProps ) {
70
+ return (
71
+ <WidgetDashboardProvider
72
+ layout={ layout }
73
+ onLayoutChange={ onLayoutChange }
74
+ onLayoutReset={ onLayoutReset }
75
+ widgetTypes={ widgetTypes }
76
+ isResolvingWidgetTypes={ isResolvingWidgetTypes }
77
+ editMode={ editMode }
78
+ onEditChange={ onEditChange }
79
+ resolveWidgetModule={ resolveWidgetModule }
80
+ gridSettings={ gridSettings }
81
+ onGridSettingsChange={ onGridSettingsChange }
82
+ >
83
+ <WidgetDashboardUIProvider>
84
+ { children ?? (
85
+ <>
86
+ <NoWidgetsState />
87
+ <Actions />
88
+ <Widgets />
89
+ <Commands />
90
+ </>
91
+ ) }
92
+
93
+ <WidgetInserter />
94
+ <LayoutSettings />
95
+ <WidgetSettings />
96
+ <ResetConfirmation />
97
+ </WidgetDashboardUIProvider>
98
+ </WidgetDashboardProvider>
99
+ );
100
+ },
101
+ { Actions, Widgets, WidgetChrome, NoWidgetsState, Commands }
102
+ );
@@ -0,0 +1,12 @@
1
+ /*
2
+ * `@wordpress/commands` ships untyped JavaScript resolved through gitignored
3
+ * build artifacts; this ambient declaration covers the surface this package
4
+ * consumes so type builds don't depend on those artifacts existing.
5
+ */
6
+ declare module '@wordpress/commands' {
7
+ import type { StoreDescriptor } from '@wordpress/data';
8
+
9
+ export function useCommands( commands: unknown[] ): void;
10
+ export const privateApis: Record< string, unknown >;
11
+ export const store: StoreDescriptor;
12
+ }