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-density.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/density/density-config.ts","../../../projects/lib/density/density.ts","../../../projects/lib/density/density.directive.ts","../../../projects/lib/density/with-density.ts","../../../projects/lib/density/pre-paint.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 { InjectionToken } from '@angular/core';\n\nimport type { WrDensityConfig } from './types';\n\nexport const DEFAULT_WR_DENSITY_CONFIG: WrDensityConfig = {\n defaultDensity: 'md',\n storageKey: 'wr-density',\n attribute: 'data-wr-density',\n};\n\nexport const WR_DENSITY_CONFIG = new InjectionToken<WrDensityConfig>('WR_DENSITY_CONFIG', {\n factory: (): WrDensityConfig => DEFAULT_WR_DENSITY_CONFIG,\n});\n\nexport type { WrDensityValue, WrDensityConfig } from './types';\n","/**\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, type Signal, effect, inject, signal } from '@angular/core';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\nconst VALID: readonly WrDensityValue[] = ['sm', 'md', 'lg', 'touch'];\n\nfunction isDensity(v: unknown): v is WrDensityValue {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v);\n}\n\n/**\n * Global density scale. Writes `[data-wr-density]` on `<html>` so the\n * stylesheet's density-scoped CSS-variable rules apply, then components\n * pick up the new multipliers without re-rendering.\n *\n * - **Per-subtree override** — drop `[wrDensity]` on any element; its\n * descendants read the override instead of the global value.\n * - **Persisted** via {@link WrStorage} (swap the engine globally if you\n * need a different store).\n * - **Booted at startup** by `provideWr(withDensity(...))`, which also sets\n * the default. Without it nothing writes the attribute until something\n * injects this service.\n *\n * @example\n * ```ts\n * const density = inject(WrDensity);\n * density.set('sm');\n * density.current(); // 'sm'\n * ```\n *\n * @see https://ngwr.dev/reference/services/density\n */\n@Service()\nexport class WrDensity {\n private readonly doc = inject(DOCUMENT);\n private readonly storage = inject(WrStorage);\n private readonly config = inject(WR_DENSITY_CONFIG);\n\n /** Active density. */\n readonly current: Signal<WrDensityValue>;\n\n private readonly _current = signal<WrDensityValue>(this.readPersisted() ?? this.config.defaultDensity);\n\n constructor() {\n this.current = this._current.asReadonly();\n effect(() => {\n const value = this._current();\n const html = this.doc.documentElement;\n if (html) html.setAttribute(this.config.attribute, value);\n this.persist(value);\n });\n }\n\n /** Switch the active density. Ignores unknown values. */\n set(density: WrDensityValue): void {\n if (!isDensity(density)) return;\n this._current.set(density);\n }\n\n /** Cycle sm → md → lg → touch → sm … */\n cycle(): void {\n const order: readonly WrDensityValue[] = ['sm', 'md', 'lg', 'touch'];\n const i = order.indexOf(this._current());\n this._current.set(order[(i + 1) % order.length]);\n }\n\n // Persistence\n\n private readPersisted(): WrDensityValue | null {\n if (!this.config.storageKey) return null;\n const raw = this.storage.get<WrDensityValue>(this.config.storageKey);\n return isDensity(raw) ? raw : null;\n }\n\n private persist(density: WrDensityValue): void {\n if (!this.config.storageKey) return;\n this.storage.set(this.config.storageKey, density);\n }\n}\n","/**\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 { Directive, ElementRef, effect, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\n/**\n * Scope a density override to a subtree. Writes the same `data-*`\n * attribute the global service writes — but on the host instead of\n * `<html>` — so the CSS-variable scope rules cascade only to descendants.\n *\n * @example\n * ```html\n * <!-- The whole sidebar is sm, the rest of the app keeps its global density. -->\n * <aside wrDensity=\"sm\">\n * <wr-list ...></wr-list>\n * </aside>\n * ```\n */\n@Directive({\n selector: '[wrDensity]',\n})\nexport class WrDensityDirective {\n /** Density to apply to this subtree. */\n readonly wrDensity = input.required<WrDensityValue>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly config = inject(WR_DENSITY_CONFIG);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('density');\n effect(() => {\n this.host.nativeElement.setAttribute(this.config.attribute, this.wrDensity());\n });\n }\n}\n","/**\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 { inject, provideEnvironmentInitializer } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { WrDensity } from './density';\nimport { DEFAULT_WR_DENSITY_CONFIG, WR_DENSITY_CONFIG, type WrDensityConfig } from './density-config';\n\n/**\n * Configure and activate {@link WrDensity}, as a feature of `provideWr()`. All\n * fields optional — merged with defaults.\n *\n * The initializer instantiates {@link WrDensity} so its constructor effect can\n * write `[data-wr-density]` onto `<html>`. Without it the tree-shakable service\n * was never created and `defaultDensity` had no effect at all.\n *\n * Bootstrap only: {@link WrDensity} is root-provided and reads its config once,\n * from the root injector.\n *\n * @example\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withDensity } from 'ngwr/density';\n *\n * bootstrapApplication(App, {\n * providers: [provideWr(withDensity({ defaultDensity: 'sm' }))],\n * });\n * ```\n */\nexport function withDensity(config: Partial<WrDensityConfig> = {}): WrFeature<'density'> {\n return wrFeature('density', [\n { provide: WR_DENSITY_CONFIG, useValue: { ...DEFAULT_WR_DENSITY_CONFIG, ...config } },\n provideEnvironmentInitializer(() => void inject(WrDensity)),\n ]);\n}\n","/**\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 { DEFAULT_WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\n/**\n * Every density the script accepts, written as a record so that a value added to\n * {@link WrDensityValue} fails to compile here instead of being refused by the\n * script in silence.\n */\nconst DENSITIES = Object.keys({ sm: true, md: true, lg: true, touch: true } satisfies Record<WrDensityValue, true>);\n\n/** Options for {@link wrDensityPrePaintScript}. All optional — defaults mirror the services. */\nexport interface WrDensityPrePaintOptions {\n /**\n * The key {@link WrDensity} persists the density under — `storageKey` in\n * `withDensity()`. `null` reads nothing, as `withDensity({ storageKey: null })`\n * persists nothing, and the script writes `defaultDensity`.\n * @default 'wr-density'\n */\n readonly storageKey?: string | null;\n /**\n * What to apply when nothing is persisted — `defaultDensity` in\n * `withDensity()`.\n * @default 'md'\n */\n readonly defaultDensity?: WrDensityValue;\n /**\n * The attribute written on `<html>` — `attribute` in `withDensity()`.\n * @default 'data-wr-density'\n */\n readonly attribute?: string;\n /**\n * `WrStorage`'s key prefix — `withStorage({ prefix })`. The script reads\n * the raw key, so a prefixed app has to pass the same string here.\n * @default ''\n */\n readonly storagePrefix?: string;\n /**\n * Whether `WrStorage` wraps values in its JSON envelope —\n * `withStorage({ json })`. The emitted reader accepts both shapes either\n * way; this only decides which one it tries first.\n * @default true\n */\n readonly json?: boolean;\n}\n\n/**\n * Source of the blocking script that applies a persisted density BEFORE first\n * paint.\n *\n * {@link WrDensity} writes `[data-wr-density]` on `<html>` from an effect, so\n * on a prerendered or server-rendered page a stored `touch` or `sm` lands only\n * once the client bundle has booted: every control is drawn at the server's\n * density first and then jumps to the visitor's. A server cannot know the\n * choice — it has no `localStorage` — and nothing inside the application can\n * act before that paint. A script in `<head>` can, and this writes it out, so\n * an app never re-derives how {@link WrDensity} and `WrStorage` spell the\n * persisted value: the key, the prefix, the JSON envelope `{ v, e }`, the\n * expiry and the default.\n *\n * It writes what the service writes: the attribute, set to the stored density\n * or else to `defaultDensity`, every time — the service never leaves it unset.\n *\n * Returns the JS source WITHOUT a `<script>` wrapper, so it can be inlined into\n * `index.html`, emitted from an SSR template, or hashed for a CSP\n * `script-src 'sha256-…'`. Plain ES5 with no dependency on the app bundle, and\n * every step is wrapped so a blocked `localStorage` (private mode, a sandboxed\n * iframe) leaves the default density rather than throwing before anything has\n * rendered.\n *\n * Pass the same values the app gives `withDensity()` / `withStorage()`; the\n * defaults here are the defaults there. It pairs with `wrThemePrePaintScript()`\n * from `ngwr/theme`, which does the same for a chosen colour scheme.\n *\n * @example\n * ```ts\n * // Build step / SSR template:\n * const html = template.replace('<!--density-->', `<script>${wrDensityPrePaintScript()}</script>`);\n *\n * // Or paste the output straight into <head>, above every stylesheet:\n * // <script>(function(){ … })();</script>\n * ```\n *\n * @see https://ngwr.dev/reference/services/density\n */\nexport function wrDensityPrePaintScript(options: WrDensityPrePaintOptions = {}): string {\n const storageKey = options.storageKey === undefined ? DEFAULT_WR_DENSITY_CONFIG.storageKey : options.storageKey;\n const key = storageKey === null ? null : (options.storagePrefix ?? '') + storageKey;\n const defaultDensity = options.defaultDensity ?? DEFAULT_WR_DENSITY_CONFIG.defaultDensity;\n const attribute = options.attribute ?? DEFAULT_WR_DENSITY_CONFIG.attribute;\n const json = options.json ?? true;\n\n // Every interpolated value goes through JSON.stringify rather than into a\n // quoted literal, for the reason `wrThemePrePaintScript()` gives.\n const d = JSON.stringify(defaultDensity);\n const a = JSON.stringify(attribute);\n\n // Reading the envelope mirrors `WrStorage.get`, fall-throughs included: an\n // unparseable string is the value itself (what `json: false` writes), a parsed\n // non-envelope is the value, and an envelope past its `e` expiry is absent.\n const read = json\n ? `try{var p=JSON.parse(r);` +\n `if(p!==null&&typeof p===\"object\"&&\"v\" in p){if(p.e===undefined||p.e>=Date.now())m=p.v;}` +\n `else{m=p;}}catch(e){m=r;}`\n : `m=r;`;\n const load =\n key === null ? '' : `try{r=window.localStorage.getItem(${JSON.stringify(key)});}catch(e){}if(r!==null){${read}}`;\n\n return (\n `(function(){try{` +\n `var m=null,r=null;${load}` +\n `if(${JSON.stringify(DENSITIES)}.indexOf(m)<0)m=${d};` +\n `document.documentElement.setAttribute(${a},m);` +\n `}catch(e){}})();`\n );\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,4BAA6C;CACxD,gBAAgB;CAChB,YAAY;CACZ,WAAW;AACZ;AAED,MAAa,oBAAoB,IAAI,eAAgC,qBAAqB,EACxF,eAAgC,0BACjC,CAAA;;;;;;;ACLD,MAAM,QAAmC;CAAC;CAAM;CAAM;CAAM;AAAO;AAEnE,SAAS,UAAU,GAAU;CAC3B,OAAO,OAAO,MAAM,YAAa,MAA4B,SAAS,CAAC;AACzE;AAyBA,IAAa,YAAb,MAAa,UAAS;CACH,M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E;CAC5E,MAAM,aAAa,QAAQ,eAAe,SAAY,0BAA0B,aAAa,QAAQ;CACrG,MAAM,MAAM,eAAe,OAAO,QAAQ,QAAQ,iBAAiB,MAAM;CACzE,MAAM,iBAAiB,QAAQ,kBAAkB,0BAA0B;CAC3E,MAAM,YAAY,QAAQ,aAAa,0BAA0B;CACjE,MAAM,OAAO,QAAQ,QAAQ;CAI7B,MAAM,IAAI,KAAK,UAAU,cAAc;CACvC,MAAM,IAAI,KAAK,UAAU,SAAS;CAKlC,MAAM,OAAO,OACT,iJAGA;CAIJ,OACE,qCAHA,QAAQ,OAAO,KAAK,qCAAqC,KAAK,UAAU,GAAG,EAAC,4BAA6B,KAAI,QAKvG,KAAK,UAAU,SAAS,EAAC,kBAAmB,EAAC,yCACV,EAAC;AAG9C"}
1
+ {"version":3,"file":"ngwr-density.mjs","names":["DOCUMENT"],"sources":["../../../projects/lib/density/density-config.ts","../../../projects/lib/density/density.ts","../../../projects/lib/density/density.directive.ts","../../../projects/lib/density/with-density.ts","../../../projects/lib/density/pre-paint.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 { InjectionToken } from '@angular/core';\n\nimport type { WrDensityConfig } from './types';\n\nexport const DEFAULT_WR_DENSITY_CONFIG: WrDensityConfig = {\n defaultDensity: 'md',\n storageKey: 'wr-density',\n attribute: 'data-wr-density',\n};\n\nexport const WR_DENSITY_CONFIG = new InjectionToken<WrDensityConfig>('WR_DENSITY_CONFIG', {\n factory: (): WrDensityConfig => DEFAULT_WR_DENSITY_CONFIG,\n});\n\nexport type { WrDensityValue, WrDensityConfig } from './types';\n","/**\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, type Signal, effect, inject, signal } from '@angular/core';\n\nimport { WrStorage } from 'ngwr/storage';\n\nimport { WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\nconst VALID: readonly WrDensityValue[] = ['sm', 'md', 'lg', 'touch'];\n\nfunction isDensity(v: unknown): v is WrDensityValue {\n return typeof v === 'string' && (VALID as readonly string[]).includes(v);\n}\n\n/**\n * Global density scale. Writes `[data-wr-density]` on `<html>` so the\n * stylesheet's density-scoped CSS-variable rules apply, then components\n * pick up the new multipliers without re-rendering.\n *\n * - **Per-subtree override** — drop `[wrDensity]` on any element; its\n * descendants read the override instead of the global value.\n * - **Persisted** via {@link WrStorage} (swap the engine globally if you\n * need a different store).\n * - **Booted at startup** by `provideWr(withDensity(...))`, which also sets\n * the default. Without it nothing writes the attribute until something\n * injects this service.\n *\n * @example\n * ```ts\n * const density = inject(WrDensity);\n * density.set('sm');\n * density.current(); // 'sm'\n * ```\n *\n * @see https://ngwr.dev/reference/services/density\n */\n@Service()\nexport class WrDensity {\n private readonly doc = inject(DOCUMENT);\n private readonly storage = inject(WrStorage);\n private readonly config = inject(WR_DENSITY_CONFIG);\n\n /** Active density. */\n readonly current: Signal<WrDensityValue>;\n\n private readonly _current = signal<WrDensityValue>(this.readPersisted() ?? this.config.defaultDensity);\n\n constructor() {\n this.current = this._current.asReadonly();\n effect(() => {\n const value = this._current();\n const html = this.doc.documentElement;\n if (html) html.setAttribute(this.config.attribute, value);\n });\n }\n\n /** Switch the active density. Ignores unknown values. */\n set(density: WrDensityValue): void {\n if (!isDensity(density)) return;\n this._current.set(density);\n this.persist(density);\n }\n\n /** Cycle sm → md → lg → touch → sm … */\n cycle(): void {\n const order: readonly WrDensityValue[] = ['sm', 'md', 'lg', 'touch'];\n const i = order.indexOf(this._current());\n const next = order[(i + 1) % order.length];\n this._current.set(next);\n this.persist(next);\n }\n\n // Persistence\n\n private readPersisted(): WrDensityValue | null {\n if (!this.config.storageKey) return null;\n const raw = this.storage.get<WrDensityValue>(this.config.storageKey);\n return isDensity(raw) ? raw : null;\n }\n\n private persist(density: WrDensityValue): void {\n if (!this.config.storageKey) return;\n this.storage.set(this.config.storageKey, density);\n }\n}\n","/**\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 { Directive, ElementRef, effect, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\n/**\n * Scope a density override to a subtree. Writes the same `data-*`\n * attribute the global service writes — but on the host instead of\n * `<html>` — so the CSS-variable scope rules cascade only to descendants.\n *\n * @example\n * ```html\n * <!-- The whole sidebar is sm, the rest of the app keeps its global density. -->\n * <aside wrDensity=\"sm\">\n * <wr-list ...></wr-list>\n * </aside>\n * ```\n */\n@Directive({\n selector: '[wrDensity]',\n})\nexport class WrDensityDirective {\n /** Density to apply to this subtree. */\n readonly wrDensity = input.required<WrDensityValue>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly config = inject(WR_DENSITY_CONFIG);\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('density');\n effect(() => {\n this.host.nativeElement.setAttribute(this.config.attribute, this.wrDensity());\n });\n }\n}\n","/**\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 { inject, provideEnvironmentInitializer } from '@angular/core';\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { WrDensity } from './density';\nimport { DEFAULT_WR_DENSITY_CONFIG, WR_DENSITY_CONFIG, type WrDensityConfig } from './density-config';\n\n/**\n * Configure and activate {@link WrDensity}, as a feature of `provideWr()`. All\n * fields optional — merged with defaults.\n *\n * The initializer instantiates {@link WrDensity} so its constructor effect can\n * write `[data-wr-density]` onto `<html>`. Without it the tree-shakable service\n * was never created and `defaultDensity` had no effect at all.\n *\n * Bootstrap only: {@link WrDensity} is root-provided and reads its config once,\n * from the root injector.\n *\n * @example\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withDensity } from 'ngwr/density';\n *\n * bootstrapApplication(App, {\n * providers: [provideWr(withDensity({ defaultDensity: 'sm' }))],\n * });\n * ```\n */\nexport function withDensity(config: Partial<WrDensityConfig> = {}): WrFeature<'density'> {\n return wrFeature('density', [\n { provide: WR_DENSITY_CONFIG, useValue: { ...DEFAULT_WR_DENSITY_CONFIG, ...config } },\n provideEnvironmentInitializer(() => void inject(WrDensity)),\n ]);\n}\n","/**\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 { DEFAULT_WR_DENSITY_CONFIG, type WrDensityValue } from './density-config';\n\n/**\n * Every density the script accepts, written as a record so that a value added to\n * {@link WrDensityValue} fails to compile here instead of being refused by the\n * script in silence.\n */\nconst DENSITIES = Object.keys({ sm: true, md: true, lg: true, touch: true } satisfies Record<WrDensityValue, true>);\n\n/** Options for {@link wrDensityPrePaintScript}. All optional — defaults mirror the services. */\nexport interface WrDensityPrePaintOptions {\n /**\n * The key {@link WrDensity} persists the density under — `storageKey` in\n * `withDensity()`. `null` reads nothing, as `withDensity({ storageKey: null })`\n * persists nothing, and the script writes `defaultDensity`.\n * @default 'wr-density'\n */\n readonly storageKey?: string | null;\n /**\n * What to apply when nothing is persisted — `defaultDensity` in\n * `withDensity()`.\n * @default 'md'\n */\n readonly defaultDensity?: WrDensityValue;\n /**\n * The attribute written on `<html>` — `attribute` in `withDensity()`.\n * @default 'data-wr-density'\n */\n readonly attribute?: string;\n /**\n * `WrStorage`'s key prefix — `withStorage({ prefix })`. The script reads\n * the raw key, so a prefixed app has to pass the same string here.\n * @default ''\n */\n readonly storagePrefix?: string;\n /**\n * Whether `WrStorage` wraps values in its JSON envelope —\n * `withStorage({ json })`. The emitted reader accepts both shapes either\n * way; this only decides which one it tries first.\n * @default true\n */\n readonly json?: boolean;\n}\n\n/**\n * Source of the blocking script that applies a persisted density BEFORE first\n * paint.\n *\n * {@link WrDensity} writes `[data-wr-density]` on `<html>` from an effect, so\n * on a prerendered or server-rendered page a stored `touch` or `sm` lands only\n * once the client bundle has booted: every control is drawn at the server's\n * density first and then jumps to the visitor's. A server cannot know the\n * choice — it has no `localStorage` — and nothing inside the application can\n * act before that paint. A script in `<head>` can, and this writes it out, so\n * an app never re-derives how {@link WrDensity} and `WrStorage` spell the\n * persisted value: the key, the prefix, the JSON envelope `{ v, e }`, the\n * expiry and the default.\n *\n * It writes what the service writes: the attribute, set to the stored density\n * or else to `defaultDensity`, every time — the service never leaves it unset.\n *\n * Returns the JS source WITHOUT a `<script>` wrapper, so it can be inlined into\n * `index.html`, emitted from an SSR template, or hashed for a CSP\n * `script-src 'sha256-…'`. Plain ES5 with no dependency on the app bundle, and\n * every step is wrapped so a blocked `localStorage` (private mode, a sandboxed\n * iframe) leaves the default density rather than throwing before anything has\n * rendered.\n *\n * Pass the same values the app gives `withDensity()` / `withStorage()`; the\n * defaults here are the defaults there. It pairs with `wrThemePrePaintScript()`\n * from `ngwr/theme`, which does the same for a chosen colour scheme.\n *\n * @example\n * ```ts\n * // Build step / SSR template:\n * const html = template.replace('<!--density-->', `<script>${wrDensityPrePaintScript()}</script>`);\n *\n * // Or paste the output straight into <head>, above every stylesheet:\n * // <script>(function(){ … })();</script>\n * ```\n *\n * @see https://ngwr.dev/reference/services/density\n */\nexport function wrDensityPrePaintScript(options: WrDensityPrePaintOptions = {}): string {\n const storageKey = options.storageKey === undefined ? DEFAULT_WR_DENSITY_CONFIG.storageKey : options.storageKey;\n const key = storageKey === null ? null : (options.storagePrefix ?? '') + storageKey;\n const defaultDensity = options.defaultDensity ?? DEFAULT_WR_DENSITY_CONFIG.defaultDensity;\n const attribute = options.attribute ?? DEFAULT_WR_DENSITY_CONFIG.attribute;\n const json = options.json ?? true;\n\n // Every interpolated value goes through JSON.stringify rather than into a\n // quoted literal, for the reason `wrThemePrePaintScript()` gives.\n const d = JSON.stringify(defaultDensity);\n const a = JSON.stringify(attribute);\n\n // Reading the envelope mirrors `WrStorage.get`, fall-throughs included: an\n // unparseable string is the value itself (what `json: false` writes), a parsed\n // non-envelope is the value, and an envelope past its `e` expiry is absent.\n const read = json\n ? `try{var p=JSON.parse(r);` +\n `if(p!==null&&typeof p===\"object\"&&\"v\" in p){if(p.e===undefined||p.e>=Date.now())m=p.v;}` +\n `else{m=p;}}catch(e){m=r;}`\n : `m=r;`;\n const load =\n key === null ? '' : `try{r=window.localStorage.getItem(${JSON.stringify(key)});}catch(e){}if(r!==null){${read}}`;\n\n return (\n `(function(){try{` +\n `var m=null,r=null;${load}` +\n `if(${JSON.stringify(DENSITIES)}.indexOf(m)<0)m=${d};` +\n `document.documentElement.setAttribute(${a},m);` +\n `}catch(e){}})();`\n );\n}\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,4BAA6C;CACxD,gBAAgB;CAChB,YAAY;CACZ,WAAW;AACZ;AAED,MAAa,oBAAoB,IAAI,eAAgC,qBAAqB,EACxF,eAAgC,0BACjC,CAAA;;;;;;;ACLD,MAAM,QAAmC;CAAC;CAAM;CAAM;CAAM;AAAO;AAEnE,SAAS,UAAU,GAAU;CAC3B,OAAO,OAAO,MAAM,YAAa,MAA4B,SAAS,CAAC;AACzE;AAyBA,IAAa,YAAb,MAAa,UAAS;CACH,MAAM,OAAOA,UAAQ;CACrB,UAAU,OAAO,SAAS;CAC1B,SAAS,OAAO,iBAAiB;CAGzC;CAEQ,WAAW,OAAuB,KAAK,cAAa,KAAM,KAAK,OAAO,gBAAe,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAEtG,cAAA;EACE,KAAK,UAAU,KAAK,SAAS,WAAU;EACvC,aAAY;GACV,MAAM,QAAQ,KAAK,SAAQ;GAC3B,MAAM,OAAO,KAAK,IAAI;GACtB,IAAI,MAAM,KAAK,aAAa,KAAK,OAAO,WAAW,KAAK;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,OACE,qCAHA,QAAQ,OAAO,KAAK,qCAAqC,KAAK,UAAU,GAAG,EAAC,4BAA6B,KAAI,QAKvG,KAAK,UAAU,SAAS,EAAC,kBAAmB,EAAC,yCACV,EAAC;AAG9C"}
@@ -1,6 +1,6 @@
1
1
  import * as i0 from "@angular/core";
2
- import { Component, ViewEncapsulation, computed, input } from "@angular/core";
3
- import { coerceBooleanProperty } from "@angular/cdk/coercion";
2
+ import { Component, ViewEncapsulation, computed, inject, input } from "@angular/core";
3
+ import { coerceBooleanProperty, coerceNumberProperty } from "@angular/cdk/coercion";
4
4
  import { wrCheckStyles } from "ngwr/utils";
5
5
  /**
6
6
  * @license
@@ -25,11 +25,17 @@ var WrDescriptions = class WrDescriptions {
25
25
  ...ngDevMode ? { debugName: "responsive" } : /* istanbul ignore next */ {},
26
26
  transform: coerceBooleanProperty
27
27
  });
