@gopherium/godmin 0.7.0 → 0.8.1
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/README.md +8 -12
- package/dist/admin-root.d.ts +1 -1
- package/dist/admin-root.js +4 -2
- package/dist/base.css +1 -0
- package/dist/frame.js +7 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/testing.js +10 -1
- package/dist/vite.js +1 -0
- package/package.json +11 -13
- package/patches/@wordpress__element@8.4.0.patch +0 -31
package/README.md
CHANGED
|
@@ -51,26 +51,22 @@ two lines do for you.
|
|
|
51
51
|
| `@gopherium/godmin/base.css` | Cascade layer order, design tokens, host rules, frame and screen styles |
|
|
52
52
|
| `@gopherium/godmin/router` | `useCanvas`, `useFrameLocation`, the `canvas` route static data |
|
|
53
53
|
| `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport`, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR` |
|
|
54
|
-
| `@gopherium/godmin/vite` | `godminDedupe`, `godminSingleCopy`, `duplicateCopies` |
|
|
54
|
+
| `@gopherium/godmin/vite` | `godminDedupe`, `godminSingleCopy`, `godminStylesheetFirst`, `duplicateCopies`, `hoistStylesheet` |
|
|
55
55
|
| `@gopherium/godmin/stylelint` | The design system stylelint rules |
|
|
56
|
-
| `@gopherium/godmin/patches/*` | The React 19 patch file for `@wordpress/element`, copied at install time, temporary |
|
|
57
56
|
|
|
58
57
|
## Before your first build
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
Duplicate packages break the application, and nothing points at the cause.
|
|
60
|
+
[Build configuration](https://docs.gopherium.org/admin-ui/build-and-versioning/)
|
|
61
|
+
covers it.
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- **React 19.** `@wordpress/element` up to 8.4.0 fails to load on React 19.
|
|
68
|
-
Copy the patch this package ships into your own `patches/` directory, since
|
|
69
|
-
pnpm applies patches before `node_modules` exists.
|
|
63
|
+
Two copies of React throw on the first hook. Two copies of `@wordpress/theme`
|
|
64
|
+
render unthemed components with no error. Spread `godminDedupe` into
|
|
65
|
+
`resolve.dedupe` and add the `godminSingleCopy()` plugin.
|
|
70
66
|
|
|
71
67
|
## Design system versions
|
|
72
68
|
|
|
73
|
-
Peer ranges are longhand and single window, for example `>=0.
|
|
69
|
+
Peer ranges are longhand and single window, for example `>=0.22.0 <0.23.0`.
|
|
74
70
|
The window moves with each design system release train and never widens, so no
|
|
75
71
|
release accepts two breaking generations at once. `SUPPORTED_WPDS` exports the
|
|
76
72
|
window this build was tested against.
|
package/dist/admin-root.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export interface AdminRootProps extends ThemeSettings {
|
|
|
10
10
|
* @param props - The theme settings, root element type and children.
|
|
11
11
|
* @returns The host element wrapping the themed children.
|
|
12
12
|
*/
|
|
13
|
-
export declare function AdminRoot({ children, as: Root, ...theme }: AdminRootProps): import("react").JSX.Element;
|
|
13
|
+
export declare function AdminRoot({ children, as: Root, color, ...theme }: AdminRootProps): import("react").JSX.Element;
|
|
14
14
|
export {};
|
package/dist/admin-root.js
CHANGED
|
@@ -2,12 +2,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
import { ThemeProvider } from '@wordpress/theme';
|
|
4
4
|
import { useEnableWpCompatOverlaySlot } from '@wordpress/ui';
|
|
5
|
+
/** The design system's own primary color, seeded when an application names none. */
|
|
6
|
+
const DEFAULT_COLOR = { primary: '#3858e9' };
|
|
5
7
|
/**
|
|
6
8
|
* Hosts a design system application in its own stacking context.
|
|
7
9
|
* @param props - The theme settings, root element type and children.
|
|
8
10
|
* @returns The host element wrapping the themed children.
|
|
9
11
|
*/
|
|
10
|
-
export function AdminRoot({ children, as: Root = 'div', ...theme }) {
|
|
12
|
+
export function AdminRoot({ children, as: Root = 'div', color = DEFAULT_COLOR, ...theme }) {
|
|
11
13
|
useEnableWpCompatOverlaySlot();
|
|
12
|
-
return (_jsx(Root, { style: { isolation: 'isolate' }, children: _jsx(ThemeProvider, { ...theme, isRoot: true, children: children }) }));
|
|
14
|
+
return (_jsx(Root, { style: { isolation: 'isolate' }, children: _jsx(ThemeProvider, { color: color, ...theme, isRoot: true, children: children }) }));
|
|
13
15
|
}
|
package/dist/base.css
CHANGED
package/dist/frame.js
CHANGED
|
@@ -10,7 +10,7 @@ import { useMediaQuery } from './use-media-query.js';
|
|
|
10
10
|
* The glyph on the button that opens the rail drawer.
|
|
11
11
|
*/
|
|
12
12
|
const menuIcon = (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: _jsx("path", { d: "M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z" }) }));
|
|
13
|
-
const FrameContext = createContext({ small: false, location: undefined });
|
|
13
|
+
const FrameContext = createContext({ small: false, location: undefined, layout: null });
|
|
14
14
|
/**
|
|
15
15
|
* Frames an admin application, folding its rail away on a narrow viewport.
|
|
16
16
|
* @param props - The regions, the current location, and the region colors.
|
|
@@ -18,8 +18,9 @@ const FrameContext = createContext({ small: false, location: undefined });
|
|
|
18
18
|
*/
|
|
19
19
|
function Root({ children, location, chromeColor, canvasColor }) {
|
|
20
20
|
const small = useMediaQuery(SMALL_VIEWPORT);
|
|
21
|
+
const [layout, setLayout] = useState(null);
|
|
21
22
|
const classes = small ? 'godmin-layout godmin-layout--small' : 'godmin-layout';
|
|
22
|
-
return (_jsx(ThemeProvider, { color: chromeColor, children: _jsx(FrameContext.Provider, { value: { small, location }, children: _jsx("div", { className: classes, children: _jsx(CanvasColorContext.Provider, { value: canvasColor, children: children }) }) }) }));
|
|
23
|
+
return (_jsx(ThemeProvider, { color: chromeColor, children: _jsx(FrameContext.Provider, { value: { small, location, layout }, children: _jsx("div", { ref: setLayout, className: classes, children: _jsx(CanvasColorContext.Provider, { value: canvasColor, children: children }) }) }) }));
|
|
23
24
|
}
|
|
24
25
|
const CanvasColorContext = createContext(undefined);
|
|
25
26
|
/**
|
|
@@ -41,13 +42,13 @@ function Rail({ children, brand, menuLabel = 'Open navigation' }) {
|
|
|
41
42
|
* @param props - The rail content, the brand, and the menu button label.
|
|
42
43
|
* @returns The top bar element.
|
|
43
44
|
*/
|
|
44
|
-
function TopBar({ children, brand, menuLabel }) {
|
|
45
|
-
const { location } = useContext(FrameContext);
|
|
45
|
+
function TopBar({ children, brand, menuLabel, }) {
|
|
46
|
+
const { location, layout } = useContext(FrameContext);
|
|
46
47
|
const [open, setOpen] = useState(false);
|
|
47
48
|
useEffect(() => {
|
|
48
49
|
setOpen(false);
|
|
49
50
|
}, [location]);
|
|
50
|
-
return (_jsxs("div", { className: "godmin-layout__topbar", children: [_jsxs(Drawer.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Drawer.Trigger, { render: _jsx(IconButton, { icon: menuIcon, label: menuLabel }) }), _jsxs(Drawer.Popup, { className: "godmin-layout__drawer", children: [_jsx(VisuallyHidden, { render: _jsx(Drawer.Title, {}), children: menuLabel }), children] })] }), brand] }));
|
|
51
|
+
return (_jsxs("div", { className: "godmin-layout__topbar", children: [_jsxs(Drawer.Root, { open: open, onOpenChange: setOpen, children: [_jsx(Drawer.Trigger, { render: _jsx(IconButton, { icon: menuIcon, label: menuLabel }) }), _jsxs(Drawer.Popup, { className: "godmin-layout__drawer", portal: _jsx(Drawer.Portal, { container: layout }), children: [_jsx(VisuallyHidden, { render: _jsx(Drawer.Title, {}), children: menuLabel }), children] })] }), brand] }));
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
54
|
* Renders the region showing the active screen.
|
|
@@ -59,7 +60,7 @@ function Canvas({ children, canvas = 'padded' }) {
|
|
|
59
60
|
const classes = canvas === 'bleed'
|
|
60
61
|
? 'godmin-layout__canvas godmin-layout__canvas--bleed'
|
|
61
62
|
: 'godmin-layout__canvas';
|
|
62
|
-
return (_jsx(ThemeProvider, { color: color, children: _jsx("main", { className: classes, children: children }) }));
|
|
63
|
+
return (_jsx(ThemeProvider, { color: color, children: _jsx("main", { className: classes, style: { isolation: 'isolate' }, children: children }) }));
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
66
|
* The admin frame, whose regions are present when their element is rendered.
|
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,6 @@ export { useTokenDocument } from './use-token-document.js';
|
|
|
16
16
|
* The design system version window this build was tested against.
|
|
17
17
|
*/
|
|
18
18
|
export declare const SUPPORTED_WPDS: {
|
|
19
|
-
readonly '@wordpress/ui': ">=0.
|
|
20
|
-
readonly '@wordpress/theme': ">=
|
|
19
|
+
readonly '@wordpress/ui': ">=0.22.0 <0.23.0";
|
|
20
|
+
readonly '@wordpress/theme': ">=2.1.0 <3.0.0";
|
|
21
21
|
};
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,6 @@ export { useTokenDocument } from './use-token-document.js';
|
|
|
12
12
|
* The design system version window this build was tested against.
|
|
13
13
|
*/
|
|
14
14
|
export const SUPPORTED_WPDS = {
|
|
15
|
-
'@wordpress/ui': '>=0.
|
|
16
|
-
'@wordpress/theme': '>=
|
|
15
|
+
'@wordpress/ui': '>=0.22.0 <0.23.0',
|
|
16
|
+
'@wordpress/theme': '>=2.1.0 <3.0.0',
|
|
17
17
|
};
|
package/dist/testing.js
CHANGED
|
@@ -41,7 +41,7 @@ export async function assertElementPatched(load = () => import('@wordpress/eleme
|
|
|
41
41
|
element = await load();
|
|
42
42
|
}
|
|
43
43
|
catch (cause) {
|
|
44
|
-
throw new Error('@wordpress/element could not be imported
|
|
44
|
+
throw new Error('@wordpress/element could not be imported', { cause });
|
|
45
45
|
}
|
|
46
46
|
for (const name of REMOVED_BY_REACT_19) {
|
|
47
47
|
if (element[name] !== undefined) {
|
|
@@ -129,8 +129,17 @@ function installFeatureDetection() {
|
|
|
129
129
|
function installResizeObserver() {
|
|
130
130
|
if (typeof globalThis.ResizeObserver !== 'function') {
|
|
131
131
|
globalThis.ResizeObserver = class {
|
|
132
|
+
/**
|
|
133
|
+
* Watches an element.
|
|
134
|
+
*/
|
|
132
135
|
observe() { }
|
|
136
|
+
/**
|
|
137
|
+
* Stops watching an element.
|
|
138
|
+
*/
|
|
133
139
|
unobserve() { }
|
|
140
|
+
/**
|
|
141
|
+
* Stops watching every element.
|
|
142
|
+
*/
|
|
134
143
|
disconnect() { }
|
|
135
144
|
};
|
|
136
145
|
}
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopherium/godmin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "The admin kit for Gopherium projects: host layer for React admin applications on the WordPress Design System.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"packageManager": "pnpm@
|
|
7
|
+
"packageManager": "pnpm@12.2.1",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/gopherium/godmin.git"
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"files": [
|
|
20
20
|
"dist",
|
|
21
|
-
"NOTICE"
|
|
22
|
-
"patches"
|
|
21
|
+
"NOTICE"
|
|
23
22
|
],
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
@@ -27,7 +26,6 @@
|
|
|
27
26
|
"default": "./dist/index.js"
|
|
28
27
|
},
|
|
29
28
|
"./base.css": "./dist/base.css",
|
|
30
|
-
"./patches/*": "./patches/*",
|
|
31
29
|
"./router": {
|
|
32
30
|
"types": "./dist/router.d.ts",
|
|
33
31
|
"default": "./dist/router.js"
|
|
@@ -60,9 +58,9 @@
|
|
|
60
58
|
"peerDependencies": {
|
|
61
59
|
"@tanstack/react-router": "^1.170.0",
|
|
62
60
|
"@testing-library/react": "^16.3.2",
|
|
63
|
-
"@wordpress/style-runtime": ">=0.
|
|
64
|
-
"@wordpress/theme": ">=
|
|
65
|
-
"@wordpress/ui": ">=0.
|
|
61
|
+
"@wordpress/style-runtime": ">=0.11.0 <0.12.0",
|
|
62
|
+
"@wordpress/theme": ">=2.1.0 <3.0.0",
|
|
63
|
+
"@wordpress/ui": ">=0.22.0 <0.23.0",
|
|
66
64
|
"react": "^19.2.0",
|
|
67
65
|
"stylelint": "^16 || ^17",
|
|
68
66
|
"vitest": "^4.1.10"
|
|
@@ -88,11 +86,11 @@
|
|
|
88
86
|
"@types/react": "^19.2.17",
|
|
89
87
|
"@vitejs/plugin-react": "^6.0.3",
|
|
90
88
|
"@vitest/coverage-v8": "^4.1.10",
|
|
91
|
-
"@wordpress/a11y": "4.
|
|
92
|
-
"@wordpress/element": "8.
|
|
93
|
-
"@wordpress/style-runtime": "0.
|
|
94
|
-
"@wordpress/theme": "
|
|
95
|
-
"@wordpress/ui": "0.
|
|
89
|
+
"@wordpress/a11y": "4.55.0",
|
|
90
|
+
"@wordpress/element": "8.7.0",
|
|
91
|
+
"@wordpress/style-runtime": "0.11.0",
|
|
92
|
+
"@wordpress/theme": "2.1.0",
|
|
93
|
+
"@wordpress/ui": "0.22.0",
|
|
96
94
|
"eslint": "^10.7.0",
|
|
97
95
|
"eslint-plugin-jsdoc": "^63.2.0",
|
|
98
96
|
"eslint-plugin-sonarjs": "^4.2.0",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
diff --git a/build-module/react-platform.mjs b/build-module/react-platform.mjs
|
|
2
|
-
index 8ed5aef770524fe83d1a0264e00f2d2f932d4f8b..882b2458878bc0881d07dead238607ed6c217dc8 100644
|
|
3
|
-
--- a/build-module/react-platform.mjs
|
|
4
|
-
+++ b/build-module/react-platform.mjs
|
|
5
|
-
@@ -1,13 +1,16 @@
|
|
6
|
-
// packages/element/src/react-platform.ts
|
|
7
|
-
+// Patched for React 19: findDOMNode, render, hydrate and
|
|
8
|
-
+// unmountComponentAtNode no longer exist in react-dom. The names stay
|
|
9
|
-
+// exported so importers keep loading, calling one is an error.
|
|
10
|
-
import {
|
|
11
|
-
createPortal,
|
|
12
|
-
- findDOMNode,
|
|
13
|
-
- flushSync,
|
|
14
|
-
- render,
|
|
15
|
-
- hydrate,
|
|
16
|
-
- unmountComponentAtNode
|
|
17
|
-
+ flushSync
|
|
18
|
-
} from "react-dom";
|
|
19
|
-
import { createRoot, hydrateRoot } from "react-dom/client";
|
|
20
|
-
+const findDOMNode = undefined;
|
|
21
|
-
+const render = undefined;
|
|
22
|
-
+const hydrate = undefined;
|
|
23
|
-
+const unmountComponentAtNode = undefined;
|
|
24
|
-
export {
|
|
25
|
-
createPortal,
|
|
26
|
-
createRoot,
|
|
27
|
-
@@ -18,4 +21,3 @@ export {
|
|
28
|
-
render,
|
|
29
|
-
unmountComponentAtNode
|
|
30
|
-
};
|
|
31
|
-
-//# sourceMappingURL=react-platform.mjs.map
|