ngwr 11.0.0 → 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/action-sheet/styles/_index.scss +4 -1
  2. package/anchor/styles/_index.scss +2 -1
  3. package/calendar/styles/_index.scss +11 -2
  4. package/cascader/styles/_index.scss +3 -1
  5. package/circular-text/styles/_index.scss +11 -0
  6. package/command-palette/styles/_index.scss +14 -1
  7. package/context-menu/styles/_index.scss +2 -1
  8. package/falling-text/styles/_index.scss +2 -1
  9. package/fesm2022/ngwr-action-sheet-testing.mjs +313 -0
  10. package/fesm2022/ngwr-action-sheet-testing.mjs.map +1 -0
  11. package/fesm2022/ngwr-bar-chart-testing.mjs +89 -0
  12. package/fesm2022/ngwr-bar-chart-testing.mjs.map +1 -0
  13. package/fesm2022/ngwr-blur-text-testing.mjs +203 -0
  14. package/fesm2022/ngwr-blur-text-testing.mjs.map +1 -0
  15. package/fesm2022/ngwr-blur-text.mjs +15 -1
  16. package/fesm2022/ngwr-blur-text.mjs.map +1 -1
  17. package/fesm2022/ngwr-border-glow-testing.mjs +325 -0
  18. package/fesm2022/ngwr-border-glow-testing.mjs.map +1 -0
  19. package/fesm2022/ngwr-border-glow.mjs +2 -2
  20. package/fesm2022/ngwr-breadcrumbs.mjs +2 -2
  21. package/fesm2022/ngwr-calendar-heatmap-testing.mjs +95 -0
  22. package/fesm2022/ngwr-calendar-heatmap-testing.mjs.map +1 -0
  23. package/fesm2022/ngwr-calendar-testing.mjs +368 -0
  24. package/fesm2022/ngwr-calendar-testing.mjs.map +1 -0
  25. package/fesm2022/ngwr-calendar.mjs +43 -3
  26. package/fesm2022/ngwr-calendar.mjs.map +1 -1
  27. package/fesm2022/ngwr-card.mjs +2 -2
  28. package/fesm2022/ngwr-cascader.mjs +14 -2
  29. package/fesm2022/ngwr-cascader.mjs.map +1 -1
  30. package/fesm2022/ngwr-checkbox.mjs +8 -0
  31. package/fesm2022/ngwr-checkbox.mjs.map +1 -1
  32. package/fesm2022/ngwr-circular-text-testing.mjs +230 -0
  33. package/fesm2022/ngwr-circular-text-testing.mjs.map +1 -0
  34. package/fesm2022/ngwr-circular-text.mjs +2 -2
  35. package/fesm2022/ngwr-circular-text.mjs.map +1 -1
  36. package/fesm2022/ngwr-color-picker-testing.mjs +432 -0
  37. package/fesm2022/ngwr-color-picker-testing.mjs.map +1 -0
  38. package/fesm2022/ngwr-color-picker.mjs +29 -3
  39. package/fesm2022/ngwr-color-picker.mjs.map +1 -1
  40. package/fesm2022/ngwr-context-menu.mjs +25 -5
  41. package/fesm2022/ngwr-context-menu.mjs.map +1 -1
  42. package/fesm2022/ngwr-date-picker-testing.mjs +10 -79
  43. package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
  44. package/fesm2022/ngwr-decrypt-text-testing.mjs +261 -0
  45. package/fesm2022/ngwr-decrypt-text-testing.mjs.map +1 -0
  46. package/fesm2022/ngwr-decrypt-text.mjs +6 -1
  47. package/fesm2022/ngwr-decrypt-text.mjs.map +1 -1
  48. package/fesm2022/ngwr-donut-chart-testing.mjs +93 -0
  49. package/fesm2022/ngwr-donut-chart-testing.mjs.map +1 -0
  50. package/fesm2022/ngwr-drag-drop.mjs +2 -2
  51. package/fesm2022/ngwr-drawer.mjs +36 -7
  52. package/fesm2022/ngwr-drawer.mjs.map +1 -1
  53. package/fesm2022/ngwr-dropdown.mjs +32 -2
  54. package/fesm2022/ngwr-dropdown.mjs.map +1 -1
  55. package/fesm2022/ngwr-event-calendar-testing.mjs +446 -0
  56. package/fesm2022/ngwr-event-calendar-testing.mjs.map +1 -0
  57. package/fesm2022/ngwr-event-calendar.mjs +43 -18
  58. package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
  59. package/fesm2022/ngwr-falling-text-testing.mjs +218 -0
  60. package/fesm2022/ngwr-falling-text-testing.mjs.map +1 -0
  61. package/fesm2022/ngwr-falling-text.mjs +2 -2
  62. package/fesm2022/ngwr-falling-text.mjs.map +1 -1
  63. package/fesm2022/ngwr-fuzzy-text-testing.mjs +134 -0
  64. package/fesm2022/ngwr-fuzzy-text-testing.mjs.map +1 -0
  65. package/fesm2022/ngwr-gauge-testing.mjs +86 -0
  66. package/fesm2022/ngwr-gauge-testing.mjs.map +1 -0
  67. package/fesm2022/ngwr-glitch-text-testing.mjs +181 -0
  68. package/fesm2022/ngwr-glitch-text-testing.mjs.map +1 -0
  69. package/fesm2022/ngwr-glitch-text.mjs +2 -2
  70. package/fesm2022/ngwr-gradient-text-testing.mjs +223 -0
  71. package/fesm2022/ngwr-gradient-text-testing.mjs.map +1 -0
  72. package/fesm2022/ngwr-gradient-text.mjs +2 -2
  73. package/fesm2022/ngwr-i18n-en.mjs +14 -0
  74. package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
  75. package/fesm2022/ngwr-i18n-ru.mjs +14 -0
  76. package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
  77. package/fesm2022/ngwr-image-cropper-testing.mjs +156 -0
  78. package/fesm2022/ngwr-image-cropper-testing.mjs.map +1 -0
  79. package/fesm2022/ngwr-image-cropper.mjs +10 -3
  80. package/fesm2022/ngwr-image-cropper.mjs.map +1 -1
  81. package/fesm2022/ngwr-input-number.mjs +73 -6
  82. package/fesm2022/ngwr-input-number.mjs.map +1 -1
  83. package/fesm2022/ngwr-knob-testing.mjs +220 -0
  84. package/fesm2022/ngwr-knob-testing.mjs.map +1 -0
  85. package/fesm2022/ngwr-lightbox-testing.mjs +223 -0
  86. package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -0
  87. package/fesm2022/ngwr-lightbox.mjs +9 -2
  88. package/fesm2022/ngwr-lightbox.mjs.map +1 -1
  89. package/fesm2022/ngwr-line-chart-testing.mjs +119 -0
  90. package/fesm2022/ngwr-line-chart-testing.mjs.map +1 -0
  91. package/fesm2022/ngwr-list.mjs +2 -2
  92. package/fesm2022/ngwr-loading-bar.mjs +2 -2
  93. package/fesm2022/ngwr-marquee-testing.mjs +336 -0
  94. package/fesm2022/ngwr-marquee-testing.mjs.map +1 -0
  95. package/fesm2022/ngwr-marquee.mjs +2 -2
  96. package/fesm2022/ngwr-meter-group-testing.mjs +80 -0
  97. package/fesm2022/ngwr-meter-group-testing.mjs.map +1 -0
  98. package/fesm2022/ngwr-overlay.mjs +28 -1
  99. package/fesm2022/ngwr-overlay.mjs.map +1 -1
  100. package/fesm2022/ngwr-popover.mjs +14 -0
  101. package/fesm2022/ngwr-popover.mjs.map +1 -1
  102. package/fesm2022/ngwr-rotating-text-testing.mjs +220 -0
  103. package/fesm2022/ngwr-rotating-text-testing.mjs.map +1 -0
  104. package/fesm2022/ngwr-rotating-text.mjs +2 -2
  105. package/fesm2022/ngwr-rotating-text.mjs.map +1 -1
  106. package/fesm2022/ngwr-select.mjs +70 -11
  107. package/fesm2022/ngwr-select.mjs.map +1 -1
  108. package/fesm2022/ngwr-shiny-text-testing.mjs +237 -0
  109. package/fesm2022/ngwr-shiny-text-testing.mjs.map +1 -0
  110. package/fesm2022/ngwr-shiny-text.mjs +2 -2
  111. package/fesm2022/ngwr-slider.mjs +44 -6
  112. package/fesm2022/ngwr-slider.mjs.map +1 -1
  113. package/fesm2022/ngwr-sparkline-testing.mjs +76 -0
  114. package/fesm2022/ngwr-sparkline-testing.mjs.map +1 -0
  115. package/fesm2022/ngwr-speed-dial-testing.mjs +279 -0
  116. package/fesm2022/ngwr-speed-dial-testing.mjs.map +1 -0
  117. package/fesm2022/ngwr-splash-cursor-testing.mjs +89 -0
  118. package/fesm2022/ngwr-splash-cursor-testing.mjs.map +1 -0
  119. package/fesm2022/ngwr-split-text-testing.mjs +224 -0
  120. package/fesm2022/ngwr-split-text-testing.mjs.map +1 -0
  121. package/fesm2022/ngwr-split-text.mjs +15 -1
  122. package/fesm2022/ngwr-split-text.mjs.map +1 -1
  123. package/fesm2022/ngwr-splitter-testing.mjs +245 -0
  124. package/fesm2022/ngwr-splitter-testing.mjs.map +1 -0
  125. package/fesm2022/ngwr-spotlight-card-testing.mjs +368 -0
  126. package/fesm2022/ngwr-spotlight-card-testing.mjs.map +1 -0
  127. package/fesm2022/ngwr-spotlight-card.mjs +2 -2
  128. package/fesm2022/ngwr-star-border-testing.mjs +172 -0
  129. package/fesm2022/ngwr-star-border-testing.mjs.map +1 -0
  130. package/fesm2022/ngwr-star-border.mjs +2 -2
  131. package/fesm2022/ngwr-table.mjs +13 -3
  132. package/fesm2022/ngwr-table.mjs.map +1 -1
  133. package/fesm2022/ngwr-tabs.mjs +15 -1
  134. package/fesm2022/ngwr-tabs.mjs.map +1 -1
  135. package/fesm2022/ngwr-tilt-card-testing.mjs +190 -0
  136. package/fesm2022/ngwr-tilt-card-testing.mjs.map +1 -0
  137. package/fesm2022/ngwr-tilt-card.mjs +21 -3
  138. package/fesm2022/ngwr-tilt-card.mjs.map +1 -1
  139. package/fesm2022/ngwr-toast.mjs +36 -7
  140. package/fesm2022/ngwr-toast.mjs.map +1 -1
  141. package/fesm2022/ngwr-tour-testing.mjs +173 -0
  142. package/fesm2022/ngwr-tour-testing.mjs.map +1 -0
  143. package/fesm2022/ngwr-tour.mjs +2 -2
  144. package/fesm2022/ngwr-tour.mjs.map +1 -1
  145. package/fesm2022/ngwr-tree.mjs +10 -3
  146. package/fesm2022/ngwr-tree.mjs.map +1 -1
  147. package/fesm2022/ngwr-typewriter-testing.mjs +228 -0
  148. package/fesm2022/ngwr-typewriter-testing.mjs.map +1 -0
  149. package/fesm2022/ngwr-typewriter.mjs +2 -2
  150. package/fesm2022/ngwr-version.mjs +1 -1
  151. package/fesm2022/ngwr-version.mjs.map +1 -1
  152. package/fesm2022/ngwr-virtual-scroll.mjs +2 -2
  153. package/fesm2022/ngwr-waves-testing.mjs +128 -0
  154. package/fesm2022/ngwr-waves-testing.mjs.map +1 -0
  155. package/fesm2022/ngwr-waves.mjs +2 -2
  156. package/fesm2022/ngwr-window-testing.mjs +361 -0
  157. package/fesm2022/ngwr-window-testing.mjs.map +1 -0
  158. package/fesm2022/ngwr-window.mjs +84 -10
  159. package/fesm2022/ngwr-window.mjs.map +1 -1
  160. package/file-upload/styles/_index.scss +7 -2
  161. package/i18n/en.json +16 -2
  162. package/i18n/ru.json +16 -2
  163. package/llms-full.txt +147 -0
  164. package/llms.txt +27 -8
  165. package/mcp/providers.js +29 -0
  166. package/mcp/tools.js +1 -29
  167. package/package.json +145 -1
  168. package/result/styles/_index.scss +3 -1
  169. package/segmented/styles/_index.scss +5 -1
  170. package/select/styles/_index.scss +3 -1
  171. package/skills/ngwr/SKILL.md +115 -0
  172. package/skills/ngwr/references/catalog.md +212 -0
  173. package/skills/ngwr/references/setup.md +73 -0
  174. package/stepper/styles/_index.scss +18 -2
  175. package/table/styles/_index.scss +3 -1
  176. package/theme/styles/_colors.scss +15 -2
  177. package/theme/styles/_dark.scss +24 -12
  178. package/tree/styles/_index.scss +4 -2
  179. package/types/ngwr-action-sheet-testing.d.ts +260 -0
  180. package/types/ngwr-bar-chart-testing.d.ts +77 -0
  181. package/types/ngwr-blur-text-testing.d.ts +180 -0
  182. package/types/ngwr-blur-text.d.ts +12 -0
  183. package/types/ngwr-border-glow-testing.d.ts +219 -0
  184. package/types/ngwr-calendar-heatmap-testing.d.ts +79 -0
  185. package/types/ngwr-calendar-testing.d.ts +277 -0
  186. package/types/ngwr-calendar.d.ts +10 -0
  187. package/types/ngwr-checkbox.d.ts +13 -0
  188. package/types/ngwr-circular-text-testing.d.ts +196 -0
  189. package/types/ngwr-color-picker-testing.d.ts +291 -0
  190. package/types/ngwr-color-picker.d.ts +13 -1
  191. package/types/ngwr-context-menu.d.ts +15 -1
  192. package/types/ngwr-date-picker-testing.d.ts +6 -66
  193. package/types/ngwr-decrypt-text-testing.d.ts +222 -0
  194. package/types/ngwr-donut-chart-testing.d.ts +79 -0
  195. package/types/ngwr-drawer.d.ts +12 -0
  196. package/types/ngwr-dropdown.d.ts +9 -0
  197. package/types/ngwr-event-calendar-testing.d.ts +301 -0
  198. package/types/ngwr-event-calendar.d.ts +9 -6
  199. package/types/ngwr-falling-text-testing.d.ts +186 -0
  200. package/types/ngwr-fuzzy-text-testing.d.ts +130 -0
  201. package/types/ngwr-gauge-testing.d.ts +71 -0
  202. package/types/ngwr-glitch-text-testing.d.ts +172 -0
  203. package/types/ngwr-gradient-text-testing.d.ts +173 -0
  204. package/types/ngwr-image-cropper-testing.d.ts +134 -0
  205. package/types/ngwr-image-cropper.d.ts +1 -0
  206. package/types/ngwr-input-number.d.ts +33 -1
  207. package/types/ngwr-knob-testing.d.ts +150 -0
  208. package/types/ngwr-lightbox-testing.d.ts +154 -0
  209. package/types/ngwr-lightbox.d.ts +6 -0
  210. package/types/ngwr-line-chart-testing.d.ts +93 -0
  211. package/types/ngwr-marquee-testing.d.ts +280 -0
  212. package/types/ngwr-meter-group-testing.d.ts +67 -0
  213. package/types/ngwr-overlay.d.ts +19 -1
  214. package/types/ngwr-rotating-text-testing.d.ts +191 -0
  215. package/types/ngwr-select.d.ts +32 -0
  216. package/types/ngwr-shiny-text-testing.d.ts +165 -0
  217. package/types/ngwr-slider.d.ts +15 -0
  218. package/types/ngwr-sparkline-testing.d.ts +69 -0
  219. package/types/ngwr-speed-dial-testing.d.ts +195 -0
  220. package/types/ngwr-splash-cursor-testing.d.ts +95 -0
  221. package/types/ngwr-split-text-testing.d.ts +209 -0
  222. package/types/ngwr-split-text.d.ts +12 -0
  223. package/types/ngwr-splitter-testing.d.ts +174 -0
  224. package/types/ngwr-spotlight-card-testing.d.ts +303 -0
  225. package/types/ngwr-star-border-testing.d.ts +135 -0
  226. package/types/ngwr-table.d.ts +10 -1
  227. package/types/ngwr-tilt-card-testing.d.ts +158 -0
  228. package/types/ngwr-tilt-card.d.ts +2 -0
  229. package/types/ngwr-toast.d.ts +14 -5
  230. package/types/ngwr-tour-testing.d.ts +143 -0
  231. package/types/ngwr-tree.d.ts +7 -0
  232. package/types/ngwr-typewriter-testing.d.ts +201 -0
  233. package/types/ngwr-version.d.ts +1 -1
  234. package/types/ngwr-waves-testing.d.ts +121 -0
  235. package/types/ngwr-window-testing.d.ts +263 -0
  236. package/types/ngwr-window.d.ts +27 -10
  237. package/window/styles/_index.scss +44 -16
