@stacksjs/calendar-api 0.64.6 → 0.66.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.
@@ -0,0 +1,43 @@
1
+ import type { Ref } from "vue";
2
+ export interface CalendarStore {
3
+ day: number;
4
+ month: Ref<number>;
5
+ year: Ref<number>;
6
+ currentMonthYear: Ref<string>;
7
+ currentMonthDayYear: Ref<string>;
8
+ datesOfThePastMonth: Ref<number[]>;
9
+ datesOfTheMonth: Ref<number[]>;
10
+ datesOfNextMonth: Ref<number[]>;
11
+ currentWeekView: Ref<number[]>;
12
+ currentWeekViewToday: Ref<number[]>;
13
+ }
14
+ export interface Time {
15
+ from: string;
16
+ to: string;
17
+ }
18
+ export interface Events {
19
+ date: string;
20
+ title: string;
21
+ description: string;
22
+ month: number;
23
+ day: number;
24
+ year: number;
25
+ time: Time;
26
+ }
27
+ export interface WeekDates {
28
+ month: number;
29
+ date: number;
30
+ }
31
+ export interface TimeTableStyle {
32
+ time: string;
33
+ gridRow: string;
34
+ }
35
+ export interface CalendarLink {
36
+ from: Date;
37
+ to: Date;
38
+ allDay: boolean;
39
+ address: string;
40
+ title: string;
41
+ description: string;
42
+ timezone: string;
43
+ }
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@stacksjs/calendar-api",
3
3
  "type": "module",
4
- "version": "0.64.6",
4
+ "version": "0.66.0",
5
5
  "description": "Easily interact with calendar APIs.",
6
6
  "author": "Chris Breuer",
7
+ "contributors": ["Chris Breuer <chris@stacksjs.org>"],
7
8
  "license": "MIT",
8
9
  "funding": "https://github.com/sponsors/chrisbbreuer",
9
10
  "homepage": "https://github.com/stacksjs/stacks/tree/main/storage/framework/core/calendar#readme",
@@ -34,23 +35,17 @@
34
35
  },
35
36
  "module": "dist/index.js",
36
37
  "types": "dist/index.d.ts",
37
- "contributors": [
38
- "Chris Breuer <chris@stacksjs.org>"
39
- ],
40
- "files": [
41
- "README.md",
42
- "dist",
43
- "src"
44
- ],
38
+ "files": ["README.md", "dist", "src"],
45
39
  "scripts": {
46
- "build": "bun --bun build.ts",
47
- "typecheck": "bun --bun tsc --noEmit",
40
+ "build": "bun build.ts",
41
+ "typecheck": "bun tsc --noEmit",
48
42
  "prepublishOnly": "bun run build"
49
43
  },
50
44
  "dependencies": {
51
- "@stacksjs/security": "latest"
45
+ "@stacksjs/browser": "0.65.1",
46
+ "@stacksjs/security": "0.65.1"
52
47
  },
53
48
  "devDependencies": {
54
- "@stacksjs/development": "latest"
49
+ "@stacksjs/development": "0.65.1"
55
50
  }
56
51
  }
@@ -1,4 +1,5 @@
1
1
  import type { CalendarLink } from '../types'
2
+ import { useDateFormat } from '@stacksjs/browser'
2
3
 
3
4
  const dateFormat = 'YYYYMMDD'
4
5
  const timeFormat = 'YYYYMMDDThhmmss'
@@ -15,12 +16,15 @@ export function generateGoogle(link: CalendarLink): string {
15
16
  useDateFormat(utcEndDateTime, dateTimeFormat).value
16
17
  }`
17
18
 
18
- if (link.timezone) url = `${url}&ctz=${link.timezone}`
19
+ if (link.timezone)
20
+ url = `${url}&ctz=${link.timezone}`
19
21
 
20
22
  url = `${url}&text=${encodeURIComponent(link.title)}`
21
23
 
22
- if (link.description) url = `${url}&details=${encodeURIComponent(link.description)}`
23
- if (link.address) url = `${url}&location=${encodeURIComponent(link.address)}`
24
+ if (link.description)
25
+ url = `${url}&details=${encodeURIComponent(link.description)}`
26
+ if (link.address)
27
+ url = `${url}&location=${encodeURIComponent(link.address)}`
24
28
 
25
29
  return url
26
30
  }
@@ -1,5 +1,6 @@
1
- import md5 from 'crypto-js/md5'
2
1
  import type { CalendarLink } from '../types'
2
+ import { useDateFormat, useMax } from '@stacksjs/browser'
3
+ import md5 from 'crypto-js/md5'
3
4
 
4
5
  export function generateIcs(link: CalendarLink): string {
5
6
  const dateFormat = 'YYYYMMDD'
@@ -25,14 +26,17 @@ export function generateIcs(link: CalendarLink): string {
25
26
  url.push(`DTSTAMP;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
26
27
  url.push(`DTSTART:${useDateFormat(link.from, dateTimeFormat).value}`)
27
28
  url.push(`DURATION:P${useMax(1, dateDiffInDays(link.from, link.to)).value}D`)
