@everymatrix/general-input 1.44.0 → 1.45.2
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/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/checkbox-group-input_10.cjs.entry.js +3873 -1756
- package/dist/cjs/general-input.cjs.entry.js +65 -63
- package/dist/cjs/general-input.cjs.js +17 -11
- package/dist/cjs/index-8cb018cb.js +1316 -0
- package/dist/cjs/index.cjs.js +13 -13
- package/dist/cjs/loader.cjs.js +7 -13
- package/dist/cjs/locale.utils-76c75c40.js +147 -0
- package/dist/cjs/toggle-checkbox-input.cjs.entry.js +77 -78
- package/dist/collection/collection-manifest.json +14 -14
- package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +368 -353
- package/dist/collection/components/checkbox-input/checkbox-input.js +325 -315
- package/dist/collection/components/date-input/date-input.css +2 -2
- package/dist/collection/components/date-input/date-input.js +397 -376
- package/dist/collection/components/email-input/email-input.css +7 -11
- package/dist/collection/components/email-input/email-input.js +404 -385
- package/dist/collection/components/general-input/general-input.js +373 -368
- package/dist/collection/components/general-input/index.js +1 -0
- package/dist/collection/components/number-input/number-input.js +370 -352
- package/dist/collection/components/password-input/password-input.css +2 -4
- package/dist/collection/components/password-input/password-input.js +513 -540
- package/dist/collection/components/radio-input/radio-input.js +301 -286
- package/dist/collection/components/select-input/select-input.css +8 -9
- package/dist/collection/components/select-input/select-input.js +427 -414
- package/dist/collection/components/tel-input/tel-input.css +1 -1
- package/dist/collection/components/tel-input/tel-input.js +440 -422
- package/dist/collection/components/text-input/text-input.css +0 -1
- package/dist/collection/components/text-input/text-input.js +444 -429
- package/dist/collection/components/toggle-checkbox-input/toggle-checkbox-input.js +327 -340
- package/dist/collection/index.js +13 -13
- package/dist/collection/utils/locale.utils.js +133 -133
- package/dist/collection/utils/utils.js +3 -3
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/checkbox-group-input_10.entry.js +3873 -1756
- package/dist/esm/general-input.entry.js +65 -63
- package/dist/esm/general-input.js +14 -11
- package/dist/esm/index-514fda47.js +1287 -0
- package/dist/esm/index.js +13 -13
- package/dist/esm/loader.js +7 -13
- package/dist/esm/locale.utils-ca41bf95.js +144 -0
- package/dist/esm/toggle-checkbox-input.entry.js +77 -78
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-03e81c11.js +2 -0
- package/dist/general-input/p-aec71434.js +1 -0
- package/dist/general-input/p-e1255160.js +1 -0
- package/dist/general-input/p-eb454344.entry.js +1 -0
- package/dist/general-input/p-ecdc294b.entry.js +5430 -0
- package/dist/general-input/p-f92ab852.entry.js +1 -0
- package/dist/stencil.config.dev.js +17 -0
- package/dist/stencil.config.js +14 -19
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.d.ts +2 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/general-input/.stencil/packages/stencil/general-input/stencil.config.dev.d.ts +2 -0
- package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +68 -68
- package/dist/types/components/checkbox-input/checkbox-input.d.ts +61 -62
- package/dist/types/components/date-input/date-input.d.ts +78 -78
- package/dist/types/components/email-input/email-input.d.ts +77 -77
- package/dist/types/components/general-input/general-input.d.ts +72 -72
- package/dist/types/components/general-input/index.d.ts +1 -0
- package/dist/types/components/number-input/number-input.d.ts +71 -71
- package/dist/types/components/password-input/password-input.d.ts +87 -92
- package/dist/types/components/radio-input/radio-input.d.ts +55 -55
- package/dist/types/components/select-input/select-input.d.ts +79 -79
- package/dist/types/components/tel-input/tel-input.d.ts +85 -85
- package/dist/types/components/text-input/text-input.d.ts +81 -81
- package/dist/types/components/toggle-checkbox-input/toggle-checkbox-input.d.ts +63 -68
- package/dist/types/components.d.ts +201 -39
- package/dist/types/stencil-public-runtime.d.ts +142 -33
- package/dist/types/utils/locale.utils.d.ts +8 -8
- package/dist/types/utils/types.d.ts +54 -54
- package/loader/cdn.js +1 -3
- package/loader/index.cjs.js +1 -3
- package/loader/index.d.ts +13 -1
- package/loader/index.es2017.js +1 -3
- package/loader/index.js +1 -3
- package/loader/package.json +1 -0
- package/package.json +8 -1
- package/dist/cjs/index-132a0774.js +0 -1327
- package/dist/cjs/locale.utils-2fa6f747.js +0 -147
- package/dist/components/active-mixin.js +0 -975
- package/dist/components/checkbox-group-input.d.ts +0 -11
- package/dist/components/checkbox-group-input.js +0 -6
- package/dist/components/checkbox-group-input2.js +0 -1078
- package/dist/components/checkbox-input.d.ts +0 -11
- package/dist/components/checkbox-input.js +0 -6
- package/dist/components/checkbox-input2.js +0 -132
- package/dist/components/date-input.d.ts +0 -11
- package/dist/components/date-input.js +0 -6
- package/dist/components/date-input2.js +0 -11556
- package/dist/components/email-input.d.ts +0 -11
- package/dist/components/email-input.js +0 -6
- package/dist/components/email-input2.js +0 -171
- package/dist/components/field-mixin.js +0 -12426
- package/dist/components/general-input.d.ts +0 -11
- package/dist/components/general-input.js +0 -6
- package/dist/components/general-input2.js +0 -350
- package/dist/components/index.d.ts +0 -26
- package/dist/components/index.js +0 -18
- package/dist/components/input-field-shared-styles.js +0 -1211
- package/dist/components/number-input.d.ts +0 -11
- package/dist/components/number-input.js +0 -6
- package/dist/components/number-input2.js +0 -158
- package/dist/components/password-input.d.ts +0 -11
- package/dist/components/password-input.js +0 -6
- package/dist/components/password-input2.js +0 -1059
- package/dist/components/radio-input.d.ts +0 -11
- package/dist/components/radio-input.js +0 -6
- package/dist/components/radio-input2.js +0 -114
- package/dist/components/select-input.d.ts +0 -11
- package/dist/components/select-input.js +0 -6
- package/dist/components/select-input2.js +0 -183
- package/dist/components/tel-input.d.ts +0 -11
- package/dist/components/tel-input.js +0 -6
- package/dist/components/tel-input2.js +0 -197
- package/dist/components/text-input.d.ts +0 -11
- package/dist/components/text-input.js +0 -6
- package/dist/components/text-input2.js +0 -199
- package/dist/components/toggle-checkbox-input.d.ts +0 -11
- package/dist/components/toggle-checkbox-input.js +0 -6
- package/dist/components/tooltipIcon.js +0 -146
- package/dist/components/vaadin-button.js +0 -490
- package/dist/components/vaadin-combo-box.js +0 -4512
- package/dist/components/virtual-keyboard-controller.js +0 -2001
- package/dist/esm/index-db76d5b5.js +0 -1299
- package/dist/esm/locale.utils-30fb5289.js +0 -144
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/general-input/p-04d4b145.js +0 -1
- package/dist/general-input/p-a8221ce9.entry.js +0 -1
- package/dist/general-input/p-b408093e.js +0 -1
- package/dist/general-input/p-b64caafa.entry.js +0 -3646
- package/dist/general-input/p-c85c0e4d.entry.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -2
- /package/dist/cjs/{tooltipIcon-092a795f.js → tooltipIcon-7e9ee226.js} +0 -0
- /package/dist/esm/{tooltipIcon-99c1c7b7.js → tooltipIcon-0a5a06a2.js} +0 -0
- /package/dist/general-input/{p-f4f4ccda.js → p-2dccd0bf.js} +0 -0
|
@@ -1,1078 +0,0 @@
|
|
|
1
|
-
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
|
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, b as DelegateFocusMixin, c as InputController, e as LabelledInputController, h as html, T as TooltipController, f as defineCustomElement$1, E as ElementMixin, g as ThemableMixin, P as PolymerElement, j as requiredField, k as helper, F as FieldMixin, l as FocusMixin, S as SlotObserver } from './field-mixin.js';
|
|
4
|
-
import { A as ActiveMixin } from './active-mixin.js';
|
|
5
|
-
|
|
6
|
-
registerStyles(
|
|
7
|
-
'vaadin-checkbox',
|
|
8
|
-
i`
|
|
9
|
-
:host {
|
|
10
|
-
color: var(--lumo-body-text-color);
|
|
11
|
-
font-size: var(--lumo-font-size-m);
|
|
12
|
-
font-family: var(--lumo-font-family);
|
|
13
|
-
line-height: var(--lumo-line-height-s);
|
|
14
|
-
-webkit-font-smoothing: antialiased;
|
|
15
|
-
-moz-osx-font-smoothing: grayscale;
|
|
16
|
-
-webkit-tap-highlight-color: transparent;
|
|
17
|
-
-webkit-user-select: none;
|
|
18
|
-
-moz-user-select: none;
|
|
19
|
-
user-select: none;
|
|
20
|
-
cursor: default;
|
|
21
|
-
outline: none;
|
|
22
|
-
--_checkbox-size: var(--vaadin-checkbox-size, calc(var(--lumo-size-m) / 2));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
:host([has-label]) ::slotted(label) {
|
|
26
|
-
padding-block: var(--lumo-space-xs);
|
|
27
|
-
padding-inline: var(--lumo-space-xs) var(--lumo-space-s);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[part='checkbox'] {
|
|
31
|
-
width: var(--_checkbox-size);
|
|
32
|
-
height: var(--_checkbox-size);
|
|
33
|
-
margin: var(--lumo-space-xs);
|
|
34
|
-
position: relative;
|
|
35
|
-
border-radius: var(--lumo-border-radius-s);
|
|
36
|
-
background-color: var(--lumo-contrast-20pct);
|
|
37
|
-
transition: transform 0.2s cubic-bezier(0.12, 0.32, 0.54, 2), background-color 0.15s;
|
|
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
|
-
}
|
|
47
|
-
|
|
48
|
-
:host([indeterminate]) [part='checkbox'],
|
|
49
|
-
:host([checked]) [part='checkbox'] {
|
|
50
|
-
background-color: var(--lumo-primary-color);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/* Checkmark */
|
|
54
|
-
[part='checkbox']::after {
|
|
55
|
-
pointer-events: none;
|
|
56
|
-
font-family: 'lumo-icons';
|
|
57
|
-
content: var(--lumo-icons-checkmark);
|
|
58
|
-
color: var(--lumo-primary-contrast-color);
|
|
59
|
-
font-size: calc(var(--_checkbox-size) + 2px);
|
|
60
|
-
line-height: 1;
|
|
61
|
-
position: absolute;
|
|
62
|
-
top: -1px;
|
|
63
|
-
left: -1px;
|
|
64
|
-
contain: content;
|
|
65
|
-
opacity: 0;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
:host([checked]) [part='checkbox']::after {
|
|
69
|
-
opacity: 1;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/* Indeterminate checkmark */
|
|
73
|
-
:host([indeterminate]) [part='checkbox']::after {
|
|
74
|
-
content: '';
|
|
75
|
-
opacity: 1;
|
|
76
|
-
top: 45%;
|
|
77
|
-
height: 10%;
|
|
78
|
-
left: 22%;
|
|
79
|
-
right: 22%;
|
|
80
|
-
width: auto;
|
|
81
|
-
border: 0;
|
|
82
|
-
background-color: var(--lumo-primary-contrast-color);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/* Focus ring */
|
|
86
|
-
: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);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/* Disabled */
|
|
92
|
-
:host([disabled]) {
|
|
93
|
-
pointer-events: none;
|
|
94
|
-
color: var(--lumo-disabled-text-color);
|
|
95
|
-
--vaadin-input-field-border-color: var(--lumo-contrast-20pct);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
:host([disabled]) ::slotted(label) {
|
|
99
|
-
color: inherit;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
:host([disabled]) [part='checkbox'] {
|
|
103
|
-
background-color: var(--lumo-contrast-10pct);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
:host([disabled]) [part='checkbox']::after {
|
|
107
|
-
color: var(--lumo-contrast-30pct);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
:host([indeterminate][disabled]) [part='checkbox']::after {
|
|
111
|
-
background-color: var(--lumo-contrast-30pct);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* RTL specific styles */
|
|
115
|
-
:host([dir='rtl'][has-label]) ::slotted(label) {
|
|
116
|
-
padding: var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-xs) var(--lumo-space-s);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Used for activation "halo" */
|
|
120
|
-
[part='checkbox']::before {
|
|
121
|
-
pointer-events: none;
|
|
122
|
-
color: transparent;
|
|
123
|
-
width: 100%;
|
|
124
|
-
height: 100%;
|
|
125
|
-
line-height: var(--_checkbox-size);
|
|
126
|
-
border-radius: inherit;
|
|
127
|
-
background-color: inherit;
|
|
128
|
-
transform: scale(1.4);
|
|
129
|
-
opacity: 0;
|
|
130
|
-
transition: transform 0.1s, opacity 0.8s;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/* Hover */
|
|
134
|
-
:host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part='checkbox'] {
|
|
135
|
-
background-color: var(--lumo-contrast-30pct);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/* Disable hover for touch devices */
|
|
139
|
-
@media (pointer: coarse) {
|
|
140
|
-
:host(:not([checked]):not([indeterminate]):not([disabled]):hover) [part='checkbox'] {
|
|
141
|
-
background-color: var(--lumo-contrast-20pct);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/* Active */
|
|
146
|
-
:host([active]) [part='checkbox'] {
|
|
147
|
-
transform: scale(0.9);
|
|
148
|
-
transition-duration: 0.05s;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
:host([active][checked]) [part='checkbox'] {
|
|
152
|
-
transform: scale(1.1);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
:host([active]:not([checked])) [part='checkbox']::before {
|
|
156
|
-
transition-duration: 0.01s, 0.01s;
|
|
157
|
-
transform: scale(0);
|
|
158
|
-
opacity: 0.4;
|
|
159
|
-
}
|
|
160
|
-
`,
|
|
161
|
-
{ moduleId: 'lumo-checkbox' },
|
|
162
|
-
);
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* @license
|
|
166
|
-
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
167
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* A mixin to manage the checked state.
|
|
172
|
-
*
|
|
173
|
-
* @polymerMixin
|
|
174
|
-
* @mixes DelegateStateMixin
|
|
175
|
-
* @mixes DisabledMixin
|
|
176
|
-
* @mixes InputMixin
|
|
177
|
-
*/
|
|
178
|
-
const CheckedMixin = dedupingMixin(
|
|
179
|
-
(superclass) =>
|
|
180
|
-
class CheckedMixinClass extends DelegateStateMixin(DisabledMixin(InputMixin(superclass))) {
|
|
181
|
-
static get properties() {
|
|
182
|
-
return {
|
|
183
|
-
/**
|
|
184
|
-
* True if the element is checked.
|
|
185
|
-
* @type {boolean}
|
|
186
|
-
*/
|
|
187
|
-
checked: {
|
|
188
|
-
type: Boolean,
|
|
189
|
-
value: false,
|
|
190
|
-
notify: true,
|
|
191
|
-
reflectToAttribute: true,
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
static get delegateProps() {
|
|
197
|
-
return [...super.delegateProps, 'checked'];
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @param {Event} event
|
|
202
|
-
* @protected
|
|
203
|
-
* @override
|
|
204
|
-
*/
|
|
205
|
-
_onChange(event) {
|
|
206
|
-
const input = event.target;
|
|
207
|
-
|
|
208
|
-
this._toggleChecked(input.checked);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** @protected */
|
|
212
|
-
_toggleChecked(checked) {
|
|
213
|
-
this.checked = checked;
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
);
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* @license
|
|
220
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
221
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
222
|
-
*/
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* A mixin providing common checkbox functionality.
|
|
226
|
-
*
|
|
227
|
-
* @polymerMixin
|
|
228
|
-
* @mixes ActiveMixin
|
|
229
|
-
* @mixes CheckedMixin
|
|
230
|
-
* @mixes DelegateFocusMixin
|
|
231
|
-
* @mixes LabelMixin
|
|
232
|
-
*/
|
|
233
|
-
const CheckboxMixin = (superclass) =>
|
|
234
|
-
class CheckboxMixinClass extends LabelMixin(CheckedMixin(DelegateFocusMixin(ActiveMixin(superclass)))) {
|
|
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
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Override method inherited from `ActiveMixin` to prevent setting
|
|
314
|
-
* `active` attribute when clicking a link placed inside the label.
|
|
315
|
-
*
|
|
316
|
-
* @param {Event} event
|
|
317
|
-
* @return {boolean}
|
|
318
|
-
* @protected
|
|
319
|
-
* @override
|
|
320
|
-
*/
|
|
321
|
-
_shouldSetActive(event) {
|
|
322
|
-
if (event.target.localName === 'a') {
|
|
323
|
-
return false;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return super._shouldSetActive(event);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Override method inherited from `CheckedMixin` to reset
|
|
331
|
-
* `indeterminate` state checkbox is toggled by the user.
|
|
332
|
-
*
|
|
333
|
-
* @param {boolean} checked
|
|
334
|
-
* @protected
|
|
335
|
-
* @override
|
|
336
|
-
*/
|
|
337
|
-
_toggleChecked(checked) {
|
|
338
|
-
if (this.indeterminate) {
|
|
339
|
-
this.indeterminate = false;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
super._toggleChecked(checked);
|
|
343
|
-
}
|
|
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
|
-
}
|
|
356
|
-
|
|
357
|
-
:host([hidden]) {
|
|
358
|
-
display: none !important;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
:host([disabled]) {
|
|
362
|
-
-webkit-tap-highlight-color: transparent;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
.vaadin-checkbox-container {
|
|
366
|
-
display: grid;
|
|
367
|
-
grid-template-columns: auto 1fr;
|
|
368
|
-
align-items: baseline;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
[part='checkbox'],
|
|
372
|
-
::slotted(input),
|
|
373
|
-
::slotted(label) {
|
|
374
|
-
grid-row: 1;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
[part='checkbox'],
|
|
378
|
-
::slotted(input) {
|
|
379
|
-
grid-column: 1;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
[part='checkbox'] {
|
|
383
|
-
width: var(--vaadin-checkbox-size, 1em);
|
|
384
|
-
height: var(--vaadin-checkbox-size, 1em);
|
|
385
|
-
--_input-border-width: var(--vaadin-input-field-border-width, 0);
|
|
386
|
-
--_input-border-color: var(--vaadin-input-field-border-color, transparent);
|
|
387
|
-
box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
[part='checkbox']::before {
|
|
391
|
-
display: block;
|
|
392
|
-
content: '\\202F';
|
|
393
|
-
line-height: var(--vaadin-checkbox-size, 1em);
|
|
394
|
-
contain: paint;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/* visually hidden */
|
|
398
|
-
::slotted(input) {
|
|
399
|
-
opacity: 0;
|
|
400
|
-
cursor: inherit;
|
|
401
|
-
margin: 0;
|
|
402
|
-
align-self: stretch;
|
|
403
|
-
-webkit-appearance: none;
|
|
404
|
-
width: initial;
|
|
405
|
-
height: initial;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
@media (forced-colors: active) {
|
|
409
|
-
[part='checkbox'] {
|
|
410
|
-
outline: 1px solid;
|
|
411
|
-
outline-offset: -1px;
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
:host([disabled]) [part='checkbox'],
|
|
415
|
-
:host([disabled]) [part='checkbox']::after {
|
|
416
|
-
outline-color: GrayText;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
:host(:is([checked], [indeterminate])) [part='checkbox']::after {
|
|
420
|
-
outline: 1px solid;
|
|
421
|
-
outline-offset: -1px;
|
|
422
|
-
border-radius: inherit;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
:host([focused]) [part='checkbox'],
|
|
426
|
-
:host([focused]) [part='checkbox']::after {
|
|
427
|
-
outline-width: 2px;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
`;
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* @license
|
|
434
|
-
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
435
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
436
|
-
*/
|
|
437
|
-
|
|
438
|
-
registerStyles('vaadin-checkbox', checkboxStyles, { moduleId: 'vaadin-checkbox-styles' });
|
|
439
|
-
|
|
440
|
-
/**
|
|
441
|
-
* `<vaadin-checkbox>` is an input field representing a binary choice.
|
|
442
|
-
*
|
|
443
|
-
* ```html
|
|
444
|
-
* <vaadin-checkbox label="I accept the terms and conditions"></vaadin-checkbox>
|
|
445
|
-
* ```
|
|
446
|
-
*
|
|
447
|
-
* ### Styling
|
|
448
|
-
*
|
|
449
|
-
* The following shadow DOM parts are available for styling:
|
|
450
|
-
*
|
|
451
|
-
* Part name | Description
|
|
452
|
-
* ------------|-------------
|
|
453
|
-
* `checkbox` | The element representing a stylable custom checkbox.
|
|
454
|
-
*
|
|
455
|
-
* The following state attributes are available for styling:
|
|
456
|
-
*
|
|
457
|
-
* Attribute | Description
|
|
458
|
-
* ----------------|-------------
|
|
459
|
-
* `active` | Set when the checkbox is activated with mouse, touch or the keyboard.
|
|
460
|
-
* `checked` | Set when the checkbox is checked.
|
|
461
|
-
* `disabled` | Set when the checkbox is disabled.
|
|
462
|
-
* `focus-ring` | Set when the checkbox is focused using the keyboard.
|
|
463
|
-
* `focused` | Set when the checkbox is focused.
|
|
464
|
-
* `indeterminate` | Set when the checkbox is in the indeterminate state.
|
|
465
|
-
* `has-label` | Set when the checkbox has a label.
|
|
466
|
-
*
|
|
467
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
468
|
-
*
|
|
469
|
-
* @fires {CustomEvent} checked-changed - Fired when the `checked` property changes.
|
|
470
|
-
* @fires {CustomEvent} indeterminate-changed - Fired when the `indeterminate` property changes.
|
|
471
|
-
*
|
|
472
|
-
* @customElement
|
|
473
|
-
* @extends HTMLElement
|
|
474
|
-
* @mixes CheckboxMixin
|
|
475
|
-
* @mixes ThemableMixin
|
|
476
|
-
* @mixes ElementMixin
|
|
477
|
-
*/
|
|
478
|
-
class Checkbox extends CheckboxMixin(ElementMixin(ThemableMixin(PolymerElement))) {
|
|
479
|
-
static get is() {
|
|
480
|
-
return 'vaadin-checkbox';
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
static get template() {
|
|
484
|
-
return html`
|
|
485
|
-
<div class="vaadin-checkbox-container">
|
|
486
|
-
<div part="checkbox" aria-hidden="true"></div>
|
|
487
|
-
<slot name="input"></slot>
|
|
488
|
-
<slot name="label"></slot>
|
|
489
|
-
</div>
|
|
490
|
-
<slot name="tooltip"></slot>
|
|
491
|
-
`;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
/** @protected */
|
|
495
|
-
ready() {
|
|
496
|
-
super.ready();
|
|
497
|
-
|
|
498
|
-
this._tooltipController = new TooltipController(this);
|
|
499
|
-
this._tooltipController.setAriaTarget(this.inputElement);
|
|
500
|
-
this.addController(this._tooltipController);
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
defineCustomElement$1(Checkbox);
|
|
505
|
-
|
|
506
|
-
const checkboxGroup = i`
|
|
507
|
-
:host {
|
|
508
|
-
color: var(--lumo-body-text-color);
|
|
509
|
-
font-size: var(--lumo-font-size-m);
|
|
510
|
-
font-family: var(--lumo-font-family);
|
|
511
|
-
-webkit-font-smoothing: antialiased;
|
|
512
|
-
-moz-osx-font-smoothing: grayscale;
|
|
513
|
-
-webkit-tap-highlight-color: transparent;
|
|
514
|
-
padding: var(--lumo-space-xs) 0;
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
:host::before {
|
|
518
|
-
/* Effective height of vaadin-checkbox */
|
|
519
|
-
height: var(--lumo-size-s);
|
|
520
|
-
box-sizing: border-box;
|
|
521
|
-
display: inline-flex;
|
|
522
|
-
align-items: center;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
:host([theme~='vertical']) [part='group-field'] {
|
|
526
|
-
flex-direction: column;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
:host([disabled]) [part='label'] {
|
|
530
|
-
color: var(--lumo-disabled-text-color);
|
|
531
|
-
-webkit-text-fill-color: var(--lumo-disabled-text-color);
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
:host([focused]:not([disabled])) [part='label'] {
|
|
535
|
-
color: var(--lumo-primary-text-color);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
:host(:hover:not([disabled]):not([focused])) [part='label'],
|
|
539
|
-
:host(:hover:not([disabled]):not([focused])) [part='helper-text'] {
|
|
540
|
-
color: var(--lumo-body-text-color);
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
/* Touch device adjustment */
|
|
544
|
-
@media (pointer: coarse) {
|
|
545
|
-
:host(:hover:not([disabled]):not([focused])) [part='label'] {
|
|
546
|
-
color: var(--lumo-secondary-text-color);
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
`;
|
|
550
|
-
|
|
551
|
-
registerStyles('vaadin-checkbox-group', [requiredField, helper, checkboxGroup], {
|
|
552
|
-
moduleId: 'lumo-checkbox-group',
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* @license
|
|
557
|
-
* Copyright (c) 2018 - 2023 Vaadin Ltd.
|
|
558
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
559
|
-
*/
|
|
560
|
-
|
|
561
|
-
/**
|
|
562
|
-
* `<vaadin-checkbox-group>` is a web component that allows the user to choose several items from a group of binary choices.
|
|
563
|
-
*
|
|
564
|
-
* ```html
|
|
565
|
-
* <vaadin-checkbox-group label="Export data">
|
|
566
|
-
* <vaadin-checkbox value="0" label="Order ID"></vaadin-checkbox>
|
|
567
|
-
* <vaadin-checkbox value="1" label="Product name"></vaadin-checkbox>
|
|
568
|
-
* <vaadin-checkbox value="2" label="Customer"></vaadin-checkbox>
|
|
569
|
-
* <vaadin-checkbox value="3" label="Status"></vaadin-checkbox>
|
|
570
|
-
* </vaadin-checkbox-group>
|
|
571
|
-
* ```
|
|
572
|
-
*
|
|
573
|
-
* ### Styling
|
|
574
|
-
*
|
|
575
|
-
* The following shadow DOM parts are available for styling:
|
|
576
|
-
*
|
|
577
|
-
* Part name | Description
|
|
578
|
-
* ---------------------|----------------
|
|
579
|
-
* `label` | The slotted label element wrapper
|
|
580
|
-
* `group-field` | The checkbox elements wrapper
|
|
581
|
-
* `helper-text` | The slotted helper text element wrapper
|
|
582
|
-
* `error-message` | The slotted error message element wrapper
|
|
583
|
-
* `required-indicator` | The `required` state indicator element
|
|
584
|
-
*
|
|
585
|
-
* The following state attributes are available for styling:
|
|
586
|
-
*
|
|
587
|
-
* Attribute | Description | Part name
|
|
588
|
-
* --------------------|-------------------------------------------|------------
|
|
589
|
-
* `disabled` | Set when the element is disabled | :host
|
|
590
|
-
* `invalid` | Set when the element is invalid | :host
|
|
591
|
-
* `focused` | Set when the element is focused | :host
|
|
592
|
-
* `has-label` | Set when the element has a label | :host
|
|
593
|
-
* `has-value` | Set when the element has a value | :host
|
|
594
|
-
* `has-helper` | Set when the element has helper text | :host
|
|
595
|
-
* `has-error-message` | Set when the element has an error message | :host
|
|
596
|
-
*
|
|
597
|
-
* See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
|
|
598
|
-
*
|
|
599
|
-
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
600
|
-
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
601
|
-
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
602
|
-
*
|
|
603
|
-
* @customElement
|
|
604
|
-
* @extends HTMLElement
|
|
605
|
-
* @mixes ThemableMixin
|
|
606
|
-
* @mixes DisabledMixin
|
|
607
|
-
* @mixes ElementMixin
|
|
608
|
-
* @mixes FocusMixin
|
|
609
|
-
* @mixes FieldMixin
|
|
610
|
-
*/
|
|
611
|
-
class CheckboxGroup extends FieldMixin(FocusMixin(DisabledMixin(ElementMixin(ThemableMixin(PolymerElement))))) {
|
|
612
|
-
static get is() {
|
|
613
|
-
return 'vaadin-checkbox-group';
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
static get template() {
|
|
617
|
-
return html`
|
|
618
|
-
<style>
|
|
619
|
-
:host {
|
|
620
|
-
display: inline-flex;
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
:host::before {
|
|
624
|
-
content: '\\2003';
|
|
625
|
-
width: 0;
|
|
626
|
-
display: inline-block;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
:host([hidden]) {
|
|
630
|
-
display: none !important;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
.vaadin-group-field-container {
|
|
634
|
-
display: flex;
|
|
635
|
-
flex-direction: column;
|
|
636
|
-
width: 100%;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
[part='group-field'] {
|
|
640
|
-
display: flex;
|
|
641
|
-
flex-wrap: wrap;
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
:host(:not([has-label])) [part='label'] {
|
|
645
|
-
display: none;
|
|
646
|
-
}
|
|
647
|
-
</style>
|
|
648
|
-
|
|
649
|
-
<div class="vaadin-group-field-container">
|
|
650
|
-
<div part="label">
|
|
651
|
-
<slot name="label"></slot>
|
|
652
|
-
<span part="required-indicator" aria-hidden="true"></span>
|
|
653
|
-
</div>
|
|
654
|
-
|
|
655
|
-
<div part="group-field">
|
|
656
|
-
<slot></slot>
|
|
657
|
-
</div>
|
|
658
|
-
|
|
659
|
-
<div part="helper-text">
|
|
660
|
-
<slot name="helper"></slot>
|
|
661
|
-
</div>
|
|
662
|
-
|
|
663
|
-
<div part="error-message">
|
|
664
|
-
<slot name="error-message"></slot>
|
|
665
|
-
</div>
|
|
666
|
-
</div>
|
|
667
|
-
|
|
668
|
-
<slot name="tooltip"></slot>
|
|
669
|
-
`;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
static get properties() {
|
|
673
|
-
return {
|
|
674
|
-
/**
|
|
675
|
-
* An array containing values of the currently checked checkboxes.
|
|
676
|
-
*
|
|
677
|
-
* The array is immutable so toggling checkboxes always results in
|
|
678
|
-
* creating a new array.
|
|
679
|
-
*
|
|
680
|
-
* @type {!Array<!string>}
|
|
681
|
-
*/
|
|
682
|
-
value: {
|
|
683
|
-
type: Array,
|
|
684
|
-
value: () => [],
|
|
685
|
-
notify: true,
|
|
686
|
-
observer: '__valueChanged',
|
|
687
|
-
},
|
|
688
|
-
};
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
constructor() {
|
|
692
|
-
super();
|
|
693
|
-
|
|
694
|
-
this.__registerCheckbox = this.__registerCheckbox.bind(this);
|
|
695
|
-
this.__unregisterCheckbox = this.__unregisterCheckbox.bind(this);
|
|
696
|
-
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
|
-
}
|
|
721
|
-
|
|
722
|
-
/** @protected */
|
|
723
|
-
ready() {
|
|
724
|
-
super.ready();
|
|
725
|
-
|
|
726
|
-
this.ariaTarget = this;
|
|
727
|
-
|
|
728
|
-
// See https://github.com/vaadin/vaadin-web-components/issues/94
|
|
729
|
-
this.setAttribute('role', 'group');
|
|
730
|
-
|
|
731
|
-
const slot = this.shadowRoot.querySelector('slot:not([name])');
|
|
732
|
-
this._observer = new SlotObserver(slot, ({ addedNodes, removedNodes }) => {
|
|
733
|
-
const addedCheckboxes = this.__filterCheckboxes(addedNodes);
|
|
734
|
-
const removedCheckboxes = this.__filterCheckboxes(removedNodes);
|
|
735
|
-
|
|
736
|
-
addedCheckboxes.forEach(this.__registerCheckbox);
|
|
737
|
-
removedCheckboxes.forEach(this.__unregisterCheckbox);
|
|
738
|
-
|
|
739
|
-
const inputs = this.__checkboxes.map((checkbox) => checkbox.inputElement);
|
|
740
|
-
this._tooltipController.setAriaTarget(inputs);
|
|
741
|
-
|
|
742
|
-
this.__warnOfCheckboxesWithoutValue(addedCheckboxes);
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
this.addController(this._tooltipController);
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Override method inherited from `ValidateMixin`
|
|
750
|
-
* to validate the value array.
|
|
751
|
-
*
|
|
752
|
-
* @override
|
|
753
|
-
* @return {boolean}
|
|
754
|
-
*/
|
|
755
|
-
checkValidity() {
|
|
756
|
-
return !this.required || this.value.length > 0;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/**
|
|
760
|
-
* @param {!Array<!Node>} nodes
|
|
761
|
-
* @return {!Array<!Checkbox>}
|
|
762
|
-
* @private
|
|
763
|
-
*/
|
|
764
|
-
__filterCheckboxes(nodes) {
|
|
765
|
-
return nodes.filter((child) => child instanceof Checkbox);
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
/**
|
|
769
|
-
* @param {!Array<!Checkbox>} checkboxes
|
|
770
|
-
* @private
|
|
771
|
-
*/
|
|
772
|
-
__warnOfCheckboxesWithoutValue(checkboxes) {
|
|
773
|
-
const hasCheckboxesWithoutValue = checkboxes.some((checkbox) => {
|
|
774
|
-
const { value } = checkbox;
|
|
775
|
-
|
|
776
|
-
return !checkbox.hasAttribute('value') && (!value || value === 'on');
|
|
777
|
-
});
|
|
778
|
-
|
|
779
|
-
if (hasCheckboxesWithoutValue) {
|
|
780
|
-
console.warn('Please provide the value attribute to all the checkboxes inside the checkbox group.');
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
/**
|
|
785
|
-
* Registers the checkbox after adding it to the group.
|
|
786
|
-
*
|
|
787
|
-
* @param {!Checkbox} checkbox
|
|
788
|
-
* @private
|
|
789
|
-
*/
|
|
790
|
-
__registerCheckbox(checkbox) {
|
|
791
|
-
checkbox.addEventListener('checked-changed', this.__onCheckboxCheckedChanged);
|
|
792
|
-
|
|
793
|
-
if (this.disabled) {
|
|
794
|
-
checkbox.disabled = true;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
if (checkbox.checked) {
|
|
798
|
-
this.__addCheckboxToValue(checkbox.value);
|
|
799
|
-
} else if (this.value.includes(checkbox.value)) {
|
|
800
|
-
checkbox.checked = true;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* Unregisters the checkbox before removing it from the group.
|
|
806
|
-
*
|
|
807
|
-
* @param {!Checkbox} checkbox
|
|
808
|
-
* @private
|
|
809
|
-
*/
|
|
810
|
-
__unregisterCheckbox(checkbox) {
|
|
811
|
-
checkbox.removeEventListener('checked-changed', this.__onCheckboxCheckedChanged);
|
|
812
|
-
|
|
813
|
-
if (checkbox.checked) {
|
|
814
|
-
this.__removeCheckboxFromValue(checkbox.value);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* Override method inherited from `DisabledMixin`
|
|
820
|
-
* to propagate the `disabled` property to the checkboxes.
|
|
821
|
-
*
|
|
822
|
-
* @param {boolean} newValue
|
|
823
|
-
* @param {boolean} oldValue
|
|
824
|
-
* @override
|
|
825
|
-
* @protected
|
|
826
|
-
*/
|
|
827
|
-
_disabledChanged(newValue, oldValue) {
|
|
828
|
-
super._disabledChanged(newValue, oldValue);
|
|
829
|
-
|
|
830
|
-
// Prevent updating the `disabled` property for the checkboxes at initialization.
|
|
831
|
-
// Otherwise, the checkboxes may end up enabled regardless the `disabled` attribute
|
|
832
|
-
// intentionally added by the user on some of them.
|
|
833
|
-
if (!newValue && oldValue === undefined) {
|
|
834
|
-
return;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
if (oldValue !== newValue) {
|
|
838
|
-
this.__checkboxes.forEach((checkbox) => {
|
|
839
|
-
checkbox.disabled = newValue;
|
|
840
|
-
});
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* @param {string} value
|
|
846
|
-
* @private
|
|
847
|
-
*/
|
|
848
|
-
__addCheckboxToValue(value) {
|
|
849
|
-
if (!this.value.includes(value)) {
|
|
850
|
-
this.value = [...this.value, value];
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
/**
|
|
855
|
-
* @param {string} value
|
|
856
|
-
* @private
|
|
857
|
-
*/
|
|
858
|
-
__removeCheckboxFromValue(value) {
|
|
859
|
-
if (this.value.includes(value)) {
|
|
860
|
-
this.value = this.value.filter((v) => v !== value);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
|
|
864
|
-
/**
|
|
865
|
-
* @param {!CustomEvent} event
|
|
866
|
-
* @private
|
|
867
|
-
*/
|
|
868
|
-
__onCheckboxCheckedChanged(event) {
|
|
869
|
-
const checkbox = event.target;
|
|
870
|
-
|
|
871
|
-
if (checkbox.checked) {
|
|
872
|
-
this.__addCheckboxToValue(checkbox.value);
|
|
873
|
-
} else {
|
|
874
|
-
this.__removeCheckboxFromValue(checkbox.value);
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* @param {string | null | undefined} value
|
|
880
|
-
* @param {string | null | undefined} oldValue
|
|
881
|
-
* @private
|
|
882
|
-
*/
|
|
883
|
-
__valueChanged(value, oldValue) {
|
|
884
|
-
// Setting initial value to empty array, skip validation
|
|
885
|
-
if (value.length === 0 && oldValue === undefined) {
|
|
886
|
-
return;
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
this.toggleAttribute('has-value', value.length > 0);
|
|
890
|
-
|
|
891
|
-
this.__checkboxes.forEach((checkbox) => {
|
|
892
|
-
checkbox.checked = value.includes(checkbox.value);
|
|
893
|
-
});
|
|
894
|
-
|
|
895
|
-
if (oldValue !== undefined) {
|
|
896
|
-
this.validate();
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
/**
|
|
901
|
-
* Override method inherited from `FocusMixin`
|
|
902
|
-
* to prevent removing the `focused` attribute
|
|
903
|
-
* when focus moves between checkboxes inside the group.
|
|
904
|
-
*
|
|
905
|
-
* @param {!FocusEvent} event
|
|
906
|
-
* @return {boolean}
|
|
907
|
-
* @protected
|
|
908
|
-
*/
|
|
909
|
-
_shouldRemoveFocus(event) {
|
|
910
|
-
return !this.contains(event.relatedTarget);
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
/**
|
|
914
|
-
* Override method inherited from `FocusMixin`
|
|
915
|
-
* to run validation when the group loses focus.
|
|
916
|
-
*
|
|
917
|
-
* @param {boolean} focused
|
|
918
|
-
* @override
|
|
919
|
-
* @protected
|
|
920
|
-
*/
|
|
921
|
-
_setFocused(focused) {
|
|
922
|
-
super._setFocused(focused);
|
|
923
|
-
|
|
924
|
-
// Do not validate when focusout is caused by document
|
|
925
|
-
// losing focus, which happens on browser tab switch.
|
|
926
|
-
if (!focused && document.hasFocus()) {
|
|
927
|
-
this.validate();
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
defineCustomElement$1(CheckboxGroup);
|
|
933
|
-
|
|
934
|
-
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
|
-
|
|
936
|
-
const CheckboxGroupInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
937
|
-
constructor() {
|
|
938
|
-
super();
|
|
939
|
-
this.__registerHost();
|
|
940
|
-
this.__attachShadow();
|
|
941
|
-
this.sendValidityState = createEvent(this, "sendValidityState", 7);
|
|
942
|
-
this.sendInputValue = createEvent(this, "sendInputValue", 7);
|
|
943
|
-
/**
|
|
944
|
-
* Default value for the input.
|
|
945
|
-
*/
|
|
946
|
-
this.defaultValue = '';
|
|
947
|
-
/**
|
|
948
|
-
* Client custom styling via inline style
|
|
949
|
-
*/
|
|
950
|
-
this.clientStyling = '';
|
|
951
|
-
this.limitStylingAppends = false;
|
|
952
|
-
this.showTooltip = false;
|
|
953
|
-
this.selectedValues = [];
|
|
954
|
-
this.value = null;
|
|
955
|
-
this.setClientStyling = () => {
|
|
956
|
-
let sheet = document.createElement('style');
|
|
957
|
-
sheet.innerHTML = this.clientStyling;
|
|
958
|
-
this.stylingContainer.prepend(sheet);
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
validityChanged() {
|
|
962
|
-
this.validityStateHandler({ valid: this.isValid, name: this.name });
|
|
963
|
-
if (this.emitValue == true) {
|
|
964
|
-
this.valueHandler({ name: this.name, value: this.value, type: 'checkboxgroup' });
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
setValue() {
|
|
968
|
-
this.value = this.options.reduce((acc, option) => {
|
|
969
|
-
acc[option.name] = this.selectedValues.includes(option.name);
|
|
970
|
-
return acc;
|
|
971
|
-
}, {});
|
|
972
|
-
this.emitValueHandler(true);
|
|
973
|
-
}
|
|
974
|
-
validityStateHandler(inputStateEvent) {
|
|
975
|
-
this.sendValidityState.emit(inputStateEvent);
|
|
976
|
-
}
|
|
977
|
-
emitValueHandler(newValue) {
|
|
978
|
-
if (newValue == true && this.isValid) {
|
|
979
|
-
this.valueHandler({ name: this.name, value: this.value, type: 'checkboxgroup' });
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
valueHandler(inputValueEvent) {
|
|
983
|
-
this.sendInputValue.emit(inputValueEvent);
|
|
984
|
-
}
|
|
985
|
-
handleClickOutside(event) {
|
|
986
|
-
if (event.composedPath()[0] === this.tooltipIconReference)
|
|
987
|
-
return;
|
|
988
|
-
if (event.composedPath()[0] !== this.tooltipReference)
|
|
989
|
-
this.showTooltip = false;
|
|
990
|
-
}
|
|
991
|
-
componentDidRender() {
|
|
992
|
-
// start custom styling area
|
|
993
|
-
if (!this.limitStylingAppends && this.stylingContainer) {
|
|
994
|
-
if (this.clientStyling)
|
|
995
|
-
this.setClientStyling();
|
|
996
|
-
this.limitStylingAppends = true;
|
|
997
|
-
}
|
|
998
|
-
// end custom styling area
|
|
999
|
-
}
|
|
1000
|
-
componentDidLoad() {
|
|
1001
|
-
this.inputReference = this.element.shadowRoot.querySelector('input');
|
|
1002
|
-
// For now this input has no validation. Send isValid as true immediately.
|
|
1003
|
-
//@TODO: add validation logic to it, if business reason arises.
|
|
1004
|
-
this.isValid = this.setValidity();
|
|
1005
|
-
if (this.defaultValue) {
|
|
1006
|
-
this.selectedValues = this.options.map((checkbox) => checkbox.name);
|
|
1007
|
-
this.value = this.defaultValue;
|
|
1008
|
-
this.valueHandler({ name: this.name, value: this.value });
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
setValidity() {
|
|
1012
|
-
return this.inputReference.validity.valid;
|
|
1013
|
-
}
|
|
1014
|
-
setErrorMessage() {
|
|
1015
|
-
if (this.inputReference.validity.valueMissing) {
|
|
1016
|
-
return translate('requiredError', this.language);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
renderTooltip() {
|
|
1020
|
-
if (this.showTooltip) {
|
|
1021
|
-
return (h("div", { class: `checkboxgroup__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
|
|
1022
|
-
}
|
|
1023
|
-
return null;
|
|
1024
|
-
}
|
|
1025
|
-
handleParentCheckbox(e) {
|
|
1026
|
-
// Logic for toggling the children checkboxes.
|
|
1027
|
-
this.selectedValues = e.target.checked
|
|
1028
|
-
? this.options.map((checkbox) => checkbox.name)
|
|
1029
|
-
: [];
|
|
1030
|
-
}
|
|
1031
|
-
renderLabel() {
|
|
1032
|
-
return (h("label", { class: 'checkbox__label', htmlFor: `${this.name}__input`, slot: 'label' }, h("div", { class: 'checkbox__label-text', innerHTML: `${this.displayName} ${this.validation.mandatory ? '*' : ''}` })));
|
|
1033
|
-
}
|
|
1034
|
-
render() {
|
|
1035
|
-
return h("div", { class: `checkboxgroup__wrapper ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { class: 'checkboxgroup__wrapper--flex' }, h("vaadin-checkbox", { class: 'checkbox__input', checked: this.selectedValues.length === this.options.length || this.defaultValue === 'true', indeterminate: this.selectedValues.length > 0 && this.selectedValues.length < this.options.length, onChange: (e) => this.handleParentCheckbox(e) }, this.renderLabel()), this.tooltip &&
|
|
1036
|
-
h("img", { class: 'checkboxgroup__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip()), h("small", { class: 'checkboxgroup__error-message' }, this.errorMessage), h("vaadin-checkbox-group", { theme: "vertical", value: this.selectedValues, "on-value-changed": (event) => {
|
|
1037
|
-
this.selectedValues = event.detail.value;
|
|
1038
|
-
} }, this.options.map((checkbox) => h("vaadin-checkbox", { class: 'checkbox__input', name: checkbox.name, value: checkbox.name, label: checkbox.displayName }))));
|
|
1039
|
-
}
|
|
1040
|
-
get element() { return this; }
|
|
1041
|
-
static get watchers() { return {
|
|
1042
|
-
"isValid": ["validityChanged"],
|
|
1043
|
-
"selectedValues": ["setValue"],
|
|
1044
|
-
"emitValue": ["emitValueHandler"]
|
|
1045
|
-
}; }
|
|
1046
|
-
static get style() { return checkboxGroupInputCss; }
|
|
1047
|
-
}, [1, "checkbox-group-input", {
|
|
1048
|
-
"name": [513],
|
|
1049
|
-
"displayName": [513, "display-name"],
|
|
1050
|
-
"defaultValue": [513, "default-value"],
|
|
1051
|
-
"autofilled": [516],
|
|
1052
|
-
"tooltip": [513],
|
|
1053
|
-
"options": [16],
|
|
1054
|
-
"validation": [16],
|
|
1055
|
-
"language": [513],
|
|
1056
|
-
"emitValue": [516, "emit-value"],
|
|
1057
|
-
"clientStyling": [513, "client-styling"],
|
|
1058
|
-
"errorMessage": [32],
|
|
1059
|
-
"isValid": [32],
|
|
1060
|
-
"limitStylingAppends": [32],
|
|
1061
|
-
"showTooltip": [32],
|
|
1062
|
-
"selectedValues": [32]
|
|
1063
|
-
}, [[4, "click", "handleClickOutside"]]]);
|
|
1064
|
-
function defineCustomElement() {
|
|
1065
|
-
if (typeof customElements === "undefined") {
|
|
1066
|
-
return;
|
|
1067
|
-
}
|
|
1068
|
-
const components = ["checkbox-group-input"];
|
|
1069
|
-
components.forEach(tagName => { switch (tagName) {
|
|
1070
|
-
case "checkbox-group-input":
|
|
1071
|
-
if (!customElements.get(tagName)) {
|
|
1072
|
-
customElements.define(tagName, CheckboxGroupInput);
|
|
1073
|
-
}
|
|
1074
|
-
break;
|
|
1075
|
-
} });
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
export { CheckboxGroupInput as C, defineCustomElement as d };
|