xt-element-ui 1.0.0 → 1.0.2
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/fonts/element-icons.f1a45d74.ttf +0 -0
- package/lib/fonts/element-icons.ff18efd1.woff +0 -0
- package/lib/index.common.js +226 -23
- package/lib/index.css +1 -0
- package/lib/index.umd.js +272 -30
- package/lib/index.umd.min.js +1 -1
- package/package.json +16 -6
- package/src/components/button/index.js +2 -0
- package/src/components/button/index.vue +14 -0
- package/src/components/input/index.js +2 -0
- package/src/components/input/index.vue +20 -0
- package/src/index.js +141 -5
- package/src/components/Button.vue +0 -1
- package/src/components/Input.vue +0 -1
- package/vue.config.js +0 -41
package/lib/index.umd.js
CHANGED
|
@@ -1,19 +1,70 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory();
|
|
3
|
+
module.exports = factory(require("ElementUI"), require("Vue"));
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("xt-element-ui", [], factory);
|
|
5
|
+
define("xt-element-ui", ["ElementUI", "Vue"], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["xt-element-ui"] = factory();
|
|
7
|
+
exports["xt-element-ui"] = factory(require("ElementUI"), require("Vue"));
|
|
8
8
|
else
|
|
9
|
-
root["xt-element-ui"] = factory();
|
|
10
|
-
})((typeof self !== 'undefined' ? self : this), () => {
|
|
9
|
+
root["xt-element-ui"] = factory(root["ElementUI"], root["Vue"]);
|
|
10
|
+
})((typeof self !== 'undefined' ? self : this), (__WEBPACK_EXTERNAL_MODULE__282__, __WEBPACK_EXTERNAL_MODULE__508__) => {
|
|
11
11
|
return /******/ (() => { // webpackBootstrap
|
|
12
12
|
/******/ "use strict";
|
|
13
|
-
/******/
|
|
14
|
-
|
|
13
|
+
/******/ var __webpack_modules__ = ({
|
|
14
|
+
|
|
15
|
+
/***/ 282
|
|
16
|
+
(module) {
|
|
17
|
+
|
|
18
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__282__;
|
|
19
|
+
|
|
20
|
+
/***/ },
|
|
21
|
+
|
|
22
|
+
/***/ 508
|
|
23
|
+
(module) {
|
|
24
|
+
|
|
25
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__508__;
|
|
26
|
+
|
|
27
|
+
/***/ }
|
|
28
|
+
|
|
29
|
+
/******/ });
|
|
30
|
+
/************************************************************************/
|
|
31
|
+
/******/ // The module cache
|
|
32
|
+
/******/ var __webpack_module_cache__ = {};
|
|
33
|
+
/******/
|
|
34
|
+
/******/ // The require function
|
|
35
|
+
/******/ function __webpack_require__(moduleId) {
|
|
36
|
+
/******/ // Check if module is in cache
|
|
37
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
38
|
+
/******/ if (cachedModule !== undefined) {
|
|
39
|
+
/******/ return cachedModule.exports;
|
|
40
|
+
/******/ }
|
|
41
|
+
/******/ // Create a new module (and put it into the cache)
|
|
42
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
43
|
+
/******/ // no module.id needed
|
|
44
|
+
/******/ // no module.loaded needed
|
|
45
|
+
/******/ exports: {}
|
|
46
|
+
/******/ };
|
|
47
|
+
/******/
|
|
48
|
+
/******/ // Execute the module function
|
|
49
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
50
|
+
/******/
|
|
51
|
+
/******/ // Return the exports of the module
|
|
52
|
+
/******/ return module.exports;
|
|
53
|
+
/******/ }
|
|
15
54
|
/******/
|
|
16
55
|
/************************************************************************/
|
|
56
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
57
|
+
/******/ (() => {
|
|
58
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
59
|
+
/******/ __webpack_require__.n = (module) => {
|
|
60
|
+
/******/ var getter = module && module.__esModule ?
|
|
61
|
+
/******/ () => (module['default']) :
|
|
62
|
+
/******/ () => (module);
|
|
63
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
64
|
+
/******/ return getter;
|
|
65
|
+
/******/ };
|
|
66
|
+
/******/ })();
|
|
67
|
+
/******/
|
|
17
68
|
/******/ /* webpack/runtime/define property getters */
|
|
18
69
|
/******/ (() => {
|
|
19
70
|
/******/ // define getter functions for harmony exports
|
|
@@ -54,7 +105,19 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
54
105
|
|
|
55
106
|
// EXPORTS
|
|
56
107
|
__webpack_require__.d(__webpack_exports__, {
|
|
57
|
-
|
|
108
|
+
ElementUI: () => (/* reexport */ (external_ElementUI_default())),
|
|
109
|
+
Vue: () => (/* reexport */ (external_Vue_default())),
|
|
110
|
+
"default": () => (/* binding */ entry_lib),
|
|
111
|
+
getConfig: () => (/* reexport */ getConfig),
|
|
112
|
+
getPrimaryColor: () => (/* reexport */ getPrimaryColor),
|
|
113
|
+
getSize: () => (/* reexport */ getSize),
|
|
114
|
+
getTheme: () => (/* reexport */ getTheme),
|
|
115
|
+
onConfigChange: () => (/* reexport */ onConfigChange),
|
|
116
|
+
resetConfig: () => (/* reexport */ resetConfig),
|
|
117
|
+
setConfig: () => (/* reexport */ setConfig),
|
|
118
|
+
setPrimaryColor: () => (/* reexport */ setPrimaryColor),
|
|
119
|
+
setSize: () => (/* reexport */ setSize),
|
|
120
|
+
setTheme: () => (/* reexport */ setTheme)
|
|
58
121
|
});
|
|
59
122
|
|
|
60
123
|
;// ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
|
|
@@ -75,12 +138,32 @@ if (typeof window !== 'undefined') {
|
|
|
75
138
|
// Indicate to webpack that this file can be concatenated
|
|
76
139
|
/* harmony default export */ const setPublicPath = (null);
|
|
77
140
|
|
|
78
|
-
|
|
79
|
-
var
|
|
141
|
+
// EXTERNAL MODULE: external "Vue"
|
|
142
|
+
var external_Vue_ = __webpack_require__(508);
|
|
143
|
+
var external_Vue_default = /*#__PURE__*/__webpack_require__.n(external_Vue_);
|
|
144
|
+
// EXTERNAL MODULE: external "ElementUI"
|
|
145
|
+
var external_ElementUI_ = __webpack_require__(282);
|
|
146
|
+
var external_ElementUI_default = /*#__PURE__*/__webpack_require__.n(external_ElementUI_);
|
|
147
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/button/index.vue?vue&type=template&id=55650f2e
|
|
148
|
+
var render = function render(){var _vm=this,_c=_vm._self._c;return _c('el-button',{on:{"click":_vm.handleClick}},[_vm._v(_vm._s(_vm.text))])
|
|
80
149
|
}
|
|
81
150
|
var staticRenderFns = []
|
|
82
151
|
|
|
83
152
|
|
|
153
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/button/index.vue?vue&type=script&lang=js
|
|
154
|
+
|
|
155
|
+
/* harmony default export */ const buttonvue_type_script_lang_js = ({
|
|
156
|
+
props:['text'],
|
|
157
|
+
name: 'XtButton',
|
|
158
|
+
methods:{
|
|
159
|
+
handleClick(){
|
|
160
|
+
this.$emit('click')
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
;// ./src/components/button/index.vue?vue&type=script&lang=js
|
|
166
|
+
/* harmony default export */ const components_buttonvue_type_script_lang_js = (buttonvue_type_script_lang_js);
|
|
84
167
|
;// ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
|
|
85
168
|
/* globals __VUE_SSR_CONTEXT__ */
|
|
86
169
|
|
|
@@ -179,15 +262,16 @@ function normalizeComponent(
|
|
|
179
262
|
}
|
|
180
263
|
}
|
|
181
264
|
|
|
182
|
-
;// ./src/components/
|
|
265
|
+
;// ./src/components/button/index.vue
|
|
266
|
+
|
|
267
|
+
|
|
183
268
|
|
|
184
|
-
var script = {}
|
|
185
269
|
|
|
186
270
|
|
|
187
271
|
/* normalize component */
|
|
188
272
|
;
|
|
189
273
|
var component = normalizeComponent(
|
|
190
|
-
|
|
274
|
+
components_buttonvue_type_script_lang_js,
|
|
191
275
|
render,
|
|
192
276
|
staticRenderFns,
|
|
193
277
|
false,
|
|
@@ -197,24 +281,43 @@ var component = normalizeComponent(
|
|
|
197
281
|
|
|
198
282
|
)
|
|
199
283
|
|
|
200
|
-
/* harmony default export */ const
|
|
201
|
-
;// ./
|
|
202
|
-
|
|
284
|
+
/* harmony default export */ const components_button = (component.exports);
|
|
285
|
+
;// ./src/components/button/index.js
|
|
286
|
+
|
|
287
|
+
/* harmony default export */ const src_components_button = (components_button);
|
|
288
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[2]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/input/index.vue?vue&type=template&id=fe9146e4
|
|
289
|
+
var inputvue_type_template_id_fe9146e4_render = function render(){var _vm=this,_c=_vm._self._c;return _c('el-input',{attrs:{"value":_vm.value,"placeholder":_vm.placeholder},on:{"input":function($event){return _vm.$emit('input', $event)}}})
|
|
203
290
|
}
|
|
204
|
-
var
|
|
291
|
+
var inputvue_type_template_id_fe9146e4_staticRenderFns = []
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
;// ./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/input/index.vue?vue&type=script&lang=js
|
|
295
|
+
|
|
296
|
+
/* harmony default export */ const inputvue_type_script_lang_js = ({
|
|
297
|
+
name: 'XtInput',
|
|
298
|
+
props: {
|
|
299
|
+
value: [String, Number],
|
|
300
|
+
placeholder: {
|
|
301
|
+
type: String,
|
|
302
|
+
default: '请输入内容'
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
;// ./src/components/input/index.vue?vue&type=script&lang=js
|
|
308
|
+
/* harmony default export */ const components_inputvue_type_script_lang_js = (inputvue_type_script_lang_js);
|
|
309
|
+
;// ./src/components/input/index.vue
|
|
205
310
|
|
|
206
311
|
|
|
207
|
-
;// ./src/components/Input.vue
|
|
208
312
|
|
|
209
|
-
var Input_script = {}
|
|
210
313
|
|
|
211
314
|
|
|
212
315
|
/* normalize component */
|
|
213
316
|
;
|
|
214
|
-
var
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
317
|
+
var input_component = normalizeComponent(
|
|
318
|
+
components_inputvue_type_script_lang_js,
|
|
319
|
+
inputvue_type_template_id_fe9146e4_render,
|
|
320
|
+
inputvue_type_template_id_fe9146e4_staticRenderFns,
|
|
218
321
|
false,
|
|
219
322
|
null,
|
|
220
323
|
null,
|
|
@@ -222,17 +325,31 @@ var Input_component = normalizeComponent(
|
|
|
222
325
|
|
|
223
326
|
)
|
|
224
327
|
|
|
225
|
-
/* harmony default export */ const
|
|
328
|
+
/* harmony default export */ const input = (input_component.exports);
|
|
329
|
+
;// ./src/components/input/index.js
|
|
330
|
+
|
|
331
|
+
/* harmony default export */ const components_input = (input);
|
|
226
332
|
;// ./src/index.js
|
|
333
|
+
// 导入 Vue
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
// 在导入 Element UI 之前,先将 Vue 设置为全局变量
|
|
337
|
+
if (typeof window !== 'undefined') {
|
|
338
|
+
window.Vue = (external_Vue_default())
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 导入 Element UI 并注册
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
227
345
|
// 导入组件
|
|
228
346
|
|
|
229
347
|
|
|
230
|
-
// ...其他组件
|
|
231
348
|
|
|
232
349
|
// 存储组件列表
|
|
233
350
|
const components = [
|
|
234
|
-
|
|
235
|
-
|
|
351
|
+
src_components_button,
|
|
352
|
+
components_input
|
|
236
353
|
]
|
|
237
354
|
|
|
238
355
|
// 定义 install 方法,Vue.use() 会自动调用
|
|
@@ -240,7 +357,10 @@ const install = function (Vue) {
|
|
|
240
357
|
if (install.installed) return
|
|
241
358
|
install.installed = true
|
|
242
359
|
|
|
243
|
-
//
|
|
360
|
+
// 注册 Element UI
|
|
361
|
+
Vue.use((external_ElementUI_default()))
|
|
362
|
+
|
|
363
|
+
// 全局注册所有 xt- 组件
|
|
244
364
|
components.forEach(component => {
|
|
245
365
|
Vue.component(component.name, component)
|
|
246
366
|
})
|
|
@@ -255,9 +375,131 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
255
375
|
/* harmony default export */ const src_0 = ({
|
|
256
376
|
install,
|
|
257
377
|
// 按需导出组件
|
|
258
|
-
Button:
|
|
259
|
-
Input:
|
|
378
|
+
Button: src_components_button,
|
|
379
|
+
Input: components_input,
|
|
380
|
+
// 导出 ElementUI 以便用户按需引入
|
|
381
|
+
ElementUI: (external_ElementUI_default())
|
|
260
382
|
});
|
|
383
|
+
|
|
384
|
+
// 导出 Vue 和 ElementUI 以便用户使用
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
// 默认配置
|
|
388
|
+
const defaultConfig = {
|
|
389
|
+
theme: 'light',
|
|
390
|
+
size: 'medium',
|
|
391
|
+
primaryColor: '#1890ff'
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// 当前配置
|
|
395
|
+
let currentConfig = { ...defaultConfig }
|
|
396
|
+
|
|
397
|
+
// 配置变更事件处理
|
|
398
|
+
const configChangeListeners = []
|
|
399
|
+
|
|
400
|
+
const emitConfigChange = function(key, value) {
|
|
401
|
+
configChangeListeners.forEach(listener => {
|
|
402
|
+
listener(key, value)
|
|
403
|
+
})
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// 获取所有配置
|
|
407
|
+
const getConfig = function() {
|
|
408
|
+
return { ...currentConfig }
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// 设置全局配置
|
|
412
|
+
const setConfig = function(config) {
|
|
413
|
+
if (typeof config !== 'object' || config === null) {
|
|
414
|
+
console.warn('[XtElementUI] setConfig 必须传入对象参数')
|
|
415
|
+
return
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
if (config.theme !== undefined) {
|
|
419
|
+
setTheme(config.theme)
|
|
420
|
+
}
|
|
421
|
+
if (config.size !== undefined) {
|
|
422
|
+
setSize(config.size)
|
|
423
|
+
}
|
|
424
|
+
if (config.primaryColor !== undefined) {
|
|
425
|
+
setPrimaryColor(config.primaryColor)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// 设置主题
|
|
430
|
+
const setTheme = function(theme) {
|
|
431
|
+
const validThemes = ['light', 'dark', 'compact']
|
|
432
|
+
if (!validThemes.includes(theme)) {
|
|
433
|
+
console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
|
|
434
|
+
return
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
currentConfig.theme = theme
|
|
438
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
439
|
+
emitConfigChange('theme', theme)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// 设置字体大小
|
|
443
|
+
const setSize = function(size) {
|
|
444
|
+
const validSizes = ['small', 'medium', 'large']
|
|
445
|
+
if (!validSizes.includes(size)) {
|
|
446
|
+
console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
|
|
447
|
+
return
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
currentConfig.size = size
|
|
451
|
+
document.documentElement.setAttribute('data-size', size)
|
|
452
|
+
emitConfigChange('size', size)
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// 设置主色调
|
|
456
|
+
const setPrimaryColor = function(color) {
|
|
457
|
+
// 简单的颜色格式验证
|
|
458
|
+
const colorRegex = /^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/
|
|
459
|
+
if (!colorRegex.test(color)) {
|
|
460
|
+
console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
|
|
461
|
+
return
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
currentConfig.primaryColor = color
|
|
465
|
+
document.documentElement.style.setProperty('--xt-color-primary', color)
|
|
466
|
+
emitConfigChange('primaryColor', color)
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// 获取当前主题
|
|
470
|
+
const getTheme = function() {
|
|
471
|
+
return currentConfig.theme
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
// 获取当前字体大小
|
|
475
|
+
const getSize = function() {
|
|
476
|
+
return currentConfig.size
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// 获取当前主色调
|
|
480
|
+
const getPrimaryColor = function() {
|
|
481
|
+
return currentConfig.primaryColor
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// 重置为默认配置
|
|
485
|
+
const resetConfig = function() {
|
|
486
|
+
setConfig(defaultConfig)
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// 监听配置变更
|
|
490
|
+
const onConfigChange = function(listener) {
|
|
491
|
+
if (typeof listener === 'function') {
|
|
492
|
+
configChangeListeners.push(listener)
|
|
493
|
+
return function() {
|
|
494
|
+
const index = configChangeListeners.indexOf(listener)
|
|
495
|
+
if (index > -1) {
|
|
496
|
+
configChangeListeners.splice(index, 1)
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
} else {
|
|
500
|
+
console.warn('[XtElementUI] onConfigChange 必须传入函数')
|
|
501
|
+
}
|
|
502
|
+
}
|
|
261
503
|
;// ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
|
|
262
504
|
|
|
263
505
|
|
package/lib/index.umd.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define("xt-element-ui",[],t):"object"===typeof exports?exports["xt-element-ui"]=t():e["xt-element-ui"]=t()})("undefined"!==typeof self?self:this,()=>(()=>{"use strict";var e={};(()=>{e.d
|
|
1
|
+
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t(require("ElementUI"),require("Vue")):"function"===typeof define&&define.amd?define("xt-element-ui",["ElementUI","Vue"],t):"object"===typeof exports?exports["xt-element-ui"]=t(require("ElementUI"),require("Vue")):e["xt-element-ui"]=t(e["ElementUI"],e["Vue"])})("undefined"!==typeof self?self:this,(e,t)=>(()=>{"use strict";var n={282(t){t.exports=e},508(e){e.exports=t}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={exports:{}};return n[e](i,i.exports,r),i.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e["default"]:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{r.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})(),(()=>{r.p=""})();var i={};if(r.r(i),r.d(i,{ElementUI:()=>f(),Vue:()=>c(),default:()=>D,getConfig:()=>T,getPrimaryColor:()=>M,getSize:()=>F,getTheme:()=>A,onConfigChange:()=>B,resetConfig:()=>N,setConfig:()=>P,setPrimaryColor:()=>q,setSize:()=>R,setTheme:()=>k}),"undefined"!==typeof window){var l=window.document.currentScript,u=l&&l.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);u&&(r.p=u[1])}var s=r(508),c=r.n(s),a=r(282),f=r.n(a),d=function(){var e=this,t=e._self._c;return t("el-button",{on:{click:e.handleClick}},[e._v(e._s(e.text))])},p=[];const m={props:["text"],name:"XtButton",methods:{handleClick(){this.$emit("click")}}},h=m;function y(e,t,n,o,r,i,l,u){var s,c="function"===typeof e?e.options:e;if(t&&(c.render=t,c.staticRenderFns=n,c._compiled=!0),o&&(c.functional=!0),i&&(c._scopeId="data-v-"+i),l?(s=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"===typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(l)},c._ssrRegister=s):r&&(s=u?function(){r.call(this,(c.functional?this.parent:this).$root.$options.shadowRoot)}:r),s)if(c.functional){c._injectStyles=s;var a=c.render;c.render=function(e,t){return s.call(t),a(e,t)}}else{var f=c.beforeCreate;c.beforeCreate=f?[].concat(f,s):[s]}return{exports:e,options:c}}var v=y(h,d,p,!1,null,null,null);const _=v.exports,C=_;var g=function(){var e=this,t=e._self._c;return t("el-input",{attrs:{value:e.value,placeholder:e.placeholder},on:{input:function(t){return e.$emit("input",t)}}})},x=[];const w={name:"XtInput",props:{value:[String,Number],placeholder:{type:String,default:"请输入内容"}}},E=w;var b=y(E,g,x,!1,null,null,null);const $=b.exports,S=$;"undefined"!==typeof window&&(window.Vue=c());const I=[C,S],U=function(e){U.installed||(U.installed=!0,e.use(f()),I.forEach(t=>{e.component(t.name,t)}))};"undefined"!==typeof window&&window.Vue&&U(window.Vue);const j={install:U,Button:C,Input:S,ElementUI:f()},V={theme:"light",size:"medium",primaryColor:"#1890ff"};let z={...V};const X=[],O=function(e,t){X.forEach(n=>{n(e,t)})},T=function(){return{...z}},P=function(e){"object"===typeof e&&null!==e?(void 0!==e.theme&&k(e.theme),void 0!==e.size&&R(e.size),void 0!==e.primaryColor&&q(e.primaryColor)):console.warn("[XtElementUI] setConfig 必须传入对象参数")},k=function(e){const t=["light","dark","compact"];t.includes(e)?(z.theme=e,document.documentElement.setAttribute("data-theme",e),O("theme",e)):console.warn(`[XtElementUI] 无效的主题值: ${e},可选值: ${t.join(", ")}`)},R=function(e){const t=["small","medium","large"];t.includes(e)?(z.size=e,document.documentElement.setAttribute("data-size",e),O("size",e)):console.warn(`[XtElementUI] 无效的大小值: ${e},可选值: ${t.join(", ")}`)},q=function(e){const t=/^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/;t.test(e)?(z.primaryColor=e,document.documentElement.style.setProperty("--xt-color-primary",e),O("primaryColor",e)):console.warn(`[XtElementUI] 无效的颜色值: ${e},请使用十六进制颜色格式,如 #1890ff`)},A=function(){return z.theme},F=function(){return z.size},M=function(){return z.primaryColor},N=function(){P(V)},B=function(e){if("function"===typeof e)return X.push(e),function(){const t=X.indexOf(e);t>-1&&X.splice(t,1)};console.warn("[XtElementUI] onConfigChange 必须传入函数")},D=j;return i})());
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xt-element-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "基于 Vue2.7 + ElementUI 的组件库",
|
|
5
|
-
"main": "lib/index.js",
|
|
5
|
+
"main": "lib/index.common.js",
|
|
6
|
+
"module": "lib/index.common.js",
|
|
7
|
+
"unpkg": "lib/index.umd.min.js",
|
|
6
8
|
"style": "lib/index.css",
|
|
7
9
|
"scripts": {
|
|
8
10
|
"docs:dev": "vuepress dev docs",
|
|
9
11
|
"docs:build": "vuepress build docs",
|
|
10
|
-
"
|
|
12
|
+
"dev": "vue-cli-service serve",
|
|
13
|
+
"lib": "vue-cli-service build --target lib --name index --dest lib src/index.js",
|
|
14
|
+
"prepublishOnly": "npm run lib"
|
|
11
15
|
},
|
|
12
16
|
"keywords": [
|
|
13
17
|
"vue2",
|
|
@@ -24,6 +28,12 @@
|
|
|
24
28
|
"devDependencies": {
|
|
25
29
|
"@vue/cli-service": "^5.0.9",
|
|
26
30
|
"sass": "^1.32.13",
|
|
27
|
-
"sass-loader": "^10.5.2"
|
|
28
|
-
|
|
29
|
-
}
|
|
31
|
+
"sass-loader": "^10.5.2",
|
|
32
|
+
"vuepress": "^1.9.10"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib",
|
|
36
|
+
"src",
|
|
37
|
+
"README.md"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-input
|
|
3
|
+
:value="value"
|
|
4
|
+
:placeholder="placeholder"
|
|
5
|
+
@input="$emit('input', $event)"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: 'XtInput',
|
|
12
|
+
props: {
|
|
13
|
+
value: [String, Number],
|
|
14
|
+
placeholder: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: '请输入内容'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
// 导入 Vue
|
|
2
|
+
import Vue from 'vue'
|
|
3
|
+
|
|
4
|
+
// 在导入 Element UI 之前,先将 Vue 设置为全局变量
|
|
5
|
+
if (typeof window !== 'undefined') {
|
|
6
|
+
window.Vue = Vue
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 导入 Element UI 并注册
|
|
10
|
+
import ElementUI from 'element-ui'
|
|
11
|
+
import 'element-ui/lib/theme-chalk/index.css'
|
|
12
|
+
|
|
1
13
|
// 导入组件
|
|
2
|
-
import Button from './components/
|
|
3
|
-
import Input from './components/
|
|
4
|
-
// ...其他组件
|
|
14
|
+
import Button from './components/button'
|
|
15
|
+
import Input from './components/input'
|
|
5
16
|
|
|
6
17
|
// 存储组件列表
|
|
7
18
|
const components = [
|
|
@@ -14,7 +25,10 @@ const install = function (Vue) {
|
|
|
14
25
|
if (install.installed) return
|
|
15
26
|
install.installed = true
|
|
16
27
|
|
|
17
|
-
//
|
|
28
|
+
// 注册 Element UI
|
|
29
|
+
Vue.use(ElementUI)
|
|
30
|
+
|
|
31
|
+
// 全局注册所有 xt- 组件
|
|
18
32
|
components.forEach(component => {
|
|
19
33
|
Vue.component(component.name, component)
|
|
20
34
|
})
|
|
@@ -30,5 +44,127 @@ export default {
|
|
|
30
44
|
install,
|
|
31
45
|
// 按需导出组件
|
|
32
46
|
Button,
|
|
33
|
-
Input
|
|
47
|
+
Input,
|
|
48
|
+
// 导出 ElementUI 以便用户按需引入
|
|
49
|
+
ElementUI
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 导出 Vue 和 ElementUI 以便用户使用
|
|
53
|
+
export { Vue, ElementUI }
|
|
54
|
+
|
|
55
|
+
// 默认配置
|
|
56
|
+
const defaultConfig = {
|
|
57
|
+
theme: 'light',
|
|
58
|
+
size: 'medium',
|
|
59
|
+
primaryColor: '#1890ff'
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 当前配置
|
|
63
|
+
let currentConfig = { ...defaultConfig }
|
|
64
|
+
|
|
65
|
+
// 配置变更事件处理
|
|
66
|
+
const configChangeListeners = []
|
|
67
|
+
|
|
68
|
+
const emitConfigChange = function(key, value) {
|
|
69
|
+
configChangeListeners.forEach(listener => {
|
|
70
|
+
listener(key, value)
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// 获取所有配置
|
|
75
|
+
export const getConfig = function() {
|
|
76
|
+
return { ...currentConfig }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// 设置全局配置
|
|
80
|
+
export const setConfig = function(config) {
|
|
81
|
+
if (typeof config !== 'object' || config === null) {
|
|
82
|
+
console.warn('[XtElementUI] setConfig 必须传入对象参数')
|
|
83
|
+
return
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (config.theme !== undefined) {
|
|
87
|
+
setTheme(config.theme)
|
|
88
|
+
}
|
|
89
|
+
if (config.size !== undefined) {
|
|
90
|
+
setSize(config.size)
|
|
91
|
+
}
|
|
92
|
+
if (config.primaryColor !== undefined) {
|
|
93
|
+
setPrimaryColor(config.primaryColor)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 设置主题
|
|
98
|
+
export const setTheme = function(theme) {
|
|
99
|
+
const validThemes = ['light', 'dark', 'compact']
|
|
100
|
+
if (!validThemes.includes(theme)) {
|
|
101
|
+
console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
currentConfig.theme = theme
|
|
106
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
107
|
+
emitConfigChange('theme', theme)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 设置字体大小
|
|
111
|
+
export const setSize = function(size) {
|
|
112
|
+
const validSizes = ['small', 'medium', 'large']
|
|
113
|
+
if (!validSizes.includes(size)) {
|
|
114
|
+
console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
currentConfig.size = size
|
|
119
|
+
document.documentElement.setAttribute('data-size', size)
|
|
120
|
+
emitConfigChange('size', size)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// 设置主色调
|
|
124
|
+
export const setPrimaryColor = function(color) {
|
|
125
|
+
// 简单的颜色格式验证
|
|
126
|
+
const colorRegex = /^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/
|
|
127
|
+
if (!colorRegex.test(color)) {
|
|
128
|
+
console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
currentConfig.primaryColor = color
|
|
133
|
+
document.documentElement.style.setProperty('--xt-color-primary', color)
|
|
134
|
+
emitConfigChange('primaryColor', color)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// 获取当前主题
|
|
138
|
+
export const getTheme = function() {
|
|
139
|
+
return currentConfig.theme
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 获取当前字体大小
|
|
143
|
+
export const getSize = function() {
|
|
144
|
+
return currentConfig.size
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 获取当前主色调
|
|
148
|
+
export const getPrimaryColor = function() {
|
|
149
|
+
return currentConfig.primaryColor
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 重置为默认配置
|
|
153
|
+
export const resetConfig = function() {
|
|
154
|
+
setConfig(defaultConfig)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 监听配置变更
|
|
158
|
+
export const onConfigChange = function(listener) {
|
|
159
|
+
if (typeof listener === 'function') {
|
|
160
|
+
configChangeListeners.push(listener)
|
|
161
|
+
return function() {
|
|
162
|
+
const index = configChangeListeners.indexOf(listener)
|
|
163
|
+
if (index > -1) {
|
|
164
|
+
configChangeListeners.splice(index, 1)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
console.warn('[XtElementUI] onConfigChange 必须传入函数')
|
|
169
|
+
}
|
|
34
170
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template><el-button>按钮</el-button></template>
|
package/src/components/Input.vue
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<template><el-input></el-input></template>
|