wj-elements 0.1.147 → 0.1.149

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.
@@ -11,20 +11,40 @@ class InfiniteScroll extends WJElement {
11
11
  super();
12
12
  __publicField(this, "className", "InfiniteScroll");
13
13
  /**
14
- * Adds the scroll event listener.
14
+ * Attaches a scroll event listener to the current object.
15
+ * The `scrollEvent` function binds the `onScroll` method to the 'scroll' event
16
+ * of the current object. This enables handling of scroll events for
17
+ * specific functionality such as updating UI elements, loading content dynamically,
18
+ * or tracking user interaction with scrollable content.
15
19
  */
16
20
  __publicField(this, "scrollEvent", () => {
17
21
  this.addEventListener("scroll", this.onScroll);
18
22
  });
19
23
  /**
20
- * Removes the scroll event listener.
24
+ * A function that removes the scroll event listener from the current context.
25
+ * This function is used to unbind the `onScroll` event listener
26
+ * from the `scroll` event of the current object. It ensures that
27
+ * the scroll event no longer triggers the `onScroll` handler.
28
+ * @function
21
29
  */
22
30
  __publicField(this, "unScrollEvent", () => {
23
31
  this.removeEventListener("scroll", this.onScroll);
24
32
  });
25
33
  /**
26
- * Handles the scroll event.
27
- * @param {Event} e The event.
34
+ * A scroll event handler function that checks the scroll position and triggers loading additional content
35
+ * when the user scrolls near the bottom of the page.
36
+ * Properties accessed:
37
+ * - `scrollTop`: The number of pixels that the content of an element is scrolled vertically.
38
+ * - `scrollHeight`: The total height of the element's content.
39
+ * - `clientHeight`: The inner height of the element in pixels, including padding but excluding borders and scrollbars.
40
+ * Conditions:
41
+ * - Determines if the scroll position is within 300 pixels of the bottom of the element.
42
+ * - Verifies that the current page number is less than or equal to the total number of pages.
43
+ * - Checks if the current page is already in the loading state.
44
+ * Actions:
45
+ * - Increments the current page number when the conditions are met.
46
+ * - Initiates loading for the next page by calling the `loadPages` function.
47
+ * @param {Event} e The scroll event object.
28
48
  */
29
49
  __publicField(this, "onScroll", (e) => {
30
50
  const { scrollTop, scrollHeight, clientHeight } = e.target;
@@ -34,16 +54,25 @@ class InfiniteScroll extends WJElement {
34
54
  }
35
55
  });
36
56
  /**
37
- * Sets the custom data.
38
- *
57
+ * Converts a data item into an HTML element based on a template.
58
+ * This function takes a data item, interpolates it into a predefined template,
59
+ * parses the resulting HTML string, and returns the first child element of the parsed HTML content.
60
+ * @param {object} item The data object to interpolate into the HTML template.
61
+ * @returns {Element} The first child element generated from the interpolated HTML string.
39
62
  */
40
63
  __publicField(this, "dataToHtml", (item) => {
41
64
  let interpolateItem = this.interpolate(this.infiniteScrollTemplate, item);
42
65
  let doc = this.parser.parseFromString(interpolateItem, "text/html");
43
66
  let element = doc.activeElement.firstElementChild;
44
- console.log("IS Element:", element);
45
67
  return element;
46
68
  });
69
+ /**
70
+ * A custom implementation of the forEach method designed to iterate over an array of data,
71
+ * transform each item into an HTML element, and append the element to a specified placement object.
72
+ * Additionally, it adds an event listener to each generated element for handling click events.
73
+ * @param {Array} data An array of items to process. Each item is transformed into an HTML element
74
+ * and appended to the placement object specified in the context of `this`.
75
+ */
47
76
  __publicField(this, "customForeach", (data) => {
48
77
  data.forEach((item) => {
49
78
  let element = this.dataToHtml(item);
@@ -52,10 +81,13 @@ class InfiniteScroll extends WJElement {
52
81
  });
53
82
  });
54
83
  /**
55
- * Interpolates the string.
56
- * @param template
57
- * @param {object} params The parameters for interpolation.
58
- * @returns {string} The interpolated string.
84
+ * Interpolates a string template with values from the provided parameters object.
85
+ * The template contains placeholders in the format `{{key}}` or `{{key.subkey}}`,
86
+ * which are replaced with the corresponding values from the `params` object.
87
+ * Placeholders support dot notation for accessing nested properties within the `params` object.
88
+ * @param {string} template The string template containing placeholders to be replaced.
89
+ * @param {object} params The object containing key-value pairs used for substitution in the template.
90
+ * @returns {string} A string with all placeholders replaced by their respective values from the `params` object.
59
91
  */
60
92
  __publicField(this, "interpolate", (template, params) => {
61
93
  let keys = template.match(/\{{.*?\}}/g);
@@ -140,7 +172,10 @@ class InfiniteScroll extends WJElement {
140
172
  this.isShadowRoot = "open";
141
173
  }
142
174
  /**
143
- * Prepares the component before drawing.
175
+ * Prepares the component for updates before it is drawn.
176
+ * This method handles the removal of templates for iteration, adjusts the height styling of the component,
177
+ * and manages abort signals for loading operations.
178
+ * @returns {void} No return value.
144
179
  */
145
180
  beforeDraw() {
146
181
  var _a, _b;
@@ -155,8 +190,9 @@ class InfiniteScroll extends WJElement {
155
190
  }
156
191
  }
157
192
  /**
158
- * Draws the component and returns a document fragment.
159
- * @returns {DocumentFragment}
193
+ * Creates and returns a document fragment containing the structure for an infinite scroll component.
194
+ * The structure includes native elements, slots for customization, and optional loading content.
195
+ * @returns {DocumentFragment} The document fragment containing the component's DOM structure.
160
196
  */
161
197
  draw() {
162
198
  let fragment = document.createDocumentFragment();
@@ -218,7 +254,9 @@ class InfiniteScroll extends WJElement {
218
254
  (_a = this == null ? void 0 : this.loadingEl) == null ? void 0 : _a.classList.remove("show");
219
255
  }
220
256
  /**
221
- * Shows the loader.
257
+ * Displays the loader element by adding the 'show' class to its class list.
258
+ * This method is useful for indicating a loading or processing state in the UI.
259
+ * @returns {void} No return value.
222
260
  */
223
261
  showLoader() {
224
262
  var _a;
@@ -269,4 +307,4 @@ class InfiniteScroll extends WJElement {
269
307
  export {
270
308
  InfiniteScroll as I
271
309
  };
272
- //# sourceMappingURL=infinite-scroll.element-XVJukzjy.js.map
310
+ //# sourceMappingURL=infinite-scroll.element-DUjjOm1e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infinite-scroll.element-DUjjOm1e.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 }\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.iterate = this.querySelector('[iterate]');\n this.infiniteScrollTemplate = this.iterate?.outerHTML;\n this.iterate?.remove(); // remove template\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\n this.customForeach(this.objectName ? response[this.objectName] : response);\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 /**\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 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"],"names":[],"mappings":";;;;;AAkBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,EAIlD,cAAc;AACV,UAAO;AAuDX,qCAAY;AA6GZ;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;AAiGD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,SAAS;AACnB,UAAI,kBAAkB,KAAK,YAAY,KAAK,wBAAwB,IAAI;AACxE,UAAI,MAAM,KAAK,OAAO,gBAAgB,iBAAiB,WAAW;AAClE,UAAI,UAAU,IAAI,cAAc;AAEhC,aAAO;AAAA,IACV;A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a,IAAI,GAAG;AACzB,YAAI;AACJ,aAAK,SAAS,IAAI,UAAW;AAE7B,YAAI,OAAO,KAAK,kBAAkB,YAAY;AAC1C,qBAAW,MAAM,KAAK,cAAc,MAAM,KAAK,OAAO;AAAA,QAC1E,OAAuB;AACH,qBAAW,MAAM,KAAK,SAAS,IAAI;AAAA,QACvD;AAEgB,aAAK,aAAa,qCAAU;AAC5B,aAAK,cAAc;AAEnB,aAAK,eAAe;AAGpB,YAAI,KAAK,aAAa,WAAW,EAAG,MAAK,eAAe,KAAK,cAAc,KAAK,SAAS;AAEzF,cAAM,oBAAoB,MAAM,4BAA4B,QAAQ;AAEpE,aAAK,WAAW;AAEhB,aAAK,cAAc,KAAK,aAAa,SAAS,KAAK,UAAU,IAAI,QAAQ;AAEzE,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;AA0DA;"}
@@ -139,15 +139,20 @@ export default class Animation extends WJElement {
139
139
  */
140
140
  getAnimationsArray(): any[];
141
141
  /**
142
- * Method to destroy the current animation.
142
+ * Terminates and cleans up the currently active animation if it exists.
143
+ * Calls the `cancel` method to stop the animation process.
144
+ * @returns {void} Does not return any value.
143
145
  */
144
146
  destroyAnimation(): void;
145
147
  /**
146
- * Method to play the current animation.
148
+ * Plays the currently assigned animation, if available.
149
+ * @returns {void} This method does not return any value.
147
150
  */
148
151
  play(): void;
149
152
  /**
150
- * Method to cancel the current animation.
153
+ * Cancels the current animation if it is initialized and has a cancel method.
154
+ * Logs a warning if the animation is not initialized or the cancel method is unavailable.
155
+ * @returns {void} Does not return a value.
151
156
  */
152
157
  cancel(): void;
153
158
  }
@@ -60,12 +60,16 @@ export default class InfiniteScroll extends WJElement {
60
60
  set objectName(value: string);
61
61
  get objectName(): string;
62
62
  /**
63
- * Prepares the component before drawing.
63
+ * Prepares the component for updates before it is drawn.
64
+ * This method handles the removal of templates for iteration, adjusts the height styling of the component,
65
+ * and manages abort signals for loading operations.
66
+ * @returns {void} No return value.
64
67
  */
65
68
  beforeDraw(): void;
66
69
  /**
67
- * Draws the component and returns a document fragment.
68
- * @returns {DocumentFragment}
70
+ * Creates and returns a document fragment containing the structure for an infinite scroll component.
71
+ * The structure includes native elements, slots for customization, and optional loading content.
72
+ * @returns {DocumentFragment} The document fragment containing the component's DOM structure.
69
73
  */
70
74
  draw(): DocumentFragment;
71
75
  loadingEl: HTMLDivElement;
@@ -79,16 +83,36 @@ export default class InfiniteScroll extends WJElement {
79
83
  currentPage: number;
80
84
  _loading: Promise<void>;
81
85
  /**
82
- * Adds the scroll event listener.
86
+ * Attaches a scroll event listener to the current object.
87
+ * The `scrollEvent` function binds the `onScroll` method to the 'scroll' event
88
+ * of the current object. This enables handling of scroll events for
89
+ * specific functionality such as updating UI elements, loading content dynamically,
90
+ * or tracking user interaction with scrollable content.
83
91
  */
84
92
  scrollEvent: () => void;
85
93
  /**
86
- * Removes the scroll event listener.
94
+ * A function that removes the scroll event listener from the current context.
95
+ * This function is used to unbind the `onScroll` event listener
96
+ * from the `scroll` event of the current object. It ensures that
97
+ * the scroll event no longer triggers the `onScroll` handler.
98
+ * @function
87
99
  */
88
100
  unScrollEvent: () => void;
89
101
  /**
90
- * Handles the scroll event.
91
- * @param {Event} e The event.
102
+ * A scroll event handler function that checks the scroll position and triggers loading additional content
103
+ * when the user scrolls near the bottom of the page.
104
+ * Properties accessed:
105
+ * - `scrollTop`: The number of pixels that the content of an element is scrolled vertically.
106
+ * - `scrollHeight`: The total height of the element's content.
107
+ * - `clientHeight`: The inner height of the element in pixels, including padding but excluding borders and scrollbars.
108
+ * Conditions:
109
+ * - Determines if the scroll position is within 300 pixels of the bottom of the element.
110
+ * - Verifies that the current page number is less than or equal to the total number of pages.
111
+ * - Checks if the current page is already in the loading state.
112
+ * Actions:
113
+ * - Increments the current page number when the conditions are met.
114
+ * - Initiates loading for the next page by calling the `loadPages` function.
115
+ * @param {Event} e The scroll event object.
92
116
  */
93
117
  onScroll: (e: Event) => void;
94
118
  /**
@@ -102,7 +126,9 @@ export default class InfiniteScroll extends WJElement {
102
126
  */
103
127
  hideLoader(): void;
104
128
  /**
105
- * Shows the loader.
129
+ * Displays the loader element by adding the 'show' class to its class list.
130
+ * This method is useful for indicating a loading or processing state in the UI.
131
+ * @returns {void} No return value.
106
132
  */
107
133
  showLoader(): void;
108
134
  /**
@@ -119,16 +145,29 @@ export default class InfiniteScroll extends WJElement {
119
145
  parser: DOMParser;
120
146
  placementObj: any;
121
147
  /**
122
- * Sets the custom data.
123
- *
148
+ * Converts a data item into an HTML element based on a template.
149
+ * This function takes a data item, interpolates it into a predefined template,
150
+ * parses the resulting HTML string, and returns the first child element of the parsed HTML content.
151
+ * @param {object} item The data object to interpolate into the HTML template.
152
+ * @returns {Element} The first child element generated from the interpolated HTML string.
124
153
  */
125
- dataToHtml: (item: any) => Element;
126
- customForeach: (data: any) => void;
154
+ dataToHtml: (item: object) => Element;
127
155
  /**
128
- * Interpolates the string.
129
- * @param template
130
- * @param {object} params The parameters for interpolation.
131
- * @returns {string} The interpolated string.
156
+ * A custom implementation of the forEach method designed to iterate over an array of data,
157
+ * transform each item into an HTML element, and append the element to a specified placement object.
158
+ * Additionally, it adds an event listener to each generated element for handling click events.
159
+ * @param {Array} data An array of items to process. Each item is transformed into an HTML element
160
+ * and appended to the placement object specified in the context of `this`.
132
161
  */
133
- interpolate: (template: any, params: object) => string;
162
+ customForeach: (data: any[]) => void;
163
+ /**
164
+ * Interpolates a string template with values from the provided parameters object.
165
+ * The template contains placeholders in the format `{{key}}` or `{{key.subkey}}`,
166
+ * which are replaced with the corresponding values from the `params` object.
167
+ * Placeholders support dot notation for accessing nested properties within the `params` object.
168
+ * @param {string} template The string template containing placeholders to be replaced.
169
+ * @param {object} params The object containing key-value pairs used for substitution in the template.
170
+ * @returns {string} A string with all placeholders replaced by their respective values from the `params` object.
171
+ */
172
+ interpolate: (template: string, params: object) => string;
134
173
  }
@@ -4242,7 +4242,7 @@ class Animation extends WJElement {
4242
4242
  * @returns {Array} An array containing the name of the observed attribute.
4243
4243
  */
4244
4244
  static get observedAttributes() {
4245
- return ["name"];
4245
+ return [];
4246
4246
  }
4247
4247
  /**
4248
4248
  * Method to setup attributes for the Animation element.
@@ -4281,7 +4281,7 @@ class Animation extends WJElement {
4281
4281
  direction: this.direction,
4282
4282
  easing: this.easing
4283
4283
  });
4284
- if (this.animation) this.animation.play();
4284
+ if (this.animation && this.animation.playState === "idle") this.animation.play();
4285
4285
  }
4286
4286
  /**
4287
4287
  * Method to fetch and parse the animations array from a CSS file.
@@ -4291,7 +4291,9 @@ class Animation extends WJElement {
4291
4291
  return await fetchAndParseCSS(animations);
4292
4292
  }
4293
4293
  /**
4294
- * Method to destroy the current animation.
4294
+ * Terminates and cleans up the currently active animation if it exists.
4295
+ * Calls the `cancel` method to stop the animation process.
4296
+ * @returns {void} Does not return any value.
4295
4297
  */
4296
4298
  destroyAnimation() {
4297
4299
  if (this.animation) {
@@ -4299,7 +4301,8 @@ class Animation extends WJElement {
4299
4301
  }
4300
4302
  }
4301
4303
  /**
4302
- * Method to play the current animation.
4304
+ * Plays the currently assigned animation, if available.
4305
+ * @returns {void} This method does not return any value.
4303
4306
  */
4304
4307
  play() {
4305
4308
  if (this.animation) {
@@ -4307,7 +4310,9 @@ class Animation extends WJElement {
4307
4310
  }
4308
4311
  }
4309
4312
  /**
4310
- * Method to cancel the current animation.
4313
+ * Cancels the current animation if it is initialized and has a cancel method.
4314
+ * Logs a warning if the animation is not initialized or the cancel method is unavailable.
4315
+ * @returns {void} Does not return a value.
4311
4316
  */
4312
4317
  cancel() {
4313
4318
  if (this.animation && typeof this.animation.cancel === "function") {
@@ -1 +1 @@
1
- {"version":3,"file":"wje-animation.js","sources":["../packages/wje-animation/animation.element.js","../packages/wje-animation/animation.js"],"sourcesContent":["import { fetchAndParseCSS } from '../utils/animations.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from '../styles/styles.css?inline';\nimport animations from 'animate.css?inline';\n\n/**\n * @summary This class represents an Animation element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/animation\n * @status stable\n * @augments WJElement\n * @slot - The animation main content.\n * @cssproperty --size - The size of the avatar.\n * @tag wje-animation\n */\nexport default class Animation extends WJElement {\n /**\n * Constructor for the Animation class.\n */\n constructor() {\n super();\n this._animations = [];\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set name(value) {\n this.setAttribute('name', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get name() {\n return this.getAttribute('name') || 'heartBeat';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration') || 1000;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set delay(value) {\n this.setAttribute('delay', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get delay() {\n return +this.getAttribute('delay') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set endDelay(value) {\n this.setAttribute('endDelay', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get endDelay() {\n return +this.getAttribute('endDelay') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get fill() {\n return this.getAttribute('fill') || 'auto';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set iterations(value) {\n this.setAttribute('iterations', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string|number}\n */\n get iterations() {\n return this.getAttribute('iterations') || Infinity;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set iterationStart(value) {\n this.setAttribute('iterationStart', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get iterationStart() {\n return +this.getAttribute('iterationStart') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set direction(value) {\n this.setAttribute('direction', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get direction() {\n return this.getAttribute('direction') || 'normal';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set easing(value) {\n this.setAttribute('easing', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get easing() {\n return this.getAttribute('easing') || 'linear';\n }\n\n /**\n * Setter for the animations property.\n * @param {Array} value The new value for the animations property.\n */\n set animations(value) {\n this._animations = value;\n }\n\n /**\n * Getter for the animations' property.\n * @returns {Array} The current value of the animations' property.\n */\n get animations() {\n return this._animations;\n }\n\n /**\n * The class name for the Animation element.\n * @type {string}\n */\n className = 'Animation';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {object} The styles for the Animation element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An array containing the name of the observed attribute.\n */\n static get observedAttributes() {\n return ['name'];\n }\n\n /**\n * Method to setup attributes for the Animation element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the Animation element.\n * @returns {object} The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let slot = document.createElement('slot');\n\n fragment.appendChild(slot);\n\n this.slotEl = slot;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the Animation element is drawn.\n * This method destroys any existing animation, fetches a new animations array,\n * selects the appropriate animation, and applies it to the element.\n */\n async afterDraw() {\n this.destroyAnimation();\n\n const element = this.slotEl.assignedElements()[0];\n this.animations = await this.getAnimationsArray();\n const selected = await this.animations.find((k) => k.name === this.name);\n\n this.animation = element?.animate(selected?.keyframes, {\n delay: +this.delay,\n endDelay: +this.endDelay,\n fill: this.fill,\n duration: +this.duration,\n iterationStart: +this.iterationStart,\n iterations: this.iterations,\n direction: this.direction,\n easing: this.easing,\n });\n if (this.animation) this.animation.play();\n }\n\n /**\n * Method to fetch and parse the animations array from a CSS file.\n * @returns {Array} An array of animation definitions parsed from the CSS file.\n */\n async getAnimationsArray() {\n return await fetchAndParseCSS(animations);\n }\n\n /**\n * Method to destroy the current animation.\n */\n destroyAnimation() {\n if (this.animation) {\n this.cancel();\n }\n }\n\n /**\n * Method to play the current animation.\n */\n play() {\n if (this.animation) {\n this.animation.play();\n }\n }\n\n /**\n * Method to cancel the current animation.\n */\n cancel() {\n if (this.animation && typeof this.animation.cancel === 'function') {\n this.animation.cancel();\n } else {\n console.warn('Animation is not initialized or cancel is not available');\n }\n }\n}\n","import Animation from './animation.element.js';\n\nexport default Animation;\n\nAnimation.define('wje-animation', Animation);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAiB,UAAU;AAAA,EAChD;AAAA;AAAA;AAAA;AAAA,EAKI,mBAAmB;AACf,QAAI,KAAK,WAAW;AAChB,WAAK,OAAQ;AAAA,IACzB;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,OAAO;AACH,QAAI,KAAK,WAAW;AAChB,WAAK,UAAU,KAAM;AAAA,IACjC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKI,SAAS;AACL,QAAI,KAAK,aAAa,OAAO,KAAK,UAAU,WAAW,YAAY;AAC/D,WAAK,UAAU,OAAQ;AAAA,IACnC,OAAe;AACH,cAAQ,KAAK,yDAAyD;AAAA,IAClF;AAAA,EACA;AACA;AC7RA,UAAU,OAAO,iBAAiB,SAAS;"}
1
+ {"version":3,"file":"wje-animation.js","sources":["../packages/wje-animation/animation.element.js","../packages/wje-animation/animation.js"],"sourcesContent":["import { fetchAndParseCSS } from '../utils/animations.js';\nimport { default as WJElement } from '../wje-element/element.js';\nimport styles from '../styles/styles.css?inline';\nimport animations from 'animate.css?inline';\n\n/**\n * @summary This class represents an Animation element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/animation\n * @status stable\n * @augments WJElement\n * @slot - The animation main content.\n * @cssproperty --size - The size of the avatar.\n * @tag wje-animation\n */\nexport default class Animation extends WJElement {\n /**\n * Constructor for the Animation class.\n */\n constructor() {\n super();\n this._animations = [];\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set name(value) {\n this.setAttribute('name', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get name() {\n return this.getAttribute('name') || 'heartBeat';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set duration(value) {\n this.setAttribute('duration', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get duration() {\n return +this.getAttribute('duration') || 1000;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set delay(value) {\n this.setAttribute('delay', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get delay() {\n return +this.getAttribute('delay') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set endDelay(value) {\n this.setAttribute('endDelay', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get endDelay() {\n return +this.getAttribute('endDelay') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set fill(value) {\n this.setAttribute('fill', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get fill() {\n return this.getAttribute('fill') || 'auto';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set iterations(value) {\n this.setAttribute('iterations', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string|number}\n */\n get iterations() {\n return this.getAttribute('iterations') || Infinity;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set iterationStart(value) {\n this.setAttribute('iterationStart', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {number}\n */\n get iterationStart() {\n return +this.getAttribute('iterationStart') || 0;\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set direction(value) {\n this.setAttribute('direction', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get direction() {\n return this.getAttribute('direction') || 'normal';\n }\n\n /**\n * Setter for the name attribute.\n * @param value\n */\n set easing(value) {\n this.setAttribute('easing', value);\n }\n\n /**\n * Getter for the name attribute.\n * @returns {string}\n */\n get easing() {\n return this.getAttribute('easing') || 'linear';\n }\n\n /**\n * Setter for the animations property.\n * @param {Array} value The new value for the animations property.\n */\n set animations(value) {\n this._animations = value;\n }\n\n /**\n * Getter for the animations' property.\n * @returns {Array} The current value of the animations' property.\n */\n get animations() {\n return this._animations;\n }\n\n /**\n * The class name for the Animation element.\n * @type {string}\n */\n className = 'Animation';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {object} The styles for the Animation element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An array containing the name of the observed attribute.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Method to setup attributes for the Animation element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the Animation element.\n * @returns {object} The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let slot = document.createElement('slot');\n\n fragment.appendChild(slot);\n\n this.slotEl = slot;\n\n return fragment;\n }\n\n /**\n * Method to perform actions after the Animation element is drawn.\n * This method destroys any existing animation, fetches a new animations array,\n * selects the appropriate animation, and applies it to the element.\n */\n async afterDraw() {\n this.destroyAnimation();\n\n const element = this.slotEl.assignedElements()[0];\n this.animations = await this.getAnimationsArray();\n const selected = await this.animations.find((k) => k.name === this.name);\n\n this.animation = element?.animate(selected?.keyframes, {\n delay: +this.delay,\n endDelay: +this.endDelay,\n fill: this.fill,\n duration: +this.duration,\n iterationStart: +this.iterationStart,\n iterations: this.iterations,\n direction: this.direction,\n easing: this.easing,\n });\n\n if (this.animation && this.animation.playState === 'idle') this.animation.play();\n }\n\n /**\n * Method to fetch and parse the animations array from a CSS file.\n * @returns {Array} An array of animation definitions parsed from the CSS file.\n */\n async getAnimationsArray() {\n return await fetchAndParseCSS(animations);\n }\n\n /**\n * Terminates and cleans up the currently active animation if it exists.\n * Calls the `cancel` method to stop the animation process.\n * @returns {void} Does not return any value.\n */\n destroyAnimation() {\n if (this.animation) {\n this.cancel();\n }\n }\n\n /**\n * Plays the currently assigned animation, if available.\n * @returns {void} This method does not return any value.\n */\n play() {\n if (this.animation) {\n this.animation.play();\n }\n }\n\n /**\n * Cancels the current animation if it is initialized and has a cancel method.\n * Logs a warning if the animation is not initialized or the cancel method is unavailable.\n * @returns {void} Does not return a value.\n */\n cancel() {\n if (this.animation && typeof this.animation.cancel === 'function') {\n this.animation.cancel();\n } else {\n console.warn('Animation is not initialized or cancel is not available');\n }\n }\n}\n","import Animation from './animation.element.js';\n\nexport default Animation;\n\nAnimation.define('wje-animation', Animation);\n"],"names":[],"mapp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je-tooltip.js";
9
9
  import { P as Popup } from "./popup.element-tyYxow0p.js";
10
- import { I as InfiniteScroll } from "./infinite-scroll.element-XVJukzjy.js";
10
+ import { I as InfiniteScroll } from "./infinite-scroll.element-DUjjOm1e.js";
11
11
  const styles = "/*\n[ Wj Icon Picker ]\n*/\n\n:host {\n padding: 0 1rem;\n}\n\n.anchor {\n width: var(--wje-icon-picker-icon-size);\n height: var(--wje-icon-picker-icon-size);\n padding: var(--wje-icon-picker-padding);\n border-width: var(--wje-icon-picker-border-width);\n border-style: var(--wje-icon-picker-border-style);\n border-color: var(--wje-icon-picker-border-color);\n box-sizing: border-box;\n border-radius: var(--wje-icon-picker-radius);\n}\n\n.picker {\n width: 320px;\n height: 271px;\n box-shadow:\n 0 0 5px rgba(0, 0, 0, 0.05),\n 0 5px 20px rgba(0, 0, 0, 0.1);\n border-radius: var(--wje-icon-picker-radius);\n border-width: var(--wje-icon-picker-border-width);\n border-style: var(--wje-icon-picker-border-style);\n border-color: var(--wje-icon-picker-border-color);\n overflow: auto;\n padding: 1rem;\n background: var(--wje-background);\n}\n\n.icon-items {\n --icon-min-width: 2rem;\n display: grid;\n grid-gap: 0.5rem;\n grid-template-columns: repeat(auto-fit, minmax(var(--icon-min-width), 1fr));\n}\n\n.icon-item {\n box-sizing: border-box;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n color: inherit;\n padding: 0.25rem;\n min-height: var(--wje-icon-picker-icon-size);\n min-width: var(--wje-icon-picker-icon-size);\n text-decoration: none;\n\n &:hover {\n border-radius: 0.25rem;\n background: var(--wje-border-color);\n }\n}\n\n.wje-size {\n --wje-icon-size: 24px !important;\n}\n\nicon-item svg {\n width: var(--wje-icon-picker-icon-size);\n height: var(--wje-icon-picker-icon-size);\n}\n\nwje-input {\n --wje-input-border-radius: 4px;\n --wje-input-margin-bottom: 0;\n}\n\nwje-infinite-scroll {\n margin-top: 1rem;\n}\n\nwje-select {\n --wje-select-border-width: 0 0 1px 0 !important;\n --wje-select-border-radius: 0 !important;\n margin-bottom: 1rem;\n}\n\n.anchor wje-icon {\n --wje-icon-size: 100% !important;\n}\n";
12
12
  class IconPicker extends WJElement {
13
13
  /**
package/dist/wje-img.js CHANGED
@@ -142,6 +142,10 @@ class Img extends WJElement {
142
142
  native.setAttribute("src", this.loader || "./assets/img/image-loader.gif");
143
143
  native.setAttribute("alt", this.alt || "");
144
144
  native.classList.add("lazy-loaded-image", "lazy");
145
+ native.addEventListener("error", (e) => {
146
+ let parent = this.parentElement;
147
+ if (parent.tagName === "WJE-AVATAR") parent.initials = true;
148
+ });
145
149
  this.onerrorFunc(native);
146
150
  this.native = native;
147
151
  fragment.appendChild(native);
@@ -1 +1 @@
1
- {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n }\n }\n\n /**\n * Sets the value of the `src` attribute for the element.\n * @param {string} value The value to set for the `src` attribute.\n */\n set src(value) {\n this.setAttribute('src', value);\n }\n\n /**\n * Retrieves the value of the 'src' attribute from the element.\n * @returns {string} The value of the 'src' attribute.\n */\n get src() {\n return this.getAttribute('src');\n }\n\n /**\n * Sets the value of the 'alt' attribute for the element.\n * @param {string} value The new value to set for the 'alt' attribute.\n */\n set alt(value) {\n this.setAttribute('alt', value);\n }\n\n /**\n * Retrieves the value of the 'alt' attribute for the current element.\n * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.\n */\n get alt() {\n return this.getAttribute('alt');\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the value of the 'loader' attribute from the element.\n * @returns {string|null} The value of the 'loader' attribute if set, otherwise null.\n */\n get loader() {\n return this.getAttribute('loader');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\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 * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.loader || './assets/img/image-loader.gif');\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n\n this.onerrorFunc(native);\n\n this.native = native;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n // console.log(\"SRC INTERSECTING\", this.src, entry.target);\n entry.target.src = this.src;\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n }\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = (img) => {\n // console.log(img, this.fallout);\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n img.onerror = this.actions[this.fallout];\n } else {\n console.error('Un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4BAAkB,UAAU,MAAM,MAAM;AAAA,QAC5D;AAAA,MACA,CAAa;AAAA,IACb,CAAS;AAED,sBAAkB,QAAQ,KAAK,MAAM;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBI,UAAU,MAAM,MAAM;AAClB,QAAI,OAAO,SAAS,YAAY;AAC5B,WAAK,QAAQ,IAAI,IAAI;AAAA,IACjC,OAAe;AACH,cAAQ,MAAM,gCAAgC;AAAA,IAC1D;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,aAAa,MAAM;AACf,QAAI,KAAK,QAAQ,IAAI,GAAG;AACpB,aAAO,KAAK,QAAQ,IAAI;AAAA,IACpC,OAAe;AACH,cAAQ,MAAM,WAAW,IAAI,mBAAmB;AAAA,IAC5D;AAAA,EACA;AAqBA;ACvOA,IAAI,OAAO,WAAW,GAAG;"}
1
+ {"version":3,"file":"wje-img.js","sources":["../packages/wje-img/img.element.js","../packages/wje-img/img.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This element represents an image. `Img` is a custom web component that represents an image. It extends from `WJElement`.\n * @documentation https://elements.webjet.sk/components/img\n * @status stable\n * @augments {WJElement}\n * @cssproperty --img-width - The width of the image\n * @cssproperty --img-height - The height of the image\n * @property {string} src - The source URL of the image.\n * @property {string} alt - The alternative text for the image.\n * @property {string} fallout - The action to perform when an error occurs while loading the image. The value can be a function or a predefined action like 'delete'.\n * @property {string} loader - The URL of the image loader to display while the image is loading.\n * @tag wje-img\n */\nexport default class Img extends WJElement {\n /**\n * Creates an instance of Img.\n * @class\n */\n constructor() {\n super();\n\n this._fallout = false;\n\n this.actions = {\n delete: () => this.deleteImage(),\n log: () => console.error('Error log pre obrázok:', this.src),\n }\n }\n\n /**\n * Sets the value of the `src` attribute for the element.\n * @param {string} value The value to set for the `src` attribute.\n */\n set src(value) {\n this.setAttribute('src', value);\n }\n\n /**\n * Retrieves the value of the 'src' attribute from the element.\n * @returns {string} The value of the 'src' attribute.\n */\n get src() {\n return this.getAttribute('src');\n }\n\n /**\n * Sets the value of the 'alt' attribute for the element.\n * @param {string} value The new value to set for the 'alt' attribute.\n */\n set alt(value) {\n this.setAttribute('alt', value);\n }\n\n /**\n * Retrieves the value of the 'alt' attribute for the current element.\n * @returns {string|null} The value of the 'alt' attribute, or null if the attribute is not set.\n */\n get alt() {\n return this.getAttribute('alt');\n }\n\n /**\n * Sets the fallout property. Updates the `fallout` attribute if the value is a string;\n * otherwise, assigns the value to the `_fallout` property.\n * @param {string|*} value The value to set for the fallout property. If a string, it will update the `fallout` attribute; for other types, it will assign it to the `_fallout` property.\n */\n set fallout(value) {\n if (typeof value === 'string') {\n this.setAttribute('fallout', value);\n } else {\n this._fallout = value;\n }\n }\n\n /**\n * Retrieves the value of the 'fallout' attribute if it exists, otherwise returns the internal `_fallout` property.\n * @returns {string|null} The value of the 'fallout' attribute or the `_fallout` property if the attribute is not present. Returns null if no value is found.\n */\n get fallout() {\n return this.hasAttribute('fallout') ? this.getAttribute('fallout') : this._fallout;\n }\n\n /**\n * Sets the value of the loader attribute.\n * @param {string} value The value to set for the loader attribute.\n */\n set loader(value) {\n if (value) {\n this.setAttribute('loader', value);\n }\n }\n\n /**\n * Retrieves the value of the 'loader' attribute from the element.\n * @returns {string|null} The value of the 'loader' attribute if set, otherwise null.\n */\n get loader() {\n return this.getAttribute('loader');\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Img';\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 * Creates and assembles a lazy-loaded image element within a document fragment.\n * @returns {DocumentFragment} A document fragment containing the image element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('img');\n native.setAttribute('part', 'native');\n native.setAttribute('src', this.loader || './assets/img/image-loader.gif');\n native.setAttribute('alt', this.alt || '');\n native.classList.add('lazy-loaded-image', 'lazy');\n native.addEventListener('error', (e) => {\n let parent = this.parentElement;\n if(parent.tagName === 'WJE-AVATAR') parent.initials = true;\n });\n\n this.onerrorFunc(native);\n\n this.native = native;\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Handles post-draw operations, such as setting up a lazy image loader using an IntersectionObserver.\n * Observes when the target element becomes visible in the viewport and updates its source with the provided image source.\n * Removes the `lazy` class once the image source is updated and unobserves the element.\n * It also invokes the `onerrorFunc` method at the beginning to handle potential error scenarios.\n * @returns {void} Does not return a value.\n */\n afterDraw() {\n\n\n let lazyImageObserver = new IntersectionObserver((entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n entry.target.src = this.src;\n this.classList.remove('lazy');\n lazyImageObserver.unobserve(entry.target);\n }\n });\n });\n\n lazyImageObserver.observe(this.native);\n }\n\n /**\n * Deletes the current image by calling the remove method.\n * This function is typically used to trigger the removal of an image element\n * or perform cleanup operations related to the image.\n */\n deleteImage = () => {\n this.remove();\n }\n\n /**\n * Adds a new action to the internal actions object.\n * @param {string} name The name of the action to be added.\n * @param {Function} func The function representing the action logic.\n * @returns {void} This method does not return a value.\n */\n addAction(name, func) {\n if (typeof func === 'function') {\n this.actions[name] = func;\n } else {\n console.error('The action must be a function.');\n }\n }\n\n /**\n * Removes an action from the actions list if it exists.\n * @param {string} name The name of the action to remove.\n * @returns {void} Does not return a value.\n */\n removeAction(name) {\n if (this.actions[name]) {\n delete this.actions[name];\n } else {\n console.error(`Action \"${name}\" does not exist.`);\n }\n }\n\n\n /**\n * Handles error scenarios by checking the `fallout` property and performing\n * corresponding actions. If `fallout` is not defined, the function terminates\n * early. Logs the active actions and attempts to assign an error handler\n * based on the `fallout` value. If the `fallout` value does not correspond to\n * a recognized action, it logs an error message.\n * @function onerrorFunc\n * @memberof Img\n */\n onerrorFunc = (img) => {\n if (!this.fallout) return;\n if (this.actions[this.fallout]) {\n img.onerror = this.actions[this.fallout];\n } else {\n console.error('Unsupported value:', this.fallout);\n }\n }\n}\n","import Img from './img.element.js';\n\nexport default Img;\n\nImg.define('wje-img', Img);\n"],"names":[],"mappings":";;;;;AAgBe,MAAM,YAAY,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKvC,cAAc;AACV,UAAO;AAqFX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAiFZ;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,MAAM;AAChB,WAAK,OAAQ;AAAA,IACrB;AAuCI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uCAAc,CAAC,QAAQ;AACnB,UAAI,CAAC,KAAK,QAAS;AACnB,UAAI,KAAK,QAAQ,KAAK,OAAO,GAAG;AAC5B,YAAI,UAAU,KAAK,QAAQ,KAAK,OAAO;AAAA,MACnD,OAAe;AACH,gBAAQ,MAAM,sBAAsB,KAAK,OAAO;AAAA,MAC5D;AAAA,IACA;AApNQ,SAAK,WAAW;AAEhB,SAAK,UAAU;AAAA,MACX,QAAQ,MAAM,KAAK,YAAa;AAAA,MAChC,KAAK,MAAM,QAAQ,MAAM,0BAA0B,KAAK,GAAG;AAAA,IACvE;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,IAAI,OAAO;AACX,SAAK,aAAa,OAAO,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM;AACN,WAAO,KAAK,aAAa,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,IAAI,OAAO;AACX,SAAK,aAAa,OAAO,KAAK;AAAA,EACtC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM;AACN,WAAO,KAAK,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MAAM;AAE3B,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASI,YAAY;AAGR,QAAI,oBAAoB,IAAI,qBAAqB,CAAC,SAAS,aAAa;AACpE,cAAQ,QAAQ,CAAC,UAAU;AACvB,YAAI,MAAM,gBAAgB;AACtB,gBAAM,OAAO,MAAM,KAAK;AACxB,eAAK,UAAU,OAAO,MAAM;AAC5B,4BAAkB,UAAU,MAAM,MAAM;AAAA,QAC5D;AAAA,MACA,CAAa;AAAA,IACb,CAAS;AAED,sBAAkB,QAAQ,KAAK,MAAM;AAAA,EAC7C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBI,UAAU,MAAM,MAAM;AAClB,QAAI,OAAO,SAAS,YAAY;AAC5B,WAAK,QAAQ,IAAI,IAAI;AAAA,IACjC,OAAe;AACH,cAAQ,MAAM,gCAAgC;AAAA,IAC1D;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,aAAa,MAAM;AACf,QAAI,KAAK,QAAQ,IAAI,GAAG;AACpB,aAAO,KAAK,QAAQ,IAAI;AAAA,IACpC,OAAe;AACH,cAAQ,MAAM,WAAW,IAAI,mBAAmB;AAAA,IAC5D;AAAA,EACA;AAoBA;ACzOA,IAAI,OAAO,WAAW,GAAG;"}
@@ -1,4 +1,4 @@
1
- import { I as InfiniteScroll } from "./infinite-scroll.element-XVJukzjy.js";
1
+ import { I as InfiniteScroll } from "./infinite-scroll.element-DUjjOm1e.js";
2
2
  InfiniteScroll.define("wje-infinite-scroll", InfiniteScroll);
3
3
  export {
4
4
  InfiniteScroll as default
@@ -100,7 +100,7 @@ import { default as default88 } from "./wje-tooltip.js";
100
100
  import { default as default89 } from "./wje-tree.js";
101
101
  import { default as default90 } from "./wje-tree-item.js";
102
102
  import { default as default91 } from "./wje-visually-hidden.js";
103
- import { I } from "./infinite-scroll.element-XVJukzjy.js";
103
+ import { I } from "./infinite-scroll.element-DUjjOm1e.js";
104
104
  import { L } from "./list.element-Ce1vIm1O.js";
105
105
  import { P } from "./popup.element-tyYxow0p.js";
106
106
  function formatDate(input, format) {
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import WJElement, { event } from "./wje-element.js";
5
- import { I as InfiniteScroll } from "./infinite-scroll.element-XVJukzjy.js";
5
+ import { I as InfiniteScroll } from "./infinite-scroll.element-DUjjOm1e.js";
6
6
  import { L as List } from "./list.element-Ce1vIm1O.js";
7
7
  import Option from "./wje-option.js";
8
8
  class Options extends WJElement {
@@ -235,7 +235,7 @@ class Pagination extends WJElement {
235
235
  * @returns {Array} The attributes to observe for changes.
236
236
  */
237
237
  static get observedAttributes() {
238
- return ["page"];
238
+ return ["page", "totalItems"];
239
239
  }
240
240
  /**
241
241
  * Sets up the attributes for the component.
@@ -1 +1 @@
1
- {"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n if (currentPage <= pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage > totalPages - pagesNearEnd + 1) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages : currentPage + halfPages - 1;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n totalItems: totalItems,\n currentPage: currentPage,\n pageSize: pageSize,\n totalPages: totalPages,\n startPage: startPage,\n endPage: endPage,\n startIndex: startIndex,\n endIndex: endIndex,\n pages: pages,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 3;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n // console.log('totalItems nastavené na:', value);\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n // console.log(\"SOM V TOTAL ITEMS:\", this, this.getAttribute('total-items'));\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n // console.log('paginateObj nastavené na:', value);\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\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 * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n async beforeDraw() {\n this.paginateObj = await paginate(this.totalItems, this.page + 1, this.pageSize, this.maxPages)\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n // console.log(\"SOM PAGINATE OBJ:\",this.paginateObj);\n let fragment = document.createDocumentFragment();\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj.startIndex + 1} - ${this.paginateObj.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if(this.page === 0)\n prevButton.disabled = true;\n prevButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if(this.paginateObj.endIndex + 1 >= this.totalItems)\n nextButton.disabled = true;\n nextButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('wje-button:click', (e) =>\n this.pageClickAction(e, this.paginateObj.totalPages - 1)\n );\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj.totalPages;\n last.addEventListener('wje-button:click', (e) => this.pageClickAction(e, paginateObj.totalPages - 1));\n\n if (paginateObj.currentPage > this.maxPages + 1) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n newButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, page - 1));\n\n if (page - 1 === this.page) newButton.removeAttribute('fill');\n\n fragment.appendChild(newButton);\n });\n\n if (paginateObj.pages.length === this.maxPages || paginateObj.currentPage <= this.maxPages + 1) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page) return;\n\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', this.paginateObj);\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],"names":[],"mappings":";;;;;;;AAQO,SAAS,SAAS,YAAY,cAAc,GAAG,WAAW,IAAI,WAAW,GAAG;AAE/E,QAAM,aAAa,KAAK,KAAK,aAAa,QAAQ;AAGlD,MAAI,cAAc,GAAG;AACjB,kBAAc;AAAA,EACtB,WAAe,cAAc,YAAY;AACjC,kBAAc;AAAA,EACtB;AAEI,MAAI;AACJ,MAAI;AAEJ,QAAM,eAAe,WAAW;AAEhC,MAA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AAU,iBAAiB,oBAAoB,CAAC,MAAM,KAAK,gBAAgB,GAAG,OAAO,CAAC,CAAC;AAEvF,UAAI,OAAO,MAAM,KAAK,KAAM,WAAU,gBAAgB,MAAM;AAE5D,eAAS,YAAY,SAAS;AAAA,IAC1C,CAAS;AAED,QAAI,YAAY,MAAM,WAAW,KAAK,YAAY,YAAY,eAAe,KAAK,WAAW,GAAG;AAC5F,eAAS,YAAY,KAAK,UAAU,IAAI,CAAC;AACzC,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,WAAO;AAAA,EACf;AAgBA;AAEA,WAAW,OAAO,kBAAkB,UAAU;AC/X9C,WAAW,OAAO,kBAAkB,UAAU;"}
1
+ {"version":3,"file":"wje-pagination.js","sources":["../packages/wje-pagination/service/service.js","../packages/wje-pagination/pagination.element.js","../packages/wje-pagination/pagination.js"],"sourcesContent":["/**\n * Paginates items based on the total number of items, current page, page size, and maximum number of pages to display.\n * @param {number} totalItems The total number of items to paginate.\n * @param {number} [currentPage] The current page number (default is 1).\n * @param {number} [pageSize] The number of items per page (default is 10).\n * @param {number} [maxPages] The maximum number of pages to display in the pagination control (default is 5).\n * @returns {object} An object containing pagination details including total items, current page, page size, total pages, start/end page, start/end index, and the pages array.\n */\nexport function paginate(totalItems, currentPage = 1, pageSize = 10, maxPages = 5) {\n // Calculate total pages\n const totalPages = Math.ceil(totalItems / pageSize);\n\n // Ensure current page is within valid range\n if (currentPage < 1) {\n currentPage = 1;\n } else if (currentPage > totalPages) {\n currentPage = totalPages;\n }\n\n let startPage;\n let endPage;\n\n const pagesNearEnd = maxPages + 1; // Define how close to the end we switch back to 5 pages 4\n\n if (currentPage <= pagesNearEnd) {\n // If in the first 4 pages, show up to 5 pages\n startPage = 1;\n endPage = Math.min(pagesNearEnd + 1, totalPages); //5\n } else if (currentPage > totalPages - pagesNearEnd + 1) {\n // If within 4 pages from the end, show last 5 pages\n startPage = Math.max(totalPages - pagesNearEnd, 1); //4\n endPage = totalPages;\n } else {\n const halfPages = Math.floor(maxPages / 2);\n\n // Otherwise, only show 3 pages (current, previous, next)\n startPage = currentPage - halfPages;\n endPage = maxPages % 2 === 1 ? currentPage + halfPages : currentPage + halfPages - 1;\n }\n\n // Calculate start and end item indexes\n const startIndex = (currentPage - 1) * pageSize;\n const endIndex = Math.min(startIndex + pageSize - 1, totalItems - 1);\n\n // Create an array of pages to display\n const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i);\n\n // Return object with all pager properties (preserving original format)\n return {\n totalItems: totalItems,\n currentPage: currentPage,\n pageSize: pageSize,\n totalPages: totalPages,\n startPage: startPage,\n endPage: endPage,\n startIndex: startIndex,\n endIndex: endIndex,\n pages: pages,\n };\n}\n","import { Localizer } from '../utils/localize.js';\nimport { default as WJElement, event } from '../wje-element/element.js';\nimport { paginate } from './service/service.js';\nimport Icon from '../wje-icon/icon.js';\nimport Button from '../wje-button/button.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents the Pagination component for navigating through paginated content and dynamically updating navigation elements based on attributes like the number of items, page size, etc. Extends the WJElement class.\n * @documentation https://elements.webjet.sk/components/pagination\n * @status stable\n * @augments WJElement\n * @dependency wje-icon, wje-button\n * @csspart native - The wrapper element for the pagination component.\n */\nexport default class Pagination extends WJElement {\n /**\n * Creates an instance of Pagination.\n */\n constructor() {\n super();\n this.localizer = new Localizer(this);\n\n this._paginateObj = null;\n }\n\n /**\n * Sets the value of the 'page' attribute for the object.\n * @param {string} value The value to set for the 'page' attribute.\n */\n set page(value) {\n this.setAttribute('page', value);\n }\n\n /**\n * Retrieves the current page number as a numeric value.\n * @returns {number} The current page number. Returns 0 if the attribute 'page' is not set or is not a numeric value.\n */\n get page() {\n return +this.getAttribute('page') || 0;\n }\n\n /**\n * Sets the maximum number of pages.\n * Updates the 'max-pages' attribute with the provided value.\n * @param {number|string} value The maximum number of pages to set. Can be a number or a parsable string representing a number.\n */\n set maxPages(value) {\n this.setAttribute('max-pages', value);\n }\n\n /**\n * Gets the maximum number of pages.\n * This getter retrieves the value of the \"max-pages\" attribute from the element.\n * If the attribute is not set or is invalid, it defaults to 3.\n * @returns {number} The maximum number of pages as a numeric value.\n */\n get maxPages() {\n return +this.getAttribute('max-pages') || 3;\n }\n\n /**\n * Sets the `pageSize` attribute to the specified value.\n * @param {number|string} value The desired page size value. This can be a number or a string representation of the size.\n */\n set pageSize(value) {\n this.setAttribute('page-size', value);\n }\n\n /**\n * Retrieves the value of the 'page-size' attribute and converts it to a number.\n * If the attribute is not set or is invalid, returns the default value of 3.\n * @returns {number} The numeric value of the 'page-size' attribute or the default value of 3.\n */\n get pageSize() {\n return +this.getAttribute('page-size') || 3;\n }\n\n /**\n * Sets the total number of items.\n * @param {number} value The new total number of items to set.\n */\n set totalItems(value) {\n // console.log('totalItems nastavené na:', value);\n this.setAttribute('total-items', value);\n }\n\n /**\n * Retrieves the total number of items represented by the 'total-items' attribute.\n * @returns {number} The total number of items. Defaults to 0 if the attribute is not set or is invalid.\n */\n get totalItems() {\n // console.log(\"SOM V TOTAL ITEMS:\", this, this.getAttribute('total-items'));\n return +this.getAttribute('total-items') || 0;\n }\n\n /**\n * Sets the visibility of the first button based on the provided value.\n * Adds the 'show-first-button' attribute when the value is truthy, and removes it otherwise.\n * @param {boolean} value Determines whether to show the first button. If true, the 'show-first-button' attribute is added; if false, it is removed.\n */\n set showFirstButton(value) {\n this.removeAttribute('show-first-button');\n\n if (value) {\n this.setAttribute('show-first-button', '');\n }\n }\n\n /**\n * Determines whether the 'show-first-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-first-button' attribute is set; otherwise, false.\n */\n get showFirstButton() {\n return this.hasAttribute('show-first-button');\n }\n\n /**\n * Sets the visibility of the \"last\" button. This method controls the presence\n * or absence of the \"show-last-button\" attribute based on the provided value.\n * @param {boolean} value A boolean value indicating whether to show the \"last\" button.\n * If true, the \"show-last-button\" attribute is added;\n * if false, the attribute is removed.\n */\n set showLastButton(value) {\n this.removeAttribute('show-last-button');\n\n if (value) {\n this.setAttribute('show-last-button', '');\n }\n }\n\n /**\n * Determines if the 'show-last-button' attribute is present on the element.\n * @returns {boolean} True if the 'show-last-button' attribute is present, otherwise false.\n */\n get showLastButton() {\n return this.hasAttribute('show-last-button');\n }\n\n /**\n * Sets the pagination object by calculating the pagination details\n * based on the total items, current page, page size, and maximum pages.\n * @param {object} value The value to set the pagination object. The pagination details are computed internally.\n */\n set paginateObj(value) {\n // console.log('paginateObj nastavené na:', value);\n this._paginateObj = value;\n }\n\n /**\n * Retrieves the pagination object used for managing paginated data.\n * @returns {object} The pagination object containing details and functionality for paginating data.\n */\n get paginateObj() {\n return this._paginateObj;\n }\n\n /**\n * Sets the 'round' attribute on the element. If the provided value is truthy,\n * the 'round' attribute is added. If the value is falsy, the attribute is removed.\n * @param {boolean} value A boolean value determining whether to add or remove the 'round' attribute.\n */\n set round(value) {\n this.removeAttribute('round');\n\n if (value) {\n this.setAttribute('round', '');\n }\n }\n\n /**\n * Retrieves the value of the 'round' attribute for the current element.\n * @returns {boolean} A boolean indicating whether the 'round' attribute is present on the element.\n */\n get round() {\n return this.hasAttribute('round');\n }\n\n /**\n * Sets the `show-info` attribute on the element based on the provided value.\n * @param {boolean} value A boolean indicating whether to add or remove the `show-info` attribute.\n */\n set showInfo(value) {\n this.removeAttribute('show-info');\n\n if (value) {\n this.setAttribute('show-info', '');\n }\n }\n\n /**\n * Retrieves the value of the 'show-info' attribute.\n * Checks if the 'show-info' attribute is present on the element.\n * @returns {boolean} True if the 'show-info' attribute is present, otherwise false.\n */\n get showInfo() {\n return this.hasAttribute('show-info');\n }\n\n /**\n * Dependencies of the Button element.\n * @type {object}\n */\n dependencies = {\n 'wje-icon': Icon,\n 'wje-button': Button,\n };\n\n className = 'Pagination';\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 * Getter for the observedAttributes attribute of the input element.\n * @returns {Array} The attributes to observe for changes.\n */\n static get observedAttributes() {\n return ['page', 'totalItems'];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n async beforeDraw() {\n this.paginateObj = await paginate(this.totalItems, this.page + 1, this.pageSize, this.maxPages)\n }\n\n /**\n * Creates a document fragment, appends a new slot element to it, and returns the fragment.\n * @returns {DocumentFragment} A document fragment containing a slot element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.setAttribute('part', 'native');\n native.classList.add('native-pagination');\n\n native.append(this.htmlPagination());\n\n fragment.append(native);\n\n return fragment;\n }\n\n /**\n * Creates a pagination control for navigating between pages of content.\n * This method generates and returns a document fragment containing pagination controls, including buttons for navigating to the first, previous, next, and last pages, as well as optional informational text about the current set of displayed items and total number of items.\n * @returns {DocumentFragment} A document fragment containing the pagination controls.\n */\n htmlPagination() {\n // console.log(\"SOM PAGINATE OBJ:\",this.paginateObj);\n let fragment = document.createDocumentFragment();\n\n let info = document.createElement('div');\n info.classList.add('info');\n info.innerHTML = `${this.paginateObj.startIndex + 1} - ${this.paginateObj.endIndex + 1} ${this.localizer.translate('wj.pagination.of')} ${this.totalItems}`;\n\n let pagination = document.createElement('div');\n pagination.classList.add('pages');\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n // First button\n let firstButton = button.cloneNode(true);\n firstButton.title = this.localizer.translate('wj.pagination.first');\n firstButton.innerHTML = `<wje-icon name=\"chevron-left-pipe\" slot=\"icon-only\"></wje-icon>`;\n firstButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n // Previous button\n const prevButton = button.cloneNode(true);\n prevButton.title = this.localizer.translate('wj.pagination.prev');\n prevButton.innerHTML = `<wje-icon name=\"chevron-left\" slot=\"icon-only\"></wje-icon>`;\n if(this.page === 0)\n prevButton.disabled = true;\n prevButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page - 1));\n\n // Next button\n const nextButton = button.cloneNode(true);\n nextButton.title = this.localizer.translate('wj.pagination.next');\n nextButton.innerHTML = `<wje-icon name=\"chevron-right\" slot=\"icon-only\"></wje-icon>`;\n if(this.paginateObj.endIndex + 1 >= this.totalItems)\n nextButton.disabled = true;\n nextButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, this.page + 1));\n\n // Last button\n let lastButton = button.cloneNode(true);\n lastButton.title = this.localizer.translate('wj.pagination.last');\n lastButton.innerHTML = `<wje-icon name=\"chevron-right-pipe\" slot=\"icon-only\"></wje-icon>`;\n lastButton.disabled = this.paginateObj.endIndex + 1 >= this.totalItems;\n lastButton.addEventListener('wje-button:click', (e) =>\n this.pageClickAction(e, this.paginateObj.totalPages - 1)\n );\n\n if (this.showFirstButton) pagination.appendChild(firstButton);\n pagination.appendChild(prevButton);\n pagination.appendChild(this.htmlStackButtons(this.paginateObj));\n pagination.appendChild(nextButton);\n if (this.showLastButton) pagination.appendChild(lastButton);\n\n if (this.showInfo) fragment.appendChild(info);\n fragment.appendChild(pagination);\n\n return fragment;\n }\n\n /**\n * Creates and returns a DocumentFragment containing a series of buttons for pagination purposes,\n * based on the provided pagination object.\n * @param {object} paginateObj An object containing pagination details.\n * @param {number} paginateObj.currentPage The current active page index (1-based).\n * @param {Array<number>} paginateObj.pages An array of page numbers to display in the pagination.\n * @param {number} paginateObj.totalPages Total number of pages available for pagination.\n * @returns {DocumentFragment} A DocumentFragment containing the buttons and additional pagination elements.\n */\n htmlStackButtons(paginateObj) {\n let fragment = document.createDocumentFragment();\n\n const button = document.createElement('wje-button');\n button.setAttribute('fill', 'link');\n if (this.round) button.setAttribute('round', '');\n\n let dots = document.createElement('span');\n dots.classList.add('dots');\n\n const first = button.cloneNode(true);\n first.textContent = '1';\n first.addEventListener('wje-button:click', (e) => this.pageClickAction(e, 0));\n\n const last = button.cloneNode(true);\n last.textContent = paginateObj.totalPages;\n last.addEventListener('wje-button:click', (e) => this.pageClickAction(e, paginateObj.totalPages - 1));\n\n if (paginateObj.currentPage > this.maxPages + 1) {\n fragment.appendChild(first);\n fragment.appendChild(dots);\n }\n\n paginateObj.pages.forEach((page) => {\n let newButton = button.cloneNode(true);\n newButton.textContent = page;\n\n newButton.addEventListener('wje-button:click', (e) => this.pageClickAction(e, page - 1));\n\n if (page - 1 === this.page) newButton.removeAttribute('fill');\n\n fragment.appendChild(newButton);\n });\n\n if (paginateObj.pages.length === this.maxPages || paginateObj.currentPage <= this.maxPages + 1) {\n fragment.appendChild(dots.cloneNode(true));\n fragment.appendChild(last);\n }\n\n return fragment;\n }\n\n /**\n * Handles the click action for pagination and updates the current page.\n * If the clicked page number is the same as the current page, no action is performed.\n * Otherwise, the current page is updated to the new page number, and a custom event\n * 'wje-pagination:page-change' is dispatched with the pagination object.\n * @param {Event} e The event triggered by the page click.\n * @param {number} page The page number that was clicked.\n */\n pageClickAction = (e, page) => {\n if (+page === this.page) return;\n\n this.page = page;\n event.dispatchCustomEvent(this, 'wje-pagination:page-change', this.paginateObj);\n };\n}\n\nPagination.define('wje-pagination', Pagination);\n","import Pagination from './pagination.element.js';\n\nexport default Pagination;\n\nPagination.define('wje-pagination', Pagination);\n"],"names":[],"mappings":";;;;;;;AAQO,SAAS,SAAS,YAAY,cAAc,GAAG,WAAW,IAAI,WAAW,GAAG;AAE/E,QAAM,aAAa,KAAK,KAAK,aAAa,QAAQ;AAGlD,MAAI,cAAc,GAAG;AACjB,kBAAc;AAAA,EACtB,WAAe,cAAc,YAAY;AACjC,kBAAc;AAAA,EACtB;AAEI,MAAI;AACJ,MAAI;AAEJ,QAAM,eAAe,WAAW;AAEhC,MAAI,eAAe,cAAc;AAE7B,gBAAY;AACZ,cAAU,KAAK,IAAI,eAAe,GAAG,UAAU;AAAA,EAClD,WAAU,cAAc,aAAa,eAAe,GAAG;AAEpD,gBAAY,KAAK,IAAI,aAAa,cAAc,CAAC;AACjD,cAAU;AAAA,EAClB,OAAW;AACH,UAAM,YAAY,KAAK,MAAM,WAAW,CAAC;AAGzC,gBAA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WAAW,GAAG;AAC5F,eAAS,YAAY,KAAK,UAAU,IAAI,CAAC;AACzC,eAAS,YAAY,IAAI;AAAA,IACrC;AAEQ,WAAO;AAAA,EACf;AAgBA;AAEA,WAAW,OAAO,kBAAkB,UAAU;AC/X9C,WAAW,OAAO,kBAAkB,UAAU;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.1.147",
4
+ "version": "0.1.149",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"file":"infinite-scroll.element-XVJukzjy.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 }\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 before drawing.\n */\n beforeDraw() {\n this.iterate = this.querySelector('[iterate]');\n this.infiniteScrollTemplate = this.iterate?.outerHTML;\n this.iterate?.remove(); // remove template\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 * Draws the component and returns a document fragment.\n * @returns {DocumentFragment}\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 * Adds the scroll event listener.\n */\n scrollEvent = () => {\n this.addEventListener('scroll', this.onScroll);\n };\n\n /**\n * Removes the scroll event listener.\n */\n unScrollEvent = () => {\n this.removeEventListener('scroll', this.onScroll);\n };\n\n /**\n * Handles the scroll event.\n * @param {Event} e The event.\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 * Shows the loader.\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\n this.customForeach(this.objectName ? response[this.objectName] : response);\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 /**\n * Sets the custom data.\n *\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 console.log('IS Element:', element);\n return element;\n };\n\n customForeach = (data) => {\n data.forEach((item) => {\n let element = this.dataToHtml(item);\n event.addListener(element, 'click', 'wje-infinite-scroll:click-item', null);\n\n this.placementObj.insertAdjacentElement('beforeend', element);\n });\n };\n\n /**\n * Interpolates the string.\n * @param template\n * @param {object} params The parameters for interpolation.\n * @returns {string} The interpolated string.\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"],"names":[],"mappings":";;;;;AAkBe,MAAM,uBAAuB,UAAU;AAAA;AAAA;AAAA;AAAA,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