@genexus/genexus-ide-ui 1.0.19 → 1.0.20
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.
- package/dist/cjs/{form-validation-df39cabb.js → form-validation-0019e158.js} +2 -2
- package/dist/cjs/form-validation-0019e158.js.map +1 -0
- package/dist/cjs/genexus-ide-ui.cjs.js +1 -1
- package/dist/cjs/gx-ide-connect-gx-server.cjs.entry.js +1 -1
- package/dist/cjs/gx-ide-create-kb-from-server.cjs.entry.js +1 -1
- package/dist/cjs/{gx-ide-empty-state_2.cjs.entry.js → gx-ide-empty-state.cjs.entry.js} +3 -56
- package/dist/cjs/gx-ide-empty-state.cjs.entry.js.map +1 -0
- package/dist/cjs/gx-ide-loader.cjs.entry.js +61 -0
- package/dist/cjs/gx-ide-loader.cjs.entry.js.map +1 -0
- package/dist/cjs/gx-ide-new-environment.cjs.entry.js +1 -1
- package/dist/cjs/gx-ide-new-kb.cjs.entry.js +1 -1
- package/dist/cjs/gx-ide-share-kb.cjs.entry.js +1 -1
- package/dist/cjs/gx-ide-splash.cjs.entry.js +76 -0
- package/dist/cjs/gx-ide-splash.cjs.entry.js.map +1 -0
- package/dist/cjs/gx-ide-start-page.cjs.entry.js +2644 -104
- package/dist/cjs/gx-ide-start-page.cjs.entry.js.map +1 -1
- package/dist/cjs/gx-ide-welcome-page.cjs.entry.js +257 -0
- package/dist/cjs/gx-ide-welcome-page.cjs.entry.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/common/form-validation.js +1 -1
- package/dist/collection/common/form-validation.js.map +1 -1
- package/dist/collection/components/_helpers/ide-loader/ide-loader.css +4 -1
- package/dist/collection/components/_helpers/ide-loader/ide-loader.js +2 -2
- package/dist/collection/components/_helpers/ide-loader/ide-loader.js.map +1 -1
- package/dist/collection/components/splash/gx-ide-assets/splash/images/copyrights-illustration.png +0 -0
- package/dist/collection/components/splash/gx-ide-assets/splash/images/icon-next.svg +4 -0
- package/dist/collection/components/splash/gx-ide-assets/splash/langs/splash.lang.en.json +14 -0
- package/dist/collection/components/splash/gx-ide-assets/splash/langs/splash.lang.ja.json +13 -0
- package/dist/collection/components/splash/gx-ide-assets/splash/langs/splash.lang.zh.json +13 -0
- package/dist/collection/components/splash/splash.css +56 -0
- package/dist/collection/components/splash/splash.js +125 -0
- package/dist/collection/components/splash/splash.js.map +1 -0
- package/dist/collection/components/start-page/gx-ide-assets/start-page/langs/start-page.lang.en.json +19 -27
- package/dist/collection/components/start-page/gx-ide-assets/start-page/langs/start-page.lang.ja.json +18 -26
- package/dist/collection/components/start-page/gx-ide-assets/start-page/langs/start-page.lang.zh.json +23 -1
- package/dist/collection/components/start-page/start-page.css +142 -624
- package/dist/collection/components/start-page/start-page.js +198 -181
- package/dist/collection/components/start-page/start-page.js.map +1 -1
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/arrow-next.svg +3 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/copyrights-base.svg +61 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/copyrights-illustration.png +0 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/fig-ellipse-blurred.svg +21 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/fig-ellipse-bottom-left.svg +14 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/fig-ellipse-top-left.svg +14 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/fig-polygon.svg +14 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/icon-next.svg +4 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/slide-1.svg +115 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/slide-2.svg +67 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/slide-3.svg +138 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/slide-4.svg +97 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/images/slide-5.svg +83 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/langs/welcome-page.lang.en.json +13 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/langs/welcome-page.lang.ja.json +13 -0
- package/dist/collection/components/welcome-page/gx-ide-assets/welcome-page/langs/welcome-page.lang.zh.json +13 -0
- package/dist/collection/components/welcome-page/welcome-page.css +264 -0
- package/dist/collection/components/welcome-page/welcome-page.js +360 -0
- package/dist/collection/components/welcome-page/welcome-page.js.map +1 -0
- package/dist/collection/pages/assets/images/welcome-page/slide-1.svg +115 -0
- package/dist/collection/pages/assets/images/welcome-page/slide-2.svg +67 -0
- package/dist/collection/pages/assets/images/welcome-page/slide-3.svg +138 -0
- package/dist/collection/pages/assets/images/welcome-page/slide-4.svg +97 -0
- package/dist/collection/pages/assets/images/welcome-page/slide-5.svg +83 -0
- package/dist/components/form-validation.js +1 -1
- package/dist/components/form-validation.js.map +1 -1
- package/dist/components/{gx-ide-recent-news.d.ts → gx-ide-splash.d.ts} +4 -4
- package/dist/components/gx-ide-splash.js +96 -0
- package/dist/components/gx-ide-splash.js.map +1 -0
- package/dist/components/gx-ide-start-page.js +2654 -126
- package/dist/components/gx-ide-start-page.js.map +1 -1
- package/dist/components/gx-ide-welcome-page.d.ts +11 -0
- package/dist/components/gx-ide-welcome-page.js +283 -0
- package/dist/components/gx-ide-welcome-page.js.map +1 -0
- package/dist/components/ide-loader.js +3 -3
- package/dist/components/ide-loader.js.map +1 -1
- package/dist/esm/{form-validation-8b3f527c.js → form-validation-44b2c2a8.js} +2 -2
- package/dist/esm/form-validation-44b2c2a8.js.map +1 -0
- package/dist/esm/genexus-ide-ui.js +1 -1
- package/dist/esm/gx-ide-connect-gx-server.entry.js +1 -1
- package/dist/esm/gx-ide-create-kb-from-server.entry.js +1 -1
- package/dist/esm/{gx-ide-empty-state_2.entry.js → gx-ide-empty-state.entry.js} +5 -57
- package/dist/esm/gx-ide-empty-state.entry.js.map +1 -0
- package/dist/esm/gx-ide-loader.entry.js +57 -0
- package/dist/esm/gx-ide-loader.entry.js.map +1 -0
- package/dist/esm/gx-ide-new-environment.entry.js +1 -1
- package/dist/esm/gx-ide-new-kb.entry.js +1 -1
- package/dist/esm/gx-ide-share-kb.entry.js +1 -1
- package/dist/esm/gx-ide-splash.entry.js +72 -0
- package/dist/esm/gx-ide-splash.entry.js.map +1 -0
- package/dist/esm/gx-ide-start-page.entry.js +2644 -104
- package/dist/esm/gx-ide-start-page.entry.js.map +1 -1
- package/dist/esm/gx-ide-welcome-page.entry.js +253 -0
- package/dist/esm/gx-ide-welcome-page.entry.js.map +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/genexus-ide-ui/genexus-ide-ui.esm.js +1 -1
- package/dist/genexus-ide-ui/genexus-ide-ui.esm.js.map +1 -1
- package/dist/genexus-ide-ui/gx-ide-assets/splash/images/copyrights-illustration.png +0 -0
- package/dist/genexus-ide-ui/gx-ide-assets/splash/images/icon-next.svg +4 -0
- package/dist/genexus-ide-ui/gx-ide-assets/splash/langs/splash.lang.en.json +14 -0
- package/dist/genexus-ide-ui/gx-ide-assets/splash/langs/splash.lang.ja.json +13 -0
- package/dist/genexus-ide-ui/gx-ide-assets/splash/langs/splash.lang.zh.json +13 -0
- package/dist/genexus-ide-ui/gx-ide-assets/start-page/langs/start-page.lang.en.json +19 -27
- package/dist/genexus-ide-ui/gx-ide-assets/start-page/langs/start-page.lang.ja.json +18 -26
- package/dist/genexus-ide-ui/gx-ide-assets/start-page/langs/start-page.lang.zh.json +23 -1
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/arrow-next.svg +3 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/copyrights-base.svg +61 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/copyrights-illustration.png +0 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/fig-ellipse-blurred.svg +21 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/fig-ellipse-bottom-left.svg +14 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/fig-ellipse-top-left.svg +14 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/fig-polygon.svg +14 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/icon-next.svg +4 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/slide-1.svg +115 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/slide-2.svg +67 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/slide-3.svg +138 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/slide-4.svg +97 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/images/slide-5.svg +83 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/langs/welcome-page.lang.en.json +13 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/langs/welcome-page.lang.ja.json +13 -0
- package/dist/genexus-ide-ui/gx-ide-assets/welcome-page/langs/welcome-page.lang.zh.json +13 -0
- package/dist/genexus-ide-ui/{p-d5d0ed5e.entry.js → p-02bc66c1.entry.js} +2 -2
- package/dist/genexus-ide-ui/p-120d283a.entry.js +2419 -0
- package/dist/genexus-ide-ui/p-120d283a.entry.js.map +1 -0
- package/dist/genexus-ide-ui/{p-fc64d088.entry.js → p-58e13823.entry.js} +2 -2
- package/dist/genexus-ide-ui/{p-98b5b178.entry.js → p-658755d5.entry.js} +18 -87
- package/dist/genexus-ide-ui/p-658755d5.entry.js.map +1 -0
- package/dist/genexus-ide-ui/p-7a2d3f1c.entry.js +304 -0
- package/dist/genexus-ide-ui/p-7a2d3f1c.entry.js.map +1 -0
- package/dist/genexus-ide-ui/p-7ec19ed6.entry.js +73 -0
- package/dist/genexus-ide-ui/p-7ec19ed6.entry.js.map +1 -0
- package/dist/genexus-ide-ui/{p-c36effd2.entry.js → p-806fc181.entry.js} +2 -2
- package/dist/genexus-ide-ui/{p-352d4aad.entry.js → p-8c986256.entry.js} +2 -2
- package/dist/genexus-ide-ui/{p-41ea711a.js → p-b8624c0b.js} +2 -2
- package/dist/genexus-ide-ui/p-b8624c0b.js.map +1 -0
- package/dist/genexus-ide-ui/p-c8b4f34c.entry.js +113 -0
- package/dist/genexus-ide-ui/p-c8b4f34c.entry.js.map +1 -0
- package/dist/genexus-ide-ui/{p-b1f6fdd6.entry.js → p-cf2c8b3c.entry.js} +2 -2
- package/dist/types/components/splash/splash.d.ts +20 -0
- package/dist/types/components/start-page/start-page.d.ts +31 -53
- package/dist/types/components/welcome-page/welcome-page.d.ts +63 -0
- package/dist/types/components.d.ts +94 -65
- package/package.json +6 -3
- package/dist/cjs/form-validation-df39cabb.js.map +0 -1
- package/dist/cjs/gx-ide-empty-state_2.cjs.entry.js.map +0 -1
- package/dist/cjs/gx-ide-recent-news.cjs.entry.js +0 -163
- package/dist/cjs/gx-ide-recent-news.cjs.entry.js.map +0 -1
- package/dist/collection/components/start-page/gx-ide-assets/recent-news/langs/recent-news.lang.en.json +0 -24
- package/dist/collection/components/start-page/gx-ide-assets/recent-news/langs/recent-news.lang.ja.json +0 -24
- package/dist/collection/components/start-page/gx-ide-assets/recent-news/langs/recent-news.lang.zh.json +0 -3
- package/dist/collection/components/start-page/recent-news.css +0 -641
- package/dist/collection/components/start-page/recent-news.js +0 -240
- package/dist/collection/components/start-page/recent-news.js.map +0 -1
- package/dist/components/gx-ide-recent-news.js +0 -8
- package/dist/components/gx-ide-recent-news.js.map +0 -1
- package/dist/components/recent-news.js +0 -197
- package/dist/components/recent-news.js.map +0 -1
- package/dist/esm/form-validation-8b3f527c.js.map +0 -1
- package/dist/esm/gx-ide-empty-state_2.entry.js.map +0 -1
- package/dist/esm/gx-ide-recent-news.entry.js +0 -159
- package/dist/esm/gx-ide-recent-news.entry.js.map +0 -1
- package/dist/genexus-ide-ui/gx-ide-assets/recent-news/langs/recent-news.lang.en.json +0 -24
- package/dist/genexus-ide-ui/gx-ide-assets/recent-news/langs/recent-news.lang.ja.json +0 -24
- package/dist/genexus-ide-ui/gx-ide-assets/recent-news/langs/recent-news.lang.zh.json +0 -3
- package/dist/genexus-ide-ui/p-0576a392.entry.js +0 -233
- package/dist/genexus-ide-ui/p-0576a392.entry.js.map +0 -1
- package/dist/genexus-ide-ui/p-20389960.entry.js +0 -211
- package/dist/genexus-ide-ui/p-20389960.entry.js.map +0 -1
- package/dist/genexus-ide-ui/p-41ea711a.js.map +0 -1
- package/dist/genexus-ide-ui/p-98b5b178.entry.js.map +0 -1
- package/dist/types/components/start-page/recent-news.d.ts +0 -43
- /package/dist/genexus-ide-ui/{p-d5d0ed5e.entry.js.map → p-02bc66c1.entry.js.map} +0 -0
- /package/dist/genexus-ide-ui/{p-fc64d088.entry.js.map → p-58e13823.entry.js.map} +0 -0
- /package/dist/genexus-ide-ui/{p-c36effd2.entry.js.map → p-806fc181.entry.js.map} +0 -0
- /package/dist/genexus-ide-ui/{p-352d4aad.entry.js.map → p-8c986256.entry.js.map} +0 -0
- /package/dist/genexus-ide-ui/{p-b1f6fdd6.entry.js.map → p-cf2c8b3c.entry.js.map} +0 -0
|
@@ -1,13 +1,2508 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { g as getIconPath } from './assets-manager.js';
|
|
3
3
|
import { L as Locale } from './locale.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { d as defineCustomElement$4 } from './gx-ide-empty-state2.js';
|
|
7
|
-
import { d as defineCustomElement$3 } from './ide-loader.js';
|
|
8
|
-
import { d as defineCustomElement$2 } from './recent-news.js';
|
|
4
|
+
import { d as defineCustomElement$3 } from './gx-ide-empty-state2.js';
|
|
5
|
+
import { d as defineCustomElement$2 } from './ide-loader.js';
|
|
9
6
|
|
|
10
|
-
const startPageCss = ":root {\n --ui-animaton-speed: 0.2s;\n}\n\n/*ALIGNMENT*/\n/*Ellipsis*/\n/*****************************************************\nTYPOGRAPHY\n*****************************************************/\n/*Title 01 (Positive)*/\n.gxg-title-01 {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-01-font-weight);\n font-size: var(--ds-title-01-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--comfortable);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n/*Title 01 (Negative)*/\n.gxg-title-01--negative {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-01-font-weight);\n font-size: var(--ds-title-01-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--comfortable);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--negative);\n}\n\n/*Title 02 (Positive)*/\n.gxg-title-02 {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-02-font-weight);\n font-size: var(--ds-title-02-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n text-transform: uppercase;\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n.gxg-title-02--negative {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-02-font-weight);\n font-size: var(--ds-title-02-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n text-transform: uppercase;\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--color-on-primary);\n}\n\n/*Title 03*/\n.gxg-title-03 {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-03-font-weight);\n font-size: var(--ds-title-03-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n text-transform: uppercase;\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n.gxg-title-03--negative {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-03-font-weight);\n font-size: var(--ds-title-03-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n text-transform: uppercase;\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--negative);\n}\n\n/*Title 04*/\n.gxg-title-04 {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-04-font-weight);\n font-size: var(--ds-title-04-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--comfortable);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n.gxg-title-04--negative {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-04-font-weight);\n font-size: var(--ds-title-04-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--comfortable);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--negative);\n}\n\n/*Title 05*/\n.gxg-title-05 {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-05-font-weight);\n font-size: var(--ds-title-05-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n.gxg-title-05--negative {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--ds-title-05-font-weight);\n font-size: var(--ds-title-05-font-size);\n letter-spacing: var(--ds-base-font-letter-spacing--regular);\n color: var(--ds-base-font-color);\n text-align: start;\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--negative);\n}\n\n/*Text*/\n.gxg-text {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n}\n\n.gxg-text--negative {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--negative);\n}\n\n.gxg-text--gray {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--dimmed);\n}\n\n/*Quote*/\n.gxg-quote {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n font-style: italic;\n}\n\n.gxg-quote--negative {\n color: var(--ds-base-font-color--negative);\n}\n\n/*Link*/\n.gxg-link {\n line-height: unset;\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--link);\n text-decoration: underline;\n cursor: pointer;\n display: inline-block;\n}\n.gxg-link:hover {\n color: var(--ds-base-font-color--link-hover);\n}\n.gxg-link:active {\n color: var(--ds-base-font-color--link-active);\n}\n\n.gxg-link-gray {\n line-height: unset;\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--link);\n text-decoration: underline;\n cursor: pointer;\n display: inline-block;\n color: var(--ds-base-font-color--dimmed);\n}\n.gxg-link-gray:hover {\n line-height: unset;\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--link);\n text-decoration: underline;\n cursor: pointer;\n display: inline-block;\n color: var(--ds-base-font-color--dimmed);\n filter: brightness(1.4);\n}\n\n/*Alerts*/\n.gxg-alert-error {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--error);\n display: inline-block;\n}\n\n.gxg-alert-warning {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--warning);\n display: inline-block;\n}\n\n.gxg-alert-success {\n font-family: var(--ds-base-font-family-primary);\n font-size: var(--ds-base-font-size);\n color: var(--ds-base-font-size-color);\n font-weight: var(--ds-base-font-size-weight);\n line-height: var(--ds-base-font-line-height--comfortable);\n color: var(--ds-base-font-color--success);\n display: inline-block;\n}\n\n/*Tab*/\n.gxg-tab--disabled {\n color: var(--color-primary-disabled);\n pointer-events: none;\n}\n.gxg-tab--disabled[disabled] {\n color: var(--color-primary-disabled);\n pointer-events: none;\n}\n\n/*Label*/\n.gxg-label {\n font-family: var(--ds-base-font-family-primary);\n font-weight: var(--gxg-label-font-weight);\n font-size: var(--gxg-label-font-size);\n color: var(--gxg-label-color);\n text-align: center;\n line-height: 1.455em;\n display: flex;\n align-items: center;\n}\n.gxg-label:hover {\n color: var(--color-primary-hover);\n}\n.gxg-label:focus {\n color: var(--color-primary-active);\n}\n.gxg-label:active {\n color: var(--color-primary-active);\n}\n.gxg-label[disabled] {\n color: var(--color-primary-disabled);\n}\n\n.gxg-label--negative {\n color: var(--color-on-primary);\n}\n.gxg-label--negative[disabled] {\n color: var(--color-on-disabled);\n}\n\n/*****************************************************\nGXG-BUTTON and GXG-BUTTON-GROUP COMMON STYLES\n*****************************************************/\n/*****************************************************\nFORM ELEMENTS\n*****************************************************/\n.gxg-scrollbar {\n /* Track */\n /* Handle */\n /* Handle on hover */\n}\n.gxg-scrollbar::-webkit-scrollbar {\n width: var(--gxg-scrollbar-width);\n height: var(--gxg-scrollbar-width);\n}\n.gxg-scrollbar::-webkit-scrollbar-track {\n background-color: var(--gxg-scrollbar-track-background);\n border-radius: var(--gxg-scrollbar-track-border-radius);\n}\n.gxg-scrollbar::-webkit-scrollbar-thumb {\n background-color: var(--gxg-scrollbar-track-thumb-background);\n border-radius: var(--gxg-scrollbar-track-thumb-radius);\n}\n.gxg-scrollbar::-webkit-scrollbar-thumb:hover {\n background-color: var(--gxg-scrollbar-track-thumb-hover-background);\n}\n.gxg-scrollbar::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n\n/*Gx Ide*/\n/*@container queries*/\n/* hiChar styles\nFound on /common/helpers.tsx hiChar function is used to add a span/class to every character that matches a search value. It is used to help the user see why the filter results are filtered. The span/class on the characters are useless without proper styling.\n*/\n@keyframes spin {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}\n/* - - - - - - - - - - - - - - - - -\nNew classes for Chameleon + Mercury\n- - - - - - - - - - - - - - - - - */\n:host {\n display: grid;\n block-size: 100%;\n}\n\n.card-regular {\n background-color: var(--mer-surface__elevation--01);\n border: var(--mer-border__width--sm) solid var(--mer-border-color__on-elevation--01);\n border-radius: var(--mer-border__radius--md);\n padding: var(--mer-spacing--md) var(--mer-spacing--md);\n display: grid;\n}\n\n.card-small {\n background-color: var(--mer-surface__elevation--02);\n border-radius: var(--mer-border__radius--sm);\n padding: var(--mer-spacing--sm) var(--mer-spacing--sm);\n}\n.card-small--actionable:hover {\n background-color: var(--mer-color__neutral-gray--600);\n}\n.card-small--actionable:active {\n background-color: var(--mer-color__neutral-gray--650);\n}\n.card-small:focus-visible {\n outline: var(--focus__outline-width) var(--focus__outline-style) var(--focus__outline-color);\n outline-offset: var(--focus__outline-offset);\n}\n\n.empty-state {\n block-size: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: var(--mer-spacing--sm);\n text-align: center;\n}\n.empty-state__title, .empty-state__button, .empty-state__link {\n max-inline-size: 300px;\n}\n\n.opacity-0 {\n opacity: 0;\n}\n\n.opacity-1 {\n opacity: 1;\n}\n\n.display-contents {\n display: contents;\n}\n\n/* - - - - - - - - - - - - - - - - - - - \nOld classes (Gemini) to be removed soon\n- - - - - - - - - - - - - - - - - - - */\n/* - - - - - - - - - - - - - - - - - - - \nOld classes (Gemini) to be removed soon\n- - - - - - - - - - - - - - - - - - - */\n/* Helper Classes */\n.gxi-hidden {\n display: none !important;\n}\n\n.gxi-full-height {\n height: 100%;\n}\n\n.gxi-overflow-auto {\n overflow: auto;\n}\n\n.gxi-display-flex {\n display: flex;\n}\n\n.align-start {\n display: flex;\n align-items: start;\n}\n\n.align-center {\n display: flex;\n align-items: center;\n}\n\n.align-end {\n display: flex;\n align-items: end;\n}\n\n.overflow-auto {\n overflow: auto;\n}\n\n.justify-start {\n display: flex;\n justify-content: start;\n}\n\n.justify-center {\n display: flex;\n justify-content: center;\n}\n\n.justify-end {\n display: flex;\n justify-content: end;\n}\n\n/* Grids */\n.grid {\n display: grid;\n grid-row-gap: var(--gx-ide-grid-row-gap);\n grid-column-gap: var(--gx-ide-grid-column-gap);\n grid-template-rows: auto;\n}\n\nch-grid-cell {\n display: flex;\n}\n\nch-grid {\n overflow: auto;\n height: 100%;\n}\n\nch-grid-column {\n /*to be removed when this works inside a component with shadow: true*/\n z-index: 99;\n border-bottom: 1px solid var(--mer-color__neutral-gray--800);\n}\n\nch-grid-column:first-child {\n padding-inline-start: var(--gx-ide-container__padding) !important;\n}\n\nch-grid-column:last-child {\n padding-inline-end: var(--gx-ide-container__padding) !important;\n}\n\nch-grid-cell {\n --mer-spacing--xs: var(--gx-ide-container__padding);\n}\n\n/*--- Layout ---*/\n.layout {\n display: grid;\n gap: var(--mer-spacing--lg);\n box-sizing: border-box;\n}\n.layout--two-cols {\n grid-template-columns: 1fr 1fr;\n}\n.layout--space-above {\n padding-block-start: var(--mer-spacing--lg);\n}\n\n/*Gxg Tabs*/\ngxg-tabs {\n box-shadow: none;\n}\n\n/*All components Host should have this class set. !important is set on every rule, since this styles could be overridden by the host user, since they are applied on the host component*/\n:host(.gx-ide-component) {\n height: 100% !important;\n display: flex !important;\n flex-direction: column !important;\n}\n\n/*stylize the top bar*/\n:host(:focus-within) gx-ide-top-bar::part(wrapper) {\n background-color: var(--color-secondary-enabled);\n}\n\n/* Main wrapper (should be the first element inside the host. Everything should be inside .gx-ide-main-wrapper) */\n.gx-ide-main-wrapper {\n color: var(--gx-ide-component-text-color);\n font-weight: var(--mer-font__weight--regular);\n font-size: var(--mer-font__size--xs);\n font-family: var(--mer-font-family--primary);\n height: 100%;\n background-color: var(--gx-ide-component-background-color);\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n box-sizing: border-box;\n}\n\n/*This is the main element. This is the one that take the remaining vertical space*/\n.gx-ide-main {\n flex-grow: 1;\n overflow-y: auto;\n /* Track */\n /* Handle */\n /* Handle on hover */\n}\n.gx-ide-main::-webkit-scrollbar {\n width: var(--gxg-scrollbar-width);\n height: var(--gxg-scrollbar-width);\n}\n.gx-ide-main::-webkit-scrollbar-track {\n background-color: var(--gxg-scrollbar-track-background);\n border-radius: var(--gxg-scrollbar-track-border-radius);\n}\n.gx-ide-main::-webkit-scrollbar-thumb {\n background-color: var(--gxg-scrollbar-track-thumb-background);\n border-radius: var(--gxg-scrollbar-track-thumb-radius);\n}\n.gx-ide-main::-webkit-scrollbar-thumb:hover {\n background-color: var(--gxg-scrollbar-track-thumb-hover-background);\n}\n.gx-ide-main::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n\n.gx-ide-overflow {\n overflow-y: auto;\n /* Track */\n /* Handle */\n /* Handle on hover */\n}\n.gx-ide-overflow::-webkit-scrollbar {\n width: var(--gxg-scrollbar-width);\n height: var(--gxg-scrollbar-width);\n}\n.gx-ide-overflow::-webkit-scrollbar-track {\n background-color: var(--gxg-scrollbar-track-background);\n border-radius: var(--gxg-scrollbar-track-border-radius);\n}\n.gx-ide-overflow::-webkit-scrollbar-thumb {\n background-color: var(--gxg-scrollbar-track-thumb-background);\n border-radius: var(--gxg-scrollbar-track-thumb-radius);\n}\n.gx-ide-overflow::-webkit-scrollbar-thumb:hover {\n background-color: var(--gxg-scrollbar-track-thumb-hover-background);\n}\n.gx-ide-overflow::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n\n.tree-view-primary {\n font-size: var(--mer-font__size--2xs);\n}\n\np {\n margin: 0;\n font-size: var(--mer-font__size--xxs);\n}\n\n/* - - - - - - - - - - - - - - - - - -\nNew : For Mercury\n- - - - - - - - - - - - - - - - - - */\n.buttons-container {\n display: flex;\n gap: var(--mer-spacing--xs);\n}\n\n/*Gx Ide*/\n/*@container queries*/\n/* hiChar styles\nFound on /common/helpers.tsx hiChar function is used to add a span/class to every character that matches a search value. It is used to help the user see why the filter results are filtered. The span/class on the characters are useless without proper styling.\n*/\n.hiChar {\n color: var(--mer-color__primary--200);\n filter: brightness(1.3);\n}\n\n:host {\n overflow: auto;\n container-type: inline-size;\n container-name: host;\n}\n\n.layout-main,\n.layout__panel {\n block-size: 100%;\n overflow: auto;\n}\n\n@container host (max-width: 768px) {\n .layout.layout-main {\n grid-template-columns: 1fr;\n grid-template-rows: 1fr 1fr;\n }\n}\n.panel-recent-kbs {\n position: relative;\n}\n\n.recent-kbs,\n.recent-news {\n display: grid;\n grid-template-rows: auto 1fr;\n gap: var(--mer-spacing--md);\n overflow: auto;\n}\n.recent-kbs__header,\n.recent-news__header {\n display: grid;\n gap: var(--mer-spacing--md);\n}\n\n.kbs-container {\n display: grid;\n gap: var(--mer-spacing--xs);\n overflow: auto;\n grid-auto-rows: max-content;\n container-type: inline-size;\n container-name: kb-container;\n animation: fadeIn var(--mer-timing--super-fast) forwards linear;\n}\n\n.card-kb {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--mer-spacing--lg);\n container-type: inline-size;\n container-name: card-kb;\n}\n.card-kb__left-col {\n display: flex;\n align-items: center;\n gap: var(--mer-spacing--sm);\n}\n\n@container kb-container (max-width: 360px) {\n .card-kb {\n align-items: center;\n flex-direction: column;\n gap: var(--mer-spacing--xs);\n justify-content: start;\n }\n}\ngx-ide-recent-news {\n overflow: auto;\n}\n\n.panel-recent-news {\n position: relative;\n}\n\n@keyframes exactMatchBright {\n 100% {\n filter: brightness(1.25);\n }\n}\n.exact-match-bright {\n animation: exactMatchBright var(--mer-timing--super-fast) ease-in-out 4 alternate;\n}\n\ngx-ide-loader::part(loader-wrapper) {\n border: var(--mer-border__width--sm) solid var(--mer-border-color__on-elevation--01);\n border-radius: var(--mer-border__radius--md);\n}\n\n@keyframes fadeIn {\n 0% {\n opacity: 0;\n }\n}";
|
|
7
|
+
/**
|
|
8
|
+
* @module constants
|
|
9
|
+
* @summary Useful constants
|
|
10
|
+
* @description
|
|
11
|
+
* Collection of useful date constants.
|
|
12
|
+
*
|
|
13
|
+
* The constants could be imported from `date-fns/constants`:
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { maxTime, minTime } from "./constants/date-fns/constants";
|
|
17
|
+
*
|
|
18
|
+
* function isAllowedTime(time) {
|
|
19
|
+
* return time <= maxTime && time >= minTime;
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @constant
|
|
26
|
+
* @name minutesInMonth
|
|
27
|
+
* @summary Minutes in 1 month.
|
|
28
|
+
*/
|
|
29
|
+
const minutesInMonth = 43200;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @constant
|
|
33
|
+
* @name minutesInDay
|
|
34
|
+
* @summary Minutes in 1 day.
|
|
35
|
+
*/
|
|
36
|
+
const minutesInDay = 1440;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @constant
|
|
40
|
+
* @name constructFromSymbol
|
|
41
|
+
* @summary Symbol enabling Date extensions to inherit properties from the reference date.
|
|
42
|
+
*
|
|
43
|
+
* The symbol is used to enable the `constructFrom` function to construct a date
|
|
44
|
+
* using a reference date and a value. It allows to transfer extra properties
|
|
45
|
+
* from the reference date to the new date. It's useful for extensions like
|
|
46
|
+
* [`TZDate`](https://github.com/date-fns/tz) that accept a time zone as
|
|
47
|
+
* a constructor argument.
|
|
48
|
+
*/
|
|
49
|
+
const constructFromSymbol = Symbol.for("constructDateFrom");
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @name constructFrom
|
|
53
|
+
* @category Generic Helpers
|
|
54
|
+
* @summary Constructs a date using the reference date and the value
|
|
55
|
+
*
|
|
56
|
+
* @description
|
|
57
|
+
* The function constructs a new date using the constructor from the reference
|
|
58
|
+
* date and the given value. It helps to build generic functions that accept
|
|
59
|
+
* date extensions.
|
|
60
|
+
*
|
|
61
|
+
* It defaults to `Date` if the passed reference date is a number or a string.
|
|
62
|
+
*
|
|
63
|
+
* Starting from v3.7.0, it allows to construct a date using `[Symbol.for("constructDateFrom")]`
|
|
64
|
+
* enabling to transfer extra properties from the reference date to the new date.
|
|
65
|
+
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
|
|
66
|
+
* that accept a time zone as a constructor argument.
|
|
67
|
+
*
|
|
68
|
+
* @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).
|
|
69
|
+
*
|
|
70
|
+
* @param date - The reference date to take constructor from
|
|
71
|
+
* @param value - The value to create the date
|
|
72
|
+
*
|
|
73
|
+
* @returns Date initialized using the given date and value
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* import { constructFrom } from "./constructFrom/date-fns";
|
|
77
|
+
*
|
|
78
|
+
* // A function that clones a date preserving the original type
|
|
79
|
+
* function cloneDate<DateType extends Date>(date: DateType): DateType {
|
|
80
|
+
* return constructFrom(
|
|
81
|
+
* date, // Use constructor from the given date
|
|
82
|
+
* date.getTime() // Use the date value to create a new date
|
|
83
|
+
* );
|
|
84
|
+
* }
|
|
85
|
+
*/
|
|
86
|
+
function constructFrom(date, value) {
|
|
87
|
+
if (typeof date === "function") return date(value);
|
|
88
|
+
|
|
89
|
+
if (date && typeof date === "object" && constructFromSymbol in date)
|
|
90
|
+
return date[constructFromSymbol](value);
|
|
91
|
+
|
|
92
|
+
if (date instanceof Date) return new date.constructor(value);
|
|
93
|
+
|
|
94
|
+
return new Date(value);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @name toDate
|
|
99
|
+
* @category Common Helpers
|
|
100
|
+
* @summary Convert the given argument to an instance of Date.
|
|
101
|
+
*
|
|
102
|
+
* @description
|
|
103
|
+
* Convert the given argument to an instance of Date.
|
|
104
|
+
*
|
|
105
|
+
* If the argument is an instance of Date, the function returns its clone.
|
|
106
|
+
*
|
|
107
|
+
* If the argument is a number, it is treated as a timestamp.
|
|
108
|
+
*
|
|
109
|
+
* If the argument is none of the above, the function returns Invalid Date.
|
|
110
|
+
*
|
|
111
|
+
* Starting from v3.7.0, it clones a date using `[Symbol.for("constructDateFrom")]`
|
|
112
|
+
* enabling to transfer extra properties from the reference date to the new date.
|
|
113
|
+
* It's useful for extensions like [`TZDate`](https://github.com/date-fns/tz)
|
|
114
|
+
* that accept a time zone as a constructor argument.
|
|
115
|
+
*
|
|
116
|
+
* **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
|
|
117
|
+
*
|
|
118
|
+
* @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).
|
|
119
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
120
|
+
*
|
|
121
|
+
* @param argument - The value to convert
|
|
122
|
+
*
|
|
123
|
+
* @returns The parsed date in the local time zone
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* // Clone the date:
|
|
127
|
+
* const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
|
|
128
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* // Convert the timestamp to date:
|
|
132
|
+
* const result = toDate(1392098430000)
|
|
133
|
+
* //=> Tue Feb 11 2014 11:30:30
|
|
134
|
+
*/
|
|
135
|
+
function toDate(argument, context) {
|
|
136
|
+
// [TODO] Get rid of `toDate` or `constructFrom`?
|
|
137
|
+
return constructFrom(context || argument, argument);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let defaultOptions = {};
|
|
141
|
+
|
|
142
|
+
function getDefaultOptions() {
|
|
143
|
+
return defaultOptions;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The {@link startOfWeek} function options.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @name startOfWeek
|
|
152
|
+
* @category Week Helpers
|
|
153
|
+
* @summary Return the start of a week for the given date.
|
|
154
|
+
*
|
|
155
|
+
* @description
|
|
156
|
+
* Return the start of a week for the given date.
|
|
157
|
+
* The result will be in the local timezone.
|
|
158
|
+
*
|
|
159
|
+
* @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).
|
|
160
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
161
|
+
*
|
|
162
|
+
* @param date - The original date
|
|
163
|
+
* @param options - An object with options
|
|
164
|
+
*
|
|
165
|
+
* @returns The start of a week
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* // The start of a week for 2 September 2014 11:55:00:
|
|
169
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0))
|
|
170
|
+
* //=> Sun Aug 31 2014 00:00:00
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // If the week starts on Monday, the start of the week for 2 September 2014 11:55:00:
|
|
174
|
+
* const result = startOfWeek(new Date(2014, 8, 2, 11, 55, 0), { weekStartsOn: 1 })
|
|
175
|
+
* //=> Mon Sep 01 2014 00:00:00
|
|
176
|
+
*/
|
|
177
|
+
function startOfWeek(date, options) {
|
|
178
|
+
const defaultOptions = getDefaultOptions();
|
|
179
|
+
const weekStartsOn =
|
|
180
|
+
options?.weekStartsOn ??
|
|
181
|
+
options?.locale?.options?.weekStartsOn ??
|
|
182
|
+
defaultOptions.weekStartsOn ??
|
|
183
|
+
defaultOptions.locale?.options?.weekStartsOn ??
|
|
184
|
+
0;
|
|
185
|
+
|
|
186
|
+
const _date = toDate(date, options?.in);
|
|
187
|
+
const day = _date.getDay();
|
|
188
|
+
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
189
|
+
|
|
190
|
+
_date.setDate(_date.getDate() - diff);
|
|
191
|
+
_date.setHours(0, 0, 0, 0);
|
|
192
|
+
return _date;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.
|
|
197
|
+
* They usually appear for dates that denote time before the timezones were introduced
|
|
198
|
+
* (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891
|
|
199
|
+
* and GMT+01:00:00 after that date)
|
|
200
|
+
*
|
|
201
|
+
* Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,
|
|
202
|
+
* which would lead to incorrect calculations.
|
|
203
|
+
*
|
|
204
|
+
* This function returns the timezone offset in milliseconds that takes seconds in account.
|
|
205
|
+
*/
|
|
206
|
+
function getTimezoneOffsetInMilliseconds(date) {
|
|
207
|
+
const _date = toDate(date);
|
|
208
|
+
const utcDate = new Date(
|
|
209
|
+
Date.UTC(
|
|
210
|
+
_date.getFullYear(),
|
|
211
|
+
_date.getMonth(),
|
|
212
|
+
_date.getDate(),
|
|
213
|
+
_date.getHours(),
|
|
214
|
+
_date.getMinutes(),
|
|
215
|
+
_date.getSeconds(),
|
|
216
|
+
_date.getMilliseconds(),
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
utcDate.setUTCFullYear(_date.getFullYear());
|
|
220
|
+
return +date - +utcDate;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function normalizeDates(context, ...dates) {
|
|
224
|
+
const normalize = constructFrom.bind(
|
|
225
|
+
null,
|
|
226
|
+
context || dates.find((date) => typeof date === "object"),
|
|
227
|
+
);
|
|
228
|
+
return dates.map(normalize);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* @name compareAsc
|
|
233
|
+
* @category Common Helpers
|
|
234
|
+
* @summary Compare the two dates and return -1, 0 or 1.
|
|
235
|
+
*
|
|
236
|
+
* @description
|
|
237
|
+
* Compare the two dates and return 1 if the first date is after the second,
|
|
238
|
+
* -1 if the first date is before the second or 0 if dates are equal.
|
|
239
|
+
*
|
|
240
|
+
* @param dateLeft - The first date to compare
|
|
241
|
+
* @param dateRight - The second date to compare
|
|
242
|
+
*
|
|
243
|
+
* @returns The result of the comparison
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* // Compare 11 February 1987 and 10 July 1989:
|
|
247
|
+
* const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
|
|
248
|
+
* //=> -1
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Sort the array of dates:
|
|
252
|
+
* const result = [
|
|
253
|
+
* new Date(1995, 6, 2),
|
|
254
|
+
* new Date(1987, 1, 11),
|
|
255
|
+
* new Date(1989, 6, 10)
|
|
256
|
+
* ].sort(compareAsc)
|
|
257
|
+
* //=> [
|
|
258
|
+
* // Wed Feb 11 1987 00:00:00,
|
|
259
|
+
* // Mon Jul 10 1989 00:00:00,
|
|
260
|
+
* // Sun Jul 02 1995 00:00:00
|
|
261
|
+
* // ]
|
|
262
|
+
*/
|
|
263
|
+
function compareAsc(dateLeft, dateRight) {
|
|
264
|
+
const diff = +toDate(dateLeft) - +toDate(dateRight);
|
|
265
|
+
|
|
266
|
+
if (diff < 0) return -1;
|
|
267
|
+
else if (diff > 0) return 1;
|
|
268
|
+
|
|
269
|
+
// Return 0 if diff is 0; return NaN if diff is NaN
|
|
270
|
+
return diff;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @name constructNow
|
|
275
|
+
* @category Generic Helpers
|
|
276
|
+
* @summary Constructs a new current date using the passed value constructor.
|
|
277
|
+
* @pure false
|
|
278
|
+
*
|
|
279
|
+
* @description
|
|
280
|
+
* The function constructs a new current date using the constructor from
|
|
281
|
+
* the reference date. It helps to build generic functions that accept date
|
|
282
|
+
* extensions and use the current date.
|
|
283
|
+
*
|
|
284
|
+
* It defaults to `Date` if the passed reference date is a number or a string.
|
|
285
|
+
*
|
|
286
|
+
* @param date - The reference date to take constructor from
|
|
287
|
+
*
|
|
288
|
+
* @returns Current date initialized using the given date constructor
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* import { constructNow, isSameDay } from 'date-fns'
|
|
292
|
+
*
|
|
293
|
+
* function isToday<DateType extends Date>(
|
|
294
|
+
* date: DateArg<DateType>,
|
|
295
|
+
* ): boolean {
|
|
296
|
+
* // If we were to use `new Date()` directly, the function would behave
|
|
297
|
+
* // differently in different timezones and return false for the same date.
|
|
298
|
+
* return isSameDay(date, constructNow(date));
|
|
299
|
+
* }
|
|
300
|
+
*/
|
|
301
|
+
function constructNow(date) {
|
|
302
|
+
return constructFrom(date, Date.now());
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* The {@link differenceInCalendarMonths} function options.
|
|
307
|
+
*/
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @name differenceInCalendarMonths
|
|
311
|
+
* @category Month Helpers
|
|
312
|
+
* @summary Get the number of calendar months between the given dates.
|
|
313
|
+
*
|
|
314
|
+
* @description
|
|
315
|
+
* Get the number of calendar months between the given dates.
|
|
316
|
+
*
|
|
317
|
+
* @param laterDate - The later date
|
|
318
|
+
* @param earlierDate - The earlier date
|
|
319
|
+
* @param options - An object with options
|
|
320
|
+
*
|
|
321
|
+
* @returns The number of calendar months
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* // How many calendar months are between 31 January 2014 and 1 September 2014?
|
|
325
|
+
* const result = differenceInCalendarMonths(
|
|
326
|
+
* new Date(2014, 8, 1),
|
|
327
|
+
* new Date(2014, 0, 31)
|
|
328
|
+
* )
|
|
329
|
+
* //=> 8
|
|
330
|
+
*/
|
|
331
|
+
function differenceInCalendarMonths(laterDate, earlierDate, options) {
|
|
332
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
333
|
+
options?.in,
|
|
334
|
+
laterDate,
|
|
335
|
+
earlierDate,
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
const yearsDiff = laterDate_.getFullYear() - earlierDate_.getFullYear();
|
|
339
|
+
const monthsDiff = laterDate_.getMonth() - earlierDate_.getMonth();
|
|
340
|
+
|
|
341
|
+
return yearsDiff * 12 + monthsDiff;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function getRoundingMethod(method) {
|
|
345
|
+
return (number) => {
|
|
346
|
+
const round = method ? Math[method] : Math.trunc;
|
|
347
|
+
const result = round(number);
|
|
348
|
+
// Prevent negative zero
|
|
349
|
+
return result === 0 ? 0 : result;
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* @name differenceInMilliseconds
|
|
355
|
+
* @category Millisecond Helpers
|
|
356
|
+
* @summary Get the number of milliseconds between the given dates.
|
|
357
|
+
*
|
|
358
|
+
* @description
|
|
359
|
+
* Get the number of milliseconds between the given dates.
|
|
360
|
+
*
|
|
361
|
+
* @param laterDate - The later date
|
|
362
|
+
* @param earlierDate - The earlier date
|
|
363
|
+
*
|
|
364
|
+
* @returns The number of milliseconds
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* // How many milliseconds are between
|
|
368
|
+
* // 2 July 2014 12:30:20.600 and 2 July 2014 12:30:21.700?
|
|
369
|
+
* const result = differenceInMilliseconds(
|
|
370
|
+
* new Date(2014, 6, 2, 12, 30, 21, 700),
|
|
371
|
+
* new Date(2014, 6, 2, 12, 30, 20, 600)
|
|
372
|
+
* )
|
|
373
|
+
* //=> 1100
|
|
374
|
+
*/
|
|
375
|
+
function differenceInMilliseconds(laterDate, earlierDate) {
|
|
376
|
+
return +toDate(laterDate) - +toDate(earlierDate);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The {@link endOfDay} function options.
|
|
381
|
+
*/
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @name endOfDay
|
|
385
|
+
* @category Day Helpers
|
|
386
|
+
* @summary Return the end of a day for the given date.
|
|
387
|
+
*
|
|
388
|
+
* @description
|
|
389
|
+
* Return the end 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 - An object with options
|
|
397
|
+
*
|
|
398
|
+
* @returns The end of a day
|
|
399
|
+
*
|
|
400
|
+
* @example
|
|
401
|
+
* // The end of a day for 2 September 2014 11:55:00:
|
|
402
|
+
* const result = endOfDay(new Date(2014, 8, 2, 11, 55, 0))
|
|
403
|
+
* //=> Tue Sep 02 2014 23:59:59.999
|
|
404
|
+
*/
|
|
405
|
+
function endOfDay(date, options) {
|
|
406
|
+
const _date = toDate(date, options?.in);
|
|
407
|
+
_date.setHours(23, 59, 59, 999);
|
|
408
|
+
return _date;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* The {@link endOfMonth} function options.
|
|
413
|
+
*/
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* @name endOfMonth
|
|
417
|
+
* @category Month Helpers
|
|
418
|
+
* @summary Return the end of a month for the given date.
|
|
419
|
+
*
|
|
420
|
+
* @description
|
|
421
|
+
* Return the end of a month for the given date.
|
|
422
|
+
* The result will be in the local timezone.
|
|
423
|
+
*
|
|
424
|
+
* @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).
|
|
425
|
+
* @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments.
|
|
426
|
+
*
|
|
427
|
+
* @param date - The original date
|
|
428
|
+
* @param options - An object with options
|
|
429
|
+
*
|
|
430
|
+
* @returns The end of a month
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* // The end of a month for 2 September 2014 11:55:00:
|
|
434
|
+
* const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
|
|
435
|
+
* //=> Tue Sep 30 2014 23:59:59.999
|
|
436
|
+
*/
|
|
437
|
+
function endOfMonth(date, options) {
|
|
438
|
+
const _date = toDate(date, options?.in);
|
|
439
|
+
const month = _date.getMonth();
|
|
440
|
+
_date.setFullYear(_date.getFullYear(), month + 1, 0);
|
|
441
|
+
_date.setHours(23, 59, 59, 999);
|
|
442
|
+
return _date;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* @name isLastDayOfMonth
|
|
447
|
+
* @category Month Helpers
|
|
448
|
+
* @summary Is the given date the last day of a month?
|
|
449
|
+
*
|
|
450
|
+
* @description
|
|
451
|
+
* Is the given date the last day of a month?
|
|
452
|
+
*
|
|
453
|
+
* @param date - The date to check
|
|
454
|
+
* @param options - An object with options
|
|
455
|
+
*
|
|
456
|
+
* @returns The date is the last day of a month
|
|
457
|
+
*
|
|
458
|
+
* @example
|
|
459
|
+
* // Is 28 February 2014 the last day of a month?
|
|
460
|
+
* const result = isLastDayOfMonth(new Date(2014, 1, 28))
|
|
461
|
+
* //=> true
|
|
462
|
+
*/
|
|
463
|
+
function isLastDayOfMonth(date, options) {
|
|
464
|
+
const _date = toDate(date, options?.in);
|
|
465
|
+
return +endOfDay(_date, options) === +endOfMonth(_date, options);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* The {@link differenceInMonths} function options.
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @name differenceInMonths
|
|
474
|
+
* @category Month Helpers
|
|
475
|
+
* @summary Get the number of full months between the given dates.
|
|
476
|
+
*
|
|
477
|
+
* @param laterDate - The later date
|
|
478
|
+
* @param earlierDate - The earlier date
|
|
479
|
+
* @param options - An object with options
|
|
480
|
+
*
|
|
481
|
+
* @returns The number of full months
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* // How many full months are between 31 January 2014 and 1 September 2014?
|
|
485
|
+
* const result = differenceInMonths(new Date(2014, 8, 1), new Date(2014, 0, 31))
|
|
486
|
+
* //=> 7
|
|
487
|
+
*/
|
|
488
|
+
function differenceInMonths(laterDate, earlierDate, options) {
|
|
489
|
+
const [laterDate_, workingLaterDate, earlierDate_] = normalizeDates(
|
|
490
|
+
options?.in,
|
|
491
|
+
laterDate,
|
|
492
|
+
laterDate,
|
|
493
|
+
earlierDate,
|
|
494
|
+
);
|
|
495
|
+
|
|
496
|
+
const sign = compareAsc(workingLaterDate, earlierDate_);
|
|
497
|
+
const difference = Math.abs(
|
|
498
|
+
differenceInCalendarMonths(workingLaterDate, earlierDate_),
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
if (difference < 1) return 0;
|
|
502
|
+
|
|
503
|
+
if (workingLaterDate.getMonth() === 1 && workingLaterDate.getDate() > 27)
|
|
504
|
+
workingLaterDate.setDate(30);
|
|
505
|
+
|
|
506
|
+
workingLaterDate.setMonth(workingLaterDate.getMonth() - sign * difference);
|
|
507
|
+
|
|
508
|
+
let isLastMonthNotFull = compareAsc(workingLaterDate, earlierDate_) === -sign;
|
|
509
|
+
|
|
510
|
+
if (
|
|
511
|
+
isLastDayOfMonth(laterDate_) &&
|
|
512
|
+
difference === 1 &&
|
|
513
|
+
compareAsc(laterDate_, earlierDate_) === 1
|
|
514
|
+
) {
|
|
515
|
+
isLastMonthNotFull = false;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const result = sign * (difference - +isLastMonthNotFull);
|
|
519
|
+
return result === 0 ? 0 : result;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* The {@link differenceInSeconds} function options.
|
|
524
|
+
*/
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* @name differenceInSeconds
|
|
528
|
+
* @category Second Helpers
|
|
529
|
+
* @summary Get the number of seconds between the given dates.
|
|
530
|
+
*
|
|
531
|
+
* @description
|
|
532
|
+
* Get the number of seconds between the given dates.
|
|
533
|
+
*
|
|
534
|
+
* @param laterDate - The later date
|
|
535
|
+
* @param earlierDate - The earlier date
|
|
536
|
+
* @param options - An object with options.
|
|
537
|
+
*
|
|
538
|
+
* @returns The number of seconds
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* // How many seconds are between
|
|
542
|
+
* // 2 July 2014 12:30:07.999 and 2 July 2014 12:30:20.000?
|
|
543
|
+
* const result = differenceInSeconds(
|
|
544
|
+
* new Date(2014, 6, 2, 12, 30, 20, 0),
|
|
545
|
+
* new Date(2014, 6, 2, 12, 30, 7, 999)
|
|
546
|
+
* )
|
|
547
|
+
* //=> 12
|
|
548
|
+
*/
|
|
549
|
+
function differenceInSeconds(laterDate, earlierDate, options) {
|
|
550
|
+
const diff = differenceInMilliseconds(laterDate, earlierDate) / 1000;
|
|
551
|
+
return getRoundingMethod(options?.roundingMethod)(diff);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
const formatDistanceLocale$2 = {
|
|
555
|
+
lessThanXSeconds: {
|
|
556
|
+
one: "less than a second",
|
|
557
|
+
other: "less than {{count}} seconds",
|
|
558
|
+
},
|
|
559
|
+
|
|
560
|
+
xSeconds: {
|
|
561
|
+
one: "1 second",
|
|
562
|
+
other: "{{count}} seconds",
|
|
563
|
+
},
|
|
564
|
+
|
|
565
|
+
halfAMinute: "half a minute",
|
|
566
|
+
|
|
567
|
+
lessThanXMinutes: {
|
|
568
|
+
one: "less than a minute",
|
|
569
|
+
other: "less than {{count}} minutes",
|
|
570
|
+
},
|
|
571
|
+
|
|
572
|
+
xMinutes: {
|
|
573
|
+
one: "1 minute",
|
|
574
|
+
other: "{{count}} minutes",
|
|
575
|
+
},
|
|
576
|
+
|
|
577
|
+
aboutXHours: {
|
|
578
|
+
one: "about 1 hour",
|
|
579
|
+
other: "about {{count}} hours",
|
|
580
|
+
},
|
|
581
|
+
|
|
582
|
+
xHours: {
|
|
583
|
+
one: "1 hour",
|
|
584
|
+
other: "{{count}} hours",
|
|
585
|
+
},
|
|
586
|
+
|
|
587
|
+
xDays: {
|
|
588
|
+
one: "1 day",
|
|
589
|
+
other: "{{count}} days",
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
aboutXWeeks: {
|
|
593
|
+
one: "about 1 week",
|
|
594
|
+
other: "about {{count}} weeks",
|
|
595
|
+
},
|
|
596
|
+
|
|
597
|
+
xWeeks: {
|
|
598
|
+
one: "1 week",
|
|
599
|
+
other: "{{count}} weeks",
|
|
600
|
+
},
|
|
601
|
+
|
|
602
|
+
aboutXMonths: {
|
|
603
|
+
one: "about 1 month",
|
|
604
|
+
other: "about {{count}} months",
|
|
605
|
+
},
|
|
606
|
+
|
|
607
|
+
xMonths: {
|
|
608
|
+
one: "1 month",
|
|
609
|
+
other: "{{count}} months",
|
|
610
|
+
},
|
|
611
|
+
|
|
612
|
+
aboutXYears: {
|
|
613
|
+
one: "about 1 year",
|
|
614
|
+
other: "about {{count}} years",
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
xYears: {
|
|
618
|
+
one: "1 year",
|
|
619
|
+
other: "{{count}} years",
|
|
620
|
+
},
|
|
621
|
+
|
|
622
|
+
overXYears: {
|
|
623
|
+
one: "over 1 year",
|
|
624
|
+
other: "over {{count}} years",
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
almostXYears: {
|
|
628
|
+
one: "almost 1 year",
|
|
629
|
+
other: "almost {{count}} years",
|
|
630
|
+
},
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
const formatDistance$3 = (token, count, options) => {
|
|
634
|
+
let result;
|
|
635
|
+
|
|
636
|
+
const tokenValue = formatDistanceLocale$2[token];
|
|
637
|
+
if (typeof tokenValue === "string") {
|
|
638
|
+
result = tokenValue;
|
|
639
|
+
} else if (count === 1) {
|
|
640
|
+
result = tokenValue.one;
|
|
641
|
+
} else {
|
|
642
|
+
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (options?.addSuffix) {
|
|
646
|
+
if (options.comparison && options.comparison > 0) {
|
|
647
|
+
return "in " + result;
|
|
648
|
+
} else {
|
|
649
|
+
return result + " ago";
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
return result;
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
function buildFormatLongFn(args) {
|
|
657
|
+
return (options = {}) => {
|
|
658
|
+
// TODO: Remove String()
|
|
659
|
+
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
660
|
+
const format = args.formats[width] || args.formats[args.defaultWidth];
|
|
661
|
+
return format;
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const dateFormats$2 = {
|
|
666
|
+
full: "EEEE, MMMM do, y",
|
|
667
|
+
long: "MMMM do, y",
|
|
668
|
+
medium: "MMM d, y",
|
|
669
|
+
short: "MM/dd/yyyy",
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
const timeFormats$2 = {
|
|
673
|
+
full: "h:mm:ss a zzzz",
|
|
674
|
+
long: "h:mm:ss a z",
|
|
675
|
+
medium: "h:mm:ss a",
|
|
676
|
+
short: "h:mm a",
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
const dateTimeFormats$2 = {
|
|
680
|
+
full: "{{date}} 'at' {{time}}",
|
|
681
|
+
long: "{{date}} 'at' {{time}}",
|
|
682
|
+
medium: "{{date}}, {{time}}",
|
|
683
|
+
short: "{{date}}, {{time}}",
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
const formatLong$2 = {
|
|
687
|
+
date: buildFormatLongFn({
|
|
688
|
+
formats: dateFormats$2,
|
|
689
|
+
defaultWidth: "full",
|
|
690
|
+
}),
|
|
691
|
+
|
|
692
|
+
time: buildFormatLongFn({
|
|
693
|
+
formats: timeFormats$2,
|
|
694
|
+
defaultWidth: "full",
|
|
695
|
+
}),
|
|
696
|
+
|
|
697
|
+
dateTime: buildFormatLongFn({
|
|
698
|
+
formats: dateTimeFormats$2,
|
|
699
|
+
defaultWidth: "full",
|
|
700
|
+
}),
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
const formatRelativeLocale$2 = {
|
|
704
|
+
lastWeek: "'last' eeee 'at' p",
|
|
705
|
+
yesterday: "'yesterday at' p",
|
|
706
|
+
today: "'today at' p",
|
|
707
|
+
tomorrow: "'tomorrow at' p",
|
|
708
|
+
nextWeek: "eeee 'at' p",
|
|
709
|
+
other: "P",
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
const formatRelative$2 = (token, _date, _baseDate, _options) =>
|
|
713
|
+
formatRelativeLocale$2[token];
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* The localize function argument callback which allows to convert raw value to
|
|
717
|
+
* the actual type.
|
|
718
|
+
*
|
|
719
|
+
* @param value - The value to convert
|
|
720
|
+
*
|
|
721
|
+
* @returns The converted value
|
|
722
|
+
*/
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* The map of localized values for each width.
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* The index type of the locale unit value. It types conversion of units of
|
|
730
|
+
* values that don't start at 0 (i.e. quarters).
|
|
731
|
+
*/
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Converts the unit value to the tuple of values.
|
|
735
|
+
*/
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* The tuple of localized era values. The first element represents BC,
|
|
739
|
+
* the second element represents AD.
|
|
740
|
+
*/
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* The tuple of localized quarter values. The first element represents Q1.
|
|
744
|
+
*/
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* The tuple of localized day values. The first element represents Sunday.
|
|
748
|
+
*/
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* The tuple of localized month values. The first element represents January.
|
|
752
|
+
*/
|
|
753
|
+
|
|
754
|
+
function buildLocalizeFn(args) {
|
|
755
|
+
return (value, options) => {
|
|
756
|
+
const context = options?.context ? String(options.context) : "standalone";
|
|
757
|
+
|
|
758
|
+
let valuesArray;
|
|
759
|
+
if (context === "formatting" && args.formattingValues) {
|
|
760
|
+
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
761
|
+
const width = options?.width ? String(options.width) : defaultWidth;
|
|
762
|
+
|
|
763
|
+
valuesArray =
|
|
764
|
+
args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
765
|
+
} else {
|
|
766
|
+
const defaultWidth = args.defaultWidth;
|
|
767
|
+
const width = options?.width ? String(options.width) : args.defaultWidth;
|
|
768
|
+
|
|
769
|
+
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
770
|
+
}
|
|
771
|
+
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
772
|
+
|
|
773
|
+
// @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!
|
|
774
|
+
return valuesArray[index];
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const eraValues$2 = {
|
|
779
|
+
narrow: ["B", "A"],
|
|
780
|
+
abbreviated: ["BC", "AD"],
|
|
781
|
+
wide: ["Before Christ", "Anno Domini"],
|
|
782
|
+
};
|
|
783
|
+
|
|
784
|
+
const quarterValues$2 = {
|
|
785
|
+
narrow: ["1", "2", "3", "4"],
|
|
786
|
+
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
|
|
787
|
+
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"],
|
|
788
|
+
};
|
|
789
|
+
|
|
790
|
+
// Note: in English, the names of days of the week and months are capitalized.
|
|
791
|
+
// If you are making a new locale based on this one, check if the same is true for the language you're working on.
|
|
792
|
+
// Generally, formatted dates should look like they are in the middle of a sentence,
|
|
793
|
+
// e.g. in Spanish language the weekdays and months should be in the lowercase.
|
|
794
|
+
const monthValues$2 = {
|
|
795
|
+
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
|
|
796
|
+
abbreviated: [
|
|
797
|
+
"Jan",
|
|
798
|
+
"Feb",
|
|
799
|
+
"Mar",
|
|
800
|
+
"Apr",
|
|
801
|
+
"May",
|
|
802
|
+
"Jun",
|
|
803
|
+
"Jul",
|
|
804
|
+
"Aug",
|
|
805
|
+
"Sep",
|
|
806
|
+
"Oct",
|
|
807
|
+
"Nov",
|
|
808
|
+
"Dec",
|
|
809
|
+
],
|
|
810
|
+
|
|
811
|
+
wide: [
|
|
812
|
+
"January",
|
|
813
|
+
"February",
|
|
814
|
+
"March",
|
|
815
|
+
"April",
|
|
816
|
+
"May",
|
|
817
|
+
"June",
|
|
818
|
+
"July",
|
|
819
|
+
"August",
|
|
820
|
+
"September",
|
|
821
|
+
"October",
|
|
822
|
+
"November",
|
|
823
|
+
"December",
|
|
824
|
+
],
|
|
825
|
+
};
|
|
826
|
+
|
|
827
|
+
const dayValues$2 = {
|
|
828
|
+
narrow: ["S", "M", "T", "W", "T", "F", "S"],
|
|
829
|
+
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
830
|
+
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
831
|
+
wide: [
|
|
832
|
+
"Sunday",
|
|
833
|
+
"Monday",
|
|
834
|
+
"Tuesday",
|
|
835
|
+
"Wednesday",
|
|
836
|
+
"Thursday",
|
|
837
|
+
"Friday",
|
|
838
|
+
"Saturday",
|
|
839
|
+
],
|
|
840
|
+
};
|
|
841
|
+
|
|
842
|
+
const dayPeriodValues$2 = {
|
|
843
|
+
narrow: {
|
|
844
|
+
am: "a",
|
|
845
|
+
pm: "p",
|
|
846
|
+
midnight: "mi",
|
|
847
|
+
noon: "n",
|
|
848
|
+
morning: "morning",
|
|
849
|
+
afternoon: "afternoon",
|
|
850
|
+
evening: "evening",
|
|
851
|
+
night: "night",
|
|
852
|
+
},
|
|
853
|
+
abbreviated: {
|
|
854
|
+
am: "AM",
|
|
855
|
+
pm: "PM",
|
|
856
|
+
midnight: "midnight",
|
|
857
|
+
noon: "noon",
|
|
858
|
+
morning: "morning",
|
|
859
|
+
afternoon: "afternoon",
|
|
860
|
+
evening: "evening",
|
|
861
|
+
night: "night",
|
|
862
|
+
},
|
|
863
|
+
wide: {
|
|
864
|
+
am: "a.m.",
|
|
865
|
+
pm: "p.m.",
|
|
866
|
+
midnight: "midnight",
|
|
867
|
+
noon: "noon",
|
|
868
|
+
morning: "morning",
|
|
869
|
+
afternoon: "afternoon",
|
|
870
|
+
evening: "evening",
|
|
871
|
+
night: "night",
|
|
872
|
+
},
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
const formattingDayPeriodValues$2 = {
|
|
876
|
+
narrow: {
|
|
877
|
+
am: "a",
|
|
878
|
+
pm: "p",
|
|
879
|
+
midnight: "mi",
|
|
880
|
+
noon: "n",
|
|
881
|
+
morning: "in the morning",
|
|
882
|
+
afternoon: "in the afternoon",
|
|
883
|
+
evening: "in the evening",
|
|
884
|
+
night: "at night",
|
|
885
|
+
},
|
|
886
|
+
abbreviated: {
|
|
887
|
+
am: "AM",
|
|
888
|
+
pm: "PM",
|
|
889
|
+
midnight: "midnight",
|
|
890
|
+
noon: "noon",
|
|
891
|
+
morning: "in the morning",
|
|
892
|
+
afternoon: "in the afternoon",
|
|
893
|
+
evening: "in the evening",
|
|
894
|
+
night: "at night",
|
|
895
|
+
},
|
|
896
|
+
wide: {
|
|
897
|
+
am: "a.m.",
|
|
898
|
+
pm: "p.m.",
|
|
899
|
+
midnight: "midnight",
|
|
900
|
+
noon: "noon",
|
|
901
|
+
morning: "in the morning",
|
|
902
|
+
afternoon: "in the afternoon",
|
|
903
|
+
evening: "in the evening",
|
|
904
|
+
night: "at night",
|
|
905
|
+
},
|
|
906
|
+
};
|
|
907
|
+
|
|
908
|
+
const ordinalNumber$2 = (dirtyNumber, _options) => {
|
|
909
|
+
const number = Number(dirtyNumber);
|
|
910
|
+
|
|
911
|
+
// If ordinal numbers depend on context, for example,
|
|
912
|
+
// if they are different for different grammatical genders,
|
|
913
|
+
// use `options.unit`.
|
|
914
|
+
//
|
|
915
|
+
// `unit` can be 'year', 'quarter', 'month', 'week', 'date', 'dayOfYear',
|
|
916
|
+
// 'day', 'hour', 'minute', 'second'.
|
|
917
|
+
|
|
918
|
+
const rem100 = number % 100;
|
|
919
|
+
if (rem100 > 20 || rem100 < 10) {
|
|
920
|
+
switch (rem100 % 10) {
|
|
921
|
+
case 1:
|
|
922
|
+
return number + "st";
|
|
923
|
+
case 2:
|
|
924
|
+
return number + "nd";
|
|
925
|
+
case 3:
|
|
926
|
+
return number + "rd";
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
return number + "th";
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
const localize$2 = {
|
|
933
|
+
ordinalNumber: ordinalNumber$2,
|
|
934
|
+
|
|
935
|
+
era: buildLocalizeFn({
|
|
936
|
+
values: eraValues$2,
|
|
937
|
+
defaultWidth: "wide",
|
|
938
|
+
}),
|
|
939
|
+
|
|
940
|
+
quarter: buildLocalizeFn({
|
|
941
|
+
values: quarterValues$2,
|
|
942
|
+
defaultWidth: "wide",
|
|
943
|
+
argumentCallback: (quarter) => quarter - 1,
|
|
944
|
+
}),
|
|
945
|
+
|
|
946
|
+
month: buildLocalizeFn({
|
|
947
|
+
values: monthValues$2,
|
|
948
|
+
defaultWidth: "wide",
|
|
949
|
+
}),
|
|
950
|
+
|
|
951
|
+
day: buildLocalizeFn({
|
|
952
|
+
values: dayValues$2,
|
|
953
|
+
defaultWidth: "wide",
|
|
954
|
+
}),
|
|
955
|
+
|
|
956
|
+
dayPeriod: buildLocalizeFn({
|
|
957
|
+
values: dayPeriodValues$2,
|
|
958
|
+
defaultWidth: "wide",
|
|
959
|
+
formattingValues: formattingDayPeriodValues$2,
|
|
960
|
+
defaultFormattingWidth: "wide",
|
|
961
|
+
}),
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
function buildMatchFn(args) {
|
|
965
|
+
return (string, options = {}) => {
|
|
966
|
+
const width = options.width;
|
|
967
|
+
|
|
968
|
+
const matchPattern =
|
|
969
|
+
(width && args.matchPatterns[width]) ||
|
|
970
|
+
args.matchPatterns[args.defaultMatchWidth];
|
|
971
|
+
const matchResult = string.match(matchPattern);
|
|
972
|
+
|
|
973
|
+
if (!matchResult) {
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
const matchedString = matchResult[0];
|
|
977
|
+
|
|
978
|
+
const parsePatterns =
|
|
979
|
+
(width && args.parsePatterns[width]) ||
|
|
980
|
+
args.parsePatterns[args.defaultParseWidth];
|
|
981
|
+
|
|
982
|
+
const key = Array.isArray(parsePatterns)
|
|
983
|
+
? findIndex(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
984
|
+
: // [TODO] -- I challenge you to fix the type
|
|
985
|
+
findKey(parsePatterns, (pattern) => pattern.test(matchedString));
|
|
986
|
+
|
|
987
|
+
let value;
|
|
988
|
+
|
|
989
|
+
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
990
|
+
value = options.valueCallback
|
|
991
|
+
? // [TODO] -- I challenge you to fix the type
|
|
992
|
+
options.valueCallback(value)
|
|
993
|
+
: value;
|
|
994
|
+
|
|
995
|
+
const rest = string.slice(matchedString.length);
|
|
996
|
+
|
|
997
|
+
return { value, rest };
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
function findKey(object, predicate) {
|
|
1002
|
+
for (const key in object) {
|
|
1003
|
+
if (
|
|
1004
|
+
Object.prototype.hasOwnProperty.call(object, key) &&
|
|
1005
|
+
predicate(object[key])
|
|
1006
|
+
) {
|
|
1007
|
+
return key;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
return undefined;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
function findIndex(array, predicate) {
|
|
1014
|
+
for (let key = 0; key < array.length; key++) {
|
|
1015
|
+
if (predicate(array[key])) {
|
|
1016
|
+
return key;
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
return undefined;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
function buildMatchPatternFn(args) {
|
|
1023
|
+
return (string, options = {}) => {
|
|
1024
|
+
const matchResult = string.match(args.matchPattern);
|
|
1025
|
+
if (!matchResult) return null;
|
|
1026
|
+
const matchedString = matchResult[0];
|
|
1027
|
+
|
|
1028
|
+
const parseResult = string.match(args.parsePattern);
|
|
1029
|
+
if (!parseResult) return null;
|
|
1030
|
+
let value = args.valueCallback
|
|
1031
|
+
? args.valueCallback(parseResult[0])
|
|
1032
|
+
: parseResult[0];
|
|
1033
|
+
|
|
1034
|
+
// [TODO] I challenge you to fix the type
|
|
1035
|
+
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
1036
|
+
|
|
1037
|
+
const rest = string.slice(matchedString.length);
|
|
1038
|
+
|
|
1039
|
+
return { value, rest };
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
const matchOrdinalNumberPattern$2 = /^(\d+)(th|st|nd|rd)?/i;
|
|
1044
|
+
const parseOrdinalNumberPattern$2 = /\d+/i;
|
|
1045
|
+
|
|
1046
|
+
const matchEraPatterns$2 = {
|
|
1047
|
+
narrow: /^(b|a)/i,
|
|
1048
|
+
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
1049
|
+
wide: /^(before christ|before common era|anno domini|common era)/i,
|
|
1050
|
+
};
|
|
1051
|
+
const parseEraPatterns$2 = {
|
|
1052
|
+
any: [/^b/i, /^(a|c)/i],
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
const matchQuarterPatterns$2 = {
|
|
1056
|
+
narrow: /^[1234]/i,
|
|
1057
|
+
abbreviated: /^q[1234]/i,
|
|
1058
|
+
wide: /^[1234](th|st|nd|rd)? quarter/i,
|
|
1059
|
+
};
|
|
1060
|
+
const parseQuarterPatterns$2 = {
|
|
1061
|
+
any: [/1/i, /2/i, /3/i, /4/i],
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const matchMonthPatterns$2 = {
|
|
1065
|
+
narrow: /^[jfmasond]/i,
|
|
1066
|
+
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
1067
|
+
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i,
|
|
1068
|
+
};
|
|
1069
|
+
const parseMonthPatterns$2 = {
|
|
1070
|
+
narrow: [
|
|
1071
|
+
/^j/i,
|
|
1072
|
+
/^f/i,
|
|
1073
|
+
/^m/i,
|
|
1074
|
+
/^a/i,
|
|
1075
|
+
/^m/i,
|
|
1076
|
+
/^j/i,
|
|
1077
|
+
/^j/i,
|
|
1078
|
+
/^a/i,
|
|
1079
|
+
/^s/i,
|
|
1080
|
+
/^o/i,
|
|
1081
|
+
/^n/i,
|
|
1082
|
+
/^d/i,
|
|
1083
|
+
],
|
|
1084
|
+
|
|
1085
|
+
any: [
|
|
1086
|
+
/^ja/i,
|
|
1087
|
+
/^f/i,
|
|
1088
|
+
/^mar/i,
|
|
1089
|
+
/^ap/i,
|
|
1090
|
+
/^may/i,
|
|
1091
|
+
/^jun/i,
|
|
1092
|
+
/^jul/i,
|
|
1093
|
+
/^au/i,
|
|
1094
|
+
/^s/i,
|
|
1095
|
+
/^o/i,
|
|
1096
|
+
/^n/i,
|
|
1097
|
+
/^d/i,
|
|
1098
|
+
],
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
const matchDayPatterns$2 = {
|
|
1102
|
+
narrow: /^[smtwf]/i,
|
|
1103
|
+
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
1104
|
+
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
1105
|
+
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i,
|
|
1106
|
+
};
|
|
1107
|
+
const parseDayPatterns$2 = {
|
|
1108
|
+
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
1109
|
+
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i],
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
const matchDayPeriodPatterns$2 = {
|
|
1113
|
+
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
1114
|
+
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i,
|
|
1115
|
+
};
|
|
1116
|
+
const parseDayPeriodPatterns$2 = {
|
|
1117
|
+
any: {
|
|
1118
|
+
am: /^a/i,
|
|
1119
|
+
pm: /^p/i,
|
|
1120
|
+
midnight: /^mi/i,
|
|
1121
|
+
noon: /^no/i,
|
|
1122
|
+
morning: /morning/i,
|
|
1123
|
+
afternoon: /afternoon/i,
|
|
1124
|
+
evening: /evening/i,
|
|
1125
|
+
night: /night/i,
|
|
1126
|
+
},
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
const match$2 = {
|
|
1130
|
+
ordinalNumber: buildMatchPatternFn({
|
|
1131
|
+
matchPattern: matchOrdinalNumberPattern$2,
|
|
1132
|
+
parsePattern: parseOrdinalNumberPattern$2,
|
|
1133
|
+
valueCallback: (value) => parseInt(value, 10),
|
|
1134
|
+
}),
|
|
1135
|
+
|
|
1136
|
+
era: buildMatchFn({
|
|
1137
|
+
matchPatterns: matchEraPatterns$2,
|
|
1138
|
+
defaultMatchWidth: "wide",
|
|
1139
|
+
parsePatterns: parseEraPatterns$2,
|
|
1140
|
+
defaultParseWidth: "any",
|
|
1141
|
+
}),
|
|
1142
|
+
|
|
1143
|
+
quarter: buildMatchFn({
|
|
1144
|
+
matchPatterns: matchQuarterPatterns$2,
|
|
1145
|
+
defaultMatchWidth: "wide",
|
|
1146
|
+
parsePatterns: parseQuarterPatterns$2,
|
|
1147
|
+
defaultParseWidth: "any",
|
|
1148
|
+
valueCallback: (index) => index + 1,
|
|
1149
|
+
}),
|
|
1150
|
+
|
|
1151
|
+
month: buildMatchFn({
|
|
1152
|
+
matchPatterns: matchMonthPatterns$2,
|
|
1153
|
+
defaultMatchWidth: "wide",
|
|
1154
|
+
parsePatterns: parseMonthPatterns$2,
|
|
1155
|
+
defaultParseWidth: "any",
|
|
1156
|
+
}),
|
|
1157
|
+
|
|
1158
|
+
day: buildMatchFn({
|
|
1159
|
+
matchPatterns: matchDayPatterns$2,
|
|
1160
|
+
defaultMatchWidth: "wide",
|
|
1161
|
+
parsePatterns: parseDayPatterns$2,
|
|
1162
|
+
defaultParseWidth: "any",
|
|
1163
|
+
}),
|
|
1164
|
+
|
|
1165
|
+
dayPeriod: buildMatchFn({
|
|
1166
|
+
matchPatterns: matchDayPeriodPatterns$2,
|
|
1167
|
+
defaultMatchWidth: "any",
|
|
1168
|
+
parsePatterns: parseDayPeriodPatterns$2,
|
|
1169
|
+
defaultParseWidth: "any",
|
|
1170
|
+
}),
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
/**
|
|
1174
|
+
* @category Locales
|
|
1175
|
+
* @summary English locale (United States).
|
|
1176
|
+
* @language English
|
|
1177
|
+
* @iso-639-2 eng
|
|
1178
|
+
* @author Sasha Koss [@kossnocorp](https://github.com/kossnocorp)
|
|
1179
|
+
* @author Lesha Koss [@leshakoss](https://github.com/leshakoss)
|
|
1180
|
+
*/
|
|
1181
|
+
const enUS = {
|
|
1182
|
+
code: "en-US",
|
|
1183
|
+
formatDistance: formatDistance$3,
|
|
1184
|
+
formatLong: formatLong$2,
|
|
1185
|
+
formatRelative: formatRelative$2,
|
|
1186
|
+
localize: localize$2,
|
|
1187
|
+
match: match$2,
|
|
1188
|
+
options: {
|
|
1189
|
+
weekStartsOn: 0 /* Sunday */,
|
|
1190
|
+
firstWeekContainsDate: 1,
|
|
1191
|
+
},
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1194
|
+
/**
|
|
1195
|
+
* The {@link formatDistance} function options.
|
|
1196
|
+
*/
|
|
1197
|
+
|
|
1198
|
+
/**
|
|
1199
|
+
* @name formatDistance
|
|
1200
|
+
* @category Common Helpers
|
|
1201
|
+
* @summary Return the distance between the given dates in words.
|
|
1202
|
+
*
|
|
1203
|
+
* @description
|
|
1204
|
+
* Return the distance between the given dates in words.
|
|
1205
|
+
*
|
|
1206
|
+
* | Distance between dates | Result |
|
|
1207
|
+
* |-------------------------------------------------------------------|---------------------|
|
|
1208
|
+
* | 0 ... 30 secs | less than a minute |
|
|
1209
|
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
|
1210
|
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
|
1211
|
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
|
1212
|
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
|
1213
|
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
|
1214
|
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
|
1215
|
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
|
1216
|
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
|
1217
|
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
|
1218
|
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
|
1219
|
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
|
1220
|
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
|
1221
|
+
* | N yrs ... N yrs 3 months | about N years |
|
|
1222
|
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
|
1223
|
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
|
1224
|
+
*
|
|
1225
|
+
* With `options.includeSeconds == true`:
|
|
1226
|
+
* | Distance between dates | Result |
|
|
1227
|
+
* |------------------------|----------------------|
|
|
1228
|
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
|
1229
|
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
|
1230
|
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
|
1231
|
+
* | 20 secs ... 40 secs | half a minute |
|
|
1232
|
+
* | 40 secs ... 60 secs | less than a minute |
|
|
1233
|
+
* | 60 secs ... 90 secs | 1 minute |
|
|
1234
|
+
*
|
|
1235
|
+
* @param laterDate - The date
|
|
1236
|
+
* @param earlierDate - The date to compare with
|
|
1237
|
+
* @param options - An object with options
|
|
1238
|
+
*
|
|
1239
|
+
* @returns The distance in words
|
|
1240
|
+
*
|
|
1241
|
+
* @throws `date` must not be Invalid Date
|
|
1242
|
+
* @throws `baseDate` must not be Invalid Date
|
|
1243
|
+
* @throws `options.locale` must contain `formatDistance` property
|
|
1244
|
+
*
|
|
1245
|
+
* @example
|
|
1246
|
+
* // What is the distance between 2 July 2014 and 1 January 2015?
|
|
1247
|
+
* const result = formatDistance(new Date(2014, 6, 2), new Date(2015, 0, 1))
|
|
1248
|
+
* //=> '6 months'
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* // What is the distance between 1 January 2015 00:00:15
|
|
1252
|
+
* // and 1 January 2015 00:00:00, including seconds?
|
|
1253
|
+
* const result = formatDistance(
|
|
1254
|
+
* new Date(2015, 0, 1, 0, 0, 15),
|
|
1255
|
+
* new Date(2015, 0, 1, 0, 0, 0),
|
|
1256
|
+
* { includeSeconds: true }
|
|
1257
|
+
* )
|
|
1258
|
+
* //=> 'less than 20 seconds'
|
|
1259
|
+
*
|
|
1260
|
+
* @example
|
|
1261
|
+
* // What is the distance from 1 January 2016
|
|
1262
|
+
* // to 1 January 2015, with a suffix?
|
|
1263
|
+
* const result = formatDistance(new Date(2015, 0, 1), new Date(2016, 0, 1), {
|
|
1264
|
+
* addSuffix: true
|
|
1265
|
+
* })
|
|
1266
|
+
* //=> 'about 1 year ago'
|
|
1267
|
+
*
|
|
1268
|
+
* @example
|
|
1269
|
+
* // What is the distance between 1 August 2016 and 1 January 2015 in Esperanto?
|
|
1270
|
+
* import { eoLocale } from 'date-fns/locale/eo'
|
|
1271
|
+
* const result = formatDistance(new Date(2016, 7, 1), new Date(2015, 0, 1), {
|
|
1272
|
+
* locale: eoLocale
|
|
1273
|
+
* })
|
|
1274
|
+
* //=> 'pli ol 1 jaro'
|
|
1275
|
+
*/
|
|
1276
|
+
function formatDistance$2(laterDate, earlierDate, options) {
|
|
1277
|
+
const defaultOptions = getDefaultOptions();
|
|
1278
|
+
const locale = options?.locale ?? defaultOptions.locale ?? enUS;
|
|
1279
|
+
const minutesInAlmostTwoDays = 2520;
|
|
1280
|
+
|
|
1281
|
+
const comparison = compareAsc(laterDate, earlierDate);
|
|
1282
|
+
|
|
1283
|
+
if (isNaN(comparison)) throw new RangeError("Invalid time value");
|
|
1284
|
+
|
|
1285
|
+
const localizeOptions = Object.assign({}, options, {
|
|
1286
|
+
addSuffix: options?.addSuffix,
|
|
1287
|
+
comparison: comparison,
|
|
1288
|
+
});
|
|
1289
|
+
|
|
1290
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
1291
|
+
options?.in,
|
|
1292
|
+
...(comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]),
|
|
1293
|
+
);
|
|
1294
|
+
|
|
1295
|
+
const seconds = differenceInSeconds(earlierDate_, laterDate_);
|
|
1296
|
+
const offsetInSeconds =
|
|
1297
|
+
(getTimezoneOffsetInMilliseconds(earlierDate_) -
|
|
1298
|
+
getTimezoneOffsetInMilliseconds(laterDate_)) /
|
|
1299
|
+
1000;
|
|
1300
|
+
const minutes = Math.round((seconds - offsetInSeconds) / 60);
|
|
1301
|
+
let months;
|
|
1302
|
+
|
|
1303
|
+
// 0 up to 2 mins
|
|
1304
|
+
if (minutes < 2) {
|
|
1305
|
+
if (options?.includeSeconds) {
|
|
1306
|
+
if (seconds < 5) {
|
|
1307
|
+
return locale.formatDistance("lessThanXSeconds", 5, localizeOptions);
|
|
1308
|
+
} else if (seconds < 10) {
|
|
1309
|
+
return locale.formatDistance("lessThanXSeconds", 10, localizeOptions);
|
|
1310
|
+
} else if (seconds < 20) {
|
|
1311
|
+
return locale.formatDistance("lessThanXSeconds", 20, localizeOptions);
|
|
1312
|
+
} else if (seconds < 40) {
|
|
1313
|
+
return locale.formatDistance("halfAMinute", 0, localizeOptions);
|
|
1314
|
+
} else if (seconds < 60) {
|
|
1315
|
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
|
1316
|
+
} else {
|
|
1317
|
+
return locale.formatDistance("xMinutes", 1, localizeOptions);
|
|
1318
|
+
}
|
|
1319
|
+
} else {
|
|
1320
|
+
if (minutes === 0) {
|
|
1321
|
+
return locale.formatDistance("lessThanXMinutes", 1, localizeOptions);
|
|
1322
|
+
} else {
|
|
1323
|
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// 2 mins up to 0.75 hrs
|
|
1328
|
+
} else if (minutes < 45) {
|
|
1329
|
+
return locale.formatDistance("xMinutes", minutes, localizeOptions);
|
|
1330
|
+
|
|
1331
|
+
// 0.75 hrs up to 1.5 hrs
|
|
1332
|
+
} else if (minutes < 90) {
|
|
1333
|
+
return locale.formatDistance("aboutXHours", 1, localizeOptions);
|
|
1334
|
+
|
|
1335
|
+
// 1.5 hrs up to 24 hrs
|
|
1336
|
+
} else if (minutes < minutesInDay) {
|
|
1337
|
+
const hours = Math.round(minutes / 60);
|
|
1338
|
+
return locale.formatDistance("aboutXHours", hours, localizeOptions);
|
|
1339
|
+
|
|
1340
|
+
// 1 day up to 1.75 days
|
|
1341
|
+
} else if (minutes < minutesInAlmostTwoDays) {
|
|
1342
|
+
return locale.formatDistance("xDays", 1, localizeOptions);
|
|
1343
|
+
|
|
1344
|
+
// 1.75 days up to 30 days
|
|
1345
|
+
} else if (minutes < minutesInMonth) {
|
|
1346
|
+
const days = Math.round(minutes / minutesInDay);
|
|
1347
|
+
return locale.formatDistance("xDays", days, localizeOptions);
|
|
1348
|
+
|
|
1349
|
+
// 1 month up to 2 months
|
|
1350
|
+
} else if (minutes < minutesInMonth * 2) {
|
|
1351
|
+
months = Math.round(minutes / minutesInMonth);
|
|
1352
|
+
return locale.formatDistance("aboutXMonths", months, localizeOptions);
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1355
|
+
months = differenceInMonths(earlierDate_, laterDate_);
|
|
1356
|
+
|
|
1357
|
+
// 2 months up to 12 months
|
|
1358
|
+
if (months < 12) {
|
|
1359
|
+
const nearestMonth = Math.round(minutes / minutesInMonth);
|
|
1360
|
+
return locale.formatDistance("xMonths", nearestMonth, localizeOptions);
|
|
1361
|
+
|
|
1362
|
+
// 1 year up to max Date
|
|
1363
|
+
} else {
|
|
1364
|
+
const monthsSinceStartOfYear = months % 12;
|
|
1365
|
+
const years = Math.trunc(months / 12);
|
|
1366
|
+
|
|
1367
|
+
// N years up to 1 years 3 months
|
|
1368
|
+
if (monthsSinceStartOfYear < 3) {
|
|
1369
|
+
return locale.formatDistance("aboutXYears", years, localizeOptions);
|
|
1370
|
+
|
|
1371
|
+
// N years 3 months up to N years 9 months
|
|
1372
|
+
} else if (monthsSinceStartOfYear < 9) {
|
|
1373
|
+
return locale.formatDistance("overXYears", years, localizeOptions);
|
|
1374
|
+
|
|
1375
|
+
// N years 9 months up to N year 12 months
|
|
1376
|
+
} else {
|
|
1377
|
+
return locale.formatDistance("almostXYears", years + 1, localizeOptions);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* The {@link formatDistanceToNow} function options.
|
|
1384
|
+
*/
|
|
1385
|
+
|
|
1386
|
+
/**
|
|
1387
|
+
* @name formatDistanceToNow
|
|
1388
|
+
* @category Common Helpers
|
|
1389
|
+
* @summary Return the distance between the given date and now in words.
|
|
1390
|
+
* @pure false
|
|
1391
|
+
*
|
|
1392
|
+
* @description
|
|
1393
|
+
* Return the distance between the given date and now in words.
|
|
1394
|
+
*
|
|
1395
|
+
* | Distance to now | Result |
|
|
1396
|
+
* |-------------------------------------------------------------------|---------------------|
|
|
1397
|
+
* | 0 ... 30 secs | less than a minute |
|
|
1398
|
+
* | 30 secs ... 1 min 30 secs | 1 minute |
|
|
1399
|
+
* | 1 min 30 secs ... 44 mins 30 secs | [2..44] minutes |
|
|
1400
|
+
* | 44 mins ... 30 secs ... 89 mins 30 secs | about 1 hour |
|
|
1401
|
+
* | 89 mins 30 secs ... 23 hrs 59 mins 30 secs | about [2..24] hours |
|
|
1402
|
+
* | 23 hrs 59 mins 30 secs ... 41 hrs 59 mins 30 secs | 1 day |
|
|
1403
|
+
* | 41 hrs 59 mins 30 secs ... 29 days 23 hrs 59 mins 30 secs | [2..30] days |
|
|
1404
|
+
* | 29 days 23 hrs 59 mins 30 secs ... 44 days 23 hrs 59 mins 30 secs | about 1 month |
|
|
1405
|
+
* | 44 days 23 hrs 59 mins 30 secs ... 59 days 23 hrs 59 mins 30 secs | about 2 months |
|
|
1406
|
+
* | 59 days 23 hrs 59 mins 30 secs ... 1 yr | [2..12] months |
|
|
1407
|
+
* | 1 yr ... 1 yr 3 months | about 1 year |
|
|
1408
|
+
* | 1 yr 3 months ... 1 yr 9 month s | over 1 year |
|
|
1409
|
+
* | 1 yr 9 months ... 2 yrs | almost 2 years |
|
|
1410
|
+
* | N yrs ... N yrs 3 months | about N years |
|
|
1411
|
+
* | N yrs 3 months ... N yrs 9 months | over N years |
|
|
1412
|
+
* | N yrs 9 months ... N+1 yrs | almost N+1 years |
|
|
1413
|
+
*
|
|
1414
|
+
* With `options.includeSeconds == true`:
|
|
1415
|
+
* | Distance to now | Result |
|
|
1416
|
+
* |---------------------|----------------------|
|
|
1417
|
+
* | 0 secs ... 5 secs | less than 5 seconds |
|
|
1418
|
+
* | 5 secs ... 10 secs | less than 10 seconds |
|
|
1419
|
+
* | 10 secs ... 20 secs | less than 20 seconds |
|
|
1420
|
+
* | 20 secs ... 40 secs | half a minute |
|
|
1421
|
+
* | 40 secs ... 60 secs | less than a minute |
|
|
1422
|
+
* | 60 secs ... 90 secs | 1 minute |
|
|
1423
|
+
*
|
|
1424
|
+
* @param date - The given date
|
|
1425
|
+
* @param options - The object with options
|
|
1426
|
+
*
|
|
1427
|
+
* @returns The distance in words
|
|
1428
|
+
*
|
|
1429
|
+
* @throws `date` must not be Invalid Date
|
|
1430
|
+
* @throws `options.locale` must contain `formatDistance` property
|
|
1431
|
+
*
|
|
1432
|
+
* @example
|
|
1433
|
+
* // If today is 1 January 2015, what is the distance to 2 July 2014?
|
|
1434
|
+
* const result = formatDistanceToNow(
|
|
1435
|
+
* new Date(2014, 6, 2)
|
|
1436
|
+
* )
|
|
1437
|
+
* //=> '6 months'
|
|
1438
|
+
*
|
|
1439
|
+
* @example
|
|
1440
|
+
* // If now is 1 January 2015 00:00:00,
|
|
1441
|
+
* // what is the distance to 1 January 2015 00:00:15, including seconds?
|
|
1442
|
+
* const result = formatDistanceToNow(
|
|
1443
|
+
* new Date(2015, 0, 1, 0, 0, 15),
|
|
1444
|
+
* {includeSeconds: true}
|
|
1445
|
+
* )
|
|
1446
|
+
* //=> 'less than 20 seconds'
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* // If today is 1 January 2015,
|
|
1450
|
+
* // what is the distance to 1 January 2016, with a suffix?
|
|
1451
|
+
* const result = formatDistanceToNow(
|
|
1452
|
+
* new Date(2016, 0, 1),
|
|
1453
|
+
* {addSuffix: true}
|
|
1454
|
+
* )
|
|
1455
|
+
* //=> 'in about 1 year'
|
|
1456
|
+
*
|
|
1457
|
+
* @example
|
|
1458
|
+
* // If today is 1 January 2015,
|
|
1459
|
+
* // what is the distance to 1 August 2016 in Esperanto?
|
|
1460
|
+
* const eoLocale = require('date-fns/locale/eo')
|
|
1461
|
+
* const result = formatDistanceToNow(
|
|
1462
|
+
* new Date(2016, 7, 1),
|
|
1463
|
+
* {locale: eoLocale}
|
|
1464
|
+
* )
|
|
1465
|
+
* //=> 'pli ol 1 jaro'
|
|
1466
|
+
*/
|
|
1467
|
+
function formatDistanceToNow(date, options) {
|
|
1468
|
+
return formatDistance$2(date, constructNow(date), options);
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
/**
|
|
1472
|
+
* The {@link isSameWeek} function options.
|
|
1473
|
+
*/
|
|
1474
|
+
|
|
1475
|
+
/**
|
|
1476
|
+
* @name isSameWeek
|
|
1477
|
+
* @category Week Helpers
|
|
1478
|
+
* @summary Are the given dates in the same week (and month and year)?
|
|
1479
|
+
*
|
|
1480
|
+
* @description
|
|
1481
|
+
* Are the given dates in the same week (and month and year)?
|
|
1482
|
+
*
|
|
1483
|
+
* @param laterDate - The first date to check
|
|
1484
|
+
* @param earlierDate - The second date to check
|
|
1485
|
+
* @param options - An object with options
|
|
1486
|
+
*
|
|
1487
|
+
* @returns The dates are in the same week (and month and year)
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* // Are 31 August 2014 and 4 September 2014 in the same week?
|
|
1491
|
+
* const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4))
|
|
1492
|
+
* //=> true
|
|
1493
|
+
*
|
|
1494
|
+
* @example
|
|
1495
|
+
* // If week starts with Monday,
|
|
1496
|
+
* // are 31 August 2014 and 4 September 2014 in the same week?
|
|
1497
|
+
* const result = isSameWeek(new Date(2014, 7, 31), new Date(2014, 8, 4), {
|
|
1498
|
+
* weekStartsOn: 1
|
|
1499
|
+
* })
|
|
1500
|
+
* //=> false
|
|
1501
|
+
*
|
|
1502
|
+
* @example
|
|
1503
|
+
* // Are 1 January 2014 and 1 January 2015 in the same week?
|
|
1504
|
+
* const result = isSameWeek(new Date(2014, 0, 1), new Date(2015, 0, 1))
|
|
1505
|
+
* //=> false
|
|
1506
|
+
*/
|
|
1507
|
+
function isSameWeek(laterDate, earlierDate, options) {
|
|
1508
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
1509
|
+
options?.in,
|
|
1510
|
+
laterDate,
|
|
1511
|
+
earlierDate,
|
|
1512
|
+
);
|
|
1513
|
+
return (
|
|
1514
|
+
+startOfWeek(laterDate_, options) === +startOfWeek(earlierDate_, options)
|
|
1515
|
+
);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
const formatDistanceLocale$1 = {
|
|
1519
|
+
lessThanXSeconds: {
|
|
1520
|
+
one: "1秒未満",
|
|
1521
|
+
other: "{{count}}秒未満",
|
|
1522
|
+
oneWithSuffix: "約1秒",
|
|
1523
|
+
otherWithSuffix: "約{{count}}秒",
|
|
1524
|
+
},
|
|
1525
|
+
|
|
1526
|
+
xSeconds: {
|
|
1527
|
+
one: "1秒",
|
|
1528
|
+
other: "{{count}}秒",
|
|
1529
|
+
},
|
|
1530
|
+
|
|
1531
|
+
halfAMinute: "30秒",
|
|
1532
|
+
|
|
1533
|
+
lessThanXMinutes: {
|
|
1534
|
+
one: "1分未満",
|
|
1535
|
+
other: "{{count}}分未満",
|
|
1536
|
+
oneWithSuffix: "約1分",
|
|
1537
|
+
otherWithSuffix: "約{{count}}分",
|
|
1538
|
+
},
|
|
1539
|
+
|
|
1540
|
+
xMinutes: {
|
|
1541
|
+
one: "1分",
|
|
1542
|
+
other: "{{count}}分",
|
|
1543
|
+
},
|
|
1544
|
+
|
|
1545
|
+
aboutXHours: {
|
|
1546
|
+
one: "約1時間",
|
|
1547
|
+
other: "約{{count}}時間",
|
|
1548
|
+
},
|
|
1549
|
+
|
|
1550
|
+
xHours: {
|
|
1551
|
+
one: "1時間",
|
|
1552
|
+
other: "{{count}}時間",
|
|
1553
|
+
},
|
|
1554
|
+
|
|
1555
|
+
xDays: {
|
|
1556
|
+
one: "1日",
|
|
1557
|
+
other: "{{count}}日",
|
|
1558
|
+
},
|
|
1559
|
+
|
|
1560
|
+
aboutXWeeks: {
|
|
1561
|
+
one: "約1週間",
|
|
1562
|
+
other: "約{{count}}週間",
|
|
1563
|
+
},
|
|
1564
|
+
|
|
1565
|
+
xWeeks: {
|
|
1566
|
+
one: "1週間",
|
|
1567
|
+
other: "{{count}}週間",
|
|
1568
|
+
},
|
|
1569
|
+
|
|
1570
|
+
aboutXMonths: {
|
|
1571
|
+
one: "約1か月",
|
|
1572
|
+
other: "約{{count}}か月",
|
|
1573
|
+
},
|
|
1574
|
+
|
|
1575
|
+
xMonths: {
|
|
1576
|
+
one: "1か月",
|
|
1577
|
+
other: "{{count}}か月",
|
|
1578
|
+
},
|
|
1579
|
+
|
|
1580
|
+
aboutXYears: {
|
|
1581
|
+
one: "約1年",
|
|
1582
|
+
other: "約{{count}}年",
|
|
1583
|
+
},
|
|
1584
|
+
|
|
1585
|
+
xYears: {
|
|
1586
|
+
one: "1年",
|
|
1587
|
+
other: "{{count}}年",
|
|
1588
|
+
},
|
|
1589
|
+
|
|
1590
|
+
overXYears: {
|
|
1591
|
+
one: "1年以上",
|
|
1592
|
+
other: "{{count}}年以上",
|
|
1593
|
+
},
|
|
1594
|
+
|
|
1595
|
+
almostXYears: {
|
|
1596
|
+
one: "1年近く",
|
|
1597
|
+
other: "{{count}}年近く",
|
|
1598
|
+
},
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
const formatDistance$1 = (token, count, options) => {
|
|
1602
|
+
options = options || {};
|
|
1603
|
+
|
|
1604
|
+
let result;
|
|
1605
|
+
|
|
1606
|
+
const tokenValue = formatDistanceLocale$1[token];
|
|
1607
|
+
if (typeof tokenValue === "string") {
|
|
1608
|
+
result = tokenValue;
|
|
1609
|
+
} else if (count === 1) {
|
|
1610
|
+
if (options.addSuffix && tokenValue.oneWithSuffix) {
|
|
1611
|
+
result = tokenValue.oneWithSuffix;
|
|
1612
|
+
} else {
|
|
1613
|
+
result = tokenValue.one;
|
|
1614
|
+
}
|
|
1615
|
+
} else {
|
|
1616
|
+
if (options.addSuffix && tokenValue.otherWithSuffix) {
|
|
1617
|
+
result = tokenValue.otherWithSuffix.replace("{{count}}", String(count));
|
|
1618
|
+
} else {
|
|
1619
|
+
result = tokenValue.other.replace("{{count}}", String(count));
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
if (options.addSuffix) {
|
|
1624
|
+
if (options.comparison && options.comparison > 0) {
|
|
1625
|
+
return result + "後";
|
|
1626
|
+
} else {
|
|
1627
|
+
return result + "前";
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
return result;
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
const dateFormats$1 = {
|
|
1635
|
+
full: "y年M月d日EEEE",
|
|
1636
|
+
long: "y年M月d日",
|
|
1637
|
+
medium: "y/MM/dd",
|
|
1638
|
+
short: "y/MM/dd",
|
|
1639
|
+
};
|
|
1640
|
+
|
|
1641
|
+
const timeFormats$1 = {
|
|
1642
|
+
full: "H時mm分ss秒 zzzz",
|
|
1643
|
+
long: "H:mm:ss z",
|
|
1644
|
+
medium: "H:mm:ss",
|
|
1645
|
+
short: "H:mm",
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1648
|
+
const dateTimeFormats$1 = {
|
|
1649
|
+
full: "{{date}} {{time}}",
|
|
1650
|
+
long: "{{date}} {{time}}",
|
|
1651
|
+
medium: "{{date}} {{time}}",
|
|
1652
|
+
short: "{{date}} {{time}}",
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
const formatLong$1 = {
|
|
1656
|
+
date: buildFormatLongFn({
|
|
1657
|
+
formats: dateFormats$1,
|
|
1658
|
+
defaultWidth: "full",
|
|
1659
|
+
}),
|
|
1660
|
+
|
|
1661
|
+
time: buildFormatLongFn({
|
|
1662
|
+
formats: timeFormats$1,
|
|
1663
|
+
defaultWidth: "full",
|
|
1664
|
+
}),
|
|
1665
|
+
|
|
1666
|
+
dateTime: buildFormatLongFn({
|
|
1667
|
+
formats: dateTimeFormats$1,
|
|
1668
|
+
defaultWidth: "full",
|
|
1669
|
+
}),
|
|
1670
|
+
};
|
|
1671
|
+
|
|
1672
|
+
const formatRelativeLocale$1 = {
|
|
1673
|
+
lastWeek: "先週のeeeeのp",
|
|
1674
|
+
yesterday: "昨日のp",
|
|
1675
|
+
today: "今日のp",
|
|
1676
|
+
tomorrow: "明日のp",
|
|
1677
|
+
nextWeek: "翌週のeeeeのp",
|
|
1678
|
+
other: "P",
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
const formatRelative$1 = (token, _date, _baseDate, _options) => {
|
|
1682
|
+
return formatRelativeLocale$1[token];
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
const eraValues$1 = {
|
|
1686
|
+
narrow: ["BC", "AC"],
|
|
1687
|
+
abbreviated: ["紀元前", "西暦"],
|
|
1688
|
+
wide: ["紀元前", "西暦"],
|
|
1689
|
+
};
|
|
1690
|
+
|
|
1691
|
+
const quarterValues$1 = {
|
|
1692
|
+
narrow: ["1", "2", "3", "4"],
|
|
1693
|
+
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
|
|
1694
|
+
wide: ["第1四半期", "第2四半期", "第3四半期", "第4四半期"],
|
|
1695
|
+
};
|
|
1696
|
+
|
|
1697
|
+
const monthValues$1 = {
|
|
1698
|
+
narrow: ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"],
|
|
1699
|
+
|
|
1700
|
+
abbreviated: [
|
|
1701
|
+
"1月",
|
|
1702
|
+
"2月",
|
|
1703
|
+
"3月",
|
|
1704
|
+
"4月",
|
|
1705
|
+
"5月",
|
|
1706
|
+
"6月",
|
|
1707
|
+
"7月",
|
|
1708
|
+
"8月",
|
|
1709
|
+
"9月",
|
|
1710
|
+
"10月",
|
|
1711
|
+
"11月",
|
|
1712
|
+
"12月",
|
|
1713
|
+
],
|
|
1714
|
+
|
|
1715
|
+
wide: [
|
|
1716
|
+
"1月",
|
|
1717
|
+
"2月",
|
|
1718
|
+
"3月",
|
|
1719
|
+
"4月",
|
|
1720
|
+
"5月",
|
|
1721
|
+
"6月",
|
|
1722
|
+
"7月",
|
|
1723
|
+
"8月",
|
|
1724
|
+
"9月",
|
|
1725
|
+
"10月",
|
|
1726
|
+
"11月",
|
|
1727
|
+
"12月",
|
|
1728
|
+
],
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
const dayValues$1 = {
|
|
1732
|
+
narrow: ["日", "月", "火", "水", "木", "金", "土"],
|
|
1733
|
+
short: ["日", "月", "火", "水", "木", "金", "土"],
|
|
1734
|
+
abbreviated: ["日", "月", "火", "水", "木", "金", "土"],
|
|
1735
|
+
wide: ["日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"],
|
|
1736
|
+
};
|
|
1737
|
+
|
|
1738
|
+
const dayPeriodValues$1 = {
|
|
1739
|
+
narrow: {
|
|
1740
|
+
am: "午前",
|
|
1741
|
+
pm: "午後",
|
|
1742
|
+
midnight: "深夜",
|
|
1743
|
+
noon: "正午",
|
|
1744
|
+
morning: "朝",
|
|
1745
|
+
afternoon: "午後",
|
|
1746
|
+
evening: "夜",
|
|
1747
|
+
night: "深夜",
|
|
1748
|
+
},
|
|
1749
|
+
abbreviated: {
|
|
1750
|
+
am: "午前",
|
|
1751
|
+
pm: "午後",
|
|
1752
|
+
midnight: "深夜",
|
|
1753
|
+
noon: "正午",
|
|
1754
|
+
morning: "朝",
|
|
1755
|
+
afternoon: "午後",
|
|
1756
|
+
evening: "夜",
|
|
1757
|
+
night: "深夜",
|
|
1758
|
+
},
|
|
1759
|
+
wide: {
|
|
1760
|
+
am: "午前",
|
|
1761
|
+
pm: "午後",
|
|
1762
|
+
midnight: "深夜",
|
|
1763
|
+
noon: "正午",
|
|
1764
|
+
morning: "朝",
|
|
1765
|
+
afternoon: "午後",
|
|
1766
|
+
evening: "夜",
|
|
1767
|
+
night: "深夜",
|
|
1768
|
+
},
|
|
1769
|
+
};
|
|
1770
|
+
const formattingDayPeriodValues$1 = {
|
|
1771
|
+
narrow: {
|
|
1772
|
+
am: "午前",
|
|
1773
|
+
pm: "午後",
|
|
1774
|
+
midnight: "深夜",
|
|
1775
|
+
noon: "正午",
|
|
1776
|
+
morning: "朝",
|
|
1777
|
+
afternoon: "午後",
|
|
1778
|
+
evening: "夜",
|
|
1779
|
+
night: "深夜",
|
|
1780
|
+
},
|
|
1781
|
+
abbreviated: {
|
|
1782
|
+
am: "午前",
|
|
1783
|
+
pm: "午後",
|
|
1784
|
+
midnight: "深夜",
|
|
1785
|
+
noon: "正午",
|
|
1786
|
+
morning: "朝",
|
|
1787
|
+
afternoon: "午後",
|
|
1788
|
+
evening: "夜",
|
|
1789
|
+
night: "深夜",
|
|
1790
|
+
},
|
|
1791
|
+
wide: {
|
|
1792
|
+
am: "午前",
|
|
1793
|
+
pm: "午後",
|
|
1794
|
+
midnight: "深夜",
|
|
1795
|
+
noon: "正午",
|
|
1796
|
+
morning: "朝",
|
|
1797
|
+
afternoon: "午後",
|
|
1798
|
+
evening: "夜",
|
|
1799
|
+
night: "深夜",
|
|
1800
|
+
},
|
|
1801
|
+
};
|
|
1802
|
+
|
|
1803
|
+
const ordinalNumber$1 = (dirtyNumber, options) => {
|
|
1804
|
+
const number = Number(dirtyNumber);
|
|
1805
|
+
const unit = String(options?.unit);
|
|
1806
|
+
|
|
1807
|
+
switch (unit) {
|
|
1808
|
+
case "year":
|
|
1809
|
+
return `${number}年`;
|
|
1810
|
+
case "quarter":
|
|
1811
|
+
return `第${number}四半期`;
|
|
1812
|
+
case "month":
|
|
1813
|
+
return `${number}月`;
|
|
1814
|
+
case "week":
|
|
1815
|
+
return `第${number}週`;
|
|
1816
|
+
case "date":
|
|
1817
|
+
return `${number}日`;
|
|
1818
|
+
case "hour":
|
|
1819
|
+
return `${number}時`;
|
|
1820
|
+
case "minute":
|
|
1821
|
+
return `${number}分`;
|
|
1822
|
+
case "second":
|
|
1823
|
+
return `${number}秒`;
|
|
1824
|
+
default:
|
|
1825
|
+
return `${number}`;
|
|
1826
|
+
}
|
|
1827
|
+
};
|
|
1828
|
+
|
|
1829
|
+
const localize$1 = {
|
|
1830
|
+
ordinalNumber: ordinalNumber$1,
|
|
1831
|
+
|
|
1832
|
+
era: buildLocalizeFn({
|
|
1833
|
+
values: eraValues$1,
|
|
1834
|
+
defaultWidth: "wide",
|
|
1835
|
+
}),
|
|
1836
|
+
|
|
1837
|
+
quarter: buildLocalizeFn({
|
|
1838
|
+
values: quarterValues$1,
|
|
1839
|
+
defaultWidth: "wide",
|
|
1840
|
+
argumentCallback: (quarter) => Number(quarter) - 1,
|
|
1841
|
+
}),
|
|
1842
|
+
|
|
1843
|
+
month: buildLocalizeFn({
|
|
1844
|
+
values: monthValues$1,
|
|
1845
|
+
defaultWidth: "wide",
|
|
1846
|
+
}),
|
|
1847
|
+
|
|
1848
|
+
day: buildLocalizeFn({
|
|
1849
|
+
values: dayValues$1,
|
|
1850
|
+
defaultWidth: "wide",
|
|
1851
|
+
}),
|
|
1852
|
+
|
|
1853
|
+
dayPeriod: buildLocalizeFn({
|
|
1854
|
+
values: dayPeriodValues$1,
|
|
1855
|
+
defaultWidth: "wide",
|
|
1856
|
+
formattingValues: formattingDayPeriodValues$1,
|
|
1857
|
+
defaultFormattingWidth: "wide",
|
|
1858
|
+
}),
|
|
1859
|
+
};
|
|
1860
|
+
|
|
1861
|
+
const matchOrdinalNumberPattern$1 = /^第?\d+(年|四半期|月|週|日|時|分|秒)?/i;
|
|
1862
|
+
const parseOrdinalNumberPattern$1 = /\d+/i;
|
|
1863
|
+
|
|
1864
|
+
const matchEraPatterns$1 = {
|
|
1865
|
+
narrow: /^(B\.?C\.?|A\.?D\.?)/i,
|
|
1866
|
+
abbreviated: /^(紀元[前後]|西暦)/i,
|
|
1867
|
+
wide: /^(紀元[前後]|西暦)/i,
|
|
1868
|
+
};
|
|
1869
|
+
const parseEraPatterns$1 = {
|
|
1870
|
+
narrow: [/^B/i, /^A/i],
|
|
1871
|
+
any: [/^(紀元前)/i, /^(西暦|紀元後)/i],
|
|
1872
|
+
};
|
|
1873
|
+
|
|
1874
|
+
const matchQuarterPatterns$1 = {
|
|
1875
|
+
narrow: /^[1234]/i,
|
|
1876
|
+
abbreviated: /^Q[1234]/i,
|
|
1877
|
+
wide: /^第[1234一二三四1234]四半期/i,
|
|
1878
|
+
};
|
|
1879
|
+
const parseQuarterPatterns$1 = {
|
|
1880
|
+
any: [/(1|一|1)/i, /(2|二|2)/i, /(3|三|3)/i, /(4|四|4)/i],
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
const matchMonthPatterns$1 = {
|
|
1884
|
+
narrow: /^([123456789]|1[012])/,
|
|
1885
|
+
abbreviated: /^([123456789]|1[012])月/i,
|
|
1886
|
+
wide: /^([123456789]|1[012])月/i,
|
|
1887
|
+
};
|
|
1888
|
+
const parseMonthPatterns$1 = {
|
|
1889
|
+
any: [
|
|
1890
|
+
/^1\D/,
|
|
1891
|
+
/^2/,
|
|
1892
|
+
/^3/,
|
|
1893
|
+
/^4/,
|
|
1894
|
+
/^5/,
|
|
1895
|
+
/^6/,
|
|
1896
|
+
/^7/,
|
|
1897
|
+
/^8/,
|
|
1898
|
+
/^9/,
|
|
1899
|
+
/^10/,
|
|
1900
|
+
/^11/,
|
|
1901
|
+
/^12/,
|
|
1902
|
+
],
|
|
1903
|
+
};
|
|
1904
|
+
|
|
1905
|
+
const matchDayPatterns$1 = {
|
|
1906
|
+
narrow: /^[日月火水木金土]/,
|
|
1907
|
+
short: /^[日月火水木金土]/,
|
|
1908
|
+
abbreviated: /^[日月火水木金土]/,
|
|
1909
|
+
wide: /^[日月火水木金土]曜日/,
|
|
1910
|
+
};
|
|
1911
|
+
const parseDayPatterns$1 = {
|
|
1912
|
+
any: [/^日/, /^月/, /^火/, /^水/, /^木/, /^金/, /^土/],
|
|
1913
|
+
};
|
|
1914
|
+
|
|
1915
|
+
const matchDayPeriodPatterns$1 = {
|
|
1916
|
+
any: /^(AM|PM|午前|午後|正午|深夜|真夜中|夜|朝)/i,
|
|
1917
|
+
};
|
|
1918
|
+
const parseDayPeriodPatterns$1 = {
|
|
1919
|
+
any: {
|
|
1920
|
+
am: /^(A|午前)/i,
|
|
1921
|
+
pm: /^(P|午後)/i,
|
|
1922
|
+
midnight: /^深夜|真夜中/i,
|
|
1923
|
+
noon: /^正午/i,
|
|
1924
|
+
morning: /^朝/i,
|
|
1925
|
+
afternoon: /^午後/i,
|
|
1926
|
+
evening: /^夜/i,
|
|
1927
|
+
night: /^深夜/i,
|
|
1928
|
+
},
|
|
1929
|
+
};
|
|
1930
|
+
|
|
1931
|
+
const match$1 = {
|
|
1932
|
+
ordinalNumber: buildMatchPatternFn({
|
|
1933
|
+
matchPattern: matchOrdinalNumberPattern$1,
|
|
1934
|
+
parsePattern: parseOrdinalNumberPattern$1,
|
|
1935
|
+
valueCallback: function (value) {
|
|
1936
|
+
return parseInt(value, 10);
|
|
1937
|
+
},
|
|
1938
|
+
}),
|
|
1939
|
+
|
|
1940
|
+
era: buildMatchFn({
|
|
1941
|
+
matchPatterns: matchEraPatterns$1,
|
|
1942
|
+
defaultMatchWidth: "wide",
|
|
1943
|
+
parsePatterns: parseEraPatterns$1,
|
|
1944
|
+
defaultParseWidth: "any",
|
|
1945
|
+
}),
|
|
1946
|
+
|
|
1947
|
+
quarter: buildMatchFn({
|
|
1948
|
+
matchPatterns: matchQuarterPatterns$1,
|
|
1949
|
+
defaultMatchWidth: "wide",
|
|
1950
|
+
parsePatterns: parseQuarterPatterns$1,
|
|
1951
|
+
defaultParseWidth: "any",
|
|
1952
|
+
valueCallback: (index) => index + 1,
|
|
1953
|
+
}),
|
|
1954
|
+
|
|
1955
|
+
month: buildMatchFn({
|
|
1956
|
+
matchPatterns: matchMonthPatterns$1,
|
|
1957
|
+
defaultMatchWidth: "wide",
|
|
1958
|
+
parsePatterns: parseMonthPatterns$1,
|
|
1959
|
+
defaultParseWidth: "any",
|
|
1960
|
+
}),
|
|
1961
|
+
|
|
1962
|
+
day: buildMatchFn({
|
|
1963
|
+
matchPatterns: matchDayPatterns$1,
|
|
1964
|
+
defaultMatchWidth: "wide",
|
|
1965
|
+
parsePatterns: parseDayPatterns$1,
|
|
1966
|
+
defaultParseWidth: "any",
|
|
1967
|
+
}),
|
|
1968
|
+
|
|
1969
|
+
dayPeriod: buildMatchFn({
|
|
1970
|
+
matchPatterns: matchDayPeriodPatterns$1,
|
|
1971
|
+
defaultMatchWidth: "any",
|
|
1972
|
+
parsePatterns: parseDayPeriodPatterns$1,
|
|
1973
|
+
defaultParseWidth: "any",
|
|
1974
|
+
}),
|
|
1975
|
+
};
|
|
1976
|
+
|
|
1977
|
+
/**
|
|
1978
|
+
* @category Locales
|
|
1979
|
+
* @summary Japanese locale.
|
|
1980
|
+
* @language Japanese
|
|
1981
|
+
* @iso-639-2 jpn
|
|
1982
|
+
* @author Thomas Eilmsteiner [@DeMuu](https://github.com/DeMuu)
|
|
1983
|
+
* @author Yamagishi Kazutoshi [@ykzts](https://github.com/ykzts)
|
|
1984
|
+
* @author Luca Ban [@mesqueeb](https://github.com/mesqueeb)
|
|
1985
|
+
* @author Terrence Lam [@skyuplam](https://github.com/skyuplam)
|
|
1986
|
+
* @author Taiki IKeda [@so99ynoodles](https://github.com/so99ynoodles)
|
|
1987
|
+
*/
|
|
1988
|
+
const ja = {
|
|
1989
|
+
code: "ja",
|
|
1990
|
+
formatDistance: formatDistance$1,
|
|
1991
|
+
formatLong: formatLong$1,
|
|
1992
|
+
formatRelative: formatRelative$1,
|
|
1993
|
+
localize: localize$1,
|
|
1994
|
+
match: match$1,
|
|
1995
|
+
options: {
|
|
1996
|
+
weekStartsOn: 0 /* Sunday */,
|
|
1997
|
+
firstWeekContainsDate: 1,
|
|
1998
|
+
},
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
const formatDistanceLocale = {
|
|
2002
|
+
lessThanXSeconds: {
|
|
2003
|
+
one: "不到 1 秒",
|
|
2004
|
+
other: "不到 {{count}} 秒",
|
|
2005
|
+
},
|
|
2006
|
+
|
|
2007
|
+
xSeconds: {
|
|
2008
|
+
one: "1 秒",
|
|
2009
|
+
other: "{{count}} 秒",
|
|
2010
|
+
},
|
|
2011
|
+
|
|
2012
|
+
halfAMinute: "半分钟",
|
|
2013
|
+
|
|
2014
|
+
lessThanXMinutes: {
|
|
2015
|
+
one: "不到 1 分钟",
|
|
2016
|
+
other: "不到 {{count}} 分钟",
|
|
2017
|
+
},
|
|
2018
|
+
|
|
2019
|
+
xMinutes: {
|
|
2020
|
+
one: "1 分钟",
|
|
2021
|
+
other: "{{count}} 分钟",
|
|
2022
|
+
},
|
|
2023
|
+
|
|
2024
|
+
xHours: {
|
|
2025
|
+
one: "1 小时",
|
|
2026
|
+
other: "{{count}} 小时",
|
|
2027
|
+
},
|
|
2028
|
+
|
|
2029
|
+
aboutXHours: {
|
|
2030
|
+
one: "大约 1 小时",
|
|
2031
|
+
other: "大约 {{count}} 小时",
|
|
2032
|
+
},
|
|
2033
|
+
|
|
2034
|
+
xDays: {
|
|
2035
|
+
one: "1 天",
|
|
2036
|
+
other: "{{count}} 天",
|
|
2037
|
+
},
|
|
2038
|
+
|
|
2039
|
+
aboutXWeeks: {
|
|
2040
|
+
one: "大约 1 个星期",
|
|
2041
|
+
other: "大约 {{count}} 个星期",
|
|
2042
|
+
},
|
|
2043
|
+
|
|
2044
|
+
xWeeks: {
|
|
2045
|
+
one: "1 个星期",
|
|
2046
|
+
other: "{{count}} 个星期",
|
|
2047
|
+
},
|
|
2048
|
+
|
|
2049
|
+
aboutXMonths: {
|
|
2050
|
+
one: "大约 1 个月",
|
|
2051
|
+
other: "大约 {{count}} 个月",
|
|
2052
|
+
},
|
|
2053
|
+
|
|
2054
|
+
xMonths: {
|
|
2055
|
+
one: "1 个月",
|
|
2056
|
+
other: "{{count}} 个月",
|
|
2057
|
+
},
|
|
2058
|
+
|
|
2059
|
+
aboutXYears: {
|
|
2060
|
+
one: "大约 1 年",
|
|
2061
|
+
other: "大约 {{count}} 年",
|
|
2062
|
+
},
|
|
2063
|
+
|
|
2064
|
+
xYears: {
|
|
2065
|
+
one: "1 年",
|
|
2066
|
+
other: "{{count}} 年",
|
|
2067
|
+
},
|
|
2068
|
+
|
|
2069
|
+
overXYears: {
|
|
2070
|
+
one: "超过 1 年",
|
|
2071
|
+
other: "超过 {{count}} 年",
|
|
2072
|
+
},
|
|
2073
|
+
|
|
2074
|
+
almostXYears: {
|
|
2075
|
+
one: "将近 1 年",
|
|
2076
|
+
other: "将近 {{count}} 年",
|
|
2077
|
+
},
|
|
2078
|
+
};
|
|
2079
|
+
|
|
2080
|
+
const formatDistance = (token, count, options) => {
|
|
2081
|
+
let result;
|
|
2082
|
+
|
|
2083
|
+
const tokenValue = formatDistanceLocale[token];
|
|
2084
|
+
if (typeof tokenValue === "string") {
|
|
2085
|
+
result = tokenValue;
|
|
2086
|
+
} else if (count === 1) {
|
|
2087
|
+
result = tokenValue.one;
|
|
2088
|
+
} else {
|
|
2089
|
+
result = tokenValue.other.replace("{{count}}", String(count));
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
if (options?.addSuffix) {
|
|
2093
|
+
if (options.comparison && options.comparison > 0) {
|
|
2094
|
+
return result + "内";
|
|
2095
|
+
} else {
|
|
2096
|
+
return result + "前";
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
return result;
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
const dateFormats = {
|
|
2104
|
+
full: "y'年'M'月'd'日' EEEE",
|
|
2105
|
+
long: "y'年'M'月'd'日'",
|
|
2106
|
+
medium: "yyyy-MM-dd",
|
|
2107
|
+
short: "yy-MM-dd",
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
const timeFormats = {
|
|
2111
|
+
full: "zzzz a h:mm:ss",
|
|
2112
|
+
long: "z a h:mm:ss",
|
|
2113
|
+
medium: "a h:mm:ss",
|
|
2114
|
+
short: "a h:mm",
|
|
2115
|
+
};
|
|
2116
|
+
|
|
2117
|
+
const dateTimeFormats = {
|
|
2118
|
+
full: "{{date}} {{time}}",
|
|
2119
|
+
long: "{{date}} {{time}}",
|
|
2120
|
+
medium: "{{date}} {{time}}",
|
|
2121
|
+
short: "{{date}} {{time}}",
|
|
2122
|
+
};
|
|
2123
|
+
|
|
2124
|
+
const formatLong = {
|
|
2125
|
+
date: buildFormatLongFn({
|
|
2126
|
+
formats: dateFormats,
|
|
2127
|
+
defaultWidth: "full",
|
|
2128
|
+
}),
|
|
2129
|
+
|
|
2130
|
+
time: buildFormatLongFn({
|
|
2131
|
+
formats: timeFormats,
|
|
2132
|
+
defaultWidth: "full",
|
|
2133
|
+
}),
|
|
2134
|
+
|
|
2135
|
+
dateTime: buildFormatLongFn({
|
|
2136
|
+
formats: dateTimeFormats,
|
|
2137
|
+
defaultWidth: "full",
|
|
2138
|
+
}),
|
|
2139
|
+
};
|
|
2140
|
+
|
|
2141
|
+
function checkWeek(date, baseDate, options) {
|
|
2142
|
+
const baseFormat = "eeee p";
|
|
2143
|
+
|
|
2144
|
+
if (isSameWeek(date, baseDate, options)) {
|
|
2145
|
+
return baseFormat; // in same week
|
|
2146
|
+
} else if (date.getTime() > baseDate.getTime()) {
|
|
2147
|
+
return "'下个'" + baseFormat; // in next week
|
|
2148
|
+
}
|
|
2149
|
+
return "'上个'" + baseFormat; // in last week
|
|
2150
|
+
}
|
|
2151
|
+
|
|
2152
|
+
const formatRelativeLocale = {
|
|
2153
|
+
lastWeek: checkWeek, // days before yesterday, maybe in this week or last week
|
|
2154
|
+
yesterday: "'昨天' p",
|
|
2155
|
+
today: "'今天' p",
|
|
2156
|
+
tomorrow: "'明天' p",
|
|
2157
|
+
nextWeek: checkWeek, // days after tomorrow, maybe in this week or next week
|
|
2158
|
+
other: "PP p",
|
|
2159
|
+
};
|
|
2160
|
+
|
|
2161
|
+
const formatRelative = (token, date, baseDate, options) => {
|
|
2162
|
+
const format = formatRelativeLocale[token];
|
|
2163
|
+
|
|
2164
|
+
if (typeof format === "function") {
|
|
2165
|
+
return format(date, baseDate, options);
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
return format;
|
|
2169
|
+
};
|
|
2170
|
+
|
|
2171
|
+
const eraValues = {
|
|
2172
|
+
narrow: ["前", "公元"],
|
|
2173
|
+
abbreviated: ["前", "公元"],
|
|
2174
|
+
wide: ["公元前", "公元"],
|
|
2175
|
+
};
|
|
2176
|
+
|
|
2177
|
+
const quarterValues = {
|
|
2178
|
+
narrow: ["1", "2", "3", "4"],
|
|
2179
|
+
abbreviated: ["第一季", "第二季", "第三季", "第四季"],
|
|
2180
|
+
wide: ["第一季度", "第二季度", "第三季度", "第四季度"],
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
const monthValues = {
|
|
2184
|
+
narrow: [
|
|
2185
|
+
"一",
|
|
2186
|
+
"二",
|
|
2187
|
+
"三",
|
|
2188
|
+
"四",
|
|
2189
|
+
"五",
|
|
2190
|
+
"六",
|
|
2191
|
+
"七",
|
|
2192
|
+
"八",
|
|
2193
|
+
"九",
|
|
2194
|
+
"十",
|
|
2195
|
+
"十一",
|
|
2196
|
+
"十二",
|
|
2197
|
+
],
|
|
2198
|
+
|
|
2199
|
+
abbreviated: [
|
|
2200
|
+
"1月",
|
|
2201
|
+
"2月",
|
|
2202
|
+
"3月",
|
|
2203
|
+
"4月",
|
|
2204
|
+
"5月",
|
|
2205
|
+
"6月",
|
|
2206
|
+
"7月",
|
|
2207
|
+
"8月",
|
|
2208
|
+
"9月",
|
|
2209
|
+
"10月",
|
|
2210
|
+
"11月",
|
|
2211
|
+
"12月",
|
|
2212
|
+
],
|
|
2213
|
+
|
|
2214
|
+
wide: [
|
|
2215
|
+
"一月",
|
|
2216
|
+
"二月",
|
|
2217
|
+
"三月",
|
|
2218
|
+
"四月",
|
|
2219
|
+
"五月",
|
|
2220
|
+
"六月",
|
|
2221
|
+
"七月",
|
|
2222
|
+
"八月",
|
|
2223
|
+
"九月",
|
|
2224
|
+
"十月",
|
|
2225
|
+
"十一月",
|
|
2226
|
+
"十二月",
|
|
2227
|
+
],
|
|
2228
|
+
};
|
|
2229
|
+
|
|
2230
|
+
const dayValues = {
|
|
2231
|
+
narrow: ["日", "一", "二", "三", "四", "五", "六"],
|
|
2232
|
+
short: ["日", "一", "二", "三", "四", "五", "六"],
|
|
2233
|
+
abbreviated: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
|
|
2234
|
+
|
|
2235
|
+
wide: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"],
|
|
2236
|
+
};
|
|
2237
|
+
|
|
2238
|
+
const dayPeriodValues = {
|
|
2239
|
+
narrow: {
|
|
2240
|
+
am: "上",
|
|
2241
|
+
pm: "下",
|
|
2242
|
+
midnight: "凌晨",
|
|
2243
|
+
noon: "午",
|
|
2244
|
+
morning: "早",
|
|
2245
|
+
afternoon: "下午",
|
|
2246
|
+
evening: "晚",
|
|
2247
|
+
night: "夜",
|
|
2248
|
+
},
|
|
2249
|
+
abbreviated: {
|
|
2250
|
+
am: "上午",
|
|
2251
|
+
pm: "下午",
|
|
2252
|
+
midnight: "凌晨",
|
|
2253
|
+
noon: "中午",
|
|
2254
|
+
morning: "早晨",
|
|
2255
|
+
afternoon: "中午",
|
|
2256
|
+
evening: "晚上",
|
|
2257
|
+
night: "夜间",
|
|
2258
|
+
},
|
|
2259
|
+
wide: {
|
|
2260
|
+
am: "上午",
|
|
2261
|
+
pm: "下午",
|
|
2262
|
+
midnight: "凌晨",
|
|
2263
|
+
noon: "中午",
|
|
2264
|
+
morning: "早晨",
|
|
2265
|
+
afternoon: "中午",
|
|
2266
|
+
evening: "晚上",
|
|
2267
|
+
night: "夜间",
|
|
2268
|
+
},
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2271
|
+
const formattingDayPeriodValues = {
|
|
2272
|
+
narrow: {
|
|
2273
|
+
am: "上",
|
|
2274
|
+
pm: "下",
|
|
2275
|
+
midnight: "凌晨",
|
|
2276
|
+
noon: "午",
|
|
2277
|
+
morning: "早",
|
|
2278
|
+
afternoon: "下午",
|
|
2279
|
+
evening: "晚",
|
|
2280
|
+
night: "夜",
|
|
2281
|
+
},
|
|
2282
|
+
abbreviated: {
|
|
2283
|
+
am: "上午",
|
|
2284
|
+
pm: "下午",
|
|
2285
|
+
midnight: "凌晨",
|
|
2286
|
+
noon: "中午",
|
|
2287
|
+
morning: "早晨",
|
|
2288
|
+
afternoon: "中午",
|
|
2289
|
+
evening: "晚上",
|
|
2290
|
+
night: "夜间",
|
|
2291
|
+
},
|
|
2292
|
+
wide: {
|
|
2293
|
+
am: "上午",
|
|
2294
|
+
pm: "下午",
|
|
2295
|
+
midnight: "凌晨",
|
|
2296
|
+
noon: "中午",
|
|
2297
|
+
morning: "早晨",
|
|
2298
|
+
afternoon: "中午",
|
|
2299
|
+
evening: "晚上",
|
|
2300
|
+
night: "夜间",
|
|
2301
|
+
},
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
const ordinalNumber = (dirtyNumber, options) => {
|
|
2305
|
+
const number = Number(dirtyNumber);
|
|
2306
|
+
|
|
2307
|
+
switch (options?.unit) {
|
|
2308
|
+
case "date":
|
|
2309
|
+
return number.toString() + "日";
|
|
2310
|
+
case "hour":
|
|
2311
|
+
return number.toString() + "时";
|
|
2312
|
+
case "minute":
|
|
2313
|
+
return number.toString() + "分";
|
|
2314
|
+
case "second":
|
|
2315
|
+
return number.toString() + "秒";
|
|
2316
|
+
default:
|
|
2317
|
+
return "第 " + number.toString();
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
|
|
2321
|
+
const localize = {
|
|
2322
|
+
ordinalNumber,
|
|
2323
|
+
|
|
2324
|
+
era: buildLocalizeFn({
|
|
2325
|
+
values: eraValues,
|
|
2326
|
+
defaultWidth: "wide",
|
|
2327
|
+
}),
|
|
2328
|
+
|
|
2329
|
+
quarter: buildLocalizeFn({
|
|
2330
|
+
values: quarterValues,
|
|
2331
|
+
defaultWidth: "wide",
|
|
2332
|
+
argumentCallback: (quarter) => quarter - 1,
|
|
2333
|
+
}),
|
|
2334
|
+
|
|
2335
|
+
month: buildLocalizeFn({
|
|
2336
|
+
values: monthValues,
|
|
2337
|
+
defaultWidth: "wide",
|
|
2338
|
+
}),
|
|
2339
|
+
|
|
2340
|
+
day: buildLocalizeFn({
|
|
2341
|
+
values: dayValues,
|
|
2342
|
+
defaultWidth: "wide",
|
|
2343
|
+
}),
|
|
2344
|
+
|
|
2345
|
+
dayPeriod: buildLocalizeFn({
|
|
2346
|
+
values: dayPeriodValues,
|
|
2347
|
+
defaultWidth: "wide",
|
|
2348
|
+
formattingValues: formattingDayPeriodValues,
|
|
2349
|
+
defaultFormattingWidth: "wide",
|
|
2350
|
+
}),
|
|
2351
|
+
};
|
|
2352
|
+
|
|
2353
|
+
const matchOrdinalNumberPattern = /^(第\s*)?\d+(日|时|分|秒)?/i;
|
|
2354
|
+
const parseOrdinalNumberPattern = /\d+/i;
|
|
2355
|
+
|
|
2356
|
+
const matchEraPatterns = {
|
|
2357
|
+
narrow: /^(前)/i,
|
|
2358
|
+
abbreviated: /^(前)/i,
|
|
2359
|
+
wide: /^(公元前|公元)/i,
|
|
2360
|
+
};
|
|
2361
|
+
const parseEraPatterns = {
|
|
2362
|
+
any: [/^(前)/i, /^(公元)/i],
|
|
2363
|
+
};
|
|
2364
|
+
|
|
2365
|
+
const matchQuarterPatterns = {
|
|
2366
|
+
narrow: /^[1234]/i,
|
|
2367
|
+
abbreviated: /^第[一二三四]刻/i,
|
|
2368
|
+
wide: /^第[一二三四]刻钟/i,
|
|
2369
|
+
};
|
|
2370
|
+
const parseQuarterPatterns = {
|
|
2371
|
+
any: [/(1|一)/i, /(2|二)/i, /(3|三)/i, /(4|四)/i],
|
|
2372
|
+
};
|
|
2373
|
+
|
|
2374
|
+
const matchMonthPatterns = {
|
|
2375
|
+
narrow: /^(一|二|三|四|五|六|七|八|九|十[二一])/i,
|
|
2376
|
+
abbreviated: /^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,
|
|
2377
|
+
wide: /^(一|二|三|四|五|六|七|八|九|十[二一])月/i,
|
|
2378
|
+
};
|
|
2379
|
+
const parseMonthPatterns = {
|
|
2380
|
+
narrow: [
|
|
2381
|
+
/^一/i,
|
|
2382
|
+
/^二/i,
|
|
2383
|
+
/^三/i,
|
|
2384
|
+
/^四/i,
|
|
2385
|
+
/^五/i,
|
|
2386
|
+
/^六/i,
|
|
2387
|
+
/^七/i,
|
|
2388
|
+
/^八/i,
|
|
2389
|
+
/^九/i,
|
|
2390
|
+
/^十(?!(一|二))/i,
|
|
2391
|
+
/^十一/i,
|
|
2392
|
+
/^十二/i,
|
|
2393
|
+
],
|
|
2394
|
+
|
|
2395
|
+
any: [
|
|
2396
|
+
/^一|1/i,
|
|
2397
|
+
/^二|2/i,
|
|
2398
|
+
/^三|3/i,
|
|
2399
|
+
/^四|4/i,
|
|
2400
|
+
/^五|5/i,
|
|
2401
|
+
/^六|6/i,
|
|
2402
|
+
/^七|7/i,
|
|
2403
|
+
/^八|8/i,
|
|
2404
|
+
/^九|9/i,
|
|
2405
|
+
/^十(?!(一|二))|10/i,
|
|
2406
|
+
/^十一|11/i,
|
|
2407
|
+
/^十二|12/i,
|
|
2408
|
+
],
|
|
2409
|
+
};
|
|
2410
|
+
|
|
2411
|
+
const matchDayPatterns = {
|
|
2412
|
+
narrow: /^[一二三四五六日]/i,
|
|
2413
|
+
short: /^[一二三四五六日]/i,
|
|
2414
|
+
abbreviated: /^周[一二三四五六日]/i,
|
|
2415
|
+
wide: /^星期[一二三四五六日]/i,
|
|
2416
|
+
};
|
|
2417
|
+
const parseDayPatterns = {
|
|
2418
|
+
any: [/日/i, /一/i, /二/i, /三/i, /四/i, /五/i, /六/i],
|
|
2419
|
+
};
|
|
2420
|
+
|
|
2421
|
+
const matchDayPeriodPatterns = {
|
|
2422
|
+
any: /^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i,
|
|
2423
|
+
};
|
|
2424
|
+
const parseDayPeriodPatterns = {
|
|
2425
|
+
any: {
|
|
2426
|
+
am: /^上午?/i,
|
|
2427
|
+
pm: /^下午?/i,
|
|
2428
|
+
midnight: /^午夜/i,
|
|
2429
|
+
noon: /^[中正]午/i,
|
|
2430
|
+
morning: /^早上/i,
|
|
2431
|
+
afternoon: /^下午/i,
|
|
2432
|
+
evening: /^晚上?/i,
|
|
2433
|
+
night: /^凌晨/i,
|
|
2434
|
+
},
|
|
2435
|
+
};
|
|
2436
|
+
|
|
2437
|
+
const match = {
|
|
2438
|
+
ordinalNumber: buildMatchPatternFn({
|
|
2439
|
+
matchPattern: matchOrdinalNumberPattern,
|
|
2440
|
+
parsePattern: parseOrdinalNumberPattern,
|
|
2441
|
+
valueCallback: (value) => parseInt(value, 10),
|
|
2442
|
+
}),
|
|
2443
|
+
|
|
2444
|
+
era: buildMatchFn({
|
|
2445
|
+
matchPatterns: matchEraPatterns,
|
|
2446
|
+
defaultMatchWidth: "wide",
|
|
2447
|
+
parsePatterns: parseEraPatterns,
|
|
2448
|
+
defaultParseWidth: "any",
|
|
2449
|
+
}),
|
|
2450
|
+
|
|
2451
|
+
quarter: buildMatchFn({
|
|
2452
|
+
matchPatterns: matchQuarterPatterns,
|
|
2453
|
+
defaultMatchWidth: "wide",
|
|
2454
|
+
parsePatterns: parseQuarterPatterns,
|
|
2455
|
+
defaultParseWidth: "any",
|
|
2456
|
+
valueCallback: (index) => index + 1,
|
|
2457
|
+
}),
|
|
2458
|
+
|
|
2459
|
+
month: buildMatchFn({
|
|
2460
|
+
matchPatterns: matchMonthPatterns,
|
|
2461
|
+
defaultMatchWidth: "wide",
|
|
2462
|
+
parsePatterns: parseMonthPatterns,
|
|
2463
|
+
defaultParseWidth: "any",
|
|
2464
|
+
}),
|
|
2465
|
+
|
|
2466
|
+
day: buildMatchFn({
|
|
2467
|
+
matchPatterns: matchDayPatterns,
|
|
2468
|
+
defaultMatchWidth: "wide",
|
|
2469
|
+
parsePatterns: parseDayPatterns,
|
|
2470
|
+
defaultParseWidth: "any",
|
|
2471
|
+
}),
|
|
2472
|
+
|
|
2473
|
+
dayPeriod: buildMatchFn({
|
|
2474
|
+
matchPatterns: matchDayPeriodPatterns,
|
|
2475
|
+
defaultMatchWidth: "any",
|
|
2476
|
+
parsePatterns: parseDayPeriodPatterns,
|
|
2477
|
+
defaultParseWidth: "any",
|
|
2478
|
+
}),
|
|
2479
|
+
};
|
|
2480
|
+
|
|
2481
|
+
/**
|
|
2482
|
+
* @category Locales
|
|
2483
|
+
* @summary Chinese Simplified locale.
|
|
2484
|
+
* @language Chinese Simplified
|
|
2485
|
+
* @iso-639-2 zho
|
|
2486
|
+
* @author Changyu Geng [@KingMario](https://github.com/KingMario)
|
|
2487
|
+
* @author Song Shuoyun [@fnlctrl](https://github.com/fnlctrl)
|
|
2488
|
+
* @author sabrinaM [@sabrinamiao](https://github.com/sabrinamiao)
|
|
2489
|
+
* @author Carney Wu [@cubicwork](https://github.com/cubicwork)
|
|
2490
|
+
* @author Terrence Lam [@skyuplam](https://github.com/skyuplam)
|
|
2491
|
+
*/
|
|
2492
|
+
const zhCN = {
|
|
2493
|
+
code: "zh-CN",
|
|
2494
|
+
formatDistance: formatDistance,
|
|
2495
|
+
formatLong: formatLong,
|
|
2496
|
+
formatRelative: formatRelative,
|
|
2497
|
+
localize: localize,
|
|
2498
|
+
match: match,
|
|
2499
|
+
options: {
|
|
2500
|
+
weekStartsOn: 1 /* Monday */,
|
|
2501
|
+
firstWeekContainsDate: 4,
|
|
2502
|
+
},
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
const startPageCss = ":host{display:grid;block-size:100%;overflow:auto}.main{animation:fadeIn 300ms forwards;display:grid;block-size:100%;overflow:auto;opacity:0;grid-template-rows:max-content 1fr;gap:var(--mer-spacing--xl)}@keyframes bounce{0%{transform:translateY(0)}100%{transform:translateY(-30px)}}@keyframes fadeIn{from{opacity:0}to{opacity:1}}.section-create-new-kb__actions,.section-secondary__actions{display:grid;grid-auto-flow:column;gap:var(--mer-spacing--md);overflow-x:auto;padding-block-end:var(--mer-spacing--xs)}.card-filled,.card-outlined{display:grid;gap:var(--mer-spacing--xl);align-content:space-between;border:var(--mer-border__width--sm) solid var(--mer-border-color__on-surface);border-radius:var(--mer-border__radius--sm);padding:var(--mer-spacing--lg)}.card-filled{background-color:var(--mer-surface__elevation--01)}.icon-capsule{pointer-events:none;display:inline-flex;block-size:40px;inline-size:40px;justify-content:center;align-items:center;border-radius:50%;border:var(--mer-border__width--sm) dashed var(--mer-border-color__on-elevation--02)}.card__header{display:grid;gap:var(--mer-spacing--sm)}.card__header-description{display:grid;gap:var(--mer-spacing--2xs)}.section-create-new-kb{display:grid;grid-auto-rows:max-content;gap:var(--mer-spacing--lg)}.section-create-new-kb__header{display:grid;gap:var(--mer-spacing--2xs)}.section-create-new-kb__actions{display:grid;gap:var(--mer-spacing--md);overflow-x:auto;grid-auto-flow:column;grid-auto-columns:430px}.section-secondary{display:grid;block-size:100%;position:relative;overflow:auto}.section-secondary__actions{display:grid;gap:var(--mer-spacing--sm)}.section-secondary__actions--two-cards{grid-template-columns:repeat(2, minmax(430px, 1fr))}.section-secondary__actions--multiple-cards{grid-auto-columns:670px}.section-kbs{background-color:var(--mer-surface__elevation--01);border-radius:var(--mer-border__radius--sm);padding:var(--mer-spacing--sm);display:grid;grid-template-rows:auto 1fr;overflow:auto}.section-kbs__header{display:grid;grid-template-columns:max-content 230px;align-items:center;gap:var(--mer-spacing--xl);border-block-end:var(--mer-border__width--sm) solid var(--mer-border-color__on-elevation--03);padding-block-end:var(--mer-spacing--sm)}.section-kbs__header--no-border{border-block-end-color:transparent !important}.section-kbs__title{align-items:center;display:flex;min-block-size:31px}.section-kbs__filter--hidden{opacity:0}.section-kbs__list{display:grid;grid-auto-rows:max-content;grid-template-columns:1fr 1fr;row-gap:var(--mer-spacing--xs);column-gap:var(--mer-spacing--md);overflow:auto;position:relative;padding-block-start:var(--mer-spacing--sm)}.section-kbs__list--empty{grid-template-columns:1fr;grid-auto-rows:1fr;overflow:hidden}.kb__item{background-color:var(--mer-surface__elevation--02);padding:var(--mer-spacing--sm);display:grid;grid-template-columns:284px 1fr;gap:var(--mer-spacing--md)}.kb__details{display:grid;grid-template-columns:max-content 1fr;align-items:center;gap:var(--mer-spacing--sm)}.kb__name{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;text-decoration:underline;cursor:pointer}.kb__name:hover{color:var(--mer-text__bright)}.kb__modified{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.hiChar{color:var(--mer-color__primary--200);filter:brightness(1.3)}.loader{border:var(--mer-border__width--sm) solid var(--mer-border-color__on-surface)}.heading-2,.heading-3{margin:0;font-weight:600 !important;color:#ffffff !important}.card-filled .heading-3{color:var(--mer-text__on-surface) !important}.text-body-regular-m,.card__footer{font-weight:var(--mer-font__weight--light) !important;--control__font-weight--regular:var(--mer-font__weight--light)}";
|
|
11
2506
|
|
|
12
2507
|
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13
2508
|
if (kind === "a" && !f)
|
|
@@ -25,7 +2520,34 @@ var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) ||
|
|
|
25
2520
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
26
2521
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
27
2522
|
};
|
|
28
|
-
var
|
|
2523
|
+
var _GxIdeStartPage_instances, _GxIdeStartPage_componentLocale, _GxIdeStartPage_userLanguage, _GxIdeStartPage_createKBClickHandler, _GxIdeStartPage_openKbClickHandler, _GxIdeStartPage_filterKbs, _GxIdeStartPage_renderKbsSection, _GxIdeStartPage_renderKbs, _GxIdeStartPage_evaluateContentToRender, _GxIdeStartPage_renderSecondarySection;
|
|
2524
|
+
// const locale = enUS; // use `zhCN` for Chinese, `ja` for Japanese, `enUS` for English
|
|
2525
|
+
const LANGS_DATE_FNS_MAP = {
|
|
2526
|
+
"en": enUS,
|
|
2527
|
+
"ja": ja,
|
|
2528
|
+
"zh-CN": zhCN,
|
|
2529
|
+
"zh-TW": zhCN,
|
|
2530
|
+
"zh-HK": zhCN
|
|
2531
|
+
};
|
|
2532
|
+
const DETAIL_ICON = getIconPath({
|
|
2533
|
+
category: "system",
|
|
2534
|
+
name: "detail",
|
|
2535
|
+
colorType: "primary"
|
|
2536
|
+
});
|
|
2537
|
+
const FILTER_ICON = getIconPath({
|
|
2538
|
+
category: "window-tools",
|
|
2539
|
+
name: "filter",
|
|
2540
|
+
colorType: "on-elevation"
|
|
2541
|
+
});
|
|
2542
|
+
const KB_DEFAULT_ICON = getIconPath({
|
|
2543
|
+
category: "objects",
|
|
2544
|
+
name: "knowledge-base"
|
|
2545
|
+
});
|
|
2546
|
+
const SEARCH_ICON = getIconPath({
|
|
2547
|
+
category: "system",
|
|
2548
|
+
name: "search",
|
|
2549
|
+
colorType: "on-elevation"
|
|
2550
|
+
});
|
|
29
2551
|
const CSS_BUNDLES = [
|
|
30
2552
|
"resets/box-sizing",
|
|
31
2553
|
"utils/typography",
|
|
@@ -33,156 +2555,167 @@ const CSS_BUNDLES = [
|
|
|
33
2555
|
"components/edit",
|
|
34
2556
|
"components/icon",
|
|
35
2557
|
"components/button",
|
|
36
|
-
"chameleon/scrollbar"
|
|
2558
|
+
"chameleon/scrollbar",
|
|
2559
|
+
"utils/typography"
|
|
37
2560
|
];
|
|
38
|
-
const KB_ICON = getIconPath({
|
|
39
|
-
category: "objects",
|
|
40
|
-
name: "knowledge-base"
|
|
41
|
-
});
|
|
42
|
-
const FOLDER_ICON = getIconPath({
|
|
43
|
-
category: "system",
|
|
44
|
-
name: "folder",
|
|
45
|
-
colorType: "on-elevation"
|
|
46
|
-
});
|
|
47
2561
|
const GxIdeStartPage$1 = /*@__PURE__*/ proxyCustomElement(class GxIdeStartPage extends HTMLElement {
|
|
48
2562
|
constructor() {
|
|
49
2563
|
super();
|
|
50
2564
|
this.__registerHost();
|
|
51
2565
|
this.__attachShadow();
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
_GxIdeStartPage_filterKbs.set(this, () => {
|
|
65
|
-
this.filteredKbs = this.kbs.filter(kb => { var _a; return (_a = kb.name) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(__classPrivateFieldGet(this, _GxIdeStartPage_kbsFilterValue, "f")); });
|
|
2566
|
+
_GxIdeStartPage_instances.add(this);
|
|
2567
|
+
/**
|
|
2568
|
+
* The component hard-coded strings translations.
|
|
2569
|
+
*/
|
|
2570
|
+
// eslint-disable-next-line @stencil-community/own-props-must-be-private
|
|
2571
|
+
_GxIdeStartPage_componentLocale.set(this, void 0);
|
|
2572
|
+
_GxIdeStartPage_userLanguage.set(this, void 0);
|
|
2573
|
+
_GxIdeStartPage_createKBClickHandler.set(this, (fromServer) => (event) => {
|
|
2574
|
+
event.stopPropagation();
|
|
2575
|
+
this.createKBCallback(fromServer);
|
|
66
2576
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
resolve(this.news);
|
|
71
|
-
});
|
|
2577
|
+
_GxIdeStartPage_openKbClickHandler.set(this, (kbId) => (event) => {
|
|
2578
|
+
event.stopPropagation();
|
|
2579
|
+
this.openKbCallback(kbId);
|
|
72
2580
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
await this.openKbCallback(kbId);
|
|
2581
|
+
_GxIdeStartPage_filterKbs.set(this, (event) => {
|
|
2582
|
+
this.kbFilterValue = event.detail;
|
|
76
2583
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
2584
|
+
_GxIdeStartPage_renderKbsSection.set(this, () => {
|
|
2585
|
+
const hideKbsFilter = this.kbs.length < this.kbsFilterThreshold;
|
|
2586
|
+
const kbsListEmpty = this.filteredKbs.length === 0;
|
|
2587
|
+
let contentToRender;
|
|
2588
|
+
// Evaluate what is the content to display.
|
|
2589
|
+
if (this.filteredKbs.length > 0) {
|
|
2590
|
+
contentToRender = __classPrivateFieldGet(this, _GxIdeStartPage_renderKbs, "f").call(this);
|
|
2591
|
+
}
|
|
2592
|
+
else {
|
|
2593
|
+
// No kb has pass the filter. Display an empty-state.
|
|
2594
|
+
contentToRender = (h("gx-ide-empty-state", { isAnimated: true, stateIconSrc: FILTER_ICON, stateTitle: __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.noMatches }));
|
|
2595
|
+
}
|
|
2596
|
+
return (h("section", { class: "section-kbs" }, h("header", { class: {
|
|
2597
|
+
"section-kbs__header": true
|
|
2598
|
+
} }, h("h2", { class: "heading-3 section-kbs__title" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.title), h("ch-edit", {
|
|
2599
|
+
// Render always, and display or hide, ro prevent FOUC, and also prevent
|
|
2600
|
+
// the header block-size from growing a little bit when the input renders.
|
|
2601
|
+
value: this.kbFilterValue, class: {
|
|
2602
|
+
"input": true,
|
|
2603
|
+
"section-kbs__filter--hidden": hideKbsFilter
|
|
2604
|
+
}, startImgSrc: SEARCH_ICON, placeholder: __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.filterKbsPlaceholder, onInput: !hideKbsFilter && __classPrivateFieldGet(this, _GxIdeStartPage_filterKbs, "f"), disabled: hideKbsFilter
|
|
2605
|
+
})), h("div", { class: {
|
|
2606
|
+
"section-kbs__list": true,
|
|
2607
|
+
"section-kbs__list--empty": kbsListEmpty,
|
|
2608
|
+
"scrollable": true
|
|
2609
|
+
} }, this.filteredKbs.length > 0 ? __classPrivateFieldGet(this, _GxIdeStartPage_renderKbs, "f").call(this) : contentToRender)));
|
|
90
2610
|
});
|
|
91
2611
|
_GxIdeStartPage_renderKbs.set(this, () => {
|
|
92
2612
|
var _a;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
2613
|
+
return (_a = this.filteredKbs) === null || _a === void 0 ? void 0 : _a.map((kb, index) => {
|
|
2614
|
+
// relative time ago
|
|
2615
|
+
var _a;
|
|
2616
|
+
const relativeDate = kb.lastOpenedDate
|
|
2617
|
+
? formatDistanceToNow(new Date(kb.lastOpenedDate), {
|
|
2618
|
+
addSuffix: true,
|
|
2619
|
+
locale: __classPrivateFieldGet(this, _GxIdeStartPage_userLanguage, "f")
|
|
2620
|
+
})
|
|
2621
|
+
: undefined;
|
|
2622
|
+
// icon
|
|
2623
|
+
const kbIcon = (_a = kb.icon) !== null && _a !== void 0 ? _a : KB_DEFAULT_ICON;
|
|
2624
|
+
return (h("article", { class: "kb__item", key: index }, h("div", { class: "kb__details" }, h("ch-image", { class: "icon-md", src: kbIcon }), h("p", { class: "text-body-regular-m kb__name", onClick: __classPrivateFieldGet(this, _GxIdeStartPage_openKbClickHandler, "f").call(this, kb.id) }, kb.name)), relativeDate && (h("div", { class: "text-body-regular-m kb__modified" }, `${__classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.opened} ${relativeDate}`))));
|
|
2625
|
+
});
|
|
101
2626
|
});
|
|
102
|
-
|
|
103
|
-
this.
|
|
2627
|
+
_GxIdeStartPage_renderSecondarySection.set(this, () => {
|
|
2628
|
+
if (!this.secondarySection) {
|
|
2629
|
+
return null;
|
|
2630
|
+
}
|
|
2631
|
+
const multipleCards = this.secondarySection.cards.length > 2;
|
|
2632
|
+
return (h("section", {
|
|
2633
|
+
// Recent Knowledge Bases
|
|
2634
|
+
class: "section-secondary"
|
|
2635
|
+
}, h("header", null, h("h2", { class: "heading-3" }, this.secondarySection.title)), h("section", { class: {
|
|
2636
|
+
"section-secondary__actions": true,
|
|
2637
|
+
"section-secondary__actions--two-cards": !multipleCards,
|
|
2638
|
+
"section-secondary__actions--multiple-cards": multipleCards,
|
|
2639
|
+
"scrollable": true
|
|
2640
|
+
} }, this.secondarySection.cards.map((card, index) => {
|
|
2641
|
+
return (h("article", { class: "card card-outlined", key: index }, h("header", { class: "card__header" }, h("span", { class: "icon-capsule" }, h("ch-image", { class: "icon-md icon-circular", src: card.icon.src, "aria-label": card.icon.ariaLabel })), h("div", { class: "card__header-description" }, h("h2", { class: "heading-3" }, card.title), card.description.map(paragraph => (h("p", { class: "text-body-regular-m" }, paragraph))))), h("footer", { class: "card__footer" }, card.action && (h("button", { class: "button-tertiary button-icon-and-text", onClick: card.action.callback && card.action.callback }, h("ch-image", { class: "icon-md", src: DETAIL_ICON }), card.action.caption)))));
|
|
2642
|
+
}))));
|
|
104
2643
|
});
|
|
105
|
-
this.
|
|
106
|
-
this.
|
|
107
|
-
this.
|
|
108
|
-
this.
|
|
109
|
-
this.loadingKbs = true;
|
|
110
|
-
this.news = undefined;
|
|
111
|
-
this.newsFilterValue = undefined;
|
|
112
|
-
this.renderedFirstTime = false;
|
|
113
|
-
this.getNewsCallback = undefined;
|
|
114
|
-
this.kbs = [];
|
|
115
|
-
this.kbsFilterThreshold = 6;
|
|
116
|
-
this.newsFilterThreshold = 6;
|
|
2644
|
+
this.kbFilterValue = "";
|
|
2645
|
+
this.filteredKbs = undefined;
|
|
2646
|
+
this.loading = true;
|
|
2647
|
+
this.createKBCallback = undefined;
|
|
117
2648
|
this.openKbCallback = undefined;
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if ((news === null || news === void 0 ? void 0 : news.length) >= this.newsFilterThreshold) {
|
|
122
|
-
this.displayNewsFilter = true;
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
this.displayNewsFilter = false;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
kbsChanged(kbs) {
|
|
129
|
-
this.loadingKbs = false;
|
|
130
|
-
__classPrivateFieldGet(this, _GxIdeStartPage_filterKbs, "f").call(this);
|
|
131
|
-
if ((kbs === null || kbs === void 0 ? void 0 : kbs.length) >= this.kbsFilterThreshold) {
|
|
132
|
-
this.displayKbsFilter = true;
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.displayKbsFilter = false;
|
|
136
|
-
}
|
|
2649
|
+
this.secondarySection = undefined;
|
|
2650
|
+
this.kbs = undefined;
|
|
2651
|
+
this.kbsFilterThreshold = undefined;
|
|
137
2652
|
}
|
|
138
|
-
|
|
139
|
-
this.
|
|
2653
|
+
kbFilterValueChanged(newKbFilterValue) {
|
|
2654
|
+
this.filteredKbs = this.kbs.filter(kb => kb.name.toLowerCase().includes(newKbFilterValue.toLocaleLowerCase()));
|
|
140
2655
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
2656
|
+
kbsChanged(newKbs) {
|
|
2657
|
+
this.filteredKbs = newKbs;
|
|
2658
|
+
this.kbFilterValue = ""; // clear filter
|
|
2659
|
+
}
|
|
2660
|
+
async componentWillLoad() {
|
|
2661
|
+
__classPrivateFieldSet(this, _GxIdeStartPage_componentLocale, await Locale.getComponentStrings(this.el), "f");
|
|
2662
|
+
// initialize filteredKbs
|
|
2663
|
+
this.kbsChanged(this.kbs);
|
|
2664
|
+
// get user language to display the kb "last opened" value in the appropriate language.
|
|
2665
|
+
const userLanguage = document.documentElement
|
|
2666
|
+
.lang;
|
|
2667
|
+
__classPrivateFieldSet(this, _GxIdeStartPage_userLanguage, LANGS_DATE_FNS_MAP[userLanguage], "f");
|
|
144
2668
|
}
|
|
145
2669
|
render() {
|
|
146
|
-
var _a
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
2670
|
+
var _a;
|
|
2671
|
+
this.loading =
|
|
2672
|
+
(!this.kbs || ((_a = this.kbs) === null || _a === void 0 ? void 0 : _a.length) === 0) && !this.secondarySection;
|
|
2673
|
+
return (h(Host, null, h("ch-theme", { model: CSS_BUNDLES }), h("main", { class: {
|
|
2674
|
+
main: true
|
|
2675
|
+
} }, h("section", {
|
|
2676
|
+
// Create a new Knowledge Base
|
|
2677
|
+
class: "section-create-new-kb"
|
|
2678
|
+
}, h("header", {
|
|
2679
|
+
// main header
|
|
2680
|
+
class: "section-create-new__header"
|
|
2681
|
+
}, h("h1", { class: "heading-2" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").createKB.title), h("p", { class: "text-body-regular-m" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").createKB.description)), h("section", { class: "section-create-new-kb__actions scrollable" }, h("article", {
|
|
2682
|
+
// create project
|
|
2683
|
+
class: "card card-filled"
|
|
2684
|
+
}, h("header", { class: "card__header" }, h("div", { class: "card__header-description" }, h("h2", { class: "heading-3" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").createProject.title), h("p", { class: "text-body-regular-m" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").createProject.description))), h("footer", { class: "card__footer" }, h("button", { class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeStartPage_createKBClickHandler, "f").call(this, false) }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").createProject.buttonCaption))), h("article", {
|
|
2685
|
+
// open existing project
|
|
2686
|
+
class: "card-filled"
|
|
2687
|
+
}, h("header", { class: "card__header" }, h("div", { class: "card__header-description" }, h("h2", { class: "heading-3" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").openExistingProject.title), h("p", { class: "text-body-regular-m" }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").openExistingProject.description))), h("footer", { class: "card__footer" }, h("button", { class: "button-secondary cancel-btn", onClick: __classPrivateFieldGet(this, _GxIdeStartPage_createKBClickHandler, "f").call(this, true) }, __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").openExistingProject.buttonCaption))))), h("section", { class: "section-secondary scrollable" }, this.loading ? (h("gx-ide-loader", { class: "loader", loaderTitle: __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.loaderTitle, description: __classPrivateFieldGet(this, _GxIdeStartPage_componentLocale, "f").recentKBs.loaderDescription, show: true })) : (__classPrivateFieldGet(this, _GxIdeStartPage_instances, "m", _GxIdeStartPage_evaluateContentToRender).call(this))))));
|
|
153
2688
|
}
|
|
154
2689
|
static get assetsDirs() { return ["gx-ide-assets/start-page"]; }
|
|
155
2690
|
get el() { return this; }
|
|
156
2691
|
static get watchers() { return {
|
|
157
|
-
"
|
|
2692
|
+
"kbFilterValue": ["kbFilterValueChanged"],
|
|
158
2693
|
"kbs": ["kbsChanged"]
|
|
159
2694
|
}; }
|
|
160
2695
|
static get style() { return startPageCss; }
|
|
161
2696
|
}, [1, "gx-ide-start-page", {
|
|
162
|
-
"
|
|
2697
|
+
"createKBCallback": [16],
|
|
2698
|
+
"openKbCallback": [16],
|
|
2699
|
+
"secondarySection": [16],
|
|
163
2700
|
"kbs": [16],
|
|
164
2701
|
"kbsFilterThreshold": [2, "kbs-filter-threshold"],
|
|
165
|
-
"
|
|
166
|
-
"openKbCallback": [16],
|
|
167
|
-
"openNewsCallback": [16],
|
|
168
|
-
"displayKbsFilter": [32],
|
|
169
|
-
"displayNewsFilter": [32],
|
|
2702
|
+
"kbFilterValue": [32],
|
|
170
2703
|
"filteredKbs": [32],
|
|
171
|
-
"
|
|
172
|
-
"loadingKbs": [32],
|
|
173
|
-
"news": [32],
|
|
174
|
-
"newsFilterValue": [32],
|
|
175
|
-
"renderedFirstTime": [32]
|
|
2704
|
+
"loading": [32]
|
|
176
2705
|
}, undefined, {
|
|
177
|
-
"
|
|
2706
|
+
"kbFilterValue": ["kbFilterValueChanged"],
|
|
178
2707
|
"kbs": ["kbsChanged"]
|
|
179
2708
|
}]);
|
|
180
|
-
|
|
2709
|
+
_GxIdeStartPage_componentLocale = new WeakMap(), _GxIdeStartPage_userLanguage = new WeakMap(), _GxIdeStartPage_createKBClickHandler = new WeakMap(), _GxIdeStartPage_openKbClickHandler = new WeakMap(), _GxIdeStartPage_filterKbs = new WeakMap(), _GxIdeStartPage_renderKbsSection = new WeakMap(), _GxIdeStartPage_renderKbs = new WeakMap(), _GxIdeStartPage_renderSecondarySection = new WeakMap(), _GxIdeStartPage_instances = new WeakSet(), _GxIdeStartPage_evaluateContentToRender = function _GxIdeStartPage_evaluateContentToRender() {
|
|
2710
|
+
return this.kbs && this.kbs.length > 0
|
|
2711
|
+
? __classPrivateFieldGet(this, _GxIdeStartPage_renderKbsSection, "f").call(this)
|
|
2712
|
+
: __classPrivateFieldGet(this, _GxIdeStartPage_renderSecondarySection, "f").call(this);
|
|
2713
|
+
};
|
|
181
2714
|
function defineCustomElement$1() {
|
|
182
2715
|
if (typeof customElements === "undefined") {
|
|
183
2716
|
return;
|
|
184
2717
|
}
|
|
185
|
-
const components = ["gx-ide-start-page", "gx-ide-empty-state", "gx-ide-loader"
|
|
2718
|
+
const components = ["gx-ide-start-page", "gx-ide-empty-state", "gx-ide-loader"];
|
|
186
2719
|
components.forEach(tagName => { switch (tagName) {
|
|
187
2720
|
case "gx-ide-start-page":
|
|
188
2721
|
if (!customElements.get(tagName)) {
|
|
@@ -190,16 +2723,11 @@ function defineCustomElement$1() {
|
|
|
190
2723
|
}
|
|
191
2724
|
break;
|
|
192
2725
|
case "gx-ide-empty-state":
|
|
193
|
-
if (!customElements.get(tagName)) {
|
|
194
|
-
defineCustomElement$4();
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
case "gx-ide-loader":
|
|
198
2726
|
if (!customElements.get(tagName)) {
|
|
199
2727
|
defineCustomElement$3();
|
|
200
2728
|
}
|
|
201
2729
|
break;
|
|
202
|
-
case "gx-ide-
|
|
2730
|
+
case "gx-ide-loader":
|
|
203
2731
|
if (!customElements.get(tagName)) {
|
|
204
2732
|
defineCustomElement$2();
|
|
205
2733
|
}
|