vxe-pc-ui 4.17.19 → 4.17.21

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 (99) hide show
  1. package/dist/all.esm.js +492 -191
  2. package/dist/style.css +1 -1
  3. package/dist/style.min.css +1 -1
  4. package/es/avatar/src/avatar.js +3 -3
  5. package/es/badge/src/badge.js +3 -3
  6. package/es/components.js +31 -1
  7. package/es/empty/src/empty.js +3 -3
  8. package/es/icon/style.css +1 -1
  9. package/es/rate/src/rate.js +3 -3
  10. package/es/result/src/result.js +3 -3
  11. package/es/slider/src/slider.js +191 -71
  12. package/es/slider/style.css +8 -15
  13. package/es/slider/style.min.css +1 -1
  14. package/es/space/index.js +12 -0
  15. package/es/space/src/space.js +143 -0
  16. package/es/space/style.css +37 -0
  17. package/es/space/style.min.css +1 -0
  18. package/es/style.css +1 -1
  19. package/es/style.min.css +1 -1
  20. package/es/ui/index.js +2 -1
  21. package/es/ui/src/dom.js +3 -0
  22. package/es/ui/src/log.js +1 -1
  23. package/es/vxe-slider/style.css +8 -15
  24. package/es/vxe-slider/style.min.css +1 -1
  25. package/es/vxe-space/index.js +3 -0
  26. package/es/vxe-space/style.css +37 -0
  27. package/es/vxe-space/style.min.css +1 -0
  28. package/es/watermark/src/watermark.js +3 -3
  29. package/lib/avatar/src/avatar.js +3 -3
  30. package/lib/badge/src/badge.js +3 -3
  31. package/lib/components.js +41 -2
  32. package/lib/components.min.js +1 -1
  33. package/lib/empty/src/empty.js +3 -3
  34. package/lib/icon/style/style.css +1 -1
  35. package/lib/icon/style/style.min.css +1 -1
  36. package/lib/index.umd.js +432 -99
  37. package/lib/index.umd.min.js +1 -1
  38. package/lib/rate/src/rate.js +3 -3
  39. package/lib/result/src/result.js +3 -3
  40. package/lib/slider/src/slider.js +196 -77
  41. package/lib/slider/src/slider.min.js +1 -1
  42. package/lib/slider/style/style.css +8 -15
  43. package/lib/slider/style/style.min.css +1 -1
  44. package/lib/space/index.js +19 -0
  45. package/lib/space/index.min.js +1 -0
  46. package/lib/space/src/space.js +167 -0
  47. package/lib/space/src/space.min.js +1 -0
  48. package/lib/space/style/index.js +1 -0
  49. package/lib/space/style/style.css +37 -0
  50. package/lib/space/style/style.min.css +1 -0
  51. package/lib/style.css +1 -1
  52. package/lib/style.min.css +1 -1
  53. package/lib/ui/index.js +2 -1
  54. package/lib/ui/index.min.js +1 -1
  55. package/lib/ui/src/dom.js +4 -0
  56. package/lib/ui/src/dom.min.js +1 -1
  57. package/lib/ui/src/log.js +1 -1
  58. package/lib/ui/src/log.min.js +1 -1
  59. package/lib/vxe-slider/style/style.css +8 -15
  60. package/lib/vxe-slider/style/style.min.css +1 -1
  61. package/lib/vxe-space/index.js +21 -0
  62. package/lib/vxe-space/index.min.js +1 -0
  63. package/lib/vxe-space/style/index.js +1 -0
  64. package/lib/vxe-space/style/style.css +37 -0
  65. package/lib/vxe-space/style/style.min.css +1 -0
  66. package/lib/watermark/src/watermark.js +3 -3
  67. package/package.json +4 -3
  68. package/packages/avatar/src/avatar.ts +3 -3
  69. package/packages/badge/src/badge.ts +3 -3
  70. package/packages/components.ts +31 -1
  71. package/packages/empty/src/empty.ts +3 -3
  72. package/packages/rate/src/rate.ts +3 -3
  73. package/packages/result/src/result.ts +3 -3
  74. package/packages/slider/src/slider.ts +194 -73
  75. package/packages/space/index.ts +16 -0
  76. package/packages/space/src/space.ts +167 -0
  77. package/packages/ui/index.ts +1 -0
  78. package/packages/ui/src/dom.ts +4 -0
  79. package/packages/watermark/src/watermark.ts +3 -3
  80. package/styles/all.scss +1 -0
  81. package/styles/components/slider.scss +8 -13
  82. package/styles/components/space.scss +38 -0
  83. package/styles/theme/base.scss +20 -6
  84. package/types/all.d.ts +3 -0
  85. package/types/components/slider.d.ts +13 -0
  86. package/types/components/space.d.ts +112 -0
  87. package/types/ui/global-config.d.ts +2 -0
  88. /package/es/icon/{iconfont.1787739841308.ttf → iconfont.1787994747472.ttf} +0 -0
  89. /package/es/icon/{iconfont.1787739841308.woff → iconfont.1787994747472.woff} +0 -0
  90. /package/es/icon/{iconfont.1787739841308.woff2 → iconfont.1787994747472.woff2} +0 -0
  91. /package/es/{iconfont.1787739841308.ttf → iconfont.1787994747472.ttf} +0 -0
  92. /package/es/{iconfont.1787739841308.woff → iconfont.1787994747472.woff} +0 -0
  93. /package/es/{iconfont.1787739841308.woff2 → iconfont.1787994747472.woff2} +0 -0
  94. /package/lib/icon/style/{iconfont.1787739841308.ttf → iconfont.1787994747472.ttf} +0 -0
  95. /package/lib/icon/style/{iconfont.1787739841308.woff → iconfont.1787994747472.woff} +0 -0
  96. /package/lib/icon/style/{iconfont.1787739841308.woff2 → iconfont.1787994747472.woff2} +0 -0
  97. /package/lib/{iconfont.1787739841308.ttf → iconfont.1787994747472.ttf} +0 -0
  98. /package/lib/{iconfont.1787739841308.woff → iconfont.1787994747472.woff} +0 -0
  99. /package/lib/{iconfont.1787739841308.woff2 → iconfont.1787994747472.woff2} +0 -0
