accomadesc 0.0.13 → 0.1.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.
Files changed (69) hide show
  1. package/dist/AccoCard.svelte +1 -1
  2. package/dist/AccoCard.svelte.d.ts +3 -2
  3. package/dist/AccoDescription.svelte +1 -1
  4. package/dist/AccoDescription.svelte.d.ts +3 -2
  5. package/dist/AmenitiesCore.svelte +3 -3
  6. package/dist/AmenitiesCore.svelte.d.ts +3 -2
  7. package/dist/BookingRequest.svelte +272 -0
  8. package/dist/BookingRequest.svelte.d.ts +5 -0
  9. package/dist/Calendar.svelte +26 -13
  10. package/dist/Calendar.svelte.d.ts +3 -2
  11. package/dist/CalendarAvailable.svelte +12 -19
  12. package/dist/CalendarAvailable.svelte.d.ts +3 -2
  13. package/dist/CalendarGrid.svelte +22 -0
  14. package/dist/CalendarGrid.svelte.d.ts +5 -0
  15. package/dist/CalendarRows.svelte +22 -0
  16. package/dist/CalendarRows.svelte.d.ts +5 -0
  17. package/dist/ContactForm.svelte +180 -0
  18. package/dist/ContactForm.svelte.d.ts +5 -0
  19. package/dist/LeafletMap.svelte +1 -1
  20. package/dist/LeafletMap.svelte.d.ts +1 -1
  21. package/dist/Photo.svelte +1 -1
  22. package/dist/Photo.svelte.d.ts +3 -2
  23. package/dist/PhotoGallery.svelte +89 -35
  24. package/dist/PhotoGallery.svelte.d.ts +3 -2
  25. package/dist/Pricing.svelte +1 -1
  26. package/dist/Pricing.svelte.d.ts +3 -2
  27. package/dist/PricingShort.svelte +1 -1
  28. package/dist/PricingShort.svelte.d.ts +3 -2
  29. package/dist/Section.svelte +1 -1
  30. package/dist/Section.svelte.d.ts +3 -2
  31. package/dist/Text.svelte +1 -1
  32. package/dist/Text.svelte.d.ts +3 -2
  33. package/dist/Weather.svelte +2 -3
  34. package/dist/Weather.svelte.d.ts +3 -2
  35. package/dist/basic/Avatar.svelte.d.ts +3 -2
  36. package/dist/basic/Button.svelte +6 -3
  37. package/dist/basic/Button.svelte.d.ts +4 -3
  38. package/dist/basic/Icon.svelte.d.ts +3 -2
  39. package/dist/basic/Notes.svelte +83 -0
  40. package/dist/basic/Notes.svelte.d.ts +7 -0
  41. package/dist/basic/Spinner.svelte.d.ts +3 -2
  42. package/dist/basic/TextInput.svelte.d.ts +3 -2
  43. package/dist/helpers/debounce.d.ts +7 -0
  44. package/dist/helpers/debounce.js +49 -0
  45. package/dist/helpers/iCSEventExample.ics +14 -0
  46. package/dist/helpers/normalizeDate.d.ts +2 -0
  47. package/dist/helpers/normalizeDate.js +53 -0
  48. package/dist/helpers/readICS.d.ts +7 -0
  49. package/dist/helpers/readICS.js +94 -0
  50. package/dist/index.d.ts +2 -2
  51. package/dist/index.js +1 -1
  52. package/dist/names/gen.js +3 -3
  53. package/dist/occuplan/OccuPlanAvailableInfo.svelte +38 -0
  54. package/dist/occuplan/OccuPlanAvailableInfo.svelte.d.ts +12 -0
  55. package/dist/occuplan/OccuPlanGrid.svelte +356 -0
  56. package/dist/occuplan/OccuPlanGrid.svelte.d.ts +13 -0
  57. package/dist/occuplan/OccuPlanPicker.svelte +559 -0
  58. package/dist/occuplan/OccuPlanPicker.svelte.d.ts +16 -0
  59. package/dist/occuplan/OccuPlanRows.svelte +360 -0
  60. package/dist/occuplan/OccuPlanRows.svelte.d.ts +13 -0
  61. package/dist/occuplan/OccuPlanWrapper.svelte +113 -0
  62. package/dist/occuplan/OccuPlanWrapper.svelte.d.ts +5 -0
  63. package/dist/occuplan/state.svelte.d.ts +90 -0
  64. package/dist/occuplan/state.svelte.js +383 -0
  65. package/dist/svg/ExtLinkSVG.svelte.d.ts +3 -2
  66. package/dist/svg/LinkSVG.svelte.d.ts +3 -2
  67. package/dist/types.d.ts +75 -4
  68. package/dist/types.js +20 -0
  69. package/package.json +64 -61
