vxe-pc-ui 4.20.32 → 4.20.34
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/dist/all.esm.js +788 -584
- package/dist/all.esm.min.js +3 -3
- package/dist/style.css +127 -2
- package/dist/style.mini.css +1 -1
- package/es/dynamics/index.d.ts +1 -0
- package/es/icon/style.css +1 -1
- package/es/icon/style.mini.css +1 -1
- package/es/modal/index.d.ts +38 -0
- package/es/modal/src/modal.d.ts +9 -0
- package/es/modal/src/modal.js +66 -44
- package/es/select/src/option.js +2 -1
- package/es/select/src/select.js +25 -20
- package/es/style.css +127 -2
- package/es/style.mini.css +1 -1
- package/es/timeline/index.d.ts +92 -0
- package/es/timeline/src/timeline-info.d.ts +6 -0
- package/es/timeline/src/timeline-info.js +19 -0
- package/es/timeline/src/timeline-item.d.ts +11 -8
- package/es/timeline/src/timeline-item.js +33 -45
- package/es/timeline/src/timeline.d.ts +22 -0
- package/es/timeline/src/timeline.js +182 -48
- package/es/timeline/src/util.d.ts +7 -0
- package/es/timeline/src/util.js +41 -0
- package/es/timeline/style.css +122 -0
- package/es/timeline/style.mini.css +1 -0
- package/es/timeline-item/index.d.ts +42 -34
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-icon/style.css +1 -1
- package/es/vxe-icon/style.mini.css +1 -1
- package/es/vxe-timeline/style.css +122 -0
- package/es/vxe-timeline/style.mini.css +1 -0
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.mini.css +1 -1
- package/lib/index.umd.js +976 -771
- package/lib/index.umd.min.js +3 -3
- package/lib/modal/src/modal.js +66 -44
- package/lib/select/src/option.js +2 -1
- package/lib/select/src/select.js +25 -20
- package/lib/style.css +127 -2
- package/lib/style.mini.css +1 -1
- package/lib/timeline/src/timeline-info.js +48 -0
- package/lib/timeline/src/timeline-item.js +32 -54
- package/lib/timeline/src/timeline.js +181 -47
- package/lib/timeline/src/util.js +71 -0
- package/lib/timeline/style/style.css +122 -0
- package/lib/timeline/style/style.mini.css +1 -0
- package/lib/ui/index.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/vxe-icon/style/style.css +1 -1
- package/lib/vxe-icon/style/style.mini.css +1 -1
- package/lib/vxe-timeline/style/style.css +122 -0
- package/lib/vxe-timeline/style/style.mini.css +1 -0
- package/package.json +10 -3
- package/packages/modal/src/modal.ts +90 -47
- package/packages/select/src/option.ts +3 -1
- package/packages/select/src/select.ts +25 -20
- package/packages/slider/src/slider.ts +1 -16
- package/packages/timeline/src/timeline-info.ts +17 -0
- package/packages/timeline/src/timeline-item.ts +25 -50
- package/packages/timeline/src/timeline.ts +154 -15
- package/packages/timeline/src/util.ts +41 -0
- package/styles/components/timeline.scss +133 -0
- package/styles/theme/dark.scss +2 -1
- package/styles/theme/light.scss +1 -0
- package/styles/variable.scss +2 -1
- package/types/components/modal.d.ts +2 -0
- package/types/components/optgroup.d.ts +0 -1
- package/types/components/option.d.ts +0 -1
- package/types/components/timeline-item.d.ts +21 -17
- package/types/components/timeline.d.ts +41 -8
- /package/dist/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/dist/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/dist/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/es/icon/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/es/icon/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/es/icon/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/es/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/es/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/es/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/es/vxe-icon/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/es/vxe-icon/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/es/vxe-icon/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/lib/icon/style/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/lib/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/lib/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/lib/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793082793047.ttf → iconfont.1793330162657.ttf} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793082793047.woff → iconfont.1793330162657.woff} +0 -0
- /package/lib/vxe-icon/style/{iconfont.1793082793047.woff2 → iconfont.1793330162657.woff2} +0 -0
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
} from '../../../types'
|
|
32
32
|
import type { VxeTableConstructor, VxeTablePrivateMethods } from '../../../types/components/table'
|
|
33
33
|
|
|
34
|
-
const { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useFns, renderEmptyElement } = VxeUI
|
|
34
|
+
const { getConfig, getIcon, getI18n, dbUtils, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useFns, renderEmptyElement } = VxeUI
|
|
35
35
|
|
|
36
36
|
const { warnLog, errLog } = createComponentLog('modal')
|
|
37
37
|
|
|
@@ -229,6 +229,10 @@ export default defineVxeComponent({
|
|
|
229
229
|
type: Boolean as PropType<VxeModalPropTypes.Storage>,
|
|
230
230
|
default: () => getConfig().modal.storage
|
|
231
231
|
},
|
|
232
|
+
storeDriver: {
|
|
233
|
+
type: String as PropType<VxeModalPropTypes.StoreDriver>,
|
|
234
|
+
default: () => getConfig().modal.storeDriver
|
|
235
|
+
},
|
|
232
236
|
storageKey: {
|
|
233
237
|
type: String as PropType<VxeModalPropTypes.StorageKey>,
|
|
234
238
|
default: () => getConfig().modal.storageKey
|
|
@@ -361,7 +365,9 @@ export default defineVxeComponent({
|
|
|
361
365
|
getComputeMaps: () => computeMaps
|
|
362
366
|
} as unknown as VxeModalConstructor & VxeModalMethods
|
|
363
367
|
|
|
364
|
-
|
|
368
|
+
const posStoreDB = dbUtils.createStore<string>(props.storageKey, {
|
|
369
|
+
driver: props.storeDriver
|
|
370
|
+
})
|
|
365
371
|
|
|
366
372
|
const getBox = () => {
|
|
367
373
|
const boxElem = refModalBox.value
|
|
@@ -534,45 +540,58 @@ export default defineVxeComponent({
|
|
|
534
540
|
}
|
|
535
541
|
}
|
|
536
542
|
|
|
537
|
-
const getStorageMap = (key: string) => {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
543
|
+
const getStorageMap = (key: string, id: string) => {
|
|
544
|
+
// if (posStoreDB) {
|
|
545
|
+
return posStoreDB.getById(id).then(dbRest => dbRest ? dbRest.data : '')
|
|
546
|
+
// }
|
|
547
|
+
// // 已废弃,兼容旧版本
|
|
548
|
+
// return new Promise<string>(resolve => {
|
|
549
|
+
// const version = getConfig().version
|
|
550
|
+
// const rest = XEUtils.toStringJSON(localStorage.getItem(key) || '')
|
|
551
|
+
// const maps = rest && rest._v === version ? rest : { _v: version }
|
|
552
|
+
// resolve(maps[id] || '')
|
|
553
|
+
// })
|
|
541
554
|
}
|
|
542
555
|
|
|
543
|
-
const
|
|
544
|
-
const {
|
|
545
|
-
|
|
556
|
+
const saveStorageMap = (id: string, posStorage: string) => {
|
|
557
|
+
// const { storageKey } = props
|
|
558
|
+
|
|
559
|
+
// if (posStoreDB) {
|
|
560
|
+
return posStoreDB.updateById(id, posStorage)
|
|
561
|
+
// }
|
|
562
|
+
// // 已废弃,兼容旧版本
|
|
563
|
+
// const version = getConfig().version
|
|
564
|
+
// const rest = XEUtils.toStringJSON(localStorage.getItem(storageKey) || '')
|
|
565
|
+
// const posStorageMap = rest && rest._v === version ? rest : { _v: version }
|
|
566
|
+
// posStorageMap[id] = posStorage
|
|
567
|
+
// localStorage.setItem(storageKey, XEUtils.toJSONString(posStorageMap))
|
|
568
|
+
// return Promise.resolve()
|
|
546
569
|
}
|
|
547
570
|
|
|
548
|
-
const restorePosStorage = () => {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const
|
|
552
|
-
if (
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
if (boxElem) {
|
|
556
|
-
if (left) {
|
|
557
|
-
boxElem.style.left = `${left}px`
|
|
558
|
-
}
|
|
559
|
-
if (top) {
|
|
560
|
-
boxElem.style.top = `${top}px`
|
|
561
|
-
}
|
|
562
|
-
if (width) {
|
|
563
|
-
boxElem.style.width = `${width}px`
|
|
564
|
-
}
|
|
565
|
-
if (height) {
|
|
566
|
-
boxElem.style.height = `${height}px`
|
|
567
|
-
}
|
|
571
|
+
const restorePosStorage = (posStorage: string) => {
|
|
572
|
+
if (posStorage) {
|
|
573
|
+
const boxElem = getBox()
|
|
574
|
+
const [left, top, width, height, zoomLeft, zoomTop, zoomWidth, zoomHeight] = posStorage.split(',')
|
|
575
|
+
if (boxElem) {
|
|
576
|
+
if (left) {
|
|
577
|
+
boxElem.style.left = `${left}px`
|
|
568
578
|
}
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
579
|
+
if (top) {
|
|
580
|
+
boxElem.style.top = `${top}px`
|
|
581
|
+
}
|
|
582
|
+
if (width) {
|
|
583
|
+
boxElem.style.width = `${width}px`
|
|
584
|
+
}
|
|
585
|
+
if (height) {
|
|
586
|
+
boxElem.style.height = `${height}px`
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
if (zoomLeft && zoomTop) {
|
|
590
|
+
reactData.revertLocat = {
|
|
591
|
+
left: XEUtils.toNumber(zoomLeft),
|
|
592
|
+
top: XEUtils.toNumber(zoomTop),
|
|
593
|
+
width: XEUtils.toNumber(zoomWidth),
|
|
594
|
+
height: XEUtils.toNumber(zoomHeight)
|
|
576
595
|
}
|
|
577
596
|
}
|
|
578
597
|
}
|
|
@@ -588,7 +607,7 @@ export default defineVxeComponent({
|
|
|
588
607
|
}
|
|
589
608
|
|
|
590
609
|
const savePosStorage = () => {
|
|
591
|
-
const { id, storage
|
|
610
|
+
const { id, storage } = props
|
|
592
611
|
const { zoomStatus, revertLocat } = reactData
|
|
593
612
|
if (zoomStatus) {
|
|
594
613
|
return
|
|
@@ -598,12 +617,23 @@ export default defineVxeComponent({
|
|
|
598
617
|
if (!boxElem) {
|
|
599
618
|
return
|
|
600
619
|
}
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
.
|
|
604
|
-
.
|
|
605
|
-
.
|
|
606
|
-
|
|
620
|
+
const posStorage = [
|
|
621
|
+
boxElem.style.left,
|
|
622
|
+
boxElem.style.top,
|
|
623
|
+
boxElem.clientWidth,
|
|
624
|
+
boxElem.clientHeight,
|
|
625
|
+
...(
|
|
626
|
+
revertLocat
|
|
627
|
+
? [
|
|
628
|
+
revertLocat.left,
|
|
629
|
+
revertLocat.top,
|
|
630
|
+
revertLocat.width,
|
|
631
|
+
revertLocat.height
|
|
632
|
+
]
|
|
633
|
+
: []
|
|
634
|
+
)
|
|
635
|
+
].map((val) => (val ? XEUtils.toNumber(val) : '')).join(',')
|
|
636
|
+
saveStorageMap(id, posStorage)
|
|
607
637
|
}
|
|
608
638
|
}
|
|
609
639
|
|
|
@@ -799,7 +829,7 @@ export default defineVxeComponent({
|
|
|
799
829
|
}
|
|
800
830
|
|
|
801
831
|
const openModal = () => {
|
|
802
|
-
const { remember, showFooter, fullscreen } = props
|
|
832
|
+
const { storageKey, id, remember, showFooter, fullscreen } = props
|
|
803
833
|
const { initialized, visible } = reactData
|
|
804
834
|
const isMsg = computeIsMsg.value
|
|
805
835
|
const isModal = computeIsModal.value
|
|
@@ -845,8 +875,21 @@ export default defineVxeComponent({
|
|
|
845
875
|
}
|
|
846
876
|
if (firstOpen) {
|
|
847
877
|
reactData.firstOpen = false
|
|
848
|
-
if (
|
|
849
|
-
|
|
878
|
+
if (storageKey && id) {
|
|
879
|
+
getStorageMap(storageKey, id).then(posStorage => {
|
|
880
|
+
if (posStorage) {
|
|
881
|
+
restorePosStorage(posStorage)
|
|
882
|
+
} else {
|
|
883
|
+
if (isModal && fullscreen) {
|
|
884
|
+
nextTick(() => handleMaximize())
|
|
885
|
+
} else {
|
|
886
|
+
recalculate()
|
|
887
|
+
updatePosition().then(() => {
|
|
888
|
+
setTimeout(() => updatePosition(), 20)
|
|
889
|
+
})
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
})
|
|
850
893
|
} else {
|
|
851
894
|
if (isModal && fullscreen) {
|
|
852
895
|
nextTick(() => handleMaximize())
|
|
@@ -1270,7 +1313,7 @@ export default defineVxeComponent({
|
|
|
1270
1313
|
emit('update:modelValue', value)
|
|
1271
1314
|
}
|
|
1272
1315
|
|
|
1273
|
-
modalMethods = {
|
|
1316
|
+
const modalMethods: ModalMethods = {
|
|
1274
1317
|
dispatchEvent,
|
|
1275
1318
|
open: openModal,
|
|
1276
1319
|
close() {
|
|
@@ -20,7 +20,9 @@ export default defineVxeComponent({
|
|
|
20
20
|
disabled: Boolean as PropType<VxeOptionPropTypes.Disabled>
|
|
21
21
|
},
|
|
22
22
|
emits: [] as VxeOptionEmits,
|
|
23
|
-
setup(props,
|
|
23
|
+
setup(props, context) {
|
|
24
|
+
const { slots } = context
|
|
25
|
+
|
|
24
26
|
const elem = ref() as Ref<HTMLDivElement>
|
|
25
27
|
const $xeSelect = inject('$xeSelect', {} as VxeSelectConstructor)
|
|
26
28
|
const $xeOptgroup = inject<XEOptionProvide | null>('$xeOptgroup', null)
|
|
@@ -350,11 +350,11 @@ export default defineVxeComponent({
|
|
|
350
350
|
return Object.assign({}, props.defaultConfig)
|
|
351
351
|
})
|
|
352
352
|
const computePropsOpts = computed(() => {
|
|
353
|
-
return Object.assign({}, props.optionProps)
|
|
353
|
+
return Object.assign({}, getConfig().select.optionProps, props.optionProps)
|
|
354
354
|
})
|
|
355
355
|
|
|
356
356
|
const computeGroupPropsOpts = computed(() => {
|
|
357
|
-
return Object.assign({}, props.optionGroupProps)
|
|
357
|
+
return Object.assign({}, getConfig().select.optionGroupProps, props.optionGroupProps)
|
|
358
358
|
})
|
|
359
359
|
|
|
360
360
|
const computeLabelField = computed(() => {
|
|
@@ -2285,26 +2285,31 @@ export default defineVxeComponent({
|
|
|
2285
2285
|
)
|
|
2286
2286
|
}
|
|
2287
2287
|
|
|
2288
|
-
watch(
|
|
2289
|
-
()
|
|
2290
|
-
|
|
2291
|
-
loadData(val)
|
|
2292
|
-
}
|
|
2293
|
-
)
|
|
2288
|
+
watch(() => reactData.staticOptions, (val) => {
|
|
2289
|
+
loadData(val)
|
|
2290
|
+
})
|
|
2294
2291
|
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2292
|
+
const refOptsFlag = ref(0)
|
|
2293
|
+
watch(() => props.options, () => {
|
|
2294
|
+
refOptsFlag.value++
|
|
2295
|
+
})
|
|
2296
|
+
watch(() => props.options ? props.options.length : -1, () => {
|
|
2297
|
+
refOptsFlag.value++
|
|
2298
|
+
})
|
|
2299
|
+
watch(refOptsFlag, () => {
|
|
2300
|
+
loadData(props.options || [])
|
|
2301
|
+
})
|
|
2301
2302
|
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2303
|
+
const refOptGrpsFlag = ref(0)
|
|
2304
|
+
watch(() => props.optionGroups, () => {
|
|
2305
|
+
refOptGrpsFlag.value++
|
|
2306
|
+
})
|
|
2307
|
+
watch(() => props.optionGroups ? props.optionGroups.length : -1, () => {
|
|
2308
|
+
refOptGrpsFlag.value++
|
|
2309
|
+
})
|
|
2310
|
+
watch(refOptGrpsFlag, () => {
|
|
2311
|
+
loadData(props.optionGroups || [])
|
|
2312
|
+
})
|
|
2308
2313
|
|
|
2309
2314
|
const reScrollFlag = ref(0)
|
|
2310
2315
|
const reLayoutFlag = ref(0)
|
|
@@ -4,22 +4,7 @@ import XEUtils from 'xe-utils'
|
|
|
4
4
|
import { VxeUI } from '@vxe-ui/core'
|
|
5
5
|
import { getText } from '../../ui/src/utils'
|
|
6
6
|
|
|
7
|
-
import type {
|
|
8
|
-
SliderReactData,
|
|
9
|
-
SliderInternalData,
|
|
10
|
-
VxeSliderEmits,
|
|
11
|
-
VxeSliderPropTypes,
|
|
12
|
-
SliderMethods,
|
|
13
|
-
VxeFormDefines,
|
|
14
|
-
VxeFormConstructor,
|
|
15
|
-
VxeFormPrivateMethods,
|
|
16
|
-
SliderPrivateMethods,
|
|
17
|
-
ValueOf,
|
|
18
|
-
SliderPrivateRef,
|
|
19
|
-
VxeSliderPrivateComputed,
|
|
20
|
-
VxeSliderConstructor,
|
|
21
|
-
VxeSliderPrivateMethods
|
|
22
|
-
} from '../../../types'
|
|
7
|
+
import type { SliderReactData, SliderInternalData, VxeSliderEmits, VxeSliderPropTypes, SliderMethods, VxeFormDefines, VxeFormConstructor, VxeFormPrivateMethods, SliderPrivateMethods, ValueOf, SliderPrivateRef, VxeSliderPrivateComputed, VxeSliderConstructor, VxeSliderPrivateMethods } from '../../../types'
|
|
23
8
|
|
|
24
9
|
const { getConfig, createEvent, renderEmptyElement, useFns } = VxeUI
|
|
25
10
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import XEUtils from 'xe-utils'
|
|
2
|
+
|
|
3
|
+
export class TimelineItemInfo {
|
|
4
|
+
id = XEUtils.uniqueId('timeline_item_')
|
|
5
|
+
constructor($xeTimeline: any, _vm: any) {
|
|
6
|
+
Object.assign(this, {
|
|
7
|
+
title: _vm.title,
|
|
8
|
+
content: _vm.content
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
update(name: any, value: any) {
|
|
13
|
+
this[name] = value
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
[key: string]: any
|
|
17
|
+
}
|
|
@@ -1,65 +1,40 @@
|
|
|
1
|
-
import { ref, h,
|
|
1
|
+
import { ref, h, inject, PropType, onMounted, onUnmounted } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
|
-
import
|
|
4
|
-
import { VxeUI } from '@vxe-ui/core'
|
|
3
|
+
import { createTimelineItem, watchTimelineItem, assembleTimelineItem, destroyTimelineItem } from './util'
|
|
5
4
|
|
|
6
|
-
import type {
|
|
5
|
+
import type { VxeTimelineConstructor, VxeTimelineItemPropTypes } from '../../../types'
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default defineVxeComponent({
|
|
7
|
+
export default /* define-vxe-component start */ defineVxeComponent({
|
|
11
8
|
name: 'VxeTimelineItem',
|
|
12
|
-
props: {
|
|
13
|
-
|
|
9
|
+
props: {
|
|
10
|
+
title: [String, Number] as PropType<VxeTimelineItemPropTypes.Title>,
|
|
11
|
+
content: [String, Number] as PropType<VxeTimelineItemPropTypes.Content>
|
|
12
|
+
},
|
|
14
13
|
setup(props, context) {
|
|
15
|
-
const {
|
|
16
|
-
|
|
17
|
-
const xID = XEUtils.uniqueId()
|
|
14
|
+
const { slots } = context
|
|
18
15
|
|
|
19
16
|
const refElem = ref<HTMLDivElement>()
|
|
17
|
+
const $xeTimeline = inject('$xeTimeline', {} as VxeTimelineConstructor)
|
|
18
|
+
const itemConfig = createTimelineItem($xeTimeline, props)
|
|
19
|
+
itemConfig.slots = slots
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const refMaps: TimelineItemPrivateRef = {
|
|
24
|
-
refElem
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const computeMaps: VxeTimelineItemPrivateComputed = {}
|
|
21
|
+
watchTimelineItem(props, itemConfig)
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
const el = refElem.value
|
|
25
|
+
if (el) {
|
|
26
|
+
assembleTimelineItem($xeTimeline, el, itemConfig)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const dispatchEvent = (type: ValueOf<VxeTimelineItemEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
40
|
-
emit(type, createEvent(evnt, { $timelineItem: $xeTimelineItem }, params))
|
|
41
|
-
}
|
|
30
|
+
onUnmounted(() => {
|
|
31
|
+
destroyTimelineItem($xeTimeline, itemConfig)
|
|
32
|
+
})
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
dispatchEvent
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const tagPrivateMethods: TimelineItemPrivateMethods = {}
|
|
48
|
-
|
|
49
|
-
Object.assign($xeTimelineItem, tagMethods, tagPrivateMethods)
|
|
50
|
-
|
|
51
|
-
const renderVN = () => {
|
|
34
|
+
return () => {
|
|
52
35
|
return h('div', {
|
|
53
|
-
ref: refElem
|
|
54
|
-
class: 'vxe-timeline-item'
|
|
36
|
+
ref: refElem
|
|
55
37
|
})
|
|
56
38
|
}
|
|
57
|
-
|
|
58
|
-
$xeTimelineItem.renderVN = renderVN
|
|
59
|
-
|
|
60
|
-
return $xeTimelineItem
|
|
61
|
-
},
|
|
62
|
-
render() {
|
|
63
|
-
return this.renderVN()
|
|
64
39
|
}
|
|
65
|
-
})
|
|
40
|
+
}) /* define-vxe-component end */
|
|
@@ -1,65 +1,204 @@
|
|
|
1
|
-
import { ref, h, reactive, PropType } from 'vue'
|
|
1
|
+
import { ref, h, reactive, PropType, computed, watch, provide, onMounted, onBeforeUnmount } from 'vue'
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { VxeUI } from '@vxe-ui/core'
|
|
5
|
+
import { getText } from '../../ui/src/utils'
|
|
5
6
|
|
|
6
|
-
import type { TimelineReactData,
|
|
7
|
+
import type { TimelineReactData, TimelineInternalData, VxeTimelineEmits, VxeTimelinePropTypes, TimelineMethods, TimelinePrivateMethods, TimelinePrivateRef, TimelinePrivateComputed, VxeTimelineConstructor, VxeTimelinePrivateMethods, ValueOf } from '../../../types'
|
|
7
8
|
|
|
8
|
-
const { getConfig, createEvent } = VxeUI
|
|
9
|
+
const { getConfig, useFns, createEvent } = VxeUI
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
function createInternalData(): TimelineInternalData {
|
|
12
|
+
return {
|
|
13
|
+
fullData: []
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createReactData(): TimelineReactData {
|
|
18
|
+
return {
|
|
19
|
+
itemList: [],
|
|
20
|
+
staticItems: [],
|
|
21
|
+
isOptConf: false
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default /* define-vxe-component start */ defineVxeComponent({
|
|
11
26
|
name: 'VxeTimeline',
|
|
12
27
|
props: {
|
|
13
28
|
size: {
|
|
14
29
|
type: String as PropType<VxeTimelinePropTypes.Size>,
|
|
15
30
|
default: () => getConfig().timeline.size || getConfig().size
|
|
16
|
-
}
|
|
31
|
+
},
|
|
32
|
+
options: Array as PropType<VxeTimelinePropTypes.Options>,
|
|
33
|
+
reverse: {
|
|
34
|
+
type: Boolean as PropType<VxeTimelinePropTypes.Reverse>,
|
|
35
|
+
default: () => getConfig().timeline.reverse
|
|
36
|
+
},
|
|
37
|
+
vertical: {
|
|
38
|
+
type: Boolean as PropType<VxeTimelinePropTypes.Vertical>,
|
|
39
|
+
default: () => getConfig().timeline.vertical
|
|
40
|
+
},
|
|
41
|
+
optionProps: Object as PropType<VxeTimelinePropTypes.OptionProps>
|
|
17
42
|
},
|
|
18
43
|
emits: [] as VxeTimelineEmits,
|
|
19
44
|
setup(props, context) {
|
|
20
|
-
const { emit } = context
|
|
45
|
+
const { slots, emit } = context
|
|
21
46
|
|
|
22
47
|
const xID = XEUtils.uniqueId()
|
|
23
48
|
|
|
49
|
+
const { computeSize } = useFns.useSize(props)
|
|
50
|
+
|
|
24
51
|
const refElem = ref<HTMLDivElement>()
|
|
25
52
|
|
|
26
|
-
const reactData = reactive
|
|
53
|
+
const reactData = reactive(createReactData())
|
|
54
|
+
const internalData = createInternalData()
|
|
27
55
|
|
|
28
56
|
const refMaps: TimelinePrivateRef = {
|
|
29
57
|
refElem
|
|
30
58
|
}
|
|
31
59
|
|
|
32
|
-
const computeMaps:
|
|
60
|
+
const computeMaps: TimelinePrivateComputed = {}
|
|
33
61
|
|
|
34
62
|
const $xeTimeline = {
|
|
35
63
|
xID,
|
|
36
64
|
props,
|
|
37
65
|
context,
|
|
38
66
|
reactData,
|
|
39
|
-
|
|
67
|
+
internalData,
|
|
40
68
|
getRefMaps: () => refMaps,
|
|
41
69
|
getComputeMaps: () => computeMaps
|
|
42
70
|
} as unknown as VxeTimelineConstructor & VxeTimelinePrivateMethods
|
|
43
71
|
|
|
72
|
+
const computePropsOpts = computed(() => {
|
|
73
|
+
return Object.assign({}, getConfig().timeline.optionProps, props.optionProps)
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
const computeTitleField = computed(() => {
|
|
77
|
+
const propsOpts = computePropsOpts.value
|
|
78
|
+
return propsOpts.title || 'title'
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const computeContentField = computed(() => {
|
|
82
|
+
const propsOpts = computePropsOpts.value
|
|
83
|
+
return propsOpts.content || 'content'
|
|
84
|
+
})
|
|
85
|
+
|
|
44
86
|
const dispatchEvent = (type: ValueOf<VxeTimelineEmits>, params: Record<string, any>, evnt: Event | null) => {
|
|
45
87
|
emit(type, createEvent(evnt, { $timeline: $xeTimeline }, params))
|
|
46
88
|
}
|
|
47
89
|
|
|
48
|
-
const
|
|
90
|
+
const loadData = (opts: any[], isOptConf: boolean) => {
|
|
91
|
+
reactData.isOptConf = isOptConf
|
|
92
|
+
internalData.fullData = opts || []
|
|
93
|
+
updateItems()
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const updateItems = () => {
|
|
97
|
+
const { reverse } = props
|
|
98
|
+
const { fullData } = internalData
|
|
99
|
+
reactData.itemList = reverse ? fullData.slice(0).reverse() : fullData.slice(0)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const timelineMethods: TimelineMethods = {
|
|
49
103
|
dispatchEvent
|
|
50
104
|
}
|
|
51
105
|
|
|
52
|
-
const
|
|
106
|
+
const timelinePrivateMethods: TimelinePrivateMethods = {}
|
|
53
107
|
|
|
54
|
-
Object.assign($xeTimeline,
|
|
108
|
+
Object.assign($xeTimeline, timelineMethods, timelinePrivateMethods)
|
|
109
|
+
|
|
110
|
+
const renderItem = (item: any, index: number) => {
|
|
111
|
+
const { itemList, isOptConf } = reactData
|
|
112
|
+
const titleField = computeTitleField.value
|
|
113
|
+
const contentField = computeContentField.value
|
|
114
|
+
const titleVal = getText(isOptConf ? item[titleField] : item.title)
|
|
115
|
+
const contentVal = getText(isOptConf ? item[contentField] : item.content)
|
|
116
|
+
const titleSlot = slots.title
|
|
117
|
+
const contentSlot = slots.content
|
|
118
|
+
return h('div', {
|
|
119
|
+
key: index,
|
|
120
|
+
class: ['vxe-timeline--item', {
|
|
121
|
+
'is--last': index === itemList.length - 1
|
|
122
|
+
}]
|
|
123
|
+
}, [
|
|
124
|
+
h('div', {
|
|
125
|
+
class: 'vxe-timeline--item-line'
|
|
126
|
+
}),
|
|
127
|
+
h('div', {
|
|
128
|
+
class: 'vxe-timeline--item-node'
|
|
129
|
+
}),
|
|
130
|
+
h('div', {
|
|
131
|
+
class: 'vxe-timeline--item-wrapper'
|
|
132
|
+
}, [
|
|
133
|
+
h('div', {
|
|
134
|
+
class: 'vxe-timeline--item-title'
|
|
135
|
+
}, titleSlot ? titleSlot({ item }) : titleVal),
|
|
136
|
+
h('div', {
|
|
137
|
+
class: 'vxe-timeline--item-content'
|
|
138
|
+
}, contentSlot ? contentSlot({ item }) : contentVal)
|
|
139
|
+
])
|
|
140
|
+
]
|
|
141
|
+
)
|
|
142
|
+
}
|
|
55
143
|
|
|
56
144
|
const renderVN = () => {
|
|
145
|
+
const { vertical } = props
|
|
146
|
+
const { itemList } = reactData
|
|
147
|
+
const vSize = computeSize.value
|
|
148
|
+
const defaultSlot = slots.default
|
|
57
149
|
return h('div', {
|
|
58
150
|
ref: refElem,
|
|
59
|
-
class: 'vxe-timeline'
|
|
60
|
-
|
|
151
|
+
class: ['vxe-timeline', {
|
|
152
|
+
[`size--${vSize}`]: vSize,
|
|
153
|
+
'is--vertical': vertical,
|
|
154
|
+
'is--horizontal': !vertical
|
|
155
|
+
}]
|
|
156
|
+
},
|
|
157
|
+
[
|
|
158
|
+
h('div', {
|
|
159
|
+
class: 'vxe-timeline--slots'
|
|
160
|
+
}, defaultSlot ? defaultSlot({}) : []),
|
|
161
|
+
h('div', {
|
|
162
|
+
class: 'vxe-timeline--body'
|
|
163
|
+
}, itemList.map((item, index) => renderItem(item, index)))
|
|
164
|
+
])
|
|
61
165
|
}
|
|
62
166
|
|
|
167
|
+
watch(() => reactData.staticItems, (val) => {
|
|
168
|
+
loadData(val, false)
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
const refOptsFlag = ref(0)
|
|
172
|
+
watch(() => props.options, () => {
|
|
173
|
+
refOptsFlag.value++
|
|
174
|
+
})
|
|
175
|
+
watch(() => props.options ? props.options.length : -1, () => {
|
|
176
|
+
refOptsFlag.value++
|
|
177
|
+
})
|
|
178
|
+
watch(refOptsFlag, () => {
|
|
179
|
+
loadData(props.options || [], true)
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
watch(() => props.reverse, () => {
|
|
183
|
+
updateItems()
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
onMounted(() => {
|
|
187
|
+
const { staticItems } = reactData
|
|
188
|
+
if (staticItems.length) {
|
|
189
|
+
loadData(staticItems, false)
|
|
190
|
+
} else {
|
|
191
|
+
loadData(props.options || [], true)
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
onBeforeUnmount(() => {
|
|
196
|
+
XEUtils.assign(reactData, createReactData())
|
|
197
|
+
XEUtils.assign(internalData, createInternalData())
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
provide('$xeTimeline', $xeTimeline)
|
|
201
|
+
|
|
63
202
|
$xeTimeline.renderVN = renderVN
|
|
64
203
|
|
|
65
204
|
return $xeTimeline
|
|
@@ -67,4 +206,4 @@ export default defineVxeComponent({
|
|
|
67
206
|
render() {
|
|
68
207
|
return this.renderVN()
|
|
69
208
|
}
|
|
70
|
-
})
|
|
209
|
+
}) /* define-vxe-component end */
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { watch } from 'vue'
|
|
2
|
+
import XEUtils from 'xe-utils'
|
|
3
|
+
import { TimelineItemInfo } from './timeline-info'
|
|
4
|
+
|
|
5
|
+
import type { VxeTimelineConstructor } from '../../../types'
|
|
6
|
+
|
|
7
|
+
export function isTimelineItem(item: any) {
|
|
8
|
+
return item instanceof TimelineItemInfo
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function createTimelineItem($xeTimeline: VxeTimelineConstructor, _vm: any) {
|
|
12
|
+
return isTimelineItem(_vm) ? _vm : new TimelineItemInfo($xeTimeline, _vm)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function watchTimelineItem(props: any, itemInfo: TimelineItemInfo) {
|
|
16
|
+
Object.keys(props).forEach((name) => {
|
|
17
|
+
watch(() => props[name], (value: any) => {
|
|
18
|
+
itemInfo.update(name, value)
|
|
19
|
+
})
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function assembleTimelineItem($xeTimeline: VxeTimelineConstructor, el: HTMLDivElement, itemInfo: TimelineItemInfo) {
|
|
24
|
+
const { reactData } = $xeTimeline
|
|
25
|
+
const { staticItems } = reactData
|
|
26
|
+
const parentElem = el.parentNode
|
|
27
|
+
if (parentElem && staticItems) {
|
|
28
|
+
staticItems.splice(XEUtils.arrayIndexOf(parentElem.children, el), 0, itemInfo)
|
|
29
|
+
reactData.staticItems = staticItems.slice(0)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function destroyTimelineItem($xeTimeline: VxeTimelineConstructor, itemInfo: TimelineItemInfo) {
|
|
34
|
+
const { reactData } = $xeTimeline
|
|
35
|
+
const { staticItems } = reactData
|
|
36
|
+
const index = XEUtils.findIndexOf(staticItems, (item: any) => item.id === itemInfo.id)
|
|
37
|
+
if (index > -1) {
|
|
38
|
+
staticItems.splice(index, 1)
|
|
39
|
+
}
|
|
40
|
+
reactData.staticItems = staticItems.slice(0)
|
|
41
|
+
}
|