ngwr 16.0.0 → 16.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/badge/styles/_tag.scss +8 -4
  2. package/button/styles/_index.scss +13 -7
  3. package/cascader/styles/_rules.scss +4 -2
  4. package/checkbox/styles/_index.scss +4 -2
  5. package/date-picker/styles/_index.scss +6 -2
  6. package/date-stamp/styles/_index.scss +38 -0
  7. package/dialog/styles/_index.scss +38 -0
  8. package/fesm2022/internal-CVLvP9b_.mjs +33 -0
  9. package/fesm2022/internal-CVLvP9b_.mjs.map +1 -0
  10. package/fesm2022/ngwr-alert.mjs +11 -7
  11. package/fesm2022/ngwr-alert.mjs.map +1 -1
  12. package/fesm2022/ngwr-avatar.mjs +11 -7
  13. package/fesm2022/ngwr-avatar.mjs.map +1 -1
  14. package/fesm2022/ngwr-back-top.mjs +10 -6
  15. package/fesm2022/ngwr-back-top.mjs.map +1 -1
  16. package/fesm2022/ngwr-badge.mjs +18 -6
  17. package/fesm2022/ngwr-badge.mjs.map +1 -1
  18. package/fesm2022/ngwr-burger.mjs +9 -6
  19. package/fesm2022/ngwr-burger.mjs.map +1 -1
  20. package/fesm2022/ngwr-button.mjs +8 -4
  21. package/fesm2022/ngwr-button.mjs.map +1 -1
  22. package/fesm2022/ngwr-calendar.mjs +19 -8
  23. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  24. package/fesm2022/ngwr-card.mjs +9 -5
  25. package/fesm2022/ngwr-card.mjs.map +1 -1
  26. package/fesm2022/ngwr-cascader.mjs +11 -5
  27. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  28. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +5 -2
  29. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  30. package/fesm2022/ngwr-checkbox.mjs +10 -6
  31. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  32. package/fesm2022/ngwr-clipboard.mjs +2 -1
  33. package/fesm2022/ngwr-clipboard.mjs.map +1 -1
  34. package/fesm2022/ngwr-collapse.mjs +9 -5
  35. package/fesm2022/ngwr-collapse.mjs.map +1 -1
  36. package/fesm2022/ngwr-color-picker.mjs +4 -2
  37. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  38. package/fesm2022/ngwr-comment.mjs +13 -7
  39. package/fesm2022/ngwr-comment.mjs.map +1 -1
  40. package/fesm2022/ngwr-compare.mjs +9 -3
  41. package/fesm2022/ngwr-compare.mjs.map +1 -1
  42. package/fesm2022/ngwr-context-menu.mjs +4 -2
  43. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  44. package/fesm2022/ngwr-copy-value.mjs +11 -6
  45. package/fesm2022/ngwr-copy-value.mjs.map +1 -1
  46. package/fesm2022/ngwr-date-picker.mjs +86 -30
  47. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  48. package/fesm2022/ngwr-date-stamp-testing.mjs +34 -0
  49. package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -0
  50. package/fesm2022/ngwr-date-stamp.mjs +149 -0
  51. package/fesm2022/ngwr-date-stamp.mjs.map +1 -0
  52. package/fesm2022/ngwr-date.mjs +279 -50
  53. package/fesm2022/ngwr-date.mjs.map +1 -1
  54. package/fesm2022/ngwr-descriptions.mjs +9 -5
  55. package/fesm2022/ngwr-descriptions.mjs.map +1 -1
  56. package/fesm2022/ngwr-dialog-testing.mjs +23 -2
  57. package/fesm2022/ngwr-dialog-testing.mjs.map +1 -1
  58. package/fesm2022/ngwr-dialog.mjs +45 -16
  59. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  60. package/fesm2022/ngwr-directives.mjs +102 -11
  61. package/fesm2022/ngwr-directives.mjs.map +1 -1
  62. package/fesm2022/ngwr-divider.mjs +4 -2
  63. package/fesm2022/ngwr-divider.mjs.map +1 -1
  64. package/fesm2022/ngwr-drawer.mjs +29 -3
  65. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  66. package/fesm2022/ngwr-dropdown.mjs +4 -2
  67. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  68. package/fesm2022/ngwr-editor.mjs +5 -2
  69. package/fesm2022/ngwr-editor.mjs.map +1 -1
  70. package/fesm2022/ngwr-event-calendar.mjs +4 -2
  71. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  72. package/fesm2022/ngwr-file-upload.mjs +9 -3
  73. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  74. package/fesm2022/ngwr-form.mjs +18 -6
  75. package/fesm2022/ngwr-form.mjs.map +1 -1
  76. package/fesm2022/ngwr-i18n-ar.mjs +2 -0
  77. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  78. package/fesm2022/ngwr-i18n-cs.mjs +2 -0
  79. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  80. package/fesm2022/ngwr-i18n-de.mjs +2 -0
  81. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  82. package/fesm2022/ngwr-i18n-en.mjs +2 -0
  83. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  84. package/fesm2022/ngwr-i18n-es.mjs +2 -0
  85. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  86. package/fesm2022/ngwr-i18n-fr.mjs +2 -0
  87. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  88. package/fesm2022/ngwr-i18n-he.mjs +2 -0
  89. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  90. package/fesm2022/ngwr-i18n-hi.mjs +2 -0
  91. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  92. package/fesm2022/ngwr-i18n-id.mjs +2 -0
  93. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  94. package/fesm2022/ngwr-i18n-it.mjs +2 -0
  95. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  96. package/fesm2022/ngwr-i18n-ja.mjs +2 -0
  97. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  98. package/fesm2022/ngwr-i18n-ko.mjs +2 -0
  99. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  100. package/fesm2022/ngwr-i18n-nl.mjs +2 -0
  101. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  102. package/fesm2022/ngwr-i18n-pl.mjs +2 -0
  103. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  104. package/fesm2022/ngwr-i18n-pt.mjs +2 -0
  105. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  106. package/fesm2022/ngwr-i18n-ru.mjs +2 -0
  107. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  108. package/fesm2022/ngwr-i18n-sv.mjs +2 -0
  109. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  110. package/fesm2022/ngwr-i18n-tr.mjs +2 -0
  111. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  112. package/fesm2022/ngwr-i18n-uk.mjs +2 -0
  113. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  114. package/fesm2022/ngwr-i18n-vi.mjs +2 -0
  115. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  116. package/fesm2022/ngwr-i18n-zh-tw.mjs +2 -0
  117. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  118. package/fesm2022/ngwr-i18n-zh.mjs +2 -0
  119. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  120. package/fesm2022/ngwr-i18n.mjs +34 -8
  121. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  122. package/fesm2022/ngwr-input-number.mjs +9 -3
  123. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  124. package/fesm2022/ngwr-input-otp.mjs +4 -2
  125. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  126. package/fesm2022/ngwr-input.mjs +20 -10
  127. package/fesm2022/ngwr-input.mjs.map +1 -1
  128. package/fesm2022/ngwr-keyboard.mjs +9 -3
  129. package/fesm2022/ngwr-keyboard.mjs.map +1 -1
  130. package/fesm2022/ngwr-knob.mjs +9 -3
  131. package/fesm2022/ngwr-knob.mjs.map +1 -1
  132. package/fesm2022/ngwr-layout.mjs +13 -5
  133. package/fesm2022/ngwr-layout.mjs.map +1 -1
  134. package/fesm2022/ngwr-lightbox.mjs +9 -5
  135. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  136. package/fesm2022/ngwr-list.mjs +13 -5
  137. package/fesm2022/ngwr-list.mjs.map +1 -1
  138. package/fesm2022/ngwr-load-state.mjs +9 -5
  139. package/fesm2022/ngwr-load-state.mjs.map +1 -1
  140. package/fesm2022/ngwr-overlay.mjs +84 -1
  141. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  142. package/fesm2022/ngwr-pagination.mjs +3 -2
  143. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  144. package/fesm2022/ngwr-pipes.mjs +21 -5
  145. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  146. package/fesm2022/ngwr-popover.mjs +93 -4
  147. package/fesm2022/ngwr-popover.mjs.map +1 -1
  148. package/fesm2022/ngwr-progress.mjs +4 -2
  149. package/fesm2022/ngwr-progress.mjs.map +1 -1
  150. package/fesm2022/ngwr-radio.mjs +9 -5
  151. package/fesm2022/ngwr-radio.mjs.map +1 -1
  152. package/fesm2022/ngwr-rating.mjs +9 -3
  153. package/fesm2022/ngwr-rating.mjs.map +1 -1
  154. package/fesm2022/ngwr-resizable.mjs +503 -0
  155. package/fesm2022/ngwr-resizable.mjs.map +1 -0
  156. package/fesm2022/ngwr-result.mjs +9 -5
  157. package/fesm2022/ngwr-result.mjs.map +1 -1
  158. package/fesm2022/ngwr-segmented.mjs +4 -2
  159. package/fesm2022/ngwr-segmented.mjs.map +1 -1
  160. package/fesm2022/ngwr-select.mjs +13 -5
  161. package/fesm2022/ngwr-select.mjs.map +1 -1
  162. package/fesm2022/ngwr-skeleton.mjs +4 -2
  163. package/fesm2022/ngwr-skeleton.mjs.map +1 -1
  164. package/fesm2022/ngwr-slider.mjs +4 -2
  165. package/fesm2022/ngwr-slider.mjs.map +1 -1
  166. package/fesm2022/ngwr-speed-dial.mjs +4 -2
  167. package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
  168. package/fesm2022/ngwr-spinner.mjs +4 -2
  169. package/fesm2022/ngwr-spinner.mjs.map +1 -1
  170. package/fesm2022/ngwr-splitter.mjs +17 -21
  171. package/fesm2022/ngwr-splitter.mjs.map +1 -1
  172. package/fesm2022/ngwr-stepper.mjs +9 -3
  173. package/fesm2022/ngwr-stepper.mjs.map +1 -1
  174. package/fesm2022/ngwr-switch.mjs +9 -5
  175. package/fesm2022/ngwr-switch.mjs.map +1 -1
  176. package/fesm2022/ngwr-table-testing.mjs +5 -1
  177. package/fesm2022/ngwr-table-testing.mjs.map +1 -1
  178. package/fesm2022/ngwr-table.mjs +167 -10
  179. package/fesm2022/ngwr-table.mjs.map +1 -1
  180. package/fesm2022/ngwr-textarea.mjs +9 -3
  181. package/fesm2022/ngwr-textarea.mjs.map +1 -1
  182. package/fesm2022/ngwr-timeline.mjs +18 -8
  183. package/fesm2022/ngwr-timeline.mjs.map +1 -1
  184. package/fesm2022/ngwr-toast-testing.mjs +6 -1
  185. package/fesm2022/ngwr-toast-testing.mjs.map +1 -1
  186. package/fesm2022/ngwr-toast.mjs +529 -104
  187. package/fesm2022/ngwr-toast.mjs.map +1 -1
  188. package/fesm2022/ngwr-transfer.mjs +4 -2
  189. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  190. package/fesm2022/ngwr-tree.mjs +4 -2
  191. package/fesm2022/ngwr-tree.mjs.map +1 -1
  192. package/fesm2022/ngwr-typography.mjs +9 -3
  193. package/fesm2022/ngwr-typography.mjs.map +1 -1
  194. package/fesm2022/ngwr-utils-router.mjs +18 -2
  195. package/fesm2022/ngwr-utils-router.mjs.map +1 -1
  196. package/fesm2022/ngwr-utils.mjs +9 -2
  197. package/fesm2022/ngwr-utils.mjs.map +1 -1
  198. package/fesm2022/ngwr-version.mjs +1 -1
  199. package/fesm2022/ngwr-version.mjs.map +1 -1
  200. package/fesm2022/ngwr-window.mjs +7 -4
  201. package/fesm2022/ngwr-window.mjs.map +1 -1
  202. package/fesm2022/ngwr.mjs.map +1 -1
  203. package/i18n/ar.json +6 -0
  204. package/i18n/cs.json +6 -0
  205. package/i18n/de.json +6 -0
  206. package/i18n/en.json +6 -0
  207. package/i18n/es.json +6 -0
  208. package/i18n/fr.json +6 -0
  209. package/i18n/he.json +6 -0
  210. package/i18n/hi.json +6 -0
  211. package/i18n/id.json +6 -0
  212. package/i18n/it.json +6 -0
  213. package/i18n/ja.json +6 -0
  214. package/i18n/ko.json +6 -0
  215. package/i18n/nl.json +6 -0
  216. package/i18n/pl.json +6 -0
  217. package/i18n/pt.json +6 -0
  218. package/i18n/ru.json +6 -0
  219. package/i18n/sv.json +6 -0
  220. package/i18n/tr.json +6 -0
  221. package/i18n/uk.json +6 -0
  222. package/i18n/vi.json +6 -0
  223. package/i18n/zh-TW.json +6 -0
  224. package/i18n/zh.json +6 -0
  225. package/input/styles/_index.scss +10 -5
  226. package/input-number/styles/_index.scss +6 -3
  227. package/input-otp/styles/_index.scss +4 -2
  228. package/llms-full.txt +29 -10
  229. package/llms.txt +8 -4
  230. package/package.json +15 -1
  231. package/radio/styles/_index.scss +4 -2
  232. package/resizable/styles/_index.scss +154 -0
  233. package/schematics/use/rule.js +1 -0
  234. package/schematics/use/symbol-map.json +4 -0
  235. package/select/styles/_index.scss +6 -3
  236. package/skills/ngwr/SKILL.md +1 -1
  237. package/skills/ngwr/references/catalog.md +4 -1
  238. package/skills/ngwr/references/setup.md +3 -0
  239. package/switch/styles/_index.scss +4 -2
  240. package/table/styles/_index.scss +53 -0
  241. package/textarea/styles/_index.scss +4 -2
  242. package/theme/styles/_motion.scss +6 -0
  243. package/toast/styles/_index.scss +19 -0
  244. package/types/ngwr-burger.d.ts +0 -1
  245. package/types/ngwr-calendar.d.ts +7 -0
  246. package/types/ngwr-charts-calendar-heatmap.d.ts +2 -1
  247. package/types/ngwr-clipboard.d.ts +7 -0
  248. package/types/ngwr-date-picker.d.ts +9 -2
  249. package/types/ngwr-date-stamp-testing.d.ts +47 -0
  250. package/types/ngwr-date-stamp.d.ts +81 -0
  251. package/types/ngwr-date.d.ts +135 -24
  252. package/types/ngwr-dialog-testing.d.ts +10 -0
  253. package/types/ngwr-dialog.d.ts +72 -4
  254. package/types/ngwr-directives.d.ts +36 -1
  255. package/types/ngwr-drawer.d.ts +21 -0
  256. package/types/ngwr-i18n.d.ts +44 -14
  257. package/types/ngwr-overlay.d.ts +36 -0
  258. package/types/ngwr-pipes.d.ts +15 -0
  259. package/types/ngwr-popover.d.ts +39 -1
  260. package/types/ngwr-resizable.d.ts +228 -0
  261. package/types/ngwr-table-testing.d.ts +3 -1
  262. package/types/ngwr-table.d.ts +120 -4
  263. package/types/ngwr-toast-testing.d.ts +12 -1
  264. package/types/ngwr-toast.d.ts +215 -18
  265. package/types/ngwr-utils-router.d.ts +22 -0
  266. package/types/ngwr-utils.d.ts +8 -1
  267. package/types/ngwr-version.d.ts +1 -1
  268. package/types/ngwr.d.ts +1 -0
