@wordpress/widget-dashboard 0.1.1 → 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.
- package/CHANGELOG.md +32 -0
- package/README.md +29 -16
- package/build/components/actions/actions.cjs +6 -23
- package/build/components/actions/actions.cjs.map +3 -3
- package/build/components/commands/commands.cjs +1 -60
- package/build/components/commands/commands.cjs.map +2 -2
- package/build/{utils/grid-model-change → components/widget-attribute-controls}/index.cjs +7 -9
- package/build/components/widget-attribute-controls/index.cjs.map +7 -0
- package/build/components/widget-attribute-controls/widget-attribute-controls.cjs +93 -0
- package/build/components/widget-attribute-controls/widget-attribute-controls.cjs.map +7 -0
- package/build/components/widget-chrome/widget-chrome.cjs +28 -69
- package/build/components/widget-chrome/widget-chrome.cjs.map +2 -2
- package/build/components/{layout-settings → widget-frame}/index.cjs +9 -7
- package/build/components/widget-frame/index.cjs.map +7 -0
- package/build/components/widget-frame/widget-frame.cjs +193 -0
- package/build/components/widget-frame/widget-frame.cjs.map +7 -0
- package/build/{utils/migrate-layout → components/widget-header}/index.cjs +7 -7
- package/build/components/widget-header/index.cjs.map +7 -0
- package/build/components/widget-header/widget-header-infotip.cjs +166 -0
- package/build/components/widget-header/widget-header-infotip.cjs.map +7 -0
- package/build/components/widget-header/widget-header.cjs +176 -0
- package/build/components/widget-header/widget-header.cjs.map +7 -0
- package/build/components/{widget-settings/utils/get-admin-menu-inset.cjs → widget-layout-controls/index.cjs} +8 -18
- package/build/components/widget-layout-controls/index.cjs.map +7 -0
- package/build/components/{widgets/widget-layout-toolbar.cjs → widget-layout-controls/widget-layout-controls.cjs} +9 -100
- package/build/components/widget-layout-controls/widget-layout-controls.cjs.map +7 -0
- package/build/components/widget-picker/widget-picker.cjs +5 -93
- package/build/components/widget-picker/widget-picker.cjs.map +3 -3
- package/build/components/widget-preview-chrome/index.cjs +31 -0
- package/build/components/widget-preview-chrome/index.cjs.map +7 -0
- package/build/components/{widget-settings/widget-settings-toolbar.cjs → widget-preview-chrome/widget-preview-chrome.cjs} +41 -23
- package/build/components/widget-preview-chrome/widget-preview-chrome.cjs.map +7 -0
- package/build/components/widget-settings/index.cjs +3 -3
- package/build/components/widget-settings/index.cjs.map +1 -1
- package/build/components/widget-settings/utils/index.cjs +0 -3
- package/build/components/widget-settings/utils/index.cjs.map +2 -2
- package/build/components/widget-settings/widget-settings-trigger.cjs +22 -28
- package/build/components/widget-settings/widget-settings-trigger.cjs.map +2 -2
- package/build/components/widget-settings/widget-settings.cjs +40 -57
- package/build/components/widget-settings/widget-settings.cjs.map +2 -2
- package/build/components/widget-toolbar/widget-toolbar.cjs +7 -4
- package/build/components/widget-toolbar/widget-toolbar.cjs.map +2 -2
- package/build/components/widgets/widget-resize-handle.cjs +4 -4
- package/build/components/widgets/widget-resize-handle.cjs.map +2 -2
- package/build/components/widgets/widgets.cjs +18 -11
- package/build/components/widgets/widgets.cjs.map +2 -2
- package/build/context/dashboard-context.cjs +31 -80
- package/build/context/dashboard-context.cjs.map +2 -2
- package/build/context/ui-context.cjs +2 -18
- package/build/context/ui-context.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/index.cjs +2 -5
- package/build/utils/index.cjs.map +2 -2
- package/build/widget-dashboard.cjs +0 -4
- package/build/widget-dashboard.cjs.map +2 -2
- package/build-module/components/actions/actions.mjs +7 -24
- package/build-module/components/actions/actions.mjs.map +2 -2
- package/build-module/components/commands/commands.mjs +2 -67
- package/build-module/components/commands/commands.mjs.map +2 -2
- package/build-module/components/widget-attribute-controls/index.mjs +6 -0
- package/build-module/components/widget-attribute-controls/index.mjs.map +7 -0
- package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs +68 -0
- package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs.map +7 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs +29 -76
- package/build-module/components/widget-chrome/widget-chrome.mjs.map +2 -2
- package/build-module/components/widget-frame/index.mjs +7 -0
- package/build-module/components/widget-frame/index.mjs.map +7 -0
- package/build-module/components/widget-frame/widget-frame.mjs +157 -0
- package/build-module/components/widget-frame/widget-frame.mjs.map +7 -0
- package/build-module/components/widget-header/index.mjs +6 -0
- package/build-module/components/widget-header/index.mjs.map +7 -0
- package/build-module/components/widget-header/widget-header-infotip.mjs +141 -0
- package/build-module/components/widget-header/widget-header-infotip.mjs.map +7 -0
- package/build-module/components/widget-header/widget-header.mjs +141 -0
- package/build-module/components/widget-header/widget-header.mjs.map +7 -0
- package/build-module/components/widget-layout-controls/index.mjs +6 -0
- package/build-module/components/widget-layout-controls/index.mjs.map +7 -0
- package/build-module/components/widget-layout-controls/widget-layout-controls.mjs +90 -0
- package/build-module/components/widget-layout-controls/widget-layout-controls.mjs.map +7 -0
- package/build-module/components/widget-picker/widget-picker.mjs +6 -94
- package/build-module/components/widget-picker/widget-picker.mjs.map +3 -3
- package/build-module/components/widget-preview-chrome/index.mjs +6 -0
- package/build-module/components/widget-preview-chrome/index.mjs.map +7 -0
- package/build-module/components/{widget-settings/widget-settings-toolbar.mjs → widget-preview-chrome/widget-preview-chrome.mjs} +37 -19
- package/build-module/components/widget-preview-chrome/widget-preview-chrome.mjs.map +7 -0
- package/build-module/components/widget-settings/index.mjs +2 -2
- package/build-module/components/widget-settings/index.mjs.map +1 -1
- package/build-module/components/widget-settings/utils/index.mjs +0 -2
- package/build-module/components/widget-settings/utils/index.mjs.map +2 -2
- package/build-module/components/widget-settings/widget-settings-trigger.mjs +23 -29
- package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +2 -2
- package/build-module/components/widget-settings/widget-settings.mjs +40 -57
- package/build-module/components/widget-settings/widget-settings.mjs.map +2 -2
- package/build-module/components/widget-toolbar/widget-toolbar.mjs +7 -4
- package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +2 -2
- package/build-module/components/widgets/widget-resize-handle.mjs +4 -4
- package/build-module/components/widgets/widget-resize-handle.mjs.map +2 -2
- package/build-module/components/widgets/widgets.mjs +18 -11
- package/build-module/components/widgets/widgets.mjs.map +2 -2
- package/build-module/context/dashboard-context.mjs +31 -80
- package/build-module/context/dashboard-context.mjs.map +2 -2
- package/build-module/context/ui-context.mjs +2 -18
- package/build-module/context/ui-context.mjs.map +2 -2
- package/build-module/types.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -3
- package/build-module/utils/index.mjs.map +2 -2
- package/build-module/widget-dashboard.mjs +0 -4
- package/build-module/widget-dashboard.mjs.map +2 -2
- package/build-types/components/actions/actions.d.ts.map +1 -1
- package/build-types/components/commands/commands.d.ts.map +1 -1
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts +1 -1
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -1
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts +1 -1
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -1
- package/build-types/components/widget-attribute-controls/index.d.ts +2 -0
- package/build-types/components/widget-attribute-controls/index.d.ts.map +1 -0
- package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts +23 -0
- package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts.map +1 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts +8 -8
- package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -1
- package/build-types/components/widget-frame/index.d.ts +3 -0
- package/build-types/components/widget-frame/index.d.ts.map +1 -0
- package/build-types/components/widget-frame/widget-frame.d.ts +25 -0
- package/build-types/components/widget-frame/widget-frame.d.ts.map +1 -0
- package/build-types/components/widget-header/index.d.ts +3 -0
- package/build-types/components/widget-header/index.d.ts.map +1 -0
- package/build-types/components/widget-header/widget-header-infotip.d.ts +20 -0
- package/build-types/components/widget-header/widget-header-infotip.d.ts.map +1 -0
- package/build-types/components/widget-header/widget-header.d.ts +38 -0
- package/build-types/components/widget-header/widget-header.d.ts.map +1 -0
- package/build-types/components/widget-layout-controls/index.d.ts +3 -0
- package/build-types/components/widget-layout-controls/index.d.ts.map +1 -0
- package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts +14 -0
- package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts.map +1 -0
- package/build-types/components/widget-picker/widget-picker.d.ts +1 -1
- package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -1
- package/build-types/components/widget-preview-chrome/index.d.ts +3 -0
- package/build-types/components/widget-preview-chrome/index.d.ts.map +1 -0
- package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts +15 -0
- package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts.map +1 -0
- package/build-types/components/widget-settings/index.d.ts +2 -2
- package/build-types/components/widget-settings/utils/index.d.ts +0 -1
- package/build-types/components/widget-settings/utils/index.d.ts.map +1 -1
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts +7 -5
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -1
- package/build-types/components/widget-settings/widget-settings.d.ts +5 -4
- package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -1
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts +10 -7
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -1
- package/build-types/components/widgets/widgets.d.ts.map +1 -1
- package/build-types/context/dashboard-context.d.ts +23 -40
- package/build-types/context/dashboard-context.d.ts.map +1 -1
- package/build-types/context/ui-context.d.ts +0 -18
- package/build-types/context/ui-context.d.ts.map +1 -1
- package/build-types/context/widget-context.d.ts +1 -1
- package/build-types/context/widget-context.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -15
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +0 -1
- package/build-types/utils/index.d.ts.map +1 -1
- package/build-types/widget-dashboard.d.ts +5 -5
- package/build-types/widget-dashboard.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/components/actions/actions.module.css +7 -7
- package/src/components/actions/actions.tsx +5 -25
- package/src/components/commands/commands.tsx +3 -70
- package/src/components/widget-attribute-controls/index.ts +1 -0
- package/src/components/widget-attribute-controls/widget-attribute-controls.tsx +108 -0
- package/src/components/widget-chrome/widget-chrome.module.css +6 -71
- package/src/components/widget-chrome/widget-chrome.tsx +31 -136
- package/src/components/widget-frame/index.ts +2 -0
- package/src/components/widget-frame/widget-frame.module.css +17 -0
- package/src/components/widget-frame/widget-frame.tsx +138 -0
- package/src/components/widget-header/index.ts +2 -0
- package/src/components/widget-header/widget-header-infotip.tsx +82 -0
- package/src/components/widget-header/widget-header.module.css +59 -0
- package/src/components/widget-header/widget-header.tsx +104 -0
- package/src/components/widget-layout-controls/index.ts +2 -0
- package/src/components/{widgets/widget-layout-toolbar.tsx → widget-layout-controls/widget-layout-controls.tsx} +12 -13
- package/src/components/widget-picker/widget-picker.tsx +5 -10
- package/src/components/widget-preview-chrome/index.ts +2 -0
- package/src/components/widget-preview-chrome/widget-preview-chrome.module.css +22 -0
- package/src/components/widget-preview-chrome/widget-preview-chrome.tsx +65 -0
- package/src/components/widget-settings/index.ts +2 -2
- package/src/components/widget-settings/utils/index.ts +0 -1
- package/src/components/widget-settings/widget-settings-trigger.tsx +39 -44
- package/src/components/widget-settings/widget-settings.tsx +10 -28
- package/src/components/widget-toolbar/widget-toolbar.module.css +13 -10
- package/src/components/widget-toolbar/widget-toolbar.tsx +14 -8
- package/src/components/widgets/widget-resize-handle.module.css +21 -21
- package/src/components/widgets/widget-resize-handle.tsx +2 -2
- package/src/components/widgets/widgets.module.css +20 -11
- package/src/components/widgets/widgets.tsx +33 -10
- package/src/context/dashboard-context.tsx +70 -133
- package/src/context/ui-context.tsx +1 -39
- package/src/test/actions.test.tsx +7 -77
- package/src/test/commands.test.tsx +6 -45
- package/src/test/staging.test.tsx +82 -144
- package/src/test/widget-dashboard.test.tsx +24 -0
- package/src/types.ts +9 -16
- package/src/utils/index.ts +0 -1
- package/src/widget-dashboard.tsx +4 -8
- package/build/components/layout-settings/index.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/index.cjs +0 -186
- package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +0 -53
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +0 -53
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +0 -7
- package/build/components/layout-settings/layout-settings.cjs +0 -207
- package/build/components/layout-settings/layout-settings.cjs.map +0 -7
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +0 -7
- package/build/components/widget-settings/widget-settings-toolbar.cjs.map +0 -7
- package/build/components/widgets/widget-layout-toolbar.cjs.map +0 -7
- package/build/utils/grid-model-change/grid-model-change.cjs +0 -56
- package/build/utils/grid-model-change/grid-model-change.cjs.map +0 -7
- package/build/utils/grid-model-change/index.cjs.map +0 -7
- package/build/utils/migrate-layout/index.cjs.map +0 -7
- package/build/utils/migrate-layout/migrate-layout.cjs +0 -94
- package/build/utils/migrate-layout/migrate-layout.cjs.map +0 -7
- package/build-module/components/layout-settings/index.mjs +0 -6
- package/build-module/components/layout-settings/index.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +0 -151
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +0 -28
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +0 -28
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-settings.mjs +0 -187
- package/build-module/components/layout-settings/layout-settings.mjs.map +0 -7
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +0 -16
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +0 -7
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +0 -7
- package/build-module/components/widgets/widget-layout-toolbar.mjs +0 -181
- package/build-module/components/widgets/widget-layout-toolbar.mjs.map +0 -7
- package/build-module/utils/grid-model-change/grid-model-change.mjs +0 -30
- package/build-module/utils/grid-model-change/grid-model-change.mjs.map +0 -7
- package/build-module/utils/grid-model-change/index.mjs +0 -7
- package/build-module/utils/grid-model-change/index.mjs.map +0 -7
- package/build-module/utils/migrate-layout/index.mjs +0 -6
- package/build-module/utils/migrate-layout/index.mjs.map +0 -7
- package/build-module/utils/migrate-layout/migrate-layout.mjs +0 -69
- package/build-module/utils/migrate-layout/migrate-layout.mjs.map +0 -7
- package/build-types/components/layout-settings/index.d.ts +0 -2
- package/build-types/components/layout-settings/index.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +0 -17
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +0 -6
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +0 -6
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-settings.d.ts +0 -14
- package/build-types/components/layout-settings/layout-settings.d.ts.map +0 -1
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +0 -17
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +0 -1
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +0 -20
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +0 -1
- package/build-types/components/widgets/widget-layout-toolbar.d.ts +0 -14
- package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +0 -1
- package/build-types/utils/grid-model-change/grid-model-change.d.ts +0 -20
- package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +0 -1
- package/build-types/utils/grid-model-change/index.d.ts +0 -2
- package/build-types/utils/grid-model-change/index.d.ts.map +0 -1
- package/build-types/utils/migrate-layout/index.d.ts +0 -2
- package/build-types/utils/migrate-layout/index.d.ts.map +0 -1
- package/build-types/utils/migrate-layout/migrate-layout.d.ts +0 -36
- package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +0 -1
- package/src/components/layout-settings/index.ts +0 -1
- package/src/components/layout-settings/layout-model-edit-field/index.tsx +0 -98
- package/src/components/layout-settings/layout-model-edit-field/style.module.css +0 -34
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +0 -28
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +0 -28
- package/src/components/layout-settings/layout-settings.tsx +0 -217
- package/src/components/widget-picker/widget-picker.module.css +0 -11
- package/src/components/widget-settings/utils/get-admin-menu-inset.ts +0 -30
- package/src/components/widget-settings/widget-settings-toolbar.module.css +0 -25
- package/src/components/widget-settings/widget-settings-toolbar.tsx +0 -45
- package/src/components/widgets/widget-layout-toolbar.module.css +0 -6
- package/src/utils/grid-model-change/grid-model-change.ts +0 -53
- package/src/utils/grid-model-change/index.ts +0 -1
- package/src/utils/migrate-layout/index.ts +0 -1
- package/src/utils/migrate-layout/migrate-layout.ts +0 -156
- package/src/utils/migrate-layout/test/migrate-layout.test.ts +0 -114
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.3.0 (2026-07-14)
|
|
6
|
+
|
|
7
|
+
- Remove layout-settings editing: the customize-toolbar button, the
|
|
8
|
+
settings drawer, the layout-model switch commands, and the
|
|
9
|
+
`onGridSettingsChange` prop. `gridSettings` is now read-only rendering
|
|
10
|
+
configuration; the consumer owns the values and their persistence.
|
|
11
|
+
|
|
12
|
+
### New Features
|
|
13
|
+
|
|
14
|
+
- Widget toolbar: edit high-relevance widget attributes inline from the
|
|
15
|
+
tile toolbar.
|
|
16
|
+
|
|
17
|
+
### Enhancements
|
|
18
|
+
|
|
19
|
+
- Widen React peer dependency ranges to `^18 || ^19` to support both React 18 and React 19 environments ([#80024](https://github.com/WordPress/gutenberg/pull/80024)).
|
|
20
|
+
- Widget grid: reserve top paint space for outward tile focus rings so scroll
|
|
21
|
+
containers do not clip the widget chrome outline ([#79990](https://github.com/WordPress/gutenberg/pull/79990)).
|
|
22
|
+
|
|
23
|
+
### Internal
|
|
24
|
+
|
|
25
|
+
- Rename CSS Module class selectors to kebab-case and drop the package
|
|
26
|
+
suppressions from `stylelint-suppressions.json` ([#79990](https://github.com/WordPress/gutenberg/pull/79990)).
|
|
27
|
+
- `WidgetHeader`: surface the widget type's `help` note as an infotip
|
|
28
|
+
beside the title: a click-open popover with the note and its links.
|
|
29
|
+
- Widget inserter: render more accurate widget previews.
|
|
30
|
+
- Widget settings: anchor the settings drawer to the right edge and
|
|
31
|
+
toggle it from the gear button.
|
|
32
|
+
- Restructure the tile chrome: extract `WidgetHeader` and `WidgetFrame`,
|
|
33
|
+
and move widget and layout controls into toolbar chips.
|
|
34
|
+
|
|
35
|
+
## 0.2.0 (2026-07-01)
|
|
36
|
+
|
|
5
37
|
## 0.1.0 (2026-06-24)
|
|
6
38
|
|
|
7
39
|
### New Features
|
package/README.md
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
This package is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes. While it is published as 0.x, breaking changes may ship in minor releases.
|
|
5
5
|
|
|
6
6
|
This prerelease depends on WordPress core-private APIs and is built to run inside WordPress core. It is not yet safe to install and run as a standalone npm dependency from an external plugin.
|
|
7
|
+
|
|
7
8
|
</div>
|
|
8
9
|
|
|
9
|
-
Stateless rendering engine for widget dashboards. `WidgetDashboard` renders an editable grid of widget instances behind a consumer-controlled edit mode: drag-to-reorder, resize, a modal inserter, per-widget
|
|
10
|
+
Stateless rendering engine for widget dashboards. `WidgetDashboard` renders an editable grid of widget instances behind a consumer-controlled edit mode: drag-to-reorder, resize, a modal inserter, per-widget settings, and command-palette integration.
|
|
10
11
|
|
|
11
12
|
The engine owns no data. Widget types flow in through the `widgetTypes` prop (see [`@wordpress/widget-primitives`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/widget-primitives)), the consumer owns the committed `layout` array, and in-progress edits accumulate in an internal staging layer until the user commits them, at which point `onLayoutChange` fires with the updated array. Grid placement renders through [`@wordpress/grid`](https://github.com/WordPress/gutenberg/tree/HEAD/packages/grid).
|
|
12
13
|
|
|
@@ -79,7 +80,7 @@ function Dashboard() {
|
|
|
79
80
|
The dashboard is built from two kinds of parts:
|
|
80
81
|
|
|
81
82
|
- **Triggers and chrome you arrange.** `Actions`, `Widgets`, `WidgetChrome`, `NoWidgetsState`, and `Commands` are compound components; compose them as `children` to place them in your layout.
|
|
82
|
-
- **Overlays the engine mounts.** The widget inserter, the
|
|
83
|
+
- **Overlays the engine mounts.** The widget inserter, the per-widget settings editor, and the reset confirmation are mounted by the engine and driven by shared UI state. Triggers open them only through that state — the "Add widget" button and the command palette both open the inserter — so there is no overlay to place in the tree.
|
|
83
84
|
|
|
84
85
|
Omitting `children` renders the default arrangement. When you pass `children`, the overlays mount regardless of what you compose.
|
|
85
86
|
|
|
@@ -121,10 +122,6 @@ Optional. Maps a `WidgetType.renderModule` id to the React component that render
|
|
|
121
122
|
|
|
122
123
|
Optional. Grid model configuration; see [Grid settings](#grid-settings). Defaults to `DEFAULT_GRID`.
|
|
123
124
|
|
|
124
|
-
#### `onGridSettingsChange`: `( gridSettings: WidgetGridSettings ) => void`
|
|
125
|
-
|
|
126
|
-
Optional. Called when the user commits grid-settings edits. When omitted, the layout-settings entry points are hidden, since there is nowhere to persist the change.
|
|
127
|
-
|
|
128
125
|
#### `children`: `ReactNode`
|
|
129
126
|
|
|
130
127
|
Optional. Composition slot for the dashboard's triggers and chrome. When omitted, the engine renders the default arrangement: the empty state, the actions, the widgets grid, and the command palette integration. The engine-mounted overlays are present either way.
|
|
@@ -145,11 +142,11 @@ Renders its children only when `layout` is empty. Pair it with `<WidgetDashboard
|
|
|
145
142
|
|
|
146
143
|
#### `<WidgetDashboard.Actions />`
|
|
147
144
|
|
|
148
|
-
Edit-mode toggle: a "Customize" button while `editMode` is off, and "Add widget", "
|
|
145
|
+
Edit-mode toggle: a "Customize" button while `editMode` is off, and "Add widget", "Cancel", "Done" while it is on. The buttons and the more-actions menu are triggers: "Customize" and "Done" fire `onEditChange`, "Add widget" opens the inserter, and "Reset to default" opens the reset confirmation. Returns `null` when the dashboard is mounted without `onEditChange`, so surfaces that don't expose edit mode can keep `Actions` in their tree unconditionally.
|
|
149
146
|
|
|
150
147
|
#### `<WidgetDashboard.Commands />`
|
|
151
148
|
|
|
152
|
-
Command palette integration. It registers the dashboard's commands through `@wordpress/commands` (customize, add widgets,
|
|
149
|
+
Command palette integration. It registers the dashboard's commands through `@wordpress/commands` (customize, add widgets, reset to default) and sets the active command context. It renders nothing, and surfaces wherever the host application mounts the command palette. Ships in the default arrangement; when passing custom children, compose it to keep the integration.
|
|
153
150
|
|
|
154
151
|
`<Page>` from `@wordpress/admin-ui` exposes an `actions` slot used across admin screens (DataViews, WidgetDashboard, …). Plug `Actions` straight into it:
|
|
155
152
|
|
|
@@ -183,28 +180,44 @@ On confirmation, the inserter creates instances (using each type's `example.attr
|
|
|
183
180
|
|
|
184
181
|
## Grid settings
|
|
185
182
|
|
|
186
|
-
The dashboard supports two grid models, configured through the `gridSettings` prop: the 2D packed `grid` model, where tiles declare explicit spans over uniform rows, and the content-driven `masonry` model, where heights follow content and resize is horizontal-only. The
|
|
183
|
+
The dashboard supports two grid models, configured through the `gridSettings` prop: the 2D packed `grid` model, where tiles declare explicit spans over uniform rows, and the content-driven `masonry` model, where heights follow content and resize is horizontal-only. The settings are read-only for the dashboard: there is no in-dashboard editing UI. The consumer owns the values and their persistence.
|
|
187
184
|
|
|
188
|
-
The exported kit for
|
|
185
|
+
The exported kit for handling them:
|
|
189
186
|
|
|
190
187
|
- `WidgetGridSettings` — discriminated union of the per-model settings shapes.
|
|
191
188
|
- `DEFAULT_GRID` — canonical default settings, applied when `gridSettings` is omitted.
|
|
192
189
|
- `normalizeGridSettings( settings, defaultRowHeight )` — coerces legacy freeform row heights to the nearest preset. Run it over stored payloads before passing them in.
|
|
193
|
-
- `ROW_HEIGHT_PRESETS` / `DEFAULT_ROW_HEIGHT` — the row-height presets (`small`, `medium`, `large`)
|
|
190
|
+
- `ROW_HEIGHT_PRESETS` / `DEFAULT_ROW_HEIGHT` — the row-height presets (`small`, `medium`, `large`) that `rowHeight` values normalize to.
|
|
194
191
|
- `WIDGET_DASHBOARD_COLUMN_COUNT` — maximum column count on wide containers. The effective count steps down from container width; persisted `columns` values are ignored.
|
|
195
192
|
|
|
196
193
|
```tsx
|
|
197
|
-
const [ gridSettings, setGridSettings ] = useState( DEFAULT_GRID );
|
|
198
|
-
|
|
199
194
|
<WidgetDashboard
|
|
200
195
|
layout={ layout }
|
|
201
196
|
onLayoutChange={ setLayout }
|
|
202
197
|
widgetTypes={ widgetTypes }
|
|
203
|
-
gridSettings={
|
|
204
|
-
|
|
205
|
-
/>;
|
|
198
|
+
gridSettings={ { model: 'masonry' } }
|
|
199
|
+
/>
|
|
206
200
|
```
|
|
207
201
|
|
|
202
|
+
## How this host translates the contract
|
|
203
|
+
|
|
204
|
+
This engine is one host implementation of `@wordpress/widget-primitives`. It maps contract fields to host-owned UI as follows.
|
|
205
|
+
|
|
206
|
+
### Identity and help
|
|
207
|
+
|
|
208
|
+
When a widget type declares `help`, the tile chrome surfaces its `content` and optional `links` in a infotip beside the title.
|
|
209
|
+
|
|
210
|
+
### Attribute editing
|
|
211
|
+
|
|
212
|
+
Hosts build settings UI from the declarative `attributes` schema. This host splits editing across two surfaces:
|
|
213
|
+
|
|
214
|
+
- **Prominent surface**: fields marked `relevance: 'high'` render inline in the tile chrome, for quick in-context edits.
|
|
215
|
+
- **Settings surface**: the full schema is available through a dedicated settings UI. When some attributes are not promoted to the prominent surface, a settings entry point exposes the rest; fields already promoted may still appear there.
|
|
216
|
+
|
|
217
|
+
When every attribute is `'high'`, no separate settings entry point is shown. A second surface would only repeat what the prominent surface already exposes.
|
|
218
|
+
|
|
219
|
+
Edits on either surface stage through the engine's internal layer and reach `onLayoutChange` on commit.
|
|
220
|
+
|
|
208
221
|
## Authoring widgets
|
|
209
222
|
|
|
210
223
|
Widget render modules receive only what they need to render and edit:
|
|
@@ -117,9 +117,9 @@ function registerStyle(hash, css) {
|
|
|
117
117
|
|
|
118
118
|
// packages/widget-dashboard/src/components/actions/actions.module.css
|
|
119
119
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
120
|
-
registerStyle("
|
|
120
|
+
registerStyle("fb18de5324", "._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{align-items:center;display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}._815569a4ac9877f6__edit-actions-divider{align-self:center;background-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);flex-shrink:0;height:var(--wpds-dimension-size-2xs,16px);width:1px}@media not (prefers-reduced-motion){._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{will-change:opacity,transform}._4cb74a57d7aea824__edit-actions-enter{animation:_332d3153b716aa20__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}._852c67c33a5780a8__edit-actions-exit{animation:_4dff70702a4b0f40__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _332d3153b716aa20__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes _4dff70702a4b0f40__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}");
|
|
121
121
|
}
|
|
122
|
-
var actions_default = { "
|
|
122
|
+
var actions_default = { "edit-actions-enter": "_4cb74a57d7aea824__edit-actions-enter", "edit-actions-exit": "_852c67c33a5780a8__edit-actions-exit", "edit-actions-divider": "_815569a4ac9877f6__edit-actions-divider", "actions-slide-in": "_332d3153b716aa20__actions-slide-in", "actions-fold-out": "_4dff70702a4b0f40__actions-fold-out" };
|
|
123
123
|
|
|
124
124
|
// packages/widget-dashboard/src/components/actions/actions.tsx
|
|
125
125
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -130,8 +130,7 @@ function Actions() {
|
|
|
130
130
|
onLayoutReset,
|
|
131
131
|
commit,
|
|
132
132
|
cancel: cancelStaging,
|
|
133
|
-
hasUncommittedChanges
|
|
134
|
-
canEditGridSettings
|
|
133
|
+
hasUncommittedChanges
|
|
135
134
|
} = (0, import_dashboard_context.useDashboardInternalContext)();
|
|
136
135
|
const [isEditActionsMounted, setIsEditActionsMounted] = (0, import_element.useState)(editMode);
|
|
137
136
|
const [isExitingEditActions, setIsExitingEditActions] = (0, import_element.useState)(false);
|
|
@@ -151,7 +150,7 @@ function Actions() {
|
|
|
151
150
|
}, 220);
|
|
152
151
|
return () => clearTimeout(exitTimeout);
|
|
153
152
|
}, [editMode, isEditActionsMounted]);
|
|
154
|
-
const { setInserterOpen,
|
|
153
|
+
const { setInserterOpen, setResetDialogOpen } = (0, import_ui_context.useDashboardUIContext)();
|
|
155
154
|
const isMobileViewport = (0, import_data.useSelect)(
|
|
156
155
|
(select) => select(import_viewport.store).isViewportMatch("< small"),
|
|
157
156
|
[]
|
|
@@ -168,9 +167,6 @@ function Actions() {
|
|
|
168
167
|
const done = (0, import_element.useCallback)(() => {
|
|
169
168
|
commit();
|
|
170
169
|
}, [commit]);
|
|
171
|
-
const openLayoutSettings = (0, import_element.useCallback)(() => {
|
|
172
|
-
setLayoutSettingsOpen(true);
|
|
173
|
-
}, [setLayoutSettingsOpen]);
|
|
174
170
|
const menuItems = [
|
|
175
171
|
{
|
|
176
172
|
label: (0, import_i18n.__)("Reset to default"),
|
|
@@ -187,7 +183,7 @@ function Actions() {
|
|
|
187
183
|
{
|
|
188
184
|
direction: "row",
|
|
189
185
|
gap: "sm",
|
|
190
|
-
className: isExitingEditActions ? actions_default
|
|
186
|
+
className: isExitingEditActions ? actions_default["edit-actions-exit"] : actions_default["edit-actions-enter"],
|
|
191
187
|
children: [
|
|
192
188
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
193
189
|
import_ui.Button,
|
|
@@ -202,23 +198,10 @@ function Actions() {
|
|
|
202
198
|
]
|
|
203
199
|
}
|
|
204
200
|
),
|
|
205
|
-
canEditGridSettings && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
206
|
-
import_ui.Button,
|
|
207
|
-
{
|
|
208
|
-
variant: "minimal",
|
|
209
|
-
tone: "brand",
|
|
210
|
-
size: "compact",
|
|
211
|
-
onClick: openLayoutSettings,
|
|
212
|
-
children: [
|
|
213
|
-
!isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Button.Icon, { icon: import_icons.layout }),
|
|
214
|
-
(0, import_i18n.__)("Layout settings")
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
),
|
|
218
201
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
219
202
|
"div",
|
|
220
203
|
{
|
|
221
|
-
className: actions_default
|
|
204
|
+
className: actions_default["edit-actions-divider"],
|
|
222
205
|
"aria-hidden": "true"
|
|
223
206
|
}
|
|
224
207
|
),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/actions/actions.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/actions/actions.module.css"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { layout as layoutIcon, plus } from '@wordpress/icons';\nimport { store as viewportStore } from '@wordpress/viewport';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { ActionsMenu } from '../actions-menu';\nimport type { ActionsMenuItem } from '../actions-menu';\nimport styles from './actions.module.css';\n\n/**\n * Edit toolbar for the dashboard. In customize mode it surfaces Add widget,\n * Layout settings (when grid settings are editable), Cancel, and Done;\n * otherwise a single Customize button. Buttons and the overflow menu are\n * triggers that flip the shared UI state the overlays react to.\n *\n * Returns `null` when mounted without `onEditChange`, so hosts that don't\n * expose edit mode can keep `Actions` in their tree unconditionally.\n */\nexport function Actions(): React.ReactNode {\n\tconst {\n\t\teditMode,\n\t\tonEditChange,\n\t\tonLayoutReset,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t\tcanEditGridSettings,\n\t} = useDashboardInternalContext();\n\n\tconst [ isEditActionsMounted, setIsEditActionsMounted ] =\n\t\tuseState( editMode );\n\tconst [ isExitingEditActions, setIsExitingEditActions ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( editMode ) {\n\t\t\tsetIsEditActionsMounted( true );\n\t\t\tsetIsExitingEditActions( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isEditActionsMounted ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsExitingEditActions( true );\n\t\tconst exitTimeout = setTimeout( () => {\n\t\t\tsetIsEditActionsMounted( false );\n\t\t\tsetIsExitingEditActions( false );\n\t\t}, 220 );\n\n\t\treturn () => clearTimeout( exitTimeout );\n\t}, [ editMode, isEditActionsMounted ] );\n\n\tconst { setInserterOpen, setLayoutSettingsOpen, setResetDialogOpen } =\n\t\tuseDashboardUIContext();\n\t// @TODO: switch to using Admin UI declaratively for mobile viewport support once available.\n\t// https://github.com/WordPress/gutenberg/issues/77628\n\tconst isMobileViewport = useSelect(\n\t\t( select ) => select( viewportStore ).isViewportMatch( '< small' ),\n\t\t[]\n\t);\n\n\tconst handleEditMode = useCallback( () => {\n\t\tonEditChange?.( ! editMode );\n\t}, [ editMode, onEditChange ] );\n\n\tconst insert = useCallback( () => {\n\t\tsetInserterOpen( true );\n\t}, [ setInserterOpen ] );\n\n\tconst cancel = useCallback( () => {\n\t\tcancelStaging();\n\t}, [ cancelStaging ] );\n\n\tconst done = useCallback( () => {\n\t\tcommit();\n\t}, [ commit ] );\n\n\tconst openLayoutSettings = useCallback( () => {\n\t\tsetLayoutSettingsOpen( true );\n\t}, [ setLayoutSettingsOpen ] );\n\n\tconst menuItems: ActionsMenuItem[] = [\n\t\t{\n\t\t\tlabel: __( 'Reset to default' ),\n\t\t\tonClick: () => setResetDialogOpen( true ),\n\t\t\tdisabled: ! onLayoutReset,\n\t\t},\n\t];\n\n\tif ( ! onEditChange ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\">\n\t\t\t{ isEditActionsMounted ? (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisExitingEditActions\n\t\t\t\t\t\t\t? styles.editActionsExit\n\t\t\t\t\t\t\t: styles.editActionsEnter\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ insert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isMobileViewport && <Button.Icon icon={ plus } /> }\n\t\t\t\t\t\t{ __( 'Add widget' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t{ canEditGridSettings && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ openLayoutSettings }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<Button.Icon icon={ layoutIcon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ __( 'Layout settings' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ styles.editActionsDivider }\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ done }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Stack>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ handleEditMode }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Customize' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t<ActionsMenu items={ menuItems } />\n\t\t</Stack>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"207feb9ccc\", \"._273463df7651817f__editActionsEnter,._3cd6628039136a20__editActionsExit{align-items:center;display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}._572540719be6c8a3__editActionsDivider{align-self:center;background-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);flex-shrink:0;height:var(--wpds-dimension-size-2xs,16px);width:1px}@media not (prefers-reduced-motion){._273463df7651817f__editActionsEnter,._3cd6628039136a20__editActionsExit{will-change:opacity,transform}._273463df7651817f__editActionsEnter{animation:_332d3153b716aa20__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}._3cd6628039136a20__editActionsExit{animation:_4dff70702a4b0f40__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _332d3153b716aa20__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes _4dff70702a4b0f40__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}\");\n}\nexport default {\"editActionsEnter\":\"_273463df7651817f__editActionsEnter\",\"editActionsExit\":\"_3cd6628039136a20__editActionsExit\",\"editActionsDivider\":\"_572540719be6c8a3__editActionsDivider\",\"actions-slide-in\":\"_332d3153b716aa20__actions-slide-in\",\"actions-fold-out\":\"_4dff70702a4b0f40__actions-fold-out\"};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAiD;AACjD,kBAAmB;AACnB,
|
|
6
|
-
"names": ["viewportStore"
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { store as viewportStore } from '@wordpress/viewport';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { ActionsMenu } from '../actions-menu';\nimport type { ActionsMenuItem } from '../actions-menu';\nimport styles from './actions.module.css';\n\n/**\n * Edit toolbar for the dashboard. In customize mode it surfaces Add widget,\n * Layout settings (when grid settings are editable), Cancel, and Done;\n * otherwise a single Customize button. Buttons and the overflow menu are\n * triggers that flip the shared UI state the overlays react to.\n *\n * Returns `null` when mounted without `onEditChange`, so hosts that don't\n * expose edit mode can keep `Actions` in their tree unconditionally.\n */\nexport function Actions(): React.ReactNode {\n\tconst {\n\t\teditMode,\n\t\tonEditChange,\n\t\tonLayoutReset,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t} = useDashboardInternalContext();\n\n\tconst [ isEditActionsMounted, setIsEditActionsMounted ] =\n\t\tuseState( editMode );\n\tconst [ isExitingEditActions, setIsExitingEditActions ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( editMode ) {\n\t\t\tsetIsEditActionsMounted( true );\n\t\t\tsetIsExitingEditActions( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isEditActionsMounted ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsExitingEditActions( true );\n\t\tconst exitTimeout = setTimeout( () => {\n\t\t\tsetIsEditActionsMounted( false );\n\t\t\tsetIsExitingEditActions( false );\n\t\t}, 220 );\n\n\t\treturn () => clearTimeout( exitTimeout );\n\t}, [ editMode, isEditActionsMounted ] );\n\n\tconst { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();\n\t// @TODO: switch to using Admin UI declaratively for mobile viewport support once available.\n\t// https://github.com/WordPress/gutenberg/issues/77628\n\tconst isMobileViewport = useSelect(\n\t\t( select ) => select( viewportStore ).isViewportMatch( '< small' ),\n\t\t[]\n\t);\n\n\tconst handleEditMode = useCallback( () => {\n\t\tonEditChange?.( ! editMode );\n\t}, [ editMode, onEditChange ] );\n\n\tconst insert = useCallback( () => {\n\t\tsetInserterOpen( true );\n\t}, [ setInserterOpen ] );\n\n\tconst cancel = useCallback( () => {\n\t\tcancelStaging();\n\t}, [ cancelStaging ] );\n\n\tconst done = useCallback( () => {\n\t\tcommit();\n\t}, [ commit ] );\n\n\tconst menuItems: ActionsMenuItem[] = [\n\t\t{\n\t\t\tlabel: __( 'Reset to default' ),\n\t\t\tonClick: () => setResetDialogOpen( true ),\n\t\t\tdisabled: ! onLayoutReset,\n\t\t},\n\t];\n\n\tif ( ! onEditChange ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\">\n\t\t\t{ isEditActionsMounted ? (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisExitingEditActions\n\t\t\t\t\t\t\t? styles[ 'edit-actions-exit' ]\n\t\t\t\t\t\t\t: styles[ 'edit-actions-enter' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ insert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isMobileViewport && <Button.Icon icon={ plus } /> }\n\t\t\t\t\t\t{ __( 'Add widget' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ styles[ 'edit-actions-divider' ] }\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ done }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Stack>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ handleEditMode }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Customize' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t<ActionsMenu items={ menuItems } />\n\t\t</Stack>\n\t);\n}\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"fb18de5324\", \"._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{align-items:center;display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}._815569a4ac9877f6__edit-actions-divider{align-self:center;background-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);flex-shrink:0;height:var(--wpds-dimension-size-2xs,16px);width:1px}@media not (prefers-reduced-motion){._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{will-change:opacity,transform}._4cb74a57d7aea824__edit-actions-enter{animation:_332d3153b716aa20__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}._852c67c33a5780a8__edit-actions-exit{animation:_4dff70702a4b0f40__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _332d3153b716aa20__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes _4dff70702a4b0f40__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}\");\n}\nexport default {\"edit-actions-enter\":\"_4cb74a57d7aea824__edit-actions-enter\",\"edit-actions-exit\":\"_852c67c33a5780a8__edit-actions-exit\",\"edit-actions-divider\":\"_815569a4ac9877f6__edit-actions-divider\",\"actions-slide-in\":\"_332d3153b716aa20__actions-slide-in\",\"actions-fold-out\":\"_4dff70702a4b0f40__actions-fold-out\"};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA0B;AAC1B,qBAAiD;AACjD,kBAAmB;AACnB,mBAAqB;AACrB,sBAAuC;AAEvC,gBAA8B;AAK9B,+BAA4C;AAC5C,wBAAsC;AACtC,0BAA4B;;;ACN5B,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAU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AA,cACA,SAAQ;AAAA,cACR,MAAK;AAAA,cACL,MAAK;AAAA,cACL,SAAU;AAAA,cACV,UAAW,CAAE;AAAA,cAEX,8BAAI,MAAO;AAAA;AAAA,UACd;AAAA;AAAA;AAAA,IACD,IAEA;AAAA,MAAC;AAAA;AAAA,QACA,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,MAAK;AAAA,QACL,SAAU;AAAA,QAER,8BAAI,WAAY;AAAA;AAAA,IACnB;AAAA,IAGD,4CAAC,mCAAY,OAAQ,WAAY;AAAA,KAClC;AAEF;",
|
|
6
|
+
"names": ["viewportStore"]
|
|
7
7
|
}
|
|
@@ -31,42 +31,17 @@ var import_icons = require("@wordpress/icons");
|
|
|
31
31
|
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
32
32
|
var import_dashboard_context = require("../../context/dashboard-context.cjs");
|
|
33
33
|
var import_ui_context = require("../../context/ui-context.cjs");
|
|
34
|
-
var import_grid_model_change = require("../../utils/grid-model-change/index.cjs");
|
|
35
34
|
var import_use_pending_when_edit_mode = require("./use-pending-when-edit-mode.cjs");
|
|
36
35
|
var { useCommandContext } = (0, import_lock_unlock.unlock)(import_commands.privateApis);
|
|
37
36
|
var DASHBOARD_COMMAND_CONTEXT = "dashboard";
|
|
38
37
|
function Commands() {
|
|
39
|
-
const {
|
|
40
|
-
editMode,
|
|
41
|
-
onEditChange,
|
|
42
|
-
onLayoutReset,
|
|
43
|
-
gridSettings,
|
|
44
|
-
canEditGridSettings,
|
|
45
|
-
commitGridModelChange
|
|
46
|
-
} = (0, import_dashboard_context.useDashboardInternalContext)();
|
|
38
|
+
const { editMode, onEditChange, onLayoutReset } = (0, import_dashboard_context.useDashboardInternalContext)();
|
|
47
39
|
const { setInserterOpen, setResetDialogOpen } = (0, import_ui_context.useDashboardUIContext)();
|
|
48
40
|
useCommandContext(DASHBOARD_COMMAND_CONTEXT);
|
|
49
41
|
const runWhenInEditMode = (0, import_use_pending_when_edit_mode.usePendingWhenEditMode)({
|
|
50
42
|
editMode,
|
|
51
43
|
onEditChange
|
|
52
44
|
});
|
|
53
|
-
const gridModel = (0, import_grid_model_change.getGridModel)(gridSettings);
|
|
54
|
-
const isGridLayout = gridModel === "grid";
|
|
55
|
-
const isMasonryLayout = gridModel === "masonry";
|
|
56
|
-
const switchToMasonry = (0, import_element.useCallback)(
|
|
57
|
-
({ close }) => {
|
|
58
|
-
close();
|
|
59
|
-
commitGridModelChange("masonry");
|
|
60
|
-
},
|
|
61
|
-
[commitGridModelChange]
|
|
62
|
-
);
|
|
63
|
-
const switchToGrid = (0, import_element.useCallback)(
|
|
64
|
-
({ close }) => {
|
|
65
|
-
close();
|
|
66
|
-
commitGridModelChange("grid");
|
|
67
|
-
},
|
|
68
|
-
[commitGridModelChange]
|
|
69
|
-
);
|
|
70
45
|
const resetToDefault = (0, import_element.useCallback)(
|
|
71
46
|
({ close }) => {
|
|
72
47
|
close();
|
|
@@ -112,35 +87,6 @@ function Commands() {
|
|
|
112
87
|
disabled: !onEditChange,
|
|
113
88
|
callback: addWidgets
|
|
114
89
|
},
|
|
115
|
-
{
|
|
116
|
-
name: "core/dashboard/switch-to-masonry-layout",
|
|
117
|
-
label: (0, import_i18n.__)("Switch dashboard to masonry layout"),
|
|
118
|
-
icon: import_icons.columns,
|
|
119
|
-
category: "command",
|
|
120
|
-
context: DASHBOARD_COMMAND_CONTEXT,
|
|
121
|
-
keywords: [
|
|
122
|
-
(0, import_i18n.__)("layout"),
|
|
123
|
-
(0, import_i18n.__)("layout model"),
|
|
124
|
-
(0, import_i18n.__)("masonry")
|
|
125
|
-
],
|
|
126
|
-
disabled: !canEditGridSettings || isMasonryLayout || editMode,
|
|
127
|
-
callback: switchToMasonry
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: "core/dashboard/switch-to-grid-layout",
|
|
131
|
-
label: (0, import_i18n.__)("Switch dashboard to grid layout"),
|
|
132
|
-
icon: import_icons.grid,
|
|
133
|
-
category: "command",
|
|
134
|
-
context: DASHBOARD_COMMAND_CONTEXT,
|
|
135
|
-
keywords: [
|
|
136
|
-
(0, import_i18n.__)("layout"),
|
|
137
|
-
(0, import_i18n.__)("layout model"),
|
|
138
|
-
(0, import_i18n.__)("grid"),
|
|
139
|
-
(0, import_i18n.__)("standard grid")
|
|
140
|
-
],
|
|
141
|
-
disabled: !canEditGridSettings || isGridLayout || editMode,
|
|
142
|
-
callback: switchToGrid
|
|
143
|
-
},
|
|
144
90
|
{
|
|
145
91
|
name: "core/dashboard/reset-to-default",
|
|
146
92
|
label: (0, import_i18n.__)("Reset dashboard widgets to default"),
|
|
@@ -157,11 +103,6 @@ function Commands() {
|
|
|
157
103
|
editMode,
|
|
158
104
|
customize,
|
|
159
105
|
addWidgets,
|
|
160
|
-
canEditGridSettings,
|
|
161
|
-
isMasonryLayout,
|
|
162
|
-
isGridLayout,
|
|
163
|
-
switchToMasonry,
|
|
164
|
-
switchToGrid,
|
|
165
106
|
onLayoutReset,
|
|
166
107
|
resetToDefault
|
|
167
108
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/commands/commands.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseCommands,\n\tprivateApis as commandsPrivateApis,\n} from '@wordpress/commands';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AACrC,kBAAmB;AACnB,sBAGO;AACP,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseCommands,\n\tprivateApis as commandsPrivateApis,\n} from '@wordpress/commands';\nimport { layout as layoutIcon, plus, trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { usePendingWhenEditMode } from './use-pending-when-edit-mode';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n\nexport const DASHBOARD_COMMAND_CONTEXT = 'dashboard';\n\ntype CommandCallback = ( options: { close: () => void } ) => void;\n\n/**\n * Registers dashboard-specific command palette commands and sets the\n * active command context so they surface under Suggestions by default.\n */\nexport function Commands() {\n\tconst { editMode, onEditChange, onLayoutReset } =\n\t\tuseDashboardInternalContext();\n\n\tconst { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();\n\n\tuseCommandContext( DASHBOARD_COMMAND_CONTEXT );\n\n\tconst runWhenInEditMode = usePendingWhenEditMode( {\n\t\teditMode,\n\t\tonEditChange,\n\t} );\n\n\tconst resetToDefault = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\tsetResetDialogOpen( true );\n\t\t},\n\t\t[ setResetDialogOpen ]\n\t);\n\n\tconst addWidgets = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\trunWhenInEditMode( () => {\n\t\t\t\tsetInserterOpen( true );\n\t\t\t} );\n\t\t},\n\t\t[ runWhenInEditMode, setInserterOpen ]\n\t);\n\n\tconst customize = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\tonEditChange?.( true );\n\t\t},\n\t\t[ onEditChange ]\n\t);\n\n\tconst commands = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/customize',\n\t\t\t\tlabel: __( 'Customize dashboard' ),\n\t\t\t\ticon: layoutIcon,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'edit' ), __( 'widgets' ), __( 'layout' ) ],\n\t\t\t\tdisabled: ! onEditChange || editMode,\n\t\t\t\tcallback: customize,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/add-widgets',\n\t\t\t\tlabel: __( 'Add dashboard widgets' ),\n\t\t\t\ticon: plus,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'widgets' ), __( 'inserter' ) ],\n\t\t\t\tdisabled: ! onEditChange,\n\t\t\t\tcallback: addWidgets,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/reset-to-default',\n\t\t\t\tlabel: __( 'Reset dashboard widgets to default' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'reset' ), __( 'default' ) ],\n\t\t\t\tdisabled: ! onLayoutReset,\n\t\t\t\tcallback: resetToDefault,\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\tonEditChange,\n\t\t\teditMode,\n\t\t\tcustomize,\n\t\t\taddWidgets,\n\t\t\tonLayoutReset,\n\t\t\tresetToDefault,\n\t\t]\n\t);\n\n\tuseCommands( commands );\n\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAqC;AACrC,kBAAmB;AACnB,sBAGO;AACP,mBAAkD;AAKlD,yBAAuB;AACvB,+BAA4C;AAC5C,wBAAsC;AACtC,wCAAuC;AAEvC,IAAM,EAAE,kBAAkB,QAAI,2BAAQ,gBAAAA,WAAoB;AAEnD,IAAM,4BAA4B;AAQlC,SAAS,WAAW;AAC1B,QAAM,EAAE,UAAU,cAAc,cAAc,QAC7C,sDAA4B;AAE7B,QAAM,EAAE,iBAAiB,mBAAmB,QAAI,yCAAsB;AAEtE,oBAAmB,yBAA0B;AAE7C,QAAM,wBAAoB,0DAAwB;AAAA,IACjD;AAAA,IACA;AAAA,EACD,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ACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,mCAAa,QAAS;AAEtB,SAAO;AACR;",
|
|
6
6
|
"names": ["commandsPrivateApis", "layoutIcon"]
|
|
7
7
|
}
|
|
@@ -17,17 +17,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
|
-
// packages/widget-dashboard/src/
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
23
|
-
|
|
24
|
-
getGridModel: () => import_grid_model_change.getGridModel
|
|
20
|
+
// packages/widget-dashboard/src/components/widget-attribute-controls/index.ts
|
|
21
|
+
var widget_attribute_controls_exports = {};
|
|
22
|
+
__export(widget_attribute_controls_exports, {
|
|
23
|
+
WidgetAttributeControls: () => import_widget_attribute_controls.WidgetAttributeControls
|
|
25
24
|
});
|
|
26
|
-
module.exports = __toCommonJS(
|
|
27
|
-
var
|
|
25
|
+
module.exports = __toCommonJS(widget_attribute_controls_exports);
|
|
26
|
+
var import_widget_attribute_controls = require("./widget-attribute-controls.cjs");
|
|
28
27
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
28
|
0 && (module.exports = {
|
|
30
|
-
|
|
31
|
-
getGridModel
|
|
29
|
+
WidgetAttributeControls
|
|
32
30
|
});
|
|
33
31
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-attribute-controls/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { WidgetAttributeControls } from './widget-attribute-controls';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAwC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/widget-dashboard/src/components/widget-attribute-controls/widget-attribute-controls.tsx
|
|
21
|
+
var widget_attribute_controls_exports = {};
|
|
22
|
+
__export(widget_attribute_controls_exports, {
|
|
23
|
+
WidgetAttributeControls: () => WidgetAttributeControls
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(widget_attribute_controls_exports);
|
|
26
|
+
var import_dataviews = require("@wordpress/dataviews");
|
|
27
|
+
var import_element = require("@wordpress/element");
|
|
28
|
+
var import_dashboard_context = require("../../context/dashboard-context.cjs");
|
|
29
|
+
var import_widget_settings = require("../widget-settings/index.cjs");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function WidgetAttributeControls({
|
|
32
|
+
widget,
|
|
33
|
+
widgetType
|
|
34
|
+
}) {
|
|
35
|
+
const { layout, onLayoutChange, scheduleAutoSave } = (0, import_dashboard_context.useDashboardInternalContext)();
|
|
36
|
+
const fields = (0, import_element.useMemo)(
|
|
37
|
+
() => (widgetType.attributes ?? []).filter(
|
|
38
|
+
(attribute) => attribute.relevance === "high"
|
|
39
|
+
),
|
|
40
|
+
[widgetType.attributes]
|
|
41
|
+
);
|
|
42
|
+
const form = (0, import_element.useMemo)(
|
|
43
|
+
() => ({
|
|
44
|
+
layout: { type: "row", alignment: "center" },
|
|
45
|
+
fields: fields.map((field) => ({
|
|
46
|
+
id: field.id,
|
|
47
|
+
layout: { type: "regular", labelPosition: "none" }
|
|
48
|
+
}))
|
|
49
|
+
}),
|
|
50
|
+
[fields]
|
|
51
|
+
);
|
|
52
|
+
const handleChange = (0, import_element.useCallback)(
|
|
53
|
+
(edits) => {
|
|
54
|
+
onLayoutChange(
|
|
55
|
+
layout.map(
|
|
56
|
+
(instance) => instance.uuid === widget.uuid ? {
|
|
57
|
+
...instance,
|
|
58
|
+
attributes: {
|
|
59
|
+
...instance.attributes,
|
|
60
|
+
...edits
|
|
61
|
+
}
|
|
62
|
+
} : instance
|
|
63
|
+
)
|
|
64
|
+
);
|
|
65
|
+
scheduleAutoSave();
|
|
66
|
+
},
|
|
67
|
+
[layout, onLayoutChange, widget.uuid, scheduleAutoSave]
|
|
68
|
+
);
|
|
69
|
+
const data = widget.attributes ?? widgetType.example?.attributes ?? {};
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
71
|
+
fields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
|
+
import_dataviews.DataForm,
|
|
73
|
+
{
|
|
74
|
+
data,
|
|
75
|
+
fields,
|
|
76
|
+
form,
|
|
77
|
+
onChange: handleChange
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
81
|
+
import_widget_settings.WidgetSettingsTrigger,
|
|
82
|
+
{
|
|
83
|
+
widget,
|
|
84
|
+
widgetType
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] });
|
|
88
|
+
}
|
|
89
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
90
|
+
0 && (module.exports = {
|
|
91
|
+
WidgetAttributeControls
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=widget-attribute-controls.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-attribute-controls/widget-attribute-controls.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { WidgetSettingsTrigger } from '../widget-settings';\nimport type { DashboardWidget } from '../../types';\n\ntype WidgetAttributes = Record< string, unknown >;\n\ntype WidgetAttributeControlsProps = {\n\t/**\n\t * The instance whose attributes these controls edit.\n\t */\n\twidget: DashboardWidget< unknown >;\n\n\t/**\n\t * The instance's widget type, source of the attribute schema.\n\t */\n\twidgetType: WidgetType;\n};\n\n/**\n * Normal-mode controls: the `relevance: 'high'` attributes on a prominent\n * surface, plus a settings entry point when needed. Inline controls appear\n * only for the high-relevance fields; edits stage live and auto-save on the\n * dashboard's shared debounce.\n *\n * @param {WidgetAttributeControlsProps} props Component props.\n */\nexport function WidgetAttributeControls( {\n\twidget,\n\twidgetType,\n}: WidgetAttributeControlsProps ): React.ReactNode {\n\tconst { layout, onLayoutChange, scheduleAutoSave } =\n\t\tuseDashboardInternalContext();\n\n\tconst fields = useMemo< Field< WidgetAttributes >[] >(\n\t\t() =>\n\t\t\t( widgetType.attributes ?? [] ).filter(\n\t\t\t\t( attribute ) => attribute.relevance === 'high'\n\t\t\t) as Field< WidgetAttributes >[],\n\t\t[ widgetType.attributes ]\n\t);\n\n\t// A `row` top-level layout lays the controls out horizontally; each field\n\t// carries `labelPosition: 'none'` so the control renders bare.\n\tconst form = useMemo< Form >(\n\t\t() => ( {\n\t\t\tlayout: { type: 'row', alignment: 'center' },\n\t\t\tfields: fields.map( ( field ) => ( {\n\t\t\t\tid: field.id,\n\t\t\t\tlayout: { type: 'regular', labelPosition: 'none' },\n\t\t\t} ) ),\n\t\t} ),\n\t\t[ fields ]\n\t);\n\n\tconst handleChange = useCallback(\n\t\t( edits: Record< string, unknown > ) => {\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( instance ) =>\n\t\t\t\t\tinstance.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...instance,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( instance.attributes as object ),\n\t\t\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: instance\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tscheduleAutoSave();\n\t\t},\n\t\t[ layout, onLayoutChange, widget.uuid, scheduleAutoSave ]\n\t);\n\n\tconst data = ( widget.attributes ??\n\t\twidgetType.example?.attributes ??\n\t\t{} ) as WidgetAttributes;\n\n\treturn (\n\t\t<>\n\t\t\t{ fields.length > 0 && (\n\t\t\t\t<DataForm< WidgetAttributes >\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t<WidgetSettingsTrigger\n\t\t\t\twidget={ widget }\n\t\t\t\twidgetType={ widgetType }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAyB;AAEzB,qBAAqC;AAMrC,+BAA4C;AAC5C,6BAAsC;AA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