wj-elements 0.2.0-alpha.9 → 0.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dark.css +15 -1
- package/dist/{form-associated-element-o0UjvdUp.js → form-associated-element-DEQ4y-jn.js} +1 -2
- package/dist/form-associated-element-DEQ4y-jn.js.map +1 -0
- package/dist/{icon-DY5AZ6xM.js → icon-DVyMc4Wv.js} +36 -2
- package/dist/{icon-DY5AZ6xM.js.map → icon-DVyMc4Wv.js.map} +1 -1
- package/dist/light.css +7 -2
- package/dist/localize.js +8 -5
- package/dist/localize.js.map +1 -1
- package/dist/packages/internals/form-associated-element.d.ts +0 -1
- package/dist/packages/utils/utils.d.ts +16 -0
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -0
- package/dist/packages/wje-avatar/avatar.element.d.ts +5 -0
- package/dist/packages/wje-breadcrumb/breadcrumb.element.d.ts +1 -0
- package/dist/packages/wje-button/button.element.d.ts +5 -1
- package/dist/packages/wje-button-group/button-group.element.d.ts +4 -0
- package/dist/packages/wje-card/card.element.d.ts +15 -6
- package/dist/packages/wje-carousel/carousel.element.d.ts +4 -0
- package/dist/packages/wje-checkbox/checkbox.element.d.ts +14 -0
- package/dist/packages/wje-chip/chip.element.d.ts +6 -0
- package/dist/packages/wje-color-picker/color-picker.element.d.ts +43 -1
- package/dist/packages/wje-copy-button/copy-button.element.d.ts +4 -0
- package/dist/packages/wje-dialog/dialog.element.d.ts +2 -0
- package/dist/packages/wje-dropdown/dropdown.element.d.ts +7 -0
- package/dist/packages/wje-element/element.d.ts +55 -24
- package/dist/packages/wje-file-upload/file-upload.element.d.ts +17 -6
- package/dist/packages/wje-file-upload/service/service.d.ts +0 -23
- package/dist/packages/wje-file-upload-item/file-upload-item.element.d.ts +5 -0
- package/dist/packages/wje-format-digital/format-digital.element.d.ts +2 -0
- package/dist/packages/wje-icon/icon.element.d.ts +11 -0
- package/dist/packages/wje-icon-picker/icon-picker.element.d.ts +4 -0
- package/dist/packages/wje-img/img.element.d.ts +1 -0
- package/dist/packages/wje-infinite-scroll/infinite-scroll.element.d.ts +4 -0
- package/dist/packages/wje-input/input.element.d.ts +9 -1
- package/dist/packages/wje-item/item.element.d.ts +8 -0
- package/dist/packages/wje-kanban/kanban.element.d.ts +4 -0
- package/dist/packages/wje-level-indicator/level-indicator.element.d.ts +17 -0
- package/dist/packages/wje-list/list.element.d.ts +4 -0
- package/dist/packages/wje-menu-item/menu-item.element.d.ts +4 -0
- package/dist/packages/wje-option/option.element.d.ts +4 -0
- package/dist/packages/wje-options/options.element.d.ts +4 -0
- package/dist/packages/wje-orgchart/orgchart.element.d.ts +4 -0
- package/dist/packages/wje-progress-bar/progress-bar.element.d.ts +11 -0
- package/dist/packages/wje-qr-code/qr-code.element.d.ts +63 -0
- package/dist/packages/wje-radio/radio.element.d.ts +5 -0
- package/dist/packages/wje-radio-group/radio-group.element.d.ts +16 -1
- package/dist/packages/wje-rate/rate.element.d.ts +4 -0
- package/dist/packages/wje-relative-time/relative-time.element.d.ts +2 -0
- package/dist/packages/wje-reorder/reorder.element.d.ts +4 -0
- package/dist/packages/wje-reorder-handle/reorder-handle.element.d.ts +4 -0
- package/dist/packages/wje-select/select.element.d.ts +7 -0
- package/dist/packages/wje-slider/slider.element.d.ts +5 -0
- package/dist/packages/wje-sliding-container/sliding-container.element.d.ts +4 -0
- package/dist/packages/wje-split-view/split-view.element.d.ts +1 -0
- package/dist/packages/wje-stepper/stepper.element.d.ts +1 -0
- package/dist/packages/wje-tab/tab.element.d.ts +10 -0
- package/dist/packages/wje-tab-group/tab-group.element.d.ts +11 -0
- package/dist/packages/wje-textarea/textarea.element.d.ts +20 -1
- package/dist/packages/wje-thumbnail/thumbnail.element.d.ts +4 -0
- package/dist/packages/wje-timeline/timeline.element.d.ts +4 -0
- package/dist/packages/wje-toggle/toggle.element.d.ts +4 -0
- package/dist/packages/wje-toolbar/toolbar.element.d.ts +4 -0
- package/dist/packages/wje-tooltip/tooltip.element.d.ts +3 -0
- package/dist/packages/wje-tree/tree.element.d.ts +4 -0
- package/dist/packages/wje-tree-item/tree-item.element.d.ts +5 -0
- package/dist/{popup.element-DeajFyOQ.js → popup.element-Cl6QeG8M.js} +2 -2
- package/dist/{popup.element-DeajFyOQ.js.map → popup.element-Cl6QeG8M.js.map} +1 -1
- package/dist/skeleton.css +197 -0
- package/dist/utils.js +18 -1
- package/dist/utils.js.map +1 -1
- package/dist/wje-accordion-item.js +26 -4
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +1 -0
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +1 -0
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-avatar.js +18 -0
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +1 -0
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +13 -1
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +1 -0
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +10 -0
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +29 -5
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card.js +37 -0
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel.js +38 -4
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +48 -3
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +22 -0
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-color-picker.js +143 -29
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-copy-button.js +21 -0
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +35 -2
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-dropdown.js +27 -3
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +87 -242
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +23 -1
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +100 -77
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-format-digital.js +9 -0
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-icon-picker.js +15 -0
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +5 -1
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +16 -1
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +10 -0
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +2 -0
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +59 -4
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +14 -0
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +14 -0
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-level-indicator.js +36 -0
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -0
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-master.js +11 -2
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +1 -0
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +24 -0
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu.js +4 -1
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +14 -1
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +13 -0
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart.js +9 -0
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +18 -9
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +1 -1
- package/dist/wje-progress-bar.js +26 -0
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +159 -17
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +49 -2
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +27 -1
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +23 -1
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +14 -1
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-handle.js +21 -0
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder.js +10 -0
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-select.js +35 -5
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +51 -1
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +18 -0
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +9 -0
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +1 -0
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-stepper.js +24 -1
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-tab-group.js +59 -2
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab.js +30 -0
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +96 -14
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +19 -0
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +4 -0
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +17 -1
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar.js +14 -0
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +31 -7
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +41 -5
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +12 -1
- package/dist/wje-tree.js.map +1 -1
- package/package.json +21 -2
- package/dist/form-associated-element-o0UjvdUp.js.map +0 -1
- package/dist/packages/wje-accordion/accordion.test.d.ts +0 -0
- package/dist/packages/wje-animation/animation.test.d.ts +0 -1
- package/dist/packages/wje-avatar/avatar.test.d.ts +0 -1
- package/dist/packages/wje-badge/badge.test.d.ts +0 -1
- package/dist/packages/wje-breadcrumbs/breadcrumbs.test.d.ts +0 -1
- package/dist/packages/wje-button/button.test.d.ts +0 -1
- package/dist/packages/wje-chip/chip.test.d.ts +0 -1
- package/dist/packages/wje-color-picker/color-picker.test.d.ts +0 -1
- package/dist/packages/wje-file-upload/file-upload.test.d.ts +0 -1
- package/dist/packages/wje-format-digital/format-digital.test.d.ts +0 -1
- package/dist/packages/wje-pagination/pagination.test.d.ts +0 -1
- package/dist/packages/wje-relative-time/relative-time.test.d.ts +0 -1
- package/dist/packages/wje-select/select.test.d.ts +0 -1
- package/dist/packages/wje-tab-group/tab-group.test.d.ts +0 -1
- package/dist/packages/wje-toast/toast.test.d.ts +0 -1
- package/dist/packages/wje-toggle/toggle.test.d.ts +0 -1
- package/dist/packages/wje-tree/tree.test.d.ts +0 -1
- package/dist/packages/wje-tree-item/tree-item.test.d.ts +0 -1
package/dist/wje-slider.js
CHANGED
|
@@ -16,7 +16,9 @@ class Slider extends WJElement {
|
|
|
16
16
|
* Sets the handle position of the slider.
|
|
17
17
|
*/
|
|
18
18
|
__publicField(this, "setHandlePosition", () => {
|
|
19
|
+
if (!this.input) return;
|
|
19
20
|
this.input.style.backgroundSize = this.getPercentage(this.input.min, this.input.max, this.input.value) + "% 100%";
|
|
21
|
+
this.syncAria();
|
|
20
22
|
});
|
|
21
23
|
/**
|
|
22
24
|
* Updates the position and content of a bubble element based on the input value.
|
|
@@ -48,6 +50,10 @@ class Slider extends WJElement {
|
|
|
48
50
|
this.input.value = value;
|
|
49
51
|
this.setHandlePosition();
|
|
50
52
|
}
|
|
53
|
+
if (this.output && this.hasAttribute("bubble")) {
|
|
54
|
+
this.output.innerHTML = value;
|
|
55
|
+
setTimeout(this.setBubble, 0);
|
|
56
|
+
}
|
|
51
57
|
}
|
|
52
58
|
/**
|
|
53
59
|
* Returns the value of the slider.
|
|
@@ -112,13 +118,42 @@ class Slider extends WJElement {
|
|
|
112
118
|
* @returns {Array<string>}
|
|
113
119
|
*/
|
|
114
120
|
static get observedAttributes() {
|
|
115
|
-
return ["max"];
|
|
121
|
+
return ["max", "min", "step", "value", "disabled", "bubble"];
|
|
122
|
+
}
|
|
123
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
124
|
+
var _a, _b, _c;
|
|
125
|
+
if (oldValue === newValue) return;
|
|
126
|
+
if (["max", "min", "step", "value", "disabled", "bubble"].includes(name)) {
|
|
127
|
+
if (this.input) {
|
|
128
|
+
if (name === "min") this.input.min = this.min;
|
|
129
|
+
if (name === "max") this.input.max = this.max;
|
|
130
|
+
if (name === "step") this.input.step = this.step;
|
|
131
|
+
if (name === "value") this.input.value = this.value;
|
|
132
|
+
if (name === "disabled") this.input.disabled = this.hasAttribute("disabled");
|
|
133
|
+
}
|
|
134
|
+
if (name === "bubble" && this.output) {
|
|
135
|
+
if (this.hasAttribute("bubble")) {
|
|
136
|
+
this.output.removeAttribute("hidden");
|
|
137
|
+
this.output.innerHTML = ((_a = this.input) == null ? void 0 : _a.value) ?? this.value;
|
|
138
|
+
setTimeout(this.setBubble, 0);
|
|
139
|
+
} else {
|
|
140
|
+
this.output.setAttribute("hidden", "");
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (["min", "max", "value", "disabled"].includes(name) && this.input) {
|
|
144
|
+
(_b = this.setHandlePosition) == null ? void 0 : _b.call(this);
|
|
145
|
+
this.syncAria();
|
|
146
|
+
}
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
(_c = super.attributeChangedCallback) == null ? void 0 : _c.call(this, name, oldValue, newValue);
|
|
116
150
|
}
|
|
117
151
|
/**
|
|
118
152
|
* Sets up the attributes for the component.
|
|
119
153
|
*/
|
|
120
154
|
setupAttributes() {
|
|
121
155
|
this.isShadowRoot = "open";
|
|
156
|
+
this.syncAria();
|
|
122
157
|
}
|
|
123
158
|
/**
|
|
124
159
|
* Draws the component for the slider.
|
|
@@ -152,6 +187,7 @@ class Slider extends WJElement {
|
|
|
152
187
|
input.part = "slider";
|
|
153
188
|
input.setAttribute("autocomplete", "off");
|
|
154
189
|
input.setAttribute("color", this.color || "");
|
|
190
|
+
if (this.hasAttribute("disabled")) input.disabled = true;
|
|
155
191
|
input.addEventListener("input", null, (e) => {
|
|
156
192
|
this.setHandlePosition(e.target);
|
|
157
193
|
});
|
|
@@ -166,6 +202,7 @@ class Slider extends WJElement {
|
|
|
166
202
|
fragment.appendChild(element);
|
|
167
203
|
this.input = input;
|
|
168
204
|
this.output = output;
|
|
205
|
+
this.syncAria();
|
|
169
206
|
return fragment;
|
|
170
207
|
}
|
|
171
208
|
/**
|
|
@@ -203,6 +240,19 @@ class Slider extends WJElement {
|
|
|
203
240
|
output: this.output
|
|
204
241
|
});
|
|
205
242
|
});
|
|
243
|
+
this.syncAria();
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Syncs ARIA attributes on the host element.
|
|
247
|
+
*/
|
|
248
|
+
syncAria() {
|
|
249
|
+
this.setAriaState({
|
|
250
|
+
role: "slider",
|
|
251
|
+
valuemin: this.min,
|
|
252
|
+
valuemax: this.max,
|
|
253
|
+
valuenow: this.value,
|
|
254
|
+
disabled: this.hasAttribute("disabled")
|
|
255
|
+
});
|
|
206
256
|
}
|
|
207
257
|
/**
|
|
208
258
|
* Calculates the percentage of a value within a given range.
|
package/dist/wje-slider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-slider.js","sources":["../packages/wje-slider/slider.element.js","../packages/wje-slider/slider.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * Represents a slider component that extends the WJElement class.\n * This slider supports features such as min, max, step values, bubble display, and event handling.\n * It offers both getter and setter methods for its attributes and dynamically handles rendering and updates.\n */\n\nexport default class Slider extends WJElement {\n /**\n * Creates an instance of Slider.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the slider.\n * @param {number} value The value to set.\n */\n set value(value) {\n this.setAttribute('value', value);\n\n if (this.input) {\n this.input.value = value;\n this.setHandlePosition();\n }\n }\n\n /**\n * Returns the value of the slider.\n * @returns {number} The value of the slider input.\n */\n get value() {\n return this.getAttribute('value') || 0;\n }\n\n /**\n * Sets the minimum value of the slider.\n * @param {number} value The minimum value to set.\n */\n set min(value) {\n this.setAttribute('min', value);\n }\n\n /**\n * Returns the minimum value of the slider.\n * @returns {number} The minimum value of the slider.\n */\n get min() {\n return this.getAttribute('min') || 0;\n }\n\n /**\n * Sets the maximum value of the slider.\n * @param {number} value The maximum value to set.\n */\n set max(value) {\n this.setAttribute('max', value);\n }\n\n /**\n * Returns the maximum value of the slider.\n * @returns {number} The maximum value of the slider.\n */\n get max() {\n return this.getAttribute('max') || 100;\n }\n\n /**\n * Sets the step value of the slider.\n * @param {number} value The step value to set.\n */\n set step(value) {\n this.setAttribute('step', value);\n }\n\n /**\n * Returns the step value of the slider.\n * @returns {number} The step value of the slider.\n */\n get step() {\n return this.getAttribute('step') || 1;\n }\n\n className = 'Slider';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['max'];\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 for the slider.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.className = 'native-slider';\n element.setAttribute('part', 'native');\n\n let slider = document.createElement('div');\n slider.className = 'slider';\n\n let label = document.createElement('slot');\n label.name = 'label';\n\n let start = document.createElement('slot');\n start.name = 'start';\n\n let end = document.createElement('slot');\n end.name = 'end';\n\n let output = document.createElement('output');\n output.setAttribute('for', 'slider');\n output.id = 'output';\n output.setAttribute('hidden', '');\n\n let input = document.createElement('input');\n input.type = 'range';\n input.min = this.min;\n input.max = this.max;\n input.step = this.step;\n input.value = this.value;\n input.id = 'slider';\n input.name = 'slider';\n input.part = 'slider';\n input.setAttribute('autocomplete', 'off');\n input.setAttribute('color', this.color || '');\n\n input.addEventListener('input', null, (e) => {\n this.setHandlePosition(e.target);\n });\n\n slider.appendChild(input);\n if (this.hasAttribute('bubble')) {\n slider.appendChild(output);\n }\n element.appendChild(label);\n element.appendChild(start);\n element.appendChild(slider);\n element.appendChild(end);\n\n fragment.appendChild(element);\n\n this.input = input;\n this.output = output;\n\n return fragment;\n }\n\n /**\n * Handles the post-rendering logic for a custom slider component. This method performs the following tasks:\n * - Sets the position of the handle.\n * - Displays a bubble indicator with the current value, if the slider has a \"bubble\" attribute.\n * - Dispatches initialization, movement, and change custom events for the slider input element.\n * - Updates the bubble position and value dynamically on input changes.\n * @returns {void} This method does not return a value.\n */\n afterDraw() {\n this.setHandlePosition();\n\n if (this.hasAttribute('bubble')) {\n this.output.innerHTML = this.input.value;\n this.output.removeAttribute('hidden');\n\n setTimeout(this.setBubble, 50);\n }\n\n event.dispatchCustomEvent(this.input, 'wje-slider:init', {\n value: this.input.value,\n output: this.output,\n });\n\n event.addListener(this.input, 'input', null, (e) => {\n this.value = e.target.value;\n\n event.dispatchCustomEvent(this.input, 'wje-slider:move', {\n value: e.target.value,\n output: this.output,\n });\n\n if (this.hasAttribute('bubble')) {\n this.setBubble();\n }\n });\n\n event.addListener(this.input, 'change', null, (e) => {\n event.dispatchCustomEvent(this.input, 'wje-slider:change', {\n value: e.target.value,\n output: this.output,\n });\n });\n }\n\n /**\n * Sets the handle position of the slider.\n */\n setHandlePosition = () => {\n this.input.style.backgroundSize =\n this.getPercentage(this.input.min, this.input.max, this.input.value) + '% 100%';\n };\n\n /**\n * Updates the position and content of a bubble element based on the input value.\n *\n * This function calculates the position of the bubble using the percentage representation\n * of the input's current value relative to its minimum and maximum bounds. It then adjusts\n * the bubble's left position dynamically for aesthetic purposes and updates its displayed\n * content to reflect the current input value.\n *\n * The function relies on the following elements:\n * - `this.input`: Represents the input element with properties `min`, `max`, and `value`.\n * - `this.output`: Represents the bubble element to be positioned and updated.\n *\n * The left positioning of the bubble ensures precise alignment with the input value indicator.\n */\n setBubble = () => {\n let newValue = this.getPercentage(this.input.min, this.input.max, this.input.value);\n this.output.style.left = `calc(${newValue}% + (${8 - newValue * 0.15}px) - ${this.output.offsetWidth / 2}px)`;\n this.output.innerHTML = this.input.value;\n };\n\n /**\n * Calculates the percentage of a value within a given range.\n * @param {number} min The minimum value of the range.\n * @param {number} max The maximum value of the range.\n * @param {number} [value] The current value within the range. Defaults to 0 if not provided.\n * @returns {number} The calculated percentage as a number between 0 and 100. Returns 0 if the range is invalid.\n */\n getPercentage(min, max, value = 0) {\n return Number(((value - min) * 100) / (max - min)) || 0;\n }\n}\n","import Slider from './slider.element.js';\n\nexport default Slider;\n\nSlider.define('wje-slider', Slider);\n"],"names":[],"mappings":";;;;;;AASe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAO;AAwEX,qCAAY;AAuIZ;AAAA;AAAA;AAAA,6CAAoB,MAAM;AACtB,WAAK,MAAM,MAAM,iBACb,KAAK,cAAc,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,IAAI;AAAA,IAC9E;AAgBD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAY,MAAM;AACd,UAAI,WAAW,KAAK,cAAc,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK;AAClF,WAAK,OAAO,MAAM,OAAO,QAAQ,QAAQ,QAAQ,IAAI,WAAW,IAAI,SAAS,KAAK,OAAO,cAAc,CAAC;AACxG,WAAK,OAAO,YAAY,KAAK,MAAM;AAAA,IACtC;AAAA,EArOL;AAAA;AAAA;AAA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E;AAAA,IACzC;AAEQ,UAAM,oBAAoB,KAAK,OAAO,mBAAmB;AAAA,MACrD,OAAO,KAAK,MAAM;AAAA,MAClB,QAAQ,KAAK;AAAA,IACzB,CAAS;AAED,UAAM,YAAY,KAAK,OAAO,SAAS,MAAM,CAAC,MAAM;AAChD,WAAK,QAAQ,EAAE,OAAO;AAEtB,YAAM,oBAAoB,KAAK,OAAO,mBAAmB;AAAA,QACrD,OAAO,EAAE,OAAO;AAAA,QAChB,QAAQ,KAAK;AAAA,MAC7B,CAAa;AAED,UAAI,KAAK,aAAa,QAAQ,GAAG;AAC7B,aAAK,UAAW;AAAA,MAChC;AAAA,IACA,CAAS;AAED,UAAM,YAAY,KAAK,OAAO,UAAU,MAAM,CAAC,MAAM;AACjD,YAAM,oBAAoB,KAAK,OAAO,qBAAqB;AAAA,QACvD,OAAO,EAAE,OAAO;AAAA,QAChB,QAAQ,KAAK;AAAA,MAC7B,CAAa;AAAA,IACb,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqCI,cAAc,KAAK,KAAK,QAAQ,GAAG;AAC/B,WAAO,QAAS,QAAQ,OAAO,OAAQ,MAAM,IAAI,KAAK;AAAA,EAC9D;AACA;AC7PA,OAAO,OAAO,cAAc,MAAM;"}
|
|
1
|
+
{"version":3,"file":"wje-slider.js","sources":["../packages/wje-slider/slider.element.js","../packages/wje-slider/slider.js"],"sourcesContent":["import { default as WJElement, event } from '../wje-element/element.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * Represents a slider component that extends the WJElement class.\n * This slider supports features such as min, max, step values, bubble display, and event handling.\n * It offers both getter and setter methods for its attributes and dynamically handles rendering and updates.\n */\n\nexport default class Slider extends WJElement {\n /**\n * Creates an instance of Slider.\n * @class\n */\n constructor() {\n super();\n }\n\n /**\n * Sets the value of the slider.\n * @param {number} value The value to set.\n */\n set value(value) {\n this.setAttribute('value', value);\n\n if (this.input) {\n this.input.value = value;\n this.setHandlePosition();\n }\n if (this.output && this.hasAttribute('bubble')) {\n this.output.innerHTML = value;\n setTimeout(this.setBubble, 0);\n }\n }\n\n /**\n * Returns the value of the slider.\n * @returns {number} The value of the slider input.\n */\n get value() {\n return this.getAttribute('value') || 0;\n }\n\n /**\n * Sets the minimum value of the slider.\n * @param {number} value The minimum value to set.\n */\n set min(value) {\n this.setAttribute('min', value);\n }\n\n /**\n * Returns the minimum value of the slider.\n * @returns {number} The minimum value of the slider.\n */\n get min() {\n return this.getAttribute('min') || 0;\n }\n\n /**\n * Sets the maximum value of the slider.\n * @param {number} value The maximum value to set.\n */\n set max(value) {\n this.setAttribute('max', value);\n }\n\n /**\n * Returns the maximum value of the slider.\n * @returns {number} The maximum value of the slider.\n */\n get max() {\n return this.getAttribute('max') || 100;\n }\n\n /**\n * Sets the step value of the slider.\n * @param {number} value The step value to set.\n */\n set step(value) {\n this.setAttribute('step', value);\n }\n\n /**\n * Returns the step value of the slider.\n * @returns {number} The step value of the slider.\n */\n get step() {\n return this.getAttribute('step') || 1;\n }\n\n className = 'Slider';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return ['max', 'min', 'step', 'value', 'disabled', 'bubble'];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue === newValue) return;\n\n // Avoid full re-render for slider updates; update DOM in place.\n if (['max', 'min', 'step', 'value', 'disabled', 'bubble'].includes(name)) {\n if (this.input) {\n if (name === 'min') this.input.min = this.min;\n if (name === 'max') this.input.max = this.max;\n if (name === 'step') this.input.step = this.step;\n if (name === 'value') this.input.value = this.value;\n if (name === 'disabled') this.input.disabled = this.hasAttribute('disabled');\n }\n\n if (name === 'bubble' && this.output) {\n if (this.hasAttribute('bubble')) {\n this.output.removeAttribute('hidden');\n this.output.innerHTML = this.input?.value ?? this.value;\n setTimeout(this.setBubble, 0);\n } else {\n this.output.setAttribute('hidden', '');\n }\n }\n\n if (['min', 'max', 'value', 'disabled'].includes(name) && this.input) {\n this.setHandlePosition?.();\n this.syncAria();\n }\n\n return;\n }\n\n super.attributeChangedCallback?.(name, oldValue, newValue);\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n this.syncAria();\n }\n\n /**\n * Draws the component for the slider.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let element = document.createElement('div');\n element.className = 'native-slider';\n element.setAttribute('part', 'native');\n\n let slider = document.createElement('div');\n slider.className = 'slider';\n\n let label = document.createElement('slot');\n label.name = 'label';\n\n let start = document.createElement('slot');\n start.name = 'start';\n\n let end = document.createElement('slot');\n end.name = 'end';\n\n let output = document.createElement('output');\n output.setAttribute('for', 'slider');\n output.id = 'output';\n output.setAttribute('hidden', '');\n\n let input = document.createElement('input');\n input.type = 'range';\n input.min = this.min;\n input.max = this.max;\n input.step = this.step;\n input.value = this.value;\n input.id = 'slider';\n input.name = 'slider';\n input.part = 'slider';\n input.setAttribute('autocomplete', 'off');\n input.setAttribute('color', this.color || '');\n if (this.hasAttribute('disabled')) input.disabled = true;\n\n input.addEventListener('input', null, (e) => {\n this.setHandlePosition(e.target);\n });\n\n slider.appendChild(input);\n if (this.hasAttribute('bubble')) {\n slider.appendChild(output);\n }\n element.appendChild(label);\n element.appendChild(start);\n element.appendChild(slider);\n element.appendChild(end);\n\n fragment.appendChild(element);\n\n this.input = input;\n this.output = output;\n\n this.syncAria();\n return fragment;\n }\n\n /**\n * Handles the post-rendering logic for a custom slider component. This method performs the following tasks:\n * - Sets the position of the handle.\n * - Displays a bubble indicator with the current value, if the slider has a \"bubble\" attribute.\n * - Dispatches initialization, movement, and change custom events for the slider input element.\n * - Updates the bubble position and value dynamically on input changes.\n * @returns {void} This method does not return a value.\n */\n afterDraw() {\n this.setHandlePosition();\n\n if (this.hasAttribute('bubble')) {\n this.output.innerHTML = this.input.value;\n this.output.removeAttribute('hidden');\n\n setTimeout(this.setBubble, 50);\n }\n\n event.dispatchCustomEvent(this.input, 'wje-slider:init', {\n value: this.input.value,\n output: this.output,\n });\n\n event.addListener(this.input, 'input', null, (e) => {\n this.value = e.target.value;\n\n event.dispatchCustomEvent(this.input, 'wje-slider:move', {\n value: e.target.value,\n output: this.output,\n });\n\n if (this.hasAttribute('bubble')) {\n this.setBubble();\n }\n });\n\n event.addListener(this.input, 'change', null, (e) => {\n event.dispatchCustomEvent(this.input, 'wje-slider:change', {\n value: e.target.value,\n output: this.output,\n });\n });\n\n this.syncAria();\n }\n\n /**\n * Sets the handle position of the slider.\n */\n setHandlePosition = () => {\n if (!this.input) return;\n this.input.style.backgroundSize =\n this.getPercentage(this.input.min, this.input.max, this.input.value) + '% 100%';\n this.syncAria();\n };\n\n /**\n * Syncs ARIA attributes on the host element.\n */\n syncAria() {\n this.setAriaState({\n role: 'slider',\n valuemin: this.min,\n valuemax: this.max,\n valuenow: this.value,\n disabled: this.hasAttribute('disabled'),\n });\n }\n\n /**\n * Updates the position and content of a bubble element based on the input value.\n *\n * This function calculates the position of the bubble using the percentage representation\n * of the input's current value relative to its minimum and maximum bounds. It then adjusts\n * the bubble's left position dynamically for aesthetic purposes and updates its displayed\n * content to reflect the current input value.\n *\n * The function relies on the following elements:\n * - `this.input`: Represents the input element with properties `min`, `max`, and `value`.\n * - `this.output`: Represents the bubble element to be positioned and updated.\n *\n * The left positioning of the bubble ensures precise alignment with the input value indicator.\n */\n setBubble = () => {\n let newValue = this.getPercentage(this.input.min, this.input.max, this.input.value);\n this.output.style.left = `calc(${newValue}% + (${8 - newValue * 0.15}px) - ${this.output.offsetWidth / 2}px)`;\n this.output.innerHTML = this.input.value;\n };\n\n /**\n * Calculates the percentage of a value within a given range.\n * @param {number} min The minimum value of the range.\n * @param {number} max The maximum value of the range.\n * @param {number} [value] The current value within the range. Defaults to 0 if not provided.\n * @returns {number} The calculated percentage as a number between 0 and 100. Returns 0 if the range is invalid.\n */\n getPercentage(min, max, value = 0) {\n return Number(((value - min) * 100) / (max - min)) || 0;\n }\n}\n","import Slider from './slider.element.js';\n\nexport default Slider;\n\nSlider.define('wje-slider', Slider);\n"],"names":[],"mappings":";;;;;;AASe,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK1C,cAAc;AACV,UAAO;AA4EX,qCAAY;AA8KZ;AAAA;AAAA;AAAA,6CAAoB,MAAM;AACtB,UAAI,CAAC,KAAK,MAAO;AACjB,WAAK,MAAM,MAAM,iBACb,KAAK,cAAc,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,IAAI;AAC3E,WAAK,SAAU;AAAA,IAClB;AA6BD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qCAAY,MAAM;AACd,UAAI,WAAW,KAAK,cAAc,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KAAK;AAClF,WAAK,OAAO,MAAM,OAAO,QAAQ,QAAQ,QAAQ,IAAI,WAAW,IAAI,SAAS,KAAK,OAAO,cAAc,CAAC;AACxG,WAAK,OAAO,YAAY,KAAK,MAAM;AAAA,IACtC;AAAA,EA/RL;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,MAAM,OAAO;AACb,SAAK,aAAa,SAAS,KAAK;AAEhC,QAAI,KAAK,OAAO;AACZ,WAAK,MAAM,QAAQ;AACnB,WAAK,kBAAmB;AAAA,IACpC;AACQ,QAAI,KAAK,UAAU,KAAK,aAAa,QAAQ,GAAG;AAC5C,WAAK,OAAO,YAAY;AACxB,iBAAW,KAAK,WAAW,CAAC;AAAA,IACxC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,QAAQ;AACR,WAAO,KAAK,aAAa,OAAO,KAAK;AAAA,EAC7C;AAAA;AAAA;AAAA;AA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M,oBAAoB,KAAK,OAAO,qBAAqB;AAAA,QACvD,OAAO,EAAE,OAAO;AAAA,QAChB,QAAQ,KAAK;AAAA,MAC7B,CAAa;AAAA,IACb,CAAS;AAED,SAAK,SAAU;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAeI,WAAW;AACP,SAAK,aAAa;AAAA,MACd,MAAM;AAAA,MACN,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf,UAAU,KAAK;AAAA,MACf,UAAU,KAAK,aAAa,UAAU;AAAA,IAClD,CAAS;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BI,cAAc,KAAK,KAAK,QAAQ,GAAG;AAC/B,WAAO,QAAS,QAAQ,OAAO,OAAQ,MAAM,IAAI,KAAK;AAAA,EAC9D;AACA;ACvTA,OAAO,OAAO,cAAc,MAAM;"}
|
|
@@ -235,6 +235,7 @@ class SlidingContainer extends WJElement {
|
|
|
235
235
|
*/
|
|
236
236
|
setupAttributes() {
|
|
237
237
|
this.isShadowRoot = "open";
|
|
238
|
+
this.syncAria();
|
|
238
239
|
}
|
|
239
240
|
/**
|
|
240
241
|
* Executes before drawing the element.
|
|
@@ -301,12 +302,27 @@ class SlidingContainer extends WJElement {
|
|
|
301
302
|
* Calls the checkForVariant method with the current variant.
|
|
302
303
|
*/
|
|
303
304
|
afterDraw() {
|
|
305
|
+
this.syncAria();
|
|
304
306
|
document.addEventListener(this.trigger, this.triggerEvent);
|
|
305
307
|
if (this.screenBreakPoint && window.innerWidth <= this.screenBreakPoint) {
|
|
306
308
|
this.variant = "over";
|
|
307
309
|
}
|
|
308
310
|
this.checkForVariant(this.variant);
|
|
309
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Sync ARIA attributes on host.
|
|
314
|
+
*/
|
|
315
|
+
syncAria() {
|
|
316
|
+
if (!this.hasAttribute("role")) {
|
|
317
|
+
this.setAriaState({ role: "region" });
|
|
318
|
+
}
|
|
319
|
+
this.setAriaState({ hidden: !this.isOpen });
|
|
320
|
+
const ariaLabel = this.getAttribute("aria-label");
|
|
321
|
+
const label = this.getAttribute("label");
|
|
322
|
+
if (!ariaLabel && label) {
|
|
323
|
+
this.setAriaState({ label });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
310
326
|
/**
|
|
311
327
|
* Creates and returns a styled close button element with an icon,
|
|
312
328
|
* including an event listener to trigger the close method.
|
|
@@ -503,6 +519,7 @@ class SlidingContainer extends WJElement {
|
|
|
503
519
|
event.dispatchCustomEvent(this, "wje-sliding-container:beforeOpen");
|
|
504
520
|
this.checkForVariant(this.variant);
|
|
505
521
|
await this.doAnimateTransition();
|
|
522
|
+
this.syncAria();
|
|
506
523
|
await Promise.resolve(this.afterOpen(e)).then(() => {
|
|
507
524
|
event.dispatchCustomEvent(this, "wje-sliding-container:open");
|
|
508
525
|
});
|
|
@@ -520,6 +537,7 @@ class SlidingContainer extends WJElement {
|
|
|
520
537
|
this.classList.remove("open");
|
|
521
538
|
event.dispatchCustomEvent(this, "wje-sliding-container:beforeClose");
|
|
522
539
|
await this.doAnimateTransition();
|
|
540
|
+
this.syncAria();
|
|
523
541
|
await Promise.resolve(this.afterClose(e)).then(() => {
|
|
524
542
|
if (this.removeChildAfterClose) {
|
|
525
543
|
this.childNodes.forEach((child) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-sliding-container.js","sources":["../packages/wje-sliding-container/sliding-container.element.js","../packages/wje-sliding-container/sliding-container.js"],"sourcesContent":["import { default as WJElement, event } from '../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 - Specifies the sliding direction of the container (e.g., 'left' or 'right').\n * @property {string} variant - Determines how the SlidingContainer behaves, such as 'over' or 'in-place'.\n * @property {string} screenBreakPoint - The width (in pixels) at which the SlidingContainer switches to the \"over\" variant for smaller screens.\n * @property {boolean} removeChildAfterClose - Removes the child after the SlidingContainer is closed.\n * @property {string} animationDuration - Specifies the duration (in milliseconds) of the sliding animation.\n * @property {string} animationEasing - Specifies the easing function used for the sliding animation (e.g., 'linear', 'ease-in', 'ease-out').\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 /**\n * Sets the maximum width of an element by updating the 'max-width' attribute.\n * @param {string} value The maximum width value to be set (e.g., '100px', '50%', etc.).\n */\n set maxWidth(value) {\n this.setAttribute('max-width', value);\n }\n\n /**\n * Gets the maximum width value of the element.\n * Retrieves the value of the 'max-width' attribute. If the attribute is not set, it defaults to 'auto'.\n * @returns {string} The maximum width value of the element or 'auto' if the attribute is not defined.\n */\n get maxWidth() {\n return this.getAttribute('max-width') ?? 'auto';\n }\n\n /**\n * Sets the maximum height for the element.\n * @param {string} value The maximum height value to be applied to the element. This can include units such as \"px\", \"em\", \"%\", etc.\n */\n set maxHeight(value) {\n this.setAttribute('max-height', value);\n }\n\n /**\n * Retrieves the maximum height value of the element, or returns 'auto' if not set.\n * @returns {string} The maximum height value or 'auto' if the attribute is not specified.\n */\n get maxHeight() {\n return this.getAttribute('max-height') ?? 'auto';\n }\n\n /**\n * Sets the 'trigger' attribute for the element.\n * @param {string} value The value to set for the 'trigger' attribute.\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Retrieves the value of the 'trigger' attribute. If the attribute is not set, it defaults to 'sliding-container'.\n * @returns {string} The value of the 'trigger' attribute or the default value 'sliding-container' if not defined.\n */\n get trigger() {\n return this.getAttribute('trigger') ?? 'sliding-container';\n }\n\n /**\n * Sets the direction attribute for the element.\n * @param {string} value The direction value to be assigned. Possible values are typically 'ltr' (left-to-right), 'rtl' (right-to-left), or 'auto'.\n */\n set direction(value) {\n this.setAttribute('direction', value);\n }\n\n /**\n * Retrieves the direction attribute of the instance.\n * If the direction attribute is not set, it defaults to 'right'.\n * @returns {string} The value of the direction attribute or 'right' if not set.\n */\n get direction() {\n return this.getAttribute('direction') ?? 'right';\n }\n\n /**\n * Sets the value of the `remove-child-after-close` attribute.\n * This attribute determines if a child element should be removed after a close operation.\n * @param {boolean|string} value The value to set for the `remove-child-after-close` attribute. The value can be a boolean or a string representation of a boolean.\n */\n set removeChildAfterClose(value) {\n this.setAttribute('remove-child-after-close', value);\n }\n\n /**\n * Gets the value indicating whether the child element should be removed after closing.\n *\n * This property checks the presence of the 'remove-child-after-close' attribute on the element.\n * Returns `false` if the attribute does not exist.\n * @returns {boolean} True if the 'remove-child-after-close' attribute is present, otherwise false.\n */\n get removeChildAfterClose() {\n return this.hasAttribute('remove-child-after-close') ?? false;\n }\n\n /**\n * Sets the 'variant' attribute to the specified value.\n * @param {string} value The value to set for the 'variant' attribute.\n */\n set variant(value) {\n this.setAttribute('variant', value);\n }\n\n /**\n * Retrieves the value of the \"variant\" attribute. If the attribute is not set,\n * it returns the default value 'in-place'.\n * @returns {string} The variant value or the default value 'in-place'.\n */\n get variant() {\n return this.getAttribute('variant') ?? 'in-place';\n }\n\n /**\n * Retrieves the value of the 'screen-break-point' attribute.\n * @returns {string} The value of the 'screen-break-point' attribute.\n */\n get screenBreakPoint() {\n return this.getAttribute('screen-break-point');\n }\n\n /**\n * Sets the screen break point value to determine responsive behavior.\n * @param {string} value The value to set as the screen break point.\n */\n set screenBreakPoint(value) {\n this.setAttribute('screen-break-point', value);\n }\n\n /**\n * Sets the duration of the animation by updating the `animation-duration` attribute.\n * @param {string} value The duration value for the animation, specified in a format\n * such as seconds (e.g., \"2s\") or milliseconds (e.g., \"200ms\").\n */\n set animationDuration(value) {\n this.setAttribute('animation-duration', value);\n }\n\n /**\n * Gets the animation duration for an element.\n * It retrieves the value of the 'animation-duration' attribute if present; otherwise, it defaults to '500'.\n * @returns {string} The value of the animation duration, either from the attribute or the default '500'.\n */\n get animationDuration() {\n return this.getAttribute('animation-duration') ?? '500';\n }\n\n /**\n * Sets the easing function for the animation.\n * @param {string} value The easing function to use for the animation. This can be any valid CSS timing function such as \"ease\", \"linear\", \"ease-in\", \"ease-out\", etc.\n */\n set animationEasing(value) {\n this.setAttribute('animation-easing', value);\n }\n\n /**\n * Retrieves the easing function for the animation.\n * @returns {string} The value of the 'animation-easing' attribute if set, otherwise defaults to 'linear'.\n */\n get animationEasing() {\n return this.getAttribute('animation-easing') ?? 'linear';\n }\n\n /**\n * Determines if the element has an 'has-opacity' attribute.\n * @returns {boolean} True if the element has the 'has-opacity' attribute, otherwise false.\n */\n get hasOpacity() {\n return this.hasAttribute('has-opacity') ?? false;\n }\n\n /**\n * Sets the value of the 'add-to-height' attribute.\n * This attribute is used to modify or adjust the height dynamically.\n * @param {string} value The value to be assigned to the 'add-to-height' attribute.\n */\n set addToHeight(value) {\n this.setAttribute('add-to-height', value);\n }\n\n /**\n * Retrieves the value of the 'add-to-height' attribute from the element.\n * If the attribute is not set, it defaults to '0'.\n * @returns {string} The value of the 'add-to-height' attribute or '0' if the attribute is not present.\n */\n get addToHeight() {\n return this.getAttribute('add-to-height') ?? '0';\n }\n\n /**\n * Determines whether the current state is open.\n * @returns {boolean} True if the state is open, otherwise false.\n */\n get isOpen() {\n return this._isOpen;\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 ['max-width', 'max-height', 'trigger', 'direction', 'variant', 'screen-break-point', 'remove-child-after-close', 'animation-duration', 'animation-easing', 'has-opacity'];\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 * Executes before drawing the element.\n */\n beforeDraw() {\n this.animation?.cancel();\n this.nativeAnimation?.cancel();\n\n document.removeEventListener(this.trigger, this.triggerEvent);\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 let wrapperDiv = document.createElement('div');\n wrapperDiv.classList.add('sliding-container-wrapper');\n\n let transparentDiv = document.createElement('div');\n transparentDiv.classList.add('sliding-container-transparent');\n\n if (this._isOpen) {\n transparentDiv.style.width = this.maxWidth;\n }\n\n let native = document.createElement('div');\n native.setAttribute('part', 'sliding-container');\n native.classList.add('native-sliding-container');\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 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.width = this.maxWidth;\n\n // APPEND\n nativeInner.append(slot);\n nativeInner.append(this.htmlCloseButton());\n\n native.append(nativeInner);\n\n wrapperDiv.append(transparentDiv);\n wrapperDiv.append(native);\n\n fragment.append(wrapperDiv);\n\n this.transparentDiv = transparentDiv;\n this.wrapperDiv = wrapperDiv\n this.nativeElement = native;\n\n return fragment;\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 */\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 /**\n * Creates and returns a styled close button element with an icon,\n * including an event listener to trigger the close method.\n * @returns {HTMLElement} The close button element configured with styles, an icon, and event listener.\n */\n htmlCloseButton() {\n let closeButton = document.createElement('wje-button');\n closeButton.setAttribute('part', 'close-button');\n closeButton.classList.add('close-button');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('slot', 'icon-only');\n icon.setAttribute('name', 'x');\n\n closeButton.append(icon);\n\n event.addListener(closeButton, 'wje-button:click', null,(e) => {\n this.close();\n });\n\n return closeButton;\n }\n\n /**\n * Retrieves the parent element of the current element.\n * If the parent element is not found, it attempts to find the root host element.\n * @returns {Element|null} The parent element or the root host element if no parent exists. Returns null if neither is found.\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 * Adjusts the position and dimensions of the current element based on the specified variant.\n *\n * The method handles modifications to the element's positioning style, aligns it relative to its parent,\n * and manages alignment to its siblings based on the specified direction.\n * @param {string} variant The variant to determine how the element should be updated. For example, when set to 'over', specific adjustments to the position and size are performed.\n * @returns {void} No value is returned, the method modifies the element's style properties directly.\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(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Callback function called after the element is opened.\n */\n afterOpen(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Executes before closing the element.\n */\n beforeClose(e) {\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(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Animates the transition of elements with specified options, toggling the visibility and/or dimensions\n * of the associated elements based on their current state.\n *\n * This method handles both forward and reverse animations for two elements (`transparentDiv` and `nativeElement`)\n * with optional opacity changes. It ensures smooth transitioning by canceling any previous animations on the provided\n * elements before initiating a new animation sequence.\n * @returns {Promise<void>} A promise that resolves when the transition animation is completed.\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 sliding container by performing necessary preparatory and transitional operations.\n * @param {Event} e The event that triggered the open operation.\n * @returns {Promise<void>} A promise that resolves when the open operation, including animations and subsequent handlers, is complete.\n */\n async open(e) {\n await Promise.resolve(this.beforeOpen(e)).then(async () => {\n if (!this._isOpen) {\n this.classList.add('open');\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:beforeOpen')\n\n this.checkForVariant(this.variant);\n\n await this.doAnimateTransition();\n\n await Promise.resolve(this.afterOpen(e)).then(() => {\n event.dispatchCustomEvent(this, 'wje-sliding-container:open')\n });\n }\n });\n }\n\n /**\n * Closes the sliding container and performs associated operations such as animations and event dispatches.\n * @param {Event} e The event object associated with the close action.\n * @returns {Promise<void>} A promise that resolves when the closing operation, including animations and child element removal, is completed.\n */\n async close(e) {\n await Promise.resolve(this.beforeClose(e)).then(async () => {\n if (this._isOpen) {\n this.classList.remove('open');\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:beforeClose');\n\n await this.doAnimateTransition();\n\n await Promise.resolve(this.afterClose(e)).then(() => {\n if (this.removeChildAfterClose) {\n this.childNodes.forEach((child) => {\n child.remove();\n });\n }\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:afterClose');\n });\n }\n });\n }\n\n /**\n * Toggles the state between open and closed.\n * @param {Event} e The event object triggering the toggle.\n * @returns {Promise<void>} A promise that resolves once the toggle operation (open or close) is complete.\n */\n async toggle(e) {\n if (this._isOpen) {\n await this.close(event);\n } else {\n await this.open(event);\n }\n }\n\n /**\n * Cleans up resources associated with the component by disconnecting\n * the resize observer and setting it to null.\n * @returns {void} Does not return a value.\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,EAKpD,cAAc;AACV,UAAO;AAyNX,qCAAY;AA+MZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAe,OAAO,MAAM;AACxB,UAAI,KAAK,eAAe,KAAK,gBAAgB,EAAE,aAAY,EAAG,CAAC,GAAG;AAE9D,cAAM,KAAK,KAAK,CAAC;AAAA,MAC7B,OAAe;AAEH,cAAM,KAAK,OAAO,CAAC;AAAA,MAC/B;AAEQ,WAAK,cAAc,EAAE,aAAY,EAAG,CAAC;AAAA,IACxC;AAhbG,SAAK,UAAU;AACf,SAAK,cAAc;AAEnB,SAAK,kBAAkB,IAAI,eAAe,CAAC,YAAY;AACnD,eAAS,SAAS,SAAS;AACvB,YAAI,MAAM,gBAAgB;AACtB,cAAI,KAAK,gBAAgB,EAAG;AAE5B,cAAI,KAAK,oBAAoB,OAAO,cAAc,KAAK,kBAAkB;AACrE,gBAAI,KAAK,YAAY,QAAQ;AACzB,mBAAK,UAAU;AAAA,YAC3C,OAA+B;AACH,mBAAK,gBAAgB,KAAK,OAAO;AAAA,YAC7D;AAAA,UACA,OAA2B;AACH,gBAAI,KAAK,YAAY,YAAY;AAC7B,mBAAK,UAAU;AAAA,YAC3C,OAA+B;AACH,mBAAK,gBAAgB,KAAK,OAAO;AAAA,YAC7D;AAAA,UACA;AAAA,QACA;AAAA,MACA;AAAA,IACA,CAAS;AAED,SAAK,gBAAgB,QAAQ,SAAS,eAAe;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,IAAI,SAAS,OAAO;AAChB,SAAK,aAAa,aAAa,KAAK;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,IAAI,WAAW;AACX,WAA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jC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,mBAAmB;;AACf,eAAK,oBAAL,mBAAsB;AACtB,SAAK,kBAAkB;AAAA,EAC/B;AACA;ACnqBA,iBAAiB,OAAO,yBAAyB,gBAAgB;"}
|
|
1
|
+
{"version":3,"file":"wje-sliding-container.js","sources":["../packages/wje-sliding-container/sliding-container.element.js","../packages/wje-sliding-container/sliding-container.js"],"sourcesContent":["import { default as WJElement, event } from '../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 - Specifies the sliding direction of the container (e.g., 'left' or 'right').\n * @property {string} variant - Determines how the SlidingContainer behaves, such as 'over' or 'in-place'.\n * @property {string} screenBreakPoint - The width (in pixels) at which the SlidingContainer switches to the \"over\" variant for smaller screens.\n * @property {boolean} removeChildAfterClose - Removes the child after the SlidingContainer is closed.\n * @property {string} animationDuration - Specifies the duration (in milliseconds) of the sliding animation.\n * @property {string} animationEasing - Specifies the easing function used for the sliding animation (e.g., 'linear', 'ease-in', 'ease-out').\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 /**\n * Sets the maximum width of an element by updating the 'max-width' attribute.\n * @param {string} value The maximum width value to be set (e.g., '100px', '50%', etc.).\n */\n set maxWidth(value) {\n this.setAttribute('max-width', value);\n }\n\n /**\n * Gets the maximum width value of the element.\n * Retrieves the value of the 'max-width' attribute. If the attribute is not set, it defaults to 'auto'.\n * @returns {string} The maximum width value of the element or 'auto' if the attribute is not defined.\n */\n get maxWidth() {\n return this.getAttribute('max-width') ?? 'auto';\n }\n\n /**\n * Sets the maximum height for the element.\n * @param {string} value The maximum height value to be applied to the element. This can include units such as \"px\", \"em\", \"%\", etc.\n */\n set maxHeight(value) {\n this.setAttribute('max-height', value);\n }\n\n /**\n * Retrieves the maximum height value of the element, or returns 'auto' if not set.\n * @returns {string} The maximum height value or 'auto' if the attribute is not specified.\n */\n get maxHeight() {\n return this.getAttribute('max-height') ?? 'auto';\n }\n\n /**\n * Sets the 'trigger' attribute for the element.\n * @param {string} value The value to set for the 'trigger' attribute.\n */\n set trigger(value) {\n this.setAttribute('trigger', value);\n }\n\n /**\n * Retrieves the value of the 'trigger' attribute. If the attribute is not set, it defaults to 'sliding-container'.\n * @returns {string} The value of the 'trigger' attribute or the default value 'sliding-container' if not defined.\n */\n get trigger() {\n return this.getAttribute('trigger') ?? 'sliding-container';\n }\n\n /**\n * Sets the direction attribute for the element.\n * @param {string} value The direction value to be assigned. Possible values are typically 'ltr' (left-to-right), 'rtl' (right-to-left), or 'auto'.\n */\n set direction(value) {\n this.setAttribute('direction', value);\n }\n\n /**\n * Retrieves the direction attribute of the instance.\n * If the direction attribute is not set, it defaults to 'right'.\n * @returns {string} The value of the direction attribute or 'right' if not set.\n */\n get direction() {\n return this.getAttribute('direction') ?? 'right';\n }\n\n /**\n * Sets the value of the `remove-child-after-close` attribute.\n * This attribute determines if a child element should be removed after a close operation.\n * @param {boolean|string} value The value to set for the `remove-child-after-close` attribute. The value can be a boolean or a string representation of a boolean.\n */\n set removeChildAfterClose(value) {\n this.setAttribute('remove-child-after-close', value);\n }\n\n /**\n * Gets the value indicating whether the child element should be removed after closing.\n *\n * This property checks the presence of the 'remove-child-after-close' attribute on the element.\n * Returns `false` if the attribute does not exist.\n * @returns {boolean} True if the 'remove-child-after-close' attribute is present, otherwise false.\n */\n get removeChildAfterClose() {\n return this.hasAttribute('remove-child-after-close') ?? false;\n }\n\n /**\n * Sets the 'variant' attribute to the specified value.\n * @param {string} value The value to set for the 'variant' attribute.\n */\n set variant(value) {\n this.setAttribute('variant', value);\n }\n\n /**\n * Retrieves the value of the \"variant\" attribute. If the attribute is not set,\n * it returns the default value 'in-place'.\n * @returns {string} The variant value or the default value 'in-place'.\n */\n get variant() {\n return this.getAttribute('variant') ?? 'in-place';\n }\n\n /**\n * Retrieves the value of the 'screen-break-point' attribute.\n * @returns {string} The value of the 'screen-break-point' attribute.\n */\n get screenBreakPoint() {\n return this.getAttribute('screen-break-point');\n }\n\n /**\n * Sets the screen break point value to determine responsive behavior.\n * @param {string} value The value to set as the screen break point.\n */\n set screenBreakPoint(value) {\n this.setAttribute('screen-break-point', value);\n }\n\n /**\n * Sets the duration of the animation by updating the `animation-duration` attribute.\n * @param {string} value The duration value for the animation, specified in a format\n * such as seconds (e.g., \"2s\") or milliseconds (e.g., \"200ms\").\n */\n set animationDuration(value) {\n this.setAttribute('animation-duration', value);\n }\n\n /**\n * Gets the animation duration for an element.\n * It retrieves the value of the 'animation-duration' attribute if present; otherwise, it defaults to '500'.\n * @returns {string} The value of the animation duration, either from the attribute or the default '500'.\n */\n get animationDuration() {\n return this.getAttribute('animation-duration') ?? '500';\n }\n\n /**\n * Sets the easing function for the animation.\n * @param {string} value The easing function to use for the animation. This can be any valid CSS timing function such as \"ease\", \"linear\", \"ease-in\", \"ease-out\", etc.\n */\n set animationEasing(value) {\n this.setAttribute('animation-easing', value);\n }\n\n /**\n * Retrieves the easing function for the animation.\n * @returns {string} The value of the 'animation-easing' attribute if set, otherwise defaults to 'linear'.\n */\n get animationEasing() {\n return this.getAttribute('animation-easing') ?? 'linear';\n }\n\n /**\n * Determines if the element has an 'has-opacity' attribute.\n * @returns {boolean} True if the element has the 'has-opacity' attribute, otherwise false.\n */\n get hasOpacity() {\n return this.hasAttribute('has-opacity') ?? false;\n }\n\n /**\n * Sets the value of the 'add-to-height' attribute.\n * This attribute is used to modify or adjust the height dynamically.\n * @param {string} value The value to be assigned to the 'add-to-height' attribute.\n */\n set addToHeight(value) {\n this.setAttribute('add-to-height', value);\n }\n\n /**\n * Retrieves the value of the 'add-to-height' attribute from the element.\n * If the attribute is not set, it defaults to '0'.\n * @returns {string} The value of the 'add-to-height' attribute or '0' if the attribute is not present.\n */\n get addToHeight() {\n return this.getAttribute('add-to-height') ?? '0';\n }\n\n /**\n * Determines whether the current state is open.\n * @returns {boolean} True if the state is open, otherwise false.\n */\n get isOpen() {\n return this._isOpen;\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 ['max-width', 'max-height', 'trigger', 'direction', 'variant', 'screen-break-point', 'remove-child-after-close', 'animation-duration', 'animation-easing', 'has-opacity'];\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 this.syncAria();\n }\n\n /**\n * Executes before drawing the element.\n */\n beforeDraw() {\n this.animation?.cancel();\n this.nativeAnimation?.cancel();\n\n document.removeEventListener(this.trigger, this.triggerEvent);\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 let wrapperDiv = document.createElement('div');\n wrapperDiv.classList.add('sliding-container-wrapper');\n\n let transparentDiv = document.createElement('div');\n transparentDiv.classList.add('sliding-container-transparent');\n\n if (this._isOpen) {\n transparentDiv.style.width = this.maxWidth;\n }\n\n let native = document.createElement('div');\n native.setAttribute('part', 'sliding-container');\n native.classList.add('native-sliding-container');\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 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.width = this.maxWidth;\n\n // APPEND\n nativeInner.append(slot);\n nativeInner.append(this.htmlCloseButton());\n\n native.append(nativeInner);\n\n wrapperDiv.append(transparentDiv);\n wrapperDiv.append(native);\n\n fragment.append(wrapperDiv);\n\n this.transparentDiv = transparentDiv;\n this.wrapperDiv = wrapperDiv\n this.nativeElement = native;\n\n return fragment;\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 */\n afterDraw() {\n this.syncAria();\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 /**\n * Sync ARIA attributes on host.\n */\n syncAria() {\n if (!this.hasAttribute('role')) {\n this.setAriaState({ role: 'region' });\n }\n\n this.setAriaState({ hidden: !this.isOpen });\n\n const ariaLabel = this.getAttribute('aria-label');\n const label = this.getAttribute('label');\n if (!ariaLabel && label) {\n this.setAriaState({ label });\n }\n }\n\n /**\n * Creates and returns a styled close button element with an icon,\n * including an event listener to trigger the close method.\n * @returns {HTMLElement} The close button element configured with styles, an icon, and event listener.\n */\n htmlCloseButton() {\n let closeButton = document.createElement('wje-button');\n closeButton.setAttribute('part', 'close-button');\n closeButton.classList.add('close-button');\n\n let icon = document.createElement('wje-icon');\n icon.setAttribute('slot', 'icon-only');\n icon.setAttribute('name', 'x');\n\n closeButton.append(icon);\n\n event.addListener(closeButton, 'wje-button:click', null,(e) => {\n this.close();\n });\n\n return closeButton;\n }\n\n /**\n * Retrieves the parent element of the current element.\n * If the parent element is not found, it attempts to find the root host element.\n * @returns {Element|null} The parent element or the root host element if no parent exists. Returns null if neither is found.\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 * Adjusts the position and dimensions of the current element based on the specified variant.\n *\n * The method handles modifications to the element's positioning style, aligns it relative to its parent,\n * and manages alignment to its siblings based on the specified direction.\n * @param {string} variant The variant to determine how the element should be updated. For example, when set to 'over', specific adjustments to the position and size are performed.\n * @returns {void} No value is returned, the method modifies the element's style properties directly.\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(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Callback function called after the element is opened.\n */\n afterOpen(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Executes before closing the element.\n */\n beforeClose(e) {\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(e) {\n // Hook for extending behavior before the dialog opens\n }\n\n /**\n * Animates the transition of elements with specified options, toggling the visibility and/or dimensions\n * of the associated elements based on their current state.\n *\n * This method handles both forward and reverse animations for two elements (`transparentDiv` and `nativeElement`)\n * with optional opacity changes. It ensures smooth transitioning by canceling any previous animations on the provided\n * elements before initiating a new animation sequence.\n * @returns {Promise<void>} A promise that resolves when the transition animation is completed.\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 sliding container by performing necessary preparatory and transitional operations.\n * @param {Event} e The event that triggered the open operation.\n * @returns {Promise<void>} A promise that resolves when the open operation, including animations and subsequent handlers, is complete.\n */\n async open(e) {\n await Promise.resolve(this.beforeOpen(e)).then(async () => {\n if (!this._isOpen) {\n this.classList.add('open');\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:beforeOpen')\n\n this.checkForVariant(this.variant);\n\n await this.doAnimateTransition();\n this.syncAria();\n\n await Promise.resolve(this.afterOpen(e)).then(() => {\n event.dispatchCustomEvent(this, 'wje-sliding-container:open')\n });\n }\n });\n }\n\n /**\n * Closes the sliding container and performs associated operations such as animations and event dispatches.\n * @param {Event} e The event object associated with the close action.\n * @returns {Promise<void>} A promise that resolves when the closing operation, including animations and child element removal, is completed.\n */\n async close(e) {\n await Promise.resolve(this.beforeClose(e)).then(async () => {\n if (this._isOpen) {\n this.classList.remove('open');\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:beforeClose');\n\n await this.doAnimateTransition();\n this.syncAria();\n\n await Promise.resolve(this.afterClose(e)).then(() => {\n if (this.removeChildAfterClose) {\n this.childNodes.forEach((child) => {\n child.remove();\n });\n }\n\n event.dispatchCustomEvent(this, 'wje-sliding-container:afterClose');\n });\n }\n });\n }\n\n /**\n * Toggles the state between open and closed.\n * @param {Event} e The event object triggering the toggle.\n * @returns {Promise<void>} A promise that resolves once the toggle operation (open or close) is complete.\n */\n async toggle(e) {\n if (this._isOpen) {\n await this.close(event);\n } else {\n await this.open(event);\n }\n }\n\n /**\n * Cleans up resources associated with the component by disconnecting\n * the resize observer and setting it to null.\n * @returns {void} Does not return a value.\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,EAKpD,cAAc;AACV,UAAO;AAyNX,qCAAY;AAkOZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wCAAe,OAAO,MAAM;AACxB,UAAI,KAAK,eAAe,KAAK,gBAAgB,EAAE,aAAY,EAAG,CAAC,GAAG;AAE9D,cAAM,KAAK,KAAK,CAAC;AAAA,MAC7B,OAAe;AAEH,cAAM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IACjC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,mBAAmB;;AACf,eAAK,oBAAL,mBAAsB;AACtB,SAAK,kBAAkB;AAAA,EAC/B;AACA;ACxrBA,iBAAiB,OAAO,yBAAyB,gBAAgB;"}
|
package/dist/wje-split-view.js
CHANGED
|
@@ -49,6 +49,9 @@ class SplitView extends WJElement {
|
|
|
49
49
|
let sizeB = 100 - this.pixelsToPercentage(newPositionInPixels);
|
|
50
50
|
this.style.setProperty("--wje-split-view-calc-a", sizeA + "%");
|
|
51
51
|
this.style.setProperty("--wje-split-view-calc-b", sizeB + "%");
|
|
52
|
+
if (this.dividerElement) {
|
|
53
|
+
this.dividerElement.setAttribute("aria-valuenow", `${Math.round(sizeA)}`);
|
|
54
|
+
}
|
|
52
55
|
},
|
|
53
56
|
initialEvent: e
|
|
54
57
|
});
|
|
@@ -99,12 +102,18 @@ class SplitView extends WJElement {
|
|
|
99
102
|
let dividerElement = document.createElement("div");
|
|
100
103
|
dividerElement.classList.add("wje-divider");
|
|
101
104
|
dividerElement.setAttribute("part", "divider");
|
|
105
|
+
dividerElement.setAttribute("role", "separator");
|
|
106
|
+
dividerElement.setAttribute("aria-orientation", this.hasAttribute("vertical") ? "vertical" : "horizontal");
|
|
107
|
+
dividerElement.setAttribute("aria-valuemin", "0");
|
|
108
|
+
dividerElement.setAttribute("aria-valuemax", "100");
|
|
109
|
+
dividerElement.setAttribute("aria-valuenow", `${this.initial}`);
|
|
102
110
|
dividerElement.appendChild(divider);
|
|
103
111
|
dividerElement.addEventListener("mousedown", this.handleDrag, false);
|
|
104
112
|
native.appendChild(start);
|
|
105
113
|
native.appendChild(dividerElement);
|
|
106
114
|
native.appendChild(end);
|
|
107
115
|
fragment.appendChild(native);
|
|
116
|
+
this.dividerElement = dividerElement;
|
|
108
117
|
return fragment;
|
|
109
118
|
}
|
|
110
119
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-split-view.js","sources":["../packages/wje-split-view/service/service.js","../packages/wje-split-view/split-view.element.js","../packages/wje-split-view/split-view.js"],"sourcesContent":["export function drag(container, options) {\n function move(pointerEvent) {\n const dims = container.getBoundingClientRect();\n const defaultView = container.ownerDocument.defaultView;\n const offsetX = dims.left + defaultView.pageXOffset;\n const offsetY = dims.top + defaultView.pageYOffset;\n const x = pointerEvent.pageX - offsetX;\n const y = pointerEvent.pageY - offsetY;\n if (options?.onMove) {\n options.onMove(x, y);\n }\n }\n\n function stop() {\n document.removeEventListener('pointermove', move);\n document.removeEventListener('pointerup', stop);\n\n if (options?.onStop) {\n options.onStop();\n }\n }\n\n document.addEventListener('pointermove', move, { passive: true });\n document.addEventListener('pointerup', stop);\n\n if (options?.initialEvent instanceof PointerEvent) {\n move(options.initialEvent);\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { drag } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `SplitView` is a custom web component that represents a split view.\n * @summary This element represents a split view.\n * @documentation https://elements.webjet.sk/components/split-view\n * @status stable\n * @augments WJElement\n * @slot start - Slot for the start view.\n * @slot end - Slot for the end view.\n * @slot divider - Slot for the divider.\n * @csspart wje-divider - The divider of the split view.\n * @cssproperty [--wje-split-view-divider-area=12px] - Defines the interactive area (hitbox) of the divider for resizing. Accepts any valid CSS length unit (e.g., `px`, `rem`, `%`).\n * @cssproperty [--wje-split-view-divider-width=4px] - Specifies the visual width of the divider. Controls how thick the divider appears.\n * @cssproperty [--wje-split-view-min=0%] - Sets the minimum size limit for the split views. Ensures that a view cannot be resized below this value.\n * @cssproperty [--wje-split-view-max=100%] - Sets the maximum size limit for the split views. Ensures that a view cannot be resized beyond this value.\n * @cssproperty [--wje-split-view-calc-a=50%] - Represents the calculated size of the first view. This is used to dynamically set the size of the first view.\n * @cssproperty [--wje-split-view-calc-b=50%] - Represents the calculated size of the second view. This is used to dynamically set the size of the second view.\n * @cssproperty [--wje-split-view-clamp-a=clamp(var(--wje-split-view-min), var(--wje-split-view-calc-a), var(--wje-split-view-max))] - Clamps the size of the first view between minimum and maximum limits. Ensures the calculated size stays within the defined range.\n * @cssproperty [--wje-split-view-clamp-b=clamp(var(--wje-split-view-min), var(--wje-split-view-calc-b), var(--wje-split-view-max))] - Clamps the size of the second view between minimum and maximum limits. Ensures the calculated size stays within the defined range.\n * @cssproperty [--wje-split-view-divider-background=var(--wje-border-color)] - Sets the background color of the divider. Accepts any valid CSS color value (e.g., hex, RGB, or CSS variable).\n * @cssproperty [--wje-split-view-divider-size=4px] - Defines the overall size of the divider, affecting both its visual and interactive dimensions. Accepts any valid CSS length unit.\n * @tag wje-split-view\n */\n\nexport default class SplitView extends WJElement {\n /**\n * Creates an instance of SplitView.\n * @class\n */\n constructor() {\n super();\n }\n\n set initial(value) {\n this.setAttribute('initial', value);\n }\n\n get initial() {\n return +this.getAttribute('initial') || 50;\n }\n\n className = 'SplitView';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component for the split view.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-split-view');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n let divider = document.createElement('slot');\n divider.setAttribute('name', 'divider');\n\n let dividerElement = document.createElement('div');\n dividerElement.classList.add('wje-divider');\n dividerElement.setAttribute('part', 'divider');\n dividerElement.appendChild(divider);\n dividerElement.addEventListener('mousedown', this.handleDrag, false);\n\n native.appendChild(start);\n native.appendChild(dividerElement);\n native.appendChild(end);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n this.detectSize();\n\n if (this.min) this.style.setProperty('--wje-split-view-min', this.pixelsToPercentage(this.min) + '%');\n\n if (this.max) this.style.setProperty('--wje-split-view-max', 100 - this.pixelsToPercentage(this.max) + '%');\n\n if (this.initial) {\n this.style.setProperty('--wje-split-view-calc-a', this.pixelsToPercentage(this.initial) + '%');\n this.style.setProperty('--wje-split-view-calc-b', 100 - this.pixelsToPercentage(this.initial) + '%');\n }\n\n this.resizeObserver = new ResizeObserver((entries) => this.handleResize(entries));\n }\n\n /**\n * Handles the drag event.\n * @param {Event} e The event object.\n */\n handleDrag = (e) => {\n if (this.hasAttribute('disabled')) return;\n\n drag(this, {\n onMove: (x, y) => {\n let newPositionInPixels = this.hasAttribute('vertical') ? y : x;\n let sizeA = this.pixelsToPercentage(newPositionInPixels);\n let sizeB = 100 - this.pixelsToPercentage(newPositionInPixels);\n\n this.style.setProperty('--wje-split-view-calc-a', sizeA + '%');\n this.style.setProperty('--wje-split-view-calc-b', sizeB + '%');\n },\n initialEvent: e,\n });\n };\n\n /**\n * Detects the size of the split view.\n */\n detectSize() {\n const { width, height } = this.getBoundingClientRect();\n\n this.size = this.hasAttribute('vertical') ? height : width;\n }\n\n /**\n * Converts pixels to a percentage.\n * @param {number} value The pixel value.\n * @returns {number} The percentage value.\n */\n pixelsToPercentage(value) {\n return (value / this.size) * 100;\n }\n}\n","import SplitView from './split-view.element.js';\n\nexport default SplitView;\n\nSplitView.define('wje-split-view', SplitView);\n"],"names":[],"mappings":";;;;AAAO,SAAS,KAAK,WAAW,SAAS;AACrC,WAAS,KAAK,cAAc;AACxB,UAAM,OAAO,UAAU,sBAAuB;AAC9C,UAAM,cAAc,UAAU,cAAc;AAC5C,UAAM,UAAU,KAAK,OAAO,YAAY;AACxC,UAAM,UAAU,KAAK,MAAM,YAAY;AACvC,UAAM,IAAI,aAAa,QAAQ;AAC/B,UAAM,IAAI,aAAa,QAAQ;AAC/B,QAAI,mC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A,EACxF;AAAA;AAAA;AAAA;AAAA,EAyBI,aAAa;AACT,UAAM,EAAE,OAAO,WAAW,KAAK,sBAAuB;AAEtD,SAAK,OAAO,KAAK,aAAa,UAAU,IAAI,SAAS;AAAA,EAC7D;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOI,mBAAmB,OAAO;AACtB,WAAQ,QAAQ,KAAK,OAAQ;AAAA,EACrC;AACA;AC5JA,UAAU,OAAO,kBAAkB,SAAS;"}
|
|
1
|
+
{"version":3,"file":"wje-split-view.js","sources":["../packages/wje-split-view/service/service.js","../packages/wje-split-view/split-view.element.js","../packages/wje-split-view/split-view.js"],"sourcesContent":["export function drag(container, options) {\n function move(pointerEvent) {\n const dims = container.getBoundingClientRect();\n const defaultView = container.ownerDocument.defaultView;\n const offsetX = dims.left + defaultView.pageXOffset;\n const offsetY = dims.top + defaultView.pageYOffset;\n const x = pointerEvent.pageX - offsetX;\n const y = pointerEvent.pageY - offsetY;\n if (options?.onMove) {\n options.onMove(x, y);\n }\n }\n\n function stop() {\n document.removeEventListener('pointermove', move);\n document.removeEventListener('pointerup', stop);\n\n if (options?.onStop) {\n options.onStop();\n }\n }\n\n document.addEventListener('pointermove', move, { passive: true });\n document.addEventListener('pointerup', stop);\n\n if (options?.initialEvent instanceof PointerEvent) {\n move(options.initialEvent);\n }\n}\n","import { default as WJElement } from '../wje-element/element.js';\nimport { drag } from './service/service.js';\nimport styles from './styles/styles.css?inline';\n\n/**\n * `SplitView` is a custom web component that represents a split view.\n * @summary This element represents a split view.\n * @documentation https://elements.webjet.sk/components/split-view\n * @status stable\n * @augments WJElement\n * @slot start - Slot for the start view.\n * @slot end - Slot for the end view.\n * @slot divider - Slot for the divider.\n * @csspart wje-divider - The divider of the split view.\n * @cssproperty [--wje-split-view-divider-area=12px] - Defines the interactive area (hitbox) of the divider for resizing. Accepts any valid CSS length unit (e.g., `px`, `rem`, `%`).\n * @cssproperty [--wje-split-view-divider-width=4px] - Specifies the visual width of the divider. Controls how thick the divider appears.\n * @cssproperty [--wje-split-view-min=0%] - Sets the minimum size limit for the split views. Ensures that a view cannot be resized below this value.\n * @cssproperty [--wje-split-view-max=100%] - Sets the maximum size limit for the split views. Ensures that a view cannot be resized beyond this value.\n * @cssproperty [--wje-split-view-calc-a=50%] - Represents the calculated size of the first view. This is used to dynamically set the size of the first view.\n * @cssproperty [--wje-split-view-calc-b=50%] - Represents the calculated size of the second view. This is used to dynamically set the size of the second view.\n * @cssproperty [--wje-split-view-clamp-a=clamp(var(--wje-split-view-min), var(--wje-split-view-calc-a), var(--wje-split-view-max))] - Clamps the size of the first view between minimum and maximum limits. Ensures the calculated size stays within the defined range.\n * @cssproperty [--wje-split-view-clamp-b=clamp(var(--wje-split-view-min), var(--wje-split-view-calc-b), var(--wje-split-view-max))] - Clamps the size of the second view between minimum and maximum limits. Ensures the calculated size stays within the defined range.\n * @cssproperty [--wje-split-view-divider-background=var(--wje-border-color)] - Sets the background color of the divider. Accepts any valid CSS color value (e.g., hex, RGB, or CSS variable).\n * @cssproperty [--wje-split-view-divider-size=4px] - Defines the overall size of the divider, affecting both its visual and interactive dimensions. Accepts any valid CSS length unit.\n * @tag wje-split-view\n */\n\nexport default class SplitView extends WJElement {\n /**\n * Creates an instance of SplitView.\n * @class\n */\n constructor() {\n super();\n }\n\n set initial(value) {\n this.setAttribute('initial', value);\n }\n\n get initial() {\n return +this.getAttribute('initial') || 50;\n }\n\n className = 'SplitView';\n\n /**\n * Returns the CSS styles for the component.\n * @static\n * @returns {CSSStyleSheet}\n */\n static get cssStyleSheet() {\n return styles;\n }\n\n /**\n * Returns the list of attributes to observe for changes.\n * @static\n * @returns {Array<string>}\n */\n static get observedAttributes() {\n return [];\n }\n\n /**\n * Sets up the attributes for the component.\n */\n setupAttributes() {\n this.isShadowRoot = 'open';\n }\n\n /**\n * Draws the component for the split view.\n * @returns {DocumentFragment}\n */\n draw() {\n let fragment = document.createDocumentFragment();\n\n let native = document.createElement('div');\n native.classList.add('native-split-view');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n let divider = document.createElement('slot');\n divider.setAttribute('name', 'divider');\n\n let dividerElement = document.createElement('div');\n dividerElement.classList.add('wje-divider');\n dividerElement.setAttribute('part', 'divider');\n dividerElement.setAttribute('role', 'separator');\n dividerElement.setAttribute('aria-orientation', this.hasAttribute('vertical') ? 'vertical' : 'horizontal');\n dividerElement.setAttribute('aria-valuemin', '0');\n dividerElement.setAttribute('aria-valuemax', '100');\n dividerElement.setAttribute('aria-valuenow', `${this.initial}`);\n dividerElement.appendChild(divider);\n dividerElement.addEventListener('mousedown', this.handleDrag, false);\n\n native.appendChild(start);\n native.appendChild(dividerElement);\n native.appendChild(end);\n\n fragment.appendChild(native);\n\n this.dividerElement = dividerElement;\n\n return fragment;\n }\n\n /**\n * Sets up the event listeners after the component is drawn.\n */\n afterDraw() {\n this.detectSize();\n\n if (this.min) this.style.setProperty('--wje-split-view-min', this.pixelsToPercentage(this.min) + '%');\n\n if (this.max) this.style.setProperty('--wje-split-view-max', 100 - this.pixelsToPercentage(this.max) + '%');\n\n if (this.initial) {\n this.style.setProperty('--wje-split-view-calc-a', this.pixelsToPercentage(this.initial) + '%');\n this.style.setProperty('--wje-split-view-calc-b', 100 - this.pixelsToPercentage(this.initial) + '%');\n }\n\n this.resizeObserver = new ResizeObserver((entries) => this.handleResize(entries));\n }\n\n /**\n * Handles the drag event.\n * @param {Event} e The event object.\n */\n handleDrag = (e) => {\n if (this.hasAttribute('disabled')) return;\n\n drag(this, {\n onMove: (x, y) => {\n let newPositionInPixels = this.hasAttribute('vertical') ? y : x;\n let sizeA = this.pixelsToPercentage(newPositionInPixels);\n let sizeB = 100 - this.pixelsToPercentage(newPositionInPixels);\n\n this.style.setProperty('--wje-split-view-calc-a', sizeA + '%');\n this.style.setProperty('--wje-split-view-calc-b', sizeB + '%');\n if (this.dividerElement) {\n this.dividerElement.setAttribute('aria-valuenow', `${Math.round(sizeA)}`);\n }\n },\n initialEvent: e,\n });\n };\n\n /**\n * Detects the size of the split view.\n */\n detectSize() {\n const { width, height } = this.getBoundingClientRect();\n\n this.size = this.hasAttribute('vertical') ? height : width;\n }\n\n /**\n * Converts pixels to a percentage.\n * @param {number} value The pixel value.\n * @returns {number} The percentage value.\n */\n pixelsToPercentage(value) {\n return (value / this.size) * 100;\n }\n}\n","import SplitView from './split-view.element.js';\n\nexport default SplitView;\n\nSplitView.define('wje-split-view', SplitView);\n"],"names":[],"mappings":";;;;AAAO,SAAS,KAAK,WAAW,SAAS;AACrC,WAAS,KAAK,cAAc;AACxB,UAAM,OAAO,UAAU,sBAAuB;AAC9C,UAAM,cAAc,UAAU,cAAc;AAC5C,UAAM,UAAU,KAAK,OAAO,YAAY;AACxC,UAAM,UAAU,KAAK,MAAM,YAAY;AACvC,UAAM,IAAI,aAAa,QAAQ;AAC/B,UAAM,IAAI,aAAa,QAAQ;AAC/B,QAAI,mCAAS,QAAQ;AACjB,cAAQ,OAAO,GAAG,CAAC;AAAA,IAC/B;AAAA,EACA;AAEI,WAAS,OAAO;AACZ,aAAS,oBAAoB,eAAe,IAAI;AAChD,aAAS,oBAAoB,aAAa,IAAI;AAE9C,QAAI,mCAAS,QAAQ;AACjB,cAAQ,OAAQ;AAAA,IAC5B;AAAA,EACA;AAEI,WAAS,iBAAiB,eAAe,MAAM,EAAE,SAAS,MAAM;AAChE,WAAS,iBAAiB,aAAa,IAAI;AAE3C,OAAI,mCAAS,yBAAwB,cAAc;AAC/C,SAAK,QAAQ,YAAY;AAAA,EACjC;AACA;;ACDe,MAAM,kBAAkB,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA,EAK7C,cAAc;AACV,UAAO;AAWX,qCAAY;AA0FZ;AAAA;AAAA;AAAA;AAAA,sCAAa,CAAC,MAAM;AAChB,UAAI,KAAK,aAAa,UAAU,EAAG;AAEnC,WAAK,MAAM;AAAA,QACP,QAAQ,CAAC,GAAG,MAAM;AACd,cAA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kB,SAAS;"}
|
package/dist/wje-status.js
CHANGED
package/dist/wje-status.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wje-status.js","sources":["../packages/wje-status/status.element.js","../packages/wje-status/status.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 Status element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/status\n * @status stable\n * @augments WJElement\n * @slot - The status main content.\n * @slot start - The status start content.\n * @slot end - The status end content.\n * @csspart native - The native part of the status.\n * @csspart bullet - The bullet part of the status.\n * @tag wje-status\n */\nexport default class Status extends WJElement {\n /**\n * Creates an instance of Status.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Status';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\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 for the status.\n * @returns {object} fragment - The document fragment\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-status');\n\n let bullet = document.createElement('div');\n bullet.setAttribute('part', 'bullet');\n bullet.classList.add('bullet');\n\n let slot = document.createElement('slot');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n bullet.appendChild(slot);\n\n native.appendChild(start);\n native.appendChild(bullet);\n native.appendChild(end);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Status from './status.element.js';\n\nexport default Status;\n\nStatus.define('wje-status', Status);\n"],"names":[],"mappings":";;;;;AAee,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AAAA,
|
|
1
|
+
{"version":3,"file":"wje-status.js","sources":["../packages/wje-status/status.element.js","../packages/wje-status/status.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 Status element, extending the WJElement class.\n * @documentation https://elements.webjet.sk/components/status\n * @status stable\n * @augments WJElement\n * @slot - The status main content.\n * @slot start - The status start content.\n * @slot end - The status end content.\n * @csspart native - The native part of the status.\n * @csspart bullet - The bullet part of the status.\n * @tag wje-status\n */\nexport default class Status extends WJElement {\n /**\n * Creates an instance of Status.\n */\n constructor() {\n super();\n }\n\n /**\n * The class name for the component.\n * @type {string}\n */\n className = 'Status';\n\n /**\n * Returns the CSS stylesheet for the component.\n * @static\n * @returns {CSSStyleSheet} The CSS stylesheet\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 this.setAriaState({ role: 'status' });\n }\n\n /**\n * Draws the component for the status.\n * @returns {object} fragment - The document fragment\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-status');\n\n let bullet = document.createElement('div');\n bullet.setAttribute('part', 'bullet');\n bullet.classList.add('bullet');\n\n let slot = document.createElement('slot');\n\n let start = document.createElement('slot');\n start.setAttribute('name', 'start');\n\n let end = document.createElement('slot');\n end.setAttribute('name', 'end');\n\n bullet.appendChild(slot);\n\n native.appendChild(start);\n native.appendChild(bullet);\n native.appendChild(end);\n\n fragment.appendChild(native);\n\n return fragment;\n }\n}\n","import Status from './status.element.js';\n\nexport default Status;\n\nStatus.define('wje-status', Status);\n"],"names":[],"mappings":";;;;;AAee,MAAM,eAAe,UAAU;AAAA;AAAA;AAAA;AAAA,EAI1C,cAAc;AACV,UAAO;AAOX;AAAA;AAAA;AAAA;AAAA,qCAAY;AAAA,EANhB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaI,WAAW,gBAAgB;AACvB,WAAO;AAAA,EACf;AAAA;AAAA;AAAA;AAAA,EAKI,kBAAkB;AACd,SAAK,eAAe;AACpB,SAAK,aAAa,EAAE,MAAM,SAAQ,CAAE;AAAA,EAC5C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMI,OAAO;AACH,QAAI,WAAW,SAAS,uBAAwB;AAEhD,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,UAAU,IAAI,eAAe;AAEpC,QAAI,SAAS,SAAS,cAAc,KAAK;AACzC,WAAO,aAAa,QAAQ,QAAQ;AACpC,WAAO,UAAU,IAAI,QAAQ;AAE7B,QAAI,OAAO,SAAS,cAAc,MAAM;AAExC,QAAI,QAAQ,SAAS,cAAc,MAAM;AACzC,UAAM,aAAa,QAAQ,OAAO;AAElC,QAAI,MAAM,SAAS,cAAc,MAAM;AACvC,QAAI,aAAa,QAAQ,KAAK;AAE9B,WAAO,YAAY,IAAI;AAEvB,WAAO,YAAY,KAAK;AACxB,WAAO,YAAY,MAAM;AACzB,WAAO,YAAY,GAAG;AAEtB,aAAS,YAAY,MAAM;AAE3B,WAAO;AAAA,EACf;AACA;AC3EA,OAAO,OAAO,cAAc,MAAM;"}
|
package/dist/wje-stepper.js
CHANGED
|
@@ -5,6 +5,7 @@ import { Localizer } from "./localize.js";
|
|
|
5
5
|
import WJElement from "./wje-element.js";
|
|
6
6
|
import { event } from "./event.js";
|
|
7
7
|
const styles = '.container {\n display: flex;\n flex-direction: column;\n}\n\n.header {\n display: flex;\n justify-content: var(--wje-stepper-justify);\n margin-bottom: var(--wje-spacing-medium);\n}\n\n.step-header {\n display: flex;\n padding: var(--wje-spacing-medium);\n gap: var(--wje-spacing-x-small);\n color: var(--wje-color-contrast-5);\n flex-grow: var(--wje-stepper-grow);\n text-align: center;\n}\n\n.pointer {\n cursor: pointer;\n}\n\n[active] {\n color: var(--wje-color-contrast-11);\n}\n\n.content {\n margin-bottom: var(--wje-spacing-medium);\n}\n\n.arrow-icon {\n margin-top: var(--wje-stepper-margin);\n}\n\n.step {\n padding: var(--wje-spacing-medium);\n text-align: center;\n}\n\n[done] {\n color: var(--wje-color-contrast-11);\n}\n\n.nav-buttons {\n display: flex;\n justify-content: space-between;\n\n slot[hidden] {\n visibility: hidden;\n display: initial;\n }\n\n slot[disabled] {\n opacity: 0.5;\n pointer-events: none;\n cursor: not-allowed;\n\n /* after */\n ::after {\n content: "";\n display: block;\n width: 100%;\n height: 100%;\n background-color: var(--wje-color-contrast-2);\n position: absolute;\n top: 0;\n left: 0;\n opacity: .5;\n }\n }\n}';
|
|
8
|
+
let stepperId = 0;
|
|
8
9
|
class Stepper extends WJElement {
|
|
9
10
|
constructor() {
|
|
10
11
|
super();
|
|
@@ -32,6 +33,7 @@ class Stepper extends WJElement {
|
|
|
32
33
|
this.localizer = new Localizer(this);
|
|
33
34
|
this.steps = [];
|
|
34
35
|
this.headerSteps = [];
|
|
36
|
+
this._stepperId = ++stepperId;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Sets the start index for an operation or a process. This method assigns
|
|
@@ -78,6 +80,7 @@ class Stepper extends WJElement {
|
|
|
78
80
|
const header = document.createElement("div");
|
|
79
81
|
header.setAttribute("part", "header");
|
|
80
82
|
header.className = "header";
|
|
83
|
+
header.setAttribute("role", "tablist");
|
|
81
84
|
const content = document.createElement("div");
|
|
82
85
|
content.setAttribute("part", "content");
|
|
83
86
|
content.className = "content";
|
|
@@ -144,6 +147,7 @@ class Stepper extends WJElement {
|
|
|
144
147
|
processStep(index, step, header, steps) {
|
|
145
148
|
const nav = document.createElement("div");
|
|
146
149
|
nav.className = "step-header";
|
|
150
|
+
nav.setAttribute("role", "tab");
|
|
147
151
|
nav.addEventListener("click", (e) => {
|
|
148
152
|
this.goToStep(index);
|
|
149
153
|
});
|
|
@@ -153,8 +157,18 @@ class Stepper extends WJElement {
|
|
|
153
157
|
badge.innerHTML = index + 1;
|
|
154
158
|
const label = document.createElement("span");
|
|
155
159
|
label.innerText = step.getAttribute("label") || `${this.localizer.translate("wj.stepper.step")} ${index + 1}`;
|
|
160
|
+
const panelId = step.id || `wje-stepper-${this._stepperId}-panel-${index}`;
|
|
161
|
+
const tabId = nav.id || `wje-stepper-${this._stepperId}-tab-${index}`;
|
|
162
|
+
step.id = panelId;
|
|
163
|
+
nav.id = tabId;
|
|
164
|
+
nav.setAttribute("aria-controls", panelId);
|
|
165
|
+
step.setAttribute("role", "tabpanel");
|
|
166
|
+
step.setAttribute("aria-labelledby", tabId);
|
|
156
167
|
if (index === this.currentStep || step.hasAttribute("active")) {
|
|
157
|
-
this.setStepActive(nav, badge);
|
|
168
|
+
this.setStepActive(nav, badge, index);
|
|
169
|
+
} else {
|
|
170
|
+
nav.setAttribute("aria-selected", "false");
|
|
171
|
+
nav.setAttribute("tabindex", "-1");
|
|
158
172
|
}
|
|
159
173
|
if (step.hasAttribute("disabled")) {
|
|
160
174
|
nav.setAttribute("disabled", "");
|
|
@@ -175,6 +189,9 @@ class Stepper extends WJElement {
|
|
|
175
189
|
step.classList.add("step");
|
|
176
190
|
if (index !== this.currentStep) {
|
|
177
191
|
step.style.display = "none";
|
|
192
|
+
step.setAttribute("aria-hidden", "true");
|
|
193
|
+
} else {
|
|
194
|
+
step.setAttribute("aria-hidden", "false");
|
|
178
195
|
}
|
|
179
196
|
this.steps.push(step);
|
|
180
197
|
return nav;
|
|
@@ -266,6 +283,8 @@ class Stepper extends WJElement {
|
|
|
266
283
|
setStepDefault(nav, badge = null, stepIndex = 0) {
|
|
267
284
|
nav.removeAttribute("active");
|
|
268
285
|
nav.removeAttribute("done");
|
|
286
|
+
nav.setAttribute("aria-selected", "false");
|
|
287
|
+
nav.setAttribute("tabindex", "-1");
|
|
269
288
|
if (!badge) {
|
|
270
289
|
badge = nav.querySelector("wje-badge");
|
|
271
290
|
}
|
|
@@ -280,6 +299,8 @@ class Stepper extends WJElement {
|
|
|
280
299
|
*/
|
|
281
300
|
setStepActive(nav, badge = null, stepIndex = null) {
|
|
282
301
|
nav.setAttribute("active", "");
|
|
302
|
+
nav.setAttribute("aria-selected", "true");
|
|
303
|
+
nav.setAttribute("tabindex", "0");
|
|
283
304
|
if (!badge) {
|
|
284
305
|
badge = nav.querySelector("wje-badge");
|
|
285
306
|
}
|
|
@@ -295,8 +316,10 @@ class Stepper extends WJElement {
|
|
|
295
316
|
(_a = this.steps) == null ? void 0 : _a.forEach((step, index) => {
|
|
296
317
|
if (index === stepIndex) {
|
|
297
318
|
step.style.display = "block";
|
|
319
|
+
step.setAttribute("aria-hidden", "false");
|
|
298
320
|
} else {
|
|
299
321
|
step.style.display = "none";
|
|
322
|
+
step.setAttribute("aria-hidden", "true");
|
|
300
323
|
}
|
|
301
324
|
});
|
|
302
325
|
}
|