@fullcalendar/core 7.0.0-beta.6 → 7.0.0-beta.8

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 (426) hide show
  1. package/README.md +3 -48
  2. package/index.d.ts +1 -0
  3. package/index.js +1 -0
  4. package/package.json +16 -63
  5. package/protected-api.d.ts +28 -0
  6. package/protected-api.js +39 -0
  7. package/cjs/index.cjs +0 -2208
  8. package/cjs/internal-classnames.cjs +0 -11
  9. package/cjs/internal-common.cjs +0 -7885
  10. package/cjs/internal.cjs +0 -192
  11. package/cjs/locales/af.cjs +0 -24
  12. package/cjs/locales/ar-dz.cjs +0 -25
  13. package/cjs/locales/ar-kw.cjs +0 -25
  14. package/cjs/locales/ar-ly.cjs +0 -25
  15. package/cjs/locales/ar-ma.cjs +0 -25
  16. package/cjs/locales/ar-sa.cjs +0 -25
  17. package/cjs/locales/ar-tn.cjs +0 -25
  18. package/cjs/locales/ar.cjs +0 -25
  19. package/cjs/locales/az.cjs +0 -26
  20. package/cjs/locales/bg.cjs +0 -26
  21. package/cjs/locales/bn.cjs +0 -26
  22. package/cjs/locales/bs.cjs +0 -27
  23. package/cjs/locales/ca.cjs +0 -25
  24. package/cjs/locales/cs.cjs +0 -27
  25. package/cjs/locales/cy.cjs +0 -24
  26. package/cjs/locales/da.cjs +0 -24
  27. package/cjs/locales/de-at.cjs +0 -57
  28. package/cjs/locales/de.cjs +0 -57
  29. package/cjs/locales/el.cjs +0 -25
  30. package/cjs/locales/en-au.cjs +0 -22
  31. package/cjs/locales/en-gb.cjs +0 -22
  32. package/cjs/locales/en-nz.cjs +0 -22
  33. package/cjs/locales/eo.cjs +0 -25
  34. package/cjs/locales/es-us.cjs +0 -34
  35. package/cjs/locales/es.cjs +0 -40
  36. package/cjs/locales/et.cjs +0 -27
  37. package/cjs/locales/eu.cjs +0 -25
  38. package/cjs/locales/fa.cjs +0 -28
  39. package/cjs/locales/fi.cjs +0 -25
  40. package/cjs/locales/fr-ca.cjs +0 -21
  41. package/cjs/locales/fr-ch.cjs +0 -25
  42. package/cjs/locales/fr.cjs +0 -25
  43. package/cjs/locales/gl.cjs +0 -40
  44. package/cjs/locales/he.cjs +0 -21
  45. package/cjs/locales/hi.cjs +0 -27
  46. package/cjs/locales/hr.cjs +0 -27
  47. package/cjs/locales/hu.cjs +0 -24
  48. package/cjs/locales/hy-am.cjs +0 -27
  49. package/cjs/locales/id.cjs +0 -25
  50. package/cjs/locales/is.cjs +0 -24
  51. package/cjs/locales/it.cjs +0 -27
  52. package/cjs/locales/ja.cjs +0 -22
  53. package/cjs/locales/ka.cjs +0 -27
  54. package/cjs/locales/kk.cjs +0 -26
  55. package/cjs/locales/km.cjs +0 -24
  56. package/cjs/locales/ko.cjs +0 -20
  57. package/cjs/locales/ku.cjs +0 -25
  58. package/cjs/locales/lb.cjs +0 -25
  59. package/cjs/locales/lt.cjs +0 -25
  60. package/cjs/locales/lv.cjs +0 -27
  61. package/cjs/locales/mk.cjs +0 -23
  62. package/cjs/locales/ms.cjs +0 -27
  63. package/cjs/locales/nb.cjs +0 -32
  64. package/cjs/locales/ne.cjs +0 -24
  65. package/cjs/locales/nl.cjs +0 -24
  66. package/cjs/locales/nn.cjs +0 -24
  67. package/cjs/locales/pl.cjs +0 -25
  68. package/cjs/locales/pt-br.cjs +0 -40
  69. package/cjs/locales/pt.cjs +0 -25
  70. package/cjs/locales/ro.cjs +0 -27
  71. package/cjs/locales/ru.cjs +0 -27
  72. package/cjs/locales/si-lk.cjs +0 -25
  73. package/cjs/locales/sk.cjs +0 -27
  74. package/cjs/locales/sl.cjs +0 -24
  75. package/cjs/locales/sm.cjs +0 -20
  76. package/cjs/locales/sq.cjs +0 -27
  77. package/cjs/locales/sr-cyrl.cjs +0 -27
  78. package/cjs/locales/sr.cjs +0 -27
  79. package/cjs/locales/sv.cjs +0 -41
  80. package/cjs/locales/ta-in.cjs +0 -26
  81. package/cjs/locales/th.cjs +0 -26
  82. package/cjs/locales/tr.cjs +0 -25
  83. package/cjs/locales/ug.cjs +0 -18
  84. package/cjs/locales/uk.cjs +0 -27
  85. package/cjs/locales/uz-cy.cjs +0 -25
  86. package/cjs/locales/uz.cjs +0 -26
  87. package/cjs/locales/vi.cjs +0 -27
  88. package/cjs/locales/zh-cn.cjs +0 -27
  89. package/cjs/locales/zh-tw.cjs +0 -20
  90. package/cjs/locales-all.cjs +0 -89
  91. package/cjs/preact.cjs +0 -24
  92. package/esm/index.d.ts +0 -53
  93. package/esm/index.js +0 -2195
  94. package/esm/internal-classnames.d.ts +0 -1
  95. package/esm/internal-classnames.js +0 -3
  96. package/esm/internal-common.d.ts +0 -2778
  97. package/esm/internal-common.js +0 -7652
  98. package/esm/internal.d.ts +0 -5
  99. package/esm/internal.js +0 -3
  100. package/esm/locales/af.d.ts +0 -6
  101. package/esm/locales/af.js +0 -20
  102. package/esm/locales/ar-dz.d.ts +0 -6
  103. package/esm/locales/ar-dz.js +0 -21
  104. package/esm/locales/ar-kw.d.ts +0 -6
  105. package/esm/locales/ar-kw.js +0 -21
  106. package/esm/locales/ar-ly.d.ts +0 -6
  107. package/esm/locales/ar-ly.js +0 -21
  108. package/esm/locales/ar-ma.d.ts +0 -6
  109. package/esm/locales/ar-ma.js +0 -21
  110. package/esm/locales/ar-sa.d.ts +0 -6
  111. package/esm/locales/ar-sa.js +0 -21
  112. package/esm/locales/ar-tn.d.ts +0 -6
  113. package/esm/locales/ar-tn.js +0 -21
  114. package/esm/locales/ar.d.ts +0 -6
  115. package/esm/locales/ar.js +0 -21
  116. package/esm/locales/az.d.ts +0 -6
  117. package/esm/locales/az.js +0 -22
  118. package/esm/locales/bg.d.ts +0 -6
  119. package/esm/locales/bg.js +0 -22
  120. package/esm/locales/bn.d.ts +0 -6
  121. package/esm/locales/bn.js +0 -22
  122. package/esm/locales/bs.d.ts +0 -6
  123. package/esm/locales/bs.js +0 -23
  124. package/esm/locales/ca.d.ts +0 -6
  125. package/esm/locales/ca.js +0 -21
  126. package/esm/locales/cs.d.ts +0 -6
  127. package/esm/locales/cs.js +0 -23
  128. package/esm/locales/cy.d.ts +0 -6
  129. package/esm/locales/cy.js +0 -20
  130. package/esm/locales/da.d.ts +0 -6
  131. package/esm/locales/da.js +0 -20
  132. package/esm/locales/de-at.d.ts +0 -6
  133. package/esm/locales/de-at.js +0 -53
  134. package/esm/locales/de.d.ts +0 -6
  135. package/esm/locales/de.js +0 -53
  136. package/esm/locales/el.d.ts +0 -6
  137. package/esm/locales/el.js +0 -21
  138. package/esm/locales/en-au.d.ts +0 -6
  139. package/esm/locales/en-au.js +0 -18
  140. package/esm/locales/en-gb.d.ts +0 -6
  141. package/esm/locales/en-gb.js +0 -18
  142. package/esm/locales/en-nz.d.ts +0 -6
  143. package/esm/locales/en-nz.js +0 -18
  144. package/esm/locales/eo.d.ts +0 -6
  145. package/esm/locales/eo.js +0 -21
  146. package/esm/locales/es-us.d.ts +0 -6
  147. package/esm/locales/es-us.js +0 -30
  148. package/esm/locales/es.d.ts +0 -6
  149. package/esm/locales/es.js +0 -36
  150. package/esm/locales/et.d.ts +0 -6
  151. package/esm/locales/et.js +0 -23
  152. package/esm/locales/eu.d.ts +0 -6
  153. package/esm/locales/eu.js +0 -21
  154. package/esm/locales/fa.d.ts +0 -6
  155. package/esm/locales/fa.js +0 -24
  156. package/esm/locales/fi.d.ts +0 -6
  157. package/esm/locales/fi.js +0 -21
  158. package/esm/locales/fr-ca.d.ts +0 -6
  159. package/esm/locales/fr-ca.js +0 -17
  160. package/esm/locales/fr-ch.d.ts +0 -6
  161. package/esm/locales/fr-ch.js +0 -21
  162. package/esm/locales/fr.d.ts +0 -6
  163. package/esm/locales/fr.js +0 -21
  164. package/esm/locales/gl.d.ts +0 -6
  165. package/esm/locales/gl.js +0 -36
  166. package/esm/locales/he.d.ts +0 -6
  167. package/esm/locales/he.js +0 -17
  168. package/esm/locales/hi.d.ts +0 -6
  169. package/esm/locales/hi.js +0 -23
  170. package/esm/locales/hr.d.ts +0 -6
  171. package/esm/locales/hr.js +0 -23
  172. package/esm/locales/hu.d.ts +0 -6
  173. package/esm/locales/hu.js +0 -20
  174. package/esm/locales/hy-am.d.ts +0 -6
  175. package/esm/locales/hy-am.js +0 -23
  176. package/esm/locales/id.d.ts +0 -6
  177. package/esm/locales/id.js +0 -21
  178. package/esm/locales/is.d.ts +0 -6
  179. package/esm/locales/is.js +0 -20
  180. package/esm/locales/it.d.ts +0 -6
  181. package/esm/locales/it.js +0 -23
  182. package/esm/locales/ja.d.ts +0 -6
  183. package/esm/locales/ja.js +0 -18
  184. package/esm/locales/ka.d.ts +0 -6
  185. package/esm/locales/ka.js +0 -23
  186. package/esm/locales/kk.d.ts +0 -6
  187. package/esm/locales/kk.js +0 -22
  188. package/esm/locales/km.d.ts +0 -6
  189. package/esm/locales/km.js +0 -20
  190. package/esm/locales/ko.d.ts +0 -6
  191. package/esm/locales/ko.js +0 -16
  192. package/esm/locales/ku.d.ts +0 -6
  193. package/esm/locales/ku.js +0 -21
  194. package/esm/locales/lb.d.ts +0 -6
  195. package/esm/locales/lb.js +0 -21
  196. package/esm/locales/lt.d.ts +0 -6
  197. package/esm/locales/lt.js +0 -21
  198. package/esm/locales/lv.d.ts +0 -6
  199. package/esm/locales/lv.js +0 -23
  200. package/esm/locales/mk.d.ts +0 -6
  201. package/esm/locales/mk.js +0 -19
  202. package/esm/locales/ms.d.ts +0 -6
  203. package/esm/locales/ms.js +0 -23
  204. package/esm/locales/nb.d.ts +0 -6
  205. package/esm/locales/nb.js +0 -28
  206. package/esm/locales/ne.d.ts +0 -6
  207. package/esm/locales/ne.js +0 -20
  208. package/esm/locales/nl.d.ts +0 -6
  209. package/esm/locales/nl.js +0 -20
  210. package/esm/locales/nn.d.ts +0 -6
  211. package/esm/locales/nn.js +0 -20
  212. package/esm/locales/pl.d.ts +0 -6
  213. package/esm/locales/pl.js +0 -21
  214. package/esm/locales/pt-br.d.ts +0 -6
  215. package/esm/locales/pt-br.js +0 -36
  216. package/esm/locales/pt.d.ts +0 -6
  217. package/esm/locales/pt.js +0 -21
  218. package/esm/locales/ro.d.ts +0 -6
  219. package/esm/locales/ro.js +0 -23
  220. package/esm/locales/ru.d.ts +0 -6
  221. package/esm/locales/ru.js +0 -23
  222. package/esm/locales/si-lk.d.ts +0 -6
  223. package/esm/locales/si-lk.js +0 -21
  224. package/esm/locales/sk.d.ts +0 -6
  225. package/esm/locales/sk.js +0 -23
  226. package/esm/locales/sl.d.ts +0 -6
  227. package/esm/locales/sl.js +0 -20
  228. package/esm/locales/sm.d.ts +0 -6
  229. package/esm/locales/sm.js +0 -16
  230. package/esm/locales/sq.d.ts +0 -6
  231. package/esm/locales/sq.js +0 -23
  232. package/esm/locales/sr-cyrl.d.ts +0 -6
  233. package/esm/locales/sr-cyrl.js +0 -23
  234. package/esm/locales/sr.d.ts +0 -6
  235. package/esm/locales/sr.js +0 -23
  236. package/esm/locales/sv.d.ts +0 -6
  237. package/esm/locales/sv.js +0 -37
  238. package/esm/locales/ta-in.d.ts +0 -6
  239. package/esm/locales/ta-in.js +0 -22
  240. package/esm/locales/th.d.ts +0 -6
  241. package/esm/locales/th.js +0 -22
  242. package/esm/locales/tr.d.ts +0 -6
  243. package/esm/locales/tr.js +0 -21
  244. package/esm/locales/ug.d.ts +0 -6
  245. package/esm/locales/ug.js +0 -14
  246. package/esm/locales/uk.d.ts +0 -6
  247. package/esm/locales/uk.js +0 -23
  248. package/esm/locales/uz-cy.d.ts +0 -6
  249. package/esm/locales/uz-cy.js +0 -21
  250. package/esm/locales/uz.d.ts +0 -6
  251. package/esm/locales/uz.js +0 -22
  252. package/esm/locales/vi.d.ts +0 -6
  253. package/esm/locales/vi.js +0 -23
  254. package/esm/locales/zh-cn.d.ts +0 -6
  255. package/esm/locales/zh-cn.js +0 -23
  256. package/esm/locales/zh-tw.d.ts +0 -6
  257. package/esm/locales/zh-tw.js +0 -16
  258. package/esm/locales-all.d.ts +0 -6
  259. package/esm/locales-all.js +0 -85
  260. package/esm/preact.d.ts +0 -16
  261. package/esm/preact.js +0 -3
  262. package/global/locales/af.js +0 -30
  263. package/global/locales/af.min.js +0 -6
  264. package/global/locales/ar-dz.js +0 -31
  265. package/global/locales/ar-dz.min.js +0 -6
  266. package/global/locales/ar-kw.js +0 -31
  267. package/global/locales/ar-kw.min.js +0 -6
  268. package/global/locales/ar-ly.js +0 -31
  269. package/global/locales/ar-ly.min.js +0 -6
  270. package/global/locales/ar-ma.js +0 -31
  271. package/global/locales/ar-ma.min.js +0 -6
  272. package/global/locales/ar-sa.js +0 -31
  273. package/global/locales/ar-sa.min.js +0 -6
  274. package/global/locales/ar-tn.js +0 -31
  275. package/global/locales/ar-tn.min.js +0 -6
  276. package/global/locales/ar.js +0 -31
  277. package/global/locales/ar.min.js +0 -6
  278. package/global/locales/az.js +0 -32
  279. package/global/locales/az.min.js +0 -6
  280. package/global/locales/bg.js +0 -32
  281. package/global/locales/bg.min.js +0 -6
  282. package/global/locales/bn.js +0 -32
  283. package/global/locales/bn.min.js +0 -6
  284. package/global/locales/bs.js +0 -33
  285. package/global/locales/bs.min.js +0 -6
  286. package/global/locales/ca.js +0 -31
  287. package/global/locales/ca.min.js +0 -6
  288. package/global/locales/cs.js +0 -33
  289. package/global/locales/cs.min.js +0 -6
  290. package/global/locales/cy.js +0 -30
  291. package/global/locales/cy.min.js +0 -6
  292. package/global/locales/da.js +0 -30
  293. package/global/locales/da.min.js +0 -6
  294. package/global/locales/de-at.js +0 -63
  295. package/global/locales/de-at.min.js +0 -6
  296. package/global/locales/de.js +0 -63
  297. package/global/locales/de.min.js +0 -6
  298. package/global/locales/el.js +0 -31
  299. package/global/locales/el.min.js +0 -6
  300. package/global/locales/en-au.js +0 -28
  301. package/global/locales/en-au.min.js +0 -6
  302. package/global/locales/en-gb.js +0 -28
  303. package/global/locales/en-gb.min.js +0 -6
  304. package/global/locales/en-nz.js +0 -28
  305. package/global/locales/en-nz.min.js +0 -6
  306. package/global/locales/eo.js +0 -31
  307. package/global/locales/eo.min.js +0 -6
  308. package/global/locales/es-us.js +0 -40
  309. package/global/locales/es-us.min.js +0 -6
  310. package/global/locales/es.js +0 -46
  311. package/global/locales/es.min.js +0 -6
  312. package/global/locales/et.js +0 -33
  313. package/global/locales/et.min.js +0 -6
  314. package/global/locales/eu.js +0 -31
  315. package/global/locales/eu.min.js +0 -6
  316. package/global/locales/fa.js +0 -34
  317. package/global/locales/fa.min.js +0 -6
  318. package/global/locales/fi.js +0 -31
  319. package/global/locales/fi.min.js +0 -6
  320. package/global/locales/fr-ca.js +0 -27
  321. package/global/locales/fr-ca.min.js +0 -6
  322. package/global/locales/fr-ch.js +0 -31
  323. package/global/locales/fr-ch.min.js +0 -6
  324. package/global/locales/fr.js +0 -31
  325. package/global/locales/fr.min.js +0 -6
  326. package/global/locales/gl.js +0 -46
  327. package/global/locales/gl.min.js +0 -6
  328. package/global/locales/he.js +0 -27
  329. package/global/locales/he.min.js +0 -6
  330. package/global/locales/hi.js +0 -33
  331. package/global/locales/hi.min.js +0 -6
  332. package/global/locales/hr.js +0 -33
  333. package/global/locales/hr.min.js +0 -6
  334. package/global/locales/hu.js +0 -30
  335. package/global/locales/hu.min.js +0 -6
  336. package/global/locales/hy-am.js +0 -33
  337. package/global/locales/hy-am.min.js +0 -6
  338. package/global/locales/id.js +0 -31
  339. package/global/locales/id.min.js +0 -6
  340. package/global/locales/is.js +0 -30
  341. package/global/locales/is.min.js +0 -6
  342. package/global/locales/it.js +0 -33
  343. package/global/locales/it.min.js +0 -6
  344. package/global/locales/ja.js +0 -28
  345. package/global/locales/ja.min.js +0 -6
  346. package/global/locales/ka.js +0 -33
  347. package/global/locales/ka.min.js +0 -6
  348. package/global/locales/kk.js +0 -32
  349. package/global/locales/kk.min.js +0 -6
  350. package/global/locales/km.js +0 -30
  351. package/global/locales/km.min.js +0 -6
  352. package/global/locales/ko.js +0 -26
  353. package/global/locales/ko.min.js +0 -6
  354. package/global/locales/ku.js +0 -31
  355. package/global/locales/ku.min.js +0 -6
  356. package/global/locales/lb.js +0 -31
  357. package/global/locales/lb.min.js +0 -6
  358. package/global/locales/lt.js +0 -31
  359. package/global/locales/lt.min.js +0 -6
  360. package/global/locales/lv.js +0 -33
  361. package/global/locales/lv.min.js +0 -6
  362. package/global/locales/mk.js +0 -29
  363. package/global/locales/mk.min.js +0 -6
  364. package/global/locales/ms.js +0 -33
  365. package/global/locales/ms.min.js +0 -6
  366. package/global/locales/nb.js +0 -38
  367. package/global/locales/nb.min.js +0 -6
  368. package/global/locales/ne.js +0 -30
  369. package/global/locales/ne.min.js +0 -6
  370. package/global/locales/nl.js +0 -30
  371. package/global/locales/nl.min.js +0 -6
  372. package/global/locales/nn.js +0 -30
  373. package/global/locales/nn.min.js +0 -6
  374. package/global/locales/pl.js +0 -31
  375. package/global/locales/pl.min.js +0 -6
  376. package/global/locales/pt-br.js +0 -46
  377. package/global/locales/pt-br.min.js +0 -6
  378. package/global/locales/pt.js +0 -31
  379. package/global/locales/pt.min.js +0 -6
  380. package/global/locales/ro.js +0 -33
  381. package/global/locales/ro.min.js +0 -6
  382. package/global/locales/ru.js +0 -33
  383. package/global/locales/ru.min.js +0 -6
  384. package/global/locales/si-lk.js +0 -31
  385. package/global/locales/si-lk.min.js +0 -6
  386. package/global/locales/sk.js +0 -33
  387. package/global/locales/sk.min.js +0 -6
  388. package/global/locales/sl.js +0 -30
  389. package/global/locales/sl.min.js +0 -6
  390. package/global/locales/sm.js +0 -26
  391. package/global/locales/sm.min.js +0 -6
  392. package/global/locales/sq.js +0 -33
  393. package/global/locales/sq.min.js +0 -6
  394. package/global/locales/sr-cyrl.js +0 -33
  395. package/global/locales/sr-cyrl.min.js +0 -6
  396. package/global/locales/sr.js +0 -33
  397. package/global/locales/sr.min.js +0 -6
  398. package/global/locales/sv.js +0 -47
  399. package/global/locales/sv.min.js +0 -6
  400. package/global/locales/ta-in.js +0 -32
  401. package/global/locales/ta-in.min.js +0 -6
  402. package/global/locales/th.js +0 -32
  403. package/global/locales/th.min.js +0 -6
  404. package/global/locales/tr.js +0 -31
  405. package/global/locales/tr.min.js +0 -6
  406. package/global/locales/ug.js +0 -24
  407. package/global/locales/ug.min.js +0 -6
  408. package/global/locales/uk.js +0 -33
  409. package/global/locales/uk.min.js +0 -6
  410. package/global/locales/uz-cy.js +0 -31
  411. package/global/locales/uz-cy.min.js +0 -6
  412. package/global/locales/uz.js +0 -32
  413. package/global/locales/uz.min.js +0 -6
  414. package/global/locales/vi.js +0 -33
  415. package/global/locales/vi.min.js +0 -6
  416. package/global/locales/zh-cn.js +0 -33
  417. package/global/locales/zh-cn.min.js +0 -6
  418. package/global/locales/zh-tw.js +0 -26
  419. package/global/locales/zh-tw.min.js +0 -6
  420. package/global/locales-all.js +0 -1730
  421. package/global/locales-all.min.js +0 -6
  422. package/global.js +0 -10076
  423. package/global.min.js +0 -6
  424. package/skeleton.css +0 -477
  425. package/skeleton.min.css +0 -1
  426. package/skeleton.styles.js +0 -30
