ngwr 16.7.1 → 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 (236) hide show
  1. package/charts/donut-chart/styles/_index.scss +9 -3
  2. package/charts/meter-group/styles/_index.scss +8 -1
  3. package/charts/sparkline/styles/_index.scss +6 -3
  4. package/command-palette/styles/_index.scss +10 -0
  5. package/descriptions/styles/_index.scss +91 -0
  6. package/fesm2022/ngwr-anchor.mjs +48 -10
  7. package/fesm2022/ngwr-anchor.mjs.map +1 -1
  8. package/fesm2022/ngwr-carousel.mjs +3 -2
  9. package/fesm2022/ngwr-carousel.mjs.map +1 -1
  10. package/fesm2022/ngwr-charts-calendar-heatmap.mjs +3 -1
  11. package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
  12. package/fesm2022/ngwr-charts-core.mjs +17 -0
  13. package/fesm2022/ngwr-charts-core.mjs.map +1 -1
  14. package/fesm2022/ngwr-charts-donut-chart-testing.mjs +27 -0
  15. package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
  16. package/fesm2022/ngwr-charts-donut-chart.mjs +54 -6
  17. package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
  18. package/fesm2022/ngwr-charts-meter-group-testing.mjs +27 -0
  19. package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
  20. package/fesm2022/ngwr-charts-meter-group.mjs +54 -6
  21. package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
  22. package/fesm2022/ngwr-charts-sparkline-testing.mjs +27 -0
  23. package/fesm2022/ngwr-charts-sparkline-testing.mjs.map +1 -1
  24. package/fesm2022/ngwr-charts-sparkline.mjs +45 -4
  25. package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
  26. package/fesm2022/ngwr-checkbox.mjs +38 -3
  27. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  28. package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -1
  29. package/fesm2022/ngwr-color-picker.mjs +4 -3
  30. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  31. package/fesm2022/ngwr-command-palette.mjs +39 -19
  32. package/fesm2022/ngwr-command-palette.mjs.map +1 -1
  33. package/fesm2022/ngwr-compare.mjs +4 -0
  34. package/fesm2022/ngwr-compare.mjs.map +1 -1
  35. package/fesm2022/ngwr-context-menu.mjs +7 -2
  36. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  37. package/fesm2022/ngwr-cookie.mjs +6 -3
  38. package/fesm2022/ngwr-cookie.mjs.map +1 -1
  39. package/fesm2022/ngwr-date-stamp-testing.mjs +3 -0
  40. package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -1
  41. package/fesm2022/ngwr-date-stamp.mjs +81 -4
  42. package/fesm2022/ngwr-date-stamp.mjs.map +1 -1
  43. package/fesm2022/ngwr-date.mjs +16 -2
  44. package/fesm2022/ngwr-date.mjs.map +1 -1
  45. package/fesm2022/ngwr-density.mjs +4 -3
  46. package/fesm2022/ngwr-density.mjs.map +1 -1
  47. package/fesm2022/ngwr-descriptions.mjs +77 -20
  48. package/fesm2022/ngwr-descriptions.mjs.map +1 -1
  49. package/fesm2022/ngwr-dialog.mjs +10 -7
  50. package/fesm2022/ngwr-dialog.mjs.map +1 -1
  51. package/fesm2022/ngwr-directives.mjs +12 -0
  52. package/fesm2022/ngwr-directives.mjs.map +1 -1
  53. package/fesm2022/ngwr-drawer.mjs +14 -8
  54. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  55. package/fesm2022/ngwr-editor.mjs +1 -0
  56. package/fesm2022/ngwr-editor.mjs.map +1 -1
  57. package/fesm2022/ngwr-file-upload.mjs +4 -5
  58. package/fesm2022/ngwr-file-upload.mjs.map +1 -1
  59. package/fesm2022/ngwr-form.mjs.map +1 -1
  60. package/fesm2022/ngwr-hotkey.mjs +10 -5
  61. package/fesm2022/ngwr-hotkey.mjs.map +1 -1
  62. package/fesm2022/ngwr-i18n-ar.mjs +18 -5
  63. package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
  64. package/fesm2022/ngwr-i18n-cs.mjs +18 -5
  65. package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
  66. package/fesm2022/ngwr-i18n-de.mjs +18 -5
  67. package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
  68. package/fesm2022/ngwr-i18n-en.mjs +18 -5
  69. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  70. package/fesm2022/ngwr-i18n-es.mjs +18 -5
  71. package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
  72. package/fesm2022/ngwr-i18n-fr.mjs +18 -5
  73. package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
  74. package/fesm2022/ngwr-i18n-he.mjs +18 -5
  75. package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
  76. package/fesm2022/ngwr-i18n-hi.mjs +18 -5
  77. package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
  78. package/fesm2022/ngwr-i18n-id.mjs +18 -5
  79. package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
  80. package/fesm2022/ngwr-i18n-it.mjs +18 -5
  81. package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
  82. package/fesm2022/ngwr-i18n-ja.mjs +18 -5
  83. package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
  84. package/fesm2022/ngwr-i18n-kk.mjs +18 -5
  85. package/fesm2022/ngwr-i18n-kk.mjs.map +1 -1
  86. package/fesm2022/ngwr-i18n-ko.mjs +18 -5
  87. package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
  88. package/fesm2022/ngwr-i18n-nl.mjs +18 -5
  89. package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
  90. package/fesm2022/ngwr-i18n-pl.mjs +18 -5
  91. package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
  92. package/fesm2022/ngwr-i18n-pt.mjs +18 -5
  93. package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
  94. package/fesm2022/ngwr-i18n-ru.mjs +18 -5
  95. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  96. package/fesm2022/ngwr-i18n-sv.mjs +18 -5
  97. package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
  98. package/fesm2022/ngwr-i18n-tr.mjs +18 -5
  99. package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
  100. package/fesm2022/ngwr-i18n-uk.mjs +18 -5
  101. package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
  102. package/fesm2022/ngwr-i18n-vi.mjs +18 -5
  103. package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
  104. package/fesm2022/ngwr-i18n-zh-tw.mjs +18 -5
  105. package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
  106. package/fesm2022/ngwr-i18n-zh.mjs +18 -5
  107. package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
  108. package/fesm2022/ngwr-i18n.mjs +7 -6
  109. package/fesm2022/ngwr-i18n.mjs.map +1 -1
  110. package/fesm2022/ngwr-image-cropper-testing.mjs +33 -0
  111. package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -1
  112. package/fesm2022/ngwr-image-cropper.mjs +536 -30
  113. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  114. package/fesm2022/ngwr-input-number.mjs +33 -10
  115. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  116. package/fesm2022/ngwr-input-otp.mjs +24 -10
  117. package/fesm2022/ngwr-input-otp.mjs.map +1 -1
  118. package/fesm2022/ngwr-input.mjs +2 -2
  119. package/fesm2022/ngwr-input.mjs.map +1 -1
  120. package/fesm2022/ngwr-knob.mjs +5 -0
  121. package/fesm2022/ngwr-knob.mjs.map +1 -1
  122. package/fesm2022/ngwr-lightbox.mjs +5 -3
  123. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  124. package/fesm2022/ngwr-mention.mjs +2 -0
  125. package/fesm2022/ngwr-mention.mjs.map +1 -1
  126. package/fesm2022/ngwr-meta.mjs +43 -8
  127. package/fesm2022/ngwr-meta.mjs.map +1 -1
  128. package/fesm2022/ngwr-overlay.mjs +51 -2
  129. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  130. package/fesm2022/ngwr-pagination.mjs +1 -1
  131. package/fesm2022/ngwr-pagination.mjs.map +1 -1
  132. package/fesm2022/ngwr-pipes.mjs +160 -8
  133. package/fesm2022/ngwr-pipes.mjs.map +1 -1
  134. package/fesm2022/ngwr-popconfirm.mjs +2 -2
  135. package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
  136. package/fesm2022/ngwr-qr.mjs +65 -7
  137. package/fesm2022/ngwr-qr.mjs.map +1 -1
  138. package/fesm2022/ngwr-schema-form.mjs +2 -2
  139. package/fesm2022/ngwr-schema-form.mjs.map +1 -1
  140. package/fesm2022/ngwr-scroll.mjs +1 -2
  141. package/fesm2022/ngwr-scroll.mjs.map +1 -1
  142. package/fesm2022/ngwr-slider.mjs +22 -17
  143. package/fesm2022/ngwr-slider.mjs.map +1 -1
  144. package/fesm2022/ngwr-speed-dial.mjs +30 -1
  145. package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
  146. package/fesm2022/ngwr-statistic.mjs +1 -1
  147. package/fesm2022/ngwr-stepper-testing.mjs +7 -1
  148. package/fesm2022/ngwr-stepper-testing.mjs.map +1 -1
  149. package/fesm2022/ngwr-stepper.mjs +55 -4
  150. package/fesm2022/ngwr-stepper.mjs.map +1 -1
  151. package/fesm2022/ngwr-switch.mjs +33 -3
  152. package/fesm2022/ngwr-switch.mjs.map +1 -1
  153. package/fesm2022/ngwr-timeline.mjs +4 -0
  154. package/fesm2022/ngwr-timeline.mjs.map +1 -1
  155. package/fesm2022/ngwr-toolbar.mjs +171 -16
  156. package/fesm2022/ngwr-toolbar.mjs.map +1 -1
  157. package/fesm2022/ngwr-tour.mjs +8 -3
  158. package/fesm2022/ngwr-tour.mjs.map +1 -1
  159. package/fesm2022/ngwr-transfer.mjs +3 -2
  160. package/fesm2022/ngwr-transfer.mjs.map +1 -1
  161. package/fesm2022/ngwr-tree.mjs +1 -1
  162. package/fesm2022/ngwr-utils.mjs +46 -8
  163. package/fesm2022/ngwr-utils.mjs.map +1 -1
  164. package/fesm2022/ngwr-version.mjs +1 -1
  165. package/fesm2022/ngwr-version.mjs.map +1 -1
  166. package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
  167. package/fesm2022/ngwr-virtual-scroll.mjs.map +1 -1
  168. package/i18n/ar.json +18 -5
  169. package/i18n/cs.json +18 -5
  170. package/i18n/de.json +18 -5
  171. package/i18n/en.json +18 -5
  172. package/i18n/es.json +18 -5
  173. package/i18n/fr.json +18 -5
  174. package/i18n/he.json +18 -5
  175. package/i18n/hi.json +18 -5
  176. package/i18n/id.json +18 -5
  177. package/i18n/it.json +18 -5
  178. package/i18n/ja.json +18 -5
  179. package/i18n/kk.json +18 -5
  180. package/i18n/ko.json +18 -5
  181. package/i18n/nl.json +18 -5
  182. package/i18n/pl.json +18 -5
  183. package/i18n/pt.json +18 -5
  184. package/i18n/ru.json +18 -5
  185. package/i18n/sv.json +18 -5
  186. package/i18n/tr.json +18 -5
  187. package/i18n/uk.json +18 -5
  188. package/i18n/vi.json +18 -5
  189. package/i18n/zh-TW.json +18 -5
  190. package/i18n/zh.json +18 -5
  191. package/image-cropper/styles/_index.scss +30 -1
  192. package/llms-full.txt +9 -9
  193. package/package.json +1 -1
  194. package/schematics/use/rule.js +1 -0
  195. package/schematics/use/symbol-map.json +2 -0
  196. package/skills/ngwr/SKILL.md +2 -2
  197. package/stepper/styles/_index.scss +33 -0
  198. package/tour/styles/_index.scss +11 -7
  199. package/types/ngwr-anchor.d.ts +14 -1
  200. package/types/ngwr-charts-donut-chart-testing.d.ts +32 -3
  201. package/types/ngwr-charts-donut-chart.d.ts +45 -6
  202. package/types/ngwr-charts-meter-group-testing.d.ts +29 -1
  203. package/types/ngwr-charts-meter-group.d.ts +43 -4
  204. package/types/ngwr-charts-sparkline-testing.d.ts +32 -2
  205. package/types/ngwr-charts-sparkline.d.ts +42 -3
  206. package/types/ngwr-checkbox.d.ts +14 -0
  207. package/types/ngwr-color-picker-testing.d.ts +1 -1
  208. package/types/ngwr-command-palette.d.ts +2 -1
  209. package/types/ngwr-date-stamp-testing.d.ts +2 -0
  210. package/types/ngwr-date-stamp.d.ts +41 -2
  211. package/types/ngwr-date.d.ts +3 -1
  212. package/types/ngwr-descriptions.d.ts +33 -5
  213. package/types/ngwr-dialog.d.ts +11 -6
  214. package/types/ngwr-directives.d.ts +1 -0
  215. package/types/ngwr-drawer.d.ts +12 -4
  216. package/types/ngwr-file-upload.d.ts +1 -1
  217. package/types/ngwr-form.d.ts +4 -0
  218. package/types/ngwr-hotkey.d.ts +2 -0
  219. package/types/ngwr-image-cropper-testing.d.ts +33 -1
  220. package/types/ngwr-image-cropper.d.ts +214 -6
  221. package/types/ngwr-input-number.d.ts +14 -2
  222. package/types/ngwr-input-otp.d.ts +2 -0
  223. package/types/ngwr-lightbox.d.ts +1 -0
  224. package/types/ngwr-meta.d.ts +13 -1
  225. package/types/ngwr-overlay.d.ts +20 -1
  226. package/types/ngwr-pipes.d.ts +125 -1
  227. package/types/ngwr-qr.d.ts +17 -0
  228. package/types/ngwr-slider.d.ts +3 -1
  229. package/types/ngwr-speed-dial.d.ts +10 -0
  230. package/types/ngwr-stepper-testing.d.ts +10 -0
  231. package/types/ngwr-stepper.d.ts +47 -1
  232. package/types/ngwr-switch.d.ts +13 -0
  233. package/types/ngwr-toolbar.d.ts +27 -0
  234. package/types/ngwr-transfer.d.ts +2 -0
  235. package/types/ngwr-utils.d.ts +61 -2
  236. package/types/ngwr-version.d.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-command-palette.mjs","names":[],"sources":["../../../projects/lib/command-palette/command-palette.ts","../../../projects/lib/command-palette/command-palette.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory, FocusMonitor } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { type BlockScrollStrategy, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\n\nimport { debounce, skip, timer } from 'rxjs';\n\nimport { WrHotkey, type WrHotkeyHandle, type WrHotkeySpec } from 'ngwr/hotkey';\nimport { wrReadI18nText, useI18nText } from 'ngwr/i18n';\nimport { WrIcon } from 'ngwr/icon';\nimport { WR_OVERLAY_CONTAINER } from 'ngwr/overlay';\nimport { wrIsComposing, wrCheckStyles, wrRestoreFocus } from 'ngwr/utils';\n\nimport type { WrCommandItem } from './types';\n\ninterface Bucket {\n readonly title: string | null;\n readonly items: readonly WrCommandItem[];\n}\n\nlet listboxUid = 0;\n\nfunction bucketize(items: readonly WrCommandItem[]): readonly Bucket[] {\n const map = new Map<string | null, WrCommandItem[]>();\n for (const item of items) {\n const key = item.group ?? null;\n const bucket = map.get(key);\n if (bucket) bucket.push(item);\n else map.set(key, [item]);\n }\n return [...map.entries()].map(([title, items]) => ({ title, items }));\n}\n\nfunction matches(item: WrCommandItem, query: string): boolean {\n if (!query) return true;\n const q = query.toLowerCase();\n if (item.label.toLowerCase().includes(q)) return true;\n if (item.description?.toLowerCase().includes(q)) return true;\n if (item.group?.toLowerCase().includes(q)) return true;\n if (item.keywords?.some(k => k.toLowerCase().includes(q))) return true;\n return false;\n}\n\n/**\n * `⌘K`-style command palette — a centred modal with a search input and\n * filtered list of actions. Items can be grouped, have icons, descriptions,\n * and visual shortcut hints.\n *\n * Drop one at the root of the app, pass it the list of commands, and bind\n * a global hotkey (default `'mod+k'`). Use `[(open)]` for controlled\n * visibility, or let it manage itself.\n *\n * @example\n * ```html\n * <wr-command-palette [items]=\"commands\" trigger=\"mod+k\" (picked)=\"onPicked($event)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/command-palette\n */\n@Component({\n selector: 'wr-command-palette',\n templateUrl: './command-palette.html',\n encapsulation: ViewEncapsulation.None,\n imports: [WrIcon],\n})\nexport class WrCommandPalette {\n /** Accessible name. Falls back to `commandPalette.label`, then `'Command palette'`. */\n readonly paletteLabel = input<string | null>(null);\n\n protected readonly resolvedPaletteLabel = useI18nText(this.paletteLabel, 'commandPalette.label', 'Command palette');\n\n /** Items shown in the palette. */\n readonly items = input<readonly WrCommandItem[]>([]);\n\n /** Controlled open state (two-way bindable). @default false */\n readonly open = model(false);\n\n /** Global hotkey that opens the palette. `null` disables auto-binding. @default 'mod+k' */\n readonly trigger = input<WrHotkeySpec | null>('mod+k');\n\n /** Search input placeholder. Falls back to `commandPalette.placeholder`. */\n readonly placeholder = input<string | null>(null);\n\n /** Text shown when no items match. Falls back to `commandPalette.noResults`. */\n readonly emptyText = input<string | null>(null);\n\n /**\n * Overrides the `commandPalette.loading` catalog string, shown instead of\n * {@link emptyText} while {@link loading} is true.\n */\n readonly loadingText = input<string | null>(null);\n\n protected readonly resolvedPlaceholder = useI18nText(\n this.placeholder,\n 'commandPalette.placeholder',\n 'Type a command or search…'\n );\n protected readonly resolvedEmpty = useI18nText(this.emptyText, 'commandPalette.noResults', 'No results');\n protected readonly resolvedLoading = useI18nText(this.loadingText, 'commandPalette.loading', 'Searching…');\n\n /**\n * The key-cap chip beside the search field. It was the literal `esc` in the\n * template — the one string on this component no catalog could reach, so a\n * fully Russian palette still hinted in English.\n */\n protected readonly resolvedEscHint = wrReadI18nText('commandPalette.escHint', 'esc');\n\n /** Auto-close on `(picked)`. Set false to keep open. @default true */\n readonly closeOnPick = input(true, { transform: coerceBooleanProperty });\n\n /** Fires when the user commits an item (Enter / click). */\n readonly picked = output<WrCommandItem>();\n\n /**\n * The search text. Two-way, so a host can seed it, clear it, or read what the\n * user is looking for — the palette used to keep this to itself, which is what\n * made it impossible to back with anything but a static `items` array.\n *\n * Writing it does NOT re-run a host's search on its own: the debounced\n * {@link searchChange} output is what fires, on exactly the cadence\n * {@link debounceMs} sets.\n */\n readonly query = model('');\n\n /**\n * The item list is already scoped to the query upstream — skip the built-in\n * client-side filter. Set it when `[items]` is fed from a server via the\n * {@link searchChange} output.\n *\n * Without this, a backend that ranks or tolerates typos (returning rows whose\n * labels do not literally contain the query) would have those rows hidden\n * again on the client — the same rule `wr-select` follows, and the same\n * reason. @default false\n */\n readonly serverSearch = input(false, { transform: coerceBooleanProperty });\n\n /**\n * A host-driven search is in flight. Swaps the empty row for\n * {@link loadingText} — an async palette that says \"No results\" between every\n * keystroke and its answer is stating something false. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /**\n * How long the query must settle before {@link searchChange} fires, in ms.\n * A search request per keystroke is what exhausts a metered search backend:\n * typing `select` is six requests at 0 and roughly one at 250. @default 250\n */\n readonly debounceMs = input(250, { transform: (v: unknown): number => Math.max(0, Number(v) || 0) });\n\n /**\n * The settled query. This is the hook for a server-backed palette: dispatch\n * on it, then feed the result into `[items]` with `[serverSearch]` set.\n *\n * Fires on the {@link debounceMs} cadence, NOT per keystroke — `queryChange`\n * is the per-keystroke signal if that is what you want.\n */\n readonly searchChange = output<string>();\n\n protected readonly activeIndex = signal(0);\n\n protected readonly inputEl = viewChild<ElementRef<HTMLInputElement>>('input');\n protected readonly panelEl = viewChild<ElementRef<HTMLElement>>('panel');\n\n /** Listbox id (referenced by the input's `aria-controls`). */\n protected readonly listboxId = `wr-command-palette-listbox-${++listboxUid}`;\n\n /** @internal Build a stable option id for a given flat index. */\n protected optionId(i: number): string {\n return `${this.listboxId}-opt-${i}`;\n }\n\n /**\n * A `role=\"listbox\"` may only own `option` and `group` children, so a titled\n * bucket becomes a labelled group and an untitled one drops out of the tree\n * entirely — leaving its options as the listbox's own children rather than as\n * role-less wrappers ARIA has no rule for.\n */\n protected groupTitleId(index: number): string {\n return `${this.listboxId}-group-${index}`;\n }\n\n /** Id of the active option for `aria-activedescendant`. */\n protected readonly activeOptionId = computed<string | null>(() => {\n const i = this.activeIndex();\n return i >= 0 && i < this.filtered().length ? this.optionId(i) : null;\n });\n\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly hotkeys = inject(WrHotkey);\n private readonly destroyRef = inject(DestroyRef);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly overlayContainer = inject(WR_OVERLAY_CONTAINER);\n private bindingHandle: WrHotkeyHandle | null = null;\n private focusTrap: ConfigurableFocusTrap | null = null;\n /**\n * The page behind a modal does not scroll, and this one announces\n * `aria-modal=\"true\"` over a backdrop: wheeling over that backdrop scrolled the\n * document 500px while the palette stayed open. The palette renders in place\n * rather than through an overlay, so it borrows the CDK's own block strategy —\n * the one `WrDialog` gets from its overlay.\n */\n private scrollBlock: BlockScrollStrategy | null = null;\n private previouslyFocused: HTMLElement | null = null;\n\n /**\n * The open branch below builds the trap inside a `queueMicrotask`, so a\n * palette destroyed while open — in the same task that opened it — runs its\n * destroy hook first and then constructs a fresh trap nothing will ever\n * destroy. A `ConfigurableFocusTrap` plants two anchor elements in the panel\n * and holds it, so that is retained DOM, not just a stray object.\n */\n private destroyed = false;\n\n /** Whether this palette filters `items` itself. */\n protected readonly clientFilter = computed(() => !this.serverSearch());\n\n /**\n * Nothing has been asked yet, so there is nothing to report as missing.\n *\n * A client-filtered palette cannot reach this state — an empty query matches\n * every item, so the list is never empty on open. A server-backed one opens\n * with no items by construction, and saying \"No results\" before a single\n * keystroke answers a question nobody asked.\n */\n protected readonly awaitingQuery = computed(() => this.serverSearch() && this.query().trim().length === 0);\n\n /** Grouped view — what the template renders. */\n protected readonly buckets = computed<readonly Bucket[]>(() =>\n bucketize(this.clientFilter() ? this.items().filter(item => matches(item, this.query())) : this.items())\n );\n\n /**\n * Flat list in RENDER order — what keyboard navigation walks, and what every\n * index in this component means. Derived FROM the buckets rather than from the\n * filter: `bucketize` collects each group as it first appears, so a flat\n * source-order list disagrees with the screen the moment two groups interleave.\n * It did, and one ArrowDown moved the highlight two rows while Enter fired the\n * command below the one that looked selected.\n */\n protected readonly filtered = computed<readonly WrCommandItem[]>(() =>\n this.buckets().flatMap(bucket => bucket.items)\n );\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('command-palette');\n // The settled query, for a host-driven search. `debounce(() => timer(...))`\n // rather than `debounceTime(this.debounceMs())`: this runs in the\n // constructor, where inputs are not bound yet, so reading the input eagerly\n // would pin the delay to the default and ignore `[debounceMs]` for good.\n //\n // `skip(1)` sits BEFORE the debounce so it drops the mount-time replay of\n // the empty query and nothing else. Downstream it would instead drop the\n // first SETTLED emission — and when a fast typist's opening keystrokes\n // coalesce with that initial `''`, the dropped emission is their query.\n //\n // Both rules are `wr-select`'s, arrived at there the hard way; this is the\n // same pipeline minus the async loader, which the palette does not own.\n toObservable(this.query)\n .pipe(\n skip(1),\n debounce(() => timer(this.debounceMs())),\n takeUntilDestroyed(this.destroyRef)\n )\n .subscribe(query => this.searchChange.emit(query));\n\n // Bind / re-bind the global trigger whenever the spec changes.\n effect(() => {\n this.bindingHandle?.unbind();\n const spec = this.trigger();\n if (!spec) return;\n this.bindingHandle = this.hotkeys.bind(\n spec,\n event => {\n // CLAIM the chord, and the distinction is the whole point: the\n // `preventDefault` OPTION suppresses the browser, while a handler\n // calling `preventDefault()` is how `WrHotkey` is documented to learn\n // that a binding took the chord and the lower-priority ones should be\n // skipped. A palette that only toggled left the chord unclaimed, so\n // two palettes on one page would both open on `mod+k`.\n event.preventDefault();\n this.open.update(v => !v);\n },\n { allowInInput: true }\n );\n });\n\n // Reset query + active index whenever we open.\n effect(() => {\n if (!this.open()) return;\n this.query.set('');\n this.activeIndex.set(0);\n });\n\n // Focus trap + restore.\n effect(() => {\n if (!this.isBrowser) return;\n if (this.open()) {\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n // The strategy's `cdk-global-scrollblock` class is styled by the CDK's\n // structural sheet, which the overlay container loads — and an app may\n // open this before it has ever opened an overlay.\n this.overlayContainer.getContainerElement();\n this.scrollBlock ??= this.scrollStrategies.block();\n this.scrollBlock.enable();\n queueMicrotask(() => {\n if (this.destroyed) return;\n const host = this.panelEl()?.nativeElement;\n if (!host) return;\n this.focusTrap?.destroy();\n this.focusTrap = this.focusTrapFactory.create(host);\n void this.focusTrap.focusInitialElementWhenReady();\n });\n } else {\n this.scrollBlock?.disable();\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n if (restore && typeof restore.focus === 'function') wrRestoreFocus(restore, this.focusMonitor);\n }\n });\n\n afterNextRender(() => {\n if (this.open()) this.inputEl()?.nativeElement.focus();\n });\n\n // Auto-focus the input when opened.\n effect(() => {\n if (!this.open()) return;\n queueMicrotask(() => this.inputEl()?.nativeElement.focus());\n });\n\n // Clamp the active index when the filtered list shrinks.\n effect(() => {\n const max = Math.max(0, this.filtered().length - 1);\n if (this.activeIndex() > max) this.activeIndex.set(max);\n });\n\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n this.bindingHandle?.unbind();\n // The trap is torn down in the close branch of the effect above, which never\n // runs when the component itself goes away while still open — leaving a live\n // trap holding the removed panel and its document listeners.\n this.focusTrap?.destroy();\n this.focusTrap = null;\n // Same reason: the close branch never runs for a palette destroyed open.\n this.scrollBlock?.disable();\n });\n }\n\n // Template handlers\n\n protected onQueryInput(event: Event): void {\n this.query.set((event.target as HTMLInputElement).value);\n this.activeIndex.set(0);\n // The highlight goes back to the first row, and the SCROLLER has to go with\n // it. Nothing moved it otherwise: the options are not focusable, so the\n // browser scrolls nothing on its own, and `revealActive` is called only from\n // the arrow keys. Edit the query after arrowing down a long list and the\n // highlight sat at the top, out of sight, while the rows on screen were\n // something else — and Enter ran the command the user could not see.\n //\n // `scrollTop = 0` rather than `revealActive()`: the list has just been\n // re-filtered, so under zoneless CD the row at index 0 is still the OLD one\n // until change detection runs, and the destination is the top either way.\n const body = this.panelEl()?.nativeElement.querySelector<HTMLElement>('.wr-command-palette__body');\n if (body) body.scrollTop = 0;\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n // Every key below belongs to the input method while it is converting: Enter\n // accepts a candidate, Escape cancels the conversion, the arrows walk the\n // candidate list. Acting on them closed the palette — and threw the query\n // away — the first time a Japanese user pressed Escape to undo a reading.\n if (wrIsComposing(event)) return;\n\n const list = this.filtered();\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (list.length > 0) this.activeIndex.set((this.activeIndex() + 1) % list.length);\n this.revealActive();\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (list.length > 0) this.activeIndex.set((this.activeIndex() - 1 + list.length) % list.length);\n this.revealActive();\n break;\n case 'Home':\n event.preventDefault();\n this.activeIndex.set(0);\n this.revealActive();\n break;\n case 'End':\n event.preventDefault();\n this.activeIndex.set(Math.max(0, list.length - 1));\n this.revealActive();\n break;\n case 'Enter': {\n event.preventDefault();\n const item = list[this.activeIndex()];\n if (item) this.commit(item);\n break;\n }\n case 'Escape':\n event.preventDefault();\n this.close();\n break;\n default:\n break;\n }\n }\n\n protected onBackdropClick(): void {\n this.close();\n }\n\n protected onItemClick(item: WrCommandItem, event: MouseEvent): void {\n event.preventDefault();\n this.commit(item);\n }\n\n protected onItemHover(item: WrCommandItem): void {\n const i = this.filtered().indexOf(item);\n if (i >= 0) this.activeIndex.set(i);\n }\n\n /** Flat index of an item within the filtered list — for highlight checks. */\n protected indexOf(item: WrCommandItem): number {\n return this.filtered().indexOf(item);\n }\n\n // Public API\n\n /** Open the palette. */\n show(): void {\n this.open.set(true);\n }\n\n /** Close the palette. */\n close(): void {\n this.open.set(false);\n }\n\n // Internals\n\n /**\n * Keep the highlighted option on screen. The body is a fixed-height scroller and\n * the options are not focusable, so nothing moves it on the browser's behalf —\n * arrow keys walked the highlight straight off the bottom and out of sight.\n * Keyboard only: doing it on hover would fight the pointer that caused it.\n * `wr-select` and `wr-tree` keep the same promise through their own\n * `ensureVisible`; theirs is index maths because they are virtualized.\n */\n private revealActive(): void {\n if (!this.isBrowser) return;\n const id = this.activeOptionId();\n if (!id) return;\n // Ids are position-based and stable, so the element is findable straight away —\n // no need to wait for change detection to re-mark the active row.\n this.panelEl()?.nativeElement.querySelector<HTMLElement>(`#${id}`)?.scrollIntoView({ block: 'nearest' });\n }\n\n private commit(item: WrCommandItem): void {\n // Let the page go BEFORE the command runs when the pick also closes the\n // palette. A command commonly opens a dialog, and the CDK block strategy will\n // not engage while the page is already blocked — so the dialog would open\n // unblocked, and the palette's own release a moment later would leave the\n // page scrolling behind it.\n if (this.closeOnPick()) this.scrollBlock?.disable();\n item.action?.();\n this.picked.emit(item);\n if (this.closeOnPick()) this.close();\n }\n}\n","@if (open()) {\n <div class=\"wr-command-palette\" role=\"dialog\" aria-modal=\"true\" [attr.aria-label]=\"resolvedPaletteLabel()\">\n <!-- Backdrop captures clicks to close. Not focusable — keyboard users use\n Esc on the panel below. -->\n\n <div class=\"wr-command-palette__backdrop\" aria-hidden=\"true\" (click)=\"onBackdropClick()\"></div>\n\n <!-- Keydown is delegated from the search input; tabindex enables Esc when\n the input is unfocused. -->\n <div #panel class=\"wr-command-palette__panel\" tabindex=\"-1\" (keydown)=\"onKeydown($event)\">\n <div class=\"wr-command-palette__search\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n <path d=\"M11 11 L14 14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n <input\n #input\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n [attr.aria-controls]=\"listboxId\"\n [attr.aria-expanded]=\"true\"\n [attr.aria-activedescendant]=\"activeOptionId() || null\"\n [placeholder]=\"resolvedPlaceholder()\"\n [value]=\"query()\"\n (input)=\"onQueryInput($event)\"\n />\n <kbd class=\"wr-command-palette__hint\">{{ resolvedEscHint() }}</kbd>\n </div>\n\n <!-- The empty row sits OUTSIDE the listbox below, and is a live region.\n A listbox may only own `option` and `group` children — the same rule\n the buckets already follow — so this row inside it was an\n `aria-required-children` critical for every query that matched\n nothing, and an empty listbox on its own is not. `role=\"status\"` also\n gets the message spoken while focus stays in the search input. -->\n @if (loading()) {\n <div class=\"wr-command-palette__empty\" role=\"status\">{{ resolvedLoading() }}</div>\n } @else if (filtered().length === 0 && !awaitingQuery()) {\n <div class=\"wr-command-palette__empty\" role=\"status\">{{ resolvedEmpty() }}</div>\n }\n\n <div class=\"wr-command-palette__body\" role=\"listbox\" [attr.id]=\"listboxId\">\n @for (bucket of buckets(); track bucket.title; let groupIndex = $index) {\n <!-- A listbox may only own `option` and `group` children, so a titled\n bucket is a labelled group and an untitled one leaves the tree with\n `role=\"none\"`, promoting its options to the listbox's own. -->\n <div\n class=\"wr-command-palette__group\"\n [attr.role]=\"bucket.title ? 'group' : 'none'\"\n [attr.aria-labelledby]=\"bucket.title ? groupTitleId(groupIndex) : null\"\n >\n @if (bucket.title) {\n <div class=\"wr-command-palette__group-title\" [attr.id]=\"groupTitleId(groupIndex)\">\n {{ bucket.title }}\n </div>\n }\n @for (item of bucket.items; track item.id) {\n <div\n class=\"wr-command-palette__option\"\n role=\"option\"\n [attr.id]=\"optionId(indexOf(item))\"\n [class.wr-command-palette__option--active]=\"indexOf(item) === activeIndex()\"\n [attr.aria-selected]=\"indexOf(item) === activeIndex()\"\n (mouseenter)=\"onItemHover(item)\"\n (mousedown)=\"onItemClick(item, $event)\"\n >\n @if (item.icon) {\n <wr-icon class=\"wr-command-palette__option-icon\" [name]=\"item.icon\" size=\"16\" />\n } @else {\n <span class=\"wr-command-palette__option-icon\" aria-hidden=\"true\"></span>\n }\n <div class=\"wr-command-palette__option-body\">\n <div class=\"wr-command-palette__option-label\">{{ item.label }}</div>\n @if (item.description) {\n <div class=\"wr-command-palette__option-description\">{{ item.description }}</div>\n }\n </div>\n @if (item.shortcut) {\n <kbd class=\"wr-command-palette__option-shortcut\">{{ item.shortcut }}</kbd>\n }\n </div>\n }\n </div>\n }\n </div>\n\n <!-- Footer slot. A real palette carries something under the list — a key\n legend, a result count, a provider's required attribution — and there\n was nowhere to put it. Projected rather than an input, because the\n content is markup (a link, a logo) rather than a string.\n\n Outside the listbox on purpose: a `role=\"listbox\"` may own only\n `option` and `group` children, the same rule the buckets and the empty\n row already follow. -->\n <div class=\"wr-command-palette__footer\">\n <ng-content select=\"[wrCommandPaletteFooter]\" />\n </div>\n </div>\n </div>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,IAAI,aAAa;AAEjB,SAAS,UAAU,OAA+B;CAChD,MAAM,sBAAM,IAAI,IAAG;CACnB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,KAAK,SAAS;EAC1B,MAAM,SAAS,IAAI,IAAI,GAAG;EAC1B,IAAI,QAAQ,OAAO,KAAK,IAAI;OACvB,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;CAC1B;CACA,OAAO,CAAC,GAAG,IAAI,QAAO,CAAE,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY;EAAE;EAAO;CAAK,EAAG;AACtE;AAEA,SAAS,QAAQ,MAAqB,OAAa;CACjD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,IAAI,MAAM,YAAW;CAC3B,IAAI,KAAK,MAAM,YAAW,CAAE,CAAC,SAAS,CAAC,GAAG,OAAO;CACjD,IAAI,KAAK,aAAa,YAAW,CAAE,CAAC,SAAS,CAAC,GAAG,OAAO;CACxD,IAAI,KAAK,OAA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A;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,cAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CACZ,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-command-palette.mjs","names":[],"sources":["../../../projects/lib/command-palette/command-palette.ts","../../../projects/lib/command-palette/command-palette.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, ConfigurableFocusTrapFactory, FocusMonitor } from '@angular/cdk/a11y';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport type { ScrollStrategy } from '@angular/cdk/overlay';\nimport { isPlatformBrowser } from '@angular/common';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n PLATFORM_ID,\n ViewEncapsulation,\n afterNextRender,\n computed,\n effect,\n inject,\n input,\n model,\n output,\n signal,\n viewChild,\n} from '@angular/core';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\n\nimport { debounce, skip, timer } from 'rxjs';\n\nimport { WrHotkey, type WrHotkeyHandle, type WrHotkeySpec } from 'ngwr/hotkey';\nimport { wrReadI18nText, useI18nText } from 'ngwr/i18n';\nimport { WrIcon } from 'ngwr/icon';\nimport { WR_OVERLAY_CONTAINER, WrScrollBlock } from 'ngwr/overlay';\nimport { wrIsComposing, wrCheckStyles, wrRestoreFocus } from 'ngwr/utils';\n\nimport type { WrCommandItem } from './types';\n\ninterface Bucket {\n readonly title: string | null;\n readonly items: readonly WrCommandItem[];\n}\n\nlet listboxUid = 0;\n\nfunction bucketize(items: readonly WrCommandItem[]): readonly Bucket[] {\n const map = new Map<string | null, WrCommandItem[]>();\n for (const item of items) {\n const key = item.group ?? null;\n const bucket = map.get(key);\n if (bucket) bucket.push(item);\n else map.set(key, [item]);\n }\n return [...map.entries()].map(([title, items]) => ({ title, items }));\n}\n\nfunction matches(item: WrCommandItem, query: string): boolean {\n if (!query) return true;\n const q = query.toLowerCase();\n if (item.label.toLowerCase().includes(q)) return true;\n if (item.description?.toLowerCase().includes(q)) return true;\n if (item.group?.toLowerCase().includes(q)) return true;\n if (item.keywords?.some(k => k.toLowerCase().includes(q))) return true;\n return false;\n}\n\n/**\n * `⌘K`-style command palette — a centred modal with a search input and\n * filtered list of actions. Items can be grouped, have icons, descriptions,\n * and visual shortcut hints.\n *\n * Drop one at the root of the app, pass it the list of commands, and bind\n * a global hotkey (default `'mod+k'`). Use `[(open)]` for controlled\n * visibility, or let it manage itself.\n *\n * @example\n * ```html\n * <wr-command-palette [items]=\"commands\" trigger=\"mod+k\" (picked)=\"onPicked($event)\" />\n * ```\n *\n * @see https://ngwr.dev/reference/components/command-palette\n */\n@Component({\n selector: 'wr-command-palette',\n templateUrl: './command-palette.html',\n encapsulation: ViewEncapsulation.None,\n imports: [WrIcon],\n})\nexport class WrCommandPalette {\n /** Accessible name. Falls back to `commandPalette.label`, then `'Command palette'`. */\n readonly paletteLabel = input<string | null>(null);\n\n protected readonly resolvedPaletteLabel = useI18nText(this.paletteLabel, 'commandPalette.label', 'Command palette');\n\n /** Items shown in the palette. */\n readonly items = input<readonly WrCommandItem[]>([]);\n\n /** Controlled open state (two-way bindable). @default false */\n readonly open = model(false);\n\n /** Global hotkey that opens the palette. `null` disables auto-binding. @default 'mod+k' */\n readonly trigger = input<WrHotkeySpec | null>('mod+k');\n\n /** Search input placeholder. Falls back to `commandPalette.placeholder`. */\n readonly placeholder = input<string | null>(null);\n\n /** Text shown when no items match. Falls back to `commandPalette.noResults`. */\n readonly emptyText = input<string | null>(null);\n\n /**\n * Overrides the `commandPalette.loading` catalog string, shown instead of\n * {@link emptyText} while {@link loading} is true.\n */\n readonly loadingText = input<string | null>(null);\n\n protected readonly resolvedPlaceholder = useI18nText(\n this.placeholder,\n 'commandPalette.placeholder',\n 'Type a command or search…'\n );\n protected readonly resolvedEmpty = useI18nText(this.emptyText, 'commandPalette.noResults', 'No results');\n protected readonly resolvedLoading = useI18nText(this.loadingText, 'commandPalette.loading', 'Searching…');\n\n /**\n * The key-cap chip beside the search field. It was the literal `esc` in the\n * template — the one string on this component no catalog could reach, so a\n * fully Russian palette still hinted in English.\n */\n protected readonly resolvedEscHint = wrReadI18nText('commandPalette.escHint', 'esc');\n\n /** Auto-close on `(picked)`. Set false to keep open. @default true */\n readonly closeOnPick = input(true, { transform: coerceBooleanProperty });\n\n /** Fires when the user commits an item (Enter / click). */\n readonly picked = output<WrCommandItem>();\n\n /**\n * The search text. Two-way, so a host can seed it, clear it, or read what the\n * user is looking for — the palette used to keep this to itself, which is what\n * made it impossible to back with anything but a static `items` array.\n *\n * Writing it does NOT re-run a host's search on its own: the debounced\n * {@link searchChange} output is what fires, on exactly the cadence\n * {@link debounceMs} sets.\n */\n readonly query = model('');\n\n /**\n * The item list is already scoped to the query upstream — skip the built-in\n * client-side filter. Set it when `[items]` is fed from a server via the\n * {@link searchChange} output.\n *\n * Without this, a backend that ranks or tolerates typos (returning rows whose\n * labels do not literally contain the query) would have those rows hidden\n * again on the client — the same rule `wr-select` follows, and the same\n * reason. @default false\n */\n readonly serverSearch = input(false, { transform: coerceBooleanProperty });\n\n /**\n * A host-driven search is in flight. Swaps the empty row for\n * {@link loadingText} — an async palette that says \"No results\" between every\n * keystroke and its answer is stating something false. @default false\n */\n readonly loading = input(false, { transform: coerceBooleanProperty });\n\n /**\n * How long the query must settle before {@link searchChange} fires, in ms.\n * A search request per keystroke is what exhausts a metered search backend:\n * typing `select` is six requests at 0 and roughly one at 250. @default 250\n */\n readonly debounceMs = input(250, { transform: (v: unknown): number => Math.max(0, Number(v) || 0) });\n\n /**\n * The settled query. This is the hook for a server-backed palette: dispatch\n * on it, then feed the result into `[items]` with `[serverSearch]` set.\n *\n * Fires on the {@link debounceMs} cadence, NOT per keystroke — `queryChange`\n * is the per-keystroke signal if that is what you want.\n */\n readonly searchChange = output<string>();\n\n protected readonly activeIndex = signal(0);\n\n protected readonly inputEl = viewChild<ElementRef<HTMLInputElement>>('input');\n protected readonly panelEl = viewChild<ElementRef<HTMLElement>>('panel');\n private readonly rootEl = viewChild<ElementRef<HTMLElement>>('root');\n\n /** Listbox id (referenced by the input's `aria-controls`). */\n protected readonly listboxId = `wr-command-palette-listbox-${++listboxUid}`;\n\n /** @internal Build a stable option id for a given flat index. */\n protected optionId(i: number): string {\n return `${this.listboxId}-opt-${i}`;\n }\n\n /**\n * A `role=\"listbox\"` may only own `option` and `group` children, so a titled\n * bucket becomes a labelled group and an untitled one drops out of the tree\n * entirely — leaving its options as the listbox's own children rather than as\n * role-less wrappers ARIA has no rule for.\n */\n protected groupTitleId(index: number): string {\n return `${this.listboxId}-group-${index}`;\n }\n\n /** Id of the active option for `aria-activedescendant`. */\n protected readonly activeOptionId = computed<string | null>(() => {\n const i = this.activeIndex();\n return i >= 0 && i < this.filtered().length ? this.optionId(i) : null;\n });\n\n private readonly focusMonitor = inject(FocusMonitor);\n private readonly hotkeys = inject(WrHotkey);\n private readonly destroyRef = inject(DestroyRef);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly scrollBlockService = inject(WrScrollBlock);\n private readonly overlayContainer = inject(WR_OVERLAY_CONTAINER);\n private bindingHandle: WrHotkeyHandle | null = null;\n private focusTrap: ConfigurableFocusTrap | null = null;\n /**\n * The page behind a modal does not scroll, and this one announces\n * `aria-modal=\"true\"` over a backdrop: wheeling over that backdrop scrolled the\n * document 500px while the palette stayed open. The palette renders in place\n * rather than through an overlay, so it borrows the CDK's own block strategy —\n * the one `WrDialog` gets from its overlay.\n */\n private scrollBlock: ScrollStrategy | null = null;\n private previouslyFocused: HTMLElement | null = null;\n\n /**\n * The open branch below builds the trap inside a `queueMicrotask`, so a\n * palette destroyed while open — in the same task that opened it — runs its\n * destroy hook first and then constructs a fresh trap nothing will ever\n * destroy. A `ConfigurableFocusTrap` plants two anchor elements in the panel\n * and holds it, so that is retained DOM, not just a stray object.\n */\n private destroyed = false;\n\n /** Whether this palette filters `items` itself. */\n protected readonly clientFilter = computed(() => !this.serverSearch());\n\n /**\n * Nothing has been asked yet, so there is nothing to report as missing.\n *\n * A client-filtered palette cannot reach this state — an empty query matches\n * every item, so the list is never empty on open. A server-backed one opens\n * with no items by construction, and saying \"No results\" before a single\n * keystroke answers a question nobody asked.\n */\n protected readonly awaitingQuery = computed(() => this.serverSearch() && this.query().trim().length === 0);\n\n /** Grouped view — what the template renders. */\n protected readonly buckets = computed<readonly Bucket[]>(() =>\n bucketize(this.clientFilter() ? this.items().filter(item => matches(item, this.query())) : this.items())\n );\n\n /**\n * Flat list in RENDER order — what keyboard navigation walks, and what every\n * index in this component means. Derived FROM the buckets rather than from the\n * filter: `bucketize` collects each group as it first appears, so a flat\n * source-order list disagrees with the screen the moment two groups interleave.\n * It did, and one ArrowDown moved the highlight two rows while Enter fired the\n * command below the one that looked selected.\n */\n protected readonly filtered = computed<readonly WrCommandItem[]>(() =>\n this.buckets().flatMap(bucket => bucket.items)\n );\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('command-palette');\n // The settled query, for a host-driven search. `debounce(() => timer(...))`\n // rather than `debounceTime(this.debounceMs())`: this runs in the\n // constructor, where inputs are not bound yet, so reading the input eagerly\n // would pin the delay to the default and ignore `[debounceMs]` for good.\n //\n // `skip(1)` sits BEFORE the debounce so it drops the mount-time replay of\n // the empty query and nothing else. Downstream it would instead drop the\n // first SETTLED emission — and when a fast typist's opening keystrokes\n // coalesce with that initial `''`, the dropped emission is their query.\n //\n // Both rules are `wr-select`'s, arrived at there the hard way; this is the\n // same pipeline minus the async loader, which the palette does not own.\n toObservable(this.query)\n .pipe(\n skip(1),\n debounce(() => timer(this.debounceMs())),\n takeUntilDestroyed(this.destroyRef)\n )\n .subscribe(query => this.searchChange.emit(query));\n\n // Bind / re-bind the global trigger whenever the spec changes.\n effect(() => {\n this.bindingHandle?.unbind();\n const spec = this.trigger();\n if (!spec) return;\n this.bindingHandle = this.hotkeys.bind(\n spec,\n event => {\n // CLAIM the chord, and the distinction is the whole point: the\n // `preventDefault` OPTION suppresses the browser, while a handler\n // calling `preventDefault()` is how `WrHotkey` is documented to learn\n // that a binding took the chord and the lower-priority ones should be\n // skipped. A palette that only toggled left the chord unclaimed, so\n // two palettes on one page would both open on `mod+k`.\n event.preventDefault();\n this.open.update(v => !v);\n },\n { allowInInput: true }\n );\n });\n\n // Reset query + active index whenever we open.\n effect(() => {\n if (!this.open()) return;\n this.query.set('');\n this.activeIndex.set(0);\n });\n\n // Focus trap + restore.\n effect(() => {\n if (!this.isBrowser) return;\n if (this.open()) {\n const active = document.activeElement;\n this.previouslyFocused = active instanceof HTMLElement ? active : null;\n // The strategy's `cdk-global-scrollblock` class is styled by the CDK's\n // structural sheet, which the overlay container loads — and an app may\n // open this before it has ever opened an overlay.\n this.overlayContainer.getContainerElement();\n this.scrollBlock ??= this.scrollBlockService.strategy();\n this.scrollBlock.enable();\n queueMicrotask(() => {\n if (this.destroyed) return;\n const host = this.panelEl()?.nativeElement;\n if (!host) return;\n // Last in the top layer, over any dialog, drawer or popover open now.\n // Set here and not in the template: a `popover` attribute hides the\n // element until it is shown, which a browser without the API never does.\n const root = this.rootEl()?.nativeElement;\n if (typeof root?.showPopover === 'function') {\n root.setAttribute('popover', 'manual');\n root.showPopover();\n }\n this.focusTrap?.destroy();\n this.focusTrap = this.focusTrapFactory.create(host);\n void this.focusTrap.focusInitialElementWhenReady();\n });\n } else {\n this.scrollBlock?.disable();\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n if (restore && typeof restore.focus === 'function') wrRestoreFocus(restore, this.focusMonitor);\n }\n });\n\n afterNextRender(() => {\n if (this.open()) this.inputEl()?.nativeElement.focus();\n });\n\n // Auto-focus the input when opened.\n effect(() => {\n if (!this.open()) return;\n queueMicrotask(() => this.inputEl()?.nativeElement.focus());\n });\n\n // Clamp the active index when the filtered list shrinks.\n effect(() => {\n const max = Math.max(0, this.filtered().length - 1);\n if (this.activeIndex() > max) this.activeIndex.set(max);\n });\n\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n this.bindingHandle?.unbind();\n // The trap is torn down in the close branch of the effect above, which never\n // runs when the component itself goes away while still open — leaving a live\n // trap holding the removed panel and its document listeners.\n this.focusTrap?.destroy();\n this.focusTrap = null;\n // Same reason: the close branch never runs for a palette destroyed open.\n this.scrollBlock?.disable();\n });\n }\n\n // Template handlers\n\n protected onQueryInput(event: Event): void {\n this.query.set((event.target as HTMLInputElement).value);\n this.activeIndex.set(0);\n // The highlight goes back to the first row, and the SCROLLER has to go with\n // it. Nothing moved it otherwise: the options are not focusable, so the\n // browser scrolls nothing on its own, and `revealActive` is called only from\n // the arrow keys. Edit the query after arrowing down a long list and the\n // highlight sat at the top, out of sight, while the rows on screen were\n // something else — and Enter ran the command the user could not see.\n //\n // `scrollTop = 0` rather than `revealActive()`: the list has just been\n // re-filtered, so under zoneless CD the row at index 0 is still the OLD one\n // until change detection runs, and the destination is the top either way.\n const body = this.panelEl()?.nativeElement.querySelector<HTMLElement>('.wr-command-palette__body');\n if (body) body.scrollTop = 0;\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n // Every key below belongs to the input method while it is converting: Enter\n // accepts a candidate, Escape cancels the conversion, the arrows walk the\n // candidate list. Acting on them closed the palette — and threw the query\n // away — the first time a Japanese user pressed Escape to undo a reading.\n if (wrIsComposing(event)) return;\n\n const list = this.filtered();\n switch (event.key) {\n case 'ArrowDown':\n event.preventDefault();\n if (list.length > 0) this.activeIndex.set((this.activeIndex() + 1) % list.length);\n this.revealActive();\n break;\n case 'ArrowUp':\n event.preventDefault();\n if (list.length > 0) this.activeIndex.set((this.activeIndex() - 1 + list.length) % list.length);\n this.revealActive();\n break;\n case 'Home':\n event.preventDefault();\n this.activeIndex.set(0);\n this.revealActive();\n break;\n case 'End':\n event.preventDefault();\n this.activeIndex.set(Math.max(0, list.length - 1));\n this.revealActive();\n break;\n case 'Enter': {\n event.preventDefault();\n const item = list[this.activeIndex()];\n if (item) this.commit(item);\n break;\n }\n case 'Escape':\n event.preventDefault();\n this.close();\n break;\n default:\n break;\n }\n }\n\n protected onBackdropClick(): void {\n this.close();\n }\n\n protected onItemClick(item: WrCommandItem, event: MouseEvent): void {\n if (event.button !== 0) return;\n event.preventDefault();\n this.commit(item);\n }\n\n protected onItemHover(item: WrCommandItem): void {\n const i = this.filtered().indexOf(item);\n if (i >= 0) this.activeIndex.set(i);\n }\n\n /** Flat index of an item within the filtered list — for highlight checks. */\n protected indexOf(item: WrCommandItem): number {\n return this.filtered().indexOf(item);\n }\n\n // Public API\n\n /** Open the palette. */\n show(): void {\n this.open.set(true);\n }\n\n /** Close the palette. */\n close(): void {\n this.open.set(false);\n }\n\n // Internals\n\n /**\n * Keep the highlighted option on screen. The body is a fixed-height scroller and\n * the options are not focusable, so nothing moves it on the browser's behalf —\n * arrow keys walked the highlight straight off the bottom and out of sight.\n * Keyboard only: doing it on hover would fight the pointer that caused it.\n * `wr-select` and `wr-tree` keep the same promise through their own\n * `ensureVisible`; theirs is index maths because they are virtualized.\n */\n private revealActive(): void {\n if (!this.isBrowser) return;\n const id = this.activeOptionId();\n if (!id) return;\n // Ids are position-based and stable, so the element is findable straight away —\n // no need to wait for change detection to re-mark the active row.\n this.panelEl()?.nativeElement.querySelector<HTMLElement>(`#${id}`)?.scrollIntoView({ block: 'nearest' });\n }\n\n private commit(item: WrCommandItem): void {\n // Let the page go BEFORE the command runs when the pick also closes the\n // palette. A command commonly opens a dialog, and the CDK block strategy will\n // not engage while the page is already blocked — so the dialog would open\n // unblocked, and the palette's own release a moment later would leave the\n // page scrolling behind it.\n if (this.closeOnPick()) this.scrollBlock?.disable();\n item.action?.();\n this.picked.emit(item);\n if (this.closeOnPick()) this.close();\n }\n}\n","@if (open()) {\n <div #root class=\"wr-command-palette\" role=\"dialog\" aria-modal=\"true\" [attr.aria-label]=\"resolvedPaletteLabel()\">\n <!-- Backdrop captures clicks to close. Not focusable — keyboard users use\n Esc on the panel below. -->\n\n <div class=\"wr-command-palette__backdrop\" aria-hidden=\"true\" (click)=\"onBackdropClick()\"></div>\n\n <!-- Keydown is delegated from the search input; tabindex enables Esc when\n the input is unfocused. -->\n <div #panel class=\"wr-command-palette__panel\" tabindex=\"-1\" (keydown)=\"onKeydown($event)\">\n <div class=\"wr-command-palette__search\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <circle cx=\"7\" cy=\"7\" r=\"5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" />\n <path d=\"M11 11 L14 14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" />\n </svg>\n <input\n #input\n type=\"text\"\n role=\"combobox\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n aria-autocomplete=\"list\"\n [attr.aria-controls]=\"listboxId\"\n [attr.aria-expanded]=\"true\"\n [attr.aria-activedescendant]=\"activeOptionId() || null\"\n [placeholder]=\"resolvedPlaceholder()\"\n [value]=\"query()\"\n (input)=\"onQueryInput($event)\"\n />\n <kbd class=\"wr-command-palette__hint\">{{ resolvedEscHint() }}</kbd>\n </div>\n\n <!-- The empty row sits OUTSIDE the listbox below, and is a live region.\n A listbox may only own `option` and `group` children — the same rule\n the buckets already follow — so this row inside it was an\n `aria-required-children` critical for every query that matched\n nothing, and an empty listbox on its own is not. `role=\"status\"` also\n gets the message spoken while focus stays in the search input. -->\n @if (loading()) {\n <div class=\"wr-command-palette__empty\" role=\"status\">{{ resolvedLoading() }}</div>\n } @else if (filtered().length === 0 && !awaitingQuery()) {\n <div class=\"wr-command-palette__empty\" role=\"status\">{{ resolvedEmpty() }}</div>\n }\n\n <div class=\"wr-command-palette__body\" role=\"listbox\" [attr.id]=\"listboxId\">\n @for (bucket of buckets(); track bucket.title; let groupIndex = $index) {\n <!-- A listbox may only own `option` and `group` children, so a titled\n bucket is a labelled group and an untitled one leaves the tree with\n `role=\"none\"`, promoting its options to the listbox's own. -->\n <div\n class=\"wr-command-palette__group\"\n [attr.role]=\"bucket.title ? 'group' : 'none'\"\n [attr.aria-labelledby]=\"bucket.title ? groupTitleId(groupIndex) : null\"\n >\n @if (bucket.title) {\n <div class=\"wr-command-palette__group-title\" [attr.id]=\"groupTitleId(groupIndex)\">\n {{ bucket.title }}\n </div>\n }\n @for (item of bucket.items; track item.id) {\n <div\n class=\"wr-command-palette__option\"\n role=\"option\"\n [attr.id]=\"optionId(indexOf(item))\"\n [class.wr-command-palette__option--active]=\"indexOf(item) === activeIndex()\"\n [attr.aria-selected]=\"indexOf(item) === activeIndex()\"\n (mouseenter)=\"onItemHover(item)\"\n (mousedown)=\"onItemClick(item, $event)\"\n >\n @if (item.icon) {\n <wr-icon class=\"wr-command-palette__option-icon\" [name]=\"item.icon\" size=\"16\" />\n } @else {\n <span class=\"wr-command-palette__option-icon\" aria-hidden=\"true\"></span>\n }\n <div class=\"wr-command-palette__option-body\">\n <div class=\"wr-command-palette__option-label\">{{ item.label }}</div>\n @if (item.description) {\n <div class=\"wr-command-palette__option-description\">{{ item.description }}</div>\n }\n </div>\n @if (item.shortcut) {\n <kbd class=\"wr-command-palette__option-shortcut\">{{ item.shortcut }}</kbd>\n }\n </div>\n }\n </div>\n }\n </div>\n\n <!-- Footer slot. A real palette carries something under the list — a key\n legend, a result count, a provider's required attribution — and there\n was nowhere to put it. Projected rather than an input, because the\n content is markup (a link, a logo) rather than a string.\n\n Outside the listbox on purpose: a `role=\"listbox\"` may own only\n `option` and `group` children, the same rule the buckets and the empty\n row already follow. -->\n <div class=\"wr-command-palette__footer\">\n <ng-content select=\"[wrCommandPaletteFooter]\" />\n </div>\n </div>\n </div>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA4CA,IAAI,aAAa;AAEjB,SAAS,UAAU,OAA+B;CAChD,MAAM,sBAAM,IAAI,IAAG;CACnB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,KAAK,SAAS;EAC1B,MAAM,SAAS,IAAI,IAAI,GAAG;EAC1B,IAAI,QAAQ,OAAO,KAAK,IAAI;OACvB,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC;CAC1B;CACA,OAAO,CAAC,GAAG,IAAI,QAAO,CAAE,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY;EAAE;EAAO;CAAK,EAAG;AACtE;AAEA,SAAS,QAAQ,MAAqB,OAAa;CACjD,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,IAAI,MAAM,YAAW;CAC3B,IAAI,KAAK,MAAM,YAAW,CAAE,CAAC,SAAS,CAAC,GAAG,OAAO;CACjD,IAAI,KAAK,aAAa,YAAW,CAAE,CAAC,SAAS,CAAC,GAAG,OAAO;CACxD,IAAI,KAAK,OAAO,YAAW,CAAE,CAAC,SAAS,CAAC,GAAG,OAAO;CAClD,IAAI,KAAK,UAAU,MAAK,MAAK,EAAE,YAAW,CAAE,CAAC,SAAS,CAAC,CAAC,GAAG,OAAO;CAClE,OAAO;AACT;AAwBA,IAAa,mBAAb,MAAa,iBAAgB;CAElB,eAAe,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;CAE/B,uBAAuB,YAAY,KAAK,cAAc,wBAAwB,iBAA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AAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,YAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,cAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,SAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CACZ,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CACV,QAAM,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
@@ -70,6 +70,10 @@ var WrCompare = class WrCompare {
70
70
  }
71
71
  onPointerMove(event) {
72
72
  if (!this.dragging) return;
73
+ if (this.disabled()) {
74
+ this.dragging = false;
75
+ return;
76
+ }
73
77
  this.updateFromPointer(event);
74
78
  }
75
79
  onPointerUp(event) {
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-compare.mjs","names":[],"sources":["../../../projects/lib/compare/compare.ts","../../../projects/lib/compare/compare.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Before/after comparison slider. Works with any content — project two\n * pieces of markup with `wrCompareBefore` and `wrCompareAfter` attributes;\n * the component stacks them in the same cell and clips the \"after\" side\n * with a draggable divider.\n *\n * @example\n * ```html\n * <wr-compare [(position)]=\"pos\">\n * <img wrCompareBefore src=\"before.jpg\" alt=\"\" />\n * <img wrCompareAfter src=\"after.jpg\" alt=\"\" />\n * </wr-compare>\n *\n * <wr-compare orientation=\"vertical\">\n * <pre wrCompareBefore>{{ oldCode }}</pre>\n * <pre wrCompareAfter>{{ newCode }}</pre>\n * </wr-compare>\n * ```\n *\n * Under `dir=\"rtl\"` the horizontal wipe MIRRORS: \"before\" occupies the inline-start\n * side, which is the right. Before/after is an ordinal pair — the two ends of a\n * progression — and ordinal progressions follow reading order, the same reason a\n * progress bar fills from the right in Arabic. The LTR habit of putting \"before\" on\n * the left IS reading order, so mirroring preserves that intent rather than breaking\n * it. Nothing is flipped pixel-wise: both layers are the images the consumer passed,\n * unscaled and unmirrored — only the side each is revealed on changes.\n *\n * Pinning the physical arrangement inside an RTL page takes the CDK's `Dir` directive\n * (`[dir]`, from `@angular/cdk/bidi`) on a wrapper, because that is what provides a\n * scoped `Directionality`. A bare `dir=\"ltr\"` attribute does NOT do it: the ambient\n * `Directionality` reads `<html>` / `<body>` once at startup and never looks at the\n * element, and this component's horizontal wipe is painted entirely from TypeScript,\n * so the attribute would change nothing at all while looking like an opt-out.\n *\n * @see https://ngwr.dev/reference/components/compare\n */\n@Component({\n selector: 'wr-compare',\n templateUrl: './compare.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-compare', '[class]': 'classes()' },\n})\nexport class WrCompare {\n /** Divider position as a percentage (0–100). Two-way bindable. @default 50 */\n readonly position = model(50);\n\n /** Accessible name of the divider. Falls back to `compare.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'compare.label', 'Comparison divider');\n\n /**\n * Divider direction:\n * - `'horizontal'` — divider line is vertical, drags left/right.\n * - `'vertical'` — divider line is horizontal, drags up/down.\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Show the round drag handle on the divider. @default true */\n readonly showHandle = input(true, { transform: coerceBooleanProperty });\n\n /** Disable interaction (divider stays put). @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Lowest position the divider may reach, in percent. @default 0 */\n readonly minPosition = input(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Highest position the divider may reach, in percent. @default 100 */\n readonly maxPosition = input(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n // Optional on purpose: `Directionality` is root-provided, so a consumer never has to\n // supply it — and a bare `TestBed` does not either.\n private readonly dir = inject(Directionality, { optional: true });\n\n /**\n * Reading direction as a signal, because unlike the splitter this component PAINTS\n * from it: the clip and the divider offset are both direction-derived, and\n * `Directionality.value` is an ordinary read. A `dir` flip at runtime would otherwise\n * leave the wipe on the side the page no longer uses until some unrelated position\n * change happened to recompute it.\n */\n private readonly rtl = signal(this.dir?.value === 'rtl');\n\n private dragging = false;\n\n /** Where the divider was when the live drag began — see `onPointerCancel`. */\n private dragStart = 0;\n\n /**\n * `aria-valuenow`, in whole percent. A drag sets `position` to wherever the\n * pointer fell, and a reader announced all of it: `29.99999788072374`.\n */\n protected readonly valueNow = computed(() =>\n wrClamp(Math.round(this.position()), this.minPosition(), this.maxPosition())\n );\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('compare');\n this.dir?.change.pipe(takeUntilDestroyed()).subscribe(value => this.rtl.set(value === 'rtl'));\n\n // `position` is a `model`, so `[(position)]` and a restored layout write into it\n // directly while only the handlers clamped — an out-of-range write reached the DOM\n // as `aria-valuenow=\"150\"` against a `valuemax` of 100.\n effect(() => {\n const clamped = wrClamp(this.position(), this.minPosition(), this.maxPosition());\n if (clamped !== this.position()) this.position.set(clamped);\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = [`wr-compare--${this.orientation()}`];\n if (this.disabled()) parts.push('wr-compare--disabled');\n return parts.join(' ');\n });\n\n /**\n * Clip path applied to the \"after\" layer so the divider reveals it.\n *\n * `inset()` takes PHYSICAL edges and has no logical form, so the mirroring is done\n * here rather than in CSS: `position` counts from the inline-start edge, and under\n * RTL that edge is the right one, so the after layer is clipped from the right by\n * the same percentage.\n */\n protected readonly clipPath = computed(() => {\n const p = wrClamp(this.position(), 0, 100);\n if (this.orientation() === 'horizontal') {\n // Show from `p%` to the inline-end edge.\n return this.rtl() ? `inset(0 ${p}% 0 0)` : `inset(0 0 0 ${p}%)`;\n }\n // Block axis: `dir` does not touch it.\n return `inset(${p}% 0 0 0)`;\n });\n\n /**\n * Physical `left` percentage of the divider. Deliberately physical: it pairs with the\n * `translateX(-50%)` that centres the 2px line on its own position, and the two have\n * to agree on which edge they count from. `position` is logical, so RTL flips it here.\n */\n protected readonly dividerLeft = computed(() => (this.rtl() ? 100 - this.position() : this.position()));\n\n // Pointer handlers\n\n protected onPointerDown(event: PointerEvent): void {\n if (this.disabled()) return;\n // Any pointerdown used to start a drag, so the right button moved the divider; the\n // same guard keeps a second finger out of a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n this.dragging = true;\n this.dragStart = this.position();\n const surface = event.currentTarget as HTMLElement;\n surface.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the click's default focus, so the arrows\n // did nothing after a mouse drag until the divider was found again with Tab.\n surface.focus();\n // A touch may still turn out to be a scroll along the other axis, which the\n // browser takes over with `pointercancel`, so it moves the divider from its first\n // move (or a tap's lift) rather than jumping it to where the finger came down.\n if (event.pointerType !== 'touch') this.updateFromPointer(event);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n this.updateFromPointer(event);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n // A tap: the touch that never moved still sets the position where it lifted.\n if (event.pointerType === 'touch') this.updateFromPointer(event);\n this.dragging = false;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n }\n\n /**\n * The browser took the gesture over — a scroll along the axis `touch-action` leaves\n * to the page — so the drag never happened, and the divider goes back to where it\n * was rather than keeping whatever the first moves of a swipe said.\n */\n protected onPointerCancel(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n this.position.set(this.dragStart);\n const surface = event.currentTarget as HTMLElement;\n if (surface.hasPointerCapture(event.pointerId)) surface.releasePointerCapture(event.pointerId);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n const step = event.shiftKey ? 10 : 1;\n // Steps count from the whole percent a reader was told, so a key after a drag\n // lands on a round number instead of carrying the drag's fraction along.\n const from = this.valueNow();\n let next: number | null = null;\n if (this.orientation() === 'horizontal') {\n // Arrows follow the VISUAL axis (WAI-ARIA APG). Under `dir=\"rtl\"` the \"before\"\n // side grows from the right, so the visual right is the low end of this slider's\n // range and ArrowRight has to decrease the value.\n const inline = this.rtl() ? -step : step;\n if (event.key === 'ArrowLeft') next = from - inline;\n else if (event.key === 'ArrowRight') next = from + inline;\n } else {\n // Block axis: unaffected by `dir`.\n if (event.key === 'ArrowUp') next = from - step;\n else if (event.key === 'ArrowDown') next = from + step;\n }\n // Home/End are semantic — first/last, not left/right — so they never mirror.\n if (event.key === 'Home') next = this.minPosition();\n else if (event.key === 'End') next = this.maxPosition();\n if (next === null) return;\n event.preventDefault();\n this.position.set(wrClamp(next, this.minPosition(), this.maxPosition()));\n }\n\n private updateFromPointer(event: PointerEvent): void {\n const rect = this.host.nativeElement.getBoundingClientRect();\n const horizontal = this.orientation() === 'horizontal';\n const extent = horizontal ? rect.width : rect.height;\n // A host that has not been laid out — hidden, detached, or a pane the browser has\n // throttled — measures 0, and dividing by it puts `Infinity` or `NaN` straight into\n // `aria-valuenow`. There is no meaningful position to compute, so keep the current one.\n if (extent <= 0) return;\n const raw = horizontal\n ? this.inlineFraction(event.clientX, rect) * 100\n : ((event.clientY - rect.top) / extent) * 100;\n this.position.set(wrClamp(raw, this.minPosition(), this.maxPosition()));\n }\n\n /**\n * Fraction of the host measured from the INLINE-START edge — the left edge in LTR, the\n * right edge in RTL, which is the side \"before\" is revealed from. Taken from\n * `rect.left` in both, a drag under `dir=\"rtl\"` read 0 at the visual maximum and moved\n * the divider opposite the pointer.\n */\n private inlineFraction(clientX: number, rect: DOMRect): number {\n return this.rtl() ? (rect.right - clientX) / rect.width : (clientX - rect.left) / rect.width;\n }\n}\n","<div\n class=\"wr-compare__surface\"\n role=\"slider\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-valuemin]=\"minPosition()\"\n [attr.aria-valuemax]=\"maxPosition()\"\n [attr.aria-valuenow]=\"valueNow()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerCancel($event)\"\n (keydown)=\"onKeydown($event)\"\n>\n <div class=\"wr-compare__layers\">\n <div class=\"wr-compare__layer wr-compare__layer--before\">\n <ng-content select=\"[wrCompareBefore]\" />\n </div>\n <div class=\"wr-compare__layer wr-compare__layer--after\" [style.clip-path]=\"clipPath()\">\n <ng-content select=\"[wrCompareAfter]\" />\n </div>\n </div>\n\n <div\n class=\"wr-compare__divider\"\n [style.left.%]=\"orientation() === 'horizontal' ? dividerLeft() : null\"\n [style.top.%]=\"orientation() === 'vertical' ? position() : null\"\n aria-hidden=\"true\"\n >\n @if (showHandle()) {\n <span class=\"wr-compare__handle\">\n @if (orientation() === 'horizontal') {\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path\n d=\"M5 4 L1 8 L5 12 M11 4 L15 8 L11 12\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n } @else {\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path\n d=\"M4 5 L8 1 L12 5 M4 11 L8 15 L12 11\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n }\n </span>\n }\n </div>\n</div>\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,YAAb,MAAa,UAAS;CAEX,WAAW,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAGpB,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,iBAAiB,oBAAoB;CAQ/F,cAAc,MAAiC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAG5D,aAAa,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAG3D,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAG1D,cAAc,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAGtF,cAAc,MAAM,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAElF,OAAO,OAAgC,UAAU;CAGjD,MAAM,OAAO,gBAAgB,EAAE,UAAU,KAAI,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AAA;IAAA,mBAAA;GAAA;GAAA,UAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,iBAAA;EAAA,MAAA;GAAA,YAAA,EAAA,SAAA,YAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UCnEtB;EA4DA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADOa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EANrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAc,WAAW;GAAW;GAAE,UAAA;EAAA,CAAA"}
1
+ {"version":3,"file":"ngwr-compare.mjs","names":[],"sources":["../../../projects/lib/compare/compare.ts","../../../projects/lib/compare/compare.html"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directionality } from '@angular/cdk/bidi';\nimport { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n model,\n signal,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrClamp, wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Before/after comparison slider. Works with any content — project two\n * pieces of markup with `wrCompareBefore` and `wrCompareAfter` attributes;\n * the component stacks them in the same cell and clips the \"after\" side\n * with a draggable divider.\n *\n * @example\n * ```html\n * <wr-compare [(position)]=\"pos\">\n * <img wrCompareBefore src=\"before.jpg\" alt=\"\" />\n * <img wrCompareAfter src=\"after.jpg\" alt=\"\" />\n * </wr-compare>\n *\n * <wr-compare orientation=\"vertical\">\n * <pre wrCompareBefore>{{ oldCode }}</pre>\n * <pre wrCompareAfter>{{ newCode }}</pre>\n * </wr-compare>\n * ```\n *\n * Under `dir=\"rtl\"` the horizontal wipe MIRRORS: \"before\" occupies the inline-start\n * side, which is the right. Before/after is an ordinal pair — the two ends of a\n * progression — and ordinal progressions follow reading order, the same reason a\n * progress bar fills from the right in Arabic. The LTR habit of putting \"before\" on\n * the left IS reading order, so mirroring preserves that intent rather than breaking\n * it. Nothing is flipped pixel-wise: both layers are the images the consumer passed,\n * unscaled and unmirrored — only the side each is revealed on changes.\n *\n * Pinning the physical arrangement inside an RTL page takes the CDK's `Dir` directive\n * (`[dir]`, from `@angular/cdk/bidi`) on a wrapper, because that is what provides a\n * scoped `Directionality`. A bare `dir=\"ltr\"` attribute does NOT do it: the ambient\n * `Directionality` reads `<html>` / `<body>` once at startup and never looks at the\n * element, and this component's horizontal wipe is painted entirely from TypeScript,\n * so the attribute would change nothing at all while looking like an opt-out.\n *\n * @see https://ngwr.dev/reference/components/compare\n */\n@Component({\n selector: 'wr-compare',\n templateUrl: './compare.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-compare', '[class]': 'classes()' },\n})\nexport class WrCompare {\n /** Divider position as a percentage (0–100). Two-way bindable. @default 50 */\n readonly position = model(50);\n\n /** Accessible name of the divider. Falls back to `compare.label`. */\n readonly ariaLabel = input<string | null>(null);\n\n protected readonly resolvedAriaLabel = useI18nText(this.ariaLabel, 'compare.label', 'Comparison divider');\n\n /**\n * Divider direction:\n * - `'horizontal'` — divider line is vertical, drags left/right.\n * - `'vertical'` — divider line is horizontal, drags up/down.\n * @default 'horizontal'\n */\n readonly orientation = input<'horizontal' | 'vertical'>('horizontal');\n\n /** Show the round drag handle on the divider. @default true */\n readonly showHandle = input(true, { transform: coerceBooleanProperty });\n\n /** Disable interaction (divider stays put). @default false */\n readonly disabled = input(false, { transform: coerceBooleanProperty });\n\n /** Lowest position the divider may reach, in percent. @default 0 */\n readonly minPosition = input(0, { transform: (v: unknown): number => coerceNumberProperty(v, 0) });\n\n /** Highest position the divider may reach, in percent. @default 100 */\n readonly maxPosition = input(100, { transform: (v: unknown): number => coerceNumberProperty(v, 100) });\n\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n // Optional on purpose: `Directionality` is root-provided, so a consumer never has to\n // supply it — and a bare `TestBed` does not either.\n private readonly dir = inject(Directionality, { optional: true });\n\n /**\n * Reading direction as a signal, because unlike the splitter this component PAINTS\n * from it: the clip and the divider offset are both direction-derived, and\n * `Directionality.value` is an ordinary read. A `dir` flip at runtime would otherwise\n * leave the wipe on the side the page no longer uses until some unrelated position\n * change happened to recompute it.\n */\n private readonly rtl = signal(this.dir?.value === 'rtl');\n\n private dragging = false;\n\n /** Where the divider was when the live drag began — see `onPointerCancel`. */\n private dragStart = 0;\n\n /**\n * `aria-valuenow`, in whole percent. A drag sets `position` to wherever the\n * pointer fell, and a reader announced all of it: `29.99999788072374`.\n */\n protected readonly valueNow = computed(() =>\n wrClamp(Math.round(this.position()), this.minPosition(), this.maxPosition())\n );\n\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('compare');\n this.dir?.change.pipe(takeUntilDestroyed()).subscribe(value => this.rtl.set(value === 'rtl'));\n\n // `position` is a `model`, so `[(position)]` and a restored layout write into it\n // directly while only the handlers clamped — an out-of-range write reached the DOM\n // as `aria-valuenow=\"150\"` against a `valuemax` of 100.\n effect(() => {\n const clamped = wrClamp(this.position(), this.minPosition(), this.maxPosition());\n if (clamped !== this.position()) this.position.set(clamped);\n });\n }\n\n protected readonly classes = computed(() => {\n const parts = [`wr-compare--${this.orientation()}`];\n if (this.disabled()) parts.push('wr-compare--disabled');\n return parts.join(' ');\n });\n\n /**\n * Clip path applied to the \"after\" layer so the divider reveals it.\n *\n * `inset()` takes PHYSICAL edges and has no logical form, so the mirroring is done\n * here rather than in CSS: `position` counts from the inline-start edge, and under\n * RTL that edge is the right one, so the after layer is clipped from the right by\n * the same percentage.\n */\n protected readonly clipPath = computed(() => {\n const p = wrClamp(this.position(), 0, 100);\n if (this.orientation() === 'horizontal') {\n // Show from `p%` to the inline-end edge.\n return this.rtl() ? `inset(0 ${p}% 0 0)` : `inset(0 0 0 ${p}%)`;\n }\n // Block axis: `dir` does not touch it.\n return `inset(${p}% 0 0 0)`;\n });\n\n /**\n * Physical `left` percentage of the divider. Deliberately physical: it pairs with the\n * `translateX(-50%)` that centres the 2px line on its own position, and the two have\n * to agree on which edge they count from. `position` is logical, so RTL flips it here.\n */\n protected readonly dividerLeft = computed(() => (this.rtl() ? 100 - this.position() : this.position()));\n\n // Pointer handlers\n\n protected onPointerDown(event: PointerEvent): void {\n if (this.disabled()) return;\n // Any pointerdown used to start a drag, so the right button moved the divider; the\n // same guard keeps a second finger out of a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n this.dragging = true;\n this.dragStart = this.position();\n const surface = event.currentTarget as HTMLElement;\n surface.setPointerCapture(event.pointerId);\n // `preventDefault` above also suppresses the click's default focus, so the arrows\n // did nothing after a mouse drag until the divider was found again with Tab.\n surface.focus();\n // A touch may still turn out to be a scroll along the other axis, which the\n // browser takes over with `pointercancel`, so it moves the divider from its first\n // move (or a tap's lift) rather than jumping it to where the finger came down.\n if (event.pointerType !== 'touch') this.updateFromPointer(event);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.dragging) return;\n // Turned disabled mid-drag: the gesture is over.\n if (this.disabled()) {\n this.dragging = false;\n return;\n }\n this.updateFromPointer(event);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.dragging) return;\n // A tap: the touch that never moved still sets the position where it lifted.\n if (event.pointerType === 'touch') this.updateFromPointer(event);\n this.dragging = false;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n }\n\n /**\n * The browser took the gesture over — a scroll along the axis `touch-action` leaves\n * to the page — so the drag never happened, and the divider goes back to where it\n * was rather than keeping whatever the first moves of a swipe said.\n */\n protected onPointerCancel(event: PointerEvent): void {\n if (!this.dragging) return;\n this.dragging = false;\n this.position.set(this.dragStart);\n const surface = event.currentTarget as HTMLElement;\n if (surface.hasPointerCapture(event.pointerId)) surface.releasePointerCapture(event.pointerId);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.disabled()) return;\n const step = event.shiftKey ? 10 : 1;\n // Steps count from the whole percent a reader was told, so a key after a drag\n // lands on a round number instead of carrying the drag's fraction along.\n const from = this.valueNow();\n let next: number | null = null;\n if (this.orientation() === 'horizontal') {\n // Arrows follow the VISUAL axis (WAI-ARIA APG). Under `dir=\"rtl\"` the \"before\"\n // side grows from the right, so the visual right is the low end of this slider's\n // range and ArrowRight has to decrease the value.\n const inline = this.rtl() ? -step : step;\n if (event.key === 'ArrowLeft') next = from - inline;\n else if (event.key === 'ArrowRight') next = from + inline;\n } else {\n // Block axis: unaffected by `dir`.\n if (event.key === 'ArrowUp') next = from - step;\n else if (event.key === 'ArrowDown') next = from + step;\n }\n // Home/End are semantic — first/last, not left/right — so they never mirror.\n if (event.key === 'Home') next = this.minPosition();\n else if (event.key === 'End') next = this.maxPosition();\n if (next === null) return;\n event.preventDefault();\n this.position.set(wrClamp(next, this.minPosition(), this.maxPosition()));\n }\n\n private updateFromPointer(event: PointerEvent): void {\n const rect = this.host.nativeElement.getBoundingClientRect();\n const horizontal = this.orientation() === 'horizontal';\n const extent = horizontal ? rect.width : rect.height;\n // A host that has not been laid out — hidden, detached, or a pane the browser has\n // throttled — measures 0, and dividing by it puts `Infinity` or `NaN` straight into\n // `aria-valuenow`. There is no meaningful position to compute, so keep the current one.\n if (extent <= 0) return;\n const raw = horizontal\n ? this.inlineFraction(event.clientX, rect) * 100\n : ((event.clientY - rect.top) / extent) * 100;\n this.position.set(wrClamp(raw, this.minPosition(), this.maxPosition()));\n }\n\n /**\n * Fraction of the host measured from the INLINE-START edge — the left edge in LTR, the\n * right edge in RTL, which is the side \"before\" is revealed from. Taken from\n * `rect.left` in both, a drag under `dir=\"rtl\"` read 0 at the visual maximum and moved\n * the divider opposite the pointer.\n */\n private inlineFraction(clientX: number, rect: DOMRect): number {\n return this.rtl() ? (rect.right - clientX) / rect.width : (clientX - rect.left) / rect.width;\n }\n}\n","<div\n class=\"wr-compare__surface\"\n role=\"slider\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n [attr.aria-orientation]=\"orientation()\"\n [attr.aria-valuemin]=\"minPosition()\"\n [attr.aria-valuemax]=\"maxPosition()\"\n [attr.aria-valuenow]=\"valueNow()\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.tabindex]=\"disabled() ? -1 : 0\"\n (pointerdown)=\"onPointerDown($event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerCancel($event)\"\n (keydown)=\"onKeydown($event)\"\n>\n <div class=\"wr-compare__layers\">\n <div class=\"wr-compare__layer wr-compare__layer--before\">\n <ng-content select=\"[wrCompareBefore]\" />\n </div>\n <div class=\"wr-compare__layer wr-compare__layer--after\" [style.clip-path]=\"clipPath()\">\n <ng-content select=\"[wrCompareAfter]\" />\n </div>\n </div>\n\n <div\n class=\"wr-compare__divider\"\n [style.left.%]=\"orientation() === 'horizontal' ? dividerLeft() : null\"\n [style.top.%]=\"orientation() === 'vertical' ? position() : null\"\n aria-hidden=\"true\"\n >\n @if (showHandle()) {\n <span class=\"wr-compare__handle\">\n @if (orientation() === 'horizontal') {\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path\n d=\"M5 4 L1 8 L5 12 M11 4 L15 8 L11 12\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n } @else {\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" aria-hidden=\"true\">\n <path\n d=\"M4 5 L8 1 L12 5 M4 11 L8 15 L12 11\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"1.5\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n }\n </span>\n }\n </div>\n</div>\n"],"mappings":";;;;;;;;;;;;;AAmEA,IAAa,YAAb,MAAa,UAAS;CAEX,WAAW,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAGpB,YAAY,MAAqB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAE5B,oBAAoB,YAAY,KAAK,WAAW,iBAAiB,oBAAoB;CAQ/F,cAAc,MAAiC,cAAa,GAAA,YAAA,CAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAG5D,aAAa,MAAM,MAAI;EAAA,GAAA,YAAA,EAAA,WAAA,aAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAG3D,WAAW,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,WAAA,+BAAA,CAAA;EAAI,WAAW;CAAqB,CAAA;CAG1D,cAAc,MAAM,GAAC;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,CAAC;CAAC,CAAA;CAGtF,cAAc,MAAM,KAAG;EAAA,GAAA,YAAA,EAAA,WAAA,cAAA,+BAAA,CAAA;EAAI,YAAY,MAAuB,qBAAqB,GAAG,GAAG;CAAC,CAAA;CAElF,OAAO,OAAgC,UAAU;CAGjD,MAAM,OAAO,gBAAgB,EAAE,UAAU,KAAI,CAAE;CAS/C,MAAM,OAAO,KAAK,KAAK,UAAU,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,MAAA,CAAA,+BAA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;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,aAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA,EAAA,UAAA,iBAAA;EAAA,MAAA;GAAA,YAAA,EAAA,SAAA,YAAA;GAAA,gBAAA;EAAA;EAAA,UAAA;EAAA,UCnEtB;EA4DA,eAAA,GAAA,kBAAA;CAAA,CAAA;;ADOa,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EANrB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAY,eAEP,kBAAkB;GAAI,MAC/B;IAAE,OAAO;IAAc,WAAW;GAAW;GAAE,UAAA;EAAA,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import * as i0 from "@angular/core";
2
2
  import { Component, DestroyRef, Directive, ElementRef, Injector, TemplateRef, ViewContainerRef, ViewEncapsulation, computed, inject, input, signal, viewChild } from "@angular/core";
3
3
  import { coerceBooleanProperty } from "@angular/cdk/coercion";
4
- import { WR_LIVE_LOCALE, wrCheckStyles, wrNoteFocusReturn, wrRandomId, wrRestoreFocus, wrToClassList, wrTypeahead } from "ngwr/utils";
4
+ import { WR_LIVE_LOCALE, wrCheckStyles, wrIsComposing, wrNoteFocusReturn, wrRandomId, wrRestoreFocus, wrToClassList, wrTypeahead } from "ngwr/utils";
5
5
  import { WrIcon } from "ngwr/icon";
6
6
  import { Directionality } from "@angular/cdk/bidi";
7
7
  import { ScrollStrategyOptions } from "@angular/cdk/overlay";
@@ -227,8 +227,12 @@ var WrContextMenuItem = class WrContextMenuItem {
227
227
  }
228
228
  onSubmenuKeydown(event) {
229
229
  const pane = this.submenuRef?.overlayElement;
230
- if (!pane) return;
230
+ if (!pane || wrIsComposing(event)) return;
231
231
  if (event.defaultPrevented) return;
232
+ if (event.key === "Tab") {
233
+ WrContextMenu.closeActive();
234
+ return;
235
+ }
232
236
  const active = document.activeElement;
233
237
  const focusedPane = active instanceof Element ? active.closest(".wr-context-menu-overlay") : null;
234
238
  const back = this.isRtl() ? "ArrowRight" : "ArrowLeft";
@@ -624,6 +628,7 @@ var WrContextMenu = class WrContextMenu {
624
628
  this.closeOverlay();
625
629
  });
626
630
  this.rootKeys = this.overlayRef.keydownEvents().pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
631
+ if (wrIsComposing(event)) return;
627
632
  if (event.key === "Escape") {
628
633
  event.preventDefault();
629
634
  this.closeOverlay();