@event-calendar/core 3.0.1 → 3.1.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
@@ -4,7 +4,7 @@ See [demo](https://vkurko.github.io/calendar/) and [changelog](CHANGELOG.md).
4
4
 
5
5
  Full-sized drag & drop JavaScript event calendar with resource & timeline views:
6
6
 
7
- * Lightweight (34kb [br](https://en.wikipedia.org/wiki/Brotli) compressed)
7
+ * Lightweight (39kb [br](https://en.wikipedia.org/wiki/Brotli) compressed)
8
8
  * Zero-dependency (pre-built bundle)
9
9
  * Used on over 70,000 websites with [Bookly](https://wordpress.org/plugins/bookly-responsive-appointment-booking-tool/)
10
10
 
@@ -115,10 +115,10 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
115
115
  - [setOption](#setoption-name-value-)
116
116
  </td><td>
117
117
 
118
- - [getEvents](#getevents)
118
+ - [addEvent](#addevent-event-)
119
119
  - [getEventById](#geteventbyid-id-)
120
+ - [getEvents](#getevents)
120
121
  - [removeEventById](#removeeventbyid-id-)
121
- - [addEvent](#addevent-event-)
122
122
  - [updateEvent](#updateevent-event-)
123
123
  - [refetchEvents](#refetchevents)
124
124
  </td><td>
@@ -126,6 +126,8 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
126
126
  - [dateFromPoint](#datefrompoint-x-y-)
127
127
  - [destroy](#destroy)
128
128
  - [getView](#getview)
129
+ - [next](#next)
130
+ - [prev](#prev)
129
131
  - [unselect](#unselect-1)
130
132
  </td></tr>
131
133
  </table>
@@ -202,8 +204,8 @@ import '@event-calendar/core/index.css';
202
204
  ### Pre-built browser ready bundle
203
205
  Include the following lines of code in the `<head>` section of your page:
204
206
  ```html
205
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.1/event-calendar.min.css">
206
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.0.1/event-calendar.min.js"></script>
207
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.1.0/event-calendar.min.css">
208
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@3.1.0/event-calendar.min.js"></script>
207
209
  ```
208
210
 
209
211
  <details>
@@ -292,21 +294,21 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
292
294
 
293
295
  ### buttonText
294
296
  - Type `object` or `function`
295
- - Default `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimelineDay: 'timeline', resourceTimelineWeek: 'timeline', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
297
+ - Default `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'resources', resourceTimeGridWeek: 'resources', resourceTimelineDay: 'timeline', resourceTimelineMonth: 'timeline', resourceTimelineWeek: 'timeline', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
296
298
  > Views override the default value as follows:
297
299
  > - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
298
300
  > - listDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
299
301
  > - listMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
300
302
  > - listWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
301
303
  > - listYear `text => ({...text, next: 'Next year', prev: 'Previous year'})`
302
- > - resourceTimelineDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
303
- > - resourceTimelineWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
304
304
  > - resourceTimeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
305
305
  > - resourceTimeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
306
+ > - resourceTimelineDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
307
+ > - resourceTimelineMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
308
+ > - resourceTimelineWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
306
309
  > - timeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
307
310
  > - timeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
308
311
 
309
-
310
312
  Text that is displayed in buttons of the header toolbar.
311
313
 
312
314
  This value can be either a plain object with all necessary properties, or a callback function that receives default button text object and should return a new one:
@@ -538,8 +540,6 @@ function (date) {
538
540
  - Default `{dateStyle: 'long'}`
539
541
  > Views override the default value as follows:
540
542
  > - dayGridMonth `{weekday: 'long'}`
541
- > - resourceTimelineDay `{dateStyle: 'long', timeStyle: 'short'}`
542
- > - resourceTimelineWeek `{dateStyle: 'long', timeStyle: 'short'}`
543
543
 
544
544
  Defines the text that is used inside the `aria-label` attribute in calendar column headings.
545
545
 
@@ -565,6 +565,7 @@ function (date) {
565
565
  - Default `{weekday: 'short', month: 'numeric', day: 'numeric'}`
566
566
  > Views override the default value as follows:
567
567
  > - dayGridMonth `{weekday: 'short'}`
568
+ > - resourceTimelineMonth `{weekday: 'short', day: 'numeric'}`
568
569
  > - timeGridDay `{weekday: 'long'}`
569
570
 
570
571
  Defines the text that is displayed on the calendar’s column headings.
@@ -614,6 +615,9 @@ function (date) {
614
615
  - Default `true`
615
616
  > Views override the default value as follows:
616
617
  > - dayGridMonth `false`
618
+ > - resourceTimelineDay `false`
619
+ > - resourceTimelineMonth `false`
620
+ > - resourceTimelineWeek `false`
617
621
 
618
622
  Determines whether to display an event’s end time.
619
623
 
@@ -632,8 +636,9 @@ Determines whether the calendar should automatically scroll during the event dra
632
636
  > - listDay `{days: 1}`
633
637
  > - listMonth `{months: 1}`
634
638
  > - listYear `{years: 1}`
635
- > - resourceTimelineDay `{days: 1}`
636
639
  > - resourceTimeGridDay `{days: 1}`
640
+ > - resourceTimelineDay `{days: 1}`
641
+ > - resourceTimelineMonth `{months: 1}`
637
642
  > - timeGridDay `{days: 1}`
638
643
 
639
644
  Sets the duration of a view.
@@ -1691,7 +1696,7 @@ function (isLoading) { }
1691
1696
  - Type `string`
1692
1697
  - Default `undefined`
1693
1698
 
1694
- Defines the `locales` parameter for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object that the Event Calendar uses to format date and time strings in options such as [dayHeaderFormat](#dayheaderformat), [eventTimeFormat](#eventtimeformat), etc.
1699
+ Defines the `locales` parameter for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#locales) object that the Event Calendar uses to format date and time strings in options such as [dayHeaderFormat](#dayheaderformat), [eventTimeFormat](#eventtimeformat), etc.
1695
1700
 
1696
1701
  ### longPressDelay
1697
1702
  - Type `integer`
@@ -1990,6 +1995,8 @@ This should be a value that can be parsed into a [Duration](#duration-object) ob
1990
1995
  ### slotDuration
1991
1996
  - Type `string`, `integer` or `object`
1992
1997
  - Default `'00:30:00'`
1998
+ > Views override the default value as follows:
1999
+ > - resourceTimelineMonth `{days: 1}`
1993
2000
 
1994
2001
  Defines the frequency for displaying time slots.
1995
2002
 
@@ -2077,6 +2084,9 @@ Defines the time slot width in pixels in `ResourceTimeline` views. When changing
2077
2084
  > - listYear `theme => ({...theme, view: 'ec-list ec-year-view'})`
2078
2085
  > - resourceTimeGridDay `theme => ({...theme, view: 'ec-time-grid ec-resource-day-view'})`
2079
2086
  > - resourceTimeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-resource-week-view'})`
2087
+ > - resourceTimelineDay `theme => ({...theme, view: 'ec-timeline ec-resource-day-view'})`
2088
+ > - resourceTimelineMonth `theme => ({...theme, view: 'ec-timeline ec-resource-month-view'})`
2089
+ > - resourceTimelineWeek `theme => ({...theme, view: 'ec-timeline ec-resource-week-view'})`
2080
2090
  > - timeGridDay `theme => ({...theme, view: 'ec-time-grid ec-day-view'})`
2081
2091
  > - timeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-week-view'})`
2082
2092
 
@@ -2194,7 +2204,7 @@ Clicking on elements that match this CSS selector will prevent the current selec
2194
2204
  - Type `string`
2195
2205
  - Default `'resourceTimeGridWeek'`
2196
2206
 
2197
- The view that is displayed in the calendar. Can be `'dayGridMonth'`, `'listDay'`, `'listWeek'`, `'listMonth'`, `'listYear'`, `'resourceTimelineDay'`, `'resourceTimelineWeek'`, `'resourceTimeGridDay'`, `'resourceTimeGridWeek'`, `'timeGridDay'` or `'timeGridWeek'`.
2207
+ The view that is displayed in the calendar. Can be `'dayGridMonth'`, `'listDay'`, `'listWeek'`, `'listMonth'`, `'listYear'`, `'resourceTimeGridDay'`, `'resourceTimeGridWeek'`, `'resourceTimelineDay'`, `'resourceTimelineWeek'`, `'resourceTimelineMonth'`, `'timeGridDay'` or `'timeGridWeek'`.
2198
2208
 
2199
2209
  ### viewDidMount
2200
2210
  - Type `function`
@@ -2277,10 +2287,13 @@ This method allows you to set new value to any calendar option.
2277
2287
  // E.g. Change the current date
2278
2288
  ec.setOption('date', new Date());
2279
2289
  ```
2280
- ### getEvents()
2281
- - Return value `Event[]` Array of [Event](#event-object) objects
2282
2290
 
2283
- Returns an array of events that the calendar has in memory.
2291
+ ### addEvent( event )
2292
+ - Parameters
2293
+ - `event` `object` A plain object that will be parsed into an [Event](#event-object) object
2294
+ - Return value [Event](#event-object) object or `null`
2295
+
2296
+ Adds a new event to the calendar.
2284
2297
 
2285
2298
  ### getEventById( id )
2286
2299
  - Parameters
@@ -2289,6 +2302,11 @@ Returns an array of events that the calendar has in memory.
2289
2302
 
2290
2303
  Returns a single event with the matching `id`.
2291
2304
 
2305
+ ### getEvents()
2306
+ - Return value `Event[]` Array of [Event](#event-object) objects
2307
+
2308
+ Returns an array of events that the calendar has in memory.
2309
+
2292
2310
  ### removeEventById( id )
2293
2311
  - Parameters
2294
2312
  - `id` `string|integer` The ID of the event
@@ -2296,13 +2314,6 @@ Returns a single event with the matching `id`.
2296
2314
 
2297
2315
  Removes a single event with the matching `id`.
2298
2316
 
2299
- ### addEvent( event )
2300
- - Parameters
2301
- - `event` `object` A plain object that will be parsed into an [Event](#event-object) object
2302
- - Return value [Event](#event-object) object or `null`
2303
-
2304
- Adds a new event to the calendar.
2305
-
2306
2317
  ### updateEvent( event )
2307
2318
  - Parameters
2308
2319
  - `event` `object` A plain object or [Event](#event-object) object
@@ -2369,6 +2380,16 @@ Destroys the calendar, removing all DOM elements, event handlers, and internal d
2369
2380
 
2370
2381
  Returns the [View](#view-object) object for the current view.
2371
2382
 
2383
+ ### next()
2384
+ - Return value `EventCalendar` The calendar instance for chaining
2385
+
2386
+ Moves the current calendar date forward by 1 day/week/month (depending on the current view).
2387
+
2388
+ ### prev()
2389
+ - Return value `EventCalendar` The calendar instance for chaining
2390
+
2391
+ Moves the current calendar date backward by 1 day/week/month (depending on the current view).
2392
+
2372
2393
  ### unselect()
2373
2394
  - Return value `EventCalendar` The calendar instance for chaining
2374
2395
 
package/index.css CHANGED
@@ -112,21 +112,23 @@
112
112
  }
113
113
  .ec-timeline .ec-times {
114
114
  display: flex;
115
- border-style: solid none none;
115
+ border-top: 1px solid var(--ec-border-color);
116
116
  }
117
117
  .ec-timeline .ec-time {
118
118
  border-left: 1px solid var(--ec-border-color);
119
119
  box-sizing: border-box;
120
+ font-size: 0.95em;
120
121
  min-height: 24px;
121
122
  overflow: hidden;
122
123
  text-overflow: ellipsis;
123
124
  }
124
125
  .ec-timeline .ec-time, .ec-timeline .ec-line {
125
- width: 52px;
126
+ width: 72px;
126
127
  }
127
128
  .ec-timeline .ec-events {
128
129
  position: relative;
129
130
  height: 100%;
131
+ margin: 0;
130
132
  }
131
133
  .ec-timeline .ec-event {
132
134
  position: absolute;
@@ -153,6 +155,7 @@
153
155
  .ec-timeline .ec-sidebar .ec-sidebar-title {
154
156
  flex-shrink: 0;
155
157
  border-bottom: 1px solid var(--ec-border-color);
158
+ box-sizing: content-box;
156
159
  }
157
160
  .ec-timeline .ec-sidebar .ec-content {
158
161
  flex: 1;
@@ -355,7 +358,6 @@
355
358
  .ec-body,
356
359
  .ec-days,
357
360
  .ec-day,
358
- .ec-times,
359
361
  .ec-day-head {
360
362
  border: 1px solid var(--ec-border-color);
361
363
  }
package/index.js CHANGED
@@ -179,6 +179,27 @@ function toSeconds(duration, defaultValue = 0) {
179
179
  return duration?.seconds ?? defaultValue;
180
180
  }
181
181
 
182
+ /**
183
+ * Move the date forward (when pressing the next button)
184
+ */
185
+ function nextDate(date, duration) {
186
+ addDuration(date, duration);
187
+ return date;
188
+ }
189
+
190
+ /**
191
+ * Move the date backward (when pressing the prev button)
192
+ */
193
+ function prevDate(date, duration, hiddenDays) {
194
+ subtractDuration(date, duration);
195
+ if (hiddenDays.length && hiddenDays.length < 7) {
196
+ while (hiddenDays.includes(date.getUTCDay())) {
197
+ subtractDay(date);
198
+ }
199
+ }
200
+ return date;
201
+ }
202
+
182
203
  /**
183
204
  * Private functions
184
205
  */
@@ -631,6 +652,16 @@ function themeView(view) {
631
652
  return theme => ({...theme, view});
632
653
  }
633
654
 
655
+ function createResources(input) {
656
+ return input.map(resource => ({
657
+ id: String(resource.id),
658
+ title: resource.title || '',
659
+ titleHTML: resource.titleHTML || '',
660
+ eventBackgroundColor: resource.eventBackgroundColor,
661
+ eventTextColor: resource.eventTextColor
662
+ }));
663
+ }
664
+
634
665
  function intl(locale, format) {
635
666
  return derived([locale, format], ([$locale, $format]) => {
636
667
  let intl = is_function($format)
@@ -691,7 +722,38 @@ function _getParts(source, parts) {
691
722
  return result;
692
723
  }
693
724
 
694
- function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel, $_intlDayHeaderAL) {
725
+ function viewResources(state) {
726
+ return derived(
727
+ [state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
728
+ ([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
729
+ let result = $resources;
730
+
731
+ if ($filterResourcesWithEvents) {
732
+ result = $resources.filter(resource => {
733
+ for (let event of $_events) {
734
+ if (
735
+ event.display !== 'background' &&
736
+ event.resourceIds.includes(resource.id) &&
737
+ event.start < $_activeRange.end &&
738
+ event.end > $_activeRange.start
739
+ ) {
740
+ return true;
741
+ }
742
+ }
743
+ return false;
744
+ });
745
+ }
746
+
747
+ if (!result.length) {
748
+ result = createResources([{}]);
749
+ }
750
+
751
+ return result;
752
+ }
753
+ );
754
+ }
755
+
756
+ function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel) {
695
757
  date = cloneDate(date);
696
758
  let compact = $slotDuration.seconds < 3600;
697
759
  let times = [];
@@ -703,8 +765,7 @@ function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel, $_i
703
765
  times.push([
704
766
  toISOString(date),
705
767
  $_intlSlotLabel.format(date),
706
- times.length && (i || !compact),
707
- $_intlDayHeaderAL && $_intlDayHeaderAL.format(date)
768
+ times.length && (i || !compact)
708
769
  ]);
709
770
  addDuration(date, $slotDuration);
710
771
  i = 1 - i;
@@ -770,7 +831,7 @@ function createOptions(plugins) {
770
831
  day: 'numeric'
771
832
  },
772
833
  dayHeaderAriaLabelFormat: {
773
- dateStyle: 'long'
834
+ dateStyle: 'full'
774
835
  },
775
836
  displayEventEnd: true,
776
837
  duration: {weeks: 1},
@@ -790,6 +851,7 @@ function createOptions(plugins) {
790
851
  hour: 'numeric',
791
852
  minute: '2-digit'
792
853
  },
854
+ filterResourcesWithEvents: false,
793
855
  firstDay: 0,
794
856
  flexibleSlotTimeLimits: false, // ec option
795
857
  headerToolbar: {
@@ -818,7 +880,7 @@ function createOptions(plugins) {
818
880
  },
819
881
  slotMaxTime: '24:00:00',
820
882
  slotMinTime: '00:00:00',
821
- slotWidth: 52,
883
+ slotWidth: 72,
822
884
  theme: {
823
885
  allDay: 'ec-all-day',
824
886
  active: 'ec-active',
@@ -884,6 +946,7 @@ function createParsers(plugins) {
884
946
  eventSources: createEventSources,
885
947
  hiddenDays: days => [...new Set(days)],
886
948
  highlightedDates: dates => dates.map(createDate),
949
+ resources: createResources,
887
950
  scrollTime: createDuration,
888
951
  slotDuration: createDuration,
889
952
  slotMaxTime: createDuration,
@@ -913,6 +976,10 @@ function dayGrid(state) {
913
976
  return derived(state.view, $view => $view?.startsWith('dayGrid'));
914
977
  }
915
978
 
979
+ function monthView(state) {
980
+ return derived(state.view, $view => $view?.includes('Month'));
981
+ }
982
+
916
983
  function activeRange(state) {
917
984
  return derived(
918
985
  [state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
@@ -939,10 +1006,10 @@ function activeRange(state) {
939
1006
 
940
1007
  function currentRange(state) {
941
1008
  return derived(
942
- [state.date, state.duration, state.firstDay, state._dayGrid],
943
- ([$date, $duration, $firstDay, $_dayGrid]) => {
1009
+ [state.date, state.duration, state.firstDay, state._monthView],
1010
+ ([$date, $duration, $firstDay, $_monthView]) => {
944
1011
  let start = cloneDate($date), end;
945
- if ($_dayGrid) {
1012
+ if ($_monthView) {
946
1013
  start.setUTCDate(1);
947
1014
  } else if ($duration.inWeeks) {
948
1015
  // First day of week
@@ -1121,6 +1188,7 @@ class State {
1121
1188
  this._tasks = new Map(); // timeout IDs for tasks
1122
1189
  this._auxiliary = writable([]); // auxiliary components
1123
1190
  this._dayGrid = dayGrid(this);
1191
+ this._monthView = monthView(this);
1124
1192
  this._currentRange = currentRange(this);
1125
1193
  this._activeRange = activeRange(this);
1126
1194
  this._fetchedRange = writable({start: undefined, end: undefined});
@@ -1263,7 +1331,7 @@ function validKey(key, state) {
1263
1331
  return state.hasOwnProperty(key) && key[0] !== '_';
1264
1332
  }
1265
1333
 
1266
- /* packages/core/src/Buttons.svelte generated by Svelte v4.2.16 */
1334
+ /* packages/core/src/Buttons.svelte generated by Svelte v4.2.18 */
1267
1335
 
1268
1336
  function get_each_context$2(ctx, list, i) {
1269
1337
  const child_ctx = ctx.slice();
@@ -1271,7 +1339,7 @@ function get_each_context$2(ctx, list, i) {
1271
1339
  return child_ctx;
1272
1340
  }
1273
1341
 
1274
- // (57:27)
1342
+ // (51:27)
1275
1343
  function create_if_block_5(ctx) {
1276
1344
  let button_1;
1277
1345
  let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[25]] + "";
@@ -1323,7 +1391,7 @@ function create_if_block_5(ctx) {
1323
1391
  };
1324
1392
  }
1325
1393
 
1326
- // (52:37)
1394
+ // (46:37)
1327
1395
  function create_if_block_4(ctx) {
1328
1396
  let button_1;
1329
1397
  let t_value = /*$customButtons*/ ctx[6][/*button*/ ctx[25]].text + "";
@@ -1369,7 +1437,7 @@ function create_if_block_4(ctx) {
1369
1437
  };
1370
1438
  }
1371
1439
 
1372
- // (46:32)
1440
+ // (40:32)
1373
1441
  function create_if_block_3(ctx) {
1374
1442
  let button_1;
1375
1443
  let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[25]] + "";
@@ -1416,7 +1484,7 @@ function create_if_block_3(ctx) {
1416
1484
  };
1417
1485
  }
1418
1486
 
1419
- // (39:31)
1487
+ // (33:31)
1420
1488
  function create_if_block_2(ctx) {
1421
1489
  let button_1;
1422
1490
  let i;
@@ -1473,7 +1541,7 @@ function create_if_block_2(ctx) {
1473
1541
  };
1474
1542
  }
1475
1543
 
1476
- // (32:31)
1544
+ // (26:31)
1477
1545
  function create_if_block_1(ctx) {
1478
1546
  let button_1;
1479
1547
  let i;
@@ -1530,7 +1598,7 @@ function create_if_block_1(ctx) {
1530
1598
  };
1531
1599
  }
1532
1600
 
1533
- // (29:4) {#if button == 'title'}
1601
+ // (23:4) {#if button == 'title'}
1534
1602
  function create_if_block$1(ctx) {
1535
1603
  let h2;
1536
1604
  let h2_class_value;
@@ -1569,7 +1637,7 @@ function create_if_block$1(ctx) {
1569
1637
  };
1570
1638
  }
1571
1639
 
1572
- // (28:0) {#each buttons as button}
1640
+ // (22:0) {#each buttons as button}
1573
1641
  function create_each_block$2(ctx) {
1574
1642
  let if_block_anchor;
1575
1643
 
@@ -1705,19 +1773,11 @@ function instance$3($$self, $$props, $$invalidate) {
1705
1773
  let today = setMidnight(createDate()), isToday;
1706
1774
 
1707
1775
  function prev() {
1708
- let d = subtractDuration($date, $duration);
1709
-
1710
- if ($hiddenDays.length && $hiddenDays.length < 7) {
1711
- while ($hiddenDays.includes(d.getUTCDay())) {
1712
- subtractDay(d);
1713
- }
1714
- }
1715
-
1716
- set_store_value(date, $date = d, $date);
1776
+ set_store_value(date, $date = prevDate($date, $duration, $hiddenDays), $date);
1717
1777
  }
1718
1778
 
1719
1779
  function next() {
1720
- set_store_value(date, $date = addDuration($date, $duration), $date);
1780
+ set_store_value(date, $date = nextDate($date, $duration), $date);
1721
1781
  }
1722
1782
 
1723
1783
  const click_handler = () => set_store_value(date, $date = cloneDate(today), $date);
@@ -1767,7 +1827,7 @@ class Buttons extends SvelteComponent {
1767
1827
  }
1768
1828
  }
1769
1829
 
1770
- /* packages/core/src/Toolbar.svelte generated by Svelte v4.2.16 */
1830
+ /* packages/core/src/Toolbar.svelte generated by Svelte v4.2.18 */
1771
1831
 
1772
1832
  function get_each_context$1(ctx, list, i) {
1773
1833
  const child_ctx = ctx.slice();
@@ -1781,7 +1841,7 @@ function get_each_context_1(ctx, list, i) {
1781
1841
  return child_ctx;
1782
1842
  }
1783
1843
 
1784
- // (28:16) {:else}
1844
+ // (29:16) {:else}
1785
1845
  function create_else_block(ctx) {
1786
1846
  let buttons_1;
1787
1847
  let current;
@@ -1815,7 +1875,7 @@ function create_else_block(ctx) {
1815
1875
  };
1816
1876
  }
1817
1877
 
1818
- // (24:16) {#if buttons.length > 1}
1878
+ // (25:16) {#if buttons.length > 1}
1819
1879
  function create_if_block(ctx) {
1820
1880
  let div;
1821
1881
  let buttons_1;
@@ -1862,7 +1922,7 @@ function create_if_block(ctx) {
1862
1922
  };
1863
1923
  }
1864
1924
 
1865
- // (23:12) {#each sections[key] as buttons}
1925
+ // (24:12) {#each sections[key] as buttons}
1866
1926
  function create_each_block_1(ctx) {
1867
1927
  let current_block_type_index;
1868
1928
  let if_block;
@@ -1935,10 +1995,11 @@ function create_each_block_1(ctx) {
1935
1995
  };
1936
1996
  }
1937
1997
 
1938
- // (21:4) {#each Object.keys(sections) as key}
1998
+ // (22:4) {#each keys(sections) as key}
1939
1999
  function create_each_block$1(ctx) {
1940
2000
  let div;
1941
2001
  let t;
2002
+ let div_class_value;
1942
2003
  let current;
1943
2004
  let each_value_1 = ensure_array_like(/*sections*/ ctx[0][/*key*/ ctx[5]]);
1944
2005
  let each_blocks = [];
@@ -1960,6 +2021,7 @@ function create_each_block$1(ctx) {
1960
2021
  }
1961
2022
 
1962
2023
  t = space();
2024
+ attr(div, "class", div_class_value = "ec-" + /*key*/ ctx[5]);
1963
2025
  },
1964
2026
  m(target, anchor) {
1965
2027
  insert(target, div, anchor);
@@ -1974,7 +2036,7 @@ function create_each_block$1(ctx) {
1974
2036
  current = true;
1975
2037
  },
1976
2038
  p(ctx, dirty) {
1977
- if (dirty & /*$theme, sections, Object*/ 3) {
2039
+ if (dirty & /*$theme, sections*/ 3) {
1978
2040
  each_value_1 = ensure_array_like(/*sections*/ ctx[0][/*key*/ ctx[5]]);
1979
2041
  let i;
1980
2042
 
@@ -2000,6 +2062,10 @@ function create_each_block$1(ctx) {
2000
2062
 
2001
2063
  check_outros();
2002
2064
  }
2065
+
2066
+ if (!current || dirty & /*sections*/ 1 && div_class_value !== (div_class_value = "ec-" + /*key*/ ctx[5])) {
2067
+ attr(div, "class", div_class_value);
2068
+ }
2003
2069
  },
2004
2070
  i(local) {
2005
2071
  if (current) return;
@@ -2033,7 +2099,7 @@ function create_fragment$2(ctx) {
2033
2099
  let nav;
2034
2100
  let nav_class_value;
2035
2101
  let current;
2036
- let each_value = ensure_array_like(Object.keys(/*sections*/ ctx[0]));
2102
+ let each_value = ensure_array_like(keys(/*sections*/ ctx[0]));
2037
2103
  let each_blocks = [];
2038
2104
 
2039
2105
  for (let i = 0; i < each_value.length; i += 1) {
@@ -2066,8 +2132,8 @@ function create_fragment$2(ctx) {
2066
2132
  current = true;
2067
2133
  },
2068
2134
  p(ctx, [dirty]) {
2069
- if (dirty & /*sections, Object, $theme*/ 3) {
2070
- each_value = ensure_array_like(Object.keys(/*sections*/ ctx[0]));
2135
+ if (dirty & /*sections, $theme*/ 3) {
2136
+ each_value = ensure_array_like(keys(/*sections*/ ctx[0]));
2071
2137
  let i;
2072
2138
 
2073
2139
  for (i = 0; i < each_value.length; i += 1) {
@@ -2136,7 +2202,7 @@ function instance$2($$self, $$props, $$invalidate) {
2136
2202
  $$self.$$.update = () => {
2137
2203
  if ($$self.$$.dirty & /*sections, $headerToolbar*/ 17) {
2138
2204
  {
2139
- for (let key of Object.keys(sections)) {
2205
+ for (let key of keys(sections)) {
2140
2206
  $$invalidate(0, sections[key] = $headerToolbar[key].split(' ').map(group => group.split(',')), sections);
2141
2207
  }
2142
2208
  }
@@ -2153,7 +2219,7 @@ class Toolbar extends SvelteComponent {
2153
2219
  }
2154
2220
  }
2155
2221
 
2156
- /* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.16 */
2222
+ /* packages/core/src/Auxiliary.svelte generated by Svelte v4.2.18 */
2157
2223
 
2158
2224
  function get_each_context(ctx, list, i) {
2159
2225
  const child_ctx = ctx.slice();
@@ -2361,7 +2427,7 @@ class Auxiliary extends SvelteComponent {
2361
2427
  }
2362
2428
  }
2363
2429
 
2364
- /* packages/core/src/Calendar.svelte generated by Svelte v4.2.16 */
2430
+ /* packages/core/src/Calendar.svelte generated by Svelte v4.2.18 */
2365
2431
 
2366
2432
  function create_fragment(ctx) {
2367
2433
  let div;
@@ -2416,7 +2482,7 @@ function create_fragment(ctx) {
2416
2482
  current = true;
2417
2483
 
2418
2484
  if (!mounted) {
2419
- dispose = listen(window, "resize", /*recheckScrollable*/ ctx[17]);
2485
+ dispose = listen(window, "resize", /*recheckScrollable*/ ctx[20]);
2420
2486
  mounted = true;
2421
2487
  }
2422
2488
  },
@@ -2492,6 +2558,9 @@ function instance($$self, $$props, $$invalidate) {
2492
2558
  let $_scrollable;
2493
2559
  let $_queue2;
2494
2560
  let $_queue;
2561
+ let $hiddenDays;
2562
+ let $duration;
2563
+ let $date;
2495
2564
  let $_interaction;
2496
2565
  let $_events;
2497
2566
  let $theme;
@@ -2504,15 +2573,18 @@ function instance($$self, $$props, $$invalidate) {
2504
2573
  let component = get_current_component();
2505
2574
  let state = new State(plugins, options);
2506
2575
  setContext('state', state);
2507
- let { _viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _queue2, _tasks, _scrollable, height, theme, view } = state;
2576
+ let { _viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _queue2, _tasks, _scrollable, date, duration, hiddenDays, height, theme, view } = state;
2508
2577
  component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
2509
- component_subscribe($$self, _bodyEl, value => $$invalidate(32, $_bodyEl = value));
2510
- component_subscribe($$self, _interaction, value => $$invalidate(35, $_interaction = value));
2578
+ component_subscribe($$self, _bodyEl, value => $$invalidate(37, $_bodyEl = value));
2579
+ component_subscribe($$self, _interaction, value => $$invalidate(43, $_interaction = value));
2511
2580
  component_subscribe($$self, _iClass, value => $$invalidate(2, $_iClass = value));
2512
- component_subscribe($$self, _events, value => $$invalidate(36, $_events = value));
2513
- component_subscribe($$self, _queue, value => $$invalidate(34, $_queue = value));
2514
- component_subscribe($$self, _queue2, value => $$invalidate(33, $_queue2 = value));
2581
+ component_subscribe($$self, _events, value => $$invalidate(44, $_events = value));
2582
+ component_subscribe($$self, _queue, value => $$invalidate(39, $_queue = value));
2583
+ component_subscribe($$self, _queue2, value => $$invalidate(38, $_queue2 = value));
2515
2584
  component_subscribe($$self, _scrollable, value => $$invalidate(0, $_scrollable = value));
2585
+ component_subscribe($$self, date, value => $$invalidate(42, $date = value));
2586
+ component_subscribe($$self, duration, value => $$invalidate(41, $duration = value));
2587
+ component_subscribe($$self, hiddenDays, value => $$invalidate(40, $hiddenDays = value));
2516
2588
  component_subscribe($$self, height, value => $$invalidate(3, $height = value));
2517
2589
  component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
2518
2590
  component_subscribe($$self, view, value => $$invalidate(4, $view = value));
@@ -2583,10 +2655,7 @@ function instance($$self, $$props, $$invalidate) {
2583
2655
  }
2584
2656
 
2585
2657
  function unselect() {
2586
- if ($_interaction.action) {
2587
- $_interaction.action.unselect();
2588
- }
2589
-
2658
+ $_interaction.action?.unselect();
2590
2659
  return this;
2591
2660
  }
2592
2661
 
@@ -2599,6 +2668,16 @@ function instance($$self, $$props, $$invalidate) {
2599
2668
  destroy_component(component, true);
2600
2669
  }
2601
2670
 
2671
+ function next() {
2672
+ set_store_value(date, $date = nextDate($date, $duration), $date);
2673
+ return this;
2674
+ }
2675
+
2676
+ function prev() {
2677
+ set_store_value(date, $date = prevDate($date, $duration, $hiddenDays), $date);
2678
+ return this;
2679
+ }
2680
+
2602
2681
  beforeUpdate(() => {
2603
2682
  flushDebounce($_queue);
2604
2683
  });
@@ -2615,12 +2694,12 @@ function instance($$self, $$props, $$invalidate) {
2615
2694
  }
2616
2695
 
2617
2696
  $$self.$$set = $$props => {
2618
- if ('plugins' in $$props) $$invalidate(18, plugins = $$props.plugins);
2619
- if ('options' in $$props) $$invalidate(19, options = $$props.options);
2697
+ if ('plugins' in $$props) $$invalidate(21, plugins = $$props.plugins);
2698
+ if ('options' in $$props) $$invalidate(22, options = $$props.options);
2620
2699
  };
2621
2700
 
2622
2701
  $$self.$$.update = () => {
2623
- if ($$self.$$.dirty[0] & /*options*/ 524288) {
2702
+ if ($$self.$$.dirty[0] & /*options*/ 4194304) {
2624
2703
  for (let [name, value] of diff(options, prevOptions)) {
2625
2704
  setOption(name, value);
2626
2705
  }
@@ -2642,6 +2721,9 @@ function instance($$self, $$props, $$invalidate) {
2642
2721
  _queue,
2643
2722
  _queue2,
2644
2723
  _scrollable,
2724
+ date,
2725
+ duration,
2726
+ hiddenDays,
2645
2727
  height,
2646
2728
  theme,
2647
2729
  view,
@@ -2659,7 +2741,9 @@ function instance($$self, $$props, $$invalidate) {
2659
2741
  getView,
2660
2742
  unselect,
2661
2743
  dateFromPoint,
2662
- destroy
2744
+ destroy,
2745
+ next,
2746
+ prev
2663
2747
  ];
2664
2748
  }
2665
2749
 
@@ -2674,20 +2758,22 @@ class Calendar extends SvelteComponent {
2674
2758
  create_fragment,
2675
2759
  safe_not_equal,
2676
2760
  {
2677
- plugins: 18,
2678
- options: 19,
2679
- setOption: 20,
2680
- getOption: 21,
2681
- refetchEvents: 22,
2682
- getEvents: 23,
2683
- getEventById: 24,
2684
- addEvent: 25,
2685
- updateEvent: 26,
2686
- removeEventById: 27,
2687
- getView: 28,
2688
- unselect: 29,
2689
- dateFromPoint: 30,
2690
- destroy: 31
2761
+ plugins: 21,
2762
+ options: 22,
2763
+ setOption: 23,
2764
+ getOption: 24,
2765
+ refetchEvents: 25,
2766
+ getEvents: 26,
2767
+ getEventById: 27,
2768
+ addEvent: 28,
2769
+ updateEvent: 29,
2770
+ removeEventById: 30,
2771
+ getView: 31,
2772
+ unselect: 32,
2773
+ dateFromPoint: 33,
2774
+ destroy: 34,
2775
+ next: 35,
2776
+ prev: 36
2691
2777
  },
2692
2778
  null,
2693
2779
  [-1, -1]
@@ -2695,52 +2781,60 @@ class Calendar extends SvelteComponent {
2695
2781
  }
2696
2782
 
2697
2783
  get setOption() {
2698
- return this.$$.ctx[20];
2784
+ return this.$$.ctx[23];
2699
2785
  }
2700
2786
 
2701
2787
  get getOption() {
2702
- return this.$$.ctx[21];
2788
+ return this.$$.ctx[24];
2703
2789
  }
2704
2790
 
2705
2791
  get refetchEvents() {
2706
- return this.$$.ctx[22];
2792
+ return this.$$.ctx[25];
2707
2793
  }
2708
2794
 
2709
2795
  get getEvents() {
2710
- return this.$$.ctx[23];
2796
+ return this.$$.ctx[26];
2711
2797
  }
2712
2798
 
2713
2799
  get getEventById() {
2714
- return this.$$.ctx[24];
2800
+ return this.$$.ctx[27];
2715
2801
  }
2716
2802
 
2717
2803
  get addEvent() {
2718
- return this.$$.ctx[25];
2804
+ return this.$$.ctx[28];
2719
2805
  }
2720
2806
 
2721
2807
  get updateEvent() {
2722
- return this.$$.ctx[26];
2808
+ return this.$$.ctx[29];
2723
2809
  }
2724
2810
 
2725
2811
  get removeEventById() {
2726
- return this.$$.ctx[27];
2812
+ return this.$$.ctx[30];
2727
2813
  }
2728
2814
 
2729
2815
  get getView() {
2730
- return this.$$.ctx[28];
2816
+ return this.$$.ctx[31];
2731
2817
  }
2732
2818
 
2733
2819
  get unselect() {
2734
- return this.$$.ctx[29];
2820
+ return this.$$.ctx[32];
2735
2821
  }
2736
2822
 
2737
2823
  get dateFromPoint() {
2738
- return this.$$.ctx[30];
2824
+ return this.$$.ctx[33];
2739
2825
  }
2740
2826
 
2741
2827
  get destroy() {
2742
- return this.$$.ctx[31];
2828
+ return this.$$.ctx[34];
2829
+ }
2830
+
2831
+ get next() {
2832
+ return this.$$.ctx[35];
2833
+ }
2834
+
2835
+ get prev() {
2836
+ return this.$$.ctx[36];
2743
2837
  }
2744
2838
  }
2745
2839
 
2746
- 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, 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, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, runReposition, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, task, themeView, timelineView, toEventWithLocalDates, toISOString, toLocalDate, toSeconds, toViewWithLocalDates };
2840
+ 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, 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.0.1",
3
+ "version": "3.1.0",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource & timeline views",
6
6
  "keywords": [
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  import {getContext} from 'svelte';
3
- import {createDate, cloneDate, subtractDay, addDuration, setContent, subtractDuration, setMidnight} from './lib.js';
3
+ import {createDate, cloneDate, setContent, setMidnight, nextDate, prevDate} from './lib.js';
4
4
 
5
5
  export let buttons;
6
6
 
@@ -11,17 +11,11 @@
11
11
  $: isToday = today >= $_currentRange.start && today < $_currentRange.end || null;
12
12
 
13
13
  function prev() {
14
- let d = subtractDuration($date, $duration);
15
- if ($hiddenDays.length && $hiddenDays.length < 7) {
16
- while ($hiddenDays.includes(d.getUTCDay())) {
17
- subtractDay(d);
18
- }
19
- }
20
- $date = d;
14
+ $date = prevDate($date, $duration, $hiddenDays);
21
15
  }
22
16
 
23
17
  function next() {
24
- $date = addDuration($date, $duration);
18
+ $date = nextDate($date, $duration);
25
19
  }
26
20
  </script>
27
21
 
@@ -18,7 +18,7 @@
18
18
  flushDebounce,
19
19
  hasYScroll,
20
20
  listView,
21
- task
21
+ task, prevDate, nextDate
22
22
  } from './lib.js';
23
23
 
24
24
  export let plugins = [];
@@ -29,7 +29,8 @@
29
29
  let state = new State(plugins, options);
30
30
  setContext('state', state);
31
31
 
32
- let {_viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _queue2, _tasks, _scrollable, height, theme, view} = state;
32
+ let {_viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _queue2, _tasks, _scrollable,
33
+ date, duration, hiddenDays, height, theme, view} = state;
33
34
 
34
35
  // Reactively update options that did change
35
36
  let prevOptions = {...options};
@@ -96,9 +97,7 @@
96
97
  }
97
98
 
98
99
  export function unselect() {
99
- if ($_interaction.action) {
100
- $_interaction.action.unselect();
101
- }
100
+ $_interaction.action?.unselect();
102
101
  return this;
103
102
  }
104
103
 
@@ -111,6 +110,16 @@
111
110
  destroy_component(component, true);
112
111
  }
113
112
 
113
+ export function next() {
114
+ $date = nextDate($date, $duration);
115
+ return this;
116
+ }
117
+
118
+ export function prev() {
119
+ $date = prevDate($date, $duration, $hiddenDays);
120
+ return this;
121
+ }
122
+
114
123
  beforeUpdate(() => {
115
124
  flushDebounce($_queue);
116
125
  });
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import {getContext} from 'svelte';
3
+ import {keys} from './lib.js';
3
4
  import Buttons from './Buttons.svelte';
4
5
 
5
6
  let {headerToolbar, theme} = getContext('state');
@@ -11,15 +12,15 @@
11
12
  };
12
13
 
13
14
  $: {
14
- for (let key of Object.keys(sections)) {
15
+ for (let key of keys(sections)) {
15
16
  sections[key] = $headerToolbar[key].split(' ').map(group => group.split(','));
16
17
  }
17
18
  }
18
19
  </script>
19
20
 
20
21
  <nav class="{$theme.toolbar}">
21
- {#each Object.keys(sections) as key}
22
- <div>
22
+ {#each keys(sections) as key}
23
+ <div class="ec-{key}">
23
24
  {#each sections[key] as buttons}
24
25
  {#if buttons.length > 1}
25
26
  <div class="{$theme.buttonGroup}">
package/src/lib/date.js CHANGED
@@ -130,6 +130,27 @@ export function toSeconds(duration, defaultValue = 0) {
130
130
  return duration?.seconds ?? defaultValue;
131
131
  }
132
132
 
133
+ /**
134
+ * Move the date forward (when pressing the next button)
135
+ */
136
+ export function nextDate(date, duration) {
137
+ addDuration(date, duration);
138
+ return date;
139
+ }
140
+
141
+ /**
142
+ * Move the date backward (when pressing the prev button)
143
+ */
144
+ export function prevDate(date, duration, hiddenDays) {
145
+ subtractDuration(date, duration);
146
+ if (hiddenDays.length && hiddenDays.length < 7) {
147
+ while (hiddenDays.includes(date.getUTCDay())) {
148
+ subtractDay(date);
149
+ }
150
+ }
151
+ return date;
152
+ }
153
+
133
154
  /**
134
155
  * Private functions
135
156
  */
@@ -0,0 +1,9 @@
1
+ export function createResources(input) {
2
+ return input.map(resource => ({
3
+ id: String(resource.id),
4
+ title: resource.title || '',
5
+ titleHTML: resource.titleHTML || '',
6
+ eventBackgroundColor: resource.eventBackgroundColor,
7
+ eventTextColor: resource.eventTextColor
8
+ }));
9
+ }
package/src/lib/stores.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {derived} from 'svelte/store';
2
2
  import {is_function} from 'svelte/internal';
3
3
  import {toLocalDate} from './date';
4
+ import {createResources} from './resources.js';
4
5
 
5
6
  export function intl(locale, format) {
6
7
  return derived([locale, format], ([$locale, $format]) => {
@@ -61,3 +62,34 @@ function _getParts(source, parts) {
61
62
  }
62
63
  return result;
63
64
  }
65
+
66
+ export function viewResources(state) {
67
+ return derived(
68
+ [state.resources, state.filterResourcesWithEvents, state._events, state._activeRange],
69
+ ([$resources, $filterResourcesWithEvents, $_events, $_activeRange]) => {
70
+ let result = $resources;
71
+
72
+ if ($filterResourcesWithEvents) {
73
+ result = $resources.filter(resource => {
74
+ for (let event of $_events) {
75
+ if (
76
+ event.display !== 'background' &&
77
+ event.resourceIds.includes(resource.id) &&
78
+ event.start < $_activeRange.end &&
79
+ event.end > $_activeRange.start
80
+ ) {
81
+ return true;
82
+ }
83
+ }
84
+ return false;
85
+ });
86
+ }
87
+
88
+ if (!result.length) {
89
+ result = createResources([{}]);
90
+ }
91
+
92
+ return result;
93
+ }
94
+ );
95
+ }
package/src/lib/times.js CHANGED
@@ -3,7 +3,7 @@ import {addDuration, cloneDate, createDuration, DAY_IN_SECONDS, toISOString, toS
3
3
  import {max as maxFn, min as minFn} from './utils.js';
4
4
  import {bgEvent} from './events.js';
5
5
 
6
- export function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel, $_intlDayHeaderAL) {
6
+ export function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLabel) {
7
7
  date = cloneDate(date);
8
8
  let compact = $slotDuration.seconds < 3600;
9
9
  let times = [];
@@ -15,8 +15,7 @@ export function createTimes(date, $slotDuration, $_slotTimeLimits, $_intlSlotLab
15
15
  times.push([
16
16
  toISOString(date),
17
17
  $_intlSlotLabel.format(date),
18
- times.length && (i || !compact),
19
- $_intlDayHeaderAL && $_intlDayHeaderAL.format(date)
18
+ times.length && (i || !compact)
20
19
  ]);
21
20
  addDuration(date, $slotDuration);
22
21
  i = 1 - i;
package/src/lib.js CHANGED
@@ -5,6 +5,7 @@ export * from './lib/debounce.js';
5
5
  export * from './lib/dom.js';
6
6
  export * from './lib/events.js';
7
7
  export * from './lib/options.js';
8
+ export * from './lib/resources.js';
8
9
  export * from './lib/stores.js';
9
10
  export * from './lib/times.js';
10
11
  export * from './lib/utils.js';
@@ -1,4 +1,13 @@
1
- import {assign, createDate, createDuration, keys, setMidnight, createEvents, createEventSources} from '../lib.js';
1
+ import {
2
+ assign,
3
+ createDate,
4
+ createDuration,
5
+ keys,
6
+ setMidnight,
7
+ createEvents,
8
+ createEventSources,
9
+ createResources
10
+ } from '../lib.js';
2
11
 
3
12
  export function createOptions(plugins) {
4
13
  let options = {
@@ -16,7 +25,7 @@ export function createOptions(plugins) {
16
25
  day: 'numeric'
17
26
  },
18
27
  dayHeaderAriaLabelFormat: {
19
- dateStyle: 'long'
28
+ dateStyle: 'full'
20
29
  },
21
30
  displayEventEnd: true,
22
31
  duration: {weeks: 1},
@@ -36,6 +45,7 @@ export function createOptions(plugins) {
36
45
  hour: 'numeric',
37
46
  minute: '2-digit'
38
47
  },
48
+ filterResourcesWithEvents: false,
39
49
  firstDay: 0,
40
50
  flexibleSlotTimeLimits: false, // ec option
41
51
  headerToolbar: {
@@ -64,7 +74,7 @@ export function createOptions(plugins) {
64
74
  },
65
75
  slotMaxTime: '24:00:00',
66
76
  slotMinTime: '00:00:00',
67
- slotWidth: 52,
77
+ slotWidth: 72,
68
78
  theme: {
69
79
  allDay: 'ec-all-day',
70
80
  active: 'ec-active',
@@ -130,6 +140,7 @@ export function createParsers(plugins) {
130
140
  eventSources: createEventSources,
131
141
  hiddenDays: days => [...new Set(days)],
132
142
  highlightedDates: dates => dates.map(createDate),
143
+ resources: createResources,
133
144
  scrollTime: createDuration,
134
145
  slotDuration: createDuration,
135
146
  slotMaxTime: createDuration,
@@ -5,6 +5,7 @@ import {
5
5
  activeRange,
6
6
  currentRange,
7
7
  dayGrid,
8
+ monthView,
8
9
  events,
9
10
  now,
10
11
  today,
@@ -37,6 +38,7 @@ export default class {
37
38
  this._tasks = new Map(); // timeout IDs for tasks
38
39
  this._auxiliary = writable([]); // auxiliary components
39
40
  this._dayGrid = dayGrid(this);
41
+ this._monthView = monthView(this);
40
42
  this._currentRange = currentRange(this);
41
43
  this._activeRange = activeRange(this);
42
44
  this._fetchedRange = writable({start: undefined, end: undefined});
@@ -22,6 +22,10 @@ export function dayGrid(state) {
22
22
  return derived(state.view, $view => $view?.startsWith('dayGrid'));
23
23
  }
24
24
 
25
+ export function monthView(state) {
26
+ return derived(state.view, $view => $view?.includes('Month'));
27
+ }
28
+
25
29
  export function activeRange(state) {
26
30
  return derived(
27
31
  [state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
@@ -48,10 +52,10 @@ export function activeRange(state) {
48
52
 
49
53
  export function currentRange(state) {
50
54
  return derived(
51
- [state.date, state.duration, state.firstDay, state._dayGrid],
52
- ([$date, $duration, $firstDay, $_dayGrid]) => {
55
+ [state.date, state.duration, state.firstDay, state._monthView],
56
+ ([$date, $duration, $firstDay, $_monthView]) => {
53
57
  let start = cloneDate($date), end;
54
- if ($_dayGrid) {
58
+ if ($_monthView) {
55
59
  start.setUTCDate(1);
56
60
  } else if ($duration.inWeeks) {
57
61
  // First day of week
@@ -140,7 +140,6 @@
140
140
  .ec-body,
141
141
  .ec-days,
142
142
  .ec-day,
143
- .ec-times,
144
143
  .ec-day-head {
145
144
  border: 1px solid var(--ec-border-color);
146
145
  }
@@ -64,24 +64,26 @@
64
64
 
65
65
  .ec-times {
66
66
  display: flex;
67
- border-style: solid none none;
67
+ border-top: 1px solid var(--ec-border-color);;
68
68
  }
69
69
 
70
70
  .ec-time {
71
71
  border-left: 1px solid var(--ec-border-color);
72
72
  box-sizing: border-box;
73
+ font-size: .95em;
73
74
  min-height: 24px;
74
75
  overflow: hidden;
75
76
  text-overflow: ellipsis;
76
77
  }
77
78
 
78
79
  .ec-time, .ec-line {
79
- width: 52px;
80
+ width: 72px;
80
81
  }
81
82
 
82
83
  .ec-events {
83
84
  position: relative;
84
85
  height: 100%;
86
+ margin: 0;
85
87
  }
86
88
 
87
89
  .ec-event {
@@ -117,6 +119,7 @@
117
119
  .ec-sidebar-title {
118
120
  flex-shrink: 0;
119
121
  border-bottom: 1px solid var(--ec-border-color);
122
+ box-sizing: content-box;
120
123
  }
121
124
 
122
125
  .ec-content {