xt-element-ui 1.0.8 → 1.1.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.
Files changed (41) hide show
  1. package/lib/index.common.js +715 -396
  2. package/lib/index.css +1 -1
  3. package/lib/index.umd.js +715 -396
  4. package/lib/index.umd.min.js +1 -1
  5. package/package.json +2 -2
  6. package/src/components/button/index.vue +54 -15
  7. package/src/components/button/style/index copy.scss +221 -0
  8. package/src/components/button/style/index.scss +136 -0
  9. package/src/components/card/index.vue +20 -41
  10. package/src/components/card/style/index.scss +49 -0
  11. package/src/components/card-item/index.vue +71 -90
  12. package/src/components/card-item/style/index.scss +72 -0
  13. package/src/components/config-provider/index.js +2 -0
  14. package/src/components/config-provider/index.vue +193 -0
  15. package/src/components/config-provider/style/index.scss +12 -0
  16. package/src/components/flex-box/index.vue +20 -90
  17. package/src/components/flex-box/style/index.scss +91 -0
  18. package/src/components/index.scss +22 -0
  19. package/src/components/input/index.vue +28 -11
  20. package/src/components/input/style/index.scss +27 -0
  21. package/src/components/text/index.js +2 -0
  22. package/src/components/text/index.vue +42 -0
  23. package/src/components/text/style/index.scss +45 -0
  24. package/src/index.js +69 -123
  25. package/src/styles/{theme.scss → css-variables.scss} +72 -31
  26. package/src/styles/{theme-element.scss → element-theme.scss} +0 -10
  27. package/src/styles/theme/background.scss +6 -0
  28. package/src/styles/theme/border-radius.scss +4 -0
  29. package/src/styles/theme/borders.scss +4 -0
  30. package/src/styles/theme/colors.scss +11 -0
  31. package/src/styles/theme/component-variables.scss +70 -0
  32. package/src/styles/theme/dark-variables.scss +29 -0
  33. package/src/styles/theme/font.scss +10 -0
  34. package/src/styles/theme/index.scss +11 -0
  35. package/src/styles/theme/shadows.scss +3 -0
  36. package/src/styles/theme/spacing.scss +5 -0
  37. package/src/styles/theme/transitions.scss +3 -0
  38. package/src/styles/theme/typography.scss +5 -0
  39. package/src/styles/{export.scss → variables-export.scss} +1 -1
  40. package/src/styles/variables.scss +1 -126
  41. package/src/utils/index.js +193 -124
@@ -0,0 +1,10 @@
1
+ $xt-font-size-extra-large: 20px; // 特大字体基础值
2
+ $xt-font-size-large: 18px; // 大字体基础值
3
+ $xt-font-size-medium: 16px; // 中等字体基础值
4
+ $xt-font-size-base: 14px; // 基准字体 - Element UI 默认
5
+ $xt-font-size-small: 13px; // 小字体基础值
6
+ $xt-font-size-extra-small: 12px; // 特小字体基础值
7
+
8
+ $xt-font-size-increment-small: 0px; // 小尺寸增量
9
+ $xt-font-size-increment-medium: 2px; // 中尺寸增量
10
+ $xt-font-size-increment-large: 4px; // 大尺寸增量
@@ -0,0 +1,11 @@
1
+ @import './colors.scss';
2
+ @import './typography.scss';
3
+ @import './background.scss';
4
+ @import './borders.scss';
5
+ @import './font.scss';
6
+ @import './spacing.scss';
7
+ @import './border-radius.scss';
8
+ @import './shadows.scss';
9
+ @import './transitions.scss';
10
+ @import './dark-variables.scss';
11
+ @import './component-variables.scss';
@@ -0,0 +1,3 @@
1
+ $xt-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04); // 小阴影
2
+ $xt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08); // 中等阴影
3
+ $xt-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12); // 大阴影
@@ -0,0 +1,5 @@
1
+ $xt-spacing-xs: 4px; // 最小间距
2
+ $xt-spacing-sm: 8px; // 小间距
3
+ $xt-spacing-md: 12px; // 中间距
4
+ $xt-spacing-lg: 16px; // 大间距
5
+ $xt-spacing-xl: 20px; // 特大间距
@@ -0,0 +1,3 @@
1
+ $xt-transition-duration: 0.3s; // 默认过渡时长
2
+ $xt-transition-duration-fast: 0.2s; // 快速过渡时长
3
+ $xt-transition-ease: ease; // 缓动函数
@@ -0,0 +1,5 @@
1
+ $xt-color-text-primary: #303133; // 主要文字颜色 - 最深
2
+ $xt-color-text-regular: #606266; // 常规文字颜色 - 中等
3
+ $xt-color-text-secondary: #909399; // 次要文字颜色 - 较浅
4
+ $xt-color-text-placeholder: #C0C4CC; // 占位符文字颜色
5
+ $xt-color-text-disabled: #C0C4CC; // 禁用状态文字颜色
@@ -1,4 +1,4 @@
1
- @use './variables.scss' as *;
1
+ @import './theme/index.scss';
2
2
 
