wj-elements 0.1.184 → 0.1.185

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.
Files changed (39) hide show
  1. package/dist/form-associated-element-CaIxmEod.js +242 -0
  2. package/dist/form-associated-element-CaIxmEod.js.map +1 -0
  3. package/dist/light.css +3 -3
  4. package/dist/packages/internals/form-associated-element.d.ts +138 -0
  5. package/dist/packages/wje-checkbox/checkbox.element.d.ts +17 -90
  6. package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +1 -1
  7. package/dist/packages/wje-input/input.element.d.ts +3 -106
  8. package/dist/packages/wje-options/options.element.d.ts +23 -19
  9. package/dist/packages/wje-popup/popup.element.d.ts +10 -0
  10. package/dist/packages/wje-radio/radio.element.d.ts +12 -1
  11. package/dist/packages/wje-radio-group/radio-group.element.d.ts +8 -90
  12. package/dist/packages/wje-select/select.d.ts +1 -1
  13. package/dist/packages/wje-select/select.element.d.ts +56 -194
  14. package/dist/packages/wje-textarea/textarea.element.d.ts +3 -110
  15. package/dist/{popup.element-Di4nHYij.js → popup.element-CVbbnTWI.js} +53 -24
  16. package/dist/{popup.element-Di4nHYij.js.map → popup.element-CVbbnTWI.js.map} +1 -1
  17. package/dist/wje-checkbox.js +59 -403
  18. package/dist/wje-checkbox.js.map +1 -1
  19. package/dist/wje-dropdown.js +1 -1
  20. package/dist/wje-icon-picker.js +1 -1
  21. package/dist/wje-infinite-scroll.js +7 -2
  22. package/dist/wje-infinite-scroll.js.map +1 -1
  23. package/dist/wje-input.js +10 -213
  24. package/dist/wje-input.js.map +1 -1
  25. package/dist/wje-master.js +1 -1
  26. package/dist/wje-option.js.map +1 -1
  27. package/dist/wje-options.js +56 -45
  28. package/dist/wje-options.js.map +1 -1
  29. package/dist/wje-popup.js +1 -1
  30. package/dist/wje-radio-group.js +82 -148
  31. package/dist/wje-radio-group.js.map +1 -1
  32. package/dist/wje-radio.js +36 -8
  33. package/dist/wje-radio.js.map +1 -1
  34. package/dist/wje-select.js +186 -303
  35. package/dist/wje-select.js.map +1 -1
  36. package/dist/wje-textarea.js +16 -210
  37. package/dist/wje-textarea.js.map +1 -1
  38. package/dist/wje-tooltip.js +1 -1
  39. package/package.json +2 -2
@@ -10,269 +10,10 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var _internalValue;
12
12
  import WJElement from "./wje-element.js";
13
+ import { F as FormAssociatedElement } from "./form-associated-element-CaIxmEod.js";
13
14
  import { event } from "./event.js";
