accomadesc 0.1.15 → 0.1.17

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.
@@ -4,6 +4,7 @@
4
4
 
5
5
  let {
6
6
  url,
7
+ debug = false,
7
8
  calendarTranslation,
8
9
  toggleGridOffset,
9
10
  gridMonthNumbers,
@@ -14,12 +15,13 @@
14
15
  rowsFirstMonth,
15
16
  rowsMaxWidth,
16
17
  translateFunc,
17
- }: CalendarContent & I18nFacade = $props();
18
+ }: CalendarContent & I18nFacade & { debug?: boolean } = $props();
18
19
  </script>
19
20
 
20
21
  <div class="cal-wrapper">
21
22
  <OccuPlanWrapper
22
23
  {url}
24
+ {debug}
23
25
  {toggleGridOffset}
24
26
  gridNumberOfMonths={gridMonthNumbers}
25
27
  {gridFirstMonth}
@@ -1,5 +1,7 @@
1
1
  import type { CalendarContent, I18nFacade } from './types.js';
2
- type $$ComponentProps = CalendarContent & I18nFacade;
2
+ type $$ComponentProps = CalendarContent & I18nFacade & {
3
+ debug?: boolean;
4
+ };
3
5
  declare const Calendar: import("svelte").Component<$$ComponentProps, {}, "">;
4
6
  type Calendar = ReturnType<typeof Calendar>;
5
7
  export default Calendar;
@@ -6,11 +6,12 @@
6
6
 
7
7
  let {
8
8
  url,
9
+ debug = true,
9
10
  search = [3, 7, 14],
10
11
  maxFutureDate = DateTime.now().plus({ years: 2 }).toISO(),
11
12
  formatFunc,
12
13
  translateFunc,
13
- }: CalendarAvailableContent & I18nFacade = $props();
14
+ }: CalendarAvailableContent & I18nFacade & { debug?: boolean } = $props();
14
15
 
15
16
  let availHeader = $derived(translateFunc ? translateFunc('availability') : '[AVAILABILITY]');
16
17
 
@@ -32,7 +33,7 @@
32
33
  <div class="cal-wrapper">
33
34
  <h3>{availHeader}</h3>
34
35
 
