xt-element-ui 1.3.2 → 1.3.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +72 -72
  2. package/LICENSE +21 -21
  3. package/README.md +240 -240
  4. package/docs/README.md +100 -100
  5. package/docs/components/base/xt-button.md +114 -114
  6. package/docs/components/base/xt-card-item.md +104 -104
  7. package/docs/components/base/xt-card.md +108 -108
  8. package/docs/components/base/xt-config-provider.md +199 -199
  9. package/docs/components/base/xt-flex-box.md +115 -115
  10. package/docs/components/base/xt-grid-box.md +302 -302
  11. package/docs/components/base/xt-input.md +150 -150
  12. package/docs/components/base/xt-map-provider.md +23 -0
  13. package/docs/components/base/xt-map.md +331 -331
  14. package/docs/components/base/xt-step-price.md +165 -165
  15. package/docs/components/base/xt-text.md +212 -212
  16. package/docs/components/base/xt-time.md +165 -165
  17. package/docs/components/extend/ex-bar.md +67 -67
  18. package/docs/components/extend/ex-button.md +62 -62
  19. package/docs/components/extend/ex-card.md +86 -86
  20. package/docs/components/extend/ex-chart.md +463 -463
  21. package/docs/components/extend/ex-icon.md +189 -189
  22. package/docs/components/extend/ex-line.md +70 -70
  23. package/docs/components/extend/ex-multi.md +155 -155
  24. package/docs/components/extend/ex-pie.md +69 -69
  25. package/docs/components/extend/ex-select-tree.md +210 -210
  26. package/docs/components/extend/ex-table.md +590 -590
  27. package/docs/components/extend/ex-upload.md +134 -134
  28. package/docs/components/utils/size.md +147 -147
  29. package/docs/components/utils/theme.md +182 -182
  30. package/lib/index.common.js +4131 -4162
  31. package/lib/index.css +1 -1
  32. package/lib/index.umd.js +4099 -4129
  33. package/lib/index.umd.min.js +3 -3
  34. package/package.json +80 -81
  35. package/src/components/ex-button/index.js +7 -7
  36. package/src/components/ex-button/index.vue +66 -66
  37. package/src/components/ex-button/style/index.scss +67 -67
  38. package/src/components/ex-card/index.js +7 -7
  39. package/src/components/ex-card/index.vue +68 -68
  40. package/src/components/ex-card/style/index.scss +73 -73
  41. package/src/components/ex-chart/index.js +7 -7
  42. package/src/components/ex-chart/index.vue +136 -136
  43. package/src/components/ex-date-picker/index.js +7 -7
  44. package/src/components/ex-icon/index.js +7 -7
  45. package/src/components/ex-icon/index.vue +168 -168
  46. package/src/components/ex-icon/style/index.scss +7 -7
  47. package/src/components/ex-page/index.js +7 -7
  48. package/src/components/ex-select-tree/index.js +7 -7
  49. package/src/components/ex-table/ExTableCell.vue +22 -22
  50. package/src/components/ex-table/index.js +7 -7
  51. package/src/components/ex-table/virtualScrollData.js +35 -35
  52. package/src/components/ex-upload/index.js +7 -7
  53. package/src/components/index.scss +39 -39
  54. package/src/components/xt-button/index.js +7 -7
  55. package/src/components/xt-button/index.vue +97 -97
  56. package/src/components/xt-card/index.js +7 -7
  57. package/src/components/xt-card/style/index.scss +48 -48
  58. package/src/components/xt-card-item/index.js +7 -7
  59. package/src/components/xt-card-item/style/index copy.scss +71 -71
  60. package/src/components/xt-card-item/style/index.scss +82 -82
  61. package/src/components/xt-config-provider/index.js +7 -7
  62. package/src/components/xt-config-provider/index.vue +362 -362
  63. package/src/components/xt-config-provider/style/index.scss +11 -11
  64. package/src/components/xt-flex-box/index.js +7 -7
  65. package/src/components/xt-flex-box/style/index.scss +81 -81
  66. package/src/components/xt-grid-box/index.js +7 -7
  67. package/src/components/xt-grid-box/style/index.scss +92 -92
  68. package/src/components/xt-grid-item/index.js +7 -7
  69. package/src/components/xt-grid-item/index.vue +106 -106
  70. package/src/components/xt-input/index.js +7 -7
  71. package/src/components/xt-input/index.vue +66 -66
  72. package/src/components/xt-input/style/index.scss +84 -84
  73. package/src/components/xt-map/adapters/amap.js +235 -235
  74. package/src/components/xt-map/adapters/baidu.js +254 -254
  75. package/src/components/xt-map/adapters/base.js +267 -267
  76. package/src/components/xt-map/adapters/index.js +29 -29
  77. package/src/components/xt-map/adapters/tianditu.js +242 -242
  78. package/src/components/xt-map/config/xt-map-config.js +197 -197
  79. package/src/components/xt-map/index.js +8 -30
  80. package/src/components/xt-map/index.vue +351 -351
  81. package/src/components/xt-map/loaders/script-loader.js +114 -114
  82. package/src/components/xt-map/provider.vue +200 -200
  83. package/src/components/xt-map/style/index.scss +77 -77
  84. package/src/components/xt-map-provider/index.js +8 -0
  85. package/src/components/xt-step-price/index.js +10 -10
  86. package/src/components/xt-step-price/index.vue +272 -272
  87. package/src/components/xt-step-price/style/index.scss +123 -123
  88. package/src/components/xt-step-price-item/index.js +7 -7
  89. package/src/components/xt-step-price-item/index.vue +187 -187
  90. package/src/components/xt-text/index.js +7 -7
  91. package/src/components/xt-text/index.vue +1 -1
  92. package/src/components/xt-text/style/index.scss +92 -92
  93. package/src/components/xt-time/index.js +7 -7
  94. package/src/components/xt-time/index.vue +313 -313
  95. package/src/components/xt-time/style/index.scss +23 -23
  96. package/src/config/element-registry.js +135 -135
  97. package/src/index.js +162 -178
  98. package/src/styles/css-variables.scss +257 -257
  99. package/src/styles/theme/background.scss +5 -5
  100. package/src/styles/theme/border-radius.scss +3 -3
  101. package/src/styles/theme/borders.scss +3 -3
  102. package/src/styles/theme/colors.scss +101 -101
  103. package/src/styles/theme/component-variables.scss +69 -69
  104. package/src/styles/theme/dark-variables.scss +28 -28
  105. package/src/styles/theme/font.scss +12 -12
  106. package/src/styles/theme/index.scss +11 -11
  107. package/src/styles/theme/shadows.scss +2 -2
  108. package/src/styles/theme/spacing.scss +4 -4
  109. package/src/styles/theme/transitions.scss +2 -2
  110. package/src/styles/theme/typography.scss +4 -4
  111. package/src/styles/variables-export.scss +85 -85
  112. package/src/utils/index.js +191 -202