28
- } else {
29
+ }
30
+ else {
29
31
  url.push(`DTSTAMP;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
30
32
  url.push(`DTSTART;TZID=${useDateFormat(link.from, dateTimeFormat).value}`)
31
33
  url.push(`DTEND;TZID=${useDateFormat(link.to, dateTimeFormat).value}`)
32
34
  }
33
35
 
34
- if (link.description) url.push(`X-ALT-DESC;FMTTYPE=text/html:${link.description}`)
35
- if (link.address) url.push(`LOCATION:${link.address}`)
36
+ if (link.description)
37
+ url.push(`X-ALT-DESC;FMTTYPE=text/html:${link.description}`)
38
+ if (link.address)
39
+ url.push(`LOCATION:${link.address}`)
36
40
 
37
41
  url.push('END:VEVENT')
38
42
  url.push('END:VCALENDAR')
@@ -1,4 +1,5 @@
1
1
  import type { CalendarLink } from '../types'
2
+ import { useDateFormat } from '@stacksjs/browser'
2
3
 
3
4
  export function generateOutlook(link: CalendarLink): string {
4
5
  const dateFormat = 'YYYY-MM-DD'
@@ -19,12 +20,15 @@ export function generateOutlook(link: CalendarLink): string {
19
20
  ? `${url}&enddt=${useDateFormat(utcEndDateTime, dateTimeFormat).value}`
20
21
  : `${url}&enddt=${useDateFormat(utcEndDateTime, dateTimeFormat).value}Z`
21
22
 
22
- if (link.allDay) url = `${url}&allday=true`
23
+ if (link.allDay)
24
+ url = `${url}&allday=true`
23
25
 
24
26
  url = `${url}&subject=${encodeURIComponent(link.title)}`
25
27
 
26
- if (link.description) url = `${url}&body=${encodeURIComponent(link.description)}`
27
- if (link.address) url = `${url}&location=${encodeURIComponent(link.address)}`
28
+ if (link.description)
29
+ url = `${url}&body=${encodeURIComponent(link.description)}`
30
+ if (link.address)
31
+ url = `${url}&location=${encodeURIComponent(link.address)}`
28
32
 
29
33
  return url
30
34
  }
@@ -1,4 +1,5 @@
1
1
  import type { CalendarLink } from '../types'
2
+ import { useDateFormat } from '@stacksjs/browser'
2
3
 
3
4
  export function generateYahoo(link: CalendarLink): string {
4
5
  const dateFormat = 'YYYYMMDD'
@@ -13,15 +14,18 @@ export function generateYahoo(link: CalendarLink): string {
13
14
  url = `${url}&ST=${useDateFormat(link.from, dateTimeFormat).value}`
14
15
  url = `${url}&DUR=allday`
15
16
  url = `${url}&ET=${useDateFormat(link.to, dateTimeFormat).value}`
16
- } else {
17
+ }
18
+ else {
17
19
  url = `${url}&ST=${useDateFormat(utcStartDateTime, dateTimeFormat).value}Z`
18
20
  url = `${url}&ET=${useDateFormat(utcEndDateTime, dateTimeFormat).value}Z`
19
21
  }
20
22
 
21
23
  url = `${url}&TITLE=${encodeURIComponent(link.title)}`
22
24
 
23
- if (link.description) url = `${url}&DESC=${encodeURIComponent(link.description)}`
24
- if (link.address) url = `${url}&in_loc=${encodeURIComponent(link.address)}`
25
+ if (link.description)
26
+ url = `${url}&DESC=${encodeURIComponent(link.description)}`
27
+ if (link.address)
28
+ url = `${url}&in_loc=${encodeURIComponent(link.address)}`
25
29
 
26
30
  return url
27
31
  }
package/src/index.ts CHANGED
@@ -1,24 +1,21 @@
1
+ import type { CalendarLink } from './types'
1
2
  import { generateGoogle } from './generators/google'
2
3
  import { generateIcs } from './generators/ics'
3
4
  import { generateOutlook } from './generators/weboutlook'
4
5
  import { generateYahoo } from './generators/yahoo'
5
- import type { CalendarLink } from './types'
6
6
 
7
7
  export function exportCalendarGoogle(link: CalendarLink): string {
8
8
  return generateGoogle(link)
9
9
  }
10
10
 
11
- // functions that mutate state and trigger updates
12
11
  export function exportCalendarIcs(link: CalendarLink): string {
13
12
  return generateIcs(link)
14
13
  }
15
14
 
16
- // functions that mutate state and trigger updates
17
15
  export function exportCalendarOutlook(link: CalendarLink): string {
18
16
  return generateOutlook(link)
19
17
  }
20
18
 
21
- // functions that mutate state and trigger updates
22
19
  export function exportCalendarYahoo(link: CalendarLink): string {
23
20
  return generateYahoo(link)
24
21
  }
package/src/types.ts CHANGED
@@ -39,7 +39,7 @@ export interface TimeTableStyle {
39
39
  export interface CalendarLink {
40
40
  from: Date
41
41
  to: Date
42
- allDay: Boolean
42
+ allDay: boolean
43
43
  address: string
44
44
  title: string
45
45
  description: string