@bagelink/vue 1.0.66 → 1.1.6-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.
Files changed (45) hide show
  1. package/dist/components/calendar/Index.vue.d.ts +41 -41
  2. package/dist/components/calendar/components/header/Header.vue.d.ts +10 -10
  3. package/dist/components/calendar/components/month/Month.vue.d.ts +6 -6
  4. package/dist/components/calendar/components/partials/EventFlyout.vue.d.ts +6 -6
  5. package/dist/components/calendar/components/week/Day.vue.d.ts +9 -9
  6. package/dist/components/calendar/components/week/DayEvent.vue.d.ts +9 -9
  7. package/dist/components/calendar/components/week/FullDayEvent.vue.d.ts +3 -3
  8. package/dist/components/calendar/components/week/Week.vue.d.ts +16 -16
  9. package/dist/components/calendar/components/week/WeekTimeline.vue.d.ts +2 -2
  10. package/dist/components/calendar/models/Event.d.ts +7 -7
  11. package/dist/components/calendar/typings/config.interface.d.ts +2 -2
  12. package/dist/components/calendar/typings/interfaces/event.interface.d.ts +4 -4
  13. package/dist/components/calendar/typings/types.d.ts +2 -1
  14. package/dist/components/calendar/typings/types.d.ts.map +1 -1
  15. package/dist/components/form/inputs/DateInput.vue.d.ts +7 -3
  16. package/dist/components/form/inputs/DateInput.vue.d.ts.map +1 -1
  17. package/dist/components/form/inputs/DatePick.vue.d.ts +3 -3
  18. package/dist/components/form/inputs/DatePick.vue.d.ts.map +1 -1
  19. package/dist/components/form/inputs/OTP.vue.d.ts.map +1 -1
  20. package/dist/index.cjs +278 -120
  21. package/dist/index.mjs +279 -121
  22. package/dist/style.css +724 -716
  23. package/dist/types/timeago.d.ts +23 -0
  24. package/dist/types/timeago.d.ts.map +1 -0
  25. package/dist/utils/timeAgo.d.ts +2 -3
  26. package/dist/utils/timeAgo.d.ts.map +1 -1
  27. package/package.json +4 -4
  28. package/src/components/calendar/Index.vue +3 -3
  29. package/src/components/calendar/components/header/Header.vue +4 -4
  30. package/src/components/calendar/components/week/Day.vue +2 -2
  31. package/src/components/calendar/components/week/DayEvent.vue +2 -2
  32. package/src/components/calendar/components/week/FullDayEvent.vue +2 -2
  33. package/src/components/calendar/components/week/Week.vue +4 -4
  34. package/src/components/calendar/components/week/WeekTimeline.vue +2 -2
  35. package/src/components/calendar/models/Event.ts +7 -7
  36. package/src/components/calendar/typings/config.interface.ts +2 -2
  37. package/src/components/calendar/typings/interfaces/event.interface.ts +4 -4
  38. package/src/components/calendar/typings/types.ts +3 -1
  39. package/src/components/form/inputs/DateInput.vue +18 -24
  40. package/src/components/form/inputs/DatePick.vue +6 -7
  41. package/src/components/form/inputs/OTP.vue +18 -5
  42. package/src/components/form/inputs/SignaturePad.vue +1 -1
  43. package/src/components/lightbox/Lightbox.vue +1 -1
  44. package/src/types/timeago.ts +51 -0
  45. 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 = '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,GAAG,EAAE,CAAA;AACvD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,GAAG,EAAE,CAAA;AACzD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,MAAM,GAAG,EAAE,CAAA;AAChD,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,EAAE,CAAA;AACvC,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;AACzC,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAE,CAAA;AACzC,MAAM,MAAM,sBAAsB,GAAG,KAAK,GAAG,EAAE,CAAA;AAC/C,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,EAAE,CAAA;AAEzC,MAAM,MAAM,wBAAwB,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAGlE,MAAM,MAAM,iBAAiB,GAC1B,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"}
