@rededor/cura 1.0.0 → 1.2.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/dist/assets/assets/cura-assets.zip +0 -0
  2. package/dist/assets/assets/fonts/Gotham/Gotham-Black.woff2 +0 -0
  3. package/dist/assets/assets/fonts/Gotham/Gotham-BlackItalic.woff2 +0 -0
  4. package/dist/assets/assets/fonts/Gotham/Gotham-Bold.woff2 +0 -0
  5. package/dist/assets/assets/fonts/Gotham/Gotham-BoldItalic.woff2 +0 -0
  6. package/dist/assets/assets/fonts/Gotham/Gotham-Book.woff2 +0 -0
  7. package/dist/assets/assets/fonts/Gotham/Gotham-BookItalic.woff2 +0 -0
  8. package/dist/assets/assets/fonts/Gotham/Gotham-ExtraLight.woff2 +0 -0
  9. package/dist/assets/assets/fonts/Gotham/Gotham-ExtraLightItalic.woff2 +0 -0
  10. package/dist/assets/assets/fonts/Gotham/Gotham-Light.woff2 +0 -0
  11. package/dist/assets/assets/fonts/Gotham/Gotham-LightItalic.woff2 +0 -0
  12. package/dist/assets/assets/fonts/Gotham/Gotham-Medium.woff2 +0 -0
  13. package/dist/assets/assets/fonts/Gotham/Gotham-MediumItalic.woff2 +0 -0
  14. package/dist/assets/assets/fonts/Gotham/Gotham-Thin.woff2 +0 -0
  15. package/dist/assets/assets/fonts/Gotham/Gotham-ThinItalic.woff2 +0 -0
  16. package/dist/assets/assets/fonts/Gotham/Gotham-Ultra.woff2 +0 -0
  17. package/dist/assets/assets/fonts/Gotham/Gotham-UltraItalic.woff2 +0 -0
  18. package/dist/assets/assets/fonts/Gotham/style.css +90 -0
  19. package/dist/assets/assets/fonts/HankenGrotesk/HankenGrotesk-Italic-VariableFont_wght.woff2 +0 -0
  20. package/dist/assets/assets/fonts/HankenGrotesk/HankenGrotesk-VariableFont_wght.woff2 +0 -0
  21. package/dist/assets/assets/fonts/HankenGrotesk/style-webfont.css +72 -0
  22. package/dist/assets/assets/fonts/HankenGrotesk/style.css +16 -0
  23. package/dist/assets/assets/fonts/Roboto/Roboto-Black.woff2 +0 -0
  24. package/dist/assets/assets/fonts/Roboto/Roboto-BlackItalic.woff2 +0 -0
  25. package/dist/assets/assets/fonts/Roboto/Roboto-Bold.woff2 +0 -0
  26. package/dist/assets/assets/fonts/Roboto/Roboto-BoldItalic.woff2 +0 -0
  27. package/dist/assets/assets/fonts/Roboto/Roboto-Italic.woff2 +0 -0
  28. package/dist/assets/assets/fonts/Roboto/Roboto-Light.woff2 +0 -0
  29. package/dist/assets/assets/fonts/Roboto/Roboto-LightItalic.woff2 +0 -0
  30. package/dist/assets/assets/fonts/Roboto/Roboto-Medium.woff2 +0 -0
  31. package/dist/assets/assets/fonts/Roboto/Roboto-MediumItalic.woff2 +0 -0
  32. package/dist/assets/assets/fonts/Roboto/Roboto-Regular.woff2 +0 -0
  33. package/dist/assets/assets/fonts/Roboto/Roboto-Thin.woff2 +0 -0
  34. package/dist/assets/assets/fonts/Roboto/Roboto-ThinItalic.woff2 +0 -0
  35. package/dist/assets/assets/fonts/Roboto/style-webfont.css +756 -0
  36. package/dist/assets/assets/fonts/Roboto/style.css +90 -0
  37. package/dist/assets/assets/images/avatar/doctor-default.svg +6 -7
  38. package/dist/assets/assets/images/avatar/doctor-default_old.svg +8 -0
  39. package/dist/assets/assets/images/avatar/dora-default.svg +3 -4
  40. package/dist/assets/assets/images/avatar/dora-default_old.svg +5 -0
  41. package/dist/assets/assets/images/avatar/patient-default.svg +16 -10
  42. package/dist/assets/assets/images/avatar/patient-default_old.svg +12 -0
  43. package/dist/assets/assets/images/avatar/unit-default.svg +7 -8
  44. package/dist/assets/assets/images/avatar/unit-default_old.svg +9 -0
  45. package/dist/cjs/{app-globals-b77d5b06.js → app-globals-4d07f363.js} +20 -4
  46. package/dist/cjs/app-globals-4d07f363.js.map +1 -0
  47. package/dist/cjs/cura-accordion_12.cjs.entry.js +24 -17
  48. package/dist/cjs/cura-accordion_12.cjs.entry.js.map +1 -1
  49. package/dist/cjs/cura-alert.cjs.entry.js +2 -2
  50. package/dist/cjs/cura-avatar.cjs.entry.js +2 -2
  51. package/dist/cjs/cura-badge-distance.cjs.entry.js +1 -1
  52. package/dist/cjs/cura-badge-number.cjs.entry.js +29 -0
  53. package/dist/cjs/cura-badge-number.cjs.entry.js.map +1 -0
  54. package/dist/cjs/cura-button-outline.cjs.entry.js +2 -2
  55. package/dist/cjs/cura-button-outline.cjs.entry.js.map +1 -1
  56. package/dist/cjs/cura-button-select.cjs.entry.js +69 -58
  57. package/dist/cjs/cura-button-select.cjs.entry.js.map +1 -1
  58. package/dist/cjs/cura-button-transparent.cjs.entry.js +2 -2
  59. package/dist/cjs/cura-button-transparent.cjs.entry.js.map +1 -1
  60. package/dist/cjs/cura-calendar.cjs.entry.js +126 -235
  61. package/dist/cjs/cura-calendar.cjs.entry.js.map +1 -1
  62. package/dist/cjs/cura-card.cjs.entry.js +2 -2
  63. package/dist/cjs/cura-checkbox.cjs.entry.js +3 -3
  64. package/dist/cjs/cura-checkbox.cjs.entry.js.map +1 -1
  65. package/dist/cjs/cura-display.cjs.entry.js +2 -2
  66. package/dist/cjs/cura-dropdown-search-option-title.cjs.entry.js +2 -2
  67. package/dist/cjs/cura-dropdown-search-option.cjs.entry.js +3 -3
  68. package/dist/cjs/cura-dropdown-search.cjs.entry.js +33 -6
  69. package/dist/cjs/cura-dropdown-search.cjs.entry.js.map +1 -1
  70. package/dist/cjs/cura-icons-view.cjs.entry.js +4 -4
  71. package/dist/cjs/cura-input-date.cjs.entry.js +188 -0
  72. package/dist/cjs/cura-input-date.cjs.entry.js.map +1 -0
  73. package/dist/cjs/cura-loader-bar.cjs.entry.js +2 -2
  74. package/dist/cjs/cura-radio.cjs.entry.js +2 -2
  75. package/dist/cjs/cura-switch.cjs.entry.js +2 -2
  76. package/dist/cjs/cura-toast.cjs.entry.js +2 -2
  77. package/dist/cjs/cura.cjs.js +3 -3
  78. package/dist/cjs/index-6dc29195.js +126 -0
  79. package/dist/cjs/index-6dc29195.js.map +1 -0
  80. package/dist/cjs/{index-98e7ba54.js → index-e6d728ec.js} +70 -3
  81. package/dist/{esm/index-1ad98520.js.map → cjs/index-e6d728ec.js.map} +1 -1
  82. package/dist/cjs/loader.cjs.js +3 -3
  83. package/dist/collection/api/theme-presets/theme-default.js +3 -3
  84. package/dist/collection/api/theme-presets/theme-default.js.map +1 -1
  85. package/dist/collection/api/theme-presets/theme-legacy-default.js +16 -0
  86. package/dist/collection/api/theme-presets/theme-legacy-default.js.map +1 -1
  87. package/dist/collection/assets/images/avatar/doctor-default.svg +6 -7
  88. package/dist/collection/assets/images/avatar/doctor-default_old.svg +8 -0
  89. package/dist/collection/assets/images/avatar/dora-default.svg +3 -4
  90. package/dist/collection/assets/images/avatar/dora-default_old.svg +5 -0
  91. package/dist/collection/assets/images/avatar/patient-default.svg +16 -10
  92. package/dist/collection/assets/images/avatar/patient-default_old.svg +12 -0
  93. package/dist/collection/assets/images/avatar/unit-default.svg +7 -8
  94. package/dist/collection/assets/images/avatar/unit-default_old.svg +9 -0
  95. package/dist/collection/collection-manifest.json +2 -0
  96. package/dist/collection/components/badges/cura-badge-number/cura-badge-number.css +30 -0
  97. package/dist/collection/components/badges/cura-badge-number/cura-badge-number.js +66 -0
  98. package/dist/collection/components/badges/cura-badge-number/cura-badge-number.js.map +1 -0
  99. package/dist/collection/components/badges/cura-badge-number/cura-badge-number.stories.js +56 -0
  100. package/dist/collection/components/badges/cura-badge-number/cura-badge-number.stories.js.map +1 -0
  101. package/dist/collection/components/buttons/cura-button/cura-button.js +1 -1
  102. package/dist/collection/components/buttons/cura-button/cura-button.js.map +1 -1
  103. package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.js +1 -1
  104. package/dist/collection/components/buttons/cura-button-outline/cura-button-outline.js.map +1 -1
  105. package/dist/collection/components/buttons/cura-button-select/cura-button-select.css +49 -21
  106. package/dist/collection/components/buttons/cura-button-select/cura-button-select.js +110 -113
  107. package/dist/collection/components/buttons/cura-button-select/cura-button-select.js.map +1 -1
  108. package/dist/collection/components/buttons/cura-button-select/cura-button-select.stories.js +133 -0
  109. package/dist/collection/components/buttons/cura-button-select/cura-button-select.stories.js.map +1 -0
  110. package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.js +1 -1
  111. package/dist/collection/components/buttons/cura-button-transparent/cura-button-transparent.js.map +1 -1
  112. package/dist/collection/components/cura-alert/cura-alert.js +1 -1
  113. package/dist/collection/components/cura-avatar/cura-avatar.js +1 -1
  114. package/dist/collection/components/cura-calendar/cura-calendar.css +15 -5
  115. package/dist/collection/components/cura-calendar/cura-calendar.js +139 -52
  116. package/dist/collection/components/cura-calendar/cura-calendar.js.map +1 -1
  117. package/dist/collection/components/cura-calendar/cura-calendar.stories.js +33 -3
  118. package/dist/collection/components/cura-calendar/cura-calendar.stories.js.map +1 -1
  119. package/dist/collection/components/cura-card/cura-card.js +1 -1
  120. package/dist/collection/components/cura-icon/cura-icon.js +1 -1
  121. package/dist/collection/components/cura-icons-view/cura-icons-view.js +3 -3
  122. package/dist/collection/components/cura-page-template/cura-page-template.js +1 -1
  123. package/dist/collection/components/cura-toast/cura-toast.js +1 -1
  124. package/dist/collection/components/forms/cura-checkbox/cura-checkbox.css +13 -5
  125. package/dist/collection/components/forms/cura-checkbox/cura-checkbox.js +1 -1
  126. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search-option/cura-dropdown-search-option.js +2 -2
  127. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search-option-title/cura-dropdown-search-option-title.js +1 -1
  128. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.css +1 -1
  129. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.js +49 -4
  130. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.js.map +1 -1
  131. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js +19 -6
  132. package/dist/collection/components/forms/cura-dropdown-search/cura-dropdown-search.stories.js.map +1 -1
  133. package/dist/collection/components/forms/cura-input-date/cura-input-date.css +79 -0
  134. package/dist/collection/components/forms/cura-input-date/cura-input-date.js +424 -0
  135. package/dist/collection/components/forms/cura-input-date/cura-input-date.js.map +1 -0
  136. package/dist/collection/components/forms/cura-input-date/cura-input-date.stories.js +138 -0
  137. package/dist/collection/components/forms/cura-input-date/cura-input-date.stories.js.map +1 -0
  138. package/dist/collection/components/forms/cura-input-text/cura-input-text.css +5 -2
  139. package/dist/collection/components/forms/cura-input-text/cura-input-text.js +41 -2
  140. package/dist/collection/components/forms/cura-input-text/cura-input-text.js.map +1 -1
  141. package/dist/collection/components/forms/cura-input-text/cura-input-text.stories.js +73 -21
  142. package/dist/collection/components/forms/cura-input-text/cura-input-text.stories.js.map +1 -1
  143. package/dist/collection/components/forms/cura-input-text/mask-presets/input-mask-presets.js +3 -0
  144. package/dist/collection/components/forms/cura-input-text/mask-presets/input-mask-presets.js.map +1 -1
  145. package/dist/collection/components/forms/cura-label/cura-label.js +1 -1
  146. package/dist/collection/components/forms/cura-radio/cura-radio.js +1 -1
  147. package/dist/collection/components/forms/cura-select/cura-select.css +6 -2
  148. package/dist/collection/components/forms/cura-select/cura-select.js +23 -4
  149. package/dist/collection/components/forms/cura-select/cura-select.js.map +1 -1
  150. package/dist/collection/components/forms/cura-select/cura-select.stories.js +11 -1
  151. package/dist/collection/components/forms/cura-select/cura-select.stories.js.map +1 -1
  152. package/dist/collection/components/forms/cura-select-options/cura-select-option.js +1 -1
  153. package/dist/collection/components/forms/cura-switch/cura-switch.js +1 -1
  154. package/dist/collection/components/loaders/cura-loader-bar/cura-loader-bar.js +1 -1
  155. package/dist/collection/components/loaders/cura-loader-circle/cura-loader-circle.js +1 -1
  156. package/dist/collection/components/text/cura-display/cura-display.js +1 -1
  157. package/dist/collection/components/text/cura-heading/cura-heading.js +1 -1
  158. package/dist/collection/components/text/cura-paragraph/cura-paragraph.css +3 -1
  159. package/dist/collection/components/text/cura-paragraph/cura-paragraph.js +1 -1
  160. package/dist/collection/stories/blocks/index.js +85 -0
  161. package/dist/components/cura-alert.js +1 -1
  162. package/dist/components/cura-avatar.js +1 -1
  163. package/dist/components/cura-badge-number.d.ts +11 -0
  164. package/dist/components/cura-badge-number.js +8 -0
  165. package/dist/components/cura-badge-number.js.map +1 -0
  166. package/dist/components/cura-badge-number2.js +49 -0
  167. package/dist/components/cura-badge-number2.js.map +1 -0
  168. package/dist/components/cura-button-outline.js +1 -1
  169. package/dist/components/cura-button-outline.js.map +1 -1
  170. package/dist/components/cura-button-select.js +81 -65
  171. package/dist/components/cura-button-select.js.map +1 -1
  172. package/dist/components/cura-button-transparent2.js +1 -1
  173. package/dist/components/cura-button-transparent2.js.map +1 -1
  174. package/dist/components/cura-button.js +1 -1
  175. package/dist/components/cura-button.js.map +1 -1
  176. package/dist/components/cura-calendar.js +1 -4065
  177. package/dist/components/cura-calendar.js.map +1 -1
  178. package/dist/components/cura-calendar2.js +4082 -0
  179. package/dist/components/cura-calendar2.js.map +1 -0
  180. package/dist/components/cura-card.js +1 -1
  181. package/dist/components/cura-checkbox.js +2 -2
  182. package/dist/components/cura-checkbox.js.map +1 -1
  183. package/dist/components/cura-display.js +1 -1
  184. package/dist/components/cura-dropdown-search-option-title.js +1 -1
  185. package/dist/components/cura-dropdown-search-option.js +2 -2
  186. package/dist/components/cura-dropdown-search.js +33 -5
  187. package/dist/components/cura-dropdown-search.js.map +1 -1
  188. package/dist/components/cura-heading2.js +1 -1
  189. package/dist/components/cura-icon2.js +1 -1
  190. package/dist/components/cura-icons-view.js +3 -3
  191. package/dist/components/cura-input-date.d.ts +11 -0
  192. package/dist/components/cura-input-date.js +270 -0
  193. package/dist/components/cura-input-date.js.map +1 -0
  194. package/dist/components/cura-input-text2.js +10 -2
  195. package/dist/components/cura-input-text2.js.map +1 -1
  196. package/dist/components/cura-label2.js +1 -1
  197. package/dist/components/cura-loader-bar2.js +1 -1
  198. package/dist/components/cura-loader-circle2.js +1 -1
  199. package/dist/components/cura-page-template.js +1 -1
  200. package/dist/components/cura-paragraph2.js +2 -2
  201. package/dist/components/cura-paragraph2.js.map +1 -1
  202. package/dist/components/cura-radio.js +1 -1
  203. package/dist/components/cura-select-option2.js +1 -1
  204. package/dist/components/cura-select2.js +7 -5
  205. package/dist/components/cura-select2.js.map +1 -1
  206. package/dist/components/cura-switch.js +1 -1
  207. package/dist/components/cura-toast.js +1 -1
  208. package/dist/components/index.js +23 -3
  209. package/dist/components/index.js.map +1 -1
  210. package/dist/cura/cura.esm.js +1 -1
  211. package/dist/cura/cura.esm.js.map +1 -1
  212. package/dist/cura/p-0b7a7306.js +2 -0
  213. package/dist/cura/p-0b7a7306.js.map +1 -0
  214. package/dist/cura/{p-0d435e42.entry.js → p-116a1cd6.entry.js} +2 -2
  215. package/dist/cura/p-272c784a.js +2 -0
  216. package/dist/cura/p-272c784a.js.map +1 -0
  217. package/dist/cura/{p-4c7a2419.entry.js → p-2d267d23.entry.js} +2 -2
  218. package/dist/cura/{p-b301a1ef.entry.js → p-33772510.entry.js} +2 -2
  219. package/dist/cura/{p-b301a1ef.entry.js.map → p-33772510.entry.js.map} +1 -1
  220. package/dist/cura/{p-0a923806.entry.js → p-41c3d47d.entry.js} +2 -2
  221. package/dist/cura/{p-0a923806.entry.js.map → p-41c3d47d.entry.js.map} +1 -1
  222. package/dist/cura/p-44e3325a.entry.js +2 -0
  223. package/dist/cura/p-44e3325a.entry.js.map +1 -0
  224. package/dist/cura/p-4e14c01c.entry.js +2 -0
  225. package/dist/cura/p-563ba0cd.entry.js +2 -0
  226. package/dist/cura/p-563ba0cd.entry.js.map +1 -0
  227. package/dist/cura/{p-57b8b468.entry.js → p-8f3db0fe.entry.js} +2 -2
  228. package/dist/cura/{p-a00d2c68.entry.js → p-907b3d12.entry.js} +2 -2
  229. package/dist/cura/p-a2ae6bd2.entry.js +2 -0
  230. package/dist/cura/p-a2ae6bd2.entry.js.map +1 -0
  231. package/dist/cura/{p-6682619b.entry.js → p-b2d5db22.entry.js} +2 -2
  232. package/dist/cura/p-b43b69f3.entry.js +2 -0
  233. package/dist/cura/p-b43b69f3.entry.js.map +1 -0
  234. package/dist/cura/{p-599acc84.entry.js → p-be10b681.entry.js} +2 -2
  235. package/dist/cura/p-be10b681.entry.js.map +1 -0
  236. package/dist/cura/{p-a5cf0fd6.entry.js → p-c6508bd7.entry.js} +2 -2
  237. package/dist/cura/{p-2203e829.entry.js → p-dcd2e5bb.entry.js} +2 -2
  238. package/dist/cura/{p-84d8c67d.entry.js → p-e5023e34.entry.js} +2 -2
  239. package/dist/cura/p-e8bc6381.entry.js +2 -0
  240. package/dist/cura/p-e8bc6381.entry.js.map +1 -0
  241. package/dist/cura/p-ed97cf3c.entry.js +2 -0
  242. package/dist/cura/p-ed97cf3c.entry.js.map +1 -0
  243. package/dist/cura/{p-ad8a7e0f.entry.js → p-fcbf4311.entry.js} +2 -2
  244. package/dist/cura/{p-66c5cf5f.entry.js → p-fd083399.entry.js} +2 -2
  245. package/dist/cura/p-fd5ed6b0.js +3 -0
  246. package/dist/cura/p-fd5ed6b0.js.map +1 -0
  247. package/dist/cura/{p-f9433d24.entry.js → p-fdce91a7.entry.js} +2 -2
  248. package/dist/esm/{app-globals-488bf508.js → app-globals-6ca7103d.js} +20 -4
  249. package/dist/esm/app-globals-6ca7103d.js.map +1 -0
  250. package/dist/esm/cura-accordion_12.entry.js +24 -17
  251. package/dist/esm/cura-accordion_12.entry.js.map +1 -1
  252. package/dist/esm/cura-alert.entry.js +2 -2
  253. package/dist/esm/cura-avatar.entry.js +2 -2
  254. package/dist/esm/cura-badge-distance.entry.js +1 -1
  255. package/dist/esm/cura-badge-number.entry.js +25 -0
  256. package/dist/esm/cura-badge-number.entry.js.map +1 -0
  257. package/dist/esm/cura-button-outline.entry.js +2 -2
  258. package/dist/esm/cura-button-outline.entry.js.map +1 -1
  259. package/dist/esm/cura-button-select.entry.js +69 -58
  260. package/dist/esm/cura-button-select.entry.js.map +1 -1
  261. package/dist/esm/cura-button-transparent.entry.js +2 -2
  262. package/dist/esm/cura-button-transparent.entry.js.map +1 -1
  263. package/dist/esm/cura-calendar.entry.js +58 -167
  264. package/dist/esm/cura-calendar.entry.js.map +1 -1
  265. package/dist/esm/cura-card.entry.js +2 -2
  266. package/dist/esm/cura-checkbox.entry.js +3 -3
  267. package/dist/esm/cura-checkbox.entry.js.map +1 -1
  268. package/dist/esm/cura-display.entry.js +2 -2
  269. package/dist/esm/cura-dropdown-search-option-title.entry.js +2 -2
  270. package/dist/esm/cura-dropdown-search-option.entry.js +3 -3
  271. package/dist/esm/cura-dropdown-search.entry.js +33 -6
  272. package/dist/esm/cura-dropdown-search.entry.js.map +1 -1
  273. package/dist/esm/cura-icons-view.entry.js +4 -4
  274. package/dist/esm/cura-input-date.entry.js +184 -0
  275. package/dist/esm/cura-input-date.entry.js.map +1 -0
  276. package/dist/esm/cura-loader-bar.entry.js +2 -2
  277. package/dist/esm/cura-radio.entry.js +2 -2
  278. package/dist/esm/cura-switch.entry.js +2 -2
  279. package/dist/esm/cura-toast.entry.js +2 -2
  280. package/dist/esm/cura.js +4 -4
  281. package/dist/esm/{index-1ad98520.js → index-747aad85.js} +70 -3
  282. package/dist/esm/index-747aad85.js.map +1 -0
  283. package/dist/esm/index-fbee309a.js +120 -0
  284. package/dist/esm/index-fbee309a.js.map +1 -0
  285. package/dist/esm/loader.js +4 -4
  286. package/dist/types/api/theme-presets/theme-legacy-default.d.ts +3 -3
  287. package/dist/types/api/theme-presets/theme-presets.d.ts +3 -3
  288. package/dist/types/components/badges/cura-badge-number/cura-badge-number.d.ts +8 -0
  289. package/dist/types/components/badges/cura-badge-number/cura-badge-number.stories.d.ts +39 -0
  290. package/dist/types/components/buttons/cura-button-select/cura-button-select.d.ts +12 -34
  291. package/dist/types/components/buttons/cura-button-select/cura-button-select.stories.d.ts +105 -0
  292. package/dist/types/components/cura-calendar/cura-calendar.d.ts +53 -42
  293. package/dist/types/components/cura-calendar/cura-calendar.stories.d.ts +33 -0
  294. package/dist/types/components/forms/cura-dropdown-search/cura-dropdown-search.d.ts +9 -3
  295. package/dist/types/components/forms/cura-dropdown-search/cura-dropdown-search.stories.d.ts +14 -0
  296. package/dist/types/components/forms/cura-input-date/cura-input-date.d.ts +92 -0
  297. package/dist/types/components/forms/cura-input-date/cura-input-date.stories.d.ts +125 -0
  298. package/dist/types/components/forms/cura-input-text/cura-input-text.d.ts +6 -0
  299. package/dist/types/components/forms/cura-input-text/cura-input-text.stories.d.ts +15 -0
  300. package/dist/types/components/forms/cura-select/cura-select.d.ts +5 -0
  301. package/dist/types/components/forms/cura-select/cura-select.stories.d.ts +11 -0
  302. package/dist/types/components.d.ts +180 -48
  303. package/package.json +5 -3
  304. package/dist/cjs/app-globals-b77d5b06.js.map +0 -1
  305. package/dist/cjs/index-98e7ba54.js.map +0 -1
  306. package/dist/cura/p-0dd837cf.entry.js +0 -2
  307. package/dist/cura/p-0dd837cf.entry.js.map +0 -1
  308. package/dist/cura/p-312791fb.js +0 -3
  309. package/dist/cura/p-312791fb.js.map +0 -1
  310. package/dist/cura/p-4ef24fbd.entry.js +0 -2
  311. package/dist/cura/p-4ef24fbd.entry.js.map +0 -1
  312. package/dist/cura/p-599acc84.entry.js.map +0 -1
  313. package/dist/cura/p-a6c3c0ea.js +0 -2
  314. package/dist/cura/p-a6c3c0ea.js.map +0 -1
  315. package/dist/cura/p-dc5d0c29.entry.js +0 -2
  316. package/dist/cura/p-dc5d0c29.entry.js.map +0 -1
  317. package/dist/cura/p-df5c3a86.entry.js +0 -2
  318. package/dist/cura/p-df5c3a86.entry.js.map +0 -1
  319. package/dist/cura/p-dfc65f66.entry.js +0 -2
  320. package/dist/esm/app-globals-488bf508.js.map +0 -1
  321. /package/dist/cura/{p-0d435e42.entry.js.map → p-116a1cd6.entry.js.map} +0 -0
  322. /package/dist/cura/{p-4c7a2419.entry.js.map → p-2d267d23.entry.js.map} +0 -0
  323. /package/dist/cura/{p-dfc65f66.entry.js.map → p-4e14c01c.entry.js.map} +0 -0
  324. /package/dist/cura/{p-57b8b468.entry.js.map → p-8f3db0fe.entry.js.map} +0 -0
  325. /package/dist/cura/{p-a00d2c68.entry.js.map → p-907b3d12.entry.js.map} +0 -0
  326. /package/dist/cura/{p-6682619b.entry.js.map → p-b2d5db22.entry.js.map} +0 -0
  327. /package/dist/cura/{p-a5cf0fd6.entry.js.map → p-c6508bd7.entry.js.map} +0 -0
  328. /package/dist/cura/{p-2203e829.entry.js.map → p-dcd2e5bb.entry.js.map} +0 -0
  329. /package/dist/cura/{p-84d8c67d.entry.js.map → p-e5023e34.entry.js.map} +0 -0
  330. /package/dist/cura/{p-ad8a7e0f.entry.js.map → p-fcbf4311.entry.js.map} +0 -0
  331. /package/dist/cura/{p-66c5cf5f.entry.js.map → p-fd083399.entry.js.map} +0 -0
  332. /package/dist/cura/{p-f9433d24.entry.js.map → p-fdce91a7.entry.js.map} +0 -0