@@ -1,14 +1,30 @@
1
- import { ref, h, reactive, PropType, watch, computed, inject, onMounted } from 'vue'
1
+ import { ref, h, reactive, PropType, watch, computed, inject, onMounted, onBeforeUnmount } from 'vue'
2
2
  import { defineVxeComponent } from '../../ui/src/comp'
3
3
  import XEUtils from 'xe-utils'
4
4
  import { getConfig, createEvent, renderEmptyElement, useSize } from '../../ui'
5
5
 
6
- import type { SliderReactData, VxeSliderEmits, VxeSliderPropTypes, SliderMethods, VxeFormDefines, VxeFormConstructor, VxeFormPrivateMethods, SliderPrivateMethods, ValueOf, SliderPrivateRef, VxeSliderPrivateComputed, VxeSliderConstructor, VxeSliderPrivateMethods } from '../../../types'
6
+ import type { SliderReactData, SliderInternalData, VxeSliderEmits, VxeSliderPropTypes, SliderMethods, VxeFormDefines, VxeFormConstructor, VxeFormPrivateMethods, SliderPrivateMethods, ValueOf, SliderPrivateRef, VxeSliderPrivateComputed, VxeSliderConstructor, VxeSliderPrivateMethods } from '../../../types'
7
+
8
+ function createInternalData (): SliderInternalData {
9
+ return {
10
+ // _isUp: false,
11
+ currValue: 0,
12
+ startValue: 0,
13
+ endValue: 0
14
+ }
15
+ }
16
+
17
+ function createReactData (): SliderReactData {
18
+ return {
19
+ }
20
+ }
7
21
 
