ngwr 16.1.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.
Files changed (123) hide show
  1. package/date-picker/styles/_index.scss +89 -1
  2. package/dropdown/styles/_index.scss +37 -1
  3. package/fesm2022/ngwr-date-picker-testing.mjs +18 -0
  4. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  5. package/fesm2022/ngwr-date-picker.mjs +152 -8
  6. package/fesm2022/ngwr-date-picker.mjs.map +1 -1
  7. package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
  8. package/fesm2022/ngwr-date-stamp.mjs +73 -9
  9. package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
  10. package/fesm2022/ngwr-date.mjs +86 -5
  11. package/fesm2022/ngwr-date.mjs.map +1 -1
  12. package/fesm2022/ngwr-dropdown-testing.mjs +38 -3
  13. package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
  14. package/fesm2022/ngwr-dropdown.mjs +358 -24
  15. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  16. package/fesm2022/ngwr-i18n-ar.mjs +7 -2
  17. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  18. package/fesm2022/ngwr-i18n-cs.mjs +7 -2
  19. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  20. package/fesm2022/ngwr-i18n-de.mjs +7 -2
  21. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  22. package/fesm2022/ngwr-i18n-en.mjs +7 -2
  23. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  24. package/fesm2022/ngwr-i18n-es.mjs +7 -2
  25. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  26. package/fesm2022/ngwr-i18n-fr.mjs +7 -2
  27. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  28. package/fesm2022/ngwr-i18n-he.mjs +7 -2
  29. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  30. package/fesm2022/ngwr-i18n-hi.mjs +7 -2
  31. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  32. package/fesm2022/ngwr-i18n-id.mjs +7 -2
  33. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  34. package/fesm2022/ngwr-i18n-it.mjs +7 -2
  35. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  36. package/fesm2022/ngwr-i18n-ja.mjs +7 -2
  37. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  38. package/fesm2022/ngwr-i18n-ko.mjs +7 -2
  39. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  40. package/fesm2022/ngwr-i18n-nl.mjs +7 -2
  41. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  42. package/fesm2022/ngwr-i18n-pl.mjs +7 -2
  43. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  44. package/fesm2022/ngwr-i18n-pt.mjs +7 -2
  45. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  46. package/fesm2022/ngwr-i18n-ru.mjs +7 -2
  47. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  48. package/fesm2022/ngwr-i18n-sv.mjs +7 -2
  49. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  50. package/fesm2022/ngwr-i18n-tr.mjs +7 -2
  51. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  52. package/fesm2022/ngwr-i18n-uk.mjs +7 -2
  53. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  54. package/fesm2022/ngwr-i18n-vi.mjs +7 -2
  55. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  56. package/fesm2022/ngwr-i18n-zh-tw.mjs +7 -2
  57. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  58. package/fesm2022/ngwr-i18n-zh.mjs +7 -2
  59. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  60. package/fesm2022/ngwr-lightbox-testing.mjs +26 -0
  61. package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -1
  62. package/fesm2022/ngwr-lightbox.mjs +246 -10
  63. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  64. package/fesm2022/ngwr-pipes.mjs +28 -6
  65. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  66. package/fesm2022/ngwr-schema-form.mjs +3 -0
  67. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  68. package/fesm2022/ngwr-slider-testing.mjs +17 -0
  69. package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
  70. package/fesm2022/ngwr-slider.mjs +87 -11
  71. package/fesm2022/ngwr-slider.mjs.map +1 -1
  72. package/fesm2022/ngwr-sortable-list-testing.mjs +103 -0
  73. package/fesm2022/ngwr-sortable-list-testing.mjs.map +1 -0
  74. package/fesm2022/ngwr-sortable-list.mjs +257 -53
  75. package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
  76. package/fesm2022/ngwr-version.mjs +1 -1
  77. package/fesm2022/ngwr-version.mjs.map +1 -1
  78. package/i18n/ar.json +7 -2
  79. package/i18n/cs.json +7 -2
  80. package/i18n/de.json +7 -2
  81. package/i18n/en.json +7 -2
  82. package/i18n/es.json +7 -2
  83. package/i18n/fr.json +7 -2
  84. package/i18n/he.json +7 -2
  85. package/i18n/hi.json +7 -2
  86. package/i18n/id.json +7 -2
  87. package/i18n/it.json +7 -2
  88. package/i18n/ja.json +7 -2
  89. package/i18n/ko.json +7 -2
  90. package/i18n/nl.json +7 -2
  91. package/i18n/pl.json +7 -2
  92. package/i18n/pt.json +7 -2
  93. package/i18n/ru.json +7 -2
  94. package/i18n/sv.json +7 -2
  95. package/i18n/tr.json +7 -2
  96. package/i18n/uk.json +7 -2
  97. package/i18n/vi.json +7 -2
  98. package/i18n/zh-TW.json +7 -2
  99. package/i18n/zh.json +7 -2
  100. package/lightbox/styles/_rules.scss +96 -0
  101. package/llms-full.txt +12 -8
  102. package/llms.txt +12 -0
  103. package/package.json +5 -1
  104. package/schematics/use/symbol-map.json +1 -0
  105. package/skills/ngwr/SKILL.md +1 -1
  106. package/skills/ngwr/references/catalog.md +2 -1
  107. package/slider/styles/_index.scss +106 -0
  108. package/sortable-list/styles/_rules.scss +23 -1
  109. package/types/ngwr-date-picker-testing.d.ts +17 -0
  110. package/types/ngwr-date-picker.d.ts +79 -2
  111. package/types/ngwr-date-stamp-testing.d.ts +1 -1
  112. package/types/ngwr-date-stamp.d.ts +53 -7
  113. package/types/ngwr-date.d.ts +118 -15
  114. package/types/ngwr-dropdown-testing.d.ts +53 -5
  115. package/types/ngwr-dropdown.d.ts +100 -0
  116. package/types/ngwr-lightbox-testing.d.ts +27 -0
  117. package/types/ngwr-lightbox.d.ts +71 -6
  118. package/types/ngwr-pipes.d.ts +33 -13
  119. package/types/ngwr-slider-testing.d.ts +8 -1
  120. package/types/ngwr-slider.d.ts +89 -3
  121. package/types/ngwr-sortable-list-testing.d.ts +79 -0
  122. package/types/ngwr-sortable-list.d.ts +113 -10
  123. package/types/ngwr-version.d.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-date-stamp-testing.mjs","names":[],"sources":["../../../projects/lib/date-stamp/testing/wr-date-stamp-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrDateStampHarnessFilters } from './types';\n\n/**\n * Test harness for one `<wr-date-stamp>`: a date over a time.\n *\n * It answers from what the component renders: the two lines as text and the\n * `datetime` attribute of the `<time>` around them. The lines are written in\n * the locale and the time zone of the test's own providers, so a spec that\n * must not depend on either asserts {@link getDateTime}, which is the instant.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const created = await loader.getHarness(WrDateStampHarness);\n *\n * expect(await created.getDateTime()).toBe('2026-11-12T08:45:00.000Z');\n * expect(await created.getTime()).toBe('13:45');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrDateStampHarness extends ComponentHarness {\n static hostSelector = 'wr-date-stamp';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrDateStampHarnessFilters = {}): HarnessPredicate<WrDateStampHarness> {\n return new HarnessPredicate(WrDateStampHarness, options)\n .addOption('date', options.date, (harness, date) => HarnessPredicate.stringMatches(harness.getDate(), date))\n .addOption('empty', options.empty, async (harness, empty) => (await harness.isEmpty()) === empty);\n }\n\n private readonly time = this.locatorForOptional('time.wr-date-stamp__value');\n\n /** The first line, or `null` when the stamp is empty. */\n async getDate(): Promise<string | null> {\n return (await (await this.locatorForOptional('.wr-date-stamp__date')())?.text()) ?? null;\n }\n\n /** The second line, or `null` when the stamp is empty or shows a date-only value. */\n async getTime(): Promise<string | null> {\n return (await (await this.locatorForOptional('.wr-date-stamp__time')())?.text()) ?? null;\n }\n\n /**\n * The `datetime` attribute: the instant in ISO 8601 (UTC), or `yyyy-MM-dd` for a\n * date-only value. `null` when the stamp is empty.\n */\n async getDateTime(): Promise<string | null> {\n return (await (await this.time())?.getAttribute('datetime')) ?? null;\n }\n\n /** Whether the value is empty: no `<time>`, the placeholder in its place. */\n async isEmpty(): Promise<boolean> {\n return (await this.time()) === null;\n }\n\n /** The placeholder an empty value shows (`emptyLabel`). Throws when there is a value. */\n async getEmptyText(): Promise<string> {\n const empty = await this.locatorForOptional('.wr-date-stamp__empty')();\n if (!empty) {\n throw new Error(\n 'WrDateStampHarness.getEmptyText(): the component shows a date, so it renders no placeholder. ' +\n 'Ask getDate() instead.'\n );\n }\n return empty.text();\n }\n}\n"],"mappings":";;;;;;;AA8BA,IAAa,qBAAb,MAAa,2BAA2B,iBAAgB;CACtD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAqC,CAAA,GAAE;EACjD,OAAO,IAAI,iBAAiB,oBAAoB,OAAO,CAAC,CACrD,UAAU,QAAQ,QAAQ,OAAO,SAAS,SAAS,iBAAiB,cAAc,QAAQ,QAAO,GAAI,IAAI,CAAC,CAAC,CAC3G,UAAU,SAAS,QAAQ,OAAO,OAAO,SAAS,UAAW,MAAM,QAAQ,QAAO,MAAQ,KAAK;CACpG;CAEiB,OAAO,KAAK,mBAAmB,2BAA2B;CAG3E,MAAM,UAAO;EACX,OAAQ,OAAO,MAAM,KAAK,mBAAmB,sBAAsB,CAAC,CAAA,EAAA,EAAK,KAAI,KAAO;CACtF;CAGA,MAAM,UAAO;EACX,OAAQ,OAAO,MAAM,KAAK,mBAAmB,sBAAsB,CAAC,CAAA,EAAA,EAAK,KAAI,KAAO;CACtF;CAMA,MAAM,cAAW;EACf,OAAQ,OAAO,MAAM,KAAK,KAAI,EAAA,EAAK,aAAa,UAAU,KAAM;CAClE;CAGA,MAAM,UAAO;EACX,OAAQ,MAAM,KAAK,KAAI,MAAQ;CACjC;CAGA,MAAM,eAAY;EAChB,MAAM,QAAQ,MAAM,KAAK,mBAAmB,uBAAuB,CAAC,CAAA;EACpE,IAAI,CAAC,OACH,MAAM,IAAI,MACR,qHAC0B;EAG9B,OAAO,MAAM,KAAI;CACnB"}
