@onereach/ui-components 3.0.4-beta.2486.0 → 3.0.4-beta.2487.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/bundled/v2/{OrCardCollection-ad2240ac.js → OrCardCollection-a10920a3.js} +1 -1
- package/dist/bundled/v2/{OrDateTimePicker-60e1a7ee.js → OrDateTimePicker-11b6d4dd.js} +261 -165
- package/dist/bundled/v2/{OrMenu-cbb0c2c8.js → OrMenu-0c2c348c.js} +6 -1
- package/dist/bundled/v2/{OrPagination-cf47d71c.js → OrPagination-00ab6954.js} +1 -1
- package/dist/bundled/v2/{OrTabs-10f7e668.js → OrTabs-f7c9f754.js} +1 -1
- package/dist/bundled/v2/components/index.js +5 -5
- package/dist/bundled/v2/components/or-card-collection-v3/index.js +2 -2
- package/dist/bundled/v2/components/or-date-time-picker-v3/OrDateTimePicker.vue.d.ts +2 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/hooks/useDefaultDate.d.ts +1 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/hooks/useDefaultHours.d.ts +1 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/hooks/useDefaultMinutes.d.ts +1 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/hooks/useDefaultMonth.d.ts +1 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/hooks/useDefaultYear.d.ts +1 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/index.js +4 -4
- package/dist/bundled/v2/components/or-date-time-picker-v3/partials/{or-date-time-picker-date-select/OrDateTimePickerDateSelect.vue.d.ts → or-date-time-picker-day-select/OrDateTimePickerDaySelect.vue.d.ts} +8 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.d.ts +3 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-month-select/OrDateTimePickerMonthSelect.vue.d.ts +26 -34
- package/dist/bundled/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-time-select/OrDateTimePickerTimeSelect.vue.d.ts +8 -20
- package/dist/bundled/v2/components/or-menu-v3/OrMenu.vue.d.ts +2 -0
- package/dist/bundled/v2/components/or-menu-v3/index.js +1 -1
- package/dist/bundled/v2/components/or-pagination-v3/index.js +2 -2
- package/dist/bundled/v2/components/or-tabs-v3/index.js +2 -2
- package/dist/bundled/v2/index.js +6 -6
- package/dist/bundled/v3/{OrCardCollection.vue_vue_type_script_lang-61f92c57.js → OrCardCollection.vue_vue_type_script_lang-93c84377.js} +2 -2
- package/dist/bundled/v3/{OrDateTimePicker.vue_vue_type_script_lang-fb197c2f.js → OrDateTimePicker.vue_vue_type_script_lang-b9bc77aa.js} +243 -163
- package/dist/bundled/v3/{OrMenu-89afef68.js → OrMenu-101f1c62.js} +1 -1
- package/dist/bundled/v3/{OrMenu.vue_vue_type_script_lang-f6748a99.js → OrMenu.vue_vue_type_script_lang-7ba15d1d.js} +6 -1
- package/dist/bundled/v3/{OrPagination.vue_vue_type_script_lang-7673a00e.js → OrPagination.vue_vue_type_script_lang-d3e6732f.js} +2 -2
- package/dist/bundled/v3/{OrTabs.vue_vue_type_script_lang-ebd2a59d.js → OrTabs.vue_vue_type_script_lang-513b1e98.js} +2 -2
- package/dist/bundled/v3/components/index.js +6 -6
- package/dist/bundled/v3/components/or-card-collection-v3/index.js +3 -3
- package/dist/bundled/v3/components/or-date-time-picker-v3/OrDateTimePicker.vue.d.ts +2 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/hooks/useDefaultDate.d.ts +1 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/hooks/useDefaultHours.d.ts +1 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/hooks/useDefaultMinutes.d.ts +1 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/hooks/useDefaultMonth.d.ts +1 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/hooks/useDefaultYear.d.ts +1 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/index.js +5 -5
- package/dist/{esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/OrDateTimePickerDateSelect.vue.d.ts → bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/OrDateTimePickerDaySelect.vue.d.ts} +8 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.d.ts +3 -0
- package/dist/bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-month-select/OrDateTimePickerMonthSelect.vue.d.ts +26 -34
- package/dist/bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-time-select/OrDateTimePickerTimeSelect.vue.d.ts +8 -20
- package/dist/bundled/v3/components/or-menu-v3/OrMenu.vue.d.ts +2 -0
- package/dist/bundled/v3/components/or-menu-v3/index.js +1 -1
- package/dist/bundled/v3/components/or-pagination-v3/index.js +3 -3
- package/dist/bundled/v3/components/or-tabs-v3/index.js +3 -3
- package/dist/bundled/v3/index.js +36 -22
- package/dist/esm/v2/{OrCardCollection-662d5727.js → OrCardCollection-54079e79.js} +1 -1
- package/dist/esm/v2/{OrDateTimePicker-4b650aca.js → OrDateTimePicker-7411ea1f.js} +266 -170
- package/dist/esm/v2/{OrMenu-47b319a6.js → OrMenu-18a7f179.js} +6 -1
- package/dist/esm/v2/{OrPagination-4d330d4f.js → OrPagination-16f6d75b.js} +1 -1
- package/dist/esm/v2/{OrTabs-f0e4db08.js → OrTabs-18df1ce9.js} +1 -1
- package/dist/esm/v2/components/index.js +5 -5
- package/dist/esm/v2/components/or-card-collection-v3/index.js +2 -2
- package/dist/esm/v2/components/or-date-time-picker-v3/OrDateTimePicker.vue.d.ts +2 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/hooks/useDefaultDate.d.ts +1 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/hooks/useDefaultHours.d.ts +1 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/hooks/useDefaultMinutes.d.ts +1 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/hooks/useDefaultMonth.d.ts +1 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/hooks/useDefaultYear.d.ts +1 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/index.js +2 -2
- package/dist/esm/v2/components/or-date-time-picker-v3/partials/{or-date-time-picker-date-select/OrDateTimePickerDateSelect.vue.d.ts → or-date-time-picker-day-select/OrDateTimePickerDaySelect.vue.d.ts} +8 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.d.ts +3 -0
- package/dist/esm/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-month-select/OrDateTimePickerMonthSelect.vue.d.ts +26 -34
- package/dist/esm/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-time-select/OrDateTimePickerTimeSelect.vue.d.ts +8 -20
- package/dist/esm/v2/components/or-menu-v3/OrMenu.vue.d.ts +2 -0
- package/dist/esm/v2/components/or-menu-v3/index.js +1 -1
- package/dist/esm/v2/components/or-pagination-v3/index.js +2 -2
- package/dist/esm/v2/components/or-tabs-v3/index.js +2 -2
- package/dist/esm/v2/index.js +5 -5
- package/dist/esm/v3/{OrCardCollection-aa7f0c81.js → OrCardCollection-b937aa7a.js} +1 -1
- package/dist/esm/v3/{OrDateTimePicker-3e2dc067.js → OrDateTimePicker-966d5b1d.js} +267 -173
- package/dist/esm/v3/{OrMenu-053a9ab7.js → OrMenu-70cee836.js} +6 -1
- package/dist/esm/v3/{OrPagination-f2d104d9.js → OrPagination-7f4ed166.js} +1 -1
- package/dist/esm/v3/{OrTabs-d9e2a07e.js → OrTabs-0a5c80be.js} +1 -1
- package/dist/esm/v3/components/index.js +5 -5
- package/dist/esm/v3/components/or-card-collection-v3/index.js +2 -2
- package/dist/esm/v3/components/or-date-time-picker-v3/OrDateTimePicker.vue.d.ts +2 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/hooks/useDefaultDate.d.ts +1 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/hooks/useDefaultHours.d.ts +1 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/hooks/useDefaultMinutes.d.ts +1 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/hooks/useDefaultMonth.d.ts +1 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/hooks/useDefaultYear.d.ts +1 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/index.js +2 -2
- package/dist/{bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/OrDateTimePickerDateSelect.vue.d.ts → esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/OrDateTimePickerDaySelect.vue.d.ts} +8 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.d.ts +3 -0
- package/dist/esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-month-select/OrDateTimePickerMonthSelect.vue.d.ts +26 -34
- package/dist/esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-time-select/OrDateTimePickerTimeSelect.vue.d.ts +8 -20
- package/dist/esm/v3/components/or-menu-v3/OrMenu.vue.d.ts +2 -0
- package/dist/esm/v3/components/or-menu-v3/index.js +1 -1
- package/dist/esm/v3/components/or-pagination-v3/index.js +2 -2
- package/dist/esm/v3/components/or-tabs-v3/index.js +2 -2
- package/dist/esm/v3/index.js +5 -5
- package/package.json +2 -2
- package/src/components/or-date-time-picker-v3/OrDateTimePicker.vue +17 -8
- package/src/components/or-date-time-picker-v3/hooks/useDefaultDate.ts +3 -0
- package/src/components/or-date-time-picker-v3/hooks/useDefaultHours.ts +3 -0
- package/src/components/or-date-time-picker-v3/hooks/useDefaultMinutes.ts +3 -0
- package/src/components/or-date-time-picker-v3/hooks/useDefaultMonth.ts +3 -0
- package/src/components/or-date-time-picker-v3/hooks/useDefaultYear.ts +3 -0
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/OrDateTimePickerDaySelect.vue +162 -0
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.ts +28 -0
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-month-select/OrDateTimePickerMonthSelect.vue +101 -79
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-time-select/OrDateTimePickerTimeSelect.vue +58 -42
- package/src/components/or-menu-v3/OrMenu.vue +3 -0
- package/dist/bundled/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/styles.d.ts +0 -1
- package/dist/bundled/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/styles.d.ts +0 -1
- package/dist/esm/v2/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/styles.d.ts +0 -1
- package/dist/esm/v3/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/styles.d.ts +0 -1
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/OrDateTimePickerDateSelect.vue +0 -63
- package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-date-select/styles.ts +0 -10
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="root"
|
|
4
|
+
:class="rootStyles"
|
|
5
|
+
>
|
|
6
|
+
<div :class="buttonGroupStyles">
|
|
7
|
+
<OrButton
|
|
8
|
+
v-for="value in dayOptions"
|
|
9
|
+
:key="Number(value)"
|
|
10
|
+
:class="buttonGroupItemStyles"
|
|
11
|
+
:variant="Number(value) === Number(proxyModelValue) ? 'contained' : 'text'"
|
|
12
|
+
:color="Number(value) === Number(proxyModelValue) ? 'primary' : 'inherit'"
|
|
13
|
+
@click.stop="proxyModelValue = value"
|
|
14
|
+
>
|
|
15
|
+
{{ formatDay(value) }}
|
|
16
|
+
</OrButton>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import { computed, defineComponent, ref } from 'vue-demi';
|
|
23
|
+
import { OrButtonV3 as OrButton } from '../../../or-button-v3';
|
|
24
|
+
import { useDefaultDate } from '../../hooks/useDefaultDate';
|
|
25
|
+
import { useDefaultHours } from '../../hooks/useDefaultHours';
|
|
26
|
+
import { useDefaultMinutes } from '../../hooks/useDefaultMinutes';
|
|
27
|
+
import { useDefaultMonth } from '../../hooks/useDefaultMonth';
|
|
28
|
+
import { useDefaultYear } from '../../hooks/useDefaultYear';
|
|
29
|
+
import { DateTimePickerDaySelect, DateTimePickerDaySelectButtonGroup, DateTimePickerDaySelectButtonGroupItem } from './styles';
|
|
30
|
+
|
|
31
|
+
export default defineComponent({
|
|
32
|
+
name: 'OrDateTimePickerDaySelect',
|
|
33
|
+
|
|
34
|
+
components: {
|
|
35
|
+
OrButton,
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
model: {
|
|
39
|
+
prop: 'modelValue',
|
|
40
|
+
event: 'update:modelValue',
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
props: {
|
|
44
|
+
modelValue: {
|
|
45
|
+
type: Date,
|
|
46
|
+
default: undefined,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
emits: [
|
|
51
|
+
'update:modelValue',
|
|
52
|
+
],
|
|
53
|
+
|
|
54
|
+
expose: [
|
|
55
|
+
'root',
|
|
56
|
+
],
|
|
57
|
+
|
|
58
|
+
setup(props, context) {
|
|
59
|
+
// Refs
|
|
60
|
+
const root = ref<HTMLElement>();
|
|
61
|
+
|
|
62
|
+
// Styles
|
|
63
|
+
const rootStyles = computed(() => [
|
|
64
|
+
'or-date-time-picker-day-select',
|
|
65
|
+
...DateTimePickerDaySelect,
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const buttonGroupStyles = computed(() => [
|
|
69
|
+
...DateTimePickerDaySelectButtonGroup,
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
const buttonGroupItemStyles = computed(() => [
|
|
73
|
+
...DateTimePickerDaySelectButtonGroupItem,
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
// State
|
|
77
|
+
const proxyModelValue = computed({
|
|
78
|
+
get: () => props.modelValue ?? new Date(Date.UTC(
|
|
79
|
+
useDefaultYear(),
|
|
80
|
+
useDefaultMonth(),
|
|
81
|
+
useDefaultDate(),
|
|
82
|
+
useDefaultHours(),
|
|
83
|
+
useDefaultMinutes(),
|
|
84
|
+
)),
|
|
85
|
+
|
|
86
|
+
set: (value) => {
|
|
87
|
+
context.emit('update:modelValue', value);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const dayOptions = computed(() => {
|
|
92
|
+
const monthStartDate = new Date(Date.UTC(
|
|
93
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
94
|
+
proxyModelValue.value.getUTCMonth(),
|
|
95
|
+
1,
|
|
96
|
+
proxyModelValue.value.getUTCHours(),
|
|
97
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
98
|
+
));
|
|
99
|
+
|
|
100
|
+
const monthEndDate = new Date(Date.UTC(
|
|
101
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
102
|
+
proxyModelValue.value.getUTCMonth() + 1,
|
|
103
|
+
0,
|
|
104
|
+
proxyModelValue.value.getUTCHours(),
|
|
105
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
106
|
+
));
|
|
107
|
+
|
|
108
|
+
const calendarStartDate = new Date(Date.UTC(
|
|
109
|
+
monthStartDate.getUTCFullYear(),
|
|
110
|
+
monthStartDate.getUTCMonth(),
|
|
111
|
+
1 - (monthStartDate.getUTCDay() + 6) % 7,
|
|
112
|
+
monthStartDate.getUTCHours(),
|
|
113
|
+
monthStartDate.getUTCMinutes(),
|
|
114
|
+
));
|
|
115
|
+
|
|
116
|
+
const calendarEndDate = new Date(Date.UTC(
|
|
117
|
+
monthEndDate.getUTCFullYear(),
|
|
118
|
+
monthEndDate.getUTCMonth() + 1,
|
|
119
|
+
(7 - monthEndDate.getUTCDay()) % 7,
|
|
120
|
+
monthEndDate.getUTCHours(),
|
|
121
|
+
monthEndDate.getUTCMinutes(),
|
|
122
|
+
));
|
|
123
|
+
|
|
124
|
+
return (() => {
|
|
125
|
+
let options = [] as Date[], value = calendarStartDate;
|
|
126
|
+
|
|
127
|
+
while (Number(value) !== Number(calendarEndDate)) {
|
|
128
|
+
options = [...options, value];
|
|
129
|
+
|
|
130
|
+
value = new Date(Date.UTC(
|
|
131
|
+
value.getUTCFullYear(),
|
|
132
|
+
value.getUTCMonth(),
|
|
133
|
+
value.getUTCDate() + 1,
|
|
134
|
+
value.getUTCHours(),
|
|
135
|
+
value.getUTCMinutes(),
|
|
136
|
+
));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return options;
|
|
140
|
+
})();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Methods
|
|
144
|
+
function formatDay(value: Date): string {
|
|
145
|
+
return value.toLocaleString('default', {
|
|
146
|
+
day: 'numeric',
|
|
147
|
+
timeZone: 'UTC',
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
root,
|
|
153
|
+
rootStyles,
|
|
154
|
+
buttonGroupStyles,
|
|
155
|
+
buttonGroupItemStyles,
|
|
156
|
+
proxyModelValue,
|
|
157
|
+
dayOptions,
|
|
158
|
+
formatDay,
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
</script>
|
package/src/components/or-date-time-picker-v3/partials/or-date-time-picker-day-select/styles.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const DateTimePickerDaySelect: string[] = [
|
|
2
|
+
// Layout
|
|
3
|
+
'layout-column',
|
|
4
|
+
|
|
5
|
+
// Spacing
|
|
6
|
+
'px-md',
|
|
7
|
+
'py-md',
|
|
8
|
+
|
|
9
|
+
'gap-sm',
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export const DateTimePickerDaySelectButtonGroup: string[] = [
|
|
13
|
+
// Layout
|
|
14
|
+
'grid',
|
|
15
|
+
'grid-cols-7',
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
export const DateTimePickerDaySelectButtonGroupItem: string[] = [
|
|
19
|
+
// Box
|
|
20
|
+
'min-w-fit',
|
|
21
|
+
|
|
22
|
+
// Spacing
|
|
23
|
+
'!px-sm',
|
|
24
|
+
'!py-sm',
|
|
25
|
+
|
|
26
|
+
// Typography
|
|
27
|
+
'typography-caption-regular',
|
|
28
|
+
];
|
|
@@ -5,58 +5,60 @@
|
|
|
5
5
|
>
|
|
6
6
|
<OrIconButton
|
|
7
7
|
:icon="'chevron_left'"
|
|
8
|
-
@click.stop="
|
|
8
|
+
@click.stop="goToPreviousMonth()"
|
|
9
9
|
/>
|
|
10
10
|
|
|
11
|
-
<div :class="['layout-row', 'gap-md']">
|
|
11
|
+
<div :class="['layout-row-reverse', 'gap-md']">
|
|
12
12
|
<OrButton
|
|
13
|
-
ref="
|
|
13
|
+
ref="yearButton"
|
|
14
14
|
:variant="'link'"
|
|
15
15
|
:color="'inherit'"
|
|
16
|
-
@click.stop="
|
|
16
|
+
@click.stop="yearMenu.open()"
|
|
17
17
|
>
|
|
18
|
-
{{
|
|
18
|
+
{{ formatYear(proxyModelValue) }} <OrIcon :icon="yearMenuState === 'open' ? 'arrow_drop_up' : 'arrow_drop_down'" />
|
|
19
19
|
</OrButton>
|
|
20
20
|
|
|
21
21
|
<OrButton
|
|
22
|
-
ref="
|
|
22
|
+
ref="monthButton"
|
|
23
23
|
:variant="'link'"
|
|
24
24
|
:color="'inherit'"
|
|
25
|
-
@click.stop="
|
|
25
|
+
@click.stop="monthMenu.open()"
|
|
26
26
|
>
|
|
27
|
-
{{
|
|
27
|
+
{{ formatMonth(proxyModelValue) }} <OrIcon :icon="monthMenuState === 'open' ? 'arrow_drop_up' : 'arrow_drop_down'" />
|
|
28
28
|
</OrButton>
|
|
29
29
|
|
|
30
30
|
<OrMenu
|
|
31
|
-
ref="
|
|
32
|
-
:trigger="
|
|
31
|
+
ref="yearMenu"
|
|
32
|
+
:trigger="yearButtonRoot"
|
|
33
33
|
>
|
|
34
34
|
<OrMenuItem
|
|
35
|
-
v-for="
|
|
36
|
-
:key="
|
|
37
|
-
|
|
35
|
+
v-for="value in yearOptions"
|
|
36
|
+
:key="Number(value)"
|
|
37
|
+
:selected="Number(value) === Number(proxyModelValue)"
|
|
38
|
+
@click.stop="proxyModelValue = value; yearMenu.close()"
|
|
38
39
|
>
|
|
39
|
-
{{
|
|
40
|
+
{{ formatYear(value) }}
|
|
40
41
|
</OrMenuItem>
|
|
41
42
|
</OrMenu>
|
|
42
43
|
|
|
43
44
|
<OrMenu
|
|
44
|
-
ref="
|
|
45
|
-
:trigger="
|
|
45
|
+
ref="monthMenu"
|
|
46
|
+
:trigger="monthButtonRoot"
|
|
46
47
|
>
|
|
47
48
|
<OrMenuItem
|
|
48
|
-
v-for="
|
|
49
|
-
:key="
|
|
50
|
-
|
|
49
|
+
v-for="value in monthOptions"
|
|
50
|
+
:key="Number(value)"
|
|
51
|
+
:selected="Number(value) === Number(proxyModelValue)"
|
|
52
|
+
@click.stop="proxyModelValue = value; monthMenu.close()"
|
|
51
53
|
>
|
|
52
|
-
{{
|
|
54
|
+
{{ formatMonth(value) }}
|
|
53
55
|
</OrMenuItem>
|
|
54
56
|
</OrMenu>
|
|
55
57
|
</div>
|
|
56
58
|
|
|
57
59
|
<OrIconButton
|
|
58
60
|
:icon="'chevron_right'"
|
|
59
|
-
@click.stop="
|
|
61
|
+
@click.stop="goToNextMonth()"
|
|
60
62
|
/>
|
|
61
63
|
</div>
|
|
62
64
|
</template>
|
|
@@ -68,6 +70,11 @@ import { OrIconButtonV3 as OrIconButton } from '../../../or-icon-button-v3';
|
|
|
68
70
|
import { OrIconV3 as OrIcon } from '../../../or-icon-v3';
|
|
69
71
|
import { OrMenuItemV3 as OrMenuItem } from '../../../or-menu-item-v3';
|
|
70
72
|
import { OrMenuV3 as OrMenu } from '../../../or-menu-v3';
|
|
73
|
+
import { useDefaultDate } from '../../hooks/useDefaultDate';
|
|
74
|
+
import { useDefaultHours } from '../../hooks/useDefaultHours';
|
|
75
|
+
import { useDefaultMinutes } from '../../hooks/useDefaultMinutes';
|
|
76
|
+
import { useDefaultMonth } from '../../hooks/useDefaultMonth';
|
|
77
|
+
import { useDefaultYear } from '../../hooks/useDefaultYear';
|
|
71
78
|
import { DateTimePickerMonthSelect } from './styles';
|
|
72
79
|
|
|
73
80
|
export default defineComponent({
|
|
@@ -105,17 +112,17 @@ export default defineComponent({
|
|
|
105
112
|
// Refs
|
|
106
113
|
const root = ref<HTMLElement>();
|
|
107
114
|
|
|
108
|
-
const monthButton = ref<InstanceType<typeof OrButton>>();
|
|
109
115
|
const yearButton = ref<InstanceType<typeof OrButton>>();
|
|
116
|
+
const monthButton = ref<InstanceType<typeof OrButton>>();
|
|
110
117
|
|
|
111
|
-
const monthButtonRoot = computed(() => monthButton.value?.root);
|
|
112
118
|
const yearButtonRoot = computed(() => yearButton.value?.root);
|
|
119
|
+
const monthButtonRoot = computed(() => monthButton.value?.root);
|
|
113
120
|
|
|
114
|
-
const monthMenu = ref<InstanceType<typeof OrMenu>>();
|
|
115
121
|
const yearMenu = ref<InstanceType<typeof OrMenu>>();
|
|
122
|
+
const monthMenu = ref<InstanceType<typeof OrMenu>>();
|
|
116
123
|
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
const yearMenuState = computed(() => yearMenu.value?.state);
|
|
125
|
+
const monthMenuState = computed(() => monthMenu.value?.state);
|
|
119
126
|
|
|
120
127
|
// Styles
|
|
121
128
|
const rootStyles = computed(() => [
|
|
@@ -125,85 +132,100 @@ export default defineComponent({
|
|
|
125
132
|
|
|
126
133
|
// State
|
|
127
134
|
const proxyModelValue = computed({
|
|
128
|
-
get: () => props.modelValue
|
|
135
|
+
get: () => props.modelValue ?? new Date(Date.UTC(
|
|
136
|
+
useDefaultYear(),
|
|
137
|
+
useDefaultMonth(),
|
|
138
|
+
useDefaultDate(),
|
|
139
|
+
useDefaultHours(),
|
|
140
|
+
useDefaultMinutes(),
|
|
141
|
+
)),
|
|
129
142
|
|
|
130
143
|
set: (value) => {
|
|
131
144
|
context.emit('update:modelValue', value);
|
|
132
145
|
},
|
|
133
146
|
});
|
|
134
147
|
|
|
135
|
-
const
|
|
136
|
-
|
|
148
|
+
const yearOptions = computed(() => {
|
|
149
|
+
return Array.from({ length: 11 }).map((_value, index, { length }) => {
|
|
150
|
+
const value = proxyModelValue.value.getUTCFullYear() - Math.floor(length / 2) + index;
|
|
137
151
|
|
|
138
|
-
|
|
139
|
-
proxyModelValue.value = new Date(Date.UTC(
|
|
152
|
+
return new Date(Date.UTC(
|
|
140
153
|
value,
|
|
141
|
-
proxyModelValue.value
|
|
142
|
-
proxyModelValue.value
|
|
143
|
-
proxyModelValue.value
|
|
144
|
-
proxyModelValue.value
|
|
154
|
+
proxyModelValue.value.getUTCMonth(),
|
|
155
|
+
proxyModelValue.value.getUTCDate(),
|
|
156
|
+
proxyModelValue.value.getUTCHours(),
|
|
157
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
145
158
|
));
|
|
146
|
-
}
|
|
159
|
+
});
|
|
147
160
|
});
|
|
148
161
|
|
|
149
|
-
const
|
|
150
|
-
|
|
162
|
+
const monthOptions = computed(() => {
|
|
163
|
+
return Array.from({ length: 12 }, (_value, index) => {
|
|
164
|
+
const value = index;
|
|
151
165
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
proxyModelValue.value?.getUTCFullYear() ?? yearValue.value,
|
|
166
|
+
return new Date(Date.UTC(
|
|
167
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
155
168
|
value,
|
|
156
|
-
proxyModelValue.value
|
|
157
|
-
proxyModelValue.value
|
|
158
|
-
proxyModelValue.value
|
|
169
|
+
proxyModelValue.value.getUTCDate(),
|
|
170
|
+
proxyModelValue.value.getUTCHours(),
|
|
171
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
159
172
|
));
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
const yearLabel = computed(() => {
|
|
164
|
-
return yearOptions.find(({ value }) => value === yearValue.value)?.label;
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
const monthLabel = computed(() => {
|
|
168
|
-
return monthOptions.find(({ value }) => value === monthValue.value)?.label;
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
const yearOptions = Array.from({ length: 100 }, (_value, index) => {
|
|
172
|
-
const year = new Date().getUTCFullYear() - index;
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
value: year,
|
|
176
|
-
label: new Date(year, monthValue.value).toLocaleString([], { year: 'numeric' }),
|
|
177
|
-
};
|
|
173
|
+
});
|
|
178
174
|
});
|
|
179
175
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
value
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
176
|
+
// Methods
|
|
177
|
+
function goToNextMonth(): void {
|
|
178
|
+
proxyModelValue.value = new Date(Date.UTC(
|
|
179
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
180
|
+
proxyModelValue.value.getUTCMonth() + 1,
|
|
181
|
+
proxyModelValue.value.getUTCDate(),
|
|
182
|
+
proxyModelValue.value.getUTCHours(),
|
|
183
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
184
|
+
));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function goToPreviousMonth(): void {
|
|
188
|
+
proxyModelValue.value = new Date(Date.UTC(
|
|
189
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
190
|
+
proxyModelValue.value.getUTCMonth() - 1,
|
|
191
|
+
proxyModelValue.value.getUTCDate(),
|
|
192
|
+
proxyModelValue.value.getUTCHours(),
|
|
193
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
194
|
+
));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function formatYear(value: Date): string {
|
|
198
|
+
return value.toLocaleString('default', {
|
|
199
|
+
year: 'numeric',
|
|
200
|
+
timeZone: 'UTC',
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function formatMonth(value: Date): string {
|
|
205
|
+
return value.toLocaleString('default', {
|
|
206
|
+
month: 'long',
|
|
207
|
+
timeZone: 'UTC',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
188
210
|
|
|
189
211
|
return {
|
|
190
212
|
root,
|
|
191
|
-
monthButton,
|
|
192
213
|
yearButton,
|
|
193
|
-
|
|
214
|
+
monthButton,
|
|
194
215
|
yearButtonRoot,
|
|
195
|
-
|
|
216
|
+
monthButtonRoot,
|
|
196
217
|
yearMenu,
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
monthMenu,
|
|
219
|
+
yearMenuState,
|
|
220
|
+
monthMenuState,
|
|
199
221
|
rootStyles,
|
|
200
222
|
proxyModelValue,
|
|
201
|
-
yearValue,
|
|
202
|
-
monthValue,
|
|
203
|
-
yearLabel,
|
|
204
|
-
monthLabel,
|
|
205
223
|
yearOptions,
|
|
206
224
|
monthOptions,
|
|
225
|
+
goToNextMonth,
|
|
226
|
+
goToPreviousMonth,
|
|
227
|
+
formatYear,
|
|
228
|
+
formatMonth,
|
|
207
229
|
};
|
|
208
230
|
},
|
|
209
231
|
});
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
>
|
|
6
6
|
<div :class="buttonGroupStyles">
|
|
7
7
|
<OrButton
|
|
8
|
-
v-for="
|
|
9
|
-
:key="
|
|
8
|
+
v-for="value in hoursOptions"
|
|
9
|
+
:key="Number(value)"
|
|
10
10
|
:class="buttonGroupItemStyles"
|
|
11
|
-
:variant="
|
|
12
|
-
:color="
|
|
13
|
-
@click.stop="
|
|
11
|
+
:variant="Number(value) === Number(proxyModelValue) ? 'contained' : 'text'"
|
|
12
|
+
:color="Number(value) === Number(proxyModelValue) ? 'primary' : 'inherit'"
|
|
13
|
+
@click.stop="proxyModelValue = value"
|
|
14
14
|
>
|
|
15
|
-
{{
|
|
15
|
+
{{ formatHours(value) }}
|
|
16
16
|
</OrButton>
|
|
17
17
|
</div>
|
|
18
18
|
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
|
|
21
21
|
<div :class="buttonGroupStyles">
|
|
22
22
|
<OrButton
|
|
23
|
-
v-for="
|
|
24
|
-
:key="
|
|
23
|
+
v-for="value in minutesOptions"
|
|
24
|
+
:key="Number(value)"
|
|
25
25
|
:class="buttonGroupItemStyles"
|
|
26
|
-
:variant="
|
|
27
|
-
:color="
|
|
28
|
-
@click.stop="
|
|
26
|
+
:variant="Number(value) === Number(proxyModelValue) ? 'contained' : 'text'"
|
|
27
|
+
:color="Number(value) === Number(proxyModelValue) ? 'primary' : 'inherit'"
|
|
28
|
+
@click.stop="proxyModelValue = value"
|
|
29
29
|
>
|
|
30
|
-
{{
|
|
30
|
+
{{ formatMinutes(value) }}
|
|
31
31
|
</OrButton>
|
|
32
32
|
</div>
|
|
33
33
|
</div>
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
<script lang="ts">
|
|
37
37
|
import { computed, defineComponent, ref } from 'vue-demi';
|
|
38
38
|
import { OrButtonV3 as OrButton } from '../../../or-button-v3';
|
|
39
|
+
import { useDefaultDate } from '../../hooks/useDefaultDate';
|
|
40
|
+
import { useDefaultHours } from '../../hooks/useDefaultHours';
|
|
41
|
+
import { useDefaultMinutes } from '../../hooks/useDefaultMinutes';
|
|
42
|
+
import { useDefaultMonth } from '../../hooks/useDefaultMonth';
|
|
43
|
+
import { useDefaultYear } from '../../hooks/useDefaultYear';
|
|
39
44
|
import { DateTimePickerTimeSelect, DateTimePickerTimeSelectButtonGroup, DateTimePickerTimeSelectButtonGroupItem } from './styles';
|
|
40
45
|
|
|
41
46
|
export default defineComponent({
|
|
@@ -85,50 +90,61 @@ export default defineComponent({
|
|
|
85
90
|
|
|
86
91
|
// State
|
|
87
92
|
const proxyModelValue = computed({
|
|
88
|
-
get: () => props.modelValue
|
|
93
|
+
get: () => props.modelValue ?? new Date(Date.UTC(
|
|
94
|
+
useDefaultYear(),
|
|
95
|
+
useDefaultMonth(),
|
|
96
|
+
useDefaultDate(),
|
|
97
|
+
useDefaultHours(),
|
|
98
|
+
useDefaultMinutes(),
|
|
99
|
+
)),
|
|
89
100
|
|
|
90
101
|
set: (value) => {
|
|
91
102
|
context.emit('update:modelValue', value);
|
|
92
103
|
},
|
|
93
104
|
});
|
|
94
105
|
|
|
95
|
-
const
|
|
96
|
-
|
|
106
|
+
const hoursOptions = computed(() => {
|
|
107
|
+
return Array.from({ length: 24 }, (_value, index) => {
|
|
108
|
+
const value = index;
|
|
97
109
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
proxyModelValue.value
|
|
101
|
-
proxyModelValue.value
|
|
102
|
-
proxyModelValue.value?.getUTCDate() ?? 1,
|
|
110
|
+
return new Date(Date.UTC(
|
|
111
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
112
|
+
proxyModelValue.value.getUTCMonth(),
|
|
113
|
+
proxyModelValue.value.getUTCDate(),
|
|
103
114
|
value,
|
|
104
|
-
proxyModelValue.value
|
|
115
|
+
proxyModelValue.value.getUTCMinutes(),
|
|
105
116
|
));
|
|
106
|
-
}
|
|
117
|
+
});
|
|
107
118
|
});
|
|
108
119
|
|
|
109
|
-
const
|
|
110
|
-
|
|
120
|
+
const minutesOptions = computed(() => {
|
|
121
|
+
return Array.from({ length: 60 }, (_value, index) => {
|
|
122
|
+
const value = index;
|
|
111
123
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
proxyModelValue.value
|
|
115
|
-
proxyModelValue.value
|
|
116
|
-
proxyModelValue.value
|
|
117
|
-
proxyModelValue.value?.getUTCHours() ?? hoursValue.value,
|
|
124
|
+
return new Date(Date.UTC(
|
|
125
|
+
proxyModelValue.value.getUTCFullYear(),
|
|
126
|
+
proxyModelValue.value.getUTCMonth(),
|
|
127
|
+
proxyModelValue.value.getUTCDate(),
|
|
128
|
+
proxyModelValue.value.getUTCHours(),
|
|
118
129
|
value,
|
|
119
130
|
));
|
|
120
|
-
}
|
|
131
|
+
});
|
|
121
132
|
});
|
|
122
133
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
// Methods
|
|
135
|
+
function formatHours(value: Date): string {
|
|
136
|
+
return value.toLocaleString('default', {
|
|
137
|
+
hour: '2-digit',
|
|
138
|
+
timeZone: 'UTC',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function formatMinutes(value: Date): string {
|
|
143
|
+
return value.toLocaleString('default', {
|
|
144
|
+
minute: '2-digit',
|
|
145
|
+
timeZone: 'UTC',
|
|
146
|
+
});
|
|
147
|
+
}
|
|
132
148
|
|
|
133
149
|
return {
|
|
134
150
|
root,
|
|
@@ -136,10 +152,10 @@ export default defineComponent({
|
|
|
136
152
|
buttonGroupStyles,
|
|
137
153
|
buttonGroupItemStyles,
|
|
138
154
|
proxyModelValue,
|
|
139
|
-
hoursValue,
|
|
140
|
-
minutesValue,
|
|
141
155
|
hoursOptions,
|
|
142
156
|
minutesOptions,
|
|
157
|
+
formatHours,
|
|
158
|
+
formatMinutes,
|
|
143
159
|
};
|
|
144
160
|
},
|
|
145
161
|
});
|
|
@@ -52,6 +52,7 @@ export default defineComponent({
|
|
|
52
52
|
|
|
53
53
|
expose: [
|
|
54
54
|
'root',
|
|
55
|
+
'state',
|
|
55
56
|
'isOpen',
|
|
56
57
|
'open',
|
|
57
58
|
'close',
|
|
@@ -64,6 +65,7 @@ export default defineComponent({
|
|
|
64
65
|
|
|
65
66
|
const popover = ref<InstanceType<typeof OrPopover>>();
|
|
66
67
|
const popoverRoot = computed(() => popover.value?.root);
|
|
68
|
+
const popoverState = computed(() => popover.value?.state);
|
|
67
69
|
|
|
68
70
|
// Styles
|
|
69
71
|
const rootStyles = computed(() => [
|
|
@@ -112,6 +114,7 @@ export default defineComponent({
|
|
|
112
114
|
root,
|
|
113
115
|
popover,
|
|
114
116
|
popoverRoot,
|
|
117
|
+
state: popoverState,
|
|
115
118
|
rootStyles,
|
|
116
119
|
isOpen,
|
|
117
120
|
open,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DateTimePickerDateSelect: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DateTimePickerDateSelect: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DateTimePickerDateSelect: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DateTimePickerDateSelect: string[];
|