@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.
- package/es/hooks/use-admin-theme-apply.mjs +83 -41
- package/es/index.mjs +27 -26
- package/es/utils/theme-scale.mjs +1 -0
- package/package.json +2 -2
- package/types/utils/theme-scale.d.ts +2 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { watch as s } from "vue";
|
|
2
|
-
import { themeScaleDerive as
|
|
3
|
-
const
|
|
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
|
-
],
|
|
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
|
-
],
|
|
28
|
+
], L = (r) => r.replace(/([A-Z])/g, "-$1").toLowerCase(), g = (r, t) => {
|
|
29
29
|
const e = [];
|
|
30
|
-
for (const [l,
|
|
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-${
|
|
34
|
-
if (
|
|
35
|
-
const d =
|
|
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
|
|
38
|
-
e.push(`${n}-${
|
|
39
|
-
for (const
|
|
40
|
-
e.push(`${
|
|
41
|
-
for (const m of
|
|
42
|
-
e.push(`${
|
|
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
|
|
46
|
+
for (const d of i) e.push(`${d}: ${o};`);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return e.join(`
|
|
50
50
|
`);
|
|
51
|
-
},
|
|
52
|
-
|
|
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
|
-
${
|
|
55
|
-
|
|
80
|
+
${n.join(
|
|
81
|
+
`
|
|
82
|
+
`
|
|
83
|
+
)}
|
|
56
84
|
}
|
|
57
85
|
:root.dark {
|
|
58
|
-
${
|
|
86
|
+
${i.join(`
|
|
87
|
+
`)}
|
|
59
88
|
}
|
|
60
89
|
`;
|
|
61
|
-
},
|
|
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
|
-
`),
|
|
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
|
-
},
|
|
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
|
|
131
|
-
const e =
|
|
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
|
-
${
|
|
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
|
|
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(
|
|
174
|
-
return o || (o = t.createElement("style"), o.id =
|
|
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 =
|
|
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:
|
|
190
|
-
if (l &&
|
|
191
|
-
if (!t.getElementById(
|
|
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 =
|
|
235
|
+
n.id = b, n.textContent = R, t.head.appendChild(n);
|
|
194
236
|
}
|
|
195
237
|
const o = () => {
|
|
196
238
|
let n = t.getElementById(
|
|
197
|
-
|
|
239
|
+
E
|
|
198
240
|
);
|
|
199
|
-
return n || (n = t.createElement("style"), n.id =
|
|
241
|
+
return n || (n = t.createElement("style"), n.id = E, t.head.appendChild(n)), n;
|
|
200
242
|
};
|
|
201
243
|
s(
|
|
202
|
-
() => [l(),
|
|
203
|
-
([n,
|
|
204
|
-
o().textContent =
|
|
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
|
-
|
|
212
|
-
|
|
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,
|
|
72
|
-
import { timeCountDown as
|
|
73
|
-
import { useActivated as
|
|
74
|
-
import { useAdminViewportApply as
|
|
75
|
-
import { useBreakpoint as
|
|
76
|
-
import { useChannelViewportHeight as
|
|
77
|
-
import { useFeelSize as
|
|
78
|
-
import { useMenusDataDispatch as
|
|
79
|
-
import { useNestForm as
|
|
80
|
-
import { useNestFormList as
|
|
81
|
-
import { useNestLayoutScale as
|
|
82
|
-
import { useTimeout as
|
|
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
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
Ft as
|
|
195
|
-
Lt as
|
|
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
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
};
|
package/es/utils/theme-scale.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/admin-core",
|
|
3
|
-
"version": "0.12.
|
|
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": "
|
|
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])。
|