ngwr 16.8.0 → 16.9.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 (165) hide show
  1. package/descriptions/styles/_index.scss +91 -0
  2. package/fesm2022/ngwr-anchor.mjs +48 -10
  3. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  4. package/fesm2022/ngwr-carousel.mjs +3 -2
  5. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  6. package/fesm2022/ngwr-compare.mjs +4 -0
  7. package/fesm2022/ngwr-compare.mjs.map +1 -1
  8. package/fesm2022/ngwr-cookie.mjs +6 -3
  9. package/fesm2022/ngwr-cookie.mjs.map +1 -1
  10. package/fesm2022/ngwr-date-stamp-testing.mjs +3 -0
  11. package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
  12. package/fesm2022/ngwr-date-stamp.mjs +81 -4
  13. package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
  14. package/fesm2022/ngwr-date.mjs +16 -2
  15. package/fesm2022/ngwr-date.mjs.map +1 -1
  16. package/fesm2022/ngwr-density.mjs +4 -3
  17. package/fesm2022/ngwr-density.mjs.map +1 -1
  18. package/fesm2022/ngwr-descriptions.mjs +77 -20
  19. package/fesm2022/ngwr-descriptions.mjs.map +1 -1
  20. package/fesm2022/ngwr-directives.mjs +12 -0
  21. package/fesm2022/ngwr-directives.mjs.map +1 -1
  22. package/fesm2022/ngwr-editor.mjs +1 -0
  23. package/fesm2022/ngwr-editor.mjs.map +1 -1
  24. package/fesm2022/ngwr-file-upload.mjs +2 -3
  25. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  26. package/fesm2022/ngwr-form.mjs.map +1 -1
  27. package/fesm2022/ngwr-hotkey.mjs +10 -5
  28. package/fesm2022/ngwr-hotkey.mjs.map +1 -1
  29. package/fesm2022/ngwr-i18n-ar.mjs +9 -3
  30. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  31. package/fesm2022/ngwr-i18n-cs.mjs +9 -3
  32. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  33. package/fesm2022/ngwr-i18n-de.mjs +9 -3
  34. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  35. package/fesm2022/ngwr-i18n-en.mjs +9 -3
  36. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  37. package/fesm2022/ngwr-i18n-es.mjs +9 -3
  38. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  39. package/fesm2022/ngwr-i18n-fr.mjs +9 -3
  40. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  41. package/fesm2022/ngwr-i18n-he.mjs +9 -3
  42. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  43. package/fesm2022/ngwr-i18n-hi.mjs +9 -3
  44. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  45. package/fesm2022/ngwr-i18n-id.mjs +9 -3
  46. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  47. package/fesm2022/ngwr-i18n-it.mjs +9 -3
  48. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  49. package/fesm2022/ngwr-i18n-ja.mjs +9 -3
  50. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  51. package/fesm2022/ngwr-i18n-kk.mjs +9 -3
  52. package/fesm2022/ngwr-i18n-kk.mjs.map +1 -1
  53. package/fesm2022/ngwr-i18n-ko.mjs +9 -3
  54. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  55. package/fesm2022/ngwr-i18n-nl.mjs +9 -3
  56. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  57. package/fesm2022/ngwr-i18n-pl.mjs +9 -3
  58. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  59. package/fesm2022/ngwr-i18n-pt.mjs +9 -3
  60. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  61. package/fesm2022/ngwr-i18n-ru.mjs +9 -3
  62. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  63. package/fesm2022/ngwr-i18n-sv.mjs +9 -3
  64. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  65. package/fesm2022/ngwr-i18n-tr.mjs +9 -3
  66. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  67. package/fesm2022/ngwr-i18n-uk.mjs +9 -3
  68. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  69. package/fesm2022/ngwr-i18n-vi.mjs +9 -3
  70. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  71. package/fesm2022/ngwr-i18n-zh-tw.mjs +9 -3
  72. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  73. package/fesm2022/ngwr-i18n-zh.mjs +9 -3
  74. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  75. package/fesm2022/ngwr-i18n.mjs +7 -6
  76. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  77. package/fesm2022/ngwr-image-cropper-testing.mjs +33 -0
  78. package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -1
  79. package/fesm2022/ngwr-image-cropper.mjs +536 -30
  80. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  81. package/fesm2022/ngwr-knob.mjs +5 -0
  82. package/fesm2022/ngwr-knob.mjs.map +1 -1
  83. package/fesm2022/ngwr-mention.mjs +2 -0
  84. package/fesm2022/ngwr-mention.mjs.map +1 -1
  85. package/fesm2022/ngwr-meta.mjs +43 -8
  86. package/fesm2022/ngwr-meta.mjs.map +1 -1
  87. package/fesm2022/ngwr-pagination.mjs +1 -1
  88. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  89. package/fesm2022/ngwr-pipes.mjs +160 -8
  90. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  91. package/fesm2022/ngwr-qr.mjs +65 -7
  92. package/fesm2022/ngwr-qr.mjs.map +1 -1
  93. package/fesm2022/ngwr-schema-form.mjs +2 -2
  94. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  95. package/fesm2022/ngwr-scroll.mjs +1 -2
  96. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  97. package/fesm2022/ngwr-speed-dial.mjs +30 -1
  98. package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
  99. package/fesm2022/ngwr-statistic.mjs +1 -1
  100. package/fesm2022/ngwr-stepper-testing.mjs +7 -1
  101. package/fesm2022/ngwr-stepper-testing.mjs.map +1 -1
  102. package/fesm2022/ngwr-stepper.mjs +55 -4
  103. package/fesm2022/ngwr-stepper.mjs.map +1 -1
  104. package/fesm2022/ngwr-timeline.mjs +4 -0
  105. package/fesm2022/ngwr-timeline.mjs.map +1 -1
  106. package/fesm2022/ngwr-toolbar.mjs +171 -16
  107. package/fesm2022/ngwr-toolbar.mjs.map +1 -1
  108. package/fesm2022/ngwr-transfer.mjs +3 -2
  109. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  110. package/fesm2022/ngwr-tree.mjs +1 -1
  111. package/fesm2022/ngwr-utils.mjs +46 -8
  112. package/fesm2022/ngwr-utils.mjs.map +1 -1
  113. package/fesm2022/ngwr-version.mjs +1 -1
  114. package/fesm2022/ngwr-version.mjs.map +1 -1
  115. package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
  116. package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
  117. package/i18n/ar.json +9 -3
  118. package/i18n/cs.json +9 -3
  119. package/i18n/de.json +9 -3
  120. package/i18n/en.json +9 -3
  121. package/i18n/es.json +9 -3
  122. package/i18n/fr.json +9 -3
  123. package/i18n/he.json +9 -3
  124. package/i18n/hi.json +9 -3
  125. package/i18n/id.json +9 -3
  126. package/i18n/it.json +9 -3
  127. package/i18n/ja.json +9 -3
  128. package/i18n/kk.json +9 -3
  129. package/i18n/ko.json +9 -3
  130. package/i18n/nl.json +9 -3
  131. package/i18n/pl.json +9 -3
  132. package/i18n/pt.json +9 -3
  133. package/i18n/ru.json +9 -3
  134. package/i18n/sv.json +9 -3
  135. package/i18n/tr.json +9 -3
  136. package/i18n/uk.json +9 -3
  137. package/i18n/vi.json +9 -3
  138. package/i18n/zh-TW.json +9 -3
  139. package/i18n/zh.json +9 -3
  140. package/image-cropper/styles/_index.scss +30 -1
  141. package/llms-full.txt +5 -5
  142. package/package.json +1 -1
  143. package/schematics/use/symbol-map.json +1 -0
  144. package/skills/ngwr/SKILL.md +2 -2
  145. package/stepper/styles/_index.scss +33 -0
  146. package/types/ngwr-anchor.d.ts +14 -1
  147. package/types/ngwr-date-stamp-testing.d.ts +2 -0
  148. package/types/ngwr-date-stamp.d.ts +41 -2
  149. package/types/ngwr-date.d.ts +3 -1
  150. package/types/ngwr-descriptions.d.ts +33 -5
  151. package/types/ngwr-directives.d.ts +1 -0
  152. package/types/ngwr-form.d.ts +4 -0
  153. package/types/ngwr-hotkey.d.ts +2 -0
  154. package/types/ngwr-image-cropper-testing.d.ts +33 -1
  155. package/types/ngwr-image-cropper.d.ts +214 -6
  156. package/types/ngwr-meta.d.ts +13 -1
  157. package/types/ngwr-pipes.d.ts +125 -1
  158. package/types/ngwr-qr.d.ts +17 -0
  159. package/types/ngwr-speed-dial.d.ts +10 -0
  160. package/types/ngwr-stepper-testing.d.ts +10 -0
  161. package/types/ngwr-stepper.d.ts +47 -1
  162. package/types/ngwr-toolbar.d.ts +27 -0
  163. package/types/ngwr-transfer.d.ts +2 -0
  164. package/types/ngwr-utils.d.ts +61 -2
  165. package/types/ngwr-version.d.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-cookie.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/cookie/cookie.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 { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport type { WrCookieOptions } from './types';\n\nconst DEFAULT_OPTS: Required<Pick<WrCookieOptions, 'path' | 'sameSite'>> = {\n path: '/',\n sameSite: 'Lax',\n};\n\n/**\n * Thin, SSR-safe `document.cookie` wrapper modelled after {@link WrStorage}.\n *\n * - Read/write/delete cookies through a typed API.\n * - `set()` serialises `expires` as either an HTTP-date or `Max-Age`.\n * - Every method short-circuits when there's no DOM (SSR / unit tests\n * without a document) — reads return the fallback, writes are no-ops.\n *\n * @example\n * ```ts\n * const cookies = inject(WrCookie);\n *\n * cookies.set('theme', 'dark', { expires: 60 * 60 * 24 * 30 }); // 30 days\n * cookies.get('theme'); // 'dark'\n * cookies.has('theme'); // true\n * cookies.remove('theme');\n * cookies.keys(); // readonly string[]\n * ```\n *\n * @see https://ngwr.dev/reference/services/cookie\n */\n@Service()\nexport class WrCookie {\n private readonly doc = inject(DOCUMENT);\n\n /**\n * `document.cookie`, or `''` when it cannot be read. Mirrors the guard on\n * `set()`: under SSR the server DOM has no cookie support and throws on the\n * getter, and sandboxed iframes reject access too.\n */\n private read(): string {\n try {\n return this.doc.cookie;\n } catch {\n return '';\n }\n }\n\n /** Is `key` present (regardless of value)? */\n has(key: string): boolean {\n return this.get(key) !== null;\n }\n\n /** Read `key`. Returns `fallback` (default `null`) when the key is missing. */\n get(key: string, fallback: string | null = null): string | null {\n const raw = this.read();\n if (!raw) return fallback;\n const needle = `${encodeURIComponent(key)}=`;\n for (const part of raw.split(';')) {\n const trimmed = part.trim();\n if (trimmed.startsWith(needle)) {\n try {\n return decodeURIComponent(trimmed.slice(needle.length));\n } catch {\n return trimmed.slice(needle.length);\n }\n }\n }\n return fallback;\n }\n\n /** Write `key=value` with optional attributes. */\n set(key: string, value: string, options?: WrCookieOptions): void {\n const opts = { ...DEFAULT_OPTS, ...options };\n const parts: string[] = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];\n\n if (opts.expires !== undefined) {\n if (opts.expires instanceof Date) {\n parts.push(`expires=${opts.expires.toUTCString()}`);\n } else {\n parts.push(`max-age=${Math.max(0, Math.floor(opts.expires))}`);\n }\n }\n\n parts.push(`path=${opts.path}`);\n if (opts.domain) parts.push(`domain=${opts.domain}`);\n // `SameSite=None` REQUIRES `Secure`: every modern browser drops the cookie outright\n // without it, so asking for one without the other used to be a silent no-op — the one\n // failure a cookie API must not have. The caller asked for a cross-site cookie, and\n // this is what one is.\n if (opts.secure || opts.sameSite === 'None') parts.push('secure');\n parts.push(`samesite=${opts.sameSite}`);\n\n try {\n this.doc.cookie = parts.join('; ');\n } catch {\n // SSR / sandboxed iframes: silently no-op.\n }\n }\n\n /** Remove `key`. Path / domain must match what was used in `set()`. */\n remove(key: string, options?: Pick<WrCookieOptions, 'path' | 'domain'>): void {\n this.set(key, '', { ...options, expires: new Date(0) });\n }\n\n /** Every cookie key visible to this document. */\n keys(): readonly string[] {\n const raw = this.read();\n if (!raw) return [];\n const out: string[] = [];\n for (const part of raw.split(';')) {\n const trimmed = part.trim();\n const eq = trimmed.indexOf('=');\n if (eq < 0) continue;\n try {\n out.push(decodeURIComponent(trimmed.slice(0, eq)));\n } catch {\n out.push(trimmed.slice(0, eq));\n }\n }\n return out;\n }\n\n /** Remove every cookie visible to this document. Uses `path: '/'`. */\n clear(): void {\n for (const k of this.keys()) this.remove(k);\n }\n}\n\nexport type { WrCookieOptions } from './types';\n"],"mappings":";;;;;;;;;AAYA,MAAM,eAAqE;CACzE,MAAM;CACN,UAAU;AACX;AAwBD,IAAa,WAAb,MAAa,SAAQ;CACF,MAAM,OAAOA,UAAQ;CAO9B,OAAI;EACV,IAAI;GACF,OAAO,KAAK,IAAI;EAClB,QAAQ;GACN,OAAO;EACT;CACF;CAGA,IAAI,KAAW;EACb,OAAO,KAAK,IAAI,GAAG,MAAM;CAC3B;CAGA,IAAI,KAAa,WAA0B,MAAI;EAC7C,MAAM,MAAM,KAAK,KAAI;EACrB,IAAI,CAAC,KAAK,OAAO;EACjB,MAAM,SAAS,GAAG,mBAAmB,GAAG,EAAC;EACzC,KAAK,MAAM,QAAQ,IAAI,MAAM,GAAG,GAAG;GACjC,MAAM,UAAU,KAAK,KAAI;GACzB,IAAI,QAAQ,WAA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AI,KAAK,QAAQ,MAAM,GAAG,EAAE,CAAC;GAC/B;EACF;EACA,OAAO;CACT;CAGA,QAAK;EACH,KAAK,MAAM,KAAK,KAAK,KAAI,GAAI,KAAK,OAAO,CAAC;CAC5C;CA9FW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAQ,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA,EADpB,MAAA,Q"}
1
+ {"version":3,"file":"ngwr-cookie.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/cookie/cookie.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 { DOCUMENT } from '@angular/common';\nimport { Service, inject } from '@angular/core';\n\nimport type { WrCookieOptions } from './types';\n\nconst DEFAULT_OPTS: Required<Pick<WrCookieOptions, 'path' | 'sameSite'>> = {\n path: '/',\n sameSite: 'Lax',\n};\n\n/**\n * Thin, SSR-safe `document.cookie` wrapper modelled after {@link WrStorage}.\n *\n * - Read/write/delete cookies through a typed API.\n * - `set()` serialises `expires` as either an HTTP-date or `Max-Age`.\n * - Every method short-circuits when there's no DOM (SSR / unit tests\n * without a document) — reads return the fallback, writes are no-ops.\n *\n * @example\n * ```ts\n * const cookies = inject(WrCookie);\n *\n * cookies.set('theme', 'dark', { expires: 60 * 60 * 24 * 30 }); // 30 days\n * cookies.get('theme'); // 'dark'\n * cookies.has('theme'); // true\n * cookies.remove('theme');\n * cookies.keys(); // readonly string[]\n * ```\n *\n * @see https://ngwr.dev/reference/services/cookie\n */\n@Service()\nexport class WrCookie {\n private readonly doc = inject(DOCUMENT);\n\n /**\n * `document.cookie`, or `''` when it cannot be read. Mirrors the guard on\n * `set()`: under SSR the server DOM has no cookie support and throws on the\n * getter, and sandboxed iframes reject access too.\n */\n private read(): string {\n try {\n return this.doc.cookie;\n } catch {\n return '';\n }\n }\n\n /** Is `key` present (regardless of value)? */\n has(key: string): boolean {\n return this.get(key) !== null;\n }\n\n /** Read `key`. Returns `fallback` (default `null`) when the key is missing. */\n get(key: string, fallback: string | null = null): string | null {\n const raw = this.read();\n if (!raw) return fallback;\n const needle = `${encodeURIComponent(key)}=`;\n for (const part of raw.split(';')) {\n const trimmed = part.trim();\n if (trimmed.startsWith(needle)) {\n try {\n return decodeURIComponent(trimmed.slice(needle.length));\n } catch {\n return trimmed.slice(needle.length);\n }\n }\n }\n return fallback;\n }\n\n /** Write `key=value` with optional attributes. */\n set(key: string, value: string, options?: WrCookieOptions): void {\n const opts = { ...DEFAULT_OPTS, ...options };\n const parts: string[] = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];\n\n if (opts.expires !== undefined) {\n if (opts.expires instanceof Date) {\n parts.push(`expires=${opts.expires.toUTCString()}`);\n } else {\n parts.push(`max-age=${Math.max(0, Math.floor(opts.expires))}`);\n }\n }\n\n // A `__Host-` / `__Secure-` name is rejected by the browser without `Secure`, and `__Host-`\n // also needs `Path=/` and no `Domain`, so those follow from the name.\n const lowerKey = key.toLowerCase();\n const host = lowerKey.startsWith('__host-');\n const prefixed = host || lowerKey.startsWith('__secure-');\n\n parts.push(`path=${host ? '/' : opts.path}`);\n if (opts.domain && !host) parts.push(`domain=${opts.domain}`);\n // `SameSite=None` REQUIRES `Secure`: every modern browser drops the cookie outright\n // without it, so asking for one without the other used to be a silent no-op — the one\n // failure a cookie API must not have. The caller asked for a cross-site cookie, and\n // this is what one is.\n if (opts.secure || prefixed || opts.sameSite === 'None') parts.push('secure');\n parts.push(`samesite=${opts.sameSite}`);\n\n try {\n this.doc.cookie = parts.join('; ');\n } catch {\n // SSR / sandboxed iframes: silently no-op.\n }\n }\n\n /** Remove `key`. Path / domain must match what was used in `set()`. */\n remove(key: string, options?: Pick<WrCookieOptions, 'path' | 'domain'>): void {\n this.set(key, '', { ...options, expires: new Date(0) });\n }\n\n /** Every cookie key visible to this document. */\n keys(): readonly string[] {\n const raw = this.read();\n if (!raw) return [];\n const out: string[] = [];\n for (const part of raw.split(';')) {\n const trimmed = part.trim();\n const eq = trimmed.indexOf('=');\n if (eq < 0) continue;\n try {\n out.push(decodeURIComponent(trimmed.slice(0, eq)));\n } catch {\n out.push(trimmed.slice(0, eq));\n }\n }\n return out;\n }\n\n /** Remove every cookie visible to this document. Uses `path: '/'`. */\n clear(): void {\n for (const k of this.keys()) this.remove(k);\n }\n}\n\nexport type { WrCookieOptions } from './types';\n"],"mappings":";;;;;;;;;AAYA,MAAM,eAAqE;CACzE,MAAM;CACN,UAAU;AACX;AAwBD,IAAa,WAAb,MAAa,SAAQ;CACF,MAAM,OAAOA,UAAQ;CAO9B,OAAI;EACV,IAAI;GACF,OAAO,KAAK,IAAI;EAClB,QAAQ;GACN,OAAO;EACT;CACF;CAGA,IAAI,KAAW;EACb,OAAO,KAAK,IAAI,GAAG,MAAM;CAC3B;CAGA,IAAI,KAAa,WAA0B,MAAI;EAC7C,MAAM,MAAM,KAAK,KAAI;EACrB,IAAI,CAAC,KAAK,OAAO;EACjB,MAAM,SAAS,GAAG,mBAAmB,GAAG,EAAC;EACzC,KAAK,MAAM,QAAQ,IAAI,MAAM,GAAG,GAAG;GACjC,MAAM,UAAU,KAAK,KAAI;GACzB,IAAI,QAAQ,WAAW,MAAM,GAC3B,IAAI;IACF,OAAO,mBAAmB,QAAQ,MAAM,OAAO,MAAM,CAAC;GACxD,QAAQ;IACN,OAAO,QAAQ,MAAM,OAAO,MAAM;GACpC;EAEJ;EACA,OAAO;CACT;CAGA,IAAI,KAAa,OAAe,SAAyB;EACvD,MAAM,OAAO;GAAE,GAAG;GAAc,GAAG;EA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KAAK,MAAM,KAAK,KAAK,KAAI,GAAI,KAAK,OAAO,CAAC;CAC5C;CApGW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAQ,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA,EADpB,MAAA,Q"}
@@ -17,6 +17,9 @@ var WrDateStampHarness = class WrDateStampHarness extends ComponentHarness {
17
17
  async getTime() {
18
18
  return await (await this.locatorForOptional(".wr-date-stamp__time")())?.text() ?? null;
19
19
  }
20
+ async getRelative() {
21
+ return await (await this.locatorForOptional(".wr-date-stamp__relative")())?.text() ?? null;
22
+ }
20
23
  async getDateTime() {
21
24
  return await (await this.time())?.getAttribute("datetime") ?? null;
22
25
  }
@@ -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 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
+ {"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 /** The relative line (\"5 minutes ago\"), or `null` when the stamp is empty or not `relative`. */\n async getRelative(): Promise<string | null> {\n return (await (await this.locatorForOptional('.wr-date-stamp__relative')())?.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;CAGA,MAAM,cAAW;EACf,OAAQ,OAAO,MAAM,KAAK,mBAAmB,0BAA0B,CAAC,CAAA,EAAA,EAAK,KAAI,KAAO;CAC1F;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,8 +1,9 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, booleanAttribute, computed, inject, input } from "@angular/core";
2
+ import { Component, Injector, ViewEncapsulation, afterNextRender, booleanAttribute, computed, effect, inject, input, linkedSignal } from "@angular/core";
3
3
  import { wrCheckStyles } from "ngwr/utils";
4
4
  import { useI18nText } from "ngwr/i18n";
5
- import { WR_DATE_STAMP_DEFAULTS, WrDateAdapter, wrIsDateOnly, wrIsNamedFormat, wrParseDate } from "ngwr/date";
5
+ import { WR_DATE_STAMP_DEFAULTS, WrDateAdapter, wrDateLocale, wrIsDateOnly, wrIsNamedFormat, wrParseDate } from "ngwr/date";
6
+ import { wrFormatRelativeTime } from "ngwr/pipes";
6
7
  /**
7
8
  * @license
8
9
  *
@@ -16,9 +17,28 @@ function withSeconds(format) {
16
17
  function pad(n, width = 2) {
17
18
  return String(n).padStart(width, "0");
18
19
  }
20
+ const SECOND = 1e3;
21
+ const MINUTE = 60 * SECOND;
22
+ const HOUR = 60 * MINUTE;
23
+ const DAY = 24 * HOUR;
24
+ function untilNextText(distance) {
25
+ const size = Math.abs(distance);
26
+ const step = size < MINUTE ? SECOND : size < HOUR ? MINUTE : size < DAY ? HOUR : DAY;
27
+ return distance > 0 ? size % step + 1 : step - size % step;
28
+ }
19
29
  var WrDateStamp = class WrDateStamp {
20
30
  constructor() {
21
31
  if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("date-stamp");
32
+ const injector = inject(Injector);
33
+ afterNextRender(() => {
34
+ effect((onCleanup) => {
35
+ this.now();
36
+ const delay = this.untilNextText(Date.now());
37
+ if (delay === null) return;
38
+ const timer = setTimeout(() => this.now.set(Date.now()), delay);
39
+ onCleanup(() => clearTimeout(timer));
40
+ }, { injector });
41
+ });
22
42
  }
23
43
  defaults = inject(WR_DATE_STAMP_DEFAULTS);
24
44
  value = input(null, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
@@ -32,6 +52,10 @@ var WrDateStamp = class WrDateStamp {
32
52
  ...ngDevMode ? { debugName: "todayTimeOnly" } : /* istanbul ignore next */ {},
33
53
  transform: booleanAttribute
34
54
  });
55
+ relative = input(this.defaults.relative ?? false, {
56
+ ...ngDevMode ? { debugName: "relative" } : /* istanbul ignore next */ {},
57
+ transform: booleanAttribute
58
+ });
35
59
  epochUnit = input(null, ...ngDevMode ? [{ debugName: "epochUnit" }] : /* istanbul ignore next */ []);
36
60
  emptyLabel = input(null, ...ngDevMode ? [{ debugName: "emptyLabel" }] : /* istanbul ignore next */ []);
37
61
  resolvedEmptyLabel = useI18nText(this.emptyLabel, "copyValue.empty", "-");
@@ -45,6 +69,8 @@ var WrDateStamp = class WrDateStamp {
45
69
  });