@@ -1,5 +1,4 @@
1
- type AvailableTimeLanguages = 'en' | 'es' | 'fr' | 'he';
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?: string, locale?: string): string;
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":"AAWA,KAAK,sBAAsB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAqDvD,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,MAAmB,EAAE,MAAM,CAAC,EAAE,MAAM,UAiF5F"}
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.0.66",
4
+ "version": "1.1.6-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.2",
86
+ "axios": "^1.8.3",
87
87
  "floating-vue": "^5.2.2",
88
- "libphonenumber-js": "1.12.5",
89
- "signature_pad": "^5.0.4"
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 { modeType } from './typings/types'
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 modeType))
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: modeType) {
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 { modeType } from '../../typings/types'
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<modeType>,
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: modeType): void
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<modeType[]>(['month', 'week', 'day', 'agenda'])
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, modeType } from '../../typings/types'
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<modeType>,
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, modeType } from '../../typings/types'
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<modeType>,
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 { modeType } from '../../typings/types'
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<modeType>,
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 { modeType } from '../../typings/types'
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<modeType>,
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<modeType>(props.modeProp)
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: modeType) {
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 { modeType } from '../../typings/types'
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: modeType
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 { modeType } from '../typings/types'
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?: modeType[]
14
- disableResize?: modeType[]
15
- isCustom?: boolean | modeType[]
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 | modeType[]) {
95
+ withIsCustom(isCustom: boolean | ModeType[]) {
96
96
  this.eventImpl.isCustom = isCustom
97
97
 
98
98
  return this
99
99
  }
100
100
 
101
- withDisableDnD(disableDnD: modeType[]) {
101
+ withDisableDnD(disableDnD: ModeType[]) {
102
102
  this.eventImpl.disableDnD = disableDnD
103
103
 
104
104
  return this
105
105
  }
106
106
 
107
- withDisableResize(disableResize: modeType[]) {
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 { modeType } from './types'
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?: modeType
62
+ defaultMode?: ModeType
63
63
  disableModes?: ('week' | 'month' | string)[]
64
64
  isSilent?: boolean
65
65
  dayIntervals?: DayIntervalsType
@@ -1,4 +1,4 @@
1
- import type { modeType } from '../types'
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?: 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.
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 modeType = 'day' | 'week' | 'month' | 'agenda'
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 { modeType } from '../../calendar/typings/types'
2
+ import type { DateViewMode, ModeType } from '../../calendar/typings/types'
3
3
  import { Btn, NumberInput, Dropdown, TextInput, formatDate } from '@bagelink/vue'
4
- import { computed, ref, onMounted, onBeforeUnmount } from 'vue'
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?: modeType
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<ViewMode>('days')
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 ? 'dd.mm.yy HH:MM' : 'dd.mm.yy')
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 ? 'dd.mm.yy HH:MM' : 'dd.mm.yy'))
122
- const formattedMax = computed(() => formatDate(props.max, props.enableTime ? 'dd.mm.yy HH:MM' : 'dd.mm.yy'))
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, 'yyyy-mm-dd HH:MM'))
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, 'yyyy-mm-dd'))
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
- const handleDocumentClick = (e: MouseEvent) => {
386
- const target = e.target as HTMLElement
387
- if (!datePickerRef.value?.contains(target) && !calendarRef.value?.contains(target)) {
388
- isOpen.value = false
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 { modeType } from '../../calendar/typings/types'
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?: modeType
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
- type ViewMode = 'days' | 'months' | 'years'
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 ? 'dd.mm.yy HH:MM' : 'dd.mm.yy', props.locale)
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 ? 'dd.mm.yy HH:MM' : 'dd.mm.yy'))
56
- const formattedMax = $computed(() => formatDate(props.max, props.enableTime ? 'dd.mm.yy HH:MM' : 'dd.mm.yy'))
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
@@ -35,6 +35,12 @@ function handleKeyDown(event: KeyboardEvent, index: number) {
35
35
  return
36
36
  }
37
37
 
