@everymatrix/general-input 1.28.7 → 1.28.8
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/dist/cjs/checkbox-group-input_10.cjs.entry.js +12517 -13047
- package/dist/components/active-mixin.js +6 -6
- package/dist/components/checkbox-group-input2.js +307 -260
- package/dist/components/date-input2.js +2206 -3449
- package/dist/components/field-mixin.js +2512 -2226
- package/dist/components/input-field-shared-styles.js +211 -308
- package/dist/components/password-input2.js +72 -119
- package/dist/components/pattern-mixin.js +85 -0
- package/dist/components/vaadin-button.js +73 -102
- package/dist/components/vaadin-combo-box.js +808 -991
- package/dist/components/virtual-keyboard-controller.js +1768 -1111
- package/dist/esm/checkbox-group-input_10.entry.js +12517 -13047
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-6958a2a8.entry.js +3581 -0
- package/package.json +1 -1
- package/dist/general-input/p-765941e7.entry.js +0 -3646
- /package/dist/types/Users/{adrian.pripon/Documents/Work → sebastian.strulea/Documents/work}/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
2
2
|
import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
|
|
3
|
-
import { r as registerStyles, i, d as dedupingMixin, D as DelegateStateMixin, a as DisabledMixin, I as InputMixin, L as LabelMixin,
|
|
3
|
+
import { r as registerStyles, i, d as dedupingMixin, D as DelegateStateMixin, a as DisabledMixin, I as InputMixin, b as isElementFocused, L as LabelMixin, c as DelegateFocusMixin, E as ElementMixin, T as ThemableMixin, C as ControllerMixin, P as PolymerElement, h as html, e as InputController, f as LabelledInputController, g as TooltipController, j as requiredField, k as helper, F as FieldMixin, l as FocusMixin, m as FlattenedNodesObserver } from './field-mixin.js';
|
|
4
4
|
import { A as ActiveMixin } from './active-mixin.js';
|
|
5
5
|
|
|
6
6
|
registerStyles(
|
|
@@ -36,13 +36,6 @@ registerStyles(
|
|
|
36
36
|
background-color: var(--lumo-contrast-20pct);
|
|
37
37
|
transition: transform 0.2s cubic-bezier(0.12, 0.32, 0.54, 2), background-color 0.15s;
|
|
38
38
|
cursor: var(--lumo-clickable-cursor);
|
|
39
|
-
/* Default field border color */
|
|
40
|
-
--_input-border-color: var(--vaadin-input-field-border-color, var(--lumo-contrast-50pct));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
:host([indeterminate]),
|
|
44
|
-
:host([checked]) {
|
|
45
|
-
--vaadin-input-field-border-color: transparent;
|
|
46
39
|
}
|
|
47
40
|
|
|
48
41
|
:host([indeterminate]) [part='checkbox'],
|
|
@@ -84,15 +77,13 @@ registerStyles(
|
|
|
84
77
|
|
|
85
78
|
/* Focus ring */
|
|
86
79
|
:host([focus-ring]) [part='checkbox'] {
|
|
87
|
-
box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct)
|
|
88
|
-
inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
|
|
80
|
+
box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
|
|
89
81
|
}
|
|
90
82
|
|
|
91
83
|
/* Disabled */
|
|
92
84
|
:host([disabled]) {
|
|
93
85
|
pointer-events: none;
|
|
94
86
|
color: var(--lumo-disabled-text-color);
|
|
95
|
-
--vaadin-input-field-border-color: var(--lumo-contrast-20pct);
|
|
96
87
|
}
|
|
97
88
|
|
|
98
89
|
:host([disabled]) ::slotted(label) {
|
|
@@ -163,7 +154,7 @@ registerStyles(
|
|
|
163
154
|
|
|
164
155
|
/**
|
|
165
156
|
* @license
|
|
166
|
-
* Copyright (c) 2021 -
|
|
157
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
167
158
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
168
159
|
*/
|
|
169
160
|
|
|
@@ -206,6 +197,12 @@ const CheckedMixin = dedupingMixin(
|
|
|
206
197
|
const input = event.target;
|
|
207
198
|
|
|
208
199
|
this._toggleChecked(input.checked);
|
|
200
|
+
|
|
201
|
+
// Clicking the checkbox or radio-button in Safari
|
|
202
|
+
// does not make it focused, so we do it manually.
|
|
203
|
+
if (!isElementFocused(input)) {
|
|
204
|
+
input.focus();
|
|
205
|
+
}
|
|
209
206
|
}
|
|
210
207
|
|
|
211
208
|
/** @protected */
|
|
@@ -217,226 +214,134 @@ const CheckedMixin = dedupingMixin(
|
|
|
217
214
|
|
|
218
215
|
/**
|
|
219
216
|
* @license
|
|
220
|
-
* Copyright (c)
|
|
217
|
+
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
221
218
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
222
219
|
*/
|
|
223
220
|
|
|
224
221
|
/**
|
|
225
|
-
* A
|
|
226
|
-
*
|
|
227
|
-
* @polymerMixin
|
|
228
|
-
* @mixes ActiveMixin
|
|
229
|
-
* @mixes CheckedMixin
|
|
230
|
-
* @mixes DelegateFocusMixin
|
|
231
|
-
* @mixes LabelMixin
|
|
222
|
+
* A controller to copy the content from a source slot to a target element.
|
|
232
223
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
static get properties() {
|
|
236
|
-
return {
|
|
237
|
-
/**
|
|
238
|
-
* True if the checkbox is in the indeterminate state which means
|
|
239
|
-
* it is not possible to say whether it is checked or unchecked.
|
|
240
|
-
* The state is reset once the user switches the checkbox by hand.
|
|
241
|
-
*
|
|
242
|
-
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
|
|
243
|
-
*
|
|
244
|
-
* @type {boolean}
|
|
245
|
-
*/
|
|
246
|
-
indeterminate: {
|
|
247
|
-
type: Boolean,
|
|
248
|
-
notify: true,
|
|
249
|
-
value: false,
|
|
250
|
-
reflectToAttribute: true,
|
|
251
|
-
},
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* The name of the checkbox.
|
|
255
|
-
*
|
|
256
|
-
* @type {string}
|
|
257
|
-
*/
|
|
258
|
-
name: {
|
|
259
|
-
type: String,
|
|
260
|
-
value: '',
|
|
261
|
-
},
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
|
|
265
|
-
*
|
|
266
|
-
* @override
|
|
267
|
-
* @protected
|
|
268
|
-
*/
|
|
269
|
-
tabindex: {
|
|
270
|
-
type: Number,
|
|
271
|
-
value: 0,
|
|
272
|
-
reflectToAttribute: true,
|
|
273
|
-
},
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/** @override */
|
|
278
|
-
static get delegateProps() {
|
|
279
|
-
return [...super.delegateProps, 'indeterminate'];
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/** @override */
|
|
283
|
-
static get delegateAttrs() {
|
|
284
|
-
return [...super.delegateAttrs, 'name'];
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
constructor() {
|
|
288
|
-
super();
|
|
289
|
-
|
|
290
|
-
this._setType('checkbox');
|
|
291
|
-
|
|
292
|
-
// Set the string "on" as the default value for the checkbox following the HTML specification:
|
|
293
|
-
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
294
|
-
this.value = 'on';
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/** @protected */
|
|
298
|
-
ready() {
|
|
299
|
-
super.ready();
|
|
300
|
-
|
|
301
|
-
this.addController(
|
|
302
|
-
new InputController(this, (input) => {
|
|
303
|
-
this._setInputElement(input);
|
|
304
|
-
this._setFocusElement(input);
|
|
305
|
-
this.stateTarget = input;
|
|
306
|
-
this.ariaTarget = input;
|
|
307
|
-
}),
|
|
308
|
-
);
|
|
309
|
-
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
310
|
-
}
|
|
311
|
-
|
|
224
|
+
class SlotTargetController {
|
|
225
|
+
constructor(sourceSlot, targetFactory, callback) {
|
|
312
226
|
/**
|
|
313
|
-
*
|
|
314
|
-
* `active` attribute when clicking a link placed inside the label.
|
|
315
|
-
*
|
|
316
|
-
* @param {Event} event
|
|
317
|
-
* @return {boolean}
|
|
318
|
-
* @protected
|
|
319
|
-
* @override
|
|
227
|
+
* The source `<slot>` element to copy nodes from.
|
|
320
228
|
*/
|
|
321
|
-
|
|
322
|
-
if (event.target.localName === 'a') {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return super._shouldSetActive(event);
|
|
327
|
-
}
|
|
229
|
+
this.sourceSlot = sourceSlot;
|
|
328
230
|
|
|
329
231
|
/**
|
|
330
|
-
*
|
|
331
|
-
* `indeterminate` state checkbox is toggled by the user.
|
|
332
|
-
*
|
|
333
|
-
* @param {boolean} checked
|
|
334
|
-
* @protected
|
|
335
|
-
* @override
|
|
232
|
+
* Function used to get a reference to slot target.
|
|
336
233
|
*/
|
|
337
|
-
|
|
338
|
-
if (this.indeterminate) {
|
|
339
|
-
this.indeterminate = false;
|
|
340
|
-
}
|
|
234
|
+
this.targetFactory = targetFactory;
|
|
341
235
|
|
|
342
|
-
|
|
236
|
+
/**
|
|
237
|
+
* Function called after copying nodes to target.
|
|
238
|
+
*/
|
|
239
|
+
this.copyCallback = callback;
|
|
240
|
+
|
|
241
|
+
if (sourceSlot) {
|
|
242
|
+
sourceSlot.addEventListener('slotchange', () => {
|
|
243
|
+
// Copy in progress, ignore this event.
|
|
244
|
+
if (this.__copying) {
|
|
245
|
+
this.__copying = false;
|
|
246
|
+
} else {
|
|
247
|
+
this.__checkAndCopyNodesToSlotTarget();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
343
250
|
}
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* @license
|
|
348
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
349
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
const checkboxStyles = i`
|
|
353
|
-
:host {
|
|
354
|
-
display: inline-block;
|
|
355
251
|
}
|
|
356
252
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
}
|
|
253
|
+
hostConnected() {
|
|
254
|
+
this.__sourceSlotObserver = new MutationObserver(() => this.__checkAndCopyNodesToSlotTarget());
|
|
360
255
|
|
|
361
|
-
|
|
362
|
-
|
|
256
|
+
// Ensure the content is up to date when host is connected
|
|
257
|
+
// to handle e.g. mutating text content while disconnected.
|
|
258
|
+
// Note, `hostConnected()` is called twice if the controller
|
|
259
|
+
// is initialized in `ready()` when using `ControllerMixin`.
|
|
260
|
+
if (!this.__copying) {
|
|
261
|
+
this.__checkAndCopyNodesToSlotTarget();
|
|
262
|
+
}
|
|
363
263
|
}
|
|
364
264
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
265
|
+
/**
|
|
266
|
+
* Copies every node from the source slot to the target element
|
|
267
|
+
* once the source slot' content is changed.
|
|
268
|
+
*
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
__checkAndCopyNodesToSlotTarget() {
|
|
272
|
+
this.__sourceSlotObserver.disconnect();
|
|
370
273
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
::slotted(label) {
|
|
374
|
-
grid-row: 1;
|
|
375
|
-
}
|
|
274
|
+
// Ensure slot target element is up to date.
|
|
275
|
+
const slotTarget = this.targetFactory();
|
|
376
276
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
}
|
|
277
|
+
if (!slotTarget) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
381
280
|
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
281
|
+
// Remove any existing clones from the slot target
|
|
282
|
+
if (this.__slotTargetClones) {
|
|
283
|
+
this.__slotTargetClones.forEach((node) => {
|
|
284
|
+
if (node.parentElement === slotTarget) {
|
|
285
|
+
slotTarget.removeChild(node);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
delete this.__slotTargetClones;
|
|
289
|
+
}
|
|
389
290
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
contain: paint;
|
|
395
|
-
}
|
|
291
|
+
// Exclude whitespace text nodes
|
|
292
|
+
const nodes = this.sourceSlot
|
|
293
|
+
.assignedNodes({ flatten: true })
|
|
294
|
+
.filter((node) => !(node.nodeType === Node.TEXT_NODE && node.textContent.trim() === ''));
|
|
396
295
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
opacity: 0;
|
|
400
|
-
cursor: inherit;
|
|
401
|
-
margin: 0;
|
|
402
|
-
align-self: stretch;
|
|
403
|
-
-webkit-appearance: none;
|
|
404
|
-
width: initial;
|
|
405
|
-
height: initial;
|
|
406
|
-
}
|
|
296
|
+
if (nodes.length > 0) {
|
|
297
|
+
slotTarget.innerHTML = '';
|
|
407
298
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
outline: 1px solid;
|
|
411
|
-
outline-offset: -1px;
|
|
412
|
-
}
|
|
299
|
+
// Ignore next slotchange
|
|
300
|
+
this.__copying = true;
|
|
413
301
|
|
|
414
|
-
|
|
415
|
-
:host([disabled]) [part='checkbox']::after {
|
|
416
|
-
outline-color: GrayText;
|
|
302
|
+
this.__copyNodesToSlotTarget(nodes, slotTarget);
|
|
417
303
|
}
|
|
304
|
+
}
|
|
418
305
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
306
|
+
/**
|
|
307
|
+
* Copies the nodes to the target element.
|
|
308
|
+
*
|
|
309
|
+
* @param {!Array<!Node>} nodes
|
|
310
|
+
* @param {HTMLElement} slotTarget
|
|
311
|
+
* @private
|
|
312
|
+
*/
|
|
313
|
+
__copyNodesToSlotTarget(nodes, slotTarget) {
|
|
314
|
+
this.__slotTargetClones = this.__slotTargetClones || [];
|
|
315
|
+
|
|
316
|
+
nodes.forEach((node) => {
|
|
317
|
+
// Clone the nodes and append the clones to the target
|
|
318
|
+
const clone = node.cloneNode(true);
|
|
319
|
+
this.__slotTargetClones.push(clone);
|
|
320
|
+
|
|
321
|
+
slotTarget.appendChild(clone);
|
|
322
|
+
|
|
323
|
+
// Observe all changes to the source node to have the clones updated
|
|
324
|
+
this.__sourceSlotObserver.observe(node, {
|
|
325
|
+
attributes: true,
|
|
326
|
+
childList: true,
|
|
327
|
+
subtree: true,
|
|
328
|
+
characterData: true,
|
|
329
|
+
});
|
|
330
|
+
});
|
|
424
331
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
332
|
+
// Run callback e.g. to show a deprecation warning
|
|
333
|
+
if (typeof this.copyCallback === 'function') {
|
|
334
|
+
this.copyCallback(nodes);
|
|
428
335
|
}
|
|
429
336
|
}
|
|
430
|
-
|
|
337
|
+
}
|
|
431
338
|
|
|
432
339
|
/**
|
|
433
340
|
* @license
|
|
434
|
-
* Copyright (c) 2017 -
|
|
341
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
435
342
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
436
343
|
*/
|
|
437
344
|
|
|
438
|
-
registerStyles('vaadin-checkbox', checkboxStyles, { moduleId: 'vaadin-checkbox-styles' });
|
|
439
|
-
|
|
440
345
|
/**
|
|
441
346
|
* `<vaadin-checkbox>` is an input field representing a binary choice.
|
|
442
347
|
*
|
|
@@ -449,59 +354,225 @@ registerStyles('vaadin-checkbox', checkboxStyles, { moduleId: 'vaadin-checkbox-s
|
|
|
449
354
|
* The following shadow DOM parts are available for styling:
|
|
450
355
|
*
|
|
451
356
|
* Part name | Description
|
|
452
|
-
*
|
|
453
|
-
* `checkbox` | The element
|
|
357
|
+
* ------------|----------------
|
|
358
|
+
* `checkbox` | The wrapper element that contains slotted <input type="checkbox">.
|
|
454
359
|
*
|
|
455
360
|
* The following state attributes are available for styling:
|
|
456
361
|
*
|
|
457
|
-
* Attribute | Description
|
|
458
|
-
*
|
|
459
|
-
* `active` | Set when the checkbox is
|
|
460
|
-
* `
|
|
461
|
-
* `
|
|
462
|
-
* `
|
|
463
|
-
* `
|
|
464
|
-
* `
|
|
465
|
-
* `has-label` | Set when the checkbox has a label.
|
|
362
|
+
* Attribute | Description | Part name
|
|
363
|
+
* ----------------|-------------|--------------
|
|
364
|
+
* `active` | Set when the checkbox is pressed down, either with mouse, touch or the keyboard. | `:host`
|
|
365
|
+
* `disabled` | Set when the checkbox is disabled. | `:host`
|
|
366
|
+
* `focus-ring` | Set when the checkbox is focused using the keyboard. | `:host`
|
|
367
|
+
* `focused` | Set when the checkbox is focused. | `:host`
|
|
368
|
+
* `indeterminate` | Set when the checkbox is in the indeterminate state. | `:host`
|
|
369
|
+
* `checked` | Set when the checkbox is checked. | `:host`
|
|
370
|
+
* `has-label` | Set when the checkbox has a label. | `:host`
|
|
466
371
|
*
|
|
467
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
372
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
468
373
|
*
|
|
469
374
|
* @fires {CustomEvent} checked-changed - Fired when the `checked` property changes.
|
|
470
375
|
* @fires {CustomEvent} indeterminate-changed - Fired when the `indeterminate` property changes.
|
|
471
376
|
*
|
|
472
|
-
* @customElement
|
|
473
377
|
* @extends HTMLElement
|
|
474
|
-
* @mixes
|
|
378
|
+
* @mixes ControllerMixin
|
|
475
379
|
* @mixes ThemableMixin
|
|
476
380
|
* @mixes ElementMixin
|
|
381
|
+
* @mixes ActiveMixin
|
|
382
|
+
* @mixes DelegateFocusMixin
|
|
383
|
+
* @mixes CheckedMixin
|
|
384
|
+
* @mixes LabelMixin
|
|
477
385
|
*/
|
|
478
|
-
class Checkbox extends
|
|
386
|
+
class Checkbox extends LabelMixin(
|
|
387
|
+
CheckedMixin(DelegateFocusMixin(ActiveMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))))),
|
|
388
|
+
) {
|
|
479
389
|
static get is() {
|
|
480
390
|
return 'vaadin-checkbox';
|
|
481
391
|
}
|
|
482
392
|
|
|
483
393
|
static get template() {
|
|
484
394
|
return html`
|
|
395
|
+
<style>
|
|
396
|
+
:host {
|
|
397
|
+
display: inline-block;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
:host([hidden]) {
|
|
401
|
+
display: none !important;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
:host([disabled]) {
|
|
405
|
+
-webkit-tap-highlight-color: transparent;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.vaadin-checkbox-container {
|
|
409
|
+
display: grid;
|
|
410
|
+
grid-template-columns: auto 1fr;
|
|
411
|
+
align-items: baseline;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
[part='checkbox'],
|
|
415
|
+
::slotted(input),
|
|
416
|
+
::slotted(label) {
|
|
417
|
+
grid-row: 1;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
[part='checkbox'],
|
|
421
|
+
::slotted(input) {
|
|
422
|
+
grid-column: 1;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
[part='checkbox'] {
|
|
426
|
+
width: var(--vaadin-checkbox-size, 1em);
|
|
427
|
+
height: var(--vaadin-checkbox-size, 1em);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
[part='checkbox']::before {
|
|
431
|
+
display: block;
|
|
432
|
+
content: '\\202F';
|
|
433
|
+
line-height: var(--vaadin-checkbox-size, 1em);
|
|
434
|
+
contain: paint;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* visually hidden */
|
|
438
|
+
::slotted(input) {
|
|
439
|
+
opacity: 0;
|
|
440
|
+
cursor: inherit;
|
|
441
|
+
margin: 0;
|
|
442
|
+
align-self: stretch;
|
|
443
|
+
-webkit-appearance: none;
|
|
444
|
+
}
|
|
445
|
+
</style>
|
|
485
446
|
<div class="vaadin-checkbox-container">
|
|
486
|
-
<div part="checkbox"
|
|
447
|
+
<div part="checkbox"></div>
|
|
487
448
|
<slot name="input"></slot>
|
|
488
449
|
<slot name="label"></slot>
|
|
450
|
+
|
|
451
|
+
<div style="display: none !important">
|
|
452
|
+
<slot id="noop"></slot>
|
|
453
|
+
</div>
|
|
489
454
|
</div>
|
|
490
455
|
<slot name="tooltip"></slot>
|
|
491
456
|
`;
|
|
492
457
|
}
|
|
493
458
|
|
|
459
|
+
static get properties() {
|
|
460
|
+
return {
|
|
461
|
+
/**
|
|
462
|
+
* True if the checkbox is in the indeterminate state which means
|
|
463
|
+
* it is not possible to say whether it is checked or unchecked.
|
|
464
|
+
* The state is reset once the user switches the checkbox by hand.
|
|
465
|
+
*
|
|
466
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Indeterminate_state_checkboxes
|
|
467
|
+
*
|
|
468
|
+
* @type {boolean}
|
|
469
|
+
*/
|
|
470
|
+
indeterminate: {
|
|
471
|
+
type: Boolean,
|
|
472
|
+
notify: true,
|
|
473
|
+
value: false,
|
|
474
|
+
reflectToAttribute: true,
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* The name of the checkbox.
|
|
479
|
+
*
|
|
480
|
+
* @type {string}
|
|
481
|
+
*/
|
|
482
|
+
name: {
|
|
483
|
+
type: String,
|
|
484
|
+
value: '',
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** @override */
|
|
490
|
+
static get delegateProps() {
|
|
491
|
+
return [...super.delegateProps, 'indeterminate'];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/** @override */
|
|
495
|
+
static get delegateAttrs() {
|
|
496
|
+
return [...super.delegateAttrs, 'name'];
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
constructor() {
|
|
500
|
+
super();
|
|
501
|
+
|
|
502
|
+
this._setType('checkbox');
|
|
503
|
+
|
|
504
|
+
// Set the string "on" as the default value for the checkbox following the HTML specification:
|
|
505
|
+
// https://html.spec.whatwg.org/multipage/input.html#dom-input-value-default-on
|
|
506
|
+
this.value = 'on';
|
|
507
|
+
}
|
|
508
|
+
|
|
494
509
|
/** @protected */
|
|
495
510
|
ready() {
|
|
496
511
|
super.ready();
|
|
497
512
|
|
|
513
|
+
this.addController(
|
|
514
|
+
new InputController(this, (input) => {
|
|
515
|
+
this._setInputElement(input);
|
|
516
|
+
this._setFocusElement(input);
|
|
517
|
+
this.stateTarget = input;
|
|
518
|
+
this.ariaTarget = input;
|
|
519
|
+
}),
|
|
520
|
+
);
|
|
521
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
522
|
+
this.addController(
|
|
523
|
+
new SlotTargetController(
|
|
524
|
+
this.$.noop,
|
|
525
|
+
() => this._labelController.node,
|
|
526
|
+
() => this.__warnDeprecated(),
|
|
527
|
+
),
|
|
528
|
+
);
|
|
498
529
|
this._tooltipController = new TooltipController(this);
|
|
499
|
-
this._tooltipController.setAriaTarget(this.inputElement);
|
|
500
530
|
this.addController(this._tooltipController);
|
|
501
531
|
}
|
|
532
|
+
|
|
533
|
+
/** @private */
|
|
534
|
+
__warnDeprecated() {
|
|
535
|
+
console.warn(
|
|
536
|
+
`WARNING: Since Vaadin 22, placing the label as a direct child of a <vaadin-checkbox> is deprecated.
|
|
537
|
+
Please use <label slot="label"> wrapper or the label property instead.`,
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* Extends the method from `ActiveMixin` in order to
|
|
543
|
+
* prevent setting the `active` attribute when interacting with a link inside the label.
|
|
544
|
+
*
|
|
545
|
+
* @param {Event} event
|
|
546
|
+
* @return {boolean}
|
|
547
|
+
* @protected
|
|
548
|
+
* @override
|
|
549
|
+
*/
|
|
550
|
+
_shouldSetActive(event) {
|
|
551
|
+
if (event.target.localName === 'a') {
|
|
552
|
+
return false;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return super._shouldSetActive(event);
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Extends the method from `CheckedMixin` in order to
|
|
560
|
+
* reset the indeterminate state once the user switches the checkbox.
|
|
561
|
+
*
|
|
562
|
+
* @param {boolean} checked
|
|
563
|
+
* @protected
|
|
564
|
+
* @override
|
|
565
|
+
*/
|
|
566
|
+
_toggleChecked(checked) {
|
|
567
|
+
if (this.indeterminate) {
|
|
568
|
+
this.indeterminate = false;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
super._toggleChecked(checked);
|
|
572
|
+
}
|
|
502
573
|
}
|
|
503
574
|
|
|
504
|
-
|
|
575
|
+
customElements.define(Checkbox.is, Checkbox);
|
|
505
576
|
|
|
506
577
|
const checkboxGroup = i`
|
|
507
578
|
:host {
|
|
@@ -523,6 +594,7 @@ const checkboxGroup = i`
|
|
|
523
594
|
}
|
|
524
595
|
|
|
525
596
|
:host([theme~='vertical']) [part='group-field'] {
|
|
597
|
+
display: flex;
|
|
526
598
|
flex-direction: column;
|
|
527
599
|
}
|
|
528
600
|
|
|
@@ -554,7 +626,7 @@ registerStyles('vaadin-checkbox-group', [requiredField, helper, checkboxGroup],
|
|
|
554
626
|
|
|
555
627
|
/**
|
|
556
628
|
* @license
|
|
557
|
-
* Copyright (c) 2018 -
|
|
629
|
+
* Copyright (c) 2018 - 2022 Vaadin Ltd.
|
|
558
630
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
559
631
|
*/
|
|
560
632
|
|
|
@@ -562,11 +634,10 @@ registerStyles('vaadin-checkbox-group', [requiredField, helper, checkboxGroup],
|
|
|
562
634
|
* `<vaadin-checkbox-group>` is a web component that allows the user to choose several items from a group of binary choices.
|
|
563
635
|
*
|
|
564
636
|
* ```html
|
|
565
|
-
* <vaadin-checkbox-group label="
|
|
566
|
-
* <vaadin-checkbox value="
|
|
567
|
-
* <vaadin-checkbox value="
|
|
568
|
-
* <vaadin-checkbox value="
|
|
569
|
-
* <vaadin-checkbox value="3" label="Status"></vaadin-checkbox>
|
|
637
|
+
* <vaadin-checkbox-group label="Preferred language of contact:">
|
|
638
|
+
* <vaadin-checkbox value="en" label="English"></vaadin-checkbox>
|
|
639
|
+
* <vaadin-checkbox value="fr" label="Français"></vaadin-checkbox>
|
|
640
|
+
* <vaadin-checkbox value="de" label="Deutsch"></vaadin-checkbox>
|
|
570
641
|
* </vaadin-checkbox-group>
|
|
571
642
|
* ```
|
|
572
643
|
*
|
|
@@ -594,13 +665,12 @@ registerStyles('vaadin-checkbox-group', [requiredField, helper, checkboxGroup],
|
|
|
594
665
|
* `has-helper` | Set when the element has helper text | :host
|
|
595
666
|
* `has-error-message` | Set when the element has an error message | :host
|
|
596
667
|
*
|
|
597
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
668
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
598
669
|
*
|
|
599
670
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
600
671
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
601
672
|
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
602
673
|
*
|
|
603
|
-
* @customElement
|
|
604
674
|
* @extends HTMLElement
|
|
605
675
|
* @mixes ThemableMixin
|
|
606
676
|
* @mixes DisabledMixin
|
|
@@ -636,11 +706,6 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
|
|
|
636
706
|
width: 100%;
|
|
637
707
|
}
|
|
638
708
|
|
|
639
|
-
[part='group-field'] {
|
|
640
|
-
display: flex;
|
|
641
|
-
flex-wrap: wrap;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
709
|
:host(:not([has-label])) [part='label'] {
|
|
645
710
|
display: none;
|
|
646
711
|
}
|
|
@@ -694,29 +759,6 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
|
|
|
694
759
|
this.__registerCheckbox = this.__registerCheckbox.bind(this);
|
|
695
760
|
this.__unregisterCheckbox = this.__unregisterCheckbox.bind(this);
|
|
696
761
|
this.__onCheckboxCheckedChanged = this.__onCheckboxCheckedChanged.bind(this);
|
|
697
|
-
|
|
698
|
-
this._tooltipController = new TooltipController(this);
|
|
699
|
-
this._tooltipController.addEventListener('tooltip-changed', (event) => {
|
|
700
|
-
const tooltip = event.detail.node;
|
|
701
|
-
if (tooltip && tooltip.isConnected) {
|
|
702
|
-
// Tooltip element has been added to the DOM
|
|
703
|
-
const inputs = this.__checkboxes.map((checkbox) => checkbox.inputElement);
|
|
704
|
-
this._tooltipController.setAriaTarget(inputs);
|
|
705
|
-
} else {
|
|
706
|
-
// Tooltip element is no longer connected
|
|
707
|
-
this._tooltipController.setAriaTarget([]);
|
|
708
|
-
}
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
/**
|
|
713
|
-
* A collection of the checkboxes.
|
|
714
|
-
*
|
|
715
|
-
* @return {!Array<!Checkbox>}
|
|
716
|
-
* @private
|
|
717
|
-
*/
|
|
718
|
-
get __checkboxes() {
|
|
719
|
-
return this.__filterCheckboxes([...this.children]);
|
|
720
762
|
}
|
|
721
763
|
|
|
722
764
|
/** @protected */
|
|
@@ -728,20 +770,17 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
|
|
|
728
770
|
// See https://github.com/vaadin/vaadin-web-components/issues/94
|
|
729
771
|
this.setAttribute('role', 'group');
|
|
730
772
|
|
|
731
|
-
|
|
732
|
-
this._observer = new SlotObserver(slot, ({ addedNodes, removedNodes }) => {
|
|
773
|
+
this._observer = new FlattenedNodesObserver(this, ({ addedNodes, removedNodes }) => {
|
|
733
774
|
const addedCheckboxes = this.__filterCheckboxes(addedNodes);
|
|
734
775
|
const removedCheckboxes = this.__filterCheckboxes(removedNodes);
|
|
735
776
|
|
|
736
777
|
addedCheckboxes.forEach(this.__registerCheckbox);
|
|
737
778
|
removedCheckboxes.forEach(this.__unregisterCheckbox);
|
|
738
779
|
|
|
739
|
-
const inputs = this.__checkboxes.map((checkbox) => checkbox.inputElement);
|
|
740
|
-
this._tooltipController.setAriaTarget(inputs);
|
|
741
|
-
|
|
742
780
|
this.__warnOfCheckboxesWithoutValue(addedCheckboxes);
|
|
743
781
|
});
|
|
744
782
|
|
|
783
|
+
this._tooltipController = new TooltipController(this);
|
|
745
784
|
this.addController(this._tooltipController);
|
|
746
785
|
}
|
|
747
786
|
|
|
@@ -765,6 +804,16 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
|
|
|
765
804
|
return nodes.filter((child) => child instanceof Checkbox);
|
|
766
805
|
}
|
|
767
806
|
|
|
807
|
+
/**
|
|
808
|
+
* A collection of the checkboxes.
|
|
809
|
+
*
|
|
810
|
+
* @return {!Array<!Checkbox>}
|
|
811
|
+
* @private
|
|
812
|
+
*/
|
|
813
|
+
get __checkboxes() {
|
|
814
|
+
return this.__filterCheckboxes([...this.children]);
|
|
815
|
+
}
|
|
816
|
+
|
|
768
817
|
/**
|
|
769
818
|
* @param {!Array<!Checkbox>} checkboxes
|
|
770
819
|
* @private
|
|
@@ -921,15 +970,13 @@ class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(The
|
|
|
921
970
|
_setFocused(focused) {
|
|
922
971
|
super._setFocused(focused);
|
|
923
972
|
|
|
924
|
-
|
|
925
|
-
// losing focus, which happens on browser tab switch.
|
|
926
|
-
if (!focused && document.hasFocus()) {
|
|
973
|
+
if (!focused) {
|
|
927
974
|
this.validate();
|
|
928
975
|
}
|
|
929
976
|
}
|
|
930
977
|
}
|
|
931
978
|
|
|
932
|
-
|
|
979
|
+
customElements.define(CheckboxGroup.is, CheckboxGroup);
|
|
933
980
|
|
|
934
981
|
const checkboxGroupInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}vaadin-checkbox-group{margin-top:5px;margin-left:40px}.checkboxgroup{font-family:\"Roboto\";font-style:normal;font-size:15px}.checkboxgroup__wrapper{position:relative}.checkboxgroup__wrapper--flex{display:flex;gap:5px;align-content:flex-start}.checkboxgroup__wrapper--relative{position:relative;display:inline}.checkboxgroup__input{vertical-align:baseline}.checkboxgroup__input[indeterminate]::part(checkbox)::after,.checkboxgroup__input[indeterminate]::part(checkbox),.checkboxgroup__input[checked]::part(checkbox){background-color:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C))}.checkboxgroup__label{font-style:inherit;font-family:inherit;font-weight:400;font-size:16px;color:var(--emfe-w-registration-typography, var(--emfe-w-color-black, #000000));line-height:1.5;padding-left:10px;vertical-align:baseline}.checkboxgroup__label-text{font-size:16px}.checkboxgroup__label a{color:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C))}.checkboxgroup__error-message{position:absolute;top:calc(100% + 5px);left:0;color:var(--emfe-w-color-error, var(--emfe-w-color-red, #ed0909))}.checkboxgroup__tooltip-icon{width:16px;height:auto}.checkboxgroup__tooltip{position:absolute;top:0;right:0;background-color:var(--emfe-w-color-white, #FFFFFF);border:1px solid var(--emfe-w-color-gray-100, #E6E6E6);color:var(--emfe-w-registration-typography, var(--emfe-w-color-black, #000000));padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.checkboxgroup__tooltip.visible{opacity:1}.checkbox__input[indeterminate]::part(checkbox),.checkbox__input[checked]::part(checkbox){background-color:var(--emfe-w-login-color-primary, var(--emfe-w-color-primary, #D0046C))}";
|
|
935
982
|
|