@@ -0,0 +1,156 @@
1
+ import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
2
+
3
+ /**
4
+ * @license
5
+ *
6
+ * Use of this source code is governed by an MIT-style license that can be
7
+ * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
8
+ */
9
+ /**
10
+ * Test harness for `<wr-image-cropper>`.
11
+ *
12
+ * **This is the smallest honest surface of any harness here, and the reason is worth
13
+ * reading before you reach for a method that is not on it.** Almost everything the
14
+ * cropper does is measured: it reads the `<img>`'s rendered box and its
15
+ * `naturalWidth`, converts between display and source pixels, and moves the crop
16
+ * window with pointer deltas. jsdom measures nothing — every rect is 0×0 and
17
+ * `naturalWidth` is 0 — so an image never "loads", the crop UI never renders, and a
18
+ * synthetic drag divides by zero. There is deliberately no `moveCrop()` or
19
+ * `resizeCrop()`: either would write `NaN` and report success.
20
+ *
21
+ * What a spec CAN do is give the image a box and a natural size itself, then call
22
+ * {@link dispatchImageLoad} — the two numbers `onImageLoad` reads are the whole
23
+ * stub, and from there {@link getCropBox} and {@link getHandles} are real answers,
24
+ * because the component writes the crop window's geometry as inline pixels.
25
+ *
26
+ * ```ts
27
+ * // In your spec, before dispatching the load:
28
+ * const img = fixture.nativeElement.querySelector('.wr-image-cropper__image');
29
+ * img.getBoundingClientRect = () => ({ width: 400, height: 400, x: 0, y: 0 }) as DOMRect;
30
+ * Object.defineProperty(img, 'naturalWidth', { value: 800 });
31
+ * Object.defineProperty(img, 'naturalHeight', { value: 800 });
32
+ * ```
33
+ *
34
+ * **There is also nothing to click.** The cropper renders no buttons: a consumer
35
+ * takes the result by calling `crop()` on the component through a `viewChild`, and
36
+ * reads `cropRect()` the same way. Those are component API rather than DOM, so they
37
+ * are outside what a harness can reach at all — which is worth knowing rather than
38
+ * discovering.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * const cropper = await loader.getHarness(WrImageCropperHarness);
43
+ *
44
+ * expect(await cropper.isEmpty()).toBe(false);
45
+ * expect(await cropper.isReady()).toBe(false); // nothing measured yet
46
+ *
47
+ * await cropper.dispatchImageLoad();
48
+ * expect(await cropper.getCropBox()).toEqual({ x: 80, y: 80, width: 240, height: 240 });
49
+ * ```
50
+ *
51
+ * @see https://ngwr.dev/guides/testing
52
+ */
53
+ class WrImageCropperHarness extends ComponentHarness {
54
+ static hostSelector = 'wr-image-cropper';
55
+ /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */
56
+ static with(options = {}) {
57
+ return new HarnessPredicate(WrImageCropperHarness, options).addOption('empty', options.empty, async (harness, empty) => (await harness.isEmpty()) === empty);
58
+ }
59
+ image = this.locatorForOptional('.wr-image-cropper__image');
60
+ cropWindow = this.locatorForOptional('.wr-image-cropper__window');
61
+ /** Whether the cropper has no source at all, and is showing its placeholder. */
62
+ async isEmpty() {
63
+ return (await this.locatorForOptional('.wr-image-cropper__empty')()) !== null;
64
+ }
65
+ /** The placeholder's text, or `null` when there is an image. Comes from the catalog. */
66
+ async getEmptyText() {
67
+ const empty = await this.locatorForOptional('.wr-image-cropper__empty')();
68
+ return empty ? empty.text() : null;
69
+ }
70
+ /**
71
+ * Whether the crop UI is up.
72
+ *
73
+ * Not the same question as {@link isEmpty}: a cropper with a perfectly good `src`
74
+ * shows nothing but the image until it has been MEASURED, because the window's size
75
+ * is a fraction of the rendered box. In a browser that happens on load; in a unit
76
+ * test it happens when the spec stubs the box and calls
77
+ * {@link dispatchImageLoad}.
78
+ */
79
+ async isReady() {
80
+ return (await this.cropWindow()) !== null;
81
+ }
82
+ /**
83
+ * What the `<img>` is pointing at.
84
+ *
85
+ * A `File` or `Blob` source becomes an object URL, so this is `blob:…` for those
86
+ * and the plain string for a string `src`. Comparing the two is not useful; asking
87
+ * whether it CHANGED is.
88
+ */
89
+ async getImageSrc() {
90
+ const image = await this.image();
91
+ return image ? image.getProperty('src') : null;
92
+ }
93
+ /**
94
+ * Fire the image's `load` event.
95
+ *
96
+ * The event, not a real load: jsdom fetches nothing, and the handler reads
97
+ * `getBoundingClientRect()` and `naturalWidth` off the element. Stub those first —
98
+ * see this class's docs — or the crop window will still not render and
99
+ * {@link isReady} will stay `false`, which is exactly what a real cropper does with
100
+ * a zero-sized image.
101
+ */
102
+ async dispatchImageLoad() {
103
+ const image = await this.image();
104
+ if (!image) {
105
+ throw new Error('WrImageCropperHarness.dispatchImageLoad(): there is no image — the cropper has no `src`, so it is ' +
106
+ 'showing its empty state.');
107
+ }
108
+ await image.dispatchEvent('load');
109
+ }
110
+ /**
111
+ * Where the crop window sits over the displayed image, in CSS pixels.
112
+ *
113
+ * From the inline styles the component writes — a measured box would be 0×0 — and
114
+ * in DISPLAY pixels, which is not what a consumer receives: `cropRect()` converts
115
+ * to the image's natural pixels, and that conversion is the component's own contract
116
+ * rather than something the DOM shows.
117
+ */
118
+ async getCropBox() {
119
+ const window_ = await this.requireReady('getCropBox');
120
+ return {
121
+ x: Number.parseFloat(await window_.getCssValue('left')),
122
+ y: Number.parseFloat(await window_.getCssValue('top')),
123
+ width: Number.parseFloat(await window_.getCssValue('width')),
124
+ height: Number.parseFloat(await window_.getCssValue('height')),
125
+ };
126
+ }
127
+ /** The eight resize handles, by their compass suffix. Throws before the crop UI is up. */
128
+ async getHandles() {
129
+ await this.requireReady('getHandles');
130
+ const handles = await this.locatorForAll('.wr-image-cropper__handle')();
131
+ return Promise.all(handles.map(async (handle) => {
132
+ const classes = (await handle.getAttribute('class')) ?? '';
133
+ const found = classes.split(/\s+/).find(name => name.startsWith('wr-image-cropper__handle--'));
134
+ return (found?.slice('wr-image-cropper__handle--'.length) ?? '');
135
+ }));
136
+ }
137
+ /** Whether the dimming backdrop with the cut-out is drawn. */
138
+ async hasBackdrop() {
139
+ return (await this.locatorForOptional('.wr-image-cropper__backdrop')()) !== null;
140
+ }
141
+ async requireReady(method) {
142
+ const window_ = await this.cropWindow();
143
+ if (window_)
144
+ return window_;
145
+ throw new Error(`WrImageCropperHarness.${method}(): the crop window is not rendered. The cropper sizes it from the ` +
146
+ "image's MEASURED box, and a unit test has none — give the <img> a `getBoundingClientRect` and a " +
147
+ '`naturalWidth`, then call dispatchImageLoad().');
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Generated bundle index. Do not edit.
153
+ */
154
+
155
+ export { WrImageCropperHarness };
156
+ //# sourceMappingURL=ngwr-image-cropper-testing.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngwr-image-cropper-testing.mjs","sources":["../../../projects/lib/image-cropper/testing/wr-image-cropper-harness.ts","../../../projects/lib/image-cropper/testing/ngwr-image-cropper-testing.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ComponentHarness, HarnessPredicate, type TestElement } from '@angular/cdk/testing';\n\nimport type { WrCropHandle } from 'ngwr/image-cropper';\n\nimport type { WrImageCropperHarnessFilters } from './interfaces';\n\n/** Where the crop window sits over the DISPLAYED image, in CSS pixels. */\nexport interface WrCropWindowBox {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\n/**\n * Test harness for `<wr-image-cropper>`.\n *\n * **This is the smallest honest surface of any harness here, and the reason is worth\n * reading before you reach for a method that is not on it.** Almost everything the\n * cropper does is measured: it reads the `<img>`'s rendered box and its\n * `naturalWidth`, converts between display and source pixels, and moves the crop\n * window with pointer deltas. jsdom measures nothing — every rect is 0×0 and\n * `naturalWidth` is 0 — so an image never \"loads\", the crop UI never renders, and a\n * synthetic drag divides by zero. There is deliberately no `moveCrop()` or\n * `resizeCrop()`: either would write `NaN` and report success.\n *\n * What a spec CAN do is give the image a box and a natural size itself, then call\n * {@link dispatchImageLoad} — the two numbers `onImageLoad` reads are the whole\n * stub, and from there {@link getCropBox} and {@link getHandles} are real answers,\n * because the component writes the crop window's geometry as inline pixels.\n *\n * ```ts\n * // In your spec, before dispatching the load:\n * const img = fixture.nativeElement.querySelector('.wr-image-cropper__image');\n * img.getBoundingClientRect = () => ({ width: 400, height: 400, x: 0, y: 0 }) as DOMRect;\n * Object.defineProperty(img, 'naturalWidth', { value: 800 });\n * Object.defineProperty(img, 'naturalHeight', { value: 800 });\n * ```\n *\n * **There is also nothing to click.** The cropper renders no buttons: a consumer\n * takes the result by calling `crop()` on the component through a `viewChild`, and\n * reads `cropRect()` the same way. Those are component API rather than DOM, so they\n * are outside what a harness can reach at all — which is worth knowing rather than\n * discovering.\n *\n * @example\n * ```ts\n * const cropper = await loader.getHarness(WrImageCropperHarness);\n *\n * expect(await cropper.isEmpty()).toBe(false);\n * expect(await cropper.isReady()).toBe(false); // nothing measured yet\n *\n * await cropper.dispatchImageLoad();\n * expect(await cropper.getCropBox()).toEqual({ x: 80, y: 80, width: 240, height: 240 });\n * ```\n *\n * @see https://ngwr.dev/guides/testing\n */\nexport class WrImageCropperHarness extends ComponentHarness {\n static hostSelector = 'wr-image-cropper';\n\n /** Build a predicate that narrows the query — pass to `getHarness` / `getAllHarnesses`. */\n static with(options: WrImageCropperHarnessFilters = {}): HarnessPredicate<WrImageCropperHarness> {\n return new HarnessPredicate(WrImageCropperHarness, options).addOption(\n 'empty',\n options.empty,\n async (harness, empty) => (await harness.isEmpty()) === empty\n );\n }\n\n private readonly image = this.locatorForOptional('.wr-image-cropper__image');\n private readonly cropWindow = this.locatorForOptional('.wr-image-cropper__window');\n\n /** Whether the cropper has no source at all, and is showing its placeholder. */\n async isEmpty(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-image-cropper__empty')()) !== null;\n }\n\n /** The placeholder's text, or `null` when there is an image. Comes from the catalog. */\n async getEmptyText(): Promise<string | null> {\n const empty = await this.locatorForOptional('.wr-image-cropper__empty')();\n return empty ? empty.text() : null;\n }\n\n /**\n * Whether the crop UI is up.\n *\n * Not the same question as {@link isEmpty}: a cropper with a perfectly good `src`\n * shows nothing but the image until it has been MEASURED, because the window's size\n * is a fraction of the rendered box. In a browser that happens on load; in a unit\n * test it happens when the spec stubs the box and calls\n * {@link dispatchImageLoad}.\n */\n async isReady(): Promise<boolean> {\n return (await this.cropWindow()) !== null;\n }\n\n /**\n * What the `<img>` is pointing at.\n *\n * A `File` or `Blob` source becomes an object URL, so this is `blob:…` for those\n * and the plain string for a string `src`. Comparing the two is not useful; asking\n * whether it CHANGED is.\n */\n async getImageSrc(): Promise<string | null> {\n const image = await this.image();\n return image ? image.getProperty<string>('src') : null;\n }\n\n /**\n * Fire the image's `load` event.\n *\n * The event, not a real load: jsdom fetches nothing, and the handler reads\n * `getBoundingClientRect()` and `naturalWidth` off the element. Stub those first —\n * see this class's docs — or the crop window will still not render and\n * {@link isReady} will stay `false`, which is exactly what a real cropper does with\n * a zero-sized image.\n */\n async dispatchImageLoad(): Promise<void> {\n const image = await this.image();\n if (!image) {\n throw new Error(\n 'WrImageCropperHarness.dispatchImageLoad(): there is no image — the cropper has no `src`, so it is ' +\n 'showing its empty state.'\n );\n }\n await image.dispatchEvent('load');\n }\n\n /**\n * Where the crop window sits over the displayed image, in CSS pixels.\n *\n * From the inline styles the component writes — a measured box would be 0×0 — and\n * in DISPLAY pixels, which is not what a consumer receives: `cropRect()` converts\n * to the image's natural pixels, and that conversion is the component's own contract\n * rather than something the DOM shows.\n */\n async getCropBox(): Promise<WrCropWindowBox> {\n const window_ = await this.requireReady('getCropBox');\n return {\n x: Number.parseFloat(await window_.getCssValue('left')),\n y: Number.parseFloat(await window_.getCssValue('top')),\n width: Number.parseFloat(await window_.getCssValue('width')),\n height: Number.parseFloat(await window_.getCssValue('height')),\n };\n }\n\n /** The eight resize handles, by their compass suffix. Throws before the crop UI is up. */\n async getHandles(): Promise<WrCropHandle[]> {\n await this.requireReady('getHandles');\n const handles = await this.locatorForAll('.wr-image-cropper__handle')();\n\n return Promise.all(\n handles.map(async handle => {\n const classes = (await handle.getAttribute('class')) ?? '';\n const found = classes.split(/\\s+/).find(name => name.startsWith('wr-image-cropper__handle--'));\n return (found?.slice('wr-image-cropper__handle--'.length) ?? '') as WrCropHandle;\n })\n );\n }\n\n /** Whether the dimming backdrop with the cut-out is drawn. */\n async hasBackdrop(): Promise<boolean> {\n return (await this.locatorForOptional('.wr-image-cropper__backdrop')()) !== null;\n }\n\n private async requireReady(method: string): Promise<TestElement> {\n const window_ = await this.cropWindow();\n if (window_) return window_;\n\n throw new Error(\n `WrImageCropperHarness.${method}(): the crop window is not rendered. The cropper sizes it from the ` +\n \"image's MEASURED box, and a unit test has none — give the <img> a `getBoundingClientRect` and a \" +\n '`naturalWidth`, then call dispatchImageLoad().'\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAgBH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CG;AACG,MAAO,qBAAsB,SAAQ,gBAAgB,CAAA;AACzD,IAAA,OAAO,YAAY,GAAG,kBAAkB;;AAGxC,IAAA,OAAO,IAAI,CAAC,OAAA,GAAwC,EAAE,EAAA;AACpD,QAAA,OAAO,IAAI,gBAAgB,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC,SAAS,CACnE,OAAO,EACP,OAAO,CAAC,KAAK,EACb,OAAO,OAAO,EAAE,KAAK,KAAK,CAAC,MAAM,OAAO,CAAC,OAAO,EAAE,MAAM,KAAK,CAC9D;IACH;AAEiB,IAAA,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,CAAC;AAC3D,IAAA,UAAU,GAAG,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC;;AAGlF,IAAA,MAAM,OAAO,GAAA;AACX,QAAA,OAAO,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,EAAE,MAAM,IAAI;IAC/E;;AAGA,IAAA,MAAM,YAAY,GAAA;QAChB,MAAM,KAAK,GAAG,MAAM,IAAI,C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AAU,GAAA;AACd,QAAA,MAAM,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC;QACrC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,2BAA2B,CAAC,EAAE;AAEvE,QAAA,OAAO,OAAO,CAAC,GAAG,CAChB,OAAO,CAAC,GAAG,CAAC,OAAM,MAAM,KAAG;AACzB,YAAA,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE;YAC1D,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAC;AAC9F,YAAA,QAAQ,KAAK,EAAE,KAAK,CAAC,4BAA4B,CAAC,MAAM,CAAC,IAAI,EAAE;QACjE,CAAC,CAAC,CACH;IACH;;AAGA,IAAA,MAAM,WAAW,GAAA;AACf,QAAA,OAAO,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,6BAA6B,CAAC,EAAE,MAAM,IAAI;IAClF;IAEQ,MAAM,YAAY,CAAC,MAAc,EAAA;AACvC,QAAA,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE;AACvC,QAAA,IAAI,OAAO;AAAE,YAAA,OAAO,OAAO;AAE3B,QAAA,MAAM,IAAI,KAAK,CACb,CAAA,sBAAA,EAAyB,MAAM,CAAA,mEAAA,CAAqE;YAClG,kGAAkG;AAClG,YAAA,gDAAgD,CACnD;IACH;;;ACtLF;;AAEG;;;;"}
@@ -1,6 +1,7 @@
1
1
  import { coerceNumberProperty } from '@angular/cdk/coercion';
2
2
  import * as i0 from '@angular/core';
3
- import { input, output, viewChild, signal, inject, DestroyRef, computed, effect, ViewEncapsulation, Component } from '@angular/core';
3
+ import { signal, input, output, viewChild, inject, DestroyRef, computed, effect, ViewEncapsulation, Component } from '@angular/core';
4
+ import { useI18nText } from 'ngwr/i18n';
4
5
  import { clamp } from 'ngwr/utils';
5
6
 
6
7
  /**
@@ -9,6 +10,11 @@ import { clamp } from 'ngwr/utils';
9
10
  * Use of this source code is governed by an MIT-style license that can be
10
11
  * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
11
12
  */
13
+ /**
14
+ * Stands in for the consumer input `useI18nText` expects — the empty state takes no
15
+ * label input, and its string was an English literal in the template.
16
+ */
17
+ const NO_OVERRIDE = signal(null).asReadonly();
12
18
  /**
13
19
  * Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags
14
20
  * the crop window or any of its eight handles. Optionally lock the crop
@@ -50,6 +56,7 @@ class WrImageCropper {
50
56
  imgEl = viewChild.required('img', /* @ts-ignore */
51
57
  ...(ngDevMode ? [{ debugName: "imgEl" }] : /* istanbul ignore next */ []));
52
58
  /** Resolved object URL for `src` (so File / Blob render in `<img>`). */
59
+ emptyText = useI18nText(NO_OVERRIDE, 'imageCropper.empty', 'No image');
53
60
  objectUrl = signal(null, /* @ts-ignore */
54
61
  ...(ngDevMode ? [{ debugName: "objectUrl" }] : /* istanbul ignore next */ []));
55
62
  /** Previous object URL we created — kept off-signal so the resolve
@@ -308,11 +315,11 @@ class WrImageCropper {
308
315
  }
309
316
  }
310
317
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrImageCropper, deps: [], target: i0.ɵɵFactoryTarget.Component });
311
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrImageCropper, isStandalone: true, selector: "wr-image-cropper", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, aspectRatio: { classPropertyName: "aspectRatio", publicName: "aspectRatio", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null }, outputQuality: { classPropertyName: "outputQuality", publicName: "outputQuality", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cropped: "cropped" }, host: { classAttribute: "wr-image-cropper" }, viewQueries: [{ propertyName: "imgEl", first: true, predicate: ["img"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window \u2014 drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">No image</div>\n}\n", encapsulation: i0.ViewEncapsulation.None });
318
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrImageCropper, isStandalone: true, selector: "wr-image-cropper", inputs: { src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, aspectRatio: { classPropertyName: "aspectRatio", publicName: "aspectRatio", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, outputType: { classPropertyName: "outputType", publicName: "outputType", isSignal: true, isRequired: false, transformFunction: null }, outputQuality: { classPropertyName: "outputQuality", publicName: "outputQuality", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cropped: "cropped" }, host: { classAttribute: "wr-image-cropper" }, viewQueries: [{ propertyName: "imgEl", first: true, predicate: ["img"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window \u2014 drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n", encapsulation: i0.ViewEncapsulation.None });
312
319
  }
313
320
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrImageCropper, decorators: [{
314
321
  type: Component,
315
- args: [{ selector: 'wr-image-cropper', encapsulation: ViewEncapsulation.None, host: { class: 'wr-image-cropper' }, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window \u2014 drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">No image</div>\n}\n" }]
322
+ args: [{ selector: 'wr-image-cropper', encapsulation: ViewEncapsulation.None, host: { class: 'wr-image-cropper' }, template: "@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window \u2014 drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n" }]
316
323
  }], ctorParameters: () => [], propDecorators: { src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], aspectRatio: [{ type: i0.Input, args: [{ isSignal: true, alias: "aspectRatio", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], outputType: [{ type: i0.Input, args: [{ isSignal: true, alias: "outputType", required: false }] }], outputQuality: [{ type: i0.Input, args: [{ isSignal: true, alias: "outputQuality", required: false }] }], cropped: [{ type: i0.Output, args: ["cropped"] }], imgEl: [{ type: i0.ViewChild, args: ['img', { isSignal: true }] }] } });
317
324
 
318
325
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ngwr-image-cropper.mjs","sources":["../../../projects/lib/image-cropper/image-cropper.ts","../../../projects/lib/image-cropper/image-cropper.html","../../../projects/lib/image-cropper/ngwr-image-cropper.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { clamp } from 'ngwr/utils';\n\nimport type { WrCropHandle, WrCropRect, WrImageOutputType } from './interfaces';\n\ninterface RectPx {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/**\n * Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags\n * the crop window or any of its eight handles. Optionally lock the crop\n * to a fixed `[aspectRatio]`.\n *\n * `(cropped)` fires after each drag end with a freshly-rendered `Blob`\n * of the cropped region. For one-off reads use `toBlob()` / `toDataUrl()`.\n *\n * @example\n * ```html\n * <wr-image-cropper\n * [src]=\"file\"\n * [aspectRatio]=\"1\"\n * (cropped)=\"onBlob($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/image-cropper\n */\n@Component({\n selector: 'wr-image-cropper',\n templateUrl: './image-cropper.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-image-cropper' },\n})\nexport class WrImageCropper {\n /** Image source — URL string, `File`, or `Blob`. */\n readonly src = input<string | File | Blob | null>(null);\n\n /** Aspect ratio (width / height). `null` = free. @default null */\n readonly aspectRatio = input<number | null>(null);\n\n /** Minimum crop width in display pixels. @default 32 */\n readonly minWidth = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Minimum crop height in display pixels. @default 32 */\n readonly minHeight = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Default output type for `(cropped)`. @default 'image/png' */\n readonly outputType = input<WrImageOutputType>('image/png');\n\n /** JPEG / WebP quality for `(cropped)` in [0, 1]. @default 0.92 */\n readonly outputQuality = input(0.92);\n\n /** Emits a Blob after each drag end. */\n readonly cropped = output<Blob>();\n\n protected readonly imgEl = viewChild.required<ElementRef<HTMLImageElement>>('img');\n\n /** Resolved object URL for `src` (so File / Blob render in `<img>`). */\n protected readonly objectUrl = signal<string | null>(null);\n\n /** Previous object URL we created — kept off-signal so the resolve\n * effect doesn't depend on its own writes (which would loop). */\n private previousObjectUrl: string | null = null;\n\n /** Natural (source) pixel dimensions. */\n protected readonly natural = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Display (rendered) pixel dimensions. */\n protected readonly display = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Crop rect in display coordinates. */\n protected readonly cropDisplay = signal<RectPx>({ x: 0, y: 0, w: 0, h: 0 });\n\n /** Currently active drag handle. */\n private active: WrCropHandle | null = null;\n private startPointer: { x: number; y: number } = { x: 0, y: 0 };\n private startRect: RectPx = { x: 0, y: 0, w: 0, h: 0 };\n\n private readonly destroyRef = inject(DestroyRef);\n\n /** Resolved crop rect in natural (source) pixel coordinates. */\n readonly cropRect = computed<WrCropRect>(() => {\n const display = this.display();\n const natural = this.natural();\n const c = this.cropDisplay();\n if (display.w === 0 || display.h === 0) return { x: 0, y: 0, width: 0, height: 0 };\n const sx = natural.w / display.w;\n const sy = natural.h / display.h;\n return {\n x: Math.round(c.x * sx),\n y: Math.round(c.y * sy),\n width: Math.round(c.w * sx),\n height: Math.round(c.h * sy),\n };\n });\n\n constructor() {\n // Resolve the source into a usable URL the <img> can render.\n // We only read `src()` here — `previousObjectUrl` is a plain field, so\n // writing to `objectUrl` doesn't re-trigger this effect (and hang the\n // tab on file upload).\n effect(() => {\n const src = this.src();\n if (this.previousObjectUrl) {\n URL.revokeObjectURL(this.previousObjectUrl);\n this.previousObjectUrl = null;\n }\n // The crop is measured against the image that WAS showing, and `cropRect` is a\n // public signal a consumer can read at any moment. Left in place it kept\n // reporting a rect scaled to the previous image for the whole gap between a new\n // `src` and its load event — long enough to crop the wrong thing.\n this.resetGeometry();\n if (!src) {\n this.objectUrl.set(null);\n return;\n }\n if (typeof src === 'string') {\n this.objectUrl.set(src);\n } else {\n const url = URL.createObjectURL(src);\n this.previousObjectUrl = url;\n this.objectUrl.set(url);\n }\n });\n\n this.destroyRef.onDestroy(() => {\n if (this.previousObjectUrl) URL.revokeObjectURL(this.previousObjectUrl);\n });\n }\n\n // Image load\n\n /**\n * Back to \"nothing measured yet\", which is also what an absent `src` means.\n *\n * `display` is the field that gates everything downstream — the crop UI renders on\n * `display().w > 0` and `cropRect` returns zeros without it — so it is the only one\n * a test can observe. The other two are reset for coherence: anything that learns to\n * set `display` from elsewhere (a resize observer is the obvious candidate for this\n * component) would otherwise resurrect a crop measured against the previous image.\n */\n private resetGeometry(): void {\n this.natural.set({ w: 0, h: 0 });\n this.display.set({ w: 0, h: 0 });\n this.cropDisplay.set({ x: 0, y: 0, w: 0, h: 0 });\n }\n\n protected onImageLoad(): void {\n const img = this.imgEl().nativeElement;\n const rect = img.getBoundingClientRect();\n const display = { w: rect.width, h: rect.height };\n // Some SVGs and odd images report zero natural dimensions — fall back\n // to the rendered size so the crop math stays well-defined.\n const natural = {\n w: img.naturalWidth || display.w,\n h: img.naturalHeight || display.h,\n };\n this.natural.set(natural);\n this.display.set(display);\n this.cropDisplay.set(this.initialCrop(display));\n }\n\n /** Compute a sensible initial crop — centered, respecting aspectRatio. */\n private initialCrop(display: { w: number; h: number }): RectPx {\n const ratio = this.aspectRatio();\n let w = display.w * 0.6;\n let h = display.h * 0.6;\n if (ratio && ratio > 0) {\n const candidate = w / ratio;\n if (candidate > h) w = h * ratio;\n else h = w / ratio;\n }\n return {\n x: (display.w - w) / 2,\n y: (display.h - h) / 2,\n w,\n h,\n };\n }\n\n // Drag handlers\n\n protected readonly handles: readonly WrCropHandle[] = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];\n\n protected onPointerDown(handle: WrCropHandle, event: PointerEvent): void {\n // Any pointerdown used to start a drag, so the right button moved the crop window and\n // a second finger could take over a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n event.stopPropagation();\n this.active = handle;\n this.startPointer = { x: event.clientX, y: event.clientY };\n this.startRect = { ...this.cropDisplay() };\n (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.active) return;\n const dx = event.clientX - this.startPointer.x;\n const dy = event.clientY - this.startPointer.y;\n if (this.active === 'move') this.applyMove(dx, dy);\n else this.applyResize(this.active, dx, dy);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.active) return;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n this.active = null;\n void this.emitCropped();\n }\n\n private applyMove(dx: number, dy: number): void {\n const display = this.display();\n const r = this.startRect;\n const next = {\n x: clamp(r.x + dx, 0, display.w - r.w),\n y: clamp(r.y + dy, 0, display.h - r.h),\n w: r.w,\n h: r.h,\n };\n this.cropDisplay.set(next);\n }\n\n private applyResize(handle: WrCropHandle, dx: number, dy: number): void {\n const display = this.display();\n const min = { w: this.minWidth(), h: this.minHeight() };\n const ratio = this.aspectRatio();\n const r = this.startRect;\n let x = r.x;\n let y = r.y;\n let w = r.w;\n let h = r.h;\n\n if (handle.includes('e')) w = clamp(r.w + dx, min.w, display.w - r.x);\n if (handle.includes('w')) {\n const nextW = clamp(r.w - dx, min.w, r.x + r.w);\n x = r.x + (r.w - nextW);\n w = nextW;\n }\n if (handle.includes('s')) h = clamp(r.h + dy, min.h, display.h - r.y);\n if (handle.includes('n')) {\n const nextH = clamp(r.h - dy, min.h, r.y + r.h);\n y = r.y + (r.h - nextH);\n h = nextH;\n }\n\n if (ratio && ratio > 0) {\n // Lock the orthogonal axis to maintain ratio. For corner handles,\n // pick whichever delta drives the larger change so we don't bounce.\n if (handle === 'e' || handle === 'w') {\n const newH = w / ratio;\n const dh = newH - r.h;\n if (handle === 'e' || handle === 'w') {\n y = r.y - dh / 2;\n h = newH;\n }\n } else if (handle === 'n' || handle === 's') {\n const newW = h * ratio;\n const dw = newW - r.w;\n x = r.x - dw / 2;\n w = newW;\n } else {\n // Corner — drive by width, then derive height.\n const newH = w / ratio;\n if (handle.includes('n')) y = r.y + r.h - newH;\n h = newH;\n }\n // Re-clamp after ratio adjustment so we never spill out of the canvas.\n x = clamp(x, 0, display.w - w);\n y = clamp(y, 0, display.h - h);\n w = clamp(w, min.w, display.w - x);\n h = clamp(h, min.h, display.h - y);\n }\n\n this.cropDisplay.set({ x, y, w, h });\n }\n\n // Public API\n\n /** Render the current crop as a Blob. */\n async toBlob(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): Promise<Blob> {\n const canvas = this.toCanvas();\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n blob => {\n if (blob) resolve(blob);\n else reject(new Error('toBlob returned null'));\n },\n type,\n quality\n );\n });\n }\n\n /** Render the current crop as a data URL. */\n toDataUrl(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): string {\n return this.toCanvas().toDataURL(type, quality);\n }\n\n /** Re-emit the crop without waiting for a drag (e.g. after a programmatic change). */\n async refresh(): Promise<void> {\n await this.emitCropped();\n }\n\n // Internals\n\n private toCanvas(): HTMLCanvasElement {\n const img = this.imgEl().nativeElement;\n const c = this.cropRect();\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, c.width);\n canvas.height = Math.max(1, c.height);\n const ctx = canvas.getContext('2d');\n if (ctx) ctx.drawImage(img, c.x, c.y, c.width, c.height, 0, 0, canvas.width, canvas.height);\n return canvas;\n }\n\n private async emitCropped(): Promise<void> {\n try {\n const blob = await this.toBlob();\n this.cropped.emit(blob);\n } catch {\n // Swallow — invalid state (image not loaded, crop empty, etc.).\n }\n }\n}\n","@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window — drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">No image</div>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AA4BH;;;;;;;;;;;;;;;;;;AAkBG;MAOU,cAAc,CAAA;;IAEhB,GAAG,GAAG,KAAK,CAA8B,IAAI;4EAAC;;IAG9C,WAAW,GAAG,KAAK,CAAgB,IAAI;oFAAC;;IAGxC,QAAQ,GAAG,KAAK,CAAC,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,UAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAA,CAAG;;IAGrG,SAAS,GAAG,KAAK,CAAC,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,WAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAA,CAAG;;IAGtG,UAAU,GAAG,KAAK,CAAoB,WAAW;mFAAC;;IAG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AAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FDoBa,cAAc,EAAA,UAAA,EAAA,CAAA;kBAN1B,SAAS;+BACE,kBAAkB,EAAA,aAAA,EAEb,iBAAiB,CAAC,IAAI,QAC/B,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAA,QAAA,EAAA,utDAAA,EAAA;4tBAwByC,KAAK,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEhFnF;;AAEG;;;;"}
1
+ {"version":3,"file":"ngwr-image-cropper.mjs","sources":["../../../projects/lib/image-cropper/image-cropper.ts","../../../projects/lib/image-cropper/image-cropper.html","../../../projects/lib/image-cropper/ngwr-image-cropper.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { coerceNumberProperty } from '@angular/cdk/coercion';\nimport {\n Component,\n DestroyRef,\n type ElementRef,\n ViewEncapsulation,\n computed,\n effect,\n inject,\n input,\n output,\n signal,\n viewChild,\n} from '@angular/core';\n\nimport { useI18nText } from 'ngwr/i18n';\nimport { clamp } from 'ngwr/utils';\n\nimport type { WrCropHandle, WrCropRect, WrImageOutputType } from './interfaces';\n\n/**\n * Stands in for the consumer input `useI18nText` expects — the empty state takes no\n * label input, and its string was an English literal in the template.\n */\nconst NO_OVERRIDE = signal<string | null>(null).asReadonly();\n\ninterface RectPx {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/**\n * Image crop UI. Pass `[src]` (URL, `File`, or `Blob`); the user drags\n * the crop window or any of its eight handles. Optionally lock the crop\n * to a fixed `[aspectRatio]`.\n *\n * `(cropped)` fires after each drag end with a freshly-rendered `Blob`\n * of the cropped region. For one-off reads use `toBlob()` / `toDataUrl()`.\n *\n * @example\n * ```html\n * <wr-image-cropper\n * [src]=\"file\"\n * [aspectRatio]=\"1\"\n * (cropped)=\"onBlob($event)\"\n * />\n * ```\n *\n * @see https://ngwr.dev/reference/components/image-cropper\n */\n@Component({\n selector: 'wr-image-cropper',\n templateUrl: './image-cropper.html',\n encapsulation: ViewEncapsulation.None,\n host: { class: 'wr-image-cropper' },\n})\nexport class WrImageCropper {\n /** Image source — URL string, `File`, or `Blob`. */\n readonly src = input<string | File | Blob | null>(null);\n\n /** Aspect ratio (width / height). `null` = free. @default null */\n readonly aspectRatio = input<number | null>(null);\n\n /** Minimum crop width in display pixels. @default 32 */\n readonly minWidth = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Minimum crop height in display pixels. @default 32 */\n readonly minHeight = input(32, { transform: (v: unknown): number => Math.max(8, coerceNumberProperty(v, 32)) });\n\n /** Default output type for `(cropped)`. @default 'image/png' */\n readonly outputType = input<WrImageOutputType>('image/png');\n\n /** JPEG / WebP quality for `(cropped)` in [0, 1]. @default 0.92 */\n readonly outputQuality = input(0.92);\n\n /** Emits a Blob after each drag end. */\n readonly cropped = output<Blob>();\n\n protected readonly imgEl = viewChild.required<ElementRef<HTMLImageElement>>('img');\n\n /** Resolved object URL for `src` (so File / Blob render in `<img>`). */\n protected readonly emptyText = useI18nText(NO_OVERRIDE, 'imageCropper.empty', 'No image');\n\n protected readonly objectUrl = signal<string | null>(null);\n\n /** Previous object URL we created — kept off-signal so the resolve\n * effect doesn't depend on its own writes (which would loop). */\n private previousObjectUrl: string | null = null;\n\n /** Natural (source) pixel dimensions. */\n protected readonly natural = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Display (rendered) pixel dimensions. */\n protected readonly display = signal<{ w: number; h: number }>({ w: 0, h: 0 });\n\n /** Crop rect in display coordinates. */\n protected readonly cropDisplay = signal<RectPx>({ x: 0, y: 0, w: 0, h: 0 });\n\n /** Currently active drag handle. */\n private active: WrCropHandle | null = null;\n private startPointer: { x: number; y: number } = { x: 0, y: 0 };\n private startRect: RectPx = { x: 0, y: 0, w: 0, h: 0 };\n\n private readonly destroyRef = inject(DestroyRef);\n\n /** Resolved crop rect in natural (source) pixel coordinates. */\n readonly cropRect = computed<WrCropRect>(() => {\n const display = this.display();\n const natural = this.natural();\n const c = this.cropDisplay();\n if (display.w === 0 || display.h === 0) return { x: 0, y: 0, width: 0, height: 0 };\n const sx = natural.w / display.w;\n const sy = natural.h / display.h;\n return {\n x: Math.round(c.x * sx),\n y: Math.round(c.y * sy),\n width: Math.round(c.w * sx),\n height: Math.round(c.h * sy),\n };\n });\n\n constructor() {\n // Resolve the source into a usable URL the <img> can render.\n // We only read `src()` here — `previousObjectUrl` is a plain field, so\n // writing to `objectUrl` doesn't re-trigger this effect (and hang the\n // tab on file upload).\n effect(() => {\n const src = this.src();\n if (this.previousObjectUrl) {\n URL.revokeObjectURL(this.previousObjectUrl);\n this.previousObjectUrl = null;\n }\n // The crop is measured against the image that WAS showing, and `cropRect` is a\n // public signal a consumer can read at any moment. Left in place it kept\n // reporting a rect scaled to the previous image for the whole gap between a new\n // `src` and its load event — long enough to crop the wrong thing.\n this.resetGeometry();\n if (!src) {\n this.objectUrl.set(null);\n return;\n }\n if (typeof src === 'string') {\n this.objectUrl.set(src);\n } else {\n const url = URL.createObjectURL(src);\n this.previousObjectUrl = url;\n this.objectUrl.set(url);\n }\n });\n\n this.destroyRef.onDestroy(() => {\n if (this.previousObjectUrl) URL.revokeObjectURL(this.previousObjectUrl);\n });\n }\n\n // Image load\n\n /**\n * Back to \"nothing measured yet\", which is also what an absent `src` means.\n *\n * `display` is the field that gates everything downstream — the crop UI renders on\n * `display().w > 0` and `cropRect` returns zeros without it — so it is the only one\n * a test can observe. The other two are reset for coherence: anything that learns to\n * set `display` from elsewhere (a resize observer is the obvious candidate for this\n * component) would otherwise resurrect a crop measured against the previous image.\n */\n private resetGeometry(): void {\n this.natural.set({ w: 0, h: 0 });\n this.display.set({ w: 0, h: 0 });\n this.cropDisplay.set({ x: 0, y: 0, w: 0, h: 0 });\n }\n\n protected onImageLoad(): void {\n const img = this.imgEl().nativeElement;\n const rect = img.getBoundingClientRect();\n const display = { w: rect.width, h: rect.height };\n // Some SVGs and odd images report zero natural dimensions — fall back\n // to the rendered size so the crop math stays well-defined.\n const natural = {\n w: img.naturalWidth || display.w,\n h: img.naturalHeight || display.h,\n };\n this.natural.set(natural);\n this.display.set(display);\n this.cropDisplay.set(this.initialCrop(display));\n }\n\n /** Compute a sensible initial crop — centered, respecting aspectRatio. */\n private initialCrop(display: { w: number; h: number }): RectPx {\n const ratio = this.aspectRatio();\n let w = display.w * 0.6;\n let h = display.h * 0.6;\n if (ratio && ratio > 0) {\n const candidate = w / ratio;\n if (candidate > h) w = h * ratio;\n else h = w / ratio;\n }\n return {\n x: (display.w - w) / 2,\n y: (display.h - h) / 2,\n w,\n h,\n };\n }\n\n // Drag handlers\n\n protected readonly handles: readonly WrCropHandle[] = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];\n\n protected onPointerDown(handle: WrCropHandle, event: PointerEvent): void {\n // Any pointerdown used to start a drag, so the right button moved the crop window and\n // a second finger could take over a drag already in progress.\n if (event.button !== 0 || !event.isPrimary) return;\n event.preventDefault();\n event.stopPropagation();\n this.active = handle;\n this.startPointer = { x: event.clientX, y: event.clientY };\n this.startRect = { ...this.cropDisplay() };\n (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);\n }\n\n protected onPointerMove(event: PointerEvent): void {\n if (!this.active) return;\n const dx = event.clientX - this.startPointer.x;\n const dy = event.clientY - this.startPointer.y;\n if (this.active === 'move') this.applyMove(dx, dy);\n else this.applyResize(this.active, dx, dy);\n }\n\n protected onPointerUp(event: PointerEvent): void {\n if (!this.active) return;\n (event.currentTarget as HTMLElement).releasePointerCapture(event.pointerId);\n this.active = null;\n void this.emitCropped();\n }\n\n private applyMove(dx: number, dy: number): void {\n const display = this.display();\n const r = this.startRect;\n const next = {\n x: clamp(r.x + dx, 0, display.w - r.w),\n y: clamp(r.y + dy, 0, display.h - r.h),\n w: r.w,\n h: r.h,\n };\n this.cropDisplay.set(next);\n }\n\n private applyResize(handle: WrCropHandle, dx: number, dy: number): void {\n const display = this.display();\n const min = { w: this.minWidth(), h: this.minHeight() };\n const ratio = this.aspectRatio();\n const r = this.startRect;\n let x = r.x;\n let y = r.y;\n let w = r.w;\n let h = r.h;\n\n if (handle.includes('e')) w = clamp(r.w + dx, min.w, display.w - r.x);\n if (handle.includes('w')) {\n const nextW = clamp(r.w - dx, min.w, r.x + r.w);\n x = r.x + (r.w - nextW);\n w = nextW;\n }\n if (handle.includes('s')) h = clamp(r.h + dy, min.h, display.h - r.y);\n if (handle.includes('n')) {\n const nextH = clamp(r.h - dy, min.h, r.y + r.h);\n y = r.y + (r.h - nextH);\n h = nextH;\n }\n\n if (ratio && ratio > 0) {\n // Lock the orthogonal axis to maintain ratio. For corner handles,\n // pick whichever delta drives the larger change so we don't bounce.\n if (handle === 'e' || handle === 'w') {\n const newH = w / ratio;\n const dh = newH - r.h;\n if (handle === 'e' || handle === 'w') {\n y = r.y - dh / 2;\n h = newH;\n }\n } else if (handle === 'n' || handle === 's') {\n const newW = h * ratio;\n const dw = newW - r.w;\n x = r.x - dw / 2;\n w = newW;\n } else {\n // Corner — drive by width, then derive height.\n const newH = w / ratio;\n if (handle.includes('n')) y = r.y + r.h - newH;\n h = newH;\n }\n // Re-clamp after ratio adjustment so we never spill out of the canvas.\n x = clamp(x, 0, display.w - w);\n y = clamp(y, 0, display.h - h);\n w = clamp(w, min.w, display.w - x);\n h = clamp(h, min.h, display.h - y);\n }\n\n this.cropDisplay.set({ x, y, w, h });\n }\n\n // Public API\n\n /** Render the current crop as a Blob. */\n async toBlob(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): Promise<Blob> {\n const canvas = this.toCanvas();\n return new Promise<Blob>((resolve, reject) => {\n canvas.toBlob(\n blob => {\n if (blob) resolve(blob);\n else reject(new Error('toBlob returned null'));\n },\n type,\n quality\n );\n });\n }\n\n /** Render the current crop as a data URL. */\n toDataUrl(type: WrImageOutputType = this.outputType(), quality: number = this.outputQuality()): string {\n return this.toCanvas().toDataURL(type, quality);\n }\n\n /** Re-emit the crop without waiting for a drag (e.g. after a programmatic change). */\n async refresh(): Promise<void> {\n await this.emitCropped();\n }\n\n // Internals\n\n private toCanvas(): HTMLCanvasElement {\n const img = this.imgEl().nativeElement;\n const c = this.cropRect();\n const canvas = document.createElement('canvas');\n canvas.width = Math.max(1, c.width);\n canvas.height = Math.max(1, c.height);\n const ctx = canvas.getContext('2d');\n if (ctx) ctx.drawImage(img, c.x, c.y, c.width, c.height, 0, 0, canvas.width, canvas.height);\n return canvas;\n }\n\n private async emitCropped(): Promise<void> {\n try {\n const blob = await this.toBlob();\n this.cropped.emit(blob);\n } catch {\n // Swallow — invalid state (image not loaded, crop empty, etc.).\n }\n }\n}\n","@if (objectUrl(); as url) {\n <div class=\"wr-image-cropper__canvas\">\n <img #img class=\"wr-image-cropper__image\" [src]=\"url\" alt=\"\" draggable=\"false\" (load)=\"onImageLoad()\" />\n\n @if (display().w > 0) {\n <!-- Semi-transparent backdrop with a cut-out for the crop window. -->\n <div\n class=\"wr-image-cropper__backdrop\"\n [style.clip-path]=\"`polygon(0 0, 100% 0, 100% 100%, 0 100%, 0 ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y}px, ${cropDisplay().x}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y + cropDisplay().h}px, ${cropDisplay().x + cropDisplay().w}px ${cropDisplay().y}px, 0 ${cropDisplay().y}px)`\"\n ></div>\n\n <!-- Crop window — drag to move, with eight resize handles. -->\n <div\n class=\"wr-image-cropper__window\"\n [style.left.px]=\"cropDisplay().x\"\n [style.top.px]=\"cropDisplay().y\"\n [style.width.px]=\"cropDisplay().w\"\n [style.height.px]=\"cropDisplay().h\"\n (pointerdown)=\"onPointerDown('move', $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n >\n @for (h of handles; track h) {\n <span\n [class]=\"`wr-image-cropper__handle wr-image-cropper__handle--${h}`\"\n (pointerdown)=\"onPointerDown(h, $event)\"\n (pointermove)=\"onPointerMove($event)\"\n (pointerup)=\"onPointerUp($event)\"\n (pointercancel)=\"onPointerUp($event)\"\n ></span>\n }\n </div>\n }\n </div>\n} @else {\n <div class=\"wr-image-cropper__empty\">{{ emptyText() }}</div>\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAsBH;;;AAGG;AACH,MAAM,WAAW,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC,UAAU,EAAE;AAS5D;;;;;;;;;;;;;;;;;;AAkBG;MAOU,cAAc,CAAA;;IAEhB,GAAG,GAAG,KAAK,CAA8B,IAAI;4EAAC;;IAG9C,WAAW,GAAG,KAAK,CAAgB,IAAI;oFAAC;;IAGxC,QAAQ,GAAG,KAAK,CAAC,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,UAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAA,CAAG;;IAGrG,SAAS,GAAG,KAAK,CAAC,EAAE,EAAA,EAAA,IAAA,SAAA,GAAA,EAAA,SAAA,EAAA,WAAA,EAAA,8BAAA,EAAA,CAAA,EAAI,SAAS,EAAE,CAAC,CAAU,KAAa,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAA,CAAG;;IAGtG,UAAU,GAAG,KAAK,CAAoB,WAAW;mFAAC;;IAGlD,aAAa,GAAG,KAAK,CAAC,IAAI;sFAAC;;IAG3B,OAAO,GAAG,MAAM,EAAQ;AAEd,IAAA,KAAK,GAAG,SAAS,C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AAA;;2FD2Ba,cAAc,EAAA,UAAA,EAAA,CAAA;kBAN1B,SAAS;+BACE,kBAAkB,EAAA,aAAA,EAEb,iBAAiB,CAAC,IAAI,QAC/B,EAAE,KAAK,EAAE,kBAAkB,EAAE,EAAA,QAAA,EAAA,guDAAA,EAAA;4tBAwByC,KAAK,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEvFnF;;AAEG;;;;"}
@@ -2,8 +2,9 @@ import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coerci
2
2
  import * as i0 from '@angular/core';
3
3
  import { input, computed, model, output, inject, LOCALE_ID, signal, effect, ViewEncapsulation, Component } from '@angular/core';
4
4
  import { useConfigValue } from 'ngwr/config';
5
+ import { useI18nText } from 'ngwr/i18n';
5
6
  import { WrInput, WrInputGroup, WrInputPrefix, WrInputSuffix } from 'ngwr/input';
6
- import { clamp, round } from 'ngwr/utils';
7
+ import { round, clamp } from 'ngwr/utils';
7
8
 
8
9
  /**
9
10
  * @license
@@ -115,6 +116,19 @@ class WrInputNumber {
115
116
  return placeholder ? placeholder : null;
116
117
  }, /* @ts-ignore */
117
118
  ...(ngDevMode ? [{ debugName: "resolvedAriaLabel" }] : /* istanbul ignore next */ []));
119
+ /** Increment button aria-label. Falls back to `inputNumber.increment`. */
120
+ incrementLabel = input(null, /* @ts-ignore */
121
+ ...(ngDevMode ? [{ debugName: "incrementLabel" }] : /* istanbul ignore next */ []));
122
+ /** Decrement button aria-label. Falls back to `inputNumber.decrement`. */
123
+ decrementLabel = input(null, /* @ts-ignore */
124
+ ...(ngDevMode ? [{ debugName: "decrementLabel" }] : /* istanbul ignore next */ []));
125
+ /**
126
+ * The steppers are icon-only buttons, so these ARE their accessible names.
127
+ * They were hard-coded English while the catalog carried the keys for them
128
+ * unread — a Russian app announced "Increment".
129
+ */
130
+ resolvedIncrement = useI18nText(this.incrementLabel, 'inputNumber.increment', 'Increment');
131
+ resolvedDecrement = useI18nText(this.decrementLabel, 'inputNumber.decrement', 'Decrement');
118
132
  /** Disable interaction. @default false */
119
133
  disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: coerceBooleanProperty });
