v-calendar-3 1.0.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/LICENSE +9 -0
- package/README.md +142 -0
- package/dist/cjs/index.css +1133 -0
- package/dist/cjs/index.js +10699 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/es/index.js +10678 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/style.css +1134 -0
- package/dist/iife/index.js +2 -0
- package/dist/iife/index.js.map +1 -0
- package/dist/mjs/index.mjs +10678 -0
- package/dist/mjs/index.mjs.map +1 -0
- package/dist/mjs/style.css +1134 -0
- package/dist/style.css +1134 -0
- package/dist/types/components/BaseIcon/BaseIcon.vue.d.ts +41 -0
- package/dist/types/components/BaseIcon/icons/IconChevronDown.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconChevronLeft.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconChevronRight.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/IconClock.vue.d.ts +3 -0
- package/dist/types/components/BaseIcon/icons/index.d.ts +4 -0
- package/dist/types/components/BaseSelect/BaseSelect.vue.d.ts +26 -0
- package/dist/types/components/Calendar/Calendar.vue.d.ts +2526 -0
- package/dist/types/components/Calendar/CalendarDay.vue.d.ts +83 -0
- package/dist/types/components/Calendar/CalendarDayPopover.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarHeader.vue.d.ts +13 -0
- package/dist/types/components/Calendar/CalendarNav.vue.d.ts +4 -0
- package/dist/types/components/Calendar/CalendarNavPopover.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarPage.vue.d.ts +3 -0
- package/dist/types/components/Calendar/CalendarPageProvider.vue.d.ts +17 -0
- package/dist/types/components/Calendar/CalendarSlot.vue.d.ts +15 -0
- package/dist/types/components/Calendar/CalendarTitleSelect.vue.d.ts +15 -0
- package/dist/types/components/CalendarGrid/CalendarCell.vue.d.ts +9 -0
- package/dist/types/components/CalendarGrid/CalendarCellPopover.vue.d.ts +209 -0
- package/dist/types/components/CalendarGrid/CalendarDayCell.vue.d.ts +8 -0
- package/dist/types/components/CalendarGrid/CalendarEventDetails.vue.d.ts +15 -0
- package/dist/types/components/CalendarGrid/CalendarEventEdit.vue.d.ts +26 -0
- package/dist/types/components/CalendarGrid/CalendarGrid.vue.d.ts +134 -0
- package/dist/types/components/CalendarGrid/CalendarGridWeek.vue.d.ts +8 -0
- package/dist/types/components/CalendarGrid/CalendarViewSelect.vue.d.ts +3 -0
- package/dist/types/components/CalendarGrid/CalendarWeekCell.vue.d.ts +10 -0
- package/dist/types/components/CalendarGrid/Constraints.d.ts +16 -0
- package/dist/types/components/DatePicker/DatePicker.vue.d.ts +15251 -0
- package/dist/types/components/DatePicker/DatePickerBase.vue.d.ts +3 -0
- package/dist/types/components/DatePicker/DatePickerPopover.vue.d.ts +3 -0
- package/dist/types/components/DatePicker/TimePicker.vue.d.ts +10089 -0
- package/dist/types/components/Popover/Popover.vue.d.ts +72 -0
- package/dist/types/components/Popover/PopoverRow.vue.d.ts +17 -0
- package/dist/types/components/index.d.ts +4 -0
- package/dist/types/index.d.cts +40981 -0
- package/dist/types/index.d.mts +40981 -0
- package/dist/types/index.d.ts +40981 -0
- package/dist/types/use/base.d.ts +67 -0
- package/dist/types/use/calendar.d.ts +2422 -0
- package/dist/types/use/calendarGrid.d.ts +9370 -0
- package/dist/types/use/datePicker.d.ts +20210 -0
- package/dist/types/use/page.d.ts +20 -0
- package/dist/types/use/slots.d.ts +5 -0
- package/dist/types/use/timePicker.d.ts +10089 -0
- package/dist/types/utils/attribute.d.ts +49 -0
- package/dist/types/utils/cache.d.ts +10 -0
- package/dist/types/utils/calendar/event.d.ts +111 -0
- package/dist/types/utils/config/index.d.ts +5 -0
- package/dist/types/utils/date/helpers.d.ts +161 -0
- package/dist/types/utils/date/range.d.ts +74 -0
- package/dist/types/utils/date/repeat.d.ts +34 -0
- package/dist/types/utils/date/rules.d.ts +82 -0
- package/dist/types/utils/defaults/index.d.ts +30 -0
- package/dist/types/utils/defaults/locales.d.ts +9 -0
- package/dist/types/utils/glyph.d.ts +58 -0
- package/dist/types/utils/helpers.d.ts +49 -0
- package/dist/types/utils/locale.d.ts +48 -0
- package/dist/types/utils/page.d.ts +95 -0
- package/dist/types/utils/plugins/index.d.ts +4 -0
- package/dist/types/utils/popovers.d.ts +47 -0
- package/dist/types/utils/theme.d.ts +17 -0
- package/dist/types/utils/touch.d.ts +8 -0
- package/dist/types/utils/useDisplayMode.d.ts +12 -0
- package/dist/types/utils/watchers.d.ts +6 -0
- package/package.json +115 -0
- package/src/components/BaseIcon/BaseIcon.vue +29 -0
- package/src/components/BaseIcon/icons/IconChevronDown.vue +5 -0
- package/src/components/BaseIcon/icons/IconChevronLeft.vue +5 -0
- package/src/components/BaseIcon/icons/IconChevronRight.vue +5 -0
- package/src/components/BaseIcon/icons/IconClock.vue +11 -0
- package/src/components/BaseIcon/icons/index.ts +4 -0
- package/src/components/BaseSelect/BaseSelect.vue +136 -0
- package/src/components/Calendar/Calendar.vue +116 -0
- package/src/components/Calendar/CalendarDay.vue +422 -0
- package/src/components/Calendar/CalendarDayPopover.vue +44 -0
- package/src/components/Calendar/CalendarHeader.vue +203 -0
- package/src/components/Calendar/CalendarNav.vue +325 -0
- package/src/components/Calendar/CalendarNavPopover.vue +24 -0
- package/src/components/Calendar/CalendarPage.vue +140 -0
- package/src/components/Calendar/CalendarPageProvider.vue +15 -0
- package/src/components/Calendar/CalendarSlot.vue +36 -0
- package/src/components/Calendar/CalendarTitleSelect.vue +72 -0
- package/src/components/CalendarGrid/CalendarCell.vue +112 -0
- package/src/components/CalendarGrid/CalendarCellPopover.vue +93 -0
- package/src/components/CalendarGrid/CalendarDayCell.vue +57 -0
- package/src/components/CalendarGrid/CalendarEventDetails.vue +71 -0
- package/src/components/CalendarGrid/CalendarEventEdit.vue +195 -0
- package/src/components/CalendarGrid/CalendarGrid.vue +715 -0
- package/src/components/CalendarGrid/CalendarGridWeek.vue +60 -0
- package/src/components/CalendarGrid/CalendarViewSelect.vue +34 -0
- package/src/components/CalendarGrid/CalendarWeekCell.vue +52 -0
- package/src/components/CalendarGrid/Constraints.ts +40 -0
- package/src/components/DatePicker/DatePicker.vue +27 -0
- package/src/components/DatePicker/DatePickerBase.vue +53 -0
- package/src/components/DatePicker/DatePickerPopover.vue +37 -0
- package/src/components/DatePicker/TimePicker.vue +167 -0
- package/src/components/Popover/Popover.vue +572 -0
- package/src/components/Popover/PopoverRow.vue +94 -0
- package/src/components/index.ts +4 -0
- package/src/index.ts +24 -0
- package/src/styles/index.css +48 -0
- package/src/styles/theme.css +322 -0
- package/src/styles/transitions.css +77 -0
- package/src/use/base.ts +144 -0
- package/src/use/calendar.ts +796 -0
- package/src/use/calendarGrid.ts +954 -0
- package/src/use/datePicker.ts +909 -0
- package/src/use/page.ts +78 -0
- package/src/use/slots.ts +17 -0
- package/src/use/timePicker.ts +194 -0
- package/src/utils/attribute.ts +107 -0
- package/src/utils/cache.ts +30 -0
- package/src/utils/calendar/event.ts +335 -0
- package/src/utils/config/index.ts +11 -0
- package/src/utils/date/helpers.ts +1039 -0
- package/src/utils/date/range.ts +274 -0
- package/src/utils/date/repeat.ts +135 -0
- package/src/utils/date/rules.ts +290 -0
- package/src/utils/defaults/index.ts +77 -0
- package/src/utils/defaults/locales.ts +123 -0
- package/src/utils/defaults/masks.json +15 -0
- package/src/utils/defaults/touch.json +5 -0
- package/src/utils/glyph.ts +305 -0
- package/src/utils/helpers.ts +181 -0
- package/src/utils/locale.ts +275 -0
- package/src/utils/page.ts +608 -0
- package/src/utils/plugins/index.ts +24 -0
- package/src/utils/popovers.ts +216 -0
- package/src/utils/theme.ts +58 -0
- package/src/utils/touch.ts +72 -0
- package/src/utils/useDisplayMode.ts +198 -0
- package/src/utils/watchers.ts +26 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="vc-grid-week-cells" :style="weekCellsStyle">
|
|
3
|
+
<template v-for="cell in cells" :key="cell.data.key">
|
|
4
|
+
<CalendarWeekCell
|
|
5
|
+
:cell="cell"
|
|
6
|
+
:min-day-index="minDayIndex"
|
|
7
|
+
:max-day-index="maxDayIndex"
|
|
8
|
+
/>
|
|
9
|
+
</template>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
export default {
|
|
15
|
+
name: 'CalendarGridWeek',
|
|
16
|
+
};
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { computed } from 'vue';
|
|
21
|
+
import CalendarWeekCell from './CalendarWeekCell.vue';
|
|
22
|
+
import { useCalendarGrid } from '../../use/calendarGrid';
|
|
23
|
+
import { DateRangeCell } from '../../utils/date/range';
|
|
24
|
+
import { Event } from '../../utils/calendar/event';
|
|
25
|
+
import { CalendarDay } from '../../utils/page';
|
|
26
|
+
|
|
27
|
+
const props = defineProps<{
|
|
28
|
+
days: CalendarDay[];
|
|
29
|
+
}>();
|
|
30
|
+
|
|
31
|
+
const { isMonthly, eventsContext } = useCalendarGrid();
|
|
32
|
+
|
|
33
|
+
const minDayIndex = computed(() => props.days[0]?.dayIndex ?? 0);
|
|
34
|
+
const maxDayIndex = computed(
|
|
35
|
+
() => props.days[props.days.length - 1]?.dayIndex ?? 0,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const cells = computed(() => {
|
|
39
|
+
const result: Array<DateRangeCell<Event>> = [];
|
|
40
|
+
const added: Record<string, boolean> = {};
|
|
41
|
+
|
|
42
|
+
props.days.forEach(day => {
|
|
43
|
+
const cells = eventsContext.value.getCells(day);
|
|
44
|
+
cells.forEach((cell: DateRangeCell<Event>) => {
|
|
45
|
+
if ((!cell.data.isWeekly && !isMonthly.value) || added[cell.data.key]) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
result.push(cell);
|
|
49
|
+
added[cell.data.key] = true;
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return result;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const weekCellsStyle = computed(() => {
|
|
57
|
+
const numDays = props.days.length;
|
|
58
|
+
return { gridTemplateColumns: `repeat(${numDays}, 1fr)` };
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<BaseSelect
|
|
3
|
+
v-model="view"
|
|
4
|
+
:options="viewOptions"
|
|
5
|
+
class="vc-view-select"
|
|
6
|
+
show-icon
|
|
7
|
+
/>
|
|
8
|
+
</template>
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed } from 'vue';
|
|
11
|
+
import { useCalendar } from '../../use/calendar';
|
|
12
|
+
import { capitalize } from '../../utils/helpers';
|
|
13
|
+
import BaseSelect from '../BaseSelect/BaseSelect.vue';
|
|
14
|
+
|
|
15
|
+
const { locale, view } = useCalendar();
|
|
16
|
+
|
|
17
|
+
const viewOptions = computed(() => {
|
|
18
|
+
const names = locale.value.relativeTimeNames;
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
21
|
+
value: 'daily',
|
|
22
|
+
label: capitalize(names.day!),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
value: 'weekly',
|
|
26
|
+
label: capitalize(names.week!),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'monthly',
|
|
30
|
+
label: capitalize(names.month!),
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<CalendarCell
|
|
3
|
+
:cell="cell"
|
|
4
|
+
:class="[
|
|
5
|
+
'is-2xs',
|
|
6
|
+
`is-${fill}`,
|
|
7
|
+
{
|
|
8
|
+
'is-2xs': true,
|
|
9
|
+
'has-start': hasStart,
|
|
10
|
+
'has-end': hasEnd,
|
|
11
|
+
},
|
|
12
|
+
]"
|
|
13
|
+
:style="style"
|
|
14
|
+
/>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed } from 'vue';
|
|
19
|
+
import { useCalendarGrid } from '../../use/calendarGrid';
|
|
20
|
+
import { Event } from '../../utils/calendar/event';
|
|
21
|
+
import { DateRangeCell } from '../../utils/date/range';
|
|
22
|
+
import CalendarCell from './CalendarCell.vue';
|
|
23
|
+
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
cell: DateRangeCell<Event>;
|
|
26
|
+
minDayIndex: number;
|
|
27
|
+
maxDayIndex: number;
|
|
28
|
+
}>();
|
|
29
|
+
|
|
30
|
+
const { isMonthly } = useCalendarGrid();
|
|
31
|
+
|
|
32
|
+
const event = computed(() => props.cell.data);
|
|
33
|
+
const hasStart = computed(() => props.minDayIndex <= props.cell.startDay);
|
|
34
|
+
const hasEnd = computed(() => props.maxDayIndex >= props.cell.endDay);
|
|
35
|
+
|
|
36
|
+
const fill = computed(() => {
|
|
37
|
+
if (isMonthly.value && !event.value.isWeekly) return 'transparent';
|
|
38
|
+
return event.value.fill;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const style = computed(() => {
|
|
42
|
+
const gridColumnStart = Math.max(
|
|
43
|
+
props.cell.startDay - props.minDayIndex + 1,
|
|
44
|
+
1,
|
|
45
|
+
);
|
|
46
|
+
const gridColumnEnd = Math.min(props.cell.endDay - props.maxDayIndex - 1, -1);
|
|
47
|
+
return {
|
|
48
|
+
gridColumnStart,
|
|
49
|
+
gridColumnEnd,
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type ConstraintType =
|
|
2
|
+
| 'MIN_DURATION'
|
|
3
|
+
| 'MAX_DURATION'
|
|
4
|
+
| 'BEFORE_DAY'
|
|
5
|
+
| 'AFTER_DAY'
|
|
6
|
+
| 'OUTSIDE_DAY';
|
|
7
|
+
|
|
8
|
+
type ConstraintRecovery = false | 'RESIZE';
|
|
9
|
+
|
|
10
|
+
interface ConstraintOptions {
|
|
11
|
+
durationMinutes?: number;
|
|
12
|
+
recover: ConstraintRecovery;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Constraint {
|
|
16
|
+
type: ConstraintType;
|
|
17
|
+
options?: ConstraintOptions;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class Constraints {
|
|
21
|
+
constraints: Constraint[];
|
|
22
|
+
|
|
23
|
+
constructor(constraints: Constraint[]) {
|
|
24
|
+
this.constraints = constraints.filter(c => this.validConstraint(c));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
validConstraint(constraint: Constraint) {
|
|
28
|
+
switch (constraint.type) {
|
|
29
|
+
case 'MIN_DURATION':
|
|
30
|
+
case 'MAX_DURATION': {
|
|
31
|
+
if (!constraint.options?.durationMinutes) {
|
|
32
|
+
console.error(
|
|
33
|
+
`Invalid constraint option for ${constraint.type}. Missing duration.`,
|
|
34
|
+
);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="$slots.default">
|
|
3
|
+
<slot v-bind="slotCtx" />
|
|
4
|
+
<DatePickerPopover v-bind="$attrs" />
|
|
5
|
+
</template>
|
|
6
|
+
<DatePickerBase v-else v-bind="$attrs" />
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { defineComponent, reactive } from 'vue';
|
|
11
|
+
import { createDatePicker, emits, propsDef } from '../../use/datePicker';
|
|
12
|
+
import { omit } from '../../utils/helpers';
|
|
13
|
+
import DatePickerBase from './DatePickerBase.vue';
|
|
14
|
+
import DatePickerPopover from './DatePickerPopover.vue';
|
|
15
|
+
|
|
16
|
+
export default defineComponent({
|
|
17
|
+
inheritAttrs: false,
|
|
18
|
+
emits,
|
|
19
|
+
props: propsDef,
|
|
20
|
+
components: { DatePickerBase, DatePickerPopover },
|
|
21
|
+
setup(props, ctx) {
|
|
22
|
+
const datePicker = createDatePicker(props, ctx);
|
|
23
|
+
const slotCtx = reactive(omit(datePicker, 'calendarRef', 'popoverRef'));
|
|
24
|
+
return { ...datePicker, slotCtx };
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="isTimeMode"
|
|
4
|
+
:class="`vc-container vc-bordered vc-${color} vc-${displayMode}`"
|
|
5
|
+
>
|
|
6
|
+
<TimePicker
|
|
7
|
+
v-for="position in positions"
|
|
8
|
+
:key="position"
|
|
9
|
+
:position="position"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
<Calendar
|
|
13
|
+
v-else
|
|
14
|
+
:attributes="attributes"
|
|
15
|
+
ref="calendarRef"
|
|
16
|
+
@dayclick="onDayClick"
|
|
17
|
+
@daymouseenter="onDayMouseEnter"
|
|
18
|
+
@daykeydown="onDayKeydown"
|
|
19
|
+
>
|
|
20
|
+
<template #footer>
|
|
21
|
+
<template v-if="isDateTimeMode">
|
|
22
|
+
<TimePicker
|
|
23
|
+
v-for="position in positions"
|
|
24
|
+
:key="position"
|
|
25
|
+
:position="position"
|
|
26
|
+
/>
|
|
27
|
+
</template>
|
|
28
|
+
<CalendarSlot name="dp-footer" />
|
|
29
|
+
</template>
|
|
30
|
+
</Calendar>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { useDatePicker } from '../../use/datePicker';
|
|
35
|
+
import Calendar from '../Calendar/Calendar.vue';
|
|
36
|
+
import CalendarSlot from '../Calendar/CalendarSlot.vue';
|
|
37
|
+
import TimePicker from './TimePicker.vue';
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
attributes,
|
|
41
|
+
calendarRef,
|
|
42
|
+
color,
|
|
43
|
+
displayMode,
|
|
44
|
+
isDateTimeMode,
|
|
45
|
+
isTimeMode,
|
|
46
|
+
isRange,
|
|
47
|
+
onDayClick,
|
|
48
|
+
onDayMouseEnter,
|
|
49
|
+
onDayKeydown,
|
|
50
|
+
} = useDatePicker();
|
|
51
|
+
|
|
52
|
+
const positions = isRange.value ? [0, 1] : [0];
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Popover
|
|
3
|
+
:id="datePickerPopoverId"
|
|
4
|
+
placement="bottom-start"
|
|
5
|
+
:class="`vc-date-picker-content vc-${color} vc-${displayMode}`"
|
|
6
|
+
ref="popoverRef"
|
|
7
|
+
@before-show="onPopoverBeforeShow"
|
|
8
|
+
@after-show="onPopoverAfterShow"
|
|
9
|
+
@before-hide="onPopoverBeforeHide"
|
|
10
|
+
@after-hide="onPopoverAfterHide"
|
|
11
|
+
>
|
|
12
|
+
<DatePickerBase v-bind="$attrs" />
|
|
13
|
+
</Popover>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
export default {
|
|
18
|
+
inheritAttrs: false,
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { useDatePicker } from '../../use/datePicker';
|
|
24
|
+
import Popover from '../Popover/Popover.vue';
|
|
25
|
+
import DatePickerBase from './DatePickerBase.vue';
|
|
26
|
+
|
|
27
|
+
const {
|
|
28
|
+
datePickerPopoverId,
|
|
29
|
+
color,
|
|
30
|
+
displayMode,
|
|
31
|
+
popoverRef,
|
|
32
|
+
onPopoverBeforeShow,
|
|
33
|
+
onPopoverAfterShow,
|
|
34
|
+
onPopoverBeforeHide,
|
|
35
|
+
onPopoverAfterHide,
|
|
36
|
+
} = useDatePicker();
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="vc-time-picker"
|
|
4
|
+
:class="[{ 'vc-invalid': !isValid, 'vc-attached': !isTimeMode }]"
|
|
5
|
+
>
|
|
6
|
+
<CalendarSlot name="time-header">
|
|
7
|
+
<div v-if="showHeader && date" class="vc-time-header">
|
|
8
|
+
<span class="vc-time-weekday">
|
|
9
|
+
{{ locale.formatDate(date, 'WWW') }}
|
|
10
|
+
</span>
|
|
11
|
+
<span class="vc-time-month">
|
|
12
|
+
{{ locale.formatDate(date, 'MMM') }}
|
|
13
|
+
</span>
|
|
14
|
+
<span class="vc-time-day">
|
|
15
|
+
{{ locale.formatDate(date, 'D') }}
|
|
16
|
+
</span>
|
|
17
|
+
<span class="vc-time-year">
|
|
18
|
+
{{ locale.formatDate(date, 'YYYY') }}
|
|
19
|
+
</span>
|
|
20
|
+
</div>
|
|
21
|
+
</CalendarSlot>
|
|
22
|
+
<div class="vc-time-select-group">
|
|
23
|
+
<BaseIcon name="Clock" size="17" />
|
|
24
|
+
<BaseSelect
|
|
25
|
+
v-model.number="hours"
|
|
26
|
+
:options="hourOptions"
|
|
27
|
+
class="vc-time-select-hours"
|
|
28
|
+
align-right
|
|
29
|
+
/>
|
|
30
|
+
<template v-if="timeAccuracy > 1">
|
|
31
|
+
<span class="vc-time-colon">:</span>
|
|
32
|
+
<BaseSelect
|
|
33
|
+
v-model.number="minutes"
|
|
34
|
+
:options="options.minutes"
|
|
35
|
+
class="vc-time-select-minutes"
|
|
36
|
+
:align-left="timeAccuracy === 2"
|
|
37
|
+
/>
|
|
38
|
+
</template>
|
|
39
|
+
<template v-if="timeAccuracy > 2">
|
|
40
|
+
<span class="vc-time-colon">:</span>
|
|
41
|
+
<BaseSelect
|
|
42
|
+
v-model.number="seconds"
|
|
43
|
+
:options="options.seconds"
|
|
44
|
+
class="vc-time-select-seconds"
|
|
45
|
+
:align-left="timeAccuracy === 3"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
<template v-if="timeAccuracy > 3">
|
|
49
|
+
<span class="vc-time-decimal">.</span>
|
|
50
|
+
<BaseSelect
|
|
51
|
+
v-model.number="milliseconds"
|
|
52
|
+
:options="options.milliseconds"
|
|
53
|
+
class="vc-time-select-milliseconds"
|
|
54
|
+
align-left
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
<BaseSelect v-if="!is24hr" v-model="isAM" :options="isAMOptions" />
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { createTimePicker } from '../../use/timePicker';
|
|
64
|
+
import BaseIcon from '../BaseIcon/BaseIcon.vue';
|
|
65
|
+
import BaseSelect from '../BaseSelect/BaseSelect.vue';
|
|
66
|
+
import CalendarSlot from '../Calendar/CalendarSlot.vue';
|
|
67
|
+
|
|
68
|
+
const props = defineProps<{
|
|
69
|
+
position: number;
|
|
70
|
+
}>();
|
|
71
|
+
|
|
72
|
+
const timePicker = createTimePicker(props);
|
|
73
|
+
defineExpose(timePicker);
|
|
74
|
+
const {
|
|
75
|
+
locale,
|
|
76
|
+
isValid,
|
|
77
|
+
date,
|
|
78
|
+
hours,
|
|
79
|
+
minutes,
|
|
80
|
+
seconds,
|
|
81
|
+
milliseconds,
|
|
82
|
+
options,
|
|
83
|
+
hourOptions,
|
|
84
|
+
isTimeMode,
|
|
85
|
+
isAM,
|
|
86
|
+
isAMOptions,
|
|
87
|
+
is24hr,
|
|
88
|
+
showHeader,
|
|
89
|
+
timeAccuracy,
|
|
90
|
+
} = timePicker;
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<style lang="css">
|
|
94
|
+
.vc-time-picker {
|
|
95
|
+
display: flex;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
align-items: center;
|
|
98
|
+
padding: 8px 4px;
|
|
99
|
+
&.vc-invalid {
|
|
100
|
+
pointer-events: none;
|
|
101
|
+
opacity: 0.5;
|
|
102
|
+
}
|
|
103
|
+
&.vc-attached {
|
|
104
|
+
border-top: 1px solid var(--vc-time-picker-border);
|
|
105
|
+
}
|
|
106
|
+
> * + * {
|
|
107
|
+
margin-top: 4px;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.vc-time-header {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
font-size: var(--vc-text-sm);
|
|
115
|
+
font-weight: var(--vc-font-semibold);
|
|
116
|
+
text-transform: uppercase;
|
|
117
|
+
margin-top: -4px;
|
|
118
|
+
padding-left: 4px;
|
|
119
|
+
padding-right: 4px;
|
|
120
|
+
line-height: 21px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.vc-time-select-group {
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
padding: 0 4px;
|
|
127
|
+
background: var(--vc-time-select-group-bg);
|
|
128
|
+
border-radius: var(--vc-rounded-md);
|
|
129
|
+
border: 1px solid var(--vc-time-select-group-border);
|
|
130
|
+
.vc-base-icon {
|
|
131
|
+
margin-right: 4px;
|
|
132
|
+
color: var(--vc-time-select-group-icon-color);
|
|
133
|
+
}
|
|
134
|
+
select {
|
|
135
|
+
background: transparent;
|
|
136
|
+
padding: 0px 4px;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.vc-time-weekday {
|
|
141
|
+
color: var(--vc-time-weekday-color);
|
|
142
|
+
letter-spacing: var(--tracking-wide);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.vc-time-month {
|
|
146
|
+
color: var(--vc-time-month-color);
|
|
147
|
+
margin-left: 8px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.vc-time-day {
|
|
151
|
+
color: var(--vc-time-day-color);
|
|
152
|
+
margin-left: 4px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.vc-time-year {
|
|
156
|
+
color: var(--vc-time-year-color);
|
|
157
|
+
margin-left: 8px;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.vc-time-colon {
|
|
161
|
+
margin: 0 1px 2px 2px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.vc-time-decimal {
|
|
165
|
+
margin: 0 0 0 1px;
|
|
166
|
+
}
|
|
167
|
+
</style>
|