@wordpress/boot 0.19.0 → 0.21.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 +38 -0
- package/README.md +4 -0
- package/build-module/components/app/index.mjs.map +2 -2
- package/build-module/components/app/router.mjs +100 -4
- package/build-module/components/app/router.mjs.map +3 -3
- package/build-module/components/app/use-route-title.mjs.map +2 -2
- package/build-module/components/canvas/back-button.mjs.map +2 -2
- package/build-module/components/canvas/index.mjs +72 -13
- package/build-module/components/canvas/index.mjs.map +2 -2
- package/build-module/components/canvas/site-preview.mjs +50 -0
- package/build-module/components/canvas/site-preview.mjs.map +7 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +122 -0
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +7 -0
- package/build-module/components/canvas/viewport.mjs +18 -0
- package/build-module/components/canvas/viewport.mjs.map +7 -0
- package/build-module/components/canvas-renderer/index.mjs.map +2 -2
- package/build-module/components/error-boundary/index.mjs +129 -0
- package/build-module/components/error-boundary/index.mjs.map +7 -0
- package/build-module/components/navigation/drilldown-item/index.mjs +91 -1
- package/build-module/components/navigation/drilldown-item/index.mjs.map +3 -3
- package/build-module/components/navigation/dropdown-item/index.mjs +99 -12
- package/build-module/components/navigation/dropdown-item/index.mjs.map +4 -4
- package/build-module/components/navigation/index.mjs +1 -2
- package/build-module/components/navigation/index.mjs.map +2 -2
- package/build-module/components/navigation/items.mjs.map +2 -2
- package/build-module/components/navigation/navigation-item/index.mjs +88 -15
- package/build-module/components/navigation/navigation-item/index.mjs.map +3 -3
- package/build-module/components/navigation/navigation-screen/index.mjs +111 -38
- package/build-module/components/navigation/navigation-screen/index.mjs.map +3 -3
- package/build-module/components/navigation/path-matching.mjs.map +2 -2
- package/build-module/components/navigation/router-link-item.mjs.map +2 -2
- package/build-module/components/navigation/use-sidebar-parent.mjs +1 -1
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +2 -2
- package/build-module/components/plugin-area/index.mjs +29 -0
- package/build-module/components/plugin-area/index.mjs.map +7 -0
- package/build-module/components/root/index.mjs +220 -122
- package/build-module/components/root/index.mjs.map +3 -3
- package/build-module/components/root/single-page.mjs +139 -47
- package/build-module/components/root/single-page.mjs.map +3 -3
- package/build-module/components/root/use-sync-body-background.mjs.map +2 -2
- package/build-module/components/save-button/index.mjs +127 -16
- package/build-module/components/save-button/index.mjs.map +3 -3
- package/build-module/components/save-panel/index.mjs +91 -1
- package/build-module/components/save-panel/index.mjs.map +3 -3
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +90 -10
- package/build-module/components/sidebar/index.mjs.map +3 -3
- package/build-module/index.mjs +0 -16
- package/build-module/index.mjs.map +3 -3
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/store/actions.mjs +8 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs +16 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +9 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-types/components/app/index.d.ts.map +1 -1
- package/build-types/components/app/router.d.ts +0 -3
- package/build-types/components/app/router.d.ts.map +1 -1
- package/build-types/components/app/use-route-title.d.ts.map +1 -1
- package/build-types/components/canvas/back-button.d.ts.map +1 -1
- package/build-types/components/canvas/index.d.ts +0 -3
- package/build-types/components/canvas/index.d.ts.map +1 -1
- package/build-types/components/canvas/site-preview.d.ts +10 -0
- package/build-types/components/canvas/site-preview.d.ts.map +1 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts +40 -0
- package/build-types/components/canvas/use-navigate-to-entity-record.d.ts.map +1 -0
- package/build-types/components/canvas/viewport.d.ts +15 -0
- package/build-types/components/canvas/viewport.d.ts.map +1 -0
- package/build-types/components/canvas-renderer/index.d.ts.map +1 -1
- package/build-types/components/error-boundary/index.d.ts +22 -0
- package/build-types/components/error-boundary/index.d.ts.map +1 -0
- package/build-types/components/navigation/drilldown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts +0 -1
- package/build-types/components/navigation/dropdown-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/index.d.ts.map +1 -1
- package/build-types/components/navigation/items.d.ts +0 -3
- package/build-types/components/navigation/items.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-item/index.d.ts +0 -1
- package/build-types/components/navigation/navigation-item/index.d.ts.map +1 -1
- package/build-types/components/navigation/navigation-screen/index.d.ts +0 -7
- package/build-types/components/navigation/navigation-screen/index.d.ts.map +1 -1
- package/build-types/components/navigation/path-matching.d.ts +0 -3
- package/build-types/components/navigation/path-matching.d.ts.map +1 -1
- package/build-types/components/navigation/router-link-item.d.ts.map +1 -1
- package/build-types/components/navigation/use-sidebar-parent.d.ts.map +1 -1
- package/build-types/components/plugin-area/index.d.ts +12 -0
- package/build-types/components/plugin-area/index.d.ts.map +1 -0
- package/build-types/components/root/index.d.ts +0 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/build-types/components/root/single-page.d.ts +0 -1
- package/build-types/components/root/single-page.d.ts.map +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts +1 -1
- package/build-types/components/root/use-sync-body-background.d.ts.map +1 -1
- package/build-types/components/save-button/index.d.ts +0 -4
- package/build-types/components/save-button/index.d.ts.map +1 -1
- package/build-types/components/save-panel/index.d.ts.map +1 -1
- package/build-types/components/save-panel/use-save-shortcut.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts +0 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/index.d.ts +0 -5
- package/build-types/index.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +15 -5
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -3
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +12 -3
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/store/types.d.ts +34 -6
- package/build-types/store/types.d.ts.map +1 -1
- package/package.json +28 -25
- package/src/components/app/index.tsx +0 -7
- package/src/components/app/router.tsx +19 -18
- package/src/components/app/use-route-title.ts +0 -7
- package/src/components/canvas/back-button.tsx +0 -3
- package/src/components/canvas/index.tsx +117 -22
- package/src/components/canvas/site-preview.tsx +64 -0
- package/src/components/canvas/use-navigate-to-entity-record.ts +220 -0
- package/src/components/canvas/viewport.ts +34 -0
- package/src/components/canvas-renderer/index.tsx +0 -7
- package/src/components/error-boundary/index.tsx +71 -0
- package/src/components/error-boundary/style.module.scss +13 -0
- package/src/components/navigation/drilldown-item/index.tsx +2 -13
- package/src/components/navigation/dropdown-item/index.tsx +11 -19
- package/src/components/navigation/dropdown-item/{style.scss → style.module.scss} +6 -2
- package/src/components/navigation/index.tsx +1 -9
- package/src/components/navigation/items.tsx +0 -7
- package/src/components/navigation/navigation-item/index.tsx +3 -18
- package/src/components/navigation/navigation-item/{style.scss → style.module.scss} +7 -14
- package/src/components/navigation/navigation-screen/index.tsx +6 -26
- package/src/components/navigation/navigation-screen/{style.scss → style.module.scss} +10 -9
- package/src/components/navigation/path-matching.ts +0 -3
- package/src/components/navigation/router-link-item.tsx +0 -11
- package/src/components/navigation/use-sidebar-parent.ts +1 -13
- package/src/components/plugin-area/index.tsx +34 -0
- package/src/components/root/{style.scss → _layout.module.scss} +71 -40
- package/src/components/root/_view-transitions.module.scss +205 -0
- package/src/components/root/index.tsx +44 -35
- package/src/components/root/single-page.tsx +15 -18
- package/src/components/root/style.module.scss +2 -0
- package/src/components/root/use-sync-body-background.ts +1 -4
- package/src/components/save-button/index.tsx +36 -21
- package/src/components/save-button/style.module.scss +10 -0
- package/src/components/save-panel/index.tsx +2 -8
- package/src/components/save-panel/style.module.scss +7 -0
- package/src/components/save-panel/use-save-shortcut.ts +0 -3
- package/src/components/sidebar/index.tsx +5 -12
- package/src/components/sidebar/style.module.scss +29 -0
- package/src/index.tsx +0 -5
- package/src/lock-unlock.ts +0 -3
- package/src/store/actions.ts +18 -4
- package/src/store/index.ts +0 -7
- package/src/store/reducer.ts +19 -3
- package/src/store/selectors.ts +28 -3
- package/src/store/types.ts +37 -6
- package/build-style/style-rtl.css +0 -132
- package/build-style/style.css +0 -132
- package/build-style/view-transitions-rtl.css +0 -189
- package/build-style/view-transitions.css +0 -189
- package/build-types/components/site-hub/index.d.ts +0 -4
- package/build-types/components/site-hub/index.d.ts.map +0 -1
- package/build-types/components/site-icon/index.d.ts +0 -9
- package/build-types/components/site-icon/index.d.ts.map +0 -1
- package/build-types/components/site-icon-link/index.d.ts +0 -8
- package/build-types/components/site-icon-link/index.d.ts.map +0 -1
- package/build-types/components/user-theme-provider/index.d.ts +0 -6
- package/build-types/components/user-theme-provider/index.d.ts.map +0 -1
- package/src/components/save-button/style.scss +0 -9
- package/src/components/sidebar/style.scss +0 -23
- package/src/style.scss +0 -33
- package/src/view-transitions.scss +0 -221
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/canvas/site-preview.tsx"],
|
|
4
|
+
"sourcesContent": ["import { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { focus } from '@wordpress/dom';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Renders the site's front end in an iframe.\n *\n * Shown where the canvas has no entity to edit, so that a route still says\n * something about the site it is configuring.\n *\n * @return The preview, or nothing until the site's address is known.\n */\nexport default function SitePreview() {\n\tconst siteUrl = useSelect( ( select ) => {\n\t\tconst siteData = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t) as { home?: unknown } | undefined;\n\t\treturn siteData?.home;\n\t}, [] );\n\n\t// `home` comes from the REST index. Without a usable URL the iframe would\n\t// resolve its `src` against the current admin page and embed that instead,\n\t// so render nothing until there is one.\n\tif ( typeof siteUrl !== 'string' || ! siteUrl ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<iframe\n\t\t\tsrc={ addQueryArgs( siteUrl, {\n\t\t\t\t// Parameter for hiding the admin bar.\n\t\t\t\twp_site_preview: 1,\n\t\t\t} ) }\n\t\t\ttitle={ __( 'Site Preview' ) }\n\t\t\tstyle={ {\n\t\t\t\tdisplay: 'block',\n\t\t\t\twidth: '100%',\n\t\t\t\theight: '100%',\n\t\t\t\tbackgroundColor: '#fff',\n\t\t\t} }\n\t\t\tonLoad={ ( event ) => {\n\t\t\t\tconst iframeDocument = ( event.target as HTMLIFrameElement )\n\t\t\t\t\t.contentDocument;\n\n\t\t\t\t// Not readable when the site is served from another origin.\n\t\t\t\tif ( ! iframeDocument ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Make interactive elements unclickable.\n\t\t\t\tfocus.focusable\n\t\t\t\t\t.find( iframeDocument.documentElement )\n\t\t\t\t\t.forEach( ( element ) => {\n\t\t\t\t\t\telement.style.pointerEvents = 'none';\n\t\t\t\t\t\telement.tabIndex = -1;\n\t\t\t\t\t\telement.setAttribute( 'aria-hidden', 'true' );\n\t\t\t\t\t} );\n\t\t\t} }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU;AACnB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,iBAAiB;AACnC,SAAS,aAAa;AACtB,SAAS,oBAAoB;AA2B3B;AAjBa,SAAR,cAA+B;AACrC,QAAM,UAAU,UAAW,CAAE,WAAY;AACxC,UAAM,WAAW,OAAQ,SAAU,EAAE;AAAA,MACpC;AAAA,MACA;AAAA,IACD;AACA,WAAO,UAAU;AAAA,EAClB,GAAG,CAAC,CAAE;AAKN,MAAK,OAAO,YAAY,YAAY,CAAE,SAAU;AAC/C,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,KAAM,aAAc,SAAS;AAAA;AAAA,QAE5B,iBAAiB;AAAA,MAClB,CAAE;AAAA,MACF,OAAQ,GAAI,cAAe;AAAA,MAC3B,OAAQ;AAAA,QACP,SAAS;AAAA,QACT,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,iBAAiB;AAAA,MAClB;AAAA,MACA,QAAS,CAAE,UAAW;AACrB,cAAM,iBAAmB,MAAM,OAC7B;AAGF,YAAK,CAAE,gBAAiB;AACvB;AAAA,QACD;AAGA,cAAM,UACJ,KAAM,eAAe,eAAgB,EACrC,QAAS,CAAE,YAAa;AACxB,kBAAQ,MAAM,gBAAgB;AAC9B,kBAAQ,WAAW;AACnB,kBAAQ,aAAc,eAAe,MAAO;AAAA,QAC7C,CAAE;AAAA,MACJ;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// packages/boot/src/components/canvas/use-navigate-to-entity-record.ts
|
|
2
|
+
import { useCallback, useMemo } from "@wordpress/element";
|
|
3
|
+
import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
|
|
4
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
5
|
+
import { store as editorStore } from "@wordpress/editor";
|
|
6
|
+
import { store as noticesStore } from "@wordpress/notices";
|
|
7
|
+
import { decodeEntities } from "@wordpress/html-entities";
|
|
8
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
9
|
+
import {
|
|
10
|
+
useNavigate,
|
|
11
|
+
useSearch,
|
|
12
|
+
privateApis as routePrivateApis
|
|
13
|
+
} from "@wordpress/route";
|
|
14
|
+
import { store as bootStore } from "../../store/index.mjs";
|
|
15
|
+
import { isValidViewport } from "./viewport.mjs";
|
|
16
|
+
import { unlock } from "../../lock-unlock.mjs";
|
|
17
|
+
var { useCanGoBack, useRouter } = unlock(routePrivateApis);
|
|
18
|
+
function useNavigateToEntityRecord() {
|
|
19
|
+
const navigate = useNavigate();
|
|
20
|
+
const search = useSearch({ strict: false });
|
|
21
|
+
const registry = useRegistry();
|
|
22
|
+
const getEntityLink = useSelect(
|
|
23
|
+
(select) => select(bootStore).getEntityLink,
|
|
24
|
+
[]
|
|
25
|
+
);
|
|
26
|
+
const router = useRouter();
|
|
27
|
+
const canGoBack = useCanGoBack();
|
|
28
|
+
const onNavigateToEntityRecord = useCallback(
|
|
29
|
+
(params) => {
|
|
30
|
+
const currentPostType = registry.select(editorStore).getCurrentPostType();
|
|
31
|
+
const currentPostId = registry.select(editorStore).getCurrentPostId();
|
|
32
|
+
const edits = registry.select(coreStore).getEntityRecordEdits(
|
|
33
|
+
"postType",
|
|
34
|
+
currentPostType,
|
|
35
|
+
currentPostId
|
|
36
|
+
);
|
|
37
|
+
const selectedBlock = edits?.selection?.selectionStart?.clientId;
|
|
38
|
+
if (selectedBlock) {
|
|
39
|
+
navigate({
|
|
40
|
+
search: (previous) => ({
|
|
41
|
+
...previous,
|
|
42
|
+
selectedBlock
|
|
43
|
+
}),
|
|
44
|
+
replace: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const requestedViewport = params.viewport?.toLowerCase();
|
|
48
|
+
const hasRequestedViewport = isValidViewport(requestedViewport);
|
|
49
|
+
const to = getEntityLink(params.postType, params.postId);
|
|
50
|
+
if (to) {
|
|
51
|
+
navigate({
|
|
52
|
+
to,
|
|
53
|
+
search: () => ({
|
|
54
|
+
focusMode: true,
|
|
55
|
+
...hasRequestedViewport ? { viewport: requestedViewport } : {}
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
[navigate, registry, getEntityLink]
|
|
61
|
+
);
|
|
62
|
+
const isFocusMode = !!search.focusMode;
|
|
63
|
+
const onNavigateToPreviousEntityRecord = useMemo(
|
|
64
|
+
() => isFocusMode && canGoBack ? () => router.history.back() : void 0,
|
|
65
|
+
[isFocusMode, canGoBack, router]
|
|
66
|
+
);
|
|
67
|
+
return { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord };
|
|
68
|
+
}
|
|
69
|
+
function useActionPerformed(postType) {
|
|
70
|
+
const navigate = useNavigate();
|
|
71
|
+
const { createSuccessNotice } = useDispatch(noticesStore);
|
|
72
|
+
const getEntityLink = useSelect(
|
|
73
|
+
(select) => select(bootStore).getEntityLink,
|
|
74
|
+
[]
|
|
75
|
+
);
|
|
76
|
+
return useCallback(
|
|
77
|
+
(actionId, items) => {
|
|
78
|
+
switch (actionId) {
|
|
79
|
+
case "move-to-trash":
|
|
80
|
+
case "delete-post": {
|
|
81
|
+
const to = postType && getEntityLink(postType);
|
|
82
|
+
if (to) {
|
|
83
|
+
navigate({ to, search: () => ({}) });
|
|
84
|
+
}
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case "duplicate-post": {
|
|
88
|
+
const newItem = items[0];
|
|
89
|
+
const to = getEntityLink(newItem.type, newItem.id);
|
|
90
|
+
if (!to) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
const title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
|
|
94
|
+
createSuccessNotice(
|
|
95
|
+
sprintf(
|
|
96
|
+
// translators: %s: Title of the created post, e.g: "Hello world".
|
|
97
|
+
__('"%s" successfully created.'),
|
|
98
|
+
decodeEntities(title ?? "") || __("(no title)")
|
|
99
|
+
),
|
|
100
|
+
{
|
|
101
|
+
type: "snackbar",
|
|
102
|
+
id: "duplicate-post-action",
|
|
103
|
+
actions: [
|
|
104
|
+
{
|
|
105
|
+
label: __("Edit"),
|
|
106
|
+
onClick: () => navigate({ to })
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
[navigate, createSuccessNotice, getEntityLink, postType]
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
export {
|
|
119
|
+
useNavigateToEntityRecord as default,
|
|
120
|
+
useActionPerformed
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=use-navigate-to-entity-record.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/canvas/use-navigate-to-entity-record.ts"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useMemo } from '@wordpress/element';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tuseNavigate,\n\tuseSearch,\n\tprivateApis as routePrivateApis,\n} from '@wordpress/route';\nimport { store as bootStore } from '../../store';\nimport { isValidViewport } from './viewport';\nimport { unlock } from '../../lock-unlock';\n\nconst { useCanGoBack, useRouter } = unlock( routePrivateApis );\n\n/*\n * The route tree is assembled from routes registered at runtime, so TanStack has\n * no search schema to infer and types `search` against a placeholder. Describe\n * the two calls this module makes instead.\n */\ntype Navigate = ( options: {\n\tto?: string;\n\treplace?: boolean;\n\tsearch?: (\n\t\tprevious: Record< string, unknown >\n\t) => Record< string, unknown >;\n} ) => void;\n\ninterface NavigateParams {\n\tpostType: string;\n\tpostId: string;\n\tviewport?: string;\n}\n\n/**\n * Builds the editor's entity navigation callbacks.\n *\n * The editor uses these to move between an entity and one nested inside it —\n * a template part or a synced pattern reached from the block inspector. They\n * are passed through the editor settings, where `onNavigateToEntityRecord`\n * gates the inspector's edit affordance and `onNavigateToPreviousEntityRecord`\n * gates the document bar's back button.\n *\n * @return The two callbacks, for spreading into the editor settings.\n */\nexport default function useNavigateToEntityRecord() {\n\tconst navigate = useNavigate() as Navigate;\n\tconst search = useSearch( { strict: false } ) as { focusMode?: unknown };\n\tconst registry = useRegistry();\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\tconst router = useRouter();\n\tconst canGoBack = useCanGoBack();\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params: NavigateParams ) => {\n\t\t\t/*\n\t\t\t * Stash the block selected in the entity being left, so returning to\n\t\t\t * it can restore the user's place. The edits hold the external\n\t\t\t * client ID, which `onChangeSelection` has already resolved.\n\t\t\t */\n\t\t\tconst currentPostType = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostType();\n\t\t\tconst currentPostId = (\n\t\t\t\tregistry.select( editorStore ) as any\n\t\t\t ).getCurrentPostId();\n\t\t\tconst edits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityRecordEdits(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPostType,\n\t\t\t\t\tcurrentPostId\n\t\t\t\t) as { selection?: { selectionStart?: { clientId?: string } } };\n\t\t\tconst selectedBlock = edits?.selection?.selectionStart?.clientId;\n\n\t\t\tif ( selectedBlock ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tsearch: ( previous: Record< string, unknown > ) => ( {\n\t\t\t\t\t\t...previous,\n\t\t\t\t\t\tselectedBlock,\n\t\t\t\t\t} ),\n\t\t\t\t\treplace: true,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * An entity can ask to be edited at a particular width — a\n\t\t\t * navigation overlay meant for mobile. The width is where the entity\n\t\t\t * opens, not something the entity being left carries away: a width\n\t\t\t * set from the device preview is view state, and an entity that asks\n\t\t\t * for none opens at the default.\n\t\t\t */\n\t\t\tconst requestedViewport = params.viewport?.toLowerCase();\n\t\t\tconst hasRequestedViewport = isValidViewport( requestedViewport );\n\n\t\t\t/*\n\t\t\t * `focusMode` marks the entity as one navigated into rather than\n\t\t\t * opened directly, which is what offers the way back out. The search\n\t\t\t * is replaced rather than extended so the block stashed above stays\n\t\t\t * with the entity it belongs to.\n\t\t\t */\n\t\t\tconst to = getEntityLink( params.postType, params.postId );\n\n\t\t\tif ( to ) {\n\t\t\t\tnavigate( {\n\t\t\t\t\tto,\n\t\t\t\t\tsearch: () => ( {\n\t\t\t\t\t\tfocusMode: true,\n\t\t\t\t\t\t...( hasRequestedViewport\n\t\t\t\t\t\t\t? { viewport: requestedViewport }\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t} ),\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ navigate, registry, getEntityLink ]\n\t);\n\n\t/*\n\t * Only entities navigated into offer a way back out. The editor reads this\n\t * as the entity being a focused one, giving it the document bar's back\n\t * button and the surrounding padding, so an entity opened directly — from a\n\t * list, say — must not have it. `canGoBack` covers reloading such a URL,\n\t * where the marker survives but the history to return to does not.\n\t */\n\tconst isFocusMode = !! search.focusMode;\n\tconst onNavigateToPreviousEntityRecord = useMemo(\n\t\t() =>\n\t\t\tisFocusMode && canGoBack ? () => router.history.back() : undefined,\n\t\t[ isFocusMode, canGoBack, router ]\n\t);\n\n\treturn { onNavigateToEntityRecord, onNavigateToPreviousEntityRecord };\n}\n\ninterface ActionItem {\n\tid: string | number;\n\ttype: string;\n\ttitle?: string | { rendered?: string };\n}\n\n/**\n * Builds the callback the editor runs after a post action.\n *\n * Actions taken from inside the editor act on the entity being edited, so\n * trashing or deleting one leaves the canvas showing something that is no\n * longer there, and duplicating one gives no way to reach the copy.\n *\n * @param postType Post type rendered in the canvas.\n * @return The callback, for passing to the editor.\n */\nexport function useActionPerformed( postType?: string ) {\n\tconst navigate = useNavigate() as Navigate;\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst getEntityLink = useSelect(\n\t\t( select ) => select( bootStore ).getEntityLink,\n\t\t[]\n\t);\n\n\treturn useCallback(\n\t\t( actionId: string, items: ActionItem[] ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\tcase 'delete-post': {\n\t\t\t\t\tconst to = postType && getEntityLink( postType );\n\n\t\t\t\t\tif ( to ) {\n\t\t\t\t\t\tnavigate( { to, search: () => ( {} ) } );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tcase 'duplicate-post': {\n\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\tconst to = getEntityLink( newItem.type, newItem.id );\n\n\t\t\t\t\tif ( ! to ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst title =\n\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t: newItem.title?.rendered;\n\n\t\t\t\t\t/*\n\t\t\t\t\t * The action has already announced the copy under this id.\n\t\t\t\t\t * Reissuing it under the same id replaces that notice rather\n\t\t\t\t\t * than stacking a second one, and adds the way to reach it.\n\t\t\t\t\t */\n\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t// translators: %s: Title of the created post, e.g: \"Hello world\".\n\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\tdecodeEntities( title ?? '' ) || __( '(no title)' )\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\tonClick: () => navigate( { to } ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\t[ navigate, createSuccessNotice, getEntityLink, postType ]\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,eAAe;AACrC,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,SAAS,iBAAiB;AACnC,SAAS,SAAS,mBAAmB;AACrC,SAAS,SA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AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,UAAU,qBAAqB,eAAe,QAAS;AAAA,EAC1D;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// packages/boot/src/components/canvas/viewport.ts
|
|
2
|
+
var DEFAULT_DEVICE_TYPE = "Desktop";
|
|
3
|
+
var VALID_VIEWPORTS = ["desktop", "tablet", "mobile"];
|
|
4
|
+
function isValidViewport(viewport) {
|
|
5
|
+
return !!viewport && VALID_VIEWPORTS.includes(viewport.toLowerCase());
|
|
6
|
+
}
|
|
7
|
+
function getDeviceType(viewport) {
|
|
8
|
+
if (!isValidViewport(viewport)) {
|
|
9
|
+
return DEFAULT_DEVICE_TYPE;
|
|
10
|
+
}
|
|
11
|
+
const value = viewport.toLowerCase();
|
|
12
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
getDeviceType,
|
|
16
|
+
isValidViewport
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=viewport.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/canvas/viewport.ts"],
|
|
4
|
+
"sourcesContent": ["const DEFAULT_DEVICE_TYPE = 'Desktop';\n\n/*\n * Lowercase in the URL, PascalCase in the editor store. Duplicated in\n * packages/edit-site/src/components/block-editor/viewport.js, in the editor's\n * preview-dropdown choices, and in the block editor's block-visibility\n * constants. Update all four when adding a viewport type.\n */\nconst VALID_VIEWPORTS = [ 'desktop', 'tablet', 'mobile' ];\n\n/**\n * Whether a viewport is one an entity can be asked to be edited at.\n *\n * @param viewport Viewport, as written in the URL.\n * @return Whether the editor has a width for it.\n */\nexport function isValidViewport( viewport?: string ): viewport is string {\n\treturn !! viewport && VALID_VIEWPORTS.includes( viewport.toLowerCase() );\n}\n\n/**\n * The device type a `viewport` search param names.\n *\n * @param viewport Viewport, as written in the URL.\n * @return Device type, Desktop for a viewport the editor has no width for.\n */\nexport function getDeviceType( viewport?: string ) {\n\tif ( ! isValidViewport( viewport ) ) {\n\t\treturn DEFAULT_DEVICE_TYPE;\n\t}\n\n\tconst value = viewport.toLowerCase();\n\treturn value.charAt( 0 ).toUpperCase() + value.slice( 1 );\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,IAAM,sBAAsB;AAQ5B,IAAM,kBAAkB,CAAE,WAAW,UAAU,QAAS;AAQjD,SAAS,gBAAiB,UAAwC;AACxE,SAAO,CAAC,CAAE,YAAY,gBAAgB,SAAU,SAAS,YAAY,CAAE;AACxE;AAQO,SAAS,cAAe,UAAoB;AAClD,MAAK,CAAE,gBAAiB,QAAS,GAAI;AACpC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,SAAS,YAAY;AACnC,SAAO,MAAM,OAAQ,CAAE,EAAE,YAAY,IAAI,MAAM,MAAO,CAAE;AACzD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/canvas-renderer/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { useState, useEffect } from '@wordpress/element';\nimport Canvas from '../canvas';\nimport type { CanvasData } from '../../store/types';\n\ninterface CanvasRendererProps {\n\tcanvas: CanvasData | null | undefined;\n\trouteContentModule?: string;\n}\n\n/**\n * CanvasRenderer handles rendering of both default and custom canvas components.\n * The logic here would have been way simpler if we just render the canvas within\n * the RouteComponent like the other surfaces.\n * The issue is that doing so forces the canvas to remount on every route change,\n * which is not desirable for smooth transitions.\n *\n * - When canvas is undefined: No canvas is rendered\n * - When canvas is null: Loads and renders custom canvas from contentModulePath\n * - When canvas is CanvasData: Renders default Canvas component with editor\n *\n * This component is designed to be rendered at the Root level to prevent\n * remounting when navigating between routes.\n *\n * @param props Component props\n * @param props.canvas Canvas data from route loader\n * @param props.routeContentModule Path to content module for custom canvas\n * @return Canvas renderer\n */\nexport default function CanvasRenderer( {\n\tcanvas,\n\trouteContentModule,\n}: CanvasRendererProps ) {\n\tconst [ CustomCanvas, setCustomCanvas ] = useState< any >( null );\n\n\tuseEffect( () => {\n\t\tif ( canvas === null && routeContentModule ) {\n\t\t\timport( routeContentModule )\n\t\t\t\t.then( ( module ) => {\n\t\t\t\t\tsetCustomCanvas( () => module.canvas );\n\t\t\t\t} )\n\t\t\t\t.catch( ( error ) => {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.error( 'Failed to load custom canvas:', error );\n\t\t\t\t} );\n\t\t} else {\n\t\t\tsetCustomCanvas( null );\n\t\t}\n\t}, [ canvas, routeContentModule ] );\n\n\t// No canvas\n\tif ( canvas === undefined ) {\n\t\treturn null;\n\t}\n\n\t// Custom canvas\n\tif ( canvas === null ) {\n\t\tif ( ! CustomCanvas ) {\n\t\t\treturn null; // Still loading\n\t\t}\n\t\treturn <CustomCanvas />;\n\t}\n\n\t// Default canvas\n\treturn <Canvas canvas={ canvas } />;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,UAAU,iBAAiB;AACpC,OAAO,YAAY;AA0DV;AA/BM,SAAR,eAAiC;AAAA,EACvC;AAAA,EACA;AACD,GAAyB;AACxB,QAAM,CAAE,cAAc,eAAgB,IAAI,SAAiB,IAAK;AAEhE,YAAW,MAAM;AAChB,QAAK,WAAW,QAAQ,oBAAqB;AAC5C,aAAQ,oBACN,KAAM,CAAE,WAAY;AACpB,wBAAiB,MAAM,OAAO,MAAO;AAAA,MACtC,CAAE,EACD,MAAO,CAAE,UAAW;AAEpB,gBAAQ,MAAO,iCAAiC,KAAM;AAAA,MACvD,CAAE;AAAA,IACJ,OAAO;AACN,sBAAiB,IAAK;AAAA,IACvB;AAAA,EACD,GAAG,CAAE,QAAQ,kBAAmB,CAAE;AAGlC,MAAK,WAAW,QAAY;AAC3B,WAAO;AAAA,EACR;AAGA,MAAK,WAAW,MAAO;AACtB,QAAK,CAAE,cAAe;AACrB,aAAO;AAAA,IACR;AACA,WAAO,oBAAC,gBAAa;AAAA,EACtB;AAGA,SAAO,oBAAC,UAAO,QAAkB;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// packages/boot/src/components/error-boundary/index.tsx
|
|
2
|
+
import { Component } from "@wordpress/element";
|
|
3
|
+
import { __ } from "@wordpress/i18n";
|
|
4
|
+
import { Button } from "@wordpress/components";
|
|
5
|
+
import { EmptyState } from "@wordpress/ui";
|
|
6
|
+
import { useCopyToClipboard } from "@wordpress/compose";
|
|
7
|
+
import { caution } from "@wordpress/icons";
|
|
8
|
+
|
|
9
|
+
// packages/style-runtime/src/index.ts
|
|
10
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
11
|
+
function getRuntime() {
|
|
12
|
+
const globalScope = globalThis;
|
|
13
|
+
if (globalScope.__wpStyleRuntime) {
|
|
14
|
+
return globalScope.__wpStyleRuntime;
|
|
15
|
+
}
|
|
16
|
+
globalScope.__wpStyleRuntime = {
|
|
17
|
+
documents: /* @__PURE__ */ new Map(),
|
|
18
|
+
styles: /* @__PURE__ */ new Map(),
|
|
19
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
20
|
+
};
|
|
21
|
+
if (typeof document !== "undefined") {
|
|
22
|
+
registerDocument(document);
|
|
23
|
+
}
|
|
24
|
+
return globalScope.__wpStyleRuntime;
|
|
25
|
+
}
|
|
26
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
27
|
+
if (!targetDocument.head) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
31
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
32
|
+
)) {
|
|
33
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
function injectStyle(targetDocument, hash, css) {
|
|
40
|
+
if (!targetDocument.head) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const runtime = getRuntime();
|
|
44
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
45
|
+
if (!injectedStyles) {
|
|
46
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
47
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
48
|
+
}
|
|
49
|
+
if (injectedStyles.has(hash)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
53
|
+
injectedStyles.add(hash);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const style = targetDocument.createElement("style");
|
|
57
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
58
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
59
|
+
targetDocument.head.appendChild(style);
|
|
60
|
+
injectedStyles.add(hash);
|
|
61
|
+
}
|
|
62
|
+
function registerDocument(targetDocument) {
|
|
63
|
+
const runtime = getRuntime();
|
|
64
|
+
runtime.documents.set(
|
|
65
|
+
targetDocument,
|
|
66
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
67
|
+
);
|
|
68
|
+
for (const [hash, css] of runtime.styles) {
|
|
69
|
+
injectStyle(targetDocument, hash, css);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
const count = runtime.documents.get(targetDocument);
|
|
73
|
+
if (count === void 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (count <= 1) {
|
|
77
|
+
runtime.documents.delete(targetDocument);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function registerStyle(hash, css) {
|
|
84
|
+
const runtime = getRuntime();
|
|
85
|
+
runtime.styles.set(hash, css);
|
|
86
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
87
|
+
injectStyle(targetDocument, hash, css);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// packages/boot/src/components/error-boundary/style.module.scss
|
|
92
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
93
|
+
registerStyle("4780fe0b1b", "._4d71ad18128c9cb8__error-boundary{align-items:center;box-sizing:border-box;display:flex;justify-content:center;min-height:100%;padding:16px}");
|
|
94
|
+
}
|
|
95
|
+
var style_module_default = { "error-boundary": "_4d71ad18128c9cb8__error-boundary" };
|
|
96
|
+
|
|
97
|
+
// packages/boot/src/components/error-boundary/index.tsx
|
|
98
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
99
|
+
function CopyErrorButton({ error }) {
|
|
100
|
+
const ref = useCopyToClipboard(() => error.stack ?? String(error));
|
|
101
|
+
return /* @__PURE__ */ jsx(Button, { __next40pxDefaultSize: true, variant: "secondary", ref, children: __("Copy error") });
|
|
102
|
+
}
|
|
103
|
+
var ErrorBoundary = class extends Component {
|
|
104
|
+
constructor(props) {
|
|
105
|
+
super(props);
|
|
106
|
+
this.state = { error: null };
|
|
107
|
+
}
|
|
108
|
+
static getDerivedStateFromError(error) {
|
|
109
|
+
return { error };
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
const { error } = this.state;
|
|
113
|
+
if (!error) {
|
|
114
|
+
return this.props.children;
|
|
115
|
+
}
|
|
116
|
+
return /* @__PURE__ */ jsx("div", { className: style_module_default["error-boundary"], children: /* @__PURE__ */ jsxs(EmptyState.Root, { children: [
|
|
117
|
+
/* @__PURE__ */ jsx(EmptyState.Icon, { icon: caution }),
|
|
118
|
+
/* @__PURE__ */ jsx(EmptyState.Title, { children: __("Something went wrong") }),
|
|
119
|
+
/* @__PURE__ */ jsx(EmptyState.Description, { children: __(
|
|
120
|
+
"This part of the screen could not be displayed. Reloading the page may help."
|
|
121
|
+
) }),
|
|
122
|
+
/* @__PURE__ */ jsx(EmptyState.Actions, { children: /* @__PURE__ */ jsx(CopyErrorButton, { error }) })
|
|
123
|
+
] }) });
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
export {
|
|
127
|
+
ErrorBoundary as default
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/error-boundary/index.tsx", "../../../../style-runtime/src/index.ts", "../../../src/components/error-boundary/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from 'react';\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { EmptyState } from '@wordpress/ui';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { caution } from '@wordpress/icons';\nimport styles from './style.module.scss';\n\ninterface Props {\n\tchildren: ReactNode;\n}\n\ninterface State {\n\terror: Error | null;\n}\n\nfunction CopyErrorButton( { error }: { error: Error } ) {\n\tconst ref = useCopyToClipboard( () => error.stack ?? String( error ) );\n\n\treturn (\n\t\t<Button __next40pxDefaultSize variant=\"secondary\" ref={ ref }>\n\t\t\t{ __( 'Copy error' ) }\n\t\t</Button>\n\t);\n}\n\n/**\n * Contains a failure to one surface, so a screen keeps working around it.\n *\n * Wrapping each surface separately means a stage that throws leaves the\n * navigation, the canvas and the way to save reachable, rather than taking the\n * whole screen down with it.\n */\nexport default class ErrorBoundary extends Component< Props, State > {\n\tconstructor( props: Props ) {\n\t\tsuper( props );\n\t\tthis.state = { error: null };\n\t}\n\n\tstatic getDerivedStateFromError( error: Error ): State {\n\t\treturn { error };\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<div className={ styles[ 'error-boundary' ] }>\n\t\t\t\t<EmptyState.Root>\n\t\t\t\t\t<EmptyState.Icon icon={ caution } />\n\t\t\t\t\t<EmptyState.Title>\n\t\t\t\t\t\t{ __( 'Something went wrong' ) }\n\t\t\t\t\t</EmptyState.Title>\n\t\t\t\t\t<EmptyState.Description>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'This part of the screen could not be displayed. Reloading the page may help.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</EmptyState.Description>\n\t\t\t\t\t<EmptyState.Actions>\n\t\t\t\t\t\t<CopyErrorButton error={ error } />\n\t\t\t\t\t</EmptyState.Actions>\n\t\t\t\t</EmptyState.Root>\n\t\t\t</div>\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(\"4780fe0b1b\", \"._4d71ad18128c9cb8__error-boundary{align-items:center;box-sizing:border-box;display:flex;justify-content:center;min-height:100%;padding:16px}\");\n}\nexport default {\"error-boundary\":\"_4d71ad18128c9cb8__error-boundary\"};\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AACnB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,0BAA0B;AACnC,SAAS,eAAe;;;ACIxB,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;AA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MAClC,oBAAC,WAAW,OAAX,EACE,aAAI,sBAAuB,GAC9B;AAAA,MACA,oBAAC,WAAW,aAAX,EACE;AAAA,QACD;AAAA,MACD,GACD;AAAA,MACA,oBAAC,WAAW,SAAX,EACA,8BAAC,mBAAgB,OAAgB,GAClC;AAAA,OACD,GACD;AAAA,EAEF;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -9,6 +9,96 @@ import {
|
|
|
9
9
|
import { isRTL } from "@wordpress/i18n";
|
|
10
10
|
import { chevronRightSmall, chevronLeftSmall } from "@wordpress/icons";
|
|
11
11
|
import { wrapIcon } from "../items.mjs";
|
|
12
|
+
|
|
13
|
+
// packages/style-runtime/src/index.ts
|
|
14
|
+
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
15
|
+
function getRuntime() {
|
|
16
|
+
const globalScope = globalThis;
|
|
17
|
+
if (globalScope.__wpStyleRuntime) {
|
|
18
|
+
return globalScope.__wpStyleRuntime;
|
|
19
|
+
}
|
|
20
|
+
globalScope.__wpStyleRuntime = {
|
|
21
|
+
documents: /* @__PURE__ */ new Map(),
|
|
22
|
+
styles: /* @__PURE__ */ new Map(),
|
|
23
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
24
|
+
};
|
|
25
|
+
if (typeof document !== "undefined") {
|
|
26
|
+
registerDocument(document);
|
|
27
|
+
}
|
|
28
|
+
return globalScope.__wpStyleRuntime;
|
|
29
|
+
}
|
|
30
|
+
function documentContainsStyleHash(targetDocument, hash) {
|
|
31
|
+
if (!targetDocument.head) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
for (const style of targetDocument.head.querySelectorAll(
|
|
35
|
+
`style[${STYLE_HASH_ATTRIBUTE}]`
|
|
36
|
+
)) {
|
|
37
|
+
if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
function injectStyle(targetDocument, hash, css) {
|
|
44
|
+
if (!targetDocument.head) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const runtime = getRuntime();
|
|
48
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
49
|
+
if (!injectedStyles) {
|
|
50
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
51
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
52
|
+
}
|
|
53
|
+
if (injectedStyles.has(hash)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
57
|
+
injectedStyles.add(hash);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const style = targetDocument.createElement("style");
|
|
61
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
62
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
63
|
+
targetDocument.head.appendChild(style);
|
|
64
|
+
injectedStyles.add(hash);
|
|
65
|
+
}
|
|
66
|
+
function registerDocument(targetDocument) {
|
|
67
|
+
const runtime = getRuntime();
|
|
68
|
+
runtime.documents.set(
|
|
69
|
+
targetDocument,
|
|
70
|
+
(runtime.documents.get(targetDocument) ?? 0) + 1
|
|
71
|
+
);
|
|
72
|
+
for (const [hash, css] of runtime.styles) {
|
|
73
|
+
injectStyle(targetDocument, hash, css);
|
|
74
|
+
}
|
|
75
|
+
return () => {
|
|
76
|
+
const count = runtime.documents.get(targetDocument);
|
|
77
|
+
if (count === void 0) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (count <= 1) {
|
|
81
|
+
runtime.documents.delete(targetDocument);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function registerStyle(hash, css) {
|
|
88
|
+
const runtime = getRuntime();
|
|
89
|
+
runtime.styles.set(hash, css);
|
|
90
|
+
for (const targetDocument of runtime.documents.keys()) {
|
|
91
|
+
injectStyle(targetDocument, hash, css);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// packages/boot/src/components/navigation/navigation-item/style.module.scss
|
|
96
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
97
|
+
registerStyle("74796ab776", ".d5331ded354c389a__item.d5331ded354c389a__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}.d5331ded354c389a__item.d5331ded354c389a__item:focus,.d5331ded354c389a__item.d5331ded354c389a__item:hover,.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}.d5331ded354c389a__item.d5331ded354c389a__item svg:last-child{padding:4px}.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=page],.d5331ded354c389a__item.d5331ded354c389a__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}.d5331ded354c389a__item.d5331ded354c389a__item:focus-visible{transform:translateZ(0)}.d5331ded354c389a__item._44ce5374f19a05f7__is-compact{min-height:24px}");
|
|
98
|
+
}
|
|
99
|
+
var style_module_default = { "item": "d5331ded354c389a__item", "is-compact": "_44ce5374f19a05f7__is-compact" };
|
|
100
|
+
|
|
101
|
+
// packages/boot/src/components/navigation/drilldown-item/index.tsx
|
|
12
102
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
103
|
function DrilldownItem({
|
|
14
104
|
className,
|
|
@@ -25,7 +115,7 @@ function DrilldownItem({
|
|
|
25
115
|
return /* @__PURE__ */ jsx(
|
|
26
116
|
Item,
|
|
27
117
|
{
|
|
28
|
-
className: clsx(
|
|
118
|
+
className: clsx(style_module_default.item, className),
|
|
29
119
|
onClick: handleClick,
|
|
30
120
|
children: /* @__PURE__ */ jsxs(
|
|
31
121
|
HStack,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/navigation/drilldown-item/index.tsx"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
3
|
+
"sources": ["../../../../src/components/navigation/drilldown-item/index.tsx", "../../../../../style-runtime/src/index.ts", "../../../../src/components/navigation/navigation-item/style.module.scss"],
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport type { ReactNode } from 'react';\nimport {\n\tFlexBlock,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tIcon as WCIcon,\n} from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\nimport { chevronRightSmall, chevronLeftSmall } from '@wordpress/icons';\nimport { wrapIcon } from '../items';\nimport type { IconType } from '../../../store/types';\nimport styles from '../navigation-item/style.module.scss';\n\ninterface DrilldownItemProps {\n\t/**\n\t * Optional CSS class name.\n\t */\n\tclassName?: string;\n\t/**\n\t * Identifier of the navigation item.\n\t */\n\tid: string;\n\t/**\n\t * Icon to display with the navigation item.\n\t */\n\ticon?: IconType;\n\t/**\n\t * Whether to show placeholder icons for alignment.\n\t */\n\tshouldShowPlaceholder?: boolean;\n\t/**\n\t * Content to display inside the navigation item.\n\t */\n\tchildren: ReactNode;\n\t/**\n\t * Function to handle sidebar navigation when the item is clicked.\n\t */\n\tonNavigate: ( {\n\t\tid,\n\t\tdirection,\n\t}: {\n\t\tid?: string;\n\t\tdirection: 'forward' | 'backward';\n\t} ) => void;\n}\n\nexport default function DrilldownItem( {\n\tclassName,\n\tid,\n\ticon,\n\tshouldShowPlaceholder = true,\n\tchildren,\n\tonNavigate,\n}: DrilldownItemProps ) {\n\tconst handleClick = ( e: React.MouseEvent ) => {\n\t\te.preventDefault();\n\t\tonNavigate( { id, direction: 'forward' } );\n\t};\n\n\treturn (\n\t\t<Item\n\t\t\tclassName={ clsx( styles.item, className ) }\n\t\t\tonClick={ handleClick }\n\t\t>\n\t\t\t<HStack\n\t\t\t\tjustify=\"flex-start\"\n\t\t\t\tspacing={ 2 }\n\t\t\t\tstyle={ { flexGrow: '1' } }\n\t\t\t>\n\t\t\t\t{ wrapIcon( icon, shouldShowPlaceholder ) }\n\t\t\t\t<FlexBlock>{ children }</FlexBlock>\n\t\t\t\t<WCIcon\n\t\t\t\t\ticon={ isRTL() ? chevronLeftSmall : chevronRightSmall }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t</Item>\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(\"74796ab776\", \".d5331ded354c389a__item.d5331ded354c389a__item{align-items:center;border:none;border-radius:var(--wpds-border-radius-sm,2px);color:var(--wpds-color-foreground-interactive-neutral,#1e1e1e);display:flex;font-family:-apple-system,system-ui,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px;font-weight:var(--wpds-typography-font-weight-default,400);line-height:20px;margin-block-end:4px;margin-inline:12px;min-height:32px;padding-block:0;padding-inline:4px;width:calc(100% - 24px)}.d5331ded354c389a__item.d5331ded354c389a__item:focus,.d5331ded354c389a__item.d5331ded354c389a__item:hover,.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=true]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000))}.d5331ded354c389a__item.d5331ded354c389a__item svg:last-child{padding:4px}.d5331ded354c389a__item.d5331ded354c389a__item[aria-current=page],.d5331ded354c389a__item.d5331ded354c389a__item[data-status=active]{color:var(--wpds-color-foreground-interactive-brand-active,color-mix(in oklch,var(--wp-admin-theme-color,#3858e9) 52%,#000));font-weight:var(--wpds-typography-font-weight-emphasis,600)}.d5331ded354c389a__item.d5331ded354c389a__item:focus-visible{transform:translateZ(0)}.d5331ded354c389a__item._44ce5374f19a05f7__is-compact{min-height:24px}\");\n}\nexport default {\"item\":\"d5331ded354c389a__item\",\"is-compact\":\"_44ce5374f19a05f7__is-compact\"};\n"],
|
|
5
|
+
"mappings": ";AAAA,OAAO,UAAU;AAEjB;AAAA,EACC;AAAA,EACA,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,QAAQ;AAAA,OACF;AACP,SAAS,aAAa;AACtB,SAAS,mBAAmB,wBAAwB;AACpD,SAAS,gBAAgB;;;ACAzB,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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