@@ -0,0 +1,356 @@
1
+ <script lang="ts">
2
+ import { DateTime, type MonthNumbers } from 'luxon';
3
+ import * as Sqrl from 'squirrelly';
4
+ import {
5
+ defaultMonthHeaderFormat,
6
+ defaultMonthLabels,
7
+ defaultWeekdayLabels,
8
+ OCCUPATION_STATE,
9
+ OccupationState,
10
+ occupationTypeFormatting,
11
+ realFirstMonth,
12
+ type FirstMonth,
13
+ type OccupationType,
14
+ type OccuplanTranslations,
15
+ } from './state.svelte.js';
16
+ import { getContext, setContext } from 'svelte';
17
+ import Button from '../basic/Button.svelte';
18
+ import { browser } from '$app/environment';
19
+ import Spinner from '../basic/Spinner.svelte';
20
+
21
+ let {
22
+ url,
23
+ header = '',
24
+ footer = '',
25
+ nextPage = '>',
26
+ prevPage = '<',
27
+ weekdayLabels = defaultWeekdayLabels,
28
+ monthLabels = defaultMonthLabels,
29
+ monthHeaderFormat = defaultMonthHeaderFormat,
30
+ numberOfMonth = 12,
31
+ maxWidth = '1200px',
32
+ firstMonth = DateTime.utc().month,
33
+ maxDate = DateTime.utc().plus({ years: 2 }),
34
+ minDate = DateTime.utc(),
35
+ typeLabels = {
36
+ one: 'BOOKING',
37
+ two: 'RESERVATION',
38
+ three: 'PERSONAL',
39
+ },
40
+ }: OccuplanTranslations & {
41
+ url: string;
42
+ numberOfMonth?: number;
43
+ firstMonth?: FirstMonth;
44
+ minDate?: DateTime;
45
+ maxDate?: DateTime;
46
+ maxWidth?: string;
47
+ } = $props();
48
+
49
+ const oStateID = `i-${url}-${OCCUPATION_STATE}`;
50
+ let occupationState: OccupationState = $state(getContext(oStateID));
51
+ $effect(() => {
52
+ if (!occupationState && browser) {
53
+ occupationState = new OccupationState(url);
54
+ setContext(oStateID, occupationState);
55
+ }
56
+ });
57
+
58
+ let formatFun = $derived(Sqrl.compile(monthHeaderFormat, { useWith: true }));
59
+ const monthHeader = (monthNum: MonthNumbers, year: number): string => {
60
+ const monthLabel = monthLabels[monthNum];
61
+ return formatFun({ month: monthLabel, year }, Sqrl.defaultConfig);
62
+ };
63
+
64
+ let page: number = $state(0);
65
+ let rfMonth: DateTime = $derived(realFirstMonth(firstMonth, numberOfMonth, page));
66
+
67
+ let currentMaxDate = $derived(rfMonth.plus({ month: numberOfMonth }));
68
+
69
+ let months: DateTime[] = $derived.by(() => {
70
+ const result = [];
71
+
72
+ let fMonth: DateTime = DateTime.utc(rfMonth.year, rfMonth.month, 1);
73
+
74
+ result.push(fMonth);
75
+
76
+ let nMonth = fMonth.plus({ months: 1 });
77
+ for (let c = 1; c < numberOfMonth; c++) {
78
+ result.push(nMonth);
79
+ nMonth = nMonth.plus({ months: 1 });
80
+ }
81
+ return result;
82
+ });
83
+
84
+ const nextClicked = () => {
85
+ page += 1;
86
+ };
87
+
88
+ const prevClicked = () => {
89
+ page -= 1;
90
+ };
91
+
92
+ let monthGridTemplateColumns = `[rowLegend] 1fr [d1] 1fr [d2] 1fr [d3] 1fr [d4] 1fr [d5] 1fr [d6] 1fr [d7] 1fr`;
93
+
94
+ let monthGridTemplateRows = (m: DateTime): string => {
95
+ let res = `[columnLegend] 1fr [w${m.weekNumber}] 1fr`;
96
+ let n = m.plus({ weeks: 1 });
97
+ for (let w = 1; w <= 5; w++) {
98
+ res += ` [w${n.weekNumber}] 1fr`;
99
+ n = n.plus({ weeks: 1 });
100
+ }
101
+ return res;
102
+ };
103
+
104
+ const weeks = (m: DateTime): DateTime[] => {
105
+ let n = m.plus({ weeks: 1 });
106
+ let res: DateTime[] = [m, n];
107
+ for (let i = 1; i <= 4; i++) {
108
+ n = n.plus({ weeks: 1 });
109
+ res.push(n);
110
+ }
111
+ return res;
112
+ };
113
+
114
+ const days = (m: DateTime): DateTime[] => {
115
+ //find first
116
+ let firstDay = m.startOf('week');
117
+
118
+ //find last
119
+ let lastDayOfMonth = m.endOf('month');
120
+ let lastDay = lastDayOfMonth.endOf('week');
121
+
122
+ let n = firstDay.plus({ days: 1 });
123
+ let res: DateTime[] = [firstDay];
124
+
125
+ while (n <= lastDay) {
126
+ res.push(n);
127
+ n = n.plus({ days: 1 });
128
+ }
129
+
130
+ return res;
131
+ };
132
+
133
+ const hiddenWeekNum = (m: DateTime, w: DateTime): boolean => {
134
+ let lastDayOfMonth = m.endOf('month');
135
+ let firstDayOfWeek = w.startOf('week');
136
+ return lastDayOfMonth < firstDayOfWeek;
137
+ };
138
+
139
+ let foundOccupationTypes: OccupationType[] = $derived(
140
+ occupationState?.occupations.reduce((res, occupation) => {
141
+ if (!res.includes(occupation.type)) {
142
+ res.push(occupation.type);
143
+ }
144
+ return res;
145
+ }, [] as OccupationType[]),
146
+ );
147
+ </script>
148
+
149
+ {#if !occupationState || occupationState.loading}
150
+ <Spinner />
151
+ {/if}
152
+
153
+ <section class="occuplan-wrapper" style="max-width: {maxWidth};">
154
+ <header class="occupation-plan-header">
155
+ <div class="header-controls">
156
+ {#if rfMonth >= minDate}
157
+ <Button text={`${prevPage}`} clicked={prevClicked} />
158
+ {/if}
159
+ </div>
160
+ <div class="header-label"><h3>{@html header}</h3></div>
161
+ <div class="header-controls">
162
+ {#if currentMaxDate <= maxDate}
163
+ <Button text={`${nextPage}`} clicked={nextClicked} />
164
+ {/if}
165
+ </div>
166
+ </header>
167
+ <main>
168
+ {#each months as m (`${m.year}-${m.month}`)}
169
+ <div class="month">
170
+ <header class="month-header">{monthHeader(m.month as MonthNumbers, m.year)}</header>
171
+ <div
172
+ style="
173
+ grid-template-columns: {monthGridTemplateColumns};
174
+ grid-template-rows: {monthGridTemplateRows(m)};
175
+ "
176
+ class="days"
177
+ >
178
+ <div class="weekday-header" style="grid-area: columnLegend / d1 / columnLegend / d1;">
179
+ {weekdayLabels[1]}
180
+ </div>
181
+ <div class="weekday-header" style="grid-area: columnLegend / d2 / columnLegend / d2;">
182
+ {weekdayLabels[2]}
183
+ </div>
184
+ <div class="weekday-header" style="grid-area: columnLegend / d3 / columnLegend / d3;">
185
+ {weekdayLabels[3]}
186
+ </div>
187
+ <div class="weekday-header" style="grid-area: columnLegend / d4 / columnLegend / d4;">
188
+ {weekdayLabels[4]}
189
+ </div>
190
+ <div class="weekday-header" style="grid-area: columnLegend / d5 / columnLegend / d5;">
191
+ {weekdayLabels[5]}
192
+ </div>
193
+ <div class="weekday-header" style="grid-area: columnLegend / d6 / columnLegend / d6;">
194
+ {weekdayLabels[6]}
195
+ </div>
196
+ <div class="weekday-header" style="grid-area: columnLegend / d7 / columnLegend / d7;">
197
+ {weekdayLabels[7]}
198
+ </div>
199
+
200
+ {#each days(m) as d (`${d.year}-${d.month}-${d.day}`)}
201
+ <div
202
+ class:weekend={[6, 7].includes(d.weekday)}
203
+ class:other-month={m.month !== d.month}
204
+ class="day"
205
+ style="
206
+ grid-area: w{d.weekNumber} / d{d.weekday} / w{d.weekNumber} / d{d.weekday};
207
+ {occupationState?.occupationStyle(
208
+ { day: d.day, month: d.month as MonthNumbers, year: d.year },
209
+ false,
210
+ maxDate,
211
+ )}
212
+ "
213
+ >
214
+ {d.day}
215
+ </div>
216
+ {/each}
217
+
218
+ {#each weeks(m) as w (`${w.year}-${w.month}-${w.weekNumber}`)}
219
+ <div
220
+ class:hidden={hiddenWeekNum(m, w)}
221
+ class="week-number"
222
+ style="grid-area: w{w.weekNumber} / rowLegend / w{w.weekNumber} / rowLegend;"
223
+ >
224
+ {w.weekNumber}
225
+ </div>
226
+ {/each}
227
+ </div>
228
+ </div>
229
+ {/each}
230
+ </main>
231
+ <footer>
232
+ <div class="legend">
233
+ {#each foundOccupationTypes as t}
234
+ {@const format = occupationTypeFormatting(t)}
235
+ <span>{typeLabels[t]}</span>
236
+ <div
237
+ id="occupation-type-{t}-legend"
238
+ class="legend-entry-marker"
239
+ style="background-color: {format.bgColor};"
240
+ >
241
+ &nbsp;
242
+ </div>
243
+ {/each}
244
+ </div>
245
+ <div class="footer-content">
246
+ {@html footer}
247
+ </div>
248
+ </footer>
249
+ </section>
250
+
251
+ <style>
252
+ .footer-content {
253
+ display: flex;
254
+ flex-direction: column;
255
+ justify-content: flex-end;
256
+ }
257
+
258
+ .legend-entry-marker {
259
+ outline: var(--occuplan-grid-border);
260
+ }
261
+
262
+ .month-header {
263
+ text-align: center;
264
+ }
265
+
266
+ .hidden {
267
+ display: none;
268
+ }
269
+
270
+ .occupation-plan-header {
271
+ display: flex;
272
+ flex-direction: row;
273
+ width: 100%;
274
+ justify-content: space-between;
275
+ }
276
+
277
+ .header-label {
278
+ text-transform: capitalize;
279
+ font-weight: bold;
280
+ font-variant: small-caps;
281
+ }
282
+
283
+ .week-number {
284
+ text-align: left;
285
+ font-style: italic;
286
+ font-weight: lighter;
287
+ background-color: var(--occuplan-bg-color-weeknum);
288
+ color: var(--occuplan-font-color-weeknum);
289
+ }
290
+
291
+ .weekday-header {
292
+ text-align: center;
293
+ background-color: var(--occuplan-bg-color-days-header);
294
+ color: var(--occuplan-font-color-days-header);
295
+ grid-area: columnLegend / d1 / columnLegend / d1;
296
+ }
297
+
298
+ .day {
299
+ text-align: center;
300
+ }
301
+
302
+ .weekend {
303
+ font-weight: bold;
304
+ }
305
+
306
+ .occuplan-wrapper {
307
+ height: 100%;
308
+ width: calc(100% - 0.5rem);
309
+ padding: 0.5rem;
310
+ margin: 0;
311
+ display: flex;
312
+ flex-direction: column;
313
+ flex-wrap: nowrap;
314
+ align-items: center;
315
+
316
+ border: var(--occuplan-main-border);
317
+ color: var(--occuplan-font-color-main);
318
+ background-color: var(--occuplan-bg-color-main);
319
+ }
320
+
321
+ main {
322
+ display: grid;
323
+ grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
324
+ gap: 1rem;
325
+ width: 100%;
326
+ }
327
+
328
+ .month {
329
+ display: flex;
330
+ flex-direction: column;
331
+ }
332
+
333
+ .days {
334
+ display: grid;
335
+ }
336
+
337
+ footer {
338
+ display: flex;
339
+ flex-direction: row;
340
+ align-items: stretch;
341
+ justify-content: space-between;
342
+ width: 100%;
343
+ margin-top: 1rem;
344
+ }
345
+
346
+ .legend {
347
+ display: grid;
348
+ grid-template-columns: [label] 1fr [marker] 1rem;
349
+ column-gap: 1rem;
350
+ text-transform: capitalize;
351
+ font-variant: small-caps;
352
+ }
353
+ .header-controls {
354
+ width: 2rem;
355
+ }
356
+ </style>
@@ -0,0 +1,13 @@
1
+ import { DateTime } from 'luxon';
2
+ import { type FirstMonth, type OccuplanTranslations } from './state.svelte.js';
3
+ type $$ComponentProps = OccuplanTranslations & {
4
+ url: string;
5
+ numberOfMonth?: number;
6
+ firstMonth?: FirstMonth;
7
+ minDate?: DateTime;
8
+ maxDate?: DateTime;
9
+ maxWidth?: string;
10
+ };
11
+ declare const OccuPlanGrid: import("svelte").Component<$$ComponentProps, {}, "">;
12
+ type OccuPlanGrid = ReturnType<typeof OccuPlanGrid>;
13
+ export default OccuPlanGrid;