wj-elements 0.7.7 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/animations.js +28 -51
- package/dist/animations.js.map +1 -1
- package/dist/base-path.js +19 -31
- package/dist/base-path.js.map +1 -1
- package/dist/custom-elements.json +11504 -11499
- package/dist/dark.css +1 -302
- package/dist/date.js +16 -36
- package/dist/date.js.map +1 -1
- package/dist/element-utils.js +20 -81
- package/dist/element-utils.js.map +1 -1
- package/dist/event.js +49 -165
- package/dist/event.js.map +1 -1
- package/dist/form-associated-element-BjeJn7j8.js +101 -0
- package/dist/{form-associated-element-DEQ4y-jn.js.map → form-associated-element-BjeJn7j8.js.map} +1 -1
- package/dist/icon-DmsqtDpL.js +102 -0
- package/dist/{icon-CReYMzAK.js.map → icon-DmsqtDpL.js.map} +1 -1
- package/dist/light.css +1 -731
- package/dist/localize.js +36 -111
- package/dist/localize.js.map +1 -1
- package/dist/packages/wje-accordion-item/accordion-item.element.d.ts +3 -2
- package/dist/permissions.js +14 -41
- package/dist/permissions.js.map +1 -1
- package/dist/popup.element-CbkhthPP.js +806 -0
- package/dist/{popup.element-CwXvVFK7.js.map → popup.element-CbkhthPP.js.map} +1 -1
- package/dist/router-links-CNsJ-elb.js +105 -0
- package/dist/{router-links-wjqCnncc.js.map → router-links-CNsJ-elb.js.map} +1 -1
- package/dist/skeleton.css +1 -197
- package/dist/styles.css +1 -866
- package/dist/universal-service.js +48 -109
- package/dist/universal-service.js.map +1 -1
- package/dist/utils.js +11 -18
- package/dist/utils.js.map +1 -1
- package/dist/web-types.json +760 -760
- package/dist/wje-accordion-item.js +33 -106
- package/dist/wje-accordion-item.js.map +1 -1
- package/dist/wje-accordion.js +19 -84
- package/dist/wje-accordion.js.map +1 -1
- package/dist/wje-animation.js +37 -4258
- package/dist/wje-animation.js.map +1 -1
- package/dist/wje-aside.js +9 -34
- package/dist/wje-aside.js.map +1 -1
- package/dist/wje-avatar.js +36 -126
- package/dist/wje-avatar.js.map +1 -1
- package/dist/wje-badge.js +10 -52
- package/dist/wje-badge.js.map +1 -1
- package/dist/wje-breadcrumb.js +205 -672
- package/dist/wje-breadcrumb.js.map +1 -1
- package/dist/wje-breadcrumbs.js +177 -633
- package/dist/wje-breadcrumbs.js.map +1 -1
- package/dist/wje-button-group.js +48 -153
- package/dist/wje-button-group.js.map +1 -1
- package/dist/wje-button.js +92 -413
- package/dist/wje-button.js.map +1 -1
- package/dist/wje-card-content.js +7 -30
- package/dist/wje-card-content.js.map +1 -1
- package/dist/wje-card-controls.js +7 -30
- package/dist/wje-card-controls.js.map +1 -1
- package/dist/wje-card-header.js +7 -30
- package/dist/wje-card-header.js.map +1 -1
- package/dist/wje-card-subtitle.js +7 -34
- package/dist/wje-card-subtitle.js.map +1 -1
- package/dist/wje-card-title.js +7 -34
- package/dist/wje-card-title.js.map +1 -1
- package/dist/wje-card.js +15 -71
- package/dist/wje-card.js.map +1 -1
- package/dist/wje-carousel-item.js +12 -56
- package/dist/wje-carousel-item.js.map +1 -1
- package/dist/wje-carousel.js +154 -509
- package/dist/wje-carousel.js.map +1 -1
- package/dist/wje-checkbox.js +50 -227
- package/dist/wje-checkbox.js.map +1 -1
- package/dist/wje-chip.js +43 -160
- package/dist/wje-chip.js.map +1 -1
- package/dist/wje-col.js +7 -20
- package/dist/wje-col.js.map +1 -1
- package/dist/wje-color-picker.js +445 -1464
- package/dist/wje-color-picker.js.map +1 -1
- package/dist/wje-container.js +9 -35
- package/dist/wje-container.js.map +1 -1
- package/dist/wje-copy-button.js +64 -204
- package/dist/wje-copy-button.js.map +1 -1
- package/dist/wje-dialog.js +85 -553
- package/dist/wje-dialog.js.map +1 -1
- package/dist/wje-divider.js +7 -34
- package/dist/wje-divider.js.map +1 -1
- package/dist/wje-dropdown.js +78 -305
- package/dist/wje-dropdown.js.map +1 -1
- package/dist/wje-element.js +191 -700
- package/dist/wje-element.js.map +1 -1
- package/dist/wje-file-upload-item.js +51 -156
- package/dist/wje-file-upload-item.js.map +1 -1
- package/dist/wje-file-upload.js +181 -619
- package/dist/wje-file-upload.js.map +1 -1
- package/dist/wje-footer.js +7 -31
- package/dist/wje-footer.js.map +1 -1
- package/dist/wje-form.js +7 -32
- package/dist/wje-form.js.map +1 -1
- package/dist/wje-format-digital.js +26 -118
- package/dist/wje-format-digital.js.map +1 -1
- package/dist/wje-grid.js +7 -33
- package/dist/wje-grid.js.map +1 -1
- package/dist/wje-header.js +9 -35
- package/dist/wje-header.js.map +1 -1
- package/dist/wje-icon-library.js +12 -18
- package/dist/wje-icon-library.js.map +1 -1
- package/dist/wje-icon-picker.js +65 -320
- package/dist/wje-icon-picker.js.map +1 -1
- package/dist/wje-icon.js +1 -1
- package/dist/wje-img-comparer.js +37 -114
- package/dist/wje-img-comparer.js.map +1 -1
- package/dist/wje-img.js +50 -198
- package/dist/wje-img.js.map +1 -1
- package/dist/wje-infinite-scroll.js +94 -346
- package/dist/wje-infinite-scroll.js.map +1 -1
- package/dist/wje-input-file.js +23 -84
- package/dist/wje-input-file.js.map +1 -1
- package/dist/wje-input.js +78 -392
- package/dist/wje-input.js.map +1 -1
- package/dist/wje-item.js +11 -64
- package/dist/wje-item.js.map +1 -1
- package/dist/wje-kanban.js +124 -401
- package/dist/wje-kanban.js.map +1 -1
- package/dist/wje-label.js +9 -32
- package/dist/wje-label.js.map +1 -1
- package/dist/wje-level-indicator.js +38 -157
- package/dist/wje-level-indicator.js.map +1 -1
- package/dist/wje-list.js +10 -40
- package/dist/wje-list.js.map +1 -1
- package/dist/wje-main.js +7 -31
- package/dist/wje-main.js.map +1 -1
- package/dist/wje-masonry.js +66 -211
- package/dist/wje-masonry.js.map +1 -1
- package/dist/wje-master.js +45 -161
- package/dist/wje-master.js.map +1 -1
- package/dist/wje-menu-button.js +10 -38
- package/dist/wje-menu-button.js.map +1 -1
- package/dist/wje-menu-item.js +127 -577
- package/dist/wje-menu-item.js.map +1 -1
- package/dist/wje-menu-label.js +9 -35
- package/dist/wje-menu-label.js.map +1 -1
- package/dist/wje-menu.js +14 -49
- package/dist/wje-menu.js.map +1 -1
- package/dist/wje-option.js +48 -279
- package/dist/wje-option.js.map +1 -1
- package/dist/wje-options.js +130 -384
- package/dist/wje-options.js.map +1 -1
- package/dist/wje-orgchart-group.js +16 -52
- package/dist/wje-orgchart-group.js.map +1 -1
- package/dist/wje-orgchart-item.js +24 -93
- package/dist/wje-orgchart-item.js.map +1 -1
- package/dist/wje-orgchart.js +18 -68
- package/dist/wje-orgchart.js.map +1 -1
- package/dist/wje-pagination.js +113 -397
- package/dist/wje-pagination.js.map +1 -1
- package/dist/wje-popup.js +3 -3
- package/dist/wje-popup.js.map +1 -1
- package/dist/wje-progress-bar.js +53 -205
- package/dist/wje-progress-bar.js.map +1 -1
- package/dist/wje-qr-code.js +398 -2980
- package/dist/wje-qr-code.js.map +1 -1
- package/dist/wje-radio-group.js +52 -190
- package/dist/wje-radio-group.js.map +1 -1
- package/dist/wje-radio.js +24 -118
- package/dist/wje-radio.js.map +1 -1
- package/dist/wje-rate.js +62 -266
- package/dist/wje-rate.js.map +1 -1
- package/dist/wje-relative-time.js +24 -99
- package/dist/wje-relative-time.js.map +1 -1
- package/dist/wje-reorder-dropzone.js +9 -31
- package/dist/wje-reorder-dropzone.js.map +1 -1
- package/dist/wje-reorder-handle.js +67 -204
- package/dist/wje-reorder-handle.js.map +1 -1
- package/dist/wje-reorder-item.js +14 -44
- package/dist/wje-reorder-item.js.map +1 -1
- package/dist/wje-reorder.js +61 -246
- package/dist/wje-reorder.js.map +1 -1
- package/dist/wje-route.js +6 -24
- package/dist/wje-route.js.map +1 -1
- package/dist/wje-router-link.js +11 -39
- package/dist/wje-router-link.js.map +1 -1
- package/dist/wje-router-outlet.js +76 -172
- package/dist/wje-router-outlet.js.map +1 -1
- package/dist/wje-routerx.js +537 -1331
- package/dist/wje-routerx.js.map +1 -1
- package/dist/wje-row.js +9 -31
- package/dist/wje-row.js.map +1 -1
- package/dist/wje-select.js +326 -1152
- package/dist/wje-select.js.map +1 -1
- package/dist/wje-slider.js +44 -225
- package/dist/wje-slider.js.map +1 -1
- package/dist/wje-sliding-container.js +295 -1319
- package/dist/wje-sliding-container.js.map +1 -1
- package/dist/wje-split-view.js +35 -121
- package/dist/wje-split-view.js.map +1 -1
- package/dist/wje-status.js +14 -45
- package/dist/wje-status.js.map +1 -1
- package/dist/wje-step.js +9 -32
- package/dist/wje-step.js.map +1 -1
- package/dist/wje-stepper.js +109 -357
- package/dist/wje-stepper.js.map +1 -1
- package/dist/wje-store.js +67 -360
- package/dist/wje-store.js.map +1 -1
- package/dist/wje-tab-group.js +85 -314
- package/dist/wje-tab-group.js.map +1 -1
- package/dist/wje-tab-panel.js +7 -28
- package/dist/wje-tab-panel.js.map +1 -1
- package/dist/wje-tab.js +21 -198
- package/dist/wje-tab.js.map +1 -1
- package/dist/wje-textarea.js +64 -264
- package/dist/wje-textarea.js.map +1 -1
- package/dist/wje-thumbnail.js +10 -51
- package/dist/wje-thumbnail.js.map +1 -1
- package/dist/wje-toast.js +127 -632
- package/dist/wje-toast.js.map +1 -1
- package/dist/wje-toggle.js +52 -177
- package/dist/wje-toggle.js.map +1 -1
- package/dist/wje-toolbar-action.js +128 -456
- package/dist/wje-toolbar-action.js.map +1 -1
- package/dist/wje-toolbar.js +75 -270
- package/dist/wje-toolbar.js.map +1 -1
- package/dist/wje-tooltip.js +50 -161
- package/dist/wje-tooltip.js.map +1 -1
- package/dist/wje-tree-item.js +70 -301
- package/dist/wje-tree-item.js.map +1 -1
- package/dist/wje-tree.js +145 -489
- package/dist/wje-tree.js.map +1 -1
- package/dist/wje-visually-hidden.js +7 -34
- package/dist/wje-visually-hidden.js.map +1 -1
- package/package.json +3 -2
- package/dist/form-associated-element-DEQ4y-jn.js +0 -245
- package/dist/icon-CReYMzAK.js +0 -245
- package/dist/popup.element-CwXvVFK7.js +0 -2133
- package/dist/router-links-wjqCnncc.js +0 -156
package/dist/wje-slider.js
CHANGED
|
@@ -1,272 +1,91 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import
|
|
5
|
-
import { event } from "./event.js";
|
|
6
|
-
|
|
7
|
-
class Slider extends WJElement {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of Slider.
|
|
10
|
-
* @class
|
|
11
|
-
*/
|
|
4
|
+
import e from "./wje-element.js";
|
|
5
|
+
import { event as t } from "./event.js";
|
|
6
|
+
class i extends e {
|
|
12
7
|
constructor() {
|
|
13
8
|
super();
|
|
14
9
|
__publicField(this, "className", "Slider");
|
|
15
|
-
/**
|
|
16
|
-
* Sets the handle position of the slider.
|
|
17
|
-
*/
|
|
18
10
|
__publicField(this, "setHandlePosition", () => {
|
|
19
|
-
|
|
20
|
-
this.input.style.backgroundSize = this.getPercentage(this.input.min, this.input.max, this.input.value) + "% 100%";
|
|
21
|
-
this.syncAria();
|
|
11
|
+
this.input && (this.input.style.backgroundSize = this.getPercentage(this.input.min, this.input.max, this.input.value) + "% 100%", this.syncAria());
|
|
22
12
|
});
|
|
23
|
-
/**
|
|
24
|
-
* Updates the position and content of a bubble element based on the input value.
|
|
25
|
-
*
|
|
26
|
-
* This function calculates the position of the bubble using the percentage representation
|
|
27
|
-
* of the input's current value relative to its minimum and maximum bounds. It then adjusts
|
|
28
|
-
* the bubble's left position dynamically for aesthetic purposes and updates its displayed
|
|
29
|
-
* content to reflect the current input value.
|
|
30
|
-
*
|
|
31
|
-
* The function relies on the following elements:
|
|
32
|
-
* - `this.input`: Represents the input element with properties `min`, `max`, and `value`.
|
|
33
|
-
* - `this.output`: Represents the bubble element to be positioned and updated.
|
|
34
|
-
*
|
|
35
|
-
* The left positioning of the bubble ensures precise alignment with the input value indicator.
|
|
36
|
-
*/
|
|
37
13
|
__publicField(this, "setBubble", () => {
|
|
38
|
-
let
|
|
39
|
-
this.output.style.left = `calc(${
|
|
40
|
-
this.output.innerHTML = this.input.value;
|
|
14
|
+
let e2 = this.getPercentage(this.input.min, this.input.max, this.input.value);
|
|
15
|
+
this.output.style.left = `calc(${e2}% + (${8 - 0.15 * e2}px) - ${this.output.offsetWidth / 2}px)`, this.output.innerHTML = this.input.value;
|
|
41
16
|
});
|
|
42
17
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @param {number} value The value to set.
|
|
46
|
-
*/
|
|
47
|
-
set value(value) {
|
|
48
|
-
this.setAttribute("value", value);
|
|
49
|
-
if (this.input) {
|
|
50
|
-
this.input.value = value;
|
|
51
|
-
this.setHandlePosition();
|
|
52
|
-
}
|
|
53
|
-
if (this.output && this.hasAttribute("bubble")) {
|
|
54
|
-
this.output.innerHTML = value;
|
|
55
|
-
setTimeout(this.setBubble, 0);
|
|
56
|
-
}
|
|
18
|
+
set value(e2) {
|
|
19
|
+
this.setAttribute("value", e2), this.input && (this.input.value = e2, this.setHandlePosition()), this.output && this.hasAttribute("bubble") && (this.output.innerHTML = e2, setTimeout(this.setBubble, 0));
|
|
57
20
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns the value of the slider.
|
|
60
|
-
* @returns {number} The value of the slider input.
|
|
61
|
-
*/
|
|
62
21
|
get value() {
|
|
63
22
|
return this.getAttribute("value") || 0;
|
|
64
23
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* @param {number} value The minimum value to set.
|
|
68
|
-
*/
|
|
69
|
-
set min(value) {
|
|
70
|
-
this.setAttribute("min", value);
|
|
24
|
+
set min(e2) {
|
|
25
|
+
this.setAttribute("min", e2);
|
|
71
26
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Returns the minimum value of the slider.
|
|
74
|
-
* @returns {number} The minimum value of the slider.
|
|
75
|
-
*/
|
|
76
27
|
get min() {
|
|
77
28
|
return this.getAttribute("min") || 0;
|
|
78
29
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* @param {number} value The maximum value to set.
|
|
82
|
-
*/
|
|
83
|
-
set max(value) {
|
|
84
|
-
this.setAttribute("max", value);
|
|
30
|
+
set max(e2) {
|
|
31
|
+
this.setAttribute("max", e2);
|
|
85
32
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Returns the maximum value of the slider.
|
|
88
|
-
* @returns {number} The maximum value of the slider.
|
|
89
|
-
*/
|
|
90
33
|
get max() {
|
|
91
34
|
return this.getAttribute("max") || 100;
|
|
92
35
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
* @param {number} value The step value to set.
|
|
96
|
-
*/
|
|
97
|
-
set step(value) {
|
|
98
|
-
this.setAttribute("step", value);
|
|
36
|
+
set step(e2) {
|
|
37
|
+
this.setAttribute("step", e2);
|
|
99
38
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Returns the step value of the slider.
|
|
102
|
-
* @returns {number} The step value of the slider.
|
|
103
|
-
*/
|
|
104
39
|
get step() {
|
|
105
40
|
return this.getAttribute("step") || 1;
|
|
106
41
|
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns the CSS styles for the component.
|
|
109
|
-
* @static
|
|
110
|
-
* @returns {CSSStyleSheet}
|
|
111
|
-
*/
|
|
112
42
|
static get cssStyleSheet() {
|
|
113
|
-
return
|
|
43
|
+
return ':host{--wje-slider-track-height: .25rem;--wje-slider-color: var(--wje-color-primary-9);--wje-slider-thumb-color: var(--wje-color-primary-9);--wje-slider-thumb-border: none;--wje-slider-thumb-shadow: none;--wje-slider-thumb-shadow-active: color-mix(in hsl, var(--wje-color-contrast-4) 60%, white) 0 0 0 7px;--wje-slider-track-color: var(--wje-color-contrast-4);position:relative;display:flex;align-items:center;max-width:100%}.native-slider{display:flex;position:relative;flex-grow:1;align-items:center;height:inherit}.slider{display:flex;align-items:center;position:relative;flex:1 1 0%;width:100%;height:var(--height);contain:size layout style;cursor:grab;touch-action:pan-y}input[type=range]{-webkit-appearance:none;width:100%;height:var(--wje-slider-track-height);margin:0;border-radius:5px;background-size:70% 100%;background-repeat:no-repeat;background-color:var(--wje-slider-track-color);background-image:linear-gradient(var(--wje-slider-color),var(--wje-slider-color))}input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;height:18px;width:18px;border-radius:50%;border:var(--wje-slider-thumb-border);background:var(--wje-slider-thumb-color);box-shadow:var(--wje-slider-thumb-shadow);cursor:ew-resize;transition:background .3s ease-in-out,border .3s ease-in-out}input[type=range]::-moz-range-thumb{height:18px;width:18px;border-radius:50%;border:var(--wje-slider-thumb-border);background:var(--wje-slider-thumb-color);box-shadow:var(--wje-slider-thumb-shadow);cursor:pointer;transition:background .3s ease-in-out,border .3s ease-in-out}input[type=range]::-ms-thumb{height:18px;width:18px;border-radius:50%;border:var(--wje-slider-thumb-border);background:var(--wje-slider-thumb-color);box-shadow:var(--wje-slider-thumb-shadow);cursor:ew-resize;transition:background .3s ease-in-out,border .3s ease-in-out}input[type=range]::-webkit-slider-thumb:active,input[type=range]::-moz-range-thumb:active,input[type=range]::-ms-thumb:active{box-shadow:var(--wje-slider-thumb-shadow-active)}input[type=range]::-webkit-slider-runnable-track{-webkit-appearance:none;box-shadow:none;border:none;background:transparent}input[type=range]::-moz-range-track{-webkit-appearance:none;box-shadow:none;border:none;background:transparent}input[type=range]::-ms-track{-webkit-appearance:none;box-shadow:none;border:none;background:transparent}input[type=range][color=primary]{--wje-slider-color: var(--wje-color-primary-9);--wje-slider-thumb-color: var(--wje-color-primary-9)}input[type=range][color=success]{--wje-slider-color: var(--wje-color-success-9);--wje-slider-thumb-color: var(--wje-color-success-9)}input[type=range][color=complete]{--wje-slider-color: var(--wje-color-complete-9);--wje-slider-thumb-color: var(--wje-color-complete-9)}input[type=range][color=danger]{--wje-slider-color: var(--wje-color-danger-9);--wje-slider-thumb-color: var(--wje-color-danger-9)}input[type=range][color=warning]{--wje-slider-color: var(--wje-color-warning-9);--wje-slider-thumb-color: var(--wje-color-warning-9)}input[type=range][color=dark]{--wje-slider-color: var(--wje-color-contrast-11);--wje-slider-thumb-color: var(--wje-color-contrast-11)}datalist{display:flex;justify-content:space-between;height:auto;overflow:hidden;margin-top:16px}datalist option:before{content:"";display:block;width:0;height:auto;padding-left:3px;text-indent:0}output{position:absolute;background:var(--wje-color-contrast-11);color:var(--wje-color-contrast-0);top:-46px;padding:4px 8px;border-radius:4px}::slotted([slot="label"]){margin-inline:0 .5rem;font-size:var(--wje-font-size)}::slotted([slot="start"]){margin-inline:0rem .75rem}::slotted([slot="end"]){margin-inline:.75rem 0rem}';
|
|
114
44
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Returns the list of attributes to observe for changes.
|
|
117
|
-
* @static
|
|
118
|
-
* @returns {Array<string>}
|
|
119
|
-
*/
|
|
120
45
|
static get observedAttributes() {
|
|
121
46
|
return ["max", "min", "step", "value", "disabled", "bubble"];
|
|
122
47
|
}
|
|
123
|
-
attributeChangedCallback(
|
|
48
|
+
attributeChangedCallback(e2, t2, i2) {
|
|
124
49
|
var _a, _b, _c;
|
|
125
|
-
if (
|
|
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);
|
|
50
|
+
if (t2 !== i2) return ["max", "min", "step", "value", "disabled", "bubble"].includes(e2) ? (this.input && ("min" === e2 && (this.input.min = this.min), "max" === e2 && (this.input.max = this.max), "step" === e2 && (this.input.step = this.step), "value" === e2 && (this.input.value = this.value), "disabled" === e2 && (this.input.disabled = this.hasAttribute("disabled"))), "bubble" === e2 && this.output && (this.hasAttribute("bubble") ? (this.output.removeAttribute("hidden"), this.output.innerHTML = ((_a = this.input) == null ? void 0 : _a.value) ?? this.value, setTimeout(this.setBubble, 0)) : this.output.setAttribute("hidden", "")), void (["min", "max", "value", "disabled"].includes(e2) && this.input && ((_b = this.setHandlePosition) == null ? void 0 : _b.call(this), this.syncAria()))) : void ((_c = super.attributeChangedCallback) == null ? void 0 : _c.call(this, e2, t2, i2));
|
|
150
51
|
}
|
|
151
|
-
/**
|
|
152
|
-
* Sets up the attributes for the component.
|
|
153
|
-
*/
|
|
154
52
|
setupAttributes() {
|
|
155
|
-
this.isShadowRoot = "open";
|
|
156
|
-
this.syncAria();
|
|
53
|
+
this.isShadowRoot = "open", this.syncAria();
|
|
157
54
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Draws the component for the slider.
|
|
160
|
-
* @returns {DocumentFragment}
|
|
161
|
-
*/
|
|
162
55
|
draw() {
|
|
163
|
-
let
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
let
|
|
168
|
-
|
|
169
|
-
let
|
|
170
|
-
|
|
171
|
-
let
|
|
172
|
-
|
|
173
|
-
let
|
|
174
|
-
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
let input = document.createElement("input");
|
|
180
|
-
input.type = "range";
|
|
181
|
-
input.min = this.min;
|
|
182
|
-
input.max = this.max;
|
|
183
|
-
input.step = this.step;
|
|
184
|
-
input.value = this.value;
|
|
185
|
-
input.id = "slider";
|
|
186
|
-
input.name = "slider";
|
|
187
|
-
input.part = "slider";
|
|
188
|
-
input.setAttribute("autocomplete", "off");
|
|
189
|
-
input.setAttribute("color", this.color || "");
|
|
190
|
-
if (this.hasAttribute("disabled")) input.disabled = true;
|
|
191
|
-
input.addEventListener("input", null, (e) => {
|
|
192
|
-
this.setHandlePosition(e.target);
|
|
193
|
-
});
|
|
194
|
-
slider.appendChild(input);
|
|
195
|
-
if (this.hasAttribute("bubble")) {
|
|
196
|
-
slider.appendChild(output);
|
|
197
|
-
}
|
|
198
|
-
element.appendChild(label);
|
|
199
|
-
element.appendChild(start);
|
|
200
|
-
element.appendChild(slider);
|
|
201
|
-
element.appendChild(end);
|
|
202
|
-
fragment.appendChild(element);
|
|
203
|
-
this.input = input;
|
|
204
|
-
this.output = output;
|
|
205
|
-
this.syncAria();
|
|
206
|
-
return fragment;
|
|
56
|
+
let e2 = document.createDocumentFragment(), t2 = document.createElement("div");
|
|
57
|
+
t2.className = "native-slider", t2.setAttribute("part", "native");
|
|
58
|
+
let i2 = document.createElement("div");
|
|
59
|
+
i2.className = "slider";
|
|
60
|
+
let r = document.createElement("slot");
|
|
61
|
+
r.name = "label";
|
|
62
|
+
let s = document.createElement("slot");
|
|
63
|
+
s.name = "start";
|
|
64
|
+
let a = document.createElement("slot");
|
|
65
|
+
a.name = "end";
|
|
66
|
+
let n = document.createElement("output");
|
|
67
|
+
n.setAttribute("for", "slider"), n.id = "output", n.setAttribute("hidden", "");
|
|
68
|
+
let o = document.createElement("input");
|
|
69
|
+
return o.type = "range", o.min = this.min, o.max = this.max, o.step = this.step, o.value = this.value, o.id = "slider", o.name = "slider", o.part = "slider", o.setAttribute("autocomplete", "off"), o.setAttribute("color", this.color || ""), this.hasAttribute("disabled") && (o.disabled = true), o.addEventListener("input", null, (e3) => {
|
|
70
|
+
this.setHandlePosition(e3.target);
|
|
71
|
+
}), i2.appendChild(o), this.hasAttribute("bubble") && i2.appendChild(n), t2.appendChild(r), t2.appendChild(s), t2.appendChild(i2), t2.appendChild(a), e2.appendChild(t2), this.input = o, this.output = n, this.syncAria(), e2;
|
|
207
72
|
}
|
|
208
|
-
/**
|
|
209
|
-
* Handles the post-rendering logic for a custom slider component. This method performs the following tasks:
|
|
210
|
-
* - Sets the position of the handle.
|
|
211
|
-
* - Displays a bubble indicator with the current value, if the slider has a "bubble" attribute.
|
|
212
|
-
* - Dispatches initialization, movement, and change custom events for the slider input element.
|
|
213
|
-
* - Updates the bubble position and value dynamically on input changes.
|
|
214
|
-
* @returns {void} This method does not return a value.
|
|
215
|
-
*/
|
|
216
73
|
afterDraw() {
|
|
217
|
-
this.setHandlePosition()
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
this.output.
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
event.dispatchCustomEvent(this.input, "wje-slider:init", {
|
|
224
|
-
value: this.input.value,
|
|
225
|
-
output: this.output
|
|
226
|
-
});
|
|
227
|
-
event.addListener(this.input, "input", null, (e) => {
|
|
228
|
-
this.value = e.target.value;
|
|
229
|
-
event.dispatchCustomEvent(this.input, "wje-slider:move", {
|
|
230
|
-
value: e.target.value,
|
|
231
|
-
output: this.output
|
|
232
|
-
});
|
|
233
|
-
if (this.hasAttribute("bubble")) {
|
|
234
|
-
this.setBubble();
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
event.addListener(this.input, "change", null, (e) => {
|
|
238
|
-
event.dispatchCustomEvent(this.input, "wje-slider:change", {
|
|
239
|
-
value: e.target.value,
|
|
240
|
-
output: this.output
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
this.syncAria();
|
|
74
|
+
this.setHandlePosition(), this.hasAttribute("bubble") && (this.output.innerHTML = this.input.value, this.output.removeAttribute("hidden"), setTimeout(this.setBubble, 50)), t.dispatchCustomEvent(this.input, "wje-slider:init", { value: this.input.value, output: this.output }), t.addListener(this.input, "input", null, (e2) => {
|
|
75
|
+
this.value = e2.target.value, t.dispatchCustomEvent(this.input, "wje-slider:move", { value: e2.target.value, output: this.output }), this.hasAttribute("bubble") && this.setBubble();
|
|
76
|
+
}), t.addListener(this.input, "change", null, (e2) => {
|
|
77
|
+
t.dispatchCustomEvent(this.input, "wje-slider:change", { value: e2.target.value, output: this.output });
|
|
78
|
+
}), this.syncAria();
|
|
244
79
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Syncs ARIA attributes on the host element.
|
|
247
|
-
*/
|
|
248
80
|
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
|
-
});
|
|
81
|
+
this.setAriaState({ role: "slider", valuemin: this.min, valuemax: this.max, valuenow: this.value, disabled: this.hasAttribute("disabled") });
|
|
256
82
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
* @param {number} min The minimum value of the range.
|
|
260
|
-
* @param {number} max The maximum value of the range.
|
|
261
|
-
* @param {number} [value] The current value within the range. Defaults to 0 if not provided.
|
|
262
|
-
* @returns {number} The calculated percentage as a number between 0 and 100. Returns 0 if the range is invalid.
|
|
263
|
-
*/
|
|
264
|
-
getPercentage(min, max, value = 0) {
|
|
265
|
-
return Number((value - min) * 100 / (max - min)) || 0;
|
|
83
|
+
getPercentage(e2, t2, i2 = 0) {
|
|
84
|
+
return Number(100 * (i2 - e2) / (t2 - e2)) || 0;
|
|
266
85
|
}
|
|
267
86
|
}
|
|
268
|
-
|
|
87
|
+
i.define("wje-slider", i);
|
|
269
88
|
export {
|
|
270
|
-
|
|
89
|
+
i as default
|
|
271
90
|
};
|
|
272
91
|
//# sourceMappingURL=wje-slider.js.map
|
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 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,UAAK;AA4ET,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,SAAQ;AAAA,IACjB;AA6BA;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,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jC;AAEA,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,UAAS;AAAA,MAClB;AAAA,IACJ,CAAC;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,IACL,CAAC;AAED,SAAK,SAAQ;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAeA,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,EACL;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA6BA,cAAc,KAAK,KAAK,QAAQ,GAAG;AAC/B,WAAO,QAAS,QAAQ,OAAO,OAAQ,MAAM,IAAI,KAAK;AAAA,EAC1D;AACJ;ACvTA,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":["Slider","WJElement","constructor","super","className","setHandlePosition","this","input","style","backgroundSize","getPercentage","min","max","value","syncAria","setBubble","newValue","output","left","offsetWidth","innerHTML","setAttribute","hasAttribute","setTimeout","getAttribute","step","cssStyleSheet","observedAttributes","name","oldValue","includes","disabled","removeAttribute","attributeChangedCallback","setupAttributes","isShadowRoot","fragment","document","createDocumentFragment","element","createElement","slider","label","start","end","id","type","part","color","addEventListener","e","target","appendChild","afterDraw","event","dispatchCustomEvent","addListener","setAriaState","role","valuemin","valuemax","valuenow","Number","define"],"mappings":";;;;;AASe,MAAMA,UAAeC,EAAAA;AAAAA,EAKhC,cAAAC;AACIC,UAAAA;AA4EJC,qCAAY;AA8KZC,6CAAoB,MAAA;AACXC,WAAKC,UACVD,KAAKC,MAAMC,MAAMC,iBACbH,KAAKI,cAAcJ,KAAKC,MAAMI,KAAKL,KAAKC,MAAMK,KAAKN,KAAKC,MAAMM,KAAAA,IAAS,UAC3EP,KAAKQ,SAAAA;AAAAA,IAAAA;AA8BTC,qCAAY,MAAA;AACR,UAAIC,KAAWV,KAAKI,cAAcJ,KAAKC,MAAMI,KAAKL,KAAKC,MAAMK,KAAKN,KAAKC,MAAMM,KAAAA;AAC7EP,WAAKW,OAAOT,MAAMU,OAAO,QAAQF,EAAAA,QAAgB,IAAe,OAAXA,EAAAA,SAAwBV,KAAKW,OAAOE,cAAc,CAAA,OACvGb,KA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