120
134
  /** Read-only — values cannot be changed (steppers + typing disabled). @default false */
@@ -151,6 +165,27 @@ class WrInputNumber {
151
165
  return parts.join(' ');
152
166
  }, /* @ts-ignore */
153
167
  ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
168
+ /**
169
+ * Fraction digits the stepper rounds its arithmetic to when `decimals` says
170
+ * nothing. High enough to leave a real value alone, low enough to erase the
171
+ * binary-float tail that repeated stepping accumulates.
172
+ */
173
+ static STEP_PRECISION = 10;
174
+ /**
175
+ * Above this, the anti-drift round is skipped — it would MANUFACTURE drift.
176
+ *
177
+ * `round(v, 10)` is `Math.round((v + EPSILON) * 1e10) / 1e10`, and the scale
178
+ * factor is only exact while `v * 1e10` stays inside 2^53, i.e. |v| under
179
+ * about 900,720. In practice the round-trip still recovers up to ~9.2e8 and
180
+ * then breaks: `round(1000000001, 10)` is `1000000000.9999999`, and since
181
+ * `format` prints up to 20 fraction digits that tail reaches the screen —
182
+ * and compounds, because the next press starts from it. Integer stepping at
183
+ * that magnitude is exact in IEEE754 and needed no help; the only thing this
184
+ * rounding exists to defend is `0.1 + 0.1 + 0.1`.
185
+ */
186
+ static SAFE_ROUND_MAGNITUDE = 1e6;
187
+ /** Steps finer than this would be rounded away by {@link STEP_PRECISION}. */
188
+ static SAFE_ROUND_STEP = 1e-9;
154
189
  constructor() {
155
190
  // Keep the display `text` in sync with external writes to `value` (via
156
191
  // `[formField]` / `[(value)]`). While the user is editing, the input
@@ -160,7 +195,26 @@ class WrInputNumber {
160
195
  const v = this.value();
161
196
  if (this.focused())
162
197
  return;
163
- this.text.set(v === null || Number.isNaN(v) ? '' : this.format(this.constrain(v)));
198
+ if (v === null || Number.isNaN(v)) {
199
+ this.text.set('');
200
+ return;
201
+ }
202
+ // SHOW WHAT THE MODEL HOLDS. It used to format `constrain(v)`, so a
203
+ // `[max]="10"` field handed 500 drew "10" over a model that still said
204
+ // 500 — the display was the thing lying, not the model.
205
+ //
206
+ // The tempting repair is to write the clamp back so the two agree, and
207
+ // that is worse: under `[formField]` the bounds arrive ONLY through the
208
+ // schema's `min()` / `max()` rules (binding `[min]` next to `[formField]`
209
+ // is an NG8022 compile error), so overwriting the value ERASES the very
210
+ // error those rules exist to raise — and the write marks a pristine form
211
+ // dirty, tripping unsaved-changes guards and opening every other
212
+ // validator's message on first paint.
213
+ //
214
+ // So: `min` / `max` bound what this component's own edits may produce,
215
+ // and a value written from outside is displayed as it is and left for
216
+ // validation to judge.
217
+ this.text.set(this.format(v));
164
218
  });
