cronofy-elements 1.44.1 → 1.47.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 (42) hide show
  1. package/build/CronofyElements.v1.47.0.js +2 -0
  2. package/build/{CronofyElements.v1.44.1.js.LICENSE.txt → CronofyElements.v1.47.0.js.LICENSE.txt} +0 -0
  3. package/build/npm/CronofyElements.js +2 -2
  4. package/demo/date-time-picker.ejs +5 -32
  5. package/demo/rules.ejs +7 -1
  6. package/package.json +1 -1
  7. package/src/js/components/AvailabilityRules/AvailabilityRules.js +15 -1
  8. package/src/js/components/AvailabilityRules/CalendarSelector.js +1 -1
  9. package/src/js/components/AvailabilityRules/Calendars.js +1 -1
  10. package/src/js/components/AvailabilityRules/TimeZoneDisplay.js +13 -2
  11. package/src/js/components/AvailabilityRules/Wrapper.js +45 -34
  12. package/src/js/components/AvailabilityRules/scss/_base.buttons.scss +58 -0
  13. package/src/js/components/AvailabilityRules/scss/_base.theme.scss +4 -0
  14. package/src/js/components/AvailabilityRules/scss/_components.timezoneselector.scss +74 -0
  15. package/src/js/components/AvailabilityRules/scss/_generic.reset.scss +13 -0
  16. package/src/js/components/AvailabilityRules/scss/_settings.colours.scss +12 -0
  17. package/src/js/components/AvailabilityRules/scss/availabilityrules.scss +5 -0
  18. package/src/js/components/AvailabilityRules/utils/tz-utils.js +44 -0
  19. package/src/js/components/DateTimePicker/Calendar.js +1 -1
  20. package/src/js/components/DateTimePicker/CalendarHeader.js +1 -1
  21. package/src/js/components/DateTimePicker/Confirm.js +38 -2
  22. package/src/js/components/DateTimePicker/DateTimePicker.js +1 -4
  23. package/src/js/components/DateTimePicker/DayButton.js +1 -1
  24. package/src/js/components/DateTimePicker/Details.js +5 -2
  25. package/src/js/components/DateTimePicker/SequencedSlotButton.js +1 -1
  26. package/src/js/components/DateTimePicker/SlotButton.js +1 -1
  27. package/src/js/components/DateTimePicker/Wrapper.js +115 -38
  28. package/src/js/components/DateTimePicker/contexts/status-reducer.js +29 -8
  29. package/src/js/components/DateTimePicker/scss/_components.confirm.scss +10 -0
  30. package/src/js/components/DateTimePicker/utils/slots.js +23 -78
  31. package/src/js/components/{DateTimePicker → generic}/TimeZoneSelector.js +10 -16
  32. package/src/js/{components/DateTimePicker/contexts → contexts}/tz-context.js +0 -0
  33. package/src/js/helpers/init.DateTimePicker.js +17 -0
  34. package/src/js/{components/DateTimePicker/utils → helpers}/tz-list.js +0 -0
  35. package/tests/AvailabilityRules/__snapshots__/AvailabilityRules.test.js.snap +37 -6
  36. package/tests/DateTimePicker/SequencedSlotButton.test.js +1 -1
  37. package/tests/DateTimePicker/SlotButton.test.js +1 -1
  38. package/tests/DateTimePicker/contexts/status-reducer.test.js +180 -24
  39. package/tests/DateTimePicker/dummy-data.js +186 -1
  40. package/tests/DateTimePicker/utils.test.js +32 -3
  41. package/tests/components/TimezoneSelector.test.js +124 -0
  42. package/build/CronofyElements.v1.44.1.js +0 -2
@@ -125,7 +125,7 @@ exports[`Snapshot test of Availability Rules Elements renders AvailabilityRules
125
125
  }
126
126
 
127
127
  .emotion-1 {
128
- z-index: 2;
128
+ z-index: 5;
129
129
  position: relative;
130
130
  width: 100%;
131
131
  display: -webkit-box;
@@ -562,6 +562,7 @@ exports[`Snapshot test of Availability Rules Elements renders AvailabilityRules
562
562
  display: -ms-flexbox;
563
563
  display: flex;
564
564
  width: 100%;
565
+ padding-right: 1em;
565
566
  }
566
567
 
