|
1 | 1 | import 'preact/debug'; |
2 | 2 | import 'zui-dev'; |
| 3 | +import '@zui/button'; |
| 4 | +import '@zui/toolbar'; |
| 5 | +import '@zui/list'; |
| 6 | +import '@zentao/icons'; |
3 | 7 | import {Calendar} from './src/main'; |
| 8 | +import events from './dev/events-example'; |
4 | 9 |
|
5 | 10 | onPageLoad(() => { |
6 | | - const calendarNormal = new Calendar('.calendar-normal', {}); |
7 | | - const calendarEvent = new Calendar('.calendar-event', { |
8 | | - maxVisibleEvents: 2, |
9 | | - shrinkFreeWeekend: true, |
10 | | - calendarEvents: [{ |
11 | | - id: '1', |
12 | | - title: '观看天花板', |
13 | | - calendarEventGroup: '1', |
14 | | - date: new Date(2024, 8, 25, 9, 29), |
15 | | - description: '观看天花板', |
16 | | - }, |
17 | | - { |
18 | | - id: '2', |
19 | | - title: '和绿巨人睡觉', |
20 | | - calendarEventGroup: '2', |
21 | | - date: new Date(2024, 8, 26, 7, 12, 47), |
22 | | - description: '和绿巨人睡觉', |
23 | | - }, |
24 | | - { |
25 | | - id: '3', |
26 | | - title: '和路人乙捶打', |
27 | | - calendarEventGroup: '3', |
28 | | - date: new Date(2024, 8, 27, 7, 30, 30), |
29 | | - description: '和路人乙捶打', |
30 | | - }, |
31 | | - { |
32 | | - id: '4', |
33 | | - title: '自言自语', |
34 | | - calendarEventGroup: '4', |
35 | | - date: new Date(2024, 8, 28, 1, 58, 30), |
36 | | - description: '自言自语', |
37 | | - }, |
38 | | - { |
39 | | - id: '5', |
40 | | - title: '观望天花板', |
41 | | - calendarEventGroup: '5', |
42 | | - date: new Date(2024, 8, 29, 7, 30, 30), |
43 | | - description: '观望天花板', |
44 | | - }, |
45 | | - { |
46 | | - id: '6', |
47 | | - title: 'event3', |
48 | | - calendarEventGroup: '1', |
49 | | - date: new Date(2024, 7, 9), |
50 | | - description: '你好呀', |
51 | | - }, |
| 11 | + const calendar = new Calendar('#calendar', { |
| 12 | + headerTitle: 'My Todo Calendar', |
| 13 | + headerActions: [ |
| 14 | + {text: 'Export'}, |
| 15 | + {text: 'Print', btnType: 'primary'}, |
52 | 16 | ], |
53 | | - calendarEventGroups: [{ |
54 | | - id: '1', |
55 | | - title: 'event set 1', |
56 | | - color: '#f39988'}, { |
57 | | - id: '2', |
58 | | - title: 'event set 2', |
59 | | - color: '#d4a785'}, {id: '3', title: 'event set 3', color: '#29bcd2'}, |
60 | | - {id: '4', title: 'event set 4', color: '#7ec67e'}, |
61 | | - {id: '5', title: 'event set 5', color: '#f1bd73'}]}); |
62 | | - const calendar = new Calendar('.calendar', { |
63 | | - maxVisibleEvents: 2, |
64 | | - shrinkFreeWeekend: true, |
65 | | - calendarEvents: [{ |
66 | | - id: '1', |
67 | | - title: '观看天花板', |
68 | | - calendarEventGroup: '1', |
69 | | - date: new Date(2024, 8, 25, 9, 29), |
70 | | - description: '观看天花板', |
71 | | - }, |
72 | | - { |
73 | | - id: '2', |
74 | | - title: '和绿巨人睡觉', |
75 | | - calendarEventGroup: '2', |
76 | | - date: new Date(2024, 8, 26, 7, 12, 47), |
77 | | - description: '和绿巨人睡觉', |
78 | | - }, |
79 | | - { |
80 | | - id: '3', |
81 | | - title: '和路人乙捶打', |
82 | | - calendarEventGroup: '3', |
83 | | - date: new Date(2024, 8, 27, 7, 30, 30), |
84 | | - description: '和路人乙捶打', |
85 | | - }, |
86 | | - { |
87 | | - id: '4', |
88 | | - title: '自言自语', |
89 | | - calendarEventGroup: '4', |
90 | | - date: new Date(2024, 8, 28, 1, 58, 30), |
91 | | - description: '自言自语', |
92 | | - }, |
93 | | - { |
94 | | - id: '5', |
95 | | - title: '观望天花板', |
96 | | - calendarEventGroup: '5', |
97 | | - date: new Date(2024, 8, 29, 7, 30, 30), |
98 | | - description: '观望天花板', |
99 | | - }, |
100 | | - { |
101 | | - id: '6', |
102 | | - title: 'event3', |
103 | | - calendarEventGroup: '1', |
104 | | - date: new Date(2024, 7, 9), |
105 | | - description: '你好呀', |
106 | | - }, |
| 17 | + categories: [ |
| 18 | + { |
| 19 | + id: 'DEFAULT', |
| 20 | + name: '默认日历', |
| 21 | + color: 'red', |
| 22 | + }, |
107 | 23 | ], |
108 | | - calendarEventGroups: [{ |
109 | | - id: '1', |
110 | | - title: 'event set 1', |
111 | | - color: '#f39988'}, { |
112 | | - id: '2', |
113 | | - title: 'event set 2', |
114 | | - color: '#d4a785'}, {id: '3', title: 'event set 3', color: '#29bcd2'}, |
115 | | - {id: '4', title: 'event set 4', color: '#7ec67e'}, |
116 | | - {id: '5', title: 'event set 5', color: '#f1bd73'}]}); |
117 | | - |
118 | | - console.log('> calendar-normal instance created', calendarNormal); |
119 | | - console.log('> calendar-event instance created', calendarEvent); |
120 | | - console.log('> calendar instance created', calendar); |
| 24 | + events, |
| 25 | + onClickEvent: (event, category, mouseEvent) => { |
| 26 | + console.log('> onClickEvent', {event, category, mouseEvent}); |
| 27 | + }, |
| 28 | + }); |
| 29 | + console.log('> calendar', calendar); |
121 | 30 | }); |
0 commit comments