wj-elements 0.1.174 → 0.1.175
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/packages/wje-element/element.d.ts +28 -31
- package/dist/packages/wje-select/select.element.d.ts +17 -6
- package/dist/packages/wje-stepper/stepper.element.d.ts +7 -6
- package/dist/wje-element.js +101 -100
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-orgchart-item.js +1 -1
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-select.js +25 -26
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-stepper.js +79 -31
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-tree-item.js +2 -4
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +4 -0
- package/dist/wje-tree.js.map +1 -1
- package/package.json +2 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
|
@@ -18,12 +18,10 @@ export default class WJElement extends HTMLElement {
|
|
|
18
18
|
* @param [options] Additional options for defining the element.
|
|
19
19
|
*/
|
|
20
20
|
static define(name: any, elementConstructor?: typeof WJElement, options?: {}): void;
|
|
21
|
-
isAttached: boolean;
|
|
22
21
|
service: UniversalService;
|
|
23
|
-
rendering: boolean;
|
|
24
22
|
_dependencies: {};
|
|
25
23
|
/**
|
|
26
|
-
* @typedef {
|
|
24
|
+
* @typedef {object} DrawingStatuses
|
|
27
25
|
* @property {number} CREATED - The component has been created.
|
|
28
26
|
* @property {number} ATTACHED - The component has been attached to the DOM.
|
|
29
27
|
* @property {number} BEGINING - The component is beginning to draw.
|
|
@@ -32,6 +30,30 @@ export default class WJElement extends HTMLElement {
|
|
|
32
30
|
* @property {number} DONE - The component has finished drawing.
|
|
33
31
|
* @property {number} DISCONNECTED - The component has been disconnected from the DOM.
|
|
34
32
|
*/
|
|
33
|
+
/**
|
|
34
|
+
* WJElement is a base class for custom web components with managed lifecycle, attribute/property sync,
|
|
35
|
+
* permission-based visibility, and extensibility hooks.
|
|
36
|
+
* @property {boolean} isAttached - True if the component is currently attached to the DOM.
|
|
37
|
+
* @property {DrawingStatuses} drawingStatuses - Enum of possible drawing states.
|
|
38
|
+
* @property {number} drawingStatus - Current drawing status (see drawingStatuses).
|
|
39
|
+
* @property {boolean} _pristine - True if the component has not been updated since last render.
|
|
40
|
+
* @property {boolean} isRendering - True if a render is currently in progress.
|
|
41
|
+
* @property {number|null} rafId - ID of the scheduled animation frame for rendering, or null.
|
|
42
|
+
* @property {string|null} originalVisibility - Stores the original CSS visibility before rendering.
|
|
43
|
+
* @property {object} params - Stores the current attributes/properties for rendering.
|
|
44
|
+
* @property {Promise<void>} updateComplete - Promise resolved when the current update/render is complete.
|
|
45
|
+
* @property {string[]} permission - List of required permissions (from 'permission' attribute).
|
|
46
|
+
* @property {boolean} isPermissionCheck - Whether permission checking is enabled (from 'permission-check' attribute).
|
|
47
|
+
* @property {boolean} noShow - Whether the element should be hidden (from 'no-show' attribute).
|
|
48
|
+
* @property {string|undefined} isShadowRoot - Value of the 'shadow' attribute, if present.
|
|
49
|
+
* @property {boolean} hasShadowRoot - True if the 'shadow' attribute is present.
|
|
50
|
+
* @property {string} shadowType - Type of shadow root ('open' by default).
|
|
51
|
+
* @property {object} store - Reference to the global store instance.
|
|
52
|
+
* @property {object} defaultStoreActions - Default store actions for arrays and objects.
|
|
53
|
+
* @property {string[]|undefined} removeClassAfterConnect - Classes to remove after connect (from 'remove-class-after-connect' attribute).
|
|
54
|
+
* @property {object} dependencies - Registered component dependencies.
|
|
55
|
+
* @property {HTMLElement|ShadowRoot} context - The rendering context (shadow root or element itself).
|
|
56
|
+
*/
|
|
35
57
|
drawingStatuses: {
|
|
36
58
|
CREATED: number;
|
|
37
59
|
ATTACHED: number;
|
|
@@ -41,16 +63,12 @@ export default class WJElement extends HTMLElement {
|
|
|
41
63
|
DONE: number;
|
|
42
64
|
DISCONNECTED: number;
|
|
43
65
|
};
|
|
44
|
-
drawingStatus: number;
|
|
45
|
-
_pristine: boolean;
|
|
46
|
-
_pristineCauseWeakMap: WeakMap<WeakKey, any>;
|
|
47
|
-
isRendering: boolean;
|
|
48
66
|
rafId: number;
|
|
49
|
-
originalVisibility: any;
|
|
50
67
|
params: {};
|
|
51
68
|
updateComplete: Promise<any>;
|
|
52
69
|
finisPromise: (value: any) => void;
|
|
53
70
|
rejectPromise: (reason?: any) => void;
|
|
71
|
+
get drawingStatus(): number;
|
|
54
72
|
/**
|
|
55
73
|
* Sets the value of the 'permission' attribute.
|
|
56
74
|
* @param {string[]} value The value to set for the 'permission' attribute.
|
|
@@ -97,7 +115,7 @@ export default class WJElement extends HTMLElement {
|
|
|
97
115
|
* Gets the rendering context, either the shadow root or the component itself.
|
|
98
116
|
* @returns The rendering context.
|
|
99
117
|
*/
|
|
100
|
-
get context():
|
|
118
|
+
get context(): this | ShadowRoot;
|
|
101
119
|
/**
|
|
102
120
|
* Gets the store instance.
|
|
103
121
|
* @returns {object} The store instance.
|
|
@@ -243,18 +261,6 @@ export default class WJElement extends HTMLElement {
|
|
|
243
261
|
*/
|
|
244
262
|
attributeChangedCallback(name: any, old: any, newName: any): void;
|
|
245
263
|
refresh(): void;
|
|
246
|
-
/**
|
|
247
|
-
* Refreshes the component by reinitializing it if it is in a drawing state.
|
|
248
|
-
* This method checks if the component's drawing status is at least in the START state.
|
|
249
|
-
* If so, it performs the following steps:
|
|
250
|
-
* 1. Calls the `beforeRedraw` hook if defined.
|
|
251
|
-
* 2. Calls the `beforeDisconnect` hook if defined.
|
|
252
|
-
* 3. Refreshes the update promise to manage the rendering lifecycle.
|
|
253
|
-
* 4. Calls the `afterDisconnect` hook if defined.
|
|
254
|
-
* 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.
|
|
255
|
-
* If the component is not in a drawing state, it simply returns a resolved promise.
|
|
256
|
-
*/
|
|
257
|
-
_refresh(): Promise<void>;
|
|
258
264
|
stopRenderLoop(): void;
|
|
259
265
|
/**
|
|
260
266
|
* Displays the component's content, optionally forcing a re-render.
|
|
@@ -272,10 +278,8 @@ export default class WJElement extends HTMLElement {
|
|
|
272
278
|
* @param {string} name The name in kebab-case format (e.g., "example-name").
|
|
273
279
|
* @returns {string} The sanitized name in camelCase format (e.g., "exampleName").
|
|
274
280
|
* @example
|
|
275
|
-
* // Returns 'exampleName'
|
|
276
281
|
* sanitizeName('example-name');
|
|
277
282
|
* @example
|
|
278
|
-
* // Returns 'myCustomComponent'
|
|
279
283
|
* sanitizeName('my-custom-component');
|
|
280
284
|
*/
|
|
281
285
|
sanitizeName(name: string): string;
|
|
@@ -291,11 +295,9 @@ export default class WJElement extends HTMLElement {
|
|
|
291
295
|
* get name() { return 'value'; },
|
|
292
296
|
* set name(val) { console.log(val); }
|
|
293
297
|
* };
|
|
294
|
-
* // Returns { hasGetter: [Function: get name], hasSetter: [Function: set name] }
|
|
295
298
|
* checkGetterSetter(obj, 'name');
|
|
296
299
|
* @example
|
|
297
300
|
* const obj = { prop: 42 };
|
|
298
|
-
* // Returns { hasGetter: null, hasSetter: null }
|
|
299
301
|
* checkGetterSetter(obj, 'prop');
|
|
300
302
|
*/
|
|
301
303
|
checkGetterSetter(obj: object, property: string): object;
|
|
@@ -303,12 +305,7 @@ export default class WJElement extends HTMLElement {
|
|
|
303
305
|
* Sets up property accessors for the component's attributes.
|
|
304
306
|
*/
|
|
305
307
|
setUpAccessors(): void;
|
|
306
|
-
|
|
307
|
-
* Resolves the rendering process of the component.
|
|
308
|
-
* @returns A promise that resolves when rendering is complete.
|
|
309
|
-
* @private
|
|
310
|
-
*/
|
|
311
|
-
private _resolveRender;
|
|
308
|
+
#private;
|
|
312
309
|
}
|
|
313
310
|
export let __esModule: string;
|
|
314
311
|
export { WjePermissionsApi, WjElementUtils, event };
|
|
@@ -164,9 +164,9 @@ export default class Select extends WJElement {
|
|
|
164
164
|
set value(value: string);
|
|
165
165
|
/**
|
|
166
166
|
* Getter for the value attribute.
|
|
167
|
-
* @returns {
|
|
167
|
+
* @returns {object} The value of the attribute.
|
|
168
168
|
*/
|
|
169
|
-
get value():
|
|
169
|
+
get value(): object;
|
|
170
170
|
/**
|
|
171
171
|
* Getter for the customErrorDisplay attribute.
|
|
172
172
|
* @returns {boolean} Whether the attribute is present.
|
|
@@ -318,10 +318,21 @@ export default class Select extends WJElement {
|
|
|
318
318
|
*/
|
|
319
319
|
selectionChanged(option?: Element, length?: number): void;
|
|
320
320
|
/**
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
* @
|
|
324
|
-
* @
|
|
321
|
+
* Updates the selected options and their corresponding chips.
|
|
322
|
+
* @param {boolean} [silence] Determines whether to suppress the "wje-select:change" event.
|
|
323
|
+
* @returns {void}
|
|
324
|
+
* @description
|
|
325
|
+
* This method fetches the currently selected options and updates the `selectedOptions` array.
|
|
326
|
+
* It clears and rebuilds the chips representing the selected items in the UI.
|
|
327
|
+
* If the number of selected options reaches the maximum allowed (`maxOptions`), it stops updating the counter.
|
|
328
|
+
* Optionally, it dispatches a custom event when the selection changes unless `silence` is set to `true`.
|
|
329
|
+
* //@fires wje-select:change - Dispatched when the selection changes, unless `silence` is `true`.
|
|
330
|
+
* @example
|
|
331
|
+
* // Call the method and allow event dispatch
|
|
332
|
+
* selections();
|
|
333
|
+
* @example
|
|
334
|
+
* // Call the method without dispatching the event
|
|
335
|
+
* selections(true);
|
|
325
336
|
*/
|
|
326
337
|
selections(silence?: boolean): void;
|
|
327
338
|
/**
|
|
@@ -19,6 +19,7 @@ export default class Stepper extends WJElement {
|
|
|
19
19
|
currentStep: number;
|
|
20
20
|
localizer: Localizer;
|
|
21
21
|
steps: any[];
|
|
22
|
+
headerSteps: any[];
|
|
22
23
|
get active(): string;
|
|
23
24
|
get done(): string;
|
|
24
25
|
/**
|
|
@@ -27,10 +28,10 @@ export default class Stepper extends WJElement {
|
|
|
27
28
|
*/
|
|
28
29
|
draw(): DocumentFragment;
|
|
29
30
|
header: HTMLDivElement;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
processStep(index: any, step: any, header: any, steps: any):
|
|
31
|
+
prev: HTMLSlotElement;
|
|
32
|
+
next: HTMLSlotElement;
|
|
33
|
+
finish: HTMLSlotElement;
|
|
34
|
+
processStep(index: any, step: any, header: any, steps: any): HTMLDivElement;
|
|
34
35
|
/**
|
|
35
36
|
* Sets up the attributes for the component.
|
|
36
37
|
*/
|
|
@@ -44,12 +45,11 @@ export default class Stepper extends WJElement {
|
|
|
44
45
|
/**
|
|
45
46
|
* Navigates to a specific step in a multi-step process and updates the stepper UI accordingly.
|
|
46
47
|
* @param {number} stepIndex The index of the step to navigate to.
|
|
47
|
-
* @param {number} direction The navigation direction. A positive value indicates forward navigation, and a negative value indicates backward navigation.
|
|
48
48
|
* //@fires stepper:next Dispatched when navigating to the next step.
|
|
49
49
|
* //@fires stepper:prev Dispatched when navigating to the previous step.
|
|
50
50
|
* //@fires stepper:finish Dispatched when the final step is completed.
|
|
51
51
|
*/
|
|
52
|
-
goToStep(stepIndex: number
|
|
52
|
+
goToStep(stepIndex: number): void;
|
|
53
53
|
/**
|
|
54
54
|
* Resets a step to its default state by clearing its active and done attributes.
|
|
55
55
|
* Updates the step's badge to show its index and removes any color styling.
|
|
@@ -76,4 +76,5 @@ export default class Stepper extends WJElement {
|
|
|
76
76
|
* @param {HTMLElement|null} [badge] The badge element within the step. If not provided, it will be selected from the `nav` element.
|
|
77
77
|
*/
|
|
78
78
|
setStepDone(nav: HTMLElement, badge?: HTMLElement | null): void;
|
|
79
|
+
setStepLocked(nav: any, badge?: any): void;
|
|
79
80
|
}
|
package/dist/wje-element.js
CHANGED
|
@@ -5,9 +5,11 @@ var __typeError = (msg) => {
|
|
|
5
5
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
6
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
7
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
8
9
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
9
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
10
|
-
var _Event_instances, dispatch_fn;
|
|
12
|
+
var _Event_instances, dispatch_fn, _drawingStatus, _isAttached, _isRendering, _originalVisibility, _pristine, _WJElement_instances, refresh_fn, resolveRender_fn;
|
|
11
13
|
import { store, defaultStoreActions } from "./wje-store.js";
|
|
12
14
|
class UniversalService {
|
|
13
15
|
constructor(props = {}) {
|
|
@@ -445,6 +447,12 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
445
447
|
*/
|
|
446
448
|
constructor() {
|
|
447
449
|
super();
|
|
450
|
+
__privateAdd(this, _WJElement_instances);
|
|
451
|
+
__privateAdd(this, _drawingStatus);
|
|
452
|
+
__privateAdd(this, _isAttached);
|
|
453
|
+
__privateAdd(this, _isRendering);
|
|
454
|
+
__privateAdd(this, _originalVisibility);
|
|
455
|
+
__privateAdd(this, _pristine);
|
|
448
456
|
/**
|
|
449
457
|
* Initializes the component, setting up attributes and rendering.
|
|
450
458
|
* @param [force] Whether to force initialization.
|
|
@@ -453,13 +461,13 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
453
461
|
__publicField(this, "initWjElement", (force = false) => {
|
|
454
462
|
return new Promise(async (resolve, reject) => {
|
|
455
463
|
var _a;
|
|
456
|
-
this
|
|
464
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.BEGINING);
|
|
457
465
|
(_a = this.setupAttributes) == null ? void 0 : _a.call(this);
|
|
458
466
|
if (this.hasShadowRoot) {
|
|
459
467
|
if (!this.shadowRoot) this.attachShadow({ mode: this.shadowType || "open" });
|
|
460
468
|
}
|
|
461
469
|
this.setUpAccessors();
|
|
462
|
-
this
|
|
470
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.START);
|
|
463
471
|
await this.display(force);
|
|
464
472
|
const sheet = new CSSStyleSheet();
|
|
465
473
|
sheet.replaceSync(this.constructor.cssStyleSheet);
|
|
@@ -467,12 +475,12 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
467
475
|
resolve();
|
|
468
476
|
});
|
|
469
477
|
});
|
|
470
|
-
this
|
|
478
|
+
__privateSet(this, _isAttached, false);
|
|
471
479
|
this.service = new UniversalService({
|
|
472
480
|
store
|
|
473
481
|
});
|
|
474
482
|
this.defineDependencies();
|
|
475
|
-
this
|
|
483
|
+
__privateSet(this, _isRendering, false);
|
|
476
484
|
this._dependencies = {};
|
|
477
485
|
this.drawingStatuses = {
|
|
478
486
|
CREATED: 0,
|
|
@@ -483,18 +491,20 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
483
491
|
DONE: 5,
|
|
484
492
|
DISCONNECTED: 6
|
|
485
493
|
};
|
|
486
|
-
this
|
|
487
|
-
this
|
|
488
|
-
this
|
|
489
|
-
this.isRendering = false;
|
|
494
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.CREATED);
|
|
495
|
+
__privateSet(this, _pristine, true);
|
|
496
|
+
__privateSet(this, _isRendering, false);
|
|
490
497
|
this.rafId = null;
|
|
491
|
-
this
|
|
498
|
+
__privateSet(this, _originalVisibility, null);
|
|
492
499
|
this.params = {};
|
|
493
500
|
this.updateComplete = new Promise((resolve, reject) => {
|
|
494
501
|
this.finisPromise = resolve;
|
|
495
502
|
this.rejectPromise = reject;
|
|
496
503
|
});
|
|
497
504
|
}
|
|
505
|
+
get drawingStatus() {
|
|
506
|
+
return __privateGet(this, _drawingStatus);
|
|
507
|
+
}
|
|
498
508
|
/**
|
|
499
509
|
* Sets the value of the 'permission' attribute.
|
|
500
510
|
* @param {string[]} value The value to set for the 'permission' attribute.
|
|
@@ -682,13 +692,13 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
682
692
|
*/
|
|
683
693
|
connectedCallback() {
|
|
684
694
|
var _a;
|
|
685
|
-
if (!this
|
|
686
|
-
this
|
|
695
|
+
if (!__privateGet(this, _isRendering)) {
|
|
696
|
+
__privateSet(this, _originalVisibility, __privateGet(this, _originalVisibility) ?? this.style.visibility);
|
|
687
697
|
this.style.visibility = "hidden";
|
|
688
698
|
(_a = this.setupAttributes) == null ? void 0 : _a.call(this);
|
|
689
699
|
this.setUpAccessors();
|
|
690
|
-
this
|
|
691
|
-
this
|
|
700
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.ATTACHED);
|
|
701
|
+
__privateSet(this, _pristine, false);
|
|
692
702
|
this.enqueueUpdate();
|
|
693
703
|
}
|
|
694
704
|
}
|
|
@@ -732,18 +742,18 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
732
742
|
*/
|
|
733
743
|
disconnectedCallback() {
|
|
734
744
|
var _a, _b;
|
|
735
|
-
if (this
|
|
745
|
+
if (__privateGet(this, _isAttached)) {
|
|
736
746
|
(_a = this.beforeDisconnect) == null ? void 0 : _a.call(this);
|
|
737
747
|
this.context.innerHTML = "";
|
|
738
748
|
(_b = this.afterDisconnect) == null ? void 0 : _b.call(this);
|
|
739
|
-
this
|
|
740
|
-
this.style.visibility = this
|
|
741
|
-
this
|
|
749
|
+
__privateSet(this, _isAttached, false);
|
|
750
|
+
this.style.visibility = __privateGet(this, _originalVisibility);
|
|
751
|
+
__privateSet(this, _originalVisibility, null);
|
|
742
752
|
}
|
|
743
|
-
if (this
|
|
753
|
+
if (__privateGet(this, _isRendering)) {
|
|
744
754
|
this.stopRenderLoop();
|
|
745
755
|
}
|
|
746
|
-
this
|
|
756
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.DISCONNECTED);
|
|
747
757
|
this.componentCleanup();
|
|
748
758
|
}
|
|
749
759
|
/**
|
|
@@ -751,8 +761,8 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
751
761
|
* This method processes the current render promise and then refreshes the component.
|
|
752
762
|
*/
|
|
753
763
|
enqueueUpdate() {
|
|
754
|
-
if (!this
|
|
755
|
-
this.rafId = requestAnimationFrame(() => this.
|
|
764
|
+
if (!__privateGet(this, _isRendering)) {
|
|
765
|
+
this.rafId = requestAnimationFrame(() => __privateMethod(this, _WJElement_instances, refresh_fn).call(this));
|
|
756
766
|
}
|
|
757
767
|
}
|
|
758
768
|
/**
|
|
@@ -763,7 +773,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
763
773
|
*/
|
|
764
774
|
attributeChangedCallback(name, old, newName) {
|
|
765
775
|
if (old !== newName) {
|
|
766
|
-
this
|
|
776
|
+
__privateSet(this, _pristine, false);
|
|
767
777
|
this.enqueueUpdate();
|
|
768
778
|
}
|
|
769
779
|
}
|
|
@@ -772,52 +782,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
772
782
|
this.finisPromise = resolve;
|
|
773
783
|
this.rejectPromise = reject;
|
|
774
784
|
});
|
|
775
|
-
this
|
|
785
|
+
__privateSet(this, _pristine, false);
|
|
776
786
|
this.enqueueUpdate();
|
|
777
787
|
}
|
|
778
|
-
/**
|
|
779
|
-
* Refreshes the component by reinitializing it if it is in a drawing state.
|
|
780
|
-
* This method checks if the component's drawing status is at least in the START state.
|
|
781
|
-
* If so, it performs the following steps:
|
|
782
|
-
* 1. Calls the `beforeRedraw` hook if defined.
|
|
783
|
-
* 2. Calls the `beforeDisconnect` hook if defined.
|
|
784
|
-
* 3. Refreshes the update promise to manage the rendering lifecycle.
|
|
785
|
-
* 4. Calls the `afterDisconnect` hook if defined.
|
|
786
|
-
* 5. Reinitializes the component by calling `initWjElement` with `true` to force initialization.
|
|
787
|
-
* If the component is not in a drawing state, it simply returns a resolved promise.
|
|
788
|
-
*/
|
|
789
|
-
async _refresh() {
|
|
790
|
-
var _a, _b, _c;
|
|
791
|
-
if (this.isRendering) {
|
|
792
|
-
this.rafId = requestAnimationFrame(() => this._refresh());
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
if (!this._pristine) {
|
|
796
|
-
this._pristine = true;
|
|
797
|
-
this.isRendering = true;
|
|
798
|
-
if (this.isAttached) {
|
|
799
|
-
(_a = this.beforeRedraw) == null ? void 0 : _a.call(this);
|
|
800
|
-
(_b = this.beforeDisconnect) == null ? void 0 : _b.call(this);
|
|
801
|
-
(_c = this.afterDisconnect) == null ? void 0 : _c.call(this);
|
|
802
|
-
} else {
|
|
803
|
-
this.stopRenderLoop();
|
|
804
|
-
}
|
|
805
|
-
try {
|
|
806
|
-
await this.initWjElement(true);
|
|
807
|
-
} catch (error) {
|
|
808
|
-
console.error("Render error:", error);
|
|
809
|
-
} finally {
|
|
810
|
-
this.isRendering = false;
|
|
811
|
-
if (!this._pristine) {
|
|
812
|
-
this._pristine = false;
|
|
813
|
-
this.enqueueUpdate();
|
|
814
|
-
} else {
|
|
815
|
-
this.finisPromise();
|
|
816
|
-
this.style.visibility = this.originalVisibility;
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
788
|
stopRenderLoop() {
|
|
822
789
|
if (this.rafId) {
|
|
823
790
|
cancelAnimationFrame(this.rafId);
|
|
@@ -860,13 +827,13 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
860
827
|
this.remove();
|
|
861
828
|
return Promise.resolve();
|
|
862
829
|
}
|
|
863
|
-
return this.
|
|
830
|
+
return __privateMethod(this, _WJElement_instances, resolveRender_fn).call(this);
|
|
864
831
|
}
|
|
865
832
|
/**
|
|
866
833
|
* Renders the component's content.
|
|
867
834
|
*/
|
|
868
835
|
async render() {
|
|
869
|
-
this
|
|
836
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.DRAWING);
|
|
870
837
|
let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));
|
|
871
838
|
if (_draw instanceof Promise || (_draw == null ? void 0 : _draw.constructor.name) === "Promise") {
|
|
872
839
|
_draw = await _draw;
|
|
@@ -888,10 +855,8 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
888
855
|
* @param {string} name The name in kebab-case format (e.g., "example-name").
|
|
889
856
|
* @returns {string} The sanitized name in camelCase format (e.g., "exampleName").
|
|
890
857
|
* @example
|
|
891
|
-
* // Returns 'exampleName'
|
|
892
858
|
* sanitizeName('example-name');
|
|
893
859
|
* @example
|
|
894
|
-
* // Returns 'myCustomComponent'
|
|
895
860
|
* sanitizeName('my-custom-component');
|
|
896
861
|
*/
|
|
897
862
|
sanitizeName(name) {
|
|
@@ -910,11 +875,9 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
910
875
|
* get name() { return 'value'; },
|
|
911
876
|
* set name(val) { console.log(val); }
|
|
912
877
|
* };
|
|
913
|
-
* // Returns { hasGetter: [Function: get name], hasSetter: [Function: set name] }
|
|
914
878
|
* checkGetterSetter(obj, 'name');
|
|
915
879
|
* @example
|
|
916
880
|
* const obj = { prop: 42 };
|
|
917
|
-
* // Returns { hasGetter: null, hasSetter: null }
|
|
918
881
|
* checkGetterSetter(obj, 'prop');
|
|
919
882
|
*/
|
|
920
883
|
checkGetterSetter(obj, property) {
|
|
@@ -945,36 +908,74 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
945
908
|
});
|
|
946
909
|
});
|
|
947
910
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
this.
|
|
967
|
-
this.
|
|
968
|
-
|
|
969
|
-
|
|
911
|
+
};
|
|
912
|
+
_drawingStatus = new WeakMap();
|
|
913
|
+
_isAttached = new WeakMap();
|
|
914
|
+
_isRendering = new WeakMap();
|
|
915
|
+
_originalVisibility = new WeakMap();
|
|
916
|
+
_pristine = new WeakMap();
|
|
917
|
+
_WJElement_instances = new WeakSet();
|
|
918
|
+
refresh_fn = async function() {
|
|
919
|
+
var _a, _b, _c;
|
|
920
|
+
if (__privateGet(this, _isRendering)) {
|
|
921
|
+
this.rafId = requestAnimationFrame(() => __privateMethod(this, _WJElement_instances, refresh_fn).call(this));
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
if (!__privateGet(this, _pristine)) {
|
|
925
|
+
__privateSet(this, _pristine, true);
|
|
926
|
+
__privateSet(this, _isRendering, true);
|
|
927
|
+
if (__privateGet(this, _isAttached)) {
|
|
928
|
+
(_a = this.beforeRedraw) == null ? void 0 : _a.call(this);
|
|
929
|
+
(_b = this.beforeDisconnect) == null ? void 0 : _b.call(this);
|
|
930
|
+
(_c = this.afterDisconnect) == null ? void 0 : _c.call(this);
|
|
931
|
+
} else {
|
|
932
|
+
this.stopRenderLoop();
|
|
933
|
+
}
|
|
934
|
+
try {
|
|
935
|
+
await this.initWjElement(true);
|
|
936
|
+
} catch (error) {
|
|
937
|
+
console.error("Render error:", error);
|
|
938
|
+
} finally {
|
|
939
|
+
__privateSet(this, _isRendering, false);
|
|
940
|
+
if (!__privateGet(this, _pristine)) {
|
|
941
|
+
__privateSet(this, _pristine, false);
|
|
942
|
+
this.enqueueUpdate();
|
|
943
|
+
} else {
|
|
944
|
+
this.finisPromise();
|
|
945
|
+
this.style.visibility = __privateGet(this, _originalVisibility);
|
|
970
946
|
}
|
|
971
|
-
|
|
972
|
-
resolve();
|
|
973
|
-
}).catch((e) => {
|
|
974
|
-
console.log(e);
|
|
975
|
-
});
|
|
947
|
+
}
|
|
976
948
|
}
|
|
977
949
|
};
|
|
950
|
+
/**
|
|
951
|
+
* Resolves the rendering process of the component.
|
|
952
|
+
* @returns A promise that resolves when rendering is complete.
|
|
953
|
+
* @private
|
|
954
|
+
*/
|
|
955
|
+
resolveRender_fn = function() {
|
|
956
|
+
this.params = WjElementUtils.getAttributes(this);
|
|
957
|
+
return new Promise(async (resolve, reject) => {
|
|
958
|
+
var _a;
|
|
959
|
+
const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));
|
|
960
|
+
if (__beforeDraw instanceof Promise || (__beforeDraw == null ? void 0 : __beforeDraw.constructor.name) === "Promise") {
|
|
961
|
+
await __beforeDraw;
|
|
962
|
+
}
|
|
963
|
+
await this.render();
|
|
964
|
+
const __afterDraw = (_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this));
|
|
965
|
+
if (__afterDraw instanceof Promise || (__afterDraw == null ? void 0 : __afterDraw.constructor.name) === "Promise") {
|
|
966
|
+
await __afterDraw;
|
|
967
|
+
}
|
|
968
|
+
__privateSet(this, _isRendering, false);
|
|
969
|
+
__privateSet(this, _isAttached, true);
|
|
970
|
+
if (this.removeClassAfterConnect) {
|
|
971
|
+
this.classList.remove(...this.removeClassAfterConnect);
|
|
972
|
+
}
|
|
973
|
+
__privateSet(this, _drawingStatus, this.drawingStatuses.DONE);
|
|
974
|
+
resolve();
|
|
975
|
+
}).catch((e) => {
|
|
976
|
+
console.log(e);
|
|
977
|
+
});
|
|
978
|
+
};
|
|
978
979
|
/**
|
|
979
980
|
* Processes and combines two templates into one.
|
|
980
981
|
* @param pTemplate The primary template.
|