jebamo 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/app-globals-3a1e7e63.js +7 -0
  3. package/dist/cjs/app-globals-3a1e7e63.js.map +1 -0
  4. package/dist/cjs/index-d5fa9014.js +1722 -0
  5. package/dist/cjs/index-d5fa9014.js.map +1 -0
  6. package/dist/cjs/index.cjs.js +4 -0
  7. package/dist/cjs/index.cjs.js.map +1 -0
  8. package/dist/cjs/je-alert_31.cjs.entry.js +4772 -0
  9. package/dist/cjs/je-alert_31.cjs.entry.js.map +1 -0
  10. package/dist/cjs/je-branch.cjs.entry.js +22 -0
  11. package/dist/cjs/je-branch.cjs.entry.js.map +1 -0
  12. package/dist/cjs/je-column-group.cjs.entry.js +29 -0
  13. package/dist/cjs/je-column-group.cjs.entry.js.map +1 -0
  14. package/dist/cjs/je-column.cjs.entry.js +73 -0
  15. package/dist/cjs/je-column.cjs.entry.js.map +1 -0
  16. package/dist/cjs/je-infinite.cjs.entry.js +45 -0
  17. package/dist/cjs/je-infinite.cjs.entry.js.map +1 -0
  18. package/dist/cjs/je-menu-option.cjs.entry.js +22 -0
  19. package/dist/cjs/je-menu-option.cjs.entry.js.map +1 -0
  20. package/dist/cjs/je-menu.cjs.entry.js +22 -0
  21. package/dist/cjs/je-menu.cjs.entry.js.map +1 -0
  22. package/dist/cjs/je-tab.cjs.entry.js +22 -0
  23. package/dist/cjs/je-tab.cjs.entry.js.map +1 -0
  24. package/dist/cjs/je-tabs.cjs.entry.js +22 -0
  25. package/dist/cjs/je-tabs.cjs.entry.js.map +1 -0
  26. package/dist/cjs/je-toast.cjs.entry.js +22 -0
  27. package/dist/cjs/je-toast.cjs.entry.js.map +1 -0
  28. package/dist/cjs/je-tree.cjs.entry.js +22 -0
  29. package/dist/cjs/je-tree.cjs.entry.js.map +1 -0
  30. package/dist/cjs/jebamo.cjs.js +27 -0
  31. package/dist/cjs/jebamo.cjs.js.map +1 -0
  32. package/dist/cjs/loader.cjs.js +17 -0
  33. package/dist/cjs/loader.cjs.js.map +1 -0
  34. package/dist/collection/collection-manifest.json +52 -0
  35. package/dist/collection/components/checkbox-group/je-checkbox-group/je-checkbox-group.css +10 -0
  36. package/dist/collection/components/checkbox-group/je-checkbox-group/je-checkbox-group.js +141 -0
  37. package/dist/collection/components/checkbox-group/je-checkbox-group/je-checkbox-group.js.map +1 -0
  38. package/dist/collection/components/checkbox-group/je-checkbox-option/je-checkbox-option.css +13 -0
  39. package/dist/collection/components/checkbox-group/je-checkbox-option/je-checkbox-option.js +153 -0
  40. package/dist/collection/components/checkbox-group/je-checkbox-option/je-checkbox-option.js.map +1 -0
  41. package/dist/collection/components/column/je-column/je-column.css +10 -0
  42. package/dist/collection/components/column/je-column/je-column.js +187 -0
  43. package/dist/collection/components/column/je-column/je-column.js.map +1 -0
  44. package/dist/collection/components/column/je-column-group/je-column-group.css +4 -0
  45. package/dist/collection/components/column/je-column-group/je-column-group.js +49 -0
  46. package/dist/collection/components/column/je-column-group/je-column-group.js.map +1 -0
  47. package/dist/collection/components/je-alert/je-alert.css +84 -0
  48. package/dist/collection/components/je-alert/je-alert.js +339 -0
  49. package/dist/collection/components/je-alert/je-alert.js.map +1 -0
  50. package/dist/collection/components/je-button/je-button.css +180 -0
  51. package/dist/collection/components/je-button/je-button.js +252 -0
  52. package/dist/collection/components/je-button/je-button.js.map +1 -0
  53. package/dist/collection/components/je-card/je-card.css +113 -0
  54. package/dist/collection/components/je-card/je-card.js +67 -0
  55. package/dist/collection/components/je-card/je-card.js.map +1 -0
  56. package/dist/collection/components/je-checkbox/je-checkbox.css +14 -0
  57. package/dist/collection/components/je-checkbox/je-checkbox.js +191 -0
  58. package/dist/collection/components/je-checkbox/je-checkbox.js.map +1 -0
  59. package/dist/collection/components/je-color/je-color.css +39 -0
  60. package/dist/collection/components/je-color/je-color.js +116 -0
  61. package/dist/collection/components/je-color/je-color.js.map +1 -0
  62. package/dist/collection/components/je-datepicker/je-datepicker.css +56 -0
  63. package/dist/collection/components/je-datepicker/je-datepicker.js +129 -0
  64. package/dist/collection/components/je-datepicker/je-datepicker.js.map +1 -0
  65. package/dist/collection/components/je-details/je-details.css +39 -0
  66. package/dist/collection/components/je-details/je-details.js +63 -0
  67. package/dist/collection/components/je-details/je-details.js.map +1 -0
  68. package/dist/collection/components/je-divider/je-divider.css +32 -0
  69. package/dist/collection/components/je-divider/je-divider.js +63 -0
  70. package/dist/collection/components/je-divider/je-divider.js.map +1 -0
  71. package/dist/collection/components/je-drawer/je-drawer.css +51 -0
  72. package/dist/collection/components/je-drawer/je-drawer.js +71 -0
  73. package/dist/collection/components/je-drawer/je-drawer.js.map +1 -0
  74. package/dist/collection/components/je-dropzone/je-dropzone.css +21 -0
  75. package/dist/collection/components/je-dropzone/je-dropzone.js +86 -0
  76. package/dist/collection/components/je-dropzone/je-dropzone.js.map +1 -0
  77. package/dist/collection/components/je-form/je-form.css +12 -0
  78. package/dist/collection/components/je-form/je-form.js +95 -0
  79. package/dist/collection/components/je-form/je-form.js.map +1 -0
  80. package/dist/collection/components/je-icon/je-icon.css +60 -0
  81. package/dist/collection/components/je-icon/je-icon.js +122 -0
  82. package/dist/collection/components/je-icon/je-icon.js.map +1 -0
  83. package/dist/collection/components/je-infinite/je-infinite.css +18 -0
  84. package/dist/collection/components/je-infinite/je-infinite.js +119 -0
  85. package/dist/collection/components/je-infinite/je-infinite.js.map +1 -0
  86. package/dist/collection/components/je-input/je-input.css +96 -0
  87. package/dist/collection/components/je-input/je-input.js +862 -0
  88. package/dist/collection/components/je-input/je-input.js.map +1 -0
  89. package/dist/collection/components/je-link/je-link.css +15 -0
  90. package/dist/collection/components/je-link/je-link.js +207 -0
  91. package/dist/collection/components/je-link/je-link.js.map +1 -0
  92. package/dist/collection/components/je-loading/je-loading.css +50 -0
  93. package/dist/collection/components/je-loading/je-loading.js +48 -0
  94. package/dist/collection/components/je-loading/je-loading.js.map +1 -0
  95. package/dist/collection/components/je-modal/je-modal.css +75 -0
  96. package/dist/collection/components/je-modal/je-modal.js +220 -0
  97. package/dist/collection/components/je-modal/je-modal.js.map +1 -0
  98. package/dist/collection/components/je-page/je-page.css +202 -0
  99. package/dist/collection/components/je-page/je-page.js +129 -0
  100. package/dist/collection/components/je-page/je-page.js.map +1 -0
  101. package/dist/collection/components/je-pill/je-pill.css +43 -0
  102. package/dist/collection/components/je-pill/je-pill.js +82 -0
  103. package/dist/collection/components/je-pill/je-pill.js.map +1 -0
  104. package/dist/collection/components/je-placeholder/je-placeholder.css +39 -0
  105. package/dist/collection/components/je-placeholder/je-placeholder.js +44 -0
  106. package/dist/collection/components/je-placeholder/je-placeholder.js.map +1 -0
  107. package/dist/collection/components/je-popover/je-popover.css +60 -0
  108. package/dist/collection/components/je-popover/je-popover.js +499 -0
  109. package/dist/collection/components/je-popover/je-popover.js.map +1 -0
  110. package/dist/collection/components/je-textarea/je-textarea.css +59 -0
  111. package/dist/collection/components/je-textarea/je-textarea.js +171 -0
  112. package/dist/collection/components/je-textarea/je-textarea.js.map +1 -0
  113. package/dist/collection/components/je-toast/je-toast.css +3 -0
  114. package/dist/collection/components/je-toast/je-toast.js +19 -0
  115. package/dist/collection/components/je-toast/je-toast.js.map +1 -0
  116. package/dist/collection/components/je-toggle/je-toggle.css +48 -0
  117. package/dist/collection/components/je-toggle/je-toggle.js +105 -0
  118. package/dist/collection/components/je-toggle/je-toggle.js.map +1 -0
  119. package/dist/collection/components/je-toolbar/je-toolbar.css +16 -0
  120. package/dist/collection/components/je-toolbar/je-toolbar.js +19 -0
  121. package/dist/collection/components/je-toolbar/je-toolbar.js.map +1 -0
  122. package/dist/collection/components/menu/je-menu/je-menu.css +3 -0
  123. package/dist/collection/components/menu/je-menu/je-menu.js +19 -0
  124. package/dist/collection/components/menu/je-menu/je-menu.js.map +1 -0
  125. package/dist/collection/components/menu/je-menu-option/je-menu-option.css +3 -0
  126. package/dist/collection/components/menu/je-menu-option/je-menu-option.js +19 -0
  127. package/dist/collection/components/menu/je-menu-option/je-menu-option.js.map +1 -0
  128. package/dist/collection/components/multiselect/je-multiselect/je-multiselect.css +79 -0
  129. package/dist/collection/components/multiselect/je-multiselect/je-multiselect.js +244 -0
  130. package/dist/collection/components/multiselect/je-multiselect/je-multiselect.js.map +1 -0
  131. package/dist/collection/components/multiselect/je-multiselect-option/je-multiselect-option.css +31 -0
  132. package/dist/collection/components/multiselect/je-multiselect-option/je-multiselect-option.js +122 -0
  133. package/dist/collection/components/multiselect/je-multiselect-option/je-multiselect-option.js.map +1 -0
  134. package/dist/collection/components/radio/je-radio/je-radio.css +13 -0
  135. package/dist/collection/components/radio/je-radio/je-radio.js +128 -0
  136. package/dist/collection/components/radio/je-radio/je-radio.js.map +1 -0
  137. package/dist/collection/components/radio/je-radio-group/je-radio-group.css +10 -0
  138. package/dist/collection/components/radio/je-radio-group/je-radio-group.js +172 -0
  139. package/dist/collection/components/radio/je-radio-group/je-radio-group.js.map +1 -0
  140. package/dist/collection/components/select/je-select/je-select.css +20 -0
  141. package/dist/collection/components/select/je-select/je-select.js +289 -0
  142. package/dist/collection/components/select/je-select/je-select.js.map +1 -0
  143. package/dist/collection/components/select/je-select-option/je-select-option.css +31 -0
  144. package/dist/collection/components/select/je-select-option/je-select-option.js +102 -0
  145. package/dist/collection/components/select/je-select-option/je-select-option.js.map +1 -0
  146. package/dist/collection/components/tabs/je-tab/je-tab.css +3 -0
  147. package/dist/collection/components/tabs/je-tab/je-tab.js +19 -0
  148. package/dist/collection/components/tabs/je-tab/je-tab.js.map +1 -0
  149. package/dist/collection/components/tabs/je-tabs/je-tabs.css +3 -0
  150. package/dist/collection/components/tabs/je-tabs/je-tabs.js +19 -0
  151. package/dist/collection/components/tabs/je-tabs/je-tabs.js.map +1 -0
  152. package/dist/collection/components/tree/je-branch/je-branch.css +3 -0
  153. package/dist/collection/components/tree/je-branch/je-branch.js +19 -0
  154. package/dist/collection/components/tree/je-branch/je-branch.js.map +1 -0
  155. package/dist/collection/components/tree/je-tree/je-tree.css +3 -0
  156. package/dist/collection/components/tree/je-tree/je-tree.js +19 -0
  157. package/dist/collection/components/tree/je-tree/je-tree.js.map +1 -0
  158. package/dist/collection/index.js +2 -0
  159. package/dist/collection/index.js.map +1 -0
  160. package/dist/collection/utils/utils.js +18 -0
  161. package/dist/collection/utils/utils.js.map +1 -0
  162. package/dist/components/index.d.ts +33 -0
  163. package/dist/components/index.js +3 -0
  164. package/dist/components/index.js.map +1 -0
  165. package/dist/components/je-alert.d.ts +11 -0
  166. package/dist/components/je-alert.js +146 -0
  167. package/dist/components/je-alert.js.map +1 -0
  168. package/dist/components/je-branch.d.ts +11 -0
  169. package/dist/components/je-branch.js +37 -0
  170. package/dist/components/je-branch.js.map +1 -0
  171. package/dist/components/je-button.d.ts +11 -0
  172. package/dist/components/je-button.js +8 -0
  173. package/dist/components/je-button.js.map +1 -0
  174. package/dist/components/je-card.d.ts +11 -0
  175. package/dist/components/je-card.js +8 -0
  176. package/dist/components/je-card.js.map +1 -0
  177. package/dist/components/je-checkbox-group.d.ts +11 -0
  178. package/dist/components/je-checkbox-group.js +90 -0
  179. package/dist/components/je-checkbox-group.js.map +1 -0
  180. package/dist/components/je-checkbox-option.d.ts +11 -0
  181. package/dist/components/je-checkbox-option.js +65 -0
  182. package/dist/components/je-checkbox-option.js.map +1 -0
  183. package/dist/components/je-checkbox.d.ts +11 -0
  184. package/dist/components/je-checkbox.js +83 -0
  185. package/dist/components/je-checkbox.js.map +1 -0
  186. package/dist/components/je-color.d.ts +11 -0
  187. package/dist/components/je-color.js +8 -0
  188. package/dist/components/je-color.js.map +1 -0
  189. package/dist/components/je-column-group.d.ts +11 -0
  190. package/dist/components/je-column-group.js +46 -0
  191. package/dist/components/je-column-group.js.map +1 -0
  192. package/dist/components/je-column.d.ts +11 -0
  193. package/dist/components/je-column.js +95 -0
  194. package/dist/components/je-column.js.map +1 -0
  195. package/dist/components/je-datepicker.d.ts +11 -0
  196. package/dist/components/je-datepicker.js +3249 -0
  197. package/dist/components/je-datepicker.js.map +1 -0
  198. package/dist/components/je-details.d.ts +11 -0
  199. package/dist/components/je-details.js +49 -0
  200. package/dist/components/je-details.js.map +1 -0
  201. package/dist/components/je-divider.d.ts +11 -0
  202. package/dist/components/je-divider.js +42 -0
  203. package/dist/components/je-divider.js.map +1 -0
  204. package/dist/components/je-drawer.d.ts +11 -0
  205. package/dist/components/je-drawer.js +60 -0
  206. package/dist/components/je-drawer.js.map +1 -0
  207. package/dist/components/je-dropzone.d.ts +11 -0
  208. package/dist/components/je-dropzone.js +55 -0
  209. package/dist/components/je-dropzone.js.map +1 -0
  210. package/dist/components/je-form.d.ts +11 -0
  211. package/dist/components/je-form.js +8 -0
  212. package/dist/components/je-form.js.map +1 -0
  213. package/dist/components/je-icon.d.ts +11 -0
  214. package/dist/components/je-icon.js +8 -0
  215. package/dist/components/je-icon.js.map +1 -0
  216. package/dist/components/je-infinite.d.ts +11 -0
  217. package/dist/components/je-infinite.js +64 -0
  218. package/dist/components/je-infinite.js.map +1 -0
  219. package/dist/components/je-input.d.ts +11 -0
  220. package/dist/components/je-input.js +8 -0
  221. package/dist/components/je-input.js.map +1 -0
  222. package/dist/components/je-link.d.ts +11 -0
  223. package/dist/components/je-link.js +62 -0
  224. package/dist/components/je-link.js.map +1 -0
  225. package/dist/components/je-loading.d.ts +11 -0
  226. package/dist/components/je-loading.js +66 -0
  227. package/dist/components/je-loading.js.map +1 -0
  228. package/dist/components/je-menu-option.d.ts +11 -0
  229. package/dist/components/je-menu-option.js +37 -0
  230. package/dist/components/je-menu-option.js.map +1 -0
  231. package/dist/components/je-menu.d.ts +11 -0
  232. package/dist/components/je-menu.js +37 -0
  233. package/dist/components/je-menu.js.map +1 -0
  234. package/dist/components/je-modal.d.ts +11 -0
  235. package/dist/components/je-modal.js +104 -0
  236. package/dist/components/je-modal.js.map +1 -0
  237. package/dist/components/je-multiselect-option.d.ts +11 -0
  238. package/dist/components/je-multiselect-option.js +62 -0
  239. package/dist/components/je-multiselect-option.js.map +1 -0
  240. package/dist/components/je-multiselect.d.ts +11 -0
  241. package/dist/components/je-multiselect.js +146 -0
  242. package/dist/components/je-multiselect.js.map +1 -0
  243. package/dist/components/je-page.d.ts +11 -0
  244. package/dist/components/je-page.js +61 -0
  245. package/dist/components/je-page.js.map +1 -0
  246. package/dist/components/je-pill.d.ts +11 -0
  247. package/dist/components/je-pill.js +8 -0
  248. package/dist/components/je-pill.js.map +1 -0
  249. package/dist/components/je-placeholder.d.ts +11 -0
  250. package/dist/components/je-placeholder.js +40 -0
  251. package/dist/components/je-placeholder.js.map +1 -0
  252. package/dist/components/je-popover.d.ts +11 -0
  253. package/dist/components/je-popover.js +8 -0
  254. package/dist/components/je-popover.js.map +1 -0
  255. package/dist/components/je-radio-group.d.ts +11 -0
  256. package/dist/components/je-radio-group.js +92 -0
  257. package/dist/components/je-radio-group.js.map +1 -0
  258. package/dist/components/je-radio.d.ts +11 -0
  259. package/dist/components/je-radio.js +68 -0
  260. package/dist/components/je-radio.js.map +1 -0
  261. package/dist/components/je-select-option.d.ts +11 -0
  262. package/dist/components/je-select-option.js +56 -0
  263. package/dist/components/je-select-option.js.map +1 -0
  264. package/dist/components/je-select.d.ts +11 -0
  265. package/dist/components/je-select.js +208 -0
  266. package/dist/components/je-select.js.map +1 -0
  267. package/dist/components/je-tab.d.ts +11 -0
  268. package/dist/components/je-tab.js +37 -0
  269. package/dist/components/je-tab.js.map +1 -0
  270. package/dist/components/je-tabs.d.ts +11 -0
  271. package/dist/components/je-tabs.js +37 -0
  272. package/dist/components/je-tabs.js.map +1 -0
  273. package/dist/components/je-textarea.d.ts +11 -0
  274. package/dist/components/je-textarea.js +55 -0
  275. package/dist/components/je-textarea.js.map +1 -0
  276. package/dist/components/je-toast.d.ts +11 -0
  277. package/dist/components/je-toast.js +37 -0
  278. package/dist/components/je-toast.js.map +1 -0
  279. package/dist/components/je-toggle.d.ts +11 -0
  280. package/dist/components/je-toggle.js +57 -0
  281. package/dist/components/je-toggle.js.map +1 -0
  282. package/dist/components/je-toolbar.d.ts +11 -0
  283. package/dist/components/je-toolbar.js +37 -0
  284. package/dist/components/je-toolbar.js.map +1 -0
  285. package/dist/components/je-tree.d.ts +11 -0
  286. package/dist/components/je-tree.js +37 -0
  287. package/dist/components/je-tree.js.map +1 -0
  288. package/dist/components/p-1f3759e7.js +41 -0
  289. package/dist/components/p-1f3759e7.js.map +1 -0
  290. package/dist/components/p-243cc91b.js +50 -0
  291. package/dist/components/p-243cc91b.js.map +1 -0
  292. package/dist/components/p-2df369c4.js +265 -0
  293. package/dist/components/p-2df369c4.js.map +1 -0
  294. package/dist/components/p-41492a72.js +1514 -0
  295. package/dist/components/p-41492a72.js.map +1 -0
  296. package/dist/components/p-4b8ae8ef.js +51 -0
  297. package/dist/components/p-4b8ae8ef.js.map +1 -0
  298. package/dist/components/p-5dee004d.js +246 -0
  299. package/dist/components/p-5dee004d.js.map +1 -0
  300. package/dist/components/p-8401b4e4.js +48 -0
  301. package/dist/components/p-8401b4e4.js.map +1 -0
  302. package/dist/components/p-94327b0d.js +39 -0
  303. package/dist/components/p-94327b0d.js.map +1 -0
  304. package/dist/components/p-aa4caa39.js +76 -0
  305. package/dist/components/p-aa4caa39.js.map +1 -0
  306. package/dist/esm/app-globals-0f993ce5.js +5 -0
  307. package/dist/esm/app-globals-0f993ce5.js.map +1 -0
  308. package/dist/esm/index-a65634db.js +1692 -0
  309. package/dist/esm/index-a65634db.js.map +1 -0
  310. package/dist/esm/index.js +3 -0
  311. package/dist/esm/index.js.map +1 -0
  312. package/dist/esm/je-alert_31.entry.js +4738 -0
  313. package/dist/esm/je-alert_31.entry.js.map +1 -0
  314. package/dist/esm/je-branch.entry.js +18 -0
  315. package/dist/esm/je-branch.entry.js.map +1 -0
  316. package/dist/esm/je-column-group.entry.js +25 -0
  317. package/dist/esm/je-column-group.entry.js.map +1 -0
  318. package/dist/esm/je-column.entry.js +69 -0
  319. package/dist/esm/je-column.entry.js.map +1 -0
  320. package/dist/esm/je-infinite.entry.js +41 -0
  321. package/dist/esm/je-infinite.entry.js.map +1 -0
  322. package/dist/esm/je-menu-option.entry.js +18 -0
  323. package/dist/esm/je-menu-option.entry.js.map +1 -0
  324. package/dist/esm/je-menu.entry.js +18 -0
  325. package/dist/esm/je-menu.entry.js.map +1 -0
  326. package/dist/esm/je-tab.entry.js +18 -0
  327. package/dist/esm/je-tab.entry.js.map +1 -0
  328. package/dist/esm/je-tabs.entry.js +18 -0
  329. package/dist/esm/je-tabs.entry.js.map +1 -0
  330. package/dist/esm/je-toast.entry.js +18 -0
  331. package/dist/esm/je-toast.entry.js.map +1 -0
  332. package/dist/esm/je-tree.entry.js +18 -0
  333. package/dist/esm/je-tree.entry.js.map +1 -0
  334. package/dist/esm/jebamo.js +22 -0
  335. package/dist/esm/jebamo.js.map +1 -0
  336. package/dist/esm/loader.js +13 -0
  337. package/dist/esm/loader.js.map +1 -0
  338. package/dist/index.cjs.js +1 -0
  339. package/dist/index.js +1 -0
  340. package/dist/jebamo/index.esm.js +2 -0
  341. package/dist/jebamo/index.esm.js.map +1 -0
  342. package/dist/jebamo/jebamo.esm.js +2 -0
  343. package/dist/jebamo/jebamo.esm.js.map +1 -0
  344. package/dist/jebamo/p-0d0cb311.entry.js +2 -0
  345. package/dist/jebamo/p-0d0cb311.entry.js.map +1 -0
  346. package/dist/jebamo/p-254ac389.entry.js +2 -0
  347. package/dist/jebamo/p-254ac389.entry.js.map +1 -0
  348. package/dist/jebamo/p-286807aa.entry.js +2 -0
  349. package/dist/jebamo/p-286807aa.entry.js.map +1 -0
  350. package/dist/jebamo/p-44735e2f.entry.js +2 -0
  351. package/dist/jebamo/p-44735e2f.entry.js.map +1 -0
  352. package/dist/jebamo/p-456b52ee.js +3 -0
  353. package/dist/jebamo/p-456b52ee.js.map +1 -0
  354. package/dist/jebamo/p-5b8d9daf.entry.js +2 -0
  355. package/dist/jebamo/p-5b8d9daf.entry.js.map +1 -0
  356. package/dist/jebamo/p-c519a7a4.entry.js +2 -0
  357. package/dist/jebamo/p-c519a7a4.entry.js.map +1 -0
  358. package/dist/jebamo/p-c6111d19.entry.js +2 -0
  359. package/dist/jebamo/p-c6111d19.entry.js.map +1 -0
  360. package/dist/jebamo/p-c8615128.entry.js +2 -0
  361. package/dist/jebamo/p-c8615128.entry.js.map +1 -0
  362. package/dist/jebamo/p-e1255160.js +2 -0
  363. package/dist/jebamo/p-e1255160.js.map +1 -0
  364. package/dist/jebamo/p-e330c9bb.entry.js +2 -0
  365. package/dist/jebamo/p-e330c9bb.entry.js.map +1 -0
  366. package/dist/jebamo/p-f6e777be.entry.js +2 -0
  367. package/dist/jebamo/p-f6e777be.entry.js.map +1 -0
  368. package/dist/jebamo/p-ff27b55f.entry.js +2 -0
  369. package/dist/jebamo/p-ff27b55f.entry.js.map +1 -0
  370. package/dist/types/components/checkbox-group/je-checkbox-group/je-checkbox-group.d.ts +25 -0
  371. package/dist/types/components/checkbox-group/je-checkbox-option/je-checkbox-option.d.ts +30 -0
  372. package/dist/types/components/column/je-column/je-column.d.ts +31 -0
  373. package/dist/types/components/column/je-column-group/je-column-group.d.ts +9 -0
  374. package/dist/types/components/je-alert/je-alert.d.ts +77 -0
  375. package/dist/types/components/je-button/je-button.d.ts +28 -0
  376. package/dist/types/components/je-card/je-card.d.ts +6 -0
  377. package/dist/types/components/je-checkbox/je-checkbox.d.ts +38 -0
  378. package/dist/types/components/je-color/je-color.d.ts +12 -0
  379. package/dist/types/components/je-datepicker/je-datepicker.d.ts +18 -0
  380. package/dist/types/components/je-details/je-details.d.ts +6 -0
  381. package/dist/types/components/je-divider/je-divider.d.ts +5 -0
  382. package/dist/types/components/je-drawer/je-drawer.d.ts +10 -0
  383. package/dist/types/components/je-dropzone/je-dropzone.d.ts +10 -0
  384. package/dist/types/components/je-form/je-form.d.ts +12 -0
  385. package/dist/types/components/je-icon/je-icon.d.ts +15 -0
  386. package/dist/types/components/je-infinite/je-infinite.d.ts +25 -0
  387. package/dist/types/components/je-input/je-input.d.ts +155 -0
  388. package/dist/types/components/je-link/je-link.d.ts +22 -0
  389. package/dist/types/components/je-loading/je-loading.d.ts +22 -0
  390. package/dist/types/components/je-modal/je-modal.d.ts +28 -0
  391. package/dist/types/components/je-page/je-page.d.ts +12 -0
  392. package/dist/types/components/je-pill/je-pill.d.ts +6 -0
  393. package/dist/types/components/je-placeholder/je-placeholder.d.ts +7 -0
  394. package/dist/types/components/je-popover/je-popover.d.ts +70 -0
  395. package/dist/types/components/je-textarea/je-textarea.d.ts +11 -0
  396. package/dist/types/components/je-toast/je-toast.d.ts +3 -0
  397. package/dist/types/components/je-toggle/je-toggle.d.ts +18 -0
  398. package/dist/types/components/je-toolbar/je-toolbar.d.ts +3 -0
  399. package/dist/types/components/menu/je-menu/je-menu.d.ts +3 -0
  400. package/dist/types/components/menu/je-menu-option/je-menu-option.d.ts +3 -0
  401. package/dist/types/components/multiselect/je-multiselect/je-multiselect.d.ts +27 -0
  402. package/dist/types/components/multiselect/je-multiselect-option/je-multiselect-option.d.ts +11 -0
  403. package/dist/types/components/radio/je-radio/je-radio.d.ts +25 -0
  404. package/dist/types/components/radio/je-radio-group/je-radio-group.d.ts +32 -0
  405. package/dist/types/components/select/je-select/je-select.d.ts +23 -0
  406. package/dist/types/components/select/je-select-option/je-select-option.d.ts +10 -0
  407. package/dist/types/components/tabs/je-tab/je-tab.d.ts +3 -0
  408. package/dist/types/components/tabs/je-tabs/je-tabs.d.ts +3 -0
  409. package/dist/types/components/tree/je-branch/je-branch.d.ts +3 -0
  410. package/dist/types/components/tree/je-tree/je-tree.d.ts +3 -0
  411. package/dist/types/components.d.ts +1846 -0
  412. package/dist/types/index.d.ts +10 -0
  413. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  414. package/dist/types/utils/utils.d.ts +4 -0
  415. package/loader/cdn.js +1 -0
  416. package/loader/index.cjs.js +1 -0
  417. package/loader/index.d.ts +24 -0
  418. package/loader/index.es2017.js +1 -0
  419. package/loader/index.js +2 -0
  420. package/loader/package.json +11 -0
  421. package/package.json +31 -26
  422. package/readme.md +114 -0
  423. package/README.md +0 -24
  424. package/esm2020/jebamo.mjs +0 -5
  425. package/esm2020/lib/jebamo.component.mjs +0 -19
  426. package/esm2020/lib/jebamo.module.mjs +0 -21
  427. package/esm2020/lib/jebamo.service.mjs +0 -14
  428. package/esm2020/public-api.mjs +0 -7
  429. package/fesm2015/jebamo.mjs +0 -60
  430. package/fesm2015/jebamo.mjs.map +0 -1
  431. package/fesm2020/jebamo.mjs +0 -60
  432. package/fesm2020/jebamo.mjs.map +0 -1
  433. package/index.d.ts +0 -5
  434. package/lib/jebamo.component.d.ts +0 -5
  435. package/lib/jebamo.module.d.ts +0 -7
  436. package/lib/jebamo.service.d.ts +0 -6
  437. package/public-api.d.ts +0 -3