@@ -1,4068 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
2
- import { d as defineCustomElement$7 } from './cura-button-transparent2.js';
3
- import { d as defineCustomElement$6 } from './cura-icon2.js';
4
- import { d as defineCustomElement$5 } from './cura-label2.js';
5
- import { d as defineCustomElement$4 } from './cura-loader-circle2.js';
6
- import { d as defineCustomElement$3 } from './cura-select2.js';
7
- import { d as defineCustomElement$2 } from './cura-select-option2.js';
8
-
9
- function _typeof(o) {
10
- "@babel/helpers - typeof";
11
-
12
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
13
- return typeof o;
14
- } : function (o) {
15
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
16
- }, _typeof(o);
17
- }
18
-
19
- function toInteger(dirtyNumber) {
20
- if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
21
- return NaN;
22
- }
23
- var number = Number(dirtyNumber);
24
- if (isNaN(number)) {
25
- return number;
26
- }
27
- return number < 0 ? Math.ceil(number) : Math.floor(number);
28
- }
29
-
30
- function requiredArgs(required, args) {
31
- if (args.length < required) {
32
- throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');
33
- }
34
- }
35
-
36
- /**
37
- * @name toDate
38
- * @category Common Helpers
39
- * @summary Convert the given argument to an instance of Date.
40
- *
41
- * @description
42
- * Convert the given argument to an instance of Date.
43
- *
44
- * If the argument is an instance of Date, the function returns its clone.
45
- *
46
- * If the argument is a number, it is treated as a timestamp.
47
- *
48
- * If the argument is none of the above, the function returns Invalid Date.
49
- *
50
- * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
51
- *
52
- * @param {Date|Number} argument - the value to convert
53
- * @returns {Date} the parsed date in the local time zone
54
- * @throws {TypeError} 1 argument required
55
- *
56
- * @example
57
- * // Clone the date:
58
- * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
59
- * //=> Tue Feb 11 2014 11:30:30
60
- *
61
- * @example
62
- * // Convert the timestamp to date:
63
- * const result = toDate(1392098430000)
64
- * //=> Tue Feb 11 2014 11:30:30
65
- */
66
- function toDate(argument) {
67
- requiredArgs(1, arguments);
68
- var argStr = Object.prototype.toString.call(argument);
69
-
70
- // Clone the date
71
- if (argument instanceof Date || _typeof(argument) === 'object' && argStr === '[object Date]') {
72
- // Prevent the date to lose the milliseconds when passed to new Date() in IE10
73
- return new Date(argument.getTime());
74
- } else if (typeof argument === 'number' || argStr === '[object Number]') {
75
- return new Date(argument);
76
- } else {
77
- if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {
78
- // eslint-disable-next-line no-console
79
- console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments");
80
- // eslint-disable-next-line no-console
81
- console.warn(new Error().stack);
82
- }
83
- return new Date(NaN);
84
- }
85
- }
86
-
87
- /**
88
- * @name addDays
89
- * @category Day Helpers
90
- * @summary Add the specified number of days to the given date.
91
- *
92
- * @description
93
- * Add the specified number of days to the given date.
94
- *
95
- * @param {Date|Number} date - the date to be changed
96
- * @param {Number} amount - the amount of days to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
97
- * @returns {Date} - the new date with the days added
98
- * @throws {TypeError} - 2 arguments required
99
- *
100
- * @example
101
- * // Add 10 days to 1 September 2014:
102
- * const result = addDays(new Date(2014, 8, 1), 10)
103
- * //=> Thu Sep 11 2014 00:00:00
104
- */
105
- function addDays(dirtyDate, dirtyAmount) {
106
- requiredArgs(2, arguments);
107
- var date = toDate(dirtyDate);
108
- var amount = toInteger(dirtyAmount);
109
- if (isNaN(amount)) {
110
- return new Date(NaN);
111
- }
112
- if (!amount) {
113
- // If 0 days, no-op to avoid changing times in the hour before end of DST
114
- return date;
115
- }
116
- date.setDate(date.getDate() + amount);
117
- return date;
118
- }
119
-
120
- /**
121
- * @name addMonths
122
- * @category Month Helpers
123
- * @summary Add the specified number of months to the given date.
124
- *
125
- * @description
126
- * Add the specified number of months to the given date.
127
- *
128
- * @param {Date|Number} date - the date to be changed
129
- * @param {Number} amount - the amount of months to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
130
- * @returns {Date} the new date with the months added
131
- * @throws {TypeError} 2 arguments required
132
- *
133
- * @example
134
- * // Add 5 months to 1 September 2014:
135
- * const result = addMonths(new Date(2014, 8, 1), 5)
136
- * //=> Sun Feb 01 2015 00:00:00
137
- */
138
- function addMonths(dirtyDate, dirtyAmount) {
139
- requiredArgs(2, arguments);
140
- var date = toDate(dirtyDate);
141
- var amount = toInteger(dirtyAmount);
142
- if (isNaN(amount)) {
143
- return new Date(NaN);
144
- }
145
- if (!amount) {
146
- // If 0 months, no-op to avoid changing times in the hour before end of DST
147
- return date;
148
- }
149
- var dayOfMonth = date.getDate();
150
-
151
- // The JS Date object supports date math by accepting out-of-bounds values for
152
- // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
153
- // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
154
- // want except that dates will wrap around the end of a month, meaning that
155
- // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
156
- // we'll default to the end of the desired month by adding 1 to the desired
157
- // month and using a date of 0 to back up one day to the end of the desired
158
- // month.
159
- var endOfDesiredMonth = new Date(date.getTime());
160
- endOfDesiredMonth.setMonth(date.getMonth() + amount + 1, 0);
161
- var daysInMonth = endOfDesiredMonth.getDate();
162
- if (dayOfMonth >= daysInMonth) {
163
- // If we're already at the end of the month, then this is the correct date
164
- // and we're done.
165
- return endOfDesiredMonth;
166
- } else {
167
- // Otherwise, we now know that setting the original day-of-month value won't
168
- // cause an overflow, so set the desired day-of-month. Note that we can't
169
- // just set the date of `endOfDesiredMonth` because that object may have had
170
- // its time changed in the unusual case where where a DST transition was on
171
- // the last day of the month and its local time was in the hour skipped or
172
- // repeated next to a DST transition. So we use `date` instead which is
173
- // guaranteed to still have the original time.
174
- date.setFullYear(endOfDesiredMonth.getFullYear(), endOfDesiredMonth.getMonth(), dayOfMonth);
175
- return date;
176
- }
177
- }
178
-
179
- /**
180
- * @name addMilliseconds
181
- * @category Millisecond Helpers
182
- * @summary Add the specified number of milliseconds to the given date.
183
- *
184
- * @description
185
- * Add the specified number of milliseconds to the given date.
186
- *
187
- * @param {Date|Number} date - the date to be changed
188
- * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
189
- * @returns {Date} the new date with the milliseconds added
190
- * @throws {TypeError} 2 arguments required
191
- *
192
- * @example
193
- * // Add 750 milliseconds to 10 July 2014 12:45:30.000:
194
- * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
195
- * //=> Thu Jul 10 2014 12:45:30.750
196
- */
197
- function addMilliseconds(dirtyDate, dirtyAmount) {
198
- requiredArgs(2, arguments);
199
- var timestamp = toDate(dirtyDate).getTime();
200
- var amount = toInteger(dirtyAmount);
201
- return new Date(timestamp + amount);
202
- }
203
-
204
- var defaultOptions = {};
205
- function getDefaultOptions() {
206
- return defaultOptions;
207
- }
208
-
209
- /**
210
- * @name startOfWeek
211
- * @category Week Helpers
212
- * @summary Return the start of a week for the given date.
213
- *
214
- * @description
215
- * Return the start of a week for the given date.
216
- * The result will be in the local timezone.
217
- *
218
- * @param {Date|Number} date - the original date
219
- * @param {Object} [options] - an object with options.
220
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
221
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
222
- * @returns {Date} the start of a week
223
- * @throws {TypeError} 1 argument required
224
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
225
- *
226
- * @example
227
- * // The start of a week for 2 September 2014 11:55:00:
228
- * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
229
- * //=> Sun Aug 31 2014 00:00:00
230
- *
231
- * @example
232
- * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
233
- * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
234
- * //=> Mon Sep 01 2014 00:00:00
235
- */
236
- function startOfWeek(dirtyDate, options) {
237
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
238
- requiredArgs(1, arguments);
239
- var defaultOptions = getDefaultOptions();
240
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
241
-
242
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
243
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
244
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
245
- }
246
- var date = toDate(dirtyDate);
247
- var day = date.getDay();
248
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
249
- date.setDate(date.getDate() - diff);
250
- date.setHours(0, 0, 0, 0);
251
- return date;
252
- }
253
-
254
- /**
255
- * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
256
- * They usually appear for dates that denote time before the timezones were introduced
257
- * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
258
- * and GMT+01:00:00 after that date)
259
- *
260
- * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
261
- * which would lead to incorrect calculations.
262
- *
263
- * This function returns the timezone offset in milliseconds that takes seconds in account.
264
- */
265
- function getTimezoneOffsetInMilliseconds(date) {
266
- var utcDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()));
267
- utcDate.setUTCFullYear(date.getFullYear());
268
- return date.getTime() - utcDate.getTime();
269
- }
270
-
271
- /**
272
- * @name startOfDay
273
- * @category Day Helpers
274
- * @summary Return the start of a day for the given date.
275
- *
276
- * @description
277
- * Return the start of a day for the given date.
278
- * The result will be in the local timezone.
279
- *
280
- * @param {Date|Number} date - the original date
281
- * @returns {Date} the start of a day
282
- * @throws {TypeError} 1 argument required
283
- *
284
- * @example
285
- * // The start of a day for 2 September 2014 11:55:00:
286
- * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
287
- * //=> Tue Sep 02 2014 00:00:00
288
- */
289
- function startOfDay(dirtyDate) {
290
- requiredArgs(1, arguments);
291
- var date = toDate(dirtyDate);
292
- date.setHours(0, 0, 0, 0);
293
- return date;
294
- }
295
-
296
- /**
297
- * @name addWeeks
298
- * @category Week Helpers
299
- * @summary Add the specified number of weeks to the given date.
300
- *
301
- * @description
302
- * Add the specified number of week to the given date.
303
- *
304
- * @param {Date|Number} date - the date to be changed
305
- * @param {Number} amount - the amount of weeks to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
306
- * @returns {Date} the new date with the weeks added
307
- * @throws {TypeError} 2 arguments required
308
- *
309
- * @example
310
- * // Add 4 weeks to 1 September 2014:
311
- * const result = addWeeks(new Date(2014, 8, 1), 4)
312
- * //=> Mon Sep 29 2014 00:00:00
313
- */
314
- function addWeeks(dirtyDate, dirtyAmount) {
315
- requiredArgs(2, arguments);
316
- var amount = toInteger(dirtyAmount);
317
- var days = amount * 7;
318
- return addDays(dirtyDate, days);
319
- }
320
-
321
- /**
322
- * Days in 1 week.
323
- *
324
- * @name daysInWeek
325
- * @constant
326
- * @type {number}
327
- * @default
328
- */
329
-
330
- /**
331
- * Milliseconds in 1 minute
332
- *
333
- * @name millisecondsInMinute
334
- * @constant
335
- * @type {number}
336
- * @default
337
- */
338
- var millisecondsInMinute = 60000;
339
-
340
- /**
341
- * Milliseconds in 1 hour
342
- *
343
- * @name millisecondsInHour
344
- * @constant
345
- * @type {number}
346
- * @default
347
- */
348
- var millisecondsInHour = 3600000;
349
-
350
- /**
351
- * @name isSameDay
352
- * @category Day Helpers
353
- * @summary Are the given dates in the same day (and year and month)?
354
- *
355
- * @description
356
- * Are the given dates in the same day (and year and month)?
357
- *
358
- * @param {Date|Number} dateLeft - the first date to check
359
- * @param {Date|Number} dateRight - the second date to check
360
- * @returns {Boolean} the dates are in the same day (and year and month)
361
- * @throws {TypeError} 2 arguments required
362
- *
363
- * @example
364
- * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
365
- * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
366
- * //=> true
367
- *
368
- * @example
369
- * // Are 4 September and 4 October in the same day?
370
- * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
371
- * //=> false
372
- *
373
- * @example
374
- * // Are 4 September, 2014 and 4 September, 2015 in the same day?
375
- * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
376
- * //=> false
377
- */
378
- function isSameDay(dirtyDateLeft, dirtyDateRight) {
379
- requiredArgs(2, arguments);
380
- var dateLeftStartOfDay = startOfDay(dirtyDateLeft);
381
- var dateRightStartOfDay = startOfDay(dirtyDateRight);
382
- return dateLeftStartOfDay.getTime() === dateRightStartOfDay.getTime();
383
- }
384
-
385
- /**
386
- * @name isDate
387
- * @category Common Helpers
388
- * @summary Is the given value a date?
389
- *
390
- * @description
391
- * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
392
- *
393
- * @param {*} value - the value to check
394
- * @returns {boolean} true if the given value is a date
395
- * @throws {TypeError} 1 arguments required
396
- *
397
- * @example
398
- * // For a valid date:
399
- * const result = isDate(new Date())
400
- * //=> true
401
- *
402
- * @example
403
- * // For an invalid date:
404
- * const result = isDate(new Date(NaN))
405
- * //=> true
406
- *
407
- * @example
408
- * // For some value:
409
- * const result = isDate('2014-02-31')
410
- * //=> false
411
- *
412
- * @example
413
- * // For an object:
414
- * const result = isDate({})
415
- * //=> false
416
- */
417
- function isDate(value) {
418
- requiredArgs(1, arguments);
419
- return value instanceof Date || _typeof(value) === 'object' && Object.prototype.toString.call(value) === '[object Date]';
420
- }
421
-
422
- /**
423
- * @name isValid
424
- * @category Common Helpers
425
- * @summary Is the given date valid?
426
- *
427
- * @description
428
- * Returns false if argument is Invalid Date and true otherwise.
429
- * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}
430
- * Invalid Date is a Date, whose time value is NaN.
431
- *
432
- * Time value of Date: http://es5.github.io/#x15.9.1.1
433
- *
434
- * @param {*} date - the date to check
435
- * @returns {Boolean} the date is valid
436
- * @throws {TypeError} 1 argument required
437
- *
438
- * @example
439
- * // For the valid date:
440
- * const result = isValid(new Date(2014, 1, 31))
441
- * //=> true
442
- *
443
- * @example
444
- * // For the value, convertable into a date:
445
- * const result = isValid(1393804800000)
446
- * //=> true
447
- *
448
- * @example
449
- * // For the invalid date:
450
- * const result = isValid(new Date(''))
451
- * //=> false
452
- */
453
- function isValid(dirtyDate) {
454
- requiredArgs(1, arguments);
455
- if (!isDate(dirtyDate) && typeof dirtyDate !== 'number') {
456
- return false;
457
- }
458
- var date = toDate(dirtyDate);
459
- return !isNaN(Number(date));
460
- }
461
-
462
- /**
463
- * @name endOfMonth
464
- * @category Month Helpers
465
- * @summary Return the end of a month for the given date.
466
- *
467
- * @description
468
- * Return the end of a month for the given date.
469
- * The result will be in the local timezone.
470
- *
471
- * @param {Date|Number} date - the original date
472
- * @returns {Date} the end of a month
473
- * @throws {TypeError} 1 argument required
474
- *
475
- * @example
476
- * // The end of a month for 2 September 2014 11:55:00:
477
- * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
478
- * //=> Tue Sep 30 2014 23:59:59.999
479
- */
480
- function endOfMonth(dirtyDate) {
481
- requiredArgs(1, arguments);
482
- var date = toDate(dirtyDate);
483
- var month = date.getMonth();
484
- date.setFullYear(date.getFullYear(), month + 1, 0);
485
- date.setHours(23, 59, 59, 999);
486
- return date;
487
- }
488
-
489
- /**
490
- * @name eachDayOfInterval
491
- * @category Interval Helpers
492
- * @summary Return the array of dates within the specified time interval.
493
- *
494
- * @description
495
- * Return the array of dates within the specified time interval.
496
- *
497
- * @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
498
- * @param {Object} [options] - an object with options.
499
- * @param {Number} [options.step=1] - the step to increment by. The value should be more than 1.
500
- * @returns {Date[]} the array with starts of days from the day of the interval start to the day of the interval end
501
- * @throws {TypeError} 1 argument required
502
- * @throws {RangeError} `options.step` must be a number greater than 1
503
- * @throws {RangeError} The start of an interval cannot be after its end
504
- * @throws {RangeError} Date in interval cannot be `Invalid Date`
505
- *
506
- * @example
507
- * // Each day between 6 October 2014 and 10 October 2014:
508
- * const result = eachDayOfInterval({
509
- * start: new Date(2014, 9, 6),
510
- * end: new Date(2014, 9, 10)
511
- * })
512
- * //=> [
513
- * // Mon Oct 06 2014 00:00:00,
514
- * // Tue Oct 07 2014 00:00:00,
515
- * // Wed Oct 08 2014 00:00:00,
516
- * // Thu Oct 09 2014 00:00:00,
517
- * // Fri Oct 10 2014 00:00:00
518
- * // ]
519
- */
520
- function eachDayOfInterval(dirtyInterval, options) {
521
- var _options$step;
522
- requiredArgs(1, arguments);
523
- var interval = dirtyInterval || {};
524
- var startDate = toDate(interval.start);
525
- var endDate = toDate(interval.end);
526
- var endTime = endDate.getTime();
527
-
528
- // Throw an exception if start date is after end date or if any date is `Invalid Date`
529
- if (!(startDate.getTime() <= endTime)) {
530
- throw new RangeError('Invalid interval');
531
- }
532
- var dates = [];
533
- var currentDate = startDate;
534
- currentDate.setHours(0, 0, 0, 0);
535
- var step = Number((_options$step = options === null || options === void 0 ? void 0 : options.step) !== null && _options$step !== void 0 ? _options$step : 1);
536
- if (step < 1 || isNaN(step)) throw new RangeError('`options.step` must be a number greater than 1');
537
- while (currentDate.getTime() <= endTime) {
538
- dates.push(toDate(currentDate));
539
- currentDate.setDate(currentDate.getDate() + step);
540
- currentDate.setHours(0, 0, 0, 0);
541
- }
542
- return dates;
543
- }
544
-
545
- /**
546
- * @name eachMonthOfInterval
547
- * @category Interval Helpers
548
- * @summary Return the array of months within the specified time interval.
549
- *
550
- * @description
551
- * Return the array of months within the specified time interval.
552
- *
553
- * @param {Interval} interval - the interval. See [Interval]{@link https://date-fns.org/docs/Interval}
554
- * @returns {Date[]} the array with starts of months from the month of the interval start to the month of the interval end
555
- * @throws {TypeError} 1 argument required
556
- * @throws {RangeError} The start of an interval cannot be after its end
557
- * @throws {RangeError} Date in interval cannot be `Invalid Date`
558
- *
559
- * @example
560
- * // Each month between 6 February 2014 and 10 August 2014:
561
- * const result = eachMonthOfInterval({
562
- * start: new Date(2014, 1, 6),
563
- * end: new Date(2014, 7, 10)
564
- * })
565
- * //=> [
566
- * // Sat Feb 01 2014 00:00:00,
567
- * // Sat Mar 01 2014 00:00:00,
568
- * // Tue Apr 01 2014 00:00:00,
569
- * // Thu May 01 2014 00:00:00,
570
- * // Sun Jun 01 2014 00:00:00,
571
- * // Tue Jul 01 2014 00:00:00,
572
- * // Fri Aug 01 2014 00:00:00
573
- * // ]
574
- */
575
- function eachMonthOfInterval(dirtyInterval) {
576
- requiredArgs(1, arguments);
577
- var interval = dirtyInterval || {};
578
- var startDate = toDate(interval.start);
579
- var endDate = toDate(interval.end);
580
- var endTime = endDate.getTime();
581
- var dates = [];
582
-
583
- // Throw an exception if start date is after end date or if any date is `Invalid Date`
584
- if (!(startDate.getTime() <= endTime)) {
585
- throw new RangeError('Invalid interval');
586
- }
587
- var currentDate = startDate;
588
- currentDate.setHours(0, 0, 0, 0);
589
- currentDate.setDate(1);
590
- while (currentDate.getTime() <= endTime) {
591
- dates.push(toDate(currentDate));
592
- currentDate.setMonth(currentDate.getMonth() + 1);
593
- }
594
- return dates;
595
- }
596
-
597
- /**
598
- * @name startOfMonth
599
- * @category Month Helpers
600
- * @summary Return the start of a month for the given date.
601
- *
602
- * @description
603
- * Return the start of a month for the given date.
604
- * The result will be in the local timezone.
605
- *
606
- * @param {Date|Number} date - the original date
607
- * @returns {Date} the start of a month
608
- * @throws {TypeError} 1 argument required
609
- *
610
- * @example
611
- * // The start of a month for 2 September 2014 11:55:00:
612
- * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
613
- * //=> Mon Sep 01 2014 00:00:00
614
- */
615
- function startOfMonth(dirtyDate) {
616
- requiredArgs(1, arguments);
617
- var date = toDate(dirtyDate);
618
- date.setDate(1);
619
- date.setHours(0, 0, 0, 0);
620
- return date;
621
- }
622
-
623
- /**
624
- * @name startOfYear
625
- * @category Year Helpers
626
- * @summary Return the start of a year for the given date.
627
- *
628
- * @description
629
- * Return the start of a year for the given date.
630
- * The result will be in the local timezone.
631
- *
632
- * @param {Date|Number} date - the original date
633
- * @returns {Date} the start of a year
634
- * @throws {TypeError} 1 argument required
635
- *
636
- * @example
637
- * // The start of a year for 2 September 2014 11:55:00:
638
- * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))
639
- * //=> Wed Jan 01 2014 00:00:00
640
- */
641
- function startOfYear(dirtyDate) {
642
- requiredArgs(1, arguments);
643
- var cleanDate = toDate(dirtyDate);
644
- var date = new Date(0);
645
- date.setFullYear(cleanDate.getFullYear(), 0, 1);
646
- date.setHours(0, 0, 0, 0);
647
- return date;
648
- }
649
-
650
- /**
651
- * @name endOfWeek
652
- * @category Week Helpers
653
- * @summary Return the end of a week for the given date.
654
- *
655
- * @description
656
- * Return the end of a week for the given date.
657
- * The result will be in the local timezone.
658
- *
659
- * @param {Date|Number} date - the original date
660
- * @param {Object} [options] - an object with options.
661
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
662
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
663
- * @returns {Date} the end of a week
664
- * @throws {TypeError} 1 argument required
665
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
666
- *
667
- * @example
668
- * // The end of a week for 2 September 2014 11:55:00:
669
- * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0))
670
- * //=> Sat Sep 06 2014 23:59:59.999
671
- *
672
- * @example
673
- * // If the week starts on Monday, the end of the week for 2 September 2014 11:55:00:
674
- * const result = endOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
675
- * //=> Sun Sep 07 2014 23:59:59.999
676
- */
677
- function endOfWeek(dirtyDate, options) {
678
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
679
- requiredArgs(1, arguments);
680
- var defaultOptions = getDefaultOptions();
681
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
682
-
683
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
684
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
685
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
686
- }
687
- var date = toDate(dirtyDate);
688
- var day = date.getDay();
689
- var diff = (day < weekStartsOn ? -7 : 0) + 6 - (day - weekStartsOn);
690
- date.setDate(date.getDate() + diff);
691
- date.setHours(23, 59, 59, 999);
692
- return date;
693
- }
694
-
695
- /**
696
- * @name subMilliseconds
697
- * @category Millisecond Helpers
698
- * @summary Subtract the specified number of milliseconds from the given date.
699
- *
700
- * @description
701
- * Subtract the specified number of milliseconds from the given date.
702
- *
703
- * @param {Date|Number} date - the date to be changed
704
- * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
705
- * @returns {Date} the new date with the milliseconds subtracted
706
- * @throws {TypeError} 2 arguments required
707
- *
708
- * @example
709
- * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:
710
- * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)
711
- * //=> Thu Jul 10 2014 12:45:29.250
712
- */
713
- function subMilliseconds(dirtyDate, dirtyAmount) {
714
- requiredArgs(2, arguments);
715
- var amount = toInteger(dirtyAmount);
716
- return addMilliseconds(dirtyDate, -amount);
717
- }
718
-
719
- var MILLISECONDS_IN_DAY = 86400000;
720
- function getUTCDayOfYear(dirtyDate) {
721
- requiredArgs(1, arguments);
722
- var date = toDate(dirtyDate);
723
- var timestamp = date.getTime();
724
- date.setUTCMonth(0, 1);
725
- date.setUTCHours(0, 0, 0, 0);
726
- var startOfYearTimestamp = date.getTime();
727
- var difference = timestamp - startOfYearTimestamp;
728
- return Math.floor(difference / MILLISECONDS_IN_DAY) + 1;
729
- }
730
-
731
- function startOfUTCISOWeek(dirtyDate) {
732
- requiredArgs(1, arguments);
733
- var weekStartsOn = 1;
734
- var date = toDate(dirtyDate);
735
- var day = date.getUTCDay();
736
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
737
- date.setUTCDate(date.getUTCDate() - diff);
738
- date.setUTCHours(0, 0, 0, 0);
739
- return date;
740
- }
741
-
742
- function getUTCISOWeekYear(dirtyDate) {
743
- requiredArgs(1, arguments);
744
- var date = toDate(dirtyDate);
745
- var year = date.getUTCFullYear();
746
- var fourthOfJanuaryOfNextYear = new Date(0);
747
- fourthOfJanuaryOfNextYear.setUTCFullYear(year + 1, 0, 4);
748
- fourthOfJanuaryOfNextYear.setUTCHours(0, 0, 0, 0);
749
- var startOfNextYear = startOfUTCISOWeek(fourthOfJanuaryOfNextYear);
750
- var fourthOfJanuaryOfThisYear = new Date(0);
751
- fourthOfJanuaryOfThisYear.setUTCFullYear(year, 0, 4);
752
- fourthOfJanuaryOfThisYear.setUTCHours(0, 0, 0, 0);
753
- var startOfThisYear = startOfUTCISOWeek(fourthOfJanuaryOfThisYear);
754
- if (date.getTime() >= startOfNextYear.getTime()) {
755
- return year + 1;
756
- } else if (date.getTime() >= startOfThisYear.getTime()) {
757
- return year;
758
- } else {
759
- return year - 1;
760
- }
761
- }
762
-
763
- function startOfUTCISOWeekYear(dirtyDate) {
764
- requiredArgs(1, arguments);
765
- var year = getUTCISOWeekYear(dirtyDate);
766
- var fourthOfJanuary = new Date(0);
767
- fourthOfJanuary.setUTCFullYear(year, 0, 4);
768
- fourthOfJanuary.setUTCHours(0, 0, 0, 0);
769
- var date = startOfUTCISOWeek(fourthOfJanuary);
770
- return date;
771
- }
772
-
773
- var MILLISECONDS_IN_WEEK$1 = 604800000;
774
- function getUTCISOWeek(dirtyDate) {
775
- requiredArgs(1, arguments);
776
- var date = toDate(dirtyDate);
777
- var diff = startOfUTCISOWeek(date).getTime() - startOfUTCISOWeekYear(date).getTime();
778
-
779
- // Round the number of days to the nearest integer
780
- // because the number of milliseconds in a week is not constant
781
- // (e.g. it's different in the week of the daylight saving time clock shift)
782
- return Math.round(diff / MILLISECONDS_IN_WEEK$1) + 1;
783
- }
784
-
785
- function startOfUTCWeek(dirtyDate, options) {
786
- var _ref, _ref2, _ref3, _options$weekStartsOn, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
787
- requiredArgs(1, arguments);
788
- var defaultOptions = getDefaultOptions();
789
- var weekStartsOn = toInteger((_ref = (_ref2 = (_ref3 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.weekStartsOn) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.weekStartsOn) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.weekStartsOn) !== null && _ref !== void 0 ? _ref : 0);
790
-
791
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
792
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
793
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
794
- }
795
- var date = toDate(dirtyDate);
796
- var day = date.getUTCDay();
797
- var diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
798
- date.setUTCDate(date.getUTCDate() - diff);
799
- date.setUTCHours(0, 0, 0, 0);
800
- return date;
801
- }
802
-
803
- function getUTCWeekYear(dirtyDate, options) {
804
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
805
- requiredArgs(1, arguments);
806
- var date = toDate(dirtyDate);
807
- var year = date.getUTCFullYear();
808
- var defaultOptions = getDefaultOptions();
809
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
810
-
811
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
812
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
813
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
814
- }
815
- var firstWeekOfNextYear = new Date(0);
816
- firstWeekOfNextYear.setUTCFullYear(year + 1, 0, firstWeekContainsDate);
817
- firstWeekOfNextYear.setUTCHours(0, 0, 0, 0);
818
- var startOfNextYear = startOfUTCWeek(firstWeekOfNextYear, options);
819
- var firstWeekOfThisYear = new Date(0);
820
- firstWeekOfThisYear.setUTCFullYear(year, 0, firstWeekContainsDate);
821
- firstWeekOfThisYear.setUTCHours(0, 0, 0, 0);
822
- var startOfThisYear = startOfUTCWeek(firstWeekOfThisYear, options);
823
- if (date.getTime() >= startOfNextYear.getTime()) {
824
- return year + 1;
825
- } else if (date.getTime() >= startOfThisYear.getTime()) {
826
- return year;
827
- } else {
828
- return year - 1;
829
- }
830
- }
831
-
832
- function startOfUTCWeekYear(dirtyDate, options) {
833
- var _ref, _ref2, _ref3, _options$firstWeekCon, _options$locale, _options$locale$optio, _defaultOptions$local, _defaultOptions$local2;
834
- requiredArgs(1, arguments);
835
- var defaultOptions = getDefaultOptions();
836
- var firstWeekContainsDate = toInteger((_ref = (_ref2 = (_ref3 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale = options.locale) === null || _options$locale === void 0 ? void 0 : (_options$locale$optio = _options$locale.options) === null || _options$locale$optio === void 0 ? void 0 : _options$locale$optio.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : defaultOptions.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref !== void 0 ? _ref : 1);
837
- var year = getUTCWeekYear(dirtyDate, options);
838
- var firstWeek = new Date(0);
839
- firstWeek.setUTCFullYear(year, 0, firstWeekContainsDate);
840
- firstWeek.setUTCHours(0, 0, 0, 0);
841
- var date = startOfUTCWeek(firstWeek, options);
842
- return date;
843
- }
844
-
845
- var MILLISECONDS_IN_WEEK = 604800000;
846
- function getUTCWeek(dirtyDate, options) {
847
- requiredArgs(1, arguments);
848
- var date = toDate(dirtyDate);
849
- var diff = startOfUTCWeek(date, options).getTime() - startOfUTCWeekYear(date, options).getTime();
850
-
851
- // Round the number of days to the nearest integer
852
- // because the number of milliseconds in a week is not constant
853
- // (e.g. it's different in the week of the daylight saving time clock shift)
854
- return Math.round(diff / MILLISECONDS_IN_WEEK) + 1;
855
- }
856
-
857
- function addLeadingZeros(number, targetLength) {
858
- var sign = number < 0 ? '-' : '';
859
- var output = Math.abs(number).toString();
860
- while (output.length < targetLength) {
861
- output = '0' + output;
862
- }
863
- return sign + output;
864
- }
865
-
866
- /*
867
- * | | Unit | | Unit |
868
- * |-----|--------------------------------|-----|--------------------------------|
869
- * | a | AM, PM | A* | |
870
- * | d | Day of month | D | |
871
- * | h | Hour [1-12] | H | Hour [0-23] |
872
- * | m | Minute | M | Month |
873
- * | s | Second | S | Fraction of second |
874
- * | y | Year (abs) | Y | |
875
- *
876
- * Letters marked by * are not implemented but reserved by Unicode standard.
877
- */
878
- var formatters$2 = {
879
- // Year
880
- y: function y(date, token) {
881
- // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
882
- // | Year | y | yy | yyy | yyyy | yyyyy |
883
- // |----------|-------|----|-------|-------|-------|
884
- // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
885
- // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
886
- // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
887
- // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
888
- // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
889
-
890
- var signedYear = date.getUTCFullYear();
891
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
892
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
893
- return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);
894
- },
895
- // Month
896
- M: function M(date, token) {
897
- var month = date.getUTCMonth();
898
- return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);
899
- },
900
- // Day of the month
901
- d: function d(date, token) {
902
- return addLeadingZeros(date.getUTCDate(), token.length);
903
- },
904
- // AM or PM
905
- a: function a(date, token) {
906
- var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';
907
- switch (token) {
908
- case 'a':
909
- case 'aa':
910
- return dayPeriodEnumValue.toUpperCase();
911
- case 'aaa':
912
- return dayPeriodEnumValue;
913
- case 'aaaaa':
914
- return dayPeriodEnumValue[0];
915
- case 'aaaa':
916
- default:
917
- return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';
918
- }
919
- },
920
- // Hour [1-12]
921
- h: function h(date, token) {
922
- return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);
923
- },
924
- // Hour [0-23]
925
- H: function H(date, token) {
926
- return addLeadingZeros(date.getUTCHours(), token.length);
927
- },
928
- // Minute
929
- m: function m(date, token) {
930
- return addLeadingZeros(date.getUTCMinutes(), token.length);
931
- },
932
- // Second
933
- s: function s(date, token) {
934
- return addLeadingZeros(date.getUTCSeconds(), token.length);
935
- },
936
- // Fraction of second
937
- S: function S(date, token) {
938
- var numberOfDigits = token.length;
939
- var milliseconds = date.getUTCMilliseconds();
940
- var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));
941
- return addLeadingZeros(fractionalSeconds, token.length);
942
- }
943
- };
944
- const formatters$3 = formatters$2;
945
-
946
- var dayPeriodEnum = {
947
- am: 'am',
948
- pm: 'pm',
949
- midnight: 'midnight',
950
- noon: 'noon',
951
- morning: 'morning',
952
- afternoon: 'afternoon',
953
- evening: 'evening',
954
- night: 'night'
955
- };
956
- /*
957
- * | | Unit | | Unit |
958
- * |-----|--------------------------------|-----|--------------------------------|
959
- * | a | AM, PM | A* | Milliseconds in day |
960
- * | b | AM, PM, noon, midnight | B | Flexible day period |
961
- * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
962
- * | d | Day of month | D | Day of year |
963
- * | e | Local day of week | E | Day of week |
964
- * | f | | F* | Day of week in month |
965
- * | g* | Modified Julian day | G | Era |
966
- * | h | Hour [1-12] | H | Hour [0-23] |
967
- * | i! | ISO day of week | I! | ISO week of year |
968
- * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
969
- * | k | Hour [1-24] | K | Hour [0-11] |
970
- * | l* | (deprecated) | L | Stand-alone month |
971
- * | m | Minute | M | Month |
972
- * | n | | N | |
973
- * | o! | Ordinal number modifier | O | Timezone (GMT) |
974
- * | p! | Long localized time | P! | Long localized date |
975
- * | q | Stand-alone quarter | Q | Quarter |
976
- * | r* | Related Gregorian year | R! | ISO week-numbering year |
977
- * | s | Second | S | Fraction of second |
978
- * | t! | Seconds timestamp | T! | Milliseconds timestamp |
979
- * | u | Extended year | U* | Cyclic year |
980
- * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
981
- * | w | Local week of year | W* | Week of month |
982
- * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
983
- * | y | Year (abs) | Y | Local week-numbering year |
984
- * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
985
- *
986
- * Letters marked by * are not implemented but reserved by Unicode standard.
987
- *
988
- * Letters marked by ! are non-standard, but implemented by date-fns:
989
- * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
990
- * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
991
- * i.e. 7 for Sunday, 1 for Monday, etc.
992
- * - `I` is ISO week of year, as opposed to `w` which is local week of year.
993
- * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
994
- * `R` is supposed to be used in conjunction with `I` and `i`
995
- * for universal ISO week-numbering date, whereas
996
- * `Y` is supposed to be used in conjunction with `w` and `e`
997
- * for week-numbering date specific to the locale.
998
- * - `P` is long localized date format
999
- * - `p` is long localized time format
1000
- */
1001
-
1002
- var formatters = {
1003
- // Era
1004
- G: function G(date, token, localize) {
1005
- var era = date.getUTCFullYear() > 0 ? 1 : 0;
1006
- switch (token) {
1007
- // AD, BC
1008
- case 'G':
1009
- case 'GG':
1010
- case 'GGG':
1011
- return localize.era(era, {
1012
- width: 'abbreviated'
1013
- });
1014
- // A, B
1015
- case 'GGGGG':
1016
- return localize.era(era, {
1017
- width: 'narrow'
1018
- });
1019
- // Anno Domini, Before Christ
1020
- case 'GGGG':
1021
- default:
1022
- return localize.era(era, {
1023
- width: 'wide'
1024
- });
1025
- }
1026
- },
1027
- // Year
1028
- y: function y(date, token, localize) {
1029
- // Ordinal number
1030
- if (token === 'yo') {
1031
- var signedYear = date.getUTCFullYear();
1032
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
1033
- var year = signedYear > 0 ? signedYear : 1 - signedYear;
1034
- return localize.ordinalNumber(year, {
1035
- unit: 'year'
1036
- });
1037
- }
1038
- return formatters$3.y(date, token);
1039
- },
1040
- // Local week-numbering year
1041
- Y: function Y(date, token, localize, options) {
1042
- var signedWeekYear = getUTCWeekYear(date, options);
1043
- // Returns 1 for 1 BC (which is year 0 in JavaScript)
1044
- var weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
1045
-
1046
- // Two digit year
1047
- if (token === 'YY') {
1048
- var twoDigitYear = weekYear % 100;
1049
- return addLeadingZeros(twoDigitYear, 2);
1050
- }
1051
-
1052
- // Ordinal number
1053
- if (token === 'Yo') {
1054
- return localize.ordinalNumber(weekYear, {
1055
- unit: 'year'
1056
- });
1057
- }
1058
-
1059
- // Padding
1060
- return addLeadingZeros(weekYear, token.length);
1061
- },
1062
- // ISO week-numbering year
1063
- R: function R(date, token) {
1064
- var isoWeekYear = getUTCISOWeekYear(date);
1065
-
1066
- // Padding
1067
- return addLeadingZeros(isoWeekYear, token.length);
1068
- },
1069
- // Extended year. This is a single number designating the year of this calendar system.
1070
- // The main difference between `y` and `u` localizers are B.C. years:
1071
- // | Year | `y` | `u` |
1072
- // |------|-----|-----|
1073
- // | AC 1 | 1 | 1 |
1074
- // | BC 1 | 1 | 0 |
1075
- // | BC 2 | 2 | -1 |
1076
- // Also `yy` always returns the last two digits of a year,
1077
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1078
- u: function u(date, token) {
1079
- var year = date.getUTCFullYear();
1080
- return addLeadingZeros(year, token.length);
1081
- },
1082
- // Quarter
1083
- Q: function Q(date, token, localize) {
1084
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1085
- switch (token) {
1086
- // 1, 2, 3, 4
1087
- case 'Q':
1088
- return String(quarter);
1089
- // 01, 02, 03, 04
1090
- case 'QQ':
1091
- return addLeadingZeros(quarter, 2);
1092
- // 1st, 2nd, 3rd, 4th
1093
- case 'Qo':
1094
- return localize.ordinalNumber(quarter, {
1095
- unit: 'quarter'
1096
- });
1097
- // Q1, Q2, Q3, Q4
1098
- case 'QQQ':
1099
- return localize.quarter(quarter, {
1100
- width: 'abbreviated',
1101
- context: 'formatting'
1102
- });
1103
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1104
- case 'QQQQQ':
1105
- return localize.quarter(quarter, {
1106
- width: 'narrow',
1107
- context: 'formatting'
1108
- });
1109
- // 1st quarter, 2nd quarter, ...
1110
- case 'QQQQ':
1111
- default:
1112
- return localize.quarter(quarter, {
1113
- width: 'wide',
1114
- context: 'formatting'
1115
- });
1116
- }
1117
- },
1118
- // Stand-alone quarter
1119
- q: function q(date, token, localize) {
1120
- var quarter = Math.ceil((date.getUTCMonth() + 1) / 3);
1121
- switch (token) {
1122
- // 1, 2, 3, 4
1123
- case 'q':
1124
- return String(quarter);
1125
- // 01, 02, 03, 04
1126
- case 'qq':
1127
- return addLeadingZeros(quarter, 2);
1128
- // 1st, 2nd, 3rd, 4th
1129
- case 'qo':
1130
- return localize.ordinalNumber(quarter, {
1131
- unit: 'quarter'
1132
- });
1133
- // Q1, Q2, Q3, Q4
1134
- case 'qqq':
1135
- return localize.quarter(quarter, {
1136
- width: 'abbreviated',
1137
- context: 'standalone'
1138
- });
1139
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1140
- case 'qqqqq':
1141
- return localize.quarter(quarter, {
1142
- width: 'narrow',
1143
- context: 'standalone'
1144
- });
1145
- // 1st quarter, 2nd quarter, ...
1146
- case 'qqqq':
1147
- default:
1148
- return localize.quarter(quarter, {
1149
- width: 'wide',
1150
- context: 'standalone'
1151
- });
1152
- }
1153
- },
1154
- // Month
1155
- M: function M(date, token, localize) {
1156
- var month = date.getUTCMonth();
1157
- switch (token) {
1158
- case 'M':
1159
- case 'MM':
1160
- return formatters$3.M(date, token);
1161
- // 1st, 2nd, ..., 12th
1162
- case 'Mo':
1163
- return localize.ordinalNumber(month + 1, {
1164
- unit: 'month'
1165
- });
1166
- // Jan, Feb, ..., Dec
1167
- case 'MMM':
1168
- return localize.month(month, {
1169
- width: 'abbreviated',
1170
- context: 'formatting'
1171
- });
1172
- // J, F, ..., D
1173
- case 'MMMMM':
1174
- return localize.month(month, {
1175
- width: 'narrow',
1176
- context: 'formatting'
1177
- });
1178
- // January, February, ..., December
1179
- case 'MMMM':
1180
- default:
1181
- return localize.month(month, {
1182
- width: 'wide',
1183
- context: 'formatting'
1184
- });
1185
- }
1186
- },
1187
- // Stand-alone month
1188
- L: function L(date, token, localize) {
1189
- var month = date.getUTCMonth();
1190
- switch (token) {
1191
- // 1, 2, ..., 12
1192
- case 'L':
1193
- return String(month + 1);
1194
- // 01, 02, ..., 12
1195
- case 'LL':
1196
- return addLeadingZeros(month + 1, 2);
1197
- // 1st, 2nd, ..., 12th
1198
- case 'Lo':
1199
- return localize.ordinalNumber(month + 1, {
1200
- unit: 'month'
1201
- });
1202
- // Jan, Feb, ..., Dec
1203
- case 'LLL':
1204
- return localize.month(month, {
1205
- width: 'abbreviated',
1206
- context: 'standalone'
1207
- });
1208
- // J, F, ..., D
1209
- case 'LLLLL':
1210
- return localize.month(month, {
1211
- width: 'narrow',
1212
- context: 'standalone'
1213
- });
1214
- // January, February, ..., December
1215
- case 'LLLL':
1216
- default:
1217
- return localize.month(month, {
1218
- width: 'wide',
1219
- context: 'standalone'
1220
- });
1221
- }
1222
- },
1223
- // Local week of year
1224
- w: function w(date, token, localize, options) {
1225
- var week = getUTCWeek(date, options);
1226
- if (token === 'wo') {
1227
- return localize.ordinalNumber(week, {
1228
- unit: 'week'
1229
- });
1230
- }
1231
- return addLeadingZeros(week, token.length);
1232
- },
1233
- // ISO week of year
1234
- I: function I(date, token, localize) {
1235
- var isoWeek = getUTCISOWeek(date);
1236
- if (token === 'Io') {
1237
- return localize.ordinalNumber(isoWeek, {
1238
- unit: 'week'
1239
- });
1240
- }
1241
- return addLeadingZeros(isoWeek, token.length);
1242
- },
1243
- // Day of the month
1244
- d: function d(date, token, localize) {
1245
- if (token === 'do') {
1246
- return localize.ordinalNumber(date.getUTCDate(), {
1247
- unit: 'date'
1248
- });
1249
- }
1250
- return formatters$3.d(date, token);
1251
- },
1252
- // Day of year
1253
- D: function D(date, token, localize) {
1254
- var dayOfYear = getUTCDayOfYear(date);
1255
- if (token === 'Do') {
1256
- return localize.ordinalNumber(dayOfYear, {
1257
- unit: 'dayOfYear'
1258
- });
1259
- }
1260
- return addLeadingZeros(dayOfYear, token.length);
1261
- },
1262
- // Day of week
1263
- E: function E(date, token, localize) {
1264
- var dayOfWeek = date.getUTCDay();
1265
- switch (token) {
1266
- // Tue
1267
- case 'E':
1268
- case 'EE':
1269
- case 'EEE':
1270
- return localize.day(dayOfWeek, {
1271
- width: 'abbreviated',
1272
- context: 'formatting'
1273
- });
1274
- // T
1275
- case 'EEEEE':
1276
- return localize.day(dayOfWeek, {
1277
- width: 'narrow',
1278
- context: 'formatting'
1279
- });
1280
- // Tu
1281
- case 'EEEEEE':
1282
- return localize.day(dayOfWeek, {
1283
- width: 'short',
1284
- context: 'formatting'
1285
- });
1286
- // Tuesday
1287
- case 'EEEE':
1288
- default:
1289
- return localize.day(dayOfWeek, {
1290
- width: 'wide',
1291
- context: 'formatting'
1292
- });
1293
- }
1294
- },
1295
- // Local day of week
1296
- e: function e(date, token, localize, options) {
1297
- var dayOfWeek = date.getUTCDay();
1298
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1299
- switch (token) {
1300
- // Numerical value (Nth day of week with current locale or weekStartsOn)
1301
- case 'e':
1302
- return String(localDayOfWeek);
1303
- // Padded numerical value
1304
- case 'ee':
1305
- return addLeadingZeros(localDayOfWeek, 2);
1306
- // 1st, 2nd, ..., 7th
1307
- case 'eo':
1308
- return localize.ordinalNumber(localDayOfWeek, {
1309
- unit: 'day'
1310
- });
1311
- case 'eee':
1312
- return localize.day(dayOfWeek, {
1313
- width: 'abbreviated',
1314
- context: 'formatting'
1315
- });
1316
- // T
1317
- case 'eeeee':
1318
- return localize.day(dayOfWeek, {
1319
- width: 'narrow',
1320
- context: 'formatting'
1321
- });
1322
- // Tu
1323
- case 'eeeeee':
1324
- return localize.day(dayOfWeek, {
1325
- width: 'short',
1326
- context: 'formatting'
1327
- });
1328
- // Tuesday
1329
- case 'eeee':
1330
- default:
1331
- return localize.day(dayOfWeek, {
1332
- width: 'wide',
1333
- context: 'formatting'
1334
- });
1335
- }
1336
- },
1337
- // Stand-alone local day of week
1338
- c: function c(date, token, localize, options) {
1339
- var dayOfWeek = date.getUTCDay();
1340
- var localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1341
- switch (token) {
1342
- // Numerical value (same as in `e`)
1343
- case 'c':
1344
- return String(localDayOfWeek);
1345
- // Padded numerical value
1346
- case 'cc':
1347
- return addLeadingZeros(localDayOfWeek, token.length);
1348
- // 1st, 2nd, ..., 7th
1349
- case 'co':
1350
- return localize.ordinalNumber(localDayOfWeek, {
1351
- unit: 'day'
1352
- });
1353
- case 'ccc':
1354
- return localize.day(dayOfWeek, {
1355
- width: 'abbreviated',
1356
- context: 'standalone'
1357
- });
1358
- // T
1359
- case 'ccccc':
1360
- return localize.day(dayOfWeek, {
1361
- width: 'narrow',
1362
- context: 'standalone'
1363
- });
1364
- // Tu
1365
- case 'cccccc':
1366
- return localize.day(dayOfWeek, {
1367
- width: 'short',
1368
- context: 'standalone'
1369
- });
1370
- // Tuesday
1371
- case 'cccc':
1372
- default:
1373
- return localize.day(dayOfWeek, {
1374
- width: 'wide',
1375
- context: 'standalone'
1376
- });
1377
- }
1378
- },
1379
- // ISO day of week
1380
- i: function i(date, token, localize) {
1381
- var dayOfWeek = date.getUTCDay();
1382
- var isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
1383
- switch (token) {
1384
- // 2
1385
- case 'i':
1386
- return String(isoDayOfWeek);
1387
- // 02
1388
- case 'ii':
1389
- return addLeadingZeros(isoDayOfWeek, token.length);
1390
- // 2nd
1391
- case 'io':
1392
- return localize.ordinalNumber(isoDayOfWeek, {
1393
- unit: 'day'
1394
- });
1395
- // Tue
1396
- case 'iii':
1397
- return localize.day(dayOfWeek, {
1398
- width: 'abbreviated',
1399
- context: 'formatting'
1400
- });
1401
- // T
1402
- case 'iiiii':
1403
- return localize.day(dayOfWeek, {
1404
- width: 'narrow',
1405
- context: 'formatting'
1406
- });
1407
- // Tu
1408
- case 'iiiiii':
1409
- return localize.day(dayOfWeek, {
1410
- width: 'short',
1411
- context: 'formatting'
1412
- });
1413
- // Tuesday
1414
- case 'iiii':
1415
- default:
1416
- return localize.day(dayOfWeek, {
1417
- width: 'wide',
1418
- context: 'formatting'
1419
- });
1420
- }
1421
- },
1422
- // AM or PM
1423
- a: function a(date, token, localize) {
1424
- var hours = date.getUTCHours();
1425
- var dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1426
- switch (token) {
1427
- case 'a':
1428
- case 'aa':
1429
- return localize.dayPeriod(dayPeriodEnumValue, {
1430
- width: 'abbreviated',
1431
- context: 'formatting'
1432
- });
1433
- case 'aaa':
1434
- return localize.dayPeriod(dayPeriodEnumValue, {
1435
- width: 'abbreviated',
1436
- context: 'formatting'
1437
- }).toLowerCase();
1438
- case 'aaaaa':
1439
- return localize.dayPeriod(dayPeriodEnumValue, {
1440
- width: 'narrow',
1441
- context: 'formatting'
1442
- });
1443
- case 'aaaa':
1444
- default:
1445
- return localize.dayPeriod(dayPeriodEnumValue, {
1446
- width: 'wide',
1447
- context: 'formatting'
1448
- });
1449
- }
1450
- },
1451
- // AM, PM, midnight, noon
1452
- b: function b(date, token, localize) {
1453
- var hours = date.getUTCHours();
1454
- var dayPeriodEnumValue;
1455
- if (hours === 12) {
1456
- dayPeriodEnumValue = dayPeriodEnum.noon;
1457
- } else if (hours === 0) {
1458
- dayPeriodEnumValue = dayPeriodEnum.midnight;
1459
- } else {
1460
- dayPeriodEnumValue = hours / 12 >= 1 ? 'pm' : 'am';
1461
- }
1462
- switch (token) {
1463
- case 'b':
1464
- case 'bb':
1465
- return localize.dayPeriod(dayPeriodEnumValue, {
1466
- width: 'abbreviated',
1467
- context: 'formatting'
1468
- });
1469
- case 'bbb':
1470
- return localize.dayPeriod(dayPeriodEnumValue, {
1471
- width: 'abbreviated',
1472
- context: 'formatting'
1473
- }).toLowerCase();
1474
- case 'bbbbb':
1475
- return localize.dayPeriod(dayPeriodEnumValue, {
1476
- width: 'narrow',
1477
- context: 'formatting'
1478
- });
1479
- case 'bbbb':
1480
- default:
1481
- return localize.dayPeriod(dayPeriodEnumValue, {
1482
- width: 'wide',
1483
- context: 'formatting'
1484
- });
1485
- }
1486
- },
1487
- // in the morning, in the afternoon, in the evening, at night
1488
- B: function B(date, token, localize) {
1489
- var hours = date.getUTCHours();
1490
- var dayPeriodEnumValue;
1491
- if (hours >= 17) {
1492
- dayPeriodEnumValue = dayPeriodEnum.evening;
1493
- } else if (hours >= 12) {
1494
- dayPeriodEnumValue = dayPeriodEnum.afternoon;
1495
- } else if (hours >= 4) {
1496
- dayPeriodEnumValue = dayPeriodEnum.morning;
1497
- } else {
1498
- dayPeriodEnumValue = dayPeriodEnum.night;
1499
- }
1500
- switch (token) {
1501
- case 'B':
1502
- case 'BB':
1503
- case 'BBB':
1504
- return localize.dayPeriod(dayPeriodEnumValue, {
1505
- width: 'abbreviated',
1506
- context: 'formatting'
1507
- });
1508
- case 'BBBBB':
1509
- return localize.dayPeriod(dayPeriodEnumValue, {
1510
- width: 'narrow',
1511
- context: 'formatting'
1512
- });
1513
- case 'BBBB':
1514
- default:
1515
- return localize.dayPeriod(dayPeriodEnumValue, {
1516
- width: 'wide',
1517
- context: 'formatting'
1518
- });
1519
- }
1520
- },
1521
- // Hour [1-12]
1522
- h: function h(date, token, localize) {
1523
- if (token === 'ho') {
1524
- var hours = date.getUTCHours() % 12;
1525
- if (hours === 0) hours = 12;
1526
- return localize.ordinalNumber(hours, {
1527
- unit: 'hour'
1528
- });
1529
- }
1530
- return formatters$3.h(date, token);
1531
- },
1532
- // Hour [0-23]
1533
- H: function H(date, token, localize) {
1534
- if (token === 'Ho') {
1535
- return localize.ordinalNumber(date.getUTCHours(), {
1536
- unit: 'hour'
1537
- });
1538
- }
1539
- return formatters$3.H(date, token);
1540
- },
1541
- // Hour [0-11]
1542
- K: function K(date, token, localize) {
1543
- var hours = date.getUTCHours() % 12;
1544
- if (token === 'Ko') {
1545
- return localize.ordinalNumber(hours, {
1546
- unit: 'hour'
1547
- });
1548
- }
1549
- return addLeadingZeros(hours, token.length);
1550
- },
1551
- // Hour [1-24]
1552
- k: function k(date, token, localize) {
1553
- var hours = date.getUTCHours();
1554
- if (hours === 0) hours = 24;
1555
- if (token === 'ko') {
1556
- return localize.ordinalNumber(hours, {
1557
- unit: 'hour'
1558
- });
1559
- }
1560
- return addLeadingZeros(hours, token.length);
1561
- },
1562
- // Minute
1563
- m: function m(date, token, localize) {
1564
- if (token === 'mo') {
1565
- return localize.ordinalNumber(date.getUTCMinutes(), {
1566
- unit: 'minute'
1567
- });
1568
- }
1569
- return formatters$3.m(date, token);
1570
- },
1571
- // Second
1572
- s: function s(date, token, localize) {
1573
- if (token === 'so') {
1574
- return localize.ordinalNumber(date.getUTCSeconds(), {
1575
- unit: 'second'
1576
- });
1577
- }
1578
- return formatters$3.s(date, token);
1579
- },
1580
- // Fraction of second
1581
- S: function S(date, token) {
1582
- return formatters$3.S(date, token);
1583
- },
1584
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1585
- X: function X(date, token, _localize, options) {
1586
- var originalDate = options._originalDate || date;
1587
- var timezoneOffset = originalDate.getTimezoneOffset();
1588
- if (timezoneOffset === 0) {
1589
- return 'Z';
1590
- }
1591
- switch (token) {
1592
- // Hours and optional minutes
1593
- case 'X':
1594
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1595
-
1596
- // Hours, minutes and optional seconds without `:` delimiter
1597
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1598
- // so this token always has the same output as `XX`
1599
- case 'XXXX':
1600
- case 'XX':
1601
- // Hours and minutes without `:` delimiter
1602
- return formatTimezone(timezoneOffset);
1603
-
1604
- // Hours, minutes and optional seconds with `:` delimiter
1605
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1606
- // so this token always has the same output as `XXX`
1607
- case 'XXXXX':
1608
- case 'XXX': // Hours and minutes with `:` delimiter
1609
- default:
1610
- return formatTimezone(timezoneOffset, ':');
1611
- }
1612
- },
1613
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1614
- x: function x(date, token, _localize, options) {
1615
- var originalDate = options._originalDate || date;
1616
- var timezoneOffset = originalDate.getTimezoneOffset();
1617
- switch (token) {
1618
- // Hours and optional minutes
1619
- case 'x':
1620
- return formatTimezoneWithOptionalMinutes(timezoneOffset);
1621
-
1622
- // Hours, minutes and optional seconds without `:` delimiter
1623
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1624
- // so this token always has the same output as `xx`
1625
- case 'xxxx':
1626
- case 'xx':
1627
- // Hours and minutes without `:` delimiter
1628
- return formatTimezone(timezoneOffset);
1629
-
1630
- // Hours, minutes and optional seconds with `:` delimiter
1631
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1632
- // so this token always has the same output as `xxx`
1633
- case 'xxxxx':
1634
- case 'xxx': // Hours and minutes with `:` delimiter
1635
- default:
1636
- return formatTimezone(timezoneOffset, ':');
1637
- }
1638
- },
1639
- // Timezone (GMT)
1640
- O: function O(date, token, _localize, options) {
1641
- var originalDate = options._originalDate || date;
1642
- var timezoneOffset = originalDate.getTimezoneOffset();
1643
- switch (token) {
1644
- // Short
1645
- case 'O':
1646
- case 'OO':
1647
- case 'OOO':
1648
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1649
- // Long
1650
- case 'OOOO':
1651
- default:
1652
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1653
- }
1654
- },
1655
- // Timezone (specific non-location)
1656
- z: function z(date, token, _localize, options) {
1657
- var originalDate = options._originalDate || date;
1658
- var timezoneOffset = originalDate.getTimezoneOffset();
1659
- switch (token) {
1660
- // Short
1661
- case 'z':
1662
- case 'zz':
1663
- case 'zzz':
1664
- return 'GMT' + formatTimezoneShort(timezoneOffset, ':');
1665
- // Long
1666
- case 'zzzz':
1667
- default:
1668
- return 'GMT' + formatTimezone(timezoneOffset, ':');
1669
- }
1670
- },
1671
- // Seconds timestamp
1672
- t: function t(date, token, _localize, options) {
1673
- var originalDate = options._originalDate || date;
1674
- var timestamp = Math.floor(originalDate.getTime() / 1000);
1675
- return addLeadingZeros(timestamp, token.length);
1676
- },
1677
- // Milliseconds timestamp
1678
- T: function T(date, token, _localize, options) {
1679
- var originalDate = options._originalDate || date;
1680
- var timestamp = originalDate.getTime();
1681
- return addLeadingZeros(timestamp, token.length);
1682
- }
1683
- };
1684
- function formatTimezoneShort(offset, dirtyDelimiter) {
1685
- var sign = offset > 0 ? '-' : '+';
1686
- var absOffset = Math.abs(offset);
1687
- var hours = Math.floor(absOffset / 60);
1688
- var minutes = absOffset % 60;
1689
- if (minutes === 0) {
1690
- return sign + String(hours);
1691
- }
1692
- var delimiter = dirtyDelimiter || '';
1693
- return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
1694
- }
1695
- function formatTimezoneWithOptionalMinutes(offset, dirtyDelimiter) {
1696
- if (offset % 60 === 0) {
1697
- var sign = offset > 0 ? '-' : '+';
1698
- return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
1699
- }
1700
- return formatTimezone(offset, dirtyDelimiter);
1701
- }
1702
- function formatTimezone(offset, dirtyDelimiter) {
1703
- var delimiter = dirtyDelimiter || '';
1704
- var sign = offset > 0 ? '-' : '+';
1705
- var absOffset = Math.abs(offset);
1706
- var hours = addLeadingZeros(Math.floor(absOffset / 60), 2);
1707
- var minutes = addLeadingZeros(absOffset % 60, 2);
1708
- return sign + hours + delimiter + minutes;
1709
- }
1710
- const formatters$1 = formatters;
1711
-
1712
- var dateLongFormatter = function dateLongFormatter(pattern, formatLong) {
1713
- switch (pattern) {
1714
- case 'P':
1715
- return formatLong.date({
1716
- width: 'short'
1717
- });
1718
- case 'PP':
1719
- return formatLong.date({
1720
- width: 'medium'
1721
- });
1722
- case 'PPP':
1723
- return formatLong.date({
1724
- width: 'long'
1725
- });
1726
- case 'PPPP':
1727
- default:
1728
- return formatLong.date({
1729
- width: 'full'
1730
- });
1731
- }
1732
- };
1733
- var timeLongFormatter = function timeLongFormatter(pattern, formatLong) {
1734
- switch (pattern) {
1735
- case 'p':
1736
- return formatLong.time({
1737
- width: 'short'
1738
- });
1739
- case 'pp':
1740
- return formatLong.time({
1741
- width: 'medium'
1742
- });
1743
- case 'ppp':
1744
- return formatLong.time({
1745
- width: 'long'
1746
- });
1747
- case 'pppp':
1748
- default:
1749
- return formatLong.time({
1750
- width: 'full'
1751
- });
1752
- }
1753
- };
1754
- var dateTimeLongFormatter = function dateTimeLongFormatter(pattern, formatLong) {
1755
- var matchResult = pattern.match(/(P+)(p+)?/) || [];
1756
- var datePattern = matchResult[1];
1757
- var timePattern = matchResult[2];
1758
- if (!timePattern) {
1759
- return dateLongFormatter(pattern, formatLong);
1760
- }
1761
- var dateTimeFormat;
1762
- switch (datePattern) {
1763
- case 'P':
1764
- dateTimeFormat = formatLong.dateTime({
1765
- width: 'short'
1766
- });
1767
- break;
1768
- case 'PP':
1769
- dateTimeFormat = formatLong.dateTime({
1770
- width: 'medium'
1771
- });
1772
- break;
1773
- case 'PPP':
1774
- dateTimeFormat = formatLong.dateTime({
1775
- width: 'long'
1776
- });
1777
- break;
1778
- case 'PPPP':
1779
- default:
1780
- dateTimeFormat = formatLong.dateTime({
1781
- width: 'full'
1782
- });
1783
- break;
1784
- }
1785
- return dateTimeFormat.replace('{{date}}', dateLongFormatter(datePattern, formatLong)).replace('{{time}}', timeLongFormatter(timePattern, formatLong));
1786
- };
1787
- var longFormatters = {
1788
- p: timeLongFormatter,
1789
- P: dateTimeLongFormatter
1790
- };
1791
- const longFormatters$1 = longFormatters;
1792
-
1793
- var protectedDayOfYearTokens = ['D', 'DD'];
1794
- var protectedWeekYearTokens = ['YY', 'YYYY'];
1795
- function isProtectedDayOfYearToken(token) {
1796
- return protectedDayOfYearTokens.indexOf(token) !== -1;
1797
- }
1798
- function isProtectedWeekYearToken(token) {
1799
- return protectedWeekYearTokens.indexOf(token) !== -1;
1800
- }
1801
- function throwProtectedError(token, format, input) {
1802
- if (token === 'YYYY') {
1803
- throw new RangeError("Use `yyyy` instead of `YYYY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1804
- } else if (token === 'YY') {
1805
- throw new RangeError("Use `yy` instead of `YY` (in `".concat(format, "`) for formatting years to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1806
- } else if (token === 'D') {
1807
- throw new RangeError("Use `d` instead of `D` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1808
- } else if (token === 'DD') {
1809
- throw new RangeError("Use `dd` instead of `DD` (in `".concat(format, "`) for formatting days of the month to the input `").concat(input, "`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md"));
1810
- }
1811
- }
1812
-
1813
- var formatDistanceLocale$1 = {
1814
- lessThanXSeconds: {
1815
- one: 'less than a second',
1816
- other: 'less than {{count}} seconds'
1817
- },
1818
- xSeconds: {
1819
- one: '1 second',
1820
- other: '{{count}} seconds'
1821
- },
1822
- halfAMinute: 'half a minute',
1823
- lessThanXMinutes: {
1824
- one: 'less than a minute',
1825
- other: 'less than {{count}} minutes'
1826
- },
1827
- xMinutes: {
1828
- one: '1 minute',
1829
- other: '{{count}} minutes'
1830
- },
1831
- aboutXHours: {
1832
- one: 'about 1 hour',
1833
- other: 'about {{count}} hours'
1834
- },
1835
- xHours: {
1836
- one: '1 hour',
1837
- other: '{{count}} hours'
1838
- },
1839
- xDays: {
1840
- one: '1 day',
1841
- other: '{{count}} days'
1842
- },
1843
- aboutXWeeks: {
1844
- one: 'about 1 week',
1845
- other: 'about {{count}} weeks'
1846
- },
1847
- xWeeks: {
1848
- one: '1 week',
1849
- other: '{{count}} weeks'
1850
- },
1851
- aboutXMonths: {
1852
- one: 'about 1 month',
1853
- other: 'about {{count}} months'
1854
- },
1855
- xMonths: {
1856
- one: '1 month',
1857
- other: '{{count}} months'
1858
- },
1859
- aboutXYears: {
1860
- one: 'about 1 year',
1861
- other: 'about {{count}} years'
1862
- },
1863
- xYears: {
1864
- one: '1 year',
1865
- other: '{{count}} years'
1866
- },
1867
- overXYears: {
1868
- one: 'over 1 year',
1869
- other: 'over {{count}} years'
1870
- },
1871
- almostXYears: {
1872
- one: 'almost 1 year',
1873
- other: 'almost {{count}} years'
1874
- }
1875
- };
1876
- var formatDistance$2 = function formatDistance(token, count, options) {
1877
- var result;
1878
- var tokenValue = formatDistanceLocale$1[token];
1879
- if (typeof tokenValue === 'string') {
1880
- result = tokenValue;
1881
- } else if (count === 1) {
1882
- result = tokenValue.one;
1883
- } else {
1884
- result = tokenValue.other.replace('{{count}}', count.toString());
1885
- }
1886
- if (options !== null && options !== void 0 && options.addSuffix) {
1887
- if (options.comparison && options.comparison > 0) {
1888
- return 'in ' + result;
1889
- } else {
1890
- return result + ' ago';
1891
- }
1892
- }
1893
- return result;
1894
- };
1895
- const formatDistance$3 = formatDistance$2;
1896
-
1897
- function buildFormatLongFn(args) {
1898
- return function () {
1899
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1900
- // TODO: Remove String()
1901
- var width = options.width ? String(options.width) : args.defaultWidth;
1902
- var format = args.formats[width] || args.formats[args.defaultWidth];
1903
- return format;
1904
- };
1905
- }
1906
-
1907
- var dateFormats$2 = {
1908
- full: 'EEEE, MMMM do, y',
1909
- long: 'MMMM do, y',
1910
- medium: 'MMM d, y',
1911
- short: 'MM/dd/yyyy'
1912
- };
1913
- var timeFormats$2 = {
1914
- full: 'h:mm:ss a zzzz',
1915
- long: 'h:mm:ss a z',
1916
- medium: 'h:mm:ss a',
1917
- short: 'h:mm a'
1918
- };
1919
- var dateTimeFormats$2 = {
1920
- full: "{{date}} 'at' {{time}}",
1921
- long: "{{date}} 'at' {{time}}",
1922
- medium: '{{date}}, {{time}}',
1923
- short: '{{date}}, {{time}}'
1924
- };
1925
- var formatLong$4 = {
1926
- date: buildFormatLongFn({
1927
- formats: dateFormats$2,
1928
- defaultWidth: 'full'
1929
- }),
1930
- time: buildFormatLongFn({
1931
- formats: timeFormats$2,
1932
- defaultWidth: 'full'
1933
- }),
1934
- dateTime: buildFormatLongFn({
1935
- formats: dateTimeFormats$2,
1936
- defaultWidth: 'full'
1937
- })
1938
- };
1939
- const formatLong$5 = formatLong$4;
1940
-
1941
- var formatRelativeLocale$1 = {
1942
- lastWeek: "'last' eeee 'at' p",
1943
- yesterday: "'yesterday at' p",
1944
- today: "'today at' p",
1945
- tomorrow: "'tomorrow at' p",
1946
- nextWeek: "eeee 'at' p",
1947
- other: 'P'
1948
- };
1949
- var formatRelative$2 = function formatRelative(token, _date, _baseDate, _options) {
1950
- return formatRelativeLocale$1[token];
1951
- };
1952
- const formatRelative$3 = formatRelative$2;
1953
-
1954
- function buildLocalizeFn(args) {
1955
- return function (dirtyIndex, options) {
1956
- var context = options !== null && options !== void 0 && options.context ? String(options.context) : 'standalone';
1957
- var valuesArray;
1958
- if (context === 'formatting' && args.formattingValues) {
1959
- var defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1960
- var width = options !== null && options !== void 0 && options.width ? String(options.width) : defaultWidth;
1961
- valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
1962
- } else {
1963
- var _defaultWidth = args.defaultWidth;
1964
- var _width = options !== null && options !== void 0 && options.width ? String(options.width) : args.defaultWidth;
1965
- valuesArray = args.values[_width] || args.values[_defaultWidth];
1966
- }
1967
- var index = args.argumentCallback ? args.argumentCallback(dirtyIndex) : dirtyIndex;
1968
- // @ts-ignore: For some reason TypeScript just don't want to match it, no matter how hard we try. I challenge you to try to remove it!
1969
- return valuesArray[index];
1970
- };
1971
- }
1972
-
1973
- var eraValues$1 = {
1974
- narrow: ['B', 'A'],
1975
- abbreviated: ['BC', 'AD'],
1976
- wide: ['Before Christ', 'Anno Domini']
1977
- };
1978
- var quarterValues$1 = {
1979
- narrow: ['1', '2', '3', '4'],
1980
- abbreviated: ['Q1', 'Q2', 'Q3', 'Q4'],
1981
- wide: ['1st quarter', '2nd quarter', '3rd quarter', '4th quarter']
1982
- };
1983
-
1984
- // Note: in English, the names of days of the week and months are capitalized.
1985
- // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1986
- // Generally, formatted dates should look like they are in the middle of a sentence,
1987
- // e.g. in Spanish language the weekdays and months should be in the lowercase.
1988
- var monthValues$1 = {
1989
- narrow: ['J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D'],
1990
- abbreviated: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
1991
- wide: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
1992
- };
1993
- var dayValues$1 = {
1994
- narrow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
1995
- short: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
1996
- abbreviated: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
1997
- wide: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
1998
- };
1999
- var dayPeriodValues$1 = {
2000
- narrow: {
2001
- am: 'a',
2002
- pm: 'p',
2003
- midnight: 'mi',
2004
- noon: 'n',
2005
- morning: 'morning',
2006
- afternoon: 'afternoon',
2007
- evening: 'evening',
2008
- night: 'night'
2009
- },
2010
- abbreviated: {
2011
- am: 'AM',
2012
- pm: 'PM',
2013
- midnight: 'midnight',
2014
- noon: 'noon',
2015
- morning: 'morning',
2016
- afternoon: 'afternoon',
2017
- evening: 'evening',
2018
- night: 'night'
2019
- },
2020
- wide: {
2021
- am: 'a.m.',
2022
- pm: 'p.m.',
2023
- midnight: 'midnight',
2024
- noon: 'noon',
2025
- morning: 'morning',
2026
- afternoon: 'afternoon',
2027
- evening: 'evening',
2028
- night: 'night'
2029
- }
2030
- };
2031
- var formattingDayPeriodValues$1 = {
2032
- narrow: {
2033
- am: 'a',
2034
- pm: 'p',
2035
- midnight: 'mi',
2036
- noon: 'n',
2037
- morning: 'in the morning',
2038
- afternoon: 'in the afternoon',
2039
- evening: 'in the evening',
2040
- night: 'at night'
2041
- },
2042
- abbreviated: {
2043
- am: 'AM',
2044
- pm: 'PM',
2045
- midnight: 'midnight',
2046
- noon: 'noon',
2047
- morning: 'in the morning',
2048
- afternoon: 'in the afternoon',
2049
- evening: 'in the evening',
2050
- night: 'at night'
2051
- },
2052
- wide: {
2053
- am: 'a.m.',
2054
- pm: 'p.m.',
2055
- midnight: 'midnight',
2056
- noon: 'noon',
2057
- morning: 'in the morning',
2058
- afternoon: 'in the afternoon',
2059
- evening: 'in the evening',
2060
- night: 'at night'
2061
- }
2062
- };
2063
- var ordinalNumber$1 = function ordinalNumber(dirtyNumber, _options) {
2064
- var number = Number(dirtyNumber);
2065
-
2066
- // If ordinal numbers depend on context, for example,
2067
- // if they are different for different grammatical genders,
2068
- // use `options.unit`.
2069
- //
2070
- // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
2071
- // 'day', 'hour', 'minute', 'second'.
2072
-
2073
- var rem100 = number % 100;
2074
- if (rem100 > 20 || rem100 < 10) {
2075
- switch (rem100 % 10) {
2076
- case 1:
2077
- return number + 'st';
2078
- case 2:
2079
- return number + 'nd';
2080
- case 3:
2081
- return number + 'rd';
2082
- }
2083
- }
2084
- return number + 'th';
2085
- };
2086
- var localize$2 = {
2087
- ordinalNumber: ordinalNumber$1,
2088
- era: buildLocalizeFn({
2089
- values: eraValues$1,
2090
- defaultWidth: 'wide'
2091
- }),
2092
- quarter: buildLocalizeFn({
2093
- values: quarterValues$1,
2094
- defaultWidth: 'wide',
2095
- argumentCallback: function argumentCallback(quarter) {
2096
- return quarter - 1;
2097
- }
2098
- }),
2099
- month: buildLocalizeFn({
2100
- values: monthValues$1,
2101
- defaultWidth: 'wide'
2102
- }),
2103
- day: buildLocalizeFn({
2104
- values: dayValues$1,
2105
- defaultWidth: 'wide'
2106
- }),
2107
- dayPeriod: buildLocalizeFn({
2108
- values: dayPeriodValues$1,
2109
- defaultWidth: 'wide',
2110
- formattingValues: formattingDayPeriodValues$1,
2111
- defaultFormattingWidth: 'wide'
2112
- })
2113
- };
2114
- const localize$3 = localize$2;
2115
-
2116
- function buildMatchFn(args) {
2117
- return function (string) {
2118
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2119
- var width = options.width;
2120
- var matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
2121
- var matchResult = string.match(matchPattern);
2122
- if (!matchResult) {
2123
- return null;
2124
- }
2125
- var matchedString = matchResult[0];
2126
- var parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
2127
- var key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, function (pattern) {
2128
- return pattern.test(matchedString);
2129
- }) : findKey(parsePatterns, function (pattern) {
2130
- return pattern.test(matchedString);
2131
- });
2132
- var value;
2133
- value = args.valueCallback ? args.valueCallback(key) : key;
2134
- value = options.valueCallback ? options.valueCallback(value) : value;
2135
- var rest = string.slice(matchedString.length);
2136
- return {
2137
- value: value,
2138
- rest: rest
2139
- };
2140
- };
2141
- }
2142
- function findKey(object, predicate) {
2143
- for (var key in object) {
2144
- if (object.hasOwnProperty(key) && predicate(object[key])) {
2145
- return key;
2146
- }
2147
- }
2148
- return undefined;
2149
- }
2150
- function findIndex(array, predicate) {
2151
- for (var key = 0; key < array.length; key++) {
2152
- if (predicate(array[key])) {
2153
- return key;
2154
- }
2155
- }
2156
- return undefined;
2157
- }
2158
-
2159
- function buildMatchPatternFn(args) {
2160
- return function (string) {
2161
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2162
- var matchResult = string.match(args.matchPattern);
2163
- if (!matchResult) return null;
2164
- var matchedString = matchResult[0];
2165
- var parseResult = string.match(args.parsePattern);
2166
- if (!parseResult) return null;
2167
- var value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
2168
- value = options.valueCallback ? options.valueCallback(value) : value;
2169
- var rest = string.slice(matchedString.length);
2170
- return {
2171
- value: value,
2172
- rest: rest
2173
- };
2174
- };
2175
- }
2176
-
2177
- var matchOrdinalNumberPattern$1 = /^(\d+)(th|st|nd|rd)?/i;
2178
- var parseOrdinalNumberPattern$1 = /\d+/i;
2179
- var matchEraPatterns$1 = {
2180
- narrow: /^(b|a)/i,
2181
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
2182
- wide: /^(before christ|before common era|anno domini|common era)/i
2183
- };
2184
- var parseEraPatterns$1 = {
2185
- any: [/^b/i, /^(a|c)/i]
2186
- };
2187
- var matchQuarterPatterns$1 = {
2188
- narrow: /^[1234]/i,
2189
- abbreviated: /^q[1234]/i,
2190
- wide: /^[1234](th|st|nd|rd)? quarter/i
2191
- };
2192
- var parseQuarterPatterns$1 = {
2193
- any: [/1/i, /2/i, /3/i, /4/i]
2194
- };
2195
- var matchMonthPatterns$1 = {
2196
- narrow: /^[jfmasond]/i,
2197
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
2198
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
2199
- };
2200
- var parseMonthPatterns$1 = {
2201
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
2202
- any: [/^ja/i, /^f/i, /^mar/i, /^ap/i, /^may/i, /^jun/i, /^jul/i, /^au/i, /^s/i, /^o/i, /^n/i, /^d/i]
2203
- };
2204
- var matchDayPatterns$1 = {
2205
- narrow: /^[smtwf]/i,
2206
- short: /^(su|mo|tu|we|th|fr|sa)/i,
2207
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
2208
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
2209
- };
2210
- var parseDayPatterns$1 = {
2211
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
2212
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
2213
- };
2214
- var matchDayPeriodPatterns$1 = {
2215
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
2216
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
2217
- };
2218
- var parseDayPeriodPatterns$1 = {
2219
- any: {
2220
- am: /^a/i,
2221
- pm: /^p/i,
2222
- midnight: /^mi/i,
2223
- noon: /^no/i,
2224
- morning: /morning/i,
2225
- afternoon: /afternoon/i,
2226
- evening: /evening/i,
2227
- night: /night/i
2228
- }
2229
- };
2230
- var match$2 = {
2231
- ordinalNumber: buildMatchPatternFn({
2232
- matchPattern: matchOrdinalNumberPattern$1,
2233
- parsePattern: parseOrdinalNumberPattern$1,
2234
- valueCallback: function valueCallback(value) {
2235
- return parseInt(value, 10);
2236
- }
2237
- }),
2238
- era: buildMatchFn({
2239
- matchPatterns: matchEraPatterns$1,
2240
- defaultMatchWidth: 'wide',
2241
- parsePatterns: parseEraPatterns$1,
2242
- defaultParseWidth: 'any'
2243
- }),
2244
- quarter: buildMatchFn({
2245
- matchPatterns: matchQuarterPatterns$1,
2246
- defaultMatchWidth: 'wide',
2247
- parsePatterns: parseQuarterPatterns$1,
2248
- defaultParseWidth: 'any',
2249
- valueCallback: function valueCallback(index) {
2250
- return index + 1;
2251
- }
2252
- }),
2253
- month: buildMatchFn({
2254
- matchPatterns: matchMonthPatterns$1,
2255
- defaultMatchWidth: 'wide',
2256
- parsePatterns: parseMonthPatterns$1,
2257
- defaultParseWidth: 'any'
2258
- }),
2259
- day: buildMatchFn({
2260
- matchPatterns: matchDayPatterns$1,
2261
- defaultMatchWidth: 'wide',
2262
- parsePatterns: parseDayPatterns$1,
2263
- defaultParseWidth: 'any'
2264
- }),
2265
- dayPeriod: buildMatchFn({
2266
- matchPatterns: matchDayPeriodPatterns$1,
2267
- defaultMatchWidth: 'any',
2268
- parsePatterns: parseDayPeriodPatterns$1,
2269
- defaultParseWidth: 'any'
2270
- })
2271
- };
2272
- const match$3 = match$2;
2273
-
2274
- /**
2275
- * @type {Locale}
2276
- * @category Locales
2277
- * @summary English locale (United States).
2278
- * @language English
2279
- * @iso-639-2 eng
2280
- * @author Sasha Koss [@kossnocorp]{@link https://github.com/kossnocorp}
2281
- * @author Lesha Koss [@leshakoss]{@link https://github.com/leshakoss}
2282
- */
2283
- var locale$2 = {
2284
- code: 'en-US',
2285
- formatDistance: formatDistance$3,
2286
- formatLong: formatLong$5,
2287
- formatRelative: formatRelative$3,
2288
- localize: localize$3,
2289
- match: match$3,
2290
- options: {
2291
- weekStartsOn: 0 /* Sunday */,
2292
- firstWeekContainsDate: 1
2293
- }
2294
- };
2295
- const defaultLocale = locale$2;
2296
-
2297
- // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2298
- // (one of the certain letters followed by `o`)
2299
- // - (\w)\1* matches any sequences of the same letter
2300
- // - '' matches two quote characters in a row
2301
- // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2302
- // except a single quote symbol, which ends the sequence.
2303
- // Two quote characters do not end the sequence.
2304
- // If there is no matching single quote
2305
- // then the sequence will continue until the end of the string.
2306
- // - . matches any single character unmatched by previous parts of the RegExps
2307
- var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2308
-
2309
- // This RegExp catches symbols escaped by quotes, and also
2310
- // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2311
- var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2312
- var escapedStringRegExp = /^'([^]*?)'?$/;
2313
- var doubleQuoteRegExp = /''/g;
2314
- var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2315
-
2316
- /**
2317
- * @name format
2318
- * @category Common Helpers
2319
- * @summary Format the date.
2320
- *
2321
- * @description
2322
- * Return the formatted date string in the given format. The result may vary by locale.
2323
- *
2324
- * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2325
- * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2326
- *
2327
- * The characters wrapped between two single quotes characters (') are escaped.
2328
- * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2329
- * (see the last example)
2330
- *
2331
- * Format of the string is based on Unicode Technical Standard #35:
2332
- * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2333
- * with a few additions (see note 7 below the table).
2334
- *
2335
- * Accepted patterns:
2336
- * | Unit | Pattern | Result examples | Notes |
2337
- * |---------------------------------|---------|-----------------------------------|-------|
2338
- * | Era | G..GGG | AD, BC | |
2339
- * | | GGGG | Anno Domini, Before Christ | 2 |
2340
- * | | GGGGG | A, B | |
2341
- * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2342
- * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2343
- * | | yy | 44, 01, 00, 17 | 5 |
2344
- * | | yyy | 044, 001, 1900, 2017 | 5 |
2345
- * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2346
- * | | yyyyy | ... | 3,5 |
2347
- * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2348
- * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2349
- * | | YY | 44, 01, 00, 17 | 5,8 |
2350
- * | | YYY | 044, 001, 1900, 2017 | 5 |
2351
- * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2352
- * | | YYYYY | ... | 3,5 |
2353
- * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2354
- * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2355
- * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2356
- * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2357
- * | | RRRRR | ... | 3,5,7 |
2358
- * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2359
- * | | uu | -43, 01, 1900, 2017 | 5 |
2360
- * | | uuu | -043, 001, 1900, 2017 | 5 |
2361
- * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2362
- * | | uuuuu | ... | 3,5 |
2363
- * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2364
- * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2365
- * | | QQ | 01, 02, 03, 04 | |
2366
- * | | QQQ | Q1, Q2, Q3, Q4 | |
2367
- * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2368
- * | | QQQQQ | 1, 2, 3, 4 | 4 |
2369
- * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2370
- * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2371
- * | | qq | 01, 02, 03, 04 | |
2372
- * | | qqq | Q1, Q2, Q3, Q4 | |
2373
- * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2374
- * | | qqqqq | 1, 2, 3, 4 | 4 |
2375
- * | Month (formatting) | M | 1, 2, ..., 12 | |
2376
- * | | Mo | 1st, 2nd, ..., 12th | 7 |
2377
- * | | MM | 01, 02, ..., 12 | |
2378
- * | | MMM | Jan, Feb, ..., Dec | |
2379
- * | | MMMM | January, February, ..., December | 2 |
2380
- * | | MMMMM | J, F, ..., D | |
2381
- * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2382
- * | | Lo | 1st, 2nd, ..., 12th | 7 |
2383
- * | | LL | 01, 02, ..., 12 | |
2384
- * | | LLL | Jan, Feb, ..., Dec | |
2385
- * | | LLLL | January, February, ..., December | 2 |
2386
- * | | LLLLL | J, F, ..., D | |
2387
- * | Local week of year | w | 1, 2, ..., 53 | |
2388
- * | | wo | 1st, 2nd, ..., 53th | 7 |
2389
- * | | ww | 01, 02, ..., 53 | |
2390
- * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2391
- * | | Io | 1st, 2nd, ..., 53th | 7 |
2392
- * | | II | 01, 02, ..., 53 | 7 |
2393
- * | Day of month | d | 1, 2, ..., 31 | |
2394
- * | | do | 1st, 2nd, ..., 31st | 7 |
2395
- * | | dd | 01, 02, ..., 31 | |
2396
- * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2397
- * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2398
- * | | DD | 01, 02, ..., 365, 366 | 9 |
2399
- * | | DDD | 001, 002, ..., 365, 366 | |
2400
- * | | DDDD | ... | 3 |
2401
- * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2402
- * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2403
- * | | EEEEE | M, T, W, T, F, S, S | |
2404
- * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2405
- * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2406
- * | | io | 1st, 2nd, ..., 7th | 7 |
2407
- * | | ii | 01, 02, ..., 07 | 7 |
2408
- * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2409
- * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2410
- * | | iiiii | M, T, W, T, F, S, S | 7 |
2411
- * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2412
- * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2413
- * | | eo | 2nd, 3rd, ..., 1st | 7 |
2414
- * | | ee | 02, 03, ..., 01 | |
2415
- * | | eee | Mon, Tue, Wed, ..., Sun | |
2416
- * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2417
- * | | eeeee | M, T, W, T, F, S, S | |
2418
- * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2419
- * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2420
- * | | co | 2nd, 3rd, ..., 1st | 7 |
2421
- * | | cc | 02, 03, ..., 01 | |
2422
- * | | ccc | Mon, Tue, Wed, ..., Sun | |
2423
- * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2424
- * | | ccccc | M, T, W, T, F, S, S | |
2425
- * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2426
- * | AM, PM | a..aa | AM, PM | |
2427
- * | | aaa | am, pm | |
2428
- * | | aaaa | a.m., p.m. | 2 |
2429
- * | | aaaaa | a, p | |
2430
- * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2431
- * | | bbb | am, pm, noon, midnight | |
2432
- * | | bbbb | a.m., p.m., noon, midnight | 2 |
2433
- * | | bbbbb | a, p, n, mi | |
2434
- * | Flexible day period | B..BBB | at night, in the morning, ... | |
2435
- * | | BBBB | at night, in the morning, ... | 2 |
2436
- * | | BBBBB | at night, in the morning, ... | |
2437
- * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2438
- * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2439
- * | | hh | 01, 02, ..., 11, 12 | |
2440
- * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2441
- * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2442
- * | | HH | 00, 01, 02, ..., 23 | |
2443
- * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2444
- * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2445
- * | | KK | 01, 02, ..., 11, 00 | |
2446
- * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2447
- * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2448
- * | | kk | 24, 01, 02, ..., 23 | |
2449
- * | Minute | m | 0, 1, ..., 59 | |
2450
- * | | mo | 0th, 1st, ..., 59th | 7 |
2451
- * | | mm | 00, 01, ..., 59 | |
2452
- * | Second | s | 0, 1, ..., 59 | |
2453
- * | | so | 0th, 1st, ..., 59th | 7 |
2454
- * | | ss | 00, 01, ..., 59 | |
2455
- * | Fraction of second | S | 0, 1, ..., 9 | |
2456
- * | | SS | 00, 01, ..., 99 | |
2457
- * | | SSS | 000, 001, ..., 999 | |
2458
- * | | SSSS | ... | 3 |
2459
- * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2460
- * | | XX | -0800, +0530, Z | |
2461
- * | | XXX | -08:00, +05:30, Z | |
2462
- * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2463
- * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2464
- * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2465
- * | | xx | -0800, +0530, +0000 | |
2466
- * | | xxx | -08:00, +05:30, +00:00 | 2 |
2467
- * | | xxxx | -0800, +0530, +0000, +123456 | |
2468
- * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2469
- * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2470
- * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2471
- * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2472
- * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2473
- * | Seconds timestamp | t | 512969520 | 7 |
2474
- * | | tt | ... | 3,7 |
2475
- * | Milliseconds timestamp | T | 512969520900 | 7 |
2476
- * | | TT | ... | 3,7 |
2477
- * | Long localized date | P | 04/29/1453 | 7 |
2478
- * | | PP | Apr 29, 1453 | 7 |
2479
- * | | PPP | April 29th, 1453 | 7 |
2480
- * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2481
- * | Long localized time | p | 12:00 AM | 7 |
2482
- * | | pp | 12:00:00 AM | 7 |
2483
- * | | ppp | 12:00:00 AM GMT+2 | 7 |
2484
- * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2485
- * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2486
- * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2487
- * | | PPPppp | April 29th, 1453 at ... | 7 |
2488
- * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2489
- * Notes:
2490
- * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2491
- * are the same as "stand-alone" units, but are different in some languages.
2492
- * "Formatting" units are declined according to the rules of the language
2493
- * in the context of a date. "Stand-alone" units are always nominative singular:
2494
- *
2495
- * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2496
- *
2497
- * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2498
- *
2499
- * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2500
- * the single quote characters (see below).
2501
- * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2502
- * the output will be the same as default pattern for this unit, usually
2503
- * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2504
- * are marked with "2" in the last column of the table.
2505
- *
2506
- * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2507
- *
2508
- * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2509
- *
2510
- * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2511
- *
2512
- * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2513
- *
2514
- * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2515
- *
2516
- * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2517
- * The output will be padded with zeros to match the length of the pattern.
2518
- *
2519
- * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2520
- *
2521
- * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2522
- * These tokens represent the shortest form of the quarter.
2523
- *
2524
- * 5. The main difference between `y` and `u` patterns are B.C. years:
2525
- *
2526
- * | Year | `y` | `u` |
2527
- * |------|-----|-----|
2528
- * | AC 1 | 1 | 1 |
2529
- * | BC 1 | 1 | 0 |
2530
- * | BC 2 | 2 | -1 |
2531
- *
2532
- * Also `yy` always returns the last two digits of a year,
2533
- * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2534
- *
2535
- * | Year | `yy` | `uu` |
2536
- * |------|------|------|
2537
- * | 1 | 01 | 01 |
2538
- * | 14 | 14 | 14 |
2539
- * | 376 | 76 | 376 |
2540
- * | 1453 | 53 | 1453 |
2541
- *
2542
- * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2543
- * except local week-numbering years are dependent on `options.weekStartsOn`
2544
- * and `options.firstWeekContainsDate` (compare [getISOWeekYear]{@link https://date-fns.org/docs/getISOWeekYear}
2545
- * and [getWeekYear]{@link https://date-fns.org/docs/getWeekYear}).
2546
- *
2547
- * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2548
- * so right now these tokens fall back to GMT timezones.
2549
- *
2550
- * 7. These patterns are not in the Unicode Technical Standard #35:
2551
- * - `i`: ISO day of week
2552
- * - `I`: ISO week of year
2553
- * - `R`: ISO week-numbering year
2554
- * - `t`: seconds timestamp
2555
- * - `T`: milliseconds timestamp
2556
- * - `o`: ordinal number modifier
2557
- * - `P`: long localized date
2558
- * - `p`: long localized time
2559
- *
2560
- * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2561
- * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2562
- *
2563
- * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2564
- * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2565
- *
2566
- * @param {Date|Number} date - the original date
2567
- * @param {String} format - the string of tokens
2568
- * @param {Object} [options] - an object with options.
2569
- * @param {Locale} [options.locale=defaultLocale] - the locale object. See [Locale]{@link https://date-fns.org/docs/Locale}
2570
- * @param {0|1|2|3|4|5|6} [options.weekStartsOn=0] - the index of the first day of the week (0 - Sunday)
2571
- * @param {Number} [options.firstWeekContainsDate=1] - the day of January, which is
2572
- * @param {Boolean} [options.useAdditionalWeekYearTokens=false] - if true, allows usage of the week-numbering year tokens `YY` and `YYYY`;
2573
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2574
- * @param {Boolean} [options.useAdditionalDayOfYearTokens=false] - if true, allows usage of the day of year tokens `D` and `DD`;
2575
- * see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2576
- * @returns {String} the formatted date string
2577
- * @throws {TypeError} 2 arguments required
2578
- * @throws {RangeError} `date` must not be Invalid Date
2579
- * @throws {RangeError} `options.locale` must contain `localize` property
2580
- * @throws {RangeError} `options.locale` must contain `formatLong` property
2581
- * @throws {RangeError} `options.weekStartsOn` must be between 0 and 6
2582
- * @throws {RangeError} `options.firstWeekContainsDate` must be between 1 and 7
2583
- * @throws {RangeError} use `yyyy` instead of `YYYY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2584
- * @throws {RangeError} use `yy` instead of `YY` for formatting years using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2585
- * @throws {RangeError} use `d` instead of `D` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2586
- * @throws {RangeError} use `dd` instead of `DD` for formatting days of the month using [format provided] to the input [input provided]; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2587
- * @throws {RangeError} format string contains an unescaped latin alphabet character
2588
- *
2589
- * @example
2590
- * // Represent 11 February 2014 in middle-endian format:
2591
- * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2592
- * //=> '02/11/2014'
2593
- *
2594
- * @example
2595
- * // Represent 2 July 2014 in Esperanto:
2596
- * import { eoLocale } from 'date-fns/locale/eo'
2597
- * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2598
- * locale: eoLocale
2599
- * })
2600
- * //=> '2-a de julio 2014'
2601
- *
2602
- * @example
2603
- * // Escape string by single quote characters:
2604
- * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2605
- * //=> "3 o'clock"
2606
- */
2607
-
2608
- function format(dirtyDate, dirtyFormatStr, options) {
2609
- var _ref, _options$locale, _ref2, _ref3, _ref4, _options$firstWeekCon, _options$locale2, _options$locale2$opti, _defaultOptions$local, _defaultOptions$local2, _ref5, _ref6, _ref7, _options$weekStartsOn, _options$locale3, _options$locale3$opti, _defaultOptions$local3, _defaultOptions$local4;
2610
- requiredArgs(2, arguments);
2611
- var formatStr = String(dirtyFormatStr);
2612
- var defaultOptions = getDefaultOptions();
2613
- var locale = (_ref = (_options$locale = options === null || options === void 0 ? void 0 : options.locale) !== null && _options$locale !== void 0 ? _options$locale : defaultOptions.locale) !== null && _ref !== void 0 ? _ref : defaultLocale;
2614
- var firstWeekContainsDate = toInteger((_ref2 = (_ref3 = (_ref4 = (_options$firstWeekCon = options === null || options === void 0 ? void 0 : options.firstWeekContainsDate) !== null && _options$firstWeekCon !== void 0 ? _options$firstWeekCon : options === null || options === void 0 ? void 0 : (_options$locale2 = options.locale) === null || _options$locale2 === void 0 ? void 0 : (_options$locale2$opti = _options$locale2.options) === null || _options$locale2$opti === void 0 ? void 0 : _options$locale2$opti.firstWeekContainsDate) !== null && _ref4 !== void 0 ? _ref4 : defaultOptions.firstWeekContainsDate) !== null && _ref3 !== void 0 ? _ref3 : (_defaultOptions$local = defaultOptions.locale) === null || _defaultOptions$local === void 0 ? void 0 : (_defaultOptions$local2 = _defaultOptions$local.options) === null || _defaultOptions$local2 === void 0 ? void 0 : _defaultOptions$local2.firstWeekContainsDate) !== null && _ref2 !== void 0 ? _ref2 : 1);
2615
-
2616
- // Test if weekStartsOn is between 1 and 7 _and_ is not NaN
2617
- if (!(firstWeekContainsDate >= 1 && firstWeekContainsDate <= 7)) {
2618
- throw new RangeError('firstWeekContainsDate must be between 1 and 7 inclusively');
2619
- }
2620
- var weekStartsOn = toInteger((_ref5 = (_ref6 = (_ref7 = (_options$weekStartsOn = options === null || options === void 0 ? void 0 : options.weekStartsOn) !== null && _options$weekStartsOn !== void 0 ? _options$weekStartsOn : options === null || options === void 0 ? void 0 : (_options$locale3 = options.locale) === null || _options$locale3 === void 0 ? void 0 : (_options$locale3$opti = _options$locale3.options) === null || _options$locale3$opti === void 0 ? void 0 : _options$locale3$opti.weekStartsOn) !== null && _ref7 !== void 0 ? _ref7 : defaultOptions.weekStartsOn) !== null && _ref6 !== void 0 ? _ref6 : (_defaultOptions$local3 = defaultOptions.locale) === null || _defaultOptions$local3 === void 0 ? void 0 : (_defaultOptions$local4 = _defaultOptions$local3.options) === null || _defaultOptions$local4 === void 0 ? void 0 : _defaultOptions$local4.weekStartsOn) !== null && _ref5 !== void 0 ? _ref5 : 0);
2621
-
2622
- // Test if weekStartsOn is between 0 and 6 _and_ is not NaN
2623
- if (!(weekStartsOn >= 0 && weekStartsOn <= 6)) {
2624
- throw new RangeError('weekStartsOn must be between 0 and 6 inclusively');
2625
- }
2626
- if (!locale.localize) {
2627
- throw new RangeError('locale must contain localize property');
2628
- }
2629
- if (!locale.formatLong) {
2630
- throw new RangeError('locale must contain formatLong property');
2631
- }
2632
- var originalDate = toDate(dirtyDate);
2633
- if (!isValid(originalDate)) {
2634
- throw new RangeError('Invalid time value');
2635
- }
2636
-
2637
- // Convert the date in system timezone to the same date in UTC+00:00 timezone.
2638
- // This ensures that when UTC functions will be implemented, locales will be compatible with them.
2639
- // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376
2640
- var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
2641
- var utcDate = subMilliseconds(originalDate, timezoneOffset);
2642
- var formatterOptions = {
2643
- firstWeekContainsDate: firstWeekContainsDate,
2644
- weekStartsOn: weekStartsOn,
2645
- locale: locale,
2646
- _originalDate: originalDate
2647
- };
2648
- var result = formatStr.match(longFormattingTokensRegExp).map(function (substring) {
2649
- var firstCharacter = substring[0];
2650
- if (firstCharacter === 'p' || firstCharacter === 'P') {
2651
- var longFormatter = longFormatters$1[firstCharacter];
2652
- return longFormatter(substring, locale.formatLong);
2653
- }
2654
- return substring;
2655
- }).join('').match(formattingTokensRegExp).map(function (substring) {
2656
- // Replace two single quote characters with one single quote character
2657
- if (substring === "''") {
2658
- return "'";
2659
- }
2660
- var firstCharacter = substring[0];
2661
- if (firstCharacter === "'") {
2662
- return cleanEscapedString(substring);
2663
- }
2664
- var formatter = formatters$1[firstCharacter];
2665
- if (formatter) {
2666
- if (!(options !== null && options !== void 0 && options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(substring)) {
2667
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2668
- }
2669
- if (!(options !== null && options !== void 0 && options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(substring)) {
2670
- throwProtectedError(substring, dirtyFormatStr, String(dirtyDate));
2671
- }
2672
- return formatter(utcDate, substring, locale.localize, formatterOptions);
2673
- }
2674
- if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
2675
- throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');
2676
- }
2677
- return substring;
2678
- }).join('');
2679
- return result;
2680
- }
2681
- function cleanEscapedString(input) {
2682
- var matched = input.match(escapedStringRegExp);
2683
- if (!matched) {
2684
- return input;
2685
- }
2686
- return matched[1].replace(doubleQuoteRegExp, "'");
2687
- }
2688
-
2689
- /**
2690
- * @name getDay
2691
- * @category Weekday Helpers
2692
- * @summary Get the day of the week of the given date.
2693
- *
2694
- * @description
2695
- * Get the day of the week of the given date.
2696
- *
2697
- * @param {Date|Number} date - the given date
2698
- * @returns {0|1|2|3|4|5|6} the day of week, 0 represents Sunday
2699
- * @throws {TypeError} 1 argument required
2700
- *
2701
- * @example
2702
- * // Which day of the week is 29 February 2012?
2703
- * const result = getDay(new Date(2012, 1, 29))
2704
- * //=> 3
2705
- */
2706
- function getDay(dirtyDate) {
2707
- requiredArgs(1, arguments);
2708
- var date = toDate(dirtyDate);
2709
- var day = date.getDay();
2710
- return day;
2711
- }
2712
-
2713
- /**
2714
- * @name getMonth
2715
- * @category Month Helpers
2716
- * @summary Get the month of the given date.
2717
- *
2718
- * @description
2719
- * Get the month of the given date.
2720
- *
2721
- * @param {Date|Number} date - the given date
2722
- * @returns {Number} the month
2723
- * @throws {TypeError} 1 argument required
2724
- *
2725
- * @example
2726
- * // Which month is 29 February 2012?
2727
- * const result = getMonth(new Date(2012, 1, 29))
2728
- * //=> 1
2729
- */
2730
- function getMonth(dirtyDate) {
2731
- requiredArgs(1, arguments);
2732
- var date = toDate(dirtyDate);
2733
- var month = date.getMonth();
2734
- return month;
2735
- }
2736
-
2737
- /**
2738
- * @name getYear
2739
- * @category Year Helpers
2740
- * @summary Get the year of the given date.
2741
- *
2742
- * @description
2743
- * Get the year of the given date.
2744
- *
2745
- * @param {Date|Number} date - the given date
2746
- * @returns {Number} the year
2747
- * @throws {TypeError} 1 argument required
2748
- *
2749
- * @example
2750
- * // Which year is 2 July 2014?
2751
- * const result = getYear(new Date(2014, 6, 2))
2752
- * //=> 2014
2753
- */
2754
- function getYear(dirtyDate) {
2755
- requiredArgs(1, arguments);
2756
- return toDate(dirtyDate).getFullYear();
2757
- }
2758
-
2759
- /**
2760
- * @name isAfter
2761
- * @category Common Helpers
2762
- * @summary Is the first date after the second one?
2763
- *
2764
- * @description
2765
- * Is the first date after the second one?
2766
- *
2767
- * @param {Date|Number} date - the date that should be after the other one to return true
2768
- * @param {Date|Number} dateToCompare - the date to compare with
2769
- * @returns {Boolean} the first date is after the second date
2770
- * @throws {TypeError} 2 arguments required
2771
- *
2772
- * @example
2773
- * // Is 10 July 1989 after 11 February 1987?
2774
- * const result = isAfter(new Date(1989, 6, 10), new Date(1987, 1, 11))
2775
- * //=> true
2776
- */
2777
- function isAfter(dirtyDate, dirtyDateToCompare) {
2778
- requiredArgs(2, arguments);
2779
- var date = toDate(dirtyDate);
2780
- var dateToCompare = toDate(dirtyDateToCompare);
2781
- return date.getTime() > dateToCompare.getTime();
2782
- }
2783
-
2784
- /**
2785
- * @name isBefore
2786
- * @category Common Helpers
2787
- * @summary Is the first date before the second one?
2788
- *
2789
- * @description
2790
- * Is the first date before the second one?
2791
- *
2792
- * @param {Date|Number} date - the date that should be before the other one to return true
2793
- * @param {Date|Number} dateToCompare - the date to compare with
2794
- * @returns {Boolean} the first date is before the second date
2795
- * @throws {TypeError} 2 arguments required
2796
- *
2797
- * @example
2798
- * // Is 10 July 1989 before 11 February 1987?
2799
- * const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
2800
- * //=> false
2801
- */
2802
- function isBefore(dirtyDate, dirtyDateToCompare) {
2803
- requiredArgs(2, arguments);
2804
- var date = toDate(dirtyDate);
2805
- var dateToCompare = toDate(dirtyDateToCompare);
2806
- return date.getTime() < dateToCompare.getTime();
2807
- }
2808
-
2809
- /**
2810
- * @name isToday
2811
- * @category Day Helpers
2812
- * @summary Is the given date today?
2813
- * @pure false
2814
- *
2815
- * @description
2816
- * Is the given date today?
2817
- *
2818
- * > ⚠️ Please note that this function is not present in the FP submodule as
2819
- * > it uses `Date.now()` internally hence impure and can't be safely curried.
2820
- *
2821
- * @param {Date|Number} date - the date to check
2822
- * @returns {Boolean} the date is today
2823
- * @throws {TypeError} 1 argument required
2824
- *
2825
- * @example
2826
- * // If today is 6 October 2014, is 6 October 14:00:00 today?
2827
- * const result = isToday(new Date(2014, 9, 6, 14, 0))
2828
- * //=> true
2829
- */
2830
- function isToday(dirtyDate) {
2831
- requiredArgs(1, arguments);
2832
- return isSameDay(dirtyDate, Date.now());
2833
- }
2834
-
2835
- /**
2836
- * @name subDays
2837
- * @category Day Helpers
2838
- * @summary Subtract the specified number of days from the given date.
2839
- *
2840
- * @description
2841
- * Subtract the specified number of days from the given date.
2842
- *
2843
- * @param {Date|Number} date - the date to be changed
2844
- * @param {Number} amount - the amount of days to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
2845
- * @returns {Date} the new date with the days subtracted
2846
- * @throws {TypeError} 2 arguments required
2847
- *
2848
- * @example
2849
- * // Subtract 10 days from 1 September 2014:
2850
- * const result = subDays(new Date(2014, 8, 1), 10)
2851
- * //=> Fri Aug 22 2014 00:00:00
2852
- */
2853
- function subDays(dirtyDate, dirtyAmount) {
2854
- requiredArgs(2, arguments);
2855
- var amount = toInteger(dirtyAmount);
2856
- return addDays(dirtyDate, -amount);
2857
- }
2858
-
2859
- /**
2860
- * @name parseISO
2861
- * @category Common Helpers
2862
- * @summary Parse ISO string
2863
- *
2864
- * @description
2865
- * Parse the given string in ISO 8601 format and return an instance of Date.
2866
- *
2867
- * Function accepts complete ISO 8601 formats as well as partial implementations.
2868
- * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
2869
- *
2870
- * If the argument isn't a string, the function cannot parse the string or
2871
- * the values are invalid, it returns Invalid Date.
2872
- *
2873
- * @param {String} argument - the value to convert
2874
- * @param {Object} [options] - an object with options.
2875
- * @param {0|1|2} [options.additionalDigits=2] - the additional number of digits in the extended year format
2876
- * @returns {Date} the parsed date in the local time zone
2877
- * @throws {TypeError} 1 argument required
2878
- * @throws {RangeError} `options.additionalDigits` must be 0, 1 or 2
2879
- *
2880
- * @example
2881
- * // Convert string '2014-02-11T11:30:30' to date:
2882
- * const result = parseISO('2014-02-11T11:30:30')
2883
- * //=> Tue Feb 11 2014 11:30:30
2884
- *
2885
- * @example
2886
- * // Convert string '+02014101' to date,
2887
- * // if the additional number of digits in the extended year format is 1:
2888
- * const result = parseISO('+02014101', { additionalDigits: 1 })
2889
- * //=> Fri Apr 11 2014 00:00:00
2890
- */
2891
- function parseISO(argument, options) {
2892
- var _options$additionalDi;
2893
- requiredArgs(1, arguments);
2894
- var additionalDigits = toInteger((_options$additionalDi = options === null || options === void 0 ? void 0 : options.additionalDigits) !== null && _options$additionalDi !== void 0 ? _options$additionalDi : 2);
2895
- if (additionalDigits !== 2 && additionalDigits !== 1 && additionalDigits !== 0) {
2896
- throw new RangeError('additionalDigits must be 0, 1 or 2');
2897
- }
2898
- if (!(typeof argument === 'string' || Object.prototype.toString.call(argument) === '[object String]')) {
2899
- return new Date(NaN);
2900
- }
2901
- var dateStrings = splitDateString(argument);
2902
- var date;
2903
- if (dateStrings.date) {
2904
- var parseYearResult = parseYear(dateStrings.date, additionalDigits);
2905
- date = parseDate(parseYearResult.restDateString, parseYearResult.year);
2906
- }
2907
- if (!date || isNaN(date.getTime())) {
2908
- return new Date(NaN);
2909
- }
2910
- var timestamp = date.getTime();
2911
- var time = 0;
2912
- var offset;
2913
- if (dateStrings.time) {
2914
- time = parseTime(dateStrings.time);
2915
- if (isNaN(time)) {
2916
- return new Date(NaN);
2917
- }
2918
- }
2919
- if (dateStrings.timezone) {
2920
- offset = parseTimezone(dateStrings.timezone);
2921
- if (isNaN(offset)) {
2922
- return new Date(NaN);
2923
- }
2924
- } else {
2925
- var dirtyDate = new Date(timestamp + time);
2926
- // js parsed string assuming it's in UTC timezone
2927
- // but we need it to be parsed in our timezone
2928
- // so we use utc values to build date in our timezone.
2929
- // Year values from 0 to 99 map to the years 1900 to 1999
2930
- // so set year explicitly with setFullYear.
2931
- var result = new Date(0);
2932
- result.setFullYear(dirtyDate.getUTCFullYear(), dirtyDate.getUTCMonth(), dirtyDate.getUTCDate());
2933
- result.setHours(dirtyDate.getUTCHours(), dirtyDate.getUTCMinutes(), dirtyDate.getUTCSeconds(), dirtyDate.getUTCMilliseconds());
2934
- return result;
2935
- }
2936
- return new Date(timestamp + time + offset);
2937
- }
2938
- var patterns = {
2939
- dateTimeDelimiter: /[T ]/,
2940
- timeZoneDelimiter: /[Z ]/i,
2941
- timezone: /([Z+-].*)$/
2942
- };
2943
- var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
2944
- var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
2945
- var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
2946
- function splitDateString(dateString) {
2947
- var dateStrings = {};
2948
- var array = dateString.split(patterns.dateTimeDelimiter);
2949
- var timeString;
2950
-
2951
- // The regex match should only return at maximum two array elements.
2952
- // [date], [time], or [date, time].
2953
- if (array.length > 2) {
2954
- return dateStrings;
2955
- }
2956
- if (/:/.test(array[0])) {
2957
- timeString = array[0];
2958
- } else {
2959
- dateStrings.date = array[0];
2960
- timeString = array[1];
2961
- if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
2962
- dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
2963
- timeString = dateString.substr(dateStrings.date.length, dateString.length);
2964
- }
2965
- }
2966
- if (timeString) {
2967
- var token = patterns.timezone.exec(timeString);
2968
- if (token) {
2969
- dateStrings.time = timeString.replace(token[1], '');
2970
- dateStrings.timezone = token[1];
2971
- } else {
2972
- dateStrings.time = timeString;
2973
- }
2974
- }
2975
- return dateStrings;
2976
- }
2977
- function parseYear(dateString, additionalDigits) {
2978
- var regex = new RegExp('^(?:(\\d{4}|[+-]\\d{' + (4 + additionalDigits) + '})|(\\d{2}|[+-]\\d{' + (2 + additionalDigits) + '})$)');
2979
- var captures = dateString.match(regex);
2980
- // Invalid ISO-formatted year
2981
- if (!captures) return {
2982
- year: NaN,
2983
- restDateString: ''
2984
- };
2985
- var year = captures[1] ? parseInt(captures[1]) : null;
2986
- var century = captures[2] ? parseInt(captures[2]) : null;
2987
-
2988
- // either year or century is null, not both
2989
- return {
2990
- year: century === null ? year : century * 100,
2991
- restDateString: dateString.slice((captures[1] || captures[2]).length)
2992
- };
2993
- }
2994
- function parseDate(dateString, year) {
2995
- // Invalid ISO-formatted year
2996
- if (year === null) return new Date(NaN);
2997
- var captures = dateString.match(dateRegex);
2998
- // Invalid ISO-formatted string
2999
- if (!captures) return new Date(NaN);
3000
- var isWeekDate = !!captures[4];
3001
- var dayOfYear = parseDateUnit(captures[1]);
3002
- var month = parseDateUnit(captures[2]) - 1;
3003
- var day = parseDateUnit(captures[3]);
3004
- var week = parseDateUnit(captures[4]);
3005
- var dayOfWeek = parseDateUnit(captures[5]) - 1;
3006
- if (isWeekDate) {
3007
- if (!validateWeekDate(year, week, dayOfWeek)) {
3008
- return new Date(NaN);
3009
- }
3010
- return dayOfISOWeekYear(year, week, dayOfWeek);
3011
- } else {
3012
- var date = new Date(0);
3013
- if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
3014
- return new Date(NaN);
3015
- }
3016
- date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
3017
- return date;
3018
- }
3019
- }
3020
- function parseDateUnit(value) {
3021
- return value ? parseInt(value) : 1;
3022
- }
3023
- function parseTime(timeString) {
3024
- var captures = timeString.match(timeRegex);
3025
- if (!captures) return NaN; // Invalid ISO-formatted time
3026
-
3027
- var hours = parseTimeUnit(captures[1]);
3028
- var minutes = parseTimeUnit(captures[2]);
3029
- var seconds = parseTimeUnit(captures[3]);
3030
- if (!validateTime(hours, minutes, seconds)) {
3031
- return NaN;
3032
- }
3033
- return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000;
3034
- }
3035
- function parseTimeUnit(value) {
3036
- return value && parseFloat(value.replace(',', '.')) || 0;
3037
- }
3038
- function parseTimezone(timezoneString) {
3039
- if (timezoneString === 'Z') return 0;
3040
- var captures = timezoneString.match(timezoneRegex);
3041
- if (!captures) return 0;
3042
- var sign = captures[1] === '+' ? -1 : 1;
3043
- var hours = parseInt(captures[2]);
3044
- var minutes = captures[3] && parseInt(captures[3]) || 0;
3045
- if (!validateTimezone(hours, minutes)) {
3046
- return NaN;
3047
- }
3048
- return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
3049
- }
3050
- function dayOfISOWeekYear(isoWeekYear, week, day) {
3051
- var date = new Date(0);
3052
- date.setUTCFullYear(isoWeekYear, 0, 4);
3053
- var fourthOfJanuaryDay = date.getUTCDay() || 7;
3054
- var diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
3055
- date.setUTCDate(date.getUTCDate() + diff);
3056
- return date;
3057
- }
3058
-
3059
- // Validation functions
3060
-
3061
- // February is null to handle the leap year (using ||)
3062
- var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
3063
- function isLeapYearIndex(year) {
3064
- return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
3065
- }
3066
- function validateDate(year, month, date) {
3067
- return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
3068
- }
3069
- function validateDayOfYearDate(year, dayOfYear) {
3070
- return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
3071
- }
3072
- function validateWeekDate(_year, week, day) {
3073
- return week >= 1 && week <= 53 && day >= 0 && day <= 6;
3074
- }
3075
- function validateTime(hours, minutes, seconds) {
3076
- if (hours === 24) {
3077
- return minutes === 0 && seconds === 0;
3078
- }
3079
- return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
3080
- }
3081
- function validateTimezone(_hours, minutes) {
3082
- return minutes >= 0 && minutes <= 59;
3083
- }
3084
-
3085
- /**
3086
- * @name subMonths
3087
- * @category Month Helpers
3088
- * @summary Subtract the specified number of months from the given date.
3089
- *
3090
- * @description
3091
- * Subtract the specified number of months from the given date.
3092
- *
3093
- * @param {Date|Number} date - the date to be changed
3094
- * @param {Number} amount - the amount of months to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
3095
- * @returns {Date} the new date with the months subtracted
3096
- * @throws {TypeError} 2 arguments required
3097
- *
3098
- * @example
3099
- * // Subtract 5 months from 1 February 2015:
3100
- * const result = subMonths(new Date(2015, 1, 1), 5)
3101
- * //=> Mon Sep 01 2014 00:00:00
3102
- */
3103
- function subMonths(dirtyDate, dirtyAmount) {
3104
- requiredArgs(2, arguments);
3105
- var amount = toInteger(dirtyAmount);
3106
- return addMonths(dirtyDate, -amount);
3107
- }
3108
-
3109
- /**
3110
- * @name subWeeks
3111
- * @category Week Helpers
3112
- * @summary Subtract the specified number of weeks from the given date.
3113
- *
3114
- * @description
3115
- * Subtract the specified number of weeks from the given date.
3116
- *
3117
- * @param {Date|Number} date - the date to be changed
3118
- * @param {Number} amount - the amount of weeks to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.
3119
- * @returns {Date} the new date with the weeks subtracted
3120
- * @throws {TypeError} 2 arguments required
3121
- *
3122
- * @example
3123
- * // Subtract 4 weeks from 1 September 2014:
3124
- * const result = subWeeks(new Date(2014, 8, 1), 4)
3125
- * //=> Mon Aug 04 2014 00:00:00
3126
- */
3127
- function subWeeks(dirtyDate, dirtyAmount) {
3128
- requiredArgs(2, arguments);
3129
- var amount = toInteger(dirtyAmount);
3130
- return addWeeks(dirtyDate, -amount);
3131
- }
3132
-
3133
- var dateFormats$1 = {
3134
- full: 'EEEE, d MMMM yyyy',
3135
- long: 'd MMMM yyyy',
3136
- medium: 'd MMM yyyy',
3137
- short: 'dd/MM/yyyy'
3138
- };
3139
- var timeFormats$1 = {
3140
- full: 'h:mm:ss a zzzz',
3141
- long: 'h:mm:ss a z',
3142
- medium: 'h:mm:ss a',
3143
- short: 'h:mm a'
3144
- };
3145
- var dateTimeFormats$1 = {
3146
- full: "{{date}} 'at' {{time}}",
3147
- long: "{{date}} 'at' {{time}}",
3148
- medium: '{{date}}, {{time}}',
3149
- short: '{{date}}, {{time}}'
3150
- };
3151
- var formatLong$2 = {
3152
- date: buildFormatLongFn({
3153
- formats: dateFormats$1,
3154
- defaultWidth: 'full'
3155
- }),
3156
- time: buildFormatLongFn({
3157
- formats: timeFormats$1,
3158
- defaultWidth: 'full'
3159
- }),
3160
- dateTime: buildFormatLongFn({
3161
- formats: dateTimeFormats$1,
3162
- defaultWidth: 'full'
3163
- })
3164
- };
3165
- const formatLong$3 = formatLong$2;
3166
-
3167
- /**
3168
- * @type {Locale}
3169
- * @category Locales
3170
- * @summary English locale (Australia).
3171
- * @language English
3172
- * @iso-639-2 eng
3173
- * @author Julien Malige [@JulienMalige]{@link https://github.com/JulienMalige}
3174
- */
3175
- var locale$1 = {
3176
- code: 'en-AU',
3177
- formatDistance: formatDistance$3,
3178
- formatLong: formatLong$3,
3179
- formatRelative: formatRelative$3,
3180
- localize: localize$3,
3181
- match: match$3,
3182
- options: {
3183
- weekStartsOn: 1 /* Monday */,
3184
- firstWeekContainsDate: 4
3185
- }
3186
- };
3187
- const enAU = locale$1;
3188
-
3189
- var formatDistanceLocale = {
3190
- lessThanXSeconds: {
3191
- one: 'menos de um segundo',
3192
- other: 'menos de {{count}} segundos'
3193
- },
3194
- xSeconds: {
3195
- one: '1 segundo',
3196
- other: '{{count}} segundos'
3197
- },
3198
- halfAMinute: 'meio minuto',
3199
- lessThanXMinutes: {
3200
- one: 'menos de um minuto',
3201
- other: 'menos de {{count}} minutos'
3202
- },
3203
- xMinutes: {
3204
- one: '1 minuto',
3205
- other: '{{count}} minutos'
3206
- },
3207
- aboutXHours: {
3208
- one: 'cerca de 1 hora',
3209
- other: 'cerca de {{count}} horas'
3210
- },
3211
- xHours: {
3212
- one: '1 hora',
3213
- other: '{{count}} horas'
3214
- },
3215
- xDays: {
3216
- one: '1 dia',
3217
- other: '{{count}} dias'
3218
- },
3219
- aboutXWeeks: {
3220
- one: 'cerca de 1 semana',
3221
- other: 'cerca de {{count}} semanas'
3222
- },
3223
- xWeeks: {
3224
- one: '1 semana',
3225
- other: '{{count}} semanas'
3226
- },
3227
- aboutXMonths: {
3228
- one: 'cerca de 1 mês',
3229
- other: 'cerca de {{count}} meses'
3230
- },
3231
- xMonths: {
3232
- one: '1 mês',
3233
- other: '{{count}} meses'
3234
- },
3235
- aboutXYears: {
3236
- one: 'cerca de 1 ano',
3237
- other: 'cerca de {{count}} anos'
3238
- },
3239
- xYears: {
3240
- one: '1 ano',
3241
- other: '{{count}} anos'
3242
- },
3243
- overXYears: {
3244
- one: 'mais de 1 ano',
3245
- other: 'mais de {{count}} anos'
3246
- },
3247
- almostXYears: {
3248
- one: 'quase 1 ano',
3249
- other: 'quase {{count}} anos'
3250
- }
3251
- };
3252
- var formatDistance = function formatDistance(token, count, options) {
3253
- var result;
3254
- var tokenValue = formatDistanceLocale[token];
3255
- if (typeof tokenValue === 'string') {
3256
- result = tokenValue;
3257
- } else if (count === 1) {
3258
- result = tokenValue.one;
3259
- } else {
3260
- result = tokenValue.other.replace('{{count}}', String(count));
3261
- }
3262
- if (options !== null && options !== void 0 && options.addSuffix) {
3263
- if (options.comparison && options.comparison > 0) {
3264
- return 'em ' + result;
3265
- } else {
3266
- return 'há ' + result;
3267
- }
3268
- }
3269
- return result;
3270
- };
3271
- const formatDistance$1 = formatDistance;
3272
-
3273
- var dateFormats = {
3274
- full: "EEEE, d 'de' MMMM 'de' y",
3275
- long: "d 'de' MMMM 'de' y",
3276
- medium: 'd MMM y',
3277
- short: 'dd/MM/yyyy'
3278
- };
3279
- var timeFormats = {
3280
- full: 'HH:mm:ss zzzz',
3281
- long: 'HH:mm:ss z',
3282
- medium: 'HH:mm:ss',
3283
- short: 'HH:mm'
3284
- };
3285
- var dateTimeFormats = {
3286
- full: "{{date}} 'às' {{time}}",
3287
- long: "{{date}} 'às' {{time}}",
3288
- medium: '{{date}}, {{time}}',
3289
- short: '{{date}}, {{time}}'
3290
- };
3291
- var formatLong = {
3292
- date: buildFormatLongFn({
3293
- formats: dateFormats,
3294
- defaultWidth: 'full'
3295
- }),
3296
- time: buildFormatLongFn({
3297
- formats: timeFormats,
3298
- defaultWidth: 'full'
3299
- }),
3300
- dateTime: buildFormatLongFn({
3301
- formats: dateTimeFormats,
3302
- defaultWidth: 'full'
3303
- })
3304
- };
3305
- const formatLong$1 = formatLong;
3306
-
3307
- var formatRelativeLocale = {
3308
- lastWeek: function lastWeek(date) {
3309
- var weekday = date.getUTCDay();
3310
- var last = weekday === 0 || weekday === 6 ? 'último' : 'última';
3311
- return "'" + last + "' eeee 'às' p";
3312
- },
3313
- yesterday: "'ontem às' p",
3314
- today: "'hoje às' p",
3315
- tomorrow: "'amanhã às' p",
3316
- nextWeek: "eeee 'às' p",
3317
- other: 'P'
3318
- };
3319
- var formatRelative = function formatRelative(token, date, _baseDate, _options) {
3320
- var format = formatRelativeLocale[token];
3321
- if (typeof format === 'function') {
3322
- return format(date);
3323
- }
3324
- return format;
3325
- };
3326
- const formatRelative$1 = formatRelative;
3327
-
3328
- var eraValues = {
3329
- narrow: ['AC', 'DC'],
3330
- abbreviated: ['AC', 'DC'],
3331
- wide: ['antes de cristo', 'depois de cristo']
3332
- };
3333
- var quarterValues = {
3334
- narrow: ['1', '2', '3', '4'],
3335
- abbreviated: ['T1', 'T2', 'T3', 'T4'],
3336
- wide: ['1º trimestre', '2º trimestre', '3º trimestre', '4º trimestre']
3337
- };
3338
- var monthValues = {
3339
- narrow: ['j', 'f', 'm', 'a', 'm', 'j', 'j', 'a', 's', 'o', 'n', 'd'],
3340
- abbreviated: ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'],
3341
- wide: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro']
3342
- };
3343
- var dayValues = {
3344
- narrow: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
3345
- short: ['dom', 'seg', 'ter', 'qua', 'qui', 'sex', 'sab'],
3346
- abbreviated: ['domingo', 'segunda', 'terça', 'quarta', 'quinta', 'sexta', 'sábado'],
3347
- wide: ['domingo', 'segunda-feira', 'terça-feira', 'quarta-feira', 'quinta-feira', 'sexta-feira', 'sábado']
3348
- };
3349
- var dayPeriodValues = {
3350
- narrow: {
3351
- am: 'a',
3352
- pm: 'p',
3353
- midnight: 'mn',
3354
- noon: 'md',
3355
- morning: 'manhã',
3356
- afternoon: 'tarde',
3357
- evening: 'tarde',
3358
- night: 'noite'
3359
- },
3360
- abbreviated: {
3361
- am: 'AM',
3362
- pm: 'PM',
3363
- midnight: 'meia-noite',
3364
- noon: 'meio-dia',
3365
- morning: 'manhã',
3366
- afternoon: 'tarde',
3367
- evening: 'tarde',
3368
- night: 'noite'
3369
- },
3370
- wide: {
3371
- am: 'a.m.',
3372
- pm: 'p.m.',
3373
- midnight: 'meia-noite',
3374
- noon: 'meio-dia',
3375
- morning: 'manhã',
3376
- afternoon: 'tarde',
3377
- evening: 'tarde',
3378
- night: 'noite'
3379
- }
3380
- };
3381
- var formattingDayPeriodValues = {
3382
- narrow: {
3383
- am: 'a',
3384
- pm: 'p',
3385
- midnight: 'mn',
3386
- noon: 'md',
3387
- morning: 'da manhã',
3388
- afternoon: 'da tarde',
3389
- evening: 'da tarde',
3390
- night: 'da noite'
3391
- },
3392
- abbreviated: {
3393
- am: 'AM',
3394
- pm: 'PM',
3395
- midnight: 'meia-noite',
3396
- noon: 'meio-dia',
3397
- morning: 'da manhã',
3398
- afternoon: 'da tarde',
3399
- evening: 'da tarde',
3400
- night: 'da noite'
3401
- },
3402
- wide: {
3403
- am: 'a.m.',
3404
- pm: 'p.m.',
3405
- midnight: 'meia-noite',
3406
- noon: 'meio-dia',
3407
- morning: 'da manhã',
3408
- afternoon: 'da tarde',
3409
- evening: 'da tarde',
3410
- night: 'da noite'
3411
- }
3412
- };
3413
- var ordinalNumber = function ordinalNumber(dirtyNumber, options) {
3414
- var number = Number(dirtyNumber);
3415
- if ((options === null || options === void 0 ? void 0 : options.unit) === 'week') {
3416
- return number + 'ª';
3417
- }
3418
- return number + 'º';
3419
- };
3420
- var localize = {
3421
- ordinalNumber: ordinalNumber,
3422
- era: buildLocalizeFn({
3423
- values: eraValues,
3424
- defaultWidth: 'wide'
3425
- }),
3426
- quarter: buildLocalizeFn({
3427
- values: quarterValues,
3428
- defaultWidth: 'wide',
3429
- argumentCallback: function argumentCallback(quarter) {
3430
- return quarter - 1;
3431
- }
3432
- }),
3433
- month: buildLocalizeFn({
3434
- values: monthValues,
3435
- defaultWidth: 'wide'
3436
- }),
3437
- day: buildLocalizeFn({
3438
- values: dayValues,
3439
- defaultWidth: 'wide'
3440
- }),
3441
- dayPeriod: buildLocalizeFn({
3442
- values: dayPeriodValues,
3443
- defaultWidth: 'wide',
3444
- formattingValues: formattingDayPeriodValues,
3445
- defaultFormattingWidth: 'wide'
3446
- })
3447
- };
3448
- const localize$1 = localize;
3449
-
3450
- var matchOrdinalNumberPattern = /^(\d+)[ºªo]?/i;
3451
- var parseOrdinalNumberPattern = /\d+/i;
3452
- var matchEraPatterns = {
3453
- narrow: /^(ac|dc|a|d)/i,
3454
- abbreviated: /^(a\.?\s?c\.?|d\.?\s?c\.?)/i,
3455
- wide: /^(antes de cristo|depois de cristo)/i
3456
- };
3457
- var parseEraPatterns = {
3458
- any: [/^ac/i, /^dc/i],
3459
- wide: [/^antes de cristo/i, /^depois de cristo/i]
3460
- };
3461
- var matchQuarterPatterns = {
3462
- narrow: /^[1234]/i,
3463
- abbreviated: /^T[1234]/i,
3464
- wide: /^[1234](º)? trimestre/i
3465
- };
3466
- var parseQuarterPatterns = {
3467
- any: [/1/i, /2/i, /3/i, /4/i]
3468
- };
3469
- var matchMonthPatterns = {
3470
- narrow: /^[jfmajsond]/i,
3471
- abbreviated: /^(jan|fev|mar|abr|mai|jun|jul|ago|set|out|nov|dez)/i,
3472
- wide: /^(janeiro|fevereiro|março|abril|maio|junho|julho|agosto|setembro|outubro|novembro|dezembro)/i
3473
- };
3474
- var parseMonthPatterns = {
3475
- narrow: [/^j/i, /^f/i, /^m/i, /^a/i, /^m/i, /^j/i, /^j/i, /^a/i, /^s/i, /^o/i, /^n/i, /^d/i],
3476
- any: [/^ja/i, /^fev/i, /^mar/i, /^abr/i, /^mai/i, /^jun/i, /^jul/i, /^ago/i, /^set/i, /^out/i, /^nov/i, /^dez/i]
3477
- };
3478
- var matchDayPatterns = {
3479
- narrow: /^(dom|[23456]ª?|s[aá]b)/i,
3480
- short: /^(dom|[23456]ª?|s[aá]b)/i,
3481
- abbreviated: /^(dom|seg|ter|qua|qui|sex|s[aá]b)/i,
3482
- wide: /^(domingo|(segunda|ter[cç]a|quarta|quinta|sexta)([- ]feira)?|s[aá]bado)/i
3483
- };
3484
- var parseDayPatterns = {
3485
- short: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
3486
- narrow: [/^d/i, /^2/i, /^3/i, /^4/i, /^5/i, /^6/i, /^s[aá]/i],
3487
- any: [/^d/i, /^seg/i, /^t/i, /^qua/i, /^qui/i, /^sex/i, /^s[aá]b/i]
3488
- };
3489
- var matchDayPeriodPatterns = {
3490
- narrow: /^(a|p|mn|md|(da) (manhã|tarde|noite))/i,
3491
- any: /^([ap]\.?\s?m\.?|meia[-\s]noite|meio[-\s]dia|(da) (manhã|tarde|noite))/i
3492
- };
3493
- var parseDayPeriodPatterns = {
3494
- any: {
3495
- am: /^a/i,
3496
- pm: /^p/i,
3497
- midnight: /^mn|^meia[-\s]noite/i,
3498
- noon: /^md|^meio[-\s]dia/i,
3499
- morning: /manhã/i,
3500
- afternoon: /tarde/i,
3501
- evening: /tarde/i,
3502
- night: /noite/i
3503
- }
3504
- };
3505
- var match = {
3506
- ordinalNumber: buildMatchPatternFn({
3507
- matchPattern: matchOrdinalNumberPattern,
3508
- parsePattern: parseOrdinalNumberPattern,
3509
- valueCallback: function valueCallback(value) {
3510
- return parseInt(value, 10);
3511
- }
3512
- }),
3513
- era: buildMatchFn({
3514
- matchPatterns: matchEraPatterns,
3515
- defaultMatchWidth: 'wide',
3516
- parsePatterns: parseEraPatterns,
3517
- defaultParseWidth: 'any'
3518
- }),
3519
- quarter: buildMatchFn({
3520
- matchPatterns: matchQuarterPatterns,
3521
- defaultMatchWidth: 'wide',
3522
- parsePatterns: parseQuarterPatterns,
3523
- defaultParseWidth: 'any',
3524
- valueCallback: function valueCallback(index) {
3525
- return index + 1;
3526
- }
3527
- }),
3528
- month: buildMatchFn({
3529
- matchPatterns: matchMonthPatterns,
3530
- defaultMatchWidth: 'wide',
3531
- parsePatterns: parseMonthPatterns,
3532
- defaultParseWidth: 'any'
3533
- }),
3534
- day: buildMatchFn({
3535
- matchPatterns: matchDayPatterns,
3536
- defaultMatchWidth: 'wide',
3537
- parsePatterns: parseDayPatterns,
3538
- defaultParseWidth: 'any'
3539
- }),
3540
- dayPeriod: buildMatchFn({
3541
- matchPatterns: matchDayPeriodPatterns,
3542
- defaultMatchWidth: 'any',
3543
- parsePatterns: parseDayPeriodPatterns,
3544
- defaultParseWidth: 'any'
3545
- })
3546
- };
3547
- const match$1 = match;
3548
-
3549
- /**
3550
- * @type {Locale}
3551
- * @category Locales
3552
- * @summary Portuguese locale (Brazil).
3553
- * @language Portuguese
3554
- * @iso-639-2 por
3555
- * @author Lucas Duailibe [@duailibe]{@link https://github.com/duailibe}
3556
- * @author Yago Carballo [@yagocarballo]{@link https://github.com/YagoCarballo}
3557
- */
3558
- var locale = {
3559
- code: 'pt-BR',
3560
- formatDistance: formatDistance$1,
3561
- formatLong: formatLong$1,
3562
- formatRelative: formatRelative$1,
3563
- localize: localize$1,
3564
- match: match$1,
3565
- options: {
3566
- weekStartsOn: 0 /* Sunday */,
3567
- firstWeekContainsDate: 1
3568
- }
3569
- };
3570
- const ptBR = locale;
3571
-
3572
- const curaCalendarCss = ":host{display:block;width:var(--width)}:host .calendar{display:flex;flex-direction:column;gap:5px;width:var(--width);padding:0 12px 12px 12px;min-width:280px;border:1px solid var(--neutral-light);border-radius:4px;overflow:hidden;background:#fff;box-shadow:0 4px 8px var(--neutral-light);font-family:var(--font-family)}:host .header{position:relative;padding:12px 0}:host .header::after{content:\"\";position:absolute;bottom:0;left:2px;right:2px;border-bottom:2px dotted var(--neutral-light)}:host .month-year{display:flex;padding:12px 8px;justify-content:space-between;align-self:stretch}:host .month-year.dropdown{padding:0%}:host .select{display:flex;padding:0px 12px;justify-content:center;align-items:center;gap:6px;flex:1 0 0}:host .drop-month{display:flex;max-width:118px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .drop-year{display:flex;min-width:80px;max-width:85px;padding:0px;align-items:flex-start;gap:0px;flex:1 0 0}:host .days-of-week{display:flex;height:30px;padding:4px;justify-content:center;align-items:center;gap:4px;flex-shrink:0}:host .day{flex:1;text-align:center}:host .dates{display:flex;flex-wrap:wrap;align-items:center;align-self:stretch;gap:0}:host .icon{cursor:pointer;position:relative;overflow:hidden;border-radius:50%}:host .icon.dropdown{margin-top:10px}:host .icon::before{content:\"\";position:absolute;border-radius:50%;top:50%;left:50%;width:20px;height:20px;background:var(--accent-base);transform:translate(-50%, -50%) scale(0);transition:transform 0.2s ease}:host .icon:active::before{transform:translate(-50%, -50%) scale(1)}:host .icon:active{transform:scale(1)}:host .collapsed-container{text-align:center;position:relative;display:flex;align-items:center;justify-content:center;padding-top:10px}:host .collapsed-container::before{content:\"\";position:absolute;bottom:0;top:0;left:2px;right:2px;border-top:2px dotted var(--neutral-light)}:host .date{display:flex;justify-content:center;align-items:center;height:auto;width:14.2857142857%;aspect-ratio:1;font-size:14px;cursor:pointer;position:relative;box-sizing:border-box;text-align:center;flex-shrink:0}:host .date.today{border:2px solid var(--primary-darker);border-radius:50%;color:var(--primary-darker)}:host .date.selected,:host .date.default-dates{color:var(--neutral-black) !important;background:var(--accent-base);border-radius:50%;border:none}:host .date.invalid{color:var(--neutral-dark) !important;cursor:not-allowed}:host .date.invalid:hover{background:none;box-shadow:none}:host .date.valid{color:var(--primary-darker);font-weight:var(--font-weight-bold)}:host .date.range.start{border-radius:50% 0 0 50%;color:var(--primary-darker) !important;background:var(--accent-base)}:host .date.range.interval{border-radius:0;background-color:var(--accent-light);color:var(--neutral-black)}:host .date.range.interval.today{border:none}:host .date.range.end{border-radius:0 50% 50% 0;color:var(--primary-darker) !important;background:var(--accent-base)}:host .date:hover{background:var(--accent-light);border-radius:50%;color:var(--neutral-black)}:host select,:host input{width:60px;font-size:16px;box-shadow:0 2px 2px var(--neutral-black);padding:5px;border-radius:4px;border:1px solid #ccc;background:#f7f7f7}";
3573
- const CuraCalendarStyle0 = curaCalendarCss;
3574
-
3575
- const CuraCalendar$1 = /*@__PURE__*/ proxyCustomElement(class CuraCalendar extends HTMLElement {
3576
- constructor() {
3577
- super();
3578
- this.__registerHost();
3579
- this.__attachShadow();
3580
- this.onchangeday = createEvent(this, "onchangeday", 7);
3581
- this.theme = window.CuraAPI.theme;
3582
- this.weights = this.theme.fonts.getWeights();
3583
- this.optionsLocale = { 'pt-BR': ptBR, 'en-US': enAU };
3584
- this.period = null;
3585
- this.width = '280px';
3586
- this.mode = 'single';
3587
- this.dateFormat = 'yyyy-MM-dd';
3588
- this.locale = 'pt-BR';
3589
- this.type = 'dropdown';
3590
- this.disable = [];
3591
- this.enable = [];
3592
- this.defaultDate = [];
3593
- this.limitRange = null;
3594
- this.disablePassDates = false;
3595
- this.collapsed = null;
3596
- this.currentDate = new Date();
3597
- this.selectedDates = [];
3598
- this.rangeStart = null;
3599
- this.defaultDates = [];
3600
- this.selectMonth = '';
3601
- this.selectYear = '';
3602
- this.styles = {};
3603
- }
3604
- connectedCallback() {
3605
- this.initializeDefaultDates();
3606
- this.setFontProperties();
3607
- const colors = [
3608
- { name: '--accent-base', theme: 'accent-base' },
3609
- { name: '--accent-light', theme: 'accent-light' },
3610
- { name: '--neutral-black', theme: 'neutral-black' },
3611
- { name: '--primary-darker', theme: 'primary-darker' },
3612
- { name: '--neutral-dark', theme: 'neutral-dark' },
3613
- { name: '--neutral-light', theme: 'neutral-light' },
3614
- ];
3615
- colors.forEach(color => this.styles = Object.assign(Object.assign({}, this.styles), { [color.name]: this.theme.colors.getColor(color.theme) }));
3616
- }
3617
- setFontProperties() {
3618
- this.styles['--font-family'] = window.CuraAPI.theme.fonts.getFamily();
3619
- this.styles['--font-size'] = window.CuraAPI.theme.fonts.getSize();
3620
- this.styles['--font-color'] = window.CuraAPI.theme.fonts.getColor();
3621
- this.styles['--font-weight-medium'] = this.weights.medium;
3622
- this.styles['--font-weight-bold'] = this.weights.bold;
3623
- this.styles['--font-weight-regular'] = this.weights.regular;
3624
- }
3625
- /**
3626
- * Initialize the selected dates based on defaultDate and mode.
3627
- */
3628
- initializeDefaultDates() {
3629
- this.defaultDates = this.expandDateRanges(this.defaultDate);
3630
- }
3631
- /**
3632
- * Get the locale for the calendar.
3633
- *
3634
- * @returns {Locale} The locale object.
3635
- */
3636
- determineLocale() {
3637
- return this.optionsLocale[this.locale] || this.locale;
3638
- }
3639
- /**
3640
- * Check if a date is within the valid period.
3641
- *
3642
- * @param {Date} date - The date to check.
3643
- * @returns {boolean} Whether the date is valid.
3644
- */
3645
- isDateInValidPeriod(date) {
3646
- if (this.period === null) {
3647
- return true;
3648
- }
3649
- return this.period.includes(format(date, this.dateFormat));
3650
- }
3651
- /**
3652
- * Check if a date is selected.
3653
- *
3654
- * @param {Date} date - The date to check.
3655
- * @returns {boolean} Whether the date is selected.
3656
- */
3657
- isDateSelected(date) {
3658
- return this.isDateInList(this.selectedDates, date);
3659
- }
3660
- /**
3661
- * Check if has date in defaultDates.
3662
- *
3663
- * @param {Date} date - The date to check.
3664
- * @returns {boolean} Whether the date is selected.
3665
- */
3666
- isDateInDefaultSelection(date) {
3667
- return this.isDateInList(this.defaultDates, date);
3668
- }
3669
- /**
3670
- * Check if a date is within a disabled period.
3671
- *
3672
- * @param {Date} date - The date to check.
3673
- * @returns {boolean} Whether the date is disabled.
3674
- */
3675
- isDateInDisabledPeriod(date) {
3676
- const today = new Date();
3677
- today.setHours(0, 0, 0, 0);
3678
- if (this.disablePassDates)
3679
- return isBefore(date, today);
3680
- if (this.disable === null)
3681
- return false;
3682
- return this.isDateInList(this.expandDateRanges(this.disable), date);
3683
- }
3684
- /**
3685
- * Check if a date is within an enabled period.
3686
- *
3687
- * @param {Date} date - The date to check.
3688
- * @returns {boolean} Whether the date is enabled.
3689
- */
3690
- isDateInEnabledPeriod(date) {
3691
- if (this.enable === null || [])
3692
- return true;
3693
- return this.isDateInList(this.expandDateRanges(this.enable), date);
3694
- }
3695
- /**
3696
- * Checks if a date is in the provided list of dates.
3697
- *
3698
- * @param {Date[]} dates - The list of dates to check against.
3699
- * @param {Date} date - The date to check.
3700
- * @returns {boolean} Whether the date is in the list.
3701
- */
3702
- isDateInList(dates, date) {
3703
- return dates.some(d => isSameDay(d, date));
3704
- }
3705
- /**
3706
- * Removes a specific date from a list of dates.
3707
- *
3708
- * @param {Date[]} dates - The array of dates to filter.
3709
- * @param {Date} dateToRemove - The date to remove from the array.
3710
- * @returns {Date[]} A new array with the specified date removed.
3711
- */
3712
- removeDateFromSelection(dates, dateToRemove) {
3713
- return dates.filter(d => !isSameDay(d, dateToRemove));
3714
- }
3715
- /**
3716
- * Change the current month.
3717
- *
3718
- * @param {string} direction - 'prev' | 'next'
3719
- */
3720
- updateCurrentMonth(direction) {
3721
- let newMonth = new Date(this.currentDate);
3722
- if (direction === 'prev')
3723
- newMonth = subMonths(this.currentDate, 1);
3724
- if (direction === 'next')
3725
- newMonth = addMonths(this.currentDate, 1);
3726
- this.currentDate = newMonth;
3727
- }
3728
- /**
3729
- * Handle the month dropdown change.
3730
- *
3731
- * @param {CustomEvent} event - The change event.
3732
- */
3733
- onMonthDropdownChange(event) {
3734
- const { months } = this.fetchMonthNames();
3735
- const newMonth = event.detail;
3736
- this.selectMonth = newMonth;
3737
- this.currentDate = new Date(getYear(this.currentDate), months.indexOf(newMonth), 1);
3738
- }
3739
- /**
3740
- * Handle the year input change.
3741
- *
3742
- * @param {CustomEvent} event - The change event.
3743
- */
3744
- onYearDropdownChange(event) {
3745
- const newYear = event.detail;
3746
- this.selectYear = newYear;
3747
- this.currentDate = new Date(newYear, getMonth(this.currentDate), 1);
3748
- }
3749
- /**
3750
- * Flatten date ranges into individual dates.
3751
- *
3752
- * @param {({ from: string; to: string } | string)[]} dates - An array of date ranges or individual dates.
3753
- * @returns {Date[]} An array of individual dates.
3754
- */
3755
- expandDateRanges(dates) {
3756
- return dates.flatMap(date => {
3757
- if (typeof date === 'string')
3758
- return isValid(parseISO(date)) ? [parseISO(date)] : [];
3759
- const start = parseISO(date.from);
3760
- const end = parseISO(date.to);
3761
- if (isValid(start) && isValid(end) && start <= end)
3762
- return eachDayOfInterval({ start, end });
3763
- return [];
3764
- });
3765
- }
3766
- /**
3767
- * Handle single date selection.
3768
- *
3769
- * @param {Date} date - The date to select.
3770
- */
3771
- selectSingleDate(date) {
3772
- this.defaultDates = [];
3773
- this.selectedDates = [date];
3774
- }
3775
- /**
3776
- * Handle multiple date selection.
3777
- *
3778
- * @param {Date} date - The date to select or deselect.
3779
- */
3780
- selectMultiplesDate(date) {
3781
- if (!this.isDateSelected(date) || !this.isDateInDefaultSelection(date))
3782
- return this.selectedDates = [...this.selectedDates, date];
3783
- this.selectedDates = this.removeDateFromSelection(this.selectedDates, date);
3784
- this.defaultDates = this.removeDateFromSelection(this.defaultDates, date);
3785
- }
3786
- /**
3787
- * Handle range date selection.
3788
- *
3789
- * @param {Date} date - The date to select.
3790
- */
3791
- selectDateRange(date) {
3792
- this.defaultDates = [];
3793
- const start = isBefore(this.rangeStart, date) ? this.rangeStart : date;
3794
- const end = isAfter(this.rangeStart, date) ? this.rangeStart : date;
3795
- const range = eachDayOfInterval({ start, end });
3796
- if (!this.rangeStart || this.selectedDates.length === 2) {
3797
- this.rangeStart = date;
3798
- this.selectedDates = [date];
3799
- return;
3800
- }
3801
- if (this.limitRange === null || range.length <= this.limitRange) {
3802
- this.selectedDates = range;
3803
- this.rangeStart = null;
3804
- }
3805
- }
3806
- /**
3807
- * Handle a click on a date.
3808
- *
3809
- * @param {Date} date - The date that was clicked.
3810
- */
3811
- onDateClick(date) {
3812
- if (!this.isDateInValidPeriod(date) || this.isDateInDisabledPeriod(date) || !this.isDateInEnabledPeriod(date))
3813
- return;
3814
- const selectionHandlers = {
3815
- single: this.selectSingleDate.bind(this),
3816
- multiple: this.selectMultiplesDate.bind(this),
3817
- range: this.selectDateRange.bind(this)
3818
- };
3819
- selectionHandlers[this.mode](date);
3820
- this.onchangeday.emit({ days: [...this.defaultDates, ...this.selectedDates].filter(d => this.isDateInValidPeriod(d)) });
3821
- }
3822
- /**
3823
- * Get the days of the week.
3824
- *
3825
- * @returns {string[]} An array of abbreviated day names.
3826
- */
3827
- fetchWeekDays() {
3828
- const start = startOfWeek(new Date(2021, 0, 3), { locale: this.determineLocale() });
3829
- const end = endOfWeek(new Date(2021, 0, 3), { locale: this.determineLocale() });
3830
- return eachDayOfInterval({ start, end }).map(day => format(day, 'EEEEEE', { locale: this.determineLocale() }));
3831
- }
3832
- /**
3833
- * Get the days of the current month, including leading nulls for alignment.
3834
- *
3835
- * @returns {(Date | null)[]} An array of dates and nulls for the current month view.
3836
- */
3837
- showNotColapsedCalendar() {
3838
- if (this.collapsed) {
3839
- this.fetchDaysOfWeek();
3840
- }
3841
- else
3842
- (this.fetchDaysOfMonth());
3843
- this.collapsed = false;
3844
- }
3845
- showColapsedCalendar() {
3846
- this.collapsed = true;
3847
- return this.fetchDaysOfWeek();
3848
- }
3849
- fetchDaysOfWeek() {
3850
- const DAYS_IN_CALENDAR_VIEW = 7;
3851
- const start = startOfWeek(this.currentDate);
3852
- const end = endOfWeek(this.currentDate);
3853
- const daysIncurrentDate = eachDayOfInterval({ start, end });
3854
- return daysIncurrentDate.slice(0, DAYS_IN_CALENDAR_VIEW);
3855
- }
3856
- updateCurrentWeek(direction) {
3857
- let newWeek = new Date(this.currentDate);
3858
- if (direction === 'prev')
3859
- newWeek = subWeeks(this.currentDate, 1);
3860
- if (direction === 'next')
3861
- newWeek = addWeeks(this.currentDate, 1);
3862
- this.currentDate = newWeek;
3863
- }
3864
- fetchDaysOfMonth() {
3865
- const WEEKS_IN_CALENDAR_VIEW = 6;
3866
- const DAYS_IN_CALENDAR_VIEW = 42;
3867
- const start = startOfMonth(this.currentDate);
3868
- const end = endOfMonth(this.currentDate);
3869
- const daysIncurrentDate = eachDayOfInterval({ start, end });
3870
- const prevMonthStart = startOfMonth(addMonths(start, -1));
3871
- const prevMonthEnd = endOfMonth(prevMonthStart);
3872
- const daysInPrevMonth = eachDayOfInterval({
3873
- start: subDays(prevMonthEnd, getDay(start)),
3874
- end: prevMonthEnd
3875
- });
3876
- const nextMonthStart = startOfMonth(addMonths(end, 1));
3877
- const nextMonthEnd = endOfMonth(nextMonthStart);
3878
- const remainingDays = WEEKS_IN_CALENDAR_VIEW - getDay(end);
3879
- const daysInNextMonth = eachDayOfInterval({
3880
- start: nextMonthStart,
3881
- end: addDays(nextMonthEnd, remainingDays)
3882
- });
3883
- const totalDays = [
3884
- ...daysInPrevMonth.slice(-getDay(start)),
3885
- ...daysIncurrentDate,
3886
- ...daysInNextMonth
3887
- ];
3888
- return totalDays.slice(0, DAYS_IN_CALENDAR_VIEW);
3889
- }
3890
- /**
3891
- * Get the names of all months in the current year.
3892
- *
3893
- * @returns {{ months: string[], currentMonth: string }} An object containing an array of month names and the name of the current month.
3894
- */
3895
- fetchMonthNames() {
3896
- const currentYear = getYear(this.currentDate);
3897
- const locale = this.determineLocale();
3898
- const months = eachMonthOfInterval({
3899
- start: startOfYear(new Date(currentYear, 0, 1)),
3900
- end: new Date(currentYear, 11, 31)
3901
- }).map(month => format(month, 'MMMM', { locale }));
3902
- const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
3903
- return {
3904
- months: months.map(capitalize),
3905
- };
3906
- }
3907
- /**
3908
- * Get a list of years in descending order from the current year to a specified limit.
3909
- *
3910
- * @returns {number[]} An array of years.
3911
- */
3912
- fetchYearList() {
3913
- const currentYear = getYear(new Date());
3914
- return Array.from({ length: 100 }, (_, i) => currentYear - i);
3915
- }
3916
- /**
3917
- * Get the color for the previous button.
3918
- *
3919
- * @returns {string} The color name for the previous button.
3920
- */
3921
- determinePrevButtonColor() {
3922
- const isPrevDisabled = isBefore(new Date(getYear(this.currentDate), getMonth(this.currentDate) - 1, 1), startOfMonth(new Date()));
3923
- return isPrevDisabled && 'primary-base';
3924
- }
3925
- /**
3926
- * Get the status of a given date, determining its position and interval status.
3927
- *
3928
- * @param {Date | null} date - The date to evaluate.
3929
- * @returns {Object} An object containing the status flags for the date.
3930
- */
3931
- getDateStatus(date) {
3932
- const [startSelected, endSelected] = [this.selectedDates[0], this.selectedDates[this.selectedDates.length - 1]];
3933
- const [startDefault, endDefault] = [this.defaultDates[0], this.defaultDates[this.defaultDates.length - 1]];
3934
- const hasSelectedDates = this.selectedDates.length > 1;
3935
- const isDateInDefaultSelection = this.defaultDates.length > 1;
3936
- const isStartSelected = this.isDateSelected(date) && isSameDay(date, startSelected);
3937
- const isStartDefault = this.isDateInDefaultSelection(date) && isSameDay(date, startDefault);
3938
- const isEndSelected = this.isDateSelected(date) && isSameDay(date, endSelected);
3939
- const isEndDefault = this.isDateInDefaultSelection(date) && isSameDay(date, endDefault);
3940
- const isStart = isStartSelected || isStartDefault;
3941
- const isEnd = isEndSelected || isEndDefault;
3942
- const selectedIntervals = this.expandDateRanges([{ from: startSelected === null || startSelected === void 0 ? void 0 : startSelected.toISOString(), to: endSelected === null || endSelected === void 0 ? void 0 : endSelected.toISOString() }]);
3943
- const defaultIntervals = this.expandDateRanges([{ from: startDefault === null || startDefault === void 0 ? void 0 : startDefault.toISOString(), to: endDefault === null || endDefault === void 0 ? void 0 : endDefault.toISOString() }]);
3944
- const intervalSelected = hasSelectedDates && this.isDateInList(selectedIntervals, date);
3945
- const intervalDefault = isDateInDefaultSelection && this.isDateInList(defaultIntervals, date);
3946
- const isValid = this.isDateInValidPeriod(date);
3947
- const isInvalid = !isValid || this.isDateInDisabledPeriod(date) || !this.isDateInEnabledPeriod(date);
3948
- const isSelected = this.isDateSelected(date);
3949
- const isRange = this.mode === 'range' && (hasSelectedDates || isDateInDefaultSelection);
3950
- const isDefault = this.mode !== 'range' && this.isDateInDefaultSelection(date);
3951
- const isInterval = (intervalSelected || intervalDefault) && !isStart && !isEnd;
3952
- return {
3953
- isStart,
3954
- isEnd,
3955
- isValid,
3956
- isInvalid,
3957
- isSelected,
3958
- isRange,
3959
- isDefault,
3960
- isInterval
3961
- };
3962
- }
3963
- /**
3964
- * Get the CSS classes for a given date based on its status.
3965
- *
3966
- * @param {Date | null} date - The date to evaluate.
3967
- * @returns {Object} An object containing the CSS classes for the date.
3968
- */
3969
- getClasses(date) {
3970
- const classes = { 'date': true };
3971
- if (date === null)
3972
- return classes;
3973
- const dateStatus = this.getDateStatus(date);
3974
- classes['today'] = isToday(date);
3975
- classes['valid'] = dateStatus.isValid;
3976
- classes['invalid'] = dateStatus.isInvalid;
3977
- classes['selected'] = dateStatus.isSelected;
3978
- classes['range'] = dateStatus.isRange;
3979
- classes['default-dates'] = dateStatus.isDefault;
3980
- classes['start'] = dateStatus.isStart;
3981
- classes['interval'] = dateStatus.isInterval;
3982
- classes['end'] = dateStatus.isEnd;
3983
- return classes;
3984
- }
3985
- /**
3986
- * Get custom CSS properties for the host element.
3987
- *
3988
- * @returns {Object} An object containing CSS properties and their values.
3989
- */
3990
- getHostCSSProperties() {
3991
- return {
3992
- '--width': this.width,
3993
- };
3994
- }
3995
- render() {
3996
- const { months } = this.fetchMonthNames();
3997
- return (h(Host, { key: '49e48240bb1da756c8d4ee8dff554a24b1da8038', style: this.getHostCSSProperties() }, h("div", { key: 'bfa7c4b9362c6a9b3c35639ebb720a3fd2601fa4', class: "calendar", style: this.styles }, h("header", { key: 'aa6803cb2bf8b6f7b58cdd9796921aadfc40abca', class: "header" }, h("div", { key: 'efa9f7c0598677defca5f31220e3b1f0dbc16037', class: `month-year ${this.type === 'dropdown' && 'dropdown'}` }, h("cura-icon", { key: '759a409d176a47c44be9615bf342d8a6d296ded6', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "left", color: this.determinePrevButtonColor(), onClick: !this.collapsed ? () => this.updateCurrentMonth('prev') : () => this.updateCurrentWeek('prev') }), this.type === 'dropdown' ? (h("div", { class: "select" }, h("cura-select", { class: "drop-month", mode: "transparent", value: months[getMonth(this.currentDate)], onSelected: (e) => this.onMonthDropdownChange(e) }, months.map((month, index) => (h("cura-select-option", { key: index, value: month }, month)))), h("cura-select", { class: "drop-year", mode: "transparent", value: getYear(this.currentDate).toString(), onSelected: (e) => this.onYearDropdownChange(e) }, this.fetchYearList().map((year, index) => (h("cura-select-option", { key: index, value: year.toString() }, year.toString())))))) : (h("cura-label", { color: "neutral-black", size: "large" }, months[getMonth(this.currentDate)].slice(0, 3), ", ", getYear(this.currentDate))), h("cura-icon", { key: '650919445aa94fd26b9605da79dbaa1950652c0d', class: `icon ${this.type === 'dropdown' && 'dropdown'}`, name: "right", color: "primary-base", onClick: !this.collapsed ? () => this.updateCurrentMonth('next') : () => this.updateCurrentWeek('next') }))), h("span", { key: '3934dec68753250503976b462b6589327b7be613', class: "days-of-week" }, this.fetchWeekDays().map((day, index) => (h("cura-label", { class: "day", size: "xsmall", color: "neutral-black", weight: 'bold', key: index }, day === 'sab' ? 'SÁB' : day.toLocaleUpperCase())))), h("div", { key: '47e46d363c972877b97889c3c5756c14d42046de', class: "dates" }, !this.collapsed ?
3998
- this.fetchDaysOfMonth().map((day, index) => (h("div", { key: index, class: this.getClasses(day), onClick: () => this.onDateClick(day) }, day ? format(day, 'd') : ''))) :
3999
- this.fetchDaysOfWeek().map((day, index) => (h("div", { key: index, class: this.getClasses(day), onClick: () => this.onDateClick(day) }, day ? format(day, 'd') : '')))), this.collapsed !== null ? (this.collapsed ? (h("div", { class: 'collapsed-container' }, h("cura-button-transparent", { onClick: () => this.showNotColapsedCalendar(), size: 'small', color: 'primary', fontColor: 'dark', iconName: 'plusCircle' }, "Veja mais datas"))) : (h("div", { class: 'collapsed-container' }, h("cura-button-transparent", { onClick: () => this.showColapsedCalendar(), size: 'small', color: 'primary', fontColor: 'dark', iconName: 'minusCircle' }, "Veja menos datas")))) : null)));
4000
- }
4001
- static get style() { return CuraCalendarStyle0; }
4002
- }, [1, "cura-calendar", {
4003
- "period": [513],
4004
- "width": [513],
4005
- "mode": [513],
4006
- "dateFormat": [1537, "date-format"],
4007
- "locale": [513],
4008
- "type": [513],
4009
- "disable": [16],
4010
- "enable": [16],
4011
- "defaultDate": [16],
4012
- "limitRange": [514, "limit-range"],
4013
- "disablePassDates": [1540, "disable-pass-dates"],
4014
- "collapsed": [1540],
4015
- "currentDate": [32],
4016
- "selectedDates": [32],
4017
- "rangeStart": [32],
4018
- "defaultDates": [32],
4019
- "selectMonth": [32],
4020
- "selectYear": [32],
4021
- "styles": [32]
4022
- }]);
4023
- function defineCustomElement$1() {
4024
- if (typeof customElements === "undefined") {
4025
- return;
4026
- }
4027
- const components = ["cura-calendar", "cura-button-transparent", "cura-icon", "cura-label", "cura-loader-circle", "cura-select", "cura-select-option"];
4028
- components.forEach(tagName => { switch (tagName) {
4029
- case "cura-calendar":
4030
- if (!customElements.get(tagName)) {
4031
- customElements.define(tagName, CuraCalendar$1);
4032
- }
4033
- break;
4034
- case "cura-button-transparent":
4035
- if (!customElements.get(tagName)) {
4036
- defineCustomElement$7();
4037
- }
4038
- break;
4039
- case "cura-icon":
4040
- if (!customElements.get(tagName)) {
4041
- defineCustomElement$6();
4042
- }
4043
- break;
4044
- case "cura-label":
4045
- if (!customElements.get(tagName)) {
4046
- defineCustomElement$5();
4047
- }
4048
- break;
4049
- case "cura-loader-circle":
4050
- if (!customElements.get(tagName)) {
4051
- defineCustomElement$4();
4052
- }
4053
- break;
4054
- case "cura-select":
4055
- if (!customElements.get(tagName)) {
4056
- defineCustomElement$3();
4057
- }
4058
- break;
4059
- case "cura-select-option":
4060
- if (!customElements.get(tagName)) {
4061
- defineCustomElement$2();
4062
- }
4063
- break;
4064
- } });
4065
- }
1
+ import { C as CuraCalendar$1, d as defineCustomElement$1 } from './cura-calendar2.js';
4066
2
 
4067
3
  const CuraCalendar = CuraCalendar$1;
4068
4
  const defineCustomElement = defineCustomElement$1;