mediacube-ui 0.1.142 → 0.1.144
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.144](https://github.com/MediaCubeCo/mcui/compare/v0.1.143...v0.1.144) (2023-09-18)
|
|
6
|
+
|
|
7
|
+
### [0.1.143](https://github.com/MediaCubeCo/mcui/compare/v0.1.142...v0.1.143) (2023-09-14)
|
|
8
|
+
|
|
5
9
|
### [0.1.142](https://github.com/MediaCubeCo/mcui/compare/v0.1.141...v0.1.142) (2023-09-13)
|
|
6
10
|
|
|
7
11
|
### [0.1.141](https://github.com/MediaCubeCo/mcui/compare/v0.1.140...v0.1.141) (2023-09-13)
|
package/package.json
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script>
|
|
16
|
+
import { dayjs } from '../../utils/dayjs'
|
|
16
17
|
import McTitle from '../McTitle/McTitle'
|
|
17
18
|
|
|
18
19
|
export default {
|
|
@@ -74,9 +75,9 @@ export default {
|
|
|
74
75
|
|
|
75
76
|
computed: {
|
|
76
77
|
dayjsDate() {
|
|
77
|
-
if (
|
|
78
|
+
if (dayjs === null) return null
|
|
78
79
|
const locale = this.$i18n?.locale || 'ru' // TODO: maybe `en`?
|
|
79
|
-
return
|
|
80
|
+
return dayjs(this.value).locale(locale)
|
|
80
81
|
},
|
|
81
82
|
formattedDate() {
|
|
82
83
|
if (this.dayjsDate === null) return this.value
|
|
@@ -392,12 +392,12 @@ export default {
|
|
|
392
392
|
: new Date()
|
|
393
393
|
}
|
|
394
394
|
const formattingDate = date =>
|
|
395
|
-
|
|
395
|
+
dayjs.tz(dayjs.utc(date, 'YYYY-MM-DD HH:mm:ss'), this.currentTimezone).format(this.format)
|
|
396
396
|
if (this.isRange && this.value) {
|
|
397
397
|
const [start_date, end_date] = this.value
|
|
398
398
|
const prepared_value = [
|
|
399
399
|
start_date,
|
|
400
|
-
|
|
400
|
+
dayjs(end_date)
|
|
401
401
|
.subtract(1, 'days')
|
|
402
402
|
.format(),
|
|
403
403
|
]
|
|
@@ -413,7 +413,7 @@ export default {
|
|
|
413
413
|
async setupDayjsLocale() {
|
|
414
414
|
const locale = this.lang !== 'ar' && Object.keys(dayjsLocales).includes(this.lang) ? this.lang : 'en'
|
|
415
415
|
await dayjsLocales[locale]?.()
|
|
416
|
-
|
|
416
|
+
dayjs.locale(locale)
|
|
417
417
|
},
|
|
418
418
|
handleEmitDate(value) {
|
|
419
419
|
const date = this.getFormattedDate(value)
|
|
@@ -430,20 +430,16 @@ export default {
|
|
|
430
430
|
if (!this.useTimezone) {
|
|
431
431
|
if (Array.isArray(newValue)) {
|
|
432
432
|
return newValue.map(v => {
|
|
433
|
-
return v?.toString?.().trim() ?
|
|
433
|
+
return v?.toString?.().trim() ? dayjs(v).format(this.toFormat) : ' '
|
|
434
434
|
})
|
|
435
435
|
}
|
|
436
|
-
return value?.toString?.().trim()
|
|
437
|
-
? this.isTime
|
|
438
|
-
? this.$dayjs.utc(value)
|
|
439
|
-
: this.$dayjs(value).format(this.toFormat)
|
|
440
|
-
: ' '
|
|
436
|
+
return value?.toString?.().trim() ? (this.isTime ? value : dayjs(value).format(this.toFormat)) : ' '
|
|
441
437
|
}
|
|
442
438
|
|
|
443
439
|
const hasDate = date => date && date?.trim()?.length
|
|
444
440
|
const formatingDate = date =>
|
|
445
|
-
|
|
446
|
-
.tz(
|
|
441
|
+
dayjs
|
|
442
|
+
.tz(dayjs(date, this.format).format('YYYY-MM-DD HH:mm:ss'), this.currentTimezone)
|
|
447
443
|
.utc()
|
|
448
444
|
.format()
|
|
449
445
|
if (Array.isArray(newValue)) {
|
|
@@ -451,7 +447,7 @@ export default {
|
|
|
451
447
|
if (hasDate(start_date) && hasDate(end_date))
|
|
452
448
|
newValue = [
|
|
453
449
|
start_date,
|
|
454
|
-
|
|
450
|
+
dayjs(end_date, this.format)
|
|
455
451
|
.add(1, 'days')
|
|
456
452
|
.format(this.format),
|
|
457
453
|
]
|
|
@@ -466,41 +462,39 @@ export default {
|
|
|
466
462
|
const end = this.pickDate || new Date()
|
|
467
463
|
switch (key) {
|
|
468
464
|
case 'week':
|
|
469
|
-
if (
|
|
470
|
-
start =
|
|
465
|
+
if (dayjs) {
|
|
466
|
+
start = dayjs(end).subtract(7, 'days')
|
|
471
467
|
break
|
|
472
468
|
}
|
|
473
469
|
start.setTime(end.getTime() - 6 * 24 * 3600 * 1000)
|
|
474
470
|
break
|
|
475
471
|
case 'month':
|
|
476
|
-
if (
|
|
477
|
-
start =
|
|
472
|
+
if (dayjs) {
|
|
473
|
+
start = dayjs(end).subtract(1, 'months')
|
|
478
474
|
break
|
|
479
475
|
}
|
|
480
476
|
start.setMonth(end.getMonth() - 1, end.getDate())
|
|
481
477
|
break
|
|
482
478
|
case 'quarter':
|
|
483
|
-
if (
|
|
484
|
-
start =
|
|
479
|
+
if (dayjs) {
|
|
480
|
+
start = dayjs(end).subtract(3, 'months')
|
|
485
481
|
break
|
|
486
482
|
}
|
|
487
483
|
start.setMonth(end.getMonth() - 3, end.getDate())
|
|
488
484
|
break
|
|
489
485
|
case 'year':
|
|
490
|
-
if (
|
|
491
|
-
start =
|
|
486
|
+
if (dayjs) {
|
|
487
|
+
start = dayjs(end).subtract(1, 'years')
|
|
492
488
|
break
|
|
493
489
|
}
|
|
494
490
|
start.setFullYear(end.getFullYear() - 1, end.getMonth(), end.getDate())
|
|
495
491
|
break
|
|
496
492
|
}
|
|
497
|
-
this.$refs.input.currentValue = [
|
|
493
|
+
this.$refs.input.currentValue = [dayjs ? start.toDate() : start, end]
|
|
498
494
|
},
|
|
499
495
|
handlerPreselectRange(period) {
|
|
500
496
|
const [start, end] = period
|
|
501
|
-
this.$refs.input.currentValue =
|
|
502
|
-
? [this.$dayjs(start).toDate(), this.$dayjs(end).toDate()]
|
|
503
|
-
: period
|
|
497
|
+
this.$refs.input.currentValue = dayjs ? [dayjs(start).toDate(), dayjs(end).toDate()] : period
|
|
504
498
|
},
|
|
505
499
|
handlePickDate(date) {
|
|
506
500
|
this.pickDate = date
|
|
@@ -49,6 +49,7 @@ import _XEUtils from 'xe-utils'
|
|
|
49
49
|
import _isEqual from 'lodash/isEqual'
|
|
50
50
|
import _isEmpty from 'lodash/isEmpty'
|
|
51
51
|
import _cloneDeep from 'lodash/cloneDeep'
|
|
52
|
+
import { dayjs } from '../../../utils/dayjs'
|
|
52
53
|
|
|
53
54
|
import McButton from '../../../elements/McButton/McButton'
|
|
54
55
|
import McTooltip from '../../../elements/McTooltip/McTooltip'
|
|
@@ -141,7 +142,7 @@ export default {
|
|
|
141
142
|
const to = value.less
|
|
142
143
|
? `${this.placeholders.to} ${this.getFormattedVal(
|
|
143
144
|
filter.type === 'date' && filter.useTimezone
|
|
144
|
-
?
|
|
145
|
+
? dayjs(value.less)
|
|
145
146
|
.subtract(1, 'days')
|
|
146
147
|
.format()
|
|
147
148
|
: value.less,
|
|
@@ -300,7 +301,7 @@ export default {
|
|
|
300
301
|
getFormattedVal(val, filter) {
|
|
301
302
|
switch (filter.type) {
|
|
302
303
|
case 'date':
|
|
303
|
-
return
|
|
304
|
+
return dayjs(val).format('DD.MM.YYYY')
|
|
304
305
|
case 'range':
|
|
305
306
|
return this.getFormattedNum(val)
|
|
306
307
|
default:
|
package/src/utils/dayjs.js
CHANGED