28
+ columns = input(1, {
29
+ ...ngDevMode ? { debugName: "columns" } : /* istanbul ignore next */ {},
30
+ transform: (value) => Math.max(1, Math.floor(coerceNumberProperty(value, 1)))
31
+ });
32
+ grid = computed(() => this.columns() > 1, ...ngDevMode ? [{ debugName: "grid" }] : /* istanbul ignore next */ []);
28
33
  classes = computed(() => {
29
34
  const parts = [];
30
35
  if (this.inline()) parts.push("wr-descriptions--inline");
31
36
  if (this.bordered()) parts.push("wr-descriptions--bordered");
32
37
  if (this.responsive()) parts.push("wr-descriptions--responsive");
38
+ if (this.grid()) parts.push("wr-descriptions--columns");
33
39
  return parts.join(" ");
34
40
  }, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
35
41
  static ɵfac = i0.ɵɵngDeclareFactory({
@@ -74,12 +80,20 @@ var WrDescriptions = class WrDescriptions {
74
80
  isSignal: true,
75
81
  isRequired: false,
76
82
  transformFunction: null
83
+ },
84
+ columns: {
85
+ classPropertyName: "columns",
86
+ publicName: "columns",
87
+ isSignal: true,
88
+ isRequired: false,
89
+ transformFunction: null
77
90
  }
78
91
  },
79
92
  host: {
80
93
  properties: {
81
94
  "class": "classes()",
82
- "attr.title": "null"
95
+ "attr.title": "null",
96
+ "style.--wr-descriptions-columns": "grid() ? columns() : null"
83
97
  },
84
98
  classAttribute: "wr-descriptions"
85
99
  },
@@ -101,7 +115,8 @@ i0.ɵɵngDeclareClassMetadata({
101
115
  host: {
102
116
  class: "wr-descriptions",
103
117
  "[class]": "classes()",
104
- "[attr.title]": "null"
118
+ "[attr.title]": "null",
119
+ "[style.--wr-descriptions-columns]": "grid() ? columns() : null"
105
120
  },
106
121
  template: "@if (title()) {\n <div class=\"wr-descriptions__title\">{{ title() }}</div>\n}\n<!--\n A plain <div> with ARIA term/definition roles on the item, not a <dl>:\n the rows are their own component, so the real DOM is\n `<dl><wr-description-item><dt>…` — which the HTML content model forbids and\n which breaks the term/definition association in AT. `role=\"term\"` /\n `role=\"definition\"` carry the same semantics with no required parent, so they\n survive the component boundary (and `display: contents` on the row).\n-->\n<div class=\"wr-descriptions__list\">\n <ng-content />\n</div>\n"
107
122
  }]
@@ -139,6 +154,14 @@ i0.ɵɵngDeclareClassMetadata({
139
154
  alias: "responsive",
140
155
  required: false
141
156
  }]
157
+ }],
158
+ columns: [{
159
+ type: i0.Input,
160
+ args: [{
161
+ isSignal: true,
162
+ alias: "columns",
163
+ required: false
164
+ }]
142
165
  }]
