@24city/web-console 0.3.4 → 0.3.6
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 +32 -0
- package/GUIDELINES.md +20 -6
- package/dist/chunks/text-link-Bb5f1eLW.js +106 -0
- package/dist/chunks/{waterfall-Cmz0ZULQ.js → waterfall-ZMzEjGwK.js} +1 -1
- package/dist/index.js +119 -115
- package/dist/list/content-square.d.ts +4 -1
- package/dist/list/index.js +1 -1
- package/dist/page/feature.d.ts +65 -0
- package/dist/page/index.d.ts +1 -0
- package/dist/page/index.js +25 -21
- package/dist/styles.css +293 -43
- package/dist/testing/guard.d.ts +4 -3
- package/dist/testing/guard.js +50 -43
- package/package.json +1 -1
- package/dist/chunks/text-link-Ch_4QIkx.js +0 -65
package/dist/testing/guard.d.ts
CHANGED
|
@@ -42,10 +42,11 @@ export declare const ALLOWED_FONT_SIZES: readonly number[];
|
|
|
42
42
|
/** 允许出现在 @media 里的宽度(px)。 */
|
|
43
43
|
export declare const ALLOWED_BREAKPOINTS: readonly number[];
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* 检查样式里写死的字号和断点是否落在设计阶梯上,斜体是否只来自本包,逐处报告(带行号):
|
|
46
46
|
* - `font-size: Npx` 的 N 必须是字号阶梯或展示尺寸里的值(引用 `var(--app-font-size-*)`、`inherit`、`em` 等不受限);
|
|
47
|
-
* - `@media` 里 `min-width` / `max-width`
|
|
48
|
-
*
|
|
47
|
+
* - `@media` 里 `min-width` / `max-width` 的像素值必须是断点之一;
|
|
48
|
+
* - 不写 `font-style: italic` / `oblique`:重点功能的斜体标题用 `FeatureTitle`,编号用 `FeatureIndex`。
|
|
49
|
+
* 新产品 `expect(checkDesignScale({ sourceRoot })).toEqual([])`;存量产品可以按 `rule` 分别断言数量不超过现状,只减不增。
|
|
49
50
|
*/
|
|
50
51
|
export declare const checkDesignScale: ({ sourceRoot, exclude }: UiGuardOptions) => UiGuardViolation[];
|
|
51
52
|
/**
|
package/dist/testing/guard.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { readFileSync as
|
|
2
|
-
import { relative as
|
|
3
|
-
import { D as
|
|
4
|
-
const C = { "@douyinfe/semi-ui": "2.104.0" },
|
|
1
|
+
import { readFileSync as m, readdirSync as I, statSync as L } from "node:fs";
|
|
2
|
+
import { relative as A, join as _ } from "node:path";
|
|
3
|
+
import { D as v, F as N, B as O } from "../chunks/scale-smFifpMm.js";
|
|
4
|
+
const C = { "@douyinfe/semi-ui": "2.104.0" }, T = {
|
|
5
5
|
peerDependencies: C
|
|
6
|
-
},
|
|
6
|
+
}, D = /<(button|input|select|textarea|option|label|form|table|thead|tbody|tr|td|th|details|summary|dialog|img|a|ul|ol|li|dl|dt|dd|h[1-6]|p)(\s|>|\/)/, F = [
|
|
7
7
|
"lucide-react",
|
|
8
8
|
"@nuwa/customer-ui",
|
|
9
9
|
"@nuwa/customer-shell",
|
|
@@ -15,28 +15,28 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
|
|
|
15
15
|
".arco-",
|
|
16
16
|
"@douyinfe/semi-ui/dist/css",
|
|
17
17
|
"theme-mode"
|
|
18
|
-
],
|
|
18
|
+
], R = ["--semi-", "--app-"], w = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, P = /\b(?:rgba?|hsla?)\((?!\s*var\()/, k = new RegExp(`(?:^|[\\s{;'"])(${R.map((s) => s.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), W = /<IconSpin\b([^>]*)>/g, j = (s) => {
|
|
19
19
|
for (const i of s.matchAll(W))
|
|
20
20
|
if (!/(?:^|\s)spin(?=[\s=/]|$)/.test(i[1])) return i[0];
|
|
21
21
|
return null;
|
|
22
|
-
}, h = (s) =>
|
|
23
|
-
const e =
|
|
24
|
-
return
|
|
25
|
-
}), S = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"),
|
|
26
|
-
const e = [], r = h(s).map((o) => ({ path: o, file:
|
|
22
|
+
}, h = (s) => I(s).flatMap((i) => {
|
|
23
|
+
const e = _(s, i);
|
|
24
|
+
return L(e).isDirectory() ? h(e) : [e];
|
|
25
|
+
}), S = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"), U = ({ sourceRoot: s, exclude: i = S }) => {
|
|
26
|
+
const e = [], r = h(s).map((o) => ({ path: o, file: A(s, o) })).filter(({ file: o }) => !i(o));
|
|
27
27
|
for (const { path: o, file: t } of r) {
|
|
28
28
|
const n = t.endsWith(".tsx");
|
|
29
29
|
if (!/\.(tsx?|css)$/.test(t)) continue;
|
|
30
|
-
const c =
|
|
30
|
+
const c = m(o, "utf8");
|
|
31
31
|
if (n) {
|
|
32
|
-
const
|
|
33
|
-
|
|
32
|
+
const f = c.match(D);
|
|
33
|
+
f && e.push({ file: t, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${f[0].trim()}` }), /className="/.test(c) && e.push({ file: t, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
|
|
34
34
|
const g = j(c);
|
|
35
35
|
g && e.push({ file: t, rule: "static-spinner", detail: `${g} 不会转:Semi 的 IconSpin 要加 spin` });
|
|
36
36
|
}
|
|
37
|
-
for (const
|
|
38
|
-
c.includes(
|
|
39
|
-
const a = c.match(
|
|
37
|
+
for (const f of F)
|
|
38
|
+
c.includes(f) && e.push({ file: t, rule: "forbidden-import", detail: `不应引用 ${f}` });
|
|
39
|
+
const a = c.match(w);
|
|
40
40
|
a && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${a[0]}` });
|
|
41
41
|
const u = c.match(P);
|
|
42
42
|
u && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${u[0]}` });
|
|
@@ -44,20 +44,20 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
|
|
|
44
44
|
E && e.push({ file: t, rule: "reserved-variable", detail: `不得声明主题变量 ${E[1]}…,品牌主色只能通过 runtime-config 的 brand.primaryColor 设置` });
|
|
45
45
|
}
|
|
46
46
|
return e;
|
|
47
|
-
}, M = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], z =
|
|
47
|
+
}, M = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], z = T.peerDependencies, p = z["@douyinfe/semi-ui"], X = (s) => {
|
|
48
48
|
var r, o;
|
|
49
|
-
const i = JSON.parse(
|
|
49
|
+
const i = JSON.parse(m(s, "utf8")), e = [];
|
|
50
50
|
for (const t of M) {
|
|
51
51
|
const n = ((r = i.dependencies) == null ? void 0 : r[t]) ?? ((o = i.devDependencies) == null ? void 0 : o[t]);
|
|
52
|
-
!(t === "@douyinfe/semi-ui" || n !== void 0) || n ===
|
|
52
|
+
!(t === "@douyinfe/semi-ui" || n !== void 0) || n === p || e.push({
|
|
53
53
|
file: "package.json",
|
|
54
54
|
rule: "semi-version",
|
|
55
|
-
detail: n ? `${t} 必须精确声明为 ${
|
|
55
|
+
detail: n ? `${t} 必须精确声明为 ${p},现在是 ${n}` : `必须声明 ${t} ${p}`
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
return e;
|
|
59
59
|
}, G = (s) => {
|
|
60
|
-
const i =
|
|
60
|
+
const i = m(s, "utf8").replace(/\/\*[\s\S]*?\*\/|\/\/[^\n]*/g, ""), e = /import\s*\{[^}]*\bsemiCssLayer\b[^}]*\}\s*from\s*['"]@24city\/web-console\/vite['"]/.test(i), r = /\bsemiCssLayer\s*\(\s*\)/.test(i);
|
|
61
61
|
return e && r ? [] : [
|
|
62
62
|
{
|
|
63
63
|
file: "vite.config.ts",
|
|
@@ -65,32 +65,39 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
|
|
|
65
65
|
detail: "plugins 里要加 semiCssLayer()(import { semiCssLayer } from '@24city/web-console/vite'),把 Semi 的样式放进 semi 层"
|
|
66
66
|
}
|
|
67
67
|
];
|
|
68
|
-
},
|
|
69
|
-
`).length,
|
|
68
|
+
}, b = [...Object.values(N), ...v], y = Object.values(O), $ = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (i) => i.replace(/[^\n]/g, " ")), d = (s, i) => s.slice(0, i).split(`
|
|
69
|
+
`).length, x = (s, i) => h(s).map((e) => ({ path: e, file: A(s, e) })).filter(({ file: e }) => e.endsWith(".css") && !i(e)), H = ({ sourceRoot: s, exclude: i = S }) => {
|
|
70
70
|
const e = [];
|
|
71
|
-
for (const { path: r, file: o } of
|
|
72
|
-
const t = $(
|
|
71
|
+
for (const { path: r, file: o } of x(s, i)) {
|
|
72
|
+
const t = $(m(r, "utf8"));
|
|
73
73
|
for (const n of t.matchAll(/font-size\s*:\s*(\d+(?:\.\d+)?)px/g))
|
|
74
|
-
|
|
74
|
+
b.includes(Number(n[1])) || e.push({
|
|
75
75
|
file: o,
|
|
76
|
-
line:
|
|
76
|
+
line: d(t, n.index),
|
|
77
77
|
rule: "font-size-scale",
|
|
78
|
-
detail: `font-size: ${n[1]}px 不在字号阶梯上(${[...
|
|
78
|
+
detail: `font-size: ${n[1]}px 不在字号阶梯上(${[...b].sort((l, c) => l - c).join("、")})`
|
|
79
79
|
});
|
|
80
80
|
for (const n of t.matchAll(/@media[^{]*/g))
|
|
81
81
|
for (const l of n[0].matchAll(/(min|max)-width\s*:\s*(\d+(?:\.\d+)?)px/g))
|
|
82
|
-
|
|
82
|
+
y.includes(Number(l[2])) || e.push({
|
|
83
83
|
file: o,
|
|
84
|
-
line:
|
|
84
|
+
line: d(t, n.index),
|
|
85
85
|
rule: "breakpoint",
|
|
86
|
-
detail: `@media 的 ${l[1]}-width: ${l[2]}px 不是规定的断点(${
|
|
86
|
+
detail: `@media 的 ${l[1]}-width: ${l[2]}px 不是规定的断点(${y.join("、")})`
|
|
87
87
|
});
|
|
88
|
+
for (const n of t.matchAll(/font-style\s*:\s*(italic|oblique)\b/g))
|
|
89
|
+
e.push({
|
|
90
|
+
file: o,
|
|
91
|
+
line: d(t, n.index),
|
|
92
|
+
rule: "font-style",
|
|
93
|
+
detail: `font-style: ${n[1]} 不写在产品样式里:重点功能的斜体标题用 FeatureTitle,编号用 FeatureIndex(@24city/web-console/page)`
|
|
94
|
+
});
|
|
88
95
|
}
|
|
89
96
|
return e;
|
|
90
97
|
}, B = /(?:^|[\s>+~])(?::global\(\s*)?\.(semi-[A-Za-z0-9-]+)/, V = /:not\((?:[^()]|\([^()]*\))*\)/g, J = ({ sourceRoot: s, exclude: i = S }) => {
|
|
91
98
|
const e = [];
|
|
92
|
-
for (const { path: r, file: o } of
|
|
93
|
-
const t = $(
|
|
99
|
+
for (const { path: r, file: o } of x(s, i)) {
|
|
100
|
+
const t = $(m(r, "utf8"));
|
|
94
101
|
for (const n of t.matchAll(/([^{}]+)\{/g)) {
|
|
95
102
|
const l = n[1];
|
|
96
103
|
if (l.trimStart().startsWith("@")) continue;
|
|
@@ -99,7 +106,7 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
|
|
|
99
106
|
const u = a.replace(V, "").trim().match(B);
|
|
100
107
|
u && e.push({
|
|
101
108
|
file: o,
|
|
102
|
-
line:
|
|
109
|
+
line: d(t, n.index + c + (a.length - a.trimStart().length)),
|
|
103
110
|
rule: "semi-internals",
|
|
104
111
|
detail: `选择器 ${a.trim()} 伸进了 Semi 组件内部(.${u[1]})`
|
|
105
112
|
}), c += a.length + 1;
|
|
@@ -109,16 +116,16 @@ const C = { "@douyinfe/semi-ui": "2.104.0" }, D = {
|
|
|
109
116
|
return e;
|
|
110
117
|
};
|
|
111
118
|
export {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
y as ALLOWED_BREAKPOINTS,
|
|
120
|
+
b as ALLOWED_FONT_SIZES,
|
|
121
|
+
p as EXPECTED_SEMI_VERSION,
|
|
122
|
+
F as FORBIDDEN_SNIPPETS,
|
|
123
|
+
D as RAW_ELEMENT_PATTERN,
|
|
124
|
+
R as RESERVED_VARIABLE_PREFIXES,
|
|
118
125
|
M as SEMI_PACKAGES,
|
|
119
126
|
H as checkDesignScale,
|
|
120
127
|
G as checkSemiCssLayer,
|
|
121
128
|
J as checkSemiInternals,
|
|
122
|
-
|
|
123
|
-
|
|
129
|
+
X as checkSemiVersion,
|
|
130
|
+
U as checkUiLibraryUsage
|
|
124
131
|
};
|
package/package.json
CHANGED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx as n, jsxs as u, Fragment as z } from "react/jsx-runtime";
|
|
2
|
-
import { Button as p, Typography as F } from "@douyinfe/semi-ui";
|
|
3
|
-
import { useNavigate as O } from "react-router";
|
|
4
|
-
import { b as S } from "./context-CaVim6ZO.js";
|
|
5
|
-
import { F as f, e as g } from "./page-YBG0dEN1.js";
|
|
6
|
-
import { useId as j, cloneElement as E, forwardRef as L } from "react";
|
|
7
|
-
const Q = () => {
|
|
8
|
-
const { config: i } = S(), r = O();
|
|
9
|
-
return /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n(
|
|
10
|
-
g,
|
|
11
|
-
{
|
|
12
|
-
status: "not-found",
|
|
13
|
-
title: "页面不存在",
|
|
14
|
-
description: "请检查地址,或返回产品首页继续。",
|
|
15
|
-
extra: /* @__PURE__ */ n(p, { theme: "solid", type: "primary", onClick: () => r(i.routes.publicHome), children: "返回首页" })
|
|
16
|
-
}
|
|
17
|
-
) });
|
|
18
|
-
}, P = "_srOnly_1mfs8_2", R = {
|
|
19
|
-
srOnly: P
|
|
20
|
-
}, U = ({ label: i, children: r }) => {
|
|
21
|
-
const t = j();
|
|
22
|
-
return /* @__PURE__ */ u(z, { children: [
|
|
23
|
-
/* @__PURE__ */ n("span", { id: t, className: R.srOnly, children: i }),
|
|
24
|
-
E(r, { "aria-labelledby": t })
|
|
25
|
-
] });
|
|
26
|
-
}, V = () => /* @__PURE__ */ n(f, { children: /* @__PURE__ */ n("div", { role: "alert", children: /* @__PURE__ */ n(
|
|
27
|
-
g,
|
|
28
|
-
{
|
|
29
|
-
status: "error",
|
|
30
|
-
title: "应用配置暂时无法加载",
|
|
31
|
-
description: "启动检查未通过。请检查运行时配置和网络连接后重新加载。",
|
|
32
|
-
extra: /* @__PURE__ */ n(p, { theme: "solid", type: "primary", onClick: () => window.location.reload(), children: "重新加载" })
|
|
33
|
-
}
|
|
34
|
-
) }) }), B = "_link_1mzr6_2", C = "_danger_1mzr6_28", I = "_warning_1mzr6_33", H = "_icon_1mzr6_38", s = {
|
|
35
|
-
link: B,
|
|
36
|
-
danger: C,
|
|
37
|
-
warning: I,
|
|
38
|
-
icon: H
|
|
39
|
-
}, W = L(function({ href: r, target: t, rel: c, download: _, onClick: a, onKeyDown: l, icon: d, status: m, disabled: o = !1, className: y, style: h, role: k, tabIndex: x, children: w, ...N }, b) {
|
|
40
|
-
const T = [s.link, m === "danger" ? s.danger : m === "warning" ? s.warning : "", y ?? ""].filter(Boolean).join(" "), v = {
|
|
41
|
-
...N,
|
|
42
|
-
ref: b,
|
|
43
|
-
href: r,
|
|
44
|
-
target: t,
|
|
45
|
-
rel: t === "_blank" ? c ?? "noreferrer" : c,
|
|
46
|
-
download: _,
|
|
47
|
-
onClick: o ? void 0 : a,
|
|
48
|
-
onKeyDown: (e) => {
|
|
49
|
-
l == null || l(e), !(e.defaultPrevented || r || o || !a) && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), a(e));
|
|
50
|
-
},
|
|
51
|
-
role: k ?? (r ? void 0 : "button"),
|
|
52
|
-
tabIndex: x ?? (r || o ? void 0 : 0),
|
|
53
|
-
"aria-disabled": o || void 0
|
|
54
|
-
};
|
|
55
|
-
return /* @__PURE__ */ u(F.Text, { link: v, disabled: o, className: T, style: h, children: [
|
|
56
|
-
d ? /* @__PURE__ */ n("span", { className: s.icon, children: d }) : null,
|
|
57
|
-
w
|
|
58
|
-
] });
|
|
59
|
-
});
|
|
60
|
-
export {
|
|
61
|
-
Q as N,
|
|
62
|
-
U as S,
|
|
63
|
-
W as T,
|
|
64
|
-
V as a
|
|
65
|
-
};
|