wj-elements 0.7.7 → 0.8.0

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.
Files changed (233) hide show
  1. package/dist/animations.js +28 -51
  2. package/dist/animations.js.map +1 -1
  3. package/dist/base-path.js +19 -31
  4. package/dist/base-path.js.map +1 -1
  5. package/dist/custom-elements.json +11504 -11499
  6. package/dist/dark.css +1 -302
  7. package/dist/date.js +16 -36
  8. package/dist/date.js.map +1 -1
  9. package/dist/element-utils.js +20 -81
  10. package/dist/element-utils.js.map +1 -1
  11. package/dist/event.js +49 -165
  12. package/dist/event.js.map +1 -1
  13. package/dist/form-associated-element-BjeJn7j8.js +101 -0
  14. package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
  15. package/dist/icon-DmsqtDpL.js +102 -0
  16. package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
  17. package/dist/light.css +1 -731
  18. package/dist/localize.js +36 -111
  19. package/dist/localize.js.map +1 -1
  20. package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
  21. package/dist/permissions.js +14 -41
  22. package/dist/permissions.js.map +1 -1
  23. package/dist/popup.element-CbkhthPP.js +806 -0
  24. package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
  25. package/dist/router-links-CNsJ-elb.js +105 -0
  26. package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
  27. package/dist/skeleton.css +1 -197
  28. package/dist/styles.css +1 -866
  29. package/dist/universal-service.js +48 -109
  30. package/dist/universal-service.js.map +1 -1
  31. package/dist/utils.js +11 -18
  32. package/dist/utils.js.map +1 -1
  33. package/dist/web-types.json +760 -760
  34. package/dist/wje-accordion-item.js +33 -106
  35. package/dist/wje-accordion-item.js.map +1 -1
  36. package/dist/wje-accordion.js +19 -84
  37. package/dist/wje-accordion.js.map +1 -1
  38. package/dist/wje-animation.js +37 -4258
  39. package/dist/wje-animation.js.map +1 -1
  40. package/dist/wje-aside.js +9 -34
  41. package/dist/wje-aside.js.map +1 -1
  42. package/dist/wje-avatar.js +36 -126
  43. package/dist/wje-avatar.js.map +1 -1
  44. package/dist/wje-badge.js +10 -52
  45. package/dist/wje-badge.js.map +1 -1
  46. package/dist/wje-breadcrumb.js +205 -672
  47. package/dist/wje-breadcrumb.js.map +1 -1
  48. package/dist/wje-breadcrumbs.js +177 -633
  49. package/dist/wje-breadcrumbs.js.map +1 -1
  50. package/dist/wje-button-group.js +48 -153
  51. package/dist/wje-button-group.js.map +1 -1
  52. package/dist/wje-button.js +92 -413
  53. package/dist/wje-button.js.map +1 -1
  54. package/dist/wje-card-content.js +7 -30
  55. package/dist/wje-card-content.js.map +1 -1
  56. package/dist/wje-card-controls.js +7 -30
  57. package/dist/wje-card-controls.js.map +1 -1
  58. package/dist/wje-card-header.js +7 -30
  59. package/dist/wje-card-header.js.map +1 -1
  60. package/dist/wje-card-subtitle.js +7 -34
  61. package/dist/wje-card-subtitle.js.map +1 -1
  62. package/dist/wje-card-title.js +7 -34
  63. package/dist/wje-card-title.js.map +1 -1
  64. package/dist/wje-card.js +15 -71
  65. package/dist/wje-card.js.map +1 -1
  66. package/dist/wje-carousel-item.js +12 -56
  67. package/dist/wje-carousel-item.js.map +1 -1
  68. package/dist/wje-carousel.js +154 -509
  69. package/dist/wje-carousel.js.map +1 -1
  70. package/dist/wje-checkbox.js +50 -227
  71. package/dist/wje-checkbox.js.map +1 -1
  72. package/dist/wje-chip.js +43 -160
  73. package/dist/wje-chip.js.map +1 -1
  74. package/dist/wje-col.js +7 -20
  75. package/dist/wje-col.js.map +1 -1
  76. package/dist/wje-color-picker.js +445 -1464
  77. package/dist/wje-color-picker.js.map +1 -1
  78. package/dist/wje-container.js +9 -35
  79. package/dist/wje-container.js.map +1 -1
  80. package/dist/wje-copy-button.js +64 -204
  81. package/dist/wje-copy-button.js.map +1 -1
  82. package/dist/wje-dialog.js +85 -553
  83. package/dist/wje-dialog.js.map +1 -1
  84. package/dist/wje-divider.js +7 -34
  85. package/dist/wje-divider.js.map +1 -1
  86. package/dist/wje-dropdown.js +78 -305
  87. package/dist/wje-dropdown.js.map +1 -1
  88. package/dist/wje-element.js +191 -700
  89. package/dist/wje-element.js.map +1 -1
  90. package/dist/wje-file-upload-item.js +51 -156
  91. package/dist/wje-file-upload-item.js.map +1 -1
  92. package/dist/wje-file-upload.js +181 -619
  93. package/dist/wje-file-upload.js.map +1 -1
  94. package/dist/wje-footer.js +7 -31
  95. package/dist/wje-footer.js.map +1 -1
  96. package/dist/wje-form.js +7 -32
  97. package/dist/wje-form.js.map +1 -1
  98. package/dist/wje-format-digital.js +26 -118
  99. package/dist/wje-format-digital.js.map +1 -1
  100. package/dist/wje-grid.js +7 -33
  101. package/dist/wje-grid.js.map +1 -1
  102. package/dist/wje-header.js +9 -35
  103. package/dist/wje-header.js.map +1 -1
  104. package/dist/wje-icon-library.js +12 -18
  105. package/dist/wje-icon-library.js.map +1 -1
  106. package/dist/wje-icon-picker.js +65 -320
  107. package/dist/wje-icon-picker.js.map +1 -1
  108. package/dist/wje-icon.js +1 -1
  109. package/dist/wje-img-comparer.js +37 -114
  110. package/dist/wje-img-comparer.js.map +1 -1
  111. package/dist/wje-img.js +50 -198
  112. package/dist/wje-img.js.map +1 -1
  113. package/dist/wje-infinite-scroll.js +94 -346
  114. package/dist/wje-infinite-scroll.js.map +1 -1
  115. package/dist/wje-input-file.js +23 -84
  116. package/dist/wje-input-file.js.map +1 -1
  117. package/dist/wje-input.js +78 -392
  118. package/dist/wje-input.js.map +1 -1
  119. package/dist/wje-item.js +11 -64
  120. package/dist/wje-item.js.map +1 -1
  121. package/dist/wje-kanban.js +124 -401
  122. package/dist/wje-kanban.js.map +1 -1
  123. package/dist/wje-label.js +9 -32
  124. package/dist/wje-label.js.map +1 -1
  125. package/dist/wje-level-indicator.js +38 -157
  126. package/dist/wje-level-indicator.js.map +1 -1
  127. package/dist/wje-list.js +10 -40
  128. package/dist/wje-list.js.map +1 -1
  129. package/dist/wje-main.js +7 -31
  130. package/dist/wje-main.js.map +1 -1
  131. package/dist/wje-masonry.js +66 -211
  132. package/dist/wje-masonry.js.map +1 -1
  133. package/dist/wje-master.js +45 -161
  134. package/dist/wje-master.js.map +1 -1
  135. package/dist/wje-menu-button.js +10 -38
  136. package/dist/wje-menu-button.js.map +1 -1
  137. package/dist/wje-menu-item.js +127 -577
  138. package/dist/wje-menu-item.js.map +1 -1
  139. package/dist/wje-menu-label.js +9 -35
  140. package/dist/wje-menu-label.js.map +1 -1
  141. package/dist/wje-menu.js +14 -49
  142. package/dist/wje-menu.js.map +1 -1
  143. package/dist/wje-option.js +48 -279
  144. package/dist/wje-option.js.map +1 -1
  145. package/dist/wje-options.js +130 -384
  146. package/dist/wje-options.js.map +1 -1
  147. package/dist/wje-orgchart-group.js +16 -52
  148. package/dist/wje-orgchart-group.js.map +1 -1
  149. package/dist/wje-orgchart-item.js +24 -93
  150. package/dist/wje-orgchart-item.js.map +1 -1
  151. package/dist/wje-orgchart.js +18 -68
  152. package/dist/wje-orgchart.js.map +1 -1
  153. package/dist/wje-pagination.js +113 -397
  154. package/dist/wje-pagination.js.map +1 -1
  155. package/dist/wje-popup.js +3 -3
  156. package/dist/wje-popup.js.map +1 -1
  157. package/dist/wje-progress-bar.js +53 -205
  158. package/dist/wje-progress-bar.js.map +1 -1
  159. package/dist/wje-qr-code.js +398 -2980
  160. package/dist/wje-qr-code.js.map +1 -1
  161. package/dist/wje-radio-group.js +52 -190
  162. package/dist/wje-radio-group.js.map +1 -1
  163. package/dist/wje-radio.js +24 -118
  164. package/dist/wje-radio.js.map +1 -1
  165. package/dist/wje-rate.js +62 -266
  166. package/dist/wje-rate.js.map +1 -1
  167. package/dist/wje-relative-time.js +24 -99
  168. package/dist/wje-relative-time.js.map +1 -1
  169. package/dist/wje-reorder-dropzone.js +9 -31
  170. package/dist/wje-reorder-dropzone.js.map +1 -1
  171. package/dist/wje-reorder-handle.js +67 -204
  172. package/dist/wje-reorder-handle.js.map +1 -1
  173. package/dist/wje-reorder-item.js +14 -44
  174. package/dist/wje-reorder-item.js.map +1 -1
  175. package/dist/wje-reorder.js +61 -246
  176. package/dist/wje-reorder.js.map +1 -1
  177. package/dist/wje-route.js +6 -24
  178. package/dist/wje-route.js.map +1 -1
  179. package/dist/wje-router-link.js +11 -39
  180. package/dist/wje-router-link.js.map +1 -1
  181. package/dist/wje-router-outlet.js +76 -172
  182. package/dist/wje-router-outlet.js.map +1 -1
  183. package/dist/wje-routerx.js +537 -1331
  184. package/dist/wje-routerx.js.map +1 -1
  185. package/dist/wje-row.js +9 -31
  186. package/dist/wje-row.js.map +1 -1
  187. package/dist/wje-select.js +326 -1152
  188. package/dist/wje-select.js.map +1 -1
  189. package/dist/wje-slider.js +44 -225
  190. package/dist/wje-slider.js.map +1 -1
  191. package/dist/wje-sliding-container.js +295 -1319
  192. package/dist/wje-sliding-container.js.map +1 -1
  193. package/dist/wje-split-view.js +35 -121
  194. package/dist/wje-split-view.js.map +1 -1
  195. package/dist/wje-status.js +14 -45
  196. package/dist/wje-status.js.map +1 -1
  197. package/dist/wje-step.js +9 -32
  198. package/dist/wje-step.js.map +1 -1
  199. package/dist/wje-stepper.js +109 -357
  200. package/dist/wje-stepper.js.map +1 -1
  201. package/dist/wje-store.js +67 -360
  202. package/dist/wje-store.js.map +1 -1
  203. package/dist/wje-tab-group.js +85 -314
  204. package/dist/wje-tab-group.js.map +1 -1
  205. package/dist/wje-tab-panel.js +7 -28
  206. package/dist/wje-tab-panel.js.map +1 -1
  207. package/dist/wje-tab.js +21 -198
  208. package/dist/wje-tab.js.map +1 -1
  209. package/dist/wje-textarea.js +64 -264
  210. package/dist/wje-textarea.js.map +1 -1
  211. package/dist/wje-thumbnail.js +10 -51
  212. package/dist/wje-thumbnail.js.map +1 -1
  213. package/dist/wje-toast.js +127 -632
  214. package/dist/wje-toast.js.map +1 -1
  215. package/dist/wje-toggle.js +52 -177
  216. package/dist/wje-toggle.js.map +1 -1
  217. package/dist/wje-toolbar-action.js +128 -456
  218. package/dist/wje-toolbar-action.js.map +1 -1
  219. package/dist/wje-toolbar.js +75 -270
  220. package/dist/wje-toolbar.js.map +1 -1
  221. package/dist/wje-tooltip.js +50 -161
  222. package/dist/wje-tooltip.js.map +1 -1
  223. package/dist/wje-tree-item.js +70 -301
  224. package/dist/wje-tree-item.js.map +1 -1
  225. package/dist/wje-tree.js +145 -489
  226. package/dist/wje-tree.js.map +1 -1
  227. package/dist/wje-visually-hidden.js +7 -34
  228. package/dist/wje-visually-hidden.js.map +1 -1
  229. package/package.json +3 -2
  230. package/dist/form-associated-element-DEQ4y-jn.js +0 -245
  231. package/dist/icon-CReYMzAK.js +0 -245
  232. package/dist/popup.element-CwXvVFK7.js +0 -2133
  233. package/dist/router-links-wjqCnncc.js +0 -156
