wj-elements 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/router-links-e0087f84.js +146 -0
  2. package/dist/style.css +2 -2365
  3. package/dist/wj-aside.js +18 -22
  4. package/dist/wj-avatar.js +32 -49
  5. package/dist/wj-badge.js +18 -22
  6. package/dist/wj-breadcrumb.js +53 -103
  7. package/dist/wj-breadcrumbs.js +21 -36
  8. package/dist/wj-button-group.js +24 -36
  9. package/dist/wj-button.js +37 -80
  10. package/dist/wj-card-content.js +16 -18
  11. package/dist/wj-card-controls.js +16 -18
  12. package/dist/wj-card-header.js +16 -20
  13. package/dist/wj-card-subtitle.js +17 -19
  14. package/dist/wj-card-title.js +16 -18
  15. package/dist/wj-card.js +16 -20
  16. package/dist/wj-checkbox.js +24 -46
  17. package/dist/wj-chip.js +21 -39
  18. package/dist/wj-col.js +18 -32
  19. package/dist/wj-color-picker.js +503 -868
  20. package/dist/wj-container.js +18 -20
  21. package/dist/wj-copy-button.js +66 -112
  22. package/dist/wj-dialog.js +43 -67
  23. package/dist/wj-divider.js +16 -20
  24. package/dist/wj-dropdown.js +22 -31
  25. package/dist/wj-element.js +241 -416
  26. package/dist/wj-footer.js +16 -18
  27. package/dist/wj-form.js +16 -18
  28. package/dist/wj-grid.js +17 -21
  29. package/dist/wj-header.js +18 -22
  30. package/dist/wj-icon-picker.js +66 -107
  31. package/dist/wj-icon.js +67 -140
  32. package/dist/wj-img-comparer.js +43 -72
  33. package/dist/wj-img.js +21 -31
  34. package/dist/wj-infinite-scroll.js +49 -84
  35. package/dist/wj-input.js +67 -146
  36. package/dist/wj-item.js +19 -34
  37. package/dist/wj-label.js +19 -21
  38. package/dist/wj-list.js +17 -20
  39. package/dist/wj-main.js +16 -18
  40. package/dist/wj-master.js +331 -462
  41. package/dist/wj-menu-button.js +18 -21
  42. package/dist/wj-menu-item.js +67 -144
  43. package/dist/wj-menu-label.js +17 -21
  44. package/dist/wj-menu.js +20 -24
  45. package/dist/wj-popup.js +714 -1140
  46. package/dist/wj-progress-bar.js +42 -100
  47. package/dist/wj-radio-group.js +27 -38
  48. package/dist/wj-radio.js +24 -46
  49. package/dist/wj-route.js +8 -11
  50. package/dist/wj-router-link.js +19 -22
  51. package/dist/wj-router-outlet.js +71 -135
  52. package/dist/wj-routerx.js +641 -1121
  53. package/dist/wj-row.js +20 -22
  54. package/dist/wj-slider.js +55 -97
  55. package/dist/wj-split-view.js +45 -81
  56. package/dist/wj-store.js +110 -195
  57. package/dist/wj-textarea.js +39 -86
  58. package/dist/wj-thumbnail.js +17 -19
  59. package/dist/wj-toast.js +34 -88
  60. package/dist/wj-toggle.js +24 -42
  61. package/dist/wj-toolbar-action.js +16 -27
  62. package/dist/wj-toolbar.js +21 -26
  63. package/dist/wj-tooltip.js +27 -41
  64. package/dist/wj-visually-hidden.js +16 -18
  65. package/package.json +1 -1
  66. package/dist/router-links-26e4a166.js +0 -204
