@sprucelabs/spruce-calendar-components 29.0.4 → 29.0.6

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 (43) hide show
  1. package/build/.spruce/errors/errors.types.d.ts +12 -12
  2. package/build/.spruce/errors/options.types.d.ts +2 -2
  3. package/build/.spruce/schemas/schemas.types.d.ts +2602 -3152
  4. package/build/.spruce/schemas/schemas.types.js +3 -0
  5. package/build/__tests__/support/CalendarToolBeltStateMachineTestFactory.js +11 -13
  6. package/build/__tests__/support/SpyEventManager.js +1 -1
  7. package/build/__tests__/support/SpyPeopleManager.js +4 -4
  8. package/build/__tests__/support/SpyRemoteEventStore.js +4 -4
  9. package/build/__tests__/support/utilities/calendarAssert.js +2 -1
  10. package/build/__tests__/support/utilities/calendarSkillAssert.js +5 -4
  11. package/build/calendar/Calendar.vc.js +17 -18
  12. package/build/calendar/CalendarEventManager.js +42 -49
  13. package/build/calendar/CalendarPeopleManager.js +12 -15
  14. package/build/calendar/CalendarPersister.js +9 -12
  15. package/build/constants.js +2 -1
  16. package/build/errors/SpruceError.js +1 -1
  17. package/build/esm/.spruce/errors/errors.types.d.ts +12 -12
  18. package/build/esm/.spruce/errors/options.types.d.ts +2 -2
  19. package/build/esm/.spruce/schemas/schemas.types.d.ts +2602 -3152
  20. package/build/esm/.spruce/schemas/schemas.types.js +3 -0
  21. package/build/root/Root.svc.js +36 -49
  22. package/build/stores/RemoteEventStore.js +13 -18
  23. package/build/stores/RemotePreferencesStore.js +4 -10
  24. package/build/toolBelt/CalendarToolRegistrar.js +12 -8
  25. package/build/toolBelt/CalendarToolTestFactory.js +1 -1
  26. package/build/toolBelt/states/AbstractCalendarEventToolBeltState.js +20 -20
  27. package/build/toolBelt/states/PrerequisitesToolBeltState.js +21 -24
  28. package/build/toolBelt/states/RootToolBeltState.js +19 -22
  29. package/build/toolBelt/states/UniversalEventToolBeltState.js +4 -1
  30. package/build/toolBelt/states/makeEventTyped.js +2 -1
  31. package/build/tools/CalendarSelectTool.vc.js +4 -7
  32. package/build/tools/EventDateTimeTool.vc.js +6 -10
  33. package/build/tools/EventDurationTool.vc.js +4 -7
  34. package/build/tools/EventRepeatingTool.vc.js +3 -7
  35. package/build/tools/EventTitleTool.vc.js +5 -8
  36. package/build/tools/PersonSelectTool.vc.js +8 -11
  37. package/build/utilities/draftGenerator.js +1 -1
  38. package/build/viewControllers/DateSelectCard.vc.js +2 -5
  39. package/build/viewControllers/EventControlsCard.vc.js +5 -9
  40. package/build/viewControllers/RepeatingControlsList.vc.js +54 -44
  41. package/build/viewControllers/SelectUpdateRepeatingStrategyCard.vc.js +4 -7
  42. package/build/viewControllers/UniversalCalendarEvent.vc.js +1 -1
  43. package/package.json +1 -1