@@ -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,120 @@ 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_LOCALE_PINNED = new InjectionToken("WR_DATE_LOCALE_PINNED", {
31
+ providedIn: "root",
32
+ factory: () => false
33
+ });
34
+ /**
35
+ * @license
36
+ *
37
+ * Use of this source code is governed by an MIT-style license that can be
38
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
39
+ */
40
+ function isLocaleTag(tag) {
41
+ try {
42
+ return Intl.getCanonicalLocales(tag).length > 0;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ function wrDateLocale() {
48
+ const fixed = inject(WR_DATE_LOCALE);
49
+ const live = inject(WR_DATE_LOCALE_PINNED) ? null : inject(WR_LIVE_LOCALE, { optional: true });
50
+ if (!live) return computed(() => fixed);
51
+ return computed(() => {
52
+ const tag = live();
53
+ return isLocaleTag(tag) ? tag : fixed;
54
+ });
55
+ }
56
+ /**
57
+ * @license
58
+ *
59
+ * Use of this source code is governed by an MIT-style license that can be
60
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
61
+ */
62
+ const OFFSET = /^([+-])(\d{2})(?::?(\d{2}))?$/;
63
+ const MINUTE = 6e4;
64
+ const resolved = /* @__PURE__ */ new Map();
65
+ function wrUtcTime(year, month, day, hours = 0, minutes = 0, seconds = 0, millis = 0) {
66
+ const date = /* @__PURE__ */ new Date(0);
67
+ date.setUTCFullYear(year, month, day);
68
+ date.setUTCHours(hours, minutes, seconds, millis);
69
+ return date.getTime();
70
+ }
71
+ function wrResolveZone(value) {
72
+ const id = value?.trim();
73
+ if (!id) return null;
74
+ const known = resolved.get(id);
75
+ if (known !== void 0) return known;
76
+ let zone = null;
77
+ const offset = OFFSET.exec(id);
78
+ if (offset) {
79
+ const hours = Number(offset[2]);
80
+ const minutes = Number(offset[3] ?? 0);
81
+ if (hours <= 23 && minutes <= 59) zone = {
82
+ kind: "offset",
83
+ id,
84
+ minutes: (offset[1] === "-" ? -1 : 1) * (hours * 60 + minutes)
85
+ };
86
+ } else try {
87
+ zone = {
88
+ kind: "iana",
89
+ id,
90
+ fields: new Intl.DateTimeFormat("en-US", {
91
+ timeZone: id,
92
+ calendar: "gregory",
93
+ numberingSystem: "latn",
94
+ hourCycle: "h23",
95
+ year: "numeric",
96
+ month: "numeric",
97
+ day: "numeric",
98
+ hour: "numeric",
99
+ minute: "numeric",
100
+ second: "numeric"
101
+ })
102
+ };
103
+ } catch {}
104
+ 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.`);
105
+ resolved.set(id, zone);
106
+ return zone;
107
+ }
108
+ function wrZoneWallTime(time, zone) {
109
+ if (!zone) return time - new Date(time).getTimezoneOffset() * MINUTE;
110
+ if (zone.kind === "offset") return time + zone.minutes * MINUTE;
111
+ const read = {};
112
+ for (const part of zone.fields.formatToParts(time)) read[part.type] = Number(part.value);
113
+ const millis = (time % 1e3 + 1e3) % 1e3;
114
+ return wrUtcTime(read["year"], read["month"] - 1, read["day"], read["hour"], read["minute"], read["second"], millis);
115
+ }
116
+ function wrZoneInstant(wall, zone) {
117
+ if (!zone) {
118
+ const w = new Date(wall);
119
+ const local = /* @__PURE__ */ new Date(0);
120
+ local.setFullYear(w.getUTCFullYear(), w.getUTCMonth(), w.getUTCDate());
121
+ local.setHours(w.getUTCHours(), w.getUTCMinutes(), w.getUTCSeconds(), w.getUTCMilliseconds());
122
+ return local.getTime();
123
+ }
124
+ if (zone.kind === "offset") return wall - zone.minutes * MINUTE;
125
+ const first = wall - (wrZoneWallTime(wall, zone) - wall);
126
+ return wall - (wrZoneWallTime(first, zone) - first);
127
+ }
128
+ /**
129
+ * @license
130
+ *
131
+ * Use of this source code is governed by an MIT-style license that can be
132
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
133
+ */
20
134
  const BIDI_RE = /[\u200e\u200f\u061c\u2066-\u2069]/g;
21
135
  const REGEX_META_RE = /[.*+?^${}()|[\]\\]/g;
22
136
  function stripBidi(value) {
@@ -193,6 +307,12 @@ var WrDateAdapter = class WrDateAdapter {
193
307
  isWithinRange(date, start, end) {
194
308
  return this.compareDate(date, start) >= 0 && this.compareDate(date, end) <= 0;
195
309
  }
310
+ zoned() {
311
+ return this;
312
+ }
313
+ displayKey() {
314
+ return "";
315
+ }
196
316
  static ɵfac = i0.ɵɵngDeclareFactory({
197
317
  minVersion: "12.0.0",
198
318
  version: "22.2.5",
@@ -224,7 +344,63 @@ i0.ɵɵngDeclareClassMetadata({
224
344
  }]
225
345
  });
226
346
  var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
227
- locale = inject(WR_DATE_LOCALE);
347
+ localeSource = wrDateLocale();
348
+ cache = null;
349
+ caches() {
350
+ const locale = this.localeSource();
351
+ if (this.cache?.locale !== locale) this.cache = {
352
+ locale,
353
+ formatters: /* @__PURE__ */ new Map(),
354
+ monthNames: /* @__PURE__ */ new Map(),
355
+ namedParsers: /* @__PURE__ */ new Map(),
356
+ numerals: null,
357
+ dayPeriods: null
358
+ };
359
+ return this.cache;
360
+ }
361
+ get locale() {
362
+ return this.caches().locale;
363
+ }
364
+ zoneSource = inject(WR_DATE_TIME_ZONE);
365
+ injector = inject(Injector);
366
+ zonal = false;
367
+ zonedSelf = null;
368
+ zoned() {
369
+ if (this.zonal || !this.zoneSource) return this;
370
+ this.zonedSelf ??= runInInjectionContext(this.injector, () => {
371
+ const zoned = new this.constructor();
372
+ zoned.zonal = true;
373
+ return zoned;
374
+ });
375
+ return this.zonedSelf;
376
+ }
377
+ displayKey() {
378
+ return `${this.locale}|${this.zonal ? this.zone()?.id ?? "" : ""}`;
379
+ }
380
+ zone() {
381
+ return wrResolveZone(this.zoneSource?.());
382
+ }
383
+ wallZone = null;
384
+ walls = /* @__PURE__ */ new Map();
385
+ wall(date) {
386
+ if (!this.zonal) return null;
387
+ const zone = this.zone();
388
+ const time = date.getTime();
389
+ if (zone?.kind !== "iana" || Number.isNaN(time)) return new Date(wrZoneWallTime(time, zone));
390
+ if (this.wallZone !== zone || this.walls.size > 512) {
391
+ this.walls.clear();
392
+ this.wallZone = zone;
393
+ }
394
+ let wall = this.walls.get(time);
395
+ if (wall === void 0) {
396
+ wall = wrZoneWallTime(time, zone);
397
+ this.walls.set(time, wall);
398
+ }
399
+ return new Date(wall);
400
+ }
401
+ instant(wall) {
402
+ return new Date(wrZoneInstant(wall.getTime(), this.zone()));
403
+ }
228
404
  today() {
229
405
  return /* @__PURE__ */ new Date();
230
406
  }
@@ -232,6 +408,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
232
408
  return new Date(date.getTime());
233
409
  }
234
410
  createDate(year, month, day) {
411
+ if (this.zonal) return this.instant(new Date(wrUtcTime(year, month, day)));
235
412
  const d = new Date(year, month, day);
236
413
  if (year >= 0 && year < 100) d.setFullYear(year);
237
414
  return d;
@@ -240,35 +417,48 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
240
417
  return date instanceof Date && !Number.isNaN(date.getTime());
241
418
  }
242
419
  getYear(date) {
243
- return date.getFullYear();
420
+ return this.wall(date)?.getUTCFullYear() ?? date.getFullYear();
244
421
  }
245
422
  getMonth(date) {
246
- return date.getMonth();
423
+ return this.wall(date)?.getUTCMonth() ?? date.getMonth();
247
424
  }
248
425
  getDate(date) {
249
- return date.getDate();
426
+ return this.wall(date)?.getUTCDate() ?? date.getDate();
250
427
  }
251
428
  getDayOfWeek(date) {
252
- return date.getDay();
429
+ return this.wall(date)?.getUTCDay() ?? date.getDay();
253
430
  }
254
431
  getDaysInMonth(date) {
255
- return new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
432
+ return new Date(this.getYear(date), this.getMonth(date) + 1, 0).getDate();
256
433
  }
257
434
  getHours(date) {
258
- return date.getHours();
435
+ return this.wall(date)?.getUTCHours() ?? date.getHours();
259
436
  }
260
437
  getMinutes(date) {
261
- return date.getMinutes();
438
+ return this.wall(date)?.getUTCMinutes() ?? date.getMinutes();
262
439
  }
263
440
  getSeconds(date) {
264
- return date.getSeconds();
441
+ return this.wall(date)?.getUTCSeconds() ?? date.getSeconds();
265
442
  }
266
443
  addYears(date, amount) {
444
+ const wall = this.wall(date);
445
+ if (wall) {
446
+ wall.setUTCFullYear(wall.getUTCFullYear() + amount);
447
+ return this.instant(wall);
448
+ }
267
449
  const d = this.clone(date);
268
450
  d.setFullYear(d.getFullYear() + amount);
269
451
  return d;
270
452
  }
271
453
  addMonths(date, amount) {
454
+ const wall = this.wall(date);
455
+ if (wall) {
456
+ const day = wall.getUTCDate();
457
+ wall.setUTCDate(1);
458
+ wall.setUTCMonth(wall.getUTCMonth() + amount);
459
+ wall.setUTCDate(Math.min(day, new Date(wall.getUTCFullYear(), wall.getUTCMonth() + 1, 0).getDate()));
460
+ return this.instant(wall);
461
+ }
272
462
  const d = this.clone(date);
273
463
  const desiredDay = d.getDate();
274
464
  d.setDate(1);
@@ -277,32 +467,45 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
277
467
  return d;
278
468
  }
279
469
  addDays(date, amount) {
470
+ const wall = this.wall(date);
471
+ if (wall) {
472
+ wall.setUTCDate(wall.getUTCDate() + amount);
473
+ return this.instant(wall);
474
+ }
280
475
  const d = this.clone(date);
281
476
  d.setDate(d.getDate() + amount);
282
477
  return d;
283
478
  }
284
479
  setTime(date, hours, minutes, seconds) {
480
+ const wall = this.wall(date);
481
+ if (wall) {
482
+ wall.setUTCHours(hours, minutes, seconds, 0);
483
+ return this.instant(wall);
484
+ }
285
485
  const d = this.clone(date);
286
486
  d.setHours(hours, minutes, seconds, 0);
287
487
  return d;
288
488
  }
289
489
  isSameDay(a, b) {
290
- return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
490
+ return this.compareDate(a, b) === 0;
291
491
  }
292
492
  isSameMonth(a, b) {
293
- return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth();
493
+ return this.getYear(a) === this.getYear(b) && this.getMonth(a) === this.getMonth(b);
294
494
  }
295
495
  compareDate(a, b) {
296
- const ay = a.getFullYear();
297
- const by = b.getFullYear();
496
+ const ay = this.getYear(a);
497
+ const by = this.getYear(b);
298
498
  if (ay !== by) return ay - by;
299
- const am = a.getMonth();
300
- const bm = b.getMonth();
499
+ const am = this.getMonth(a);
500
+ const bm = this.getMonth(b);
301
501
  if (am !== bm) return am - bm;
302
- return a.getDate() - b.getDate();
502
+ return this.getDate(a) - this.getDate(b);
303
503
  }
304
504
  format(date, formatKeyOrString) {
305
- if (wrIsNamedFormat(formatKeyOrString)) return this.intl(formatKeyOrString).format(date);
505
+ if (wrIsNamedFormat(formatKeyOrString)) {
506
+ const wall = this.wall(date);
507
+ return wall ? this.intl(formatKeyOrString, true).format(wall) : this.intl(formatKeyOrString).format(date);
508
+ }
306
509
  return this.formatWithTokens(date, formatKeyOrString);
307
510
  }
308
511
  parse(value, formatKeyOrString) {
@@ -318,18 +521,23 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
318
521
  } catch {}
319
522
  return this.locale.toLowerCase().startsWith("en-us") ? 0 : 1;
320
523
  }
321
- formatters = /* @__PURE__ */ new Map();
322
524
  intlOptions(options) {
323
525
  return {
324
526
  ...options,
325
527
  calendar: "gregory"
326
528
  };
327
529
  }
328
- intl(key) {
329
- let found = this.formatters.get(key);
530
+ intl(key, utc = false) {
531
+ const { locale, formatters } = this.caches();
532
+ const cacheKey = utc ? `utc:${key}` : key;
533
+ let found = formatters.get(cacheKey);
330
534
  if (!found) {
331
- found = new Intl.DateTimeFormat(this.locale, this.intlOptions(INTL_OPTIONS[key]));
332
- this.formatters.set(key, found);
535
+ const options = this.intlOptions(INTL_OPTIONS[key]);
536
+ found = new Intl.DateTimeFormat(locale, utc ? {
537
+ ...options,
538
+ timeZone: "UTC"
539
+ } : options);
540
+ formatters.set(cacheKey, found);
333
541
  }
334
542
  return found;
335
543
  }
@@ -348,17 +556,17 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
348
556
  getMonthNames(style) {
349
557
  return this.monthNames(style, "standalone");
350
558
  }
351
- numeralsCache = null;
352
559
  localeNumerals() {
353
- this.numeralsCache ??= numeralsFor(this.locale, new Intl.NumberFormat(this.locale).resolvedOptions().numberingSystem) ?? [];
354
- return this.numeralsCache;
560
+ const cache = this.caches();
561
+ cache.numerals ??= numeralsFor(cache.locale, new Intl.NumberFormat(cache.locale).resolvedOptions().numberingSystem) ?? [];
562
+ return cache.numerals;
355
563
  }
356
- dayPeriodCache = null;
357
564
  dayPeriods() {
358
- if (this.dayPeriodCache) return this.dayPeriodCache;
565
+ const cache = this.caches();
566
+ if (cache.dayPeriods) return cache.dayPeriods;
359
567
  let periods = ["AM", "PM"];
360
568
  try {
361
- const formatter = new Intl.DateTimeFormat(this.locale, this.intlOptions({
569
+ const formatter = new Intl.DateTimeFormat(cache.locale, this.intlOptions({
362
570
  hour: "numeric",
363
571
  hour12: true
364
572
  }));
@@ -366,21 +574,21 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
366
574
  const [am, pm] = [read(9), read(21)];
367
575
  if (am && pm && am !== pm) periods = [am, pm];
368
576
  } catch {}
369
- this.dayPeriodCache = periods;
577
+ cache.dayPeriods = periods;
370
578
  return periods;
371
579
  }
372
- monthNameCache = /* @__PURE__ */ new Map();
373
580
  monthNames(style, context) {
581
+ const { locale, monthNames } = this.caches();
374
582
  const cacheKey = `${style}:${context}`;
375
- const cached = this.monthNameCache.get(cacheKey);
583
+ const cached = monthNames.get(cacheKey);
376
584
  if (cached) return cached;
377
- const standaloneFormatter = new Intl.DateTimeFormat(this.locale, this.intlOptions({ month: style }));
585
+ const standaloneFormatter = new Intl.DateTimeFormat(locale, this.intlOptions({ month: style }));
378
586
  const standalone = [];
379
587
  for (let i = 0; i < 12; i++) standalone.push(standaloneFormatter.format(new Date(2024, i, 15)));
380
588
  let out = standalone;
381
589
  if (context === "format") {
382
- const numerals = numeralsFor(this.locale, standaloneFormatter.resolvedOptions().numberingSystem) ?? [];
383
- const inDate = new Intl.DateTimeFormat(this.locale, this.intlOptions({
590
+ const numerals = numeralsFor(locale, standaloneFormatter.resolvedOptions().numberingSystem) ?? [];
591
+ const inDate = new Intl.DateTimeFormat(locale, this.intlOptions({
384
592
  day: "numeric",
385
593
  month: style
386
594
  }));
@@ -390,7 +598,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
390
598
  return part;
391
599
  });
392
600
  }
393
- this.monthNameCache.set(cacheKey, out);
601
+ monthNames.set(cacheKey, out);
394
602
  return out;
395
603
  }
396
604
  hasDayToken(pattern) {
@@ -402,13 +610,14 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
402
610
  return found;
403
611
  }
404
612
  formatWithTokens(date, pattern) {
405
- const year = date.getFullYear();
406
- const month = date.getMonth();
407
- const day = date.getDate();
408
- const hours24 = date.getHours();
613
+ const wall = this.wall(date);
614
+ const year = wall ? wall.getUTCFullYear() : date.getFullYear();
615
+ const month = wall ? wall.getUTCMonth() : date.getMonth();
616
+ const day = wall ? wall.getUTCDate() : date.getDate();
617
+ const hours24 = wall ? wall.getUTCHours() : date.getHours();
409
618
  const hours12 = hours24 % 12 === 0 ? 12 : hours24 % 12;
410
- const minutes = date.getMinutes();
411
- const seconds = date.getSeconds();
619
+ const minutes = wall ? wall.getUTCMinutes() : date.getMinutes();
620
+ const seconds = wall ? wall.getUTCSeconds() : date.getSeconds();
412
621
  const context = this.hasDayToken(pattern) ? "format" : "standalone";
413
622
  const monthNames = this.monthNames("long", context);
414
623
  const monthShort = this.monthNames("short", context);
@@ -608,12 +817,12 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
608
817
  const read = (hour) => formatter.formatToParts(new Date(2024, 0, 15, hour, 30)).find((p) => p.type === "dayPeriod")?.value ?? "";
609
818
  return [read(9), read(21)];
610
819
  }
611
- namedParsers = /* @__PURE__ */ new Map();
612
820
  parseNamed(raw, key) {
613
- let parser = this.namedParsers.get(key);
821
+ const { namedParsers } = this.caches();
822
+ let parser = namedParsers.get(key);
614
823
  if (parser === void 0) {
615
824
  parser = this.buildNamedParser(key);
616
- this.namedParsers.set(key, parser);
825
+ namedParsers.set(key, parser);
617
826
  }
618
827
  if (!parser) return null;
619
828
  const match = parser.regex.exec(stripBidi(raw));
@@ -657,15 +866,20 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
657
866
  }
658
867
  compose(parts) {
659
868
  const now = /* @__PURE__ */ new Date();
660
- const year = parts.year ?? now.getFullYear();
661
- const month = parts.month ?? now.getMonth();
869
+ const year = parts.year ?? this.getYear(now);
870
+ const month = parts.month ?? this.getMonth(now);
662
871
  let hours = parts.hours ?? 0;
663
872
  if (parts.hour12 !== void 0) hours = parts.hour12 % 12 + (parts.isPm ? 12 : 0);
664
873
  const minutes = parts.minutes ?? 0;
665
874
  const seconds = parts.seconds ?? 0;
666
875
  if (hours < 0 || hours > 23 || minutes < 0 || minutes > 59 || seconds < 0 || seconds > 59) return null;
667
876
  const monthLength = new Date(year, month + 1, 0).getDate();
668
- const day = parts.day ?? Math.min(now.getDate(), monthLength);
877
+ const day = parts.day ?? Math.min(this.getDate(now), monthLength);
878
+ if (this.zonal) {
879
+ const wall = new Date(wrUtcTime(year, month, day, hours, minutes, seconds));
880
+ if (wall.getUTCMonth() !== month || wall.getUTCDate() !== day) return null;
881
+ return this.instant(wall);
882
+ }
669
883
  const out = new Date(year, month, day, hours, minutes, seconds);
670
884
  if (year >= 0 && year < 100) out.setFullYear(year);
671
885
  if (!this.isValid(out)) return null;
@@ -701,6 +915,9 @@ i0.ɵɵngDeclareClassMetadata({
701
915
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
702
916
  */
703
917
  const ISO_DATE_ONLY = /^\d{4}(?:-\d{2}(?:-\d{2})?)?$/;
918
+ function wrIsDateOnly(value) {
919
+ return typeof value === "string" && ISO_DATE_ONLY.test(value.trim());
920
+ }
704
921
  function wrToLocalDate(value) {
705
922
  const parsed = new Date(value);
706
923
  if (typeof value !== "string" || !ISO_DATE_ONLY.test(value) || Number.isNaN(parsed.getTime())) return parsed;
@@ -745,9 +962,21 @@ function withDates(options = {}) {
745
962
  if (options.locale) providers.push({
746
963
  provide: WR_DATE_LOCALE,
747
964
  useValue: options.locale
965
+ }, {
966
+ provide: WR_DATE_LOCALE_PINNED,
967
+ useValue: true
968
+ });
969
+ const { timeZone } = options;
970
+ if (timeZone) providers.push({
971
+ provide: WR_DATE_TIME_ZONE,
972
+ useFactory: () => {
973
+ if (typeof timeZone !== "function") return () => timeZone;
974
+ const injector = inject(Injector);
975
+ return () => runInInjectionContext(injector, timeZone);
976
+ }
748
977
  });
749
978
  return wrFeature("dates", providers);
750
979
  }
751
- export { WR_DATE_LOCALE, WrDateAdapter, WrNativeDateAdapter, withDates, wrIsNamedFormat, wrParseDate, wrToLocalDate };
980
+ export { WR_DATE_LOCALE, WR_DATE_TIME_ZONE, WrDateAdapter, WrNativeDateAdapter, withDates, wrDateLocale, wrIsDateOnly, wrIsNamedFormat, wrParseDate, wrToLocalDate };
752
981
 
753
982
  //# sourceMappingURL=ngwr-date.mjs.map