@wordpress/boot 0.25.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-module/components/app/index.mjs +29 -53
- package/build-module/components/app/index.mjs.map +1 -7
- package/build-module/components/app/router.mjs +238 -214
- package/build-module/components/app/router.mjs.map +1 -7
- package/build-module/components/app/use-route-title.mjs +35 -42
- package/build-module/components/app/use-route-title.mjs.map +1 -7
- package/build-module/components/canvas/back-button.mjs +21 -20
- package/build-module/components/canvas/back-button.mjs.map +1 -7
- package/build-module/components/canvas/index.mjs +104 -130
- package/build-module/components/canvas/index.mjs.map +1 -7
- package/build-module/components/canvas/site-preview.mjs +36 -43
- package/build-module/components/canvas/site-preview.mjs.map +1 -7
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs +109 -113
- package/build-module/components/canvas/use-navigate-to-entity-record.mjs.map +1 -7
- package/build-module/components/canvas/viewport.mjs +25 -13
- package/build-module/components/canvas/viewport.mjs.map +1 -7
- package/build-module/components/canvas-renderer/index.mjs +40 -32
- package/build-module/components/canvas-renderer/index.mjs.map +1 -7
- package/build-module/components/error-boundary/index.mjs +161 -109
- package/build-module/components/error-boundary/index.mjs.map +1 -7
- package/build-module/components/navigation/drilldown-item/index.mjs +124 -127
- package/build-module/components/navigation/drilldown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/dropdown-item/index.mjs +156 -173
- package/build-module/components/navigation/dropdown-item/index.mjs.map +1 -7
- package/build-module/components/navigation/index.mjs +55 -90
- package/build-module/components/navigation/index.mjs.map +1 -7
- package/build-module/components/navigation/items.mjs +51 -53
- package/build-module/components/navigation/items.mjs.map +1 -7
- package/build-module/components/navigation/navigation-item/index.mjs +120 -114
- package/build-module/components/navigation/navigation-item/index.mjs.map +1 -7
- package/build-module/components/navigation/navigation-screen/index.mjs +192 -185
- package/build-module/components/navigation/navigation-screen/index.mjs.map +1 -7
- package/build-module/components/navigation/path-matching.mjs +74 -73
- package/build-module/components/navigation/path-matching.mjs.map +1 -7
- package/build-module/components/navigation/router-link-item.mjs +13 -11
- package/build-module/components/navigation/router-link-item.mjs.map +1 -7
- package/build-module/components/navigation/use-sidebar-parent.mjs +37 -48
- package/build-module/components/navigation/use-sidebar-parent.mjs.map +1 -7
- package/build-module/components/plugin-area/index.mjs +20 -24
- package/build-module/components/plugin-area/index.mjs.map +1 -7
- package/build-module/components/root/index.mjs +228 -243
- package/build-module/components/root/index.mjs.map +1 -7
- package/build-module/components/root/single-page.mjs +174 -148
- package/build-module/components/root/single-page.mjs.map +1 -7
- package/build-module/components/root/use-sync-body-background.mjs +28 -22
- package/build-module/components/root/use-sync-body-background.mjs.map +1 -7
- package/build-module/components/save-button/index.mjs +170 -214
- package/build-module/components/save-button/index.mjs.map +1 -7
- package/build-module/components/save-panel/index.mjs +110 -106
- package/build-module/components/save-panel/index.mjs.map +1 -7
- package/build-module/components/save-panel/use-save-shortcut.mjs +42 -51
- package/build-module/components/save-panel/use-save-shortcut.mjs.map +1 -7
- package/build-module/components/sidebar/index.mjs +126 -104
- package/build-module/components/sidebar/index.mjs.map +1 -7
- package/build-module/index.mjs +1 -7
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/store/actions.mjs +34 -31
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +9 -11
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +48 -55
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +21 -16
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/types.mjs +0 -1
- package/build-types/components/error-boundary/index.d.ts.map +1 -1
- package/build-types/components/root/index.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/error-boundary/index.tsx +52 -6
- package/src/components/navigation/navigation-screen/index.tsx +2 -2
- package/src/components/root/_layout.module.scss +1 -1
- package/src/components/root/index.tsx +7 -3
- package/build-module/index.mjs.map +0 -7
- package/build-module/store/types.mjs.map +0 -7
|
@@ -1,201 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
__unstableMotion as motion,
|
|
5
|
-
__unstableAnimatePresence as AnimatePresence,
|
|
6
|
-
Button,
|
|
7
|
-
__experimentalHStack as HStack
|
|
8
|
-
} from "@wordpress/components";
|
|
9
|
-
import { isRTL, __ } from "@wordpress/i18n";
|
|
10
|
-
import { chevronRight, chevronLeft } from "@wordpress/icons";
|
|
1
|
+
import { Button, __experimentalHStack, __experimentalHeading, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
|
|
2
|
+
import { __, isRTL } from "@wordpress/i18n";
|
|
3
|
+
import { chevronLeft, chevronRight } from "@wordpress/icons";
|
|
11
4
|
import { useReducedMotion } from "@wordpress/compose";
|
|
12
|
-
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
6
|
// packages/style-runtime/src/index.ts
|
|
14
|
-
|
|
7
|
+
const STYLE_HASH_ATTRIBUTE = "data-wp-hash";
|
|
8
|
+
/**
|
|
9
|
+
* Returns the shared style runtime registry.
|
|
10
|
+
*
|
|
11
|
+
* The registry is stored on `globalThis` so separately bundled copies of this
|
|
12
|
+
* package can coordinate through the same document and style maps.
|
|
13
|
+
*
|
|
14
|
+
* @return The shared runtime registry.
|
|
15
|
+
*/
|
|
15
16
|
function getRuntime() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (typeof document !== "undefined") {
|
|
26
|
-
registerDocument(document);
|
|
27
|
-
}
|
|
28
|
-
return globalScope.__wpStyleRuntime;
|
|
17
|
+
const globalScope = globalThis;
|
|
18
|
+
if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
|
|
19
|
+
globalScope.__wpStyleRuntime = {
|
|
20
|
+
documents: /* @__PURE__ */ new Map(),
|
|
21
|
+
styles: /* @__PURE__ */ new Map(),
|
|
22
|
+
injectedStyles: /* @__PURE__ */ new WeakMap()
|
|
23
|
+
};
|
|
24
|
+
if (typeof document !== "undefined") registerDocument(document);
|
|
25
|
+
return globalScope.__wpStyleRuntime;
|
|
29
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Checks whether a document already contains a style tag for a hash.
|
|
29
|
+
*
|
|
30
|
+
* @param targetDocument Document to inspect.
|
|
31
|
+
* @param hash Stable hash for the transformed CSS.
|
|
32
|
+
*
|
|
33
|
+
* @return Whether the style hash already exists in the document.
|
|
34
|
+
*/
|
|
30
35
|
function documentContainsStyleHash(targetDocument, hash) {
|
|
31
|
-
|
|
32
|
-
|
|
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;
|
|
36
|
+
if (!targetDocument.head) return false;
|
|
37
|
+
for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
|
|
38
|
+
return false;
|
|
42
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Injects a registered style into a document, unless that document already
|
|
42
|
+
* contains a style tag for the same hash.
|
|
43
|
+
*
|
|
44
|
+
* @param targetDocument Document to inject the style into.
|
|
45
|
+
* @param hash Stable hash for the transformed CSS.
|
|
46
|
+
* @param css CSS text to inject.
|
|
47
|
+
*/
|
|
43
48
|
function injectStyle(targetDocument, hash, css) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
62
|
-
style.appendChild(targetDocument.createTextNode(css));
|
|
63
|
-
targetDocument.head.appendChild(style);
|
|
64
|
-
injectedStyles.add(hash);
|
|
49
|
+
if (!targetDocument.head) return;
|
|
50
|
+
const runtime = getRuntime();
|
|
51
|
+
let injectedStyles = runtime.injectedStyles.get(targetDocument);
|
|
52
|
+
if (!injectedStyles) {
|
|
53
|
+
injectedStyles = /* @__PURE__ */ new Set();
|
|
54
|
+
runtime.injectedStyles.set(targetDocument, injectedStyles);
|
|
55
|
+
}
|
|
56
|
+
if (injectedStyles.has(hash)) return;
|
|
57
|
+
if (documentContainsStyleHash(targetDocument, hash)) {
|
|
58
|
+
injectedStyles.add(hash);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const style = targetDocument.createElement("style");
|
|
62
|
+
style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
|
|
63
|
+
style.appendChild(targetDocument.createTextNode(css));
|
|
64
|
+
targetDocument.head.appendChild(style);
|
|
65
|
+
injectedStyles.add(hash);
|
|
65
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Registers a document as a style injection target.
|
|
69
|
+
*
|
|
70
|
+
* Existing registered styles are replayed into the document immediately.
|
|
71
|
+
* Documents are reference-counted so multiple providers can safely register the
|
|
72
|
+
* same document without one cleanup removing it while another registration is
|
|
73
|
+
* still active.
|
|
74
|
+
*
|
|
75
|
+
* @param targetDocument Document to receive registered styles.
|
|
76
|
+
* @return Cleanup function that unregisters this document registration.
|
|
77
|
+
*/
|
|
66
78
|
function registerDocument(targetDocument) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
if (count <= 1) {
|
|
81
|
-
runtime.documents.delete(targetDocument);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
runtime.documents.set(targetDocument, count - 1);
|
|
85
|
-
};
|
|
79
|
+
const runtime = getRuntime();
|
|
80
|
+
runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
|
|
81
|
+
for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
|
|
82
|
+
return () => {
|
|
83
|
+
const count = runtime.documents.get(targetDocument);
|
|
84
|
+
if (count === void 0) return;
|
|
85
|
+
if (count <= 1) {
|
|
86
|
+
runtime.documents.delete(targetDocument);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
runtime.documents.set(targetDocument, count - 1);
|
|
90
|
+
};
|
|
86
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Registers a style and injects it into all registered documents.
|
|
94
|
+
*
|
|
95
|
+
* The hash is used as the deduplication key, so calling this repeatedly with
|
|
96
|
+
* the same hash will not add duplicate style tags to a document.
|
|
97
|
+
* Registered styles are retained for the lifetime of the page so they can be
|
|
98
|
+
* replayed into documents that are registered later.
|
|
99
|
+
*
|
|
100
|
+
* @param hash Stable hash for the transformed CSS.
|
|
101
|
+
* @param css CSS text to inject.
|
|
102
|
+
*/
|
|
87
103
|
function registerStyle(hash, css) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
injectStyle(targetDocument, hash, css);
|
|
92
|
-
}
|
|
104
|
+
const runtime = getRuntime();
|
|
105
|
+
runtime.styles.set(hash, css);
|
|
106
|
+
for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
|
|
93
107
|
}
|
|
94
|
-
|
|
95
108
|
// packages/boot/src/components/navigation/navigation-screen/style.module.scss
|
|
96
|
-
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
109
|
+
if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("587e8bd148", "._8ee768104cd6989d__screen{padding-block-end:4px}._8ee768104cd6989d__screen .components-text{color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._86eaeab8cbb71ab3__title-icon{padding-block-end:8px;padding-block-start:12px;padding-inline-end:16px;padding-inline-start:16px;position:sticky;top:0}.c70a3969756ff3ce__title{flex-grow:1;overflow-wrap:break-word}.c70a3969756ff3ce__title.c70a3969756ff3ce__title,.c70a3969756ff3ce__title.c70a3969756ff3ce__title .c70a3969756ff3ce__title{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);line-height:32px}.f21c64ba84799e5c__actions{display:flex;flex-shrink:0}");
|
|
110
|
+
var style_module_default = {
|
|
111
|
+
"screen": "_8ee768104cd6989d__screen",
|
|
112
|
+
"title-icon": "_86eaeab8cbb71ab3__title-icon",
|
|
113
|
+
"title": "c70a3969756ff3ce__title",
|
|
114
|
+
"actions": "f21c64ba84799e5c__actions"
|
|
115
|
+
};
|
|
101
116
|
// packages/boot/src/components/navigation/navigation-screen/index.tsx
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
})
|
|
117
|
+
const ANIMATION_DURATION = .3;
|
|
118
|
+
const slideVariants = {
|
|
119
|
+
initial: (direction) => ({
|
|
120
|
+
x: (direction === "forward" ? 100 : -100) * (isRTL() ? -1 : 1),
|
|
121
|
+
opacity: 0
|
|
122
|
+
}),
|
|
123
|
+
animate: {
|
|
124
|
+
x: 0,
|
|
125
|
+
opacity: 1
|
|
126
|
+
},
|
|
127
|
+
exit: (direction) => ({
|
|
128
|
+
x: (direction === "forward" ? 100 : -100) * (isRTL() ? -1 : 1),
|
|
129
|
+
opacity: 0
|
|
130
|
+
})
|
|
117
131
|
};
|
|
118
|
-
function NavigationScreen({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
]
|
|
192
|
-
},
|
|
193
|
-
navigationKey
|
|
194
|
-
) })
|
|
195
|
-
}
|
|
196
|
-
);
|
|
132
|
+
function NavigationScreen({ isRoot, title, actions, content, description, animationDirection, backMenuItem, backButtonRef, navigationKey, onNavigate }) {
|
|
133
|
+
const icon = isRTL() ? chevronRight : chevronLeft;
|
|
134
|
+
const disableMotion = useReducedMotion();
|
|
135
|
+
const handleBackClick = (e) => {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
onNavigate({
|
|
138
|
+
id: backMenuItem,
|
|
139
|
+
direction: "backward"
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
return /* @__PURE__ */ jsx("div", {
|
|
143
|
+
className: style_module_default.screen,
|
|
144
|
+
style: {
|
|
145
|
+
overflow: "hidden",
|
|
146
|
+
position: "relative",
|
|
147
|
+
display: "grid",
|
|
148
|
+
gridTemplateColumns: "1fr",
|
|
149
|
+
gridTemplateRows: "1fr"
|
|
150
|
+
},
|
|
151
|
+
children: /* @__PURE__ */ jsx(__unstableAnimatePresence, {
|
|
152
|
+
initial: false,
|
|
153
|
+
children: /* @__PURE__ */ jsxs(__unstableMotion.div, {
|
|
154
|
+
custom: animationDirection,
|
|
155
|
+
variants: slideVariants,
|
|
156
|
+
initial: "initial",
|
|
157
|
+
animate: "animate",
|
|
158
|
+
exit: "exit",
|
|
159
|
+
transition: {
|
|
160
|
+
type: "tween",
|
|
161
|
+
duration: disableMotion ? 0 : ANIMATION_DURATION,
|
|
162
|
+
ease: [
|
|
163
|
+
.33,
|
|
164
|
+
0,
|
|
165
|
+
0,
|
|
166
|
+
1
|
|
167
|
+
]
|
|
168
|
+
},
|
|
169
|
+
style: {
|
|
170
|
+
width: "100%",
|
|
171
|
+
gridColumn: "1",
|
|
172
|
+
gridRow: "1"
|
|
173
|
+
},
|
|
174
|
+
children: [
|
|
175
|
+
/* @__PURE__ */ jsxs(__experimentalHStack, {
|
|
176
|
+
spacing: 2,
|
|
177
|
+
className: style_module_default["title-icon"],
|
|
178
|
+
children: [
|
|
179
|
+
!isRoot && /* @__PURE__ */ jsx(Button, {
|
|
180
|
+
ref: backButtonRef,
|
|
181
|
+
icon,
|
|
182
|
+
onClick: handleBackClick,
|
|
183
|
+
label: __("Back"),
|
|
184
|
+
size: "small",
|
|
185
|
+
variant: "tertiary"
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ jsx(__experimentalHeading, {
|
|
188
|
+
className: style_module_default.title,
|
|
189
|
+
level: 1,
|
|
190
|
+
size: "15px",
|
|
191
|
+
children: title
|
|
192
|
+
}),
|
|
193
|
+
actions && /* @__PURE__ */ jsx("div", {
|
|
194
|
+
className: style_module_default.actions,
|
|
195
|
+
children: actions
|
|
196
|
+
})
|
|
197
|
+
]
|
|
198
|
+
}),
|
|
199
|
+
description && /* @__PURE__ */ jsx("div", { children: description }),
|
|
200
|
+
content
|
|
201
|
+
]
|
|
202
|
+
}, navigationKey)
|
|
203
|
+
})
|
|
204
|
+
});
|
|
197
205
|
}
|
|
198
|
-
export {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
//# sourceMappingURL=index.mjs.map
|
|
206
|
+
export { NavigationScreen as default };
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/components/navigation/navigation-screen/index.tsx", "../../../../../style-runtime/src/index.ts", "../../../../src/components/navigation/navigation-screen/style.module.scss"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode, RefObject } from 'react';\nimport {\n\t__experimentalHeading as Heading,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\tButton,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useReducedMotion } from '@wordpress/compose';\nimport styles from './style.module.scss';\n\nconst ANIMATION_DURATION = 0.3;\nconst slideVariants = {\n\tinitial: ( direction: 'forward' | 'backward' ) => ( {\n\t\tx: direction === 'forward' ? 100 : -100,\n\t\topacity: 0,\n\t} ),\n\tanimate: {\n\t\tx: 0,\n\t\topacity: 1,\n\t},\n\texit: ( direction: 'forward' | 'backward' ) => ( {\n\t\tx: direction === 'forward' ? 100 : -100,\n\t\topacity: 0,\n\t} ),\n};\n\nexport default function NavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n\tdescription,\n\tanimationDirection,\n\tbackMenuItem,\n\tbackButtonRef,\n\tnavigationKey,\n\tonNavigate,\n}: {\n\tisRoot?: boolean;\n\ttitle: string;\n\tactions?: ReactNode;\n\tcontent: ReactNode;\n\tdescription?: ReactNode;\n\tbackMenuItem?: string;\n\tbackButtonRef?: RefObject< HTMLButtonElement | null >;\n\tanimationDirection?: 'forward' | 'backward';\n\tnavigationKey?: string;\n\tonNavigate: ( {\n\t\tid,\n\t\tdirection,\n\t}: {\n\t\tid?: string;\n\t\tdirection: 'forward' | 'backward';\n\t} ) => void;\n} ) {\n\tconst icon = isRTL() ? chevronRight : chevronLeft;\n\tconst disableMotion = useReducedMotion();\n\n\tconst handleBackClick = ( e: React.MouseEvent ) => {\n\t\te.preventDefault();\n\t\tonNavigate( { id: backMenuItem, direction: 'backward' } );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ styles.screen }\n\t\t\tstyle={ {\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'grid',\n\t\t\t\tgridTemplateColumns: '1fr',\n\t\t\t\tgridTemplateRows: '1fr',\n\t\t\t} }\n\t\t>\n\t\t\t<AnimatePresence initial={ false }>\n\t\t\t\t<motion.div\n\t\t\t\t\tkey={ navigationKey }\n\t\t\t\t\tcustom={ animationDirection }\n\t\t\t\t\tvariants={ slideVariants }\n\t\t\t\t\tinitial=\"initial\"\n\t\t\t\t\tanimate=\"animate\"\n\t\t\t\t\texit=\"exit\"\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : ANIMATION_DURATION,\n\t\t\t\t\t\tease: [ 0.33, 0, 0, 1 ],\n\t\t\t\t\t} }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\tgridColumn: '1',\n\t\t\t\t\t\tgridRow: '1',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack spacing={ 2 } className={ styles[ 'title-icon' ] }>\n\t\t\t\t\t\t{ ! isRoot && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tref={ backButtonRef }\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\tonClick={ handleBackClick }\n\t\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\tclassName={ styles.title }\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsize=\"15px\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t{ actions && (\n\t\t\t\t\t\t\t<div className={ styles.actions }>{ actions }</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\n\t\t\t\t\t{ description && <div>{ description }</div> }\n\n\t\t\t\t\t{ content }\n\t\t\t\t</motion.div>\n\t\t\t</AnimatePresence>\n\t\t</div>\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(\"9bfc8fef50\", \".c93eb5f7b870f29c__screen{padding-block-end:4px}.c93eb5f7b870f29c__screen .components-text{color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}.bee113ef4a391bcd__title-icon{padding-block-end:8px;padding-block-start:12px;padding-inline-end:16px;padding-inline-start:16px;position:sticky;top:0}._2f6050d2407c9dee__title{flex-grow:1;overflow-wrap:break-word}._2f6050d2407c9dee__title._2f6050d2407c9dee__title,._2f6050d2407c9dee__title._2f6050d2407c9dee__title ._2f6050d2407c9dee__title{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);line-height:32px}.e78f7a9cf7e91164__actions{display:flex;flex-shrink:0}\");\n}\nexport default {\"screen\":\"c93eb5f7b870f29c__screen\",\"title-icon\":\"bee113ef4a391bcd__title-icon\",\"title\":\"_2f6050d2407c9dee__title\",\"actions\":\"e78f7a9cf7e91164__actions\"};\n"],
|
|
5
|
-
"mappings": ";AACA;AAAA,EACC,yBAAyB;AAAA,EACzB,oBAAoB;AAAA,EACpB,6BAA6B;AAAA,EAC7B;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,OAAO,UAAU;AAC1B,SAAS,cAAc,mBAAmB;AAC1C,SAAS,wBAAwB;;;ACAjC,IAAM,uBAAuB;AAU7B,SAAS,aAAa;AACrB,QAAM,cAAc;AAEpB,MAAK,YAAY,kBAAmB;AACnC,WAAO,YAAY;AAAA,EACpB;AAEA,cAAY,mBAAmB;AAAA,IAC9B,WAAW,oBAAI,IAAI;AAAA,IACnB,QAAQ,oBAAI,IAAI;AAAA,IAChB,gBAAgB,oBAAI,QAAQ;AAAA,EAC7B;AAEA,MAAK,OAAO,aAAa,aAAc;AACtC,qBAAkB,QAAS;AAAA,EAC5B;AAEA,SAAO,YAAY;AACpB;AAUA,SAAS,0BACR,gBACA,MACU;AACV,MAAK,CAAE,eAAe,MAAO;AAC5B,WAAO;AAAA,EACR;AAEA,aAAY,SAAS,eAAe,KAAK;AAAA,IACxC,SAAU,oBAAqB;AAAA,EAChC,GAAI;AACH,QAAK,MAAM,aAAc,oBAAqB,MAAM,MAAO;AAC1D,aAAO;AAAA,IACR;AAAA,EACD;AAEA,SAAO;AACR;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;AAC3E,MAAK,CAAE,eAAe,MAAO;AAC5B;AAAA,EACD;AAEA,QAAM,UAAU,WAAW;AAC3B,MAAI,iBAAiB,QAAQ,eAA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,SAAS;AAAA,UACV;AAAA,UAEA;AAAA,iCAAC,UAAO,SAAU,GAAI,WAAY,qBAAQ,YAAa,GACpD;AAAA,eAAE,UACH;AAAA,gBAAC;AAAA;AAAA,kBACA,KAAM;AAAA,kBACN;AAAA,kBACA,SAAU;AAAA,kBACV,OAAQ,GAAI,MAAO;AAAA,kBACnB,MAAK;AAAA,kBACL,SAAQ;AAAA;AAAA,cACT;AAAA,cAED;AAAA,gBAAC;AAAA;AAAA,kBACA,WAAY,qBAAO;AAAA,kBACnB,OAAQ;AAAA,kBACR,MAAK;AAAA,kBAEH;AAAA;AAAA,cACH;AAAA,cACE,WACD,oBAAC,SAAI,WAAY,qBAAO,SAAY,mBAAS;AAAA,eAE/C;AAAA,YAEE,eAAe,oBAAC,SAAM,uBAAa;AAAA,YAEnC;AAAA;AAAA;AAAA,QA1CI;AAAA,MA2CP,GACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["styles","AnimatePresence","motion","HStack","Heading"],"sources":["../../../../../style-runtime/src/index.ts","../../../../src/components/navigation/navigation-screen/style.module.scss","../../../../src/components/navigation/navigation-screen/index.tsx"],"sourcesContent":["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(\"587e8bd148\", \"._8ee768104cd6989d__screen{padding-block-end:4px}._8ee768104cd6989d__screen .components-text{color:var(--wpds-color-foreground-content-neutral,#1e1e1e)}._86eaeab8cbb71ab3__title-icon{padding-block-end:8px;padding-block-start:12px;padding-inline-end:16px;padding-inline-start:16px;position:sticky;top:0}.c70a3969756ff3ce__title{flex-grow:1;overflow-wrap:break-word}.c70a3969756ff3ce__title.c70a3969756ff3ce__title,.c70a3969756ff3ce__title.c70a3969756ff3ce__title .c70a3969756ff3ce__title{color:var(--wpds-color-foreground-content-neutral,#1e1e1e);line-height:32px}.f21c64ba84799e5c__actions{display:flex;flex-shrink:0}\");\n}\nexport default {\"screen\":\"_8ee768104cd6989d__screen\",\"title-icon\":\"_86eaeab8cbb71ab3__title-icon\",\"title\":\"c70a3969756ff3ce__title\",\"actions\":\"f21c64ba84799e5c__actions\"};\n","import type { ReactNode, RefObject } from 'react';\nimport {\n\t__experimentalHeading as Heading,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n\tButton,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { chevronRight, chevronLeft } from '@wordpress/icons';\nimport { useReducedMotion } from '@wordpress/compose';\nimport styles from './style.module.scss';\n\nconst ANIMATION_DURATION = 0.3;\nconst slideVariants = {\n\tinitial: ( direction: 'forward' | 'backward' ) => ( {\n\t\tx: ( direction === 'forward' ? 100 : -100 ) * ( isRTL() ? -1 : 1 ),\n\t\topacity: 0,\n\t} ),\n\tanimate: {\n\t\tx: 0,\n\t\topacity: 1,\n\t},\n\texit: ( direction: 'forward' | 'backward' ) => ( {\n\t\tx: ( direction === 'forward' ? 100 : -100 ) * ( isRTL() ? -1 : 1 ),\n\t\topacity: 0,\n\t} ),\n};\n\nexport default function NavigationScreen( {\n\tisRoot,\n\ttitle,\n\tactions,\n\tcontent,\n\tdescription,\n\tanimationDirection,\n\tbackMenuItem,\n\tbackButtonRef,\n\tnavigationKey,\n\tonNavigate,\n}: {\n\tisRoot?: boolean;\n\ttitle: string;\n\tactions?: ReactNode;\n\tcontent: ReactNode;\n\tdescription?: ReactNode;\n\tbackMenuItem?: string;\n\tbackButtonRef?: RefObject< HTMLButtonElement | null >;\n\tanimationDirection?: 'forward' | 'backward';\n\tnavigationKey?: string;\n\tonNavigate: ( {\n\t\tid,\n\t\tdirection,\n\t}: {\n\t\tid?: string;\n\t\tdirection: 'forward' | 'backward';\n\t} ) => void;\n} ) {\n\tconst icon = isRTL() ? chevronRight : chevronLeft;\n\tconst disableMotion = useReducedMotion();\n\n\tconst handleBackClick = ( e: React.MouseEvent ) => {\n\t\te.preventDefault();\n\t\tonNavigate( { id: backMenuItem, direction: 'backward' } );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ styles.screen }\n\t\t\tstyle={ {\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tposition: 'relative',\n\t\t\t\tdisplay: 'grid',\n\t\t\t\tgridTemplateColumns: '1fr',\n\t\t\t\tgridTemplateRows: '1fr',\n\t\t\t} }\n\t\t>\n\t\t\t<AnimatePresence initial={ false }>\n\t\t\t\t<motion.div\n\t\t\t\t\tkey={ navigationKey }\n\t\t\t\t\tcustom={ animationDirection }\n\t\t\t\t\tvariants={ slideVariants }\n\t\t\t\t\tinitial=\"initial\"\n\t\t\t\t\tanimate=\"animate\"\n\t\t\t\t\texit=\"exit\"\n\t\t\t\t\ttransition={ {\n\t\t\t\t\t\ttype: 'tween',\n\t\t\t\t\t\tduration: disableMotion ? 0 : ANIMATION_DURATION,\n\t\t\t\t\t\tease: [ 0.33, 0, 0, 1 ],\n\t\t\t\t\t} }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\tgridColumn: '1',\n\t\t\t\t\t\tgridRow: '1',\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<HStack spacing={ 2 } className={ styles[ 'title-icon' ] }>\n\t\t\t\t\t\t{ ! isRoot && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tref={ backButtonRef }\n\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\tonClick={ handleBackClick }\n\t\t\t\t\t\t\t\tlabel={ __( 'Back' ) }\n\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\tclassName={ styles.title }\n\t\t\t\t\t\t\tlevel={ 1 }\n\t\t\t\t\t\t\tsize=\"15px\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t{ actions && (\n\t\t\t\t\t\t\t<div className={ styles.actions }>{ actions }</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\n\t\t\t\t\t{ description && <div>{ description }</div> }\n\n\t\t\t\t\t{ content }\n\t\t\t\t</motion.div>\n\t\t\t</AnimatePresence>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;AAUA,MAAM,uBAAuB;;;;;;;;;AAU7B,SAAS,aAAa;CACrB,MAAM,cAAc;CAEpB,IAAK,YAAY,kBAChB,OAAO,YAAY;CAGpB,YAAY,mBAAmB;EAC9B,2BAAW,IAAI,IAAI;EACnB,wBAAQ,IAAI,IAAI;EAChB,gCAAgB,IAAI,QAAQ;CAC7B;CAEA,IAAK,OAAO,aAAa,aACxB,iBAAkB,QAAS;CAG5B,OAAO,YAAY;AACpB;;;;;;;;;AAUA,SAAS,0BACR,gBACA,MACU;CACV,IAAK,CAAE,eAAe,MACrB,OAAO;CAGR,KAAM,MAAM,SAAS,eAAe,KAAK,iBACxC,SAAU,qBAAsB,EACjC,GACC,IAAK,MAAM,aAAc,oBAAqB,MAAM,MACnD,OAAO;CAIT,OAAO;AACR;;;;;;;;;AAUA,SAAS,YAAa,gBAA0B,MAAc,KAAc;CAC3E,IAAK,CAAE,eAAe,MACrB;CAGD,MAAM,UAAU,WAAW;CAC3B,IAAI,iBAAiB,QAAQ,eAAe,IAAK,cAAe;CAEhE,IAAK,CAAE,gBAAiB;EACvB,iCAAiB,IAAI,IAAI;EACzB,QAAQ,eAAe,IAAK,gBAAgB,cAAe;CAC5D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EP"}
|
|
@@ -1,78 +1,79 @@
|
|
|
1
1
|
// packages/boot/src/components/navigation/path-matching.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a menu path is a valid parent path of the current path.
|
|
4
|
+
* A valid parent path must be a complete path prefix, not just share segments.
|
|
5
|
+
*
|
|
6
|
+
* @param currentPath - Current page path
|
|
7
|
+
* @param menuPath - Menu item path to check as potential parent
|
|
8
|
+
* @return True if menuPath is a parent of currentPath
|
|
9
|
+
*/
|
|
10
|
+
const isValidParentPath = (currentPath, menuPath) => {
|
|
11
|
+
if (!menuPath || menuPath === currentPath) return false;
|
|
12
|
+
const normalizePath = (path) => {
|
|
13
|
+
const normalized = path.startsWith("/") ? path : "/" + path;
|
|
14
|
+
return normalized.endsWith("/") && normalized.length > 1 ? normalized.slice(0, -1) : normalized;
|
|
15
|
+
};
|
|
16
|
+
const normalizedCurrent = normalizePath(currentPath);
|
|
17
|
+
const normalizedMenu = normalizePath(menuPath);
|
|
18
|
+
return normalizedCurrent.startsWith(normalizedMenu) && (normalizedCurrent[normalizedMenu.length] === "/" || normalizedMenu === "/");
|
|
13
19
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Finds the menu item that is the closest parent of the current path.
|
|
22
|
+
* Only considers menu items that have a 'to' path defined and are valid parents.
|
|
23
|
+
*
|
|
24
|
+
* @param currentPath - Current page path
|
|
25
|
+
* @param menuItems - Array of all menu items
|
|
26
|
+
* @return Menu item that is the closest parent, or null if no valid parent found
|
|
27
|
+
*/
|
|
28
|
+
const findClosestMenuItem = (currentPath, menuItems) => {
|
|
29
|
+
const exactMatch = menuItems.find((item) => item.to === currentPath);
|
|
30
|
+
if (exactMatch) return exactMatch;
|
|
31
|
+
let bestMatch = null;
|
|
32
|
+
let bestPathLength = 0;
|
|
33
|
+
for (const item of menuItems) {
|
|
34
|
+
if (!item.to) continue;
|
|
35
|
+
if (isValidParentPath(currentPath, item.to)) {
|
|
36
|
+
if (item.to.length > bestPathLength) {
|
|
37
|
+
bestMatch = item;
|
|
38
|
+
bestPathLength = item.to.length;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return bestMatch;
|
|
33
43
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return findDrilldownParent(parentItem.id, menuItems);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return void 0;
|
|
44
|
+
/**
|
|
45
|
+
* Finds the drilldown parent of a menu item by traversing up the menu tree.
|
|
46
|
+
*
|
|
47
|
+
* @param id - The ID of the menu item to find the drilldown parent for
|
|
48
|
+
* @param menuItems - Array of all menu items
|
|
49
|
+
* @return The ID of the drilldown parent, or undefined if none found
|
|
50
|
+
*/
|
|
51
|
+
const findDrilldownParent = (id, menuItems) => {
|
|
52
|
+
if (!id) return;
|
|
53
|
+
const currentItem = menuItems.find((item) => item.id === id);
|
|
54
|
+
if (!currentItem) return;
|
|
55
|
+
if (currentItem.parent) {
|
|
56
|
+
const parentItem = menuItems.find((item) => item.id === currentItem.parent);
|
|
57
|
+
if (parentItem?.parent_type === "drilldown") return parentItem.id;
|
|
58
|
+
if (parentItem) return findDrilldownParent(parentItem.id, menuItems);
|
|
59
|
+
}
|
|
54
60
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return void 0;
|
|
61
|
+
/**
|
|
62
|
+
* Finds the dropdown parent of a menu item.
|
|
63
|
+
*
|
|
64
|
+
* @param id - The ID of the menu item to find the dropdown parent for
|
|
65
|
+
* @param menuItems - Array of all menu items
|
|
66
|
+
* @return The ID of the dropdown parent, or undefined if none found
|
|
67
|
+
*/
|
|
68
|
+
const findDropdownParent = (id, menuItems) => {
|
|
69
|
+
if (!id) return;
|
|
70
|
+
const currentItem = menuItems.find((item) => item.id === id);
|
|
71
|
+
if (!currentItem) return;
|
|
72
|
+
if (currentItem.parent) {
|
|
73
|
+
const parentItem = menuItems.find((item) => item.id === currentItem.parent);
|
|
74
|
+
if (parentItem?.parent_type === "dropdown") return parentItem.id;
|
|
75
|
+
}
|
|
72
76
|
};
|
|
73
|
-
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
findDropdownParent
|
|
77
|
-
};
|
|
78
|
-
//# sourceMappingURL=path-matching.mjs.map
|
|
77
|
+
export { findClosestMenuItem, findDrilldownParent, findDropdownParent };
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=path-matching.mjs.map
|