wj-elements 0.1.129 → 0.1.130

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 (104) hide show
  1. package/README.md +8 -4
  2. package/dist/assets/tags.json +3252 -22012
  3. package/dist/dark.css +213 -210
  4. package/dist/{infinite-scroll.element-R3y_ZQj6.js → infinite-scroll.element-BmojLp3Z.js} +16 -34
  5. package/dist/light.css +511 -501
  6. package/dist/{list.element-syl98NWS.js → list.element-Ce1vIm1O.js} +2 -11
  7. package/dist/localize.js +1 -2
  8. package/dist/{popup.element-C0a1z1y2.js → popup.element-4DNn6DjX.js} +102 -224
  9. package/dist/{router-links-I2vcmVCs.js → router-links-CJnOdbas.js} +30 -77
  10. package/dist/styles.css +485 -473
  11. package/dist/wje-accordion-item.js +12 -10
  12. package/dist/wje-accordion.js +51 -14
  13. package/dist/wje-animation.js +9 -13
  14. package/dist/wje-aside.js +6 -11
  15. package/dist/wje-avatar.js +7 -10
  16. package/dist/wje-badge.js +23 -18
  17. package/dist/wje-breadcrumb.js +30 -48
  18. package/dist/wje-breadcrumbs.js +80 -23
  19. package/dist/wje-button-group.js +15 -21
  20. package/dist/wje-button.js +64 -71
  21. package/dist/wje-card-content.js +9 -12
  22. package/dist/wje-card-controls.js +9 -12
  23. package/dist/wje-card-header.js +4 -8
  24. package/dist/wje-card-subtitle.js +4 -7
  25. package/dist/wje-card-title.js +4 -7
  26. package/dist/wje-card.js +13 -14
  27. package/dist/wje-carousel-item.js +25 -0
  28. package/dist/wje-carousel.js +140 -23
  29. package/dist/wje-checkbox.js +294 -48
  30. package/dist/wje-chip.js +30 -11
  31. package/dist/wje-col.js +7 -17
  32. package/dist/wje-color-picker.js +32 -34
  33. package/dist/wje-container.js +5 -9
  34. package/dist/wje-copy-button.js +11 -15
  35. package/dist/wje-dialog.js +12 -17
  36. package/dist/wje-divider.js +1 -4
  37. package/dist/wje-dropdown.js +41 -23
  38. package/dist/wje-element.js +214 -196
  39. package/dist/wje-file-upload-item.js +11 -21
  40. package/dist/wje-file-upload.js +64 -59
  41. package/dist/wje-footer.js +2 -9
  42. package/dist/wje-form.js +22 -0
  43. package/dist/wje-format-digital.js +4 -12
  44. package/dist/wje-grid.js +23 -2
  45. package/dist/wje-header.js +2 -9
  46. package/dist/wje-icon-picker.js +14 -33
  47. package/dist/wje-icon.js +9 -12
  48. package/dist/wje-img-comparer.js +7 -15
  49. package/dist/wje-img.js +3 -12
  50. package/dist/wje-infinite-scroll.js +1 -1
  51. package/dist/wje-input-file.js +19 -19
  52. package/dist/wje-input.js +50 -66
  53. package/dist/wje-item.js +11 -15
  54. package/dist/wje-kanban.js +22 -23
  55. package/dist/wje-label.js +3 -11
  56. package/dist/wje-list.js +1 -1
  57. package/dist/wje-main.js +3 -10
  58. package/dist/wje-masonry.js +16 -21
  59. package/dist/wje-master.js +197 -236
  60. package/dist/wje-menu-button.js +4 -15
  61. package/dist/wje-menu-item.js +209 -37
  62. package/dist/wje-menu-label.js +3 -10
  63. package/dist/wje-menu.js +5 -17
  64. package/dist/wje-option.js +18 -29
  65. package/dist/wje-options.js +141 -55
  66. package/dist/wje-orgchart-group.js +8 -15
  67. package/dist/wje-orgchart-item.js +10 -157
  68. package/dist/wje-orgchart.js +3 -9
  69. package/dist/wje-popup.js +1 -1
  70. package/dist/wje-progress-bar.js +11 -25
  71. package/dist/wje-qr-code.js +27 -11
  72. package/dist/wje-radio-group.js +20 -45
  73. package/dist/wje-radio.js +45 -7
  74. package/dist/wje-rate.js +35 -58
  75. package/dist/wje-relative-time.js +19 -29
  76. package/dist/wje-reorder-dropzone.js +20 -2
  77. package/dist/wje-reorder-handle.js +62 -3
  78. package/dist/wje-reorder-item.js +20 -2
  79. package/dist/wje-reorder.js +43 -49
  80. package/dist/wje-route.js +2 -8
  81. package/dist/wje-router-link.js +9 -12
  82. package/dist/wje-router-outlet.js +35 -37
  83. package/dist/wje-routerx.js +231 -340
  84. package/dist/wje-row.js +7 -9
  85. package/dist/wje-select.js +72 -99
  86. package/dist/wje-slider.js +13 -32
  87. package/dist/wje-sliding-container.js +3 -7
  88. package/dist/wje-split-view.js +8 -22
  89. package/dist/wje-status.js +8 -12
  90. package/dist/wje-step.js +18 -0
  91. package/dist/wje-stepper.js +41 -4823
  92. package/dist/wje-store.js +178 -74
  93. package/dist/wje-tab-group.js +7 -19
  94. package/dist/wje-tab-panel.js +3 -12
  95. package/dist/wje-tab.js +5 -16
  96. package/dist/wje-textarea.js +127 -47
  97. package/dist/wje-thumbnail.js +9 -14
  98. package/dist/wje-toast.js +27 -64
  99. package/dist/wje-toggle.js +21 -32
  100. package/dist/wje-toolbar-action.js +10 -14
  101. package/dist/wje-toolbar.js +10 -15
  102. package/dist/wje-tooltip.js +33 -25
  103. package/dist/wje-visually-hidden.js +9 -13
  104. package/package.json +15 -8
