wj-elements 0.1.136 → 0.1.137

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 (202) hide show
  1. package/dist/dark.css +223 -0
  2. package/dist/infinite-scroll.element-XVJukzjy.js +272 -0
  3. package/dist/infinite-scroll.element-XVJukzjy.js.map +1 -0
  4. package/dist/light.css +534 -0
  5. package/dist/list.element-Ce1vIm1O.js +50 -0
  6. package/dist/list.element-Ce1vIm1O.js.map +1 -0
  7. package/dist/localize.js +70 -0
  8. package/dist/localize.js.map +1 -0
  9. package/dist/popup.element-tyYxow0p.js +1623 -0
  10. package/dist/popup.element-tyYxow0p.js.map +1 -0
  11. package/dist/router-links-CJnOdbas.js +150 -0
  12. package/dist/router-links-CJnOdbas.js.map +1 -0
  13. package/dist/styles.css +849 -0
  14. package/dist/wje-accordion-item.js +113 -0
  15. package/dist/wje-accordion-item.js.map +1 -0
  16. package/dist/wje-accordion.js +122 -0
  17. package/dist/wje-accordion.js.map +1 -0
  18. package/dist/wje-animation.js +4326 -0
  19. package/dist/wje-animation.js.map +1 -0
  20. package/dist/wje-aside.js +55 -0
  21. package/dist/wje-aside.js.map +1 -0
  22. package/dist/wje-avatar.js +90 -0
  23. package/dist/wje-avatar.js.map +1 -0
  24. package/dist/wje-badge.js +71 -0
  25. package/dist/wje-badge.js.map +1 -0
  26. package/dist/wje-breadcrumb.js +195 -0
  27. package/dist/wje-breadcrumb.js.map +1 -0
  28. package/dist/wje-breadcrumbs.js +140 -0
  29. package/dist/wje-breadcrumbs.js.map +1 -0
  30. package/dist/wje-button-group.js +85 -0
  31. package/dist/wje-button-group.js.map +1 -0
  32. package/dist/wje-button.js +352 -0
  33. package/dist/wje-button.js.map +1 -0
  34. package/dist/wje-card-content.js +48 -0
  35. package/dist/wje-card-content.js.map +1 -0
  36. package/dist/wje-card-controls.js +48 -0
  37. package/dist/wje-card-controls.js.map +1 -0
  38. package/dist/wje-card-header.js +48 -0
  39. package/dist/wje-card-header.js.map +1 -0
  40. package/dist/wje-card-subtitle.js +55 -0
  41. package/dist/wje-card-subtitle.js.map +1 -0
  42. package/dist/wje-card-title.js +55 -0
  43. package/dist/wje-card-title.js.map +1 -0
  44. package/dist/wje-card.js +56 -0
  45. package/dist/wje-card.js.map +1 -0
  46. package/dist/wje-carousel-item.js +63 -0
  47. package/dist/wje-carousel-item.js.map +1 -0
  48. package/dist/wje-carousel.js +380 -0
  49. package/dist/wje-carousel.js.map +1 -0
  50. package/dist/wje-checkbox.js +540 -0
  51. package/dist/wje-checkbox.js.map +1 -0
  52. package/dist/wje-chip.js +76 -0
  53. package/dist/wje-chip.js.map +1 -0
  54. package/dist/wje-col.js +38 -0
  55. package/dist/wje-col.js.map +1 -0
  56. package/dist/wje-color-picker.js +1339 -0
  57. package/dist/wje-color-picker.js.map +1 -0
  58. package/dist/wje-container.js +56 -0
  59. package/dist/wje-container.js.map +1 -0
  60. package/dist/wje-copy-button.js +218 -0
  61. package/dist/wje-copy-button.js.map +1 -0
  62. package/dist/wje-dialog.js +249 -0
  63. package/dist/wje-dialog.js.map +1 -0
  64. package/dist/wje-divider.js +55 -0
  65. package/dist/wje-divider.js.map +1 -0
  66. package/dist/wje-dropdown.js +194 -0
  67. package/dist/wje-dropdown.js.map +1 -0
  68. package/dist/wje-element.js +967 -0
  69. package/dist/wje-element.js.map +1 -0
  70. package/dist/wje-fetchAndParseCSS.js +60 -0
  71. package/dist/wje-fetchAndParseCSS.js.map +1 -0
  72. package/dist/wje-file-upload-item.js +140 -0
  73. package/dist/wje-file-upload-item.js.map +1 -0
  74. package/dist/wje-file-upload.js +552 -0
  75. package/dist/wje-file-upload.js.map +1 -0
  76. package/dist/wje-footer.js +52 -0
  77. package/dist/wje-footer.js.map +1 -0
  78. package/dist/wje-form.js +53 -0
  79. package/dist/wje-form.js.map +1 -0
  80. package/dist/wje-format-digital.js +146 -0
  81. package/dist/wje-format-digital.js.map +1 -0
  82. package/dist/wje-grid.js +54 -0
  83. package/dist/wje-grid.js.map +1 -0
  84. package/dist/wje-header.js +56 -0
  85. package/dist/wje-header.js.map +1 -0
  86. package/dist/wje-icon-picker.js +349 -0
  87. package/dist/wje-icon-picker.js.map +1 -0
  88. package/dist/wje-icon.js +191 -0
  89. package/dist/wje-icon.js.map +1 -0
  90. package/dist/wje-img-comparer.js +131 -0
  91. package/dist/wje-img-comparer.js.map +1 -0
  92. package/dist/wje-img.js +80 -0
  93. package/dist/wje-img.js.map +1 -0
  94. package/dist/wje-infinite-scroll.js +6 -0
  95. package/dist/wje-infinite-scroll.js.map +1 -0
  96. package/dist/wje-input-file.js +111 -0
  97. package/dist/wje-input-file.js.map +1 -0
  98. package/dist/wje-input.js +452 -0
  99. package/dist/wje-input.js.map +1 -0
  100. package/dist/wje-item.js +88 -0
  101. package/dist/wje-item.js.map +1 -0
  102. package/dist/wje-kanban.js +462 -0
  103. package/dist/wje-kanban.js.map +1 -0
  104. package/dist/wje-label.js +53 -0
  105. package/dist/wje-label.js.map +1 -0
  106. package/dist/wje-list.js +6 -0
  107. package/dist/wje-list.js.map +1 -0
  108. package/dist/wje-main.js +52 -0
  109. package/dist/wje-main.js.map +1 -0
  110. package/dist/wje-masonry.js +267 -0
  111. package/dist/wje-masonry.js.map +1 -0
  112. package/dist/wje-master.js +687 -0
  113. package/dist/wje-master.js.map +1 -0
  114. package/dist/wje-menu-button.js +60 -0
  115. package/dist/wje-menu-button.js.map +1 -0
  116. package/dist/wje-menu-item.js +545 -0
  117. package/dist/wje-menu-item.js.map +1 -0
  118. package/dist/wje-menu-label.js +55 -0
  119. package/dist/wje-menu-label.js.map +1 -0
  120. package/dist/wje-menu.js +72 -0
  121. package/dist/wje-menu.js.map +1 -0
  122. package/dist/wje-option.js +112 -0
  123. package/dist/wje-option.js.map +1 -0
  124. package/dist/wje-options.js +355 -0
  125. package/dist/wje-options.js.map +1 -0
  126. package/dist/wje-orgchart-group.js +72 -0
  127. package/dist/wje-orgchart-group.js.map +1 -0
  128. package/dist/wje-orgchart-item.js +98 -0
  129. package/dist/wje-orgchart-item.js.map +1 -0
  130. package/dist/wje-orgchart.js +49 -0
  131. package/dist/wje-orgchart.js.map +1 -0
  132. package/dist/wje-popup.js +6 -0
  133. package/dist/wje-popup.js.map +1 -0
  134. package/dist/wje-progress-bar.js +213 -0
  135. package/dist/wje-progress-bar.js.map +1 -0
  136. package/dist/wje-qr-code.js +2892 -0
  137. package/dist/wje-qr-code.js.map +1 -0
  138. package/dist/wje-radio-group.js +228 -0
  139. package/dist/wje-radio-group.js.map +1 -0
  140. package/dist/wje-radio.js +106 -0
  141. package/dist/wje-radio.js.map +1 -0
  142. package/dist/wje-rate.js +300 -0
  143. package/dist/wje-rate.js.map +1 -0
  144. package/dist/wje-relative-time.js +115 -0
  145. package/dist/wje-relative-time.js.map +1 -0
  146. package/dist/wje-reorder-dropzone.js +49 -0
  147. package/dist/wje-reorder-dropzone.js.map +1 -0
  148. package/dist/wje-reorder-handle.js +218 -0
  149. package/dist/wje-reorder-handle.js.map +1 -0
  150. package/dist/wje-reorder-item.js +61 -0
  151. package/dist/wje-reorder-item.js.map +1 -0
  152. package/dist/wje-reorder.js +281 -0
  153. package/dist/wje-reorder.js.map +1 -0
  154. package/dist/wje-route.js +43 -0
  155. package/dist/wje-route.js.map +1 -0
  156. package/dist/wje-router-link.js +64 -0
  157. package/dist/wje-router-link.js.map +1 -0
  158. package/dist/wje-router-outlet.js +192 -0
  159. package/dist/wje-router-outlet.js.map +1 -0
  160. package/dist/wje-routerx.js +1437 -0
  161. package/dist/wje-routerx.js.map +1 -0
  162. package/dist/wje-row.js +49 -0
  163. package/dist/wje-row.js.map +1 -0
  164. package/dist/wje-select.js +630 -0
  165. package/dist/wje-select.js.map +1 -0
  166. package/dist/wje-slider.js +221 -0
  167. package/dist/wje-slider.js.map +1 -0
  168. package/dist/wje-sliding-container.js +474 -0
  169. package/dist/wje-sliding-container.js.map +1 -0
  170. package/dist/wje-split-view.js +153 -0
  171. package/dist/wje-split-view.js.map +1 -0
  172. package/dist/wje-status.js +61 -0
  173. package/dist/wje-status.js.map +1 -0
  174. package/dist/wje-step.js +50 -0
  175. package/dist/wje-step.js.map +1 -0
  176. package/dist/wje-stepper.js +231 -0
  177. package/dist/wje-stepper.js.map +1 -0
  178. package/dist/wje-store.js +401 -0
  179. package/dist/wje-store.js.map +1 -0
  180. package/dist/wje-tab-group.js +137 -0
  181. package/dist/wje-tab-group.js.map +1 -0
  182. package/dist/wje-tab-panel.js +46 -0
  183. package/dist/wje-tab-panel.js.map +1 -0
  184. package/dist/wje-tab.js +59 -0
  185. package/dist/wje-tab.js.map +1 -0
  186. package/dist/wje-textarea.js +373 -0
  187. package/dist/wje-textarea.js.map +1 -0
  188. package/dist/wje-thumbnail.js +54 -0
  189. package/dist/wje-thumbnail.js.map +1 -0
  190. package/dist/wje-toast.js +334 -0
  191. package/dist/wje-toast.js.map +1 -0
  192. package/dist/wje-toggle.js +125 -0
  193. package/dist/wje-toggle.js.map +1 -0
  194. package/dist/wje-toolbar-action.js +72 -0
  195. package/dist/wje-toolbar-action.js.map +1 -0
  196. package/dist/wje-toolbar.js +63 -0
  197. package/dist/wje-toolbar.js.map +1 -0
  198. package/dist/wje-tooltip.js +166 -0
  199. package/dist/wje-tooltip.js.map +1 -0
  200. package/dist/wje-visually-hidden.js +55 -0
  201. package/dist/wje-visually-hidden.js.map +1 -0
  202. package/package.json +1 -1
