@24city/web-console 0.1.2 → 0.2.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/GUIDELINES.md +223 -0
  3. package/README.md +70 -11
  4. package/dist/account/index.js +2 -2
  5. package/dist/chunks/console-layout-DH-aROYp.js +209 -0
  6. package/dist/chunks/page-YBG0dEN1.js +111 -0
  7. package/dist/chunks/scale-smFifpMm.js +26 -0
  8. package/dist/chunks/{stale-build-DUKkQHuu.js → stale-build-DG-Tb2RA.js} +24 -20
  9. package/dist/chunks/status-tag-BrLUhH6Z.js +87 -0
  10. package/dist/chunks/text-link-BAKoHe5o.js +64 -0
  11. package/dist/chunks/unsupported-browser-Dwq1mNRy.js +48 -0
  12. package/dist/chunks/upgrade-modal-DgChxbLm.js +667 -0
  13. package/dist/chunks/{wallet-badge-CnyMLpUO.js → wallet-badge-dVrO6py9.js} +118 -118
  14. package/dist/chunks/waterfall-CQG8aVdx.js +613 -0
  15. package/dist/data/index.d.ts +2 -0
  16. package/dist/data/index.js +6 -0
  17. package/dist/data/metric-card.d.ts +41 -0
  18. package/dist/data/status-tag.d.ts +18 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +160 -120
  21. package/dist/layout/index.js +1 -1
  22. package/dist/list/choice-cards.d.ts +29 -0
  23. package/dist/list/content-square.d.ts +50 -0
  24. package/dist/list/filter-dropdown.d.ts +43 -0
  25. package/dist/list/filter-panel.d.ts +94 -0
  26. package/dist/list/index.d.ts +7 -0
  27. package/dist/list/index.js +27 -0
  28. package/dist/list/list-toolbar.d.ts +56 -0
  29. package/dist/list/waterfall-layout.d.ts +11 -0
  30. package/dist/list/waterfall.d.ts +13 -0
  31. package/dist/page/index.d.ts +2 -0
  32. package/dist/page/index.js +19 -15
  33. package/dist/page/page.d.ts +21 -2
  34. package/dist/page/select-label.d.ts +11 -0
  35. package/dist/page/unsupported-browser.d.ts +2 -0
  36. package/dist/runtime/browser-support.d.ts +6 -0
  37. package/dist/runtime/index.d.ts +1 -0
  38. package/dist/runtime/index.js +38 -37
  39. package/dist/runtime/providers.d.ts +1 -1
  40. package/dist/styles.css +1993 -576
  41. package/dist/testing/guard.d.ts +25 -0
  42. package/dist/testing/guard.js +95 -38
  43. package/dist/theme/index.d.ts +1 -0
  44. package/dist/theme/index.js +29 -25
  45. package/dist/theme/scale.d.ts +34 -0
  46. package/dist/vite.d.ts +24 -0
  47. package/dist/vite.js +24 -0
  48. package/package.json +18 -2
  49. package/dist/chunks/console-layout-BibioK5M.js +0 -198
  50. package/dist/chunks/error-boundary-D3qiD7ov.js +0 -35
  51. package/dist/chunks/page-BaitnD--.js +0 -89
  52. package/dist/chunks/text-link-FTsBp_QU.js +0 -54
  53. package/dist/chunks/upgrade-modal-_psMAWRK.js +0 -667
@@ -3,6 +3,8 @@ export interface UiGuardViolation {
3
3
  file: string;
4
4
  rule: string;
5
5
  detail: string;
6
+ /** 所在行(从 1 起);只有逐处报告的检查(checkDesignScale、checkSemiInternals)才有 */
7
+ line?: number;
6
8
  }
