fluency-v8-components 1.3.9 → 1.4.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.
- package/dist/fluency-v8-components.es.js +1 -1
- package/dist/fluency-v8-components.umd.js +2 -2
- package/dist/{index-DrG6GyAN.mjs → index-Br4jyWhU.mjs} +141 -136
- package/dist/{index.es-BrS6IGfB.mjs → index.es-jnmHZtX5.mjs} +1 -1
- package/package.json +1 -1
- package/src/components/common/DatePickerInput.vue +43 -28
- package/src/components/form/GreyPassword.vue +1 -1
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="col">
|
|
3
|
-
<
|
|
3
|
+
<VueTailwindDatepicker :shortcuts="customShortcuts" v-model="dateValue" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
8
|
-
import { ref, watch
|
|
8
|
+
import { ref, watch } from "vue";
|
|
9
9
|
import VueTailwindDatepicker from "vue-tailwind-datepicker";
|
|
10
10
|
import moment from "moment";
|
|
11
11
|
|
|
@@ -14,40 +14,47 @@ const props = defineProps({
|
|
|
14
14
|
to: Number,
|
|
15
15
|
});
|
|
16
16
|
const emits = defineEmits(["selectTime"]);
|
|
17
|
-
const dateValue = ref(
|
|
17
|
+
const dateValue = ref(defaultRange());
|
|
18
18
|
|
|
19
|
-
watch(dateValue, (val) => {
|
|
20
|
-
emits("selectTime", [moment(val[0]).valueOf(), moment(val[1]).valueOf()]);
|
|
21
|
-
});
|
|
22
19
|
watch(
|
|
23
|
-
() => props.from,
|
|
24
|
-
(
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
() => [props.from, props.to],
|
|
21
|
+
([from, to]) => {
|
|
22
|
+
const baseRange = Array.isArray(dateValue.value) ? dateValue.value : [];
|
|
23
|
+
const nextRange = baseRange.length === 2 ? [...baseRange] : defaultRange();
|
|
24
|
+
let updated = false;
|
|
25
|
+
|
|
26
|
+
if (isValidTimestamp(from)) {
|
|
27
|
+
nextRange[0] = formatTime(from);
|
|
28
|
+
updated = true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isValidTimestamp(to)) {
|
|
32
|
+
nextRange[1] = formatTime(to);
|
|
33
|
+
updated = true;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (updated) {
|
|
37
|
+
dateValue.value = nextRange;
|
|
27
38
|
} else {
|
|
28
39
|
resetDate();
|
|
29
40
|
}
|
|
30
|
-
}
|
|
41
|
+
},
|
|
42
|
+
{ immediate: true }
|
|
31
43
|
);
|
|
44
|
+
|
|
32
45
|
watch(
|
|
33
|
-
|
|
46
|
+
dateValue,
|
|
34
47
|
(val) => {
|
|
35
|
-
if (val) {
|
|
36
|
-
|
|
48
|
+
if (Array.isArray(val) && val.length === 2 && val[0] && val[1]) {
|
|
49
|
+
emits("selectTime", [
|
|
50
|
+
moment(val[0]).valueOf(),
|
|
51
|
+
moment(val[1]).valueOf(),
|
|
52
|
+
]);
|
|
37
53
|
}
|
|
38
|
-
}
|
|
54
|
+
},
|
|
55
|
+
{ deep: true }
|
|
39
56
|
);
|
|
40
57
|
|
|
41
|
-
onMounted(() => {
|
|
42
|
-
if (props.from && props.to) {
|
|
43
|
-
const fromFormatted = formatTime(props.from);
|
|
44
|
-
const toFormatted = formatTime(props.to);
|
|
45
|
-
dateValue.value = [fromFormatted, toFormatted];
|
|
46
|
-
} else {
|
|
47
|
-
resetDate();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
58
|
function customShortcuts() {
|
|
52
59
|
const date = moment().valueOf();
|
|
53
60
|
return [
|
|
@@ -97,13 +104,21 @@ function customShortcuts() {
|
|
|
97
104
|
}
|
|
98
105
|
|
|
99
106
|
function resetDate() {
|
|
100
|
-
dateValue.value =
|
|
107
|
+
dateValue.value = defaultRange();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function formatTime(time) {
|
|
111
|
+
return moment(time).format("YYYY-MM-DD HH:mm:ss");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function defaultRange() {
|
|
115
|
+
return [
|
|
101
116
|
formatTime(moment().subtract(1, "hours")),
|
|
102
117
|
formatTime(moment()),
|
|
103
118
|
];
|
|
104
119
|
}
|
|
105
120
|
|
|
106
|
-
function
|
|
107
|
-
return
|
|
121
|
+
function isValidTimestamp(value) {
|
|
122
|
+
return typeof value === "number" && !Number.isNaN(value);
|
|
108
123
|
}
|
|
109
124
|
</script>
|