ngwr 16.0.0 → 16.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/badge/styles/_tag.scss +8 -4
- package/button/styles/_index.scss +13 -7
- package/cascader/styles/_rules.scss +4 -2
- package/checkbox/styles/_index.scss +4 -2
- package/date-picker/styles/_index.scss +95 -3
- package/date-stamp/styles/_index.scss +38 -0
- package/dialog/styles/_index.scss +38 -0
- package/dropdown/styles/_index.scss +37 -1
- package/fesm2022/internal-CVLvP9b_.mjs +33 -0
- package/fesm2022/internal-CVLvP9b_.mjs.map +1 -0
- package/fesm2022/ngwr-alert.mjs +11 -7
- package/fesm2022/ngwr-alert.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +11 -7
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +10 -6
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-badge.mjs +18 -6
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +9 -6
- package/fesm2022/ngwr-burger.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +8 -4
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +19 -8
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +9 -5
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +11 -5
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +5 -2
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +10 -6
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +2 -1
- package/fesm2022/ngwr-clipboard.mjs.map +1 -1
- package/fesm2022/ngwr-collapse.mjs +9 -5
- package/fesm2022/ngwr-collapse.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +4 -2
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-comment.mjs +13 -7
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +9 -3
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +4 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +11 -6
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs +18 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +238 -38
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +34 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -0
- package/fesm2022/ngwr-date-stamp.mjs +213 -0
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -0
- package/fesm2022/ngwr-date.mjs +364 -54
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +9 -5
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog-testing.mjs +23 -2
- package/fesm2022/ngwr-dialog-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +45 -16
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +102 -11
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +4 -2
- package/fesm2022/ngwr-divider.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +29 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs +38 -3
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +362 -26
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +5 -2
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +4 -2
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +9 -3
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +18 -6
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +9 -2
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +9 -2
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +9 -2
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +9 -2
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +9 -2
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +9 -2
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +9 -2
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +9 -2
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +9 -2
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +9 -2
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +9 -2
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +9 -2
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +9 -2
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +9 -2
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +9 -2
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +9 -2
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +9 -2
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +9 -2
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +9 -2
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +9 -2
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +34 -8
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +9 -3
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +4 -2
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +20 -10
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +9 -3
- package/fesm2022/ngwr-keyboard.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +9 -3
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs +13 -5
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox-testing.mjs +26 -0
- package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +255 -15
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +13 -5
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +9 -5
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +84 -1
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +3 -2
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +47 -9
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +93 -4
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +4 -2
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +9 -5
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +9 -3
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-resizable.mjs +503 -0
- package/fesm2022/ngwr-resizable.mjs.map +1 -0
- package/fesm2022/ngwr-result.mjs +9 -5
- package/fesm2022/ngwr-result.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +3 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +4 -2
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +13 -5
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +4 -2
- package/fesm2022/ngwr-skeleton.mjs.map +1 -1
- package/fesm2022/ngwr-slider-testing.mjs +17 -0
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +91 -13
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list-testing.mjs +103 -0
- package/fesm2022/ngwr-sortable-list-testing.mjs.map +1 -0
- package/fesm2022/ngwr-sortable-list.mjs +257 -53
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +4 -2
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spinner.mjs +4 -2
- package/fesm2022/ngwr-spinner.mjs.map +1 -1
- package/fesm2022/ngwr-splitter.mjs +17 -21
- package/fesm2022/ngwr-splitter.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +9 -3
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +9 -5
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-testing.mjs +5 -1
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +167 -10
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +9 -3
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +18 -8
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toast-testing.mjs +6 -1
- package/fesm2022/ngwr-toast-testing.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +529 -104
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +4 -2
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +4 -2
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +9 -3
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs +18 -2
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +9 -2
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +7 -4
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/fesm2022/ngwr.mjs.map +1 -1
- package/i18n/ar.json +13 -2
- package/i18n/cs.json +13 -2
- package/i18n/de.json +13 -2
- package/i18n/en.json +13 -2
- package/i18n/es.json +13 -2
- package/i18n/fr.json +13 -2
- package/i18n/he.json +13 -2
- package/i18n/hi.json +13 -2
- package/i18n/id.json +13 -2
- package/i18n/it.json +13 -2
- package/i18n/ja.json +13 -2
- package/i18n/ko.json +13 -2
- package/i18n/nl.json +13 -2
- package/i18n/pl.json +13 -2
- package/i18n/pt.json +13 -2
- package/i18n/ru.json +13 -2
- package/i18n/sv.json +13 -2
- package/i18n/tr.json +13 -2
- package/i18n/uk.json +13 -2
- package/i18n/vi.json +13 -2
- package/i18n/zh-TW.json +13 -2
- package/i18n/zh.json +13 -2
- package/input/styles/_index.scss +10 -5
- package/input-number/styles/_index.scss +6 -3
- package/input-otp/styles/_index.scss +4 -2
- package/lightbox/styles/_rules.scss +96 -0
- package/llms-full.txt +40 -17
- package/llms.txt +20 -4
- package/package.json +19 -1
- package/radio/styles/_index.scss +4 -2
- package/resizable/styles/_index.scss +154 -0
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +5 -0
- package/select/styles/_index.scss +6 -3
- package/skills/ngwr/SKILL.md +1 -1
- package/skills/ngwr/references/catalog.md +6 -2
- package/skills/ngwr/references/setup.md +3 -0
- package/slider/styles/_index.scss +106 -0
- package/sortable-list/styles/_rules.scss +23 -1
- package/switch/styles/_index.scss +4 -2
- package/table/styles/_index.scss +53 -0
- package/textarea/styles/_index.scss +4 -2
- package/theme/styles/_motion.scss +6 -0
- package/toast/styles/_index.scss +19 -0
- package/types/ngwr-burger.d.ts +0 -1
- package/types/ngwr-calendar.d.ts +7 -0
- package/types/ngwr-charts-calendar-heatmap.d.ts +2 -1
- package/types/ngwr-clipboard.d.ts +7 -0
- package/types/ngwr-date-picker-testing.d.ts +17 -0
- package/types/ngwr-date-picker.d.ts +88 -4
- package/types/ngwr-date-stamp-testing.d.ts +47 -0
- package/types/ngwr-date-stamp.d.ts +127 -0
- package/types/ngwr-date.d.ts +251 -37
- package/types/ngwr-dialog-testing.d.ts +10 -0
- package/types/ngwr-dialog.d.ts +72 -4
- package/types/ngwr-directives.d.ts +36 -1
- package/types/ngwr-drawer.d.ts +21 -0
- package/types/ngwr-dropdown-testing.d.ts +53 -5
- package/types/ngwr-dropdown.d.ts +100 -0
- package/types/ngwr-i18n.d.ts +44 -14
- package/types/ngwr-lightbox-testing.d.ts +27 -0
- package/types/ngwr-lightbox.d.ts +71 -6
- package/types/ngwr-overlay.d.ts +36 -0
- package/types/ngwr-pipes.d.ts +48 -13
- package/types/ngwr-popover.d.ts +39 -1
- package/types/ngwr-resizable.d.ts +228 -0
- package/types/ngwr-slider-testing.d.ts +8 -1
- package/types/ngwr-slider.d.ts +89 -3
- package/types/ngwr-sortable-list-testing.d.ts +79 -0
- package/types/ngwr-sortable-list.d.ts +113 -10
- package/types/ngwr-table-testing.d.ts +3 -1
- package/types/ngwr-table.d.ts +120 -4
- package/types/ngwr-toast-testing.d.ts +12 -1
- package/types/ngwr-toast.d.ts +215 -18
- package/types/ngwr-utils-router.d.ts +22 -0
- package/types/ngwr-utils.d.ts +8 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr.d.ts +1 -0
package/fesm2022/ngwr-date.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { Injectable, InjectionToken, LOCALE_ID, Service, forwardRef, inject } from "@angular/core";
|
|
3
|
-
import { wrFeature } from "ngwr/utils";
|
|
2
|
+
import { Injectable, InjectionToken, Injector, LOCALE_ID, Service, computed, forwardRef, inject, isDevMode, runInInjectionContext } from "@angular/core";
|
|
3
|
+
import { WR_LIVE_LOCALE, wrFeature } from "ngwr/utils";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
*
|
|
@@ -17,6 +17,143 @@ const WR_DATE_LOCALE = new InjectionToken("WR_DATE_LOCALE", {
|
|
|
17
17
|
* Use of this source code is governed by an MIT-style license that can be
|
|
18
18
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
19
19
|
*/
|
|
20
|
+
const WR_DATE_TIME_ZONE = new InjectionToken("WR_DATE_TIME_ZONE", {
|
|
21
|
+
providedIn: "root",
|
|
22
|
+
factory: () => null
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* @license
|
|
26
|
+
*
|
|
27
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
28
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
29
|
+
*/
|
|
30
|
+
const WR_DATE_INPUT = new InjectionToken("WR_DATE_INPUT", {
|
|
31
|
+
providedIn: "root",
|
|
32
|
+
factory: () => ({
|
|
33
|
+
epochUnit: "ms",
|
|
34
|
+
zonelessIn: "browser"
|
|
35
|
+
})
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* @license
|
|
39
|
+
*
|
|
40
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
41
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
42
|
+
*/
|
|
43
|
+
const WR_DATE_STAMP_DEFAULTS = new InjectionToken("WR_DATE_STAMP_DEFAULTS", {
|
|
44
|
+
providedIn: "root",
|
|
45
|
+
factory: () => ({})
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* @license
|
|
49
|
+
*
|
|
50
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
51
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
52
|
+
*/
|
|
53
|
+
const WR_DATE_LOCALE_PINNED = new InjectionToken("WR_DATE_LOCALE_PINNED", {
|
|
54
|
+
providedIn: "root",
|
|
55
|
+
factory: () => false
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* @license
|
|
59
|
+
*
|
|
60
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
61
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
62
|
+
*/
|
|
63
|
+
function isLocaleTag(tag) {
|
|
64
|
+
try {
|
|
65
|
+
return Intl.getCanonicalLocales(tag).length > 0;
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function wrDateLocale() {
|
|
71
|
+
const fixed = inject(WR_DATE_LOCALE);
|
|
72
|
+
const live = inject(WR_DATE_LOCALE_PINNED) ? null : inject(WR_LIVE_LOCALE, { optional: true });
|
|
73
|
+
if (!live) return computed(() => fixed);
|
|
74
|
+
return computed(() => {
|
|
75
|
+
const tag = live();
|
|
76
|
+
return isLocaleTag(tag) ? tag : fixed;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @license
|
|
81
|
+
*
|
|
82
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
83
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
84
|
+
*/
|
|
85
|
+
const OFFSET = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
86
|
+
const MINUTE = 6e4;
|
|
87
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
88
|
+
function wrUtcTime(year, month, day, hours = 0, minutes = 0, seconds = 0, millis = 0) {
|
|
89
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
90
|
+
date.setUTCFullYear(year, month, day);
|
|
91
|
+
date.setUTCHours(hours, minutes, seconds, millis);
|
|
92
|
+
return date.getTime();
|
|
93
|
+
}
|
|
94
|
+
function wrResolveZone(value) {
|
|
95
|
+
const id = value?.trim();
|
|
96
|
+
if (!id) return null;
|
|
97
|
+
const known = resolved.get(id);
|
|
98
|
+
if (known !== void 0) return known;
|
|
99
|
+
let zone = null;
|
|
100
|
+
const offset = OFFSET.exec(id);
|
|
101
|
+
if (offset) {
|
|
102
|
+
const hours = Number(offset[2]);
|
|
103
|
+
const minutes = Number(offset[3] ?? 0);
|
|
104
|
+
if (hours <= 23 && minutes <= 59) zone = {
|
|
105
|
+
kind: "offset",
|
|
106
|
+
id,
|
|
107
|
+
minutes: (offset[1] === "-" ? -1 : 1) * (hours * 60 + minutes)
|
|
108
|
+
};
|
|
109
|
+
} else try {
|
|
110
|
+
zone = {
|
|
111
|
+
kind: "iana",
|
|
112
|
+
id,
|
|
113
|
+
fields: new Intl.DateTimeFormat("en-US", {
|
|
114
|
+
timeZone: id,
|
|
115
|
+
calendar: "gregory",
|
|
116
|
+
numberingSystem: "latn",
|
|
117
|
+
hourCycle: "h23",
|
|
118
|
+
year: "numeric",
|
|
119
|
+
month: "numeric",
|
|
120
|
+
day: "numeric",
|
|
121
|
+
hour: "numeric",
|
|
122
|
+
minute: "numeric",
|
|
123
|
+
second: "numeric"
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
} catch {}
|
|
127
|
+
if (!zone && isDevMode()) console.warn(`[NGWR] withDates({ timeZone }) got '${id}', which is neither an IANA time zone this browser knows nor an offset such as '+05:00'. Dates are shown in the browser's own time zone.`);
|
|
128
|
+
resolved.set(id, zone);
|
|
129
|
+
return zone;
|
|
130
|
+
}
|
|
131
|
+
function wrZoneWallTime(time, zone) {
|
|
132
|
+
if (!zone) return time - new Date(time).getTimezoneOffset() * MINUTE;
|
|
133
|
+
if (zone.kind === "offset") return time + zone.minutes * MINUTE;
|
|
134
|
+
const read = {};
|
|
135
|
+
for (const part of zone.fields.formatToParts(time)) read[part.type] = Number(part.value);
|
|
136
|
+
const millis = (time % 1e3 + 1e3) % 1e3;
|
|
137
|
+
return wrUtcTime(read["year"], read["month"] - 1, read["day"], read["hour"], read["minute"], read["second"], millis);
|
|
138
|
+
}
|
|
139
|
+
function wrZoneInstant(wall, zone) {
|
|
140
|
+
if (!zone) {
|
|
141
|
+
const w = new Date(wall);
|
|
142
|
+
const local = /* @__PURE__ */ new Date(0);
|
|
143
|
+
local.setFullYear(w.getUTCFullYear(), w.getUTCMonth(), w.getUTCDate());
|
|
144
|
+
local.setHours(w.getUTCHours(), w.getUTCMinutes(), w.getUTCSeconds(), w.getUTCMilliseconds());
|
|
145
|
+
return local.getTime();
|
|
146
|
+
}
|
|
147
|
+
if (zone.kind === "offset") return wall - zone.minutes * MINUTE;
|
|
148
|
+
const first = wall - (wrZoneWallTime(wall, zone) - wall);
|
|
149
|
+
return wall - (wrZoneWallTime(first, zone) - first);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* @license
|
|
153
|
+
*
|
|
154
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
155
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
156
|
+
*/
|
|
20
157
|
const BIDI_RE = /[\u200e\u200f\u061c\u2066-\u2069]/g;
|
|
21
158
|
const REGEX_META_RE = /[.*+?^${}()|[\]\\]/g;
|
|
22
159
|
function stripBidi(value) {
|
|
@@ -161,7 +298,7 @@ const INTL_OPTIONS = {
|
|
|
161
298
|
}
|
|
162
299
|
};
|
|
163
300
|
const NAMED_KEYS = new Set(Object.keys(INTL_OPTIONS));
|
|
164
|
-
const PART_RE = /'((?:[^']|'')*)'|yyyy|yy|MMMM|MMM|MM|M|dd|d|HH|H|hh|h|mm|ss|a/g;
|
|
301
|
+
const PART_RE = /'((?:[^']|'')*)'|yyyy|yy|y|MMMM|MMM|MM|M|dd|d|HH|H|hh|h|mm|ss|a/g;
|
|
165
302
|
function unquote(quoted) {
|
|
166
303
|
return quoted === "" ? "'" : quoted.replaceAll("''", "'");
|
|
167
304
|
}
|
|
@@ -175,6 +312,7 @@ function tokenToRegex(token, digits) {
|
|
|
175
312
|
switch (token) {
|
|
176
313
|
case "yyyy": return `(${digits}{4})`;
|
|
177
314
|
case "yy": return `(${digits}{2})`;
|
|
315
|
+
case "y": return `(${digits}{1,6})`;
|
|
178
316
|
case "MM":
|
|
179
317
|
case "dd":
|
|
180
318
|
case "HH":
|
|
@@ -193,6 +331,15 @@ var WrDateAdapter = class WrDateAdapter {
|
|
|
193
331
|
isWithinRange(date, start, end) {
|
|
194
332
|
return this.compareDate(date, start) >= 0 && this.compareDate(date, end) <= 0;
|
|
195
333
|
}
|
|
334
|
+
zoned() {
|
|
335
|
+
return this;
|
|
336
|
+
}
|
|
337
|
+
displayKey() {
|
|
338
|
+
return "";
|
|
339
|
+
}
|
|
340
|
+
parseOptions() {
|
|
341
|
+
return {};
|
|
342
|
+
}
|
|
196
343
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
197
344
|
minVersion: "12.0.0",
|
|
198
345
|
version: "22.2.5",
|
|
@@ -224,7 +371,70 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
224
371
|
}]
|
|
225
372
|
});
|
|
226
373
|
var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
227
|
-
|
|
374
|
+
localeSource = wrDateLocale();
|
|
375
|
+
cache = null;
|
|
376
|
+
caches() {
|
|
377
|
+
const locale = this.localeSource();
|
|
378
|
+
if (this.cache?.locale !== locale) this.cache = {
|
|
379
|
+
locale,
|
|
380
|
+
formatters: /* @__PURE__ */ new Map(),
|
|
381
|
+
monthNames: /* @__PURE__ */ new Map(),
|
|
382
|
+
namedParsers: /* @__PURE__ */ new Map(),
|
|
383
|
+
numerals: null,
|
|
384
|
+
dayPeriods: null
|
|
385
|
+
};
|
|
386
|
+
return this.cache;
|
|
387
|
+
}
|
|
388
|
+
get locale() {
|
|
389
|
+
return this.caches().locale;
|
|
390
|
+
}
|
|
391
|
+
zoneSource = inject(WR_DATE_TIME_ZONE);
|
|
392
|
+
injector = inject(Injector);
|
|
393
|
+
zonal = false;
|
|
394
|
+
zonedSelf = null;
|
|
395
|
+
zoned() {
|
|
396
|
+
if (this.zonal || !this.zoneSource) return this;
|
|
397
|
+
this.zonedSelf ??= runInInjectionContext(this.injector, () => {
|
|
398
|
+
const zoned = new this.constructor();
|
|
399
|
+
zoned.zonal = true;
|
|
400
|
+
return zoned;
|
|
401
|
+
});
|
|
402
|
+
return this.zonedSelf;
|
|
403
|
+
}
|
|
404
|
+
displayKey() {
|
|
405
|
+
return `${this.locale}|${this.zonal ? this.zone()?.id ?? "" : ""}`;
|
|
406
|
+
}
|
|
407
|
+
input = inject(WR_DATE_INPUT);
|
|
408
|
+
parseOptions() {
|
|
409
|
+
return {
|
|
410
|
+
...this.input,
|
|
411
|
+
timeZone: this.zoneSource?.() ?? null
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
zone() {
|
|
415
|
+
return wrResolveZone(this.zoneSource?.());
|
|
416
|
+
}
|
|
417
|
+
wallZone = null;
|
|
418
|
+
walls = /* @__PURE__ */ new Map();
|
|
419
|
+
wall(date) {
|
|
420
|
+
if (!this.zonal) return null;
|
|
421
|
+
const zone = this.zone();
|
|
422
|
+
const time = date.getTime();
|
|
423
|
+
if (zone?.kind !== "iana" || Number.isNaN(time)) return new Date(wrZoneWallTime(time, zone));
|
|
424
|
+
if (this.wallZone !== zone || this.walls.size > 512) {
|
|
425
|
+
this.walls.clear();
|
|
426
|
+
this.wallZone = zone;
|
|
427
|
+
}
|
|
428
|
+
let wall = this.walls.get(time);
|
|
429
|
+
if (wall === void 0) {
|
|
430
|
+
wall = wrZoneWallTime(time, zone);
|
|
431
|
+
this.walls.set(time, wall);
|
|
432
|
+
}
|
|
433
|
+
return new Date(wall);
|
|
434
|
+
}
|
|
435
|
+
instant(wall) {
|
|
436
|
+
return new Date(wrZoneInstant(wall.getTime(), this.zone()));
|
|
437
|
+
}
|
|
228
438
|
today() {
|
|
229
439
|
return /* @__PURE__ */ new Date();
|
|
230
440
|
}
|
|
@@ -232,6 +442,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
232
442
|
return new Date(date.getTime());
|
|
233
443
|
}
|
|
234
444
|
createDate(year, month, day) {
|
|
445
|
+
if (this.zonal) return this.instant(new Date(wrUtcTime(year, month, day)));
|
|
235
446
|
const d = new Date(year, month, day);
|
|
236
447
|
if (year >= 0 && year < 100) d.setFullYear(year);
|
|
237
448
|
return d;
|
|
@@ -240,35 +451,48 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
240
451
|
return date instanceof Date && !Number.isNaN(date.getTime());
|
|
241
452
|
}
|
|
242
453
|
getYear(date) {
|
|
243
|
-
return date.getFullYear();
|
|
454
|
+
return this.wall(date)?.getUTCFullYear() ?? date.getFullYear();
|
|
244
455
|
}
|
|
245
456
|
getMonth(date) {
|
|
246
|
-
return date.getMonth();
|
|
457
|
+
return this.wall(date)?.getUTCMonth() ?? date.getMonth();
|
|
247
458
|
}
|
|
248
459
|
getDate(date) {
|
|
249
|
-
return date.getDate();
|
|
460
|
+
return this.wall(date)?.getUTCDate() ?? date.getDate();
|
|
250
461
|
}
|
|
251
462
|
getDayOfWeek(date) {
|
|
252
|
-
return date.getDay();
|
|
463
|
+
return this.wall(date)?.getUTCDay() ?? date.getDay();
|
|
253
464
|
}
|
|
254
465
|
getDaysInMonth(date) {
|
|
255
|
-
return new Date(
|
|
466
|
+
return new Date(this.getYear(date), this.getMonth(date) + 1, 0).getDate();
|
|
256
467
|
}
|
|
257
468
|
getHours(date) {
|
|
258
|
-
return date.getHours();
|
|
469
|
+
return this.wall(date)?.getUTCHours() ?? date.getHours();
|
|
259
470
|
}
|
|
260
471
|
getMinutes(date) {
|
|
261
|
-
return date.getMinutes();
|
|
472
|
+
return this.wall(date)?.getUTCMinutes() ?? date.getMinutes();
|
|
262
473
|
}
|
|
263
474
|
getSeconds(date) {
|
|
264
|
-
return date.getSeconds();
|
|
475
|
+
return this.wall(date)?.getUTCSeconds() ?? date.getSeconds();
|
|
265
476
|
}
|
|
266
477
|
addYears(date, amount) {
|
|
478
|
+
const wall = this.wall(date);
|
|
479
|
+
if (wall) {
|
|
480
|
+
wall.setUTCFullYear(wall.getUTCFullYear() + amount);
|
|
481
|
+
return this.instant(wall);
|
|
482
|
+
}
|
|
267
483
|
const d = this.clone(date);
|
|
268
484
|
d.setFullYear(d.getFullYear() + amount);
|
|
269
485
|
return d;
|
|
270
486
|
}
|
|
271
487
|
addMonths(date, amount) {
|
|
488
|
+
const wall = this.wall(date);
|
|
489
|
+
if (wall) {
|
|
490
|
+
const day = wall.getUTCDate();
|
|
491
|
+
wall.setUTCDate(1);
|
|
492
|
+
wall.setUTCMonth(wall.getUTCMonth() + amount);
|
|
493
|
+
wall.setUTCDate(Math.min(day, new Date(wall.getUTCFullYear(), wall.getUTCMonth() + 1, 0).getDate()));
|
|
494
|
+
return this.instant(wall);
|
|
495
|
+
}
|
|
272
496
|
const d = this.clone(date);
|
|
273
497
|
const desiredDay = d.getDate();
|
|
274
498
|
d.setDate(1);
|
|
@@ -277,32 +501,45 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
277
501
|
return d;
|
|
278
502
|
}
|
|
279
503
|
addDays(date, amount) {
|
|
504
|
+
const wall = this.wall(date);
|
|
505
|
+
if (wall) {
|
|
506
|
+
wall.setUTCDate(wall.getUTCDate() + amount);
|
|
507
|
+
return this.instant(wall);
|
|
508
|
+
}
|
|
280
509
|
const d = this.clone(date);
|
|
281
510
|
d.setDate(d.getDate() + amount);
|
|
282
511
|
return d;
|
|
283
512
|
}
|
|
284
513
|
setTime(date, hours, minutes, seconds) {
|
|
514
|
+
const wall = this.wall(date);
|
|
515
|
+
if (wall) {
|
|
516
|
+
wall.setUTCHours(hours, minutes, seconds, 0);
|
|
517
|
+
return this.instant(wall);
|
|
518
|
+
}
|
|
285
519
|
const d = this.clone(date);
|
|
286
520
|
d.setHours(hours, minutes, seconds, 0);
|
|
287
521
|
return d;
|
|
288
522
|
}
|
|
289
523
|
isSameDay(a, b) {
|
|
290
|
-
return
|
|
524
|
+
return this.compareDate(a, b) === 0;
|
|
291
525
|
}
|
|
292
526
|
isSameMonth(a, b) {
|
|
293
|
-
return
|
|
527
|
+
return this.getYear(a) === this.getYear(b) && this.getMonth(a) === this.getMonth(b);
|
|
294
528
|
}
|
|
295
529
|
compareDate(a, b) {
|
|
296
|
-
const ay =
|
|
297
|
-
const by =
|
|
530
|
+
const ay = this.getYear(a);
|
|
531
|
+
const by = this.getYear(b);
|
|
298
532
|
if (ay !== by) return ay - by;
|
|
299
|
-
const am =
|
|
300
|
-
const bm =
|
|
533
|
+
const am = this.getMonth(a);
|
|
534
|
+
const bm = this.getMonth(b);
|
|
301
535
|
if (am !== bm) return am - bm;
|
|
302
|
-
return
|
|
536
|
+
return this.getDate(a) - this.getDate(b);
|
|
303
537
|
}
|
|
304
538
|
format(date, formatKeyOrString) {
|
|
305
|
-
if (wrIsNamedFormat(formatKeyOrString))
|
|
539
|
+
if (wrIsNamedFormat(formatKeyOrString)) {
|
|
540
|
+
const wall = this.wall(date);
|
|
541
|
+
return wall ? this.intl(formatKeyOrString, true).format(wall) : this.intl(formatKeyOrString).format(date);
|
|
542
|
+
}
|
|
306
543
|
return this.formatWithTokens(date, formatKeyOrString);
|
|
307
544
|
}
|
|
308
545
|
parse(value, formatKeyOrString) {
|
|
@@ -318,18 +555,23 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
318
555
|
} catch {}
|
|
319
556
|
return this.locale.toLowerCase().startsWith("en-us") ? 0 : 1;
|
|
320
557
|
}
|
|
321
|
-
formatters = /* @__PURE__ */ new Map();
|
|
322
558
|
intlOptions(options) {
|
|
323
559
|
return {
|
|
324
560
|
...options,
|
|
325
561
|
calendar: "gregory"
|
|
326
562
|
};
|
|
327
563
|
}
|
|
328
|
-
intl(key) {
|
|
329
|
-
|
|
564
|
+
intl(key, utc = false) {
|
|
565
|
+
const { locale, formatters } = this.caches();
|
|
566
|
+
const cacheKey = utc ? `utc:${key}` : key;
|
|
567
|
+
let found = formatters.get(cacheKey);
|
|
330
568
|
if (!found) {
|
|
331
|
-
|
|
332
|
-
|
|
569
|
+
const options = this.intlOptions(INTL_OPTIONS[key]);
|
|
570
|
+
found = new Intl.DateTimeFormat(locale, utc ? {
|
|
571
|
+
...options,
|
|
572
|
+
timeZone: "UTC"
|
|
573
|
+
} : options);
|
|
574
|
+
formatters.set(cacheKey, found);
|
|
333
575
|
}
|
|
334
576
|
return found;
|
|
335
577
|
}
|
|
@@ -348,17 +590,17 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
348
590
|
getMonthNames(style) {
|
|
349
591
|
return this.monthNames(style, "standalone");
|
|
350
592
|
}
|
|
351
|
-
numeralsCache = null;
|
|
352
593
|
localeNumerals() {
|
|
353
|
-
|
|
354
|
-
|
|
594
|
+
const cache = this.caches();
|
|
595
|
+
cache.numerals ??= numeralsFor(cache.locale, new Intl.NumberFormat(cache.locale).resolvedOptions().numberingSystem) ?? [];
|
|
596
|
+
return cache.numerals;
|
|
355
597
|
}
|
|
356
|
-
dayPeriodCache = null;
|
|
357
598
|
dayPeriods() {
|
|
358
|
-
|
|
599
|
+
const cache = this.caches();
|
|
600
|
+
if (cache.dayPeriods) return cache.dayPeriods;
|
|
359
601
|
let periods = ["AM", "PM"];
|
|
360
602
|
try {
|
|
361
|
-
const formatter = new Intl.DateTimeFormat(
|
|
603
|
+
const formatter = new Intl.DateTimeFormat(cache.locale, this.intlOptions({
|
|
362
604
|
hour: "numeric",
|
|
363
605
|
hour12: true
|
|
364
606
|
}));
|
|
@@ -366,21 +608,21 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
366
608
|
const [am, pm] = [read(9), read(21)];
|
|
367
609
|
if (am && pm && am !== pm) periods = [am, pm];
|
|
368
610
|
} catch {}
|
|
369
|
-
|
|
611
|
+
cache.dayPeriods = periods;
|
|
370
612
|
return periods;
|
|
371
613
|
}
|
|
372
|
-
monthNameCache = /* @__PURE__ */ new Map();
|
|
373
614
|
monthNames(style, context) {
|
|
615
|
+
const { locale, monthNames } = this.caches();
|
|
374
616
|
const cacheKey = `${style}:${context}`;
|
|
375
|
-
const cached =
|
|
617
|
+
const cached = monthNames.get(cacheKey);
|
|
376
618
|
if (cached) return cached;
|
|
377
|
-
const standaloneFormatter = new Intl.DateTimeFormat(
|
|
619
|
+
const standaloneFormatter = new Intl.DateTimeFormat(locale, this.intlOptions({ month: style }));
|
|
378
620
|
const standalone = [];
|
|
379
621
|
for (let i = 0; i < 12; i++) standalone.push(standaloneFormatter.format(new Date(2024, i, 15)));
|
|
380
622
|
let out = standalone;
|
|
381
623
|
if (context === "format") {
|
|
382
|
-
const numerals = numeralsFor(
|
|
383
|
-
const inDate = new Intl.DateTimeFormat(
|
|
624
|
+
const numerals = numeralsFor(locale, standaloneFormatter.resolvedOptions().numberingSystem) ?? [];
|
|
625
|
+
const inDate = new Intl.DateTimeFormat(locale, this.intlOptions({
|
|
384
626
|
day: "numeric",
|
|
385
627
|
month: style
|
|
386
628
|
}));
|
|
@@ -390,7 +632,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
390
632
|
return part;
|
|
391
633
|
});
|
|
392
634
|
}
|
|
393
|
-
|
|
635
|
+
monthNames.set(cacheKey, out);
|
|
394
636
|
return out;
|
|
395
637
|
}
|
|
396
638
|
hasDayToken(pattern) {
|
|
@@ -402,13 +644,14 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
402
644
|
return found;
|
|
403
645
|
}
|
|
404
646
|
formatWithTokens(date, pattern) {
|
|
405
|
-
const
|
|
406
|
-
const
|
|
407
|
-
const
|
|
408
|
-
const
|
|
647
|
+
const wall = this.wall(date);
|
|
648
|
+
const year = wall ? wall.getUTCFullYear() : date.getFullYear();
|
|
649
|
+
const month = wall ? wall.getUTCMonth() : date.getMonth();
|
|
650
|
+
const day = wall ? wall.getUTCDate() : date.getDate();
|
|
651
|
+
const hours24 = wall ? wall.getUTCHours() : date.getHours();
|
|
409
652
|
const hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
|
|
410
|
-
const minutes = date.getMinutes();
|
|
411
|
-
const seconds = date.getSeconds();
|
|
653
|
+
const minutes = wall ? wall.getUTCMinutes() : date.getMinutes();
|
|
654
|
+
const seconds = wall ? wall.getUTCSeconds() : date.getSeconds();
|
|
412
655
|
const context = this.hasDayToken(pattern) ? "format" : "standalone";
|
|
413
656
|
const monthNames = this.monthNames("long", context);
|
|
414
657
|
const monthShort = this.monthNames("short", context);
|
|
@@ -418,6 +661,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
418
661
|
switch (token) {
|
|
419
662
|
case "yyyy": return pad(year, 4);
|
|
420
663
|
case "yy": return pad(year % 100, 2);
|
|
664
|
+
case "y": return String(year);
|
|
421
665
|
case "MMMM": return monthNames[month] ?? "";
|
|
422
666
|
case "MMM": return monthShort[month] ?? "";
|
|
423
667
|
case "MM": return pad(month + 1);
|
|
@@ -460,6 +704,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
460
704
|
const n = digitsToNumber(raw, numerals);
|
|
461
705
|
switch (token) {
|
|
462
706
|
case "yyyy":
|
|
707
|
+
case "y":
|
|
463
708
|
parts.year = n;
|
|
464
709
|
break;
|
|
465
710
|
case "yy":
|
|
@@ -608,12 +853,12 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
608
853
|
const read = (hour) => formatter.formatToParts(new Date(2024, 0, 15, hour, 30)).find((p) => p.type === "dayPeriod")?.value ?? "";
|
|
609
854
|
return [read(9), read(21)];
|
|
610
855
|
}
|
|
611
|
-
namedParsers = /* @__PURE__ */ new Map();
|
|
612
856
|
parseNamed(raw, key) {
|
|
613
|
-
|
|
857
|
+
const { namedParsers } = this.caches();
|
|
858
|
+
let parser = namedParsers.get(key);
|
|
614
859
|
if (parser === void 0) {
|
|
615
860
|
parser = this.buildNamedParser(key);
|
|
616
|
-
|
|
861
|
+
namedParsers.set(key, parser);
|
|
617
862
|
}
|
|
618
863
|
if (!parser) return null;
|
|
619
864
|
const match = parser.regex.exec(stripBidi(raw));
|
|
@@ -657,15 +902,20 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
|
|
|
657
902
|
}
|
|
658
903
|
compose(parts) {
|
|
659
904
|
const now = /* @__PURE__ */ new Date();
|
|
660
|
-
const year = parts.year ??
|
|
661
|
-
const month = parts.month ??
|
|
905
|
+
const year = parts.year ?? this.getYear(now);
|
|
906
|
+
const month = parts.month ?? this.getMonth(now);
|
|
662
907
|
let hours = parts.hours ?? 0;
|
|
663
908
|
if (parts.hour12 !== void 0) hours = parts.hour12 % 12 + (parts.isPm ? 12 : 0);
|
|
664
909
|
const minutes = parts.minutes ?? 0;
|
|
665
910
|
const seconds = parts.seconds ?? 0;
|
|
666
911
|
if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) return null;
|
|
667
912
|
const monthLength = new Date(year, month + 1, 0).getDate();
|
|
668
|
-
const day = parts.day ?? Math.min(
|
|
913
|
+
const day = parts.day ?? Math.min(this.getDate(now), monthLength);
|
|
914
|
+
if (this.zonal) {
|
|
915
|
+
const wall = new Date(wrUtcTime(year, month, day, hours, minutes, seconds));
|
|
916
|
+
if (wall.getUTCMonth() !== month || wall.getUTCDate() !== day) return null;
|
|
917
|
+
return this.instant(wall);
|
|
918
|
+
}
|
|
669
919
|
const out = new Date(year, month, day, hours, minutes, seconds);
|
|
670
920
|
if (year >= 0 && year < 100) out.setFullYear(year);
|
|
671
921
|
if (!this.isValid(out)) return null;
|
|
@@ -701,6 +951,9 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
701
951
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
702
952
|
*/
|
|
703
953
|
const ISO_DATE_ONLY = /^\d{4}(?:-\d{2}(?:-\d{2})?)?$/;
|
|
954
|
+
function wrIsDateOnly(value) {
|
|
955
|
+
return typeof value === "string" && ISO_DATE_ONLY.test(value.trim());
|
|
956
|
+
}
|
|
704
957
|
function wrToLocalDate(value) {
|
|
705
958
|
const parsed = new Date(value);
|
|
706
959
|
if (typeof value !== "string" || !ISO_DATE_ONLY.test(value) || Number.isNaN(parsed.getTime())) return parsed;
|
|
@@ -715,10 +968,31 @@ function wrToLocalDate(value) {
|
|
|
715
968
|
* Use of this source code is governed by an MIT-style license that can be
|
|
716
969
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
717
970
|
*/
|
|
971
|
+
const ZONELESS = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?$/i;
|
|
972
|
+
const SECONDS_BELOW = 1e10;
|
|
973
|
+
const MILLISECONDS_BELOW = 0x9184e72a000;
|
|
974
|
+
function fromNumber(value, unit) {
|
|
975
|
+
const size = Math.abs(value);
|
|
976
|
+
const resolved = unit !== "auto" ? unit : size < SECONDS_BELOW ? "s" : size < MILLISECONDS_BELOW ? "ms" : "us";
|
|
977
|
+
return new Date(resolved === "s" ? value * 1e3 : resolved === "us" ? value / 1e3 : value);
|
|
978
|
+
}
|
|
979
|
+
function fromWallClock(match, options) {
|
|
980
|
+
const [year, month, day, hours, minutes, seconds] = match.slice(1, 7).map((part) => Number(part ?? 0));
|
|
981
|
+
const millis = Number((match[7] ?? "").slice(0, 3).padEnd(3, "0"));
|
|
982
|
+
const wall = wrUtcTime(year, month - 1, day, hours, minutes, seconds, millis);
|
|
983
|
+
const read = new Date(wall);
|
|
984
|
+
if (read.getUTCMonth() !== month - 1 || read.getUTCDate() !== day || read.getUTCHours() !== hours) return null;
|
|
985
|
+
if (read.getUTCMinutes() !== minutes || read.getUTCSeconds() !== seconds) return null;
|
|
986
|
+
return new Date(options.zonelessIn === "utc" ? wall : wrZoneInstant(wall, wrResolveZone(options.timeZone)));
|
|
987
|
+
}
|
|
718
988
|
const SPACE_SEPARATED = /^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:(Z)|([+-]\d{2})(?::?(\d{2}))?)?$/i;
|
|
719
|
-
function fromString(value) {
|
|
989
|
+
function fromString(value, options) {
|
|
720
990
|
const text = String(value).trim();
|
|
721
991
|
if (text === "") return null;
|
|
992
|
+
if (options.zonelessIn === "display" || options.zonelessIn === "utc") {
|
|
993
|
+
const zoneless = ZONELESS.exec(text);
|
|
994
|
+
if (zoneless !== null) return fromWallClock(zoneless, options);
|
|
995
|
+
}
|
|
722
996
|
const match = SPACE_SEPARATED.exec(text);
|
|
723
997
|
if (match === null) return wrToLocalDate(text);
|
|
724
998
|
const [, day, time, seconds = "00", fraction, utc, hours, minutes = "00"] = match;
|
|
@@ -726,9 +1000,9 @@ function fromString(value) {
|
|
|
726
1000
|
const zone = utc !== void 0 ? "Z" : hours === void 0 ? "" : `${hours}:${minutes}`;
|
|
727
1001
|
return /* @__PURE__ */ new Date(`${day}T${time}:${seconds}${millis}${zone}`);
|
|
728
1002
|
}
|
|
729
|
-
function wrParseDate(value) {
|
|
1003
|
+
function wrParseDate(value, options = {}) {
|
|
730
1004
|
if (value === null || value === void 0) return null;
|
|
731
|
-
const date = value instanceof Date ? value : typeof value === "number" ?
|
|
1005
|
+
const date = value instanceof Date ? value : typeof value === "number" ? fromNumber(value, options.epochUnit ?? "ms") : fromString(value, options);
|
|
732
1006
|
return date === null || Number.isNaN(date.getTime()) ? null : date;
|
|
733
1007
|
}
|
|
734
1008
|
/**
|
|
@@ -745,9 +1019,45 @@ function withDates(options = {}) {
|
|
|
745
1019
|
if (options.locale) providers.push({
|
|
746
1020
|
provide: WR_DATE_LOCALE,
|
|
747
1021
|
useValue: options.locale
|
|
1022
|
+
}, {
|
|
1023
|
+
provide: WR_DATE_LOCALE_PINNED,
|
|
1024
|
+
useValue: true
|
|
1025
|
+
});
|
|
1026
|
+
const { timeZone } = options;
|
|
1027
|
+
if (timeZone) providers.push({
|
|
1028
|
+
provide: WR_DATE_TIME_ZONE,
|
|
1029
|
+
useFactory: () => {
|
|
1030
|
+
if (typeof timeZone !== "function") return () => timeZone;
|
|
1031
|
+
const injector = inject(Injector);
|
|
1032
|
+
return () => runInInjectionContext(injector, timeZone);
|
|
1033
|
+
}
|
|
1034
|
+
});
|
|
1035
|
+
const { epochUnit, zonelessIn, stamp } = options;
|
|
1036
|
+
if (epochUnit || zonelessIn) providers.push({
|
|
1037
|
+
provide: WR_DATE_INPUT,
|
|
1038
|
+
useFactory: () => {
|
|
1039
|
+
const above = inject(WR_DATE_INPUT, {
|
|
1040
|
+
skipSelf: true,
|
|
1041
|
+
optional: true
|
|
1042
|
+
});
|
|
1043
|
+
return {
|
|
1044
|
+
epochUnit: epochUnit ?? above?.epochUnit ?? "ms",
|
|
1045
|
+
zonelessIn: zonelessIn ?? above?.zonelessIn ?? "browser"
|
|
1046
|
+
};
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
if (stamp) providers.push({
|
|
1050
|
+
provide: WR_DATE_STAMP_DEFAULTS,
|
|
1051
|
+
useFactory: () => ({
|
|
1052
|
+
...inject(WR_DATE_STAMP_DEFAULTS, {
|
|
1053
|
+
skipSelf: true,
|
|
1054
|
+
optional: true
|
|
1055
|
+
}),
|
|
1056
|
+
...stamp
|
|
1057
|
+
})
|
|
748
1058
|
});
|
|
749
1059
|
return wrFeature("dates", providers);
|
|
750
1060
|
}
|
|
751
|
-
export { WR_DATE_LOCALE, WrDateAdapter, WrNativeDateAdapter, withDates, wrIsNamedFormat, wrParseDate, wrToLocalDate };
|
|
1061
|
+
export { WR_DATE_INPUT, WR_DATE_LOCALE, WR_DATE_STAMP_DEFAULTS, WR_DATE_TIME_ZONE, WrDateAdapter, WrNativeDateAdapter, withDates, wrDateLocale, wrIsDateOnly, wrIsNamedFormat, wrParseDate, wrToLocalDate };
|
|
752
1062
|
|
|
753
1063
|
//# sourceMappingURL=ngwr-date.mjs.map
|