pimelon-ui 0.1.88 → 0.1.90
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/package.json +2 -1
- package/src/components/{types → DatePicker}/DatePicker.ts +1 -0
- package/src/components/{DatePicker.vue → DatePicker/DatePicker.vue} +36 -20
- package/src/components/{DateRangePicker.vue → DatePicker/DateRangePicker.vue} +35 -21
- package/src/components/{DateTimePicker.vue → DatePicker/DateTimePicker.vue} +55 -46
- package/src/{utils → components/DatePicker}/useDatePicker.ts +1 -1
- package/src/{utils/dates.ts → components/DatePicker/utils.ts} +8 -12
- package/src/index.js +4 -3
- package/src/utils/dayjs.js +45 -0
- /package/src/components/{DatePicker.story.vue → DatePicker/DatePicker.story.vue} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pimelon-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.90",
|
|
4
4
|
"description": "A set of components and utilities for rapid UI development",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@tiptap/suggestion": "^2.0.3",
|
|
48
48
|
"@tiptap/vue-3": "^2.0.3",
|
|
49
49
|
"@vueuse/core": "^10.4.1",
|
|
50
|
+
"dayjs": "^1.11.13",
|
|
50
51
|
"feather-icons": "^4.28.0",
|
|
51
52
|
"husky": "^9.1.7",
|
|
52
53
|
"idb-keyval": "^6.2.0",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<Popover
|
|
3
3
|
@open="selectCurrentMonthYear"
|
|
4
4
|
class="flex w-full [&>div:first-child]:w-full"
|
|
5
|
+
:placement="placement"
|
|
5
6
|
>
|
|
6
7
|
<template #target="{ togglePopover }">
|
|
7
8
|
<Input
|
|
@@ -18,11 +19,12 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<template #body="{ togglePopover }">
|
|
21
|
-
<!-- Month Switcher -->
|
|
22
22
|
<div
|
|
23
|
-
class="
|
|
23
|
+
class="w-fit select-none text-base text-ink-gray-9 divide-y divide-outline-gray-modals rounded-lg bg-surface-modal shadow-2xl ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
24
|
+
:class="marginClass"
|
|
24
25
|
>
|
|
25
|
-
|
|
26
|
+
<!-- Month Switcher -->
|
|
27
|
+
<div class="flex items-center p-1 text-ink-gray-4">
|
|
26
28
|
<Button variant="ghost" class="h-7 w-7" @click="prevMonth">
|
|
27
29
|
<FeatherIcon
|
|
28
30
|
:stroke-width="2"
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
class="h-4 w-4"
|
|
31
33
|
/>
|
|
32
34
|
</Button>
|
|
33
|
-
<div class="flex-1 text-center text-base font-medium text-gray-
|
|
35
|
+
<div class="flex-1 text-center text-base font-medium text-ink-gray-6">
|
|
34
36
|
{{ formattedMonth }}
|
|
35
37
|
</div>
|
|
36
38
|
<Button variant="ghost" class="h-7 w-7" @click="nextMonth">
|
|
@@ -55,7 +57,7 @@
|
|
|
55
57
|
class="text-sm"
|
|
56
58
|
@click="
|
|
57
59
|
() => {
|
|
58
|
-
selectDate(getDate())
|
|
60
|
+
selectDate(getDate(), true)
|
|
59
61
|
togglePopover()
|
|
60
62
|
}
|
|
61
63
|
"
|
|
@@ -64,12 +66,12 @@
|
|
|
64
66
|
|
|
65
67
|
<!-- Calendar -->
|
|
66
68
|
<div
|
|
67
|
-
class="flex flex-col items-center justify-center p-1 text-gray-
|
|
69
|
+
class="flex flex-col items-center justify-center p-1 text-ink-gray-8"
|
|
68
70
|
>
|
|
69
71
|
<div class="flex items-center text-xs uppercase">
|
|
70
72
|
<div
|
|
71
73
|
class="flex h-6 w-8 items-center justify-center text-center"
|
|
72
|
-
v-for="(d, i) in ['
|
|
74
|
+
v-for="(d, i) in ['s', 'm', 't', 'w', 't', 'f', 's']"
|
|
73
75
|
:key="i"
|
|
74
76
|
>
|
|
75
77
|
{{ d }}
|
|
@@ -83,12 +85,12 @@
|
|
|
83
85
|
<div
|
|
84
86
|
v-for="date in week"
|
|
85
87
|
:key="getDateValue(date)"
|
|
86
|
-
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-gray-
|
|
88
|
+
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-surface-gray-2"
|
|
87
89
|
:class="{
|
|
88
|
-
'text-gray-
|
|
89
|
-
'font-extrabold text-gray-
|
|
90
|
+
'text-ink-gray-3': date.getMonth() !== currentMonth - 1,
|
|
91
|
+
'font-extrabold text-ink-gray-9':
|
|
90
92
|
getDateValue(date) === getDateValue(today),
|
|
91
|
-
'bg-gray-
|
|
93
|
+
'bg-surface-gray-6 text-ink-white hover:bg-surface-gray-6':
|
|
92
94
|
getDateValue(date) === dateValue,
|
|
93
95
|
}"
|
|
94
96
|
@click="
|
|
@@ -124,16 +126,17 @@
|
|
|
124
126
|
<script setup lang="ts">
|
|
125
127
|
import { computed, onMounted } from 'vue'
|
|
126
128
|
|
|
127
|
-
import Input from '
|
|
128
|
-
import { Button } from '
|
|
129
|
-
import Popover from '
|
|
130
|
-
import FeatherIcon from '
|
|
131
|
-
import TextInput from '
|
|
129
|
+
import Input from '../Input.vue'
|
|
130
|
+
import { Button } from '../Button'
|
|
131
|
+
import Popover from '../Popover.vue'
|
|
132
|
+
import FeatherIcon from '../FeatherIcon.vue'
|
|
133
|
+
import TextInput from '../TextInput.vue'
|
|
132
134
|
|
|
133
|
-
import { getDate, getDateValue } from '
|
|
134
|
-
import { useDatePicker } from '
|
|
135
|
+
import { getDate, getDateValue } from './utils'
|
|
136
|
+
import { useDatePicker } from './useDatePicker'
|
|
137
|
+
import { dayjsLocal } from '../../utils/dayjs'
|
|
135
138
|
|
|
136
|
-
import type { DatePickerEmits, DatePickerProps } from './
|
|
139
|
+
import type { DatePickerEmits, DatePickerProps } from './DatePicker'
|
|
137
140
|
|
|
138
141
|
const props = defineProps<DatePickerProps>()
|
|
139
142
|
const emit = defineEmits<DatePickerEmits>()
|
|
@@ -148,11 +151,24 @@ const {
|
|
|
148
151
|
nextMonth,
|
|
149
152
|
} = useDatePicker()
|
|
150
153
|
|
|
154
|
+
const marginClass = computed(() => {
|
|
155
|
+
let _marginClass = 'mt-2'
|
|
156
|
+
if (props.placement?.startsWith('top')) {
|
|
157
|
+
_marginClass = 'mb-2'
|
|
158
|
+
} else if (props.placement?.startsWith('left')) {
|
|
159
|
+
_marginClass = 'mr-2'
|
|
160
|
+
} else if (props.placement?.startsWith('right')) {
|
|
161
|
+
_marginClass = 'ml-2'
|
|
162
|
+
}
|
|
163
|
+
return _marginClass
|
|
164
|
+
})
|
|
165
|
+
|
|
151
166
|
const dateValue = computed(() => {
|
|
152
167
|
return props.value ? props.value : props.modelValue
|
|
153
168
|
})
|
|
154
169
|
|
|
155
|
-
function selectDate(date: Date | string) {
|
|
170
|
+
function selectDate(date: Date | string, isNow: boolean = false) {
|
|
171
|
+
date = isNow ? dayjsLocal(date) : date
|
|
156
172
|
emit('change', getDateValue(date))
|
|
157
173
|
emit('update:modelValue', getDateValue(date))
|
|
158
174
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<Popover
|
|
3
3
|
@open="selectCurrentMonthYear"
|
|
4
4
|
class="flex w-full [&>div:first-child]:w-full"
|
|
5
|
+
:placement="placement"
|
|
5
6
|
>
|
|
6
7
|
<template #target="{ togglePopover }">
|
|
7
8
|
<Input
|
|
@@ -18,11 +19,12 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<template #body="{ togglePopover }">
|
|
21
|
-
<!-- Month Switcher -->
|
|
22
22
|
<div
|
|
23
|
-
class="
|
|
23
|
+
class="w-fit select-none text-base text-ink-gray-9 divide-y divide-outline-gray-modals rounded-lg bg-surface-modal shadow-2xl ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
24
|
+
:class="marginClass"
|
|
24
25
|
>
|
|
25
|
-
|
|
26
|
+
<!-- Month Switcher -->
|
|
27
|
+
<div class="flex items-center p-1 text-ink-gray-4">
|
|
26
28
|
<Button variant="ghost" class="h-7 w-7" @click="prevMonth">
|
|
27
29
|
<FeatherIcon
|
|
28
30
|
:stroke-width="2"
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
class="h-4 w-4"
|
|
31
33
|
/>
|
|
32
34
|
</Button>
|
|
33
|
-
<div class="flex-1 text-center text-base font-medium text-gray-
|
|
35
|
+
<div class="flex-1 text-center text-base font-medium text-ink-gray-6">
|
|
34
36
|
{{ formattedMonth }}
|
|
35
37
|
</div>
|
|
36
38
|
<Button variant="ghost" class="h-7 w-7" @click="nextMonth">
|
|
@@ -50,12 +52,12 @@
|
|
|
50
52
|
|
|
51
53
|
<!-- Calendar -->
|
|
52
54
|
<div
|
|
53
|
-
class="flex flex-col items-center justify-center p-1 text-gray-
|
|
55
|
+
class="flex flex-col items-center justify-center p-1 text-ink-gray-8"
|
|
54
56
|
>
|
|
55
57
|
<div class="flex items-center text-xs uppercase">
|
|
56
58
|
<div
|
|
57
59
|
class="flex h-6 w-8 items-center justify-center text-center"
|
|
58
|
-
v-for="(d, i) in ['
|
|
60
|
+
v-for="(d, i) in ['s', 'm', 't', 'w', 't', 'f', 's']"
|
|
59
61
|
:key="i"
|
|
60
62
|
>
|
|
61
63
|
{{ d }}
|
|
@@ -69,16 +71,16 @@
|
|
|
69
71
|
<div
|
|
70
72
|
v-for="date in week"
|
|
71
73
|
:key="getDateValue(date)"
|
|
72
|
-
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-gray-
|
|
74
|
+
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-surface-gray-2"
|
|
73
75
|
:class="{
|
|
74
|
-
'text-gray-
|
|
75
|
-
'text-gray-
|
|
76
|
-
'font-extrabold text-gray-
|
|
76
|
+
'text-ink-gray-3': date.getMonth() !== currentMonth - 1,
|
|
77
|
+
'text-ink-gray-9': date.getMonth() === currentMonth - 1,
|
|
78
|
+
'font-extrabold text-ink-gray-9':
|
|
77
79
|
getDateValue(date) === getDateValue(today),
|
|
78
|
-
'rounded-none bg-gray-
|
|
79
|
-
'rounded-l-md rounded-r-none bg-gray-
|
|
80
|
+
'rounded-none bg-surface-gray-3': isInRange(date),
|
|
81
|
+
'rounded-l-md rounded-r-none bg-surface-gray-6 text-ink-white hover:bg-surface-gray-6':
|
|
80
82
|
fromDate && getDateValue(date) === getDateValue(fromDate),
|
|
81
|
-
'rounded-r-md bg-gray-
|
|
83
|
+
'rounded-r-md bg-surface-gray-6 text-ink-white hover:bg-surface-gray-6':
|
|
82
84
|
toDate && getDateValue(date) === getDateValue(toDate),
|
|
83
85
|
}"
|
|
84
86
|
@click="() => handleDateClick(date)"
|
|
@@ -120,16 +122,16 @@
|
|
|
120
122
|
<script setup lang="ts">
|
|
121
123
|
import { computed, ref, onMounted } from 'vue'
|
|
122
124
|
|
|
123
|
-
import Input from '
|
|
124
|
-
import { Button } from '
|
|
125
|
-
import Popover from '
|
|
126
|
-
import FeatherIcon from '
|
|
127
|
-
import TextInput from '
|
|
125
|
+
import Input from '../Input.vue'
|
|
126
|
+
import { Button } from '../Button'
|
|
127
|
+
import Popover from '../Popover.vue'
|
|
128
|
+
import FeatherIcon from '../FeatherIcon.vue'
|
|
129
|
+
import TextInput from '../TextInput.vue'
|
|
128
130
|
|
|
129
|
-
import { getDate, getDateValue } from '
|
|
130
|
-
import { useDatePicker } from '
|
|
131
|
+
import { getDate, getDateValue } from './utils'
|
|
132
|
+
import { useDatePicker } from './useDatePicker'
|
|
131
133
|
|
|
132
|
-
import type { DatePickerEmits, DatePickerProps } from './
|
|
134
|
+
import type { DatePickerEmits, DatePickerProps } from './DatePicker'
|
|
133
135
|
|
|
134
136
|
const props = defineProps<DatePickerProps>()
|
|
135
137
|
const emit = defineEmits<DatePickerEmits>()
|
|
@@ -144,6 +146,18 @@ const {
|
|
|
144
146
|
nextMonth,
|
|
145
147
|
} = useDatePicker()
|
|
146
148
|
|
|
149
|
+
const marginClass = computed(() => {
|
|
150
|
+
let _marginClass = 'mt-2'
|
|
151
|
+
if (props.placement?.startsWith('top')) {
|
|
152
|
+
_marginClass = 'mb-2'
|
|
153
|
+
} else if (props.placement?.startsWith('left')) {
|
|
154
|
+
_marginClass = 'mr-2'
|
|
155
|
+
} else if (props.placement?.startsWith('right')) {
|
|
156
|
+
_marginClass = 'ml-2'
|
|
157
|
+
}
|
|
158
|
+
return _marginClass
|
|
159
|
+
})
|
|
160
|
+
|
|
147
161
|
const dateValue = computed(() => {
|
|
148
162
|
return props.value ? props.value : props.modelValue
|
|
149
163
|
})
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
<Popover
|
|
3
3
|
@open="selectCurrentMonthYear"
|
|
4
4
|
class="flex w-full [&>div:first-child]:w-full"
|
|
5
|
+
:placement="placement"
|
|
5
6
|
>
|
|
6
7
|
<template #target="{ togglePopover }">
|
|
7
8
|
<Input
|
|
@@ -18,11 +19,12 @@
|
|
|
18
19
|
</template>
|
|
19
20
|
|
|
20
21
|
<template #body="{ togglePopover }">
|
|
21
|
-
<!-- Month Switcher -->
|
|
22
22
|
<div
|
|
23
|
-
class="
|
|
23
|
+
class="w-fit select-none text-base text-ink-gray-9 divide-y divide-outline-gray-modals rounded-lg bg-surface-modal shadow-2xl ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
24
|
+
:class="marginClass"
|
|
24
25
|
>
|
|
25
|
-
|
|
26
|
+
<!-- Month Switcher -->
|
|
27
|
+
<div class="flex items-center p-1 text-ink-gray-4">
|
|
26
28
|
<Button variant="ghost" class="h-7 w-7" @click="prevMonth">
|
|
27
29
|
<FeatherIcon
|
|
28
30
|
:stroke-width="2"
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
class="h-4 w-4"
|
|
31
33
|
/>
|
|
32
34
|
</Button>
|
|
33
|
-
<div class="flex-1 text-center text-base font-medium text-gray-
|
|
35
|
+
<div class="flex-1 text-center text-base font-medium text-ink-gray-6">
|
|
34
36
|
{{ formattedMonth }}
|
|
35
37
|
</div>
|
|
36
38
|
<Button variant="ghost" class="h-7 w-7" @click="nextMonth">
|
|
@@ -60,7 +62,7 @@
|
|
|
60
62
|
class="text-sm"
|
|
61
63
|
@click="
|
|
62
64
|
() => {
|
|
63
|
-
selectDate(getDate(),
|
|
65
|
+
selectDate(getDate(), true)
|
|
64
66
|
togglePopover()
|
|
65
67
|
}
|
|
66
68
|
"
|
|
@@ -69,12 +71,12 @@
|
|
|
69
71
|
|
|
70
72
|
<!-- Date Picker -->
|
|
71
73
|
<div
|
|
72
|
-
class="flex flex-col items-center justify-center p-1 text-gray-
|
|
74
|
+
class="flex flex-col items-center justify-center p-1 text-ink-gray-8"
|
|
73
75
|
>
|
|
74
76
|
<div class="flex items-center text-xs uppercase">
|
|
75
77
|
<div
|
|
76
78
|
class="flex h-6 w-8 items-center justify-center text-center"
|
|
77
|
-
v-for="(d, i) in ['
|
|
79
|
+
v-for="(d, i) in ['s', 'm', 't', 'w', 't', 'f', 's']"
|
|
78
80
|
:key="i"
|
|
79
81
|
>
|
|
80
82
|
{{ d }}
|
|
@@ -88,12 +90,12 @@
|
|
|
88
90
|
<div
|
|
89
91
|
v-for="date in week"
|
|
90
92
|
:key="toValue(date)"
|
|
91
|
-
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-gray-
|
|
93
|
+
class="flex h-8 w-8 cursor-pointer items-center justify-center rounded hover:bg-surface-gray-2"
|
|
92
94
|
:class="{
|
|
93
|
-
'text-gray-
|
|
94
|
-
'font-extrabold text-gray-
|
|
95
|
+
'text-ink-gray-3': date.getMonth() !== currentMonth - 1,
|
|
96
|
+
'font-extrabold text-ink-gray-9':
|
|
95
97
|
toValue(date) === toValue(today),
|
|
96
|
-
'bg-gray-
|
|
98
|
+
'bg-surface-gray-6 text-ink-white hover:bg-surface-gray-6':
|
|
97
99
|
toValue(date) === dateValue,
|
|
98
100
|
}"
|
|
99
101
|
@click="
|
|
@@ -187,16 +189,17 @@
|
|
|
187
189
|
<script setup lang="ts">
|
|
188
190
|
import { ref, computed, onMounted } from 'vue'
|
|
189
191
|
|
|
190
|
-
import Input from '
|
|
191
|
-
import { Button } from '
|
|
192
|
-
import Popover from '
|
|
193
|
-
import FeatherIcon from '
|
|
194
|
-
import TextInput from '
|
|
192
|
+
import Input from '../Input.vue'
|
|
193
|
+
import { Button } from '../Button'
|
|
194
|
+
import Popover from '../Popover.vue'
|
|
195
|
+
import FeatherIcon from '../FeatherIcon.vue'
|
|
196
|
+
import TextInput from '../TextInput.vue'
|
|
195
197
|
|
|
196
|
-
import { getDate } from '
|
|
197
|
-
import { useDatePicker } from '
|
|
198
|
+
import { getDate } from './utils'
|
|
199
|
+
import { useDatePicker } from './useDatePicker'
|
|
200
|
+
import { dayjs, dayjsLocal, dayjsSystem } from '../../utils/dayjs'
|
|
198
201
|
|
|
199
|
-
import type { DatePickerEmits, DatePickerProps } from './
|
|
202
|
+
import type { DatePickerEmits, DatePickerProps } from './DatePicker'
|
|
200
203
|
|
|
201
204
|
const props = defineProps<DatePickerProps>()
|
|
202
205
|
const emit = defineEmits<DatePickerEmits>()
|
|
@@ -211,50 +214,56 @@ const {
|
|
|
211
214
|
nextMonth,
|
|
212
215
|
} = useDatePicker()
|
|
213
216
|
|
|
217
|
+
const marginClass = computed(() => {
|
|
218
|
+
let _marginClass = 'mt-2'
|
|
219
|
+
if (props.placement?.startsWith('top')) {
|
|
220
|
+
_marginClass = 'mb-2'
|
|
221
|
+
} else if (props.placement?.startsWith('left')) {
|
|
222
|
+
_marginClass = 'mr-2'
|
|
223
|
+
} else if (props.placement?.startsWith('right')) {
|
|
224
|
+
_marginClass = 'ml-2'
|
|
225
|
+
}
|
|
226
|
+
return _marginClass
|
|
227
|
+
})
|
|
228
|
+
|
|
214
229
|
const hour = ref<number>(0)
|
|
215
230
|
const minute = ref<number>(0)
|
|
216
231
|
const second = ref<number>(0)
|
|
217
232
|
|
|
218
233
|
const dateValue = computed(() => {
|
|
219
|
-
|
|
234
|
+
let date = props.value ? props.value : props.modelValue
|
|
235
|
+
return date ? dayjsLocal(date).format('YYYY-MM-DD HH:mm:ss') : ''
|
|
220
236
|
})
|
|
221
237
|
|
|
222
238
|
function changeTime() {
|
|
223
239
|
let date = dateValue.value ? getDate(dateValue.value) : getDate()
|
|
224
|
-
selectDate(date
|
|
240
|
+
selectDate(date)
|
|
225
241
|
}
|
|
226
242
|
|
|
227
|
-
function selectDate(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
let currentDate =
|
|
234
|
-
dateValue.value && !isNow ? getDate(dateValue.value) : getDate()
|
|
235
|
-
hour.value = currentDate.getHours()
|
|
236
|
-
minute.value = currentDate.getMinutes()
|
|
237
|
-
second.value = currentDate.getSeconds()
|
|
243
|
+
function selectDate(date: Date | string, isNow: boolean = false) {
|
|
244
|
+
if (isNow) {
|
|
245
|
+
date = dayjsLocal(date)
|
|
246
|
+
hour.value = date.hour()
|
|
247
|
+
minute.value = date.minute()
|
|
248
|
+
second.value = date.second()
|
|
238
249
|
}
|
|
239
250
|
|
|
240
|
-
|
|
241
|
-
|
|
251
|
+
let systemParsedDate = date
|
|
252
|
+
? dayjsSystem(toValue(date)).format('YYYY-MM-DD HH:mm:ss')
|
|
253
|
+
: ''
|
|
254
|
+
emit('change', systemParsedDate)
|
|
255
|
+
emit('update:modelValue', systemParsedDate)
|
|
242
256
|
}
|
|
243
257
|
|
|
244
258
|
function toValue(date: Date | string) {
|
|
245
259
|
if (!date || date.toString() === 'Invalid Date') return ''
|
|
246
260
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
return `${date.getFullYear()}-${twoDigit(
|
|
254
|
-
date.getMonth() + 1,
|
|
255
|
-
)}-${twoDigit(date.getDate())} ${twoDigit(
|
|
256
|
-
date.getHours(),
|
|
257
|
-
)}:${twoDigit(date.getMinutes())}:${twoDigit(date.getSeconds())}`
|
|
261
|
+
// "YYYY-MM-DD HH:mm:ss"
|
|
262
|
+
return dayjs(date)
|
|
263
|
+
.set('hour', hour.value)
|
|
264
|
+
.set('minute', minute.value)
|
|
265
|
+
.set('second', second.value)
|
|
266
|
+
.format('YYYY-MM-DD HH:mm:ss')
|
|
258
267
|
}
|
|
259
268
|
|
|
260
269
|
function twoDigit(number: number) {
|
|
@@ -266,7 +275,7 @@ function updateDate(date: Date | string) {
|
|
|
266
275
|
hour.value = date.getHours()
|
|
267
276
|
minute.value = date.getMinutes()
|
|
268
277
|
second.value = date.getSeconds()
|
|
269
|
-
selectDate(date
|
|
278
|
+
selectDate(date)
|
|
270
279
|
}
|
|
271
280
|
|
|
272
281
|
function selectCurrentMonthYear() {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dayjs } from '../../utils/dayjs'
|
|
2
|
+
|
|
1
3
|
type DateConstructorParam = string | number | Date
|
|
2
4
|
|
|
3
5
|
function getDate(...args: DateConstructorParam[]): Date {
|
|
@@ -7,18 +9,12 @@ function getDate(...args: DateConstructorParam[]): Date {
|
|
|
7
9
|
function getDateValue(date: Date | string) {
|
|
8
10
|
if (!date || date.toString() === 'Invalid Date') return ''
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// in order to circumvent that we need to use luxon/moment
|
|
17
|
-
// but that refactor could take some time, so fixing the time difference
|
|
18
|
-
// as suggested in this answer.
|
|
19
|
-
// https://stackoverflow.com/a/16084846/3541205
|
|
20
|
-
date.setHours(0, -date.getTimezoneOffset(), 0, 0)
|
|
21
|
-
return date.toISOString().slice(0, 10)
|
|
12
|
+
return dayjs(date)
|
|
13
|
+
.set('hour', 0)
|
|
14
|
+
.set('minute', 0)
|
|
15
|
+
.set('second', 0)
|
|
16
|
+
.set('millisecond', 0)
|
|
17
|
+
.format('YYYY-MM-DD')
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
function getDatesAfter(date: Date, count: number) {
|
package/src/index.js
CHANGED
|
@@ -7,9 +7,9 @@ export { default as Breadcrumbs } from './components/Breadcrumbs.vue'
|
|
|
7
7
|
export * from './components/Button'
|
|
8
8
|
export { default as Card } from './components/Card.vue'
|
|
9
9
|
export { default as Checkbox } from './components/Checkbox.vue'
|
|
10
|
-
export { default as DatePicker } from './components/DatePicker.vue'
|
|
11
|
-
export { default as DateTimePicker } from './components/DateTimePicker.vue'
|
|
12
|
-
export { default as DateRangePicker } from './components/DateRangePicker.vue'
|
|
10
|
+
export { default as DatePicker } from './components/DatePicker/DatePicker.vue'
|
|
11
|
+
export { default as DateTimePicker } from './components/DatePicker/DateTimePicker.vue'
|
|
12
|
+
export { default as DateRangePicker } from './components/DatePicker/DateRangePicker.vue'
|
|
13
13
|
export { default as Dialog } from './components/Dialog.vue'
|
|
14
14
|
export { default as Dialogs } from './components/Dialogs.vue'
|
|
15
15
|
export { default as Divider } from './components/Divider.vue'
|
|
@@ -79,6 +79,7 @@ export { default as debounce } from './utils/debounce.ts'
|
|
|
79
79
|
export { default as fileToBase64 } from './utils/file-to-base64.js'
|
|
80
80
|
export { default as FileUploadHandler } from './utils/fileUploadHandler.ts'
|
|
81
81
|
export { usePageMeta } from './utils/pageMeta.js'
|
|
82
|
+
export { dayjsLocal, dayjs } from './utils/dayjs.js'
|
|
82
83
|
|
|
83
84
|
// data-fetching, resources
|
|
84
85
|
export {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _dayjs from 'dayjs/esm'
|
|
2
|
+
import relativeTime from 'dayjs/esm/plugin/relativeTime'
|
|
3
|
+
import localizedFormat from 'dayjs/esm/plugin/localizedFormat'
|
|
4
|
+
import updateLocale from 'dayjs/esm/plugin/updateLocale'
|
|
5
|
+
import isToday from 'dayjs/esm/plugin/isToday'
|
|
6
|
+
import duration from 'dayjs/esm/plugin/duration'
|
|
7
|
+
import utc from 'dayjs/esm/plugin/utc'
|
|
8
|
+
import timezone from 'dayjs/esm/plugin/timezone'
|
|
9
|
+
import advancedFormat from 'dayjs/plugin/advancedFormat'
|
|
10
|
+
import { getConfig } from './config'
|
|
11
|
+
|
|
12
|
+
_dayjs.extend(updateLocale)
|
|
13
|
+
_dayjs.extend(relativeTime)
|
|
14
|
+
_dayjs.extend(localizedFormat)
|
|
15
|
+
_dayjs.extend(isToday)
|
|
16
|
+
_dayjs.extend(duration)
|
|
17
|
+
_dayjs.extend(utc)
|
|
18
|
+
_dayjs.extend(timezone)
|
|
19
|
+
_dayjs.extend(advancedFormat)
|
|
20
|
+
|
|
21
|
+
function getBrowserTimezone() {
|
|
22
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function dayjsLocal(dateTimeString) {
|
|
26
|
+
let systemTimezone = getConfig('systemTimezone')
|
|
27
|
+
let localTimezone = getConfig('localTimezone') || getBrowserTimezone()
|
|
28
|
+
|
|
29
|
+
if (!systemTimezone) return _dayjs(dateTimeString)
|
|
30
|
+
|
|
31
|
+
if (!dateTimeString) return _dayjs().tz(localTimezone)
|
|
32
|
+
return _dayjs.tz(dateTimeString, systemTimezone).tz(localTimezone)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function dayjsSystem(dateTimeString) {
|
|
36
|
+
let systemTimezone = getConfig('systemTimezone')
|
|
37
|
+
let localTimezone = getConfig('localTimezone') || getBrowserTimezone()
|
|
38
|
+
|
|
39
|
+
if (!systemTimezone) return _dayjs(dateTimeString)
|
|
40
|
+
|
|
41
|
+
if (!dateTimeString) return _dayjs().tz(systemTimezone)
|
|
42
|
+
return _dayjs.tz(dateTimeString, localTimezone).tz(systemTimezone)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export let dayjs = _dayjs
|
|
File without changes
|