wj-elements 0.1.138 → 0.1.140

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/light.css CHANGED
@@ -528,7 +528,8 @@
528
528
  --wje-tooltip-spacing: var(--wje-spacing-x-small);
529
529
  --wje-tooltip-border-radius: var(--wje-border-radius-medium);
530
530
 
531
- /* Tree */
532
- --wje-tree-item-indent: 1.3rem;
531
+ /* Tree - Item */
532
+ --wje-tree-item-indent: var(--wje-spacing-large);
533
533
  --wje-tree-item-indent-guid-width: 0px;
534
+ --wje-tree-item-border-radius: var(--wje-border-radius-medium);
534
535
  }
package/dist/localize.js CHANGED
@@ -3,6 +3,7 @@ class LocalizerDefault {
3
3
  this.element = element;
4
4
  this.lang = this.element.lang || document.documentElement.lang || "en-gb";
5
5
  this.dir = this.element.dir || document.documentElement.dir || "ltr";
6
+ this.currentLang = "en-gb";
6
7
  this.setLanguage();
7
8
  }
8
9
  get languages() {
@@ -10,7 +11,8 @@ class LocalizerDefault {
10
11
  }
11
12
  // Nastavenie aktuálneho jazyka
12
13
  setLanguage() {
13
- if (this.languages.has(this.lang)) {
14
+ var _a;
15
+ if ((_a = this.languages) == null ? void 0 : _a.has(this.lang)) {
14
16
  this.currentLang = this.lang;
15
17
  } else {
16
18
  console.error(`Language "${this.lang}" not loaded.`);
@@ -18,9 +20,9 @@ class LocalizerDefault {
18
20
  }
19
21
  // Vyhľadávanie prekladu podľa kľúča
20
22
  translate(key) {
21
- console.log("TRANSLATE:", this.element.lang, this.lang, this.currentLang, key);
22
- const langMap = this.languages.get(this.currentLang);
23
- console.log("LANG MAP:", langMap);
23
+ var _a;
24
+ const langMap = (_a = this.languages) == null ? void 0 : _a.get(this.currentLang);
25
+ if (!langMap) return key;
24
26
  return langMap ? langMap[key] || key : key;
25
27
  }
26
28
  // Vyhľadávanie prekladu podľa kľúča a typu čísla
@@ -1 +1 @@
1
- {"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element.lang || document.documentElement.lang || 'en-gb';\n this.dir = this.element.dir || document.documentElement.dir || 'ltr';\n\n this.setLanguage();\n }\n\n get languages() {\n return window.translations;\n }\n\n // Nastavenie aktuálneho jazyka\n setLanguage() {\n if (this.languages.has(this.lang)) {\n this.currentLang = this.lang;\n } else {\n console.error(`Language \"${this.lang}\" not loaded.`);\n }\n }\n\n // Vyhľadávanie prekladu podľa kľúča\n translate(key) {\n console.log(\"TRANSLATE:\",this.element.lang, this.lang, this.currentLang, key);\n const langMap = this.languages.get(this.currentLang);\n console.log(\"LANG MAP:\", langMap);\n return langMap ? langMap[key] || key : key;\n }\n\n // Vyhľadávanie prekladu podľa kľúča a typu čísla\n translatePlural(key, count = 0, type = 'cardinal') {\n const plural = new Intl.PluralRules(this.lang, { type: type });\n\n if (count !== undefined) key += '.' + plural.select(count);\n\n return this.translate(key);\n }\n\n // Formátovanie čísla podľa aktuálneho jazyka\n formatNumber(number, options) {\n return new Intl.NumberFormat(this.currentLang, options).format(number);\n }\n\n // Formátovanie dátumu podľa aktuálneho jazyka\n formatDate(date) {\n return new Intl.DateTimeFormat(this.currentLang).format(new Date(date));\n }\n\n relativeTime(lang, value = 0, unit = 'day', options = { numeric: 'auto' }) {\n lang = lang || this.currentLang;\n return new Intl.RelativeTimeFormat(lang, options).format(value, unit);\n }\n}\n\nexport function registerTranslation(...translation) {\n translation.forEach((t) => {\n if (!t.code) {\n console.error(\"Translation object is missing 'code' property:\", t);\n return;\n }\n\n const code = t.code.toLowerCase();\n if (window.translations.has(code)) {\n window.translations.set(code, { ...window.translations.get(code), ...t });\n } else {\n window.translations.set(code, t);\n }\n });\n}\n","import { LocalizerDefault, registerTranslation } from '../localize/localize.js';\n\nexport class Localizer extends LocalizerDefault {\n constructor(element) {\n super(element);\n }\n static registerTranslation(...translation) {\n registerTranslation(...translation);\n }\n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UAAU;AACvE,WAAO,QAAQ,KAAK;AACpB,WAAO,IAAI,KAAK,mBAAmB,MAAM,OAAO,EAAE,OAAO,OAAO,IAAI;AAAA,EAC5E;AACA;AAEO,SAAS,uBAAuB,aAAa;AAChD,cAAY,QAAQ,CAAC,MAAM;AACvB,QAAI,CAAC,EAAE,MAAM;AACT,cAAQ,MAAM,kDAAkD,CAAC;AACjE;AAAA,IACZ;AAEQ,UAAM,OAAO,EAAE,KAAK,YAAa;AACjC,QAAI,OAAO,aAAa,IAAI,IAAI,GAAG;AAC/B,aAAO,aAAa,IAAI,MAAM,EAAE,GAAG,OAAO,aAAa,IAAI,IAAI,GAAG,GAAG,EAAC,CAAE;AAAA,IACpF,OAAe;AACH,aAAO,aAAa,IAAI,MAAM,CAAC;AAAA,IAC3C;AAAA,EACA,CAAK;AACL;ACtEO,MAAM,kBAAkB,iBAAiB;AAAA,EAC5C,YAAY,SAAS;AACjB,UAAM,OAAO;AAAA,EACrB;AAAA,EACI,OAAO,uBAAuB,aAAa;AACvC,wBAAoB,GAAG,WAAW;AAAA,EAC1C;AACA;"}
1
+ {"version":3,"file":"localize.js","sources":["../packages/localize/localize.js","../packages/utils/localize.js"],"sourcesContent":["// export const translations = new Map();\n\nexport class LocalizerDefault {\n constructor(element) {\n this.element = element;\n\n this.lang = this.element.lang || document.documentElement.lang || 'en-gb';\n this.dir = this.element.dir || document.documentElement.dir || 'ltr';\n this.currentLang = 'en-gb';\n\n this.setLanguage();\n }\n\n get languages() {\n return window.translations;\n }\n\n // Nastavenie aktuálneho jazyka\n setLanguage() {\n if (this.languages?.has(this.lang)) {\n this.currentLang = this.lang;\n } else {\n console.error(`Language \"${this.lang}\" not loaded.`);\n }\n }\n\n // Vyhľadávanie prekladu podľa kľúča\n translate(key) {\n const langMap = this.languages?.get(this.currentLang);\n if (!langMap) return key;\n return langMap ? langMap[key] || key : key;\n }\n\n // Vyhľadávanie prekladu podľa kľúča a typu čísla\n translatePlural(key, count = 0, type = 'cardinal') {\n const plural = new Intl.PluralRules(this.lang, { type: type });\n\n if (count !== undefined) key += '.' + plural.select(count);\n\n return this.translate(key);\n }\n\n // Formátovanie čísla podľa aktuálneho jazyka\n formatNumber(number, options) {\n return new Intl.NumberFormat(this.currentLang, options).format(number);\n }\n\n // Formátovanie dátumu podľa aktuálneho jazyka\n formatDate(date) {\n return new Intl.DateTimeFormat(this.currentLang).format(new Date(date));\n }\n\n relativeTime(lang, value = 0, unit = 'day', options = { numeric: 'auto' }) {\n lang = lang || this.currentLang;\n return new Intl.RelativeTimeFormat(lang, options).format(value, unit);\n }\n}\n\nexport function registerTranslation(...translation) {\n translation.forEach((t) => {\n if (!t.code) {\n console.error(\"Translation object is missing 'code' property:\", t);\n return;\n }\n\n const code = t.code.toLowerCase();\n if (window.translations.has(code)) {\n window.translations.set(code, { ...window.translations.get(code), ...t });\n } else {\n window.translations.set(code, t);\n }\n });\n}\n","import { LocalizerDefault, registerTranslation } from '../localize/localize.js';\n\nexport class Localizer extends LocalizerDefault {\n constructor(element) {\n super(element);\n }\n static registerTranslation(...translation) {\n registerTranslation(...translation);\n }\n}\n"],"names":[],"mappings":"AAEO,MAAM,iBAAiB;AAAA,EAC1B,YAAY,SAAS;AACjB,SAAK,UAAU;AAEf,SAAK,OAAO,KAAK,QAAQ,QAAQ,SAAS,gBAAgB,QAAQ;AAClE,SAAK,MAAM,KAAK,QAAQ,OAAO,SAAS,gBAAgB,OAAO;AAC/D,SAAK,cAAc;AAEnB,SAAK,YAAa;AAAA,EAC1B;AAAA,EAEI,IAAI,YAAY;AACZ,WAAO,OAAO;AAAA,EACtB;AAAA;AAAA,EAGI,cAAc;AAlBlB;AAmBQ,SAAI,UAAK,cAAL,mBAAgB,IAAI,KAAK,OAAO;AAChC,WAAK,cAAc,KAAK;AAAA,IACpC,OAAe;AACH,cAAQ,MAAM,aAAa,KAAK,IAAI,eAAe;AAAA,IAC/D;AAAA,EACA;AAAA;AAAA,EAGI,UAAU,KAAK;AA3BnB;AA4BQ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UAAM,OAAO;AAAA,EACrB;AAAA,EACI,OAAO,uBAAuB,aAAa;AACvC,wBAAoB,GAAG,WAAW;AAAA,EAC1C;AACA;"}
File without changes
@@ -4,9 +4,9 @@ export class LocalizerDefault {
4
4
  element: any;
5
5
  lang: any;
6
6
  dir: any;
7
+ currentLang: string;
7
8
  get languages(): any;
8
9
  setLanguage(): void;
9
- currentLang: any;
10
10
  translate(key: any): any;
11
11
  translatePlural(key: any, count?: number, type?: string): any;
12
12
  formatNumber(number: any, options: any): string;
@@ -39,12 +39,14 @@ export default class FileUploadItem extends WJElement {
39
39
  */
40
40
  dependencies: object;
41
41
  /**
42
- * Called when an observed attribute has been added, removed, updated, or replaced.
43
- * @param {string} name The name of the attribute that has changed.
44
- * @param {string} oldValue The old value of the attribute.
45
- * @param {string} newValue The new value of the attribute.
42
+ * Handles updates to the attributes of a custom element whenever one of the observed attributes is changed.
43
+ * Updates the related elements based on the changed attribute and its new value.
44
+ * @param {string} name The name of the attribute being changed.
45
+ * @param {string | null} oldValue The previous value of the attribute before the change, or null if the attribute was not previously set.
46
+ * @param {string | null} newValue The new value of the attribute after the change, or null if the attribute is being removed.
47
+ * @returns {void} Does not return a value.
46
48
  */
47
- attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
49
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
48
50
  /**
49
51
  * Method to draw the component on the screen.
50
52
  * @returns {DocumentFragment} The fragment containing the component.
@@ -1,7 +1,14 @@
1
1
  import { default as WJElement } from '../wje-element/element.js';
2
2
  /**
3
- * Represents a custom Tree component that extends the functionality of WJElement.
4
- * This component is used to create a hierarchical tree structure with selectable items.
3
+ * `Tree` is a custom web component that represents a hierarchical tree structure.
4
+ * It extends from `WJElement`.
5
+ * @summary This element visually represents a tree structure, supporting single or multiple selection modes and hierarchy management.
6
+ * @documentation https://elements.webjet.sk/components/tree
7
+ * @status stable
8
+ * @augments {WJElement}
9
+ * @csspart native - The native container part of the tree.
10
+ * @slot - The default slot to place `wje-tree-item` child components.
11
+ * @tag wje-tree
5
12
  */
6
13
  export default class Tree extends WJElement {
7
14
  /**
@@ -10,9 +17,24 @@ export default class Tree extends WJElement {
10
17
  * @returns {CSSStyleSheet} The CSS stylesheet
11
18
  */
12
19
  static get cssStyleSheet(): CSSStyleSheet;
20
+ /**
21
+ * Sets the selection attribute for the element.
22
+ * @param {string} value The value to set as the selection attribute.
23
+ */
13
24
  set selection(value: string);
25
+ /**
26
+ * Gets the current selection mode for the element.
27
+ * If no selection is explicitly set, it defaults to 'single'.
28
+ * @returns {string} The current selection mode, either set by the element's attribute or the default value 'single'.
29
+ */
14
30
  get selection(): string;
15
- beforeDraw(context: any, appStoreObj: any, params: any): void;
31
+ /**
32
+ * A method called before the drawing or rendering process of tree items.
33
+ * It iterates through all `wje-tree-item` elements, updating their selection state
34
+ * and managing their expand/collapse icons accordingly.
35
+ * @returns {void} This method does not return a value.
36
+ */
37
+ beforeDraw(): void;
16
38
  /**
17
39
  * Draw method for the toast notification.
18
40
  * @returns {object} Document fragment
@@ -45,4 +67,38 @@ export default class Tree extends WJElement {
45
67
  * @returns {void} This method does not return a value. If the icon matching the given status is not found, a warning is logged.
46
68
  */
47
69
  getExpandCollapseIcon(item: HTMLElement, status: string): void;
70
+ /**
71
+ * Updates the state of a checkbox, syncing the state both upwards to parent elements
72
+ * and downwards to child elements as necessary.
73
+ * @param {object} changedItem The specific item whose checkbox state has changed.
74
+ * @param {boolean} [isInitialSync] Indicates whether the state update is part of the initial synchronization process.
75
+ * @returns {void} This method does not return a value.
76
+ */
77
+ updateCheckboxState(changedItem: object, isInitialSync?: boolean): void;
78
+ isInitialSync: boolean;
79
+ /**
80
+ * Updates the state of the parent item based on the state of its child items.
81
+ * Recursively propagates changes up to all parent items to reflect the selection
82
+ * or indeterminate state accurately.
83
+ * @param {object} item The current tree item whose parent state needs to be updated.
84
+ * It is expected to have properties `selected`, `indeterminate`,
85
+ * and a method `getChildrenItems({ includeDisabled: boolean })`.
86
+ * @returns {void} This method does not return a value.
87
+ */
88
+ updateParentState(item: object): void;
89
+ /**
90
+ * Propagates the state changes of an item upwards through its ancestors in the hierarchy.
91
+ * Calls the `updateParentState` method for each parent element until no parent exists.
92
+ * @param {HTMLElement} item The current item whose state to propagate to its parent.
93
+ * @returns {void} This method does not return a value.
94
+ */
95
+ propagateStateUpwards(item: HTMLElement): void;
96
+ /**
97
+ * Propagates the selected state of an item to its children recursively. Depending on the `isInitialSync` flag,
98
+ * it also determines how the state should be applied to the child items and updates the parent state if needed.
99
+ * @param {object} item The item whose state is being propagated to its child items. The item must have properties
100
+ * such as `selected` and methods like `getChildrenItems` to retrieve its child elements.
101
+ * @returns {void} This method does not return a value.
102
+ */
103
+ propagateStateDownwards(item: object): void;
48
104
  }
@@ -1,48 +1,155 @@
1
- import { default as WJElement } from '../wje-element/element.js';
2
1
  /**
3
- * `Toast` is a custom web component that represents a toast notification.
4
- * @summary This element represents a toast notification.
5
- * @documentation https://elements.webjet.sk/components/toast
2
+ * `wje-tree-item` is a custom web component used as a child of the `wje-tree`.
3
+ * It represents a node within a tree structure, capable of nesting other items.
4
+ * @summary Represents a single item in a tree structure.
5
+ * @documentation https://elements.webjet.sk/components/tree-item
6
6
  * @status stable
7
- * @augments {WJElement}
8
- * @csspart native - The native part
9
- * @cssproperty {string} headline - Specifies the headline text of the toast. Represents the main title or heading displayed in the toast.
10
- * @cssproperty {boolean} open - Indicates whether the toast is currently open (visible). A value of `true` shows the toast, while `false` hides it.
11
- * @cssproperty {number} duration - Determines the duration (in milliseconds) for which the toast is displayed. After this time, the toast will automatically close unless it is manually closed.
12
- * @cssproperty {boolean} closable - Specifies whether the toast can be manually closed by the user. If `true`, the toast will include a close button or mechanism.
13
- * @cssproperty {string} color - Defines the color of the toast. Accepts any valid CSS color value such as `hex`, `RGB`, or named colors.
14
- * @cssproperty {boolean} countdown - Indicates whether a countdown is displayed in the toast. When `true`, a visual countdown timer is shown to indicate the remaining time before the toast closes.
15
- * @slot - The content of the toast.
16
- * @slot media - The media of the toast.
17
- * // @fires wje-toast:after-show - Fired after the toast is shown.
18
- * // @fires wje-toast:after-hide - Fired after the toast is hidden.
7
+ * @augments {HTMLElement}
8
+ * @slot - Default slot for rendering the tree item's content (e.g., text or custom elements).
9
+ * @csspart native - The native container of the tree item.
10
+ * @cssproperty [--wje-tree-item-indent=var(--wje-spacing-large)] - Defines the indentation for nested tree items.
11
+ * @cssproperty [--wje-tree-item-indent-guid-width=0px] - Specifies the width of the guide element shown next to a tree item.
12
+ * @cssproperty [--wje-tree-item-border-radius=var(--wje-border-radius-medium)] - Sets the border radius of the tree item’s container.
13
+ * @tag wje-tree-item
19
14
  */
20
- export default class TreeItem extends WJElement {
15
+ export default class TreeItem extends HTMLElement {
21
16
  /**
22
17
  * Returns the CSS stylesheet for the component.
23
18
  * @static
24
19
  * @returns {CSSStyleSheet} The CSS stylesheet
25
20
  */
26
21
  static get cssStyleSheet(): CSSStyleSheet;
22
+ /**
23
+ * Returns the list of attributes to observe for changes.
24
+ * @static
25
+ * @returns {Array<string>}
26
+ */
27
+ static get observedAttributes(): Array<string>;
27
28
  _selection: string;
29
+ /**
30
+ * Sets the expanded state of the element. When set to a truthy value,
31
+ * the 'expanded' attribute will be added to the element. When set to a falsy
32
+ * value, the 'expanded' attribute will be removed.
33
+ * @param {boolean} value A boolean value indicating whether the
34
+ * element should be expanded (true) or collapsed (false).
35
+ */
36
+ set expanded(value: boolean);
37
+ /**
38
+ * Retrieves the value of the 'expanded' state for the current element.
39
+ * This getter checks whether the 'expanded' attribute is present on the element.
40
+ * If the attribute exists, it returns true, representing that the element is expanded.
41
+ * Otherwise, it returns false, indicating that the element is not expanded.
42
+ * @returns {boolean} True if the 'expanded' attribute is present, false otherwise.
43
+ */
44
+ get expanded(): boolean;
45
+ /**
46
+ * Sets the 'selected' attribute of the element. Removes the attribute if the provided value is falsy; otherwise, sets it.
47
+ * @param {boolean} value The value indicating whether the element should have the 'selected' attribute.
48
+ */
28
49
  set selected(value: boolean);
50
+ /**
51
+ * Getter method for determining if the 'selected' attribute is present on the element.
52
+ * @returns {boolean} Returns true if the 'selected' attribute is present, otherwise false.
53
+ */
29
54
  get selected(): boolean;
55
+ /**
56
+ * Sets the selection mode for the component.
57
+ * @param {string} value The selection mode to apply. Defaults to 'single'
58
+ * if no value is provided. Possible options may be
59
+ * specific to the implementation of the component
60
+ * (e.g., 'single', 'multiple').
61
+ */
30
62
  set selection(value: string);
31
- get selection(): string;
32
- beforeDraw(context: any, appStoreObj: any, params: any): void;
33
63
  /**
34
- * Draw method for the toast notification.
35
- * @returns {object} Document fragment
64
+ * Retrieves the current selection.
65
+ * @returns {*} The value of the current selection.
66
+ */
67
+ get selection(): any;
68
+ /**
69
+ * Sets or removes the 'indeterminate' attribute based on the provided value.
70
+ * This can be used to visually indicate an indeterminate state for elements like checkboxes.
71
+ * @param {boolean} value A boolean indicating whether to set the element to an indeterminate state.
72
+ * If true, the 'indeterminate' attribute is added to the element; if false, the attribute is removed.
73
+ */
74
+ set indeterminate(value: boolean);
75
+ /**
76
+ * Retrieves the state of the indeterminate attribute.
77
+ * @returns {boolean} True if the indeterminate attribute is present, otherwise false.
78
+ */
79
+ get indeterminate(): boolean;
80
+ /**
81
+ * Setup attributes for the Button element.
36
82
  */
37
- draw(): object;
83
+ setupAttributes(): void;
84
+ isShadowRoot: string;
85
+ /**
86
+ * Handles updates when observed attributes of the element are changed.
87
+ * Updates the checkbox state based on changes to the "selected" or "indeterminate" attributes.
88
+ * @param {string} name The name of the attribute that was changed.
89
+ * @param {string|null} oldValue The previous value of the attribute before the change.
90
+ * @param {string|null} newValue The new value of the attribute after the change.
91
+ * @returns {void}
92
+ */
93
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
94
+ /**
95
+ * Custom logic executed before the draw process begins.
96
+ * Determines and sets the appropriate slot if the current item is nested.
97
+ * @returns {void} No return value.
98
+ */
99
+ beforeDraw(): void;
100
+ /**
101
+ * Creates and returns a document fragment representing the structure of a tree item component.
102
+ * The method constructs the DOM elements including the native container, indentation, toggle button,
103
+ * selection checkbox, label, and children container, along with their respective slots and attributes.
104
+ * It dynamically handles the creation of expand and collapse icons, as well as appending slots for
105
+ * child components.
106
+ * @returns {DocumentFragment} A fragment containing the complete tree item structure to be rendered.
107
+ */
108
+ draw(): DocumentFragment;
38
109
  checkbox: HTMLElement;
39
110
  native: HTMLDivElement;
40
111
  button: HTMLDivElement;
41
112
  childrenElement: HTMLDivElement;
42
113
  childrenSlot: HTMLSlotElement;
114
+ /**
115
+ * Executes operations to be performed after the draw action is completed.
116
+ * If the state indicates it is expanded, toggles its children.
117
+ * Additionally, sets up an event listener on the button element to handle toggling children upon click.
118
+ * @returns {void} Does not return a value.
119
+ */
43
120
  afterDraw(): void;
121
+ /**
122
+ * Determines if the current item is a nested item within a tree structure.
123
+ * Checks if the item's parent element exists and is also a tree item.
124
+ * @returns {boolean} Returns true if the current item is a nested tree item; otherwise, false.
125
+ */
44
126
  isNestedItem(): boolean;
45
- isTreeItem(node: any): boolean;
127
+ /**
128
+ * Checks whether the given node is a tree item.
129
+ * @param {object} node The node to check.
130
+ * @returns {boolean} Returns true if the node is an Element and has a class name of 'TreeItem', otherwise false.
131
+ */
132
+ isTreeItem(node: object): boolean;
133
+ /**
134
+ * Toggles the visibility state of the children element and updates the class of the parent element.
135
+ * The method toggles the 'open' class on the children elements and the 'expanded' class on the parent element,
136
+ * effectively showing or hiding the children and indicating the expanded state.
137
+ * @returns {void} Does not return a value.
138
+ */
46
139
  toggleChildren(): void;
47
- getChildrenItems(options?: {}): Element[];
140
+ /**
141
+ * Retrieves the child items from the `childrenSlot` that match specific criteria.
142
+ * @param {object} [options] Configuration options.
143
+ * @param {boolean} [options.includeDisabled] Determines whether disabled items should be included in the result. Defaults to true.
144
+ * @returns {Array} An array of child items that are valid tree items and meet the criteria specified in the options.
145
+ */
146
+ getChildrenItems(options?: {
147
+ includeDisabled?: boolean;
148
+ }): any[];
149
+ /**
150
+ * Retrieves all descendant children of the current object in a flattened array structure.
151
+ * @param {object} [options] An optional object specifying filters or configurations for retrieving children.
152
+ * @returns {Array} An array containing all children and their descendants in a flat structure.
153
+ */
154
+ getAllChildrenFlat(options?: object): any[];
48
155
  }
@@ -744,7 +744,7 @@ const _WJElement = class _WJElement extends HTMLElement {
744
744
  */
745
745
  async enqueueUpdate() {
746
746
  try {
747
- if (this.renderPromise && this.renderPromise instanceof Promise) {
747
+ if (this.renderPromise && (this.renderPromise instanceof Promise || this.renderPromise.constructor.name === "Promise")) {
748
748
  await this.renderPromise;
749
749
  }
750
750
  } catch (e) {
@@ -836,7 +836,7 @@ const _WJElement = class _WJElement extends HTMLElement {
836
836
  async render() {
837
837
  this.drawingStatus = this.drawingStatuses.DRAWING;
838
838
  let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));
839
- if (_draw instanceof Promise) {
839
+ if (_draw instanceof Promise || _draw.constructor.name === "Promise") {
840
840
  _draw = await _draw;
841
841
  }
842
842
  let rend = _draw;
@@ -923,12 +923,12 @@ const _WJElement = class _WJElement extends HTMLElement {
923
923
  return new Promise(async (resolve, reject) => {
924
924
  var _a;
925
925
  const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));
926
- if (__beforeDraw instanceof Promise) {
926
+ if (__beforeDraw instanceof Promise || __beforeDraw.constructor.name === "Promise") {
927
927
  await __beforeDraw;
928
928
  }
929
929
  await this.render();
930
930
  const __afterDraw = (_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this));
931
- if (__afterDraw instanceof Promise) {
931
+ if (__afterDraw instanceof Promise || __afterDraw.constructor.name === "Promise") {
932
932
  await __afterDraw;
933
933
  }
934
934
  this.finisPromise();