@molecule/app-rating-display-angular 0.0.0-stage → 0.0.1-stage

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,327 @@
1
- # Temporary Holding Version
1
+ <!--
2
+ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
+ Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
+ Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
+ To change this document, edit the module-level JSDoc in src/index.ts.
6
+ Generated: 2026-11-15T09:12:59.687Z
7
+ -->
2
8
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
9
+ # @molecule/app-rating-display-angular
10
+
11
+ Angular star-rating display.
12
+
13
+ Exports `RatingDisplay` — fractional star rendering (inline SVG), optional
14
+ review count tail, optional interactive mode via `onChange`. It is the
15
+ Angular counterpart of `@molecule/app-rating-display-react`: same props
16
+ (React names), same DOM for the same input.
17
+
18
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
19
+ > It is written to be read by coding agents as much as by people, and is generated from this
20
+ > package's source — edit `src/index.ts` JSDoc, not this file.
21
+
22
+ ## Quick Start
23
+
24
+ ```ts
25
+ import { Component, signal } from '@angular/core'
26
+ import { RatingDisplay } from '@molecule/app-rating-display-angular'
27
+
28
+ @Component({
29
+ selector: 'app-product-rating',
30
+ standalone: true,
31
+ imports: [RatingDisplay],
32
+ template: `
33
+ <span mol-rating-display [value]="4.5" [reviewCount]="128" (click)="scrollToReviews()"></span>
34
+ <span mol-rating-display [value]="rating()" size="lg" [onChange]="setRating"></span>
35
+ `,
36
+ })
37
+ export class ProductRating {
38
+ readonly rating = signal(0)
39
+ readonly setRating = (value: number): void => this.rating.set(value)
40
+ scrollToReviews(): void {
41
+ document.getElementById('reviews')?.scrollIntoView()
42
+ }
43
+ }
44
+ ```
45
+
46
+ ## Type
47
+
48
+ `feature`
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ npm install @molecule/app-rating-display-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular
54
+ ```
55
+
56
+ ## API
57
+
58
+ ### Interfaces
59
+
60
+ #### `RatingDisplayProps`
61
+
62
+ Props accepted by {@link RatingDisplay} — the same props
63
+ `@molecule/app-rating-display-react` accepts. Every one is an input:
64
+ `onReviewsClick` and `onChange` are inputs holding the callback functions
65
+ React takes as props.
66
+
67
+ ```typescript
68
+ interface RatingDisplayProps {
69
+ /** Rating value (0–max). Fractional supported. */
70
+ value: number
71
+ /** Maximum rating. Defaults to 5. */
72
+ max?: number
73
+ /** Optional review count shown after the stars. */
74
+ reviewCount?: number
75
+ /**
76
+ * Called when the review-count is clicked (renders it as a button). React
77
+ * passes the click event, so this receives it too.
78
+ */
79
+ onReviewsClick?: (event?: MouseEvent) => void
80
+ /** Size preset. */
81
+ size?: 'sm' | 'md' | 'lg'
82
+ /** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
83
+ onChange?: (value: number) => void
84
+ /** Accessible label override. */
85
+ ariaLabel?: string
86
+ /** Extra classes. */
87
+ className?: string
88
+ }
89
+ ```
90
+
91
+ ### Classes
92
+
93
+ #### `RatingDisplay`
94
+
95
+ RatingDisplay component.
96
+
97
+ Star-rating display supporting fractional values and an optional
98
+ review-count tail. When `onChange` is provided each star becomes an
99
+ interactive button. The host IS the outer `<span>`
100
+ (`span[mol-rating-display]`), matching React's root exactly, so the root's
101
+ class, `role` and `aria-label` are host bindings.
102
+
103
+ Uses inline SVG stars so the component works without icon-font fallback.
104
+ Same props (React names) and same DOM as
105
+ `@molecule/app-rating-display-react`'s `RatingDisplay`.
106
+
107
+ ```typescript
108
+ @Component({
109
+ selector: 'span[mol-rating-display]',
110
+ standalone: true,
111
+ inputs: [
112
+ 'value',
113
+ 'max',
114
+ 'reviewCount',
115
+ 'onReviewsClick',
116
+ 'size',
117
+ 'onChange',
118
+ 'ariaLabel',
119
+ 'className',
120
+ ],
121
+ host: {
122
+ role: 'img',
123
+ '[class]': 'classes()',
124
+ '[attr.aria-label]': 'label()',
125
+ },
126
+ template: `@for (star of stars(); track star.i) {
127
+ @if (onChange) {
128
+ <button type="button" (click)="select(star.i)" [attr.aria-label]="rateLabel(star.i)">
129
+ <svg [attr.width]="px()" [attr.height]="px()" viewBox="0 0 24 24" aria-hidden="true">
130
+ <defs>
131
+ <linearGradient [attr.id]="star.id">
132
+ <stop [attr.offset]="offset(star.fill)" stop-color="currentColor"></stop>
133
+ <stop
134
+ [attr.offset]="offset(star.fill)"
135
+ stop-color="currentColor"
136
+ stop-opacity="0.25"
137
+ ></stop>
138
+ </linearGradient>
139
+ </defs>
140
+ <path [attr.d]="path" [attr.fill]="fillUrl(star.id)"></path>
141
+ </svg>
142
+ </button>
143
+ } @else {
144
+ <svg [attr.width]="px()" [attr.height]="px()" viewBox="0 0 24 24" aria-hidden="true">
145
+ <defs>
146
+ <linearGradient [attr.id]="star.id">
147
+ <stop [attr.offset]="offset(star.fill)" stop-color="currentColor"></stop>
148
+ <stop
149
+ [attr.offset]="offset(star.fill)"
150
+ stop-color="currentColor"
151
+ stop-opacity="0.25"
152
+ ></stop>
153
+ </linearGradient>
154
+ </defs>
155
+ <path [attr.d]="path" [attr.fill]="fillUrl(star.id)"></path>
156
+ </svg>
157
+ }
158
+ }
159
+ @if (reviewCount !== undefined) {
160
+ @if (onReviewsClick) {
161
+ <button type="button" (click)="onReviewsClick($event)" [class]="reviewClasses()">
162
+ ({{ reviewCount }})
163
+ </button>
164
+ } @else {
165
+ <span [class]="textClasses()">({{ reviewCount }})</span>
166
+ }
167
+ }`,
168
+ })
169
+ export class RatingDisplay {
170
+ /** Rating value (0–max). Fractional supported. */
171
+ value!: number
172
+ /** Maximum rating (defaults to 5 at read time). */
173
+ max?: number
174
+ /** Optional review count shown after the stars. */
175
+ reviewCount?: number
176
+ /** Called when the review-count is clicked; receives the DOM click event. */
177
+ onReviewsClick?: (event?: MouseEvent) => void
178
+ /** Size preset (defaults to `'md'` at read time). */
179
+ size?: 'sm' | 'md' | 'lg'
180
+ /** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
181
+ onChange?: (value: number) => void
182
+ /** Accessible label override. */
183
+ ariaLabel?: string
184
+ /** Extra classes. */
185
+ className?: string
186
+ /** The star's single SVG path. */
187
+ readonly path = STAR_PATH
188
+
189
+ /**
190
+ * The current class map.
191
+ * @returns The UIClassMap.
192
+ */
193
+ cm(): UIClassMap {
194
+ return getClassMap()
195
+ }
196
+
197
+ /**
198
+ * The effective maximum (React's default parameter: a later-bound write of
199
+ * `undefined` must not erase the `5` default).
200
+ * @returns The maximum rating.
201
+ */
202
+ maxValue(): number {
203
+ return this.max ?? 5
204
+ }
205
+
206
+ /**
207
+ * The star size in pixels (React's `SIZE_PX[size]`, which is `undefined` for
208
+ * an unknown size so both axes are omitted).
209
+ * @returns The pixel size.
210
+ */
211
+ px(): number | undefined {
212
+ return SIZE_PX[this.size ?? 'md']
213
+ }
214
+
215
+ /**
216
+ * One render state per star: its index, its fractional fill and its gradient
217
+ * id (minted per render, as React mints one per star per render).
218
+ * @returns The star states.
219
+ */
220
+ stars(): StarState[] {
221
+ return Array.from({ length: this.maxValue() }, (_value, i) => ({
222
+ i,
223
+ fill: Math.max(0, Math.min(1, this.value - i)),
224
+ id: starId(),
225
+ }))
226
+ }
227
+
228
+ /**
229
+ * The gradient stop offset for a fill fraction.
230
+ * @param fill - Star fill fraction (0–1).
231
+ * @returns The percentage offset.
232
+ */
233
+ offset(fill: number): string {
234
+ return `${fill * 100}%`
235
+ }
236
+
237
+ /**
238
+ * The `<path>` fill referencing the star's gradient.
239
+ * @param id - The star's gradient id.
240
+ * @returns The `url(#id)` fill.
241
+ */
242
+ fillUrl(id: string): string {
243
+ return `url(#${id})`
244
+ }
245
+
246
+ /**
247
+ * The per-star button label in interactive mode.
248
+ * @param i - Star index (0-based).
249
+ * @returns The accessible label.
250
+ */
251
+ rateLabel(i: number): string {
252
+ return `Rate ${i + 1} of ${this.maxValue()}`
253
+ }
254
+
255
+ /**
256
+ * Calls `onChange` with the rating a clicked star selects.
257
+ * @param i - Star index (0-based).
258
+ */
259
+ select(i: number): void {
260
+ this.onChange?.(i + 1)
261
+ }
262
+
263
+ /**
264
+ * The root `<span>` class list (`cm.flex({ align: 'center', gap: 'xs' })` +
265
+ * `className`).
266
+ * @returns The class string.
267
+ */
268
+ classes(): string {
269
+ return this.cm().cn(this.cm().flex({ align: 'center', gap: 'xs' }), this.className)
270
+ }
271
+
272
+ /**
273
+ * The root `aria-label` (`ariaLabel`, or React's default).
274
+ * @returns The accessible label.
275
+ */
276
+ label(): string {
277
+ return this.ariaLabel ?? `Rating: ${this.value} of ${this.maxValue()}`
278
+ }
279
+
280
+ /**
281
+ * The review-count button class (`cm.textSize('sm')` + `cm.link`).
282
+ * @returns The class string.
283
+ */
284
+ reviewClasses(): string {
285
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().link)
286
+ }
287
+
288
+ /**
289
+ * The review-count text span class (`cm.textSize('sm')`).
290
+ * @returns The class string.
291
+ */
292
+ textClasses(): string {
293
+ return this.cm().textSize('sm')
294
+ }
295
+ }
296
+ ```
297
+
298
+ ## Injection Notes
299
+
300
+ ### Requirements
301
+
302
+ Peer dependencies:
303
+
304
+ - `@angular/common` ^22.0.0
305
+ - `@angular/core` ^22.0.0
306
+ - `@angular/platform-browser` ^22.0.0
307
+ - `@molecule/app-angular` ^3.5.0
308
+ - `@molecule/app-ui` ^1.0.1
309
+ - `@molecule/app-ui-angular` ^1.1.0
310
+
311
+ ### Runtime Dependencies
312
+
313
+ - `@angular/common`
314
+ - `@angular/core`
315
+ - `@angular/platform-browser`
316
+ - `@molecule/app-angular`
317
+ - `@molecule/app-ui`
318
+ - `@molecule/app-ui-angular`
319
+
320
+ The host element IS the outer `<span>` (`span[mol-rating-display]`), exactly
321
+ as in React. Stars are inline SVG filled with `currentColor` — set a text
322
+ color on the wrapper (e.g. a warning/amber token) to tint them; unfilled
323
+ portions render at 25% opacity of the same color. Accessibility labels are
324
+ English defaults, matching the React package: the container label is
325
+ overridable via `ariaLabel`, but the per-star "Rate N of M" button labels in
326
+ interactive mode are not — this package has no locale bond. Requires a wired
327
+ ClassMap bond.
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Angular star-rating display.
3
+ *
4
+ * Exports `RatingDisplay` — fractional star rendering (inline SVG), optional
5
+ * review count tail, optional interactive mode via `onChange`. It is the
6
+ * Angular counterpart of `@molecule/app-rating-display-react`: same props
7
+ * (React names), same DOM for the same input.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { Component, signal } from '@angular/core'
12
+ * import { RatingDisplay } from '@molecule/app-rating-display-angular'
13
+ *
14
+ * @Component({
15
+ * selector: 'app-product-rating',
16
+ * standalone: true,
17
+ * imports: [RatingDisplay],
18
+ * template: `
19
+ * <span
20
+ * mol-rating-display
21
+ * [value]="4.5"
22
+ * [reviewCount]="128"
23
+ * (click)="scrollToReviews()"
24
+ * ></span>
25
+ * <span mol-rating-display [value]="rating()" size="lg" [onChange]="setRating"></span>
26
+ * `,
27
+ * })
28
+ * export class ProductRating {
29
+ * readonly rating = signal(0)
30
+ * readonly setRating = (value: number): void => this.rating.set(value)
31
+ * scrollToReviews(): void {
32
+ * document.getElementById('reviews')?.scrollIntoView()
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * The host element IS the outer `<span>` (`span[mol-rating-display]`), exactly
39
+ * as in React. Stars are inline SVG filled with `currentColor` — set a text
40
+ * color on the wrapper (e.g. a warning/amber token) to tint them; unfilled
41
+ * portions render at 25% opacity of the same color. Accessibility labels are
42
+ * English defaults, matching the React package: the container label is
43
+ * overridable via `ariaLabel`, but the per-star "Rate N of M" button labels in
44
+ * interactive mode are not — this package has no locale bond. Requires a wired
45
+ * ClassMap bond.
46
+ *
47
+ * @module
48
+ */
49
+ export * from './rating-display.component.js';
50
+ export * from './types.js';
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Angular star-rating display.
3
+ *
4
+ * Exports `RatingDisplay` — fractional star rendering (inline SVG), optional
5
+ * review count tail, optional interactive mode via `onChange`. It is the
6
+ * Angular counterpart of `@molecule/app-rating-display-react`: same props
7
+ * (React names), same DOM for the same input.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { Component, signal } from '@angular/core'
12
+ * import { RatingDisplay } from '@molecule/app-rating-display-angular'
13
+ *
14
+ * @Component({
15
+ * selector: 'app-product-rating',
16
+ * standalone: true,
17
+ * imports: [RatingDisplay],
18
+ * template: `
19
+ * <span
20
+ * mol-rating-display
21
+ * [value]="4.5"
22
+ * [reviewCount]="128"
23
+ * (click)="scrollToReviews()"
24
+ * ></span>
25
+ * <span mol-rating-display [value]="rating()" size="lg" [onChange]="setRating"></span>
26
+ * `,
27
+ * })
28
+ * export class ProductRating {
29
+ * readonly rating = signal(0)
30
+ * readonly setRating = (value: number): void => this.rating.set(value)
31
+ * scrollToReviews(): void {
32
+ * document.getElementById('reviews')?.scrollIntoView()
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * The host element IS the outer `<span>` (`span[mol-rating-display]`), exactly
39
+ * as in React. Stars are inline SVG filled with `currentColor` — set a text
40
+ * color on the wrapper (e.g. a warning/amber token) to tint them; unfilled
41
+ * portions render at 25% opacity of the same color. Accessibility labels are
42
+ * English defaults, matching the React package: the container label is
43
+ * overridable via `ariaLabel`, but the per-star "Rate N of M" button labels in
44
+ * interactive mode are not — this package has no locale bond. Requires a wired
45
+ * ClassMap bond.
46
+ *
47
+ * @module
48
+ */
49
+ export * from './rating-display.component.js';
50
+ export * from './types.js';
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
@@ -0,0 +1,115 @@
1
+ import type { UIClassMap } from '@molecule/app-ui';
2
+ import * as i0 from "@angular/core";
3
+ /** One star's computed render state. */
4
+ interface StarState {
5
+ /** Star index (0-based). */
6
+ i: number;
7
+ /** Star fill fraction (0–1). */
8
+ fill: number;
9
+ /** The star's gradient id. */
10
+ id: string;
11
+ }
12
+ /**
13
+ * RatingDisplay component.
14
+ *
15
+ * Star-rating display supporting fractional values and an optional
16
+ * review-count tail. When `onChange` is provided each star becomes an
17
+ * interactive button. The host IS the outer `<span>`
18
+ * (`span[mol-rating-display]`), matching React's root exactly, so the root's
19
+ * class, `role` and `aria-label` are host bindings.
20
+ *
21
+ * Uses inline SVG stars so the component works without icon-font fallback.
22
+ * Same props (React names) and same DOM as
23
+ * `@molecule/app-rating-display-react`'s `RatingDisplay`.
24
+ */
25
+ export declare class RatingDisplay {
26
+ /** Rating value (0–max). Fractional supported. */
27
+ value: number;
28
+ /** Maximum rating (defaults to 5 at read time). */
29
+ max?: number;
30
+ /** Optional review count shown after the stars. */
31
+ reviewCount?: number;
32
+ /** Called when the review-count is clicked; receives the DOM click event. */
33
+ onReviewsClick?: (event?: MouseEvent) => void;
34
+ /** Size preset (defaults to `'md'` at read time). */
35
+ size?: 'sm' | 'md' | 'lg';
36
+ /** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
37
+ onChange?: (value: number) => void;
38
+ /** Accessible label override. */
39
+ ariaLabel?: string;
40
+ /** Extra classes. */
41
+ className?: string;
42
+ /** The star's single SVG path. */
43
+ readonly path = "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z";
44
+ /**
45
+ * The current class map.
46
+ * @returns The UIClassMap.
47
+ */
48
+ cm(): UIClassMap;
49
+ /**
50
+ * The effective maximum (React's default parameter: a later-bound write of
51
+ * `undefined` must not erase the `5` default).
52
+ * @returns The maximum rating.
53
+ */
54
+ maxValue(): number;
55
+ /**
56
+ * The star size in pixels (React's `SIZE_PX[size]`, which is `undefined` for
57
+ * an unknown size so both axes are omitted).
58
+ * @returns The pixel size.
59
+ */
60
+ px(): number | undefined;
61
+ /**
62
+ * One render state per star: its index, its fractional fill and its gradient
63
+ * id (minted per render, as React mints one per star per render).
64
+ * @returns The star states.
65
+ */
66
+ stars(): StarState[];
67
+ /**
68
+ * The gradient stop offset for a fill fraction.
69
+ * @param fill - Star fill fraction (0–1).
70
+ * @returns The percentage offset.
71
+ */
72
+ offset(fill: number): string;
73
+ /**
74
+ * The `<path>` fill referencing the star's gradient.
75
+ * @param id - The star's gradient id.
76
+ * @returns The `url(#id)` fill.
77
+ */
78
+ fillUrl(id: string): string;
79
+ /**
80
+ * The per-star button label in interactive mode.
81
+ * @param i - Star index (0-based).
82
+ * @returns The accessible label.
83
+ */
84
+ rateLabel(i: number): string;
85
+ /**
86
+ * Calls `onChange` with the rating a clicked star selects.
87
+ * @param i - Star index (0-based).
88
+ */
89
+ select(i: number): void;
90
+ /**
91
+ * The root `<span>` class list (`cm.flex({ align: 'center', gap: 'xs' })` +
92
+ * `className`).
93
+ * @returns The class string.
94
+ */
95
+ classes(): string;
96
+ /**
97
+ * The root `aria-label` (`ariaLabel`, or React's default).
98
+ * @returns The accessible label.
99
+ */
100
+ label(): string;
101
+ /**
102
+ * The review-count button class (`cm.textSize('sm')` + `cm.link`).
103
+ * @returns The class string.
104
+ */
105
+ reviewClasses(): string;
106
+ /**
107
+ * The review-count text span class (`cm.textSize('sm')`).
108
+ * @returns The class string.
109
+ */
110
+ textClasses(): string;
111
+ static ɵfac: i0.ɵɵFactoryDeclaration<RatingDisplay, never>;
112
+ static ɵcmp: i0.ɵɵComponentDeclaration<RatingDisplay, "span[mol-rating-display]", never, { "value": { "alias": "value"; "required": false; }; "max": { "alias": "max"; "required": false; }; "reviewCount": { "alias": "reviewCount"; "required": false; }; "onReviewsClick": { "alias": "onReviewsClick"; "required": false; }; "size": { "alias": "size"; "required": false; }; "onChange": { "alias": "onChange"; "required": false; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, never, true, never>;
113
+ }
114
+ export {};
115
+ //# sourceMappingURL=rating-display.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating-display.component.d.ts","sourceRoot":"","sources":["../src/rating-display.component.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;;AAUlD,wCAAwC;AACxC,UAAU,SAAS;IACjB,4BAA4B;IAC5B,CAAC,EAAE,MAAM,CAAA;IACT,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAA;CACX;AASD;;;;;;;;;;;;GAYG;AACH,qBA6Da,aAAa;IACxB,kDAAkD;IAClD,KAAK,EAAG,MAAM,CAAA;IACd,mDAAmD;IACnD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;IAC7C,qDAAqD;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACzB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,kCAAkC;IAClC,QAAQ,CAAC,IAAI,kGAAY;IAEzB;;;OAGG;IACH,EAAE,IAAI,UAAU;IAIhB;;;;OAIG;IACH,QAAQ,IAAI,MAAM;IAIlB;;;;OAIG;IACH,EAAE,IAAI,MAAM,GAAG,SAAS;IAIxB;;;;OAIG;IACH,KAAK,IAAI,SAAS,EAAE;IAQpB;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAI5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAI3B;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAI5B;;;OAGG;IACH,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAIvB;;;;OAIG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,KAAK,IAAI,MAAM;IAIf;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,WAAW,IAAI,MAAM;yCA3HV,aAAa;2CAAb,aAAa;CA8HzB"}
@@ -0,0 +1,304 @@
1
+ /**
2
+ * RatingDisplay component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { Component } from '@angular/core';
7
+ import { getClassMap } from '@molecule/app-ui';
8
+ import * as i0 from "@angular/core";
9
+ const _forTrack0 = ($index, $item) => $item.i;
10
+ function RatingDisplay_For_1_Conditional_0_Template(rf, ctx) { if (rf & 1) {
11
+ const _r1 = i0.ɵɵgetCurrentView();
12
+ i0.ɵɵdomElementStart(0, "button", 2);
13
+ i0.ɵɵdomListener("click", function RatingDisplay_For_1_Conditional_0_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r1); const star_r2 = i0.ɵɵnextContext().$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.select(star_r2.i)); });
14
+ i0.ɵɵnamespaceSVG();
15
+ i0.ɵɵdomElementStart(1, "svg", 1)(2, "defs")(3, "linearGradient");
16
+ i0.ɵɵdomElement(4, "stop", 3)(5, "stop", 4);
17
+ i0.ɵɵdomElementEnd()();
18
+ i0.ɵɵdomElement(6, "path");
19
+ i0.ɵɵdomElementEnd()();
20
+ } if (rf & 2) {
21
+ const star_r2 = i0.ɵɵnextContext().$implicit;
22
+ const ctx_r2 = i0.ɵɵnextContext();
23
+ i0.ɵɵattribute("aria-label", ctx_r2.rateLabel(star_r2.i));
24
+ i0.ɵɵadvance();
25
+ i0.ɵɵattribute("width", ctx_r2.px())("height", ctx_r2.px());
26
+ i0.ɵɵadvance(2);
27
+ i0.ɵɵattribute("id", star_r2.id);
28
+ i0.ɵɵadvance();
29
+ i0.ɵɵattribute("offset", ctx_r2.offset(star_r2.fill));
30
+ i0.ɵɵadvance();
31
+ i0.ɵɵattribute("offset", ctx_r2.offset(star_r2.fill));
32
+ i0.ɵɵadvance();
33
+ i0.ɵɵattribute("d", ctx_r2.path)("fill", ctx_r2.fillUrl(star_r2.id));
34
+ } }
35
+ function RatingDisplay_For_1_Conditional_1_Template(rf, ctx) { if (rf & 1) {
36
+ i0.ɵɵnamespaceSVG();
37
+ i0.ɵɵdomElementStart(0, "svg", 1)(1, "defs")(2, "linearGradient");
38
+ i0.ɵɵdomElement(3, "stop", 3)(4, "stop", 4);
39
+ i0.ɵɵdomElementEnd()();
40
+ i0.ɵɵdomElement(5, "path");
41
+ i0.ɵɵdomElementEnd();
42
+ } if (rf & 2) {
43
+ const star_r2 = i0.ɵɵnextContext().$implicit;
44
+ const ctx_r2 = i0.ɵɵnextContext();
45
+ i0.ɵɵattribute("width", ctx_r2.px())("height", ctx_r2.px());
46
+ i0.ɵɵadvance(2);
47
+ i0.ɵɵattribute("id", star_r2.id);
48
+ i0.ɵɵadvance();
49
+ i0.ɵɵattribute("offset", ctx_r2.offset(star_r2.fill));
50
+ i0.ɵɵadvance();
51
+ i0.ɵɵattribute("offset", ctx_r2.offset(star_r2.fill));
52
+ i0.ɵɵadvance();
53
+ i0.ɵɵattribute("d", ctx_r2.path)("fill", ctx_r2.fillUrl(star_r2.id));
54
+ } }
55
+ function RatingDisplay_For_1_Template(rf, ctx) { if (rf & 1) {
56
+ i0.ɵɵconditionalCreate(0, RatingDisplay_For_1_Conditional_0_Template, 7, 8, "button", 0)(1, RatingDisplay_For_1_Conditional_1_Template, 6, 7, "svg", 1);
57
+ } if (rf & 2) {
58
+ const ctx_r2 = i0.ɵɵnextContext();
59
+ i0.ɵɵconditional(ctx_r2.onChange ? 0 : 1);
60
+ } }
61
+ function RatingDisplay_Conditional_2_Conditional_0_Template(rf, ctx) { if (rf & 1) {
62
+ const _r4 = i0.ɵɵgetCurrentView();
63
+ i0.ɵɵdomElementStart(0, "button", 2);
64
+ i0.ɵɵdomListener("click", function RatingDisplay_Conditional_2_Conditional_0_Template_button_click_0_listener($event) { i0.ɵɵrestoreView(_r4); const ctx_r2 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r2.onReviewsClick($event)); });
65
+ i0.ɵɵtext(1);
66
+ i0.ɵɵdomElementEnd();
67
+ } if (rf & 2) {
68
+ const ctx_r2 = i0.ɵɵnextContext(2);
69
+ i0.ɵɵclassMap(ctx_r2.reviewClasses());
70
+ i0.ɵɵadvance();
71
+ i0.ɵɵtextInterpolate1(" (", ctx_r2.reviewCount, ") ");
72
+ } }
73
+ function RatingDisplay_Conditional_2_Conditional_1_Template(rf, ctx) { if (rf & 1) {
74
+ i0.ɵɵdomElementStart(0, "span");
75
+ i0.ɵɵtext(1);
76
+ i0.ɵɵdomElementEnd();
77
+ } if (rf & 2) {
78
+ const ctx_r2 = i0.ɵɵnextContext(2);
79
+ i0.ɵɵclassMap(ctx_r2.textClasses());
80
+ i0.ɵɵadvance();
81
+ i0.ɵɵtextInterpolate1("(", ctx_r2.reviewCount, ")");
82
+ } }
83
+ function RatingDisplay_Conditional_2_Template(rf, ctx) { if (rf & 1) {
84
+ i0.ɵɵconditionalCreate(0, RatingDisplay_Conditional_2_Conditional_0_Template, 2, 3, "button", 5)(1, RatingDisplay_Conditional_2_Conditional_1_Template, 2, 3, "span", 6);
85
+ } if (rf & 2) {
86
+ const ctx_r2 = i0.ɵɵnextContext();
87
+ i0.ɵɵconditional(ctx_r2.onReviewsClick ? 0 : 1);
88
+ } }
89
+ /** Star pixel size per size preset. */
90
+ const SIZE_PX = { sm: 12, md: 16, lg: 20 };
91
+ /** The star's single SVG path, identical to React's. */
92
+ const STAR_PATH = 'M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z';
93
+ /**
94
+ * Mints one star's gradient id, exactly as React's `Star` does.
95
+ *
96
+ * @returns The gradient id.
97
+ */
98
+ const starId = () => `star-grad-${Math.random().toString(36).slice(2, 9)}`;
99
+ /**
100
+ * RatingDisplay component.
101
+ *
102
+ * Star-rating display supporting fractional values and an optional
103
+ * review-count tail. When `onChange` is provided each star becomes an
104
+ * interactive button. The host IS the outer `<span>`
105
+ * (`span[mol-rating-display]`), matching React's root exactly, so the root's
106
+ * class, `role` and `aria-label` are host bindings.
107
+ *
108
+ * Uses inline SVG stars so the component works without icon-font fallback.
109
+ * Same props (React names) and same DOM as
110
+ * `@molecule/app-rating-display-react`'s `RatingDisplay`.
111
+ */
112
+ export class RatingDisplay {
113
+ /** Rating value (0–max). Fractional supported. */
114
+ value;
115
+ /** Maximum rating (defaults to 5 at read time). */
116
+ max;
117
+ /** Optional review count shown after the stars. */
118
+ reviewCount;
119
+ /** Called when the review-count is clicked; receives the DOM click event. */
120
+ onReviewsClick;
121
+ /** Size preset (defaults to `'md'` at read time). */
122
+ size;
123
+ /** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
124
+ onChange;
125
+ /** Accessible label override. */
126
+ ariaLabel;
127
+ /** Extra classes. */
128
+ className;
129
+ /** The star's single SVG path. */
130
+ path = STAR_PATH;
131
+ /**
132
+ * The current class map.
133
+ * @returns The UIClassMap.
134
+ */
135
+ cm() {
136
+ return getClassMap();
137
+ }
138
+ /**
139
+ * The effective maximum (React's default parameter: a later-bound write of
140
+ * `undefined` must not erase the `5` default).
141
+ * @returns The maximum rating.
142
+ */
143
+ maxValue() {
144
+ return this.max ?? 5;
145
+ }
146
+ /**
147
+ * The star size in pixels (React's `SIZE_PX[size]`, which is `undefined` for
148
+ * an unknown size so both axes are omitted).
149
+ * @returns The pixel size.
150
+ */
151
+ px() {
152
+ return SIZE_PX[this.size ?? 'md'];
153
+ }
154
+ /**
155
+ * One render state per star: its index, its fractional fill and its gradient
156
+ * id (minted per render, as React mints one per star per render).
157
+ * @returns The star states.
158
+ */
159
+ stars() {
160
+ return Array.from({ length: this.maxValue() }, (_value, i) => ({
161
+ i,
162
+ fill: Math.max(0, Math.min(1, this.value - i)),
163
+ id: starId(),
164
+ }));
165
+ }
166
+ /**
167
+ * The gradient stop offset for a fill fraction.
168
+ * @param fill - Star fill fraction (0–1).
169
+ * @returns The percentage offset.
170
+ */
171
+ offset(fill) {
172
+ return `${fill * 100}%`;
173
+ }
174
+ /**
175
+ * The `<path>` fill referencing the star's gradient.
176
+ * @param id - The star's gradient id.
177
+ * @returns The `url(#id)` fill.
178
+ */
179
+ fillUrl(id) {
180
+ return `url(#${id})`;
181
+ }
182
+ /**
183
+ * The per-star button label in interactive mode.
184
+ * @param i - Star index (0-based).
185
+ * @returns The accessible label.
186
+ */
187
+ rateLabel(i) {
188
+ return `Rate ${i + 1} of ${this.maxValue()}`;
189
+ }
190
+ /**
191
+ * Calls `onChange` with the rating a clicked star selects.
192
+ * @param i - Star index (0-based).
193
+ */
194
+ select(i) {
195
+ this.onChange?.(i + 1);
196
+ }
197
+ /**
198
+ * The root `<span>` class list (`cm.flex({ align: 'center', gap: 'xs' })` +
199
+ * `className`).
200
+ * @returns The class string.
201
+ */
202
+ classes() {
203
+ return this.cm().cn(this.cm().flex({ align: 'center', gap: 'xs' }), this.className);
204
+ }
205
+ /**
206
+ * The root `aria-label` (`ariaLabel`, or React's default).
207
+ * @returns The accessible label.
208
+ */
209
+ label() {
210
+ return this.ariaLabel ?? `Rating: ${this.value} of ${this.maxValue()}`;
211
+ }
212
+ /**
213
+ * The review-count button class (`cm.textSize('sm')` + `cm.link`).
214
+ * @returns The class string.
215
+ */
216
+ reviewClasses() {
217
+ return this.cm().cn(this.cm().textSize('sm'), this.cm().link);
218
+ }
219
+ /**
220
+ * The review-count text span class (`cm.textSize('sm')`).
221
+ * @returns The class string.
222
+ */
223
+ textClasses() {
224
+ return this.cm().textSize('sm');
225
+ }
226
+ static ɵfac = function RatingDisplay_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || RatingDisplay)(); };
227
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: RatingDisplay, selectors: [["span", "mol-rating-display", ""]], hostAttrs: ["role", "img"], hostVars: 3, hostBindings: function RatingDisplay_HostBindings(rf, ctx) { if (rf & 2) {
228
+ i0.ɵɵattribute("aria-label", ctx.label());
229
+ i0.ɵɵclassMap(ctx.classes());
230
+ } }, inputs: { value: "value", max: "max", reviewCount: "reviewCount", onReviewsClick: "onReviewsClick", size: "size", onChange: "onChange", ariaLabel: "ariaLabel", className: "className" }, decls: 3, vars: 1, consts: [["type", "button"], ["viewBox", "0 0 24 24", "aria-hidden", "true"], ["type", "button", 3, "click"], ["stop-color", "currentColor"], ["stop-color", "currentColor", "stop-opacity", "0.25"], ["type", "button", 3, "class"], [3, "class"]], template: function RatingDisplay_Template(rf, ctx) { if (rf & 1) {
231
+ i0.ɵɵrepeaterCreate(0, RatingDisplay_For_1_Template, 2, 1, null, null, _forTrack0);
232
+ i0.ɵɵconditionalCreate(2, RatingDisplay_Conditional_2_Template, 2, 1);
233
+ } if (rf & 2) {
234
+ i0.ɵɵrepeater(ctx.stars());
235
+ i0.ɵɵadvance(2);
236
+ i0.ɵɵconditional(ctx.reviewCount !== undefined ? 2 : -1);
237
+ } }, encapsulation: 2 });
238
+ }
239
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(RatingDisplay, [{
240
+ type: Component,
241
+ args: [{
242
+ selector: 'span[mol-rating-display]',
243
+ standalone: true,
244
+ inputs: [
245
+ 'value',
246
+ 'max',
247
+ 'reviewCount',
248
+ 'onReviewsClick',
249
+ 'size',
250
+ 'onChange',
251
+ 'ariaLabel',
252
+ 'className',
253
+ ],
254
+ host: {
255
+ role: 'img',
256
+ '[class]': 'classes()',
257
+ '[attr.aria-label]': 'label()',
258
+ },
259
+ template: `@for (star of stars(); track star.i) {
260
+ @if (onChange) {
261
+ <button type="button" (click)="select(star.i)" [attr.aria-label]="rateLabel(star.i)">
262
+ <svg [attr.width]="px()" [attr.height]="px()" viewBox="0 0 24 24" aria-hidden="true">
263
+ <defs>
264
+ <linearGradient [attr.id]="star.id">
265
+ <stop [attr.offset]="offset(star.fill)" stop-color="currentColor"></stop>
266
+ <stop
267
+ [attr.offset]="offset(star.fill)"
268
+ stop-color="currentColor"
269
+ stop-opacity="0.25"
270
+ ></stop>
271
+ </linearGradient>
272
+ </defs>
273
+ <path [attr.d]="path" [attr.fill]="fillUrl(star.id)"></path>
274
+ </svg>
275
+ </button>
276
+ } @else {
277
+ <svg [attr.width]="px()" [attr.height]="px()" viewBox="0 0 24 24" aria-hidden="true">
278
+ <defs>
279
+ <linearGradient [attr.id]="star.id">
280
+ <stop [attr.offset]="offset(star.fill)" stop-color="currentColor"></stop>
281
+ <stop
282
+ [attr.offset]="offset(star.fill)"
283
+ stop-color="currentColor"
284
+ stop-opacity="0.25"
285
+ ></stop>
286
+ </linearGradient>
287
+ </defs>
288
+ <path [attr.d]="path" [attr.fill]="fillUrl(star.id)"></path>
289
+ </svg>
290
+ }
291
+ }
292
+ @if (reviewCount !== undefined) {
293
+ @if (onReviewsClick) {
294
+ <button type="button" (click)="onReviewsClick($event)" [class]="reviewClasses()">
295
+ ({{ reviewCount }})
296
+ </button>
297
+ } @else {
298
+ <span [class]="textClasses()">({{ reviewCount }})</span>
299
+ }
300
+ }`,
301
+ }]
302
+ }], null, null); })();
303
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(RatingDisplay, { className: "RatingDisplay", filePath: "rating-display.component.ts", lineNumber: 110 }); })();
304
+ //# sourceMappingURL=rating-display.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rating-display.component.js","sourceRoot":"","sources":["../src/rating-display.component.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Types of `@molecule/app-rating-display-angular` — the Angular counterpart of
3
+ * `@molecule/app-rating-display-react`: the same props (React names) and the
4
+ * same DOM for the same input.
5
+ *
6
+ * @module
7
+ */
8
+ /**
9
+ * Props accepted by {@link RatingDisplay} — the same props
10
+ * `@molecule/app-rating-display-react` accepts. Every one is an input:
11
+ * `onReviewsClick` and `onChange` are inputs holding the callback functions
12
+ * React takes as props.
13
+ */
14
+ export interface RatingDisplayProps {
15
+ /** Rating value (0–max). Fractional supported. */
16
+ value: number;
17
+ /** Maximum rating. Defaults to 5. */
18
+ max?: number;
19
+ /** Optional review count shown after the stars. */
20
+ reviewCount?: number;
21
+ /**
22
+ * Called when the review-count is clicked (renders it as a button). React
23
+ * passes the click event, so this receives it too.
24
+ */
25
+ onReviewsClick?: (event?: MouseEvent) => void;
26
+ /** Size preset. */
27
+ size?: 'sm' | 'md' | 'lg';
28
+ /** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
29
+ onChange?: (value: number) => void;
30
+ /** Accessible label override. */
31
+ ariaLabel?: string;
32
+ /** Extra classes. */
33
+ className?: string;
34
+ }
35
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,qCAAqC;IACrC,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,mDAAmD;IACnD,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;IAC7C,mBAAmB;IACnB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;IACzB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAClC,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
package/dist/types.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Types of `@molecule/app-rating-display-angular` — the Angular counterpart of
3
+ * `@molecule/app-rating-display-react`: the same props (React names) and the
4
+ * same DOM for the same input.
5
+ *
6
+ * @module
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@molecule/app-rating-display-angular",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1-stage",
4
+ "description": "Read-only and interactive star rating display with half-star support",
5
+ "homepage": "https://www.molecule.dev/packages/app-rating-display-angular",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "ngc",
21
+ "dev": "ngc --watch",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest"
24
+ },
25
+ "keywords": [
26
+ "molecule",
27
+ "rating-display",
28
+ "angular"
29
+ ],
30
+ "author": "Molecule Dev, Inc. (https://molecule.dev)",
31
+ "license": "Apache-2.0",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/molecule-dev/molecule.git",
35
+ "directory": "packages/app/features/rating-display-angular"
36
+ },
37
+ "engines": {
38
+ "node": ">=20"
39
+ },
40
+ "bugs": "https://github.com/molecule-dev/molecule/issues",
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "peerDependencies": {
45
+ "@angular/common": "^22.0.0",
46
+ "@angular/core": "^22.0.0",
47
+ "@angular/platform-browser": "^22.0.0",
48
+ "@molecule/app-angular": "^3.5.0",
49
+ "@molecule/app-ui": "^1.0.1",
50
+ "@molecule/app-ui-angular": "^1.1.0"
51
+ },
52
+ "devDependencies": {
53
+ "@angular/common": "22.2.3",
54
+ "@angular/compiler": "22.2.3",
55
+ "@angular/compiler-cli": "22.2.3",
56
+ "@angular/core": "22.2.3",
57
+ "@angular/platform-browser": "22.2.3",
58
+ "@molecule/app-angular": "3.6.0",
59
+ "@molecule/app-framework-conformance": "0.0.0",
60
+ "@molecule/app-i18n": "1.2.1",
61
+ "@molecule/app-icons": "1.0.4",
62
+ "@molecule/app-ui": "1.3.11",
63
+ "@molecule/app-ui-angular": "1.1.2",
64
+ "@types/node": "26.6.5",
65
+ "jsdom": "30.1.3",
66
+ "rxjs": "7.8.2",
67
+ "typescript": "6.0.3",
68
+ "vitest": "4.1.12",
69
+ "zone.js": "0.16.3"
70
+ }
71
+ }