classcard-ui 0.2.989 → 0.2.991

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.
Files changed (188) hide show
  1. package/README.md +24 -24
  2. package/dist/classcard-ui.common.js +68 -60
  3. package/dist/classcard-ui.common.js.map +1 -1
  4. package/dist/classcard-ui.umd.js +68 -60
  5. package/dist/classcard-ui.umd.js.map +1 -1
  6. package/dist/classcard-ui.umd.min.js +1 -1
  7. package/dist/classcard-ui.umd.min.js.map +1 -1
  8. package/package.json +82 -82
  9. package/src/App.vue +16 -16
  10. package/src/components/CAlerts/CAlerts.vue +70 -70
  11. package/src/components/CAlerts/index.js +2 -2
  12. package/src/components/CAnchorTabs/CAnchorTabs.vue +96 -96
  13. package/src/components/CAnchorTabs/index.js +2 -2
  14. package/src/components/CAnchorTag/CAnchorTag.vue +62 -62
  15. package/src/components/CAnchorTag/index.js +2 -2
  16. package/src/components/CAvatar/CAvatar.vue +136 -136
  17. package/src/components/CAvatar/index.js +2 -2
  18. package/src/components/CAvatarGroup/CAvatarGroup.vue +145 -145
  19. package/src/components/CAvatarGroup/index.js +2 -2
  20. package/src/components/CBasicTable/CBasicTable.vue +184 -184
  21. package/src/components/CBasicTable/index.js +2 -2
  22. package/src/components/CBreadcrumbs/CBreadcrumbs.vue +38 -38
  23. package/src/components/CBreadcrumbs/index.js +2 -2
  24. package/src/components/CButton/CButton.vue +152 -152
  25. package/src/components/CButton/index.js +2 -2
  26. package/src/components/CButtonGroup/CButtonGroup.vue +118 -118
  27. package/src/components/CButtonGroup/index.js +2 -2
  28. package/src/components/CButtonIcon/CButtonIcon.vue +117 -117
  29. package/src/components/CButtonIcon/index.js +2 -2
  30. package/src/components/CButtonLink/CButtonLink.vue +39 -39
  31. package/src/components/CButtonLink/index.js +2 -2
  32. package/src/components/CButtonSelect/CButtonSelect.vue +124 -124
  33. package/src/components/CButtonSelect/index.js +2 -2
  34. package/src/components/CButtonSelectBorder/CButtonSelectBorder.vue +135 -135
  35. package/src/components/CButtonSelectBorder/index.js +3 -3
  36. package/src/components/CButtonWithDropdown/CButtonWithDropdown.vue +135 -135
  37. package/src/components/CButtonWithDropdown/index.js +2 -2
  38. package/src/components/CCalendar/CCalendar.vue +410 -410
  39. package/src/components/CCalendar/index.js +3 -3
  40. package/src/components/CCard/CCard.vue +49 -49
  41. package/src/components/CCard/index.js +2 -2
  42. package/src/components/CCheckbox/CCheckbox.vue +85 -85
  43. package/src/components/CCheckbox/index.js +2 -2
  44. package/src/components/CCircularButton/CCircularButton.vue +52 -52
  45. package/src/components/CCircularButton/index.js +2 -2
  46. package/src/components/CCollapsibleSection/CCollapsibleSection.vue +101 -101
  47. package/src/components/CCollapsibleSection/index.js +2 -2
  48. package/src/components/CColorDots/CColorDots.vue +46 -46
  49. package/src/components/CColorDots/index.js +3 -3
  50. package/src/components/CConfirmActionModal/CConfirmActionModal.vue +171 -171
  51. package/src/components/CConfirmActionModal/index.js +3 -3
  52. package/src/components/CDatepicker/CDatepicker.vue +158 -158
  53. package/src/components/CDatepicker/index.js +2 -2
  54. package/src/components/CDualSelect/CDualSelect.vue +193 -193
  55. package/src/components/CDualSelect/index.js +2 -2
  56. package/src/components/CEditor/CEditor.vue +98 -98
  57. package/src/components/CEditor/index.js +2 -2
  58. package/src/components/CFormSectionHeading/CFormSectionHeading.vue +53 -53
  59. package/src/components/CFormSectionHeading/index.js +2 -2
  60. package/src/components/CGroupedSelect/CGroupedSelect.vue +245 -245
  61. package/src/components/CGroupedSelect/index.js +3 -3
  62. package/src/components/CIcon/CIcon.vue +77 -77
  63. package/src/components/CIcon/index.js +2 -2
  64. package/src/components/CIconDropdown/CIconDropdown.vue +146 -146
  65. package/src/components/CIconDropdown/index.js +2 -2
  66. package/src/components/CInput/CInput.vue +134 -134
  67. package/src/components/CInput/index.js +2 -2
  68. package/src/components/CInputAddon/CInputAddon.vue +228 -228
  69. package/src/components/CInputAddon/index.js +2 -2
  70. package/src/components/CInputEmail/CInputEmail.vue +93 -93
  71. package/src/components/CInputEmail/index.js +2 -2
  72. package/src/components/CInsetTabs/CInsetTabs.vue +88 -88
  73. package/src/components/CInsetTabs/index.js +3 -3
  74. package/src/components/CModalHeading/CModalHeading.vue +22 -22
  75. package/src/components/CModalHeading/index.js +2 -2
  76. package/src/components/CModuleHelpLinks/CModuleHelpLinks.vue +70 -70
  77. package/src/components/CModuleHelpLinks/index.js +3 -3
  78. package/src/components/CMultiselect/CMultiselect.vue +492 -479
  79. package/src/components/CMultiselect/index.js +2 -2
  80. package/src/components/CMultiselectr/CMultiselectr.vue +44 -44
  81. package/src/components/CMultiselectr/index.js +2 -2
  82. package/src/components/CPageHeading/CPageHeading.vue +56 -56
  83. package/src/components/CPageHeading/index.js +2 -2
  84. package/src/components/CPagination/CPagination.vue +233 -233
  85. package/src/components/CPagination/index.js +2 -2
  86. package/src/components/CPhoneNumber/CPhoneNumber.vue +114 -114
  87. package/src/components/CPhoneNumber/index.js +2 -2
  88. package/src/components/CRadio/CRadio.vue +124 -124
  89. package/src/components/CRadio/index.js +2 -2
  90. package/src/components/CRangeSlider/CRangeSlider.vue +55 -55
  91. package/src/components/CRangeSlider/index.js +2 -2
  92. package/src/components/CReorderableStackedList/CReorderableStackedList.vue +94 -94
  93. package/src/components/CReorderableStackedList/index.js +2 -2
  94. package/src/components/CSelect/CSelect.vue +417 -417
  95. package/src/components/CSelect/index.js +2 -2
  96. package/src/components/CSmallTimeline/CSmallTimeline.vue +40 -40
  97. package/src/components/CSmallTimeline/index.js +2 -2
  98. package/src/components/CStackedList/CStackedList.vue +150 -150
  99. package/src/components/CStackedList/index.js +2 -2
  100. package/src/components/CStats/CStats.vue +116 -116
  101. package/src/components/CStats/index.js +2 -2
  102. package/src/components/CSwitch/CSwitch.vue +171 -171
  103. package/src/components/CSwitch/index.js +2 -2
  104. package/src/components/CTabLazy/CTabLazy.vue +58 -58
  105. package/src/components/CTabLazy/index.js +2 -2
  106. package/src/components/CTable/CTable.vue +671 -671
  107. package/src/components/CTable/index.js +2 -2
  108. package/src/components/CTabs/CTabs.vue +125 -125
  109. package/src/components/CTabs/index.js +2 -2
  110. package/src/components/CTag/CTag.vue +59 -59
  111. package/src/components/CTag/index.js +2 -2
  112. package/src/components/CTextarea/CTextarea.vue +107 -107
  113. package/src/components/CTextarea/index.js +2 -2
  114. package/src/components/CTimeline/CTimeline.vue +237 -237
  115. package/src/components/CTimeline/index.js +2 -2
  116. package/src/components/CUpload/CUpload.vue +267 -267
  117. package/src/components/CUpload/index.js +2 -2
  118. package/src/components/index.js +52 -52
  119. package/src/icons.js +364 -364
  120. package/src/main.js +22 -22
  121. package/src/stories/CAlerts.stories.js +37 -37
  122. package/src/stories/CAnchorTabs.stories.js +29 -29
  123. package/src/stories/CAnchorTag.stories.js +36 -36
  124. package/src/stories/CAvatar.stories.js +38 -38
  125. package/src/stories/CAvatarGroup.stories.js +100 -100
  126. package/src/stories/CBasicTable.stories.js +316 -316
  127. package/src/stories/CBreadcrumbs.stories.js +24 -24
  128. package/src/stories/CButton.stories.js +47 -47
  129. package/src/stories/CButtonGroup.stories.js +33 -33
  130. package/src/stories/CButtonIcon.stories.js +27 -27
  131. package/src/stories/CButtonLink.stories.js +24 -24
  132. package/src/stories/CButtonSelect.stories.js +41 -41
  133. package/src/stories/CButtonSelectBorder.stories.js +48 -48
  134. package/src/stories/CButtonWithDropdown.stories.js +41 -41
  135. package/src/stories/CCalendar.stories.js +16 -16
  136. package/src/stories/CCard.stories.js +30 -30
  137. package/src/stories/CCheckbox.stories.js +29 -29
  138. package/src/stories/CCircularButton.stories.js +29 -29
  139. package/src/stories/CCollapsibleSection.stories.js +28 -28
  140. package/src/stories/CColorDots.stories.js +28 -28
  141. package/src/stories/CConfirmActionModal.stories.js +59 -59
  142. package/src/stories/CDatepicker.stories.js +30 -30
  143. package/src/stories/CDualSelect.stories.js +29 -29
  144. package/src/stories/CEditor.stories.js +30 -30
  145. package/src/stories/CFormSectionHeading.stories.js +34 -34
  146. package/src/stories/CGroupedSelect.stories.js +71 -71
  147. package/src/stories/CIcon.stories.js +26 -26
  148. package/src/stories/CIconDropdown.stories.js +45 -45
  149. package/src/stories/CInput.stories.js +36 -36
  150. package/src/stories/CInputAddon.stories.js +37 -37
  151. package/src/stories/CInputEmail.stories.js +27 -27
  152. package/src/stories/CInsetTabs.stories.js +38 -38
  153. package/src/stories/CModalHeading.stories.js +25 -25
  154. package/src/stories/CModuleHelpLinks.stories.js +25 -25
  155. package/src/stories/CMultiselect.stories.js +157 -157
  156. package/src/stories/CMultiselectr.stories.js +23 -23
  157. package/src/stories/CPageHeading.stories.js +32 -32
  158. package/src/stories/CPagination.stories.js +30 -30
  159. package/src/stories/CPhoneNumber.stories.js +29 -29
  160. package/src/stories/CRadio.stories.js +36 -36
  161. package/src/stories/CRangeSlider.stories.js +23 -23
  162. package/src/stories/CReorderableStackedList.stories.js +23 -23
  163. package/src/stories/CSelect.stories.js +96 -96
  164. package/src/stories/CSmallTimeline.stories.js +26 -26
  165. package/src/stories/CStackedList.stories.js +37 -37
  166. package/src/stories/CStats.stories.js +33 -33
  167. package/src/stories/CSwitch.stories.js +28 -28
  168. package/src/stories/CTabLazy.stories.js +24 -24
  169. package/src/stories/CTable.stories.js +169 -169
  170. package/src/stories/CTabs.stories.js +33 -33
  171. package/src/stories/CTag.stories.js +34 -34
  172. package/src/stories/CTextarea.stories.js +32 -32
  173. package/src/stories/CTimeline.stories.js +26 -26
  174. package/src/stories/CUpload.stories.js +36 -36
  175. package/src/stories/Introduction.stories.mdx +207 -207
  176. package/src/stories/Page.vue +88 -88
  177. package/src/stories/assets/code-brackets.svg +0 -0
  178. package/src/stories/assets/colors.svg +0 -0
  179. package/src/stories/assets/comments.svg +0 -0
  180. package/src/stories/assets/direction.svg +0 -0
  181. package/src/stories/assets/flow.svg +0 -0
  182. package/src/stories/assets/plugin.svg +0 -0
  183. package/src/stories/assets/repo.svg +0 -0
  184. package/src/stories/assets/stackalt.svg +0 -0
  185. package/src/stories/header.css +26 -26
  186. package/src/stories/page.css +69 -69
  187. package/src/stories/utils.css +17 -17
  188. package/src/.DS_Store +0 -0
