wj-elements 0.7.7 → 0.8.0

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 (233) hide show
  1. package/dist/animations.js +28 -51
  2. package/dist/animations.js.map +1 -1
  3. package/dist/base-path.js +19 -31
  4. package/dist/base-path.js.map +1 -1
  5. package/dist/custom-elements.json +11504 -11499
  6. package/dist/dark.css +1 -302
  7. package/dist/date.js +16 -36
  8. package/dist/date.js.map +1 -1
  9. package/dist/element-utils.js +20 -81
  10. package/dist/element-utils.js.map +1 -1
  11. package/dist/event.js +49 -165
  12. package/dist/event.js.map +1 -1
  13. package/dist/form-associated-element-BjeJn7j8.js +101 -0
  14. package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
  15. package/dist/icon-DmsqtDpL.js +102 -0
  16. package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
  17. package/dist/light.css +1 -731
  18. package/dist/localize.js +36 -111
  19. package/dist/localize.js.map +1 -1
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
  21. package/dist/permissions.js +14 -41
  22. package/dist/permissions.js.map +1 -1
  23. package/dist/popup.element-CbkhthPP.js +806 -0
  24. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  25. package/dist/router-links-CNsJ-elb.js +105 -0
  26. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  27. package/dist/skeleton.css +1 -197
  28. package/dist/styles.css +1 -866
  29. package/dist/universal-service.js +48 -109
  30. package/dist/universal-service.js.map +1 -1
  31. package/dist/utils.js +11 -18
  32. package/dist/utils.js.map +1 -1
  33. package/dist/web-types.json +760 -760
  34. package/dist/wje-accordion-item.js +33 -106
  35. package/dist/wje-accordion-item.js.map +1 -1
  36. package/dist/wje-accordion.js +19 -84
  37. package/dist/wje-accordion.js.map +1 -1
  38. package/dist/wje-animation.js +37 -4258
  39. package/dist/wje-animation.js.map +1 -1
  40. package/dist/wje-aside.js +9 -34
  41. package/dist/wje-aside.js.map +1 -1
  42. package/dist/wje-avatar.js +36 -126
  43. package/dist/wje-avatar.js.map +1 -1
  44. package/dist/wje-badge.js +10 -52
  45. package/dist/wje-badge.js.map +1 -1
  46. package/dist/wje-breadcrumb.js +205 -672
  47. package/dist/wje-breadcrumb.js.map +1 -1
  48. package/dist/wje-breadcrumbs.js +177 -633
  49. package/dist/wje-breadcrumbs.js.map +1 -1
  50. package/dist/wje-button-group.js +48 -153
  51. package/dist/wje-button-group.js.map +1 -1
  52. package/dist/wje-button.js +92 -413
  53. package/dist/wje-button.js.map +1 -1
  54. package/dist/wje-card-content.js +7 -30
  55. package/dist/wje-card-content.js.map +1 -1
  56. package/dist/wje-card-controls.js +7 -30
  57. package/dist/wje-card-controls.js.map +1 -1
  58. package/dist/wje-card-header.js +7 -30
  59. package/dist/wje-card-header.js.map +1 -1
  60. package/dist/wje-card-subtitle.js +7 -34
  61. package/dist/wje-card-subtitle.js.map +1 -1
  62. package/dist/wje-card-title.js +7 -34
  63. package/dist/wje-card-title.js.map +1 -1
  64. package/dist/wje-card.js +15 -71
  65. package/dist/wje-card.js.map +1 -1
  66. package/dist/wje-carousel-item.js +12 -56
  67. package/dist/wje-carousel-item.js.map +1 -1
  68. package/dist/wje-carousel.js +154 -509
  69. package/dist/wje-carousel.js.map +1 -1
  70. package/dist/wje-checkbox.js +50 -227
  71. package/dist/wje-checkbox.js.map +1 -1
  72. package/dist/wje-chip.js +43 -160
  73. package/dist/wje-chip.js.map +1 -1
  74. package/dist/wje-col.js +7 -20
  75. package/dist/wje-col.js.map +1 -1
  76. package/dist/wje-color-picker.js +445 -1464
  77. package/dist/wje-color-picker.js.map +1 -1
  78. package/dist/wje-container.js +9 -35
  79. package/dist/wje-container.js.map +1 -1
  80. package/dist/wje-copy-button.js +64 -204
  81. package/dist/wje-copy-button.js.map +1 -1
  82. package/dist/wje-dialog.js +85 -553
  83. package/dist/wje-dialog.js.map +1 -1
  84. package/dist/wje-divider.js +7 -34
  85. package/dist/wje-divider.js.map +1 -1
  86. package/dist/wje-dropdown.js +78 -305
  87. package/dist/wje-dropdown.js.map +1 -1
  88. package/dist/wje-element.js +191 -700
  89. package/dist/wje-element.js.map +1 -1
  90. package/dist/wje-file-upload-item.js +51 -156
  91. package/dist/wje-file-upload-item.js.map +1 -1
  92. package/dist/wje-file-upload.js +181 -619
  93. package/dist/wje-file-upload.js.map +1 -1
  94. package/dist/wje-footer.js +7 -31
  95. package/dist/wje-footer.js.map +1 -1
  96. package/dist/wje-form.js +7 -32
  97. package/dist/wje-form.js.map +1 -1
  98. package/dist/wje-format-digital.js +26 -118
  99. package/dist/wje-format-digital.js.map +1 -1
  100. package/dist/wje-grid.js +7 -33
  101. package/dist/wje-grid.js.map +1 -1
  102. package/dist/wje-header.js +9 -35
  103. package/dist/wje-header.js.map +1 -1
  104. package/dist/wje-icon-library.js +12 -18
  105. package/dist/wje-icon-library.js.map +1 -1
  106. package/dist/wje-icon-picker.js +65 -320
  107. package/dist/wje-icon-picker.js.map +1 -1
  108. package/dist/wje-icon.js +1 -1
  109. package/dist/wje-img-comparer.js +37 -114
  110. package/dist/wje-img-comparer.js.map +1 -1
  111. package/dist/wje-img.js +50 -198
  112. package/dist/wje-img.js.map +1 -1
  113. package/dist/wje-infinite-scroll.js +94 -346
  114. package/dist/wje-infinite-scroll.js.map +1 -1
  115. package/dist/wje-input-file.js +23 -84
  116. package/dist/wje-input-file.js.map +1 -1
  117. package/dist/wje-input.js +78 -392
  118. package/dist/wje-input.js.map +1 -1
  119. package/dist/wje-item.js +11 -64
  120. package/dist/wje-item.js.map +1 -1
  121. package/dist/wje-kanban.js +124 -401
  122. package/dist/wje-kanban.js.map +1 -1
  123. package/dist/wje-label.js +9 -32
  124. package/dist/wje-label.js.map +1 -1
  125. package/dist/wje-level-indicator.js +38 -157
  126. package/dist/wje-level-indicator.js.map +1 -1
  127. package/dist/wje-list.js +10 -40
  128. package/dist/wje-list.js.map +1 -1
  129. package/dist/wje-main.js +7 -31
  130. package/dist/wje-main.js.map +1 -1
  131. package/dist/wje-masonry.js +66 -211
  132. package/dist/wje-masonry.js.map +1 -1
  133. package/dist/wje-master.js +45 -161
  134. package/dist/wje-master.js.map +1 -1
  135. package/dist/wje-menu-button.js +10 -38
  136. package/dist/wje-menu-button.js.map +1 -1
  137. package/dist/wje-menu-item.js +127 -577
  138. package/dist/wje-menu-item.js.map +1 -1
  139. package/dist/wje-menu-label.js +9 -35
  140. package/dist/wje-menu-label.js.map +1 -1
  141. package/dist/wje-menu.js +14 -49
  142. package/dist/wje-menu.js.map +1 -1
  143. package/dist/wje-option.js +48 -279
  144. package/dist/wje-option.js.map +1 -1
  145. package/dist/wje-options.js +130 -384
  146. package/dist/wje-options.js.map +1 -1
  147. package/dist/wje-orgchart-group.js +16 -52
  148. package/dist/wje-orgchart-group.js.map +1 -1
  149. package/dist/wje-orgchart-item.js +24 -93
  150. package/dist/wje-orgchart-item.js.map +1 -1
  151. package/dist/wje-orgchart.js +18 -68
  152. package/dist/wje-orgchart.js.map +1 -1
  153. package/dist/wje-pagination.js +113 -397
  154. package/dist/wje-pagination.js.map +1 -1
  155. package/dist/wje-popup.js +3 -3
  156. package/dist/wje-popup.js.map +1 -1
  157. package/dist/wje-progress-bar.js +53 -205
  158. package/dist/wje-progress-bar.js.map +1 -1
  159. package/dist/wje-qr-code.js +398 -2980
  160. package/dist/wje-qr-code.js.map +1 -1
  161. package/dist/wje-radio-group.js +52 -190
  162. package/dist/wje-radio-group.js.map +1 -1
  163. package/dist/wje-radio.js +24 -118
  164. package/dist/wje-radio.js.map +1 -1
  165. package/dist/wje-rate.js +62 -266
  166. package/dist/wje-rate.js.map +1 -1
  167. package/dist/wje-relative-time.js +24 -99
  168. package/dist/wje-relative-time.js.map +1 -1
  169. package/dist/wje-reorder-dropzone.js +9 -31
  170. package/dist/wje-reorder-dropzone.js.map +1 -1
  171. package/dist/wje-reorder-handle.js +67 -204
  172. package/dist/wje-reorder-handle.js.map +1 -1
  173. package/dist/wje-reorder-item.js +14 -44
  174. package/dist/wje-reorder-item.js.map +1 -1
  175. package/dist/wje-reorder.js +61 -246
  176. package/dist/wje-reorder.js.map +1 -1
  177. package/dist/wje-route.js +6 -24
  178. package/dist/wje-route.js.map +1 -1
  179. package/dist/wje-router-link.js +11 -39
  180. package/dist/wje-router-link.js.map +1 -1
  181. package/dist/wje-router-outlet.js +76 -172
  182. package/dist/wje-router-outlet.js.map +1 -1
  183. package/dist/wje-routerx.js +537 -1331
  184. package/dist/wje-routerx.js.map +1 -1
  185. package/dist/wje-row.js +9 -31
  186. package/dist/wje-row.js.map +1 -1
  187. package/dist/wje-select.js +326 -1152
  188. package/dist/wje-select.js.map +1 -1
  189. package/dist/wje-slider.js +44 -225
  190. package/dist/wje-slider.js.map +1 -1
  191. package/dist/wje-sliding-container.js +295 -1319
  192. package/dist/wje-sliding-container.js.map +1 -1
  193. package/dist/wje-split-view.js +35 -121
  194. package/dist/wje-split-view.js.map +1 -1
  195. package/dist/wje-status.js +14 -45
  196. package/dist/wje-status.js.map +1 -1
  197. package/dist/wje-step.js +9 -32
  198. package/dist/wje-step.js.map +1 -1
  199. package/dist/wje-stepper.js +109 -357
  200. package/dist/wje-stepper.js.map +1 -1
  201. package/dist/wje-store.js +67 -360
  202. package/dist/wje-store.js.map +1 -1
  203. package/dist/wje-tab-group.js +85 -314
  204. package/dist/wje-tab-group.js.map +1 -1
  205. package/dist/wje-tab-panel.js +7 -28
  206. package/dist/wje-tab-panel.js.map +1 -1
  207. package/dist/wje-tab.js +21 -198
  208. package/dist/wje-tab.js.map +1 -1
  209. package/dist/wje-textarea.js +64 -264
  210. package/dist/wje-textarea.js.map +1 -1
  211. package/dist/wje-thumbnail.js +10 -51
  212. package/dist/wje-thumbnail.js.map +1 -1
  213. package/dist/wje-toast.js +127 -632
  214. package/dist/wje-toast.js.map +1 -1
  215. package/dist/wje-toggle.js +52 -177
  216. package/dist/wje-toggle.js.map +1 -1
  217. package/dist/wje-toolbar-action.js +128 -456
  218. package/dist/wje-toolbar-action.js.map +1 -1
  219. package/dist/wje-toolbar.js +75 -270
  220. package/dist/wje-toolbar.js.map +1 -1
  221. package/dist/wje-tooltip.js +50 -161
  222. package/dist/wje-tooltip.js.map +1 -1
  223. package/dist/wje-tree-item.js +70 -301
  224. package/dist/wje-tree-item.js.map +1 -1
  225. package/dist/wje-tree.js +145 -489
  226. package/dist/wje-tree.js.map +1 -1
  227. package/dist/wje-visually-hidden.js +7 -34
  228. package/dist/wje-visually-hidden.js.map +1 -1
  229. package/package.json +3 -2
  230. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  231. package/dist/icon-CReYMzAK.js +0 -245
  232. package/dist/popup.element-CwXvVFK7.js +0 -2133
  233. package/dist/router-links-wjqCnncc.js +0 -156
