@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,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Container width (px) below which the dashboard uses a single column.
|
|
3
|
+
* Matches `@container widget-dashboard (max-width: …)` in widgets CSS.
|
|
4
|
+
*/
|
|
5
|
+
export declare const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN = 600;
|
|
6
|
+
/**
|
|
7
|
+
* Container width (px) below which the dashboard drops from four columns
|
|
8
|
+
* to two. Above this threshold (and below the four-column cap) the
|
|
9
|
+
* grid uses {@link WIDGET_DASHBOARD_COLUMN_COUNT}.
|
|
10
|
+
*/
|
|
11
|
+
export declare const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS = 960;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the dashboard grid column count from the widget surface
|
|
14
|
+
* container width. Uses discrete steps (4 → 2 → 1), not viewport
|
|
15
|
+
* media queries.
|
|
16
|
+
*
|
|
17
|
+
* @param containerWidth Measured inline size of the dashboard grid container.
|
|
18
|
+
* @return Column count for {@link @wordpress/grid} surfaces.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveDashboardColumnCount(containerWidth: number): number;
|
|
21
|
+
//# sourceMappingURL=resolve-dashboard-column-count.d.ts.map
|
package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-dashboard-column-count.d.ts","sourceRoot":"","sources":["../../../src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,gDAAgD,MAAM,CAAC;AAEpE;;;;GAIG;AACH,eAAO,MAAM,iDAAiD,MAAM,CAAC;AAErE;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAE,cAAc,EAAE,MAAM,GAAI,MAAM,CAc5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/row-height-presets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACb,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const ROW_HEIGHT_PRESETS: {
|
|
2
|
+
readonly small: 200;
|
|
3
|
+
readonly medium: 300;
|
|
4
|
+
readonly large: 400;
|
|
5
|
+
};
|
|
6
|
+
export type RowHeightPreset = keyof typeof ROW_HEIGHT_PRESETS;
|
|
7
|
+
export declare const DEFAULT_ROW_HEIGHT: 300;
|
|
8
|
+
/**
|
|
9
|
+
* Maps a stored pixel height to the nearest preset so legacy freeform
|
|
10
|
+
* values still resolve to a valid toggle option.
|
|
11
|
+
*
|
|
12
|
+
* @param rowHeight Row height in pixels.
|
|
13
|
+
*/
|
|
14
|
+
export declare function rowHeightToPreset(rowHeight: number): RowHeightPreset;
|
|
15
|
+
export declare function presetToRowHeight(preset: RowHeightPreset): number;
|
|
16
|
+
export declare function snapRowHeight(rowHeight: number): number;
|
|
17
|
+
//# sourceMappingURL=row-height-presets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-height-presets.d.ts","sourceRoot":"","sources":["../../../src/utils/row-height-presets/row-height-presets.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;aAC9B,KAAK,EAAE,GAAG;aACV,MAAM,EAAE,GAAG;aACX,KAAK,EAAE,GAAG;CACD,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,kBAAkB,CAAC;AAE9D,eAAO,MAAM,kBAAkB,KAA4B,CAAC;AAO5D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAE,SAAS,EAAE,MAAM,GAAI,eAAe,CAatE;AAED,wBAAgB,iBAAiB,CAAE,MAAM,EAAE,eAAe,GAAI,MAAM,CAEnE;AAED,wBAAgB,aAAa,CAAE,SAAS,EAAE,MAAM,GAAI,MAAM,CAEzD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Actions } from './components/actions';
|
|
2
|
+
import { Commands } from './components/commands';
|
|
3
|
+
import { NoWidgetsState } from './components/no-widgets-state';
|
|
4
|
+
import type { WidgetDashboardProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* Stateless rendering engine for widget dashboards.
|
|
7
|
+
*
|
|
8
|
+
* The consumer owns `layout` and `editMode` state; every mutation fires
|
|
9
|
+
* `onLayoutChange` with the fully updated array. The engine never queries a
|
|
10
|
+
* widget store; types flow in via the `widgetTypes` prop.
|
|
11
|
+
*
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { WidgetDashboard } from '@wordpress/widget-dashboard';
|
|
14
|
+
*
|
|
15
|
+
* function MyDashboard() {
|
|
16
|
+
* const [ layout, setLayout ] = useState( defaultLayout );
|
|
17
|
+
* const [ editMode, setEditMode ] = useState( false );
|
|
18
|
+
* return (
|
|
19
|
+
* <WidgetDashboard
|
|
20
|
+
* layout={ layout }
|
|
21
|
+
* onLayoutChange={ setLayout }
|
|
22
|
+
* widgetTypes={ widgetTypes }
|
|
23
|
+
* editMode={ editMode }
|
|
24
|
+
* onEditChange={ setEditMode }
|
|
25
|
+
* >
|
|
26
|
+
* <WidgetDashboard.NoWidgetsState>
|
|
27
|
+
* <p>No widgets yet.</p>
|
|
28
|
+
* </WidgetDashboard.NoWidgetsState>
|
|
29
|
+
* <WidgetDashboard.Actions />
|
|
30
|
+
* <WidgetDashboard.Widgets />
|
|
31
|
+
* <WidgetDashboard.Commands />
|
|
32
|
+
* </WidgetDashboard>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Children compose the dashboard's triggers and chrome: `Actions`,
|
|
38
|
+
* `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the
|
|
39
|
+
* widget inserter, the layout and widget settings editors, the reset
|
|
40
|
+
* confirmation) are mounted by the engine and driven by shared UI state, so
|
|
41
|
+
* a trigger works wherever it is composed without a matching target in the
|
|
42
|
+
* tree. Omitting `children` renders the default arrangement.
|
|
43
|
+
*/
|
|
44
|
+
export declare const WidgetDashboard: (({ layout, onLayoutChange, onLayoutReset, widgetTypes, isResolvingWidgetTypes, editMode, onEditChange, resolveWidgetModule, gridSettings, onGridSettingsChange, children, }: WidgetDashboardProps) => import("react").JSX.Element) & {
|
|
45
|
+
Actions: typeof Actions;
|
|
46
|
+
Widgets: import("react").ForwardRefExoticComponent<import("./components/widgets/widgets").WidgetsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
47
|
+
WidgetChrome: import("react").ForwardRefExoticComponent<import("./components/widget-chrome/widget-chrome").WidgetChromeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
48
|
+
NoWidgetsState: typeof NoWidgetsState;
|
|
49
|
+
Commands: typeof Commands;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=widget-dashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-dashboard.d.ts","sourceRoot":"","sources":["../src/widget-dashboard.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAM/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,eAAe,gLAaxB,oBAAoB;;;;;;CAiCvB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wordpress/widget-dashboard",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Stateless rendering engine for widget dashboards: the WidgetDashboard compound component and its grid-settings kit.",
|
|
5
|
+
"author": "The WordPress Contributors",
|
|
6
|
+
"license": "GPL-2.0-or-later",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"wordpress",
|
|
9
|
+
"gutenberg",
|
|
10
|
+
"widgets",
|
|
11
|
+
"dashboard",
|
|
12
|
+
"grid"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/widget-dashboard/README.md",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/WordPress/gutenberg.git",
|
|
18
|
+
"directory": "packages/widget-dashboard"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/WordPress/gutenberg/issues"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=20.10.0",
|
|
25
|
+
"npm": ">=10.2.3"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"src",
|
|
29
|
+
"build",
|
|
30
|
+
"build-module",
|
|
31
|
+
"build-types",
|
|
32
|
+
"*.md"
|
|
33
|
+
],
|
|
34
|
+
"main": "build/index.cjs",
|
|
35
|
+
"module": "build-module/index.mjs",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./build-types/index.d.ts",
|
|
39
|
+
"import": "./build-module/index.mjs",
|
|
40
|
+
"default": "./build/index.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"wpScript": false,
|
|
45
|
+
"types": "build-types",
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"src/**/*.module.css"
|
|
48
|
+
],
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@wordpress/commands": "^1.49.0",
|
|
51
|
+
"@wordpress/components": "^36.0.0",
|
|
52
|
+
"@wordpress/compose": "^8.2.0",
|
|
53
|
+
"@wordpress/data": "^10.49.0",
|
|
54
|
+
"@wordpress/dataviews": "^17.0.0",
|
|
55
|
+
"@wordpress/element": "^8.1.0",
|
|
56
|
+
"@wordpress/grid": "^0.1.0",
|
|
57
|
+
"@wordpress/i18n": "^6.22.0",
|
|
58
|
+
"@wordpress/icons": "^15.0.0",
|
|
59
|
+
"@wordpress/primitives": "^4.49.0",
|
|
60
|
+
"@wordpress/private-apis": "^1.49.0",
|
|
61
|
+
"@wordpress/style-runtime": "^0.5.0",
|
|
62
|
+
"@wordpress/ui": "^0.16.0",
|
|
63
|
+
"@wordpress/viewport": "^6.49.0",
|
|
64
|
+
"@wordpress/widget-primitives": "^0.1.0",
|
|
65
|
+
"clsx": "^2.1.1",
|
|
66
|
+
"fast-deep-equal": "^3.1.3",
|
|
67
|
+
"uuid": "^14.0.0"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@testing-library/dom": "^10.4.1",
|
|
71
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
72
|
+
"@testing-library/react": "^16.3.2",
|
|
73
|
+
"@testing-library/user-event": "^14.6.1",
|
|
74
|
+
"@types/jest": "^29.5.14"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"@types/react": "^18.3.27",
|
|
78
|
+
"react": "^18.0.0",
|
|
79
|
+
"react-dom": "^18.0.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"@types/react": {
|
|
83
|
+
"optional": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"publishConfig": {
|
|
87
|
+
"access": "public"
|
|
88
|
+
},
|
|
89
|
+
"gitHead": "0e7112a4f4fde4ea15bd9060489b8f6fe11eb6ca"
|
|
90
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.editActionsEnter,
|
|
2
|
+
.editActionsExit {
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
gap: var(--wp--preset--spacing--20);
|
|
6
|
+
transform-origin: right center;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.editActionsDivider {
|
|
10
|
+
flex-shrink: 0;
|
|
11
|
+
align-self: center;
|
|
12
|
+
width: 1px;
|
|
13
|
+
height: var(--wpds-dimension-size-2xs);
|
|
14
|
+
background-color: var(--wpds-color-stroke-surface-neutral);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@media not ( prefers-reduced-motion ) {
|
|
18
|
+
.editActionsEnter,
|
|
19
|
+
.editActionsExit {
|
|
20
|
+
will-change: opacity, transform;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.editActionsEnter {
|
|
24
|
+
animation: actions-slide-in var(--wpds-motion-duration-md) var(--wpds-motion-easing-expressive) forwards;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.editActionsExit {
|
|
28
|
+
animation: actions-fold-out var(--wpds-motion-duration-sm) var(--wpds-motion-easing-balanced) forwards;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@keyframes actions-slide-in {
|
|
32
|
+
from {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
transform: translateX(12px) scaleX(0.92);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
to {
|
|
38
|
+
opacity: 1;
|
|
39
|
+
transform: translateX(0) scaleX(1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@keyframes actions-fold-out {
|
|
44
|
+
from {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
transform: translateX(0) scaleX(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
to {
|
|
50
|
+
opacity: 0;
|
|
51
|
+
transform: translateX(12px) scaleX(0.92);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { useCallback, useEffect, useState } from '@wordpress/element';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { layout as layoutIcon, plus } from '@wordpress/icons';
|
|
8
|
+
import { store as viewportStore } from '@wordpress/viewport';
|
|
9
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
10
|
+
import { Button, Stack } from '@wordpress/ui';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
16
|
+
import { useDashboardUIContext } from '../../context/ui-context';
|
|
17
|
+
import { ActionsMenu } from '../actions-menu';
|
|
18
|
+
import type { ActionsMenuItem } from '../actions-menu';
|
|
19
|
+
import styles from './actions.module.css';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Edit toolbar for the dashboard. In customize mode it surfaces Add widget,
|
|
23
|
+
* Layout settings (when grid settings are editable), Cancel, and Done;
|
|
24
|
+
* otherwise a single Customize button. Buttons and the overflow menu are
|
|
25
|
+
* triggers that flip the shared UI state the overlays react to.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` when mounted without `onEditChange`, so hosts that don't
|
|
28
|
+
* expose edit mode can keep `Actions` in their tree unconditionally.
|
|
29
|
+
*/
|
|
30
|
+
export function Actions(): React.ReactNode {
|
|
31
|
+
const {
|
|
32
|
+
editMode,
|
|
33
|
+
onEditChange,
|
|
34
|
+
onLayoutReset,
|
|
35
|
+
commit,
|
|
36
|
+
cancel: cancelStaging,
|
|
37
|
+
hasUncommittedChanges,
|
|
38
|
+
canEditGridSettings,
|
|
39
|
+
} = useDashboardInternalContext();
|
|
40
|
+
|
|
41
|
+
const [ isEditActionsMounted, setIsEditActionsMounted ] =
|
|
42
|
+
useState( editMode );
|
|
43
|
+
const [ isExitingEditActions, setIsExitingEditActions ] = useState( false );
|
|
44
|
+
|
|
45
|
+
useEffect( () => {
|
|
46
|
+
if ( editMode ) {
|
|
47
|
+
setIsEditActionsMounted( true );
|
|
48
|
+
setIsExitingEditActions( false );
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if ( ! isEditActionsMounted ) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setIsExitingEditActions( true );
|
|
57
|
+
const exitTimeout = setTimeout( () => {
|
|
58
|
+
setIsEditActionsMounted( false );
|
|
59
|
+
setIsExitingEditActions( false );
|
|
60
|
+
}, 220 );
|
|
61
|
+
|
|
62
|
+
return () => clearTimeout( exitTimeout );
|
|
63
|
+
}, [ editMode, isEditActionsMounted ] );
|
|
64
|
+
|
|
65
|
+
const { setInserterOpen, setLayoutSettingsOpen, setResetDialogOpen } =
|
|
66
|
+
useDashboardUIContext();
|
|
67
|
+
// @TODO: switch to using Admin UI declaratively for mobile viewport support once available.
|
|
68
|
+
// https://github.com/WordPress/gutenberg/issues/77628
|
|
69
|
+
const isMobileViewport = useSelect(
|
|
70
|
+
( select ) => select( viewportStore ).isViewportMatch( '< small' ),
|
|
71
|
+
[]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const handleEditMode = useCallback( () => {
|
|
75
|
+
onEditChange?.( ! editMode );
|
|
76
|
+
}, [ editMode, onEditChange ] );
|
|
77
|
+
|
|
78
|
+
const insert = useCallback( () => {
|
|
79
|
+
setInserterOpen( true );
|
|
80
|
+
}, [ setInserterOpen ] );
|
|
81
|
+
|
|
82
|
+
const cancel = useCallback( () => {
|
|
83
|
+
cancelStaging();
|
|
84
|
+
}, [ cancelStaging ] );
|
|
85
|
+
|
|
86
|
+
const done = useCallback( () => {
|
|
87
|
+
commit();
|
|
88
|
+
}, [ commit ] );
|
|
89
|
+
|
|
90
|
+
const openLayoutSettings = useCallback( () => {
|
|
91
|
+
setLayoutSettingsOpen( true );
|
|
92
|
+
}, [ setLayoutSettingsOpen ] );
|
|
93
|
+
|
|
94
|
+
const menuItems: ActionsMenuItem[] = [
|
|
95
|
+
{
|
|
96
|
+
label: __( 'Reset to default' ),
|
|
97
|
+
onClick: () => setResetDialogOpen( true ),
|
|
98
|
+
disabled: ! onLayoutReset,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
if ( ! onEditChange ) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<Stack direction="row" gap="sm">
|
|
108
|
+
{ isEditActionsMounted ? (
|
|
109
|
+
<Stack
|
|
110
|
+
direction="row"
|
|
111
|
+
gap="sm"
|
|
112
|
+
className={
|
|
113
|
+
isExitingEditActions
|
|
114
|
+
? styles.editActionsExit
|
|
115
|
+
: styles.editActionsEnter
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
<Button
|
|
119
|
+
variant="minimal"
|
|
120
|
+
tone="brand"
|
|
121
|
+
size="compact"
|
|
122
|
+
onClick={ insert }
|
|
123
|
+
>
|
|
124
|
+
{ ! isMobileViewport && <Button.Icon icon={ plus } /> }
|
|
125
|
+
{ __( 'Add widget' ) }
|
|
126
|
+
</Button>
|
|
127
|
+
|
|
128
|
+
{ canEditGridSettings && (
|
|
129
|
+
<Button
|
|
130
|
+
variant="minimal"
|
|
131
|
+
tone="brand"
|
|
132
|
+
size="compact"
|
|
133
|
+
onClick={ openLayoutSettings }
|
|
134
|
+
>
|
|
135
|
+
{ ! isMobileViewport && (
|
|
136
|
+
<Button.Icon icon={ layoutIcon } />
|
|
137
|
+
) }
|
|
138
|
+
{ __( 'Layout settings' ) }
|
|
139
|
+
</Button>
|
|
140
|
+
) }
|
|
141
|
+
|
|
142
|
+
<div
|
|
143
|
+
className={ styles.editActionsDivider }
|
|
144
|
+
aria-hidden="true"
|
|
145
|
+
/>
|
|
146
|
+
|
|
147
|
+
<Button
|
|
148
|
+
variant="minimal"
|
|
149
|
+
tone="brand"
|
|
150
|
+
size="compact"
|
|
151
|
+
onClick={ cancel }
|
|
152
|
+
>
|
|
153
|
+
{ __( 'Cancel' ) }
|
|
154
|
+
</Button>
|
|
155
|
+
|
|
156
|
+
<Button
|
|
157
|
+
variant="solid"
|
|
158
|
+
tone="brand"
|
|
159
|
+
size="compact"
|
|
160
|
+
onClick={ done }
|
|
161
|
+
disabled={ ! hasUncommittedChanges }
|
|
162
|
+
>
|
|
163
|
+
{ __( 'Done' ) }
|
|
164
|
+
</Button>
|
|
165
|
+
</Stack>
|
|
166
|
+
) : (
|
|
167
|
+
<Button
|
|
168
|
+
variant="minimal"
|
|
169
|
+
tone="brand"
|
|
170
|
+
size="compact"
|
|
171
|
+
onClick={ handleEditMode }
|
|
172
|
+
>
|
|
173
|
+
{ __( 'Customize' ) }
|
|
174
|
+
</Button>
|
|
175
|
+
) }
|
|
176
|
+
|
|
177
|
+
<ActionsMenu items={ menuItems } />
|
|
178
|
+
</Stack>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Actions } from './actions';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { moreVertical } from '@wordpress/icons';
|
|
7
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
8
|
+
import { Button, IconButton, Tooltip } from '@wordpress/ui';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { unlock } from '../../lock-unlock';
|
|
14
|
+
|
|
15
|
+
const { Menu } = unlock( componentsPrivateApis );
|
|
16
|
+
|
|
17
|
+
export interface ActionsMenuItem {
|
|
18
|
+
label: string;
|
|
19
|
+
onClick: () => void;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Shown on hover when the item is disabled (for example, to explain
|
|
23
|
+
* why the action is unavailable).
|
|
24
|
+
*/
|
|
25
|
+
disabledTooltip?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ActionsMenuProps {
|
|
29
|
+
items: ActionsMenuItem[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function ActionsMenuEntry( { item }: { item: ActionsMenuItem } ) {
|
|
33
|
+
const showDisabledTooltip = item.disabled && item.disabledTooltip;
|
|
34
|
+
|
|
35
|
+
const menuItem = (
|
|
36
|
+
<Menu.Item
|
|
37
|
+
disabled={ item.disabled }
|
|
38
|
+
onClick={ item.onClick }
|
|
39
|
+
render={ <Button variant="minimal" tone="neutral" /> }
|
|
40
|
+
>
|
|
41
|
+
{ item.label }
|
|
42
|
+
</Menu.Item>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if ( ! showDisabledTooltip ) {
|
|
46
|
+
return menuItem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Tooltip.Root>
|
|
51
|
+
<Tooltip.Trigger
|
|
52
|
+
render={
|
|
53
|
+
<Menu.Item
|
|
54
|
+
disabled={ item.disabled }
|
|
55
|
+
onClick={ item.onClick }
|
|
56
|
+
render={ <Button variant="minimal" tone="neutral" /> }
|
|
57
|
+
/>
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
{ item.label }
|
|
61
|
+
</Tooltip.Trigger>
|
|
62
|
+
<Tooltip.Popup positioner={ <Tooltip.Positioner side="bottom" /> }>
|
|
63
|
+
{ item.disabledTooltip }
|
|
64
|
+
</Tooltip.Popup>
|
|
65
|
+
</Tooltip.Root>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Renders the dashboard's overflow menu: a three-dots trigger surfacing
|
|
71
|
+
* secondary actions. Returns `null` when there are no items.
|
|
72
|
+
*
|
|
73
|
+
* @param {ActionsMenuProps} props Component props.
|
|
74
|
+
*/
|
|
75
|
+
export function ActionsMenu( { items }: ActionsMenuProps ): React.ReactNode {
|
|
76
|
+
if ( items.length === 0 ) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Menu>
|
|
82
|
+
<Menu.TriggerButton
|
|
83
|
+
render={
|
|
84
|
+
<IconButton
|
|
85
|
+
icon={ moreVertical }
|
|
86
|
+
label={ __( 'More options' ) }
|
|
87
|
+
variant="minimal"
|
|
88
|
+
tone="brand"
|
|
89
|
+
size="compact"
|
|
90
|
+
/>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
<Menu.Popover>
|
|
94
|
+
<Tooltip.Provider delay={ 0 }>
|
|
95
|
+
<Menu.Group>
|
|
96
|
+
{ items.map( ( item, index ) => (
|
|
97
|
+
<ActionsMenuEntry key={ index } item={ item } />
|
|
98
|
+
) ) }
|
|
99
|
+
</Menu.Group>
|
|
100
|
+
</Tooltip.Provider>
|
|
101
|
+
</Menu.Popover>
|
|
102
|
+
</Menu>
|
|
103
|
+
);
|
|
104
|
+
}
|