@@ -0,0 +1,474 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import WJElement from "./wje-element.js";
5
+ const styles = ":host {\n display: block;\n z-index: 1000;\n /* make css property for width height position and if it is on top lef bottom right */\n}\n\n.sliding-container-wrapper {\n height: 100%;\n position: relative;\n overflow: hidden;\n}\n\n.native-sliding-container {\n overflow: auto;\n}\n";
6
+ class SlidingContainer extends WJElement {
7
+ /**
8
+ * Creates an instance of SlidingContainer.
9
+ * @class
10
+ */
11
+ constructor() {
12
+ super();
13
+ __publicField(this, "className", "SlidingContainer");
14
+ /**
15
+ * Triggers the event based on the target element.
16
+ * If the target element is different from the last caller, it refreshes the children by calling the `open` method.
17
+ * If the target element is the same as the last caller, it toggles the state by calling the `toggle` method.
18
+ * @param {Event} e The event object.
19
+ */
20
+ __publicField(this, "triggerEvent", async (e) => {
21
+ if (this._lastCaller && this._lastCaller !== e.composedPath()[0]) {
22
+ await this.open(e);
23
+ } else {
24
+ await this.toggle(e);
25
+ }
26
+ this._lastCaller = e.composedPath()[0];
27
+ });
28
+ this._isOpen = false;
29
+ this._lastCaller = null;
30
+ this._resizeObserver = new ResizeObserver((entries) => {
31
+ for (let entry of entries) {
32
+ if (entry.contentBoxSize) {
33
+ if (this.drawingStatus < 3) return;
34
+ if (this.screenBreakPoint && window.innerWidth <= this.screenBreakPoint) {
35
+ if (this.variant !== "over") {
36
+ this.variant = "over";
37
+ } else {
38
+ this.checkForVariant(this.variant);
39
+ }
40
+ } else {
41
+ if (this.variant !== "in-place") {
42
+ this.variant = "in-place";
43
+ } else {
44
+ this.checkForVariant(this.variant);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ });
50
+ this._resizeObserver.observe(document.documentElement);
51
+ }
52
+ set maxWidth(value) {
53
+ this.setAttribute("max-width", value);
54
+ }
55
+ get maxWidth() {
56
+ return this.getAttribute("max-width") ?? "auto";
57
+ }
58
+ set maxHeight(value) {
59
+ this.setAttribute("max-height", value);
60
+ }
61
+ get maxHeight() {
62
+ return this.getAttribute("max-height") ?? "auto";
63
+ }
64
+ set trigger(value) {
65
+ this.setAttribute("trigger", value);
66
+ }
67
+ get trigger() {
68
+ return this.getAttribute("trigger") ?? "sliding-container";
69
+ }
70
+ set direction(value) {
71
+ this.setAttribute("direction", value);
72
+ }
73
+ get direction() {
74
+ return this.getAttribute("direction") ?? "right";
75
+ }
76
+ set removeChildAfterClose(value) {
77
+ this.setAttribute("remove-child-after-close", value);
78
+ }
79
+ get removeChildAfterClose() {
80
+ return this.hasAttribute("remove-child-after-close") ?? false;
81
+ }
82
+ set variant(value) {
83
+ this.setAttribute("variant", value);
84
+ }
85
+ get variant() {
86
+ return this.getAttribute("variant") ?? "in-place";
87
+ }
88
+ get screenBreakPoint() {
89
+ return this.getAttribute("screen-break-point");
90
+ }
91
+ set screenBreakPoint(value) {
92
+ this.setAttribute("screen-break-point", value);
93
+ }
94
+ get animationDuration() {
95
+ return this.getAttribute("animation-duration") ?? "500";
96
+ }
97
+ set animationDuration(value) {
98
+ this.setAttribute("animation-duration", value);
99
+ }
100
+ get animationEasing() {
101
+ return this.getAttribute("animation-easing") ?? "linear";
102
+ }
103
+ set animationEasing(value) {
104
+ this.setAttribute("animation-easing", value);
105
+ }
106
+ get hasOpacity() {
107
+ return this.hasAttribute("has-opacity") ?? false;
108
+ }
109
+ get addToHeight() {
110
+ return this.getAttribute("add-to-height") ?? "0";
111
+ }
112
+ set addToHeight(value) {
113
+ this.setAttribute("add-to-height", value);
114
+ }
115
+ /**
116
+ * Returns the observed attributes for the component.
117
+ * @returns {string[]}
118
+ */
119
+ static get observedAttributes() {
120
+ return [
121
+ "max-width",
122
+ "max-height",
123
+ "trigger",
124
+ "direction",
125
+ "variant",
126
+ "screen-break-point",
127
+ "remove-child-after-close",
128
+ "animation-duration",
129
+ "animation-easing",
130
+ "has-opacity"
131
+ ];
132
+ }
133
+ /**
134
+ * Returns the CSS styles for the component.
135
+ * @static
136
+ * @returns {CSSStyleSheet}
137
+ */
138
+ static get cssStyleSheet() {
139
+ return styles;
140
+ }
141
+ /**
142
+ * Sets up the attributes for the component.
143
+ */
144
+ setupAttributes() {
145
+ this.isShadowRoot = "open";
146
+ }
147
+ /**
148
+ * Draws the component.
149
+ * @param {object} context The context for drawing.
150
+ * @param {object} store The store for drawing.
151
+ * @param {object} params The parameters for drawing.
152
+ * @returns {DocumentFragment}
153
+ */
154
+ draw(context, store, params) {
155
+ let fragment = document.createDocumentFragment();
156
+ this.style.position = "relative";
157
+ this.style.height = "100%";
158
+ this.style.right = "unset";
159
+ this.style.left = "unset";
160
+ this.wrapperDiv = document.createElement("div");
161
+ this.wrapperDiv.classList.add("sliding-container-wrapper");
162
+ this.transparentDiv = document.createElement("div");
163
+ this.transparentDiv.classList.add("sliding-container-transparent");
164
+ if (this._isOpen) {
165
+ this.transparentDiv.style.width = this.maxWidth;
166
+ }
167
+ let native = document.createElement("div");
168
+ native.style.position = "absolute";
169
+ native.style.width = 0;
170
+ if (this.hasOpacity) {
171
+ native.style.opacity = 0;
172
+ }
173
+ if (this._isOpen) {
174
+ native.style.width = this.maxWidth;
175
+ if (this.hasOpacity) {
176
+ native.style.opacity = 1;
177
+ }
178
+ }
179
+ native.style.height = "100%";
180
+ native.classList.add("native-sliding-container");
181
+ native.setAttribute("part", "sliding-container");
182
+ if (this.direction === "right") {
183
+ native.style.right = 0;
184
+ } else {
185
+ native.style.left = 0;
186
+ }
187
+ let slot = document.createElement("slot");
188
+ const nativeInner = document.createElement("div");
189
+ nativeInner.classList.add("native-sliding-container-inner");
190
+ nativeInner.style.height = "100%";
191
+ nativeInner.style.position = "absolute";
192
+ nativeInner.style.width = this.maxWidth;
193
+ nativeInner.appendChild(slot);
194
+ nativeInner.appendChild(this.getCloseButton());
195
+ native.appendChild(nativeInner);
196
+ this.wrapperDiv.appendChild(this.transparentDiv);
197
+ this.wrapperDiv.appendChild(native);
198
+ fragment.appendChild(this.wrapperDiv);
199
+ this.nativeElement = native;
200
+ return fragment;
201
+ }
202
+ /**
203
+ * Creates and returns a close button element.
204
+ * @returns {HTMLElement} The close button element.
205
+ */
206
+ getCloseButton() {
207
+ let closeButton = document.createElement("wje-button");
208
+ closeButton.setAttribute("part", "close-button");
209
+ closeButton.style.position = "absolute";
210
+ closeButton.style.top = "0";
211
+ closeButton.style.right = "0";
212
+ closeButton.style.zIndex = "1000";
213
+ let icon = document.createElement("wje-icon");
214
+ icon.setAttribute("slot", "icon-only");
215
+ icon.setAttribute("name", "x");
216
+ closeButton.appendChild(icon);
217
+ closeButton.addEventListener("click", () => {
218
+ this.close();
219
+ });
220
+ return closeButton;
221
+ }
222
+ /**
223
+ * Executes before drawing the element.
224
+ */
225
+ beforeDraw() {
226
+ var _a, _b;
227
+ (_a = this.animation) == null ? void 0 : _a.cancel();
228
+ (_b = this.nativeAnimation) == null ? void 0 : _b.cancel();
229
+ document.removeEventListener(this.trigger, this.triggerEvent);
230
+ }
231
+ /**
232
+ * Performs actions after the element is drawn on the screen.
233
+ * Attaches an event listener to the document based on the specified trigger.
234
+ * Sets the variant to "over" if the document width is smaller than the screen break point.
235
+ * Calls the checkForVariant method with the current variant.
236
+ * @returns {Promise<void>} A promise that resolves after the actions are completed.
237
+ */
238
+ afterDraw() {
239
+ document.addEventListener(this.trigger, this.triggerEvent);
240
+ if (this.screenBreakPoint && window.innerWidth <= this.screenBreakPoint) {
241
+ this.variant = "over";
242
+ }
243
+ this.checkForVariant(this.variant);
244
+ }
245
+ getParentElement() {
246
+ let parentElement = this.parentElement;
247
+ if (!parentElement) {
248
+ parentElement = this.getRootNode().host;
249
+ }
250
+ return parentElement;
251
+ }
252
+ /**
253
+ * Checks for a specific variant and applies corresponding styles.
254
+ * @param {string} variant The variant to check for.
255
+ */
256
+ checkForVariant(variant) {
257
+ if (variant === "over") {
258
+ this.style.position = "fixed";
259
+ let computentStyleOfParent = window.getComputedStyle(this.getParentElement());
260
+ let parentElementBoundingbox = this.getParentElement().getBoundingClientRect();
261
+ let heightOfParrentElement = parseFloat(computentStyleOfParent.height);
262
+ let topOfParrentElement = parseFloat(computentStyleOfParent.top);
263
+ this.style.height = heightOfParrentElement + +this.addToHeight + "px";
264
+ this.wrapperDiv.style.height = heightOfParrentElement + +this.addToHeight + "px";
265
+ this.style.top = topOfParrentElement + "px";
266
+ const leftSibling = this.previousElementSibling;
267
+ const rightSibling = this.nextElementSibling;
268
+ const leftSiblingBoundingbox = leftSibling == null ? void 0 : leftSibling.getBoundingClientRect();
269
+ const rightSiblingBoundingbox = rightSibling == null ? void 0 : rightSibling.getBoundingClientRect();
270
+ if (this.direction === "right") {
271
+ if (leftSiblingBoundingbox) {
272
+ this.style.left = leftSiblingBoundingbox.left + leftSiblingBoundingbox.width + "px";
273
+ } else {
274
+ this.style.left = parentElementBoundingbox.left + "px";
275
+ }
276
+ } else {
277
+ if (rightSiblingBoundingbox) {
278
+ this.style.right = window.innerWidth - rightSiblingBoundingbox.left + "px";
279
+ } else {
280
+ this.style.right = window.innerWidth - (parentElementBoundingbox.left + parentElementBoundingbox.width) + "px";
281
+ }
282
+ }
283
+ }
284
+ }
285
+ /**
286
+ * Executes before the element is opened.
287
+ */
288
+ beforeOpen(event) {
289
+ }
290
+ /**
291
+ * Callback function called after the element is opened.
292
+ */
293
+ afterOpen(event) {
294
+ }
295
+ /**
296
+ * Executes before closing the element.
297
+ */
298
+ beforeClose(event) {
299
+ }
300
+ /**
301
+ * Callback function that is called after the container is closed.
302
+ */
303
+ afterClose(event) {
304
+ }
305
+ /**
306
+ * Animates the transition of the element's width from 0 to the maximum width or vice versa.
307
+ * @returns {Promise<void>} A promise that resolves when the animation is complete.
308
+ */
309
+ doAnimateTransition() {
310
+ var _a, _b, _c, _d;
311
+ const options = {
312
+ delay: 0,
313
+ endDelay: 0,
314
+ fill: "forwards",
315
+ duration: +this.animationDuration,
316
+ iterationStart: 0,
317
+ iterations: 1,
318
+ direction: "normal",
319
+ easing: this.animationEasing
320
+ };
321
+ if (this.animation && ((_b = (_a = this.animation) == null ? void 0 : _a.effect) == null ? void 0 : _b.target) !== this.transparentDiv) {
322
+ this.animation.cancel();
323
+ this.animation = null;
324
+ }
325
+ if (this.nativeAnimation && ((_d = (_c = this.nativeAnimation) == null ? void 0 : _c.effect) == null ? void 0 : _d.target) !== this.nativeElement) {
326
+ this.nativeAnimation.cancel();
327
+ this.nativeAnimation = null;
328
+ }
329
+ if (!this._isOpen) {
330
+ if (this.animation && this.nativeAnimation) {
331
+ this.animation.reverse();
332
+ this.nativeAnimation.reverse();
333
+ } else {
334
+ this.animation = this.transparentDiv.animate(
335
+ [
336
+ {
337
+ width: 0
338
+ },
339
+ {
340
+ width: this.maxWidth
341
+ }
342
+ ],
343
+ options
344
+ );
345
+ this.nativeAnimation = this.nativeElement.animate(
346
+ [
347
+ {
348
+ ...this.hasOpacity ? { opacity: 0 } : {},
349
+ width: 0
350
+ },
351
+ {
352
+ ...this.hasOpacity ? { opacity: 1 } : {},
353
+ width: this.maxWidth
354
+ }
355
+ ],
356
+ options
357
+ );
358
+ }
359
+ } else {
360
+ if (this.animation && this.nativeAnimation) {
361
+ this.animation.reverse();
362
+ this.nativeAnimation.reverse();
363
+ } else {
364
+ this.animation = this.transparentDiv.animate(
365
+ [
366
+ {
367
+ width: this.maxWidth
368
+ },
369
+ {
370
+ width: 0
371
+ }
372
+ ],
373
+ options
374
+ );
375
+ this.nativeAnimation = this.nativeElement.animate(
376
+ [
377
+ {
378
+ ...this.hasOpacity ? { opacity: 1 } : {},
379
+ width: this.maxWidth
380
+ },
381
+ {
382
+ ...this.hasOpacity ? { opacity: 0 } : {},
383
+ width: 0
384
+ }
385
+ ],
386
+ options
387
+ );
388
+ }
389
+ }
390
+ return new Promise((resolve, reject) => {
391
+ this.animation.onfinish = () => {
392
+ this._isOpen = !this._isOpen;
393
+ resolve();
394
+ };
395
+ });
396
+ }
397
+ /**
398
+ * Opens the container with an animation.
399
+ * @returns {Promise<void>} A promise that resolves when the container is opened.
400
+ */
401
+ async open(event) {
402
+ await Promise.resolve(this.beforeOpen(event)).then(async () => {
403
+ if (!this._isOpen) {
404
+ this.dispatchEvent(
405
+ new CustomEvent("wje-sliding-container:beforeOpen", {
406
+ bubbles: true,
407
+ composed: true
408
+ })
409
+ );
410
+ await this.doAnimateTransition();
411
+ await Promise.resolve(this.afterOpen(event)).then(() => {
412
+ this.dispatchEvent(
413
+ new CustomEvent("wje-sliding-container:open", {
414
+ bubbles: true,
415
+ composed: true
416
+ })
417
+ );
418
+ });
419
+ }
420
+ });
421
+ }
422
+ /**
423
+ * Closes the animation container.
424
+ * @returns {Promise<void>} A promise that resolves when the container is closed.
425
+ */
426
+ async close(event) {
427
+ await Promise.resolve(this.beforeClose(event)).then(async () => {
428
+ if (this._isOpen) {
429
+ this.dispatchEvent(
430
+ new CustomEvent("wje-sliding-container:beforeClose", {
431
+ bubbles: true,
432
+ composed: true
433
+ })
434
+ );
435
+ await this.doAnimateTransition();
436
+ await Promise.resolve(this.afterClose(event)).then(() => {
437
+ if (this.removeChildAfterClose) {
438
+ this.childNodes.forEach((child) => {
439
+ child.remove();
440
+ });
441
+ }
442
+ this.dispatchEvent(
443
+ new CustomEvent("wje-sliding-container:close", {
444
+ bubbles: true,
445
+ composed: true
446
+ })
447
+ );
448
+ });
449
+ }
450
+ });
451
+ }
452
+ /**
453
+ * Toggles the state of the element.
454
+ * If the element is open, it will be closed. If it is closed, it will be opened.
455
+ * @returns {Promise<void>} A promise that resolves when the toggle operation is complete.
456
+ */
457
+ async toggle(event) {
458
+ if (this._isOpen) {
459
+ await this.close(event);
460
+ } else {
461
+ await this.open(event);
462
+ }
463
+ }
464
+ componentCleanup() {
465
+ var _a;
466
+ (_a = this._resizeObserver) == null ? void 0 : _a.disconnect();
467
+ this._resizeObserver = null;
468
+ }
469
+ }
470
+ SlidingContainer.define("wje-sliding-container", SlidingContainer);
471
+ export {
472
+ SlidingContainer as default
473
+ };
474
+ //# sourceMappingURL=wje-sliding-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wje-sliding-container.js","sources":["../experimental-packages/wje-sliding-container/sliding-container.element.js","../experimental-packages/wje-sliding-container/sliding-container.js"],"sourcesContent":["import { default as WJElement } from '../../packages/wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * @summary SlidingContainer is a custom web component that extends WJElement.\n * @documentation https://elements.webjet.sk/components/SlidingContainer\n * @status stable\n * @augments WJElement\n * @csspart - Styles the element.\n * @slot - The default slot for the SlidingContainer.\n * @property {string} maxWidth - The maximum width of the SlidingContainer.\n * @property {string} maxHeight - The maximum height of the SlidingContainer.\n * @property {string} trigger - The trigger for the SlidingContainer.\n * @property {string} direction - The direction of the SlidingContainer.\n * @property {string} variant - The variant of the SlidingContainer.\n * @property {string} screenBreakPoint - The screen break point of the SlidingContainer.\n * @property {boolean} removeChildAfterClose - Removes the child after the SlidingContainer is closed.\n * @property {string} animationDuration - The duration of the animation.\n * @property {string} animationEasing - The easing of the animation.\n * @property {boolean} hasOpacity - Sets the opacity of the SlidingContainer.\n * @tag wje-sliding-container\n * @example\n * <wje-sliding-container trigger=\"test-resize-container-event-right\" id=\"left-in-place\" direction=\"left\" max-width=\"100px\" max-height=\"100%\">\n * <wje-card>\n * <wje-card-header>\n * <wje-card-subtitle>CONTENT Subtitle</wje-card-subtitle>\n * <wje-card-title>CONTENT Title</wje-card-title>\n * </wje-card-header>\n * <wje-card-content>\n * CONTENT Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n * </wje-card-content>\n * </wje-card>\n * </wje-sliding-container>\n */\nexport default class SlidingContainer extends WJElement {\n /**\n * Creates an instance of SlidingContainer.\n * @class\n */\n constructor() {\n super();\n\n this._isOpen = false;\n this._lastCaller = null;\n\n this._resizeObserver = new ResizeObserver((entries) => {\n for (let entry of entries) {\n if (entry.contentBoxSize) {\n if (this.drawingStatus < 3) return;\n\n if (this.screenBreakPoint && window.innerWidth <= this.screenBreakPoint) {\n if (this.variant !== 'over') {\n this.variant = 'over';\n } else {\n this.checkForVariant(this.variant);\n }\n } else {\n if (this.variant !== 'in-place') {\n this.variant = 'in-place';\n } else {\n this.checkForVariant(this.variant);\n }\n }\n }\n }\n });\n\n this._resizeObserver.observe(document.documentElement);\n }\n\n set maxWidth(value) {\n this.setAttribute('max-width', value);\n }\n\n get maxWidth() {\n return this.getAttribute('max-width') ?? 'auto';\n }\n\n set maxHeight(value) {\n this.setAttribute('max-height', value);\n }\n\n get maxHeight() {\n return this.getAttribute('max-height') ?? 'auto';\n }\n\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n get trigger() {\n return this.getAttribute('trigger') ?? 'sliding-container';\n }\n\n set direction(value) {\n this.setAttribute('direction', value);\n }\n\n get direction() {\n return this.getAttribute('direction') ?? 'right';\n }\n\n set removeChildAfterClose(value) {\n this.setAttribute('remove-child-after-close', value);\n }\n\n get removeChildAfterClose() {\n return this.hasAttribute('remove-child-after-close') ?? false;\n }\n\n set variant(value) {\n this.setAttribute('variant', value);\n }\n\n get variant() {\n return this.getAttribute('variant') ?? 'in-place';\n }\n\n get screenBreakPoint() {\n return this.getAttribute('screen-break-point');\n }\n\n set screenBreakPoint(value) {\n this.setAttribute('screen-break-point', value);\n }\n\n get animationDuration() {\n return this.getAttribute('animation-duration') ?? '500';\n }\n\n set animationDuration(value) {\n this.setAttribute('animation-duration', value);\n }\n\n get animationEasing() {\n return this.getAttribute('animation-easing') ?? 'linear';\n }\n\n set animationEasing(value) {\n this.setAttribute('animation-easing', value);\n }\n\n get hasOpacity() {\n return this.hasAttribute('has-opacity') ?? false;\n }\n\n get addToHeight() {\n return this.getAttribute('add-to-height') ?? '0';\n }\n\n set addToHeight(value) {\n this.setAttribute('add-to-height', value);\n }\n\n className = 'SlidingContainer';\n\n /**\n * Returns the observed attributes for the component.\n * @returns {string[]}\n */\n static get observedAttributes() {\n return [\n 'max-width',\n 'max-height',\n 'trigger',\n 'direction',\n 'variant',\n 'screen-break-point',\n 'remove-child-after-close',\n 'animation-duration',\n 'animation-easing',\n 'has-opacity',\n ];\n }\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 * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component.\n * @param {object} context The context for drawing.\n * @param {object} store The store for drawing.\n * @param {object} params The parameters for drawing.\n * @returns {DocumentFragment}\n */\n draw(context, store, params) {\n let fragment = document.createDocumentFragment();\n\n this.style.position = 'relative';\n this.style.height = '100%';\n this.style.right = 'unset';\n this.style.left = 'unset';\n\n this.wrapperDiv = document.createElement('div');\n this.wrapperDiv.classList.add('sliding-container-wrapper');\n\n this.transparentDiv = document.createElement('div');\n this.transparentDiv.classList.add('sliding-container-transparent');\n if (this._isOpen) {\n this.transparentDiv.style.width = this.maxWidth;\n }\n\n let native = document.createElement('div');\n native.style.position = 'absolute';\n native.style.width = 0;\n if (this.hasOpacity) {\n native.style.opacity = 0;\n }\n\n if (this._isOpen) {\n native.style.width = this.maxWidth;\n if (this.hasOpacity) {\n native.style.opacity = 1;\n }\n }\n\n native.style.height = '100%';\n\n native.classList.add('native-sliding-container');\n native.setAttribute('part', 'sliding-container');\n\n if (this.direction === 'right') {\n native.style.right = 0;\n } else {\n native.style.left = 0;\n }\n\n let slot = document.createElement('slot');\n\n const nativeInner = document.createElement('div');\n nativeInner.classList.add('native-sliding-container-inner');\n nativeInner.style.height = '100%';\n nativeInner.style.position = 'absolute';\n nativeInner.style.width = this.maxWidth;\n\n nativeInner.appendChild(slot);\n nativeInner.appendChild(this.getCloseButton());\n\n native.appendChild(nativeInner);\n this.wrapperDiv.appendChild(this.transparentDiv);\n this.wrapperDiv.appendChild(native);\n fragment.appendChild(this.wrapperDiv);\n\n this.nativeElement = native;\n\n return fragment;\n }\n\n /**\n * Creates and returns a close button element.\n * @returns {HTMLElement} The close button element.\n */\n getCloseButton() {\n let closeButton = document.createElement('wje-button');\n closeButton.setAttribute('part', 'close-button');\n closeButton.style.position = 'absolute';\n closeButton.style.top = '0';\n closeButton.style.right = '0';\n closeButton.style.zIndex = '1000';\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('slot', 'icon-only');\n icon.setAttribute('name', 'x');\n closeButton.appendChild(icon);\n\n closeButton.addEventListener('click', () => {\n this.close();\n });\n\n return closeButton;\n }\n\n /**\n * Executes before drawing the element.\n */\n beforeDraw() {\n this.animation?.cancel();\n this.nativeAnimation?.cancel();\n document.removeEventListener(this.trigger, this.triggerEvent);\n }\n\n /**\n * Performs actions after the element is drawn on the screen.\n * Attaches an event listener to the document based on the specified trigger.\n * Sets the variant to \"over\" if the document width is smaller than the screen break point.\n * Calls the checkForVariant method with the current variant.\n * @returns {Promise<void>} A promise that resolves after the actions are completed.\n */\n afterDraw() {\n document.addEventListener(this.trigger, this.triggerEvent);\n\n // if document width is on small screen set variant to over\n if (this.screenBreakPoint && window.innerWidth <= this.screenBreakPoint) {\n this.variant = 'over';\n }\n\n this.checkForVariant(this.variant);\n }\n\n getParentElement() {\n let parentElement = this.parentElement;\n\n if (!parentElement) {\n parentElement = this.getRootNode().host;\n }\n\n return parentElement;\n }\n\n /**\n * Checks for a specific variant and applies corresponding styles.\n * @param {string} variant The variant to check for.\n */\n checkForVariant(variant) {\n if (variant === 'over') {\n this.style.position = 'fixed';\n let computentStyleOfParent = window.getComputedStyle(this.getParentElement());\n let parentElementBoundingbox = this.getParentElement().getBoundingClientRect();\n let heightOfParrentElement = parseFloat(computentStyleOfParent.height);\n\n let topOfParrentElement = parseFloat(computentStyleOfParent.top);\n\n this.style.height = heightOfParrentElement + +this.addToHeight + 'px';\n this.wrapperDiv.style.height = heightOfParrentElement + +this.addToHeight + 'px';\n this.style.top = topOfParrentElement + 'px';\n\n const leftSibling = this.previousElementSibling;\n const rightSibling = this.nextElementSibling;\n const leftSiblingBoundingbox = leftSibling?.getBoundingClientRect();\n const rightSiblingBoundingbox = rightSibling?.getBoundingClientRect();\n\n if (this.direction === 'right') {\n // attach to left sibling\n if (leftSiblingBoundingbox) {\n this.style.left = leftSiblingBoundingbox.left + leftSiblingBoundingbox.width + 'px';\n } else {\n this.style.left = parentElementBoundingbox.left + 'px';\n }\n } else {\n // attach to right sibling\n if (rightSiblingBoundingbox) {\n this.style.right = window.innerWidth - rightSiblingBoundingbox.left + 'px';\n } else {\n this.style.right =\n window.innerWidth - (parentElementBoundingbox.left + parentElementBoundingbox.width) + 'px';\n }\n }\n }\n }\n\n /**\n * Triggers the event based on the target element.\n * If the target element is different from the last caller, it refreshes the children by calling the `open` method.\n * If the target element is the same as the last caller, it toggles the state by calling the `toggle` method.\n * @param {Event} e The event object.\n */\n triggerEvent = async (e) => {\n if (this._lastCaller && this._lastCaller !== e.composedPath()[0]) {\n // same oppener event but different caller so just refresh inner content\n await this.open(e);\n } else {\n // came caller so toggle\n await this.toggle(e);\n }\n\n this._lastCaller = e.composedPath()[0];\n };\n\n /**\n * Executes before the element is opened.\n */\n beforeOpen(event) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Callback function called after the element is opened.\n */\n afterOpen(event) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Executes before closing the element.\n */\n beforeClose(event) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Callback function that is called after the container is closed.\n */\n afterClose(event) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Animates the transition of the element's width from 0 to the maximum width or vice versa.\n * @returns {Promise<void>} A promise that resolves when the animation is complete.\n */\n doAnimateTransition() {\n const options = {\n delay: 0,\n endDelay: 0,\n fill: 'forwards',\n duration: +this.animationDuration,\n iterationStart: 0,\n iterations: 1,\n direction: 'normal',\n easing: this.animationEasing,\n };\n\n if (this.animation && this.animation?.effect?.target !== this.transparentDiv) {\n this.animation.cancel();\n this.animation = null;\n }\n\n if (this.nativeAnimation && this.nativeAnimation?.effect?.target !== this.nativeElement) {\n this.nativeAnimation.cancel();\n this.nativeAnimation = null;\n }\n\n if (!this._isOpen) {\n if (this.animation && this.nativeAnimation) {\n this.animation.reverse();\n this.nativeAnimation.reverse();\n } else {\n this.animation = this.transparentDiv.animate(\n [\n {\n width: 0,\n },\n {\n width: this.maxWidth,\n },\n ],\n options,\n );\n\n this.nativeAnimation = this.nativeElement.animate(\n [\n {\n ...(this.hasOpacity ? { opacity: 0 } : {}),\n width: 0,\n },\n {\n ...(this.hasOpacity ? { opacity: 1 } : {}),\n width: this.maxWidth,\n },\n ],\n options,\n );\n }\n } else {\n if (this.animation && this.nativeAnimation) {\n this.animation.reverse();\n this.nativeAnimation.reverse();\n } else {\n this.animation = this.transparentDiv.animate(\n [\n {\n width: this.maxWidth,\n },\n {\n width: 0,\n },\n ],\n options,\n );\n\n this.nativeAnimation = this.nativeElement.animate(\n [\n {\n ...(this.hasOpacity ? { opacity: 1 } : {}),\n width: this.maxWidth,\n },\n {\n ...(this.hasOpacity ? { opacity: 0 } : {}),\n width: 0,\n },\n ],\n options,\n );\n }\n }\n\n return new Promise((resolve, reject) => {\n this.animation.onfinish = () => {\n this._isOpen = !this._isOpen;\n resolve();\n };\n });\n }\n\n /**\n * Opens the container with an animation.\n * @returns {Promise<void>} A promise that resolves when the container is opened.\n */\n async open(event) {\n await Promise.resolve(this.beforeOpen(event)).then(async () => {\n if (!this._isOpen) {\n this.dispatchEvent(\n new CustomEvent('wje-sliding-container:beforeOpen', {\n bubbles: true,\n composed: true,\n }),\n );\n\n await this.doAnimateTransition();\n\n await Promise.resolve(this.afterOpen(event)).then(() => {\n this.dispatchEvent(\n new CustomEvent('wje-sliding-container:open', {\n bubbles: true,\n composed: true,\n }),\n );\n });\n }\n });\n }\n\n /**\n * Closes the animation container.\n * @returns {Promise<void>} A promise that resolves when the container is closed.\n */\n async close(event) {\n await Promise.resolve(this.beforeClose(event)).then(async () => {\n if (this._isOpen) {\n this.dispatchEvent(\n new CustomEvent('wje-sliding-container:beforeClose', {\n bubbles: true,\n composed: true,\n }),\n );\n\n await this.doAnimateTransition();\n\n await Promise.resolve(this.afterClose(event)).then(() => {\n if (this.removeChildAfterClose) {\n this.childNodes.forEach((child) => {\n child.remove();\n });\n }\n\n this.dispatchEvent(\n new CustomEvent('wje-sliding-container:close', {\n bubbles: true,\n composed: true,\n }),\n );\n });\n }\n });\n }\n\n /**\n * Toggles the state of the element.\n * If the element is open, it will be closed. If it is closed, it will be opened.\n * @returns {Promise<void>} A promise that resolves when the toggle operation is complete.\n */\n async toggle(event) {\n if (this._isOpen) {\n await this.close(event);\n } else {\n await this.open(event);\n }\n }\n\n componentCleanup() {\n this._resizeObserver?.disconnect();\n this._resizeObserver = null;\n }\n}\n","import SlidingContainer from './sliding-container.element.js';\n\nexport default SlidingContainer;\n\nSlidingContainer.define('wje-sliding-container', SlidingContainer);\n"],"names":[],"mappings":";;;;;AAkCe,MAAM,yBAAyB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAKtD,cAAc;AACZ,UAAO;AAkHT,qCAAY;AAuNZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAe,OAAO,MAAM;AAC1B,UAAI,KAAK,eAAe,KAAK,gBAAgB,EAAE,aAAY,EAAG,CAAC,GAAG;AAEhE,cAAM,KAAK,KAAK,CAAC;AAAA,MACvB,OAAW;AAEL,cAAM,KAAK,OAAO,CAAC;AAAA,MACzB;AAEI,WAAK,cAAc,EAAE,aAAY,EAAG,CAAC;AAAA,IACtC;AAjVC,SAAK,UAAU;AACf,SAAK,cAAc;AAEnB,SAAK,kBAAkB,IAAI,eAAe,CAAC,YAAY;AACrD,eAAS,SAAS,SAAS;AACzB,YAAI,MAAM,gBAAgB;AACxB,cAAI,KAAK,gBAAgB,EAAG;AAE5B,cAAI,KAAK,oBAAoB,OAAO,cAAc,KAAK,kBAAkB;AACvE,gBAAI,KAAK,YAAY,QAAQ;AAC3B,mBAAK,UAAU;AAAA,YAC7B,OAAmB;AACL,mBAAK,gBAAgB,KAAK,OAAO;AAAA,YAC/C;AAAA,UACA,OAAiB;AACL,gBAAI,KAAK,YAAY,YAAY;AAC/B,mBAAK,UAAU;AAAA,YAC7B,OAAmB;AACL,mBAAK,gBAAgB,KAAK,OAAO;AAAA,YAC/C;AAAA,UACA;AAAA,QACA;AAAA,MACA;AAAA,IACA,CAAK;AAED,SAAK,gBAAgB,QAAQ,SAAS,eAAe;AAAA,EACzD;AAAA,EAEE,IAAI,SAAS,OAAO;AAClB,SAAK,aAAa,aAAa,KAAK;A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Prop = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import WJElement from "./wje-element.js";
5
+ function drag(container, options) {
6
+ function move(pointerEvent) {
7
+ const dims = container.getBoundingClientRect();
8
+ const defaultView = container.ownerDocument.defaultView;
9
+ const offsetX = dims.left + defaultView.pageXOffset;
10
+ const offsetY = dims.top + defaultView.pageYOffset;
11
+ const x = pointerEvent.pageX - offsetX;
12
+ const y = pointerEvent.pageY - offsetY;
13
+ if (options == null ? void 0 : options.onMove) {
14
+ options.onMove(x, y);
15
+ }
16
+ }
17
+ function stop() {
18
+ document.removeEventListener("pointermove", move);
19
+ document.removeEventListener("pointerup", stop);
20
+ if (options == null ? void 0 : options.onStop) {
21
+ options.onStop();
22
+ }
23
+ }
24
+ document.addEventListener("pointermove", move, { passive: true });
25
+ document.addEventListener("pointerup", stop);
26
+ if ((options == null ? void 0 : options.initialEvent) instanceof PointerEvent) {
27
+ move(options.initialEvent);
28
+ }
29
+ }
30
+ const styles = "/*\n[ WJ Split View ]\n*/\n\n:host {\n --wje-split-view-divider-area: 12px;\n --wje-split-view-divider-width: 4px;\n --wje-split-view-min: 0%;\n --wje-split-view-max: 100%;\n --wje-split-view-calc-a: 50%;\n --wje-split-view-calc-b: 50%;\n --wje-split-view-clamp-a: clamp(var(--wje-split-view-min), var(--wje-split-view-calc-a), var(--wje-split-view-max));\n --wje-split-view-clamp-b: clamp(var(--wje-split-view-min), var(--wje-split-view-calc-b), var(--wje-split-view-max));\n\n --wje-split-view-divider-background: var(--wje-border-color);\n --wje-split-view-divider-size: 4px;\n height: 100%;\n width: 100%;\n}\n\n::slotted([slot='start']),\n::slotted([slot='end']) {\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n}\n\n:host(:not([vertical])) ::slotted([slot='start']) {\n width: var(--wje-split-view-clamp-a);\n}\n\n:host(:not([vertical])) ::slotted([slot='end']) {\n width: var(--wje-split-view-clamp-b);\n}\n\n:host([vertical]) ::slotted([slot='start']) {\n height: var(--wje-split-view-clamp-a);\n width: 100%;\n}\n\n:host([vertical]) ::slotted([slot='end']) {\n height: var(--wje-split-view-clamp-b);\n width: 100%;\n}\n\n.native-split-view {\n height: 100%;\n width: 100%;\n display: flex;\n flex-direction: row;\n overflow: hidden;\n position: relative;\n}\n\n:host([vertical]) .native-split-view {\n flex-direction: column;\n}\n\n.wje-divider {\n display: flex;\n position: relative;\n align-items: center;\n justify-content: center;\n z-index: 1;\n background-color: var(--wje-split-view-divider-background);\n height: 100%;\n width: var(--wje-split-view-divider-size);\n cursor: col-resize;\n &:after {\n display: flex;\n align-items: center;\n content: '';\n position: absolute;\n height: 100%;\n left: calc(var(--wje-split-view-divider-area) / -2 + var(--wje-split-view-divider-width) / 2);\n width: var(--wje-split-view-divider-area);\n }\n}\n\n:host([vertical]) .wje-divider {\n height: var(--wje-split-view-divider-size);\n width: 100%;\n cursor: row-resize;\n &:after {\n width: 100%;\n top: calc(var(--wje-split-view-divider-area) / -2 + var(--wje-split-view-divider-width) / 2);\n height: var(--wje-split-view-divider-area);\n }\n}\n";
31
+ class SplitView extends WJElement {
32
+ /**
33
+ * Creates an instance of SplitView.
34
+ * @class
35
+ */
36
+ constructor() {
37
+ super();
38
+ __publicField(this, "className", "SplitView");
39
+ /**
40
+ * Handles the drag event.
41
+ * @param {Event} e The event object.
42
+ */
43
+ __publicField(this, "handleDrag", (e) => {
44
+ if (this.hasAttribute("disabled")) return;
45
+ drag(this, {
46
+ onMove: (x, y) => {
47
+ console.log("x", x);
48
+ console.log("y", y);
49
+ console.log("this.hasAttribute(vertical)", this.hasAttribute("vertical"));
50
+ let newPositionInPixels = this.hasAttribute("vertical") ? y : x;
51
+ console.log("newPositionInPixels", newPositionInPixels);
52
+ let sizeA = this.pixelsToPercentage(newPositionInPixels);
53
+ let sizeB = 100 - this.pixelsToPercentage(newPositionInPixels);
54
+ console.log("sizeA", sizeA);
55
+ console.log("sizeB", sizeB);
56
+ this.style.setProperty("--wje-split-view-calc-a", sizeA + "%");
57
+ this.style.setProperty("--wje-split-view-calc-b", sizeB + "%");
58
+ },
59
+ initialEvent: e
60
+ });
61
+ });
62
+ }
63
+ set initial(value) {
64
+ this.setAttribute("initial", value);
65
+ }
66
+ get initial() {
67
+ return +this.getAttribute("initial") || 50;
68
+ }
69
+ /**
70
+ * Returns the CSS styles for the component.
71
+ * @static
72
+ * @returns {CSSStyleSheet}
73
+ */
74
+ static get cssStyleSheet() {
75
+ return styles;
76
+ }
77
+ /**
78
+ * Returns the list of attributes to observe for changes.
79
+ * @static
80
+ * @returns {Array<string>}
81
+ */
82
+ static get observedAttributes() {
83
+ return [];
84
+ }
85
+ /**
86
+ * Sets up the attributes for the component.
87
+ */
88
+ setupAttributes() {
89
+ this.isShadowRoot = "open";
90
+ }
91
+ /**
92
+ * Draws the component for the split view.
93
+ * @returns {DocumentFragment}
94
+ */
95
+ draw() {
96
+ let fragment = document.createDocumentFragment();
97
+ let native = document.createElement("div");
98
+ native.classList.add("native-split-view");
99
+ let start = document.createElement("slot");
100
+ start.setAttribute("name", "start");
101
+ let end = document.createElement("slot");
102
+ end.setAttribute("name", "end");
103
+ let divider = document.createElement("slot");
104
+ divider.setAttribute("name", "divider");
105
+ let dividerElement = document.createElement("div");
106
+ dividerElement.classList.add("wje-divider");
107
+ dividerElement.setAttribute("part", "divider");
108
+ dividerElement.appendChild(divider);
109
+ dividerElement.addEventListener("mousedown", this.handleDrag, false);
110
+ native.appendChild(start);
111
+ native.appendChild(dividerElement);
112
+ native.appendChild(end);
113
+ fragment.appendChild(native);
114
+ return fragment;
115
+ }
116
+ /**
117
+ * Sets up the event listeners after the component is drawn.
118
+ */
119
+ afterDraw() {
120
+ this.detectSize();
121
+ if (this.min) this.style.setProperty("--wje-split-view-min", this.pixelsToPercentage(this.min) + "%");
122
+ if (this.max) this.style.setProperty("--wje-split-view-max", 100 - this.pixelsToPercentage(this.max) + "%");
123
+ if (this.initial) {
124
+ this.style.setProperty("--wje-split-view-calc-a", this.pixelsToPercentage(this.initial) + "%");
125
+ this.style.setProperty("--wje-split-view-calc-b", 100 - this.pixelsToPercentage(this.initial) + "%");
126
+ }
127
+ this.resizeObserver = new ResizeObserver((entries) => this.handleResize(entries));
128
+ }
129
+ /**
130
+ * Detects the size of the split view.
131
+ */
132
+ detectSize() {
133
+ const { width, height } = this.getBoundingClientRect();
134
+ console.log("VERTICAL:", this.hasAttribute("vertical"), this.getBoundingClientRect(), this);
135
+ console.log("width", width);
136
+ console.log("height", height);
137
+ this.size = this.hasAttribute("vertical") ? height : width;
138
+ }
139
+ /**
140
+ * Converts pixels to a percentage.
141
+ * @param {number} value The pixel value.
142
+ * @returns {number} The percentage value.
143
+ */
144
+ pixelsToPercentage(value) {
145
+ console.log("pixelsToPercentage", value, value / this.size * 100);
146
+ return value / this.size * 100;
147
+ }
148
+ }
149
+ SplitView.define("wje-split-view", SplitView);
150
+ export {
151
+ SplitView as default
152
+ };
153
+ //# sourceMappingURL=wje-split-view.js.map