@vaadin/checkbox 24.4.0-dev.b3e1d14600 → 24.4.0-rc2

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.
@@ -26,6 +26,13 @@ registerStyles(
26
26
  --_focus-ring-color: var(--vaadin-focus-ring-color, var(--lumo-primary-color-50pct));
27
27
  --_focus-ring-width: var(--vaadin-focus-ring-width, 2px);
28
28
  --_selection-color: var(--vaadin-selection-color, var(--lumo-primary-color));
29
+ --_invalid-background: var(--vaadin-input-field-invalid-background, var(--lumo-error-color-10pct));
30
+ }
31
+
32
+ [part='label'] {
33
+ display: flex;
34
+ position: relative;
35
+ max-width: max-content;
29
36
  }
30
37
 
31
38
  :host([has-label]) ::slotted(label) {
@@ -35,6 +42,14 @@ registerStyles(
35
42
  );
36
43
  }
37
44
 
45
+ :host([dir='rtl'][has-label]) ::slotted(label) {
46
+ padding: var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-s);
47
+ }
48
+
49
+ :host([has-label][required]) ::slotted(label) {
50
+ padding-inline-end: var(--lumo-space-m);
51
+ }
52
+
38
53
  [part='checkbox'] {
39
54
  width: var(--_checkbox-size);
40
55
  height: var(--_checkbox-size);
@@ -77,6 +92,27 @@ registerStyles(
77
92
  opacity: 1;
78
93
  }
79
94
 
95
+ :host([readonly]:not([checked]):not([indeterminate])) {
96
+ color: var(--lumo-secondary-text-color);
97
+ }
98
+
99
+ :host([readonly]:not([checked]):not([indeterminate])) [part='checkbox'] {
100
+ background: transparent;
101
+ box-shadow: none;
102
+ }
103
+
104
+ :host([readonly]:not([checked]):not([indeterminate])) [part='checkbox']::after {
105
+ content: '';
106
+ box-sizing: border-box;
107
+ width: 100%;
108
+ height: 100%;
109
+ border-radius: inherit;
110
+ top: 0;
111
+ left: 0;
112
+ opacity: 1;
113
+ border: var(--vaadin-input-field-readonly-border, 1px dashed var(--lumo-contrast-50pct));
114
+ }
115
+
80
116
  /* Indeterminate checkmark */
81
117
  :host([indeterminate]) [part='checkbox']::after {
82
118
  content: var(--vaadin-checkbox-checkmark-char-indeterminate, '');
@@ -96,10 +132,13 @@ registerStyles(
96
132
  inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
97
133
  }
98
134
 
135
+ :host([focus-ring][readonly]:not([checked]):not([indeterminate])) [part='checkbox'] {
136
+ box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 calc(var(--_focus-ring-width) + 1px) var(--_focus-ring-color);
137
+ }
138
+
99
139
  /* Disabled */
100
140
  :host([disabled]) {
101
141
  pointer-events: none;
102
- color: var(--lumo-disabled-text-color);
103
142
  --vaadin-input-field-border-color: var(--lumo-contrast-20pct);
104
143
  }
105
144
 
@@ -115,13 +154,19 @@ registerStyles(
115
154
  color: var(--lumo-contrast-30pct);
116
155
  }
117
156
 
157
+ :host([disabled]) [part='label'],
158
+ :host([disabled]) [part='helper-text'] {
159
+ color: var(--lumo-disabled-text-color);
160
+ -webkit-text-fill-color: var(--lumo-disabled-text-color);
161
+ }
162
+
118
163
  :host([indeterminate][disabled]) [part='checkbox']::after {
119
164
  background-color: var(--lumo-contrast-30pct);
120
165
  }
121
166
 
122
- /* RTL specific styles */
123
- :host([dir='rtl'][has-label]) ::slotted(label) {
124
- padding: var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-s);
167
+ :host([readonly][checked]) [part='checkbox'],
168
+ :host([readonly][indeterminate]) [part='checkbox'] {
169
+ background-color: var(--vaadin-checkbox-readonly-checked-background, var(--lumo-contrast-70pct));
125
170
  }
126
171
 
127
172
  /* Used for activation "halo" */
@@ -139,13 +184,14 @@ registerStyles(
139
184
  }
140
185
 
141
186
  /* Hover */
142
- :host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part='checkbox'] {
187
+ :host(:not([checked]):not([indeterminate]):not([disabled]):not([readonly]):not([invalid]):hover) [part='checkbox'] {
143
188
  background: var(--vaadin-checkbox-background-hover, var(--lumo-contrast-30pct));
144
189
  }
145
190
 
146
191
  /* Disable hover for touch devices */
147
192
  @media (pointer: coarse) {
148
- :host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part='checkbox'] {
193
+ /* prettier-ignore */
194
+ :host(:not([checked]):not([indeterminate]):not([disabled]):not([readonly]):not([invalid]):hover) [part='checkbox'] {
149
195
  background: var(--vaadin-checkbox-background, var(--lumo-contrast-20pct));
150
196
  }
151
197
  }
@@ -165,6 +211,94 @@ registerStyles(
165
211
  transform: scale(0);
166
212
  opacity: 0.4;
167
213
  }
214
+
215
+ /* Required */
216
+ :host([required]) [part='required-indicator'] {
217
+ position: absolute;
218
+ top: var(--lumo-space-xs);
219
+ right: var(--lumo-space-xs);
220
+ }
221
+
222
+ :host([required][dir='rtl']) [part='required-indicator'] {
223
+ right: auto;
224
+ left: var(--lumo-space-xs);
225
+ }
226
+
227
+ :host([required]) [part='required-indicator']::after {
228
+ content: var(--lumo-required-field-indicator, '\\2022');
229
+ transition: opacity 0.2s;
230
+ color: var(--lumo-required-field-indicator-color, var(--lumo-primary-text-color));
231
+ width: 1em;
232
+ text-align: center;
233
+ }
234
+
235
+ /* Invalid */
236
+ :host([invalid]) {
237
+ --vaadin-input-field-border-color: var(--lumo-error-color);
238
+ }
239
+
240
+ :host([invalid]) [part='checkbox'] {
241
+ background: var(--_invalid-background);
242
+ background-image: linear-gradient(var(--_invalid-background) 0%, var(--_invalid-background) 100%);
243
+ }
244
+
245
+ :host([invalid]:hover) [part='checkbox'] {
246
+ background-image: linear-gradient(var(--_invalid-background) 0%, var(--_invalid-background) 100%),
247
+ linear-gradient(var(--_invalid-background) 0%, var(--_invalid-background) 100%);
248
+ }
249
+
250
+ :host([invalid][focus-ring]) {
251
+ --_focus-ring-color: var(--lumo-error-color-50pct);
252
+ }
253
+
254
+ :host([invalid]) [part='required-indicator']::after {
255
+ color: var(--lumo-required-field-indicator-color, var(--lumo-error-text-color));
256
+ }
257
+
258
+ /* Error message */
259
+ [part='error-message'] {
260
+ font-size: var(--vaadin-input-field-error-font-size, var(--lumo-font-size-xs));
261
+ line-height: var(--lumo-line-height-xs);
262
+ font-weight: var(--vaadin-input-field-error-font-weight, 400);
263
+ color: var(--vaadin-input-field-error-color, var(--lumo-error-text-color));
264
+ will-change: max-height;
265
+ transition: 0.4s max-height;
266
+ max-height: 5em;
267
+ padding-inline-start: var(--lumo-space-xs);
268
+ }
269
+
270
+ :host([has-error-message]) [part='error-message']::after,
271
+ :host([has-helper]) [part='helper-text']::after {
272
+ content: '';
273
+ display: block;
274
+ height: 0.4em;
275
+ }
276
+
277
+ :host(:not([invalid])) [part='error-message'] {
278
+ max-height: 0;
279
+ overflow: hidden;
280
+ }
281
+
282
+ /* Helper */
283
+ [part='helper-text'] {
284
+ display: block;
285
+ color: var(--vaadin-input-field-helper-color, var(--lumo-secondary-text-color));
286
+ font-size: var(--vaadin-input-field-helper-font-size, var(--lumo-font-size-xs));
287
+ line-height: var(--lumo-line-height-xs);
288
+ font-weight: var(--vaadin-input-field-helper-font-weight, 400);
289
+ margin-left: calc(var(--lumo-border-radius-m) / 4);
290
+ transition: color 0.2s;
291
+ padding-inline-start: var(--lumo-space-xs);
292
+ }
293
+
294
+ :host(:hover:not([readonly])) [part='helper-text'] {
295
+ color: var(--lumo-body-text-color);
296
+ }
297
+
298
+ :host([has-error-message]) ::slotted(label),
299
+ :host([has-helper]) ::slotted(label) {
300
+ padding-bottom: 0;
301
+ }
168
302
  `,
169
303
  { moduleId: 'lumo-checkbox' },
170
304
  );
@@ -0,0 +1,2 @@
1
+ import './vaadin-checkbox-styles.js';
2
+ import '../../src/vaadin-checkbox.js';
@@ -0,0 +1,2 @@
1
+ import './vaadin-checkbox-styles.js';
2
+ import '../../src/vaadin-lit-checkbox.js';
@@ -0,0 +1 @@
1
+ import '@vaadin/vaadin-material-styles/color.js';
@@ -15,6 +15,12 @@ registerStyles(
15
15
  --_checkbox-size: var(--vaadin-checkbox-size, 16px);
16
16
  }
17
17
 
18
+ [part='label'] {
19
+ display: flex;
20
+ position: relative;
21
+ max-width: max-content;
22
+ }
23
+
18
24
  :host([has-label]) ::slotted(label) {
19
25
  padding: 3px 12px 3px 6px;
20
26
  }
@@ -118,10 +124,62 @@ registerStyles(
118
124
  background-color: var(--material-disabled-color);
119
125
  }
120
126
 
127
+ :host([readonly][checked]) [part='checkbox'],
128
+ :host([readonly][indeterminate]) [part='checkbox'],
129
+ :host([readonly]) [part='checkbox']::before {
130
+ background-color: var(--material-secondary-text-color);
131
+ }
132
+
121
133
  /* RTL specific styles */
122
134
  :host([dir='rtl'][has-label]) ::slotted(label) {
123
135
  padding: 3px 6px 3px 12px;
124
136
  }
137
+
138
+ /* Required */
139
+ :host([required]) [part='required-indicator'] {
140
+ position: absolute;
141
+ top: 3px;
142
+ right: 2px;
143
+ }
144
+
145
+ :host([dir='rtl'][required]) [part='required-indicator'] {
146
+ right: auto;
147
+ left: 2px;
148
+ }
149
+
150
+ :host([required]:not([disabled])) [part='required-indicator'] {
151
+ color: var(--material-secondary-text-color);
152
+ }
153
+
154
+ :host([required]) [part='required-indicator']::after {
155
+ content: '*';
156
+ }
157
+
158
+ :host([invalid]) [part='required-indicator']::after {
159
+ color: var(--material-error-text-color);
160
+ }
161
+
162
+ [part='error-message'],
163
+ [part='helper-text'] {
164
+ font-size: 0.75em;
165
+ line-height: 1;
166
+ padding-left: 6px;
167
+ }
168
+
169
+ [part='error-message'] {
170
+ color: var(--material-error-text-color);
171
+ }
172
+
173
+ [part='helper-text'] {
174
+ color: var(--material-secondary-text-color);
175
+ }
176
+
177
+ :host([has-error-message]) [part='error-message']::before,
178
+ :host([has-helper]) [part='helper-text']::before {
179
+ content: '';
180
+ display: block;
181
+ height: 6px;
182
+ }
125
183
  `,
126
184
  { moduleId: 'material-checkbox' },
127
185
  );
@@ -0,0 +1,2 @@
1
+ import './vaadin-checkbox-styles.js';
2
+ import '../../src/vaadin-checkbox.js';
@@ -0,0 +1,2 @@
1
+ import './vaadin-checkbox-styles.js';
2
+ import '../../src/vaadin-lit-checkbox.js';
package/web-types.json ADDED
@@ -0,0 +1,355 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/web-types",
3
+ "name": "@vaadin/checkbox",
4
+ "version": "24.4.0-rc2",
5
+ "description-markup": "markdown",
6
+ "contributions": {
7
+ "html": {
8
+ "elements": [
9
+ {
10
+ "name": "vaadin-checkbox",
11
+ "description": "`<vaadin-checkbox>` is an input field representing a binary choice.\n\n```html\n<vaadin-checkbox label=\"I accept the terms and conditions\"></vaadin-checkbox>\n```\n\n### Styling\n\nThe following shadow DOM parts are available for styling:\n\nPart name | Description\n---------------------|-------------\n`checkbox` | The element representing a stylable custom checkbox\n`label` | The slotted label element wrapper\n`helper-text` | The slotted helper text element wrapper\n`error-message` | The slotted error message element wrapper\n`required-indicator` | The `required` state indicator element\n\nThe following state attributes are available for styling:\n\nAttribute | Description\n---------------------|-------------\n`active` | Set when the checkbox is activated with mouse, touch or the keyboard.\n`checked` | Set when the checkbox is checked.\n`disabled` | Set when the checkbox is disabled.\n`readonly` | Set when the checkbox is readonly.\n`focus-ring` | Set when the checkbox is focused using the keyboard.\n`focused` | Set when the checkbox is focused.\n`indeterminate` | Set when the checkbox is in the indeterminate state.\n`invalid` | Set when the checkbox is invalid.\n`has-label` | Set when the checkbox has a label.\n`has-helper` | Set when the checkbox has helper text.\n`has-error-message` | Set when the checkbox has an error message.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.",
12
+ "attributes": [
13
+ {
14
+ "name": "disabled",
15
+ "description": "If true, the user cannot interact with this element.",
16
+ "value": {
17
+ "type": [
18
+ "boolean",
19
+ "null",
20
+ "undefined"
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "name": "value",
26
+ "description": "The value of the field.",
27
+ "value": {
28
+ "type": [
29
+ "string",
30
+ "null",
31
+ "undefined"
32
+ ]
33
+ }
34
+ },
35
+ {
36
+ "name": "checked",
37
+ "description": "True if the element is checked.",
38
+ "value": {
39
+ "type": [
40
+ "boolean"
41
+ ]
42
+ }
43
+ },
44
+ {
45
+ "name": "autofocus",
46
+ "description": "Specify that this control should have input focus when the page loads.",
47
+ "value": {
48
+ "type": [
49
+ "boolean",
50
+ "null",
51
+ "undefined"
52
+ ]
53
+ }
54
+ },
55
+ {
56
+ "name": "label",
57
+ "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
58
+ "value": {
59
+ "type": [
60
+ "string",
61
+ "null",
62
+ "undefined"
63
+ ]
64
+ }
65
+ },
66
+ {
67
+ "name": "invalid",
68
+ "description": "Set to true when the field is invalid.",
69
+ "value": {
70
+ "type": [
71
+ "boolean",
72
+ "null",
73
+ "undefined"
74
+ ]
75
+ }
76
+ },
77
+ {
78
+ "name": "required",
79
+ "description": "Specifies that the user must fill in a value.",
80
+ "value": {
81
+ "type": [
82
+ "boolean",
83
+ "null",
84
+ "undefined"
85
+ ]
86
+ }
87
+ },
88
+ {
89
+ "name": "error-message",
90
+ "description": "Error to show when the field is invalid.",
91
+ "value": {
92
+ "type": [
93
+ "string",
94
+ "null",
95
+ "undefined"
96
+ ]
97
+ }
98
+ },
99
+ {
100
+ "name": "helper-text",
101
+ "description": "String used for the helper text.",
102
+ "value": {
103
+ "type": [
104
+ "string",
105
+ "null",
106
+ "undefined"
107
+ ]
108
+ }
109
+ },
110
+ {
111
+ "name": "accessible-name",
112
+ "description": "String used to label the component to screen reader users.",
113
+ "value": {
114
+ "type": [
115
+ "string",
116
+ "null",
117
+ "undefined"
118
+ ]
119
+ }
120
+ },
121
+ {
122
+ "name": "accessible-name-ref",
123
+ "description": "Id of the element used as label of the component to screen reader users.",
124
+ "value": {
125
+ "type": [
126
+ "string",
127
+ "null",
128
+ "undefined"
129
+ ]
130
+ }
131
+ },
132
+ {
133
+ "name": "indeterminate",
134
+ "description": "True if the checkbox is in the indeterminate state which means\nit is not possible to say whether it is checked or unchecked.\nThe state is reset once the user switches the checkbox by hand.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes",
135
+ "value": {
136
+ "type": [
137
+ "boolean"
138
+ ]
139
+ }
140
+ },
141
+ {
142
+ "name": "name",
143
+ "description": "The name of the checkbox.",
144
+ "value": {
145
+ "type": [
146
+ "string"
147
+ ]
148
+ }
149
+ },
150
+ {
151
+ "name": "readonly",
152
+ "description": "When true, the user cannot modify the value of the checkbox.\nThe difference between `disabled` and `readonly` is that the\nread-only checkbox remains focusable, is announced by screen\nreaders and its value can be submitted as part of the form.",
153
+ "value": {
154
+ "type": [
155
+ "boolean",
156
+ "null",
157
+ "undefined"
158
+ ]
159
+ }
160
+ },
161
+ {
162
+ "name": "theme",
163
+ "description": "The theme variants to apply to the component.",
164
+ "value": {
165
+ "type": [
166
+ "string",
167
+ "null",
168
+ "undefined"
169
+ ]
170
+ }
171
+ }
172
+ ],
173
+ "js": {
174
+ "properties": [
175
+ {
176
+ "name": "disabled",
177
+ "description": "If true, the user cannot interact with this element.",
178
+ "value": {
179
+ "type": [
180
+ "boolean",
181
+ "null",
182
+ "undefined"
183
+ ]
184
+ }
185
+ },
186
+ {
187
+ "name": "value",
188
+ "description": "The value of the field.",
189
+ "value": {
190
+ "type": [
191
+ "string",
192
+ "null",
193
+ "undefined"
194
+ ]
195
+ }
196
+ },
197
+ {
198
+ "name": "checked",
199
+ "description": "True if the element is checked.",
200
+ "value": {
201
+ "type": [
202
+ "boolean"
203
+ ]
204
+ }
205
+ },
206
+ {
207
+ "name": "autofocus",
208
+ "description": "Specify that this control should have input focus when the page loads.",
209
+ "value": {
210
+ "type": [
211
+ "boolean",
212
+ "null",
213
+ "undefined"
214
+ ]
215
+ }
216
+ },
217
+ {
218
+ "name": "label",
219
+ "description": "The label text for the input node.\nWhen no light dom defined via [slot=label], this value will be used.",
220
+ "value": {
221
+ "type": [
222
+ "string",
223
+ "null",
224
+ "undefined"
225
+ ]
226
+ }
227
+ },
228
+ {
229
+ "name": "invalid",
230
+ "description": "Set to true when the field is invalid.",
231
+ "value": {
232
+ "type": [
233
+ "boolean",
234
+ "null",
235
+ "undefined"
236
+ ]
237
+ }
238
+ },
239
+ {
240
+ "name": "required",
241
+ "description": "Specifies that the user must fill in a value.",
242
+ "value": {
243
+ "type": [
244
+ "boolean",
245
+ "null",
246
+ "undefined"
247
+ ]
248
+ }
249
+ },
250
+ {
251
+ "name": "errorMessage",
252
+ "description": "Error to show when the field is invalid.",
253
+ "value": {
254
+ "type": [
255
+ "string",
256
+ "null",
257
+ "undefined"
258
+ ]
259
+ }
260
+ },
261
+ {
262
+ "name": "helperText",
263
+ "description": "String used for the helper text.",
264
+ "value": {
265
+ "type": [
266
+ "string",
267
+ "null",
268
+ "undefined"
269
+ ]
270
+ }
271
+ },
272
+ {
273
+ "name": "accessibleName",
274
+ "description": "String used to label the component to screen reader users.",
275
+ "value": {
276
+ "type": [
277
+ "string",
278
+ "null",
279
+ "undefined"
280
+ ]
281
+ }
282
+ },
283
+ {
284
+ "name": "accessibleNameRef",
285
+ "description": "Id of the element used as label of the component to screen reader users.",
286
+ "value": {
287
+ "type": [
288
+ "string",
289
+ "null",
290
+ "undefined"
291
+ ]
292
+ }
293
+ },
294
+ {
295
+ "name": "indeterminate",
296
+ "description": "True if the checkbox is in the indeterminate state which means\nit is not possible to say whether it is checked or unchecked.\nThe state is reset once the user switches the checkbox by hand.\n\nhttps://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes",
297
+ "value": {
298
+ "type": [
299
+ "boolean"
300
+ ]
301
+ }
302
+ },
303
+ {
304
+ "name": "name",
305
+ "description": "The name of the checkbox.",
306
+ "value": {
307
+ "type": [
308
+ "string"
309
+ ]
310
+ }
311
+ },
312
+ {
313
+ "name": "readonly",
314
+ "description": "When true, the user cannot modify the value of the checkbox.\nThe difference between `disabled` and `readonly` is that the\nread-only checkbox remains focusable, is announced by screen\nreaders and its value can be submitted as part of the form.",
315
+ "value": {
316
+ "type": [
317
+ "boolean",
318
+ "null",
319
+ "undefined"
320
+ ]
321
+ }
322
+ }
323
+ ],
324
+ "events": [
325
+ {
326
+ "name": "validated",
327
+ "description": "Fired whenever the field is validated."
328
+ },
329
+ {
330
+ "name": "change",
331
+ "description": "Fired when the checkbox is checked or unchecked by the user."
332
+ },
333
+ {
334
+ "name": "value-changed",
335
+ "description": "Fired when the `value` property changes."
336
+ },
337
+ {
338
+ "name": "checked-changed",
339
+ "description": "Fired when the `checked` property changes."
340
+ },
341
+ {
342
+ "name": "invalid-changed",
343
+ "description": "Fired when the `invalid` property changes."
344
+ },
345
+ {
346
+ "name": "indeterminate-changed",
347
+ "description": "Fired when the `indeterminate` property changes."
348
+ }
349
+ ]
350
+ }
351
+ }
352
+ ]
353
+ }
354
+ }
355
+ }