7
9
  export interface UiGuardOptions {
8
10
  /** 产品 `src` 目录的绝对路径 */
@@ -30,3 +32,26 @@ export declare const EXPECTED_SEMI_VERSION: string;
30
32
  * 图标与插画包若有声明也必须是同一版本。传产品 `apps/web/package.json` 的路径;返回空数组表示一致。
31
33
  */
32
34
  export declare const checkSemiVersion: (productPackageJsonPath: string) => UiGuardViolation[];
35
+ /**
36
+ * 检查产品的 Vite 配置用了 `@24city/web-console/vite` 的 `semiCssLayer()`:不分层时本包主题会被 Semi 的样式整体压掉
37
+ * (主题写在 `semi` 层里),产品自己的覆盖样式也要逐条比 Semi 的选择器更具体才生效。传 `apps/web/vite.config.ts` 的路径。
38
+ */
39
+ export declare const checkSemiCssLayer: (viteConfigPath: string) => UiGuardViolation[];
40
+ /** 允许写死的字号(px):文字阶梯(`--app-font-size-*` 的取值)加展示尺寸。 */
41
+ export declare const ALLOWED_FONT_SIZES: readonly number[];
42
+ /** 允许出现在 @media 里的宽度(px)。 */
43
+ export declare const ALLOWED_BREAKPOINTS: readonly number[];
44
+ /**
45
+ * 检查样式里写死的字号和断点是否落在设计阶梯上,逐处报告(带行号):
46
+ * - `font-size: Npx` 的 N 必须是字号阶梯或展示尺寸里的值(引用 `var(--app-font-size-*)`、`inherit`、`em` 等不受限);
47
+ * - `@media` 里 `min-width` / `max-width` 的像素值必须是断点之一。
48
+ * 新产品 `expect(checkDesignScale({ sourceRoot })).toEqual([])`;存量产品可以先断言数量不超过现状,只减不增。
49
+ */
50
+ export declare const checkDesignScale: ({ sourceRoot, exclude }: UiGuardOptions) => UiGuardViolation[];
51
+ /**
52
+ * 找出伸进 Semi 组件内部结构的选择器(`.mine :global(.semi-card-body)` 这类),逐处报告(带行号)。
53
+ * 这类样式依赖 Semi 的内部类名,Semi 升级时会悄悄失效:优先用组件自己的属性(`bodyStyle`、`imgStyle`、`inputStyle` 等),
54
+ * 多个产品都要的调整提给底座统一做。用自己的类直接修饰 Semi 元素(`.mine:global(.semi-button)` 或只写 `.mine`)不在此列。
55
+ * 这是一条只减不增的检查:产品断言数量不超过现状,例如 `expect(checkSemiInternals({ sourceRoot }).length).toBeLessThanOrEqual(12)`。
56
+ */
57
+ export declare const checkSemiInternals: ({ sourceRoot, exclude }: UiGuardOptions) => UiGuardViolation[];
@@ -1,8 +1,9 @@
1
- import { readFileSync as m, readdirSync as E, statSync as S } from "node:fs";
2
- import { relative as y, join as $ } from "node:path";
3
- const v = { "@douyinfe/semi-ui": "2.104.0" }, b = {
4
- peerDependencies: v
5
- }, x = /<(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|>|\/)/, A = [
1
+ import { readFileSync as d, readdirSync as $, statSync as v } from "node:fs";
2
+ import { relative as b, join as x } from "node:path";
3
+ import { D as _, F as I, B as N } from "../chunks/scale-smFifpMm.js";
4
+ const O = { "@douyinfe/semi-ui": "2.104.0" }, C = {
5
+ peerDependencies: O
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|>|\/)/, R = [
6
7
  "lucide-react",
7
8
  "@nuwa/customer-ui",
8
9
  "@nuwa/customer-shell",
@@ -14,48 +15,104 @@ const v = { "@douyinfe/semi-ui": "2.104.0" }, b = {
14
15
  ".arco-",
15
16
  "@douyinfe/semi-ui/dist/css",
16
17
  "theme-mode"
17
- ], R = ["--semi-", "--app-"], _ = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, g = /\b(?:rgba?|hsla?)\((?!\s*var\()/, D = new RegExp(`(?:^|[\\s{;'"])(${R.map((t) => t.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), p = (t) => E(t).flatMap((o) => {
18
- const e = $(t, o);
19
- return S(e).isDirectory() ? p(e) : [e];
20
- }), F = (t) => /\.test\.(ts|tsx)$/.test(t) || t.startsWith("test/") || t.endsWith(".d.ts"), O = ({ sourceRoot: t, exclude: o = F }) => {
21
- const e = [], a = p(t).map((i) => ({ path: i, file: y(t, i) })).filter(({ file: i }) => !o(i));
22
- for (const { path: i, file: s } of a) {
23
- const n = s.endsWith(".tsx");
24
- if (!/\.(tsx?|css)$/.test(s)) continue;
25
- const r = m(i, "utf8");
18
+ ], T = ["--semi-", "--app-"], w = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, F = /\b(?:rgba?|hsla?)\((?!\s*var\()/, P = new RegExp(`(?:^|[\\s{;'"])(${T.map((s) => s.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), h = (s) => $(s).flatMap((i) => {
19
+ const e = x(s, i);
20
+ return v(e).isDirectory() ? h(e) : [e];
21
+ }), S = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"), Z = ({ sourceRoot: s, exclude: i = S }) => {
22
+ const e = [], r = h(s).map((o) => ({ path: o, file: b(s, o) })).filter(({ file: o }) => !i(o));
23
+ for (const { path: o, file: t } of r) {
24
+ const n = t.endsWith(".tsx");
25
+ if (!/\.(tsx?|css)$/.test(t)) continue;
26
+ const c = d(o, "utf8");
26
27
  if (n) {
27
- const c = r.match(x);
28
- c && e.push({ file: s, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${c[0].trim()}` }), /className="/.test(r) && e.push({ file: s, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
28
+ const m = c.match(D);
29
+ m && e.push({ file: t, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${m[0].trim()}` }), /className="/.test(c) && e.push({ file: t, rule: "class-string", detail: "className 应引用 CSS Module,不写工具类字符串" });
29
30
  }
30
- for (const c of A)
31
- r.includes(c) && e.push({ file: s, rule: "forbidden-import", detail: `不应引用 ${c}` });
32
- const u = r.match(_);
33
- u && e.push({ file: s, rule: "color-literal", detail: `含有写死的色值 ${u[0]}` });
34
- const d = r.match(g);
35
- d && e.push({ file: s, rule: "color-literal", detail: `含有写死的色值 ${d[0]}` });
36
- const f = r.match(D);
37
- f && e.push({ file: s, rule: "reserved-variable", detail: `不得声明主题变量 ${f[1]}…,品牌主色只能通过 runtime-config 的 brand.primaryColor 设置` });
31
+ for (const m of R)
32
+ c.includes(m) && e.push({ file: t, rule: "forbidden-import", detail: `不应引用 ${m}` });
33
+ const a = c.match(w);
34
+ a && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${a[0]}` });
35
+ const u = c.match(F);
36
+ u && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${u[0]}` });
37
+ const E = c.match(P);
38
+ E && e.push({ file: t, rule: "reserved-variable", detail: `不得声明主题变量 ${E[1]}…,品牌主色只能通过 runtime-config 的 brand.primaryColor 设置` });
38
39
  }
39
40
  return e;
40
- }, I = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], N = b.peerDependencies, l = N["@douyinfe/semi-ui"], T = (t) => {
41
- var a, i;
42
- const o = JSON.parse(m(t, "utf8")), e = [];
43
- for (const s of I) {
44
- const n = ((a = o.dependencies) == null ? void 0 : a[s]) ?? ((i = o.devDependencies) == null ? void 0 : i[s]);
45
- !(s === "@douyinfe/semi-ui" || n !== void 0) || n === l || e.push({
41
+ }, k = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], W = C.peerDependencies, f = W["@douyinfe/semi-ui"], K = (s) => {
42
+ var r, o;
43
+ const i = JSON.parse(d(s, "utf8")), e = [];
44
+ for (const t of k) {
45
+ const n = ((r = i.dependencies) == null ? void 0 : r[t]) ?? ((o = i.devDependencies) == null ? void 0 : o[t]);
46
+ !(t === "@douyinfe/semi-ui" || n !== void 0) || n === f || e.push({
46
47
  file: "package.json",
47
48
  rule: "semi-version",
48
- detail: n ? `${s} 必须精确声明为 ${l},现在是 ${n}` : `必须声明 ${s} ${l}`
49
+ detail: n ? `${t} 必须精确声明为 ${f},现在是 ${n}` : `必须声明 ${t} ${f}`
49
50
  });
50
51
  }
51
52
  return e;
53
+ }, U = (s) => {
54
+ const i = d(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);
55
+ return e && r ? [] : [
56
+ {
57
+ file: "vite.config.ts",
58
+ rule: "semi-css-layer",
59
+ detail: "plugins 里要加 semiCssLayer()(import { semiCssLayer } from '@24city/web-console/vite'),把 Semi 的样式放进 semi 层"
60
+ }
61
+ ];
62
+ }, g = [...Object.values(I), ..._], A = Object.values(N), y = (s) => s.replace(/\/\*[\s\S]*?\*\//g, (i) => i.replace(/[^\n]/g, " ")), p = (s, i) => s.slice(0, i).split(`
63
+ `).length, L = (s, i) => h(s).map((e) => ({ path: e, file: b(s, e) })).filter(({ file: e }) => e.endsWith(".css") && !i(e)), X = ({ sourceRoot: s, exclude: i = S }) => {
64
+ const e = [];
65
+ for (const { path: r, file: o } of L(s, i)) {
66
+ const t = y(d(r, "utf8"));
67
+ for (const n of t.matchAll(/font-size\s*:\s*(\d+(?:\.\d+)?)px/g))
68
+ g.includes(Number(n[1])) || e.push({
69
+ file: o,
70
+ line: p(t, n.index),
71
+ rule: "font-size-scale",
72
+ detail: `font-size: ${n[1]}px 不在字号阶梯上(${[...g].sort((l, c) => l - c).join("、")})`
73
+ });
74
+ for (const n of t.matchAll(/@media[^{]*/g))
75
+ for (const l of n[0].matchAll(/(min|max)-width\s*:\s*(\d+(?:\.\d+)?)px/g))
76
+ A.includes(Number(l[2])) || e.push({
77
+ file: o,
78
+ line: p(t, n.index),
79
+ rule: "breakpoint",
80
+ detail: `@media 的 ${l[1]}-width: ${l[2]}px 不是规定的断点(${A.join("、")})`
81
+ });
82
+ }
83
+ return e;
84
+ }, j = /(?:^|[\s>+~])(?::global\(\s*)?\.(semi-[A-Za-z0-9-]+)/, M = /:not\((?:[^()]|\([^()]*\))*\)/g, q = ({ sourceRoot: s, exclude: i = S }) => {
85
+ const e = [];
86
+ for (const { path: r, file: o } of L(s, i)) {
87
+ const t = y(d(r, "utf8"));
88
+ for (const n of t.matchAll(/([^{}]+)\{/g)) {
89
+ const l = n[1];
90
+ if (l.trimStart().startsWith("@")) continue;
91
+ let c = 0;
92
+ for (const a of l.split(",")) {
93
+ const u = a.replace(M, "").trim().match(j);
94
+ u && e.push({
95
+ file: o,
96
+ line: p(t, n.index + c + (a.length - a.trimStart().length)),
97
+ rule: "semi-internals",
98
+ detail: `选择器 ${a.trim()} 伸进了 Semi 组件内部(.${u[1]})`
99
+ }), c += a.length + 1;
100
+ }
101
+ }
102
+ }
103
+ return e;
52
104
  };
53
105
  export {
54
- l as EXPECTED_SEMI_VERSION,
55
- A as FORBIDDEN_SNIPPETS,
56
- x as RAW_ELEMENT_PATTERN,
57
- R as RESERVED_VARIABLE_PREFIXES,
58
- I as SEMI_PACKAGES,
59
- T as checkSemiVersion,
60
- O as checkUiLibraryUsage
106
+ A as ALLOWED_BREAKPOINTS,
107
+ g as ALLOWED_FONT_SIZES,
108
+ f as EXPECTED_SEMI_VERSION,
109
+ R as FORBIDDEN_SNIPPETS,
110
+ D as RAW_ELEMENT_PATTERN,
111
+ T as RESERVED_VARIABLE_PREFIXES,
112
+ k as SEMI_PACKAGES,
113
+ X as checkDesignScale,
114
+ U as checkSemiCssLayer,
115
+ q as checkSemiInternals,
116
+ K as checkSemiVersion,
117
+ Z as checkUiLibraryUsage
61
118
  };
@@ -1,4 +1,5 @@
1
1
  import './theme.css';
2
+ export * from './scale';
2
3
  /**
3
4
  * 由一个品牌色生成十级主色(第 6 级即传入的颜色),返回 "R, G, B" 写法。
4
5
  * 本包的样式用 `--app-brand-1..10` 引用这组颜色;Semi 组件的主色、链接色与聚焦描边由同一组颜色映射。
@@ -1,28 +1,27 @@
1
- const E = /^#[0-9a-fA-F]{6}$/, h = (t) => [
1
+ import { B as N, D as B, F as O, b as k, a as U } from "../chunks/scale-smFifpMm.js";
2
+ const f = /^#[0-9a-fA-F]{6}$/, y = (t) => [
2
3
  parseInt(t.slice(1, 3), 16),
3
4
  parseInt(t.slice(3, 5), 16),
4
5
  parseInt(t.slice(5, 7), 16)
5
- ], _ = ([t, l, r]) => {
6
- const s = t / 255, e = l / 255, o = r / 255, c = Math.max(s, e, o), A = Math.min(s, e, o), a = c - A;
6
+ ], E = ([t, a, r]) => {
7
+ const s = t / 255, e = a / 255, o = r / 255, c = Math.max(s, e, o), m = Math.min(s, e, o), l = c - m;
7
8
  let n = 0;
8
- return a !== 0 && (c === s ? n = (e - o) / a % 6 : c === e ? n = (o - s) / a + 2 : n = (s - e) / a + 4, n *= 60, n < 0 && (n += 360)), { h: n, s: c === 0 ? 0 : a / c * 100, v: c * 100 };
9
- }, p = ({ h: t, s: l, v: r }) => {
10
- const s = l / 100, e = r / 100, o = e * s, c = o * (1 - Math.abs(t / 60 % 2 - 1)), A = e - o, [a, n, m] = t < 60 ? [o, c, 0] : t < 120 ? [c, o, 0] : t < 180 ? [0, o, c] : t < 240 ? [0, c, o] : t < 300 ? [c, 0, o] : [o, 0, c];
11
- return [Math.round((a + A) * 255), Math.round((n + A) * 255), Math.round((m + A) * 255)];
12
- };
13
- const v = (t, l) => {
14
- const r = l < 6, s = r ? 6 - l : l - 6;
15
- if (l === 6) return t;
16
- let e = t.h >= 60 && t.h <= 240 ? r ? t.h - 2 * s : t.h + 2 * s : r ? t.h + 2 * s : t.h - 2 * s;
9
+ return l !== 0 && (c === s ? n = (e - o) / l % 6 : c === e ? n = (o - s) / l + 2 : n = (s - e) / l + 4, n *= 60, n < 0 && (n += 360)), { h: n, s: c === 0 ? 0 : l / c * 100, v: c * 100 };
10
+ }, i = ({ h: t, s: a, v: r }) => {
11
+ const s = a / 100, e = r / 100, o = e * s, c = o * (1 - Math.abs(t / 60 % 2 - 1)), m = e - o, [l, n, A] = t < 60 ? [o, c, 0] : t < 120 ? [c, o, 0] : t < 180 ? [0, o, c] : t < 240 ? [0, c, o] : t < 300 ? [c, 0, o] : [o, 0, c];
12
+ return [Math.round((l + m) * 255), Math.round((n + m) * 255), Math.round((A + m) * 255)];
13
+ }, p = 2, b = 100, h = 9, u = 100, v = 30, d = (t, a) => {
14
+ const r = a < 6, s = r ? 6 - a : a - 6;
15
+ if (a === 6) return t;
16
+ let e = t.h >= 60 && t.h <= 240 ? r ? t.h - p * s : t.h + p * s : r ? t.h + p * s : t.h - p * s;
17
17
  e < 0 ? e += 360 : e >= 360 && (e -= 360);
18
- const o = r ? t.s <= 9 ? t.s : t.s - (t.s - 9) / 5 * s : t.s + (100 - t.s) / 4 * s, c = r ? t.v + (100 - t.v) / 5 * s : t.v <= 30 ? t.v : t.v - (t.v - 30) / 4 * s;
18
+ const o = r ? t.s <= h ? t.s : t.s - (t.s - h) / 5 * s : t.s + (b - t.s) / 4 * s, c = r ? t.v + (u - t.v) / 5 * s : t.v <= v ? t.v : t.v - (t.v - v) / 4 * s;
19
19
  return { h: Math.round(e), s: o, v: c };
20
- }, T = (t) => {
21
- if (!E.test(t)) throw new Error("品牌主色必须是六位十六进制颜色,例如 #E04E06");
22
- const l = _(h(t));
23
- return Array.from({ length: 10 }, (r, s) => p(v(l, s + 1)).join(", "));
24
- };
25
- const y = (t) => T(t), M = Array.from({ length: 10 }, (t, l) => `--app-brand-${l + 1}`), f = {
20
+ }, I = (t) => {
21
+ if (!f.test(t)) throw new Error("品牌主色必须是六位十六进制颜色,例如 #E04E06");
22
+ const a = E(y(t));
23
+ return Array.from({ length: 10 }, (r, s) => i(d(a, s + 1)).join(", "));
24
+ }, S = 10, _ = (t) => I(t), M = Array.from({ length: S }, (t, a) => `--app-brand-${a + 1}`), T = {
26
25
  "--semi-color-primary": 6,
27
26
  "--semi-color-primary-hover": 7,
28
27
  "--semi-color-primary-active": 8,
@@ -35,17 +34,22 @@ const y = (t) => T(t), M = Array.from({ length: 10 }, (t, l) => `--app-brand-${l
35
34
  "--semi-color-link-hover": 7,
36
35
  "--semi-color-link-active": 8,
37
36
  "--semi-color-link-visited": 6
38
- }, I = ({ primaryColor: t, target: l } = {}) => {
39
- const r = l ?? document.body, s = t ? y(t) : null;
37
+ }, P = ({ primaryColor: t, target: a } = {}) => {
38
+ const r = a ?? document.body, s = t ? _(t) : null;
40
39
  M.forEach((e, o) => {
41
40
  s ? r.style.setProperty(e, s[o]) : r.style.removeProperty(e);
42
- }), Object.entries(f).forEach(([e, o]) => {
41
+ }), Object.entries(T).forEach(([e, o]) => {
43
42
  s ? r.style.setProperty(e, `rgb(${s[o - 1]})`) : r.style.removeProperty(e);
44
43
  });
45
44
  };
46
45
  export {
47
46
  M as BRAND_VARIABLES,
48
- f as SEMI_BRAND_VARIABLES,
49
- I as applyBrand,
50
- y as brandPalette
47
+ N as BREAKPOINTS,
48
+ B as DISPLAY_SIZES,
49
+ O as FONT_SIZE_SCALE,
50
+ T as SEMI_BRAND_VARIABLES,
51
+ P as applyBrand,
52
+ _ as brandPalette,
53
+ k as breakpointDown,
54
+ U as breakpointUp
51
55
  };
@@ -0,0 +1,34 @@
1
+ /** 文字字号阶梯(px):键是变量名 `--app-font-size-<键>` 的后缀。 */
2
+ export declare const FONT_SIZE_SCALE: {
3
+ readonly h1: 32;
4
+ readonly h2: 28;
5
+ readonly h3: 24;
6
+ readonly h4: 20;
7
+ readonly h5: 18;
8
+ readonly h6: 16;
9
+ readonly lead: 15;
10
+ readonly body: 14;
11
+ readonly compact: 13;
12
+ readonly caption: 12;
13
+ readonly badge: 11;
14
+ };
15
+ export type FontSizeName = keyof typeof FONT_SIZE_SCALE;
16
+ /** 展示尺寸(px):只用于大数字和大图标,没有对应变量,直接写数值。 */
17
+ export declare const DISPLAY_SIZES: readonly number[];
18
+ /**
19
+ * 断点(px)。CSS 的 @media 里不能用变量,直接写这几个数值,守卫会检查:
20
+ * `max-width: 576px` 手机;`max-width: 768px` 手机与竖屏平板(单列);`min-width: 992px` 侧栏常驻的桌面;
21
+ * `min-width: 1200px` 宽屏;`min-width: 1440px` 大屏(顶栏接产品名)。
22
+ */
23
+ export declare const BREAKPOINTS: {
24
+ readonly phone: 576;
25
+ readonly tablet: 768;
26
+ readonly desktop: 992;
27
+ readonly wide: 1200;
28
+ readonly xwide: 1440;
29
+ };
30
+ export type BreakpointName = keyof typeof BREAKPOINTS;
31
+ /** 视口不小于某个断点的媒体查询,配合 useMediaQuery 使用,例如 `useMediaQuery(breakpointUp('desktop'))`。 */
32
+ export declare const breakpointUp: (name: BreakpointName) => string;
33
+ /** 视口不大于某个断点的媒体查询。 */
34
+ export declare const breakpointDown: (name: BreakpointName) => string;
package/dist/vite.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /** 与 Vite 插件接口兼容的最小形状;本包不依赖 vite 的类型。 */
2
+ export interface SemiCssLayerPlugin {
3
+ name: string;
4
+ enforce: 'pre';
5
+ transform: (code: string, id: string) => {
6
+ code: string;
7
+ map: null;
8
+ } | null;
9
+ }
10
+ /** Semi 的样式文件:`@douyinfe/semi-ui/lib/es/_base/base.css` 和 `@douyinfe/semi-foundation/lib/es/<组件>/<组件>.css`。 */
11
+ export declare const SEMI_CSS_FILE: RegExp;
12
+ /** 分层的名字;本包主题写在同名层里。 */
13
+ export declare const SEMI_CSS_LAYER = "semi";
14
+ /** 把一份 Semi 样式包进 `@layer semi { … }`;`@charset`、`@import` 必须留在最前面。已经分过层的原样返回。 */
15
+ export declare const wrapSemiCss: (code: string) => string;
16
+ /**
17
+ * 产品的 vite.config.ts 必须加上它(本包的守卫 `checkSemiCssLayer` 会检查):
18
+ *
19
+ * ```ts
20
+ * import { semiCssLayer } from '@24city/web-console/vite'
21
+ * export default defineConfig({ plugins: [react(), semiCssLayer()] })
22
+ * ```
23
+ */
24
+ export declare const semiCssLayer: () => SemiCssLayerPlugin;
package/dist/vite.js ADDED
@@ -0,0 +1,24 @@
1
+ const a = /[\\/]@douyinfe[\\/]semi-[a-z-]+[\\/].*\.css(?:$|\?)/, r = "semi", c = /^(?:\s*(?:@charset\s[^;]*;|@import\s[^;]*;|\/\*[\s\S]*?\*\/))+/, l = (s) => {
2
+ var n;
3
+ if (new RegExp(`^\\s*@layer\\s+${r}\\s*\\{`).test(s)) return s;
4
+ const e = ((n = s.match(c)) == null ? void 0 : n[0]) ?? "", t = s.slice(e.length);
5
+ return `${e}${e ? `
6
+ ` : ""}@layer ${r} {
7
+ ${t}
8
+ }
9
+ `;
10
+ }, o = () => ({
11
+ name: "24city-web-console:semi-css-layer",
12
+ enforce: "pre",
13
+ transform(s, e) {
14
+ if (!a.test(e) || /[?&](?:raw|url)\b/.test(e)) return null;
15
+ const t = l(s);
16
+ return t === s ? null : { code: t, map: null };
17
+ }
18
+ });
19
+ export {
20
+ a as SEMI_CSS_FILE,
21
+ r as SEMI_CSS_LAYER,
22
+ o as semiCssLayer,
23
+ l as wrapSemiCss
24
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@24city/web-console",
3
- "version": "0.1.2",
4
- "description": "24.city 产品用户端的控制台外壳、账号菜单、个人中心、会员引导与 Semi Design 主题",
3
+ "version": "0.2.0",
4
+ "description": "24.city 产品用户端的界面底座:Semi Design 主题与设计变量、控制台外壳、账号与会员界面、列表与数据组件、界面规范与守卫",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "sideEffects": [
@@ -9,6 +9,7 @@
9
9
  ],
10
10
  "files": [
11
11
  "README.md",
12
+ "GUIDELINES.md",
12
13
  "CHANGELOG.md",
13
14
  "LICENSE",
14
15
  "dist"
@@ -47,6 +48,11 @@
47
48
  "import": "./dist/account/index.js",
48
49
  "default": "./dist/account/index.js"
49
50
  },
51
+ "./data": {
52
+ "types": "./dist/data/index.d.ts",
53
+ "import": "./dist/data/index.js",
54
+ "default": "./dist/data/index.js"
55
+ },
50
56
  ".": {
51
57
  "types": "./dist/index.d.ts",
52
58
  "import": "./dist/index.js",
@@ -57,6 +63,11 @@
57
63
  "import": "./dist/layout/index.js",
58
64
  "default": "./dist/layout/index.js"
59
65
  },
66
+ "./list": {
67
+ "types": "./dist/list/index.d.ts",
68
+ "import": "./dist/list/index.js",
69
+ "default": "./dist/list/index.js"
70
+ },
60
71
  "./page": {
61
72
  "types": "./dist/page/index.d.ts",
62
73
  "import": "./dist/page/index.js",
@@ -92,6 +103,11 @@
92
103
  "import": "./dist/theme/index.js",
93
104
  "default": "./dist/theme/index.js"
94
105
  },
106
+ "./vite": {
107
+ "types": "./dist/vite.d.ts",
108
+ "import": "./dist/vite.js",
109
+ "default": "./dist/vite.js"
110
+ },
95
111
  "./styles.css": "./dist/styles.css",
96
112
  "./package.json": "./package.json"
97
113
  },
@@ -1,198 +0,0 @@
1
- import { jsx as t, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
- import { useState as v, useEffect as R } from "react";
3
- import { Layout as f, Button as x, Typography as F, Space as Q, Nav as G } from "@douyinfe/semi-ui";
4
- import { IconSidebar as $ } from "@douyinfe/semi-icons";
5
- import { useLocation as Y, useNavigate as q, Outlet as D } from "react-router";
6
- import { h as J, B as V, o as X, e as Z, W as z, b as ee } from "./wallet-badge-CnyMLpUO.js";
7
- import { u as A, b as te, a as ne } from "./context-CaVim6ZO.js";
8
- import { u as ae } from "./use-media-query-DvyinWNg.js";
9
- const oe = "_layout_15fx1_6", se = "_header_15fx1_13", le = "_headerLeft_15fx1_34", re = "_logo_15fx1_42", ce = "_logoMark_15fx1_57", ie = "_logoText_15fx1_64", de = "_modules_15fx1_73", ue = "_module_15fx1_73", me = "_moduleText_15fx1_110", _e = "_moduleIcon_15fx1_130", he = "_moduleInk_15fx1_134", pe = "_headerRight_15fx1_154", fe = "_body_15fx1_163", xe = "_sider_15fx1_169", ye = "_siderInner_15fx1_183", ke = "_panel_15fx1_190", ge = "_expandButton_15fx1_227", Ne = "_menu_15fx1_243", ve = "_menuGroup_15fx1_254", be = "_menuGroupTitle_15fx1_263", Ie = "_menuList_15fx1_274", Ce = "_collapseButton_15fx1_390", Me = "_mask_15fx1_411", Be = "_content_15fx1_420", we = "_contentCentered_15fx1_426", Le = "_contentInner_15fx1_438", Te = "_letterMark_15fx1_491", e = {
10
- layout: oe,
11
- header: se,
12
- headerLeft: le,
13
- logo: re,
14
- logoMark: ce,
15
- logoText: ie,
16
- modules: de,
17
- module: ue,
18
- moduleText: me,
19
- moduleIcon: _e,
20
- moduleInk: he,
21
- headerRight: pe,
22
- body: fe,
23
- sider: xe,
24
- siderInner: ye,
25
- panel: ke,
26
- expandButton: ge,
27
- menu: Ne,
28
- menuGroup: ve,
29
- menuGroupTitle: be,
30
- menuList: Ie,
31
- collapseButton: Ce,
32
- mask: Me,
33
- content: Be,
34
- contentCentered: we,
35
- contentInner: Le,
36
- letterMark: Te
37
- }, Se = (a, l) => a === l || a.startsWith(`${l}/`), Ge = (a, l) => a.flatMap((o) => o.items).find((o) => new URL(o.to, "http://console.local").pathname === l), $e = (a, l) => {
38
- var o;
39
- return (o = [...a].map((r) => ({ module: r, path: new URL(r.to, "http://console.local").pathname })).filter(({ path: r }) => Se(l, r)).sort((r, u) => u.path.length - r.path.length)[0]) == null ? void 0 : o.module;
40
- }, Re = () => {
41
- const [a, l] = v(!1);
42
- return R(() => {
43
- const o = () => l(window.scrollY > 0);
44
- return o(), window.addEventListener("scroll", o, { passive: !0 }), () => window.removeEventListener("scroll", o);
45
- }, []), a;
46
- }, Ae = ({ size: a = 30, className: l }) => {
47
- const o = A(), r = (u) => l ? `${u} ${l}` : u;
48
- return o.markUrl ? /* @__PURE__ */ t(
49
- "span",
50
- {
51
- className: r(e.logoMark),
52
- style: { width: a, height: a, backgroundImage: `url("${o.markUrl}")` },
53
- "aria-hidden": "true"
54
- }
55
- ) : /* @__PURE__ */ t("span", { className: r(e.letterMark), style: { width: a, height: a }, "aria-hidden": "true", children: Array.from(o.mark).slice(0, 2).join("") });
56
- }, Fe = ({
57
- modules: a = [],
58
- activeModuleKey: l,
59
- moduleTarget: o,
60
- sidebar: r = [],
61
- selectedKey: u,
62
- renderItemLabel: b,
63
- headerRight: U,
64
- menuLabel: E = "工作台菜单",
65
- children: K,
66
- extra: P
67
- }) => {
68
- var S;
69
- const { config: I } = te(), C = A(), y = Y(), k = q(), M = I.routes.app, h = J(M, V(ne())), B = X(M, y.pathname), p = B ? [] : r ?? [], w = p.length > 0, W = l ?? ((S = $e(a, y.pathname)) == null ? void 0 : S.key), m = Ge([...p, h], y.pathname), L = u ?? (m == null ? void 0 : m.key), i = ae("(min-width: 992px)"), j = Re(), [_, g] = v(!i), [N, d] = v(!1), H = new Map([...p, h].flatMap((n) => n.items.map((s) => [s.key, s])));
70
- R(() => {
71
- g(!i), d(!1);
72
- }, [i]);
73
- const T = (n) => {
74
- const s = H.get(n);
75
- s && k(s.to), d(!1);
76
- };
77
- return /* @__PURE__ */ c(f, { className: e.layout, children: [
78
- /* @__PURE__ */ c(f.Header, { className: e.header, "data-scrolled": j ? "true" : "false", children: [
79
- /* @__PURE__ */ c("div", { className: e.headerLeft, children: [
80
- /* @__PURE__ */ c(
81
- x,
82
- {
83
- theme: "borderless",
84
- type: "tertiary",
85
- className: e.logo,
86
- "aria-label": `${C.shortName} 首页`,
87
- onClick: () => k(I.routes.publicHome),
88
- children: [
89
- /* @__PURE__ */ t(Ae, {}),
90
- /* @__PURE__ */ t(F.Text, { className: e.logoText, children: C.shortName })
91
- ]
92
- }
93
- ),
94
- a.length ? /* @__PURE__ */ t("div", { className: e.modules, role: "navigation", "aria-label": "产品模块", children: a.map((n) => /* @__PURE__ */ c(
95
- x,
96
- {
97
- theme: "borderless",
98
- type: "tertiary",
99
- className: e.module,
100
- "aria-current": W === n.key ? "page" : void 0,
101
- onClick: () => k(o ? o(n) : n.to),
102
- children: [
103
- /* @__PURE__ */ c("span", { className: e.moduleText, children: [
104
- n.icon ? /* @__PURE__ */ t("span", { className: e.moduleIcon, children: /* @__PURE__ */ t(n.icon, {}) }) : null,
105
- n.label
106
- ] }),
107
- /* @__PURE__ */ t("span", { className: e.moduleInk, "aria-hidden": "true" })
108
- ]
109
- },
110
- n.key
111
- )) }) : null
112
- ] }),
113
- /* @__PURE__ */ t(Q, { spacing: 10, className: e.headerRight, children: U ?? /* @__PURE__ */ c(O, { children: [
114
- /* @__PURE__ */ t(Z, {}),
115
- /* @__PURE__ */ t(z, {}),
116
- /* @__PURE__ */ t(ee, { personal: h, selectedKey: m && h.items.includes(m) ? m.key : void 0, onOpen: T })
117
- ] }) })
118
- ] }),
119
- /* @__PURE__ */ c(f, { className: e.body, children: [
120
- w ? /* @__PURE__ */ t("aside", { className: e.sider, "data-collapsed": _ ? "true" : "false", children: /* @__PURE__ */ c(
121
- "div",
122
- {
123
- className: e.siderInner,
124
- "data-collapsed": _ ? "true" : "false",
125
- "data-peek": N ? "true" : "false",
126
- onMouseEnter: () => {
127
- _ && i && d(!0);
128
- },
129
- onMouseLeave: () => {
130
- i && d(!1);
131
- },
132
- children: [
133
- _ ? /* @__PURE__ */ t(
134
- x,
135
- {
136
- theme: "light",
137
- type: "tertiary",
138
- className: e.expandButton,
139
- icon: /* @__PURE__ */ t($, { "aria-hidden": "true" }),
140
- "aria-label": "展开侧边栏",
141
- "aria-expanded": N,
142
- onClick: () => {
143
- i ? (g(!1), d(!1)) : d((n) => !n);
144
- }
145
- }
146
- ) : null,
147
- /* @__PURE__ */ c("div", { className: e.panel, children: [
148
- /* @__PURE__ */ t("nav", { className: e.menu, "aria-label": E, children: p.map((n) => /* @__PURE__ */ c("div", { className: e.menuGroup, role: "group", "aria-label": n.label || void 0, children: [
149
- n.label ? /* @__PURE__ */ t("div", { className: e.menuGroupTitle, children: n.label }) : null,
150
- /* @__PURE__ */ t(
151
- G,
152
- {
153
- mode: "vertical",
154
- className: e.menuList,
155
- selectedKeys: L ? [L] : [],
156
- onSelect: ({ itemKey: s }) => T(String(s)),
157
- children: n.items.map((s) => /* @__PURE__ */ t(
158
- G.Item,
159
- {
160
- itemKey: s.key,
161
- icon: s.icon ? /* @__PURE__ */ t(s.icon, {}) : void 0,
162
- text: b ? b(s) : s.label
163
- },
164
- s.key
165
- ))
166
- }
167
- )
168
- ] }, n.key)) }),
169
- i ? /* @__PURE__ */ t(
170
- x,
171
- {
172
- theme: "borderless",
173
- type: "tertiary",
174
- className: e.collapseButton,
175
- icon: /* @__PURE__ */ t($, { "aria-hidden": "true" }),
176
- onClick: () => {
177
- g((n) => !n), d(!1);
178
- },
179
- children: _ ? "固定侧边栏" : "收起侧边栏"
180
- }
181
- ) : null
182
- ] })
183
- ]
184
- }
185
- ) }) : null,
186
- N && !i && w ? /* @__PURE__ */ t("div", { className: e.mask, "aria-hidden": "true", onClick: () => d(!1) }) : null,
187
- /* @__PURE__ */ t(f.Content, { className: B ? `${e.content} ${e.contentCentered}` : e.content, children: /* @__PURE__ */ t("div", { className: e.contentInner, children: K ?? /* @__PURE__ */ t(D, {}) }) })
188
- ] }),
189
- P
190
- ] });
191
- };
192
- export {
193
- Ae as B,
194
- Fe as C,
195
- Ge as a,
196
- $e as f,
197
- Se as i
198
- };
@@ -1,35 +0,0 @@
1
- var l = Object.defineProperty;
2
- var d = (e, t, o) => t in e ? l(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var i = (e, t, o) => d(e, typeof t != "symbol" ? t + "" : t, o);
4
- import { jsx as r } from "react/jsx-runtime";
5
- import { Component as c } from "react";
6
- import { Card as m, Button as p } from "@douyinfe/semi-ui";
7
- import { F as n, c as f } from "./page-BaitnD--.js";
8
- const a = () => /* @__PURE__ */ r("div", { role: "alert", children: /* @__PURE__ */ r(
9
- f,
10
- {
11
- status: "error",
12
- title: "页面暂时无法显示",
13
- description: "本次页面加载没有完成。您可以重新加载;如问题持续,请联系管理员。",
14
- extra: /* @__PURE__ */ r(p, { theme: "solid", type: "primary", onClick: () => window.location.reload(), children: "重新加载" })
15
- }
16
- ) }), E = ({ inLayout: e = !1 }) => e ? /* @__PURE__ */ r(m, { bordered: !1, children: /* @__PURE__ */ r(a, {}) }) : /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(a, {}) });
17
- class F extends c {
18
- constructor() {
19
- super(...arguments);
20
- i(this, "state", { failed: !1 });
21
- }
22
- static getDerivedStateFromError() {
23
- return { failed: !0 };
24
- }
25
- componentDidCatch(o, s) {
26
- console.error("产品用户 Web 渲染失败", o, s.componentStack);
27
- }
28
- render() {
29
- return this.state.failed ? /* @__PURE__ */ r(n, { children: /* @__PURE__ */ r(a, {}) }) : this.props.children;
30
- }
31
- }
32
- export {
33
- F as E,
34
- E as R
35
- };