@@ -2,15 +2,25 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __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, { event } from "./wje-element.js";
5
- const styles = '/*\n[ WJ Textarea ]\n*/\n\n:host {\n width: 100%;\n margin-bottom: var(--wje-textarea-margin-bottom);\n display: block;\n .wrapper {\n display: flex;\n width: 100%;\n border-width: var(--wje-textarea-border-width);\n border-style: var(--wje-textarea-border-style);\n border-color: var(--wje-textarea-border-color);\n border-radius: var(--wje-textarea-border-radius);\n box-sizing: border-box;\n }\n textarea {\n font-family: var(--wje-textarea-font-family);\n color: var(--wje-textarea-color);\n font-size: 14px;\n border: 0 none;\n padding: 0 var(--wje-textarea-padding);\n &:focus {\n outline: none;\n }\n }\n}\n\n:host([resize="auto"]) textarea,\n:host([resize="none"]) textarea {\n resize: none;\n}\n\n.native-textarea {\n .input-wrapper {\n width: 100%;\n line-height: normal;\n }\n &.default {\n background-color: var(--wje-textarea-background-color);\n font-family: var(--wje-textarea-font-family);\n position: relative;\n padding-inline: 0;\n padding-top: 0;\n transition: background-color 0.2s ease;\n cursor: text;\n &.focused {\n .wrapper {\n border-color: var(--wje-textarea-border-color-focus) !important;\n }\n label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n textarea {\n border: none;\n padding-top: 0;\n background: none;\n box-shadow: none;\n width: calc(100% - var(--wje-textarea-padding) * 2);\n max-width: calc(100% - var(--wje-textarea-padding) * 2);\n min-width: calc(100% - var(--wje-textarea-padding) * 2);\n }\n label {\n padding: 0 var(--wje-textarea-padding);\n display: block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-textarea-line-height);\n padding-top: .25rem;\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n ::slotted([slot="start"]) {\n border-left: none;\n border-top: none;\n border-bottom: none;\n }\n\n ::slotted([slot="end"]) {\n border-right: none;\n border-top: none;\n border-bottom: none;\n }\n }\n &.standard {\n font-family: var(--wje-textarea-font-family);\n position: relative;\n border-radius: var(--wje-textarea-border-radius);\n padding: 0;\n transition: background-color 0.2s ease;\n cursor: text;\n &.focused {\n .wrapper {\n border-color: var(--wje-textarea-border-color-focus) !important;\n }\n }\n textarea {\n background-color: var(--wje-textarea-background-color);\n display: block;\n min-height: 32px;\n box-shadow: none;\n width: 100%;\n box-sizing: border-box;\n border-radius: var(--wje-textarea-border-radius);\n }\n label {\n margin: 0;\n display: inline-block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-textarea-line-height);\n }\n ::slotted([slot="start"]) {\n border-right: none;\n border-radius: var(--wje-textarea-border-radius) 0 0 var(--wje-textarea-border-radius);\n }\n\n ::slotted([slot="end"]) {\n border-left: none;\n border-radius: 0 var(--wje-textarea-border-radius) var(--wje-textarea-border-radius) 0;\n }\n\n &.has-start textarea{\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n\n &.has-end textarea{\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n .error-message {\n position: static;\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-textarea-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n}\n\n.counter {\n float: right;\n}';
5
+ const styles = "/*\n[ WJ Textarea ]\n*/\n\n:host {\n width: 100%;\n margin-bottom: var(--wje-textarea-margin-bottom);\n display: block;\n .wrapper {\n display: flex;\n width: 100%;\n border-width: var(--wje-textarea-border-width);\n border-style: var(--wje-textarea-border-style);\n border-color: var(--wje-textarea-border-color);\n border-radius: var(--wje-textarea-border-radius);\n box-sizing: border-box;\n }\n textarea {\n font-family: var(--wje-textarea-font-family);\n color: var(--wje-textarea-color);\n font-size: 14px;\n border: 0 none;\n padding: 0 var(--wje-textarea-padding);\n &:focus {\n outline: none;\n }\n }\n}\n\n:host([invalid]) {\n .error-message {\n display: block;\n }\n .default {\n label {\n opacity: 1 !important;\n color: var(--wje-input-color-invalid) !important;\n animation-name: shake;\n animation-duration: 0.4s;\n animation-iteration-count: 1;\n }\n }\n}\n\n:host([required]) .input-wrapper::after {\n color: var(--wje-input-color-invalid);\n content: '*';\n font-family: var(--wje-force-mac-font-family);\n font-size: 20px;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n:host([required]) .standard .input-wrapper::after {\n top: 0;\n}\n\n:host([resize='auto']) textarea,\n:host([resize='none']) textarea {\n resize: none;\n}\n\n.native-textarea {\n .input-wrapper {\n width: 100%;\n line-height: normal;\n }\n &.default {\n background-color: var(--wje-textarea-background-color);\n font-family: var(--wje-textarea-font-family);\n position: relative;\n padding-inline: 0;\n padding-top: 0;\n transition: background-color 0.2s ease;\n cursor: text;\n &.focused {\n .wrapper {\n border-color: var(--wje-textarea-border-color-focus) !important;\n }\n label {\n opacity: 0.67;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n textarea {\n border: none;\n padding-top: 0;\n background: none;\n box-shadow: none;\n width: calc(100% - var(--wje-textarea-padding) * 2);\n max-width: calc(100% - var(--wje-textarea-padding) * 2);\n min-width: calc(100% - var(--wje-textarea-padding) * 2);\n }\n label {\n padding: 0 var(--wje-textarea-padding);\n display: block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-textarea-line-height);\n padding-top: 0.25rem;\n &.fade {\n opacity: 0.5;\n font-size: 12px;\n letter-spacing: normal;\n }\n }\n ::slotted([slot='start']) {\n border-left: none;\n border-top: none;\n border-bottom: none;\n }\n\n ::slotted([slot='end']) {\n border-right: none;\n border-top: none;\n border-bottom: none;\n }\n }\n &.standard {\n font-family: var(--wje-textarea-font-family);\n position: relative;\n border-radius: var(--wje-textarea-border-radius);\n padding: 0;\n transition: background-color 0.2s ease;\n cursor: text;\n &.focused {\n .wrapper {\n border-color: var(--wje-textarea-border-color-focus) !important;\n }\n }\n textarea {\n background-color: var(--wje-textarea-background-color);\n display: block;\n min-height: 32px;\n box-shadow: none;\n width: 100%;\n box-sizing: border-box;\n border-radius: var(--wje-textarea-border-radius);\n }\n label {\n margin: 0;\n display: inline-block;\n opacity: 1;\n cursor: text;\n transition: opacity 0.2s ease;\n line-height: var(--wje-textarea-line-height);\n }\n ::slotted([slot='start']) {\n border-right: none;\n border-radius: var(--wje-textarea-border-radius) 0 0 var(--wje-textarea-border-radius);\n }\n\n ::slotted([slot='end']) {\n border-left: none;\n border-radius: 0 var(--wje-textarea-border-radius) var(--wje-textarea-border-radius) 0;\n }\n\n &.has-start textarea {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n }\n\n &.has-end textarea {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0;\n }\n .error-message {\n position: static;\n background: transparent;\n padding: 0.25rem 0;\n left: auto;\n transform: none;\n color: var(--wje-textarea-color-invalid);\n font-size: 12px;\n line-height: normal;\n }\n }\n}\n\n.counter {\n float: right;\n}\n\n@keyframes shake {\n 8%,\n 41% {\n transform: translateX(-4px);\n }\n 25%,\n 58% {\n transform: translateX(4px);\n }\n 75% {\n transform: translateX(-2px);\n }\n 92% {\n transform: translateX(2px);\n }\n 0%,\n 100% {\n transform: translateX(0);\n }\n}\n";
6
6
  class Textarea extends WJElement {
7
7
  /**
8
8
  * Creates an instance of Textarea.
9
- *
10
- * @constructor
9
+ * @class
11
10
  */
12
11
  constructor() {
13
12
  super();
13
+ __publicField(this, "observeFunction", (mutations) => {
14
+ mutations.forEach((mutation) => {
15
+ if (mutation.type === "attributes") {
16
+ const attributeName = mutation.attributeName;
17
+ const oldValue = mutation.oldValue;
18
+ const newValue = this.getAttribute(attributeName);
19
+ console.log(`Attribute ${attributeName} changed from ${oldValue} to ${newValue}`);
20
+ }
21
+ });
22
+ this.refresh();
23
+ });
14
24
  __publicField(this, "className", "Textarea");
15
25
  /**
16
26
  * Sets the height of the textarea.
@@ -23,22 +33,23 @@ class Textarea extends WJElement {
23
33
  });
24
34
  /**
25
35
  * Updates the counter for the textarea.
26
- *
27
- * @param {Event} e - The event object.
36
+ * @param {Event} e The event object.
28
37
  */
29
- __publicField(this, "counter", (e) => {
38
+ __publicField(this, "counterFn", (e) => {
30
39
  this.counterElement.innerText = e.target.value.length + "/" + this.input.maxLength;
31
40
  });
41
+ this.invalid = false;
42
+ this.pristine = true;
32
43
  this.internals = this.attachInternals();
44
+ this.observer = new MutationObserver(this.observeFunction);
33
45
  }
34
46
  /**
35
47
  * Setter for the value attribute.
36
- * @param {string} value - The value to set.
48
+ * @param {string} value The value to set.
37
49
  */
38
50
  set value(value) {
39
51
  this.internals.setFormValue(value);
40
- if (this.input)
41
- this.input.value = value;
52
+ if (this.input) this.input.value = value;
42
53
  this.pristine = false;
43
54
  this._value = value;
44
55
  }
@@ -59,13 +70,11 @@ class Textarea extends WJElement {
59
70
  }
60
71
  /**
61
72
  * Setter for the invalid attribute.
62
- * @param {boolean} isInvalid - Whether the input is invalid.
73
+ * @param {boolean} isInvalid Whether the input is invalid.
63
74
  */
64
75
  set invalid(isInvalid) {
65
- if (isInvalid)
66
- this.setAttribute("invalid", "");
67
- else
68
- this.removeAttribute("invalid");
76
+ if (isInvalid) this.setAttribute("invalid", "");
77
+ else this.removeAttribute("invalid");
69
78
  }
70
79
  /**
71
80
  * Getter for the form attribute.
@@ -111,16 +120,14 @@ class Textarea extends WJElement {
111
120
  }
112
121
  /**
113
122
  * Returns the CSS styles for the component.
114
- *
115
123
  * @static
116
- * @returns {CSSStyleSheet}
124
+ * @returns {CSSStyleSheet} The CSS stylesheet
117
125
  */
118
126
  static get cssStyleSheet() {
119
127
  return styles;
120
128
  }
121
129
  /**
122
130
  * Returns the list of attributes to observe for changes.
123
- *
124
131
  * @static
125
132
  * @returns {Array<string>}
126
133
  */
@@ -138,13 +145,16 @@ class Textarea extends WJElement {
138
145
  */
139
146
  setupAttributes() {
140
147
  this.isShadowRoot = "open";
148
+ if (this.pristine) {
149
+ this.value = this.innerHTML;
150
+ this.pristine = false;
151
+ }
152
+ }
153
+ beforeDraw() {
154
+ this.observer.disconnect();
141
155
  }
142
156
  /**
143
- * Draws the component.
144
- *
145
- * @param {Object} context - The context for drawing.
146
- * @param {Object} store - The store for drawing.
147
- * @param {Object} params - The parameters for drawing.
157
+ * Draws the component for the textarea.
148
158
  * @returns {DocumentFragment}
149
159
  */
150
160
  draw() {
@@ -152,9 +162,9 @@ class Textarea extends WJElement {
152
162
  let native = document.createElement("div");
153
163
  native.classList.add("native-textarea", this.variant || "default");
154
164
  native.setAttribute("part", "native");
155
- if (this.hasAttribute("invalid"))
156
- native.classList.add("has-error");
165
+ if (this.hasAttribute("invalid")) native.classList.add("has-error");
157
166
  let wrapper = document.createElement("div");
167
+ wrapper.setAttribute("part", "wrapper");
158
168
  wrapper.classList.add("wrapper");
159
169
  let inputWrapper = document.createElement("div");
160
170
  inputWrapper.classList.add("input-wrapper");
@@ -165,17 +175,21 @@ class Textarea extends WJElement {
165
175
  input.id = "textarea";
166
176
  input.name = this.name;
167
177
  input.disabled = this.hasAttribute("disabled");
168
- input.innerText = this.innerHTML;
178
+ input.innerText = this.value;
169
179
  input.placeholder = this.placeholder || "";
170
180
  input.classList.add("form-control");
171
181
  input.setAttribute("part", "input");
172
182
  input.setAttribute("rows", this.rows || 3);
173
183
  input.setAttribute("spellcheck", false);
174
- if (this.resize === "auto")
175
- input.addEventListener("input", this.setTextareaHeight);
184
+ const attributes = Array.from(this.attributes).map((attr) => attr.name);
185
+ attributes.forEach((attr) => {
186
+ if (this.hasAttribute(attr)) {
187
+ input.setAttribute(attr, this[attr] || "");
188
+ }
189
+ });
190
+ if (this.resize === "auto") input.addEventListener("input", this.setTextareaHeight);
176
191
  if (this.variant === "standard") {
177
- if (this.label)
178
- native.appendChild(label);
192
+ if (this.label) native.appendChild(label);
179
193
  } else {
180
194
  inputWrapper.appendChild(label);
181
195
  }
@@ -185,7 +199,7 @@ class Textarea extends WJElement {
185
199
  fragment.appendChild(native);
186
200
  if (this.hasAttribute("counter")) {
187
201
  input.maxLength = this.maxLength || 1e3;
188
- input.addEventListener("input", this.counter);
202
+ input.addEventListener("input", this.counterFn);
189
203
  let counter = document.createElement("div");
190
204
  counter.classList.add("counter");
191
205
  counter.innerText = `${input.value.length}/${input.maxLength}`;
@@ -199,9 +213,6 @@ class Textarea extends WJElement {
199
213
  }
200
214
  /**
201
215
  * Sets up the event listeners after the component is drawn.
202
- * @params {Object} context - The context for drawing.
203
- * @params {Object} store - The store for drawing.
204
- * @params {Object} params - The parameters for drawing.
205
216
  */
206
217
  afterDraw() {
207
218
  this.resizeObserver = new ResizeObserver(() => this.setTextareaHeight);
@@ -215,30 +226,102 @@ class Textarea extends WJElement {
215
226
  });
216
227
  this.input.addEventListener("blur", (e) => {
217
228
  this.native.classList.remove("focused");
218
- if (!e.target.value)
219
- this.labelElement.classList.remove("fade");
229
+ if (!e.target.value) this.labelElement.classList.remove("fade");
230
+ });
231
+ this.addEventListener("invalid", (e) => {
232
+ this.invalid = true;
233
+ this.pristine = false;
234
+ this.showInvalidMessage();
235
+ if (this.customErrorDisplay) {
236
+ e.preventDefault();
237
+ }
238
+ });
239
+ this.input.addEventListener("input", (e) => {
240
+ this.validateInput();
241
+ if (this.validateOnChange) {
242
+ this.pristine = false;
243
+ this.propagateValidation();
244
+ }
245
+ this.input.classList.remove("pristine");
246
+ this.labelElement.classList.add("fade");
247
+ const clone = new e.constructor(e.type, e);
248
+ this.dispatchEvent(clone);
249
+ event.dispatchCustomEvent(this, "wje-textarea:input", {
250
+ value: this.input.value
251
+ });
252
+ this.value = this.input.value;
253
+ });
254
+ this.validateInput();
255
+ this.observer.observe(this, {
256
+ attributes: true,
257
+ // Watch for attribute changes
258
+ attributeOldValue: true
259
+ // Keep track of the old value of attributes
220
260
  });
221
261
  }
262
+ componentCleanup() {
263
+ this.observer.disconnect();
264
+ }
222
265
  /**
223
266
  * Disconnects the component.
224
267
  */
225
268
  beforeDisconnect() {
226
269
  this.resizeObserver.unobserve(this.input);
227
270
  }
271
+ /**
272
+ * @summary Validates the input.
273
+ * This method checks the validity state of the input. If the input is not valid, it iterates over the validity state object.
274
+ * For each invalid state, it constructs an attribute name and checks if the input has this attribute.
275
+ * If the input has the attribute, it sets the validation error to the state and the error message to the attribute value.
276
+ * If the input does not have the attribute, it sets the error message to the default validation message of the input.
277
+ * It then sets the validity in the form internals to an object with the validation error as key and true as value, and the error message.
278
+ * If the input is valid, it sets the validity in the form internals to an empty object.
279
+ */
280
+ validateInput() {
281
+ const validState = this.input.validity;
282
+ if (!validState.valid) {
283
+ for (let state in validState) {
284
+ const attr = `message-${state.toString()}`;
285
+ if (validState[state]) {
286
+ this.validationError = state.toString();
287
+ let errorMessage = this.message;
288
+ if (!this.hasAttribute("message"))
289
+ errorMessage = this.hasAttribute(attr) ? this.getAttribute(attr) : this.input.validationMessage;
290
+ this.internals.setValidity({ [this.validationError]: true }, errorMessage);
291
+ }
292
+ }
293
+ } else {
294
+ this.internals.setValidity({});
295
+ }
296
+ }
297
+ /**
298
+ * @summary Propagates the validation state of the input.
299
+ * This method sets the 'invalid' property of the input based on its 'pristine' state and its internal validity state.
300
+ * If the input is invalid and the 'customErrorDisplay' property is true, it dispatches an 'invalid' event.
301
+ */
302
+ propagateValidation() {
303
+ this.invalid = !this.pristine && !this.internals.validity.valid;
304
+ if (this.invalid && this.customErrorDisplay) {
305
+ this.dispatchEvent(new Event("invalid"));
306
+ }
307
+ }
228
308
  /**
229
309
  * @summary Callback function that is called when the custom element is associated with a form.
230
310
  * 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.
311
+ * @param {HTMLFormElement} form The form the custom element is associated with.
232
312
  */
233
313
  formAssociatedCallback(form) {
234
314
  this.internals.setFormValue(this.value);
315
+ form == null ? void 0 : form.addEventListener("submit", () => {
316
+ this.validateInput();
317
+ this.propagateValidation();
318
+ });
235
319
  }
236
320
  /**
237
321
  * The formResetCallback method is a built-in lifecycle callback that gets called when a form gets reset.
238
322
  * This method is responsible for resetting the value of the custom input element to its default value.
239
323
  * It also resets the form value and validity state in the form internals.
240
- *
241
- * @method
324
+ * @function
242
325
  */
243
326
  formResetCallback() {
244
327
  this.value = this.defaultValue;
@@ -249,9 +332,8 @@ class Textarea extends WJElement {
249
332
  * The formStateRestoreCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is restored.
250
333
  * This method is responsible for restoring the value of the custom input element to its saved state.
251
334
  * It also restores the form value and validity state in the form internals to their saved states.
252
- *
253
- * @param {Object} state - The saved state of the custom input element.
254
- * @method
335
+ * @param {object} state The saved state of the custom input element.
336
+ * @function
255
337
  */
256
338
  formStateRestoreCallback(state) {
257
339
  this.value = state.value;
@@ -261,9 +343,8 @@ class Textarea extends WJElement {
261
343
  /**
262
344
  * The formStateSaveCallback method is a built-in lifecycle callback that gets called when the state of a form-associated custom element is saved.
263
345
  * This method is responsible for saving the value of the custom input element.
264
- *
265
- * @returns {Object} The saved state of the custom input element.
266
- * @method
346
+ * @returns {object} The saved state of the custom input element.
347
+ * @function
267
348
  */
268
349
  formStateSaveCallback() {
269
350
  return {
@@ -273,9 +354,8 @@ class Textarea extends WJElement {
273
354
  /**
274
355
  * The formDisabledCallback method is a built-in lifecycle callback that gets called when the disabled state of a form-associated custom element changes.
275
356
  * This method is not implemented yet.
276
- *
277
- * @param {boolean} disabled - The new disabled state of the custom input element.
278
- * @method
357
+ * @param {boolean} disabled The new disabled state of the custom input element.
358
+ * @function
279
359
  */
280
360
  formDisabledCallback(disabled) {
281
361
  console.warn("formDisabledCallback not implemented yet");
@@ -2,30 +2,28 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __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
- const styles = "/*\n[ WJ Thumbnail ]\n*/\n\n:host {\n width: var(--wje-thumbnail-width);\n height: var(--wje-thumbnail-height);\n display: block;\n border-radius: var(--wje-border-radius);\n}\n\n:host([circle]) ::slotted(img) {\n border-radius: 50%;\n}\n::slotted(wje-img),\n::slotted(img) {\n border-radius: var(--wje-thumbnail-border-radius);\n width: 100%;\n height: 100%;\n object-fit: cover;\n overflow: hidden;\n}";
5
+ const styles = "/*\n[ WJ Thumbnail ]\n*/\n\n:host {\n width: var(--wje-thumbnail-width);\n height: var(--wje-thumbnail-height);\n display: block;\n border-radius: var(--wje-border-radius);\n}\n\n:host([circle]) ::slotted(img) {\n border-radius: 50%;\n}\n::slotted(wje-img),\n::slotted(img) {\n border-radius: var(--wje-thumbnail-border-radius);\n width: 100%;\n height: 100%;\n object-fit: cover;\n overflow: hidden;\n}\n";
6
6
  class Thumbnail extends WJElement {
7
7
  /**
8
- * Thumbnail constructor
9
- * @constructor
8
+ * Creates an instance of Thumbnail.
10
9
  */
11
10
  constructor() {
12
11
  super();
13
12
  /**
14
- * Class name
15
- * @type {string}
13
+ * The class name for the component
16
14
  */
17
15
  __publicField(this, "className", "Thumbnail");
18
16
  }
19
17
  /**
20
- * Get CSS stylesheet
18
+ * Returns the CSS stylesheet for the component.
21
19
  * @static
22
- * @returns {Object} styles
20
+ * @returns {CSSStyleSheet} The CSS stylesheet
23
21
  */
24
22
  static get cssStyleSheet() {
25
23
  return styles;
26
24
  }
27
25
  /**
28
- * Get observed attributes
26
+ * Returns the list of observed attributes.
29
27
  * @static
30
28
  * @returns {Array} An empty array
31
29
  */
@@ -33,17 +31,14 @@ class Thumbnail extends WJElement {
33
31
  return [];
34
32
  }
35
33
  /**
36
- * Setup attributes
34
+ * Sets up the attributes for the component.
37
35
  */
38
36
  setupAttributes() {
39
37
  this.isShadowRoot = "open";
40
38
  }
41
39
  /**
42
- * Draw method
43
- * @param {Object} context - The context
44
- * @param {Object} store - The store
45
- * @param {Object} params - The parameters
46
- * @returns {Object} Document fragment
40
+ * Draws the component for the thumbnail.
41
+ * @returns {object} Document fragment
47
42
  */
48
43
  draw() {
49
44
  let fragment = document.createDocumentFragment();