@@ -1,165 +1,117 @@
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;
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 __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))
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
- 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;
10
+ e instanceof WeakSet ? e.add(o) : e.set(o, t);
19
11
  };
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
- }
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
- __publicField(this, "update", (data, action) => {
44
- this._store.dispatch(action(data));
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
- __publicField(this, "add", (data, action) => {
47
- this._store.dispatch(action(data));
26
+ a(this, "findAttributeValue", (e) => this._store.getState()[e]);
27
+ a(this, "update", (e, t) => {
28
+ this._store.dispatch(t(e));
48
29
  });
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
- });
30
+ a(this, "add", (e, t) => {
31
+ this._store.dispatch(t(e));
73
32
  });
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),
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((response) => {
110
- if (response.ok) {
111
- return response.json();
112
- } else {
113
- return response.json();
114
- }
115
- });
116
- return this.dispatch(promise, dispatchMethod, action);
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(url, action, dispatchMethod) {
119
- let promise = fetch(url, {
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 (response) => {
127
- let text;
85
+ }).then(async (n) => {
86
+ let r;
128
87
  try {
129
- let text2 = await response.text();
130
- const data = JSON.parse(text2);
131
- return data;
132
- } catch (err) {
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(promise, dispatchMethod, action);
94
+ return this.dispatch(i, s, t);
137
95
  }
138
- put(url, data, action, dispatchMethod = true) {
139
- return this._save(url, data, action, dispatchMethod, "PUT");
96
+ put(e, t, s, i = !0) {
97
+ return this._save(e, t, s, i, "PUT");
140
98
  }
141
- post(url, data, action, dispatchMethod = true) {
142
- return this._save(url, data, action, dispatchMethod, "POST");
99
+ post(e, t, s, i = !0) {
100
+ return this._save(e, t, s, i, "POST");
143
101
  }
144
- delete(url, data, action, dispatchMethod = true) {
145
- return this._save(url, data, action, dispatchMethod, "DELETE");
102
+ delete(e, t, s, i = !0) {
103
+ return this._save(e, t, s, i, "DELETE");
146
104
  }
147
- get(url, action, dispatchMethod = true) {
148
- return this._get(url, action, dispatchMethod);
105
+ get(e, t, s = !0) {
106
+ return this._get(e, t, s);
149
107
  }
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;
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 WjPermissionsApi {
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(key) {
172
- return WjPermissionsApi.permissions.includes(key);
123
+ static includesKey(e) {
124
+ return c.permissions.includes(e);
173
125
  }
174
126
  static getKeys() {
175
- let key = [];
176
- if (this.hasAttribute("permission-check")) {
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 WjPermissionsApi.getKeys.bind(this)().some((perm) => WjPermissionsApi.permissions.includes(perm)) || WjPermissionsApi.shouldShow.bind(this)();
134
+ return c.getKeys.bind(this)().some((e) => c.permissions.includes(e)) || c.shouldShow.bind(this)();
186
135
  }
187
136
  }
188
- class WjElementUtils {
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(element, object) {
197
- Object.entries(object).forEach(([key, value]) => {
198
- element.setAttribute(key, value);
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(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);
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 self;
241
- class WjEvent {
171
+ var d, l, m;
172
+ class T {
242
173
  constructor() {
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
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(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
- }
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 false;
192
+ return !1;
264
193
  }
265
- addListener(element, originalEvent, event2, listener, options) {
266
- if (!element)
194
+ addListener(e, t, s, i, n) {
195
+ if (!e)
267
196
  return;
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
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
- if (!this.listenerExists(element, originalEvent, obj)) {
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(element, event2, listener) {
291
- let record = this.findRecordByElement(element);
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(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
- }
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
- listener = listener || __privateMethod(this, _dispatch, dispatch_fn);
306
- element.removeEventListener(originalEvent, listener, options);
218
+ i = i || f(this, l, m), e.removeEventListener(t, i, n);
307
219
  }
308
- removeElement(element) {
309
- this.customEventStorage = this.customEventStorage.filter((e) => {
310
- if (e.element !== element)
311
- return e;
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
- _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, {
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: element,
324
- event: self
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 event = new WjEvent();
331
- const template = document.createElement("template");
332
- template.innerHTML = ``;
333
- class WJElement extends HTMLElement {
334
- constructor(componentTemplate) {
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
- __publicField(this, "initWjElement", async (force = false) => {
337
- var _a;
243
+ a(this, "initWjElement", async (t = !1) => {
244
+ var n;
338
245
  this.functionStack = [];
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
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.rendering = false;
359
- this.runtimeTimeout = null;
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(shadow) {
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(shadow) {
380
- return this.setAttribute("shadow", 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
- if (this.isShadowRoot) {
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 store;
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 defaultStoreActions;
304
+ return P;
418
305
  }
419
306
  get removeClassAfterConnect() {
420
- var _a;
421
- return (_a = this.getAttribute("remove-class-after-connect")) == null ? void 0 : _a.split(" ");
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(callback = () => {
314
+ makeRuntimeTimeout(t = () => {
428
315
  }) {
429
316
  return setTimeout(() => {
430
- callback();
317
+ t();
431
318
  }, 0);
432
319
  }
433
320
  refreshUpdatePromise() {
434
- this.updateComplete = new Promise((resolve, reject) => {
435
- this.finisPromise = resolve;
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 = (resolve) => {
441
- resolve();
442
- };
443
- this.rejectPromise = (reject) => {
444
- reject();
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
- 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);
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 _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);
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(name, old, newName) {
472
- if (!this.isAttached && old !== newName) {
473
- this.scheludedRefresh = true;
349
+ attributeChangedCallback(t, s, i) {
350
+ if (!this.isAttached && s !== i) {
351
+ this.scheludedRefresh = !0;
474
352
  return;
475
353
  }
476
- if (old !== newName) {
477
- this.refresh();
478
- }
354
+ s !== i && this.refresh();
479
355
  }
480
356
  async refresh() {
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
- }
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(context, store2, params) {
363
+ draw(t, s, i) {
495
364
  return null;
496
365
  }
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
- 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(processId) {
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 rend = this.draw(this.context, this.store, WjElementUtils.getAttributes(this)) || "";
523
- let element;
524
- if (rend instanceof HTMLElement || rend instanceof DocumentFragment) {
525
- element = rend;
526
- } else {
527
- let template2 = document.createElement("template");
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 rendered = element;
532
- if (this.isProcessingFlow(processId))
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(name) {
540
- let parts = name.split("-");
541
- return [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join("");
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
- let attrs = this.getAttributeNames();
549
- attrs.forEach((name) => {
550
- const sanitizedName = this.sanitizeName(name);
551
- if (this[sanitizedName] == void 0) {
552
- Object.defineProperty(this, sanitizedName, {
553
- set: (value) => this.setAttribute(name, value),
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(processId) {
562
- return !this.functionStack.find((d) => d == processId);
402
+ isProcessingFlow(t) {
403
+ return !this.functionStack.find((s) => s == t);
563
404
  }
564
- _resolveRender(processId) {
565
- if (this.isProcessingFlow(processId))
566
- return;
567
- this.params = WjElementUtils.getAttributes(this);
568
- Promise.resolve(this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this))).then((res) => {
569
- var _a;
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
- __publicField(WJElement, "processTemplates", (pTemplate, template2) => {
591
- const newTemplate = document.createElement("template");
592
- newTemplate.innerHTML = [template2.innerHTML, (pTemplate == null ? void 0 : pTemplate.innerHTML) || ""].join("");
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 __esModule = "true";
596
- customElements.get("wj-element") || customElements.define("wj-element", WJElement);
420
+ let _ = "true";
421
+ customElements.get("wj-element") || customElements.define("wj-element", S);
597
422
  export {
598
- WjElementUtils,
599
- WjPermissionsApi,
600
- __esModule,
601
- WJElement as default,
602
- event
423
+ u as WjElementUtils,
424
+ c as WjPermissionsApi,
425
+ _ as __esModule,
426
+ S as default,
427
+ k as event
603
428
  };