@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,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/navigation/path-matching.ts"],
4
- "sourcesContent": ["import type { MenuItem } from '../../store/types';\n\n/**\n * Checks if a menu path is a valid parent path of the current path.\n * A valid parent path must be a complete path prefix, not just share segments.\n *\n * @param currentPath - Current page path\n * @param menuPath - Menu item path to check as potential parent\n * @return True if menuPath is a parent of currentPath\n */\nconst isValidParentPath = (\n\tcurrentPath: string,\n\tmenuPath: string\n): boolean => {\n\tif ( ! menuPath || menuPath === currentPath ) {\n\t\treturn false;\n\t}\n\n\t// Normalize paths by removing trailing slashes and ensuring leading slash\n\tconst normalizePath = ( path: string ) => {\n\t\tconst normalized = path.startsWith( '/' ) ? path : '/' + path;\n\t\treturn normalized.endsWith( '/' ) && normalized.length > 1\n\t\t\t? normalized.slice( 0, -1 )\n\t\t\t: normalized;\n\t};\n\n\tconst normalizedCurrent = normalizePath( currentPath );\n\tconst normalizedMenu = normalizePath( menuPath );\n\n\t// Menu path must be shorter and current path must start with menu path + '/'\n\treturn (\n\t\tnormalizedCurrent.startsWith( normalizedMenu ) &&\n\t\t( normalizedCurrent[ normalizedMenu.length ] === '/' ||\n\t\t\tnormalizedMenu === '/' )\n\t);\n};\n\n/**\n * Finds the menu item that is the closest parent of the current path.\n * Only considers menu items that have a 'to' path defined and are valid parents.\n *\n * @param currentPath - Current page path\n * @param menuItems - Array of all menu items\n * @return Menu item that is the closest parent, or null if no valid parent found\n */\nexport const findClosestMenuItem = (\n\tcurrentPath: string,\n\tmenuItems: MenuItem[]\n): MenuItem | null => {\n\tconst exactMatch = menuItems.find( ( item ) => item.to === currentPath );\n\tif ( exactMatch ) {\n\t\treturn exactMatch;\n\t}\n\n\tlet bestMatch: MenuItem | null = null;\n\tlet bestPathLength = 0;\n\n\tfor ( const item of menuItems ) {\n\t\tif ( ! item.to ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Only consider items that are valid parents of the current path\n\t\tif ( isValidParentPath( currentPath, item.to ) ) {\n\t\t\t// Prefer the longest parent path (most specific)\n\t\t\tif ( item.to.length > bestPathLength ) {\n\t\t\t\tbestMatch = item;\n\t\t\t\tbestPathLength = item.to.length;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn bestMatch;\n};\n\n/**\n * Finds the drilldown parent of a menu item by traversing up the menu tree.\n *\n * @param id - The ID of the menu item to find the drilldown parent for\n * @param menuItems - Array of all menu items\n * @return The ID of the drilldown parent, or undefined if none found\n */\nexport const findDrilldownParent = (\n\tid: string | undefined,\n\tmenuItems: MenuItem[]\n): string | undefined => {\n\tif ( ! id ) {\n\t\treturn undefined;\n\t}\n\n\tconst currentItem = menuItems.find( ( item ) => item.id === id );\n\tif ( ! currentItem ) {\n\t\treturn undefined;\n\t}\n\n\t// If the item has a parent, check if that parent is a drilldown\n\tif ( currentItem.parent ) {\n\t\tconst parentItem = menuItems.find(\n\t\t\t( item ) => item.id === currentItem.parent\n\t\t);\n\n\t\tif ( parentItem?.parent_type === 'drilldown' ) {\n\t\t\treturn parentItem.id;\n\t\t}\n\n\t\tif ( parentItem ) {\n\t\t\treturn findDrilldownParent( parentItem.id, menuItems );\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Finds the dropdown parent of a menu item.\n *\n * @param id - The ID of the menu item to find the dropdown parent for\n * @param menuItems - Array of all menu items\n * @return The ID of the dropdown parent, or undefined if none found\n */\nexport const findDropdownParent = (\n\tid: string | undefined,\n\tmenuItems: MenuItem[]\n): string | undefined => {\n\tif ( ! id ) {\n\t\treturn undefined;\n\t}\n\n\tconst currentItem = menuItems.find( ( item ) => item.id === id );\n\tif ( ! currentItem ) {\n\t\treturn undefined;\n\t}\n\n\t// If the item has a parent, check if that parent is a dropdown\n\tif ( currentItem.parent ) {\n\t\tconst parentItem = menuItems.find(\n\t\t\t( item ) => item.id === currentItem.parent\n\t\t);\n\n\t\tif ( parentItem?.parent_type === 'dropdown' ) {\n\t\t\treturn parentItem.id;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],
5
- "mappings": ";AAUA,IAAM,oBAAoB,CACzB,aACA,aACa;AACb,MAAK,CAAE,YAAY,aAAa,aAAc;AAC7C,WAAO;AAAA,EACR;AAGA,QAAM,gBAAgB,CAAE,SAAkB;AACzC,UAAM,aAAa,KAAK,WAAY,GAAI,IAAI,OAAO,MAAM;AACzD,WAAO,WAAW,SAAU,GAAI,KAAK,WAAW,SAAS,IACtD,WAAW,MAAO,GAAG,EAAG,IACxB;AAAA,EACJ;AAEA,QAAM,oBAAoB,cAAe,WAAY;AACrD,QAAM,iBAAiB,cAAe,QAAS;AAG/C,SACC,kBAAkB,WAAY,cAAe,MAC3C,kBAAmB,eAAe,MAAO,MAAM,OAChD,mBAAmB;AAEtB;AAUO,IAAM,sBAAsB,CAClC,aACA,cACqB;AACrB,QAAM,aAAa,UAAU,KAAM,CAAE,SAAU,KAAK,OAAO,WAAY;AACvE,MAAK,YAAa;AACjB,WAAO;AAAA,EACR;AAEA,MAAI,YAA6B;AACjC,MAAI,iBAAiB;AAErB,aAAY,QAAQ,WAAY;AAC/B,QAAK,CAAE,KAAK,IAAK;AAChB;AAAA,IACD;AAGA,QAAK,kBAAmB,aAAa,KAAK,EAAG,GAAI;AAEhD,UAAK,KAAK,GAAG,SAAS,gBAAiB;AACtC,oBAAY;AACZ,yBAAiB,KAAK,GAAG;AAAA,MAC1B;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AASO,IAAM,sBAAsB,CAClC,IACA,cACwB;AACxB,MAAK,CAAE,IAAK;AACX,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,UAAU,KAAM,CAAE,SAAU,KAAK,OAAO,EAAG;AAC/D,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAGA,MAAK,YAAY,QAAS;AACzB,UAAM,aAAa,UAAU;AAAA,MAC5B,CAAE,SAAU,KAAK,OAAO,YAAY;AAAA,IACrC;AAEA,QAAK,YAAY,gBAAgB,aAAc;AAC9C,aAAO,WAAW;AAAA,IACnB;AAEA,QAAK,YAAa;AACjB,aAAO,oBAAqB,WAAW,IAAI,SAAU;AAAA,IACtD;AAAA,EACD;AAEA,SAAO;AACR;AASO,IAAM,qBAAqB,CACjC,IACA,cACwB;AACxB,MAAK,CAAE,IAAK;AACX,WAAO;AAAA,EACR;AAEA,QAAM,cAAc,UAAU,KAAM,CAAE,SAAU,KAAK,OAAO,EAAG;AAC/D,MAAK,CAAE,aAAc;AACpB,WAAO;AAAA,EACR;AAGA,MAAK,YAAY,QAAS;AACzB,UAAM,aAAa,UAAU;AAAA,MAC5B,CAAE,SAAU,KAAK,OAAO,YAAY;AAAA,IACrC;AAEA,QAAK,YAAY,gBAAgB,YAAa;AAC7C,aAAO,WAAW;AAAA,IACnB;AAAA,EACD;AAEA,SAAO;AACR;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"path-matching.mjs","names":[],"sources":["../../../src/components/navigation/path-matching.ts"],"sourcesContent":["import type { MenuItem } from '../../store/types';\n\n/**\n * Checks if a menu path is a valid parent path of the current path.\n * A valid parent path must be a complete path prefix, not just share segments.\n *\n * @param currentPath - Current page path\n * @param menuPath - Menu item path to check as potential parent\n * @return True if menuPath is a parent of currentPath\n */\nconst isValidParentPath = (\n\tcurrentPath: string,\n\tmenuPath: string\n): boolean => {\n\tif ( ! menuPath || menuPath === currentPath ) {\n\t\treturn false;\n\t}\n\n\t// Normalize paths by removing trailing slashes and ensuring leading slash\n\tconst normalizePath = ( path: string ) => {\n\t\tconst normalized = path.startsWith( '/' ) ? path : '/' + path;\n\t\treturn normalized.endsWith( '/' ) && normalized.length > 1\n\t\t\t? normalized.slice( 0, -1 )\n\t\t\t: normalized;\n\t};\n\n\tconst normalizedCurrent = normalizePath( currentPath );\n\tconst normalizedMenu = normalizePath( menuPath );\n\n\t// Menu path must be shorter and current path must start with menu path + '/'\n\treturn (\n\t\tnormalizedCurrent.startsWith( normalizedMenu ) &&\n\t\t( normalizedCurrent[ normalizedMenu.length ] === '/' ||\n\t\t\tnormalizedMenu === '/' )\n\t);\n};\n\n/**\n * Finds the menu item that is the closest parent of the current path.\n * Only considers menu items that have a 'to' path defined and are valid parents.\n *\n * @param currentPath - Current page path\n * @param menuItems - Array of all menu items\n * @return Menu item that is the closest parent, or null if no valid parent found\n */\nexport const findClosestMenuItem = (\n\tcurrentPath: string,\n\tmenuItems: MenuItem[]\n): MenuItem | null => {\n\tconst exactMatch = menuItems.find( ( item ) => item.to === currentPath );\n\tif ( exactMatch ) {\n\t\treturn exactMatch;\n\t}\n\n\tlet bestMatch: MenuItem | null = null;\n\tlet bestPathLength = 0;\n\n\tfor ( const item of menuItems ) {\n\t\tif ( ! item.to ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Only consider items that are valid parents of the current path\n\t\tif ( isValidParentPath( currentPath, item.to ) ) {\n\t\t\t// Prefer the longest parent path (most specific)\n\t\t\tif ( item.to.length > bestPathLength ) {\n\t\t\t\tbestMatch = item;\n\t\t\t\tbestPathLength = item.to.length;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn bestMatch;\n};\n\n/**\n * Finds the drilldown parent of a menu item by traversing up the menu tree.\n *\n * @param id - The ID of the menu item to find the drilldown parent for\n * @param menuItems - Array of all menu items\n * @return The ID of the drilldown parent, or undefined if none found\n */\nexport const findDrilldownParent = (\n\tid: string | undefined,\n\tmenuItems: MenuItem[]\n): string | undefined => {\n\tif ( ! id ) {\n\t\treturn undefined;\n\t}\n\n\tconst currentItem = menuItems.find( ( item ) => item.id === id );\n\tif ( ! currentItem ) {\n\t\treturn undefined;\n\t}\n\n\t// If the item has a parent, check if that parent is a drilldown\n\tif ( currentItem.parent ) {\n\t\tconst parentItem = menuItems.find(\n\t\t\t( item ) => item.id === currentItem.parent\n\t\t);\n\n\t\tif ( parentItem?.parent_type === 'drilldown' ) {\n\t\t\treturn parentItem.id;\n\t\t}\n\n\t\tif ( parentItem ) {\n\t\t\treturn findDrilldownParent( parentItem.id, menuItems );\n\t\t}\n\t}\n\n\treturn undefined;\n};\n\n/**\n * Finds the dropdown parent of a menu item.\n *\n * @param id - The ID of the menu item to find the dropdown parent for\n * @param menuItems - Array of all menu items\n * @return The ID of the dropdown parent, or undefined if none found\n */\nexport const findDropdownParent = (\n\tid: string | undefined,\n\tmenuItems: MenuItem[]\n): string | undefined => {\n\tif ( ! id ) {\n\t\treturn undefined;\n\t}\n\n\tconst currentItem = menuItems.find( ( item ) => item.id === id );\n\tif ( ! currentItem ) {\n\t\treturn undefined;\n\t}\n\n\t// If the item has a parent, check if that parent is a dropdown\n\tif ( currentItem.parent ) {\n\t\tconst parentItem = menuItems.find(\n\t\t\t( item ) => item.id === currentItem.parent\n\t\t);\n\n\t\tif ( parentItem?.parent_type === 'dropdown' ) {\n\t\t\treturn parentItem.id;\n\t\t}\n\t}\n\n\treturn undefined;\n};\n"],"mappings":";;;;;;;;;AAUA,MAAM,qBACL,aACA,aACa;CACb,IAAK,CAAE,YAAY,aAAa,aAC/B,OAAO;CAIR,MAAM,iBAAkB,SAAkB;EACzC,MAAM,aAAa,KAAK,WAAY,GAAI,IAAI,OAAO,MAAM;EACzD,OAAO,WAAW,SAAU,GAAI,KAAK,WAAW,SAAS,IACtD,WAAW,MAAO,GAAG,EAAG,IACxB;CACJ;CAEA,MAAM,oBAAoB,cAAe,WAAY;CACrD,MAAM,iBAAiB,cAAe,QAAS;CAG/C,OACC,kBAAkB,WAAY,cAAe,MAC3C,kBAAmB,eAAe,YAAa,OAChD,mBAAmB;AAEtB;;;;;;;;;AAUA,MAAa,uBACZ,aACA,cACqB;CACrB,MAAM,aAAa,UAAU,MAAQ,SAAU,KAAK,OAAO,WAAY;CACvE,IAAK,YACJ,OAAO;CAGR,IAAI,YAA6B;CACjC,IAAI,iBAAiB;CAErB,KAAM,MAAM,QAAQ,WAAY;EAC/B,IAAK,CAAE,KAAK,IACX;EAID,IAAK,kBAAmB,aAAa,KAAK,EAAG,GAEvC;OAAA,KAAK,GAAG,SAAS,gBAAiB;IACtC,YAAY;IACZ,iBAAiB,KAAK,GAAG;GAC1B;;CAEF;CAEA,OAAO;AACR;;;;;;;;AASA,MAAa,uBACZ,IACA,cACwB;CACxB,IAAK,CAAE,IACN;CAGD,MAAM,cAAc,UAAU,MAAQ,SAAU,KAAK,OAAO,EAAG;CAC/D,IAAK,CAAE,aACN;CAID,IAAK,YAAY,QAAS;EACzB,MAAM,aAAa,UAAU,MAC1B,SAAU,KAAK,OAAO,YAAY,MACrC;EAEA,IAAK,YAAY,gBAAgB,aAChC,OAAO,WAAW;EAGnB,IAAK,YACJ,OAAO,oBAAqB,WAAW,IAAI,SAAU;CAEvD;AAGD;;;;;;;;AASA,MAAa,sBACZ,IACA,cACwB;CACxB,IAAK,CAAE,IACN;CAGD,MAAM,cAAc,UAAU,MAAQ,SAAU,KAAK,OAAO,EAAG;CAC/D,IAAK,CAAE,aACN;CAID,IAAK,YAAY,QAAS;EACzB,MAAM,aAAa,UAAU,MAC1B,SAAU,KAAK,OAAO,YAAY,MACrC;EAEA,IAAK,YAAY,gBAAgB,YAChC,OAAO,WAAW;CAEpB;AAGD"}
@@ -1,16 +1,18 @@
1
- // packages/boot/src/components/navigation/router-link-item.tsx
2
1
  import { forwardRef } from "@wordpress/element";
3
- import { __experimentalItem as Item } from "@wordpress/components";
4
- import { privateApis as routePrivateApis } from "@wordpress/route";
2
+ import { __experimentalItem } from "@wordpress/components";
3
+ import { privateApis } from "@wordpress/route";
5
4
  import { unlock } from "../../lock-unlock.mjs";
6
5
  import { jsx } from "react/jsx-runtime";
7
- var { createLink } = unlock(routePrivateApis);
6
+ // packages/boot/src/components/navigation/router-link-item.tsx
7
+ const { createLink } = unlock(privateApis);
8
8
  function AnchorOnlyItem(props, forwardedRef) {
9
- return /* @__PURE__ */ jsx(Item, { as: "a", ref: forwardedRef, ...props });
9
+ return /* @__PURE__ */ jsx(__experimentalItem, {
10
+ as: "a",
11
+ ref: forwardedRef,
12
+ ...props
13
+ });
10
14
  }
11
- var RouterLinkItem = createLink(forwardRef(AnchorOnlyItem));
12
- var router_link_item_default = RouterLinkItem;
13
- export {
14
- router_link_item_default as default
15
- };
16
- //# sourceMappingURL=router-link-item.mjs.map
15
+ const RouterLinkItem = createLink(forwardRef(AnchorOnlyItem));
16
+ export { RouterLinkItem as default };
17
+
18
+ //# sourceMappingURL=router-link-item.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/navigation/router-link-item.tsx"],
4
- "sourcesContent": ["import type { ForwardedRef } from 'react';\nimport { forwardRef } from '@wordpress/element';\nimport { __experimentalItem as Item } from '@wordpress/components';\nimport { privateApis as routePrivateApis } from '@wordpress/route';\nimport { unlock } from '../../lock-unlock';\n\nconst { createLink } = unlock( routePrivateApis );\n\nfunction AnchorOnlyItem(\n\tprops: React.ComponentProps< typeof Item >,\n\tforwardedRef: ForwardedRef< HTMLAnchorElement >\n) {\n\treturn <Item as=\"a\" ref={ forwardedRef } { ...props } />;\n}\n\nconst RouterLinkItem = createLink( forwardRef( AnchorOnlyItem ) );\n\nexport default RouterLinkItem;\n"],
5
- "mappings": ";AACA,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB,YAAY;AAC3C,SAAS,eAAe,wBAAwB;AAChD,SAAS,cAAc;AAQf;AANR,IAAM,EAAE,WAAW,IAAI,OAAQ,gBAAiB;AAEhD,SAAS,eACR,OACA,cACC;AACD,SAAO,oBAAC,QAAK,IAAG,KAAI,KAAM,cAAiB,GAAG,OAAQ;AACvD;AAEA,IAAM,iBAAiB,WAAY,WAAY,cAAe,CAAE;AAEhE,IAAO,2BAAQ;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"router-link-item.mjs","names":["routePrivateApis","Item"],"sources":["../../../src/components/navigation/router-link-item.tsx"],"sourcesContent":["import type { ForwardedRef } from 'react';\nimport { forwardRef } from '@wordpress/element';\nimport { __experimentalItem as Item } from '@wordpress/components';\nimport { privateApis as routePrivateApis } from '@wordpress/route';\nimport { unlock } from '../../lock-unlock';\n\nconst { createLink } = unlock( routePrivateApis );\n\nfunction AnchorOnlyItem(\n\tprops: React.ComponentProps< typeof Item >,\n\tforwardedRef: ForwardedRef< HTMLAnchorElement >\n) {\n\treturn <Item as=\"a\" ref={ forwardedRef } { ...props } />;\n}\n\nconst RouterLinkItem = createLink( forwardRef( AnchorOnlyItem ) );\n\nexport default RouterLinkItem;\n"],"mappings":";;;;;;AAMA,MAAM,EAAE,eAAe,OAAQA,WAAiB;AAEhD,SAAS,eACR,OACA,cACC;CACD,OAAO,oBAACC,oBAAD;EAAM,IAAG;EAAI,KAAM;EAAe,GAAK;CAAS,CAAA;AACxD;AAEA,MAAM,iBAAiB,WAAY,WAAY,cAAe,CAAE"}
@@ -1,54 +1,43 @@
1
- // packages/boot/src/components/navigation/use-sidebar-parent.ts
2
- import { privateApis as routePrivateApis } from "@wordpress/route";
1
+ import { privateApis } from "@wordpress/route";
3
2
  import { useEffect, useState } from "@wordpress/element";
4
3
  import { useSelect } from "@wordpress/data";
5
4
  import { unlock } from "../../lock-unlock.mjs";
6
5
  import { STORE_NAME } from "../../store/index.mjs";
7
- import {
8
- findDrilldownParent,
9
- findDropdownParent,
10
- findClosestMenuItem
11
- } from "./path-matching.mjs";
12
- var { useRouter, useMatches } = unlock(routePrivateApis);
6
+ import { findClosestMenuItem, findDrilldownParent, findDropdownParent } from "./path-matching.mjs";
7
+ // packages/boot/src/components/navigation/use-sidebar-parent.ts
8
+ const { useRouter, useMatches } = unlock(privateApis);
9
+ /**
10
+ * The `useSidebarParent` hook returns the ID of the parent menu item
11
+ * to render in the sidebar based on the current route.
12
+ *
13
+ * - It finds the closest matching menu item when exact path matches fail
14
+ * - It allows the user to navigate in the sidebar (local state) without changing the URL.
15
+ * - If the URL changes, it will update the parent ID to ensure the correct drilldown level is displayed.
16
+ *
17
+ * @return The ID of the parent menu item to render in the sidebar.
18
+ */
13
19
  function useSidebarParent() {
14
- const matches = useMatches();
15
- const router = useRouter();
16
- const menuItems = useSelect(
17
- (select) => (
18
- // @ts-expect-error Store types are not available when selecting by store name.
19
- select(STORE_NAME).getMenuItems()
20
- ),
21
- []
22
- );
23
- const currentPath = matches[matches.length - 1].pathname.slice(
24
- router.options.basepath?.length ?? 0
25
- );
26
- const currentMenuItem = findClosestMenuItem(currentPath, menuItems);
27
- const [parentId, setParentId] = useState(
28
- findDrilldownParent(currentMenuItem?.id, menuItems)
29
- );
30
- const [parentDropdownId, setParentDropdownId] = useState(findDropdownParent(currentMenuItem?.id, menuItems));
31
- useEffect(() => {
32
- const matchedMenuItem = findClosestMenuItem(currentPath, menuItems);
33
- const updatedParentId = findDrilldownParent(
34
- matchedMenuItem?.id,
35
- menuItems
36
- );
37
- const updatedDropdownParent = findDropdownParent(
38
- matchedMenuItem?.id,
39
- menuItems
40
- );
41
- setParentId(updatedParentId);
42
- setParentDropdownId(updatedDropdownParent);
43
- }, [currentPath, menuItems]);
44
- return [
45
- parentId,
46
- setParentId,
47
- parentDropdownId,
48
- setParentDropdownId
49
- ];
20
+ const matches = useMatches();
21
+ const router = useRouter();
22
+ const menuItems = useSelect((select) => select(STORE_NAME).getMenuItems(), []);
23
+ const currentPath = matches[matches.length - 1].pathname.slice(router.options.basepath?.length ?? 0);
24
+ const currentMenuItem = findClosestMenuItem(currentPath, menuItems);
25
+ const [parentId, setParentId] = useState(findDrilldownParent(currentMenuItem?.id, menuItems));
26
+ const [parentDropdownId, setParentDropdownId] = useState(findDropdownParent(currentMenuItem?.id, menuItems));
27
+ useEffect(() => {
28
+ const matchedMenuItem = findClosestMenuItem(currentPath, menuItems);
29
+ const updatedParentId = findDrilldownParent(matchedMenuItem?.id, menuItems);
30
+ const updatedDropdownParent = findDropdownParent(matchedMenuItem?.id, menuItems);
31
+ setParentId(updatedParentId);
32
+ setParentDropdownId(updatedDropdownParent);
33
+ }, [currentPath, menuItems]);
34
+ return [
35
+ parentId,
36
+ setParentId,
37
+ parentDropdownId,
38
+ setParentDropdownId
39
+ ];
50
40
  }
51
- export {
52
- useSidebarParent
53
- };
54
- //# sourceMappingURL=use-sidebar-parent.mjs.map
41
+ export { useSidebarParent };
42
+
43
+ //# sourceMappingURL=use-sidebar-parent.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/navigation/use-sidebar-parent.ts"],
4
- "sourcesContent": ["import { privateApis as routePrivateApis } from '@wordpress/route';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { unlock } from '../../lock-unlock';\nconst { useRouter, useMatches } = unlock( routePrivateApis );\nimport { STORE_NAME } from '../../store';\nimport {\n\tfindDrilldownParent,\n\tfindDropdownParent,\n\tfindClosestMenuItem,\n} from './path-matching';\n\n/**\n * The `useSidebarParent` hook returns the ID of the parent menu item\n * to render in the sidebar based on the current route.\n *\n * - It finds the closest matching menu item when exact path matches fail\n * - It allows the user to navigate in the sidebar (local state) without changing the URL.\n * - If the URL changes, it will update the parent ID to ensure the correct drilldown level is displayed.\n *\n * @return The ID of the parent menu item to render in the sidebar.\n */\nexport function useSidebarParent() {\n\tconst matches = useMatches();\n\tconst router = useRouter();\n\tconst menuItems = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error Store types are not available when selecting by store name.\n\t\t\tselect( STORE_NAME ).getMenuItems(),\n\t\t[]\n\t);\n\n\tconst currentPath = matches[ matches.length - 1 ].pathname.slice(\n\t\trouter.options.basepath?.length ?? 0\n\t);\n\n\tconst currentMenuItem = findClosestMenuItem( currentPath, menuItems );\n\tconst [ parentId, setParentId ] = useState< string | undefined >(\n\t\tfindDrilldownParent( currentMenuItem?.id, menuItems )\n\t);\n\tconst [ parentDropdownId, setParentDropdownId ] = useState<\n\t\tstring | undefined\n\t>( findDropdownParent( currentMenuItem?.id, menuItems ) );\n\n\t// Effect to update parent IDs when URL or menu items change\n\tuseEffect( () => {\n\t\tconst matchedMenuItem = findClosestMenuItem( currentPath, menuItems );\n\t\t// Find the appropriate parents for the current route\n\t\tconst updatedParentId = findDrilldownParent(\n\t\t\tmatchedMenuItem?.id,\n\t\t\tmenuItems\n\t\t);\n\t\tconst updatedDropdownParent = findDropdownParent(\n\t\t\tmatchedMenuItem?.id,\n\t\t\tmenuItems\n\t\t);\n\n\t\tsetParentId( updatedParentId );\n\t\tsetParentDropdownId( updatedDropdownParent );\n\t}, [ currentPath, menuItems ] );\n\n\treturn [\n\t\tparentId,\n\t\tsetParentId,\n\t\tparentDropdownId,\n\t\tsetParentDropdownId,\n\t] as const;\n}\n"],
5
- "mappings": ";AAAA,SAAS,eAAe,wBAAwB;AAChD,SAAS,WAAW,gBAAgB;AACpC,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AAEvB,SAAS,kBAAkB;AAC3B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AANP,IAAM,EAAE,WAAW,WAAW,IAAI,OAAQ,gBAAiB;AAkBpD,SAAS,mBAAmB;AAClC,QAAM,UAAU,WAAW;AAC3B,QAAM,SAAS,UAAU;AACzB,QAAM,YAAY;AAAA,IACjB,CAAE;AAAA;AAAA,MAED,OAAQ,UAAW,EAAE,aAAa;AAAA;AAAA,IACnC,CAAC;AAAA,EACF;AAEA,QAAM,cAAc,QAAS,QAAQ,SAAS,CAAE,EAAE,SAAS;AAAA,IAC1D,OAAO,QAAQ,UAAU,UAAU;AAAA,EACpC;AAEA,QAAM,kBAAkB,oBAAqB,aAAa,SAAU;AACpE,QAAM,CAAE,UAAU,WAAY,IAAI;AAAA,IACjC,oBAAqB,iBAAiB,IAAI,SAAU;AAAA,EACrD;AACA,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAE/C,mBAAoB,iBAAiB,IAAI,SAAU,CAAE;AAGxD,YAAW,MAAM;AAChB,UAAM,kBAAkB,oBAAqB,aAAa,SAAU;AAEpE,UAAM,kBAAkB;AAAA,MACvB,iBAAiB;AAAA,MACjB;AAAA,IACD;AACA,UAAM,wBAAwB;AAAA,MAC7B,iBAAiB;AAAA,MACjB;AAAA,IACD;AAEA,gBAAa,eAAgB;AAC7B,wBAAqB,qBAAsB;AAAA,EAC5C,GAAG,CAAE,aAAa,SAAU,CAAE;AAE9B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"use-sidebar-parent.mjs","names":["routePrivateApis"],"sources":["../../../src/components/navigation/use-sidebar-parent.ts"],"sourcesContent":["import { privateApis as routePrivateApis } from '@wordpress/route';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { unlock } from '../../lock-unlock';\nconst { useRouter, useMatches } = unlock( routePrivateApis );\nimport { STORE_NAME } from '../../store';\nimport {\n\tfindDrilldownParent,\n\tfindDropdownParent,\n\tfindClosestMenuItem,\n} from './path-matching';\n\n/**\n * The `useSidebarParent` hook returns the ID of the parent menu item\n * to render in the sidebar based on the current route.\n *\n * - It finds the closest matching menu item when exact path matches fail\n * - It allows the user to navigate in the sidebar (local state) without changing the URL.\n * - If the URL changes, it will update the parent ID to ensure the correct drilldown level is displayed.\n *\n * @return The ID of the parent menu item to render in the sidebar.\n */\nexport function useSidebarParent() {\n\tconst matches = useMatches();\n\tconst router = useRouter();\n\tconst menuItems = useSelect(\n\t\t( select ) =>\n\t\t\t// @ts-expect-error Store types are not available when selecting by store name.\n\t\t\tselect( STORE_NAME ).getMenuItems(),\n\t\t[]\n\t);\n\n\tconst currentPath = matches[ matches.length - 1 ].pathname.slice(\n\t\trouter.options.basepath?.length ?? 0\n\t);\n\n\tconst currentMenuItem = findClosestMenuItem( currentPath, menuItems );\n\tconst [ parentId, setParentId ] = useState< string | undefined >(\n\t\tfindDrilldownParent( currentMenuItem?.id, menuItems )\n\t);\n\tconst [ parentDropdownId, setParentDropdownId ] = useState<\n\t\tstring | undefined\n\t>( findDropdownParent( currentMenuItem?.id, menuItems ) );\n\n\t// Effect to update parent IDs when URL or menu items change\n\tuseEffect( () => {\n\t\tconst matchedMenuItem = findClosestMenuItem( currentPath, menuItems );\n\t\t// Find the appropriate parents for the current route\n\t\tconst updatedParentId = findDrilldownParent(\n\t\t\tmatchedMenuItem?.id,\n\t\t\tmenuItems\n\t\t);\n\t\tconst updatedDropdownParent = findDropdownParent(\n\t\t\tmatchedMenuItem?.id,\n\t\t\tmenuItems\n\t\t);\n\n\t\tsetParentId( updatedParentId );\n\t\tsetParentDropdownId( updatedDropdownParent );\n\t}, [ currentPath, menuItems ] );\n\n\treturn [\n\t\tparentId,\n\t\tsetParentId,\n\t\tparentDropdownId,\n\t\tsetParentDropdownId,\n\t] as const;\n}\n"],"mappings":";;;;;;;AAIA,MAAM,EAAE,WAAW,eAAe,OAAQA,WAAiB;;;;;;;;;;;AAkB3D,SAAgB,mBAAmB;CAClC,MAAM,UAAU,WAAW;CAC3B,MAAM,SAAS,UAAU;CACzB,MAAM,YAAY,WACf,WAED,OAAQ,UAAW,CAAC,CAAC,aAAa,GACnC,CAAC,CACF;CAEA,MAAM,cAAc,QAAS,QAAQ,SAAS,EAAG,CAAC,SAAS,MAC1D,OAAO,QAAQ,UAAU,UAAU,CACpC;CAEA,MAAM,kBAAkB,oBAAqB,aAAa,SAAU;CACpE,MAAM,CAAE,UAAU,eAAgB,SACjC,oBAAqB,iBAAiB,IAAI,SAAU,CACrD;CACA,MAAM,CAAE,kBAAkB,uBAAwB,SAE/C,mBAAoB,iBAAiB,IAAI,SAAU,CAAE;CAGxD,gBAAiB;EAChB,MAAM,kBAAkB,oBAAqB,aAAa,SAAU;EAEpE,MAAM,kBAAkB,oBACvB,iBAAiB,IACjB,SACD;EACA,MAAM,wBAAwB,mBAC7B,iBAAiB,IACjB,SACD;EAEA,YAAa,eAAgB;EAC7B,oBAAqB,qBAAsB;CAC5C,GAAG,CAAE,aAAa,SAAU,CAAE;CAE9B,OAAO;EACN;EACA;EACA;EACA;CACD;AACD"}
@@ -1,29 +1,25 @@
1
- // packages/boot/src/components/plugin-area/index.tsx
2
1
  import { useDispatch } from "@wordpress/data";
3
2
  import { __, sprintf } from "@wordpress/i18n";
4
- import { store as noticesStore } from "@wordpress/notices";
5
- import { PluginArea as WPPluginArea } from "@wordpress/plugins";
3
+ import { store } from "@wordpress/notices";
4
+ import { PluginArea as PluginArea$1 } from "@wordpress/plugins";
6
5
  import { jsx } from "react/jsx-runtime";
6
+ // packages/boot/src/components/plugin-area/index.tsx
7
+ /**
8
+ * Mounts every plugin registered with `registerPlugin`, so the fills they
9
+ * render reach their slots.
10
+ *
11
+ * Sits at the root rather than with the editor: a plugin's fills mostly target
12
+ * editor slots, but the component holding them is also where it registers
13
+ * commands and extends a list, which the routes without a canvas need too.
14
+ *
15
+ * @return The mount point. Renders whatever the plugins do, and nothing itself.
16
+ */
7
17
  function PluginArea() {
8
- const { createErrorNotice } = useDispatch(noticesStore);
9
- return /* @__PURE__ */ jsx(
10
- WPPluginArea,
11
- {
12
- onError: (name) => {
13
- createErrorNotice(
14
- sprintf(
15
- /* translators: %s: plugin name */
16
- __(
17
- 'The "%s" plugin has encountered an error and cannot be rendered.'
18
- ),
19
- name
20
- )
21
- );
22
- }
23
- }
24
- );
18
+ const { createErrorNotice } = useDispatch(store);
19
+ return /* @__PURE__ */ jsx(PluginArea$1, { onError: (name) => {
20
+ createErrorNotice(sprintf(__("The \"%s\" plugin has encountered an error and cannot be rendered."), name));
21
+ } });
25
22
  }
26
- export {
27
- PluginArea as default
28
- };
29
- //# sourceMappingURL=index.mjs.map
23
+ export { PluginArea as default };
24
+
25
+ //# sourceMappingURL=index.mjs.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/plugin-area/index.tsx"],
4
- "sourcesContent": ["import { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { PluginArea as WPPluginArea } from '@wordpress/plugins';\n\n/**\n * Mounts every plugin registered with `registerPlugin`, so the fills they\n * render reach their slots.\n *\n * Sits at the root rather than with the editor: a plugin's fills mostly target\n * editor slots, but the component holding them is also where it registers\n * commands and extends a list, which the routes without a canvas need too.\n *\n * @return The mount point. Renders whatever the plugins do, and nothing itself.\n */\nexport default function PluginArea() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\treturn (\n\t\t<WPPluginArea\n\t\t\tonError={ ( name ) => {\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tname\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
5
- "mappings": ";AAAA,SAAS,mBAAmB;AAC5B,SAAS,IAAI,eAAe;AAC5B,SAAS,SAAS,oBAAoB;AACtC,SAAS,cAAc,oBAAoB;AAgBzC;AAJa,SAAR,aAA8B;AACpC,QAAM,EAAE,kBAAkB,IAAI,YAAa,YAAa;AAExD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,SAAU,CAAE,SAAU;AACrB;AAAA,UACC;AAAA;AAAA,YAEC;AAAA,cACC;AAAA,YACD;AAAA,YACA;AAAA,UACD;AAAA,QACD;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
6
- "names": []
7
- }
1
+ {"version":3,"file":"index.mjs","names":["noticesStore","WPPluginArea"],"sources":["../../../src/components/plugin-area/index.tsx"],"sourcesContent":["import { useDispatch } from '@wordpress/data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { PluginArea as WPPluginArea } from '@wordpress/plugins';\n\n/**\n * Mounts every plugin registered with `registerPlugin`, so the fills they\n * render reach their slots.\n *\n * Sits at the root rather than with the editor: a plugin's fills mostly target\n * editor slots, but the component holding them is also where it registers\n * commands and extends a list, which the routes without a canvas need too.\n *\n * @return The mount point. Renders whatever the plugins do, and nothing itself.\n */\nexport default function PluginArea() {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\treturn (\n\t\t<WPPluginArea\n\t\t\tonError={ ( name ) => {\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t/* translators: %s: plugin name */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The \"%s\" plugin has encountered an error and cannot be rendered.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tname\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,SAAwB,aAAa;CACpC,MAAM,EAAE,sBAAsB,YAAaA,KAAa;CAExD,OACC,oBAACC,cAAD,EACC,UAAY,SAAU;EACrB,kBACC,QAEC,GACC,oEACD,GACA,IACD,CACD;CACD,EACA,CAAA;AAEH"}