165
219
  }
166
220
  // Template handlers
@@ -205,7 +259,20 @@ class WrInputNumber {
205
259
  bump(units) {
206
260
  const stepSize = this.step() || 1;
207
261
  const base = this.value() ?? this.fallbackBase();
208
- const next = this.constrain(base + units * stepSize);
262
+ // `round` before `constrain`, and only on the stepped ARITHMETIC. Binary
263
+ // floats do not add: three presses of a `step="0.1"` stepper produced
264
+ // 0.30000000000000004, `constrain` only rounds when `decimals` is set, and
265
+ // `format` prints up to 20 fraction digits — so the drift went into the
266
+ // model AND onto the screen. Ten digits erases IEEE noise without
267
+ // quantising a value the user typed (0.15000000000000002 stays 0.15, it
268
+ // does not snap to the step grid).
269
+ //
270
+ // Guarded on BOTH ends, because outside them the correction is the thing
271
+ // that corrupts: see SAFE_ROUND_MAGNITUDE, and a step finer than 1e-9 would
272
+ // simply be rounded away to nothing.
273
+ const raw = base + units * stepSize;
274
+ const correctable = Math.abs(raw) < WrInputNumber.SAFE_ROUND_MAGNITUDE && Math.abs(stepSize) >= WrInputNumber.SAFE_ROUND_STEP;
275
+ const next = this.constrain(correctable ? round(raw, WrInputNumber.STEP_PRECISION) : raw);
209
276
  this.value.set(next);
210
277
  this.text.set(this.format(next));
211
278
  }
@@ -255,12 +322,12 @@ class WrInputNumber {
255
322
  return formatter.format(v);
256
323
  }
257
324
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrInputNumber, deps: [], target: i0.ɵɵFactoryTarget.Component });
258
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrInputNumber, isStandalone: true, selector: "wr-input-number", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, showSteppers: { classPropertyName: "showSteppers", publicName: "showSteppers", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", touch: "touch" }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: "<wr-input-group [rounded]=\"resolvedRounded()\">\n @if (prefix(); as p) {\n <span wrInputPrefix>{{ p }}</span>\n }\n <input\n #input\n wrInput\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [wrSize]=\"resolvedSize()\"\n [rounded]=\"resolvedRounded()\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n spellcheck=\"false\"\n [value]=\"text()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n />\n @if (suffix(); as s) {\n <span wrInputSuffix>{{ s }}</span>\n }\n @if (showSteppers()) {\n <div class=\"wr-input-number__steppers\" wrInputSuffix>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n aria-label=\"Increment\"\n [disabled]=\"!interactive() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 5 L4 0 L8 5 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n aria-label=\"Decrement\"\n [disabled]=\"!interactive() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 0 L4 5 L8 0 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n </div>\n }\n</wr-input-group>\n", dependencies: [{ kind: "directive", type: WrInput, selector: "input[wrInput], textarea[wrInput]", inputs: ["wrSize", "rounded"] }, { kind: "component", type: WrInputGroup, selector: "wr-input-group", inputs: ["rounded"] }, { kind: "directive", type: WrInputPrefix, selector: "[wrInputPrefix]" }, { kind: "directive", type: WrInputSuffix, selector: "[wrInputSuffix]" }], encapsulation: i0.ViewEncapsulation.None });
325
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: WrInputNumber, isStandalone: true, selector: "wr-input-number", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, showSteppers: { classPropertyName: "showSteppers", publicName: "showSteppers", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, incrementLabel: { classPropertyName: "incrementLabel", publicName: "incrementLabel", isSignal: true, isRequired: false, transformFunction: null }, decrementLabel: { classPropertyName: "decrementLabel", publicName: "decrementLabel", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange", touch: "touch" }, host: { properties: { "class": "classes()" } }, ngImport: i0, template: "<wr-input-group [rounded]=\"resolvedRounded()\">\n @if (prefix(); as p) {\n <span wrInputPrefix>{{ p }}</span>\n }\n <input\n #input\n wrInput\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [wrSize]=\"resolvedSize()\"\n [rounded]=\"resolvedRounded()\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n spellcheck=\"false\"\n [value]=\"text()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n />\n @if (suffix(); as s) {\n <span wrInputSuffix>{{ s }}</span>\n }\n @if (showSteppers()) {\n <div class=\"wr-input-number__steppers\" wrInputSuffix>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n [attr.aria-label]=\"resolvedIncrement()\"\n [disabled]=\"!interactive() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 5 L4 0 L8 5 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n [attr.aria-label]=\"resolvedDecrement()\"\n [disabled]=\"!interactive() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 0 L4 5 L8 0 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n </div>\n }\n</wr-input-group>\n", dependencies: [{ kind: "directive", type: WrInput, selector: "input[wrInput], textarea[wrInput]", inputs: ["wrSize", "rounded"] }, { kind: "component", type: WrInputGroup, selector: "wr-input-group", inputs: ["rounded"] }, { kind: "directive", type: WrInputPrefix, selector: "[wrInputPrefix]" }, { kind: "directive", type: WrInputSuffix, selector: "[wrInputSuffix]" }], encapsulation: i0.ViewEncapsulation.None });
259
326
  }
