wj-elements 0.0.3 → 0.0.5

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 (66) hide show
  1. package/dist/router-links-e0087f84.js +146 -0
  2. package/dist/style.css +2 -2365
  3. package/dist/wj-aside.js +18 -22
  4. package/dist/wj-avatar.js +32 -49
  5. package/dist/wj-badge.js +18 -22
  6. package/dist/wj-breadcrumb.js +53 -103
  7. package/dist/wj-breadcrumbs.js +21 -36
  8. package/dist/wj-button-group.js +24 -36
  9. package/dist/wj-button.js +37 -80
  10. package/dist/wj-card-content.js +16 -18
  11. package/dist/wj-card-controls.js +16 -18
  12. package/dist/wj-card-header.js +16 -20
  13. package/dist/wj-card-subtitle.js +17 -19
  14. package/dist/wj-card-title.js +16 -18
  15. package/dist/wj-card.js +16 -20
  16. package/dist/wj-checkbox.js +24 -46
  17. package/dist/wj-chip.js +21 -39
  18. package/dist/wj-col.js +18 -32
  19. package/dist/wj-color-picker.js +503 -868
  20. package/dist/wj-container.js +18 -20
  21. package/dist/wj-copy-button.js +66 -112
  22. package/dist/wj-dialog.js +43 -67
  23. package/dist/wj-divider.js +16 -20
  24. package/dist/wj-dropdown.js +22 -31
  25. package/dist/wj-element.js +241 -416
  26. package/dist/wj-footer.js +16 -18
  27. package/dist/wj-form.js +16 -18
  28. package/dist/wj-grid.js +17 -21
  29. package/dist/wj-header.js +18 -22
  30. package/dist/wj-icon-picker.js +66 -107
  31. package/dist/wj-icon.js +67 -142
  32. package/dist/wj-img-comparer.js +43 -72
  33. package/dist/wj-img.js +21 -31
  34. package/dist/wj-infinite-scroll.js +49 -84
  35. package/dist/wj-input.js +67 -146
  36. package/dist/wj-item.js +19 -34
  37. package/dist/wj-label.js +19 -21
  38. package/dist/wj-list.js +17 -20
  39. package/dist/wj-main.js +16 -18
  40. package/dist/wj-master.js +331 -462
  41. package/dist/wj-menu-button.js +18 -21
  42. package/dist/wj-menu-item.js +67 -144
  43. package/dist/wj-menu-label.js +17 -21
  44. package/dist/wj-menu.js +20 -24
  45. package/dist/wj-popup.js +714 -1140
  46. package/dist/wj-progress-bar.js +42 -100
  47. package/dist/wj-radio-group.js +27 -38
  48. package/dist/wj-radio.js +24 -46
  49. package/dist/wj-route.js +8 -11
  50. package/dist/wj-router-link.js +19 -22
  51. package/dist/wj-router-outlet.js +71 -135
  52. package/dist/wj-routerx.js +641 -1121
  53. package/dist/wj-row.js +20 -22
  54. package/dist/wj-slider.js +55 -97
  55. package/dist/wj-split-view.js +45 -81
  56. package/dist/wj-store.js +110 -195
  57. package/dist/wj-textarea.js +39 -86
  58. package/dist/wj-thumbnail.js +17 -19
  59. package/dist/wj-toast.js +34 -88
  60. package/dist/wj-toggle.js +24 -42
  61. package/dist/wj-toolbar-action.js +16 -27
  62. package/dist/wj-toolbar.js +21 -26
  63. package/dist/wj-tooltip.js +27 -41
  64. package/dist/wj-visually-hidden.js +16 -18
  65. package/package.json +1 -1
  66. package/dist/router-links-26e4a166.js +0 -204
