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.
Files changed (79) hide show
  1. package/dist/localize-20081fd1.js +55 -0
  2. package/dist/router-links-26e4a166.js +204 -0
  3. package/dist/style.css +2243 -2
  4. package/dist/wj-animation.js +35 -23
  5. package/dist/wj-aside.js +22 -16
  6. package/dist/wj-avatar.js +49 -30
  7. package/dist/wj-badge.js +22 -18
  8. package/dist/wj-breadcrumb.js +102 -50
  9. package/dist/wj-breadcrumbs.js +36 -19
  10. package/dist/wj-button-group.js +36 -22
  11. package/dist/wj-button.js +104 -39
  12. package/dist/wj-card-content.js +18 -14
  13. package/dist/wj-card-controls.js +18 -14
  14. package/dist/wj-card-header.js +20 -14
  15. package/dist/wj-card-subtitle.js +19 -15
  16. package/dist/wj-card-title.js +18 -14
  17. package/dist/wj-card.js +20 -14
  18. package/dist/wj-carousel-item.js +22 -16
  19. package/dist/wj-carousel.js +169 -92
  20. package/dist/wj-checkbox.js +46 -24
  21. package/dist/wj-chip.js +39 -21
  22. package/dist/wj-col.js +31 -17
  23. package/dist/wj-color-picker.js +877 -509
  24. package/dist/wj-container.js +20 -16
  25. package/dist/wj-copy-button.js +112 -64
  26. package/dist/wj-dialog.js +68 -42
  27. package/dist/wj-divider.js +20 -14
  28. package/dist/wj-dropdown.js +29 -17
  29. package/dist/wj-element.js +415 -241
  30. package/dist/wj-fetchAndParseCSS.js +49 -32
  31. package/dist/wj-file-upload-item.js +64 -38
  32. package/dist/wj-file-upload.js +237 -137
  33. package/dist/wj-footer.js +18 -14
  34. package/dist/wj-form.js +18 -14
  35. package/dist/wj-format-digital.js +40 -25
  36. package/dist/wj-grid.js +20 -16
  37. package/dist/wj-header.js +22 -16
  38. package/dist/wj-icon-picker.js +122 -68
  39. package/dist/wj-icon.js +144 -64
  40. package/dist/wj-img-comparer.js +72 -41
  41. package/dist/wj-img.js +31 -19
  42. package/dist/wj-infinite-scroll.js +90 -52
  43. package/dist/wj-input-file.js +50 -27
  44. package/dist/wj-input.js +169 -70
  45. package/dist/wj-item.js +34 -17
  46. package/dist/wj-label.js +21 -19
  47. package/dist/wj-list.js +20 -15
  48. package/dist/wj-main.js +18 -14
  49. package/dist/wj-masonry.js +140 -83
  50. package/dist/wj-master.js +492 -350
  51. package/dist/wj-menu-button.js +19 -15
  52. package/dist/wj-menu-item.js +150 -64
  53. package/dist/wj-menu-label.js +21 -17
  54. package/dist/wj-menu.js +24 -18
  55. package/dist/wj-popup.js +1140 -712
  56. package/dist/wj-progress-bar.js +100 -40
  57. package/dist/wj-radio-group.js +38 -25
  58. package/dist/wj-radio.js +46 -22
  59. package/dist/wj-rate.js +121 -71
  60. package/dist/wj-relative-time.js +48 -24
  61. package/dist/wj-route.js +11 -8
  62. package/dist/wj-router-link.js +22 -17
  63. package/dist/wj-router-outlet.js +135 -71
  64. package/dist/wj-routerx.js +1124 -641
  65. package/dist/wj-row.js +21 -19
  66. package/dist/wj-slider.js +97 -55
  67. package/dist/wj-split-view.js +81 -43
  68. package/dist/wj-store.js +195 -110
  69. package/dist/wj-textarea.js +86 -37
  70. package/dist/wj-thumbnail.js +19 -15
  71. package/dist/wj-toast.js +87 -34
  72. package/dist/wj-toggle.js +42 -24
  73. package/dist/wj-toolbar-action.js +27 -16
  74. package/dist/wj-toolbar.js +26 -19
  75. package/dist/wj-tooltip.js +40 -24
  76. package/dist/wj-visually-hidden.js +18 -14
  77. package/package.json +1 -1
  78. package/dist/localize-762a9f0f.js +0 -43
  79. package/dist/router-links-e0087f84.js +0 -146
