@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,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/use-dashboard-container-column-count.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useResizeObserver, useMergeRefs } from '@wordpress/compose';\nimport {\n\tuseLayoutEffect,\n\tuseMemo,\n\tuseState,\n\ttype Ref,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { resolveDashboardColumnCount } from '../utils/resolve-dashboard-column-count/resolve-dashboard-column-count';\n\ninterface UseDashboardContainerColumnCountResult {\n\tcontainerRef: Ref< HTMLDivElement >;\n\tcolumnCount: number;\n}\n\n/**\n * Tracks the dashboard grid container width and maps it to an opinionated\n * column count (4 → 2 → 1). Measurement is container-based via\n * `ResizeObserver`, not viewport media queries.\n *\n * @param {Ref< HTMLDivElement >} [forwardedRef] Ref forwarded from the grid wrapper.\n */\nexport function useDashboardContainerColumnCount(\n\tforwardedRef?: Ref< HTMLDivElement >\n): UseDashboardContainerColumnCountResult {\n\tconst [ container, setContainer ] = useState< HTMLDivElement | null >(\n\t\tnull\n\t);\n\tconst [ containerWidth, setContainerWidth ] = useState( 0 );\n\n\tconst resizeObserverRef = useResizeObserver( ( [ { contentRect } ] ) => {\n\t\tsetContainerWidth( contentRect.width );\n\t} );\n\n\tconst containerRef = useMergeRefs( [\n\t\tsetContainer,\n\t\tresizeObserverRef,\n\t\tforwardedRef ?? null,\n\t] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! container ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { width } = container.getBoundingClientRect();\n\t\tif ( width > 0 ) {\n\t\t\tsetContainerWidth( width );\n\t\t}\n\t}, [ container ] );\n\n\tconst columnCount = useMemo(\n\t\t() => resolveDashboardColumnCount( containerWidth ),\n\t\t[ containerWidth ]\n\t);\n\n\treturn { containerRef, columnCount };\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB,oBAAoB;AAChD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAKP,SAAS,mCAAmC;AAcrC,SAAS,iCACf,cACyC;AACzC,QAAM,CAAE,WAAW,YAAa,IAAI;AAAA,IACnC;AAAA,EACD;AACA,QAAM,CAAE,gBAAgB,iBAAkB,IAAI,SAAU,CAAE;AAE1D,QAAM,oBAAoB,kBAAmB,CAAE,CAAE,EAAE,YAAY,CAAE,MAAO;AACvE,sBAAmB,YAAY,KAAM;AAAA,EACtC,CAAE;AAEF,QAAM,eAAe,aAAc;AAAA,IAClC;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,EACjB,CAAE;AAEF,kBAAiB,MAAM;AACtB,QAAK,CAAE,WAAY;AAClB;AAAA,IACD;AACA,UAAM,EAAE,MAAM,IAAI,UAAU,sBAAsB;AAClD,QAAK,QAAQ,GAAI;AAChB,wBAAmB,KAAM;AAAA,IAC1B;AAAA,EACD,GAAG,CAAE,SAAU,CAAE;AAEjB,QAAM,cAAc;AAAA,IACnB,MAAM,4BAA6B,cAAe;AAAA,IAClD,CAAE,cAAe;AAAA,EAClB;AAEA,SAAO,EAAE,cAAc,YAAY;AACpC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/index.ts
|
|
2
|
+
import { WidgetDashboard } from "./widget-dashboard.mjs";
|
|
3
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from "./types.mjs";
|
|
4
|
+
import { DEFAULT_GRID } from "./utils/default-grid/index.mjs";
|
|
5
|
+
import { normalizeGridSettings } from "./utils/normalize-grid-settings/index.mjs";
|
|
6
|
+
import {
|
|
7
|
+
ROW_HEIGHT_PRESETS,
|
|
8
|
+
DEFAULT_ROW_HEIGHT
|
|
9
|
+
} from "./utils/row-height-presets/index.mjs";
|
|
10
|
+
export {
|
|
11
|
+
DEFAULT_GRID,
|
|
12
|
+
DEFAULT_ROW_HEIGHT,
|
|
13
|
+
ROW_HEIGHT_PRESETS,
|
|
14
|
+
WIDGET_DASHBOARD_COLUMN_COUNT,
|
|
15
|
+
WidgetDashboard,
|
|
16
|
+
normalizeGridSettings
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { WidgetDashboard } from './widget-dashboard';\nexport type { DashboardWidget, WidgetGridSettings } from './types';\nexport { WIDGET_DASHBOARD_COLUMN_COUNT } from './types';\nexport { DEFAULT_GRID } from './utils/default-grid';\nexport { normalizeGridSettings } from './utils/normalize-grid-settings';\nexport {\n\tROW_HEIGHT_PRESETS,\n\tDEFAULT_ROW_HEIGHT,\n} from './utils/row-height-presets';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB;AAEhC,SAAS,qCAAqC;AAC9C,SAAS,oBAAoB;AAC7B,SAAS,6BAA6B;AACtC;AAAA,EACC;AAAA,EACA;AAAA,OACM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/lock-unlock.ts
|
|
2
|
+
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
3
|
+
var { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules(
|
|
4
|
+
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
|
5
|
+
"@wordpress/widget-dashboard"
|
|
6
|
+
);
|
|
7
|
+
export {
|
|
8
|
+
lock,
|
|
9
|
+
unlock
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=lock-unlock.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/lock-unlock.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/widget-dashboard'\n\t);\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Dashboard-specific types: `DashboardWidget`, grid settings, and the\n * `WidgetDashboard` prop bag.\n *\n * The widget contract types (`WidgetName`, `WidgetType`, `WidgetRenderProps`,\n * `ResolveWidgetModule`) live in `@wordpress/widget-primitives` and are\n * imported from there directly; this module does not re-export them.\n */\n\n/**\n * External dependencies\n */\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport type {\n\tDashboardGridLayoutItem,\n\tDashboardLanesLayoutItem,\n} from '@wordpress/grid';\nimport type {\n\tWidgetName,\n\tWidgetType,\n\tResolveWidgetModule,\n} from '@wordpress/widget-primitives';\n\nexport type GridTilePlacement = Omit< DashboardGridLayoutItem, 'key' >;\nexport type MasonryTilePlacement = Omit< DashboardLanesLayoutItem, 'key' >;\n\n/**\n * Storage shape for a widget's placement.\n *\n * Structurally a union of every supported per-model shape, but the\n * intended invariant is stronger than the type suggests: every\n * placement in a given layout must match the shape of the currently\n * active `gridSettings.model`. `migrateLayout` is the only correct\n * way to transition placements across model changes; the render\n * layer is allowed to trust the active model and treat each\n * placement as the matching shape.\n *\n * The type system cannot enforce that invariant on its own (there is\n * no discriminator on the placement itself), so consider this union a\n * declaration of which shapes are *valid*, not which shape any given\n * placement happens to be at runtime.\n */\nexport type DashboardTilePlacement = GridTilePlacement | MasonryTilePlacement;\n\n/**\n * A widget placed on the dashboard.\n *\n * A `WidgetType` describes the blueprint. A `DashboardWidget` is a\n * concrete placement of that type on a specific dashboard: its unique\n * id, the type it references, user-configured attributes, and its\n * `placement` in the grid.\n */\nexport interface DashboardWidget< Item = unknown > {\n\t/**\n\t * Unique instance identifier.\n\t */\n\tuuid: string;\n\n\t/**\n\t * Widget type name — must match a `WidgetType.name` in `widgetTypes`.\n\t */\n\ttype: WidgetName;\n\n\t/**\n\t * User-configured attributes for this instance.\n\t */\n\tattributes?: Item;\n\n\t/**\n\t * Grid-model-specific placement (column/row spans, ordering,\n\t * etc.). Must match the shape implied by the dashboard's active\n\t * `gridSettings.model`; see `DashboardTilePlacement` for the\n\t * invariant and `migrateLayout` for the transition mechanism.\n\t */\n\tplacement?: DashboardTilePlacement;\n}\n\n/**\n * Identity of a widget within the rendering tree. Returned by\n * `useWidgetContext()`; `null` when called outside a widget render subtree.\n */\nexport interface WidgetContextValue {\n\t/**\n\t * Widget instance id.\n\t */\n\tuuid: string;\n\n\t/**\n\t * Widget type name.\n\t */\n\tname: WidgetName;\n\n\t/**\n\t * Index of the widget in the `layout` array.\n\t */\n\tindex: number;\n}\n\n/**\n * Identifier for the active grid model. Drives which `@wordpress/grid`\n * surface the dashboard mounts and which per-model settings the\n * `WidgetGridSettings` union admits.\n *\n * Model names describe user-facing concepts. The mapping to the\n * underlying `@wordpress/grid` component is an implementation detail\n * resolved in the render layer; `'masonry'` is rendered today through\n * `DashboardLanes` (skyline placement) but could swap to a future\n * native `display: grid-lanes` path without affecting the model name.\n */\nexport type WidgetGridModel = 'grid' | 'masonry';\n\n/**\n * Maximum column count for the widget dashboard on wide containers.\n * Not exposed in layout settings; container width steps the count down\n * to two and one column at fixed breakpoints.\n */\nexport const WIDGET_DASHBOARD_COLUMN_COUNT = 4;\n\n/**\n * Settings common to every grid model. Column count is resolved from\n * the dashboard container width (see\n * `utils/resolve-dashboard-column-count`). `columns` and `minColumnWidth`\n * on this type remain for persisted payloads and `@wordpress/grid`\n * compatibility; the dashboard ignores user-facing values for both.\n *\n * `spacing` is intentionally absent: the gap between tiles is\n * presentational and lives with the design-system theme/density, not\n * with per-dashboard settings. The grid surface keeps the prop for\n * programmatic overrides, but the dashboard does not propagate it.\n */\ninterface BaseWidgetGridSettings {\n\t/**\n\t * Target column count (cap). The dashboard always uses\n\t * {@link WIDGET_DASHBOARD_COLUMN_COUNT}; persisted values are ignored.\n\t */\n\tcolumns?: number;\n\n\t/**\n\t * Per-tile minimum width in pixels. Unused by the dashboard; column\n\t * count is derived from container width instead.\n\t */\n\tminColumnWidth?: number;\n}\n\n/**\n * 2D packed grid settings. Items declare explicit width and height\n * spans; rows use a uniform track height via `rowHeight`.\n */\nexport interface WidgetGridLayoutSettings extends BaseWidgetGridSettings {\n\tmodel?: 'grid';\n\n\t/**\n\t * Row height in pixels (`200` small, `300` medium, `400` large). Every\n\t * tile in a row fills the row vertically.\n\t */\n\trowHeight?: number;\n}\n\n/**\n * Masonry settings. Heights are content-driven; resize is\n * horizontal-only. `flowTolerance` tunes how aggressively the placer\n * preserves source order vs. minimizing empty regions.\n */\nexport interface WidgetMasonryLayoutSettings extends BaseWidgetGridSettings {\n\tmodel: 'masonry';\n\n\t/**\n\t * Pixel tolerance for source-order tiebreaking when two candidate\n\t * columns have similar baselines.\n\t */\n\tflowTolerance?: number;\n}\n\n/**\n * Discriminated union of supported grid-model configurations.\n *\n * When `model` is omitted the dashboard treats the settings as the\n * 2D packed grid (`'grid'`) for backwards compatibility with the\n * pre-union shape.\n */\nexport type WidgetGridSettings =\n\t| WidgetGridLayoutSettings\n\t| WidgetMasonryLayoutSettings;\n\n/**\n * Props for `WidgetDashboard`.\n *\n * The consumer owns the committed layout state; the dashboard maintains\n * a staging copy internally for in-progress edits, and `onLayoutChange`\n * fires only when the user commits via the Done action.\n */\nexport interface WidgetDashboardProps {\n\t/**\n\t * Widget instances to render. Consumer owns this state.\n\t */\n\tlayout: DashboardWidget[];\n\n\t/**\n\t * Called when the user commits in-progress edits via the Done action.\n\t * Receives the full layout array as it should be persisted. In-progress\n\t * mutations (reorder, resize, add, remove, attribute edits) accumulate\n\t * in the dashboard's internal staging layer and do not fire this\n\t * callback until commit.\n\t */\n\tonLayoutChange: ( layout: DashboardWidget[] ) => void;\n\n\t/**\n\t * Called when the layout is reset to the default.\n\t */\n\tonLayoutReset?: () => void;\n\n\t/**\n\t * Widget types available for rendering. The dashboard never queries a\n\t * store directly — consumers scope and filter via this prop.\n\t */\n\twidgetTypes: WidgetType[];\n\n\t/**\n\t * When true, widget types are still loading. Instances whose type is\n\t * not yet in `widgetTypes` show a loading state instead of missing.\n\t */\n\tisResolvingWidgetTypes?: boolean;\n\n\t/**\n\t * Whether the dashboard is in edit mode (enables drag/resize).\n\t */\n\teditMode?: boolean;\n\n\t/**\n\t * Called when edit mode toggles via `WidgetDashboard.Actions`.\n\t */\n\tonEditChange?: ( next: boolean ) => void;\n\n\t/**\n\t * Overrides the default `import()` resolution of\n\t * `WidgetType.renderModule`. Useful for tests, Storybook, or future\n\t * remote-URL loading.\n\t */\n\tresolveWidgetModule?: ResolveWidgetModule;\n\n\t/**\n\t * Grid model configuration. See `WidgetGridSettings` for the shape.\n\t */\n\tgridSettings?: WidgetGridSettings;\n\n\t/**\n\t * Called when the user commits in-progress grid-settings edits via\n\t * the Done action. The dashboard maintains a staging copy of\n\t * settings internally; mutations stay local until commit. When\n\t * omitted, the `Layout settings` button in the customize toolbar is\n\t * hidden, since there is nowhere to persist the change.\n\t */\n\tonGridSettingsChange?: ( gridSettings: WidgetGridSettings ) => void;\n\n\tchildren?: ReactNode;\n}\n"],
|
|
5
|
+
"mappings": ";AAwHO,IAAM,gCAAgC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/create-dashboard-widget/create-dashboard-widget.ts
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
var DEFAULT_PLACEMENT = {
|
|
4
|
+
width: 1,
|
|
5
|
+
height: 2,
|
|
6
|
+
order: 0
|
|
7
|
+
};
|
|
8
|
+
function createDashboardWidget(widgetType, initialAttributes) {
|
|
9
|
+
return {
|
|
10
|
+
uuid: uuid(),
|
|
11
|
+
type: widgetType.name,
|
|
12
|
+
attributes: initialAttributes ?? widgetType.example?.attributes,
|
|
13
|
+
placement: DEFAULT_PLACEMENT
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
createDashboardWidget
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=create-dashboard-widget.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/create-dashboard-widget/create-dashboard-widget.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport { v4 as uuid } from 'uuid';\n\n/**\n * WordPress dependencies\n */\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport type { DashboardWidget, GridTilePlacement } from '../../types';\n\nconst DEFAULT_PLACEMENT: GridTilePlacement = {\n\twidth: 1,\n\theight: 2,\n\torder: 0,\n};\n\n/**\n * Create a new dashboard widget from a widget type.\n *\n * Generates a unique id and applies default placement. If no initial\n * attributes are provided, falls back to the type's `example.attributes`\n * (matching the `widget.json` schema).\n *\n * @param widgetType Source widget type.\n * @param initialAttributes Initial attributes; default to the type's example.\n */\nexport function createDashboardWidget< T >(\n\twidgetType: WidgetType,\n\tinitialAttributes?: T\n): DashboardWidget< T > {\n\treturn {\n\t\tuuid: uuid(),\n\t\ttype: widgetType.name,\n\t\tattributes:\n\t\t\tinitialAttributes ?? ( widgetType.example?.attributes as T ),\n\t\tplacement: DEFAULT_PLACEMENT,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,MAAM,YAAY;AAY3B,IAAM,oBAAuC;AAAA,EAC5C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACR;AAYO,SAAS,sBACf,YACA,mBACuB;AACvB,SAAO;AAAA,IACN,MAAM,KAAK;AAAA,IACX,MAAM,WAAW;AAAA,IACjB,YACC,qBAAuB,WAAW,SAAS;AAAA,IAC5C,WAAW;AAAA,EACZ;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/default-grid/default-grid.ts
|
|
2
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from "../../types.mjs";
|
|
3
|
+
import { DEFAULT_ROW_HEIGHT } from "../row-height-presets/index.mjs";
|
|
4
|
+
var DEFAULT_GRID = {
|
|
5
|
+
model: "grid",
|
|
6
|
+
columns: WIDGET_DASHBOARD_COLUMN_COUNT,
|
|
7
|
+
rowHeight: DEFAULT_ROW_HEIGHT
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
DEFAULT_GRID
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=default-grid.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/default-grid/default-grid.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { WidgetGridSettings } from '../../types';\nimport { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';\nimport { DEFAULT_ROW_HEIGHT } from '../row-height-presets';\n\n/**\n * Canonical default grid settings. Applied by the dashboard when the\n * consumer omits `gridSettings`, and the baseline hosts should treat as\n * the factory default when persisting their own copy.\n */\nexport const DEFAULT_GRID: WidgetGridSettings = {\n\tmodel: 'grid',\n\tcolumns: WIDGET_DASHBOARD_COLUMN_COUNT,\n\trowHeight: DEFAULT_ROW_HEIGHT,\n};\n"],
|
|
5
|
+
"mappings": ";AAIA,SAAS,qCAAqC;AAC9C,SAAS,0BAA0B;AAO5B,IAAM,eAAmC;AAAA,EAC/C,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AACZ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/grid-model-change/grid-model-change.ts
|
|
2
|
+
import { migrateLayout } from "../migrate-layout/index.mjs";
|
|
3
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from "../../types.mjs";
|
|
4
|
+
function getGridModel(settings) {
|
|
5
|
+
return settings.model ?? "grid";
|
|
6
|
+
}
|
|
7
|
+
function computeGridModelChange({
|
|
8
|
+
layout,
|
|
9
|
+
gridSettings,
|
|
10
|
+
targetModel
|
|
11
|
+
}) {
|
|
12
|
+
const currentModel = getGridModel(gridSettings);
|
|
13
|
+
if (currentModel === targetModel) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
layout: migrateLayout(layout, currentModel, targetModel, {
|
|
18
|
+
columns: WIDGET_DASHBOARD_COLUMN_COUNT
|
|
19
|
+
}),
|
|
20
|
+
gridSettings: {
|
|
21
|
+
...gridSettings,
|
|
22
|
+
model: targetModel
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
computeGridModelChange,
|
|
28
|
+
getGridModel
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=grid-model-change.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/grid-model-change/grid-model-change.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { migrateLayout } from '../migrate-layout';\nimport type {\n\tDashboardWidget,\n\tWidgetGridModel,\n\tWidgetGridSettings,\n} from '../../types';\nimport { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';\n\nexport function getGridModel( settings: WidgetGridSettings ): WidgetGridModel {\n\treturn settings.model ?? 'grid';\n}\n\ntype ComputeGridModelChangeProps = {\n\tlayout: DashboardWidget[];\n\tgridSettings: WidgetGridSettings;\n\ttargetModel: WidgetGridModel;\n};\n\ntype ComputeGridModelChangeResult = {\n\tlayout: DashboardWidget[];\n\tgridSettings: WidgetGridSettings;\n} | null;\n\n/**\n * Computes the staged layout and grid settings after a layout-model change.\n *\n * @param {ComputeGridModelChangeProps} params Layout, current settings, and target model.\n * @return {ComputeGridModelChangeResult} Migrated layout and settings, or `null` when the model is unchanged.\n */\nexport function computeGridModelChange( {\n\tlayout,\n\tgridSettings,\n\ttargetModel,\n}: ComputeGridModelChangeProps ): ComputeGridModelChangeResult {\n\tconst currentModel = getGridModel( gridSettings );\n\n\tif ( currentModel === targetModel ) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\tlayout: migrateLayout( layout, currentModel, targetModel, {\n\t\t\tcolumns: WIDGET_DASHBOARD_COLUMN_COUNT,\n\t\t} ),\n\t\tgridSettings: {\n\t\t\t...gridSettings,\n\t\t\tmodel: targetModel,\n\t\t} as WidgetGridSettings,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,qBAAqB;AAM9B,SAAS,qCAAqC;AAEvC,SAAS,aAAc,UAAgD;AAC7E,SAAO,SAAS,SAAS;AAC1B;AAmBO,SAAS,uBAAwB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACD,GAA+D;AAC9D,QAAM,eAAe,aAAc,YAAa;AAEhD,MAAK,iBAAiB,aAAc;AACnC,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,QAAQ,cAAe,QAAQ,cAAc,aAAa;AAAA,MACzD,SAAS;AAAA,IACV,CAAE;AAAA,IACF,cAAc;AAAA,MACb,GAAG;AAAA,MACH,OAAO;AAAA,IACR;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/index.ts
|
|
2
|
+
import { createDashboardWidget } from "./create-dashboard-widget/index.mjs";
|
|
3
|
+
import { migrateLayout } from "./migrate-layout/index.mjs";
|
|
4
|
+
export {
|
|
5
|
+
createDashboardWidget,
|
|
6
|
+
migrateLayout
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { createDashboardWidget } from './create-dashboard-widget';\nexport { migrateLayout } from './migrate-layout';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/migrate-layout/migrate-layout.ts
|
|
2
|
+
var FALLBACK_COLUMNS = 6;
|
|
3
|
+
function gridWidthToMasonryWidth(width, targetColumns) {
|
|
4
|
+
if (width === "full") {
|
|
5
|
+
return targetColumns;
|
|
6
|
+
}
|
|
7
|
+
if (width === "fill" || width === void 0) {
|
|
8
|
+
return 1;
|
|
9
|
+
}
|
|
10
|
+
return width;
|
|
11
|
+
}
|
|
12
|
+
function migratePlacementGridToMasonry(placement, context) {
|
|
13
|
+
if (!placement) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const next = {};
|
|
17
|
+
const width = gridWidthToMasonryWidth(placement.width, context.columns);
|
|
18
|
+
if (width !== 1) {
|
|
19
|
+
next.width = width;
|
|
20
|
+
}
|
|
21
|
+
if (placement.order !== void 0) {
|
|
22
|
+
next.order = placement.order;
|
|
23
|
+
}
|
|
24
|
+
return next;
|
|
25
|
+
}
|
|
26
|
+
function migratePlacementMasonryToGrid(placement) {
|
|
27
|
+
if (!placement) {
|
|
28
|
+
return { height: 1 };
|
|
29
|
+
}
|
|
30
|
+
const next = { height: 1 };
|
|
31
|
+
if (placement.width !== void 0) {
|
|
32
|
+
next.width = placement.width;
|
|
33
|
+
}
|
|
34
|
+
if (placement.order !== void 0) {
|
|
35
|
+
next.order = placement.order;
|
|
36
|
+
}
|
|
37
|
+
return next;
|
|
38
|
+
}
|
|
39
|
+
function migrateLayout(widgets, from, to, context = {}) {
|
|
40
|
+
const resolvedFrom = from ?? "grid";
|
|
41
|
+
if (resolvedFrom === to) {
|
|
42
|
+
return widgets;
|
|
43
|
+
}
|
|
44
|
+
const resolvedContext = {
|
|
45
|
+
columns: context.columns ?? FALLBACK_COLUMNS
|
|
46
|
+
};
|
|
47
|
+
if (resolvedFrom === "grid" && to === "masonry") {
|
|
48
|
+
return widgets.map((widget) => ({
|
|
49
|
+
...widget,
|
|
50
|
+
placement: migratePlacementGridToMasonry(
|
|
51
|
+
widget.placement,
|
|
52
|
+
resolvedContext
|
|
53
|
+
)
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
if (resolvedFrom === "masonry" && to === "grid") {
|
|
57
|
+
return widgets.map((widget) => ({
|
|
58
|
+
...widget,
|
|
59
|
+
placement: migratePlacementMasonryToGrid(
|
|
60
|
+
widget.placement
|
|
61
|
+
)
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
return widgets;
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
migrateLayout
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=migrate-layout.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/migrate-layout/migrate-layout.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tDashboardWidget,\n\tGridTilePlacement,\n\tMasonryTilePlacement,\n\tWidgetGridModel,\n} from '../../types';\n\ninterface MigrationContext {\n\t/**\n\t * Column count of the currently-mounted grid surface. Used to\n\t * resolve `'full'` widths to a concrete numeric span when going\n\t * from the 2D grid model to masonry. When the surface is in\n\t * responsive mode and the runtime column count is unknown,\n\t * callers should pass a sensible fallback (e.g., the default of\n\t * 6 used by `@wordpress/grid`).\n\t */\n\tcolumns: number;\n}\n\nconst FALLBACK_COLUMNS = 6;\n\n/**\n * Coerces a `'fill'`/`'full'`/numeric width into a concrete numeric\n * span when migrating from `'grid'` to `'masonry'`. `'fill'` collapses\n * to a single column; resolving it against per-row remainder would\n * require either DOM measurement or replicating CSS-Grid's auto-flow\n * placement, both of which were judged not worth the complexity for\n * a one-shot migration the user can correct visually in staging.\n *\n * @param width Source width from a grid placement.\n * @param targetColumns Column count to use for `'full'` widths.\n */\nfunction gridWidthToMasonryWidth(\n\twidth: GridTilePlacement[ 'width' ],\n\ttargetColumns: number\n): number {\n\tif ( width === 'full' ) {\n\t\treturn targetColumns;\n\t}\n\tif ( width === 'fill' || width === undefined ) {\n\t\treturn 1;\n\t}\n\treturn width;\n}\n\n/**\n * Transforms a single placement from the 2D grid shape to the masonry\n * shape. Drops `height` (masonry derives heights from content),\n * preserves `order`, leaves `lane` unset so the auto-flow placer\n * arranges items by source order.\n *\n * @param placement Source grid placement.\n * @param context Migration context (column count).\n */\nfunction migratePlacementGridToMasonry(\n\tplacement: GridTilePlacement | undefined,\n\tcontext: MigrationContext\n): MasonryTilePlacement {\n\tif ( ! placement ) {\n\t\treturn {};\n\t}\n\n\tconst next: MasonryTilePlacement = {};\n\tconst width = gridWidthToMasonryWidth( placement.width, context.columns );\n\tif ( width !== 1 ) {\n\t\tnext.width = width;\n\t}\n\tif ( placement.order !== undefined ) {\n\t\tnext.order = placement.order;\n\t}\n\treturn next;\n}\n\n/**\n * Transforms a single placement from the masonry shape to the 2D grid\n * shape. Preserves the numeric width, drops `lane` (the 2D grid\n * auto-packs and has no pin-to-column concept), and seeds `height: 1`\n * since masonry never persisted a height. The user is expected to\n * resize tiles vertically after the migration.\n *\n * @param placement Source masonry placement.\n */\nfunction migratePlacementMasonryToGrid(\n\tplacement: MasonryTilePlacement | undefined\n): GridTilePlacement {\n\tif ( ! placement ) {\n\t\treturn { height: 1 };\n\t}\n\n\tconst next: GridTilePlacement = { height: 1 };\n\tif ( placement.width !== undefined ) {\n\t\tnext.width = placement.width;\n\t}\n\tif ( placement.order !== undefined ) {\n\t\tnext.order = placement.order;\n\t}\n\treturn next;\n}\n\n/**\n * Migrates every widget's `placement` between grid models.\n *\n * The two storage shapes overlap on `width` and `order` but diverge\n * on the rest: 2D grid carries `height` and discriminated string\n * widths (`'fill'`/`'full'`), lanes carries `lane` and only numeric\n * widths. Each conversion loses information that the target model\n * cannot represent. The caller is responsible for surfacing the\n * result to the user in a way that lets them correct visually.\n *\n * When `from === to`, the input is returned unchanged.\n *\n * @param widgets Widgets to migrate.\n * @param from Source model. `undefined` is treated as `'grid'`.\n * @param to Target model.\n * @param context Information that depends on the live render (today\n * only `columns`).\n */\nexport function migrateLayout(\n\twidgets: DashboardWidget[],\n\tfrom: WidgetGridModel | undefined,\n\tto: WidgetGridModel,\n\tcontext: Partial< MigrationContext > = {}\n): DashboardWidget[] {\n\tconst resolvedFrom: WidgetGridModel = from ?? 'grid';\n\tif ( resolvedFrom === to ) {\n\t\treturn widgets;\n\t}\n\n\tconst resolvedContext: MigrationContext = {\n\t\tcolumns: context.columns ?? FALLBACK_COLUMNS,\n\t};\n\n\tif ( resolvedFrom === 'grid' && to === 'masonry' ) {\n\t\treturn widgets.map( ( widget ) => ( {\n\t\t\t...widget,\n\t\t\tplacement: migratePlacementGridToMasonry(\n\t\t\t\twidget.placement as GridTilePlacement | undefined,\n\t\t\t\tresolvedContext\n\t\t\t),\n\t\t} ) );\n\t}\n\n\tif ( resolvedFrom === 'masonry' && to === 'grid' ) {\n\t\treturn widgets.map( ( widget ) => ( {\n\t\t\t...widget,\n\t\t\tplacement: migratePlacementMasonryToGrid(\n\t\t\t\twidget.placement as MasonryTilePlacement | undefined\n\t\t\t),\n\t\t} ) );\n\t}\n\n\treturn widgets;\n}\n"],
|
|
5
|
+
"mappings": ";AAsBA,IAAM,mBAAmB;AAazB,SAAS,wBACR,OACA,eACS;AACT,MAAK,UAAU,QAAS;AACvB,WAAO;AAAA,EACR;AACA,MAAK,UAAU,UAAU,UAAU,QAAY;AAC9C,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAWA,SAAS,8BACR,WACA,SACuB;AACvB,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,OAA6B,CAAC;AACpC,QAAM,QAAQ,wBAAyB,UAAU,OAAO,QAAQ,OAAQ;AACxE,MAAK,UAAU,GAAI;AAClB,SAAK,QAAQ;AAAA,EACd;AACA,MAAK,UAAU,UAAU,QAAY;AACpC,SAAK,QAAQ,UAAU;AAAA,EACxB;AACA,SAAO;AACR;AAWA,SAAS,8BACR,WACoB;AACpB,MAAK,CAAE,WAAY;AAClB,WAAO,EAAE,QAAQ,EAAE;AAAA,EACpB;AAEA,QAAM,OAA0B,EAAE,QAAQ,EAAE;AAC5C,MAAK,UAAU,UAAU,QAAY;AACpC,SAAK,QAAQ,UAAU;AAAA,EACxB;AACA,MAAK,UAAU,UAAU,QAAY;AACpC,SAAK,QAAQ,UAAU;AAAA,EACxB;AACA,SAAO;AACR;AAoBO,SAAS,cACf,SACA,MACA,IACA,UAAuC,CAAC,GACpB;AACpB,QAAM,eAAgC,QAAQ;AAC9C,MAAK,iBAAiB,IAAK;AAC1B,WAAO;AAAA,EACR;AAEA,QAAM,kBAAoC;AAAA,IACzC,SAAS,QAAQ,WAAW;AAAA,EAC7B;AAEA,MAAK,iBAAiB,UAAU,OAAO,WAAY;AAClD,WAAO,QAAQ,IAAK,CAAE,YAAc;AAAA,MACnC,GAAG;AAAA,MACH,WAAW;AAAA,QACV,OAAO;AAAA,QACP;AAAA,MACD;AAAA,IACD,EAAI;AAAA,EACL;AAEA,MAAK,iBAAiB,aAAa,OAAO,QAAS;AAClD,WAAO,QAAQ,IAAK,CAAE,YAAc;AAAA,MACnC,GAAG;AAAA,MACH,WAAW;AAAA,QACV,OAAO;AAAA,MACR;AAAA,IACD,EAAI;AAAA,EACL;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/normalize-grid-settings/normalize-grid-settings.ts
|
|
2
|
+
import { snapRowHeight } from "../row-height-presets/index.mjs";
|
|
3
|
+
function normalizeGridSettings(settings, defaultRowHeight) {
|
|
4
|
+
if ((settings.model ?? "grid") === "masonry") {
|
|
5
|
+
return settings;
|
|
6
|
+
}
|
|
7
|
+
const gridSettings = settings;
|
|
8
|
+
const rowHeight = gridSettings.rowHeight;
|
|
9
|
+
const resolved = typeof rowHeight === "number" ? snapRowHeight(rowHeight) : defaultRowHeight;
|
|
10
|
+
if (rowHeight === resolved) {
|
|
11
|
+
return settings;
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
...gridSettings,
|
|
15
|
+
rowHeight: resolved
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
normalizeGridSettings
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=normalize-grid-settings.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/normalize-grid-settings/normalize-grid-settings.ts"],
|
|
4
|
+
"sourcesContent": ["import type { WidgetGridLayoutSettings, WidgetGridSettings } from '../../types';\nimport { snapRowHeight } from '../row-height-presets';\n\n/**\n * Coerces legacy grid row heights to a dashboard preset. Standard grid\n * rows always use uniform track sizing so tiles align with the masonry\n * model boundary.\n *\n * @param settings Grid settings to normalize.\n * @param defaultRowHeight Fallback row height when none is set.\n */\nexport function normalizeGridSettings(\n\tsettings: WidgetGridSettings,\n\tdefaultRowHeight: number\n): WidgetGridSettings {\n\tif ( ( settings.model ?? 'grid' ) === 'masonry' ) {\n\t\treturn settings;\n\t}\n\n\t// The guard above cannot narrow the union for TypeScript: `model` is\n\t// optional and the check goes through `??`.\n\tconst gridSettings = settings as WidgetGridLayoutSettings;\n\n\tconst rowHeight = gridSettings.rowHeight;\n\tconst resolved =\n\t\ttypeof rowHeight === 'number'\n\t\t\t? snapRowHeight( rowHeight )\n\t\t\t: defaultRowHeight;\n\n\tif ( rowHeight === resolved ) {\n\t\treturn settings;\n\t}\n\n\treturn {\n\t\t...gridSettings,\n\t\trowHeight: resolved,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,qBAAqB;AAUvB,SAAS,sBACf,UACA,kBACqB;AACrB,OAAO,SAAS,SAAS,YAAa,WAAY;AACjD,WAAO;AAAA,EACR;AAIA,QAAM,eAAe;AAErB,QAAM,YAAY,aAAa;AAC/B,QAAM,WACL,OAAO,cAAc,WAClB,cAAe,SAAU,IACzB;AAEJ,MAAK,cAAc,UAAW;AAC7B,WAAO;AAAA,EACR;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH,WAAW;AAAA,EACZ;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts
|
|
2
|
+
import { WIDGET_DASHBOARD_COLUMN_COUNT } from "../../types.mjs";
|
|
3
|
+
var WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN = 600;
|
|
4
|
+
var WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS = 960;
|
|
5
|
+
function resolveDashboardColumnCount(containerWidth) {
|
|
6
|
+
if (containerWidth <= 0) {
|
|
7
|
+
return WIDGET_DASHBOARD_COLUMN_COUNT;
|
|
8
|
+
}
|
|
9
|
+
if (containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN) {
|
|
10
|
+
return 1;
|
|
11
|
+
}
|
|
12
|
+
if (containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS) {
|
|
13
|
+
return 2;
|
|
14
|
+
}
|
|
15
|
+
return WIDGET_DASHBOARD_COLUMN_COUNT;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN,
|
|
19
|
+
WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS,
|
|
20
|
+
resolveDashboardColumnCount
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=resolve-dashboard-column-count.mjs.map
|
package/build-module/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.mjs.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/resolve-dashboard-column-count/resolve-dashboard-column-count.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { WIDGET_DASHBOARD_COLUMN_COUNT } from '../../types';\n\n/**\n * Container width (px) below which the dashboard uses a single column.\n * Matches `@container widget-dashboard (max-width: …)` in widgets CSS.\n */\nexport const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN = 600;\n\n/**\n * Container width (px) below which the dashboard drops from four columns\n * to two. Above this threshold (and below the four-column cap) the\n * grid uses {@link WIDGET_DASHBOARD_COLUMN_COUNT}.\n */\nexport const WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS = 960;\n\n/**\n * Resolves the dashboard grid column count from the widget surface\n * container width. Uses discrete steps (4 → 2 → 1), not viewport\n * media queries.\n *\n * @param containerWidth Measured inline size of the dashboard grid container.\n * @return Column count for {@link @wordpress/grid} surfaces.\n */\nexport function resolveDashboardColumnCount( containerWidth: number ): number {\n\tif ( containerWidth <= 0 ) {\n\t\treturn WIDGET_DASHBOARD_COLUMN_COUNT;\n\t}\n\n\tif ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_ONE_COLUMN ) {\n\t\treturn 1;\n\t}\n\n\tif ( containerWidth < WIDGET_DASHBOARD_CONTAINER_BREAKPOINT_TWO_COLUMNS ) {\n\t\treturn 2;\n\t}\n\n\treturn WIDGET_DASHBOARD_COLUMN_COUNT;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,qCAAqC;AAMvC,IAAM,mDAAmD;AAOzD,IAAM,oDAAoD;AAU1D,SAAS,4BAA6B,gBAAiC;AAC7E,MAAK,kBAAkB,GAAI;AAC1B,WAAO;AAAA,EACR;AAEA,MAAK,iBAAiB,kDAAmD;AACxE,WAAO;AAAA,EACR;AAEA,MAAK,iBAAiB,mDAAoD;AACzE,WAAO;AAAA,EACR;AAEA,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/row-height-presets/index.ts
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_ROW_HEIGHT,
|
|
4
|
+
ROW_HEIGHT_PRESETS,
|
|
5
|
+
presetToRowHeight,
|
|
6
|
+
rowHeightToPreset,
|
|
7
|
+
snapRowHeight
|
|
8
|
+
} from "./row-height-presets.mjs";
|
|
9
|
+
export {
|
|
10
|
+
DEFAULT_ROW_HEIGHT,
|
|
11
|
+
ROW_HEIGHT_PRESETS,
|
|
12
|
+
presetToRowHeight,
|
|
13
|
+
rowHeightToPreset,
|
|
14
|
+
snapRowHeight
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/row-height-presets/index.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n\tDEFAULT_ROW_HEIGHT,\n\tROW_HEIGHT_PRESETS,\n\tpresetToRowHeight,\n\trowHeightToPreset,\n\tsnapRowHeight,\n} from './row-height-presets';\nexport type { RowHeightPreset } from './row-height-presets';\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/utils/row-height-presets/row-height-presets.ts
|
|
2
|
+
var ROW_HEIGHT_PRESETS = {
|
|
3
|
+
small: 200,
|
|
4
|
+
medium: 300,
|
|
5
|
+
large: 400
|
|
6
|
+
};
|
|
7
|
+
var DEFAULT_ROW_HEIGHT = ROW_HEIGHT_PRESETS.medium;
|
|
8
|
+
var PRESET_ENTRIES = Object.entries(ROW_HEIGHT_PRESETS);
|
|
9
|
+
function rowHeightToPreset(rowHeight) {
|
|
10
|
+
let closest = "medium";
|
|
11
|
+
let minDistance = Infinity;
|
|
12
|
+
for (const [preset, value] of PRESET_ENTRIES) {
|
|
13
|
+
const distance = Math.abs(rowHeight - value);
|
|
14
|
+
if (distance < minDistance) {
|
|
15
|
+
minDistance = distance;
|
|
16
|
+
closest = preset;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return closest;
|
|
20
|
+
}
|
|
21
|
+
function presetToRowHeight(preset) {
|
|
22
|
+
return ROW_HEIGHT_PRESETS[preset];
|
|
23
|
+
}
|
|
24
|
+
function snapRowHeight(rowHeight) {
|
|
25
|
+
return presetToRowHeight(rowHeightToPreset(rowHeight));
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
DEFAULT_ROW_HEIGHT,
|
|
29
|
+
ROW_HEIGHT_PRESETS,
|
|
30
|
+
presetToRowHeight,
|
|
31
|
+
rowHeightToPreset,
|
|
32
|
+
snapRowHeight
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=row-height-presets.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/row-height-presets/row-height-presets.ts"],
|
|
4
|
+
"sourcesContent": ["export const ROW_HEIGHT_PRESETS = {\n\tsmall: 200,\n\tmedium: 300,\n\tlarge: 400,\n} as const;\n\nexport type RowHeightPreset = keyof typeof ROW_HEIGHT_PRESETS;\n\nexport const DEFAULT_ROW_HEIGHT = ROW_HEIGHT_PRESETS.medium;\n\nconst PRESET_ENTRIES = Object.entries( ROW_HEIGHT_PRESETS ) as [\n\tRowHeightPreset,\n\tnumber,\n][];\n\n/**\n * Maps a stored pixel height to the nearest preset so legacy freeform\n * values still resolve to a valid toggle option.\n *\n * @param rowHeight Row height in pixels.\n */\nexport function rowHeightToPreset( rowHeight: number ): RowHeightPreset {\n\tlet closest: RowHeightPreset = 'medium';\n\tlet minDistance = Infinity;\n\n\tfor ( const [ preset, value ] of PRESET_ENTRIES ) {\n\t\tconst distance = Math.abs( rowHeight - value );\n\t\tif ( distance < minDistance ) {\n\t\t\tminDistance = distance;\n\t\t\tclosest = preset;\n\t\t}\n\t}\n\n\treturn closest;\n}\n\nexport function presetToRowHeight( preset: RowHeightPreset ): number {\n\treturn ROW_HEIGHT_PRESETS[ preset ];\n}\n\nexport function snapRowHeight( rowHeight: number ): number {\n\treturn presetToRowHeight( rowHeightToPreset( rowHeight ) );\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,qBAAqB;AAAA,EACjC,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AACR;AAIO,IAAM,qBAAqB,mBAAmB;AAErD,IAAM,iBAAiB,OAAO,QAAS,kBAAmB;AAWnD,SAAS,kBAAmB,WAAqC;AACvE,MAAI,UAA2B;AAC/B,MAAI,cAAc;AAElB,aAAY,CAAE,QAAQ,KAAM,KAAK,gBAAiB;AACjD,UAAM,WAAW,KAAK,IAAK,YAAY,KAAM;AAC7C,QAAK,WAAW,aAAc;AAC7B,oBAAc;AACd,gBAAU;AAAA,IACX;AAAA,EACD;AAEA,SAAO;AACR;AAEO,SAAS,kBAAmB,QAAkC;AACpE,SAAO,mBAAoB,MAAO;AACnC;AAEO,SAAS,cAAe,WAA4B;AAC1D,SAAO,kBAAmB,kBAAmB,SAAU,CAAE;AAC1D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/widget-dashboard.tsx
|
|
2
|
+
import { WidgetDashboardProvider } from "./context/dashboard-context.mjs";
|
|
3
|
+
import { WidgetDashboardUIProvider } from "./context/ui-context.mjs";
|
|
4
|
+
import { Actions } from "./components/actions/index.mjs";
|
|
5
|
+
import { Commands } from "./components/commands/index.mjs";
|
|
6
|
+
import { LayoutSettings } from "./components/layout-settings/index.mjs";
|
|
7
|
+
import { NoWidgetsState } from "./components/no-widgets-state/index.mjs";
|
|
8
|
+
import { ResetConfirmation } from "./components/reset-confirmation/index.mjs";
|
|
9
|
+
import { WidgetChrome } from "./components/widget-chrome/index.mjs";
|
|
10
|
+
import { WidgetInserter } from "./components/widget-inserter/index.mjs";
|
|
11
|
+
import { WidgetSettings } from "./components/widget-settings/index.mjs";
|
|
12
|
+
import { Widgets } from "./components/widgets/index.mjs";
|
|
13
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
var WidgetDashboard = Object.assign(
|
|
15
|
+
function WidgetDashboard2({
|
|
16
|
+
layout,
|
|
17
|
+
onLayoutChange,
|
|
18
|
+
onLayoutReset,
|
|
19
|
+
widgetTypes,
|
|
20
|
+
isResolvingWidgetTypes,
|
|
21
|
+
editMode,
|
|
22
|
+
onEditChange,
|
|
23
|
+
resolveWidgetModule,
|
|
24
|
+
gridSettings,
|
|
25
|
+
onGridSettingsChange,
|
|
26
|
+
children
|
|
27
|
+
}) {
|
|
28
|
+
return /* @__PURE__ */ jsx(
|
|
29
|
+
WidgetDashboardProvider,
|
|
30
|
+
{
|
|
31
|
+
layout,
|
|
32
|
+
onLayoutChange,
|
|
33
|
+
onLayoutReset,
|
|
34
|
+
widgetTypes,
|
|
35
|
+
isResolvingWidgetTypes,
|
|
36
|
+
editMode,
|
|
37
|
+
onEditChange,
|
|
38
|
+
resolveWidgetModule,
|
|
39
|
+
gridSettings,
|
|
40
|
+
onGridSettingsChange,
|
|
41
|
+
children: /* @__PURE__ */ jsxs(WidgetDashboardUIProvider, { children: [
|
|
42
|
+
children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
+
/* @__PURE__ */ jsx(NoWidgetsState, {}),
|
|
44
|
+
/* @__PURE__ */ jsx(Actions, {}),
|
|
45
|
+
/* @__PURE__ */ jsx(Widgets, {}),
|
|
46
|
+
/* @__PURE__ */ jsx(Commands, {})
|
|
47
|
+
] }),
|
|
48
|
+
/* @__PURE__ */ jsx(WidgetInserter, {}),
|
|
49
|
+
/* @__PURE__ */ jsx(LayoutSettings, {}),
|
|
50
|
+
/* @__PURE__ */ jsx(WidgetSettings, {}),
|
|
51
|
+
/* @__PURE__ */ jsx(ResetConfirmation, {})
|
|
52
|
+
] })
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
{ Actions, Widgets, WidgetChrome, NoWidgetsState, Commands }
|
|
57
|
+
);
|
|
58
|
+
export {
|
|
59
|
+
WidgetDashboard
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=widget-dashboard.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/widget-dashboard.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport { WidgetDashboardProvider } from './context/dashboard-context';\nimport { WidgetDashboardUIProvider } from './context/ui-context';\nimport { Actions } from './components/actions';\nimport { Commands } from './components/commands';\nimport { LayoutSettings } from './components/layout-settings';\nimport { NoWidgetsState } from './components/no-widgets-state';\nimport { ResetConfirmation } from './components/reset-confirmation';\nimport { WidgetChrome } from './components/widget-chrome';\nimport { WidgetInserter } from './components/widget-inserter';\nimport { WidgetSettings } from './components/widget-settings';\nimport { Widgets } from './components/widgets';\nimport type { WidgetDashboardProps } from './types';\n\n/**\n * Stateless rendering engine for widget dashboards.\n *\n * The consumer owns `layout` and `editMode` state; every mutation fires\n * `onLayoutChange` with the fully updated array. The engine never queries a\n * widget store; types flow in via the `widgetTypes` prop.\n *\n * ```tsx\n * import { WidgetDashboard } from '@wordpress/widget-dashboard';\n *\n * function MyDashboard() {\n * \tconst [ layout, setLayout ] = useState( defaultLayout );\n * \tconst [ editMode, setEditMode ] = useState( false );\n * \treturn (\n * \t\t<WidgetDashboard\n * \t\t\tlayout={ layout }\n * \t\t\tonLayoutChange={ setLayout }\n * \t\t\twidgetTypes={ widgetTypes }\n * \t\t\teditMode={ editMode }\n * \t\t\tonEditChange={ setEditMode }\n * \t\t>\n * \t\t\t<WidgetDashboard.NoWidgetsState>\n * \t\t\t\t<p>No widgets yet.</p>\n * \t\t\t</WidgetDashboard.NoWidgetsState>\n * \t\t\t<WidgetDashboard.Actions />\n * \t\t\t<WidgetDashboard.Widgets />\n * \t\t\t<WidgetDashboard.Commands />\n * \t\t</WidgetDashboard>\n * \t);\n * }\n * ```\n *\n * Children compose the dashboard's triggers and chrome: `Actions`,\n * `Widgets`, `Commands`, `NoWidgetsState`. The targets they open (the\n * widget inserter, the layout and widget settings editors, the reset\n * confirmation) are mounted by the engine and driven by shared UI state, so\n * a trigger works wherever it is composed without a matching target in the\n * tree. Omitting `children` renders the default arrangement.\n */\nexport const WidgetDashboard = Object.assign(\n\tfunction WidgetDashboard( {\n\t\tlayout,\n\t\tonLayoutChange,\n\t\tonLayoutReset,\n\t\twidgetTypes,\n\t\tisResolvingWidgetTypes,\n\t\teditMode,\n\t\tonEditChange,\n\t\tresolveWidgetModule,\n\t\tgridSettings,\n\t\tonGridSettingsChange,\n\t\tchildren,\n\t}: WidgetDashboardProps ) {\n\t\treturn (\n\t\t\t<WidgetDashboardProvider\n\t\t\t\tlayout={ layout }\n\t\t\t\tonLayoutChange={ onLayoutChange }\n\t\t\t\tonLayoutReset={ onLayoutReset }\n\t\t\t\twidgetTypes={ widgetTypes }\n\t\t\t\tisResolvingWidgetTypes={ isResolvingWidgetTypes }\n\t\t\t\teditMode={ editMode }\n\t\t\t\tonEditChange={ onEditChange }\n\t\t\t\tresolveWidgetModule={ resolveWidgetModule }\n\t\t\t\tgridSettings={ gridSettings }\n\t\t\t\tonGridSettingsChange={ onGridSettingsChange }\n\t\t\t>\n\t\t\t\t<WidgetDashboardUIProvider>\n\t\t\t\t\t{ children ?? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<NoWidgetsState />\n\t\t\t\t\t\t\t<Actions />\n\t\t\t\t\t\t\t<Widgets />\n\t\t\t\t\t\t\t<Commands />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<WidgetInserter />\n\t\t\t\t\t<LayoutSettings />\n\t\t\t\t\t<WidgetSettings />\n\t\t\t\t\t<ResetConfirmation />\n\t\t\t\t</WidgetDashboardUIProvider>\n\t\t\t</WidgetDashboardProvider>\n\t\t);\n\t},\n\t{ Actions, Widgets, WidgetChrome, NoWidgetsState, Commands }\n);\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,+BAA+B;AACxC,SAAS,iCAAiC;AAC1C,SAAS,eAAe;AACxB,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,eAAe;AAuElB,mBACC,KADD;AA7BC,IAAM,kBAAkB,OAAO;AAAA,EACrC,SAASA,iBAAiB;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,GAA0B;AACzB,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QAEA,+BAAC,6BACE;AAAA,sBACD,iCACC;AAAA,gCAAC,kBAAe;AAAA,YAChB,oBAAC,WAAQ;AAAA,YACT,oBAAC,WAAQ;AAAA,YACT,oBAAC,YAAS;AAAA,aACX;AAAA,UAGD,oBAAC,kBAAe;AAAA,UAChB,oBAAC,kBAAe;AAAA,UAChB,oBAAC,kBAAe;AAAA,UAChB,oBAAC,qBAAkB;AAAA,WACpB;AAAA;AAAA,IACD;AAAA,EAEF;AAAA,EACA,EAAE,SAAS,SAAS,cAAc,gBAAgB,SAAS;AAC5D;",
|
|
6
|
+
"names": ["WidgetDashboard"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=wordpress-commands.d.mjs.map
|