@@ -0,0 +1,3249 @@
1
+ import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-41492a72.js';
2
+ import { d as defineCustomElement$3 } from './p-aa4caa39.js';
3
+ import { d as defineCustomElement$2 } from './p-4b8ae8ef.js';
4
+
5
+ /**
6
+ * @module constants
7
+ * @summary Useful constants
8
+ * @description
9
+ * Collection of useful date constants.
10
+ *
11
+ * The constants could be imported from `date-fns/constants`:
12
+ *
13
+ * ```ts
14
+ * import { maxTime, minTime } from "./constants/date-fns/constants";
15
+ *
16
+ * function isAllowedTime(time) {
17
+ * return time <= maxTime && time >= minTime;
18
+ * }
19
+ * ```
20
+ */
21
+
22
+ /**
23
+ * @constant
24
+ * @name millisecondsInWeek
25
+ * @summary Milliseconds in 1 week.
26
+ */
27
+ const millisecondsInWeek = 604800000;
28
+
29
+ /**
30
+ * @constant
31
+ * @name millisecondsInDay
32
+ * @summary Milliseconds in 1 day.
33
+ */
34
+ const millisecondsInDay = 86400000;
35
+
36
+ /**
37
+ * @constant
38
+ * @name constructFromSymbol
39
+ * @summary Symbol enabling Date extensions to inherit properties from the reference date.
40
+ *
41
+ * The symbol is used to enable the `constructFrom` function to construct a date
42
+ * using a reference date and a value. It allows to transfer extra properties
43
+ * from the reference date to the new date. It's useful for extensions like
44
+ * [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
45
+ * a constructor argument.
46
+ */
47
+ const constructFromSymbol = Symbol.for("constructDateFrom");
48
+
49
+ /**
50
+ * @name constructFrom
51
+ * @category Generic Helpers
52
+ * @summary Constructs a date using the reference date and the value
53
+ *
54
+ * @description
55
+ * The function constructs a new date using the constructor from the reference
56
+ * date and the given value. It helps to build generic functions that accept
57
+ * date extensions.
58
+ *
59
+ * It defaults to `Date` if the passed reference date is a number or a string.
60
+ *
61
+ * Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
62
+ * enabling to transfer extra properties from the reference date to the new date.
63
+ * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
64
+ * that accept a time zone as a constructor argument.
65
+ *
66
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
67
+ *
68
+ * @param date - The reference date to take constructor from
69
+ * @param value - The value to create the date
70
+ *
71
+ * @returns Date initialized using the given date and value
72
+ *
73
+ * @example
74
+ * import { constructFrom } from "./constructFrom/date-fns";
75
+ *
76
+ * // A function that clones a date preserving the original type
77
+ * function cloneDate<DateType extends Date>(date: DateType): DateType {
78
+ * return constructFrom(
79
+ * date, // Use constructor from the given date
80
+ * date.getTime() // Use the date value to create a new date
81
+ * );
82
+ * }
83
+ */
84
+ function constructFrom(date, value) {
85
+ if (typeof date === "function") return date(value);
86
+
87
+ if (date && typeof date === "object" && constructFromSymbol in date)
88
+ return date[constructFromSymbol](value);
89
+
90
+ if (date instanceof Date) return new date.constructor(value);
91
+
92
+ return new Date(value);
93
+ }
94
+
95
+ /**
96
+ * @name toDate
97
+ * @category Common Helpers
98
+ * @summary Convert the given argument to an instance of Date.
99
+ *
100
+ * @description
101
+ * Convert the given argument to an instance of Date.
102
+ *
103
+ * If the argument is an instance of Date, the function returns its clone.
104
+ *
105
+ * If the argument is a number, it is treated as a timestamp.
106
+ *
107
+ * If the argument is none of the above, the function returns Invalid Date.
108
+ *
109
+ * Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
110
+ * enabling to transfer extra properties from the reference date to the new date.
111
+ * It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
112
+ * that accept a time zone as a constructor argument.
113
+ *
114
+ * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
115
+ *
116
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
117
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
118
+ *
119
+ * @param argument - The value to convert
120
+ *
121
+ * @returns The parsed date in the local time zone
122
+ *
123
+ * @example
124
+ * // Clone the date:
125
+ * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
126
+ * //=> Tue Feb 11 2014 11:30:30
127
+ *
128
+ * @example
129
+ * // Convert the timestamp to date:
130
+ * const result = toDate(1392098430000)
131
+ * //=> Tue Feb 11 2014 11:30:30
132
+ */
133
+ function toDate(argument, context) {
134
+ // [TODO] Get rid of `toDate` or `constructFrom`?
135
+ return constructFrom(context || argument, argument);
136
+ }
137
+
138
+ /**
139
+ * The {@link addMonths} function options.
140
+ */
141
+
142
+ /**
143
+ * @name addMonths
144
+ * @category Month Helpers
145
+ * @summary Add the specified number of months to the given date.
146
+ *
147
+ * @description
148
+ * Add the specified number of months to the given date.
149
+ *
150
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
151
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
152
+ *
153
+ * @param date - The date to be changed
154
+ * @param amount - The amount of months to be added.
155
+ * @param options - The options object
156
+ *
157
+ * @returns The new date with the months added
158
+ *
159
+ * @example
160
+ * // Add 5 months to 1 September 2014:
161
+ * const result = addMonths(new Date(2014, 8, 1), 5)
162
+ * //=> Sun Feb 01 2015 00:00:00
163
+ *
164
+ * // Add one month to 30 January 2023:
165
+ * const result = addMonths(new Date(2023, 0, 30), 1)
166
+ * //=> Tue Feb 28 2023 00:00:00
167
+ */
168
+ function addMonths(date, amount, options) {
169
+ const _date = toDate(date, options?.in);
170
+ if (isNaN(amount)) return constructFrom(options?.in || date, NaN);
171
+ if (!amount) {
172
+ // If 0 months, no-op to avoid changing times in the hour before end of DST
173
+ return _date;
174
+ }
175
+ const dayOfMonth = _date.getDate();
176
+
177
+ // The JS Date object supports date math by accepting out-of-bounds values for
178
+ // month, day, etc. For example, new Date(2020, 0, 0) returns 31 Dec 2019 and
179
+ // new Date(2020, 13, 1) returns 1 Feb 2021. This is *almost* the behavior we
180
+ // want except that dates will wrap around the end of a month, meaning that
181
+ // new Date(2020, 13, 31) will return 3 Mar 2021 not 28 Feb 2021 as desired. So
182
+ // we'll default to the end of the desired month by adding 1 to the desired
183
+ // month and using a date of 0 to back up one day to the end of the desired
184
+ // month.
185
+ const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime());
186
+ endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0);
187
+ const daysInMonth = endOfDesiredMonth.getDate();
188
+ if (dayOfMonth >= daysInMonth) {
189
+ // If we're already at the end of the month, then this is the correct date
190
+ // and we're done.
191
+ return endOfDesiredMonth;
192
+ } else {
193
+ // Otherwise, we now know that setting the original day-of-month value won't
194
+ // cause an overflow, so set the desired day-of-month. Note that we can't
195
+ // just set the date of `endOfDesiredMonth` because that object may have had
196
+ // its time changed in the unusual case where where a DST transition was on
197
+ // the last day of the month and its local time was in the hour skipped or
198
+ // repeated next to a DST transition. So we use `date` instead which is
199
+ // guaranteed to still have the original time.
200
+ _date.setFullYear(
201
+ endOfDesiredMonth.getFullYear(),
202
+ endOfDesiredMonth.getMonth(),
203
+ dayOfMonth,
204
+ );
205
+ return _date;
206
+ }
207
+ }
208
+
209
+ let defaultOptions = {};
210
+
211
+ function getDefaultOptions() {
212
+ return defaultOptions;
213
+ }
214
+
215
+ /**
216
+ * The {@link startOfWeek} function options.
217
+ */
218
+
219
+ /**
220
+ * @name startOfWeek
221
+ * @category Week Helpers
222
+ * @summary Return the start of a week for the given date.
223
+ *
224
+ * @description
225
+ * Return the start of a week for the given date.
226
+ * The result will be in the local timezone.
227
+ *
228
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
229
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
230
+ *
231
+ * @param date - The original date
232
+ * @param options - An object with options
233
+ *
234
+ * @returns The start of a week
235
+ *
236
+ * @example
237
+ * // The start of a week for 2 September 2014 11:55:00:
238
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
239
+ * //=> Sun Aug 31 2014 00:00:00
240
+ *
241
+ * @example
242
+ * // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
243
+ * const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
244
+ * //=> Mon Sep 01 2014 00:00:00
245
+ */
246
+ function startOfWeek(date, options) {
247
+ const defaultOptions = getDefaultOptions();
248
+ const weekStartsOn =
249
+ options?.weekStartsOn ??
250
+ options?.locale?.options?.weekStartsOn ??
251
+ defaultOptions.weekStartsOn ??
252
+ defaultOptions.locale?.options?.weekStartsOn ??
253
+ 0;
254
+
255
+ const _date = toDate(date, options?.in);
256
+ const day = _date.getDay();
257
+ const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
258
+
259
+ _date.setDate(_date.getDate() - diff);
260
+ _date.setHours(0, 0, 0, 0);
261
+ return _date;
262
+ }
263
+
264
+ /**
265
+ * The {@link startOfISOWeek} function options.
266
+ */
267
+
268
+ /**
269
+ * @name startOfISOWeek
270
+ * @category ISO Week Helpers
271
+ * @summary Return the start of an ISO week for the given date.
272
+ *
273
+ * @description
274
+ * Return the start of an ISO week for the given date.
275
+ * The result will be in the local timezone.
276
+ *
277
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
278
+ *
279
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
280
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
281
+ *
282
+ * @param date - The original date
283
+ * @param options - An object with options
284
+ *
285
+ * @returns The start of an ISO week
286
+ *
287
+ * @example
288
+ * // The start of an ISO week for 2 September 2014 11:55:00:
289
+ * const result = startOfISOWeek(new Date(2014, 8, 2, 11, 55, 0))
290
+ * //=> Mon Sep 01 2014 00:00:00
291
+ */
292
+ function startOfISOWeek(date, options) {
293
+ return startOfWeek(date, { ...options, weekStartsOn: 1 });
294
+ }
295
+
296
+ /**
297
+ * The {@link getISOWeekYear} function options.
298
+ */
299
+
300
+ /**
301
+ * @name getISOWeekYear
302
+ * @category ISO Week-Numbering Year Helpers
303
+ * @summary Get the ISO week-numbering year of the given date.
304
+ *
305
+ * @description
306
+ * Get the ISO week-numbering year of the given date,
307
+ * which always starts 3 days before the year's first Thursday.
308
+ *
309
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
310
+ *
311
+ * @param date - The given date
312
+ *
313
+ * @returns The ISO week-numbering year
314
+ *
315
+ * @example
316
+ * // Which ISO-week numbering year is 2 January 2005?
317
+ * const result = getISOWeekYear(new Date(2005, 0, 2))
318
+ * //=> 2004
319
+ */
320
+ function getISOWeekYear(date, options) {
321
+ const _date = toDate(date, options?.in);
322
+ const year = _date.getFullYear();
323
+
324
+ const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
325
+ fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
326
+ fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
327
+ const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
328
+
329
+ const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
330
+ fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
331
+ fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
332
+ const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
333
+
334
+ if (_date.getTime() >= startOfNextYear.getTime()) {
335
+ return year + 1;
336
+ } else if (_date.getTime() >= startOfThisYear.getTime()) {
337
+ return year;
338
+ } else {
339
+ return year - 1;
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
345
+ * They usually appear for dates that denote time before the timezones were introduced
346
+ * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
347
+ * and GMT+01:00:00 after that date)
348
+ *
349
+ * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
350
+ * which would lead to incorrect calculations.
351
+ *
352
+ * This function returns the timezone offset in milliseconds that takes seconds in account.
353
+ */
354
+ function getTimezoneOffsetInMilliseconds(date) {
355
+ const _date = toDate(date);
356
+ const utcDate = new Date(
357
+ Date.UTC(
358
+ _date.getFullYear(),
359
+ _date.getMonth(),
360
+ _date.getDate(),
361
+ _date.getHours(),
362
+ _date.getMinutes(),
363
+ _date.getSeconds(),
364
+ _date.getMilliseconds(),
365
+ ),
366
+ );
367
+ utcDate.setUTCFullYear(_date.getFullYear());
368
+ return +date - +utcDate;
369
+ }
370
+
371
+ function normalizeDates(context, ...dates) {
372
+ const normalize = constructFrom.bind(
373
+ null,
374
+ context || dates.find((date) => typeof date === "object"),
375
+ );
376
+ return dates.map(normalize);
377
+ }
378
+
379
+ /**
380
+ * The {@link startOfDay} function options.
381
+ */
382
+
383
+ /**
384
+ * @name startOfDay
385
+ * @category Day Helpers
386
+ * @summary Return the start of a day for the given date.
387
+ *
388
+ * @description
389
+ * Return the start of a day for the given date.
390
+ * The result will be in the local timezone.
391
+ *
392
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
393
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
394
+ *
395
+ * @param date - The original date
396
+ * @param options - The options
397
+ *
398
+ * @returns The start of a day
399
+ *
400
+ * @example
401
+ * // The start of a day for 2 September 2014 11:55:00:
402
+ * const result = startOfDay(new Date(2014, 8, 2, 11, 55, 0))
403
+ * //=> Tue Sep 02 2014 00:00:00
404
+ */
405
+ function startOfDay(date, options) {
406
+ const _date = toDate(date, options?.in);
407
+ _date.setHours(0, 0, 0, 0);
408
+ return _date;
409
+ }
410
+
411
+ /**
412
+ * The {@link differenceInCalendarDays} function options.
413
+ */
414
+
415
+ /**
416
+ * @name differenceInCalendarDays
417
+ * @category Day Helpers
418
+ * @summary Get the number of calendar days between the given dates.
419
+ *
420
+ * @description
421
+ * Get the number of calendar days between the given dates. This means that the times are removed
422
+ * from the dates and then the difference in days is calculated.
423
+ *
424
+ * @param laterDate - The later date
425
+ * @param earlierDate - The earlier date
426
+ * @param options - The options object
427
+ *
428
+ * @returns The number of calendar days
429
+ *
430
+ * @example
431
+ * // How many calendar days are between
432
+ * // 2 July 2011 23:00:00 and 2 July 2012 00:00:00?
433
+ * const result = differenceInCalendarDays(
434
+ * new Date(2012, 6, 2, 0, 0),
435
+ * new Date(2011, 6, 2, 23, 0)
436
+ * )
437
+ * //=> 366
438
+ * // How many calendar days are between
439
+ * // 2 July 2011 23:59:00 and 3 July 2011 00:01:00?
440
+ * const result = differenceInCalendarDays(
441
+ * new Date(2011, 6, 3, 0, 1),
442
+ * new Date(2011, 6, 2, 23, 59)
443
+ * )
444
+ * //=> 1
445
+ */
446
+ function differenceInCalendarDays(laterDate, earlierDate, options) {
447
+ const [laterDate_, earlierDate_] = normalizeDates(
448
+ options?.in,
449
+ laterDate,
450
+ earlierDate,
451
+ );
452
+
453
+ const laterStartOfDay = startOfDay(laterDate_);
454
+ const earlierStartOfDay = startOfDay(earlierDate_);
455
+
456
+ const laterTimestamp =
457
+ +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
458
+ const earlierTimestamp =
459
+ +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
460
+
461
+ // Round the number of days to the nearest integer because the number of
462
+ // milliseconds in a day is not constant (e.g. it's different in the week of
463
+ // the daylight saving time clock shift).
464
+ return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
465
+ }
466
+
467
+ /**
468
+ * The {@link startOfISOWeekYear} function options.
469
+ */
470
+
471
+ /**
472
+ * @name startOfISOWeekYear
473
+ * @category ISO Week-Numbering Year Helpers
474
+ * @summary Return the start of an ISO week-numbering year for the given date.
475
+ *
476
+ * @description
477
+ * Return the start of an ISO week-numbering year,
478
+ * which always starts 3 days before the year's first Thursday.
479
+ * The result will be in the local timezone.
480
+ *
481
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
482
+ *
483
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
484
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
485
+ *
486
+ * @param date - The original date
487
+ * @param options - An object with options
488
+ *
489
+ * @returns The start of an ISO week-numbering year
490
+ *
491
+ * @example
492
+ * // The start of an ISO week-numbering year for 2 July 2005:
493
+ * const result = startOfISOWeekYear(new Date(2005, 6, 2))
494
+ * //=> Mon Jan 03 2005 00:00:00
495
+ */
496
+ function startOfISOWeekYear(date, options) {
497
+ const year = getISOWeekYear(date, options);
498
+ const fourthOfJanuary = constructFrom(options?.in || date, 0);
499
+ fourthOfJanuary.setFullYear(year, 0, 4);
500
+ fourthOfJanuary.setHours(0, 0, 0, 0);
501
+ return startOfISOWeek(fourthOfJanuary);
502
+ }
503
+
504
+ /**
505
+ * @name constructNow
506
+ * @category Generic Helpers
507
+ * @summary Constructs a new current date using the passed value constructor.
508
+ * @pure false
509
+ *
510
+ * @description
511
+ * The function constructs a new current date using the constructor from
512
+ * the reference date. It helps to build generic functions that accept date
513
+ * extensions and use the current date.
514
+ *
515
+ * It defaults to `Date` if the passed reference date is a number or a string.
516
+ *
517
+ * @param date - The reference date to take constructor from
518
+ *
519
+ * @returns Current date initialized using the given date constructor
520
+ *
521
+ * @example
522
+ * import { constructNow, isSameDay } from 'date-fns'
523
+ *
524
+ * function isToday<DateType extends Date>(
525
+ * date: DateArg<DateType>,
526
+ * ): boolean {
527
+ * // If we were to use `new Date()` directly, the function would behave
528
+ * // differently in different timezones and return false for the same date.
529
+ * return isSameDay(date, constructNow(date));
530
+ * }
531
+ */
532
+ function constructNow(date) {
533
+ return constructFrom(date, Date.now());
534
+ }
535
+
536
+ /**
537
+ * The {@link isSameDay} function options.
538
+ */
539
+
540
+ /**
541
+ * @name isSameDay
542
+ * @category Day Helpers
543
+ * @summary Are the given dates in the same day (and year and month)?
544
+ *
545
+ * @description
546
+ * Are the given dates in the same day (and year and month)?
547
+ *
548
+ * @param laterDate - The first date to check
549
+ * @param earlierDate - The second date to check
550
+ * @param options - An object with options
551
+ *
552
+ * @returns The dates are in the same day (and year and month)
553
+ *
554
+ * @example
555
+ * // Are 4 September 06:00:00 and 4 September 18:00:00 in the same day?
556
+ * const result = isSameDay(new Date(2014, 8, 4, 6, 0), new Date(2014, 8, 4, 18, 0))
557
+ * //=> true
558
+ *
559
+ * @example
560
+ * // Are 4 September and 4 October in the same day?
561
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2014, 9, 4))
562
+ * //=> false
563
+ *
564
+ * @example
565
+ * // Are 4 September, 2014 and 4 September, 2015 in the same day?
566
+ * const result = isSameDay(new Date(2014, 8, 4), new Date(2015, 8, 4))
567
+ * //=> false
568
+ */
569
+ function isSameDay(laterDate, earlierDate, options) {
570
+ const [dateLeft_, dateRight_] = normalizeDates(
571
+ options?.in,
572
+ laterDate,
573
+ earlierDate,
574
+ );
575
+ return +startOfDay(dateLeft_) === +startOfDay(dateRight_);
576
+ }
577
+
578
+ /**
579
+ * @name isDate
580
+ * @category Common Helpers
581
+ * @summary Is the given value a date?
582
+ *
583
+ * @description
584
+ * Returns true if the given value is an instance of Date. The function works for dates transferred across iframes.
585
+ *
586
+ * @param value - The value to check
587
+ *
588
+ * @returns True if the given value is a date
589
+ *
590
+ * @example
591
+ * // For a valid date:
592
+ * const result = isDate(new Date())
593
+ * //=> true
594
+ *
595
+ * @example
596
+ * // For an invalid date:
597
+ * const result = isDate(new Date(NaN))
598
+ * //=> true
599
+ *
600
+ * @example
601
+ * // For some value:
602
+ * const result = isDate('2014-02-31')
603
+ * //=> false
604
+ *
605
+ * @example
606
+ * // For an object:
607
+ * const result = isDate({})
608
+ * //=> false
609
+ */
610
+ function isDate(value) {
611
+ return (
612
+ value instanceof Date ||
613
+ (typeof value === "object" &&
614
+ Object.prototype.toString.call(value) === "[object Date]")
615
+ );
616
+ }
617
+
618
+ /**
619
+ * @name isValid
620
+ * @category Common Helpers
621
+ * @summary Is the given date valid?
622
+ *
623
+ * @description
624
+ * Returns false if argument is Invalid Date and true otherwise.
625
+ * Argument is converted to Date using `toDate`. See [toDate](https://date-fns.org/docs/toDate)
626
+ * Invalid Date is a Date, whose time value is NaN.
627
+ *
628
+ * Time value of Date: http://es5.github.io/#x15.9.1.1
629
+ *
630
+ * @param date - The date to check
631
+ *
632
+ * @returns The date is valid
633
+ *
634
+ * @example
635
+ * // For the valid date:
636
+ * const result = isValid(new Date(2014, 1, 31))
637
+ * //=> true
638
+ *
639
+ * @example
640
+ * // For the value, convertible into a date:
641
+ * const result = isValid(1393804800000)
642
+ * //=> true
643
+ *
644
+ * @example
645
+ * // For the invalid date:
646
+ * const result = isValid(new Date(''))
647
+ * //=> false
648
+ */
649
+ function isValid(date) {
650
+ return !((!isDate(date) && typeof date !== "number") || isNaN(+toDate(date)));
651
+ }
652
+
653
+ /**
654
+ * The {@link endOfMonth} function options.
655
+ */
656
+
657
+ /**
658
+ * @name endOfMonth
659
+ * @category Month Helpers
660
+ * @summary Return the end of a month for the given date.
661
+ *
662
+ * @description
663
+ * Return the end of a month for the given date.
664
+ * The result will be in the local timezone.
665
+ *
666
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
667
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
668
+ *
669
+ * @param date - The original date
670
+ * @param options - An object with options
671
+ *
672
+ * @returns The end of a month
673
+ *
674
+ * @example
675
+ * // The end of a month for 2 September 2014 11:55:00:
676
+ * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
677
+ * //=> Tue Sep 30 2014 23:59:59.999
678
+ */
679
+ function endOfMonth(date, options) {
680
+ const _date = toDate(date, options?.in);
681
+ const month = _date.getMonth();
682
+ _date.setFullYear(_date.getFullYear(), month + 1, 0);
683
+ _date.setHours(23, 59, 59, 999);
684
+ return _date;
685
+ }
686
+
687
+ function normalizeInterval(context, interval) {
688
+ const [start, end] = normalizeDates(context, interval.start, interval.end);
689
+ return { start, end };
690
+ }
691
+
692
+ /**
693
+ * The {@link eachDayOfInterval} function options.
694
+ */
695
+
696
+ /**
697
+ * The {@link eachDayOfInterval} function result type. It resolves the proper data type.
698
+ * It uses the first argument date object type, starting from the date argument,
699
+ * then the start interval date, and finally the end interval date. If
700
+ * a context function is passed, it uses the context function return type.
701
+ */
702
+
703
+ /**
704
+ * @name eachDayOfInterval
705
+ * @category Interval Helpers
706
+ * @summary Return the array of dates within the specified time interval.
707
+ *
708
+ * @description
709
+ * Return the array of dates within the specified time interval.
710
+ *
711
+ * @typeParam IntervalType - Interval type.
712
+ * @typeParam Options - Options type.
713
+ *
714
+ * @param interval - The interval.
715
+ * @param options - An object with options.
716
+ *
717
+ * @returns The array with starts of days from the day of the interval start to the day of the interval end
718
+ *
719
+ * @example
720
+ * // Each day between 6 October 2014 and 10 October 2014:
721
+ * const result = eachDayOfInterval({
722
+ * start: new Date(2014, 9, 6),
723
+ * end: new Date(2014, 9, 10)
724
+ * })
725
+ * //=> [
726
+ * // Mon Oct 06 2014 00:00:00,
727
+ * // Tue Oct 07 2014 00:00:00,
728
+ * // Wed Oct 08 2014 00:00:00,
729
+ * // Thu Oct 09 2014 00:00:00,
730
+ * // Fri Oct 10 2014 00:00:00
731
+ * // ]
732
+ */
733
+ function eachDayOfInterval(interval, options) {
734
+ const { start, end } = normalizeInterval(options?.in, interval);
735
+
736
+ let reversed = +start > +end;
737
+ const endTime = reversed ? +start : +end;
738
+ const date = reversed ? end : start;
739
+ date.setHours(0, 0, 0, 0);
740
+
741
+ let step = options?.step ?? 1;
742
+ if (!step) return [];
743
+ if (step < 0) {
744
+ step = -step;
745
+ reversed = !reversed;
746
+ }
747
+
748
+ const dates = [];
749
+
750
+ while (+date <= endTime) {
751
+ dates.push(constructFrom(start, date));
752
+ date.setDate(date.getDate() + step);
753
+ date.setHours(0, 0, 0, 0);
754
+ }
755
+
756
+ return reversed ? dates.reverse() : dates;
757
+ }
758
+
759
+ /**
760
+ * The {@link startOfMonth} function options.
761
+ */
762
+
763
+ /**
764
+ * @name startOfMonth
765
+ * @category Month Helpers
766
+ * @summary Return the start of a month for the given date.
767
+ *
768
+ * @description
769
+ * Return the start of a month for the given date. The result will be in the local timezone.
770
+ *
771
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments.
772
+ * Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
773
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed,
774
+ * or inferred from the arguments.
775
+ *
776
+ * @param date - The original date
777
+ * @param options - An object with options
778
+ *
779
+ * @returns The start of a month
780
+ *
781
+ * @example
782
+ * // The start of a month for 2 September 2014 11:55:00:
783
+ * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
784
+ * //=> Mon Sep 01 2014 00:00:00
785
+ */
786
+ function startOfMonth(date, options) {
787
+ const _date = toDate(date, options?.in);
788
+ _date.setDate(1);
789
+ _date.setHours(0, 0, 0, 0);
790
+ return _date;
791
+ }
792
+
793
+ /**
794
+ * The {@link startOfYear} function options.
795
+ */
796
+
797
+ /**
798
+ * @name startOfYear
799
+ * @category Year Helpers
800
+ * @summary Return the start of a year for the given date.
801
+ *
802
+ * @description
803
+ * Return the start of a year for the given date.
804
+ * The result will be in the local timezone.
805
+ *
806
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
807
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
808
+ *
809
+ * @param date - The original date
810
+ * @param options - The options
811
+ *
812
+ * @returns The start of a year
813
+ *
814
+ * @example
815
+ * // The start of a year for 2 September 2014 11:55:00:
816
+ * const result = startOfYear(new Date(2014, 8, 2, 11, 55, 00))
817
+ * //=> Wed Jan 01 2014 00:00:00
818
+ */
819
+ function startOfYear(date, options) {
820
+ const date_ = toDate(date, options?.in);
821
+ date_.setFullYear(date_.getFullYear(), 0, 1);
822
+ date_.setHours(0, 0, 0, 0);
823
+ return date_;
824
+ }
825
+
826
+ const formatDistanceLocale = {
827
+ lessThanXSeconds: {
828
+ one: "less than a second",
829
+ other: "less than {{count}} seconds",
830
+ },
831
+
832
+ xSeconds: {
833
+ one: "1 second",
834
+ other: "{{count}} seconds",
835
+ },
836
+
837
+ halfAMinute: "half a minute",
838
+
839
+ lessThanXMinutes: {
840
+ one: "less than a minute",
841
+ other: "less than {{count}} minutes",
842
+ },
843
+
844
+ xMinutes: {
845
+ one: "1 minute",
846
+ other: "{{count}} minutes",
847
+ },
848
+
849
+ aboutXHours: {
850
+ one: "about 1 hour",
851
+ other: "about {{count}} hours",
852
+ },
853
+
854
+ xHours: {
855
+ one: "1 hour",
856
+ other: "{{count}} hours",
857
+ },
858
+
859
+ xDays: {
860
+ one: "1 day",
861
+ other: "{{count}} days",
862
+ },
863
+
864
+ aboutXWeeks: {
865
+ one: "about 1 week",
866
+ other: "about {{count}} weeks",
867
+ },
868
+
869
+ xWeeks: {
870
+ one: "1 week",
871
+ other: "{{count}} weeks",
872
+ },
873
+
874
+ aboutXMonths: {
875
+ one: "about 1 month",
876
+ other: "about {{count}} months",
877
+ },
878
+
879
+ xMonths: {
880
+ one: "1 month",
881
+ other: "{{count}} months",
882
+ },
883
+
884
+ aboutXYears: {
885
+ one: "about 1 year",
886
+ other: "about {{count}} years",
887
+ },
888
+
889
+ xYears: {
890
+ one: "1 year",
891
+ other: "{{count}} years",
892
+ },
893
+
894
+ overXYears: {
895
+ one: "over 1 year",
896
+ other: "over {{count}} years",
897
+ },
898
+
899
+ almostXYears: {
900
+ one: "almost 1 year",
901
+ other: "almost {{count}} years",
902
+ },
903
+ };
904
+
905
+ const formatDistance = (token, count, options) => {
906
+ let result;
907
+
908
+ const tokenValue = formatDistanceLocale[token];
909
+ if (typeof tokenValue === "string") {
910
+ result = tokenValue;
911
+ } else if (count === 1) {
912
+ result = tokenValue.one;
913
+ } else {
914
+ result = tokenValue.other.replace("{{count}}", count.toString());
915
+ }
916
+
917
+ if (options?.addSuffix) {
918
+ if (options.comparison && options.comparison > 0) {
919
+ return "in " + result;
920
+ } else {
921
+ return result + " ago";
922
+ }
923
+ }
924
+
925
+ return result;
926
+ };
927
+
928
+ function buildFormatLongFn(args) {
929
+ return (options = {}) => {
930
+ // TODO: Remove String()
931
+ const width = options.width ? String(options.width) : args.defaultWidth;
932
+ const format = args.formats[width] || args.formats[args.defaultWidth];
933
+ return format;
934
+ };
935
+ }
936
+
937
+ const dateFormats = {
938
+ full: "EEEE, MMMM do, y",
939
+ long: "MMMM do, y",
940
+ medium: "MMM d, y",
941
+ short: "MM/dd/yyyy",
942
+ };
943
+
944
+ const timeFormats = {
945
+ full: "h:mm:ss a zzzz",
946
+ long: "h:mm:ss a z",
947
+ medium: "h:mm:ss a",
948
+ short: "h:mm a",
949
+ };
950
+
951
+ const dateTimeFormats = {
952
+ full: "{{date}} 'at' {{time}}",
953
+ long: "{{date}} 'at' {{time}}",
954
+ medium: "{{date}}, {{time}}",
955
+ short: "{{date}}, {{time}}",
956
+ };
957
+
958
+ const formatLong = {
959
+ date: buildFormatLongFn({
960
+ formats: dateFormats,
961
+ defaultWidth: "full",
962
+ }),
963
+
964
+ time: buildFormatLongFn({
965
+ formats: timeFormats,
966
+ defaultWidth: "full",
967
+ }),
968
+
969
+ dateTime: buildFormatLongFn({
970
+ formats: dateTimeFormats,
971
+ defaultWidth: "full",
972
+ }),
973
+ };
974
+
975
+ const formatRelativeLocale = {
976
+ lastWeek: "'last' eeee 'at' p",
977
+ yesterday: "'yesterday at' p",
978
+ today: "'today at' p",
979
+ tomorrow: "'tomorrow at' p",
980
+ nextWeek: "eeee 'at' p",
981
+ other: "P",
982
+ };
983
+
984
+ const formatRelative = (token, _date, _baseDate, _options) =>
985
+ formatRelativeLocale[token];
986
+
987
+ /**
988
+ * The localize function argument callback which allows to convert raw value to
989
+ * the actual type.
990
+ *
991
+ * @param value - The value to convert
992
+ *
993
+ * @returns The converted value
994
+ */
995
+
996
+ /**
997
+ * The map of localized values for each width.
998
+ */
999
+
1000
+ /**
1001
+ * The index type of the locale unit value. It types conversion of units of
1002
+ * values that don't start at 0 (i.e. quarters).
1003
+ */
1004
+
1005
+ /**
1006
+ * Converts the unit value to the tuple of values.
1007
+ */
1008
+
1009
+ /**
1010
+ * The tuple of localized era values. The first element represents BC,
1011
+ * the second element represents AD.
1012
+ */
1013
+
1014
+ /**
1015
+ * The tuple of localized quarter values. The first element represents Q1.
1016
+ */
1017
+
1018
+ /**
1019
+ * The tuple of localized day values. The first element represents Sunday.
1020
+ */
1021
+
1022
+ /**
1023
+ * The tuple of localized month values. The first element represents January.
1024
+ */
1025
+
1026
+ function buildLocalizeFn(args) {
1027
+ return (value, options) => {
1028
+ const context = options?.context ? String(options.context) : "standalone";
1029
+
1030
+ let valuesArray;
1031
+ if (context === "formatting" && args.formattingValues) {
1032
+ const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
1033
+ const width = options?.width ? String(options.width) : defaultWidth;
1034
+
1035
+ valuesArray =
1036
+ args.formattingValues[width] || args.formattingValues[defaultWidth];
1037
+ } else {
1038
+ const defaultWidth = args.defaultWidth;
1039
+ const width = options?.width ? String(options.width) : args.defaultWidth;
1040
+
1041
+ valuesArray = args.values[width] || args.values[defaultWidth];
1042
+ }
1043
+ const index = args.argumentCallback ? args.argumentCallback(value) : value;
1044
+
1045
+ // @ts-expect-error - 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!
1046
+ return valuesArray[index];
1047
+ };
1048
+ }
1049
+
1050
+ const eraValues = {
1051
+ narrow: ["B", "A"],
1052
+ abbreviated: ["BC", "AD"],
1053
+ wide: ["Before Christ", "Anno Domini"],
1054
+ };
1055
+
1056
+ const quarterValues = {
1057
+ narrow: ["1", "2", "3", "4"],
1058
+ abbreviated: ["Q1", "Q2", "Q3", "Q4"],
1059
+ wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"],
1060
+ };
1061
+
1062
+ // Note: in English, the names of days of the week and months are capitalized.
1063
+ // If you are making a new locale based on this one, check if the same is true for the language you're working on.
1064
+ // Generally, formatted dates should look like they are in the middle of a sentence,
1065
+ // e.g. in Spanish language the weekdays and months should be in the lowercase.
1066
+ const monthValues = {
1067
+ narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
1068
+ abbreviated: [
1069
+ "Jan",
1070
+ "Feb",
1071
+ "Mar",
1072
+ "Apr",
1073
+ "May",
1074
+ "Jun",
1075
+ "Jul",
1076
+ "Aug",
1077
+ "Sep",
1078
+ "Oct",
1079
+ "Nov",
1080
+ "Dec",
1081
+ ],
1082
+
1083
+ wide: [
1084
+ "January",
1085
+ "February",
1086
+ "March",
1087
+ "April",
1088
+ "May",
1089
+ "June",
1090
+ "July",
1091
+ "August",
1092
+ "September",
1093
+ "October",
1094
+ "November",
1095
+ "December",
1096
+ ],
1097
+ };
1098
+
1099
+ const dayValues = {
1100
+ narrow: ["S", "M", "T", "W", "T", "F", "S"],
1101
+ short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
1102
+ abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1103
+ wide: [
1104
+ "Sunday",
1105
+ "Monday",
1106
+ "Tuesday",
1107
+ "Wednesday",
1108
+ "Thursday",
1109
+ "Friday",
1110
+ "Saturday",
1111
+ ],
1112
+ };
1113
+
1114
+ const dayPeriodValues = {
1115
+ narrow: {
1116
+ am: "a",
1117
+ pm: "p",
1118
+ midnight: "mi",
1119
+ noon: "n",
1120
+ morning: "morning",
1121
+ afternoon: "afternoon",
1122
+ evening: "evening",
1123
+ night: "night",
1124
+ },
1125
+ abbreviated: {
1126
+ am: "AM",
1127
+ pm: "PM",
1128
+ midnight: "midnight",
1129
+ noon: "noon",
1130
+ morning: "morning",
1131
+ afternoon: "afternoon",
1132
+ evening: "evening",
1133
+ night: "night",
1134
+ },
1135
+ wide: {
1136
+ am: "a.m.",
1137
+ pm: "p.m.",
1138
+ midnight: "midnight",
1139
+ noon: "noon",
1140
+ morning: "morning",
1141
+ afternoon: "afternoon",
1142
+ evening: "evening",
1143
+ night: "night",
1144
+ },
1145
+ };
1146
+
1147
+ const formattingDayPeriodValues = {
1148
+ narrow: {
1149
+ am: "a",
1150
+ pm: "p",
1151
+ midnight: "mi",
1152
+ noon: "n",
1153
+ morning: "in the morning",
1154
+ afternoon: "in the afternoon",
1155
+ evening: "in the evening",
1156
+ night: "at night",
1157
+ },
1158
+ abbreviated: {
1159
+ am: "AM",
1160
+ pm: "PM",
1161
+ midnight: "midnight",
1162
+ noon: "noon",
1163
+ morning: "in the morning",
1164
+ afternoon: "in the afternoon",
1165
+ evening: "in the evening",
1166
+ night: "at night",
1167
+ },
1168
+ wide: {
1169
+ am: "a.m.",
1170
+ pm: "p.m.",
1171
+ midnight: "midnight",
1172
+ noon: "noon",
1173
+ morning: "in the morning",
1174
+ afternoon: "in the afternoon",
1175
+ evening: "in the evening",
1176
+ night: "at night",
1177
+ },
1178
+ };
1179
+
1180
+ const ordinalNumber = (dirtyNumber, _options) => {
1181
+ const number = Number(dirtyNumber);
1182
+
1183
+ // If ordinal numbers depend on context, for example,
1184
+ // if they are different for different grammatical genders,
1185
+ // use `options.unit`.
1186
+ //
1187
+ // `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
1188
+ // 'day', 'hour', 'minute', 'second'.
1189
+
1190
+ const rem100 = number % 100;
1191
+ if (rem100 > 20 || rem100 < 10) {
1192
+ switch (rem100 % 10) {
1193
+ case 1:
1194
+ return number + "st";
1195
+ case 2:
1196
+ return number + "nd";
1197
+ case 3:
1198
+ return number + "rd";
1199
+ }
1200
+ }
1201
+ return number + "th";
1202
+ };
1203
+
1204
+ const localize = {
1205
+ ordinalNumber,
1206
+
1207
+ era: buildLocalizeFn({
1208
+ values: eraValues,
1209
+ defaultWidth: "wide",
1210
+ }),
1211
+
1212
+ quarter: buildLocalizeFn({
1213
+ values: quarterValues,
1214
+ defaultWidth: "wide",
1215
+ argumentCallback: (quarter) => quarter - 1,
1216
+ }),
1217
+
1218
+ month: buildLocalizeFn({
1219
+ values: monthValues,
1220
+ defaultWidth: "wide",
1221
+ }),
1222
+
1223
+ day: buildLocalizeFn({
1224
+ values: dayValues,
1225
+ defaultWidth: "wide",
1226
+ }),
1227
+
1228
+ dayPeriod: buildLocalizeFn({
1229
+ values: dayPeriodValues,
1230
+ defaultWidth: "wide",
1231
+ formattingValues: formattingDayPeriodValues,
1232
+ defaultFormattingWidth: "wide",
1233
+ }),
1234
+ };
1235
+
1236
+ function buildMatchFn(args) {
1237
+ return (string, options = {}) => {
1238
+ const width = options.width;
1239
+
1240
+ const matchPattern =
1241
+ (width && args.matchPatterns[width]) ||
1242
+ args.matchPatterns[args.defaultMatchWidth];
1243
+ const matchResult = string.match(matchPattern);
1244
+
1245
+ if (!matchResult) {
1246
+ return null;
1247
+ }
1248
+ const matchedString = matchResult[0];
1249
+
1250
+ const parsePatterns =
1251
+ (width && args.parsePatterns[width]) ||
1252
+ args.parsePatterns[args.defaultParseWidth];
1253
+
1254
+ const key = Array.isArray(parsePatterns)
1255
+ ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString))
1256
+ : // [TODO] -- I challenge you to fix the type
1257
+ findKey(parsePatterns, (pattern) => pattern.test(matchedString));
1258
+
1259
+ let value;
1260
+
1261
+ value = args.valueCallback ? args.valueCallback(key) : key;
1262
+ value = options.valueCallback
1263
+ ? // [TODO] -- I challenge you to fix the type
1264
+ options.valueCallback(value)
1265
+ : value;
1266
+
1267
+ const rest = string.slice(matchedString.length);
1268
+
1269
+ return { value, rest };
1270
+ };
1271
+ }
1272
+
1273
+ function findKey(object, predicate) {
1274
+ for (const key in object) {
1275
+ if (
1276
+ Object.prototype.hasOwnProperty.call(object, key) &&
1277
+ predicate(object[key])
1278
+ ) {
1279
+ return key;
1280
+ }
1281
+ }
1282
+ return undefined;
1283
+ }
1284
+
1285
+ function findIndex(array, predicate) {
1286
+ for (let key = 0; key < array.length; key++) {
1287
+ if (predicate(array[key])) {
1288
+ return key;
1289
+ }
1290
+ }
1291
+ return undefined;
1292
+ }
1293
+
1294
+ function buildMatchPatternFn(args) {
1295
+ return (string, options = {}) => {
1296
+ const matchResult = string.match(args.matchPattern);
1297
+ if (!matchResult) return null;
1298
+ const matchedString = matchResult[0];
1299
+
1300
+ const parseResult = string.match(args.parsePattern);
1301
+ if (!parseResult) return null;
1302
+ let value = args.valueCallback
1303
+ ? args.valueCallback(parseResult[0])
1304
+ : parseResult[0];
1305
+
1306
+ // [TODO] I challenge you to fix the type
1307
+ value = options.valueCallback ? options.valueCallback(value) : value;
1308
+
1309
+ const rest = string.slice(matchedString.length);
1310
+
1311
+ return { value, rest };
1312
+ };
1313
+ }
1314
+
1315
+ const matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
1316
+ const parseOrdinalNumberPattern = /\d+/i;
1317
+
1318
+ const matchEraPatterns = {
1319
+ narrow: /^(b|a)/i,
1320
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1321
+ wide: /^(before christ|before common era|anno domini|common era)/i,
1322
+ };
1323
+ const parseEraPatterns = {
1324
+ any: [/^b/i, /^(a|c)/i],
1325
+ };
1326
+
1327
+ const matchQuarterPatterns = {
1328
+ narrow: /^[1234]/i,
1329
+ abbreviated: /^q[1234]/i,
1330
+ wide: /^[1234](th|st|nd|rd)? quarter/i,
1331
+ };
1332
+ const parseQuarterPatterns = {
1333
+ any: [/1/i, /2/i, /3/i, /4/i],
1334
+ };
1335
+
1336
+ const matchMonthPatterns = {
1337
+ narrow: /^[jfmasond]/i,
1338
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
1339
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i,
1340
+ };
1341
+ const parseMonthPatterns = {
1342
+ narrow: [
1343
+ /^j/i,
1344
+ /^f/i,
1345
+ /^m/i,
1346
+ /^a/i,
1347
+ /^m/i,
1348
+ /^j/i,
1349
+ /^j/i,
1350
+ /^a/i,
1351
+ /^s/i,
1352
+ /^o/i,
1353
+ /^n/i,
1354
+ /^d/i,
1355
+ ],
1356
+
1357
+ any: [
1358
+ /^ja/i,
1359
+ /^f/i,
1360
+ /^mar/i,
1361
+ /^ap/i,
1362
+ /^may/i,
1363
+ /^jun/i,
1364
+ /^jul/i,
1365
+ /^au/i,
1366
+ /^s/i,
1367
+ /^o/i,
1368
+ /^n/i,
1369
+ /^d/i,
1370
+ ],
1371
+ };
1372
+
1373
+ const matchDayPatterns = {
1374
+ narrow: /^[smtwf]/i,
1375
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
1376
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
1377
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i,
1378
+ };
1379
+ const parseDayPatterns = {
1380
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
1381
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i],
1382
+ };
1383
+
1384
+ const matchDayPeriodPatterns = {
1385
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
1386
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i,
1387
+ };
1388
+ const parseDayPeriodPatterns = {
1389
+ any: {
1390
+ am: /^a/i,
1391
+ pm: /^p/i,
1392
+ midnight: /^mi/i,
1393
+ noon: /^no/i,
1394
+ morning: /morning/i,
1395
+ afternoon: /afternoon/i,
1396
+ evening: /evening/i,
1397
+ night: /night/i,
1398
+ },
1399
+ };
1400
+
1401
+ const match = {
1402
+ ordinalNumber: buildMatchPatternFn({
1403
+ matchPattern: matchOrdinalNumberPattern,
1404
+ parsePattern: parseOrdinalNumberPattern,
1405
+ valueCallback: (value) => parseInt(value, 10),
1406
+ }),
1407
+
1408
+ era: buildMatchFn({
1409
+ matchPatterns: matchEraPatterns,
1410
+ defaultMatchWidth: "wide",
1411
+ parsePatterns: parseEraPatterns,
1412
+ defaultParseWidth: "any",
1413
+ }),
1414
+
1415
+ quarter: buildMatchFn({
1416
+ matchPatterns: matchQuarterPatterns,
1417
+ defaultMatchWidth: "wide",
1418
+ parsePatterns: parseQuarterPatterns,
1419
+ defaultParseWidth: "any",
1420
+ valueCallback: (index) => index + 1,
1421
+ }),
1422
+
1423
+ month: buildMatchFn({
1424
+ matchPatterns: matchMonthPatterns,
1425
+ defaultMatchWidth: "wide",
1426
+ parsePatterns: parseMonthPatterns,
1427
+ defaultParseWidth: "any",
1428
+ }),
1429
+
1430
+ day: buildMatchFn({
1431
+ matchPatterns: matchDayPatterns,
1432
+ defaultMatchWidth: "wide",
1433
+ parsePatterns: parseDayPatterns,
1434
+ defaultParseWidth: "any",
1435
+ }),
1436
+
1437
+ dayPeriod: buildMatchFn({
1438
+ matchPatterns: matchDayPeriodPatterns,
1439
+ defaultMatchWidth: "any",
1440
+ parsePatterns: parseDayPeriodPatterns,
1441
+ defaultParseWidth: "any",
1442
+ }),
1443
+ };
1444
+
1445
+ /**
1446
+ * @category Locales
1447
+ * @summary English locale (United States).
1448
+ * @language English
1449
+ * @iso-639-2 eng
1450
+ * @author Sasha Koss [@kossnocorp](https://github.com/kossnocorp)
1451
+ * @author Lesha Koss [@leshakoss](https://github.com/leshakoss)
1452
+ */
1453
+ const enUS = {
1454
+ code: "en-US",
1455
+ formatDistance: formatDistance,
1456
+ formatLong: formatLong,
1457
+ formatRelative: formatRelative,
1458
+ localize: localize,
1459
+ match: match,
1460
+ options: {
1461
+ weekStartsOn: 0 /* Sunday */,
1462
+ firstWeekContainsDate: 1,
1463
+ },
1464
+ };
1465
+
1466
+ /**
1467
+ * The {@link getDayOfYear} function options.
1468
+ */
1469
+
1470
+ /**
1471
+ * @name getDayOfYear
1472
+ * @category Day Helpers
1473
+ * @summary Get the day of the year of the given date.
1474
+ *
1475
+ * @description
1476
+ * Get the day of the year of the given date.
1477
+ *
1478
+ * @param date - The given date
1479
+ * @param options - The options
1480
+ *
1481
+ * @returns The day of year
1482
+ *
1483
+ * @example
1484
+ * // Which day of the year is 2 July 2014?
1485
+ * const result = getDayOfYear(new Date(2014, 6, 2))
1486
+ * //=> 183
1487
+ */
1488
+ function getDayOfYear(date, options) {
1489
+ const _date = toDate(date, options?.in);
1490
+ const diff = differenceInCalendarDays(_date, startOfYear(_date));
1491
+ const dayOfYear = diff + 1;
1492
+ return dayOfYear;
1493
+ }
1494
+
1495
+ /**
1496
+ * The {@link getISOWeek} function options.
1497
+ */
1498
+
1499
+ /**
1500
+ * @name getISOWeek
1501
+ * @category ISO Week Helpers
1502
+ * @summary Get the ISO week of the given date.
1503
+ *
1504
+ * @description
1505
+ * Get the ISO week of the given date.
1506
+ *
1507
+ * ISO week-numbering year: http://en.wikipedia.org/wiki/ISO_week_date
1508
+ *
1509
+ * @param date - The given date
1510
+ * @param options - The options
1511
+ *
1512
+ * @returns The ISO week
1513
+ *
1514
+ * @example
1515
+ * // Which week of the ISO-week numbering year is 2 January 2005?
1516
+ * const result = getISOWeek(new Date(2005, 0, 2))
1517
+ * //=> 53
1518
+ */
1519
+ function getISOWeek(date, options) {
1520
+ const _date = toDate(date, options?.in);
1521
+ const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
1522
+
1523
+ // Round the number of weeks to the nearest integer because the number of
1524
+ // milliseconds in a week is not constant (e.g. it's different in the week of
1525
+ // the daylight saving time clock shift).
1526
+ return Math.round(diff / millisecondsInWeek) + 1;
1527
+ }
1528
+
1529
+ /**
1530
+ * The {@link getWeekYear} function options.
1531
+ */
1532
+
1533
+ /**
1534
+ * @name getWeekYear
1535
+ * @category Week-Numbering Year Helpers
1536
+ * @summary Get the local week-numbering year of the given date.
1537
+ *
1538
+ * @description
1539
+ * Get the local week-numbering year of the given date.
1540
+ * The exact calculation depends on the values of
1541
+ * `options.weekStartsOn` (which is the index of the first day of the week)
1542
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
1543
+ * the first week of the week-numbering year)
1544
+ *
1545
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
1546
+ *
1547
+ * @param date - The given date
1548
+ * @param options - An object with options.
1549
+ *
1550
+ * @returns The local week-numbering year
1551
+ *
1552
+ * @example
1553
+ * // Which week numbering year is 26 December 2004 with the default settings?
1554
+ * const result = getWeekYear(new Date(2004, 11, 26))
1555
+ * //=> 2005
1556
+ *
1557
+ * @example
1558
+ * // Which week numbering year is 26 December 2004 if week starts on Saturday?
1559
+ * const result = getWeekYear(new Date(2004, 11, 26), { weekStartsOn: 6 })
1560
+ * //=> 2004
1561
+ *
1562
+ * @example
1563
+ * // Which week numbering year is 26 December 2004 if the first week contains 4 January?
1564
+ * const result = getWeekYear(new Date(2004, 11, 26), { firstWeekContainsDate: 4 })
1565
+ * //=> 2004
1566
+ */
1567
+ function getWeekYear(date, options) {
1568
+ const _date = toDate(date, options?.in);
1569
+ const year = _date.getFullYear();
1570
+
1571
+ const defaultOptions = getDefaultOptions();
1572
+ const firstWeekContainsDate =
1573
+ options?.firstWeekContainsDate ??
1574
+ options?.locale?.options?.firstWeekContainsDate ??
1575
+ defaultOptions.firstWeekContainsDate ??
1576
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
1577
+ 1;
1578
+
1579
+ const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
1580
+ firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
1581
+ firstWeekOfNextYear.setHours(0, 0, 0, 0);
1582
+ const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
1583
+
1584
+ const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
1585
+ firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
1586
+ firstWeekOfThisYear.setHours(0, 0, 0, 0);
1587
+ const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
1588
+
1589
+ if (+_date >= +startOfNextYear) {
1590
+ return year + 1;
1591
+ } else if (+_date >= +startOfThisYear) {
1592
+ return year;
1593
+ } else {
1594
+ return year - 1;
1595
+ }
1596
+ }
1597
+
1598
+ /**
1599
+ * The {@link startOfWeekYear} function options.
1600
+ */
1601
+
1602
+ /**
1603
+ * @name startOfWeekYear
1604
+ * @category Week-Numbering Year Helpers
1605
+ * @summary Return the start of a local week-numbering year for the given date.
1606
+ *
1607
+ * @description
1608
+ * Return the start of a local week-numbering year.
1609
+ * The exact calculation depends on the values of
1610
+ * `options.weekStartsOn` (which is the index of the first day of the week)
1611
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
1612
+ * the first week of the week-numbering year)
1613
+ *
1614
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
1615
+ *
1616
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
1617
+ * @typeParam ResultDate - The result `Date` type.
1618
+ *
1619
+ * @param date - The original date
1620
+ * @param options - An object with options
1621
+ *
1622
+ * @returns The start of a week-numbering year
1623
+ *
1624
+ * @example
1625
+ * // The start of an a week-numbering year for 2 July 2005 with default settings:
1626
+ * const result = startOfWeekYear(new Date(2005, 6, 2))
1627
+ * //=> Sun Dec 26 2004 00:00:00
1628
+ *
1629
+ * @example
1630
+ * // The start of a week-numbering year for 2 July 2005
1631
+ * // if Monday is the first day of week
1632
+ * // and 4 January is always in the first week of the year:
1633
+ * const result = startOfWeekYear(new Date(2005, 6, 2), {
1634
+ * weekStartsOn: 1,
1635
+ * firstWeekContainsDate: 4
1636
+ * })
1637
+ * //=> Mon Jan 03 2005 00:00:00
1638
+ */
1639
+ function startOfWeekYear(date, options) {
1640
+ const defaultOptions = getDefaultOptions();
1641
+ const firstWeekContainsDate =
1642
+ options?.firstWeekContainsDate ??
1643
+ options?.locale?.options?.firstWeekContainsDate ??
1644
+ defaultOptions.firstWeekContainsDate ??
1645
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
1646
+ 1;
1647
+
1648
+ const year = getWeekYear(date, options);
1649
+ const firstWeek = constructFrom(options?.in || date, 0);
1650
+ firstWeek.setFullYear(year, 0, firstWeekContainsDate);
1651
+ firstWeek.setHours(0, 0, 0, 0);
1652
+ const _date = startOfWeek(firstWeek, options);
1653
+ return _date;
1654
+ }
1655
+
1656
+ /**
1657
+ * The {@link getWeek} function options.
1658
+ */
1659
+
1660
+ /**
1661
+ * @name getWeek
1662
+ * @category Week Helpers
1663
+ * @summary Get the local week index of the given date.
1664
+ *
1665
+ * @description
1666
+ * Get the local week index of the given date.
1667
+ * The exact calculation depends on the values of
1668
+ * `options.weekStartsOn` (which is the index of the first day of the week)
1669
+ * and `options.firstWeekContainsDate` (which is the day of January, which is always in
1670
+ * the first week of the week-numbering year)
1671
+ *
1672
+ * Week numbering: https://en.wikipedia.org/wiki/Week#The_ISO_week_date_system
1673
+ *
1674
+ * @param date - The given date
1675
+ * @param options - An object with options
1676
+ *
1677
+ * @returns The week
1678
+ *
1679
+ * @example
1680
+ * // Which week of the local week numbering year is 2 January 2005 with default options?
1681
+ * const result = getWeek(new Date(2005, 0, 2))
1682
+ * //=> 2
1683
+ *
1684
+ * @example
1685
+ * // Which week of the local week numbering year is 2 January 2005,
1686
+ * // if Monday is the first day of the week,
1687
+ * // and the first week of the year always contains 4 January?
1688
+ * const result = getWeek(new Date(2005, 0, 2), {
1689
+ * weekStartsOn: 1,
1690
+ * firstWeekContainsDate: 4
1691
+ * })
1692
+ * //=> 53
1693
+ */
1694
+ function getWeek(date, options) {
1695
+ const _date = toDate(date, options?.in);
1696
+ const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
1697
+
1698
+ // Round the number of weeks to the nearest integer because the number of
1699
+ // milliseconds in a week is not constant (e.g. it's different in the week of
1700
+ // the daylight saving time clock shift).
1701
+ return Math.round(diff / millisecondsInWeek) + 1;
1702
+ }
1703
+
1704
+ function addLeadingZeros(number, targetLength) {
1705
+ const sign = number < 0 ? "-" : "";
1706
+ const output = Math.abs(number).toString().padStart(targetLength, "0");
1707
+ return sign + output;
1708
+ }
1709
+
1710
+ /*
1711
+ * | | Unit | | Unit |
1712
+ * |-----|--------------------------------|-----|--------------------------------|
1713
+ * | a | AM, PM | A* | |
1714
+ * | d | Day of month | D | |
1715
+ * | h | Hour [1-12] | H | Hour [0-23] |
1716
+ * | m | Minute | M | Month |
1717
+ * | s | Second | S | Fraction of second |
1718
+ * | y | Year (abs) | Y | |
1719
+ *
1720
+ * Letters marked by * are not implemented but reserved by Unicode standard.
1721
+ */
1722
+
1723
+ const lightFormatters = {
1724
+ // Year
1725
+ y(date, token) {
1726
+ // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens
1727
+ // | Year | y | yy | yyy | yyyy | yyyyy |
1728
+ // |----------|-------|----|-------|-------|-------|
1729
+ // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |
1730
+ // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |
1731
+ // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |
1732
+ // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |
1733
+ // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |
1734
+
1735
+ const signedYear = date.getFullYear();
1736
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1737
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
1738
+ return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
1739
+ },
1740
+
1741
+ // Month
1742
+ M(date, token) {
1743
+ const month = date.getMonth();
1744
+ return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
1745
+ },
1746
+
1747
+ // Day of the month
1748
+ d(date, token) {
1749
+ return addLeadingZeros(date.getDate(), token.length);
1750
+ },
1751
+
1752
+ // AM or PM
1753
+ a(date, token) {
1754
+ const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
1755
+
1756
+ switch (token) {
1757
+ case "a":
1758
+ case "aa":
1759
+ return dayPeriodEnumValue.toUpperCase();
1760
+ case "aaa":
1761
+ return dayPeriodEnumValue;
1762
+ case "aaaaa":
1763
+ return dayPeriodEnumValue[0];
1764
+ case "aaaa":
1765
+ default:
1766
+ return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
1767
+ }
1768
+ },
1769
+
1770
+ // Hour [1-12]
1771
+ h(date, token) {
1772
+ return addLeadingZeros(date.getHours() % 12 || 12, token.length);
1773
+ },
1774
+
1775
+ // Hour [0-23]
1776
+ H(date, token) {
1777
+ return addLeadingZeros(date.getHours(), token.length);
1778
+ },
1779
+
1780
+ // Minute
1781
+ m(date, token) {
1782
+ return addLeadingZeros(date.getMinutes(), token.length);
1783
+ },
1784
+
1785
+ // Second
1786
+ s(date, token) {
1787
+ return addLeadingZeros(date.getSeconds(), token.length);
1788
+ },
1789
+
1790
+ // Fraction of second
1791
+ S(date, token) {
1792
+ const numberOfDigits = token.length;
1793
+ const milliseconds = date.getMilliseconds();
1794
+ const fractionalSeconds = Math.trunc(
1795
+ milliseconds * Math.pow(10, numberOfDigits - 3),
1796
+ );
1797
+ return addLeadingZeros(fractionalSeconds, token.length);
1798
+ },
1799
+ };
1800
+
1801
+ const dayPeriodEnum = {
1802
+ am: "am",
1803
+ pm: "pm",
1804
+ midnight: "midnight",
1805
+ noon: "noon",
1806
+ morning: "morning",
1807
+ afternoon: "afternoon",
1808
+ evening: "evening",
1809
+ night: "night",
1810
+ };
1811
+
1812
+ /*
1813
+ * | | Unit | | Unit |
1814
+ * |-----|--------------------------------|-----|--------------------------------|
1815
+ * | a | AM, PM | A* | Milliseconds in day |
1816
+ * | b | AM, PM, noon, midnight | B | Flexible day period |
1817
+ * | c | Stand-alone local day of week | C* | Localized hour w/ day period |
1818
+ * | d | Day of month | D | Day of year |
1819
+ * | e | Local day of week | E | Day of week |
1820
+ * | f | | F* | Day of week in month |
1821
+ * | g* | Modified Julian day | G | Era |
1822
+ * | h | Hour [1-12] | H | Hour [0-23] |
1823
+ * | i! | ISO day of week | I! | ISO week of year |
1824
+ * | j* | Localized hour w/ day period | J* | Localized hour w/o day period |
1825
+ * | k | Hour [1-24] | K | Hour [0-11] |
1826
+ * | l* | (deprecated) | L | Stand-alone month |
1827
+ * | m | Minute | M | Month |
1828
+ * | n | | N | |
1829
+ * | o! | Ordinal number modifier | O | Timezone (GMT) |
1830
+ * | p! | Long localized time | P! | Long localized date |
1831
+ * | q | Stand-alone quarter | Q | Quarter |
1832
+ * | r* | Related Gregorian year | R! | ISO week-numbering year |
1833
+ * | s | Second | S | Fraction of second |
1834
+ * | t! | Seconds timestamp | T! | Milliseconds timestamp |
1835
+ * | u | Extended year | U* | Cyclic year |
1836
+ * | v* | Timezone (generic non-locat.) | V* | Timezone (location) |
1837
+ * | w | Local week of year | W* | Week of month |
1838
+ * | x | Timezone (ISO-8601 w/o Z) | X | Timezone (ISO-8601) |
1839
+ * | y | Year (abs) | Y | Local week-numbering year |
1840
+ * | z | Timezone (specific non-locat.) | Z* | Timezone (aliases) |
1841
+ *
1842
+ * Letters marked by * are not implemented but reserved by Unicode standard.
1843
+ *
1844
+ * Letters marked by ! are non-standard, but implemented by date-fns:
1845
+ * - `o` modifies the previous token to turn it into an ordinal (see `format` docs)
1846
+ * - `i` is ISO day of week. For `i` and `ii` is returns numeric ISO week days,
1847
+ * i.e. 7 for Sunday, 1 for Monday, etc.
1848
+ * - `I` is ISO week of year, as opposed to `w` which is local week of year.
1849
+ * - `R` is ISO week-numbering year, as opposed to `Y` which is local week-numbering year.
1850
+ * `R` is supposed to be used in conjunction with `I` and `i`
1851
+ * for universal ISO week-numbering date, whereas
1852
+ * `Y` is supposed to be used in conjunction with `w` and `e`
1853
+ * for week-numbering date specific to the locale.
1854
+ * - `P` is long localized date format
1855
+ * - `p` is long localized time format
1856
+ */
1857
+
1858
+ const formatters = {
1859
+ // Era
1860
+ G: function (date, token, localize) {
1861
+ const era = date.getFullYear() > 0 ? 1 : 0;
1862
+ switch (token) {
1863
+ // AD, BC
1864
+ case "G":
1865
+ case "GG":
1866
+ case "GGG":
1867
+ return localize.era(era, { width: "abbreviated" });
1868
+ // A, B
1869
+ case "GGGGG":
1870
+ return localize.era(era, { width: "narrow" });
1871
+ // Anno Domini, Before Christ
1872
+ case "GGGG":
1873
+ default:
1874
+ return localize.era(era, { width: "wide" });
1875
+ }
1876
+ },
1877
+
1878
+ // Year
1879
+ y: function (date, token, localize) {
1880
+ // Ordinal number
1881
+ if (token === "yo") {
1882
+ const signedYear = date.getFullYear();
1883
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1884
+ const year = signedYear > 0 ? signedYear : 1 - signedYear;
1885
+ return localize.ordinalNumber(year, { unit: "year" });
1886
+ }
1887
+
1888
+ return lightFormatters.y(date, token);
1889
+ },
1890
+
1891
+ // Local week-numbering year
1892
+ Y: function (date, token, localize, options) {
1893
+ const signedWeekYear = getWeekYear(date, options);
1894
+ // Returns 1 for 1 BC (which is year 0 in JavaScript)
1895
+ const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
1896
+
1897
+ // Two digit year
1898
+ if (token === "YY") {
1899
+ const twoDigitYear = weekYear % 100;
1900
+ return addLeadingZeros(twoDigitYear, 2);
1901
+ }
1902
+
1903
+ // Ordinal number
1904
+ if (token === "Yo") {
1905
+ return localize.ordinalNumber(weekYear, { unit: "year" });
1906
+ }
1907
+
1908
+ // Padding
1909
+ return addLeadingZeros(weekYear, token.length);
1910
+ },
1911
+
1912
+ // ISO week-numbering year
1913
+ R: function (date, token) {
1914
+ const isoWeekYear = getISOWeekYear(date);
1915
+
1916
+ // Padding
1917
+ return addLeadingZeros(isoWeekYear, token.length);
1918
+ },
1919
+
1920
+ // Extended year. This is a single number designating the year of this calendar system.
1921
+ // The main difference between `y` and `u` localizers are B.C. years:
1922
+ // | Year | `y` | `u` |
1923
+ // |------|-----|-----|
1924
+ // | AC 1 | 1 | 1 |
1925
+ // | BC 1 | 1 | 0 |
1926
+ // | BC 2 | 2 | -1 |
1927
+ // Also `yy` always returns the last two digits of a year,
1928
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1929
+ u: function (date, token) {
1930
+ const year = date.getFullYear();
1931
+ return addLeadingZeros(year, token.length);
1932
+ },
1933
+
1934
+ // Quarter
1935
+ Q: function (date, token, localize) {
1936
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
1937
+ switch (token) {
1938
+ // 1, 2, 3, 4
1939
+ case "Q":
1940
+ return String(quarter);
1941
+ // 01, 02, 03, 04
1942
+ case "QQ":
1943
+ return addLeadingZeros(quarter, 2);
1944
+ // 1st, 2nd, 3rd, 4th
1945
+ case "Qo":
1946
+ return localize.ordinalNumber(quarter, { unit: "quarter" });
1947
+ // Q1, Q2, Q3, Q4
1948
+ case "QQQ":
1949
+ return localize.quarter(quarter, {
1950
+ width: "abbreviated",
1951
+ context: "formatting",
1952
+ });
1953
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1954
+ case "QQQQQ":
1955
+ return localize.quarter(quarter, {
1956
+ width: "narrow",
1957
+ context: "formatting",
1958
+ });
1959
+ // 1st quarter, 2nd quarter, ...
1960
+ case "QQQQ":
1961
+ default:
1962
+ return localize.quarter(quarter, {
1963
+ width: "wide",
1964
+ context: "formatting",
1965
+ });
1966
+ }
1967
+ },
1968
+
1969
+ // Stand-alone quarter
1970
+ q: function (date, token, localize) {
1971
+ const quarter = Math.ceil((date.getMonth() + 1) / 3);
1972
+ switch (token) {
1973
+ // 1, 2, 3, 4
1974
+ case "q":
1975
+ return String(quarter);
1976
+ // 01, 02, 03, 04
1977
+ case "qq":
1978
+ return addLeadingZeros(quarter, 2);
1979
+ // 1st, 2nd, 3rd, 4th
1980
+ case "qo":
1981
+ return localize.ordinalNumber(quarter, { unit: "quarter" });
1982
+ // Q1, Q2, Q3, Q4
1983
+ case "qqq":
1984
+ return localize.quarter(quarter, {
1985
+ width: "abbreviated",
1986
+ context: "standalone",
1987
+ });
1988
+ // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1989
+ case "qqqqq":
1990
+ return localize.quarter(quarter, {
1991
+ width: "narrow",
1992
+ context: "standalone",
1993
+ });
1994
+ // 1st quarter, 2nd quarter, ...
1995
+ case "qqqq":
1996
+ default:
1997
+ return localize.quarter(quarter, {
1998
+ width: "wide",
1999
+ context: "standalone",
2000
+ });
2001
+ }
2002
+ },
2003
+
2004
+ // Month
2005
+ M: function (date, token, localize) {
2006
+ const month = date.getMonth();
2007
+ switch (token) {
2008
+ case "M":
2009
+ case "MM":
2010
+ return lightFormatters.M(date, token);
2011
+ // 1st, 2nd, ..., 12th
2012
+ case "Mo":
2013
+ return localize.ordinalNumber(month + 1, { unit: "month" });
2014
+ // Jan, Feb, ..., Dec
2015
+ case "MMM":
2016
+ return localize.month(month, {
2017
+ width: "abbreviated",
2018
+ context: "formatting",
2019
+ });
2020
+ // J, F, ..., D
2021
+ case "MMMMM":
2022
+ return localize.month(month, {
2023
+ width: "narrow",
2024
+ context: "formatting",
2025
+ });
2026
+ // January, February, ..., December
2027
+ case "MMMM":
2028
+ default:
2029
+ return localize.month(month, { width: "wide", context: "formatting" });
2030
+ }
2031
+ },
2032
+
2033
+ // Stand-alone month
2034
+ L: function (date, token, localize) {
2035
+ const month = date.getMonth();
2036
+ switch (token) {
2037
+ // 1, 2, ..., 12
2038
+ case "L":
2039
+ return String(month + 1);
2040
+ // 01, 02, ..., 12
2041
+ case "LL":
2042
+ return addLeadingZeros(month + 1, 2);
2043
+ // 1st, 2nd, ..., 12th
2044
+ case "Lo":
2045
+ return localize.ordinalNumber(month + 1, { unit: "month" });
2046
+ // Jan, Feb, ..., Dec
2047
+ case "LLL":
2048
+ return localize.month(month, {
2049
+ width: "abbreviated",
2050
+ context: "standalone",
2051
+ });
2052
+ // J, F, ..., D
2053
+ case "LLLLL":
2054
+ return localize.month(month, {
2055
+ width: "narrow",
2056
+ context: "standalone",
2057
+ });
2058
+ // January, February, ..., December
2059
+ case "LLLL":
2060
+ default:
2061
+ return localize.month(month, { width: "wide", context: "standalone" });
2062
+ }
2063
+ },
2064
+
2065
+ // Local week of year
2066
+ w: function (date, token, localize, options) {
2067
+ const week = getWeek(date, options);
2068
+
2069
+ if (token === "wo") {
2070
+ return localize.ordinalNumber(week, { unit: "week" });
2071
+ }
2072
+
2073
+ return addLeadingZeros(week, token.length);
2074
+ },
2075
+
2076
+ // ISO week of year
2077
+ I: function (date, token, localize) {
2078
+ const isoWeek = getISOWeek(date);
2079
+
2080
+ if (token === "Io") {
2081
+ return localize.ordinalNumber(isoWeek, { unit: "week" });
2082
+ }
2083
+
2084
+ return addLeadingZeros(isoWeek, token.length);
2085
+ },
2086
+
2087
+ // Day of the month
2088
+ d: function (date, token, localize) {
2089
+ if (token === "do") {
2090
+ return localize.ordinalNumber(date.getDate(), { unit: "date" });
2091
+ }
2092
+
2093
+ return lightFormatters.d(date, token);
2094
+ },
2095
+
2096
+ // Day of year
2097
+ D: function (date, token, localize) {
2098
+ const dayOfYear = getDayOfYear(date);
2099
+
2100
+ if (token === "Do") {
2101
+ return localize.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
2102
+ }
2103
+
2104
+ return addLeadingZeros(dayOfYear, token.length);
2105
+ },
2106
+
2107
+ // Day of week
2108
+ E: function (date, token, localize) {
2109
+ const dayOfWeek = date.getDay();
2110
+ switch (token) {
2111
+ // Tue
2112
+ case "E":
2113
+ case "EE":
2114
+ case "EEE":
2115
+ return localize.day(dayOfWeek, {
2116
+ width: "abbreviated",
2117
+ context: "formatting",
2118
+ });
2119
+ // T
2120
+ case "EEEEE":
2121
+ return localize.day(dayOfWeek, {
2122
+ width: "narrow",
2123
+ context: "formatting",
2124
+ });
2125
+ // Tu
2126
+ case "EEEEEE":
2127
+ return localize.day(dayOfWeek, {
2128
+ width: "short",
2129
+ context: "formatting",
2130
+ });
2131
+ // Tuesday
2132
+ case "EEEE":
2133
+ default:
2134
+ return localize.day(dayOfWeek, {
2135
+ width: "wide",
2136
+ context: "formatting",
2137
+ });
2138
+ }
2139
+ },
2140
+
2141
+ // Local day of week
2142
+ e: function (date, token, localize, options) {
2143
+ const dayOfWeek = date.getDay();
2144
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
2145
+ switch (token) {
2146
+ // Numerical value (Nth day of week with current locale or weekStartsOn)
2147
+ case "e":
2148
+ return String(localDayOfWeek);
2149
+ // Padded numerical value
2150
+ case "ee":
2151
+ return addLeadingZeros(localDayOfWeek, 2);
2152
+ // 1st, 2nd, ..., 7th
2153
+ case "eo":
2154
+ return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
2155
+ case "eee":
2156
+ return localize.day(dayOfWeek, {
2157
+ width: "abbreviated",
2158
+ context: "formatting",
2159
+ });
2160
+ // T
2161
+ case "eeeee":
2162
+ return localize.day(dayOfWeek, {
2163
+ width: "narrow",
2164
+ context: "formatting",
2165
+ });
2166
+ // Tu
2167
+ case "eeeeee":
2168
+ return localize.day(dayOfWeek, {
2169
+ width: "short",
2170
+ context: "formatting",
2171
+ });
2172
+ // Tuesday
2173
+ case "eeee":
2174
+ default:
2175
+ return localize.day(dayOfWeek, {
2176
+ width: "wide",
2177
+ context: "formatting",
2178
+ });
2179
+ }
2180
+ },
2181
+
2182
+ // Stand-alone local day of week
2183
+ c: function (date, token, localize, options) {
2184
+ const dayOfWeek = date.getDay();
2185
+ const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
2186
+ switch (token) {
2187
+ // Numerical value (same as in `e`)
2188
+ case "c":
2189
+ return String(localDayOfWeek);
2190
+ // Padded numerical value
2191
+ case "cc":
2192
+ return addLeadingZeros(localDayOfWeek, token.length);
2193
+ // 1st, 2nd, ..., 7th
2194
+ case "co":
2195
+ return localize.ordinalNumber(localDayOfWeek, { unit: "day" });
2196
+ case "ccc":
2197
+ return localize.day(dayOfWeek, {
2198
+ width: "abbreviated",
2199
+ context: "standalone",
2200
+ });
2201
+ // T
2202
+ case "ccccc":
2203
+ return localize.day(dayOfWeek, {
2204
+ width: "narrow",
2205
+ context: "standalone",
2206
+ });
2207
+ // Tu
2208
+ case "cccccc":
2209
+ return localize.day(dayOfWeek, {
2210
+ width: "short",
2211
+ context: "standalone",
2212
+ });
2213
+ // Tuesday
2214
+ case "cccc":
2215
+ default:
2216
+ return localize.day(dayOfWeek, {
2217
+ width: "wide",
2218
+ context: "standalone",
2219
+ });
2220
+ }
2221
+ },
2222
+
2223
+ // ISO day of week
2224
+ i: function (date, token, localize) {
2225
+ const dayOfWeek = date.getDay();
2226
+ const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
2227
+ switch (token) {
2228
+ // 2
2229
+ case "i":
2230
+ return String(isoDayOfWeek);
2231
+ // 02
2232
+ case "ii":
2233
+ return addLeadingZeros(isoDayOfWeek, token.length);
2234
+ // 2nd
2235
+ case "io":
2236
+ return localize.ordinalNumber(isoDayOfWeek, { unit: "day" });
2237
+ // Tue
2238
+ case "iii":
2239
+ return localize.day(dayOfWeek, {
2240
+ width: "abbreviated",
2241
+ context: "formatting",
2242
+ });
2243
+ // T
2244
+ case "iiiii":
2245
+ return localize.day(dayOfWeek, {
2246
+ width: "narrow",
2247
+ context: "formatting",
2248
+ });
2249
+ // Tu
2250
+ case "iiiiii":
2251
+ return localize.day(dayOfWeek, {
2252
+ width: "short",
2253
+ context: "formatting",
2254
+ });
2255
+ // Tuesday
2256
+ case "iiii":
2257
+ default:
2258
+ return localize.day(dayOfWeek, {
2259
+ width: "wide",
2260
+ context: "formatting",
2261
+ });
2262
+ }
2263
+ },
2264
+
2265
+ // AM or PM
2266
+ a: function (date, token, localize) {
2267
+ const hours = date.getHours();
2268
+ const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
2269
+
2270
+ switch (token) {
2271
+ case "a":
2272
+ case "aa":
2273
+ return localize.dayPeriod(dayPeriodEnumValue, {
2274
+ width: "abbreviated",
2275
+ context: "formatting",
2276
+ });
2277
+ case "aaa":
2278
+ return localize
2279
+ .dayPeriod(dayPeriodEnumValue, {
2280
+ width: "abbreviated",
2281
+ context: "formatting",
2282
+ })
2283
+ .toLowerCase();
2284
+ case "aaaaa":
2285
+ return localize.dayPeriod(dayPeriodEnumValue, {
2286
+ width: "narrow",
2287
+ context: "formatting",
2288
+ });
2289
+ case "aaaa":
2290
+ default:
2291
+ return localize.dayPeriod(dayPeriodEnumValue, {
2292
+ width: "wide",
2293
+ context: "formatting",
2294
+ });
2295
+ }
2296
+ },
2297
+
2298
+ // AM, PM, midnight, noon
2299
+ b: function (date, token, localize) {
2300
+ const hours = date.getHours();
2301
+ let dayPeriodEnumValue;
2302
+ if (hours === 12) {
2303
+ dayPeriodEnumValue = dayPeriodEnum.noon;
2304
+ } else if (hours === 0) {
2305
+ dayPeriodEnumValue = dayPeriodEnum.midnight;
2306
+ } else {
2307
+ dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
2308
+ }
2309
+
2310
+ switch (token) {
2311
+ case "b":
2312
+ case "bb":
2313
+ return localize.dayPeriod(dayPeriodEnumValue, {
2314
+ width: "abbreviated",
2315
+ context: "formatting",
2316
+ });
2317
+ case "bbb":
2318
+ return localize
2319
+ .dayPeriod(dayPeriodEnumValue, {
2320
+ width: "abbreviated",
2321
+ context: "formatting",
2322
+ })
2323
+ .toLowerCase();
2324
+ case "bbbbb":
2325
+ return localize.dayPeriod(dayPeriodEnumValue, {
2326
+ width: "narrow",
2327
+ context: "formatting",
2328
+ });
2329
+ case "bbbb":
2330
+ default:
2331
+ return localize.dayPeriod(dayPeriodEnumValue, {
2332
+ width: "wide",
2333
+ context: "formatting",
2334
+ });
2335
+ }
2336
+ },
2337
+
2338
+ // in the morning, in the afternoon, in the evening, at night
2339
+ B: function (date, token, localize) {
2340
+ const hours = date.getHours();
2341
+ let dayPeriodEnumValue;
2342
+ if (hours >= 17) {
2343
+ dayPeriodEnumValue = dayPeriodEnum.evening;
2344
+ } else if (hours >= 12) {
2345
+ dayPeriodEnumValue = dayPeriodEnum.afternoon;
2346
+ } else if (hours >= 4) {
2347
+ dayPeriodEnumValue = dayPeriodEnum.morning;
2348
+ } else {
2349
+ dayPeriodEnumValue = dayPeriodEnum.night;
2350
+ }
2351
+
2352
+ switch (token) {
2353
+ case "B":
2354
+ case "BB":
2355
+ case "BBB":
2356
+ return localize.dayPeriod(dayPeriodEnumValue, {
2357
+ width: "abbreviated",
2358
+ context: "formatting",
2359
+ });
2360
+ case "BBBBB":
2361
+ return localize.dayPeriod(dayPeriodEnumValue, {
2362
+ width: "narrow",
2363
+ context: "formatting",
2364
+ });
2365
+ case "BBBB":
2366
+ default:
2367
+ return localize.dayPeriod(dayPeriodEnumValue, {
2368
+ width: "wide",
2369
+ context: "formatting",
2370
+ });
2371
+ }
2372
+ },
2373
+
2374
+ // Hour [1-12]
2375
+ h: function (date, token, localize) {
2376
+ if (token === "ho") {
2377
+ let hours = date.getHours() % 12;
2378
+ if (hours === 0) hours = 12;
2379
+ return localize.ordinalNumber(hours, { unit: "hour" });
2380
+ }
2381
+
2382
+ return lightFormatters.h(date, token);
2383
+ },
2384
+
2385
+ // Hour [0-23]
2386
+ H: function (date, token, localize) {
2387
+ if (token === "Ho") {
2388
+ return localize.ordinalNumber(date.getHours(), { unit: "hour" });
2389
+ }
2390
+
2391
+ return lightFormatters.H(date, token);
2392
+ },
2393
+
2394
+ // Hour [0-11]
2395
+ K: function (date, token, localize) {
2396
+ const hours = date.getHours() % 12;
2397
+
2398
+ if (token === "Ko") {
2399
+ return localize.ordinalNumber(hours, { unit: "hour" });
2400
+ }
2401
+
2402
+ return addLeadingZeros(hours, token.length);
2403
+ },
2404
+
2405
+ // Hour [1-24]
2406
+ k: function (date, token, localize) {
2407
+ let hours = date.getHours();
2408
+ if (hours === 0) hours = 24;
2409
+
2410
+ if (token === "ko") {
2411
+ return localize.ordinalNumber(hours, { unit: "hour" });
2412
+ }
2413
+
2414
+ return addLeadingZeros(hours, token.length);
2415
+ },
2416
+
2417
+ // Minute
2418
+ m: function (date, token, localize) {
2419
+ if (token === "mo") {
2420
+ return localize.ordinalNumber(date.getMinutes(), { unit: "minute" });
2421
+ }
2422
+
2423
+ return lightFormatters.m(date, token);
2424
+ },
2425
+
2426
+ // Second
2427
+ s: function (date, token, localize) {
2428
+ if (token === "so") {
2429
+ return localize.ordinalNumber(date.getSeconds(), { unit: "second" });
2430
+ }
2431
+
2432
+ return lightFormatters.s(date, token);
2433
+ },
2434
+
2435
+ // Fraction of second
2436
+ S: function (date, token) {
2437
+ return lightFormatters.S(date, token);
2438
+ },
2439
+
2440
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
2441
+ X: function (date, token, _localize) {
2442
+ const timezoneOffset = date.getTimezoneOffset();
2443
+
2444
+ if (timezoneOffset === 0) {
2445
+ return "Z";
2446
+ }
2447
+
2448
+ switch (token) {
2449
+ // Hours and optional minutes
2450
+ case "X":
2451
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
2452
+
2453
+ // Hours, minutes and optional seconds without `:` delimiter
2454
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2455
+ // so this token always has the same output as `XX`
2456
+ case "XXXX":
2457
+ case "XX": // Hours and minutes without `:` delimiter
2458
+ return formatTimezone(timezoneOffset);
2459
+
2460
+ // Hours, minutes and optional seconds with `:` delimiter
2461
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2462
+ // so this token always has the same output as `XXX`
2463
+ case "XXXXX":
2464
+ case "XXX": // Hours and minutes with `:` delimiter
2465
+ default:
2466
+ return formatTimezone(timezoneOffset, ":");
2467
+ }
2468
+ },
2469
+
2470
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
2471
+ x: function (date, token, _localize) {
2472
+ const timezoneOffset = date.getTimezoneOffset();
2473
+
2474
+ switch (token) {
2475
+ // Hours and optional minutes
2476
+ case "x":
2477
+ return formatTimezoneWithOptionalMinutes(timezoneOffset);
2478
+
2479
+ // Hours, minutes and optional seconds without `:` delimiter
2480
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2481
+ // so this token always has the same output as `xx`
2482
+ case "xxxx":
2483
+ case "xx": // Hours and minutes without `:` delimiter
2484
+ return formatTimezone(timezoneOffset);
2485
+
2486
+ // Hours, minutes and optional seconds with `:` delimiter
2487
+ // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
2488
+ // so this token always has the same output as `xxx`
2489
+ case "xxxxx":
2490
+ case "xxx": // Hours and minutes with `:` delimiter
2491
+ default:
2492
+ return formatTimezone(timezoneOffset, ":");
2493
+ }
2494
+ },
2495
+
2496
+ // Timezone (GMT)
2497
+ O: function (date, token, _localize) {
2498
+ const timezoneOffset = date.getTimezoneOffset();
2499
+
2500
+ switch (token) {
2501
+ // Short
2502
+ case "O":
2503
+ case "OO":
2504
+ case "OOO":
2505
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
2506
+ // Long
2507
+ case "OOOO":
2508
+ default:
2509
+ return "GMT" + formatTimezone(timezoneOffset, ":");
2510
+ }
2511
+ },
2512
+
2513
+ // Timezone (specific non-location)
2514
+ z: function (date, token, _localize) {
2515
+ const timezoneOffset = date.getTimezoneOffset();
2516
+
2517
+ switch (token) {
2518
+ // Short
2519
+ case "z":
2520
+ case "zz":
2521
+ case "zzz":
2522
+ return "GMT" + formatTimezoneShort(timezoneOffset, ":");
2523
+ // Long
2524
+ case "zzzz":
2525
+ default:
2526
+ return "GMT" + formatTimezone(timezoneOffset, ":");
2527
+ }
2528
+ },
2529
+
2530
+ // Seconds timestamp
2531
+ t: function (date, token, _localize) {
2532
+ const timestamp = Math.trunc(+date / 1000);
2533
+ return addLeadingZeros(timestamp, token.length);
2534
+ },
2535
+
2536
+ // Milliseconds timestamp
2537
+ T: function (date, token, _localize) {
2538
+ return addLeadingZeros(+date, token.length);
2539
+ },
2540
+ };
2541
+
2542
+ function formatTimezoneShort(offset, delimiter = "") {
2543
+ const sign = offset > 0 ? "-" : "+";
2544
+ const absOffset = Math.abs(offset);
2545
+ const hours = Math.trunc(absOffset / 60);
2546
+ const minutes = absOffset % 60;
2547
+ if (minutes === 0) {
2548
+ return sign + String(hours);
2549
+ }
2550
+ return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
2551
+ }
2552
+
2553
+ function formatTimezoneWithOptionalMinutes(offset, delimiter) {
2554
+ if (offset % 60 === 0) {
2555
+ const sign = offset > 0 ? "-" : "+";
2556
+ return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
2557
+ }
2558
+ return formatTimezone(offset, delimiter);
2559
+ }
2560
+
2561
+ function formatTimezone(offset, delimiter = "") {
2562
+ const sign = offset > 0 ? "-" : "+";
2563
+ const absOffset = Math.abs(offset);
2564
+ const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
2565
+ const minutes = addLeadingZeros(absOffset % 60, 2);
2566
+ return sign + hours + delimiter + minutes;
2567
+ }
2568
+
2569
+ const dateLongFormatter = (pattern, formatLong) => {
2570
+ switch (pattern) {
2571
+ case "P":
2572
+ return formatLong.date({ width: "short" });
2573
+ case "PP":
2574
+ return formatLong.date({ width: "medium" });
2575
+ case "PPP":
2576
+ return formatLong.date({ width: "long" });
2577
+ case "PPPP":
2578
+ default:
2579
+ return formatLong.date({ width: "full" });
2580
+ }
2581
+ };
2582
+
2583
+ const timeLongFormatter = (pattern, formatLong) => {
2584
+ switch (pattern) {
2585
+ case "p":
2586
+ return formatLong.time({ width: "short" });
2587
+ case "pp":
2588
+ return formatLong.time({ width: "medium" });
2589
+ case "ppp":
2590
+ return formatLong.time({ width: "long" });
2591
+ case "pppp":
2592
+ default:
2593
+ return formatLong.time({ width: "full" });
2594
+ }
2595
+ };
2596
+
2597
+ const dateTimeLongFormatter = (pattern, formatLong) => {
2598
+ const matchResult = pattern.match(/(P+)(p+)?/) || [];
2599
+ const datePattern = matchResult[1];
2600
+ const timePattern = matchResult[2];
2601
+
2602
+ if (!timePattern) {
2603
+ return dateLongFormatter(pattern, formatLong);
2604
+ }
2605
+
2606
+ let dateTimeFormat;
2607
+
2608
+ switch (datePattern) {
2609
+ case "P":
2610
+ dateTimeFormat = formatLong.dateTime({ width: "short" });
2611
+ break;
2612
+ case "PP":
2613
+ dateTimeFormat = formatLong.dateTime({ width: "medium" });
2614
+ break;
2615
+ case "PPP":
2616
+ dateTimeFormat = formatLong.dateTime({ width: "long" });
2617
+ break;
2618
+ case "PPPP":
2619
+ default:
2620
+ dateTimeFormat = formatLong.dateTime({ width: "full" });
2621
+ break;
2622
+ }
2623
+
2624
+ return dateTimeFormat
2625
+ .replace("{{date}}", dateLongFormatter(datePattern, formatLong))
2626
+ .replace("{{time}}", timeLongFormatter(timePattern, formatLong));
2627
+ };
2628
+
2629
+ const longFormatters = {
2630
+ p: timeLongFormatter,
2631
+ P: dateTimeLongFormatter,
2632
+ };
2633
+
2634
+ const dayOfYearTokenRE = /^D+$/;
2635
+ const weekYearTokenRE = /^Y+$/;
2636
+
2637
+ const throwTokens = ["D", "DD", "YY", "YYYY"];
2638
+
2639
+ function isProtectedDayOfYearToken(token) {
2640
+ return dayOfYearTokenRE.test(token);
2641
+ }
2642
+
2643
+ function isProtectedWeekYearToken(token) {
2644
+ return weekYearTokenRE.test(token);
2645
+ }
2646
+
2647
+ function warnOrThrowProtectedError(token, format, input) {
2648
+ const _message = message(token, format, input);
2649
+ console.warn(_message);
2650
+ if (throwTokens.includes(token)) throw new RangeError(_message);
2651
+ }
2652
+
2653
+ function message(token, format, input) {
2654
+ const subject = token[0] === "Y" ? "years" : "days of the month";
2655
+ return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
2656
+ }
2657
+
2658
+ // This RegExp consists of three parts separated by `|`:
2659
+ // - [yYQqMLwIdDecihHKkms]o matches any available ordinal number token
2660
+ // (one of the certain letters followed by `o`)
2661
+ // - (\w)\1* matches any sequences of the same letter
2662
+ // - '' matches two quote characters in a row
2663
+ // - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),
2664
+ // except a single quote symbol, which ends the sequence.
2665
+ // Two quote characters do not end the sequence.
2666
+ // If there is no matching single quote
2667
+ // then the sequence will continue until the end of the string.
2668
+ // - . matches any single character unmatched by previous parts of the RegExps
2669
+ const formattingTokensRegExp =
2670
+ /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
2671
+
2672
+ // This RegExp catches symbols escaped by quotes, and also
2673
+ // sequences of symbols P, p, and the combinations like `PPPPPPPppppp`
2674
+ const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
2675
+
2676
+ const escapedStringRegExp = /^'([^]*?)'?$/;
2677
+ const doubleQuoteRegExp = /''/g;
2678
+ const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
2679
+
2680
+ /**
2681
+ * The {@link format} function options.
2682
+ */
2683
+
2684
+ /**
2685
+ * @name format
2686
+ * @alias formatDate
2687
+ * @category Common Helpers
2688
+ * @summary Format the date.
2689
+ *
2690
+ * @description
2691
+ * Return the formatted date string in the given format. The result may vary by locale.
2692
+ *
2693
+ * > ⚠️ Please note that the `format` tokens differ from Moment.js and other libraries.
2694
+ * > See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2695
+ *
2696
+ * The characters wrapped between two single quotes characters (') are escaped.
2697
+ * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.
2698
+ * (see the last example)
2699
+ *
2700
+ * Format of the string is based on Unicode Technical Standard #35:
2701
+ * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
2702
+ * with a few additions (see note 7 below the table).
2703
+ *
2704
+ * Accepted patterns:
2705
+ * | Unit | Pattern | Result examples | Notes |
2706
+ * |---------------------------------|---------|-----------------------------------|-------|
2707
+ * | Era | G..GGG | AD, BC | |
2708
+ * | | GGGG | Anno Domini, Before Christ | 2 |
2709
+ * | | GGGGG | A, B | |
2710
+ * | Calendar year | y | 44, 1, 1900, 2017 | 5 |
2711
+ * | | yo | 44th, 1st, 0th, 17th | 5,7 |
2712
+ * | | yy | 44, 01, 00, 17 | 5 |
2713
+ * | | yyy | 044, 001, 1900, 2017 | 5 |
2714
+ * | | yyyy | 0044, 0001, 1900, 2017 | 5 |
2715
+ * | | yyyyy | ... | 3,5 |
2716
+ * | Local week-numbering year | Y | 44, 1, 1900, 2017 | 5 |
2717
+ * | | Yo | 44th, 1st, 1900th, 2017th | 5,7 |
2718
+ * | | YY | 44, 01, 00, 17 | 5,8 |
2719
+ * | | YYY | 044, 001, 1900, 2017 | 5 |
2720
+ * | | YYYY | 0044, 0001, 1900, 2017 | 5,8 |
2721
+ * | | YYYYY | ... | 3,5 |
2722
+ * | ISO week-numbering year | R | -43, 0, 1, 1900, 2017 | 5,7 |
2723
+ * | | RR | -43, 00, 01, 1900, 2017 | 5,7 |
2724
+ * | | RRR | -043, 000, 001, 1900, 2017 | 5,7 |
2725
+ * | | RRRR | -0043, 0000, 0001, 1900, 2017 | 5,7 |
2726
+ * | | RRRRR | ... | 3,5,7 |
2727
+ * | Extended year | u | -43, 0, 1, 1900, 2017 | 5 |
2728
+ * | | uu | -43, 01, 1900, 2017 | 5 |
2729
+ * | | uuu | -043, 001, 1900, 2017 | 5 |
2730
+ * | | uuuu | -0043, 0001, 1900, 2017 | 5 |
2731
+ * | | uuuuu | ... | 3,5 |
2732
+ * | Quarter (formatting) | Q | 1, 2, 3, 4 | |
2733
+ * | | Qo | 1st, 2nd, 3rd, 4th | 7 |
2734
+ * | | QQ | 01, 02, 03, 04 | |
2735
+ * | | QQQ | Q1, Q2, Q3, Q4 | |
2736
+ * | | QQQQ | 1st quarter, 2nd quarter, ... | 2 |
2737
+ * | | QQQQQ | 1, 2, 3, 4 | 4 |
2738
+ * | Quarter (stand-alone) | q | 1, 2, 3, 4 | |
2739
+ * | | qo | 1st, 2nd, 3rd, 4th | 7 |
2740
+ * | | qq | 01, 02, 03, 04 | |
2741
+ * | | qqq | Q1, Q2, Q3, Q4 | |
2742
+ * | | qqqq | 1st quarter, 2nd quarter, ... | 2 |
2743
+ * | | qqqqq | 1, 2, 3, 4 | 4 |
2744
+ * | Month (formatting) | M | 1, 2, ..., 12 | |
2745
+ * | | Mo | 1st, 2nd, ..., 12th | 7 |
2746
+ * | | MM | 01, 02, ..., 12 | |
2747
+ * | | MMM | Jan, Feb, ..., Dec | |
2748
+ * | | MMMM | January, February, ..., December | 2 |
2749
+ * | | MMMMM | J, F, ..., D | |
2750
+ * | Month (stand-alone) | L | 1, 2, ..., 12 | |
2751
+ * | | Lo | 1st, 2nd, ..., 12th | 7 |
2752
+ * | | LL | 01, 02, ..., 12 | |
2753
+ * | | LLL | Jan, Feb, ..., Dec | |
2754
+ * | | LLLL | January, February, ..., December | 2 |
2755
+ * | | LLLLL | J, F, ..., D | |
2756
+ * | Local week of year | w | 1, 2, ..., 53 | |
2757
+ * | | wo | 1st, 2nd, ..., 53th | 7 |
2758
+ * | | ww | 01, 02, ..., 53 | |
2759
+ * | ISO week of year | I | 1, 2, ..., 53 | 7 |
2760
+ * | | Io | 1st, 2nd, ..., 53th | 7 |
2761
+ * | | II | 01, 02, ..., 53 | 7 |
2762
+ * | Day of month | d | 1, 2, ..., 31 | |
2763
+ * | | do | 1st, 2nd, ..., 31st | 7 |
2764
+ * | | dd | 01, 02, ..., 31 | |
2765
+ * | Day of year | D | 1, 2, ..., 365, 366 | 9 |
2766
+ * | | Do | 1st, 2nd, ..., 365th, 366th | 7 |
2767
+ * | | DD | 01, 02, ..., 365, 366 | 9 |
2768
+ * | | DDD | 001, 002, ..., 365, 366 | |
2769
+ * | | DDDD | ... | 3 |
2770
+ * | Day of week (formatting) | E..EEE | Mon, Tue, Wed, ..., Sun | |
2771
+ * | | EEEE | Monday, Tuesday, ..., Sunday | 2 |
2772
+ * | | EEEEE | M, T, W, T, F, S, S | |
2773
+ * | | EEEEEE | Mo, Tu, We, Th, Fr, Sa, Su | |
2774
+ * | ISO day of week (formatting) | i | 1, 2, 3, ..., 7 | 7 |
2775
+ * | | io | 1st, 2nd, ..., 7th | 7 |
2776
+ * | | ii | 01, 02, ..., 07 | 7 |
2777
+ * | | iii | Mon, Tue, Wed, ..., Sun | 7 |
2778
+ * | | iiii | Monday, Tuesday, ..., Sunday | 2,7 |
2779
+ * | | iiiii | M, T, W, T, F, S, S | 7 |
2780
+ * | | iiiiii | Mo, Tu, We, Th, Fr, Sa, Su | 7 |
2781
+ * | Local day of week (formatting) | e | 2, 3, 4, ..., 1 | |
2782
+ * | | eo | 2nd, 3rd, ..., 1st | 7 |
2783
+ * | | ee | 02, 03, ..., 01 | |
2784
+ * | | eee | Mon, Tue, Wed, ..., Sun | |
2785
+ * | | eeee | Monday, Tuesday, ..., Sunday | 2 |
2786
+ * | | eeeee | M, T, W, T, F, S, S | |
2787
+ * | | eeeeee | Mo, Tu, We, Th, Fr, Sa, Su | |
2788
+ * | Local day of week (stand-alone) | c | 2, 3, 4, ..., 1 | |
2789
+ * | | co | 2nd, 3rd, ..., 1st | 7 |
2790
+ * | | cc | 02, 03, ..., 01 | |
2791
+ * | | ccc | Mon, Tue, Wed, ..., Sun | |
2792
+ * | | cccc | Monday, Tuesday, ..., Sunday | 2 |
2793
+ * | | ccccc | M, T, W, T, F, S, S | |
2794
+ * | | cccccc | Mo, Tu, We, Th, Fr, Sa, Su | |
2795
+ * | AM, PM | a..aa | AM, PM | |
2796
+ * | | aaa | am, pm | |
2797
+ * | | aaaa | a.m., p.m. | 2 |
2798
+ * | | aaaaa | a, p | |
2799
+ * | AM, PM, noon, midnight | b..bb | AM, PM, noon, midnight | |
2800
+ * | | bbb | am, pm, noon, midnight | |
2801
+ * | | bbbb | a.m., p.m., noon, midnight | 2 |
2802
+ * | | bbbbb | a, p, n, mi | |
2803
+ * | Flexible day period | B..BBB | at night, in the morning, ... | |
2804
+ * | | BBBB | at night, in the morning, ... | 2 |
2805
+ * | | BBBBB | at night, in the morning, ... | |
2806
+ * | Hour [1-12] | h | 1, 2, ..., 11, 12 | |
2807
+ * | | ho | 1st, 2nd, ..., 11th, 12th | 7 |
2808
+ * | | hh | 01, 02, ..., 11, 12 | |
2809
+ * | Hour [0-23] | H | 0, 1, 2, ..., 23 | |
2810
+ * | | Ho | 0th, 1st, 2nd, ..., 23rd | 7 |
2811
+ * | | HH | 00, 01, 02, ..., 23 | |
2812
+ * | Hour [0-11] | K | 1, 2, ..., 11, 0 | |
2813
+ * | | Ko | 1st, 2nd, ..., 11th, 0th | 7 |
2814
+ * | | KK | 01, 02, ..., 11, 00 | |
2815
+ * | Hour [1-24] | k | 24, 1, 2, ..., 23 | |
2816
+ * | | ko | 24th, 1st, 2nd, ..., 23rd | 7 |
2817
+ * | | kk | 24, 01, 02, ..., 23 | |
2818
+ * | Minute | m | 0, 1, ..., 59 | |
2819
+ * | | mo | 0th, 1st, ..., 59th | 7 |
2820
+ * | | mm | 00, 01, ..., 59 | |
2821
+ * | Second | s | 0, 1, ..., 59 | |
2822
+ * | | so | 0th, 1st, ..., 59th | 7 |
2823
+ * | | ss | 00, 01, ..., 59 | |
2824
+ * | Fraction of second | S | 0, 1, ..., 9 | |
2825
+ * | | SS | 00, 01, ..., 99 | |
2826
+ * | | SSS | 000, 001, ..., 999 | |
2827
+ * | | SSSS | ... | 3 |
2828
+ * | Timezone (ISO-8601 w/ Z) | X | -08, +0530, Z | |
2829
+ * | | XX | -0800, +0530, Z | |
2830
+ * | | XXX | -08:00, +05:30, Z | |
2831
+ * | | XXXX | -0800, +0530, Z, +123456 | 2 |
2832
+ * | | XXXXX | -08:00, +05:30, Z, +12:34:56 | |
2833
+ * | Timezone (ISO-8601 w/o Z) | x | -08, +0530, +00 | |
2834
+ * | | xx | -0800, +0530, +0000 | |
2835
+ * | | xxx | -08:00, +05:30, +00:00 | 2 |
2836
+ * | | xxxx | -0800, +0530, +0000, +123456 | |
2837
+ * | | xxxxx | -08:00, +05:30, +00:00, +12:34:56 | |
2838
+ * | Timezone (GMT) | O...OOO | GMT-8, GMT+5:30, GMT+0 | |
2839
+ * | | OOOO | GMT-08:00, GMT+05:30, GMT+00:00 | 2 |
2840
+ * | Timezone (specific non-locat.) | z...zzz | GMT-8, GMT+5:30, GMT+0 | 6 |
2841
+ * | | zzzz | GMT-08:00, GMT+05:30, GMT+00:00 | 2,6 |
2842
+ * | Seconds timestamp | t | 512969520 | 7 |
2843
+ * | | tt | ... | 3,7 |
2844
+ * | Milliseconds timestamp | T | 512969520900 | 7 |
2845
+ * | | TT | ... | 3,7 |
2846
+ * | Long localized date | P | 04/29/1453 | 7 |
2847
+ * | | PP | Apr 29, 1453 | 7 |
2848
+ * | | PPP | April 29th, 1453 | 7 |
2849
+ * | | PPPP | Friday, April 29th, 1453 | 2,7 |
2850
+ * | Long localized time | p | 12:00 AM | 7 |
2851
+ * | | pp | 12:00:00 AM | 7 |
2852
+ * | | ppp | 12:00:00 AM GMT+2 | 7 |
2853
+ * | | pppp | 12:00:00 AM GMT+02:00 | 2,7 |
2854
+ * | Combination of date and time | Pp | 04/29/1453, 12:00 AM | 7 |
2855
+ * | | PPpp | Apr 29, 1453, 12:00:00 AM | 7 |
2856
+ * | | PPPppp | April 29th, 1453 at ... | 7 |
2857
+ * | | PPPPpppp| Friday, April 29th, 1453 at ... | 2,7 |
2858
+ * Notes:
2859
+ * 1. "Formatting" units (e.g. formatting quarter) in the default en-US locale
2860
+ * are the same as "stand-alone" units, but are different in some languages.
2861
+ * "Formatting" units are declined according to the rules of the language
2862
+ * in the context of a date. "Stand-alone" units are always nominative singular:
2863
+ *
2864
+ * `format(new Date(2017, 10, 6), 'do LLLL', {locale: cs}) //=> '6. listopad'`
2865
+ *
2866
+ * `format(new Date(2017, 10, 6), 'do MMMM', {locale: cs}) //=> '6. listopadu'`
2867
+ *
2868
+ * 2. Any sequence of the identical letters is a pattern, unless it is escaped by
2869
+ * the single quote characters (see below).
2870
+ * If the sequence is longer than listed in table (e.g. `EEEEEEEEEEE`)
2871
+ * the output will be the same as default pattern for this unit, usually
2872
+ * the longest one (in case of ISO weekdays, `EEEE`). Default patterns for units
2873
+ * are marked with "2" in the last column of the table.
2874
+ *
2875
+ * `format(new Date(2017, 10, 6), 'MMM') //=> 'Nov'`
2876
+ *
2877
+ * `format(new Date(2017, 10, 6), 'MMMM') //=> 'November'`
2878
+ *
2879
+ * `format(new Date(2017, 10, 6), 'MMMMM') //=> 'N'`
2880
+ *
2881
+ * `format(new Date(2017, 10, 6), 'MMMMMM') //=> 'November'`
2882
+ *
2883
+ * `format(new Date(2017, 10, 6), 'MMMMMMM') //=> 'November'`
2884
+ *
2885
+ * 3. Some patterns could be unlimited length (such as `yyyyyyyy`).
2886
+ * The output will be padded with zeros to match the length of the pattern.
2887
+ *
2888
+ * `format(new Date(2017, 10, 6), 'yyyyyyyy') //=> '00002017'`
2889
+ *
2890
+ * 4. `QQQQQ` and `qqqqq` could be not strictly numerical in some locales.
2891
+ * These tokens represent the shortest form of the quarter.
2892
+ *
2893
+ * 5. The main difference between `y` and `u` patterns are B.C. years:
2894
+ *
2895
+ * | Year | `y` | `u` |
2896
+ * |------|-----|-----|
2897
+ * | AC 1 | 1 | 1 |
2898
+ * | BC 1 | 1 | 0 |
2899
+ * | BC 2 | 2 | -1 |
2900
+ *
2901
+ * Also `yy` always returns the last two digits of a year,
2902
+ * while `uu` pads single digit years to 2 characters and returns other years unchanged:
2903
+ *
2904
+ * | Year | `yy` | `uu` |
2905
+ * |------|------|------|
2906
+ * | 1 | 01 | 01 |
2907
+ * | 14 | 14 | 14 |
2908
+ * | 376 | 76 | 376 |
2909
+ * | 1453 | 53 | 1453 |
2910
+ *
2911
+ * The same difference is true for local and ISO week-numbering years (`Y` and `R`),
2912
+ * except local week-numbering years are dependent on `options.weekStartsOn`
2913
+ * and `options.firstWeekContainsDate` (compare [getISOWeekYear](https://date-fns.org/docs/getISOWeekYear)
2914
+ * and [getWeekYear](https://date-fns.org/docs/getWeekYear)).
2915
+ *
2916
+ * 6. Specific non-location timezones are currently unavailable in `date-fns`,
2917
+ * so right now these tokens fall back to GMT timezones.
2918
+ *
2919
+ * 7. These patterns are not in the Unicode Technical Standard #35:
2920
+ * - `i`: ISO day of week
2921
+ * - `I`: ISO week of year
2922
+ * - `R`: ISO week-numbering year
2923
+ * - `t`: seconds timestamp
2924
+ * - `T`: milliseconds timestamp
2925
+ * - `o`: ordinal number modifier
2926
+ * - `P`: long localized date
2927
+ * - `p`: long localized time
2928
+ *
2929
+ * 8. `YY` and `YYYY` tokens represent week-numbering years but they are often confused with years.
2930
+ * You should enable `options.useAdditionalWeekYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2931
+ *
2932
+ * 9. `D` and `DD` tokens represent days of the year but they are often confused with days of the month.
2933
+ * You should enable `options.useAdditionalDayOfYearTokens` to use them. See: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md
2934
+ *
2935
+ * @param date - The original date
2936
+ * @param format - The string of tokens
2937
+ * @param options - An object with options
2938
+ *
2939
+ * @returns The formatted date string
2940
+ *
2941
+ * @throws `date` must not be Invalid Date
2942
+ * @throws `options.locale` must contain `localize` property
2943
+ * @throws `options.locale` must contain `formatLong` property
2944
+ * @throws 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
2945
+ * @throws 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
2946
+ * @throws 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
2947
+ * @throws 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
2948
+ * @throws format string contains an unescaped latin alphabet character
2949
+ *
2950
+ * @example
2951
+ * // Represent 11 February 2014 in middle-endian format:
2952
+ * const result = format(new Date(2014, 1, 11), 'MM/dd/yyyy')
2953
+ * //=> '02/11/2014'
2954
+ *
2955
+ * @example
2956
+ * // Represent 2 July 2014 in Esperanto:
2957
+ * import { eoLocale } from 'date-fns/locale/eo'
2958
+ * const result = format(new Date(2014, 6, 2), "do 'de' MMMM yyyy", {
2959
+ * locale: eoLocale
2960
+ * })
2961
+ * //=> '2-a de julio 2014'
2962
+ *
2963
+ * @example
2964
+ * // Escape string by single quote characters:
2965
+ * const result = format(new Date(2014, 6, 2, 15), "h 'o''clock'")
2966
+ * //=> "3 o'clock"
2967
+ */
2968
+ function format(date, formatStr, options) {
2969
+ const defaultOptions = getDefaultOptions();
2970
+ const locale = options?.locale ?? defaultOptions.locale ?? enUS;
2971
+
2972
+ const firstWeekContainsDate =
2973
+ options?.firstWeekContainsDate ??
2974
+ options?.locale?.options?.firstWeekContainsDate ??
2975
+ defaultOptions.firstWeekContainsDate ??
2976
+ defaultOptions.locale?.options?.firstWeekContainsDate ??
2977
+ 1;
2978
+
2979
+ const weekStartsOn =
2980
+ options?.weekStartsOn ??
2981
+ options?.locale?.options?.weekStartsOn ??
2982
+ defaultOptions.weekStartsOn ??
2983
+ defaultOptions.locale?.options?.weekStartsOn ??
2984
+ 0;
2985
+
2986
+ const originalDate = toDate(date, options?.in);
2987
+
2988
+ if (!isValid(originalDate)) {
2989
+ throw new RangeError("Invalid time value");
2990
+ }
2991
+
2992
+ let parts = formatStr
2993
+ .match(longFormattingTokensRegExp)
2994
+ .map((substring) => {
2995
+ const firstCharacter = substring[0];
2996
+ if (firstCharacter === "p" || firstCharacter === "P") {
2997
+ const longFormatter = longFormatters[firstCharacter];
2998
+ return longFormatter(substring, locale.formatLong);
2999
+ }
3000
+ return substring;
3001
+ })
3002
+ .join("")
3003
+ .match(formattingTokensRegExp)
3004
+ .map((substring) => {
3005
+ // Replace two single quote characters with one single quote character
3006
+ if (substring === "''") {
3007
+ return { isToken: false, value: "'" };
3008
+ }
3009
+
3010
+ const firstCharacter = substring[0];
3011
+ if (firstCharacter === "'") {
3012
+ return { isToken: false, value: cleanEscapedString(substring) };
3013
+ }
3014
+
3015
+ if (formatters[firstCharacter]) {
3016
+ return { isToken: true, value: substring };
3017
+ }
3018
+
3019
+ if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
3020
+ throw new RangeError(
3021
+ "Format string contains an unescaped latin alphabet character `" +
3022
+ firstCharacter +
3023
+ "`",
3024
+ );
3025
+ }
3026
+
3027
+ return { isToken: false, value: substring };
3028
+ });
3029
+
3030
+ // invoke localize preprocessor (only for french locales at the moment)
3031
+ if (locale.localize.preprocessor) {
3032
+ parts = locale.localize.preprocessor(originalDate, parts);
3033
+ }
3034
+
3035
+ const formatterOptions = {
3036
+ firstWeekContainsDate,
3037
+ weekStartsOn,
3038
+ locale,
3039
+ };
3040
+
3041
+ return parts
3042
+ .map((part) => {
3043
+ if (!part.isToken) return part.value;
3044
+
3045
+ const token = part.value;
3046
+
3047
+ if (
3048
+ (!options?.useAdditionalWeekYearTokens &&
3049
+ isProtectedWeekYearToken(token)) ||
3050
+ (!options?.useAdditionalDayOfYearTokens &&
3051
+ isProtectedDayOfYearToken(token))
3052
+ ) {
3053
+ warnOrThrowProtectedError(token, formatStr, String(date));
3054
+ }
3055
+
3056
+ const formatter = formatters[token[0]];
3057
+ return formatter(originalDate, token, locale.localize, formatterOptions);
3058
+ })
3059
+ .join("");
3060
+ }
3061
+
3062
+ function cleanEscapedString(input) {
3063
+ const matched = input.match(escapedStringRegExp);
3064
+
3065
+ if (!matched) {
3066
+ return input;
3067
+ }
3068
+
3069
+ return matched[1].replace(doubleQuoteRegExp, "'");
3070
+ }
3071
+
3072
+ /**
3073
+ * The {@link getDay} function options.
3074
+ */
3075
+
3076
+ /**
3077
+ * @name getDay
3078
+ * @category Weekday Helpers
3079
+ * @summary Get the day of the week of the given date.
3080
+ *
3081
+ * @description
3082
+ * Get the day of the week of the given date.
3083
+ *
3084
+ * @param date - The given date
3085
+ * @param options - The options
3086
+ *
3087
+ * @returns The day of week, 0 represents Sunday
3088
+ *
3089
+ * @example
3090
+ * // Which day of the week is 29 February 2012?
3091
+ * const result = getDay(new Date(2012, 1, 29))
3092
+ * //=> 3
3093
+ */
3094
+ function getDay(date, options) {
3095
+ return toDate(date, options?.in).getDay();
3096
+ }
3097
+
3098
+ /**
3099
+ * The {@link isToday} function options.
3100
+ */
3101
+
3102
+ /**
3103
+ * @name isToday
3104
+ * @category Day Helpers
3105
+ * @summary Is the given date today?
3106
+ * @pure false
3107
+ *
3108
+ * @description
3109
+ * Is the given date today?
3110
+ *
3111
+ * @param date - The date to check
3112
+ * @param options - An object with options
3113
+ *
3114
+ * @returns The date is today
3115
+ *
3116
+ * @example
3117
+ * // If today is 6 October 2014, is 6 October 14:00:00 today?
3118
+ * const result = isToday(new Date(2014, 9, 6, 14, 0))
3119
+ * //=> true
3120
+ */
3121
+ function isToday(date, options) {
3122
+ return isSameDay(
3123
+ constructFrom(options?.in || date, date),
3124
+ constructNow(options?.in || date),
3125
+ );
3126
+ }
3127
+
3128
+ /**
3129
+ * The subMonths function options.
3130
+ */
3131
+
3132
+ /**
3133
+ * @name subMonths
3134
+ * @category Month Helpers
3135
+ * @summary Subtract the specified number of months from the given date.
3136
+ *
3137
+ * @description
3138
+ * Subtract the specified number of months from the given date.
3139
+ *
3140
+ * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
3141
+ * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
3142
+ *
3143
+ * @param date - The date to be changed
3144
+ * @param amount - The amount of months to be subtracted.
3145
+ * @param options - An object with options
3146
+ *
3147
+ * @returns The new date with the months subtracted
3148
+ *
3149
+ * @example
3150
+ * // Subtract 5 months from 1 February 2015:
3151
+ * const result = subMonths(new Date(2015, 1, 1), 5)
3152
+ * //=> Mon Sep 01 2014 00:00:00
3153
+ */
3154
+ function subMonths(date, amount, options) {
3155
+ return addMonths(date, -amount, options);
3156
+ }
3157
+
3158
+ const jeDatepickerCss = ":host{display:block;padding:var(--je-spacing-xs);box-sizing:border-box}je-button.day{--je-button-min-width:20px;--je-button-height:20px;--je-button-inline-padding:0px}je-button.day::part(inner-button){font-weight:400}.header{display:flex;align-items:center;margin-bottom:10px}.header div{user-select:none;display:flex;cursor:pointer;flex:1;align-items:center}.weekdays-grid{display:grid;grid-template-columns:repeat(7, 1fr);gap:5px;margin-bottom:8px}.weekdays-grid div{height:20px;font-size:1em;font-weight:400;color:var(--je-medium-600);text-align:center;align-content:center}.days-grid{display:grid;grid-template-columns:repeat(7, 1fr);gap:5px}je-icon{transition:transform 250ms ease}je-icon.open{transform:rotate(180deg)}";
3159
+ const JeDatepickerStyle0 = jeDatepickerCss;
3160
+
3161
+ const JeDatepicker$1 = /*@__PURE__*/ proxyCustomElement(class JeDatepicker extends H {
3162
+ constructor() {
3163
+ super();
3164
+ this.__registerHost();
3165
+ this.__attachShadow();
3166
+ this.valueChange = createEvent(this, "valueChange", 7);
3167
+ this.nextMonth = () => {
3168
+ this.currentDate = addMonths(this.currentDate, 1);
3169
+ };
3170
+ this.prevMonth = () => {
3171
+ this.currentDate = subMonths(this.currentDate, 1);
3172
+ };
3173
+ this.currentDate = new Date();
3174
+ this.value = undefined;
3175
+ this.isDark = false;
3176
+ this.monthYearPicker = false;
3177
+ }
3178
+ handleThemeChange(e) {
3179
+ this.isDark = e.detail === 'dark';
3180
+ }
3181
+ valueChangeHandler() {
3182
+ this.valueChange.emit(this.value ? new Date(this.value) : undefined);
3183
+ }
3184
+ getDaysInMonth() {
3185
+ const start = startOfMonth(this.currentDate);
3186
+ const end = endOfMonth(this.currentDate);
3187
+ return eachDayOfInterval({ start, end });
3188
+ }
3189
+ render() {
3190
+ const daysOfWeek = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
3191
+ const firstDayOfMonth = startOfMonth(this.currentDate);
3192
+ const lastDayOfMonth = endOfMonth(this.currentDate);
3193
+ const firstDayOfWeek = getDay(firstDayOfMonth);
3194
+ const lastDayOfWeek = getDay(lastDayOfMonth);
3195
+ const daysInMonth = eachDayOfInterval({ start: firstDayOfMonth, end: lastDayOfMonth });
3196
+ const prevMonth = subMonths(this.currentDate, 1);
3197
+ const prevMonthEnd = endOfMonth(prevMonth);
3198
+ const daysBefore = Array.from({ length: firstDayOfWeek }).map((_, i) => subMonths(this.currentDate, 1).setDate(prevMonthEnd.getDate() - (firstDayOfWeek - i - 1)));
3199
+ const daysAfter = Array.from({ length: 6 - lastDayOfWeek }).map((_, i) => addMonths(this.currentDate, 1).setDate(i + 1));
3200
+ return (h(Host, { key: 'ff2ec54e4e3de84b80468820efa641a2922b93cf' }, h("div", { key: '44b43c08d7dcdb90d3db8ee837fe902e804b8255', class: "header" }, h("div", { key: '34649267bbeeab302a646017714da9f00aa3503a', onClick: () => this.monthYearPicker = !this.monthYearPicker }, h("span", { key: 'f83d4b65cc03662bdd7555113a0d367f263e30f6' }, format(this.currentDate, 'MMMM yyyy')), h("je-button", { key: 'c12c79e67bb19ce76b37ff122a9aba76c33d8627', fill: 'clear', iconOnly: true }, h("je-icon", { key: '7fd6737727798a895899015a30c295913c9c9077', class: { open: this.monthYearPicker }, icon: 'expand_more' }))), h("je-button", { key: '17d319c0c3120906ce733bee52eaf31e3ecfce77', iconOnly: true, fill: 'clear', onClick: this.prevMonth }, h("je-icon", { key: 'c6c86b0c4f0360a335903a0298e39f1db9658d51', fill: true, icon: 'arrow_left' })), h("je-button", { key: '21a79c20202fd0acd26589deab5746bfdda32a3c', iconOnly: true, fill: 'clear', onClick: this.nextMonth }, h("je-icon", { key: '508587d9cd3642520f6b58d197df066da15c10ab', icon: 'arrow_right', fill: true }))), h("div", { key: 'c40de53a4277adebef8c7077af02ab4e80491aea', class: "weekdays-grid" }, daysOfWeek.map(day => h("div", null, day))), h("div", { key: '90a3fea593cd4772cfa4006180532a79264e3502', class: "days-grid" }, daysBefore.map(day => (h("je-button", { expand: true, disabled: true, color: 'medium', fill: 'clear', class: 'day' }, format(day, 'd')))), daysInMonth.map(day => {
3201
+ const selected = this.value && isSameDay(day, this.value);
3202
+ const today = isToday(day);
3203
+ return (h("je-button", { expand: true, color: selected || today ? 'primary' : this.isDark ? 'light' : 'dark', fill: selected ? 'solid' : 'clear', class: 'day', onClick: () => this.value = day }, format(day, 'd')));
3204
+ }), daysAfter.map(day => (h("je-button", { expand: true, disabled: true, color: 'medium', fill: 'clear', class: 'day' }, format(day, 'd')))))));
3205
+ }
3206
+ get el() { return this; }
3207
+ static get watchers() { return {
3208
+ "value": ["valueChangeHandler"]
3209
+ }; }
3210
+ static get style() { return JeDatepickerStyle0; }
3211
+ }, [1, "je-datepicker", {
3212
+ "value": [1025],
3213
+ "currentDate": [32],
3214
+ "isDark": [32],
3215
+ "monthYearPicker": [32]
3216
+ }, [[16, "themeChange", "handleThemeChange"]], {
3217
+ "value": ["valueChangeHandler"]
3218
+ }]);
3219
+ function defineCustomElement$1() {
3220
+ if (typeof customElements === "undefined") {
3221
+ return;
3222
+ }
3223
+ const components = ["je-datepicker", "je-button", "je-icon"];
3224
+ components.forEach(tagName => { switch (tagName) {
3225
+ case "je-datepicker":
3226
+ if (!customElements.get(tagName)) {
3227
+ customElements.define(tagName, JeDatepicker$1);
3228
+ }
3229
+ break;
3230
+ case "je-button":
3231
+ if (!customElements.get(tagName)) {
3232
+ defineCustomElement$3();
3233
+ }
3234
+ break;
3235
+ case "je-icon":
3236
+ if (!customElements.get(tagName)) {
3237
+ defineCustomElement$2();
3238
+ }
3239
+ break;
3240
+ } });
3241
+ }
3242
+ defineCustomElement$1();
3243
+
3244
+ const JeDatepicker = JeDatepicker$1;
3245
+ const defineCustomElement = defineCustomElement$1;
3246
+
3247
+ export { JeDatepicker, defineCustomElement };
3248
+
3249
+ //# sourceMappingURL=je-datepicker.js.map