@wordpress/widget-dashboard 0.1.1 → 0.3.1-next.v.202607070741.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 +24 -0
- package/README.md +10 -16
- package/build/components/actions/actions.cjs +2 -19
- 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 +16 -63
- 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 +173 -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/widgets.cjs +14 -7
- 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 +3 -20
- 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 +17 -70
- 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 +138 -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/widgets.mjs +14 -7
- 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/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.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 +4 -3
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -1
- package/build-types/components/widget-settings/widget-settings.d.ts +2 -2
- 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/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 +17 -17
- package/src/components/actions/actions.tsx +2 -22
- 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 +3 -68
- package/src/components/widget-chrome/widget-chrome.tsx +19 -130
- 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 +76 -0
- package/src/components/widget-header/widget-header.tsx +101 -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 +36 -43
- package/src/components/widget-settings/widget-settings.tsx +7 -26
- package/src/components/widget-toolbar/widget-toolbar.module.css +6 -9
- package/src/components/widget-toolbar/widget-toolbar.tsx +14 -8
- package/src/components/widgets/widgets.module.css +0 -1
- package/src/components/widgets/widgets.tsx +30 -8
- 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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/layout-settings/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
5
|
-
/**
|
|
6
|
-
* Internal dependencies
|
|
7
|
-
*/
|
|
8
|
-
import type { WidgetGridSettings } from '../../../types';
|
|
9
|
-
/**
|
|
10
|
-
* Card-style picker for the layout model: each option (`grid`, `masonry`)
|
|
11
|
-
* renders as a thumbnail card in a radio group. Wired as the `Edit` control
|
|
12
|
-
* for the `model` field of the layout settings DataForm.
|
|
13
|
-
*
|
|
14
|
-
* @param {DataFormControlProps< WidgetGridSettings >} props DataForm control props.
|
|
15
|
-
*/
|
|
16
|
-
export declare function LayoutModelEditField({ data, field, onChange }: DataFormControlProps<WidgetGridSettings>): React.ReactNode;
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layout-settings/layout-model-edit-field/index.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAMjE;;GAEG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAqBzD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAE,EACrC,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,EAAE,oBAAoB,CAAE,kBAAkB,CAAE,GAAI,KAAK,CAAC,SAAS,CAgD/D"}
|
package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thumbnail-grid.d.ts","sourceRoot":"","sources":["../../../../src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx"],"names":[],"mappings":"AAKA,UAAU,kBAAkB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,aAAa,CAAE,EAC9B,SAAS,EACT,EAAE,kBAAkB,GAAI,KAAK,CAAC,SAAS,CAgBvC"}
|
package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"thumbnail-masonry.d.ts","sourceRoot":"","sources":["../../../../src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx"],"names":[],"mappings":"AAKA,UAAU,qBAAqB;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAE,EACjC,SAAS,EACT,EAAE,qBAAqB,GAAI,KAAK,CAAC,SAAS,CAgB1C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modal side drawer for grid-level settings (layout model and row height),
|
|
3
|
-
* mounted by the engine and shown while `layoutSettingsOpen` is set in the
|
|
4
|
-
* shared UI context. Renders nothing when grid settings are not editable.
|
|
5
|
-
*
|
|
6
|
-
* Edits, including Reset, apply to the staging copy and preview live behind
|
|
7
|
-
* the drawer. Save commits them; Cancel and any other dismissal (X, Escape)
|
|
8
|
-
* revert them. Either way only grid settings change, so in-progress widget
|
|
9
|
-
* layout edits survive and customize mode stays active.
|
|
10
|
-
*
|
|
11
|
-
* Tile gap is deliberately not exposed; spacing stays a design-system concern.
|
|
12
|
-
*/
|
|
13
|
-
export declare function LayoutSettings(): React.ReactNode;
|
|
14
|
-
//# sourceMappingURL=layout-settings.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layout-settings.d.ts","sourceRoot":"","sources":["../../../src/components/layout-settings/layout-settings.tsx"],"names":[],"mappings":"AAiFA;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,KAAK,CAAC,SAAS,CA2HhD"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Width, in pixels, taken up by the WordPress admin menu
|
|
3
|
-
* (`#adminmenuback`) on the inline-start edge of the viewport.
|
|
4
|
-
*
|
|
5
|
-
* The settings drawer portals to the document body and anchors to a
|
|
6
|
-
* viewport edge, so a left-anchored drawer would slide over the fixed
|
|
7
|
-
* admin menu. Offsetting the drawer by this value keeps the menu
|
|
8
|
-
* uncovered (and reachable) instead of raising the drawer's z-index over
|
|
9
|
-
* it.
|
|
10
|
-
*
|
|
11
|
-
* Defensive: returns `0` when the element is absent (outside wp-admin, or
|
|
12
|
-
* in tests/Storybook), so the drawer just anchors to the viewport edge.
|
|
13
|
-
*
|
|
14
|
-
* @return {number} The admin menu's right edge in px, or `0`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function getAdminMenuInset(): number;
|
|
17
|
-
//# sourceMappingURL=get-admin-menu-inset.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-admin-menu-inset.d.ts","sourceRoot":"","sources":["../../../../src/components/widget-settings/utils/get-admin-menu-inset.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAW1C"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
5
|
-
import type { DashboardWidget } from '../../types';
|
|
6
|
-
export interface WidgetSettingsToolbarProps {
|
|
7
|
-
/** The instance whose settings this toolbar configures. */
|
|
8
|
-
widget: DashboardWidget<unknown>;
|
|
9
|
-
/** The instance's widget type, for the trigger label and guard. */
|
|
10
|
-
widgetType: WidgetType;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Normal-mode per-tile toolbar: the gear that opens the settings drawer. Lives
|
|
14
|
-
* in the grid's `actionableArea` slot, so it shows for every `presentation`.
|
|
15
|
-
* Returns `null` when the type has no attributes.
|
|
16
|
-
*
|
|
17
|
-
* @param {WidgetSettingsToolbarProps} props Component props.
|
|
18
|
-
*/
|
|
19
|
-
export declare function WidgetSettingsToolbar({ widget, widgetType }: WidgetSettingsToolbarProps): React.ReactNode;
|
|
20
|
-
//# sourceMappingURL=widget-settings-toolbar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widget-settings-toolbar.d.ts","sourceRoot":"","sources":["../../../src/components/widget-settings/widget-settings-toolbar.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAQ/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,MAAM,WAAW,0BAA0B;IAC1C,2DAA2D;IAC3D,MAAM,EAAE,eAAe,CAAE,OAAO,CAAE,CAAC;IAEnC,mEAAmE;IACnE,UAAU,EAAE,UAAU,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAE,EACtC,MAAM,EACN,UAAU,EACV,EAAE,0BAA0B,GAAI,KAAK,CAAC,SAAS,CAa/C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DashboardWidget } from '../../types';
|
|
2
|
-
export interface WidgetLayoutToolbarProps {
|
|
3
|
-
/** The instance this toolbar manages within the layout. */
|
|
4
|
-
widget: DashboardWidget<unknown>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Customize-mode per-tile toolbar: a width menu and removal, editing the
|
|
8
|
-
* widget's place in the layout. Lives in the grid's `actionableArea` slot, so
|
|
9
|
-
* it stays interactive while the card is `inert`.
|
|
10
|
-
*
|
|
11
|
-
* @param {WidgetLayoutToolbarProps} props Component props.
|
|
12
|
-
*/
|
|
13
|
-
export declare function WidgetLayoutToolbar({ widget }: WidgetLayoutToolbarProps): React.ReactNode;
|
|
14
|
-
//# sourceMappingURL=widget-layout-toolbar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widget-layout-toolbar.d.ts","sourceRoot":"","sources":["../../../src/components/widgets/widget-layout-toolbar.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,aAAa,CAAC;AAStE,MAAM,WAAW,wBAAwB;IACxC,2DAA2D;IAC3D,MAAM,EAAE,eAAe,CAAE,OAAO,CAAE,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAE,EACpC,MAAM,EACN,EAAE,wBAAwB,GAAI,KAAK,CAAC,SAAS,CA6E7C"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DashboardWidget, WidgetGridModel, WidgetGridSettings } from '../../types';
|
|
2
|
-
export declare function getGridModel(settings: WidgetGridSettings): WidgetGridModel;
|
|
3
|
-
type ComputeGridModelChangeProps = {
|
|
4
|
-
layout: DashboardWidget[];
|
|
5
|
-
gridSettings: WidgetGridSettings;
|
|
6
|
-
targetModel: WidgetGridModel;
|
|
7
|
-
};
|
|
8
|
-
type ComputeGridModelChangeResult = {
|
|
9
|
-
layout: DashboardWidget[];
|
|
10
|
-
gridSettings: WidgetGridSettings;
|
|
11
|
-
} | null;
|
|
12
|
-
/**
|
|
13
|
-
* Computes the staged layout and grid settings after a layout-model change.
|
|
14
|
-
*
|
|
15
|
-
* @param {ComputeGridModelChangeProps} params Layout, current settings, and target model.
|
|
16
|
-
* @return {ComputeGridModelChangeResult} Migrated layout and settings, or `null` when the model is unchanged.
|
|
17
|
-
*/
|
|
18
|
-
export declare function computeGridModelChange({ layout, gridSettings, targetModel }: ComputeGridModelChangeProps): ComputeGridModelChangeResult;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=grid-model-change.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grid-model-change.d.ts","sourceRoot":"","sources":["../../../src/utils/grid-model-change/grid-model-change.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACX,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,MAAM,aAAa,CAAC;AAGrB,wBAAgB,YAAY,CAAE,QAAQ,EAAE,kBAAkB,GAAI,eAAe,CAE5E;AAED,KAAK,2BAA2B,GAAG;IAClC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,YAAY,EAAE,kBAAkB,CAAC;IACjC,WAAW,EAAE,eAAe,CAAC;CAC7B,CAAC;AAEF,KAAK,4BAA4B,GAAG;IACnC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,YAAY,EAAE,kBAAkB,CAAC;CACjC,GAAG,IAAI,CAAC;AAET;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAE,EACvC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,EAAE,2BAA2B,GAAI,4BAA4B,CAgB7D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/grid-model-change/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/migrate-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import type { DashboardWidget, WidgetGridModel } from '../../types';
|
|
5
|
-
interface MigrationContext {
|
|
6
|
-
/**
|
|
7
|
-
* Column count of the currently-mounted grid surface. Used to
|
|
8
|
-
* resolve `'full'` widths to a concrete numeric span when going
|
|
9
|
-
* from the 2D grid model to masonry. When the surface is in
|
|
10
|
-
* responsive mode and the runtime column count is unknown,
|
|
11
|
-
* callers should pass a sensible fallback (e.g., the default of
|
|
12
|
-
* 6 used by `@wordpress/grid`).
|
|
13
|
-
*/
|
|
14
|
-
columns: number;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Migrates every widget's `placement` between grid models.
|
|
18
|
-
*
|
|
19
|
-
* The two storage shapes overlap on `width` and `order` but diverge
|
|
20
|
-
* on the rest: 2D grid carries `height` and discriminated string
|
|
21
|
-
* widths (`'fill'`/`'full'`), lanes carries `lane` and only numeric
|
|
22
|
-
* widths. Each conversion loses information that the target model
|
|
23
|
-
* cannot represent. The caller is responsible for surfacing the
|
|
24
|
-
* result to the user in a way that lets them correct visually.
|
|
25
|
-
*
|
|
26
|
-
* When `from === to`, the input is returned unchanged.
|
|
27
|
-
*
|
|
28
|
-
* @param widgets Widgets to migrate.
|
|
29
|
-
* @param from Source model. `undefined` is treated as `'grid'`.
|
|
30
|
-
* @param to Target model.
|
|
31
|
-
* @param context Information that depends on the live render (today
|
|
32
|
-
* only `columns`).
|
|
33
|
-
*/
|
|
34
|
-
export declare function migrateLayout(widgets: DashboardWidget[], from: WidgetGridModel | undefined, to: WidgetGridModel, context?: Partial<MigrationContext>): DashboardWidget[];
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=migrate-layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-layout.d.ts","sourceRoot":"","sources":["../../../src/utils/migrate-layout/migrate-layout.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EACX,eAAe,EAGf,eAAe,EACf,MAAM,aAAa,CAAC;AAErB,UAAU,gBAAgB;IACzB;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;CAChB;AAkFD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,eAAe,EAAE,EAC1B,IAAI,EAAE,eAAe,GAAG,SAAS,EACjC,EAAE,EAAE,eAAe,EACnB,OAAO,GAAE,OAAO,CAAE,gBAAgB,CAAO,GACvC,eAAe,EAAE,CA8BnB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { LayoutSettings } from './layout-settings';
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import type { DataFormControlProps } from '@wordpress/dataviews';
|
|
10
|
-
import { useCallback } from '@wordpress/element';
|
|
11
|
-
/* eslint-disable @wordpress/use-recommended-components */
|
|
12
|
-
import { Button, Fieldset, Stack, Text } from '@wordpress/ui';
|
|
13
|
-
/* eslint-enable @wordpress/use-recommended-components */
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import type { WidgetGridSettings } from '../../../types';
|
|
19
|
-
import { GridThumbnail } from './thumbnail-grid';
|
|
20
|
-
import { MasonryThumbnail } from './thumbnail-masonry';
|
|
21
|
-
import styles from './style.module.css';
|
|
22
|
-
|
|
23
|
-
interface ModelThumbnailProps {
|
|
24
|
-
model: string;
|
|
25
|
-
className?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function ModelThumbnail( {
|
|
29
|
-
model,
|
|
30
|
-
className,
|
|
31
|
-
}: ModelThumbnailProps ): React.ReactNode {
|
|
32
|
-
return model === 'masonry' ? (
|
|
33
|
-
<MasonryThumbnail className={ className } />
|
|
34
|
-
) : (
|
|
35
|
-
<GridThumbnail className={ className } />
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Card-style picker for the layout model: each option (`grid`, `masonry`)
|
|
41
|
-
* renders as a thumbnail card in a radio group. Wired as the `Edit` control
|
|
42
|
-
* for the `model` field of the layout settings DataForm.
|
|
43
|
-
*
|
|
44
|
-
* @param {DataFormControlProps< WidgetGridSettings >} props DataForm control props.
|
|
45
|
-
*/
|
|
46
|
-
export function LayoutModelEditField( {
|
|
47
|
-
data,
|
|
48
|
-
field,
|
|
49
|
-
onChange,
|
|
50
|
-
}: DataFormControlProps< WidgetGridSettings > ): React.ReactNode {
|
|
51
|
-
const { getValue, setValue, elements = [] } = field;
|
|
52
|
-
const value = getValue( { item: data } );
|
|
53
|
-
const disabled = field.isDisabled( { item: data, field } );
|
|
54
|
-
|
|
55
|
-
const onSelect = useCallback(
|
|
56
|
-
( nextValue: string | number | undefined ) =>
|
|
57
|
-
onChange( setValue( { item: data, value: nextValue } ) ),
|
|
58
|
-
[ data, onChange, setValue ]
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<Fieldset.Root>
|
|
63
|
-
<Fieldset.Legend>{ field.label }</Fieldset.Legend>
|
|
64
|
-
<Stack direction="row" gap="md" role="radiogroup">
|
|
65
|
-
{ elements.map( ( option ) => {
|
|
66
|
-
const isSelected = value === option.value;
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<Button
|
|
70
|
-
key={ String( option.value ) }
|
|
71
|
-
variant="unstyled"
|
|
72
|
-
role="radio"
|
|
73
|
-
aria-checked={ isSelected }
|
|
74
|
-
disabled={ disabled }
|
|
75
|
-
className={ clsx( styles.option, {
|
|
76
|
-
[ styles.optionSelected ]: isSelected,
|
|
77
|
-
} ) }
|
|
78
|
-
onClick={ () => onSelect( option.value ) }
|
|
79
|
-
>
|
|
80
|
-
<Stack direction="column" gap="sm" align="stretch">
|
|
81
|
-
<ModelThumbnail
|
|
82
|
-
model={ String( option.value ) }
|
|
83
|
-
className={ styles.thumbnail }
|
|
84
|
-
/>
|
|
85
|
-
<Text>{ option.label }</Text>
|
|
86
|
-
</Stack>
|
|
87
|
-
</Button>
|
|
88
|
-
);
|
|
89
|
-
} ) }
|
|
90
|
-
</Stack>
|
|
91
|
-
{ typeof field.description === 'string' && (
|
|
92
|
-
<Fieldset.Description>
|
|
93
|
-
{ field.description }
|
|
94
|
-
</Fieldset.Description>
|
|
95
|
-
) }
|
|
96
|
-
</Fieldset.Root>
|
|
97
|
-
);
|
|
98
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
.option {
|
|
2
|
-
flex: 1;
|
|
3
|
-
padding: var(--wpds-dimension-padding-md);
|
|
4
|
-
border: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral);
|
|
5
|
-
border-radius: var(--wpds-border-radius-md);
|
|
6
|
-
background: transparent;
|
|
7
|
-
color: inherit;
|
|
8
|
-
cursor: var(--wpds-cursor-control);
|
|
9
|
-
text-align: center;
|
|
10
|
-
transition:
|
|
11
|
-
border-color var(--wpds-motion-duration-sm) var(--wpds-motion-easing-subtle),
|
|
12
|
-
background-color var(--wpds-motion-duration-sm) var(--wpds-motion-easing-subtle);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.option:hover {
|
|
16
|
-
border-color: var(--wpds-color-stroke-surface-neutral-strong);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.optionSelected,
|
|
20
|
-
.optionSelected:hover {
|
|
21
|
-
border-color: var(--wpds-color-stroke-interactive-brand);
|
|
22
|
-
background-color: color-mix(in srgb, var(--wpds-color-background-surface-brand) 6%, transparent);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.thumbnail {
|
|
26
|
-
display: block;
|
|
27
|
-
inline-size: 100%;
|
|
28
|
-
block-size: auto;
|
|
29
|
-
color: var(--wpds-color-foreground-content-neutral-weak);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.optionSelected .thumbnail {
|
|
33
|
-
color: var(--wpds-color-foreground-interactive-brand);
|
|
34
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { SVG, Rect } from '@wordpress/primitives';
|
|
5
|
-
|
|
6
|
-
interface GridThumbnailProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function GridThumbnail( {
|
|
11
|
-
className,
|
|
12
|
-
}: GridThumbnailProps ): React.ReactNode {
|
|
13
|
-
return (
|
|
14
|
-
<SVG
|
|
15
|
-
className={ className }
|
|
16
|
-
viewBox="0 0 40 24"
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
aria-hidden="true"
|
|
19
|
-
>
|
|
20
|
-
<Rect x="2" y="1.25" width="11" height="10" rx="1.5" />
|
|
21
|
-
<Rect x="14.5" y="1.25" width="11" height="10" rx="1.5" />
|
|
22
|
-
<Rect x="27" y="1.25" width="11" height="10" rx="1.5" />
|
|
23
|
-
<Rect x="2" y="12.75" width="11" height="10" rx="1.5" />
|
|
24
|
-
<Rect x="14.5" y="12.75" width="11" height="10" rx="1.5" />
|
|
25
|
-
<Rect x="27" y="12.75" width="11" height="10" rx="1.5" />
|
|
26
|
-
</SVG>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { SVG, Rect } from '@wordpress/primitives';
|
|
5
|
-
|
|
6
|
-
interface MasonryThumbnailProps {
|
|
7
|
-
className?: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function MasonryThumbnail( {
|
|
11
|
-
className,
|
|
12
|
-
}: MasonryThumbnailProps ): React.ReactNode {
|
|
13
|
-
return (
|
|
14
|
-
<SVG
|
|
15
|
-
className={ className }
|
|
16
|
-
viewBox="0 0 40 24"
|
|
17
|
-
fill="currentColor"
|
|
18
|
-
aria-hidden="true"
|
|
19
|
-
>
|
|
20
|
-
<Rect x="2" y="0.75" width="11" height="13" rx="1.5" />
|
|
21
|
-
<Rect x="2" y="15.25" width="11" height="8" rx="1.5" />
|
|
22
|
-
<Rect x="14.5" y="0.75" width="11" height="8" rx="1.5" />
|
|
23
|
-
<Rect x="14.5" y="10.25" width="11" height="13" rx="1.5" />
|
|
24
|
-
<Rect x="27" y="0.75" width="11" height="10" rx="1.5" />
|
|
25
|
-
<Rect x="27" y="12.25" width="11" height="11" rx="1.5" />
|
|
26
|
-
</SVG>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { DataForm } from '@wordpress/dataviews';
|
|
5
|
-
import type { Field, Form } from '@wordpress/dataviews';
|
|
6
|
-
import { useCallback, useEffect } from '@wordpress/element';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { Button, Drawer } from '@wordpress/ui'; // eslint-disable-line @wordpress/use-recommended-components
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
13
|
-
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
14
|
-
import { useDashboardUIContext } from '../../context/ui-context';
|
|
15
|
-
import { migrateLayout } from '../../utils/migrate-layout';
|
|
16
|
-
import {
|
|
17
|
-
presetToRowHeight,
|
|
18
|
-
rowHeightToPreset,
|
|
19
|
-
type RowHeightPreset,
|
|
20
|
-
} from '../../utils/row-height-presets';
|
|
21
|
-
import {
|
|
22
|
-
WIDGET_DASHBOARD_COLUMN_COUNT,
|
|
23
|
-
type WidgetGridLayoutSettings,
|
|
24
|
-
type WidgetGridModel,
|
|
25
|
-
type WidgetGridSettings,
|
|
26
|
-
} from '../../types';
|
|
27
|
-
import { LayoutModelEditField } from './layout-model-edit-field';
|
|
28
|
-
|
|
29
|
-
function getModel( item: WidgetGridSettings ): WidgetGridModel {
|
|
30
|
-
return item.model ?? 'grid';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function isMasonry( item: WidgetGridSettings ): boolean {
|
|
34
|
-
return getModel( item ) === 'masonry';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const fields: Field< WidgetGridSettings >[] = [
|
|
38
|
-
{
|
|
39
|
-
id: 'model',
|
|
40
|
-
type: 'text',
|
|
41
|
-
Edit: LayoutModelEditField,
|
|
42
|
-
label: __( 'Layout model' ),
|
|
43
|
-
description: __(
|
|
44
|
-
'Grid keeps every tile the same height. Masonry lets tiles flow at their own height.'
|
|
45
|
-
),
|
|
46
|
-
elements: [
|
|
47
|
-
{ value: 'grid', label: __( 'Standard grid' ) },
|
|
48
|
-
{ value: 'masonry', label: __( 'Masonry' ) },
|
|
49
|
-
],
|
|
50
|
-
getValue: ( { item } ) => getModel( item ),
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: 'rowHeight',
|
|
54
|
-
type: 'text',
|
|
55
|
-
Edit: 'toggleGroup',
|
|
56
|
-
label: __( 'Row height' ),
|
|
57
|
-
description: __( 'Height of each grid row.' ),
|
|
58
|
-
elements: [
|
|
59
|
-
{ value: 'small', label: __( 'Small' ) },
|
|
60
|
-
{ value: 'medium', label: __( 'Medium' ) },
|
|
61
|
-
{ value: 'large', label: __( 'Large' ) },
|
|
62
|
-
],
|
|
63
|
-
getValue: ( { item } ) => {
|
|
64
|
-
const rowHeight = ( item as WidgetGridLayoutSettings ).rowHeight;
|
|
65
|
-
if ( typeof rowHeight !== 'number' ) {
|
|
66
|
-
return 'medium';
|
|
67
|
-
}
|
|
68
|
-
return rowHeightToPreset( rowHeight );
|
|
69
|
-
},
|
|
70
|
-
setValue: ( { value } ) => ( {
|
|
71
|
-
rowHeight: presetToRowHeight( value as RowHeightPreset ),
|
|
72
|
-
} ),
|
|
73
|
-
isVisible: ( item ) => ! isMasonry( item ),
|
|
74
|
-
},
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
const form: Form = {
|
|
78
|
-
layout: { type: 'regular', labelPosition: 'top' },
|
|
79
|
-
fields: [ 'model', 'rowHeight' ],
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Modal side drawer for grid-level settings (layout model and row height),
|
|
84
|
-
* mounted by the engine and shown while `layoutSettingsOpen` is set in the
|
|
85
|
-
* shared UI context. Renders nothing when grid settings are not editable.
|
|
86
|
-
*
|
|
87
|
-
* Edits, including Reset, apply to the staging copy and preview live behind
|
|
88
|
-
* the drawer. Save commits them; Cancel and any other dismissal (X, Escape)
|
|
89
|
-
* revert them. Either way only grid settings change, so in-progress widget
|
|
90
|
-
* layout edits survive and customize mode stays active.
|
|
91
|
-
*
|
|
92
|
-
* Tile gap is deliberately not exposed; spacing stays a design-system concern.
|
|
93
|
-
*/
|
|
94
|
-
export function LayoutSettings(): React.ReactNode {
|
|
95
|
-
const {
|
|
96
|
-
gridSettings,
|
|
97
|
-
onGridSettingsChange,
|
|
98
|
-
layout,
|
|
99
|
-
onLayoutChange,
|
|
100
|
-
commit,
|
|
101
|
-
cancel: cancelStaging,
|
|
102
|
-
resetGridSettings,
|
|
103
|
-
hasUncommittedChanges,
|
|
104
|
-
canEditGridSettings,
|
|
105
|
-
editMode,
|
|
106
|
-
} = useDashboardInternalContext();
|
|
107
|
-
|
|
108
|
-
const { layoutSettingsOpen: open, setLayoutSettingsOpen: onOpenChange } =
|
|
109
|
-
useDashboardUIContext();
|
|
110
|
-
|
|
111
|
-
// Close when customize mode exits, whatever the exit path.
|
|
112
|
-
useEffect( () => {
|
|
113
|
-
if ( ! editMode && open ) {
|
|
114
|
-
onOpenChange( false );
|
|
115
|
-
}
|
|
116
|
-
}, [ editMode, open, onOpenChange ] );
|
|
117
|
-
|
|
118
|
-
const handleChange = useCallback(
|
|
119
|
-
( edits: Record< string, unknown > ) => {
|
|
120
|
-
const nextModel = edits.model as WidgetGridModel | undefined;
|
|
121
|
-
const currentModel = getModel( gridSettings );
|
|
122
|
-
|
|
123
|
-
if ( nextModel && nextModel !== currentModel ) {
|
|
124
|
-
const migrated = migrateLayout(
|
|
125
|
-
layout,
|
|
126
|
-
currentModel,
|
|
127
|
-
nextModel,
|
|
128
|
-
{ columns: WIDGET_DASHBOARD_COLUMN_COUNT }
|
|
129
|
-
);
|
|
130
|
-
onLayoutChange( migrated );
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
onGridSettingsChange( {
|
|
134
|
-
...gridSettings,
|
|
135
|
-
...edits,
|
|
136
|
-
} as WidgetGridSettings );
|
|
137
|
-
},
|
|
138
|
-
[ gridSettings, layout, onGridSettingsChange, onLayoutChange ]
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
const handleCancel = useCallback( () => {
|
|
142
|
-
cancelStaging( { exitEditMode: false, revertLayout: false } );
|
|
143
|
-
onOpenChange( false );
|
|
144
|
-
}, [ cancelStaging, onOpenChange ] );
|
|
145
|
-
|
|
146
|
-
const handleSave = useCallback( () => {
|
|
147
|
-
commit( { exitEditMode: false } );
|
|
148
|
-
onOpenChange( false );
|
|
149
|
-
}, [ commit, onOpenChange ] );
|
|
150
|
-
|
|
151
|
-
const handleOpenChange = useCallback(
|
|
152
|
-
( nextOpen: boolean ) => {
|
|
153
|
-
if ( ! nextOpen && open ) {
|
|
154
|
-
cancelStaging( { exitEditMode: false, revertLayout: false } );
|
|
155
|
-
}
|
|
156
|
-
onOpenChange( nextOpen );
|
|
157
|
-
},
|
|
158
|
-
[ open, cancelStaging, onOpenChange ]
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
if ( ! canEditGridSettings ) {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<Drawer.Root
|
|
167
|
-
open={ open }
|
|
168
|
-
onOpenChange={ handleOpenChange }
|
|
169
|
-
swipeDirection="right"
|
|
170
|
-
>
|
|
171
|
-
<Drawer.Popup size="medium" style={ { marginTop: '32px' } }>
|
|
172
|
-
<Drawer.Header>
|
|
173
|
-
<Drawer.Title>{ __( 'Layout settings' ) }</Drawer.Title>
|
|
174
|
-
<Drawer.CloseIcon />
|
|
175
|
-
</Drawer.Header>
|
|
176
|
-
|
|
177
|
-
<Drawer.Content>
|
|
178
|
-
<DataForm
|
|
179
|
-
data={ gridSettings }
|
|
180
|
-
fields={ fields }
|
|
181
|
-
form={ form }
|
|
182
|
-
onChange={ handleChange }
|
|
183
|
-
/>
|
|
184
|
-
</Drawer.Content>
|
|
185
|
-
|
|
186
|
-
<Drawer.Footer>
|
|
187
|
-
<Button
|
|
188
|
-
variant="minimal"
|
|
189
|
-
tone="neutral"
|
|
190
|
-
size="compact"
|
|
191
|
-
onClick={ resetGridSettings }
|
|
192
|
-
style={ { marginInlineEnd: 'auto' } }
|
|
193
|
-
>
|
|
194
|
-
{ __( 'Reset' ) }
|
|
195
|
-
</Button>
|
|
196
|
-
<Button
|
|
197
|
-
variant="minimal"
|
|
198
|
-
tone="brand"
|
|
199
|
-
size="compact"
|
|
200
|
-
onClick={ handleCancel }
|
|
201
|
-
>
|
|
202
|
-
{ __( 'Cancel' ) }
|
|
203
|
-
</Button>
|
|
204
|
-
<Button
|
|
205
|
-
variant="solid"
|
|
206
|
-
tone="brand"
|
|
207
|
-
size="compact"
|
|
208
|
-
onClick={ handleSave }
|
|
209
|
-
disabled={ ! hasUncommittedChanges }
|
|
210
|
-
>
|
|
211
|
-
{ __( 'Save' ) }
|
|
212
|
-
</Button>
|
|
213
|
-
</Drawer.Footer>
|
|
214
|
-
</Drawer.Popup>
|
|
215
|
-
</Drawer.Root>
|
|
216
|
-
);
|
|
217
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
.preview {
|
|
2
|
-
width: 125%;
|
|
3
|
-
height: 125%;
|
|
4
|
-
overflow: hidden;
|
|
5
|
-
padding: 0;
|
|
6
|
-
transform: scale(0.8);
|
|
7
|
-
transform-origin: top left;
|
|
8
|
-
/* Let clicks and hovers reach the picker tile, not links inside the preview. */
|
|
9
|
-
pointer-events: none;
|
|
10
|
-
user-select: none;
|
|
11
|
-
}
|