@@ -1,410 +1,410 @@
1
- <template>
2
- <!-- This example requires Tailwind CSS v2.0+ -->
3
- <div>
4
- <div class="grid grid-cols-1 md:grid-cols-2 md:gap-8">
5
- <div :class="`sticky top-0 md:block ${calendarClasses}`">
6
- <div
7
- class="relative z-20 flex items-center justify-between border-b border-gray-200 py-4 px-4 sm:px-0"
8
- >
9
- <h2 class="flex-auto font-semibold text-gray-900">
10
- {{ currentMonthAndYear }}
11
- </h2>
12
- <div class="flex items-center">
13
- <div class="flex items-center rounded-md shadow-sm">
14
- <button
15
- @click="handlePreviousMonthClick"
16
- type="button"
17
- class="flex items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-white py-2 pl-3 pr-4 text-gray-400 hover:text-gray-500 focus:relative"
18
- >
19
- <span class="sr-only">Previous month</span>
20
- <!-- Heroicon name: solid/chevron-left -->
21
- <svg
22
- class="h-5 w-5"
23
- xmlns="http://www.w3.org/2000/svg"
24
- viewBox="0 0 20 20"
25
- fill="currentColor"
26
- aria-hidden="true"
27
- >
28
- <path
29
- fill-rule="evenodd"
30
- d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
31
- clip-rule="evenodd"
32
- />
33
- </svg>
34
- </button>
35
- <span class="relative -mx-px h-5 w-px bg-gray-300"></span>
36
- <button
37
- @click="handleNextMonthClick"
38
- type="button"
39
- class="flex items-center justify-center rounded-r-md border border-l-0 border-gray-300 bg-white py-2 pl-4 pr-3 text-gray-400 hover:text-gray-500 focus:relative"
40
- >
41
- <span class="sr-only">Next month</span>
42
- <!-- Heroicon name: solid/chevron-right -->
43
- <svg
44
- class="h-5 w-5"
45
- xmlns="http://www.w3.org/2000/svg"
46
- viewBox="0 0 20 20"
47
- fill="currentColor"
48
- aria-hidden="true"
49
- >
50
- <path
51
- fill-rule="evenodd"
52
- d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
53
- clip-rule="evenodd"
54
- />
55
- </svg>
56
- </button>
57
- </div>
58
- </div>
59
- </div>
60
-
61
- <div
62
- class="col-span-1 overflow-hidden rounded shadow ring-1 ring-gray-200"
63
- >
64
- <div
65
- class="grid grid-cols-7 gap-px border-b border-gray-300 bg-gray-200 text-center text-xs font-semibold leading-6 text-gray-700"
66
- >
67
- <div class="bg-white py-2">Mo<span class="sr-only">on</span></div>
68
- <div class="bg-white py-2">Tu<span class="sr-only">ue</span></div>
69
- <div class="bg-white py-2">We<span class="sr-only">ed</span></div>
70
- <div class="bg-white py-2">Th<span class="sr-only">hu</span></div>
71
- <div class="bg-white py-2">Fr<span class="sr-only">ri</span></div>
72
- <div class="bg-white py-2">Sa<span class="sr-only">at</span></div>
73
- <div class="bg-white py-2">Su<span class="sr-only">un</span></div>
74
- </div>
75
- <div class="flex bg-gray-200 text-xs leading-6 text-gray-700">
76
- <div class="isolate grid w-full grid-cols-7 grid-rows-6 gap-px">
77
- <button
78
- v-for="date in daysArray"
79
- :key="getDateKey(date)"
80
- type="button"
81
- :class="{
82
- 'flex h-14 flex-col py-2 px-3 hover:bg-gray-100 focus:z-10': true,
83
- 'bg-white': isCurrentMonth(date),
84
- 'bg-gray-50': !isCurrentMonth(date),
85
- 'font-semibold': isSelected(date) || isToday(date),
86
- 'text-white': isSelected(date),
87
- 'text-indigo-600': !isSelected(date) && isToday(date),
88
- 'text-gray-900':
89
- !isSelected(date) && isCurrentMonth(date) && !isToday(date),
90
- 'text-gray-500':
91
- !isSelected(date) &&
92
- !isCurrentMonth(date) &&
93
- !isToday(date),
94
- }"
95
- @click="handleDateClick(date)"
96
- >
97
- <time
98
- :datetime="formatForDateTime(date)"
99
- :class="{
100
- 'ml-auto': true,
101
- 'flex h-6 w-6 items-center justify-center rounded-full':
102
- isSelected(date),
103
- 'bg-indigo-600': isSelected(date) && isToday(date),
104
- 'bg-gray-900': isSelected(date) && !isToday(date),
105
- }"
106
- >{{ getDayFromDate(date) }}</time
107
- >
108
- <span v-if="eventsCount" class="sr-only"
109
- >{{ getEventsCountForDate(date) }} events</span
110
- >
111
- <span
112
- v-if="eventsCount && getEventsCountForDate(date) > 0"
113
- class="-mx-0.5 mt-auto flex flex-wrap-reverse"
114
- >
115
- <span
116
- class="mx-0.5 mb-1 h-1.5 w-1.5 rounded-full bg-gray-400"
117
- ></span>
118
- </span>
119
- </button>
120
- </div>
121
- </div>
122
- </div>
123
- </div>
124
- <section
125
- v-if="eventsData && validSelectedDate"
126
- class="col-span-1 my-10 mx-4 md:mx-0 md:my-0"
127
- >
128
- <h2
129
- v-if="showSelectedDate"
130
- class="hidden py-4 font-semibold text-gray-900 md:block"
131
- >
132
- Schedule for
133
- <time :datetime="selectedDateForDateTime">{{
134
- formattedSelectedDate
135
- }}</time>
136
- </h2>
137
- <p
138
- v-if="getEventsForDate(value).length === 0"
139
- class="mt-3 text-center text-sm text-gray-400"
140
- >
141
- Sorry, no events found for this date.
142
- </p>
143
- <ol
144
- v-if="getEventsForDate(value).length !== 0"
145
- class="mt-3 divide-y divide-gray-100 overflow-hidden rounded-lg bg-white text-sm shadow ring-1 ring-indigo-700 ring-opacity-5"
146
- >
147
- <li
148
- class="cursor-pointer p-4 focus-within:bg-gray-50 hover:bg-gray-50"
149
- v-for="event in getEventsForDate(value)"
150
- :key="event.id"
151
- @click="handleEventClick(event)"
152
- >
153
- <div class="text-sm text-gray-900">
154
- {{ formatTimeFromDate(event.start) }} -
155
- {{ formatTimeFromDate(event.end) }}
156
- </div>
157
- <div
158
- class="mt-1 flex text-sm font-semibold"
159
- :style="{ color: event.color }"
160
- :class="event.status === 7 ? 'line-through' : ''"
161
- >
162
- <c-icon
163
- v-if="event.attendance"
164
- name="check"
165
- type="solid"
166
- class="mt-0.5 h-4 w-4 shrink-0"
167
- :style="`color:${event.color}`"
168
- ></c-icon>
169
- {{ event.title }}
170
- </div>
171
- <div class="-mx-1 -my-0.5 flex flex-wrap items-center">
172
- <div class="mx-1 my-0.5 flex items-center space-x-0.5">
173
- <svg
174
- xmlns="http://www.w3.org/2000/svg"
175
- class="h-4 w-4 flex-none text-gray-400"
176
- fill="none"
177
- viewBox="0 0 24 24"
178
- stroke="currentColor"
179
- stroke-width="2"
180
- >
181
- <path
182
- stroke-linecap="round"
183
- stroke-linejoin="round"
184
- d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
185
- />
186
- </svg>
187
- <span class="min-w-0 flex-1 text-sm text-gray-500"
188
- >{{ event.duration }} mins</span
189
- >
190
- </div>
191
- <div
192
- v-if="event.subject && event.subject.length"
193
- class="mx-1 my-0.5 flex items-center space-x-0.5"
194
- >
195
- <svg
196
- xmlns="http://www.w3.org/2000/svg"
197
- class="h-4 w-4 flex-none text-gray-400"
198
- fill="none"
199
- viewBox="0 0 24 24"
200
- stroke="currentColor"
201
- stroke-width="2"
202
- >
203
- <path
204
- stroke-linecap="round"
205
- stroke-linejoin="round"
206
- d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
207
- />
208
- </svg>
209
- <span class="min-w-0 flex-1 text-sm text-gray-500">{{
210
- event.subject
211
- }}</span>
212
- </div>
213
- <div
214
- v-if="event.location && event.location.length"
215
- class="mx-1 my-0.5 flex items-center space-x-0.5"
216
- >
217
- <svg
218
- xmlns="http://www.w3.org/2000/svg"
219
- class="h-4 w-4 flex-none text-gray-400"
220
- fill="none"
221
- viewBox="0 0 24 24"
222
- stroke="currentColor"
223
- stroke-width="2"
224
- >
225
- <path
226
- stroke-linecap="round"
227
- stroke-linejoin="round"
228
- d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"
229
- />
230
- </svg>
231
- <span class="min-w-0 flex-1 text-sm text-gray-500">{{
232
- event.location
233
- }}</span>
234
- </div>
235
- <div
236
- v-if="event.staff && event.staff.length"
237
- class="mx-1 my-0.5 flex items-center space-x-0.5"
238
- >
239
- <svg
240
- xmlns="http://www.w3.org/2000/svg"
241
- class="h-4 w-4 flex-none text-gray-400"
242
- fill="none"
243
- viewBox="0 0 24 24"
244
- stroke="currentColor"
245
- stroke-width="2"
246
- >
247
- <path
248
- stroke-linecap="round"
249
- stroke-linejoin="round"
250
- d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
251
- />
252
- </svg>
253
- <span class="min-w-0 flex-1 text-sm text-gray-500">{{
254
- event.staff
255
- }}</span>
256
- </div>
257
- </div>
258
- </li>
259
- </ol>
260
- </section>
261
- </div>
262
- </div>
263
- </template>
264
-
265
- <script>
266
- import * as dayjs from "dayjs";
267
- import CIcon from "../CIcon/CIcon.vue";
268
-
269
- export default {
270
- name: "CCalendar",
271
- components: { CIcon },
272
- props: {
273
- value: {
274
- type: [String, Date, Object],
275
- default: () => dayjs(),
276
- },
277
- eventsCount: {
278
- type: Array,
279
- default: () => null,
280
- },
281
- eventsData: {
282
- type: Array,
283
- default: () => null,
284
- },
285
- calendarClasses: {
286
- type: String,
287
- default: "",
288
- },
289
- showSelectedDate: {
290
- type: Boolean,
291
- default: true,
292
- },
293
- },
294
- data() {
295
- return {
296
- activeDate: dayjs(),
297
- };
298
- },
299
- methods: {
300
- handlePreviousMonthClick() {
301
- this.activeDate = this.activeDate.subtract(1, "month");
302
- this.$emit("prev-month", this.getActiveStartAndEndDates());
303
- },
304
- handleNextMonthClick() {
305
- this.activeDate = this.activeDate.add(1, "month");
306
- this.$emit("next-month", this.getActiveStartAndEndDates());
307
- },
308
- handleDateClick(date) {
309
- this.$emit("input", date);
310
- },
311
- getDayFromDate(date) {
312
- return dayjs(date).format("D");
313
- },
314
- isSelected(date) {
315
- return dayjs(date).isSame(this.value, "day");
316
- },
317
- isToday(date) {
318
- return dayjs(date).isSame(dayjs(), "day");
319
- },
320
- isCurrentMonth(date) {
321
- return dayjs(date).isSame(this.activeDate, "month");
322
- },
323
- getDateKey(date) {
324
- return dayjs(date).format();
325
- },
326
- formatForDateTime(date) {
327
- return dayjs(date).format("YYYY-MM-DD");
328
- },
329
- formatTimeFromDate(date) {
330
- return dayjs(date).format("hh:mma");
331
- },
332
- getEventsCountForDate(date) {
333
- let eventsCountObj = this.eventsCount.find((event) =>
334
- dayjs(date).isSame(dayjs(event.date), "day")
335
- );
336
- if (eventsCountObj) {
337
- return eventsCountObj.eventsCount;
338
- } else {
339
- return 0;
340
- }
341
- },
342
- getActiveStartAndEndDates() {
343
- return {
344
- startDate: this.daysArray[0],
345
- endDate: this.daysArray[this.daysArray.length - 1],
346
- };
347
- },
348
- getEventsForDate(date) {
349
- return this.eventsData.filter((event) =>
350
- dayjs(date).isSame(dayjs(event.start), "day")
351
- );
352
- },
353
- handleEventClick(event) {
354
- this.$emit("event-click", event);
355
- },
356
- },
357
- computed: {
358
- currentMonthAndYear() {
359
- return dayjs(this.activeDate).format("MMMM YYYY");
360
- },
361
- daysArray() {
362
- let dates = [];
363
- let firstDayOfmonth = dayjs(this.activeDate).startOf("month");
364
- let lastDayOfmonth = dayjs(this.activeDate).endOf("month");
365
- let firstDayOfMonthInWeek = firstDayOfmonth.day();
366
- let lastDayOfMonthInWeek = lastDayOfmonth.day();
367
- if (firstDayOfMonthInWeek === 0) {
368
- firstDayOfMonthInWeek = 7;
369
- }
370
- if (lastDayOfMonthInWeek === 0) {
371
- lastDayOfMonthInWeek = 7;
372
- }
373
- for (let i = 0; i < firstDayOfMonthInWeek - 1; i++) {
374
- dates.unshift(firstDayOfmonth.subtract(i + 1, "day"));
375
- }
376
- for (let i = 0; i < dayjs(this.activeDate).daysInMonth(); i++) {
377
- dates.push(firstDayOfmonth.add(i, "day"));
378
- }
379
- let cursor = 1;
380
- for (let i = lastDayOfMonthInWeek; i < 7; i++) {
381
- dates.push(lastDayOfmonth.add(cursor, "day"));
382
- cursor++;
383
- }
384
- if (dates.length !== 42) {
385
- let lastDayOfDates = dates[dates.length - 1];
386
- for (let i = 1; i <= 7; i++) {
387
- dates.push(lastDayOfDates.add(i, "day"));
388
- }
389
- }
390
- return dates;
391
- },
392
- formattedSelectedDate() {
393
- return dayjs(this.value ?? dayjs()).format("MMMM D, YYYY");
394
- },
395
- selectedDateForDateTime() {
396
- return dayjs(this.value ?? dayjs()).format("YYYY-MM-DD");
397
- },
398
- validSelectedDate() {
399
- return this.value && dayjs(this.value).isValid();
400
- },
401
- },
402
- mounted() {
403
- if (this.value) {
404
- this.activeDate = dayjs(this.value);
405
- }
406
- },
407
- };
408
- </script>
409
-
410
- <style></style>
1
+ <template>
2
+ <!-- This example requires Tailwind CSS v2.0+ -->
3
+ <div>
4
+ <div class="grid grid-cols-1 md:grid-cols-2 md:gap-8">
5
+ <div :class="`sticky top-0 md:block ${calendarClasses}`">
6
+ <div
7
+ class="relative z-20 flex items-center justify-between border-b border-gray-200 py-4 px-4 sm:px-0"
8
+ >
9
+ <h2 class="flex-auto font-semibold text-gray-900">
10
+ {{ currentMonthAndYear }}
11
+ </h2>
12
+ <div class="flex items-center">
13
+ <div class="flex items-center rounded-md shadow-sm">
14
+ <button
15
+ @click="handlePreviousMonthClick"
16
+ type="button"
17
+ class="flex items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-white py-2 pl-3 pr-4 text-gray-400 hover:text-gray-500 focus:relative"
18
+ >
19
+ <span class="sr-only">Previous month</span>
20
+ <!-- Heroicon name: solid/chevron-left -->
21
+ <svg
22
+ class="h-5 w-5"
23
+ xmlns="http://www.w3.org/2000/svg"
24
+ viewBox="0 0 20 20"
25
+ fill="currentColor"
26
+ aria-hidden="true"
27
+ >
28
+ <path
29
+ fill-rule="evenodd"
30
+ d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
31
+ clip-rule="evenodd"
32
+ />
33
+ </svg>
34
+ </button>
35
+ <span class="relative -mx-px h-5 w-px bg-gray-300"></span>
36
+ <button
37
+ @click="handleNextMonthClick"
38
+ type="button"
39
+ class="flex items-center justify-center rounded-r-md border border-l-0 border-gray-300 bg-white py-2 pl-4 pr-3 text-gray-400 hover:text-gray-500 focus:relative"
40
+ >
41
+ <span class="sr-only">Next month</span>
42
+ <!-- Heroicon name: solid/chevron-right -->
43
+ <svg
44
+ class="h-5 w-5"
45
+ xmlns="http://www.w3.org/2000/svg"
46
+ viewBox="0 0 20 20"
47
+ fill="currentColor"
48
+ aria-hidden="true"
49
+ >
50
+ <path
51
+ fill-rule="evenodd"
52
+ d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
53
+ clip-rule="evenodd"
54
+ />
55
+ </svg>
56
+ </button>
57
+ </div>
58
+ </div>
59
+ </div>
60
+
61
+ <div
62
+ class="col-span-1 overflow-hidden rounded shadow ring-1 ring-gray-200"
63
+ >
64
+ <div
65
+ class="grid grid-cols-7 gap-px border-b border-gray-300 bg-gray-200 text-center text-xs font-semibold leading-6 text-gray-700"
66
+ >
67
+ <div class="bg-white py-2">Mo<span class="sr-only">on</span></div>
68
+ <div class="bg-white py-2">Tu<span class="sr-only">ue</span></div>
69
+ <div class="bg-white py-2">We<span class="sr-only">ed</span></div>
70
+ <div class="bg-white py-2">Th<span class="sr-only">hu</span></div>
71
+ <div class="bg-white py-2">Fr<span class="sr-only">ri</span></div>
72
+ <div class="bg-white py-2">Sa<span class="sr-only">at</span></div>
73
+ <div class="bg-white py-2">Su<span class="sr-only">un</span></div>
74
+ </div>
75
+ <div class="flex bg-gray-200 text-xs leading-6 text-gray-700">
76
+ <div class="isolate grid w-full grid-cols-7 grid-rows-6 gap-px">
77
+ <button
78
+ v-for="date in daysArray"
79
+ :key="getDateKey(date)"
80
+ type="button"
81
+ :class="{
82
+ 'flex h-14 flex-col py-2 px-3 hover:bg-gray-100 focus:z-10': true,
83
+ 'bg-white': isCurrentMonth(date),
84
+ 'bg-gray-50': !isCurrentMonth(date),
85
+ 'font-semibold': isSelected(date) || isToday(date),
86
+ 'text-white': isSelected(date),
87
+ 'text-indigo-600': !isSelected(date) && isToday(date),
88
+ 'text-gray-900':
89
+ !isSelected(date) && isCurrentMonth(date) && !isToday(date),
90
+ 'text-gray-500':
91
+ !isSelected(date) &&
92
+ !isCurrentMonth(date) &&
93
+ !isToday(date),
94
+ }"
95
+ @click="handleDateClick(date)"
96
+ >
97
+ <time
98
+ :datetime="formatForDateTime(date)"
99
+ :class="{
100
+ 'ml-auto': true,
101
+ 'flex h-6 w-6 items-center justify-center rounded-full':
102
+ isSelected(date),
103
+ 'bg-indigo-600': isSelected(date) && isToday(date),
104
+ 'bg-gray-900': isSelected(date) && !isToday(date),
105
+ }"
106
+ >{{ getDayFromDate(date) }}</time
107
+ >
108
+ <span v-if="eventsCount" class="sr-only"
109
+ >{{ getEventsCountForDate(date) }} events</span
110
+ >
111
+ <span
112
+ v-if="eventsCount && getEventsCountForDate(date) > 0"
113
+ class="-mx-0.5 mt-auto flex flex-wrap-reverse"
114
+ >
115
+ <span
116
+ class="mx-0.5 mb-1 h-1.5 w-1.5 rounded-full bg-gray-400"
117
+ ></span>
118
+ </span>
119
+ </button>
120
+ </div>
121
+ </div>
122
+ </div>
123
+ </div>
124
+ <section
125
+ v-if="eventsData && validSelectedDate"
126
+ class="col-span-1 my-10 mx-4 md:mx-0 md:my-0"
127
+ >
128
+ <h2
129
+ v-if="showSelectedDate"
130
+ class="hidden py-4 font-semibold text-gray-900 md:block"
131
+ >
132
+ Schedule for
133
+ <time :datetime="selectedDateForDateTime">{{
134
+ formattedSelectedDate
135
+ }}</time>
136
+ </h2>
137
+ <p
138
+ v-if="getEventsForDate(value).length === 0"
139
+ class="mt-3 text-center text-sm text-gray-400"
140
+ >
141
+ Sorry, no events found for this date.
142
+ </p>
143
+ <ol
144
+ v-if="getEventsForDate(value).length !== 0"
145
+ class="mt-3 divide-y divide-gray-100 overflow-hidden rounded-lg bg-white text-sm shadow ring-1 ring-indigo-700 ring-opacity-5"
146
+ >
147
+ <li
148
+ class="cursor-pointer p-4 focus-within:bg-gray-50 hover:bg-gray-50"
149
+ v-for="event in getEventsForDate(value)"
150
+ :key="event.id"
151
+ @click="handleEventClick(event)"
152
+ >
153
+ <div class="text-sm text-gray-900">
154
+ {{ formatTimeFromDate(event.start) }} -
155
+ {{ formatTimeFromDate(event.end) }}
156
+ </div>
157
+ <div
158
+ class="mt-1 flex text-sm font-semibold"
159
+ :style="{ color: event.color }"
160
+ :class="event.status === 7 ? 'line-through' : ''"
161
+ >
162
+ <c-icon
163
+ v-if="event.attendance"
164
+ name="check"
165
+ type="solid"
166
+ class="mt-0.5 h-4 w-4 shrink-0"
167
+ :style="`color:${event.color}`"
168
+ ></c-icon>
169
+ {{ event.title }}
170
+ </div>
171
+ <div class="-mx-1 -my-0.5 flex flex-wrap items-center">
172
+ <div class="mx-1 my-0.5 flex items-center space-x-0.5">
173
+ <svg
174
+ xmlns="http://www.w3.org/2000/svg"
175
+ class="h-4 w-4 flex-none text-gray-400"
176
+ fill="none"
177
+ viewBox="0 0 24 24"
178
+ stroke="currentColor"
179
+ stroke-width="2"
180
+ >
181
+ <path
182
+ stroke-linecap="round"
183
+ stroke-linejoin="round"
184
+ d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
185
+ />
186
+ </svg>
187
+ <span class="min-w-0 flex-1 text-sm text-gray-500"
188
+ >{{ event.duration }} mins</span
189
+ >
190
+ </div>
191
+ <div
192
+ v-if="event.subject && event.subject.length"
193
+ class="mx-1 my-0.5 flex items-center space-x-0.5"
194
+ >
195
+ <svg
196
+ xmlns="http://www.w3.org/2000/svg"
197
+ class="h-4 w-4 flex-none text-gray-400"
198
+ fill="none"
199
+ viewBox="0 0 24 24"
200
+ stroke="currentColor"
201
+ stroke-width="2"
202
+ >
203
+ <path
204
+ stroke-linecap="round"
205
+ stroke-linejoin="round"
206
+ d="M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"
207
+ />
208
+ </svg>
209
+ <span class="min-w-0 flex-1 text-sm text-gray-500">{{
210
+ event.subject
211
+ }}</span>
212
+ </div>
213
+ <div
214
+ v-if="event.location && event.location.length"
215
+ class="mx-1 my-0.5 flex items-center space-x-0.5"
216
+ >
217
+ <svg
218
+ xmlns="http://www.w3.org/2000/svg"
219
+ class="h-4 w-4 flex-none text-gray-400"
220
+ fill="none"
221
+ viewBox="0 0 24 24"
222
+ stroke="currentColor"
223
+ stroke-width="2"
224
+ >
225
+ <path
226
+ stroke-linecap="round"
227
+ stroke-linejoin="round"
228
+ d="M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7"
229
+ />
230
+ </svg>
231
+ <span class="min-w-0 flex-1 text-sm text-gray-500">{{
232
+ event.location
233
+ }}</span>
234
+ </div>
235
+ <div
236
+ v-if="event.staff && event.staff.length"
237
+ class="mx-1 my-0.5 flex items-center space-x-0.5"
238
+ >
239
+ <svg
240
+ xmlns="http://www.w3.org/2000/svg"
241
+ class="h-4 w-4 flex-none text-gray-400"
242
+ fill="none"
243
+ viewBox="0 0 24 24"
244
+ stroke="currentColor"
245
+ stroke-width="2"
246
+ >
247
+ <path
248
+ stroke-linecap="round"
249
+ stroke-linejoin="round"
250
+ d="M21 13.255A23.931 23.931 0 0112 15c-3.183 0-6.22-.62-9-1.745M16 6V4a2 2 0 00-2-2h-4a2 2 0 00-2 2v2m4 6h.01M5 20h14a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
251
+ />
252
+ </svg>
253
+ <span class="min-w-0 flex-1 text-sm text-gray-500">{{
254
+ event.staff
255
+ }}</span>
256
+ </div>
257
+ </div>
258
+ </li>
259
+ </ol>
260
+ </section>
261
+ </div>
262
+ </div>
263
+ </template>
264
+
265
+ <script>
266
+ import * as dayjs from "dayjs";
267
+ import CIcon from "../CIcon/CIcon.vue";
268
+
269
+ export default {
270
+ name: "CCalendar",
271
+ components: { CIcon },
272
+ props: {
273
+ value: {
274
+ type: [String, Date, Object],
275
+ default: () => dayjs(),
276
+ },
277
+ eventsCount: {
278
+ type: Array,
279
+ default: () => null,
280
+ },
281
+ eventsData: {
282
+ type: Array,
283
+ default: () => null,
284
+ },
285
+ calendarClasses: {
286
+ type: String,
287
+ default: "",
288
+ },
289
+ showSelectedDate: {
290
+ type: Boolean,
291
+ default: true,
292
+ },
293
+ },
294
+ data() {
295
+ return {
296
+ activeDate: dayjs(),
297
+ };
298
+ },
299
+ methods: {
300
+ handlePreviousMonthClick() {
301
+ this.activeDate = this.activeDate.subtract(1, "month");
302
+ this.$emit("prev-month", this.getActiveStartAndEndDates());
303
+ },
304
+ handleNextMonthClick() {
305
+ this.activeDate = this.activeDate.add(1, "month");
306
+ this.$emit("next-month", this.getActiveStartAndEndDates());
307
+ },
308
+ handleDateClick(date) {
309
+ this.$emit("input", date);
310
+ },
311
+ getDayFromDate(date) {
312
+ return dayjs(date).format("D");
313
+ },
314
+ isSelected(date) {
315
+ return dayjs(date).isSame(this.value, "day");
316
+ },
317
+ isToday(date) {
318
+ return dayjs(date).isSame(dayjs(), "day");
319
+ },
320
+ isCurrentMonth(date) {
321
+ return dayjs(date).isSame(this.activeDate, "month");
322
+ },
323
+ getDateKey(date) {
324
+ return dayjs(date).format();
325
+ },
326
+ formatForDateTime(date) {
327
+ return dayjs(date).format("YYYY-MM-DD");
328
+ },
329
+ formatTimeFromDate(date) {
330
+ return dayjs(date).format("hh:mma");
331
+ },
332
+ getEventsCountForDate(date) {
333
+ let eventsCountObj = this.eventsCount.find((event) =>
334
+ dayjs(date).isSame(dayjs(event.date), "day")
335
+ );
336
+ if (eventsCountObj) {
337
+ return eventsCountObj.eventsCount;
338
+ } else {
339
+ return 0;
340
+ }
341
+ },
342
+ getActiveStartAndEndDates() {
343
+ return {
344
+ startDate: this.daysArray[0],
345
+ endDate: this.daysArray[this.daysArray.length - 1],
346
+ };
347
+ },
348
+ getEventsForDate(date) {
349
+ return this.eventsData.filter((event) =>
350
+ dayjs(date).isSame(dayjs(event.start), "day")
351
+ );
352
+ },
353
+ handleEventClick(event) {
354
+ this.$emit("event-click", event);
355
+ },
356
+ },
357
+ computed: {
358
+ currentMonthAndYear() {
359
+ return dayjs(this.activeDate).format("MMMM YYYY");
360
+ },
361
+ daysArray() {
362
+ let dates = [];
363
+ let firstDayOfmonth = dayjs(this.activeDate).startOf("month");
364
+ let lastDayOfmonth = dayjs(this.activeDate).endOf("month");
365
+ let firstDayOfMonthInWeek = firstDayOfmonth.day();
366
+ let lastDayOfMonthInWeek = lastDayOfmonth.day();
367
+ if (firstDayOfMonthInWeek === 0) {
368
+ firstDayOfMonthInWeek = 7;
369
+ }
370
+ if (lastDayOfMonthInWeek === 0) {
371
+ lastDayOfMonthInWeek = 7;
372
+ }
373
+ for (let i = 0; i < firstDayOfMonthInWeek - 1; i++) {
374
+ dates.unshift(firstDayOfmonth.subtract(i + 1, "day"));
375
+ }
376
+ for (let i = 0; i < dayjs(this.activeDate).daysInMonth(); i++) {
377
+ dates.push(firstDayOfmonth.add(i, "day"));
378
+ }
379
+ let cursor = 1;
380
+ for (let i = lastDayOfMonthInWeek; i < 7; i++) {
381
+ dates.push(lastDayOfmonth.add(cursor, "day"));
382
+ cursor++;
383
+ }
384
+ if (dates.length !== 42) {
385
+ let lastDayOfDates = dates[dates.length - 1];
386
+ for (let i = 1; i <= 7; i++) {
387
+ dates.push(lastDayOfDates.add(i, "day"));
388
+ }
389
+ }
390
+ return dates;
391
+ },
392
+ formattedSelectedDate() {
393
+ return dayjs(this.value ?? dayjs()).format("MMMM D, YYYY");
394
+ },
395
+ selectedDateForDateTime() {
396
+ return dayjs(this.value ?? dayjs()).format("YYYY-MM-DD");
397
+ },
398
+ validSelectedDate() {
399
+ return this.value && dayjs(this.value).isValid();
400
+ },
401
+ },
402
+ mounted() {
403
+ if (this.value) {
404
+ this.activeDate = dayjs(this.value);
405
+ }
406
+ },
407
+ };
408
+ </script>
409
+
410
+ <style></style>