@wordpress/boot 0.25.0 → 0.26.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/build-module/components/app/index.mjs +29 -53
- package/build-module/components/app/index.mjs.map +1 -7
- package/build-module/components/app/router.mjs +238 -214
- package/build-module/components/app/router.mjs.map +1 -7
- package/build-module/components/app/use-route-title.mjs +35 -42
- package/build-module/components/app/use-route-title.mjs.map +1 -7
- package/build-module/components/canvas/back-button.mjs +21 -20
- package/build-module/components/canvas/back-button.mjs.map +1 -7
- package/build-module/components/canvas/index.mjs +104 -130
- package/build-module/components/canvas/index.mjs.map +1 -7
- package/build-module/components/canvas/site-preview.mjs +36 -43
- package/build-module/components/canvas/site-preview.mjs.map +1 -7
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
- package/build-module/components/canvas/viewport.mjs +25 -13
- package/build-module/components/canvas/viewport.mjs.map +1 -7
- package/build-module/components/canvas-renderer/index.mjs +40 -32
- package/build-module/components/canvas-renderer/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +160 -108
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
- package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
- package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/index.mjs +55 -90
- package/build-module/components/navigation/index.mjs.map +1 -7
- package/build-module/components/navigation/items.mjs +51 -53
- package/build-module/components/navigation/items.mjs.map +1 -7
- package/build-module/components/navigation/navigation-item/index.mjs +120 -114
- package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
- package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
- package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
- package/build-module/components/navigation/path-matching.mjs +74 -73
- package/build-module/components/navigation/path-matching.mjs.map +1 -7
- package/build-module/components/navigation/router-link-item.mjs +13 -11
- package/build-module/components/navigation/router-link-item.mjs.map +1 -7
- package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
- package/build-module/components/plugin-area/index.mjs +20 -24
- package/build-module/components/plugin-area/index.mjs.map +1 -7
- package/build-module/components/root/index.mjs +227 -242
- package/build-module/components/root/index.mjs.map +1 -7
- package/build-module/components/root/single-page.mjs +174 -148
- package/build-module/components/root/single-page.mjs.map +1 -7
- package/build-module/components/root/use-sync-body-background.mjs +28 -22
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +170 -214
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/save-panel/index.mjs +110 -106
- package/build-module/components/save-panel/index.mjs.map +1 -7
- package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +126 -104
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/index.mjs +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +34 -31
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +9 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +48 -55
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +21 -16
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/types.mjs +0 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/error-boundary/index.tsx +50 -4
- package/build-module/index.mjs.map +0 -7
- package/build-module/store/types.mjs.map +0 -7
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
// packages/boot/src/store/selectors.ts
|
|
2
2
|
function getMenuItems(state) {
|
|
3
|
-
|
|
3
|
+
return Object.values(state.menuItems);
|
|
4
4
|
}
|
|
5
5
|
function getRoutes(state) {
|
|
6
|
-
|
|
6
|
+
return state.routes;
|
|
7
7
|
}
|
|
8
8
|
function getDashboardLink(state) {
|
|
9
|
-
|
|
9
|
+
return state.dashboardLink;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns the path an entity is edited or listed at.
|
|
13
|
+
*
|
|
14
|
+
* Falls back to the links registered for `default`, so a post type with no
|
|
15
|
+
* entry of its own still resolves.
|
|
16
|
+
*
|
|
17
|
+
* @param state Store state.
|
|
18
|
+
* @param postType Post type to resolve for.
|
|
19
|
+
* @param postId Entity to edit. Omit for the list of the post type.
|
|
20
|
+
* @return The path, or undefined when nothing is registered for it.
|
|
21
|
+
*/
|
|
11
22
|
function getEntityLink(state, postType, postId) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
return path.replace("{type}", encodeURIComponent(postType)).replace("{id}", encodeURIComponent(postId ?? ""));
|
|
23
|
+
const links = state.entityLinks[postType] ?? state.entityLinks.default;
|
|
24
|
+
const path = postId === void 0 ? links?.list : links?.edit;
|
|
25
|
+
if (!path) return;
|
|
26
|
+
return path.replace("{type}", encodeURIComponent(postType)).replace("{id}", encodeURIComponent(postId ?? ""));
|
|
18
27
|
}
|
|
19
|
-
export {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
getMenuItems,
|
|
23
|
-
getRoutes
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=selectors.mjs.map
|
|
28
|
+
export { getDashboardLink, getEntityLink, getMenuItems, getRoutes };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=selectors.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/store/selectors.ts"],
|
|
4
|
-
"sourcesContent": ["import type { State } from './types';\n\nexport function getMenuItems( state: State ) {\n\treturn Object.values( state.menuItems );\n}\n\nexport function getRoutes( state: State ) {\n\treturn state.routes;\n}\n\nexport function getDashboardLink( state: State ) {\n\treturn state.dashboardLink;\n}\n\n/**\n * Returns the path an entity is edited or listed at.\n *\n * Falls back to the links registered for `default`, so a post type with no\n * entry of its own still resolves.\n *\n * @param state Store state.\n * @param postType Post type to resolve for.\n * @param postId Entity to edit. Omit for the list of the post type.\n * @return The path, or undefined when nothing is registered for it.\n */\nexport function getEntityLink(\n\tstate: State,\n\tpostType: string,\n\tpostId?: string | number\n) {\n\tconst links = state.entityLinks[ postType ] ?? state.entityLinks.default;\n\tconst path = postId === undefined ? links?.list : links?.edit;\n\n\tif ( ! path ) {\n\t\treturn undefined;\n\t}\n\n\treturn path\n\t\t.replace( '{type}', encodeURIComponent( postType ) )\n\t\t.replace( '{id}', encodeURIComponent( postId ?? '' ) );\n}\n"],
|
|
5
|
-
"mappings": ";AAEO,SAAS,aAAc,OAAe;AAC5C,SAAO,OAAO,OAAQ,MAAM,SAAU;AACvC;AAEO,SAAS,UAAW,OAAe;AACzC,SAAO,MAAM;AACd;AAEO,SAAS,iBAAkB,OAAe;AAChD,SAAO,MAAM;AACd;AAaO,SAAS,cACf,OACA,UACA,QACC;AACD,QAAM,QAAQ,MAAM,YAAa,QAAS,KAAK,MAAM,YAAY;AACjE,QAAM,OAAO,WAAW,SAAY,OAAO,OAAO,OAAO;AAEzD,MAAK,CAAE,MAAO;AACb,WAAO;AAAA,EACR;AAEA,SAAO,KACL,QAAS,UAAU,mBAAoB,QAAS,CAAE,EAClD,QAAS,QAAQ,mBAAoB,UAAU,EAAG,CAAE;AACvD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"selectors.mjs","names":[],"sources":["../../src/store/selectors.ts"],"sourcesContent":["import type { State } from './types';\n\nexport function getMenuItems( state: State ) {\n\treturn Object.values( state.menuItems );\n}\n\nexport function getRoutes( state: State ) {\n\treturn state.routes;\n}\n\nexport function getDashboardLink( state: State ) {\n\treturn state.dashboardLink;\n}\n\n/**\n * Returns the path an entity is edited or listed at.\n *\n * Falls back to the links registered for `default`, so a post type with no\n * entry of its own still resolves.\n *\n * @param state Store state.\n * @param postType Post type to resolve for.\n * @param postId Entity to edit. Omit for the list of the post type.\n * @return The path, or undefined when nothing is registered for it.\n */\nexport function getEntityLink(\n\tstate: State,\n\tpostType: string,\n\tpostId?: string | number\n) {\n\tconst links = state.entityLinks[ postType ] ?? state.entityLinks.default;\n\tconst path = postId === undefined ? links?.list : links?.edit;\n\n\tif ( ! path ) {\n\t\treturn undefined;\n\t}\n\n\treturn path\n\t\t.replace( '{type}', encodeURIComponent( postType ) )\n\t\t.replace( '{id}', encodeURIComponent( postId ?? '' ) );\n}\n"],"mappings":";AAEA,SAAgB,aAAc,OAAe;CAC5C,OAAO,OAAO,OAAQ,MAAM,SAAU;AACvC;AAEA,SAAgB,UAAW,OAAe;CACzC,OAAO,MAAM;AACd;AAEA,SAAgB,iBAAkB,OAAe;CAChD,OAAO,MAAM;AACd;;;;;;;;;;;;AAaA,SAAgB,cACf,OACA,UACA,QACC;CACD,MAAM,QAAQ,MAAM,YAAa,aAAc,MAAM,YAAY;CACjE,MAAM,OAAO,WAAW,KAAA,IAAY,OAAO,OAAO,OAAO;CAEzD,IAAK,CAAE,MACN;CAGD,OAAO,KACL,QAAS,UAAU,mBAAoB,QAAS,CAAE,CAAC,CACnD,QAAS,QAAQ,mBAAoB,UAAU,EAAG,CAAE;AACvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/error-boundary/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/error-boundary/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAuB,MAAM,oBAAoB,CAAC;AAQpE,UAAU,KAAK;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAyDD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS,CAAE,KAAK,EAAE,KAAK,CAAE;IACnE,YAAa,KAAK,EAAE,KAAK,EAGxB;IAED,MAAM,CAAC,wBAAwB,CAAE,KAAK,EAAE,KAAK,GAAI,KAAK,CAErD;IAED,MAAM,gUAyBL;CACD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/boot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Minimal boot package for WordPress admin pages.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,32 +38,32 @@
|
|
|
38
38
|
"wpScriptModuleExports": "./build-module/index.mjs",
|
|
39
39
|
"types": "build-types",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@wordpress/a11y": "^5.
|
|
42
|
-
"@wordpress/admin-ui": "^3.
|
|
43
|
-
"@wordpress/base-styles": "^
|
|
44
|
-
"@wordpress/components": "^
|
|
45
|
-
"@wordpress/compose": "^9.
|
|
46
|
-
"@wordpress/core-data": "^9.
|
|
47
|
-
"@wordpress/data": "^11.
|
|
48
|
-
"@wordpress/dom": "^5.
|
|
49
|
-
"@wordpress/editor": "^16.
|
|
50
|
-
"@wordpress/element": "^10.
|
|
51
|
-
"@wordpress/html-entities": "^5.
|
|
52
|
-
"@wordpress/i18n": "^7.
|
|
53
|
-
"@wordpress/icons": "^
|
|
54
|
-
"@wordpress/keyboard-shortcuts": "^6.
|
|
55
|
-
"@wordpress/keycodes": "^5.
|
|
56
|
-
"@wordpress/lazy-editor": "^2.
|
|
57
|
-
"@wordpress/notices": "^6.
|
|
58
|
-
"@wordpress/plugins": "^8.
|
|
59
|
-
"@wordpress/primitives": "^5.
|
|
60
|
-
"@wordpress/private-apis": "^3.
|
|
61
|
-
"@wordpress/react-inert-value": "^2.
|
|
62
|
-
"@wordpress/route": "^0.
|
|
63
|
-
"@wordpress/style-runtime": "^0.
|
|
64
|
-
"@wordpress/theme": "^
|
|
65
|
-
"@wordpress/ui": "^0.
|
|
66
|
-
"@wordpress/url": "^5.
|
|
41
|
+
"@wordpress/a11y": "^5.1.0",
|
|
42
|
+
"@wordpress/admin-ui": "^3.1.0",
|
|
43
|
+
"@wordpress/base-styles": "^15.0.0",
|
|
44
|
+
"@wordpress/components": "^44.0.0",
|
|
45
|
+
"@wordpress/compose": "^9.1.0",
|
|
46
|
+
"@wordpress/core-data": "^9.1.0",
|
|
47
|
+
"@wordpress/data": "^11.1.0",
|
|
48
|
+
"@wordpress/dom": "^5.1.0",
|
|
49
|
+
"@wordpress/editor": "^16.1.0",
|
|
50
|
+
"@wordpress/element": "^10.1.0",
|
|
51
|
+
"@wordpress/html-entities": "^5.1.0",
|
|
52
|
+
"@wordpress/i18n": "^7.1.0",
|
|
53
|
+
"@wordpress/icons": "^20.0.0",
|
|
54
|
+
"@wordpress/keyboard-shortcuts": "^6.1.0",
|
|
55
|
+
"@wordpress/keycodes": "^5.1.0",
|
|
56
|
+
"@wordpress/lazy-editor": "^2.1.0",
|
|
57
|
+
"@wordpress/notices": "^6.1.0",
|
|
58
|
+
"@wordpress/plugins": "^8.1.0",
|
|
59
|
+
"@wordpress/primitives": "^5.1.0",
|
|
60
|
+
"@wordpress/private-apis": "^3.1.0",
|
|
61
|
+
"@wordpress/react-inert-value": "^2.1.0",
|
|
62
|
+
"@wordpress/route": "^0.25.0",
|
|
63
|
+
"@wordpress/style-runtime": "^0.15.0",
|
|
64
|
+
"@wordpress/theme": "^4.0.0",
|
|
65
|
+
"@wordpress/ui": "^0.26.0",
|
|
66
|
+
"@wordpress/url": "^5.1.0",
|
|
67
67
|
"clsx": "^2.1.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
|
|
83
83
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { speak } from '@wordpress/a11y';
|
|
3
|
+
import { Component, useEffect, useState } from '@wordpress/element';
|
|
3
4
|
import { __ } from '@wordpress/i18n';
|
|
4
5
|
import { Button } from '@wordpress/components';
|
|
5
6
|
import { EmptyState } from '@wordpress/ui';
|
|
6
7
|
import { useCopyToClipboard } from '@wordpress/compose';
|
|
7
|
-
import { caution } from '@wordpress/icons';
|
|
8
|
+
import { caution, check, copy, error as errorIcon } from '@wordpress/icons';
|
|
8
9
|
import styles from './style.module.scss';
|
|
9
10
|
|
|
10
11
|
interface Props {
|
|
@@ -15,11 +16,56 @@ interface State {
|
|
|
15
16
|
error: Error | null;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
const COPY_FEEDBACK_TIMEOUT = 2000;
|
|
20
|
+
|
|
21
|
+
type CopyResult = 'idle' | 'copied' | 'error';
|
|
22
|
+
|
|
23
|
+
const RESULT_ICON = {
|
|
24
|
+
idle: copy,
|
|
25
|
+
copied: check,
|
|
26
|
+
error: errorIcon,
|
|
27
|
+
};
|
|
28
|
+
|
|
18
29
|
function CopyErrorButton( { error }: { error: Error } ) {
|
|
19
|
-
|
|
30
|
+
// Bump the id on every result so a repeat of the same outcome restarts
|
|
31
|
+
// the time the icon stays visible.
|
|
32
|
+
const [ feedback, setFeedback ] = useState< {
|
|
33
|
+
result: CopyResult;
|
|
34
|
+
id: number;
|
|
35
|
+
} >( { result: 'idle', id: 0 } );
|
|
36
|
+
|
|
37
|
+
useEffect( () => {
|
|
38
|
+
if ( feedback.result === 'idle' ) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const timeoutId = setTimeout(
|
|
42
|
+
() => setFeedback( { result: 'idle', id: 0 } ),
|
|
43
|
+
COPY_FEEDBACK_TIMEOUT
|
|
44
|
+
);
|
|
45
|
+
return () => clearTimeout( timeoutId );
|
|
46
|
+
}, [ feedback ] );
|
|
47
|
+
|
|
48
|
+
function report( result: Exclude< CopyResult, 'idle' >, message: string ) {
|
|
49
|
+
setFeedback( ( current ) => ( {
|
|
50
|
+
result,
|
|
51
|
+
id: current.id + 1,
|
|
52
|
+
} ) );
|
|
53
|
+
speak( message );
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const ref = useCopyToClipboard(
|
|
57
|
+
() => error.stack ?? String( error ),
|
|
58
|
+
() => report( 'copied', __( 'Copied to clipboard' ) ),
|
|
59
|
+
() => report( 'error', __( "Couldn't copy to clipboard." ) )
|
|
60
|
+
);
|
|
20
61
|
|
|
21
62
|
return (
|
|
22
|
-
<Button
|
|
63
|
+
<Button
|
|
64
|
+
__next40pxDefaultSize
|
|
65
|
+
variant="secondary"
|
|
66
|
+
ref={ ref }
|
|
67
|
+
icon={ RESULT_ICON[ feedback.result ] }
|
|
68
|
+
>
|
|
23
69
|
{ __( 'Copy error' ) }
|
|
24
70
|
</Button>
|
|
25
71
|
);
|