1
+ {"version":3,"file":"ngwr-date-stamp-testing.mjs","names":[],"sources":["../../../projects/lib/date-stamp/testing/wr-date-stamp-harness.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';\n\nimport type { WrDateStampHarnessFilters } from './types';\n\n/**\n * Test harness for one `<wr-date-stamp>`: a date over a time.\n *\n * It answers from what the component renders: the two lines as text and the\n * `datetime` attribute of the `<time>` around them. The lines are written in\n * the locale and the time zone of the test's own providers, so a spec that\n * must not depend on either asserts {@link getDateTime}, which is the instant.\n *\n * @example\n * ```ts\n * const loader = TestbedHarnessEnvironment.loader(fixture);\n * const created = await loader.getHarness(WrDateStampHarness);\n *\n * expect(await created.getDateTime()).toBe('2026-11-12T08:45:00.000Z');\n * expect(await created.getTime()).toBe('13:45');\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrDateStampHarness extends ComponentHarness {\n static hostSelector = 'wr-date-stamp';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrDateStampHarnessFilters = {}): HarnessPredicate<WrDateStampHarness> {\n return new HarnessPredicate(WrDateStampHarness, options)\n .addOption('date', options.date, (harness, date) => HarnessPredicate.stringMatches(harness.getDate(), date))\n .addOption('empty', options.empty, async (harness, empty) => (await harness.isEmpty()) === empty);\n }\n\n private readonly time = this.locatorForOptional('time.wr-date-stamp__value');\n\n /** The first line, or `null` when the stamp is empty or `todayTimeOnly` shows a value from today. */\n async getDate(): Promise<string | null> {\n return (await (await this.locatorForOptional('.wr-date-stamp__date')())?.text()) ?? null;\n }\n\n /** The second line, or `null` when the stamp is empty or shows a date-only value. */\n async getTime(): Promise<string | null> {\n return (await (await this.locatorForOptional('.wr-date-stamp__time')())?.text()) ?? null;\n }\n\n /**\n * The `datetime` attribute: the instant in ISO 8601 (UTC), or `yyyy-MM-dd` for a\n * date-only value. `null` when the stamp is empty.\n */\n async getDateTime(): Promise<string | null> {\n return (await (await this.time())?.getAttribute('datetime')) ?? null;\n }\n\n /** Whether the value is empty: no `<time>`, the placeholder in its place. */\n async isEmpty(): Promise<boolean> {\n return (await this.time()) === null;\n }\n\n /** The placeholder an empty value shows (`emptyLabel`). Throws when there is a value. */\n async getEmptyText(): Promise<string> {\n const empty = await this.locatorForOptional('.wr-date-stamp__empty')();\n if (!empty) {\n throw new Error(\n 'WrDateStampHarness.getEmptyText(): the component shows a date, so it renders no placeholder. ' +\n 'Ask getDate() instead.'\n );\n }\n return empty.text();\n }\n}\n"],"mappings":";;;;;;;AA8BA,IAAa,qBAAb,MAAa,2BAA2B,iBAAgB;CACtD,OAAO,eAAe;CAGtB,OAAO,KAAK,UAAqC,CAAA,GAAE;EACjD,OAAO,IAAI,iBAAiB,oBAAoB,OAAO,CAAC,CACrD,UAAU,QAAQ,QAAQ,OAAO,SAAS,SAAS,iBAAiB,cAAc,QAAQ,QAAO,GAAI,IAAI,CAAC,CAAC,CAC3G,UAAU,SAAS,QAAQ,OAAO,OAAO,SAAS,UAAW,MAAM,QAAQ,QAAO,MAAQ,KAAK;CACpG;CAEiB,OAAO,KAAK,mBAAmB,2BAA2B;CAG3E,MAAM,UAAO;EACX,OAAQ,OAAO,MAAM,KAAK,mBAAmB,sBAAsB,CAAC,CAAA,EAAA,EAAK,KAAI,KAAO;CACtF;CAGA,MAAM,UAAO;EACX,OAAQ,OAAO,MAAM,KAAK,mBAAmB,sBAAsB,CAAC,CAAA,EAAA,EAAK,KAAI,KAAO;CACtF;CAMA,MAAM,cAAW;EACf,OAAQ,OAAO,MAAM,KAAK,KAAI,EAAA,EAAK,aAAa,UAAU,KAAM;CAClE;CAGA,MAAM,UAAO;EACX,OAAQ,MAAM,KAAK,KAAI,MAAQ;CACjC;CAGA,MAAM,eAAY;EAChB,MAAM,QAAQ,MAAM,KAAK,mBAAmB,uBAAuB,CAAC,CAAA;EACpE,IAAI,CAAC,OACH,MAAM,IAAI,MACR,qHAC0B;EAG9B,OAAO,MAAM,KAAI;CACnB"}
@@ -1,14 +1,18 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, computed, inject, input } from "@angular/core";
2
+ import { Component, ViewEncapsulation, booleanAttribute, computed, inject, input } from "@angular/core";
3
3
  import { wrCheckStyles } from "ngwr/utils";