14
- const styles = `/*
15
- [ Checkbox ]
16
- */
17
-
18
- :host {
19
- display: block;
20
- margin-top: var(--wje-checkbox-margin-top);
21
- margin-bottom: var(--wje-checkbox-margin-bottom);
22
- margin-inline: var(--wje-checkbox-margin-inline);
23
- line-height: 100%;
24
- padding-left: 0;
25
-
26
- label {
27
- display: flex;
28
- align-items: center;
29
- cursor: pointer;
30
- position: relative;
31
- padding-left: calc(var(--wje-checkbox-size) + 0.5rem);
32
- /*min-width: var(--wje-checkbox-size);*/
33
- min-height: var(--wje-checkbox-size);
34
- margin-bottom: 0;
35
- &:before {
36
- content: '';
37
- position: absolute;
38
- width: var(--wje-checkbox-size);
39
- height: var(--wje-checkbox-size);
40
- left: 0;
41
- -webkit-box-sizing: inherit;
42
- box-sizing: border-box;
43
- background-color: var(--wje-color-contrast-0);
44
- border-width: 1px;
45
- border-style: solid;
46
- border-color: var(--wje-color-contrast-3);
47
- }
48
- }
49
- }
50
-
51
- .native-checkbox {
52
- label {
53
- &:hover {
54
- color: var(--wje-color-contrast-11);
55
- }
56
-
57
- &:before {
58
- border-radius: var(--wje-checkbox-border-radius);
59
- }
60
- }
61
-
62
- input[type='checkbox'] {
63
- position: absolute;
64
- margin: 0;
65
- z-index: -1;
66
- width: 16px;
67
- height: 16px;
68
- opacity: 0;
69
- display: none;
70
- & + label {
71
- &::after {
72
- content: '';
73
- position: absolute;
74
- left: 0;
75
- border-right: 0 solid transparent;
76
- border-bottom: 0 solid transparent;
77
- width: var(--wje-checkbox-size);
78
- height: var(--wje-checkbox-size);
79
- overflow: hidden;
80
- }
81
- }
82
- }
83
-
84
- input[type='checkbox']:checked + label::after {
85
- content: '';
86
- mask-image: var(--wje-checkbox-checkmark);
87
- mask-size: var(--wje-checkbox-size);
88
- background-color: var(--wje-color-primary-9);
89
- }
90
-
91
- /* Disabled */
92
- input[type='checkbox'][disabled] {
93
- & + label {
94
- cursor: not-allowed !important;
95
- color: var(--wje-color-contrast-8);
96
- opacity: 0.58;
97
-
98
- &:before {
99
- background: var(--wje-color-contrast-2);
100
- }
101
- &:after {
102
- background: transparent;
103
- }
104
- }
105
- }
106
-
107
- input[type='checkbox']:checked[disabled] {
108
- & + label {
109
- cursor: not-allowed !important;
110
- color: var(--wje-color-contrast-8);
111
- opacity: 0.58;
112
-
113
- &:before {
114
- background: var(--wje-color-contrast-2);
115
- }
116
- &:after {
117
- background: var(--wje-color-contrast-5);
118
- }
119
- }
120
- }
121
-
122
- /* Indeterminate */
123
- input[type='checkbox']:not(:checked):indeterminate {
124
- & + label {
125
- &:after {
126
- content: '';
127
- mask-image: var(--wje-checkbox-interminate);
128
- mask-size: var(--wje-checkbox-size);
129
- background-color: var(--wje-color-primary-9);
130
- }
131
- }
132
- }
133
- }
134
-
135
- :host([variant='circle']) {
136
- label {
137
- &:after {
138
- border-radius: 99px;
139
- }
140
-
141
- &:before {
142
- border-radius: 99px;
143
- }
144
- }
145
- }
146
-
147
- :host([placement='end']) {
148
- label {
149
- padding-left: 0;
150
- padding-right: 26px;
151
-
152
- &:before {
153
- right: 0;
154
- left: auto;
155
- }
156
- }
157
-
158
- input[type='checkbox']:checked {
159
- & + label {
160
- position: relative;
161
-
162
- &::after {
163
- position: absolute;
164
- right: 0;
165
- left: auto;
166
- }
167
- }
168
- }
169
- }
170
-
171
- /*Colors*/
172
-
173
- :host([color='primary']) {
174
- input[type='checkbox']:checked + label::after,
175
- input[type='checkbox']:indeterminate + label:after {
176
- background-color: var(--wje-color-contrast-0);
177
- }
178
- :is(input[type='checkbox']:checked + label)::before,
179
- :is(input[type='checkbox']:indeterminate + label)::before {
180
- border-color: var(--wje-color-primary-9);
181
- background-color: var(--wje-color-primary-9);
182
- }
183
- }
184
-
185
- :host([color='complete']) {
186
- input[type='checkbox']:checked + label::after,
187
- input[type='checkbox']:indeterminate + label:after {
188
- background-color: var(--wje-color-contrast-0);
189
- }
190
- :is(input[type='checkbox']:checked + label)::before,
191
- :is(input[type='checkbox']:indeterminate + label)::before {
192
- border-color: var(--wje-color-complete-9);
193
- background-color: var(--wje-color-complete-9);
194
- }
195
- }
196
-
197
- :host([color='success']) {
198
- input[type='checkbox']:checked + label::after,
199
- input[type='checkbox']:indeterminate + label:after {
200
- background-color: var(--wje-color-contrast-0);
201
- }
202
- :is(input[type='checkbox']:checked + label)::before,
203
- :is(input[type='checkbox']:indeterminate + label)::before {
204
- border-color: var(--wje-color-success-9);
205
- background-color: var(--wje-color-success-9);
206
- }
207
- }
208
-
209
- :host([color='warning']) {
210
- input[type='checkbox']:checked + label::after,
211
- input[type='checkbox']:indeterminate + label:after {
212
- background-color: var(--wje-color-contrast-0);
213
- }
214
- :is(input[type='checkbox']:checked + label)::before,
215
- :is(input[type='checkbox']:indeterminate + label)::before {
216
- border-color: var(--wje-color-warning-9);
217
- background-color: var(--wje-color-warning-9);
218
- }
219
- }
220
-
221
- :host([color='danger']) {
222
- input[type='checkbox']:checked + label::after,
223
- input[type='checkbox']:indeterminate + label:after {
224
- background-color: var(--wje-color-contrast-0);
225
- }
226
- :is(input[type='checkbox']:checked + label)::before,
227
- :is(input[type='checkbox']:indeterminate + label)::before {
228
- border-color: var(--wje-color-danger-9);
229
- background-color: var(--wje-color-danger-9);
230
- }
231
- }
232
-
233
- :host([color='info']) {
234
- input[type='checkbox']:checked + label::after,
235
- input[type='checkbox']:indeterminate + label:after {
236
- background-color: var(--wje-color-contrast-0);
237
- }
238
- :is(input[type='checkbox']:checked + label)::before,
239
- :is(input[type='checkbox']:indeterminate + label)::before {
240
- border-color: var(--wje-color-info-9);
241
- background-color: var(--wje-color-info-9);
242
- }
243
- }
244
-
245
- /*input[type="checkbox"]:checked + label {*/
246
- /* .info > *::after,*/
247
- /* .danger > *::after,*/
248
- /* .complete > *::after,*/
249
- /* .primary > *::after,*/
250
- /* .success > *::after {*/
251
- /* background: var(--wje-white-check-icon);*/
252
- /* }*/
253
- /*}*/
254
-
255
- /*input[type="checkbox"]:indeterminate + label {*/
256
- /* .info > *::after,*/
257
- /* .danger > *::after,*/
258
- /* .complete > *::after,*/
259
- /* .primary > *::after,*/
260
- /* .success > *::after {*/
261
- /* background-color: var(--wje-color-contrast-0);*/
262
- /* }*/
263
- /*}*/
264
-
265
- /* hide focus style if not from keyboard navigation */
266
- /*.js-focus-visible .native-checkbox input[type="checkbox"]:focus:not(.focus-visible) + label:before {*/
267
- /* box-shadow: none;*/
268
- /*}*/
269
-
270
- /*input[type="checkbox"] {*/
271
- /* accent-color: var(--wje-color-primary) !important;*/
272
- /* font-size: 50px;*/
273
- /*}*/
274
- `;
275
- class Checkbox extends WJElement {
15
+ const styles = "/*\n[ Checkbox ]\n*/\n\n:host {\n display: block;\n margin-top: var(--wje-checkbox-margin-top);\n margin-bottom: var(--wje-checkbox-margin-bottom);\n margin-inline: var(--wje-checkbox-margin-inline);\n line-height: 100%;\n padding-left: 0;\n\n label {\n display: flex;\n align-items: center;\n cursor: pointer;\n position: relative;\n padding-left: calc(var(--wje-checkbox-size) + 0.5rem);\n min-height: var(--wje-checkbox-size);\n margin-bottom: 0;\n &:before {\n content: '';\n position: absolute;\n width: var(--wje-checkbox-size);\n height: var(--wje-checkbox-size);\n left: 0;\n -webkit-box-sizing: inherit;\n box-sizing: border-box;\n background-color: var(--wje-color-contrast-0);\n border-width: 1px;\n border-style: solid;\n border-color: var(--wje-color-contrast-3);\n }\n }\n}\n\n.native-checkbox {\n label {\n &:hover {\n color: var(--wje-color-contrast-11);\n }\n\n &:before {\n border-radius: var(--wje-checkbox-border-radius);\n }\n }\n\n input[type='checkbox'] {\n position: absolute;\n margin: 0;\n z-index: -1;\n width: 16px;\n height: 16px;\n opacity: 0;\n display: none;\n & + label {\n &::after {\n content: '';\n position: absolute;\n left: 0;\n border-right: 0 solid transparent;\n border-bottom: 0 solid transparent;\n width: var(--wje-checkbox-size);\n height: var(--wje-checkbox-size);\n overflow: hidden;\n }\n }\n }\n\n input[type='checkbox']:checked + label::after {\n content: '';\n mask-image: var(--wje-checkbox-checkmark);\n mask-size: var(--wje-checkbox-size);\n background-color: var(--wje-color-primary-9);\n }\n\n /* Disabled */\n input[type='checkbox'][disabled] {\n & + label {\n cursor: not-allowed !important;\n color: var(--wje-color-contrast-8);\n opacity: 0.58;\n\n &:before {\n background: var(--wje-color-contrast-2);\n }\n &:after {\n background: transparent;\n }\n }\n }\n\n input[type='checkbox']:checked[disabled] {\n & + label {\n cursor: not-allowed !important;\n color: var(--wje-color-contrast-8);\n opacity: 0.58;\n\n &:before {\n background: var(--wje-color-contrast-2);\n }\n &:after {\n background: var(--wje-color-contrast-5);\n }\n }\n }\n\n /* Indeterminate */\n input[type='checkbox']:not(:checked):indeterminate {\n & + label {\n &:after {\n content: '';\n mask-image: var(--wje-checkbox-interminate);\n mask-size: var(--wje-checkbox-size);\n background-color: var(--wje-color-primary-9);\n }\n }\n }\n}\n\n:host([invalid]) {\n label{\n color: var(--wje-input-color-invalid);\n }\n}\n\nslot[name='error'] {\n display: none;\n}\n\n:host([invalid]) slot[name='error'] {\n display: block;\n}\n\n:host([variant='circle']) {\n label {\n &:after {\n border-radius: 99px;\n }\n\n &:before {\n border-radius: 99px;\n }\n }\n}\n\n:host([placement='end']) {\n label {\n padding-left: 0;\n padding-right: 26px;\n\n &:before {\n right: 0;\n left: auto;\n }\n }\n\n input[type='checkbox']:checked {\n & + label {\n position: relative;\n\n &::after {\n position: absolute;\n right: 0;\n left: auto;\n }\n }\n }\n}\n\nslot[name='error'] {\n display: none;\n max-width: 100%;\n min-width: auto;\n border-radius: 50px;\n top: 0;\n width: max-content;\n line-height: normal;\n position: static;\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-input-color-invalid);\n font-size: 12px;\n}\n\n/*Colors*/\n\n:host([color='primary']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-primary-9);\n background-color: var(--wje-color-primary-9);\n }\n}\n\n:host([color='complete']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-complete-9);\n background-color: var(--wje-color-complete-9);\n }\n}\n\n:host([color='success']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-success-9);\n background-color: var(--wje-color-success-9);\n }\n}\n\n:host([color='warning']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-warning-9);\n background-color: var(--wje-color-warning-9);\n }\n}\n\n:host([color='danger']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-danger-9);\n background-color: var(--wje-color-danger-9);\n }\n}\n\n:host([color='info']) {\n input[type='checkbox']:checked + label::after,\n input[type='checkbox']:indeterminate + label:after {\n background-color: var(--wje-color-contrast-0);\n }\n :is(input[type='checkbox']:checked + label)::before,\n :is(input[type='checkbox']:indeterminate + label)::before {\n border-color: var(--wje-color-info-9);\n background-color: var(--wje-color-info-9);\n }\n}\n";
16
+ class Checkbox extends FormAssociatedElement {
276
17
  /**
277
18
  * Checkbox constructor method.
278
19
  */
@@ -283,7 +24,8 @@ class Checkbox extends WJElement {
283
24
  * The class name for the Checkbox.
284
25
  */
285
26
  __publicField(this, "className", "Checkbox");
286
- this.internals = this.attachInternals();
27
+ this.invalid = false;
28
+ this.pristine = true;
287
29
  }
288
30
  /**
289
31
  * Setter for the value attribute.
@@ -295,6 +37,7 @@ class Checkbox extends WJElement {
295
37
  if (this.input) {
296
38
  this.input.value = value;
297
39
  this.input.checked = value;
40
+ this.pristine = false;
298
41
  }
299
42
  }
300
43
  /**
@@ -319,61 +62,13 @@ class Checkbox extends WJElement {
319
62
  return this.hasAttribute("validate-on-change");
320
63
  }
321
64
  /**
322
- * Setter for the invalid attribute.
323
- * @param {boolean} isInvalid Whether the input is invalid.
324
- */
325
- set invalid(isInvalid) {
326
- if (isInvalid) this.setAttribute("invalid", "");
327
- else this.removeAttribute("invalid");
328
- }
329
- /**
330
- * Getter for the invalid attribute.
331
- * @returns {boolean} Whether the attribute is present.
332
- */
333
- get invalid() {
334
- return this.hasAttribute("invalid");
335
- }
336
- /**
337
- * Getter for the form attribute.
338
- * @returns {HTMLFormElement} The form the input is associated with.
339
- */
340
- get form() {
341
- return this.internals.form;
342
- }
343
- /**
344
- * Getter for the name attribute.
345
- * @returns {string} The name of the input.
346
- */
347
- get name() {
348
- return this.getAttribute("name");
349
- }
350
- /**
351
- * Getter for the type attribute.
352
- * @returns {string} The type of the input.
353
- */
354
- get type() {
355
- return this.localName;
356
- }
357
- /**
358
- * Getter for the validity attribute.
359
- * @returns {ValidityState} The validity state of the input.
360
- */
361
- get validity() {
362
- return this.internals.validity;
363
- }
364
- /**
365
- * Getter for the validationMessage attribute.
366
- * @returns {string} The validation message of the input.
367
- */
368
- get validationMessage() {
369
- return this.internals.validationMessage;
370
- }
371
- /**
372
- * Getter for the willValidate attribute.
373
- * @returns {boolean} Whether the input will be validated.
65
+ * Setter for the defaultValue attribute.
66
+ * This method sets the 'value' attribute of the custom input element to the provided value.
67
+ * The 'value' attribute represents the default value of the input element.
68
+ * @param {string} value The value to set as the default value.
374
69
  */
375
- get willValidate() {
376
- return this.internals.willValidate;
70
+ set defaultValue(value) {
71
+ this.setAttribute("value", value);
377
72
  }
378
73
  /**
379
74
  * Getter for the defaultValue attribute.
@@ -386,28 +81,29 @@ class Checkbox extends WJElement {
386
81
  return this.getAttribute("value") ?? "";
387
82
  }
388
83
  /**
389
- * Setter for the defaultValue attribute.
390
- * This method sets the 'value' attribute of the custom input element to the provided value.
391
- * The 'value' attribute represents the default value of the input element.
392
- * @param {string} value The value to set as the default value.
393
- */
394
- set defaultValue(value) {
395
- this.setAttribute("value", value);
396
- }
397
- /**
398
- * Set checked attribute.
399
- * @param {boolean} value true if the toggle is checked, false otherwise
84
+ * Sets or removes the 'indeterminate' attribute for the object.
85
+ * This property typically reflects the visual or functional state where
86
+ * the component is neither fully active nor inactive.
87
+ * @param {boolean} value A boolean where `true` indicates the 'indeterminate'
88
+ * state should be set, and `false` removes it.
400
89
  */
401
- set disabled(value) {
402
- if (value) this.setAttribute("disabled", "");
403
- else this.removeAttribute("disabled");
90
+ set indeterminate(value) {
91
+ if (value) {
92
+ this.setAttribute("indeterminate", "");
93
+ } else {
94
+ this.removeAttribute("indeterminate");
95
+ }
404
96
  }
405
97
  /**
406
- * Get disabled attribute value.
407
- * @returns {boolean} true if the toggle is disabled, false otherwise
98
+ * Retrieves the current state of the 'indeterminate' attribute.
99
+ *
100
+ * The 'indeterminate' attribute is typically used to signify a state
101
+ * where a checkbox is neither checked nor unchecked, such as a partially
102
+ * selected state.
103
+ * @returns {boolean} Returns true if the 'indeterminate' attribute is present; otherwise, false.
408
104
  */
409
- get disabled() {
410
- return this.hasAttribute("disabled");
105
+ get indeterminate() {
106
+ return this.hasAttribute("indeterminate");
411
107
  }
412
108
  /**
413
109
  * Set checked attribute.
@@ -416,10 +112,8 @@ class Checkbox extends WJElement {
416
112
  set checked(value) {
417
113
  if (value) {
418
114
  this.setAttribute("checked", "");
419
- this.value = true;
420
115
  } else {
421
116
  this.removeAttribute("checked");
422
- this.value = false;
423
117
  }
424
118
  }
425
119
  /**
@@ -444,6 +138,10 @@ class Checkbox extends WJElement {
444
138
  */
445
139
  setupAttributes() {
446
140
  this.isShadowRoot = "open";
141
+ if (this.pristine) {
142
+ this.value = __privateGet(this, _internalValue);
143
+ this.pristine = false;
144
+ }
447
145
  }
448
146
  /**
449
147
  * Draws the checkbox element.
@@ -458,14 +156,21 @@ class Checkbox extends WJElement {
458
156
  input.type = "checkbox";
459
157
  input.id = "checkbox";
460
158
  input.name = this.name || "checkbox";
461
- input.checked = this.hasAttribute("checked");
462
- input.disabled = this.hasAttribute("disabled");
463
- input.indeterminate = this.hasAttribute("indeterminate");
159
+ input.checked = this.checked;
160
+ input.disabled = this.disabled;
161
+ input.indeterminate = this.indeterminate;
162
+ input.required = this.required;
464
163
  let label = document.createElement("label");
465
164
  label.htmlFor = "checkbox";
466
165
  label.innerHTML = "<slot></slot>";
467
- native.appendChild(input);
468
- native.appendChild(label);
166
+ let errorSlot = document.createElement("slot");
167
+ errorSlot.setAttribute("name", "error");
168
+ let error = document.createElement("div");
169
+ error.setAttribute("slot", "error");
170
+ native.append(input);
171
+ native.append(label);
172
+ native.append(errorSlot);
173
+ this.append(error);
469
174
  this.input = input;
470
175
  fragment.appendChild(native);
471
176
  return fragment;
@@ -476,15 +181,24 @@ class Checkbox extends WJElement {
476
181
  afterDraw() {
477
182
  if (!this.disabled) {
478
183
  this.input.addEventListener("input", (e) => {
184
+ this.validate();
185
+ this.pristine = false;
186
+ this.propagateValidation();
479
187
  this.value = e.target.checked;
480
- this.checked = e.target.checked;
481
188
  event.dispatchCustomEvent(this, "wje-toggle:input");
482
189
  });
483
190
  this.input.addEventListener("change", (e) => {
484
- this.value = e.target.checked;
485
- this.checked = e.target.checked;
486
191
  event.dispatchCustomEvent(this, "wje-toggle:change");
487
192
  });
193
+ this.addEventListener("wje-checkbox:invalid", (e) => {
194
+ this.invalid = true;
195
+ this.pristine = false;
196
+ this.showInvalidMessage();
197
+ });
198
+ this.validate();
199
+ if (this.invalid) {
200
+ this.showInvalidMessage();
201
+ }
488
202
  }
489
203
  }
490
204
  /**
@@ -493,66 +207,8 @@ class Checkbox extends WJElement {
493
207
  beforeDisconnect() {
494
208
  event.removeElement(this.input);
495
209
  }
496
- /**
497
- * @summary Callback function that is called when the custom element is associated with a form.
498
- * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
499
- * @param {HTMLFormElement} form The form the custom element is associated with.
500
- */
501
- formAssociatedCallback(form) {
502
- if (form) {
503
- this.internals.setFormValue(this.value);
504
- }
505
- }
506
- /**
507
- * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
508
- * This method is responsible for resetting the value of the custom input element to its default value.
509
- * It also resets the form value and validity state in the form internals.
510
- * @function
511
- */
512
- formResetCallback() {
513
- this.value = this.defaultValue;
514
- this.internals.setFormValue(this.defaultValue);
515
- this.internals.setValidity({});
516
- }
517
- /**
518
- * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
519
- * This method is responsible for restoring the value of the custom input element to its saved state.
520
- * It also restores the form value and validity state in the form internals to their saved states.
521
- * @param {object} state The saved state of the custom input element.
522
- * @function
523
- */
524
- formStateRestoreCallback(state) {
525
- this.value = state.value;
526
- this.internals.setFormValue(state.value);
527
- this.internals.setValidity({});
528
- }
529
- /**
530
- * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
531
- * This method is responsible for saving the value of the custom input element.
532
- * @returns {object} The saved state of the custom input element.
533
- * @function
534
- */
535
- formStateSaveCallback() {
536
- return {
537
- value: this.value
538
- };
539
- }
540
- /**
541
- * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
542
- * This method is not implemented yet.
543
- * @param {boolean} disabled The new disabled state of the custom input element.
544
- * @function
545
- */
546
- formDisabledCallback(disabled) {
547
- console.warn("formDisabledCallback not implemented yet");
548
- }
549
210
  }
550
211
  _internalValue = new WeakMap();
551
- /**
552
- * Whether the input is associated with a form.
553
- * @type {boolean}
554
- */
555
- __publicField(Checkbox, "formAssociated", true);
556
212
  WJElement.define("wje-checkbox", Checkbox);
557
213
  export {
558
214
  Checkbox as default
@@ -1 +1 @@
1
- {"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-checkbox:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments WJElement\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n * //@fires wje-checkbox:change - Dispatched when the checkbox state changes;\n */\nexport default class Checkbox extends WJElement {\n\t#internalValue = false;\n\t/**\n\t * Checkbox constructor method.\n\t */\n\tconstructor() {\n\t\tsuper();\n\t\tthis.internals = this.attachInternals();\n\t}\n\n\t/**\n\t * Setter for the value attribute.\n\t * @param {string} value The value to set.\n\t */\n\tset value(value) {\n\t\tthis.internals.setFormValue(value);\n\t\tthis.#internalValue = value;\n\n\t\tif (this.input) {\n\t\t\tthis.input.value = value;\n\t\t\tthis.input.checked = value;\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the value attribute.\n\t * @returns {string} The value of the attribute.\n\t */\n\tget value() {\n\t\treturn this.#internalValue;\n\t}\n\n\t/**\n\t * Getter for the customErrorDisplay attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget customErrorDisplay() {\n\t\treturn this.hasAttribute('custom-error-display');\n\t}\n\n\t/**\n\t * Getter for the validateOnChange attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget validateOnChange() {\n\t\treturn this.hasAttribute('validate-on-change');\n\t}\n\n\t/**\n\t * Setter for the invalid attribute.\n\t * @param {boolean} isInvalid Whether the input is invalid.\n\t */\n\tset invalid(isInvalid) {\n\t\tif (isInvalid) this.setAttribute('invalid', '');\n\t\telse this.removeAttribute('invalid');\n\t}\n\n\t/**\n\t * Getter for the invalid attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget invalid() {\n\t\treturn this.hasAttribute('invalid');\n\t}\n\n\t/**\n\t * Getter for the form attribute.\n\t * @returns {HTMLFormElement} The form the input is associated with.\n\t */\n\tget form() {\n\t\treturn this.internals.form;\n\t}\n\n\t/**\n\t * Getter for the name attribute.\n\t * @returns {string} The name of the input.\n\t */\n\tget name() {\n\t\treturn this.getAttribute('name');\n\t}\n\n\t/**\n\t * Getter for the type attribute.\n\t * @returns {string} The type of the input.\n\t */\n\tget type() {\n\t\treturn this.localName;\n\t}\n\n\t/**\n\t * Getter for the validity attribute.\n\t * @returns {ValidityState} The validity state of the input.\n\t */\n\tget validity() {\n\t\treturn this.internals.validity;\n\t}\n\n\t/**\n\t * Getter for the validationMessage attribute.\n\t * @returns {string} The validation message of the input.\n\t */\n\tget validationMessage() {\n\t\treturn this.internals.validationMessage;\n\t}\n\n\t/**\n\t * Getter for the willValidate attribute.\n\t * @returns {boolean} Whether the input will be validated.\n\t */\n\tget willValidate() {\n\t\treturn this.internals.willValidate;\n\t}\n\n\t/**\n\t * Getter for the defaultValue attribute.\n\t * This method retrieves the 'value' attribute of the custom input element.\n\t * The 'value' attribute represents the default value of the input element.\n\t * If the 'value' attribute is not set, it returns an empty string.\n\t * @returns {string} The default value of the input element.\n\t */\n\tget defaultValue() {\n\t\treturn this.getAttribute('value') ?? '';\n\t}\n\n\t/**\n\t * Setter for the defaultValue attribute.\n\t * This method sets the 'value' attribute of the custom input element to the provided value.\n\t * The 'value' attribute represents the default value of the input element.\n\t * @param {string} value The value to set as the default value.\n\t */\n\tset defaultValue(value) {\n\t\tthis.setAttribute('value', value);\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset disabled(value) {\n\t\tif (value) this.setAttribute('disabled', '');\n\t\telse this.removeAttribute('disabled');\n\t}\n\n\t/**\n\t * Get disabled attribute value.\n\t * @returns {boolean} true if the toggle is disabled, false otherwise\n\t */\n\tget disabled() {\n\t\treturn this.hasAttribute('disabled');\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset checked(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('checked', '');\n\t\t\tthis.value = true;\n\t\t}\n\t\telse {\n\t\t\tthis.removeAttribute('checked');\n\t\t\tthis.value = false;\n\t\t}\n\t}\n\n\t/**\n\t * Get checked attribute.\n\t * @returns {boolean} true if the toggle is checked, false otherwise\n\t */\n\tget checked() {\n\t\treturn this.hasAttribute('checked');\n\t}\n\n\t/**\n\t * The class name for the Checkbox.\n\t */\n\tclassName = 'Checkbox';\n\n\t/**\n\t * Getter for the CSS stylesheet.\n\t * @returns {string} The CSS stylesheet.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tstatic get observedAttributes() {\n\t\treturn ['checked', 'disabled', 'value', 'indeterminate'];\n\t}\n\n\t/**\n\t * Whether the input is associated with a form.\n\t * @type {boolean}\n\t */\n\tstatic formAssociated = true;\n\n\t/**\n\t * Sets up the attributes for the checkbox.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t}\n\n\t/**\n\t * Draws the checkbox element.\n\t * @returns {DocumentFragment} The created fragment.\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tlet native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.classList.add('native-checkbox');\n\n\t\tlet input = document.createElement('input');\n\t\tinput.type = 'checkbox';\n\t\tinput.id = 'checkbox';\n\t\tinput.name = this.name || 'checkbox';\n\t\tinput.checked = this.hasAttribute('checked');\n\t\tinput.disabled = this.hasAttribute('disabled');\n\t\tinput.indeterminate = this.hasAttribute('indeterminate');\n\n\t\tlet label = document.createElement('label');\n\t\tlabel.htmlFor = 'checkbox';\n\t\tlabel.innerHTML = '<slot></slot>';\n\n\t\tnative.appendChild(input);\n\t\tnative.appendChild(label);\n\n\t\tthis.input = input;\n\n\t\tfragment.appendChild(native);\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Adds an event listener after drawing the checkbox.\n\t */\n\tafterDraw() {\n\t\tif (!this.disabled) {\n\t\t\tthis.input.addEventListener('input', (e) => {\n\t\t\t\tthis.value = e.target.checked;\n\t\t\t\tthis.checked = e.target.checked;\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:input');\n\t\t\t});\n\n\t\t\tthis.input.addEventListener('change', (e) => {\n\t\t\t\tthis.value = e.target.checked;\n\t\t\t\tthis.checked = e.target.checked;\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:change');\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Removes the event listener when the checkbox is disconnected.\n\t */\n\tbeforeDisconnect() {\n\t\tevent.removeElement(this.input);\n\t}\n\n\t/**\n\t * @summary Callback function that is called when the custom element is associated with a form.\n\t * This function adds an event listener to the form's submit event, which validates the input and propagates the validation.\n\t * @param {HTMLFormElement} form The form the custom element is associated with.\n\t */\n\tformAssociatedCallback(form) {\n\t\tif (form) {\n\t\t\tthis.internals.setFormValue(this.value);\n\t\t}\n\t}\n\n\t/**\n\t * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.\n\t * This method is responsible for resetting the value of the custom input element to its default value.\n\t * It also resets the form value and validity state in the form internals.\n\t * @function\n\t */\n\tformResetCallback() {\n\t\t// Set the value of the custom input element to its default value\n\t\tthis.value = this.defaultValue;\n\t\t// Reset the form value in the form internals to the default value\n\t\tthis.internals.setFormValue(this.defaultValue);\n\t\t// Reset the validity state in the form internals\n\t\tthis.internals.setValidity({});\n\t}\n\n\t/**\n\t * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.\n\t * This method is responsible for restoring the value of the custom input element to its saved state.\n\t * It also restores the form value and validity state in the form internals to their saved states.\n\t * @param {object} state The saved state of the custom input element.\n\t * @function\n\t */\n\tformStateRestoreCallback(state) {\n\t\t// Set the value of the custom input element to its saved value\n\t\tthis.value = state.value;\n\t\t// Restore the form value in the form internals to the saved value\n\t\tthis.internals.setFormValue(state.value);\n\t\t// Restore the validity state in the form internals to the saved state\n\t\tthis.internals.setValidity({});\n\t}\n\n\t/**\n\t * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.\n\t * This method is responsible for saving the value of the custom input element.\n\t * @returns {object} The saved state of the custom input element.\n\t * @function\n\t */\n\tformStateSaveCallback() {\n\t\treturn {\n\t\t\tvalue: this.value,\n\t\t};\n\t}\n\n\t/**\n\t * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.\n\t * This method is not implemented yet.\n\t * @param {boolean} disabled The new disabled state of the custom input element.\n\t * @function\n\t */\n\tformDisabledCallback(disabled) {\n\t\tconsole.warn('formDisabledCallback not implemented yet');\n\t}\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './chec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AAM,oBAAoB,MAAM,mBAAmB;AAAA,MACvD,CAAI;AAAA,IACJ;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKC,mBAAmB;AAClB,UAAM,cAAc,KAAK,KAAK;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOC,uBAAuB,MAAM;AAC5B,QAAI,MAAM;AACT,WAAK,UAAU,aAAa,KAAK,KAAK;AAAA,IACzC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,oBAAoB;AAEnB,SAAK,QAAQ,KAAK;AAElB,SAAK,UAAU,aAAa,KAAK,YAAY;AAE7C,SAAK,UAAU,YAAY,EAAE;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASC,yBAAyB,OAAO;AAE/B,SAAK,QAAQ,MAAM;AAEnB,SAAK,UAAU,aAAa,MAAM,KAAK;AAEvC,SAAK,UAAU,YAAY,EAAE;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,wBAAwB;AACvB,WAAO;AAAA,MACN,OAAO,KAAK;AAAA,IACZ;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,qBAAqB,UAAU;AAC9B,YAAQ,KAAK,0CAA0C;AAAA,EACzD;AACA;AArUC;AAAA;AAAA;AAAA;AAAA;AAkMA,cAnMoB,UAmMb,kBAAiB;AChNzB,UAAU,OAAO,gBAAgB,QAAQ;"}
1
+ {"version":3,"file":"wje-checkbox.js","sources":["../packages/wje-checkbox/checkbox.element.js","../packages/wje-checkbox/checkbox.js"],"sourcesContent":["import { FormAssociatedElement } from '../internals/form-associated-element.js';\nimport { event } from '../utils/event.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This method dispatches a custom event named \"wje-checkbox:change\".\n * It is triggered when the input event is fired, which happens when the state of the checkbox changes.\n * The event is dispatched on the current instance of the Checkbox class.\n * @documentation https://elements.webjet.sk/components/checkbox\n * @status stable\n * @augments {FormAssociatedElement}\n * @slot - The checkbox main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-checkbox-border-radius=--wje-border-radius-medium] - Border radius of the component;\n * @cssproperty [--wje-checkbox-border-width=1px] - Border width of the component;\n * @cssproperty [--wje-checkbox-border-style=solid] - Border style of the component;\n * @cssproperty [--wje-checkbox-border-color=--wje-color-contrast-1] - Border color of the component;\n * @cssproperty [--wje-checkbox-margin-inline=0] - Margin inline of the component;\n * //@fires wje-checkbox:change - Dispatched when the checkbox state changes;\n */\nexport default class Checkbox extends FormAssociatedElement {\n\t#internalValue = false;\n\t/**\n\t * Checkbox constructor method.\n\t */\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis.invalid = false;\n\t\tthis.pristine = true;\n\t}\n\n\t/**\n\t * Setter for the value attribute.\n\t * @param {string} value The value to set.\n\t */\n\tset value(value) {\n\t\tthis.internals.setFormValue(value);\n\t\tthis.#internalValue = value;\n\n\t\tif (this.input) {\n\t\t\tthis.input.value = value;\n\t\t\tthis.input.checked = value;\n\t\t\tthis.pristine = false;\n\t\t}\n\t}\n\n\t/**\n\t * Getter for the value attribute.\n\t * @returns {string} The value of the attribute.\n\t */\n\tget value() {\n\t\treturn this.#internalValue;\n\t}\n\n\t/**\n\t * Getter for the customErrorDisplay attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget customErrorDisplay() {\n\t\treturn this.hasAttribute('custom-error-display');\n\t}\n\n\t/**\n\t * Getter for the validateOnChange attribute.\n\t * @returns {boolean} Whether the attribute is present.\n\t */\n\tget validateOnChange() {\n\t\treturn this.hasAttribute('validate-on-change');\n\t}\n\n\t/**\n\t * Setter for the defaultValue attribute.\n\t * This method sets the 'value' attribute of the custom input element to the provided value.\n\t * The 'value' attribute represents the default value of the input element.\n\t * @param {string} value The value to set as the default value.\n\t */\n\tset defaultValue(value) {\n\t\tthis.setAttribute('value', value);\n\t}\n\n\t/**\n\t * Getter for the defaultValue attribute.\n\t * This method retrieves the 'value' attribute of the custom input element.\n\t * The 'value' attribute represents the default value of the input element.\n\t * If the 'value' attribute is not set, it returns an empty string.\n\t * @returns {string} The default value of the input element.\n\t */\n\tget defaultValue() {\n\t\treturn this.getAttribute('value') ?? '';\n\t}\n\n\t/**\n\t * Sets or removes the 'indeterminate' attribute for the object.\n\t * This property typically reflects the visual or functional state where\n\t * the component is neither fully active nor inactive.\n\t * @param {boolean} value A boolean where `true` indicates the 'indeterminate'\n\t * state should be set, and `false` removes it.\n\t */\n\tset indeterminate(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('indeterminate', '');\n\t\t} else {\n\t\t\tthis.removeAttribute('indeterminate');\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves the current state of the 'indeterminate' attribute.\n\t *\n\t * The 'indeterminate' attribute is typically used to signify a state\n\t * where a checkbox is neither checked nor unchecked, such as a partially\n\t * selected state.\n\t * @returns {boolean} Returns true if the 'indeterminate' attribute is present; otherwise, false.\n\t */\n\tget indeterminate() {\n\t\treturn this.hasAttribute('indeterminate');\n\t}\n\n\t/**\n\t * Set checked attribute.\n\t * @param {boolean} value true if the toggle is checked, false otherwise\n\t */\n\tset checked(value) {\n\t\tif (value) {\n\t\t\tthis.setAttribute('checked', '');\n\t\t} else {\n\t\t\tthis.removeAttribute('checked');\n\t\t}\n\t}\n\n\t/**\n\t * Get checked attribute.\n\t * @returns {boolean} true if the toggle is checked, false otherwise\n\t */\n\tget checked() {\n\t\treturn this.hasAttribute('checked');\n\t}\n\n\t/**\n\t * The class name for the Checkbox.\n\t */\n\tclassName = 'Checkbox';\n\n\t/**\n\t * Getter for the CSS stylesheet.\n\t * @returns {string} The CSS stylesheet.\n\t */\n\tstatic get cssStyleSheet() {\n\t\treturn styles;\n\t}\n\n\tstatic get observedAttributes() {\n\t\treturn ['checked', 'disabled', 'value', 'indeterminate'];\n\t}\n\n\t/**\n\t * Sets up the attributes for the checkbox.\n\t */\n\tsetupAttributes() {\n\t\tthis.isShadowRoot = 'open';\n\t\t// if some value was set via value setter then dont use default value\n\t\tif (this.pristine) {\n\t\t\tthis.value = this.#internalValue;\n\t\t\tthis.pristine = false;\n\t\t}\n\t}\n\n\t/**\n\t * Draws the checkbox element.\n\t * @returns {DocumentFragment} The created fragment.\n\t */\n\tdraw() {\n\t\tlet fragment = document.createDocumentFragment();\n\n\t\tlet native = document.createElement('div');\n\t\tnative.setAttribute('part', 'native');\n\t\tnative.classList.add('native-checkbox');\n\n\t\tlet input = document.createElement('input');\n\t\tinput.type = 'checkbox';\n\t\tinput.id = 'checkbox';\n\t\tinput.name = this.name || 'checkbox';\n\t\tinput.checked = this.checked;\n\t\tinput.disabled = this.disabled;\n\t\tinput.indeterminate = this.indeterminate;\n\t\tinput.required = this.required;\n\n\t\tlet label = document.createElement('label');\n\t\tlabel.htmlFor = 'checkbox';\n\t\tlabel.innerHTML = '<slot></slot>';\n\n\t\t// Error\n\t\tlet errorSlot = document.createElement('slot');\n\t\terrorSlot.setAttribute('name', 'error');\n\n\t\tlet error = document.createElement('div');\n\t\terror.setAttribute('slot', 'error');\n\n\t\tnative.append(input);\n\t\tnative.append(label);\n\t\tnative.append(errorSlot);\n\n\t\tthis.append(error);\n\n\t\tthis.input = input;\n\n\t\tfragment.appendChild(native);\n\n\t\treturn fragment;\n\t}\n\n\t/**\n\t * Adds an event listener after drawing the checkbox.\n\t */\n\tafterDraw() {\n\t\tif (!this.disabled) {\n\t\t\tthis.input.addEventListener('input', (e) => {\n\t\t\t\tthis.validate();\n\n\t\t\t\tthis.pristine = false;\n\t\t\t\tthis.propagateValidation();\n\n\t\t\t\tthis.value = e.target.checked;\n\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:input');\n\t\t\t});\n\n\t\t\tthis.input.addEventListener('change', (e) => {\n\t\t\t\tevent.dispatchCustomEvent(this, 'wje-toggle:change');\n\t\t\t});\n\n\t\t\tthis.addEventListener('wje-checkbox:invalid', (e) => {\n\t\t\t\tthis.invalid = true;\n\t\t\t\tthis.pristine = false;\n\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t});\n\n\t\t\tthis.validate();\n\n\t\t\tif (this.invalid) {\n\t\t\t\tthis.showInvalidMessage();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Removes the event listener when the checkbox is disconnected.\n\t */\n\tbeforeDisconnect() {\n\t\tevent.removeElement(this.input);\n\t}\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Checkbox from './checkbox.element.js';\n\n// export * from \"./checkbox.element.js\";\nexport default Checkbox;\n\nWJElement.define('wje-checkbox', Checkbox);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAoBe,MAAM,iBAAiB,sBAAsB;AAAA;AAAA;AAAA;AAAA,EAK3D,cAAc;AACb,UAAO;AALR,uCAAiB;AAyHjB;AAAA;AAAA;AAAA,qCAAY;AAlHX,SAAK,UAAU;AACf,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,MAAM,OAAO;AAChB,SAAK,UAAU,aAAa,KAAK;AACjC,uBAAK,gBAAiB;AAEtB,QAAI,KAAK,OAAO;AACf,WAAK,MAAM,QAAQ;AACnB,WAAK,MAAM,UAAU;AACrB,WAAK,WAAW;AAAA,IACnB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,QAAQ;AACX,WAAO,mBAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,qBAAqB;AACxB,WAAO,KAAK,aAAa,sBAAsB;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMC,IAAI,mBAAmB;AACtB,WAAO,KAAK,aAAa,oBAAoB;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQC,IAAI,aAAa,OAAO;AACvB,SAAK,aAAa,SAAS,KAAK;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import WJElement from "./wje-element.js";
5
- import { P as Popup } from "./popup.element-Di4nHYij.js";
5
+ import { P as Popup } from "./popup.element-CVbbnTWI.js";
6
6
  import { event } from "./event.js";
7
7
  class Dropdown extends WJElement {
8
8
  /**
@@ -7,7 +7,7 @@ import InfiniteScroll from "./wje-infinite-scroll.js";
7
7
  import Input from "./wje-input.js";
8
8
  import "./wje-popup.js";
9
9
  import Tooltip from "./wje-tooltip.js";
10
- import { P as Popup } from "./popup.element-Di4nHYij.js";
10
+ import { P as Popup } from "./popup.element-CVbbnTWI.js";
11
11
  import { event } from "./event.js";
12
12
  const styles = "/*\n[ Wj Icon Picker ]\n*/\n\n:host {\n padding: 0 1rem;\n}\n\n.anchor {\n width: var(--wje-icon-picker-icon-size);\n height: var(--wje-icon-picker-icon-size);\n padding: var(--wje-icon-picker-padding);\n border-width: var(--wje-icon-picker-border-width);\n border-style: var(--wje-icon-picker-border-style);\n border-color: var(--wje-icon-picker-border-color);\n box-sizing: border-box;\n border-radius: var(--wje-icon-picker-radius);\n}\n\n.picker {\n width: 320px;\n height: 271px;\n box-shadow:\n 0 0 5px rgba(0, 0, 0, 0.05),\n 0 5px 20px rgba(0, 0, 0, 0.1);\n border-radius: var(--wje-icon-picker-radius);\n border-width: var(--wje-icon-picker-border-width);\n border-style: var(--wje-icon-picker-border-style);\n border-color: var(--wje-icon-picker-border-color);\n overflow: auto;\n padding: 1rem;\n background: var(--wje-background);\n}\n\n.icon-items {\n --icon-min-width: 2rem;\n display: grid;\n grid-gap: 0.5rem;\n grid-template-columns: repeat(auto-fit, minmax(var(--icon-min-width), 1fr));\n}\n\n.icon-item {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n color: inherit;\n padding: 0.25rem;\n min-height: var(--wje-icon-picker-icon-size);\n min-width: var(--wje-icon-picker-icon-size);\n text-decoration: none;\n\n &:hover {\n border-radius: 0.25rem;\n background: var(--wje-border-color);\n }\n}\n\n.wje-size {\n --wje-icon-size: 24px !important;\n}\n\nicon-item svg {\n width: var(--wje-icon-picker-icon-size);\n height: var(--wje-icon-picker-icon-size);\n}\n\nwje-input {\n --wje-input-border-radius: 4px;\n --wje-input-margin-bottom: 0;\n}\n\nwje-infinite-scroll {\n margin-top: 1rem;\n}\n\nwje-select {\n --wje-select-border-width: 0 0 1px 0 !important;\n --wje-select-border-radius: 0 !important;\n margin-bottom: 1rem;\n}\n\n.anchor wje-icon {\n --wje-icon-size: 100% !important;\n}\n";
13
13
  class IconPicker extends WJElement {