@wordpress/widget-dashboard 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -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
|
@@ -15,7 +15,7 @@ import type { WidgetType } from '@wordpress/widget-primitives';
|
|
|
15
15
|
*/
|
|
16
16
|
import { useDashboardInternalContext } from '../context/dashboard-context';
|
|
17
17
|
import { WidgetDashboard } from '../widget-dashboard';
|
|
18
|
-
import type { DashboardWidget
|
|
18
|
+
import type { DashboardWidget } from '../types';
|
|
19
19
|
|
|
20
20
|
const widgetTypes: WidgetType[] = [];
|
|
21
21
|
|
|
@@ -26,16 +26,13 @@ const initialLayout: DashboardWidget[] = [
|
|
|
26
26
|
|
|
27
27
|
interface ProbeApi {
|
|
28
28
|
layout: DashboardWidget[];
|
|
29
|
-
gridSettings: WidgetGridSettings;
|
|
30
29
|
hasUncommittedChanges: boolean;
|
|
31
30
|
editMode: boolean;
|
|
32
31
|
mutate: ( next: DashboardWidget[] ) => void;
|
|
33
|
-
mutateGridSettings: ( next: WidgetGridSettings ) => void;
|
|
34
32
|
commit: ( options?: { exitEditMode?: boolean } ) => void;
|
|
35
|
-
cancel: (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} ) => void;
|
|
33
|
+
cancel: () => void;
|
|
34
|
+
scheduleAutoSave: () => void;
|
|
35
|
+
flushAutoSave: () => void;
|
|
39
36
|
}
|
|
40
37
|
|
|
41
38
|
const probeRef: { current: ProbeApi | null } = { current: null };
|
|
@@ -45,13 +42,13 @@ function Probe() {
|
|
|
45
42
|
useEffect( () => {
|
|
46
43
|
probeRef.current = {
|
|
47
44
|
layout: ctx.layout,
|
|
48
|
-
gridSettings: ctx.gridSettings,
|
|
49
45
|
hasUncommittedChanges: ctx.hasUncommittedChanges,
|
|
50
46
|
editMode: ctx.editMode,
|
|
51
47
|
mutate: ctx.onLayoutChange,
|
|
52
|
-
mutateGridSettings: ctx.onGridSettingsChange,
|
|
53
48
|
commit: ctx.commit,
|
|
54
49
|
cancel: ctx.cancel,
|
|
50
|
+
scheduleAutoSave: ctx.scheduleAutoSave,
|
|
51
|
+
flushAutoSave: ctx.flushAutoSave,
|
|
55
52
|
};
|
|
56
53
|
} );
|
|
57
54
|
return null;
|
|
@@ -67,24 +64,20 @@ function readProbe(): ProbeApi {
|
|
|
67
64
|
interface HarnessProps {
|
|
68
65
|
layout: DashboardWidget[];
|
|
69
66
|
onLayoutChange: ( next: DashboardWidget[] ) => void;
|
|
70
|
-
|
|
71
|
-
onGridSettingsChange?: ( next: WidgetGridSettings ) => void;
|
|
67
|
+
initialEditMode?: boolean;
|
|
72
68
|
}
|
|
73
69
|
|
|
74
70
|
function Harness( {
|
|
75
71
|
layout,
|
|
76
72
|
onLayoutChange,
|
|
77
|
-
|
|
78
|
-
onGridSettingsChange,
|
|
73
|
+
initialEditMode = true,
|
|
79
74
|
}: HarnessProps ) {
|
|
80
|
-
const [ editMode, setEditMode ] = useState(
|
|
75
|
+
const [ editMode, setEditMode ] = useState( initialEditMode );
|
|
81
76
|
|
|
82
77
|
return (
|
|
83
78
|
<WidgetDashboard
|
|
84
79
|
layout={ layout }
|
|
85
80
|
onLayoutChange={ onLayoutChange }
|
|
86
|
-
gridSettings={ gridSettings }
|
|
87
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
88
81
|
widgetTypes={ widgetTypes }
|
|
89
82
|
editMode={ editMode }
|
|
90
83
|
onEditChange={ setEditMode }
|
|
@@ -286,191 +279,136 @@ describe( 'WidgetDashboard staging layer', () => {
|
|
|
286
279
|
expect( readProbe().editMode ).toBe( true );
|
|
287
280
|
} );
|
|
288
281
|
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
282
|
+
it( 'stays in edit mode when commit passes exitEditMode: false', () => {
|
|
283
|
+
const onLayoutChange = jest.fn();
|
|
284
|
+
render(
|
|
285
|
+
<Harness
|
|
286
|
+
layout={ initialLayout }
|
|
287
|
+
onLayoutChange={ onLayoutChange }
|
|
288
|
+
/>
|
|
289
|
+
);
|
|
294
290
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
render(
|
|
299
|
-
<Harness
|
|
300
|
-
layout={ initialLayout }
|
|
301
|
-
onLayoutChange={ onLayoutChange }
|
|
302
|
-
gridSettings={ initialSettings }
|
|
303
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
304
|
-
/>
|
|
305
|
-
);
|
|
291
|
+
act( () => {
|
|
292
|
+
readProbe().mutate( [ initialLayout[ 0 ] ] );
|
|
293
|
+
} );
|
|
306
294
|
|
|
307
|
-
|
|
295
|
+
act( () => {
|
|
296
|
+
readProbe().commit( { exitEditMode: false } );
|
|
297
|
+
} );
|
|
308
298
|
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
299
|
+
expect( readProbe().editMode ).toBe( true );
|
|
300
|
+
expect( onLayoutChange ).toHaveBeenCalledTimes( 1 );
|
|
301
|
+
} );
|
|
302
|
+
|
|
303
|
+
describe( 'inline auto-save', () => {
|
|
304
|
+
const moved: DashboardWidget[] = [
|
|
305
|
+
{ ...initialLayout[ 1 ] },
|
|
306
|
+
{ ...initialLayout[ 0 ] },
|
|
307
|
+
];
|
|
308
|
+
|
|
309
|
+
beforeEach( () => {
|
|
310
|
+
jest.useFakeTimers();
|
|
311
|
+
} );
|
|
315
312
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
expect( readProbe().gridSettings.rowHeight ).toBe( 300 );
|
|
313
|
+
afterEach( () => {
|
|
314
|
+
jest.useRealTimers();
|
|
319
315
|
} );
|
|
320
316
|
|
|
321
|
-
it( 'publishes
|
|
317
|
+
it( 'publishes a scheduled edit once the debounce elapses, staying in normal mode', () => {
|
|
322
318
|
const onLayoutChange = jest.fn();
|
|
323
|
-
const onGridSettingsChange = jest.fn();
|
|
324
319
|
render(
|
|
325
320
|
<Harness
|
|
326
321
|
layout={ initialLayout }
|
|
327
322
|
onLayoutChange={ onLayoutChange }
|
|
328
|
-
|
|
329
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
323
|
+
initialEditMode={ false }
|
|
330
324
|
/>
|
|
331
325
|
);
|
|
332
326
|
|
|
333
327
|
act( () => {
|
|
334
|
-
readProbe().mutate(
|
|
335
|
-
readProbe().
|
|
336
|
-
...initialSettings,
|
|
337
|
-
model: 'masonry',
|
|
338
|
-
} );
|
|
328
|
+
readProbe().mutate( moved );
|
|
329
|
+
readProbe().scheduleAutoSave();
|
|
339
330
|
} );
|
|
340
331
|
|
|
332
|
+
expect( onLayoutChange ).not.toHaveBeenCalled();
|
|
333
|
+
|
|
341
334
|
act( () => {
|
|
342
|
-
|
|
335
|
+
jest.runOnlyPendingTimers();
|
|
343
336
|
} );
|
|
344
337
|
|
|
345
338
|
expect( onLayoutChange ).toHaveBeenCalledTimes( 1 );
|
|
346
|
-
expect(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
339
|
+
expect(
|
|
340
|
+
onLayoutChange.mock.calls[ 0 ][ 0 ].map(
|
|
341
|
+
( w: DashboardWidget ) => w.uuid
|
|
342
|
+
)
|
|
343
|
+
).toEqual( [ 'b', 'a' ] );
|
|
344
|
+
expect( readProbe().editMode ).toBe( false );
|
|
350
345
|
} );
|
|
351
346
|
|
|
352
|
-
it( '
|
|
347
|
+
it( 'publishes a pending edit immediately on flushAutoSave', () => {
|
|
353
348
|
const onLayoutChange = jest.fn();
|
|
354
|
-
const onGridSettingsChange = jest.fn();
|
|
355
349
|
render(
|
|
356
350
|
<Harness
|
|
357
351
|
layout={ initialLayout }
|
|
358
352
|
onLayoutChange={ onLayoutChange }
|
|
359
|
-
|
|
360
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
353
|
+
initialEditMode={ false }
|
|
361
354
|
/>
|
|
362
355
|
);
|
|
363
356
|
|
|
364
357
|
act( () => {
|
|
365
|
-
readProbe().
|
|
366
|
-
|
|
367
|
-
model: 'masonry',
|
|
368
|
-
} );
|
|
358
|
+
readProbe().mutate( moved );
|
|
359
|
+
readProbe().scheduleAutoSave();
|
|
369
360
|
} );
|
|
370
361
|
|
|
371
|
-
expect( readProbe().hasUncommittedChanges ).toBe( true );
|
|
372
|
-
|
|
373
362
|
act( () => {
|
|
374
|
-
readProbe().
|
|
363
|
+
readProbe().flushAutoSave();
|
|
375
364
|
} );
|
|
376
365
|
|
|
377
|
-
expect(
|
|
378
|
-
expect( readProbe().hasUncommittedChanges ).toBe( false );
|
|
379
|
-
expect( readProbe().gridSettings.model ).toBe( 'grid' );
|
|
366
|
+
expect( onLayoutChange ).toHaveBeenCalledTimes( 1 );
|
|
380
367
|
} );
|
|
381
368
|
|
|
382
|
-
it( '
|
|
369
|
+
it( 'flushes a pending edit on unmount instead of dropping it', () => {
|
|
383
370
|
const onLayoutChange = jest.fn();
|
|
384
|
-
const
|
|
385
|
-
render(
|
|
371
|
+
const { unmount } = render(
|
|
386
372
|
<Harness
|
|
387
373
|
layout={ initialLayout }
|
|
388
374
|
onLayoutChange={ onLayoutChange }
|
|
389
|
-
|
|
390
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
375
|
+
initialEditMode={ false }
|
|
391
376
|
/>
|
|
392
377
|
);
|
|
393
378
|
|
|
394
379
|
act( () => {
|
|
395
|
-
readProbe().mutate(
|
|
380
|
+
readProbe().mutate( moved );
|
|
381
|
+
readProbe().scheduleAutoSave();
|
|
396
382
|
} );
|
|
397
383
|
|
|
398
|
-
|
|
399
|
-
readProbe().commit();
|
|
400
|
-
} );
|
|
384
|
+
expect( onLayoutChange ).not.toHaveBeenCalled();
|
|
401
385
|
|
|
402
|
-
|
|
403
|
-
expect( onGridSettingsChange ).not.toHaveBeenCalled();
|
|
404
|
-
} );
|
|
405
|
-
} );
|
|
406
|
-
|
|
407
|
-
it( 'reverts only grid settings when cancel passes revertLayout: false', () => {
|
|
408
|
-
const onLayoutChange = jest.fn();
|
|
409
|
-
const onGridSettingsChange = jest.fn();
|
|
410
|
-
const initialSettings: WidgetGridSettings = {
|
|
411
|
-
model: 'grid',
|
|
412
|
-
minColumnWidth: 350,
|
|
413
|
-
rowHeight: 200,
|
|
414
|
-
};
|
|
415
|
-
render(
|
|
416
|
-
<Harness
|
|
417
|
-
layout={ initialLayout }
|
|
418
|
-
onLayoutChange={ onLayoutChange }
|
|
419
|
-
gridSettings={ initialSettings }
|
|
420
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
421
|
-
/>
|
|
422
|
-
);
|
|
386
|
+
unmount();
|
|
423
387
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
388
|
+
expect( onLayoutChange ).toHaveBeenCalledTimes( 1 );
|
|
389
|
+
expect(
|
|
390
|
+
onLayoutChange.mock.calls[ 0 ][ 0 ].map(
|
|
391
|
+
( w: DashboardWidget ) => w.uuid
|
|
392
|
+
)
|
|
393
|
+
).toEqual( [ 'b', 'a' ] );
|
|
430
394
|
} );
|
|
431
395
|
|
|
432
|
-
|
|
396
|
+
it( 'does not publish unscheduled staging on unmount', () => {
|
|
397
|
+
const onLayoutChange = jest.fn();
|
|
398
|
+
const { unmount } = render(
|
|
399
|
+
<Harness
|
|
400
|
+
layout={ initialLayout }
|
|
401
|
+
onLayoutChange={ onLayoutChange }
|
|
402
|
+
/>
|
|
403
|
+
);
|
|
433
404
|
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
exitEditMode: false,
|
|
437
|
-
revertLayout: false,
|
|
405
|
+
act( () => {
|
|
406
|
+
readProbe().mutate( moved );
|
|
438
407
|
} );
|
|
439
|
-
} );
|
|
440
408
|
|
|
441
|
-
|
|
442
|
-
expect( readProbe().layout ).toHaveLength( 1 );
|
|
443
|
-
expect( readProbe().gridSettings.minColumnWidth ).toBe( 350 );
|
|
444
|
-
} );
|
|
409
|
+
unmount();
|
|
445
410
|
|
|
446
|
-
|
|
447
|
-
const onLayoutChange = jest.fn();
|
|
448
|
-
render(
|
|
449
|
-
<Harness
|
|
450
|
-
layout={ initialLayout }
|
|
451
|
-
onLayoutChange={ onLayoutChange }
|
|
452
|
-
/>
|
|
453
|
-
);
|
|
454
|
-
|
|
455
|
-
act( () => {
|
|
456
|
-
readProbe().mutate( [ initialLayout[ 0 ] ] );
|
|
457
|
-
} );
|
|
458
|
-
|
|
459
|
-
act( () => {
|
|
460
|
-
readProbe().commit( { exitEditMode: false } );
|
|
411
|
+
expect( onLayoutChange ).not.toHaveBeenCalled();
|
|
461
412
|
} );
|
|
462
|
-
|
|
463
|
-
expect( readProbe().editMode ).toBe( true );
|
|
464
|
-
expect( onLayoutChange ).toHaveBeenCalledTimes( 1 );
|
|
465
|
-
|
|
466
|
-
act( () => {
|
|
467
|
-
readProbe().mutate( [ initialLayout[ 0 ] ] );
|
|
468
|
-
} );
|
|
469
|
-
|
|
470
|
-
act( () => {
|
|
471
|
-
readProbe().cancel( { exitEditMode: false } );
|
|
472
|
-
} );
|
|
473
|
-
|
|
474
|
-
expect( readProbe().editMode ).toBe( true );
|
|
475
413
|
} );
|
|
476
414
|
} );
|
|
@@ -45,6 +45,10 @@ const widgetTypes: WidgetType[] = [
|
|
|
45
45
|
apiVersion: 1,
|
|
46
46
|
name: 'test/greet',
|
|
47
47
|
title: 'Greet',
|
|
48
|
+
help: {
|
|
49
|
+
content: 'Greetings at a glance.',
|
|
50
|
+
links: [ { label: 'Learn more', href: 'options-general.php' } ],
|
|
51
|
+
},
|
|
48
52
|
renderModule: 'test-greet-module',
|
|
49
53
|
},
|
|
50
54
|
];
|
|
@@ -101,6 +105,26 @@ describe( 'WidgetDashboard', () => {
|
|
|
101
105
|
);
|
|
102
106
|
} );
|
|
103
107
|
|
|
108
|
+
it( 'surfaces the widget type help note in the header', async () => {
|
|
109
|
+
render( <Harness /> );
|
|
110
|
+
|
|
111
|
+
// The infotip trigger opens a popover holding the note.
|
|
112
|
+
await userEvent.click(
|
|
113
|
+
await screen.findByRole( 'button', {
|
|
114
|
+
name: 'More information',
|
|
115
|
+
} )
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
expect(
|
|
119
|
+
await screen.findByText( 'Greetings at a glance.' )
|
|
120
|
+
).toBeInTheDocument();
|
|
121
|
+
|
|
122
|
+
// The note's declared links render in the popover.
|
|
123
|
+
expect(
|
|
124
|
+
screen.getByRole( 'link', { name: 'Learn more' } )
|
|
125
|
+
).toBeInTheDocument();
|
|
126
|
+
} );
|
|
127
|
+
|
|
104
128
|
it( 'threads setAttributes into onLayoutChange on commit with merged attributes', async () => {
|
|
105
129
|
const onChange = jest.fn();
|
|
106
130
|
render( <Harness onLayoutChange={ onChange } /> );
|
package/src/types.ts
CHANGED
|
@@ -34,10 +34,10 @@ export type MasonryTilePlacement = Omit< DashboardLanesLayoutItem, 'key' >;
|
|
|
34
34
|
* Structurally a union of every supported per-model shape, but the
|
|
35
35
|
* intended invariant is stronger than the type suggests: every
|
|
36
36
|
* placement in a given layout must match the shape of the currently
|
|
37
|
-
* active `gridSettings.model`.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
37
|
+
* active `gridSettings.model`. Consumers that switch the model must
|
|
38
|
+
* supply placements in the new shape; the render layer is allowed to
|
|
39
|
+
* trust the active model and treat each placement as the matching
|
|
40
|
+
* shape.
|
|
41
41
|
*
|
|
42
42
|
* The type system cannot enforce that invariant on its own (there is
|
|
43
43
|
* no discriminator on the placement itself), so consider this union a
|
|
@@ -74,7 +74,7 @@ export interface DashboardWidget< Item = unknown > {
|
|
|
74
74
|
* Grid-model-specific placement (column/row spans, ordering,
|
|
75
75
|
* etc.). Must match the shape implied by the dashboard's active
|
|
76
76
|
* `gridSettings.model`; see `DashboardTilePlacement` for the
|
|
77
|
-
* invariant
|
|
77
|
+
* invariant.
|
|
78
78
|
*/
|
|
79
79
|
placement?: DashboardTilePlacement;
|
|
80
80
|
}
|
|
@@ -115,8 +115,8 @@ export type WidgetGridModel = 'grid' | 'masonry';
|
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* Maximum column count for the widget dashboard on wide containers.
|
|
118
|
-
* Not
|
|
119
|
-
*
|
|
118
|
+
* Not user-configurable; container width steps the count down to two
|
|
119
|
+
* and one column at fixed breakpoints.
|
|
120
120
|
*/
|
|
121
121
|
export const WIDGET_DASHBOARD_COLUMN_COUNT = 4;
|
|
122
122
|
|
|
@@ -244,17 +244,10 @@ export interface WidgetDashboardProps {
|
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
246
|
* Grid model configuration. See `WidgetGridSettings` for the shape.
|
|
247
|
+
* Read-only for the dashboard: the consumer owns the settings and
|
|
248
|
+
* their persistence.
|
|
247
249
|
*/
|
|
248
250
|
gridSettings?: WidgetGridSettings;
|
|
249
251
|
|
|
250
|
-
/**
|
|
251
|
-
* Called when the user commits in-progress grid-settings edits via
|
|
252
|
-
* the Done action. The dashboard maintains a staging copy of
|
|
253
|
-
* settings internally; mutations stay local until commit. When
|
|
254
|
-
* omitted, the `Layout settings` button in the customize toolbar is
|
|
255
|
-
* hidden, since there is nowhere to persist the change.
|
|
256
|
-
*/
|
|
257
|
-
onGridSettingsChange?: ( gridSettings: WidgetGridSettings ) => void;
|
|
258
|
-
|
|
259
252
|
children?: ReactNode;
|
|
260
253
|
}
|
package/src/utils/index.ts
CHANGED
package/src/widget-dashboard.tsx
CHANGED
|
@@ -5,7 +5,6 @@ import { WidgetDashboardProvider } from './context/dashboard-context';
|
|
|
5
5
|
import { WidgetDashboardUIProvider } from './context/ui-context';
|
|
6
6
|
import { Actions } from './components/actions';
|
|
7
7
|
import { Commands } from './components/commands';
|
|
8
|
-
import { LayoutSettings } from './components/layout-settings';
|
|
9
8
|
import { NoWidgetsState } from './components/no-widgets-state';
|
|
10
9
|
import { ResetConfirmation } from './components/reset-confirmation';
|
|
11
10
|
import { WidgetChrome } from './components/widget-chrome';
|
|
@@ -48,10 +47,10 @@ import type { WidgetDashboardProps } from './types';
|
|
|
48
47
|
*
|
|
49
48
|
* Children compose the dashboard's triggers and chrome: `Actions`,
|
|
50
49
|
* `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the
|
|
51
|
-
* widget inserter, the
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* widget inserter, the widget settings editor, the reset confirmation) are
|
|
51
|
+
* mounted by the engine and driven by shared UI state, so a trigger works
|
|
52
|
+
* wherever it is composed without a matching target in the tree. Omitting
|
|
53
|
+
* `children` renders the default arrangement.
|
|
55
54
|
*/
|
|
56
55
|
export const WidgetDashboard = Object.assign(
|
|
57
56
|
function WidgetDashboard( {
|
|
@@ -64,7 +63,6 @@ export const WidgetDashboard = Object.assign(
|
|
|
64
63
|
onEditChange,
|
|
65
64
|
resolveWidgetModule,
|
|
66
65
|
gridSettings,
|
|
67
|
-
onGridSettingsChange,
|
|
68
66
|
children,
|
|
69
67
|
}: WidgetDashboardProps ) {
|
|
70
68
|
return (
|
|
@@ -78,7 +76,6 @@ export const WidgetDashboard = Object.assign(
|
|
|
78
76
|
onEditChange={ onEditChange }
|
|
79
77
|
resolveWidgetModule={ resolveWidgetModule }
|
|
80
78
|
gridSettings={ gridSettings }
|
|
81
|
-
onGridSettingsChange={ onGridSettingsChange }
|
|
82
79
|
>
|
|
83
80
|
<WidgetDashboardUIProvider>
|
|
84
81
|
{ children ?? (
|
|
@@ -91,7 +88,6 @@ export const WidgetDashboard = Object.assign(
|
|
|
91
88
|
) }
|
|
92
89
|
|
|
93
90
|
<WidgetInserter />
|
|
94
|
-
<LayoutSettings />
|
|
95
91
|
<WidgetSettings />
|
|
96
92
|
<ResetConfirmation />
|
|
97
93
|
</WidgetDashboardUIProvider>
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// packages/widget-dashboard/src/components/layout-settings/layout-model-edit-field/index.tsx
|
|
31
|
-
var layout_model_edit_field_exports = {};
|
|
32
|
-
__export(layout_model_edit_field_exports, {
|
|
33
|
-
LayoutModelEditField: () => LayoutModelEditField
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(layout_model_edit_field_exports);
|
|
36
|
-
var import_clsx = __toESM(require("clsx"));
|
|
37
|
-
var import_element = require("@wordpress/element");
|
|
38
|
-
var import_ui = require("@wordpress/ui");
|
|
39
|
-
var import_thumbnail_grid = require("./thumbnail-grid.cjs");
|
|
40
|
-
var import_thumbnail_masonry = require("./thumbnail-masonry.cjs");
|
|
41
|
-
|
|
42
|
-
// packages/style-runtime/src/index.ts
|
|
43
|
-
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
44
|
-
function getRuntime() {
|
|
45
|
-
const globalScope = globalThis;
|
|
46
|
-
if (globalScope.__wpStyleRuntime) {
|
|
47
|
-
return globalScope.__wpStyleRuntime;
|
|
48
|
-
}
|
|
49
|
-
globalScope.__wpStyleRuntime = {
|
|
50
|
-
documents: /* @__PURE__ */ new Map(),
|
|
51
|
-
styles: /* @__PURE__ */ new Map(),
|
|
52
|
-
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
53
|
-
};
|
|
54
|
-
if (typeof document !== "undefined") {
|
|
55
|
-
registerDocument(document);
|
|
56
|
-
}
|
|
57
|
-
return globalScope.__wpStyleRuntime;
|
|
58
|
-
}
|
|
59
|
-
function documentContainsStyleHash(targetDocument, hash) {
|
|
60
|
-
if (!targetDocument.head) {
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
for (const style of targetDocument.head.querySelectorAll(
|
|
64
|
-
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
65
|
-
)) {
|
|
66
|
-
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
function injectStyle(targetDocument, hash, css) {
|
|
73
|
-
if (!targetDocument.head) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const runtime = getRuntime();
|
|
77
|
-
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
78
|
-
if (!injectedStyles) {
|
|
79
|
-
injectedStyles = /* @__PURE__ */ new Set();
|
|
80
|
-
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
81
|
-
}
|
|
82
|
-
if (injectedStyles.has(hash)) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
86
|
-
injectedStyles.add(hash);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const style = targetDocument.createElement("style");
|
|
90
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
91
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
92
|
-
targetDocument.head.appendChild(style);
|
|
93
|
-
injectedStyles.add(hash);
|
|
94
|
-
}
|
|
95
|
-
function registerDocument(targetDocument) {
|
|
96
|
-
const runtime = getRuntime();
|
|
97
|
-
runtime.documents.set(
|
|
98
|
-
targetDocument,
|
|
99
|
-
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
100
|
-
);
|
|
101
|
-
for (const [hash, css] of runtime.styles) {
|
|
102
|
-
injectStyle(targetDocument, hash, css);
|
|
103
|
-
}
|
|
104
|
-
return () => {
|
|
105
|
-
const count = runtime.documents.get(targetDocument);
|
|
106
|
-
if (count === void 0) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (count <= 1) {
|
|
110
|
-
runtime.documents.delete(targetDocument);
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
function registerStyle(hash, css) {
|
|
117
|
-
const runtime = getRuntime();
|
|
118
|
-
runtime.styles.set(hash, css);
|
|
119
|
-
for (const targetDocument of runtime.documents.keys()) {
|
|
120
|
-
injectStyle(targetDocument, hash, css);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// packages/widget-dashboard/src/components/layout-settings/layout-model-edit-field/style.module.css
|
|
125
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
126
|
-
registerStyle("1e741045ea", ".a197e5fadbd013d8__option{background:transparent;border:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral,#dbdbdb);border-radius:var(--wpds-border-radius-md,4px);color:inherit;cursor:var(--wpds-cursor-control,pointer);flex:1;padding:var(--wpds-dimension-padding-md,12px);text-align:center;transition:border-color var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1)),background-color var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}.a197e5fadbd013d8__option:hover{border-color:var(--wpds-color-stroke-surface-neutral-strong,#8d8d8d)}._90dfb85f4fe1f83c__optionSelected,._90dfb85f4fe1f83c__optionSelected:hover{background-color:color-mix(in srgb,var(--wpds-color-background-surface-brand,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 9%,#fff)) 6%,transparent);border-color:var(--wpds-color-stroke-interactive-brand,var(--wp-admin-theme-color,#3858e9))}._8dc1e0008b2c61a8__thumbnail{block-size:auto;color:var(--wpds-color-foreground-content-neutral-weak,#707070);display:block;inline-size:100%}._90dfb85f4fe1f83c__optionSelected ._8dc1e0008b2c61a8__thumbnail{color:var(--wpds-color-foreground-interactive-brand,var(--wp-admin-theme-color,#3858e9))}");
|
|
127
|
-
}
|
|
128
|
-
var style_default = { "option": "a197e5fadbd013d8__option", "optionSelected": "_90dfb85f4fe1f83c__optionSelected", "thumbnail": "_8dc1e0008b2c61a8__thumbnail" };
|
|
129
|
-
|
|
130
|
-
// packages/widget-dashboard/src/components/layout-settings/layout-model-edit-field/index.tsx
|
|
131
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
132
|
-
function ModelThumbnail({
|
|
133
|
-
model,
|
|
134
|
-
className
|
|
135
|
-
}) {
|
|
136
|
-
return model === "masonry" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_thumbnail_masonry.MasonryThumbnail, { className }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_thumbnail_grid.GridThumbnail, { className });
|
|
137
|
-
}
|
|
138
|
-
function LayoutModelEditField({
|
|
139
|
-
data,
|
|
140
|
-
field,
|
|
141
|
-
onChange
|
|
142
|
-
}) {
|
|
143
|
-
const { getValue, setValue, elements = [] } = field;
|
|
144
|
-
const value = getValue({ item: data });
|
|
145
|
-
const disabled = field.isDisabled({ item: data, field });
|
|
146
|
-
const onSelect = (0, import_element.useCallback)(
|
|
147
|
-
(nextValue) => onChange(setValue({ item: data, value: nextValue })),
|
|
148
|
-
[data, onChange, setValue]
|
|
149
|
-
);
|
|
150
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Fieldset.Root, { children: [
|
|
151
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Fieldset.Legend, { children: field.label }),
|
|
152
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Stack, { direction: "row", gap: "md", role: "radiogroup", children: elements.map((option) => {
|
|
153
|
-
const isSelected = value === option.value;
|
|
154
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
import_ui.Button,
|
|
156
|
-
{
|
|
157
|
-
variant: "unstyled",
|
|
158
|
-
role: "radio",
|
|
159
|
-
"aria-checked": isSelected,
|
|
160
|
-
disabled,
|
|
161
|
-
className: (0, import_clsx.default)(style_default.option, {
|
|
162
|
-
[style_default.optionSelected]: isSelected
|
|
163
|
-
}),
|
|
164
|
-
onClick: () => onSelect(option.value),
|
|
165
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_ui.Stack, { direction: "column", gap: "sm", align: "stretch", children: [
|
|
166
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
167
|
-
ModelThumbnail,
|
|
168
|
-
{
|
|
169
|
-
model: String(option.value),
|
|
170
|
-
className: style_default.thumbnail
|
|
171
|
-
}
|
|
172
|
-
),
|
|
173
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Text, { children: option.label })
|
|
174
|
-
] })
|
|
175
|
-
},
|
|
176
|
-
String(option.value)
|
|
177
|
-
);
|
|
178
|
-
}) }),
|
|
179
|
-
typeof field.description === "string" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Fieldset.Description, { children: field.description })
|
|
180
|
-
] });
|
|
181
|
-
}
|
|
182
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
183
|
-
0 && (module.exports = {
|
|
184
|
-
LayoutModelEditField
|
|
185
|
-
});
|
|
186
|
-
//# sourceMappingURL=index.cjs.map
|