@event-calendar/core 3.3.0 → 3.5.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.
package/README.md CHANGED
@@ -61,6 +61,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
61
61
  - [eventStartEditable](#eventstarteditable)
62
62
  - [eventTextColor](#eventtextcolor)
63
63
  - [eventTimeFormat](#eventtimeformat)
64
+ - [filterEventsWithResources](#filtereventswithresources)
64
65
  - [filterResourcesWithEvents](#filterresourceswithevents)
65
66
  - [firstDay](#firstday)
66
67
  - [flexibleSlotTimeLimits](#flexibleslottimelimits)
@@ -204,8 +205,8 @@ import '@event-calendar/core/index.css';
204
205
  ### Pre-built browser ready bundle
205
206
  Include the following lines of code in the `<head>` section of your page:
206
207
  ```html
207
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.3.0/event-calendar.min.css">
208
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.3.0/event-calendar.min.js"></script>
208
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.5.0/event-calendar.min.css">
209
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.5.0/event-calendar.min.js"></script>
209
210
  ```
210
211
 
211
212
  <details>
@@ -668,7 +669,7 @@ Determines whether the events on the calendar can be dragged and resized (both a
668
669
  If you don't need both, use the more specific [eventStartEditable](#eventstarteditable) and [eventDurationEditable](#eventdurationeditable) instead.
669
670
 
670
671
  ### events
671
- - Type `Array`
672
+ - Type `array`
672
673
  - Default `[]`
673
674
 
674
675
  Array of plain objects that will be parsed into [Event](#event-object) objects and displayed on the calendar.
@@ -804,11 +805,11 @@ This is currently an alias for the `eventBackgroundColor`.
804
805
 
805
806
  Defines the content that is rendered inside an event’s element.
806
807
 
807
- This value can be either a [Content](#content) or a function that returns content:
808
+ This value can be either a [Content](#content) or a function that returns content or `undefined`:
808
809
 
809
810
  ```js
810
811
  function (info) {
811
- // return Content
812
+ // return Content or undefined
812
813
  }
813
814
  ```
814
815
  `info` is an object with the following properties:
@@ -842,6 +843,8 @@ The current [View](#view-object) object
842
843
  </tr>
843
844
  </table>
844
845
 
846
+ In case the function returns `undefined`, the event will be rendered in the default way.
847
+
845
848
  ### eventDidMount
846
849
  - Type `function`
847
850
  - Default `undefined`
@@ -1504,6 +1507,12 @@ Sets the default text color for events on the calendar.
1504
1507
 
1505
1508
  You can use any of the CSS color formats such `'#f00'`, `'#ff0000'`, `'rgb(255,0,0)'`, or `'red'`.
1506
1509
 
1510
+ ### filterEventsWithResources
1511
+ - Type `boolean`
1512
+ - Default `false`
1513
+
1514
+ Determines whether events that do not belong to the current array of [resources](#resources) should be hidden in `dayGrid`/`timeGrid`/`list` views.
1515
+
1507
1516
  ### filterResourcesWithEvents
1508
1517
  - Type `boolean`
1509
1518
  - Default `false`
@@ -1614,13 +1623,13 @@ Defines the height of the entire calendar.
1614
1623
  This should be a valid CSS value like `'100%'` or `'600px'`.
1615
1624
 
1616
1625
  ### hiddenDays
1617
- - Type `Array`
1626
+ - Type `array`
1618
1627
  - Default `[]`
1619
1628
 
1620
1629
  Exclude certain days-of-the-week from being displayed, where Sunday is `0`, Monday is `1`, etc. Saturday is `6`.
1621
1630
 
1622
1631
  ### highlightedDates
1623
- - Type `Array`
1632
+ - Type `array`
1624
1633
  - Default `[]`
1625
1634
 
1626
1635
  Array of dates that need to be highlighted in the calendar.
@@ -1811,7 +1820,7 @@ Enables a marker indicating the current time in `timeGrid`/`resourceTimeGrid` vi
1811
1820
  Enables mouse cursor pointer in `timeGrid`/`resourceTimeGrid` and other views.
1812
1821
 
1813
1822
  ### resources
1814
- - Type `Array`
1823
+ - Type `array`
1815
1824
  - Default `[]`
1816
1825
 
1817
1826
  Array of plain objects that will be parsed into [Resource](#resource-object) objects for displaying in the resource view.
@@ -2076,13 +2085,13 @@ This should be a value that can be parsed into a [Duration](#duration-object) ob
2076
2085
 
2077
2086
  ### slotWidth
2078
2087
  - Type `integer`
2079
- - Default `52`
2088
+ - Default `72`
2080
2089
 
2081
2090
  Defines the time slot width in pixels in `ResourceTimeline` views. When changing the setting, you must additionally override the following CSS styles:
2082
2091
 
2083
2092
  ```css
2084
2093
  .ec-timeline .ec-time, .ec-timeline .ec-line {
2085
- width: 52px; /* override this value */
2094
+ width: 72px; /* override this value */
2086
2095
  }
2087
2096
  ```
2088
2097
 
@@ -2531,48 +2540,48 @@ The [eventTextColor](#eventtextcolor) override for this specific event
2531
2540
  <tr>
2532
2541
  <td>
2533
2542
 
2534
- `extendedProps`
2543
+ `classNames`
2535
2544
  </td>
2536
2545
  <td>
2537
2546
 
2538
- A plain object holding miscellaneous properties specified during parsing in the explicitly given `extendedProps` field
2547
+ An array of additional CSS classes for this specific event
2539
2548
  </td>
2540
2549
  </tr>
2541
- </table>
2542
-
2543
- ### Parsing event from a plain object
2544
- When Event Calendar receives an array of plain event’s objects either from the `events` option or as a result of an HTTP request to a URL of an event source, it parses the input objects into proper Event objects.
2545
-
2546
- Here are all admissible fields for the event’s input object:
2547
- <table>
2548
2550
  <tr>
2549
2551
  <td>
2550
2552
 
2551
- `id`
2553
+ `styles`
2552
2554
  </td>
2553
2555
  <td>
2554
2556
 
2555
- `string` or `integer` A unique identifier of the event. Default `auto-generated value`
2557
+ An array of additional inline styling declarations for this specific event
2556
2558
  </td>
2557
2559
  </tr>
2558
2560
  <tr>
2559
2561
  <td>
2560
2562
 
2561
- `resourceId`
2563
+ `extendedProps`
2562
2564
  </td>
2563
2565
  <td>
2564
2566
 
2565
- `string` or `integer` An ID of a resource that the event is associated with. This field is not used if `resourceIds` is provided. Default `undefined`
2567
+ A plain object holding miscellaneous properties specified during parsing in the explicitly given `extendedProps` field
2566
2568
  </td>
2567
2569
  </tr>
2570
+ </table>
2571
+
2572
+ ### Parsing event from a plain object
2573
+ When Event Calendar receives an array of plain event’s objects either from the `events` option or as a result of an HTTP request to a URL of an event source, it parses the input objects into proper Event objects.
2574
+
2575
+ Here are all admissible fields for the event’s input object:
2576
+ <table>
2568
2577
  <tr>
2569
2578
  <td>
2570
2579
 
2571
- `resourceIds`
2580
+ `id`
2572
2581
  </td>
2573
2582
  <td>
2574
2583
 
2575
- `Array` An array of resource IDs that the event is associated with. This field is used instead of `resourceId`. Default `[]`
2584
+ `string` or `integer` A unique identifier of the event. Default `auto-generated value`
2576
2585
  </td>
2577
2586
  </tr>
2578
2587
  <tr>
@@ -2638,6 +2647,26 @@ Here are all admissible fields for the event’s input object:
2638
2647
  <tr>
2639
2648
  <td>
2640
2649
 
2650
+ `durationEditable`
2651
+ </td>
2652
+ <td>
2653
+
2654
+ `boolean` Overrides the master [eventDurationEditable](#eventdurationeditable) option for this single event. Default `undefined`
2655
+ </td>
2656
+ </tr>
2657
+ <tr>
2658
+ <td>
2659
+
2660
+ `resourceIds` or `resourceId`
2661
+ </td>
2662
+ <td>
2663
+
2664
+ `string`, `integer` or `array` An ID of a resource or an array of resource IDs that the event is associated with. Default `[]`
2665
+ </td>
2666
+ </tr>
2667
+ <tr>
2668
+ <td>
2669
+
2641
2670
  `display`
2642
2671
  </td>
2643
2672
  <td>
@@ -2678,6 +2707,26 @@ Here are all admissible fields for the event’s input object:
2678
2707
  <tr>
2679
2708
  <td>
2680
2709
 
2710
+ `classNames` or `className`
2711
+ </td>
2712
+ <td>
2713
+
2714
+ `string` or `array` Sets additional CSS classes for this single event. See [eventClassNames](#eventclassnames). Default `[]`
2715
+ </td>
2716
+ </tr>
2717
+ <tr>
2718
+ <td>
2719
+
2720
+ `styles` or `style`
2721
+ </td>
2722
+ <td>
2723
+
2724
+ `string` or `array` Sets additional inline styling declarations for this single event. This value can be either a string containing styles `'font-size: 24px; border-radius: 4px; ...'` or an array of strings `['font-size: 24px', 'border-radius: 4px', ...]`. Default `[]`
2725
+ </td>
2726
+ </tr>
2727
+ <tr>
2728
+ <td>
2729
+
2681
2730
  `extendedProps`
2682
2731
  </td>
2683
2732
  <td>
@@ -2773,6 +2822,16 @@ The title of the resource. See [Content](#content)
2773
2822
  </td>
2774
2823
  <td>Default text color for this resource's events</td>
2775
2824
  </tr>
2825
+ <tr>
2826
+ <td>
2827
+
2828
+ `extendedProps`
2829
+ </td>
2830
+ <td>
2831
+
2832
+ A plain object holding miscellaneous properties specified during parsing in the explicitly given `extendedProps` field
2833
+ </td>
2834
+ </tr>
2776
2835
  </table>
2777
2836
 
2778
2837
  ### Parsing resource from a plain object
@@ -2820,6 +2879,16 @@ Here are all admissible fields for the resource’s input object:
2820
2879
  `string` Sets the default text color for this resource's events just like the calendar-wide [eventTextColor](#eventtextcolor) option. Default `undefined`
2821
2880
  </td>
2822
2881
  </tr>
2882
+ <tr>
2883
+ <td>
2884
+
2885
+ `extendedProps`
2886
+ </td>
2887
+ <td>
2888
+
2889
+ `object` A plain object with any miscellaneous properties. It will be directly transferred to the `extendedProps` property of the Resource object. Default `{}`
2890
+ </td>
2891
+ </tr>
2823
2892
  </table>
2824
2893
 
2825
2894
  ## View object
package/index.js CHANGED
@@ -274,6 +274,10 @@ function symbol() {
274
274
  return Symbol('ec');
275
275
  }
276
276
 
277
+ function isArray(value) {
278
+ return Array.isArray(value);
279
+ }
280
+
277
281
  function createElement(tag, className, content, attrs = []) {
278
282
  let el = document.createElement(tag);
279
283
  el.className = className;
@@ -373,21 +377,20 @@ function createEvents(input) {
373
377
  return input.map(event => {
374
378
  let result = {
375
379
  id: 'id' in event ? String(event.id) : `{generated-${eventId++}}`,
376
- resourceIds: Array.isArray(event.resourceIds)
377
- ? event.resourceIds.map(String)
378
- : ('resourceId' in event ? [String(event.resourceId)] : []),
380
+ resourceIds: toArrayProp(event, 'resourceId').map(String),
379
381
  allDay: event.allDay ?? (noTimePart(event.start) && noTimePart(event.end)),
380
382
  start: createDate(event.start),
381
383
  end: createDate(event.end),
382
- title: event.title || '',
383
- titleHTML: event.titleHTML || '',
384
+ title: event.title ?? '',
384
385
  editable: event.editable,
385
386
  startEditable: event.startEditable,
386
387
  durationEditable: event.durationEditable,
387
- display: event.display || 'auto',
388
- extendedProps: event.extendedProps || {},
389
- backgroundColor: event.backgroundColor || event.color,
390
- textColor: event.textColor
388
+ display: event.display ?? 'auto',
389
+ extendedProps: event.extendedProps ?? {},
390
+ backgroundColor: event.backgroundColor ?? event.color,
391
+ textColor: event.textColor,
392
+ classNames: toArrayProp(event, 'className'),
393
+ styles: toArrayProp(event, 'style')
391
394
  };
392
395
 
393
396
  if (result.allDay) {
@@ -407,6 +410,11 @@ function createEvents(input) {
407
410
  });
408
411
  }
409
412
 
413
+ function toArrayProp(input, propName) {
414
+ let result = input[propName + 's'] ?? input[propName] ?? [];
415
+ return isArray(result) ? result : [result];
416
+ }
417
+
410
418
  function createEventSources(input) {
411
419
  return input.map(source => ({
412
420
  events: source.events,
@@ -446,7 +454,9 @@ function createEventContent(chunk, displayEventEnd, eventContent, theme, _intlEv
446
454
  view: toViewWithLocalDates(_view)
447
455
  })
448
456
  : eventContent;
449
- } else {
457
+ }
458
+
459
+ if (content === undefined) {
450
460
  let domNodes;
451
461
  switch (chunk.event.display) {
452
462
  case 'background':
@@ -477,6 +487,7 @@ function createTimeElement(timeText, chunk, theme) {
477
487
  }
478
488
 
479
489
  function createEventClasses(eventClassNames, event, _view) {
490
+ let result = event.classNames;
480
491
  if (eventClassNames) {
481
492
  if (is_function(eventClassNames)) {
482
493
  eventClassNames = eventClassNames({
@@ -484,9 +495,12 @@ function createEventClasses(eventClassNames, event, _view) {
484
495
  view: toViewWithLocalDates(_view)
485
496
  });
486
497
  }
487
- return Array.isArray(eventClassNames) ? eventClassNames : [eventClassNames];
498
+ result = [
499
+ ...isArray(eventClassNames) ? eventClassNames : [eventClassNames],
500
+ ...result
501
+ ];
488
502
  }
489
- return [];
503
+ return result;
490
504
  }
491
505
 
492
506
  function toEventWithLocalDates(event) {
@@ -599,17 +613,24 @@ function runReposition(refs, data) {
599
613
  }
600
614
 
601
615
  /**
602
- * Check whether the event intersects with the given date range and resource
616
+ * Check whether the event intersects with the given date range and resources
603
617
  * @param event
604
618
  * @param start
605
619
  * @param end
606
- * @param [resource]
620
+ * @param resources
607
621
  * @return boolean
608
622
  */
609
- function eventIntersects(event, start, end, resource) {
610
- return event.start < end && event.end > start && (
611
- resource === undefined || event.resourceIds.includes(resource.id)
612
- );
623
+ function eventIntersects(event, start, end, resources) {
624
+ if (event.start < end && event.end > start) {
625
+ if (resources) {
626
+ if (!isArray(resources)) {
627
+ resources = [resources];
628
+ }
629
+ return resources.some(resource => event.resourceIds.includes(resource.id));
630
+ }
631
+ return true;
632
+ }
633
+ return false;
613
634
  }
614
635
 
615
636
  function helperEvent(display) {
@@ -664,9 +685,9 @@ function createResources(input) {
664
685
  return input.map(resource => ({
665
686
  id: String(resource.id),
666
687
  title: resource.title || '',
667
- titleHTML: resource.titleHTML || '',
668
688
  eventBackgroundColor: resource.eventBackgroundColor,
669
- eventTextColor: resource.eventTextColor
689
+ eventTextColor: resource.eventTextColor,
690
+ extendedProps: resource.extendedProps ?? {}
670
691
  }));
671
692
  }
672
693
 
@@ -871,6 +892,7 @@ function createOptions(plugins) {
871
892
  hour: 'numeric',
872
893
  minute: '2-digit'
873
894
  },
895
+ filterEventsWithResources: false,
874
896
  filterResourcesWithEvents: false,
875
897
  firstDay: 0,
876
898
  flexibleSlotTimeLimits: false, // ec option
@@ -1343,7 +1365,7 @@ function validKey(key, state) {
1343
1365
  return state.hasOwnProperty(key) && key[0] !== '_';
1344
1366
  }
1345
1367
 
1346
- /* packages/core/src/Buttons.svelte generated by Svelte v4.2.18 */
1368
+ /* packages/core/src/Buttons.svelte generated by Svelte v4.2.19 */
1347
1369
 
1348
1370
  function get_each_context$2(ctx, list, i) {
1349
1371
  const child_ctx = ctx.slice();
@@ -1845,7 +1867,7 @@ class Buttons extends SvelteComponent {
1845
1867
  }
1846
1868
  }
1847
1869
 
1848
- /* packages/core/src/Toolbar.svelte generated by Svelte v4.2.18 */
1870
+ /* packages/core/src/Toolbar.svelte generated by Svelte v4.2.19 */
1849
1871
 
1850
1872
  function get_each_context$1(ctx, list, i) {
1851
1873
  const child_ctx = ctx.slice();
@@ -2237,7 +2259,7 @@ class Toolbar extends SvelteComponent {
2237
2259
  }
2238
2260
  }
2239
2261
 
2240
- /* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.18 */
2262
+ /* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.19 */
2241
2263
 
2242
2264
  function get_each_context(ctx, list, i) {
2243
2265
  const child_ctx = ctx.slice();
@@ -2445,7 +2467,7 @@ class Auxiliary extends SvelteComponent {
2445
2467
  }
2446
2468
  }
2447
2469
 
2448
- /* packages/core/src/Calendar.svelte generated by Svelte v4.2.18 */
2470
+ /* packages/core/src/Calendar.svelte generated by Svelte v4.2.19 */
2449
2471
 
2450
2472
  function create_fragment(ctx) {
2451
2473
  let div;
@@ -2640,21 +2662,23 @@ function instance($$self, $$props, $$invalidate) {
2640
2662
  }
2641
2663
 
2642
2664
  function addEvent(event) {
2643
- $_events.push(createEvents([event])[0]);
2665
+ event = createEvents([event])[0];
2666
+ $_events.push(event);
2644
2667
  _events.set($_events);
2645
- return this;
2668
+ return event;
2646
2669
  }
2647
2670
 
2648
2671
  function updateEvent(event) {
2649
2672
  for (let e of $_events) {
2650
2673
  if (e.id == event.id) {
2651
- assign(e, createEvents([event])[0]);
2674
+ event = createEvents([event])[0];
2675
+ assign(e, event);
2652
2676
  _events.set($_events);
2653
- break;
2677
+ return event;
2654
2678
  }
2655
2679
  }
2656
2680
 
2657
- return this;
2681
+ return null;
2658
2682
  }
2659
2683
 
2660
2684
  function removeEventById(id) {
@@ -2862,4 +2886,4 @@ class Calendar extends SvelteComponent {
2862
2886
  }
2863
2887
  }
2864
2888
 
2865
- export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, ceil, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createResources, createSlotTimeLimits, createTimes, createView, datesEqual, debounce, Calendar as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, listView, max, min, nextClosestDay, nextDate, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, prevDate, previewEvent, rect, repositionEvent, resourceBackgroundColor, resourceTextColor, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
2889
+ export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, ceil, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createResources, createSlotTimeLimits, createTimes, createView, datesEqual, debounce, Calendar as default, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, isArray, keyEnter, keys, listView, max, min, nextClosestDay, nextDate, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, prevDate, previewEvent, rect, repositionEvent, resourceBackgroundColor, resourceTextColor, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates, viewResources };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource & timeline views",
6
6
  "keywords": [
@@ -28,6 +28,6 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "dependencies": {
31
- "svelte": "^4.2.16"
31
+ "svelte": "^4.2.19"
32
32
  }
33
33
  }
@@ -67,20 +67,22 @@
67
67
  }
68
68
 
69
69
  export function addEvent(event) {
70
- $_events.push(createEvents([event])[0]);
70
+ event = createEvents([event])[0];
71
+ $_events.push(event);
71
72
  $_events = $_events;
72
- return this;
73
+ return event;
73
74
  }
74
75
 
75
76
  export function updateEvent(event) {
76
77
  for (let e of $_events) {
77
78
  if (e.id == event.id) {
78
- assign(e, createEvents([event])[0]);
79
+ event = createEvents([event])[0];
80
+ assign(e, event);
79
81
  $_events = $_events;
80
- break;
82
+ return event;
81
83
  }
82
84
  }
83
- return this;
85
+ return null;
84
86
  }
85
87
 
86
88
  export function removeEventById(id) {
package/src/lib/events.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {addDay, datesEqual, createDate, cloneDate, setMidnight, toLocalDate, toISOString, noTimePart, copyTime} from './date';
2
2
  import {createElement} from './dom';
3
- import {assign} from './utils';
3
+ import {assign, isArray} from './utils';
4
4
  import {toViewWithLocalDates} from './view';
5
5
  import {is_function} from 'svelte/internal';
6
6
 
@@ -9,21 +9,20 @@ export function createEvents(input) {
9
9
  return input.map(event => {
10
10
  let result = {
11
11
  id: 'id' in event ? String(event.id) : `{generated-${eventId++}}`,
12
- resourceIds: Array.isArray(event.resourceIds)
13
- ? event.resourceIds.map(String)
14
- : ('resourceId' in event ? [String(event.resourceId)] : []),
12
+ resourceIds: toArrayProp(event, 'resourceId').map(String),
15
13
  allDay: event.allDay ?? (noTimePart(event.start) && noTimePart(event.end)),
16
14
  start: createDate(event.start),
17
15
  end: createDate(event.end),
18
- title: event.title || '',
19
- titleHTML: event.titleHTML || '',
16
+ title: event.title ?? '',
20
17
  editable: event.editable,
21
18
  startEditable: event.startEditable,
22
19
  durationEditable: event.durationEditable,
23
- display: event.display || 'auto',
24
- extendedProps: event.extendedProps || {},
25
- backgroundColor: event.backgroundColor || event.color,
26
- textColor: event.textColor
20
+ display: event.display ?? 'auto',
21
+ extendedProps: event.extendedProps ?? {},
22
+ backgroundColor: event.backgroundColor ?? event.color,
23
+ textColor: event.textColor,
24
+ classNames: toArrayProp(event, 'className'),
25
+ styles: toArrayProp(event, 'style')
27
26
  };
28
27
 
29
28
  if (result.allDay) {
@@ -43,6 +42,11 @@ export function createEvents(input) {
43
42
  });
44
43
  }
45
44
 
45
+ function toArrayProp(input, propName) {
46
+ let result = input[propName + 's'] ?? input[propName] ?? [];
47
+ return isArray(result) ? result : [result];
48
+ }
49
+
46
50
  export function createEventSources(input) {
47
51
  return input.map(source => ({
48
52
  events: source.events,
@@ -82,7 +86,9 @@ export function createEventContent(chunk, displayEventEnd, eventContent, theme,
82
86
  view: toViewWithLocalDates(_view)
83
87
  })
84
88
  : eventContent;
85
- } else {
89
+ }
90
+
91
+ if (content === undefined) {
86
92
  let domNodes;
87
93
  switch (chunk.event.display) {
88
94
  case 'background':
@@ -113,6 +119,7 @@ function createTimeElement(timeText, chunk, theme) {
113
119
  }
114
120
 
115
121
  export function createEventClasses(eventClassNames, event, _view) {
122
+ let result = event.classNames;
116
123
  if (eventClassNames) {
117
124
  if (is_function(eventClassNames)) {
118
125
  eventClassNames = eventClassNames({
@@ -120,9 +127,12 @@ export function createEventClasses(eventClassNames, event, _view) {
120
127
  view: toViewWithLocalDates(_view)
121
128
  });
122
129
  }
123
- return Array.isArray(eventClassNames) ? eventClassNames : [eventClassNames];
130
+ result = [
131
+ ...isArray(eventClassNames) ? eventClassNames : [eventClassNames],
132
+ ...result
133
+ ];
124
134
  }
125
- return [];
135
+ return result;
126
136
  }
127
137
 
128
138
  export function toEventWithLocalDates(event) {
@@ -235,17 +245,24 @@ export function runReposition(refs, data) {
235
245
  }
236
246
 
237
247
  /**
238
- * Check whether the event intersects with the given date range and resource
248
+ * Check whether the event intersects with the given date range and resources
239
249
  * @param event
240
250
  * @param start
241
251
  * @param end
242
- * @param [resource]
252
+ * @param resources
243
253
  * @return boolean
244
254
  */
245
- export function eventIntersects(event, start, end, resource) {
246
- return event.start < end && event.end > start && (
247
- resource === undefined || event.resourceIds.includes(resource.id)
248
- );
255
+ export function eventIntersects(event, start, end, resources) {
256
+ if (event.start < end && event.end > start) {
257
+ if (resources) {
258
+ if (!isArray(resources)) {
259
+ resources = [resources];
260
+ }
261
+ return resources.some(resource => event.resourceIds.includes(resource.id));
262
+ }
263
+ return true;
264
+ }
265
+ return false;
249
266
  }
250
267
 
251
268
  export function helperEvent(display) {
@@ -2,9 +2,9 @@ export function createResources(input) {
2
2
  return input.map(resource => ({
3
3
  id: String(resource.id),
4
4
  title: resource.title || '',
5
- titleHTML: resource.titleHTML || '',
6
5
  eventBackgroundColor: resource.eventBackgroundColor,
7
- eventTextColor: resource.eventTextColor
6
+ eventTextColor: resource.eventTextColor,
7
+ extendedProps: resource.extendedProps ?? {}
8
8
  }));
9
9
  }
10
10
 
package/src/lib/utils.js CHANGED
@@ -25,3 +25,7 @@ export function max(...args) {
25
25
  export function symbol() {
26
26
  return Symbol('ec');
27
27
  }
28
+
29
+ export function isArray(value) {
30
+ return Array.isArray(value);
31
+ }
@@ -45,6 +45,7 @@ export function createOptions(plugins) {
45
45
  hour: 'numeric',
46
46
  minute: '2-digit'
47
47
  },
48
+ filterEventsWithResources: false,
48
49
  filterResourcesWithEvents: false,
49
50
  firstDay: 0,
50
51
  flexibleSlotTimeLimits: false, // ec option