260
327
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: WrInputNumber, decorators: [{
261
328
  type: Component,
262
- args: [{ selector: 'wr-input-number', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, imports: [WrInput, WrInputGroup, WrInputPrefix, WrInputSuffix], template: "<wr-input-group [rounded]=\"resolvedRounded()\">\n @if (prefix(); as p) {\n <span wrInputPrefix>{{ p }}</span>\n }\n <input\n #input\n wrInput\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [wrSize]=\"resolvedSize()\"\n [rounded]=\"resolvedRounded()\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n spellcheck=\"false\"\n [value]=\"text()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n />\n @if (suffix(); as s) {\n <span wrInputSuffix>{{ s }}</span>\n }\n @if (showSteppers()) {\n <div class=\"wr-input-number__steppers\" wrInputSuffix>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n aria-label=\"Increment\"\n [disabled]=\"!interactive() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 5 L4 0 L8 5 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n aria-label=\"Decrement\"\n [disabled]=\"!interactive() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 0 L4 5 L8 0 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n </div>\n }\n</wr-input-group>\n" }]
263
- }], ctorParameters: () => [], propDecorators: { min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], decimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimals", required: false }] }], showSteppers: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSteppers", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], prefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "prefix", required: false }] }], suffix: [{ type: i0.Input, args: [{ isSignal: true, alias: "suffix", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], touch: [{ type: i0.Output, args: ["touch"] }] } });
329
+ args: [{ selector: 'wr-input-number', encapsulation: ViewEncapsulation.None, host: { '[class]': 'classes()' }, imports: [WrInput, WrInputGroup, WrInputPrefix, WrInputSuffix], template: "<wr-input-group [rounded]=\"resolvedRounded()\">\n @if (prefix(); as p) {\n <span wrInputPrefix>{{ p }}</span>\n }\n <input\n #input\n wrInput\n type=\"text\"\n inputmode=\"decimal\"\n autocomplete=\"off\"\n [wrSize]=\"resolvedSize()\"\n [rounded]=\"resolvedRounded()\"\n [attr.aria-label]=\"resolvedAriaLabel()\"\n spellcheck=\"false\"\n [value]=\"text()\"\n [placeholder]=\"placeholder()\"\n [disabled]=\"disabled()\"\n [readonly]=\"readonly()\"\n (input)=\"onInput($event)\"\n (focus)=\"onFocus()\"\n (blur)=\"onBlur()\"\n (keydown)=\"onKeydown($event)\"\n />\n @if (suffix(); as s) {\n <span wrInputSuffix>{{ s }}</span>\n }\n @if (showSteppers()) {\n <div class=\"wr-input-number__steppers\" wrInputSuffix>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n [attr.aria-label]=\"resolvedIncrement()\"\n [disabled]=\"!interactive() || atMax()\"\n (click)=\"stepBy(1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 5 L4 0 L8 5 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n <button\n type=\"button\"\n class=\"wr-input-number__step\"\n tabindex=\"-1\"\n [attr.aria-label]=\"resolvedDecrement()\"\n [disabled]=\"!interactive() || atMin()\"\n (click)=\"stepBy(-1)\"\n >\n <svg width=\"10\" height=\"6\" viewBox=\"0 0 8 5\" aria-hidden=\"true\">\n <path d=\"M0 0 L4 5 L8 0 Z\" fill=\"currentColor\" />\n </svg>\n </button>\n </div>\n }\n</wr-input-group>\n" }]
330
+ }], ctorParameters: () => [], propDecorators: { min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], decimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimals", required: false }] }], showSteppers: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSteppers", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], prefix: [{ type: i0.Input, args: [{ isSignal: true, alias: "prefix", required: false }] }], suffix: [{ type: i0.Input, args: [{ isSignal: true, alias: "suffix", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], incrementLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "incrementLabel", required: false }] }], decrementLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "decrementLabel", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], touch: [{ type: i0.Output, args: ["touch"] }] } });
264
331
 
265
332
  /**
266
333
  * Generated bundle index. Do not edit.