46
70
  if (date === null) return null;
47
71
  if (wrIsDateOnly(value)) return {
72
+ at: date,
73
+ dayOnly: true,
48
74
  iso: `${pad(date.getFullYear(), 4)}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`,
49
75
  date: this.adapter.format(date, this.dateFormat()),
50
76
  time: null
@@ -52,11 +78,47 @@ var WrDateStamp = class WrDateStamp {
52
78
  const zoned = this.adapter.zoned();
53
79
  const timeFormat = this.timeFormat();
54
80
  return {
81
+ at: date,
82
+ dayOnly: false,
55
83
  iso: date.toISOString(),
56
84
  date: this.todayTimeOnly() && zoned.isSameDay(date, zoned.today()) ? null : zoned.format(date, this.dateFormat()),
57
85
  time: zoned.format(date, this.seconds() ? withSeconds(timeFormat) : timeFormat)
58
86
  };
59
87
  }, ...ngDevMode ? [{ debugName: "parts" }] : /* istanbul ignore next */ []);
88
+ locale = wrDateLocale();
89
+ now = linkedSignal(() => {
90
+ this.value();
91
+ this.relative();
92
+ return Date.now();
93
+ }, ...ngDevMode ? [{ debugName: "now" }] : /* istanbul ignore next */ []);
94
+ today = computed(() => {
95
+ const zoned = this.adapter.zoned();
96
+ const now = new Date(this.now());
97
+ return zoned.createDate(zoned.getYear(now), zoned.getMonth(now), zoned.getDate(now));
98
+ }, ...ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []);
99
+ relativeText = computed(() => {
100
+ const stamp = this.parts();
101
+ if (stamp === null || !this.relative()) return null;
102
+ if (!stamp.dayOnly) return wrFormatRelativeTime(stamp.at, this.locale(), { now: this.now() });
103
+ const zoned = this.adapter.zoned();
104
+ const today = this.today();
105
+ const local = new Date(zoned.getYear(today), zoned.getMonth(today), zoned.getDate(today));
106
+ return wrFormatRelativeTime(this.value(), this.locale(), { now: local });
107
+ }, ...ngDevMode ? [{ debugName: "relativeText" }] : /* istanbul ignore next */ []);
108
+ title = computed(() => {
109
+ const stamp = this.parts();
110
+ if (stamp === null || !this.relative()) return null;
111
+ return [stamp.date, stamp.time].filter((line) => line !== null).join(", ");
112
+ }, ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
113
+ untilNextText(now) {
114
+ const stamp = this.parts();
115
+ if (stamp === null || !this.relative()) return null;
116
+ if (!stamp.dayOnly) return untilNextText(stamp.at.getTime() - now);
117
+ const zoned = this.adapter.zoned();
118
+ const today = this.today();
119
+ const next = zoned.createDate(zoned.getYear(today), zoned.getMonth(today), zoned.getDate(today) + 1);
120
+ return Math.max(1, next.getTime() - now);
121
+ }
60
122
  static ɵfac = i0.ɵɵngDeclareFactory({
61
123
  minVersion: "12.0.0",
62
124
  version: "22.3.0",
@@ -107,6 +169,13 @@ var WrDateStamp = class WrDateStamp {
107
169
  isRequired: false,
108
170
  transformFunction: null
109
171
  },
172
+ relative: {
173
+ classPropertyName: "relative",
174
+ publicName: "relative",
175
+ isSignal: true,
176
+ isRequired: false,
177
+ transformFunction: null
178
+ },
110
179
  epochUnit: {
111
180
  classPropertyName: "epochUnit",
112
181
  publicName: "epochUnit",
@@ -127,7 +196,7 @@ var WrDateStamp = class WrDateStamp {
127
196
  classAttribute: "wr-date-stamp"
128
197
  },
129
198
  ngImport: i0,
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",
199
+ template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\" [attr.title]=\"title()\">\n @if (relativeText(); as text) {\n <span class=\"wr-date-stamp__relative\">{{ text }}</span>\n } @else {\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 }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n",
131
200
  encapsulation: i0.ViewEncapsulation.None
132
201
  });
133
202
  };
@@ -145,7 +214,7 @@ i0.ɵɵngDeclareClassMetadata({
145
214
  class: "wr-date-stamp",
146
215
  "[class.wr-date-stamp--empty]": "parts() === null"
147
216
  },
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"
217
+ template: "@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\" [attr.title]=\"title()\">\n @if (relativeText(); as text) {\n <span class=\"wr-date-stamp__relative\">{{ text }}</span>\n } @else {\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 }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"
149
218
  }]