38
+ const preventKeys = ['ArrowUp', 'ArrowDown']
39
+ if (preventKeys.includes(event.key)) {
40
+ event.preventDefault()
41
+ return
42
+ }
43
+
38
44
  if (event.key === 'Backspace') {
39
45
  digits[index] = undefined
40
46
 
@@ -95,6 +101,7 @@ function isDigitsFull() {
95
101
  oninput="this.value = this.value.slice(0, 1)"
96
102
  @keydown="handleKeyDown($event, ind)"
97
103
  @paste="handlePaste($event, ind)"
104
+ @keyup.prevent
98
105
  >
99
106
  </div>
100
107
  </template>
@@ -119,10 +126,15 @@ function isDigitsFull() {
119
126
  font-size: 2.4rem;
120
127
  -moz-appearance: textfield; /* Firefox */
121
128
  caret-color: transparent;
129
+ /* Remove spinner arrows */
130
+ appearance: textfield; /* Standardized property */
122
131
  }
123
132
 
124
- .digit-box::-webkit-outer-spin-button {
125
- -webkit-appearance: none; /* Chrome, Safari, Edge, Opera */
133
+ /* Remove spinner arrows for Webkit browsers */
134
+ .digit-box::-webkit-outer-spin-button,
135
+ .digit-box::-webkit-inner-spin-button {
136
+ -webkit-appearance: none;
137
+ appearance: none;
126
138
  margin: 0;
127
139
  }
128
140
 
@@ -131,9 +143,10 @@ function isDigitsFull() {
131
143
  filter: drop-shadow(0 0 0.25rem var(--bgl-primary));
132
144
  }
133
145
 
134
- .digit-box[type="number"] {
135
- -moz-appearance: textfield; /* Firefox */
136
- }
146
+ /* Redundant, already covered above */
147
+ /* .digit-box[type="number"] {
148
+ -moz-appearance: textfield;
149
+ } */
137
150
 
138
151
  @media screen and (max-width: 910px) {
139
152
  .digit-box {
@@ -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 = new Array(byteCharacters.length)
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)
@@ -266,7 +266,7 @@ defineExpose({ open, close })
266
266
  }
267
267
  .file-info *{
268
268
  text-align: center !important;
269
- margin-inline: 0 !important;;
269
+ margin-inline: 0 !important;
270
270
  max-width: 100% !important;
271
271
  }
272
272
  }
@@ -0,0 +1,51 @@
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
+ | 'DD.MM.YY' | 'DD.MM.YYYY' | 'DD/MM/YY' | 'DD/MM/YYYY' // European style
28
+ | 'MM.DD.YY' | 'MM.DD.YYYY' | 'MM/DD/YY' | 'MM/DD/YYYY' // US style
29
+ | 'YYYY-MM-DD' | 'YY-MM-DD' // ISO style
30
+ | 'DD MMM YYYY' | 'DD MMMM YYYY' // Long format
31
+ | 'DDD, DD MMM' | 'DDDD, DD MMMM' // Day-focused format
32
+ | 'MMM DD' | 'MMMM DD' // Month-day format
33
+
34
+ export type CommonTimeFormats =
35
+ | 'HH:mm' | 'HH:mm:ss' | 'HH:mm:ss:sss' // 24-hour format
36
+ | 'HH:MM' // Alternative minute format
37
+ | 'HH:mm AmPm' // 12-hour format
38
+
39
+ // Combined date and time formats
40
+ export type CommonDateTimeFormats =
41
+ | `${CommonDateFormats} ${CommonTimeFormats}`
42
+ | `${CommonTimeFormats}, ${CommonDateFormats}`
43
+ | 'YYYY-MM-DD HH:MM' // Explicit ISO-style datetime format
44
+
45
+ // Final accepted format type with string fallback for custom formats
46
+ export type DateTimeAcceptedFormats =
47
+ | CommonDateFormats
48
+ | CommonTimeFormats
49
+ | CommonDateTimeFormats
50
+ // ! | string
51
+ // ! no string fallback so that autocomplete works (developers should can always cast to DateTimeAcceptedFormats)