143
166
  }
144
167
  });
@@ -149,10 +172,19 @@ i0.ɵɵngDeclareClassMetadata({
149
172
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
150
173
  */
151
174
  var WrDescriptionItem = class WrDescriptionItem {
175
+ list = inject(WrDescriptions, { optional: true });
152
176
  constructor() {
153
177
  if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("descriptions");
154
178
  }
155
179
  label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
180
+ span = input(1, {
181
+ ...ngDevMode ? { debugName: "span" } : /* istanbul ignore next */ {},
182
+ transform: (value) => Math.max(1, Math.floor(coerceNumberProperty(value, 1)))
183
+ });
184
+ track = computed(() => {
185
+ const span = Math.min(this.span(), this.list?.columns() ?? 1);
186
+ return span > 1 ? span : null;
187
+ }, ...ngDevMode ? [{ debugName: "track" }] : /* istanbul ignore next */ []);
156
188
  static ɵfac = i0.ɵɵngDeclareFactory({
157
189
  minVersion: "12.0.0",
158
190
  version: "22.3.0",
@@ -167,14 +199,26 @@ var WrDescriptionItem = class WrDescriptionItem {
167
199
  type: WrDescriptionItem,
168
200
  isStandalone: true,
169
201
  selector: "wr-description-item",
170
- inputs: { label: {
171
- classPropertyName: "label",
172
- publicName: "label",
173
- isSignal: true,
174
- isRequired: false,
175
- transformFunction: null
176
- } },
177
- host: { classAttribute: "wr-descriptions__row" },
202
+ inputs: {
203
+ label: {
204
+ classPropertyName: "label",
205
+ publicName: "label",
206
+ isSignal: true,
207
+ isRequired: false,
208
+ transformFunction: null
209
+ },
210
+ span: {
211
+ classPropertyName: "span",
212
+ publicName: "span",
213
+ isSignal: true,
214
+ isRequired: false,
215
+ transformFunction: null
216
+ }
217
+ },
218
+ host: {
219
+ properties: { "style.--wr-descriptions-span": "track()" },
220
+ classAttribute: "wr-descriptions__row"
221
+ },
178
222
  ngImport: i0,
179
223
  template: "<div class=\"wr-descriptions__label\" role=\"term\">{{ label() }}</div><div class=\"wr-descriptions__value\" role=\"definition\"><ng-content /></div>",
180
224
  isInline: true,
@@ -192,18 +236,31 @@ i0.ɵɵngDeclareClassMetadata({
192
236
  selector: "wr-description-item",
193
237
  template: "<div class=\"wr-descriptions__label\" role=\"term\">{{ label() }}</div><div class=\"wr-descriptions__value\" role=\"definition\"><ng-content /></div>",
194
238
  encapsulation: ViewEncapsulation.None,
195
- host: { class: "wr-descriptions__row" }
239
+ host: {
240
+ class: "wr-descriptions__row",
241
+ "[style.--wr-descriptions-span]": "track()"
242
+ }
196
243
  }]
197
244
  }],
198
245
  ctorParameters: () => [],
199
- propDecorators: { label: [{
200
- type: i0.Input,
201
- args: [{
202
- isSignal: true,
203
- alias: "label",
204
- required: false
246
+ propDecorators: {
247
+ label: [{
248
+ type: i0.Input,
249
+ args: [{
250
+ isSignal: true,
251
+ alias: "label",
252
+ required: false
253
+ }]
254
+ }],
255
+ span: [{
256
+ type: i0.Input,
257
+ args: [{
258
+ isSignal: true,
259
+ alias: "span",
260
+ required: false
261
+ }]
205
262
  }]
206
- }] }
263
+ }
207
264
  });
208
265
  export { WrDescriptionItem, WrDescriptions };
209
266
 
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-descriptions.mjs","names":[],"sources":["../../../projects/lib/descriptions/descriptions.ts","../../../projects/lib/descriptions/descriptions.html","../../../projects/lib/descriptions/description-item.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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Read-only labeled key / value list. Project `<wr-description-item>`\n * children. `title` is optional. Default layout stacks vertically; set\n * `[inline]=\"true\"` for label-left / value-right rows.\n *\n * @example\n * ```html\n * <wr-descriptions title=\"Account\" inline>\n * <wr-description-item label=\"Name\">Ada Lovelace</wr-description-item>\n * <wr-description-item label=\"Email\">ada@example.com</wr-description-item>\n * <wr-description-item label=\"Joined\">2024-03-12</wr-description-item>\n * </wr-descriptions>\n * ```\n *\n * @see https://ngwr.dev/reference/components/descriptions\n */\n@Component({\n selector: 'wr-descriptions',\n templateUrl: './descriptions.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: { class: 'wr-descriptions', '[class]': 'classes()', '[attr.title]': 'null' },\n})\nexport class WrDescriptions {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('descriptions');\n }\n\n /** Optional title shown above the list. */\n readonly title = input<string>('');\n\n /** Two-column rows (label left, value right) instead of stacked. @default false */\n readonly inline = input(false, { transform: coerceBooleanProperty });\n\n /** Add visible borders around each row. @default false */\n readonly bordered = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Reflow `inline` rows back to a stacked layout when the box itself is\n * narrow (a container query on its own width, not the viewport — so it\n * adapts inside a narrow card or side panel). Makes the box fill its\n * container's width. @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.inline()) parts.push('wr-descriptions--inline');\n if (this.bordered()) parts.push('wr-descriptions--bordered');\n if (this.responsive()) parts.push('wr-descriptions--responsive');\n return parts.join(' ');\n });\n}\n","@if (title()) {\n <div class=\"wr-descriptions__title\">{{ title() }}</div>\n}\n<!--\n A plain <div> with ARIA term/definition roles on the item, not a <dl>:\n the rows are their own component, so the real DOM is\n `<dl><wr-description-item><dt>…` — which the HTML content model forbids and\n which breaks the term/definition association in AT. `role=\"term\"` /\n `role=\"definition\"` carry the same semantics with no required parent, so they\n survive the component boundary (and `display: contents` on the row).\n-->\n<div class=\"wr-descriptions__list\">\n <ng-content />\n</div>\n","/**\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, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * One row in a {@link WrDescriptions}. The label comes from the\n * `label` input; the value is the projected content.\n */\n@Component({\n selector: 'wr-description-item',\n template:\n '<div class=\"wr-descriptions__label\" role=\"term\">{{ label() }}</div>' +\n '<div class=\"wr-descriptions__value\" role=\"definition\"><ng-content /></div>',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-descriptions__row' },\n})\nexport class WrDescriptionItem {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('descriptions');\n }\n\n /**\n * The term shown beside the projected value — \"Email\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GAAA,kBAAA;CAAA,CAAA;;AAAjB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiB,YAAA,CAAA;EAR7B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UACE;GAEF,eAAe,kBAAkB;GACjC,MAAM,EAAE,OAAO,uBAAsB;EACtC,CAAA"}
1
+ {"version":3,"file":"ngwr-descriptions.mjs","names":[],"sources":["../../../projects/lib/descriptions/descriptions.ts","../../../projects/lib/descriptions/descriptions.html","../../../projects/lib/descriptions/description-item.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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Read-only labeled key / value list. Project `<wr-description-item>`\n * children. `title` is optional. Default layout stacks vertically; set\n * `[inline]=\"true\"` for label-left / value-right rows, and `columns` for a\n * grid of several items per row.\n *\n * @example\n * ```html\n * <wr-descriptions title=\"Account\" inline>\n * <wr-description-item label=\"Name\">Ada Lovelace</wr-description-item>\n * <wr-description-item label=\"Email\">ada@example.com</wr-description-item>\n * <wr-description-item label=\"Joined\">2024-03-12</wr-description-item>\n * </wr-descriptions>\n * ```\n *\n * @see https://ngwr.dev/reference/components/descriptions\n */\n@Component({\n selector: 'wr-descriptions',\n templateUrl: './descriptions.html',\n encapsulation: ViewEncapsulation.None,\n // See `WrAlert`: a static `title=` feeds the input AND lands on the host,\n // where the browser draws it as a tooltip over the whole component.\n host: {\n class: 'wr-descriptions',\n '[class]': 'classes()',\n '[attr.title]': 'null',\n '[style.--wr-descriptions-columns]': 'grid() ? columns() : null',\n },\n})\nexport class WrDescriptions {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('descriptions');\n }\n\n /** Optional title shown above the list. */\n readonly title = input<string>('');\n\n /** Two-column rows (label left, value right) instead of stacked. @default false */\n readonly inline = input(false, { transform: coerceBooleanProperty });\n\n /** Add visible borders around each row. @default false */\n readonly bordered = input(false, { transform: coerceBooleanProperty });\n\n /**\n * Reflow `inline` rows back to a stacked layout, and a `columns` grid back\n * to one column, when the box itself is narrow (a container query on its\n * own width, not the viewport — so it adapts inside a narrow card or side\n * panel). Makes the box fill its container's width. @default false\n */\n readonly responsive = input(false, { transform: coerceBooleanProperty });\n\n /**\n * How many items a row holds, as equal columns. An item takes more of them\n * with its `span`.\n *\n * @default 1\n */\n readonly columns = input(1, {\n transform: (value: unknown): number => Math.max(1, Math.floor(coerceNumberProperty(value, 1))),\n });\n\n protected readonly grid = computed(() => this.columns() > 1);\n\n protected readonly classes = computed(() => {\n const parts: string[] = [];\n if (this.inline()) parts.push('wr-descriptions--inline');\n if (this.bordered()) parts.push('wr-descriptions--bordered');\n if (this.responsive()) parts.push('wr-descriptions--responsive');\n if (this.grid()) parts.push('wr-descriptions--columns');\n return parts.join(' ');\n });\n}\n","@if (title()) {\n <div class=\"wr-descriptions__title\">{{ title() }}</div>\n}\n<!--\n A plain <div> with ARIA term/definition roles on the item, not a <dl>:\n the rows are their own component, so the real DOM is\n `<dl><wr-description-item><dt>…` — which the HTML content model forbids and\n which breaks the term/definition association in AT. `role=\"term\"` /\n `role=\"definition\"` carry the same semantics with no required parent, so they\n survive the component boundary (and `display: contents` on the row).\n-->\n<div class=\"wr-descriptions__list\">\n <ng-content />\n</div>\n","/**\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 { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { Component, ViewEncapsulation, computed, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrDescriptions } from './descriptions';\n\n/**\n * One row in a {@link WrDescriptions}. The label comes from the\n * `label` input; the value is the projected content.\n */\n@Component({\n selector: 'wr-description-item',\n template:\n '<div class=\"wr-descriptions__label\" role=\"term\">{{ label() }}</div>' +\n '<div class=\"wr-descriptions__value\" role=\"definition\"><ng-content /></div>',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-descriptions__row', '[style.--wr-descriptions-span]': 'track()' },\n})\nexport class WrDescriptionItem {\n private readonly list = inject(WrDescriptions, { optional: true });\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('descriptions');\n }\n\n /**\n * The term shown beside the projected value — \"Email\", \"Created\". Keep it a\n * noun: it is read as the name of the value, not as a sentence.\n */\n readonly label = input<string>('');\n\n /**\n * Columns the item takes in a list with `columns`. A number above the\n * list's `columns` takes the whole row.\n *\n * @default 1\n */\n readonly span = input(1, {\n transform: (value: unknown): number => Math.max(1, Math.floor(coerceNumberProperty(value, 1))),\n });\n\n protected readonly track = computed(() => {\n const span = Math.min(this.span(), this.list?.columns() ?? 1);\n return span > 1 ? span : null;\n });\n}\n"],"mappings":";;;;;;;;;;AA0CA,IAAa,iBAAb,MAAa,eAAc;CACzB,cAAA;EACE,IAAI,OAAO,cAAc,eAAe,WAAW,cAAc,cAAc;CACjF;CAGS,QAAQ,MAAc,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAGzB,SAAS,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,SAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAGxD,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAQ1D,aAAa,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAQ5D,UAAU,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,UAAA,+BAAA,CAAA;EACxB,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AAA;EAAiB,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,OAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA;GAAA,YAAA,EAAA,gCAAA,UAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UAAA;EAAA,UAAA;EAAA,eAAA,GAAA,kBAAA;CAAA,CAAA;;AAAjB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAiB,YAAA,CAAA;EAR7B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UACE;GAEF,eAAe,kBAAkB;GACjC,MAAM;IAAE,OAAO;IAAwB,kCAAkC;GAAS;EACnF,CAAA"}
@@ -92,6 +92,7 @@ var WrAutosize = class WrAutosize {
92
92
  });
93
93
  el = inject(ElementRef);
94
94
  isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
95
+ destroyRef = inject(DestroyRef);
95
96
  lastValue = null;
96
97
  constructor() {
97
98
  afterEveryRender(() => {
@@ -101,6 +102,17 @@ var WrAutosize = class WrAutosize {
101
102
  this.resize();
102
103
  }
103
104
  });
105
+ afterNextRender(() => {
106
+ if (typeof ResizeObserver === "undefined") return;
107
+ let width = -1;
108
+ const observer = new ResizeObserver(([entry]) => {
109
+ if (entry.contentRect.width === width) return;
110
+ width = entry.contentRect.width;
111
+ this.resize();
112
+ });
113
+ observer.observe(this.el.nativeElement);
114
+ this.destroyRef.onDestroy(() => observer.disconnect());
115
+ });
104
116
  effect(() => {
105
117
  this.minRows();
106
118
  this.maxRows();
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-directives.mjs","names":["DOCUMENT","DOCUMENT"],"sources":["../../../projects/lib/directives/autofocus.ts","../../../projects/lib/directives/autosize.ts","../../../projects/lib/directives/click-outside.ts","../../../projects/lib/directives/copy-to-clipboard.ts","../../../projects/lib/directives/fit-text.ts","../../../projects/lib/directives/in-view.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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, Injector, afterNextRender, effect, inject, input } from '@angular/core';\n\nimport { wrGetFocusableElements } from 'ngwr/utils';\n\n/**\n * Focus the host element after the first render, or whenever the bound\n * expression turns truthy. `\"first\"` focuses the first focusable element\n * inside the host instead: the control of a form, a card or a dialog body.\n * Disabled and hidden elements are skipped.\n *\n * @example\n * ```html\n * <input wrAutofocus />\n * <input [wrAutofocus]=\"shouldFocus()\" />\n * <form wrAutofocus=\"first\">…</form>\n * <form [wrAutofocus]=\"editing() && 'first'\">…</form>\n * ```\n */\n@Directive({ selector: '[wrAutofocus]' })\nexport class WrAutofocus {\n /**\n * Truthy = focus the host, `'first'` = focus the first focusable element\n * inside it. Defaults to `true` so bare `wrAutofocus` works.\n */\n readonly wrAutofocus = input(true, {\n transform: (value: unknown): boolean | 'first' => (value === 'first' ? value : coerceBooleanProperty(value)),\n });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n constructor() {\n effect(() => {\n const mode = this.wrAutofocus();\n if (!mode) return;\n // After the render, so what the same change drew is there to take focus.\n afterNextRender(\n () => {\n const host = this.el.nativeElement;\n // An explicit negative `tabindex` takes an element out of the Tab order;\n // an editing host with none still reads `tabIndex` -1 and stays eligible.\n const reachable = (el: HTMLElement): boolean => Number(el.getAttribute('tabindex') ?? 0) >= 0;\n (mode === 'first' ? wrGetFocusableElements(host).find(reachable) : host)?.focus();\n },\n { injector: this.injector }\n );\n });\n }\n}\n","/**\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 { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isPlatformBrowser } from '@angular/common';\nimport { Directive, ElementRef, PLATFORM_ID, afterEveryRender, effect, inject, input } from '@angular/core';\n\n/**\n * Auto-grow a `<textarea>` to fit its content. Optional `minRows` /\n * `maxRows` bounds the height in rendered rows.\n *\n * @example\n * ```html\n * <textarea wrAutosize minRows=\"2\" maxRows=\"8\" [(ngModel)]=\"text\"></textarea>\n * ```\n */\n@Directive({\n selector: 'textarea[wrAutosize]',\n // Bound rather than a static `style` attribute: a real attribute is refused\n // under `style-src 'self'`, and the textarea then keeps the native resize\n // grip, which fights the directive's own height management.\n host: { '[style.overflow]': \"'hidden'\", '[style.resize]': \"'none'\", '(input)': 'onInput()' },\n})\nexport class WrAutosize {\n /**\n * Smallest height, in rendered rows. The textarea never shrinks below it,\n * so a field that starts empty still reserves the room.\n */\n readonly minRows = input(1, { transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 1)) });\n /**\n * Largest height, in rendered rows. `0` — the default — lets it grow without\n * a ceiling; any other value caps the height and the textarea scrolls past it.\n */\n readonly maxRows = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n private readonly el = inject<ElementRef<HTMLTextAreaElement>>(ElementRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private lastValue: string | null = null;\n\n constructor() {\n // Typing fires `input`, but `[(ngModel)]` / `setValue` write the value\n // without one — a cheap per-render value check catches both, including\n // the initial write that lands after the first render.\n afterEveryRender(() => {\n const value = this.el.nativeElement.value;\n if (value !== this.lastValue) {\n this.lastValue = value;\n this.resize();\n }\n });\n // Resize when `minRows` / `maxRows` change. Read the inputs before the\n // platform check so the effect still tracks them; the measurement itself\n // needs a real layout, which the server has none of (`afterEveryRender`\n // above is browser-only already, so it needs no guard).\n effect(() => {\n this.minRows();\n this.maxRows();\n if (!this.isBrowser) return;\n this.resize();\n });\n }\n\n /** @internal */\n protected onInput(): void {\n this.lastValue = this.el.nativeElement.value;\n this.resize();\n }\n\n /** Recompute height from `scrollHeight`, clamped to min/max rows. */\n private resize(): void {\n const node = this.el.nativeElement;\n const styles = getComputedStyle(node);\n // `line-height: normal` computes to the literal string — derive the\n // row height from the font size instead of guessing a fixed 20px.\n const lineHeight = parseFloat(styles.lineHeight) || parseFloat(styles.fontSize) * 1.25 || 20;\n const paddingY = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom);\n const border = (parseFloat(styles.borderTopWidth) || 0) + (parseFloat(styles.borderBottomWidth) || 0);\n\n // Reset to a single row first so `scrollHeight` shrinks as well as grows.\n node.style.height = 'auto';\n const min = this.minRows() * lineHeight + paddingY + border;\n const max = this.maxRows() > 0 ? this.maxRows() * lineHeight + paddingY + border : Infinity;\n const next = Math.min(Math.max(node.scrollHeight + border, min), max);\n node.style.height = `${next}px`;\n node.style.overflowY = node.scrollHeight + border > max ? 'auto' : 'hidden';\n }\n}\n","/**\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 { DestroyRef, Directive, ElementRef, NgZone, inject, output } from '@angular/core';\n\n/**\n * Fires `(wrClickOutside)` when a pointer event lands outside the host\n * element. Useful for closing custom poppers / menus.\n *\n * @example\n * ```html\n * <div class=\"popup\" (wrClickOutside)=\"close()\"> … </div>\n * ```\n */\n@Directive({ selector: '[wrClickOutside]' })\nexport class WrClickOutside {\n /**\n * Fires on a pointer press that landed outside the host element. Close a\n * menu or commit an inline edit with it; the event is the original click.\n */\n readonly wrClickOutside = output<MouseEvent>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly doc = inject(DOCUMENT);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n\n constructor() {\n // Listen outside Angular to avoid CD on every page click; re-enter\n // only when the event lands outside the host.\n this.zone.runOutsideAngular(() => {\n const handler = (event: MouseEvent): void => {\n const target = event.target as Node | null;\n if (target && !this.host.nativeElement.contains(target)) {\n this.zone.run(() => this.wrClickOutside.emit(event));\n }\n };\n this.doc.addEventListener('mousedown', handler, true);\n this.destroyRef.onDestroy(() => {\n this.doc.removeEventListener('mousedown', handler, true);\n });\n });\n }\n}\n","/**\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 { FocusMonitor, LiveAnnouncer } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Directive, Injector, inject, input, output, signal } from '@angular/core';\n\nimport { WR_COPIED_DURATION } from 'ngwr/clipboard';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrPopover, wrUseTextTooltip } from 'ngwr/popover';\nimport { WrToast } from 'ngwr/toast';\nimport { wrRestoreFocus } from 'ngwr/utils';\n\n/**\n * Copy `wrCopyToClipboard` to the system clipboard on host click.\n *\n * Uses `navigator.clipboard.writeText` when available, with a hidden\n * `<textarea>` + `document.execCommand('copy')` fallback for older browsers\n * and non-secure contexts.\n *\n * After a successful copy the host carries `wr-copy-to-clipboard--copied` for\n * a moment, a tooltip over it reads \"Copied\" and the same text is announced\n * politely. `wrCopyToClipboardToast` shows a toast instead of the tooltip and\n * the announcement. A refused write changes nothing and emits `copyFailed`.\n *\n * @example\n * ```html\n * <button [wrCopyToClipboard]=\"value\">Copy</button>\n * <button [wrCopyToClipboard]=\"rows\" wrCopyToClipboardToast copiedLabel=\"Copied to clipboard\">Copy all</button>\n * ```\n */\n@Directive({\n selector: '[wrCopyToClipboard]',\n exportAs: 'wrCopyToClipboard',\n host: {\n class: 'wr-copy-to-clipboard',\n '[class.wr-copy-to-clipboard--copied]': 'justCopied()',\n '(click)': 'copy()',\n },\n})\nexport class WrCopyToClipboard {\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n this.destroyed = true;\n this.clearTimer();\n });\n }\n\n /** The text to copy. */\n readonly wrCopyToClipboard = input.required<string>();\n\n /**\n * Confirm a copy with a toast instead of the tooltip and the announcement.\n *\n * @default false\n */\n readonly wrCopyToClipboardToast = input(false, { transform: coerceBooleanProperty });\n\n /** Text of the tooltip, the announcement and the toast. Falls back to `copyToClipboard.copied`, then `'Copied'`. */\n readonly copiedLabel = input<string | null>(null);\n\n /** Emitted with the copied text once the write succeeds. */\n readonly copied = output<string>();\n\n /** Emitted if the copy fails (denied permission, no clipboard, …). */\n readonly copyFailed = output<unknown>();\n\n /** True for a moment after a successful copy. */\n protected readonly justCopied = signal(false);\n\n private readonly resolvedCopiedLabel = useI18nText(this.copiedLabel, 'copyToClipboard.copied', 'Copied');\n\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly doc = inject(DOCUMENT);\n private readonly injector = inject(Injector);\n private readonly tooltip = wrUseTextTooltip();\n private readonly hostPopover = inject(WrPopover, { self: true, optional: true });\n private destroyed = false;\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * Copies the bound text, as a click does: `(copied)` or `(copyFailed)` fires\n * either way. Resolves `true` once the text is on the clipboard and `false`\n * when neither path could write it. It never rejects.\n */\n async copy(): Promise<boolean> {\n const text = this.wrCopyToClipboard();\n const async = this.doc.defaultView?.navigator?.clipboard;\n\n try {\n if (async) {\n try {\n await async.writeText(text);\n } catch {\n // The legacy path is a RECOVERY from the async one, so it only runs\n // when there was an async attempt to recover from. Reached from the\n // fallback's own failure it just repeated the same refused write —\n // two selections and two focus jumps for one press.\n this.fallback(text);\n }\n } else {\n this.fallback(text);\n }\n } catch (error) {\n this.copyFailed.emit(error);\n return false;\n }\n\n // Outside the try because the try's job is the WRITE. The shape this\n // replaced emitted inside it and recovered by calling `fallback` again, so\n // one refused write became two selections, two focus jumps and two `copied`\n // emissions. (A consumer's own `(copied)` handler cannot reach this frame\n // either way: `OutputEmitterRef.emit` catches what a listener throws and\n // hands it to the `ErrorHandler`.)\n // An output refuses to emit once its directive is gone.\n if (this.destroyed) return true;\n this.confirm();\n this.copied.emit(text);\n return true;\n }\n\n private confirm(): void {\n const label = this.resolvedCopiedLabel();\n this.clearTimer();\n this.justCopied.set(true);\n\n if (this.wrCopyToClipboardToast()) {\n this.injector.get(WrToast).show({ type: 'success', message: label, showCopy: false });\n } else {\n // The host's own hover tooltip would sit under this one, in the same place.\n if (this.hostPopover?.mode() === 'tooltip') this.hostPopover.close();\n this.tooltip.show(label);\n void this.injector.get(LiveAnnouncer).announce(label, 'polite', WR_COPIED_DURATION);\n }\n\n this.timer = setTimeout(() => {\n this.justCopied.set(false);\n this.tooltip.hide();\n }, WR_COPIED_DURATION);\n }\n\n private clearTimer(): void {\n if (this.timer !== null) clearTimeout(this.timer);\n this.timer = null;\n }\n\n /**\n * Legacy clipboard write — hidden textarea + `execCommand('copy')`.\n *\n * Two things this has to get right beyond writing the text. `execCommand`\n * REPORTS refusal rather than throwing it: a document without focus hands back\n * `false` and copies nothing, so ignoring the return value shows a \"Copied!\"\n * toast over an unchanged clipboard. And selecting the textarea moves focus\n * into it, so removing the node afterwards drops focus on `<body>` — the user's\n * next Tab restarts from the top of the page, on every copy.\n */\n private fallback(text: string): void {\n const node = this.doc.createElement('textarea');\n node.value = text;\n node.setAttribute('readonly', '');\n node.style.position = 'fixed';\n node.style.top = '0';\n node.style.left = '0';\n node.style.opacity = '0';\n node.style.pointerEvents = 'none';\n\n const previous = this.doc.activeElement;\n this.doc.body.appendChild(node);\n node.select();\n\n try {\n if (!this.doc.execCommand('copy')) throw new Error('The copy command was refused.');\n } finally {\n this.doc.body.removeChild(node);\n if (previous instanceof HTMLElement) wrRestoreFocus(previous, this.focusMonitor);\n }\n }\n}\n","/**\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, afterNextRender, effect, inject, input } from '@angular/core';\n\n/**\n * Shrink a block whose text wraps to the width of its longest line.\n *\n * A wrapped block keeps the width it was offered, so a tinted pill with three\n * lines of text carries an empty band of background beside them, and CSS has\n * no way to take it back. The lines are measured and the host's inline `width`\n * is set to the widest one, padding and border included as its `box-sizing`\n * needs. Every line already fits that width, so the line breaks stay where\n * they were. It is measured again when the text changes and when the parent is\n * resized; a block on one line is left alone.\n *\n * The host needs a box that takes a width (block, inline-block, a flex or grid\n * item) and holds text and inline content.\n *\n * @example\n * ```html\n * <wr-tag wrFitText>A label long enough to wrap onto a second line</wr-tag>\n * <p [wrFitText]=\"fit()\">…</p>\n * ```\n */\n@Directive({ selector: '[wrFitText]' })\nexport class WrFitText {\n /** `false` switches the fitting off and removes the width it wrote. Bare `wrFitText` is on. */\n readonly wrFitText = input(true, { transform: coerceBooleanProperty });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n private frame = 0;\n private started = false;\n /** The width this directive wrote, so switching off removes that and nothing else. */\n private written = '';\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.el.nativeElement;\n // The parent's height follows the host's, and in a shrink-to-fit parent so\n // does its width: only a new inline size can move a line break.\n let offered = -1;\n const resize =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver(([entry]) => {\n if (entry.contentRect.width === offered) return;\n offered = entry.contentRect.width;\n this.schedule();\n });\n const text = new MutationObserver(() => this.schedule());\n\n if (host.parentElement) resize?.observe(host.parentElement);\n // No `attributes`: the width written below must not call the measure back.\n text.observe(host, { characterData: true, childList: true, subtree: true });\n\n this.started = true;\n this.fit();\n\n destroyRef.onDestroy(() => {\n cancelAnimationFrame(this.frame);\n resize?.disconnect();\n text.disconnect();\n });\n });\n\n effect(() => {\n this.wrFitText();\n if (this.started) this.schedule();\n });\n }\n\n private schedule(): void {\n cancelAnimationFrame(this.frame);\n this.frame = requestAnimationFrame(() => this.fit());\n }\n\n private fit(): void {\n const host = this.el.nativeElement;\n\n if (!this.wrFitText()) {\n if (this.written && host.style.width === this.written) host.style.width = '';\n this.written = '';\n return;\n }\n\n // Cleared first, so a parent that grew can take words back onto a line.\n host.style.width = '';\n this.written = '';\n\n const range = host.ownerDocument.createRange();\n range.selectNodeContents(host);\n const rects = Array.from(range.getClientRects()).filter(rect => rect.width > 0);\n if (!rects.length) return;\n\n // Inline children give several rects to one line, so a count says nothing.\n const firstLineEnd = rects[0].bottom;\n if (!rects.some(rect => rect.top >= firstLineEnd)) return;\n\n const start = Math.min(...rects.map(rect => rect.left));\n const end = Math.max(...rects.map(rect => rect.right));\n const style = getComputedStyle(host);\n const px = (value: string): number => parseFloat(value) || 0;\n const box =\n style.boxSizing === 'border-box'\n ? px(style.paddingLeft) + px(style.paddingRight) + px(style.borderLeftWidth) + px(style.borderRightWidth)\n : 0;\n\n // One pixel over: at the exact width, subpixel rounding wraps the longest line again.\n this.written = `${Math.ceil(end - start + box) + 1}px`;\n host.style.width = this.written;\n }\n}\n","/**\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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, Service, afterNextRender, inject, input, output } from '@angular/core';\n\ntype ViewCallback = (inView: boolean) => void;\n\ninterface Pool {\n readonly observer: IntersectionObserver;\n readonly targets: Map<Element, Set<ViewCallback>>;\n}\n\n/**\n * One `IntersectionObserver` per distinct `threshold`, shared by every element\n * watched with it. The observer is created with the first element and\n * disconnected with the last. Browser only: call it from `afterNextRender`.\n */\n@Service()\nexport class WrInViewObserver {\n private readonly pools = new Map<number, Pool>();\n\n /**\n * Watch `el` and call `callback` on every change with whether at least `threshold`\n * of it shows: `isIntersecting` alone is true for any sliver. Returns the stop function.\n */\n observe(el: Element, threshold: number, callback: ViewCallback): () => void {\n let pool = this.pools.get(threshold);\n if (!pool) {\n const targets = new Map<Element, Set<ViewCallback>>();\n const observer = new IntersectionObserver(\n entries => {\n for (const entry of entries) {\n // A copy: a callback may stop itself while the set is walked.\n // A fully shown host can report a hair under 1 from subpixel rounding;\n // any lower threshold is compared as it is.\n const inView = entry.isIntersecting && entry.intersectionRatio >= (threshold >= 1 ? 0.999 : threshold);\n for (const cb of [...(targets.get(entry.target) ?? [])]) cb(inView);\n }\n },\n { threshold }\n );\n pool = { observer, targets };\n this.pools.set(threshold, pool);\n }\n\n const { observer, targets } = pool;\n let callbacks = targets.get(el);\n if (!callbacks) {\n callbacks = new Set();\n targets.set(el, callbacks);\n observer.observe(el);\n }\n callbacks.add(callback);\n\n return () => {\n const set = targets.get(el);\n if (!set?.delete(callback) || set.size) return;\n targets.delete(el);\n observer.unobserve(el);\n if (!targets.size) {\n observer.disconnect();\n if (this.pools.get(threshold) === pool) this.pools.delete(threshold);\n }\n };\n }\n}\n\n/**\n * Emits when the host enters or leaves the viewport.\n *\n * `(wrInView)` carries `true` on entering and `false` on leaving, and only on a\n * change: an element that starts out of view emits nothing until it shows up.\n * `wrInViewOnce` stops after the first entry. Every instance with the same\n * `wrInViewThreshold` shares one `IntersectionObserver`. Nothing is observed on\n * the server.\n *\n * @example\n * ```html\n * <section (wrInView)=\"seen.set($event)\" [wrInViewThreshold]=\"0.5\"> … </section>\n * <img wrInViewOnce (wrInView)=\"load()\" />\n * ```\n */\n@Directive({ selector: '[wrInView]' })\nexport class WrInView {\n /** Fires with `true` when the host enters the viewport and `false` when it leaves. */\n readonly wrInView = output<boolean>();\n\n /**\n * The share of the host, from 0 to 1, that must be visible to count as in view.\n * Read once, when the host first renders. A host taller than the viewport never\n * reaches a threshold of 1.\n */\n readonly wrInViewThreshold = input(0, {\n transform: (value: unknown) => Math.min(1, Math.max(0, coerceNumberProperty(value, 0))),\n });\n\n /** Stop watching after the first entry. Bare `wrInViewOnce` is on. */\n readonly wrInViewOnce = input(false, { transform: coerceBooleanProperty });\n\n private readonly el = inject<ElementRef<Element>>(ElementRef);\n private readonly pool = inject(WrInViewObserver);\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n if (typeof IntersectionObserver === 'undefined') return;\n\n let stop: (() => void) | null = null;\n const unwatch = (): void => {\n stop?.();\n stop = null;\n };\n let last = false;\n stop = this.pool.observe(this.el.nativeElement, this.wrInViewThreshold(), inView => {\n if (inView === last) return;\n last = inView;\n this.wrInView.emit(inView);\n if (inView && this.wrInViewOnce()) unwatch();\n });\n destroyRef.onDestroy(unwatch);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAa,cAAb,MAAa,YAAW;CAKb,cAAc,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAC/B,YAAY,UAAuC,UAAU,UAAU,QAAQ,sBAAsB,KAAK;CAAE,CAAA;CAG7F,KAAK,OAAgC,UAAU;CAC/C,WAAW,OAAO,QAAQ;CAE3C,cAAA;EACE,aAAY;GACV,MAAM,OAAO,KAAK,YAAW;GAC7B,IAAI,CAAC,MAAM;GAEX,sBACO;IACH,MAAM,OAAO,KAAK,GAAG;IAGrB,MAAM,aAAa,OAA6B,OAAO,GAAG,aAAa,UAAU,KAAK,CAAC,KAAK;IAC5F,CAAC,SAAS,UAAU,uBAAuB,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,KAAA,EAAO,MAAK;GACjF,GACA,EAAE,UAAU,KAAK,SAAQ,CAAE;EAE/B,CAAC;CACH;CA5BW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAW,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,aAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EA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,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAQ,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,mBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,cAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,WAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EADpB,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,aAAY,CAAE"}
1
+ {"version":3,"file":"ngwr-directives.mjs","names":["DOCUMENT","DOCUMENT"],"sources":["../../../projects/lib/directives/autofocus.ts","../../../projects/lib/directives/autosize.ts","../../../projects/lib/directives/click-outside.ts","../../../projects/lib/directives/copy-to-clipboard.ts","../../../projects/lib/directives/fit-text.ts","../../../projects/lib/directives/in-view.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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Directive, ElementRef, Injector, afterNextRender, effect, inject, input } from '@angular/core';\n\nimport { wrGetFocusableElements } from 'ngwr/utils';\n\n/**\n * Focus the host element after the first render, or whenever the bound\n * expression turns truthy. `\"first\"` focuses the first focusable element\n * inside the host instead: the control of a form, a card or a dialog body.\n * Disabled and hidden elements are skipped.\n *\n * @example\n * ```html\n * <input wrAutofocus />\n * <input [wrAutofocus]=\"shouldFocus()\" />\n * <form wrAutofocus=\"first\">…</form>\n * <form [wrAutofocus]=\"editing() && 'first'\">…</form>\n * ```\n */\n@Directive({ selector: '[wrAutofocus]' })\nexport class WrAutofocus {\n /**\n * Truthy = focus the host, `'first'` = focus the first focusable element\n * inside it. Defaults to `true` so bare `wrAutofocus` works.\n */\n readonly wrAutofocus = input(true, {\n transform: (value: unknown): boolean | 'first' => (value === 'first' ? value : coerceBooleanProperty(value)),\n });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n constructor() {\n effect(() => {\n const mode = this.wrAutofocus();\n if (!mode) return;\n // After the render, so what the same change drew is there to take focus.\n afterNextRender(\n () => {\n const host = this.el.nativeElement;\n // An explicit negative `tabindex` takes an element out of the Tab order;\n // an editing host with none still reads `tabIndex` -1 and stays eligible.\n const reachable = (el: HTMLElement): boolean => Number(el.getAttribute('tabindex') ?? 0) >= 0;\n (mode === 'first' ? wrGetFocusableElements(host).find(reachable) : host)?.focus();\n },\n { injector: this.injector }\n );\n });\n }\n}\n","/**\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 { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n Directive,\n ElementRef,\n PLATFORM_ID,\n afterEveryRender,\n afterNextRender,\n effect,\n inject,\n input,\n} from '@angular/core';\n\n/**\n * Auto-grow a `<textarea>` to fit its content. Optional `minRows` /\n * `maxRows` bounds the height in rendered rows.\n *\n * @example\n * ```html\n * <textarea wrAutosize minRows=\"2\" maxRows=\"8\" [(ngModel)]=\"text\"></textarea>\n * ```\n */\n@Directive({\n selector: 'textarea[wrAutosize]',\n // Bound rather than a static `style` attribute: a real attribute is refused\n // under `style-src 'self'`, and the textarea then keeps the native resize\n // grip, which fights the directive's own height management.\n host: { '[style.overflow]': \"'hidden'\", '[style.resize]': \"'none'\", '(input)': 'onInput()' },\n})\nexport class WrAutosize {\n /**\n * Smallest height, in rendered rows. The textarea never shrinks below it,\n * so a field that starts empty still reserves the room.\n */\n readonly minRows = input(1, { transform: (v: unknown): number => Math.max(1, coerceNumberProperty(v, 1)) });\n /**\n * Largest height, in rendered rows. `0` — the default — lets it grow without\n * a ceiling; any other value caps the height and the textarea scrolls past it.\n */\n readonly maxRows = input(0, { transform: (v: unknown): number => Math.max(0, coerceNumberProperty(v, 0)) });\n\n private readonly el = inject<ElementRef<HTMLTextAreaElement>>(ElementRef);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n\n private readonly destroyRef = inject(DestroyRef);\n\n private lastValue: string | null = null;\n\n constructor() {\n // Typing fires `input`, but `[(ngModel)]` / `setValue` write the value\n // without one — a cheap per-render value check catches both, including\n // the initial write that lands after the first render.\n afterEveryRender(() => {\n const value = this.el.nativeElement.value;\n if (value !== this.lastValue) {\n this.lastValue = value;\n this.resize();\n }\n });\n // A narrower or wider box re-wraps the text without any input, so the\n // width is watched too. Height-only changes are this directive's own writes.\n afterNextRender(() => {\n if (typeof ResizeObserver === 'undefined') return;\n let width = -1;\n const observer = new ResizeObserver(([entry]) => {\n if (entry.contentRect.width === width) return;\n width = entry.contentRect.width;\n this.resize();\n });\n observer.observe(this.el.nativeElement);\n this.destroyRef.onDestroy(() => observer.disconnect());\n });\n // Resize when `minRows` / `maxRows` change. Read the inputs before the\n // platform check so the effect still tracks them; the measurement itself\n // needs a real layout, which the server has none of (`afterEveryRender`\n // above is browser-only already, so it needs no guard).\n effect(() => {\n this.minRows();\n this.maxRows();\n if (!this.isBrowser) return;\n this.resize();\n });\n }\n\n /** @internal */\n protected onInput(): void {\n this.lastValue = this.el.nativeElement.value;\n this.resize();\n }\n\n /** Recompute height from `scrollHeight`, clamped to min/max rows. */\n private resize(): void {\n const node = this.el.nativeElement;\n const styles = getComputedStyle(node);\n // `line-height: normal` computes to the literal string — derive the\n // row height from the font size instead of guessing a fixed 20px.\n const lineHeight = parseFloat(styles.lineHeight) || parseFloat(styles.fontSize) * 1.25 || 20;\n const paddingY = parseFloat(styles.paddingTop) + parseFloat(styles.paddingBottom);\n const border = (parseFloat(styles.borderTopWidth) || 0) + (parseFloat(styles.borderBottomWidth) || 0);\n\n // Reset to a single row first so `scrollHeight` shrinks as well as grows.\n node.style.height = 'auto';\n const min = this.minRows() * lineHeight + paddingY + border;\n const max = this.maxRows() > 0 ? this.maxRows() * lineHeight + paddingY + border : Infinity;\n const next = Math.min(Math.max(node.scrollHeight + border, min), max);\n node.style.height = `${next}px`;\n node.style.overflowY = node.scrollHeight + border > max ? 'auto' : 'hidden';\n }\n}\n","/**\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 { DestroyRef, Directive, ElementRef, NgZone, inject, output } from '@angular/core';\n\n/**\n * Fires `(wrClickOutside)` when a pointer event lands outside the host\n * element. Useful for closing custom poppers / menus.\n *\n * @example\n * ```html\n * <div class=\"popup\" (wrClickOutside)=\"close()\"> … </div>\n * ```\n */\n@Directive({ selector: '[wrClickOutside]' })\nexport class WrClickOutside {\n /**\n * Fires on a pointer press that landed outside the host element. Close a\n * menu or commit an inline edit with it; the event is the original click.\n */\n readonly wrClickOutside = output<MouseEvent>();\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly doc = inject(DOCUMENT);\n private readonly zone = inject(NgZone);\n private readonly destroyRef = inject(DestroyRef);\n\n constructor() {\n // Listen outside Angular to avoid CD on every page click; re-enter\n // only when the event lands outside the host.\n this.zone.runOutsideAngular(() => {\n const handler = (event: MouseEvent): void => {\n const target = event.target as Node | null;\n if (target && !this.host.nativeElement.contains(target)) {\n this.zone.run(() => this.wrClickOutside.emit(event));\n }\n };\n this.doc.addEventListener('mousedown', handler, true);\n this.destroyRef.onDestroy(() => {\n this.doc.removeEventListener('mousedown', handler, true);\n });\n });\n }\n}\n","/**\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 { FocusMonitor, LiveAnnouncer } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DOCUMENT } from '@angular/common';\nimport { DestroyRef, Directive, Injector, inject, input, output, signal } from '@angular/core';\n\nimport { WR_COPIED_DURATION } from 'ngwr/clipboard';\nimport { useI18nText } from 'ngwr/i18n';\nimport { WrPopover, wrUseTextTooltip } from 'ngwr/popover';\nimport { WrToast } from 'ngwr/toast';\nimport { wrRestoreFocus } from 'ngwr/utils';\n\n/**\n * Copy `wrCopyToClipboard` to the system clipboard on host click.\n *\n * Uses `navigator.clipboard.writeText` when available, with a hidden\n * `<textarea>` + `document.execCommand('copy')` fallback for older browsers\n * and non-secure contexts.\n *\n * After a successful copy the host carries `wr-copy-to-clipboard--copied` for\n * a moment, a tooltip over it reads \"Copied\" and the same text is announced\n * politely. `wrCopyToClipboardToast` shows a toast instead of the tooltip and\n * the announcement. A refused write changes nothing and emits `copyFailed`.\n *\n * @example\n * ```html\n * <button [wrCopyToClipboard]=\"value\">Copy</button>\n * <button [wrCopyToClipboard]=\"rows\" wrCopyToClipboardToast copiedLabel=\"Copied to clipboard\">Copy all</button>\n * ```\n */\n@Directive({\n selector: '[wrCopyToClipboard]',\n exportAs: 'wrCopyToClipboard',\n host: {\n class: 'wr-copy-to-clipboard',\n '[class.wr-copy-to-clipboard--copied]': 'justCopied()',\n '(click)': 'copy()',\n },\n})\nexport class WrCopyToClipboard {\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n this.destroyed = true;\n this.clearTimer();\n });\n }\n\n /** The text to copy. */\n readonly wrCopyToClipboard = input.required<string>();\n\n /**\n * Confirm a copy with a toast instead of the tooltip and the announcement.\n *\n * @default false\n */\n readonly wrCopyToClipboardToast = input(false, { transform: coerceBooleanProperty });\n\n /** Text of the tooltip, the announcement and the toast. Falls back to `copyToClipboard.copied`, then `'Copied'`. */\n readonly copiedLabel = input<string | null>(null);\n\n /** Emitted with the copied text once the write succeeds. */\n readonly copied = output<string>();\n\n /** Emitted if the copy fails (denied permission, no clipboard, …). */\n readonly copyFailed = output<unknown>();\n\n /** True for a moment after a successful copy. */\n protected readonly justCopied = signal(false);\n\n private readonly resolvedCopiedLabel = useI18nText(this.copiedLabel, 'copyToClipboard.copied', 'Copied');\n\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly doc = inject(DOCUMENT);\n private readonly injector = inject(Injector);\n private readonly tooltip = wrUseTextTooltip();\n private readonly hostPopover = inject(WrPopover, { self: true, optional: true });\n private destroyed = false;\n private timer: ReturnType<typeof setTimeout> | null = null;\n\n /**\n * Copies the bound text, as a click does: `(copied)` or `(copyFailed)` fires\n * either way. Resolves `true` once the text is on the clipboard and `false`\n * when neither path could write it. It never rejects.\n */\n async copy(): Promise<boolean> {\n const text = this.wrCopyToClipboard();\n const async = this.doc.defaultView?.navigator?.clipboard;\n\n try {\n if (async) {\n try {\n await async.writeText(text);\n } catch {\n // The legacy path is a RECOVERY from the async one, so it only runs\n // when there was an async attempt to recover from. Reached from the\n // fallback's own failure it just repeated the same refused write —\n // two selections and two focus jumps for one press.\n this.fallback(text);\n }\n } else {\n this.fallback(text);\n }\n } catch (error) {\n this.copyFailed.emit(error);\n return false;\n }\n\n // Outside the try because the try's job is the WRITE. The shape this\n // replaced emitted inside it and recovered by calling `fallback` again, so\n // one refused write became two selections, two focus jumps and two `copied`\n // emissions. (A consumer's own `(copied)` handler cannot reach this frame\n // either way: `OutputEmitterRef.emit` catches what a listener throws and\n // hands it to the `ErrorHandler`.)\n // An output refuses to emit once its directive is gone.\n if (this.destroyed) return true;\n this.confirm();\n this.copied.emit(text);\n return true;\n }\n\n private confirm(): void {\n const label = this.resolvedCopiedLabel();\n this.clearTimer();\n this.justCopied.set(true);\n\n if (this.wrCopyToClipboardToast()) {\n this.injector.get(WrToast).show({ type: 'success', message: label, showCopy: false });\n } else {\n // The host's own hover tooltip would sit under this one, in the same place.\n if (this.hostPopover?.mode() === 'tooltip') this.hostPopover.close();\n this.tooltip.show(label);\n void this.injector.get(LiveAnnouncer).announce(label, 'polite', WR_COPIED_DURATION);\n }\n\n this.timer = setTimeout(() => {\n this.justCopied.set(false);\n this.tooltip.hide();\n }, WR_COPIED_DURATION);\n }\n\n private clearTimer(): void {\n if (this.timer !== null) clearTimeout(this.timer);\n this.timer = null;\n }\n\n /**\n * Legacy clipboard write — hidden textarea + `execCommand('copy')`.\n *\n * Two things this has to get right beyond writing the text. `execCommand`\n * REPORTS refusal rather than throwing it: a document without focus hands back\n * `false` and copies nothing, so ignoring the return value shows a \"Copied!\"\n * toast over an unchanged clipboard. And selecting the textarea moves focus\n * into it, so removing the node afterwards drops focus on `<body>` — the user's\n * next Tab restarts from the top of the page, on every copy.\n */\n private fallback(text: string): void {\n const node = this.doc.createElement('textarea');\n node.value = text;\n node.setAttribute('readonly', '');\n node.style.position = 'fixed';\n node.style.top = '0';\n node.style.left = '0';\n node.style.opacity = '0';\n node.style.pointerEvents = 'none';\n\n const previous = this.doc.activeElement;\n this.doc.body.appendChild(node);\n node.select();\n\n try {\n if (!this.doc.execCommand('copy')) throw new Error('The copy command was refused.');\n } finally {\n this.doc.body.removeChild(node);\n if (previous instanceof HTMLElement) wrRestoreFocus(previous, this.focusMonitor);\n }\n }\n}\n","/**\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 { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, afterNextRender, effect, inject, input } from '@angular/core';\n\n/**\n * Shrink a block whose text wraps to the width of its longest line.\n *\n * A wrapped block keeps the width it was offered, so a tinted pill with three\n * lines of text carries an empty band of background beside them, and CSS has\n * no way to take it back. The lines are measured and the host's inline `width`\n * is set to the widest one, padding and border included as its `box-sizing`\n * needs. Every line already fits that width, so the line breaks stay where\n * they were. It is measured again when the text changes and when the parent is\n * resized; a block on one line is left alone.\n *\n * The host needs a box that takes a width (block, inline-block, a flex or grid\n * item) and holds text and inline content.\n *\n * @example\n * ```html\n * <wr-tag wrFitText>A label long enough to wrap onto a second line</wr-tag>\n * <p [wrFitText]=\"fit()\">…</p>\n * ```\n */\n@Directive({ selector: '[wrFitText]' })\nexport class WrFitText {\n /** `false` switches the fitting off and removes the width it wrote. Bare `wrFitText` is on. */\n readonly wrFitText = input(true, { transform: coerceBooleanProperty });\n\n private readonly el = inject<ElementRef<HTMLElement>>(ElementRef);\n\n private frame = 0;\n private started = false;\n /** The width this directive wrote, so switching off removes that and nothing else. */\n private written = '';\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.el.nativeElement;\n // The parent's height follows the host's, and in a shrink-to-fit parent so\n // does its width: only a new inline size can move a line break.\n let offered = -1;\n const resize =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver(([entry]) => {\n if (entry.contentRect.width === offered) return;\n offered = entry.contentRect.width;\n this.schedule();\n });\n const text = new MutationObserver(() => this.schedule());\n\n if (host.parentElement) resize?.observe(host.parentElement);\n // No `attributes`: the width written below must not call the measure back.\n text.observe(host, { characterData: true, childList: true, subtree: true });\n\n this.started = true;\n this.fit();\n\n destroyRef.onDestroy(() => {\n cancelAnimationFrame(this.frame);\n resize?.disconnect();\n text.disconnect();\n });\n });\n\n effect(() => {\n this.wrFitText();\n if (this.started) this.schedule();\n });\n }\n\n private schedule(): void {\n cancelAnimationFrame(this.frame);\n this.frame = requestAnimationFrame(() => this.fit());\n }\n\n private fit(): void {\n const host = this.el.nativeElement;\n\n if (!this.wrFitText()) {\n if (this.written && host.style.width === this.written) host.style.width = '';\n this.written = '';\n return;\n }\n\n // Cleared first, so a parent that grew can take words back onto a line.\n host.style.width = '';\n this.written = '';\n\n const range = host.ownerDocument.createRange();\n range.selectNodeContents(host);\n const rects = Array.from(range.getClientRects()).filter(rect => rect.width > 0);\n if (!rects.length) return;\n\n // Inline children give several rects to one line, so a count says nothing.\n const firstLineEnd = rects[0].bottom;\n if (!rects.some(rect => rect.top >= firstLineEnd)) return;\n\n const start = Math.min(...rects.map(rect => rect.left));\n const end = Math.max(...rects.map(rect => rect.right));\n const style = getComputedStyle(host);\n const px = (value: string): number => parseFloat(value) || 0;\n const box =\n style.boxSizing === 'border-box'\n ? px(style.paddingLeft) + px(style.paddingRight) + px(style.borderLeftWidth) + px(style.borderRightWidth)\n : 0;\n\n // One pixel over: at the exact width, subpixel rounding wraps the longest line again.\n this.written = `${Math.ceil(end - start + box) + 1}px`;\n host.style.width = this.written;\n }\n}\n","/**\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 { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport { DestroyRef, Directive, ElementRef, Service, afterNextRender, inject, input, output } from '@angular/core';\n\ntype ViewCallback = (inView: boolean) => void;\n\ninterface Pool {\n readonly observer: IntersectionObserver;\n readonly targets: Map<Element, Set<ViewCallback>>;\n}\n\n/**\n * One `IntersectionObserver` per distinct `threshold`, shared by every element\n * watched with it. The observer is created with the first element and\n * disconnected with the last. Browser only: call it from `afterNextRender`.\n */\n@Service()\nexport class WrInViewObserver {\n private readonly pools = new Map<number, Pool>();\n\n /**\n * Watch `el` and call `callback` on every change with whether at least `threshold`\n * of it shows: `isIntersecting` alone is true for any sliver. Returns the stop function.\n */\n observe(el: Element, threshold: number, callback: ViewCallback): () => void {\n let pool = this.pools.get(threshold);\n if (!pool) {\n const targets = new Map<Element, Set<ViewCallback>>();\n const observer = new IntersectionObserver(\n entries => {\n for (const entry of entries) {\n // A copy: a callback may stop itself while the set is walked.\n // A fully shown host can report a hair under 1 from subpixel rounding;\n // any lower threshold is compared as it is.\n const inView = entry.isIntersecting && entry.intersectionRatio >= (threshold >= 1 ? 0.999 : threshold);\n for (const cb of [...(targets.get(entry.target) ?? [])]) cb(inView);\n }\n },\n { threshold }\n );\n pool = { observer, targets };\n this.pools.set(threshold, pool);\n }\n\n const { observer, targets } = pool;\n let callbacks = targets.get(el);\n if (!callbacks) {\n callbacks = new Set();\n targets.set(el, callbacks);\n observer.observe(el);\n }\n callbacks.add(callback);\n\n return () => {\n const set = targets.get(el);\n if (!set?.delete(callback) || set.size) return;\n targets.delete(el);\n observer.unobserve(el);\n if (!targets.size) {\n observer.disconnect();\n if (this.pools.get(threshold) === pool) this.pools.delete(threshold);\n }\n };\n }\n}\n\n/**\n * Emits when the host enters or leaves the viewport.\n *\n * `(wrInView)` carries `true` on entering and `false` on leaving, and only on a\n * change: an element that starts out of view emits nothing until it shows up.\n * `wrInViewOnce` stops after the first entry. Every instance with the same\n * `wrInViewThreshold` shares one `IntersectionObserver`. Nothing is observed on\n * the server.\n *\n * @example\n * ```html\n * <section (wrInView)=\"seen.set($event)\" [wrInViewThreshold]=\"0.5\"> … </section>\n * <img wrInViewOnce (wrInView)=\"load()\" />\n * ```\n */\n@Directive({ selector: '[wrInView]' })\nexport class WrInView {\n /** Fires with `true` when the host enters the viewport and `false` when it leaves. */\n readonly wrInView = output<boolean>();\n\n /**\n * The share of the host, from 0 to 1, that must be visible to count as in view.\n * Read once, when the host first renders. A host taller than the viewport never\n * reaches a threshold of 1.\n */\n readonly wrInViewThreshold = input(0, {\n transform: (value: unknown) => Math.min(1, Math.max(0, coerceNumberProperty(value, 0))),\n });\n\n /** Stop watching after the first entry. Bare `wrInViewOnce` is on. */\n readonly wrInViewOnce = input(false, { transform: coerceBooleanProperty });\n\n private readonly el = inject<ElementRef<Element>>(ElementRef);\n private readonly pool = inject(WrInViewObserver);\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n if (typeof IntersectionObserver === 'undefined') return;\n\n let stop: (() => void) | null = null;\n const unwatch = (): void => {\n stop?.();\n stop = null;\n };\n let last = false;\n stop = this.pool.observe(this.el.nativeElement, this.wrInViewThreshold(), inView => {\n if (inView === last) return;\n last = inView;\n this.wrInView.emit(inView);\n if (inView && this.wrInViewOnce()) unwatch();\n });\n destroyRef.onDestroy(unwatch);\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA2BA,IAAa,cAAb,MAAa,YAAW;CAKb,cAAc,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAC/B,YAAY,UAAuC,UAAU,UAAU,QAAQ,sBAAsB,KAAK;CAAE,CAAA;CAG7F,KAAK,OAAgC,UAAU;CAC/C,WAAW,OAAO,QAAQ;CAE3C,cAAA;EACE,aAAY;GACV,MAAM,OAAO,KAAK,YAAW;GAC7B,IAAI,CAAC,MAAM;GAEX,sBACO;IACH,MAAM,OAAO,KAAK,GAAG;IAGrB,MAAM,aAAa,OAA6B,OAAO,GAAG,aAAa,UAAU,KAAK,CAAC,KAAK;IAC5F,CAAC,SAAS,UAAU,uBAAuB,IAAI,CAAC,CAAC,KAAK,SAAS,IAAI,KAAA,EAAO,MAAK;GACjF,GACA,EAAE,UAAU,KAAK,SAAQ,CAAE;EAE/B,CAAC;CACH;CA5BW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAW,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAX,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAW,cAAA;EAAA,UAAA;EAAA,QAAA,EAAA,aAAA;GAAA,mBAAA;GAAA,YAAA;GAAA,UAAA;GAAA,YAAA;GAAA,mBAAA;EAAA,EAAA;EAAA,UAAA;CAAA,CAAA;;AAAX,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAW,YAAA,CAAA;EADvB,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,gBAAe,CAAE;;;;;;;;;;;;;;;;;;ACWxC,IAAa,aAAb,MA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Y,GAAI,QAAO;GAC5C,CAAC;GACD,WAAW,UAAU,OAAO;EAC9B,CAAC;CACH;CAvCW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAQ,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,mBAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,cAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,WAAA;EAAA,UAAA;CAAA,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EADpB,MAAA;EAAU,MAAA,CAAA,EAAE,UAAU,aAAY,CAAE"}
@@ -1453,6 +1453,7 @@ var WrEditor = class WrEditor {
1453
1453
  } catch (error) {
1454
1454
  if (isDevMode()) this.warnRefused(error);
1455
1455
  this.refused.set(true);
1456
+ this.lastSerialized = value;
1456
1457
  return;
1457
1458
  }
1458
1459
  this.refused.set(false);