4
4
  import { useI18nText } from "ngwr/i18n";
5
- import { WrDateAdapter, wrIsDateOnly, wrParseDate } from "ngwr/date";
5
+ import { WR_DATE_STAMP_DEFAULTS, WrDateAdapter, wrIsDateOnly, wrIsNamedFormat, wrParseDate } from "ngwr/date";
6
6
  /**
7
7
  * @license
8
8
  *
9
9
  * Use of this source code is governed by an MIT-style license that can be
10
10
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
11
11
  */
12
+ function withSeconds(format) {
13
+ if (wrIsNamedFormat(format)) return /^(?:time|shortDateTime)(?:12h|24h)?$/.test(format) ? `${format}Seconds` : format;
14
+ return format.includes("ss") ? format : format.replace("mm", "mm:ss");
15
+ }
12
16
  function pad(n, width = 2) {
13
17
  return String(n).padStart(width, "0");
14
18
  }
@@ -16,15 +20,29 @@ var WrDateStamp = class WrDateStamp {
16
20
  constructor() {
17
21
  if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("date-stamp");
18
22
  }
23
+ defaults = inject(WR_DATE_STAMP_DEFAULTS);
19
24
  value = input(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
20
- dateFormat = input("mediumDate", ...ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []);
21
- timeFormat = input("time", ...ngDevMode ? [{ debugName: "timeFormat" }] : /* istanbul ignore next */ []);
25
+ dateFormat = input(this.defaults.dateFormat ?? "mediumDate", ...ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []);
26
+ timeFormat = input(this.defaults.timeFormat ?? "time", ...ngDevMode ? [{ debugName: "timeFormat" }] : /* istanbul ignore next */ []);
27
+ seconds = input(this.defaults.seconds ?? false, {
28
+ ...ngDevMode ? { debugName: "seconds" } : /* istanbul ignore next */ {},
29
+ transform: booleanAttribute
30
+ });
31
+ todayTimeOnly = input(this.defaults.todayTimeOnly ?? false, {
32
+ ...ngDevMode ? { debugName: "todayTimeOnly" } : /* istanbul ignore next */ {},
33
+ transform: booleanAttribute
34
+ });
35
+ epochUnit = input(null, ...ngDevMode ? [{ debugName: "epochUnit" }] : /* istanbul ignore next */ []);
22
36
  emptyLabel = input(null, ...ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []);
23
37
  resolvedEmptyLabel = useI18nText(this.emptyLabel, "copyValue.empty", "-");
24
38
  adapter = inject(WrDateAdapter);
25
39
  parts = computed(() => {
26
40
  const value = this.value();
27
- const date = wrParseDate(value);
41
+ const epochUnit = this.epochUnit();
42
+ const date = wrParseDate(value, {
43
+ ...this.adapter.parseOptions(),
44
+ ...epochUnit ? { epochUnit } : {}
45
+ });
28
46
  if (date === null) return null;
29
47
  if (wrIsDateOnly(value)) return {
30
48
  iso: `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`,
@@ -32,10 +50,11 @@ var WrDateStamp = class WrDateStamp {
32
50
  time: null
33
51
  };
34
52
  const zoned = this.adapter.zoned();
53
+ const timeFormat = this.timeFormat();
35
54
  return {
36
55
  iso: date.toISOString(),
37
- date: zoned.format(date, this.dateFormat()),
38
- time: zoned.format(date, this.timeFormat())
56
+ date: this.todayTimeOnly() && zoned.isSameDay(date, zoned.today()) ? null : zoned.format(date, this.dateFormat()),
57
+ time: zoned.format(date, this.seconds() ? withSeconds(timeFormat) : timeFormat)
39
58
  };
40
59
  }, ...ngDevMode ? [{ debugName: "parts" }] : /* istanbul ignore next */ []);
41
60
  static ɵfac = i0.ɵɵngDeclareFactory({
@@ -74,6 +93,27 @@ var WrDateStamp = class WrDateStamp {
74
93
  isRequired: false,
75
94
  transformFunction: null
76
95
  },
96
+ seconds: {
97
+ classPropertyName: "seconds",
98
+ publicName: "seconds",
99
+ isSignal: true,
100
+ isRequired: false,
101
+ transformFunction: null
102
+ },
103
+ todayTimeOnly: {
104
+ classPropertyName: "todayTimeOnly",
105
+ publicName: "todayTimeOnly",
106
+ isSignal: true,
107
+ isRequired: false,
108
+ transformFunction: null
109
+ },
110
+ epochUnit: {
111
+ classPropertyName: "epochUnit",
112
+ publicName: "epochUnit",
113
+ isSignal: true,
114
+ isRequired: false,
115
+ transformFunction: null
116
+ },
77
117
  emptyLabel: {
78
118
  classPropertyName: "emptyLabel",
79
119
  publicName: "emptyLabel",
@@ -87,7 +127,7 @@ var WrDateStamp = class WrDateStamp {
87
127
  classAttribute: "wr-date-stamp"
88
128
  },
89
129
  ngImport: i0,
90
- template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n",
130
+ template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n @if (stamp.date !== null) {\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n }\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n",
91
131
  encapsulation: i0.ViewEncapsulation.None
92
132
  });
93
133
  };
@@ -105,7 +145,7 @@ i0.ɵɵngDeclareClassMetadata({
105
145
  class: "wr-date-stamp",
106
146
  "[class.wr-date-stamp--empty]": "parts() === null"
107
147
  },
108
- template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"
148
+ template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n @if (stamp.date !== null) {\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n }\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"
109
149
  }]
110
150
  }],