35
- <OccuPlanAvailableInfo {search} {url}>
36
+ <OccuPlanAvailableInfo {debug} {search} {url}>
36
37
  {#snippet children(av: AvailableSpans)}
37
38
  <ul>
38
39
  {#each search as s}
@@ -1,5 +1,7 @@
1
1
  import type { CalendarAvailableContent, I18nFacade } from './types.js';
2
- type $$ComponentProps = CalendarAvailableContent & I18nFacade;
2
+ type $$ComponentProps = CalendarAvailableContent & I18nFacade & {
3
+ debug?: boolean;
4
+ };
3
5
  declare const CalendarAvailable: import("svelte").Component<$$ComponentProps, {}, "">;
4
6
  type CalendarAvailable = ReturnType<typeof CalendarAvailable>;
5
7
  export default CalendarAvailable;
@@ -2,12 +2,18 @@
2
2
  import type { CalendarGridContent, I18nFacade } from './types.js';
3
3
  import OccuPlanGrid from './occuplan/OccuPlanGrid.svelte';
4
4
 
5
- let { url, calendarTranslation, translateFunc }: CalendarGridContent & I18nFacade = $props();
5
+ let {
6
+ url,
7
+ debug = false,
8
+ calendarTranslation,
9
+ translateFunc,
10
+ }: CalendarGridContent & I18nFacade & { debug?: boolean } = $props();
6
11
  </script>
7
12
 
8
13
  <div class="cal-wrapper">
9
14
  <OccuPlanGrid
10
15
  {url}
16
+ {debug}
11
17
  header={translateFunc ? translateFunc('calendarHeader') : ''}
12
18
  {...calendarTranslation}
13
19
  />
@@ -1,5 +1,7 @@
1
1
  import type { CalendarGridContent, I18nFacade } from './types.js';
2
- type $$ComponentProps = CalendarGridContent & I18nFacade;
2
+ type $$ComponentProps = CalendarGridContent & I18nFacade & {
3
+ debug?: boolean;
4
+ };
3
5
  declare const CalendarGrid: import("svelte").Component<$$ComponentProps, {}, "">;
4
6
  type CalendarGrid = ReturnType<typeof CalendarGrid>;
5
7
  export default CalendarGrid;
@@ -2,12 +2,18 @@
2
2
  import type { CalendarRowsContent, I18nFacade } from './types.js';
3
3
  import OccuPlanRows from './occuplan/OccuPlanRows.svelte';
4
4
 
5
- let { url, calendarTranslation, translateFunc }: CalendarRowsContent & I18nFacade = $props();
5
+ let {
6
+ url,
7
+ debug,
8
+ calendarTranslation,
9
+ translateFunc,
10
+ }: CalendarRowsContent & I18nFacade & { debug?: boolean } = $props();
6
11
  </script>
7
12
 
8
13
  <div class="cal-wrapper">
9
14
  <OccuPlanRows
10
15
  {url}
16
+ {debug}
11
17
  header={translateFunc ? translateFunc('calendarHeader') : ''}
12
18
  {...calendarTranslation}
13
19
  />
@@ -1,5 +1,7 @@
1
1
  import type { CalendarRowsContent, I18nFacade } from './types.js';
2
- type $$ComponentProps = CalendarRowsContent & I18nFacade;
2
+ type $$ComponentProps = CalendarRowsContent & I18nFacade & {
3
+ debug?: boolean;
4
+ };
3
5
  declare const CalendarRows: import("svelte").Component<$$ComponentProps, {}, "">;
4
6
  type CalendarRows = ReturnType<typeof CalendarRows>;
5
7
  export default CalendarRows;
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { getIcon } from './icons.js';
3
- import { randomID } from '../names/gen.ts';
3
+ import { randomID } from '../names/gen.js';
4
4
 
5
5
  const {
6
6
  text = null,
@@ -5,6 +5,7 @@
5
5
  import {
6
6
  OCCUPATION_STATE,
7
7
  OccupationState,
8
+ getOccupationState,
8
9
  type AvailableSpans,
9
10
  } from './state.svelte.js';
10
11
  import Spinner from '../basic/Spinner.svelte';
@@ -12,11 +13,13 @@
12
13
 
13
14
  let {
14
15
  url,
16
+ debug = false,
15
17
  search = [3, 7, 14],
16
18
  maxFutureDate = normalizeDate(DateTime.utc().plus({ years: 1 })),
17
19
  children,
18
20
  }: {
19
21
  url: string;
22
+ debug?: boolean;
20
23
  search?: number[];
21
24
  maxFutureDate?: DateTime;
22
25
  children: Snippet<[AvailableSpans]>;
@@ -27,7 +30,7 @@
27
30
 
28
31
  $effect(() => {
29
32
  if (!occupationState && browser) {
30
- occupationState = new OccupationState(url);
33
+ occupationState = getOccupationState(url, debug);
31
34
  setContext(oStateID, occupationState);
32
35
  }
33
36
  });
@@ -3,6 +3,7 @@ import { type Snippet } from 'svelte';
3
3
  import { type AvailableSpans } from './state.svelte.js';
4
4
  type $$ComponentProps = {
5
5
  url: string;
6
+ debug?: boolean;
6
7
  search?: number[];
7
8
  maxFutureDate?: DateTime;
8
9
  children: Snippet<[AvailableSpans]>;
@@ -7,6 +7,7 @@
7
7
  defaultWeekdayLabels,
8
8
  OCCUPATION_STATE,
9
9
  OccupationState,
10
+ getOccupationState,
10
11
  occupationTypeFormatting,
11
12
  realFirstMonth,
12
13
  type FirstMonth,
@@ -20,6 +21,7 @@
20
21
 
21
22
  let {
22
23
  url,
24
+ debug = false,
23
25
  header = '',
24
26
  footer = '',
25
27
  nextPage = '>',
@@ -39,6 +41,7 @@
39
41
  },
40
42
  }: OccuplanTranslations & {
41
43
  url: string;
44
+ debug?: boolean;
42
45
  numberOfMonth?: number;
43
46
  firstMonth?: FirstMonth;
44
47
  minDate?: DateTime;
@@ -50,7 +53,7 @@
50
53
  let occupationState: OccupationState = $state(getContext(oStateID));
51
54
  $effect(() => {
52
55
  if (!occupationState && browser) {
53
- occupationState = new OccupationState(url);
56
+ occupationState = getOccupationState(url, debug);
54
57
  setContext(oStateID, occupationState);
55
58
  }
56
59
  });
@@ -2,6 +2,7 @@ import { DateTime } from 'luxon';
2
2
  import { type FirstMonth, type OccuplanTranslations } from './state.svelte.js';
3
3
  type $$ComponentProps = OccuplanTranslations & {
4
4
  url: string;
5
+ debug?: boolean;
5
6
  numberOfMonth?: number;
6
7
  firstMonth?: FirstMonth;
7
8
  minDate?: DateTime;
@@ -7,6 +7,7 @@
7
7
  defaultWeekdayLabels,
8
8
  OCCUPATION_STATE,
9
9
  OccupationState,
10
+ getOccupationState,
10
11
  realFirstMonth,
11
12
  type OccuplanTranslations,
12
13
  } from './state.svelte.js';
@@ -18,6 +19,7 @@
18
19
 
19
20
  let {
20
21
  url,
22
+ debug = false,
21
23
  arrival = undefined,
22
24
  leave = undefined,
23
25
  nextPage = '>',
@@ -46,6 +48,7 @@
46
48
  },
47
49
  }: OccuplanTranslations & {
48
50
  url: string;
51
+ debug?: boolean;
49
52
  arrival?: DateTime;
50
53
  leave?: DateTime;
51
54
  showArrival?: boolean;
@@ -60,7 +63,7 @@
60
63
  let occupationState: OccupationState = $state(getContext(oStateID));
61
64
  $effect(() => {
62
65
  if (!occupationState && browser) {
63
- occupationState = new OccupationState(url);
66
+ occupationState = getOccupationState(url, debug);
64
67
  setContext(oStateID, occupationState);
65
68
  }
66
69
  });
@@ -2,6 +2,7 @@ import { DateTime } from 'luxon';
2
2
  import { type OccuplanTranslations } from './state.svelte.js';
3
3
  type $$ComponentProps = OccuplanTranslations & {
4
4
  url: string;
5
+ debug?: boolean;
5
6
  arrival?: DateTime;
6
7
  leave?: DateTime;
7
8
  showArrival?: boolean;
@@ -4,6 +4,7 @@
4
4
  defaultMonthLabels,
5
5
  defaultWeekendLabel,
6
6
  OccupationState,
7
+ getOccupationState,
7
8
  occupationTypeFormatting,
8
9
  type OccupationType,
9
10
  type OccuplanTranslations,
@@ -19,6 +20,7 @@
19
20
 
20
21
  let {
21
22
  url,
23
+ debug = false,
22
24
  header = '',
23
25
  footer = '',
24
26
  weekendLabel = defaultWeekendLabel,
@@ -35,6 +37,7 @@
35
37
  },
36
38
  }: OccuplanTranslations & {
37
39
  url: string;
40
+ debug?: boolean;
38
41
  numberOfMonth?: number;
39
42
  firstMonth?: FirstMonth;
40
43
  minDate?: DateTime;
@@ -46,7 +49,7 @@
46
49
  let occupationState: OccupationState = $state(getContext(oStateID));
47
50
  $effect(() => {
48
51
  if (!occupationState && browser) {
49
- occupationState = new OccupationState(url);
52
+ occupationState = getOccupationState(url, debug);
50
53
  setContext(oStateID, occupationState);
51
54
  }
52
55
  });
@@ -2,6 +2,7 @@ import { DateTime } from 'luxon';
2
2
  import { type OccuplanTranslations, type FirstMonth } from './state.svelte.js';
3
3
  type $$ComponentProps = OccuplanTranslations & {
4
4
  url: string;
5
+ debug?: boolean;
5
6
  numberOfMonth?: number;
6
7
  firstMonth?: FirstMonth;
7
8
  minDate?: DateTime;
@@ -19,6 +19,7 @@
19
19
  url,
20
20
  header = '',
21
21
  footer = '',
22
+ debug = false,
22
23
  weekendLabel = defaultWeekendLabel,
23
24
  monthLabels = defaultMonthLabels,
24
25
  weekdayLabels = defaultWeekdayLabels,
@@ -42,16 +43,6 @@
42
43
  },
43
44
  }: OccuplanTranslations & OccuplanMiscProps = $props();
44
45
 
45
- /*const oStateID = `i-${url}-${OCCUPATION_STATE}`;
46
- let occupationState: OccupationState = getContext(oStateID);
47
- $effect(() => {
48
- if (browser && !occupationState) {
49
- occupationState = new OccupationState(url);
50
- setContext(oStateID, occupationState);
51
- }
52
- });
53
- */
54
-
55
46
  /*
56
47
  use different component based on different media size.
57
48
  */
@@ -76,6 +67,7 @@
76
67
  <div class="calendar-wrapper" bind:clientWidth={w}>
77
68
  {#if showRows}
78
69
  <OccuPlanRows
70
+ {debug}
79
71
  {url}
80
72
  {header}
81
73
  {footer}
@@ -90,6 +82,7 @@
90
82
  />
91
83
  {:else if showGrid}
92
84
  <OccuPlanGrid
85
+ {debug}
93
86
  {url}
94
87
  {header}
95
88
  {footer}
@@ -51,6 +51,7 @@ export type PrevMonthNumbers = '-1' | '-2' | '-3' | '-4' | '-5' | '-6' | '-7' |
51
51
  export type FirstMonth = MonthNumbers | NextMonthNumbers | PrevMonthNumbers | 0;
52
52
  export interface OccuplanMiscProps {
53
53
  url: string;
54
+ debug?: boolean;
54
55
  gridNumberOfMonths?: number;
55
56
  gridFirstMonth?: FirstMonth;
56
57
  gridMaxWidth?: string;
@@ -71,7 +72,8 @@ export declare class OccupationState {
71
72
  occupiedDays: Record<string, boolean>;
72
73
  occupations: Occupation[];
73
74
  loading: boolean;
74
- constructor(iCalURL: string);
75
+ debug: boolean;
76
+ constructor(iCalURL: string, debug?: boolean);
75
77
  private loadOccupations;
76
78
  private eventsIncomingCallback;
77
79
  private dayKey;
@@ -87,4 +89,4 @@ export declare class OccupationState {
87
89
  validRequest: (from: DateTime, to: DateTime) => boolean;
88
90
  occupationStyle: (d: DayHelper, highlightWeekend: boolean | undefined, maxDate: DateTime) => string;
89
91
  }
90
- export declare const getOccupationState: (url: string) => OccupationState;
92
+ export declare const getOccupationState: (url: string, debug?: boolean) => OccupationState;
@@ -179,11 +179,17 @@ export class OccupationState {
179
179
  occupiedDays = $state({});
180
180
  occupations = $state([]);
181
181
  loading = $state(false);
182
- constructor(iCalURL) {
182
+ debug = $state(false);
183
+ constructor(iCalURL, debug = false) {
184
+ this.debug = debug;
185
+ if (this.debug)
186
+ console.log('Constructing OState with CalUrl: ', iCalURL);
183
187
  this.iCalURL = iCalURL;
184
188
  this.loadOccupations();
185
189
  }
186
190
  loadOccupations = async () => {
191
+ if (this.debug)
192
+ console.log('(Re)Loading Occupations');
187
193
  this.loading = true;
188
194
  if (this.iCalURL) {
189
195
  const eventsResult = await getEvents(this.iCalURL, this.eventsIncomingCallback);
@@ -193,6 +199,8 @@ export class OccupationState {
193
199
  return false;
194
200
  };
195
201
  eventsIncomingCallback = (o) => {
202
+ if (this.debug)
203
+ console.log('Occupation incoming: ', o);
196
204
  this.occupations.push(o);
197
205
  this.updateOccupiedDays(o);
198
206
  };
@@ -373,11 +381,13 @@ export class OccupationState {
373
381
  };
374
382
  }
375
383
  let _instances = {};
376
- export const getOccupationState = (url) => {
384
+ export const getOccupationState = (url, debug = false) => {
385
+ if (debug)
386
+ console.log('Get OState /w url', url);
377
387
  const currentInstance = _instances[url];
378
388
  if (currentInstance)
379
389
  return currentInstance;
380
- const newInstance = new OccupationState(url);
390
+ const newInstance = new OccupationState(url, debug);
381
391
  _instances[url] = newInstance;
382
392
  return _instances[url];
383
393
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accomadesc",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run package",