@@ -1,242 +1,242 @@
1
- /**
2
- * 天地图适配器 (Tianditu)
3
- * 天地图使用 WMTS 切片服务,不支持原生主题切换,
4
- * dark/light 通过图层样式参数模拟(部分图层可调整色调)
5
- */
6
-
7
- import { MapAdapterBase } from './base'
8
- import { hasGlobal } from '../loaders/script-loader'
9
-
10
- // 天地图地图类型映射
11
- const TIANDITU_MAP_TYPES = {
12
- standard: 'vec', // 矢量地图
13
- satellite: 'img', // 影像地图
14
- hybrid: 'img', // 混合(影像 + 注记)
15
- traffic: 'vec' // 天地图不支持原生路况,降级为矢量
16
- }
17
-
18
- // 天地图主题色模拟:通过调整图层透明度/色调CSS滤镜
19
- const TIANDITU_THEME_FILTER = {
20
- light: 'none',
21
- dark: 'invert(1) hue-rotate(180deg) saturate(1.2) brightness(0.95)'
22
- }
23
-
24
- export class TiandituAdapter extends MapAdapterBase {
25
- constructor(container, options = {}) {
26
- super(container, options)
27
- this._mapTypeMap = { ...TIANDITU_MAP_TYPES }
28
- this._layerType = options.tiandituLayerType || 'vec'
29
- this._currentLayer = null
30
- this._annotationLayer = null
31
- }
32
-
33
- getScriptUrl() {
34
- if (this.apiUrl) return this.apiUrl
35
- if (!this.apiKey) {
36
- console.warn('[XtMap] 天地图需要配置 apiKey (tk)')
37
- return ''
38
- }
39
- return `https://api.tianditu.gov.cn/api?v=4.0&tk=${encodeURIComponent(this.apiKey)}`
40
- }
41
-
42
- isSdkLoaded() {
43
- return hasGlobal('T') && typeof window.T === 'object' && window.T.Map
44
- }
45
-
46
- async createMap() {
47
- const T = window.T
48
- if (!T || !T.Map) throw new Error('[XtMap] 天地图 SDK 未加载')
49
-
50
- const mapOptions = {
51
- center: new T.LngLat(this.center[0], this.center[1]),
52
- zoom: this.zoom
53
- }
54
-
55
- this.mapInstance = new T.Map(this.container, mapOptions)
56
-
57
- // 应用地图类型
58
- this._applyMapType(this.mapType)
59
-
60
- // 应用主题
61
- this._applyTheme(this.theme)
62
-
63
- // 等待地图就绪
64
- await new Promise((resolve) => {
65
- setTimeout(resolve, 500)
66
- })
67
-
68
- // 绑定事件
69
- for (const [eventName, handler] of this.eventHandlers.entries()) {
70
- this._bindEvent(eventName, handler)
71
- }
72
- }
73
-
74
- _applyMapType(type) {
75
- if (!this.mapInstance) return
76
- const T = window.T
77
- if (!T) return
78
-
79
- try {
80
- // 天地图通过 switchTo 方法切换图层
81
- const layerType = this._mapTypeMap[type] || 'vec'
82
-
83
- if (type === 'standard') {
84
- // 矢量地图
85
- this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
86
- } else if (type === 'satellite') {
87
- // 影像地图
88
- this.mapInstance.setMapType(window.TMAP_SATELLITE_MAP || 2)
89
- } else if (type === 'hybrid') {
90
- // 混合(影像+注记)
91
- this.mapInstance.setMapType(window.TMAP_HYBRID_MAP || 3)
92
- } else {
93
- // 路况等特殊类型,天地图无原生支持
94
- this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
95
- }
96
- } catch (e) {
97
- console.warn('[XtMap] 天地图切换地图类型失败:', e)
98
- }
99
- }
100
-
101
- _applyTheme(theme) {
102
- if (!this.container) return
103
- // 天地图不支持原生 dark 主题,通过 CSS 滤镜模拟
104
- const filter = TIANDITU_THEME_FILTER[theme] || 'none'
105
- const imgElements = this.container.querySelectorAll('img')
106
- imgElements.forEach((img) => {
107
- img.style.filter = filter
108
- img.style.webkitFilter = filter
109
- })
110
- // 同时设置容器级 CSS 变量,方便样式覆盖
111
- this.container.setAttribute('data-map-theme', theme)
112
- // 监听后续新增的 tile 图片(通过 MutationObserver)
113
- this._setupThemeObserver(theme)
114
- }
115
-
116
- _setupThemeObserver(theme) {
117
- if (this._themeObserver) {
118
- this._themeObserver.disconnect()
119
- }
120
- if (theme !== 'dark') return
121
- const filter = TIANDITU_THEME_FILTER[theme]
122
- this._themeObserver = new MutationObserver((mutations) => {
123
- mutations.forEach((mutation) => {
124
- mutation.addedNodes.forEach((node) => {
125
- if (node.nodeType === 1) {
126
- if (node.tagName === 'IMG') {
127
- node.style.filter = filter
128
- node.style.webkitFilter = filter
129
- } else if (node.querySelectorAll) {
130
- const imgs = node.querySelectorAll('img')
131
- imgs.forEach((img) => {
132
- img.style.filter = filter
133
- img.style.webkitFilter = filter
134
- })
135
- }
136
- }
137
- })
138
- })
139
- })
140
- try {
141
- this._themeObserver.observe(this.container, {
142
- childList: true,
143
- subtree: true
144
- })
145
- } catch (e) {
146
- // 忽略
147
- }
148
- }
149
-
150
- _applyCenter(center) {
151
- if (!this.mapInstance || !window.T) return
152
- try {
153
- this.mapInstance.centerAndZoom(new window.T.LngLat(center[0], center[1]), this.zoom)
154
- } catch (e) {
155
- // 忽略
156
- }
157
- }
158
-
159
- _applyZoom(zoom) {
160
- if (!this.mapInstance) return
161
- try {
162
- this.mapInstance.setZoom(zoom)
163
- } catch (e) {
164
- // 忽略
165
- }
166
- }
167
-
168
- getCenter() {
169
- if (this.mapInstance && this.mapInstance.getCenter) {
170
- const c = this.mapInstance.getCenter()
171
- if (c && c.getLng !== undefined) {
172
- return [c.getLng(), c.getLat()]
173
- }
174
- }
175
- return this.center
176
- }
177
-
178
- getZoom() {
179
- if (this.mapInstance && this.mapInstance.getZoom) {
180
- return this.mapInstance.getZoom()
181
- }
182
- return this.zoom
183
- }
184
-
185
- _bindEvent(eventName, handler) {
186
- if (!this.mapInstance) return
187
- try {
188
- const eventMap = {
189
- click: 'click',
190
- moveend: 'moveend',
191
- zoomend: 'zoomend',
192
- zoomchange: 'zoomend'
193
- }
194
- const nativeEvent = eventMap[eventName] || eventName
195
- this.mapInstance.addEventListener(nativeEvent, (e) => {
196
- const normalized = {
197
- originalEvent: e,
198
- lnglat: e && e.lnglat ? [e.lnglat.getLng(), e.lnglat.getLat()] : null
199
- }
200
- handler(normalized)
201
- })
202
- } catch (err) {
203
- console.warn('[XtMap] 天地图事件绑定失败:', eventName, err)
204
- }
205
- }
206
-
207
- _unbindEvent(eventName, handler) {
208
- if (!this.mapInstance) return
209
- try {
210
- this.mapInstance.removeEventListener(eventName, handler)
211
- } catch (e) {
212
- // 忽略
213
- }
214
- }
215
-
216
- _applyResize() {
217
- if (this.mapInstance && this.mapInstance.checkResize) {
218
- try {
219
- this.mapInstance.checkResize()
220
- } catch (e) {
221
- // 忽略
222
- }
223
- }
224
- }
225
-
226
- destroy() {
227
- if (this._themeObserver) {
228
- this._themeObserver.disconnect()
229
- this._themeObserver = null
230
- }
231
- if (this.mapInstance && typeof this.mapInstance.clearOverLays === 'function') {
232
- try {
233
- this.mapInstance.clearOverLays()
234
- } catch (e) {
235
- // 忽略
236
- }
237
- }
238
- super.destroy()
239
- }
240
- }
241
-
242
- export default TiandituAdapter
1
+ /**
2
+ * 天地图适配器 (Tianditu)
3
+ * 天地图使用 WMTS 切片服务,不支持原生主题切换,
4
+ * dark/light 通过图层样式参数模拟(部分图层可调整色调)
5
+ */
6
+
7
+ import { MapAdapterBase } from './base'
8
+ import { hasGlobal } from '../loaders/script-loader'
9
+
10
+ // 天地图地图类型映射
11
+ const TIANDITU_MAP_TYPES = {
12
+ standard: 'vec', // 矢量地图
13
+ satellite: 'img', // 影像地图
14
+ hybrid: 'img', // 混合(影像 + 注记)
15
+ traffic: 'vec' // 天地图不支持原生路况,降级为矢量
16
+ }
17
+
18
+ // 天地图主题色模拟:通过调整图层透明度/色调CSS滤镜
19
+ const TIANDITU_THEME_FILTER = {
20
+ light: 'none',
21
+ dark: 'invert(1) hue-rotate(180deg) saturate(1.2) brightness(0.95)'
22
+ }
23
+
24
+ export class TiandituAdapter extends MapAdapterBase {
25
+ constructor(container, options = {}) {
26
+ super(container, options)
27
+ this._mapTypeMap = { ...TIANDITU_MAP_TYPES }
28
+ this._layerType = options.tiandituLayerType || 'vec'
29
+ this._currentLayer = null
30
+ this._annotationLayer = null
31
+ }
32
+
33
+ getScriptUrl() {
34
+ if (this.apiUrl) return this.apiUrl
35
+ if (!this.apiKey) {
36
+ console.warn('[XtMap] 天地图需要配置 apiKey (tk)')
37
+ return ''
38
+ }
39
+ return `https://api.tianditu.gov.cn/api?v=4.0&tk=${encodeURIComponent(this.apiKey)}`
40
+ }
41
+
42
+ isSdkLoaded() {
43
+ return hasGlobal('T') && typeof window.T === 'object' && window.T.Map
44
+ }
45
+
46
+ async createMap() {
47
+ const T = window.T
48
+ if (!T || !T.Map) throw new Error('[XtMap] 天地图 SDK 未加载')
49
+
50
+ const mapOptions = {
51
+ center: new T.LngLat(this.center[0], this.center[1]),
52
+ zoom: this.zoom
53
+ }
54
+
55
+ this.mapInstance = new T.Map(this.container, mapOptions)
56
+
57
+ // 应用地图类型
58
+ this._applyMapType(this.mapType)
59
+
60
+ // 应用主题
61
+ this._applyTheme(this.theme)
62
+
63
+ // 等待地图就绪
64
+ await new Promise((resolve) => {
65
+ setTimeout(resolve, 500)
66
+ })
67
+
68
+ // 绑定事件
69
+ for (const [eventName, handler] of this.eventHandlers.entries()) {
70
+ this._bindEvent(eventName, handler)
71
+ }
72
+ }
73
+
74
+ _applyMapType(type) {
75
+ if (!this.mapInstance) return
76
+ const T = window.T
77
+ if (!T) return
78
+
79
+ try {
80
+ // 天地图通过 switchTo 方法切换图层
81
+ const layerType = this._mapTypeMap[type] || 'vec'
82
+
83
+ if (type === 'standard') {
84
+ // 矢量地图
85
+ this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
86
+ } else if (type === 'satellite') {
87
+ // 影像地图
88
+ this.mapInstance.setMapType(window.TMAP_SATELLITE_MAP || 2)
89
+ } else if (type === 'hybrid') {
90
+ // 混合(影像+注记)
91
+ this.mapInstance.setMapType(window.TMAP_HYBRID_MAP || 3)
92
+ } else {
93
+ // 路况等特殊类型,天地图无原生支持
94
+ this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
95
+ }
96
+ } catch (e) {
97
+ console.warn('[XtMap] 天地图切换地图类型失败:', e)
98
+ }
99
+ }
100
+
101
+ _applyTheme(theme) {
102
+ if (!this.container) return
103
+ // 天地图不支持原生 dark 主题,通过 CSS 滤镜模拟
104
+ const filter = TIANDITU_THEME_FILTER[theme] || 'none'
105
+ const imgElements = this.container.querySelectorAll('img')
106
+ imgElements.forEach((img) => {
107
+ img.style.filter = filter
108
+ img.style.webkitFilter = filter
109
+ })
110
+ // 同时设置容器级 CSS 变量,方便样式覆盖
111
+ this.container.setAttribute('data-map-theme', theme)
112
+ // 监听后续新增的 tile 图片(通过 MutationObserver)
113
+ this._setupThemeObserver(theme)
114
+ }
115
+
116
+ _setupThemeObserver(theme) {
117
+ if (this._themeObserver) {
118
+ this._themeObserver.disconnect()
119
+ }
120
+ if (theme !== 'dark') return
121
+ const filter = TIANDITU_THEME_FILTER[theme]
122
+ this._themeObserver = new MutationObserver((mutations) => {
123
+ mutations.forEach((mutation) => {
124
+ mutation.addedNodes.forEach((node) => {
125
+ if (node.nodeType === 1) {
126
+ if (node.tagName === 'IMG') {
127
+ node.style.filter = filter
128
+ node.style.webkitFilter = filter
129
+ } else if (node.querySelectorAll) {
130
+ const imgs = node.querySelectorAll('img')
131
+ imgs.forEach((img) => {
132
+ img.style.filter = filter
133
+ img.style.webkitFilter = filter
134
+ })
135
+ }
136
+ }
137
+ })
138
+ })
139
+ })
140
+ try {
141
+ this._themeObserver.observe(this.container, {
142
+ childList: true,
143
+ subtree: true
144
+ })
145
+ } catch (e) {
146
+ // 忽略
147
+ }
148
+ }
149
+
150
+ _applyCenter(center) {
151
+ if (!this.mapInstance || !window.T) return
152
+ try {
153
+ this.mapInstance.centerAndZoom(new window.T.LngLat(center[0], center[1]), this.zoom)
154
+ } catch (e) {
155
+ // 忽略
156
+ }
157
+ }
158
+
159
+ _applyZoom(zoom) {
160
+ if (!this.mapInstance) return
161
+ try {
162
+ this.mapInstance.setZoom(zoom)
163
+ } catch (e) {
164
+ // 忽略
165
+ }
166
+ }
167
+
168
+ getCenter() {
169
+ if (this.mapInstance && this.mapInstance.getCenter) {
170
+ const c = this.mapInstance.getCenter()
171
+ if (c && c.getLng !== undefined) {
172
+ return [c.getLng(), c.getLat()]
173
+ }
174
+ }
175
+ return this.center
176
+ }
177
+
178
+ getZoom() {
179
+ if (this.mapInstance && this.mapInstance.getZoom) {
180
+ return this.mapInstance.getZoom()
181
+ }
182
+ return this.zoom
183
+ }
184
+
185
+ _bindEvent(eventName, handler) {
186
+ if (!this.mapInstance) return
187
+ try {
188
+ const eventMap = {
189
+ click: 'click',
190
+ moveend: 'moveend',
191
+ zoomend: 'zoomend',
192
+ zoomchange: 'zoomend'
193
+ }
194
+ const nativeEvent = eventMap[eventName] || eventName
195
+ this.mapInstance.addEventListener(nativeEvent, (e) => {
196
+ const normalized = {
197
+ originalEvent: e,
198
+ lnglat: e && e.lnglat ? [e.lnglat.getLng(), e.lnglat.getLat()] : null
199
+ }
200
+ handler(normalized)
201
+ })
202
+ } catch (err) {
203
+ console.warn('[XtMap] 天地图事件绑定失败:', eventName, err)
204
+ }
205
+ }
206
+
207
+ _unbindEvent(eventName, handler) {
208
+ if (!this.mapInstance) return
209
+ try {
210
+ this.mapInstance.removeEventListener(eventName, handler)
211
+ } catch (e) {
212
+ // 忽略
213
+ }
214
+ }
215
+
216
+ _applyResize() {
217
+ if (this.mapInstance && this.mapInstance.checkResize) {
218
+ try {
219
+ this.mapInstance.checkResize()
220
+ } catch (e) {
221
+ // 忽略
222
+ }
223
+ }
224
+ }
225
+
226
+ destroy() {
227
+ if (this._themeObserver) {
228
+ this._themeObserver.disconnect()
229
+ this._themeObserver = null
230
+ }
231
+ if (this.mapInstance && typeof this.mapInstance.clearOverLays === 'function') {
232
+ try {
233
+ this.mapInstance.clearOverLays()
234
+ } catch (e) {
235
+ // 忽略
236
+ }
237
+ }
238
+ super.destroy()
239
+ }
240
+ }
241
+
242
+ export default TiandituAdapter