@italia/rating 1.0.0-alpha.5
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 +455 -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 +566 -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
package/AUTHORS
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Copyright (c) 2025, the respective contributors, as shown by the AUTHORS file.
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# \<it-rating>
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@italia/rating)
|
|
4
|
+
|
|
5
|
+
Web component per la valutazione con stelle (rating) del Design System Italia basato su Bootstrap Italia.
|
|
6
|
+
|
|
7
|
+
## Installazione
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @italia/rating
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Utilizzo Base
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script type="module">
|
|
17
|
+
import '@italia/rating';
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<it-rating name="rating" value="3">
|
|
21
|
+
<span slot="legend">Valuta questo servizio</span>
|
|
22
|
+
</it-rating>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Con Label
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<it-rating name="rating" value="4" label="Valutazione">
|
|
29
|
+
</it-rating>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Sola Lettura
|
|
33
|
+
|
|
34
|
+
```html
|
|
35
|
+
<it-rating name="rating" value="4" read-only>
|
|
36
|
+
</it-rating>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Disabilitato
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<it-rating name="rating" value="3" disabled>
|
|
43
|
+
<span slot="legend">Valutazione</span>
|
|
44
|
+
</it-rating>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Obbligatorio
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<form>
|
|
51
|
+
<it-rating name="rating" required>
|
|
52
|
+
<span slot="legend">Valuta questo contenuto (obbligatorio)</span>
|
|
53
|
+
</it-rating>
|
|
54
|
+
<button type="submit">Invia</button>
|
|
55
|
+
</form>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Proprietà
|
|
59
|
+
|
|
60
|
+
| Proprietà | Tipo | Default | Descrizione |
|
|
61
|
+
|-----------|------|---------|-------------|
|
|
62
|
+
| `name` | `string` | `''` | Nome del campo per l'invio del form |
|
|
63
|
+
| `value` | `number` | `0` | Valore corrente della valutazione (1-5) |
|
|
64
|
+
| `label` | `string` | `''` | Etichetta del rating |
|
|
65
|
+
| `disabled` | `boolean` | `false` | Se il rating è disabilitato |
|
|
66
|
+
| `read-only` | `boolean` | `false` | Se il rating è in sola lettura (non interattivo) |
|
|
67
|
+
| `required` | `boolean` | `false` | Se la selezione è obbligatoria |
|
|
68
|
+
| `max-stars` | `number` | `5` | Numero massimo di stelle |
|
|
69
|
+
|
|
70
|
+
## Eventi
|
|
71
|
+
|
|
72
|
+
### `change`
|
|
73
|
+
|
|
74
|
+
Emesso quando cambia il valore della valutazione.
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
const rating = document.querySelector('it-rating');
|
|
78
|
+
rating.addEventListener('change', (event) => {
|
|
79
|
+
console.log('Nuovo valore:', event.detail.value);
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Slot
|
|
84
|
+
|
|
85
|
+
### `legend`
|
|
86
|
+
|
|
87
|
+
Contenuto della legend del fieldset (label del rating).
|
|
88
|
+
|
|
89
|
+
```html
|
|
90
|
+
<it-rating name="rating">
|
|
91
|
+
<span slot="legend">Valuta questo servizio</span>
|
|
92
|
+
</it-rating>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Accessibilità
|
|
96
|
+
|
|
97
|
+
Il componente implementa le best practice di accessibilità:
|
|
98
|
+
|
|
99
|
+
- Utilizza `role="radiogroup"` per il gruppo di stelle
|
|
100
|
+
- Ogni stella ha `role="radio"` (quando interattivo) o `role="img"` (quando read-only)
|
|
101
|
+
- Supporto completo per la navigazione da tastiera:
|
|
102
|
+
- `Tab`: entra/esce dal rating
|
|
103
|
+
- `Frecce`: naviga tra le stelle
|
|
104
|
+
- `Home`: vai alla prima stella
|
|
105
|
+
- `End`: vai all'ultima stella
|
|
106
|
+
- `Spazio/Enter`: seleziona la stella corrente
|
|
107
|
+
- Etichette aria-label appropriate per ogni stella
|
|
108
|
+
- Supporto per screen reader con testo nascosto visualmente
|
|
109
|
+
|
|
110
|
+
## Integrazione con Form
|
|
111
|
+
|
|
112
|
+
Il componente si integra nativamente con i form HTML:
|
|
113
|
+
|
|
114
|
+
```html
|
|
115
|
+
<form id="reviewForm">
|
|
116
|
+
<it-rating name="rating" value="3" required>
|
|
117
|
+
<span slot="legend">Valutazione</span>
|
|
118
|
+
</it-rating>
|
|
119
|
+
|
|
120
|
+
<button type="submit">Invia recensione</button>
|
|
121
|
+
</form>
|
|
122
|
+
|
|
123
|
+
<script>
|
|
124
|
+
document.getElementById('reviewForm').addEventListener('submit', (e) => {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
const formData = new FormData(e.target);
|
|
127
|
+
console.log('Rating:', formData.get('rating'));
|
|
128
|
+
});
|
|
129
|
+
</script>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Validazione
|
|
133
|
+
|
|
134
|
+
Il componente supporta la validazione HTML5:
|
|
135
|
+
|
|
136
|
+
```javascript
|
|
137
|
+
const rating = document.querySelector('it-rating');
|
|
138
|
+
|
|
139
|
+
// Verifica validità
|
|
140
|
+
if (rating.checkValidity()) {
|
|
141
|
+
console.log('Rating valido');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Mostra errori di validazione
|
|
145
|
+
rating.reportValidity();
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Personalizzazione CSS
|
|
149
|
+
|
|
150
|
+
```css
|
|
151
|
+
it-rating {
|
|
152
|
+
--rating-star-size: 1.5rem;
|
|
153
|
+
--rating-star-color: #ffc107;
|
|
154
|
+
--rating-star-empty-color: #e0e0e0;
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Browser Support
|
|
159
|
+
|
|
160
|
+
- Chrome/Edge (ultimo + 1 versione precedente)
|
|
161
|
+
- Firefox (ultimo + 1 versione precedente)
|
|
162
|
+
- Safari (ultimo + 1 versione precedente)
|
|
163
|
+
|
|
164
|
+
## Licenza
|
|
165
|
+
|
|
166
|
+
BSD-3-Clause © Presidenza del Consiglio dei Ministri
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/index.ts",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": [
|
|
10
|
+
{
|
|
11
|
+
"kind": "js",
|
|
12
|
+
"name": "ItRating",
|
|
13
|
+
"declaration": {
|
|
14
|
+
"name": "ItRating",
|
|
15
|
+
"module": "./it-rating.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"kind": "js",
|
|
20
|
+
"name": "ItRatingItem",
|
|
21
|
+
"declaration": {
|
|
22
|
+
"name": "ItRatingItem",
|
|
23
|
+
"module": "./it-rating-item.js"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"kind": "javascript-module",
|
|
30
|
+
"path": "src/it-rating-item.ts",
|
|
31
|
+
"declarations": [
|
|
32
|
+
{
|
|
33
|
+
"kind": "class",
|
|
34
|
+
"description": "Rating item component - extends it-radio to render a star icon",
|
|
35
|
+
"name": "ItRatingItem",
|
|
36
|
+
"slots": [
|
|
37
|
+
{
|
|
38
|
+
"description": "The accessibility label for the star (e.g., \"Valuta 3 stelle su 5\")",
|
|
39
|
+
"name": "label"
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"members": [
|
|
43
|
+
{
|
|
44
|
+
"kind": "field",
|
|
45
|
+
"name": "group",
|
|
46
|
+
"description": "Override group getter to find parent it-rating instead of it-radio-group",
|
|
47
|
+
"readonly": true
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"kind": "field",
|
|
51
|
+
"name": "icon",
|
|
52
|
+
"type": {
|
|
53
|
+
"text": "string"
|
|
54
|
+
},
|
|
55
|
+
"readonly": true
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"kind": "method",
|
|
59
|
+
"name": "_renderInput",
|
|
60
|
+
"privacy": "protected",
|
|
61
|
+
"description": "Override _renderInput to render icon instead of radio circle\nNow that _renderInput is protected in parent, we can override it"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"kind": "method",
|
|
65
|
+
"name": "handleSlotChange",
|
|
66
|
+
"privacy": "private"
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"superclass": {
|
|
70
|
+
"name": "ItRadio",
|
|
71
|
+
"package": "@italia/radio"
|
|
72
|
+
},
|
|
73
|
+
"tagName": "it-rating-item",
|
|
74
|
+
"customElement": true
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"exports": [
|
|
78
|
+
{
|
|
79
|
+
"kind": "js",
|
|
80
|
+
"name": "ItRatingItem",
|
|
81
|
+
"declaration": {
|
|
82
|
+
"name": "ItRatingItem",
|
|
83
|
+
"module": "src/it-rating-item.ts"
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"kind": "custom-element-definition",
|
|
88
|
+
"name": "it-rating-item",
|
|
89
|
+
"declaration": {
|
|
90
|
+
"name": "ItRatingItem",
|
|
91
|
+
"module": "src/it-rating-item.ts"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"kind": "javascript-module",
|
|
98
|
+
"path": "src/it-rating.ts",
|
|
99
|
+
"declarations": [
|
|
100
|
+
{
|
|
101
|
+
"kind": "class",
|
|
102
|
+
"description": "Rating component - extends it-radio-group for star rating",
|
|
103
|
+
"name": "ItRating",
|
|
104
|
+
"slots": [
|
|
105
|
+
{
|
|
106
|
+
"description": "Contains the `<it-rating-item>` elements",
|
|
107
|
+
"name": ""
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"description": "The label/legend text for the rating",
|
|
111
|
+
"name": "label"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
"members": [
|
|
115
|
+
{
|
|
116
|
+
"kind": "field",
|
|
117
|
+
"name": "_radios",
|
|
118
|
+
"type": {
|
|
119
|
+
"text": "ItRatingItem[]"
|
|
120
|
+
},
|
|
121
|
+
"privacy": "protected",
|
|
122
|
+
"description": "Get all slotted rating items"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"kind": "field",
|
|
126
|
+
"name": "maxElements",
|
|
127
|
+
"type": {
|
|
128
|
+
"text": "number"
|
|
129
|
+
},
|
|
130
|
+
"default": "5",
|
|
131
|
+
"description": "Maximum number of stars (to calculate \"X out of Y\")",
|
|
132
|
+
"attribute": "max-elements",
|
|
133
|
+
"reflects": true
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"kind": "field",
|
|
137
|
+
"name": "readOnly",
|
|
138
|
+
"type": {
|
|
139
|
+
"text": "boolean"
|
|
140
|
+
},
|
|
141
|
+
"default": "false",
|
|
142
|
+
"description": "Whether the rating is read-only (non-interactive)",
|
|
143
|
+
"attribute": "read-only",
|
|
144
|
+
"reflects": true
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"kind": "field",
|
|
148
|
+
"name": "icon",
|
|
149
|
+
"type": {
|
|
150
|
+
"text": "string"
|
|
151
|
+
},
|
|
152
|
+
"default": "'it-star-outline'",
|
|
153
|
+
"description": "The icon name to use for the rating item",
|
|
154
|
+
"attribute": "icon",
|
|
155
|
+
"reflects": true
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"kind": "method",
|
|
159
|
+
"name": "_syncReadOnlyToItems",
|
|
160
|
+
"privacy": "private",
|
|
161
|
+
"description": "Sync read-only state to all rating items"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"kind": "method",
|
|
165
|
+
"name": "_getRatingAnnouncement",
|
|
166
|
+
"privacy": "private",
|
|
167
|
+
"return": {
|
|
168
|
+
"type": {
|
|
169
|
+
"text": "string"
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
"description": "Get the localized rating announcement for screen readers"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"kind": "method",
|
|
176
|
+
"name": "_updateRatingItemsDisplay",
|
|
177
|
+
"privacy": "private",
|
|
178
|
+
"description": "Force re-render of all rating items to update star colors\nThis ensures star colors reflect the current value"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"kind": "method",
|
|
182
|
+
"name": "_ensureAnnouncement",
|
|
183
|
+
"privacy": "private",
|
|
184
|
+
"description": "Create or update the visually-hidden announcement element\nFollowing BSI pattern: announcement placed directly in the label slot"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
"events": [
|
|
188
|
+
{
|
|
189
|
+
"type": {
|
|
190
|
+
"text": "CustomEvent"
|
|
191
|
+
},
|
|
192
|
+
"description": "Emitted when the rating value changes",
|
|
193
|
+
"name": "change"
|
|
194
|
+
}
|
|
195
|
+
],
|
|
196
|
+
"attributes": [
|
|
197
|
+
{
|
|
198
|
+
"name": "max-elements",
|
|
199
|
+
"type": {
|
|
200
|
+
"text": "number"
|
|
201
|
+
},
|
|
202
|
+
"default": "5",
|
|
203
|
+
"description": "Maximum number of stars (to calculate \"X out of Y\")",
|
|
204
|
+
"fieldName": "maxElements"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "read-only",
|
|
208
|
+
"type": {
|
|
209
|
+
"text": "boolean"
|
|
210
|
+
},
|
|
211
|
+
"default": "false",
|
|
212
|
+
"description": "Whether the rating is read-only (non-interactive)",
|
|
213
|
+
"fieldName": "readOnly"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "icon",
|
|
217
|
+
"type": {
|
|
218
|
+
"text": "string"
|
|
219
|
+
},
|
|
220
|
+
"default": "'it-star-outline'",
|
|
221
|
+
"description": "The icon name to use for the rating item",
|
|
222
|
+
"fieldName": "icon"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"superclass": {
|
|
226
|
+
"name": "ItRadioGroup",
|
|
227
|
+
"package": "@italia/radio"
|
|
228
|
+
},
|
|
229
|
+
"tagName": "it-rating",
|
|
230
|
+
"customElement": true
|
|
231
|
+
}
|
|
232
|
+
],
|
|
233
|
+
"exports": [
|
|
234
|
+
{
|
|
235
|
+
"kind": "js",
|
|
236
|
+
"name": "ItRating",
|
|
237
|
+
"declaration": {
|
|
238
|
+
"name": "ItRating",
|
|
239
|
+
"module": "src/it-rating.ts"
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"kind": "custom-element-definition",
|
|
244
|
+
"name": "it-rating",
|
|
245
|
+
"declaration": {
|
|
246
|
+
"name": "ItRating",
|
|
247
|
+
"module": "src/it-rating.ts"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"kind": "javascript-module",
|
|
254
|
+
"path": "stories/it-rating.stories.ts",
|
|
255
|
+
"declarations": [
|
|
256
|
+
{
|
|
257
|
+
"kind": "variable",
|
|
258
|
+
"name": "meta",
|
|
259
|
+
"default": "{ title: 'Componenti/Rating', tags: ['alpha', 'web-component', 'a11y-ok'], component: 'it-rating', args: { name: 'rating', value: 0, disabled: false, readOnly: false, required: false, icon: 'it-star-outline', maxElements: 5, }, argTypes: { name: { control: 'text', description: \"Nome del campo per l'invio del form\", }, value: { control: { type: 'number', min: 0, max: 5, step: 1 }, description: 'Valore corrente della valutazione (0-5, 0 = nessuna stella selezionata)', }, icon: { control: 'text', description: \"Nome dell'icona da utilizzare per gli item del rating\", table: { defaultValue: { summary: 'it-star-outline' } }, }, disabled: { control: 'boolean', type: 'boolean', description: 'Se il rating è disabilitato', table: { defaultValue: { summary: 'false' } }, }, readOnly: { name: 'read-only', control: 'boolean', type: 'boolean', description: 'Se il rating è in sola lettura (non interattivo)', table: { defaultValue: { summary: 'false' } }, }, required: { control: 'boolean', type: 'boolean', description: 'Se la selezione è obbligatoria', table: { defaultValue: { summary: 'false' } }, }, maxElements: { name: 'max-elements', control: { type: 'number', min: 1, step: 1 }, description: 'Numero massimo di elementi nel rating, per messaggi di supporto e accessibilità, modificare rispetto al default solo se si cambia il numero di elementi visualizzati rispetto al default di 5', table: { defaultValue: { summary: '5' } }, }, }, } satisfies Meta<RatingProps>"
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"kind": "variable",
|
|
263
|
+
"name": "EsempioInterattivo",
|
|
264
|
+
"type": {
|
|
265
|
+
"text": "Story"
|
|
266
|
+
},
|
|
267
|
+
"default": "{ ...meta, name: 'Esempio interattivo', tags: ['!autodocs', '!dev'], parameters: { docs: { canvas: { sourceState: 'shown', }, }, }, render: (args) => html` <it-rating name=${ifDefined(args.name || undefined)} value=${args.value.toString()} ?disabled=${args.disabled} ?read-only=${args.readOnly} ?required=${args.required} @change=${(e: CustomEvent) => { console.log('Rating changed:', (e.target as HTMLElement).getAttribute('value')); }} icon=${ifDefined(args.icon || undefined)} max-elements=${args.maxElements.toString()} > <span slot=\"label\">Valuta questo contenuto</span> <it-rating-item value=\"1\" ?checked=${args.value === 1}> <span slot=\"label\">1 stella</span> </it-rating-item> <it-rating-item value=\"2\" ?checked=${args.value === 2}> <span slot=\"label\">2 stelle</span> </it-rating-item> <it-rating-item value=\"3\" ?checked=${args.value === 3}> <span slot=\"label\">3 stelle</span> </it-rating-item> <it-rating-item value=\"4\" ?checked=${args.value === 4}> <span slot=\"label\">4 stelle</span> </it-rating-item> <it-rating-item value=\"5\" ?checked=${args.value === 5}> <span slot=\"label\">5 stelle</span> </it-rating-item> </it-rating> `, }"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"kind": "variable",
|
|
271
|
+
"name": "PersonalizzazioneDegliStili",
|
|
272
|
+
"type": {
|
|
273
|
+
"text": "Story"
|
|
274
|
+
},
|
|
275
|
+
"default": "{ name: 'Personalizzazione degli stili', tags: ['!dev'], parameters: { viewMode: 'docs', docs: { canvas: { hidden: true, sourceState: 'none' }, }, }, render: () => html`<div class=\"hide-preview\"></div>`, }"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"kind": "variable",
|
|
279
|
+
"name": "ValorePreimpostato",
|
|
280
|
+
"type": {
|
|
281
|
+
"text": "Story"
|
|
282
|
+
},
|
|
283
|
+
"default": "{ name: 'Con valore preimpostato', args: { value: 3, }, render: () => html` <it-rating name=\"rating-preset\" value=\"3\"> <span slot=\"label\">Valutazione</span> <it-rating-item value=\"1\"><span slot=\"label\">1 stella</span></it-rating-item> <it-rating-item value=\"2\"><span slot=\"label\">2 stelle</span></it-rating-item> <it-rating-item value=\"3\"><span slot=\"label\">3 stelle</span></it-rating-item> <it-rating-item value=\"4\"><span slot=\"label\">4 stelle</span></it-rating-item> <it-rating-item value=\"5\"><span slot=\"label\">5 stelle</span></it-rating-item> </it-rating> `, }"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"kind": "variable",
|
|
287
|
+
"name": "SolaLettura",
|
|
288
|
+
"type": {
|
|
289
|
+
"text": "Story"
|
|
290
|
+
},
|
|
291
|
+
"default": "{ name: 'Sola lettura', args: { value: 4, readOnly: true, }, render: () => html` <it-rating name=\"rating-readonly\" value=\"4\" read-only> <span slot=\"label\">Sola lettura</span> <it-rating-item value=\"1\"><span slot=\"label\">1 stella</span></it-rating-item> <it-rating-item value=\"2\"><span slot=\"label\">2 stelle</span></it-rating-item> <it-rating-item value=\"3\"><span slot=\"label\">3 stelle</span></it-rating-item> <it-rating-item value=\"4\" checked><span slot=\"label\">4 stelle</span></it-rating-item> <it-rating-item value=\"5\"><span slot=\"label\">5 stelle</span></it-rating-item> </it-rating> <p class=\"mt-3\">Valutazione 4 stelle su 5</p> `, }"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"kind": "variable",
|
|
295
|
+
"name": "IconePersonalizzate",
|
|
296
|
+
"type": {
|
|
297
|
+
"text": "Story"
|
|
298
|
+
},
|
|
299
|
+
"default": "{ name: 'Con icone personalizzate', args: { value: 3, }, render: () => html` <it-rating name=\"rating-check\" icon=\"it-check-circle\" value=\"4\"> <span slot=\"label\">Valutazione con check</span> <it-rating-item value=\"1\"><span slot=\"label\">1 check</span></it-rating-item> <it-rating-item value=\"2\"><span slot=\"label\">2 check</span></it-rating-item> <it-rating-item value=\"3\"><span slot=\"label\">3 check</span></it-rating-item> <it-rating-item value=\"4\"><span slot=\"label\">4 check</span></it-rating-item> <it-rating-item value=\"5\"><span slot=\"label\">5 check</span></it-rating-item> </it-rating> `, }"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"kind": "variable",
|
|
303
|
+
"name": "Obbligatorio",
|
|
304
|
+
"type": {
|
|
305
|
+
"text": "Story"
|
|
306
|
+
},
|
|
307
|
+
"default": "{ args: { value: 0, required: true, }, render: () => html` <form @submit=${(e: Event) => { e.preventDefault(); const formData = new FormData(e.target as HTMLFormElement); console.log(`Rating selezionato: ${formData.get('rating-required')}`); }} > <it-rating name=\"rating-required\" required> <span slot=\"label\">Valutazione (obbligatoria)</span> <it-rating-item value=\"1\"> <span slot=\"label\">1 stella</span> </it-rating-item> <it-rating-item value=\"2\"> <span slot=\"label\">2 stelle</span> </it-rating-item> <it-rating-item value=\"3\"> <span slot=\"label\">3 stelle</span> </it-rating-item> <it-rating-item value=\"4\"> <span slot=\"label\">4 stelle</span> </it-rating-item> <it-rating-item value=\"5\"> <span slot=\"label\">5 stelle</span> </it-rating-item> </it-rating> <it-button type=\"submit\" class=\"mt-3\" variant=\"primary\">Invia</it-button> </form> `, }"
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
"kind": "variable",
|
|
311
|
+
"name": "InForm",
|
|
312
|
+
"type": {
|
|
313
|
+
"text": "Story"
|
|
314
|
+
},
|
|
315
|
+
"default": "{ name: 'Integrazione con form', render: () => html` <form id=\"review-form\" @submit=${(e: Event) => { e.preventDefault(); const form = e.target as HTMLFormElement; const formData = new FormData(form); const data = Object.fromEntries(formData); console.log(`Form inviato! Rating: ${data.rating} Commento: ${data.comment}`); }} > <div class=\"mb-4\"> <it-rating name=\"rating\" required> <span slot=\"label\">Valuta questo servizio (obbligatorio)</span> <it-rating-item value=\"1\"> <span slot=\"label\">1 stella</span> </it-rating-item> <it-rating-item value=\"2\"> <span slot=\"label\">2 stelle</span> </it-rating-item> <it-rating-item value=\"3\"> <span slot=\"label\">3 stelle</span> </it-rating-item> <it-rating-item value=\"4\"> <span slot=\"label\">4 stelle</span> </it-rating-item> <it-rating-item value=\"5\"> <span slot=\"label\">5 stelle</span> </it-rating-item> </it-rating> </div> <div class=\"mb-4\"> <div class=\"form-group\"> <label for=\"comment\">Commento</label> <it-input type=\"textarea\" id=\"comment\" name=\"comment\" class=\"form-control\" rows=\"3\" required></textarea> </div> </div> <it-button type=\"submit\" variant=\"primary\">Invia recensione</it-button> <it-button type=\"reset\" variant=\"primary\" outline>Reset</it-button> </form> <style> #review-form { max-width: 400px; } </style> `, }"
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
"kind": "variable",
|
|
319
|
+
"name": "MetodiEPropPubblici",
|
|
320
|
+
"type": {
|
|
321
|
+
"text": "Story"
|
|
322
|
+
},
|
|
323
|
+
"default": "{ ...StoryFormControlMethodAndProps('', `|\\`click()\\`| Triggera l'evento di click sull'input reale | - |`), tags: ['!dev'], }"
|
|
324
|
+
}
|
|
325
|
+
],
|
|
326
|
+
"exports": [
|
|
327
|
+
{
|
|
328
|
+
"kind": "js",
|
|
329
|
+
"name": "default",
|
|
330
|
+
"declaration": {
|
|
331
|
+
"name": "meta",
|
|
332
|
+
"module": "stories/it-rating.stories.ts"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"kind": "js",
|
|
337
|
+
"name": "EsempioInterattivo",
|
|
338
|
+
"declaration": {
|
|
339
|
+
"name": "EsempioInterattivo",
|
|
340
|
+
"module": "stories/it-rating.stories.ts"
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
"kind": "js",
|
|
345
|
+
"name": "PersonalizzazioneDegliStili",
|
|
346
|
+
"declaration": {
|
|
347
|
+
"name": "PersonalizzazioneDegliStili",
|
|
348
|
+
"module": "stories/it-rating.stories.ts"
|
|
349
|
+
}
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"kind": "js",
|
|
353
|
+
"name": "ValorePreimpostato",
|
|
354
|
+
"declaration": {
|
|
355
|
+
"name": "ValorePreimpostato",
|
|
356
|
+
"module": "stories/it-rating.stories.ts"
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"kind": "js",
|
|
361
|
+
"name": "SolaLettura",
|
|
362
|
+
"declaration": {
|
|
363
|
+
"name": "SolaLettura",
|
|
364
|
+
"module": "stories/it-rating.stories.ts"
|
|
365
|
+
}
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
"kind": "js",
|
|
369
|
+
"name": "IconePersonalizzate",
|
|
370
|
+
"declaration": {
|
|
371
|
+
"name": "IconePersonalizzate",
|
|
372
|
+
"module": "stories/it-rating.stories.ts"
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
"kind": "js",
|
|
377
|
+
"name": "Obbligatorio",
|
|
378
|
+
"declaration": {
|
|
379
|
+
"name": "Obbligatorio",
|
|
380
|
+
"module": "stories/it-rating.stories.ts"
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
"kind": "js",
|
|
385
|
+
"name": "InForm",
|
|
386
|
+
"declaration": {
|
|
387
|
+
"name": "InForm",
|
|
388
|
+
"module": "stories/it-rating.stories.ts"
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"kind": "js",
|
|
393
|
+
"name": "MetodiEPropPubblici",
|
|
394
|
+
"declaration": {
|
|
395
|
+
"name": "MetodiEPropPubblici",
|
|
396
|
+
"module": "stories/it-rating.stories.ts"
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
]
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
"kind": "javascript-module",
|
|
403
|
+
"path": "src/locales/it.ts",
|
|
404
|
+
"declarations": [
|
|
405
|
+
{
|
|
406
|
+
"kind": "variable",
|
|
407
|
+
"name": "translation",
|
|
408
|
+
"type": {
|
|
409
|
+
"text": "DefaultTranslation"
|
|
410
|
+
},
|
|
411
|
+
"default": "{ $code: 'it', $name: 'Italiano', $dir: 'ltr', noRating: 'Nessuna valutazione', ratingLabelSingle: (rating: number, max: number) => `${rating} stella su ${max}`, ratingLabelPlural: (rating: number, max: number) => `${rating} stelle su ${max}`, }"
|
|
412
|
+
}
|
|
413
|
+
],
|
|
414
|
+
"exports": [
|
|
415
|
+
{
|
|
416
|
+
"kind": "js",
|
|
417
|
+
"name": "default",
|
|
418
|
+
"declaration": {
|
|
419
|
+
"name": "translation",
|
|
420
|
+
"module": "src/locales/it.ts"
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
]
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ItRating } from './it-rating.js';
|
|
2
|
+
export { ItRatingItem } from './it-rating-item.js';
|
|
3
|
+
import '../tslib.es6-Cv888lzs.js';
|
|
4
|
+
import 'lit/decorators.js';
|
|
5
|
+
import '@italia/radio';
|
|
6
|
+
import '@italia/i18n';
|
|
7
|
+
import 'lit';
|
|
8
|
+
import '@italia/icon';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ItRadio } from '@italia/radio';
|
|
2
|
+
import '@italia/icon';
|
|
3
|
+
/**
|
|
4
|
+
* Rating item component - extends it-radio to render a star icon
|
|
5
|
+
*
|
|
6
|
+
* @element it-rating-item
|
|
7
|
+
*
|
|
8
|
+
* @slot label - The accessibility label for the star (e.g., "Valuta 3 stelle su 5")
|
|
9
|
+
*/
|
|
10
|
+
export declare class ItRatingItem extends ItRadio {
|
|
11
|
+
static styles: import("lit").CSSResultGroup;
|
|
12
|
+
/**
|
|
13
|
+
* Override group getter to find parent it-rating instead of it-radio-group
|
|
14
|
+
*/
|
|
15
|
+
get group(): import("./it-rating.js").ItRating | null;
|
|
16
|
+
get icon(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Override _renderInput to render icon instead of radio circle
|
|
19
|
+
* Now that _renderInput is protected in parent, we can override it
|
|
20
|
+
*/
|
|
21
|
+
protected _renderInput(): import("lit").TemplateResult<1>;
|
|
22
|
+
private handleSlotChange;
|
|
23
|
+
/**
|
|
24
|
+
* Override render to use rating-specific structure
|
|
25
|
+
*/
|
|
26
|
+
render(): import("lit").TemplateResult<1>;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'it-rating-item': ItRatingItem;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=it-rating-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"it-rating-item.d.ts","sourceRoot":"","sources":["../../src/it-rating-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,cAAc,CAAC;AAItB;;;;;;GAMG;AACH,qBACa,YAAa,SAAQ,OAAO;IACvC,OAAgB,MAAM,+BAAU;IAEhC;;OAEG;IACH,IAAa,KAAK,6CAEjB;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;OAGG;cACgB,YAAY;IAsB/B,OAAO,CAAC,gBAAgB;IAOxB;;OAEG;IACM,MAAM;CAQhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,YAAY,CAAC;KAChC;CACF"}
|