wj-elements 0.1.48 → 0.1.49
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/custom-elements.json +14058 -0
- package/dist/dark.css +1 -0
- package/dist/light.css +1 -0
- package/dist/localize.js +45 -0
- package/dist/popup.element-CWsSOxs2.js +1072 -0
- package/dist/router-links-FtZbFUto.js +146 -0
- package/dist/styles.css +1 -0
- package/dist/web-types.json +3122 -0
- package/dist/wje-accordion-item.js +88 -0
- package/dist/wje-accordion.js +79 -0
- package/dist/wje-animation.js +121 -0
- package/dist/wje-aside.js +55 -0
- package/dist/wje-avatar.js +77 -0
- package/dist/wje-badge.js +50 -0
- package/dist/wje-breadcrumb.js +148 -0
- package/dist/wje-breadcrumbs.js +67 -0
- package/dist/wje-button-group.js +78 -0
- package/dist/wje-button.js +207 -0
- package/dist/wje-card-content.js +48 -0
- package/dist/wje-card-controls.js +48 -0
- package/dist/wje-card-header.js +47 -0
- package/dist/wje-card-subtitle.js +55 -0
- package/dist/wje-card-title.js +55 -0
- package/dist/wje-card.js +50 -0
- package/dist/wje-carousel-item.js +33 -0
- package/dist/wje-carousel.js +177 -0
- package/dist/wje-checkbox.js +96 -0
- package/dist/wje-chip.js +32 -0
- package/dist/wje-col.js +27 -0
- package/dist/wje-color-picker.js +953 -0
- package/dist/wje-container.js +57 -0
- package/dist/wje-copy-button.js +170 -0
- package/dist/wje-dialog.js +86 -0
- package/dist/wje-divider.js +53 -0
- package/dist/wje-dropdown.js +114 -0
- package/dist/wje-element.js +453 -0
- package/dist/wje-fetchAndParseCSS.js +40 -0
- package/dist/wje-file-upload-item.js +115 -0
- package/dist/wje-file-upload.js +297 -0
- package/dist/wje-footer.js +56 -0
- package/dist/wje-form.js +28 -0
- package/dist/wje-format-digital.js +85 -0
- package/dist/wje-grid.js +28 -0
- package/dist/wje-header.js +58 -0
- package/dist/wje-icon-picker.js +221 -0
- package/dist/wje-icon.js +119 -0
- package/dist/wje-img-comparer.js +111 -0
- package/dist/wje-img.js +58 -0
- package/dist/wje-infinite-scroll.js +201 -0
- package/dist/wje-inline-edit.js +145 -0
- package/dist/wje-input-file.js +85 -0
- package/dist/wje-input.js +334 -0
- package/dist/wje-item.js +45 -0
- package/dist/wje-label.js +67 -0
- package/dist/wje-list.js +53 -0
- package/dist/wje-main.js +56 -0
- package/dist/wje-masonry.js +218 -0
- package/dist/wje-master.js +423 -0
- package/dist/wje-menu-button.js +65 -0
- package/dist/wje-menu-item.js +230 -0
- package/dist/wje-menu-label.js +57 -0
- package/dist/wje-menu.js +74 -0
- package/dist/wje-option.js +99 -0
- package/dist/wje-options.js +63 -0
- package/dist/wje-popup.js +5 -0
- package/dist/wje-progress-bar.js +161 -0
- package/dist/wje-qr-code.js +2332 -0
- package/dist/wje-radio-group.js +101 -0
- package/dist/wje-radio.js +46 -0
- package/dist/wje-rate.js +260 -0
- package/dist/wje-relative-time.js +85 -0
- package/dist/wje-reorder-dropzone.js +27 -0
- package/dist/wje-reorder-handle.js +115 -0
- package/dist/wje-reorder-item.js +32 -0
- package/dist/wje-reorder.js +138 -0
- package/dist/wje-route.js +46 -0
- package/dist/wje-router-link.js +64 -0
- package/dist/wje-router-outlet.js +127 -0
- package/dist/wje-routerx.js +1088 -0
- package/dist/wje-row.js +58 -0
- package/dist/wje-select.js +242 -0
- package/dist/wje-slider.js +177 -0
- package/dist/wje-sliding-container.js +277 -0
- package/dist/wje-split-view.js +112 -0
- package/dist/wje-status.js +54 -0
- package/dist/wje-store.js +192 -0
- package/dist/wje-tab-group.js +107 -0
- package/dist/wje-tab-panel.js +52 -0
- package/dist/wje-tab.js +59 -0
- package/dist/wje-textarea.js +116 -0
- package/dist/wje-thumbnail.js +64 -0
- package/dist/wje-toast.js +76 -0
- package/dist/wje-toggle.js +94 -0
- package/dist/wje-toolbar-action.js +63 -0
- package/dist/wje-toolbar.js +61 -0
- package/dist/wje-tooltip.js +116 -0
- package/dist/wje-visually-hidden.js +56 -0
- package/package.json +1 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var g = (l, o, e) => o in l ? w(l, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[o] = e;
|
|
3
|
+
var p = (l, o, e) => (g(l, typeof o != "symbol" ? o + "" : o, e), e);
|
|
4
|
+
import b, { event as j } from "./wje-element.js";
|
|
5
|
+
import u from "./wje-infinite-scroll.js";
|
|
6
|
+
import v from "./wje-input.js";
|
|
7
|
+
import f from "./wje-tooltip.js";
|
|
8
|
+
import "./wje-popup.js";
|
|
9
|
+
import { P as k } from "./popup.element-CWsSOxs2.js";
|
|
10
|
+
const x = ":host{--wje-icon-picker-radius: var(--wje-border-radius-small);--wje-icon-picker-icon-size: 1.5rem;--wje-icon-picker-border-width: 1px;--wje-icon-picker-border-style: solid;--wje-icon-picker-border-color: var(--wje-border-color);--wje-icon-picker-padding: .25rem;padding:0 1rem}.anchor{width:var(--wje-icon-picker-icon-size);height:var(--wje-icon-picker-icon-size);padding:var(--wje-icon-picker-padding);border-width:var(--wje-icon-picker-border-width);border-style:var(--wje-icon-picker-border-style);border-color:var(--wje-icon-picker-border-color);box-sizing:border-box;border-radius:var(--wje-icon-picker-radius)}.picker{width:320px;height:271px;box-shadow:0 0 5px #0000000d,0 5px 20px #0000001a;border-radius:var(--wje-icon-picker-radius);border-width:var(--wje-icon-picker-border-width);border-style:var(--wje-icon-picker-border-style);border-color:var(--wje-icon-picker-border-color);overflow:auto;padding:1rem;background:var(--wje-background)}.icon-items{--icon-min-width: 2rem;display:grid;grid-gap:.5rem;grid-template-columns:repeat(auto-fit,minmax(var(--icon-min-width),1fr))}.icon-item{box-sizing:border-box;display:flex;align-items:center;justify-content:center;text-align:center;color:inherit;padding:.25rem;min-height:var(--wje-icon-picker-icon-size);min-width:var(--wje-icon-picker-icon-size);text-decoration:none}.icon-item:hover{border-radius:.25rem;background:var(--wje-border-color)}.wje-size{--wje-icon-size: 24px !important}icon-item svg{width:var(--wje-icon-picker-icon-size);height:var(--wje-icon-picker-icon-size)}wje-input{--wje-input-border-radius: 4px;--wje-input-margin-bottom: 0}wje-infinite-scroll{margin-top:1rem}wje-select{--wje-select-border-width: 0 0 1px 0 !important;--wje-select-border-radius: 0 !important;margin-bottom:1rem}.anchor wje-icon{--wje-icon-size: 100% !important}";
|
|
11
|
+
class m extends b {
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of IconPicker.
|
|
14
|
+
*
|
|
15
|
+
* @constructor
|
|
16
|
+
*/
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
/**
|
|
20
|
+
* Dependencies of the IconPicker component.
|
|
21
|
+
*
|
|
22
|
+
* @property {Object} depandencies
|
|
23
|
+
*/
|
|
24
|
+
p(this, "depandencies", {
|
|
25
|
+
"wje-input": v,
|
|
26
|
+
"wje-infinite-scroll": u,
|
|
27
|
+
"wje-tooltip": f,
|
|
28
|
+
"wje-popup": k
|
|
29
|
+
});
|
|
30
|
+
p(this, "className", "IconPicker");
|
|
31
|
+
/**
|
|
32
|
+
* Event handler for searching icons.
|
|
33
|
+
*
|
|
34
|
+
* @param {Event} e - The event.
|
|
35
|
+
*/
|
|
36
|
+
p(this, "searchIcon", (e) => {
|
|
37
|
+
this.infiniteScroll.unScrollEvent(), this.infiniteScroll.setCustomData = (i = 0) => {
|
|
38
|
+
let t = this.tags.filter((n) => n.tags.includes(e.detail.value));
|
|
39
|
+
return {
|
|
40
|
+
data: t,
|
|
41
|
+
page: i,
|
|
42
|
+
size: this.size,
|
|
43
|
+
totalPages: Math.round(t.length / this.size)
|
|
44
|
+
};
|
|
45
|
+
}, this.clearIconsContainer(), this.infiniteScroll.loadPages();
|
|
46
|
+
});
|
|
47
|
+
/**
|
|
48
|
+
* Closes the component.
|
|
49
|
+
*/
|
|
50
|
+
p(this, "onClose", () => {
|
|
51
|
+
this.popup.onHide();
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Gets the URL of the tags.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} path - The path to get the URL of.
|
|
57
|
+
* @returns {string} The URL of the tags.
|
|
58
|
+
*/
|
|
59
|
+
p(this, "getTagsUrl", (e) => {
|
|
60
|
+
let i = new URL(import.meta.url), t = i.pathname, r = t.substring(0, t.lastIndexOf("/"));
|
|
61
|
+
return new URL(i.origin + r + e).href;
|
|
62
|
+
});
|
|
63
|
+
this.size = 48;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Setter for the markerPosition property.
|
|
67
|
+
*
|
|
68
|
+
* @param {any} value - The value to set.
|
|
69
|
+
*/
|
|
70
|
+
set markerPosition(e) {
|
|
71
|
+
this._markerPosition = e;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Getter for the markerPosition property.
|
|
75
|
+
*
|
|
76
|
+
* @returns {any} The value of the markerPosition property.
|
|
77
|
+
*/
|
|
78
|
+
get markerPosition() {
|
|
79
|
+
return this._markerPosition;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Setter for the swatches property.
|
|
83
|
+
*
|
|
84
|
+
* @param {any} value - The value to set.
|
|
85
|
+
*/
|
|
86
|
+
set swatches(e) {
|
|
87
|
+
this.setAttribute("swatches", e.split(","));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Getter for the swatches property.
|
|
91
|
+
*
|
|
92
|
+
* @returns {any} The value of the swatches property.
|
|
93
|
+
*/
|
|
94
|
+
get swatches() {
|
|
95
|
+
return this._swatches;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the CSS styles for the component.
|
|
99
|
+
*
|
|
100
|
+
* @static
|
|
101
|
+
* @returns {CSSStyleSheet}
|
|
102
|
+
*/
|
|
103
|
+
static get cssStyleSheet() {
|
|
104
|
+
return x;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Returns the list of attributes to observe for changes.
|
|
108
|
+
*
|
|
109
|
+
* @static
|
|
110
|
+
* @returns {Array<string>}
|
|
111
|
+
*/
|
|
112
|
+
static get observedAttributes() {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Sets up the attributes for the component.
|
|
117
|
+
*/
|
|
118
|
+
setupAttributes() {
|
|
119
|
+
this.isShadowRoot = "open";
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Prepares the component before drawing.
|
|
123
|
+
*/
|
|
124
|
+
async beforeDraw() {
|
|
125
|
+
this.tags = Object.values(await this.getTags()), this.category = this.getCategory(this.tags);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Draws the component.
|
|
129
|
+
*
|
|
130
|
+
* @param {Object} context - The context for drawing.
|
|
131
|
+
* @param {Object} store - The store for drawing.
|
|
132
|
+
* @param {Object} params - The parameters for drawing.
|
|
133
|
+
* @returns {DocumentFragment}
|
|
134
|
+
*/
|
|
135
|
+
draw(e, i, t) {
|
|
136
|
+
let r = document.createDocumentFragment(), n = document.createElement("div");
|
|
137
|
+
n.classList.add("native-color-picker");
|
|
138
|
+
let d = document.createElement("div");
|
|
139
|
+
d.setAttribute("slot", "anchor"), d.classList.add("anchor");
|
|
140
|
+
let h = document.createElement("div");
|
|
141
|
+
h.classList.add("picker");
|
|
142
|
+
let s = document.createElement("wje-input");
|
|
143
|
+
s.classList.add("input"), s.setAttribute("variant", "standard"), s.setAttribute("placeholder", "type to filter..."), s.setAttribute("clearable", ""), s.addEventListener("wje-input:input", this.searchIcon);
|
|
144
|
+
let a = new u();
|
|
145
|
+
a.setAttribute("url", this.getTagsUrl("/assets/tags.json")), a.setAttribute("placement", ".icon-items"), a.setAttribute("size", this.size), a.setAttribute("height", "223px"), a.innerHTML = `<div class="icon-items">
|
|
146
|
+
<div class="icon-item" iterate>
|
|
147
|
+
<wje-tooltip content="{{name}}">
|
|
148
|
+
<wje-icon name="{{name}}" size="large"></wje-icon>
|
|
149
|
+
</wje-tooltip>
|
|
150
|
+
</div>
|
|
151
|
+
</div>`, h.appendChild(s), h.appendChild(a);
|
|
152
|
+
let c = document.createElement("wje-popup");
|
|
153
|
+
return c.setAttribute("placement", this.placement || "bottom-start"), c.setAttribute("offset", this.offset), c.setAttribute("manual", ""), c.appendChild(d), c.appendChild(h), n.appendChild(c), r.appendChild(n), this.popup = c, this.input = s, this.anchor = d, this.picker = h, this.infiniteScroll = a, r;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Called after the component has been drawn.
|
|
157
|
+
*/
|
|
158
|
+
afterDraw() {
|
|
159
|
+
this.setupInfiniteScroll(), this.addEventListener("wje-popup:show", (e) => {
|
|
160
|
+
this.initial();
|
|
161
|
+
}), this.addEventListener("wje-input:clear", (e) => {
|
|
162
|
+
this.setupInfiniteScroll(), this.clearIconsContainer(), this.infiniteScroll.scrollEvent(), this.infiniteScroll.loadPages(0);
|
|
163
|
+
}), this.addEventListener("wje-infinite-scroll:click-item", (e) => {
|
|
164
|
+
const t = e.detail.context.querySelector("wje-icon").getAttribute("name"), r = this.tags.find((d) => d.name === t), n = document.createElement("wje-icon");
|
|
165
|
+
n.setAttribute("name", t), r.icon = n, this.value = r, this.anchor.innerHTML = "", this.anchor.appendChild(n), j.dispatchCustomEvent(this, "wje-icon-picker:select", r);
|
|
166
|
+
}), this.init = !1;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Initializes the component.
|
|
170
|
+
*/
|
|
171
|
+
initial() {
|
|
172
|
+
this.infiniteScroll.scrollEvent();
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Sets up the infinite scroll for the component.
|
|
176
|
+
*/
|
|
177
|
+
setupInfiniteScroll() {
|
|
178
|
+
this.infiniteScroll.setCustomData = (e = 0) => {
|
|
179
|
+
let i = Object.values(this.tags);
|
|
180
|
+
return {
|
|
181
|
+
data: i.slice(e * this.size, e * this.size + this.size),
|
|
182
|
+
page: e,
|
|
183
|
+
size: this.size,
|
|
184
|
+
totalPages: Math.round(i.length / this.size)
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Gets the category of the tags.
|
|
190
|
+
*
|
|
191
|
+
* @param {Array} tags - The tags to get the category of.
|
|
192
|
+
* @returns {Array} The category of the tags.
|
|
193
|
+
*/
|
|
194
|
+
getCategory(e) {
|
|
195
|
+
return [...new Set(e.map((t) => t.category))];
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Gets the tags.
|
|
199
|
+
*
|
|
200
|
+
* @returns {Promise<Array>} The tags.
|
|
201
|
+
*/
|
|
202
|
+
async getTags() {
|
|
203
|
+
return (await fetch(this.getTagsUrl("/assets/tags.json"))).json();
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Called when the component is disconnected.
|
|
207
|
+
*/
|
|
208
|
+
disconnectedCallback() {
|
|
209
|
+
this.init = !1;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Clears the icons container.
|
|
213
|
+
*/
|
|
214
|
+
clearIconsContainer() {
|
|
215
|
+
this.context.querySelector(".icon-items").innerHTML = "";
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
m.define("wje-icon-picker", m);
|
|
219
|
+
export {
|
|
220
|
+
m as default
|
|
221
|
+
};
|
package/dist/wje-icon.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
var g = Object.defineProperty;
|
|
2
|
+
var w = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
|
+
var d = (e, t, s) => (w(e, typeof t != "symbol" ? t + "" : t, s), s);
|
|
4
|
+
import m from "./wje-element.js";
|
|
5
|
+
const n = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
|
|
6
|
+
let l;
|
|
7
|
+
const j = (e) => c(e) && (e = e.trim(), z(e)) ? e : null, z = (e) => e.length > 0 && /(\/|\.)/.test(e), p = (e) => e.startsWith("data:image/svg+xml"), x = (e) => e.indexOf(";utf8,") !== -1, c = (e) => typeof e == "string", b = (e) => {
|
|
8
|
+
const t = document.createElement("div");
|
|
9
|
+
t.innerHTML = e;
|
|
10
|
+
const s = t.firstElementChild;
|
|
11
|
+
return s && s.nodeName.toLowerCase() === "svg" && (s.getAttribute("class"), f(s)) ? t.innerHTML : "";
|
|
12
|
+
}, f = (e) => {
|
|
13
|
+
if (e.nodeType === 1) {
|
|
14
|
+
if (e.nodeName.toLowerCase() === "script")
|
|
15
|
+
return !1;
|
|
16
|
+
for (let t = 0; t < e.attributes.length; t++) {
|
|
17
|
+
const s = e.attributes[t].name;
|
|
18
|
+
if (c(s) && s.toLowerCase().indexOf("on") === 0)
|
|
19
|
+
return !1;
|
|
20
|
+
}
|
|
21
|
+
for (let t = 0; t < e.childNodes.length; t++)
|
|
22
|
+
if (!f(e.childNodes[t]))
|
|
23
|
+
return !1;
|
|
24
|
+
}
|
|
25
|
+
return !0;
|
|
26
|
+
}, y = (e, t) => {
|
|
27
|
+
let s = v.get(e);
|
|
28
|
+
if (!s)
|
|
29
|
+
if (typeof fetch < "u" && typeof document < "u")
|
|
30
|
+
if (p(e) && x(e)) {
|
|
31
|
+
l || (l = new DOMParser());
|
|
32
|
+
const r = l.parseFromString(e, "text/html").querySelector("svg");
|
|
33
|
+
return r && n.set(e, r.outerHTML), Promise.resolve();
|
|
34
|
+
} else
|
|
35
|
+
s = fetch(e).then((o) => {
|
|
36
|
+
if (o.ok)
|
|
37
|
+
return o.text().then((r) => {
|
|
38
|
+
r && t !== !1 && (r = b(r)), n.set(e, r || "");
|
|
39
|
+
});
|
|
40
|
+
n.set(e, "");
|
|
41
|
+
}), v.set(e, s);
|
|
42
|
+
else
|
|
43
|
+
return n.set(e, ""), Promise.resolve();
|
|
44
|
+
return s;
|
|
45
|
+
}, k = (e) => {
|
|
46
|
+
let t = j(e.src);
|
|
47
|
+
return t || (t = L(e.name), t ? S(t, e.hasAttribute("filled")) : null);
|
|
48
|
+
}, L = (e) => !c(e) || e.trim() === "" || e.replace(/[a-z]|-|\d/gi, "") !== "" ? null : e, S = (e, t = !1) => {
|
|
49
|
+
const s = `/assets/img/icons/${t ? "filled" : "outline"}/${e}.svg`;
|
|
50
|
+
let o = new URL(import.meta.url), r = o.pathname, i = r.substring(0, r.lastIndexOf("/"));
|
|
51
|
+
return new URL(o.origin + i + s).href;
|
|
52
|
+
}, E = ':host{width:var(--wje-icon-size);height:var(--wje-icon-size);display:block}.native-icon{display:flex;align-items:center}svg{width:100%;height:100%;stroke-width:var(--wje-icon-stroke);color:var(--wje-icon-color)}:host([stroke="1"]){--wje-icon-stroke: 1}:host([stroke="1.25"]){--wje-icon-stroke: 1.25}:host([stroke="1.5"]){--wje-icon-stroke: 1.5}:host([stroke="1.75"]){--wje-icon-stroke: 1.75}:host([stroke="2"]){--wje-icon-stroke: 2}:host([size="2x-small"]){--wje-icon-size: var(--wje-size-2x-small)}:host([size="x-small"]){--wje-icon-size: var(--wje-size-x-small)}:host([size="small"]){--wje-icon-size: var(--wje-size-small)}:host([size="medium"]){--wje-icon-size: var(--wje-size-medium)}:host([size="large"]){--wje-icon-size: var(--wje-size-large)}:host([size="x-large"]){--wje-icon-size: var(--wje-size-x-large)}:host([size="2x-large"]){--wje-icon-size: var(--wje-size-2x-large)}:host([size="3x-large"]){--wje-icon-size: var(--wje-size-3x-large)}:host([size="4x-large"]){--wje-icon-size: var(--wje-size-4x-large)}:host([color="primary"]) .native-icon{color:var(--wje-color-primary-9)}:host([color="complete"]) .native-icon{color:var(--wje-color-complete-9)}:host([color="success"]) .native-icon{color:var(--wje-color-success-9)}:host([color="warning"]) .native-icon{color:var(--wje-color-warning-9)}:host([color="danger"]) .native-icon{color:var(--wje-color-danger-9)}:host([color="info"]) .native-icon{color:var(--wje-color-info-9)}:host([color="menu"]) .native-icon{color:var(--wje-color-contrast-9)}';
|
|
53
|
+
class u extends m {
|
|
54
|
+
/**
|
|
55
|
+
* Creates an instance of IconElement.
|
|
56
|
+
*
|
|
57
|
+
* @constructor
|
|
58
|
+
*/
|
|
59
|
+
constructor() {
|
|
60
|
+
super();
|
|
61
|
+
d(this, "className", "Icon");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns the CSS styles for the component.
|
|
65
|
+
*
|
|
66
|
+
* @static
|
|
67
|
+
* @returns {CSSStyleSheet}
|
|
68
|
+
*/
|
|
69
|
+
static get cssStyleSheet() {
|
|
70
|
+
return E;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the list of attributes to observe for changes.
|
|
74
|
+
*
|
|
75
|
+
* @static
|
|
76
|
+
* @returns {Array<string>}
|
|
77
|
+
*/
|
|
78
|
+
static get observedAttributes() {
|
|
79
|
+
return ["name"];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sets up the attributes for the component.
|
|
83
|
+
*/
|
|
84
|
+
setupAttributes() {
|
|
85
|
+
this.isShadowRoot = "open";
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Draws the component.
|
|
89
|
+
*
|
|
90
|
+
* @param {Object} context - The context for drawing.
|
|
91
|
+
* @param {Object} store - The store for drawing.
|
|
92
|
+
* @param {Object} params - The parameters for drawing.
|
|
93
|
+
* @returns {DocumentFragment}
|
|
94
|
+
*/
|
|
95
|
+
draw(s, o, r) {
|
|
96
|
+
let i = document.createDocumentFragment();
|
|
97
|
+
this.classList.add("lazy-loaded-image", "lazy");
|
|
98
|
+
let a = document.createElement("div");
|
|
99
|
+
return a.setAttribute("part", "native"), a.classList.add("native-icon"), this.url = k(this), i.appendChild(a), this.native = a, i;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Called after the component has been drawn.
|
|
103
|
+
*/
|
|
104
|
+
afterDraw() {
|
|
105
|
+
let s = new IntersectionObserver((o, r) => {
|
|
106
|
+
o.forEach((i) => {
|
|
107
|
+
i.isIntersecting && (y(this.url).then((a) => {
|
|
108
|
+
var h;
|
|
109
|
+
this.native.innerHTML = n == null ? void 0 : n.get(this.url), (h = this.native.querySelector("svg")) == null || h.setAttribute("part", "svg");
|
|
110
|
+
}), this.classList.remove("lazy"), s.unobserve(i.target));
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
s.observe(this.native);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
u.define("wje-icon", u);
|
|
117
|
+
export {
|
|
118
|
+
u as default
|
|
119
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var f = Object.defineProperty;
|
|
2
|
+
var h = (i, e, t) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
|
+
var c = (i, e, t) => (h(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import w from "./wje-element.js";
|
|
5
|
+
import g from "./wje-icon.js";
|
|
6
|
+
function b(i, e) {
|
|
7
|
+
function t(o) {
|
|
8
|
+
const d = i.getBoundingClientRect(), r = i.ownerDocument.defaultView, n = d.left + r.pageXOffset, m = d.top + r.pageYOffset, s = o.pageX - n, p = o.pageY - m;
|
|
9
|
+
e != null && e.onMove && e.onMove(s, p);
|
|
10
|
+
}
|
|
11
|
+
function a() {
|
|
12
|
+
document.removeEventListener("pointermove", t), document.removeEventListener("pointerup", a), e != null && e.onStop && e.onStop();
|
|
13
|
+
}
|
|
14
|
+
document.addEventListener("pointermove", t, { passive: !0 }), document.addEventListener("pointerup", a), (e == null ? void 0 : e.initialEvent) instanceof PointerEvent && t(e.initialEvent);
|
|
15
|
+
}
|
|
16
|
+
const j = ':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}';
|
|
17
|
+
class u extends w {
|
|
18
|
+
/**
|
|
19
|
+
* Creates an instance of ImgComparer.
|
|
20
|
+
*
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
/**
|
|
26
|
+
* Dependencies of the ImgComparer component.
|
|
27
|
+
*
|
|
28
|
+
* @property {Object} depandencies
|
|
29
|
+
*/
|
|
30
|
+
c(this, "depandencies", {
|
|
31
|
+
"wje-icon": g
|
|
32
|
+
});
|
|
33
|
+
c(this, "className", "ImgComparer");
|
|
34
|
+
/**
|
|
35
|
+
* Handles the drag event.
|
|
36
|
+
*
|
|
37
|
+
* @param {Event} e - The event.
|
|
38
|
+
*/
|
|
39
|
+
c(this, "handleDrag", (t) => {
|
|
40
|
+
const { width: a } = this.native.getBoundingClientRect();
|
|
41
|
+
b(this, {
|
|
42
|
+
onMove: (o) => {
|
|
43
|
+
let d = o / a * 100;
|
|
44
|
+
this.position = parseFloat(this.clamp(d, 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)`);
|
|
45
|
+
},
|
|
46
|
+
initialEvent: t
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Clamps a number between a minimum and maximum value.
|
|
51
|
+
*
|
|
52
|
+
* @param {number} num - The number to clamp.
|
|
53
|
+
* @param {number} min - The minimum value.
|
|
54
|
+
* @param {number} max - The maximum value.
|
|
55
|
+
* @returns {number} The clamped number.
|
|
56
|
+
*/
|
|
57
|
+
c(this, "clamp", (t, a, o) => Math.min(Math.max(t, a), o));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Returns the CSS styles for the component.
|
|
61
|
+
*
|
|
62
|
+
* @static
|
|
63
|
+
* @returns {CSSStyleSheet}
|
|
64
|
+
*/
|
|
65
|
+
static get cssStyleSheet() {
|
|
66
|
+
return j;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Returns the list of attributes to observe for changes.
|
|
70
|
+
*
|
|
71
|
+
* @static
|
|
72
|
+
* @returns {Array<string>}
|
|
73
|
+
*/
|
|
74
|
+
static get observedAttributes() {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sets up the attributes for the component.
|
|
79
|
+
*/
|
|
80
|
+
setupAttributes() {
|
|
81
|
+
this.isShadowRoot = "open";
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Draws the component.
|
|
85
|
+
*
|
|
86
|
+
* @param {Object} context - The context for drawing.
|
|
87
|
+
* @param {Object} store - The store for drawing.
|
|
88
|
+
* @param {Object} params - The parameters for drawing.
|
|
89
|
+
* @returns {DocumentFragment}
|
|
90
|
+
*/
|
|
91
|
+
draw(t, a, o) {
|
|
92
|
+
let d = document.createDocumentFragment(), r = document.createElement("div");
|
|
93
|
+
r.classList.add("native-split-view");
|
|
94
|
+
let n = document.createElement("div");
|
|
95
|
+
n.classList.add("wje-before");
|
|
96
|
+
let m = document.createElement("slot");
|
|
97
|
+
m.setAttribute("name", "before");
|
|
98
|
+
let s = document.createElement("div");
|
|
99
|
+
s.classList.add("wje-after");
|
|
100
|
+
let p = document.createElement("slot");
|
|
101
|
+
p.setAttribute("name", "after");
|
|
102
|
+
let v = document.createElement("wje-icon");
|
|
103
|
+
v.setAttribute("name", "arrow-bar-both");
|
|
104
|
+
let l = document.createElement("div");
|
|
105
|
+
return l.classList.add("wje-divider"), l.setAttribute("part", "divider"), l.addEventListener("mousedown", this.handleDrag, !1), n.appendChild(m), s.appendChild(p), l.appendChild(v), r.appendChild(n), r.appendChild(s), r.appendChild(l), d.appendChild(r), this.native = r, d;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
u.define("wje-img-comparer", u);
|
|
109
|
+
export {
|
|
110
|
+
u as default
|
|
111
|
+
};
|
package/dist/wje-img.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var d = (r, e, t) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var o = (r, e, t) => (d(r, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
+
import n from "./wje-element.js";
|
|
5
|
+
const h = "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)}";
|
|
6
|
+
class m extends n {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Img.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
o(this, "className", "Img");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the CSS styles for the component.
|
|
18
|
+
*
|
|
19
|
+
* @static
|
|
20
|
+
* @returns {CSSStyleSheet}
|
|
21
|
+
*/
|
|
22
|
+
static get cssStyleSheet() {
|
|
23
|
+
return h;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Sets up the attributes for the component.
|
|
27
|
+
*/
|
|
28
|
+
setupAttributes() {
|
|
29
|
+
this.isShadowRoot = "open";
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Draws the component.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} context - The context for drawing.
|
|
35
|
+
* @param {Object} store - The store for drawing.
|
|
36
|
+
* @param {Object} params - The parameters for drawing.
|
|
37
|
+
* @returns {DocumentFragment}
|
|
38
|
+
*/
|
|
39
|
+
draw(t, c, g) {
|
|
40
|
+
let a = document.createDocumentFragment(), s = document.createElement("img");
|
|
41
|
+
return s.setAttribute("src", "./assets/img/image-loader.gif"), s.classList.add("lazy-loaded-image", "lazy"), s.setAttribute("alt", this.alt || ""), this.img = s, a.appendChild(s), a;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Called after the component has been drawn.
|
|
45
|
+
*/
|
|
46
|
+
afterDraw(t, c, g) {
|
|
47
|
+
let a = new IntersectionObserver((s, u) => {
|
|
48
|
+
s.forEach((i) => {
|
|
49
|
+
i.isIntersecting && (i.target.src = this.src, this.classList.remove("lazy"), a.unobserve(i.target));
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
a.observe(this.img);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
m.define("wje-img", m);
|
|
56
|
+
export {
|
|
57
|
+
m as default
|
|
58
|
+
};
|