@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.
Files changed (71) hide show
  1. package/build-module/components/app/index.mjs +29 -53
  2. package/build-module/components/app/index.mjs.map +1 -7
  3. package/build-module/components/app/router.mjs +238 -214
  4. package/build-module/components/app/router.mjs.map +1 -7
  5. package/build-module/components/app/use-route-title.mjs +35 -42
  6. package/build-module/components/app/use-route-title.mjs.map +1 -7
  7. package/build-module/components/canvas/back-button.mjs +21 -20
  8. package/build-module/components/canvas/back-button.mjs.map +1 -7
  9. package/build-module/components/canvas/index.mjs +104 -130
  10. package/build-module/components/canvas/index.mjs.map +1 -7
  11. package/build-module/components/canvas/site-preview.mjs +36 -43
  12. package/build-module/components/canvas/site-preview.mjs.map +1 -7
  13. package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
  14. package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
  15. package/build-module/components/canvas/viewport.mjs +25 -13
  16. package/build-module/components/canvas/viewport.mjs.map +1 -7
  17. package/build-module/components/canvas-renderer/index.mjs +40 -32
  18. package/build-module/components/canvas-renderer/index.mjs.map +1 -7
  19. package/build-module/components/error-boundary/index.mjs +160 -108
  20. package/build-module/components/error-boundary/index.mjs.map +1 -7
  21. package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
  22. package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
  23. package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
  24. package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
  25. package/build-module/components/navigation/index.mjs +55 -90
  26. package/build-module/components/navigation/index.mjs.map +1 -7
  27. package/build-module/components/navigation/items.mjs +51 -53
  28. package/build-module/components/navigation/items.mjs.map +1 -7
  29. package/build-module/components/navigation/navigation-item/index.mjs +120 -114
  30. package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
  31. package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
  32. package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
  33. package/build-module/components/navigation/path-matching.mjs +74 -73
  34. package/build-module/components/navigation/path-matching.mjs.map +1 -7
  35. package/build-module/components/navigation/router-link-item.mjs +13 -11
  36. package/build-module/components/navigation/router-link-item.mjs.map +1 -7
  37. package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
  38. package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
  39. package/build-module/components/plugin-area/index.mjs +20 -24
  40. package/build-module/components/plugin-area/index.mjs.map +1 -7
  41. package/build-module/components/root/index.mjs +227 -242
  42. package/build-module/components/root/index.mjs.map +1 -7
  43. package/build-module/components/root/single-page.mjs +174 -148
  44. package/build-module/components/root/single-page.mjs.map +1 -7
  45. package/build-module/components/root/use-sync-body-background.mjs +28 -22
  46. package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
  47. package/build-module/components/save-button/index.mjs +170 -214
  48. package/build-module/components/save-button/index.mjs.map +1 -7
  49. package/build-module/components/save-panel/index.mjs +110 -106
  50. package/build-module/components/save-panel/index.mjs.map +1 -7
  51. package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
  52. package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
  53. package/build-module/components/sidebar/index.mjs +126 -104
  54. package/build-module/components/sidebar/index.mjs.map +1 -7
  55. package/build-module/index.mjs +1 -7
  56. package/build-module/lock-unlock.mjs +5 -10
  57. package/build-module/lock-unlock.mjs.map +1 -7
  58. package/build-module/store/actions.mjs +34 -31
  59. package/build-module/store/actions.mjs.map +1 -7
  60. package/build-module/store/index.mjs +9 -11
  61. package/build-module/store/index.mjs.map +1 -7
  62. package/build-module/store/reducer.mjs +48 -55
  63. package/build-module/store/reducer.mjs.map +1 -7
  64. package/build-module/store/selectors.mjs +21 -16
  65. package/build-module/store/selectors.mjs.map +1 -7
  66. package/build-module/store/types.mjs +0 -1
  67. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  68. package/package.json +28 -28
  69. package/src/components/error-boundary/index.tsx +50 -4
  70. package/build-module/index.mjs.map +0 -7
  71. 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
- return Object.values(state.menuItems);
3
+ return Object.values(state.menuItems);
4
4
  }
5
5
  function getRoutes(state) {
6
- return state.routes;
6
+ return state.routes;
7
7
  }
8
8
  function getDashboardLink(state) {
9
- return state.dashboardLink;
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
- const links = state.entityLinks[postType] ?? state.entityLinks.default;
13
- const path = postId === void 0 ? links?.list : links?.edit;
14
- if (!path) {
15
- return void 0;
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
- getDashboardLink,
21
- getEntityLink,
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;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAQ/C,UAAU,KAAK;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,KAAK;IACd,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACpB;AAYD;;;;;;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"}
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.25.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.0.0",
42
- "@wordpress/admin-ui": "^3.0.0",
43
- "@wordpress/base-styles": "^14.0.0",
44
- "@wordpress/components": "^43.0.0",
45
- "@wordpress/compose": "^9.0.0",
46
- "@wordpress/core-data": "^9.0.0",
47
- "@wordpress/data": "^11.0.0",
48
- "@wordpress/dom": "^5.0.0",
49
- "@wordpress/editor": "^16.0.0",
50
- "@wordpress/element": "^10.0.0",
51
- "@wordpress/html-entities": "^5.0.0",
52
- "@wordpress/i18n": "^7.0.0",
53
- "@wordpress/icons": "^19.0.0",
54
- "@wordpress/keyboard-shortcuts": "^6.0.0",
55
- "@wordpress/keycodes": "^5.0.0",
56
- "@wordpress/lazy-editor": "^2.0.0",
57
- "@wordpress/notices": "^6.0.0",
58
- "@wordpress/plugins": "^8.0.0",
59
- "@wordpress/primitives": "^5.0.0",
60
- "@wordpress/private-apis": "^3.0.0",
61
- "@wordpress/react-inert-value": "^2.0.0",
62
- "@wordpress/route": "^0.24.0",
63
- "@wordpress/style-runtime": "^0.14.0",
64
- "@wordpress/theme": "^3.0.0",
65
- "@wordpress/ui": "^0.25.0",
66
- "@wordpress/url": "^5.0.0",
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": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
82
+ "gitHead": "9b70363b9f93cff0583a1f3153738d383cf5a49e"
83
83
  }
@@ -1,10 +1,11 @@
1
1
  import type { ReactNode } from 'react';
2
- import { Component } from '@wordpress/element';
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
- const ref = useCopyToClipboard( () => error.stack ?? String( error ) );
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 __next40pxDefaultSize variant="secondary" ref={ ref }>
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
  );
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/index.tsx"],
4
- "sourcesContent": ["export { init, initSinglePage } from './components/app';\nexport { store } from './store';\n"],
5
- "mappings": ";AAAA,SAAS,MAAM,sBAAsB;AACrC,SAAS,aAAa;",
6
- "names": []
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
6
- "names": []
7
- }