xt-element-ui 1.1.3 → 1.1.4
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/lib/css/2.9f53fb10.css +1 -0
- package/lib/css/3.f955b130.css +1 -0
- package/lib/css/4.04feac2c.css +1 -0
- package/lib/css/5.6a8558e0.css +1 -0
- package/lib/css/6.e474b334.css +1 -0
- package/lib/index.common.0.js +16448 -15696
- package/lib/index.common.2.js +298 -270
- package/lib/index.common.3.js +82 -54
- package/lib/index.common.4.js +519 -489
- package/lib/index.common.5.js +74 -46
- package/lib/index.common.6.js +76 -48
- package/lib/index.common.js +826 -308
- package/lib/index.css +1 -1
- package/lib/index.umd.0.js +16448 -15696
- package/lib/index.umd.2.js +298 -270
- package/lib/index.umd.3.js +82 -54
- package/lib/index.umd.4.js +519 -489
- package/lib/index.umd.5.js +74 -46
- package/lib/index.umd.6.js +76 -48
- package/lib/index.umd.js +832 -313
- package/lib/index.umd.min.0.js +3 -3
- package/lib/index.umd.min.2.js +1 -1
- package/lib/index.umd.min.3.js +1 -1
- package/lib/index.umd.min.4.js +1 -1
- package/lib/index.umd.min.5.js +1 -1
- package/lib/index.umd.min.6.js +1 -1
- package/lib/index.umd.min.js +1 -1
- package/package.json +2 -1
- package/src/components/ex-button/index.js +2 -0
- package/src/components/ex-button/index.vue +61 -0
- package/src/components/ex-button/style/index.scss +31 -0
- package/src/components/ex-card/index.js +7 -0
- package/src/components/ex-card/index.vue +150 -0
- package/src/components/ex-card/style/index.scss +69 -0
- package/src/components/{chart → ex-chart}/ExBar.vue +3 -0
- package/src/components/{chart → ex-chart}/ExLine.vue +3 -0
- package/src/components/{chart → ex-chart}/ExMulti.vue +5 -0
- package/src/components/{chart → ex-chart}/ExPie.vue +3 -0
- package/src/components/{chart → ex-chart}/ExTrend.vue +3 -0
- package/src/components/ex-chart/index.js +2 -0
- package/src/components/ex-chart/index.vue +134 -0
- package/src/components/{chart → ex-chart}/theme/dark.js +1 -1
- package/src/components/{chart → ex-chart}/utils.js +40 -12
- package/src/components/index.scss +13 -7
- package/src/components/{button → xt-button}/index.vue +1 -1
- package/src/components/{card-item → xt-card-item}/index.vue +1 -1
- package/src/components/{config-provider → xt-config-provider}/index.vue +66 -0
- package/src/components/{date-picker → xt-date-picker}/index.vue +1 -1
- package/src/components/{date-picker → xt-date-picker}/quarter.vue +4 -2
- package/src/components/{table → xt-table}/index.vue +48 -107
- package/src/config/element-registry.js +136 -0
- package/src/index.js +56 -32
- package/src/styles/theme/colors.scss +1 -0
- package/lib/css/2.3f7aa432.css +0 -1
- package/lib/css/3.ffcc175d.css +0 -1
- package/lib/css/4.9abd1f2b.css +0 -1
- package/lib/css/5.1a31ed8a.css +0 -1
- package/lib/css/6.c2d0d77e.css +0 -1
- package/src/components/chart/index.js +0 -2
- package/src/components/chart/index.vue +0 -51
- /package/src/components/{chart → ex-chart}/pieList.vue +0 -0
- /package/src/components/{chart → ex-chart}/theme/blue.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/orange.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/starry.js +0 -0
- /package/src/components/{chart → ex-chart}/theme/white.js +0 -0
- /package/src/components/{button → xt-button}/index.js +0 -0
- /package/src/components/{button → xt-button}/style/index.scss +0 -0
- /package/src/components/{card → xt-card}/index.js +0 -0
- /package/src/components/{card → xt-card}/index.vue +0 -0
- /package/src/components/{card → xt-card}/style/index.scss +0 -0
- /package/src/components/{card-item → xt-card-item}/index.js +0 -0
- /package/src/components/{card-item → xt-card-item}/style/index.scss +0 -0
- /package/src/components/{config-provider → xt-config-provider}/index.js +0 -0
- /package/src/components/{config-provider → xt-config-provider}/style/index.scss +0 -0
- /package/src/components/{date-picker → xt-date-picker}/SearchDate.vue +0 -0
- /package/src/components/{date-picker → xt-date-picker}/index.js +0 -0
- /package/src/components/{flex-box → xt-flex-box}/index.js +0 -0
- /package/src/components/{flex-box → xt-flex-box}/index.vue +0 -0
- /package/src/components/{flex-box → xt-flex-box}/style/index.scss +0 -0
- /package/src/components/{grid-box → xt-grid-box}/index.js +0 -0
- /package/src/components/{grid-box → xt-grid-box}/index.vue +0 -0
- /package/src/components/{input → xt-input}/index.js +0 -0
- /package/src/components/{input → xt-input}/index.vue +0 -0
- /package/src/components/{input → xt-input}/style/index.scss +0 -0
- /package/src/components/{layout → xt-layout}/BaseCollapse.vue +0 -0
- /package/src/components/{layout → xt-layout}/ExFieldset.vue +0 -0
- /package/src/components/{page → xt-page}/index.js +0 -0
- /package/src/components/{page → xt-page}/index.vue +0 -0
- /package/src/components/{select-tree → xt-select-tree}/index.js +0 -0
- /package/src/components/{select-tree → xt-select-tree}/index.vue +0 -0
- /package/src/components/{table → xt-table}/ExCell.vue +0 -0
- /package/src/components/{table → xt-table}/ExColumn.vue +0 -0
- /package/src/components/{table → xt-table}/index.js +0 -0
- /package/src/components/{table → xt-table}/processor.js +0 -0
- /package/src/components/{text → xt-text}/index.js +0 -0
- /package/src/components/{text → xt-text}/index.vue +0 -0
- /package/src/components/{text → xt-text}/style/index.scss +0 -0
- /package/src/components/{upload → xt-upload}/index.js +0 -0
- /package/src/components/{upload → xt-upload}/index.vue +0 -0
- /package/src/components/{upload → xt-upload}/preview.vue +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// ExCard 组件样式
|
|
2
|
+
@import '../../../styles/variables.scss';
|
|
3
|
+
|
|
4
|
+
.ex-card {
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
transition: all 0.3s;
|
|
7
|
+
font-size: var(--ex-card-font-size, 14px);
|
|
8
|
+
|
|
9
|
+
.el-card__header {
|
|
10
|
+
padding: var(--ex-card-header-padding, 16px 20px);
|
|
11
|
+
border-bottom: 1px solid #ebeef5;
|
|
12
|
+
background-color: #fafafa;
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.el-card__body {
|
|
17
|
+
padding: var(--ex-card-body-padding, 20px);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ex-card-small {
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
|
|
24
|
+
.el-card__header {
|
|
25
|
+
font-size: 12px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ex-card-medium {
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
|
|
32
|
+
.el-card__header {
|
|
33
|
+
font-size: 14px;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ex-card-large {
|
|
38
|
+
font-size: 16px;
|
|
39
|
+
|
|
40
|
+
.el-card__header {
|
|
41
|
+
font-size: 16px;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.ex-card-always {
|
|
46
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.ex-card-hover {
|
|
50
|
+
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
|
51
|
+
|
|
52
|
+
&:hover {
|
|
53
|
+
box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.15);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.ex-card-never {
|
|
58
|
+
box-shadow: none;
|
|
59
|
+
border: 1px solid #ebeef5;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.ex-card-no-border {
|
|
63
|
+
border: none;
|
|
64
|
+
|
|
65
|
+
.el-card__header {
|
|
66
|
+
border-bottom: none;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ex-bar v-if="type=='bar'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-bar>
|
|
3
|
+
<ex-line v-else-if="type=='line'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-line>
|
|
4
|
+
<ex-pie v-else-if="type=='pie'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-pie>
|
|
5
|
+
<ex-multi v-else-if="type=='multi'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-multi>
|
|
6
|
+
<ex-trend v-else-if="type=='trend'" v-bind="$attrs" :theme="myTheme" :size="mySize"></ex-trend>
|
|
7
|
+
</template>
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
name: "ExChart",
|
|
11
|
+
components: {
|
|
12
|
+
ExBar: () => import("./ExBar.vue"),
|
|
13
|
+
ExLine: () => import("./ExLine.vue"),
|
|
14
|
+
ExPie: () => import("./ExPie.vue"),
|
|
15
|
+
ExMulti: () => import("./ExMulti.vue"),
|
|
16
|
+
ExTrend: () => import("./ExTrend.vue")
|
|
17
|
+
},
|
|
18
|
+
props: {
|
|
19
|
+
theme: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: ""
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "medium",
|
|
26
|
+
validator: (value) => {
|
|
27
|
+
return ['small', 'medium', 'large'].includes(value)
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
type: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
default: "bar"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
myTheme: this.theme,
|
|
39
|
+
mySize: this.size,
|
|
40
|
+
observer: null
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
mounted() {
|
|
44
|
+
// 初始化时检测父元素的 data-theme
|
|
45
|
+
this.detectParentTheme();
|
|
46
|
+
|
|
47
|
+
// 监听父元素的 data-theme 属性变化
|
|
48
|
+
this.observeThemeChange();
|
|
49
|
+
},
|
|
50
|
+
beforeUnmount() {
|
|
51
|
+
// 清理观察器
|
|
52
|
+
if (this.observer) {
|
|
53
|
+
this.observer.disconnect();
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
watch: {
|
|
57
|
+
theme(newVal) {
|
|
58
|
+
this.myTheme = newVal;
|
|
59
|
+
},
|
|
60
|
+
size(newVal) {
|
|
61
|
+
this.mySize = newVal;
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
methods: {
|
|
65
|
+
// 检测父元素的 data-theme 属性
|
|
66
|
+
detectParentTheme() {
|
|
67
|
+
if (this.theme) {
|
|
68
|
+
// 如果用户显式传入了 theme prop,使用传入的值
|
|
69
|
+
this.myTheme = this.theme;
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 查找最近的带有 data-theme 属性的父元素
|
|
74
|
+
let parent = this.$el ? this.$el.parentElement : null;
|
|
75
|
+
while (parent) {
|
|
76
|
+
const parentTheme = parent.getAttribute('data-theme');
|
|
77
|
+
if (parentTheme) {
|
|
78
|
+
this.myTheme = parentTheme === 'dark' ? 'dark' : 'default';
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
parent = parent.parentElement;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 如果没有找到,检查 document.body 或 document.documentElement
|
|
85
|
+
const bodyTheme = document.body.getAttribute('data-theme');
|
|
86
|
+
const htmlTheme = document.documentElement.getAttribute('data-theme');
|
|
87
|
+
if (bodyTheme === 'dark' || htmlTheme === 'dark') {
|
|
88
|
+
this.myTheme = 'dark';
|
|
89
|
+
} else {
|
|
90
|
+
this.myTheme = 'default';
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
// 监听主题变化
|
|
95
|
+
observeThemeChange() {
|
|
96
|
+
if (!this.$el) return;
|
|
97
|
+
|
|
98
|
+
// 创建 MutationObserver 监听父元素的属性变化
|
|
99
|
+
this.observer = new MutationObserver((mutations) => {
|
|
100
|
+
mutations.forEach((mutation) => {
|
|
101
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'data-theme') {
|
|
102
|
+
const newTheme = mutation.target.getAttribute('data-theme');
|
|
103
|
+
if (newTheme === 'dark') {
|
|
104
|
+
this.myTheme = 'dark';
|
|
105
|
+
} else if (newTheme === 'light') {
|
|
106
|
+
this.myTheme = 'default';
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// 监听当前元素和所有父元素的属性变化
|
|
113
|
+
let parent = this.$el.parentElement;
|
|
114
|
+
while (parent) {
|
|
115
|
+
this.observer.observe(parent, {
|
|
116
|
+
attributes: true,
|
|
117
|
+
attributeFilter: ['data-theme']
|
|
118
|
+
});
|
|
119
|
+
parent = parent.parentElement;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// 同时监听 body 和 html 的变化
|
|
123
|
+
this.observer.observe(document.body, {
|
|
124
|
+
attributes: true,
|
|
125
|
+
attributeFilter: ['data-theme']
|
|
126
|
+
});
|
|
127
|
+
this.observer.observe(document.documentElement, {
|
|
128
|
+
attributes: true,
|
|
129
|
+
attributeFilter: ['data-theme']
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
</script>
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as echarts from "echarts";
|
|
2
|
-
|
|
3
1
|
import themeWhite from "./theme/white";
|
|
4
2
|
import themeDark from "./theme/dark";
|
|
5
3
|
import themeBlue from "./theme/blue";
|
|
@@ -15,8 +13,22 @@ const themeKeys = {
|
|
|
15
13
|
"orange": themeOrange
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// echarts 仅在客户端加载,避免 SSR 编译/渲染报错
|
|
17
|
+
let echarts = null;
|
|
18
|
+
|
|
19
|
+
function getEcharts() {
|
|
20
|
+
if (!echarts && typeof window !== 'undefined') {
|
|
21
|
+
try {
|
|
22
|
+
echarts = require('echarts');
|
|
23
|
+
// 注册所有主题
|
|
24
|
+
for (const key in themeKeys) {
|
|
25
|
+
echarts.registerTheme(key, themeKeys[key]);
|
|
26
|
+
}
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.warn('[ExChart] echarts 加载失败:', e.message);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return echarts;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
34
|
// 字体大小配置
|
|
@@ -162,6 +174,10 @@ EchartsUtil.applyFontSize = function(themeOption, size) {
|
|
|
162
174
|
};
|
|
163
175
|
|
|
164
176
|
EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
177
|
+
const ec = getEcharts();
|
|
178
|
+
// SSR 环境下忽略初始化
|
|
179
|
+
if (!ec || !dom) return null;
|
|
180
|
+
|
|
165
181
|
theme = theme || "default";
|
|
166
182
|
size = size || "medium";
|
|
167
183
|
customOption = customOption || {};
|
|
@@ -178,7 +194,7 @@ EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
|
178
194
|
|
|
179
195
|
const option = this.mergeOptions(themeOption, customOption);
|
|
180
196
|
|
|
181
|
-
const chart =
|
|
197
|
+
const chart = ec.init(dom, useTheme);
|
|
182
198
|
chart.setOption(option, true);
|
|
183
199
|
|
|
184
200
|
this.chartInstanceList.push({
|
|
@@ -193,7 +209,8 @@ EchartsUtil.init = function(dom, theme, customOption, size) {
|
|
|
193
209
|
};
|
|
194
210
|
|
|
195
211
|
EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme) {
|
|
196
|
-
|
|
212
|
+
const ec = getEcharts();
|
|
213
|
+
if (!ec || !dom || !chartIns) return;
|
|
197
214
|
|
|
198
215
|
customOption = customOption || {};
|
|
199
216
|
newTheme = newTheme || "default";
|
|
@@ -201,7 +218,7 @@ EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme)
|
|
|
201
218
|
this.currentTheme = newTheme;
|
|
202
219
|
chartIns.dispose();
|
|
203
220
|
|
|
204
|
-
const newChart =
|
|
221
|
+
const newChart = ec.init(dom, newTheme, customOption);
|
|
205
222
|
|
|
206
223
|
const item = this.chartInstanceList.find(function(v) {
|
|
207
224
|
return v.dom === dom;
|
|
@@ -214,26 +231,37 @@ EchartsUtil.changeSingleTheme = function(dom, chartIns, customOption, newTheme)
|
|
|
214
231
|
return newChart;
|
|
215
232
|
};
|
|
216
233
|
|
|
217
|
-
EchartsUtil.changeAllTheme = function(newTheme) {
|
|
218
|
-
|
|
234
|
+
EchartsUtil.changeAllTheme = function(newTheme, newSize) {
|
|
235
|
+
const ec = getEcharts();
|
|
236
|
+
if (!ec || !newTheme) return;
|
|
219
237
|
|
|
220
238
|
this.currentTheme = newTheme;
|
|
239
|
+
// 如果传入了新的 size,则更新全局 size
|
|
240
|
+
if (newSize) {
|
|
241
|
+
this.currentSize = newSize;
|
|
242
|
+
}
|
|
221
243
|
|
|
222
244
|
this.chartInstanceList.forEach(function(item) {
|
|
223
245
|
const dom = item.dom;
|
|
224
246
|
const chart = item.chart;
|
|
225
247
|
const customOption = item.customOption;
|
|
248
|
+
// 使用图表自己的 size,如果没有则使用全局 size
|
|
249
|
+
const useSize = item.size || EchartsUtil.currentSize;
|
|
226
250
|
|
|
227
251
|
if (chart) {
|
|
228
252
|
chart.dispose();
|
|
229
253
|
}
|
|
230
254
|
|
|
231
|
-
const newChart =
|
|
232
|
-
|
|
255
|
+
const newChart = ec.init(dom, newTheme);
|
|
256
|
+
let themeOption = themeKeys[newTheme];
|
|
257
|
+
// 应用字体大小配置
|
|
258
|
+
themeOption = EchartsUtil.applyFontSize(themeOption, useSize);
|
|
233
259
|
const option = EchartsUtil.mergeOptions(themeOption, customOption);
|
|
234
260
|
|
|
235
261
|
newChart.setOption(option, true);
|
|
236
262
|
item.chart = newChart;
|
|
263
|
+
// 更新图表的 size 记录
|
|
264
|
+
item.size = useSize;
|
|
237
265
|
EchartsUtil.bindResize(newChart);
|
|
238
266
|
});
|
|
239
267
|
};
|
|
@@ -270,4 +298,4 @@ EchartsUtil.destroyAll = function() {
|
|
|
270
298
|
|
|
271
299
|
export default EchartsUtil;
|
|
272
300
|
|
|
273
|
-
export {
|
|
301
|
+
export { getEcharts };
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
// 组件样式统一入口文件
|
|
2
2
|
|
|
3
3
|
// Button 组件样式
|
|
4
|
-
@import './button/style/index.scss';
|
|
4
|
+
@import './xt-button/style/index.scss';
|
|
5
5
|
|
|
6
6
|
// Card 组件样式
|
|
7
|
-
@import './card/style/index.scss';
|
|
7
|
+
@import './xt-card/style/index.scss';
|
|
8
8
|
|
|
9
9
|
// CardItem 组件样式
|
|
10
|
-
@import './card-item/style/index.scss';
|
|
10
|
+
@import './xt-card-item/style/index.scss';
|
|
11
11
|
|
|
12
12
|
// Input 组件样式
|
|
13
|
-
@import './input/style/index.scss';
|
|
13
|
+
@import './xt-input/style/index.scss';
|
|
14
14
|
|
|
15
15
|
// FlexBox 组件样式
|
|
16
|
-
@import './flex-box/style/index.scss';
|
|
16
|
+
@import './xt-flex-box/style/index.scss';
|
|
17
17
|
|
|
18
18
|
// ConfigProvider 组件样式
|
|
19
|
-
@import './config-provider/style/index.scss';
|
|
19
|
+
@import './xt-config-provider/style/index.scss';
|
|
20
20
|
|
|
21
21
|
// Text 组件样式
|
|
22
|
-
@import './text/style/index.scss';
|
|
22
|
+
@import './xt-text/style/index.scss';
|
|
23
|
+
|
|
24
|
+
// ExButton 组件样式
|
|
25
|
+
@import './ex-button/style/index.scss';
|
|
26
|
+
|
|
27
|
+
// ExCard 组件样式
|
|
28
|
+
@import './ex-card/style/index.scss';
|
|
@@ -23,7 +23,7 @@ export default {
|
|
|
23
23
|
type: {
|
|
24
24
|
type: String,
|
|
25
25
|
default: '',
|
|
26
|
-
validator: (val) => ['primary', 'success', 'warning', 'danger'].includes(val)
|
|
26
|
+
validator: (val) => ['', 'primary', 'success', 'warning', 'danger'].includes(val)
|
|
27
27
|
},
|
|
28
28
|
size: {
|
|
29
29
|
type: String,
|
|
@@ -2,6 +2,38 @@
|
|
|
2
2
|
export default {
|
|
3
3
|
name: 'XtConfigProvider',
|
|
4
4
|
inheritAttrs: false,
|
|
5
|
+
provide() {
|
|
6
|
+
return {
|
|
7
|
+
xtConfig: {
|
|
8
|
+
theme: this.theme,
|
|
9
|
+
size: this.size,
|
|
10
|
+
primaryColor: this.primaryColor
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
watch: {
|
|
15
|
+
theme(newVal) {
|
|
16
|
+
this.$provide('xtConfig', {
|
|
17
|
+
theme: newVal,
|
|
18
|
+
size: this.size,
|
|
19
|
+
primaryColor: this.primaryColor
|
|
20
|
+
})
|
|
21
|
+
},
|
|
22
|
+
size(newVal) {
|
|
23
|
+
this.$provide('xtConfig', {
|
|
24
|
+
theme: this.theme,
|
|
25
|
+
size: newVal,
|
|
26
|
+
primaryColor: this.primaryColor
|
|
27
|
+
})
|
|
28
|
+
},
|
|
29
|
+
primaryColor(newVal) {
|
|
30
|
+
this.$provide('xtConfig', {
|
|
31
|
+
theme: this.theme,
|
|
32
|
+
size: this.size,
|
|
33
|
+
primaryColor: newVal
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
},
|
|
5
37
|
render(h) {
|
|
6
38
|
// Vue 2 不支持 Fragment,当 tag="template" 时需要特殊处理
|
|
7
39
|
// 如果设置了 proxyElement,则不渲染包裹元素,只渲染 slot 内容
|
|
@@ -77,6 +109,16 @@ export default {
|
|
|
77
109
|
type: [HTMLElement, String, Object],
|
|
78
110
|
default: null,
|
|
79
111
|
description: '代理元素,将样式应用到该元素上。支持 HTMLElement、CSS选择器字符串或 ref 对象'
|
|
112
|
+
},
|
|
113
|
+
onThemeChange: {
|
|
114
|
+
type: Function,
|
|
115
|
+
default: null,
|
|
116
|
+
description: '主题改变时的钩子函数,接收参数: { theme, size, primaryColor }'
|
|
117
|
+
},
|
|
118
|
+
onStyleApplied: {
|
|
119
|
+
type: Function,
|
|
120
|
+
default: null,
|
|
121
|
+
description: '样式应用完成时的钩子函数,接收参数: { element, style, theme }'
|
|
80
122
|
}
|
|
81
123
|
},
|
|
82
124
|
computed: {
|
|
@@ -257,13 +299,37 @@ export default {
|
|
|
257
299
|
if (!element) return
|
|
258
300
|
|
|
259
301
|
const style = this.mergedStyle
|
|
302
|
+
const prevTheme = element.getAttribute('data-theme')
|
|
260
303
|
|
|
304
|
+
// 应用样式到代理元素
|
|
261
305
|
for (const key in style) {
|
|
262
306
|
element.style.setProperty(key, style[key])
|
|
263
307
|
}
|
|
264
308
|
|
|
265
309
|
// 设置 data-theme 属性
|
|
266
310
|
element.setAttribute('data-theme', this.theme)
|
|
311
|
+
|
|
312
|
+
// 触发主题改变钩子(当主题实际发生变化时)
|
|
313
|
+
if (prevTheme !== this.theme && typeof this.onThemeChange === 'function') {
|
|
314
|
+
this.onThemeChange({
|
|
315
|
+
theme: this.theme,
|
|
316
|
+
size: this.size,
|
|
317
|
+
primaryColor: this.primaryColor,
|
|
318
|
+
prevTheme: prevTheme
|
|
319
|
+
})
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// 触发样式应用完成钩子
|
|
323
|
+
if (typeof this.onStyleApplied === 'function') {
|
|
324
|
+
this.onStyleApplied({
|
|
325
|
+
element: element,
|
|
326
|
+
style: style,
|
|
327
|
+
theme: this.theme,
|
|
328
|
+
size: this.size,
|
|
329
|
+
primaryColor: this.primaryColor
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
|
|
267
333
|
},
|
|
268
334
|
|
|
269
335
|
clearProxyElementStyle() {
|
|
@@ -17,7 +17,7 @@ const typeFormatEnum = {
|
|
|
17
17
|
datetime: "yyyy-MM-dd HH:mm", month: "yyyy-MM", year: "yyyy", date: "yyyy-MM-dd", quarter: "yyyy-Qq", week: "yyyy-WW"
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
import FlexBox from '../flex-box/index.vue'
|
|
20
|
+
import FlexBox from '../xt-flex-box/index.vue'
|
|
21
21
|
import Quarter from "./quarter.vue";
|
|
22
22
|
export default {
|
|
23
23
|
name: "XtDatePicker",
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
<template>
|
|
2
4
|
<el-popover v-model="popoverVisible" trigger="click" :disabled="disabled" transition="el-zoom-in-top" :placement="placement" :width="popoverWidth" @hide="handleBlur">
|
|
3
5
|
<div class="quarter-wrapper">
|
|
4
6
|
<BaseFlexBox content="between">
|
|
@@ -15,7 +17,7 @@
|
|
|
15
17
|
</template>
|
|
16
18
|
|
|
17
19
|
<script>
|
|
18
|
-
import BaseFlexBox from "../flex-box/index.vue";
|
|
20
|
+
import BaseFlexBox from "../xt-flex-box/index.vue";
|
|
19
21
|
import dateFns from "date-fns";
|
|
20
22
|
export default {
|
|
21
23
|
name: "DateQuarter",
|