@@ -1,135 +1,58 @@
1
1
  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
- import WJElement from "./wje-element.js";
5
- import { I as Icon } from "./icon-CReYMzAK.js";
6
- function drag(container, options) {
7
- function move(pointerEvent) {
8
- const dims = container.getBoundingClientRect();
9
- const defaultView = container.ownerDocument.defaultView;
10
- const offsetX = dims.left + defaultView.pageXOffset;
11
- const offsetY = dims.top + defaultView.pageYOffset;
12
- const x = pointerEvent.pageX - offsetX;
13
- const y = pointerEvent.pageY - offsetY;
14
- if (options == null ? void 0 : options.onMove) {
15
- options.onMove(x, y);
16
- }
17
- }
18
- function stop() {
19
- document.removeEventListener("pointermove", move);
20
- document.removeEventListener("pointerup", stop);
21
- if (options == null ? void 0 : options.onStop) {
22
- options.onStop();
23
- }
24
- }
25
- document.addEventListener("pointermove", move, { passive: true });
26
- document.addEventListener("pointerup", stop);
27
- if ((options == null ? void 0 : options.initialEvent) instanceof PointerEvent) {
28
- move(options.initialEvent);
29
- }
30
- }
31
- const styles = "/*\n[ WJ Image Compare ]\n*/\n\n:host {\n display: inline-block;\n position: relative;\n width: 100%;\n border-color: var(--wje-border-color);\n border-style: solid;\n border-width: 1px;\n}\n\n.wje-before,\n.wje-after {\n display: block;\n}\n\n.wje-after {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n clip-path: var(--wje-img-compare-clip-path);\n}\n\n.native-split-view {\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n}\n\n.wje-divider {\n display: flex;\n position: absolute;\n align-items: center;\n justify-content: center;\n z-index: 1;\n background-color: var(--wje-img-compare-divider-background);\n height: 100%;\n width: var(--wje-img-compare-divider-size);\n cursor: col-resize;\n top: 0;\n left: var(--wje-img-compare-divider-left);\n &:after {\n display: flex;\n content: '';\n position: absolute;\n height: 100%;\n left: calc(var(--wje-img-compare-divider-area) / -2 + var(--wje-img-compare-divider-size) / 2);\n width: var(---wje-img-compare-divider-area);\n }\n wje-icon {\n position: absolute;\n background-color: white;\n padding: 0.5rem;\n color: var(--wje-color-dark);\n border-radius: var(--wje-border-radius-circle);\n box-shadow: rgba(82, 63, 105, 0.2) 0 0 30px 10px;\n background: var(--wje-color-white) !important;\n }\n}\n";
32
- class ImgComparer extends WJElement {
33
- /**
34
- * Creates an instance of ImgComparer.
35
- * @class
36
- */
4
+ import e from "./wje-element.js";
5
+ import { I as t } from "./icon-DmsqtDpL.js";
6
+ class i extends e {
37
7
  constructor() {
38
8
  super();
39
- /**
40
- * Dependencies of the ImgComparer component.
41
- * @property {object} dependencies
42
- */
43
- __publicField(this, "dependencies", {
44
- "wje-icon": Icon
45
- });
9
+ __publicField(this, "dependencies", { "wje-icon": t });
46
10
  __publicField(this, "className", "ImgComparer");
47
- /**
48
- * Handles the drag event.
49
- * @param {Event} e The event.
50
- */
51
- __publicField(this, "handleDrag", (e) => {
52
- const { width } = this.native.getBoundingClientRect();
53
- drag(this, {
54
- onMove: (x) => {
55
- let value = x / width * 100;
56
- this.position = parseFloat(this.clamp(value, 0, 100).toFixed(2));
57
- this.native.style.setProperty("--wje-img-compare-divider-left", this.position + "%");
58
- this.native.style.setProperty("--wje-img-compare-clip-path", `inset(0 ${100 - this.position}% 0 0)`);
59
- },
60
- initialEvent: e
61
- });
11
+ __publicField(this, "handleDrag", (e2) => {
12
+ const { width: t2 } = this.native.getBoundingClientRect();
13
+ !(function(e3, t3) {
14
+ function i2(i3) {
15
+ const o = e3.getBoundingClientRect(), r = e3.ownerDocument.defaultView, a = o.left + r.pageXOffset, n = o.top + r.pageYOffset, d = i3.pageX - a, s = i3.pageY - n;
16
+ (t3 == null ? void 0 : t3.onMove) && t3.onMove(d, s);
17
+ }
18
+ document.addEventListener("pointermove", i2, { passive: true }), document.addEventListener("pointerup", function e4() {
19
+ document.removeEventListener("pointermove", i2), document.removeEventListener("pointerup", e4), (t3 == null ? void 0 : t3.onStop) && t3.onStop();
20
+ }), (t3 == null ? void 0 : t3.initialEvent) instanceof PointerEvent && i2(t3.initialEvent);
21
+ })(this, { onMove: (e3) => {
22
+ let i2 = e3 / t2 * 100;
23
+ this.position = parseFloat(this.clamp(i2, 0, 100).toFixed(2)), this.native.style.setProperty("--wje-img-compare-divider-left", this.position + "%"), this.native.style.setProperty("--wje-img-compare-clip-path", `inset(0 ${100 - this.position}% 0 0)`);
24
+ }, initialEvent: e2 });
62
25
  });
63
- /**
64
- * Clamps a number between a minimum and maximum value.
65
- * @param {number} num The number to clamp.
66
- * @param {number} min The minimum value.
67
- * @param {number} max The maximum value.
68
- * @returns {number} The clamped number.
69
- */
70
- __publicField(this, "clamp", (num, min, max) => Math.min(Math.max(num, min), max));
26
+ __publicField(this, "clamp", (e2, t2, i2) => Math.min(Math.max(e2, t2), i2));
71
27
  }
72
- /**
73
- * Returns the CSS styles for the component.
74
- * @static
75
- * @returns {CSSStyleSheet}
76
- */
77
28
  static get cssStyleSheet() {
78
- return styles;
29
+ return ':host{display:inline-block;position:relative;width:100%;border-color:var(--wje-border-color);border-style:solid;border-width:1px}.wje-before,.wje-after{display:block}.wje-after{position:absolute;top:0;left:0;height:100%;width:100%;clip-path:var(--wje-img-compare-clip-path)}.native-split-view{max-width:100%;max-height:100%;overflow:hidden}.wje-divider{display:flex;position:absolute;align-items:center;justify-content:center;z-index:1;background-color:var(--wje-img-compare-divider-background);height:100%;width:var(--wje-img-compare-divider-size);cursor:col-resize;top:0;left:var(--wje-img-compare-divider-left)}.wje-divider:after{display:flex;content:"";position:absolute;height:100%;left:calc(var(--wje-img-compare-divider-area) / -2 + var(--wje-img-compare-divider-size) / 2);width:var(---wje-img-compare-divider-area)}.wje-divider wje-icon{position:absolute;background-color:#fff;padding:.5rem;color:var(--wje-color-dark);border-radius:var(--wje-border-radius-circle);box-shadow:#523f6933 0 0 30px 10px;background:var(--wje-color-white)!important}';
79
30
  }
80
- /**
81
- * Returns the list of attributes to observe for changes.
82
- * @static
83
- * @returns {Array<string>}
84
- */
85
31
  static get observedAttributes() {
86
32
  return [];
87
33
  }
88
- /**
89
- * Sets up the attributes for the component.
90
- */
91
34
  setupAttributes() {
92
- this.isShadowRoot = "open";
93
- this.setAriaState({ role: "group" });
35
+ this.isShadowRoot = "open", this.setAriaState({ role: "group" });
94
36
  }
95
- /**
96
- * Draws the component.
97
- * @returns {DocumentFragment}
98
- */
99
37
  draw() {
100
- let fragment = document.createDocumentFragment();
101
- let native = document.createElement("div");
102
- native.classList.add("native-split-view");
103
- let beforeElement = document.createElement("div");
104
- beforeElement.classList.add("wje-before");
105
- let before = document.createElement("slot");
106
- before.setAttribute("name", "before");
107
- let afterElement = document.createElement("div");
108
- afterElement.classList.add("wje-after");
109
- let after = document.createElement("slot");
110
- after.setAttribute("name", "after");
111
- let icon = document.createElement("wje-icon");
112
- icon.setAttribute("name", "arrow-bar-both");
113
- let dividerElement = document.createElement("div");
114
- dividerElement.classList.add("wje-divider");
115
- dividerElement.setAttribute("part", "divider");
116
- dividerElement.setAttribute("role", "separator");
117
- dividerElement.setAttribute("tabindex", "0");
118
- dividerElement.setAttribute("aria-orientation", "horizontal");
119
- dividerElement.addEventListener("mousedown", this.handleDrag, false);
120
- beforeElement.appendChild(before);
121
- afterElement.appendChild(after);
122
- dividerElement.appendChild(icon);
123
- native.appendChild(beforeElement);
124
- native.appendChild(afterElement);
125
- native.appendChild(dividerElement);
126
- fragment.appendChild(native);
127
- this.native = native;
128
- return fragment;
38
+ let e2 = document.createDocumentFragment(), t2 = document.createElement("div");
39
+ t2.classList.add("native-split-view");
40
+ let i2 = document.createElement("div");
41
+ i2.classList.add("wje-before");
42
+ let o = document.createElement("slot");
43
+ o.setAttribute("name", "before");
44
+ let r = document.createElement("div");
45
+ r.classList.add("wje-after");
46
+ let a = document.createElement("slot");
47
+ a.setAttribute("name", "after");
48
+ let n = document.createElement("wje-icon");
49
+ n.setAttribute("name", "arrow-bar-both");
50
+ let d = document.createElement("div");
51
+ return d.classList.add("wje-divider"), d.setAttribute("part", "divider"), d.setAttribute("role", "separator"), d.setAttribute("tabindex", "0"), d.setAttribute("aria-orientation", "horizontal"), d.addEventListener("mousedown", this.handleDrag, false), i2.appendChild(o), r.appendChild(a), d.appendChild(n), t2.appendChild(i2), t2.appendChild(r), t2.appendChild(d), e2.appendChild(t2), this.native = t2, e2;
129
52
  }
130
53
  }
131
- ImgComparer.define("wje-img-comparer", ImgComparer);
54
+ i.define("wje-img-comparer", i);
132
55
  export {
133
- ImgComparer as default
56
+ i as default
134
57
  };
135
58
  //# sourceMappingURL=wje-img-comparer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-img-comparer.js","sources":["../packages/wje-img-comparer/service/service.js","../packages/wje-img-comparer/img-comparer.element.js","../packages/wje-img-comparer/img-comparer.js"],"sourcesContent":["export function drag(container, options) {\n function move(pointerEvent) {\n const dims = container.getBoundingClientRect();\n const defaultView = container.ownerDocument.defaultView;\n const offsetX = dims.left + defaultView.pageXOffset;\n const offsetY = dims.top + defaultView.pageYOffset;\n const x = pointerEvent.pageX - offsetX;\n const y = pointerEvent.pageY - offsetY;\n\n if (options?.onMove) {\n options.onMove(x, y);\n }\n }\n\n function stop() {\n document.removeEventListener('pointermove', move);\n document.removeEventListener('pointerup', stop);\n\n if (options?.onStop) {\n options.onStop();\n }\n }\n\n document.addEventListener('pointermove', move, { passive: true });\n document.addEventListener('pointerup', stop);\n\n if (options?.initialEvent instanceof PointerEvent) {\n move(options.initialEvent);\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport { drag } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to compare two images. `ImgComparer` is a custom web component that represents an image comparer.\n * It extends from `WJElement` and uses the `Icon` component.\n * @documentation https://elements.webjet.sk/components/img-comparer\n * @status stable\n * @augments {WJElement}\n * @slot before - The before image slot.\n * @slot after - The after image slot.\n * @csspart divider - The divider part.\n * @cssproperty [--wje-img-compare-divider-area=12px] - The area of the divider. This is the size of the divider. Accepts any valid CSS size.\n * @cssproperty [--wje-img-compare-divider-background=white] - Sets the background color of the divider in the image comparison component. Accepts any valid CSS color value (e.g., `red`, `#ff0000`, `rgba(255, 255, 255, 0.5)`). The default value is `white`, which ensures high contrast in most designs.\n * @cssproperty [--wje-img-compare-divider-size=2px] - The size of the divider. This is the thickness of the divider. Accepts any valid CSS size.\n * @cssproperty [--wje-img-compare-divider-left=50%] - The left position of the divider. This is the initial position of the divider.\n * @cssproperty [--wje-img-compare-position=50%] - The position of the divider. This is the position of the divider.\n * @cssproperty [--wje-img-compare-clip-path=inset(0 calc(100% - var(--wje-img-compare-position)) 0 0)] - The clip path of the divider. This is the clip path of the divider.\n * @tag wje-img-comparer\n */\nexport default class ImgComparer extends WJElement {\n /**\n * Creates an instance of ImgComparer.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Dependencies of the ImgComparer component.\n * @property {object} dependencies\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n className = 'ImgComparer';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'group' });\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-split-view');\n\n let beforeElement = document.createElement('div');\n beforeElement.classList.add('wje-before');\n\n let before = document.createElement('slot');\n before.setAttribute('name', 'before');\n\n let afterElement = document.createElement('div');\n afterElement.classList.add('wje-after');\n\n let after = document.createElement('slot');\n after.setAttribute('name', 'after');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'arrow-bar-both');\n\n let dividerElement = document.createElement('div');\n dividerElement.classList.add('wje-divider');\n dividerElement.setAttribute('part', 'divider');\n dividerElement.setAttribute('role', 'separator');\n dividerElement.setAttribute('tabindex', '0');\n dividerElement.setAttribute('aria-orientation', 'horizontal');\n dividerElement.addEventListener('mousedown', this.handleDrag, false);\n\n beforeElement.appendChild(before);\n afterElement.appendChild(after);\n dividerElement.appendChild(icon);\n\n native.appendChild(beforeElement);\n native.appendChild(afterElement);\n native.appendChild(dividerElement);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Handles the drag event.\n * @param {Event} e The event.\n */\n handleDrag = (e) => {\n const { width } = this.native.getBoundingClientRect();\n\n drag(this, {\n onMove: (x) => {\n let value = (x / width) * 100;\n this.position = parseFloat(this.clamp(value, 0, 100).toFixed(2));\n this.native.style.setProperty('--wje-img-compare-divider-left', this.position + '%');\n this.native.style.setProperty('--wje-img-compare-clip-path', `inset(0 ${100 - this.position}% 0 0)`);\n },\n initialEvent: e,\n });\n };\n\n /**\n * Clamps a number between a minimum and maximum value.\n * @param {number} num The number to clamp.\n * @param {number} min The minimum value.\n * @param {number} max The maximum value.\n * @returns {number} The clamped number.\n */\n clamp = (num, min, max) => Math.min(Math.max(num, min), max);\n}\n","import ImgComparer from './img-comparer.element.js';\n\nexport default ImgComparer;\n\nImgComparer.define('wje-img-comparer', ImgComparer);\n"],"names":[],"mappings":";;;;;AAAO,SAAS,KAAK,WAAW,SAAS;AACrC,WAAS,KAAK,cAAc;AACxB,UAAM,OAAO,UAAU,sBAAqB;AAC5C,UAAM,cAAc,UAAU,cAAc;AAC5C,UAAM,UAAU,KAAK,OAAO,YAAY;AACxC,UAAM,UAAU,KAAK,MAAM,YAAY;AACvC,UAAM,IAAI,aAAa,QAAQ;AAC/B,UAAM,IAAI,aAAa,QAAQ;AAE/B,QAAI,mCAAS,QAAQ;AACjB,cAAQ,OAAO,GAAG,CAAC;AAAA,IACvB;AAAA,EACJ;AAEA,WAAS,OAAO;AACZ,aAAS,oBAAoB,eAAe,IAAI;AAChD,aAAS,oBAAoB,aAAa,IAAI;AAE9C,QAAI,mCAAS,QAAQ;AACjB,cAAQ,OAAM;AAAA,IAClB;AAAA,EACJ;AAEA,WAAS,iBAAiB,eAAe,MAAM,EAAE,SAAS,MAAM;AAChE,WAAS,iBAAiB,aAAa,IAAI;AAE3C,OAAI,mCAAS,yBAAwB,cAAc;AAC/C,SAAK,QAAQ,YAAY;AAAA,EAC7B;AACJ;;ACPe,MAAM,oBAAoB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK/C,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,wCAAe;AAAA,MACX,YAAY;AAAA,IACpB;AAEI,qCAAY;AAgFZ;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,MAAM;AAChB,YAAM,EAAE,MAAK,IAAK,KAAK,OAAO,sBAAqB;AAEnD,WAAK,MAAM;AAAA,QACP,QAAQ,CAAC,MAAM;AACX,cAAI,QAAS,IAAI,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,mBAAe,UAAU,IAAI,aAAa;AAC1C,mBAAe,aAAa,QAAQ,SAAS;AAC7C,mBAAe,aAAa,QAAQ,WAAW;AAC/C,mBAAe,aAAa,YAAY,GAAG;AAC3C,mBAAe,aAAa,oBAAoB,YAAY;AAC5D,mBAAe,iBAAiB,aAAa,KAAK,YAAY,KAAK;AAEnE,kBAAc,YAAY,MAAM;AAChC,iBAAa,YAAY,KAAK;AAC9B,mBAAe,YAAY,IAAI;AAE/B,WAAO,YAAY,aAAa;AAChC,WAAO,YAAY,YAAY;AAC/B,WAAO,YAAY,cAAc;AAEjC,aAAS,YAAY,MAAM;AAE3B,SAAK,SAAS;AAEd,WAAO;AAAA,EACX;AA4BJ;ACzIA,YAAY,OAAO,oBAAoB,WAAW;"}
1
+ {"version":3,"file":"wje-img-comparer.js","sources":["../packages/wje-img-comparer/img-comparer.element.js","../packages/wje-img-comparer/service/service.js","../packages/wje-img-comparer/img-comparer.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport Icon from '../wje-icon/icon.js';\nimport { drag } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element allows users to compare two images. `ImgComparer` is a custom web component that represents an image comparer.\n * It extends from `WJElement` and uses the `Icon` component.\n * @documentation https://elements.webjet.sk/components/img-comparer\n * @status stable\n * @augments {WJElement}\n * @slot before - The before image slot.\n * @slot after - The after image slot.\n * @csspart divider - The divider part.\n * @cssproperty [--wje-img-compare-divider-area=12px] - The area of the divider. This is the size of the divider. Accepts any valid CSS size.\n * @cssproperty [--wje-img-compare-divider-background=white] - Sets the background color of the divider in the image comparison component. Accepts any valid CSS color value (e.g., `red`, `#ff0000`, `rgba(255, 255, 255, 0.5)`). The default value is `white`, which ensures high contrast in most designs.\n * @cssproperty [--wje-img-compare-divider-size=2px] - The size of the divider. This is the thickness of the divider. Accepts any valid CSS size.\n * @cssproperty [--wje-img-compare-divider-left=50%] - The left position of the divider. This is the initial position of the divider.\n * @cssproperty [--wje-img-compare-position=50%] - The position of the divider. This is the position of the divider.\n * @cssproperty [--wje-img-compare-clip-path=inset(0 calc(100% - var(--wje-img-compare-position)) 0 0)] - The clip path of the divider. This is the clip path of the divider.\n * @tag wje-img-comparer\n */\nexport default class ImgComparer extends WJElement {\n /**\n * Creates an instance of ImgComparer.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Dependencies of the ImgComparer component.\n * @property {object} dependencies\n */\n dependencies = {\n 'wje-icon': Icon,\n };\n\n className = 'ImgComparer';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'group' });\n }\n\n /**\n * Draws the component.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-split-view');\n\n let beforeElement = document.createElement('div');\n beforeElement.classList.add('wje-before');\n\n let before = document.createElement('slot');\n before.setAttribute('name', 'before');\n\n let afterElement = document.createElement('div');\n afterElement.classList.add('wje-after');\n\n let after = document.createElement('slot');\n after.setAttribute('name', 'after');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'arrow-bar-both');\n\n let dividerElement = document.createElement('div');\n dividerElement.classList.add('wje-divider');\n dividerElement.setAttribute('part', 'divider');\n dividerElement.setAttribute('role', 'separator');\n dividerElement.setAttribute('tabindex', '0');\n dividerElement.setAttribute('aria-orientation', 'horizontal');\n dividerElement.addEventListener('mousedown', this.handleDrag, false);\n\n beforeElement.appendChild(before);\n afterElement.appendChild(after);\n dividerElement.appendChild(icon);\n\n native.appendChild(beforeElement);\n native.appendChild(afterElement);\n native.appendChild(dividerElement);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n return fragment;\n }\n\n /**\n * Handles the drag event.\n * @param {Event} e The event.\n */\n handleDrag = (e) => {\n const { width } = this.native.getBoundingClientRect();\n\n drag(this, {\n onMove: (x) => {\n let value = (x / width) * 100;\n this.position = parseFloat(this.clamp(value, 0, 100).toFixed(2));\n this.native.style.setProperty('--wje-img-compare-divider-left', this.position + '%');\n this.native.style.setProperty('--wje-img-compare-clip-path', `inset(0 ${100 - this.position}% 0 0)`);\n },\n initialEvent: e,\n });\n };\n\n /**\n * Clamps a number between a minimum and maximum value.\n * @param {number} num The number to clamp.\n * @param {number} min The minimum value.\n * @param {number} max The maximum value.\n * @returns {number} The clamped number.\n */\n clamp = (num, min, max) => Math.min(Math.max(num, min), max);\n}\n","export function drag(container, options) {\n function move(pointerEvent) {\n const dims = container.getBoundingClientRect();\n const defaultView = container.ownerDocument.defaultView;\n const offsetX = dims.left + defaultView.pageXOffset;\n const offsetY = dims.top + defaultView.pageYOffset;\n const x = pointerEvent.pageX - offsetX;\n const y = pointerEvent.pageY - offsetY;\n\n if (options?.onMove) {\n options.onMove(x, y);\n }\n }\n\n function stop() {\n document.removeEventListener('pointermove', move);\n document.removeEventListener('pointerup', stop);\n\n if (options?.onStop) {\n options.onStop();\n }\n }\n\n document.addEventListener('pointermove', move, { passive: true });\n document.addEventListener('pointerup', stop);\n\n if (options?.initialEvent instanceof PointerEvent) {\n move(options.initialEvent);\n }\n}\n","import ImgComparer from './img-comparer.element.js';\n\nexport default ImgComparer;\n\nImgComparer.define('wje-img-comparer', ImgComparer);\n"],"names":["ImgComparer","WJElement","constructor","super","dependencies","Icon","className","handleDrag","e","width","this","native","getBoundingClientRect","container","options","move","pointerEvent","dims","defaultView","ownerDocument","offsetX","left","pageXOffset","offsetY","top","pageYOffset","x","pageX","y","pageY","onMove","document","addEventListener","passive","stop","removeEventListener","onStop","initialEvent","PointerEvent","value","position","parseFloat","clamp","toFixed","style","setProperty","num","min","max","Math","cssStyleSheet","setupAttributes","isShadowRoot","setAriaState","role","draw","fragment","createDocumentFragment","createElement","classList","add","beforeElement","before","setAttribute","afterElement","after","icon","dividerElement","appendChild","define"],"mappings":";;;;;AAsBe,MAAMA,UAAoBC,EAAAA;AAAAA,EAKrC,cAAAC;AACIC,UAAAA;AAOJC,wCAAe,EACX,YAAYC;AAGhBC,qCAAY;AAgFZC,sCAAcC,CAAAA,OAAAA;AACV,YAAA,EAAMC,OAAEA,OAAUC,KAAKC,OAAOC,sBAAAA;AAAAA,QCxH/B,SAAcC,IAAWC,IAAAA;AAC5B,iBAASC,GAAKC;AACV,gBAAMC,IAAOJ,GAAUD,sBAAAA,GACjBM,IAAcL,GAAUM,cAAcD,aACtCE,IAAUH,EAAKI,OAAOH,EAAYI,aAClCC,IAAUN,EAAKO,MAAMN,EAAYO,aACjCC,IAAIV,GAAaW,QAAQP,GACzBQ,IAAIZ,GAAaa,QAAQN;AAE3BT,WAAAA,MAAAA,gBAAAA,GAASgB,WACThB,GAAQgB,OAAOJ,GAAGE,CAAAA;AAAAA,QAE1B;AAWAG,iBAASC,iBAAiB,eAAejB,IAAM,EAAEkB,SAAAA,KAAS,CAAA,GAC1DF,SAASC,iBAAiB,aAV1B,SAASE,KAAAA;AACLH,mBAASI,oBAAoB,eAAepB,EAAAA,GAC5CgB,SAASI,oBAAoB,aAAaD,EAAAA,IAEtCpB,MAAAA,gBAAAA,GAASsB,WACTtB,GAAQsB,OAAAA;AAAAA,QAEhB,CAAA,IAKItB,MAAAA,gBAAAA,GAASuB,yBAAwBC,gBACjCvB,GAAKD,GAAQuB;MAErB,GD6Fa3B,MAAM,EACPoB,QAASJ,CAAAA,OAAAA;AACL,YAAIa,KAASb,KAAIjB,KAAS;AAC1BC,aAAK8B,WAAWC,WAAW/B,KAAKgC,MAAMH,IAAO,GAAG,GAAA,EAAKI,QAAQ,CAAA,CAAA,GAC7DjC,KAAKC,OAAOiC,MAAMC,YAAY,kCAAkCnC,KAAK8B,WAAW,GAAA,GAChF9B,KAAKC,OAAOiC,MAAMC,YAAY,+BAA+B,WAA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AC1BE,EAAaI,YAAYH,CAAAA,GACzBE,EAAeC,YAAYF,CAAAA,GAE3BvD,GAAOyD,YAAYP,EAAAA,GACnBlD,GAAOyD,YAAYJ,CAAAA,GACnBrD,GAAOyD,YAAYD,CAAAA,GAEnBX,GAASY,YAAYzD,EAAAA,GAErBD,KAAKC,SAASA,IAEP6C;AAAAA,EACX;AA2BwDR;AExI5DhD,EAAYqE,OAAO,oBAAoBrE,CAAAA;"}
package/dist/wje-img.js CHANGED
@@ -1,246 +1,98 @@
1
1
  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
- import { getBasePath } from "./base-path.js";
5
- import WJElement from "./wje-element.js";
6
- const styles = "/*\n[ WJ Img ]\n*/\n\nimg {\n display: block;\n width: var(--wje-img-width, 100%);\n height: var(--wje-img-height, auto);\n max-width: 100%;\n object-fit: inherit;\n border-radius: var(--wje-img-border-radius, 0);\n}\n";
7
- class Img extends WJElement {
8
- /**
9
- * Creates an instance of Img.
10
- * @class
11
- */
4
+ import { getBasePath as t } from "./base-path.js";
5
+ import e from "./wje-element.js";
6
+ class i extends e {
12
7
  constructor() {
13
8
  super();
14
- /**
15
- * The class name for the component.
16
- * @type {string}
17
- */
18
9
  __publicField(this, "className", "Img");
19
- __publicField(this, "setAvatarInitials", (value = false) => {
20
- let parent = this.parentElement;
21
- if ((parent == null ? void 0 : parent.tagName) === "WJE-AVATAR") parent.initials = value;
10
+ __publicField(this, "setAvatarInitials", (t2 = false) => {
11
+ let e2 = this.parentElement;
12
+ "WJE-AVATAR" === (e2 == null ? void 0 : e2.tagName) && (e2.initials = t2);
22
13
  });
23
- /**
24
- * Deletes the current image by calling the remove method.
25
- * This function is typically used to trigger the removal of an image element
26
- * or perform cleanup operations related to the image.
27
- */
28
14
  __publicField(this, "deleteImage", () => {
29
15
  this.remove();
30
16
  });
31
- /**
32
- * Handles error scenarios by checking the `fallout` property and performing
33
- * corresponding actions. If `fallout` is not defined, the function terminates
34
- * early. Logs the active actions and attempts to assign an error handler
35
- * based on the `fallout` value. If the `fallout` value does not correspond to
36
- * a recognized action, it logs an error message.
37
- * @function onerrorFunc
38
- * @memberof Img
39
- */
40
- __publicField(this, "onerrorFunc", (img) => {
41
- if (!this.fallout) return;
42
- if (this.actions[this.fallout]) {
43
- img.onerror = this.actions[this.fallout];
44
- } else {
45
- console.error("Unsupported value:", this.fallout);
46
- }
17
+ __publicField(this, "onerrorFunc", (t2) => {
18
+ this.fallout && (this.actions[this.fallout] ? t2.onerror = this.actions[this.fallout] : console.error("Unsupported value:", this.fallout));
47
19
  });
48
- this._fallout = false;
49
- this.actions = {
50
- delete: () => this.deleteImage(),
51
- log: () => console.error("Error log pre obrázok:", this.src)
52
- };
53
- }
54
- /**
55
- * Sets the value of the `src` attribute for the element.
56
- * @param {string} value The value to set for the `src` attribute.
57
- */
58
- set src(value) {
59
- this.setAttribute("src", value);
60
- }
61
- /**
62
- * Retrieves the value of the 'src' attribute from the element.
63
- * @returns {string} The value of the 'src' attribute.
64
- */
20
+ this._fallout = false, this.actions = { delete: () => this.deleteImage(), log: () => console.error("Error log pre obrázok:", this.src) };
21
+ }
22
+ set src(t2) {
23
+ this.setAttribute("src", t2);
24
+ }
65
25
  get src() {
66
26
  return this.getAttribute("src");
67
27
  }
68
- /**
69
- * Sets the value of the 'alt' attribute for the element.
70
- * @param {string} value The new value to set for the 'alt' attribute.
71
- */
72
- set alt(value) {
73
- this.setAttribute("alt", value);
74
- }
75
- /**
76
- * Retrieves the value of the 'alt' attribute for the current element.
77
- * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.
78
- */
28
+ set alt(t2) {
29
+ this.setAttribute("alt", t2);
30
+ }
79
31
  get alt() {
80
32
  return this.getAttribute("alt");
81
33
  }
82
- /**
83
- * Sets the fallout property. Updates the `fallout` attribute if the value is a string;
84
- * otherwise, assigns the value to the `_fallout` property.
85
- * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.
86
- */
87
- set fallout(value) {
88
- if (typeof value === "string") {
89
- this.setAttribute("fallout", value);
90
- } else {
91
- this._fallout = value;
92
- }
34
+ set fallout(t2) {
35
+ "string" == typeof t2 ? this.setAttribute("fallout", t2) : this._fallout = t2;
93
36
  }
94
- /**
95
- * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.
96
- * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.
97
- */
98
37
  get fallout() {
99
38
  return this.hasAttribute("fallout") ? this.getAttribute("fallout") : this._fallout;
100
39
  }
101
- /**
102
- * Sets the value of the loader attribute.
103
- * @param {string} value The value to set for the loader attribute.
104
- */
105
- set loader(value) {
106
- if (value) {
107
- this.setAttribute("loader", value);
108
- }
40
+ set loader(t2) {
41
+ t2 && this.setAttribute("loader", t2);
109
42
  }
110
- /**
111
- * Retrieves the configured loader URL or resolves the default loader from the base path.
112
- * @returns {string} The loader URL.
113
- */
114
43
  get loader() {
115
- return this.getAttribute("loader") || getBasePath("assets/img/image-loader.gif");
116
- }
117
- /**
118
- * Enables or disables lazy loading for the image.
119
- * @param {boolean} value True to disable lazy loading, false to restore the default lazy behavior.
120
- */
121
- set noLazy(value) {
122
- if (value) {
123
- this.setAttribute("no-lazy", "");
124
- } else {
125
- this.removeAttribute("no-lazy");
126
- }
44
+ return this.getAttribute("loader") || t("assets/img/image-loader.gif");
45
+ }
46
+ set noLazy(t2) {
47
+ t2 ? this.setAttribute("no-lazy", "") : this.removeAttribute("no-lazy");
127
48
  }
128
- /**
129
- * Checks whether lazy loading is disabled.
130
- * @returns {boolean} True when the `no-lazy` attribute is present.
131
- */
132
49
  get noLazy() {
133
50
  return this.hasAttribute("no-lazy");
134
51
  }
135
- /**
136
- * Returns the CSS styles for the component.
137
- * @static
138
- * @returns {CSSStyleSheet}
139
- */
140
52
  static get cssStyleSheet() {
141
- return styles;
53
+ return "img{display:block;width:var(--wje-img-width, 100%);height:var(--wje-img-height, auto);max-width:100%;object-fit:inherit;border-radius:var(--wje-img-border-radius, 0)}";
142
54
  }
143
- /**
144
- * Returns the list of attributes to observe for changes.
145
- * @static
146
- * @returns {Array<string>}
147
- */
148
55
  static get observedAttributes() {
149
56
  return ["src", "alt", "no-lazy"];
150
57
  }
151
- attributeChangedCallback(name, oldValue, newValue) {
58
+ attributeChangedCallback(t2, e2, i2) {
152
59
  var _a, _b;
153
- (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, name, oldValue, newValue);
154
- if (oldValue === newValue) return;
155
- if (name === "alt") {
156
- if (this.native) this.native.setAttribute("alt", this.alt || "");
157
- const label = (_b = this.alt) == null ? void 0 : _b.trim();
158
- if (label) this.setAriaState({ label });
60
+ if ((_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, t2, e2, i2), e2 !== i2 && "alt" === t2) {
61
+ this.native && this.native.setAttribute("alt", this.alt || "");
62
+ const t3 = (_b = this.alt) == null ? void 0 : _b.trim();
63
+ t3 && this.setAriaState({ label: t3 });
159
64
  }
160
65
  }
161
- /**
162
- * Sets up the attributes for the component.
163
- */
164
66
  setupAttributes() {
165
67
  var _a;
166
- this.isShadowRoot = "open";
167
- this.setAriaState({ role: "img" });
168
- if ((_a = this.alt) == null ? void 0 : _a.trim()) this.setAriaState({ label: this.alt.trim() });
169
- }
170
- /**
171
- * Creates and assembles a lazy-loaded image element within a document fragment.
172
- * @returns {DocumentFragment} A document fragment containing the image element.
173
- */
68
+ this.isShadowRoot = "open", this.setAriaState({ role: "img" }), ((_a = this.alt) == null ? void 0 : _a.trim()) && this.setAriaState({ label: this.alt.trim() });
69
+ }
174
70
  draw() {
175
71
  var _a;
176
- let fragment = document.createDocumentFragment();
177
- let native = document.createElement("img");
178
- native.setAttribute("part", "native");
179
- native.setAttribute("src", this.noLazy ? this.src : this.loader);
180
- native.setAttribute("alt", this.alt || "");
181
- native.classList.add("lazy-loaded-image", "lazy");
182
- native.addEventListener("error", (e) => {
183
- const absoluteLoaderUrl = new URL(this.loader, window.location.origin).href;
184
- if (e.target.src === absoluteLoaderUrl) return;
185
- this.setAvatarInitials(true);
186
- });
187
- this.onerrorFunc(native);
188
- fragment.appendChild(native);
189
- this.native = native;
190
- if ((_a = this.alt) == null ? void 0 : _a.trim()) this.setAriaState({ label: this.alt.trim() });
191
- return fragment;
192
- }
193
- /**
194
- * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.
195
- * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.
196
- * Removes the `lazy` class once the image source is updated and unobserves the element.
197
- * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.
198
- * @returns {void} Does not return a value.
199
- */
72
+ let t2 = document.createDocumentFragment(), e2 = document.createElement("img");
73
+ return e2.setAttribute("part", "native"), e2.setAttribute("src", this.noLazy ? this.src : this.loader), e2.setAttribute("alt", this.alt || ""), e2.classList.add("lazy-loaded-image", "lazy"), e2.addEventListener("error", (t3) => {
74
+ const e3 = new URL(this.loader, window.location.origin).href;
75
+ t3.target.src !== e3 && this.setAvatarInitials(true);
76
+ }), this.onerrorFunc(e2), t2.appendChild(e2), this.native = e2, ((_a = this.alt) == null ? void 0 : _a.trim()) && this.setAriaState({ label: this.alt.trim() }), t2;
77
+ }
200
78
  afterDraw() {
201
- if (this.noLazy) {
202
- this.native.classList.remove("lazy");
203
- return;
204
- }
205
- let lazyImageObserver = new IntersectionObserver((entries, observer) => {
206
- entries.forEach((entry) => {
207
- if (entry.isIntersecting) {
208
- entry.target.src = this.src;
209
- this.classList.remove("lazy");
210
- lazyImageObserver.unobserve(entry.target);
211
- }
79
+ if (this.noLazy) return void this.native.classList.remove("lazy");
80
+ let t2 = new IntersectionObserver((e2, i2) => {
81
+ e2.forEach((e3) => {
82
+ e3.isIntersecting && (e3.target.src = this.src, this.classList.remove("lazy"), t2.unobserve(e3.target));
212
83
  });
213
84
  });
214
- lazyImageObserver.observe(this.native);
215
- }
216
- /**
217
- * Adds a new action to the internal actions object.
218
- * @param {string} name The name of the action to be added.
219
- * @param {Function} func The function representing the action logic.
220
- * @returns {void} This method does not return a value.
221
- */
222
- addAction(name, func) {
223
- if (typeof func === "function") {
224
- this.actions[name] = func;
225
- } else {
226
- console.error("The action must be a function.");
227
- }
85
+ t2.observe(this.native);
228
86
  }
229
- /**
230
- * Removes an action from the actions list if it exists.
231
- * @param {string} name The name of the action to remove.
232
- * @returns {void} Does not return a value.
233
- */
234
- removeAction(name) {
235
- if (this.actions[name]) {
236
- delete this.actions[name];
237
- } else {
238
- console.error(`Action "${name}" does not exist.`);
239
- }
87
+ addAction(t2, e2) {
88
+ "function" == typeof e2 ? this.actions[t2] = e2 : console.error("The action must be a function.");
89
+ }
90
+ removeAction(t2) {
91
+ this.actions[t2] ? delete this.actions[t2] : console.error(`Action "${t2}" does not exist.`);
240
92
  }
241
93
  }
242
- Img.define("wje-img", Img);
94
+ i.define("wje-img", i);
243
95
  export {
244
- Img as default
96
+ i as default
245
97
  };
246
98
  //# sourceMappingURL=wje-img.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { getBasePath } from '../utils/base-path.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading. Defaults to the loader asset resolved from the configured base path.\n * @property {boolean} noLazy - Disables lazy loading and renders the image source immediately.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n };\n }\n\n /**\n * Sets the value of the `src` attribute for the element.\n * @param {string} value The value to set for the `src` attribute.\n */\n set src(value) {\n this.setAttribute('src', value);\n }\n\n /**\n * Retrieves the value of the 'src' attribute from the element.\n * @returns {string} The value of the 'src' attribute.\n */\n get src() {\n return this.getAttribute('src');\n }\n\n /**\n * Sets the value of the 'alt' attribute for the element.\n * @param {string} value The new value to set for the 'alt' attribute.\n */\n set alt(value) {\n this.setAttribute('alt', value);\n }\n\n /**\n * Retrieves the value of the 'alt' attribute for the current element.\n * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.\n */\n get alt() {\n return this.getAttribute('alt');\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the configured loader URL or resolves the default loader from the base path.\n * @returns {string} The loader URL.\n */\n get loader() {\n return this.getAttribute('loader') || getBasePath('assets/img/image-loader.gif');\n }\n\n /**\n * Enables or disables lazy loading for the image.\n * @param {boolean} value True to disable lazy loading, false to restore the default lazy behavior.\n */\n set noLazy(value) {\n if (value) {\n this.setAttribute('no-lazy', '');\n } else {\n this.removeAttribute('no-lazy');\n }\n }\n\n /**\n * Checks whether lazy loading is disabled.\n * @returns {boolean} True when the `no-lazy` attribute is present.\n */\n get noLazy() {\n return this.hasAttribute('no-lazy');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['src', 'alt', 'no-lazy'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (oldValue === newValue) return;\n if (name === 'alt') {\n if (this.native) this.native.setAttribute('alt', this.alt || '');\n const label = this.alt?.trim();\n if (label) this.setAriaState({ label });\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'img' });\n if (this.alt?.trim()) this.setAriaState({ label: this.alt.trim() });\n }\n\n /**\n * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.noLazy ? this.src : this.loader);\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n native.addEventListener('error', (e) => {\n const absoluteLoaderUrl = new URL(this.loader, window.location.origin).href;\n if (e.target.src === absoluteLoaderUrl) return;\n\n this.setAvatarInitials(true);\n });\n\n this.onerrorFunc(native);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n if (this.alt?.trim()) this.setAriaState({ label: this.alt.trim() });\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n if (this.noLazy) {\n this.native.classList.remove('lazy');\n return;\n }\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n entry.target.src = this.src;\n this.classList.remove('lazy');\n\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n setAvatarInitials = (value = false) => {\n let parent = this.parentElement;\n if (parent?.tagName === 'WJE-AVATAR') parent.initials = value;\n };\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n };\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = (img) => {\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n img.onerror = this.actions[this.fallout];\n } else {\n console.error('Unsupported value:', this.fallout);\n }\n };\n}\n","import Img from './img.element.js';\n\nexport default Img;\n\nImg.define('wje-img', Img);\n"],"names":[],"mappings":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AQ,KAAK,MAAM;AAAA,EACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBA,UAAU,MAAM,MAAM;AAClB,QAAI,OAAO,SAAS,YAAY;AAC5B,WAAK,QAAQ,IAAI,IAAI;AAAA,IACzB,OAAO;AACH,cAAQ,MAAM,gCAAgC;AAAA,IAClD;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,aAAa,MAAM;AACf,QAAI,KAAK,QAAQ,IAAI,GAAG;AACpB,aAAO,KAAK,QAAQ,IAAI;AAAA,IAC5B,OAAO;AACH,cAAQ,MAAM,WAAW,IAAI,mBAAmB;AAAA,IACpD;AAAA,EACJ;AAmBJ;ACtRA,IAAI,OAAO,WAAW,GAAG;"}
1
+ {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { getBasePath } from '../utils/base-path.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading. Defaults to the loader asset resolved from the configured base path.\n * @property {boolean} noLazy - Disables lazy loading and renders the image source immediately.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n };\n }\n\n /**\n * Sets the value of the `src` attribute for the element.\n * @param {string} value The value to set for the `src` attribute.\n */\n set src(value) {\n this.setAttribute('src', value);\n }\n\n /**\n * Retrieves the value of the 'src' attribute from the element.\n * @returns {string} The value of the 'src' attribute.\n */\n get src() {\n return this.getAttribute('src');\n }\n\n /**\n * Sets the value of the 'alt' attribute for the element.\n * @param {string} value The new value to set for the 'alt' attribute.\n */\n set alt(value) {\n this.setAttribute('alt', value);\n }\n\n /**\n * Retrieves the value of the 'alt' attribute for the current element.\n * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.\n */\n get alt() {\n return this.getAttribute('alt');\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the configured loader URL or resolves the default loader from the base path.\n * @returns {string} The loader URL.\n */\n get loader() {\n return this.getAttribute('loader') || getBasePath('assets/img/image-loader.gif');\n }\n\n /**\n * Enables or disables lazy loading for the image.\n * @param {boolean} value True to disable lazy loading, false to restore the default lazy behavior.\n */\n set noLazy(value) {\n if (value) {\n this.setAttribute('no-lazy', '');\n } else {\n this.removeAttribute('no-lazy');\n }\n }\n\n /**\n * Checks whether lazy loading is disabled.\n * @returns {boolean} True when the `no-lazy` attribute is present.\n */\n get noLazy() {\n return this.hasAttribute('no-lazy');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['src', 'alt', 'no-lazy'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (oldValue === newValue) return;\n if (name === 'alt') {\n if (this.native) this.native.setAttribute('alt', this.alt || '');\n const label = this.alt?.trim();\n if (label) this.setAriaState({ label });\n }\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'img' });\n if (this.alt?.trim()) this.setAriaState({ label: this.alt.trim() });\n }\n\n /**\n * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.noLazy ? this.src : this.loader);\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n native.addEventListener('error', (e) => {\n const absoluteLoaderUrl = new URL(this.loader, window.location.origin).href;\n if (e.target.src === absoluteLoaderUrl) return;\n\n this.setAvatarInitials(true);\n });\n\n this.onerrorFunc(native);\n\n fragment.appendChild(native);\n\n this.native = native;\n\n if (this.alt?.trim()) this.setAriaState({ label: this.alt.trim() });\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n if (this.noLazy) {\n this.native.classList.remove('lazy');\n return;\n }\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n entry.target.src = this.src;\n this.classList.remove('lazy');\n\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n setAvatarInitials = (value = false) => {\n let parent = this.parentElement;\n if (parent?.tagName === 'WJE-AVATAR') parent.initials = value;\n };\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n };\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = (img) => {\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n img.onerror = this.actions[this.fallout];\n } else {\n console.error('Unsupported value:', this.fallout);\n }\n };\n}\n","import Img from './img.element.js';\n\nexport default Img;\n\nImg.define('wje-img', Img);\n"],"names":["Img","WJElement","constructor","super","className","setAvatarInitials","value","parent","this","parentElement","tagName","initials","deleteImage","remove","onerrorFunc","img","fallout","actions","onerror","console","error","_fallout","delete","log","src","setAttribute","getAttribute","hasAttribute","loader","getBasePath","removeAttribute","noLazy","cssStyleSheet","observedAttributes","name","oldValue","newValue","attributeChangedCallback","native","alt","label","trim","setAriaState","setupAttributes","isShadowRoot","role","draw","fragment","document","createDocumentFragment","createElement","classList","add","addEventListener","e","absoluteLoaderUrl","URL","window","location","origin","href","target","appendChild","afterDraw","lazyImageObserver","IntersectionObserver","entries","observer","forEach","entry","isIntersecting","unobserve","observe","func","define"],"mappings":";;;;;AAkBe,MAAMA,UAAYC,EAAAA;AAAAA,EAK7B,cAAAC;AACIC,UAAAA;AAyGJC,qCAAY;AAgGZC,6CAAoB,CAACC,KAAAA,UAAQ;AACzB,UAAIC,KAASC,KAAKC;AACM,wBAApBF,MAAAA,gBAAAA,GAAQG,aAA0BH,GAAOI,WAAWL;AAAAA;AAO5DM,uCAAc,MAAA;AACVJ,WAAKK,OAAAA;AAAAA,IAAAA;AAuCTC,uCAAeC,CAAAA,OAAAA;AACNP,WAAKQ,YACNR,KAAKS,QAAQT,KAAKQ,OAAAA,IAClBD,GAAIG,UAAUV,KAAKS,QAAQT,KAAKQ,OAAAA,IAEhCG,QAAQC,MAAM,sBAAsBZ,KAAKQ;;AA7P7CR,SAAKa,WAAAA,OAELb,KAAKS,UAAU,EACXK,QAAQ,MAAMd,KAAKI,eACnBW,KAAK,MAAMJ,QAAQC,MAAM,0BAA0BZ,KAAKgB,GAAAA,EAAAA;AAAAA,EAEhE;AAAA,EAMA,QAAQlB,IAAAA;AACJE,SAAKiB,aAAa,OAAOnB;EAC7B;AAAA,EAMA,IAAA;AACI,WAAOE,KAAKkB,aAAa,KAAA;AAAA,EAC7B;AAAA,EAMA,QAAQpB,IAAAA;AACJE,SAAKiB,aAAa,OAAOnB;EAC7B;AAAA,EAMA,IAAA;AACI,WAAOE,KAAKkB,aAAa,KAAA;AAAA,EAC7B;AAAA,EAOA,YAAYpB,IAAAA;AACa,uBAAVA,KACPE,KAAKiB,aAAa,WAAWnB,EAAAA,IAE7BE,KAAKa,WAAWf;AAAAA,EAExB;AAAA,EAMA,IAAA,UAAIU;AACA,WAAOR,KAAKmB,aAAa,aAAanB,KAAKkB,aAAa,aAAalB,KAAKa;AAAAA,EAC9E;AAAA,EAMA,IAAA,OAAWf;AACHA,IAAAA,MACAE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