@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,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
import { render, screen } from '@testing-library/react';
|
|
6
|
+
import userEvent from '@testing-library/user-event';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* WordPress dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { useState } from '@wordpress/element';
|
|
12
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { WidgetDashboard } from '../widget-dashboard';
|
|
18
|
+
import type { DashboardWidget, WidgetGridSettings } from '../types';
|
|
19
|
+
|
|
20
|
+
const widgetTypes: WidgetType[] = [];
|
|
21
|
+
|
|
22
|
+
// Use a non-empty layout so the provider's auto-edit-when-empty effect
|
|
23
|
+
// does not flip editMode on as a side effect of mounting.
|
|
24
|
+
const layout: DashboardWidget[] = [
|
|
25
|
+
{ uuid: 'a', type: 'core/test', placement: { width: 1, height: 1 } },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
const gridSettings: WidgetGridSettings = {
|
|
29
|
+
model: 'grid',
|
|
30
|
+
minColumnWidth: 350,
|
|
31
|
+
rowHeight: 200,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
interface HarnessProps {
|
|
35
|
+
initialEditMode?: boolean;
|
|
36
|
+
onEditChange?: ( next: boolean ) => void;
|
|
37
|
+
onLayoutChange?: ( next: DashboardWidget[] ) => void;
|
|
38
|
+
onGridSettingsChange?: ( next: WidgetGridSettings ) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function Harness( {
|
|
42
|
+
initialEditMode = false,
|
|
43
|
+
onEditChange,
|
|
44
|
+
onLayoutChange = () => {},
|
|
45
|
+
onGridSettingsChange,
|
|
46
|
+
}: HarnessProps ) {
|
|
47
|
+
const [ editMode, setEditMode ] = useState( initialEditMode );
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<WidgetDashboard
|
|
51
|
+
layout={ layout }
|
|
52
|
+
onLayoutChange={ onLayoutChange }
|
|
53
|
+
gridSettings={ gridSettings }
|
|
54
|
+
onGridSettingsChange={ onGridSettingsChange }
|
|
55
|
+
widgetTypes={ widgetTypes }
|
|
56
|
+
editMode={ editMode }
|
|
57
|
+
onEditChange={ ( next ) => {
|
|
58
|
+
setEditMode( next );
|
|
59
|
+
onEditChange?.( next );
|
|
60
|
+
} }
|
|
61
|
+
>
|
|
62
|
+
<WidgetDashboard.Actions />
|
|
63
|
+
</WidgetDashboard>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
describe( 'WidgetDashboard.Actions', () => {
|
|
68
|
+
let user: ReturnType< typeof userEvent.setup >;
|
|
69
|
+
|
|
70
|
+
beforeEach( () => {
|
|
71
|
+
user = userEvent.setup();
|
|
72
|
+
} );
|
|
73
|
+
|
|
74
|
+
it( 'renders the Customize button when editMode is false', () => {
|
|
75
|
+
render( <Harness /> );
|
|
76
|
+
|
|
77
|
+
expect(
|
|
78
|
+
screen.getByRole( 'button', { name: 'Customize' } )
|
|
79
|
+
).toBeInTheDocument();
|
|
80
|
+
expect(
|
|
81
|
+
screen.queryByRole( 'button', { name: 'Done' } )
|
|
82
|
+
).not.toBeInTheDocument();
|
|
83
|
+
} );
|
|
84
|
+
|
|
85
|
+
it( 'renders the Done button when editMode is true', () => {
|
|
86
|
+
render( <Harness initialEditMode /> );
|
|
87
|
+
|
|
88
|
+
expect(
|
|
89
|
+
screen.getByRole( 'button', { name: 'Done' } )
|
|
90
|
+
).toBeInTheDocument();
|
|
91
|
+
expect(
|
|
92
|
+
screen.queryByRole( 'button', { name: 'Customize' } )
|
|
93
|
+
).not.toBeInTheDocument();
|
|
94
|
+
} );
|
|
95
|
+
|
|
96
|
+
it( 'fires onEditChange with true when Customize is clicked', async () => {
|
|
97
|
+
const onEditChange = jest.fn();
|
|
98
|
+
render( <Harness onEditChange={ onEditChange } /> );
|
|
99
|
+
|
|
100
|
+
await user.click( screen.getByRole( 'button', { name: 'Customize' } ) );
|
|
101
|
+
|
|
102
|
+
expect( onEditChange ).toHaveBeenLastCalledWith( true );
|
|
103
|
+
} );
|
|
104
|
+
|
|
105
|
+
it( 'disables Done when there are no staging changes', () => {
|
|
106
|
+
render( <Harness initialEditMode /> );
|
|
107
|
+
|
|
108
|
+
expect(
|
|
109
|
+
screen.getByRole( 'button', { name: 'Done' } )
|
|
110
|
+
).toHaveAttribute( 'aria-disabled', 'true' );
|
|
111
|
+
} );
|
|
112
|
+
|
|
113
|
+
it( 'fires onEditChange with false when Cancel is clicked', async () => {
|
|
114
|
+
const onEditChange = jest.fn();
|
|
115
|
+
const onLayoutChange = jest.fn();
|
|
116
|
+
render(
|
|
117
|
+
<Harness
|
|
118
|
+
initialEditMode
|
|
119
|
+
onEditChange={ onEditChange }
|
|
120
|
+
onLayoutChange={ onLayoutChange }
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
await user.click( screen.getByRole( 'button', { name: 'Cancel' } ) );
|
|
125
|
+
|
|
126
|
+
expect( onEditChange ).toHaveBeenLastCalledWith( false );
|
|
127
|
+
expect( onLayoutChange ).not.toHaveBeenCalled();
|
|
128
|
+
} );
|
|
129
|
+
|
|
130
|
+
it( 'renders nothing when onEditChange is not provided', () => {
|
|
131
|
+
render(
|
|
132
|
+
<WidgetDashboard
|
|
133
|
+
layout={ layout }
|
|
134
|
+
onLayoutChange={ () => {} }
|
|
135
|
+
widgetTypes={ widgetTypes }
|
|
136
|
+
>
|
|
137
|
+
<WidgetDashboard.Actions />
|
|
138
|
+
</WidgetDashboard>
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
expect(
|
|
142
|
+
screen.queryByRole( 'button', { name: 'Customize' } )
|
|
143
|
+
).not.toBeInTheDocument();
|
|
144
|
+
expect(
|
|
145
|
+
screen.queryByRole( 'button', { name: 'Done' } )
|
|
146
|
+
).not.toBeInTheDocument();
|
|
147
|
+
} );
|
|
148
|
+
|
|
149
|
+
describe( 'Layout settings', () => {
|
|
150
|
+
it( 'is hidden when editMode is false', () => {
|
|
151
|
+
render( <Harness onGridSettingsChange={ () => {} } /> );
|
|
152
|
+
|
|
153
|
+
expect(
|
|
154
|
+
screen.queryByRole( 'button', { name: 'Layout settings' } )
|
|
155
|
+
).not.toBeInTheDocument();
|
|
156
|
+
} );
|
|
157
|
+
|
|
158
|
+
it( 'is visible in the edit toolbar when grid settings are editable', () => {
|
|
159
|
+
render(
|
|
160
|
+
<Harness initialEditMode onGridSettingsChange={ () => {} } />
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
expect(
|
|
164
|
+
screen.getByRole( 'button', { name: 'Layout settings' } )
|
|
165
|
+
).toBeInTheDocument();
|
|
166
|
+
} );
|
|
167
|
+
|
|
168
|
+
it( 'is hidden when onGridSettingsChange is not provided', () => {
|
|
169
|
+
render( <Harness initialEditMode /> );
|
|
170
|
+
|
|
171
|
+
expect(
|
|
172
|
+
screen.queryByRole( 'button', { name: 'Layout settings' } )
|
|
173
|
+
).not.toBeInTheDocument();
|
|
174
|
+
} );
|
|
175
|
+
|
|
176
|
+
it( 'opens the layout settings drawer when clicked', async () => {
|
|
177
|
+
render(
|
|
178
|
+
<Harness initialEditMode onGridSettingsChange={ () => {} } />
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
await user.click(
|
|
182
|
+
screen.getByRole( 'button', { name: 'Layout settings' } )
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
expect(
|
|
186
|
+
await screen.findByRole( 'dialog', { name: 'Layout settings' } )
|
|
187
|
+
).toBeInTheDocument();
|
|
188
|
+
} );
|
|
189
|
+
|
|
190
|
+
it( 'is not in the more-actions menu', async () => {
|
|
191
|
+
const onLayoutReset = jest.fn();
|
|
192
|
+
render(
|
|
193
|
+
<WidgetDashboard
|
|
194
|
+
layout={ layout }
|
|
195
|
+
onLayoutChange={ () => {} }
|
|
196
|
+
onLayoutReset={ onLayoutReset }
|
|
197
|
+
gridSettings={ gridSettings }
|
|
198
|
+
onGridSettingsChange={ () => {} }
|
|
199
|
+
widgetTypes={ widgetTypes }
|
|
200
|
+
editMode
|
|
201
|
+
onEditChange={ () => {} }
|
|
202
|
+
>
|
|
203
|
+
<WidgetDashboard.Actions />
|
|
204
|
+
</WidgetDashboard>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
await user.click(
|
|
208
|
+
screen.getByRole( 'button', { name: 'More options' } )
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
expect(
|
|
212
|
+
screen.queryByRole( 'menuitem', { name: 'Layout settings' } )
|
|
213
|
+
).not.toBeInTheDocument();
|
|
214
|
+
} );
|
|
215
|
+
} );
|
|
216
|
+
|
|
217
|
+
it( 'throws when used outside a WidgetDashboard subtree', () => {
|
|
218
|
+
const spy = jest
|
|
219
|
+
.spyOn( console, 'error' )
|
|
220
|
+
.mockImplementation( () => {} );
|
|
221
|
+
|
|
222
|
+
expect( () => render( <WidgetDashboard.Actions /> ) ).toThrow(
|
|
223
|
+
/Dashboard compound used outside a WidgetDashboard subtree/
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
spy.mockRestore();
|
|
227
|
+
} );
|
|
228
|
+
} );
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
import { render, screen } from '@testing-library/react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { store as commandsStore } from '@wordpress/commands';
|
|
13
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import { WidgetDashboard } from '../widget-dashboard';
|
|
19
|
+
import { DASHBOARD_COMMAND_CONTEXT } from '../components/commands';
|
|
20
|
+
import type { DashboardWidget } from '../types';
|
|
21
|
+
|
|
22
|
+
const widgetTypes: WidgetType[] = [];
|
|
23
|
+
|
|
24
|
+
const layout: DashboardWidget[] = [
|
|
25
|
+
{ uuid: 'a', type: 'core/test', placement: { width: 1, height: 1 } },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
function CommandsProbe( { names }: { names: string[] } ) {
|
|
29
|
+
const context = useSelect(
|
|
30
|
+
( select ) => select( commandsStore ).getContext(),
|
|
31
|
+
[]
|
|
32
|
+
);
|
|
33
|
+
const contextualCommands = useSelect(
|
|
34
|
+
( select ) => select( commandsStore ).getCommands( true ),
|
|
35
|
+
[]
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const registered = useMemo(
|
|
39
|
+
() =>
|
|
40
|
+
Object.fromEntries(
|
|
41
|
+
names.map( ( name ) => [
|
|
42
|
+
name,
|
|
43
|
+
contextualCommands.some(
|
|
44
|
+
( command ) => command.name === name
|
|
45
|
+
),
|
|
46
|
+
] )
|
|
47
|
+
),
|
|
48
|
+
[ names, contextualCommands ]
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
data-testid="commands-probe"
|
|
54
|
+
data-context={ context }
|
|
55
|
+
data-registered={ JSON.stringify( registered ) }
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const COMMAND_NAMES = [
|
|
61
|
+
'core/dashboard/customize',
|
|
62
|
+
'core/dashboard/add-widgets',
|
|
63
|
+
'core/dashboard/switch-to-masonry-layout',
|
|
64
|
+
'core/dashboard/switch-to-grid-layout',
|
|
65
|
+
'core/dashboard/reset-to-default',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
interface HarnessProps {
|
|
69
|
+
initialEditMode?: boolean;
|
|
70
|
+
withGridSettings?: boolean;
|
|
71
|
+
withLayoutReset?: boolean;
|
|
72
|
+
gridModel?: 'grid' | 'masonry';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function Harness( {
|
|
76
|
+
initialEditMode = false,
|
|
77
|
+
withGridSettings = false,
|
|
78
|
+
withLayoutReset = false,
|
|
79
|
+
gridModel = 'grid',
|
|
80
|
+
}: HarnessProps ) {
|
|
81
|
+
const [ editMode, setEditMode ] = useState( initialEditMode );
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<WidgetDashboard
|
|
85
|
+
layout={ layout }
|
|
86
|
+
onLayoutChange={ () => {} }
|
|
87
|
+
widgetTypes={ widgetTypes }
|
|
88
|
+
editMode={ editMode }
|
|
89
|
+
onEditChange={ setEditMode }
|
|
90
|
+
onLayoutReset={ withLayoutReset ? async () => {} : undefined }
|
|
91
|
+
gridSettings={
|
|
92
|
+
withGridSettings ? { model: gridModel, columns: 6 } : undefined
|
|
93
|
+
}
|
|
94
|
+
onGridSettingsChange={ withGridSettings ? () => {} : undefined }
|
|
95
|
+
>
|
|
96
|
+
<WidgetDashboard.Commands />
|
|
97
|
+
<CommandsProbe names={ COMMAND_NAMES } />
|
|
98
|
+
</WidgetDashboard>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function getRegistered( probe: HTMLElement ): Record< string, boolean > {
|
|
103
|
+
return JSON.parse( probe.getAttribute( 'data-registered' ) ?? '{}' );
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
describe( 'WidgetDashboard.Commands', () => {
|
|
107
|
+
it( 'sets the dashboard command context and registers core commands', () => {
|
|
108
|
+
render( <Harness withGridSettings withLayoutReset /> );
|
|
109
|
+
const probe = screen.getByTestId( 'commands-probe' );
|
|
110
|
+
const registered = getRegistered( probe );
|
|
111
|
+
|
|
112
|
+
expect( probe ).toHaveAttribute(
|
|
113
|
+
'data-context',
|
|
114
|
+
DASHBOARD_COMMAND_CONTEXT
|
|
115
|
+
);
|
|
116
|
+
expect( registered[ 'core/dashboard/customize' ] ).toBe( true );
|
|
117
|
+
expect( registered[ 'core/dashboard/add-widgets' ] ).toBe( true );
|
|
118
|
+
expect( registered[ 'core/dashboard/reset-to-default' ] ).toBe( true );
|
|
119
|
+
} );
|
|
120
|
+
|
|
121
|
+
it( 'unregisters Customize while edit mode is active', () => {
|
|
122
|
+
render( <Harness initialEditMode withGridSettings withLayoutReset /> );
|
|
123
|
+
const registered = getRegistered(
|
|
124
|
+
screen.getByTestId( 'commands-probe' )
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
expect( registered[ 'core/dashboard/customize' ] ).toBe( false );
|
|
128
|
+
expect( registered[ 'core/dashboard/add-widgets' ] ).toBe( true );
|
|
129
|
+
} );
|
|
130
|
+
|
|
131
|
+
it( 'disables layout commands while edit mode is active', () => {
|
|
132
|
+
render(
|
|
133
|
+
<Harness
|
|
134
|
+
initialEditMode
|
|
135
|
+
withGridSettings
|
|
136
|
+
withLayoutReset
|
|
137
|
+
gridModel="grid"
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
const registered = getRegistered(
|
|
141
|
+
screen.getByTestId( 'commands-probe' )
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
expect( registered[ 'core/dashboard/switch-to-masonry-layout' ] ).toBe(
|
|
145
|
+
false
|
|
146
|
+
);
|
|
147
|
+
expect( registered[ 'core/dashboard/switch-to-grid-layout' ] ).toBe(
|
|
148
|
+
false
|
|
149
|
+
);
|
|
150
|
+
} );
|
|
151
|
+
|
|
152
|
+
it( 'only registers the active layout-model switch command', () => {
|
|
153
|
+
render( <Harness withGridSettings withLayoutReset gridModel="grid" /> );
|
|
154
|
+
const registered = getRegistered(
|
|
155
|
+
screen.getByTestId( 'commands-probe' )
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect( registered[ 'core/dashboard/switch-to-masonry-layout' ] ).toBe(
|
|
159
|
+
true
|
|
160
|
+
);
|
|
161
|
+
expect( registered[ 'core/dashboard/switch-to-grid-layout' ] ).toBe(
|
|
162
|
+
false
|
|
163
|
+
);
|
|
164
|
+
} );
|
|
165
|
+
|
|
166
|
+
it( 'omits grid-settings commands when grid settings are not editable', () => {
|
|
167
|
+
render( <Harness withLayoutReset /> );
|
|
168
|
+
const registered = getRegistered(
|
|
169
|
+
screen.getByTestId( 'commands-probe' )
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
expect( registered[ 'core/dashboard/switch-to-masonry-layout' ] ).toBe(
|
|
173
|
+
false
|
|
174
|
+
);
|
|
175
|
+
} );
|
|
176
|
+
} );
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createDashboardWidget } from '../utils/create-dashboard-widget';
|
|
10
|
+
|
|
11
|
+
const baseType: WidgetType = {
|
|
12
|
+
apiVersion: 1,
|
|
13
|
+
name: 'core/example',
|
|
14
|
+
title: 'Example',
|
|
15
|
+
renderModule: 'https://example.test/widget.js',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
describe( 'createDashboardWidget', () => {
|
|
19
|
+
it( 'stamps the type name and a unique uuid', () => {
|
|
20
|
+
const a = createDashboardWidget( baseType );
|
|
21
|
+
const b = createDashboardWidget( baseType );
|
|
22
|
+
|
|
23
|
+
expect( a.type ).toBe( 'core/example' );
|
|
24
|
+
expect( b.type ).toBe( 'core/example' );
|
|
25
|
+
expect( a.uuid ).not.toBe( b.uuid );
|
|
26
|
+
expect( a.uuid ).toMatch( /^[0-9a-f-]{36}$/ );
|
|
27
|
+
} );
|
|
28
|
+
|
|
29
|
+
it( 'applies default placement values', () => {
|
|
30
|
+
const instance = createDashboardWidget( baseType );
|
|
31
|
+
expect( instance.placement ).toEqual( {
|
|
32
|
+
width: 1,
|
|
33
|
+
height: 2,
|
|
34
|
+
order: 0,
|
|
35
|
+
} );
|
|
36
|
+
} );
|
|
37
|
+
|
|
38
|
+
it( 'uses initialAttributes when provided', () => {
|
|
39
|
+
const instance = createDashboardWidget< { greeting: string } >(
|
|
40
|
+
baseType,
|
|
41
|
+
{ greeting: 'hi' }
|
|
42
|
+
);
|
|
43
|
+
expect( instance.attributes ).toEqual( { greeting: 'hi' } );
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
it( 'falls back to the type example attributes when no attributes are supplied', () => {
|
|
47
|
+
const typeWithExample: WidgetType = {
|
|
48
|
+
...baseType,
|
|
49
|
+
example: { attributes: { greeting: 'default' } },
|
|
50
|
+
};
|
|
51
|
+
const instance = createDashboardWidget( typeWithExample );
|
|
52
|
+
expect( instance.attributes ).toEqual( { greeting: 'default' } );
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
it( 'leaves attributes undefined when no example and no initial provided', () => {
|
|
56
|
+
const instance = createDashboardWidget( baseType );
|
|
57
|
+
expect( instance.attributes ).toBeUndefined();
|
|
58
|
+
} );
|
|
59
|
+
} );
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useWidgetContext } from '../context/widget-context';
|
|
10
|
+
|
|
11
|
+
function CaptureWidgetContext( {
|
|
12
|
+
onRender,
|
|
13
|
+
}: {
|
|
14
|
+
onRender: ( value: ReturnType< typeof useWidgetContext > ) => void;
|
|
15
|
+
} ) {
|
|
16
|
+
onRender( useWidgetContext() );
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe( 'useWidgetContext', () => {
|
|
21
|
+
it( 'returns null outside a widget render subtree', () => {
|
|
22
|
+
const handler = jest.fn();
|
|
23
|
+
render( <CaptureWidgetContext onRender={ handler } /> );
|
|
24
|
+
expect( handler ).toHaveBeenCalledWith( null );
|
|
25
|
+
} );
|
|
26
|
+
} );
|