accomadesc 0.3.31 → 0.3.33

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.
@@ -5,11 +5,12 @@
5
5
  import Notes from './basic/Notes.svelte';
6
6
  import Spinner from './basic/Spinner.svelte';
7
7
  import TextInput from './basic/TextInput.svelte';
8
- import { OCCUPATION_STATE, OccupationState } from './occuplan/state.svelte.js';
8
+ import { getOccupationState, OccupationState } from './occuplan/state.svelte.js';
9
9
  import OccuPlanPicker from './occuplan/OccuPlanPicker.svelte';
10
- import { slide } from 'svelte/transition';
10
+ import { fade } from 'svelte/transition';
11
11
  import type { DateTime } from 'luxon';
12
12
  import { randomID } from './names/gen.js';
13
+ import { format } from './helpers/format.ts';
13
14
 
14
15
  const {
15
16
  endpoint,
@@ -55,9 +56,7 @@
55
56
  let sending = $state(false);
56
57
  let disabled = $derived(preview || errored || successfullySent);
57
58
 
58
- const url = calUrl;
59
- const oStateID = `i-${url}-${OCCUPATION_STATE}`;
60
- let occupationState: OccupationState = $state(getContext(oStateID));
59
+ let occupationState: OccupationState = getOccupationState(calUrl);
61
60
  let invalid = $derived(
62
61
  occupationState && arrival && leave ? occupationState.validRequest(arrival, leave) : false,
63
62
  );
@@ -83,6 +82,20 @@
83
82
  inputDatesEngaged = false;
84
83
  };
85
84
 
85
+ let travelDates = $derived.by(() => {
86
+ if (arrival && leave) {
87
+ if (formatDateFunc) {
88
+ return `${formatDateFunc(arrival)} - ${formatDateFunc(leave)}`;
89
+ } else {
90
+ const formattedArrival = arrival.toFormat('yyyy-MM-dd');
91
+ const formattedLeave = leave.toFormat('yyyy-MM-dd');
92
+ return `${formattedArrival} - ${formattedLeave}`;
93
+ }
94
+ } else {
95
+ return '';
96
+ }
97
+ });
98
+
86
99
  const createRequest = async (e: SubmitEvent) => {
87
100
  sending = true;
88
101
  e.preventDefault();
@@ -113,7 +126,11 @@
113
126
  console.log('Error sending request', e);
114
127
  }
115
128
 
129
+ arrival = undefined;
130
+ leave = undefined;
131
+ inputDatesEngaged = false;
116
132
  sending = false;
