@24city/web-console 0.1.3 → 0.2.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.
Files changed (51) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/GUIDELINES.md +223 -0
  3. package/README.md +42 -10
  4. package/dist/account/index.js +2 -2
  5. package/dist/chunks/console-layout-BWz1qRog.js +210 -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-BXu-WxJa.js → wallet-badge-dVrO6py9.js} +136 -136
  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 +1973 -575
  41. package/dist/testing/guard.d.ts +20 -0
  42. package/dist/testing/guard.js +83 -36
  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/package.json +13 -2
  47. package/dist/chunks/console-layout-D5YgsZYN.js +0 -208
  48. package/dist/chunks/error-boundary-D3qiD7ov.js +0 -35
  49. package/dist/chunks/page-BaitnD--.js +0 -89
  50. package/dist/chunks/text-link-FTsBp_QU.js +0 -54
  51. package/dist/chunks/upgrade-modal-J0X79nT2.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` 目录的绝对路径 */
@@ -35,3 +37,21 @@ export declare const checkSemiVersion: (productPackageJsonPath: string) => UiGua
35
37
  * (主题写在 `semi` 层里),产品自己的覆盖样式也要逐条比 Semi 的选择器更具体才生效。传 `apps/web/vite.config.ts` 的路径。
36
38
  */
37
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 u, readdirSync as y, statSync as E } from "node:fs";
2
- import { relative as S, join as b } from "node:path";
3
- const v = { "@douyinfe/semi-ui": "2.104.0" }, g = {
4
- peerDependencies: v
5
- }, $ = /<(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|>|\/)/, L = [
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,43 +15,43 @@ const v = { "@douyinfe/semi-ui": "2.104.0" }, g = {
14
15
  ".arco-",
15
16
  "@douyinfe/semi-ui/dist/css",
16
17
  "theme-mode"
17
- ], x = ["--semi-", "--app-"], A = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b/, C = /\b(?:rgba?|hsla?)\((?!\s*var\()/, R = new RegExp(`(?:^|[\\s{;'"])(${x.map((s) => s.replace(/-/g, "\\-")).join("|")})[a-z0-9_-]*\\s*['"]?\\s*:`, "m"), p = (s) => y(s).flatMap((i) => {
18
- const e = b(s, i);
19
- return E(e).isDirectory() ? p(e) : [e];
20
- }), _ = (s) => /\.test\.(ts|tsx)$/.test(s) || s.startsWith("test/") || s.endsWith(".d.ts"), N = ({ sourceRoot: s, exclude: i = _ }) => {
21
- const e = [], r = p(s).map((o) => ({ path: o, file: S(s, o) })).filter(({ file: o }) => !i(o));
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));
22
23
  for (const { path: o, file: t } of r) {
23
24
  const n = t.endsWith(".tsx");
24
25
  if (!/\.(tsx?|css)$/.test(t)) continue;
25
- const c = u(o, "utf8");
26
+ const c = d(o, "utf8");
26
27
  if (n) {
27
- const a = c.match($);
28
- a && e.push({ file: t, rule: "raw-element", detail: `应改用 Semi 组件,而不是 ${a[0].trim()}` }), /className="/.test(c) && e.push({ file: t, 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 a of L)
31
- c.includes(a) && e.push({ file: t, rule: "forbidden-import", detail: `不应引用 ${a}` });
32
- const d = c.match(A);
33
- d && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${d[0]}` });
34
- const m = c.match(C);
35
- m && e.push({ file: t, rule: "color-literal", detail: `含有写死的色值 ${m[0]}` });
36
- const f = c.match(R);
37
- f && e.push({ file: t, 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
- }, w = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], D = g.peerDependencies, l = D["@douyinfe/semi-ui"], O = (s) => {
41
+ }, k = ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "@douyinfe/semi-illustrations"], W = C.peerDependencies, f = W["@douyinfe/semi-ui"], K = (s) => {
41
42
  var r, o;
42
- const i = JSON.parse(u(s, "utf8")), e = [];
43
- for (const t of w) {
43
+ const i = JSON.parse(d(s, "utf8")), e = [];
44
+ for (const t of k) {
44
45
  const n = ((r = i.dependencies) == null ? void 0 : r[t]) ?? ((o = i.devDependencies) == null ? void 0 : o[t]);
45
- !(t === "@douyinfe/semi-ui" || n !== void 0) || n === l || e.push({
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 ? `${t} 必须精确声明为 ${l},现在是 ${n}` : `必须声明 ${t} ${l}`
49
+ detail: n ? `${t} 必须精确声明为 ${f},现在是 ${n}` : `必须声明 ${t} ${f}`
49
50
  });
50
51
  }
51
52
  return e;
52
- }, T = (s) => {
53
- const i = u(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);
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);
54
55
  return e && r ? [] : [
55
56
  {
56
57
  file: "vite.config.ts",
@@ -58,14 +59,60 @@ const v = { "@douyinfe/semi-ui": "2.104.0" }, g = {
58
59
  detail: "plugins 里要加 semiCssLayer()(import { semiCssLayer } from '@24city/web-console/vite'),把 Semi 的样式放进 semi 层"
59
60
  }
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;
61
104
  };
62
105
  export {
63
- l as EXPECTED_SEMI_VERSION,
64
- L as FORBIDDEN_SNIPPETS,
65
- $ as RAW_ELEMENT_PATTERN,
66
- x as RESERVED_VARIABLE_PREFIXES,
67
- w as SEMI_PACKAGES,
68
- T as checkSemiCssLayer,
69
- O as checkSemiVersion,
70
- N 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
71
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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@24city/web-console",
3
- "version": "0.1.3",
4
- "description": "24.city 产品用户端的控制台外壳、账号菜单、个人中心、会员引导与 Semi Design 主题",
3
+ "version": "0.2.1",
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",
@@ -1,208 +0,0 @@
1
- import { jsx as n, jsxs as c, Fragment as O } from "react/jsx-runtime";
2
- import { useState as b, useEffect as S } from "react";
3
- import { Layout as k, Button as f, Typography as F, Space as Q, Nav as $ } from "@douyinfe/semi-ui";
4
- import { IconSidebar as P } 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-BXu-WxJa.js";
7
- import { u as R, b as ne, a as te } from "./context-CaVim6ZO.js";
8
- import { u as ae } from "./use-media-query-DvyinWNg.js";
9
- const oe = "_layout_1pk01_6", se = "_header_1pk01_13", le = "_headerLeft_1pk01_34", re = "_logo_1pk01_42", ce = "_logoMark_1pk01_57", ie = "_logoText_1pk01_64", de = "_modules_1pk01_73", ue = "_module_1pk01_73", pe = "_moduleText_1pk01_110", me = "_moduleIcon_1pk01_130", _e = "_moduleInk_1pk01_134", he = "_headerRight_1pk01_154", ke = "_body_1pk01_163", fe = "_sider_1pk01_169", ye = "_siderInner_1pk01_183", ge = "_panel_1pk01_190", Ne = "_expandButton_1pk01_227", ve = "_menu_1pk01_243", be = "_menuGroup_1pk01_254", Ie = "_menuGroupPlain_1pk01_263", xe = "_menuGroupTitle_1pk01_268", Ce = "_menuList_1pk01_279", Me = "_collapseButton_1pk01_402", Be = "_mask_1pk01_423", we = "_content_1pk01_432", Le = "_contentCentered_1pk01_438", Ge = "_contentInner_1pk01_450", Te = "_letterMark_1pk01_503", 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: pe,
19
- moduleIcon: me,
20
- moduleInk: _e,
21
- headerRight: he,
22
- body: ke,
23
- sider: fe,
24
- siderInner: ye,
25
- panel: ge,
26
- expandButton: Ne,
27
- menu: ve,
28
- menuGroup: be,
29
- menuGroupPlain: Ie,
30
- menuGroupTitle: xe,
31
- menuList: Ce,
32
- collapseButton: Me,
33
- mask: Be,
34
- content: we,
35
- contentCentered: Le,
36
- contentInner: Ge,
37
- letterMark: Te
38
- }, $e = (a, l) => a === l || a.startsWith(`${l}/`), Pe = (a, l) => a.flatMap((o) => o.items).find((o) => new URL(o.to, "http://console.local").pathname === l), Se = (a, l) => {
39
- var o;
40
- return (o = [...a].map((r) => ({ module: r, path: new URL(r.to, "http://console.local").pathname })).filter(({ path: r }) => $e(l, r)).sort((r, u) => u.path.length - r.path.length)[0]) == null ? void 0 : o.module;
41
- }, Re = () => {
42
- const [a, l] = b(!1);
43
- return S(() => {
44
- const o = () => l(window.scrollY > 0);
45
- return o(), window.addEventListener("scroll", o, { passive: !0 }), () => window.removeEventListener("scroll", o);
46
- }, []), a;
47
- }, Ae = ({ size: a = 30, className: l }) => {
48
- const o = R(), r = (u) => l ? `${u} ${l}` : u;
49
- return o.markUrl ? /* @__PURE__ */ n(
50
- "span",
51
- {
52
- className: r(e.logoMark),
53
- style: { width: a, height: a, backgroundImage: `url("${o.markUrl}")` },
54
- "aria-hidden": "true"
55
- }
56
- ) : /* @__PURE__ */ n("span", { className: r(e.letterMark), style: { width: a, height: a }, "aria-hidden": "true", children: Array.from(o.mark).slice(0, 2).join("") });
57
- }, Qe = ({
58
- modules: a = [],
59
- activeModuleKey: l,
60
- moduleTarget: o,
61
- sidebar: r = [],
62
- selectedKey: u,
63
- renderItemLabel: I,
64
- headerRight: A,
65
- menuLabel: U = "工作台菜单",
66
- children: E,
67
- extra: K
68
- }) => {
69
- var T;
70
- const { config: x } = ne(), C = R(), y = Y(), g = q(), M = x.routes.app, _ = J(M, V(te())), B = X(M, y.pathname), h = B ? [] : r ?? [], w = h.length > 0, W = l ?? ((T = Se(a, y.pathname)) == null ? void 0 : T.key), p = Pe([...h, _], y.pathname), L = u ?? (p == null ? void 0 : p.key), i = ae("(min-width: 992px)"), j = Re(), [m, N] = b(!i), [v, d] = b(!1), H = new Map([...h, _].flatMap((t) => t.items.map((s) => [s.key, s])));
71
- S(() => {
72
- N(!i), d(!1);
73
- }, [i]);
74
- const G = (t) => {
75
- const s = H.get(t);
76
- s && g(s.to), d(!1);
77
- };
78
- return /* @__PURE__ */ c(k, { className: e.layout, children: [
79
- /* @__PURE__ */ c(k.Header, { className: e.header, "data-scrolled": j ? "true" : "false", children: [
80
- /* @__PURE__ */ c("div", { className: e.headerLeft, children: [
81
- /* @__PURE__ */ c(
82
- f,
83
- {
84
- theme: "borderless",
85
- type: "tertiary",
86
- className: e.logo,
87
- "aria-label": `${C.shortName} 首页`,
88
- onClick: () => g(x.routes.publicHome),
89
- children: [
90
- /* @__PURE__ */ n(Ae, {}),
91
- /* @__PURE__ */ n(F.Text, { className: e.logoText, children: C.shortName })
92
- ]
93
- }
94
- ),
95
- a.length ? /* @__PURE__ */ n("div", { className: e.modules, role: "navigation", "aria-label": "产品模块", children: a.map((t) => /* @__PURE__ */ c(
96
- f,
97
- {
98
- theme: "borderless",
99
- type: "tertiary",
100
- className: e.module,
101
- "aria-current": W === t.key ? "page" : void 0,
102
- onClick: () => g(o ? o(t) : t.to),
103
- children: [
104
- /* @__PURE__ */ c("span", { className: e.moduleText, children: [
105
- t.icon ? /* @__PURE__ */ n("span", { className: e.moduleIcon, children: /* @__PURE__ */ n(t.icon, {}) }) : null,
106
- t.label
107
- ] }),
108
- /* @__PURE__ */ n("span", { className: e.moduleInk, "aria-hidden": "true" })
109
- ]
110
- },
111
- t.key
112
- )) }) : null
113
- ] }),
114
- /* @__PURE__ */ n(Q, { spacing: 10, className: e.headerRight, children: A ?? /* @__PURE__ */ c(O, { children: [
115
- /* @__PURE__ */ n(Z, {}),
116
- /* @__PURE__ */ n(z, {}),
117
- /* @__PURE__ */ n(ee, { personal: _, selectedKey: p && _.items.includes(p) ? p.key : void 0, onOpen: G })
118
- ] }) })
119
- ] }),
120
- /* @__PURE__ */ c(k, { className: e.body, children: [
121
- w ? /* @__PURE__ */ n("aside", { className: e.sider, "data-collapsed": m ? "true" : "false", children: /* @__PURE__ */ c(
122
- "div",
123
- {
124
- className: e.siderInner,
125
- "data-collapsed": m ? "true" : "false",
126
- "data-peek": v ? "true" : "false",
127
- onMouseEnter: () => {
128
- m && i && d(!0);
129
- },
130
- onMouseLeave: () => {
131
- i && d(!1);
132
- },
133
- children: [
134
- m ? /* @__PURE__ */ n(
135
- f,
136
- {
137
- theme: "light",
138
- type: "tertiary",
139
- className: e.expandButton,
140
- icon: /* @__PURE__ */ n(P, { "aria-hidden": "true" }),
141
- "aria-label": "展开侧边栏",
142
- "aria-expanded": v,
143
- onClick: () => {
144
- i ? (N(!1), d(!1)) : d((t) => !t);
145
- }
146
- }
147
- ) : null,
148
- /* @__PURE__ */ c("div", { className: e.panel, children: [
149
- /* @__PURE__ */ n("nav", { className: e.menu, "aria-label": U, children: h.map((t) => /* @__PURE__ */ c(
150
- "div",
151
- {
152
- className: t.label ? e.menuGroup : `${e.menuGroup} ${e.menuGroupPlain}`,
153
- role: "group",
154
- "aria-label": t.label || void 0,
155
- children: [
156
- t.label ? /* @__PURE__ */ n("div", { className: e.menuGroupTitle, children: t.label }) : null,
157
- /* @__PURE__ */ n(
158
- $,
159
- {
160
- mode: "vertical",
161
- className: e.menuList,
162
- selectedKeys: L ? [L] : [],
163
- onSelect: ({ itemKey: s }) => G(String(s)),
164
- children: t.items.map((s) => /* @__PURE__ */ n(
165
- $.Item,
166
- {
167
- itemKey: s.key,
168
- icon: s.icon ? /* @__PURE__ */ n(s.icon, {}) : void 0,
169
- text: I ? I(s) : s.label
170
- },
171
- s.key
172
- ))
173
- }
174
- )
175
- ]
176
- },
177
- t.key
178
- )) }),
179
- i ? /* @__PURE__ */ n(
180
- f,
181
- {
182
- theme: "borderless",
183
- type: "tertiary",
184
- className: e.collapseButton,
185
- icon: /* @__PURE__ */ n(P, { "aria-hidden": "true" }),
186
- onClick: () => {
187
- N((t) => !t), d(!1);
188
- },
189
- children: m ? "固定侧边栏" : "收起侧边栏"
190
- }
191
- ) : null
192
- ] })
193
- ]
194
- }
195
- ) }) : null,
196
- v && !i && w ? /* @__PURE__ */ n("div", { className: e.mask, "aria-hidden": "true", onClick: () => d(!1) }) : null,
197
- /* @__PURE__ */ n(k.Content, { className: B ? `${e.content} ${e.contentCentered}` : e.content, children: /* @__PURE__ */ n("div", { className: e.contentInner, children: E ?? /* @__PURE__ */ n(D, {}) }) })
198
- ] }),
199
- K
200
- ] });
201
- };
202
- export {
203
- Ae as B,
204
- Qe as C,
205
- Pe as a,
206
- Se as f,
207
- $e as i
208
- };
@@ -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
- };