@done-coding/forge-core 0.0.0-placeholder.0 → 0.100.0-alpha.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.
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/es/bridge/badge.mjs +37 -0
- package/es/bridge/config-hook.mjs +58 -0
- package/es/bridge/contracts/event.mjs +102 -0
- package/es/bridge/contracts/index.mjs +5 -0
- package/es/bridge/event.mjs +87 -0
- package/es/bridge/index.mjs +331 -0
- package/es/bridge/layout.mjs +100 -0
- package/es/bridge/permission.mjs +91 -0
- package/es/bridge/plugin.mjs +39 -0
- package/es/bridge/route.mjs +78 -0
- package/es/bridge/state.mjs +61 -0
- package/es/bridge/storage.mjs +26 -0
- package/es/bridge/theme/index.mjs +233 -0
- package/es/bridge/theme/persist.mjs +18 -0
- package/es/bridge/theme/system-dark.mjs +18 -0
- package/es/components/basic/AppCollapseToggle.vue.mjs +7 -0
- package/es/components/basic/AppCollapseToggle.vue2.mjs +63 -0
- package/es/components/basic/action-btn/ActionBtn.vue.mjs +200 -0
- package/es/components/basic/action-btn/ActionBtn.vue2.mjs +4 -0
- package/es/components/basic/action-btn/index.mjs +4 -0
- package/es/components/basic/action-btn/use-action-btn-report.mjs +54 -0
- package/es/components/basic/action-btn-group/ActionBtnGroup.vue.mjs +69 -0
- package/es/components/basic/action-btn-group/ActionBtnGroup.vue2.mjs +4 -0
- package/es/components/basic/action-btn-group/index.mjs +4 -0
- package/es/components/basic/action-btn-group/use-action-btn-group-report.mjs +30 -0
- package/es/components/basic/display-contracts/index.mjs +1 -0
- package/es/components/basic/drag-float/DragFloat.vue.mjs +7 -0
- package/es/components/basic/drag-float/DragFloat.vue2.mjs +109 -0
- package/es/components/basic/drag-float/index.mjs +4 -0
- package/es/components/basic/height-provider/HeightProvider.vue.mjs +62 -0
- package/es/components/basic/height-provider/HeightProvider.vue2.mjs +4 -0
- package/es/components/basic/height-provider/index.mjs +4 -0
- package/es/components/basic/index.mjs +4 -0
- package/es/components/basic/shadow-clone/ShadowClone.vue.mjs +32 -0
- package/es/components/basic/shadow-clone/ShadowClone.vue2.mjs +4 -0
- package/es/components/basic/shadow-clone/index.mjs +4 -0
- package/es/components/basic/shadow-clone/use-shadow-target.mjs +76 -0
- package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.mjs +7 -0
- package/es/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue2.mjs +68 -0
- package/es/components/basic/slot-layout-flow-aside/index.mjs +4 -0
- package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue.mjs +30 -0
- package/es/components/basic/slot-layout-template/SlotLayoutTemplate.vue2.mjs +4 -0
- package/es/components/basic/slot-layout-template/index.mjs +4 -0
- package/es/components/basic/watch-size/WatchSize.vue.mjs +73 -0
- package/es/components/basic/watch-size/WatchSize.vue2.mjs +4 -0
- package/es/components/basic/watch-size/index.mjs +4 -0
- package/es/components/config/app-theme/AppTheme.vue.mjs +7 -0
- package/es/components/config/app-theme/AppTheme.vue2.mjs +82 -0
- package/es/components/config/app-theme/index.mjs +4 -0
- package/es/components/data/badge-mark/BadgeMark.vue.mjs +7 -0
- package/es/components/data/badge-mark/BadgeMark.vue2.mjs +80 -0
- package/es/components/data/badge-mark/index.mjs +4 -0
- package/es/components/data/badge-mark/use-badge-mask.mjs +82 -0
- package/es/components/data/badge-mark/use-badge.mjs +106 -0
- package/es/components/data/boolean-tag/BooleanTag.vue.mjs +36 -0
- package/es/components/data/boolean-tag/BooleanTag.vue2.mjs +4 -0
- package/es/components/data/boolean-tag/index.mjs +4 -0
- package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue.mjs +38 -0
- package/es/components/data/image-preview-trigger/ImagePreviewTrigger.vue2.mjs +4 -0
- package/es/components/data/image-preview-trigger/index.mjs +4 -0
- package/es/components/data/modal-image-preview/ModalImagePreview.vue.mjs +52 -0
- package/es/components/data/modal-image-preview/ModalImagePreview.vue2.mjs +4 -0
- package/es/components/data/modal-image-preview/index.mjs +4 -0
- package/es/components/feedback/action-confirm/ActionConfirm.vue.mjs +7 -0
- package/es/components/feedback/action-confirm/ActionConfirm.vue2.mjs +143 -0
- package/es/components/feedback/action-confirm/index.mjs +4 -0
- package/es/components/feedback/modal-confirm/ModalConfirm.vue.mjs +8 -0
- package/es/components/feedback/modal-confirm/ModalConfirm.vue2.mjs +243 -0
- package/es/components/feedback/modal-confirm/index.mjs +4 -0
- package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue.mjs +8 -0
- package/es/components/feedback/modal-video-preview/ModalVideoPreview.vue2.mjs +93 -0
- package/es/components/feedback/modal-video-preview/index.mjs +4 -0
- package/es/components/feedback/preview-keys/index.mjs +7 -0
- package/es/components/feedback/preview-keys/keys.mjs +7 -0
- package/es/components/feedback/shelf-contracts/index.mjs +1 -0
- package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.mjs +7 -0
- package/es/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue2.mjs +133 -0
- package/es/components/feedback/video-preview-trigger/index.mjs +4 -0
- package/es/components/other/TriggerAutoImport.vue.mjs +12 -0
- package/es/components/other/TriggerAutoImport.vue2.mjs +4 -0
- package/es/components/other/auto-refresh/AutoRefresh.vue.mjs +7 -0
- package/es/components/other/auto-refresh/AutoRefresh.vue2.mjs +96 -0
- package/es/components/other/auto-refresh/index.mjs +4 -0
- package/es/components/other/auto-refresh/use-auto-refresh-report.mjs +31 -0
- package/es/components/other/auto-refresh-contracts/index.mjs +1 -0
- package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue.mjs +7 -0
- package/es/components/other/auto-refresh-group/AutoRefreshGroup.vue2.mjs +69 -0
- package/es/components/other/auto-refresh-group/index.mjs +4 -0
- package/es/components/other/auto-refresh-group/use-auto-refresh-group-report.mjs +12 -0
- package/es/components/other/index.mjs +4 -0
- package/es/config/badge-attr.mjs +6 -0
- package/es/config/index.mjs +19 -0
- package/es/config/list-model.mjs +13 -0
- package/es/config/modal-keys.mjs +6 -0
- package/es/config/route.mjs +6 -0
- package/es/config/slot-region.mjs +45 -0
- package/es/helpers/form.mjs +25 -0
- package/es/helpers/index.mjs +10 -0
- package/es/helpers/list-helper.mjs +77 -0
- package/es/hooks/activated.mjs +64 -0
- package/es/hooks/feel-size.mjs +46 -0
- package/es/hooks/index.mjs +31 -0
- package/es/hooks/menus-dispatch.mjs +85 -0
- package/es/hooks/timeout.mjs +36 -0
- package/es/hooks/use-active-record.mjs +104 -0
- package/es/hooks/use-breakpoint.mjs +48 -0
- package/es/hooks/use-bridge-report.mjs +12 -0
- package/es/hooks/use-channel-viewport-height.mjs +43 -0
- package/es/hooks/use-context-defaults.mjs +44 -0
- package/es/hooks/use-custom-breakpoint.mjs +69 -0
- package/es/hooks/use-is-dev.mjs +16 -0
- package/es/hooks/use-observe-size.mjs +43 -0
- package/es/hooks/use-permission.mjs +12 -0
- package/es/hooks/use-surface.mjs +35 -0
- package/es/hooks/use-theme-apply.mjs +496 -0
- package/es/hooks/use-viewport-apply.mjs +52 -0
- package/es/index.mjs +179 -0
- package/es/inject/index.mjs +19 -0
- package/es/inject/key.mjs +70 -0
- package/es/injection-namespace.mjs +4 -0
- package/es/internals/index.mjs +16 -0
- package/es/router/group-redirect.mjs +26 -0
- package/es/router/guard/index.mjs +36 -0
- package/es/router/guard/login.mjs +6 -0
- package/es/router/guard/permission.mjs +6 -0
- package/es/router/index.mjs +10 -0
- package/es/store/app.mjs +306 -0
- package/es/store/index.mjs +8 -0
- package/es/store/router-permission.mjs +94 -0
- package/es/store/user.mjs +128 -0
- package/es/style.css +339 -0
- package/es/types/index.mjs +1 -0
- package/es/utils/dom.mjs +42 -0
- package/es/utils/export.mjs +39 -0
- package/es/utils/gap-scale.mjs +25 -0
- package/es/utils/id.mjs +7 -0
- package/es/utils/index.mjs +37 -0
- package/es/utils/permission.mjs +31 -0
- package/es/utils/router.mjs +42 -0
- package/es/utils/theme-scale.mjs +86 -0
- package/es/utils/time.mjs +24 -0
- package/package.json +232 -1
- package/types/bridge/badge.d.ts +215 -0
- package/types/bridge/config-hook.d.ts +12 -0
- package/types/bridge/contracts/bridge.d.ts +339 -0
- package/types/bridge/contracts/config.d.ts +519 -0
- package/types/bridge/contracts/event.d.ts +546 -0
- package/types/bridge/contracts/index.d.ts +3 -0
- package/types/bridge/event.d.ts +3 -0
- package/types/bridge/index.d.ts +28 -0
- package/types/bridge/layout.d.ts +102 -0
- package/types/bridge/permission.d.ts +31 -0
- package/types/bridge/plugin.d.ts +11 -0
- package/types/bridge/route.d.ts +36 -0
- package/types/bridge/state.d.ts +26 -0
- package/types/bridge/storage.d.ts +10 -0
- package/types/bridge/theme/index.d.ts +10 -0
- package/types/bridge/theme/persist.d.ts +23 -0
- package/types/bridge/theme/system-dark.d.ts +14 -0
- package/types/bridge/theme/types.d.ts +346 -0
- package/types/components/basic/AppCollapseToggle.vue.d.ts +14 -0
- package/types/components/basic/action-btn/ActionBtn.vue.d.ts +19 -0
- package/types/components/basic/action-btn/index.d.ts +1 -0
- package/types/components/basic/action-btn/use-action-btn-report.d.ts +12 -0
- package/types/components/basic/action-btn-group/ActionBtnGroup.vue.d.ts +18 -0
- package/types/components/basic/action-btn-group/index.d.ts +1 -0
- package/types/components/basic/action-btn-group/use-action-btn-group-report.d.ts +6 -0
- package/types/components/basic/display-contracts/index.d.ts +1 -0
- package/types/components/basic/display-contracts/types.d.ts +280 -0
- package/types/components/basic/drag-float/DragFloat.vue.d.ts +35 -0
- package/types/components/basic/drag-float/index.d.ts +1 -0
- package/types/components/basic/height-provider/HeightProvider.vue.d.ts +28 -0
- package/types/components/basic/height-provider/index.d.ts +1 -0
- package/types/components/basic/index.d.ts +1 -0
- package/types/components/basic/shadow-clone/ShadowClone.vue.d.ts +20 -0
- package/types/components/basic/shadow-clone/index.d.ts +1 -0
- package/types/components/basic/shadow-clone/use-shadow-target.d.ts +9 -0
- package/types/components/basic/slot-layout-flow-aside/SlotLayoutFlowAside.vue.d.ts +32 -0
- package/types/components/basic/slot-layout-flow-aside/index.d.ts +2 -0
- package/types/components/basic/slot-layout-flow-aside/types.d.ts +10 -0
- package/types/components/basic/slot-layout-template/SlotLayoutTemplate.vue.d.ts +48 -0
- package/types/components/basic/slot-layout-template/index.d.ts +1 -0
- package/types/components/basic/watch-size/WatchSize.vue.d.ts +45 -0
- package/types/components/basic/watch-size/index.d.ts +1 -0
- package/types/components/config/app-theme/AppTheme.vue.d.ts +2 -0
- package/types/components/config/app-theme/index.d.ts +1 -0
- package/types/components/data/badge-mark/BadgeMark.vue.d.ts +212 -0
- package/types/components/data/badge-mark/index.d.ts +1 -0
- package/types/components/data/badge-mark/use-badge-mask.d.ts +8 -0
- package/types/components/data/badge-mark/use-badge.d.ts +78 -0
- package/types/components/data/boolean-tag/BooleanTag.vue.d.ts +8 -0
- package/types/components/data/boolean-tag/index.d.ts +1 -0
- package/types/components/data/image-preview-trigger/ImagePreviewTrigger.vue.d.ts +41 -0
- package/types/components/data/image-preview-trigger/index.d.ts +1 -0
- package/types/components/data/modal-image-preview/ModalImagePreview.vue.d.ts +31 -0
- package/types/components/data/modal-image-preview/index.d.ts +1 -0
- package/types/components/feedback/action-confirm/ActionConfirm.vue.d.ts +33 -0
- package/types/components/feedback/action-confirm/index.d.ts +1 -0
- package/types/components/feedback/modal-confirm/ModalConfirm.vue.d.ts +120 -0
- package/types/components/feedback/modal-confirm/index.d.ts +2 -0
- package/types/components/feedback/modal-confirm/types.d.ts +4 -0
- package/types/components/feedback/modal-video-preview/ModalVideoPreview.vue.d.ts +40 -0
- package/types/components/feedback/modal-video-preview/index.d.ts +1 -0
- package/types/components/feedback/preview-keys/index.d.ts +2 -0
- package/types/components/feedback/preview-keys/keys.d.ts +14 -0
- package/types/components/feedback/shelf-contracts/index.d.ts +1 -0
- package/types/components/feedback/shelf-contracts/types.d.ts +1 -0
- package/types/components/feedback/video-preview-trigger/VideoPreviewTrigger.vue.d.ts +46 -0
- package/types/components/feedback/video-preview-trigger/index.d.ts +1 -0
- package/types/components/other/TriggerAutoImport.vue.d.ts +17 -0
- package/types/components/other/auto-refresh/AutoRefresh.vue.d.ts +14 -0
- package/types/components/other/auto-refresh/index.d.ts +1 -0
- package/types/components/other/auto-refresh/use-auto-refresh-report.d.ts +1 -0
- package/types/components/other/auto-refresh-contracts/index.d.ts +1 -0
- package/types/components/other/auto-refresh-contracts/types.d.ts +17 -0
- package/types/components/other/auto-refresh-group/AutoRefreshGroup.vue.d.ts +18 -0
- package/types/components/other/auto-refresh-group/index.d.ts +1 -0
- package/types/components/other/auto-refresh-group/use-auto-refresh-group-report.d.ts +3 -0
- package/types/components/other/index.d.ts +1 -0
- package/types/config/badge-attr.d.ts +26 -0
- package/types/config/index.d.ts +5 -0
- package/types/config/list-model.d.ts +49 -0
- package/types/config/modal-keys.d.ts +12 -0
- package/types/config/route.d.ts +4 -0
- package/types/config/slot-region.d.ts +72 -0
- package/types/helpers/form.d.ts +8 -0
- package/types/helpers/index.d.ts +3 -0
- package/types/helpers/list-helper.d.ts +35 -0
- package/types/helpers/types.d.ts +15 -0
- package/types/hooks/activated.d.ts +36 -0
- package/types/hooks/feel-size.d.ts +10 -0
- package/types/hooks/index.d.ts +12 -0
- package/types/hooks/menus-dispatch.d.ts +35 -0
- package/types/hooks/timeout.d.ts +7 -0
- package/types/hooks/use-active-record.d.ts +64 -0
- package/types/hooks/use-breakpoint.d.ts +4 -0
- package/types/hooks/use-bridge-report.d.ts +3 -0
- package/types/hooks/use-channel-viewport-height.d.ts +22 -0
- package/types/hooks/use-context-defaults.d.ts +39 -0
- package/types/hooks/use-custom-breakpoint.d.ts +17 -0
- package/types/hooks/use-is-dev.d.ts +24 -0
- package/types/hooks/use-observe-size.d.ts +36 -0
- package/types/hooks/use-permission.d.ts +14 -0
- package/types/hooks/use-surface.d.ts +45 -0
- package/types/hooks/use-theme-apply.d.ts +34 -0
- package/types/hooks/use-viewport-apply.d.ts +20 -0
- package/types/index.d.ts +33 -0
- package/types/inject/index.d.ts +1 -0
- package/types/inject/key.d.ts +247 -0
- package/types/injection-namespace.d.ts +4 -0
- package/types/internals/index.d.ts +6 -0
- package/types/router/group-redirect.d.ts +14 -0
- package/types/router/guard/index.d.ts +20 -0
- package/types/router/guard/login.d.ts +4 -0
- package/types/router/guard/permission.d.ts +4 -0
- package/types/router/guard/types.d.ts +14 -0
- package/types/router/index.d.ts +2 -0
- package/types/store/app.d.ts +219 -0
- package/types/store/index.d.ts +3 -0
- package/types/store/router-permission.d.ts +79 -0
- package/types/store/user.d.ts +64 -0
- package/types/types/app-layout.d.ts +42 -0
- package/types/types/dc-path.d.ts +2 -0
- package/types/types/dot-path.d.ts +13 -0
- package/types/types/index.d.ts +9 -0
- package/types/types/list-api.d.ts +17 -0
- package/types/types/modal-shelf.d.ts +123 -0
- package/types/types/nest-form.d.ts +8 -0
- package/types/types/permission.d.ts +31 -0
- package/types/types/route.d.ts +141 -0
- package/types/types/utility-types.d.ts +25 -0
- package/types/utils/dom.d.ts +61 -0
- package/types/utils/export.d.ts +35 -0
- package/types/utils/gap-scale.d.ts +46 -0
- package/types/utils/id.d.ts +2 -0
- package/types/utils/index.d.ts +8 -0
- package/types/utils/permission.d.ts +16 -0
- package/types/utils/router.d.ts +18 -0
- package/types/utils/theme-scale.d.ts +78 -0
- package/types/utils/time.d.ts +2 -0
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
import { watch, onScopeDispose } from "vue";
|
|
2
|
+
import { themeScaleDerive, themeScaleParseHex, themeScaleIsNearBlack, themeScaleSurfaceColor, themeScalePageColor, themeScaleMix, themeScaleToRgba } from "../utils/theme-scale.mjs";
|
|
3
|
+
const STYLE_EL_ID = "dc-core-theme";
|
|
4
|
+
const randomStyleSuffix = () => Math.random().toString(36).slice(2, 9);
|
|
5
|
+
const THEME_FIELD_SPECS = [
|
|
6
|
+
["primaryColor", { scale: true, el: "--el-color-primary" }],
|
|
7
|
+
["successColor", { scale: true, el: "--el-color-success" }],
|
|
8
|
+
["warningColor", { scale: true, el: "--el-color-warning" }],
|
|
9
|
+
["dangerColor", { scale: true, el: "--el-color-danger" }],
|
|
10
|
+
["errorColor", { scale: true, el: "--el-color-error" }],
|
|
11
|
+
["infoColor", { scale: true, el: "--el-color-info" }],
|
|
12
|
+
// bodyColor = 面(默认背景色),只挂 --el-bg-color;底 --el-bg-color-page 由
|
|
13
|
+
// buildElevationDecls 派生([MUST NOT] 再拉平三档,见 elevation 注释)。
|
|
14
|
+
["bodyColor", { el: "--el-bg-color" }],
|
|
15
|
+
["baseColor", { el: "--el-text-color-primary" }],
|
|
16
|
+
["radius", { el: "--el-border-radius-base" }],
|
|
17
|
+
["borderColor", { el: "--el-border-color" }],
|
|
18
|
+
["shadow", { el: "--el-box-shadow" }],
|
|
19
|
+
["borderWidth", { el: "--el-border-width" }],
|
|
20
|
+
["accent", {}],
|
|
21
|
+
["glow", {}],
|
|
22
|
+
["blur", {}],
|
|
23
|
+
["focusRing", {}],
|
|
24
|
+
// surface = 抬升面(overlay 档):preset 显式给值时双挂(与派生兜底同口径)
|
|
25
|
+
["surface", { el: "--el-bg-color-overlay" }],
|
|
26
|
+
// ground = 底(page 档):同 surface 的「显式优先」范式——preset 给了就双挂,
|
|
27
|
+
// 没给才由 buildElevationDecls 派生。⚠️ 与 bodyColor(面)是两档,[MUST NOT] 混。
|
|
28
|
+
["ground", { el: "--el-bg-color-page" }]
|
|
29
|
+
];
|
|
30
|
+
const THEME_SCALE_SUFFIXES = [
|
|
31
|
+
"light-3",
|
|
32
|
+
"light-5",
|
|
33
|
+
"light-7",
|
|
34
|
+
"light-8",
|
|
35
|
+
"light-9",
|
|
36
|
+
"dark-2"
|
|
37
|
+
];
|
|
38
|
+
const themeKebab = (s) => s.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
39
|
+
const buildThemeBlockBody = (color, mode) => {
|
|
40
|
+
const lines = [];
|
|
41
|
+
for (const [key, spec] of THEME_FIELD_SPECS) {
|
|
42
|
+
const value = color[key];
|
|
43
|
+
if (value === void 0 || value === "") continue;
|
|
44
|
+
const corePrefix = `--dc-core-${themeKebab(key)}`;
|
|
45
|
+
const elVars = spec.el === void 0 ? [] : Array.isArray(spec.el) ? spec.el : [spec.el];
|
|
46
|
+
if (spec.scale) {
|
|
47
|
+
const scale = themeScaleDerive(value, mode);
|
|
48
|
+
lines.push(`${corePrefix}: ${value};`);
|
|
49
|
+
for (const suf of THEME_SCALE_SUFFIXES) {
|
|
50
|
+
lines.push(`${corePrefix}-${suf}: ${scale[suf]};`);
|
|
51
|
+
}
|
|
52
|
+
for (const el of elVars) {
|
|
53
|
+
lines.push(`${el}: ${value};`);
|
|
54
|
+
for (const suf of THEME_SCALE_SUFFIXES) {
|
|
55
|
+
lines.push(`${el}-${suf}: ${scale[suf]};`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
lines.push(`${corePrefix}: ${value};`);
|
|
60
|
+
for (const el of elVars) lines.push(`${el}: ${value};`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return lines.join("\n ");
|
|
64
|
+
};
|
|
65
|
+
const OVERLAY_DARKEN_REL = 0.4;
|
|
66
|
+
const OVERLAY_CAP_MAX_CH = 10;
|
|
67
|
+
const OVERLAY_ALPHA = {
|
|
68
|
+
light: 0.5,
|
|
69
|
+
dark: 0.72
|
|
70
|
+
};
|
|
71
|
+
const buildOverlayDecl = (bodyColor, mode) => {
|
|
72
|
+
if (!bodyColor) return "";
|
|
73
|
+
const rgb = themeScaleParseHex(bodyColor);
|
|
74
|
+
if (!rgb) return "";
|
|
75
|
+
const maxCh = Math.max(...rgb);
|
|
76
|
+
const k = maxCh === 0 ? 0 : Math.min(OVERLAY_DARKEN_REL, OVERLAY_CAP_MAX_CH / maxCh);
|
|
77
|
+
const scrim = themeScaleMix(bodyColor, "#000000", k);
|
|
78
|
+
return `--el-overlay-color-lighter: ${themeScaleToRgba(
|
|
79
|
+
scrim,
|
|
80
|
+
OVERLAY_ALPHA[mode]
|
|
81
|
+
)};`;
|
|
82
|
+
};
|
|
83
|
+
const MASK_ALPHA = { light: 0.5, dark: 0.6 };
|
|
84
|
+
const buildMaskDecl = (bodyColor, mode) => {
|
|
85
|
+
if (!bodyColor) return "";
|
|
86
|
+
const veil = themeScaleToRgba(bodyColor, MASK_ALPHA[mode]);
|
|
87
|
+
if (veil === bodyColor) return "";
|
|
88
|
+
return `--el-mask-color: ${veil};`;
|
|
89
|
+
};
|
|
90
|
+
const warnNearBlackFlip = (body, face, mode) => {
|
|
91
|
+
console.warn(
|
|
92
|
+
`[dc-theme] ${mode} 档的 bodyColor ${body} 已近黑,向黑派生「底」无余量可压(底会等于面、模块间距的缝不可见)。已自动翻转基准:底取 ${body}、面提亮为 ${face}。建议在该档显式给 ground(底)与 bodyColor(面),[MUST NOT] 依赖本兜底猜出来的面色。`
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
const buildElevationDecls = (color, mode) => {
|
|
96
|
+
const body = color.bodyColor;
|
|
97
|
+
if (!body || !themeScaleParseHex(body)) return [];
|
|
98
|
+
const hasGround = color.ground !== void 0 && color.ground !== "";
|
|
99
|
+
const lines = [];
|
|
100
|
+
const flip = !hasGround && themeScaleIsNearBlack(body);
|
|
101
|
+
const face = flip ? themeScaleSurfaceColor(body, "dark") : body;
|
|
102
|
+
if (flip) {
|
|
103
|
+
lines.push(
|
|
104
|
+
`--el-bg-color-page: ${body};`,
|
|
105
|
+
`--dc-core-ground: ${body};`,
|
|
106
|
+
`--el-bg-color: ${face};`,
|
|
107
|
+
`--dc-core-body-color: ${face};`
|
|
108
|
+
);
|
|
109
|
+
warnNearBlackFlip(body, face, mode);
|
|
110
|
+
} else if (!hasGround) {
|
|
111
|
+
const ground = themeScalePageColor(body);
|
|
112
|
+
lines.push(
|
|
113
|
+
`--el-bg-color-page: ${ground};`,
|
|
114
|
+
`--dc-core-ground: ${ground};`
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (color.surface === void 0 || color.surface === "") {
|
|
118
|
+
const surface = themeScaleSurfaceColor(face, flip ? "dark" : mode);
|
|
119
|
+
lines.push(
|
|
120
|
+
`--dc-core-surface: ${surface};`,
|
|
121
|
+
`--el-bg-color-overlay: ${surface};`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
return lines;
|
|
125
|
+
};
|
|
126
|
+
const buildThemeCss = (config) => {
|
|
127
|
+
const lightColor = config.light;
|
|
128
|
+
const darkColor = config.dark;
|
|
129
|
+
const lightBody = buildThemeBlockBody(lightColor, "light");
|
|
130
|
+
const darkBody = buildThemeBlockBody(darkColor, "dark");
|
|
131
|
+
const rootColorDecl = "color: var(--dc-core-base-color);";
|
|
132
|
+
const rootBackgroundDecl = "background: var(--el-bg-color-page, #f2f3f5);";
|
|
133
|
+
const lightLines = [
|
|
134
|
+
lightBody,
|
|
135
|
+
rootColorDecl,
|
|
136
|
+
rootBackgroundDecl,
|
|
137
|
+
...buildElevationDecls(lightColor, "light"),
|
|
138
|
+
buildOverlayDecl(lightColor.bodyColor, "light"),
|
|
139
|
+
buildMaskDecl(lightColor.bodyColor, "light")
|
|
140
|
+
].filter(Boolean);
|
|
141
|
+
const darkLines = [
|
|
142
|
+
darkBody,
|
|
143
|
+
...buildElevationDecls(darkColor, "dark"),
|
|
144
|
+
buildOverlayDecl(darkColor.bodyColor, "dark"),
|
|
145
|
+
buildMaskDecl(darkColor.bodyColor, "dark")
|
|
146
|
+
].filter(Boolean);
|
|
147
|
+
return `:root {
|
|
148
|
+
${lightLines.join(
|
|
149
|
+
"\n "
|
|
150
|
+
)}
|
|
151
|
+
}
|
|
152
|
+
:root.dark {
|
|
153
|
+
${darkLines.join("\n ")}
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
};
|
|
157
|
+
const RHYTHM_STYLE_EL_ID = "dc-core-rhythm";
|
|
158
|
+
const EP_BRIDGE_STYLE_EL_ID = "dc-core-ep-bridge";
|
|
159
|
+
const EP_STRUCTURAL_STYLE_EL_ID = "dc-core-ep-structural";
|
|
160
|
+
const EP_STRUCTURAL_CSS = [
|
|
161
|
+
// ElSwitch 关闭态:EP 默认 `--el-switch-off-color: var(--el-border-color)`,
|
|
162
|
+
// 而边框色是**给分隔线用的最浅档** ⇒ 开关整体几乎看不见。
|
|
163
|
+
// 🔴 依据是 CDP 实测对比度(对白底 / 对近黑底),[MUST NOT] 只看顺眼:
|
|
164
|
+
// --el-border-color(EP 默认,现状) 1.33 / 2.18 ← 两侧都远低于下限
|
|
165
|
+
// --el-border-color-dark 1.44 / 2.60
|
|
166
|
+
// --el-text-color-placeholder 2.30 / 5.75 ← 亮色仍不过
|
|
167
|
+
// --el-text-color-secondary 3.08 / 7.56 ← **取它**:两侧都过且最轻
|
|
168
|
+
// --el-text-color-regular 6.11 / 12.29 ← 过重,关闭态会读成开启
|
|
169
|
+
// 下限取 3:1 —— WCAG 1.4.11 对**非文字 UI 控件**的可辨识要求;开关的轨道就是它的边界。
|
|
170
|
+
// ⚠️ 落点 [MUST] 在此而非组件 scoped:开关广泛散在各族与业务页,
|
|
171
|
+
// 逐处改既漏又会各定各的(同 .el-badge__content 那条的理由)。
|
|
172
|
+
// ⚠️ 这是**全仓所有 ElSwitch** 的关闭态观感变更,[MUST] 在 migrations 登记。
|
|
173
|
+
".el-switch {",
|
|
174
|
+
" --el-switch-off-color: var(",
|
|
175
|
+
" --dc-core-text-color-secondary,",
|
|
176
|
+
" var(--el-text-color-secondary)",
|
|
177
|
+
" );",
|
|
178
|
+
"}",
|
|
179
|
+
// 居中浮层(Dialog / MessageBox)+ 抽屉(Drawer):1px 主题描边硬边界
|
|
180
|
+
// (--el-border-color 类明暗自换:亮色浅灰近隐形、暗色中灰清晰)。
|
|
181
|
+
".el-dialog,",
|
|
182
|
+
".el-message-box,",
|
|
183
|
+
".el-drawer {",
|
|
184
|
+
" border: 1px solid var(--dc-core-border-color, var(--el-border-color));",
|
|
185
|
+
"}",
|
|
186
|
+
// 表格固定列分隔阴影:EP 原值 inset ±10px 0 10px -10px rgba(0,0,0,.15) 为黑投影,暗色近黑底
|
|
187
|
+
// 上不可见 → 横向滚动时固定列无边界。仅**暗色** override 为随主题的边框色(中灰、暗底可见);
|
|
188
|
+
// 亮色保留 EP 默认(黑投影在白底本就可见)。规则 14:优先 --dc-core-border-color、退 --el-border-color。
|
|
189
|
+
":root.dark .el-table {",
|
|
190
|
+
" --el-table-fixed-left-column: inset 10px 0 10px -10px var(--dc-core-border-color, var(--el-border-color));",
|
|
191
|
+
" --el-table-fixed-right-column: inset -10px 0 10px -10px var(--dc-core-border-color, var(--el-border-color));",
|
|
192
|
+
"}",
|
|
193
|
+
// ── 浮层描边:**接主题**,不是「补上缺失的边框」(r4jsl6 ① 的前提已实测更正)──
|
|
194
|
+
// 实测 EP 2.13.7:`.el-popper.is-light` / `.el-dropdown__popper.el-popper` / `.el-card`
|
|
195
|
+
// **本来就各带 1px 边框**(`--el-border-color-light`),暗色下 `#414243` 对 overlay
|
|
196
|
+
// `#1d1e1f` 也有 Δ36、看得见 —— 所以「浮层没有边界」这条不成立。
|
|
197
|
+
// 真正的缺口是**这些边框走 EP 固定灰、不随本仓主题**:弹窗 / 抽屉那条已改用
|
|
198
|
+
// `--dc-core-border-color`,浮层没跟上 ⇒ 换主题时两类浮层边框分家。此处只改 `border-color`
|
|
199
|
+
// ([MUST NOT] 写整条 `border`,那会连宽度 / 样式一起夺权),并**同步箭头**——
|
|
200
|
+
// 箭头的 `::before` 自带同色边框,只改容器会出现「框变色、箭头没变」的裂缝。
|
|
201
|
+
// 🔴 [MUST NOT] 把 `.el-popper.is-dark` 纳入:那是**深色气泡**(tooltip 默认档),
|
|
202
|
+
// 它的边框本就与自身深底同色,套上主题边框会给黑气泡镶一圈亮边。
|
|
203
|
+
// 🔴 [MUST NOT] 把 `.el-card` 纳入:卡片边框是常驻结构线、不是浮层边界,
|
|
204
|
+
// 改它等于把全站卡片加深一档 —— 那是独立的视觉决策,不该夹带进「浮层描边」。
|
|
205
|
+
".el-popper.is-light,",
|
|
206
|
+
".el-dropdown__popper.el-popper {",
|
|
207
|
+
" border-color: var(--dc-core-border-color, var(--el-border-color-light));",
|
|
208
|
+
"}",
|
|
209
|
+
".el-popper.is-light > .el-popper__arrow::before,",
|
|
210
|
+
".el-dropdown__popper.el-popper .el-popper__arrow::before {",
|
|
211
|
+
" border-color: var(--dc-core-border-color, var(--el-border-color-light));",
|
|
212
|
+
"}",
|
|
213
|
+
// ── 表格斑马纹加深(r4jsl6 ②)──
|
|
214
|
+
// EP 原值 `--el-fill-color-lighter`:亮 `#fafafa` 对面 `#ffffff` 通道差仅 **5/5/5**、
|
|
215
|
+
// 暗 `#1d1d1d` 对 `#141414` 仅 **9/9/9** —— 斑马纹的意义就是「长行易对齐」,Δ5 等于没做。
|
|
216
|
+
// 取「主题边框色按比例混进面色」而非 EP 的固定灰档:边框色**随主题自动反转**
|
|
217
|
+
// (亮色偏黑向 / 暗色偏白向),一份声明亮暗都成立,且换主题时跟着走
|
|
218
|
+
// (EP 的 `--el-fill-color*` 是固定灰,彩色主题下会显脏)。
|
|
219
|
+
// 40% 是实测取的:亮 Δ14/13/10、暗 Δ22/23/24 —— 暗色需要更大的差才读得出来,
|
|
220
|
+
// 这个比例恰好让两边观感相当。[MUST NOT] 再往上调:超过 50% 斑马纹会读成「选中行」。
|
|
221
|
+
".el-table--striped .el-table__body tr.el-table__row--striped td.el-table__cell {",
|
|
222
|
+
" background: color-mix(in srgb, var(--dc-core-border-color, var(--el-border-color)) 40%, var(--el-bg-color));",
|
|
223
|
+
"}",
|
|
224
|
+
// ── 占位符对比(r4jsl6 ③)——**只修亮色**(工单的暗色数据已实测更正)──
|
|
225
|
+
// 实测:亮色 `#a8abb2` 对 `#fff` 仅 **2.30:1**,低于 WCAG AA 的 4.5:1;
|
|
226
|
+
// 而暗色 `#8d9095` 对面色 `#141414` 已有 **5.75:1**、对 overlay `#1d1e1f` 5.21:1,
|
|
227
|
+
// **本就达标** ⇒ 暗色一并加深只会让占位符抢戏。工单写的「亮暗均 2.3~2.6」是错的。
|
|
228
|
+
// 取值 = `color-mix(regular 60%, secondary)` → `#73767a`,对白底 **4.56:1**(刚过线),
|
|
229
|
+
// 与「已输入文字」`--el-text-color-regular` 的 6.11:1 仍拉得开,不会读成真值。
|
|
230
|
+
// 🔴 **[MUST NOT] 改 `--el-text-color-placeholder` 变量**:EP 的
|
|
231
|
+
// `--el-disabled-text-color: var(--el-text-color-placeholder)` ——改变量会把**禁用态**
|
|
232
|
+
// 一起加深,而 disabled 在 WCAG 里是**明确豁免**的,加深反而削弱「这是禁用」的语义。
|
|
233
|
+
// 故只打伪元素。禁用态的 EP 规则(`.el-input.is-disabled .el-input__inner::placeholder`)
|
|
234
|
+
// 选择器更具体,天然压过本条;`.el-date-editor` 那条同权,故显式 `:not(.is-disabled)`。
|
|
235
|
+
":root:not(.dark) .el-input__inner::placeholder,",
|
|
236
|
+
":root:not(.dark) .el-textarea__inner::placeholder,",
|
|
237
|
+
":root:not(.dark) .el-date-editor:not(.is-disabled) .el-range-input::placeholder,",
|
|
238
|
+
":root:not(.dark) .el-select__placeholder.is-transparent {",
|
|
239
|
+
" color: color-mix(in srgb, var(--el-text-color-regular) 60%, var(--el-text-color-secondary));",
|
|
240
|
+
"}",
|
|
241
|
+
// 徽标**镂空**(gyycky,甲方 2026-09-17:「badge 使用镂空,而不是当前的纯色背景 + 白字」)。
|
|
242
|
+
// 🔴 落点 [MUST] 在此、[MUST NOT] 在 BadgeMark.vue 写 scoped —— 角标由 ElBadge 渲染在
|
|
243
|
+
// 它自己的 DOM 上(`.el-badge__content`),scoped 选择器打不中。
|
|
244
|
+
//
|
|
245
|
+
// 三件事:底从语义色实心 → **面色**([MUST NOT] 用纯透明:角标叠在宿主内容上,
|
|
246
|
+
// 全透会透出下面的字)· 边框 **1px 语义色** · 文字 → **语义色**。
|
|
247
|
+
// ⚠️ 原注里的「图标走 currentColor」已作废 —— 七档自 15vsrv 起**一律文字**、图标族已删。
|
|
248
|
+
//
|
|
249
|
+
// 🔴 **[MUST] 逐档写,[MUST NOT] 想着「引 --el-badge-bg-color 一条规则covers全档」**:
|
|
250
|
+
// 实测那个变量**不按档赋值** —— EP 只在基类里用它(恒 danger 红),per-type 色是
|
|
251
|
+
// `.el-badge__content--<type>{background-color: var(--el-color-<type>)}` 五条独立规则给的。
|
|
252
|
+
// 曾按「一条覆盖全档」写过,CDP 实测八档全渲染成 danger 红当场证伪。
|
|
253
|
+
// 五档即 EP 语义色全集:无 type 修饰符的基类 = danger(count 默认档),custom 的 `type`
|
|
254
|
+
// 也只收这五档 ⇒ 五条 + 基类一条 = 全覆盖,不存在漏档。
|
|
255
|
+
".el-badge__content {",
|
|
256
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
257
|
+
" color: var(--el-color-danger);",
|
|
258
|
+
" border: 1px solid var(--el-color-danger);",
|
|
259
|
+
"}",
|
|
260
|
+
".el-badge__content--primary {",
|
|
261
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
262
|
+
" color: var(--el-color-primary);",
|
|
263
|
+
" border-color: var(--el-color-primary);",
|
|
264
|
+
"}",
|
|
265
|
+
".el-badge__content--success {",
|
|
266
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
267
|
+
" color: var(--el-color-success);",
|
|
268
|
+
" border-color: var(--el-color-success);",
|
|
269
|
+
"}",
|
|
270
|
+
".el-badge__content--warning {",
|
|
271
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
272
|
+
" color: var(--el-color-warning);",
|
|
273
|
+
" border-color: var(--el-color-warning);",
|
|
274
|
+
"}",
|
|
275
|
+
".el-badge__content--danger {",
|
|
276
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
277
|
+
" color: var(--el-color-danger);",
|
|
278
|
+
" border-color: var(--el-color-danger);",
|
|
279
|
+
"}",
|
|
280
|
+
".el-badge__content--info {",
|
|
281
|
+
" background-color: var(--dc-core-surface, var(--el-bg-color));",
|
|
282
|
+
" color: var(--el-color-info);",
|
|
283
|
+
" border-color: var(--el-color-info);",
|
|
284
|
+
"}",
|
|
285
|
+
// 亮色下把**字色**压深一档(描边仍取 base,镂空的轮廓才读得出语义色相)。
|
|
286
|
+
// 🔴 依据是 CDP 实测的 WCAG 对比度,[MUST NOT] 只看顺眼:
|
|
287
|
+
//
|
|
288
|
+
// | 档 | 亮色 base | 亮色 dark-2 | 暗色 base |
|
|
289
|
+
// | --- | --- | --- | --- |
|
|
290
|
+
// | primary | 2.78 | **4.20** | 6.63 |
|
|
291
|
+
// | success | 2.24 | **3.45** | 8.21 |
|
|
292
|
+
// | warning | 2.19 | **3.35** | 8.42 |
|
|
293
|
+
// | danger | 2.90 | **4.36** | 6.35 |
|
|
294
|
+
// | info | 3.08 | **4.56** | 5.98 |
|
|
295
|
+
//
|
|
296
|
+
// ⇒ **暗色 base 已 5.98–8.42,[MUST NOT] 跟着压深**(深底上再压只会更糊),故只打亮色。
|
|
297
|
+
// ⚠️ 亮色压深后 3.35–4.56 **仍未普遍达到小字 4.5:1** —— 但那是 EP 语义色板在白底上的
|
|
298
|
+
// 固有天花板(要达标得换色相、即放弃 EP 语义色);且**改造前的实心底白字是同一组数字**
|
|
299
|
+
// (对比度对称:白字压在 success 上同样是 2.24)⇒ 镂空 + 压深是**净改善约 1.2 倍**,
|
|
300
|
+
// 不是新引入的缺陷。徽标是补充性指示器,图标档的完整语义另由悬浮气泡承载。
|
|
301
|
+
":root:not(.dark) .el-badge__content {",
|
|
302
|
+
" color: var(--el-color-danger-dark-2);",
|
|
303
|
+
"}",
|
|
304
|
+
":root:not(.dark) .el-badge__content--primary {",
|
|
305
|
+
" color: var(--el-color-primary-dark-2);",
|
|
306
|
+
"}",
|
|
307
|
+
":root:not(.dark) .el-badge__content--success {",
|
|
308
|
+
" color: var(--el-color-success-dark-2);",
|
|
309
|
+
"}",
|
|
310
|
+
":root:not(.dark) .el-badge__content--warning {",
|
|
311
|
+
" color: var(--el-color-warning-dark-2);",
|
|
312
|
+
"}",
|
|
313
|
+
":root:not(.dark) .el-badge__content--danger {",
|
|
314
|
+
" color: var(--el-color-danger-dark-2);",
|
|
315
|
+
"}",
|
|
316
|
+
":root:not(.dark) .el-badge__content--info {",
|
|
317
|
+
" color: var(--el-color-info-dark-2);",
|
|
318
|
+
"}"
|
|
319
|
+
].join("\n");
|
|
320
|
+
const EP_BRIDGE_CSS = [
|
|
321
|
+
// T1 必纳:表格行密度(垂直经 td padding,水平经 .cell padding)
|
|
322
|
+
".el-table .el-table__cell {",
|
|
323
|
+
" padding-top: var(--dc-core-cell-padding-y, 8px);",
|
|
324
|
+
" padding-bottom: var(--dc-core-cell-padding-y, 8px);",
|
|
325
|
+
"}",
|
|
326
|
+
".el-table .cell {",
|
|
327
|
+
" padding-left: var(--dc-core-cell-padding-x, 12px);",
|
|
328
|
+
" padding-right: var(--dc-core-cell-padding-x, 12px);",
|
|
329
|
+
"}",
|
|
330
|
+
// T1 必纳:表单项间距
|
|
331
|
+
".el-form-item {",
|
|
332
|
+
" margin-bottom: var(--dc-core-form-item-gap, 18px);",
|
|
333
|
+
"}"
|
|
334
|
+
// 注:dialog/card 内距撤到期二——其 EP 原生值(dialog 16 / card 20)与单一
|
|
335
|
+
// content-gap 无法同时对齐,本期纳入会破"默认档零漂移";期二用专属 var 补。
|
|
336
|
+
].join("\n");
|
|
337
|
+
const DENSITY_VALUE_MAP = {
|
|
338
|
+
compact: {
|
|
339
|
+
spaceUnit: "4px",
|
|
340
|
+
gap: "8px",
|
|
341
|
+
controlHeight: "28px",
|
|
342
|
+
cellPaddingY: "6px",
|
|
343
|
+
cellPaddingX: "12px",
|
|
344
|
+
formItemGap: "12px",
|
|
345
|
+
fontSizeBase: "13px",
|
|
346
|
+
fontScale: "1.15"
|
|
347
|
+
},
|
|
348
|
+
cozy: {
|
|
349
|
+
// cozy = 默认档:取值 [MUST] 与 EP 原生对齐(控件 32 / 字号 14 / 行垂距 8 /
|
|
350
|
+
// 横距 12 / form-item 18),保证未 opt-in 的存量应用零视觉漂移。
|
|
351
|
+
spaceUnit: "4px",
|
|
352
|
+
gap: "12px",
|
|
353
|
+
controlHeight: "32px",
|
|
354
|
+
cellPaddingY: "8px",
|
|
355
|
+
cellPaddingX: "12px",
|
|
356
|
+
formItemGap: "18px",
|
|
357
|
+
fontSizeBase: "14px",
|
|
358
|
+
fontScale: "1.2"
|
|
359
|
+
},
|
|
360
|
+
comfortable: {
|
|
361
|
+
spaceUnit: "4px",
|
|
362
|
+
gap: "20px",
|
|
363
|
+
controlHeight: "40px",
|
|
364
|
+
cellPaddingY: "14px",
|
|
365
|
+
cellPaddingX: "12px",
|
|
366
|
+
formItemGap: "26px",
|
|
367
|
+
fontSizeBase: "15px",
|
|
368
|
+
fontScale: "1.25"
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const MOTION_VALUE_MAP = {
|
|
372
|
+
snappy: {
|
|
373
|
+
duration: "120ms",
|
|
374
|
+
durationSlow: "180ms",
|
|
375
|
+
easing: "cubic-bezier(0.4, 0, 0.2, 1)"
|
|
376
|
+
},
|
|
377
|
+
standard: {
|
|
378
|
+
// standard = 默认档:duration 200 / durationSlow 300 对齐 EP 原生
|
|
379
|
+
// (--el-transition-duration-fast .2s / --el-transition-duration .3s),默认零漂移。
|
|
380
|
+
duration: "200ms",
|
|
381
|
+
durationSlow: "300ms",
|
|
382
|
+
easing: "cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
383
|
+
},
|
|
384
|
+
calm: {
|
|
385
|
+
duration: "320ms",
|
|
386
|
+
durationSlow: "420ms",
|
|
387
|
+
easing: "cubic-bezier(0.22, 0.61, 0.36, 1)"
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
function buildRhythmCss(density, motion) {
|
|
391
|
+
const d = DENSITY_VALUE_MAP[density];
|
|
392
|
+
const m = MOTION_VALUE_MAP[motion];
|
|
393
|
+
const lines = [
|
|
394
|
+
`--dc-core-space-unit: ${d.spaceUnit};`,
|
|
395
|
+
`--dc-core-content-gap: ${d.gap};`,
|
|
396
|
+
`--dc-core-control-height: ${d.controlHeight};`,
|
|
397
|
+
`--el-component-size: ${d.controlHeight};`,
|
|
398
|
+
`--dc-core-cell-padding-y: ${d.cellPaddingY};`,
|
|
399
|
+
`--dc-core-cell-padding-x: ${d.cellPaddingX};`,
|
|
400
|
+
`--dc-core-form-item-gap: ${d.formItemGap};`,
|
|
401
|
+
`--dc-core-font-size-base: ${d.fontSizeBase};`,
|
|
402
|
+
`--el-font-size-base: ${d.fontSizeBase};`,
|
|
403
|
+
`--dc-core-font-scale: ${d.fontScale};`,
|
|
404
|
+
`--dc-core-motion-duration: ${m.duration};`,
|
|
405
|
+
`--el-transition-duration-fast: ${m.duration};`,
|
|
406
|
+
`--dc-core-motion-duration-slow: ${m.durationSlow};`,
|
|
407
|
+
`--el-transition-duration: ${m.durationSlow};`,
|
|
408
|
+
// easing 仅挂 dc-core,[MUST NOT] dual-write 覆盖 EP 两条 bezier——
|
|
409
|
+
// EP ease-in-out / fast 曲线各异,覆盖会让默认档动画曲线漂移;motion 档对 EP 只经 duration 生效。
|
|
410
|
+
`--dc-core-motion-easing: ${m.easing};`
|
|
411
|
+
];
|
|
412
|
+
const reduced = [
|
|
413
|
+
"--dc-core-motion-duration: 0.01ms;",
|
|
414
|
+
"--dc-core-motion-duration-slow: 0.01ms;",
|
|
415
|
+
"--el-transition-duration: 0.01ms;",
|
|
416
|
+
"--el-transition-duration-fast: 0.01ms;"
|
|
417
|
+
];
|
|
418
|
+
return `:root {
|
|
419
|
+
${lines.join("\n ")}
|
|
420
|
+
}
|
|
421
|
+
@media (prefers-reduced-motion: reduce) {
|
|
422
|
+
:root {
|
|
423
|
+
${reduced.join(
|
|
424
|
+
"\n "
|
|
425
|
+
)}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
`;
|
|
429
|
+
}
|
|
430
|
+
function useCoreThemeApply(options) {
|
|
431
|
+
const doc = options.document ?? (typeof document !== "undefined" ? document : void 0);
|
|
432
|
+
if (!doc) return;
|
|
433
|
+
const idSuffix = randomStyleSuffix();
|
|
434
|
+
const ownedEls = [];
|
|
435
|
+
const createOwnedStyle = (baseId) => {
|
|
436
|
+
const el = doc.createElement("style");
|
|
437
|
+
el.id = `${baseId}-${idSuffix}`;
|
|
438
|
+
doc.head.appendChild(el);
|
|
439
|
+
ownedEls.push(el);
|
|
440
|
+
return el;
|
|
441
|
+
};
|
|
442
|
+
let themeEl = null;
|
|
443
|
+
const ensureStyleEl = () => {
|
|
444
|
+
if (!themeEl) themeEl = createOwnedStyle(STYLE_EL_ID);
|
|
445
|
+
return themeEl;
|
|
446
|
+
};
|
|
447
|
+
if (!doc.getElementById(EP_STRUCTURAL_STYLE_EL_ID)) {
|
|
448
|
+
const structEl = doc.createElement("style");
|
|
449
|
+
structEl.id = EP_STRUCTURAL_STYLE_EL_ID;
|
|
450
|
+
structEl.textContent = EP_STRUCTURAL_CSS;
|
|
451
|
+
doc.head.appendChild(structEl);
|
|
452
|
+
}
|
|
453
|
+
watch(
|
|
454
|
+
options.getThemeConfig,
|
|
455
|
+
(config) => {
|
|
456
|
+
ensureStyleEl().textContent = buildThemeCss(config);
|
|
457
|
+
},
|
|
458
|
+
{ deep: true, immediate: true }
|
|
459
|
+
);
|
|
460
|
+
watch(
|
|
461
|
+
options.getThemeIsDark,
|
|
462
|
+
(isDark) => {
|
|
463
|
+
doc.documentElement.classList.toggle("dark", isDark);
|
|
464
|
+
},
|
|
465
|
+
{ immediate: true }
|
|
466
|
+
);
|
|
467
|
+
const { getThemeDensity, getThemeMotion } = options;
|
|
468
|
+
if (getThemeDensity && getThemeMotion) {
|
|
469
|
+
if (!doc.getElementById(EP_BRIDGE_STYLE_EL_ID)) {
|
|
470
|
+
const epEl = doc.createElement("style");
|
|
471
|
+
epEl.id = EP_BRIDGE_STYLE_EL_ID;
|
|
472
|
+
epEl.textContent = EP_BRIDGE_CSS;
|
|
473
|
+
doc.head.appendChild(epEl);
|
|
474
|
+
}
|
|
475
|
+
let rhythmEl = null;
|
|
476
|
+
const ensureRhythmStyleEl = () => {
|
|
477
|
+
if (!rhythmEl) rhythmEl = createOwnedStyle(RHYTHM_STYLE_EL_ID);
|
|
478
|
+
return rhythmEl;
|
|
479
|
+
};
|
|
480
|
+
watch(
|
|
481
|
+
() => [getThemeDensity(), getThemeMotion()],
|
|
482
|
+
([density, motion]) => {
|
|
483
|
+
ensureRhythmStyleEl().textContent = buildRhythmCss(density, motion);
|
|
484
|
+
},
|
|
485
|
+
{ immediate: true }
|
|
486
|
+
);
|
|
487
|
+
}
|
|
488
|
+
onScopeDispose(() => {
|
|
489
|
+
ownedEls.forEach((el) => el.remove());
|
|
490
|
+
ownedEls.length = 0;
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
export {
|
|
494
|
+
buildRhythmCss,
|
|
495
|
+
useCoreThemeApply
|
|
496
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { watch, onScopeDispose } from "vue";
|
|
2
|
+
const STYLE_EL_ID = "dc-core-viewport";
|
|
3
|
+
const randomStyleSuffix = () => Math.random().toString(36).slice(2, 9);
|
|
4
|
+
const buildViewportCss = (config, gap) => {
|
|
5
|
+
const horizontal = config.paddingLeft + config.paddingRight;
|
|
6
|
+
const vertical = config.paddingTop + config.paddingBottom;
|
|
7
|
+
return `:root {
|
|
8
|
+
--dc-core-viewport-width: calc(100vw - ${horizontal}px);
|
|
9
|
+
--dc-core-viewport-height: calc(100vh - ${vertical}px);
|
|
10
|
+
--dc-core-viewport-padding-top: ${config.paddingTop}px;
|
|
11
|
+
--dc-core-viewport-padding-right: ${config.paddingRight}px;
|
|
12
|
+
--dc-core-viewport-padding-bottom: ${config.paddingBottom}px;
|
|
13
|
+
--dc-core-viewport-padding-left: ${config.paddingLeft}px;
|
|
14
|
+
` + // gap 内缝 var:仅当提供 getGapConfig 时注入(纯对外暴露,core 不读)。
|
|
15
|
+
(gap ? ` --dc-core-gap: ${gap.size}px;
|
|
16
|
+
` : ``) + `}
|
|
17
|
+
`;
|
|
18
|
+
};
|
|
19
|
+
function useCoreViewportApply(options) {
|
|
20
|
+
const doc = options.document ?? (typeof document !== "undefined" ? document : void 0);
|
|
21
|
+
if (!doc) return;
|
|
22
|
+
const styleId = `${STYLE_EL_ID}-${randomStyleSuffix()}`;
|
|
23
|
+
let el = null;
|
|
24
|
+
const ensureStyleEl = () => {
|
|
25
|
+
if (!el) {
|
|
26
|
+
el = doc.createElement("style");
|
|
27
|
+
el.id = styleId;
|
|
28
|
+
doc.head.appendChild(el);
|
|
29
|
+
}
|
|
30
|
+
return el;
|
|
31
|
+
};
|
|
32
|
+
watch(
|
|
33
|
+
() => {
|
|
34
|
+
var _a;
|
|
35
|
+
return {
|
|
36
|
+
viewport: options.getViewportConfig(),
|
|
37
|
+
gap: (_a = options.getGapConfig) == null ? void 0 : _a.call(options)
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
({ viewport, gap }) => {
|
|
41
|
+
ensureStyleEl().textContent = buildViewportCss(viewport, gap);
|
|
42
|
+
},
|
|
43
|
+
{ deep: true, immediate: true }
|
|
44
|
+
);
|
|
45
|
+
onScopeDispose(() => {
|
|
46
|
+
el == null ? void 0 : el.remove();
|
|
47
|
+
el = null;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
useCoreViewportApply
|
|
52
|
+
};
|