133
+
117
134
  setTimeout(() => {
118
135
  errored = false;
119
136
  successfullySent = false;
@@ -161,8 +178,8 @@
161
178
  </label>
162
179
  <div class="input-wrapper" class:disabled>
163
180
  {#if inputDatesEngaged}
164
- <div transition:slide style="min-width: 32rem;" class="picker-wrapper">
165
- <OccuPlanPicker {arrival} {leave} {url} aborted={abortDateInput} {dateSelected} />
181
+ <div transition:fade style="min-width: 32rem;" class="picker-wrapper">
182
+ <OccuPlanPicker {arrival} {leave} url={calUrl} aborted={abortDateInput} {dateSelected} />
166
183
  </div>
167
184
  {/if}
168
185
  <div class="date-input-wrapper" id="engage-date-buttons">
@@ -172,9 +189,7 @@
172
189
  iconName="edit"
173
190
  size={1.8}
174
191
  clicked={engageDateInput}
175
- text={arrival && leave && formatDateFunc
176
- ? `${formatDateFunc(arrival)} - ${formatDateFunc(leave)}`
177
- : ''}
192
+ text={travelDates}
178
193
  />
179
194
  {#if arrival && leave}
180
195
  <Button iconName="delete" size={1.8} clicked={dateDeleted} />
@@ -243,9 +258,10 @@
243
258
  }
244
259
  }
245
260
  form {
261
+ position: relative;
246
262
  display: grid;
247
263
  grid-template-columns: [start] 1fr [gap-start] 0.5fr [gap-end] 3fr [end];
248
- row-gap: 0.5rem;
264
+ row-gap: 1rem;
249
265
 
250
266
  label {
251
267
  align-content: center;
@@ -272,6 +288,8 @@
272
288
  justify-content: flex-start;
273
289
  }
274
290
  div.picker-wrapper {
291
+ bottom: 2rem;
292
+ right: -3rem;
275
293
  position: absolute;
276
294
  z-index: 9999;
277
295
  background-color: var(--main-bg-color);
@@ -40,7 +40,7 @@
40
40
 
41
41
  width: 100%;
42
42
  max-width: 800px;
43
- min-height: 5rem;
43
+ min-height: 8rem;
44
44
  height: 100%;
45
45
 
46
46
  border: none;
@@ -62,7 +62,9 @@
62
62
  };
63
63
 
64
64
  let page: number = $state(0);
65
- let rfMonth: DateTime = $derived(realFirstMonth(firstMonth, numberOfMonth, page));
65
+ let rfMonth: DateTime = $derived(
66
+ realFirstMonth(firstMonth, DateTime.utc().get('year'), numberOfMonth, page),
67
+ );
66
68
 
67
69
  let currentMaxDate = $derived(rfMonth.plus({ month: numberOfMonth }));
68
70
 
@@ -74,6 +74,7 @@
74
74
  let rfMonth: DateTime = $derived(
75
75
  realFirstMonth(
76
76
  (arrival?.month ? arrival.month : minDate.month) as MonthNumbers,
77
+ arrival?.year ? arrival.year : minDate.year,
77
78
  numberOfMonth,
78
79
  page,
79
80
  ),
@@ -50,7 +50,9 @@
50
50
  let occupationState: OccupationState = getOccupationState(url, debug);
51
51
 
52
52
  let page: number = $state(0);
53
- let rfMonth: number | DateTime = $derived(realFirstMonth(firstMonth, numberOfMonth, page));
53
+ let rfMonth: number | DateTime = $derived(
54
+ realFirstMonth(firstMonth, DateTime.utc().get('year'), numberOfMonth, page),
55
+ );
54
56
 
55
57
  let currentMaxDate = $derived(rfMonth.plus({ month: numberOfMonth }));
56
58
 
@@ -30,7 +30,7 @@ export interface DayHelper {
30
30
  year: number;
31
31
  }
32
32
  export declare const firstMonthValid: (value: string | number) => boolean;
33
- export declare const realFirstMonth: (firstMonth: FirstMonth, numberOfMonth: number, page: number) => DateTime;
33
+ export declare const realFirstMonth: (firstMonth: FirstMonth, firstMonthYear: number, numberOfMonth: number, page: number) => DateTime;
34
34
  export interface OccuplanTranslations {
35
35
  arrivalLabel?: string;
36
36
  leaveLabel?: string;
@@ -75,16 +75,19 @@ export const firstMonthValid = (value) => {
75
75
  }
76
76
  return false;
77
77
  };
78
- export const realFirstMonth = (firstMonth, numberOfMonth, page) => {
78
+ export const realFirstMonth = (firstMonth, firstMonthYear, numberOfMonth, page) => {
79
79
  const monthToAdd = page * numberOfMonth;
80
80
  if (typeof firstMonth === 'number') {
81
81
  const intValue = firstMonth;
82
82
  if (intValue >= 1 && intValue <= 12) {
83
83
  const tDate = normalizeDate(DateTime.utc())
84
- .set({ month: intValue })
84
+ .set({ month: intValue, year: firstMonthYear })
85
85
  .plus({ month: monthToAdd });
86
86
  return tDate;
87
87
  }
88
+ else {
89
+ return normalizeDate(DateTime.utc()).plus(monthToAdd);
90
+ }
88
91
  }
89
92
  else if (typeof firstMonth === 'string' && firstMonth.length > 1) {
90
93
  //check + sign
@@ -94,10 +97,14 @@ export const realFirstMonth = (firstMonth, numberOfMonth, page) => {
94
97
  const intValue = parseInt(toParse);
95
98
  if (intValue >= 1 && intValue <= 12) {
96
99
  const tDate = normalizeDate(DateTime.utc())
100
+ .set({ year: firstMonthYear })
97
101
  .plus({ month: intValue })
98
102
  .plus({ month: monthToAdd });
99
103
  return tDate;
100
104
  }
105
+ else {
106
+ return normalizeDate(DateTime.utc()).plus(monthToAdd);
107
+ }
101
108
  }
102
109
  catch (e) {
103
110
  console.log('casting error', e);
@@ -110,10 +117,14 @@ export const realFirstMonth = (firstMonth, numberOfMonth, page) => {
110
117
  const intValue = parseInt(toParse);
111
118
  if (intValue >= 0 && intValue <= 12) {
112
119
  const tDate = normalizeDate(DateTime.utc())
120
+ .set({ year: firstMonthYear })
113
121
  .minus({ month: intValue })
114
122
  .plus({ month: monthToAdd });
115
123
  return tDate;
116
124
  }
125
+ else {
126
+ return normalizeDate(DateTime.utc()).plus(monthToAdd);
127
+ }
117
128
  }
118
129
  catch (e) {
119
130
  console.log('casting error', e);
@@ -125,7 +136,7 @@ export const realFirstMonth = (firstMonth, numberOfMonth, page) => {
125
136
  const intValue = parseInt(firstMonth);
126
137
  //current dynamic month
127
138
  if (intValue == 0) {
128
- return normalizeDate(DateTime.utc()).plus({ month: monthToAdd });
139
+ return normalizeDate(DateTime.utc()).set({ year: firstMonthYear }).plus({ month: monthToAdd });
129
140
  }
130
141
  //static month of current year
131
142
  if (intValue >= 1 && intValue <= 12) {
@@ -134,13 +145,16 @@ export const realFirstMonth = (firstMonth, numberOfMonth, page) => {
134
145
  .plus({ month: monthToAdd });
135
146
  return tDate;
136
147
  }
148
+ else {
149
+ return normalizeDate(DateTime.utc()).set({ year: firstMonthYear }).plus(monthToAdd);
150
+ }
137
151
  }
138
152
  catch (e) {
139
153
  console.log('casting error', e);
140
154
  }
141
155
  }
142
156
  //first month of current year ... default
143
- return normalizeDate(DateTime.utc()).set({ month: 1 }).plus({ month: monthToAdd });
157
+ return normalizeDate(DateTime.utc()).set({ month: 1, year: firstMonthYear }).plus({ month: monthToAdd });
144
158
  };
145
159
  const validDay = (d) => {
146
160
  const today = luxon.utc();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accomadesc",
3
- "version": "0.3.31",
3
+ "version": "0.3.33",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",
@@ -26,16 +26,16 @@
26
26
  "devDependencies": {
27
27
  "@sveltejs/adapter-auto": "^3.3.1",
28
28
  "@sveltejs/adapter-static": "^3.0.10",
29
- "@sveltejs/kit": "^2.47.3",
30
- "@sveltejs/package": "^2.5.4",
29
+ "@sveltejs/kit": "^2.49.0",
30
+ "@sveltejs/package": "^2.5.6",
31
31
  "@sveltejs/vite-plugin-svelte": "^5.1.1",
32
32
  "@types/luxon": "^3.7.1",
33
33
  "gdpr-cooco-banner": "^0.0.11",
34
34
  "prettier": "^3.6.2",
35
35
  "prettier-plugin-svelte": "^3.4.0",
36
36
  "publint": "^0.3.15",
37
- "svelte": "^5.41.4",
38
- "svelte-check": "^4.3.3",
37
+ "svelte": "^5.43.14",
38
+ "svelte-check": "^4.3.4",
39
39
  "typescript": "^5.9.3",
40
40
  "vite": "^6.4.1"
41
41
  },