@wordpress/widget-dashboard 0.1.1-next.v.202606191442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE.md +788 -0
- package/README.md +241 -0
- package/build/components/actions/actions.cjs +265 -0
- package/build/components/actions/actions.cjs.map +7 -0
- package/build/components/actions/index.cjs +31 -0
- package/build/components/actions/index.cjs.map +7 -0
- package/build/components/actions-menu/actions-menu.cjs +92 -0
- package/build/components/actions-menu/actions-menu.cjs.map +7 -0
- package/build/components/actions-menu/index.cjs +31 -0
- package/build/components/actions-menu/index.cjs.map +7 -0
- package/build/components/commands/commands.cjs +177 -0
- package/build/components/commands/commands.cjs.map +7 -0
- package/build/components/commands/index.cjs +33 -0
- package/build/components/commands/index.cjs.map +7 -0
- package/build/components/commands/use-pending-when-edit-mode.cjs +57 -0
- package/build/components/commands/use-pending-when-edit-mode.cjs.map +7 -0
- package/build/components/layout-settings/index.cjs +31 -0
- package/build/components/layout-settings/index.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/index.cjs +186 -0
- package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +53 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +7 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +53 -0
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +7 -0
- package/build/components/layout-settings/layout-settings.cjs +207 -0
- package/build/components/layout-settings/layout-settings.cjs.map +7 -0
- package/build/components/no-widgets-state/index.cjs +31 -0
- package/build/components/no-widgets-state/index.cjs.map +7 -0
- package/build/components/no-widgets-state/no-widgets-state.cjs +140 -0
- package/build/components/no-widgets-state/no-widgets-state.cjs.map +7 -0
- package/build/components/reset-confirmation/index.cjs +31 -0
- package/build/components/reset-confirmation/index.cjs.map +7 -0
- package/build/components/reset-confirmation/reset-confirmation.cjs +62 -0
- package/build/components/reset-confirmation/reset-confirmation.cjs.map +7 -0
- package/build/components/widget-chrome/index.cjs +31 -0
- package/build/components/widget-chrome/index.cjs.map +7 -0
- package/build/components/widget-chrome/widget-chrome.cjs +277 -0
- package/build/components/widget-chrome/widget-chrome.cjs.map +7 -0
- package/build/components/widget-inserter/index.cjs +31 -0
- package/build/components/widget-inserter/index.cjs.map +7 -0
- package/build/components/widget-inserter/widget-inserter.cjs +78 -0
- package/build/components/widget-inserter/widget-inserter.cjs.map +7 -0
- package/build/components/widget-picker/index.cjs +31 -0
- package/build/components/widget-picker/index.cjs.map +7 -0
- package/build/components/widget-picker/widget-picker.cjs +209 -0
- package/build/components/widget-picker/widget-picker.cjs.map +7 -0
- package/build/components/widget-render/index.cjs +31 -0
- package/build/components/widget-render/index.cjs.map +7 -0
- package/build/components/widget-render/widget-render.cjs +62 -0
- package/build/components/widget-render/widget-render.cjs.map +7 -0
- package/build/components/widget-settings/index.cjs +37 -0
- package/build/components/widget-settings/index.cjs.map +7 -0
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs +41 -0
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +7 -0
- package/build/components/widget-settings/utils/get-widget-settings.cjs +38 -0
- package/build/components/widget-settings/utils/get-widget-settings.cjs.map +7 -0
- package/build/components/widget-settings/utils/index.cjs +34 -0
- package/build/components/widget-settings/utils/index.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings-toolbar.cjs +138 -0
- package/build/components/widget-settings/widget-settings-toolbar.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings-trigger.cjs +82 -0
- package/build/components/widget-settings/widget-settings-trigger.cjs.map +7 -0
- package/build/components/widget-settings/widget-settings.cjs +269 -0
- package/build/components/widget-settings/widget-settings.cjs.map +7 -0
- package/build/components/widget-toolbar/index.cjs +31 -0
- package/build/components/widget-toolbar/index.cjs.map +7 -0
- package/build/components/widget-toolbar/widget-toolbar.cjs +148 -0
- package/build/components/widget-toolbar/widget-toolbar.cjs.map +7 -0
- package/build/components/widgets/index.cjs +31 -0
- package/build/components/widgets/index.cjs.map +7 -0
- package/build/components/widgets/widget-layout-toolbar.cjs +206 -0
- package/build/components/widgets/widget-layout-toolbar.cjs.map +7 -0
- package/build/components/widgets/widget-resize-handle.cjs +163 -0
- package/build/components/widgets/widget-resize-handle.cjs.map +7 -0
- package/build/components/widgets/widgets.cjs +277 -0
- package/build/components/widgets/widgets.cjs.map +7 -0
- package/build/context/dashboard-context.cjs +234 -0
- package/build/context/dashboard-context.cjs.map +7 -0
- package/build/context/ui-context.cjs +77 -0
- package/build/context/ui-context.cjs.map +7 -0
- package/build/context/widget-context.cjs +44 -0
- package/build/context/widget-context.cjs.map +7 -0
- package/build/hooks/use-dashboard-container-column-count.cjs +61 -0
- package/build/hooks/use-dashboard-container-column-count.cjs.map +7 -0
- package/build/index.cjs +45 -0
- package/build/index.cjs.map +7 -0
- package/build/lock-unlock.cjs +37 -0
- package/build/lock-unlock.cjs.map +7 -0
- package/build/types.cjs +31 -0
- package/build/types.cjs.map +7 -0
- package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs +44 -0
- package/build/utils/create-dashboard-widget/create-dashboard-widget.cjs.map +7 -0
- package/build/utils/create-dashboard-widget/index.cjs +31 -0
- package/build/utils/create-dashboard-widget/index.cjs.map +7 -0
- package/build/utils/default-grid/default-grid.cjs +37 -0
- package/build/utils/default-grid/default-grid.cjs.map +7 -0
- package/build/utils/default-grid/index.cjs +31 -0
- package/build/utils/default-grid/index.cjs.map +7 -0
- package/build/utils/grid-model-change/grid-model-change.cjs +56 -0
- package/build/utils/grid-model-change/grid-model-change.cjs.map +7 -0
- package/build/utils/grid-model-change/index.cjs +33 -0
- package/build/utils/grid-model-change/index.cjs.map +7 -0
- package/build/utils/index.cjs +34 -0
- package/build/utils/index.cjs.map +7 -0
- package/build/utils/migrate-layout/index.cjs +31 -0
- package/build/utils/migrate-layout/index.cjs.map +7 -0
- package/build/utils/migrate-layout/migrate-layout.cjs +94 -0
- package/build/utils/migrate-layout/migrate-layout.cjs.map +7 -0
- package/build/utils/normalize-grid-settings/index.cjs +31 -0
- package/build/utils/normalize-grid-settings/index.cjs.map +7 -0
- package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs +46 -0
- package/build/utils/normalize-grid-settings/normalize-grid-settings.cjs.map +7 -0
- package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs +49 -0
- package/build/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.cjs.map +7 -0
- package/build/utils/row-height-presets/index.cjs +39 -0
- package/build/utils/row-height-presets/index.cjs.map +7 -0
- package/build/utils/row-height-presets/row-height-presets.cjs +63 -0
- package/build/utils/row-height-presets/row-height-presets.cjs.map +7 -0
- package/build/widget-dashboard.cjs +86 -0
- package/build/widget-dashboard.cjs.map +7 -0
- package/build/wordpress-commands.d.cjs +2 -0
- package/build/wordpress-commands.d.cjs.map +7 -0
- package/build-module/components/actions/actions.mjs +240 -0
- package/build-module/components/actions/actions.mjs.map +7 -0
- package/build-module/components/actions/index.mjs +6 -0
- package/build-module/components/actions/index.mjs.map +7 -0
- package/build-module/components/actions-menu/actions-menu.mjs +67 -0
- package/build-module/components/actions-menu/actions-menu.mjs.map +7 -0
- package/build-module/components/actions-menu/index.mjs +6 -0
- package/build-module/components/actions-menu/index.mjs.map +7 -0
- package/build-module/components/commands/commands.mjs +160 -0
- package/build-module/components/commands/commands.mjs.map +7 -0
- package/build-module/components/commands/index.mjs +7 -0
- package/build-module/components/commands/index.mjs.map +7 -0
- package/build-module/components/commands/use-pending-when-edit-mode.mjs +32 -0
- package/build-module/components/commands/use-pending-when-edit-mode.mjs.map +7 -0
- package/build-module/components/layout-settings/index.mjs +6 -0
- package/build-module/components/layout-settings/index.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +151 -0
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +28 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +28 -0
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +7 -0
- package/build-module/components/layout-settings/layout-settings.mjs +187 -0
- package/build-module/components/layout-settings/layout-settings.mjs.map +7 -0
- package/build-module/components/no-widgets-state/index.mjs +6 -0
- package/build-module/components/no-widgets-state/index.mjs.map +7 -0
- package/build-module/components/no-widgets-state/no-widgets-state.mjs +115 -0
- package/build-module/components/no-widgets-state/no-widgets-state.mjs.map +7 -0
- package/build-module/components/reset-confirmation/index.mjs +6 -0
- package/build-module/components/reset-confirmation/index.mjs.map +7 -0
- package/build-module/components/reset-confirmation/reset-confirmation.mjs +37 -0
- package/build-module/components/reset-confirmation/reset-confirmation.mjs.map +7 -0
- package/build-module/components/widget-chrome/index.mjs +6 -0
- package/build-module/components/widget-chrome/index.mjs.map +7 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs +248 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs.map +7 -0
- package/build-module/components/widget-inserter/index.mjs +6 -0
- package/build-module/components/widget-inserter/index.mjs.map +7 -0
- package/build-module/components/widget-inserter/widget-inserter.mjs +53 -0
- package/build-module/components/widget-inserter/widget-inserter.mjs.map +7 -0
- package/build-module/components/widget-picker/index.mjs +6 -0
- package/build-module/components/widget-picker/index.mjs.map +7 -0
- package/build-module/components/widget-picker/widget-picker.mjs +184 -0
- package/build-module/components/widget-picker/widget-picker.mjs.map +7 -0
- package/build-module/components/widget-render/index.mjs +6 -0
- package/build-module/components/widget-render/index.mjs.map +7 -0
- package/build-module/components/widget-render/widget-render.mjs +37 -0
- package/build-module/components/widget-render/widget-render.mjs.map +7 -0
- package/build-module/components/widget-settings/index.mjs +10 -0
- package/build-module/components/widget-settings/index.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +16 -0
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/get-widget-settings.mjs +13 -0
- package/build-module/components/widget-settings/utils/get-widget-settings.mjs.map +7 -0
- package/build-module/components/widget-settings/utils/index.mjs +8 -0
- package/build-module/components/widget-settings/utils/index.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs +113 -0
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings-trigger.mjs +57 -0
- package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +7 -0
- package/build-module/components/widget-settings/widget-settings.mjs +244 -0
- package/build-module/components/widget-settings/widget-settings.mjs.map +7 -0
- package/build-module/components/widget-toolbar/index.mjs +6 -0
- package/build-module/components/widget-toolbar/index.mjs.map +7 -0
- package/build-module/components/widget-toolbar/widget-toolbar.mjs +113 -0
- package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +7 -0
- package/build-module/components/widgets/index.mjs +6 -0
- package/build-module/components/widgets/index.mjs.map +7 -0
- package/build-module/components/widgets/widget-layout-toolbar.mjs +181 -0
- package/build-module/components/widgets/widget-layout-toolbar.mjs.map +7 -0
- package/build-module/components/widgets/widget-resize-handle.mjs +128 -0
- package/build-module/components/widgets/widget-resize-handle.mjs.map +7 -0
- package/build-module/components/widgets/widgets.mjs +242 -0
- package/build-module/components/widgets/widgets.mjs.map +7 -0
- package/build-module/context/dashboard-context.mjs +205 -0
- package/build-module/context/dashboard-context.mjs.map +7 -0
- package/build-module/context/ui-context.mjs +56 -0
- package/build-module/context/ui-context.mjs.map +7 -0
- package/build-module/context/widget-context.mjs +18 -0
- package/build-module/context/widget-context.mjs.map +7 -0
- package/build-module/hooks/use-dashboard-container-column-count.mjs +40 -0
- package/build-module/hooks/use-dashboard-container-column-count.mjs.map +7 -0
- package/build-module/index.mjs +18 -0
- package/build-module/index.mjs.map +7 -0
- package/build-module/lock-unlock.mjs +11 -0
- package/build-module/lock-unlock.mjs.map +7 -0
- package/build-module/types.mjs +6 -0
- package/build-module/types.mjs.map +7 -0
- package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs +19 -0
- package/build-module/utils/create-dashboard-widget/create-dashboard-widget.mjs.map +7 -0
- package/build-module/utils/create-dashboard-widget/index.mjs +6 -0
- package/build-module/utils/create-dashboard-widget/index.mjs.map +7 -0
- package/build-module/utils/default-grid/default-grid.mjs +12 -0
- package/build-module/utils/default-grid/default-grid.mjs.map +7 -0
- package/build-module/utils/default-grid/index.mjs +6 -0
- package/build-module/utils/default-grid/index.mjs.map +7 -0
- package/build-module/utils/grid-model-change/grid-model-change.mjs +30 -0
- package/build-module/utils/grid-model-change/grid-model-change.mjs.map +7 -0
- package/build-module/utils/grid-model-change/index.mjs +7 -0
- package/build-module/utils/grid-model-change/index.mjs.map +7 -0
- package/build-module/utils/index.mjs +8 -0
- package/build-module/utils/index.mjs.map +7 -0
- package/build-module/utils/migrate-layout/index.mjs +6 -0
- package/build-module/utils/migrate-layout/index.mjs.map +7 -0
- package/build-module/utils/migrate-layout/migrate-layout.mjs +69 -0
- package/build-module/utils/migrate-layout/migrate-layout.mjs.map +7 -0
- package/build-module/utils/normalize-grid-settings/index.mjs +6 -0
- package/build-module/utils/normalize-grid-settings/index.mjs.map +7 -0
- package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs +21 -0
- package/build-module/utils/normalize-grid-settings/normalize-grid-settings.mjs.map +7 -0
- package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs +22 -0
- package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs.map +7 -0
- package/build-module/utils/row-height-presets/index.mjs +16 -0
- package/build-module/utils/row-height-presets/index.mjs.map +7 -0
- package/build-module/utils/row-height-presets/row-height-presets.mjs +34 -0
- package/build-module/utils/row-height-presets/row-height-presets.mjs.map +7 -0
- package/build-module/widget-dashboard.mjs +61 -0
- package/build-module/widget-dashboard.mjs.map +7 -0
- package/build-module/wordpress-commands.d.mjs +1 -0
- package/build-module/wordpress-commands.d.mjs.map +7 -0
- package/build-types/components/actions/actions.d.ts +11 -0
- package/build-types/components/actions/actions.d.ts.map +1 -0
- package/build-types/components/actions/index.d.ts +2 -0
- package/build-types/components/actions/index.d.ts.map +1 -0
- package/build-types/components/actions-menu/actions-menu.d.ts +22 -0
- package/build-types/components/actions-menu/actions-menu.d.ts.map +1 -0
- package/build-types/components/actions-menu/index.d.ts +3 -0
- package/build-types/components/actions-menu/index.d.ts.map +1 -0
- package/build-types/components/commands/commands.d.ts +7 -0
- package/build-types/components/commands/commands.d.ts.map +1 -0
- package/build-types/components/commands/index.d.ts +2 -0
- package/build-types/components/commands/index.d.ts.map +1 -0
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts +15 -0
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -0
- package/build-types/components/layout-settings/index.d.ts +2 -0
- package/build-types/components/layout-settings/index.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +17 -0
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +6 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +6 -0
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +1 -0
- package/build-types/components/layout-settings/layout-settings.d.ts +14 -0
- package/build-types/components/layout-settings/layout-settings.d.ts.map +1 -0
- package/build-types/components/no-widgets-state/index.d.ts +2 -0
- package/build-types/components/no-widgets-state/index.d.ts.map +1 -0
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts +17 -0
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -0
- package/build-types/components/reset-confirmation/index.d.ts +2 -0
- package/build-types/components/reset-confirmation/index.d.ts.map +1 -0
- package/build-types/components/reset-confirmation/reset-confirmation.d.ts +8 -0
- package/build-types/components/reset-confirmation/reset-confirmation.d.ts.map +1 -0
- package/build-types/components/widget-chrome/index.d.ts +2 -0
- package/build-types/components/widget-chrome/index.d.ts.map +1 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts +22 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -0
- package/build-types/components/widget-inserter/index.d.ts +2 -0
- package/build-types/components/widget-inserter/index.d.ts.map +1 -0
- package/build-types/components/widget-inserter/widget-inserter.d.ts +7 -0
- package/build-types/components/widget-inserter/widget-inserter.d.ts.map +1 -0
- package/build-types/components/widget-picker/index.d.ts +2 -0
- package/build-types/components/widget-picker/index.d.ts.map +1 -0
- package/build-types/components/widget-picker/widget-picker.d.ts +26 -0
- package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -0
- package/build-types/components/widget-render/index.d.ts +2 -0
- package/build-types/components/widget-render/index.d.ts.map +1 -0
- package/build-types/components/widget-render/widget-render.d.ts +17 -0
- package/build-types/components/widget-render/widget-render.d.ts.map +1 -0
- package/build-types/components/widget-settings/index.d.ts +5 -0
- package/build-types/components/widget-settings/index.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +17 -0
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/get-widget-settings.d.ts +10 -0
- package/build-types/components/widget-settings/utils/get-widget-settings.d.ts.map +1 -0
- package/build-types/components/widget-settings/utils/index.d.ts +3 -0
- package/build-types/components/widget-settings/utils/index.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +20 -0
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts +23 -0
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -0
- package/build-types/components/widget-settings/widget-settings.d.ts +13 -0
- package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -0
- package/build-types/components/widget-toolbar/index.d.ts +3 -0
- package/build-types/components/widget-toolbar/index.d.ts.map +1 -0
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts +16 -0
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -0
- package/build-types/components/widgets/index.d.ts +2 -0
- package/build-types/components/widgets/index.d.ts.map +1 -0
- package/build-types/components/widgets/widget-layout-toolbar.d.ts +14 -0
- package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +1 -0
- package/build-types/components/widgets/widget-resize-handle.d.ts +12 -0
- package/build-types/components/widgets/widget-resize-handle.d.ts.map +1 -0
- package/build-types/components/widgets/widgets.d.ts +10 -0
- package/build-types/components/widgets/widgets.d.ts.map +1 -0
- package/build-types/context/dashboard-context.d.ts +111 -0
- package/build-types/context/dashboard-context.d.ts.map +1 -0
- package/build-types/context/ui-context.d.ts +54 -0
- package/build-types/context/ui-context.d.ts.map +1 -0
- package/build-types/context/widget-context.d.ts +25 -0
- package/build-types/context/widget-context.d.ts.map +1 -0
- package/build-types/hooks/use-dashboard-container-column-count.d.ts +15 -0
- package/build-types/hooks/use-dashboard-container-column-count.d.ts.map +1 -0
- package/build-types/index.d.ts +7 -0
- package/build-types/index.d.ts.map +1 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/build-types/types.d.ts +222 -0
- package/build-types/types.d.ts.map +1 -0
- package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts +20 -0
- package/build-types/utils/create-dashboard-widget/create-dashboard-widget.d.ts.map +1 -0
- package/build-types/utils/create-dashboard-widget/index.d.ts +2 -0
- package/build-types/utils/create-dashboard-widget/index.d.ts.map +1 -0
- package/build-types/utils/default-grid/default-grid.d.ts +11 -0
- package/build-types/utils/default-grid/default-grid.d.ts.map +1 -0
- package/build-types/utils/default-grid/index.d.ts +2 -0
- package/build-types/utils/default-grid/index.d.ts.map +1 -0
- package/build-types/utils/grid-model-change/grid-model-change.d.ts +20 -0
- package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +1 -0
- package/build-types/utils/grid-model-change/index.d.ts +2 -0
- package/build-types/utils/grid-model-change/index.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/migrate-layout/index.d.ts +2 -0
- package/build-types/utils/migrate-layout/index.d.ts.map +1 -0
- package/build-types/utils/migrate-layout/migrate-layout.d.ts +36 -0
- package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +1 -0
- package/build-types/utils/normalize-grid-settings/index.d.ts +2 -0
- package/build-types/utils/normalize-grid-settings/index.d.ts.map +1 -0
- package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts +11 -0
- package/build-types/utils/normalize-grid-settings/normalize-grid-settings.d.ts.map +1 -0
- package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts +21 -0
- package/build-types/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.d.ts.map +1 -0
- package/build-types/utils/row-height-presets/index.d.ts +3 -0
- package/build-types/utils/row-height-presets/index.d.ts.map +1 -0
- package/build-types/utils/row-height-presets/row-height-presets.d.ts +17 -0
- package/build-types/utils/row-height-presets/row-height-presets.d.ts.map +1 -0
- package/build-types/widget-dashboard.d.ts +51 -0
- package/build-types/widget-dashboard.d.ts.map +1 -0
- package/package.json +90 -0
- package/src/components/actions/actions.module.css +54 -0
- package/src/components/actions/actions.tsx +180 -0
- package/src/components/actions/index.ts +1 -0
- package/src/components/actions-menu/actions-menu.tsx +104 -0
- package/src/components/actions-menu/index.ts +2 -0
- package/src/components/commands/commands.tsx +182 -0
- package/src/components/commands/index.ts +1 -0
- package/src/components/commands/use-pending-when-edit-mode.ts +48 -0
- package/src/components/layout-settings/index.ts +1 -0
- package/src/components/layout-settings/layout-model-edit-field/index.tsx +98 -0
- package/src/components/layout-settings/layout-model-edit-field/style.module.css +34 -0
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +28 -0
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +28 -0
- package/src/components/layout-settings/layout-settings.tsx +217 -0
- package/src/components/no-widgets-state/index.ts +1 -0
- package/src/components/no-widgets-state/no-widgets-state.module.css +3 -0
- package/src/components/no-widgets-state/no-widgets-state.tsx +56 -0
- package/src/components/reset-confirmation/index.ts +1 -0
- package/src/components/reset-confirmation/reset-confirmation.tsx +44 -0
- package/src/components/widget-chrome/index.ts +1 -0
- package/src/components/widget-chrome/widget-chrome.module.css +87 -0
- package/src/components/widget-chrome/widget-chrome.tsx +255 -0
- package/src/components/widget-inserter/index.ts +1 -0
- package/src/components/widget-inserter/widget-inserter.tsx +70 -0
- package/src/components/widget-picker/index.ts +1 -0
- package/src/components/widget-picker/widget-picker.module.css +11 -0
- package/src/components/widget-picker/widget-picker.tsx +137 -0
- package/src/components/widget-render/index.ts +1 -0
- package/src/components/widget-render/widget-render.tsx +58 -0
- package/src/components/widget-settings/index.ts +4 -0
- package/src/components/widget-settings/utils/get-admin-menu-inset.ts +30 -0
- package/src/components/widget-settings/utils/get-widget-settings.ts +22 -0
- package/src/components/widget-settings/utils/index.ts +2 -0
- package/src/components/widget-settings/widget-settings-toolbar.module.css +25 -0
- package/src/components/widget-settings/widget-settings-toolbar.tsx +45 -0
- package/src/components/widget-settings/widget-settings-trigger.tsx +96 -0
- package/src/components/widget-settings/widget-settings.module.css +8 -0
- package/src/components/widget-settings/widget-settings.tsx +200 -0
- package/src/components/widget-toolbar/index.ts +2 -0
- package/src/components/widget-toolbar/widget-toolbar.module.css +12 -0
- package/src/components/widget-toolbar/widget-toolbar.tsx +46 -0
- package/src/components/widgets/index.ts +1 -0
- package/src/components/widgets/widget-layout-toolbar.module.css +6 -0
- package/src/components/widgets/widget-layout-toolbar.tsx +118 -0
- package/src/components/widgets/widget-resize-handle.module.css +135 -0
- package/src/components/widgets/widget-resize-handle.tsx +60 -0
- package/src/components/widgets/widgets.module.css +43 -0
- package/src/components/widgets/widgets.tsx +208 -0
- package/src/context/dashboard-context.tsx +386 -0
- package/src/context/ui-context.tsx +118 -0
- package/src/context/widget-context.tsx +45 -0
- package/src/hooks/use-dashboard-container-column-count.ts +63 -0
- package/src/index.ts +9 -0
- package/src/lock-unlock.ts +10 -0
- package/src/test/actions.test.tsx +226 -0
- package/src/test/commands.test.tsx +176 -0
- package/src/test/create-dashboard-widget.test.ts +59 -0
- package/src/test/dashboard-context.test.tsx +26 -0
- package/src/test/staging.test.tsx +476 -0
- package/src/test/widget-dashboard.test.tsx +204 -0
- package/src/test/widget-inserter.test.tsx +210 -0
- package/src/test/widget-settings.test.tsx +199 -0
- package/src/types.ts +260 -0
- package/src/utils/create-dashboard-widget/create-dashboard-widget.ts +43 -0
- package/src/utils/create-dashboard-widget/index.ts +1 -0
- package/src/utils/default-grid/default-grid.ts +17 -0
- package/src/utils/default-grid/index.ts +1 -0
- package/src/utils/grid-model-change/grid-model-change.ts +53 -0
- package/src/utils/grid-model-change/index.ts +1 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/migrate-layout/index.ts +1 -0
- package/src/utils/migrate-layout/migrate-layout.ts +156 -0
- package/src/utils/migrate-layout/test/migrate-layout.test.ts +114 -0
- package/src/utils/normalize-grid-settings/index.ts +1 -0
- package/src/utils/normalize-grid-settings/normalize-grid-settings.ts +38 -0
- package/src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts +41 -0
- package/src/utils/resolve-dashboard-column-count/test/resolve-dashboard-column-count.test.ts +44 -0
- package/src/utils/row-height-presets/index.ts +8 -0
- package/src/utils/row-height-presets/row-height-presets.ts +43 -0
- package/src/widget-dashboard.tsx +102 -0
- package/src/wordpress-commands.d.ts +12 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { WidgetRender as WidgetRenderPrimitive } from '@wordpress/widget-primitives';
|
|
6
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
12
|
+
import type { DashboardWidget } from '../../types';
|
|
13
|
+
|
|
14
|
+
interface WidgetRenderProps {
|
|
15
|
+
widget: DashboardWidget< unknown >;
|
|
16
|
+
widgetType: WidgetType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adapter around the host-agnostic `WidgetRender` primitive. Bridges the
|
|
21
|
+
* dashboard context (`resolveWidgetModule`, layout state) and turns
|
|
22
|
+
* layout-level attribute updates into the per-instance `setAttributes`
|
|
23
|
+
* callback the render contract expects.
|
|
24
|
+
*
|
|
25
|
+
* @param {WidgetRenderProps} props Component props.
|
|
26
|
+
*/
|
|
27
|
+
export function WidgetRender( { widget, widgetType }: WidgetRenderProps ) {
|
|
28
|
+
const { layout, onLayoutChange, resolveWidgetModule } =
|
|
29
|
+
useDashboardInternalContext();
|
|
30
|
+
|
|
31
|
+
const setAttributes = useCallback(
|
|
32
|
+
( next: Partial< unknown > ) => {
|
|
33
|
+
onLayoutChange(
|
|
34
|
+
layout.map( ( w ) =>
|
|
35
|
+
w.uuid === widget.uuid
|
|
36
|
+
? {
|
|
37
|
+
...w,
|
|
38
|
+
attributes: {
|
|
39
|
+
...( w.attributes as object ),
|
|
40
|
+
...( next as object ),
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
: w
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
[ widget.uuid, layout, onLayoutChange ]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<WidgetRenderPrimitive
|
|
52
|
+
widgetType={ widgetType }
|
|
53
|
+
attributes={ widget.attributes }
|
|
54
|
+
setAttributes={ setAttributes }
|
|
55
|
+
resolveWidgetModule={ resolveWidgetModule }
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// cspell:ignore adminmenuback
|
|
2
|
+
const ADMIN_MENU_ID = 'adminmenuback';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Width, in pixels, taken up by the WordPress admin menu
|
|
6
|
+
* (`#adminmenuback`) on the inline-start edge of the viewport.
|
|
7
|
+
*
|
|
8
|
+
* The settings drawer portals to the document body and anchors to a
|
|
9
|
+
* viewport edge, so a left-anchored drawer would slide over the fixed
|
|
10
|
+
* admin menu. Offsetting the drawer by this value keeps the menu
|
|
11
|
+
* uncovered (and reachable) instead of raising the drawer's z-index over
|
|
12
|
+
* it.
|
|
13
|
+
*
|
|
14
|
+
* Defensive: returns `0` when the element is absent (outside wp-admin, or
|
|
15
|
+
* in tests/Storybook), so the drawer just anchors to the viewport edge.
|
|
16
|
+
*
|
|
17
|
+
* @return {number} The admin menu's right edge in px, or `0`.
|
|
18
|
+
*/
|
|
19
|
+
export function getAdminMenuInset(): number {
|
|
20
|
+
if ( typeof document === 'undefined' ) {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const adminMenu = document.getElementById( ADMIN_MENU_ID );
|
|
25
|
+
if ( ! adminMenu ) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return Math.max( 0, adminMenu.getBoundingClientRect().right );
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { sprintf, __ } from '@wordpress/i18n';
|
|
5
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Localized "<Widget> settings" label, falling back to a generic title
|
|
9
|
+
* when the type declares none.
|
|
10
|
+
*
|
|
11
|
+
* @param {WidgetType} widgetType Type backing the open instance.
|
|
12
|
+
* @return {string} The drawer/trigger title.
|
|
13
|
+
*/
|
|
14
|
+
export function getWidgetSettingsTitle( widgetType?: WidgetType ): string {
|
|
15
|
+
return widgetType?.title
|
|
16
|
+
? sprintf(
|
|
17
|
+
/* translators: %s: Widget title. */
|
|
18
|
+
__( '%s settings' ),
|
|
19
|
+
widgetType.title
|
|
20
|
+
)
|
|
21
|
+
: __( 'Widget settings' );
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* Translucent surface so the gear stays legible over any widget background. */
|
|
2
|
+
.widgetSettingsToolbar {
|
|
3
|
+
background: color-mix(in srgb, var(--wpds-color-background-surface-neutral) 40%, transparent);
|
|
4
|
+
opacity: 0;
|
|
5
|
+
pointer-events: none;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
* Revealed on tile hover or focus. Hidden with opacity, not display, so the
|
|
10
|
+
* gear stays in the tab order and `:focus-within` surfaces it for keyboard
|
|
11
|
+
* users. The matched ancestor is the grid item, shared by the slot and card.
|
|
12
|
+
*/
|
|
13
|
+
:global([data-wp-grid-item-key]):hover .widgetSettingsToolbar,
|
|
14
|
+
:global([data-wp-grid-item-key]):focus-within .widgetSettingsToolbar {
|
|
15
|
+
opacity: 1;
|
|
16
|
+
pointer-events: auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media not ( prefers-reduced-motion ) {
|
|
20
|
+
.widgetSettingsToolbar {
|
|
21
|
+
transition:
|
|
22
|
+
opacity var(--wpds-motion-duration-sm)
|
|
23
|
+
var(--wpds-motion-easing-subtle);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { WidgetToolbar } from '../widget-toolbar';
|
|
10
|
+
import { WidgetSettingsTrigger } from './widget-settings-trigger';
|
|
11
|
+
import styles from './widget-settings-toolbar.module.css';
|
|
12
|
+
import type { DashboardWidget } from '../../types';
|
|
13
|
+
|
|
14
|
+
export interface WidgetSettingsToolbarProps {
|
|
15
|
+
/** The instance whose settings this toolbar configures. */
|
|
16
|
+
widget: DashboardWidget< unknown >;
|
|
17
|
+
|
|
18
|
+
/** The instance's widget type, for the trigger label and guard. */
|
|
19
|
+
widgetType: WidgetType;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Normal-mode per-tile toolbar: the gear that opens the settings drawer. Lives
|
|
24
|
+
* in the grid's `actionableArea` slot, so it shows for every `presentation`.
|
|
25
|
+
* Returns `null` when the type has no attributes.
|
|
26
|
+
*
|
|
27
|
+
* @param {WidgetSettingsToolbarProps} props Component props.
|
|
28
|
+
*/
|
|
29
|
+
export function WidgetSettingsToolbar( {
|
|
30
|
+
widget,
|
|
31
|
+
widgetType,
|
|
32
|
+
}: WidgetSettingsToolbarProps ): React.ReactNode {
|
|
33
|
+
if ( ! widgetType.attributes?.length ) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<WidgetToolbar className={ styles.widgetSettingsToolbar }>
|
|
39
|
+
<WidgetSettingsTrigger
|
|
40
|
+
widget={ widget }
|
|
41
|
+
widgetType={ widgetType }
|
|
42
|
+
/>
|
|
43
|
+
</WidgetToolbar>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback } from '@wordpress/element';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { cog } from '@wordpress/icons';
|
|
7
|
+
// Dashboard is still experimental.
|
|
8
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
9
|
+
import { IconButton } from '@wordpress/ui';
|
|
10
|
+
import type { WidgetType } from '@wordpress/widget-primitives';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { useDashboardUIContext } from '../../context/ui-context';
|
|
16
|
+
import { getAdminMenuInset } from './utils';
|
|
17
|
+
import type { DashboardWidget } from '../../types';
|
|
18
|
+
|
|
19
|
+
export interface WidgetSettingsTriggerProps {
|
|
20
|
+
/**
|
|
21
|
+
* The instance whose settings drawer this gear opens.
|
|
22
|
+
*/
|
|
23
|
+
widget: DashboardWidget< unknown >;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The instance's widget type, used for the accessible label and the
|
|
27
|
+
* attributes guard.
|
|
28
|
+
*/
|
|
29
|
+
widgetType: WidgetType;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Per-instance gear that opens the shared settings drawer by writing the
|
|
34
|
+
* instance `uuid` to the UI context; the single `WidgetSettings` at the root
|
|
35
|
+
* reacts to it. Returns `null` when the type declares no attributes, so chrome
|
|
36
|
+
* can mount it unconditionally.
|
|
37
|
+
*
|
|
38
|
+
* @param {WidgetSettingsTriggerProps} props Component props.
|
|
39
|
+
*/
|
|
40
|
+
export function WidgetSettingsTrigger( {
|
|
41
|
+
widget,
|
|
42
|
+
widgetType,
|
|
43
|
+
}: WidgetSettingsTriggerProps ): React.ReactNode {
|
|
44
|
+
const {
|
|
45
|
+
setSettingsWidgetUuid,
|
|
46
|
+
setSettingsDrawerSide,
|
|
47
|
+
setSettingsDrawerInset,
|
|
48
|
+
} = useDashboardUIContext();
|
|
49
|
+
|
|
50
|
+
const open = useCallback(
|
|
51
|
+
( event: React.MouseEvent< HTMLElement > ) => {
|
|
52
|
+
// Open the drawer on the side away from the widget: compare the
|
|
53
|
+
// tile's center against the midpoint of the usable content area
|
|
54
|
+
// (which starts after the admin menu). Past it opens left.
|
|
55
|
+
const adminMenuInset = getAdminMenuInset();
|
|
56
|
+
// The gear sits in the grid slot, outside the card, so reach the
|
|
57
|
+
// tile via the grid item's data hook.
|
|
58
|
+
const tile = event.currentTarget.closest(
|
|
59
|
+
'[data-wp-grid-item-key]'
|
|
60
|
+
);
|
|
61
|
+
const rect = (
|
|
62
|
+
tile ?? event.currentTarget
|
|
63
|
+
).getBoundingClientRect();
|
|
64
|
+
const widgetCenter = rect.left + rect.width / 2;
|
|
65
|
+
const contentCenter = ( adminMenuInset + window.innerWidth ) / 2;
|
|
66
|
+
const side = widgetCenter > contentCenter ? 'left' : 'right';
|
|
67
|
+
|
|
68
|
+
setSettingsDrawerSide( side );
|
|
69
|
+
// A left drawer would otherwise slide over the fixed admin menu;
|
|
70
|
+
// offset it by the menu width so it lands clear of it.
|
|
71
|
+
setSettingsDrawerInset( side === 'left' ? adminMenuInset : 0 );
|
|
72
|
+
setSettingsWidgetUuid( widget.uuid );
|
|
73
|
+
},
|
|
74
|
+
[
|
|
75
|
+
setSettingsDrawerSide,
|
|
76
|
+
setSettingsDrawerInset,
|
|
77
|
+
setSettingsWidgetUuid,
|
|
78
|
+
widget.uuid,
|
|
79
|
+
]
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
if ( ! widgetType.attributes?.length ) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<IconButton
|
|
88
|
+
icon={ cog }
|
|
89
|
+
label={ __( 'Widget settings' ) }
|
|
90
|
+
variant="minimal"
|
|
91
|
+
tone="neutral"
|
|
92
|
+
size="compact"
|
|
93
|
+
onClick={ open }
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { DataForm } from '@wordpress/dataviews';
|
|
5
|
+
import type { Field, Form } from '@wordpress/dataviews';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
// Dashboard is still experimental.
|
|
9
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
10
|
+
import { Button, Drawer } 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 { getWidgetSettingsTitle } from './utils';
|
|
18
|
+
import styles from './widget-settings.module.css';
|
|
19
|
+
|
|
20
|
+
type WidgetAttributes = Record< string, unknown >;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Side drawer that edits one instance's attributes, mounted once at the
|
|
24
|
+
* dashboard root. It resolves the active instance from `settingsWidgetUuid`
|
|
25
|
+
* in the UI context (set by the per-instance gear), renders the type's
|
|
26
|
+
* declarative `attributes` through `DataForm`, and enters from the edge away
|
|
27
|
+
* from the widget.
|
|
28
|
+
*
|
|
29
|
+
* Edits write to the staging layer, so they preview live behind the drawer
|
|
30
|
+
* and are published on Save or reverted on any other exit. Available in
|
|
31
|
+
* normal mode only; the gear is hidden while the layout is being edited.
|
|
32
|
+
*/
|
|
33
|
+
export function WidgetSettings(): React.ReactNode {
|
|
34
|
+
const {
|
|
35
|
+
layout,
|
|
36
|
+
onLayoutChange,
|
|
37
|
+
widgetTypes,
|
|
38
|
+
commit,
|
|
39
|
+
cancel: cancelStaging,
|
|
40
|
+
hasUncommittedChanges,
|
|
41
|
+
} = useDashboardInternalContext();
|
|
42
|
+
const {
|
|
43
|
+
settingsWidgetUuid,
|
|
44
|
+
setSettingsWidgetUuid,
|
|
45
|
+
settingsDrawerSide,
|
|
46
|
+
settingsDrawerInset,
|
|
47
|
+
} = useDashboardUIContext();
|
|
48
|
+
|
|
49
|
+
const open = settingsWidgetUuid !== null;
|
|
50
|
+
|
|
51
|
+
// Keep the last opened instance resolved while the drawer animates
|
|
52
|
+
// closed so its form and title don't blank out mid-transition. While
|
|
53
|
+
// open the live `settingsWidgetUuid` wins, so opening shows no stale
|
|
54
|
+
// frame.
|
|
55
|
+
const [ lastWidgetUuid, setLastWidgetUuid ] = useState< string | null >(
|
|
56
|
+
settingsWidgetUuid
|
|
57
|
+
);
|
|
58
|
+
useEffect( () => {
|
|
59
|
+
if ( settingsWidgetUuid ) {
|
|
60
|
+
setLastWidgetUuid( settingsWidgetUuid );
|
|
61
|
+
}
|
|
62
|
+
}, [ settingsWidgetUuid ] );
|
|
63
|
+
|
|
64
|
+
const activeUuid = settingsWidgetUuid ?? lastWidgetUuid;
|
|
65
|
+
const widget = activeUuid
|
|
66
|
+
? layout.find( ( instance ) => instance.uuid === activeUuid )
|
|
67
|
+
: undefined;
|
|
68
|
+
const widgetType = widget
|
|
69
|
+
? widgetTypes.find( ( type ) => type.name === widget.type )
|
|
70
|
+
: undefined;
|
|
71
|
+
|
|
72
|
+
const fields = useMemo< Field< WidgetAttributes >[] >(
|
|
73
|
+
() => ( widgetType?.attributes ?? [] ) as Field< WidgetAttributes >[],
|
|
74
|
+
[ widgetType?.attributes ]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const form = useMemo< Form >(
|
|
78
|
+
() => ( {
|
|
79
|
+
layout: { type: 'regular', labelPosition: 'top' },
|
|
80
|
+
fields: fields.map( ( field ) => field.id ),
|
|
81
|
+
} ),
|
|
82
|
+
[ fields ]
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
const handleChange = useCallback(
|
|
86
|
+
( edits: Record< string, unknown > ) => {
|
|
87
|
+
if ( ! widget ) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
onLayoutChange(
|
|
91
|
+
layout.map( ( instance ) =>
|
|
92
|
+
instance.uuid === widget.uuid
|
|
93
|
+
? {
|
|
94
|
+
...instance,
|
|
95
|
+
attributes: {
|
|
96
|
+
...( instance.attributes as object ),
|
|
97
|
+
...edits,
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
: instance
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
},
|
|
104
|
+
[ layout, onLayoutChange, widget ]
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const close = useCallback(
|
|
108
|
+
() => setSettingsWidgetUuid( null ),
|
|
109
|
+
[ setSettingsWidgetUuid ]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const handleSave = useCallback( () => {
|
|
113
|
+
commit();
|
|
114
|
+
close();
|
|
115
|
+
}, [ commit, close ] );
|
|
116
|
+
|
|
117
|
+
const handleOpenChange = useCallback(
|
|
118
|
+
( nextOpen: boolean ) => {
|
|
119
|
+
// Any path out of the drawer other than Save discards the
|
|
120
|
+
// staged edits, matching the layout-settings drawer.
|
|
121
|
+
if ( ! nextOpen ) {
|
|
122
|
+
cancelStaging();
|
|
123
|
+
close();
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[ cancelStaging, close ]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// For a left drawer, clear the fixed admin menu on the inline-start
|
|
130
|
+
// edge so the drawer lands beside it. The admin bar at the top is
|
|
131
|
+
// cleared in the CSS module.
|
|
132
|
+
const popupStyle = useMemo< React.CSSProperties >(
|
|
133
|
+
() =>
|
|
134
|
+
settingsDrawerSide === 'left' && settingsDrawerInset > 0
|
|
135
|
+
? { marginLeft: settingsDrawerInset }
|
|
136
|
+
: {},
|
|
137
|
+
[ settingsDrawerSide, settingsDrawerInset ]
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const hasForm = !! widget && !! widgetType && fields.length > 0;
|
|
141
|
+
|
|
142
|
+
if ( ! hasForm ) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const title = getWidgetSettingsTitle( widgetType );
|
|
147
|
+
const data = ( widget?.attributes ??
|
|
148
|
+
widgetType?.example?.attributes ??
|
|
149
|
+
{} ) as WidgetAttributes;
|
|
150
|
+
|
|
151
|
+
return (
|
|
152
|
+
<Drawer.Root
|
|
153
|
+
open={ open }
|
|
154
|
+
onOpenChange={ handleOpenChange }
|
|
155
|
+
swipeDirection={ settingsDrawerSide }
|
|
156
|
+
modal={ false }
|
|
157
|
+
disablePointerDismissal
|
|
158
|
+
>
|
|
159
|
+
<Drawer.Popup
|
|
160
|
+
size="medium"
|
|
161
|
+
className={ styles.popup }
|
|
162
|
+
style={ popupStyle }
|
|
163
|
+
>
|
|
164
|
+
<Drawer.Header>
|
|
165
|
+
<Drawer.Title>{ title }</Drawer.Title>
|
|
166
|
+
<Drawer.CloseIcon />
|
|
167
|
+
</Drawer.Header>
|
|
168
|
+
|
|
169
|
+
<Drawer.Content>
|
|
170
|
+
<DataForm< WidgetAttributes >
|
|
171
|
+
data={ data }
|
|
172
|
+
fields={ fields }
|
|
173
|
+
form={ form }
|
|
174
|
+
onChange={ handleChange }
|
|
175
|
+
/>
|
|
176
|
+
</Drawer.Content>
|
|
177
|
+
|
|
178
|
+
<Drawer.Footer>
|
|
179
|
+
<Button
|
|
180
|
+
variant="minimal"
|
|
181
|
+
tone="brand"
|
|
182
|
+
size="compact"
|
|
183
|
+
onClick={ () => handleOpenChange( false ) }
|
|
184
|
+
>
|
|
185
|
+
{ __( 'Cancel' ) }
|
|
186
|
+
</Button>
|
|
187
|
+
<Button
|
|
188
|
+
variant="solid"
|
|
189
|
+
tone="brand"
|
|
190
|
+
size="compact"
|
|
191
|
+
onClick={ handleSave }
|
|
192
|
+
disabled={ ! hasUncommittedChanges }
|
|
193
|
+
>
|
|
194
|
+
{ __( 'Save' ) }
|
|
195
|
+
</Button>
|
|
196
|
+
</Drawer.Footer>
|
|
197
|
+
</Drawer.Popup>
|
|
198
|
+
</Drawer.Root>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Per-tile toolbar shell: anchored top-right (the grid item is the positioned
|
|
3
|
+
* ancestor) with the shared padding and radius. Variants add the background.
|
|
4
|
+
*/
|
|
5
|
+
.widgetToolbar {
|
|
6
|
+
position: absolute;
|
|
7
|
+
inset-block-start: var(--wpds-dimension-padding-sm);
|
|
8
|
+
inset-inline-end: var(--wpds-dimension-padding-sm);
|
|
9
|
+
z-index: 1;
|
|
10
|
+
padding: var(--wpds-dimension-padding-xs);
|
|
11
|
+
border-radius: var(--wpds-border-radius-md);
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import type { ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { Stack } from '@wordpress/ui';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import styles from './widget-toolbar.module.css';
|
|
16
|
+
|
|
17
|
+
export interface WidgetToolbarProps {
|
|
18
|
+
/** Toolbar controls, laid out in one row. */
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
|
|
21
|
+
/** Variant surface class (background, reveal). */
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shared shell for the per-tile action toolbars. Anchors to the tile's
|
|
27
|
+
* top-right corner and lays controls out in the row the header also uses, so
|
|
28
|
+
* a toolbar lines up with the title when they overlap.
|
|
29
|
+
*
|
|
30
|
+
* @param {WidgetToolbarProps} props Component props.
|
|
31
|
+
*/
|
|
32
|
+
export function WidgetToolbar( {
|
|
33
|
+
children,
|
|
34
|
+
className,
|
|
35
|
+
}: WidgetToolbarProps ): React.ReactNode {
|
|
36
|
+
return (
|
|
37
|
+
<Stack
|
|
38
|
+
direction="row"
|
|
39
|
+
align="center"
|
|
40
|
+
gap="xs"
|
|
41
|
+
className={ clsx( styles.widgetToolbar, className ) }
|
|
42
|
+
>
|
|
43
|
+
{ children }
|
|
44
|
+
</Stack>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Widgets } from './widgets';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* Solid surface: shown for the whole customize session, not on hover. */
|
|
2
|
+
.widgetLayoutToolbar {
|
|
3
|
+
background: var(--wpds-color-background-surface-neutral-strong);
|
|
4
|
+
border: 1px solid var(--wpds-color-stroke-surface-neutral-weak);
|
|
5
|
+
box-shadow: var(--wpds-elevation-xs);
|
|
6
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { moreVertical, trash } from '@wordpress/icons';
|
|
7
|
+
// Dashboard is still experimental.
|
|
8
|
+
// eslint-disable-next-line @wordpress/use-recommended-components
|
|
9
|
+
import { IconButton } from '@wordpress/ui';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { unlock } from '../../lock-unlock';
|
|
15
|
+
import { useDashboardInternalContext } from '../../context/dashboard-context';
|
|
16
|
+
import { WidgetToolbar } from '../widget-toolbar';
|
|
17
|
+
import styles from './widget-layout-toolbar.module.css';
|
|
18
|
+
import type { DashboardWidget, GridTilePlacement } from '../../types';
|
|
19
|
+
|
|
20
|
+
const { Menu } = unlock( componentsPrivateApis );
|
|
21
|
+
|
|
22
|
+
type NamedGridWidth = Exclude<
|
|
23
|
+
NonNullable< GridTilePlacement[ 'width' ] >,
|
|
24
|
+
number
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export interface WidgetLayoutToolbarProps {
|
|
28
|
+
/** The instance this toolbar manages within the layout. */
|
|
29
|
+
widget: DashboardWidget< unknown >;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Customize-mode per-tile toolbar: a width menu and removal, editing the
|
|
34
|
+
* widget's place in the layout. Lives in the grid's `actionableArea` slot, so
|
|
35
|
+
* it stays interactive while the card is `inert`.
|
|
36
|
+
*
|
|
37
|
+
* @param {WidgetLayoutToolbarProps} props Component props.
|
|
38
|
+
*/
|
|
39
|
+
export function WidgetLayoutToolbar( {
|
|
40
|
+
widget,
|
|
41
|
+
}: WidgetLayoutToolbarProps ): React.ReactNode {
|
|
42
|
+
const { layout, onLayoutChange } = useDashboardInternalContext();
|
|
43
|
+
const width = widget.placement?.width;
|
|
44
|
+
|
|
45
|
+
const updateWidth = ( nextWidth: GridTilePlacement[ 'width' ] ) => {
|
|
46
|
+
const nextLayout = layout.map( ( currentWidget ) =>
|
|
47
|
+
currentWidget.uuid === widget.uuid
|
|
48
|
+
? {
|
|
49
|
+
...currentWidget,
|
|
50
|
+
placement: {
|
|
51
|
+
...currentWidget.placement,
|
|
52
|
+
width: nextWidth,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
: currentWidget
|
|
56
|
+
);
|
|
57
|
+
onLayoutChange( nextLayout );
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const onNamedWidthChange = ( nextWidth: NamedGridWidth ) => {
|
|
61
|
+
updateWidth( nextWidth );
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const onRemove = () => {
|
|
65
|
+
onLayoutChange(
|
|
66
|
+
layout.filter(
|
|
67
|
+
( currentWidget ) => currentWidget.uuid !== widget.uuid
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<WidgetToolbar className={ styles.widgetLayoutToolbar }>
|
|
74
|
+
<Menu>
|
|
75
|
+
<Menu.TriggerButton
|
|
76
|
+
render={
|
|
77
|
+
<IconButton
|
|
78
|
+
icon={ moreVertical }
|
|
79
|
+
label={ __( 'Widget options' ) }
|
|
80
|
+
size="compact"
|
|
81
|
+
variant="minimal"
|
|
82
|
+
tone="neutral"
|
|
83
|
+
/>
|
|
84
|
+
}
|
|
85
|
+
/>
|
|
86
|
+
<Menu.Popover>
|
|
87
|
+
<Menu.Group>
|
|
88
|
+
<Menu.GroupLabel>{ __( 'Width' ) }</Menu.GroupLabel>
|
|
89
|
+
<Menu.Item
|
|
90
|
+
disabled={ width === 'fill' }
|
|
91
|
+
onClick={ () => onNamedWidthChange( 'fill' ) }
|
|
92
|
+
>
|
|
93
|
+
<Menu.ItemLabel>
|
|
94
|
+
{ __( 'Use available width' ) }
|
|
95
|
+
</Menu.ItemLabel>
|
|
96
|
+
</Menu.Item>
|
|
97
|
+
<Menu.Item
|
|
98
|
+
disabled={ width === 'full' }
|
|
99
|
+
onClick={ () => onNamedWidthChange( 'full' ) }
|
|
100
|
+
>
|
|
101
|
+
<Menu.ItemLabel>
|
|
102
|
+
{ __( 'Make full width' ) }
|
|
103
|
+
</Menu.ItemLabel>
|
|
104
|
+
</Menu.Item>
|
|
105
|
+
</Menu.Group>
|
|
106
|
+
</Menu.Popover>
|
|
107
|
+
</Menu>
|
|
108
|
+
<IconButton
|
|
109
|
+
icon={ trash }
|
|
110
|
+
label={ __( 'Remove' ) }
|
|
111
|
+
size="compact"
|
|
112
|
+
variant="minimal"
|
|
113
|
+
tone="neutral"
|
|
114
|
+
onClick={ onRemove }
|
|
115
|
+
/>
|
|
116
|
+
</WidgetToolbar>
|
|
117
|
+
);
|
|
118
|
+
}
|