567
568
  @media (max-width:650px) {
@@ -571,6 +572,11 @@ exports[`Snapshot test of Availability Rules Elements renders AvailabilityRules
571
572
  }
572
573
 
573
574
  .emotion-58 {
575
+ padding: 0.3em 0.6em 0 0;
576
+ margin: 0;
577
+ }
578
+
579
+ .emotion-59 {
574
580
  -webkit-appearance: none;
575
581
  -moz-appearance: none;
576
582
  appearance: none;
@@ -598,7 +604,7 @@ exports[`Snapshot test of Availability Rules Elements renders AvailabilityRules
598
604
  }
599
605
 
600
606
  <div
601
- class="PREFIX emotion-0"
607
+ class="PREFIX AR emotion-0"
602
608
  >
603
609
  <div
604
610
  class="PREFIX__calendars emotion-1"
@@ -999,12 +1005,37 @@ exports[`Snapshot test of Availability Rules Elements renders AvailabilityRules
999
1005
  <div
1000
1006
  class="PREFIX__timezone emotion-57"
1001
1007
  >
1002
- Time Zone
1003
- :
1004
- London
1008
+ <p
1009
+ class="emotion-58"
1010
+ >
1011
+ Time Zone
1012
+ </p>
1013
+ <div
1014
+ class="PREFIX__timezone-selector AR__timezone-selector"
1015
+ >
1016
+ <button
1017
+ aria-expanded="false"
1018
+ aria-haspopup="listbox"
1019
+ aria-label="Choose a timezone"
1020
+ class="PREFIX__timezone-selector--button AR__timezone-selector--button"
1021
+ id="timezone-button"
1022
+ type="button"
1023
+ >
1024
+ London
1025
+ <svg
1026
+ aria-hidden="true"
1027
+ class="PREFIX__timezone-selector--icon AR__timezone-selector--icon"
1028
+ viewBox="0 0 13 7"
1029
+ >
1030
+ <path
1031
+ d="M.809 1.315L2.124 0l4.383 4.342L10.876.013l1.315 1.302L6.507 7l-.939-.938z"
1032
+ />
1033
+ </svg>
1034
+ </button>
1035
+ </div>
1005
1036
  </div>
1006
1037
  <button
1007
- class="PREFIX__submit emotion-58"
1038
+ class="PREFIX__submit emotion-59"
1008
1039
  type="button"
1009
1040
  >
1010
1041
  Save new rules
@@ -7,7 +7,7 @@ import SequencedSlotButton from "../../src/js/components/DateTimePicker/Sequence
7
7
  import { I18nProvider } from "../../src/js/contexts/i18n-context";
8
8
  import { ThemeProvider } from "../../src/js/components/DateTimePicker/contexts/theme-context";
9
9
  import { StatusProvider } from "../../src/js/components/DateTimePicker/contexts/status-context";
10
- import { TzProvider } from "../../src/js/components/DateTimePicker/contexts/tz-context";
10
+ import { TzProvider } from "../../src/js/contexts/tz-context";
11
11
 
12
12
  const wrapper = ({ children, status }) => (
13
13
  <ThemeProvider options={{ name: "DTP" }}>
@@ -7,7 +7,7 @@ import SlotButton from "../../src/js/components/DateTimePicker/SlotButton";
7
7
  import { I18nProvider } from "../../src/js/contexts/i18n-context";
8
8
  import { ThemeProvider } from "../../src/js/components/DateTimePicker/contexts/theme-context";
9
9
  import { StatusProvider } from "../../src/js/components/DateTimePicker/contexts/status-context";
10
- import { TzProvider } from "../../src/js/components/DateTimePicker/contexts/tz-context";
10
+ import { TzProvider } from "../../src/js/contexts/tz-context";
11
11
 
12
12
  const wrapper = ({ children, status }) => (
13
13
  <ThemeProvider options={{ name: "DTP" }}>
@@ -9,8 +9,9 @@ import {
9
9
  testSequencedSlotsArray,
10
10
  testDaySlots,
11
11
  testDaySequencedSlots,
12
- testSequencedSlotsAObject,
12
+ testSequencedSlotsObject,
13
13
  testQuery,
14
+ testSequencedQuery,
14
15
  } from "../dummy-data";
15
16
 
16
17
  import {
@@ -154,9 +155,39 @@ describe("Date Time Picker status reducer", () => {
154
155
  const callbackSpy = jest.spyOn(startingState, "callback");
155
156
  const oldState = {
156
157
  ...startingState,
157
- monthsLoading: [
158
- { month: "2021-09", loading: true },
159
- { month: "2021-10", loading: true },
158
+ months: [
159
+ {
160
+ month: "2021-09",
161
+ current: true,
162
+ loading: false,
163
+ query: {
164
+ max_results: 512,
165
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
166
+ query_periods: [
167
+ {
168
+ start: "2021-09-29T08:00:00Z",
169
+ end: "2021-09-30T22:59:00Z",
170
+ },
171
+ ],
172
+ required_duration: { minutes: 60 },
173
+ },
174
+ },
175
+ {
176
+ month: "2021-10",
177
+ current: false,
178
+ loading: true,
179
+ query: {
180
+ max_results: 512,
181
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
182
+ query_periods: [
183
+ {
184
+ start: "2021-09-30T23:00:00Z",
185
+ end: "2021-10-04T18:00:00Z",
186
+ },
187
+ ],
188
+ required_duration: { minutes: 60 },
189
+ },
190
+ },
160
191
  ],
161
192
  };
162
193
  const error = {
@@ -191,23 +222,47 @@ describe("Date Time Picker status reducer", () => {
191
222
  },
192
223
  };
193
224
 
194
- const newMonthsLoading = [
225
+ const expectedResultForMonths = [
195
226
  {
196
227
  month: "2021-09",
197
- loading: true,
228
+ current: true,
229
+ loading: false,
230
+ query: {
231
+ max_results: 512,
232
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
233
+ query_periods: [
234
+ {
235
+ start: "2021-09-29T08:00:00Z",
236
+ end: "2021-09-30T22:59:00Z",
237
+ },
238
+ ],
239
+ required_duration: { minutes: 60 },
240
+ },
198
241
  },
199
242
  {
200
243
  month: "2021-10",
244
+ current: false,
201
245
  loading: false,
246
+ query: {
247
+ max_results: 512,
248
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
249
+ query_periods: [
250
+ {
251
+ start: "2021-09-30T23:00:00Z",
252
+ end: "2021-10-04T18:00:00Z",
253
+ },
254
+ ],
255
+ required_duration: { minutes: 60 },
256
+ },
202
257
  },
203
258
  ];
204
259
 
205
- delete oldState.monthsLoading;
260
+ delete oldState.months;
206
261
 
207
- const { monthsLoading, ...newState } = result;
262
+ const { months, ...newState } = result;
208
263
 
209
264
  // These values have been updated
210
- expect(monthsLoading).toStrictEqual(newMonthsLoading);
265
+ expect(months).toStrictEqual(expectedResultForMonths);
211
266
  expect(callbackSpy).toHaveBeenCalled();
212
267
  expect(callbackSpy).toHaveBeenCalledWith(expectedNotification);
213
268
  // All other values are unchanged
@@ -271,14 +326,38 @@ describe("Date Time Picker status reducer", () => {
271
326
  tzid: "Europe/London",
272
327
  });
273
328
 
274
- const newMonthsLoading = [
329
+ const expectedResultForMonths = [
275
330
  {
276
331
  month: "2021-09",
332
+ current: true,
277
333
  loading: false,
334
+ query: {
335
+ max_results: 512,
336
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
337
+ query_periods: [
338
+ {
339
+ start: "2021-09-29T08:00:00Z",
340
+ end: "2021-09-30T22:59:00Z",
341
+ },
342
+ ],
343
+ required_duration: { minutes: 60 },
344
+ },
278
345
  },
279
346
  {
280
347
  month: "2021-10",
348
+ current: false,
281
349
  loading: true,
350
+ query: {
351
+ max_results: 512,
352
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
353
+ query_periods: [
354
+ {
355
+ start: "2021-09-30T23:00:00Z",
356
+ end: "2021-10-04T18:00:00Z",
357
+ },
358
+ ],
359
+ required_duration: { minutes: 60 },
360
+ },
282
361
  },
283
362
  ];
284
363
 
@@ -286,14 +365,14 @@ describe("Date Time Picker status reducer", () => {
286
365
  delete oldState.availableDays;
287
366
  delete oldState.slotFetchCount;
288
367
  delete oldState.slotInjectionPoint;
289
- delete oldState.monthsLoading;
368
+ delete oldState.months;
290
369
 
291
370
  const {
292
371
  slots,
293
372
  availableDays,
294
373
  slotFetchCount,
295
374
  slotInjectionPoint,
296
- monthsLoading,
375
+ months,
297
376
  ...newState
298
377
  } = result;
299
378
 
@@ -307,7 +386,7 @@ describe("Date Time Picker status reducer", () => {
307
386
  ]);
308
387
  expect(slotFetchCount).toBe(1);
309
388
  expect(slotInjectionPoint).toBe("2021-09-29");
310
- expect(monthsLoading).toStrictEqual(newMonthsLoading);
389
+ expect(months).toStrictEqual(expectedResultForMonths);
311
390
 
312
391
  // All other values are unchanged
313
392
  expect(newState).toStrictEqual(oldState);
@@ -396,26 +475,74 @@ describe("Date Time Picker status reducer", () => {
396
475
  ...startingState,
397
476
  slots: testSlotsObjectPartial,
398
477
  availableDays: ["2021-09-29", "2021-09-30"],
399
- monthsLoading: [
478
+ months: [
400
479
  {
401
480
  month: "2021-09",
481
+ current: true,
402
482
  loading: false,
483
+ query: {
484
+ max_results: 512,
485
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
486
+ query_periods: [
487
+ {
488
+ start: "2021-09-29T08:00:00Z",
489
+ end: "2021-09-30T22:59:00Z",
490
+ },
491
+ ],
492
+ required_duration: { minutes: 60 },
493
+ },
403
494
  },
404
495
  {
405
496
  month: "2021-10",
497
+ current: false,
406
498
  loading: true,
499
+ query: {
500
+ max_results: 512,
501
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
502
+ query_periods: [
503
+ {
504
+ start: "2021-09-30T23:00:00Z",
505
+ end: "2021-10-04T18:00:00Z",
506
+ },
507
+ ],
508
+ required_duration: { minutes: 60 },
509
+ },
407
510
  },
408
511
  ],
409
512
  };
410
513
 
411
- const newMonthsLoading = [
514
+ const expectedResultForMonths = [
412
515
  {
413
516
  month: "2021-09",
517
+ current: true,
414
518
  loading: false,
519
+ query: {
520
+ max_results: 512,
521
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
522
+ query_periods: [
523
+ {
524
+ start: "2021-09-29T08:00:00Z",
525
+ end: "2021-09-30T22:59:00Z",
526
+ },
527
+ ],
528
+ required_duration: { minutes: 60 },
529
+ },
415
530
  },
416
531
  {
417
532
  month: "2021-10",
533
+ current: false,
418
534
  loading: false,
535
+ query: {
536
+ max_results: 512,
537
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
538
+ query_periods: [
539
+ {
540
+ start: "2021-09-30T23:00:00Z",
541
+ end: "2021-10-04T18:00:00Z",
542
+ },
543
+ ],
544
+ required_duration: { minutes: 60 },
545
+ },
419
546
  },
420
547
  ];
421
548
 
@@ -430,14 +557,14 @@ describe("Date Time Picker status reducer", () => {
430
557
  delete oldState.slotFetchCount;
431
558
  delete oldState.slotInjectionPoint;
432
559
  delete oldState.availableDays;
433
- delete oldState.monthsLoading;
560
+ delete oldState.months;
434
561
 
435
562
  const {
436
563
  slots,
437
564
  slotFetchCount,
438
565
  slotInjectionPoint,
439
566
  availableDays,
440
- monthsLoading,
567
+ months,
441
568
  ...newState
442
569
  } = result;
443
570
 
@@ -450,7 +577,7 @@ describe("Date Time Picker status reducer", () => {
450
577
  "2021-10-01",
451
578
  "2021-10-04",
452
579
  ]);
453
- expect(monthsLoading).toStrictEqual(newMonthsLoading);
580
+ expect(months).toStrictEqual(expectedResultForMonths);
454
581
 
455
582
  expect(newState).toStrictEqual(oldState);
456
583
  });
@@ -458,6 +585,7 @@ describe("Date Time Picker status reducer", () => {
458
585
  it("sets sequenced slots", () => {
459
586
  const oldState = {
460
587
  ...startingState,
588
+ query: testSequencedQuery,
461
589
  slots: {},
462
590
  availableDays: [],
463
591
  slotFetchCount: 0,
@@ -472,14 +600,38 @@ describe("Date Time Picker status reducer", () => {
472
600
  tzid: "Europe/London",
473
601
  });
474
602
 
475
- const newMonthsLoading = [
603
+ const expectedResultForMonths = [
476
604
  {
477
605
  month: "2021-09",
606
+ current: true,
478
607
  loading: false,
608
+ query: {
609
+ max_results: 512,
610
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
611
+ query_periods: [
612
+ {
613
+ start: "2021-09-29T08:00:00Z",
614
+ end: "2021-09-30T22:59:00Z",
615
+ },
616
+ ],
617
+ required_duration: { minutes: 60 },
618
+ },
479
619
  },
480
620
  {
481
621
  month: "2021-10",
622
+ current: false,
482
623
  loading: true,
624
+ query: {
625
+ max_results: 512,
626
+ participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
627
+ query_periods: [
628
+ {
629
+ start: "2021-09-30T23:00:00Z",
630
+ end: "2021-10-04T18:00:00Z",
631
+ },
632
+ ],
633
+ required_duration: { minutes: 60 },
634
+ },
483
635
  },
484
636
  ];
485
637
 
@@ -487,19 +639,19 @@ describe("Date Time Picker status reducer", () => {
487
639
  delete oldState.availableDays;
488
640
  delete oldState.slotFetchCount;
489
641
  delete oldState.slotInjectionPoint;
490
- delete oldState.monthsLoading;
642
+ delete oldState.months;
491
643
 
492
644
  const {
493
645
  slots,
494
646
  availableDays,
495
647
  slotFetchCount,
496
648
  slotInjectionPoint,
497
- monthsLoading,
649
+ months,
498
650
  ...newState
499
651
  } = result;
500
652
 
501
653
  // These values have been updated
502
- expect(slots).toStrictEqual(testSequencedSlotsAObject);
654
+ expect(slots).toStrictEqual(testSequencedSlotsObject);
503
655
  expect(availableDays).toStrictEqual([
504
656
  "2021-09-29",
505
657
  "2021-09-30",
@@ -508,7 +660,7 @@ describe("Date Time Picker status reducer", () => {
508
660
  ]);
509
661
  expect(slotFetchCount).toBe(1);
510
662
  expect(slotInjectionPoint).toBe("2021-09-29");
511
- expect(monthsLoading).toStrictEqual(newMonthsLoading);
663
+ expect(months).toStrictEqual(expectedResultForMonths);
512
664
 
513
665
  // All other values are unchanged
514
666
  expect(newState).toStrictEqual(oldState);
@@ -598,7 +750,7 @@ describe("Date Time Picker status reducer", () => {
598
750
  it("SELECT_DAY for sequenced slots", async () => {
599
751
  const oldState = {
600
752
  ...startingState,
601
- slots: testSequencedSlotsAObject,
753
+ slots: testSequencedSlotsObject,
602
754
  sequenced_availability: true,
603
755
  };
604
756
  const date = "2021-09-29";
@@ -672,6 +824,7 @@ describe("Date Time Picker status reducer", () => {
672
824
  {
673
825
  month: "2021-09",
674
826
  current: false,
827
+ loading: false,
675
828
  query: {
676
829
  max_results: 512,
677
830
  participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
@@ -687,6 +840,7 @@ describe("Date Time Picker status reducer", () => {
687
840
  {
688
841
  month: "2021-10",
689
842
  current: true,
843
+ loading: true,
690
844
  query: {
691
845
  max_results: 512,
692
846
  participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
@@ -732,6 +886,7 @@ describe("Date Time Picker status reducer", () => {
732
886
  {
733
887
  month: "2021-09",
734
888
  current: false,
889
+ loading: false,
735
890
  query: {
736
891
  max_results: 512,
737
892
  participants: [{ sub: "acc_5f35432b3f07d06753082354" }],
@@ -747,6 +902,7 @@ describe("Date Time Picker status reducer", () => {
747
902
  {
748
903
  month: "2021-10",
749
904
  current: true,
905
+ loading: true,
750
906
  query: {
751
907
  max_results: 512,
752
908
  participants: [{ sub: "acc_5f35432b3f07d06753082354" }],