@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,37 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/reset-confirmation/reset-confirmation.tsx
|
|
2
|
+
import { __ } from "@wordpress/i18n";
|
|
3
|
+
import { AlertDialog } from "@wordpress/ui";
|
|
4
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
5
|
+
import { useDashboardUIContext } from "../../context/ui-context.mjs";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
function ResetConfirmation() {
|
|
8
|
+
const { onLayoutReset, onEditChange } = useDashboardInternalContext();
|
|
9
|
+
const { resetDialogOpen, setResetDialogOpen } = useDashboardUIContext();
|
|
10
|
+
return /* @__PURE__ */ jsx(
|
|
11
|
+
AlertDialog.Root,
|
|
12
|
+
{
|
|
13
|
+
open: resetDialogOpen,
|
|
14
|
+
onOpenChange: setResetDialogOpen,
|
|
15
|
+
onConfirm: async () => {
|
|
16
|
+
await onLayoutReset?.();
|
|
17
|
+
onEditChange?.(false);
|
|
18
|
+
setResetDialogOpen(false);
|
|
19
|
+
},
|
|
20
|
+
children: /* @__PURE__ */ jsx(
|
|
21
|
+
AlertDialog.Popup,
|
|
22
|
+
{
|
|
23
|
+
intent: "irreversible",
|
|
24
|
+
title: __("Reset dashboard to default?"),
|
|
25
|
+
description: __(
|
|
26
|
+
"All customizations will be permanently lost."
|
|
27
|
+
),
|
|
28
|
+
confirmButtonText: __("Reset")
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
ResetConfirmation
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=reset-confirmation.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/reset-confirmation/reset-confirmation.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { AlertDialog } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\n\n/**\n * Confirmation prompt for resetting the dashboard to its default layout,\n * mounted by the engine and shown while `resetDialogOpen` is set in the\n * shared UI context. Confirming runs `onLayoutReset` and leaves customize\n * mode.\n */\nexport function ResetConfirmation(): React.ReactNode {\n\tconst { onLayoutReset, onEditChange } = useDashboardInternalContext();\n\tconst { resetDialogOpen, setResetDialogOpen } = useDashboardUIContext();\n\n\treturn (\n\t\t<AlertDialog.Root\n\t\t\topen={ resetDialogOpen }\n\t\t\tonOpenChange={ setResetDialogOpen }\n\t\t\tonConfirm={ async () => {\n\t\t\t\tawait onLayoutReset?.();\n\t\t\t\tonEditChange?.( false );\n\t\t\t\tsetResetDialogOpen( false );\n\t\t\t} }\n\t\t>\n\t\t\t<AlertDialog.Popup\n\t\t\t\tintent=\"irreversible\"\n\t\t\t\ttitle={ __( 'Reset dashboard to default?' ) }\n\t\t\t\tdescription={ __(\n\t\t\t\t\t'All customizations will be permanently lost.'\n\t\t\t\t) }\n\t\t\t\tconfirmButtonText={ __( 'Reset' ) }\n\t\t\t/>\n\t\t</AlertDialog.Root>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU;AAEnB,SAAS,mBAAmB;AAK5B,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AAsBnC;AAdI,SAAS,oBAAqC;AACpD,QAAM,EAAE,eAAe,aAAa,IAAI,4BAA4B;AACpE,QAAM,EAAE,iBAAiB,mBAAmB,IAAI,sBAAsB;AAEtE,SACC;AAAA,IAAC,YAAY;AAAA,IAAZ;AAAA,MACA,MAAO;AAAA,MACP,cAAe;AAAA,MACf,WAAY,YAAY;AACvB,cAAM,gBAAgB;AACtB,uBAAgB,KAAM;AACtB,2BAAoB,KAAM;AAAA,MAC3B;AAAA,MAEA;AAAA,QAAC,YAAY;AAAA,QAAZ;AAAA,UACA,QAAO;AAAA,UACP,OAAQ,GAAI,6BAA8B;AAAA,UAC1C,aAAc;AAAA,YACb;AAAA,UACD;AAAA,UACA,mBAAoB,GAAI,OAAQ;AAAA;AAAA,MACjC;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.tsx
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { Spinner } from "@wordpress/components";
|
|
4
|
+
import {
|
|
5
|
+
Component,
|
|
6
|
+
Suspense,
|
|
7
|
+
forwardRef,
|
|
8
|
+
useId,
|
|
9
|
+
useMemo
|
|
10
|
+
} from "@wordpress/element";
|
|
11
|
+
import { __ } from "@wordpress/i18n";
|
|
12
|
+
import { plugins } from "@wordpress/icons";
|
|
13
|
+
import { Card, Icon, Stack, Notice, Text, VisuallyHidden } from "@wordpress/ui";
|
|
14
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
15
|
+
import { WidgetContextProvider } from "../../context/widget-context.mjs";
|
|
16
|
+
import { WidgetRender } from "../widget-render/index.mjs";
|
|
17
|
+
|
|
18
|
+
// packages/style-runtime/src/index.ts
|
|
19
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
20
|
+
function getRuntime() {
|
|
21
|
+
const globalScope = globalThis;
|
|
22
|
+
if (globalScope.__wpStyleRuntime) {
|
|
23
|
+
return globalScope.__wpStyleRuntime;
|
|
24
|
+
}
|
|
25
|
+
globalScope.__wpStyleRuntime = {
|
|
26
|
+
documents: /* @__PURE__ */ new Map(),
|
|
27
|
+
styles: /* @__PURE__ */ new Map(),
|
|
28
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
29
|
+
};
|
|
30
|
+
if (typeof document !== "undefined") {
|
|
31
|
+
registerDocument(document);
|
|
32
|
+
}
|
|
33
|
+
return globalScope.__wpStyleRuntime;
|
|
34
|
+
}
|
|
35
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
36
|
+
if (!targetDocument.head) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
40
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
41
|
+
)) {
|
|
42
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
function injectStyle(targetDocument, hash, css) {
|
|
49
|
+
if (!targetDocument.head) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const runtime = getRuntime();
|
|
53
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
54
|
+
if (!injectedStyles) {
|
|
55
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
56
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
57
|
+
}
|
|
58
|
+
if (injectedStyles.has(hash)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
62
|
+
injectedStyles.add(hash);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const style = targetDocument.createElement("style");
|
|
66
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
67
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
68
|
+
targetDocument.head.appendChild(style);
|
|
69
|
+
injectedStyles.add(hash);
|
|
70
|
+
}
|
|
71
|
+
function registerDocument(targetDocument) {
|
|
72
|
+
const runtime = getRuntime();
|
|
73
|
+
runtime.documents.set(
|
|
74
|
+
targetDocument,
|
|
75
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
76
|
+
);
|
|
77
|
+
for (const [hash, css] of runtime.styles) {
|
|
78
|
+
injectStyle(targetDocument, hash, css);
|
|
79
|
+
}
|
|
80
|
+
return () => {
|
|
81
|
+
const count = runtime.documents.get(targetDocument);
|
|
82
|
+
if (count === void 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (count <= 1) {
|
|
86
|
+
runtime.documents.delete(targetDocument);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function registerStyle(hash, css) {
|
|
93
|
+
const runtime = getRuntime();
|
|
94
|
+
runtime.styles.set(hash, css);
|
|
95
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
96
|
+
injectStyle(targetDocument, hash, css);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.module.css
|
|
101
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
102
|
+
registerStyle("345dedc0b8", "._79b45ce7d3422efe__widgetChrome{contain:layout;height:100%}._79b45ce7d3422efe__widgetChrome:has(._9f0be51a1b96c8d7__widgetChromeContent :focus-visible){outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:2px}.d85f7657585b9203__widgetChromeHeaderIcon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}._9f0be51a1b96c8d7__widgetChromeContent{flex:1;height:100%;min-height:0;min-width:0;overflow-y:auto}._21770471c9c2115b__widgetChromeContentBleed{padding-block:0}._229727240ac2aa18__widgetChromeBleedScroll{height:100%;margin-block-end:0;overflow-y:auto}._3c919e86d1bb80ab__loading,._9b694d63bdec1a98__unavailable{height:100%}");
|
|
103
|
+
}
|
|
104
|
+
var widget_chrome_default = { "widgetChrome": "_79b45ce7d3422efe__widgetChrome", "widgetChromeContent": "_9f0be51a1b96c8d7__widgetChromeContent", "widgetChromeHeaderIcon": "d85f7657585b9203__widgetChromeHeaderIcon", "widgetChromeContentBleed": "_21770471c9c2115b__widgetChromeContentBleed", "widgetChromeBleedScroll": "_229727240ac2aa18__widgetChromeBleedScroll", "loading": "_3c919e86d1bb80ab__loading", "unavailable": "_9b694d63bdec1a98__unavailable" };
|
|
105
|
+
|
|
106
|
+
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.tsx
|
|
107
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
108
|
+
var WidgetErrorBoundary = class extends Component {
|
|
109
|
+
state = { hasError: false };
|
|
110
|
+
static getDerivedStateFromError() {
|
|
111
|
+
return { hasError: true };
|
|
112
|
+
}
|
|
113
|
+
render() {
|
|
114
|
+
if (this.state.hasError) {
|
|
115
|
+
return /* @__PURE__ */ jsx(Notice.Root, { intent: "error", children: /* @__PURE__ */ jsx(Notice.Description, { children: __("This widget encountered an error.") }) });
|
|
116
|
+
}
|
|
117
|
+
return this.props.children;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
function LoadingOverlay() {
|
|
121
|
+
return /* @__PURE__ */ jsx(Stack, { justify: "center", align: "center", className: widget_chrome_default.loading, children: /* @__PURE__ */ jsx(Spinner, {}) });
|
|
122
|
+
}
|
|
123
|
+
function UnavailableWidget({ widgetTypeName }) {
|
|
124
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
125
|
+
/* @__PURE__ */ jsx(Card.Header, { children: /* @__PURE__ */ jsx(
|
|
126
|
+
"span",
|
|
127
|
+
{
|
|
128
|
+
className: widget_chrome_default.widgetChromeHeaderIcon,
|
|
129
|
+
"aria-hidden": "true",
|
|
130
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: plugins })
|
|
131
|
+
}
|
|
132
|
+
) }),
|
|
133
|
+
/* @__PURE__ */ jsx(Card.Content, { className: widget_chrome_default.widgetChromeContent, children: /* @__PURE__ */ jsxs(
|
|
134
|
+
Stack,
|
|
135
|
+
{
|
|
136
|
+
direction: "column",
|
|
137
|
+
justify: "center",
|
|
138
|
+
align: "center",
|
|
139
|
+
gap: "md",
|
|
140
|
+
className: widget_chrome_default.unavailable,
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsx(Text, { children: __("Widget is no longer available.") }),
|
|
143
|
+
/* @__PURE__ */ jsx(Text, { render: /* @__PURE__ */ jsx("code", {}), children: widgetTypeName })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
) })
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
function Header({ titleId, widgetType }) {
|
|
150
|
+
if (!widgetType.title) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
return /* @__PURE__ */ jsx(Card.Header, { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", align: "center", gap: "sm", children: [
|
|
154
|
+
widgetType.icon && /* @__PURE__ */ jsx(
|
|
155
|
+
"span",
|
|
156
|
+
{
|
|
157
|
+
className: widget_chrome_default.widgetChromeHeaderIcon,
|
|
158
|
+
"aria-hidden": "true",
|
|
159
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: widgetType.icon })
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsx(Card.Title, { id: titleId, render: /* @__PURE__ */ jsx("h3", {}), children: widgetType.title })
|
|
163
|
+
] }) });
|
|
164
|
+
}
|
|
165
|
+
var WidgetChrome = forwardRef(
|
|
166
|
+
function WidgetChrome2({ widget, index, className }, ref) {
|
|
167
|
+
const { widgetTypes, isResolvingWidgetTypes, editMode } = useDashboardInternalContext();
|
|
168
|
+
const widgetType = widgetTypes.find((t) => t.name === widget.type);
|
|
169
|
+
const titleId = useId();
|
|
170
|
+
const contextValue = useMemo(
|
|
171
|
+
() => ({
|
|
172
|
+
uuid: widget.uuid,
|
|
173
|
+
name: widget.type,
|
|
174
|
+
index
|
|
175
|
+
}),
|
|
176
|
+
[widget.uuid, widget.type, index]
|
|
177
|
+
);
|
|
178
|
+
if (!widgetType) {
|
|
179
|
+
if (isResolvingWidgetTypes) {
|
|
180
|
+
return /* @__PURE__ */ jsx(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
181
|
+
Card.Root,
|
|
182
|
+
{
|
|
183
|
+
render: /* @__PURE__ */ jsx("section", {}),
|
|
184
|
+
ref,
|
|
185
|
+
className: clsx(widget_chrome_default.widgetChrome, className),
|
|
186
|
+
"aria-busy": "true",
|
|
187
|
+
"aria-label": __("Loading"),
|
|
188
|
+
children: /* @__PURE__ */ jsx(
|
|
189
|
+
Card.Content,
|
|
190
|
+
{
|
|
191
|
+
className: widget_chrome_default.widgetChromeContent,
|
|
192
|
+
children: /* @__PURE__ */ jsx(LoadingOverlay, {})
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
) });
|
|
197
|
+
}
|
|
198
|
+
return /* @__PURE__ */ jsx(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
199
|
+
Card.Root,
|
|
200
|
+
{
|
|
201
|
+
render: /* @__PURE__ */ jsx("section", {}),
|
|
202
|
+
ref,
|
|
203
|
+
className: clsx(widget_chrome_default.widgetChrome, className),
|
|
204
|
+
"aria-label": __("Missing widget"),
|
|
205
|
+
children: /* @__PURE__ */ jsx(UnavailableWidget, { widgetTypeName: widget.type })
|
|
206
|
+
}
|
|
207
|
+
) });
|
|
208
|
+
}
|
|
209
|
+
const { presentation } = widgetType;
|
|
210
|
+
const isHeaderHidden = presentation === "full-bleed";
|
|
211
|
+
const isBodyBleeding = presentation === "full-bleed" || presentation === "content-bleed";
|
|
212
|
+
const header = /* @__PURE__ */ jsx(Header, { titleId, widgetType });
|
|
213
|
+
const body = /* @__PURE__ */ jsx(WidgetErrorBoundary, { children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingOverlay, {}), children: /* @__PURE__ */ jsx(WidgetRender, { widget, widgetType }) }) });
|
|
214
|
+
return /* @__PURE__ */ jsx(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ jsxs(
|
|
215
|
+
Card.Root,
|
|
216
|
+
{
|
|
217
|
+
render: /* @__PURE__ */ jsx("section", {}),
|
|
218
|
+
ref,
|
|
219
|
+
className: clsx(widget_chrome_default.widgetChrome, className),
|
|
220
|
+
"aria-labelledby": widgetType.title ? titleId : void 0,
|
|
221
|
+
...editMode ? { inert: "true" } : {},
|
|
222
|
+
children: [
|
|
223
|
+
isHeaderHidden ? /* @__PURE__ */ jsx(VisuallyHidden, { children: header }) : header,
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
Card.Content,
|
|
226
|
+
{
|
|
227
|
+
className: clsx(
|
|
228
|
+
widget_chrome_default.widgetChromeContent,
|
|
229
|
+
isBodyBleeding && widget_chrome_default.widgetChromeContentBleed
|
|
230
|
+
),
|
|
231
|
+
children: isBodyBleeding ? /* @__PURE__ */ jsx(
|
|
232
|
+
Card.FullBleed,
|
|
233
|
+
{
|
|
234
|
+
className: widget_chrome_default.widgetChromeBleedScroll,
|
|
235
|
+
children: body
|
|
236
|
+
}
|
|
237
|
+
) : body
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
) });
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
export {
|
|
246
|
+
WidgetChrome
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=widget-chrome.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-chrome/widget-chrome.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-chrome/widget-chrome.module.css"],
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Spinner } from '@wordpress/components';\nimport {\n\tComponent,\n\tSuspense,\n\tforwardRef,\n\tuseId,\n\tuseMemo,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plugins } from '@wordpress/icons';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Card, Icon, Stack, Notice, Text, VisuallyHidden } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { WidgetContextProvider } from '../../context/widget-context';\nimport { WidgetRender } from '../widget-render';\nimport styles from './widget-chrome.module.css';\nimport type { DashboardWidget } from '../../types';\n\ninterface ErrorBoundaryProps {\n\tchildren: ReactNode;\n}\n\ninterface ErrorBoundaryState {\n\thasError: boolean;\n}\n\nclass WidgetErrorBoundary extends Component<\n\tErrorBoundaryProps,\n\tErrorBoundaryState\n> {\n\tstate: ErrorBoundaryState = { hasError: false };\n\n\tstatic getDerivedStateFromError(): ErrorBoundaryState {\n\t\treturn { hasError: true };\n\t}\n\n\trender() {\n\t\tif ( this.state.hasError ) {\n\t\t\treturn (\n\t\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t\t<Notice.Description>\n\t\t\t\t\t\t{ __( 'This widget encountered an error.' ) }\n\t\t\t\t\t</Notice.Description>\n\t\t\t\t</Notice.Root>\n\t\t\t);\n\t\t}\n\t\treturn this.props.children;\n\t}\n}\n\nfunction LoadingOverlay() {\n\treturn (\n\t\t<Stack justify=\"center\" align=\"center\" className={ styles.loading }>\n\t\t\t<Spinner />\n\t\t</Stack>\n\t);\n}\n\ninterface UnavailableWidgetProps {\n\twidgetTypeName: string;\n}\n\nfunction UnavailableWidget( { widgetTypeName }: UnavailableWidgetProps ) {\n\treturn (\n\t\t<>\n\t\t\t<Card.Header>\n\t\t\t\t<span\n\t\t\t\t\tclassName={ styles.widgetChromeHeaderIcon }\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t>\n\t\t\t\t\t<Icon icon={ plugins } />\n\t\t\t\t</span>\n\t\t\t</Card.Header>\n\t\t\t<Card.Content className={ styles.widgetChromeContent }>\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\talign=\"center\"\n\t\t\t\t\tgap=\"md\"\n\t\t\t\t\tclassName={ styles.unavailable }\n\t\t\t\t>\n\t\t\t\t\t<Text>{ __( 'Widget is no longer available.' ) }</Text>\n\t\t\t\t\t<Text render={ <code /> }>{ widgetTypeName }</Text>\n\t\t\t\t</Stack>\n\t\t\t</Card.Content>\n\t\t</>\n\t);\n}\n\ninterface HeaderProps {\n\ttitleId: string;\n\twidgetType: WidgetType;\n}\n\nfunction Header( { titleId, widgetType }: HeaderProps ) {\n\tif ( ! widgetType.title ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Card.Header>\n\t\t\t<Stack direction=\"row\" align=\"center\" gap=\"sm\">\n\t\t\t\t{ widgetType.icon && (\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ styles.widgetChromeHeaderIcon }\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<Icon icon={ widgetType.icon } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<Card.Title id={ titleId } render={ <h3 /> }>\n\t\t\t\t\t{ widgetType.title }\n\t\t\t\t</Card.Title>\n\t\t\t</Stack>\n\t\t</Card.Header>\n\t);\n}\n\nexport interface WidgetChromeProps {\n\twidget: DashboardWidget< unknown >;\n\tindex: number;\n\t/**\n\t * Lifted by the surrounding `@wordpress/grid` surface into a sibling\n\t * slot of the grid item; not rendered by `WidgetChrome` itself.\n\t * Living outside `Card.Root` is what keeps these controls interactive\n\t * while edit mode applies `inert` to the chrome.\n\t */\n\tactionableArea?: ReactNode;\n\tclassName?: string;\n}\n\n/**\n * Per-instance wrapper. Owns the chrome around a widget instance: identity\n * context, header (title + icon), edit-mode `inert` attribute, and the\n * error/loading boundaries that keep neighbours mounted when one widget fails\n * or is still resolving.\n */\nexport const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(\n\tfunction WidgetChrome( { widget, index, className }, ref ) {\n\t\tconst { widgetTypes, isResolvingWidgetTypes, editMode } =\n\t\t\tuseDashboardInternalContext();\n\t\tconst widgetType = widgetTypes.find( ( t ) => t.name === widget.type );\n\t\tconst titleId = useId();\n\n\t\tconst contextValue = useMemo(\n\t\t\t() => ( {\n\t\t\t\tuuid: widget.uuid,\n\t\t\t\tname: widget.type,\n\t\t\t\tindex,\n\t\t\t} ),\n\t\t\t[ widget.uuid, widget.type, index ]\n\t\t);\n\n\t\tif ( ! widgetType ) {\n\t\t\tif ( isResolvingWidgetTypes ) {\n\t\t\t\treturn (\n\t\t\t\t\t<WidgetContextProvider value={ contextValue }>\n\t\t\t\t\t\t<Card.Root\n\t\t\t\t\t\t\trender={ <section /> }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tclassName={ clsx( styles.widgetChrome, className ) }\n\t\t\t\t\t\t\taria-busy=\"true\"\n\t\t\t\t\t\t\taria-label={ __( 'Loading' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Card.Content\n\t\t\t\t\t\t\t\tclassName={ styles.widgetChromeContent }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<LoadingOverlay />\n\t\t\t\t\t\t\t</Card.Content>\n\t\t\t\t\t\t</Card.Root>\n\t\t\t\t\t</WidgetContextProvider>\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<WidgetContextProvider value={ contextValue }>\n\t\t\t\t\t<Card.Root\n\t\t\t\t\t\trender={ <section /> }\n\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\tclassName={ clsx( styles.widgetChrome, className ) }\n\t\t\t\t\t\taria-label={ __( 'Missing widget' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<UnavailableWidget widgetTypeName={ widget.type } />\n\t\t\t\t\t</Card.Root>\n\t\t\t\t</WidgetContextProvider>\n\t\t\t);\n\t\t}\n\n\t\t// `presentation` encodes two independent axes. `full-bleed` hides\n\t\t// the header; both `full-bleed` and `content-bleed` let the body\n\t\t// break out of the content padding.\n\t\tconst { presentation } = widgetType;\n\t\tconst isHeaderHidden = presentation === 'full-bleed';\n\t\tconst isBodyBleeding =\n\t\t\tpresentation === 'full-bleed' || presentation === 'content-bleed';\n\t\tconst header = <Header titleId={ titleId } widgetType={ widgetType } />;\n\n\t\tconst body = (\n\t\t\t<WidgetErrorBoundary>\n\t\t\t\t<Suspense fallback={ <LoadingOverlay /> }>\n\t\t\t\t\t<WidgetRender widget={ widget } widgetType={ widgetType } />\n\t\t\t\t</Suspense>\n\t\t\t</WidgetErrorBoundary>\n\t\t);\n\n\t\treturn (\n\t\t\t<WidgetContextProvider value={ contextValue }>\n\t\t\t\t<Card.Root\n\t\t\t\t\trender={ <section /> }\n\t\t\t\t\tref={ ref }\n\t\t\t\t\tclassName={ clsx( styles.widgetChrome, className ) }\n\t\t\t\t\taria-labelledby={ widgetType.title ? titleId : undefined }\n\t\t\t\t\t{ ...( editMode ? { inert: 'true' } : {} ) }\n\t\t\t\t>\n\t\t\t\t\t{ isHeaderHidden ? (\n\t\t\t\t\t\t<VisuallyHidden>{ header }</VisuallyHidden>\n\t\t\t\t\t) : (\n\t\t\t\t\t\theader\n\t\t\t\t\t) }\n\n\t\t\t\t\t<Card.Content\n\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\tstyles.widgetChromeContent,\n\t\t\t\t\t\t\tisBodyBleeding && styles.widgetChromeContentBleed\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ isBodyBleeding ? (\n\t\t\t\t\t\t\t<Card.FullBleed\n\t\t\t\t\t\t\t\tclassName={ styles.widgetChromeBleedScroll }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ body }\n\t\t\t\t\t\t\t</Card.FullBleed>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\tbody\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Card.Content>\n\t\t\t\t</Card.Root>\n\t\t\t</WidgetContextProvider>\n\t\t);\n\t}\n);\n", "type GlobalScopeWithStyleRuntime = typeof globalThis & {\n\t// This global is shared by separately bundled copies of this package.\n\t// Keep its shape backward compatible after release.\n\t__wpStyleRuntime?: {\n\t\tdocuments: Map< Document, number >;\n\t\tstyles: Map< string, string >;\n\t\tinjectedStyles: WeakMap< Document, Set< string > >;\n\t};\n};\n\nconst STYLE_HASH_ATTRIBUTE = 'data-wp-hash';\n\n/**\n * Returns the shared style runtime registry.\n *\n * The registry is stored on `globalThis` so separately bundled copies of this\n * package can coordinate through the same document and style maps.\n *\n * @return The shared runtime registry.\n */\nfunction getRuntime() {\n\tconst globalScope = globalThis as GlobalScopeWithStyleRuntime;\n\n\tif ( globalScope.__wpStyleRuntime ) {\n\t\treturn globalScope.__wpStyleRuntime;\n\t}\n\n\tglobalScope.__wpStyleRuntime = {\n\t\tdocuments: new Map(),\n\t\tstyles: new Map(),\n\t\tinjectedStyles: new WeakMap(),\n\t};\n\n\tif ( typeof document !== 'undefined' ) {\n\t\tregisterDocument( document );\n\t}\n\n\treturn globalScope.__wpStyleRuntime;\n}\n\n/**\n * Checks whether a document already contains a style tag for a hash.\n *\n * @param targetDocument Document to inspect.\n * @param hash Stable hash for the transformed CSS.\n *\n * @return Whether the style hash already exists in the document.\n */\nfunction documentContainsStyleHash(\n\ttargetDocument: Document,\n\thash: string\n): boolean {\n\tif ( ! targetDocument.head ) {\n\t\treturn false;\n\t}\n\n\tfor ( const style of targetDocument.head.querySelectorAll(\n\t\t`style[${ STYLE_HASH_ATTRIBUTE }]`\n\t) ) {\n\t\tif ( style.getAttribute( STYLE_HASH_ATTRIBUTE ) === hash ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\n/**\n * Injects a registered style into a document, unless that document already\n * contains a style tag for the same hash.\n *\n * @param targetDocument Document to inject the style into.\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nfunction injectStyle( targetDocument: Document, hash: string, css: string ) {\n\tif ( ! targetDocument.head ) {\n\t\treturn;\n\t}\n\n\tconst runtime = getRuntime();\n\tlet injectedStyles = runtime.injectedStyles.get( targetDocument );\n\n\tif ( ! injectedStyles ) {\n\t\tinjectedStyles = new Set();\n\t\truntime.injectedStyles.set( targetDocument, injectedStyles );\n\t}\n\n\tif ( injectedStyles.has( hash ) ) {\n\t\treturn;\n\t}\n\n\t// Older generated CSS module output can still inject matching style tags\n\t// after this document's cache is created, so keep the DOM as the fallback\n\t// source of truth on cache misses.\n\tif ( documentContainsStyleHash( targetDocument, hash ) ) {\n\t\tinjectedStyles.add( hash );\n\t\treturn;\n\t}\n\n\tconst style = targetDocument.createElement( 'style' );\n\tstyle.setAttribute( STYLE_HASH_ATTRIBUTE, hash );\n\tstyle.appendChild( targetDocument.createTextNode( css ) );\n\ttargetDocument.head.appendChild( style );\n\tinjectedStyles.add( hash );\n}\n\n/**\n * Registers a document as a style injection target.\n *\n * Existing registered styles are replayed into the document immediately.\n * Documents are reference-counted so multiple providers can safely register the\n * same document without one cleanup removing it while another registration is\n * still active.\n *\n * @param targetDocument Document to receive registered styles.\n * @return Cleanup function that unregisters this document registration.\n */\nexport function registerDocument( targetDocument: Document ) {\n\tconst runtime = getRuntime();\n\n\truntime.documents.set(\n\t\ttargetDocument,\n\t\t( runtime.documents.get( targetDocument ) ?? 0 ) + 1\n\t);\n\n\tfor ( const [ hash, css ] of runtime.styles ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n\n\treturn () => {\n\t\tconst count = runtime.documents.get( targetDocument );\n\n\t\tif ( count === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( count <= 1 ) {\n\t\t\truntime.documents.delete( targetDocument );\n\t\t\treturn;\n\t\t}\n\n\t\truntime.documents.set( targetDocument, count - 1 );\n\t};\n}\n\n/**\n * Registers a style and injects it into all registered documents.\n *\n * The hash is used as the deduplication key, so calling this repeatedly with\n * the same hash will not add duplicate style tags to a document.\n * Registered styles are retained for the lifetime of the page so they can be\n * replayed into documents that are registered later.\n *\n * @param hash Stable hash for the transformed CSS.\n * @param css CSS text to inject.\n */\nexport function registerStyle( hash: string, css: string ) {\n\tconst runtime = getRuntime();\n\n\truntime.styles.set( hash, css );\n\n\tfor ( const targetDocument of runtime.documents.keys() ) {\n\t\tinjectStyle( targetDocument, hash, css );\n\t}\n}\n", "import { registerStyle } from '@wordpress/style-runtime';\nif (typeof process === 'undefined' || process.env.NODE_ENV !== 'test') {\n\tregisterStyle(\"345dedc0b8\", \"._79b45ce7d3422efe__widgetChrome{contain:layout;height:100%}._79b45ce7d3422efe__widgetChrome:has(._9f0be51a1b96c8d7__widgetChromeContent :focus-visible){outline:var(--wpds-border-width-focus,var(--wp-admin-border-width-focus,2px)) solid var(--wpds-color-stroke-focus,var(--wp-admin-theme-color,#3858e9));outline-offset:2px}.d85f7657585b9203__widgetChromeHeaderIcon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}._9f0be51a1b96c8d7__widgetChromeContent{flex:1;height:100%;min-height:0;min-width:0;overflow-y:auto}._21770471c9c2115b__widgetChromeContentBleed{padding-block:0}._229727240ac2aa18__widgetChromeBleedScroll{height:100%;margin-block-end:0;overflow-y:auto}._3c919e86d1bb80ab__loading,._9b694d63bdec1a98__unavailable{height:100%}\");\n}\nexport default {\"widgetChrome\":\"_79b45ce7d3422efe__widgetChrome\",\"widgetChromeContent\":\"_9f0be51a1b96c8d7__widgetChromeContent\",\"widgetChromeHeaderIcon\":\"d85f7657585b9203__widgetChromeHeaderIcon\",\"widgetChromeContentBleed\":\"_21770471c9c2115b__widgetChromeContentBleed\",\"widgetChromeBleedScroll\":\"_229727240ac2aa18__widgetChromeBleedScroll\",\"loading\":\"_3c919e86d1bb80ab__loading\",\"unavailable\":\"_9b694d63bdec1a98__unavailable\"};\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,eAAe;AACxB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AACnB,SAAS,eAAe;AAExB,SAAS,MAAM,MAAM,OAAO,QAA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,YAA0B,GAC3D,GACD;AAGD,WACC,oBAAC,yBAAsB,OAAQ,cAC9B;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,QAAS,oBAAC,aAAQ;AAAA,QAClB;AAAA,QACA,WAAY,KAAM,sBAAO,cAAc,SAAU;AAAA,QACjD,mBAAkB,WAAW,QAAQ,UAAU;AAAA,QAC7C,GAAK,WAAW,EAAE,OAAO,OAAO,IAAI,CAAC;AAAA,QAErC;AAAA,2BACD,oBAAC,kBAAiB,kBAAQ,IAE1B;AAAA,UAGD;AAAA,YAAC,KAAK;AAAA,YAAL;AAAA,cACA,WAAY;AAAA,gBACX,sBAAO;AAAA,gBACP,kBAAkB,sBAAO;AAAA,cAC1B;AAAA,cAEE,2BACD;AAAA,gBAAC,KAAK;AAAA,gBAAL;AAAA,kBACA,WAAY,sBAAO;AAAA,kBAEjB;AAAA;AAAA,cACH,IAEA;AAAA;AAAA,UAEF;AAAA;AAAA;AAAA,IACD,GACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": ["WidgetChrome"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-inserter/widget-inserter.tsx
|
|
2
|
+
import { useCallback } from "@wordpress/element";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { Dialog } from "@wordpress/ui";
|
|
5
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
6
|
+
import { useDashboardUIContext } from "../../context/ui-context.mjs";
|
|
7
|
+
import { createDashboardWidget } from "../../utils/create-dashboard-widget/index.mjs";
|
|
8
|
+
import { WidgetPicker } from "../widget-picker/index.mjs";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
function WidgetInserter() {
|
|
11
|
+
const { layout, onLayoutChange } = useDashboardInternalContext();
|
|
12
|
+
const { inserterOpen, setInserterOpen } = useDashboardUIContext();
|
|
13
|
+
const insertWidgets = useCallback(
|
|
14
|
+
(widgetTypes) => {
|
|
15
|
+
if (widgetTypes.length > 0) {
|
|
16
|
+
const newWidgets = widgetTypes.map(
|
|
17
|
+
(widgetType) => createDashboardWidget(widgetType)
|
|
18
|
+
);
|
|
19
|
+
onLayoutChange([...layout, ...newWidgets]);
|
|
20
|
+
}
|
|
21
|
+
setInserterOpen(false);
|
|
22
|
+
},
|
|
23
|
+
[layout, onLayoutChange, setInserterOpen]
|
|
24
|
+
);
|
|
25
|
+
if (!inserterOpen) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return /* @__PURE__ */ jsx(Dialog.Root, { open: inserterOpen, onOpenChange: setInserterOpen, children: /* @__PURE__ */ jsxs(
|
|
29
|
+
Dialog.Popup,
|
|
30
|
+
{
|
|
31
|
+
size: "full",
|
|
32
|
+
portal: /* @__PURE__ */ jsx(
|
|
33
|
+
Dialog.Portal,
|
|
34
|
+
{
|
|
35
|
+
style: {
|
|
36
|
+
"--wp-ui-dialog-z-index": 99999
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
),
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ jsxs(Dialog.Header, { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(Dialog.Title, { children: __("Add widget") }),
|
|
43
|
+
/* @__PURE__ */ jsx(Dialog.CloseIcon, {})
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx(Dialog.Content, { children: /* @__PURE__ */ jsx(WidgetPicker, { onSelect: insertWidgets }) })
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
) });
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
WidgetInserter
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=widget-inserter.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-inserter/widget-inserter.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Dialog } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { createDashboardWidget } from '../../utils/create-dashboard-widget';\nimport { WidgetPicker } from '../widget-picker';\n\n/**\n * Modal widget inserter, mounted by the engine and shown while `inserterOpen`\n * is set in the shared UI context. Selecting widgets appends them to the\n * layout and closes the dialog.\n */\nexport function WidgetInserter() {\n\tconst { layout, onLayoutChange } = useDashboardInternalContext();\n\tconst { inserterOpen, setInserterOpen } = useDashboardUIContext();\n\n\tconst insertWidgets = useCallback(\n\t\t( widgetTypes: WidgetType[] ) => {\n\t\t\tif ( widgetTypes.length > 0 ) {\n\t\t\t\tconst newWidgets = widgetTypes.map( ( widgetType ) =>\n\t\t\t\t\tcreateDashboardWidget( widgetType )\n\t\t\t\t);\n\t\t\t\tonLayoutChange( [ ...layout, ...newWidgets ] );\n\t\t\t}\n\n\t\t\tsetInserterOpen( false );\n\t\t},\n\t\t[ layout, onLayoutChange, setInserterOpen ]\n\t);\n\n\tif ( ! inserterOpen ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Dialog.Root open={ inserterOpen } onOpenChange={ setInserterOpen }>\n\t\t\t<Dialog.Popup\n\t\t\t\tsize=\"full\"\n\t\t\t\tportal={\n\t\t\t\t\t<Dialog.Portal\n\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t'--wp-ui-dialog-z-index': 99999,\n\t\t\t\t\t\t\t} as React.CSSProperties\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t<Dialog.Header>\n\t\t\t\t\t<Dialog.Title>{ __( 'Add widget' ) }</Dialog.Title>\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AAP,EACA,8BAAC,gBAAa,UAAW,eAAgB,GAC1C;AAAA;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-picker/widget-picker.tsx
|
|
2
|
+
import { DataViewsPicker, filterSortAndPaginate } from "@wordpress/dataviews";
|
|
3
|
+
import { Suspense, useMemo, useState } from "@wordpress/element";
|
|
4
|
+
import { __ } from "@wordpress/i18n";
|
|
5
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
6
|
+
import { createDashboardWidget } from "../../utils/create-dashboard-widget/index.mjs";
|
|
7
|
+
import { WidgetRender } from "../widget-render/index.mjs";
|
|
8
|
+
|
|
9
|
+
// packages/style-runtime/src/index.ts
|
|
10
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
11
|
+
function getRuntime() {
|
|
12
|
+
const globalScope = globalThis;
|
|
13
|
+
if (globalScope.__wpStyleRuntime) {
|
|
14
|
+
return globalScope.__wpStyleRuntime;
|
|
15
|
+
}
|
|
16
|
+
globalScope.__wpStyleRuntime = {
|
|
17
|
+
documents: /* @__PURE__ */ new Map(),
|
|
18
|
+
styles: /* @__PURE__ */ new Map(),
|
|
19
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
20
|
+
};
|
|
21
|
+
if (typeof document !== "undefined") {
|
|
22
|
+
registerDocument(document);
|
|
23
|
+
}
|
|
24
|
+
return globalScope.__wpStyleRuntime;
|
|
25
|
+
}
|
|
26
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
27
|
+
if (!targetDocument.head) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
31
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
32
|
+
)) {
|
|
33
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function injectStyle(targetDocument, hash, css) {
|
|
40
|
+
if (!targetDocument.head) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const runtime = getRuntime();
|
|
44
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
45
|
+
if (!injectedStyles) {
|
|
46
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
47
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
48
|
+
}
|
|
49
|
+
if (injectedStyles.has(hash)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
53
|
+
injectedStyles.add(hash);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const style = targetDocument.createElement("style");
|
|
57
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
58
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
59
|
+
targetDocument.head.appendChild(style);
|
|
60
|
+
injectedStyles.add(hash);
|
|
61
|
+
}
|
|
62
|
+
function registerDocument(targetDocument) {
|
|
63
|
+
const runtime = getRuntime();
|
|
64
|
+
runtime.documents.set(
|
|
65
|
+
targetDocument,
|
|
66
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
67
|
+
);
|
|
68
|
+
for (const [hash, css] of runtime.styles) {
|
|
69
|
+
injectStyle(targetDocument, hash, css);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
const count = runtime.documents.get(targetDocument);
|
|
73
|
+
if (count === void 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (count <= 1) {
|
|
77
|
+
runtime.documents.delete(targetDocument);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function registerStyle(hash, css) {
|
|
84
|
+
const runtime = getRuntime();
|
|
85
|
+
runtime.styles.set(hash, css);
|
|
86
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
87
|
+
injectStyle(targetDocument, hash, css);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// packages/widget-dashboard/src/components/widget-picker/widget-picker.module.css
|
|
92
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
93
|
+
registerStyle("93a9ea86b0", "._623aa9eba189276f__preview{height:125%;overflow:hidden;padding:0;pointer-events:none;transform:scale(.8);transform-origin:top left;user-select:none;width:125%}");
|
|
94
|
+
}
|
|
95
|
+
var widget_picker_default = { "preview": "_623aa9eba189276f__preview" };
|
|
96
|
+
|
|
97
|
+
// packages/widget-dashboard/src/components/widget-picker/widget-picker.tsx
|
|
98
|
+
import { jsx } from "react/jsx-runtime";
|
|
99
|
+
var DEFAULT_VIEW = {
|
|
100
|
+
type: "pickerGrid",
|
|
101
|
+
page: 1,
|
|
102
|
+
search: "",
|
|
103
|
+
mediaField: "preview",
|
|
104
|
+
titleField: "title"
|
|
105
|
+
};
|
|
106
|
+
var getItemId = (item) => item.name;
|
|
107
|
+
function WidgetPreview({ item }) {
|
|
108
|
+
const exampleWidget = useMemo(
|
|
109
|
+
() => createDashboardWidget(item, item.example?.attributes),
|
|
110
|
+
[item]
|
|
111
|
+
);
|
|
112
|
+
return /* @__PURE__ */ jsx("div", { className: widget_picker_default.preview, ...{ inert: "" }, children: /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(WidgetRender, { widget: exampleWidget, widgetType: item }) }) });
|
|
113
|
+
}
|
|
114
|
+
var fields = [
|
|
115
|
+
{
|
|
116
|
+
id: "title",
|
|
117
|
+
type: "text",
|
|
118
|
+
label: __("Title"),
|
|
119
|
+
filterBy: false
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
id: "preview",
|
|
123
|
+
type: "media",
|
|
124
|
+
render: WidgetPreview
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
id: "name",
|
|
128
|
+
type: "text",
|
|
129
|
+
enableGlobalSearch: true,
|
|
130
|
+
enableHiding: false,
|
|
131
|
+
enableSorting: false,
|
|
132
|
+
filterBy: false,
|
|
133
|
+
getValue: ({ item }) => `${item.name.replace(/[\/,\-_]/g, " ")} ${item.title}`
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
function WidgetPicker({
|
|
137
|
+
onSelect,
|
|
138
|
+
itemListLabel = __("Widget list")
|
|
139
|
+
}) {
|
|
140
|
+
const { widgetTypes: registeredTypes } = useDashboardInternalContext();
|
|
141
|
+
const [selection, setSelection] = useState([]);
|
|
142
|
+
const [view, setView] = useState(DEFAULT_VIEW);
|
|
143
|
+
const { data: widgetTypes } = filterSortAndPaginate(
|
|
144
|
+
registeredTypes,
|
|
145
|
+
view,
|
|
146
|
+
fields
|
|
147
|
+
);
|
|
148
|
+
const actions = useMemo(
|
|
149
|
+
() => [
|
|
150
|
+
{
|
|
151
|
+
id: "select",
|
|
152
|
+
label: __("Select"),
|
|
153
|
+
isPrimary: true,
|
|
154
|
+
supportsBulk: true,
|
|
155
|
+
callback: (items) => onSelect(items)
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
[onSelect]
|
|
159
|
+
);
|
|
160
|
+
return /* @__PURE__ */ jsx(
|
|
161
|
+
DataViewsPicker,
|
|
162
|
+
{
|
|
163
|
+
data: widgetTypes,
|
|
164
|
+
fields,
|
|
165
|
+
view,
|
|
166
|
+
actions,
|
|
167
|
+
defaultLayouts: { pickerGrid: {} },
|
|
168
|
+
onChangeView: setView,
|
|
169
|
+
isLoading: false,
|
|
170
|
+
paginationInfo: {
|
|
171
|
+
totalItems: widgetTypes.length,
|
|
172
|
+
totalPages: 1
|
|
173
|
+
},
|
|
174
|
+
selection,
|
|
175
|
+
onChangeSelection: setSelection,
|
|
176
|
+
getItemId,
|
|
177
|
+
itemListLabel
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
export {
|
|
182
|
+
WidgetPicker
|
|
183
|
+
};
|
|
184
|
+
//# sourceMappingURL=widget-picker.mjs.map
|