@wordpress/widget-dashboard 0.2.0 → 0.3.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 +30 -0
- package/README.md +29 -16
- package/build/components/actions/actions.cjs +6 -23
- package/build/components/actions/actions.cjs.map +3 -3
- package/build/components/commands/commands.cjs +1 -60
- package/build/components/commands/commands.cjs.map +2 -2
- package/build/{utils/grid-model-change → components/widget-attribute-controls}/index.cjs +7 -9
- package/build/components/widget-attribute-controls/index.cjs.map +7 -0
- package/build/components/widget-attribute-controls/widget-attribute-controls.cjs +93 -0
- package/build/components/widget-attribute-controls/widget-attribute-controls.cjs.map +7 -0
- package/build/components/widget-chrome/widget-chrome.cjs +28 -69
- package/build/components/widget-chrome/widget-chrome.cjs.map +2 -2
- package/build/components/{layout-settings → widget-frame}/index.cjs +9 -7
- package/build/components/widget-frame/index.cjs.map +7 -0
- package/build/components/widget-frame/widget-frame.cjs +193 -0
- package/build/components/widget-frame/widget-frame.cjs.map +7 -0
- package/build/{utils/migrate-layout → components/widget-header}/index.cjs +7 -7
- package/build/components/widget-header/index.cjs.map +7 -0
- package/build/components/widget-header/widget-header-infotip.cjs +166 -0
- package/build/components/widget-header/widget-header-infotip.cjs.map +7 -0
- package/build/components/widget-header/widget-header.cjs +176 -0
- package/build/components/widget-header/widget-header.cjs.map +7 -0
- package/build/components/{widget-settings/utils/get-admin-menu-inset.cjs → widget-layout-controls/index.cjs} +8 -18
- package/build/components/widget-layout-controls/index.cjs.map +7 -0
- package/build/components/{widgets/widget-layout-toolbar.cjs → widget-layout-controls/widget-layout-controls.cjs} +9 -100
- package/build/components/widget-layout-controls/widget-layout-controls.cjs.map +7 -0
- package/build/components/widget-picker/widget-picker.cjs +5 -93
- package/build/components/widget-picker/widget-picker.cjs.map +3 -3
- package/build/components/widget-preview-chrome/index.cjs +31 -0
- package/build/components/widget-preview-chrome/index.cjs.map +7 -0
- package/build/components/{widget-settings/widget-settings-toolbar.cjs → widget-preview-chrome/widget-preview-chrome.cjs} +41 -23
- package/build/components/widget-preview-chrome/widget-preview-chrome.cjs.map +7 -0
- package/build/components/widget-settings/index.cjs +3 -3
- package/build/components/widget-settings/index.cjs.map +1 -1
- package/build/components/widget-settings/utils/index.cjs +0 -3
- package/build/components/widget-settings/utils/index.cjs.map +2 -2
- package/build/components/widget-settings/widget-settings-trigger.cjs +22 -28
- package/build/components/widget-settings/widget-settings-trigger.cjs.map +2 -2
- package/build/components/widget-settings/widget-settings.cjs +40 -57
- package/build/components/widget-settings/widget-settings.cjs.map +2 -2
- package/build/components/widget-toolbar/widget-toolbar.cjs +7 -4
- package/build/components/widget-toolbar/widget-toolbar.cjs.map +2 -2
- package/build/components/widgets/widget-resize-handle.cjs +4 -4
- package/build/components/widgets/widget-resize-handle.cjs.map +2 -2
- package/build/components/widgets/widgets.cjs +18 -11
- package/build/components/widgets/widgets.cjs.map +2 -2
- package/build/context/dashboard-context.cjs +31 -80
- package/build/context/dashboard-context.cjs.map +2 -2
- package/build/context/ui-context.cjs +2 -18
- package/build/context/ui-context.cjs.map +2 -2
- package/build/types.cjs.map +1 -1
- package/build/utils/index.cjs +2 -5
- package/build/utils/index.cjs.map +2 -2
- package/build/widget-dashboard.cjs +0 -4
- package/build/widget-dashboard.cjs.map +2 -2
- package/build-module/components/actions/actions.mjs +7 -24
- package/build-module/components/actions/actions.mjs.map +2 -2
- package/build-module/components/commands/commands.mjs +2 -67
- package/build-module/components/commands/commands.mjs.map +2 -2
- package/build-module/components/widget-attribute-controls/index.mjs +6 -0
- package/build-module/components/widget-attribute-controls/index.mjs.map +7 -0
- package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs +68 -0
- package/build-module/components/widget-attribute-controls/widget-attribute-controls.mjs.map +7 -0
- package/build-module/components/widget-chrome/widget-chrome.mjs +29 -76
- package/build-module/components/widget-chrome/widget-chrome.mjs.map +2 -2
- package/build-module/components/widget-frame/index.mjs +7 -0
- package/build-module/components/widget-frame/index.mjs.map +7 -0
- package/build-module/components/widget-frame/widget-frame.mjs +157 -0
- package/build-module/components/widget-frame/widget-frame.mjs.map +7 -0
- package/build-module/components/widget-header/index.mjs +6 -0
- package/build-module/components/widget-header/index.mjs.map +7 -0
- package/build-module/components/widget-header/widget-header-infotip.mjs +141 -0
- package/build-module/components/widget-header/widget-header-infotip.mjs.map +7 -0
- package/build-module/components/widget-header/widget-header.mjs +141 -0
- package/build-module/components/widget-header/widget-header.mjs.map +7 -0
- package/build-module/components/widget-layout-controls/index.mjs +6 -0
- package/build-module/components/widget-layout-controls/index.mjs.map +7 -0
- package/build-module/components/widget-layout-controls/widget-layout-controls.mjs +90 -0
- package/build-module/components/widget-layout-controls/widget-layout-controls.mjs.map +7 -0
- package/build-module/components/widget-picker/widget-picker.mjs +6 -94
- package/build-module/components/widget-picker/widget-picker.mjs.map +3 -3
- package/build-module/components/widget-preview-chrome/index.mjs +6 -0
- package/build-module/components/widget-preview-chrome/index.mjs.map +7 -0
- package/build-module/components/{widget-settings/widget-settings-toolbar.mjs → widget-preview-chrome/widget-preview-chrome.mjs} +37 -19
- package/build-module/components/widget-preview-chrome/widget-preview-chrome.mjs.map +7 -0
- package/build-module/components/widget-settings/index.mjs +2 -2
- package/build-module/components/widget-settings/index.mjs.map +1 -1
- package/build-module/components/widget-settings/utils/index.mjs +0 -2
- package/build-module/components/widget-settings/utils/index.mjs.map +2 -2
- package/build-module/components/widget-settings/widget-settings-trigger.mjs +23 -29
- package/build-module/components/widget-settings/widget-settings-trigger.mjs.map +2 -2
- package/build-module/components/widget-settings/widget-settings.mjs +40 -57
- package/build-module/components/widget-settings/widget-settings.mjs.map +2 -2
- package/build-module/components/widget-toolbar/widget-toolbar.mjs +7 -4
- package/build-module/components/widget-toolbar/widget-toolbar.mjs.map +2 -2
- package/build-module/components/widgets/widget-resize-handle.mjs +4 -4
- package/build-module/components/widgets/widget-resize-handle.mjs.map +2 -2
- package/build-module/components/widgets/widgets.mjs +18 -11
- package/build-module/components/widgets/widgets.mjs.map +2 -2
- package/build-module/context/dashboard-context.mjs +31 -80
- package/build-module/context/dashboard-context.mjs.map +2 -2
- package/build-module/context/ui-context.mjs +2 -18
- package/build-module/context/ui-context.mjs.map +2 -2
- package/build-module/types.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -3
- package/build-module/utils/index.mjs.map +2 -2
- package/build-module/widget-dashboard.mjs +0 -4
- package/build-module/widget-dashboard.mjs.map +2 -2
- package/build-types/components/actions/actions.d.ts.map +1 -1
- package/build-types/components/commands/commands.d.ts.map +1 -1
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts +1 -1
- package/build-types/components/commands/use-pending-when-edit-mode.d.ts.map +1 -1
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts +1 -1
- package/build-types/components/no-widgets-state/no-widgets-state.d.ts.map +1 -1
- package/build-types/components/widget-attribute-controls/index.d.ts +2 -0
- package/build-types/components/widget-attribute-controls/index.d.ts.map +1 -0
- package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts +23 -0
- package/build-types/components/widget-attribute-controls/widget-attribute-controls.d.ts.map +1 -0
- package/build-types/components/widget-chrome/widget-chrome.d.ts +8 -8
- package/build-types/components/widget-chrome/widget-chrome.d.ts.map +1 -1
- package/build-types/components/widget-frame/index.d.ts +3 -0
- package/build-types/components/widget-frame/index.d.ts.map +1 -0
- package/build-types/components/widget-frame/widget-frame.d.ts +25 -0
- package/build-types/components/widget-frame/widget-frame.d.ts.map +1 -0
- package/build-types/components/widget-header/index.d.ts +3 -0
- package/build-types/components/widget-header/index.d.ts.map +1 -0
- package/build-types/components/widget-header/widget-header-infotip.d.ts +20 -0
- package/build-types/components/widget-header/widget-header-infotip.d.ts.map +1 -0
- package/build-types/components/widget-header/widget-header.d.ts +38 -0
- package/build-types/components/widget-header/widget-header.d.ts.map +1 -0
- package/build-types/components/widget-layout-controls/index.d.ts +3 -0
- package/build-types/components/widget-layout-controls/index.d.ts.map +1 -0
- package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts +14 -0
- package/build-types/components/widget-layout-controls/widget-layout-controls.d.ts.map +1 -0
- package/build-types/components/widget-picker/widget-picker.d.ts +1 -1
- package/build-types/components/widget-picker/widget-picker.d.ts.map +1 -1
- package/build-types/components/widget-preview-chrome/index.d.ts +3 -0
- package/build-types/components/widget-preview-chrome/index.d.ts.map +1 -0
- package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts +15 -0
- package/build-types/components/widget-preview-chrome/widget-preview-chrome.d.ts.map +1 -0
- package/build-types/components/widget-settings/index.d.ts +2 -2
- package/build-types/components/widget-settings/utils/index.d.ts +0 -1
- package/build-types/components/widget-settings/utils/index.d.ts.map +1 -1
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts +7 -5
- package/build-types/components/widget-settings/widget-settings-trigger.d.ts.map +1 -1
- package/build-types/components/widget-settings/widget-settings.d.ts +5 -4
- package/build-types/components/widget-settings/widget-settings.d.ts.map +1 -1
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts +10 -7
- package/build-types/components/widget-toolbar/widget-toolbar.d.ts.map +1 -1
- package/build-types/components/widgets/widgets.d.ts.map +1 -1
- package/build-types/context/dashboard-context.d.ts +23 -40
- package/build-types/context/dashboard-context.d.ts.map +1 -1
- package/build-types/context/ui-context.d.ts +0 -18
- package/build-types/context/ui-context.d.ts.map +1 -1
- package/build-types/context/widget-context.d.ts +1 -1
- package/build-types/context/widget-context.d.ts.map +1 -1
- package/build-types/types.d.ts +9 -15
- package/build-types/types.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +0 -1
- package/build-types/utils/index.d.ts.map +1 -1
- package/build-types/widget-dashboard.d.ts +5 -5
- package/build-types/widget-dashboard.d.ts.map +1 -1
- package/package.json +20 -20
- package/src/components/actions/actions.module.css +7 -7
- package/src/components/actions/actions.tsx +5 -25
- package/src/components/commands/commands.tsx +3 -70
- package/src/components/widget-attribute-controls/index.ts +1 -0
- package/src/components/widget-attribute-controls/widget-attribute-controls.tsx +108 -0
- package/src/components/widget-chrome/widget-chrome.module.css +6 -71
- package/src/components/widget-chrome/widget-chrome.tsx +31 -136
- package/src/components/widget-frame/index.ts +2 -0
- package/src/components/widget-frame/widget-frame.module.css +17 -0
- package/src/components/widget-frame/widget-frame.tsx +138 -0
- package/src/components/widget-header/index.ts +2 -0
- package/src/components/widget-header/widget-header-infotip.tsx +82 -0
- package/src/components/widget-header/widget-header.module.css +59 -0
- package/src/components/widget-header/widget-header.tsx +104 -0
- package/src/components/widget-layout-controls/index.ts +2 -0
- package/src/components/{widgets/widget-layout-toolbar.tsx → widget-layout-controls/widget-layout-controls.tsx} +12 -13
- package/src/components/widget-picker/widget-picker.tsx +5 -10
- package/src/components/widget-preview-chrome/index.ts +2 -0
- package/src/components/widget-preview-chrome/widget-preview-chrome.module.css +22 -0
- package/src/components/widget-preview-chrome/widget-preview-chrome.tsx +65 -0
- package/src/components/widget-settings/index.ts +2 -2
- package/src/components/widget-settings/utils/index.ts +0 -1
- package/src/components/widget-settings/widget-settings-trigger.tsx +39 -44
- package/src/components/widget-settings/widget-settings.tsx +10 -28
- package/src/components/widget-toolbar/widget-toolbar.module.css +13 -10
- package/src/components/widget-toolbar/widget-toolbar.tsx +14 -8
- package/src/components/widgets/widget-resize-handle.module.css +21 -21
- package/src/components/widgets/widget-resize-handle.tsx +2 -2
- package/src/components/widgets/widgets.module.css +20 -11
- package/src/components/widgets/widgets.tsx +33 -10
- package/src/context/dashboard-context.tsx +70 -133
- package/src/context/ui-context.tsx +1 -39
- package/src/test/actions.test.tsx +7 -77
- package/src/test/commands.test.tsx +6 -45
- package/src/test/staging.test.tsx +82 -144
- package/src/test/widget-dashboard.test.tsx +24 -0
- package/src/types.ts +9 -16
- package/src/utils/index.ts +0 -1
- package/src/widget-dashboard.tsx +4 -8
- package/build/components/layout-settings/index.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/index.cjs +0 -186
- package/build/components/layout-settings/layout-model-edit-field/index.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs +0 -53
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-grid.cjs.map +0 -7
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs +0 -53
- package/build/components/layout-settings/layout-model-edit-field/thumbnail-masonry.cjs.map +0 -7
- package/build/components/layout-settings/layout-settings.cjs +0 -207
- package/build/components/layout-settings/layout-settings.cjs.map +0 -7
- package/build/components/widget-settings/utils/get-admin-menu-inset.cjs.map +0 -7
- package/build/components/widget-settings/widget-settings-toolbar.cjs.map +0 -7
- package/build/components/widgets/widget-layout-toolbar.cjs.map +0 -7
- package/build/utils/grid-model-change/grid-model-change.cjs +0 -56
- package/build/utils/grid-model-change/grid-model-change.cjs.map +0 -7
- package/build/utils/grid-model-change/index.cjs.map +0 -7
- package/build/utils/migrate-layout/index.cjs.map +0 -7
- package/build/utils/migrate-layout/migrate-layout.cjs +0 -94
- package/build/utils/migrate-layout/migrate-layout.cjs.map +0 -7
- package/build-module/components/layout-settings/index.mjs +0 -6
- package/build-module/components/layout-settings/index.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs +0 -151
- package/build-module/components/layout-settings/layout-model-edit-field/index.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs +0 -28
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-grid.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs +0 -28
- package/build-module/components/layout-settings/layout-model-edit-field/thumbnail-masonry.mjs.map +0 -7
- package/build-module/components/layout-settings/layout-settings.mjs +0 -187
- package/build-module/components/layout-settings/layout-settings.mjs.map +0 -7
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs +0 -16
- package/build-module/components/widget-settings/utils/get-admin-menu-inset.mjs.map +0 -7
- package/build-module/components/widget-settings/widget-settings-toolbar.mjs.map +0 -7
- package/build-module/components/widgets/widget-layout-toolbar.mjs +0 -181
- package/build-module/components/widgets/widget-layout-toolbar.mjs.map +0 -7
- package/build-module/utils/grid-model-change/grid-model-change.mjs +0 -30
- package/build-module/utils/grid-model-change/grid-model-change.mjs.map +0 -7
- package/build-module/utils/grid-model-change/index.mjs +0 -7
- package/build-module/utils/grid-model-change/index.mjs.map +0 -7
- package/build-module/utils/migrate-layout/index.mjs +0 -6
- package/build-module/utils/migrate-layout/index.mjs.map +0 -7
- package/build-module/utils/migrate-layout/migrate-layout.mjs +0 -69
- package/build-module/utils/migrate-layout/migrate-layout.mjs.map +0 -7
- package/build-types/components/layout-settings/index.d.ts +0 -2
- package/build-types/components/layout-settings/index.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts +0 -17
- package/build-types/components/layout-settings/layout-model-edit-field/index.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts +0 -6
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-grid.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts +0 -6
- package/build-types/components/layout-settings/layout-model-edit-field/thumbnail-masonry.d.ts.map +0 -1
- package/build-types/components/layout-settings/layout-settings.d.ts +0 -14
- package/build-types/components/layout-settings/layout-settings.d.ts.map +0 -1
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts +0 -17
- package/build-types/components/widget-settings/utils/get-admin-menu-inset.d.ts.map +0 -1
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts +0 -20
- package/build-types/components/widget-settings/widget-settings-toolbar.d.ts.map +0 -1
- package/build-types/components/widgets/widget-layout-toolbar.d.ts +0 -14
- package/build-types/components/widgets/widget-layout-toolbar.d.ts.map +0 -1
- package/build-types/utils/grid-model-change/grid-model-change.d.ts +0 -20
- package/build-types/utils/grid-model-change/grid-model-change.d.ts.map +0 -1
- package/build-types/utils/grid-model-change/index.d.ts +0 -2
- package/build-types/utils/grid-model-change/index.d.ts.map +0 -1
- package/build-types/utils/migrate-layout/index.d.ts +0 -2
- package/build-types/utils/migrate-layout/index.d.ts.map +0 -1
- package/build-types/utils/migrate-layout/migrate-layout.d.ts +0 -36
- package/build-types/utils/migrate-layout/migrate-layout.d.ts.map +0 -1
- package/src/components/layout-settings/index.ts +0 -1
- package/src/components/layout-settings/layout-model-edit-field/index.tsx +0 -98
- package/src/components/layout-settings/layout-model-edit-field/style.module.css +0 -34
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-grid.tsx +0 -28
- package/src/components/layout-settings/layout-model-edit-field/thumbnail-masonry.tsx +0 -28
- package/src/components/layout-settings/layout-settings.tsx +0 -217
- package/src/components/widget-picker/widget-picker.module.css +0 -11
- package/src/components/widget-settings/utils/get-admin-menu-inset.ts +0 -30
- package/src/components/widget-settings/widget-settings-toolbar.module.css +0 -25
- package/src/components/widget-settings/widget-settings-toolbar.tsx +0 -45
- package/src/components/widgets/widget-layout-toolbar.module.css +0 -6
- package/src/utils/grid-model-change/grid-model-change.ts +0 -53
- package/src/utils/grid-model-change/index.ts +0 -1
- package/src/utils/migrate-layout/index.ts +0 -1
- package/src/utils/migrate-layout/migrate-layout.ts +0 -156
- package/src/utils/migrate-layout/test/migrate-layout.test.ts +0 -114
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/actions/actions.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/actions/actions.module.css"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { layout as layoutIcon, plus } from '@wordpress/icons';\nimport { store as viewportStore } from '@wordpress/viewport';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { ActionsMenu } from '../actions-menu';\nimport type { ActionsMenuItem } from '../actions-menu';\nimport styles from './actions.module.css';\n\n/**\n * Edit toolbar for the dashboard. In customize mode it surfaces Add widget,\n * Layout settings (when grid settings are editable), Cancel, and Done;\n * otherwise a single Customize button. Buttons and the overflow menu are\n * triggers that flip the shared UI state the overlays react to.\n *\n * Returns `null` when mounted without `onEditChange`, so hosts that don't\n * expose edit mode can keep `Actions` in their tree unconditionally.\n */\nexport function Actions(): React.ReactNode {\n\tconst {\n\t\teditMode,\n\t\tonEditChange,\n\t\tonLayoutReset,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t\tcanEditGridSettings,\n\t} = useDashboardInternalContext();\n\n\tconst [ isEditActionsMounted, setIsEditActionsMounted ] =\n\t\tuseState( editMode );\n\tconst [ isExitingEditActions, setIsExitingEditActions ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( editMode ) {\n\t\t\tsetIsEditActionsMounted( true );\n\t\t\tsetIsExitingEditActions( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isEditActionsMounted ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsExitingEditActions( true );\n\t\tconst exitTimeout = setTimeout( () => {\n\t\t\tsetIsEditActionsMounted( false );\n\t\t\tsetIsExitingEditActions( false );\n\t\t}, 220 );\n\n\t\treturn () => clearTimeout( exitTimeout );\n\t}, [ editMode, isEditActionsMounted ] );\n\n\tconst { setInserterOpen, setLayoutSettingsOpen, setResetDialogOpen } =\n\t\tuseDashboardUIContext();\n\t// @TODO: switch to using Admin UI declaratively for mobile viewport support once available.\n\t// https://github.com/WordPress/gutenberg/issues/77628\n\tconst isMobileViewport = useSelect(\n\t\t( select ) => select( viewportStore ).isViewportMatch( '< small' ),\n\t\t[]\n\t);\n\n\tconst handleEditMode = useCallback( () => {\n\t\tonEditChange?.( ! editMode );\n\t}, [ editMode, onEditChange ] );\n\n\tconst insert = useCallback( () => {\n\t\tsetInserterOpen( true );\n\t}, [ setInserterOpen ] );\n\n\tconst cancel = useCallback( () => {\n\t\tcancelStaging();\n\t}, [ cancelStaging ] );\n\n\tconst done = useCallback( () => {\n\t\tcommit();\n\t}, [ commit ] );\n\n\tconst openLayoutSettings = useCallback( () => {\n\t\tsetLayoutSettingsOpen( true );\n\t}, [ setLayoutSettingsOpen ] );\n\n\tconst menuItems: ActionsMenuItem[] = [\n\t\t{\n\t\t\tlabel: __( 'Reset to default' ),\n\t\t\tonClick: () => setResetDialogOpen( true ),\n\t\t\tdisabled: ! onLayoutReset,\n\t\t},\n\t];\n\n\tif ( ! onEditChange ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\">\n\t\t\t{ isEditActionsMounted ? (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisExitingEditActions\n\t\t\t\t\t\t\t? styles.editActionsExit\n\t\t\t\t\t\t\t: styles.editActionsEnter\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ insert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isMobileViewport && <Button.Icon icon={ plus } /> }\n\t\t\t\t\t\t{ __( 'Add widget' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t{ canEditGridSettings && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\tonClick={ openLayoutSettings }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ ! isMobileViewport && (\n\t\t\t\t\t\t\t\t<Button.Icon icon={ layoutIcon } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ __( 'Layout settings' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ styles.editActionsDivider }\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ done }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Stack>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ handleEditMode }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Customize' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t<ActionsMenu items={ menuItems } />\n\t\t</Stack>\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(\"207feb9ccc\", \"._273463df7651817f__editActionsEnter,._3cd6628039136a20__editActionsExit{align-items:center;display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}._572540719be6c8a3__editActionsDivider{align-self:center;background-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);flex-shrink:0;height:var(--wpds-dimension-size-2xs,16px);width:1px}@media not (prefers-reduced-motion){._273463df7651817f__editActionsEnter,._3cd6628039136a20__editActionsExit{will-change:opacity,transform}._273463df7651817f__editActionsEnter{animation:_332d3153b716aa20__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}._3cd6628039136a20__editActionsExit{animation:_4dff70702a4b0f40__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _332d3153b716aa20__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes _4dff70702a4b0f40__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}\");\n}\nexport default {\"editActionsEnter\":\"_273463df7651817f__editActionsEnter\",\"editActionsExit\":\"_3cd6628039136a20__editActionsExit\",\"editActionsDivider\":\"_572540719be6c8a3__editActionsDivider\",\"actions-slide-in\":\"_332d3153b716aa20__actions-slide-in\",\"actions-fold-out\":\"_4dff70702a4b0f40__actions-fold-out\"};\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,UAAU;AACnB,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus } from '@wordpress/icons';\nimport { store as viewportStore } from '@wordpress/viewport';\n// eslint-disable-next-line @wordpress/use-recommended-components\nimport { Button, Stack } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { ActionsMenu } from '../actions-menu';\nimport type { ActionsMenuItem } from '../actions-menu';\nimport styles from './actions.module.css';\n\n/**\n * Edit toolbar for the dashboard. In customize mode it surfaces Add widget,\n * Layout settings (when grid settings are editable), Cancel, and Done;\n * otherwise a single Customize button. Buttons and the overflow menu are\n * triggers that flip the shared UI state the overlays react to.\n *\n * Returns `null` when mounted without `onEditChange`, so hosts that don't\n * expose edit mode can keep `Actions` in their tree unconditionally.\n */\nexport function Actions(): React.ReactNode {\n\tconst {\n\t\teditMode,\n\t\tonEditChange,\n\t\tonLayoutReset,\n\t\tcommit,\n\t\tcancel: cancelStaging,\n\t\thasUncommittedChanges,\n\t} = useDashboardInternalContext();\n\n\tconst [ isEditActionsMounted, setIsEditActionsMounted ] =\n\t\tuseState( editMode );\n\tconst [ isExitingEditActions, setIsExitingEditActions ] = useState( false );\n\n\tuseEffect( () => {\n\t\tif ( editMode ) {\n\t\t\tsetIsEditActionsMounted( true );\n\t\t\tsetIsExitingEditActions( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! isEditActionsMounted ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsExitingEditActions( true );\n\t\tconst exitTimeout = setTimeout( () => {\n\t\t\tsetIsEditActionsMounted( false );\n\t\t\tsetIsExitingEditActions( false );\n\t\t}, 220 );\n\n\t\treturn () => clearTimeout( exitTimeout );\n\t}, [ editMode, isEditActionsMounted ] );\n\n\tconst { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();\n\t// @TODO: switch to using Admin UI declaratively for mobile viewport support once available.\n\t// https://github.com/WordPress/gutenberg/issues/77628\n\tconst isMobileViewport = useSelect(\n\t\t( select ) => select( viewportStore ).isViewportMatch( '< small' ),\n\t\t[]\n\t);\n\n\tconst handleEditMode = useCallback( () => {\n\t\tonEditChange?.( ! editMode );\n\t}, [ editMode, onEditChange ] );\n\n\tconst insert = useCallback( () => {\n\t\tsetInserterOpen( true );\n\t}, [ setInserterOpen ] );\n\n\tconst cancel = useCallback( () => {\n\t\tcancelStaging();\n\t}, [ cancelStaging ] );\n\n\tconst done = useCallback( () => {\n\t\tcommit();\n\t}, [ commit ] );\n\n\tconst menuItems: ActionsMenuItem[] = [\n\t\t{\n\t\t\tlabel: __( 'Reset to default' ),\n\t\t\tonClick: () => setResetDialogOpen( true ),\n\t\t\tdisabled: ! onLayoutReset,\n\t\t},\n\t];\n\n\tif ( ! onEditChange ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Stack direction=\"row\" gap=\"sm\">\n\t\t\t{ isEditActionsMounted ? (\n\t\t\t\t<Stack\n\t\t\t\t\tdirection=\"row\"\n\t\t\t\t\tgap=\"sm\"\n\t\t\t\t\tclassName={\n\t\t\t\t\t\tisExitingEditActions\n\t\t\t\t\t\t\t? styles[ 'edit-actions-exit' ]\n\t\t\t\t\t\t\t: styles[ 'edit-actions-enter' ]\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ insert }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ! isMobileViewport && <Button.Icon icon={ plus } /> }\n\t\t\t\t\t\t{ __( 'Add widget' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ styles[ 'edit-actions-divider' ] }\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ cancel }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"solid\"\n\t\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tonClick={ done }\n\t\t\t\t\t\tdisabled={ ! hasUncommittedChanges }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Done' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Stack>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"minimal\"\n\t\t\t\t\ttone=\"brand\"\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\tonClick={ handleEditMode }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Customize' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\n\t\t\t<ActionsMenu items={ menuItems } />\n\t\t</Stack>\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(\"fb18de5324\", \"._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{align-items:center;display:inline-flex;gap:var(--wp--preset--spacing--20);transform-origin:right center}._815569a4ac9877f6__edit-actions-divider{align-self:center;background-color:var(--wpds-color-stroke-surface-neutral,#dbdbdb);flex-shrink:0;height:var(--wpds-dimension-size-2xs,16px);width:1px}@media not (prefers-reduced-motion){._4cb74a57d7aea824__edit-actions-enter,._852c67c33a5780a8__edit-actions-exit{will-change:opacity,transform}._4cb74a57d7aea824__edit-actions-enter{animation:_332d3153b716aa20__actions-slide-in var(--wpds-motion-duration-md,.2s) var(--wpds-motion-easing-expressive,cubic-bezier(.25,0,0,1)) forwards}._852c67c33a5780a8__edit-actions-exit{animation:_4dff70702a4b0f40__actions-fold-out var(--wpds-motion-duration-sm,.1s) var(--wpds-motion-easing-balanced,cubic-bezier(.4,0,.2,1)) forwards}@keyframes _332d3153b716aa20__actions-slide-in{0%{opacity:0;transform:translateX(12px) scaleX(.92)}to{opacity:1;transform:translateX(0) scaleX(1)}}@keyframes _4dff70702a4b0f40__actions-fold-out{0%{opacity:1;transform:translateX(0) scaleX(1)}to{opacity:0;transform:translateX(12px) scaleX(.92)}}}\");\n}\nexport default {\"edit-actions-enter\":\"_4cb74a57d7aea824__edit-actions-enter\",\"edit-actions-exit\":\"_852c67c33a5780a8__edit-actions-exit\",\"edit-actions-divider\":\"_815569a4ac9877f6__edit-actions-divider\",\"actions-slide-in\":\"_332d3153b716aa20__actions-slide-in\",\"actions-fold-out\":\"_4dff70702a4b0f40__actions-fold-out\"};\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,aAAa,WAAW,gBAAgB;AACjD,SAAS,UAAU;AACnB,SAAS,YAAY;AACrB,SAAS,SAAS,qBAAqB;AAEvC,SAAS,QAAQ,aAAa;AAK9B,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;;;ACN5B,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;AA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IACD,IAEA;AAAA,MAAC;AAAA;AAAA,QACA,SAAQ;AAAA,QACR,MAAK;AAAA,QACL,MAAK;AAAA,QACL,SAAU;AAAA,QAER,aAAI,WAAY;AAAA;AAAA,IACnB;AAAA,IAGD,oBAAC,eAAY,OAAQ,WAAY;AAAA,KAClC;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,52 +5,21 @@ import {
|
|
|
5
5
|
useCommands,
|
|
6
6
|
privateApis as commandsPrivateApis
|
|
7
7
|
} from "@wordpress/commands";
|
|
8
|
-
import {
|
|
9
|
-
columns,
|
|
10
|
-
grid,
|
|
11
|
-
layout as layoutIcon,
|
|
12
|
-
plus,
|
|
13
|
-
trash
|
|
14
|
-
} from "@wordpress/icons";
|
|
8
|
+
import { layout as layoutIcon, plus, trash } from "@wordpress/icons";
|
|
15
9
|
import { unlock } from "../../lock-unlock.mjs";
|
|
16
10
|
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
17
11
|
import { useDashboardUIContext } from "../../context/ui-context.mjs";
|
|
18
|
-
import { getGridModel } from "../../utils/grid-model-change/index.mjs";
|
|
19
12
|
import { usePendingWhenEditMode } from "./use-pending-when-edit-mode.mjs";
|
|
20
13
|
var { useCommandContext } = unlock(commandsPrivateApis);
|
|
21
14
|
var DASHBOARD_COMMAND_CONTEXT = "dashboard";
|
|
22
15
|
function Commands() {
|
|
23
|
-
const {
|
|
24
|
-
editMode,
|
|
25
|
-
onEditChange,
|
|
26
|
-
onLayoutReset,
|
|
27
|
-
gridSettings,
|
|
28
|
-
canEditGridSettings,
|
|
29
|
-
commitGridModelChange
|
|
30
|
-
} = useDashboardInternalContext();
|
|
16
|
+
const { editMode, onEditChange, onLayoutReset } = useDashboardInternalContext();
|
|
31
17
|
const { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();
|
|
32
18
|
useCommandContext(DASHBOARD_COMMAND_CONTEXT);
|
|
33
19
|
const runWhenInEditMode = usePendingWhenEditMode({
|
|
34
20
|
editMode,
|
|
35
21
|
onEditChange
|
|
36
22
|
});
|
|
37
|
-
const gridModel = getGridModel(gridSettings);
|
|
38
|
-
const isGridLayout = gridModel === "grid";
|
|
39
|
-
const isMasonryLayout = gridModel === "masonry";
|
|
40
|
-
const switchToMasonry = useCallback(
|
|
41
|
-
({ close }) => {
|
|
42
|
-
close();
|
|
43
|
-
commitGridModelChange("masonry");
|
|
44
|
-
},
|
|
45
|
-
[commitGridModelChange]
|
|
46
|
-
);
|
|
47
|
-
const switchToGrid = useCallback(
|
|
48
|
-
({ close }) => {
|
|
49
|
-
close();
|
|
50
|
-
commitGridModelChange("grid");
|
|
51
|
-
},
|
|
52
|
-
[commitGridModelChange]
|
|
53
|
-
);
|
|
54
23
|
const resetToDefault = useCallback(
|
|
55
24
|
({ close }) => {
|
|
56
25
|
close();
|
|
@@ -96,35 +65,6 @@ function Commands() {
|
|
|
96
65
|
disabled: !onEditChange,
|
|
97
66
|
callback: addWidgets
|
|
98
67
|
},
|
|
99
|
-
{
|
|
100
|
-
name: "core/dashboard/switch-to-masonry-layout",
|
|
101
|
-
label: __("Switch dashboard to masonry layout"),
|
|
102
|
-
icon: columns,
|
|
103
|
-
category: "command",
|
|
104
|
-
context: DASHBOARD_COMMAND_CONTEXT,
|
|
105
|
-
keywords: [
|
|
106
|
-
__("layout"),
|
|
107
|
-
__("layout model"),
|
|
108
|
-
__("masonry")
|
|
109
|
-
],
|
|
110
|
-
disabled: !canEditGridSettings || isMasonryLayout || editMode,
|
|
111
|
-
callback: switchToMasonry
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: "core/dashboard/switch-to-grid-layout",
|
|
115
|
-
label: __("Switch dashboard to grid layout"),
|
|
116
|
-
icon: grid,
|
|
117
|
-
category: "command",
|
|
118
|
-
context: DASHBOARD_COMMAND_CONTEXT,
|
|
119
|
-
keywords: [
|
|
120
|
-
__("layout"),
|
|
121
|
-
__("layout model"),
|
|
122
|
-
__("grid"),
|
|
123
|
-
__("standard grid")
|
|
124
|
-
],
|
|
125
|
-
disabled: !canEditGridSettings || isGridLayout || editMode,
|
|
126
|
-
callback: switchToGrid
|
|
127
|
-
},
|
|
128
68
|
{
|
|
129
69
|
name: "core/dashboard/reset-to-default",
|
|
130
70
|
label: __("Reset dashboard widgets to default"),
|
|
@@ -141,11 +81,6 @@ function Commands() {
|
|
|
141
81
|
editMode,
|
|
142
82
|
customize,
|
|
143
83
|
addWidgets,
|
|
144
|
-
canEditGridSettings,
|
|
145
|
-
isMasonryLayout,
|
|
146
|
-
isGridLayout,
|
|
147
|
-
switchToMasonry,
|
|
148
|
-
switchToGrid,
|
|
149
84
|
onLayoutReset,
|
|
150
85
|
resetToDefault
|
|
151
86
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/commands/commands.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseCommands,\n\tprivateApis as commandsPrivateApis,\n} from '@wordpress/commands';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,aAAa,eAAe;AACrC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AACP
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseCommands,\n\tprivateApis as commandsPrivateApis,\n} from '@wordpress/commands';\nimport { layout as layoutIcon, plus, trash } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { useDashboardUIContext } from '../../context/ui-context';\nimport { usePendingWhenEditMode } from './use-pending-when-edit-mode';\n\nconst { useCommandContext } = unlock( commandsPrivateApis );\n\nexport const DASHBOARD_COMMAND_CONTEXT = 'dashboard';\n\ntype CommandCallback = ( options: { close: () => void } ) => void;\n\n/**\n * Registers dashboard-specific command palette commands and sets the\n * active command context so they surface under Suggestions by default.\n */\nexport function Commands() {\n\tconst { editMode, onEditChange, onLayoutReset } =\n\t\tuseDashboardInternalContext();\n\n\tconst { setInserterOpen, setResetDialogOpen } = useDashboardUIContext();\n\n\tuseCommandContext( DASHBOARD_COMMAND_CONTEXT );\n\n\tconst runWhenInEditMode = usePendingWhenEditMode( {\n\t\teditMode,\n\t\tonEditChange,\n\t} );\n\n\tconst resetToDefault = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\tsetResetDialogOpen( true );\n\t\t},\n\t\t[ setResetDialogOpen ]\n\t);\n\n\tconst addWidgets = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\trunWhenInEditMode( () => {\n\t\t\t\tsetInserterOpen( true );\n\t\t\t} );\n\t\t},\n\t\t[ runWhenInEditMode, setInserterOpen ]\n\t);\n\n\tconst customize = useCallback< CommandCallback >(\n\t\t( { close } ) => {\n\t\t\tclose();\n\t\t\tonEditChange?.( true );\n\t\t},\n\t\t[ onEditChange ]\n\t);\n\n\tconst commands = useMemo(\n\t\t() => [\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/customize',\n\t\t\t\tlabel: __( 'Customize dashboard' ),\n\t\t\t\ticon: layoutIcon,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'edit' ), __( 'widgets' ), __( 'layout' ) ],\n\t\t\t\tdisabled: ! onEditChange || editMode,\n\t\t\t\tcallback: customize,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/add-widgets',\n\t\t\t\tlabel: __( 'Add dashboard widgets' ),\n\t\t\t\ticon: plus,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'widgets' ), __( 'inserter' ) ],\n\t\t\t\tdisabled: ! onEditChange,\n\t\t\t\tcallback: addWidgets,\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/dashboard/reset-to-default',\n\t\t\t\tlabel: __( 'Reset dashboard widgets to default' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcategory: 'command',\n\t\t\t\tcontext: DASHBOARD_COMMAND_CONTEXT,\n\t\t\t\tkeywords: [ __( 'reset' ), __( 'default' ) ],\n\t\t\t\tdisabled: ! onLayoutReset,\n\t\t\t\tcallback: resetToDefault,\n\t\t\t},\n\t\t],\n\t\t[\n\t\t\tonEditChange,\n\t\t\teditMode,\n\t\t\tcustomize,\n\t\t\taddWidgets,\n\t\t\tonLayoutReset,\n\t\t\tresetToDefault,\n\t\t]\n\t);\n\n\tuseCommands( commands );\n\n\treturn null;\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,aAAa,eAAe;AACrC,SAAS,UAAU;AACnB;AAAA,EACC;AAAA,EACA,eAAe;AAAA,OACT;AACP,SAAS,UAAU,YAAY,MAAM,aAAa;AAKlD,SAAS,cAAc;AACvB,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AAEvC,IAAM,EAAE,kBAAkB,IAAI,OAAQ,mBAAoB;AAEnD,IAAM,4BAA4B;AAQlC,SAAS,WAAW;AAC1B,QAAM,EAAE,UAAU,cAAc,cAAc,IAC7C,4BAA4B;AAE7B,QAAM,EAAE,iBAAiB,mBAAmB,IAAI,sBAAsB;AAEtE,oBAAmB,yBAA0B;AAE7C,QAAM,oBAAoB,uBAAwB;AAAA,IACjD;AAAA,IACA;AAAA,EACD,CAAE;AAEF,QAAM,iBAAiB;AAAA,IACtB,CAAE,EAAE,MAAM,MAAO;AAChB,YAAM;AACN,yBAAoB,IAAK;AAAA,IAC1B;AAAA,IACA,CAAE,kBAAmB;AAAA,EACtB;AAEA,QAAM,aAAa;AAAA,IAClB,C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+
// packages/widget-dashboard/src/components/widget-attribute-controls/widget-attribute-controls.tsx
|
|
2
|
+
import { DataForm } from "@wordpress/dataviews";
|
|
3
|
+
import { useCallback, useMemo } from "@wordpress/element";
|
|
4
|
+
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
5
|
+
import { WidgetSettingsTrigger } from "../widget-settings/index.mjs";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
function WidgetAttributeControls({
|
|
8
|
+
widget,
|
|
9
|
+
widgetType
|
|
10
|
+
}) {
|
|
11
|
+
const { layout, onLayoutChange, scheduleAutoSave } = useDashboardInternalContext();
|
|
12
|
+
const fields = useMemo(
|
|
13
|
+
() => (widgetType.attributes ?? []).filter(
|
|
14
|
+
(attribute) => attribute.relevance === "high"
|
|
15
|
+
),
|
|
16
|
+
[widgetType.attributes]
|
|
17
|
+
);
|
|
18
|
+
const form = useMemo(
|
|
19
|
+
() => ({
|
|
20
|
+
layout: { type: "row", alignment: "center" },
|
|
21
|
+
fields: fields.map((field) => ({
|
|
22
|
+
id: field.id,
|
|
23
|
+
layout: { type: "regular", labelPosition: "none" }
|
|
24
|
+
}))
|
|
25
|
+
}),
|
|
26
|
+
[fields]
|
|
27
|
+
);
|
|
28
|
+
const handleChange = useCallback(
|
|
29
|
+
(edits) => {
|
|
30
|
+
onLayoutChange(
|
|
31
|
+
layout.map(
|
|
32
|
+
(instance) => instance.uuid === widget.uuid ? {
|
|
33
|
+
...instance,
|
|
34
|
+
attributes: {
|
|
35
|
+
...instance.attributes,
|
|
36
|
+
...edits
|
|
37
|
+
}
|
|
38
|
+
} : instance
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
scheduleAutoSave();
|
|
42
|
+
},
|
|
43
|
+
[layout, onLayoutChange, widget.uuid, scheduleAutoSave]
|
|
44
|
+
);
|
|
45
|
+
const data = widget.attributes ?? widgetType.example?.attributes ?? {};
|
|
46
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
fields.length > 0 && /* @__PURE__ */ jsx(
|
|
48
|
+
DataForm,
|
|
49
|
+
{
|
|
50
|
+
data,
|
|
51
|
+
fields,
|
|
52
|
+
form,
|
|
53
|
+
onChange: handleChange
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ jsx(
|
|
57
|
+
WidgetSettingsTrigger,
|
|
58
|
+
{
|
|
59
|
+
widget,
|
|
60
|
+
widgetType
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
WidgetAttributeControls
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=widget-attribute-controls.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-attribute-controls/widget-attribute-controls.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { DataForm } from '@wordpress/dataviews';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport type { WidgetType } from '@wordpress/widget-primitives';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { WidgetSettingsTrigger } from '../widget-settings';\nimport type { DashboardWidget } from '../../types';\n\ntype WidgetAttributes = Record< string, unknown >;\n\ntype WidgetAttributeControlsProps = {\n\t/**\n\t * The instance whose attributes these controls edit.\n\t */\n\twidget: DashboardWidget< unknown >;\n\n\t/**\n\t * The instance's widget type, source of the attribute schema.\n\t */\n\twidgetType: WidgetType;\n};\n\n/**\n * Normal-mode controls: the `relevance: 'high'` attributes on a prominent\n * surface, plus a settings entry point when needed. Inline controls appear\n * only for the high-relevance fields; edits stage live and auto-save on the\n * dashboard's shared debounce.\n *\n * @param {WidgetAttributeControlsProps} props Component props.\n */\nexport function WidgetAttributeControls( {\n\twidget,\n\twidgetType,\n}: WidgetAttributeControlsProps ): React.ReactNode {\n\tconst { layout, onLayoutChange, scheduleAutoSave } =\n\t\tuseDashboardInternalContext();\n\n\tconst fields = useMemo< Field< WidgetAttributes >[] >(\n\t\t() =>\n\t\t\t( widgetType.attributes ?? [] ).filter(\n\t\t\t\t( attribute ) => attribute.relevance === 'high'\n\t\t\t) as Field< WidgetAttributes >[],\n\t\t[ widgetType.attributes ]\n\t);\n\n\t// A `row` top-level layout lays the controls out horizontally; each field\n\t// carries `labelPosition: 'none'` so the control renders bare.\n\tconst form = useMemo< Form >(\n\t\t() => ( {\n\t\t\tlayout: { type: 'row', alignment: 'center' },\n\t\t\tfields: fields.map( ( field ) => ( {\n\t\t\t\tid: field.id,\n\t\t\t\tlayout: { type: 'regular', labelPosition: 'none' },\n\t\t\t} ) ),\n\t\t} ),\n\t\t[ fields ]\n\t);\n\n\tconst handleChange = useCallback(\n\t\t( edits: Record< string, unknown > ) => {\n\t\t\tonLayoutChange(\n\t\t\t\tlayout.map( ( instance ) =>\n\t\t\t\t\tinstance.uuid === widget.uuid\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...instance,\n\t\t\t\t\t\t\t\tattributes: {\n\t\t\t\t\t\t\t\t\t...( instance.attributes as object ),\n\t\t\t\t\t\t\t\t\t...edits,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: instance\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tscheduleAutoSave();\n\t\t},\n\t\t[ layout, onLayoutChange, widget.uuid, scheduleAutoSave ]\n\t);\n\n\tconst data = ( widget.attributes ??\n\t\twidgetType.example?.attributes ??\n\t\t{} ) as WidgetAttributes;\n\n\treturn (\n\t\t<>\n\t\t\t{ fields.length > 0 && (\n\t\t\t\t<DataForm< WidgetAttributes >\n\t\t\t\t\tdata={ data }\n\t\t\t\t\tfields={ fields }\n\t\t\t\t\tform={ form }\n\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t/>\n\t\t\t) }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;AAAA,QACA;AAAA,QACA,UAAW;AAAA;AAAA,IACZ;AAAA,IAGD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.tsx
|
|
2
2
|
import clsx from "clsx";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
Component,
|
|
6
|
-
Suspense,
|
|
7
|
-
forwardRef,
|
|
8
|
-
useId,
|
|
9
|
-
useMemo
|
|
10
|
-
} from "@wordpress/element";
|
|
3
|
+
import { forwardRef, useId, useMemo } from "@wordpress/element";
|
|
11
4
|
import { __ } from "@wordpress/i18n";
|
|
12
5
|
import { plugins } from "@wordpress/icons";
|
|
13
|
-
import { Card, Icon, Stack,
|
|
6
|
+
import { Card, Icon, Stack, Text } from "@wordpress/ui";
|
|
14
7
|
import { useDashboardInternalContext } from "../../context/dashboard-context.mjs";
|
|
15
8
|
import { WidgetContextProvider } from "../../context/widget-context.mjs";
|
|
16
|
-
import {
|
|
9
|
+
import { LoadingOverlay, WidgetFrame } from "../widget-frame/index.mjs";
|
|
17
10
|
|
|
18
11
|
// packages/style-runtime/src/index.ts
|
|
19
12
|
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
@@ -99,38 +92,23 @@ function registerStyle(hash, css) {
|
|
|
99
92
|
|
|
100
93
|
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.module.css
|
|
101
94
|
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
102
|
-
registerStyle("
|
|
95
|
+
registerStyle("9c052414dc", ".c10bdb70b86e7888__widget-chrome:has(: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:var(--wp-widget-dashboard-tile-focus-offset,2px)}._05be5860e5abb8bb__widget-chrome-header-icon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}.a7e5c80edbcdf3f5__widget-chrome-content{flex:1;height:100%;min-height:0;min-width:0}._9b694d63bdec1a98__unavailable{height:100%}");
|
|
103
96
|
}
|
|
104
|
-
var widget_chrome_default = { "
|
|
97
|
+
var widget_chrome_default = { "widget-chrome": "c10bdb70b86e7888__widget-chrome", "widget-chrome-header-icon": "_05be5860e5abb8bb__widget-chrome-header-icon", "widget-chrome-content": "a7e5c80edbcdf3f5__widget-chrome-content", "unavailable": "_9b694d63bdec1a98__unavailable" };
|
|
105
98
|
|
|
106
99
|
// packages/widget-dashboard/src/components/widget-chrome/widget-chrome.tsx
|
|
107
100
|
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
101
|
function UnavailableWidget({ widgetTypeName }) {
|
|
124
102
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
125
103
|
/* @__PURE__ */ jsx(Card.Header, { children: /* @__PURE__ */ jsx(
|
|
126
104
|
"span",
|
|
127
105
|
{
|
|
128
|
-
className: widget_chrome_default
|
|
106
|
+
className: widget_chrome_default["widget-chrome-header-icon"],
|
|
129
107
|
"aria-hidden": "true",
|
|
130
108
|
children: /* @__PURE__ */ jsx(Icon, { icon: plugins })
|
|
131
109
|
}
|
|
132
110
|
) }),
|
|
133
|
-
/* @__PURE__ */ jsx(Card.Content, { className: widget_chrome_default
|
|
111
|
+
/* @__PURE__ */ jsx(Card.Content, { className: widget_chrome_default["widget-chrome-content"], children: /* @__PURE__ */ jsxs(
|
|
134
112
|
Stack,
|
|
135
113
|
{
|
|
136
114
|
direction: "column",
|
|
@@ -146,24 +124,8 @@ function UnavailableWidget({ widgetTypeName }) {
|
|
|
146
124
|
) })
|
|
147
125
|
] });
|
|
148
126
|
}
|
|
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("h2", {}), children: widgetType.title })
|
|
163
|
-
] }) });
|
|
164
|
-
}
|
|
165
127
|
var WidgetChrome = forwardRef(
|
|
166
|
-
function WidgetChrome2({ widget, index, className }, ref) {
|
|
128
|
+
function WidgetChrome2({ widget, index, className, headerToolbar }, ref) {
|
|
167
129
|
const { widgetTypes, isResolvingWidgetTypes, editMode } = useDashboardInternalContext();
|
|
168
130
|
const widgetType = widgetTypes.find((t) => t.name === widget.type);
|
|
169
131
|
const titleId = useId();
|
|
@@ -182,13 +144,16 @@ var WidgetChrome = forwardRef(
|
|
|
182
144
|
{
|
|
183
145
|
render: /* @__PURE__ */ jsx("section", {}),
|
|
184
146
|
ref,
|
|
185
|
-
className: clsx(
|
|
147
|
+
className: clsx(
|
|
148
|
+
widget_chrome_default["widget-chrome"],
|
|
149
|
+
className
|
|
150
|
+
),
|
|
186
151
|
"aria-busy": "true",
|
|
187
152
|
"aria-label": __("Loading"),
|
|
188
153
|
children: /* @__PURE__ */ jsx(
|
|
189
154
|
Card.Content,
|
|
190
155
|
{
|
|
191
|
-
className: widget_chrome_default
|
|
156
|
+
className: widget_chrome_default["widget-chrome-content"],
|
|
192
157
|
children: /* @__PURE__ */ jsx(LoadingOverlay, {})
|
|
193
158
|
}
|
|
194
159
|
)
|
|
@@ -200,44 +165,32 @@ var WidgetChrome = forwardRef(
|
|
|
200
165
|
{
|
|
201
166
|
render: /* @__PURE__ */ jsx("section", {}),
|
|
202
167
|
ref,
|
|
203
|
-
className: clsx(
|
|
168
|
+
className: clsx(
|
|
169
|
+
widget_chrome_default["widget-chrome"],
|
|
170
|
+
className
|
|
171
|
+
),
|
|
204
172
|
"aria-label": __("Missing widget"),
|
|
205
173
|
children: /* @__PURE__ */ jsx(UnavailableWidget, { widgetTypeName: widget.type })
|
|
206
174
|
}
|
|
207
175
|
) });
|
|
208
176
|
}
|
|
209
|
-
|
|
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(
|
|
177
|
+
return /* @__PURE__ */ jsx(WidgetContextProvider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
215
178
|
Card.Root,
|
|
216
179
|
{
|
|
217
180
|
render: /* @__PURE__ */ jsx("section", {}),
|
|
218
181
|
ref,
|
|
219
|
-
className: clsx(widget_chrome_default
|
|
182
|
+
className: clsx(widget_chrome_default["widget-chrome"], className),
|
|
220
183
|
"aria-labelledby": widgetType.title ? titleId : void 0,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
]
|
|
184
|
+
children: /* @__PURE__ */ jsx(
|
|
185
|
+
WidgetFrame,
|
|
186
|
+
{
|
|
187
|
+
widget,
|
|
188
|
+
widgetType,
|
|
189
|
+
titleId,
|
|
190
|
+
editMode,
|
|
191
|
+
headerToolbar
|
|
192
|
+
}
|
|
193
|
+
)
|
|
241
194
|
}
|
|
242
195
|
) });
|
|
243
196
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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={ <h2 /> }>\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,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\nimport type { ReactNode } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef, useId, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plugins } from '@wordpress/icons';\nimport { Card, Icon, Stack, Text } from '@wordpress/ui';\n\n/**\n * Internal dependencies\n */\nimport { useDashboardInternalContext } from '../../context/dashboard-context';\nimport { WidgetContextProvider } from '../../context/widget-context';\nimport { LoadingOverlay, WidgetFrame } from '../widget-frame';\nimport styles from './widget-chrome.module.css';\nimport type { DashboardWidget } from '../../types';\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[ 'widget-chrome-header-icon' ] }\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[ 'widget-chrome-content' ] }>\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\nexport interface WidgetChromeProps {\n\twidget: DashboardWidget< unknown >;\n\tindex: number;\n\t/**\n\t * Lifted by `@wordpress/grid` into a sibling slot outside `Card.Root`,\n\t * for full-bleed widgets with no in-card header to host the toolbar.\n\t */\n\tactionableArea?: ReactNode;\n\t/**\n\t * Toolbar rendered in the in-card header (framed and content-bleed).\n\t */\n\theaderToolbar?: ReactNode;\n\tclassName?: string;\n}\n\n/**\n * Dashboard chrome: wraps `WidgetFrame` in the grid tile's `Card.Root`, owning\n * the missing and resolving states.\n */\nexport const WidgetChrome = forwardRef< HTMLDivElement, WidgetChromeProps >(\n\tfunction WidgetChrome( { widget, index, className, headerToolbar }, 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(\n\t\t\t\t\t\t\t\tstyles[ 'widget-chrome' ],\n\t\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t\t) }\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[ 'widget-chrome-content' ] }\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(\n\t\t\t\t\t\t\tstyles[ 'widget-chrome' ],\n\t\t\t\t\t\t\tclassName\n\t\t\t\t\t\t) }\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\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[ 'widget-chrome' ], className ) }\n\t\t\t\t\taria-labelledby={ widgetType.title ? titleId : undefined }\n\t\t\t\t>\n\t\t\t\t\t<WidgetFrame\n\t\t\t\t\t\twidget={ widget }\n\t\t\t\t\t\twidgetType={ widgetType }\n\t\t\t\t\t\ttitleId={ titleId }\n\t\t\t\t\t\teditMode={ editMode }\n\t\t\t\t\t\theaderToolbar={ headerToolbar }\n\t\t\t\t\t/>\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(\"9c052414dc\", \".c10bdb70b86e7888__widget-chrome:has(: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:var(--wp-widget-dashboard-tile-focus-offset,2px)}._05be5860e5abb8bb__widget-chrome-header-icon{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:inline-flex}.a7e5c80edbcdf3f5__widget-chrome-content{flex:1;height:100%;min-height:0;min-width:0}._9b694d63bdec1a98__unavailable{height:100%}\");\n}\nexport default {\"widget-chrome\":\"c10bdb70b86e7888__widget-chrome\",\"widget-chrome-header-icon\":\"_05be5860e5abb8bb__widget-chrome-header-icon\",\"widget-chrome-content\":\"a7e5c80edbcdf3f5__widget-chrome-content\",\"unavailable\":\"_9b694d63bdec1a98__unavailable\"};\n"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAMjB,SAAS,YAAY,OAAO,eAAe;AAC3C,SAAS,UAAU;AACnB,SAAS,eAAe;AACxB,SAAS,MAAM,MAAM,OAAO,YAAY;AAKxC,SAAS,mCAAmC;AAC5C,SAAS,6BAA6B;AACtC,SAAS,gBAAgB,mBAAmB;;;ACT5C,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;AAC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AAa,GAAI,SAAU;AAAA,YAE3B;AAAA,cAAC,KAAK;AAAA,cAAL;AAAA,gBACA,WAAY,sBAAQ,uBAAwB;AAAA,gBAE5C,8BAAC,kBAAe;AAAA;AAAA,YACjB;AAAA;AAAA,QACD,GACD;AAAA,MAEF;AAEA,aACC,oBAAC,yBAAsB,OAAQ,cAC9B;AAAA,QAAC,KAAK;AAAA,QAAL;AAAA,UACA,QAAS,oBAAC,aAAQ;AAAA,UAClB;AAAA,UACA,WAAY;AAAA,YACX,sBAAQ,eAAgB;AAAA,YACxB;AAAA,UACD;AAAA,UACA,cAAa,GAAI,gBAAiB;AAAA,UAElC,8BAAC,qBAAkB,gBAAiB,OAAO,MAAO;AAAA;AAAA,MACnD,GACD;AAAA,IAEF;AAEA,WACC,oBAAC,yBAAsB,OAAQ,cAC9B;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QACA,QAAS,oBAAC,aAAQ;AAAA,QAClB;AAAA,QACA,WAAY,KAAM,sBAAQ,eAAgB,GAAG,SAAU;AAAA,QACvD,mBAAkB,WAAW,QAAQ,UAAU;AAAA,QAE/C;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA,IACD,GACD;AAAA,EAEF;AACD;",
|
|
6
6
|
"names": ["WidgetChrome"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/widget-frame/index.ts"],
|
|
4
|
+
"sourcesContent": ["export { WidgetFrame, LoadingOverlay } from './widget-frame';\nexport type { WidgetFrameProps } from './widget-frame';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|