@@ -2,19 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
4
4
  class RepeatingControlsListViewController extends heartwood_view_controllers_1.AbstractViewController {
5
- static id = 'repeating-controls-list';
6
- listVc;
7
- repeating = {};
8
- calendarVc;
9
- didChangeRepeating;
10
5
  constructor(options) {
11
6
  super(options);
7
+ this.repeating = {};
12
8
  const { repeating, didChangeRepeating } = options;
13
- this.repeating = repeating ?? {};
14
- if (repeating?.repeatsUntil) {
9
+ this.repeating = repeating !== null && repeating !== void 0 ? repeating : {};
10
+ if (repeating === null || repeating === void 0 ? void 0 : repeating.repeatsUntil) {
15
11
  this.repeating.repeatAmount = 'until';
16
12
  }
17
- else if (repeating?.occurrences) {
13
+ else if (repeating === null || repeating === void 0 ? void 0 : repeating.occurrences) {
18
14
  this.repeating.repeatAmount = 'after';
19
15
  }
20
16
  this.didChangeRepeating = didChangeRepeating;
@@ -37,6 +33,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
37
33
  }
38
34
  }
39
35
  renderRepeatRow() {
36
+ var _a, _b;
40
37
  const cells = [
41
38
  {
42
39
  selectInput: {
@@ -47,10 +44,11 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
47
44
  { label: 'Monthly', value: 'monthly' },
48
45
  ],
49
46
  name: 'repeats',
50
- value: this.repeating?.repeats ?? 'doesntRepeat',
47
+ value: (_b = (_a = this.repeating) === null || _a === void 0 ? void 0 : _a.repeats) !== null && _b !== void 0 ? _b : 'doesntRepeat',
51
48
  onChange: (value) => {
49
+ var _a;
52
50
  this.handleRepeatsChange(value);
53
- this.didChangeRepeating?.({ ...this.repeating });
51
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, { ...this.repeating });
54
52
  },
55
53
  },
56
54
  },
@@ -83,6 +81,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
83
81
  return rows;
84
82
  }
85
83
  renderRepeatEveryRow() {
84
+ var _a, _b;
86
85
  return {
87
86
  id: 'repeatEveryRow',
88
87
  height: 'content',
@@ -95,12 +94,13 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
95
94
  {
96
95
  textInput: {
97
96
  name: 'interval',
98
- value: this.repeating?.interval
99
- ? `${this.repeating?.interval}`
97
+ value: ((_a = this.repeating) === null || _a === void 0 ? void 0 : _a.interval)
98
+ ? `${(_b = this.repeating) === null || _b === void 0 ? void 0 : _b.interval}`
100
99
  : '1',
101
100
  onChange: async (value) => {
101
+ var _a;
102
102
  this.repeating.interval = value;
103
- this.didChangeRepeating?.(this.repeating);
103
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
104
104
  this.listVc.upsertRow('repeatEveryRow', this.renderRepeatEveryRow());
105
105
  },
106
106
  },
@@ -114,6 +114,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
114
114
  };
115
115
  }
116
116
  renderWeekDayRow() {
117
+ var _a;
117
118
  return {
118
119
  id: 'weekDayRow',
119
120
  height: 'content',
@@ -122,10 +123,11 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
122
123
  buttonBar: this.Controller('buttonBar', {
123
124
  shouldAllowMultiSelect: true,
124
125
  onSelectionChange: (value) => {
126
+ var _a;
125
127
  this.repeating.daysOfWeek = value;
126
- this.didChangeRepeating?.(this.repeating);
128
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
127
129
  },
128
- selected: this.repeating.daysOfWeek ?? [],
130
+ selected: (_a = this.repeating.daysOfWeek) !== null && _a !== void 0 ? _a : [],
129
131
  buttons: [
130
132
  {
131
133
  id: 'sun',
@@ -162,17 +164,19 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
162
164
  };
163
165
  }
164
166
  renderCalendarRow() {
167
+ var _a;
165
168
  return {
166
169
  id: 'calendarRow',
167
170
  height: 'content',
168
171
  cells: [
169
172
  {
170
- calendar: this.calendarVc?.render(),
173
+ calendar: (_a = this.calendarVc) === null || _a === void 0 ? void 0 : _a.render(),
171
174
  },
172
175
  ],
173
176
  };
174
177
  }
175
178
  renderRepeatAmountRow() {
179
+ var _a, _b, _c, _d, _e, _f, _g, _h;
176
180
  const cells = [
177
181
  {
178
182
  selectInput: {
@@ -182,43 +186,46 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
182
186
  { label: 'For', value: 'after' },
183
187
  ],
184
188
  name: 'repeatAmount',
185
- value: this.repeating?.repeatAmount ?? 'forever',
189
+ value: (_b = (_a = this.repeating) === null || _a === void 0 ? void 0 : _a.repeatAmount) !== null && _b !== void 0 ? _b : 'forever',
186
190
  onChange: (value) => {
191
+ var _a;
187
192
  this.handleRepeatAmountChange(value);
188
- this.didChangeRepeating?.(this.repeating);
193
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
189
194
  },
190
195
  },
191
196
  },
192
197
  ];
193
- if (this.repeating?.repeatAmount === 'until') {
198
+ if (((_c = this.repeating) === null || _c === void 0 ? void 0 : _c.repeatAmount) === 'until') {
194
199
  cells.push({
195
200
  id: 'repeatsUntil',
196
201
  dateInput: {
197
202
  name: 'repeatsUntil',
198
203
  label: ``,
199
- value: this.repeating?.repeatsUntil
200
- ? `${this.repeating?.repeatsUntil}`
204
+ value: ((_d = this.repeating) === null || _d === void 0 ? void 0 : _d.repeatsUntil)
205
+ ? `${(_e = this.repeating) === null || _e === void 0 ? void 0 : _e.repeatsUntil}`
201
206
  : undefined,
202
207
  onChange: (value) => {
208
+ var _a;
203
209
  this.repeating.repeatsUntil =
204
210
  this.dates.getEndOfDay(value);
205
- this.didChangeRepeating?.(this.repeating);
211
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
206
212
  },
207
213
  },
208
214
  });
209
215
  }
210
- else if (this.repeating?.repeatAmount === 'after') {
216
+ else if (((_f = this.repeating) === null || _f === void 0 ? void 0 : _f.repeatAmount) === 'after') {
211
217
  cells.push({
212
218
  id: 'occurrences',
213
219
  textInput: {
214
220
  name: 'occurrences',
215
221
  label: ``,
216
- value: this.repeating?.occurrences
217
- ? `${this.repeating?.occurrences}`
222
+ value: ((_g = this.repeating) === null || _g === void 0 ? void 0 : _g.occurrences)
223
+ ? `${(_h = this.repeating) === null || _h === void 0 ? void 0 : _h.occurrences}`
218
224
  : undefined,
219
225
  onChange: (value) => {
226
+ var _a;
220
227
  this.repeating.occurrences = value;
221
- this.didChangeRepeating?.(this.repeating);
228
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
222
229
  this.listVc.upsertRow('repeatAmountRow', this.renderRepeatAmountRow());
223
230
  },
224
231
  },
@@ -278,12 +285,13 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
278
285
  this.triggerRender();
279
286
  }
280
287
  mapFieldRepeatSuffix(value) {
288
+ var _a, _b, _c;
281
289
  switch (value) {
282
290
  case 'daily':
283
291
  if (!this.repeating || !this.repeating.interval) {
284
292
  return 'Day(s)';
285
293
  }
286
- else if (this.repeating?.interval > 1) {
294
+ else if (((_a = this.repeating) === null || _a === void 0 ? void 0 : _a.interval) > 1) {
287
295
  return 'Days';
288
296
  }
289
297
  return 'Day';
@@ -291,7 +299,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
291
299
  if (!this.repeating || !this.repeating.interval) {
292
300
  return 'Week(s)';
293
301
  }
294
- else if (this.repeating?.interval > 1) {
302
+ else if (((_b = this.repeating) === null || _b === void 0 ? void 0 : _b.interval) > 1) {
295
303
  return 'Weeks';
296
304
  }
297
305
  return 'Week';
@@ -299,7 +307,7 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
299
307
  if (!this.repeating || !this.repeating.interval) {
300
308
  return 'Month(s)';
301
309
  }
302
- else if (this.repeating?.interval > 1) {
310
+ else if (((_c = this.repeating) === null || _c === void 0 ? void 0 : _c.interval) > 1) {
303
311
  return 'Months';
304
312
  }
305
313
  return 'Month';
@@ -308,15 +316,17 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
308
316
  }
309
317
  }
310
318
  mapFieldRepeatAfterSuffix() {
319
+ var _a;
311
320
  if (!this.repeating || !this.repeating.occurrences) {
312
321
  return 'time(s)';
313
322
  }
314
- else if (this.repeating?.occurrences > 1) {
323
+ else if (((_a = this.repeating) === null || _a === void 0 ? void 0 : _a.occurrences) > 1) {
315
324
  return 'times';
316
325
  }
317
326
  return 'time';
318
327
  }
319
328
  CalendarVc() {
329
+ var _a;
320
330
  let startDate = {};
321
331
  if (this.repeating.startDateTimeMs) {
322
332
  startDate = this.repeating.startDateTimeMs;
@@ -326,12 +336,13 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
326
336
  }
327
337
  return this.Controller('calendar', {
328
338
  onClickView: async (options) => {
339
+ var _a;
329
340
  if (options.dateTimeMs) {
330
341
  this.changeCalendarSelectedDate(options.dateTimeMs);
331
- this.didChangeRepeating?.(this.repeating);
342
+ (_a = this.didChangeRepeating) === null || _a === void 0 ? void 0 : _a.call(this, this.repeating);
332
343
  }
333
344
  },
334
- selectedDates: this.getSelectedDatesFromDate(startDate, this.repeating?.daysOfMonth),
345
+ selectedDates: this.getSelectedDatesFromDate(startDate, (_a = this.repeating) === null || _a === void 0 ? void 0 : _a.daysOfMonth),
335
346
  view: 'month',
336
347
  });
337
348
  }
@@ -353,13 +364,14 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
353
364
  this.repeating = { ...this.repeating, ...repeating };
354
365
  this.resetRows();
355
366
  if (repeating.startDateTimeMs) {
356
- this.setCalendarSelectedDatesFromDate(repeating.startDateTimeMs, repeating?.daysOfMonth);
367
+ this.setCalendarSelectedDatesFromDate(repeating.startDateTimeMs, repeating === null || repeating === void 0 ? void 0 : repeating.daysOfMonth);
357
368
  }
358
369
  }
359
370
  setCalendarSelectedDatesFromDate(dateTimeMs, daysOfMonth) {
371
+ var _a, _b;
360
372
  const selectedDates = this.getSelectedDatesFromDate(dateTimeMs, daysOfMonth);
361
- this.calendarVc?.setSelectedDates(selectedDates);
362
- this.calendarVc?.triggerRender();
373
+ (_a = this.calendarVc) === null || _a === void 0 ? void 0 : _a.setSelectedDates(selectedDates);
374
+ (_b = this.calendarVc) === null || _b === void 0 ? void 0 : _b.triggerRender();
363
375
  }
364
376
  getSelectedDatesFromDate(dateTimeMs, daysOfMonth) {
365
377
  const startDate = this.dates.splitDate(dateTimeMs);
@@ -374,25 +386,23 @@ class RepeatingControlsListViewController extends heartwood_view_controllers_1.A
374
386
  }
375
387
  }
376
388
  changeCalendarSelectedDate(dateTimeMs) {
389
+ var _a, _b, _c, _d, _e;
377
390
  const selectedDate = this.dates.splitDate(dateTimeMs);
378
- const match = this.calendarVc
379
- ?.getSelectedDates()
380
- .find((x) => x.day == selectedDate.day &&
391
+ const match = (_a = this.calendarVc) === null || _a === void 0 ? void 0 : _a.getSelectedDates().find((x) => x.day == selectedDate.day &&
381
392
  x.year == selectedDate.year &&
382
393
  x.month == selectedDate.month);
383
394
  if (match) {
384
- this.calendarVc?.deselectDate(selectedDate.year, selectedDate.month, selectedDate.day);
395
+ (_b = this.calendarVc) === null || _b === void 0 ? void 0 : _b.deselectDate(selectedDate.year, selectedDate.month, selectedDate.day);
385
396
  }
386
397
  else {
387
- this.calendarVc?.selectDate(selectedDate.year, selectedDate.month, selectedDate.day);
398
+ (_c = this.calendarVc) === null || _c === void 0 ? void 0 : _c.selectDate(selectedDate.year, selectedDate.month, selectedDate.day);
388
399
  }
389
- this.repeating.daysOfMonth = this.calendarVc
390
- ?.getSelectedDates()
391
- .map((s) => s.day);
392
- this.calendarVc?.triggerRender();
400
+ this.repeating.daysOfMonth = (_d = this.calendarVc) === null || _d === void 0 ? void 0 : _d.getSelectedDates().map((s) => s.day);
401
+ (_e = this.calendarVc) === null || _e === void 0 ? void 0 : _e.triggerRender();
393
402
  }
394
403
  render() {
395
404
  return this.listVc.render();
396
405
  }
397
406
  }
407
+ RepeatingControlsListViewController.id = 'repeating-controls-list';
398
408
  exports.default = RepeatingControlsListViewController;
@@ -4,11 +4,6 @@ const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-control
4
4
  const schema_1 = require("@sprucelabs/schema");
5
5
  const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils");
6
6
  class SelectUpdateRepeatingStrategyCardViewController extends heartwood_view_controllers_1.AbstractViewController {
7
- static id = 'select-update-repeating-strategy-card';
8
- cardVc;
9
- event;
10
- onSelectStrategy;
11
- action;
12
7
  constructor(options) {
13
8
  super(options);
14
9
  const { event, onSelectStrategy, action } = (0, schema_1.assertOptions)(options, [
@@ -17,17 +12,18 @@ class SelectUpdateRepeatingStrategyCardViewController extends heartwood_view_con
17
12
  ]);
18
13
  this.onSelectStrategy = onSelectStrategy;
19
14
  this.event = event;
20
- this.action = action ?? 'update';
15
+ this.action = action !== null && action !== void 0 ? action : 'update';
21
16
  this.cardVc = this.CardVc();
22
17
  }
23
18
  CardVc() {
19
+ var _a;
24
20
  const buttons = [
25
21
  {
26
22
  id: 'only-this-one',
27
23
  label: `${this.capitalizedAction()} only this event`,
28
24
  },
29
25
  ];
30
- if ((this.event.nthInRepeating ?? 0) > 0) {
26
+ if (((_a = this.event.nthInRepeating) !== null && _a !== void 0 ? _a : 0) > 0) {
31
27
  buttons.push({
32
28
  id: 'all-going-forward',
33
29
  label: `${this.capitalizedAction()} this and all going forward`,
@@ -92,6 +88,7 @@ class SelectUpdateRepeatingStrategyCardViewController extends heartwood_view_con
92
88
  return this.cardVc.render();
93
89
  }
94
90
  }
91
+ SelectUpdateRepeatingStrategyCardViewController.id = 'select-update-repeating-strategy-card';
95
92
  exports.default = SelectUpdateRepeatingStrategyCardViewController;
96
93
  function ordinal_suffix_of(i) {
97
94
  let j = i % 10, k = i % 100;
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const heartwood_view_controllers_1 = require("@sprucelabs/heartwood-view-controllers");
7
7
  const UniversalEventToolBeltState_1 = __importDefault(require("../toolBelt/states/UniversalEventToolBeltState"));
8
8
  class UniversalCalendarEventViewController extends heartwood_view_controllers_1.AbstractCalendarEventViewController {
9
- static id = 'universal-calendar-event';
10
9
  getToolBeltState() {
11
10
  const state = new UniversalEventToolBeltState_1.default();
12
11
  return state;
13
12
  }
14
13
  }
14
+ UniversalCalendarEventViewController.id = 'universal-calendar-event';
15
15
  exports.default = UniversalCalendarEventViewController;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-calendar-components",
3
3
  "description": "Calendar components for working with calendars and Sprucebot.",
4
- "version": "29.0.4",
4
+ "version": "29.0.6",
5
5
  "skill": {
6
6
  "namespace": "calendar"
7
7
  },