@italia/rating 1.0.0-alpha.10
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/AUTHORS +3 -0
- package/LICENSE +11 -0
- package/README.md +166 -0
- package/custom-elements.json +426 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/it-rating-item.d.ts +33 -0
- package/dist/src/it-rating-item.d.ts.map +1 -0
- package/dist/src/it-rating-item.js +456 -0
- package/dist/src/it-rating-item.js.map +1 -0
- package/dist/src/it-rating.d.ts +61 -0
- package/dist/src/it-rating.d.ts.map +1 -0
- package/dist/src/it-rating.js +567 -0
- package/dist/src/it-rating.js.map +1 -0
- package/dist/src/locales/it.d.ts +4 -0
- package/dist/src/locales/it.d.ts.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-Cv888lzs.js';
|
|
2
|
+
import { css, html } from 'lit';
|
|
3
|
+
import { customElement } from 'lit/decorators.js';
|
|
4
|
+
import { ItRadio } from '@italia/radio';
|
|
5
|
+
import '@italia/icon';
|
|
6
|
+
|
|
7
|
+
var styles = css`@charset "UTF-8";
|
|
8
|
+
/***************************** 1 ****************************************/
|
|
9
|
+
/***************************** 2 ****************************************/
|
|
10
|
+
/***************************** 1 ****************************************/
|
|
11
|
+
/***************************** 2 ****************************************/
|
|
12
|
+
/***************************** 1 ****************************************/
|
|
13
|
+
/***************************** 2 ****************************************/
|
|
14
|
+
/***************************** 3 ****************************************/
|
|
15
|
+
/***************************** 1 ****************************************/
|
|
16
|
+
/***************************** 2 ****************************************/
|
|
17
|
+
/***************************** 3 ****************************************/
|
|
18
|
+
/***************************** NEUTRAL 1 ****************************************/
|
|
19
|
+
/***************************** NEUTRAL 2 ****************************************/
|
|
20
|
+
/***************************** NEUTRAL 2 / 3 ****************************************/
|
|
21
|
+
*,
|
|
22
|
+
*::before,
|
|
23
|
+
*::after {
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
28
|
+
:root {
|
|
29
|
+
scroll-behavior: smooth;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
body {
|
|
34
|
+
margin: 0;
|
|
35
|
+
-webkit-text-size-adjust: 100%;
|
|
36
|
+
-webkit-tap-highlight-color: hsla(0, 0%, 0%, 0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
hr {
|
|
40
|
+
margin: 1rem 0;
|
|
41
|
+
color: inherit;
|
|
42
|
+
border: 0;
|
|
43
|
+
border-top: 1px solid;
|
|
44
|
+
opacity: 0.25;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
p {
|
|
48
|
+
margin-top: 0;
|
|
49
|
+
margin-bottom: var(--bsi-paragraph-spacing);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
abbr[title] {
|
|
53
|
+
text-decoration: underline dotted;
|
|
54
|
+
cursor: help;
|
|
55
|
+
text-decoration-skip-ink: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
address {
|
|
59
|
+
margin-bottom: var(--bsi-spacing-s);
|
|
60
|
+
font-style: normal;
|
|
61
|
+
line-height: inherit;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ol,
|
|
65
|
+
ul {
|
|
66
|
+
padding-left: var(--bsi-spacing-l);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
ol,
|
|
70
|
+
ul,
|
|
71
|
+
dl {
|
|
72
|
+
margin-top: 0;
|
|
73
|
+
margin-bottom: var(--bsi-spacing-s);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
ol ol,
|
|
77
|
+
ul ul,
|
|
78
|
+
ol ul,
|
|
79
|
+
ul ol {
|
|
80
|
+
margin-bottom: 0;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
dt {
|
|
84
|
+
font-weight: var(--bsi-font-weight-strong);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
dd {
|
|
88
|
+
margin-bottom: var(--bsi-spacing-xxs);
|
|
89
|
+
margin-left: 0;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
blockquote {
|
|
93
|
+
margin: 0 0 var(--bsi-spacing-s);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
sub,
|
|
97
|
+
sup {
|
|
98
|
+
position: relative;
|
|
99
|
+
font-size: var(--bsi-font-size-1);
|
|
100
|
+
line-height: 0;
|
|
101
|
+
vertical-align: baseline;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
sub {
|
|
105
|
+
bottom: -0.25em;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
sup {
|
|
109
|
+
top: -0.5em;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
a {
|
|
113
|
+
color: var(--bsi-color-link);
|
|
114
|
+
text-decoration: underline;
|
|
115
|
+
text-decoration-skip-ink: auto;
|
|
116
|
+
text-underline-offset: 2px;
|
|
117
|
+
}
|
|
118
|
+
a:hover {
|
|
119
|
+
color: var(--bsi-color-link-hover);
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
pre,
|
|
124
|
+
code,
|
|
125
|
+
kbd,
|
|
126
|
+
samp {
|
|
127
|
+
font-size: 1em;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
pre {
|
|
131
|
+
display: block;
|
|
132
|
+
margin-top: 0;
|
|
133
|
+
margin-bottom: var(--bsi-paragraph-spacing);
|
|
134
|
+
overflow: auto;
|
|
135
|
+
}
|
|
136
|
+
pre code {
|
|
137
|
+
word-break: normal;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
a > code {
|
|
141
|
+
color: inherit;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
figure {
|
|
145
|
+
margin: 0 0 1rem;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
img,
|
|
149
|
+
svg {
|
|
150
|
+
vertical-align: middle;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
table {
|
|
154
|
+
caption-side: bottom;
|
|
155
|
+
border-collapse: collapse;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
caption {
|
|
159
|
+
padding-top: 0.5rem;
|
|
160
|
+
padding-bottom: 0.5rem;
|
|
161
|
+
color: hsl(210, 17%, 44%);
|
|
162
|
+
text-align: left;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
th {
|
|
166
|
+
text-align: inherit;
|
|
167
|
+
text-align: -webkit-match-parent;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
thead,
|
|
171
|
+
tbody,
|
|
172
|
+
tfoot,
|
|
173
|
+
tr,
|
|
174
|
+
td,
|
|
175
|
+
th {
|
|
176
|
+
border-color: inherit;
|
|
177
|
+
border-style: solid;
|
|
178
|
+
border-width: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
label {
|
|
182
|
+
display: inline-block;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
button {
|
|
186
|
+
border-radius: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
button:focus:not(:focus-visible) {
|
|
190
|
+
outline: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
input,
|
|
194
|
+
button,
|
|
195
|
+
select,
|
|
196
|
+
optgroup,
|
|
197
|
+
textarea {
|
|
198
|
+
margin: 0;
|
|
199
|
+
font-family: inherit;
|
|
200
|
+
font-size: inherit;
|
|
201
|
+
line-height: inherit;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
button,
|
|
205
|
+
select {
|
|
206
|
+
text-transform: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
[role=button] {
|
|
210
|
+
cursor: pointer;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
select {
|
|
214
|
+
word-wrap: normal;
|
|
215
|
+
}
|
|
216
|
+
select:disabled {
|
|
217
|
+
opacity: 1;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
[list]:not([type=date]):not([type=datetime-local]):not([type=month]):not([type=week]):not([type=time])::-webkit-calendar-picker-indicator {
|
|
221
|
+
display: none !important;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
button,
|
|
225
|
+
[type=button],
|
|
226
|
+
[type=reset],
|
|
227
|
+
[type=submit] {
|
|
228
|
+
-webkit-appearance: button;
|
|
229
|
+
}
|
|
230
|
+
button:not(:disabled),
|
|
231
|
+
[type=button]:not(:disabled),
|
|
232
|
+
[type=reset]:not(:disabled),
|
|
233
|
+
[type=submit]:not(:disabled) {
|
|
234
|
+
cursor: pointer;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
::-moz-focus-inner {
|
|
238
|
+
padding: 0;
|
|
239
|
+
border-style: none;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
textarea {
|
|
243
|
+
resize: vertical;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
fieldset {
|
|
247
|
+
min-width: 0;
|
|
248
|
+
padding: 0;
|
|
249
|
+
margin: 0;
|
|
250
|
+
border: 0;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
::-webkit-datetime-edit-fields-wrapper,
|
|
254
|
+
::-webkit-datetime-edit-text,
|
|
255
|
+
::-webkit-datetime-edit-minute,
|
|
256
|
+
::-webkit-datetime-edit-hour-field,
|
|
257
|
+
::-webkit-datetime-edit-day-field,
|
|
258
|
+
::-webkit-datetime-edit-month-field,
|
|
259
|
+
::-webkit-datetime-edit-year-field {
|
|
260
|
+
padding: 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
::-webkit-inner-spin-button {
|
|
264
|
+
height: auto;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
[type=search] {
|
|
268
|
+
outline-offset: -2px;
|
|
269
|
+
-webkit-appearance: textfield;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/* rtl:raw:
|
|
273
|
+
[type="tel"],
|
|
274
|
+
[type="url"],
|
|
275
|
+
[type="email"],
|
|
276
|
+
[type="number"] {
|
|
277
|
+
direction: ltr;
|
|
278
|
+
}
|
|
279
|
+
*/
|
|
280
|
+
::-webkit-search-decoration {
|
|
281
|
+
-webkit-appearance: none;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
::-webkit-color-swatch-wrapper {
|
|
285
|
+
padding: 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
::file-selector-button {
|
|
289
|
+
font: inherit;
|
|
290
|
+
-webkit-appearance: button;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
output {
|
|
294
|
+
display: inline-block;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
iframe {
|
|
298
|
+
border: 0;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
summary {
|
|
302
|
+
display: list-item;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
progress {
|
|
307
|
+
vertical-align: baseline;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
[hidden] {
|
|
311
|
+
display: none !important;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.visually-hidden,
|
|
315
|
+
.visually-hidden-focusable:not(:focus):not(:focus-within) {
|
|
316
|
+
position: absolute !important;
|
|
317
|
+
width: 1px !important;
|
|
318
|
+
height: 1px !important;
|
|
319
|
+
padding: 0 !important;
|
|
320
|
+
margin: -1px !important;
|
|
321
|
+
overflow: hidden !important;
|
|
322
|
+
clip: rect(0, 0, 0, 0) !important;
|
|
323
|
+
white-space: nowrap !important;
|
|
324
|
+
border: 0 !important;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:host {
|
|
328
|
+
display: inline-flex;
|
|
329
|
+
padding: 0;
|
|
330
|
+
margin: 0;
|
|
331
|
+
box-shadow: none !important;
|
|
332
|
+
cursor: pointer;
|
|
333
|
+
-webkit-focus-ring-color: transparent;
|
|
334
|
+
outline: none !important;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
:host([disabled]) {
|
|
338
|
+
cursor: not-allowed;
|
|
339
|
+
opacity: 0.6;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* Focus ring - mostra quando l'item è focalizzato via tastiera */
|
|
343
|
+
:host(:focus-visible) #star {
|
|
344
|
+
border-radius: var(--bsi-radius-xs);
|
|
345
|
+
box-shadow: 0 0 0 2px hsl(0, 0%, 100%), 0 0 0 5px hsl(0, 0%, 0%) !important;
|
|
346
|
+
outline: none;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.rating-item-control {
|
|
350
|
+
display: inline-flex;
|
|
351
|
+
align-items: center;
|
|
352
|
+
padding: 0;
|
|
353
|
+
margin: 0;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* Nascondi completamente l'input invisibile */
|
|
357
|
+
#input {
|
|
358
|
+
position: absolute;
|
|
359
|
+
overflow: hidden;
|
|
360
|
+
width: 1px;
|
|
361
|
+
height: 1px;
|
|
362
|
+
padding: 0;
|
|
363
|
+
border: 0;
|
|
364
|
+
margin: -1px;
|
|
365
|
+
clip: rect(0, 0, 0, 0);
|
|
366
|
+
white-space: nowrap;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/* Stile per l'icona stella */
|
|
370
|
+
#star {
|
|
371
|
+
display: inline-flex;
|
|
372
|
+
width: 1.5rem;
|
|
373
|
+
height: 1.5rem;
|
|
374
|
+
color: var(--bsi-form-control-label-color, #5c6f82);
|
|
375
|
+
transition: color var(--bsi-transition-instant) ease-out, transform 0.1s ease-out;
|
|
376
|
+
}
|
|
377
|
+
#star:hover {
|
|
378
|
+
transform: scale(1.1);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* Stella vuota quando non checked */
|
|
382
|
+
:host(:not([checked])) #star,
|
|
383
|
+
:host([aria-checked=false]) #star {
|
|
384
|
+
color: var(--bsi-form-control-label-color, #5c6f82);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/* Stato disabled */
|
|
388
|
+
:host([disabled]) #star {
|
|
389
|
+
cursor: not-allowed;
|
|
390
|
+
opacity: 0.6;
|
|
391
|
+
}`;
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Rating item component - extends it-radio to render a star icon
|
|
395
|
+
*
|
|
396
|
+
* @element it-rating-item
|
|
397
|
+
*
|
|
398
|
+
* @slot label - The accessibility label for the star (e.g., "Valuta 3 stelle su 5")
|
|
399
|
+
*/
|
|
400
|
+
let ItRatingItem = class ItRatingItem extends ItRadio {
|
|
401
|
+
/**
|
|
402
|
+
* Override group getter to find parent it-rating instead of it-radio-group
|
|
403
|
+
*/
|
|
404
|
+
get group() {
|
|
405
|
+
return this.closest('it-rating');
|
|
406
|
+
}
|
|
407
|
+
get icon() {
|
|
408
|
+
return this.group?.icon || 'it-star-outline';
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Override _renderInput to render icon instead of radio circle
|
|
412
|
+
* Now that _renderInput is protected in parent, we can override it
|
|
413
|
+
*/
|
|
414
|
+
_renderInput() {
|
|
415
|
+
// Get the parent rating to determine which items should be filled
|
|
416
|
+
const rating = this.closest('it-rating');
|
|
417
|
+
const ratingValue = rating ? parseInt(rating.value || '0', 10) : 0;
|
|
418
|
+
const thisValue = parseInt(this.value || '0', 10);
|
|
419
|
+
// Icon should be filled if its value is <= the rating value
|
|
420
|
+
const isFilled = thisValue <= ratingValue;
|
|
421
|
+
// Use primary color only for filled icons
|
|
422
|
+
const iconColor = isFilled ? 'primary' : 'secondary';
|
|
423
|
+
let renderedIcon = this.icon;
|
|
424
|
+
if (isFilled && this.icon === 'it-star-outline') {
|
|
425
|
+
renderedIcon = 'it-star-full';
|
|
426
|
+
}
|
|
427
|
+
return html `
|
|
428
|
+
<div id="input" part="input"></div>
|
|
429
|
+
<it-icon id="star" part="star" name="${renderedIcon}" size="sm" aria-hidden="true" color="${iconColor}"></it-icon>
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
handleSlotChange() {
|
|
433
|
+
// Notify assistive technologies of label change
|
|
434
|
+
this.labelElements.forEach((el) => {
|
|
435
|
+
el.classList.add('visually-hidden');
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Override render to use rating-specific structure
|
|
440
|
+
*/
|
|
441
|
+
render() {
|
|
442
|
+
return html `
|
|
443
|
+
<div class="rating-item-control">
|
|
444
|
+
${this._renderInput()}
|
|
445
|
+
<slot name="label" @slotchange=${this.handleSlotChange}></slot>
|
|
446
|
+
</div>
|
|
447
|
+
`;
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
ItRatingItem.styles = styles;
|
|
451
|
+
ItRatingItem = __decorate([
|
|
452
|
+
customElement('it-rating-item')
|
|
453
|
+
], ItRatingItem);
|
|
454
|
+
|
|
455
|
+
export { ItRatingItem };
|
|
456
|
+
//# sourceMappingURL=it-rating-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"it-rating-item.js","sources":["../../../src/it-rating-item.ts"],"sourcesContent":["import { html } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { ItRadio } from '@italia/radio';\nimport '@italia/icon';\n\nimport styles from './rating-item.scss';\n\n/**\n * Rating item component - extends it-radio to render a star icon\n *\n * @element it-rating-item\n *\n * @slot label - The accessibility label for the star (e.g., \"Valuta 3 stelle su 5\")\n */\n@customElement('it-rating-item')\nexport class ItRatingItem extends ItRadio {\n static override styles = styles;\n\n /**\n * Override group getter to find parent it-rating instead of it-radio-group\n */\n override get group() {\n return this.closest('it-rating');\n }\n\n get icon(): string {\n return this.group?.icon || 'it-star-outline';\n }\n\n /**\n * Override _renderInput to render icon instead of radio circle\n * Now that _renderInput is protected in parent, we can override it\n */\n protected override _renderInput() {\n // Get the parent rating to determine which items should be filled\n const rating = this.closest('it-rating');\n const ratingValue = rating ? parseInt((rating as any).value || '0', 10) : 0;\n const thisValue = parseInt(this.value || '0', 10);\n\n // Icon should be filled if its value is <= the rating value\n const isFilled = thisValue <= ratingValue;\n\n // Use primary color only for filled icons\n const iconColor = isFilled ? 'primary' : 'secondary';\n let renderedIcon = this.icon;\n if (isFilled && this.icon === 'it-star-outline') {\n renderedIcon = 'it-star-full';\n }\n\n return html`\n <div id=\"input\" part=\"input\"></div>\n <it-icon id=\"star\" part=\"star\" name=\"${renderedIcon}\" size=\"sm\" aria-hidden=\"true\" color=\"${iconColor}\"></it-icon>\n `;\n }\n\n private handleSlotChange() {\n // Notify assistive technologies of label change\n this.labelElements.forEach((el) => {\n el.classList.add('visually-hidden');\n });\n }\n\n /**\n * Override render to use rating-specific structure\n */\n override render() {\n return html`\n <div class=\"rating-item-control\">\n ${this._renderInput()}\n <slot name=\"label\" @slotchange=${this.handleSlotChange}></slot>\n </div>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'it-rating-item': ItRatingItem;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;;;;;;AAMG;AAEI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,OAAO,CAAA;AAGvC;;AAEG;AACH,IAAA,IAAa,KAAK,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;IAClC;AAEA,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,iBAAiB;IAC9C;AAEA;;;AAGG;IACgB,YAAY,GAAA;;QAE7B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QACxC,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAE,MAAc,CAAC,KAAK,IAAI,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC;AAC3E,QAAA,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,EAAE,EAAE,CAAC;;AAGjD,QAAA,MAAM,QAAQ,GAAG,SAAS,IAAI,WAAW;;QAGzC,MAAM,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW;AACpD,QAAA,IAAI,YAAY,GAAG,IAAI,CAAC,IAAI;QAC5B,IAAI,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,iBAAiB,EAAE;YAC/C,YAAY,GAAG,cAAc;QAC/B;AAEA,QAAA,OAAO,IAAI,CAAA;;AAE8B,2CAAA,EAAA,YAAY,yCAAyC,SAAS,CAAA;KACtG;IACH;IAEQ,gBAAgB,GAAA;;QAEtB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,EAAE,KAAI;AAChC,YAAA,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC;AACrC,QAAA,CAAC,CAAC;IACJ;AAEA;;AAEG;IACM,MAAM,GAAA;AACb,QAAA,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,YAAY,EAAE;AACY,uCAAA,EAAA,IAAI,CAAC,gBAAgB,CAAA;;KAEzD;IACH;;AAxDgB,YAAA,CAAA,MAAM,GAAG,MAAH;AADX,YAAY,GAAA,UAAA,CAAA;IADxB,aAAa,CAAC,gBAAgB;AAClB,CAAA,EAAA,YAAY,CA0DxB;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type PropertyValues } from 'lit';
|
|
2
|
+
import { ItRadioGroup } from '@italia/radio';
|
|
3
|
+
import { type ItRatingItem } from '@italia/rating';
|
|
4
|
+
/**
|
|
5
|
+
* Rating component - extends it-radio-group for star rating
|
|
6
|
+
*
|
|
7
|
+
* @element it-rating
|
|
8
|
+
*
|
|
9
|
+
* @slot - Contains the `<it-rating-item>` elements
|
|
10
|
+
* @slot label - The label/legend text for the rating
|
|
11
|
+
*
|
|
12
|
+
* @fires {CustomEvent} change - Emitted when the rating value changes
|
|
13
|
+
*/
|
|
14
|
+
export declare class ItRating extends ItRadioGroup {
|
|
15
|
+
static styles: import("lit").CSSResultGroup;
|
|
16
|
+
/**
|
|
17
|
+
* Get all slotted rating items
|
|
18
|
+
*/
|
|
19
|
+
protected _radios: ItRatingItem[];
|
|
20
|
+
/**
|
|
21
|
+
* Maximum number of stars (to calculate "X out of Y")
|
|
22
|
+
*/
|
|
23
|
+
maxElements: number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the rating is read-only (non-interactive)
|
|
26
|
+
*/
|
|
27
|
+
readOnly: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The icon name to use for the rating item
|
|
30
|
+
* @default 'it-star-outline'
|
|
31
|
+
*/
|
|
32
|
+
icon: string;
|
|
33
|
+
/**
|
|
34
|
+
* Sync read-only state to all rating items
|
|
35
|
+
*/
|
|
36
|
+
private _syncReadOnlyToItems;
|
|
37
|
+
/**
|
|
38
|
+
* Get the localized rating announcement for screen readers
|
|
39
|
+
*/
|
|
40
|
+
private _getRatingAnnouncement;
|
|
41
|
+
/**
|
|
42
|
+
* Override updated to refresh the rating items and announcement when value changes
|
|
43
|
+
*/
|
|
44
|
+
updated(changedProperties: PropertyValues): void;
|
|
45
|
+
/**
|
|
46
|
+
* Force re-render of all rating items to update star colors
|
|
47
|
+
* This ensures star colors reflect the current value
|
|
48
|
+
*/
|
|
49
|
+
private _updateRatingItemsDisplay;
|
|
50
|
+
/**
|
|
51
|
+
* Create or update the visually-hidden announcement element
|
|
52
|
+
* Following BSI pattern: announcement placed directly in the label slot
|
|
53
|
+
*/
|
|
54
|
+
private _ensureAnnouncement;
|
|
55
|
+
}
|
|
56
|
+
declare global {
|
|
57
|
+
interface HTMLElementTagNameMap {
|
|
58
|
+
'it-rating': ItRating;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=it-rating.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"it-rating.d.ts","sourceRoot":"","sources":["../../src/it-rating.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAOnD;;;;;;;;;GASG;AACH,qBACa,QAAS,SAAQ,YAAY;IACxC,OAAgB,MAAM,+BAAU;IAEhC;;OAEG;IAEH,SAAS,CAAC,OAAO,EAAG,YAAY,EAAE,CAAC;IAEnC;;OAEG;IAEH,WAAW,SAAK;IAEhB;;OAEG;IAEH,QAAQ,UAAS;IAEjB;;;OAGG;IAEH,IAAI,SAAqB;IAEzB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAW5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAa9B;;OAEG;IACM,OAAO,CAAC,iBAAiB,EAAE,cAAc;IA+BlD;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IAOjC;;;OAGG;IACH,OAAO,CAAC,mBAAmB;CAyB5B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
|