@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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { home } from '@wordpress/icons';
|
|
11
|
+
import { EmptyState, Stack } from '@wordpress/ui';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
17
|
+
import styles from './no-widgets-state.module.css';
|
|
18
|
+
|
|
19
|
+
export interface NoWidgetsStateProps {
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Empty-state placeholder shown while the dashboard `layout` has no widgets.
|
|
25
|
+
* Pair it with `WidgetDashboard.Widgets` so it stands in for the grid until
|
|
26
|
+
* widgets are added. Falls back to a built-in placeholder; pass `children` to
|
|
27
|
+
* override.
|
|
28
|
+
*
|
|
29
|
+
* @param {NoWidgetsStateProps} props Component props.
|
|
30
|
+
*/
|
|
31
|
+
export function NoWidgetsState( {
|
|
32
|
+
children,
|
|
33
|
+
}: NoWidgetsStateProps ): React.ReactNode {
|
|
34
|
+
const { layout } = useDashboardInternalContext();
|
|
35
|
+
if ( layout.length > 0 ) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Stack justify="center" align="center" className={ styles.root }>
|
|
41
|
+
{ children ?? (
|
|
42
|
+
<EmptyState.Root>
|
|
43
|
+
<EmptyState.Icon icon={ home } />
|
|
44
|
+
<EmptyState.Title>
|
|
45
|
+
{ __( 'Your dashboard is empty' ) }
|
|
46
|
+
</EmptyState.Title>
|
|
47
|
+
<EmptyState.Description>
|
|
48
|
+
{ __(
|
|
49
|
+
'Add widgets to start customizing your dashboard.'
|
|
50
|
+
) }
|
|
51
|
+
</EmptyState.Description>
|
|
52
|
+
</EmptyState.Root>
|
|
53
|
+
) }
|
|
54
|
+
</Stack>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ResetConfirmation } from './reset-confirmation';
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
6
|
+
import { AlertDialog } from '@wordpress/ui';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
12
|
+
import { useDashboardUIContext } from '../../context/ui-context';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Confirmation prompt for resetting the dashboard to its default layout,
|
|
16
|
+
* mounted by the engine and shown while `resetDialogOpen` is set in the
|
|
17
|
+
* shared UI context. Confirming runs `onLayoutReset` and leaves customize
|
|
18
|
+
* mode.
|
|
19
|
+
*/
|
|
20
|
+
export function ResetConfirmation(): React.ReactNode {
|
|
21
|
+
const { onLayoutReset, onEditChange } = useDashboardInternalContext();
|
|
22
|
+
const { resetDialogOpen, setResetDialogOpen } = useDashboardUIContext();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<AlertDialog.Root
|
|
26
|
+
open={ resetDialogOpen }
|
|
27
|
+
onOpenChange={ setResetDialogOpen }
|
|
28
|
+
onConfirm={ async () => {
|
|
29
|
+
await onLayoutReset?.();
|
|
30
|
+
onEditChange?.( false );
|
|
31
|
+
setResetDialogOpen( false );
|
|
32
|
+
} }
|
|
33
|
+
>
|
|
34
|
+
<AlertDialog.Popup
|
|
35
|
+
intent="irreversible"
|
|
36
|
+
title={ __( 'Reset dashboard to default?' ) }
|
|
37
|
+
description={ __(
|
|
38
|
+
'All customizations will be permanently lost.'
|
|
39
|
+
) }
|
|
40
|
+
confirmButtonText={ __( 'Reset' ) }
|
|
41
|
+
/>
|
|
42
|
+
</AlertDialog.Root>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetChrome } from './widget-chrome';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.widgetChrome {
|
|
2
|
+
height: 100%;
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Isolate the widget body from the surrounding layout. In a fixed-row
|
|
6
|
+
* grid the tile height comes from its row span, but a body taller than
|
|
7
|
+
* the tile lets its intrinsic size feed the grid item's `min-height: auto`
|
|
8
|
+
* and overflow the cell, adding scroll space below the grid. Layout
|
|
9
|
+
* containment severs that propagation so the body stays within the tile
|
|
10
|
+
* and scrolls internally. It contains layout only, not size or paint, so
|
|
11
|
+
* the masonry surface still measures the tile from its content and the
|
|
12
|
+
* tile elevation is not clipped.
|
|
13
|
+
*/
|
|
14
|
+
contain: layout;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* When keyboard focus lands on the widget's own content (a link or control
|
|
19
|
+
* the render module draws), outline the whole tile so Tab users can tell
|
|
20
|
+
* which widget holds focus, since an inner ring alone is easy to miss. Scoped
|
|
21
|
+
* to content focus, and to `:focus-visible` so a mouse click doesn't draw it.
|
|
22
|
+
*/
|
|
23
|
+
.widgetChrome:has(.widgetChromeContent :focus-visible) {
|
|
24
|
+
outline: var(--wpds-border-width-focus) solid var(--wpds-color-stroke-focus);
|
|
25
|
+
outline-offset: 2px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.widgetChromeHeaderIcon {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
color: var(--wpds-color-foreground-content-neutral);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
* Scroll container for the widget body. The card root clips its own overflow
|
|
35
|
+
* and the header is a fixed-size flex sibling, so confining the scroll to this
|
|
36
|
+
* element is what keeps the header pinned while the body scrolls.
|
|
37
|
+
*/
|
|
38
|
+
.widgetChromeContent {
|
|
39
|
+
flex: 1;
|
|
40
|
+
height: 100%;
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* As a flex item, the content area defaults to `min-height: auto`, which
|
|
45
|
+
* lets tall widget content expand it past the height the card allots
|
|
46
|
+
* instead of staying bounded. Pinning the min sizes to 0 keeps the area
|
|
47
|
+
* within its slot so a widget's own `overflow` scrolls internally rather
|
|
48
|
+
* than pushing past the card.
|
|
49
|
+
*/
|
|
50
|
+
min-width: 0;
|
|
51
|
+
min-height: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* Bleed block edges: zero the content's block padding so the body fills the
|
|
56
|
+
* card top to bottom. The top is ours to flush (a full-bleed widget hides its
|
|
57
|
+
* header in a position:absolute VisuallyHidden node that stays the card's
|
|
58
|
+
* :first-child and blocks Card.FullBleed's top-flush rule). The bottom pairs
|
|
59
|
+
* with the `margin-block-end: 0` on the bleed scroll wrapper below.
|
|
60
|
+
*/
|
|
61
|
+
.widgetChromeContentBleed {
|
|
62
|
+
padding-block: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Scroll container for a bleeding body. Card.FullBleed only does the edge
|
|
67
|
+
* breakout (negative margins) and declares no height or overflow, so the scroll
|
|
68
|
+
* container must be re-established here, on the wrapper that spans the card
|
|
69
|
+
* edges, so the scrollbar tracks the edge and the header stays pinned.
|
|
70
|
+
*
|
|
71
|
+
* Card.FullBleed also adds `margin-block-end: calc(var(--wp-ui-card-padding) *
|
|
72
|
+
* -1)` to cancel the content's bottom padding; that padding is zeroed above, so
|
|
73
|
+
* neutralize the margin. Left in, it pulls the wrapper's box short of the body,
|
|
74
|
+
* surfacing as a phantom scrollbar on a content-driven tile or a bottom inset
|
|
75
|
+
* on a fixed-height one.
|
|
76
|
+
*/
|
|
77
|
+
.widgetChromeBleedScroll {
|
|
78
|
+
height: 100%;
|
|
79
|
+
overflow-y: auto;
|
|
80
|
+
margin-block-end: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.loading,
|
|
84
|
+
.unavailable {
|
|
85
|
+
height: 100%;
|
|
86
|
+
}
|
|
87
|
+
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { Spinner } from '@wordpress/components';
|
|
11
|
+
import {
|
|
12
|
+
Component,
|
|
13
|
+
Suspense,
|
|
14
|
+
forwardRef,
|
|
15
|
+
useId,
|
|
16
|
+
useMemo,
|
|
17
|
+
} from '@wordpress/element';
|
|
18
|
+
import { __ } from '@wordpress/i18n';
|
|
19
|
+
import { plugins } from '@wordpress/icons';
|
|
20
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
21
|
+
import { Card, Icon, Stack, Notice, Text, VisuallyHidden } from '@wordpress/ui';
|
|
22
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
28
|
+
import { WidgetContextProvider } from '../../context/widget-context';
|
|
29
|
+
import { WidgetRender } from '../widget-render';
|
|
30
|
+
import styles from './widget-chrome.module.css';
|
|
31
|
+
import type { DashboardWidget } from '../../types';
|
|
32
|
+
|
|
33
|
+
interface ErrorBoundaryProps {
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface ErrorBoundaryState {
|
|
38
|
+
hasError: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class WidgetErrorBoundary extends Component<
|
|
42
|
+
ErrorBoundaryProps,
|
|
43
|
+
ErrorBoundaryState
|
|
44
|
+
> {
|
|
45
|
+
state: ErrorBoundaryState = { hasError: false };
|
|
46
|
+
|
|
47
|
+
static getDerivedStateFromError(): ErrorBoundaryState {
|
|
48
|
+
return { hasError: true };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
if ( this.state.hasError ) {
|
|
53
|
+
return (
|
|
54
|
+
<Notice.Root intent="error">
|
|
55
|
+
<Notice.Description>
|
|
56
|
+
{ __( 'This widget encountered an error.' ) }
|
|
57
|
+
</Notice.Description>
|
|
58
|
+
</Notice.Root>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return this.props.children;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function LoadingOverlay() {
|
|
66
|
+
return (
|
|
67
|
+
<Stack justify="center" align="center" className={ styles.loading }>
|
|
68
|
+
<Spinner />
|
|
69
|
+
</Stack>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface UnavailableWidgetProps {
|
|
74
|
+
widgetTypeName: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function UnavailableWidget( { widgetTypeName }: UnavailableWidgetProps ) {
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<Card.Header>
|
|
81
|
+
<span
|
|
82
|
+
className={ styles.widgetChromeHeaderIcon }
|
|
83
|
+
aria-hidden="true"
|
|
84
|
+
>
|
|
85
|
+
<Icon icon={ plugins } />
|
|
86
|
+
</span>
|
|
87
|
+
</Card.Header>
|
|
88
|
+
<Card.Content className={ styles.widgetChromeContent }>
|
|
89
|
+
<Stack
|
|
90
|
+
direction="column"
|
|
91
|
+
justify="center"
|
|
92
|
+
align="center"
|
|
93
|
+
gap="md"
|
|
94
|
+
className={ styles.unavailable }
|
|
95
|
+
>
|
|
96
|
+
<Text>{ __( 'Widget is no longer available.' ) }</Text>
|
|
97
|
+
<Text render={ <code /> }>{ widgetTypeName }</Text>
|
|
98
|
+
</Stack>
|
|
99
|
+
</Card.Content>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
interface HeaderProps {
|
|
105
|
+
titleId: string;
|
|
106
|
+
widgetType: WidgetType;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function Header( { titleId, widgetType }: HeaderProps ) {
|
|
110
|
+
if ( ! widgetType.title ) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<Card.Header>
|
|
116
|
+
<Stack direction="row" align="center" gap="sm">
|
|
117
|
+
{ widgetType.icon && (
|
|
118
|
+
<span
|
|
119
|
+
className={ styles.widgetChromeHeaderIcon }
|
|
120
|
+
aria-hidden="true"
|
|
121
|
+
>
|
|
122
|
+
<Icon icon={ widgetType.icon } />
|
|
123
|
+
</span>
|
|
124
|
+
) }
|
|
125
|
+
<Card.Title id={ titleId } render={ <h2 /> }>
|
|
126
|
+
{ widgetType.title }
|
|
127
|
+
</Card.Title>
|
|
128
|
+
</Stack>
|
|
129
|
+
</Card.Header>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface WidgetChromeProps {
|
|
134
|
+
widget: DashboardWidget< unknown >;
|
|
135
|
+
index: number;
|
|
136
|
+
/**
|
|
137
|
+
* Lifted by the surrounding `@wordpress/grid` surface into a sibling
|
|
138
|
+
* slot of the grid item; not rendered by `WidgetChrome` itself.
|
|
139
|
+
* Living outside `Card.Root` is what keeps these controls interactive
|
|
140
|
+
* while edit mode applies `inert` to the chrome.
|
|
141
|
+
*/
|
|
142
|
+
actionableArea?: ReactNode;
|
|
143
|
+
className?: string;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Per-instance wrapper. Owns the chrome around a widget instance: identity
|
|
148
|
+
* context, header (title + icon), edit-mode `inert` attribute, and the
|
|
149
|
+
* error/loading boundaries that keep neighbours mounted when one widget fails
|
|
150
|
+
* or is still resolving.
|
|
151
|
+
*/
|
|
152
|
+
export const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(
|
|
153
|
+
function WidgetChrome( { widget, index, className }, ref ) {
|
|
154
|
+
const { widgetTypes, isResolvingWidgetTypes, editMode } =
|
|
155
|
+
useDashboardInternalContext();
|
|
156
|
+
const widgetType = widgetTypes.find( ( t ) => t.name === widget.type );
|
|
157
|
+
const titleId = useId();
|
|
158
|
+
|
|
159
|
+
const contextValue = useMemo(
|
|
160
|
+
() => ( {
|
|
161
|
+
uuid: widget.uuid,
|
|
162
|
+
name: widget.type,
|
|
163
|
+
index,
|
|
164
|
+
} ),
|
|
165
|
+
[ widget.uuid, widget.type, index ]
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
if ( ! widgetType ) {
|
|
169
|
+
if ( isResolvingWidgetTypes ) {
|
|
170
|
+
return (
|
|
171
|
+
<WidgetContextProvider value={ contextValue }>
|
|
172
|
+
<Card.Root
|
|
173
|
+
render={ <section /> }
|
|
174
|
+
ref={ ref }
|
|
175
|
+
className={ clsx( styles.widgetChrome, className ) }
|
|
176
|
+
aria-busy="true"
|
|
177
|
+
aria-label={ __( 'Loading' ) }
|
|
178
|
+
>
|
|
179
|
+
<Card.Content
|
|
180
|
+
className={ styles.widgetChromeContent }
|
|
181
|
+
>
|
|
182
|
+
<LoadingOverlay />
|
|
183
|
+
</Card.Content>
|
|
184
|
+
</Card.Root>
|
|
185
|
+
</WidgetContextProvider>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<WidgetContextProvider value={ contextValue }>
|
|
191
|
+
<Card.Root
|
|
192
|
+
render={ <section /> }
|
|
193
|
+
ref={ ref }
|
|
194
|
+
className={ clsx( styles.widgetChrome, className ) }
|
|
195
|
+
aria-label={ __( 'Missing widget' ) }
|
|
196
|
+
>
|
|
197
|
+
<UnavailableWidget widgetTypeName={ widget.type } />
|
|
198
|
+
</Card.Root>
|
|
199
|
+
</WidgetContextProvider>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// `presentation` encodes two independent axes. `full-bleed` hides
|
|
204
|
+
// the header; both `full-bleed` and `content-bleed` let the body
|
|
205
|
+
// break out of the content padding.
|
|
206
|
+
const { presentation } = widgetType;
|
|
207
|
+
const isHeaderHidden = presentation === 'full-bleed';
|
|
208
|
+
const isBodyBleeding =
|
|
209
|
+
presentation === 'full-bleed' || presentation === 'content-bleed';
|
|
210
|
+
const header = <Header titleId={ titleId } widgetType={ widgetType } />;
|
|
211
|
+
|
|
212
|
+
const body = (
|
|
213
|
+
<WidgetErrorBoundary>
|
|
214
|
+
<Suspense fallback={ <LoadingOverlay /> }>
|
|
215
|
+
<WidgetRender widget={ widget } widgetType={ widgetType } />
|
|
216
|
+
</Suspense>
|
|
217
|
+
</WidgetErrorBoundary>
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<WidgetContextProvider value={ contextValue }>
|
|
222
|
+
<Card.Root
|
|
223
|
+
render={ <section /> }
|
|
224
|
+
ref={ ref }
|
|
225
|
+
className={ clsx( styles.widgetChrome, className ) }
|
|
226
|
+
aria-labelledby={ widgetType.title ? titleId : undefined }
|
|
227
|
+
{ ...( editMode ? { inert: 'true' } : {} ) }
|
|
228
|
+
>
|
|
229
|
+
{ isHeaderHidden ? (
|
|
230
|
+
<VisuallyHidden>{ header }</VisuallyHidden>
|
|
231
|
+
) : (
|
|
232
|
+
header
|
|
233
|
+
) }
|
|
234
|
+
|
|
235
|
+
<Card.Content
|
|
236
|
+
className={ clsx(
|
|
237
|
+
styles.widgetChromeContent,
|
|
238
|
+
isBodyBleeding && styles.widgetChromeContentBleed
|
|
239
|
+
) }
|
|
240
|
+
>
|
|
241
|
+
{ isBodyBleeding ? (
|
|
242
|
+
<Card.FullBleed
|
|
243
|
+
className={ styles.widgetChromeBleedScroll }
|
|
244
|
+
>
|
|
245
|
+
{ body }
|
|
246
|
+
</Card.FullBleed>
|
|
247
|
+
) : (
|
|
248
|
+
body
|
|
249
|
+
) }
|
|
250
|
+
</Card.Content>
|
|
251
|
+
</Card.Root>
|
|
252
|
+
</WidgetContextProvider>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetInserter } from './widget-inserter';
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
7
|
+
import { Dialog } from '@wordpress/ui';
|
|
8
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
14
|
+
import { useDashboardUIContext } from '../../context/ui-context';
|
|
15
|
+
import { createDashboardWidget } from '../../utils/create-dashboard-widget';
|
|
16
|
+
import { WidgetPicker } from '../widget-picker';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Modal widget inserter, mounted by the engine and shown while `inserterOpen`
|
|
20
|
+
* is set in the shared UI context. Selecting widgets appends them to the
|
|
21
|
+
* layout and closes the dialog.
|
|
22
|
+
*/
|
|
23
|
+
export function WidgetInserter() {
|
|
24
|
+
const { layout, onLayoutChange } = useDashboardInternalContext();
|
|
25
|
+
const { inserterOpen, setInserterOpen } = useDashboardUIContext();
|
|
26
|
+
|
|
27
|
+
const insertWidgets = useCallback(
|
|
28
|
+
( widgetTypes: WidgetType[] ) => {
|
|
29
|
+
if ( widgetTypes.length > 0 ) {
|
|
30
|
+
const newWidgets = widgetTypes.map( ( widgetType ) =>
|
|
31
|
+
createDashboardWidget( widgetType )
|
|
32
|
+
);
|
|
33
|
+
onLayoutChange( [ ...layout, ...newWidgets ] );
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setInserterOpen( false );
|
|
37
|
+
},
|
|
38
|
+
[ layout, onLayoutChange, setInserterOpen ]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if ( ! inserterOpen ) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dialog.Root open={ inserterOpen } onOpenChange={ setInserterOpen }>
|
|
47
|
+
<Dialog.Popup
|
|
48
|
+
size="full"
|
|
49
|
+
portal={
|
|
50
|
+
<Dialog.Portal
|
|
51
|
+
style={
|
|
52
|
+
{
|
|
53
|
+
'--wp-ui-dialog-z-index': 99999,
|
|
54
|
+
} as React.CSSProperties
|
|
55
|
+
}
|
|
56
|
+
/>
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
<Dialog.Header>
|
|
60
|
+
<Dialog.Title>{ __( 'Add widget' ) }</Dialog.Title>
|
|
61
|
+
<Dialog.CloseIcon />
|
|
62
|
+
</Dialog.Header>
|
|
63
|
+
|
|
64
|
+
<Dialog.Content>
|
|
65
|
+
<WidgetPicker onSelect={ insertWidgets } />
|
|
66
|
+
</Dialog.Content>
|
|
67
|
+
</Dialog.Popup>
|
|
68
|
+
</Dialog.Root>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetPicker } from './widget-picker';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
.preview {
|
|
2
|
+
width: 125%;
|
|
3
|
+
height: 125%;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
padding: 0;
|
|
6
|
+
transform: scale(0.8);
|
|
7
|
+
transform-origin: top left;
|
|
8
|
+
/* Let clicks and hovers reach the picker tile, not links inside the preview. */
|
|
9
|
+
pointer-events: none;
|
|
10
|
+
user-select: none;
|
|
11
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { DataViewsPicker, filterSortAndPaginate } from '@wordpress/dataviews';
|
|
5
|
+
import type { Field, View } from '@wordpress/dataviews';
|
|
6
|
+
import { Suspense, useMemo, useState } from '@wordpress/element';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
14
|
+
import { createDashboardWidget } from '../../utils/create-dashboard-widget';
|
|
15
|
+
import { WidgetRender } from '../widget-render';
|
|
16
|
+
import styles from './widget-picker.module.css';
|
|
17
|
+
|
|
18
|
+
const DEFAULT_VIEW: View = {
|
|
19
|
+
type: 'pickerGrid',
|
|
20
|
+
page: 1,
|
|
21
|
+
search: '',
|
|
22
|
+
mediaField: 'preview',
|
|
23
|
+
titleField: 'title',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const getItemId = ( item: WidgetType ) => item.name;
|
|
27
|
+
|
|
28
|
+
function WidgetPreview( { item }: { item: WidgetType } ) {
|
|
29
|
+
const exampleWidget = useMemo(
|
|
30
|
+
() => createDashboardWidget( item, item.example?.attributes ),
|
|
31
|
+
[ item ]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className={ styles.preview } { ...{ inert: '' } }>
|
|
36
|
+
<Suspense fallback={ null }>
|
|
37
|
+
<WidgetRender widget={ exampleWidget } widgetType={ item } />
|
|
38
|
+
</Suspense>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const fields: Field< WidgetType >[] = [
|
|
44
|
+
{
|
|
45
|
+
id: 'title',
|
|
46
|
+
type: 'text',
|
|
47
|
+
label: __( 'Title' ),
|
|
48
|
+
filterBy: false,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'preview',
|
|
52
|
+
type: 'media',
|
|
53
|
+
render: WidgetPreview,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'name',
|
|
57
|
+
type: 'text',
|
|
58
|
+
enableGlobalSearch: true,
|
|
59
|
+
enableHiding: false,
|
|
60
|
+
enableSorting: false,
|
|
61
|
+
filterBy: false,
|
|
62
|
+
getValue: ( { item } ) =>
|
|
63
|
+
`${ item.name.replace( /[\/,\-_]/g, ' ' ) } ${ item.title }`,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
interface WidgetPickerProps {
|
|
68
|
+
/**
|
|
69
|
+
* Called with the widget types selected by the user. The picker keeps
|
|
70
|
+
* its own selection state; consumers receive the resolved list when
|
|
71
|
+
* the "Select" action fires.
|
|
72
|
+
*/
|
|
73
|
+
onSelect: ( widgetTypes: WidgetType[] ) => void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Accessible label for the picker's item list.
|
|
77
|
+
*
|
|
78
|
+
* @default __( 'Widget list' )
|
|
79
|
+
*/
|
|
80
|
+
itemListLabel?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* DataViews-driven widget type picker. Lists `widgetTypes` from the dashboard
|
|
85
|
+
* context as a grid of live previews, supports search via `name`/`title`, and
|
|
86
|
+
* exposes a single "Select" action with bulk support so users can insert one
|
|
87
|
+
* or several widgets at once.
|
|
88
|
+
*
|
|
89
|
+
* @param {WidgetPickerProps} props Component props.
|
|
90
|
+
*/
|
|
91
|
+
export function WidgetPicker( {
|
|
92
|
+
onSelect,
|
|
93
|
+
itemListLabel = __( 'Widget list' ),
|
|
94
|
+
}: WidgetPickerProps ) {
|
|
95
|
+
const { widgetTypes: registeredTypes } = useDashboardInternalContext();
|
|
96
|
+
const [ selection, setSelection ] = useState< string[] >( [] );
|
|
97
|
+
const [ view, setView ] = useState< View >( DEFAULT_VIEW );
|
|
98
|
+
|
|
99
|
+
const { data: widgetTypes } = filterSortAndPaginate(
|
|
100
|
+
registeredTypes,
|
|
101
|
+
view,
|
|
102
|
+
fields
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
const actions = useMemo(
|
|
106
|
+
() => [
|
|
107
|
+
{
|
|
108
|
+
id: 'select',
|
|
109
|
+
label: __( 'Select' ),
|
|
110
|
+
isPrimary: true,
|
|
111
|
+
supportsBulk: true,
|
|
112
|
+
callback: ( items: WidgetType[] ) => onSelect( items ),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
[ onSelect ]
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<DataViewsPicker
|
|
120
|
+
data={ widgetTypes }
|
|
121
|
+
fields={ fields }
|
|
122
|
+
view={ view }
|
|
123
|
+
actions={ actions }
|
|
124
|
+
defaultLayouts={ { pickerGrid: {} } }
|
|
125
|
+
onChangeView={ setView }
|
|
126
|
+
isLoading={ false }
|
|
127
|
+
paginationInfo={ {
|
|
128
|
+
totalItems: widgetTypes.length,
|
|
129
|
+
totalPages: 1,
|
|
130
|
+
} }
|
|
131
|
+
selection={ selection }
|
|
132
|
+
onChangeSelection={ setSelection }
|
|
133
|
+
getItemId={ getItemId }
|
|
134
|
+
itemListLabel={ itemListLabel }
|
|
135
|
+
/>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WidgetRender } from './widget-render';
|