@@ -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 * @attribute {string} name - The Animate.css animation name played on the slotted element.\n * @attribute {number} duration - The animation playback duration in milliseconds.\n * @attribute {number} delay - The delay before the animation starts.\n * @attribute {number} endDelay - The delay applied after the animation completes.\n * @attribute {string} fill - The fill mode used by the animation playback.\n * @attribute {string|number} iterations - The number of animation repetitions.\n * @attribute {number} iterationStart - The starting offset for the first animation iteration.\n * @attribute {string} direction - The playback direction of the animation.\n * @attribute {string} easing - The easing function used by the animation playback.\n * @slot - The animation main content.\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 names of the observed attributes.\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 this.setAriaState({ role: 'presentation' });\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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,KAAK,WAAW;AAChB,WAAK,UAAU,KAAI;AAAA,IACvB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,SAAS;AACL,QAAI,KAAK,aAAa,OAAO,KAAK,UAAU,WAAW,YAAY;AAC/D,WAAK,UAAU,OAAM;AAAA,IACzB,OAAO;AACH,cAAQ,KAAK,yDAAyD;AAAA,IAC1E;AAAA,EACJ;AACJ;AC5SA,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 * @attribute {string} name - The Animate.css animation name played on the slotted element.\n * @attribute {number} duration - The animation playback duration in milliseconds.\n * @attribute {number} delay - The delay before the animation starts.\n * @attribute {number} endDelay - The delay applied after the animation completes.\n * @attribute {string} fill - The fill mode used by the animation playback.\n * @attribute {string|number} iterations - The number of animation repetitions.\n * @attribute {number} iterationStart - The starting offset for the first animation iteration.\n * @attribute {string} direction - The playback direction of the animation.\n * @attribute {string} easing - The easing function used by the animation playback.\n * @slot - The animation main content.\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 names of the observed attributes.\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 this.setAriaState({ role: 'presentation' });\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":["Animation","WJElement","constructor","super","className","this","_animations","value","setAttribute","name","getAttribute","duration","delay","fill","iterations","Infinity","iterationStart","direction","cssStyleSheet","observedAttributes","setupAttributes","isShadowRoot","setAriaState","role","draw","fragment","document","createDocumentFragment","slot","createElement","appendChild","slotEl","afterDraw","destroyAnimation","element","assignedElements","animations","getAnimationsArray","selected","find","k","animation","animate","keyframes","endDelay","easing","playState","play","fetchAndParseCSS","cancel","console","warn","define"],"mappings":";;;;;AAsBe,MAAMA,UAAkBC;EAInC,cAAAC;AACIC,UAAAA;AAwKJC,qCAAY;AAvKRC,SAAKC,cAAc,CAAA;AAAA,EACvB;AAAA,EAMA,IAAA,KAASC;AACLF,SAAKG,aAAa,QAAQD,EAAAA;AAAAA,EAC9B;AAAA,EAMA,IAAA,OAAIE;AACA,WAAOJ,KAAKK,aAAa,MAAA,KAAW;AAAA,EACxC;AAAA,EAMA,IAAA,SAAaH,IAAAA;AACTF,SAAKG,aAAa,YAAYD;EAClC;AAAA,EAMA,IAAA,WAAII;AACA,WAAA,CAAQN,KAAKK,aAAa,UAAA,KAAe;AAAA,EAC7C;AAAA,EAMA,UAAUH,IAAAA;AACNF,SAAKG,aAAa,SAASD,EAAAA;AAAAA,EAC/B;AAAA,EAMA,IAAA,QAAIK;AACA,YAAQP,KAAKK,aAAa,OAAA,KAAY;AAAA,EAC1C;AAAA,EAMA,IAAA,SAAaH,IAAAA;AACTF,SAAKG,aAAa,YAAYD,EAAAA;AAAAA,EAClC;AAAA,EAMA,IAAA;AACI,WAAA,CAAQF,KAAKK,aAAa,UAAA,KAAe;AAAA,EAC7C;AAAA,EAMA,IAAA,KAASH,IAAAA;AACLF,SAAKG,aAAa,QAAQD,EAAAA;AAAAA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CAAA;AAC/C9B,SAAK+B,aAAAA,MAAmB/B,KAAKgC;AAC7B,UAAMC,KAAAA,MAAiBjC,KAAK+B,WAAWG,KAAMC,CAAAA,OAAMA,GAAE/B,SAASJ,KAAKI;AAEnEJ,SAAKoC,YAAYP,MAAAA,gBAAAA,GAASQ,QAAQJ,MAAAA,gBAAAA,GAAUK,WAAW,EACnD/B,OAAAA,CAAQP,KAAKO,OACbgC,UAAAA,CAAWvC,KAAKuC,UAChB/B,MAAMR,KAAKQ,MACXF,UAAAA,CAAWN,KAAKM,UAChBK,iBAAiBX,KAAKW,gBACtBF,YAAYT,KAAKS,YACjBG,WAAWZ,KAAKY,WAChB4B,QAAQxC,KAAKwC,OAAAA,IAGbxC,KAAKoC,aAA0C,WAA7BpC,KAAKoC,UAAUK,aAAsBzC,KAAKoC,UAAUM;EAC9E;AAAA,EAMA,MAAA,qBAAMV;AACF,WAAA,MAAaW;EACjB;AAAA,EAOA,mBAAAf;AACQ5B,SAAKoC,aACLpC,KAAK4C,OAAAA;AAAAA,EAEb;AAAA,EAMA,OAAAF;AACQ1C,SAAKoC,aACLpC,KAAKoC,UAAUM,KAAAA;AAAAA,EAEvB;AAAA,EAOA,SAAAE;AACQ5C,SAAKoC,aAA8C,cAAA,OAA1BpC,KAAKoC,UAAUQ,SACxC5C,KAAKoC,UAAUQ,OAAAA,IAEfC,QAAQC,KAAK,yDAAA;AAAA,EAErB;AAAA;AC3SJnD,EAAUoD,OAAO,iBAAiBpD,CAAAA;"}
package/dist/wje-aside.js CHANGED
@@ -1,55 +1,30 @@
1
1
  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
