@wordpress/widget-dashboard 0.1.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 +19 -0
- package/LICENSE.md +788 -0
- package/README.md +241 -0
- package/build/components/actions/actions.cjs +265 -0
- package/build/components/actions/actions.cjs.map +7 -0
- package/build/components/actions/index.cjs +31 -0
- package/build/components/actions/index.cjs.map +7 -0
- package/build/components/actions-menu/actions-menu.cjs +92 -0
- package/build/components/actions-menu/actions-menu.cjs.map +7 -0
- package/build/components/actions-menu/index.cjs +31 -0
- package/build/components/actions-menu/index.cjs.map +7 -0
- package/build/components/commands/commands.cjs +177 -0
- package/build/components/commands/commands.cjs.map +7 -0
- package/build/components/commands/index.cjs +33 -0
- package/build/components/commands/index.cjs.map +7 -0
- package/build/components/commands/use-pending-when-edit-mode.cjs +57 -0
- package/build/components/commands/use-pending-when-edit-mode.cjs.map +7 -0
- package/build/components/layout-settings/index.cjs +31 -0
- package/build/components/layout-settings/index.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/index.cjs +186 -0
- package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +53 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +53 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +7 -0
- package/build/components/layout-settings/layout-settings.cjs +207 -0
- package/build/components/layout-settings/layout-settings.cjs.map +7 -0
- package/build/components/no-widgets-state/index.cjs +31 -0
- package/build/components/no-widgets-state/index.cjs.map +7 -0
- package/build/components/no-widgets-state/no-widgets-state.cjs +140 -0
- package/build/components/no-widgets-state/no-widgets-state.cjs.map +7 -0
- package/build/components/reset-confirmation/index.cjs +31 -0
- package/build/components/reset-confirmation/index.cjs.map +7 -0
- package/build/components/reset-confirmation/reset-confirmation.cjs +62 -0
- package/build/components/reset-confirmation/reset-confirmation.cjs.map +7 -0
- package/build/components/widget-chrome/index.cjs +31 -0
- package/build/components/widget-chrome/index.cjs.map +7 -0
- package/build/components/widget-chrome/widget-chrome.cjs +277 -0
- package/build/components/widget-chrome/widget-chrome.cjs.map +7 -0
- package/build/components/widget-inserter/index.cjs +31 -0
- package/build/components/widget-inserter/index.cjs.map +7 -0
- package/build/components/widget-inserter/widget-inserter.cjs +78 -0
- package/build/components/widget-inserter/widget-inserter.cjs.map +7 -0
- package/build/components/widget-picker/index.cjs +31 -0
- package/build/components/widget-picker/index.cjs.map +7 -0
- package/build/components/widget-picker/widget-picker.cjs +209 -0
- package/build/components/widget-picker/widget-picker.cjs.map +7 -0
- package/build/components/widget-render/index.cjs +31 -0
- package/build/components/widget-render/index.cjs.map +7 -0
- package/build/components/widget-render/widget-render.cjs +62 -0
- package/build/components/widget-render/widget-render.cjs.map +7 -0
- package/build/components/widget-settings/index.cjs +37 -0
- package/build/components/widget-settings/index.cjs.map +7 -0
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs +41 -0
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +7 -0
- package/build/components/widget-settings/utils/get-widget-settings.cjs +38 -0
- package/build/components/widget-settings/utils/get-widget-settings.cjs.map +7 -0
- package/build/components/widget-settings/utils/index.cjs +34 -0
- package/build/components/widget-settings/utils/index.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings-toolbar.cjs +138 -0
- package/build/components/widget-settings/widget-settings-toolbar.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings-trigger.cjs +82 -0
- package/build/components/widget-settings/widget-settings-trigger.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings.cjs +269 -0
- package/build/components/widget-settings/widget-settings.cjs.map +7 -0
- package/build/components/widget-toolbar/index.cjs +31 -0
- package/build/components/widget-toolbar/index.cjs.map +7 -0
- package/build/components/widget-toolbar/widget-toolbar.cjs +148 -0
- package/build/components/widget-toolbar/widget-toolbar.cjs.map +7 -0
- package/build/components/widgets/index.cjs +31 -0
- package/build/components/widgets/index.cjs.map +7 -0
- package/build/components/widgets/widget-layout-toolbar.cjs +206 -0
- package/build/components/widgets/widget-layout-toolbar.cjs.map +7 -0
- package/build/components/widgets/widget-resize-handle.cjs +163 -0
- package/build/components/widgets/widget-resize-handle.cjs.map +7 -0
- package/build/components/widgets/widgets.cjs +277 -0
- package/build/components/widgets/widgets.cjs.map +7 -0
- package/build/context/dashboard-context.cjs +234 -0
- package/build/context/dashboard-context.cjs.map +7 -0
- package/build/context/ui-context.cjs +77 -0
- package/build/context/ui-context.cjs.map +7 -0
- package/build/context/widget-context.cjs +44 -0
- package/build/context/widget-context.cjs.map +7 -0
- package/build/hooks/use-dashboard-container-column-count.cjs +61 -0
- package/build/hooks/use-dashboard-container-column-count.cjs.map +7 -0
- package/build/index.cjs +45 -0
- package/build/index.cjs.map +7 -0
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/types.cjs +31 -0
- package/build/types.cjs.map +7 -0
- package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs +44 -0
- package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs.map +7 -0
- package/build/utils/create-dashboard-widget/index.cjs +31 -0
- package/build/utils/create-dashboard-widget/index.cjs.map +7 -0
- package/build/utils/default-grid/default-grid.cjs +37 -0
- package/build/utils/default-grid/default-grid.cjs.map +7 -0
- package/build/utils/default-grid/index.cjs +31 -0
- package/build/utils/default-grid/index.cjs.map +7 -0
- package/build/utils/grid-model-change/grid-model-change.cjs +56 -0
- package/build/utils/grid-model-change/grid-model-change.cjs.map +7 -0
- package/build/utils/grid-model-change/index.cjs +33 -0
- package/build/utils/grid-model-change/index.cjs.map +7 -0
- package/build/utils/index.cjs +34 -0
- package/build/utils/index.cjs.map +7 -0
- package/build/utils/migrate-layout/index.cjs +31 -0
- package/build/utils/migrate-layout/index.cjs.map +7 -0
- package/build/utils/migrate-layout/migrate-layout.cjs +94 -0
- package/build/utils/migrate-layout/migrate-layout.cjs.map +7 -0
- package/build/utils/normalize-grid-settings/index.cjs +31 -0
- package/build/utils/normalize-grid-settings/index.cjs.map +7 -0
- package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs +46 -0
- package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs.map +7 -0
- package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs +49 -0
- package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs.map +7 -0
- package/build/utils/row-height-presets/index.cjs +39 -0
- package/build/utils/row-height-presets/index.cjs.map +7 -0
- package/build/utils/row-height-presets/row-height-presets.cjs +63 -0
- package/build/utils/row-height-presets/row-height-presets.cjs.map +7 -0
- package/build/widget-dashboard.cjs +86 -0
- package/build/widget-dashboard.cjs.map +7 -0
- package/build/wordpress-commands.d.cjs +2 -0
- package/build/wordpress-commands.d.cjs.map +7 -0
- package/build-module/components/actions/actions.mjs +240 -0
- package/build-module/components/actions/actions.mjs.map +7 -0
- package/build-module/components/actions/index.mjs +6 -0
- package/build-module/components/actions/index.mjs.map +7 -0
- package/build-module/components/actions-menu/actions-menu.mjs +67 -0
- package/build-module/components/actions-menu/actions-menu.mjs.map +7 -0
- package/build-module/components/actions-menu/index.mjs +6 -0
- package/build-module/components/actions-menu/index.mjs.map +7 -0
- package/build-module/components/commands/commands.mjs +160 -0
- package/build-module/components/commands/commands.mjs.map +7 -0
- package/build-module/components/commands/index.mjs +7 -0
- package/build-module/components/commands/index.mjs.map +7 -0
- package/build-module/components/commands/use-pending-when-edit-mode.mjs +32 -0
- package/build-module/components/commands/use-pending-when-edit-mode.mjs.map +7 -0
- package/build-module/components/layout-settings/index.mjs +6 -0
- package/build-module/components/layout-settings/index.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +151 -0
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +28 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +28 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-settings.mjs +187 -0
- package/build-module/components/layout-settings/layout-settings.mjs.map +7 -0
- package/build-module/components/no-widgets-state/index.mjs +6 -0
- package/build-module/components/no-widgets-state/index.mjs.map +7 -0
- package/build-module/components/no-widgets-state/no-widgets-state.mjs +115 -0
- package/build-module/components/no-widgets-state/no-widgets-state.mjs.map +7 -0
- package/build-module/components/reset-confirmation/index.mjs +6 -0
- package/build-module/components/reset-confirmation/index.mjs.map +7 -0
- package/build-module/components/reset-confirmation/reset-confirmation.mjs +37 -0
- package/build-module/components/reset-confirmation/reset-confirmation.mjs.map +7 -0
- package/build-module/components/widget-chrome/index.mjs +6 -0
- package/build-module/components/widget-chrome/index.mjs.map +7 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs +248 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs.map +7 -0
- package/build-module/components/widget-inserter/index.mjs +6 -0
- package/build-module/components/widget-inserter/index.mjs.map +7 -0
- package/build-module/components/widget-inserter/widget-inserter.mjs +53 -0
- package/build-module/components/widget-inserter/widget-inserter.mjs.map +7 -0
- package/build-module/components/widget-picker/index.mjs +6 -0
- package/build-module/components/widget-picker/index.mjs.map +7 -0
- package/build-module/components/widget-picker/widget-picker.mjs +184 -0
- package/build-module/components/widget-picker/widget-picker.mjs.map +7 -0
- package/build-module/components/widget-render/index.mjs +6 -0
- package/build-module/components/widget-render/index.mjs.map +7 -0
- package/build-module/components/widget-render/widget-render.mjs +37 -0
- package/build-module/components/widget-render/widget-render.mjs.map +7 -0
- package/build-module/components/widget-settings/index.mjs +10 -0
- package/build-module/components/widget-settings/index.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +16 -0
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/get-widget-settings.mjs +13 -0
- package/build-module/components/widget-settings/utils/get-widget-settings.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/index.mjs +8 -0
- package/build-module/components/widget-settings/utils/index.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs +113 -0
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings-trigger.mjs +57 -0
- package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings.mjs +244 -0
- package/build-module/components/widget-settings/widget-settings.mjs.map +7 -0
- package/build-module/components/widget-toolbar/index.mjs +6 -0
- package/build-module/components/widget-toolbar/index.mjs.map +7 -0
- package/build-module/components/widget-toolbar/widget-toolbar.mjs +113 -0
- package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +7 -0
- package/build-module/components/widgets/index.mjs +6 -0
- package/build-module/components/widgets/index.mjs.map +7 -0
- package/build-module/components/widgets/widget-layout-toolbar.mjs +181 -0
- package/build-module/components/widgets/widget-layout-toolbar.mjs.map +7 -0
- package/build-module/components/widgets/widget-resize-handle.mjs +128 -0
- package/build-module/components/widgets/widget-resize-handle.mjs.map +7 -0
- package/build-module/components/widgets/widgets.mjs +242 -0
- package/build-module/components/widgets/widgets.mjs.map +7 -0
- package/build-module/context/dashboard-context.mjs +205 -0
- package/build-module/context/dashboard-context.mjs.map +7 -0
- package/build-module/context/ui-context.mjs +56 -0
- package/build-module/context/ui-context.mjs.map +7 -0
- package/build-module/context/widget-context.mjs +18 -0
- package/build-module/context/widget-context.mjs.map +7 -0
- package/build-module/hooks/use-dashboard-container-column-count.mjs +40 -0
- package/build-module/hooks/use-dashboard-container-column-count.mjs.map +7 -0
- package/build-module/index.mjs +18 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/types.mjs +6 -0
- package/build-module/types.mjs.map +7 -0
- package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs +19 -0
- package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs.map +7 -0
- package/build-module/utils/create-dashboard-widget/index.mjs +6 -0
- package/build-module/utils/create-dashboard-widget/index.mjs.map +7 -0
- package/build-module/utils/default-grid/default-grid.mjs +12 -0
- package/build-module/utils/default-grid/default-grid.mjs.map +7 -0
- package/build-module/utils/default-grid/index.mjs +6 -0
- package/build-module/utils/default-grid/index.mjs.map +7 -0
- package/build-module/utils/grid-model-change/grid-model-change.mjs +30 -0
- package/build-module/utils/grid-model-change/grid-model-change.mjs.map +7 -0
- package/build-module/utils/grid-model-change/index.mjs +7 -0
- package/build-module/utils/grid-model-change/index.mjs.map +7 -0
- package/build-module/utils/index.mjs +8 -0
- package/build-module/utils/index.mjs.map +7 -0
- package/build-module/utils/migrate-layout/index.mjs +6 -0
- package/build-module/utils/migrate-layout/index.mjs.map +7 -0
- package/build-module/utils/migrate-layout/migrate-layout.mjs +69 -0
- package/build-module/utils/migrate-layout/migrate-layout.mjs.map +7 -0
- package/build-module/utils/normalize-grid-settings/index.mjs +6 -0
- package/build-module/utils/normalize-grid-settings/index.mjs.map +7 -0
- package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs +21 -0
- package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs.map +7 -0
- package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs +22 -0
- package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs.map +7 -0
- package/build-module/utils/row-height-presets/index.mjs +16 -0
- package/build-module/utils/row-height-presets/index.mjs.map +7 -0
- package/build-module/utils/row-height-presets/row-height-presets.mjs +34 -0
- package/build-module/utils/row-height-presets/row-height-presets.mjs.map +7 -0
- package/build-module/widget-dashboard.mjs +61 -0
- package/build-module/widget-dashboard.mjs.map +7 -0
- package/build-module/wordpress-commands.d.mjs +1 -0
- package/build-module/wordpress-commands.d.mjs.map +7 -0
- package/build-types/components/actions/actions.d.ts +11 -0
- package/build-types/components/actions/actions.d.ts.map +1 -0
- package/build-types/components/actions/index.d.ts +2 -0
- package/build-types/components/actions/index.d.ts.map +1 -0
- package/build-types/components/actions-menu/actions-menu.d.ts +22 -0
- package/build-types/components/actions-menu/actions-menu.d.ts.map +1 -0
- package/build-types/components/actions-menu/index.d.ts +3 -0
- package/build-types/components/actions-menu/index.d.ts.map +1 -0
- package/build-types/components/commands/commands.d.ts +7 -0
- package/build-types/components/commands/commands.d.ts.map +1 -0
- package/build-types/components/commands/index.d.ts +2 -0
- package/build-types/components/commands/index.d.ts.map +1 -0
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts +15 -0
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -0
- package/build-types/components/layout-settings/index.d.ts +2 -0
- package/build-types/components/layout-settings/index.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +17 -0
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +6 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +6 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-settings.d.ts +14 -0
- package/build-types/components/layout-settings/layout-settings.d.ts.map +1 -0
- package/build-types/components/no-widgets-state/index.d.ts +2 -0
- package/build-types/components/no-widgets-state/index.d.ts.map +1 -0
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts +17 -0
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -0
- package/build-types/components/reset-confirmation/index.d.ts +2 -0
- package/build-types/components/reset-confirmation/index.d.ts.map +1 -0
- package/build-types/components/reset-confirmation/reset-confirmation.d.ts +8 -0
- package/build-types/components/reset-confirmation/reset-confirmation.d.ts.map +1 -0
- package/build-types/components/widget-chrome/index.d.ts +2 -0
- package/build-types/components/widget-chrome/index.d.ts.map +1 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts +22 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -0
- package/build-types/components/widget-inserter/index.d.ts +2 -0
- package/build-types/components/widget-inserter/index.d.ts.map +1 -0
- package/build-types/components/widget-inserter/widget-inserter.d.ts +7 -0
- package/build-types/components/widget-inserter/widget-inserter.d.ts.map +1 -0
- package/build-types/components/widget-picker/index.d.ts +2 -0
- package/build-types/components/widget-picker/index.d.ts.map +1 -0
- package/build-types/components/widget-picker/widget-picker.d.ts +26 -0
- package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -0
- package/build-types/components/widget-render/index.d.ts +2 -0
- package/build-types/components/widget-render/index.d.ts.map +1 -0
- package/build-types/components/widget-render/widget-render.d.ts +17 -0
- package/build-types/components/widget-render/widget-render.d.ts.map +1 -0
- package/build-types/components/widget-settings/index.d.ts +5 -0
- package/build-types/components/widget-settings/index.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +17 -0
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/get-widget-settings.d.ts +10 -0
- package/build-types/components/widget-settings/utils/get-widget-settings.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/index.d.ts +3 -0
- package/build-types/components/widget-settings/utils/index.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +20 -0
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts +23 -0
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings.d.ts +13 -0
- package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -0
- package/build-types/components/widget-toolbar/index.d.ts +3 -0
- package/build-types/components/widget-toolbar/index.d.ts.map +1 -0
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts +16 -0
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -0
- package/build-types/components/widgets/index.d.ts +2 -0
- package/build-types/components/widgets/index.d.ts.map +1 -0
- package/build-types/components/widgets/widget-layout-toolbar.d.ts +14 -0
- package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +1 -0
- package/build-types/components/widgets/widget-resize-handle.d.ts +12 -0
- package/build-types/components/widgets/widget-resize-handle.d.ts.map +1 -0
- package/build-types/components/widgets/widgets.d.ts +10 -0
- package/build-types/components/widgets/widgets.d.ts.map +1 -0
- package/build-types/context/dashboard-context.d.ts +111 -0
- package/build-types/context/dashboard-context.d.ts.map +1 -0
- package/build-types/context/ui-context.d.ts +54 -0
- package/build-types/context/ui-context.d.ts.map +1 -0
- package/build-types/context/widget-context.d.ts +25 -0
- package/build-types/context/widget-context.d.ts.map +1 -0
- package/build-types/hooks/use-dashboard-container-column-count.d.ts +15 -0
- package/build-types/hooks/use-dashboard-container-column-count.d.ts.map +1 -0
- package/build-types/index.d.ts +7 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/types.d.ts +222 -0
- package/build-types/types.d.ts.map +1 -0
- package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts +20 -0
- package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts.map +1 -0
- package/build-types/utils/create-dashboard-widget/index.d.ts +2 -0
- package/build-types/utils/create-dashboard-widget/index.d.ts.map +1 -0
- package/build-types/utils/default-grid/default-grid.d.ts +11 -0
- package/build-types/utils/default-grid/default-grid.d.ts.map +1 -0
- package/build-types/utils/default-grid/index.d.ts +2 -0
- package/build-types/utils/default-grid/index.d.ts.map +1 -0
- package/build-types/utils/grid-model-change/grid-model-change.d.ts +20 -0
- package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +1 -0
- package/build-types/utils/grid-model-change/index.d.ts +2 -0
- package/build-types/utils/grid-model-change/index.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/migrate-layout/index.d.ts +2 -0
- package/build-types/utils/migrate-layout/index.d.ts.map +1 -0
- package/build-types/utils/migrate-layout/migrate-layout.d.ts +36 -0
- package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +1 -0
- package/build-types/utils/normalize-grid-settings/index.d.ts +2 -0
- package/build-types/utils/normalize-grid-settings/index.d.ts.map +1 -0
- package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts +11 -0
- package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts.map +1 -0
- package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts +21 -0
- package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts.map +1 -0
- package/build-types/utils/row-height-presets/index.d.ts +3 -0
- package/build-types/utils/row-height-presets/index.d.ts.map +1 -0
- package/build-types/utils/row-height-presets/row-height-presets.d.ts +17 -0
- package/build-types/utils/row-height-presets/row-height-presets.d.ts.map +1 -0
- package/build-types/widget-dashboard.d.ts +51 -0
- package/build-types/widget-dashboard.d.ts.map +1 -0
- package/package.json +90 -0
- package/src/components/actions/actions.module.css +54 -0
- package/src/components/actions/actions.tsx +180 -0
- package/src/components/actions/index.ts +1 -0
- package/src/components/actions-menu/actions-menu.tsx +104 -0
- package/src/components/actions-menu/index.ts +2 -0
- package/src/components/commands/commands.tsx +182 -0
- package/src/components/commands/index.ts +1 -0
- package/src/components/commands/use-pending-when-edit-mode.ts +48 -0
- package/src/components/layout-settings/index.ts +1 -0
- package/src/components/layout-settings/layout-model-edit-field/index.tsx +98 -0
- package/src/components/layout-settings/layout-model-edit-field/style.module.css +34 -0
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +28 -0
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +28 -0
- package/src/components/layout-settings/layout-settings.tsx +217 -0
- package/src/components/no-widgets-state/index.ts +1 -0
- package/src/components/no-widgets-state/no-widgets-state.module.css +3 -0
- package/src/components/no-widgets-state/no-widgets-state.tsx +56 -0
- package/src/components/reset-confirmation/index.ts +1 -0
- package/src/components/reset-confirmation/reset-confirmation.tsx +44 -0
- package/src/components/widget-chrome/index.ts +1 -0
- package/src/components/widget-chrome/widget-chrome.module.css +87 -0
- package/src/components/widget-chrome/widget-chrome.tsx +255 -0
- package/src/components/widget-inserter/index.ts +1 -0
- package/src/components/widget-inserter/widget-inserter.tsx +70 -0
- package/src/components/widget-picker/index.ts +1 -0
- package/src/components/widget-picker/widget-picker.module.css +11 -0
- package/src/components/widget-picker/widget-picker.tsx +137 -0
- package/src/components/widget-render/index.ts +1 -0
- package/src/components/widget-render/widget-render.tsx +58 -0
- package/src/components/widget-settings/index.ts +4 -0
- package/src/components/widget-settings/utils/get-admin-menu-inset.ts +30 -0
- package/src/components/widget-settings/utils/get-widget-settings.ts +22 -0
- package/src/components/widget-settings/utils/index.ts +2 -0
- package/src/components/widget-settings/widget-settings-toolbar.module.css +25 -0
- package/src/components/widget-settings/widget-settings-toolbar.tsx +45 -0
- package/src/components/widget-settings/widget-settings-trigger.tsx +96 -0
- package/src/components/widget-settings/widget-settings.module.css +8 -0
- package/src/components/widget-settings/widget-settings.tsx +200 -0
- package/src/components/widget-toolbar/index.ts +2 -0
- package/src/components/widget-toolbar/widget-toolbar.module.css +12 -0
- package/src/components/widget-toolbar/widget-toolbar.tsx +46 -0
- package/src/components/widgets/index.ts +1 -0
- package/src/components/widgets/widget-layout-toolbar.module.css +6 -0
- package/src/components/widgets/widget-layout-toolbar.tsx +118 -0
- package/src/components/widgets/widget-resize-handle.module.css +135 -0
- package/src/components/widgets/widget-resize-handle.tsx +60 -0
- package/src/components/widgets/widgets.module.css +43 -0
- package/src/components/widgets/widgets.tsx +208 -0
- package/src/context/dashboard-context.tsx +386 -0
- package/src/context/ui-context.tsx +118 -0
- package/src/context/widget-context.tsx +45 -0
- package/src/hooks/use-dashboard-container-column-count.ts +63 -0
- package/src/index.ts +9 -0
- package/src/lock-unlock.ts +10 -0
- package/src/test/actions.test.tsx +228 -0
- package/src/test/commands.test.tsx +176 -0
- package/src/test/create-dashboard-widget.test.ts +59 -0
- package/src/test/dashboard-context.test.tsx +26 -0
- package/src/test/staging.test.tsx +476 -0
- package/src/test/widget-dashboard.test.tsx +204 -0
- package/src/test/widget-inserter.test.tsx +210 -0
- package/src/test/widget-settings.test.tsx +199 -0
- package/src/types.ts +260 -0
- package/src/utils/create-dashboard-widget/create-dashboard-widget.ts +43 -0
- package/src/utils/create-dashboard-widget/index.ts +1 -0
- package/src/utils/default-grid/default-grid.ts +17 -0
- package/src/utils/default-grid/index.ts +1 -0
- package/src/utils/grid-model-change/grid-model-change.ts +53 -0
- package/src/utils/grid-model-change/index.ts +1 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/migrate-layout/index.ts +1 -0
- package/src/utils/migrate-layout/migrate-layout.ts +156 -0
- package/src/utils/migrate-layout/test/migrate-layout.test.ts +114 -0
- package/src/utils/normalize-grid-settings/index.ts +1 -0
- package/src/utils/normalize-grid-settings/normalize-grid-settings.ts +38 -0
- package/src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts +41 -0
- package/src/utils/resolve-dashboard-column-count/test/resolve-dashboard-column-count.test.ts +44 -0
- package/src/utils/row-height-presets/index.ts +8 -0
- package/src/utils/row-height-presets/row-height-presets.ts +43 -0
- package/src/widget-dashboard.tsx +102 -0
- package/src/wordpress-commands.d.ts +12 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
useCommands,
|
|
8
|
+
privateApis as commandsPrivateApis,
|
|
9
|
+
} from '@wordpress/commands';
|
|
10
|
+
import {
|
|
11
|
+
columns,
|
|
12
|
+
grid,
|
|
13
|
+
layout as layoutIcon,
|
|
14
|
+
plus,
|
|
15
|
+
trash,
|
|
16
|
+
} from '@wordpress/icons';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
22
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
23
|
+
import { useDashboardUIContext } from '../../context/ui-context';
|
|
24
|
+
import { getGridModel } from '../../utils/grid-model-change';
|
|
25
|
+
import { usePendingWhenEditMode } from './use-pending-when-edit-mode';
|
|
26
|
+
|
|
27
|
+
const { useCommandContext } = unlock( commandsPrivateApis );
|
|
28
|
+
|
|
29
|
+
export const DASHBOARD_COMMAND_CONTEXT = 'dashboard';
|
|
30
|
+
|
|
31
|
+
type CommandCallback = ( options: { close: () => void } ) => void;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Registers dashboard-specific command palette commands and sets the
|
|
35
|
+
* active command context so they surface under Suggestions by default.
|
|
36
|
+
*/
|
|
37
|
+
export function Commands() {
|
|
38
|
+
const {
|
|
39
|
+
editMode,
|
|
40
|
+
onEditChange,
|
|
41
|
+
onLayoutReset,
|
|
42
|
+
gridSettings,
|
|
43
|
+
canEditGridSettings,
|
|
44
|
+
commitGridModelChange,
|
|
45
|
+
} = useDashboardInternalContext();
|
|
46
|
+
|
|
47
|
+
const { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();
|
|
48
|
+
|
|
49
|
+
useCommandContext( DASHBOARD_COMMAND_CONTEXT );
|
|
50
|
+
|
|
51
|
+
const runWhenInEditMode = usePendingWhenEditMode( {
|
|
52
|
+
editMode,
|
|
53
|
+
onEditChange,
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
const gridModel = getGridModel( gridSettings );
|
|
57
|
+
const isGridLayout = gridModel === 'grid';
|
|
58
|
+
const isMasonryLayout = gridModel === 'masonry';
|
|
59
|
+
|
|
60
|
+
const switchToMasonry = useCallback< CommandCallback >(
|
|
61
|
+
( { close } ) => {
|
|
62
|
+
close();
|
|
63
|
+
commitGridModelChange( 'masonry' );
|
|
64
|
+
},
|
|
65
|
+
[ commitGridModelChange ]
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
const switchToGrid = useCallback< CommandCallback >(
|
|
69
|
+
( { close } ) => {
|
|
70
|
+
close();
|
|
71
|
+
commitGridModelChange( 'grid' );
|
|
72
|
+
},
|
|
73
|
+
[ commitGridModelChange ]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const resetToDefault = useCallback< CommandCallback >(
|
|
77
|
+
( { close } ) => {
|
|
78
|
+
close();
|
|
79
|
+
setResetDialogOpen( true );
|
|
80
|
+
},
|
|
81
|
+
[ setResetDialogOpen ]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const addWidgets = useCallback< CommandCallback >(
|
|
85
|
+
( { close } ) => {
|
|
86
|
+
close();
|
|
87
|
+
runWhenInEditMode( () => {
|
|
88
|
+
setInserterOpen( true );
|
|
89
|
+
} );
|
|
90
|
+
},
|
|
91
|
+
[ runWhenInEditMode, setInserterOpen ]
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const customize = useCallback< CommandCallback >(
|
|
95
|
+
( { close } ) => {
|
|
96
|
+
close();
|
|
97
|
+
onEditChange?.( true );
|
|
98
|
+
},
|
|
99
|
+
[ onEditChange ]
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const commands = useMemo(
|
|
103
|
+
() => [
|
|
104
|
+
{
|
|
105
|
+
name: 'core/dashboard/customize',
|
|
106
|
+
label: __( 'Customize dashboard' ),
|
|
107
|
+
icon: layoutIcon,
|
|
108
|
+
category: 'command',
|
|
109
|
+
context: DASHBOARD_COMMAND_CONTEXT,
|
|
110
|
+
keywords: [ __( 'edit' ), __( 'widgets' ), __( 'layout' ) ],
|
|
111
|
+
disabled: ! onEditChange || editMode,
|
|
112
|
+
callback: customize,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'core/dashboard/add-widgets',
|
|
116
|
+
label: __( 'Add dashboard widgets' ),
|
|
117
|
+
icon: plus,
|
|
118
|
+
category: 'command',
|
|
119
|
+
context: DASHBOARD_COMMAND_CONTEXT,
|
|
120
|
+
keywords: [ __( 'widgets' ), __( 'inserter' ) ],
|
|
121
|
+
disabled: ! onEditChange,
|
|
122
|
+
callback: addWidgets,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'core/dashboard/switch-to-masonry-layout',
|
|
126
|
+
label: __( 'Switch dashboard to masonry layout' ),
|
|
127
|
+
icon: columns,
|
|
128
|
+
category: 'command',
|
|
129
|
+
context: DASHBOARD_COMMAND_CONTEXT,
|
|
130
|
+
keywords: [
|
|
131
|
+
__( 'layout' ),
|
|
132
|
+
__( 'layout model' ),
|
|
133
|
+
__( 'masonry' ),
|
|
134
|
+
],
|
|
135
|
+
disabled: ! canEditGridSettings || isMasonryLayout || editMode,
|
|
136
|
+
callback: switchToMasonry,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: 'core/dashboard/switch-to-grid-layout',
|
|
140
|
+
label: __( 'Switch dashboard to grid layout' ),
|
|
141
|
+
icon: grid,
|
|
142
|
+
category: 'command',
|
|
143
|
+
context: DASHBOARD_COMMAND_CONTEXT,
|
|
144
|
+
keywords: [
|
|
145
|
+
__( 'layout' ),
|
|
146
|
+
__( 'layout model' ),
|
|
147
|
+
__( 'grid' ),
|
|
148
|
+
__( 'standard grid' ),
|
|
149
|
+
],
|
|
150
|
+
disabled: ! canEditGridSettings || isGridLayout || editMode,
|
|
151
|
+
callback: switchToGrid,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'core/dashboard/reset-to-default',
|
|
155
|
+
label: __( 'Reset dashboard widgets to default' ),
|
|
156
|
+
icon: trash,
|
|
157
|
+
category: 'command',
|
|
158
|
+
context: DASHBOARD_COMMAND_CONTEXT,
|
|
159
|
+
keywords: [ __( 'reset' ), __( 'default' ) ],
|
|
160
|
+
disabled: ! onLayoutReset,
|
|
161
|
+
callback: resetToDefault,
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
[
|
|
165
|
+
onEditChange,
|
|
166
|
+
editMode,
|
|
167
|
+
customize,
|
|
168
|
+
addWidgets,
|
|
169
|
+
canEditGridSettings,
|
|
170
|
+
isMasonryLayout,
|
|
171
|
+
isGridLayout,
|
|
172
|
+
switchToMasonry,
|
|
173
|
+
switchToGrid,
|
|
174
|
+
onLayoutReset,
|
|
175
|
+
resetToDefault,
|
|
176
|
+
]
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
useCommands( commands );
|
|
180
|
+
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Commands, DASHBOARD_COMMAND_CONTEXT } from './commands';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useEffect, useRef } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
type UsePendingWhenEditModeProps = {
|
|
7
|
+
editMode: boolean;
|
|
8
|
+
onEditChange?: ( next: boolean ) => void;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type UsePendingWhenEditModeResult = ( action: () => void ) => void;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Runs an action immediately when already in edit mode. Otherwise enables
|
|
15
|
+
* edit mode and runs the action after edit mode becomes active.
|
|
16
|
+
*
|
|
17
|
+
* @param {UsePendingWhenEditModeProps} params Current edit mode and the change handler.
|
|
18
|
+
* @return {UsePendingWhenEditModeResult} Runs an action, deferring it until edit mode is active.
|
|
19
|
+
*/
|
|
20
|
+
export function usePendingWhenEditMode( {
|
|
21
|
+
editMode,
|
|
22
|
+
onEditChange,
|
|
23
|
+
}: UsePendingWhenEditModeProps ): UsePendingWhenEditModeResult {
|
|
24
|
+
const pendingRef = useRef< ( () => void ) | null >( null );
|
|
25
|
+
const wasEditingRef = useRef( editMode );
|
|
26
|
+
|
|
27
|
+
useEffect( () => {
|
|
28
|
+
if ( ! wasEditingRef.current && editMode && pendingRef.current ) {
|
|
29
|
+
const action = pendingRef.current;
|
|
30
|
+
pendingRef.current = null;
|
|
31
|
+
action();
|
|
32
|
+
}
|
|
33
|
+
wasEditingRef.current = editMode;
|
|
34
|
+
}, [ editMode ] );
|
|
35
|
+
|
|
36
|
+
return useCallback(
|
|
37
|
+
( action: () => void ) => {
|
|
38
|
+
if ( editMode ) {
|
|
39
|
+
action();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
pendingRef.current = action;
|
|
44
|
+
onEditChange?.( true );
|
|
45
|
+
},
|
|
46
|
+
[ editMode, onEditChange ]
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LayoutSettings } from './layout-settings';
|
|
@@ -0,0 +1,98 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NoWidgetsState } from './no-widgets-state';
|