150
219
  }],
151
220
  ctorParameters: () => [],
@@ -190,6 +259,14 @@ i0.ɵɵngDeclareClassMetadata({
190
259
  required: false
191
260
  }]
192
261
  }],
262
+ relative: [{
263
+ type: i0.Input,
264
+ args: [{
265
+ isSignal: true,
266
+ alias: "relative",
267
+ required: false
268
+ }]
269
+ }],
193
270
  epochUnit: [{
194
271
  type: i0.Input,
195
272
  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, 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":";;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mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,eAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,WAAA;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"}
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 {\n Component,\n Injector,\n ViewEncapsulation,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n linkedSignal,\n} from '@angular/core';\n\nimport {\n type WrDateFormat,\n type WrEpochUnit,\n WR_DATE_STAMP_DEFAULTS,\n WrDateAdapter,\n wrDateLocale,\n wrIsDateOnly,\n wrIsNamedFormat,\n wrParseDate,\n} from 'ngwr/date';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrFormatRelativeTime } from 'ngwr/pipes';\nimport { wrCheckStyles } from 'ngwr/utils';\n\ninterface Stamp {\n readonly at: Date;\n readonly dayOnly: boolean;\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\nconst SECOND = 1000;\nconst MINUTE = 60 * SECOND;\nconst HOUR = 60 * MINUTE;\nconst DAY = 24 * HOUR;\n\n/**\n * Milliseconds until the relative text of an instant `distance` away changes:\n * the next whole second under a minute, minute under an hour, hour under a\n * day, then day. `wrFormatRelativeTime` cuts the count, so the text of a past\n * value moves on a whole step and the text of a coming one right after it.\n */\nfunction untilNextText(distance: number): number {\n const size = Math.abs(distance);\n const step = size < MINUTE ? SECOND : size < HOUR ? MINUTE : size < DAY ? HOUR : DAY;\n return distance > 0 ? (size % step) + 1 : step - (size % step);\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 * `relative` shows how far the moment is from now instead (\"5 minutes ago\"),\n * and keeps that text current on a timer. The date and the time stay in the\n * `title` of the `<time>`.\n *\n * `withDates({ stamp })` sets the formats, `todayTimeOnly`, `seconds` and\n * `relative` for 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 * <wr-date-stamp [value]=\"comment.createdAt\" relative />\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 // The browser only, and after the first paint: the server renders the text once and keeps no timer.\n const injector = inject(Injector);\n afterNextRender(() => {\n effect(\n onCleanup => {\n // Re-armed by each tick. Measured from the real clock, not the sample: a restart for\n // another reason (a new format) must not push the next change a whole step away.\n this.now();\n const delay = this.untilNextText(Date.now());\n if (delay === null) return;\n const timer = setTimeout(() => this.now.set(Date.now()), delay);\n onCleanup(() => clearTimeout(timer));\n },\n { injector }\n );\n });\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 * Show how far the moment is from now (\"5 minutes ago\", \"tomorrow\") in\n * place of the two lines, as `wrFormatRelativeTime` writes it, in the\n * language the stamp formats in. The text is kept current: it is written\n * again each second under a minute, each minute under an hour, each hour\n * under a day and each day after that, from a timer that starts after the\n * first render and never on the server. The date and the time move to the\n * `title` of the `<time>`. A date-only value is compared as a day (\"today\",\n * \"yesterday\"). `withDates({ stamp })` changes the default.\n *\n * @default false\n */\n readonly relative = input(this.defaults.relative ?? 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 at: date,\n dayOnly: true,\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 at: date,\n dayOnly: false,\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 private readonly locale = wrDateLocale();\n\n /**\n * The current time the relative text is measured from. The timer moves it,\n * and a new value or `relative` turned on reads the clock again: a stamp of\n * last year ticks once a day, and must not measure the next value from then.\n */\n private readonly now = linkedSignal(() => {\n this.value();\n this.relative();\n return Date.now();\n });\n\n /** Midnight of today in the display zone, which a date-only value is compared with. */\n private readonly today = computed(() => {\n const zoned = this.adapter.zoned();\n const now = new Date(this.now());\n return zoned.createDate(zoned.getYear(now), zoned.getMonth(now), zoned.getDate(now));\n });\n\n protected readonly relativeText = computed<string | null>(() => {\n const stamp = this.parts();\n if (stamp === null || !this.relative()) return null;\n if (!stamp.dayOnly) return wrFormatRelativeTime(stamp.at, this.locale(), { now: this.now() });\n\n // A day is not moved by the zone: it is compared with the zone's today as two local days.\n const zoned = this.adapter.zoned();\n const today = this.today();\n const local = new Date(zoned.getYear(today), zoned.getMonth(today), zoned.getDate(today));\n return wrFormatRelativeTime(this.value(), this.locale(), { now: local });\n });\n\n /** The two lines as one, for the `title` a relative stamp keeps them in. */\n protected readonly title = computed<string | null>(() => {\n const stamp = this.parts();\n if (stamp === null || !this.relative()) return null;\n return [stamp.date, stamp.time].filter(line => line !== null).join(', ');\n });\n\n /** Milliseconds to the next change of the relative text, `null` when there is none to keep current. */\n private untilNextText(now: number): number | null {\n const stamp = this.parts();\n if (stamp === null || !this.relative()) return null;\n if (!stamp.dayOnly) return untilNextText(stamp.at.getTime() - now);\n // Built, not added: on a day whose midnight the zone skips, `addDays` would keep the 01:00 it starts at.\n const zoned = this.adapter.zoned();\n const today = this.today();\n const next = zoned.createDate(zoned.getYear(today), zoned.getMonth(today), zoned.getDate(today) + 1);\n return Math.max(1, next.getTime() - now);\n }\n}\n","@if (parts(); as stamp) {\n <time class=\"wr-date-stamp__value\" [attr.datetime]=\"stamp.iso\" [attr.title]=\"title()\">\n @if (relativeText(); as text) {\n <span class=\"wr-date-stamp__relative\">{{ text }}</span>\n } @else {\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 }\n </time>\n} @else {\n <span class=\"wr-date-stamp__empty\">{{ resolvedEmptyLabel() }}</span>\n}\n"],"mappings":";;;;;;;;;;;;AA2CA,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;CAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO,GAAG;AACtC;AAEA,MAAM,SAAS;AACf,MAAM,SAAS,KAAK;AACpB,MAAM,OAAO,KAAK;AAClB,MAAM,MAAM,KAAK;AAQjB,SAAS,cAAc,UAAgB;CACrC,MAAM,OAAO,KAAK,IAAI,QAAQ;CAC9B,MAAM,OAAO,OAAO,SAAS,SAAS,OAAO,OAAO,SAAS,OAAO,MAAM,OAAO;CACjF,OAAO,WAAW,IAAK,OAAO,OAAQ,IAAI,OAAQ,OAAO;AAC3D;AAwCA,IAAa,cAAb,MAAa,YAAW;CACtB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,YAAY;EAG7E,MAAM,WAAW,OAAO,QAAQ;EAChC,sBAAqB;GACnB,QACE,cAAY;IAGV,KAAK,IAAG;IACR,MAAM,QAAQ,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AAE,OAAO;IAAiB,gCAAgC;GAAkB;GAAE,UAAA;EAAA,CAAA"}
@@ -214,6 +214,8 @@ function digitsToNumber(text, numerals) {
214
214
  function isAllDigits(text, numerals) {
215
215
  return text.length > 0 && !Number.isNaN(digitsToNumber(text, numerals));
216
216
  }
217
+ const SUNDAY_REGIONS = new Set("AG AS BD BR BS BT BW BZ CA CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW".split(" "));
218
+ const SATURDAY_REGIONS = new Set("AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY".split(" "));
217
219
  const SHORT_DATE = {
218
220
  year: "numeric",
219
221
  month: "numeric",
@@ -552,11 +554,23 @@ var WrNativeDateAdapter = class WrNativeDateAdapter extends WrDateAdapter {
552
554
  return this.parseWithTokens(raw, formatKeyOrString);
553
555
  }
554
556
  getFirstDayOfWeek() {
557
+ let region;
555
558
  try {
556
- const info = new Intl.Locale(this.locale).getWeekInfo?.();
559
+ const locale = new Intl.Locale(this.locale);
560
+ const info = locale.getWeekInfo?.() ?? locale.weekInfo;
557
561
  if (info && typeof info.firstDay === "number") return info.firstDay % 7;
562
+ region = locale.maximize().region;
558
563
  } catch {}
559
- return this.locale.toLowerCase().startsWith("en-us") ? 0 : 1;
564
+ if (!region) for (const part of this.locale.split(/[-_]/).slice(1)) {
565
+ if (part.length === 1) break;
566
+ if (/^[a-z]{2}$/i.test(part)) {
567
+ region = part.toUpperCase();
568
+ break;
569
+ }
570
+ }
571
+ if (region && SUNDAY_REGIONS.has(region)) return 0;
572
+ if (region && SATURDAY_REGIONS.has(region)) return 6;
573
+ return 1;
560
574
  }
561
575
  intlOptions(options) {
562
576
  return {