wj-elements 0.1.129 → 0.1.130
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/README.md +8 -4
- package/dist/assets/tags.json +3252 -22012
- package/dist/dark.css +213 -210
- package/dist/{infinite-scroll.element-R3y_ZQj6.js → infinite-scroll.element-BmojLp3Z.js} +16 -34
- package/dist/light.css +511 -501
- package/dist/{list.element-syl98NWS.js → list.element-Ce1vIm1O.js} +2 -11
- package/dist/localize.js +1 -2
- package/dist/{popup.element-C0a1z1y2.js → popup.element-4DNn6DjX.js} +102 -224
- package/dist/{router-links-I2vcmVCs.js → router-links-CJnOdbas.js} +30 -77
- package/dist/styles.css +485 -473
- package/dist/wje-accordion-item.js +12 -10
- package/dist/wje-accordion.js +51 -14
- package/dist/wje-animation.js +9 -13
- package/dist/wje-aside.js +6 -11
- package/dist/wje-avatar.js +7 -10
- package/dist/wje-badge.js +23 -18
- package/dist/wje-breadcrumb.js +30 -48
- package/dist/wje-breadcrumbs.js +80 -23
- package/dist/wje-button-group.js +15 -21
- package/dist/wje-button.js +64 -71
- package/dist/wje-card-content.js +9 -12
- package/dist/wje-card-controls.js +9 -12
- package/dist/wje-card-header.js +4 -8
- package/dist/wje-card-subtitle.js +4 -7
- package/dist/wje-card-title.js +4 -7
- package/dist/wje-card.js +13 -14
- package/dist/wje-carousel-item.js +25 -0
- package/dist/wje-carousel.js +140 -23
- package/dist/wje-checkbox.js +294 -48
- package/dist/wje-chip.js +30 -11
- package/dist/wje-col.js +7 -17
- package/dist/wje-color-picker.js +32 -34
- package/dist/wje-container.js +5 -9
- package/dist/wje-copy-button.js +11 -15
- package/dist/wje-dialog.js +12 -17
- package/dist/wje-divider.js +1 -4
- package/dist/wje-dropdown.js +41 -23
- package/dist/wje-element.js +214 -196
- package/dist/wje-file-upload-item.js +11 -21
- package/dist/wje-file-upload.js +64 -59
- package/dist/wje-footer.js +2 -9
- package/dist/wje-form.js +22 -0
- package/dist/wje-format-digital.js +4 -12
- package/dist/wje-grid.js +23 -2
- package/dist/wje-header.js +2 -9
- package/dist/wje-icon-picker.js +14 -33
- package/dist/wje-icon.js +9 -12
- package/dist/wje-img-comparer.js +7 -15
- package/dist/wje-img.js +3 -12
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-input-file.js +19 -19
- package/dist/wje-input.js +50 -66
- package/dist/wje-item.js +11 -15
- package/dist/wje-kanban.js +22 -23
- package/dist/wje-label.js +3 -11
- package/dist/wje-list.js +1 -1
- package/dist/wje-main.js +3 -10
- package/dist/wje-masonry.js +16 -21
- package/dist/wje-master.js +197 -236
- package/dist/wje-menu-button.js +4 -15
- package/dist/wje-menu-item.js +209 -37
- package/dist/wje-menu-label.js +3 -10
- package/dist/wje-menu.js +5 -17
- package/dist/wje-option.js +18 -29
- package/dist/wje-options.js +141 -55
- package/dist/wje-orgchart-group.js +8 -15
- package/dist/wje-orgchart-item.js +10 -157
- package/dist/wje-orgchart.js +3 -9
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +11 -25
- package/dist/wje-qr-code.js +27 -11
- package/dist/wje-radio-group.js +20 -45
- package/dist/wje-radio.js +45 -7
- package/dist/wje-rate.js +35 -58
- package/dist/wje-relative-time.js +19 -29
- package/dist/wje-reorder-dropzone.js +20 -2
- package/dist/wje-reorder-handle.js +62 -3
- package/dist/wje-reorder-item.js +20 -2
- package/dist/wje-reorder.js +43 -49
- package/dist/wje-route.js +2 -8
- package/dist/wje-router-link.js +9 -12
- package/dist/wje-router-outlet.js +35 -37
- package/dist/wje-routerx.js +231 -340
- package/dist/wje-row.js +7 -9
- package/dist/wje-select.js +72 -99
- package/dist/wje-slider.js +13 -32
- package/dist/wje-sliding-container.js +3 -7
- package/dist/wje-split-view.js +8 -22
- package/dist/wje-status.js +8 -12
- package/dist/wje-step.js +18 -0
- package/dist/wje-stepper.js +41 -4823
- package/dist/wje-store.js +178 -74
- package/dist/wje-tab-group.js +7 -19
- package/dist/wje-tab-panel.js +3 -12
- package/dist/wje-tab.js +5 -16
- package/dist/wje-textarea.js +127 -47
- package/dist/wje-thumbnail.js +9 -14
- package/dist/wje-toast.js +27 -64
- package/dist/wje-toggle.js +21 -32
- package/dist/wje-toolbar-action.js +10 -14
- package/dist/wje-toolbar.js +10 -15
- package/dist/wje-tooltip.js +33 -25
- package/dist/wje-visually-hidden.js +9 -13
- package/package.json +15 -8
package/dist/wje-element.js
CHANGED
|
@@ -133,37 +133,34 @@ class UniversalService {
|
|
|
133
133
|
return promise;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
class
|
|
137
|
-
constructor() {
|
|
138
|
-
this._permissionKey = "permissions";
|
|
139
|
-
}
|
|
136
|
+
const _WjePermissionsApi = class _WjePermissionsApi {
|
|
140
137
|
/**
|
|
141
138
|
* Sets the permission key.
|
|
142
139
|
* @param value
|
|
143
140
|
*/
|
|
144
141
|
static set permissionKey(value) {
|
|
145
|
-
|
|
142
|
+
_WjePermissionsApi._permissionKey = value || "permissions";
|
|
146
143
|
}
|
|
147
144
|
/**
|
|
148
145
|
* Returns the permission key.
|
|
149
146
|
* @returns {*|string}
|
|
150
147
|
*/
|
|
151
148
|
static get permissionKey() {
|
|
152
|
-
return
|
|
149
|
+
return _WjePermissionsApi._permissionKey;
|
|
153
150
|
}
|
|
154
151
|
/**
|
|
155
152
|
* Sets the permissions.
|
|
156
153
|
* @param value
|
|
157
154
|
*/
|
|
158
155
|
static set permissions(value) {
|
|
159
|
-
window.localStorage.setItem(
|
|
156
|
+
window.localStorage.setItem(_WjePermissionsApi.permissionKey, JSON.stringify(value));
|
|
160
157
|
}
|
|
161
158
|
/**
|
|
162
159
|
* Returns the permissions.
|
|
163
160
|
* @returns {string[]}
|
|
164
161
|
*/
|
|
165
162
|
static get permissions() {
|
|
166
|
-
return window.localStorage.getItem(
|
|
163
|
+
return JSON.parse(window.localStorage.getItem(_WjePermissionsApi.permissionKey)) || [];
|
|
167
164
|
}
|
|
168
165
|
/**
|
|
169
166
|
* Checks if the permission is included.
|
|
@@ -171,39 +168,23 @@ class WjePermissionsApi {
|
|
|
171
168
|
* @returns {boolean}
|
|
172
169
|
*/
|
|
173
170
|
static includesKey(key) {
|
|
174
|
-
return
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Returns the keys for the permission check.
|
|
178
|
-
* @returns {string[]}
|
|
179
|
-
*/
|
|
180
|
-
static getKeys() {
|
|
181
|
-
let key = [];
|
|
182
|
-
if (this.hasAttribute("permission-check")) {
|
|
183
|
-
key = this.getAttribute("permission-check").split(",");
|
|
184
|
-
}
|
|
185
|
-
return key;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Checks if the component should be shown.
|
|
189
|
-
* @returns {boolean}
|
|
190
|
-
*/
|
|
191
|
-
static shouldShow() {
|
|
192
|
-
return this.hasAttribute("show") && JSON.parse(this.getAttribute("show"));
|
|
171
|
+
return _WjePermissionsApi.permissions.includes(key);
|
|
193
172
|
}
|
|
194
173
|
/**
|
|
195
174
|
* Checks if the permission is fulfilled.
|
|
196
175
|
* @returns {boolean}
|
|
197
176
|
*/
|
|
198
|
-
static isPermissionFulfilled() {
|
|
199
|
-
return
|
|
177
|
+
static isPermissionFulfilled(permissions) {
|
|
178
|
+
return permissions.some((perm) => _WjePermissionsApi.permissions.includes(perm));
|
|
200
179
|
}
|
|
201
|
-
}
|
|
180
|
+
};
|
|
181
|
+
__publicField(_WjePermissionsApi, "_permissionKey", "permissions");
|
|
182
|
+
let WjePermissionsApi = _WjePermissionsApi;
|
|
202
183
|
class WjElementUtils {
|
|
203
184
|
/**
|
|
204
|
-
* This function creates an element
|
|
205
|
-
* @param element : HTMLElement
|
|
206
|
-
* @param object : Object
|
|
185
|
+
* This function creates an element.
|
|
186
|
+
* @param element : HTMLElement - The element value.
|
|
187
|
+
* @param object : Object - The object value.
|
|
207
188
|
*/
|
|
208
189
|
static setAttributesToElement(element, object) {
|
|
209
190
|
Object.entries(object).forEach(([key, value]) => {
|
|
@@ -211,41 +192,42 @@ class WjElementUtils {
|
|
|
211
192
|
});
|
|
212
193
|
}
|
|
213
194
|
/**
|
|
214
|
-
* This function gets the attributes from an element
|
|
215
|
-
* @param el
|
|
216
|
-
* @
|
|
195
|
+
* This function gets the attributes from an element.
|
|
196
|
+
* @param {string|HTMLElement} el The element or selector to retrieve attributes from.
|
|
197
|
+
* @returns {object} - An object containing the element's attributes as key-value pairs.
|
|
217
198
|
*/
|
|
218
199
|
static getAttributes(el) {
|
|
219
|
-
if (typeof el === "string")
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
200
|
+
if (typeof el === "string") el = document.querySelector(el);
|
|
201
|
+
return Array.from(el.attributes).filter((a) => !a.name.startsWith("@")).map((a) => [
|
|
202
|
+
a.name.split("-").map((s, i) => {
|
|
203
|
+
if (i !== 0) {
|
|
204
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
205
|
+
} else {
|
|
206
|
+
return s;
|
|
207
|
+
}
|
|
208
|
+
}).join(""),
|
|
209
|
+
a.value
|
|
210
|
+
]).reduce((acc, attr) => {
|
|
228
211
|
acc[attr[0]] = attr[1];
|
|
229
212
|
return acc;
|
|
230
213
|
}, {});
|
|
231
214
|
}
|
|
232
215
|
/**
|
|
233
|
-
* This function gets the events from an element
|
|
234
|
-
* @param el
|
|
235
|
-
* @returns {Map<any, any>}
|
|
216
|
+
* This function gets the events from an element.
|
|
217
|
+
* @param {string|HTMLElement} el The element or selector to retrieve events from.
|
|
218
|
+
* @returns {Map<any, any>} - The map value.
|
|
236
219
|
*/
|
|
237
220
|
static getEvents(el) {
|
|
238
|
-
if (typeof el === "string")
|
|
239
|
-
el = document.querySelector(el);
|
|
221
|
+
if (typeof el === "string") el = document.querySelector(el);
|
|
240
222
|
return Array.from(el.attributes).filter((a) => a.name.startsWith("@wje")).map((a) => [a.name.substring(3).split("-").join(""), a.value]).reduce((acc, attr) => {
|
|
241
223
|
acc.set(attr[0], attr[1]);
|
|
242
224
|
return acc;
|
|
243
225
|
}, /* @__PURE__ */ new Map());
|
|
244
226
|
}
|
|
245
227
|
/**
|
|
246
|
-
* This function converts an object to a string
|
|
247
|
-
* @param object
|
|
248
|
-
* @returns {string}
|
|
228
|
+
* This function converts an object to a string.
|
|
229
|
+
* @param {object} object The object to convert.
|
|
230
|
+
* @returns {string} - The string value.
|
|
249
231
|
*/
|
|
250
232
|
static attributesToString(object) {
|
|
251
233
|
return Object.entries(object).map(([key, value]) => {
|
|
@@ -253,20 +235,20 @@ class WjElementUtils {
|
|
|
253
235
|
}).join(" ");
|
|
254
236
|
}
|
|
255
237
|
/**
|
|
256
|
-
* This function checks if the slot exists
|
|
257
|
-
* @param el
|
|
258
|
-
* @param slotName
|
|
259
|
-
* @returns {boolean}
|
|
238
|
+
* This function checks if the slot exists.
|
|
239
|
+
* @param {string|HTMLElement} el The element or selector to check for slots.
|
|
240
|
+
* @param slotName The slot name to check for.
|
|
241
|
+
* @returns {boolean} - The boolean value.
|
|
260
242
|
*/
|
|
261
243
|
static hasSlot(el, slotName = null) {
|
|
262
244
|
let selector = slotName ? `[slot="${slotName}"]` : "[slot]";
|
|
263
245
|
return el.querySelectorAll(selector).length > 0 ? true : false;
|
|
264
246
|
}
|
|
265
247
|
/**
|
|
266
|
-
* This function checks if the slot has content
|
|
267
|
-
* @param el
|
|
268
|
-
* @param slotName
|
|
269
|
-
* @returns {boolean}
|
|
248
|
+
* This function checks if the slot has content.
|
|
249
|
+
* @param {string|HTMLElement} el The element or selector to check for slot content
|
|
250
|
+
* @param slotName The slot name to check for.
|
|
251
|
+
* @returns {boolean} - The boolean value.
|
|
270
252
|
*/
|
|
271
253
|
static hasSlotContent(el, slotName = null) {
|
|
272
254
|
let slotElement = el.querySelector(`slot`);
|
|
@@ -280,13 +262,12 @@ class WjElementUtils {
|
|
|
280
262
|
return false;
|
|
281
263
|
}
|
|
282
264
|
/**
|
|
283
|
-
* This function converts a string to a boolean
|
|
284
|
-
* @param value
|
|
285
|
-
* @returns {boolean}
|
|
265
|
+
* This function converts a string to a boolean.
|
|
266
|
+
* @param {string | object} value The value to convert to a boolean. If the value is a boolean, it will be returned as is.
|
|
267
|
+
* @returns {boolean} - The boolean value.
|
|
286
268
|
*/
|
|
287
269
|
static stringToBoolean(value) {
|
|
288
|
-
if (typeof value === "boolean")
|
|
289
|
-
return value;
|
|
270
|
+
if (typeof value === "boolean") return value;
|
|
290
271
|
return !["false", "0", 0].includes(value);
|
|
291
272
|
}
|
|
292
273
|
}
|
|
@@ -298,7 +279,7 @@ class Event {
|
|
|
298
279
|
self = this;
|
|
299
280
|
}
|
|
300
281
|
/**
|
|
301
|
-
* Dispatch custom event
|
|
282
|
+
* Dispatch custom event to the element with the specified event name and detail.
|
|
302
283
|
* @param element
|
|
303
284
|
* @param event
|
|
304
285
|
* @param detail
|
|
@@ -317,9 +298,9 @@ class Event {
|
|
|
317
298
|
);
|
|
318
299
|
}
|
|
319
300
|
/**
|
|
320
|
-
* Find record by element
|
|
301
|
+
* Find record by element in the storage.
|
|
321
302
|
* @param element
|
|
322
|
-
* @returns {
|
|
303
|
+
* @returns {*}
|
|
323
304
|
*/
|
|
324
305
|
findRecordByElement(element) {
|
|
325
306
|
for (let index = 0, length = this.customEventStorage.length; index < length; index++) {
|
|
@@ -331,7 +312,7 @@ class Event {
|
|
|
331
312
|
return false;
|
|
332
313
|
}
|
|
333
314
|
/**
|
|
334
|
-
* Add listener to the element
|
|
315
|
+
* Add listener to the element. If the element is an array, the listener will be added to all elements in the array.
|
|
335
316
|
* @param element
|
|
336
317
|
* @param originalEvent
|
|
337
318
|
* @param event
|
|
@@ -339,16 +320,14 @@ class Event {
|
|
|
339
320
|
* @param options
|
|
340
321
|
*/
|
|
341
322
|
addListener(element, originalEvent, event2, listener, options) {
|
|
342
|
-
if (!element)
|
|
343
|
-
|
|
344
|
-
if (!Array.isArray(element))
|
|
345
|
-
element = [element];
|
|
323
|
+
if (!element) return;
|
|
324
|
+
if (!Array.isArray(element)) element = [element];
|
|
346
325
|
element.forEach((el) => {
|
|
347
326
|
this.writeRecord(el, originalEvent, event2, listener, options);
|
|
348
327
|
});
|
|
349
328
|
}
|
|
350
329
|
/**
|
|
351
|
-
* Write record to the storage
|
|
330
|
+
* Write record to the storage.
|
|
352
331
|
* @param element
|
|
353
332
|
* @param originalEvent
|
|
354
333
|
* @param event
|
|
@@ -380,27 +359,26 @@ class Event {
|
|
|
380
359
|
}
|
|
381
360
|
/**
|
|
382
361
|
* Performs a deep equality check between two objects.
|
|
383
|
-
*
|
|
384
|
-
* @param
|
|
385
|
-
* @
|
|
386
|
-
* @returns {boolean} - Returns `true` if the objects are deeply equal, `false` otherwise.
|
|
362
|
+
* @param x The first object to compare.
|
|
363
|
+
* @param y The second object to compare.
|
|
364
|
+
* @returns - Returns `true` if the objects are deeply equal, `false` otherwise.
|
|
387
365
|
*/
|
|
388
366
|
deepEqual(x, y) {
|
|
389
367
|
return x && y && typeof x === "object" && typeof x === typeof y ? Object.keys(x).length === Object.keys(y).length && Object.keys(x).every((key) => this.deepEqual(x[key], y[key])) : x === y;
|
|
390
368
|
}
|
|
391
369
|
/**
|
|
392
|
-
* Check if the listener already exists
|
|
370
|
+
* Check if the listener already exists on the element.
|
|
393
371
|
* @param element
|
|
394
372
|
* @param event
|
|
395
373
|
* @param listener
|
|
396
|
-
* @returns
|
|
374
|
+
* @returns
|
|
397
375
|
*/
|
|
398
376
|
listenerExists(element, event2, listener) {
|
|
399
377
|
let record = this.findRecordByElement(element);
|
|
400
378
|
return record.listeners[event2].some((e) => this.deepEqual(e, listener));
|
|
401
379
|
}
|
|
402
380
|
/**
|
|
403
|
-
* Remove listener from the element
|
|
381
|
+
* Remove listener from the element and delete the listener from the custom event storage.
|
|
404
382
|
* @param element
|
|
405
383
|
* @param originalEvent
|
|
406
384
|
* @param event
|
|
@@ -422,8 +400,8 @@ class Event {
|
|
|
422
400
|
element.removeEventListener(originalEvent, listener, options);
|
|
423
401
|
}
|
|
424
402
|
/**
|
|
425
|
-
* Remove all listeners from the element
|
|
426
|
-
* @param element
|
|
403
|
+
* Remove all event listeners from the specified element and delete the element from the custom event storage.
|
|
404
|
+
* @param {HTMLElement} element The element from which all listeners will be removed.
|
|
427
405
|
*/
|
|
428
406
|
removeElement(element) {
|
|
429
407
|
this.customEventStorage = this.customEventStorage.filter((e) => {
|
|
@@ -443,7 +421,7 @@ class Event {
|
|
|
443
421
|
}
|
|
444
422
|
_Event_instances = new WeakSet();
|
|
445
423
|
/**
|
|
446
|
-
* Dispatch event to the element
|
|
424
|
+
* Dispatch event to the element and trigger the listener.
|
|
447
425
|
* @param e
|
|
448
426
|
*/
|
|
449
427
|
dispatch_fn = function(e) {
|
|
@@ -456,8 +434,7 @@ dispatch_fn = function(e) {
|
|
|
456
434
|
context: element,
|
|
457
435
|
event: self
|
|
458
436
|
});
|
|
459
|
-
if (listener.options && listener.options.stopPropagation === true)
|
|
460
|
-
e.stopPropagation();
|
|
437
|
+
if (listener.options && listener.options.stopPropagation === true) e.stopPropagation();
|
|
461
438
|
});
|
|
462
439
|
};
|
|
463
440
|
let event = new Event();
|
|
@@ -466,16 +443,13 @@ template.innerHTML = ``;
|
|
|
466
443
|
const _WJElement = class _WJElement extends HTMLElement {
|
|
467
444
|
/**
|
|
468
445
|
* Initializes a new instance of the WJElement class.
|
|
469
|
-
*
|
|
470
|
-
* @param {HTMLTemplateElement} [componentTemplate] - The template to use for this component.
|
|
471
446
|
*/
|
|
472
|
-
constructor(
|
|
447
|
+
constructor() {
|
|
473
448
|
super();
|
|
474
449
|
/**
|
|
475
450
|
* Initializes the component, setting up attributes and rendering.
|
|
476
|
-
*
|
|
477
|
-
* @
|
|
478
|
-
* @return {Promise<void>} A promise that resolves when initialization is complete.
|
|
451
|
+
* @param [force] Whether to force initialization.
|
|
452
|
+
* @returns A promise that resolves when initialization is complete.
|
|
479
453
|
*/
|
|
480
454
|
__publicField(this, "initWjElement", (force = false) => {
|
|
481
455
|
return new Promise(async (resolve, reject) => {
|
|
@@ -483,8 +457,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
483
457
|
this.drawingStatus = this.drawingStatuses.BEGINING;
|
|
484
458
|
(_a = this.setupAttributes) == null ? void 0 : _a.call(this);
|
|
485
459
|
if (this.isShadowRoot) {
|
|
486
|
-
if (!this.shadowRoot)
|
|
487
|
-
this.attachShadow({ mode: this.shadowType || "open" });
|
|
460
|
+
if (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || "open" });
|
|
488
461
|
}
|
|
489
462
|
this.setUpAccessors();
|
|
490
463
|
this.drawingStatus = this.drawingStatuses.START;
|
|
@@ -495,7 +468,6 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
495
468
|
resolve();
|
|
496
469
|
});
|
|
497
470
|
});
|
|
498
|
-
this.template = componentTemplate || template;
|
|
499
471
|
this.isAttached = false;
|
|
500
472
|
this.service = new UniversalService({
|
|
501
473
|
store
|
|
@@ -514,66 +486,71 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
514
486
|
};
|
|
515
487
|
this.drawingStatus = this.drawingStatuses.CREATED;
|
|
516
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* Sets the value of the 'permission' attribute.
|
|
491
|
+
* @param {string[]} value The value to set for the 'permission' attribute.
|
|
492
|
+
*/
|
|
493
|
+
set permission(value) {
|
|
494
|
+
this.setAttribute("permission", value.join(","));
|
|
495
|
+
}
|
|
517
496
|
/**
|
|
518
497
|
* Gets the value of the 'permission-check' attribute.
|
|
519
|
-
*
|
|
520
|
-
* @return {string|null} The value of the 'permission-check' attribute or null if not set.
|
|
498
|
+
* @returns {string[]} The value of the 'permission' attribute.
|
|
521
499
|
*/
|
|
522
500
|
get permission() {
|
|
523
|
-
|
|
501
|
+
var _a;
|
|
502
|
+
return ((_a = this.getAttribute("permission")) == null ? void 0 : _a.split(",")) || [];
|
|
524
503
|
}
|
|
525
504
|
/**
|
|
526
505
|
* Sets the 'permission-check' attribute.
|
|
527
|
-
*
|
|
528
|
-
* @param {string} shadow - The value to set for the 'permission-check' attribute.
|
|
506
|
+
* @param {boolean} value The value to set for the 'permission-check' attribute.
|
|
529
507
|
*/
|
|
530
|
-
set isPermissionCheck(
|
|
531
|
-
|
|
508
|
+
set isPermissionCheck(value) {
|
|
509
|
+
if (value) this.setAttribute("permission-check", "");
|
|
510
|
+
else this.removeAttribute("permission-check");
|
|
532
511
|
}
|
|
533
512
|
/**
|
|
534
513
|
* Checks if the 'permission-check' attribute is present.
|
|
535
|
-
*
|
|
536
|
-
* @return {boolean} True if the 'permission-check' attribute is present.
|
|
514
|
+
* @returns {boolean} True if the 'permission-check' attribute is present.
|
|
537
515
|
*/
|
|
538
516
|
get isPermissionCheck() {
|
|
539
517
|
return this.hasAttribute("permission-check");
|
|
540
518
|
}
|
|
519
|
+
set noShow(value) {
|
|
520
|
+
if (value) this.setAttribute("no-show", "");
|
|
521
|
+
else this.removeAttribute("no-show");
|
|
522
|
+
}
|
|
541
523
|
/**
|
|
542
524
|
* Checks if the 'show' attribute is present.
|
|
543
|
-
*
|
|
544
|
-
* @return {boolean} True if the 'show' attribute is present.
|
|
525
|
+
* @returns {boolean} True if the 'show' attribute is present.
|
|
545
526
|
*/
|
|
546
|
-
get
|
|
547
|
-
return this.hasAttribute("show");
|
|
527
|
+
get noShow() {
|
|
528
|
+
return this.hasAttribute("no-show");
|
|
548
529
|
}
|
|
549
530
|
/**
|
|
550
531
|
* Sets the 'shadow' attribute.
|
|
551
|
-
*
|
|
552
|
-
* @param {string} shadow - The value to set for the 'shadow' attribute.
|
|
532
|
+
* @param value The value to set for the 'shadow' attribute.
|
|
553
533
|
*/
|
|
554
534
|
set isShadowRoot(value) {
|
|
555
535
|
return this.setAttribute("shadow", value);
|
|
556
536
|
}
|
|
557
537
|
/**
|
|
558
538
|
* Checks if the 'shadow' attribute is present.
|
|
559
|
-
*
|
|
560
|
-
* @return {boolean} True if the 'shadow' attribute is present.
|
|
539
|
+
* @returns {boolean} True if the 'shadow' attribute is present.
|
|
561
540
|
*/
|
|
562
541
|
get isShadowRoot() {
|
|
563
542
|
return this.hasAttribute("shadow");
|
|
564
543
|
}
|
|
565
544
|
/**
|
|
566
545
|
* Gets the value of the 'shadow' attribute or 'open' if not set.
|
|
567
|
-
*
|
|
568
|
-
* @return {string} The value of the 'shadow' attribute or 'open'.
|
|
546
|
+
* @returns {string} The value of the 'shadow' attribute or 'open'.
|
|
569
547
|
*/
|
|
570
548
|
get shadowType() {
|
|
571
549
|
return this.getAttribute("shadow") || "open";
|
|
572
550
|
}
|
|
573
551
|
/**
|
|
574
552
|
* Gets the rendering context, either the shadow root or the component itself.
|
|
575
|
-
*
|
|
576
|
-
* @return {HTMLElement|ShadowRoot} The rendering context.
|
|
553
|
+
* @returns The rendering context.
|
|
577
554
|
*/
|
|
578
555
|
get context() {
|
|
579
556
|
if (this.isShadowRoot) {
|
|
@@ -584,38 +561,35 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
584
561
|
}
|
|
585
562
|
/**
|
|
586
563
|
* Gets the store instance.
|
|
587
|
-
*
|
|
588
|
-
* @return {Object} The store instance.
|
|
564
|
+
* @returns {object} The store instance.
|
|
589
565
|
*/
|
|
590
566
|
get store() {
|
|
591
567
|
return store;
|
|
592
568
|
}
|
|
593
569
|
/**
|
|
594
|
-
* @typedef {
|
|
595
|
-
* @property {
|
|
596
|
-
* @property {
|
|
597
|
-
* @property {
|
|
598
|
-
* @property {
|
|
599
|
-
* @property {
|
|
570
|
+
* @typedef {object} ArrayActions
|
|
571
|
+
* @property {Function} addAction - Adds an item to the array.
|
|
572
|
+
* @property {Function} deleteAction - Deletes an item from the array.
|
|
573
|
+
* @property {Function} loadAction - Loads an array.
|
|
574
|
+
* @property {Function} updateAction - Updates an item in the array.
|
|
575
|
+
* @property {Function} addManyAction - Adds many items to the array.
|
|
600
576
|
*/
|
|
601
577
|
/**
|
|
602
|
-
* @typedef {
|
|
603
|
-
* @property {
|
|
604
|
-
* @property {
|
|
605
|
-
* @property {
|
|
578
|
+
* @typedef {object} ObjectActions
|
|
579
|
+
* @property {Function} addAction - Replace old object with new object
|
|
580
|
+
* @property {Function} deleteAction - Delete item based on key
|
|
581
|
+
* @property {Function} updateAction - Update item based on key
|
|
606
582
|
*/
|
|
607
583
|
/**
|
|
608
584
|
* Gets the default store actions.
|
|
609
|
-
*
|
|
610
|
-
* @return {ArrayActions|ObjectActions} The default store actions.
|
|
585
|
+
* @returns The default store actions for arrays and objects.
|
|
611
586
|
*/
|
|
612
587
|
get defaultStoreActions() {
|
|
613
588
|
return defaultStoreActions;
|
|
614
589
|
}
|
|
615
590
|
/**
|
|
616
591
|
* Gets the classes to be removed after the component is connected.
|
|
617
|
-
*
|
|
618
|
-
* @return {Array<string>} An array of class names to remove.
|
|
592
|
+
* @returns An array of class names to remove.
|
|
619
593
|
*/
|
|
620
594
|
get removeClassAfterConnect() {
|
|
621
595
|
var _a;
|
|
@@ -623,26 +597,23 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
623
597
|
}
|
|
624
598
|
/**
|
|
625
599
|
* Sets the component dependencies.
|
|
626
|
-
*
|
|
627
|
-
* @param {Object} value - The dependencies to set.
|
|
600
|
+
* @param value The dependencies to set.
|
|
628
601
|
*/
|
|
629
602
|
set dependencies(value) {
|
|
630
603
|
this._dependencies = value;
|
|
631
604
|
}
|
|
632
605
|
/**
|
|
633
606
|
* Gets the component dependencies.
|
|
634
|
-
*
|
|
635
|
-
* @return {Object} The dependencies.
|
|
607
|
+
* @returns The component dependencies.
|
|
636
608
|
*/
|
|
637
609
|
get dependencies() {
|
|
638
610
|
return this._dependencies;
|
|
639
611
|
}
|
|
640
612
|
/**
|
|
641
613
|
* Defines a custom element if not already defined.
|
|
642
|
-
*
|
|
643
|
-
* @param
|
|
644
|
-
* @param
|
|
645
|
-
* @param {Object} [options={}] - Additional options for defining the element.
|
|
614
|
+
* @param name The name of the custom element.
|
|
615
|
+
* @param [elementConstructor] The constructor for the custom element.
|
|
616
|
+
* @param [options] Additional options for defining the element.
|
|
646
617
|
*/
|
|
647
618
|
static define(name, elementConstructor = this, options = {}) {
|
|
648
619
|
const definedElement = customElements.get(name);
|
|
@@ -659,21 +630,40 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
659
630
|
}
|
|
660
631
|
/**
|
|
661
632
|
* Hook for extending behavior before drawing the component.
|
|
662
|
-
*
|
|
663
|
-
* @param
|
|
664
|
-
* @param
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
633
|
+
* @param context The rendering context, usually the element's shadow root or main DOM element.
|
|
634
|
+
* @param appStoreObj The global application store for managing state.
|
|
635
|
+
* @param params Additional parameters or attributes for rendering the component.
|
|
636
|
+
*/
|
|
637
|
+
beforeDraw(context, appStoreObj, params) {
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Renders the component within the provided context.
|
|
641
|
+
* @param context The rendering context, usually the element's shadow root or main DOM element.
|
|
642
|
+
* @param appStoreObj
|
|
643
|
+
* @param params Additional parameters or attributes for rendering the component.
|
|
644
|
+
* @returns This implementation does not render anything and returns `null`.
|
|
645
|
+
* @description
|
|
646
|
+
* The `draw` method is responsible for rendering the component's content.
|
|
647
|
+
* Override this method in subclasses to define custom rendering logic.
|
|
648
|
+
* @example
|
|
649
|
+
* class MyComponent extends WJElement {
|
|
650
|
+
* draw(context, appStoreObj, params) {
|
|
651
|
+
* const div = document.createElement('div');
|
|
652
|
+
* div.textContent = 'Hello, world!';
|
|
653
|
+
* context.appendChild(div);
|
|
654
|
+
* }
|
|
655
|
+
* }
|
|
656
|
+
*/
|
|
657
|
+
draw(context, appStoreObj, params) {
|
|
658
|
+
return null;
|
|
668
659
|
}
|
|
669
660
|
/**
|
|
670
661
|
* Hook for extending behavior after drawing the component.
|
|
671
|
-
*
|
|
672
|
-
* @param
|
|
673
|
-
* @param
|
|
674
|
-
* @param {Object} attributes - The component attributes.
|
|
662
|
+
* @param context The rendering context, usually the element's shadow root or main DOM element.
|
|
663
|
+
* @param appStoreObj The global application store for managing state.
|
|
664
|
+
* @param params Additional parameters or attributes for rendering the component.
|
|
675
665
|
*/
|
|
676
|
-
afterDraw(context,
|
|
666
|
+
afterDraw(context, appStoreObj, params) {
|
|
677
667
|
}
|
|
678
668
|
/**
|
|
679
669
|
* Refreshes the update promise for rendering lifecycle management.
|
|
@@ -700,6 +690,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
700
690
|
}
|
|
701
691
|
/**
|
|
702
692
|
* Sets up attributes and event listeners for the component.
|
|
693
|
+
* This method retrieves all custom events defined for the component
|
|
694
|
+
* and adds event listeners for each of them. When an event is triggered,
|
|
695
|
+
* it calls the corresponding method on the host element.
|
|
703
696
|
*/
|
|
704
697
|
setupAttributes() {
|
|
705
698
|
let allEvents = WjElementUtils.getEvents(this);
|
|
@@ -744,8 +737,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
744
737
|
}
|
|
745
738
|
/**
|
|
746
739
|
* Enqueues an update to the component.
|
|
747
|
-
*
|
|
748
|
-
* @return {Promise<void>} A promise that resolves when the update is complete.
|
|
740
|
+
* @returns A promise that resolves when the update is complete.
|
|
749
741
|
*/
|
|
750
742
|
async enqueueUpdate() {
|
|
751
743
|
try {
|
|
@@ -764,10 +756,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
764
756
|
}
|
|
765
757
|
/**
|
|
766
758
|
* Lifecycle method invoked when an observed attribute changes.
|
|
767
|
-
*
|
|
768
|
-
* @param
|
|
769
|
-
* @param
|
|
770
|
-
* @param {string} newName - The new value of the attribute.
|
|
759
|
+
* @param name The name of the attribute that changed.
|
|
760
|
+
* @param old The old value of the attribute.
|
|
761
|
+
* @param newName The new value of the attribute.
|
|
771
762
|
*/
|
|
772
763
|
attributeChangedCallback(name, old, newName) {
|
|
773
764
|
if (old !== newName) {
|
|
@@ -775,9 +766,16 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
775
766
|
}
|
|
776
767
|
}
|
|
777
768
|
/**
|
|
778
|
-
* Refreshes the component.
|
|
779
|
-
*
|
|
780
|
-
*
|
|
769
|
+
* Refreshes the component by reinitializing it if it is in a drawing state.
|
|
770
|
+
* This method checks if the component's drawing status is at least in the START state.
|
|
771
|
+
* If so, it performs the following steps:
|
|
772
|
+
* 1. Calls the `beforeRedraw` hook if defined.
|
|
773
|
+
* 2. Calls the `beforeDisconnect` hook if defined.
|
|
774
|
+
* 3. Refreshes the update promise to manage the rendering lifecycle.
|
|
775
|
+
* 4. Calls the `afterDisconnect` hook if defined.
|
|
776
|
+
* 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.
|
|
777
|
+
* If the component is not in a drawing state, it simply returns a resolved promise.
|
|
778
|
+
* @returns {Promise<void>} A promise that resolves when the refresh is complete.
|
|
781
779
|
*/
|
|
782
780
|
refresh() {
|
|
783
781
|
var _a, _b, _c;
|
|
@@ -791,39 +789,43 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
791
789
|
return Promise.resolve();
|
|
792
790
|
}
|
|
793
791
|
/**
|
|
794
|
-
*
|
|
795
|
-
*
|
|
796
|
-
* @param
|
|
797
|
-
* @param
|
|
798
|
-
* @
|
|
799
|
-
* @
|
|
792
|
+
* Renders the component within the provided context.
|
|
793
|
+
* @param context The rendering context, usually the element's shadow root or main DOM element.
|
|
794
|
+
* @param appStore The global application store for managing state.
|
|
795
|
+
* @param params Additional parameters or attributes for rendering the component.
|
|
796
|
+
* @returns This implementation does not render anything and returns `null`.
|
|
797
|
+
* @description
|
|
798
|
+
* The `draw` method is responsible for rendering the component's content.
|
|
799
|
+
* Override this method in subclasses to define custom rendering logic.
|
|
800
|
+
* @example
|
|
801
|
+
* class MyComponent extends WJElement {
|
|
802
|
+
* draw(context, appStore, params) {
|
|
803
|
+
* const div = document.createElement('div');
|
|
804
|
+
* div.textContent = 'Hello, world!';
|
|
805
|
+
* context.appendChild(div);
|
|
806
|
+
* }
|
|
807
|
+
* }
|
|
800
808
|
*/
|
|
801
809
|
draw(context, appStore, params) {
|
|
802
810
|
return null;
|
|
803
811
|
}
|
|
804
812
|
/**
|
|
805
813
|
* Displays the component's content, optionally forcing a re-render.
|
|
806
|
-
*
|
|
807
|
-
* @
|
|
808
|
-
* @return {Promise<void>} A promise that resolves when the display is complete.
|
|
814
|
+
* @param [force] Whether to force a re-render.
|
|
815
|
+
* @returns A promise that resolves when the display is complete.
|
|
809
816
|
*/
|
|
810
817
|
display(force = false) {
|
|
818
|
+
this.template = this.constructor.customTemplate || document.createElement("template");
|
|
811
819
|
if (force) {
|
|
812
820
|
[...this.context.childNodes].forEach(this.context.removeChild.bind(this.context));
|
|
813
821
|
this.isAttached = false;
|
|
814
822
|
}
|
|
815
823
|
this.context.append(this.template.content.cloneNode(true));
|
|
816
|
-
if (this.
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
return this._resolveRender();
|
|
820
|
-
} else {
|
|
821
|
-
this.remove();
|
|
822
|
-
return Promise.resolve();
|
|
823
|
-
}
|
|
824
|
-
} else {
|
|
825
|
-
return this._resolveRender();
|
|
824
|
+
if (this.noShow || this.isPermissionCheck && !WjePermissionsApi.isPermissionFulfilled(this.permission)) {
|
|
825
|
+
this.remove();
|
|
826
|
+
return Promise.resolve();
|
|
826
827
|
}
|
|
828
|
+
return this._resolveRender();
|
|
827
829
|
}
|
|
828
830
|
/**
|
|
829
831
|
* Renders the component's content.
|
|
@@ -847,21 +849,38 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
847
849
|
this.context.appendChild(rendered);
|
|
848
850
|
}
|
|
849
851
|
/**
|
|
850
|
-
*
|
|
851
|
-
*
|
|
852
|
-
* @
|
|
853
|
-
* @
|
|
852
|
+
* Sanitizes a given name by converting it from kebab-case to camelCase.
|
|
853
|
+
* @param {string} name The name in kebab-case format (e.g., "example-name").
|
|
854
|
+
* @returns {string} The sanitized name in camelCase format (e.g., "exampleName").
|
|
855
|
+
* @example
|
|
856
|
+
* // Returns 'exampleName'
|
|
857
|
+
* sanitizeName('example-name');
|
|
858
|
+
* @example
|
|
859
|
+
* // Returns 'myCustomComponent'
|
|
860
|
+
* sanitizeName('my-custom-component');
|
|
854
861
|
*/
|
|
855
862
|
sanitizeName(name) {
|
|
856
863
|
let parts = name.split("-");
|
|
857
864
|
return [parts.shift(), ...parts.map((n) => n[0].toUpperCase() + n.slice(1))].join("");
|
|
858
865
|
}
|
|
859
866
|
/**
|
|
860
|
-
* Checks if an object
|
|
861
|
-
*
|
|
862
|
-
* @param {
|
|
863
|
-
* @
|
|
864
|
-
* @
|
|
867
|
+
* Checks if a property on an object has a getter or setter method defined.
|
|
868
|
+
* @param {object} obj The object on which the property is defined.
|
|
869
|
+
* @param {string} property The name of the property to check.
|
|
870
|
+
* @returns {object} An object indicating the presence of getter and setter methods.
|
|
871
|
+
* @property {Function|null} hasGetter The getter function if it exists, otherwise `null`.
|
|
872
|
+
* @property {Function|null} hasSetter The setter function if it exists, otherwise `null`.
|
|
873
|
+
* @example
|
|
874
|
+
* const obj = {
|
|
875
|
+
* get name() { return 'value'; },
|
|
876
|
+
* set name(val) { console.log(val); }
|
|
877
|
+
* };
|
|
878
|
+
* // Returns { hasGetter: [Function: get name], hasSetter: [Function: set name] }
|
|
879
|
+
* checkGetterSetter(obj, 'name');
|
|
880
|
+
* @example
|
|
881
|
+
* const obj = { prop: 42 };
|
|
882
|
+
* // Returns { hasGetter: null, hasSetter: null }
|
|
883
|
+
* checkGetterSetter(obj, 'prop');
|
|
865
884
|
*/
|
|
866
885
|
checkGetterSetter(obj, property) {
|
|
867
886
|
let descriptor = Object.getOwnPropertyDescriptor(obj, property);
|
|
@@ -893,8 +912,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
893
912
|
}
|
|
894
913
|
/**
|
|
895
914
|
* Resolves the rendering process of the component.
|
|
896
|
-
*
|
|
897
|
-
* @return {Promise<void>} A promise that resolves when rendering is complete.
|
|
915
|
+
* @returns A promise that resolves when rendering is complete.
|
|
898
916
|
* @private
|
|
899
917
|
*/
|
|
900
918
|
_resolveRender() {
|
|
@@ -913,8 +931,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
913
931
|
this.finisPromise();
|
|
914
932
|
this.rendering = false;
|
|
915
933
|
this.isAttached = true;
|
|
916
|
-
if (this.removeClassAfterConnect)
|
|
934
|
+
if (this.removeClassAfterConnect) {
|
|
917
935
|
this.classList.remove(...this.removeClassAfterConnect);
|
|
936
|
+
}
|
|
918
937
|
this.drawingStatus = this.drawingStatuses.DONE;
|
|
919
938
|
resolve();
|
|
920
939
|
}).catch((e) => {
|
|
@@ -924,10 +943,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
924
943
|
};
|
|
925
944
|
/**
|
|
926
945
|
* Processes and combines two templates into one.
|
|
927
|
-
*
|
|
928
|
-
* @param
|
|
929
|
-
* @
|
|
930
|
-
* @return {HTMLTemplateElement} The combined template.
|
|
946
|
+
* @param pTemplate The primary template.
|
|
947
|
+
* @param inputTemplate The secondary template.
|
|
948
|
+
* @returns The combined template.
|
|
931
949
|
*/
|
|
932
950
|
__publicField(_WJElement, "processTemplates", (pTemplate, inputTemplate) => {
|
|
933
951
|
const newTemplate = document.createElement("template");
|