@multiplatform.one/backoffice 7.88.7 → 7.88.9
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/package.json +12 -12
- package/src/shell/BackofficeShell.spec.tsx +63 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/backoffice",
|
|
3
|
-
"version": "7.88.
|
|
3
|
+
"version": "7.88.9",
|
|
4
4
|
"description": "Embeddable Frappe desk recreation (backoffice) for the multiplatform.one stack",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"backoffice",
|
|
@@ -71,21 +71,21 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@multiplatform.one/components": "^7.88.
|
|
75
|
-
"@multiplatform.one/forms": "^7.88.
|
|
76
|
-
"@multiplatform.one/frappe": "^7.88.
|
|
77
|
-
"@multiplatform.one/frappe-ui": "^7.88.
|
|
78
|
-
"@multiplatform.one/i18n": "^7.88.
|
|
79
|
-
"@multiplatform.one/platform": "^7.88.
|
|
80
|
-
"@multiplatform.one/store": "^7.88.
|
|
81
|
-
"@multiplatform.one/table": "^7.88.
|
|
82
|
-
"@multiplatform.one/theme": "^7.88.
|
|
74
|
+
"@multiplatform.one/components": "^7.88.9",
|
|
75
|
+
"@multiplatform.one/forms": "^7.88.9",
|
|
76
|
+
"@multiplatform.one/frappe": "^7.88.9",
|
|
77
|
+
"@multiplatform.one/frappe-ui": "^7.88.9",
|
|
78
|
+
"@multiplatform.one/i18n": "^7.88.9",
|
|
79
|
+
"@multiplatform.one/platform": "^7.88.9",
|
|
80
|
+
"@multiplatform.one/store": "^7.88.9",
|
|
81
|
+
"@multiplatform.one/table": "^7.88.9",
|
|
82
|
+
"@multiplatform.one/theme": "^7.88.9",
|
|
83
83
|
"@phosphor-icons/react": "^2.1.10",
|
|
84
84
|
"tamagui": "2.7.6"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
|
-
"@multiplatform.one/config": "7.88.
|
|
88
|
-
"@multiplatform.one/test-utils": "7.88.
|
|
87
|
+
"@multiplatform.one/config": "7.88.9",
|
|
88
|
+
"@multiplatform.one/test-utils": "7.88.9",
|
|
89
89
|
"@tamagui/build": "2.7.6",
|
|
90
90
|
"@testing-library/react": "^16.3.3",
|
|
91
91
|
"@types/react-dom": "^19.2.3",
|
|
@@ -3,6 +3,7 @@ import { InMemoryFixtureProvider } from "@multiplatform.one/frappe";
|
|
|
3
3
|
import { renderWithProviders } from "@multiplatform.one/test-utils";
|
|
4
4
|
import { cleanup, fireEvent, screen, waitFor, within } from "@testing-library/react";
|
|
5
5
|
import { defaultKnobs, resolveKnobs, type LayoutSizeClass } from "@multiplatform.one/theme";
|
|
6
|
+
import { getConfig } from "tamagui";
|
|
6
7
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
7
8
|
import { BackofficeProvider } from "../config/BackofficeProvider";
|
|
8
9
|
import { createMemoryNavigator } from "../navigation/navigator";
|
|
@@ -71,15 +72,76 @@ describe("BackofficeShell pane hairlines", () => {
|
|
|
71
72
|
expect(trigger?.classList.contains("_w-auto")).toBe(true);
|
|
72
73
|
});
|
|
73
74
|
|
|
75
|
+
function ruleValue(className: string, property: string): string | null {
|
|
76
|
+
for (const sheet of Array.from(document.styleSheets)) {
|
|
77
|
+
for (const rule of Array.from(sheet.cssRules)) {
|
|
78
|
+
if (!(rule instanceof CSSStyleRule) || !rule.selectorText.endsWith(`.${className}`))
|
|
79
|
+
continue;
|
|
80
|
+
const value = rule.style.getPropertyValue(property).trim();
|
|
81
|
+
if (value) return value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function themeTokenAt(el: Element, token: string): string | null {
|
|
88
|
+
const themes = getConfig().themes as Record<string, Record<string, { val?: unknown }>>;
|
|
89
|
+
let sub: string | null = null;
|
|
90
|
+
for (let node: Element | null = el; node; node = node.parentElement) {
|
|
91
|
+
const classes = Array.from(node.classList);
|
|
92
|
+
const scheme = classes.includes("t_dark")
|
|
93
|
+
? "dark"
|
|
94
|
+
: classes.includes("t_light")
|
|
95
|
+
? "light"
|
|
96
|
+
: null;
|
|
97
|
+
const names = classes
|
|
98
|
+
.filter((c) => c.startsWith("t_") && !["t_sub_theme", "t_light", "t_dark"].includes(c))
|
|
99
|
+
.map((c) => c.slice(2));
|
|
100
|
+
if (sub === null && names.length) sub = names.sort((a, b) => b.length - a.length)[0]!;
|
|
101
|
+
if (!scheme) continue;
|
|
102
|
+
const parts = sub ? `${scheme}_${sub}`.split("_") : [scheme];
|
|
103
|
+
for (let end = parts.length; end > 0; end--) {
|
|
104
|
+
const hit = themes[parts.slice(0, end).join("_")]?.[token]?.val;
|
|
105
|
+
if (typeof hit === "string") return hit;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function resolvePaint(el: Element, value: string | null): string | null {
|
|
113
|
+
const name = value?.match(/^var\((--[\w-]+)\)$/)?.[1];
|
|
114
|
+
if (!name) return value;
|
|
115
|
+
for (let node: Element | null = el; node; node = node.parentElement) {
|
|
116
|
+
const declared = (node as HTMLElement).style?.getPropertyValue(name).trim();
|
|
117
|
+
if (declared) return resolvePaint(node, declared);
|
|
118
|
+
}
|
|
119
|
+
return themeTokenAt(el, name.slice(2));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function glyphInk(svg: Element): string | null {
|
|
123
|
+
const fill = svg.getAttribute("fill");
|
|
124
|
+
if (fill !== "currentColor") return fill;
|
|
125
|
+
for (let node = svg.parentElement; node; node = node.parentElement) {
|
|
126
|
+
const cls = Array.from(node.classList).find(
|
|
127
|
+
(c) => c.startsWith("_col-") && !/^_col-0(hover|active|focus|press)/.test(c),
|
|
128
|
+
);
|
|
129
|
+
if (cls) return resolvePaint(node, ruleValue(cls, "color"));
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
|
|
74
134
|
it("supplies theme ink to the header glyphs instead of native currentColor", () => {
|
|
75
135
|
renderShell();
|
|
76
136
|
const glyphs = ["Toggle sidebar", "Search", "Notifications"].map((label) =>
|
|
77
137
|
screen.getByLabelText(label).querySelector("svg"),
|
|
78
138
|
);
|
|
139
|
+
const ink = glyphInk(glyphs[0] as Element);
|
|
140
|
+
expect(ink).toMatch(/^#|^rgb|^hsl/);
|
|
79
141
|
for (const glyph of glyphs) {
|
|
80
142
|
expect(glyph).toBeTruthy();
|
|
81
|
-
expect(glyph?.getAttribute("fill")).not.toBe("currentColor");
|
|
82
143
|
expect(glyph?.getAttribute("fill")).toBe(glyphs[0]?.getAttribute("fill"));
|
|
144
|
+
expect(glyphInk(glyph as Element)).toBe(ink);
|
|
83
145
|
}
|
|
84
146
|
});
|
|
85
147
|
|