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.
- 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-element.js
CHANGED
|
@@ -1,165 +1,117 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var E = (o, e, t) => e in o ? A(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var a = (o, e, t) => (E(o, typeof e != "symbol" ? e + "" : e, t), t), v = (o, e, t) => {
|
|
4
|
+
if (!e.has(o))
|
|
5
|
+
throw TypeError("Cannot " + t);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
9
|
-
throw TypeError("Cannot " + msg);
|
|
10
|
-
};
|
|
11
|
-
var __privateAdd = (obj, member, value) => {
|
|
12
|
-
if (member.has(obj))
|
|
7
|
+
var y = (o, e, t) => {
|
|
8
|
+
if (e.has(o))
|
|
13
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
var __privateMethod = (obj, member, method) => {
|
|
17
|
-
__accessCheck(obj, member, "access private method");
|
|
18
|
-
return method;
|
|
10
|
+
e instanceof WeakSet ? e.add(o) : e.set(o, t);
|
|
19
11
|
};
|
|
20
|
-
var
|
|
21
|
-
import { store, defaultStoreActions } from "./wj-store.js";
|
|
22
|
-
class
|
|
23
|
-
constructor(
|
|
24
|
-
|
|
25
|
-
if (this._store.getState()[
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} else {
|
|
29
|
-
console.warn(` Attribute ${attrName} is not array`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
__publicField(this, "findById", (attrName, id) => {
|
|
33
|
-
if (this._store.getState()[attrName] instanceof Array) {
|
|
34
|
-
let find = this._store.getState()[attrName].find((item) => item.id == id);
|
|
35
|
-
return find;
|
|
36
|
-
} else {
|
|
37
|
-
console.warn(` Attribute ${attrName} is not array`);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
__publicField(this, "findAttributeValue", (attrName) => {
|
|
41
|
-
return this._store.getState()[attrName];
|
|
12
|
+
var f = (o, e, t) => (v(o, e, "access private method"), t);
|
|
13
|
+
import { store as b, defaultStoreActions as P } from "./wj-store.js";
|
|
14
|
+
class j {
|
|
15
|
+
constructor(e = {}) {
|
|
16
|
+
a(this, "findByKey", (e, t, s) => {
|
|
17
|
+
if (this._store.getState()[e] instanceof Array)
|
|
18
|
+
return this._store.getState()[e].find((n) => n[t] == s);
|
|
19
|
+
console.warn(` Attribute ${e} is not array`);
|
|
42
20
|
});
|
|
43
|
-
|
|
44
|
-
this._store.
|
|
21
|
+
a(this, "findById", (e, t) => {
|
|
22
|
+
if (this._store.getState()[e] instanceof Array)
|
|
23
|
+
return this._store.getState()[e].find((i) => i.id == t);
|
|
24
|
+
console.warn(` Attribute ${e} is not array`);
|
|
45
25
|
});
|
|
46
|
-
|
|
47
|
-
|
|
26
|
+
a(this, "findAttributeValue", (e) => this._store.getState()[e]);
|
|
27
|
+
a(this, "update", (e, t) => {
|
|
28
|
+
this._store.dispatch(t(e));
|
|
48
29
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return fetch(url, {
|
|
52
|
-
method,
|
|
53
|
-
body: data,
|
|
54
|
-
cache: "no-cache",
|
|
55
|
-
headers: {
|
|
56
|
-
"Content-Type": "application/json"
|
|
57
|
-
},
|
|
58
|
-
async: true,
|
|
59
|
-
referrerPolicy: "same-origin"
|
|
60
|
-
}).then((response, e) => {
|
|
61
|
-
var _a;
|
|
62
|
-
let permissions = (_a = response.headers.get("permissions")) == null ? void 0 : _a.split(",");
|
|
63
|
-
permissionCallBack(permissions);
|
|
64
|
-
if (response.ok) {
|
|
65
|
-
return response.json();
|
|
66
|
-
} else {
|
|
67
|
-
throw response.json();
|
|
68
|
-
}
|
|
69
|
-
}).then((data2) => {
|
|
70
|
-
this._store.dispatch(action(data2));
|
|
71
|
-
return data2;
|
|
72
|
-
});
|
|
30
|
+
a(this, "add", (e, t) => {
|
|
31
|
+
this._store.dispatch(t(e));
|
|
73
32
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"Content-Type": "application/json"
|
|
79
|
-
},
|
|
80
|
-
referrerPolicy: "same-origin"
|
|
81
|
-
}).then((data) => {
|
|
82
|
-
data = data.json();
|
|
83
|
-
if (action) {
|
|
84
|
-
this._store.dispatch(action(data));
|
|
85
|
-
}
|
|
86
|
-
return data;
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
__publicField(this, "load", (url, async = false) => {
|
|
90
|
-
return $.ajax({
|
|
91
|
-
method: "GET",
|
|
92
|
-
url,
|
|
93
|
-
async,
|
|
94
|
-
dataType: "json"
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
this._store = props.store;
|
|
98
|
-
this.premenna = null;
|
|
99
|
-
}
|
|
100
|
-
_save(url, data, action, dispatchMethod, method) {
|
|
101
|
-
let promise = fetch(url, {
|
|
102
|
-
method,
|
|
103
|
-
body: JSON.stringify(data),
|
|
33
|
+
a(this, "loadPromise", (e, t, s = "GET", i, n = () => {
|
|
34
|
+
}) => fetch(e, {
|
|
35
|
+
method: s,
|
|
36
|
+
body: i,
|
|
104
37
|
cache: "no-cache",
|
|
105
38
|
headers: {
|
|
106
39
|
"Content-Type": "application/json"
|
|
107
40
|
},
|
|
41
|
+
async: !0,
|
|
108
42
|
referrerPolicy: "same-origin"
|
|
109
|
-
}).then((
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return
|
|
114
|
-
|
|
115
|
-
});
|
|
116
|
-
|
|
43
|
+
}).then((r, h) => {
|
|
44
|
+
var g;
|
|
45
|
+
let p = (g = r.headers.get("permissions")) == null ? void 0 : g.split(",");
|
|
46
|
+
if (n(p), r.ok)
|
|
47
|
+
return r.json();
|
|
48
|
+
throw r.json();
|
|
49
|
+
}).then((r) => (this._store.dispatch(t(r)), r)));
|
|
50
|
+
a(this, "loadOnePromise", (e, t) => fetch(e, {
|
|
51
|
+
cache: "no-cache",
|
|
52
|
+
headers: {
|
|
53
|
+
"Content-Type": "application/json"
|
|
54
|
+
},
|
|
55
|
+
referrerPolicy: "same-origin"
|
|
56
|
+
}).then((s) => (s = s.json(), t && this._store.dispatch(t(s)), s)));
|
|
57
|
+
a(this, "load", (e, t = !1) => $.ajax({
|
|
58
|
+
method: "GET",
|
|
59
|
+
url: e,
|
|
60
|
+
async: t,
|
|
61
|
+
dataType: "json"
|
|
62
|
+
}));
|
|
63
|
+
this._store = e.store, this.premenna = null;
|
|
64
|
+
}
|
|
65
|
+
_save(e, t, s, i, n) {
|
|
66
|
+
let r = fetch(e, {
|
|
67
|
+
method: n,
|
|
68
|
+
body: JSON.stringify(t),
|
|
69
|
+
cache: "no-cache",
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/json"
|
|
72
|
+
},
|
|
73
|
+
referrerPolicy: "same-origin"
|
|
74
|
+
}).then((h) => (h.ok, h.json()));
|
|
75
|
+
return this.dispatch(r, i, s);
|
|
117
76
|
}
|
|
118
|
-
_get(
|
|
119
|
-
let
|
|
77
|
+
_get(e, t, s) {
|
|
78
|
+
let i = fetch(e, {
|
|
120
79
|
method: "GET",
|
|
121
80
|
cache: "no-cache",
|
|
122
81
|
headers: {
|
|
123
82
|
"Content-Type": "application/json"
|
|
124
83
|
},
|
|
125
84
|
referrerPolicy: "same-origin"
|
|
126
|
-
}).then(async (
|
|
127
|
-
let
|
|
85
|
+
}).then(async (n) => {
|
|
86
|
+
let r;
|
|
128
87
|
try {
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return text;
|
|
88
|
+
let h = await n.text();
|
|
89
|
+
return JSON.parse(h);
|
|
90
|
+
} catch {
|
|
91
|
+
return r;
|
|
134
92
|
}
|
|
135
93
|
});
|
|
136
|
-
return this.dispatch(
|
|
94
|
+
return this.dispatch(i, s, t);
|
|
137
95
|
}
|
|
138
|
-
put(
|
|
139
|
-
return this._save(
|
|
96
|
+
put(e, t, s, i = !0) {
|
|
97
|
+
return this._save(e, t, s, i, "PUT");
|
|
140
98
|
}
|
|
141
|
-
post(
|
|
142
|
-
return this._save(
|
|
99
|
+
post(e, t, s, i = !0) {
|
|
100
|
+
return this._save(e, t, s, i, "POST");
|
|
143
101
|
}
|
|
144
|
-
delete(
|
|
145
|
-
return this._save(
|
|
102
|
+
delete(e, t, s, i = !0) {
|
|
103
|
+
return this._save(e, t, s, i, "DELETE");
|
|
146
104
|
}
|
|
147
|
-
get(
|
|
148
|
-
return this._get(
|
|
105
|
+
get(e, t, s = !0) {
|
|
106
|
+
return this._get(e, t, s);
|
|
149
107
|
}
|
|
150
|
-
dispatch(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
return data;
|
|
155
|
-
}).catch((error) => {
|
|
156
|
-
console.error(error);
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return promise;
|
|
108
|
+
dispatch(e, t, s) {
|
|
109
|
+
return t ? e.then((i) => (this._store.dispatch(s(i.data)), i)).catch((i) => {
|
|
110
|
+
console.error(i);
|
|
111
|
+
}) : e;
|
|
160
112
|
}
|
|
161
113
|
}
|
|
162
|
-
class
|
|
114
|
+
class c {
|
|
163
115
|
constructor() {
|
|
164
116
|
}
|
|
165
117
|
static get permissions() {
|
|
@@ -168,24 +120,21 @@ class WjPermissionsApi {
|
|
|
168
120
|
...intranet.storage().getItem("globalPermissions", "settings") || []
|
|
169
121
|
];
|
|
170
122
|
}
|
|
171
|
-
static includesKey(
|
|
172
|
-
return
|
|
123
|
+
static includesKey(e) {
|
|
124
|
+
return c.permissions.includes(e);
|
|
173
125
|
}
|
|
174
126
|
static getKeys() {
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
key = this.getAttribute("permission-check").split(",");
|
|
178
|
-
}
|
|
179
|
-
return key;
|
|
127
|
+
let e = [];
|
|
128
|
+
return this.hasAttribute("permission-check") && (e = this.getAttribute("permission-check").split(",")), e;
|
|
180
129
|
}
|
|
181
130
|
static shouldShow() {
|
|
182
131
|
return this.hasAttribute("show") && JSON.parse(this.getAttribute("show"));
|
|
183
132
|
}
|
|
184
133
|
static isPermissionFulfilled() {
|
|
185
|
-
return
|
|
134
|
+
return c.getKeys.bind(this)().some((e) => c.permissions.includes(e)) || c.shouldShow.bind(this)();
|
|
186
135
|
}
|
|
187
136
|
}
|
|
188
|
-
class
|
|
137
|
+
class u {
|
|
189
138
|
constructor() {
|
|
190
139
|
}
|
|
191
140
|
/**
|
|
@@ -193,173 +142,115 @@ class WjElementUtils {
|
|
|
193
142
|
* @param element : HTMLElement
|
|
194
143
|
* @param object : Object
|
|
195
144
|
*/
|
|
196
|
-
static setAttributesToElement(
|
|
197
|
-
Object.entries(
|
|
198
|
-
|
|
145
|
+
static setAttributesToElement(e, t) {
|
|
146
|
+
Object.entries(t).forEach(([s, i]) => {
|
|
147
|
+
e.setAttribute(s, i);
|
|
199
148
|
});
|
|
200
149
|
}
|
|
201
150
|
/** @function getAttributes
|
|
202
151
|
* @description Vráti všetky atributy elementu v poli
|
|
203
152
|
* @return (array)
|
|
204
153
|
*/
|
|
205
|
-
static getAttributes(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (typeof el === "string")
|
|
221
|
-
el = document.querySelector(el);
|
|
222
|
-
return Array.from(el.attributes).filter((a) => a.name.startsWith("@wj")).map((a) => [a.name.substring(3).split("-").join(""), a.value]).reduce((acc, attr) => {
|
|
223
|
-
acc.set(attr[0], attr[1]);
|
|
224
|
-
return acc;
|
|
225
|
-
}, /* @__PURE__ */ new Map());
|
|
226
|
-
}
|
|
227
|
-
static attributesToString(object) {
|
|
228
|
-
return Object.entries(object).map(([key, value]) => {
|
|
229
|
-
return `${key}="${value}"`;
|
|
230
|
-
}).join(" ");
|
|
231
|
-
}
|
|
232
|
-
static hasSlot(el, slotName = null) {
|
|
233
|
-
let selector = slotName ? `[slot="${slotName}"]` : "[slot]";
|
|
234
|
-
return el.querySelectorAll(selector).length > 0 ? true : false;
|
|
235
|
-
}
|
|
236
|
-
static stringToBoolean(string) {
|
|
237
|
-
return !["false", "0", 0].includes(string);
|
|
154
|
+
static getAttributes(e) {
|
|
155
|
+
return typeof e == "string" && (e = document.querySelector(e)), Array.from(e.attributes).filter((t) => !t.name.startsWith("@")).map((t) => [t.name.split("-").map((s, i) => i != 0 ? s.charAt(0).toUpperCase() + s.slice(1) : s).join(""), t.value]).reduce((t, s) => (t[s[0]] = s[1], t), {});
|
|
156
|
+
}
|
|
157
|
+
static getEvents(e) {
|
|
158
|
+
return typeof e == "string" && (e = document.querySelector(e)), Array.from(e.attributes).filter((t) => t.name.startsWith("@wj")).map((t) => [t.name.substring(3).split("-").join(""), t.value]).reduce((t, s) => (t.set(s[0], s[1]), t), /* @__PURE__ */ new Map());
|
|
159
|
+
}
|
|
160
|
+
static attributesToString(e) {
|
|
161
|
+
return Object.entries(e).map(([t, s]) => `${t}="${s}"`).join(" ");
|
|
162
|
+
}
|
|
163
|
+
static hasSlot(e, t = null) {
|
|
164
|
+
let s = t ? `[slot="${t}"]` : "[slot]";
|
|
165
|
+
return e.querySelectorAll(s).length > 0;
|
|
166
|
+
}
|
|
167
|
+
static stringToBoolean(e) {
|
|
168
|
+
return !["false", "0", 0].includes(e);
|
|
238
169
|
}
|
|
239
170
|
}
|
|
240
|
-
var
|
|
241
|
-
class
|
|
171
|
+
var d, l, m;
|
|
172
|
+
class T {
|
|
242
173
|
constructor() {
|
|
243
|
-
|
|
244
|
-
this.customEventStorage = [];
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
composed: true
|
|
174
|
+
y(this, l);
|
|
175
|
+
this.customEventStorage = [], d = this;
|
|
176
|
+
}
|
|
177
|
+
dispatchCustomEvent(e, t, s) {
|
|
178
|
+
e.dispatchEvent(
|
|
179
|
+
new CustomEvent(t, {
|
|
180
|
+
detail: s,
|
|
181
|
+
bubbles: !0,
|
|
182
|
+
composed: !0
|
|
253
183
|
})
|
|
254
184
|
);
|
|
255
185
|
}
|
|
256
|
-
findRecordByElement(
|
|
257
|
-
for (var
|
|
258
|
-
var
|
|
259
|
-
if (
|
|
260
|
-
return
|
|
261
|
-
}
|
|
186
|
+
findRecordByElement(e) {
|
|
187
|
+
for (var t = 0, s = this.customEventStorage.length; t < s; t++) {
|
|
188
|
+
var i = this.customEventStorage[t];
|
|
189
|
+
if (e == i.element)
|
|
190
|
+
return i;
|
|
262
191
|
}
|
|
263
|
-
return
|
|
192
|
+
return !1;
|
|
264
193
|
}
|
|
265
|
-
addListener(
|
|
266
|
-
if (!
|
|
194
|
+
addListener(e, t, s, i, n) {
|
|
195
|
+
if (!e)
|
|
267
196
|
return;
|
|
268
|
-
let
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
this.customEventStorage.push(record);
|
|
278
|
-
}
|
|
279
|
-
listener = listener || __privateMethod(this, _dispatch, dispatch_fn);
|
|
280
|
-
let obj = {
|
|
281
|
-
listener,
|
|
282
|
-
options,
|
|
283
|
-
event: event2
|
|
197
|
+
let r = this.findRecordByElement(e);
|
|
198
|
+
r ? r.listeners[t] = r.listeners[t] || [] : (r = {
|
|
199
|
+
element: e,
|
|
200
|
+
listeners: {}
|
|
201
|
+
}, r.listeners[t] = [], this.customEventStorage.push(r)), i = i || f(this, l, m);
|
|
202
|
+
let h = {
|
|
203
|
+
listener: i,
|
|
204
|
+
options: n,
|
|
205
|
+
event: s
|
|
284
206
|
};
|
|
285
|
-
|
|
286
|
-
record.listeners[originalEvent].push(obj);
|
|
287
|
-
element.addEventListener(originalEvent, listener);
|
|
288
|
-
}
|
|
207
|
+
this.listenerExists(e, t, h) || (r.listeners[t].push(h), e.addEventListener(t, i));
|
|
289
208
|
}
|
|
290
|
-
listenerExists(
|
|
291
|
-
|
|
292
|
-
return record.listeners[event2].some((e) => JSON.stringify(e) === JSON.stringify(listener));
|
|
209
|
+
listenerExists(e, t, s) {
|
|
210
|
+
return this.findRecordByElement(e).listeners[t].some((n) => JSON.stringify(n) === JSON.stringify(s));
|
|
293
211
|
}
|
|
294
|
-
removeListener(
|
|
295
|
-
let
|
|
296
|
-
if (
|
|
297
|
-
var
|
|
298
|
-
|
|
299
|
-
record.listeners[originalEvent].splice(index, 1);
|
|
300
|
-
}
|
|
301
|
-
if (!record.listeners[originalEvent].length) {
|
|
302
|
-
delete record.listeners[originalEvent];
|
|
303
|
-
}
|
|
212
|
+
removeListener(e, t, s, i, n) {
|
|
213
|
+
let r = this.findRecordByElement(e);
|
|
214
|
+
if (r && t in r.listeners) {
|
|
215
|
+
var h = r.listeners[t].indexOf(i);
|
|
216
|
+
~h && r.listeners[t].splice(h, 1), r.listeners[t].length || delete r.listeners[t];
|
|
304
217
|
}
|
|
305
|
-
|
|
306
|
-
element.removeEventListener(originalEvent, listener, options);
|
|
218
|
+
i = i || f(this, l, m), e.removeEventListener(t, i, n);
|
|
307
219
|
}
|
|
308
|
-
removeElement(
|
|
309
|
-
this.customEventStorage = this.customEventStorage.filter((
|
|
310
|
-
if (
|
|
311
|
-
return
|
|
220
|
+
removeElement(e) {
|
|
221
|
+
this.customEventStorage = this.customEventStorage.filter((t) => {
|
|
222
|
+
if (t.element !== e)
|
|
223
|
+
return t;
|
|
312
224
|
});
|
|
313
225
|
}
|
|
314
226
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
let listeners = record.listeners[e.type];
|
|
320
|
-
listeners.forEach((listener, i) => {
|
|
321
|
-
self.dispatchCustomEvent(element, listener.event, {
|
|
227
|
+
l = new WeakSet(), m = function(e) {
|
|
228
|
+
let t = this;
|
|
229
|
+
d.findRecordByElement(t).listeners[e.type].forEach((n, r) => {
|
|
230
|
+
d.dispatchCustomEvent(t, n.event, {
|
|
322
231
|
originalEvent: (e == null ? void 0 : e.type) || null,
|
|
323
|
-
context:
|
|
324
|
-
event:
|
|
325
|
-
});
|
|
326
|
-
if (listener.options && listener.options.stopPropagation === true)
|
|
327
|
-
e.stopPropagation();
|
|
232
|
+
context: t,
|
|
233
|
+
event: d
|
|
234
|
+
}), n.options && n.options.stopPropagation === !0 && e.stopPropagation();
|
|
328
235
|
});
|
|
329
236
|
};
|
|
330
|
-
let
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
class
|
|
334
|
-
constructor(
|
|
237
|
+
let k = new T();
|
|
238
|
+
const w = document.createElement("template");
|
|
239
|
+
w.innerHTML = "";
|
|
240
|
+
class S extends HTMLElement {
|
|
241
|
+
constructor(t) {
|
|
335
242
|
super();
|
|
336
|
-
|
|
337
|
-
var
|
|
243
|
+
a(this, "initWjElement", async (t = !1) => {
|
|
244
|
+
var n;
|
|
338
245
|
this.functionStack = [];
|
|
339
|
-
const
|
|
340
|
-
this.functionStack.push(
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
!this.shadowRoot && this.attachShadow({ mode: this.shadowType || "open" });
|
|
344
|
-
}
|
|
345
|
-
this.setUpAccessors();
|
|
346
|
-
this.drawingStatus = "BEGINING";
|
|
347
|
-
this.display(force, processId);
|
|
348
|
-
const sheet = new CSSStyleSheet();
|
|
349
|
-
sheet.replaceSync(this.constructor.cssStyleSheet);
|
|
350
|
-
this.context.adoptedStyleSheets = [sheet];
|
|
351
|
-
});
|
|
352
|
-
this.template = componentTemplate || template;
|
|
353
|
-
this._attributes = {};
|
|
354
|
-
this.isAttached = false;
|
|
355
|
-
this.service = new UniversalService({
|
|
356
|
-
store
|
|
246
|
+
const s = Date.now();
|
|
247
|
+
this.functionStack.push(s), (n = this.setupAttributes) == null || n.call(this), this.isShadowRoot && !this.shadowRoot && this.attachShadow({ mode: this.shadowType || "open" }), this.setUpAccessors(), this.drawingStatus = "BEGINING", this.display(t, s);
|
|
248
|
+
const i = new CSSStyleSheet();
|
|
249
|
+
i.replaceSync(this.constructor.cssStyleSheet), this.context.adoptedStyleSheets = [i];
|
|
357
250
|
});
|
|
358
|
-
this.
|
|
359
|
-
|
|
360
|
-
this.count = 0;
|
|
361
|
-
this.functionStack = [];
|
|
362
|
-
this.scheludedRefresh = false;
|
|
251
|
+
this.template = t || w, this._attributes = {}, this.isAttached = !1, this.service = new j({
|
|
252
|
+
store: b
|
|
253
|
+
}), this.rendering = !1, this.runtimeTimeout = null, this.count = 0, this.functionStack = [], this.scheludedRefresh = !1;
|
|
363
254
|
}
|
|
364
255
|
get permission() {
|
|
365
256
|
return this.getAttribute("permission-check");
|
|
@@ -367,7 +258,7 @@ class WJElement extends HTMLElement {
|
|
|
367
258
|
get isPermissionCheck() {
|
|
368
259
|
return this.hasAttribute("permission-check");
|
|
369
260
|
}
|
|
370
|
-
set isPermissionCheck(
|
|
261
|
+
set isPermissionCheck(t) {
|
|
371
262
|
return this.setAttribute("permission-check", "permission-check");
|
|
372
263
|
}
|
|
373
264
|
get isShow() {
|
|
@@ -376,21 +267,17 @@ class WJElement extends HTMLElement {
|
|
|
376
267
|
get isShadowRoot() {
|
|
377
268
|
return this.hasAttribute("shadow");
|
|
378
269
|
}
|
|
379
|
-
set isShadowRoot(
|
|
380
|
-
return this.setAttribute("shadow",
|
|
270
|
+
set isShadowRoot(t) {
|
|
271
|
+
return this.setAttribute("shadow", t);
|
|
381
272
|
}
|
|
382
273
|
get shadowType() {
|
|
383
274
|
return this.getAttribute("shadow") || "open";
|
|
384
275
|
}
|
|
385
276
|
get context() {
|
|
386
|
-
|
|
387
|
-
return this.shadowRoot;
|
|
388
|
-
} else {
|
|
389
|
-
return this;
|
|
390
|
-
}
|
|
277
|
+
return this.isShadowRoot ? this.shadowRoot : this;
|
|
391
278
|
}
|
|
392
279
|
get store() {
|
|
393
|
-
return
|
|
280
|
+
return b;
|
|
394
281
|
}
|
|
395
282
|
// addAction,
|
|
396
283
|
// deleteAction,
|
|
@@ -414,190 +301,128 @@ class WJElement extends HTMLElement {
|
|
|
414
301
|
* @return {ArrayActions, ObjectActions}
|
|
415
302
|
*/
|
|
416
303
|
get defaultStoreActions() {
|
|
417
|
-
return
|
|
304
|
+
return P;
|
|
418
305
|
}
|
|
419
306
|
get removeClassAfterConnect() {
|
|
420
|
-
var
|
|
421
|
-
return (
|
|
307
|
+
var t;
|
|
308
|
+
return (t = this.getAttribute("remove-class-after-connect")) == null ? void 0 : t.split(" ");
|
|
422
309
|
}
|
|
423
310
|
beforeDraw() {
|
|
424
311
|
}
|
|
425
312
|
afterDraw() {
|
|
426
313
|
}
|
|
427
|
-
makeRuntimeTimeout(
|
|
314
|
+
makeRuntimeTimeout(t = () => {
|
|
428
315
|
}) {
|
|
429
316
|
return setTimeout(() => {
|
|
430
|
-
|
|
317
|
+
t();
|
|
431
318
|
}, 0);
|
|
432
319
|
}
|
|
433
320
|
refreshUpdatePromise() {
|
|
434
|
-
this.updateComplete = new Promise((
|
|
435
|
-
this.finisPromise =
|
|
436
|
-
this.rejectPromise = reject;
|
|
321
|
+
this.updateComplete = new Promise((t, s) => {
|
|
322
|
+
this.finisPromise = t, this.rejectPromise = s;
|
|
437
323
|
});
|
|
438
324
|
}
|
|
439
325
|
async connectedCallback() {
|
|
440
|
-
this.finisPromise = (
|
|
441
|
-
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
};
|
|
446
|
-
this.refreshUpdatePromise();
|
|
447
|
-
await this.initWjElement(true);
|
|
326
|
+
this.finisPromise = (t) => {
|
|
327
|
+
t();
|
|
328
|
+
}, this.rejectPromise = (t) => {
|
|
329
|
+
t();
|
|
330
|
+
}, this.refreshUpdatePromise(), await this.initWjElement(!0);
|
|
448
331
|
}
|
|
449
332
|
setupAttributes() {
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
(_b = (_a = this.getRootNode().host)[customEvent]) == null ? void 0 : _b.call(_a);
|
|
333
|
+
u.getEvents(this).forEach((s, i) => {
|
|
334
|
+
this.addEventListener(i, (n) => {
|
|
335
|
+
var r, h;
|
|
336
|
+
(h = (r = this.getRootNode().host)[s]) == null || h.call(r);
|
|
455
337
|
});
|
|
456
338
|
});
|
|
457
339
|
}
|
|
458
340
|
beforeDisconnect() {
|
|
459
341
|
}
|
|
460
342
|
disconnectedCallback() {
|
|
461
|
-
var
|
|
462
|
-
(
|
|
463
|
-
if (this.isAttached)
|
|
464
|
-
this.context.innerHTML = "";
|
|
465
|
-
this.isAttached = false;
|
|
466
|
-
(_b = this.afterDisconnect) == null ? void 0 : _b.call(this);
|
|
343
|
+
var t, s;
|
|
344
|
+
(t = this.beforeDisconnect) == null || t.call(this), this.isAttached && (this.context.innerHTML = ""), this.isAttached = !1, (s = this.afterDisconnect) == null || s.call(this);
|
|
467
345
|
}
|
|
468
346
|
/**
|
|
469
347
|
* Lifecycle method, called whenever an observed property changes
|
|
470
348
|
*/
|
|
471
|
-
attributeChangedCallback(
|
|
472
|
-
if (!this.isAttached &&
|
|
473
|
-
this.scheludedRefresh =
|
|
349
|
+
attributeChangedCallback(t, s, i) {
|
|
350
|
+
if (!this.isAttached && s !== i) {
|
|
351
|
+
this.scheludedRefresh = !0;
|
|
474
352
|
return;
|
|
475
353
|
}
|
|
476
|
-
|
|
477
|
-
this.refresh();
|
|
478
|
-
}
|
|
354
|
+
s !== i && this.refresh();
|
|
479
355
|
}
|
|
480
356
|
async refresh() {
|
|
481
|
-
var
|
|
482
|
-
this.refreshUpdatePromise();
|
|
483
|
-
if (this.drawingStatus != "AFTER") {
|
|
484
|
-
(_a = this.afterDisconnect) == null ? void 0 : _a.call(this);
|
|
485
|
-
await this.initWjElement(true);
|
|
486
|
-
} else {
|
|
487
|
-
(_b = this.unregister) == null ? void 0 : _b.call(this);
|
|
488
|
-
await this.initWjElement(true);
|
|
489
|
-
}
|
|
357
|
+
var t, s;
|
|
358
|
+
this.refreshUpdatePromise(), this.drawingStatus != "AFTER" ? ((t = this.afterDisconnect) == null || t.call(this), await this.initWjElement(!0)) : ((s = this.unregister) == null || s.call(this), await this.initWjElement(!0));
|
|
490
359
|
}
|
|
491
360
|
/**
|
|
492
361
|
* To be implemented by the child class
|
|
493
362
|
*/
|
|
494
|
-
draw(
|
|
363
|
+
draw(t, s, i) {
|
|
495
364
|
return null;
|
|
496
365
|
}
|
|
497
|
-
display(
|
|
498
|
-
|
|
499
|
-
return;
|
|
500
|
-
if (force && this.isShadowRoot) {
|
|
501
|
-
[...this.context.children].forEach(this.context.removeChild.bind(this.context));
|
|
502
|
-
this.isAttached = false;
|
|
503
|
-
}
|
|
504
|
-
if (this.isAttached) {
|
|
505
|
-
console.log("Already rendered...", this);
|
|
506
|
-
}
|
|
507
|
-
this.context.append(this.template.content.cloneNode(true));
|
|
508
|
-
if (this.isPermissionCheck || this.isShow) {
|
|
509
|
-
if (WjPermissionsApi.isPermissionFulfilled.bind(this)(this.permission)) {
|
|
510
|
-
this._resolveRender(processId);
|
|
511
|
-
} else {
|
|
512
|
-
this.remove();
|
|
513
|
-
}
|
|
514
|
-
} else {
|
|
515
|
-
this._resolveRender(processId);
|
|
516
|
-
}
|
|
366
|
+
display(t = !1, s) {
|
|
367
|
+
this.isProcessingFlow(s) || (t && this.isShadowRoot && ([...this.context.children].forEach(this.context.removeChild.bind(this.context)), this.isAttached = !1), this.isAttached && console.log("Already rendered...", this), this.context.append(this.template.content.cloneNode(!0)), this.isPermissionCheck || this.isShow ? c.isPermissionFulfilled.bind(this)(this.permission) ? this._resolveRender(s) : this.remove() : this._resolveRender(s));
|
|
517
368
|
}
|
|
518
|
-
render(
|
|
519
|
-
this.drawingStatus = "DRAWING"
|
|
520
|
-
if (this.isProcessingFlow(processId))
|
|
369
|
+
render(t) {
|
|
370
|
+
if (this.drawingStatus = "DRAWING", this.isProcessingFlow(t))
|
|
521
371
|
return;
|
|
522
|
-
let
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
template2.innerHTML = rend;
|
|
529
|
-
element = template2.content.cloneNode(true);
|
|
372
|
+
let s = this.draw(this.context, this.store, u.getAttributes(this)) || "", i;
|
|
373
|
+
if (s instanceof HTMLElement || s instanceof DocumentFragment)
|
|
374
|
+
i = s;
|
|
375
|
+
else {
|
|
376
|
+
let r = document.createElement("template");
|
|
377
|
+
r.innerHTML = s, i = r.content.cloneNode(!0);
|
|
530
378
|
}
|
|
531
|
-
let
|
|
532
|
-
|
|
533
|
-
return;
|
|
534
|
-
this.context.appendChild(rendered);
|
|
379
|
+
let n = i;
|
|
380
|
+
this.isProcessingFlow(t) || this.context.appendChild(n);
|
|
535
381
|
}
|
|
536
382
|
/**
|
|
537
383
|
* Turns a string split with "-" into camel case notation
|
|
538
384
|
*/
|
|
539
|
-
sanitizeName(
|
|
540
|
-
let
|
|
541
|
-
return [
|
|
385
|
+
sanitizeName(t) {
|
|
386
|
+
let s = t.split("-");
|
|
387
|
+
return [s.shift(), ...s.map((i) => i[0].toUpperCase() + i.slice(1))].join("");
|
|
542
388
|
}
|
|
543
389
|
/**
|
|
544
390
|
* Creates one property on this class for every
|
|
545
391
|
* HTML property defined on the element
|
|
546
392
|
*/
|
|
547
393
|
setUpAccessors() {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
get: (_) => {
|
|
555
|
-
return this.getAttribute(name);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
}
|
|
394
|
+
this.getAttributeNames().forEach((s) => {
|
|
395
|
+
const i = this.sanitizeName(s);
|
|
396
|
+
this[i] == null && Object.defineProperty(this, i, {
|
|
397
|
+
set: (n) => this.setAttribute(s, n),
|
|
398
|
+
get: (n) => this.getAttribute(s)
|
|
399
|
+
});
|
|
559
400
|
});
|
|
560
401
|
}
|
|
561
|
-
isProcessingFlow(
|
|
562
|
-
return !this.functionStack.find((
|
|
402
|
+
isProcessingFlow(t) {
|
|
403
|
+
return !this.functionStack.find((s) => s == t);
|
|
563
404
|
}
|
|
564
|
-
_resolveRender(
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
this.drawingStatus = "BEFORE";
|
|
571
|
-
this.render(processId);
|
|
572
|
-
if (this.isProcessingFlow(processId))
|
|
573
|
-
return;
|
|
574
|
-
Promise.resolve((_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this))).then(
|
|
575
|
-
(a, b, c) => {
|
|
576
|
-
this.drawingStatus = "AFTER";
|
|
577
|
-
this.finisPromise();
|
|
578
|
-
this.rendering = false;
|
|
579
|
-
this.isAttached = true;
|
|
580
|
-
this.removeClassAfterConnect && this.classList.remove(...this.removeClassAfterConnect);
|
|
581
|
-
if (this.scheludedRefresh) {
|
|
582
|
-
this.refresh();
|
|
583
|
-
this.scheludedRefresh = false;
|
|
584
|
-
}
|
|
405
|
+
_resolveRender(t) {
|
|
406
|
+
this.isProcessingFlow(t) || (this.params = u.getAttributes(this), Promise.resolve(this.beforeDraw(this.context, this.store, u.getAttributes(this))).then((s) => {
|
|
407
|
+
var i;
|
|
408
|
+
this.drawingStatus = "BEFORE", this.render(t), !this.isProcessingFlow(t) && Promise.resolve((i = this.afterDraw) == null ? void 0 : i.call(this, this.context, this.store, u.getAttributes(this))).then(
|
|
409
|
+
(n, r, h) => {
|
|
410
|
+
this.drawingStatus = "AFTER", this.finisPromise(), this.rendering = !1, this.isAttached = !0, this.removeClassAfterConnect && this.classList.remove(...this.removeClassAfterConnect), this.scheludedRefresh && (this.refresh(), this.scheludedRefresh = !1);
|
|
585
411
|
}
|
|
586
412
|
);
|
|
587
|
-
});
|
|
413
|
+
}));
|
|
588
414
|
}
|
|
589
415
|
}
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
return newTemplate;
|
|
416
|
+
a(S, "processTemplates", (t, s) => {
|
|
417
|
+
const i = document.createElement("template");
|
|
418
|
+
return i.innerHTML = [s.innerHTML, (t == null ? void 0 : t.innerHTML) || ""].join(""), i;
|
|
594
419
|
});
|
|
595
|
-
let
|
|
596
|
-
customElements.get("wj-element") || customElements.define("wj-element",
|
|
420
|
+
let _ = "true";
|
|
421
|
+
customElements.get("wj-element") || customElements.define("wj-element", S);
|
|
597
422
|
export {
|
|
598
|
-
WjElementUtils,
|
|
599
|
-
WjPermissionsApi,
|
|
600
|
-
__esModule,
|
|
601
|
-
|
|
602
|
-
event
|
|
423
|
+
u as WjElementUtils,
|
|
424
|
+
c as WjPermissionsApi,
|
|
425
|
+
_ as __esModule,
|
|
426
|
+
S as default,
|
|
427
|
+
k as event
|
|
603
428
|
};
|