wj-elements 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/router-links-e0087f84.js +146 -0
- package/dist/style.css +2 -2365
- package/dist/wj-aside.js +18 -22
- package/dist/wj-avatar.js +32 -49
- package/dist/wj-badge.js +18 -22
- package/dist/wj-breadcrumb.js +53 -103
- package/dist/wj-breadcrumbs.js +21 -36
- package/dist/wj-button-group.js +24 -36
- package/dist/wj-button.js +37 -80
- package/dist/wj-card-content.js +16 -18
- package/dist/wj-card-controls.js +16 -18
- package/dist/wj-card-header.js +16 -20
- package/dist/wj-card-subtitle.js +17 -19
- package/dist/wj-card-title.js +16 -18
- package/dist/wj-card.js +16 -20
- package/dist/wj-checkbox.js +24 -46
- package/dist/wj-chip.js +21 -39
- package/dist/wj-col.js +18 -32
- package/dist/wj-color-picker.js +503 -868
- package/dist/wj-container.js +18 -20
- package/dist/wj-copy-button.js +66 -112
- package/dist/wj-dialog.js +43 -67
- package/dist/wj-divider.js +16 -20
- package/dist/wj-dropdown.js +22 -31
- package/dist/wj-element.js +241 -416
- package/dist/wj-footer.js +16 -18
- package/dist/wj-form.js +16 -18
- package/dist/wj-grid.js +17 -21
- package/dist/wj-header.js +18 -22
- package/dist/wj-icon-picker.js +66 -107
- package/dist/wj-icon.js +67 -142
- package/dist/wj-img-comparer.js +43 -72
- package/dist/wj-img.js +21 -31
- package/dist/wj-infinite-scroll.js +49 -84
- package/dist/wj-input.js +67 -146
- package/dist/wj-item.js +19 -34
- package/dist/wj-label.js +19 -21
- package/dist/wj-list.js +17 -20
- package/dist/wj-main.js +16 -18
- package/dist/wj-master.js +331 -462
- package/dist/wj-menu-button.js +18 -21
- package/dist/wj-menu-item.js +67 -144
- package/dist/wj-menu-label.js +17 -21
- package/dist/wj-menu.js +20 -24
- package/dist/wj-popup.js +714 -1140
- package/dist/wj-progress-bar.js +42 -100
- package/dist/wj-radio-group.js +27 -38
- package/dist/wj-radio.js +24 -46
- package/dist/wj-route.js +8 -11
- package/dist/wj-router-link.js +19 -22
- package/dist/wj-router-outlet.js +71 -135
- package/dist/wj-routerx.js +641 -1121
- package/dist/wj-row.js +20 -22
- package/dist/wj-slider.js +55 -97
- package/dist/wj-split-view.js +45 -81
- package/dist/wj-store.js +110 -195
- package/dist/wj-textarea.js +39 -86
- package/dist/wj-thumbnail.js +17 -19
- package/dist/wj-toast.js +34 -88
- package/dist/wj-toggle.js +24 -42
- package/dist/wj-toolbar-action.js +16 -27
- package/dist/wj-toolbar.js +21 -26
- package/dist/wj-tooltip.js +27 -41
- package/dist/wj-visually-hidden.js +16 -18
- package/package.json +1 -1
- package/dist/router-links-26e4a166.js +0 -204
package/dist/wj-icon.js
CHANGED
|
@@ -1,127 +1,67 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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:", `/assets/img/icons/svg/${t}.svg`);
|
|
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
|
-
|
|
61
|
+
l(this, "className", "Icon");
|
|
122
62
|
}
|
|
123
63
|
static get cssStyleSheet() {
|
|
124
|
-
return
|
|
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(
|
|
133
|
-
let
|
|
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
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
84
|
+
o.observe(this.element);
|
|
160
85
|
}
|
|
161
86
|
}
|
|
162
|
-
customElements.get("wj-icon") || window.customElements.define("wj-icon",
|
|
87
|
+
customElements.get("wj-icon") || window.customElements.define("wj-icon", S);
|
|
163
88
|
export {
|
|
164
|
-
Icon
|
|
89
|
+
S as Icon
|
|
165
90
|
};
|
package/dist/wj-img-comparer.js
CHANGED
|
@@ -1,57 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
|
35
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
const { width } = this.native.getBoundingClientRect();
|
|
41
|
-
|
|
42
|
-
onMove: (
|
|
43
|
-
let
|
|
44
|
-
this.position = parseFloat(this.clamp(
|
|
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:
|
|
31
|
+
initialEvent: t
|
|
49
32
|
});
|
|
50
33
|
});
|
|
51
|
-
|
|
34
|
+
p(this, "clamp", (t, a, o) => Math.min(Math.max(t, a), o));
|
|
52
35
|
}
|
|
53
36
|
static get cssStyleSheet() {
|
|
54
|
-
return
|
|
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(
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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",
|
|
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
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
|
10
|
-
|
|
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
|
-
|
|
13
|
+
o(this, "className", "Img");
|
|
14
14
|
}
|
|
15
15
|
static get cssStyleSheet() {
|
|
16
|
-
return
|
|
16
|
+
return d;
|
|
17
17
|
}
|
|
18
18
|
setupAttributes() {
|
|
19
19
|
this.isShadowRoot = "open";
|
|
20
20
|
}
|
|
21
|
-
draw(
|
|
22
|
-
let
|
|
23
|
-
|
|
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(
|
|
32
|
-
let
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
31
|
+
r.observe(this.img);
|
|
42
32
|
}
|
|
43
33
|
}
|
|
44
|
-
customElements.get("wj-img") || window.customElements.define("wj-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
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
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
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
13
|
+
h(this, "className", "InfiniteScroll");
|
|
14
|
+
h(this, "scrollEvent", () => {
|
|
15
15
|
this.addEventListener("scroll", this.onScroll);
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
const { scrollTop, scrollHeight, clientHeight } =
|
|
19
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
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(
|
|
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(
|
|
58
|
-
let
|
|
59
|
-
|
|
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(
|
|
78
|
-
let
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
throw new Error(`An error occurred: ${
|
|
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(
|
|
92
|
-
return this.totalPages === 0 ||
|
|
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(
|
|
76
|
+
async loadPages(t) {
|
|
99
77
|
this.showLoader();
|
|
100
78
|
try {
|
|
101
|
-
if (this.hasMorePages(
|
|
102
|
-
let
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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 (
|
|
121
|
-
console.log(
|
|
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",
|
|
92
|
+
customElements.get("wj-infinite-scroll") || window.customElements.define("wj-infinite-scroll", p);
|
|
128
93
|
export {
|
|
129
|
-
InfiniteScroll
|
|
94
|
+
p as InfiniteScroll
|
|
130
95
|
};
|