@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 +0,0 @@
1
- export { LayoutSettings } from './layout-settings';
@@ -1,98 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import type { DataFormControlProps } from '@wordpress/dataviews';
10
- import { useCallback } from '@wordpress/element';
11
- /* eslint-disable @wordpress/use-recommended-components */
12
- import { Button, Fieldset, Stack, Text } from '@wordpress/ui';
13
- /* eslint-enable @wordpress/use-recommended-components */
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import type { WidgetGridSettings } from '../../../types';
19
- import { GridThumbnail } from './thumbnail-grid';
20
- import { MasonryThumbnail } from './thumbnail-masonry';
21
- import styles from './style.module.css';
22
-
23
- interface ModelThumbnailProps {
24
- model: string;
25
- className?: string;
26
- }
27
-
28
- function ModelThumbnail( {
29
- model,
30
- className,
31
- }: ModelThumbnailProps ): React.ReactNode {
32
- return model === 'masonry' ? (
33
- <MasonryThumbnail className={ className } />
34
- ) : (
35
- <GridThumbnail className={ className } />
36
- );
37
- }
38
-
39
- /**
40
- * Card-style picker for the layout model: each option (`grid`, `masonry`)
41
- * renders as a thumbnail card in a radio group. Wired as the `Edit` control
42
- * for the `model` field of the layout settings DataForm.
43
- *
44
- * @param {DataFormControlProps< WidgetGridSettings >} props DataForm control props.
45
- */
46
- export function LayoutModelEditField( {
47
- data,
48
- field,
49
- onChange,
50
- }: DataFormControlProps< WidgetGridSettings > ): React.ReactNode {
51
- const { getValue, setValue, elements = [] } = field;
52
- const value = getValue( { item: data } );
53
- const disabled = field.isDisabled( { item: data, field } );
54
-
55
- const onSelect = useCallback(
56
- ( nextValue: string | number | undefined ) =>
57
- onChange( setValue( { item: data, value: nextValue } ) ),
58
- [ data, onChange, setValue ]
59
- );
60
-
61
- return (
62
- <Fieldset.Root>
63
- <Fieldset.Legend>{ field.label }</Fieldset.Legend>
64
- <Stack direction="row" gap="md" role="radiogroup">
65
- { elements.map( ( option ) => {
66
- const isSelected = value === option.value;
67
-
68
- return (
69
- <Button
70
- key={ String( option.value ) }
71
- variant="unstyled"
72
- role="radio"
73
- aria-checked={ isSelected }
74
- disabled={ disabled }
75
- className={ clsx( styles.option, {
76
- [ styles.optionSelected ]: isSelected,
77
- } ) }
78
- onClick={ () => onSelect( option.value ) }
79
- >
80
- <Stack direction="column" gap="sm" align="stretch">
81
- <ModelThumbnail
82
- model={ String( option.value ) }
83
- className={ styles.thumbnail }
84
- />
85
- <Text>{ option.label }</Text>
86
- </Stack>
87
- </Button>
88
- );
89
- } ) }
90
- </Stack>
91
- { typeof field.description === 'string' && (
92
- <Fieldset.Description>
93
- { field.description }
94
- </Fieldset.Description>
95
- ) }
96
- </Fieldset.Root>
97
- );
98
- }
@@ -1,34 +0,0 @@
1
- .option {
2
- flex: 1;
3
- padding: var(--wpds-dimension-padding-md);
4
- border: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral);
5
- border-radius: var(--wpds-border-radius-md);
6
- background: transparent;
7
- color: inherit;
8
- cursor: var(--wpds-cursor-control);
9
- text-align: center;
10
- transition:
11
- border-color var(--wpds-motion-duration-sm) var(--wpds-motion-easing-subtle),
12
- background-color var(--wpds-motion-duration-sm) var(--wpds-motion-easing-subtle);
13
- }
14
-
15
- .option:hover {
16
- border-color: var(--wpds-color-stroke-surface-neutral-strong);
17
- }
18
-
19
- .optionSelected,
20
- .optionSelected:hover {
21
- border-color: var(--wpds-color-stroke-interactive-brand);
22
- background-color: color-mix(in srgb, var(--wpds-color-background-surface-brand) 6%, transparent);
23
- }
24
-
25
- .thumbnail {
26
- display: block;
27
- inline-size: 100%;
28
- block-size: auto;
29
- color: var(--wpds-color-foreground-content-neutral-weak);
30
- }
31
-
32
- .optionSelected .thumbnail {
33
- color: var(--wpds-color-foreground-interactive-brand);
34
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { SVG, Rect } from '@wordpress/primitives';
5
-
6
- interface GridThumbnailProps {
7
- className?: string;
8
- }
9
-
10
- export function GridThumbnail( {
11
- className,
12
- }: GridThumbnailProps ): React.ReactNode {
13
- return (
14
- <SVG
15
- className={ className }
16
- viewBox="0 0 40 24"
17
- fill="currentColor"
18
- aria-hidden="true"
19
- >
20
- <Rect x="2" y="1.25" width="11" height="10" rx="1.5" />
21
- <Rect x="14.5" y="1.25" width="11" height="10" rx="1.5" />
22
- <Rect x="27" y="1.25" width="11" height="10" rx="1.5" />
23
- <Rect x="2" y="12.75" width="11" height="10" rx="1.5" />
24
- <Rect x="14.5" y="12.75" width="11" height="10" rx="1.5" />
25
- <Rect x="27" y="12.75" width="11" height="10" rx="1.5" />
26
- </SVG>
27
- );
28
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { SVG, Rect } from '@wordpress/primitives';
5
-
6
- interface MasonryThumbnailProps {
7
- className?: string;
8
- }
9
-
10
- export function MasonryThumbnail( {
11
- className,
12
- }: MasonryThumbnailProps ): React.ReactNode {
13
- return (
14
- <SVG
15
- className={ className }
16
- viewBox="0 0 40 24"
17
- fill="currentColor"
18
- aria-hidden="true"
19
- >
20
- <Rect x="2" y="0.75" width="11" height="13" rx="1.5" />
21
- <Rect x="2" y="15.25" width="11" height="8" rx="1.5" />
22
- <Rect x="14.5" y="0.75" width="11" height="8" rx="1.5" />
23
- <Rect x="14.5" y="10.25" width="11" height="13" rx="1.5" />
24
- <Rect x="27" y="0.75" width="11" height="10" rx="1.5" />
25
- <Rect x="27" y="12.25" width="11" height="11" rx="1.5" />
26
- </SVG>
27
- );
28
- }
@@ -1,217 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { DataForm } from '@wordpress/dataviews';
5
- import type { Field, Form } from '@wordpress/dataviews';
6
- import { useCallback, useEffect } from '@wordpress/element';
7
- import { __ } from '@wordpress/i18n';
8
- import { Button, Drawer } from '@wordpress/ui'; // eslint-disable-line @wordpress/use-recommended-components
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import { useDashboardInternalContext } from '../../context/dashboard-context';
14
- import { useDashboardUIContext } from '../../context/ui-context';
15
- import { migrateLayout } from '../../utils/migrate-layout';
16
- import {
17
- presetToRowHeight,
18
- rowHeightToPreset,
19
- type RowHeightPreset,
20
- } from '../../utils/row-height-presets';
21
- import {
22
- WIDGET_DASHBOARD_COLUMN_COUNT,
23
- type WidgetGridLayoutSettings,
24
- type WidgetGridModel,
25
- type WidgetGridSettings,
26
- } from '../../types';
27
- import { LayoutModelEditField } from './layout-model-edit-field';
28
-
29
- function getModel( item: WidgetGridSettings ): WidgetGridModel {
30
- return item.model ?? 'grid';
31
- }
32
-
33
- function isMasonry( item: WidgetGridSettings ): boolean {
34
- return getModel( item ) === 'masonry';
35
- }
36
-
37
- const fields: Field< WidgetGridSettings >[] = [
38
- {
39
- id: 'model',
40
- type: 'text',
41
- Edit: LayoutModelEditField,
42
- label: __( 'Layout model' ),
43
- description: __(
44
- 'Grid keeps every tile the same height. Masonry lets tiles flow at their own height.'
45
- ),
46
- elements: [
47
- { value: 'grid', label: __( 'Standard grid' ) },
48
- { value: 'masonry', label: __( 'Masonry' ) },
49
- ],
50
- getValue: ( { item } ) => getModel( item ),
51
- },
52
- {
53
- id: 'rowHeight',
54
- type: 'text',
55
- Edit: 'toggleGroup',
56
- label: __( 'Row height' ),
57
- description: __( 'Height of each grid row.' ),
58
- elements: [
59
- { value: 'small', label: __( 'Small' ) },
60
- { value: 'medium', label: __( 'Medium' ) },
61
- { value: 'large', label: __( 'Large' ) },
62
- ],
63
- getValue: ( { item } ) => {
64
- const rowHeight = ( item as WidgetGridLayoutSettings ).rowHeight;
65
- if ( typeof rowHeight !== 'number' ) {
66
- return 'medium';
67
- }
68
- return rowHeightToPreset( rowHeight );
69
- },
70
- setValue: ( { value } ) => ( {
71
- rowHeight: presetToRowHeight( value as RowHeightPreset ),
72
- } ),
73
- isVisible: ( item ) => ! isMasonry( item ),
74
- },
75
- ];
76
-
77
- const form: Form = {
78
- layout: { type: 'regular', labelPosition: 'top' },
79
- fields: [ 'model', 'rowHeight' ],
80
- };
81
-
82
- /**
83
- * Modal side drawer for grid-level settings (layout model and row height),
84
- * mounted by the engine and shown while `layoutSettingsOpen` is set in the
85
- * shared UI context. Renders nothing when grid settings are not editable.
86
- *
87
- * Edits, including Reset, apply to the staging copy and preview live behind
88
- * the drawer. Save commits them; Cancel and any other dismissal (X, Escape)
89
- * revert them. Either way only grid settings change, so in-progress widget
90
- * layout edits survive and customize mode stays active.
91
- *
92
- * Tile gap is deliberately not exposed; spacing stays a design-system concern.
93
- */
94
- export function LayoutSettings(): React.ReactNode {
95
- const {
96
- gridSettings,
97
- onGridSettingsChange,
98
- layout,
99
- onLayoutChange,
100
- commit,
101
- cancel: cancelStaging,
102
- resetGridSettings,
103
- hasUncommittedChanges,
104
- canEditGridSettings,
105
- editMode,
106
- } = useDashboardInternalContext();
107
-
108
- const { layoutSettingsOpen: open, setLayoutSettingsOpen: onOpenChange } =
109
- useDashboardUIContext();
110
-
111
- // Close when customize mode exits, whatever the exit path.
112
- useEffect( () => {
113
- if ( ! editMode && open ) {
114
- onOpenChange( false );
115
- }
116
- }, [ editMode, open, onOpenChange ] );
117
-
118
- const handleChange = useCallback(
119
- ( edits: Record< string, unknown > ) => {
120
- const nextModel = edits.model as WidgetGridModel | undefined;
121
- const currentModel = getModel( gridSettings );
122
-
123
- if ( nextModel && nextModel !== currentModel ) {
124
- const migrated = migrateLayout(
125
- layout,
126
- currentModel,
127
- nextModel,
128
- { columns: WIDGET_DASHBOARD_COLUMN_COUNT }
129
- );
130
- onLayoutChange( migrated );
131
- }
132
-
133
- onGridSettingsChange( {
134
- ...gridSettings,
135
- ...edits,
136
- } as WidgetGridSettings );
137
- },
138
- [ gridSettings, layout, onGridSettingsChange, onLayoutChange ]
139
- );
140
-
141
- const handleCancel = useCallback( () => {
142
- cancelStaging( { exitEditMode: false, revertLayout: false } );
143
- onOpenChange( false );
144
- }, [ cancelStaging, onOpenChange ] );
145
-
146
- const handleSave = useCallback( () => {
147
- commit( { exitEditMode: false } );
148
- onOpenChange( false );
149
- }, [ commit, onOpenChange ] );
150
-
151
- const handleOpenChange = useCallback(
152
- ( nextOpen: boolean ) => {
153
- if ( ! nextOpen && open ) {
154
- cancelStaging( { exitEditMode: false, revertLayout: false } );
155
- }
156
- onOpenChange( nextOpen );
157
- },
158
- [ open, cancelStaging, onOpenChange ]
159
- );
160
-
161
- if ( ! canEditGridSettings ) {
162
- return null;
163
- }
164
-
165
- return (
166
- <Drawer.Root
167
- open={ open }
168
- onOpenChange={ handleOpenChange }
169
- swipeDirection="right"
170
- >
171
- <Drawer.Popup size="medium" style={ { marginTop: '32px' } }>
172
- <Drawer.Header>
173
- <Drawer.Title>{ __( 'Layout settings' ) }</Drawer.Title>
174
- <Drawer.CloseIcon />
175
- </Drawer.Header>
176
-
177
- <Drawer.Content>
178
- <DataForm
179
- data={ gridSettings }
180
- fields={ fields }
181
- form={ form }
182
- onChange={ handleChange }
183
- />
184
- </Drawer.Content>
185
-
186
- <Drawer.Footer>
187
- <Button
188
- variant="minimal"
189
- tone="neutral"
190
- size="compact"
191
- onClick={ resetGridSettings }
192
- style={ { marginInlineEnd: 'auto' } }
193
- >
194
- { __( 'Reset' ) }
195
- </Button>
196
- <Button
197
- variant="minimal"
198
- tone="brand"
199
- size="compact"
200
- onClick={ handleCancel }
201
- >
202
- { __( 'Cancel' ) }
203
- </Button>
204
- <Button
205
- variant="solid"
206
- tone="brand"
207
- size="compact"
208
- onClick={ handleSave }
209
- disabled={ ! hasUncommittedChanges }
210
- >
211
- { __( 'Save' ) }
212
- </Button>
213
- </Drawer.Footer>
214
- </Drawer.Popup>
215
- </Drawer.Root>
216
- );
217
- }
@@ -1,11 +0,0 @@
1
- .preview {
2
- width: 125%;
3
- height: 125%;
4
- overflow: hidden;
5
- padding: 0;
6
- transform: scale(0.8);
7
- transform-origin: top left;
8
- /* Let clicks and hovers reach the picker tile, not links inside the preview. */
9
- pointer-events: none;
10
- user-select: none;
11
- }
@@ -1,30 +0,0 @@
1
- // cspell:ignore adminmenuback
2
- const ADMIN_MENU_ID = 'adminmenuback';
3
-
4
- /**
5
- * Width, in pixels, taken up by the WordPress admin menu
6
- * (`#adminmenuback`) on the inline-start edge of the viewport.
7
- *
8
- * The settings drawer portals to the document body and anchors to a
9
- * viewport edge, so a left-anchored drawer would slide over the fixed
10
- * admin menu. Offsetting the drawer by this value keeps the menu
11
- * uncovered (and reachable) instead of raising the drawer's z-index over
12
- * it.
13
- *
14
- * Defensive: returns `0` when the element is absent (outside wp-admin, or
15
- * in tests/Storybook), so the drawer just anchors to the viewport edge.
16
- *
17
- * @return {number} The admin menu's right edge in px, or `0`.
18
- */
19
- export function getAdminMenuInset(): number {
20
- if ( typeof document === 'undefined' ) {
21
- return 0;
22
- }
23
-
24
- const adminMenu = document.getElementById( ADMIN_MENU_ID );
25
- if ( ! adminMenu ) {
26
- return 0;
27
- }
28
-
29
- return Math.max( 0, adminMenu.getBoundingClientRect().right );
30
- }
@@ -1,25 +0,0 @@
1
- /* Translucent surface so the gear stays legible over any widget background. */
2
- .widgetSettingsToolbar {
3
- background: color-mix(in srgb, var(--wpds-color-background-surface-neutral) 40%, transparent);
4
- opacity: 0;
5
- pointer-events: none;
6
- }
7
-
8
- /*
9
- * Revealed on tile hover or focus. Hidden with opacity, not display, so the
10
- * gear stays in the tab order and `:focus-within` surfaces it for keyboard
11
- * users. The matched ancestor is the grid item, shared by the slot and card.
12
- */
13
- :global([data-wp-grid-item-key]):hover .widgetSettingsToolbar,
14
- :global([data-wp-grid-item-key]):focus-within .widgetSettingsToolbar {
15
- opacity: 1;
16
- pointer-events: auto;
17
- }
18
-
19
- @media not ( prefers-reduced-motion ) {
20
- .widgetSettingsToolbar {
21
- transition:
22
- opacity var(--wpds-motion-duration-sm)
23
- var(--wpds-motion-easing-subtle);
24
- }
25
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import type { WidgetType } from '@wordpress/widget-primitives';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import { WidgetToolbar } from '../widget-toolbar';
10
- import { WidgetSettingsTrigger } from './widget-settings-trigger';
11
- import styles from './widget-settings-toolbar.module.css';
12
- import type { DashboardWidget } from '../../types';
13
-
14
- export interface WidgetSettingsToolbarProps {
15
- /** The instance whose settings this toolbar configures. */
16
- widget: DashboardWidget< unknown >;
17
-
18
- /** The instance's widget type, for the trigger label and guard. */
19
- widgetType: WidgetType;
20
- }
21
-
22
- /**
23
- * Normal-mode per-tile toolbar: the gear that opens the settings drawer. Lives
24
- * in the grid's `actionableArea` slot, so it shows for every `presentation`.
25
- * Returns `null` when the type has no attributes.
26
- *
27
- * @param {WidgetSettingsToolbarProps} props Component props.
28
- */
29
- export function WidgetSettingsToolbar( {
30
- widget,
31
- widgetType,
32
- }: WidgetSettingsToolbarProps ): React.ReactNode {
33
- if ( ! widgetType.attributes?.length ) {
34
- return null;
35
- }
36
-
37
- return (
38
- <WidgetToolbar className={ styles.widgetSettingsToolbar }>
39
- <WidgetSettingsTrigger
40
- widget={ widget }
41
- widgetType={ widgetType }
42
- />
43
- </WidgetToolbar>
44
- );
45
- }
@@ -1,6 +0,0 @@
1
- /* Solid surface: shown for the whole customize session, not on hover. */
2
- .widgetLayoutToolbar {
3
- background: var(--wpds-color-background-surface-neutral-strong);
4
- border: 1px solid var(--wpds-color-stroke-surface-neutral-weak);
5
- box-shadow: var(--wpds-elevation-xs);
6
- }
@@ -1,53 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export { computeGridModelChange, getGridModel } from './grid-model-change';
@@ -1 +0,0 @@
1
- export { migrateLayout } from './migrate-layout';