wj-elements 0.1.97 → 0.1.99
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/wje-checkbox.js +171 -1
- package/dist/wje-routerx.js +4 -1
- package/dist/wje-select.js +168 -2
- package/package.json +1 -1
package/dist/wje-checkbox.js
CHANGED
|
@@ -16,6 +16,113 @@ class Checkbox extends WJElement {
|
|
|
16
16
|
* The class name.
|
|
17
17
|
*/
|
|
18
18
|
__publicField(this, "className", "Checkbox");
|
|
19
|
+
this.internals = this.attachInternals();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Setter for the value attribute.
|
|
23
|
+
* @param {string} value - The value to set.
|
|
24
|
+
*/
|
|
25
|
+
set value(value) {
|
|
26
|
+
this.internals.setFormValue(value);
|
|
27
|
+
if (this.input)
|
|
28
|
+
this.input.value = value;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Getter for the value attribute.
|
|
32
|
+
* @returns {string} The value of the attribute.
|
|
33
|
+
*/
|
|
34
|
+
get value() {
|
|
35
|
+
var _a;
|
|
36
|
+
return ((_a = this.input) == null ? void 0 : _a.value) || "";
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Getter for the customErrorDisplay attribute.
|
|
40
|
+
* @returns {boolean} Whether the attribute is present.
|
|
41
|
+
*/
|
|
42
|
+
get customErrorDisplay() {
|
|
43
|
+
return this.hasAttribute("custom-error-display");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Getter for the validateOnChange attribute.
|
|
47
|
+
* @returns {boolean} Whether the attribute is present.
|
|
48
|
+
*/
|
|
49
|
+
get validateOnChange() {
|
|
50
|
+
return this.hasAttribute("validate-on-change");
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Getter for the invalid attribute.
|
|
54
|
+
* @returns {boolean} Whether the attribute is present.
|
|
55
|
+
*/
|
|
56
|
+
get invalid() {
|
|
57
|
+
return this.hasAttribute("invalid");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Setter for the invalid attribute.
|
|
61
|
+
* @param {boolean} isInvalid - Whether the input is invalid.
|
|
62
|
+
*/
|
|
63
|
+
set invalid(isInvalid) {
|
|
64
|
+
isInvalid ? this.setAttribute("invalid", "") : this.removeAttribute("invalid");
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Getter for the form attribute.
|
|
68
|
+
* @returns {HTMLFormElement} The form the input is associated with.
|
|
69
|
+
*/
|
|
70
|
+
get form() {
|
|
71
|
+
return this.internals.form;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Getter for the name attribute.
|
|
75
|
+
* @returns {string} The name of the input.
|
|
76
|
+
*/
|
|
77
|
+
get name() {
|
|
78
|
+
return this.getAttribute("name");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Getter for the type attribute.
|
|
82
|
+
* @returns {string} The type of the input.
|
|
83
|
+
*/
|
|
84
|
+
get type() {
|
|
85
|
+
return this.localName;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Getter for the validity attribute.
|
|
89
|
+
* @returns {ValidityState} The validity state of the input.
|
|
90
|
+
*/
|
|
91
|
+
get validity() {
|
|
92
|
+
return this.internals.validity;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Getter for the validationMessage attribute.
|
|
96
|
+
* @returns {string} The validation message of the input.
|
|
97
|
+
*/
|
|
98
|
+
get validationMessage() {
|
|
99
|
+
return this.internals.validationMessage;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Getter for the willValidate attribute.
|
|
103
|
+
* @returns {boolean} Whether the input will be validated.
|
|
104
|
+
*/
|
|
105
|
+
get willValidate() {
|
|
106
|
+
return this.internals.willValidate;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @summary Getter for the defaultValue attribute.
|
|
110
|
+
* This method retrieves the 'value' attribute of the custom input element.
|
|
111
|
+
* The 'value' attribute represents the default value of the input element.
|
|
112
|
+
* If the 'value' attribute is not set, it returns an empty string.
|
|
113
|
+
* @returns {string} The default value of the input element.
|
|
114
|
+
*/
|
|
115
|
+
get defaultValue() {
|
|
116
|
+
return this.getAttribute("value") ?? "";
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* @summary Setter for the defaultValue attribute.
|
|
120
|
+
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
121
|
+
* The 'value' attribute represents the default value of the input element.
|
|
122
|
+
* @param {string} value - The value to set as the default value.
|
|
123
|
+
*/
|
|
124
|
+
set defaultValue(value) {
|
|
125
|
+
this.setAttribute("value", value);
|
|
19
126
|
}
|
|
20
127
|
/**
|
|
21
128
|
* @summary Set checked attribute
|
|
@@ -59,7 +166,7 @@ class Checkbox extends WJElement {
|
|
|
59
166
|
return styles;
|
|
60
167
|
}
|
|
61
168
|
static get observedAttributes() {
|
|
62
|
-
return ["checked", "disabled"];
|
|
169
|
+
return ["checked", "disabled", "value"];
|
|
63
170
|
}
|
|
64
171
|
/**
|
|
65
172
|
* Sets up the attributes for the checkbox.
|
|
@@ -101,10 +208,12 @@ class Checkbox extends WJElement {
|
|
|
101
208
|
afterDraw() {
|
|
102
209
|
if (!this.disabled) {
|
|
103
210
|
this.input.addEventListener("input", (e) => {
|
|
211
|
+
this.value = e.target.checked;
|
|
104
212
|
this.checked = e.target.checked;
|
|
105
213
|
event.dispatchCustomEvent(this, "wje-toggle:input");
|
|
106
214
|
});
|
|
107
215
|
this.input.addEventListener("change", (e) => {
|
|
216
|
+
this.value = e.target.checked;
|
|
108
217
|
this.checked = e.target.checked;
|
|
109
218
|
event.dispatchCustomEvent(this, "wje-toggle:change");
|
|
110
219
|
});
|
|
@@ -116,7 +225,68 @@ class Checkbox extends WJElement {
|
|
|
116
225
|
disconnectedCallback() {
|
|
117
226
|
event.removeElement(this.input);
|
|
118
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* @summary Callback function that is called when the custom element is associated with a form.
|
|
230
|
+
* This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
|
|
231
|
+
* @param {HTMLFormElement} form - The form the custom element is associated with.
|
|
232
|
+
*/
|
|
233
|
+
formAssociatedCallback(form) {
|
|
234
|
+
form.addEventListener("submit", () => {
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
|
|
239
|
+
* This method is responsible for resetting the value of the custom input element to its default value.
|
|
240
|
+
* It also resets the form value and validity state in the form internals.
|
|
241
|
+
*
|
|
242
|
+
* @method
|
|
243
|
+
*/
|
|
244
|
+
formResetCallback() {
|
|
245
|
+
this.value = this.defaultValue;
|
|
246
|
+
this.internals.setFormValue(this.defaultValue);
|
|
247
|
+
this.internals.setValidity({});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
|
|
251
|
+
* This method is responsible for restoring the value of the custom input element to its saved state.
|
|
252
|
+
* It also restores the form value and validity state in the form internals to their saved states.
|
|
253
|
+
*
|
|
254
|
+
* @param {Object} state - The saved state of the custom input element.
|
|
255
|
+
* @method
|
|
256
|
+
*/
|
|
257
|
+
formStateRestoreCallback(state) {
|
|
258
|
+
this.value = state.value;
|
|
259
|
+
this.internals.setFormValue(state.value);
|
|
260
|
+
this.internals.setValidity({});
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
|
|
264
|
+
* This method is responsible for saving the value of the custom input element.
|
|
265
|
+
*
|
|
266
|
+
* @returns {Object} The saved state of the custom input element.
|
|
267
|
+
* @method
|
|
268
|
+
*/
|
|
269
|
+
formStateSaveCallback() {
|
|
270
|
+
return {
|
|
271
|
+
value: this.value
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
|
|
276
|
+
* This method is not implemented yet.
|
|
277
|
+
*
|
|
278
|
+
* @param {boolean} disabled - The new disabled state of the custom input element.
|
|
279
|
+
* @method
|
|
280
|
+
*/
|
|
281
|
+
formDisabledCallback(disabled) {
|
|
282
|
+
console.warn("formDisabledCallback not implemented yet");
|
|
283
|
+
}
|
|
119
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Whether the input is associated with a form.
|
|
287
|
+
* @type {boolean}
|
|
288
|
+
*/
|
|
289
|
+
__publicField(Checkbox, "formAssociated", true);
|
|
120
290
|
WJElement.define("wje-checkbox", Checkbox);
|
|
121
291
|
export {
|
|
122
292
|
Checkbox as default
|
package/dist/wje-routerx.js
CHANGED
|
@@ -1526,7 +1526,10 @@ class Routerx extends WJElement {
|
|
|
1526
1526
|
const attributeName = attributes[i].name;
|
|
1527
1527
|
const attributeValue = attributes[i].value;
|
|
1528
1528
|
if (attributeName === "component" && attributeValue.indexOf(".js") > -1) {
|
|
1529
|
-
obj.component = () => import(
|
|
1529
|
+
obj.component = () => import(
|
|
1530
|
+
/*vite-ignore*/
|
|
1531
|
+
attributeValue
|
|
1532
|
+
);
|
|
1530
1533
|
} else {
|
|
1531
1534
|
if (attributeName !== "shadow") {
|
|
1532
1535
|
const camelCase = attributeName.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
package/dist/wje-select.js
CHANGED
|
@@ -66,6 +66,110 @@ class Select extends WJElement {
|
|
|
66
66
|
});
|
|
67
67
|
this._selected = [];
|
|
68
68
|
this.counterEl = null;
|
|
69
|
+
this.internals = this.attachInternals();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Setter for the value attribute.
|
|
73
|
+
* @param {string} value - The value to set.
|
|
74
|
+
*/
|
|
75
|
+
set value(value) {
|
|
76
|
+
this.internals.setFormValue(JSON.stringify(value));
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Getter for the value attribute.
|
|
80
|
+
* @returns {string} The value of the attribute.
|
|
81
|
+
*/
|
|
82
|
+
get value() {
|
|
83
|
+
return this.selected;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Getter for the customErrorDisplay attribute.
|
|
87
|
+
* @returns {boolean} Whether the attribute is present.
|
|
88
|
+
*/
|
|
89
|
+
get customErrorDisplay() {
|
|
90
|
+
return this.hasAttribute("custom-error-display");
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Getter for the validateOnChange attribute.
|
|
94
|
+
* @returns {boolean} Whether the attribute is present.
|
|
95
|
+
*/
|
|
96
|
+
get validateOnChange() {
|
|
97
|
+
return this.hasAttribute("validate-on-change");
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Getter for the invalid attribute.
|
|
101
|
+
* @returns {boolean} Whether the attribute is present.
|
|
102
|
+
*/
|
|
103
|
+
get invalid() {
|
|
104
|
+
return this.hasAttribute("invalid");
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Setter for the invalid attribute.
|
|
108
|
+
* @param {boolean} isInvalid - Whether the input is invalid.
|
|
109
|
+
*/
|
|
110
|
+
set invalid(isInvalid) {
|
|
111
|
+
isInvalid ? this.setAttribute("invalid", "") : this.removeAttribute("invalid");
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Getter for the form attribute.
|
|
115
|
+
* @returns {HTMLFormElement} The form the input is associated with.
|
|
116
|
+
*/
|
|
117
|
+
get form() {
|
|
118
|
+
return this.internals.form;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Getter for the name attribute.
|
|
122
|
+
* @returns {string} The name of the input.
|
|
123
|
+
*/
|
|
124
|
+
get name() {
|
|
125
|
+
return this.getAttribute("name");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Getter for the type attribute.
|
|
129
|
+
* @returns {string} The type of the input.
|
|
130
|
+
*/
|
|
131
|
+
get type() {
|
|
132
|
+
return this.localName;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Getter for the validity attribute.
|
|
136
|
+
* @returns {ValidityState} The validity state of the input.
|
|
137
|
+
*/
|
|
138
|
+
get validity() {
|
|
139
|
+
return this.internals.validity;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Getter for the validationMessage attribute.
|
|
143
|
+
* @returns {string} The validation message of the input.
|
|
144
|
+
*/
|
|
145
|
+
get validationMessage() {
|
|
146
|
+
return this.internals.validationMessage;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Getter for the willValidate attribute.
|
|
150
|
+
* @returns {boolean} Whether the input will be validated.
|
|
151
|
+
*/
|
|
152
|
+
get willValidate() {
|
|
153
|
+
return this.internals.willValidate;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @summary Getter for the defaultValue attribute.
|
|
157
|
+
* This method retrieves the 'value' attribute of the custom input element.
|
|
158
|
+
* The 'value' attribute represents the default value of the input element.
|
|
159
|
+
* If the 'value' attribute is not set, it returns an empty string.
|
|
160
|
+
* @returns {string} The default value of the input element.
|
|
161
|
+
*/
|
|
162
|
+
get defaultValue() {
|
|
163
|
+
return this.getAttribute("value") ?? "";
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @summary Setter for the defaultValue attribute.
|
|
167
|
+
* This method sets the 'value' attribute of the custom input element to the provided value.
|
|
168
|
+
* The 'value' attribute represents the default value of the input element.
|
|
169
|
+
* @param {string} value - The value to set as the default value.
|
|
170
|
+
*/
|
|
171
|
+
set defaultValue(value) {
|
|
172
|
+
this.setAttribute("value", value);
|
|
69
173
|
}
|
|
70
174
|
/**
|
|
71
175
|
* Sets the selected value.
|
|
@@ -305,8 +409,9 @@ class Select extends WJElement {
|
|
|
305
409
|
* @param {number} length - The length of the selected options.
|
|
306
410
|
*/
|
|
307
411
|
selectionChanged(option = null, length = 0) {
|
|
412
|
+
var _a, _b;
|
|
308
413
|
if (this.hasAttribute("multiple")) {
|
|
309
|
-
this.value = this.selectedOptions.map((el) => el).reverse();
|
|
414
|
+
this.value = this.selectedOptions.map((el) => el.value).reverse();
|
|
310
415
|
if (this.placeholder && length === 0) {
|
|
311
416
|
this.chips.innerHTML = this.placeholder;
|
|
312
417
|
this.input.value = "";
|
|
@@ -320,7 +425,7 @@ class Select extends WJElement {
|
|
|
320
425
|
}
|
|
321
426
|
} else {
|
|
322
427
|
let value = (option == null ? void 0 : option.textContent.trim()) || "";
|
|
323
|
-
this.value = value;
|
|
428
|
+
this.value = (_b = (_a = this.selectedOptions) == null ? void 0 : _a.map((el) => el.value)) == null ? void 0 : _b.at(0);
|
|
324
429
|
this.input.value = value;
|
|
325
430
|
if (option && option instanceof HTMLElement) {
|
|
326
431
|
this.slotStart.innerHTML = "";
|
|
@@ -386,7 +491,68 @@ class Select extends WJElement {
|
|
|
386
491
|
chip.appendChild(label);
|
|
387
492
|
return chip;
|
|
388
493
|
}
|
|
494
|
+
/**
|
|
495
|
+
* @summary Callback function that is called when the custom element is associated with a form.
|
|
496
|
+
* This function adds an event listener to the form's submit event, which validates the input and propagates the validation.
|
|
497
|
+
* @param {HTMLFormElement} form - The form the custom element is associated with.
|
|
498
|
+
*/
|
|
499
|
+
formAssociatedCallback(form) {
|
|
500
|
+
form.addEventListener("submit", () => {
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
|
|
505
|
+
* This method is responsible for resetting the value of the custom input element to its default value.
|
|
506
|
+
* It also resets the form value and validity state in the form internals.
|
|
507
|
+
*
|
|
508
|
+
* @method
|
|
509
|
+
*/
|
|
510
|
+
formResetCallback() {
|
|
511
|
+
this.value = this.defaultValue;
|
|
512
|
+
this.internals.setFormValue(this.defaultValue);
|
|
513
|
+
this.internals.setValidity({});
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
* The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
|
|
517
|
+
* This method is responsible for restoring the value of the custom input element to its saved state.
|
|
518
|
+
* It also restores the form value and validity state in the form internals to their saved states.
|
|
519
|
+
*
|
|
520
|
+
* @param {Object} state - The saved state of the custom input element.
|
|
521
|
+
* @method
|
|
522
|
+
*/
|
|
523
|
+
formStateRestoreCallback(state) {
|
|
524
|
+
this.value = state.value;
|
|
525
|
+
this.internals.setFormValue(state.value);
|
|
526
|
+
this.internals.setValidity({});
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
|
|
530
|
+
* This method is responsible for saving the value of the custom input element.
|
|
531
|
+
*
|
|
532
|
+
* @returns {Object} The saved state of the custom input element.
|
|
533
|
+
* @method
|
|
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
|
+
*
|
|
544
|
+
* @param {boolean} disabled - The new disabled state of the custom input element.
|
|
545
|
+
* @method
|
|
546
|
+
*/
|
|
547
|
+
formDisabledCallback(disabled) {
|
|
548
|
+
console.warn("formDisabledCallback not implemented yet");
|
|
549
|
+
}
|
|
389
550
|
}
|
|
551
|
+
/**
|
|
552
|
+
* Whether the input is associated with a form.
|
|
553
|
+
* @type {boolean}
|
|
554
|
+
*/
|
|
555
|
+
__publicField(Select, "formAssociated", true);
|
|
390
556
|
Select.define("wje-select", Select);
|
|
391
557
|
export {
|
|
392
558
|
Select as default
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wj-elements",
|
|
3
3
|
"description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.99",
|
|
5
5
|
"homepage": "https://github.com/lencys/wj-elements",
|
|
6
6
|
"author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
|
|
7
7
|
"license": "MIT",
|