package/dist/wj-icon.js CHANGED
@@ -1,127 +1,67 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement from "./wj-element.js";
1
+ var h = Object.defineProperty;
2
+ var m = (t, e, o) => e in t ? h(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var l = (t, e, o) => (m(t, typeof e != "symbol" ? e + "" : e, o), o);
4
+ import w from "./wj-element.js";
8
5
  import "./wj-store.js";
9
- const iconContent = /* @__PURE__ */ new Map();
10
- const requests = /* @__PURE__ */ new Map();
11
- let parser;
12
- const getSrc = (src) => {
13
- if (isStr(src)) {
14
- src = src.trim();
15
- if (isSrc(src)) {
16
- return src;
17
- }
18
- }
19
- return null;
20
- };
21
- const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
22
- const isSvgDataUrl = (url) => url.startsWith("data:image/svg+xml");
23
- const isEncodedDataUrl = (url) => url.indexOf(";utf8,") !== -1;
24
- const isStr = (val) => typeof val === "string";
25
- const validateContent = (svgContent) => {
26
- const div = document.createElement("div");
27
- div.innerHTML = svgContent;
28
- const svgElm = div.firstElementChild;
29
- if (svgElm && svgElm.nodeName.toLowerCase() === "svg") {
30
- svgElm.getAttribute("class") || "";
31
- if (isValid(svgElm)) {
32
- return div.innerHTML;
33
- }
34
- }
35
- return "";
36
- };
37
- const isValid = (elm) => {
38
- if (elm.nodeType === 1) {
39
- if (elm.nodeName.toLowerCase() === "script") {
40
- return false;
41
- }
42
- for (let i = 0; i < elm.attributes.length; i++) {
43
- const name = elm.attributes[i].name;
44
- if (isStr(name) && name.toLowerCase().indexOf("on") === 0) {
45
- return false;
46
- }
47
- }
48
- for (let i = 0; i < elm.childNodes.length; i++) {
49
- if (!isValid(elm.childNodes[i])) {
50
- return false;
51
- }
6
+ const i = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
7
+ let a;
8
+ const u = (t) => c(t) && (t = t.trim(), g(t)) ? t : null, g = (t) => t.length > 0 && /(\/|\.)/.test(t), p = (t) => t.startsWith("data:image/svg+xml"), j = (t) => t.indexOf(";utf8,") !== -1, c = (t) => typeof t == "string", v = (t) => {
9
+ const e = document.createElement("div");
10
+ e.innerHTML = t;
11
+ const o = e.firstElementChild;
12
+ return o && o.nodeName.toLowerCase() === "svg" && (o.getAttribute("class"), f(o)) ? e.innerHTML : "";
13
+ }, f = (t) => {
14
+ if (t.nodeType === 1) {
15
+ if (t.nodeName.toLowerCase() === "script")
16
+ return !1;
17
+ for (let e = 0; e < t.attributes.length; e++) {
18
+ const o = t.attributes[e].name;
19
+ if (c(o) && o.toLowerCase().indexOf("on") === 0)
20
+ return !1;
52
21
  }
22
+ for (let e = 0; e < t.childNodes.length; e++)
23
+ if (!f(t.childNodes[e]))
24
+ return !1;
53
25
  }
54
- return true;
55
- };
56
- const getSvgContent = (url, sanitize) => {
57
- let req = requests.get(url);
58
- if (!req) {
59
- if (typeof fetch !== "undefined" && typeof document !== "undefined") {
60
- if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
61
- if (!parser) {
62
- parser = new DOMParser();
63
- }
64
- const doc = parser.parseFromString(url, "text/html");
65
- const svg = doc.querySelector("svg");
66
- if (svg) {
67
- iconContent.set(url, svg.outerHTML);
68
- }
69
- return Promise.resolve();
70
- } else {
71
- req = fetch(url).then((rsp) => {
72
- if (rsp.ok) {
73
- return rsp.text().then((svgContent) => {
74
- if (svgContent && sanitize !== false) {
75
- svgContent = validateContent(svgContent);
76
- }
77
- iconContent.set(url, svgContent || "");
26
+ return !0;
27
+ }, b = (t, e) => {
28
+ let o = d.get(t);
29
+ if (!o)
30
+ if (typeof fetch < "u" && typeof document < "u")
31
+ if (p(t) && j(t)) {
32
+ a || (a = new DOMParser());
33
+ const s = a.parseFromString(t, "text/html").querySelector("svg");
34
+ return s && i.set(t, s.outerHTML), Promise.resolve();
35
+ } else
36
+ o = fetch(t).then((r) => {
37
+ if (r.ok)
38
+ return r.text().then((s) => {
39
+ s && e !== !1 && (s = v(s)), i.set(t, s || "");
78
40
  });
79
- }
80
- iconContent.set(url, "");
81
- });
82
- requests.set(url, req);
83
- }
84
- } else {
85
- iconContent.set(url, "");
86
- return Promise.resolve();
87
- }
88
- }
89
- return req;
90
- };
91
- const getUrl = (i) => {
92
- let url = getSrc(i.src);
93
- if (url) {
94
- return url;
95
- }
96
- url = getName(i.name);
97
- if (url) {
98
- return getNamedUrl(url);
99
- }
100
- return null;
101
- };
102
- const getName = (iconName) => {
103
- if (!isStr(iconName) || iconName.trim() === "") {
104
- return null;
105
- }
106
- const invalidChars = iconName.replace(/[a-z]|-|\d/gi, "");
107
- if (invalidChars !== "") {
108
- return null;
109
- }
110
- return iconName;
111
- };
112
- const getNamedUrl = (iconName) => {
113
- const url = new URL(`/assets/img/icons/svg/${iconName}.svg`, "");
114
- console.log(url);
115
- return `/assets/img/icons/svg/${iconName}.svg`;
116
- };
117
- const styles = "/*!\n* direction.scss\n*/\n/* Skeleton Variables */\n/*\n[ Icon ]\n*/\n:host(.wj-color-primary) {\n --wj-color-base: #eae0fb !important;\n --wj-color-contrast: #845ae0 !important;\n}\n:host(.wj-color-complete) {\n --wj-color-base: #d3eeff !important;\n --wj-color-contrast: #0f8ff9 !important;\n}\n:host(.wj-color-success) {\n --wj-color-base: #d6f7f0 !important;\n --wj-color-contrast: #26bf93 !important;\n}\n:host(.wj-color-warning) {\n --wj-color-base: #fffde1 !important;\n --wj-color-contrast: #ffe858 !important;\n}\n:host(.wj-color-danger) {\n --wj-color-base: #fde2da !important;\n --wj-color-contrast: #e6533c !important;\n}\n:host(.wj-color-info) {\n --wj-color-base: #dbe6e8 !important;\n --wj-color-contrast: #475b6b !important;\n}\n:host(.wj-color-menu) {\n --wj-color-base: #f4f4f4 !important;\n --wj-color-contrast: #21252d !important;\n}\n:host {\n --wj-icon-width: 100%;\n --wj-icon-height: 100%;\n display: inline-block;\n width: 1em;\n height: 1em;\n contain: strict;\n fill: currentColor;\n box-sizing: content-box !important;\n}\n.icon-inner, svg {\n display: block;\n height: var(--wj-icon-height);\n width: var(--wj-icon-width);\n}\n:host(.wj-size-small) {\n --wj-icon-size: 18px;\n}\n:host(.wj-size-large) {\n --wj-icon-size: 32px;\n}\n:host(.wj-size) {\n font-size: var(--wj-icon-size) !important;\n}\n:host(.wj-color) {\n color: var(--wj-color-contrast);\n}";
118
- class Icon extends WJElement {
41
+ i.set(t, "");
42
+ }), d.set(t, o);
43
+ else
44
+ return i.set(t, ""), Promise.resolve();
45
+ return o;
46
+ }, z = (t) => {
47
+ let e = u(t.src);
48
+ return e || (e = L(t.name), e ? y(e) : null);
49
+ }, L = (t) => !c(t) || t.trim() === "" || t.replace(/[a-z]|-|\d/gi, "") !== "" ? null : t, y = (t) => {
50
+ const e = `./assets/img/icons/svg/${t}.svg`;
51
+ console.log("SOM:", e);
52
+ const o = new URL(e, import.meta.url);
53
+ return console.log(o), o.href;
54
+ }, x = `/*!
55
+ * direction.scss
56
+ */:host(.wj-color-primary){--wj-color-base: #eae0fb !important;--wj-color-contrast: #845ae0 !important}:host(.wj-color-complete){--wj-color-base: #d3eeff !important;--wj-color-contrast: #0f8ff9 !important}:host(.wj-color-success){--wj-color-base: #d6f7f0 !important;--wj-color-contrast: #26bf93 !important}:host(.wj-color-warning){--wj-color-base: #fffde1 !important;--wj-color-contrast: #ffe858 !important}:host(.wj-color-danger){--wj-color-base: #fde2da !important;--wj-color-contrast: #e6533c !important}:host(.wj-color-info){--wj-color-base: #dbe6e8 !important;--wj-color-contrast: #475b6b !important}:host(.wj-color-menu){--wj-color-base: #f4f4f4 !important;--wj-color-contrast: #21252d !important}:host{--wj-icon-width: 100%;--wj-icon-height: 100%;display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box!important}.icon-inner,svg{display:block;height:var(--wj-icon-height);width:var(--wj-icon-width)}:host(.wj-size-small){--wj-icon-size: 18px}:host(.wj-size-large){--wj-icon-size: 32px}:host(.wj-size){font-size:var(--wj-icon-size)!important}:host(.wj-color){color:var(--wj-color-contrast)}
57
+ `;
58
+ class S extends w {
119
59
  constructor() {
120
60
  super();
121
- __publicField(this, "className", "Icon");
61
+ l(this, "className", "Icon");
122
62
  }
123
63
  static get cssStyleSheet() {
124
- return styles;
64
+ return x;
125
65
  }
126
66
  static get observedAttributes() {
127
67
  return ["name"];
@@ -129,37 +69,22 @@ class Icon extends WJElement {
129
69
  setupAttributes() {
130
70
  this.isShadowRoot = "open";
131
71
  }
132
- draw(context, store, params) {
133
- let fragment = document.createDocumentFragment();
134
- this.classList.add("lazy-loaded-image", "lazy");
135
- this.classList.remove(...this.classList);
136
- this.element = document.createElement("div");
137
- this.element.classList.add("icon-inner");
138
- this.url = getUrl(this);
139
- this.classList.add("wj-size");
140
- if (this.color)
141
- this.classList.add("wj-color-" + this.color, "wj-color");
142
- if (this.size)
143
- this.classList.add("wj-size-" + this.size);
144
- fragment.appendChild(this.element);
145
- return fragment;
72
+ draw(o, r, s) {
73
+ let n = document.createDocumentFragment();
74
+ return this.classList.add("lazy-loaded-image", "lazy"), this.classList.remove(...this.classList), this.element = document.createElement("div"), this.element.classList.add("icon-inner"), this.url = z(this), this.classList.add("wj-size"), this.color && this.classList.add("wj-color-" + this.color, "wj-color"), this.size && this.classList.add("wj-size-" + this.size), n.appendChild(this.element), n;
146
75
  }
147
76
  afterDraw() {
148
- let lazyImageObserver = new IntersectionObserver((entries, observer) => {
149
- entries.forEach((entry) => {
150
- if (entry.isIntersecting) {
151
- getSvgContent(this.url).then((svgContent) => {
152
- this.element.innerHTML = iconContent.get(this.url);
153
- });
154
- this.classList.remove("lazy");
155
- lazyImageObserver.unobserve(entry.target);
156
- }
77
+ let o = new IntersectionObserver((r, s) => {
78
+ r.forEach((n) => {
79
+ n.isIntersecting && (b(this.url).then((C) => {
80
+ this.element.innerHTML = i.get(this.url);
81
+ }), this.classList.remove("lazy"), o.unobserve(n.target));
157
82
  });
158
83
  });
159
- lazyImageObserver.observe(this.element);
84
+ o.observe(this.element);
160
85
  }
161
86
  }
162
- customElements.get("wj-icon") || window.customElements.define("wj-icon", Icon);
87
+ customElements.get("wj-icon") || window.customElements.define("wj-icon", S);
163
88
  export {
164
- Icon
89
+ S as Icon
165
90
  };
@@ -1,57 +1,40 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement from "./wj-element.js";
1
+ var w = Object.defineProperty;
2
+ var h = (i, e, t) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var p = (i, e, t) => (h(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import u from "./wj-element.js";
8
5
  import "./wj-store.js";
9
- function drag(container, options) {
10
- function move(pointerEvent) {
11
- const dims = container.getBoundingClientRect();
12
- const defaultView = container.ownerDocument.defaultView;
13
- const offsetX = dims.left + defaultView.pageXOffset;
14
- const offsetY = dims.top + defaultView.pageYOffset;
15
- const x = pointerEvent.pageX - offsetX;
16
- const y = pointerEvent.pageY - offsetY;
17
- if (options == null ? void 0 : options.onMove) {
18
- options.onMove(x, y);
19
- }
20
- }
21
- function stop() {
22
- document.removeEventListener("pointermove", move);
23
- document.removeEventListener("pointerup", stop);
24
- if (options == null ? void 0 : options.onStop) {
25
- options.onStop();
26
- }
6
+ function f(i, e) {
7
+ function t(o) {
8
+ const d = i.getBoundingClientRect(), r = i.ownerDocument.defaultView, n = d.left + r.pageXOffset, l = d.top + r.pageYOffset, s = o.pageX - n, m = o.pageY - l;
9
+ e != null && e.onMove && e.onMove(s, m);
27
10
  }
28
- document.addEventListener("pointermove", move, { passive: true });
29
- document.addEventListener("pointerup", stop);
30
- if ((options == null ? void 0 : options.initialEvent) instanceof PointerEvent) {
31
- move(options.initialEvent);
11
+ function a() {
12
+ document.removeEventListener("pointermove", t), document.removeEventListener("pointerup", a), e != null && e.onStop && e.onStop();
32
13
  }
14
+ document.addEventListener("pointermove", t, { passive: !0 }), document.addEventListener("pointerup", a), (e == null ? void 0 : e.initialEvent) instanceof PointerEvent && t(e.initialEvent);
33
15
  }
34
- const styles = '/*!\n* direction.scss\n*/\n/* Skeleton Variables */\n/*\n[ SplitView ]\n*/\n:host {\n --wj-img-compare-divider-area: 12px;\n --wj-img-compare-divider-background: white;\n --wj-img-compare-divider-size: 2px;\n --wj-img-compare-divider-left: 50%;\n --wj-img-compare-position: 50%;\n --wj-img-compare-clip-path: inset(0 calc(100% - var(--wj-img-compare-position)) 0 0);\n display: inline-block;\n position: relative;\n width: 100%;\n border-color: var(--wj-border-color);\n border-style: solid;\n border-width: 1px;\n}\n.wj-before, .wj-after {\n display: block;\n}\n.wj-after {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n width: 100%;\n clip-path: var(--wj-img-compare-clip-path);\n}\n.native-split-view {\n max-width: 100%;\n max-height: 100%;\n overflow: hidden;\n}\n.wj-divider {\n display: flex;\n position: absolute;\n align-items: center;\n justify-content: center;\n z-index: 1;\n background-color: var(--wj-img-compare-divider-background);\n height: 100%;\n width: var(--wj-img-compare-divider-size);\n cursor: col-resize;\n top: 0;\n left: var(--wj-img-compare-divider-left);\n}\n.wj-divider:after {\n display: flex;\n content: "";\n position: absolute;\n height: 100%;\n left: calc(var(--wj-img-compare-divider-area) / -2 + var(--wj-img-compare-divider-size) / 2);\n width: var(---wj-img-compare-divider-area);\n}\n.wj-divider wj-icon {\n position: absolute;\n background-color: white;\n padding: 0.5rem;\n color: var(--wj-color);\n border-radius: 50%;\n width: 20px;\n height: 20px;\n box-shadow: rgba(82, 63, 105, 0.2) 0px 0px 30px 10px;\n}';
35
- class ImgComparer extends WJElement {
16
+ const g = `/*!
17
+ * direction.scss
18
+ */:host{--wj-img-compare-divider-area: 12px;--wj-img-compare-divider-background: white;--wj-img-compare-divider-size: 2px;--wj-img-compare-divider-left: 50%;--wj-img-compare-position: 50%;--wj-img-compare-clip-path: inset(0 calc(100% - var(--wj-img-compare-position)) 0 0);display:inline-block;position:relative;width:100%;border-color:var(--wj-border-color);border-style:solid;border-width:1px}.wj-before,.wj-after{display:block}.wj-after{position:absolute;top:0;left:0;height:100%;width:100%;clip-path:var(--wj-img-compare-clip-path)}.native-split-view{max-width:100%;max-height:100%;overflow:hidden}.wj-divider{display:flex;position:absolute;align-items:center;justify-content:center;z-index:1;background-color:var(--wj-img-compare-divider-background);height:100%;width:var(--wj-img-compare-divider-size);cursor:col-resize;top:0;left:var(--wj-img-compare-divider-left)}.wj-divider:after{display:flex;content:"";position:absolute;height:100%;left:calc(var(--wj-img-compare-divider-area) / -2 + var(--wj-img-compare-divider-size) / 2);width:var(---wj-img-compare-divider-area)}.wj-divider wj-icon{position:absolute;background-color:#fff;padding:.5rem;color:var(--wj-color);border-radius:50%;width:20px;height:20px;box-shadow:#523f6933 0 0 30px 10px}
19
+ `;
20
+ class j extends u {
36
21
  constructor() {
37
22
  super();
38
- __publicField(this, "className", "ImgComparer");
39
- __publicField(this, "handleDrag", (e) => {
40
- const { width } = this.native.getBoundingClientRect();
41
- drag(this, {
42
- onMove: (x) => {
43
- let value = x / width * 100;
44
- this.position = parseFloat(this.clamp(value, 0, 100).toFixed(2));
45
- this.native.style.setProperty("--wj-img-compare-divider-left", this.position + "%");
46
- this.native.style.setProperty("--wj-img-compare-clip-path", `inset(0 ${100 - this.position}% 0 0)`);
23
+ p(this, "className", "ImgComparer");
24
+ p(this, "handleDrag", (t) => {
25
+ const { width: a } = this.native.getBoundingClientRect();
26
+ f(this, {
27
+ onMove: (o) => {
28
+ let d = o / a * 100;
29
+ this.position = parseFloat(this.clamp(d, 0, 100).toFixed(2)), this.native.style.setProperty("--wj-img-compare-divider-left", this.position + "%"), this.native.style.setProperty("--wj-img-compare-clip-path", `inset(0 ${100 - this.position}% 0 0)`);
47
30
  },
48
- initialEvent: e
31
+ initialEvent: t
49
32
  });
50
33
  });
51
- __publicField(this, "clamp", (num, min, max) => Math.min(Math.max(num, min), max));
34
+ p(this, "clamp", (t, a, o) => Math.min(Math.max(t, a), o));
52
35
  }
53
36
  static get cssStyleSheet() {
54
- return styles;
37
+ return g;
55
38
  }
56
39
  static get observedAttributes() {
57
40
  return [];
@@ -59,36 +42,24 @@ class ImgComparer extends WJElement {
59
42
  setupAttributes() {
60
43
  this.isShadowRoot = "open";
61
44
  }
62
- draw(context, store, params) {
63
- let fragment = document.createDocumentFragment();
64
- let native = document.createElement("div");
65
- native.classList.add("native-split-view");
66
- let beforeElement = document.createElement("div");
67
- beforeElement.classList.add("wj-before");
68
- let before = document.createElement("slot");
69
- before.setAttribute("name", "before");
70
- let afterElement = document.createElement("div");
71
- afterElement.classList.add("wj-after");
72
- let after = document.createElement("slot");
73
- after.setAttribute("name", "after");
74
- let icon = document.createElement("wj-icon");
75
- icon.setAttribute("name", "arrows-left-right");
76
- let dividerElement = document.createElement("div");
77
- dividerElement.classList.add("wj-divider");
78
- dividerElement.setAttribute("part", "divider");
79
- dividerElement.addEventListener("mousedown", this.handleDrag, false);
80
- beforeElement.appendChild(before);
81
- afterElement.appendChild(after);
82
- dividerElement.appendChild(icon);
83
- native.appendChild(beforeElement);
84
- native.appendChild(afterElement);
85
- native.appendChild(dividerElement);
86
- fragment.appendChild(native);
87
- this.native = native;
88
- return fragment;
45
+ draw(t, a, o) {
46
+ let d = document.createDocumentFragment(), r = document.createElement("div");
47
+ r.classList.add("native-split-view");
48
+ let n = document.createElement("div");
49
+ n.classList.add("wj-before");
50
+ let l = document.createElement("slot");
51
+ l.setAttribute("name", "before");
52
+ let s = document.createElement("div");
53
+ s.classList.add("wj-after");
54
+ let m = document.createElement("slot");
55
+ m.setAttribute("name", "after");
56
+ let v = document.createElement("wj-icon");
57
+ v.setAttribute("name", "arrows-left-right");
58
+ let c = document.createElement("div");
59
+ return c.classList.add("wj-divider"), c.setAttribute("part", "divider"), c.addEventListener("mousedown", this.handleDrag, !1), n.appendChild(l), s.appendChild(m), c.appendChild(v), r.appendChild(n), r.appendChild(s), r.appendChild(c), d.appendChild(r), this.native = r, d;
89
60
  }
90
61
  }
91
- customElements.get("wj-img-comparer") || window.customElements.define("wj-img-comparer", ImgComparer);
62
+ customElements.get("wj-img-comparer") || window.customElements.define("wj-img-comparer", j);
92
63
  export {
93
- ImgComparer
64
+ j as ImgComparer
94
65
  };
package/dist/wj-img.js CHANGED
@@ -1,47 +1,37 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement from "./wj-element.js";
1
+ var c = Object.defineProperty;
2
+ var l = (i, e, t) => e in i ? c(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var o = (i, e, t) => (l(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import g from "./wj-element.js";
8
5
  import "./wj-store.js";
9
- const styles = "/*!\n* direction.scss\n*/\n/* Skeleton Variables */\nimg {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: inherit;\n object-position: inherit;\n}";
10
- class Img extends WJElement {
6
+ const d = `/*!
7
+ * direction.scss
8
+ */img{display:block;width:100%;height:100%;object-fit:inherit;object-position:inherit}
9
+ `;
10
+ class h extends g {
11
11
  constructor() {
12
12
  super();
13
- __publicField(this, "className", "Img");
13
+ o(this, "className", "Img");
14
14
  }
15
15
  static get cssStyleSheet() {
16
- return styles;
16
+ return d;
17
17
  }
18
18
  setupAttributes() {
19
19
  this.isShadowRoot = "open";
20
20
  }
21
- draw(context, store, params) {
22
- let fragment = document.createDocumentFragment();
23
- let img = document.createElement("img");
24
- img.setAttribute("src", "./demo/assets/img/image-loader.gif");
25
- img.classList.add("lazy-loaded-image", "lazy");
26
- img.setAttribute("alt", this.alt || "");
27
- this.img = img;
28
- fragment.appendChild(img);
29
- return fragment;
21
+ draw(t, m, n) {
22
+ let r = document.createDocumentFragment(), s = document.createElement("img");
23
+ return s.setAttribute("src", "./demo/assets/img/image-loader.gif"), s.classList.add("lazy-loaded-image", "lazy"), s.setAttribute("alt", this.alt || ""), this.img = s, r.appendChild(s), r;
30
24
  }
31
- afterDraw(context, store, params) {
32
- let lazyImageObserver = new IntersectionObserver((entries, observer) => {
33
- entries.forEach((entry) => {
34
- if (entry.isIntersecting) {
35
- entry.target.src = this.src;
36
- this.classList.remove("lazy");
37
- lazyImageObserver.unobserve(entry.target);
38
- }
25
+ afterDraw(t, m, n) {
26
+ let r = new IntersectionObserver((s, u) => {
27
+ s.forEach((a) => {
28
+ a.isIntersecting && (a.target.src = this.src, this.classList.remove("lazy"), r.unobserve(a.target));
39
29
  });
40
30
  });
41
- lazyImageObserver.observe(this.img);
31
+ r.observe(this.img);
42
32
  }
43
33
  }
44
- customElements.get("wj-img") || window.customElements.define("wj-img", Img);
34
+ customElements.get("wj-img") || window.customElements.define("wj-img", h);
45
35
  export {
46
- Img
36
+ h as Img
47
37
  };
@@ -1,46 +1,37 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- import WJElement from "./wj-element.js";
1
+ var d = Object.defineProperty;
2
+ var u = (a, r, t) => r in a ? d(a, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[r] = t;
3
+ var h = (a, r, t) => (u(a, typeof r != "symbol" ? r + "" : r, t), t);
4
+ import g from "./wj-element.js";
8
5
  import "./wj-store.js";
9
- const styles = "/*!\n* direction.scss\n*/\n/* Skeleton Variables */\n/*\n[ InfiniteScroll ]\n*/\n:host {\n --wj-infinite-scroll-width: 100%;\n --wj-infinite-scroll-height: 300px;\n overflow-x: auto;\n width: var(--wj-infinite-scroll-width);\n height: var(--wj-infinite-scroll-height);\n display: block;\n}";
10
- class InfiniteScroll extends WJElement {
11
- constructor(options = {}) {
6
+ const m = `/*!
7
+ * direction.scss
8
+ */:host{--wj-infinite-scroll-width: 100%;--wj-infinite-scroll-height: 300px;overflow-x:auto;width:var(--wj-infinite-scroll-width);height:var(--wj-infinite-scroll-height);display:block}
9
+ `;
10
+ class p extends g {
11
+ constructor(t = {}) {
12
12
  super();
13
- __publicField(this, "className", "InfiniteScroll");
14
- __publicField(this, "scrollEvent", () => {
13
+ h(this, "className", "InfiniteScroll");
14
+ h(this, "scrollEvent", () => {
15
15
  this.addEventListener("scroll", this.onScroll);
16
16
  });
17
- __publicField(this, "onScroll", (e) => {
18
- const { scrollTop, scrollHeight, clientHeight } = e.target;
19
- if (scrollTop + clientHeight >= scrollHeight - 300 && this.currentPage <= this.totalPages && this.isLoading.includes(this.currentPage)) {
20
- this.currentPage++;
21
- this.loadPages(this.currentPage);
22
- }
17
+ h(this, "onScroll", (t) => {
18
+ const { scrollTop: s, scrollHeight: e, clientHeight: i } = t.target;
19
+ s + i >= e - 300 && this.currentPage <= this.totalPages && this.isLoading.includes(this.currentPage) && (this.currentPage++, this.loadPages(this.currentPage));
23
20
  });
24
- this.totalPages = 0;
25
- this.isLoading = [];
26
- String.prototype.interpolate = function(params) {
27
- let template = this;
28
- let keys = template.match(/\{{.*?\}}/g);
29
- if (keys) {
30
- for (let key of keys) {
31
- let cleanKey = key.replace("{{", "").replace("}}", "");
32
- let val = "";
33
- cleanKey.split(".").forEach((k) => {
34
- val = val == "" ? params[k] : val[k];
35
- });
36
- template = template.replace(key, val);
21
+ this.totalPages = 0, this.isLoading = [], String.prototype.interpolate = function(s) {
22
+ let e = this, i = e.match(/\{{.*?\}}/g);
23
+ if (i)
24
+ for (let o of i) {
25
+ let l = o.replace("{{", "").replace("}}", ""), n = "";
26
+ l.split(".").forEach((c) => {
27
+ n = n == "" ? s[c] : n[c];
28
+ }), e = e.replace(o, n);
37
29
  }
38
- }
39
- return template;
30
+ return e;
40
31
  };
41
32
  }
42
33
  static get cssStyleSheet() {
43
- return styles;
34
+ return m;
44
35
  }
45
36
  static get observedAttributes() {
46
37
  return [];
@@ -48,39 +39,26 @@ class InfiniteScroll extends WJElement {
48
39
  setupAttributes() {
49
40
  this.isShadowRoot = "open";
50
41
  }
51
- beforeDraw(context, store, params) {
52
- this.iterate = this.querySelector("[iterate]");
53
- this.infiniteScrollTemplate = this.iterate.outerHTML;
54
- this.iterate.remove();
55
- this.setAttribute("style", "height: " + this.height);
42
+ beforeDraw(t, s, e) {
43
+ this.iterate = this.querySelector("[iterate]"), this.infiniteScrollTemplate = this.iterate.outerHTML, this.iterate.remove(), this.setAttribute("style", "height: " + this.height);
56
44
  }
57
- draw(context, store, params) {
58
- let fragment = document.createDocumentFragment();
59
- let slot = document.createElement("slot");
60
- let loader = document.createElement("div");
61
- loader.classList.add("loader");
62
- fragment.appendChild(loader);
63
- fragment.appendChild(slot);
64
- this.loaderEl = loader;
65
- return fragment;
45
+ draw(t, s, e) {
46
+ let i = document.createDocumentFragment(), o = document.createElement("slot"), l = document.createElement("div");
47
+ return l.classList.add("loader"), i.appendChild(l), i.appendChild(o), this.loaderEl = l, i;
66
48
  }
67
49
  async afterDraw() {
68
- this.queryParams = this.queryParams || "";
69
- this.size = +this.size || 10;
70
- this.currentPage = 0;
71
- await this.loadPages(this.currentPage);
50
+ this.queryParams = this.queryParams || "", this.size = +this.size || 10, this.currentPage = 0, await this.loadPages(this.currentPage);
72
51
  }
73
52
  /** @function getPages
74
53
  * @description nacitanie dalsej stranky
75
54
  * @return response json
76
55
  */
77
- async getPages(page) {
78
- let hasParams = this.url.includes("?");
79
- const response = await fetch(`${this.url}${hasParams ? "&" : "?"}page=${page}&size=${this.size}${this == null ? void 0 : this.queryParams}`);
80
- if (!response.ok) {
81
- throw new Error(`An error occurred: ${response.status}`);
82
- }
83
- return await response.json();
56
+ async getPages(t) {
57
+ let s = this.url.includes("?");
58
+ const e = await fetch(`${this.url}${s ? "&" : "?"}page=${t}&size=${this.size}${this == null ? void 0 : this.queryParams}`);
59
+ if (!e.ok)
60
+ throw new Error(`An error occurred: ${e.status}`);
61
+ return await e.json();
84
62
  }
85
63
  hideLoader() {
86
64
  this.loaderEl.classList.remove("show");
@@ -88,43 +66,30 @@ class InfiniteScroll extends WJElement {
88
66
  showLoader() {
89
67
  this.loaderEl.classList.add("show");
90
68
  }
91
- hasMorePages(page) {
92
- return this.totalPages === 0 || page <= this.totalPages;
69
+ hasMorePages(t) {
70
+ return this.totalPages === 0 || t <= this.totalPages;
93
71
  }
94
72
  /** @function getPages
95
73
  * @description methoda zavola getPages a nasledne sa vykona callback funkcia draw. Ako a kde sa nieco vykresli sa deje v inicializacii lib-ky
96
74
  * @return response json
97
75
  */
98
- async loadPages(page) {
76
+ async loadPages(t) {
99
77
  this.showLoader();
100
78
  try {
101
- if (this.hasMorePages(page)) {
102
- let result;
103
- let response;
104
- if (typeof this.setCustomData === "function") {
105
- response = await this.setCustomData(page);
106
- } else {
107
- response = await this.getPages(page);
108
- }
109
- this.totalPages = response.totalPages;
110
- this.currentPage = page;
111
- result = response.data.map((item) => {
112
- return this.infiniteScrollTemplate.interpolate(item);
113
- });
114
- let placement = this;
115
- if (this.hasAttribute("placement"))
116
- placement = this.querySelector(this.placement);
117
- placement.insertAdjacentHTML("beforeend", result.join(""));
118
- this.isLoading.push(page);
79
+ if (this.hasMorePages(t)) {
80
+ let s, e;
81
+ typeof this.setCustomData == "function" ? e = await this.setCustomData(t) : e = await this.getPages(t), this.totalPages = e.totalPages, this.currentPage = t, s = e.data.map((o) => this.infiniteScrollTemplate.interpolate(o));
82
+ let i = this;
83
+ this.hasAttribute("placement") && (i = this.querySelector(this.placement)), i.insertAdjacentHTML("beforeend", s.join("")), this.isLoading.push(t);
119
84
  }
120
- } catch (error) {
121
- console.log(error.message);
85
+ } catch (s) {
86
+ console.log(s.message);
122
87
  } finally {
123
88
  this.hideLoader();
124
89
  }
125
90
  }
126
91
  }
127
- customElements.get("wj-infinite-scroll") || window.customElements.define("wj-infinite-scroll", InfiniteScroll);
92
+ customElements.get("wj-infinite-scroll") || window.customElements.define("wj-infinite-scroll", p);
128
93
  export {
129
- InfiniteScroll
94
+ p as InfiniteScroll
130
95
  };