@event-calendar/core 2.0.0 → 2.2.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
@@ -26,6 +26,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
26
26
  - [dateClick](#dateclick)
27
27
  - [datesAboveResources](#datesaboveresources)
28
28
  - [datesSet](#datesset)
29
+ - [dayCellFormat](#daycellformat)
29
30
  - [dayHeaderFormat](#dayheaderformat)
30
31
  - [dayMaxEvents](#daymaxevents)
31
32
  - [dayPopoverFormat](#daypopoverformat)
@@ -44,9 +45,9 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
44
45
  - [eventDragStart](#eventdragstart)
45
46
  - [eventDragStop](#eventdragstop)
46
47
  - [eventDrop](#eventdrop)
47
- - [eventDurationEditable](#eventdurationeditable)
48
48
  </td><td>
49
49
 
50
+ - [eventDurationEditable](#eventdurationeditable)
50
51
  - [eventLongPressDelay](#eventlongpressdelay)
51
52
  - [eventMouseEnter](#eventmouseenter)
52
53
  - [eventMouseLeave](#eventmouseleave)
@@ -72,9 +73,9 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
72
73
  - [longPressDelay](#longpressdelay)
73
74
  - [moreLinkContent](#morelinkcontent)
74
75
  - [noEventsClick](#noeventsclick)
75
- - [noEventsContent](#noeventscontent)
76
76
  </td><td>
77
77
 
78
+ - [noEventsContent](#noeventscontent)
78
79
  - [nowIndicator](#nowindicator)
79
80
  - [pointer](#pointer)
80
81
  - [resources](#resources)
@@ -124,6 +125,7 @@ Inspired by [FullCalendar](https://fullcalendar.io/), implements similar options
124
125
  - [unselect](#unselect-1)
125
126
  </td></tr>
126
127
  </table>
128
+ - [Content](#content)
127
129
  - [Event object](#event-object)
128
130
  - [Parsing event from a plain object](#parsing-event-from-a-plain-object)
129
131
  - [Duration object](#duration-object)
@@ -194,8 +196,8 @@ import '@event-calendar/core/index.css';
194
196
  ### Pre-built browser ready bundle
195
197
  Include the following lines of code in the `<head>` section of your page:
196
198
  ```html
197
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.0.0/event-calendar.min.css">
198
- <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.0.0/event-calendar.min.js"></script>
199
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.2.0/event-calendar.min.css">
200
+ <script src="https://cdn.jsdelivr.net/npm/@event-calendar/build@2.2.0/event-calendar.min.js"></script>
199
201
  ```
200
202
 
201
203
  <details>
@@ -286,15 +288,15 @@ When hidden with `false`, all-day events will not be displayed in `timeGrid`/`re
286
288
  - Type `object` or `function`
287
289
  - Default `{close: 'Close', dayGridMonth: 'month', listDay: 'list', listMonth: 'list', listWeek: 'list', listYear: 'list', resourceTimeGridDay: 'day', resourceTimeGridWeek: 'week', timeGridDay: 'day', timeGridWeek: 'week', today: 'today'}`
288
290
  > Views override the default value as follows:
289
- > - dayGridMonth `function (text) { return {...text, next: 'Next month', prev: 'Previous month'}; }`
290
- > - listDay `function (text) { return {...text, next: 'Next day', prev: 'Previous day'}; }`
291
- > - listMonth `function (text) { return {...text, next: 'Next month', prev: 'Previous month'}; }`
292
- > - listWeek `function (text) { return {...text, next: 'Next week', prev: 'Previous week'}; }`
293
- > - listYear `function (text) { return {...text, next: 'Next year', prev: 'Previous year'}; }`
294
- > - resourceTimeGridDay `function (text) { return {...text, next: 'Next day', prev: 'Previous day'}; }`
295
- > - resourceTimeGridWeek `function (text) { return {...text, next: 'Next week', prev: 'Previous week'}; }`
296
- > - timeGridDay `function (text) { return {...text, next: 'Next day', prev: 'Previous day'}; }`
297
- > - timeGridWeek `function (text) { return {...text, next: 'Next week', prev: 'Previous week'}; }`
291
+ > - dayGridMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
292
+ > - listDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
293
+ > - listMonth `text => ({...text, next: 'Next month', prev: 'Previous month'})`
294
+ > - listWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
295
+ > - listYear `text => ({...text, next: 'Next year', prev: 'Previous year'})`
296
+ > - resourceTimeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
297
+ > - resourceTimeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
298
+ > - timeGridDay `text => ({...text, next: 'Next day', prev: 'Previous day'})`
299
+ > - timeGridWeek `text => ({...text, next: 'Next week', prev: 'Previous week'})`
298
300
 
299
301
 
300
302
  Text that is displayed in buttons of the header toolbar.
@@ -452,6 +454,29 @@ The current [View](#view-object) object
452
454
  </tr>
453
455
  </table>
454
456
 
457
+ ### dayCellFormat
458
+ - Type `object` or `function`
459
+ - Default `{day: 'numeric'}`
460
+
461
+ Defines the text that is displayed inside the day cell in the `dayGrid` view.
462
+
463
+ This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with the formatted string:
464
+
465
+ ```js
466
+ function (date) {
467
+ // return Content with the formatted date string
468
+ }
469
+ ```
470
+ <table>
471
+ <tr>
472
+ <td>
473
+
474
+ `date`
475
+ </td>
476
+ <td>JavaScript Date object that needs to be formatted</td>
477
+ </tr>
478
+ </table>
479
+
455
480
  ### dayHeaderFormat
456
481
  - Type `object` or `function`
457
482
  - Default `{weekday: 'short', month: 'numeric', day: 'numeric'}`
@@ -1303,7 +1328,7 @@ Determines whether the events on the calendar can be dragged.
1303
1328
 
1304
1329
  Defines the time-text that is displayed on each event.
1305
1330
 
1306
- This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with formatted string:
1331
+ This value can be either an object with options for the native JavaScript [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat) object, or a callback function that returns a [Content](#content) with the formatted string:
1307
1332
 
1308
1333
  ```js
1309
1334
  function (start, end) {
@@ -1905,7 +1930,17 @@ This should be a value that can be parsed into a [Duration](#duration-object) ob
1905
1930
 
1906
1931
  ### theme
1907
1932
  - Type `object` or `function`
1908
- - Default `{active: 'ec-active', allDay: 'ec-all-day', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', content: 'ec-content', day: 'ec-day', dayFoot: 'ec-day-foot', dayHead: 'ec-day-head', daySide: 'ec-day-side', days: 'ec-days', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines', list: 'ec-list', month: 'ec-month', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', otherMonth: 'ec-other-month', pointer: 'ec-pointer', popup: 'ec-popup', preview: 'ec-preview', resizer: 'ec-resizer', resizingX: 'ec-resizing-x', resizingY: 'ec-resizing-y', resource: 'ec-resource', resourceTitle: 'ec-resource-title', selecting: 'ec-selecting', sidebar: 'ec-sidebar', sidebarTitle: 'ec-sidebar-title', time: 'ec-time', title: 'ec-title', today: 'ec-today', toolbar: 'ec-toolbar', uniform: 'ec-uniform', week: 'ec-week', withScroll: 'ec-with-scroll'}`
1933
+ - Default `{active: 'ec-active', allDay: 'ec-all-day', bgEvent: 'ec-bg-event', bgEvents: 'ec-bg-events', body: 'ec-body', button: 'ec-button', buttonGroup: 'ec-button-group', calendar: 'ec', compact: 'ec-compact', content: 'ec-content', day: 'ec-day', dayFoot: 'ec-day-foot', dayHead: 'ec-day-head', daySide: 'ec-day-side', days: 'ec-days', draggable: 'ec-draggable', dragging: 'ec-dragging', event: 'ec-event', eventBody: 'ec-event-body', eventTag: 'ec-event-tag', eventTime: 'ec-event-time', eventTitle: 'ec-event-title', events: 'ec-events', extra: 'ec-extra', ghost: 'ec-ghost', handle: 'ec-handle', header: 'ec-header', hiddenScroll: 'ec-hidden-scroll', highlight: 'ec-highlight', icon: 'ec-icon', line: 'ec-line', lines: 'ec-lines', noEvents: 'ec-no-events', nowIndicator: 'ec-now-indicator', otherMonth: 'ec-other-month', pointer: 'ec-pointer', popup: 'ec-popup', preview: 'ec-preview', resizer: 'ec-resizer', resizingX: 'ec-resizing-x', resizingY: 'ec-resizing-y', resource: 'ec-resource', resourceTitle: 'ec-resource-title', selecting: 'ec-selecting', sidebar: 'ec-sidebar', sidebarTitle: 'ec-sidebar-title', time: 'ec-time', title: 'ec-title', today: 'ec-today', toolbar: 'ec-toolbar', uniform: 'ec-uniform', view: '', withScroll: 'ec-with-scroll'}`
1934
+ > Views override the default value as follows:
1935
+ > - dayGridMonth `theme => ({...theme, view: 'ec-day-grid ec-month-view'})`
1936
+ > - listDay `theme => ({...theme, view: 'ec-list ec-day-view'})`
1937
+ > - listMonth `theme => ({...theme, view: 'ec-list ec-month-view'})`
1938
+ > - listWeek `theme => ({...theme, view: 'ec-list ec-week-view'})`
1939
+ > - listYear `theme => ({...theme, view: 'ec-list ec-year-view'})`
1940
+ > - resourceTimeGridDay `theme => ({...theme, view: 'ec-time-grid ec-resource-day-view'})`
1941
+ > - resourceTimeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-resource-week-view'})`
1942
+ > - timeGridDay `theme => ({...theme, view: 'ec-time-grid ec-day-view'})`
1943
+ > - timeGridWeek `theme => ({...theme, view: 'ec-time-grid ec-week-view'})`
1909
1944
 
1910
1945
  Defines the CSS classes that the Event Calendar uses to generate HTML markup.
1911
1946
 
@@ -1959,16 +1994,6 @@ function (start, end) {
1959
1994
  </tr>
1960
1995
  </table>
1961
1996
 
1962
- The callback function can return HTML markup. If you want to use HTML entities in the title, you must use the callback function:
1963
-
1964
- ```js
1965
- function (date) {
1966
- let month = date.toLocaleDateString('en-US', { month: 'long' })
1967
- let year = date.toLocaleDateString('en-US', { year: 'numeric' })
1968
- return `<span class="month">${month}</span> <span class="year">${year}</span>`
1969
- }
1970
- ```
1971
-
1972
1997
  ### unselect
1973
1998
  - Type `function`
1974
1999
  - Default `undefined`
package/index.css CHANGED
@@ -161,7 +161,7 @@
161
161
  .ec:not(.ec-list) .ec-body {
162
162
  border-top: none;
163
163
  }
164
- .ec-month .ec-body {
164
+ .ec-day-grid .ec-body {
165
165
  flex: 1 1 auto;
166
166
  }
167
167
 
@@ -190,11 +190,11 @@
190
190
  .ec-content {
191
191
  display: flex;
192
192
  }
193
- .ec-month .ec-content {
193
+ .ec-day-grid .ec-content {
194
194
  flex-direction: column;
195
195
  height: 100%;
196
196
  }
197
- .ec-month .ec-uniform .ec-content {
197
+ .ec-day-grid .ec-uniform .ec-content {
198
198
  overflow: hidden;
199
199
  }
200
200
  .ec-list .ec-content {
@@ -212,10 +212,10 @@
212
212
  .ec-days:last-child {
213
213
  border-bottom: none;
214
214
  }
215
- .ec-month .ec-days, .ec-resource .ec-days {
215
+ .ec-day-grid .ec-days, .ec-resource .ec-days {
216
216
  flex: 1 0 auto;
217
217
  }
218
- .ec-month .ec-uniform .ec-days {
218
+ .ec-day-grid .ec-uniform .ec-days {
219
219
  flex: 1 1 0%;
220
220
  min-height: 0;
221
221
  }
@@ -229,14 +229,14 @@
229
229
  .ec-day.ec-highlight {
230
230
  background-color: #e5f7fe;
231
231
  }
232
- .ec-month .ec-body .ec-day {
232
+ .ec-day-grid .ec-body .ec-day {
233
233
  min-height: 5em;
234
234
  position: relative;
235
235
  }
236
- .ec-month .ec-uniform .ec-day {
236
+ .ec-day-grid .ec-uniform .ec-day {
237
237
  min-height: 0;
238
238
  }
239
- .ec-month .ec-day:first-child {
239
+ .ec-day-grid .ec-day:first-child {
240
240
  border-left: none;
241
241
  }
242
242
  .ec-day.ec-other-month .ec-day-head {
@@ -256,17 +256,17 @@
256
256
  border-top: none;
257
257
  }
258
258
 
259
- .ec-month .ec-day-head {
259
+ .ec-day-grid .ec-day-head {
260
260
  text-align: right;
261
261
  padding: 4px 4px 3px;
262
262
  }
263
- .ec-month .ec-day-foot {
263
+ .ec-day-grid .ec-day-foot {
264
264
  position: absolute;
265
265
  bottom: 0;
266
266
  padding: 2px;
267
267
  font-size: 0.85em;
268
268
  }
269
- .ec-month .ec-day-foot a {
269
+ .ec-day-grid .ec-day-foot a {
270
270
  cursor: pointer;
271
271
  }
272
272
 
@@ -281,7 +281,7 @@
281
281
  .ec-events {
282
282
  margin: 0 6px 0 0;
283
283
  }
284
- .ec-week .ec-events, .ec-events.ec-preview {
284
+ .ec-time-grid .ec-events, .ec-events.ec-preview {
285
285
  position: relative;
286
286
  }
287
287
 
@@ -297,10 +297,10 @@
297
297
  line-height: 1.5;
298
298
  z-index: 1;
299
299
  }
300
- .ec-month .ec-event, .ec-all-day .ec-event {
300
+ .ec-day-grid .ec-event, .ec-all-day .ec-event {
301
301
  position: relative;
302
302
  }
303
- .ec-week .ec-body .ec-event {
303
+ .ec-time-grid .ec-body .ec-event {
304
304
  position: absolute;
305
305
  }
306
306
  .ec-list .ec-event {
@@ -335,7 +335,7 @@
335
335
  flex-direction: column;
336
336
  width: 100%;
337
337
  }
338
- .ec-month .ec-event-body, .ec-all-day .ec-event-body {
338
+ .ec-day-grid .ec-event-body, .ec-all-day .ec-event-body {
339
339
  flex-direction: row;
340
340
  }
341
341
 
@@ -351,7 +351,7 @@
351
351
  margin: 0 0 1px 0;
352
352
  flex-shrink: 0;
353
353
  }
354
- .ec-month .ec-event-time {
354
+ .ec-day-grid .ec-event-time {
355
355
  margin: 0 3px 0 0;
356
356
  max-width: 100%;
357
357
  text-overflow: ellipsis;
@@ -360,12 +360,12 @@
360
360
  .ec-event-title {
361
361
  overflow: hidden;
362
362
  }
363
- .ec-month .ec-event-title, .ec-all-day .ec-event-title {
363
+ .ec-day-grid .ec-event-title, .ec-all-day .ec-event-title {
364
364
  min-height: 1.5em;
365
365
  white-space: nowrap;
366
366
  text-overflow: ellipsis;
367
367
  }
368
- .ec-week .ec-body .ec-event-title {
368
+ .ec-time-grid .ec-body .ec-event-title {
369
369
  position: sticky;
370
370
  top: 0;
371
371
  }
@@ -489,7 +489,7 @@
489
489
  position: absolute;
490
490
  user-select: none;
491
491
  }
492
- .ec-month .ec-resizer, .ec-all-day .ec-resizer {
492
+ .ec-day-grid .ec-resizer, .ec-all-day .ec-resizer {
493
493
  top: 0;
494
494
  right: 0;
495
495
  bottom: 0;
@@ -497,7 +497,7 @@
497
497
  max-width: 8px;
498
498
  cursor: ew-resize;
499
499
  }
500
- .ec-week .ec-body .ec-resizer {
500
+ .ec-time-grid .ec-body .ec-resizer {
501
501
  left: 0;
502
502
  right: 0;
503
503
  bottom: 0;
package/index.js CHANGED
@@ -8,30 +8,6 @@ function keyEnter(fn) {
8
8
  };
9
9
  }
10
10
 
11
- function btnTextDay(text) {
12
- return btnText(text, 'day');
13
- }
14
-
15
- function btnTextWeek(text) {
16
- return btnText(text, 'week');
17
- }
18
-
19
- function btnTextMonth(text) {
20
- return btnText(text, 'month');
21
- }
22
-
23
- function btnTextYear(text) {
24
- return btnText(text, 'year');
25
- }
26
-
27
- function btnText(text, period) {
28
- return {
29
- ...text,
30
- next: 'Next ' + period,
31
- prev: 'Previous ' + period
32
- };
33
- }
34
-
35
11
  function setContent(node, content) {
36
12
  let actions = {
37
13
  update(content) {
@@ -569,6 +545,34 @@ function pointerEvent(display) {
569
545
  return display === 'pointer';
570
546
  }
571
547
 
548
+ function btnTextDay(text) {
549
+ return btnText(text, 'day');
550
+ }
551
+
552
+ function btnTextWeek(text) {
553
+ return btnText(text, 'week');
554
+ }
555
+
556
+ function btnTextMonth(text) {
557
+ return btnText(text, 'month');
558
+ }
559
+
560
+ function btnTextYear(text) {
561
+ return btnText(text, 'year');
562
+ }
563
+
564
+ function btnText(text, period) {
565
+ return {
566
+ ...text,
567
+ next: 'Next ' + period,
568
+ prev: 'Previous ' + period
569
+ };
570
+ }
571
+
572
+ function themeView(view) {
573
+ return theme => ({...theme, view});
574
+ }
575
+
572
576
  function writable2(value, parser, start) {
573
577
  return {
574
578
  ...writable(value, start),
@@ -710,7 +714,7 @@ function createOptions(plugins) {
710
714
  time: 'ec-time',
711
715
  title: 'ec-title',
712
716
  toolbar: 'ec-toolbar',
713
- week: 'ec-week',
717
+ view: '',
714
718
  withScroll: 'ec-with-scroll'
715
719
  },
716
720
  titleFormat: {
@@ -730,9 +734,8 @@ function createOptions(plugins) {
730
734
  return options;
731
735
  }
732
736
 
733
- function createParsers(options, plugins) {
737
+ function createParsers(plugins) {
734
738
  let parsers = {
735
- buttonText: input => is_function(input) ? input(options.buttonText) : input,
736
739
  date: date => setMidnight(createDate(date)),
737
740
  duration: createDuration,
738
741
  events: createEvents,
@@ -742,12 +745,11 @@ function createParsers(options, plugins) {
742
745
  scrollTime: createDuration,
743
746
  slotDuration: createDuration,
744
747
  slotMaxTime: createDuration,
745
- slotMinTime: createDuration,
746
- theme: input => is_function(input) ? input(options.theme) : input
748
+ slotMinTime: createDuration
747
749
  };
748
750
 
749
751
  for (let plugin of plugins) {
750
- plugin.createParsers?.(parsers, options);
752
+ plugin.createParsers?.(parsers);
751
753
  }
752
754
 
753
755
  return parsers;
@@ -768,18 +770,18 @@ function diff(options) {
768
770
  return diff;
769
771
  }
770
772
 
771
- function monthMode(state) {
773
+ function dayGrid(state) {
772
774
  return derived(state.view, $view => $view?.startsWith('dayGrid'));
773
775
  }
774
776
 
775
777
  function activeRange(state) {
776
778
  return derived(
777
- [state._currentRange, state.firstDay, state.slotMaxTime, state._monthMode],
778
- ([$_currentRange, $firstDay, $slotMaxTime, $_monthMode]) => {
779
+ [state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
780
+ ([$_currentRange, $firstDay, $slotMaxTime, $_dayGrid]) => {
779
781
  let start = cloneDate($_currentRange.start);
780
782
  let end = cloneDate($_currentRange.end);
781
783
 
782
- if ($_monthMode) {
784
+ if ($_dayGrid) {
783
785
  // First day of week
784
786
  prevClosestDay(start, $firstDay);
785
787
  nextClosestDay(end, $firstDay);
@@ -798,10 +800,10 @@ function activeRange(state) {
798
800
 
799
801
  function currentRange(state) {
800
802
  return derived(
801
- [state.date, state.duration, state.firstDay, state._monthMode],
802
- ([$date, $duration, $firstDay, $_monthMode]) => {
803
+ [state.date, state.duration, state.firstDay, state._dayGrid],
804
+ ([$date, $duration, $firstDay, $_dayGrid]) => {
803
805
  let start = cloneDate($date), end;
804
- if ($_monthMode) {
806
+ if ($_dayGrid) {
805
807
  start.setUTCDate(1);
806
808
  } else if ($duration.inWeeks) {
807
809
  // First day of week
@@ -842,9 +844,9 @@ function viewDates(state) {
842
844
 
843
845
  function viewTitle(state) {
844
846
  return derived(
845
- [state.date, state._activeRange, state._intlTitle, state._monthMode],
846
- ([$date, $_activeRange, $_intlTitle, $_monthMode]) => {
847
- return $_monthMode
847
+ [state.date, state._activeRange, state._intlTitle, state._dayGrid],
848
+ ([$date, $_activeRange, $_intlTitle, $_dayGrid]) => {
849
+ return $_dayGrid
848
850
  ? $_intlTitle.formatRange($date, $date)
849
851
  : $_intlTitle.formatRange($_activeRange.start, subtractDay(cloneDate($_activeRange.end)));
850
852
  }
@@ -962,8 +964,8 @@ class State {
962
964
  plugins = plugins || [];
963
965
 
964
966
  // Create options
965
- let options= createOptions(plugins);
966
- let parsers = createParsers(options, plugins);
967
+ let options = createOptions(plugins);
968
+ let parsers = createParsers(plugins);
967
969
 
968
970
  // Parse options
969
971
  options = parseOpts(options, parsers);
@@ -977,7 +979,7 @@ class State {
977
979
  // Private stores
978
980
  this._queue = writable(new Map()); // debounce queue
979
981
  this._auxiliary = writable([]); // auxiliary components
980
- this._monthMode = monthMode(this);
982
+ this._dayGrid = dayGrid(this);
981
983
  this._currentRange = currentRange(this);
982
984
  this._activeRange = activeRange(this);
983
985
  this._fetchedRange = writable({start: undefined, end: undefined});
@@ -993,7 +995,6 @@ class State {
993
995
  this._viewTitle = viewTitle(this);
994
996
  this._viewDates = viewDates(this);
995
997
  this._view = view(this);
996
- this._viewClass = writable(undefined);
997
998
  this._viewComponent = writable(undefined);
998
999
  // Resources
999
1000
  this._resBgColor = writable(noop);
@@ -1017,7 +1018,7 @@ class State {
1017
1018
  // Set options for each view
1018
1019
  let views = new Set([...keys(options.views), ...keys(input.views ?? {})]);
1019
1020
  for (let view of views) {
1020
- let opts = assign({}, options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
1021
+ let opts = mergeOpts(options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
1021
1022
  // Change view component when view changes
1022
1023
  this.view.subscribe(newView => {
1023
1024
  if (newView === view) {
@@ -1069,6 +1070,17 @@ function parseOpts(opts, parsers) {
1069
1070
  return result;
1070
1071
  }
1071
1072
 
1073
+ function mergeOpts(...args) {
1074
+ let mergable = ['buttonText', 'theme'];
1075
+ let result = {};
1076
+ for (let opts of args) {
1077
+ for (let key of keys(opts)) {
1078
+ result[key] = mergable.includes(key) && is_function(opts[key]) ? opts[key](result[key]) : opts[key];
1079
+ }
1080
+ }
1081
+ return result;
1082
+ }
1083
+
1072
1084
  /* packages/core/src/Buttons.svelte generated by Svelte v4.1.1 */
1073
1085
 
1074
1086
  function get_each_context$2(ctx, list, i) {
@@ -1077,7 +1089,7 @@ function get_each_context$2(ctx, list, i) {
1077
1089
  return child_ctx;
1078
1090
  }
1079
1091
 
1080
- // (38:27)
1092
+ // (52:27)
1081
1093
  function create_if_block_4(ctx) {
1082
1094
  let button_1;
1083
1095
  let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[23]] + "";
@@ -1129,7 +1141,7 @@ function create_if_block_4(ctx) {
1129
1141
  };
1130
1142
  }
1131
1143
 
1132
- // (36:32)
1144
+ // (46:32)
1133
1145
  function create_if_block_3(ctx) {
1134
1146
  let button_1;
1135
1147
  let t_value = /*$buttonText*/ ctx[5][/*button*/ ctx[23]] + "";
@@ -1176,13 +1188,14 @@ function create_if_block_3(ctx) {
1176
1188
  };
1177
1189
  }
1178
1190
 
1179
- // (34:31)
1191
+ // (39:31)
1180
1192
  function create_if_block_2(ctx) {
1181
1193
  let button_1;
1182
1194
  let i;
1183
1195
  let i_class_value;
1184
1196
  let button_1_class_value;
1185
1197
  let button_1_aria_label_value;
1198
+ let button_1_title_value;
1186
1199
  let mounted;
1187
1200
  let dispose;
1188
1201
 
@@ -1193,6 +1206,7 @@ function create_if_block_2(ctx) {
1193
1206
  attr(i, "class", i_class_value = "" + (/*$theme*/ ctx[3].icon + " ec-" + /*button*/ ctx[23]));
1194
1207
  attr(button_1, "class", button_1_class_value = "" + (/*$theme*/ ctx[3].button + " ec-" + /*button*/ ctx[23]));
1195
1208
  attr(button_1, "aria-label", button_1_aria_label_value = /*$buttonText*/ ctx[5].next);
1209
+ attr(button_1, "title", button_1_title_value = /*$buttonText*/ ctx[5].next);
1196
1210
  },
1197
1211
  m(target, anchor) {
1198
1212
  insert(target, button_1, anchor);
@@ -1215,6 +1229,10 @@ function create_if_block_2(ctx) {
1215
1229
  if (dirty & /*$buttonText*/ 32 && button_1_aria_label_value !== (button_1_aria_label_value = /*$buttonText*/ ctx[5].next)) {
1216
1230
  attr(button_1, "aria-label", button_1_aria_label_value);
1217
1231
  }
1232
+
1233
+ if (dirty & /*$buttonText*/ 32 && button_1_title_value !== (button_1_title_value = /*$buttonText*/ ctx[5].next)) {
1234
+ attr(button_1, "title", button_1_title_value);
1235
+ }
1218
1236
  },
1219
1237
  d(detaching) {
1220
1238
  if (detaching) {
@@ -1234,6 +1252,7 @@ function create_if_block_1(ctx) {
1234
1252
  let i_class_value;
1235
1253
  let button_1_class_value;
1236
1254
  let button_1_aria_label_value;
1255
+ let button_1_title_value;
1237
1256
  let mounted;
1238
1257
  let dispose;
1239
1258
 
@@ -1244,6 +1263,7 @@ function create_if_block_1(ctx) {
1244
1263
  attr(i, "class", i_class_value = "" + (/*$theme*/ ctx[3].icon + " ec-" + /*button*/ ctx[23]));
1245
1264
  attr(button_1, "class", button_1_class_value = "" + (/*$theme*/ ctx[3].button + " ec-" + /*button*/ ctx[23]));
1246
1265
  attr(button_1, "aria-label", button_1_aria_label_value = /*$buttonText*/ ctx[5].prev);
1266
+ attr(button_1, "title", button_1_title_value = /*$buttonText*/ ctx[5].prev);
1247
1267
  },
1248
1268
  m(target, anchor) {
1249
1269
  insert(target, button_1, anchor);
@@ -1266,6 +1286,10 @@ function create_if_block_1(ctx) {
1266
1286
  if (dirty & /*$buttonText*/ 32 && button_1_aria_label_value !== (button_1_aria_label_value = /*$buttonText*/ ctx[5].prev)) {
1267
1287
  attr(button_1, "aria-label", button_1_aria_label_value);
1268
1288
  }
1289
+
1290
+ if (dirty & /*$buttonText*/ 32 && button_1_title_value !== (button_1_title_value = /*$buttonText*/ ctx[5].prev)) {
1291
+ attr(button_1, "title", button_1_title_value);
1292
+ }
1269
1293
  },
1270
1294
  d(detaching) {
1271
1295
  if (detaching) {
@@ -2118,7 +2142,7 @@ function create_fragment(ctx) {
2118
2142
  let mounted;
2119
2143
  let dispose;
2120
2144
  toolbar = new Toolbar({});
2121
- var switch_value = /*$_viewComponent*/ ctx[5];
2145
+ var switch_value = /*$_viewComponent*/ ctx[4];
2122
2146
 
2123
2147
  function switch_props(ctx, dirty) {
2124
2148
  return {};
@@ -2139,15 +2163,13 @@ function create_fragment(ctx) {
2139
2163
  t1 = space();
2140
2164
  create_component(auxiliary.$$.fragment);
2141
2165
 
2142
- attr(div, "class", div_class_value = "" + (/*$theme*/ ctx[1].calendar + (/*$_viewClass*/ ctx[2]
2143
- ? ' ' + /*$theme*/ ctx[1][/*$_viewClass*/ ctx[2]]
2144
- : '') + (/*$_scrollable*/ ctx[0]
2166
+ attr(div, "class", div_class_value = "" + (/*$theme*/ ctx[1].calendar + " " + /*$theme*/ ctx[1].view + (/*$_scrollable*/ ctx[0]
2145
2167
  ? ' ' + /*$theme*/ ctx[1].withScroll
2146
- : '') + (/*$_iClass*/ ctx[3]
2147
- ? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[3]]
2168
+ : '') + (/*$_iClass*/ ctx[2]
2169
+ ? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[2]]
2148
2170
  : '')));
2149
2171
 
2150
- set_style(div, "height", /*$height*/ ctx[4]);
2172
+ set_style(div, "height", /*$height*/ ctx[3]);
2151
2173
  },
2152
2174
  m(target, anchor) {
2153
2175
  insert(target, div, anchor);
@@ -2159,12 +2181,12 @@ function create_fragment(ctx) {
2159
2181
  current = true;
2160
2182
 
2161
2183
  if (!mounted) {
2162
- dispose = listen(window, "resize", /*recheckScrollable*/ ctx[18]);
2184
+ dispose = listen(window, "resize", /*recheckScrollable*/ ctx[16]);
2163
2185
  mounted = true;
2164
2186
  }
2165
2187
  },
2166
2188
  p(ctx, dirty) {
2167
- if (dirty[0] & /*$_viewComponent*/ 32 && switch_value !== (switch_value = /*$_viewComponent*/ ctx[5])) {
2189
+ if (dirty[0] & /*$_viewComponent*/ 16 && switch_value !== (switch_value = /*$_viewComponent*/ ctx[4])) {
2168
2190
  if (switch_instance) {
2169
2191
  group_outros();
2170
2192
  const old_component = switch_instance;
@@ -2186,18 +2208,16 @@ function create_fragment(ctx) {
2186
2208
  }
2187
2209
  }
2188
2210
 
2189
- if (!current || dirty[0] & /*$theme, $_viewClass, $_scrollable, $_iClass*/ 15 && div_class_value !== (div_class_value = "" + (/*$theme*/ ctx[1].calendar + (/*$_viewClass*/ ctx[2]
2190
- ? ' ' + /*$theme*/ ctx[1][/*$_viewClass*/ ctx[2]]
2191
- : '') + (/*$_scrollable*/ ctx[0]
2211
+ if (!current || dirty[0] & /*$theme, $_scrollable, $_iClass*/ 7 && div_class_value !== (div_class_value = "" + (/*$theme*/ ctx[1].calendar + " " + /*$theme*/ ctx[1].view + (/*$_scrollable*/ ctx[0]
2192
2212
  ? ' ' + /*$theme*/ ctx[1].withScroll
2193
- : '') + (/*$_iClass*/ ctx[3]
2194
- ? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[3]]
2213
+ : '') + (/*$_iClass*/ ctx[2]
2214
+ ? ' ' + /*$theme*/ ctx[1][/*$_iClass*/ ctx[2]]
2195
2215
  : '')))) {
2196
2216
  attr(div, "class", div_class_value);
2197
2217
  }
2198
2218
 
2199
- if (!current || dirty[0] & /*$height*/ 16) {
2200
- set_style(div, "height", /*$height*/ ctx[4]);
2219
+ if (dirty[0] & /*$height*/ 8) {
2220
+ set_style(div, "height", /*$height*/ ctx[3]);
2201
2221
  }
2202
2222
  },
2203
2223
  i(local) {
@@ -2237,7 +2257,6 @@ function instance($$self, $$props, $$invalidate) {
2237
2257
  let $eventSources;
2238
2258
  let $_interaction;
2239
2259
  let $theme;
2240
- let $_viewClass;
2241
2260
  let $_iClass;
2242
2261
  let $height;
2243
2262
  let $_viewComponent;
@@ -2246,18 +2265,17 @@ function instance($$self, $$props, $$invalidate) {
2246
2265
  let component = get_current_component();
2247
2266
  let state = new State(plugins, options);
2248
2267
  setContext('state', state);
2249
- let { _viewComponent, _viewClass, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable, events, eventSources, height, theme } = state;
2250
- component_subscribe($$self, _viewComponent, value => $$invalidate(5, $_viewComponent = value));
2251
- component_subscribe($$self, _viewClass, value => $$invalidate(2, $_viewClass = value));
2252
- component_subscribe($$self, _bodyEl, value => $$invalidate(33, $_bodyEl = value));
2253
- component_subscribe($$self, _interaction, value => $$invalidate(38, $_interaction = value));
2254
- component_subscribe($$self, _iClass, value => $$invalidate(3, $_iClass = value));
2255
- component_subscribe($$self, _events, value => $$invalidate(35, $_events = value));
2256
- component_subscribe($$self, _queue, value => $$invalidate(34, $_queue = value));
2268
+ let { _viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable, events, eventSources, height, theme } = state;
2269
+ component_subscribe($$self, _viewComponent, value => $$invalidate(4, $_viewComponent = value));
2270
+ component_subscribe($$self, _bodyEl, value => $$invalidate(31, $_bodyEl = value));
2271
+ component_subscribe($$self, _interaction, value => $$invalidate(36, $_interaction = value));
2272
+ component_subscribe($$self, _iClass, value => $$invalidate(2, $_iClass = value));
2273
+ component_subscribe($$self, _events, value => $$invalidate(33, $_events = value));
2274
+ component_subscribe($$self, _queue, value => $$invalidate(32, $_queue = value));
2257
2275
  component_subscribe($$self, _scrollable, value => $$invalidate(0, $_scrollable = value));
2258
- component_subscribe($$self, events, value => $$invalidate(36, $events = value));
2259
- component_subscribe($$self, eventSources, value => $$invalidate(37, $eventSources = value));
2260
- component_subscribe($$self, height, value => $$invalidate(4, $height = value));
2276
+ component_subscribe($$self, events, value => $$invalidate(34, $events = value));
2277
+ component_subscribe($$self, eventSources, value => $$invalidate(35, $eventSources = value));
2278
+ component_subscribe($$self, height, value => $$invalidate(3, $height = value));
2261
2279
  component_subscribe($$self, theme, value => $$invalidate(1, $theme = value));
2262
2280
 
2263
2281
  function setOption(name, value) {
@@ -2365,12 +2383,12 @@ function instance($$self, $$props, $$invalidate) {
2365
2383
  }
2366
2384
 
2367
2385
  $$self.$$set = $$props => {
2368
- if ('plugins' in $$props) $$invalidate(19, plugins = $$props.plugins);
2369
- if ('options' in $$props) $$invalidate(20, options = $$props.options);
2386
+ if ('plugins' in $$props) $$invalidate(17, plugins = $$props.plugins);
2387
+ if ('options' in $$props) $$invalidate(18, options = $$props.options);
2370
2388
  };
2371
2389
 
2372
2390
  $$self.$$.update = () => {
2373
- if ($$self.$$.dirty[0] & /*options*/ 1048576) {
2391
+ if ($$self.$$.dirty[0] & /*options*/ 262144) {
2374
2392
  // Reactively update options that did change
2375
2393
  for (let [name, value] of diff(options)) {
2376
2394
  setOption(name, value);
@@ -2381,12 +2399,10 @@ function instance($$self, $$props, $$invalidate) {
2381
2399
  return [
2382
2400
  $_scrollable,
2383
2401
  $theme,
2384
- $_viewClass,
2385
2402
  $_iClass,
2386
2403
  $height,
2387
2404
  $_viewComponent,
2388
2405
  _viewComponent,
2389
- _viewClass,
2390
2406
  _bodyEl,
2391
2407
  _interaction,
2392
2408
  _iClass,
@@ -2426,20 +2442,20 @@ class Calendar extends SvelteComponent {
2426
2442
  create_fragment,
2427
2443
  safe_not_equal,
2428
2444
  {
2429
- plugins: 19,
2430
- options: 20,
2431
- setOption: 21,
2432
- getOption: 22,
2433
- refetchEvents: 23,
2434
- getEvents: 24,
2435
- getEventById: 25,
2436
- addEvent: 26,
2437
- updateEvent: 27,
2438
- removeEventById: 28,
2439
- getView: 29,
2440
- unselect: 30,
2441
- dateFromPoint: 31,
2442
- destroy: 32
2445
+ plugins: 17,
2446
+ options: 18,
2447
+ setOption: 19,
2448
+ getOption: 20,
2449
+ refetchEvents: 21,
2450
+ getEvents: 22,
2451
+ getEventById: 23,
2452
+ addEvent: 24,
2453
+ updateEvent: 25,
2454
+ removeEventById: 26,
2455
+ getView: 27,
2456
+ unselect: 28,
2457
+ dateFromPoint: 29,
2458
+ destroy: 30
2443
2459
  },
2444
2460
  null,
2445
2461
  [-1, -1]
@@ -2447,52 +2463,52 @@ class Calendar extends SvelteComponent {
2447
2463
  }
2448
2464
 
2449
2465
  get setOption() {
2450
- return this.$$.ctx[21];
2466
+ return this.$$.ctx[19];
2451
2467
  }
2452
2468
 
2453
2469
  get getOption() {
2454
- return this.$$.ctx[22];
2470
+ return this.$$.ctx[20];
2455
2471
  }
2456
2472
 
2457
2473
  get refetchEvents() {
2458
- return this.$$.ctx[23];
2474
+ return this.$$.ctx[21];
2459
2475
  }
2460
2476
 
2461
2477
  get getEvents() {
2462
- return this.$$.ctx[24];
2478
+ return this.$$.ctx[22];
2463
2479
  }
2464
2480
 
2465
2481
  get getEventById() {
2466
- return this.$$.ctx[25];
2482
+ return this.$$.ctx[23];
2467
2483
  }
2468
2484
 
2469
2485
  get addEvent() {
2470
- return this.$$.ctx[26];
2486
+ return this.$$.ctx[24];
2471
2487
  }
2472
2488
 
2473
2489
  get updateEvent() {
2474
- return this.$$.ctx[27];
2490
+ return this.$$.ctx[25];
2475
2491
  }
2476
2492
 
2477
2493
  get removeEventById() {
2478
- return this.$$.ctx[28];
2494
+ return this.$$.ctx[26];
2479
2495
  }
2480
2496
 
2481
2497
  get getView() {
2482
- return this.$$.ctx[29];
2498
+ return this.$$.ctx[27];
2483
2499
  }
2484
2500
 
2485
2501
  get unselect() {
2486
- return this.$$.ctx[30];
2502
+ return this.$$.ctx[28];
2487
2503
  }
2488
2504
 
2489
2505
  get dateFromPoint() {
2490
- return this.$$.ctx[31];
2506
+ return this.$$.ctx[29];
2491
2507
  }
2492
2508
 
2493
2509
  get destroy() {
2494
- return this.$$.ctx[32];
2510
+ return this.$$.ctx[30];
2495
2511
  }
2496
2512
  }
2497
2513
 
2498
- export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createView, datesEqual, debounce, Calendar as default, derived2, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates, writable2 };
2514
+ export { DAY_IN_SECONDS, addDay, addDuration, ancestor, assign, bgEvent, btnTextDay, btnTextMonth, btnTextWeek, btnTextYear, cloneDate, cloneEvent, copyTime, createDate, createDuration, createElement, createEventChunk, createEventClasses, createEventContent, createEventSources, createEvents, createView, datesEqual, debounce, Calendar as default, derived2, eventIntersects, floor, flushDebounce, getElementWithPayload, getPayload, ghostEvent, hasPayload, hasYScroll, height, helperEvent, intl, intlRange, keyEnter, keys, max, min, nextClosestDay, noTimePart, outsideEvent, pointerEvent, prepareEventChunks, prevClosestDay, previewEvent, rect, repositionEvent, setContent, setMidnight, setPayload, sortEventChunks, subtractDay, subtractDuration, symbol, themeView, toEventWithLocalDates, toISOString, toLocalDate, toViewWithLocalDates, writable2 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@event-calendar/core",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "title": "Event Calendar Core package",
5
5
  "description": "Full-sized drag & drop event calendar with resource view",
6
6
  "keywords": [
@@ -30,12 +30,29 @@
30
30
  <!-- svelte-ignore a11y-missing-content -->
31
31
  <h2 class="{$theme.title}" use:setContent={$_viewTitle}></h2>
32
32
  {:else if button == 'prev'}
33
- <button class="{$theme.button} ec-{button}" aria-label={$buttonText.prev} on:click={prev}><i class="{$theme.icon} ec-{button}"></i></button>
33
+ <button
34
+ class="{$theme.button} ec-{button}"
35
+ aria-label={$buttonText.prev}
36
+ title={$buttonText.prev}
37
+ on:click={prev}
38
+ ><i class="{$theme.icon} ec-{button}"></i></button>
34
39
  {:else if button == 'next'}
35
- <button class="{$theme.button} ec-{button}" aria-label={$buttonText.next} on:click={next}><i class="{$theme.icon} ec-{button}"></i></button>
40
+ <button
41
+ class="{$theme.button} ec-{button}"
42
+ aria-label={$buttonText.next}
43
+ title={$buttonText.next}
44
+ on:click={next}
45
+ ><i class="{$theme.icon} ec-{button}"></i></button>
36
46
  {:else if button == 'today'}
37
- <button class="{$theme.button} ec-{button}" on:click={() => $date = cloneDate(today)} disabled={isToday}>{$buttonText[button]}</button>
47
+ <button
48
+ class="{$theme.button} ec-{button}"
49
+ on:click={() => $date = cloneDate(today)}
50
+ disabled={isToday}
51
+ >{$buttonText[button]}</button>
38
52
  {:else if button != ''}
39
- <button class="{$theme.button}{$view === button ? ' ' + $theme.active : ''} ec-{button}" on:click={() => $view = button}>{$buttonText[button]}</button>
53
+ <button
54
+ class="{$theme.button}{$view === button ? ' ' + $theme.active : ''} ec-{button}"
55
+ on:click={() => $view = button}
56
+ >{$buttonText[button]}</button>
40
57
  {/if}
41
58
  {/each}
@@ -26,7 +26,7 @@
26
26
  let state = new State(plugins, options);
27
27
  setContext('state', state);
28
28
 
29
- let {_viewComponent, _viewClass, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable,
29
+ let {_viewComponent, _bodyEl, _interaction, _iClass, _events, _queue, _scrollable,
30
30
  events, eventSources, height, theme} = state;
31
31
 
32
32
  // Reactively update options that did change
@@ -130,8 +130,8 @@
130
130
  </script>
131
131
 
132
132
  <div
133
- class="{$theme.calendar}{$_viewClass ? ' ' + $theme[$_viewClass] : ''}{$_scrollable ? ' ' + $theme.withScroll : ''}{$_iClass ? ' ' + $theme[$_iClass] : ''}"
134
- style="height: {$height}"
133
+ class="{$theme.calendar} {$theme.view}{$_scrollable ? ' ' + $theme.withScroll : ''}{$_iClass ? ' ' + $theme[$_iClass] : ''}"
134
+ style:height={$height}
135
135
  >
136
136
  <Toolbar/>
137
137
  <svelte:component this={$_viewComponent}/>
package/src/index.scss CHANGED
@@ -184,7 +184,7 @@
184
184
  border-top: none;
185
185
  }
186
186
 
187
- .ec-month & {
187
+ .ec-day-grid & {
188
188
  flex: 1 1 auto;
189
189
  }
190
190
  }
@@ -215,12 +215,12 @@
215
215
  .ec-content {
216
216
  display: flex;
217
217
 
218
- .ec-month & {
218
+ .ec-day-grid & {
219
219
  flex-direction: column;
220
220
  height: 100%;
221
221
  }
222
222
 
223
- .ec-month .ec-uniform & {
223
+ .ec-day-grid .ec-uniform & {
224
224
  overflow: hidden; // remove scrolling due to hidden events
225
225
  }
226
226
 
@@ -241,12 +241,12 @@
241
241
  border-bottom: none;
242
242
  }
243
243
 
244
- .ec-month &,
244
+ .ec-day-grid &,
245
245
  .ec-resource & {
246
246
  flex: 1 0 auto;
247
247
  }
248
248
 
249
- .ec-month .ec-uniform & {
249
+ .ec-day-grid .ec-uniform & {
250
250
  flex: 1 1 0%; // % is required to work properly for both auto and fixed calendar height
251
251
  min-height: 0;
252
252
  }
@@ -263,16 +263,16 @@
263
263
  background-color: #e5f7fe;
264
264
  }
265
265
 
266
- .ec-month .ec-body & {
266
+ .ec-day-grid .ec-body & {
267
267
  min-height: 5em;
268
268
  position: relative;
269
269
  }
270
270
 
271
- .ec-month .ec-uniform & {
271
+ .ec-day-grid .ec-uniform & {
272
272
  min-height: 0;
273
273
  }
274
274
 
275
- .ec-month &:first-child {
275
+ .ec-day-grid &:first-child {
276
276
  border-left: none;
277
277
  }
278
278
 
@@ -296,7 +296,7 @@
296
296
  }
297
297
  }
298
298
 
299
- .ec-month {
299
+ .ec-day-grid {
300
300
  .ec-day-head {
301
301
  text-align: right;
302
302
  padding: 4px 4px 3px;
@@ -328,7 +328,7 @@
328
328
  .ec-events {
329
329
  margin: 0 6px 0 0;
330
330
 
331
- .ec-week &,
331
+ .ec-time-grid &,
332
332
  &.ec-preview {
333
333
  position: relative;
334
334
  }
@@ -346,12 +346,12 @@
346
346
  line-height: 1.5;
347
347
  z-index: 1; // put it above the pointer event (for multi-day events in month view)
348
348
 
349
- .ec-month &,
349
+ .ec-day-grid &,
350
350
  .ec-all-day & {
351
351
  position: relative;
352
352
  }
353
353
 
354
- .ec-week .ec-body & {
354
+ .ec-time-grid .ec-body & {
355
355
  position: absolute;
356
356
  }
357
357
 
@@ -390,7 +390,7 @@
390
390
  flex-direction: column;
391
391
  width: 100%;
392
392
 
393
- .ec-month &,
393
+ .ec-day-grid &,
394
394
  .ec-all-day & {
395
395
  flex-direction: row;
396
396
  }
@@ -408,7 +408,7 @@
408
408
  margin: 0 0 1px 0;
409
409
  flex-shrink: 0;
410
410
 
411
- .ec-month & {
411
+ .ec-day-grid & {
412
412
  margin: 0 3px 0 0;
413
413
  max-width: 100%;
414
414
  text-overflow: ellipsis;
@@ -418,14 +418,14 @@
418
418
  .ec-event-title {
419
419
  overflow: hidden;
420
420
 
421
- .ec-month &,
421
+ .ec-day-grid &,
422
422
  .ec-all-day & {
423
423
  min-height: 1.5em;
424
424
  white-space: nowrap;
425
425
  text-overflow: ellipsis;
426
426
  }
427
427
 
428
- .ec-week .ec-body & {
428
+ .ec-time-grid .ec-body & {
429
429
  position: sticky;
430
430
  top: 0;
431
431
  }
@@ -557,7 +557,7 @@
557
557
  position: absolute;
558
558
  user-select: none;
559
559
 
560
- .ec-month &,
560
+ .ec-day-grid &,
561
561
  .ec-all-day & {
562
562
  top: 0;
563
563
  right: 0;
@@ -567,7 +567,7 @@
567
567
  cursor: ew-resize;
568
568
  }
569
569
 
570
- .ec-week .ec-body & {
570
+ .ec-time-grid .ec-body & {
571
571
  left: 0;
572
572
  right: 0;
573
573
  bottom: 0;
package/src/lib/a11y.js CHANGED
@@ -4,27 +4,3 @@ export function keyEnter(fn) {
4
4
  return e.key === 'Enter' || e.key === ' ' ? fn.call(this, e) : undefined;
5
5
  };
6
6
  }
7
-
8
- export function btnTextDay(text) {
9
- return btnText(text, 'day');
10
- }
11
-
12
- export function btnTextWeek(text) {
13
- return btnText(text, 'week');
14
- }
15
-
16
- export function btnTextMonth(text) {
17
- return btnText(text, 'month');
18
- }
19
-
20
- export function btnTextYear(text) {
21
- return btnText(text, 'year');
22
- }
23
-
24
- function btnText(text, period) {
25
- return {
26
- ...text,
27
- next: 'Next ' + period,
28
- prev: 'Previous ' + period
29
- };
30
- }
@@ -0,0 +1,28 @@
1
+
2
+ export function btnTextDay(text) {
3
+ return btnText(text, 'day');
4
+ }
5
+
6
+ export function btnTextWeek(text) {
7
+ return btnText(text, 'week');
8
+ }
9
+
10
+ export function btnTextMonth(text) {
11
+ return btnText(text, 'month');
12
+ }
13
+
14
+ export function btnTextYear(text) {
15
+ return btnText(text, 'year');
16
+ }
17
+
18
+ function btnText(text, period) {
19
+ return {
20
+ ...text,
21
+ next: 'Next ' + period,
22
+ prev: 'Previous ' + period
23
+ };
24
+ }
25
+
26
+ export function themeView(view) {
27
+ return theme => ({...theme, view});
28
+ }
package/src/lib.js CHANGED
@@ -4,6 +4,7 @@ export * from './lib/date';
4
4
  export * from './lib/debounce';
5
5
  export * from './lib/dom';
6
6
  export * from './lib/events';
7
+ export * from './lib/options';
7
8
  export * from './lib/stores';
8
9
  export * from './lib/utils';
9
10
  export * from './lib/view';
@@ -1,5 +1,4 @@
1
1
  import {assign, createDate, createDuration, setMidnight, createEvents, createEventSources} from '../lib.js';
2
- import {is_function} from 'svelte/internal';
3
2
 
4
3
  export function createOptions(plugins) {
5
4
  let options = {
@@ -92,7 +91,7 @@ export function createOptions(plugins) {
92
91
  time: 'ec-time',
93
92
  title: 'ec-title',
94
93
  toolbar: 'ec-toolbar',
95
- week: 'ec-week',
94
+ view: '',
96
95
  withScroll: 'ec-with-scroll'
97
96
  },
98
97
  titleFormat: {
@@ -112,9 +111,8 @@ export function createOptions(plugins) {
112
111
  return options;
113
112
  }
114
113
 
115
- export function createParsers(options, plugins) {
114
+ export function createParsers(plugins) {
116
115
  let parsers = {
117
- buttonText: input => is_function(input) ? input(options.buttonText) : input,
118
116
  date: date => setMidnight(createDate(date)),
119
117
  duration: createDuration,
120
118
  events: createEvents,
@@ -124,12 +122,11 @@ export function createParsers(options, plugins) {
124
122
  scrollTime: createDuration,
125
123
  slotDuration: createDuration,
126
124
  slotMaxTime: createDuration,
127
- slotMinTime: createDuration,
128
- theme: input => is_function(input) ? input(options.theme) : input
125
+ slotMinTime: createDuration
129
126
  };
130
127
 
131
128
  for (let plugin of plugins) {
132
- plugin.createParsers?.(parsers, options);
129
+ plugin.createParsers?.(parsers);
133
130
  }
134
131
 
135
132
  return parsers;
@@ -4,23 +4,23 @@ import {createOptions, createParsers} from './options';
4
4
  import {
5
5
  activeRange,
6
6
  currentRange,
7
+ dayGrid,
7
8
  events,
8
- monthMode,
9
9
  now,
10
10
  today,
11
11
  viewDates,
12
12
  viewTitle,
13
13
  view as view2 // hack to avoid a runtime error in SvelteKit dev mode (ReferenceError: view is not defined)
14
14
  } from './stores';
15
- import {assign, keys, writable2, intl, intlRange} from '../lib.js';
15
+ import {keys, writable2, intl, intlRange} from '../lib.js';
16
16
 
17
17
  export default class {
18
18
  constructor(plugins, input) {
19
19
  plugins = plugins || [];
20
20
 
21
21
  // Create options
22
- let options= createOptions(plugins);
23
- let parsers = createParsers(options, plugins);
22
+ let options = createOptions(plugins);
23
+ let parsers = createParsers(plugins);
24
24
 
25
25
  // Parse options
26
26
  options = parseOpts(options, parsers);
@@ -34,7 +34,7 @@ export default class {
34
34
  // Private stores
35
35
  this._queue = writable(new Map()); // debounce queue
36
36
  this._auxiliary = writable([]); // auxiliary components
37
- this._monthMode = monthMode(this);
37
+ this._dayGrid = dayGrid(this);
38
38
  this._currentRange = currentRange(this);
39
39
  this._activeRange = activeRange(this);
40
40
  this._fetchedRange = writable({start: undefined, end: undefined});
@@ -50,7 +50,6 @@ export default class {
50
50
  this._viewTitle = viewTitle(this);
51
51
  this._viewDates = viewDates(this);
52
52
  this._view = view2(this);
53
- this._viewClass = writable(undefined);
54
53
  this._viewComponent = writable(undefined);
55
54
  // Resources
56
55
  this._resBgColor = writable(noop);
@@ -74,7 +73,7 @@ export default class {
74
73
  // Set options for each view
75
74
  let views = new Set([...keys(options.views), ...keys(input.views ?? {})]);
76
75
  for (let view of views) {
77
- let opts = assign({}, options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
76
+ let opts = mergeOpts(options, options.views[view] ?? {}, input, input.views?.[view] ?? {});
78
77
  // Change view component when view changes
79
78
  this.view.subscribe(newView => {
80
79
  if (newView === view) {
@@ -125,3 +124,14 @@ function parseOpts(opts, parsers) {
125
124
  }
126
125
  return result;
127
126
  }
127
+
128
+ function mergeOpts(...args) {
129
+ let mergable = ['buttonText', 'theme'];
130
+ let result = {};
131
+ for (let opts of args) {
132
+ for (let key of keys(opts)) {
133
+ result[key] = mergable.includes(key) && is_function(opts[key]) ? opts[key](result[key]) : opts[key];
134
+ }
135
+ }
136
+ return result;
137
+ }
@@ -19,18 +19,18 @@ import {
19
19
  debounce
20
20
  } from '../lib.js';
21
21
 
22
- export function monthMode(state) {
22
+ export function dayGrid(state) {
23
23
  return derived(state.view, $view => $view?.startsWith('dayGrid'));
24
24
  }
25
25
 
26
26
  export function activeRange(state) {
27
27
  return derived(
28
- [state._currentRange, state.firstDay, state.slotMaxTime, state._monthMode],
29
- ([$_currentRange, $firstDay, $slotMaxTime, $_monthMode]) => {
28
+ [state._currentRange, state.firstDay, state.slotMaxTime, state._dayGrid],
29
+ ([$_currentRange, $firstDay, $slotMaxTime, $_dayGrid]) => {
30
30
  let start = cloneDate($_currentRange.start);
31
31
  let end = cloneDate($_currentRange.end);
32
32
 
33
- if ($_monthMode) {
33
+ if ($_dayGrid) {
34
34
  // First day of week
35
35
  prevClosestDay(start, $firstDay);
36
36
  nextClosestDay(end, $firstDay);
@@ -49,10 +49,10 @@ export function activeRange(state) {
49
49
 
50
50
  export function currentRange(state) {
51
51
  return derived(
52
- [state.date, state.duration, state.firstDay, state._monthMode],
53
- ([$date, $duration, $firstDay, $_monthMode]) => {
52
+ [state.date, state.duration, state.firstDay, state._dayGrid],
53
+ ([$date, $duration, $firstDay, $_dayGrid]) => {
54
54
  let start = cloneDate($date), end;
55
- if ($_monthMode) {
55
+ if ($_dayGrid) {
56
56
  start.setUTCDate(1);
57
57
  } else if ($duration.inWeeks) {
58
58
  // First day of week
@@ -93,9 +93,9 @@ export function viewDates(state) {
93
93
 
94
94
  export function viewTitle(state) {
95
95
  return derived(
96
- [state.date, state._activeRange, state._intlTitle, state._monthMode],
97
- ([$date, $_activeRange, $_intlTitle, $_monthMode]) => {
98
- return $_monthMode
96
+ [state.date, state._activeRange, state._intlTitle, state._dayGrid],
97
+ ([$date, $_activeRange, $_intlTitle, $_dayGrid]) => {
98
+ return $_dayGrid
99
99
  ? $_intlTitle.formatRange($date, $date)
100
100
  : $_intlTitle.formatRange($_activeRange.start, subtractDay(cloneDate($_activeRange.end)));
101
101
  }