@@ -1,117 +1,165 @@
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);
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 b = (o, e, t) => {
8
- if (e.has(o))
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
- e instanceof WeakSet ? e.add(o) : e.set(o, t);
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 f = (o, e, t) => (v(o, e, "access private method"), t);
13
- import { store as w, 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`);
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
- 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`);
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
- a(this, "findAttributeValue", (e) => this._store.getState()[e]);
27
- a(this, "update", (e, t) => {
28
- this._store.dispatch(t(e));
40
+ __publicField(this, "findAttributeValue", (attrName) => {
41
+ return this._store.getState()[attrName];
29
42
  });
30
- a(this, "add", (e, t) => {
31
- this._store.dispatch(t(e));
43
+ __publicField(this, "update", (data, action) => {
44
+ this._store.dispatch(action(data));
32
45
  });
33
- a(this, "loadPromise", (e, t, s = "GET", i, n = () => {
34
- }) => fetch(e, {
35
- method: s,
36
- body: i,
37
- cache: "no-cache",
38
- headers: {
39
- "Content-Type": "application/json"
40
- },
41
- async: !0,
42
- referrerPolicy: "same-origin"
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),
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((h) => (h.ok, h.json()));
75
- return this.dispatch(r, i, s);
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(e, t, s) {
78
- let i = fetch(e, {
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 (n) => {
86
- let r;
126
+ }).then(async (response) => {
127
+ let text;
87
128
  try {
88
- let h = await n.text();
89
- return JSON.parse(h);
90
- } catch {
91
- return r;
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(i, s, t);
136
+ return this.dispatch(promise, dispatchMethod, action);
95
137
  }
96
- put(e, t, s, i = !0) {
97
- return this._save(e, t, s, i, "PUT");
138
+ put(url, data, action, dispatchMethod = true) {
139
+ return this._save(url, data, action, dispatchMethod, "PUT");
98
140
  }
99
- post(e, t, s, i = !0) {
100
- return this._save(e, t, s, i, "POST");
141
+ post(url, data, action, dispatchMethod = true) {
142
+ return this._save(url, data, action, dispatchMethod, "POST");
101
143
  }
102
- delete(e, t, s, i = !0) {
103
- return this._save(e, t, s, i, "DELETE");
144
+ delete(url, data, action, dispatchMethod = true) {
145
+ return this._save(url, data, action, dispatchMethod, "DELETE");
104
146
  }
105
- get(e, t, s = !0) {
106
- return this._get(e, t, s);
147
+ get(url, action, dispatchMethod = true) {
148
+ return this._get(url, action, dispatchMethod);
107
149
  }
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;
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 c {
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(e) {
124
- return c.permissions.includes(e);
171
+ static includesKey(key) {
172
+ return WjPermissionsApi.permissions.includes(key);
125
173
  }
126
174
  static getKeys() {
127
- let e = [];
128
- return this.hasAttribute("permission-check") && (e = this.getAttribute("permission-check").split(",")), e;
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 c.getKeys.bind(this)().some((e) => c.permissions.includes(e)) || c.shouldShow.bind(this)();
185
+ return WjPermissionsApi.getKeys.bind(this)().some((perm) => WjPermissionsApi.permissions.includes(perm)) || WjPermissionsApi.shouldShow.bind(this)();
135
186
  }
136
187
  }
137
- class u {
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(e, t) {
146
- Object.entries(t).forEach(([s, i]) => {
147
- e.setAttribute(s, i);
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(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);
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 d, l, m;
172
- class T {
240
+ var self;
241
+ class WjEvent {
173
242
  constructor() {
174
- b(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
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(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;
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 !1;
263
+ return false;
193
264
  }
194
- addListener(e, t, s, i, n) {
195
- if (!e)
265
+ addListener(element, originalEvent, event2, listener, options) {
266
+ if (!element)
196
267
  return;
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
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(e, t, h) || (r.listeners[t].push(h), e.addEventListener(t, i));
285
+ if (!this.listenerExists(element, originalEvent, obj)) {
286
+ record.listeners[originalEvent].push(obj);
287
+ element.addEventListener(originalEvent, listener);
288
+ }
208
289
  }
209
- listenerExists(e, t, s) {
210
- return this.findRecordByElement(e).listeners[t].some((n) => JSON.stringify(n) === JSON.stringify(s));
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(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];
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
- i = i || f(this, l, m), e.removeEventListener(t, i, n);
305
+ listener = listener || __privateMethod(this, _dispatch, dispatch_fn);
306
+ element.removeEventListener(originalEvent, listener, options);
219
307
  }
220
- removeElement(e) {
221
- this.customEventStorage = this.customEventStorage.filter((t) => {
222
- if (t.element !== e)
223
- return t;
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
- 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, {
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: t,
233
- event: d
234
- }), n.options && n.options.stopPropagation === !0 && e.stopPropagation();
323
+ context: element,
324
+ event: self
325
+ });
326
+ if (listener.options && listener.options.stopPropagation === true)
327
+ e.stopPropagation();
235
328
  });
236
329
  };
237
- let k = new T();
238
- const y = document.createElement("template");
239
- y.innerHTML = "";
240
- class S extends HTMLElement {
241
- constructor(t) {
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
- a(this, "initWjElement", async (t = !1) => {
244
- var n;
336
+ __publicField(this, "initWjElement", async (force = false) => {
337
+ var _a;
245
338
  this.functionStack = [];
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];
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.template = t || y, this._attributes = {}, this.isAttached = !1, this.service = new j({
252
- store: w
253
- }), this.rendering = !1, this.runtimeTimeout = null, this.count = 0, this.functionStack = [], this.scheludedRefresh = !1;
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(t) {
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(t) {
271
- return this.setAttribute("shadow", t);
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
- return this.isShadowRoot ? this.shadowRoot : this;
386
+ if (this.isShadowRoot) {
387
+ return this.shadowRoot;
388
+ } else {
389
+ return this;
390
+ }
278
391
  }
279
392
  get store() {
280
- return w;
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 P;
417
+ return defaultStoreActions;
305
418
  }
306
419
  get removeClassAfterConnect() {
307
- var t;
308
- return (t = this.getAttribute("remove-class-after-connect")) == null ? void 0 : t.split(" ");
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(t = () => {
427
+ makeRuntimeTimeout(callback = () => {
315
428
  }) {
316
429
  return setTimeout(() => {
317
- t();
430
+ callback();
318
431
  }, 0);
319
432
  }
320
433
  refreshUpdatePromise() {
321
- this.updateComplete = new Promise((t, s) => {
322
- this.finisPromise = t, this.rejectPromise = s;
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 = (t) => {
327
- t();
328
- }, this.rejectPromise = (t) => {
329
- t();
330
- }, this.refreshUpdatePromise(), await this.initWjElement(!0);
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
- 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);
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 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);
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(t, s, i) {
350
- if (!this.isAttached && s !== i) {
351
- this.scheludedRefresh = !0;
471
+ attributeChangedCallback(name, old, newName) {
472
+ if (!this.isAttached && old !== newName) {
473
+ this.scheludedRefresh = true;
352
474
  return;
353
475
  }
354
- s !== i && this.refresh();
476
+ if (old !== newName) {
477
+ this.refresh();
478
+ }
355
479
  }
356
480
  async refresh() {
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));
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(t, s, i) {
494
+ draw(context, store2, params) {
364
495
  return null;
365
496
  }
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, 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));
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(t) {
370
- if (this.drawingStatus = "DRAWING", this.isProcessingFlow(t))
517
+ render(processId) {
518
+ this.drawingStatus = "DRAWING";
519
+ if (this.isProcessingFlow(processId))
371
520
  return;
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);
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 n = i;
380
- this.isProcessingFlow(t) || this.context.appendChild(n);
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(t) {
386
- let s = t.split("-");
387
- return [s.shift(), ...s.map((i) => i[0].toUpperCase() + i.slice(1))].join("");
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().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
- });
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(t) {
403
- return !this.functionStack.find((s) => s == t);
560
+ isProcessingFlow(processId) {
561
+ return !this.functionStack.find((d) => d == processId);
404
562
  }
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);
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
- 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;
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 _ = "true";
421
- customElements.get("wj-element") || customElements.define("wj-element", S);
594
+ let __esModule = "true";
595
+ customElements.get("wj-element") || customElements.define("wj-element", WJElement);
422
596
  export {
423
- u as WjElementUtils,
424
- c as WjPermissionsApi,
425
- _ as __esModule,
426
- S as default,
427
- k as event
597
+ WjElementUtils,
598
+ WjPermissionsApi,
599
+ __esModule,
600
+ WJElement as default,
601
+ event
428
602
  };