accomadesc 0.3.42 → 0.4.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/README.md +130 -34
- package/dist/AccoCard.svelte +1 -1
- package/dist/CalendarAvailable.svelte +1 -1
- package/dist/MainNav.svelte +1 -2
- package/dist/PageComponent.svelte +1 -2
- package/dist/PhotoGallery.svelte +5 -1
- package/dist/Pricing.svelte +81 -168
- package/dist/SiteState.svelte.d.ts +1 -1
- package/dist/SiteState.svelte.js +21 -13
- package/dist/basic/TextInput.svelte +78 -116
- package/dist/basic/TextInput.svelte.d.ts +2 -0
- package/dist/basic/icons/actions.d.ts +13 -0
- package/dist/basic/icons/actions.js +44 -0
- package/dist/basic/icons/navigation.d.ts +6 -0
- package/dist/basic/icons/navigation.js +16 -0
- package/dist/basic/icons/ui.d.ts +13 -0
- package/dist/basic/icons/ui.js +44 -0
- package/dist/basic/icons.d.ts +4 -0
- package/dist/basic/icons.js +51 -413
- package/dist/helpers/debounce.js +8 -2
- package/dist/helpers/format.js +2 -1
- package/dist/helpers/normalizeDate.d.ts +1 -1
- package/dist/helpers/normalizeDate.js +25 -16
- package/dist/helpers/readICS.js +21 -4
- package/dist/index.d.ts +1 -1
- package/dist/names/README.md +1 -1
- package/dist/names/gen.js +10 -1
- package/dist/occuplan/state.svelte.js +7 -3
- package/dist/occusplan-link/OccuPlanAvailableInfo.svelte +38 -0
- package/dist/occusplan-link/OccuPlanGrid.svelte +375 -0
- package/dist/occusplan-link/OccuPlanPicker.svelte +575 -0
- package/dist/occusplan-link/OccuPlanRows.svelte +368 -0
- package/dist/occusplan-link/OccuPlanWrapper.svelte +108 -0
- package/dist/occusplan-link/defaultTranslations.js +157 -0
- package/dist/occusplan-link/state.svelte.d.ts +92 -0
- package/dist/occusplan-link/state.svelte.js +424 -0
- package/dist/svg/LogoSVG.svelte +0 -1
- package/dist/types.d.ts +2 -2
- package/package.json +10 -4
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { DateTime, type MonthNumbers, type WeekdayNumbers } from 'luxon';
|
|
2
|
+
export interface AvailableSpans {
|
|
3
|
+
[key: number]: DateTime | null;
|
|
4
|
+
}
|
|
5
|
+
export interface Occupation {
|
|
6
|
+
arrival: DateTime;
|
|
7
|
+
leave: DateTime;
|
|
8
|
+
type: OccupationType;
|
|
9
|
+
}
|
|
10
|
+
export type OccupationCallback = (occupation: Occupation) => void;
|
|
11
|
+
export type WeekdayLabels = {
|
|
12
|
+
[key in WeekdayNumbers]: string;
|
|
13
|
+
};
|
|
14
|
+
export type MonthLabels = {
|
|
15
|
+
[key in MonthNumbers]: string;
|
|
16
|
+
};
|
|
17
|
+
export type OccupationType = 'one' | 'two' | 'three';
|
|
18
|
+
export declare const OCCUPATION_STATE = "occupation-state";
|
|
19
|
+
export declare const occupationTypeFormattingByOccupation: (o?: Occupation) => {
|
|
20
|
+
fontColor: string;
|
|
21
|
+
bgColor: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const occupationTypeFormatting: (t?: OccupationType) => {
|
|
24
|
+
fontColor: string;
|
|
25
|
+
bgColor: string;
|
|
26
|
+
};
|
|
27
|
+
export interface DayHelper {
|
|
28
|
+
day: number;
|
|
29
|
+
month: MonthNumbers;
|
|
30
|
+
year: number;
|
|
31
|
+
}
|
|
32
|
+
export declare const firstMonthValid: (value: string | number) => boolean;
|
|
33
|
+
export declare const realFirstMonth: (firstMonth: FirstMonth, firstMonthYear: number, numberOfMonth: number, page: number) => DateTime;
|
|
34
|
+
export interface OccuplanTranslations {
|
|
35
|
+
arrivalLabel?: string;
|
|
36
|
+
leaveLabel?: string;
|
|
37
|
+
header?: string;
|
|
38
|
+
footer?: string;
|
|
39
|
+
weekendLabel?: string;
|
|
40
|
+
weekdayLabels?: WeekdayLabels;
|
|
41
|
+
monthLabels?: MonthLabels;
|
|
42
|
+
monthHeaderFormat?: string;
|
|
43
|
+
datePickerDateFormat?: string;
|
|
44
|
+
numberOfNights?: string;
|
|
45
|
+
nextPage?: string;
|
|
46
|
+
prevPage?: string;
|
|
47
|
+
typeLabels?: Record<OccupationType, string>;
|
|
48
|
+
}
|
|
49
|
+
export type NextMonthNumbers = '+1' | '+2' | '+3' | '+4' | '+5' | '+6' | '+7' | '+8' | '+9' | '+10' | '+11' | '+12';
|
|
50
|
+
export type PrevMonthNumbers = '-1' | '-2' | '-3' | '-4' | '-5' | '-6' | '-7' | '-8' | '-9' | '-10' | '-11' | '-12';
|
|
51
|
+
export type FirstMonth = MonthNumbers | NextMonthNumbers | PrevMonthNumbers | 0;
|
|
52
|
+
export interface OccuplanMiscProps {
|
|
53
|
+
url: string;
|
|
54
|
+
debug?: boolean;
|
|
55
|
+
gridNumberOfMonths?: number;
|
|
56
|
+
gridFirstMonth?: FirstMonth;
|
|
57
|
+
gridMaxWidth?: string;
|
|
58
|
+
rowsNumberOfMonths?: number;
|
|
59
|
+
rowsFirstMonth?: FirstMonth;
|
|
60
|
+
rowsMaxWidth?: string;
|
|
61
|
+
minDate?: DateTime;
|
|
62
|
+
maxDate?: DateTime;
|
|
63
|
+
toggleGridOffset?: number;
|
|
64
|
+
toggleRowsOffset?: number;
|
|
65
|
+
}
|
|
66
|
+
export declare const defaultWeekendLabel = "Weekend";
|
|
67
|
+
export declare const defaultWeekdayLabels: WeekdayLabels;
|
|
68
|
+
export declare const defaultMonthLabels: MonthLabels;
|
|
69
|
+
export declare const defaultMonthHeaderFormat = "{{month}} / {{year}}";
|
|
70
|
+
export declare class OccupationState {
|
|
71
|
+
iCalURL: string;
|
|
72
|
+
occupiedDays: Record<string, boolean>;
|
|
73
|
+
occupations: Occupation[];
|
|
74
|
+
loading: boolean;
|
|
75
|
+
debug: boolean;
|
|
76
|
+
constructor(iCalURL: string, debug?: boolean);
|
|
77
|
+
loadOccupations: () => Promise<boolean>;
|
|
78
|
+
private eventsIncomingCallback;
|
|
79
|
+
private dayKey;
|
|
80
|
+
private updateOccupiedDays;
|
|
81
|
+
firstFree: (maxFutureDate: DateTime) => DateTime;
|
|
82
|
+
earliestRequestStart: (currentEnd: DateTime | undefined) => DateTime | undefined;
|
|
83
|
+
latestRequestEnd: (maxFutureDate: DateTime, currentStart: DateTime | undefined) => DateTime | undefined;
|
|
84
|
+
calcAvailability: (search: number[], maxFutureDate: DateTime) => AvailableSpans;
|
|
85
|
+
dayOccupied: (day: DateTime) => boolean;
|
|
86
|
+
startingOccupation: (d: DateTime) => Occupation | undefined;
|
|
87
|
+
endingOccupation: (d: DateTime) => Occupation | undefined;
|
|
88
|
+
fullOccupation: (d: DateTime) => Occupation | undefined;
|
|
89
|
+
validRequest: (from: DateTime, to: DateTime) => boolean;
|
|
90
|
+
occupationStyle: (d: DayHelper, highlightWeekend: boolean | undefined, maxDate: DateTime) => string;
|
|
91
|
+
}
|
|
92
|
+
export declare const getOccupationState: (url: string, debug?: boolean) => OccupationState;
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { normalizeDate } from '../helpers/normalizeDate.js';
|
|
2
|
+
import { getEvents } from '../helpers/readICS.js';
|
|
3
|
+
import { DateTime } from 'luxon';
|
|
4
|
+
import { DateTime as luxon } from 'luxon';
|
|
5
|
+
import { getContext, setContext } from 'svelte';
|
|
6
|
+
export const OCCUPATION_STATE = 'occupation-state';
|
|
7
|
+
export const occupationTypeFormattingByOccupation = (o) => {
|
|
8
|
+
return occupationTypeFormatting(o?.type);
|
|
9
|
+
};
|
|
10
|
+
export const occupationTypeFormatting = (t) => {
|
|
11
|
+
switch (t) {
|
|
12
|
+
case 'one':
|
|
13
|
+
return {
|
|
14
|
+
fontColor: 'var(--occupation-type-1-font-color)',
|
|
15
|
+
bgColor: 'var(--occupation-type-1-bg-color)',
|
|
16
|
+
};
|
|
17
|
+
case 'two':
|
|
18
|
+
return {
|
|
19
|
+
fontColor: 'var(--occupation-type-2-font-color)',
|
|
20
|
+
bgColor: 'var(--occupation-type-2-bg-color)',
|
|
21
|
+
};
|
|
22
|
+
case 'three':
|
|
23
|
+
return {
|
|
24
|
+
fontColor: 'var(--occupation-type-3-font-color)',
|
|
25
|
+
bgColor: 'var(--occupation-type-3-bg-color)',
|
|
26
|
+
};
|
|
27
|
+
default:
|
|
28
|
+
return {
|
|
29
|
+
fontColor: 'var(--occupation-type-1-font-color)',
|
|
30
|
+
bgColor: 'var(--occupation-type-1-bg-color)',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export const firstMonthValid = (value) => {
|
|
35
|
+
if (typeof value === 'number') {
|
|
36
|
+
const intValue = value;
|
|
37
|
+
return intValue >= 0 && intValue <= 12;
|
|
38
|
+
}
|
|
39
|
+
else if (value.length > 1) {
|
|
40
|
+
//check + sign
|
|
41
|
+
if (value[0] == '+') {
|
|
42
|
+
const toParse = value.slice(1);
|
|
43
|
+
try {
|
|
44
|
+
const intValue = parseInt(toParse);
|
|
45
|
+
if (intValue >= 0 && intValue <= 12) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
console.log('casting error', e);
|
|
51
|
+
}
|
|
52
|
+
//check - sign
|
|
53
|
+
}
|
|
54
|
+
else if (value[0] == '-') {
|
|
55
|
+
const toParse = value.slice(1);
|
|
56
|
+
try {
|
|
57
|
+
const intValue = parseInt(toParse);
|
|
58
|
+
if (intValue >= 0 && intValue <= 12) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (e) {
|
|
63
|
+
console.log('casting error', e);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
const intValue = parseInt(value);
|
|
69
|
+
if (intValue >= 0 && intValue <= 12) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
console.log('casting error', e);
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
export const realFirstMonth = (firstMonth, firstMonthYear, numberOfMonth, page) => {
|
|
79
|
+
const monthToAdd = page * numberOfMonth;
|
|
80
|
+
if (typeof firstMonth === 'number') {
|
|
81
|
+
const intValue = firstMonth;
|
|
82
|
+
if (intValue >= 1 && intValue <= 12) {
|
|
83
|
+
const tDate = normalizeDate(DateTime.utc())
|
|
84
|
+
.set({ month: intValue, year: firstMonthYear })
|
|
85
|
+
.plus({ month: monthToAdd });
|
|
86
|
+
return tDate;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
return normalizeDate(DateTime.utc()).plus(monthToAdd);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (typeof firstMonth === 'string' && firstMonth.length > 1) {
|
|
93
|
+
//check + sign
|
|
94
|
+
if (firstMonth[0] == '+') {
|
|
95
|
+
const toParse = firstMonth.slice(1);
|
|
96
|
+
try {
|
|
97
|
+
const intValue = parseInt(toParse);
|
|
98
|
+
if (intValue >= 1 && intValue <= 12) {
|
|
99
|
+
const tDate = normalizeDate(DateTime.utc())
|
|
100
|
+
.set({ year: firstMonthYear })
|
|
101
|
+
.plus({ month: intValue })
|
|
102
|
+
.plus({ month: monthToAdd });
|
|
103
|
+
return tDate;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return normalizeDate(DateTime.utc()).plus(monthToAdd);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
console.log('casting error', e);
|
|
111
|
+
}
|
|
112
|
+
//check - sign
|
|
113
|
+
}
|
|
114
|
+
else if (firstMonth[0] == '-') {
|
|
115
|
+
const toParse = firstMonth.slice(1);
|
|
116
|
+
try {
|
|
117
|
+
const intValue = parseInt(toParse);
|
|
118
|
+
if (intValue >= 0 && intValue <= 12) {
|
|
119
|
+
const tDate = normalizeDate(DateTime.utc())
|
|
120
|
+
.set({ year: firstMonthYear })
|
|
121
|
+
.minus({ month: intValue })
|
|
122
|
+
.plus({ month: monthToAdd });
|
|
123
|
+
return tDate;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return normalizeDate(DateTime.utc()).plus(monthToAdd);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
console.log('casting error', e);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (typeof firstMonth == 'string') {
|
|
135
|
+
try {
|
|
136
|
+
const intValue = parseInt(firstMonth);
|
|
137
|
+
//current dynamic month
|
|
138
|
+
if (intValue == 0) {
|
|
139
|
+
return normalizeDate(DateTime.utc())
|
|
140
|
+
.set({ year: firstMonthYear })
|
|
141
|
+
.plus({ month: monthToAdd });
|
|
142
|
+
}
|
|
143
|
+
//static month of current year
|
|
144
|
+
if (intValue >= 1 && intValue <= 12) {
|
|
145
|
+
const tDate = normalizeDate(DateTime.utc())
|
|
146
|
+
.set({ month: intValue })
|
|
147
|
+
.plus({ month: monthToAdd });
|
|
148
|
+
return tDate;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
return normalizeDate(DateTime.utc()).set({ year: firstMonthYear }).plus(monthToAdd);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
console.log('casting error', e);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
//first month of current year ... default
|
|
159
|
+
return normalizeDate(DateTime.utc())
|
|
160
|
+
.set({ month: 1, year: firstMonthYear })
|
|
161
|
+
.plus({ month: monthToAdd });
|
|
162
|
+
};
|
|
163
|
+
const validDay = (d) => {
|
|
164
|
+
const today = luxon.utc();
|
|
165
|
+
const m = luxon.local(d.year, d.month, d.day);
|
|
166
|
+
if (m < today) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
return d.day <= m.endOf('month').day;
|
|
170
|
+
};
|
|
171
|
+
export const defaultWeekendLabel = 'Weekend';
|
|
172
|
+
export const defaultWeekdayLabels = {
|
|
173
|
+
1: 'Mo',
|
|
174
|
+
2: 'Tu',
|
|
175
|
+
3: 'We',
|
|
176
|
+
4: 'Th',
|
|
177
|
+
5: 'Fr',
|
|
178
|
+
6: 'Sa',
|
|
179
|
+
7: 'Su',
|
|
180
|
+
};
|
|
181
|
+
export const defaultMonthLabels = {
|
|
182
|
+
1: 'Jan',
|
|
183
|
+
2: 'Feb',
|
|
184
|
+
3: 'Mar',
|
|
185
|
+
4: 'Apr',
|
|
186
|
+
5: 'May',
|
|
187
|
+
6: 'Jun',
|
|
188
|
+
7: 'Jul',
|
|
189
|
+
8: 'Aug',
|
|
190
|
+
9: 'Sep',
|
|
191
|
+
10: 'Oct',
|
|
192
|
+
11: 'Nov',
|
|
193
|
+
12: 'Dec',
|
|
194
|
+
};
|
|
195
|
+
export const defaultMonthHeaderFormat = '{{month}} / {{year}}';
|
|
196
|
+
export class OccupationState {
|
|
197
|
+
iCalURL;
|
|
198
|
+
occupiedDays = $state({});
|
|
199
|
+
occupations = $state([]);
|
|
200
|
+
loading = $state(false);
|
|
201
|
+
debug = $state(false);
|
|
202
|
+
constructor(iCalURL, debug = false) {
|
|
203
|
+
this.debug = debug;
|
|
204
|
+
if (this.debug)
|
|
205
|
+
console.log('Constructing OState with CalUrl: ', iCalURL);
|
|
206
|
+
this.iCalURL = iCalURL;
|
|
207
|
+
//this.loadOccupations();
|
|
208
|
+
}
|
|
209
|
+
loadOccupations = async () => {
|
|
210
|
+
if (this.debug)
|
|
211
|
+
console.log('(Re)Loading Occupations');
|
|
212
|
+
this.loading = true;
|
|
213
|
+
if (this.iCalURL) {
|
|
214
|
+
const eventsResult = await getEvents(this.iCalURL, this.eventsIncomingCallback);
|
|
215
|
+
this.loading = false;
|
|
216
|
+
return !eventsResult.error;
|
|
217
|
+
}
|
|
218
|
+
return false;
|
|
219
|
+
};
|
|
220
|
+
eventsIncomingCallback = (o) => {
|
|
221
|
+
if (this.debug)
|
|
222
|
+
console.log('Occupation incoming: ', o);
|
|
223
|
+
this.occupations.push(o);
|
|
224
|
+
this.updateOccupiedDays(o);
|
|
225
|
+
};
|
|
226
|
+
dayKey = (d) => {
|
|
227
|
+
return `${d.year}-${d.month}-${d.day}`;
|
|
228
|
+
};
|
|
229
|
+
updateOccupiedDays = (o) => {
|
|
230
|
+
let startDate = o.arrival;
|
|
231
|
+
let endDate = o.leave;
|
|
232
|
+
if (o.arrival > o.leave) {
|
|
233
|
+
startDate = o.leave;
|
|
234
|
+
endDate = o.arrival;
|
|
235
|
+
}
|
|
236
|
+
let cDate = startDate;
|
|
237
|
+
while (cDate < endDate) {
|
|
238
|
+
const key = this.dayKey(cDate);
|
|
239
|
+
this.occupiedDays[key] = true;
|
|
240
|
+
cDate = cDate.plus({ days: 1 });
|
|
241
|
+
}
|
|
242
|
+
//console.log(this.occupiedDays);
|
|
243
|
+
};
|
|
244
|
+
firstFree = (maxFutureDate) => {
|
|
245
|
+
let day = normalizeDate();
|
|
246
|
+
while (this.dayOccupied(day) && day < maxFutureDate) {
|
|
247
|
+
day = day.plus({ day: 1 });
|
|
248
|
+
}
|
|
249
|
+
return day;
|
|
250
|
+
};
|
|
251
|
+
earliestRequestStart = (currentEnd) => {
|
|
252
|
+
if (!currentEnd)
|
|
253
|
+
return;
|
|
254
|
+
let day = normalizeDate(currentEnd).minus({ day: 1 });
|
|
255
|
+
while (day > normalizeDate() && !this.dayOccupied(day)) {
|
|
256
|
+
day = day.minus({ day: 1 });
|
|
257
|
+
}
|
|
258
|
+
return day;
|
|
259
|
+
};
|
|
260
|
+
latestRequestEnd = (maxFutureDate, currentStart) => {
|
|
261
|
+
if (!currentStart)
|
|
262
|
+
return;
|
|
263
|
+
let day = normalizeDate(currentStart);
|
|
264
|
+
while (day < maxFutureDate && !this.dayOccupied(day)) {
|
|
265
|
+
day = day.plus({ day: 1 });
|
|
266
|
+
}
|
|
267
|
+
return day;
|
|
268
|
+
};
|
|
269
|
+
calcAvailability = (search, maxFutureDate) => {
|
|
270
|
+
let av = search.reduce((acc, num) => {
|
|
271
|
+
acc[num] = null;
|
|
272
|
+
return acc;
|
|
273
|
+
}, {});
|
|
274
|
+
let foundFirst = false;
|
|
275
|
+
let firstDate;
|
|
276
|
+
let consecutive = 0;
|
|
277
|
+
let d = normalizeDate(luxon.utc());
|
|
278
|
+
while (d <= maxFutureDate) {
|
|
279
|
+
const key = `${d.year}-${d.month}-${d.day}`;
|
|
280
|
+
if (this.occupiedDays[key]) {
|
|
281
|
+
foundFirst = false;
|
|
282
|
+
consecutive = 0;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
if (foundFirst) {
|
|
286
|
+
consecutive++;
|
|
287
|
+
search.forEach((n) => {
|
|
288
|
+
if (consecutive >= n && av[n] == null) {
|
|
289
|
+
av[n] = firstDate;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
let foundAll = true;
|
|
293
|
+
search.forEach((num) => {
|
|
294
|
+
if (!av[num]) {
|
|
295
|
+
foundAll = false;
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
if (foundAll)
|
|
299
|
+
break;
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
foundFirst = true;
|
|
303
|
+
firstDate = d;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
d = d.plus({ day: 1 });
|
|
307
|
+
}
|
|
308
|
+
return av;
|
|
309
|
+
};
|
|
310
|
+
dayOccupied = (day) => {
|
|
311
|
+
const key = this.dayKey(day);
|
|
312
|
+
return this.occupiedDays[key] ?? false;
|
|
313
|
+
};
|
|
314
|
+
startingOccupation = (d) => {
|
|
315
|
+
const startOfDay = d.startOf('day');
|
|
316
|
+
const endOfDay = d.endOf('day');
|
|
317
|
+
return this.occupations.find((o) => o.arrival > startOfDay && o.arrival < endOfDay);
|
|
318
|
+
};
|
|
319
|
+
endingOccupation = (d) => {
|
|
320
|
+
const startOfDay = d.startOf('day');
|
|
321
|
+
const endOfDay = d.endOf('day');
|
|
322
|
+
return this.occupations.find((o) => o.leave > startOfDay && o.leave < endOfDay);
|
|
323
|
+
};
|
|
324
|
+
fullOccupation = (d) => {
|
|
325
|
+
const startOfDay = d.startOf('day');
|
|
326
|
+
const endOfDay = d.endOf('day');
|
|
327
|
+
return this.occupations.find((o) => o.arrival < startOfDay && o.leave > endOfDay);
|
|
328
|
+
};
|
|
329
|
+
validRequest = (from, to) => {
|
|
330
|
+
//TODO take min nights into account
|
|
331
|
+
const found = this.occupations.find((o) => o.arrival < to && o.leave > from);
|
|
332
|
+
return !found;
|
|
333
|
+
};
|
|
334
|
+
occupationStyle = (d, highlightWeekend = false, maxDate) => {
|
|
335
|
+
const valid = validDay(d);
|
|
336
|
+
if (!valid) {
|
|
337
|
+
return 'background-color: var(--occuplan-invalid-days-bg-color); color: var(--occuplan-invalid-days-font-color);';
|
|
338
|
+
}
|
|
339
|
+
const day = luxon.utc(d.year, d.month, d.day);
|
|
340
|
+
const outOfScope = day >= maxDate;
|
|
341
|
+
if (outOfScope) {
|
|
342
|
+
return 'background-color: var(--occuplan-invalid-days-bg-color); color: var(--occuplan-invalid-days-font-color);';
|
|
343
|
+
}
|
|
344
|
+
const o = this.fullOccupation(day);
|
|
345
|
+
const oStarts = this.startingOccupation(day);
|
|
346
|
+
const oEnds = this.endingOccupation(day);
|
|
347
|
+
const isWeekend = [6, 7].includes(day.weekday);
|
|
348
|
+
if (o) {
|
|
349
|
+
const f = occupationTypeFormattingByOccupation(o);
|
|
350
|
+
if (highlightWeekend && isWeekend) {
|
|
351
|
+
return `
|
|
352
|
+
background: radial-gradient(var(--occuplan-weekend-bg-color), ${f.bgColor}, ${f.bgColor});
|
|
353
|
+
color: ${f.fontColor};
|
|
354
|
+
`;
|
|
355
|
+
}
|
|
356
|
+
return `
|
|
357
|
+
background-color: ${f.bgColor};
|
|
358
|
+
color: ${f.fontColor};
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
if (oEnds && oStarts) {
|
|
362
|
+
const sf = occupationTypeFormattingByOccupation(oStarts);
|
|
363
|
+
const ef = occupationTypeFormattingByOccupation(oEnds);
|
|
364
|
+
if (isWeekend && highlightWeekend) {
|
|
365
|
+
return `
|
|
366
|
+
color: ${ef.fontColor};
|
|
367
|
+
background: radial-gradient(var(--occuplan-weekend-bg-color), transparent, transparent), linear-gradient(90deg, ${ef.bgColor}, ${sf.bgColor});
|
|
368
|
+
`;
|
|
369
|
+
}
|
|
370
|
+
return `
|
|
371
|
+
background: linear-gradient(90deg, ${ef.bgColor}, ${sf.bgColor});
|
|
372
|
+
color: ${ef.fontColor};
|
|
373
|
+
`;
|
|
374
|
+
}
|
|
375
|
+
if (oStarts) {
|
|
376
|
+
const sf = occupationTypeFormattingByOccupation(oStarts);
|
|
377
|
+
if (isWeekend && highlightWeekend) {
|
|
378
|
+
return `
|
|
379
|
+
color: var(--occuplan-main-font-color);
|
|
380
|
+
background:
|
|
381
|
+
radial-gradient(var(--occuplan-weekend-bg-color), transparent, transparent), linear-gradient(90deg, var(--occuplan-main-bg-color), ${sf.bgColor});
|
|
382
|
+
`;
|
|
383
|
+
}
|
|
384
|
+
return `
|
|
385
|
+
background: linear-gradient(90deg, var(--occuplan-main-bg-color), ${sf.bgColor});
|
|
386
|
+
color: var(--occuplan-main-font-color);
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
if (oEnds) {
|
|
390
|
+
const ef = occupationTypeFormattingByOccupation(oEnds);
|
|
391
|
+
if (isWeekend && highlightWeekend) {
|
|
392
|
+
return `
|
|
393
|
+
background:
|
|
394
|
+
radial-gradient(var(--occuplan-weekend-bg-color), transparent, transparent), linear-gradient(90deg, ${ef.bgColor}, var(--occuplan-main-bg-color));
|
|
395
|
+
color: ${ef.fontColor};
|
|
396
|
+
`;
|
|
397
|
+
}
|
|
398
|
+
return `
|
|
399
|
+
background: linear-gradient(90deg, ${ef.bgColor}, var(--occuplan-main-bg-color));
|
|
400
|
+
color: ${ef.fontColor};
|
|
401
|
+
`;
|
|
402
|
+
}
|
|
403
|
+
if (isWeekend && highlightWeekend) {
|
|
404
|
+
return `
|
|
405
|
+
background: radial-gradient(var(--occuplan-weekend-bg-color), var(--occuplan-main-bg-color), var(--occuplan-main-bg-color));
|
|
406
|
+
color: var(--occuplan-main-font-color);
|
|
407
|
+
`;
|
|
408
|
+
}
|
|
409
|
+
return `
|
|
410
|
+
background-color: var(--occuplan-main-bg-color);
|
|
411
|
+
color: var(--occuplan-main-font-color);
|
|
412
|
+
`;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
export const getOccupationState = (url, debug = false) => {
|
|
416
|
+
if (debug)
|
|
417
|
+
console.log('Get OState /w url', url);
|
|
418
|
+
const stateID = `i-${url}-${OCCUPATION_STATE}`;
|
|
419
|
+
let _instance = getContext(stateID);
|
|
420
|
+
if (_instance)
|
|
421
|
+
return _instance;
|
|
422
|
+
setContext(stateID, new OccupationState(url, debug));
|
|
423
|
+
return getContext(stateID);
|
|
424
|
+
};
|
package/dist/svg/LogoSVG.svelte
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -361,7 +361,7 @@ export interface PageProps {
|
|
|
361
361
|
header?: string;
|
|
362
362
|
showFooter?: boolean;
|
|
363
363
|
footerRef?: string;
|
|
364
|
-
isToS?:
|
|
364
|
+
isToS?: boolean;
|
|
365
365
|
fixedHamburger?: boolean;
|
|
366
366
|
navbarOverHamburger?: boolean;
|
|
367
367
|
disableLinks?: boolean;
|
|
@@ -398,7 +398,7 @@ export interface I18nFacade {
|
|
|
398
398
|
calendarTranslation?: OccuplanTranslations;
|
|
399
399
|
translateFunc?: (ref: string) => string;
|
|
400
400
|
translateWithLangFunc?: (ref: string, lang: string) => string;
|
|
401
|
-
formatFunc?: (formatter: string, props: Record<string,
|
|
401
|
+
formatFunc?: (formatter: string, props: Record<string, unknown>) => string;
|
|
402
402
|
formatMoneyFunc?: (d: number) => string;
|
|
403
403
|
formatDateFunc?: (d: DateTime | string) => string;
|
|
404
404
|
updateCurrentLang?: (lang: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accomadesc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"!dist/**/*.test.*",
|
|
@@ -29,18 +29,24 @@
|
|
|
29
29
|
"@sveltejs/kit": "^2.50.0",
|
|
30
30
|
"@sveltejs/package": "^2.5.7",
|
|
31
31
|
"@sveltejs/vite-plugin-svelte": "^5.1.1",
|
|
32
|
+
"@testing-library/dom": "^10.4.1",
|
|
33
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
34
|
+
"@testing-library/svelte": "^5.3.1",
|
|
32
35
|
"@types/luxon": "^3.7.1",
|
|
36
|
+
"@types/node": "^25.0.9",
|
|
37
|
+
"@vitest/ui": "^4.0.17",
|
|
33
38
|
"gdpr-cooco-banner": "^0.0.13",
|
|
39
|
+
"jsdom": "^27.4.0",
|
|
34
40
|
"prettier": "^3.8.0",
|
|
35
41
|
"prettier-plugin-svelte": "^3.4.1",
|
|
36
42
|
"publint": "^0.3.16",
|
|
37
|
-
"svelte": "^5.
|
|
43
|
+
"svelte": "^5.47.0",
|
|
38
44
|
"svelte-check": "^4.3.5",
|
|
39
45
|
"typescript": "^5.9.3",
|
|
40
|
-
"vite": "^6.4.1"
|
|
46
|
+
"vite": "^6.4.1",
|
|
47
|
+
"vitest": "^4.0.17"
|
|
41
48
|
},
|
|
42
49
|
"dependencies": {
|
|
43
|
-
"@dinero.js/currencies": "2.0.0-alpha.14",
|
|
44
50
|
"@fontsource/raleway": "^5.2.8",
|
|
45
51
|
"@twicpics/components": "^0.31.4",
|
|
46
52
|
"@types/leaflet": "^1.9.21",
|