package/esm/index.js DELETED
@@ -1,2195 +0,0 @@
1
- import { m as mergeCalendarOptions, g as guid, i as isArraysEqual, a as mergeViewOptionsMap, b as mapHash, B as BaseComponent, V as ViewContextType, C as ContentContainer, c as generateClassName, d as greatestDurationDenominator, e as createDuration, f as arrayToHash, h as filterHash, j as buildEventSourceRefiners, p as parseEventSource, k as formatWithOrdinals, u as unpromisify, l as buildRangeApiWithTimeZone, n as identity, r as requestJson, s as subtractDurations, o as intersectRanges, q as startOfDay, t as addDays, v as hashValuesToArray, w as buildEventApis, D as DelayedRunner, x as createFormatter, y as diffWholeDays, z as memoize, A as memoizeObjArg, E as isPropsEqualShallow, F as Emitter, G as getInitialDate, H as rangeContainsMarker, I as createEmptyEventStore, J as reduceCurrentDate, K as reduceEventStore, L as rezoneEventStoreDates, M as BASE_OPTION_DEFAULTS, N as BASE_OPTION_REFINERS, O as CALENDAR_LISTENER_REFINERS, P as CALENDAR_ONLY_OPTION_REFINERS, Q as COMPLEX_OPTION_COMPARATORS, R as VIEW_ONLY_OPTION_REFINERS, S as DateEnv, T as DateProfileGenerator, U as createEventUi, W as parseBusinessHours, X as Interaction, Y as getElEventRange, Z as EventImpl, _ as listenBySelector, $ as classNames, a0 as listenToHoverBySelector, a1 as joinArrayishClassNames, a2 as joinClassNames, a3 as PureComponent, a4 as buildViewContext, a5 as getUniqueDomId, a6 as parseInteractionSettings, a7 as interactionSettingsStore, a8 as getIsHeightAuto, a9 as CalendarImpl, aa as flushSync, ab as CalendarRoot, ac as getNow, ad as RenderId, ae as applyStyleProp, af as sliceEventStore } from './internal-common.js';
2
- export { ag as JsonRequestError, a2 as joinClassNames } from './internal-common.js';
3
- import { createElement, Fragment, render } from 'preact';
4
- import 'preact/compat';
5
-
6
- const globalLocales = [];
7
-
8
- const MINIMAL_RAW_EN_LOCALE = {
9
- code: 'en',
10
- week: {
11
- dow: 0,
12
- doy: 4, // 4 days need to be within the year to be considered the first week
13
- },
14
- direction: 'ltr',
15
- todayText: 'Today',
16
- prevText: 'Prev',
17
- nextText: 'Next',
18
- prevYearText: 'Prev year',
19
- nextYearText: 'Next year',
20
- yearText: 'Year',
21
- monthText: 'Month',
22
- weekText: 'Week',
23
- dayText: 'Day',
24
- listText: 'List',
25
- closeHint: 'Close',
26
- eventsHint: 'Events',
27
- allDayText: 'All-day',
28
- timedText: 'Timed',
29
- moreLinkText: 'more',
30
- noEventsText: 'No events to display',
31
- };
32
- /*
33
- Includes things we don't want other locales to inherit,
34
- things that derive from other translatable strings.
35
- */
36
- const RAW_EN_LOCALE = Object.assign(Object.assign({}, MINIMAL_RAW_EN_LOCALE), {
37
- // if a locale doesn't define this, fall back to weekText, don't use EN
38
- weekTextShort: 'W', todayHint: (unitText, unit) => {
39
- return (unit === 'day')
40
- ? 'Today'
41
- : `This ${unitText}`;
42
- }, prevHint: 'Previous $0', nextHint: 'Next $0', viewHint: '$0 view', viewChangeHint: 'Change view', navLinkHint: 'Go to $0', moreLinkHint(eventCnt) {
43
- return `Show ${eventCnt} more event${eventCnt === 1 ? '' : 's'}`;
44
- } });
45
- function organizeRawLocales(explicitRawLocales) {
46
- let defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : 'en';
47
- let allRawLocales = globalLocales.concat(explicitRawLocales);
48
- let rawLocaleMap = {
49
- en: RAW_EN_LOCALE,
50
- };
51
- for (let rawLocale of allRawLocales) {
52
- rawLocaleMap[rawLocale.code] = rawLocale;
53
- }
54
- return {
55
- map: rawLocaleMap,
56
- defaultCode,
57
- };
58
- }
59
- function buildLocale(inputSingular, available) {
60
- if (typeof inputSingular === 'object' && !Array.isArray(inputSingular)) {
61
- return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
62
- }
63
- return queryLocale(inputSingular, available);
64
- }
65
- function queryLocale(codeArg, available) {
66
- let codes = [].concat(codeArg || []); // will convert to array
67
- let raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
68
- return parseLocale(codeArg, codes, raw);
69
- }
70
- function queryRawLocale(codes, available) {
71
- for (let i = 0; i < codes.length; i += 1) {
72
- let parts = codes[i].toLocaleLowerCase().split('-');
73
- for (let j = parts.length; j > 0; j -= 1) {
74
- let simpleId = parts.slice(0, j).join('-');
75
- if (available[simpleId]) {
76
- return available[simpleId];
77
- }
78
- }
79
- }
80
- return null;
81
- }
82
- function parseLocale(codeArg, codes, raw) {
83
- let merged = mergeCalendarOptions(MINIMAL_RAW_EN_LOCALE, raw);
84
- delete merged.code; // don't want this part of the options
85
- let { week } = merged;
86
- delete merged.week;
87
- return {
88
- codeArg,
89
- codes,
90
- week,
91
- simpleNumberFormat: new Intl.NumberFormat(codeArg),
92
- options: merged,
93
- };
94
- }
95
-
96
- // TODO: easier way to add new hooks? need to update a million things
97
- function createPlugin(input) {
98
- return {
99
- id: guid(),
100
- name: input.name,
101
- premiumReleaseDate: input.premiumReleaseDate ? new Date(input.premiumReleaseDate) : undefined,
102
- deps: input.deps || [],
103
- reducers: input.reducers || [],
104
- isLoadingFuncs: input.isLoadingFuncs || [],
105
- contextInit: [].concat(input.contextInit || []),
106
- eventRefiners: input.eventRefiners || {},
107
- eventDefMemberAdders: input.eventDefMemberAdders || [],
108
- eventSourceRefiners: input.eventSourceRefiners || {},
109
- isDraggableTransformers: input.isDraggableTransformers || [],
110
- eventDragMutationMassagers: input.eventDragMutationMassagers || [],
111
- eventDefMutationAppliers: input.eventDefMutationAppliers || [],
112
- dateSelectionTransformers: input.dateSelectionTransformers || [],
113
- datePointTransforms: input.datePointTransforms || [],
114
- dateSpanTransforms: input.dateSpanTransforms || [],
115
- views: input.views || {},
116
- viewPropsTransformers: input.viewPropsTransformers || [],
117
- isPropsValid: input.isPropsValid || null,
118
- externalDefTransforms: input.externalDefTransforms || [],
119
- viewContainerAppends: input.viewContainerAppends || [],
120
- eventDropTransformers: input.eventDropTransformers || [],
121
- componentInteractions: input.componentInteractions || [],
122
- calendarInteractions: input.calendarInteractions || [],
123
- eventSourceDefs: input.eventSourceDefs || [],
124
- cmdFormatter: input.cmdFormatter,
125
- recurringTypes: input.recurringTypes || [],
126
- namedTimeZonedImpl: input.namedTimeZonedImpl,
127
- initialView: input.initialView || '',
128
- elementDraggingImpl: input.elementDraggingImpl,
129
- optionChangeHandlers: input.optionChangeHandlers || {},
130
- scrollerSyncerClass: input.scrollerSyncerClass || null,
131
- listenerRefiners: input.listenerRefiners || {},
132
- optionRefiners: input.optionRefiners || {},
133
- optionDefaults: input.optionDefaults ? [input.optionDefaults] : [],
134
- propSetHandlers: input.propSetHandlers || {},
135
- };
136
- }
137
- function buildPluginHooks(pluginDefs, globalDefs) {
138
- let currentPluginIds = {};
139
- let hooks = {
140
- premiumReleaseDate: undefined,
141
- reducers: [],
142
- isLoadingFuncs: [],
143
- contextInit: [],
144
- eventRefiners: {},
145
- eventDefMemberAdders: [],
146
- eventSourceRefiners: {},
147
- isDraggableTransformers: [],
148
- eventDragMutationMassagers: [],
149
- eventDefMutationAppliers: [],
150
- dateSelectionTransformers: [],
151
- datePointTransforms: [],
152
- dateSpanTransforms: [],
153
- views: {},
154
- viewPropsTransformers: [],
155
- isPropsValid: null,
156
- externalDefTransforms: [],
157
- viewContainerAppends: [],
158
- eventDropTransformers: [],
159
- componentInteractions: [],
160
- calendarInteractions: [],
161
- eventSourceDefs: [],
162
- cmdFormatter: null,
163
- recurringTypes: [],
164
- namedTimeZonedImpl: null,
165
- initialView: '',
166
- elementDraggingImpl: null,
167
- optionChangeHandlers: {},
168
- scrollerSyncerClass: null,
169
- listenerRefiners: {},
170
- optionRefiners: {},
171
- optionDefaults: [],
172
- propSetHandlers: {},
173
- };
174
- function addDefs(defs) {
175
- for (let def of defs) {
176
- const pluginName = def.name;
177
- const currentId = currentPluginIds[pluginName];
178
- if (currentId === undefined) {
179
- currentPluginIds[pluginName] = def.id;
180
- addDefs(def.deps);
181
- hooks = combineHooks(hooks, def);
182
- }
183
- else if (currentId !== def.id) {
184
- // different ID than the one already added
185
- console.warn(`Duplicate plugin '${pluginName}'`);
186
- }
187
- }
188
- }
189
- if (pluginDefs) {
190
- addDefs(pluginDefs);
191
- }
192
- addDefs(globalDefs);
193
- return hooks;
194
- }
195
- function buildBuildPluginHooks() {
196
- let currentOverrideDefs = [];
197
- let currentGlobalDefs = [];
198
- let currentHooks;
199
- return (overrideDefs, globalDefs) => {
200
- if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
201
- currentHooks = buildPluginHooks(overrideDefs, globalDefs);
202
- }
203
- currentOverrideDefs = overrideDefs;
204
- currentGlobalDefs = globalDefs;
205
- return currentHooks;
206
- };
207
- }
208
- function combineHooks(hooks0, hooks1) {
209
- return {
210
- premiumReleaseDate: compareOptionalDates(hooks0.premiumReleaseDate, hooks1.premiumReleaseDate),
211
- reducers: hooks0.reducers.concat(hooks1.reducers),
212
- isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
213
- contextInit: hooks0.contextInit.concat(hooks1.contextInit),
214
- eventRefiners: Object.assign(Object.assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
215
- eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
216
- eventSourceRefiners: Object.assign(Object.assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
217
- isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
218
- eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
219
- eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
220
- dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
221
- datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
222
- dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
223
- views: mergeViewOptionsMap(hooks0.views, hooks1.views),
224
- viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
225
- isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
226
- externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
227
- viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
228
- eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
229
- calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
230
- componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
231
- eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
232
- cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
233
- recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
234
- namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
235
- initialView: hooks0.initialView || hooks1.initialView,
236
- elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
237
- optionChangeHandlers: Object.assign(Object.assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
238
- scrollerSyncerClass: hooks0.scrollerSyncerClass || hooks1.scrollerSyncerClass,
239
- listenerRefiners: Object.assign(Object.assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
240
- optionRefiners: Object.assign(Object.assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
241
- optionDefaults: hooks0.optionDefaults.concat(hooks1.optionDefaults),
242
- propSetHandlers: Object.assign(Object.assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers),
243
- };
244
- }
245
- function compareOptionalDates(date0, date1) {
246
- if (date0 === undefined) {
247
- return date1;
248
- }
249
- if (date1 === undefined) {
250
- return date0;
251
- }
252
- return new Date(Math.max(date0.valueOf(), date1.valueOf()));
253
- }
254
-
255
- function compileViewDefs(defaultConfigs, overrideConfigs) {
256
- let hash = {};
257
- let viewType;
258
- for (viewType in defaultConfigs) {
259
- ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
260
- }
261
- for (viewType in overrideConfigs) {
262
- ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
263
- }
264
- return hash;
265
- }
266
- function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
267
- if (hash[viewType]) {
268
- return hash[viewType];
269
- }
270
- let viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
271
- if (viewDef) {
272
- hash[viewType] = viewDef;
273
- }
274
- return viewDef;
275
- }
276
- function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
277
- let defaultConfig = defaultConfigs[viewType];
278
- let overrideConfig = overrideConfigs[viewType];
279
- let queryProp = (name) => ((defaultConfig && defaultConfig[name] !== null) ? defaultConfig[name] :
280
- ((overrideConfig && overrideConfig[name] !== null) ? overrideConfig[name] : null));
281
- let theComponent = queryProp('component');
282
- let superType = queryProp('superType');
283
- let superDef = null;
284
- if (superType) {
285
- if (superType === viewType) {
286
- throw new Error('Can\'t have a custom view type that references itself');
287
- }
288
- superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
289
- }
290
- if (!theComponent && superDef) {
291
- theComponent = superDef.component;
292
- }
293
- if (!theComponent) {
294
- return null; // don't throw a warning, might be settings for a single-unit view
295
- }
296
- return {
297
- type: viewType,
298
- component: theComponent,
299
- defaults: mergeCalendarOptions(superDef ? superDef.defaults : {}, defaultConfig ? defaultConfig.rawOptions : {}),
300
- overrides: mergeCalendarOptions(superDef ? superDef.overrides : {}, overrideConfig ? overrideConfig.rawOptions : {}),
301
- };
302
- }
303
-
304
- function parseViewConfigs(inputs) {
305
- return mapHash(inputs, parseViewConfig);
306
- }
307
- function parseViewConfig(input) {
308
- let rawOptions = typeof input === 'function' ?
309
- { component: input } :
310
- input;
311
- let { component } = rawOptions;
312
- if (rawOptions.content) {
313
- // TODO: remove content/classNames/didMount/etc from options?
314
- component = createViewHookComponent(rawOptions);
315
- }
316
- else if (component && !(component.prototype instanceof BaseComponent)) {
317
- // WHY?: people were using `component` property for `content`
318
- // TODO: converge on one setting name
319
- component = createViewHookComponent(Object.assign(Object.assign({}, rawOptions), { content: component }));
320
- }
321
- return {
322
- superType: rawOptions.type,
323
- component: component,
324
- rawOptions, // includes type and component too :(
325
- };
326
- }
327
- function createViewHookComponent(options) {
328
- return (viewProps) => (createElement(ViewContextType.Consumer, null, (context) => {
329
- var _a;
330
- return (createElement(ContentContainer, { tag: "div", className: generateClassName(options.viewClass, {
331
- view: context.viewApi,
332
- }), renderProps: Object.assign(Object.assign({}, viewProps), { nextDayThreshold: options.nextDayThreshold }), generatorName: undefined, customGenerator: options.content, classNameGenerator: ((_a = options.class) !== null && _a !== void 0 ? _a : options.className), didMount: options.didMount, willUnmount: options.willUnmount }));
333
- }));
334
- }
335
-
336
- function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides) {
337
- let defaultConfigs = parseViewConfigs(defaultInputs);
338
- let overrideConfigs = parseViewConfigs(optionOverrides.views);
339
- let viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
340
- return mapHash(viewDefs, (viewDef) => buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides));
341
- }
342
- function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides) {
343
- let durationInput = viewDef.overrides.duration ||
344
- viewDef.defaults.duration ||
345
- dynamicOptionOverrides.duration ||
346
- optionOverrides.duration;
347
- let duration = null;
348
- let durationUnit = '';
349
- let singleUnit = '';
350
- let singleUnitOverrides = {};
351
- if (durationInput) {
352
- duration = createDurationCached(durationInput);
353
- if (duration) { // valid?
354
- let denom = greatestDurationDenominator(duration);
355
- durationUnit = denom.unit;
356
- if (denom.value === 1) {
357
- singleUnit = durationUnit;
358
- singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
359
- }
360
- }
361
- }
362
- return {
363
- type: viewDef.type,
364
- component: viewDef.component,
365
- duration,
366
- durationUnit,
367
- singleUnit,
368
- optionDefaults: viewDef.defaults,
369
- optionOverrides: Object.assign(Object.assign({}, singleUnitOverrides), viewDef.overrides),
370
- };
371
- }
372
- // hack to get memoization working
373
- let durationInputMap = {};
374
- function createDurationCached(durationInput) {
375
- let json = JSON.stringify(durationInput);
376
- let res = durationInputMap[json];
377
- if (res === undefined) {
378
- res = createDuration(durationInput);
379
- durationInputMap[json] = res;
380
- }
381
- return res;
382
- }
383
-
384
- function reduceViewType(viewType, action) {
385
- switch (action.type) {
386
- case 'CHANGE_VIEW_TYPE':
387
- viewType = action.viewType;
388
- }
389
- return viewType;
390
- }
391
-
392
- function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
393
- switch (action.type) {
394
- case 'SET_OPTION':
395
- return Object.assign(Object.assign({}, dynamicOptionOverrides), { [action.optionName]: action.rawOptionValue });
396
- default:
397
- return dynamicOptionOverrides;
398
- }
399
- }
400
-
401
- function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
402
- let dp;
403
- switch (action.type) {
404
- case 'CHANGE_VIEW_TYPE':
405
- return dateProfileGenerator.build(action.dateMarker || currentDate);
406
- case 'CHANGE_DATE':
407
- return dateProfileGenerator.build(action.dateMarker);
408
- case 'PREV':
409
- dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
410
- if (dp.isValid) {
411
- return dp;
412
- }
413
- break;
414
- case 'NEXT':
415
- dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
416
- if (dp.isValid) {
417
- return dp;
418
- }
419
- break;
420
- }
421
- return currentDateProfile;
422
- }
423
-
424
- function initEventSources(calendarOptions, dateProfile, context) {
425
- let activeRange = dateProfile ? dateProfile.activeRange : null;
426
- return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
427
- }
428
- function reduceEventSources(eventSources, action, dateProfile, context) {
429
- let activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
430
- switch (action.type) {
431
- case 'ADD_EVENT_SOURCES': // already parsed
432
- return addSources(eventSources, action.sources, activeRange, context);
433
- case 'REMOVE_EVENT_SOURCE':
434
- return removeSource(eventSources, action.sourceId);
435
- case 'PREV': // TODO: how do we track all actions that affect dateProfile :(
436
- case 'NEXT':
437
- case 'CHANGE_DATE':
438
- case 'CHANGE_VIEW_TYPE':
439
- if (dateProfile) {
440
- return fetchDirtySources(eventSources, activeRange, context);
441
- }
442
- return eventSources;
443
- case 'FETCH_EVENT_SOURCES':
444
- return fetchSourcesByIds(eventSources, action.sourceIds ? // why no type?
445
- arrayToHash(action.sourceIds) :
446
- excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
447
- case 'RECEIVE_EVENTS':
448
- case 'RECEIVE_EVENT_ERROR':
449
- return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
450
- case 'REMOVE_ALL_EVENT_SOURCES':
451
- return {};
452
- default:
453
- return eventSources;
454
- }
455
- }
456
- function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
457
- let activeRange = dateProfile ? dateProfile.activeRange : null; // need this check?
458
- return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
459
- }
460
- function computeEventSourcesLoading(eventSources) {
461
- for (let sourceId in eventSources) {
462
- if (eventSources[sourceId].isFetching) {
463
- return true;
464
- }
465
- }
466
- return false;
467
- }
468
- function addSources(eventSourceHash, sources, fetchRange, context) {
469
- let hash = {};
470
- for (let source of sources) {
471
- hash[source.sourceId] = source;
472
- }
473
- if (fetchRange) {
474
- hash = fetchDirtySources(hash, fetchRange, context);
475
- }
476
- return Object.assign(Object.assign({}, eventSourceHash), hash);
477
- }
478
- function removeSource(eventSourceHash, sourceId) {
479
- return filterHash(eventSourceHash, (eventSource) => eventSource.sourceId !== sourceId);
480
- }
481
- function fetchDirtySources(sourceHash, fetchRange, context) {
482
- return fetchSourcesByIds(sourceHash, filterHash(sourceHash, (eventSource) => isSourceDirty(eventSource, fetchRange, context)), fetchRange, false, context);
483
- }
484
- function isSourceDirty(eventSource, fetchRange, context) {
485
- if (!doesSourceNeedRange(eventSource, context)) {
486
- return !eventSource.latestFetchId;
487
- }
488
- return !context.options.lazyFetching ||
489
- !eventSource.fetchRange ||
490
- eventSource.isFetching || // always cancel outdated in-progress fetches
491
- fetchRange.start < eventSource.fetchRange.start ||
492
- fetchRange.end > eventSource.fetchRange.end;
493
- }
494
- function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
495
- let nextSources = {};
496
- for (let sourceId in prevSources) {
497
- let source = prevSources[sourceId];
498
- if (sourceIdHash[sourceId]) {
499
- nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
500
- }
501
- else {
502
- nextSources[sourceId] = source;
503
- }
504
- }
505
- return nextSources;
506
- }
507
- function fetchSource(eventSource, fetchRange, isRefetch, context) {
508
- let { options, calendarApi } = context;
509
- let sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
510
- let fetchId = guid();
511
- sourceDef.fetch({
512
- eventSource,
513
- range: fetchRange,
514
- isRefetch,
515
- context,
516
- }, (res) => {
517
- let { rawEvents } = res;
518
- if (options.eventSourceSuccess) {
519
- rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.response) || rawEvents;
520
- }
521
- if (eventSource.success) {
522
- rawEvents = eventSource.success.call(calendarApi, rawEvents, res.response) || rawEvents;
523
- }
524
- context.dispatch({
525
- type: 'RECEIVE_EVENTS',
526
- sourceId: eventSource.sourceId,
527
- fetchId,
528
- fetchRange,
529
- rawEvents,
530
- });
531
- }, (error) => {
532
- let errorHandled = false;
533
- if (options.eventSourceFailure) {
534
- options.eventSourceFailure.call(calendarApi, error);
535
- errorHandled = true;
536
- }
537
- if (eventSource.failure) {
538
- eventSource.failure(error);
539
- errorHandled = true;
540
- }
541
- if (!errorHandled) {
542
- console.warn(error.message, error);
543
- }
544
- context.dispatch({
545
- type: 'RECEIVE_EVENT_ERROR',
546
- sourceId: eventSource.sourceId,
547
- fetchId,
548
- fetchRange,
549
- error,
550
- });
551
- });
552
- return Object.assign(Object.assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
553
- }
554
- function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
555
- let eventSource = sourceHash[sourceId];
556
- if (eventSource && // not already removed
557
- fetchId === eventSource.latestFetchId) {
558
- return Object.assign(Object.assign({}, sourceHash), { [sourceId]: Object.assign(Object.assign({}, eventSource), { isFetching: false, fetchRange }) });
559
- }
560
- return sourceHash;
561
- }
562
- function excludeStaticSources(eventSources, context) {
563
- return filterHash(eventSources, (eventSource) => doesSourceNeedRange(eventSource, context));
564
- }
565
- function parseInitialSources(rawOptions, context) {
566
- let refiners = buildEventSourceRefiners(context);
567
- let rawSources = [].concat(rawOptions.eventSources || []);
568
- let sources = []; // parsed
569
- if (rawOptions.initialEvents) {
570
- rawSources.unshift(rawOptions.initialEvents);
571
- }
572
- if (rawOptions.events) {
573
- rawSources.unshift(rawOptions.events);
574
- }
575
- for (let rawSource of rawSources) {
576
- let source = parseEventSource(rawSource, context, refiners);
577
- if (source) {
578
- sources.push(source);
579
- }
580
- }
581
- return sources;
582
- }
583
- function doesSourceNeedRange(eventSource, context) {
584
- let defs = context.pluginHooks.eventSourceDefs;
585
- return !defs[eventSource.sourceDefId].ignoreRange;
586
- }
587
-
588
- function reduceDateSelection(currentSelection, action) {
589
- switch (action.type) {
590
- case 'UNSELECT_DATES':
591
- return null;
592
- case 'SELECT_DATES':
593
- return action.selection;
594
- default:
595
- return currentSelection;
596
- }
597
- }
598
-
599
- function reduceSelectedEvent(currentInstanceId, action) {
600
- switch (action.type) {
601
- case 'UNSELECT_EVENT':
602
- return '';
603
- case 'SELECT_EVENT':
604
- return action.eventInstanceId;
605
- default:
606
- return currentInstanceId;
607
- }
608
- }
609
-
610
- function reduceEventDrag(currentDrag, action) {
611
- let newDrag;
612
- switch (action.type) {
613
- case 'UNSET_EVENT_DRAG':
614
- return null;
615
- case 'SET_EVENT_DRAG':
616
- newDrag = action.state;
617
- return {
618
- affectedEvents: newDrag.affectedEvents,
619
- mutatedEvents: newDrag.mutatedEvents,
620
- isEvent: newDrag.isEvent,
621
- };
622
- default:
623
- return currentDrag;
624
- }
625
- }
626
-
627
- function reduceEventResize(currentResize, action) {
628
- let newResize;
629
- switch (action.type) {
630
- case 'UNSET_EVENT_RESIZE':
631
- return null;
632
- case 'SET_EVENT_RESIZE':
633
- newResize = action.state;
634
- return {
635
- affectedEvents: newResize.affectedEvents,
636
- mutatedEvents: newResize.mutatedEvents,
637
- isEvent: newResize.isEvent,
638
- };
639
- default:
640
- return currentResize;
641
- }
642
- }
643
-
644
- function parseToolbars(calendarOptions, viewSpecs, calendarApi) {
645
- let header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, viewSpecs, calendarApi) : null;
646
- let footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, viewSpecs, calendarApi) : null;
647
- return { header, footer };
648
- }
649
- function parseToolbar(sectionStrHash, calendarOptions, viewSpecs, calendarApi) {
650
- let isRtl = calendarOptions.direction === 'rtl';
651
- let viewsWithButtons = [];
652
- let hasTitle = false;
653
- function processSectionStr(sectionStr) {
654
- let sectionRes = parseSection(sectionStr, calendarOptions, viewSpecs, calendarApi);
655
- viewsWithButtons.push(...sectionRes.viewsWithButtons);
656
- hasTitle = hasTitle || sectionRes.hasTitle;
657
- return sectionRes.widgets;
658
- }
659
- const sectionWidgets = {
660
- start: processSectionStr(sectionStrHash[isRtl ? 'right' : 'left'] || sectionStrHash.start || ''),
661
- center: processSectionStr(sectionStrHash.center || ''),
662
- end: processSectionStr(sectionStrHash[isRtl ? 'left' : 'right'] || sectionStrHash.end || ''),
663
- };
664
- return {
665
- sectionWidgets,
666
- viewsWithButtons,
667
- hasTitle,
668
- };
669
- }
670
- /*
671
- BAD: querying icons and text here. should be done at render time
672
- */
673
- function parseSection(sectionStr, calendarOptions, viewSpecs, calendarApi) {
674
- let calendarButtons = calendarOptions.buttons || {};
675
- let customElements = calendarOptions.toolbarElements || {};
676
- let sectionSubstrs = sectionStr ? sectionStr.split(' ') : [];
677
- let viewsWithButtons = [];
678
- let hasTitle = false;
679
- let widgets = sectionSubstrs.map((buttonGroupStr) => (buttonGroupStr.split(',').map((name) => {
680
- var _a;
681
- if (name === 'title') {
682
- hasTitle = true;
683
- return { name };
684
- }
685
- if (customElements[name]) {
686
- return { name, customElement: customElements[name] };
687
- }
688
- let viewSpec;
689
- let buttonInput = calendarButtons[name] || {};
690
- let buttonText;
691
- let buttonHint;
692
- let buttonClick;
693
- if ((viewSpec = viewSpecs[name])) {
694
- viewsWithButtons.push(name);
695
- const buttonTextKey = viewSpec.optionDefaults.buttonTextKey;
696
- buttonText = buttonInput.text ||
697
- (buttonTextKey ? calendarOptions[buttonTextKey] : '') ||
698
- (viewSpec.singleUnit ? calendarOptions[viewSpec.singleUnit + 'Text'] : '') ||
699
- name;
700
- /*
701
- buttons{}.hint(viewButtonText, viewName)
702
- viewHint(viewButtonText, viewName)
703
- */
704
- buttonHint = formatWithOrdinals(buttonInput.hint || calendarOptions.viewHint, [buttonText, name], // ordinal arguments
705
- buttonText);
706
- buttonClick = (ev) => {
707
- var _a;
708
- (_a = buttonInput === null || buttonInput === void 0 ? void 0 : buttonInput.click) === null || _a === void 0 ? void 0 : _a.call(buttonInput, ev);
709
- if (!ev.defaultPrevented) {
710
- calendarApi.changeView(name);
711
- }
712
- };
713
- }
714
- else {
715
- buttonText = buttonInput.text ||
716
- calendarOptions[name + 'Text'] ||
717
- name;
718
- /*
719
- button{}.hint(currentUnitText, currentUnit)
720
- prevHint(currentUnitUnitext, currentUnit)
721
- nextHint -- same
722
- todayHint -- same
723
- */
724
- if (name === 'prevYear') {
725
- buttonHint = formatWithOrdinals(buttonInput.hint || calendarOptions.prevHint, [calendarOptions.yearText, 'year'], buttonText);
726
- }
727
- else if (name === 'nextYear') {
728
- buttonHint = formatWithOrdinals(buttonInput.hint || calendarOptions.nextHint, [calendarOptions.yearText, 'year'], buttonText);
729
- }
730
- else {
731
- buttonHint = (currentUnit) => {
732
- return formatWithOrdinals(buttonInput.hint || calendarOptions[name + 'Hint'], // todayHint/prevHint/nextHint
733
- [calendarOptions[currentUnit + 'Text'], currentUnit], // ordinal arguments
734
- buttonText);
735
- };
736
- }
737
- buttonClick = (ev) => {
738
- var _a, _b;
739
- (_a = buttonInput === null || buttonInput === void 0 ? void 0 : buttonInput.click) === null || _a === void 0 ? void 0 : _a.call(buttonInput, ev);
740
- if (!ev.defaultPrevented) {
741
- (_b = calendarApi[name]) === null || _b === void 0 ? void 0 : _b.call(calendarApi);
742
- }
743
- };
744
- }
745
- return {
746
- name,
747
- isView: Boolean(viewSpec),
748
- buttonText,
749
- buttonHint,
750
- buttonDisplay: buttonInput.display,
751
- buttonIconClass: buttonInput.iconClass,
752
- buttonIconContent: buttonInput.iconContent,
753
- buttonClick,
754
- buttonIsPrimary: buttonInput.isPrimary || false,
755
- buttonClass: (_a = buttonInput.class) !== null && _a !== void 0 ? _a : buttonInput.className,
756
- buttonDidMount: buttonInput.didMount,
757
- buttonWillUnmount: buttonInput.willUnmount,
758
- };
759
- })));
760
- return { widgets, viewsWithButtons, hasTitle };
761
- }
762
-
763
- // always represents the current view. otherwise, it'd need to change value every time date changes
764
- class ViewImpl {
765
- constructor(type, getCurrentData, dateEnv) {
766
- this.type = type;
767
- this.getCurrentData = getCurrentData;
768
- this.dateEnv = dateEnv;
769
- }
770
- get calendar() {
771
- return this.getCurrentData().calendarApi;
772
- }
773
- get title() {
774
- return this.getCurrentData().viewTitle;
775
- }
776
- get activeStart() {
777
- return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
778
- }
779
- get activeEnd() {
780
- return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
781
- }
782
- get currentStart() {
783
- return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
784
- }
785
- get currentEnd() {
786
- return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
787
- }
788
- getOption(name) {
789
- return this.getCurrentData().options[name]; // are the view-specific options
790
- }
791
- }
792
-
793
- let eventSourceDef$2 = {
794
- ignoreRange: true,
795
- parseMeta(refined) {
796
- if (Array.isArray(refined.events)) {
797
- return refined.events;
798
- }
799
- return null;
800
- },
801
- fetch(arg, successCallback) {
802
- successCallback({
803
- rawEvents: arg.eventSource.meta,
804
- });
805
- },
806
- };
807
- const arrayEventSourcePlugin = createPlugin({
808
- name: 'array-event-source',
809
- eventSourceDefs: [eventSourceDef$2],
810
- });
811
-
812
- let eventSourceDef$1 = {
813
- parseMeta(refined) {
814
- if (typeof refined.events === 'function') {
815
- return refined.events;
816
- }
817
- return null;
818
- },
819
- fetch(arg, successCallback, errorCallback) {
820
- const { dateEnv } = arg.context;
821
- const func = arg.eventSource.meta;
822
- unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), (rawEvents) => successCallback({ rawEvents }), errorCallback);
823
- },
824
- };
825
- const funcEventSourcePlugin = createPlugin({
826
- name: 'func-event-source',
827
- eventSourceDefs: [eventSourceDef$1],
828
- });
829
-
830
- const JSON_FEED_EVENT_SOURCE_REFINERS = {
831
- method: String,
832
- extraParams: identity,
833
- startParam: String,
834
- endParam: String,
835
- timeZoneParam: String,
836
- };
837
-
838
- let eventSourceDef = {
839
- parseMeta(refined) {
840
- if (refined.url && (refined.format === 'json' || !refined.format)) {
841
- return {
842
- url: refined.url,
843
- format: 'json',
844
- method: (refined.method || 'GET').toUpperCase(),
845
- extraParams: refined.extraParams,
846
- startParam: refined.startParam,
847
- endParam: refined.endParam,
848
- timeZoneParam: refined.timeZoneParam,
849
- };
850
- }
851
- return null;
852
- },
853
- fetch(arg, successCallback, errorCallback) {
854
- const { meta } = arg.eventSource;
855
- const requestParams = buildRequestParams(meta, arg.range, arg.context);
856
- requestJson(meta.method, meta.url, requestParams).then(([rawEvents, response]) => {
857
- successCallback({ rawEvents, response });
858
- }, errorCallback);
859
- },
860
- };
861
- const jsonFeedEventSourcePlugin = createPlugin({
862
- name: 'json-event-source',
863
- eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
864
- eventSourceDefs: [eventSourceDef],
865
- });
866
- function buildRequestParams(meta, range, context) {
867
- let { dateEnv, options } = context;
868
- let startParam;
869
- let endParam;
870
- let timeZoneParam;
871
- let customRequestParams;
872
- let params = {};
873
- startParam = meta.startParam;
874
- if (startParam == null) {
875
- startParam = options.startParam;
876
- }
877
- endParam = meta.endParam;
878
- if (endParam == null) {
879
- endParam = options.endParam;
880
- }
881
- timeZoneParam = meta.timeZoneParam;
882
- if (timeZoneParam == null) {
883
- timeZoneParam = options.timeZoneParam;
884
- }
885
- // retrieve any outbound GET/POST data from the options
886
- if (typeof meta.extraParams === 'function') {
887
- // supplied as a function that returns a key/value object
888
- customRequestParams = meta.extraParams();
889
- }
890
- else {
891
- // probably supplied as a straight key/value object
892
- customRequestParams = meta.extraParams || {};
893
- }
894
- Object.assign(params, customRequestParams);
895
- params[startParam] = dateEnv.formatIso(range.start);
896
- params[endParam] = dateEnv.formatIso(range.end);
897
- if (dateEnv.timeZone !== 'local') {
898
- params[timeZoneParam] = dateEnv.timeZone;
899
- }
900
- return params;
901
- }
902
-
903
- const SIMPLE_RECURRING_REFINERS = {
904
- daysOfWeek: identity,
905
- startTime: createDuration,
906
- endTime: createDuration,
907
- duration: createDuration,
908
- startRecur: identity,
909
- endRecur: identity,
910
- };
911
-
912
- let recurring = {
913
- parse(refined, dateEnv) {
914
- if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
915
- let recurringData = {
916
- daysOfWeek: refined.daysOfWeek || null,
917
- startTime: refined.startTime || null,
918
- endTime: refined.endTime || null,
919
- startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
920
- endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null,
921
- };
922
- let duration;
923
- if (refined.duration) {
924
- duration = refined.duration;
925
- }
926
- if (!duration && refined.startTime && refined.endTime) {
927
- duration = subtractDurations(refined.endTime, refined.startTime);
928
- }
929
- return {
930
- allDayGuess: Boolean(!refined.startTime && !refined.endTime),
931
- duration,
932
- typeData: recurringData, // doesn't need endTime anymore but oh well
933
- };
934
- }
935
- return null;
936
- },
937
- expand(typeData, framingRange, dateEnv) {
938
- let clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
939
- if (clippedFramingRange) {
940
- return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
941
- }
942
- return [];
943
- },
944
- };
945
- const simpleRecurringEventsPlugin = createPlugin({
946
- name: 'simple-recurring-event',
947
- recurringTypes: [recurring],
948
- eventRefiners: SIMPLE_RECURRING_REFINERS,
949
- });
950
- function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
951
- let dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
952
- let dayMarker = startOfDay(framingRange.start);
953
- let endMarker = framingRange.end;
954
- let instanceStarts = [];
955
- while (dayMarker < endMarker) {
956
- let instanceStart;
957
- // if everyday, or this particular day-of-week
958
- if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
959
- if (startTime) {
960
- instanceStart = dateEnv.add(dayMarker, startTime);
961
- }
962
- else {
963
- instanceStart = dayMarker;
964
- }
965
- instanceStarts.push(instanceStart);
966
- }
967
- dayMarker = addDays(dayMarker, 1);
968
- }
969
- return instanceStarts;
970
- }
971
-
972
- const changeHandlerPlugin = createPlugin({
973
- name: 'change-handler',
974
- optionChangeHandlers: {
975
- controller(controller, context) {
976
- // TODO: the initial setting is in CalendarDataManager
977
- controller._setApi(context.calendarApi);
978
- },
979
- events(events, context) {
980
- handleEventSources([events], context);
981
- },
982
- eventSources: handleEventSources,
983
- },
984
- });
985
- /*
986
- BUG: if `event` was supplied, all previously-given `eventSources` will be wiped out
987
- */
988
- function handleEventSources(inputs, context) {
989
- let unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
990
- if (unfoundSources.length === 1 &&
991
- inputs.length === 1 &&
992
- Array.isArray(unfoundSources[0]._raw) &&
993
- Array.isArray(inputs[0])) {
994
- context.dispatch({
995
- type: 'RESET_RAW_EVENTS',
996
- sourceId: unfoundSources[0].sourceId,
997
- rawEvents: inputs[0],
998
- });
999
- return;
1000
- }
1001
- let newInputs = [];
1002
- for (let input of inputs) {
1003
- let inputFound = false;
1004
- for (let i = 0; i < unfoundSources.length; i += 1) {
1005
- if (unfoundSources[i]._raw === input) {
1006
- unfoundSources.splice(i, 1); // delete
1007
- inputFound = true;
1008
- break;
1009
- }
1010
- }
1011
- if (!inputFound) {
1012
- newInputs.push(input);
1013
- }
1014
- }
1015
- for (let unfoundSource of unfoundSources) {
1016
- context.dispatch({
1017
- type: 'REMOVE_EVENT_SOURCE',
1018
- sourceId: unfoundSource.sourceId,
1019
- });
1020
- }
1021
- for (let newInput of newInputs) {
1022
- context.calendarApi.addEventSource(newInput);
1023
- }
1024
- }
1025
-
1026
- function handleDateProfile(dateProfile, context) {
1027
- context.emitter.trigger('datesSet', Object.assign(Object.assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
1028
- }
1029
-
1030
- function handleEventStore(eventStore, context) {
1031
- let { emitter } = context;
1032
- if (emitter.hasHandlers('eventsSet')) {
1033
- emitter.trigger('eventsSet', buildEventApis(eventStore, context));
1034
- }
1035
- }
1036
-
1037
- /*
1038
- this array is exposed on the root namespace so that UMD plugins can add to it.
1039
- see the rollup-bundles script.
1040
- */
1041
- const globalPlugins = [
1042
- arrayEventSourcePlugin,
1043
- funcEventSourcePlugin,
1044
- jsonFeedEventSourcePlugin,
1045
- simpleRecurringEventsPlugin,
1046
- changeHandlerPlugin,
1047
- createPlugin({
1048
- name: 'misc',
1049
- isLoadingFuncs: [
1050
- (state) => computeEventSourcesLoading(state.eventSources),
1051
- ],
1052
- propSetHandlers: {
1053
- dateProfile: handleDateProfile,
1054
- eventStore: handleEventStore,
1055
- },
1056
- }),
1057
- ];
1058
-
1059
- class TaskRunner {
1060
- constructor(runTaskOption, drainedOption) {
1061
- this.runTaskOption = runTaskOption;
1062
- this.drainedOption = drainedOption;
1063
- this.queue = [];
1064
- this.delayedRunner = new DelayedRunner(this.drain.bind(this));
1065
- }
1066
- request(task, delay) {
1067
- this.queue.push(task);
1068
- this.delayedRunner.request(delay);
1069
- }
1070
- pause(scope) {
1071
- this.delayedRunner.pause(scope);
1072
- }
1073
- resume(scope, force) {
1074
- this.delayedRunner.resume(scope, force);
1075
- }
1076
- drain() {
1077
- let { queue } = this;
1078
- while (queue.length) {
1079
- let completedTasks = [];
1080
- let task;
1081
- while ((task = queue.shift())) {
1082
- this.runTask(task);
1083
- completedTasks.push(task);
1084
- }
1085
- this.drained(completedTasks);
1086
- } // keep going, in case new tasks were added in the drained handler
1087
- }
1088
- runTask(task) {
1089
- if (this.runTaskOption) {
1090
- this.runTaskOption(task);
1091
- }
1092
- }
1093
- drained(completedTasks) {
1094
- if (this.drainedOption) {
1095
- this.drainedOption(completedTasks);
1096
- }
1097
- }
1098
- }
1099
-
1100
- // Computes what the title at the top of the calendarApi should be for this view
1101
- function buildTitle(dateProfile, viewOptions, dateEnv) {
1102
- let range;
1103
- // for views that span a large unit of time, show the proper interval, ignoring stray days before and after
1104
- if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
1105
- range = dateProfile.currentRange;
1106
- }
1107
- else { // for day units or smaller, use the actual day range
1108
- range = dateProfile.activeRange;
1109
- }
1110
- return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile, dateEnv)), {
1111
- isEndExclusive: dateProfile.isRangeAllDay,
1112
- defaultSeparator: viewOptions.titleRangeSeparator,
1113
- });
1114
- }
1115
- // Generates the format string that should be used to generate the title for the current date range.
1116
- // Attempts to compute the most appropriate format if not explicitly specified with `titleFormat`.
1117
- function buildTitleFormat(dateProfile, dateEnv) {
1118
- let { currentRangeUnit } = dateProfile;
1119
- if (currentRangeUnit === 'year') {
1120
- return { year: 'numeric' };
1121
- }
1122
- if (currentRangeUnit === 'month') {
1123
- return { year: 'numeric', month: 'long' }; // like "September 2014"
1124
- }
1125
- let days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
1126
- if (days !== null && days > 1) {
1127
- return {
1128
- year: 'numeric',
1129
- month: dateEnv.getMonth(dateProfile.activeRange.start) !== dateEnv.getMonth(dateProfile.activeRange.end)
1130
- ? 'short' // different months? do "Sep - Oct 2014"
1131
- : 'long', // same month? do "September 2014"
1132
- };
1133
- }
1134
- // one day. longer, like "September 9 2014"
1135
- return { year: 'numeric', month: 'long', day: 'numeric' };
1136
- }
1137
-
1138
- // in future refactor, do the redux-style function(state=initial) for initial-state
1139
- // also, whatever is happening in constructor, have it happen in action queue too
1140
- class CalendarDataManager {
1141
- constructor(props) {
1142
- this.computeCurrentViewData = memoize(this._computeCurrentViewData);
1143
- this.organizeRawLocales = memoize(organizeRawLocales);
1144
- this.buildLocale = memoize(buildLocale);
1145
- this.buildPluginHooks = buildBuildPluginHooks();
1146
- this.buildDateEnv = memoize(buildDateEnv$1);
1147
- this.parseToolbars = memoize(parseToolbars);
1148
- this.buildViewSpecs = memoize(buildViewSpecs);
1149
- this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
1150
- this.buildViewApi = memoize(buildViewApi);
1151
- this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
1152
- this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqualShallow);
1153
- this.buildEventUiBases = memoize(buildEventUiBases);
1154
- this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
1155
- this.buildTitle = memoize(buildTitle);
1156
- this.emitter = new Emitter();
1157
- this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
1158
- this.currentCalendarOptionsInput = {};
1159
- this.currentCalendarOptionsRefined = {};
1160
- this.currentViewOptionsInput = {};
1161
- this.currentViewOptionsRefined = {};
1162
- this.currentCalendarOptionsRefiners = {};
1163
- this.optionsForRefining = [];
1164
- this.optionsForHandling = [];
1165
- this.getCurrentData = () => this.data;
1166
- this.dispatch = (action) => {
1167
- this.actionRunner.request(action); // protects against recursive calls to _handleAction
1168
- };
1169
- this.props = props;
1170
- this.actionRunner.pause();
1171
- let dynamicOptionOverrides = {};
1172
- let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
1173
- let currentViewType = optionsData.calendarOptions.initialView ||
1174
- optionsData.pluginHooks.initialView;
1175
- let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
1176
- // wire things up
1177
- // TODO: not DRY
1178
- props.calendarApi.currentDataManager = this;
1179
- this.emitter.setThisContext(props.calendarApi);
1180
- this.emitter.setOptions(currentViewData.options);
1181
- // NOTE: subsequent updates detected by options-change-handlers.ts
1182
- const controllerOption = optionsData.calendarOptions.controller;
1183
- if (controllerOption) {
1184
- controllerOption._setApi(props.calendarApi);
1185
- }
1186
- let currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
1187
- let dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
1188
- if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
1189
- currentDate = dateProfile.currentRange.start;
1190
- }
1191
- let calendarContext = {
1192
- dateEnv: optionsData.dateEnv,
1193
- options: optionsData.calendarOptions,
1194
- pluginHooks: optionsData.pluginHooks,
1195
- calendarApi: props.calendarApi,
1196
- dispatch: this.dispatch,
1197
- emitter: this.emitter,
1198
- getCurrentData: this.getCurrentData,
1199
- };
1200
- // needs to be after setThisContext
1201
- for (let callback of optionsData.pluginHooks.contextInit) {
1202
- callback(calendarContext);
1203
- }
1204
- // NOT DRY
1205
- let eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
1206
- let initialState = {
1207
- dynamicOptionOverrides,
1208
- currentViewType,
1209
- currentDate,
1210
- dateProfile,
1211
- businessHours: this.parseContextBusinessHours(calendarContext),
1212
- eventSources,
1213
- eventUiBases: {},
1214
- eventStore: createEmptyEventStore(),
1215
- renderableEventStore: createEmptyEventStore(),
1216
- dateSelection: null,
1217
- eventSelection: '',
1218
- eventDrag: null,
1219
- eventResize: null,
1220
- selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig,
1221
- };
1222
- let contextAndState = Object.assign(Object.assign({}, calendarContext), initialState);
1223
- for (let reducer of optionsData.pluginHooks.reducers) {
1224
- Object.assign(initialState, reducer(null, null, contextAndState));
1225
- }
1226
- if (computeIsLoading(initialState, calendarContext)) {
1227
- this.emitter.trigger('loading', true); // NOT DRY
1228
- }
1229
- this.state = initialState;
1230
- this.updateData();
1231
- this.actionRunner.resume();
1232
- }
1233
- resetOptions(optionOverrides, changedOptionNames) {
1234
- let { props } = this;
1235
- if (changedOptionNames === undefined) {
1236
- props.optionOverrides = optionOverrides;
1237
- }
1238
- else {
1239
- props.optionOverrides = Object.assign(Object.assign({}, (props.optionOverrides || {})), optionOverrides);
1240
- this.optionsForRefining.push(...changedOptionNames);
1241
- }
1242
- if (changedOptionNames === undefined || changedOptionNames.length) {
1243
- this.actionRunner.request({
1244
- type: 'NOTHING',
1245
- });
1246
- }
1247
- }
1248
- _handleAction(action) {
1249
- let { props, state, emitter } = this;
1250
- let dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
1251
- let optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
1252
- let currentViewType = reduceViewType(state.currentViewType, action);
1253
- let currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
1254
- // wire things up
1255
- // TODO: not DRY
1256
- props.calendarApi.currentDataManager = this;
1257
- emitter.setThisContext(props.calendarApi);
1258
- emitter.setOptions(currentViewData.options);
1259
- let calendarContext = {
1260
- dateEnv: optionsData.dateEnv,
1261
- options: optionsData.calendarOptions,
1262
- pluginHooks: optionsData.pluginHooks,
1263
- calendarApi: props.calendarApi,
1264
- dispatch: this.dispatch,
1265
- emitter,
1266
- getCurrentData: this.getCurrentData,
1267
- };
1268
- let { currentDate, dateProfile } = state;
1269
- if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) { // hack
1270
- dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
1271
- }
1272
- currentDate = reduceCurrentDate(currentDate, action);
1273
- dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
1274
- if (action.type === 'PREV' || // TODO: move this logic into DateProfileGenerator
1275
- action.type === 'NEXT' || // "
1276
- !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
1277
- currentDate = dateProfile.currentRange.start;
1278
- }
1279
- let eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
1280
- let eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
1281
- let isEventsLoading = computeEventSourcesLoading(eventSources); // BAD. also called in this func in computeIsLoading
1282
- let renderableEventStore = (isEventsLoading && !currentViewData.options.progressiveEventRendering) ?
1283
- (state.renderableEventStore || eventStore) : // try from previous state
1284
- eventStore;
1285
- let { eventUiSingleBase, selectionConfig } = this.buildViewUiProps(calendarContext); // will memoize obj
1286
- let eventUiBySource = this.buildEventUiBySource(eventSources);
1287
- let eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
1288
- let newState = {
1289
- dynamicOptionOverrides,
1290
- currentViewType,
1291
- currentDate,
1292
- dateProfile,
1293
- eventSources,
1294
- eventStore,
1295
- renderableEventStore,
1296
- selectionConfig,
1297
- eventUiBases,
1298
- businessHours: this.parseContextBusinessHours(calendarContext),
1299
- dateSelection: reduceDateSelection(state.dateSelection, action),
1300
- eventSelection: reduceSelectedEvent(state.eventSelection, action),
1301
- eventDrag: reduceEventDrag(state.eventDrag, action),
1302
- eventResize: reduceEventResize(state.eventResize, action),
1303
- };
1304
- let contextAndState = Object.assign(Object.assign({}, calendarContext), newState);
1305
- for (let reducer of optionsData.pluginHooks.reducers) {
1306
- Object.assign(newState, reducer(state, action, contextAndState)); // give the OLD state, for old value
1307
- }
1308
- let wasLoading = computeIsLoading(state, calendarContext);
1309
- let isLoading = computeIsLoading(newState, calendarContext);
1310
- // TODO: use propSetHandlers in plugin system
1311
- if (!wasLoading && isLoading) {
1312
- emitter.trigger('loading', true);
1313
- }
1314
- else if (wasLoading && !isLoading) {
1315
- emitter.trigger('loading', false);
1316
- }
1317
- this.state = newState;
1318
- if (props.onAction) {
1319
- props.onAction(action);
1320
- }
1321
- }
1322
- updateData() {
1323
- let { props, state } = this;
1324
- let oldData = this.data;
1325
- let optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
1326
- let currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
1327
- let viewTitle = this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv);
1328
- let data = this.data = Object.assign(Object.assign(Object.assign({ viewTitle, calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
1329
- let changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
1330
- let oldCalendarOptions = oldData && oldData.calendarOptions;
1331
- let newCalendarOptions = optionsData.calendarOptions;
1332
- if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
1333
- if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
1334
- // hack
1335
- state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
1336
- state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
1337
- state.renderableEventStore = data.renderableEventStore = rezoneEventStoreDates(data.renderableEventStore, oldData.dateEnv, data.dateEnv);
1338
- }
1339
- for (let optionName in changeHandlers) {
1340
- if (this.optionsForHandling.indexOf(optionName) !== -1 ||
1341
- oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
1342
- changeHandlers[optionName](newCalendarOptions[optionName], data);
1343
- }
1344
- }
1345
- }
1346
- this.optionsForHandling = [];
1347
- if (props.onData) {
1348
- props.onData(data);
1349
- }
1350
- }
1351
- computeOptionsData(optionOverrides, dynamicOptionOverrides, calendarApi) {
1352
- // TODO: blacklist options that are handled by optionChangeHandlers
1353
- if (!this.optionsForRefining.length &&
1354
- optionOverrides === this.stableOptionOverrides &&
1355
- dynamicOptionOverrides === this.stableDynamicOptionOverrides) {
1356
- return this.stableCalendarOptionsData;
1357
- }
1358
- let { refinedOptions, pluginHooks, localeDefaults, availableLocaleData, } = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides);
1359
- let dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, refinedOptions.weekTextShort, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
1360
- let viewSpecs = this.buildViewSpecs(pluginHooks.views, this.stableOptionOverrides, this.stableDynamicOptionOverrides);
1361
- let toolbarConfig = this.parseToolbars(refinedOptions, viewSpecs, calendarApi);
1362
- return this.stableCalendarOptionsData = {
1363
- calendarOptions: refinedOptions,
1364
- pluginHooks,
1365
- dateEnv,
1366
- viewSpecs,
1367
- toolbarConfig,
1368
- localeDefaults,
1369
- availableRawLocales: availableLocaleData.map,
1370
- };
1371
- }
1372
- // always called from behind a memoizer
1373
- processRawCalendarOptions(optionOverrides, dynamicOptionOverrides) {
1374
- let { locales, locale } = mergeCalendarOptions(BASE_OPTION_DEFAULTS, optionOverrides, dynamicOptionOverrides);
1375
- let availableLocaleData = this.organizeRawLocales(locales);
1376
- let availableRawLocales = availableLocaleData.map;
1377
- let localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
1378
- let pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
1379
- let refiners = this.currentCalendarOptionsRefiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_ONLY_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
1380
- let raw = mergeCalendarOptions(BASE_OPTION_DEFAULTS, ...pluginHooks.optionDefaults, localeDefaults, filterKnownOptions(mergeCalendarOptions(optionOverrides, dynamicOptionOverrides), refiners));
1381
- let refined = {};
1382
- let currentRaw = this.currentCalendarOptionsInput;
1383
- let currentRefined = this.currentCalendarOptionsRefined;
1384
- let anyChanges = false;
1385
- for (let optionName in raw) {
1386
- if (this.optionsForRefining.indexOf(optionName) === -1 && (raw[optionName] === currentRaw[optionName] || (COMPLEX_OPTION_COMPARATORS[optionName] &&
1387
- (optionName in currentRaw) &&
1388
- COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName])) || (
1389
- // see options-manip
1390
- currentRaw[optionName] && currentRaw[optionName].parts &&
1391
- raw[optionName] && raw[optionName].parts &&
1392
- isArraysEqual(currentRaw[optionName].parts, raw[optionName].parts)))) {
1393
- refined[optionName] = currentRefined[optionName];
1394
- }
1395
- else if (refiners[optionName]) {
1396
- refined[optionName] = refiners[optionName](raw[optionName]);
1397
- anyChanges = true;
1398
- }
1399
- }
1400
- if (anyChanges) {
1401
- this.currentCalendarOptionsInput = raw;
1402
- this.currentCalendarOptionsRefined = refined;
1403
- this.stableOptionOverrides = optionOverrides;
1404
- this.stableDynamicOptionOverrides = dynamicOptionOverrides;
1405
- }
1406
- this.optionsForHandling.push(...this.optionsForRefining);
1407
- this.optionsForRefining = [];
1408
- return {
1409
- rawOptions: this.currentCalendarOptionsInput,
1410
- refinedOptions: this.currentCalendarOptionsRefined,
1411
- pluginHooks,
1412
- availableLocaleData,
1413
- localeDefaults,
1414
- };
1415
- }
1416
- _computeCurrentViewData(viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
1417
- let viewSpec = optionsData.viewSpecs[viewType];
1418
- if (!viewSpec) {
1419
- throw new Error(`viewType "${viewType}" is not available. Please make sure you've loaded all neccessary plugins`);
1420
- }
1421
- let { refinedOptions } = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides);
1422
- let dateProfileGenerator = this.buildDateProfileGenerator({
1423
- dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
1424
- duration: viewSpec.duration,
1425
- durationUnit: viewSpec.durationUnit,
1426
- usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
1427
- dateEnv: optionsData.dateEnv,
1428
- calendarApi: this.props.calendarApi,
1429
- slotMinTime: refinedOptions.slotMinTime,
1430
- slotMaxTime: refinedOptions.slotMaxTime,
1431
- showNonCurrentDates: refinedOptions.showNonCurrentDates,
1432
- dayCount: refinedOptions.dayCount,
1433
- dateAlignment: refinedOptions.dateAlignment,
1434
- dateIncrement: refinedOptions.dateIncrement,
1435
- hiddenDays: refinedOptions.hiddenDays,
1436
- weekends: refinedOptions.weekends,
1437
- nowInput: refinedOptions.now,
1438
- validRangeInput: refinedOptions.validRange,
1439
- visibleRangeInput: refinedOptions.visibleRange,
1440
- fixedWeekCount: refinedOptions.fixedWeekCount,
1441
- });
1442
- let viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
1443
- return { viewSpec, options: refinedOptions, dateProfileGenerator, viewApi };
1444
- }
1445
- processRawViewOptions(viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
1446
- let refiners = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_ONLY_OPTION_REFINERS), VIEW_ONLY_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
1447
- let raw = mergeCalendarOptions(BASE_OPTION_DEFAULTS, ...pluginHooks.optionDefaults, viewSpec.optionDefaults, localeDefaults, filterKnownOptions(mergeCalendarOptions(optionOverrides, viewSpec.optionOverrides, dynamicOptionOverrides), refiners));
1448
- let refined = {};
1449
- let currentRaw = this.currentViewOptionsInput;
1450
- let currentRefined = this.currentViewOptionsRefined;
1451
- let anyChanges = false;
1452
- for (let optionName in raw) {
1453
- if (raw[optionName] === currentRaw[optionName] || (COMPLEX_OPTION_COMPARATORS[optionName] &&
1454
- COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], currentRaw[optionName])) || (
1455
- // see options-manip
1456
- currentRaw[optionName] && currentRaw[optionName].parts &&
1457
- raw[optionName] && raw[optionName].parts &&
1458
- isArraysEqual(currentRaw[optionName].parts, raw[optionName].parts))) {
1459
- refined[optionName] = currentRefined[optionName];
1460
- }
1461
- else {
1462
- if (raw[optionName] === this.currentCalendarOptionsInput[optionName] ||
1463
- (COMPLEX_OPTION_COMPARATORS[optionName] &&
1464
- COMPLEX_OPTION_COMPARATORS[optionName](raw[optionName], this.currentCalendarOptionsInput[optionName]))) {
1465
- if (optionName in this.currentCalendarOptionsRefined) { // might be an "extra" prop
1466
- refined[optionName] = this.currentCalendarOptionsRefined[optionName];
1467
- }
1468
- }
1469
- else if (refiners[optionName]) {
1470
- refined[optionName] = refiners[optionName](raw[optionName]);
1471
- }
1472
- anyChanges = true;
1473
- }
1474
- }
1475
- if (anyChanges) {
1476
- this.currentViewOptionsInput = raw;
1477
- this.currentViewOptionsRefined = refined;
1478
- }
1479
- return {
1480
- rawOptions: this.currentViewOptionsInput,
1481
- refinedOptions: this.currentViewOptionsRefined,
1482
- };
1483
- }
1484
- }
1485
- function buildDateEnv$1(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, weekTextShort, pluginHooks, availableLocaleData, defaultSeparator) {
1486
- let locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
1487
- return new DateEnv({
1488
- calendarSystem: 'gregory',
1489
- timeZone,
1490
- namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
1491
- locale,
1492
- weekNumberCalculation,
1493
- firstDay,
1494
- weekText,
1495
- weekTextShort,
1496
- cmdFormatter: pluginHooks.cmdFormatter,
1497
- defaultSeparator,
1498
- });
1499
- }
1500
- function buildDateProfileGenerator(props) {
1501
- let DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
1502
- return new DateProfileGeneratorClass(props);
1503
- }
1504
- function buildViewApi(type, getCurrentData, dateEnv) {
1505
- return new ViewImpl(type, getCurrentData, dateEnv);
1506
- }
1507
- function buildEventUiBySource(eventSources) {
1508
- return mapHash(eventSources, (eventSource) => eventSource.ui);
1509
- }
1510
- /*
1511
- The result of this is processed by compileEventUi
1512
- */
1513
- function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
1514
- let eventUiBases = {
1515
- '': eventUiSingleBase, // fallback
1516
- };
1517
- for (let defId in eventDefs) {
1518
- let def = eventDefs[defId];
1519
- if (def.sourceId && eventUiBySource[def.sourceId]) {
1520
- eventUiBases[defId] = eventUiBySource[def.sourceId];
1521
- }
1522
- }
1523
- return eventUiBases;
1524
- }
1525
- function buildViewUiProps(calendarContext) {
1526
- const { options } = calendarContext;
1527
- return {
1528
- eventUiSingleBase: createEventUi({
1529
- display: options.eventDisplay,
1530
- editable: options.editable,
1531
- startEditable: options.eventStartEditable,
1532
- durationEditable: options.eventDurationEditable,
1533
- constraint: options.eventConstraint,
1534
- overlap: typeof options.eventOverlap === 'boolean' ? options.eventOverlap : undefined,
1535
- allow: options.eventAllow,
1536
- // color: options.eventColor, // StandardEvent/BgEvent will handle this
1537
- // contrastColor: options.eventContrastColor, // StandardEvent/BgEvent will handle this
1538
- // className: options.eventClass // render hook will handle this
1539
- }, calendarContext),
1540
- selectionConfig: createEventUi({
1541
- constraint: options.selectConstraint,
1542
- overlap: typeof options.selectOverlap === 'boolean' ? options.selectOverlap : undefined,
1543
- allow: options.selectAllow,
1544
- }, calendarContext),
1545
- };
1546
- }
1547
- function computeIsLoading(state, context) {
1548
- for (let isLoadingFunc of context.pluginHooks.isLoadingFuncs) {
1549
- if (isLoadingFunc(state)) {
1550
- return true;
1551
- }
1552
- }
1553
- return false;
1554
- }
1555
- function parseContextBusinessHours(calendarContext) {
1556
- return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
1557
- }
1558
- function filterKnownOptions(options, optionRefiners) {
1559
- const knownOptions = {};
1560
- for (const optionName in options) {
1561
- if (optionRefiners[optionName]) {
1562
- knownOptions[optionName] = options[optionName];
1563
- }
1564
- }
1565
- return knownOptions;
1566
- }
1567
-
1568
- /*
1569
- Detects when the user clicks on an event within a DateComponent
1570
- */
1571
- class EventClicking extends Interaction {
1572
- constructor(settings) {
1573
- super(settings);
1574
- this.handleSegClick = (ev, segEl) => {
1575
- let { component } = this;
1576
- let { context } = component;
1577
- let eventRange = getElEventRange(segEl);
1578
- if (eventRange && // might be the <div> surrounding the more link
1579
- component.isValidSegDownEl(ev.target)) {
1580
- context.emitter.trigger('eventClick', {
1581
- el: segEl,
1582
- event: new EventImpl(component.context, eventRange.def, eventRange.instance),
1583
- jsEvent: ev,
1584
- view: context.viewApi,
1585
- });
1586
- }
1587
- };
1588
- this.destroy = listenBySelector(settings.el, 'click', `.${classNames.internalEvent}`, // on both fg and bg events
1589
- this.handleSegClick);
1590
- }
1591
- }
1592
-
1593
- /*
1594
- Triggers events and adds/removes core classNames when the user's pointer
1595
- enters/leaves event-elements of a component.
1596
- */
1597
- class EventHovering extends Interaction {
1598
- constructor(settings) {
1599
- super(settings);
1600
- // for simulating an eventMouseLeave when the event el is destroyed while mouse is over it
1601
- this.handleEventElRemove = (el) => {
1602
- if (el === this.currentSegEl) {
1603
- this.handleSegLeave(null, this.currentSegEl);
1604
- }
1605
- };
1606
- this.handleSegEnter = (ev, segEl) => {
1607
- if (getElEventRange(segEl)) { // TODO: better way to make sure not hovering over more+ link or its wrapper
1608
- this.currentSegEl = segEl;
1609
- this.triggerEvent('eventMouseEnter', ev, segEl);
1610
- }
1611
- };
1612
- this.handleSegLeave = (ev, segEl) => {
1613
- if (this.currentSegEl) {
1614
- this.currentSegEl = null;
1615
- this.triggerEvent('eventMouseLeave', ev, segEl);
1616
- }
1617
- };
1618
- this.removeHoverListeners = listenToHoverBySelector(settings.el, `.${classNames.internalEvent}`, // on both fg and bg events
1619
- this.handleSegEnter, this.handleSegLeave);
1620
- }
1621
- destroy() {
1622
- this.removeHoverListeners();
1623
- }
1624
- triggerEvent(publicEvName, ev, segEl) {
1625
- let { component } = this;
1626
- let { context } = component;
1627
- let eventRange = getElEventRange(segEl);
1628
- if (!ev || component.isValidSegDownEl(ev.target)) {
1629
- context.emitter.trigger(publicEvName, {
1630
- el: segEl,
1631
- event: new EventImpl(context, eventRange.def, eventRange.instance),
1632
- jsEvent: ev,
1633
- view: context.viewApi,
1634
- });
1635
- }
1636
- }
1637
- }
1638
-
1639
- class ButtonIcon extends BaseComponent {
1640
- render() {
1641
- const { contentGenerator, className } = this.props;
1642
- if (contentGenerator) {
1643
- // TODO: somehow give className to the svg?
1644
- return (createElement(ContentContainer, { tag: 'span', style: { display: 'contents' }, attrs: { 'aria-hidden': true }, renderProps: {}, generatorName: undefined, customGenerator: contentGenerator }));
1645
- }
1646
- if (className !== undefined) {
1647
- return (createElement("span", { "aria-hidden": true, className: className }));
1648
- }
1649
- }
1650
- }
1651
-
1652
- class ToolbarSection extends BaseComponent {
1653
- render() {
1654
- let { props } = this;
1655
- let { options } = this.context;
1656
- let children = props.widgetGroups.map((widgetGroup) => this.renderWidgetGroup(widgetGroup));
1657
- return createElement('div', {
1658
- className: generateClassName(options.toolbarSectionClass, { name: props.name }),
1659
- }, ...children);
1660
- }
1661
- renderWidgetGroup(widgetGroup) {
1662
- var _a;
1663
- let { props, context } = this;
1664
- let { options } = context;
1665
- let children = [];
1666
- let isOnlyButtons = true;
1667
- let isOnlyView = true;
1668
- for (const widget of widgetGroup) {
1669
- const { name, isView } = widget;
1670
- if (name === 'title') {
1671
- isOnlyButtons = false;
1672
- }
1673
- else if (!isView) {
1674
- isOnlyView = false;
1675
- }
1676
- }
1677
- for (let widget of widgetGroup) {
1678
- let { name, customElement, buttonHint } = widget;
1679
- if (name === 'title') {
1680
- children.push(createElement("div", { role: 'heading', "aria-level": options.headingLevel, id: props.titleId, className: joinArrayishClassNames(options.toolbarTitleClass) }, props.title));
1681
- }
1682
- else if (customElement) {
1683
- children.push(createElement(ContentContainer, { tag: 'span', style: { display: 'contents' }, renderProps: {}, generatorName: undefined, customGenerator: customElement }));
1684
- }
1685
- else {
1686
- let isSelected = name === props.selectedButton;
1687
- let isDisabled = (!props.isTodayEnabled && name === 'today') ||
1688
- (!props.isPrevEnabled && name === 'prev') ||
1689
- (!props.isNextEnabled && name === 'next');
1690
- let buttonDisplay = (_a = widget.buttonDisplay) !== null && _a !== void 0 ? _a : options.buttonDisplay;
1691
- if (buttonDisplay === 'auto') {
1692
- buttonDisplay = (widget.buttonIconContent || widget.buttonIconClass)
1693
- ? 'icon'
1694
- : 'text';
1695
- }
1696
- let iconNode;
1697
- if (buttonDisplay !== 'text') {
1698
- iconNode = (createElement(ButtonIcon, { className: widget.buttonIconClass, contentGenerator: widget.buttonIconContent }));
1699
- }
1700
- let inGroup = widgetGroup.length > 1 && isOnlyButtons;
1701
- let inViewGroup = inGroup && isOnlyView;
1702
- let renderProps = {
1703
- name,
1704
- text: widget.buttonText,
1705
- isPrimary: widget.buttonIsPrimary,
1706
- isSelected,
1707
- isDisabled,
1708
- isIconOnly: buttonDisplay === 'icon',
1709
- inGroup,
1710
- inSelectGroup: inViewGroup,
1711
- };
1712
- children.push(createElement(ContentContainer, { tag: 'button', attrs: Object.assign(Object.assign({ type: 'button', disabled: isDisabled }, ((isOnlyButtons && isOnlyView)
1713
- ? { 'role': 'tab', 'aria-selected': isSelected }
1714
- : { 'aria-pressed': isSelected })), { 'aria-label': typeof buttonHint === 'function'
1715
- ? buttonHint(props.navUnit)
1716
- : buttonHint, onClick: widget.buttonClick }), className: joinClassNames(generateClassName(options.buttonClass, renderProps), !isDisabled && classNames.cursorPointer, inGroup && joinClassNames(isSelected ? classNames.z1 : classNames.z0, classNames.focusZ2)), renderProps: renderProps, generatorName: undefined, classNameGenerator: widget.buttonClass, didMount: widget.buttonDidMount, willUnmount: widget.buttonWillUnmount }, () => (buttonDisplay === 'text'
1717
- ? widget.buttonText
1718
- : buttonDisplay === 'icon'
1719
- ? iconNode
1720
- : buttonDisplay === 'icon-text'
1721
- ? (createElement(Fragment, null,
1722
- iconNode,
1723
- widget.buttonText))
1724
- : (createElement(Fragment, null,
1725
- widget.buttonText,
1726
- iconNode)) // text-icon
1727
- )));
1728
- }
1729
- }
1730
- if (children.length > 1) {
1731
- return createElement('div', {
1732
- role: (isOnlyButtons && isOnlyView) ? 'tablist' : undefined,
1733
- 'aria-label': (isOnlyButtons && isOnlyView) ? options.viewChangeHint : undefined,
1734
- className: joinClassNames(generateClassName(options.buttonGroupClass, { isSelectGroup: isOnlyView }), classNames.isolate),
1735
- }, ...children);
1736
- }
1737
- return children[0];
1738
- }
1739
- }
1740
-
1741
- class Toolbar extends BaseComponent {
1742
- render() {
1743
- let { props } = this;
1744
- let options = this.context.options;
1745
- let { sectionWidgets } = props.model;
1746
- return (createElement("div", { className: joinClassNames(props.className, generateClassName(options.toolbarClass, {
1747
- borderlessX: props.borderlessX,
1748
- })) },
1749
- this.renderSection('start', sectionWidgets.start),
1750
- this.renderSection('center', sectionWidgets.center),
1751
- this.renderSection('end', sectionWidgets.end)));
1752
- }
1753
- renderSection(key, widgetGroups) {
1754
- let { props } = this;
1755
- return (createElement(ToolbarSection, { key: key, name: key, widgetGroups: widgetGroups, title: props.title, titleId: props.titleId, navUnit: props.navUnit, selectedButton: props.selectedButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled }));
1756
- }
1757
- }
1758
-
1759
- class CalendarContent extends PureComponent {
1760
- constructor() {
1761
- super(...arguments);
1762
- this.buildViewContext = memoize(buildViewContext);
1763
- this.buildViewPropTransformers = memoize(buildViewPropTransformers);
1764
- this.interactionsStore = {};
1765
- this.viewTitleId = getUniqueDomId();
1766
- // Component Registration
1767
- // -----------------------------------------------------------------------------------------------------------------
1768
- this.registerInteractiveComponent = (component, settingsInput) => {
1769
- let settings = parseInteractionSettings(component, settingsInput);
1770
- let DEFAULT_INTERACTIONS = [
1771
- EventClicking,
1772
- EventHovering,
1773
- ];
1774
- let interactionClasses = DEFAULT_INTERACTIONS;
1775
- if (!settingsInput.disableHits) {
1776
- interactionClasses = interactionClasses.concat(this.props.pluginHooks.componentInteractions);
1777
- }
1778
- let interactions = interactionClasses.map((TheInteractionClass) => new TheInteractionClass(settings));
1779
- this.interactionsStore[component.uid] = interactions;
1780
- interactionSettingsStore[component.uid] = settings;
1781
- };
1782
- this.unregisterInteractiveComponent = (component) => {
1783
- let listeners = this.interactionsStore[component.uid];
1784
- if (listeners) {
1785
- for (let listener of listeners) {
1786
- listener.destroy();
1787
- }
1788
- delete this.interactionsStore[component.uid];
1789
- }
1790
- delete interactionSettingsStore[component.uid];
1791
- };
1792
- }
1793
- /*
1794
- renders INSIDE of an outer div
1795
- */
1796
- render() {
1797
- var _a;
1798
- let { props } = this;
1799
- let { toolbarProps, toolbarConfig, options } = props;
1800
- let viewHeight;
1801
- let viewHeightLiquid = false;
1802
- let viewAspectRatio;
1803
- if (props.forPrint || getIsHeightAuto(options)) ;
1804
- else if (options.height != null) {
1805
- viewHeightLiquid = true;
1806
- }
1807
- else if (options.contentHeight != null) {
1808
- viewHeight = options.contentHeight;
1809
- }
1810
- else {
1811
- viewAspectRatio = Math.max(options.aspectRatio, 0.5); // prevent from getting too tall
1812
- }
1813
- let viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
1814
- let borderlessX = (_a = options.borderlessX) !== null && _a !== void 0 ? _a : options.borderless; // TODO: DRY
1815
- return (createElement(ViewContextType.Provider, { value: viewContext },
1816
- toolbarConfig.header && (createElement(Toolbar, Object.assign({ className: generateClassName(options.headerToolbarClass, { borderlessX }), model: toolbarConfig.header, borderlessX: borderlessX, titleId: this.viewTitleId }, toolbarProps))),
1817
- createElement("div", { className: joinClassNames(classNames.flexCol, classNames.rel, viewHeightLiquid && classNames.liquid), style: {
1818
- height: viewHeight,
1819
- paddingBottom: viewAspectRatio != null
1820
- ? `${(1 / viewAspectRatio) * 100}%`
1821
- : undefined
1822
- } },
1823
- this.renderView(joinClassNames((viewHeightLiquid || viewHeight) && classNames.liquid, viewAspectRatio != null && classNames.fill, classNames.internalView), toolbarProps.title),
1824
- this.buildAppendContent()),
1825
- toolbarConfig.footer && (createElement(Toolbar, Object.assign({ className: generateClassName(options.footerToolbarClass, { borderlessX }), model: toolbarConfig.footer, borderlessX: borderlessX }, toolbarProps)))));
1826
- }
1827
- componentDidMount() {
1828
- let { props } = this;
1829
- this.calendarInteractions = props.pluginHooks.calendarInteractions
1830
- .map((CalendarInteractionClass) => new CalendarInteractionClass(props));
1831
- let { propSetHandlers } = props.pluginHooks;
1832
- for (let propName in propSetHandlers) {
1833
- propSetHandlers[propName](props[propName], props);
1834
- }
1835
- }
1836
- componentDidUpdate(prevProps) {
1837
- let { props } = this;
1838
- let { propSetHandlers } = props.pluginHooks;
1839
- for (let propName in propSetHandlers) {
1840
- if (props[propName] !== prevProps[propName]) {
1841
- propSetHandlers[propName](props[propName], props);
1842
- }
1843
- }
1844
- }
1845
- componentWillUnmount() {
1846
- for (let interaction of this.calendarInteractions) {
1847
- interaction.destroy();
1848
- }
1849
- this.props.emitter.trigger('_unmount');
1850
- }
1851
- buildAppendContent() {
1852
- let { props } = this;
1853
- let children = props.pluginHooks.viewContainerAppends.map((buildAppendContent) => buildAppendContent(props));
1854
- return createElement(Fragment, {}, ...children);
1855
- }
1856
- renderView(className, title) {
1857
- var _a, _b, _c;
1858
- let { props } = this;
1859
- let { pluginHooks, viewSpec, toolbarConfig, options } = props;
1860
- // TODO: DRY
1861
- let { borderless } = options;
1862
- let calendarBorderlessX = (_a = options.borderlessX) !== null && _a !== void 0 ? _a : borderless;
1863
- let calendarBorderlessTop = (_b = options.borderlessTop) !== null && _b !== void 0 ? _b : borderless;
1864
- let calendarBorderlessBottom = (_c = options.borderlessBottom) !== null && _c !== void 0 ? _c : borderless;
1865
- let viewProps = {
1866
- className,
1867
- dateProfile: props.dateProfile,
1868
- businessHours: props.businessHours,
1869
- eventStore: props.renderableEventStore,
1870
- eventUiBases: props.eventUiBases,
1871
- dateSelection: props.dateSelection,
1872
- eventSelection: props.eventSelection,
1873
- eventDrag: props.eventDrag,
1874
- eventResize: props.eventResize,
1875
- forPrint: props.forPrint,
1876
- labelId: toolbarConfig.header && toolbarConfig.header.hasTitle ? this.viewTitleId : undefined,
1877
- labelStr: toolbarConfig.header && toolbarConfig.header.hasTitle ? undefined : title,
1878
- borderlessX: calendarBorderlessX,
1879
- borderlessTop: toolbarConfig.header ? false : calendarBorderlessTop,
1880
- borderlessBottom: toolbarConfig.footer ? false : calendarBorderlessBottom,
1881
- noEdgeEffects: calendarBorderlessX || calendarBorderlessTop || calendarBorderlessBottom,
1882
- };
1883
- let transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
1884
- for (let transformer of transformers) {
1885
- Object.assign(viewProps, transformer.transform(viewProps, props));
1886
- }
1887
- let ViewComponent = viewSpec.component;
1888
- return (createElement(ViewComponent, Object.assign({}, viewProps)));
1889
- }
1890
- }
1891
- // Plugin
1892
- // -----------------------------------------------------------------------------------------------------------------
1893
- function buildViewPropTransformers(theClasses) {
1894
- return theClasses.map((TheClass) => new TheClass());
1895
- }
1896
-
1897
- /*
1898
- Vanilla JS API
1899
- */
1900
- class Calendar extends CalendarImpl {
1901
- constructor(el, optionOverrides = {}) {
1902
- super();
1903
- this.buildToolbarProps = memoize(buildToolbarProps);
1904
- this.isRendering = false;
1905
- this.isRendered = false;
1906
- this.currentClassName = '';
1907
- this.customContentRenderId = 0;
1908
- this.handleAction = (action) => {
1909
- // actions we know we want to render immediately
1910
- switch (action.type) {
1911
- case 'SET_EVENT_DRAG':
1912
- case 'SET_EVENT_RESIZE':
1913
- this.renderRunner.tryDrain();
1914
- }
1915
- };
1916
- this.handleData = (data) => {
1917
- this.currentData = data;
1918
- this.renderRunner.request(data.calendarOptions.rerenderDelay);
1919
- };
1920
- this.handleRenderRequest = () => {
1921
- if (this.isRendering) {
1922
- this.isRendered = true;
1923
- let { currentData } = this;
1924
- flushSync(() => {
1925
- render(createElement(CalendarRoot, { options: currentData.calendarOptions, emitter: currentData.emitter }, (isRtl, className, height, forPrint) => {
1926
- this.setIsRtl(isRtl);
1927
- this.setClassName(className);
1928
- this.setHeight(height);
1929
- const toolbarProps = this.toolbarProps = this.buildToolbarProps(currentData.viewSpec, currentData.dateProfile, currentData.dateProfileGenerator, currentData.currentDate, getNow(currentData.options.now, currentData.dateEnv), // TODO: use NowTimer????
1930
- currentData.viewTitle);
1931
- return (createElement(RenderId.Provider, { value: this.customContentRenderId },
1932
- createElement(CalendarContent, Object.assign({ forPrint: forPrint, toolbarProps: toolbarProps }, currentData))));
1933
- }), this.el);
1934
- });
1935
- }
1936
- else if (this.isRendered) {
1937
- this.isRendered = false;
1938
- render(null, this.el);
1939
- this.setIsRtl(false);
1940
- this.setClassName('');
1941
- this.setHeight('');
1942
- }
1943
- };
1944
- this.el = el;
1945
- this.renderRunner = new DelayedRunner(this.handleRenderRequest);
1946
- new CalendarDataManager({
1947
- optionOverrides,
1948
- calendarApi: this,
1949
- onAction: this.handleAction,
1950
- onData: this.handleData,
1951
- });
1952
- }
1953
- render() {
1954
- let wasRendering = this.isRendering;
1955
- if (!wasRendering) {
1956
- this.isRendering = true;
1957
- }
1958
- else {
1959
- this.customContentRenderId += 1;
1960
- }
1961
- this.renderRunner.request();
1962
- if (wasRendering) {
1963
- this.updateSize();
1964
- }
1965
- }
1966
- destroy() {
1967
- if (this.isRendering) {
1968
- this.isRendering = false;
1969
- this.renderRunner.request();
1970
- }
1971
- }
1972
- batchRendering(func) {
1973
- this.renderRunner.pause('batchRendering');
1974
- func();
1975
- this.renderRunner.resume('batchRendering');
1976
- }
1977
- pauseRendering() {
1978
- this.renderRunner.pause('pauseRendering');
1979
- }
1980
- resumeRendering() {
1981
- this.renderRunner.resume('pauseRendering', true);
1982
- }
1983
- resetOptions(optionOverrides, changedOptionNames) {
1984
- this.currentDataManager.resetOptions(optionOverrides, changedOptionNames);
1985
- }
1986
- /*
1987
- TODO: DRY with toolbar-parse.ts and ToolbarSection
1988
- */
1989
- getButtonState() {
1990
- var _a;
1991
- const { currentData, toolbarProps } = this;
1992
- const options = currentData.calendarOptions;
1993
- const buttonConfigs = options.buttons || {};
1994
- const viewSpecs = currentData.viewSpecs;
1995
- const buttonState = {
1996
- today: {
1997
- text: options.todayText,
1998
- hint: options.todayHint,
1999
- isDisabled: !toolbarProps.isTodayEnabled,
2000
- },
2001
- prev: {
2002
- text: options.prevText,
2003
- hint: options.prevHint,
2004
- isDisabled: !toolbarProps.isPrevEnabled,
2005
- },
2006
- next: {
2007
- text: options.nextText,
2008
- hint: options.nextHint,
2009
- isDisabled: !toolbarProps.isNextEnabled,
2010
- },
2011
- prevYear: {
2012
- text: options.prevYearText,
2013
- hint: formatWithOrdinals(options.prevHint, [options.yearText, 'year'], options.prevYearText),
2014
- isDisabled: false,
2015
- },
2016
- nextYear: {
2017
- text: options.prevYearText,
2018
- hint: formatWithOrdinals(options.nextHint, [options.yearText, 'year'], options.nextYearText),
2019
- isDisabled: false,
2020
- },
2021
- };
2022
- for (const viewSpecName in viewSpecs) {
2023
- const viewSpec = viewSpecs[viewSpecName];
2024
- const buttonTextKey = viewSpec.optionDefaults.buttonTextKey;
2025
- const buttonText = ((_a = buttonConfigs[viewSpecName]) === null || _a === void 0 ? void 0 : _a.text) ||
2026
- (buttonTextKey ? options[buttonTextKey] : '') ||
2027
- (viewSpec.singleUnit ? options[viewSpec.singleUnit + 'Text'] : '') ||
2028
- viewSpecName;
2029
- const buttonHint = formatWithOrdinals(options.viewHint, [buttonText, viewSpecName], // ordinal arguments
2030
- buttonText);
2031
- buttonState[viewSpecName] = {
2032
- text: buttonText,
2033
- hint: buttonHint,
2034
- };
2035
- }
2036
- return buttonState;
2037
- }
2038
- setClassName(className) {
2039
- if (className !== this.currentClassName) {
2040
- let { classList } = this.el;
2041
- for (let singleClassName of this.currentClassName.split(' ')) {
2042
- if (singleClassName) {
2043
- classList.remove(singleClassName);
2044
- }
2045
- }
2046
- for (let singleClassName of className.split(' ')) {
2047
- if (singleClassName) {
2048
- classList.add(singleClassName);
2049
- }
2050
- }
2051
- this.currentClassName = className;
2052
- }
2053
- }
2054
- setHeight(height) {
2055
- applyStyleProp(this.el, 'height', height);
2056
- }
2057
- setIsRtl(isRtl) {
2058
- if (isRtl) {
2059
- this.el.dir = 'rtl';
2060
- }
2061
- else {
2062
- this.el.removeAttribute('dir');
2063
- }
2064
- }
2065
- }
2066
- function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
2067
- // don't force any date-profiles to valid date profiles (the `false`) so that we can tell if it's invalid
2068
- let todayInfo = dateProfileGenerator.build(now, undefined, false); // TODO: need `undefined` or else INFINITE LOOP for some reason
2069
- let prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
2070
- let nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
2071
- return {
2072
- title,
2073
- selectedButton: viewSpec.type,
2074
- navUnit: viewSpec.singleUnit,
2075
- isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
2076
- isPrevEnabled: prevInfo.isValid,
2077
- isNextEnabled: nextInfo.isValid,
2078
- };
2079
- }
2080
-
2081
- const blankButtonState = {
2082
- text: '', hint: '', isDisabled: false,
2083
- };
2084
- class CalendarController {
2085
- constructor(handleDateChange) {
2086
- this.handleDateChange = handleDateChange;
2087
- }
2088
- today() {
2089
- var _a;
2090
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.today();
2091
- }
2092
- prev() {
2093
- var _a;
2094
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.prev();
2095
- }
2096
- next() {
2097
- var _a;
2098
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.next();
2099
- }
2100
- prevYear() {
2101
- var _a;
2102
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.prevYear();
2103
- }
2104
- nextYear() {
2105
- var _a;
2106
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.nextYear();
2107
- }
2108
- gotoDate(zonedDateInput) {
2109
- var _a;
2110
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.gotoDate(zonedDateInput);
2111
- }
2112
- incrementDate(duration) {
2113
- var _a;
2114
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.incrementDate(duration);
2115
- }
2116
- changeView(viewType) {
2117
- var _a;
2118
- (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.changeView(viewType);
2119
- }
2120
- get view() {
2121
- var _a;
2122
- return (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.view;
2123
- }
2124
- getDate() {
2125
- var _a;
2126
- return (_a = this.calendarApi) === null || _a === void 0 ? void 0 : _a.getDate();
2127
- }
2128
- getButtonState() {
2129
- const { calendarApi } = this;
2130
- return (calendarApi && calendarApi.getButtonState()) || {
2131
- today: blankButtonState,
2132
- prev: blankButtonState,
2133
- next: blankButtonState,
2134
- prevYear: blankButtonState,
2135
- nextYear: blankButtonState,
2136
- };
2137
- }
2138
- _setApi(calendarApi) {
2139
- if (this.calendarApi !== calendarApi) {
2140
- if (this.calendarApi) {
2141
- this.calendarApi.off('datesSet', this.handleDateChange);
2142
- this.calendarApi = undefined;
2143
- }
2144
- if (calendarApi) {
2145
- this.calendarApi = calendarApi;
2146
- calendarApi.on('datesSet', this.handleDateChange);
2147
- }
2148
- }
2149
- }
2150
- }
2151
-
2152
- function formatDate(dateInput, options = {}) {
2153
- let dateEnv = buildDateEnv(options);
2154
- let formatter = createFormatter(options);
2155
- let dateMeta = dateEnv.createMarkerMeta(dateInput);
2156
- if (!dateMeta) { // TODO: warning?
2157
- return '';
2158
- }
2159
- return dateEnv.format(dateMeta.marker, formatter, {
2160
- forcedTzo: dateMeta.forcedTzo,
2161
- })[0];
2162
- }
2163
- function formatRange(startInput, endInput, options) {
2164
- let dateEnv = buildDateEnv(typeof options === 'object' && options ? options : {}); // pass in if non-null object
2165
- let formatter = createFormatter(options);
2166
- let startMeta = dateEnv.createMarkerMeta(startInput);
2167
- let endMeta = dateEnv.createMarkerMeta(endInput);
2168
- if (!startMeta || !endMeta) { // TODO: warning?
2169
- return '';
2170
- }
2171
- return dateEnv.formatRange(startMeta.marker, endMeta.marker, formatter, {
2172
- forcedStartTzo: startMeta.forcedTzo,
2173
- forcedEndTzo: endMeta.forcedTzo,
2174
- isEndExclusive: options.isEndExclusive,
2175
- defaultSeparator: BASE_OPTION_DEFAULTS.defaultRangeSeparator,
2176
- });
2177
- }
2178
- // TODO: more DRY and optimized
2179
- function buildDateEnv(settings) {
2180
- let locale = buildLocale(settings.locale || 'en', organizeRawLocales([]).map); // TODO: don't hardcode 'en' everywhere
2181
- return new DateEnv(Object.assign(Object.assign({ timeZone: BASE_OPTION_DEFAULTS.timeZone, calendarSystem: 'gregory' }, settings), { locale }));
2182
- }
2183
-
2184
- // HELPERS
2185
- /*
2186
- if nextDayThreshold is specified, slicing is done in an all-day fashion.
2187
- you can get nextDayThreshold from context.nextDayThreshold
2188
- */
2189
- function sliceEvents(props, allDay) {
2190
- return sliceEventStore(props.eventStore, props.eventUiBases, props.dateProfile.activeRange, allDay ? props.nextDayThreshold : null).fg;
2191
- }
2192
-
2193
- const version = '7.0.0-beta.6';
2194
-
2195
- export { Calendar, CalendarController, createPlugin, formatDate, formatRange, globalLocales, globalPlugins, sliceEvents, version };