@wordpress/widget-dashboard 0.1.1-next.v.202606191442.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 +226 -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,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { WidgetGridSettings } from '../../types';
|
|
5
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
|
|
6
|
+
import { DEFAULT_ROW_HEIGHT } from '../row-height-presets';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Canonical default grid settings. Applied by the dashboard when the
|
|
10
|
+
* consumer omits `gridSettings`, and the baseline hosts should treat as
|
|
11
|
+
* the factory default when persisting their own copy.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_GRID: WidgetGridSettings = {
|
|
14
|
+
model: 'grid',
|
|
15
|
+
columns: WIDGET_DASHBOARD_COLUMN_COUNT,
|
|
16
|
+
rowHeight: DEFAULT_ROW_HEIGHT,
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DEFAULT_GRID } from './default-grid';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { migrateLayout } from '../migrate-layout';
|
|
5
|
+
import type {
|
|
6
|
+
DashboardWidget,
|
|
7
|
+
WidgetGridModel,
|
|
8
|
+
WidgetGridSettings,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
|
|
11
|
+
|
|
12
|
+
export function getGridModel( settings: WidgetGridSettings ): WidgetGridModel {
|
|
13
|
+
return settings.model ?? 'grid';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ComputeGridModelChangeProps = {
|
|
17
|
+
layout: DashboardWidget[];
|
|
18
|
+
gridSettings: WidgetGridSettings;
|
|
19
|
+
targetModel: WidgetGridModel;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type ComputeGridModelChangeResult = {
|
|
23
|
+
layout: DashboardWidget[];
|
|
24
|
+
gridSettings: WidgetGridSettings;
|
|
25
|
+
} | null;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Computes the staged layout and grid settings after a layout-model change.
|
|
29
|
+
*
|
|
30
|
+
* @param {ComputeGridModelChangeProps} params Layout, current settings, and target model.
|
|
31
|
+
* @return {ComputeGridModelChangeResult} Migrated layout and settings, or `null` when the model is unchanged.
|
|
32
|
+
*/
|
|
33
|
+
export function computeGridModelChange( {
|
|
34
|
+
layout,
|
|
35
|
+
gridSettings,
|
|
36
|
+
targetModel,
|
|
37
|
+
}: ComputeGridModelChangeProps ): ComputeGridModelChangeResult {
|
|
38
|
+
const currentModel = getGridModel( gridSettings );
|
|
39
|
+
|
|
40
|
+
if ( currentModel === targetModel ) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
layout: migrateLayout( layout, currentModel, targetModel, {
|
|
46
|
+
columns: WIDGET_DASHBOARD_COLUMN_COUNT,
|
|
47
|
+
} ),
|
|
48
|
+
gridSettings: {
|
|
49
|
+
...gridSettings,
|
|
50
|
+
model: targetModel,
|
|
51
|
+
} as WidgetGridSettings,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { computeGridModelChange, getGridModel } from './grid-model-change';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { migrateLayout } from './migrate-layout';
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type {
|
|
5
|
+
DashboardWidget,
|
|
6
|
+
GridTilePlacement,
|
|
7
|
+
MasonryTilePlacement,
|
|
8
|
+
WidgetGridModel,
|
|
9
|
+
} from '../../types';
|
|
10
|
+
|
|
11
|
+
interface MigrationContext {
|
|
12
|
+
/**
|
|
13
|
+
* Column count of the currently-mounted grid surface. Used to
|
|
14
|
+
* resolve `'full'` widths to a concrete numeric span when going
|
|
15
|
+
* from the 2D grid model to masonry. When the surface is in
|
|
16
|
+
* responsive mode and the runtime column count is unknown,
|
|
17
|
+
* callers should pass a sensible fallback (e.g., the default of
|
|
18
|
+
* 6 used by `@wordpress/grid`).
|
|
19
|
+
*/
|
|
20
|
+
columns: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const FALLBACK_COLUMNS = 6;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Coerces a `'fill'`/`'full'`/numeric width into a concrete numeric
|
|
27
|
+
* span when migrating from `'grid'` to `'masonry'`. `'fill'` collapses
|
|
28
|
+
* to a single column; resolving it against per-row remainder would
|
|
29
|
+
* require either DOM measurement or replicating CSS-Grid's auto-flow
|
|
30
|
+
* placement, both of which were judged not worth the complexity for
|
|
31
|
+
* a one-shot migration the user can correct visually in staging.
|
|
32
|
+
*
|
|
33
|
+
* @param width Source width from a grid placement.
|
|
34
|
+
* @param targetColumns Column count to use for `'full'` widths.
|
|
35
|
+
*/
|
|
36
|
+
function gridWidthToMasonryWidth(
|
|
37
|
+
width: GridTilePlacement[ 'width' ],
|
|
38
|
+
targetColumns: number
|
|
39
|
+
): number {
|
|
40
|
+
if ( width === 'full' ) {
|
|
41
|
+
return targetColumns;
|
|
42
|
+
}
|
|
43
|
+
if ( width === 'fill' || width === undefined ) {
|
|
44
|
+
return 1;
|
|
45
|
+
}
|
|
46
|
+
return width;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Transforms a single placement from the 2D grid shape to the masonry
|
|
51
|
+
* shape. Drops `height` (masonry derives heights from content),
|
|
52
|
+
* preserves `order`, leaves `lane` unset so the auto-flow placer
|
|
53
|
+
* arranges items by source order.
|
|
54
|
+
*
|
|
55
|
+
* @param placement Source grid placement.
|
|
56
|
+
* @param context Migration context (column count).
|
|
57
|
+
*/
|
|
58
|
+
function migratePlacementGridToMasonry(
|
|
59
|
+
placement: GridTilePlacement | undefined,
|
|
60
|
+
context: MigrationContext
|
|
61
|
+
): MasonryTilePlacement {
|
|
62
|
+
if ( ! placement ) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const next: MasonryTilePlacement = {};
|
|
67
|
+
const width = gridWidthToMasonryWidth( placement.width, context.columns );
|
|
68
|
+
if ( width !== 1 ) {
|
|
69
|
+
next.width = width;
|
|
70
|
+
}
|
|
71
|
+
if ( placement.order !== undefined ) {
|
|
72
|
+
next.order = placement.order;
|
|
73
|
+
}
|
|
74
|
+
return next;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Transforms a single placement from the masonry shape to the 2D grid
|
|
79
|
+
* shape. Preserves the numeric width, drops `lane` (the 2D grid
|
|
80
|
+
* auto-packs and has no pin-to-column concept), and seeds `height: 1`
|
|
81
|
+
* since masonry never persisted a height. The user is expected to
|
|
82
|
+
* resize tiles vertically after the migration.
|
|
83
|
+
*
|
|
84
|
+
* @param placement Source masonry placement.
|
|
85
|
+
*/
|
|
86
|
+
function migratePlacementMasonryToGrid(
|
|
87
|
+
placement: MasonryTilePlacement | undefined
|
|
88
|
+
): GridTilePlacement {
|
|
89
|
+
if ( ! placement ) {
|
|
90
|
+
return { height: 1 };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const next: GridTilePlacement = { height: 1 };
|
|
94
|
+
if ( placement.width !== undefined ) {
|
|
95
|
+
next.width = placement.width;
|
|
96
|
+
}
|
|
97
|
+
if ( placement.order !== undefined ) {
|
|
98
|
+
next.order = placement.order;
|
|
99
|
+
}
|
|
100
|
+
return next;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Migrates every widget's `placement` between grid models.
|
|
105
|
+
*
|
|
106
|
+
* The two storage shapes overlap on `width` and `order` but diverge
|
|
107
|
+
* on the rest: 2D grid carries `height` and discriminated string
|
|
108
|
+
* widths (`'fill'`/`'full'`), lanes carries `lane` and only numeric
|
|
109
|
+
* widths. Each conversion loses information that the target model
|
|
110
|
+
* cannot represent. The caller is responsible for surfacing the
|
|
111
|
+
* result to the user in a way that lets them correct visually.
|
|
112
|
+
*
|
|
113
|
+
* When `from === to`, the input is returned unchanged.
|
|
114
|
+
*
|
|
115
|
+
* @param widgets Widgets to migrate.
|
|
116
|
+
* @param from Source model. `undefined` is treated as `'grid'`.
|
|
117
|
+
* @param to Target model.
|
|
118
|
+
* @param context Information that depends on the live render (today
|
|
119
|
+
* only `columns`).
|
|
120
|
+
*/
|
|
121
|
+
export function migrateLayout(
|
|
122
|
+
widgets: DashboardWidget[],
|
|
123
|
+
from: WidgetGridModel | undefined,
|
|
124
|
+
to: WidgetGridModel,
|
|
125
|
+
context: Partial< MigrationContext > = {}
|
|
126
|
+
): DashboardWidget[] {
|
|
127
|
+
const resolvedFrom: WidgetGridModel = from ?? 'grid';
|
|
128
|
+
if ( resolvedFrom === to ) {
|
|
129
|
+
return widgets;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const resolvedContext: MigrationContext = {
|
|
133
|
+
columns: context.columns ?? FALLBACK_COLUMNS,
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if ( resolvedFrom === 'grid' && to === 'masonry' ) {
|
|
137
|
+
return widgets.map( ( widget ) => ( {
|
|
138
|
+
...widget,
|
|
139
|
+
placement: migratePlacementGridToMasonry(
|
|
140
|
+
widget.placement as GridTilePlacement | undefined,
|
|
141
|
+
resolvedContext
|
|
142
|
+
),
|
|
143
|
+
} ) );
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if ( resolvedFrom === 'masonry' && to === 'grid' ) {
|
|
147
|
+
return widgets.map( ( widget ) => ( {
|
|
148
|
+
...widget,
|
|
149
|
+
placement: migratePlacementMasonryToGrid(
|
|
150
|
+
widget.placement as MasonryTilePlacement | undefined
|
|
151
|
+
),
|
|
152
|
+
} ) );
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return widgets;
|
|
156
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { migrateLayout } from '../migrate-layout';
|
|
5
|
+
import type { DashboardWidget } from '../../../types';
|
|
6
|
+
|
|
7
|
+
function widget( uuid: string, placement: object | undefined = undefined ) {
|
|
8
|
+
return {
|
|
9
|
+
uuid,
|
|
10
|
+
type: 'core/test' as const,
|
|
11
|
+
placement,
|
|
12
|
+
} as DashboardWidget;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe( 'migrateLayout', () => {
|
|
16
|
+
it( 'returns input unchanged when source and target match', () => {
|
|
17
|
+
const layout: DashboardWidget[] = [
|
|
18
|
+
widget( 'a', { width: 2, height: 1 } ),
|
|
19
|
+
];
|
|
20
|
+
expect( migrateLayout( layout, 'grid', 'grid' ) ).toBe( layout );
|
|
21
|
+
} );
|
|
22
|
+
|
|
23
|
+
it( 'treats undefined source as grid', () => {
|
|
24
|
+
const layout: DashboardWidget[] = [
|
|
25
|
+
widget( 'a', { width: 'full', height: 1 } ),
|
|
26
|
+
];
|
|
27
|
+
const migrated = migrateLayout( layout, undefined, 'masonry', {
|
|
28
|
+
columns: 4,
|
|
29
|
+
} );
|
|
30
|
+
expect( migrated[ 0 ].placement ).toEqual( { width: 4 } );
|
|
31
|
+
} );
|
|
32
|
+
|
|
33
|
+
describe( 'grid to masonry', () => {
|
|
34
|
+
it( "expands 'full' to the target column count", () => {
|
|
35
|
+
const layout: DashboardWidget[] = [
|
|
36
|
+
widget( 'a', { width: 'full', height: 1 } ),
|
|
37
|
+
];
|
|
38
|
+
const migrated = migrateLayout( layout, 'grid', 'masonry', {
|
|
39
|
+
columns: 6,
|
|
40
|
+
} );
|
|
41
|
+
expect( migrated[ 0 ].placement ).toEqual( { width: 6 } );
|
|
42
|
+
} );
|
|
43
|
+
|
|
44
|
+
it( "collapses 'fill' to a single column", () => {
|
|
45
|
+
const layout: DashboardWidget[] = [
|
|
46
|
+
widget( 'a', { width: 'fill', height: 2 } ),
|
|
47
|
+
];
|
|
48
|
+
const migrated = migrateLayout( layout, 'grid', 'masonry', {
|
|
49
|
+
columns: 6,
|
|
50
|
+
} );
|
|
51
|
+
expect( migrated[ 0 ].placement ).toEqual( {} );
|
|
52
|
+
} );
|
|
53
|
+
|
|
54
|
+
it( 'preserves numeric width and drops height and explicit width=1', () => {
|
|
55
|
+
const layout: DashboardWidget[] = [
|
|
56
|
+
widget( 'a', { width: 3, height: 2, order: 5 } ),
|
|
57
|
+
widget( 'b', { width: 1, height: 1 } ),
|
|
58
|
+
];
|
|
59
|
+
const migrated = migrateLayout( layout, 'grid', 'masonry', {
|
|
60
|
+
columns: 6,
|
|
61
|
+
} );
|
|
62
|
+
expect( migrated[ 0 ].placement ).toEqual( {
|
|
63
|
+
width: 3,
|
|
64
|
+
order: 5,
|
|
65
|
+
} );
|
|
66
|
+
expect( migrated[ 1 ].placement ).toEqual( {} );
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
it( 'falls back to a default column count when not provided', () => {
|
|
70
|
+
const layout: DashboardWidget[] = [
|
|
71
|
+
widget( 'a', { width: 'full', height: 1 } ),
|
|
72
|
+
];
|
|
73
|
+
const migrated = migrateLayout( layout, 'grid', 'masonry' );
|
|
74
|
+
expect( migrated[ 0 ].placement ).toEqual( { width: 6 } );
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
it( 'handles widgets without a placement', () => {
|
|
78
|
+
const layout: DashboardWidget[] = [ widget( 'a' ) ];
|
|
79
|
+
const migrated = migrateLayout( layout, 'grid', 'masonry' );
|
|
80
|
+
expect( migrated[ 0 ].placement ).toEqual( {} );
|
|
81
|
+
} );
|
|
82
|
+
} );
|
|
83
|
+
|
|
84
|
+
describe( 'masonry to grid', () => {
|
|
85
|
+
it( 'seeds height=1 and preserves width and order', () => {
|
|
86
|
+
const layout: DashboardWidget[] = [
|
|
87
|
+
widget( 'a', { width: 2, order: 1 } ),
|
|
88
|
+
];
|
|
89
|
+
const migrated = migrateLayout( layout, 'masonry', 'grid' );
|
|
90
|
+
expect( migrated[ 0 ].placement ).toEqual( {
|
|
91
|
+
width: 2,
|
|
92
|
+
height: 1,
|
|
93
|
+
order: 1,
|
|
94
|
+
} );
|
|
95
|
+
} );
|
|
96
|
+
|
|
97
|
+
it( 'drops the lane field', () => {
|
|
98
|
+
const layout: DashboardWidget[] = [
|
|
99
|
+
widget( 'a', { width: 1, lane: 2 } ),
|
|
100
|
+
];
|
|
101
|
+
const migrated = migrateLayout( layout, 'masonry', 'grid' );
|
|
102
|
+
expect( migrated[ 0 ].placement ).toEqual( {
|
|
103
|
+
width: 1,
|
|
104
|
+
height: 1,
|
|
105
|
+
} );
|
|
106
|
+
} );
|
|
107
|
+
|
|
108
|
+
it( 'handles widgets without a placement', () => {
|
|
109
|
+
const layout: DashboardWidget[] = [ widget( 'a' ) ];
|
|
110
|
+
const migrated = migrateLayout( layout, 'masonry', 'grid' );
|
|
111
|
+
expect( migrated[ 0 ].placement ).toEqual( { height: 1 } );
|
|
112
|
+
} );
|
|
113
|
+
} );
|
|
114
|
+
} );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { normalizeGridSettings } from './normalize-grid-settings';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { WidgetGridLayoutSettings, WidgetGridSettings } from '../../types';
|
|
2
|
+
import { snapRowHeight } from '../row-height-presets';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Coerces legacy grid row heights to a dashboard preset. Standard grid
|
|
6
|
+
* rows always use uniform track sizing so tiles align with the masonry
|
|
7
|
+
* model boundary.
|
|
8
|
+
*
|
|
9
|
+
* @param settings Grid settings to normalize.
|
|
10
|
+
* @param defaultRowHeight Fallback row height when none is set.
|
|
11
|
+
*/
|
|
12
|
+
export function normalizeGridSettings(
|
|
13
|
+
settings: WidgetGridSettings,
|
|
14
|
+
defaultRowHeight: number
|
|
15
|
+
): WidgetGridSettings {
|
|
16
|
+
if ( ( settings.model ?? 'grid' ) === 'masonry' ) {
|
|
17
|
+
return settings;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// The guard above cannot narrow the union for TypeScript: `model` is
|
|
21
|
+
// optional and the check goes through `??`.
|
|
22
|
+
const gridSettings = settings as WidgetGridLayoutSettings;
|
|
23
|
+
|
|
24
|
+
const rowHeight = gridSettings.rowHeight;
|
|
25
|
+
const resolved =
|
|
26
|
+
typeof rowHeight === 'number'
|
|
27
|
+
? snapRowHeight( rowHeight )
|
|
28
|
+
: defaultRowHeight;
|
|
29
|
+
|
|
30
|
+
if ( rowHeight === resolved ) {
|
|
31
|
+
return settings;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...gridSettings,
|
|
36
|
+
rowHeight: resolved,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Container width (px) below which the dashboard uses a single column.
|
|
8
|
+
* Matches `@container widget-dashboard (max-width: …)` in widgets CSS.
|
|
9
|
+
*/
|
|
10
|
+
export const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN = 600;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Container width (px) below which the dashboard drops from four columns
|
|
14
|
+
* to two. Above this threshold (and below the four-column cap) the
|
|
15
|
+
* grid uses {@link WIDGET_DASHBOARD_COLUMN_COUNT}.
|
|
16
|
+
*/
|
|
17
|
+
export const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS = 960;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the dashboard grid column count from the widget surface
|
|
21
|
+
* container width. Uses discrete steps (4 → 2 → 1), not viewport
|
|
22
|
+
* media queries.
|
|
23
|
+
*
|
|
24
|
+
* @param containerWidth Measured inline size of the dashboard grid container.
|
|
25
|
+
* @return Column count for {@link @wordpress/grid} surfaces.
|
|
26
|
+
*/
|
|
27
|
+
export function resolveDashboardColumnCount( containerWidth: number ): number {
|
|
28
|
+
if ( containerWidth <= 0 ) {
|
|
29
|
+
return WIDGET_DASHBOARD_COLUMN_COUNT;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN ) {
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS ) {
|
|
37
|
+
return 2;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return WIDGET_DASHBOARD_COLUMN_COUNT;
|
|
41
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
resolveDashboardColumnCount,
|
|
6
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN,
|
|
7
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS,
|
|
8
|
+
} from '../resolve-dashboard-column-count';
|
|
9
|
+
|
|
10
|
+
describe( 'resolveDashboardColumnCount', () => {
|
|
11
|
+
it( 'defaults to four columns before measurement', () => {
|
|
12
|
+
expect( resolveDashboardColumnCount( 0 ) ).toBe( 4 );
|
|
13
|
+
} );
|
|
14
|
+
|
|
15
|
+
it( 'uses four columns at wide container sizes', () => {
|
|
16
|
+
expect(
|
|
17
|
+
resolveDashboardColumnCount(
|
|
18
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS
|
|
19
|
+
)
|
|
20
|
+
).toBe( 4 );
|
|
21
|
+
expect( resolveDashboardColumnCount( 1200 ) ).toBe( 4 );
|
|
22
|
+
} );
|
|
23
|
+
|
|
24
|
+
it( 'uses two columns between mobile and wide breakpoints', () => {
|
|
25
|
+
expect(
|
|
26
|
+
resolveDashboardColumnCount(
|
|
27
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN
|
|
28
|
+
)
|
|
29
|
+
).toBe( 2 );
|
|
30
|
+
expect(
|
|
31
|
+
resolveDashboardColumnCount(
|
|
32
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS - 1
|
|
33
|
+
)
|
|
34
|
+
).toBe( 2 );
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
it( 'uses one column below the mobile container breakpoint', () => {
|
|
38
|
+
expect(
|
|
39
|
+
resolveDashboardColumnCount(
|
|
40
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN - 1
|
|
41
|
+
)
|
|
42
|
+
).toBe( 1 );
|
|
43
|
+
} );
|
|
44
|
+
} );
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const ROW_HEIGHT_PRESETS = {
|
|
2
|
+
small: 200,
|
|
3
|
+
medium: 300,
|
|
4
|
+
large: 400,
|
|
5
|
+
} as const;
|
|
6
|
+
|
|
7
|
+
export type RowHeightPreset = keyof typeof ROW_HEIGHT_PRESETS;
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_ROW_HEIGHT = ROW_HEIGHT_PRESETS.medium;
|
|
10
|
+
|
|
11
|
+
const PRESET_ENTRIES = Object.entries( ROW_HEIGHT_PRESETS ) as [
|
|
12
|
+
RowHeightPreset,
|
|
13
|
+
number,
|
|
14
|
+
][];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Maps a stored pixel height to the nearest preset so legacy freeform
|
|
18
|
+
* values still resolve to a valid toggle option.
|
|
19
|
+
*
|
|
20
|
+
* @param rowHeight Row height in pixels.
|
|
21
|
+
*/
|
|
22
|
+
export function rowHeightToPreset( rowHeight: number ): RowHeightPreset {
|
|
23
|
+
let closest: RowHeightPreset = 'medium';
|
|
24
|
+
let minDistance = Infinity;
|
|
25
|
+
|
|
26
|
+
for ( const [ preset, value ] of PRESET_ENTRIES ) {
|
|
27
|
+
const distance = Math.abs( rowHeight - value );
|
|
28
|
+
if ( distance < minDistance ) {
|
|
29
|
+
minDistance = distance;
|
|
30
|
+
closest = preset;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return closest;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function presetToRowHeight( preset: RowHeightPreset ): number {
|
|
38
|
+
return ROW_HEIGHT_PRESETS[ preset ];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function snapRowHeight( rowHeight: number ): number {
|
|
42
|
+
return presetToRowHeight( rowHeightToPreset( rowHeight ) );
|
|
43
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { WidgetDashboardProvider } from './context/dashboard-context';
|
|
5
|
+
import { WidgetDashboardUIProvider } from './context/ui-context';
|
|
6
|
+
import { Actions } from './components/actions';
|
|
7
|
+
import { Commands } from './components/commands';
|
|
8
|
+
import { LayoutSettings } from './components/layout-settings';
|
|
9
|
+
import { NoWidgetsState } from './components/no-widgets-state';
|
|
10
|
+
import { ResetConfirmation } from './components/reset-confirmation';
|
|
11
|
+
import { WidgetChrome } from './components/widget-chrome';
|
|
12
|
+
import { WidgetInserter } from './components/widget-inserter';
|
|
13
|
+
import { WidgetSettings } from './components/widget-settings';
|
|
14
|
+
import { Widgets } from './components/widgets';
|
|
15
|
+
import type { WidgetDashboardProps } from './types';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Stateless rendering engine for widget dashboards.
|
|
19
|
+
*
|
|
20
|
+
* The consumer owns `layout` and `editMode` state; every mutation fires
|
|
21
|
+
* `onLayoutChange` with the fully updated array. The engine never queries a
|
|
22
|
+
* widget store; types flow in via the `widgetTypes` prop.
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* import { WidgetDashboard } from '@wordpress/widget-dashboard';
|
|
26
|
+
*
|
|
27
|
+
* function MyDashboard() {
|
|
28
|
+
* const [ layout, setLayout ] = useState( defaultLayout );
|
|
29
|
+
* const [ editMode, setEditMode ] = useState( false );
|
|
30
|
+
* return (
|
|
31
|
+
* <WidgetDashboard
|
|
32
|
+
* layout={ layout }
|
|
33
|
+
* onLayoutChange={ setLayout }
|
|
34
|
+
* widgetTypes={ widgetTypes }
|
|
35
|
+
* editMode={ editMode }
|
|
36
|
+
* onEditChange={ setEditMode }
|
|
37
|
+
* >
|
|
38
|
+
* <WidgetDashboard.NoWidgetsState>
|
|
39
|
+
* <p>No widgets yet.</p>
|
|
40
|
+
* </WidgetDashboard.NoWidgetsState>
|
|
41
|
+
* <WidgetDashboard.Actions />
|
|
42
|
+
* <WidgetDashboard.Widgets />
|
|
43
|
+
* <WidgetDashboard.Commands />
|
|
44
|
+
* </WidgetDashboard>
|
|
45
|
+
* );
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* Children compose the dashboard's triggers and chrome: `Actions`,
|
|
50
|
+
* `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the
|
|
51
|
+
* widget inserter, the layout and widget settings editors, the reset
|
|
52
|
+
* confirmation) are mounted by the engine and driven by shared UI state, so
|
|
53
|
+
* a trigger works wherever it is composed without a matching target in the
|
|
54
|
+
* tree. Omitting `children` renders the default arrangement.
|
|
55
|
+
*/
|
|
56
|
+
export const WidgetDashboard = Object.assign(
|
|
57
|
+
function WidgetDashboard( {
|
|
58
|
+
layout,
|
|
59
|
+
onLayoutChange,
|
|
60
|
+
onLayoutReset,
|
|
61
|
+
widgetTypes,
|
|
62
|
+
isResolvingWidgetTypes,
|
|
63
|
+
editMode,
|
|
64
|
+
onEditChange,
|
|
65
|
+
resolveWidgetModule,
|
|
66
|
+
gridSettings,
|
|
67
|
+
onGridSettingsChange,
|
|
68
|
+
children,
|
|
69
|
+
}: WidgetDashboardProps ) {
|
|
70
|
+
return (
|
|
71
|
+
<WidgetDashboardProvider
|
|
72
|
+
layout={ layout }
|
|
73
|
+
onLayoutChange={ onLayoutChange }
|
|
74
|
+
onLayoutReset={ onLayoutReset }
|
|
75
|
+
widgetTypes={ widgetTypes }
|
|
76
|
+
isResolvingWidgetTypes={ isResolvingWidgetTypes }
|
|
77
|
+
editMode={ editMode }
|
|
78
|
+
onEditChange={ onEditChange }
|
|
79
|
+
resolveWidgetModule={ resolveWidgetModule }
|
|
80
|
+
gridSettings={ gridSettings }
|
|
81
|
+
onGridSettingsChange={ onGridSettingsChange }
|
|
82
|
+
>
|
|
83
|
+
<WidgetDashboardUIProvider>
|
|
84
|
+
{ children ?? (
|
|
85
|
+
<>
|
|
86
|
+
<NoWidgetsState />
|
|
87
|
+
<Actions />
|
|
88
|
+
<Widgets />
|
|
89
|
+
<Commands />
|
|
90
|
+
</>
|
|
91
|
+
) }
|
|
92
|
+
|
|
93
|
+
<WidgetInserter />
|
|
94
|
+
<LayoutSettings />
|
|
95
|
+
<WidgetSettings />
|
|
96
|
+
<ResetConfirmation />
|
|
97
|
+
</WidgetDashboardUIProvider>
|
|
98
|
+
</WidgetDashboardProvider>
|
|
99
|
+
);
|
|
100
|
+
},
|
|
101
|
+
{ Actions, Widgets, WidgetChrome, NoWidgetsState, Commands }
|
|
102
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* `@wordpress/commands` ships untyped JavaScript resolved through gitignored
|
|
3
|
+
* build artifacts; this ambient declaration covers the surface this package
|
|
4
|
+
* consumes so type builds don't depend on those artifacts existing.
|
|
5
|
+
*/
|
|
6
|
+
declare module '@wordpress/commands' {
|
|
7
|
+
import type { StoreDescriptor } from '@wordpress/data';
|
|
8
|
+
|
|
9
|
+
export function useCommands( commands: unknown[] ): void;
|
|
10
|
+
export const privateApis: Record< string, unknown >;
|
|
11
|
+
export const store: StoreDescriptor;
|
|
12
|
+
}
|