- import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ WJ Aside ]\n*/\n\n:host {\n box-sizing: border-box;\n flex-shrink: 0;\n overflow: auto;\n border-color: var(--wje-aside-border-color);\n border-width: var(--wje-aside-border-width);\n border-style: var(--wje-aside-border-style);\n}\n\n:host(.open) {\n display: block !important;\n}\n\n@media (min-width: 768px) {\n :host([fixed]) {\n position: fixed;\n width: var(--wje-aside-width);\n top: var(--wje-aside-top);\n height: calc(100% - var(--wje-aside-top));\n }\n}\n\n@media (max-width: 768px) {\n :host {\n display: none;\n }\n\n :host([variant='top-start']) {\n position: fixed;\n top: 0;\n left: 0;\n width: 80%;\n height: 100%;\n z-index: 9999;\n background-color: #fff;\n }\n}\n";
6
- class Aside extends WJElement {
7
- /**
8
- * Constructor for the Aside class.
9
- */
4
+ import t from "./wje-element.js";
5
+ class e extends t {
10
6
  constructor() {
11
7
  super();
12
- /**
13
- * The class name for the Aside element.
14
- * @type {string}
15
- */
16
8
  __publicField(this, "className", "Aside");
17
9
  }
18
- /**
19
- * Getter for the CSS stylesheet.
20
- * @returns {object} The styles for the Aside element.
21
- */
22
10
  static get cssStyleSheet() {
23
- return styles;
11
+ return ':host{box-sizing:border-box;flex-shrink:0;overflow:auto;border-color:var(--wje-aside-border-color);border-width:var(--wje-aside-border-width);border-style:var(--wje-aside-border-style)}:host(.open){display:block!important}@media(min-width:768px){:host([fixed]){position:fixed;width:var(--wje-aside-width);top:var(--wje-aside-top);height:calc(100% - var(--wje-aside-top))}}@media(max-width:768px){:host{display:none}:host([variant="top-start"]){position:fixed;top:0;left:0;width:80%;height:100%;z-index:9999;background-color:#fff}}';
24
12
  }
25
- /**
26
- * Getter for the observed attributes.
27
- * @returns {Array} An empty array as there are no observed attributes.
28
- */
29
13
  static get observedAttributes() {
30
14
  return [];
31
15
  }
32
- /**
33
- * Method to setup attributes for the Aside element.
34
- */
35
16
  setupAttributes() {
36
17
  this.isShadowRoot = "open";
37
18
  }
38
- /**
39
- * Method to draw the Aside element.
40
- * @returns {object} The document fragment containing the drawn element.
41
- */
42
19
  draw() {
43
- let fragment = document.createDocumentFragment();
44
- if (this.width) this.style.setProperty("--wje-aside-width", this.width);
45
- if (this.top && this.hasAttribute("fixed")) this.style.setProperty("--wje-aside-top", this.top);
46
- let element = document.createElement("slot");
47
- fragment.appendChild(element);
48
- return fragment;
20
+ let t2 = document.createDocumentFragment();
21
+ this.width && this.style.setProperty("--wje-aside-width", this.width), this.top && this.hasAttribute("fixed") && this.style.setProperty("--wje-aside-top", this.top);
22
+ let e2 = document.createElement("slot");
23
+ return t2.appendChild(e2), t2;
49
24
  }
50
25
  }
51
- Aside.define("wje-aside", Aside);
26
+ e.define("wje-aside", e);
52
27
  export {
53
- Aside as default
28
+ e as default
54
29
  };
55
30
  //# sourceMappingURL=wje-aside.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-aside.js","sources":["../packages/wje-aside/aside.element.js","../packages/wje-aside/aside.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Aside element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/aside\n * @status stable\n * @augments WJElement\n * @attribute {string} width - Sets the width of the aside column, typically through a CSS length or design token.\n * @attribute {string} top - Sets the top offset used together with the `fixed` layout mode.\n * @attribute {boolean} fixed - Pins the aside in a fixed desktop position instead of keeping it in normal flow.\n * @attribute {string} variant - Selects an alternate layout variant such as the mobile `top-start` drawer style.\n * @slot default - Slot for the aside content.\n * @cssproperty [--wje-aside-width] - Controls the width of the aside column.\n * @cssproperty [--wje-aside-top] - Controls the top offset of a fixed aside.\n * @cssproperty [--wje-aside-border-color=var(--wje-border-color)] - Controls the border color of the aside.\n * @cssproperty [--wje-aside-border-width] - Controls the border width of the aside.\n * @cssproperty [--wje-aside-border-style] - Controls the border style of the aside.\n * @tag wje-aside\n */\nexport default class Aside extends WJElement {\n /**\n * Constructor for the Aside class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Aside element.\n * @type {string}\n */\n className = 'Aside';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {object} The styles for the Aside element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An empty array as there are no observed attributes.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Method to setup attributes for the Aside element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the Aside element.\n * @returns {object} The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n if (this.width) this.style.setProperty('--wje-aside-width', this.width);\n\n if (this.top && this.hasAttribute('fixed')) this.style.setProperty('--wje-aside-top', this.top);\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Aside from './aside.element.js';\n\n// export * from \"./aside.element.js\";\nexport default Aside;\n\nAside.define('wje-aside', Aside);\n"],"names":[],"mappings":";;;;;AAoBe,MAAM,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA,EAIzC,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,qBAAqB;AAC5B,WAAO,CAAA;AAAA,EACX;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAkB;AACd,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,KAAK,MAAO,MAAK,MAAM,YAAY,qBAAqB,KAAK,KAAK;AAEtE,QAAI,KAAK,OAAO,KAAK,aAAa,OAAO,EAAG,MAAK,MAAM,YAAY,mBAAmB,KAAK,GAAG;AAE9F,QAAI,UAAU,SAAS,cAAc,MAAM;AAE3C,aAAS,YAAY,OAAO;AAE5B,WAAO;AAAA,EACX;AACJ;ACrEA,MAAM,OAAO,aAAa,KAAK;"}
1
+ {"version":3,"file":"wje-aside.js","sources":["../packages/wje-aside/aside.element.js","../packages/wje-aside/aside.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Aside element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/aside\n * @status stable\n * @augments WJElement\n * @attribute {string} width - Sets the width of the aside column, typically through a CSS length or design token.\n * @attribute {string} top - Sets the top offset used together with the `fixed` layout mode.\n * @attribute {boolean} fixed - Pins the aside in a fixed desktop position instead of keeping it in normal flow.\n * @attribute {string} variant - Selects an alternate layout variant such as the mobile `top-start` drawer style.\n * @slot default - Slot for the aside content.\n * @cssproperty [--wje-aside-width] - Controls the width of the aside column.\n * @cssproperty [--wje-aside-top] - Controls the top offset of a fixed aside.\n * @cssproperty [--wje-aside-border-color=var(--wje-border-color)] - Controls the border color of the aside.\n * @cssproperty [--wje-aside-border-width] - Controls the border width of the aside.\n * @cssproperty [--wje-aside-border-style] - Controls the border style of the aside.\n * @tag wje-aside\n */\nexport default class Aside extends WJElement {\n /**\n * Constructor for the Aside class.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Aside element.\n * @type {string}\n */\n className = 'Aside';\n\n /**\n * Getter for the CSS stylesheet.\n * @returns {object} The styles for the Aside element.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Getter for the observed attributes.\n * @returns {Array} An empty array as there are no observed attributes.\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Method to setup attributes for the Aside element.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Method to draw the Aside element.\n * @returns {object} The document fragment containing the drawn element.\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n if (this.width) this.style.setProperty('--wje-aside-width', this.width);\n\n if (this.top && this.hasAttribute('fixed')) this.style.setProperty('--wje-aside-top', this.top);\n\n let element = document.createElement('slot');\n\n fragment.appendChild(element);\n\n return fragment;\n }\n}\n","import Aside from './aside.element.js';\n\n// export * from \"./aside.element.js\";\nexport default Aside;\n\nAside.define('wje-aside', Aside);\n"],"names":["Aside","WJElement","constructor","super","className","cssStyleSheet","observedAttributes","setupAttributes","this","isShadowRoot","draw","fragment","document","createDocumentFragment","width","style","setProperty","top","hasAttribute","element","createElement","appendChild","define"],"mappings":";;;;AAoBe,MAAMA,UAAcC,EAAAA;AAAAA,EAI/B,cAAAC;AACIC,UAAAA;AAOJC,qCAAY;AAAA,EANZ;AAAA,EAYA,WAAA,gBAAWC;AACP;EACJ;AAAA,EAMA,WAAA,qBAAWC;AACP,WAAO,CAAA;AAAA,EACX;AAAA,EAKA,kBAAAC;AACIC,SAAKC,eAAe;AAAA,EACxB;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,uBAAAA;AAEpBL,SAAKM,SAAON,KAAKO,MAAMC,YAAY,qBAAqBR,KAAKM,KAAAA,GAE7DN,KAAKS,OAAOT,KAAKU,aAAa,OAAA,KAAUV,KAAKO,MAAMC,YAAY,mBAAmBR,KAAKS,GAAAA;AAE3F,QAAIE,KAAUP,SAASQ,cAAc;AAIrC,WAFAT,GAASU,YAAYF,EAAAA,GAEdR;AAAAA,EACX;AAAA;ACpEJX,EAAMsB,OAAO,aAAatB,CAAAA;"}
@@ -1,169 +1,79 @@
1
1
  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
- import WJElement from "./wje-element.js";
5
- function getAvatarColors(text) {
6
- let hash = 0;
7
- for (let i = 0; i < (text == null ? void 0 : text.length); i++) {
8
- hash = text.charCodeAt(i) + hash * 31;
9
- }
10
- const h = Math.abs(hash) % 360;
11
- const bgS = 30;
12
- const bgL = 88;
13
- const textS = 50;
14
- const textL = 48;
15
- return {
16
- background: `hsl(${h}, ${bgS}%, ${bgL}%)`,
17
- color: `hsl(${h}, ${textS}%, ${textL}%)`
18
- };
19
- }
20
- function getInitials(string, length = 2) {
21
- let names = string.split(" ");
22
- let initials = names[0].substring(0, 1).toUpperCase();
23
- if (names.length > 1 && length > 1) {
24
- initials += names[names.length - 1].substring(0, 1).toUpperCase();
25
- }
26
- return initials;
27
- }
28
- const styles = "/*\n[ WJ Avatar ]\n*/\n\n:host {\n display: inline-block;\n font-size: var(--wje-avatar-font-size);\n font-weight: var(--wje-avatar-font-weight);\n color: var(--wje-avatar-color);\n .native-avatar {\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n width: var(--wje-avatar-size);\n height: var(--wje-avatar-size);\n border-radius: var(--wje-avatar-border-radius);\n background-color: var(--wje-avatar-background-color);\n }\n}\n\n::slotted(wje-img),\n::slotted(img) {\n border-radius: var(--wje-avatar-border-radius);\n width: 100%;\n height: 100%;\n object-fit: cover;\n overflow: hidden;\n}\n\n:host(.wje-avatar-border) {\n border-color: var(--wje-avatar-border-color);\n border-width: var(--wje-avatar-border-width);\n border-style: var(--wje-avatar-border-style);\n}\n\n:host([size='small']) {\n --wje-avatar-size: var(--wje-size-small); /* 12px */\n --wje-avatar-font-size: var(--wje-font-size-2x-small);\n}\n\n:host([size='medium']) {\n --wje-avatar-size: var(--wje-size-medium); /* 14px */\n --wje-avatar-font-size: var(--wje-font-size-2x-small);\n}\n\n:host([size='normal']) {\n --wje-avatar-size: var(--wje-size); /* 14px */\n}\n\n:host([size='large']) {\n --wje-avatar-size: var(--wje-size-large); /* 20px */\n}\n\n:host([size='x-large']) {\n --wje-avatar-size: var(--wje-size-x-large); /* 24px */\n}\n\n:host([size='2x-large']) {\n --wje-avatar-size: var(--wje-size-2x-large); /* 36px */\n --wje-avatar-font-size: var(--wje-font-size-small);\n}\n\n:host([size='3x-large']) {\n --wje-avatar-size: var(--wje-size-3x-large); /* 48px */\n --wje-avatar-font-size: var(--wje-font-size-medium);\n}\n\n:host([size='4x-large']) {\n --wje-avatar-size: var(--wje-size-4x-large); /* 72px */\n --wje-avatar-font-size: var(--wje-font-size-x-large);\n}\n\n:host([size='5x-large']) {\n --wje-avatar-size: var(--wje-size-5x-large); /* 144px */\n --wje-avatar-font-size: var(--wje-font-size-3x-large);\n}\n\n/* Status Placement */\n:host slot[name='status'] {\n display: block;\n position: absolute;\n}\n\n:host([status-placement='top-start']) slot[name='status'] {\n top: -4px;\n left: -4px;\n}\n\n:host([status-placement='top-end']) slot[name='status'] {\n top: -4px;\n right: -4px;\n}\n\n:host([status-placement='bottom-start']) slot[name='status'] {\n bottom: -4px;\n left: -4px;\n}\n\n:host([status-placement='bottom-end']) slot[name='status'] {\n bottom: -4px;\n right: -4px;\n}\n";
29
- class Avatar extends WJElement {
30
- /**
31
- * Avatar class constructor.
32
- */
4
+ import t from "./wje-element.js";
5
+ class e extends t {
33
6
  constructor() {
34
7
  super();
35
- /**
36
- * Class name for the Avatar element.
37
- */
38
8
  __publicField(this, "className", "Avatar");
39
9
  }
40
- /**
41
- * Sets the value of the 'label' attribute for the element.
42
- * @param {string} value The new value to be set for the 'label' attribute.
43
- */
44
- set label(value) {
45
- this.setAttribute("label", value);
10
+ set label(t2) {
11
+ this.setAttribute("label", t2);
46
12
  }
47
- /**
48
- * Retrieves the value of the 'label' attribute for the element.
49
- * If the attribute is not set, it defaults to an empty string.
50
- * @returns {string} The value of the 'label' attribute or an empty string if not defined.
51
- */
52
13
  get label() {
53
14
  return this.getAttribute("label") || "";
54
15
  }
55
- /**
56
- * Sets the value of initials for the element by updating
57
- * the 'initials' attribute with the provided value.
58
- * @param {string} value The value to be set as the initials.
59
- */
60
- set initials(value) {
16
+ set initials(t2) {
61
17
  this.setAttribute("initials", "");
62
18
  }
63
- /**
64
- * Retrieves the value of the 'initials' attribute if it exists.
65
- * @returns {boolean} Returns true if the 'initials' attribute is present, otherwise false.
66
- */
67
19
  get initials() {
68
20
  return this.hasAttribute("initials") || false;
69
21
  }
70
- /**
71
- * Sets the size attribute for the element.
72
- * @param {string | number} value The value to set for the size attribute.
73
- */
74
- set size(value) {
75
- this.setAttribute("size", value);
22
+ set size(t2) {
23
+ this.setAttribute("size", t2);
76
24
  }
77
- /**
78
- * Retrieves the size attribute of the element. If the size attribute
79
- * is not defined, it returns the default value 'medium'.
80
- * @returns {string} The size value of the element or 'medium' if not specified.
81
- */
82
25
  get size() {
83
26
  return this.getAttribute("size") || "medium";
84
27
  }
85
- /**
86
- * Getter for cssStyleSheet.
87
- * @returns {string} styles
88
- */
89
28
  static get cssStyleSheet() {
90
- return styles;
29
+ return ':host{display:inline-block;font-size:var(--wje-avatar-font-size);font-weight:var(--wje-avatar-font-weight);color:var(--wje-avatar-color)}:host .native-avatar{position:relative;display:flex;align-items:center;justify-content:center;width:var(--wje-avatar-size);height:var(--wje-avatar-size);border-radius:var(--wje-avatar-border-radius);background-color:var(--wje-avatar-background-color)}::slotted(wje-img),::slotted(img){border-radius:var(--wje-avatar-border-radius);width:100%;height:100%;object-fit:cover;overflow:hidden}:host(.wje-avatar-border){border-color:var(--wje-avatar-border-color);border-width:var(--wje-avatar-border-width);border-style:var(--wje-avatar-border-style)}:host([size="small"]){--wje-avatar-size: var(--wje-size-small);--wje-avatar-font-size: var(--wje-font-size-2x-small)}:host([size="medium"]){--wje-avatar-size: var(--wje-size-medium);--wje-avatar-font-size: var(--wje-font-size-2x-small)}:host([size="normal"]){--wje-avatar-size: var(--wje-size)}:host([size="large"]){--wje-avatar-size: var(--wje-size-large)}:host([size="x-large"]){--wje-avatar-size: var(--wje-size-x-large)}:host([size="2x-large"]){--wje-avatar-size: var(--wje-size-2x-large);--wje-avatar-font-size: var(--wje-font-size-small)}:host([size="3x-large"]){--wje-avatar-size: var(--wje-size-3x-large);--wje-avatar-font-size: var(--wje-font-size-medium)}:host([size="4x-large"]){--wje-avatar-size: var(--wje-size-4x-large);--wje-avatar-font-size: var(--wje-font-size-x-large)}:host([size="5x-large"]){--wje-avatar-size: var(--wje-size-5x-large);--wje-avatar-font-size: var(--wje-font-size-3x-large)}:host slot[name=status]{display:block;position:absolute}:host([status-placement="top-start"]) slot[name=status]{top:-4px;left:-4px}:host([status-placement="top-end"]) slot[name=status]{top:-4px;right:-4px}:host([status-placement="bottom-start"]) slot[name=status]{bottom:-4px;left:-4px}:host([status-placement="bottom-end"]) slot[name=status]{bottom:-4px;right:-4px}';
91
30
  }
92
- /**
93
- * Returns the list of attributes to observe for changes.
94
- * @static
95
- * @returns {Array<string>}
96
- */
97
31
  static get observedAttributes() {
98
32
  return ["initials", "label"];
99
33
  }
100
- /**
101
- * Method to setup attributes.
102
- */
103
34
  setupAttributes() {
104
- this.isShadowRoot = "open";
105
- this.syncAria();
35
+ this.isShadowRoot = "open", this.syncAria();
106
36
  }
107
- attributeChangedCallback(name, oldValue, newValue) {
37
+ attributeChangedCallback(t2, e2, a) {
108
38
  var _a;
109
- (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, name, oldValue, newValue);
110
- if (name === "label" || name === "initials") {
111
- this.syncAria();
112
- }
39
+ (_a = super.attributeChangedCallback) == null ? void 0 : _a.call(this, t2, e2, a), "label" !== t2 && "initials" !== t2 || this.syncAria();
113
40
  }
114
- /**
115
- * Method to draw the avatar element and return a document fragment.
116
- * @returns {object} fragment - The document fragment
117
- */
118
41
  draw() {
119
- let fragment = document.createDocumentFragment();
120
- let element = document.createElement("div");
121
- element.setAttribute("part", "native");
122
- element.classList.add("native-avatar");
123
- let slot = document.createElement("slot");
124
- element.appendChild(slot);
125
- if (this.initials) {
126
- let initials = getInitials(this.label);
127
- const { background, color } = getAvatarColors(initials);
128
- this.style.setProperty("--wje-avatar-background-color", background);
129
- this.style.setProperty("--wje-avatar-color", color);
130
- element.innerText = initials;
42
+ let t2 = document.createDocumentFragment(), e2 = document.createElement("div");
43
+ e2.setAttribute("part", "native"), e2.classList.add("native-avatar");
44
+ let a = document.createElement("slot");
45
+ if (e2.appendChild(a), this.initials) {
46
+ let t3 = (function(t4, e3 = 2) {
47
+ let a3 = t4.split(" "), s3 = a3[0].substring(0, 1).toUpperCase();
48
+ return a3.length > 1 && e3 > 1 && (s3 += a3[a3.length - 1].substring(0, 1).toUpperCase()), s3;
49
+ })(this.label);
50
+ const { background: a2, color: s2 } = (function(t4) {
51
+ let e3 = 0;
52
+ for (let a4 = 0; a4 < (t4 == null ? void 0 : t4.length); a4++) e3 = t4.charCodeAt(a4) + 31 * e3;
53
+ const a3 = Math.abs(e3) % 360;
54
+ return { background: `hsl(${a3}, 30%, 88%)`, color: `hsl(${a3}, 50%, 48%)` };
55
+ })(t3);
56
+ this.style.setProperty("--wje-avatar-background-color", a2), this.style.setProperty("--wje-avatar-color", s2), e2.innerText = t3;
131
57
  } else {
132
- let slotIcon = document.createElement("slot");
133
- slotIcon.setAttribute("name", "icon");
134
- element.appendChild(slotIcon);
58
+ let t3 = document.createElement("slot");
59
+ t3.setAttribute("name", "icon"), e2.appendChild(t3);
135
60
  }
136
- let status = document.createElement("slot");
137
- status.setAttribute("name", "status");
138
- status.setAttribute("part", "status");
139
- let secondary = document.createElement("slot");
140
- secondary.setAttribute("name", "secondary");
141
- secondary.setAttribute("part", "secondary");
142
- element.appendChild(status);
143
- element.appendChild(secondary);
144
- fragment.appendChild(element);
145
- return fragment;
61
+ let s = document.createElement("slot");
62
+ s.setAttribute("name", "status"), s.setAttribute("part", "status");
63
+ let r = document.createElement("slot");
64
+ return r.setAttribute("name", "secondary"), r.setAttribute("part", "secondary"), e2.appendChild(s), e2.appendChild(r), t2.appendChild(e2), t2;
146
65
  }
147
- /**
148
- * Syncs ARIA attributes on the host element.
149
- */
150
66
  syncAria() {
151
67
  var _a;
152
- const label = (_a = this.label) == null ? void 0 : _a.trim();
153
- if (label) {
154
- this.setAriaState({ label });
155
- }
68
+ const t2 = (_a = this.label) == null ? void 0 : _a.trim();
69
+ t2 && this.setAriaState({ label: t2 });
156
70
  }
157
- /**
158
- * Method to check if the avatar is an image.
159
- * @returns {boolean} - True if the avatar is an image, false otherwise
160
- */
161
71
  isImage() {
162
72
  return this.getElementsByTagName("wje-img").length > 0;
163
73
  }
164
74
  }
165
- Avatar.define("wje-avatar", Avatar);
75
+ e.define("wje-avatar", e);
166
76
  export {
167
- Avatar as default
77
+ e as default
168
78
  };
169
79
  //# sourceMappingURL=wje-avatar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-avatar.js","sources":["../packages/wje-avatar/service/service.js","../packages/wje-avatar/avatar.element.js","../packages/wje-avatar/avatar.js"],"sourcesContent":["/**\n * Generates an HSL color value based on the input text.\n * @param {string} text The input text to generate the HSL color.\n * @param {number} [s] The saturation value (in percentage) for the HSL color.\n * @param {number} [l] The lightness value (in percentage) for the HSL color.\n * @returns {string} - The HSL color string in the format `hsl(h, s%, l%)`.\n * @description\n * This function computes a hash from the input text and uses it to generate\n * a hue value. The hue is combined with the provided saturation and lightness\n * values to create an HSL color. This can be useful for consistently assigning\n * colors based on text input, such as for avatars or tags.\n * @example\n * // Returns 'hsl(180, 40%, 65%)'\n * getHsl('example');\n * @example\n * // Returns 'hsl(300, 50%, 70%)'\n * getHsl('test', 50, 70);\n */\nexport function getHsl(text, s = 40, l = 75) {\n let str = text;\n let hash = 0;\n\n for (let i = 0; i < str?.length; i++) {\n hash = str.charCodeAt(i) + hash * 31;\n }\n\n let h = hash % 360;\n\n return `hsl(${h}, ${s}%, ${l}%)`;\n}\n\n/**\n * Generates background and text HSL colors for avatars based on input text.\n * The text color is a darker, more saturated variant of the background color\n * to ensure sufficient contrast while keeping the same hue.\n * @param {string} text The input text (e.g. initials or name).\n * @returns {{ background: string, color: string }}\n */\nexport function getAvatarColors(text) {\n let hash = 0;\n for (let i = 0; i < text?.length; i++) {\n hash = text.charCodeAt(i) + hash * 31;\n }\n\n const h = Math.abs(hash) % 360;\n\n // 👇 Figma-like pastel background\n const bgS = 30;\n const bgL = 88;\n\n // 👇 Softer text color (same hue)\n const textS = 50;\n const textL = 48;\n\n return {\n background: `hsl(${h}, ${bgS}%, ${bgL}%)`,\n color: `hsl(${h}, ${textS}%, ${textL}%)`\n };\n}\n\n/**\n * Generates initials from a given string.\n * @param {string} string The input string, typically a full name.\n * @param {number} [length] The desired number of initials (default is 2).\n * @returns {string} - The generated initials in uppercase.\n * @description\n * This function takes a string, splits it by spaces, and generates initials.\n * It always includes the first character of the first word. If the input string\n * contains more than one word and the `length` parameter is greater than 1, it\n * also includes the first character of the last word.\n * @example\n * // Returns 'JD'\n * getInitials('John Doe');\n * @example\n * // Returns 'J'\n * getInitials('John');\n * @example\n * // Returns 'JM'\n * getInitials('John Michael Doe', 2);\n */\nexport function getInitials(string, length = 2) {\n let names = string.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n\n if (names.length > 1 && length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n }\n return initials;\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { getHsl, getInitials, getAvatarColors } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Avatar element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/avatar\n * @status stable\n * @augments WJElement\n * @attribute {boolean} initials - Renders generated initials from `label` instead of the default slotted content.\n * @attribute {string} label - Provides the source text for generated initials and the accessible label of the avatar.\n * @attribute {string} size - Selects a predefined avatar size such as `small`, `medium`, `normal`, `large`, or larger variants.\n * @attribute {string} status-placement - Positions the `status` slot on one of the avatar corners.\n * @slot default - Slot for the main avatar content, typically an image.\n * @slot icon - Slot for an icon rendered inside the avatar.\n * @slot status - Slot for a status badge or indicator positioned on the avatar edge.\n * @slot secondary - Slot for additional secondary content rendered with the avatar.\n * @csspart native - The component's native wrapper.\n * @csspart status - The positioned slot container for status content.\n * @csspart secondary - The slot container for secondary avatar content.\n * @cssproperty [--wje-avatar-size] - Controls the overall rendered size of the avatar shell.\n * @cssproperty [--wje-avatar-font-size] - Controls the font size used for initials and text content.\n * @cssproperty [--wje-avatar-font-weight] - Controls the font weight used for initials and text content.\n * @cssproperty [--wje-avatar-color] - Controls the text color inside the avatar.\n * @cssproperty [--wje-avatar-background-color] - Controls the background color of the avatar surface.\n * @cssproperty [--wje-avatar-border-radius] - Controls the avatar border radius.\n * @cssproperty [--wje-avatar-border-color] - Controls the avatar border color when a border is applied.\n * @cssproperty [--wje-avatar-border-width] - Controls the avatar border width when a border is applied.\n * @cssproperty [--wje-avatar-border-style] - Controls the avatar border style when a border is applied.\n * @tag wje-avatar\n */\nexport default class Avatar extends WJElement {\n /**\n * Avatar class constructor.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'label' attribute for the element.\n * @param {string} value The new value to be set for the 'label' attribute.\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Retrieves the value of the 'label' attribute for the element.\n * If the attribute is not set, it defaults to an empty string.\n * @returns {string} The value of the 'label' attribute or an empty string if not defined.\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Sets the value of initials for the element by updating\n * the 'initials' attribute with the provided value.\n * @param {string} value The value to be set as the initials.\n */\n set initials(value) {\n this.setAttribute('initials', '');\n }\n\n /**\n * Retrieves the value of the 'initials' attribute if it exists.\n * @returns {boolean} Returns true if the 'initials' attribute is present, otherwise false.\n */\n get initials() {\n return this.hasAttribute('initials') || false;\n }\n\n /**\n * Sets the size attribute for the element.\n * @param {string | number} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the size attribute of the element. If the size attribute\n * is not defined, it returns the default value 'medium'.\n * @returns {string} The size value of the element or 'medium' if not specified.\n */\n get size() {\n return this.getAttribute('size') || 'medium';\n }\n\n /**\n * Class name for the Avatar element.\n */\n className = 'Avatar';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} styles\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 ['initials', 'label'];\n }\n\n /**\n * Method to setup attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'label' || name === 'initials') {\n this.syncAria();\n }\n }\n\n /**\n * Method to draw the avatar element and return a document fragment.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-avatar');\n\n let slot = document.createElement('slot');\n\n element.appendChild(slot);\n\n if (this.initials) {\n let initials = getInitials(this.label);\n const { background, color } = getAvatarColors(initials);\n\n this.style.setProperty('--wje-avatar-background-color', background);\n this.style.setProperty('--wje-avatar-color', color);\n\n element.innerText = initials;\n } else {\n let slotIcon = document.createElement('slot');\n slotIcon.setAttribute('name', 'icon');\n\n element.appendChild(slotIcon);\n }\n\n let status = document.createElement('slot');\n status.setAttribute('name', 'status');\n status.setAttribute('part', 'status');\n\n let secondary = document.createElement('slot');\n secondary.setAttribute('name', 'secondary');\n secondary.setAttribute('part', 'secondary');\n\n element.appendChild(status);\n element.appendChild(secondary);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const label = this.label?.trim();\n if (label) {\n this.setAriaState({ label });\n }\n }\n\n /**\n * Method to check if the avatar is an image.\n * @returns {boolean} - True if the avatar is an image, false otherwise\n */\n isImage() {\n return this.getElementsByTagName('wje-img').length > 0;\n }\n}\n","import Avatar from './avatar.element.js';\n\nexport default Avatar;\n\nAvatar.define('wje-avatar', Avatar);\n"],"names":[],"mappings":";;;;AAsCO,SAAS,gBAAgB,MAAM;AAClC,MAAI,OAAO;AACX,WAAS,IAAI,GAAG,KAAI,6BAAM,SAAQ,KAAK;AACnC,WAAO,KAAK,WAAW,CAAC,IAAI,OAAO;AAAA,EACvC;AAEA,QAAM,IAAI,KAAK,IAAI,IAAI,IAAI;AAG3B,QAAM,MAAM;AACZ,QAAM,MAAM;AAGZ,QAAM,QAAQ;AACd,QAAM,QAAQ;AAEd,S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;;AACP,UAAM,SAAQ,UAAK,UAAL,mBAAY;AAC1B,QAAI,OAAO;AACP,WAAK,aAAa,EAAE,OAAO;AAAA,IAC/B;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,UAAU;AACN,WAAO,KAAK,qBAAqB,SAAS,EAAE,SAAS;AAAA,EACzD;AACJ;AC1LA,OAAO,OAAO,cAAc,MAAM;"}
1
+ {"version":3,"file":"wje-avatar.js","sources":["../packages/wje-avatar/avatar.element.js","../packages/wje-avatar/service/service.js","../packages/wje-avatar/avatar.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport { getHsl, getInitials, getAvatarColors } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents an Avatar element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/avatar\n * @status stable\n * @augments WJElement\n * @attribute {boolean} initials - Renders generated initials from `label` instead of the default slotted content.\n * @attribute {string} label - Provides the source text for generated initials and the accessible label of the avatar.\n * @attribute {string} size - Selects a predefined avatar size such as `small`, `medium`, `normal`, `large`, or larger variants.\n * @attribute {string} status-placement - Positions the `status` slot on one of the avatar corners.\n * @slot default - Slot for the main avatar content, typically an image.\n * @slot icon - Slot for an icon rendered inside the avatar.\n * @slot status - Slot for a status badge or indicator positioned on the avatar edge.\n * @slot secondary - Slot for additional secondary content rendered with the avatar.\n * @csspart native - The component's native wrapper.\n * @csspart status - The positioned slot container for status content.\n * @csspart secondary - The slot container for secondary avatar content.\n * @cssproperty [--wje-avatar-size] - Controls the overall rendered size of the avatar shell.\n * @cssproperty [--wje-avatar-font-size] - Controls the font size used for initials and text content.\n * @cssproperty [--wje-avatar-font-weight] - Controls the font weight used for initials and text content.\n * @cssproperty [--wje-avatar-color] - Controls the text color inside the avatar.\n * @cssproperty [--wje-avatar-background-color] - Controls the background color of the avatar surface.\n * @cssproperty [--wje-avatar-border-radius] - Controls the avatar border radius.\n * @cssproperty [--wje-avatar-border-color] - Controls the avatar border color when a border is applied.\n * @cssproperty [--wje-avatar-border-width] - Controls the avatar border width when a border is applied.\n * @cssproperty [--wje-avatar-border-style] - Controls the avatar border style when a border is applied.\n * @tag wje-avatar\n */\nexport default class Avatar extends WJElement {\n /**\n * Avatar class constructor.\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the 'label' attribute for the element.\n * @param {string} value The new value to be set for the 'label' attribute.\n */\n set label(value) {\n this.setAttribute('label', value);\n }\n\n /**\n * Retrieves the value of the 'label' attribute for the element.\n * If the attribute is not set, it defaults to an empty string.\n * @returns {string} The value of the 'label' attribute or an empty string if not defined.\n */\n get label() {\n return this.getAttribute('label') || '';\n }\n\n /**\n * Sets the value of initials for the element by updating\n * the 'initials' attribute with the provided value.\n * @param {string} value The value to be set as the initials.\n */\n set initials(value) {\n this.setAttribute('initials', '');\n }\n\n /**\n * Retrieves the value of the 'initials' attribute if it exists.\n * @returns {boolean} Returns true if the 'initials' attribute is present, otherwise false.\n */\n get initials() {\n return this.hasAttribute('initials') || false;\n }\n\n /**\n * Sets the size attribute for the element.\n * @param {string | number} value The value to set for the size attribute.\n */\n set size(value) {\n this.setAttribute('size', value);\n }\n\n /**\n * Retrieves the size attribute of the element. If the size attribute\n * is not defined, it returns the default value 'medium'.\n * @returns {string} The size value of the element or 'medium' if not specified.\n */\n get size() {\n return this.getAttribute('size') || 'medium';\n }\n\n /**\n * Class name for the Avatar element.\n */\n className = 'Avatar';\n\n /**\n * Getter for cssStyleSheet.\n * @returns {string} styles\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 ['initials', 'label'];\n }\n\n /**\n * Method to setup attributes.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n super.attributeChangedCallback?.(name, oldValue, newValue);\n if (name === 'label' || name === 'initials') {\n this.syncAria();\n }\n }\n\n /**\n * Method to draw the avatar element and return a document fragment.\n * @returns {object} fragment - The document fragment\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.setAttribute('part', 'native');\n element.classList.add('native-avatar');\n\n let slot = document.createElement('slot');\n\n element.appendChild(slot);\n\n if (this.initials) {\n let initials = getInitials(this.label);\n const { background, color } = getAvatarColors(initials);\n\n this.style.setProperty('--wje-avatar-background-color', background);\n this.style.setProperty('--wje-avatar-color', color);\n\n element.innerText = initials;\n } else {\n let slotIcon = document.createElement('slot');\n slotIcon.setAttribute('name', 'icon');\n\n element.appendChild(slotIcon);\n }\n\n let status = document.createElement('slot');\n status.setAttribute('name', 'status');\n status.setAttribute('part', 'status');\n\n let secondary = document.createElement('slot');\n secondary.setAttribute('name', 'secondary');\n secondary.setAttribute('part', 'secondary');\n\n element.appendChild(status);\n element.appendChild(secondary);\n\n fragment.appendChild(element);\n\n return fragment;\n }\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n const label = this.label?.trim();\n if (label) {\n this.setAriaState({ label });\n }\n }\n\n /**\n * Method to check if the avatar is an image.\n * @returns {boolean} - True if the avatar is an image, false otherwise\n */\n isImage() {\n return this.getElementsByTagName('wje-img').length > 0;\n }\n}\n","/**\n * Generates an HSL color value based on the input text.\n * @param {string} text The input text to generate the HSL color.\n * @param {number} [s] The saturation value (in percentage) for the HSL color.\n * @param {number} [l] The lightness value (in percentage) for the HSL color.\n * @returns {string} - The HSL color string in the format `hsl(h, s%, l%)`.\n * @description\n * This function computes a hash from the input text and uses it to generate\n * a hue value. The hue is combined with the provided saturation and lightness\n * values to create an HSL color. This can be useful for consistently assigning\n * colors based on text input, such as for avatars or tags.\n * @example\n * // Returns 'hsl(180, 40%, 65%)'\n * getHsl('example');\n * @example\n * // Returns 'hsl(300, 50%, 70%)'\n * getHsl('test', 50, 70);\n */\nexport function getHsl(text, s = 40, l = 75) {\n let str = text;\n let hash = 0;\n\n for (let i = 0; i < str?.length; i++) {\n hash = str.charCodeAt(i) + hash * 31;\n }\n\n let h = hash % 360;\n\n return `hsl(${h}, ${s}%, ${l}%)`;\n}\n\n/**\n * Generates background and text HSL colors for avatars based on input text.\n * The text color is a darker, more saturated variant of the background color\n * to ensure sufficient contrast while keeping the same hue.\n * @param {string} text The input text (e.g. initials or name).\n * @returns {{ background: string, color: string }}\n */\nexport function getAvatarColors(text) {\n let hash = 0;\n for (let i = 0; i < text?.length; i++) {\n hash = text.charCodeAt(i) + hash * 31;\n }\n\n const h = Math.abs(hash) % 360;\n\n // 👇 Figma-like pastel background\n const bgS = 30;\n const bgL = 88;\n\n // 👇 Softer text color (same hue)\n const textS = 50;\n const textL = 48;\n\n return {\n background: `hsl(${h}, ${bgS}%, ${bgL}%)`,\n color: `hsl(${h}, ${textS}%, ${textL}%)`\n };\n}\n\n/**\n * Generates initials from a given string.\n * @param {string} string The input string, typically a full name.\n * @param {number} [length] The desired number of initials (default is 2).\n * @returns {string} - The generated initials in uppercase.\n * @description\n * This function takes a string, splits it by spaces, and generates initials.\n * It always includes the first character of the first word. If the input string\n * contains more than one word and the `length` parameter is greater than 1, it\n * also includes the first character of the last word.\n * @example\n * // Returns 'JD'\n * getInitials('John Doe');\n * @example\n * // Returns 'J'\n * getInitials('John');\n * @example\n * // Returns 'JM'\n * getInitials('John Michael Doe', 2);\n */\nexport function getInitials(string, length = 2) {\n let names = string.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n\n if (names.length > 1 && length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n }\n return initials;\n}\n","import Avatar from './avatar.element.js';\n\nexport default Avatar;\n\nAvatar.define('wje-avatar', Avatar);\n"],"names":["Avatar","WJElement","constructor","super","className","value","this","setAttribute","label","getAttribute","initials","hasAttribute","size","setupAttributes","isShadowRoot","syncAria","name","oldValue","newValue","attributeChangedCallback","fragment","document","createDocumentFragment","element","createElement","classList","add","slot","appendChild","string","length","names","split","substring","toUpperCase","background","color","text","hash","i","charCodeAt","h","Math","abs","style","setProperty","innerText","slotIcon","status","secondary","trim","setAriaState","getElementsByTagName","define"],"mappings":";;;;AA+Be,MAAMA,UAAeC,EAAAA;AAAAA,EAIhC,cAAAC;AACIC,UAAAA;AAyDJC,qCAAY;AAAA,EAxDZ;AAAA,EAMA,IAAA,MAAUC,IAAAA;AACNC,SAAKC,aAAa,SAASF,EAAAA;AAAAA,EAC/B;AAAA,EAOA,IAAA,QAAIG;AACA,WAAOF,KAAKG,aAAa,OAAA,KAAY;AAAA,EACzC;AAAA,EAOA,IAAA,SAAaJ,IAAAA;AACTC,SAAKC,aAAa,YAAY,EAAA;AAAA,EAClC;AAAA,EAMA,eAAIG;AACA,WAAOJ,KAAKK,aAAa,UAAA,KAAA;AAAA,EAC7B;AAAA,EAMA,IAAA,KAASN,IAAAA;AACLC,SAAKC,aAAa,QAAQF,EAAAA;AAAAA,EAC9B;AAAA,EAOA,IAAA,OAAIO;AACA,WAAON,KAAKG,aAAa,MAAA,KAAW;AAAA,EACxC;AAAA,EAWA,WAAA;AACI;EACJ;AAAA,EAOA,WAAA;AACI,WAAO,CAAC,YAAY,OAAA;AAAA,EACxB;AAAA,EAKA,kBAAAI;AACIP,SAAKQ,eAAe,QACpBR,KAAKS,SAAAA;AAAAA,EACT;AAAA,EAEA,yBAAyBC,IAAMC,IAAUC,GAAAA;;AACrCf,gBAAMgB,6BAANhB,8BAAiCa,IAAMC,IAAUC,IACpC,YAATF,MAA6B,eAATA,MACpBV,KAAKS,SAAAA;AAAAA,EAEb;AAAA,EAMA;AACI,QAAIK,KAAWC,SAASC,uBAAAA,GAEpBC,KAAUF,SAASG,cAAc,KAAA;AACrCD,IAAAA,GAAQhB,aAAa,QAAQ,QAAA,GAC7BgB,GAAQE,UAAUC,IAAI,eAAA;AAEtB,QAAIC,IAAON,SAASG,cAAc,MAAA;AAIlC,QAFAD,GAAQK,YAAYD,CAAAA,GAEhBrB,KAAKI,UAAU;AACf,UAAIA,MC/DT,SAAqBmB,IAAQC,KAAS,GAAA;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;AAAA,EAKA,WAAAL;;AACI,UAAMP,MAAQF,UAAKE,UAALF,mBAAY4C;AACtB1C,IAAAA,MACAF,KAAK6C,aAAa,EAAE3C,OAAAA,GAAAA,CAAAA;AAAAA,EAE5B;AAAA,EAMA;AACI,WAAOF,KAAK8C,qBAAqB,SAAA,EAAWtB,SAAS;AAAA,EACzD;AAAA;AEzLJ9B,EAAOqD,OAAO,cAAcrD,CAAAA;"}
package/dist/wje-badge.js CHANGED
@@ -1,72 +1,30 @@
1
1
  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
- import WJElement from "./wje-element.js";
5
- const styles = "/*\n[ WJ Badge ]\n*/\n\n.native-badge {\n display: flex;\n align-items: center;\n justify-content: center;\n text-shadow: none;\n font-family: var(--wje-font-family);\n font-size: var(--wje-font-size-x-small);\n line-height: var(--wje-badge-line-height);\n padding: 0;\n padding-block: var(--wje-badge-padding-block);\n padding-inline: var(--wje-badge-padding-inline);\n border-radius: var(--wje-badge-border-radius);\n border-width: var(--wje-badge-border-width);\n border-style: var(--wje-badge-border-style);\n border-color: var(--wje-badge-border-color);\n height: var(--wje-badge-height);\n}\n\n.wje-color-primary {\n background-color: var(--wje-color-primary-2);\n color: var(--wje-color-primary-9);\n}\n\n.wje-color-complete {\n background-color: var(--wje-color-complete-2);\n color: var(--wje-color-complete-9);\n}\n\n.wje-color-success {\n background-color: var(--wje-color-success-2);\n color: var(--wje-color-success-9);\n}\n\n.wje-color-warning {\n background-color: var(--wje-color-warning-2);\n color: var(--wje-color-warning-11);\n}\n\n.wje-color-danger {\n background-color: var(--wje-color-danger-2);\n color: var(--wje-color-danger-9);\n}\n\n.wje-color-info {\n background-color: var(--wje-color-contrast-0);\n color: var(--wje-color-info-11);\n border-color: var(--wje-color-contrast-2);\n}\n\n.wje-color-default {\n background-color: var(--wje-color-contrast-3);\n color: var(--wje-color-contrast-11);\n}\n";
6
- class Badge extends WJElement {
7
- /**
8
- * Creates an instance of Badge.
9
- * Represents a custom Badge element.
10
- * @class
11
- */
4
+ import e from "./wje-element.js";
5
+ class o extends e {
12
6
  constructor() {
13
7
  super();
14
- /**
15
- * The class name for the Badge element.
16
- * @type {string} The class name for the Badge element.
17
- */
18
8
  __publicField(this, "className", "Badge");
19
9
  }
20
- /**
21
- * Retrieves the CSS stylesheet for the Badge element.
22
- * @static
23
- * @returns {CSSStyleSheet} The CSS styles associated with the Badge.
24
- */
25
10
  static get cssStyleSheet() {
26
- return styles;
11
+ return ".native-badge{display:flex;align-items:center;justify-content:center;text-shadow:none;font-family:var(--wje-font-family);font-size:var(--wje-font-size-x-small);line-height:var(--wje-badge-line-height);padding:0;padding-block:var(--wje-badge-padding-block);padding-inline:var(--wje-badge-padding-inline);border-radius:var(--wje-badge-border-radius);border-width:var(--wje-badge-border-width);border-style:var(--wje-badge-border-style);border-color:var(--wje-badge-border-color);height:var(--wje-badge-height)}.wje-color-primary{background-color:var(--wje-color-primary-2);color:var(--wje-color-primary-9)}.wje-color-complete{background-color:var(--wje-color-complete-2);color:var(--wje-color-complete-9)}.wje-color-success{background-color:var(--wje-color-success-2);color:var(--wje-color-success-9)}.wje-color-warning{background-color:var(--wje-color-warning-2);color:var(--wje-color-warning-11)}.wje-color-danger{background-color:var(--wje-color-danger-2);color:var(--wje-color-danger-9)}.wje-color-info{background-color:var(--wje-color-contrast-0);color:var(--wje-color-info-11);border-color:var(--wje-color-contrast-2)}.wje-color-default{background-color:var(--wje-color-contrast-3);color:var(--wje-color-contrast-11)}";
27
12
  }
28
- /**
29
- * Specifies the attributes to observe for changes.
30
- * @static
31
- * @returns {Array<string>} An array containing the names of attributes to observe.
32
- * @example
33
- * static get observedAttributes() {
34
- * return ['color'];
35
- * }
36
- */
37
13
  static get observedAttributes() {
38
14
  return ["color"];
39
15
  }
40
- /**
41
- * Configures initial attributes for the Badge element.
42
- * @returns {void} Nothing is returned.
43
- */
44
16
  setupAttributes() {
45
- this.isShadowRoot = "open";
46
- this.setAriaState({ role: "status" });
17
+ this.isShadowRoot = "open", this.setAriaState({ role: "status" });
47
18
  }
48
- /**
49
- * Creates the DOM structure for the Badge element.
50
- * @returns {DocumentFragment} A document fragment containing the Badge's structure.
51
- */
52
19
  draw() {
53
- let fragment = document.createDocumentFragment();
54
- let native = document.createElement("div");
55
- native.setAttribute("part", "native");
56
- native.classList.add("native-badge");
57
- if (this.hasAttribute("color")) {
58
- native.classList.add(`wje-color-${this.color}`, "wje-color");
59
- } else {
60
- native.classList.add("wje-color-default", "wje-color");
61
- }
62
- let slot = document.createElement("slot");
63
- native.appendChild(slot);
64
- fragment.appendChild(native);
65
- return fragment;
20
+ let e2 = document.createDocumentFragment(), o2 = document.createElement("div");
21
+ o2.setAttribute("part", "native"), o2.classList.add("native-badge"), this.hasAttribute("color") ? o2.classList.add(`wje-color-${this.color}`, "wje-color") : o2.classList.add("wje-color-default", "wje-color");
22
+ let r = document.createElement("slot");
23
+ return o2.appendChild(r), e2.appendChild(o2), e2;
66
24
  }
67
25
  }
68
- Badge.define("wje-badge", Badge);
26
+ o.define("wje-badge", o);
69
27
  export {
70
- Badge as default
28
+ o as default
71
29
  };
72
30
  //# sourceMappingURL=wje-badge.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"wje-badge.js","sources":["../packages/wje-badge/badge.element.js","../packages/wje-badge/badge.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents a Badge element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/badge\n * @status stable\n * @augments WJElement\n * @attribute {string} color - The color of the badge element. Accepts any valid string primary, secondary, success, danger, warning, info, default.\n * @slot - The badge's main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-badge-border-radius=var(--wje-border-radius-pill)] - Border radius of the badge element.\n * @tag wje-badge\n */\n\nexport default class Badge extends WJElement {\n /**\n * Creates an instance of Badge.\n * Represents a custom Badge element.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Badge element.\n * @type {string} The class name for the Badge element.\n */\n className = 'Badge';\n\n /**\n * Retrieves the CSS stylesheet for the Badge element.\n * @static\n * @returns {CSSStyleSheet} The CSS styles associated with the Badge.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Specifies the attributes to observe for changes.\n * @static\n * @returns {Array<string>} An array containing the names of attributes to observe.\n * @example\n * static get observedAttributes() {\n * return ['color'];\n * }\n */\n static get observedAttributes() {\n return ['color'];\n }\n\n /**\n * Configures initial attributes for the Badge element.\n * @returns {void} Nothing is returned.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'status' });\n }\n\n /**\n * Creates the DOM structure for the Badge element.\n * @returns {DocumentFragment} A document fragment containing the Badge's structure.\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-badge');\n\n // Add color classes based on the `color` attribute\n if (this.hasAttribute('color')) {\n native.classList.add(`wje-color-${this.color}`, 'wje-color');\n } else {\n native.classList.add('wje-color-default', 'wje-color');\n }\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Badge from './badge.element.js';\n\nexport default Badge;\n\nBadge.define('wje-badge', Badge);\n"],"names":[],"mappings":";;;;;AAee,MAAM,cAAc,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMzC,cAAc;AACV,UAAK;AAOT;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaA,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,WAAW,qBAAqB;AAC5B,WAAO,CAAC,OAAO;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,kBAAkB;AACd,SAAK,eAAe;AACpB,SAAK,aAAa,EAAE,MAAM,SAAQ,CAAE;AAAA,EACxC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO;AACH,QAAI,WAAW,SAAS,uBAAsB;AAE9C,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,UAAU,IAAI,cAAc;AAGnC,QAAI,KAAK,aAAa,OAAO,GAAG;AAC5B,aAAO,UAAU,IAAI,aAAa,KAAK,KAAK,IAAI,WAAW;AAAA,IAC/D,OAAO;AACH,aAAO,UAAU,IAAI,qBAAqB,WAAW;AAAA,IACzD;AAEA,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,WAAO,YAAY,IAAI;AAEvB,aAAS,YAAY,MAAM;AAE3B,WAAO;AAAA,EACX;AACJ;ACpFA,MAAM,OAAO,aAAa,KAAK;"}
1
+ {"version":3,"file":"wje-badge.js","sources":["../packages/wje-badge/badge.element.js","../packages/wje-badge/badge.js"],"sourcesContent":["import { default as WJElement } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary This class represents a Badge element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/badge\n * @status stable\n * @augments WJElement\n * @attribute {string} color - The color of the badge element. Accepts any valid string primary, secondary, success, danger, warning, info, default.\n * @slot - The badge's main content.\n * @csspart native - The component's native wrapper.\n * @cssproperty [--wje-badge-border-radius=var(--wje-border-radius-pill)] - Border radius of the badge element.\n * @tag wje-badge\n */\n\nexport default class Badge extends WJElement {\n /**\n * Creates an instance of Badge.\n * Represents a custom Badge element.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the Badge element.\n * @type {string} The class name for the Badge element.\n */\n className = 'Badge';\n\n /**\n * Retrieves the CSS stylesheet for the Badge element.\n * @static\n * @returns {CSSStyleSheet} The CSS styles associated with the Badge.\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Specifies the attributes to observe for changes.\n * @static\n * @returns {Array<string>} An array containing the names of attributes to observe.\n * @example\n * static get observedAttributes() {\n * return ['color'];\n * }\n */\n static get observedAttributes() {\n return ['color'];\n }\n\n /**\n * Configures initial attributes for the Badge element.\n * @returns {void} Nothing is returned.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.setAriaState({ role: 'status' });\n }\n\n /**\n * Creates the DOM structure for the Badge element.\n * @returns {DocumentFragment} A document fragment containing the Badge's structure.\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-badge');\n\n // Add color classes based on the `color` attribute\n if (this.hasAttribute('color')) {\n native.classList.add(`wje-color-${this.color}`, 'wje-color');\n } else {\n native.classList.add('wje-color-default', 'wje-color');\n }\n\n let slot = document.createElement('slot');\n\n native.appendChild(slot);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Badge from './badge.element.js';\n\nexport default Badge;\n\nBadge.define('wje-badge', Badge);\n"],"names":["Badge","WJElement","super","className","cssStyleSheet","setupAttributes","this","isShadowRoot","setAriaState","role","draw","fragment","document","createDocumentFragment","native","createElement","setAttribute","classList","add","hasAttribute","color","slot","appendChild","define"],"mappings":";;;;AAee,MAAMA,UAAcC,EAAAA;AAAAA,EAM/B;AACIC,UAAAA;AAOJC,qCAAY;AAAA,EANZ;AAAA,EAaA,2BAAWC;AACP;EACJ;AAAA,EAWA,WAAA;AACI,WAAO,CAAC,OAAA;AAAA,EACZ;AAAA,EAMA,kBAAAC;AACIC,SAAKC,eAAe,QACpBD,KAAKE,aAAa,EAAEC,MAAM,SAAA,CAAA;AAAA,EAC9B;AAAA,EAMA,OAAAC;AACI,QAAIC,KAAWC,SAASC,uBAAAA,GAEpBC,KAASF,SAASG,cAAc,KAAA;AACpCD,IAAAA,GAAOE,aAAa,QAAQ,QAAA,GAC5BF,GAAOG,UAAUC,IAAI,cAAA,GAGjBZ,KAAKa,aAAa,OAAA,IAClBL,GAAOG,UAAUC,IAAI,aAAaZ,KAAKc,KAAAA,IAAS,eAEhDN,GAAOG,UAAUC,IAAI,qBAAqB;AAG9C,QAAIG,IAAOT,SAASG,cAAc,MAAA;AAMlC,WAJAD,GAAOQ,YAAYD,CAAAA,GAEnBV,GAASW,YAAYR,EAAAA,GAEdH;AAAAA,EACX;;ACnFJX,EAAMuB,OAAO,aAAavB,CAAAA;"}