@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/widget-dashboard/src/context/dashboard-context.tsx
|
|
2
2
|
import fastDeepEqual from "fast-deep-equal/es6/index.js";
|
|
3
|
+
import { debounce, useEvent } from "@wordpress/compose";
|
|
3
4
|
import {
|
|
4
5
|
createContext,
|
|
5
6
|
useCallback,
|
|
@@ -9,7 +10,6 @@ import {
|
|
|
9
10
|
useState
|
|
10
11
|
} from "@wordpress/element";
|
|
11
12
|
import { DEFAULT_GRID } from "../utils/default-grid/index.mjs";
|
|
12
|
-
import { computeGridModelChange } from "../utils/grid-model-change/index.mjs";
|
|
13
13
|
import { normalizeGridSettings } from "../utils/normalize-grid-settings/index.mjs";
|
|
14
14
|
import { DEFAULT_ROW_HEIGHT } from "../utils/row-height-presets/index.mjs";
|
|
15
15
|
import { WIDGET_DASHBOARD_COLUMN_COUNT } from "../types.mjs";
|
|
@@ -25,6 +25,7 @@ var DEFAULT_RESOLVE_WIDGET_MODULE = (moduleId) => import(
|
|
|
25
25
|
/* webpackIgnore: true */
|
|
26
26
|
moduleId
|
|
27
27
|
);
|
|
28
|
+
var AUTO_SAVE_DELAY_MS = 5e3;
|
|
28
29
|
function canonicalize(layout) {
|
|
29
30
|
const indexed = layout.map((widget, index) => ({
|
|
30
31
|
widget,
|
|
@@ -59,21 +60,16 @@ function WidgetDashboardProvider({
|
|
|
59
60
|
onEditChange,
|
|
60
61
|
resolveWidgetModule = DEFAULT_RESOLVE_WIDGET_MODULE,
|
|
61
62
|
gridSettings: committedGridSettings = DEFAULT_GRID,
|
|
62
|
-
onGridSettingsChange,
|
|
63
63
|
children
|
|
64
64
|
}) {
|
|
65
65
|
const [stagingLayout, setStagingLayout] = useState(committedLayout);
|
|
66
66
|
useEffect(() => {
|
|
67
67
|
setStagingLayout(committedLayout);
|
|
68
68
|
}, [committedLayout]);
|
|
69
|
-
const
|
|
70
|
-
() =>
|
|
69
|
+
const gridSettings = useMemo(
|
|
70
|
+
() => resolveGridSettings(committedGridSettings),
|
|
71
|
+
[committedGridSettings]
|
|
71
72
|
);
|
|
72
|
-
useEffect(() => {
|
|
73
|
-
setStagingGridSettings(
|
|
74
|
-
normalizeGridSettings(committedGridSettings, DEFAULT_ROW_HEIGHT)
|
|
75
|
-
);
|
|
76
|
-
}, [committedGridSettings]);
|
|
77
73
|
const hasLayoutChanges = useMemo(
|
|
78
74
|
() => !fastDeepEqual(
|
|
79
75
|
canonicalize(committedLayout),
|
|
@@ -81,85 +77,43 @@ function WidgetDashboardProvider({
|
|
|
81
77
|
),
|
|
82
78
|
[committedLayout, stagingLayout]
|
|
83
79
|
);
|
|
84
|
-
const
|
|
85
|
-
() => !fastDeepEqual(committedGridSettings, stagingGridSettings),
|
|
86
|
-
[committedGridSettings, stagingGridSettings]
|
|
87
|
-
);
|
|
88
|
-
const hasUncommittedChanges = hasLayoutChanges || hasGridSettingsChanges;
|
|
80
|
+
const hasUncommittedChanges = hasLayoutChanges;
|
|
89
81
|
const commit = useCallback(
|
|
90
82
|
(options) => {
|
|
91
83
|
if (hasLayoutChanges) {
|
|
92
84
|
onLayoutChange(canonicalize(stagingLayout));
|
|
93
85
|
}
|
|
94
|
-
if (hasGridSettingsChanges) {
|
|
95
|
-
onGridSettingsChange?.(
|
|
96
|
-
normalizeGridSettings(
|
|
97
|
-
stagingGridSettings,
|
|
98
|
-
DEFAULT_ROW_HEIGHT
|
|
99
|
-
)
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
86
|
if (options?.exitEditMode !== false) {
|
|
103
87
|
onEditChange?.(false);
|
|
104
88
|
}
|
|
105
89
|
},
|
|
106
|
-
[
|
|
107
|
-
hasLayoutChanges,
|
|
108
|
-
hasGridSettingsChanges,
|
|
109
|
-
onLayoutChange,
|
|
110
|
-
onGridSettingsChange,
|
|
111
|
-
stagingLayout,
|
|
112
|
-
stagingGridSettings,
|
|
113
|
-
onEditChange
|
|
114
|
-
]
|
|
90
|
+
[hasLayoutChanges, onLayoutChange, stagingLayout, onEditChange]
|
|
115
91
|
);
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
setStagingGridSettings(committedGridSettings);
|
|
122
|
-
if (options?.exitEditMode !== false) {
|
|
123
|
-
onEditChange?.(false);
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
[committedLayout, committedGridSettings, onEditChange]
|
|
92
|
+
const publishAutoSave = useEvent(() => commit({ exitEditMode: false }));
|
|
93
|
+
const scheduleAutoSave = useMemo(
|
|
94
|
+
() => debounce(publishAutoSave, AUTO_SAVE_DELAY_MS),
|
|
95
|
+
[publishAutoSave]
|
|
127
96
|
);
|
|
128
|
-
const
|
|
129
|
-
(
|
|
130
|
-
|
|
131
|
-
layout: stagingLayout,
|
|
132
|
-
gridSettings: stagingGridSettings,
|
|
133
|
-
targetModel
|
|
134
|
-
});
|
|
135
|
-
if (!next) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
setStagingLayout(next.layout);
|
|
139
|
-
setStagingGridSettings(next.gridSettings);
|
|
140
|
-
onLayoutChange(canonicalize(next.layout));
|
|
141
|
-
onGridSettingsChange?.(
|
|
142
|
-
normalizeGridSettings(next.gridSettings, DEFAULT_ROW_HEIGHT)
|
|
143
|
-
);
|
|
144
|
-
onEditChange?.(false);
|
|
145
|
-
},
|
|
146
|
-
[
|
|
147
|
-
stagingLayout,
|
|
148
|
-
stagingGridSettings,
|
|
149
|
-
onLayoutChange,
|
|
150
|
-
onGridSettingsChange,
|
|
151
|
-
onEditChange
|
|
152
|
-
]
|
|
97
|
+
const flushAutoSave = useCallback(
|
|
98
|
+
() => scheduleAutoSave.flush(),
|
|
99
|
+
[scheduleAutoSave]
|
|
153
100
|
);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
if (!editMode) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
scheduleAutoSave.flush();
|
|
106
|
+
}, [editMode, scheduleAutoSave]);
|
|
107
|
+
useEffect(() => () => scheduleAutoSave.flush(), [scheduleAutoSave]);
|
|
108
|
+
const cancel = useCallback(() => {
|
|
109
|
+
setStagingLayout(committedLayout);
|
|
110
|
+
onEditChange?.(false);
|
|
111
|
+
}, [committedLayout, onEditChange]);
|
|
157
112
|
useEffect(() => {
|
|
158
113
|
if (stagingLayout.length === 0) {
|
|
159
114
|
onEditChange?.(true);
|
|
160
115
|
}
|
|
161
116
|
}, [stagingLayout.length === 0]);
|
|
162
|
-
const canEditGridSettings = onGridSettingsChange !== void 0;
|
|
163
117
|
const value = useMemo(
|
|
164
118
|
() => ({
|
|
165
119
|
widgetTypes,
|
|
@@ -167,13 +121,11 @@ function WidgetDashboardProvider({
|
|
|
167
121
|
layout: stagingLayout,
|
|
168
122
|
onLayoutChange: setStagingLayout,
|
|
169
123
|
onLayoutReset,
|
|
170
|
-
gridSettings
|
|
171
|
-
onGridSettingsChange: setStagingGridSettings,
|
|
172
|
-
canEditGridSettings,
|
|
173
|
-
resetGridSettings,
|
|
124
|
+
gridSettings,
|
|
174
125
|
commit,
|
|
175
|
-
commitGridModelChange,
|
|
176
126
|
cancel,
|
|
127
|
+
scheduleAutoSave,
|
|
128
|
+
flushAutoSave,
|
|
177
129
|
hasUncommittedChanges,
|
|
178
130
|
editMode,
|
|
179
131
|
onEditChange,
|
|
@@ -184,12 +136,11 @@ function WidgetDashboardProvider({
|
|
|
184
136
|
isResolvingWidgetTypes,
|
|
185
137
|
stagingLayout,
|
|
186
138
|
onLayoutReset,
|
|
187
|
-
|
|
188
|
-
canEditGridSettings,
|
|
189
|
-
resetGridSettings,
|
|
139
|
+
gridSettings,
|
|
190
140
|
commit,
|
|
191
|
-
commitGridModelChange,
|
|
192
141
|
cancel,
|
|
142
|
+
scheduleAutoSave,
|
|
143
|
+
flushAutoSave,
|
|
193
144
|
hasUncommittedChanges,
|
|
194
145
|
editMode,
|
|
195
146
|
onEditChange,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/context/dashboard-context.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport type {\n\tResolveWidgetModule,\n\tWidgetType,\n} from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_GRID } from '../utils/default-grid';\nimport { computeGridModelChange } from '../utils/grid-model-change';\nimport { normalizeGridSettings } from '../utils/normalize-grid-settings';\nimport { DEFAULT_ROW_HEIGHT } from '../utils/row-height-presets';\nimport type {\n\tWidgetGridModel,\n\tWidgetGridSettings,\n\tDashboardWidget,\n} from '../types';\nimport { WIDGET_DASHBOARD_COLUMN_COUNT } from '../types';\n\ntype GridSettingsWithColumns = WidgetGridSettings & { columns: number };\n\nfunction resolveGridSettings(\n\tsettings: WidgetGridSettings\n): GridSettingsWithColumns {\n\tconst normalized = normalizeGridSettings( settings, DEFAULT_ROW_HEIGHT );\n\treturn {\n\t\t...normalized,\n\t\tcolumns: WIDGET_DASHBOARD_COLUMN_COUNT,\n\t};\n}\n\nconst DEFAULT_RESOLVE_WIDGET_MODULE: ResolveWidgetModule = ( moduleId ) =>\n\timport( /* webpackIgnore: true */ moduleId );\n\n/**\n * Canonical form of `layout`: widgets sorted by `placement.order` (falling\n * back to array index), then `order` stripped since position now implies it.\n * Used both as the comparison form for `hasUncommittedChanges` (so a change\n * and its undo compare equal) and as the publish form, keeping persisted\n * payloads free of redundant `order` fields.\n *\n * @param {DashboardWidget[]} layout Layout to canonicalize.\n * @return {DashboardWidget[]} Canonicalized layout.\n */\nfunction canonicalize( layout: DashboardWidget[] ): DashboardWidget[] {\n\tconst indexed = layout.map( ( widget, index ) => ( {\n\t\twidget,\n\t\torder: widget.placement?.order ?? index,\n\t} ) );\n\n\tindexed.sort( ( a, b ) => a.order - b.order );\n\n\treturn indexed.map( ( { widget } ) => {\n\t\tif ( ! widget.placement ) {\n\t\t\treturn widget;\n\t\t}\n\t\tconst { order: _stripped, ...placement } = widget.placement;\n\t\treturn { ...widget, placement };\n\t} );\n}\n\n/**\n * Rich state distributed to every compound component inside `WidgetDashboard`.\n * Internal — compounds reach the full state via `useDashboardInternalContext()`.\n *\n * `layout`/`onLayoutChange` and `gridSettings`/`onGridSettingsChange` here\n * operate on the staging layer, not the committed props. Mutations from\n * compound children stay in staging until `commit` publishes them on the\n * consumer.\n */\ninterface InternalDashboardContextValue {\n\twidgetTypes: WidgetType[];\n\tisResolvingWidgetTypes: boolean;\n\tlayout: DashboardWidget[];\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\tonLayoutReset?: () => void;\n\tgridSettings: GridSettingsWithColumns;\n\tonGridSettingsChange: ( gridSettings: WidgetGridSettings ) => void;\n\tcanEditGridSettings: boolean;\n\n\t/**\n\t * Restores the staging copy of `gridSettings` to the package's\n\t * built-in defaults. Does not touch the committed slice; the user\n\t * must `commit` to publish the reset, or `cancel` to discard it.\n\t */\n\tresetGridSettings: () => void;\n\n\t/**\n\t * Publishes staged slices that differ from their committed\n\t * counterparts. By default also exits edit mode; pass\n\t * `{ exitEditMode: false }` when committing from the layout\n\t * settings drawer so customize mode stays active.\n\t */\n\tcommit: ( options?: CommitOptions ) => void;\n\n\t/**\n\t * Switches the layout model, updates staging, and publishes\n\t * immediately — equivalent to changing the model in layout\n\t * settings and clicking Save.\n\t */\n\tcommitGridModelChange: ( targetModel: WidgetGridModel ) => void;\n\n\t/**\n\t * Reverts staging slices. By default reverts both layout and grid\n\t * settings and exits edit mode. Pass `{ exitEditMode: false }` when\n\t * dismissing the layout settings drawer. Pass `{ revertLayout: false }`\n\t * to revert only grid settings (preserves in-progress widget layout\n\t * edits while customize mode is active).\n\t */\n\tcancel: ( options?: CancelOptions ) => void;\n\n\thasUncommittedChanges: boolean;\n\teditMode: boolean;\n\tonEditChange?: ( next: boolean ) => void;\n\tresolveWidgetModule: ResolveWidgetModule;\n}\n\ninterface CommitOptions {\n\texitEditMode?: boolean;\n}\n\ninterface CancelOptions {\n\texitEditMode?: boolean;\n\trevertLayout?: boolean;\n}\n\nconst Context = createContext< InternalDashboardContextValue | null >( null );\n\n/**\n * Compound-internal hook — exposes the full provider state.\n * Not part of the public API; lives in the same module\n * so compound components can reach the state directly.\n */\nexport function useDashboardInternalContext(): InternalDashboardContextValue {\n\tconst ctx = useContext( Context );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Dashboard compound used outside a WidgetDashboard subtree.'\n\t\t);\n\t}\n\treturn ctx;\n}\n\ninterface ProviderProps {\n\twidgetTypes: WidgetType[];\n\tisResolvingWidgetTypes?: boolean;\n\tlayout: DashboardWidget[];\n\n\t/**\n\t * Fired on commit when the staged layout differs from `layout`.\n\t */\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\n\t/**\n\t * Optional reset action surfaced by the bundled `Actions`.\n\t */\n\tonLayoutReset?: () => void;\n\n\teditMode?: boolean;\n\tonEditChange?: ( next: boolean ) => void;\n\n\t/**\n\t * Overrides the default `import()` resolution of\n\t * `WidgetType.renderModule`.\n\t */\n\tresolveWidgetModule?: ResolveWidgetModule;\n\n\tgridSettings?: WidgetGridSettings;\n\n\t/**\n\t * Fired on commit when the staged settings differ from\n\t * `gridSettings`.\n\t */\n\tonGridSettingsChange?: ( gridSettings: WidgetGridSettings ) => void;\n\n\tchildren: ReactNode;\n}\n\n/**\n * Provider for the dashboard's staging layer. Owns staging copies of\n * `layout` and `gridSettings`; `commit` publishes whichever slice\n * differs from its committed prop, `cancel` reverts both.\n *\n * Staging re-syncs from the committed props on prop change. In-flight\n * edits are dropped silently when an external update (cross-tab commit,\n * reset, websocket push) lands. Consumers that cannot tolerate this\n * loss should mediate the prop updates before forwarding them here.\n *\n * @param {ProviderProps} props Component props.\n */\nexport function WidgetDashboardProvider( {\n\twidgetTypes,\n\tisResolvingWidgetTypes = false,\n\tlayout: committedLayout,\n\tonLayoutChange,\n\tonLayoutReset,\n\teditMode = false,\n\tonEditChange,\n\tresolveWidgetModule = DEFAULT_RESOLVE_WIDGET_MODULE,\n\tgridSettings: committedGridSettings = DEFAULT_GRID,\n\tonGridSettingsChange,\n\tchildren,\n}: ProviderProps ): React.ReactNode {\n\tconst [ stagingLayout, setStagingLayout ] =\n\t\tuseState< DashboardWidget[] >( committedLayout );\n\n\t// External change in `layout` (consumer-side reset, cross-tab sync,\n\t// websocket push, etc.) drops any in-flight staging edits without\n\t// surfacing a warning. See the provider JSDoc for the trade-off.\n\tuseEffect( () => {\n\t\tsetStagingLayout( committedLayout );\n\t}, [ committedLayout ] );\n\n\tconst [ stagingGridSettings, setStagingGridSettings ] =\n\t\tuseState< WidgetGridSettings >( () =>\n\t\t\tnormalizeGridSettings( committedGridSettings, DEFAULT_ROW_HEIGHT )\n\t\t);\n\n\t// Same external-resync semantics as `stagingLayout`.\n\tuseEffect( () => {\n\t\tsetStagingGridSettings(\n\t\t\tnormalizeGridSettings( committedGridSettings, DEFAULT_ROW_HEIGHT )\n\t\t);\n\t}, [ committedGridSettings ] );\n\n\tconst hasLayoutChanges = useMemo(\n\t\t() =>\n\t\t\t! fastDeepEqual(\n\t\t\t\tcanonicalize( committedLayout ),\n\t\t\t\tcanonicalize( stagingLayout )\n\t\t\t),\n\t\t[ committedLayout, stagingLayout ]\n\t);\n\n\tconst hasGridSettingsChanges = useMemo(\n\t\t() => ! fastDeepEqual( committedGridSettings, stagingGridSettings ),\n\t\t[ committedGridSettings, stagingGridSettings ]\n\t);\n\n\tconst hasUncommittedChanges = hasLayoutChanges || hasGridSettingsChanges;\n\n\tconst commit = useCallback(\n\t\t( options?: CommitOptions ) => {\n\t\t\tif ( hasLayoutChanges ) {\n\t\t\t\tonLayoutChange( canonicalize( stagingLayout ) );\n\t\t\t}\n\n\t\t\tif ( hasGridSettingsChanges ) {\n\t\t\t\tonGridSettingsChange?.(\n\t\t\t\t\tnormalizeGridSettings(\n\t\t\t\t\t\tstagingGridSettings,\n\t\t\t\t\t\tDEFAULT_ROW_HEIGHT\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif ( options?.exitEditMode !== false ) {\n\t\t\t\tonEditChange?.( false );\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\thasLayoutChanges,\n\t\t\thasGridSettingsChanges,\n\t\t\tonLayoutChange,\n\t\t\tonGridSettingsChange,\n\t\t\tstagingLayout,\n\t\t\tstagingGridSettings,\n\t\t\tonEditChange,\n\t\t]\n\t);\n\n\tconst cancel = useCallback(\n\t\t( options?: CancelOptions ) => {\n\t\t\tif ( options?.revertLayout !== false ) {\n\t\t\t\tsetStagingLayout( committedLayout );\n\t\t\t}\n\t\t\tsetStagingGridSettings( committedGridSettings );\n\t\t\tif ( options?.exitEditMode !== false ) {\n\t\t\t\tonEditChange?.( false );\n\t\t\t}\n\t\t},\n\t\t[ committedLayout, committedGridSettings, onEditChange ]\n\t);\n\n\tconst commitGridModelChange = useCallback(\n\t\t( targetModel: WidgetGridModel ) => {\n\t\t\tconst next = computeGridModelChange( {\n\t\t\t\tlayout: stagingLayout,\n\t\t\t\tgridSettings: stagingGridSettings,\n\t\t\t\ttargetModel,\n\t\t\t} );\n\n\t\t\tif ( ! next ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsetStagingLayout( next.layout );\n\t\t\tsetStagingGridSettings( next.gridSettings );\n\t\t\tonLayoutChange( canonicalize( next.layout ) );\n\t\t\tonGridSettingsChange?.(\n\t\t\t\tnormalizeGridSettings( next.gridSettings, DEFAULT_ROW_HEIGHT )\n\t\t\t);\n\t\t\tonEditChange?.( false );\n\t\t},\n\t\t[\n\t\t\tstagingLayout,\n\t\t\tstagingGridSettings,\n\t\t\tonLayoutChange,\n\t\t\tonGridSettingsChange,\n\t\t\tonEditChange,\n\t\t]\n\t);\n\n\tconst resetGridSettings = useCallback( () => {\n\t\tsetStagingGridSettings( DEFAULT_GRID );\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tif ( stagingLayout.length === 0 ) {\n\t\t\tonEditChange?.( true );\n\t\t}\n\n\t\t// Only react to the layout count flipping to zero; firing on every\n\t\t// onEditChange identity change would also reopen edit mode after the\n\t\t// user explicitly closed it on a non-empty layout.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ stagingLayout.length === 0 ] );\n\n\tconst canEditGridSettings = onGridSettingsChange !== undefined;\n\n\tconst value = useMemo< InternalDashboardContextValue >(\n\t\t() => ( {\n\t\t\twidgetTypes,\n\t\t\tisResolvingWidgetTypes,\n\t\t\tlayout: stagingLayout,\n\t\t\tonLayoutChange: setStagingLayout,\n\t\t\tonLayoutReset,\n\t\t\tgridSettings: resolveGridSettings( stagingGridSettings ),\n\t\t\tonGridSettingsChange: setStagingGridSettings,\n\t\t\tcanEditGridSettings,\n\t\t\tresetGridSettings,\n\t\t\tcommit,\n\t\t\tcommitGridModelChange,\n\t\t\tcancel,\n\t\t\thasUncommittedChanges,\n\t\t\teditMode,\n\t\t\tonEditChange,\n\t\t\tresolveWidgetModule,\n\t\t} ),\n\t\t[\n\t\t\twidgetTypes,\n\t\t\tisResolvingWidgetTypes,\n\t\t\tstagingLayout,\n\t\t\tonLayoutReset,\n\t\t\tstagingGridSettings,\n\t\t\tcanEditGridSettings,\n\t\t\tresetGridSettings,\n\t\t\tcommit,\n\t\t\tcommitGridModelChange,\n\t\t\tcancel,\n\t\t\thasUncommittedChanges,\n\t\t\teditMode,\n\t\t\tonEditChange,\n\t\t\tresolveWidgetModule,\n\t\t]\n\t);\n\n\treturn <Context.Provider value={ value }>{ children }</Context.Provider>;\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,OAAO,mBAAmB;AAM1B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AASP,SAAS,oBAAoB;AAC7B,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6/index.js';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { debounce, useEvent } from '@wordpress/compose';\nimport {\n\tcreateContext,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\nimport type {\n\tResolveWidgetModule,\n\tWidgetType,\n} from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { DEFAULT_GRID } from '../utils/default-grid';\nimport { normalizeGridSettings } from '../utils/normalize-grid-settings';\nimport { DEFAULT_ROW_HEIGHT } from '../utils/row-height-presets';\nimport type { WidgetGridSettings, DashboardWidget } from '../types';\nimport { WIDGET_DASHBOARD_COLUMN_COUNT } from '../types';\n\ntype GridSettingsWithColumns = WidgetGridSettings & { columns: number };\n\nfunction resolveGridSettings(\n\tsettings: WidgetGridSettings\n): GridSettingsWithColumns {\n\tconst normalized = normalizeGridSettings( settings, DEFAULT_ROW_HEIGHT );\n\treturn {\n\t\t...normalized,\n\t\tcolumns: WIDGET_DASHBOARD_COLUMN_COUNT,\n\t};\n}\n\nconst DEFAULT_RESOLVE_WIDGET_MODULE: ResolveWidgetModule = ( moduleId ) =>\n\timport( /* webpackIgnore: true */ moduleId );\n\n/**\n * Inline widget-instance edits stage live, then publish once the user pauses.\n * A single global timer, so editing several widgets settles into one save.\n */\nconst AUTO_SAVE_DELAY_MS = 5000;\n\n/**\n * Canonical form of `layout`: widgets sorted by `placement.order` (falling\n * back to array index), then `order` stripped since position now implies it.\n * Used both as the comparison form for `hasUncommittedChanges` (so a change\n * and its undo compare equal) and as the publish form, keeping persisted\n * payloads free of redundant `order` fields.\n *\n * @param {DashboardWidget[]} layout Layout to canonicalize.\n * @return {DashboardWidget[]} Canonicalized layout.\n */\nfunction canonicalize( layout: DashboardWidget[] ): DashboardWidget[] {\n\tconst indexed = layout.map( ( widget, index ) => ( {\n\t\twidget,\n\t\torder: widget.placement?.order ?? index,\n\t} ) );\n\n\tindexed.sort( ( a, b ) => a.order - b.order );\n\n\treturn indexed.map( ( { widget } ) => {\n\t\tif ( ! widget.placement ) {\n\t\t\treturn widget;\n\t\t}\n\t\tconst { order: _stripped, ...placement } = widget.placement;\n\t\treturn { ...widget, placement };\n\t} );\n}\n\n/**\n * Rich state distributed to every compound component inside `WidgetDashboard`.\n * Internal — compounds reach the full state via `useDashboardInternalContext()`.\n *\n * `layout`/`onLayoutChange` here operate on the staging layer, not the\n * committed props. Mutations from compound children stay in staging until\n * `commit` publishes them on the consumer.\n */\ninterface InternalDashboardContextValue {\n\twidgetTypes: WidgetType[];\n\tisResolvingWidgetTypes: boolean;\n\tlayout: DashboardWidget[];\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\tonLayoutReset?: () => void;\n\tgridSettings: GridSettingsWithColumns;\n\n\t/**\n\t * Publishes the staged layout when it differs from the committed\n\t * prop. By default also exits edit mode; pass `{ exitEditMode: false }`\n\t * for inline auto-saves that keep the current mode.\n\t */\n\tcommit: ( options?: CommitOptions ) => void;\n\n\t/**\n\t * Reverts the staged layout and exits edit mode.\n\t */\n\tcancel: () => void;\n\n\t/**\n\t * Debounced auto-save for inline widget-instance edits. Controls call it\n\t * after staging a change; a single global timer publishes once the edits\n\t * settle. The settings drawer does not use it (it commits on Save).\n\t */\n\tscheduleAutoSave: () => void;\n\n\t/**\n\t * Publishes any pending auto-save immediately. Called when leaving the\n\t * inline surface (opening the drawer, entering customize) so staged inline\n\t * edits do not commingle with the drawer's explicit-save flow.\n\t */\n\tflushAutoSave: () => void;\n\n\thasUncommittedChanges: boolean;\n\teditMode: boolean;\n\tonEditChange?: ( next: boolean ) => void;\n\tresolveWidgetModule: ResolveWidgetModule;\n}\n\ninterface CommitOptions {\n\texitEditMode?: boolean;\n}\n\nconst Context = createContext< InternalDashboardContextValue | null >( null );\n\n/**\n * Compound-internal hook — exposes the full provider state.\n * Not part of the public API; lives in the same module\n * so compound components can reach the state directly.\n */\nexport function useDashboardInternalContext(): InternalDashboardContextValue {\n\tconst ctx = useContext( Context );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Dashboard compound used outside a WidgetDashboard subtree.'\n\t\t);\n\t}\n\treturn ctx;\n}\n\ninterface ProviderProps {\n\twidgetTypes: WidgetType[];\n\tisResolvingWidgetTypes?: boolean;\n\tlayout: DashboardWidget[];\n\n\t/**\n\t * Fired on commit when the staged layout differs from `layout`.\n\t */\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\n\t/**\n\t * Optional reset action surfaced by the bundled `Actions`.\n\t */\n\tonLayoutReset?: () => void;\n\n\teditMode?: boolean;\n\tonEditChange?: ( next: boolean ) => void;\n\n\t/**\n\t * Overrides the default `import()` resolution of\n\t * `WidgetType.renderModule`.\n\t */\n\tresolveWidgetModule?: ResolveWidgetModule;\n\n\tgridSettings?: WidgetGridSettings;\n\n\tchildren: ReactNode;\n}\n\n/**\n * Provider for the dashboard's staging layer. Owns the staging copy of\n * `layout`; `commit` publishes it when it differs from the committed\n * prop, `cancel` reverts it.\n *\n * Staging re-syncs from the committed prop on prop change. In-flight\n * edits are dropped silently when an external update (cross-tab commit,\n * reset, websocket push) lands. Consumers that cannot tolerate this\n * loss should mediate the prop updates before forwarding them here.\n *\n * @param {ProviderProps} props Component props.\n */\nexport function WidgetDashboardProvider( {\n\twidgetTypes,\n\tisResolvingWidgetTypes = false,\n\tlayout: committedLayout,\n\tonLayoutChange,\n\tonLayoutReset,\n\teditMode = false,\n\tonEditChange,\n\tresolveWidgetModule = DEFAULT_RESOLVE_WIDGET_MODULE,\n\tgridSettings: committedGridSettings = DEFAULT_GRID,\n\tchildren,\n}: ProviderProps ): React.ReactNode {\n\tconst [ stagingLayout, setStagingLayout ] =\n\t\tuseState< DashboardWidget[] >( committedLayout );\n\n\t// External change in `layout` (consumer-side reset, cross-tab sync,\n\t// websocket push, etc.) drops any in-flight staging edits without\n\t// surfacing a warning. See the provider JSDoc for the trade-off.\n\tuseEffect( () => {\n\t\tsetStagingLayout( committedLayout );\n\t}, [ committedLayout ] );\n\n\tconst gridSettings = useMemo(\n\t\t() => resolveGridSettings( committedGridSettings ),\n\t\t[ committedGridSettings ]\n\t);\n\n\tconst hasLayoutChanges = useMemo(\n\t\t() =>\n\t\t\t! fastDeepEqual(\n\t\t\t\tcanonicalize( committedLayout ),\n\t\t\t\tcanonicalize( stagingLayout )\n\t\t\t),\n\t\t[ committedLayout, stagingLayout ]\n\t);\n\n\tconst hasUncommittedChanges = hasLayoutChanges;\n\n\tconst commit = useCallback(\n\t\t( options?: CommitOptions ) => {\n\t\t\tif ( hasLayoutChanges ) {\n\t\t\t\tonLayoutChange( canonicalize( stagingLayout ) );\n\t\t\t}\n\n\t\t\tif ( options?.exitEditMode !== false ) {\n\t\t\t\tonEditChange?.( false );\n\t\t\t}\n\t\t},\n\t\t[ hasLayoutChanges, onLayoutChange, stagingLayout, onEditChange ]\n\t);\n\n\t// Auto-save for inline edits.\n\t// A single debounced timer publishes through `useEvent`, so it always\n\t// reads the latest `commit` (and so the current staging) without\n\t// resetting on staging re-renders.\n\tconst publishAutoSave = useEvent( () => commit( { exitEditMode: false } ) );\n\n\tconst scheduleAutoSave = useMemo(\n\t\t() => debounce( publishAutoSave, AUTO_SAVE_DELAY_MS ),\n\t\t[ publishAutoSave ]\n\t);\n\n\tconst flushAutoSave = useCallback(\n\t\t() => scheduleAutoSave.flush(),\n\t\t[ scheduleAutoSave ]\n\t);\n\n\t// Entering customize flushes any pending inline save first, so it does not\n\t// commingle with the layout edit flow.\n\tuseEffect( () => {\n\t\tif ( ! editMode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tscheduleAutoSave.flush();\n\t}, [ editMode, scheduleAutoSave ] );\n\n\t// Flush, not cancel, on unmount: an edit still inside the debounce window\n\t// must persist when the user navigates away from the dashboard.\n\tuseEffect( () => () => scheduleAutoSave.flush(), [ scheduleAutoSave ] );\n\n\tconst cancel = useCallback( () => {\n\t\tsetStagingLayout( committedLayout );\n\t\tonEditChange?.( false );\n\t}, [ committedLayout, onEditChange ] );\n\n\tuseEffect( () => {\n\t\tif ( stagingLayout.length === 0 ) {\n\t\t\tonEditChange?.( true );\n\t\t}\n\n\t\t// Only react to the layout count flipping to zero; firing on every\n\t\t// onEditChange identity change would also reopen edit mode after the\n\t\t// user explicitly closed it on a non-empty layout.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ stagingLayout.length === 0 ] );\n\n\tconst value = useMemo< InternalDashboardContextValue >(\n\t\t() => ( {\n\t\t\twidgetTypes,\n\t\t\tisResolvingWidgetTypes,\n\t\t\tlayout: stagingLayout,\n\t\t\tonLayoutChange: setStagingLayout,\n\t\t\tonLayoutReset,\n\t\t\tgridSettings,\n\t\t\tcommit,\n\t\t\tcancel,\n\t\t\tscheduleAutoSave,\n\t\t\tflushAutoSave,\n\t\t\thasUncommittedChanges,\n\t\t\teditMode,\n\t\t\tonEditChange,\n\t\t\tresolveWidgetModule,\n\t\t} ),\n\t\t[\n\t\t\twidgetTypes,\n\t\t\tisResolvingWidgetTypes,\n\t\t\tstagingLayout,\n\t\t\tonLayoutReset,\n\t\t\tgridSettings,\n\t\t\tcommit,\n\t\t\tcancel,\n\t\t\tscheduleAutoSave,\n\t\t\tflushAutoSave,\n\t\t\thasUncommittedChanges,\n\t\t\teditMode,\n\t\t\tonEditChange,\n\t\t\tresolveWidgetModule,\n\t\t]\n\t);\n\n\treturn <Context.Provider value={ value }>{ children }</Context.Provider>;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,mBAAmB;AAM1B,SAAS,UAAU,gBAAgB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AASP,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC,SAAS,0BAA0B;AAEnC,SAAS,qCAAqC;AAmStC;AA/RR,SAAS,oBACR,UAC0B;AAC1B,QAAM,aAAa,sBAAuB,UAAU,kBAAmB;AACvE,SAAO;AAAA,IACN,GAAG;AAAA,IACH,SAAS;AAAA,EACV;AACD;AAEA,IAAM,gCAAqD,CAAE,aAC5D;AAAA;AAAA,EAAkC;AAAA;AAMnC,IAAM,qBAAqB;AAY3B,SAAS,aAAc,QAA+C;AACrE,QAAM,UAAU,OAAO,IAAK,CAAE,QAAQ,WAAa;AAAA,IAClD;AAAA,IACA,OAAO,OAAO,WAAW,SAAS;AAAA,EACnC,EAAI;AAEJ,UAAQ,KAAM,CAAE,GAAG,MAAO,EAAE,QAAQ,EAAE,KAAM;AAE5C,SAAO,QAAQ,IAAK,CAAE,EAAE,OAAO,MAAO;AACrC,QAAK,CAAE,OAAO,WAAY;AACzB,aAAO;AAAA,IACR;AACA,UAAM,EAAE,OAAO,WAAW,GAAG,UAAU,IAAI,OAAO;AAClD,WAAO,EAAE,GAAG,QAAQ,UAAU;AAAA,EAC/B,CAAE;AACH;AAsDA,IAAM,UAAU,cAAuD,IAAK;AAOrE,SAAS,8BAA6D;AAC5E,QAAM,MAAM,WAAY,OAAQ;AAChC,MAAK,CAAE,KAAM;AACZ,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AA2CO,SAAS,wBAAyB;AAAA,EACxC;AAAA,EACA,yBAAyB;AAAA,EACzB,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,sBAAsB;AAAA,EACtB,cAAc,wBAAwB;AAAA,EACtC;AACD,GAAoC;AACnC,QAAM,CAAE,eAAe,gBAAiB,IACvC,SAA+B,eAAgB;AAKhD,YAAW,MAAM;AAChB,qBAAkB,eAAgB;AAAA,EACnC,GAAG,CAAE,eAAgB,CAAE;AAEvB,QAAM,eAAe;AAAA,IACpB,MAAM,oBAAqB,qBAAsB;AAAA,IACjD,CAAE,qBAAsB;AAAA,EACzB;AAEA,QAAM,mBAAmB;AAAA,IACxB,MACC,CAAE;AAAA,MACD,aAAc,eAAgB;AAAA,MAC9B,aAAc,aAAc;AAAA,IAC7B;AAAA,IACD,CAAE,iBAAiB,aAAc;AAAA,EAClC;AAEA,QAAM,wBAAwB;AAE9B,QAAM,SAAS;AAAA,IACd,CAAE,YAA6B;AAC9B,UAAK,kBAAmB;AACvB,uBAAgB,aAAc,aAAc,CAAE;AAAA,MAC/C;AAEA,UAAK,SAAS,iBAAiB,OAAQ;AACtC,uBAAgB,KAAM;AAAA,MACvB;AAAA,IACD;AAAA,IACA,CAAE,kBAAkB,gBAAgB,eAAe,YAAa;AAAA,EACjE;AAMA,QAAM,kBAAkB,SAAU,MAAM,OAAQ,EAAE,cAAc,MAAM,CAAE,CAAE;AAE1E,QAAM,mBAAmB;AAAA,IACxB,MAAM,SAAU,iBAAiB,kBAAmB;AAAA,IACpD,CAAE,eAAgB;AAAA,EACnB;AAEA,QAAM,gBAAgB;AAAA,IACrB,MAAM,iBAAiB,MAAM;AAAA,IAC7B,CAAE,gBAAiB;AAAA,EACpB;AAIA,YAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB;AAAA,IACD;AAEA,qBAAiB,MAAM;AAAA,EACxB,GAAG,CAAE,UAAU,gBAAiB,CAAE;AAIlC,YAAW,MAAM,MAAM,iBAAiB,MAAM,GAAG,CAAE,gBAAiB,CAAE;AAEtE,QAAM,SAAS,YAAa,MAAM;AACjC,qBAAkB,eAAgB;AAClC,mBAAgB,KAAM;AAAA,EACvB,GAAG,CAAE,iBAAiB,YAAa,CAAE;AAErC,YAAW,MAAM;AAChB,QAAK,cAAc,WAAW,GAAI;AACjC,qBAAgB,IAAK;AAAA,IACtB;AAAA,EAMD,GAAG,CAAE,cAAc,WAAW,CAAE,CAAE;AAElC,QAAM,QAAQ;AAAA,IACb,OAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,SAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAkB,UAAU;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,34 +18,18 @@ function useDashboardUIContext() {
|
|
|
18
18
|
}
|
|
19
19
|
function WidgetDashboardUIProvider({ children }) {
|
|
20
20
|
const [inserterOpen, setInserterOpen] = useState(false);
|
|
21
|
-
const [layoutSettingsOpen, setLayoutSettingsOpen] = useState(false);
|
|
22
21
|
const [resetDialogOpen, setResetDialogOpen] = useState(false);
|
|
23
22
|
const [settingsWidgetUuid, setSettingsWidgetUuid] = useState(null);
|
|
24
|
-
const [settingsDrawerSide, setSettingsDrawerSide] = useState("right");
|
|
25
|
-
const [settingsDrawerInset, setSettingsDrawerInset] = useState(0);
|
|
26
23
|
const value = useMemo(
|
|
27
24
|
() => ({
|
|
28
25
|
inserterOpen,
|
|
29
26
|
setInserterOpen,
|
|
30
|
-
layoutSettingsOpen,
|
|
31
|
-
setLayoutSettingsOpen,
|
|
32
27
|
resetDialogOpen,
|
|
33
28
|
setResetDialogOpen,
|
|
34
29
|
settingsWidgetUuid,
|
|
35
|
-
setSettingsWidgetUuid
|
|
36
|
-
settingsDrawerSide,
|
|
37
|
-
setSettingsDrawerSide,
|
|
38
|
-
settingsDrawerInset,
|
|
39
|
-
setSettingsDrawerInset
|
|
30
|
+
setSettingsWidgetUuid
|
|
40
31
|
}),
|
|
41
|
-
[
|
|
42
|
-
inserterOpen,
|
|
43
|
-
layoutSettingsOpen,
|
|
44
|
-
resetDialogOpen,
|
|
45
|
-
settingsWidgetUuid,
|
|
46
|
-
settingsDrawerSide,
|
|
47
|
-
settingsDrawerInset
|
|
48
|
-
]
|
|
32
|
+
[inserterOpen, resetDialogOpen, settingsWidgetUuid]
|
|
49
33
|
);
|
|
50
34
|
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
51
35
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/context/ui-context.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n\
|
|
5
|
-
"mappings": ";AAQA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseMemo,\n\tuseState,\n} from '@wordpress/element';\n\ninterface DashboardUIContextValue {\n\tinserterOpen: boolean;\n\tsetInserterOpen: ( next: boolean ) => void;\n\n\tresetDialogOpen: boolean;\n\tsetResetDialogOpen: ( next: boolean ) => void;\n\n\t/**\n\t * `uuid` of the instance whose settings drawer is open, or `null`\n\t * when no settings drawer is showing. The per-instance gear in the\n\t * chrome sets it; the single `WidgetSettings` at the root reads\n\t * it.\n\t */\n\tsettingsWidgetUuid: string | null;\n\tsetSettingsWidgetUuid: ( next: string | null ) => void;\n}\n\nconst Context = createContext< DashboardUIContextValue | null >( null );\n\n/**\n * Accesses the shared UI state: overlay open flags and the active settings\n * instance with its placement. Throws when called outside `WidgetDashboard`.\n */\nexport function useDashboardUIContext(): DashboardUIContextValue {\n\tconst ctx = useContext( Context );\n\tif ( ! ctx ) {\n\t\tthrow new Error(\n\t\t\t'Dashboard compound used outside a WidgetDashboard subtree.'\n\t\t);\n\t}\n\treturn ctx;\n}\n\ninterface ProviderProps {\n\tchildren: ReactNode;\n}\n\n/**\n * Holds transient UI state shared across compounds (the inserter modal and\n * the per-instance settings drawer). Kept separate from the data context so\n * that data mutations don't churn the UI state and vice-versa.\n *\n * @param {ProviderProps} props Component props.\n */\nexport function WidgetDashboardUIProvider( { children }: ProviderProps ) {\n\tconst [ inserterOpen, setInserterOpen ] = useState( false );\n\tconst [ resetDialogOpen, setResetDialogOpen ] = useState( false );\n\tconst [ settingsWidgetUuid, setSettingsWidgetUuid ] = useState<\n\t\tstring | null\n\t>( null );\n\n\tconst value = useMemo< DashboardUIContextValue >(\n\t\t() => ( {\n\t\t\tinserterOpen,\n\t\t\tsetInserterOpen,\n\t\t\tresetDialogOpen,\n\t\t\tsetResetDialogOpen,\n\t\t\tsettingsWidgetUuid,\n\t\t\tsetSettingsWidgetUuid,\n\t\t} ),\n\t\t[ inserterOpen, resetDialogOpen, settingsWidgetUuid ]\n\t);\n\n\treturn <Context.Provider value={ value }>{ children }</Context.Provider>;\n}\n"],
|
|
5
|
+
"mappings": ";AAQA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAiEC;AA9CR,IAAM,UAAU,cAAiD,IAAK;AAM/D,SAAS,wBAAiD;AAChE,QAAM,MAAM,WAAY,OAAQ;AAChC,MAAK,CAAE,KAAM;AACZ,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAaO,SAAS,0BAA2B,EAAE,SAAS,GAAmB;AACxE,QAAM,CAAE,cAAc,eAAgB,IAAI,SAAU,KAAM;AAC1D,QAAM,CAAE,iBAAiB,kBAAmB,IAAI,SAAU,KAAM;AAChE,QAAM,CAAE,oBAAoB,qBAAsB,IAAI,SAEnD,IAAK;AAER,QAAM,QAAQ;AAAA,IACb,OAAQ;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA,CAAE,cAAc,iBAAiB,kBAAmB;AAAA,EACrD;AAEA,SAAO,oBAAC,QAAQ,UAAR,EAAiB,OAAkB,UAAU;AACtD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Dashboard-specific types: `DashboardWidget`, grid settings, and the\n * `WidgetDashboard` prop bag.\n *\n * The widget contract types (`WidgetName`, `WidgetType`, `WidgetRenderProps`,\n * `ResolveWidgetModule`) live in `@wordpress/widget-primitives` and are\n * imported from there directly; this module does not re-export them.\n */\n\n/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type {\n\tDashboardGridLayoutItem,\n\tDashboardLanesLayoutItem,\n} from '@wordpress/grid';\nimport type {\n\tWidgetName,\n\tWidgetType,\n\tResolveWidgetModule,\n} from '@wordpress/widget-primitives';\n\nexport type GridTilePlacement = Omit< DashboardGridLayoutItem, 'key' >;\nexport type MasonryTilePlacement = Omit< DashboardLanesLayoutItem, 'key' >;\n\n/**\n * Storage shape for a widget's placement.\n *\n * Structurally a union of every supported per-model shape, but the\n * intended invariant is stronger than the type suggests: every\n * placement in a given layout must match the shape of the currently\n * active `gridSettings.model`.
|
|
4
|
+
"sourcesContent": ["/**\n * Dashboard-specific types: `DashboardWidget`, grid settings, and the\n * `WidgetDashboard` prop bag.\n *\n * The widget contract types (`WidgetName`, `WidgetType`, `WidgetRenderProps`,\n * `ResolveWidgetModule`) live in `@wordpress/widget-primitives` and are\n * imported from there directly; this module does not re-export them.\n */\n\n/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type {\n\tDashboardGridLayoutItem,\n\tDashboardLanesLayoutItem,\n} from '@wordpress/grid';\nimport type {\n\tWidgetName,\n\tWidgetType,\n\tResolveWidgetModule,\n} from '@wordpress/widget-primitives';\n\nexport type GridTilePlacement = Omit< DashboardGridLayoutItem, 'key' >;\nexport type MasonryTilePlacement = Omit< DashboardLanesLayoutItem, 'key' >;\n\n/**\n * Storage shape for a widget's placement.\n *\n * Structurally a union of every supported per-model shape, but the\n * intended invariant is stronger than the type suggests: every\n * placement in a given layout must match the shape of the currently\n * active `gridSettings.model`. Consumers that switch the model must\n * supply placements in the new shape; the render layer is allowed to\n * trust the active model and treat each placement as the matching\n * shape.\n *\n * The type system cannot enforce that invariant on its own (there is\n * no discriminator on the placement itself), so consider this union a\n * declaration of which shapes are *valid*, not which shape any given\n * placement happens to be at runtime.\n */\nexport type DashboardTilePlacement = GridTilePlacement | MasonryTilePlacement;\n\n/**\n * A widget placed on the dashboard.\n *\n * A `WidgetType` describes the blueprint. A `DashboardWidget` is a\n * concrete placement of that type on a specific dashboard: its unique\n * id, the type it references, user-configured attributes, and its\n * `placement` in the grid.\n */\nexport interface DashboardWidget< Item = unknown > {\n\t/**\n\t * Unique instance identifier.\n\t */\n\tuuid: string;\n\n\t/**\n\t * Widget type name — must match a `WidgetType.name` in `widgetTypes`.\n\t */\n\ttype: WidgetName;\n\n\t/**\n\t * User-configured attributes for this instance.\n\t */\n\tattributes?: Item;\n\n\t/**\n\t * Grid-model-specific placement (column/row spans, ordering,\n\t * etc.). Must match the shape implied by the dashboard's active\n\t * `gridSettings.model`; see `DashboardTilePlacement` for the\n\t * invariant.\n\t */\n\tplacement?: DashboardTilePlacement;\n}\n\n/**\n * Identity of a widget within the rendering tree. Returned by\n * `useWidgetContext()`; `null` when called outside a widget render subtree.\n */\nexport interface WidgetContextValue {\n\t/**\n\t * Widget instance id.\n\t */\n\tuuid: string;\n\n\t/**\n\t * Widget type name.\n\t */\n\tname: WidgetName;\n\n\t/**\n\t * Index of the widget in the `layout` array.\n\t */\n\tindex: number;\n}\n\n/**\n * Identifier for the active grid model. Drives which `@wordpress/grid`\n * surface the dashboard mounts and which per-model settings the\n * `WidgetGridSettings` union admits.\n *\n * Model names describe user-facing concepts. The mapping to the\n * underlying `@wordpress/grid` component is an implementation detail\n * resolved in the render layer; `'masonry'` is rendered today through\n * `DashboardLanes` (skyline placement) but could swap to a future\n * native `display: grid-lanes` path without affecting the model name.\n */\nexport type WidgetGridModel = 'grid' | 'masonry';\n\n/**\n * Maximum column count for the widget dashboard on wide containers.\n * Not user-configurable; container width steps the count down to two\n * and one column at fixed breakpoints.\n */\nexport const WIDGET_DASHBOARD_COLUMN_COUNT = 4;\n\n/**\n * Settings common to every grid model. Column count is resolved from\n * the dashboard container width (see\n * `utils/resolve-dashboard-column-count`). `columns` and `minColumnWidth`\n * on this type remain for persisted payloads and `@wordpress/grid`\n * compatibility; the dashboard ignores user-facing values for both.\n *\n * `spacing` is intentionally absent: the gap between tiles is\n * presentational and lives with the design-system theme/density, not\n * with per-dashboard settings. The grid surface keeps the prop for\n * programmatic overrides, but the dashboard does not propagate it.\n */\ninterface BaseWidgetGridSettings {\n\t/**\n\t * Target column count (cap). The dashboard always uses\n\t * {@link WIDGET_DASHBOARD_COLUMN_COUNT}; persisted values are ignored.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Per-tile minimum width in pixels. Unused by the dashboard; column\n\t * count is derived from container width instead.\n\t */\n\tminColumnWidth?: number;\n}\n\n/**\n * 2D packed grid settings. Items declare explicit width and height\n * spans; rows use a uniform track height via `rowHeight`.\n */\nexport interface WidgetGridLayoutSettings extends BaseWidgetGridSettings {\n\tmodel?: 'grid';\n\n\t/**\n\t * Row height in pixels (`200` small, `300` medium, `400` large). Every\n\t * tile in a row fills the row vertically.\n\t */\n\trowHeight?: number;\n}\n\n/**\n * Masonry settings. Heights are content-driven; resize is\n * horizontal-only. `flowTolerance` tunes how aggressively the placer\n * preserves source order vs. minimizing empty regions.\n */\nexport interface WidgetMasonryLayoutSettings extends BaseWidgetGridSettings {\n\tmodel: 'masonry';\n\n\t/**\n\t * Pixel tolerance for source-order tiebreaking when two candidate\n\t * columns have similar baselines.\n\t */\n\tflowTolerance?: number;\n}\n\n/**\n * Discriminated union of supported grid-model configurations.\n *\n * When `model` is omitted the dashboard treats the settings as the\n * 2D packed grid (`'grid'`) for backwards compatibility with the\n * pre-union shape.\n */\nexport type WidgetGridSettings =\n\t| WidgetGridLayoutSettings\n\t| WidgetMasonryLayoutSettings;\n\n/**\n * Props for `WidgetDashboard`.\n *\n * The consumer owns the committed layout state; the dashboard maintains\n * a staging copy internally for in-progress edits, and `onLayoutChange`\n * fires only when the user commits via the Done action.\n */\nexport interface WidgetDashboardProps {\n\t/**\n\t * Widget instances to render. Consumer owns this state.\n\t */\n\tlayout: DashboardWidget[];\n\n\t/**\n\t * Called when the user commits in-progress edits via the Done action.\n\t * Receives the full layout array as it should be persisted. In-progress\n\t * mutations (reorder, resize, add, remove, attribute edits) accumulate\n\t * in the dashboard's internal staging layer and do not fire this\n\t * callback until commit.\n\t */\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\n\t/**\n\t * Called when the layout is reset to the default.\n\t */\n\tonLayoutReset?: () => void;\n\n\t/**\n\t * Widget types available for rendering. The dashboard never queries a\n\t * store directly — consumers scope and filter via this prop.\n\t */\n\twidgetTypes: WidgetType[];\n\n\t/**\n\t * When true, widget types are still loading. Instances whose type is\n\t * not yet in `widgetTypes` show a loading state instead of missing.\n\t */\n\tisResolvingWidgetTypes?: boolean;\n\n\t/**\n\t * Whether the dashboard is in edit mode (enables drag/resize).\n\t */\n\teditMode?: boolean;\n\n\t/**\n\t * Called when edit mode toggles via `WidgetDashboard.Actions`.\n\t */\n\tonEditChange?: ( next: boolean ) => void;\n\n\t/**\n\t * Overrides the default `import()` resolution of\n\t * `WidgetType.renderModule`. Useful for tests, Storybook, or future\n\t * remote-URL loading.\n\t */\n\tresolveWidgetModule?: ResolveWidgetModule;\n\n\t/**\n\t * Grid model configuration. See `WidgetGridSettings` for the shape.\n\t * Read-only for the dashboard: the consumer owns the settings and\n\t * their persistence.\n\t */\n\tgridSettings?: WidgetGridSettings;\n\n\tchildren?: ReactNode;\n}\n"],
|
|
5
5
|
"mappings": ";AAwHO,IAAM,gCAAgC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// packages/widget-dashboard/src/utils/index.ts
|
|
2
2
|
import { createDashboardWidget } from "./create-dashboard-widget/index.mjs";
|
|
3
|
-
import { migrateLayout } from "./migrate-layout/index.mjs";
|
|
4
3
|
export {
|
|
5
|
-
createDashboardWidget
|
|
6
|
-
migrateLayout
|
|
4
|
+
createDashboardWidget
|
|
7
5
|
};
|
|
8
6
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["export { createDashboardWidget } from './create-dashboard-widget';\
|
|
5
|
-
"mappings": ";AAAA,SAAS,6BAA6B;
|
|
4
|
+
"sourcesContent": ["export { createDashboardWidget } from './create-dashboard-widget';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,6BAA6B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,6 @@ import { WidgetDashboardProvider } from "./context/dashboard-context.mjs";
|
|
|
3
3
|
import { WidgetDashboardUIProvider } from "./context/ui-context.mjs";
|
|
4
4
|
import { Actions } from "./components/actions/index.mjs";
|
|
5
5
|
import { Commands } from "./components/commands/index.mjs";
|
|
6
|
-
import { LayoutSettings } from "./components/layout-settings/index.mjs";
|
|
7
6
|
import { NoWidgetsState } from "./components/no-widgets-state/index.mjs";
|
|
8
7
|
import { ResetConfirmation } from "./components/reset-confirmation/index.mjs";
|
|
9
8
|
import { WidgetChrome } from "./components/widget-chrome/index.mjs";
|
|
@@ -22,7 +21,6 @@ var WidgetDashboard = Object.assign(
|
|
|
22
21
|
onEditChange,
|
|
23
22
|
resolveWidgetModule,
|
|
24
23
|
gridSettings,
|
|
25
|
-
onGridSettingsChange,
|
|
26
24
|
children
|
|
27
25
|
}) {
|
|
28
26
|
return /* @__PURE__ */ jsx(
|
|
@@ -37,7 +35,6 @@ var WidgetDashboard = Object.assign(
|
|
|
37
35
|
onEditChange,
|
|
38
36
|
resolveWidgetModule,
|
|
39
37
|
gridSettings,
|
|
40
|
-
onGridSettingsChange,
|
|
41
38
|
children: /* @__PURE__ */ jsxs(WidgetDashboardUIProvider, { children: [
|
|
42
39
|
children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
40
|
/* @__PURE__ */ jsx(NoWidgetsState, {}),
|
|
@@ -46,7 +43,6 @@ var WidgetDashboard = Object.assign(
|
|
|
46
43
|
/* @__PURE__ */ jsx(Commands, {})
|
|
47
44
|
] }),
|
|
48
45
|
/* @__PURE__ */ jsx(WidgetInserter, {}),
|
|
49
|
-
/* @__PURE__ */ jsx(LayoutSettings, {}),
|
|
50
46
|
/* @__PURE__ */ jsx(WidgetSettings, {}),
|
|
51
47
|
/* @__PURE__ */ jsx(ResetConfirmation, {})
|
|
52
48
|
] })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/widget-dashboard.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { WidgetDashboardProvider } from './context/dashboard-context';\nimport { WidgetDashboardUIProvider } from './context/ui-context';\nimport { Actions } from './components/actions';\nimport { Commands } from './components/commands';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { WidgetDashboardProvider } from './context/dashboard-context';\nimport { WidgetDashboardUIProvider } from './context/ui-context';\nimport { Actions } from './components/actions';\nimport { Commands } from './components/commands';\nimport { NoWidgetsState } from './components/no-widgets-state';\nimport { ResetConfirmation } from './components/reset-confirmation';\nimport { WidgetChrome } from './components/widget-chrome';\nimport { WidgetInserter } from './components/widget-inserter';\nimport { WidgetSettings } from './components/widget-settings';\nimport { Widgets } from './components/widgets';\nimport type { WidgetDashboardProps } from './types';\n\n/**\n * Stateless rendering engine for widget dashboards.\n *\n * The consumer owns `layout` and `editMode` state; every mutation fires\n * `onLayoutChange` with the fully updated array. The engine never queries a\n * widget store; types flow in via the `widgetTypes` prop.\n *\n * ```tsx\n * import { WidgetDashboard } from '@wordpress/widget-dashboard';\n *\n * function MyDashboard() {\n * \tconst [ layout, setLayout ] = useState( defaultLayout );\n * \tconst [ editMode, setEditMode ] = useState( false );\n * \treturn (\n * \t\t<WidgetDashboard\n * \t\t\tlayout={ layout }\n * \t\t\tonLayoutChange={ setLayout }\n * \t\t\twidgetTypes={ widgetTypes }\n * \t\t\teditMode={ editMode }\n * \t\t\tonEditChange={ setEditMode }\n * \t\t>\n * \t\t\t<WidgetDashboard.NoWidgetsState>\n * \t\t\t\t<p>No widgets yet.</p>\n * \t\t\t</WidgetDashboard.NoWidgetsState>\n * \t\t\t<WidgetDashboard.Actions />\n * \t\t\t<WidgetDashboard.Widgets />\n * \t\t\t<WidgetDashboard.Commands />\n * \t\t</WidgetDashboard>\n * \t);\n * }\n * ```\n *\n * Children compose the dashboard's triggers and chrome: `Actions`,\n * `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the\n * widget inserter, the widget settings editor, the reset confirmation) are\n * mounted by the engine and driven by shared UI state, so a trigger works\n * wherever it is composed without a matching target in the tree. Omitting\n * `children` renders the default arrangement.\n */\nexport const WidgetDashboard = Object.assign(\n\tfunction WidgetDashboard( {\n\t\tlayout,\n\t\tonLayoutChange,\n\t\tonLayoutReset,\n\t\twidgetTypes,\n\t\tisResolvingWidgetTypes,\n\t\teditMode,\n\t\tonEditChange,\n\t\tresolveWidgetModule,\n\t\tgridSettings,\n\t\tchildren,\n\t}: WidgetDashboardProps ) {\n\t\treturn (\n\t\t\t<WidgetDashboardProvider\n\t\t\t\tlayout={ layout }\n\t\t\t\tonLayoutChange={ onLayoutChange }\n\t\t\t\tonLayoutReset={ onLayoutReset }\n\t\t\t\twidgetTypes={ widgetTypes }\n\t\t\t\tisResolvingWidgetTypes={ isResolvingWidgetTypes }\n\t\t\t\teditMode={ editMode }\n\t\t\t\tonEditChange={ onEditChange }\n\t\t\t\tresolveWidgetModule={ resolveWidgetModule }\n\t\t\t\tgridSettings={ gridSettings }\n\t\t\t>\n\t\t\t\t<WidgetDashboardUIProvider>\n\t\t\t\t\t{ children ?? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<NoWidgetsState />\n\t\t\t\t\t\t\t<Actions />\n\t\t\t\t\t\t\t<Widgets />\n\t\t\t\t\t\t\t<Commands />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<WidgetInserter />\n\t\t\t\t\t<WidgetSettings />\n\t\t\t\t\t<ResetConfirmation />\n\t\t\t\t</WidgetDashboardUIProvider>\n\t\t\t</WidgetDashboardProvider>\n\t\t);\n\t},\n\t{ Actions, Widgets, WidgetChrome, NoWidgetsState, Commands }\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAqElB,mBACC,KADD;AA3BC,IAAM,kBAAkB,OAAO;AAAA,EACrC,SAASA,iBAAiB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,GAA0B;AACzB,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAEA,+BAAC,6BACE;AAAA,sBACD,iCACC;AAAA,gCAAC,kBAAe;AAAA,YAChB,oBAAC,WAAQ;AAAA,YACT,oBAAC,WAAQ;AAAA,YACT,oBAAC,YAAS;AAAA,aACX;AAAA,UAGD,oBAAC,kBAAe;AAAA,UAChB,oBAAC,kBAAe;AAAA,UAChB,oBAAC,qBAAkB;AAAA,WACpB;AAAA;AAAA,IACD;AAAA,EAEF;AAAA,EACA,EAAE,SAAS,SAAS,cAAc,gBAAgB,SAAS;AAC5D;",
|
|
6
6
|
"names": ["WidgetDashboard"]
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions/actions.tsx"],"names":[],"mappings":"AAoBA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,IAAI,KAAK,CAAC,SAAS,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/components/actions/actions.tsx"],"names":[],"mappings":"AAoBA;;;;;;;;GAQG;AACH,wBAAgB,OAAO,IAAI,KAAK,CAAC,SAAS,CAkIzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/components/commands/commands.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../src/components/commands/commands.tsx"],"names":[],"mappings":"AAqBA,eAAO,MAAM,yBAAyB,cAAc,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,QAAQ,SAqFvB"}
|
|
@@ -10,6 +10,6 @@ type UsePendingWhenEditModeResult = (action: () => void) => void;
|
|
|
10
10
|
* @param {UsePendingWhenEditModeProps} params Current edit mode and the change handler.
|
|
11
11
|
* @return {UsePendingWhenEditModeResult} Runs an action, deferring it until edit mode is active.
|
|
12
12
|
*/
|
|
13
|
-
export declare function usePendingWhenEditMode({ editMode, onEditChange }: UsePendingWhenEditModeProps): UsePendingWhenEditModeResult;
|
|
13
|
+
export declare function usePendingWhenEditMode({ editMode, onEditChange, }: UsePendingWhenEditModeProps): UsePendingWhenEditModeResult;
|
|
14
14
|
export {};
|
|
15
15
|
//# sourceMappingURL=use-pending-when-edit-mode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-pending-when-edit-mode.d.ts","sourceRoot":"","sources":["../../../src/components/commands/use-pending-when-edit-mode.ts"],"names":[],"mappings":"AAKA,KAAK,2BAA2B,GAAG;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAE,IAAI,EAAE,OAAO,KAAM,IAAI,CAAC;CACzC,CAAC;AAEF,KAAK,4BAA4B,GAAG,CAAE,MAAM,EAAE,MAAM,IAAI,KAAM,IAAI,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,EACvC,QAAQ,EACR,YAAY,
|
|
1
|
+
{"version":3,"file":"use-pending-when-edit-mode.d.ts","sourceRoot":"","sources":["../../../src/components/commands/use-pending-when-edit-mode.ts"],"names":[],"mappings":"AAKA,KAAK,2BAA2B,GAAG;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,CAAC,EAAE,CAAE,IAAI,EAAE,OAAO,KAAM,IAAI,CAAC;CACzC,CAAC;AAEF,KAAK,4BAA4B,GAAG,CAAE,MAAM,EAAE,MAAM,IAAI,KAAM,IAAI,CAAC;AAEnE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAE,EACvC,QAAQ,EACR,YAAY,GACZ,EAAE,2BAA2B,GAAI,4BAA4B,CAyB7D"}
|
|
@@ -13,5 +13,5 @@ export interface NoWidgetsStateProps {
|
|
|
13
13
|
*
|
|
14
14
|
* @param {NoWidgetsStateProps} props Component props.
|
|
15
15
|
*/
|
|
16
|
-
export declare function NoWidgetsState({ children }: NoWidgetsStateProps): React.ReactNode;
|
|
16
|
+
export declare function NoWidgetsState({ children, }: NoWidgetsStateProps): React.ReactNode;
|
|
17
17
|
//# sourceMappingURL=no-widgets-state.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-widgets-state.d.ts","sourceRoot":"","sources":["../../../src/components/no-widgets-state/no-widgets-state.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAevC,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,EAC/B,QAAQ,
|
|
1
|
+
{"version":3,"file":"no-widgets-state.d.ts","sourceRoot":"","sources":["../../../src/components/no-widgets-state/no-widgets-state.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAevC,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAE,EAC/B,QAAQ,GACR,EAAE,mBAAmB,GAAI,KAAK,CAAC,SAAS,CAuBxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/widget-attribute-controls/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
2
|
+
import type { DashboardWidget } from '../../types';
|
|
3
|
+
type WidgetAttributeControlsProps = {
|
|
4
|
+
/**
|
|
5
|
+
* The instance whose attributes these controls edit.
|
|
6
|
+
*/
|
|
7
|
+
widget: DashboardWidget<unknown>;
|
|
8
|
+
/**
|
|
9
|
+
* The instance's widget type, source of the attribute schema.
|
|
10
|
+
*/
|
|
11
|
+
widgetType: WidgetType;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Normal-mode controls: the `relevance: 'high'` attributes on a prominent
|
|
15
|
+
* surface, plus a settings entry point when needed. Inline controls appear
|
|
16
|
+
* only for the high-relevance fields; edits stage live and auto-save on the
|
|
17
|
+
* dashboard's shared debounce.
|
|
18
|
+
*
|
|
19
|
+
* @param {WidgetAttributeControlsProps} props Component props.
|
|
20
|
+
*/
|
|
21
|
+
export declare function WidgetAttributeControls({ widget, widgetType, }: WidgetAttributeControlsProps): React.ReactNode;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=widget-attribute-controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-attribute-controls.d.ts","sourceRoot":"","sources":["../../../src/components/widget-attribute-controls/widget-attribute-controls.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAO/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAInD,KAAK,4BAA4B,GAAG;IACnC;;OAEG;IACH,MAAM,EAAE,eAAe,CAAE,OAAO,CAAE,CAAC;IAEnC;;OAEG;IACH,UAAU,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAE,EACxC,MAAM,EACN,UAAU,GACV,EAAE,4BAA4B,GAAI,KAAK,CAAC,SAAS,CAmEjD"}
|
|
@@ -4,19 +4,19 @@ export interface WidgetChromeProps {
|
|
|
4
4
|
widget: DashboardWidget<unknown>;
|
|
5
5
|
index: number;
|
|
6
6
|
/**
|
|
7
|
-
* Lifted by
|
|
8
|
-
*
|
|
9
|
-
* Living outside `Card.Root` is what keeps these controls interactive
|
|
10
|
-
* while edit mode applies `inert` to the chrome.
|
|
7
|
+
* Lifted by `@wordpress/grid` into a sibling slot outside `Card.Root`,
|
|
8
|
+
* for full-bleed widgets with no in-card header to host the toolbar.
|
|
11
9
|
*/
|
|
12
10
|
actionableArea?: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Toolbar rendered in the in-card header (framed and content-bleed).
|
|
13
|
+
*/
|
|
14
|
+
headerToolbar?: ReactNode;
|
|
13
15
|
className?: string;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* error/loading boundaries that keep neighbours mounted when one widget fails
|
|
19
|
-
* or is still resolving.
|
|
18
|
+
* Dashboard chrome: wraps `WidgetFrame` in the grid tile's `Card.Root`, owning
|
|
19
|
+
* the missing and resolving states.
|
|
20
20
|
*/
|
|
21
21
|
export declare const WidgetChrome: import("react").ForwardRefExoticComponent<WidgetChromeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
22
22
|
//# sourceMappingURL=widget-chrome.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget-chrome.d.ts","sourceRoot":"","sources":["../../../src/components/widget-chrome/widget-chrome.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"widget-chrome.d.ts","sourceRoot":"","sources":["../../../src/components/widget-chrome/widget-chrome.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiBvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAiCnD,MAAM,WAAW,iBAAiB;IACjC,MAAM,EAAE,eAAe,CAAE,OAAO,CAAE,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,8GA4ExB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/widget-frame/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
3
|
+
import type { DashboardWidget } from '../../types';
|
|
4
|
+
export declare function LoadingOverlay(): import("react").JSX.Element;
|
|
5
|
+
export interface WidgetFrameProps {
|
|
6
|
+
widget: DashboardWidget<unknown>;
|
|
7
|
+
widgetType: WidgetType;
|
|
8
|
+
titleId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Inert the body and identity while customizing.
|
|
11
|
+
*/
|
|
12
|
+
editMode?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Toolbar shown beside the identity in the in-card header.
|
|
15
|
+
*/
|
|
16
|
+
headerToolbar?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Shared framing: `presentation` into header + content, with the error/loading
|
|
20
|
+
* boundaries. Hosts supply the `Card.Root` and their own concerns.
|
|
21
|
+
*
|
|
22
|
+
* @param {WidgetFrameProps} props Component props.
|
|
23
|
+
*/
|
|
24
|
+
export declare function WidgetFrame({ widget, widgetType, titleId, editMode, headerToolbar, }: WidgetFrameProps): import("react").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=widget-frame.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-frame.d.ts","sourceRoot":"","sources":["../../../src/components/widget-frame/widget-frame.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAmCnD,wBAAgB,cAAc,gCAM7B;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,eAAe,CAAE,OAAO,CAAE,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,EAC5B,MAAM,EACN,UAAU,EACV,OAAO,EACP,QAAgB,EAChB,aAAa,GACb,EAAE,gBAAgB,+BA4ClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/widget-header/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC"}
|