111
151
  ctorParameters: () => [],
@@ -134,6 +174,30 @@ i0.ɵɵngDeclareClassMetadata({
134
174
  required: false
135
175
  }]
136
176
  }],
177
+ seconds: [{
178
+ type: i0.Input,
179
+ args: [{
180
+ isSignal: true,
181
+ alias: "seconds",
182
+ required: false
183
+ }]
184
+ }],
185
+ todayTimeOnly: [{
186
+ type: i0.Input,
187
+ args: [{
188
+ isSignal: true,
189
+ alias: "todayTimeOnly",
190
+ required: false
191
+ }]
192
+ }],
193
+ epochUnit: [{
194
+ type: i0.Input,
195
+ args: [{
196
+ isSignal: true,
197
+ alias: "epochUnit",
198
+ required: false
199
+ }]
200
+ }],
137
201
  emptyLabel: [{
138
202
  type: i0.Input,
139
203
  args: [{
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-date-stamp.mjs","names":[],"sources":["../../../projects/lib/date-stamp/date-stamp.ts","../../../projects/lib/date-stamp/date-stamp.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, computed, inject, input } from '@angular/core';\n\nimport { type WrDateFormat, WrDateAdapter, wrIsDateOnly, wrParseDate } from 'ngwr/date';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\ninterface Stamp {\n readonly iso: string;\n readonly date: string;\n readonly time: string | null;\n}\n\nfunction pad(n: number, width = 2): string {\n return String(n).padStart(width, '0');\n}\n\n/**\n * A moment in two lines, for a table cell: the date over the time.\n *\n * Both lines are written by the date adapter, so they are in the interface\n * language and, for an instant, on the wall clock of\n * `withDates({ timeZone })`, and they follow both at runtime. The value is read\n * as `wrDate` reads it: a `Date`, epoch milliseconds or a string. A date-only\n * string (`'2026-11-12'`) is a day, so it shows the date line alone and does\n * not shift with the zone.\n *\n * The lines sit in one `<time>` whose `datetime` is the instant in ISO 8601,\n * or the day for a date-only string. `null`, `undefined`, `''` and a value\n * that is not a date are empty: the component shows `emptyLabel`.\n *\n * @example\n * ```html\n * <wr-date-stamp [value]=\"row.createdAt\" />\n * <wr-date-stamp [value]=\"row.createdAt\" dateFormat=\"d MMM yyyy\" timeFormat=\"time24hSeconds\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/date-stamp\n */\n@Component({\n selector: 'wr-date-stamp',\n templateUrl: './date-stamp.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-date-stamp', '[class.wr-date-stamp--empty]': 'parts() === null' },\n})\nexport class WrDateStamp {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('date-stamp');\n }\n\n /**\n * The moment shown: a `Date`, epoch milliseconds, or a string `wrParseDate`\n * reads. `null`, `undefined`, `''` and a value that is not a date are empty.\n *\n * @default null\n */\n readonly value = input<Date | string | number | null | undefined>(null);\n\n /**\n * Format of the first line: a named key or a token string (`'d MMM yyyy'`).\n *\n * @default 'mediumDate'\n */\n readonly dateFormat = input<WrDateFormat | (string & {})>('mediumDate');\n\n /**\n * Format of the second line: a named key (`'time24hSeconds'`) or a token\n * string (`'HH:mm'`).\n *\n * @default 'time'\n */\n readonly timeFormat = input<WrDateFormat | (string & {})>('time');\n\n /** What stands in for an empty value. Falls back to `copyValue.empty`, then `'-'`. */\n readonly emptyLabel = input<string | null>(null);\n\n // The key `wr-copy-value` reads: one placeholder for an empty cell, whatever fills the cell.\n protected readonly resolvedEmptyLabel = useI18nText(this.emptyLabel, 'copyValue.empty', '-');\n\n private readonly adapter = inject<WrDateAdapter<Date>>(WrDateAdapter);\n\n protected readonly parts = computed<Stamp | null>(() => {\n const value = this.value();\n const date = wrParseDate(value);\n if (date === null) return null;\n\n if (wrIsDateOnly(value)) {\n return {\n iso: `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`,\n date: this.adapter.format(date, this.dateFormat()),\n time: null,\n };\n }\n\n const zoned = this.adapter.zoned();\n return {\n iso: date.toISOString(),\n date: zoned.format(date, this.dateFormat()),\n time: zoned.format(date, this.timeFormat()),\n };\n });\n}\n","@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAS,IAAI,GAAW,QAAQ,GAAC;CAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,GAAG;AACtC;AA8BA,IAAa,cAAb,MAAa,YAAW;CACtB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,YAAY;CAC/E;CAQS,QAAQ,MAAiD,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAO9D,aAAa,MAAoC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAQ9D,aAAa,MAAoC,QAAO,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAGxD,aAAa,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAG7B,qBAAqB,YAAY,KAAK,YAAY,mBAAmB,GAAG;CAE1E,UAAU,OAA4B,aAAa;CAEjD,QAAQ,eAA4B;EACrD,MAAM,QAAQ,KAAK,MAAK;EACxB,MAAM,OAAO,YAAY,KAAK;EAC9B,IAAI,SAAS,MAAM,OAAO;EAE1B,IAAI,aAAa,KAAK,GACpB,OAAO;GACL,KAAK,GAAG,IAAI,KAAK,YAAW,GAAI,CAAC,EAAC,GAAI,IAAI,KAAK,SAAQ,IAAK,CAAC,EAAC,GAAI,IAAI,KAAK,QAAO,CAAE;GACpF,MAAM,KAAK,QAAQ,OAAO,MAAM,KAAK,WAAU,CAAE;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../../../projects/lib/date-stamp/date-stamp.ts","../../../projects/lib/date-stamp/date-stamp.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, booleanAttribute, computed, inject, input } from '@angular/core';\n\nimport {\n type WrDateFormat,\n type WrEpochUnit,\n WR_DATE_STAMP_DEFAULTS,\n WrDateAdapter,\n wrIsDateOnly,\n wrIsNamedFormat,\n wrParseDate,\n} from 'ngwr/date';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\ninterface Stamp {\n readonly iso: string;\n readonly date: string | null;\n readonly time: string | null;\n}\n\n/** The format with seconds: the `Seconds` twin of a named key, `ss` after the minutes of a token string. */\nfunction withSeconds(format: string): string {\n if (wrIsNamedFormat(format)) return /^(?:time|shortDateTime)(?:12h|24h)?$/.test(format) ? `${format}Seconds` : format;\n return format.includes('ss') ? format : format.replace('mm', 'mm:ss');\n}\n\nfunction pad(n: number, width = 2): string {\n return String(n).padStart(width, '0');\n}\n\n/**\n * A moment in two lines, for a table cell: the date over the time.\n *\n * Both lines are written by the date adapter, so they are in the interface\n * language and, for an instant, on the wall clock of\n * `withDates({ timeZone })`, and they follow both at runtime. The value is read\n * as `wrDate` reads it: a `Date`, an epoch number or a string, under the\n * `epochUnit` and `zonelessIn` of `withDates()`. A date-only string\n * (`'2026-11-12'`) is a day, so it shows the date line alone and does not\n * shift with the zone.\n *\n * `withDates({ stamp })` sets the formats, `todayTimeOnly` and `seconds` for\n * every stamp of the app; an input set here wins.\n *\n * The lines sit in one `<time>` whose `datetime` is the instant in ISO 8601,\n * or the day for a date-only string. `null`, `undefined`, `''` and a value\n * that is not a date are empty: the component shows `emptyLabel`.\n *\n * @example\n * ```html\n * <wr-date-stamp [value]=\"row.createdAt\" />\n * <wr-date-stamp [value]=\"row.createdAt\" dateFormat=\"d MMM yyyy\" timeFormat=\"time24hSeconds\" />\n * <wr-date-stamp [value]=\"message.sentAt\" todayTimeOnly seconds />\n * ```\n *\n * @see https://ngwr.dev/reference/components/date-stamp\n */\n@Component({\n selector: 'wr-date-stamp',\n templateUrl: './date-stamp.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-date-stamp', '[class.wr-date-stamp--empty]': 'parts() === null' },\n})\nexport class WrDateStamp {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('date-stamp');\n }\n\n private readonly defaults = inject(WR_DATE_STAMP_DEFAULTS);\n\n /**\n * The moment shown: a `Date`, an epoch number, or a string `wrParseDate`\n * reads. `null`, `undefined`, `''` and a value that is not a date are empty.\n *\n * @default null\n */\n readonly value = input<Date | string | number | null | undefined>(null);\n\n /**\n * Format of the first line: a named key or a token string (`'d MMM yyyy'`).\n * `withDates({ stamp })` changes the default.\n *\n * @default 'mediumDate'\n */\n readonly dateFormat = input<WrDateFormat | (string & {})>(this.defaults.dateFormat ?? 'mediumDate');\n\n /**\n * Format of the second line: a named key (`'time24hSeconds'`) or a token\n * string (`'HH:mm'`). `withDates({ stamp })` changes the default.\n *\n * @default 'time'\n */\n readonly timeFormat = input<WrDateFormat | (string & {})>(this.defaults.timeFormat ?? 'time');\n\n /**\n * Write the seconds in the time line: `'time'` is read as `'timeSeconds'`\n * and `'HH:mm'` as `'HH:mm:ss'`. A format that already has them is left\n * alone. `withDates({ stamp })` changes the default.\n *\n * @default false\n */\n readonly seconds = input(this.defaults.seconds ?? false, { transform: booleanAttribute });\n\n /**\n * Show the time alone for a value from today. Today is the day in the\n * display zone, read when the stamp renders: one left on screen past\n * midnight keeps its single line. A date-only value keeps its date.\n * `withDates({ stamp })` changes the default.\n *\n * @default false\n */\n readonly todayTimeOnly = input(this.defaults.todayTimeOnly ?? false, { transform: booleanAttribute });\n\n /**\n * What a number in `value` counts since the epoch: `'ms'`, `'us'`, `'s'` or\n * `'auto'`, by size. `null` follows `withDates({ epochUnit })`.\n *\n * @default null\n */\n readonly epochUnit = input<WrEpochUnit | null>(null);\n\n /** What stands in for an empty value. Falls back to `copyValue.empty`, then `'-'`. */\n readonly emptyLabel = input<string | null>(null);\n\n // The key `wr-copy-value` reads: one placeholder for an empty cell, whatever fills the cell.\n protected readonly resolvedEmptyLabel = useI18nText(this.emptyLabel, 'copyValue.empty', '-');\n\n private readonly adapter = inject<WrDateAdapter<Date>>(WrDateAdapter);\n\n protected readonly parts = computed<Stamp | null>(() => {\n const value = this.value();\n const epochUnit = this.epochUnit();\n const date = wrParseDate(value, { ...this.adapter.parseOptions(), ...(epochUnit ? { epochUnit } : {}) });\n if (date === null) return null;\n\n if (wrIsDateOnly(value)) {\n return {\n iso: `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`,\n date: this.adapter.format(date, this.dateFormat()),\n time: null,\n };\n }\n\n const zoned = this.adapter.zoned();\n const timeFormat = this.timeFormat();\n return {\n iso: date.toISOString(),\n date: this.todayTimeOnly() && zoned.isSameDay(date, zoned.today()) ? null : zoned.format(date, this.dateFormat()),\n time: zoned.format(date, this.seconds() ? withSeconds(timeFormat) : timeFormat),\n };\n });\n}\n","@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\">\n @if (stamp.date !== null) {\n <span class=\"wr-date-stamp__date\">{{ stamp.date }}</span>\n }\n @if (stamp.time !== null) {\n <span class=\"wr-date-stamp__time\">{{ stamp.time }}</span>\n }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAAS,YAAY,QAAc;CACjC,IAAI,gBAAgB,MAAM,GAAG,OAAO,uCAAuC,KAAK,MAAM,IAAI,GAAG,OAAM,WAAY;CAC/G,OAAO,OAAO,SAAS,IAAI,IAAI,SAAS,OAAO,QAAQ,MAAM,OAAO;AACtE;AAEA,SAAS,IAAI,GAAW,QAAQ,GAAC;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AAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,YAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,8BAAA,mBAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UCtExB;EAYA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AD0Da,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EANvB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAe,eAEV,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAiB,gCAAgC;GAAkB;GAAE,UAAA;EAAA,CAAA"}
@@ -27,6 +27,29 @@ const WR_DATE_TIME_ZONE = new InjectionToken("WR_DATE_TIME_ZONE", {
27
27
  * Use of this source code is governed by an MIT-style license that can be
28
28
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
29
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
+ */
30
53
  const WR_DATE_LOCALE_PINNED = new InjectionToken("WR_DATE_LOCALE_PINNED", {
31
54
  providedIn: "root",
32
55
  factory: () => false
@@ -275,7 +298,7 @@ const INTL_OPTIONS = {
275
298
  }
276
299
  };
277
300
  const NAMED_KEYS = new Set(Object.keys(INTL_OPTIONS));
278
- 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;
279
302
  function unquote(quoted) {
280
303
  return quoted === "" ? "'" : quoted.replaceAll("''", "'");
281
304
  }
@@ -289,6 +312,7 @@ function tokenToRegex(token, digits) {
289
312
  switch (token) {
290
313
  case "yyyy": return `(${digits}{4})`;
291
314
  case "yy": return `(${digits}{2})`;
315
+ case "y": return `(${digits}{1,6})`;
292
316
  case "MM":
293
317
  case "dd":
294
318
  case "HH":
@@ -313,6 +337,9 @@ var WrDateAdapter = class WrDateAdapter {
313
337
  displayKey() {
314
338
  return "";
315
339
  }
340
+ parseOptions() {
341
+ return {};
342
+ }
316
343
  static ɵfac = i0.ɵɵngDeclareFactory({
317
344
  minVersion: "12.0.0",
318
345
  version: "22.2.5",
@@ -377,6 +404,13 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
377
404
  displayKey() {
378
405
  return `${this.locale}|${this.zonal ? this.zone()?.id ?? "" : ""}`;
379
406
  }
407
+ input = inject(WR_DATE_INPUT);
408
+ parseOptions() {
409
+ return {
410
+ ...this.input,
411
+ timeZone: this.zoneSource?.() ?? null
412
+ };
413
+ }
380
414
  zone() {
381
415
  return wrResolveZone(this.zoneSource?.());
382
416
  }
@@ -627,6 +661,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
627
661
  switch (token) {
628
662
  case "yyyy": return pad(year, 4);
629
663
  case "yy": return pad(year % 100, 2);
664
+ case "y": return String(year);
630
665
  case "MMMM": return monthNames[month] ?? "";
631
666
  case "MMM": return monthShort[month] ?? "";
632
667
  case "MM": return pad(month + 1);
@@ -669,6 +704,7 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
669
704
  const n = digitsToNumber(raw, numerals);
670
705
  switch (token) {
671
706
  case "yyyy":
707
+ case "y":
672
708
  parts.year = n;
673
709
  break;
674
710
  case "yy":
@@ -932,10 +968,31 @@ function wrToLocalDate(value) {
932
968
  * Use of this source code is governed by an MIT-style license that can be
933
969
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
934
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
+ }
935
988
  const SPACE_SEPARATED = /^(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:(Z)|([+-]\d{2})(?::?(\d{2}))?)?$/i;
936
- function fromString(value) {
989
+ function fromString(value, options) {
937
990
  const text = String(value).trim();
938
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
+ }
939
996
  const match = SPACE_SEPARATED.exec(text);
940
997
  if (match === null) return wrToLocalDate(text);
941
998
  const [, day, time, seconds = "00", fraction, utc, hours, minutes = "00"] = match;
@@ -943,9 +1000,9 @@ function fromString(value) {
943
1000
  const zone = utc !== void 0 ? "Z" : hours === void 0 ? "" : `${hours}:${minutes}`;
944
1001
  return /* @__PURE__ */ new Date(`${day}T${time}:${seconds}${millis}${zone}`);
945
1002
  }
946
- function wrParseDate(value) {
1003
+ function wrParseDate(value, options = {}) {
947
1004
  if (value === null || value === void 0) return null;
948
- const date = value instanceof Date ? value : typeof value === "number" ? new Date(value) : fromString(value);
1005
+ const date = value instanceof Date ? value : typeof value === "number" ? fromNumber(value, options.epochUnit ?? "ms") : fromString(value, options);
949
1006
  return date === null || Number.isNaN(date.getTime()) ? null : date;
950
1007
  }
951
1008
  /**
@@ -975,8 +1032,32 @@ function withDates(options = {}) {
975
1032
  return () => runInInjectionContext(injector, timeZone);
976
1033
  }
977
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
+ })
1058
+ });
978
1059
  return wrFeature("dates", providers);
979
1060
  }
980
- export { WR_DATE_LOCALE, WR_DATE_TIME_ZONE, WrDateAdapter, WrNativeDateAdapter, withDates, wrDateLocale, wrIsDateOnly, 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 };
981
1062
 
982
1063
  //# sourceMappingURL=ngwr-date.mjs.map