3
3
  // SCSS 变量导出给 JavaScript 使用
4
4
  :export {
@@ -1,126 +1 @@
1
- // ===========================
2
- // Element UI 标准颜色变量
3
- // ===========================
4
-
5
- // 主色调系列
6
- $xt-color-primary: #409EFF; // 主颜色 - Element UI 标准蓝色
7
- $xt-color-success: #67C23A; // 成功色 - Element UI 标准绿色
8
- $xt-color-warning: #E6A23C; // 警告色 - Element UI 标准橙色
9
- $xt-color-danger: #F56C6C; // 危险色 - Element UI 标准红色
10
- $xt-color-info: #909399; // 信息色 - Element UI 标准灰色
11
-
12
- // 主色调浅色系列(用于 hover、active 等状态)
13
- $xt-color-primary-light-3: #79BBFF; // 主色浅色 30%
14
- $xt-color-primary-light-5: #A0CFFF; // 主色浅色 50%
15
- $xt-color-primary-light-7: #C6E2FF; // 主色浅色 70%
16
- $xt-color-primary-light-8: #D9ECFF; // 主色浅色 80%
17
- $xt-color-primary-light-9: #ECF5FF; // 主色浅色 90%
18
-
19
- // ===========================
20
- // 文字颜色
21
- // ===========================
22
- $xt-color-text-primary: #303133; // 主要文字颜色 - 最深
23
- $xt-color-text-regular: #606266; // 常规文字颜色 - 中等
24
- $xt-color-text-secondary: #909399; // 次要文字颜色 - 较浅
25
- $xt-color-text-placeholder: #C0C4CC; // 占位符文字颜色
26
- $xt-color-text-disabled: #C0C4CC; // 禁用状态文字颜色
27
-
28
- // ===========================
29
- // 背景颜色
30
- // ===========================
31
- $xt-color-bg-primary: #ffffff; // 主背景色 - 白色
32
- $xt-color-bg-secondary: #f5f7fa; // 次要背景色 - 浅灰
33
- $xt-color-bg-hover: #f5f5f5; // 悬停背景色
34
- $xt-color-bg-container: #f5f7fa; // 容器背景色
35
- $xt-color-bg-main: #ffffff; // 主内容区域背景色
36
- $xt-color-bg-overlay: #ffffff; // 浮层背景色
37
-
38
- // ===========================
39
- // 边框颜色
40
- // ===========================
41
- $xt-color-border: #DCDFE6; // 边框颜色 - 标准
42
- $xt-color-border-light: #E4E7ED; // 边框浅色
43
- $xt-color-border-lighter: #EBEEF5; // 边框更浅色
44
- $xt-color-border-extra-light: #F2F6FC; // 边框极浅色
45
-
46
- // ===========================
47
- // 字体大小 - 基础值
48
- // ===========================
49
- $xt-font-size-extra-large: 20px; // 特大字体基础值
50
- $xt-font-size-large: 18px; // 大字体基础值
51
- $xt-font-size-medium: 16px; // 中等字体基础值
52
- $xt-font-size-base: 14px; // 基准字体 - Element UI 默认
53
- $xt-font-size-small: 13px; // 小字体基础值
54
- $xt-font-size-extra-small: 12px; // 特小字体基础值
55
-
56
- // ===========================
57
- // 字体大小增量(用于主题切换)
58
- // ===========================
59
- $xt-font-size-increment-small: 0px; // 小尺寸增量
60
- $xt-font-size-increment-medium: 2px; // 中尺寸增量
61
- $xt-font-size-increment-large: 4px; // 大尺寸增量
62
-
63
- // ===========================
64
- // 间距
65
- // ===========================
66
- $xt-spacing-xs: 4px; // 最小间距
67
- $xt-spacing-sm: 8px; // 小间距
68
- $xt-spacing-md: 12px; // 中间距
69
- $xt-spacing-lg: 16px; // 大间距
70
- $xt-spacing-xl: 20px; // 特大间距
71
-
72
- // ===========================
73
- // 圆角
74
- // ===========================
75
- $xt-border-radius-base: 4px; // 基准圆角
76
- $xt-border-radius-small: 2px; // 小圆角
77
- $xt-border-radius-round: 20px; // 圆角(胶囊状)
78
- $xt-border-radius-circle: 50%; // 圆形
79
-
80
- // ===========================
81
- // 阴影
82
- // ===========================
83
- $xt-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04); // 小阴影
84
- $xt-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08); // 中等阴影
85
- $xt-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12); // 大阴影
86
-
87
- // ===========================
88
- // 过渡动画
89
- // ===========================
90
- $xt-transition-duration: 0.3s; // 默认过渡时长
91
- $xt-transition-duration-fast: 0.2s; // 快速过渡时长
92
- $xt-transition-ease: ease; // 缓动函数
93
-
94
- // ===========================
95
- // 布局 / 头部 / 导航 专用变量
96
- // ===========================
97
-
98
- // 头部导航
99
- $xt-header-bg: #ffffff; // 头部背景色
100
- $xt-header-text-color: #303133; // 头部文字颜色
101
- $xt-header-active-text: #409EFF; // 头部激活状态文字颜色
102
- $xt-header-hover-text: #409EFF; // 头部悬停状态文字颜色
103
-
104
- // 汉堡菜单按钮
105
- $xt-hamburger-bg: #409EFF; // 汉堡按钮背景色
106
-
107
- // 侧边菜单
108
- $xt-menu-bg: #304156; // 菜单背景色
109
- $xt-menu-hover: #263445; // 菜单悬停背景色
110
- $xt-menu-text: #bfcbd9; // 菜单文字颜色
111
- $xt-menu-active-text: #ffffff; // 菜单激活状态文字颜色
112
-
113
- // 子菜单
114
- $xt-sub-menu-bg: #1f2d3d; // 子菜单背景色
115
- $xt-sub-menu-hover: #001528; // 子菜单悬停背景色
116
-
117
- // ===========================
118
- // 弹窗专用变量
119
- // ===========================
120
- $xt-dialog-bg: #ffffff; // 弹窗背景色
121
- $xt-dialog-title: #303133; // 弹窗标题文字颜色
122
-
123
- // ===========================
124
- // TAG 标签专用变量
125
- // ===========================
126
- $xt-tag-bg: #ffffff; // 标签背景色
1
+ @import './theme/index.scss';
@@ -1,124 +1,193 @@
1
-
2
- // 默认配置
3
- const defaultConfig = {
4
- theme: 'light',
5
- size: 'medium',
6
- primaryColor: '#1890ff'
7
- }
8
-
9
- // 当前配置
10
- let currentConfig = { ...defaultConfig }
11
-
12
- // 配置变更事件处理
13
- const configChangeListeners = []
14
-
15
- const emitConfigChange = function(key, value) {
16
- configChangeListeners.forEach(listener => {
17
- listener(key, value)
18
- })
19
- }
20
-
21
- // 获取所有配置
22
- export const getConfig = function() {
23
- return { ...currentConfig }
24
- }
25
-
26
- // 设置全局配置
27
- export const setConfig = function(config) {
28
- if (typeof config !== 'object' || config === null) {
29
- console.warn('[XtElementUI] setConfig 必须传入对象参数')
30
- return
31
- }
32
-
33
- if (config.theme !== undefined) {
34
- setTheme(config.theme)
35
- }
36
- if (config.size !== undefined) {
37
- setSize(config.size)
38
- }
39
- if (config.primaryColor !== undefined) {
40
- setPrimaryColor(config.primaryColor)
41
- }
42
- }
43
-
44
-
45
- // 设置主题
46
- export const setTheme = function(theme) {
47
- const validThemes = ['light', 'dark', 'compact']
48
- if (!validThemes.includes(theme)) {
49
- console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
50
- return
51
- }
52
-
53
- currentConfig.theme = theme
54
- document.documentElement.setAttribute('data-theme', theme)
55
- emitConfigChange('theme', theme)
56
- }
57
-
58
- // 设置字体大小
59
- export const setSize = function(size) {
60
- const validSizes = ['small', 'medium', 'large']
61
- if (!validSizes.includes(size)) {
62
- console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
63
- return
64
- }
65
-
66
- currentConfig.size = size
67
- document.documentElement.setAttribute('data-size', size)
68
- emitConfigChange('size', size)
69
- }
70
-
71
- // 设置主色调
72
- export const setPrimaryColor = function(color) {
73
- // 简单的颜色格式验证
74
- const colorRegex = /^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{3}$/
75
- if (!colorRegex.test(color)) {
76
- console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
77
- return
78
- }
79
-
80
- currentConfig.primaryColor = color
81
- document.documentElement.style.setProperty('--xt-color-primary', color)
82
- emitConfigChange('primaryColor', color)
83
- }
84
-
85
- // 获取当前主题
86
- export const getTheme = function() {
87
- return currentConfig.theme
88
- }
89
-
90
- // 获取当前字体大小
91
- export const getSize = function() {
92
- return currentConfig.size
93
- }
94
-
95
- // 获取当前主色调
96
- export const getPrimaryColor = function() {
97
- return currentConfig.primaryColor
98
- }
99
-
100
- // 重置为默认配置
101
- export const resetConfig = function() {
102
- setConfig(defaultConfig)
103
- }
104
-
105
- // 监听配置变更
106
- export const onConfigChange = function(listener) {
107
- if (typeof listener === 'function') {
108
- configChangeListeners.push(listener)
109
- return function() {
110
- const index = configChangeListeners.indexOf(listener)
111
- if (index > -1) {
112
- configChangeListeners.splice(index, 1)
113
- }
114
- }
115
- } else {
116
- console.warn('[XtElementUI] onConfigChange 必须传入函数')
117
- }
118
- }
119
-
120
- export default {
121
- setTheme,
122
- setSize,
123
- setPrimaryColor
124
- }
1
+ // 默认配置
2
+ const defaultConfig = {
3
+ theme: 'white',
4
+ size: 'medium',
5
+ primaryColor: '#1890ff'
6
+ }
7
+
8
+ // 当前配置
9
+ let currentConfig = { ...defaultConfig }
10
+
11
+ // 调试:输出初始化信息
12
+ console.log('[XtElementUI] utils initialized with currentConfig:', currentConfig)
13
+
14
+ // 配置变更事件处理
15
+ const configChangeListeners = []
16
+
17
+ const emitConfigChange = function(key, value) {
18
+ configChangeListeners.forEach(listener => {
19
+ listener(key, value)
20
+ })
21
+ }
22
+
23
+ // 获取所有配置
24
+ export const getConfig = function() {
25
+ return { ...currentConfig }
26
+ }
27
+
28
+ // 设置全局配置
29
+ export const setConfig = function(config) {
30
+ if (typeof config !== 'object' || config === null) {
31
+ console.warn('[XtElementUI] setConfig 必须传入对象参数')
32
+ return
33
+ }
34
+
35
+ if (config.theme !== undefined) {
36
+ setTheme(config.theme)
37
+ }
38
+ if (config.size !== undefined) {
39
+ setSize(config.size)
40
+ }
41
+ if (config.primaryColor !== undefined) {
42
+ setPrimaryColor(config.primaryColor)
43
+ }
44
+ }
45
+
46
+
47
+ // 设置主题
48
+ export const setTheme = function(theme) {
49
+ const validThemes = ['white', 'dark']
50
+ if (!validThemes.includes(theme)) {
51
+ console.warn(`[XtElementUI] 无效的主题值: ${theme},可选值: ${validThemes.join(', ')}`)
52
+ return
53
+ }
54
+
55
+ currentConfig.theme = theme
56
+ const root = document.documentElement
57
+
58
+ // 使用类名方式切换主题(兼容 Element Plus 风格)
59
+ if (theme === 'dark') {
60
+ root.setAttribute('data-theme', 'dark')
61
+ } else {
62
+ root.removeAttribute('data-theme')
63
+ }
64
+
65
+ emitConfigChange('theme', theme)
66
+ }
67
+
68
+ // 设置字体大小
69
+ export const setSize = function(size) {
70
+ const validSizes = ['small', 'medium', 'large']
71
+ if (!validSizes.includes(size)) {
72
+ console.warn(`[XtElementUI] 无效的大小值: ${size},可选值: ${validSizes.join(', ')}`)
73
+ return
74
+ }
75
+
76
+ currentConfig.size = size
77
+ document.documentElement.setAttribute('data-size', size)
78
+ emitConfigChange('size', size)
79
+ }
80
+
81
+ // 将十六进制颜色转换为 RGB 对象
82
+ function hexToRgb(hex) {
83
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex)
84
+ return result ? {
85
+ r: parseInt(result[1], 16),
86
+ g: parseInt(result[2], 16),
87
+ b: parseInt(result[3], 16)
88
+ } : null
89
+ }
90
+
91
+ // RGB 对象转换为十六进制颜色
92
+ function rgbToHex(r, g, b) {
93
+ return '#' + [r, g, b].map(x => {
94
+ const hex = x.toString(16)
95
+ return hex.length === 1 ? '0' + hex : hex
96
+ }).join('')
97
+ }
98
+
99
+ // 计算浅色系列(混合白色)
100
+ function lightenColor(hex, percent) {
101
+ const rgb = hexToRgb(hex)
102
+ if (!rgb) return hex
103
+
104
+ const amount = Math.round(2.55 * percent)
105
+ const r = Math.min(255, rgb.r + amount)
106
+ const g = Math.min(255, rgb.g + amount)
107
+ const b = Math.min(255, rgb.b + amount)
108
+
109
+ return rgbToHex(r, g, b)
110
+ }
111
+
112
+ // 设置主色调
113
+ export const setPrimaryColor = function(color) {
114
+ // 颜色格式验证(支持 3/6/8 位十六进制)
115
+ const colorRegex = /^#[0-9A-Fa-f]{3}$|^#[0-9A-Fa-f]{6}$|^#[0-9A-Fa-f]{8}$/
116
+ if (!colorRegex.test(color)) {
117
+ console.warn(`[XtElementUI] 无效的颜色值: ${color},请使用十六进制颜色格式,如 #1890ff`)
118
+ return
119
+ }
120
+
121
+ // 转换为 6 位十六进制(去掉透明度)
122
+ let validColor = color
123
+ if (color.length === 4) {
124
+ // #RGB 转换为 #RRGGBB
125
+ validColor = '#' + color[1] + color[1] + color[2] + color[2] + color[3] + color[3]
126
+ } else if (color.length === 9) {
127
+ // #RRGGBBAA 转换为 #RRGGBB(去掉 Alpha)
128
+ validColor = color.substring(0, 7)
129
+ }
130
+
131
+ currentConfig.primaryColor = validColor
132
+
133
+ // 设置主色调
134
+ document.documentElement.style.setProperty('--xt-color-primary', validColor)
135
+
136
+ // 动态计算并设置浅色系列
137
+ document.documentElement.style.setProperty('--xt-color-primary-light-3', lightenColor(validColor, 30))
138
+ document.documentElement.style.setProperty('--xt-color-primary-light-5', lightenColor(validColor, 50))
139
+ document.documentElement.style.setProperty('--xt-color-primary-light-7', lightenColor(validColor, 70))
140
+ document.documentElement.style.setProperty('--xt-color-primary-light-8', lightenColor(validColor, 80))
141
+ document.documentElement.style.setProperty('--xt-color-primary-light-9', lightenColor(validColor, 90))
142
+
143
+ emitConfigChange('primaryColor', validColor)
144
+ console.log('[XtElementUI] 主色调已设置为:', validColor)
145
+ }
146
+
147
+ // 获取当前主题
148
+ export const getTheme = function() {
149
+ return currentConfig.theme
150
+ }
151
+
152
+ // 获取当前字体大小
153
+ export const getSize = function() {
154
+ return currentConfig.size
155
+ }
156
+
157
+ // 获取当前主色调
158
+ export const getPrimaryColor = function() {
159
+ return currentConfig.primaryColor
160
+ }
161
+
162
+ // 重置为默认配置
163
+ export const resetConfig = function() {
164
+ setConfig(defaultConfig)
165
+ }
166
+
167
+ // 监听配置变更
168
+ export const onConfigChange = function(listener) {
169
+ if (typeof listener === 'function') {
170
+ configChangeListeners.push(listener)
171
+ return function() {
172
+ const index = configChangeListeners.indexOf(listener)
173
+ if (index > -1) {
174
+ configChangeListeners.splice(index, 1)
175
+ }
176
+ }
177
+ } else {
178
+ console.warn('[XtElementUI] onConfigChange 必须传入函数')
179
+ }
180
+ }
181
+
182
+ export default {
183
+ setTheme,
184
+ setSize,
185
+ setPrimaryColor,
186
+ getConfig,
187
+ setConfig,
188
+ getTheme,
189
+ getSize,
190
+ getPrimaryColor,
191
+ resetConfig,
192
+ onConfigChange
193
+ }