@event-calendar/core 0.7.0 → 0.8.2

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/src/index.scss ADDED
@@ -0,0 +1,507 @@
1
+ /* Grid */
2
+ .ec-flex {
3
+ display: flex;
4
+ }
5
+
6
+ .ec-body.ec-month,
7
+ .ec-days,
8
+ .ec-day,
9
+ .ec-day-title,
10
+ .ec-resource {
11
+ flex: 1 1 0%; /* % for ie11 */
12
+ min-width: 0;
13
+ max-width: 100%;
14
+ }
15
+
16
+ .ec {
17
+ display: flex;
18
+ flex-direction: column;
19
+
20
+ /* Scrollbar */
21
+ ::-webkit-scrollbar {
22
+ background: #fff;
23
+ }
24
+
25
+ ::-webkit-scrollbar-thumb {
26
+ border: 4px solid #fff;
27
+ box-shadow: none;
28
+ background: #dadce0;
29
+ border-radius: 8px;
30
+ min-height: 40px;
31
+ }
32
+
33
+ :hover::-webkit-scrollbar-thumb {
34
+ background: #bdc1c6;
35
+ }
36
+ }
37
+
38
+ .ec-hidden-scroll {
39
+ display: none;
40
+ overflow-y: scroll;
41
+ visibility: hidden;
42
+ flex-shrink: 0;
43
+
44
+ .ec-with-scroll & {
45
+ display: block;
46
+ }
47
+ }
48
+
49
+ /* Toolbar */
50
+ .ec-toolbar {
51
+ flex: 0 0 auto;
52
+ display: flex;
53
+ justify-content: space-between;
54
+ align-items: center;
55
+ margin-bottom: 1em;
56
+
57
+ > * {
58
+ margin-bottom: -.5em;
59
+
60
+ > * {
61
+ margin-bottom: .5em;
62
+
63
+ &:not(:last-child) {
64
+ margin-right: .75em;
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ .ec-title {
71
+ margin: 0;
72
+ }
73
+
74
+ .ec-button {
75
+ background-color: #fff;
76
+ border: 1px solid #ced4da;
77
+ padding: .375rem .75rem;
78
+ font-size: 1rem;
79
+ line-height: 1.5;
80
+ border-radius: .25rem;
81
+
82
+ &:not(:disabled) {
83
+ color: #212529;
84
+ cursor: pointer;
85
+ }
86
+
87
+ &:not(:disabled):hover,
88
+ &.ec-active {
89
+ background-color: #ececec;
90
+ border-color: #b1bbc4;
91
+ }
92
+ }
93
+
94
+ .ec-button-group {
95
+ display: inline-flex;
96
+
97
+ .ec-button:not(:first-child) {
98
+ border-top-left-radius: 0;
99
+ border-bottom-left-radius: 0;
100
+ margin-left: -1px;
101
+ }
102
+
103
+ .ec-button:not(:last-child) {
104
+ border-top-right-radius: 0;
105
+ border-bottom-right-radius: 0;
106
+ }
107
+ }
108
+
109
+ .ec-icon {
110
+ display: inline-block;
111
+ width: 1em;
112
+
113
+ &.ec-prev:after,
114
+ &.ec-next:after {
115
+ content: '';
116
+ position: relative;
117
+ width: .5em;
118
+ height: .5em;
119
+ border-top: 2px solid #212529;
120
+ border-right: 2px solid #212529;
121
+ display: inline-block;
122
+ }
123
+
124
+ &.ec-prev:after {
125
+ transform: rotate(-135deg) translate(-2px, 2px);
126
+ }
127
+
128
+ &.ec-next:after {
129
+ transform: rotate(45deg) translate(-2px, 2px);
130
+ }
131
+ }
132
+
133
+ /* Header */
134
+ .ec-header,
135
+ .ec-body,
136
+ .ec-days,
137
+ .ec-day {
138
+ border: 1px solid #dadce0;
139
+ }
140
+
141
+ .ec-header {
142
+ display: flex;
143
+ flex-shrink: 0;
144
+
145
+ .ec-resource {
146
+ flex-direction: column;
147
+
148
+ .ec-days {
149
+ border-top-style: solid;
150
+ }
151
+ }
152
+
153
+ .ec-days {
154
+ border-bottom: none;
155
+ }
156
+
157
+ .ec-day {
158
+ min-height: 24px;
159
+ line-height: 24px;
160
+ text-align: center;
161
+ overflow: hidden;
162
+ text-overflow: ellipsis;
163
+ }
164
+ }
165
+
166
+ /* Body */
167
+ .ec-body {
168
+ position: relative;
169
+ overflow-x: hidden;
170
+ overflow-y: auto;
171
+
172
+ &:not(.ec-list) {
173
+ border-top: none;
174
+ }
175
+ }
176
+
177
+ .ec-sidebar {
178
+ flex: 0 0 auto;
179
+ width: auto;
180
+ max-width: 100%;
181
+ padding: 0 4px 0 8px;
182
+ }
183
+
184
+ .ec-content {
185
+ display: flex;
186
+
187
+ .ec-month & {
188
+ flex-direction: column;
189
+ height: 100%; /* ie11 */
190
+ }
191
+
192
+ .ec-month.ec-uniform & {
193
+ overflow: hidden;
194
+ }
195
+
196
+ .ec-list & {
197
+ flex-direction: column;
198
+ }
199
+ }
200
+
201
+ .ec-resource {
202
+ display: flex;
203
+ }
204
+
205
+ .ec-days {
206
+ display: flex;
207
+ border-style: none none solid;
208
+
209
+ &:last-child {
210
+ border-bottom: none;
211
+ }
212
+
213
+ .ec-month &,
214
+ .ec-resource & {
215
+ flex: 1 0 auto; /* ie11 */
216
+ }
217
+
218
+ .ec-month.ec-uniform & {
219
+ flex: 1 1 0%;
220
+ min-height: 0;
221
+ }
222
+ }
223
+
224
+ .ec-day {
225
+ border-style: none none none solid;
226
+
227
+ &.ec-today {
228
+ background-color: #fcf8e3;
229
+ }
230
+
231
+ &.ec-highlight {
232
+ background-color: #e5f7fe;
233
+ }
234
+
235
+ .ec-month.ec-body & {
236
+ min-height: 5em;
237
+ position: relative;
238
+ }
239
+
240
+ .ec-month.ec-uniform & {
241
+ min-height: 0;
242
+ }
243
+
244
+ .ec-month &:first-child {
245
+ border-left: none;
246
+ }
247
+
248
+ &.ec-other-month .ec-day-head {
249
+ opacity: .3;
250
+ }
251
+
252
+ .ec-list & {
253
+ flex: 1 0 auto; /* ie11 */
254
+ background-color: #fff;
255
+ border-style: solid none;
256
+ padding: 8px 14px;
257
+ font-weight: bold;
258
+ position: sticky;
259
+ top: 0;
260
+ z-index: 2;
261
+
262
+ &:first-child {
263
+ border-top: none;
264
+ }
265
+ }
266
+ }
267
+
268
+ .ec-month {
269
+ .ec-day-head {
270
+ text-align: right;
271
+ padding: 4px 4px 3px;
272
+ }
273
+
274
+ .ec-day-foot {
275
+ position: absolute;
276
+ bottom: 0;
277
+ padding: 2px;
278
+ font-size: .85em;
279
+
280
+ a {
281
+ cursor: pointer;
282
+ }
283
+ }
284
+ }
285
+
286
+ .ec-list {
287
+ .ec-day-side {
288
+ float: right;
289
+ }
290
+
291
+ .ec-no-events {
292
+ text-align: center;
293
+ padding: 5em 0;
294
+ }
295
+ }
296
+
297
+ .ec-events {
298
+ margin: 0 6px 0 0;
299
+
300
+ .ec-week &,
301
+ &.ec-preview {
302
+ position: relative;
303
+ }
304
+ }
305
+
306
+ .ec-event {
307
+ display: flex;
308
+ flex-direction: column;
309
+ padding: 2px;
310
+ color: #fff;
311
+ box-sizing: border-box;
312
+ box-shadow: 0 0 1px 0 #dadce0;
313
+ background-color: #039be5;
314
+ border-radius: 3px;
315
+ font-size: .85em;
316
+ line-height: 1.5;
317
+ z-index: 1; // put it above the pointer event (for multi-day events in month view)
318
+
319
+ .ec-month & {
320
+ position: relative;
321
+ flex-direction: row;
322
+ }
323
+
324
+ .ec-week & {
325
+ position: absolute;
326
+ }
327
+
328
+ .ec-list & {
329
+ flex-direction: row;
330
+ padding: 8px 14px;
331
+ color: inherit;
332
+ background-color: transparent;
333
+ border-radius: 0;
334
+ }
335
+
336
+ &.ec-preview {
337
+ cursor: pointer;
338
+ position: absolute;
339
+ z-index: 1000;
340
+ width: 100%;
341
+ user-select: none;
342
+ opacity: .8;
343
+ }
344
+
345
+ &.ec-pointer {
346
+ color: inherit;
347
+ pointer-events: none;
348
+ user-select: none;
349
+ position: absolute;
350
+ z-index: 0;
351
+ box-shadow: none;
352
+ display: none;
353
+ .ec-day:hover & {
354
+ display: flex;
355
+ }
356
+ }
357
+ }
358
+
359
+ .ec-event-tag {
360
+ width: 4px;
361
+ border-radius: 2px;
362
+ margin-right: 8px;
363
+ }
364
+
365
+ .ec-event-time {
366
+ overflow: hidden;
367
+ white-space: nowrap;
368
+ margin: 0 0 1px 0;
369
+ flex-shrink: 0;
370
+
371
+ .ec-month & {
372
+ margin: 0 3px 0 0;
373
+ max-width: 100%;
374
+ text-overflow: ellipsis;
375
+ }
376
+ }
377
+
378
+ .ec-event-title {
379
+ overflow: hidden;
380
+
381
+ .ec-month & {
382
+ white-space: nowrap;
383
+ text-overflow: ellipsis;
384
+ }
385
+
386
+ .ec-week & {
387
+ position: sticky;
388
+ top: 0;
389
+ }
390
+
391
+ .ec-list & {
392
+ font-size: 1rem;
393
+ }
394
+ }
395
+
396
+ .ec-draggable {
397
+ cursor: pointer;
398
+ user-select: none;
399
+ touch-action: none;
400
+ }
401
+
402
+ .ec-ghost {
403
+ opacity: .5;
404
+ user-select: none;
405
+ touch-action: none;
406
+ }
407
+
408
+ .ec-bg-events {
409
+ position: relative;
410
+ }
411
+
412
+ .ec-bg-event {
413
+ position: absolute;
414
+ background-color: #dadce0;
415
+ opacity: 0.3;
416
+ width: 100%;
417
+ }
418
+
419
+ .ec-hidden-times {
420
+ visibility: hidden;
421
+ overflow-y: hidden;
422
+ height: 0;
423
+ }
424
+
425
+ .ec-time,
426
+ .ec-line {
427
+ height: 24px;
428
+ }
429
+
430
+ .ec-time {
431
+ position: relative;
432
+ line-height: 24px;
433
+ top: -12px;
434
+ text-align: right;
435
+ white-space: nowrap;
436
+ }
437
+
438
+ .ec-lines {
439
+ width: 8px;
440
+ }
441
+
442
+ .ec-line:not(:first-child):after {
443
+ content: '';
444
+ position: absolute;
445
+ width: 100%;
446
+ border-bottom: 1px solid #dadce0;
447
+ pointer-events: none;
448
+ }
449
+
450
+ .ec-body:not(.ec-compact) .ec-line:nth-child(even):after {
451
+ border-bottom-style: dotted;
452
+ }
453
+
454
+ .ec-popup {
455
+ position: absolute;
456
+ top: 0;
457
+ width: 110%;
458
+ min-width: 180px;
459
+ z-index: 1010;
460
+ padding: 8px 10px 14px;
461
+ background-color: #fff;
462
+ border-radius: 6px;
463
+ outline: 1px solid transparent;
464
+ box-shadow: 0 1px 3px 0 rgba(60, 64, 67, .3), 0 4px 8px 3px rgba(60, 64, 67, .15);
465
+
466
+ .ec-day-head {
467
+ text-align: left;
468
+ display: flex;
469
+ justify-content: space-between;
470
+
471
+ a {
472
+ cursor: pointer;
473
+ font-size: 1.5em;
474
+ line-height: .8;
475
+ }
476
+ }
477
+
478
+ .ec-events {
479
+ margin: 0;
480
+ }
481
+ }
482
+
483
+ .ec-extra {
484
+ position: relative;
485
+ height: 100%;
486
+ overflow: hidden;
487
+ margin-left: -6.5px;
488
+ }
489
+
490
+ .ec-now-indicator {
491
+ position: absolute;
492
+ z-index: 1005;
493
+ width: 100%;
494
+ border-top: #ea4335 solid 2px;
495
+ pointer-events: none;
496
+
497
+ &:before {
498
+ background: #ea4335;
499
+ border-radius: 50%;
500
+ content: "";
501
+ position: absolute;
502
+ height: 12px;
503
+ margin-top: -7px;
504
+ width: 12px;
505
+ pointer-events: none;
506
+ }
507
+ }
@@ -0,0 +1,150 @@
1
+ import {assign, createDate, createDuration, setMidnight} from '@event-calendar/common';
2
+ import {createEvents, createEventSources} from '@event-calendar/common';
3
+ import {is_function} from 'svelte/internal';
4
+
5
+ export function createOptions(plugins) {
6
+ let options = {
7
+ buttonText: {
8
+ today: 'today',
9
+ },
10
+ date: new Date(),
11
+ dateClick: undefined,
12
+ datesSet: undefined,
13
+ dayHeaderFormat: {
14
+ weekday: 'short',
15
+ month: 'numeric',
16
+ day: 'numeric'
17
+ },
18
+ displayEventEnd: true,
19
+ duration: {weeks: 1},
20
+ events: [],
21
+ eventBackgroundColor: undefined,
22
+ eventClick: undefined,
23
+ eventColor: undefined,
24
+ eventContent: undefined,
25
+ eventDidMount: undefined,
26
+ eventMouseEnter: undefined,
27
+ eventMouseLeave: undefined,
28
+ eventSources: [],
29
+ eventTimeFormat: {
30
+ hour: 'numeric',
31
+ minute: '2-digit'
32
+ },
33
+ firstDay: 0,
34
+ flexibleSlotTimeLimits: false, // ec option
35
+ headerToolbar: {
36
+ start: 'title',
37
+ center: '',
38
+ end: 'today prev,next'
39
+ },
40
+ height: 'auto',
41
+ hiddenDays: [],
42
+ highlightedDates: [], // ec option
43
+ lazyFetching: true,
44
+ loading: undefined,
45
+ locale: undefined,
46
+ monthMode: false,
47
+ nowIndicator: false,
48
+ scrollTime: '06:00:00',
49
+ slotDuration: '00:30:00',
50
+ slotHeight: 24, // ec option
51
+ slotLabelFormat: {
52
+ hour: 'numeric',
53
+ minute: '2-digit'
54
+ },
55
+ slotMaxTime: '24:00:00',
56
+ slotMinTime: '00:00:00',
57
+ theme: {
58
+ active: 'ec-active',
59
+ bgEvent: 'ec-bg-event',
60
+ bgEvents: 'ec-bg-events',
61
+ body: 'ec-body',
62
+ button: 'ec-button',
63
+ buttonGroup: 'ec-button-group',
64
+ calendar: 'ec',
65
+ compact: 'ec-compact',
66
+ content: 'ec-content',
67
+ day: 'ec-day',
68
+ dayHead: 'ec-day-head',
69
+ days: 'ec-days',
70
+ event: 'ec-event',
71
+ eventTime: 'ec-event-time',
72
+ eventTitle: 'ec-event-title',
73
+ events: 'ec-events',
74
+ extra: 'ec-extra',
75
+ handle: 'ec-handle',
76
+ header: 'ec-header',
77
+ hiddenScroll: 'ec-hidden-scroll',
78
+ hiddenTimes: 'ec-hidden-times',
79
+ highlight: 'ec-highlight',
80
+ icon: 'ec-icon',
81
+ line: 'ec-line',
82
+ lines: 'ec-lines',
83
+ nowIndicator: 'ec-now-indicator',
84
+ otherMonth: 'ec-other-month',
85
+ sidebar: 'ec-sidebar',
86
+ today: 'ec-today',
87
+ time: 'ec-time',
88
+ title: 'ec-title',
89
+ toolbar: 'ec-toolbar',
90
+ week: 'ec-week',
91
+ withScroll: 'ec-with-scroll'
92
+ },
93
+ titleFormat: {
94
+ year: 'numeric',
95
+ month: 'short',
96
+ day: 'numeric'
97
+ },
98
+ view: undefined,
99
+ viewDidMount: undefined,
100
+ views: {}
101
+ };
102
+
103
+ for (let plugin of plugins) {
104
+ if ('createOptions' in plugin) {
105
+ plugin.createOptions(options);
106
+ }
107
+ }
108
+
109
+ return options;
110
+ }
111
+
112
+ export function createParsers(options, plugins) {
113
+ let parsers = {
114
+ buttonText: input => is_function(input) ? input(options.buttonText) : input,
115
+ date: date => setMidnight(createDate(date)),
116
+ duration: createDuration,
117
+ events: createEvents,
118
+ eventSources: createEventSources,
119
+ hiddenDays: days => [...new Set(days)],
120
+ highlightedDates: dates => dates.map(createDate),
121
+ scrollTime: createDuration,
122
+ slotDuration: createDuration,
123
+ slotMaxTime: createDuration,
124
+ slotMinTime: createDuration,
125
+ theme: input => is_function(input) ? input(options.theme) : input
126
+ };
127
+
128
+ for (let plugin of plugins) {
129
+ if ('createParsers' in plugin) {
130
+ plugin.createParsers(parsers, options);
131
+ }
132
+ }
133
+
134
+ return parsers;
135
+ }
136
+
137
+ let prev;
138
+ export function diff(options) {
139
+ let diff = [];
140
+ if (prev) {
141
+ for (let name of Object.keys(options)) {
142
+ if (options[name] !== prev[name]) {
143
+ diff.push([name, options[name]]);
144
+ }
145
+ }
146
+ }
147
+ prev = assign({}, options);
148
+
149
+ return diff;
150
+ }