@vue-ui-kit/ant 2.5.1 → 2.5.3
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/dist/ant.css +2 -0
- package/dist/cjs/index.js +6 -6
- package/dist/es/index.js +1970 -1694
- package/dist/index.d.ts +78 -1
- package/dist/style.css +58 -1
- package/dist/style.scss +3 -1
- package/package.json +2 -2
- package/src/packages/components/PCanvasGrid.vue +28 -28
- package/src/packages/components/PCanvasTable.vue +12 -1
- package/src/packages/styles/canvas-theme.scss +57 -0
- package/src/packages/styles/index.scss +3 -1
- package/src/packages/utils/canvasTableTheme.ts +111 -0
package/dist/index.d.ts
CHANGED
|
@@ -782,6 +782,12 @@ declare class Config {
|
|
|
782
782
|
CELL_HOVER_ICON_BG_COLOR: string;
|
|
783
783
|
/** hover编辑图标边框颜色 */
|
|
784
784
|
CELL_HOVER_ICON_BORDER_COLOR: string;
|
|
785
|
+
/** 内容缩放最小比例 */
|
|
786
|
+
MIN_ZOOM: number;
|
|
787
|
+
/** 内容缩放最大比例 */
|
|
788
|
+
MAX_ZOOM: number;
|
|
789
|
+
/** 启用 Ctrl + 滚轮内容缩放 */
|
|
790
|
+
ENABLE_ZOOM_WHEEL: boolean;
|
|
785
791
|
/** 滚动条轨道尺寸 */
|
|
786
792
|
SCROLLER_TRACK_SIZE: number;
|
|
787
793
|
/** 滚动条滑块尺寸 */
|
|
@@ -1075,6 +1081,10 @@ declare class Context {
|
|
|
1075
1081
|
loadingElement?: HTMLDivElement;
|
|
1076
1082
|
stageWidth: number;
|
|
1077
1083
|
stageHeight: number;
|
|
1084
|
+
stagePhysicalWidth: number;
|
|
1085
|
+
stagePhysicalHeight: number;
|
|
1086
|
+
zoomScale: ZoomScale;
|
|
1087
|
+
get zoom(): number;
|
|
1078
1088
|
paint: Paint;
|
|
1079
1089
|
icons: Icons;
|
|
1080
1090
|
domSelectionStr: string;
|
|
@@ -1156,6 +1166,12 @@ declare class Context {
|
|
|
1156
1166
|
offsetX: number;
|
|
1157
1167
|
offsetY: number;
|
|
1158
1168
|
};
|
|
1169
|
+
toVisual(value: number): number;
|
|
1170
|
+
toLogical(value: number): number;
|
|
1171
|
+
toVisualPx(value: number): string;
|
|
1172
|
+
scaleStyle<T extends Record<string, any>>(style: T): T;
|
|
1173
|
+
setZoom(zoom: number): void;
|
|
1174
|
+
getZoom(): number;
|
|
1159
1175
|
hasEvent(event: string): boolean;
|
|
1160
1176
|
on(event: string, callback: EventCallback): void;
|
|
1161
1177
|
once(event: string, callback: EventCallback): void;
|
|
@@ -1617,6 +1633,12 @@ declare class EVirtTable {
|
|
|
1617
1633
|
clearEditableData(value?: null): ChangeItem[];
|
|
1618
1634
|
clearEditor(): void;
|
|
1619
1635
|
doLayout(): void;
|
|
1636
|
+
/**
|
|
1637
|
+
* 设置内容缩放比例(容器大小不变,内容变大/变小,基于原生分辨率重绘不失清晰度)
|
|
1638
|
+
* @param zoom 缩放比例,范围 MIN_ZOOM ~ MAX_ZOOM
|
|
1639
|
+
*/
|
|
1640
|
+
setZoom(zoom: number): void;
|
|
1641
|
+
getZoom(): number;
|
|
1620
1642
|
getChangedData(): {
|
|
1621
1643
|
rowKey: string;
|
|
1622
1644
|
colKey: string;
|
|
@@ -1911,7 +1933,7 @@ declare class Paint {
|
|
|
1911
1933
|
constructor(target: HTMLCanvasElement);
|
|
1912
1934
|
getCtx(): CanvasRenderingContext2D;
|
|
1913
1935
|
clearTextCache(): void;
|
|
1914
|
-
scale(dpr: number): void;
|
|
1936
|
+
scale(dpr: number, zoom?: number): void;
|
|
1915
1937
|
save(): void;
|
|
1916
1938
|
restore(): void;
|
|
1917
1939
|
translate(x: number, y: number): void;
|
|
@@ -5363,6 +5385,17 @@ declare type ValidatorFunction<T> = (value: T) => boolean
|
|
|
5363
5385
|
|
|
5364
5386
|
declare type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
5365
5387
|
|
|
5388
|
+
declare type ViewportRect = {
|
|
5389
|
+
x: number;
|
|
5390
|
+
y: number;
|
|
5391
|
+
left: number;
|
|
5392
|
+
top: number;
|
|
5393
|
+
right: number;
|
|
5394
|
+
bottom: number;
|
|
5395
|
+
width: number;
|
|
5396
|
+
height: number;
|
|
5397
|
+
};
|
|
5398
|
+
|
|
5366
5399
|
declare interface VueTypeBaseDef<
|
|
5367
5400
|
T = unknown,
|
|
5368
5401
|
D = DefaultType<T>,
|
|
@@ -5387,4 +5420,48 @@ declare interface VueTypeValidableDef<T = unknown> extends VueTypeBaseDef<T> {
|
|
|
5387
5420
|
|
|
5388
5421
|
export declare function watchPreviousDeep<T extends object>(source: WatchSource<T>, cb: (value: T, oldValue: T, onCleanup: () => void) => void, options?: WatchOptions): WatchHandle;
|
|
5389
5422
|
|
|
5423
|
+
/** 内容缩放:逻辑坐标 ↔ 物理像素,canvas / DOM 共用 */
|
|
5424
|
+
declare class ZoomScale {
|
|
5425
|
+
value: number;
|
|
5426
|
+
get isDefault(): boolean;
|
|
5427
|
+
clamp(value: number, min: number, max: number): number;
|
|
5428
|
+
/** @returns 是否发生变化 */
|
|
5429
|
+
set(value: number, min: number, max: number): boolean;
|
|
5430
|
+
/** 逻辑 -> 物理 */
|
|
5431
|
+
toVisual(logical: number): number;
|
|
5432
|
+
/** 物理 -> 逻辑 */
|
|
5433
|
+
toLogical(physical: number): number;
|
|
5434
|
+
toPx(logical: number): string;
|
|
5435
|
+
/** DOM 测量高度 -> 逻辑高度 */
|
|
5436
|
+
domHeightToLogical(physicalHeight: number): number;
|
|
5437
|
+
/** 逻辑内容尺寸 -> 物理尺寸 */
|
|
5438
|
+
contentToPhysical(logical: number): number;
|
|
5439
|
+
scaleStyle<T extends Record<string, any>>(style: T): T;
|
|
5440
|
+
assignScaledStyle(el: HTMLElement, style: Record<string, any>): void;
|
|
5441
|
+
/** 容器物理宽度 -> 逻辑可视宽度 */
|
|
5442
|
+
containerWidth(containerPhysicalWidth: number): number;
|
|
5443
|
+
resolveStageWidth(options: {
|
|
5444
|
+
containerPhysicalWidth: number;
|
|
5445
|
+
contentWidth: number;
|
|
5446
|
+
scrollerTrackSize: number;
|
|
5447
|
+
fillContainer: boolean;
|
|
5448
|
+
}): {
|
|
5449
|
+
stageWidth: number;
|
|
5450
|
+
stagePhysicalWidth: number;
|
|
5451
|
+
};
|
|
5452
|
+
applyStageHeight(stageElement: HTMLDivElement, physicalHeight: number): {
|
|
5453
|
+
stageHeight: number;
|
|
5454
|
+
stagePhysicalHeight: number;
|
|
5455
|
+
};
|
|
5456
|
+
/** floating-ui 锚点:逻辑单元格 -> 视口物理矩形 */
|
|
5457
|
+
getViewportRect(logical: {
|
|
5458
|
+
x: number;
|
|
5459
|
+
y: number;
|
|
5460
|
+
width: number;
|
|
5461
|
+
height: number;
|
|
5462
|
+
}, containerRect: DOMRect): ViewportRect;
|
|
5463
|
+
/** overlayer 单元格:外层物理定位 + 内层 zoom 缩放自定义 render */
|
|
5464
|
+
createOverlayerCellElement(cell: Cell | CellHeader, cssPrefix: string): HTMLDivElement;
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5390
5467
|
export { }
|
package/dist/style.css
CHANGED
|
@@ -1,4 +1,61 @@
|
|
|
1
1
|
@charset "UTF-8";
|
|
2
|
+
/**
|
|
3
|
+
* EVirtTable(PCanvasGrid / PCanvasTable)主题变量
|
|
4
|
+
* - 与 PGrid 共用 --p-* 语义变量,保证 Canvas 表格与 DOM 表格同色
|
|
5
|
+
* - 无对应 --p-* 的项使用 storybook theme.css 默认值
|
|
6
|
+
* - e-virt-table 初始化时通过 Config.updateCssVar() 读取 --evt-*
|
|
7
|
+
*/
|
|
8
|
+
:root {
|
|
9
|
+
--evt-border-color: var(--p-border-color, #d9d9d9);
|
|
10
|
+
--evt-header-bg-color: var(--p-table-thead-bg-color, #f2f3f6);
|
|
11
|
+
--evt-body-bg-color: var(--p-table-row-bg-color, #fff);
|
|
12
|
+
--evt-stripe-color: var(--p-striped-bg-color, #f2f3f6);
|
|
13
|
+
--evt-highlight-hover-row-color: var(--p-table-row-hover-bg-color, #e6e7ea);
|
|
14
|
+
--evt-select-border-color: var(--p-primary-color, #4096ff);
|
|
15
|
+
--evt-sort-icon-color: var(--p-primary-color, #4096ff);
|
|
16
|
+
--evt-required-color: var(--p-danger-color, #f5222d);
|
|
17
|
+
--evt-error-tip-color: var(--p-danger-color, #f5222d);
|
|
18
|
+
--evt-error-tip-icon-color: var(--p-danger-color, #f5222d);
|
|
19
|
+
--evt-readonly-color: var(--p-table-row-bg-color, #fff);
|
|
20
|
+
--evt-scroller-track-color: var(--p-table-row-bg-color, #fff);
|
|
21
|
+
/* Canvas 专用(白天 = storybook 默认值) */
|
|
22
|
+
--evt-header-text-color: #1d2129;
|
|
23
|
+
--evt-body-text-color: #4e5969;
|
|
24
|
+
--evt-footer-text-color: #4e5969;
|
|
25
|
+
--evt-readonly-text-color: #4e5969;
|
|
26
|
+
--evt-scroller-color: #dee0e3;
|
|
27
|
+
--evt-scroller-focus-color: #bbbec4;
|
|
28
|
+
--evt-edit-bg-color: #fcf6ed;
|
|
29
|
+
--evt-footer-bg-color: #fafafa;
|
|
30
|
+
--evt-autofill-point-border-color: #fff;
|
|
31
|
+
--evt-editor-bg-color: #fff;
|
|
32
|
+
--evt-editor-text-color: #333;
|
|
33
|
+
--evt-context-menu-bg-color: #fff;
|
|
34
|
+
--evt-context-menu-text-color: #333;
|
|
35
|
+
--evt-context-menu-item-hover-bg-color: #f5f5f5;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* 夜间:背景随 --p-* 传递,仅覆盖 Canvas 专用色 */
|
|
39
|
+
html[theme-mode=dark],
|
|
40
|
+
:root[data-theme=dark],
|
|
41
|
+
:root.dark {
|
|
42
|
+
--evt-header-text-color: #a3a6ad;
|
|
43
|
+
--evt-body-text-color: #cfd3dc;
|
|
44
|
+
--evt-footer-text-color: #cfd3dc;
|
|
45
|
+
--evt-readonly-text-color: #a3a6ad;
|
|
46
|
+
--evt-scroller-color: #414243;
|
|
47
|
+
--evt-scroller-track-color: #141414;
|
|
48
|
+
--evt-scroller-focus-color: #a3a6ad;
|
|
49
|
+
--evt-edit-bg-color: #141414;
|
|
50
|
+
--evt-footer-bg-color: #262727;
|
|
51
|
+
--evt-autofill-point-border-color: #a3a6ad;
|
|
52
|
+
--evt-editor-bg-color: #434343;
|
|
53
|
+
--evt-editor-text-color: #cfd3dc;
|
|
54
|
+
--evt-context-menu-bg-color: #141414;
|
|
55
|
+
--evt-context-menu-text-color: #cfd3dc;
|
|
56
|
+
--evt-context-menu-item-hover-bg-color: #414243;
|
|
57
|
+
}
|
|
58
|
+
|
|
2
59
|
.p-pane {
|
|
3
60
|
background-color: var(--p-theme-bg, #fff);
|
|
4
61
|
padding: 16px;
|
|
@@ -159,7 +216,7 @@
|
|
|
159
216
|
margin-bottom: -0.5em;
|
|
160
217
|
}
|
|
161
218
|
.p-wrapper .p-canvas-toolbar-wrapper {
|
|
162
|
-
box-shadow: 0 8px var(--p-bg
|
|
219
|
+
box-shadow: 0 8px var(--p-theme-bg, #fff);
|
|
163
220
|
border-radius: 0.5em 0.5em 0 0;
|
|
164
221
|
}
|
|
165
222
|
.p-wrapper .ant-form .ant-form-item {
|
package/dist/style.scss
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'canvas-theme';
|
|
2
|
+
|
|
1
3
|
.p-pane {
|
|
2
4
|
background-color: var(--p-theme-bg, #fff);
|
|
3
5
|
padding: 16px;
|
|
@@ -164,7 +166,7 @@
|
|
|
164
166
|
margin-bottom: -0.5em;
|
|
165
167
|
}
|
|
166
168
|
.p-canvas-toolbar-wrapper {
|
|
167
|
-
box-shadow: 0 8px var(--p-bg
|
|
169
|
+
box-shadow: 0 8px var(--p-theme-bg, #fff);
|
|
168
170
|
border-radius: 0.5em 0.5em 0 0;
|
|
169
171
|
}
|
|
170
172
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-ui-kit/ant",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"description": "Vue3 UI Kit based on Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"email": "adoin@qq.com"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"e-virt-table": "
|
|
50
|
+
"e-virt-table": "1.4.2",
|
|
51
51
|
"uuid": "^11.1.1",
|
|
52
52
|
"xe-utils": "^3.7.6"
|
|
53
53
|
},
|
|
@@ -4,20 +4,6 @@
|
|
|
4
4
|
generic="D extends Recordable = Recordable, F extends Recordable = Recordable"
|
|
5
5
|
name="PCanvasGrid"
|
|
6
6
|
>
|
|
7
|
-
import PCanvasTable from './PCanvasTable.vue';
|
|
8
|
-
import {
|
|
9
|
-
computed,
|
|
10
|
-
useAttrs,
|
|
11
|
-
ref,
|
|
12
|
-
Ref,
|
|
13
|
-
reactive,
|
|
14
|
-
onMounted,
|
|
15
|
-
nextTick,
|
|
16
|
-
toRefs,
|
|
17
|
-
onBeforeUnmount,
|
|
18
|
-
watch,
|
|
19
|
-
} from 'vue';
|
|
20
|
-
import { debounce, get, isBoolean, isFunction, isObject, isString, omit, uniq } from 'xe-utils';
|
|
21
7
|
import {
|
|
22
8
|
CanvasColumnProps,
|
|
23
9
|
PCanvasGridProps,
|
|
@@ -25,28 +11,42 @@
|
|
|
25
11
|
PFormItemProps,
|
|
26
12
|
ResponsePathConfig,
|
|
27
13
|
} from '#/antProxy';
|
|
28
|
-
import { v4 as uuid_v4 } from 'uuid';
|
|
29
|
-
import { isGoodValue } from '@/utils/is';
|
|
30
14
|
import PFormCol from '@/components/PFormCol.vue';
|
|
31
|
-
import { defaultLabelCol } from '@/utils/core';
|
|
32
|
-
import Icon from '@/renders/Icon';
|
|
33
15
|
import { $confirm, $error, $success, $warning } from '@/hooks/useMessage';
|
|
34
|
-
import
|
|
35
|
-
Button as AButton,
|
|
36
|
-
Form as AForm,
|
|
37
|
-
Row as ARow,
|
|
38
|
-
Spin as ASpin,
|
|
39
|
-
Pagination as APagination,
|
|
40
|
-
} from 'ant-design-vue';
|
|
41
|
-
import { DownOutlined } from '@ant-design/icons-vue';
|
|
42
|
-
import { getCanvasTableDefaults, getGridDefaults } from '@/utils/config';
|
|
16
|
+
import Icon from '@/renders/Icon';
|
|
43
17
|
import {
|
|
44
18
|
createAutoViewportBoxController,
|
|
45
19
|
parseAutoViewportBoxOffset,
|
|
46
20
|
type AutoViewportBoxController,
|
|
47
21
|
type AutoViewportBoxOffsetInput,
|
|
48
22
|
} from '@/utils/autoViewportBox';
|
|
23
|
+
import { getCanvasTableDefaults, getGridDefaults } from '@/utils/config';
|
|
24
|
+
import { defaultLabelCol } from '@/utils/core';
|
|
25
|
+
import { isGoodValue } from '@/utils/is';
|
|
49
26
|
import { eachTree } from '@/utils/treeHelper';
|
|
27
|
+
import { DownOutlined } from '@ant-design/icons-vue';
|
|
28
|
+
import {
|
|
29
|
+
Button as AButton,
|
|
30
|
+
Form as AForm,
|
|
31
|
+
Pagination as APagination,
|
|
32
|
+
Row as ARow,
|
|
33
|
+
Spin as ASpin,
|
|
34
|
+
} from 'ant-design-vue';
|
|
35
|
+
import { v4 as uuid_v4 } from 'uuid';
|
|
36
|
+
import {
|
|
37
|
+
Ref,
|
|
38
|
+
computed,
|
|
39
|
+
nextTick,
|
|
40
|
+
onBeforeUnmount,
|
|
41
|
+
onMounted,
|
|
42
|
+
reactive,
|
|
43
|
+
ref,
|
|
44
|
+
toRefs,
|
|
45
|
+
useAttrs,
|
|
46
|
+
watch,
|
|
47
|
+
} from 'vue';
|
|
48
|
+
import { debounce, get, isBoolean, isFunction, isObject, isString, omit, uniq } from 'xe-utils';
|
|
49
|
+
import PCanvasTable from './PCanvasTable.vue';
|
|
50
50
|
const props = withDefaults(defineProps<PCanvasGridProps<D, F>>(), {
|
|
51
51
|
lazyReset: () => getGridDefaults().lazyReset ?? false,
|
|
52
52
|
fitHeight: () => getGridDefaults().fitCanvasHeight ?? 0,
|
|
@@ -655,7 +655,7 @@
|
|
|
655
655
|
</template>
|
|
656
656
|
</span>
|
|
657
657
|
</div>
|
|
658
|
-
<div ref="tableWrapperEl" class="
|
|
658
|
+
<div ref="tableWrapperEl" class="flex-1 h-0 min-h-0 flex flex-col p-inner-scroll">
|
|
659
659
|
<div ref="tableBodyEl" class="flex-1 min-h-0 overflow-hidden">
|
|
660
660
|
<p-canvas-table
|
|
661
661
|
ref="canvasTableRef"
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
OverlayerContainer,
|
|
13
13
|
FormatterMethod,
|
|
14
14
|
} from 'e-virt-table';
|
|
15
|
-
import { ref, onMounted, computed, useAttrs, watch } from 'vue';
|
|
15
|
+
import { ref, onMounted, onUnmounted, computed, useAttrs, watch } from 'vue';
|
|
16
16
|
import { EventCallback } from 'e-virt-table/dist/lib/EventBus';
|
|
17
17
|
import { isArray, isEqual, isFunction, isString, omit } from 'xe-utils';
|
|
18
18
|
import renderStore from '@/store/renderStore';
|
|
@@ -20,8 +20,10 @@
|
|
|
20
20
|
import type { CanvasColumnProps, CanvasTableProps, FormatterFunc, CellRender } from '#/antProxy';
|
|
21
21
|
import { v4 as uuidv4 } from 'uuid';
|
|
22
22
|
import { antFormatters } from '@/utils/AFormatters';
|
|
23
|
+
import { bindCanvasTableThemeSync, syncCanvasThemeCssVars, type CanvasTableThemeHandle } from '@/utils/canvasTableTheme';
|
|
23
24
|
import { getCanvasTableDefaults } from '@/utils/config';
|
|
24
25
|
import { watchPreviousDeep } from '@/utils/core';
|
|
26
|
+
import '../styles/canvas-theme.scss';
|
|
25
27
|
|
|
26
28
|
const emit = defineEmits<{
|
|
27
29
|
(e: 'change', value: any[]): void; // 需要默认实现change,不能动态绑定
|
|
@@ -45,6 +47,7 @@
|
|
|
45
47
|
},
|
|
46
48
|
}));
|
|
47
49
|
let eVirtTable: EVirtTable | null = null;
|
|
50
|
+
let themeSyncHandle: CanvasTableThemeHandle | null = null;
|
|
48
51
|
const attrs = useAttrs();
|
|
49
52
|
const eVirtTableRef = ref(null);
|
|
50
53
|
const eVirtTableEditorRef = ref(null);
|
|
@@ -150,6 +153,7 @@
|
|
|
150
153
|
if (!eVirtTableRef.value) {
|
|
151
154
|
return;
|
|
152
155
|
}
|
|
156
|
+
syncCanvasThemeCssVars();
|
|
153
157
|
eVirtTable = new EVirtTable(eVirtTableRef.value, {
|
|
154
158
|
config: propsWithDefaults.value.config,
|
|
155
159
|
columns: props.columns.map((col) => parseToEVirtColumn(col)),
|
|
@@ -190,6 +194,13 @@
|
|
|
190
194
|
emit('selectionChange', selection);
|
|
191
195
|
});
|
|
192
196
|
emit('ready', eVirtTable);
|
|
197
|
+
themeSyncHandle = bindCanvasTableThemeSync({
|
|
198
|
+
getTable: () => eVirtTable,
|
|
199
|
+
getConfig: () => propsWithDefaults.value.config,
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
onUnmounted(() => {
|
|
203
|
+
themeSyncHandle?.disconnect();
|
|
193
204
|
});
|
|
194
205
|
function saveCellValue(value) {
|
|
195
206
|
if (!eVirtTable || !editorCell.value) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVirtTable(PCanvasGrid / PCanvasTable)主题变量
|
|
3
|
+
* - 与 PGrid 共用 --p-* 语义变量,保证 Canvas 表格与 DOM 表格同色
|
|
4
|
+
* - 无对应 --p-* 的项使用 storybook theme.css 默认值
|
|
5
|
+
* - e-virt-table 初始化时通过 Config.updateCssVar() 读取 --evt-*
|
|
6
|
+
*/
|
|
7
|
+
:root {
|
|
8
|
+
--evt-border-color: var(--p-border-color, #d9d9d9);
|
|
9
|
+
--evt-header-bg-color: var(--p-table-thead-bg-color, #f2f3f6);
|
|
10
|
+
--evt-body-bg-color: var(--p-table-row-bg-color, #fff);
|
|
11
|
+
--evt-stripe-color: var(--p-striped-bg-color, #f2f3f6);
|
|
12
|
+
--evt-highlight-hover-row-color: var(--p-table-row-hover-bg-color, #e6e7ea);
|
|
13
|
+
--evt-select-border-color: var(--p-primary-color, #4096ff);
|
|
14
|
+
--evt-sort-icon-color: var(--p-primary-color, #4096ff);
|
|
15
|
+
--evt-required-color: var(--p-danger-color, #f5222d);
|
|
16
|
+
--evt-error-tip-color: var(--p-danger-color, #f5222d);
|
|
17
|
+
--evt-error-tip-icon-color: var(--p-danger-color, #f5222d);
|
|
18
|
+
--evt-readonly-color: var(--p-table-row-bg-color, #fff);
|
|
19
|
+
--evt-scroller-track-color: var(--p-table-row-bg-color, #fff);
|
|
20
|
+
|
|
21
|
+
/* Canvas 专用(白天 = storybook 默认值) */
|
|
22
|
+
--evt-header-text-color: #1d2129;
|
|
23
|
+
--evt-body-text-color: #4e5969;
|
|
24
|
+
--evt-footer-text-color: #4e5969;
|
|
25
|
+
--evt-readonly-text-color: #4e5969;
|
|
26
|
+
--evt-scroller-color: #dee0e3;
|
|
27
|
+
--evt-scroller-focus-color: #bbbec4;
|
|
28
|
+
--evt-edit-bg-color: #fcf6ed;
|
|
29
|
+
--evt-footer-bg-color: #fafafa;
|
|
30
|
+
--evt-autofill-point-border-color: #fff;
|
|
31
|
+
--evt-editor-bg-color: #fff;
|
|
32
|
+
--evt-editor-text-color: #333;
|
|
33
|
+
--evt-context-menu-bg-color: #fff;
|
|
34
|
+
--evt-context-menu-text-color: #333;
|
|
35
|
+
--evt-context-menu-item-hover-bg-color: #f5f5f5;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* 夜间:背景随 --p-* 传递,仅覆盖 Canvas 专用色 */
|
|
39
|
+
html[theme-mode='dark'],
|
|
40
|
+
:root[data-theme='dark'],
|
|
41
|
+
:root.dark {
|
|
42
|
+
--evt-header-text-color: #a3a6ad;
|
|
43
|
+
--evt-body-text-color: #cfd3dc;
|
|
44
|
+
--evt-footer-text-color: #cfd3dc;
|
|
45
|
+
--evt-readonly-text-color: #a3a6ad;
|
|
46
|
+
--evt-scroller-color: #414243;
|
|
47
|
+
--evt-scroller-track-color: #141414;
|
|
48
|
+
--evt-scroller-focus-color: #a3a6ad;
|
|
49
|
+
--evt-edit-bg-color: #141414;
|
|
50
|
+
--evt-footer-bg-color: #262727;
|
|
51
|
+
--evt-autofill-point-border-color: #a3a6ad;
|
|
52
|
+
--evt-editor-bg-color: #434343;
|
|
53
|
+
--evt-editor-text-color: #cfd3dc;
|
|
54
|
+
--evt-context-menu-bg-color: #141414;
|
|
55
|
+
--evt-context-menu-text-color: #cfd3dc;
|
|
56
|
+
--evt-context-menu-item-hover-bg-color: #414243;
|
|
57
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@use 'canvas-theme';
|
|
2
|
+
|
|
1
3
|
.p-pane {
|
|
2
4
|
background-color: var(--p-theme-bg, #fff);
|
|
3
5
|
padding: 16px;
|
|
@@ -164,7 +166,7 @@
|
|
|
164
166
|
margin-bottom: -0.5em;
|
|
165
167
|
}
|
|
166
168
|
.p-canvas-toolbar-wrapper {
|
|
167
|
-
box-shadow: 0 8px var(--p-bg
|
|
169
|
+
box-shadow: 0 8px var(--p-theme-bg, #fff);
|
|
168
170
|
border-radius: 0.5em 0.5em 0 0;
|
|
169
171
|
}
|
|
170
172
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type EVirtTable from 'e-virt-table';
|
|
2
|
+
import type { ConfigType } from 'e-virt-table';
|
|
3
|
+
|
|
4
|
+
/** --p-* → --evt-* 桥接(与 canvas-theme.scss / storybook theme.css 对齐) */
|
|
5
|
+
const P_TO_EVT_BRIDGE: ReadonlyArray<readonly [evt: string, p: string, fallback: string]> = [
|
|
6
|
+
['--evt-border-color', '--p-border-color', '#d9d9d9'],
|
|
7
|
+
['--evt-header-bg-color', '--p-table-thead-bg-color', '#f2f3f6'],
|
|
8
|
+
['--evt-body-bg-color', '--p-table-row-bg-color', '#fff'],
|
|
9
|
+
['--evt-stripe-color', '--p-striped-bg-color', '#f2f3f6'],
|
|
10
|
+
['--evt-highlight-hover-row-color', '--p-table-row-hover-bg-color', '#e6e7ea'],
|
|
11
|
+
['--evt-select-border-color', '--p-primary-color', '#4096ff'],
|
|
12
|
+
['--evt-sort-icon-color', '--p-primary-color', '#4096ff'],
|
|
13
|
+
['--evt-required-color', '--p-danger-color', '#f5222d'],
|
|
14
|
+
['--evt-error-tip-color', '--p-danger-color', '#f5222d'],
|
|
15
|
+
['--evt-error-tip-icon-color', '--p-danger-color', '#f5222d'],
|
|
16
|
+
['--evt-readonly-color', '--p-table-row-bg-color', '#fff'],
|
|
17
|
+
['--evt-scroller-track-color', '--p-table-row-bg-color', '#fff'],
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
/** Canvas 专用色(无 --p-* 对应项,storybook 默认值) */
|
|
21
|
+
const LIGHT_EVT_DEDICATED: Readonly<Record<string, string>> = {
|
|
22
|
+
'--evt-header-text-color': '#1d2129',
|
|
23
|
+
'--evt-body-text-color': '#4e5969',
|
|
24
|
+
'--evt-footer-text-color': '#4e5969',
|
|
25
|
+
'--evt-readonly-text-color': '#4e5969',
|
|
26
|
+
'--evt-scroller-color': '#dee0e3',
|
|
27
|
+
'--evt-scroller-focus-color': '#bbbec4',
|
|
28
|
+
'--evt-edit-bg-color': '#fcf6ed',
|
|
29
|
+
'--evt-footer-bg-color': '#fafafa',
|
|
30
|
+
'--evt-autofill-point-border-color': '#fff',
|
|
31
|
+
'--evt-editor-bg-color': '#fff',
|
|
32
|
+
'--evt-editor-text-color': '#333',
|
|
33
|
+
'--evt-context-menu-bg-color': '#fff',
|
|
34
|
+
'--evt-context-menu-text-color': '#333',
|
|
35
|
+
'--evt-context-menu-item-hover-bg-color': '#f5f5f5',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const DARK_EVT_DEDICATED: Readonly<Record<string, string>> = {
|
|
39
|
+
'--evt-header-text-color': '#a3a6ad',
|
|
40
|
+
'--evt-body-text-color': '#cfd3dc',
|
|
41
|
+
'--evt-footer-text-color': '#cfd3dc',
|
|
42
|
+
'--evt-readonly-text-color': '#a3a6ad',
|
|
43
|
+
'--evt-scroller-color': '#414243',
|
|
44
|
+
'--evt-scroller-track-color': '#141414',
|
|
45
|
+
'--evt-scroller-focus-color': '#a3a6ad',
|
|
46
|
+
'--evt-edit-bg-color': '#141414',
|
|
47
|
+
'--evt-footer-bg-color': '#262727',
|
|
48
|
+
'--evt-autofill-point-border-color': '#a3a6ad',
|
|
49
|
+
'--evt-editor-bg-color': '#434343',
|
|
50
|
+
'--evt-editor-text-color': '#cfd3dc',
|
|
51
|
+
'--evt-context-menu-bg-color': '#141414',
|
|
52
|
+
'--evt-context-menu-text-color': '#cfd3dc',
|
|
53
|
+
'--evt-context-menu-item-hover-bg-color': '#414243',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function isDarkThemeRoot(el: HTMLElement = document.documentElement): boolean {
|
|
57
|
+
return (
|
|
58
|
+
el.getAttribute('theme-mode') === 'dark' ||
|
|
59
|
+
el.getAttribute('data-theme') === 'dark' ||
|
|
60
|
+
el.classList.contains('dark')
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 将 --p-* 解析值写入 --evt-*,覆盖 e-virt-table 运行时注入的浅色默认值。
|
|
66
|
+
*/
|
|
67
|
+
export function syncCanvasThemeCssVars(el: HTMLElement = document.documentElement): void {
|
|
68
|
+
const computed = getComputedStyle(el);
|
|
69
|
+
for (const [evt, p, fallback] of P_TO_EVT_BRIDGE) {
|
|
70
|
+
const value = computed.getPropertyValue(p).trim() || fallback;
|
|
71
|
+
el.style.setProperty(evt, value);
|
|
72
|
+
}
|
|
73
|
+
const dedicated = isDarkThemeRoot(el) ? DARK_EVT_DEDICATED : LIGHT_EVT_DEDICATED;
|
|
74
|
+
for (const [evt, value] of Object.entries(dedicated)) {
|
|
75
|
+
el.style.setProperty(evt, value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type CanvasTableThemeHandle = {
|
|
80
|
+
disconnect: () => void;
|
|
81
|
+
sync: () => void;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 同步 CSS 变量并 loadConfig,使 Canvas 表格与 PGrid 主题一致。
|
|
86
|
+
*/
|
|
87
|
+
export function bindCanvasTableThemeSync(options: {
|
|
88
|
+
getTable: () => EVirtTable | null;
|
|
89
|
+
getConfig: () => ConfigType;
|
|
90
|
+
}): CanvasTableThemeHandle {
|
|
91
|
+
const sync = () => {
|
|
92
|
+
syncCanvasThemeCssVars();
|
|
93
|
+
const table = options.getTable();
|
|
94
|
+
if (table) {
|
|
95
|
+
table.loadConfig(options.getConfig());
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const observer = new MutationObserver(sync);
|
|
100
|
+
observer.observe(document.documentElement, {
|
|
101
|
+
attributes: true,
|
|
102
|
+
attributeFilter: ['theme-mode', 'class', 'data-theme'],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
sync();
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
sync,
|
|
109
|
+
disconnect: () => observer.disconnect(),
|
|
110
|
+
};
|
|
111
|
+
}
|