wj-elements 0.1.159 → 0.1.161
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/{infinite-scroll.element-DUjjOm1e.js → infinite-scroll.element-Cj53cbpC.js} +42 -5
- package/dist/infinite-scroll.element-Cj53cbpC.js.map +1 -0
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +1 -0
- package/dist/packages/wje-element/element.d.ts +1 -1
- package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +7 -0
- package/dist/packages/wje-options/options.element.d.ts +25 -1
- package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
- package/dist/packages/wje-store/pubsub.d.ts +5 -4
- package/dist/packages/wje-tab/tab.element.d.ts +23 -0
- package/dist/packages/wje-tab-group/tab-group.element.d.ts +5 -0
- package/dist/wje-dialog.js +3 -1
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-element.js +3 -3
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-icon-picker.js +1 -1
- package/dist/wje-infinite-scroll.js +1 -1
- package/dist/wje-master.js +1 -1
- package/dist/wje-options.js +30 -2
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-sliding-container.js +3 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-stepper.js +52 -36
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js +7 -6
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +72 -12
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js +1 -1
- package/dist/wje-tab.js +146 -1
- package/dist/wje-tab.js.map +1 -1
- package/package.json +2 -2
- package/dist/infinite-scroll.element-DUjjOm1e.js.map +0 -1
|
@@ -53,6 +53,7 @@ class InfiniteScroll extends WJElement {
|
|
|
53
53
|
this._loading = this.loadPages(this.currentPage);
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
+
__publicField(this, "compareFunction", (i, item) => i.id === item.id);
|
|
56
57
|
/**
|
|
57
58
|
* Converts a data item into an HTML element based on a template.
|
|
58
59
|
* This function takes a data item, interpolates it into a predefined template,
|
|
@@ -76,6 +77,7 @@ class InfiniteScroll extends WJElement {
|
|
|
76
77
|
__publicField(this, "customForeach", (data) => {
|
|
77
78
|
data.forEach((item) => {
|
|
78
79
|
let element = this.dataToHtml(item);
|
|
80
|
+
this._dataToElementWeakMap.set(element, item);
|
|
79
81
|
event.addListener(element, "click", "wje-infinite-scroll:click-item", null);
|
|
80
82
|
this.placementObj.insertAdjacentElement("beforeend", element);
|
|
81
83
|
});
|
|
@@ -110,6 +112,10 @@ class InfiniteScroll extends WJElement {
|
|
|
110
112
|
this._infiniteScrollTemplate = null;
|
|
111
113
|
this._abortController = new AbortController();
|
|
112
114
|
this._signal = this._abortController.signal;
|
|
115
|
+
this._dataToElementWeakMap = /* @__PURE__ */ new WeakMap();
|
|
116
|
+
this._drawnItems = [];
|
|
117
|
+
this._loadedItems = [];
|
|
118
|
+
this._actualDrawnIndex = 0;
|
|
113
119
|
}
|
|
114
120
|
/**
|
|
115
121
|
* Dependencies of the InfiniteScroll component.
|
|
@@ -178,10 +184,20 @@ class InfiniteScroll extends WJElement {
|
|
|
178
184
|
* @returns {void} No return value.
|
|
179
185
|
*/
|
|
180
186
|
beforeDraw() {
|
|
181
|
-
var _a, _b;
|
|
187
|
+
var _a, _b, _c;
|
|
188
|
+
this._loadedItems = [];
|
|
189
|
+
this._drawnItems = [];
|
|
190
|
+
this._dataToElementWeakMap = /* @__PURE__ */ new WeakMap();
|
|
182
191
|
this.iterate = this.querySelector("[iterate]");
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
if (this.iterate) {
|
|
193
|
+
if (this.iterate.nodeName !== "TEMPLATE") {
|
|
194
|
+
console.error("The iterate attribute must be a template element");
|
|
195
|
+
this.infiniteScrollTemplate = (_a = this.iterate) == null ? void 0 : _a.outerHTML;
|
|
196
|
+
} else {
|
|
197
|
+
this.infiniteScrollTemplate = (_b = this.iterate) == null ? void 0 : _b.innerHTML;
|
|
198
|
+
}
|
|
199
|
+
(_c = this.iterate) == null ? void 0 : _c.remove();
|
|
200
|
+
}
|
|
185
201
|
this.setAttribute("style", "height: " + this.height);
|
|
186
202
|
if (this._signal) {
|
|
187
203
|
this._abortController.abort();
|
|
@@ -291,7 +307,10 @@ class InfiniteScroll extends WJElement {
|
|
|
291
307
|
if (this.hasAttribute("placement")) this.placementObj = this.querySelector(this.placement);
|
|
292
308
|
event.dispatchCustomEvent(this, "wje-infinite-scroll:load", response);
|
|
293
309
|
this.response = response;
|
|
294
|
-
this.
|
|
310
|
+
this._loadedItems = this.objectName ? response[this.objectName] : response;
|
|
311
|
+
const notDrawnItems = this._loadedItems.filter((item) => !this._drawnItems.some(this.compareFunction.bind(this, item)));
|
|
312
|
+
this.customForeach(notDrawnItems);
|
|
313
|
+
this._drawnItems.push(...notDrawnItems);
|
|
295
314
|
this.isLoading.push(page);
|
|
296
315
|
} else {
|
|
297
316
|
event.dispatchCustomEvent(this, "wje-infinite-scroll:complete");
|
|
@@ -303,8 +322,26 @@ class InfiniteScroll extends WJElement {
|
|
|
303
322
|
this.hideLoader();
|
|
304
323
|
}
|
|
305
324
|
}
|
|
325
|
+
addItem(item, place = "beforeend") {
|
|
326
|
+
let element = this.dataToHtml(item);
|
|
327
|
+
this._dataToElementWeakMap.set(element, item);
|
|
328
|
+
this.placementObj.insertAdjacentElement(place, element);
|
|
329
|
+
this._drawnItems.push(item);
|
|
330
|
+
if (this._drawnItems.length > this.size * this.currentPage) {
|
|
331
|
+
this.totalPages += 1;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
removeItem(item) {
|
|
335
|
+
let element = this._dataToElementWeakMap.get(item);
|
|
336
|
+
element.remove();
|
|
337
|
+
this._drawnItems = this._drawnItems.filter((i) => i !== item);
|
|
338
|
+
if (this._drawnItems.length < this.size * this.currentPage) {
|
|
339
|
+
this.isLoading = this.isLoading.filter((i) => i !== this.currentPage);
|
|
340
|
+
this.currentPage--;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
306
343
|
}
|
|
307
344
|
export {
|
|
308
345
|
InfiniteScroll as I
|
|
309
346
|
};
|
|
310
|
-
//# sourceMappingURL=infinite-scroll.element-
|
|
347
|
+
//# sourceMappingURL=infinite-scroll.element-Cj53cbpC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infinite-scroll.element-Cj53cbpC.js","sources":["../packages/wje-infinite-scroll/infinite-scroll.element.js"],"sourcesContent":["import { default as WJElement, event, WjElementUtils } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `InfiniteScroll` is a custom web component that represents an infinite scroll.\n * It extends from `WJElement`.\n * @summary This element allows users to scroll through a potentially infinite amount of content.\n * @documentation https://elements.webjet.sk/components/infinite-scroll\n * @status stable\n * @augments {WJElement}\n * @csspart loader - The loader part of the infinite scroll.\n * @slot - The default slot for the infinite scroll.\n * @cssproperty [--wje-infinite-scroll-width=100%] - Sets the width of the infinite scroll container. his property determines how wide the infinite scroll area will be relative to its parent element. Accepts any valid CSS width value, such as percentages (`%`), pixels (`px`), or viewport units (`vw`). The default value is `100%`, which makes it span the full width of its container.\n * @cssproperty [--wje-infinite-scroll-height=300px] - Defines the height of the infinite scroll container. This property specifies how tall the infinite scroll area should be. Accepts any valid CSS height value, such as pixels (`px`), percentages (`%`), or viewport units (`vh`). The default value is `300px`, providing a fixed height suitable for most use cases.\n * //@fires wje-infinite-scroll:click-item - Event fired when an item is clicked.\n * @tag wje-infinite-scroll\n */\n\nexport default class InfiniteScroll extends WJElement {\n /**\n * Creates an instance of InfiniteScroll.\n */\n constructor() {\n super();\n\n this.totalPages = 0;\n this.isLoading = [];\n this._response = {};\n this.iterate = null;\n this._infiniteScrollTemplate = null;\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n this._dataToElementWeakMap = new WeakMap();\n this._drawnItems = [];\n this._loadedItems = [];\n this._actualDrawnIndex = 0;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set infiniteScrollTemplate(value) {\n this._infiniteScrollTemplate = value;\n }\n\n /**\n * Getter for the infiniteScrollTemplate property.\n * @returns {null}\n */\n get infiniteScrollTemplate() {\n return this._infiniteScrollTemplate;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set response(value) {\n this._response = value;\n }\n\n /**\n * Getter for the response property.\n * @returns {*|{}}\n */\n get response() {\n return this._response;\n }\n\n /**\n * Dependencies of the InfiniteScroll component.\n * @param value\n */\n set objectName(value) {\n this.setAttribute('object-name', value);\n }\n\n get objectName() {\n return this.getAttribute('object-name') ?? 'data';\n }\n\n className = 'InfiniteScroll';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Prepares the component for updates before it is drawn.\n * This method handles the removal of templates for iteration, adjusts the height styling of the component,\n * and manages abort signals for loading operations.\n * @returns {void} No return value.\n */\n beforeDraw() {\n this._loadedItems = [];\n this._drawnItems = [];\n this._dataToElementWeakMap = new WeakMap();\n\n this.iterate = this.querySelector('[iterate]');\n\n if (this.iterate) {\n if (this.iterate.nodeName !== 'TEMPLATE') {\n console.error('The iterate attribute must be a template element');\n this.infiniteScrollTemplate = this.iterate?.outerHTML;\n } else {\n this.infiniteScrollTemplate = this.iterate?.innerHTML;\n }\n\n this.iterate?.remove(); // remove template\n }\n\n this.setAttribute('style', 'height: ' + this.height);\n\n // if this._loading is not fulfilled then cancel the promise\n if (this._signal) {\n this._abortController.abort();\n this._abortController = new AbortController();\n this._signal = this._abortController.signal;\n }\n }\n\n /**\n * Creates and returns a document fragment containing the structure for an infinite scroll component.\n * The structure includes native elements, slots for customization, and optional loading content.\n * @returns {DocumentFragment} The document fragment containing the component's DOM structure.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native');\n native.setAttribute('part', 'native-infinite-scroll');\n\n let slot = document.createElement('slot');\n\n let ending = document.createElement('slot');\n ending.setAttribute('name', 'ending');\n\n if (WjElementUtils.hasSlot(this, 'loader')) {\n let loading = document.createElement('div');\n loading.classList.add('loading');\n\n let loader = document.createElement('slot');\n loader.setAttribute('name', 'loader');\n\n loading.appendChild(loader);\n\n this.loadingEl = loading;\n\n fragment.appendChild(loading);\n }\n\n native.appendChild(slot);\n native.appendChild(ending);\n\n fragment.appendChild(native);\n\n this.endingEl = ending;\n\n return fragment;\n }\n\n /**\n * Called after the component has been drawn.\n */\n async afterDraw() {\n this.queryParams = this.queryParams || '';\n this.size = +this.size || 10;\n this.currentPage = 0;\n\n this.scrollEvent();\n this._loading = this.loadPages(this.currentPage);\n await this._loading;\n }\n\n /**\n * Attaches a scroll event listener to the current object.\n * The `scrollEvent` function binds the `onScroll` method to the 'scroll' event\n * of the current object. This enables handling of scroll events for\n * specific functionality such as updating UI elements, loading content dynamically,\n * or tracking user interaction with scrollable content.\n */\n scrollEvent = () => {\n this.addEventListener('scroll', this.onScroll);\n };\n\n /**\n * A function that removes the scroll event listener from the current context.\n * This function is used to unbind the `onScroll` event listener\n * from the `scroll` event of the current object. It ensures that\n * the scroll event no longer triggers the `onScroll` handler.\n * @function\n */\n unScrollEvent = () => {\n this.removeEventListener('scroll', this.onScroll);\n };\n\n /**\n * A scroll event handler function that checks the scroll position and triggers loading additional content\n * when the user scrolls near the bottom of the page.\n * Properties accessed:\n * - `scrollTop`: The number of pixels that the content of an element is scrolled vertically.\n * - `scrollHeight`: The total height of the element's content.\n * - `clientHeight`: The inner height of the element in pixels, including padding but excluding borders and scrollbars.\n * Conditions:\n * - Determines if the scroll position is within 300 pixels of the bottom of the element.\n * - Verifies that the current page number is less than or equal to the total number of pages.\n * - Checks if the current page is already in the loading state.\n * Actions:\n * - Increments the current page number when the conditions are met.\n * - Initiates loading for the next page by calling the `loadPages` function.\n * @param {Event} e The scroll event object.\n */\n onScroll = (e) => {\n const { scrollTop, scrollHeight, clientHeight } = e.target;\n\n if (\n scrollTop + clientHeight >= scrollHeight - 300 &&\n this.currentPage <= this.totalPages &&\n this.isLoading.includes(this.currentPage)\n ) {\n this.currentPage++;\n this._loading = this.loadPages(this.currentPage);\n }\n };\n\n /**\n * Fetches the pages from the server.\n * @param {number} page The page number.\n * @returns {Promise<object>} The response from the server.\n */\n async getPages(page) {\n let hasParams = this.url.includes('?');\n const response = await fetch(\n `${this.url}${hasParams ? '&' : '?'}page=${page}&size=${this.size}${this?.queryParams}`,\n {\n signal: this._signal,\n }\n );\n\n if (!response.ok) {\n throw new Error(`An error occurred: ${response.status}`);\n }\n return await response.json();\n }\n\n /**\n * Hides the loader.\n */\n hideLoader() {\n this?.loadingEl?.classList.remove('show');\n }\n\n /**\n * Displays the loader element by adding the 'show' class to its class list.\n * This method is useful for indicating a loading or processing state in the UI.\n * @returns {void} No return value.\n */\n showLoader() {\n this?.loadingEl?.classList.add('show');\n }\n\n /**\n * Checks if there are more pages to load.\n * @param {number} page The page number.\n * @returns {boolean} Whether there are more pages to load.\n */\n hasMorePages(page) {\n return this.totalPages === 0 || page < this.totalPages;\n }\n\n /**\n * Loads the pages.\n * @param {number} page The page number.\n */\n async loadPages(page) {\n this.showLoader();\n try {\n if (this.hasMorePages(page)) {\n let response;\n this.parser = new DOMParser();\n\n if (typeof this.setCustomData === 'function') {\n response = await this.setCustomData(page, this._signal);\n } else {\n response = await this.getPages(page);\n }\n\n this.totalPages = response?.totalPages;\n this.currentPage = page;\n\n this.placementObj = this;\n\n // if there is a \"container\" attribute, find the element\n if (this.hasAttribute('placement')) this.placementObj = this.querySelector(this.placement);\n\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:load', response);\n\n this.response = response;\n this._loadedItems = this.objectName ? response[this.objectName] : response;\n const notDrawnItems = this._loadedItems.filter((item) => !this._drawnItems.some(this.compareFunction.bind(this, item)));\n this.customForeach(notDrawnItems);\n this._drawnItems.push(...notDrawnItems);\n\n this.isLoading.push(page);\n } else {\n event.dispatchCustomEvent(this, 'wje-infinite-scroll:complete');\n this.endingEl.classList.add('show');\n }\n } catch (error) {\n console.log(error);\n } finally {\n this.hideLoader();\n }\n }\n\n compareFunction = (i, item) => i.id === item.id\n\n /**\n * Converts a data item into an HTML element based on a template.\n * This function takes a data item, interpolates it into a predefined template,\n * parses the resulting HTML string, and returns the first child element of the parsed HTML content.\n * @param {object} item The data object to interpolate into the HTML template.\n * @returns {Element} The first child element generated from the interpolated HTML string.\n */\n dataToHtml = (item) => {\n let interpolateItem = this.interpolate(this.infiniteScrollTemplate, item);\n let doc = this.parser.parseFromString(interpolateItem, 'text/html');\n let element = doc.activeElement.firstElementChild;\n\n return element;\n };\n\n /**\n * A custom implementation of the forEach method designed to iterate over an array of data,\n * transform each item into an HTML element, and append the element to a specified placement object.\n * Additionally, it adds an event listener to each generated element for handling click events.\n * @param {Array} data An array of items to process. Each item is transformed into an HTML element\n * and appended to the placement object specified in the context of `this`.\n */\n customForeach = (data) => {\n data.forEach((item) => {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n\n event.addListener(element, 'click', 'wje-infinite-scroll:click-item', null);\n\n this.placementObj.insertAdjacentElement('beforeend', element);\n });\n };\n\n /**\n * Interpolates a string template with values from the provided parameters object.\n * The template contains placeholders in the format `{{key}}` or `{{key.subkey}}`,\n * which are replaced with the corresponding values from the `params` object.\n * Placeholders support dot notation for accessing nested properties within the `params` object.\n * @param {string} template The string template containing placeholders to be replaced.\n * @param {object} params The object containing key-value pairs used for substitution in the template.\n * @returns {string} A string with all placeholders replaced by their respective values from the `params` object.\n */\n interpolate = (template, params) => {\n let keys = template.match(/\\{{.*?\\}}/g);\n\n if (keys) {\n for (let key of keys) {\n let cleanKey = key.replace('{{', '').replace('}}', '');\n let val = '';\n cleanKey.split('.').forEach((k) => {\n val = val === '' ? params[k] : val[k];\n });\n\n template = template.replace(key, val);\n }\n }\n return template;\n };\n\n addItem(item, place = 'beforeend') {\n let element = this.dataToHtml(item);\n this._dataToElementWeakMap.set(element, item);\n this.placementObj.insertAdjacentElement(place, element);\n\n this._drawnItems.push(item);\n\n // if drawnItems are more than page * size then add the page to isLoading\n if (this._drawnItems.length > this.size * this.currentPage) {\n this.totalPages += 1;\n }\n }\n\n removeItem(item) {\n let element = this._dataToElementWeakMap.get(item);\n element.remove();\n this._drawnItems = this._drawnItems.filter((i) => i !== item);\n // if drawnItems are less than page * size then remove the page from isLoading\n if (this._drawnItems.length < this.size * this.currentPage) {\n this.isLoading = this.isLoading.filter((i) => i !== this.currentPage);\n this.currentPage--;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAkBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIlD,cAAc;AACV,UAAO;AA2DX,qCAAY;AA0HZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,iBAAiB,UAAU,KAAK,QAAQ;AAAA,IAChD;AASD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yCAAgB,MAAM;AAClB,WAAK,oBAAoB,UAAU,KAAK,QAAQ;AAAA,IACnD;AAkBD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAW,CAAC,MAAM;AACd,YAAM,EAAE,WAAW,cAAc,aAAc,IAAG,EAAE;AAEpD,UACI,YAAY,gBAAgB,eAAe,OAC3C,KAAK,eAAe,KAAK,cACzB,KAAK,UAAU,SAAS,KAAK,WAAW,GAC1C;AACE,aAAK;AACL,aAAK,WAAW,KAAK,UAAU,KAAK,WAAW;AAAA,MAC3D;AAAA,IACK;AA4FD,2CAA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K,MAAM,IAAI,CAAC,CAAC;AACtH,aAAK,cAAc,aAAa;AAChC,aAAK,YAAY,KAAK,GAAG,aAAa;AAEtC,aAAK,UAAU,KAAK,IAAI;AAAA,MACxC,OAAmB;AACH,cAAM,oBAAoB,MAAM,8BAA8B;AAC9D,aAAK,SAAS,UAAU,IAAI,MAAM;AAAA,MAClD;AAAA,IACS,SAAQ,OAAO;AACZ,cAAQ,IAAI,KAAK;AAAA,IAC7B,UAAkB;AACN,WAAK,WAAY;AAAA,IAC7B;AAAA,EACA;AAAA,EA+DI,QAAQ,MAAM,QAAQ,aAAa;AAC/B,QAAI,UAAU,KAAK,WAAW,IAAI;AAClC,SAAK,sBAAsB,IAAI,SAAS,IAAI;AAC5C,SAAK,aAAa,sBAAsB,OAAO,OAAO;AAEtD,SAAK,YAAY,KAAK,IAAI;AAG1B,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,cAAc;AAAA,IAC/B;AAAA,EACA;AAAA,EAEI,WAAW,MAAM;AACb,QAAI,UAAU,KAAK,sBAAsB,IAAI,IAAI;AACjD,YAAQ,OAAQ;AAChB,SAAK,cAAc,KAAK,YAAY,OAAO,CAAC,MAAM,MAAM,IAAI;AAE5D,QAAI,KAAK,YAAY,SAAS,KAAK,OAAO,KAAK,aAAa;AACxD,WAAK,YAAY,KAAK,UAAU,OAAO,CAAC,MAAM,MAAM,KAAK,WAAW;AACpE,WAAK;AAAA,IACjB;AAAA,EACA;AACA;"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -97,7 +97,7 @@ export default class WJElement extends HTMLElement {
|
|
|
97
97
|
* Gets the rendering context, either the shadow root or the component itself.
|
|
98
98
|
* @returns The rendering context.
|
|
99
99
|
*/
|
|
100
|
-
get context():
|
|
100
|
+
get context(): any;
|
|
101
101
|
/**
|
|
102
102
|
* Gets the store instance.
|
|
103
103
|
* @returns {object} The store instance.
|
|
@@ -33,6 +33,10 @@ export default class InfiniteScroll extends WJElement {
|
|
|
33
33
|
_infiniteScrollTemplate: any;
|
|
34
34
|
_abortController: AbortController;
|
|
35
35
|
_signal: AbortSignal;
|
|
36
|
+
_dataToElementWeakMap: WeakMap<WeakKey, any>;
|
|
37
|
+
_drawnItems: any[];
|
|
38
|
+
_loadedItems: any[];
|
|
39
|
+
_actualDrawnIndex: number;
|
|
36
40
|
/**
|
|
37
41
|
* Dependencies of the InfiniteScroll component.
|
|
38
42
|
* @param value
|
|
@@ -144,6 +148,7 @@ export default class InfiniteScroll extends WJElement {
|
|
|
144
148
|
loadPages(page: number): Promise<void>;
|
|
145
149
|
parser: DOMParser;
|
|
146
150
|
placementObj: any;
|
|
151
|
+
compareFunction: (i: any, item: any) => boolean;
|
|
147
152
|
/**
|
|
148
153
|
* Converts a data item into an HTML element based on a template.
|
|
149
154
|
* This function takes a data item, interpolates it into a predefined template,
|
|
@@ -170,4 +175,6 @@ export default class InfiniteScroll extends WJElement {
|
|
|
170
175
|
* @returns {string} A string with all placeholders replaced by their respective values from the `params` object.
|
|
171
176
|
*/
|
|
172
177
|
interpolate: (template: string, params: object) => string;
|
|
178
|
+
addItem(item: any, place?: string): void;
|
|
179
|
+
removeItem(item: any): void;
|
|
173
180
|
}
|
|
@@ -95,9 +95,33 @@ export default class Options extends WJElement {
|
|
|
95
95
|
* @returns {boolean} True if the search attribute is present, false otherwise.
|
|
96
96
|
*/
|
|
97
97
|
get hasSearch(): boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Sets the value to define search-to-query params behavior.
|
|
100
|
+
* @param {string} value The value to be set for the search-to-query-params attribute.
|
|
101
|
+
*/
|
|
98
102
|
set searchToQueryParams(value: string);
|
|
99
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Retrieves the value of the 'search-to-query-params' attribute from the current instance.
|
|
105
|
+
* @returns {string | null} The value of the 'search-to-query-params' attribute, or null if the attribute is not set.
|
|
106
|
+
*/
|
|
107
|
+
get searchToQueryParams(): string | null;
|
|
108
|
+
/**
|
|
109
|
+
* Determines whether the 'search-to-query-params' attribute is present on the element.
|
|
110
|
+
* @returns {boolean} True if the 'search-to-query-params' attribute exists, otherwise false.
|
|
111
|
+
*/
|
|
100
112
|
get hasSearchToQueryParams(): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Sets the value of the search parameter name attribute.
|
|
115
|
+
* @param {string} value The string value to set as the search parameter name.
|
|
116
|
+
*/
|
|
117
|
+
set searchParamName(value: string);
|
|
118
|
+
/**
|
|
119
|
+
* Gets the search parameter name used in queries.
|
|
120
|
+
* Retrieves the value of the 'search-param-name' attribute.
|
|
121
|
+
* If the attribute is not set, it defaults to 'search'.
|
|
122
|
+
* @returns {string} The search parameter name used for queries.
|
|
123
|
+
*/
|
|
124
|
+
get searchParamName(): string;
|
|
101
125
|
/**
|
|
102
126
|
* Sets the lazy attribute.
|
|
103
127
|
* @param {boolean} value The value to set for the lazy attribute.
|
|
@@ -12,10 +12,11 @@ export default class PubSub {
|
|
|
12
12
|
/**
|
|
13
13
|
* If the passed event has callbacks attached to it, loop through each one and call it.
|
|
14
14
|
* @param {string} event The name of the event to publish
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {object} [
|
|
17
|
-
* @
|
|
15
|
+
* @param {any} state The current state to pass to the callbacks
|
|
16
|
+
* @param {object} [newData] The new data to pass to the callbacks
|
|
17
|
+
* @param {object} [oldData] The old data to pass to the callbacks
|
|
18
|
+
* @returns {Array} The results of the callbacks for this event, or an empty array if no event exists
|
|
18
19
|
* @memberof PubSub
|
|
19
20
|
*/
|
|
20
|
-
publish(event: string, newData?: object, oldData?: object): any[];
|
|
21
|
+
publish(event: string, state: any, newData?: object, oldData?: object): any[];
|
|
21
22
|
}
|
|
@@ -28,6 +28,28 @@ export default class Tab extends WJElement {
|
|
|
28
28
|
* @type {boolean}
|
|
29
29
|
*/
|
|
30
30
|
last: boolean;
|
|
31
|
+
_hasPanel: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the panel attribute to the specified value.
|
|
34
|
+
* @param {string} value The value to set for the panel attribute.
|
|
35
|
+
*/
|
|
36
|
+
set panel(value: string);
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the value of the 'panel' attribute of the element.
|
|
39
|
+
* @returns {string|null} Returns the 'panel' attribute value if it exists; otherwise, returns null.
|
|
40
|
+
*/
|
|
41
|
+
get panel(): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Sets the value of the 'route' attribute for the current object.
|
|
44
|
+
* @param {string} value The new value to set for the 'route' attribute.
|
|
45
|
+
*/
|
|
46
|
+
set route(value: string);
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the value of the 'route' attribute.
|
|
49
|
+
* If the 'route' attribute is not set, it returns null.
|
|
50
|
+
* @returns {string|null} The value of the 'route' attribute or null if not set.
|
|
51
|
+
*/
|
|
52
|
+
get route(): string | null;
|
|
31
53
|
/**
|
|
32
54
|
* Draws the component for the tab.
|
|
33
55
|
* @returns {DocumentFragment}
|
|
@@ -38,4 +60,5 @@ export default class Tab extends WJElement {
|
|
|
38
60
|
* // @fires wje-tab:change - Dispatched when the component is clicked, indicating a tab change.
|
|
39
61
|
*/
|
|
40
62
|
afterDraw(): void;
|
|
63
|
+
unbindRouterLinks: any;
|
|
41
64
|
}
|
|
@@ -31,10 +31,13 @@ export default class TabGroup extends WJElement {
|
|
|
31
31
|
* @returns {DocumentFragment}
|
|
32
32
|
*/
|
|
33
33
|
draw(context: object, store: object, params: object): DocumentFragment;
|
|
34
|
+
nav: HTMLElement;
|
|
35
|
+
moreDropdown: HTMLElement;
|
|
34
36
|
/**
|
|
35
37
|
* Sets up the event listeners after the component is drawn.
|
|
36
38
|
*/
|
|
37
39
|
afterDraw(): void;
|
|
40
|
+
checkOverflow(): void;
|
|
38
41
|
/**
|
|
39
42
|
* Removes the active attribute from all tabs and panels.
|
|
40
43
|
*/
|
|
@@ -64,4 +67,6 @@ export default class TabGroup extends WJElement {
|
|
|
64
67
|
* @returns {Array<string>} An array of all tab names.
|
|
65
68
|
*/
|
|
66
69
|
getPanelAllName(): Array<string>;
|
|
70
|
+
toggleMoreVisibility(): void;
|
|
71
|
+
dropdownActive(el: any): void;
|
|
67
72
|
}
|
package/dist/wje-dialog.js
CHANGED
|
@@ -19,7 +19,9 @@ class Dialog extends WJElement {
|
|
|
19
19
|
* @param e
|
|
20
20
|
*/
|
|
21
21
|
__publicField(this, "onOpen", (e) => {
|
|
22
|
-
this.dialog
|
|
22
|
+
if (this.dialog) {
|
|
23
|
+
this.dialog.innerHTML = "";
|
|
24
|
+
}
|
|
23
25
|
Promise.resolve(this.beforeOpen(this, e)).then((res) => {
|
|
24
26
|
this.htmlDialogBody(this.dialog);
|
|
25
27
|
this.dialog.showModal();
|
package/dist/wje-dialog.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-dialog.js","sources":["../packages/wje-dialog/dialog.element.js","../packages/wje-dialog/dialog.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n /**\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n return fragment;\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n close.appendChild(icon);\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.getAttribute('headline')}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n header.appendChild(headerActions);\n if (!this.closeHidden) header.appendChild(close);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n body.appendChild(contentSlot);\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n\n footer.appendChild(slotFooter);\n\n dialog.appendChild(header);\n dialog.appendChild(body);\n dialog.appendChild(footer);\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n\n //this.dialog.addEventListener('close', this.onClose);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen() {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen() {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose() {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose() {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n this.dialog.innerHTML = '';\n\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n };\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n console.log('Button clicked');\n\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport default Dialog;\n\nDialog.define('wje-dialog', Dialog);\n"],"names":[],"mappings":";;;;;AA2Be,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc;AACV,UAAO;AAuDX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAwKZ;AAAA;AAAA;AAAA;AAAA,kCAAS,CAAC,MAAM;AAC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oBAAoB,OAAO,MAAM;AACrD,cAAQ,IAAI,gBAAgB;AAE5B,UAAI,kBAAkB,SAAS,cAAc,KAAK;AAClD,sBAAgB,UAAU,IAAI,kBAAkB;AAEhD,UAAI,OAAO,SAAS,cAAc,UAAU;AAC5C,WAAK,aAAa,QAAQ,UAAU;AACpC,WAAK,aAAa,QAAQ,UAAU;AAEpC,sBAAgB,YAAY,IAAI;AAEhC,UAAI,eAAe,KAAK,OAAO;AAC/B,sBAAgB,MAAM,MAAM,GAAG,YAAY;AAC3C,sBAAgB,MAAM,SAAS,IAAI,YAAY;AAE/C,WAAK,OAAO,YAAY,eAAe;AAEvC,YAAM,QAAO,EACR,KAAK,CAAC,QAAQ;AACX,aAAK,MAAO;AACZ,wBAAgB,OAAQ;AAAA,MAC3B,CAAA,EACA,MAAM,CAAC,QAAQ;AACZ,gBAAQ,MAAM,GAAG;AACjB,wBAAgB,OAAQ;AAAA,MAC5C,CAAiB;AAAA,IACjB,CAAS;AAAA,EACT;AACA;AC3TA,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-dialog.js","sources":["../packages/wje-dialog/dialog.element.js","../packages/wje-dialog/dialog.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport '../wje-button/button.element.js';\nimport '../wje-icon/icon.element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `Dialog` is a custom web component that represents a dialog.\n * @summary This element represents a dialog.\n * @documentation https://elements.webjet.sk/components/dialog\n * @status stable\n * @augments {WJElement}\n * @slot header - Slot for the header content.\n * @slot body - Slot for the body content.\n * @slot footer - Slot for the footer content.\n * @csspart dialog - The dialog wrapper.\n * @csspart header - The header of the dialog.\n * @csspart body - The body of the dialog.\n * @csspart footer - The footer of the dialog.\n * @csspart close - The close button of the dialog.\n * @cssproperty [--wje-dialog-background=var(--wje-background-color)] - Specifies the background color of the dialog.\n * @cssproperty [--wje-dialog-color=var(--wje-text-color)] - Defines the text color within the dialog.\n * @cssproperty [--wje-dialog-padding=1rem] - Controls the padding inside the dialog.\n * @cssproperty [--wje-dialog-border-radius=0.5rem] - Sets the border radius for the dialog's corners.\n * @cssproperty [--wje-dialog-box-shadow=0 2px 10px rgba(0, 0, 0, 0.1)] - Applies a shadow effect to the dialog.\n * @tag wje-dialog\n */\n\nexport default class Dialog extends WJElement {\n /**\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set placement(value) {\n this.setAttribute('placement', value);\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {string|string}\n */\n get placement() {\n return this.getAttribute('placement') || 'slide-up';\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set async(value) {\n this.setAttribute('async', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get async() {\n return this.hasAttribute('async');\n }\n\n /**\n * Sets the headline of the dialog.\n * @param value\n */\n set closeHidden(value) {\n if (value) this.setAttribute('close-hidden', '');\n }\n\n /**\n * Gets the headline of the dialog.\n * @returns {boolean}\n */\n get closeHidden() {\n return !!this.hasAttribute('close-hidden');\n }\n\n /**\n * Sets the headline of the dialog.\n * @type {string}\n */\n className = 'Dialog';\n\n /**\n * Returns the CSS styles for the component.\n * @returns {*}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @returns {*[]}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.classList.add('fade', this.placement, params.size);\n\n let dialog = document.createElement('dialog');\n dialog.classList.add('modal-dialog');\n\n fragment.appendChild(dialog);\n\n this.dialog = dialog;\n return fragment;\n }\n\n /**\n * Creates the dialog body.\n * @param dialog\n */\n htmlDialogBody(dialog) {\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'x');\n icon.setAttribute('slot', 'icon-only');\n\n let close = document.createElement('wje-button');\n close.setAttribute('fill', 'link');\n close.setAttribute('size', 'small');\n close.setAttribute('part', 'close');\n close.addEventListener('click', (e) => {\n this.close(e);\n });\n close.appendChild(icon);\n\n let header = document.createElement('div');\n header.setAttribute('part', 'header');\n header.classList.add('dialog-header');\n if (this.hasAttribute('headline'))\n header.innerHTML = `<span part=\"headline\">${this.getAttribute('headline')}</span>`;\n\n let slotHeader = document.createElement('slot');\n slotHeader.setAttribute('name', 'header');\n\n const headerActions = document.createElement('div');\n headerActions.classList.add('header-actions');\n headerActions.setAttribute('part', 'header-actions');\n headerActions.appendChild(slotHeader);\n\n header.appendChild(headerActions);\n if (!this.closeHidden) header.appendChild(close);\n\n let contentSlot = document.createElement('slot');\n\n let body = document.createElement('div');\n body.setAttribute('part', 'body');\n body.classList.add('dialog-content');\n body.appendChild(contentSlot);\n\n let footer = document.createElement('div');\n footer.setAttribute('part', 'footer');\n footer.classList.add('dialog-footer');\n footer.innerHTML = '';\n\n let slotFooter = document.createElement('slot');\n slotFooter.setAttribute('name', 'footer');\n\n footer.appendChild(slotFooter);\n\n dialog.appendChild(header);\n dialog.appendChild(body);\n dialog.appendChild(footer);\n }\n\n /**\n * Closes the dialog.\n * @param e\n */\n close(e) {\n this.onClose(e);\n }\n\n /**\n * Draws the component after it has been drawn.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n */\n afterDraw(context, store, params) {\n if (params.trigger) {\n event.addListener(document, params.trigger, null, this.onOpen);\n }\n\n //this.dialog.addEventListener('close', this.onClose);\n }\n\n /**\n * Before the component is disconnected.\n */\n beforeDisconnect() {\n if (this.params?.trigger) {\n event.removeListener(document, this.params?.trigger, null, this.onOpen);\n }\n\n //this.dialog.removeEventListener('close', this.onClose);\n }\n\n /**\n * Before the dialog opens.\n */\n beforeOpen() {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * After the dialog opens.\n */\n afterOpen() {\n // Hook for extending behavior after the dialog opens\n }\n\n /**\n * Before the dialog closes.\n */\n beforeClose() {\n // Hook for extending behavior before the dialog closes\n }\n\n /**\n * After the dialog closes.\n */\n afterClose() {\n // Hook for extending behavior after the dialog closes\n }\n\n /**\n * Opens the dialog.\n * @param e\n */\n onOpen = (e) => {\n if (this.dialog) {\n this.dialog.innerHTML = '';\n }\n\n Promise.resolve(this.beforeOpen(this, e)).then((res) => {\n this.htmlDialogBody(this.dialog);\n\n this.dialog.showModal(); // Now open the dialog\n\n if (this.dialog.open) {\n Promise.resolve(this.afterOpen(this, e));\n }\n });\n }\n\n /**\n * Closes the dialog.\n * @param {object} e\n */\n onClose = (e) => {\n Promise.resolve(this.beforeClose(this, e)).then((res) => {\n this.dialog.close(); // Now close the dialog\n\n if (!this.dialog.open) {\n Promise.resolve(this.afterClose(this, e));\n }\n });\n };\n\n /**\n * Registers an event listener on the provided button that triggers a blocking UI element\n * and executes a given promise when the button is clicked.\n * @param {HTMLElement} button The button element to attach the event listener to.\n * @param {Function} promise A function that returns a promise to be executed when the button is clicked.\n */\n registerBlockingEvent(button, promise) {\n button.addEventListener('wje-button:click', async (e) => {\n console.log('Button clicked');\n\n let blockingElement = document.createElement('div');\n blockingElement.classList.add('blocking-element');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('name', 'loader-2');\n icon.setAttribute('size', '2x-large');\n\n blockingElement.appendChild(icon);\n\n let scrollOffset = this.dialog.scrollTop;\n blockingElement.style.top = `${scrollOffset}px`;\n blockingElement.style.bottom = `-${scrollOffset}px`;\n\n this.dialog.appendChild(blockingElement);\n\n await promise()\n .then((res) => {\n this.close();\n blockingElement.remove();\n })\n .catch((err) => {\n console.error(err);\n blockingElement.remove();\n });\n });\n }\n}\n","import Dialog from './dialog.element.js';\n\nexport default Dialog;\n\nDialog.define('wje-dialog', Dialog);\n"],"names":[],"mappings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,YAAY;AAAA,EAEhB;AAAA;AAAA;AAAA;AAAA,EAKI,cAAc;AAAA,EAElB;AAAA;AAAA;AAAA;AAAA,EAKI,aAAa;AAAA,EAEjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0CI,sBAAsB,QAAQ,SAAS;AACnC,WAAO,iBAAiB,oBAAoB,OAAO,MAAM;AACrD,cAAQ,IAAI,gBAAgB;AAE5B,UAAI,kBAAkB,SAAS,cAAc,KAAK;AAClD,sBAAgB,UAAU,IAAI,kBAAkB;AAEhD,UAAI,OAAO,SAAS,cAAc,UAAU;AAC5C,WAAK,aAAa,QAAQ,UAAU;AACpC,WAAK,aAAa,QAAQ,UAAU;AAEpC,sBAAgB,YAAY,IAAI;AAEhC,UAAI,eAAe,KAAK,OAAO;AAC/B,sBAAgB,MAAM,MAAM,GAAG,YAAY;AAC3C,sBAAgB,MAAM,SAAS,IAAI,YAAY;AAE/C,WAAK,OAAO,YAAY,eAAe;AAEvC,YAAM,QAAO,EACR,KAAK,CAAC,QAAQ;AACX,aAAK,MAAO;AACZ,wBAAgB,OAAQ;AAAA,MAC3B,CAAA,EACA,MAAM,CAAC,QAAQ;AACZ,gBAAQ,MAAM,GAAG;AACjB,wBAAgB,OAAQ;AAAA,MAC5C,CAAiB;AAAA,IACjB,CAAS;AAAA,EACT;AACA;AC7TA,OAAO,OAAO,cAAc,MAAM;"}
|
package/dist/wje-element.js
CHANGED
|
@@ -877,7 +877,7 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
877
877
|
async render() {
|
|
878
878
|
this.drawingStatus = this.drawingStatuses.DRAWING;
|
|
879
879
|
let _draw = this.draw(this.context, this.store, WjElementUtils.getAttributes(this));
|
|
880
|
-
if (_draw instanceof Promise) {
|
|
880
|
+
if (_draw instanceof Promise || (_draw == null ? void 0 : _draw.constructor.name) === "Promise") {
|
|
881
881
|
_draw = await _draw;
|
|
882
882
|
}
|
|
883
883
|
let rend = _draw;
|
|
@@ -964,12 +964,12 @@ const _WJElement = class _WJElement extends HTMLElement {
|
|
|
964
964
|
return new Promise(async (resolve, reject) => {
|
|
965
965
|
var _a;
|
|
966
966
|
const __beforeDraw = this.beforeDraw(this.context, this.store, WjElementUtils.getAttributes(this));
|
|
967
|
-
if (__beforeDraw instanceof Promise) {
|
|
967
|
+
if (__beforeDraw instanceof Promise || (__beforeDraw == null ? void 0 : __beforeDraw.constructor.name) === "Promise") {
|
|
968
968
|
await __beforeDraw;
|
|
969
969
|
}
|
|
970
970
|
await this.render();
|
|
971
971
|
const __afterDraw = (_a = this.afterDraw) == null ? void 0 : _a.call(this, this.context, this.store, WjElementUtils.getAttributes(this));
|
|
972
|
-
if (__afterDraw instanceof Promise) {
|
|
972
|
+
if (__afterDraw instanceof Promise || (__afterDraw == null ? void 0 : __afterDraw.constructor.name) === "Promise") {
|
|
973
973
|
await __afterDraw;
|
|
974
974
|
}
|
|
975
975
|
this.rendering = false;
|