@bagelink/vue 1.1.1 → 1.1.7-beta.1
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/components/calendar/Index.vue.d.ts +41 -41
- package/dist/components/calendar/components/header/Header.vue.d.ts +10 -10
- package/dist/components/calendar/components/month/Month.vue.d.ts +6 -6
- package/dist/components/calendar/components/partials/EventFlyout.vue.d.ts +6 -6
- package/dist/components/calendar/components/week/Day.vue.d.ts +9 -9
- package/dist/components/calendar/components/week/DayEvent.vue.d.ts +9 -9
- package/dist/components/calendar/components/week/FullDayEvent.vue.d.ts +3 -3
- package/dist/components/calendar/components/week/Week.vue.d.ts +16 -16
- package/dist/components/calendar/components/week/WeekTimeline.vue.d.ts +2 -2
- package/dist/components/calendar/models/Event.d.ts +7 -7
- package/dist/components/calendar/typings/config.interface.d.ts +2 -2
- package/dist/components/calendar/typings/interfaces/event.interface.d.ts +4 -4
- package/dist/components/calendar/typings/types.d.ts +2 -1
- package/dist/components/calendar/typings/types.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +7 -3
- package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DatePick.vue.d.ts +3 -3
- package/dist/components/form/inputs/DatePick.vue.d.ts.map +1 -1
- package/dist/index.cjs +268 -117
- package/dist/index.mjs +269 -118
- package/dist/style.css +712 -712
- package/dist/types/timeago.d.ts +23 -0
- package/dist/types/timeago.d.ts.map +1 -0
- package/dist/utils/timeAgo.d.ts +2 -3
- package/dist/utils/timeAgo.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/calendar/Index.vue +3 -3
- package/src/components/calendar/components/header/Header.vue +4 -4
- package/src/components/calendar/components/week/Day.vue +2 -2
- package/src/components/calendar/components/week/DayEvent.vue +2 -2
- package/src/components/calendar/components/week/FullDayEvent.vue +2 -2
- package/src/components/calendar/components/week/Week.vue +4 -4
- package/src/components/calendar/components/week/WeekTimeline.vue +2 -2
- package/src/components/calendar/models/Event.ts +7 -7
- package/src/components/calendar/typings/config.interface.ts +2 -2
- package/src/components/calendar/typings/interfaces/event.interface.ts +4 -4
- package/src/components/calendar/typings/types.ts +3 -1
- package/src/components/form/inputs/DateInput.vue +18 -24
- package/src/components/form/inputs/DatePick.vue +6 -7
- package/src/components/form/inputs/SignaturePad.vue +1 -1
- package/src/types/timeago.ts +52 -0
- package/src/utils/timeAgo.ts +30 -36
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface TimeUnit {
|
|
2
|
+
singular: string;
|
|
3
|
+
plural: string;
|
|
4
|
+
}
|
|
5
|
+
export type TranslationValue = string | TimeUnit;
|
|
6
|
+
export interface LanguageTranslations {
|
|
7
|
+
[key: string]: TranslationValue;
|
|
8
|
+
}
|
|
9
|
+
export type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he';
|
|
10
|
+
export type DayFormatTypes = 'DD' | 'DDD' | 'DDDD';
|
|
11
|
+
export type MonthFormatTypes = 'MM' | 'MMM' | 'MMMM';
|
|
12
|
+
export type YearFormatTypes = 'YY' | 'YYYY';
|
|
13
|
+
export type HourFormatTypes = 'HH';
|
|
14
|
+
export type MinuteFormatTypes = 'mm';
|
|
15
|
+
export type SecondFormatTypes = 'ss';
|
|
16
|
+
export type MillisecondFormatTypes = 'sss';
|
|
17
|
+
export type AmPmFormatTypes = 'AmPm';
|
|
18
|
+
export type DateFormatSeparatorTypes = '/' | '-' | ' ' | ':' | '.';
|
|
19
|
+
export type CommonDateFormats = `${DayFormatTypes}${DateFormatSeparatorTypes}${MonthFormatTypes}${DateFormatSeparatorTypes}${YearFormatTypes}` | 'DD.MM.YY' | 'DD.MM.YYYY' | 'DD/MM/YY' | 'DD/MM/YYYY' | 'MM.DD.YY' | 'MM.DD.YYYY' | 'MM/DD/YY' | 'MM/DD/YYYY' | 'YYYY-MM-DD' | 'YY-MM-DD' | 'DD MMM YYYY' | 'DD MMMM YYYY' | 'DDD, DD MMM' | 'DDDD, DD MMMM' | 'MMM DD' | 'MMMM DD';
|
|
20
|
+
export type CommonTimeFormats = 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss:sss' | 'HH:MM' | 'HH:mm AmPm';
|
|
21
|
+
export type CommonDateTimeFormats = `${CommonDateFormats} ${CommonTimeFormats}` | `${CommonTimeFormats}, ${CommonDateFormats}` | 'YYYY-MM-DD HH:MM';
|
|
22
|
+
export type DateTimeAcceptedFormats = CommonDateFormats | CommonTimeFormats | CommonDateTimeFormats;
|
|
23
|
+
//# sourceMappingURL=timeago.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeago.d.ts","sourceRoot":"","sources":["../../src/types/timeago.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEhD,MAAM,WAAW,oBAAoB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAC/B;AAED,MAAM,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAA;AAClD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAA;AACpD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,CAAA;AAC3C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAA;AAClC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACpC,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAA;AACpC,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAA;AAC1C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AAEpC,MAAM,MAAM,wBAAwB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAGlE,MAAM,MAAM,iBAAiB,GAC1B,GAAG,cAAc,GAAG,wBAAwB,GAAG,gBAAgB,GAAG,wBAAwB,GAAG,eAAe,EAAE,GAC9G,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GACrD,UAAU,GAAG,YAAY,GAAG,UAAU,GAAG,YAAY,GACrD,YAAY,GAAG,UAAU,GACzB,aAAa,GAAG,cAAc,GAC9B,aAAa,GAAG,eAAe,GAC/B,QAAQ,GAAG,SAAS,CAAA;AAEvB,MAAM,MAAM,iBAAiB,GAC1B,OAAO,GAAG,UAAU,GAAG,cAAc,GACrC,OAAO,GACP,YAAY,CAAA;AAGf,MAAM,MAAM,qBAAqB,GAC9B,GAAG,iBAAiB,IAAI,iBAAiB,EAAE,GAC3C,GAAG,iBAAiB,KAAK,iBAAiB,EAAE,GAC5C,kBAAkB,CAAA;AAGrB,MAAM,MAAM,uBAAuB,GAChC,iBAAiB,GACjB,iBAAiB,GACjB,qBAAqB,CAAA"}
|
package/dist/utils/timeAgo.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { AvailableTimeLanguages, DateTimeAcceptedFormats } from '../types/timeago';
|
|
2
2
|
export declare function timeAgo(date: string | Date, lang?: AvailableTimeLanguages): string;
|
|
3
|
-
export declare function formatDate(date?: string | Date, format?:
|
|
4
|
-
export {};
|
|
3
|
+
export declare function formatDate(date?: string | Date, format?: DateTimeAcceptedFormats, locale?: string): string;
|
|
5
4
|
//# sourceMappingURL=timeAgo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"timeAgo.d.ts","sourceRoot":"","sources":["../../src/utils/timeAgo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,uBAAuB,EAAkC,MAAM,kBAAkB,CAAA;AAqDvH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,GAAE,sBAA6B,UAsD/E;AASD,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,GAAE,uBAAoC,EAAE,MAAM,CAAC,EAAE,MAAM,UAsF7G"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bagelink/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.1",
|
|
4
|
+
"version": "1.1.7-beta.1",
|
|
5
5
|
"description": "Bagel core sdk packages",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Neveh Allon",
|
|
@@ -83,10 +83,10 @@
|
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"date-fns": "^4.1.0",
|
|
85
85
|
"@vueuse/core": "^13.0.0",
|
|
86
|
-
"axios": "^1.8.
|
|
86
|
+
"axios": "^1.8.3",
|
|
87
87
|
"floating-vue": "^5.2.2",
|
|
88
|
-
"libphonenumber-js": "1.12.
|
|
89
|
-
"signature_pad": "^5.0.
|
|
88
|
+
"libphonenumber-js": "1.12.6",
|
|
89
|
+
"signature_pad": "^5.0.6"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"dev": "tsx watch src/index.ts",
|
|
@@ -4,7 +4,7 @@ import type { ConfigInterface } from './typings/config.interface'
|
|
|
4
4
|
import type { DayInterface } from './typings/interfaces/day.interface'
|
|
5
5
|
import type { EventInterface } from './typings/interfaces/event.interface'
|
|
6
6
|
import type { PeriodInterface } from './typings/interfaces/period.interface'
|
|
7
|
-
import type {
|
|
7
|
+
import type { ModeType } from './typings/types'
|
|
8
8
|
import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
|
|
9
9
|
import AppHeader from './components/header/Header.vue'
|
|
10
10
|
import AgendaEvents from './components/month/AgendaEvents.vue'
|
|
@@ -52,7 +52,7 @@ const period = ref({
|
|
|
52
52
|
end: new Date(),
|
|
53
53
|
selectedDate: props.selectedDate,
|
|
54
54
|
})
|
|
55
|
-
const mode = ref(props.config.defaultMode || ('week' as
|
|
55
|
+
const mode = ref(props.config.defaultMode || ('week' as ModeType))
|
|
56
56
|
const time = ref(new Time(props.config.week?.startsOn, props.config.locale || null, {
|
|
57
57
|
start: setTimePointsFromDayBoundary(props.config.dayBoundaries?.start || 0),
|
|
58
58
|
end: setTimePointsFromDayBoundary(props.config.dayBoundaries?.end || 24),
|
|
@@ -107,7 +107,7 @@ function handleUpdatedPeriod(
|
|
|
107
107
|
if (leaveMonthMode) mode.value = 'day'
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
function handleChangeMode(payload:
|
|
110
|
+
function handleChangeMode(payload: ModeType) {
|
|
111
111
|
if (payload === 'day') {
|
|
112
112
|
period.value.start = period.value.selectedDate
|
|
113
113
|
period.value.end = time.value.setDateToEndOfDay(period.value.selectedDate)
|
|
@@ -3,7 +3,7 @@ import type { PropType } from 'vue'
|
|
|
3
3
|
import type Time from '../../helpers/Time'
|
|
4
4
|
import type { ConfigInterface } from '../../typings/config.interface'
|
|
5
5
|
import type { PeriodInterface } from '../../typings/interfaces/period.interface'
|
|
6
|
-
import type {
|
|
6
|
+
import type { ModeType } from '../../typings/types'
|
|
7
7
|
|
|
8
8
|
import { DatePick, TabsNav, Btn } from '@bagelink/vue'
|
|
9
9
|
import { ref, computed, watch } from 'vue'
|
|
@@ -15,7 +15,7 @@ const props = defineProps({
|
|
|
15
15
|
default: () => ({}),
|
|
16
16
|
},
|
|
17
17
|
mode: {
|
|
18
|
-
type: String as PropType<
|
|
18
|
+
type: String as PropType<ModeType>,
|
|
19
19
|
default: 'week',
|
|
20
20
|
},
|
|
21
21
|
time: {
|
|
@@ -33,13 +33,13 @@ const props = defineProps({
|
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
const emit = defineEmits<{
|
|
36
|
-
(e: 'changeMode', mode:
|
|
36
|
+
(e: 'changeMode', mode: ModeType): void
|
|
37
37
|
(e: 'updatedPeriod', value: PeriodInterface): void
|
|
38
38
|
}>()
|
|
39
39
|
|
|
40
40
|
const periodSelect = ref<InstanceType<typeof DatePick>>()
|
|
41
41
|
const currentPeriod = ref(props.period)
|
|
42
|
-
const modeOptions = ref<
|
|
42
|
+
const modeOptions = ref<ModeType[]>(['month', 'week', 'day', 'agenda'])
|
|
43
43
|
|
|
44
44
|
// const icons = {
|
|
45
45
|
// chevronLeft: 'chevron_left',
|
|
@@ -5,7 +5,7 @@ import type Time from '../../helpers/Time'
|
|
|
5
5
|
import type { ConfigInterface, DayIntervalsType } from '../../typings/config.interface'
|
|
6
6
|
import type { DayInterface } from '../../typings/interfaces/day.interface'
|
|
7
7
|
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
8
|
-
import type { DayInfo,
|
|
8
|
+
import type { DayInfo, ModeType } from '../../typings/types'
|
|
9
9
|
import { ref, computed, onMounted } from 'vue'
|
|
10
10
|
import DayIntervals from '../../helpers/DayIntervals'
|
|
11
11
|
import EventConcurrency from '../../helpers/EventConcurrency'
|
|
@@ -29,7 +29,7 @@ const props = defineProps({
|
|
|
29
29
|
required: true,
|
|
30
30
|
},
|
|
31
31
|
mode: {
|
|
32
|
-
type: String as PropType<
|
|
32
|
+
type: String as PropType<ModeType>,
|
|
33
33
|
required: true,
|
|
34
34
|
},
|
|
35
35
|
dayIntervals: {
|
|
@@ -3,7 +3,7 @@ import type { PropType } from 'vue'
|
|
|
3
3
|
import type Time from '../../helpers/Time'
|
|
4
4
|
import type { ConfigInterface } from '../../typings/config.interface'
|
|
5
5
|
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
6
|
-
import type { DayInfo,
|
|
6
|
+
import type { DayInfo, ModeType } from '../../typings/types'
|
|
7
7
|
import { Icon } from '@bagelink/vue'
|
|
8
8
|
|
|
9
9
|
import { ref, computed, onMounted, watch } from 'vue'
|
|
@@ -30,7 +30,7 @@ const props = defineProps({
|
|
|
30
30
|
required: true,
|
|
31
31
|
},
|
|
32
32
|
mode: {
|
|
33
|
-
type: String as PropType<
|
|
33
|
+
type: String as PropType<ModeType>,
|
|
34
34
|
required: true,
|
|
35
35
|
},
|
|
36
36
|
})
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { PropType } from 'vue'
|
|
3
3
|
import type { ConfigInterface } from '../../typings/config.interface'
|
|
4
4
|
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
5
|
-
import type {
|
|
5
|
+
import type { ModeType } from '../../typings/types'
|
|
6
6
|
import { computed, onMounted, ref } from 'vue'
|
|
7
7
|
import { EVENT_COLORS } from '../../constants'
|
|
8
8
|
|
|
@@ -20,7 +20,7 @@ const props = defineProps({
|
|
|
20
20
|
required: true,
|
|
21
21
|
},
|
|
22
22
|
mode: {
|
|
23
|
-
type: String as PropType<
|
|
23
|
+
type: String as PropType<ModeType>,
|
|
24
24
|
required: true,
|
|
25
25
|
},
|
|
26
26
|
})
|
|
@@ -6,7 +6,7 @@ import type { DayInterface } from '../../typings/interfaces/day.interface'
|
|
|
6
6
|
import type { EventInterface } from '../../typings/interfaces/event.interface'
|
|
7
7
|
import type { FullDayEventsWeek } from '../../typings/interfaces/full-day-events-week.type'
|
|
8
8
|
import type { PeriodInterface } from '../../typings/interfaces/period.interface'
|
|
9
|
-
import type {
|
|
9
|
+
import type { ModeType } from '../../typings/types'
|
|
10
10
|
import { ref, computed, onMounted, watch, useSlots } from 'vue'
|
|
11
11
|
import EventPosition from '../../helpers/EventPosition'
|
|
12
12
|
import { EventsFilter } from '../../helpers/EventsFilter'
|
|
@@ -32,7 +32,7 @@ const props = defineProps({
|
|
|
32
32
|
required: true,
|
|
33
33
|
},
|
|
34
34
|
modeProp: {
|
|
35
|
-
type: String as PropType<
|
|
35
|
+
type: String as PropType<ModeType>,
|
|
36
36
|
default: 'week',
|
|
37
37
|
},
|
|
38
38
|
time: {
|
|
@@ -55,7 +55,7 @@ const emit = defineEmits([
|
|
|
55
55
|
const eventPosition = new EventPosition()
|
|
56
56
|
|
|
57
57
|
const days = ref<DayInterface[]>([])
|
|
58
|
-
const mode = ref<
|
|
58
|
+
const mode = ref<ModeType>(props.modeProp)
|
|
59
59
|
const selectedEvent = ref<EventInterface | null>(null)
|
|
60
60
|
const selectedEventElement = ref<any | null>(null)
|
|
61
61
|
const events = ref<EventInterface[]>(props.eventsProp)
|
|
@@ -187,7 +187,7 @@ function setDay() {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
function setInitialEvents(currentMode:
|
|
190
|
+
function setInitialEvents(currentMode: ModeType) {
|
|
191
191
|
if (currentMode === 'day') setDay()
|
|
192
192
|
if (currentMode === 'week') setDays()
|
|
193
193
|
|
|
@@ -3,7 +3,7 @@ import type Time from '../../helpers/Time'
|
|
|
3
3
|
import type { ConfigInterface } from '../../typings/config.interface'
|
|
4
4
|
import type { DayInterface } from '../../typings/interfaces/day.interface'
|
|
5
5
|
import type { DayWithFullDayEvents } from '../../typings/interfaces/full-day-events-week.type'
|
|
6
|
-
import type {
|
|
6
|
+
import type { ModeType } from '../../typings/types'
|
|
7
7
|
import { ref, defineEmits } from 'vue'
|
|
8
8
|
import FullDayEvent from './FullDayEvent.vue'
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ const props = defineProps<{
|
|
|
12
12
|
time: Time
|
|
13
13
|
fullDayEvents: DayWithFullDayEvents[]
|
|
14
14
|
config: ConfigInterface
|
|
15
|
-
mode:
|
|
15
|
+
mode: ModeType
|
|
16
16
|
}>()
|
|
17
17
|
|
|
18
18
|
const emit = defineEmits<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EventColor, EventID, EventInterface } from '../typings/interfaces/event.interface'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModeType } from '../typings/types'
|
|
3
3
|
|
|
4
4
|
export class EventImpl implements EventInterface {
|
|
5
5
|
title?: string
|
|
@@ -10,9 +10,9 @@ export class EventImpl implements EventInterface {
|
|
|
10
10
|
colorScheme?: string
|
|
11
11
|
color?: EventColor
|
|
12
12
|
isEditable?: boolean
|
|
13
|
-
disableDnD?:
|
|
14
|
-
disableResize?:
|
|
15
|
-
isCustom?: boolean |
|
|
13
|
+
disableDnD?: ModeType[]
|
|
14
|
+
disableResize?: ModeType[]
|
|
15
|
+
isCustom?: boolean | ModeType[]
|
|
16
16
|
|
|
17
17
|
// Properties that should not be set from outside Calendar
|
|
18
18
|
nOfPreviousConcurrentEvents?: number
|
|
@@ -92,19 +92,19 @@ export class EventBuilder {
|
|
|
92
92
|
return this
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
withIsCustom(isCustom: boolean |
|
|
95
|
+
withIsCustom(isCustom: boolean | ModeType[]) {
|
|
96
96
|
this.eventImpl.isCustom = isCustom
|
|
97
97
|
|
|
98
98
|
return this
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
withDisableDnD(disableDnD:
|
|
101
|
+
withDisableDnD(disableDnD: ModeType[]) {
|
|
102
102
|
this.eventImpl.disableDnD = disableDnD
|
|
103
103
|
|
|
104
104
|
return this
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
withDisableResize(disableResize:
|
|
107
|
+
withDisableResize(disableResize: ModeType[]) {
|
|
108
108
|
this.eventImpl.disableResize = disableResize
|
|
109
109
|
|
|
110
110
|
return this
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { WEEK_START_DAY } from '../helpers/Time'
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModeType } from './types'
|
|
3
3
|
|
|
4
4
|
export enum DAY_TIME_POINT {
|
|
5
5
|
MIDNIGHT = 0,
|
|
@@ -59,7 +59,7 @@ export interface ConfigInterface {
|
|
|
59
59
|
fontFamily?: string
|
|
60
60
|
colorSchemes?: ColorSchemes
|
|
61
61
|
}
|
|
62
|
-
defaultMode?:
|
|
62
|
+
defaultMode?: ModeType
|
|
63
63
|
disableModes?: ('week' | 'month' | string)[]
|
|
64
64
|
isSilent?: boolean
|
|
65
65
|
dayIntervals?: DayIntervalsType
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ModeType } from '../types'
|
|
2
2
|
|
|
3
3
|
export type EventID = string | number
|
|
4
4
|
|
|
@@ -17,9 +17,9 @@ export interface EventInterface {
|
|
|
17
17
|
colorScheme?: string
|
|
18
18
|
color?: EventColor // Says 'color', but represents CSS-Property background-color
|
|
19
19
|
isEditable?: boolean // If true, the event has delete- and edit icons in Event-Flyout. Can also be dragged and dropped.
|
|
20
|
-
disableDnD?:
|
|
21
|
-
disableResize?:
|
|
22
|
-
isCustom?: boolean |
|
|
20
|
+
disableDnD?: ModeType[] // Disable Drag and Drop for this event, in the modes specified
|
|
21
|
+
disableResize?: ModeType[] // Disable Resize for this event, in the modes specified
|
|
22
|
+
isCustom?: boolean | ModeType[] // If true, the event expects to be displayed using the event slot. It can also be specified as an array, of all modes, where the event should be displayed using the event slot.
|
|
23
23
|
|
|
24
24
|
// These are properties that should never be fed into the Calendar
|
|
25
25
|
// Instead, they are assigned to events, in order to for example position/style them correctly
|
|
@@ -9,7 +9,9 @@ export interface DOMRect {
|
|
|
9
9
|
y: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type DateViewMode = 'days' | 'months' | 'years'
|
|
13
|
+
|
|
14
|
+
export type ModeType = 'day' | 'week' | 'month' | 'agenda'
|
|
13
15
|
|
|
14
16
|
// ! @natanelyoung PLEASE DON'T USE ENUMS 🙏🏼
|
|
15
17
|
// * please see: https://tduyng.medium.com/why-you-might-be-using-enums-in-typescript-wrong-6d9c5742db5a
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { DateViewMode, ModeType } from '../../calendar/typings/types'
|
|
3
3
|
import { Btn, NumberInput, Dropdown, TextInput, formatDate } from '@bagelink/vue'
|
|
4
|
-
import {
|
|
4
|
+
import { onClickOutside } from '@vueuse/core'
|
|
5
|
+
import { computed, ref, onMounted } from 'vue'
|
|
5
6
|
import Time, { WEEK_START_DAY } from '../../calendar/helpers/Time'
|
|
6
7
|
|
|
7
|
-
// Types
|
|
8
|
-
type ViewMode = 'days' | 'months' | 'years'
|
|
9
|
-
|
|
10
|
-
// Props
|
|
11
8
|
const props = withDefaults(
|
|
12
9
|
defineProps<{
|
|
13
10
|
required?: boolean
|
|
14
11
|
label?: string
|
|
15
12
|
editMode?: boolean
|
|
16
13
|
small?: boolean
|
|
14
|
+
/**
|
|
15
|
+
* Whether to enable time selection.
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
17
18
|
enableTime?: boolean
|
|
18
19
|
modelValue?: string | Date
|
|
19
20
|
min?: string | Date
|
|
20
21
|
max?: string | Date
|
|
21
|
-
mode?:
|
|
22
|
+
mode?: ModeType
|
|
22
23
|
defaultValue?: string | Date
|
|
23
24
|
firstDayOfWeek?: WEEK_START_DAY
|
|
24
25
|
locale?: string
|
|
@@ -39,7 +40,7 @@ const emit = defineEmits(['update:modelValue'])
|
|
|
39
40
|
// State
|
|
40
41
|
const isOpen = ref(false)
|
|
41
42
|
const currentMonth = ref(new Date())
|
|
42
|
-
const currentView = ref<
|
|
43
|
+
const currentView = ref<DateViewMode>('days')
|
|
43
44
|
|
|
44
45
|
// Time helper instance
|
|
45
46
|
const time = new Time(props.firstDayOfWeek, props.locale)
|
|
@@ -55,7 +56,7 @@ function parseDate(value: string | Date | undefined): Date | null {
|
|
|
55
56
|
function useFormatting() {
|
|
56
57
|
const formatDisplayDate = (date: Date | string | undefined): string => {
|
|
57
58
|
if (!date) return ''
|
|
58
|
-
return formatDate(date, props.enableTime ? '
|
|
59
|
+
return formatDate(date, props.enableTime ? 'DD.MM.YY HH:mm' : 'DD.MM.YY')
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const parseUserInput = (input: string): Date | null => {
|
|
@@ -118,8 +119,8 @@ function useDateState() {
|
|
|
118
119
|
const { formatDisplayDate } = useFormatting()
|
|
119
120
|
|
|
120
121
|
const formattedDisplayValue = computed(() => formatDisplayDate(props.modelValue))
|
|
121
|
-
const formattedMin = computed(() => formatDate(props.min, props.enableTime ? '
|
|
122
|
-
const formattedMax = computed(() => formatDate(props.max, props.enableTime ? '
|
|
122
|
+
const formattedMin = computed(() => formatDate(props.min, props.enableTime ? 'DD.MM.YY HH:mm' : 'DD.MM.YY'))
|
|
123
|
+
const formattedMax = computed(() => formatDate(props.max, props.enableTime ? 'DD.MM.YY HH:mm' : 'DD.MM.YY'))
|
|
123
124
|
const selectedDate = computed(() => {
|
|
124
125
|
return parseDate(props.modelValue || props.defaultValue)
|
|
125
126
|
})
|
|
@@ -280,10 +281,10 @@ function useTimeHandling() {
|
|
|
280
281
|
function emitDateValue(date: Date) {
|
|
281
282
|
if (props.enableTime) {
|
|
282
283
|
// For dates with time, emit the date object directly
|
|
283
|
-
emit('update:modelValue', formatDate(date, '
|
|
284
|
+
emit('update:modelValue', formatDate(date, 'YYYY-MM-DD HH:MM'))
|
|
284
285
|
} else {
|
|
285
286
|
// For date-only, emit a date with time set to midnight
|
|
286
|
-
emit('update:modelValue', formatDate(date, '
|
|
287
|
+
emit('update:modelValue', formatDate(date, 'YYYY-MM-DD'))
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -382,17 +383,10 @@ onMounted(() => {
|
|
|
382
383
|
)
|
|
383
384
|
}
|
|
384
385
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
document.addEventListener('click', handleDocumentClick)
|
|
393
|
-
|
|
394
|
-
onBeforeUnmount(() => {
|
|
395
|
-
document.removeEventListener('click', handleDocumentClick)
|
|
386
|
+
onClickOutside(datePickerRef.value, () => {
|
|
387
|
+
isOpen.value = false
|
|
388
|
+
}, {
|
|
389
|
+
ignore: () => [calendarRef.value]
|
|
396
390
|
})
|
|
397
391
|
})
|
|
398
392
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { DateViewMode, ModeType } from '../../calendar/typings/types'
|
|
3
3
|
import { Btn, NumberInput, Dropdown, formatDate } from '@bagelink/vue'
|
|
4
4
|
import Time, { WEEK_START_DAY } from '../../calendar/helpers/Time'
|
|
5
5
|
|
|
@@ -14,7 +14,7 @@ const props = withDefaults(
|
|
|
14
14
|
min?: string | Date
|
|
15
15
|
max?: string | Date
|
|
16
16
|
timezone?: string
|
|
17
|
-
mode?:
|
|
17
|
+
mode?: ModeType
|
|
18
18
|
firstDayOfWeek?: WEEK_START_DAY
|
|
19
19
|
locale?: string
|
|
20
20
|
center?: boolean
|
|
@@ -34,15 +34,14 @@ const props = withDefaults(
|
|
|
34
34
|
const emit = defineEmits(['update:modelValue'])
|
|
35
35
|
let isOpen = $ref(false)
|
|
36
36
|
let currentMonth = $ref(new Date())
|
|
37
|
-
|
|
38
|
-
let currentView = $ref<ViewMode>('days')
|
|
37
|
+
let currentView = $ref<DateViewMode>('days')
|
|
39
38
|
|
|
40
39
|
const time = new Time(props.firstDayOfWeek, props.locale)
|
|
41
40
|
|
|
42
41
|
function formatDisplayDate(date: Date | string | undefined): string {
|
|
43
42
|
if (!date) return ''
|
|
44
43
|
console.log('date', date)
|
|
45
|
-
return formatDate(date, props.enableTime ? '
|
|
44
|
+
return formatDate(date, props.enableTime ? 'DD.MM.YY HH:MM' : 'DD.MM.YY', props.locale)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
// function formatDate(date: Date | string | undefined): string {
|
|
@@ -52,8 +51,8 @@ function formatDisplayDate(date: Date | string | undefined): string {
|
|
|
52
51
|
// }
|
|
53
52
|
|
|
54
53
|
const formattedDisplayValue = $computed(() => formatDisplayDate(props.modelValue))
|
|
55
|
-
const formattedMin = $computed(() => formatDate(props.min, props.enableTime ? '
|
|
56
|
-
const formattedMax = $computed(() => formatDate(props.max, props.enableTime ? '
|
|
54
|
+
const formattedMin = $computed(() => formatDate(props.min, props.enableTime ? 'DD.MM.YY HH:MM' : 'DD.MM.YY'))
|
|
55
|
+
const formattedMax = $computed(() => formatDate(props.max, props.enableTime ? 'DD.MM.YY HH:MM' : 'DD.MM.YY'))
|
|
57
56
|
|
|
58
57
|
const selectedDate = $computed(() => {
|
|
59
58
|
if (!props.modelValue) return null
|
|
@@ -65,7 +65,7 @@ function saveFile() {
|
|
|
65
65
|
// For PNG/JPG, convert base64 to blob first
|
|
66
66
|
const base64Data = data.split(',')[1]
|
|
67
67
|
const byteCharacters = atob(base64Data)
|
|
68
|
-
const byteNumbers =
|
|
68
|
+
const byteNumbers: number[] = Array.from({ length: byteCharacters.length })
|
|
69
69
|
|
|
70
70
|
for (let i = 0; i < byteCharacters.length; i++) {
|
|
71
71
|
byteNumbers[i] = byteCharacters.charCodeAt(i)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface TimeUnit {
|
|
2
|
+
singular: string
|
|
3
|
+
plural: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type TranslationValue = string | TimeUnit
|
|
7
|
+
|
|
8
|
+
export interface LanguageTranslations {
|
|
9
|
+
[key: string]: TranslationValue
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
|
|
13
|
+
|
|
14
|
+
export type DayFormatTypes = 'DD' | 'DDD' | 'DDDD'
|
|
15
|
+
export type MonthFormatTypes = 'MM' | 'MMM' | 'MMMM'
|
|
16
|
+
export type YearFormatTypes = 'YY' | 'YYYY'
|
|
17
|
+
export type HourFormatTypes = 'HH'
|
|
18
|
+
export type MinuteFormatTypes = 'mm'
|
|
19
|
+
export type SecondFormatTypes = 'ss'
|
|
20
|
+
export type MillisecondFormatTypes = 'sss'
|
|
21
|
+
export type AmPmFormatTypes = 'AmPm'
|
|
22
|
+
|
|
23
|
+
export type DateFormatSeparatorTypes = '/' | '-' | ' ' | ':' | '.'
|
|
24
|
+
|
|
25
|
+
// Common predefined formats instead of template literals
|
|
26
|
+
export type CommonDateFormats =
|
|
27
|
+
| `${DayFormatTypes}${DateFormatSeparatorTypes}${MonthFormatTypes}${DateFormatSeparatorTypes}${YearFormatTypes}`
|
|
28
|
+
| 'DD.MM.YY' | 'DD.MM.YYYY' | 'DD/MM/YY' | 'DD/MM/YYYY' // European style
|
|
29
|
+
| 'MM.DD.YY' | 'MM.DD.YYYY' | 'MM/DD/YY' | 'MM/DD/YYYY' // US style
|
|
30
|
+
| 'YYYY-MM-DD' | 'YY-MM-DD' // ISO style
|
|
31
|
+
| 'DD MMM YYYY' | 'DD MMMM YYYY' // Long format
|
|
32
|
+
| 'DDD, DD MMM' | 'DDDD, DD MMMM' // Day-focused format
|
|
33
|
+
| 'MMM DD' | 'MMMM DD' // Month-day format
|
|
34
|
+
|
|
35
|
+
export type CommonTimeFormats =
|
|
36
|
+
| 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss:sss' // 24-hour format
|
|
37
|
+
| 'HH:MM' // Alternative minute format
|
|
38
|
+
| 'HH:mm AmPm' // 12-hour format
|
|
39
|
+
|
|
40
|
+
// Combined date and time formats
|
|
41
|
+
export type CommonDateTimeFormats =
|
|
42
|
+
| `${CommonDateFormats} ${CommonTimeFormats}`
|
|
43
|
+
| `${CommonTimeFormats}, ${CommonDateFormats}`
|
|
44
|
+
| 'YYYY-MM-DD HH:MM' // Explicit ISO-style datetime format
|
|
45
|
+
|
|
46
|
+
// Final accepted format type with string fallback for custom formats
|
|
47
|
+
export type DateTimeAcceptedFormats =
|
|
48
|
+
| CommonDateFormats
|
|
49
|
+
| CommonTimeFormats
|
|
50
|
+
| CommonDateTimeFormats
|
|
51
|
+
// ! | string
|
|
52
|
+
// ! no string fallback so that autocomplete works (developers should can always cast to DateTimeAcceptedFormats)
|
package/src/utils/timeAgo.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
singular: string
|
|
3
|
-
plural: string
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
type TranslationValue = string | TimeUnit
|
|
7
|
-
|
|
8
|
-
interface LanguageTranslations {
|
|
9
|
-
[key: string]: TranslationValue
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he'
|
|
1
|
+
import type { AvailableTimeLanguages, DateTimeAcceptedFormats, LanguageTranslations, TimeUnit } from '../types/timeago'
|
|
13
2
|
|
|
14
3
|
const translations: Record<AvailableTimeLanguages, LanguageTranslations> = {
|
|
15
4
|
en: {
|
|
@@ -125,7 +114,7 @@ function getBrowserNavigatorLocale(): string {
|
|
|
125
114
|
: navigator.language
|
|
126
115
|
}
|
|
127
116
|
|
|
128
|
-
export function formatDate(date?: string | Date, format:
|
|
117
|
+
export function formatDate(date?: string | Date, format: DateTimeAcceptedFormats = 'DD.MM.YY', locale?: string) {
|
|
129
118
|
if (!date) return ''
|
|
130
119
|
locale = locale || getBrowserNavigatorLocale()
|
|
131
120
|
try {
|
|
@@ -138,31 +127,34 @@ export function formatDate(date?: string | Date, format: string = 'dd.mm.yy', lo
|
|
|
138
127
|
return ''
|
|
139
128
|
}
|
|
140
129
|
|
|
141
|
-
|
|
142
|
-
const datePartsMap
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
mmm: d.toLocaleString(locale, { month: 'short' }),
|
|
148
|
-
mmmm: d.toLocaleString(locale, { month: 'long' }),
|
|
149
|
-
yy: String(d.getFullYear()).slice(-2),
|
|
150
|
-
yyyy: String(d.getFullYear()),
|
|
130
|
+
/// keep-sorted
|
|
131
|
+
const datePartsMap = {
|
|
132
|
+
AmPm: d.toLocaleString(locale, { hour: 'numeric', hour12: true, minute: 'numeric' }).split(' ')[1],
|
|
133
|
+
DD: String(d.getDate()).padStart(2, '0'),
|
|
134
|
+
DDD: d.toLocaleString(locale, { weekday: 'short' }),
|
|
135
|
+
DDDD: d.toLocaleString(locale, { weekday: 'long' }),
|
|
151
136
|
HH: String(d.getHours()).padStart(2, '0'),
|
|
152
|
-
|
|
153
|
-
|
|
137
|
+
mm: String(d.getMinutes()).padStart(2, '0'),
|
|
138
|
+
MM: String(d.getMonth() + 1).padStart(2, '0'),
|
|
139
|
+
MMM: d.toLocaleString(locale, { month: 'short' }),
|
|
140
|
+
MMMM: d.toLocaleString(locale, { month: 'long' }),
|
|
141
|
+
ss: String(d.getSeconds()).padStart(2, '0'),
|
|
142
|
+
sss: String(d.getMilliseconds()).padStart(3, '0'),
|
|
143
|
+
YY: String(d.getFullYear()).slice(-2),
|
|
144
|
+
YYYY: String(d.getFullYear()),
|
|
154
145
|
}
|
|
155
146
|
|
|
156
147
|
// For more complex formats that need localization, use Intl.DateTimeFormat
|
|
148
|
+
/// keep-sorted
|
|
157
149
|
const formatter = new Intl.DateTimeFormat(locale, {
|
|
158
|
-
weekday: 'long',
|
|
159
|
-
month: 'long',
|
|
160
150
|
day: 'numeric',
|
|
161
|
-
year: 'numeric',
|
|
162
151
|
hour: '2-digit',
|
|
152
|
+
hour12: true,
|
|
163
153
|
minute: '2-digit',
|
|
154
|
+
month: 'long',
|
|
164
155
|
second: '2-digit',
|
|
165
|
-
|
|
156
|
+
weekday: 'long',
|
|
157
|
+
year: 'numeric',
|
|
166
158
|
})
|
|
167
159
|
|
|
168
160
|
const formattedParts = formatter.formatToParts(d)
|
|
@@ -176,24 +168,26 @@ export function formatDate(date?: string | Date, format: string = 'dd.mm.yy', lo
|
|
|
176
168
|
|
|
177
169
|
// Add localized formats to our map
|
|
178
170
|
if (partsMap.month) {
|
|
179
|
-
datePartsMap.
|
|
180
|
-
datePartsMap.
|
|
171
|
+
datePartsMap.MMM = partsMap.month.substring(0, 3)
|
|
172
|
+
datePartsMap.MMMM = partsMap.month
|
|
181
173
|
}
|
|
182
174
|
|
|
183
175
|
if (partsMap.weekday) {
|
|
184
|
-
datePartsMap.
|
|
185
|
-
datePartsMap.
|
|
176
|
+
datePartsMap.DDD = partsMap.weekday.substring(0, 3)
|
|
177
|
+
datePartsMap.DDDD = partsMap.weekday
|
|
186
178
|
}
|
|
187
179
|
|
|
188
180
|
if (partsMap.dayPeriod) {
|
|
189
|
-
datePartsMap.
|
|
181
|
+
datePartsMap.AmPm = partsMap.dayPeriod
|
|
190
182
|
}
|
|
191
183
|
|
|
192
184
|
// Process the format string by replacing each token with its value
|
|
193
|
-
let formattedDate = format
|
|
185
|
+
let formattedDate: string = format
|
|
194
186
|
|
|
195
187
|
// Sort tokens by length (longest first) to avoid partial replacements
|
|
196
|
-
const tokens =
|
|
188
|
+
const tokens = (
|
|
189
|
+
Object.keys(datePartsMap).sort((a, b) => b.length - a.length)
|
|
190
|
+
) as (keyof typeof datePartsMap)[]
|
|
197
191
|
|
|
198
192
|
// Replace each token with its value
|
|
199
193
|
for (const token of tokens) {
|