@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/components/widget-picker/widget-picker.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-picker/widget-picker.module.css"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataViewsPicker, filterSortAndPaginate } from '@wordpress/dataviews';\nimport type { Field, View } from '@wordpress/dataviews';\nimport { Suspense, useMemo, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { createDashboardWidget } from '../../utils/create-dashboard-widget';\nimport { WidgetRender } from '../widget-render';\nimport styles from './widget-picker.module.css';\n\nconst DEFAULT_VIEW: View = {\n\ttype: 'pickerGrid',\n\tpage: 1,\n\tsearch: '',\n\tmediaField: 'preview',\n\ttitleField: 'title',\n};\n\nconst getItemId = ( item: WidgetType ) => item.name;\n\nfunction WidgetPreview( { item }: { item: WidgetType } ) {\n\tconst exampleWidget = useMemo(\n\t\t() => createDashboardWidget( item, item.example?.attributes ),\n\t\t[ item ]\n\t);\n\n\treturn (\n\t\t<div className={ styles.preview } { ...{ inert: '' } }>\n\t\t\t<Suspense fallback={ null }>\n\t\t\t\t<WidgetRender widget={ exampleWidget } widgetType={ item } />\n\t\t\t</Suspense>\n\t\t</div>\n\t);\n}\n\nconst fields: Field< WidgetType >[] = [\n\t{\n\t\tid: 'title',\n\t\ttype: 'text',\n\t\tlabel: __( 'Title' ),\n\t\tfilterBy: false,\n\t},\n\t{\n\t\tid: 'preview',\n\t\ttype: 'media',\n\t\trender: WidgetPreview,\n\t},\n\t{\n\t\tid: 'name',\n\t\ttype: 'text',\n\t\tenableGlobalSearch: true,\n\t\tenableHiding: false,\n\t\tenableSorting: false,\n\t\tfilterBy: false,\n\t\tgetValue: ( { item } ) =>\n\t\t\t`${ item.name.replace( /[\\/,\\-_]/g, ' ' ) } ${ item.title }`,\n\t},\n];\n\ninterface WidgetPickerProps {\n\t/**\n\t * Called with the widget types selected by the user. The picker keeps\n\t * its own selection state; consumers receive the resolved list when\n\t * the \"Select\" action fires.\n\t */\n\tonSelect: ( widgetTypes: WidgetType[] ) => void;\n\n\t/**\n\t * Accessible label for the picker's item list.\n\t *\n\t * @default __( 'Widget list' )\n\t */\n\titemListLabel?: string;\n}\n\n/**\n * DataViews-driven widget type picker. Lists `widgetTypes` from the dashboard\n * context as a grid of live previews, supports search via `name`/`title`, and\n * exposes a single \"Select\" action with bulk support so users can insert one\n * or several widgets at once.\n *\n * @param {WidgetPickerProps} props Component props.\n */\nexport function WidgetPicker( {\n\tonSelect,\n\titemListLabel = __( 'Widget list' ),\n}: WidgetPickerProps ) {\n\tconst { widgetTypes: registeredTypes } = useDashboardInternalContext();\n\tconst [ selection, setSelection ] = useState< string[] >( [] );\n\tconst [ view, setView ] = useState< View >( DEFAULT_VIEW );\n\n\tconst { data: widgetTypes } = filterSortAndPaginate(\n\t\tregisteredTypes,\n\t\tview,\n\t\tfields\n\t);\n\n\tconst actions = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tid: 'select',\n\t\t\t\tlabel: __( 'Select' ),\n\t\t\t\tisPrimary: true,\n\t\t\t\tsupportsBulk: true,\n\t\t\t\tcallback: ( items: WidgetType[] ) => onSelect( items ),\n\t\t\t},\n\t\t],\n\t\t[ onSelect ]\n\t);\n\n\treturn (\n\t\t<DataViewsPicker\n\t\t\tdata={ widgetTypes }\n\t\t\tfields={ fields }\n\t\t\tview={ view }\n\t\t\tactions={ actions }\n\t\t\tdefaultLayouts={ { pickerGrid: {} } }\n\t\t\tonChangeView={ setView }\n\t\t\tisLoading={ false }\n\t\t\tpaginationInfo={ {\n\t\t\t\ttotalItems: widgetTypes.length,\n\t\t\t\ttotalPages: 1,\n\t\t\t} }\n\t\t\tselection={ selection }\n\t\t\tonChangeSelection={ setSelection }\n\t\t\tgetItemId={ getItemId }\n\t\t\titemListLabel={ itemListLabel }\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(\"93a9ea86b0\", \"._623aa9eba189276f__preview{height:125%;overflow:hidden;padding:0;pointer-events:none;transform:scale(.8);transform-origin:top left;user-select:none;width:125%}\");\n}\nexport default {\"preview\":\"_623aa9eba189276f__preview\"};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-render/widget-render.tsx
|
|
2
|
+
import { useCallback } from "@wordpress/element";
|
|
3
|
+
import { WidgetRender as WidgetRenderPrimitive } from "@wordpress/widget-primitives";
|
|
4
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
function WidgetRender({ widget, widgetType }) {
|
|
7
|
+
const { layout, onLayoutChange, resolveWidgetModule } = useDashboardInternalContext();
|
|
8
|
+
const setAttributes = useCallback(
|
|
9
|
+
(next) => {
|
|
10
|
+
onLayoutChange(
|
|
11
|
+
layout.map(
|
|
12
|
+
(w) => w.uuid === widget.uuid ? {
|
|
13
|
+
...w,
|
|
14
|
+
attributes: {
|
|
15
|
+
...w.attributes,
|
|
16
|
+
...next
|
|
17
|
+
}
|
|
18
|
+
} : w
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
},
|
|
22
|
+
[widget.uuid, layout, onLayoutChange]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ jsx(
|
|
25
|
+
WidgetRenderPrimitive,
|
|
26
|
+
{
|
|
27
|
+
widgetType,
|
|
28
|
+
attributes: widget.attributes,
|
|
29
|
+
setAttributes,
|
|
30
|
+
resolveWidgetModule
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
WidgetRender
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=widget-render.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-render/widget-render.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { WidgetRender as WidgetRenderPrimitive } from '@wordpress/widget-primitives';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport type { DashboardWidget } from '../../types';\n\ninterface WidgetRenderProps {\n\twidget: DashboardWidget< unknown >;\n\twidgetType: WidgetType;\n}\n\n/**\n * Adapter around the host-agnostic `WidgetRender` primitive. Bridges the\n * dashboard context (`resolveWidgetModule`, layout state) and turns\n * layout-level attribute updates into the per-instance `setAttributes`\n * callback the render contract expects.\n *\n * @param {WidgetRenderProps} props Component props.\n */\nexport function WidgetRender( { widget, widgetType }: WidgetRenderProps ) {\n\tconst { layout, onLayoutChange, resolveWidgetModule } =\n\t\tuseDashboardInternalContext();\n\n\tconst setAttributes = useCallback(\n\t\t( next: Partial< unknown > ) => {\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( w ) =>\n\t\t\t\t\tw.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...w,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( w.attributes as object ),\n\t\t\t\t\t\t\t\t\t...( next as object ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: w\n\t\t\t\t)\n\t\t\t);\n\t\t},\n\t\t[ widget.uuid, layout, onLayoutChange ]\n\t);\n\n\treturn (\n\t\t<WidgetRenderPrimitive\n\t\t\twidgetType={ widgetType }\n\t\t\tattributes={ widget.attributes }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tresolveWidgetModule={ resolveWidgetModule }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB,6BAA6B;AAMtD,SAAS,mCAAmC;AAwC1C;AAxBK,SAAS,aAAc,EAAE,QAAQ,WAAW,GAAuB;AACzE,QAAM,EAAE,QAAQ,gBAAgB,oBAAoB,IACnD,4BAA4B;AAE7B,QAAM,gBAAgB;AAAA,IACrB,CAAE,SAA8B;AAC/B;AAAA,QACC,OAAO;AAAA,UAAK,CAAE,MACb,EAAE,SAAS,OAAO,OACf;AAAA,YACA,GAAG;AAAA,YACH,YAAY;AAAA,cACX,GAAK,EAAE;AAAA,cACP,GAAK;AAAA,YACN;AAAA,UACA,IACA;AAAA,QACJ;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,OAAO,MAAM,QAAQ,cAAe;AAAA,EACvC;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA,YAAa,OAAO;AAAA,MACpB;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/index.ts
|
|
2
|
+
import { WidgetSettings } from "./widget-settings.mjs";
|
|
3
|
+
import { getWidgetSettingsTitle } from "./utils/index.mjs";
|
|
4
|
+
import { WidgetSettingsToolbar } from "./widget-settings-toolbar.mjs";
|
|
5
|
+
export {
|
|
6
|
+
WidgetSettings,
|
|
7
|
+
WidgetSettingsToolbar,
|
|
8
|
+
getWidgetSettingsTitle
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-settings/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { WidgetSettings } from './widget-settings';\nexport { getWidgetSettingsTitle } from './utils';\nexport { WidgetSettingsToolbar } from './widget-settings-toolbar';\nexport type { WidgetSettingsToolbarProps } from './widget-settings-toolbar';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,6BAA6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/utils/get-admin-menu-inset.ts
|
|
2
|
+
var ADMIN_MENU_ID = "adminmenuback";
|
|
3
|
+
function getAdminMenuInset() {
|
|
4
|
+
if (typeof document === "undefined") {
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
const adminMenu = document.getElementById(ADMIN_MENU_ID);
|
|
8
|
+
if (!adminMenu) {
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
return Math.max(0, adminMenu.getBoundingClientRect().right);
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
getAdminMenuInset
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=get-admin-menu-inset.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/widget-settings/utils/get-admin-menu-inset.ts"],
|
|
4
|
+
"sourcesContent": ["// cspell:ignore adminmenuback\nconst ADMIN_MENU_ID = 'adminmenuback';\n\n/**\n * Width, in pixels, taken up by the WordPress admin menu\n * (`#adminmenuback`) on the inline-start edge of the viewport.\n *\n * The settings drawer portals to the document body and anchors to a\n * viewport edge, so a left-anchored drawer would slide over the fixed\n * admin menu. Offsetting the drawer by this value keeps the menu\n * uncovered (and reachable) instead of raising the drawer's z-index over\n * it.\n *\n * Defensive: returns `0` when the element is absent (outside wp-admin, or\n * in tests/Storybook), so the drawer just anchors to the viewport edge.\n *\n * @return {number} The admin menu's right edge in px, or `0`.\n */\nexport function getAdminMenuInset(): number {\n\tif ( typeof document === 'undefined' ) {\n\t\treturn 0;\n\t}\n\n\tconst adminMenu = document.getElementById( ADMIN_MENU_ID );\n\tif ( ! adminMenu ) {\n\t\treturn 0;\n\t}\n\n\treturn Math.max( 0, adminMenu.getBoundingClientRect().right );\n}\n"],
|
|
5
|
+
"mappings": ";AACA,IAAM,gBAAgB;AAiBf,SAAS,oBAA4B;AAC3C,MAAK,OAAO,aAAa,aAAc;AACtC,WAAO;AAAA,EACR;AAEA,QAAM,YAAY,SAAS,eAAgB,aAAc;AACzD,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,SAAO,KAAK,IAAK,GAAG,UAAU,sBAAsB,EAAE,KAAM;AAC7D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/utils/get-widget-settings.ts
|
|
2
|
+
import { sprintf, __ } from "@wordpress/i18n";
|
|
3
|
+
function getWidgetSettingsTitle(widgetType) {
|
|
4
|
+
return widgetType?.title ? sprintf(
|
|
5
|
+
/* translators: %s: Widget title. */
|
|
6
|
+
__("%s settings"),
|
|
7
|
+
widgetType.title
|
|
8
|
+
) : __("Widget settings");
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
getWidgetSettingsTitle
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=get-widget-settings.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/widget-settings/utils/get-widget-settings.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { sprintf, __ } from '@wordpress/i18n';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Localized \"<Widget> settings\" label, falling back to a generic title\n * when the type declares none.\n *\n * @param {WidgetType} widgetType Type backing the open instance.\n * @return {string} The drawer/trigger title.\n */\nexport function getWidgetSettingsTitle( widgetType?: WidgetType ): string {\n\treturn widgetType?.title\n\t\t? sprintf(\n\t\t\t\t/* translators: %s: Widget title. */\n\t\t\t\t__( '%s settings' ),\n\t\t\t\twidgetType.title\n\t\t )\n\t\t: __( 'Widget settings' );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,SAAS,UAAU;AAUrB,SAAS,uBAAwB,YAAkC;AACzE,SAAO,YAAY,QAChB;AAAA;AAAA,IAEA,GAAI,aAAc;AAAA,IAClB,WAAW;AAAA,EACX,IACA,GAAI,iBAAkB;AAC1B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/utils/index.ts
|
|
2
|
+
import { getAdminMenuInset } from "./get-admin-menu-inset.mjs";
|
|
3
|
+
import { getWidgetSettingsTitle } from "./get-widget-settings.mjs";
|
|
4
|
+
export {
|
|
5
|
+
getAdminMenuInset,
|
|
6
|
+
getWidgetSettingsTitle
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/components/widget-settings/utils/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { getAdminMenuInset } from './get-admin-menu-inset';\nexport { getWidgetSettingsTitle } from './get-widget-settings';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.tsx
|
|
2
|
+
import { WidgetToolbar } from "../widget-toolbar/index.mjs";
|
|
3
|
+
import { WidgetSettingsTrigger } from "./widget-settings-trigger.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/style-runtime/src/index.ts
|
|
6
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
7
|
+
function getRuntime() {
|
|
8
|
+
const globalScope = globalThis;
|
|
9
|
+
if (globalScope.__wpStyleRuntime) {
|
|
10
|
+
return globalScope.__wpStyleRuntime;
|
|
11
|
+
}
|
|
12
|
+
globalScope.__wpStyleRuntime = {
|
|
13
|
+
documents: /* @__PURE__ */ new Map(),
|
|
14
|
+
styles: /* @__PURE__ */ new Map(),
|
|
15
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
16
|
+
};
|
|
17
|
+
if (typeof document !== "undefined") {
|
|
18
|
+
registerDocument(document);
|
|
19
|
+
}
|
|
20
|
+
return globalScope.__wpStyleRuntime;
|
|
21
|
+
}
|
|
22
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
23
|
+
if (!targetDocument.head) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
27
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
28
|
+
)) {
|
|
29
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
function injectStyle(targetDocument, hash, css) {
|
|
36
|
+
if (!targetDocument.head) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const runtime = getRuntime();
|
|
40
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
41
|
+
if (!injectedStyles) {
|
|
42
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
43
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
44
|
+
}
|
|
45
|
+
if (injectedStyles.has(hash)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
49
|
+
injectedStyles.add(hash);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const style = targetDocument.createElement("style");
|
|
53
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
54
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
55
|
+
targetDocument.head.appendChild(style);
|
|
56
|
+
injectedStyles.add(hash);
|
|
57
|
+
}
|
|
58
|
+
function registerDocument(targetDocument) {
|
|
59
|
+
const runtime = getRuntime();
|
|
60
|
+
runtime.documents.set(
|
|
61
|
+
targetDocument,
|
|
62
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
63
|
+
);
|
|
64
|
+
for (const [hash, css] of runtime.styles) {
|
|
65
|
+
injectStyle(targetDocument, hash, css);
|
|
66
|
+
}
|
|
67
|
+
return () => {
|
|
68
|
+
const count = runtime.documents.get(targetDocument);
|
|
69
|
+
if (count === void 0) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (count <= 1) {
|
|
73
|
+
runtime.documents.delete(targetDocument);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function registerStyle(hash, css) {
|
|
80
|
+
const runtime = getRuntime();
|
|
81
|
+
runtime.styles.set(hash, css);
|
|
82
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
83
|
+
injectStyle(targetDocument, hash, css);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.module.css
|
|
88
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
89
|
+
registerStyle("76555dc7e2", "._931c420497181bdb__widgetSettingsToolbar{background:color-mix(in srgb,var(--wpds-color-background-surface-neutral,#fcfcfc) 40%,transparent);opacity:0;pointer-events:none}[data-wp-grid-item-key]:focus-within ._931c420497181bdb__widgetSettingsToolbar,[data-wp-grid-item-key]:hover ._931c420497181bdb__widgetSettingsToolbar{opacity:1;pointer-events:auto}@media not (prefers-reduced-motion){._931c420497181bdb__widgetSettingsToolbar{transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}");
|
|
90
|
+
}
|
|
91
|
+
var widget_settings_toolbar_default = { "widgetSettingsToolbar": "_931c420497181bdb__widgetSettingsToolbar" };
|
|
92
|
+
|
|
93
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings-toolbar.tsx
|
|
94
|
+
import { jsx } from "react/jsx-runtime";
|
|
95
|
+
function WidgetSettingsToolbar({
|
|
96
|
+
widget,
|
|
97
|
+
widgetType
|
|
98
|
+
}) {
|
|
99
|
+
if (!widgetType.attributes?.length) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
return /* @__PURE__ */ jsx(WidgetToolbar, { className: widget_settings_toolbar_default.widgetSettingsToolbar, children: /* @__PURE__ */ jsx(
|
|
103
|
+
WidgetSettingsTrigger,
|
|
104
|
+
{
|
|
105
|
+
widget,
|
|
106
|
+
widgetType
|
|
107
|
+
}
|
|
108
|
+
) });
|
|
109
|
+
}
|
|
110
|
+
export {
|
|
111
|
+
WidgetSettingsToolbar
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=widget-settings-toolbar.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-settings/widget-settings-toolbar.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/widget-settings/widget-settings-toolbar.module.css"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { WidgetToolbar } from '../widget-toolbar';\nimport { WidgetSettingsTrigger } from './widget-settings-trigger';\nimport styles from './widget-settings-toolbar.module.css';\nimport type { DashboardWidget } from '../../types';\n\nexport interface WidgetSettingsToolbarProps {\n\t/** The instance whose settings this toolbar configures. */\n\twidget: DashboardWidget< unknown >;\n\n\t/** The instance's widget type, for the trigger label and guard. */\n\twidgetType: WidgetType;\n}\n\n/**\n * Normal-mode per-tile toolbar: the gear that opens the settings drawer. Lives\n * in the grid's `actionableArea` slot, so it shows for every `presentation`.\n * Returns `null` when the type has no attributes.\n *\n * @param {WidgetSettingsToolbarProps} props Component props.\n */\nexport function WidgetSettingsToolbar( {\n\twidget,\n\twidgetType,\n}: WidgetSettingsToolbarProps ): React.ReactNode {\n\tif ( ! widgetType.attributes?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<WidgetToolbar className={ styles.widgetSettingsToolbar }>\n\t\t\t<WidgetSettingsTrigger\n\t\t\t\twidget={ widget }\n\t\t\t\twidgetType={ widgetType }\n\t\t\t/>\n\t\t</WidgetToolbar>\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(\"76555dc7e2\", \"._931c420497181bdb__widgetSettingsToolbar{background:color-mix(in srgb,var(--wpds-color-background-surface-neutral,#fcfcfc) 40%,transparent);opacity:0;pointer-events:none}[data-wp-grid-item-key]:focus-within ._931c420497181bdb__widgetSettingsToolbar,[data-wp-grid-item-key]:hover ._931c420497181bdb__widgetSettingsToolbar{opacity:1;pointer-events:auto}@media not (prefers-reduced-motion){._931c420497181bdb__widgetSettingsToolbar{transition:opacity var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-subtle,cubic-bezier(.15,0,.15,1))}}\");\n}\nexport default {\"widgetSettingsToolbar\":\"_931c420497181bdb__widgetSettingsToolbar\"};\n"],
|
|
5
|
+
"mappings": ";AAQA,SAAS,qBAAqB;AAC9B,SAAS,6BAA6B;;;ACCtC,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;AAC3E,MAAK,CAAE,eAAe,MAAO;AAC5B;AAAA,EACD;AAEA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;AAEhE,MAAK,CAAE,gBAAiB;AACvB,qBAAiB,oBAAI,IAAI;AACzB,YAAQ,eAAe,IAAK,gBAAgB,cAAe;AAAA,EAC5D;AAEA,MAAK,eAAe,IAAK,IAAK,GAAI;AACjC;AAAA,EACD;AAKA,MAAK,0BAA2B,gBAAgB,IAAK,GAAI;AACxD,mBAAe,IAAK,IAAK;AACzB;AAAA,EACD;AAEA,QAAM,QAAQ,eAAe,cAAe,OAAQ;AACpD,QAAM,aAAc,sBAAsB,IAAK;AAC/C,QAAM,YAAa,eAAe,eAAgB,GAAI,CAAE;AACxD,iBAAe,KAAK,YAAa,KAAM;AACvC,iBAAe,IAAK,IAAK;AAC1B;AAaO,SAAS,iBAAkB,gBAA2B;AAC5D,QAAM,UAAU,WAAW;AAE3B,UAAQ,UAAU;AAAA,IACjB;AAAA,KACE,QAAQ,UAAU,IAAK,cAAe,KAAK,KAAM;AAAA,EACpD;AAEA,aAAY,CAAE,MAAM,GAAI,KAAK,QAAQ,QAAS;AAC7C,gBAAa,gBAAgB,MAAM,GAAI;AAAA,EACxC;AAEA,SAAO,MAAM;AACZ,UAAM,QAAQ,QAAQ,UAAU,IAAK,cAAe;AAEpD,QAAK,UAAU,QAAY;AAC1B;AAAA,IACD;AAEA,QAAK,SAAS,GAAI;AACjB,cAAQ,UAAU,OAAQ,cAAe;AACzC;AAAA,IACD;AAEA,YAAQ,UAAU,IAAK,gBAAgB,QAAQ,CAAE;AAAA,EAClD;AACD;AAaO,SAAS,cAAe,MAAc,KAAc;AAC1D,QAAM,UAAU,WAAW;AAE3B,UAAQ,OAAO,IAAK,MAAM,GAAI;AAE9B,aAAY,kBAAkB,QAAQ,UAAU,KAAK,GAAI;AACxD,gBAAa,gBAAgB,MAAM,GAAI;AAAA,EACxC;AACD;;;ACpKA,IAAI,OAAO,YAAY,eAAe,QAAQ,IAAI,aAAa,QAAQ;AACtE,gBAAc,cAAc,kiBAAkiB;AAC/jB;AACA,IAAO,kCAAQ,EAAC,yBAAwB,2CAA0C;;;AFkC/E;AAVI,SAAS,sBAAuB;AAAA,EACtC;AAAA,EACA;AACD,GAAiD;AAChD,MAAK,CAAE,WAAW,YAAY,QAAS;AACtC,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,iBAAc,WAAY,gCAAO,uBACjC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings-trigger.tsx
|
|
2
|
+
import { useCallback } from "@wordpress/element";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { cog } from "@wordpress/icons";
|
|
5
|
+
import { IconButton } from "@wordpress/ui";
|
|
6
|
+
import { useDashboardUIContext } from "../../context/ui-context.mjs";
|
|
7
|
+
import { getAdminMenuInset } from "./utils/index.mjs";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
function WidgetSettingsTrigger({
|
|
10
|
+
widget,
|
|
11
|
+
widgetType
|
|
12
|
+
}) {
|
|
13
|
+
const {
|
|
14
|
+
setSettingsWidgetUuid,
|
|
15
|
+
setSettingsDrawerSide,
|
|
16
|
+
setSettingsDrawerInset
|
|
17
|
+
} = useDashboardUIContext();
|
|
18
|
+
const open = useCallback(
|
|
19
|
+
(event) => {
|
|
20
|
+
const adminMenuInset = getAdminMenuInset();
|
|
21
|
+
const tile = event.currentTarget.closest(
|
|
22
|
+
"[data-wp-grid-item-key]"
|
|
23
|
+
);
|
|
24
|
+
const rect = (tile ?? event.currentTarget).getBoundingClientRect();
|
|
25
|
+
const widgetCenter = rect.left + rect.width / 2;
|
|
26
|
+
const contentCenter = (adminMenuInset + window.innerWidth) / 2;
|
|
27
|
+
const side = widgetCenter > contentCenter ? "left" : "right";
|
|
28
|
+
setSettingsDrawerSide(side);
|
|
29
|
+
setSettingsDrawerInset(side === "left" ? adminMenuInset : 0);
|
|
30
|
+
setSettingsWidgetUuid(widget.uuid);
|
|
31
|
+
},
|
|
32
|
+
[
|
|
33
|
+
setSettingsDrawerSide,
|
|
34
|
+
setSettingsDrawerInset,
|
|
35
|
+
setSettingsWidgetUuid,
|
|
36
|
+
widget.uuid
|
|
37
|
+
]
|
|
38
|
+
);
|
|
39
|
+
if (!widgetType.attributes?.length) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return /* @__PURE__ */ jsx(
|
|
43
|
+
IconButton,
|
|
44
|
+
{
|
|
45
|
+
icon: cog,
|
|
46
|
+
label: __("Widget settings"),
|
|
47
|
+
variant: "minimal",
|
|
48
|
+
tone: "neutral",
|
|
49
|
+
size: "compact",
|
|
50
|
+
onClick: open
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
WidgetSettingsTrigger
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=widget-settings-trigger.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-settings/widget-settings-trigger.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { cog } from '@wordpress/icons';\n// Dashboard is still experimental.\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { IconButton } from '@wordpress/ui';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { getAdminMenuInset } from './utils';\nimport type { DashboardWidget } from '../../types';\n\nexport interface WidgetSettingsTriggerProps {\n\t/**\n\t * The instance whose settings drawer this gear opens.\n\t */\n\twidget: DashboardWidget< unknown >;\n\n\t/**\n\t * The instance's widget type, used for the accessible label and the\n\t * attributes guard.\n\t */\n\twidgetType: WidgetType;\n}\n\n/**\n * Per-instance gear that opens the shared settings drawer by writing the\n * instance `uuid` to the UI context; the single `WidgetSettings` at the root\n * reacts to it. Returns `null` when the type declares no attributes, so chrome\n * can mount it unconditionally.\n *\n * @param {WidgetSettingsTriggerProps} props Component props.\n */\nexport function WidgetSettingsTrigger( {\n\twidget,\n\twidgetType,\n}: WidgetSettingsTriggerProps ): React.ReactNode {\n\tconst {\n\t\tsetSettingsWidgetUuid,\n\t\tsetSettingsDrawerSide,\n\t\tsetSettingsDrawerInset,\n\t} = useDashboardUIContext();\n\n\tconst open = useCallback(\n\t\t( event: React.MouseEvent< HTMLElement > ) => {\n\t\t\t// Open the drawer on the side away from the widget: compare the\n\t\t\t// tile's center against the midpoint of the usable content area\n\t\t\t// (which starts after the admin menu). Past it opens left.\n\t\t\tconst adminMenuInset = getAdminMenuInset();\n\t\t\t// The gear sits in the grid slot, outside the card, so reach the\n\t\t\t// tile via the grid item's data hook.\n\t\t\tconst tile = event.currentTarget.closest(\n\t\t\t\t'[data-wp-grid-item-key]'\n\t\t\t);\n\t\t\tconst rect = (\n\t\t\t\ttile ?? event.currentTarget\n\t\t\t).getBoundingClientRect();\n\t\t\tconst widgetCenter = rect.left + rect.width / 2;\n\t\t\tconst contentCenter = ( adminMenuInset + window.innerWidth ) / 2;\n\t\t\tconst side = widgetCenter > contentCenter ? 'left' : 'right';\n\n\t\t\tsetSettingsDrawerSide( side );\n\t\t\t// A left drawer would otherwise slide over the fixed admin menu;\n\t\t\t// offset it by the menu width so it lands clear of it.\n\t\t\tsetSettingsDrawerInset( side === 'left' ? adminMenuInset : 0 );\n\t\t\tsetSettingsWidgetUuid( widget.uuid );\n\t\t},\n\t\t[\n\t\t\tsetSettingsDrawerSide,\n\t\t\tsetSettingsDrawerInset,\n\t\t\tsetSettingsWidgetUuid,\n\t\t\twidget.uuid,\n\t\t]\n\t);\n\n\tif ( ! widgetType.attributes?.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<IconButton\n\t\t\ticon={ cog }\n\t\t\tlabel={ __( 'Widget settings' ) }\n\t\t\tvariant=\"minimal\"\n\t\t\ttone=\"neutral\"\n\t\t\tsize=\"compact\"\n\t\t\tonClick={ open }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,mBAAmB;AAC5B,SAAS,UAAU;AACnB,SAAS,WAAW;AAGpB,SAAS,kBAAkB;AAM3B,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAuEhC;AA/CK,SAAS,sBAAuB;AAAA,EACtC;AAAA,EACA;AACD,GAAiD;AAChD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,sBAAsB;AAE1B,QAAM,OAAO;AAAA,IACZ,CAAE,UAA4C;AAI7C,YAAM,iBAAiB,kBAAkB;AAGzC,YAAM,OAAO,MAAM,cAAc;AAAA,QAChC;AAAA,MACD;AACA,YAAM,QACL,QAAQ,MAAM,eACb,sBAAsB;AACxB,YAAM,eAAe,KAAK,OAAO,KAAK,QAAQ;AAC9C,YAAM,iBAAkB,iBAAiB,OAAO,cAAe;AAC/D,YAAM,OAAO,eAAe,gBAAgB,SAAS;AAErD,4BAAuB,IAAK;AAG5B,6BAAwB,SAAS,SAAS,iBAAiB,CAAE;AAC7D,4BAAuB,OAAO,IAAK;AAAA,IACpC;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IACR;AAAA,EACD;AAEA,MAAK,CAAE,WAAW,YAAY,QAAS;AACtC,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,OAAQ,GAAI,iBAAkB;AAAA,MAC9B,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAK;AAAA,MACL,SAAU;AAAA;AAAA,EACX;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings.tsx
|
|
2
|
+
import { DataForm } from "@wordpress/dataviews";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState } from "@wordpress/element";
|
|
4
|
+
import { __ } from "@wordpress/i18n";
|
|
5
|
+
import { Button, Drawer } from "@wordpress/ui";
|
|
6
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
7
|
+
import { useDashboardUIContext } from "../../context/ui-context.mjs";
|
|
8
|
+
import { getWidgetSettingsTitle } from "./utils/index.mjs";
|
|
9
|
+
|
|
10
|
+
// packages/style-runtime/src/index.ts
|
|
11
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
12
|
+
function getRuntime() {
|
|
13
|
+
const globalScope = globalThis;
|
|
14
|
+
if (globalScope.__wpStyleRuntime) {
|
|
15
|
+
return globalScope.__wpStyleRuntime;
|
|
16
|
+
}
|
|
17
|
+
globalScope.__wpStyleRuntime = {
|
|
18
|
+
documents: /* @__PURE__ */ new Map(),
|
|
19
|
+
styles: /* @__PURE__ */ new Map(),
|
|
20
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
21
|
+
};
|
|
22
|
+
if (typeof document !== "undefined") {
|
|
23
|
+
registerDocument(document);
|
|
24
|
+
}
|
|
25
|
+
return globalScope.__wpStyleRuntime;
|
|
26
|
+
}
|
|
27
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
28
|
+
if (!targetDocument.head) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
32
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
33
|
+
)) {
|
|
34
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
function injectStyle(targetDocument, hash, css) {
|
|
41
|
+
if (!targetDocument.head) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const runtime = getRuntime();
|
|
45
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
46
|
+
if (!injectedStyles) {
|
|
47
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
48
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
49
|
+
}
|
|
50
|
+
if (injectedStyles.has(hash)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
54
|
+
injectedStyles.add(hash);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const style = targetDocument.createElement("style");
|
|
58
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
59
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
60
|
+
targetDocument.head.appendChild(style);
|
|
61
|
+
injectedStyles.add(hash);
|
|
62
|
+
}
|
|
63
|
+
function registerDocument(targetDocument) {
|
|
64
|
+
const runtime = getRuntime();
|
|
65
|
+
runtime.documents.set(
|
|
66
|
+
targetDocument,
|
|
67
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
68
|
+
);
|
|
69
|
+
for (const [hash, css] of runtime.styles) {
|
|
70
|
+
injectStyle(targetDocument, hash, css);
|
|
71
|
+
}
|
|
72
|
+
return () => {
|
|
73
|
+
const count = runtime.documents.get(targetDocument);
|
|
74
|
+
if (count === void 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (count <= 1) {
|
|
78
|
+
runtime.documents.delete(targetDocument);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function registerStyle(hash, css) {
|
|
85
|
+
const runtime = getRuntime();
|
|
86
|
+
runtime.styles.set(hash, css);
|
|
87
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
88
|
+
injectStyle(targetDocument, hash, css);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings.module.css
|
|
93
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
94
|
+
registerStyle("809494c486", "._34828f30ba41ad89__popup{margin-block-start:var(--wp-admin--admin-bar--height,0)}");
|
|
95
|
+
}
|
|
96
|
+
var widget_settings_default = { "popup": "_34828f30ba41ad89__popup" };
|
|
97
|
+
|
|
98
|
+
// packages/widget-dashboard/src/components/widget-settings/widget-settings.tsx
|
|
99
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
100
|
+
function WidgetSettings() {
|
|
101
|
+
const {
|
|
102
|
+
layout,
|
|
103
|
+
onLayoutChange,
|
|
104
|
+
widgetTypes,
|
|
105
|
+
commit,
|
|
106
|
+
cancel: cancelStaging,
|
|
107
|
+
hasUncommittedChanges
|
|
108
|
+
} = useDashboardInternalContext();
|
|
109
|
+
const {
|
|
110
|
+
settingsWidgetUuid,
|
|
111
|
+
setSettingsWidgetUuid,
|
|
112
|
+
settingsDrawerSide,
|
|
113
|
+
settingsDrawerInset
|
|
114
|
+
} = useDashboardUIContext();
|
|
115
|
+
const open = settingsWidgetUuid !== null;
|
|
116
|
+
const [lastWidgetUuid, setLastWidgetUuid] = useState(
|
|
117
|
+
settingsWidgetUuid
|
|
118
|
+
);
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (settingsWidgetUuid) {
|
|
121
|
+
setLastWidgetUuid(settingsWidgetUuid);
|
|
122
|
+
}
|
|
123
|
+
}, [settingsWidgetUuid]);
|
|
124
|
+
const activeUuid = settingsWidgetUuid ?? lastWidgetUuid;
|
|
125
|
+
const widget = activeUuid ? layout.find((instance) => instance.uuid === activeUuid) : void 0;
|
|
126
|
+
const widgetType = widget ? widgetTypes.find((type) => type.name === widget.type) : void 0;
|
|
127
|
+
const fields = useMemo(
|
|
128
|
+
() => widgetType?.attributes ?? [],
|
|
129
|
+
[widgetType?.attributes]
|
|
130
|
+
);
|
|
131
|
+
const form = useMemo(
|
|
132
|
+
() => ({
|
|
133
|
+
layout: { type: "regular", labelPosition: "top" },
|
|
134
|
+
fields: fields.map((field) => field.id)
|
|
135
|
+
}),
|
|
136
|
+
[fields]
|
|
137
|
+
);
|
|
138
|
+
const handleChange = useCallback(
|
|
139
|
+
(edits) => {
|
|
140
|
+
if (!widget) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
onLayoutChange(
|
|
144
|
+
layout.map(
|
|
145
|
+
(instance) => instance.uuid === widget.uuid ? {
|
|
146
|
+
...instance,
|
|
147
|
+
attributes: {
|
|
148
|
+
...instance.attributes,
|
|
149
|
+
...edits
|
|
150
|
+
}
|
|
151
|
+
} : instance
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
},
|
|
155
|
+
[layout, onLayoutChange, widget]
|
|
156
|
+
);
|
|
157
|
+
const close = useCallback(
|
|
158
|
+
() => setSettingsWidgetUuid(null),
|
|
159
|
+
[setSettingsWidgetUuid]
|
|
160
|
+
);
|
|
161
|
+
const handleSave = useCallback(() => {
|
|
162
|
+
commit();
|
|
163
|
+
close();
|
|
164
|
+
}, [commit, close]);
|
|
165
|
+
const handleOpenChange = useCallback(
|
|
166
|
+
(nextOpen) => {
|
|
167
|
+
if (!nextOpen) {
|
|
168
|
+
cancelStaging();
|
|
169
|
+
close();
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
[cancelStaging, close]
|
|
173
|
+
);
|
|
174
|
+
const popupStyle = useMemo(
|
|
175
|
+
() => settingsDrawerSide === "left" && settingsDrawerInset > 0 ? { marginLeft: settingsDrawerInset } : {},
|
|
176
|
+
[settingsDrawerSide, settingsDrawerInset]
|
|
177
|
+
);
|
|
178
|
+
const hasForm = !!widget && !!widgetType && fields.length > 0;
|
|
179
|
+
if (!hasForm) {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
const title = getWidgetSettingsTitle(widgetType);
|
|
183
|
+
const data = widget?.attributes ?? widgetType?.example?.attributes ?? {};
|
|
184
|
+
return /* @__PURE__ */ jsx(
|
|
185
|
+
Drawer.Root,
|
|
186
|
+
{
|
|
187
|
+
open,
|
|
188
|
+
onOpenChange: handleOpenChange,
|
|
189
|
+
swipeDirection: settingsDrawerSide,
|
|
190
|
+
modal: false,
|
|
191
|
+
disablePointerDismissal: true,
|
|
192
|
+
children: /* @__PURE__ */ jsxs(
|
|
193
|
+
Drawer.Popup,
|
|
194
|
+
{
|
|
195
|
+
size: "medium",
|
|
196
|
+
className: widget_settings_default.popup,
|
|
197
|
+
style: popupStyle,
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsxs(Drawer.Header, { children: [
|
|
200
|
+
/* @__PURE__ */ jsx(Drawer.Title, { children: title }),
|
|
201
|
+
/* @__PURE__ */ jsx(Drawer.CloseIcon, {})
|
|
202
|
+
] }),
|
|
203
|
+
/* @__PURE__ */ jsx(Drawer.Content, { children: /* @__PURE__ */ jsx(
|
|
204
|
+
DataForm,
|
|
205
|
+
{
|
|
206
|
+
data,
|
|
207
|
+
fields,
|
|
208
|
+
form,
|
|
209
|
+
onChange: handleChange
|
|
210
|
+
}
|
|
211
|
+
) }),
|
|
212
|
+
/* @__PURE__ */ jsxs(Drawer.Footer, { children: [
|
|
213
|
+
/* @__PURE__ */ jsx(
|
|
214
|
+
Button,
|
|
215
|
+
{
|
|
216
|
+
variant: "minimal",
|
|
217
|
+
tone: "brand",
|
|
218
|
+
size: "compact",
|
|
219
|
+
onClick: () => handleOpenChange(false),
|
|
220
|
+
children: __("Cancel")
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
/* @__PURE__ */ jsx(
|
|
224
|
+
Button,
|
|
225
|
+
{
|
|
226
|
+
variant: "solid",
|
|
227
|
+
tone: "brand",
|
|
228
|
+
size: "compact",
|
|
229
|
+
onClick: handleSave,
|
|
230
|
+
disabled: !hasUncommittedChanges,
|
|
231
|
+
children: __("Save")
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] })
|
|
235
|
+
]
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
WidgetSettings
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=widget-settings.mjs.map
|