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