@done-coding/admin-core 0.12.0 → 0.12.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.
@@ -1,6 +1,6 @@
1
1
  import { watch as s } from "vue";
2
- import { themeScaleDerive as x } from "../utils/theme-scale.mjs";
3
- const p = "admin-core-theme", $ = [
2
+ import { themeScaleDerive as C, themeScaleParseHex as S, themeScaleMix as $, themeScaleToRgba as _ } from "../utils/theme-scale.mjs";
3
+ const u = "admin-core-theme", y = [
4
4
  ["primaryColor", { scale: !0, el: "--el-color-primary" }],
5
5
  ["successColor", { scale: !0, el: "--el-color-success" }],
6
6
  ["warningColor", { scale: !0, el: "--el-color-warning" }],
@@ -18,47 +18,85 @@ const p = "admin-core-theme", $ = [
18
18
  ["blur", {}],
19
19
  ["focusRing", {}],
20
20
  ["surface", {}]
21
- ], u = [
21
+ ], p = [
22
22
  "light-3",
23
23
  "light-5",
24
24
  "light-7",
25
25
  "light-8",
26
26
  "light-9",
27
27
  "dark-2"
28
- ], b = (r) => r.replace(/([A-Z])/g, "-$1").toLowerCase(), g = (r, t) => {
28
+ ], L = (r) => r.replace(/([A-Z])/g, "-$1").toLowerCase(), g = (r, t) => {
29
29
  const e = [];
30
- for (const [l, i] of $) {
30
+ for (const [l, a] of y) {
31
31
  const o = r[l];
32
32
  if (o === void 0 || o === "") continue;
33
- const n = `--admin-core-${b(l)}`, c = i.el === void 0 ? [] : Array.isArray(i.el) ? i.el : [i.el];
34
- if (i.scale) {
35
- const d = x(o, t);
33
+ const n = `--admin-core-${L(l)}`, i = a.el === void 0 ? [] : Array.isArray(a.el) ? a.el : [a.el];
34
+ if (a.scale) {
35
+ const d = C(o, t);
36
36
  e.push(`${n}: ${o};`);
37
- for (const a of u)
38
- e.push(`${n}-${a}: ${d[a]};`);
39
- for (const a of c) {
40
- e.push(`${a}: ${o};`);
41
- for (const m of u)
42
- e.push(`${a}-${m}: ${d[m]};`);
37
+ for (const c of p)
38
+ e.push(`${n}-${c}: ${d[c]};`);
39
+ for (const c of i) {
40
+ e.push(`${c}: ${o};`);
41
+ for (const m of p)
42
+ e.push(`${c}-${m}: ${d[m]};`);
43
43
  }
44
44
  } else {
45
45
  e.push(`${n}: ${o};`);
46
- for (const d of c) e.push(`${d}: ${o};`);
46
+ for (const d of i) e.push(`${d}: ${o};`);
47
47
  }
48
48
  }
49
49
  return e.join(`
50
50
  `);
51
- }, E = (r) => {
52
- const t = g(r.light, "light"), e = g(r.dark, "dark");
51
+ }, A = 0.4, T = 10, v = {
52
+ light: 0.5,
53
+ dark: 0.72
54
+ }, f = (r, t) => {
55
+ if (!r) return "";
56
+ const e = S(r);
57
+ if (!e) return "";
58
+ const l = Math.max(...e), a = l === 0 ? 0 : Math.min(A, T / l), o = $(r, "#000000", a);
59
+ return `--el-overlay-color-lighter: ${_(
60
+ o,
61
+ v[t]
62
+ )};`;
63
+ }, I = { light: 0.9, dark: 0.8 }, h = (r, t) => {
64
+ if (!r) return "";
65
+ const e = _(r, I[t]);
66
+ return e === r ? "" : `--el-mask-color: ${e};`;
67
+ }, P = 0.88, k = (r, t) => !r || !S(r) ? "" : `--admin-core-dialog-surface: ${$(r, "#ffffff", P)};`, D = (r) => {
68
+ const t = r.light, e = r.dark, l = g(t, "light"), a = g(e, "dark"), n = [
69
+ l,
70
+ "color: var(--admin-core-base-color);",
71
+ f(t.bodyColor, "light"),
72
+ h(t.bodyColor, "light")
73
+ ].filter(Boolean), i = [
74
+ a,
75
+ f(e.bodyColor, "dark"),
76
+ h(e.bodyColor, "dark"),
77
+ k(e.bodyColor)
78
+ ].filter(Boolean);
53
79
  return `:root {
54
- ${t}
55
- color: var(--admin-core-base-color);
80
+ ${n.join(
81
+ `
82
+ `
83
+ )}
56
84
  }
57
85
  :root.dark {
58
- ${e}
86
+ ${i.join(`
87
+ `)}
59
88
  }
60
89
  `;
61
- }, f = "admin-core-rhythm", h = "admin-core-ep-bridge", y = [
90
+ }, E = "admin-core-rhythm", b = "admin-core-ep-bridge", x = "admin-core-ep-structural", B = [
91
+ ".el-dialog,",
92
+ ".el-message-box {",
93
+ // elevation:暗色下用提亮过的面板底(--admin-core-dialog-surface,仅 :root.dark 派生),
94
+ // 让整块面板亮于页面底而浮起;缺省(亮色 / 非 hex)退 --el-bg-color,亮色零改动。
95
+ " background-color: var(--admin-core-dialog-surface, var(--el-bg-color));",
96
+ " border: 1px solid var(--admin-core-border-color, var(--el-border-color));",
97
+ "}"
98
+ ].join(`
99
+ `), R = [
62
100
  // T1 必纳:表格行密度(垂直经 td padding,水平经 .cell padding)
63
101
  ".el-table .el-table__cell {",
64
102
  " padding-top: var(--admin-core-cell-padding-y, 8px);",
@@ -75,7 +113,7 @@ const p = "admin-core-theme", $ = [
75
113
  // 注:dialog/card 内距撤到期二——其 EP 原生值(dialog 16 / card 20)与单一
76
114
  // content-gap 无法同时对齐,本期纳入会破"默认档零漂移";期二用专属 var 补。
77
115
  ].join(`
78
- `), S = {
116
+ `), w = {
79
117
  compact: {
80
118
  spaceUnit: "4px",
81
119
  gap: "8px",
@@ -108,7 +146,7 @@ const p = "admin-core-theme", $ = [
108
146
  fontSizeBase: "15px",
109
147
  fontScale: "1.25"
110
148
  }
111
- }, C = {
149
+ }, H = {
112
150
  snappy: {
113
151
  duration: "120ms",
114
152
  durationSlow: "180ms",
@@ -127,8 +165,8 @@ const p = "admin-core-theme", $ = [
127
165
  easing: "cubic-bezier(0.22, 0.61, 0.36, 1)"
128
166
  }
129
167
  };
130
- function _(r, t) {
131
- const e = S[r], l = C[t], i = [
168
+ function Y(r, t) {
169
+ const e = w[r], l = H[t], a = [
132
170
  `--admin-core-space-unit: ${e.spaceUnit};`,
133
171
  `--admin-core-content-gap: ${e.gap};`,
134
172
  `--admin-core-control-height: ${e.controlHeight};`,
@@ -153,7 +191,7 @@ function _(r, t) {
153
191
  "--el-transition-duration-fast: 0.01ms;"
154
192
  ];
155
193
  return `:root {
156
- ${i.join(`
194
+ ${a.join(`
157
195
  `)}
158
196
  }
159
197
  @media (prefers-reduced-motion: reduce) {
@@ -166,17 +204,21 @@ function _(r, t) {
166
204
  }
167
205
  `;
168
206
  }
169
- function T(r) {
207
+ function U(r) {
170
208
  const t = r.document ?? (typeof document < "u" ? document : void 0);
171
209
  if (!t) return;
172
210
  const e = () => {
173
- let o = t.getElementById(p);
174
- return o || (o = t.createElement("style"), o.id = p, t.head.appendChild(o)), o;
211
+ let o = t.getElementById(u);
212
+ return o || (o = t.createElement("style"), o.id = u, t.head.appendChild(o)), o;
175
213
  };
214
+ if (!t.getElementById(x)) {
215
+ const o = t.createElement("style");
216
+ o.id = x, o.textContent = B, t.head.appendChild(o);
217
+ }
176
218
  s(
177
219
  r.getThemeConfig,
178
220
  (o) => {
179
- e().textContent = E(o);
221
+ e().textContent = D(o);
180
222
  },
181
223
  { deep: !0, immediate: !0 }
182
224
  ), s(
@@ -186,28 +228,28 @@ function T(r) {
186
228
  },
187
229
  { immediate: !0 }
188
230
  );
189
- const { getThemeDensity: l, getThemeMotion: i } = r;
190
- if (l && i) {
191
- if (!t.getElementById(h)) {
231
+ const { getThemeDensity: l, getThemeMotion: a } = r;
232
+ if (l && a) {
233
+ if (!t.getElementById(b)) {
192
234
  const n = t.createElement("style");
193
- n.id = h, n.textContent = y, t.head.appendChild(n);
235
+ n.id = b, n.textContent = R, t.head.appendChild(n);
194
236
  }
195
237
  const o = () => {
196
238
  let n = t.getElementById(
197
- f
239
+ E
198
240
  );
199
- return n || (n = t.createElement("style"), n.id = f, t.head.appendChild(n)), n;
241
+ return n || (n = t.createElement("style"), n.id = E, t.head.appendChild(n)), n;
200
242
  };
201
243
  s(
202
- () => [l(), i()],
203
- ([n, c]) => {
204
- o().textContent = _(n, c);
244
+ () => [l(), a()],
245
+ ([n, i]) => {
246
+ o().textContent = Y(n, i);
205
247
  },
206
248
  { immediate: !0 }
207
249
  );
208
250
  }
209
251
  }
210
252
  export {
211
- _ as buildRhythmCss,
212
- T as useAdminThemeApply
253
+ Y as buildRhythmCss,
254
+ U as useAdminThemeApply
213
255
  };
package/es/index.mjs CHANGED
@@ -68,18 +68,18 @@ import { nestFormItem as ut } from "./components/form/nest-form-item.mjs";
68
68
  import { nestFormItemList as xt } from "./components/form/nest-form-item-list.mjs";
69
69
  import { nestPanelForm as it } from "./components/panel/nest-panel-form.mjs";
70
70
  import { nestPanelItem as _t } from "./components/panel/nest-panel-item.mjs";
71
- import { themeScaleDerive as Et, themeScaleMix as ct, themeScaleToRgba as St } from "./utils/theme-scale.mjs";
72
- import { timeCountDown as It } from "./utils/time.mjs";
73
- import { useActivated as Rt, useActivatedEvent as Ft, useActivatedExec as Lt } from "./hooks/activated.mjs";
74
- import { useAdminViewportApply as Ot } from "./hooks/use-admin-viewport-apply.mjs";
75
- import { useBreakpoint as ht } from "./hooks/use-breakpoint.mjs";
76
- import { useChannelViewportHeight as Nt } from "./hooks/use-channel-viewport-height.mjs";
77
- import { useFeelSize as yt } from "./hooks/feel-size.mjs";
78
- import { useMenusDataDispatch as Vt } from "./hooks/menus-dispatch.mjs";
79
- import { useNestForm as bt } from "./components/form/use-nest-form.mjs";
80
- import { useNestFormList as Ut } from "./components/form/use-nest-form-list.mjs";
81
- import { useNestLayoutScale as vt } from "./components/form/use-nest-layout-scale.mjs";
82
- import { useTimeout as Ht } from "./hooks/timeout.mjs";
71
+ import { themeScaleDerive as Et, themeScaleMix as ct, themeScaleParseHex as St, themeScaleToRgba as Tt } from "./utils/theme-scale.mjs";
72
+ import { timeCountDown as Pt } from "./utils/time.mjs";
73
+ import { useActivated as Ft, useActivatedEvent as Lt, useActivatedExec as Mt } from "./hooks/activated.mjs";
74
+ import { useAdminViewportApply as gt } from "./hooks/use-admin-viewport-apply.mjs";
75
+ import { useBreakpoint as Ct } from "./hooks/use-breakpoint.mjs";
76
+ import { useChannelViewportHeight as Dt } from "./hooks/use-channel-viewport-height.mjs";
77
+ import { useFeelSize as Bt } from "./hooks/feel-size.mjs";
78
+ import { useMenusDataDispatch as Yt } from "./hooks/menus-dispatch.mjs";
79
+ import { useNestForm as Gt } from "./components/form/use-nest-form.mjs";
80
+ import { useNestFormList as Kt } from "./components/form/use-nest-form-list.mjs";
81
+ import { useNestLayoutScale as wt } from "./components/form/use-nest-layout-scale.mjs";
82
+ import { useTimeout as Wt } from "./hooks/timeout.mjs";
83
83
  export {
84
84
  W as ADMIN_BRIDGE_KEY,
85
85
  ee as ADMIN_CORE_VIEWPORT_DECOR_ZINDEX_ABOVE,
@@ -188,19 +188,20 @@ export {
188
188
  ro as swiftFormItemConfig,
189
189
  Et as themeScaleDerive,
190
190
  ct as themeScaleMix,
191
- St as themeScaleToRgba,
192
- It as timeCountDown,
193
- Rt as useActivated,
194
- Ft as useActivatedEvent,
195
- Lt as useActivatedExec,
191
+ St as themeScaleParseHex,
192
+ Tt as themeScaleToRgba,
193
+ Pt as timeCountDown,
194
+ Ft as useActivated,
195
+ Lt as useActivatedEvent,
196
+ Mt as useActivatedExec,
196
197
  Do as useAdminThemeApply,
197
- Ot as useAdminViewportApply,
198
- ht as useBreakpoint,
199
- Nt as useChannelViewportHeight,
200
- yt as useFeelSize,
201
- Vt as useMenusDataDispatch,
202
- bt as useNestForm,
203
- Ut as useNestFormList,
204
- vt as useNestLayoutScale,
205
- Ht as useTimeout
198
+ gt as useAdminViewportApply,
199
+ Ct as useBreakpoint,
200
+ Dt as useChannelViewportHeight,
201
+ Bt as useFeelSize,
202
+ Yt as useMenusDataDispatch,
203
+ Gt as useNestForm,
204
+ Kt as useNestFormList,
205
+ wt as useNestLayoutScale,
206
+ Wt as useTimeout
206
207
  };
@@ -39,5 +39,6 @@ const c = (s) => {
39
39
  export {
40
40
  h as themeScaleDerive,
41
41
  o as themeScaleMix,
42
+ c as themeScaleParseHex,
42
43
  l as themeScaleToRgba
43
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@done-coding/admin-core",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "后台管理核心",
5
5
  "private": false,
6
6
  "main": "lib/index.cjs",
@@ -81,5 +81,5 @@
81
81
  "node": ">=18.0.0",
82
82
  "pnpm": ">=9.0.0"
83
83
  },
84
- "gitHead": "de49e7d3580a081b7f865fc1a79b76b77221ab99"
84
+ "gitHead": "d6b53243bbb38460aab7b806e57885a4fcd70172"
85
85
  }
@@ -18,6 +18,8 @@ export interface ThemeColorScale {
18
18
  "light-9": string;
19
19
  "dark-2": string;
20
20
  }
21
+ /** `#rgb` / `#rrggbb` → [r,g,b];非法格式返回 null */
22
+ export declare const themeScaleParseHex: (hex: string) => [number, number, number] | null;
21
23
  /**
22
24
  * 混色:`c1` 占 `w1`、`c2` 占 `1-w1`,各通道线性混合后四舍五入
23
25
  * (复刻 EP/SCSS `mix(c1, c2, w1)` 语义,w1 为 c1 的权重 [0,1])。