8
22
  export default defineVxeComponent({
9
23
  name: 'VxeSlider',
10
24
  props: {
11
25
  modelValue: [String, Number, Array] as PropType<VxeSliderPropTypes.ModelValue>,
26
+ startValue: [String, Number] as PropType<VxeSliderPropTypes.StartValue>,
27
+ endValue: [String, Number] as PropType<VxeSliderPropTypes.EndValue>,
12
28
  vertical: Boolean as PropType<VxeSliderPropTypes.Vertical>,
13
29
  max: {
14
30
  type: [String, Number] as PropType<VxeSliderPropTypes.Max>,
@@ -37,10 +53,16 @@ export default defineVxeComponent({
37
53
  disabled: {
38
54
  type: Boolean as PropType<VxeSliderPropTypes.Disabled>,
39
55
  default: null
56
+ },
57
+ immediate: {
58
+ type: Boolean as PropType<VxeSliderPropTypes.Immediate>,
59
+ default: () => getConfig().slider.immediate
40
60
  }
41
61
  },
42
62
  emits: [
43
63
  'update:modelValue',
64
+ 'update:startValue',
65
+ 'update:endValue',
44
66
  'change',
45
67
  'track-dragstart',
46
68
  'track-dragover',
@@ -62,10 +84,8 @@ export default defineVxeComponent({
62
84
  const refStartBtnElem = ref<HTMLDivElement>()
63
85
  const refEndBtnElem = ref<HTMLDivElement>()
64
86
 
65
- const reactData = reactive<SliderReactData>({
66
- startValue: 0,
67
- endValue: 0
68
- })
87
+ const reactData = reactive(createReactData())
88
+ const internalData = createInternalData()
69
89
 
70
90
  const refMaps: SliderPrivateRef = {
71
91
  refElem
@@ -101,6 +121,11 @@ export default defineVxeComponent({
101
121
  return XEUtils.toNumber(props.min || 0)
102
122
  })
103
123
 
124
+ const computeMVal = computed(() => {
125
+ const { range, startValue, endValue } = props
126
+ return range ? `${startValue || ''}${endValue || ''}` : ''
127
+ })
128
+
104
129
  const computeMaps: VxeSliderPrivateComputed = {
105
130
  }
106
131
 
@@ -115,6 +140,7 @@ export default defineVxeComponent({
115
140
  } as unknown as VxeSliderConstructor & VxeSliderPrivateMethods
116
141
 
117
142
  const emitModel = (value: any) => {
143
+ internalData._isUp = true
118
144
  emit('update:modelValue', value)
119
145
  }
120
146
 
@@ -126,63 +152,121 @@ export default defineVxeComponent({
126
152
  dispatchEvent
127
153
  }
128
154
 
129
- const getStartPercent = (startValue: number) => {
130
- const { range } = props
155
+ const getBarPercent = (currValue: number) => {
131
156
  const maxNum = computeMaxNum.value
132
157
  const minNum = computeMinNum.value
133
- return range ? XEUtils.floor((startValue - minNum) / XEUtils.toNumber(maxNum - minNum) * 100) : 0
158
+ if (maxNum === minNum) {
159
+ return 0
160
+ }
161
+ if (currValue < minNum) {
162
+ currValue = minNum
163
+ }
164
+ if (currValue > maxNum) {
165
+ currValue = maxNum
166
+ }
167
+ return ((currValue - minNum) / (maxNum - minNum)) * 100
134
168
  }
135
169
 
136
- const getEndPercent = (startValue: number, endValue: number) => {
137
- const { range } = props
138
- const maxNum = computeMaxNum.value
139
- const minNum = computeMinNum.value
140
- return XEUtils.floor((endValue - (range ? startValue : 0) - minNum) / XEUtils.toNumber(maxNum - minNum) * 100)
170
+ const parseFields = (startValue?: VxeSliderPropTypes.StartValue, endValue?: VxeSliderPropTypes.EndValue) => {
171
+ const [sVal, eVal] = XEUtils.orderBy([XEUtils.toNumber(startValue), XEUtils.toNumber(endValue)])
172
+ const currValue = XEUtils.floor(XEUtils.toNumber(sVal || 0))
173
+ internalData.currValue = currValue
174
+ internalData.startValue = currValue
175
+ internalData.endValue = XEUtils.floor(XEUtils.toNumber(eVal || 0))
141
176
  }
142
177
 
143
- const updateModel = () => {
144
- const { modelValue } = props
145
- if (XEUtils.isArray(modelValue)) {
146
- const [sVal, eVal] = XEUtils.clone(modelValue, true).sort()
147
- reactData.startValue = XEUtils.floor(XEUtils.toNumber(sVal || 0))
148
- reactData.endValue = XEUtils.floor(XEUtils.toNumber(eVal || 0))
178
+ const parseArrs = (arrVals: number[]) => {
179
+ const [sVal, eVal] = XEUtils.orderBy(arrVals)
180
+ const currValue = XEUtils.floor(XEUtils.toNumber(sVal || 0))
181
+ internalData.currValue = currValue
182
+ internalData.startValue = currValue
183
+ internalData.endValue = XEUtils.floor(XEUtils.toNumber(eVal || 0))
184
+ }
185
+
186
+ const parseNum = (val: VxeSliderPropTypes.ModelValue | undefined) => {
187
+ const currValue = XEUtils.floor(XEUtils.toNumber(val || 0))
188
+ internalData.currValue = currValue
189
+ internalData.startValue = 0
190
+ internalData.endValue = currValue
191
+ }
192
+
193
+ const updateModelValue = (umType?: 1 | 2) => {
194
+ const { range, modelValue, startValue, endValue } = props
195
+ if (!umType) {
196
+ if (range) {
197
+ if (XEUtils.eqNull(modelValue)) {
198
+ if (startValue || endValue) {
199
+ parseFields(startValue, endValue)
200
+ }
201
+ } else {
202
+ if (XEUtils.isArray(modelValue)) {
203
+ parseArrs(modelValue.map(num => XEUtils.toNumber(num)))
204
+ } else {
205
+ parseNum(modelValue)
206
+ }
207
+ }
208
+ } else {
209
+ parseNum(modelValue)
210
+ }
211
+ } else if (range && umType === 2) {
212
+ parseFields(startValue, endValue)
149
213
  } else {
150
- reactData.startValue = 0
151
- reactData.endValue = XEUtils.floor(XEUtils.toNumber(modelValue || 0))
214
+ if (XEUtils.isArray(modelValue)) {
215
+ parseArrs(modelValue.map(num => XEUtils.toNumber(num)))
216
+ } else {
217
+ parseNum(modelValue)
218
+ }
152
219
  }
220
+ updateBarStyle()
221
+ updateTrackStyle()
153
222
  }
154
223
 
155
224
  const updateBarStyle = () => {
156
- const { startValue, endValue } = reactData
157
- const trackElem = refTrackElem.value
225
+ const { range } = props
226
+ const { currValue, startValue, endValue } = internalData
158
227
  const startBtnElem = refStartBtnElem.value
159
228
  const endBtnElem = refEndBtnElem.value
160
- let startPercent = 0
161
- let endPercent = 0
162
- if (startValue > endValue) {
163
- startPercent = getStartPercent(endValue)
164
- endPercent = getEndPercent(endValue, startValue)
229
+ if (range) {
230
+ const [sVal, eVal] = XEUtils.orderBy([startValue, endValue])
231
+ if (startBtnElem) {
232
+ startBtnElem.style.left = getBarPercent(sVal) + '%'
233
+ }
234
+ if (endBtnElem) {
235
+ endBtnElem.style.left = getBarPercent(eVal) + '%'
236
+ }
165
237
  } else {
166
- startPercent = getStartPercent(startValue)
167
- endPercent = getEndPercent(startValue, endValue)
238
+ if (endBtnElem) {
239
+ endBtnElem.style.left = getBarPercent(currValue) + '%'
240
+ }
168
241
  }
242
+ }
243
+
244
+ const updateTrackStyle = () => {
245
+ const { range } = props
246
+ const { currValue, startValue, endValue } = internalData
247
+ const trackElem = refTrackElem.value
169
248
  if (trackElem) {
170
- trackElem.style.left = `${startPercent}%`
171
- trackElem.style.width = `${endPercent}%`
172
- }
173
- if (startBtnElem) {
174
- startBtnElem.style.left = `${startPercent}%`
175
- }
176
- if (endBtnElem) {
177
- endBtnElem.style.left = `${XEUtils.floor(startPercent + endPercent)}%`
249
+ if (range) {
250
+ const [sVal, eVal] = XEUtils.orderBy([startValue, endValue])
251
+ trackElem.style.left = getBarPercent(sVal) + '%'
252
+ trackElem.style.width = getBarPercent(eVal - sVal) + '%'
253
+ } else {
254
+ trackElem.style.left = '0'
255
+ trackElem.style.width = getBarPercent(currValue) + '%'
256
+ }
178
257
  }
179
258
  }
180
259
 
181
260
  const changeEvent = (evnt: MouseEvent) => {
182
261
  const { range } = props
183
- const { startValue, endValue } = reactData
184
- const value = range ? [startValue, endValue].sort() : endValue
262
+ const { currValue, startValue, endValue } = internalData
263
+ const vals = range ? XEUtils.orderBy([startValue, endValue]) : []
264
+ const value = range ? vals : currValue
185
265
  emitModel(value)
266
+ if (range) {
267
+ emit('update:startValue', vals[0] || 0)
268
+ emit('update:endValue', vals[1] || 0)
269
+ }
186
270
  dispatchEvent('change', { value }, evnt)
187
271
  // 自动更新校验状态
188
272
  if ($xeForm && formItemInfo) {
@@ -190,11 +274,23 @@ export default defineVxeComponent({
190
274
  }
191
275
  }
192
276
 
193
- const handleMousedownEvent = (evnt: MouseEvent, isEnd: boolean) => {
194
- const formReadonly = computeFormReadonly.value
195
- const isDisabled = computeIsDisabled.value
277
+ const getValueByLeft = (offsetLeft: number, barWidth: number) => {
196
278
  const maxNum = computeMaxNum.value
197
279
  const minNum = computeMinNum.value
280
+ if (barWidth === 0) {
281
+ return minNum
282
+ }
283
+ const clamped = Math.max(0, Math.min(barWidth, offsetLeft))
284
+ const ratio = clamped / barWidth
285
+ const raw = minNum + ratio * (maxNum - minNum)
286
+ return Math.floor(raw)
287
+ }
288
+
289
+ const handleBtnMousedownEvent = (evnt: MouseEvent) => {
290
+ const { range, immediate } = props
291
+ const btnElem = evnt.currentTarget as HTMLDivElement
292
+ const formReadonly = computeFormReadonly.value
293
+ const isDisabled = computeIsDisabled.value
198
294
  if (!(formReadonly || isDisabled)) {
199
295
  evnt.preventDefault()
200
296
  document.onmousemove = evnt => {
@@ -202,40 +298,50 @@ export default defineVxeComponent({
202
298
  const el = refElem.value
203
299
  const barElem = refBarElem.value
204
300
  if (el && barElem) {
301
+ const btnType = btnElem.getAttribute('data-type')
205
302
  const barRect = barElem.getBoundingClientRect()
206
- const trackWidth = (evnt.clientX - barRect.left) / barRect.width
207
- if (isEnd) {
208
- reactData.endValue = XEUtils.floor(Math.max(minNum, Math.min(maxNum, trackWidth * (maxNum - minNum) + minNum)))
209
- } else {
210
- reactData.startValue = XEUtils.floor(Math.max(minNum, Math.min(maxNum, trackWidth * (maxNum - minNum))))
303
+ const barWidth = barRect.width
304
+ const offsetLeft = Math.min(barWidth, Math.max(0, evnt.clientX - barRect.left))
305
+ const currValue = getValueByLeft(offsetLeft, barWidth)
306
+ if (range) {
307
+ if (btnType === '1') {
308
+ internalData.startValue = currValue
309
+ } else {
310
+ internalData.endValue = currValue
311
+ }
211
312
  }
212
- dispatchEvent('track-dragover', { startValue: reactData.startValue, endValue: reactData.endValue }, evnt)
313
+ internalData.currValue = currValue
314
+ btnElem.style.left = getBarPercent(currValue) + '%'
315
+ dispatchEvent('track-dragover', {
316
+ currentValue: internalData.currValue,
317
+ startValue: internalData.startValue,
318
+ endValue: internalData.endValue
319
+ }, evnt)
213
320
  }
214
- updateBarStyle()
321
+ if (immediate) {
322
+ changeEvent(evnt)
323
+ }
324
+ updateTrackStyle()
215
325
  }
216
326
  document.onmouseup = (evnt: MouseEvent) => {
217
327
  document.onmousemove = null
218
328
  document.onmouseup = null
219
- dispatchEvent('track-dragend', { startValue: reactData.startValue, endValue: reactData.endValue }, evnt)
329
+ dispatchEvent('track-dragend', {
330
+ currentValue: internalData.currValue,
331
+ startValue: internalData.startValue,
332
+ endValue: internalData.endValue
333
+ }, evnt)
220
334
  changeEvent(evnt)
221
- updateBarStyle()
335
+ updateTrackStyle()
222
336
  }
223
- dispatchEvent('track-dragstart', { startValue: reactData.startValue, endValue: reactData.endValue }, evnt)
337
+ dispatchEvent('track-dragstart', {
338
+ currentValue: internalData.currValue,
339
+ startValue: internalData.startValue,
340
+ endValue: internalData.endValue
341
+ }, evnt)
224
342
  }
225
343
  }
226
344
 
227
- const handleStartMousedownEvent = (evnt: MouseEvent) => {
228
- const endBtnElem = refEndBtnElem.value
229
- const startBtnElem = evnt.currentTarget as HTMLDivElement
230
- handleMousedownEvent(evnt, endBtnElem ? endBtnElem.offsetLeft < startBtnElem.offsetLeft : false)
231
- }
232
-
233
- const handleEndMousedownEvent = (evnt: MouseEvent) => {
234
- const startBtnElem = refStartBtnElem.value
235
- const endBtnElem = evnt.currentTarget as HTMLDivElement
236
- handleMousedownEvent(evnt, startBtnElem ? endBtnElem.offsetLeft > startBtnElem.offsetLeft : true)
237
- }
238
-
239
345
  const collapsePanePrivateMethods: SliderPrivateMethods = {
240
346
  }
241
347
 
@@ -270,29 +376,44 @@ export default defineVxeComponent({
270
376
  ? renderEmptyElement($xeSlider)
271
377
  : h('div', {
272
378
  ref: refStartBtnElem,
273
- class: 'vxe-slider--bar-btn vxe-slider--start-btn',
274
- onMousedown: handleStartMousedownEvent
379
+ class: 'vxe-slider--bar-btn',
380
+ 'data-type': '1',
381
+ onMousedown: handleBtnMousedownEvent
275
382
  }),
276
383
  formReadonly
277
384
  ? renderEmptyElement($xeSlider)
278
385
  : h('div', {
279
386
  ref: refEndBtnElem,
280
- class: 'vxe-slider--bar-btn vxe-slider--end-btn',
281
- onMousedown: handleEndMousedownEvent
387
+ class: 'vxe-slider--bar-btn',
388
+ 'data-type': '2',
389
+ onMousedown: handleBtnMousedownEvent
282
390
  })
283
391
  ])
284
392
  ])
285
393
  }
286
394
 
287
395
  watch(() => props.modelValue, () => {
288
- updateModel()
396
+ if (!internalData._isUp) {
397
+ updateModelValue(1)
398
+ }
399
+ internalData._isUp = false
400
+ })
401
+
402
+ watch(computeMVal, () => {
403
+ if (!internalData._isUp) {
404
+ updateModelValue(2)
405
+ }
406
+ internalData._isUp = false
289
407
  })
290
408
 
291
409
  onMounted(() => {
292
- updateBarStyle()
410
+ updateModelValue()
293
411
  })
294
412
 
295
- updateModel()
413
+ onBeforeUnmount(() => {
414
+ XEUtils.assign(reactData, createReactData())
415
+ XEUtils.assign(internalData, createInternalData())
416
+ })
296
417
 
297
418
  $xeSlider.renderVN = renderVN
298
419
 
@@ -0,0 +1,16 @@
1
+ import { App } from 'vue'
2
+ import { VxeUI } from '@vxe-ui/core'
3
+ import VxeSpaceComponent from './src/space'
4
+ import { dynamicApp } from '../dynamics'
5
+
6
+ export const VxeSpace = Object.assign({}, VxeSpaceComponent, {
7
+ install (app: App) {
8
+ app.component(VxeSpaceComponent.name as string, VxeSpaceComponent)
9
+ }
10
+ })
11
+
12
+ dynamicApp.use(VxeSpace)
13
+ VxeUI.component(VxeSpaceComponent)
14
+
15
+ export const Space = VxeSpace
16
+ export default VxeSpace
@@ -0,0 +1,167 @@
1
+ import { ref, h, PropType, computed, reactive, VNode } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { getConfig, createEvent, useSize } from '../../ui'
5
+ import { getPropClass, toCssUnit } from '../../ui/src/dom'
6
+ import { eqEmptyValue } from '../../ui/src/utils'
7
+
8
+ import type { SpaceReactData, VxeSpaceEmits, SpaceMethods, VxeSpacePropTypes, SpacePrivateMethods, ValueOf, SpacePrivateRef, VxeSpacePrivateComputed, VxeSpaceConstructor, VxeSpacePrivateMethods, VxeComponentStyleType } from '../../../types'
9
+
10
+ export default defineVxeComponent({
11
+ name: 'VxeSpace',
12
+ props: {
13
+ size: {
14
+ type: String as PropType<VxeSpacePropTypes.Size>,
15
+ default: () => getConfig().space.size || getConfig().size
16
+ },
17
+ wrap: {
18
+ type: Boolean as PropType<VxeSpacePropTypes.Wrap>,
19
+ default: () => getConfig().space.wrap
20
+ },
21
+ gap: {
22
+ type: [Number, String, Array, Object] as PropType<VxeSpacePropTypes.Gap>,
23
+ default: () => getConfig().space.gap
24
+ },
25
+ vertical: {
26
+ type: Boolean as PropType<VxeSpacePropTypes.Vertical>,
27
+ default: () => getConfig().space.vertical
28
+ },
29
+ className: {
30
+ type: String as PropType<VxeSpacePropTypes.ClassName>,
31
+ default: () => getConfig().space.className
32
+ },
33
+ itemClassName: {
34
+ type: String as PropType<VxeSpacePropTypes.ItemClassName>,
35
+ default: () => getConfig().space.itemClassName
36
+ },
37
+ separator: {
38
+ type: String as PropType<VxeSpacePropTypes.Separator>,
39
+ default: () => getConfig().space.separator
40
+ },
41
+ align: {
42
+ type: String as PropType<VxeSpacePropTypes.Align>,
43
+ default: () => getConfig().space.align
44
+ }
45
+ },
46
+ emits: [] as VxeSpaceEmits,
47
+ setup (props, context) {
48
+ const { emit, slots } = context
49
+
50
+ const xID = XEUtils.uniqueId()
51
+
52
+ const { computeSize } = useSize(props)
53
+
54
+ const refElem = ref<HTMLDivElement>()
55
+
56
+ const reactData = reactive<SpaceReactData>({
57
+ activeValue: null
58
+ })
59
+
60
+ const refMaps: SpacePrivateRef = {
61
+ refElem
62
+ }
63
+
64
+ const computeWrapperStyle = computed(() => {
65
+ const { align, gap } = props
66
+ const stys: VxeComponentStyleType = {}
67
+ let rowGap: string | number = ''
68
+ let columGap: string | number = ''
69
+ if (XEUtils.isNumber(gap) || XEUtils.isString(gap)) {
70
+ rowGap = gap
71
+ columGap = gap
72
+ } else if (gap) {
73
+ if (XEUtils.isArray(gap)) {
74
+ rowGap = gap[0]
75
+ columGap = gap[1]
76
+ } else {
77
+ rowGap = gap.rowGap || ''
78
+ columGap = gap.columGap || ''
79
+ }
80
+ }
81
+ if (align) {
82
+ stys['align-items'] = align
83
+ }
84
+ if (!eqEmptyValue(rowGap)) {
85
+ stys['--vxe-ui-space-current-row-gap'] = toCssUnit(rowGap)
86
+ }
87
+ if (!eqEmptyValue(columGap)) {
88
+ stys['--vxe-ui-space-current-column-gap'] = toCssUnit(columGap)
89
+ }
90
+ return stys
91
+ })
92
+
93
+ const computeMaps: VxeSpacePrivateComputed = {
94
+ }
95
+
96
+ const $xeSpace = {
97
+ xID,
98
+ props,
99
+ context,
100
+ reactData,
101
+
102
+ getRefMaps: () => refMaps,
103
+ getComputeMaps: () => computeMaps
104
+ } as unknown as VxeSpaceConstructor & VxeSpacePrivateMethods
105
+
106
+ const dispatchEvent = (type: ValueOf<VxeSpaceEmits>, params: Record<string, any>, evnt: Event | null) => {
107
+ emit(type, createEvent(evnt, { $space: $xeSpace }, params))
108
+ }
109
+
110
+ const spaceMethods: SpaceMethods = {
111
+ dispatchEvent
112
+ }
113
+
114
+ const spacePrivateMethods: SpacePrivateMethods = {
115
+ }
116
+
117
+ Object.assign($xeSpace, spaceMethods, spacePrivateMethods)
118
+
119
+ const renderItems = () => {
120
+ const { separator, itemClassName } = props
121
+ const itemVNs: VNode[] = []
122
+ const defaultSlot = slots.default
123
+ const separatorSlot = slots.separator
124
+ if (defaultSlot) {
125
+ XEUtils.each(defaultSlot({}), (itemVN, index, items) => {
126
+ itemVNs.push(
127
+ h('div', {
128
+ key: 'i' + index,
129
+ class: ['vxe-space--item', getPropClass(itemClassName, { index })]
130
+ }, [itemVN])
131
+ )
132
+ if ((separator || separatorSlot) && index < items.length - 1) {
133
+ itemVNs.push(
134
+ h('div', {
135
+ key: 's' + index,
136
+ class: 'vxe-space--separator'
137
+ }, separatorSlot ? separatorSlot({}) : ('' + separator))
138
+ )
139
+ }
140
+ })
141
+ }
142
+ return itemVNs
143
+ }
144
+
145
+ const renderVN = () => {
146
+ const { vertical, wrap, className } = props
147
+ const wrapperStyle = computeWrapperStyle.value
148
+ const vSize = computeSize.value
149
+ return h('div', {
150
+ ref: refElem,
151
+ class: ['vxe-space', getPropClass(className, {}), {
152
+ [`size--${vSize}`]: vSize,
153
+ 'is--wrap': wrap,
154
+ 'is--vertical': vertical
155
+ }],
156
+ style: wrapperStyle
157
+ }, renderItems())
158
+ }
159
+
160
+ $xeSpace.renderVN = renderVN
161
+
162
+ return $xeSpace
163
+ },
164
+ render () {
165
+ return this.renderVN()
166
+ }
167
+ })
@@ -382,6 +382,7 @@ setConfig({
382
382
  max: 100,
383
383
  min: 0
384
384
  },
385
+ space: {},
385
386
  steps: {},
386
387
  switch: {},
387
388
  tabPane: {},
@@ -17,6 +17,10 @@ export function getTpImg () {
17
17
  return tpImgEl
18
18
  }
19
19
 
20
+ export function getPropClass (property: any, params: any) {
21
+ return property ? (XEUtils.isFunction(property) ? property(params) : property) || '' : ''
22
+ }
23
+
20
24
  const reClsMap: { [key: string]: any } = {}
21
25
 
22
26
  function getClsRE (cls: any) {
@@ -83,7 +83,7 @@ export default defineVxeComponent({
83
83
  emit(type, createEvent(evnt, { $watermark: $xeWatermark }, params))
84
84
  }
85
85
 
86
- const collapsePaneMethods: WatermarkMethods = {
86
+ const watermarkMethods: WatermarkMethods = {
87
87
  dispatchEvent
88
88
  }
89
89
 
@@ -105,10 +105,10 @@ export default defineVxeComponent({
105
105
  }
106
106
  }
107
107
 
108
- const collapsePanePrivateMethods: WatermarkPrivateMethods = {
108
+ const watermarkPrivateMethods: WatermarkPrivateMethods = {
109
109
  }
110
110
 
111
- Object.assign($xeWatermark, collapsePaneMethods, collapsePanePrivateMethods)
111
+ Object.assign($xeWatermark, watermarkMethods, watermarkPrivateMethods)
112
112
 
113
113
  const renderVN = () => {
114
114
  const wrapperStyle = computeWrapperStyle.value
package/styles/all.scss CHANGED
@@ -70,6 +70,7 @@
70
70
  @use './components/split.scss';
71
71
  @use './components/split-pane.scss';
72
72
  @use './components/slider.scss';
73
+ @use './components/space.scss';
73
74
  @use './components/steps.scss';
74
75
  @use './components/switch.scss';
75
76
  @use './components/tab-pane.scss';
@@ -50,7 +50,7 @@ $sliderThemeList: (
50
50
  .vxe-slider {
51
51
  position: relative;
52
52
  display: block;
53
- padding: 0.5em 1em;
53
+ padding: 0.8em;
54
54
  @for $index from 0 to list.length($sliderThemeList) {
55
55
  $item: list.nth($sliderThemeList, $index + 1);
56
56
  &.theme--#{map.get($item, name)} {
@@ -80,10 +80,10 @@ $sliderThemeList: (
80
80
  }
81
81
  .vxe-slider--bar-btn {
82
82
  &:hover {
83
- transform: scale(1.2);
83
+ transform: translate(-50%, -50%) scale(1.2);
84
84
  }
85
85
  &:active {
86
- transform: scale(1.1);
86
+ transform: translate(-50%, -50%) scale(1.1);
87
87
  }
88
88
  }
89
89
  }
@@ -122,19 +122,14 @@ $sliderThemeList: (
122
122
 
123
123
  .vxe-slider--bar-btn {
124
124
  position: absolute;
125
- width: 0.9em;
126
- height: 0.9em;
127
- top: -0.3em;
125
+ width: 1.2em;
126
+ height: 1.2em;
127
+ top: 50%;
128
+ transform: translate(-50%, -50%);
128
129
  border-radius: 50%;
129
- border: 0.15em solid var(--vxe-ui-font-primary-color);
130
+ border: 2px solid var(--vxe-ui-font-primary-color);
130
131
  background-color: #fff;
131
132
  cursor: pointer;
132
133
  z-index: 1;
133
134
  @include baseMixin.createAnimationTransition(transform, 0.1s);
134
- }
135
- .vxe-slider--start-btn {
136
- left: -0.45em;
137
- }
138
- .vxe-slider--end-btn {
139
- right: -0.45em;
140
135
  }