@cas-smartdesign/lit-slider 7.0.4

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.
@@ -0,0 +1,81 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from "lit";
2
+ import { ValidationLevel } from "@cas-smartdesign/field-validation-message";
3
+ import "@cas-smartdesign/lit-input";
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ [Slider.ID]: Slider;
7
+ }
8
+ }
9
+ export interface IValueChangeEvent {
10
+ value: number;
11
+ }
12
+ export interface CustomEventMap extends HTMLElementEventMap {
13
+ "immediate-value-change": CustomEvent<IValueChangeEvent>;
14
+ "value-change": CustomEvent<IValueChangeEvent>;
15
+ }
16
+ export default interface Slider {
17
+ addEventListener<K extends keyof CustomEventMap>(event: K, listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null, options?: AddEventListenerOptions | boolean): void;
18
+ addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: AddEventListenerOptions | boolean): void;
19
+ removeEventListener<K extends keyof CustomEventMap>(type: K, listener: (this: this, ev: CustomEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void;
20
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
21
+ dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;
22
+ }
23
+ export default class Slider extends LitElement {
24
+ static readonly ID = "sd-lit-slider";
25
+ private thumbPosition;
26
+ private _value;
27
+ private _relativeValue;
28
+ min: number;
29
+ max: number;
30
+ step: number;
31
+ editable: boolean;
32
+ inputSuffix: string;
33
+ disabled: boolean;
34
+ validationMessage: string;
35
+ validationIconSrc: string;
36
+ validationLevel: ValidationLevel;
37
+ decimalSeparator: string;
38
+ private active;
39
+ private colorBlender;
40
+ private static defaultColor;
41
+ private baseColor;
42
+ private resizeObserver;
43
+ private lastKnownWidth;
44
+ private _trackContainer;
45
+ private _inputElement;
46
+ private updateAlreadyRequested;
47
+ constructor();
48
+ firstUpdated(changedProperties: any): void;
49
+ connectedCallback(): void;
50
+ disconnectedCallback(): void;
51
+ private upgradeProperty;
52
+ private updateInitialValue;
53
+ protected shouldUpdate(_changedProperties: PropertyValues): boolean;
54
+ get value(): number;
55
+ set value(newValue: number);
56
+ private roundToStep;
57
+ private setValueInternal;
58
+ get relativeValue(): number;
59
+ set relativeValue(newRelativeValue: number);
60
+ private doUpdateRelativeValue;
61
+ get colors(): Map<number, string>;
62
+ set colors(newColors: Map<number, string>);
63
+ static get styles(): import("lit").CSSResult[];
64
+ render(): TemplateResult;
65
+ private listenMoveEvents;
66
+ private onPointerMove;
67
+ private addPointerEventListener;
68
+ private updateThumbPosition;
69
+ private onInputValueChange;
70
+ private formattedValue;
71
+ private get escapedDecimalSeparator();
72
+ private get decimalSeparatorOrDefault();
73
+ private get navigatorLanguage();
74
+ private handleKeyDown;
75
+ private get inputElement();
76
+ private get trackContainer();
77
+ private get trackContainerWidth();
78
+ private fireBothValueChangeEvents;
79
+ private fireValueChange;
80
+ private useTouchEvents;
81
+ }
@@ -0,0 +1,322 @@
1
+ import { LitElement as p, css as g, unsafeCSS as v, html as d } from "lit";
2
+ import { property as o } from "lit/decorators/property.js";
3
+ import f from "hex-rgb";
4
+ import "@cas-smartdesign/lit-input";
5
+ import { Big as m } from "big.js";
6
+ class b {
7
+ constructor() {
8
+ this._rgbaColors = /* @__PURE__ */ new Map(), this._originalColors = /* @__PURE__ */ new Map();
9
+ }
10
+ get colors() {
11
+ return this._originalColors;
12
+ }
13
+ set colors(t) {
14
+ if (this._rgbaColors.clear(), this._originalColors = t, t && t.size) {
15
+ if (Array.from(t.keys()).find((r) => r < 0 || r > 1))
16
+ throw Error(
17
+ "The keys of the colors must represent the relative value where the color is fully applied."
18
+ );
19
+ t.forEach((r, s) => {
20
+ const h = this.convertFromRGBAString(r) || this.convertFromHex(r);
21
+ if (Object.keys(h).length === 0 && h.constructor === Object)
22
+ throw Error(`Cannot convert color: ${r} to rgba-color`);
23
+ this._rgbaColors.set(s, h);
24
+ });
25
+ const i = Array.from(this._rgbaColors.entries()).sort();
26
+ this._rgbaColors = new Map(i);
27
+ }
28
+ }
29
+ blend(t) {
30
+ if (!this._rgbaColors.size)
31
+ throw Error("It is not possible to blend without a color list.");
32
+ let e, i;
33
+ for (const s of this._rgbaColors)
34
+ if (e || (e = s), s[0] < t)
35
+ e = s;
36
+ else if (s[0] === t) {
37
+ e = i = s;
38
+ break;
39
+ } else {
40
+ i = s;
41
+ break;
42
+ }
43
+ i || (i = e);
44
+ const r = i[0] - e[0];
45
+ return r ? this.blendColors(e[1], i[1], (t - e[0]) / r) : this.convertToRGBAString(e[1]);
46
+ }
47
+ blendColors(t, e, i) {
48
+ return this.convertToRGBAString({
49
+ red: Math.round(t.red + (e.red - t.red) * i),
50
+ green: Math.round(t.green + (e.green - t.green) * i),
51
+ blue: Math.round(t.blue + (e.blue - t.blue) * i),
52
+ alpha: t.alpha + (e.alpha - t.alpha) * i
53
+ });
54
+ }
55
+ convertFromHex(t) {
56
+ const e = f(t);
57
+ return e.alpha > 1 && (e.alpha /= 255), e;
58
+ }
59
+ convertFromRGBAString(t) {
60
+ const e = t.match(/rgba?\((\d{1,3}), ?(\d{1,3}), ?(\d{1,3})\)?(?:, ?(\d(?:\.\d?))\))?/);
61
+ return e ? {
62
+ red: parseInt(e[1], 10),
63
+ green: parseInt(e[2], 10),
64
+ blue: parseInt(e[3], 10),
65
+ alpha: parseInt(e[4], 10) || 1
66
+ } : null;
67
+ }
68
+ transparentize(t, e) {
69
+ return this.convertToRGBAString(this.convertFromRGBAString(t), e);
70
+ }
71
+ convertToRGBAString(t, e) {
72
+ return `rgba(${t.red},${t.green},${t.blue},${e || t.alpha})`;
73
+ }
74
+ }
75
+ const C = ":host{display:block;position:relative;width:100%;height:48px;cursor:pointer;touch-action:none;contain:layout style}:host([hidden]){display:none!important}:host([disabled]){opacity:.6;cursor:default;filter:grayscale(100%)}:host([disabled]) sd-lit-input{opacity:1}#track-container{position:absolute;top:50%;left:0;height:2px;overflow:hidden}#track{position:absolute;width:100%;height:100%;transform-origin:left top;will-change:transform}:host(:focus) #thumb{top:11px;left:-14px;border-width:8px}#thumb[active]{top:7px!important;left:-18px!important;border-width:12px!important}#thumb{width:12px;height:12px;position:absolute;top:19px;left:-6px;border-radius:50%;border-width:0;background-clip:padding-box;-webkit-user-select:none;user-select:none;will-change:transform;border-style:solid}sd-lit-input{position:absolute;height:100%;width:var(--slider-suffix-width, 50px);right:0;text-align:center;outline:none;white-space:nowrap}sd-field-validation-message{position:absolute;bottom:0}";
76
+ var y = Object.defineProperty, x = Object.getOwnPropertyDescriptor, n = (u, t, e, i) => {
77
+ for (var r = i > 1 ? void 0 : i ? x(t, e) : t, s = u.length - 1, h; s >= 0; s--)
78
+ (h = u[s]) && (r = (i ? h(t, e, r) : h(r)) || r);
79
+ return i && r && y(t, e, r), r;
80
+ }, l;
81
+ const a = (l = class extends p {
82
+ constructor() {
83
+ super(), this.thumbPosition = 0, this._value = 0, this._relativeValue = 0, this.min = 0, this.max = 1, this.colorBlender = new b(), this.baseColor = l.defaultColor, this.resizeObserver = new ResizeObserver(() => {
84
+ window.requestAnimationFrame(() => {
85
+ this.lastKnownWidth !== this.trackContainerWidth && (this.lastKnownWidth = this.trackContainerWidth, this.doUpdateRelativeValue(this._relativeValue, !0));
86
+ });
87
+ });
88
+ }
89
+ firstUpdated(t) {
90
+ super.firstUpdated(t), this.updateInitialValue(), this.addEventListener(
91
+ this.useTouchEvents() ? "touchstart" : "pointerdown",
92
+ (e) => {
93
+ !this.hasAttribute("disabled") && e.composedPath().indexOf(this.inputElement) === -1 && (e.preventDefault(), e.pointerId && this.setPointerCapture(e.pointerId), this.focus(), this.listenMoveEvents(
94
+ e.clientX || e.changedTouches[0].clientX
95
+ ));
96
+ }
97
+ ), this.addEventListener("keydown", this.handleKeyDown, !0), this.setAttribute("aria-valuemin", this.min.toString()), this.setAttribute("aria-valuemax", this.max.toString()), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0");
98
+ }
99
+ connectedCallback() {
100
+ super.connectedCallback(), ["colors", "min", "max", "step", "editable", "inputSuffix", "value"].forEach((t) => {
101
+ this.upgradeProperty(t);
102
+ }), this.resizeObserver.observe(this);
103
+ }
104
+ disconnectedCallback() {
105
+ super.disconnectedCallback(), this.lastKnownWidth = void 0, this.resizeObserver.disconnect();
106
+ }
107
+ upgradeProperty(t) {
108
+ if (Object.prototype.hasOwnProperty.call(this, t)) {
109
+ const e = this[t];
110
+ delete this[t], this[t] = e;
111
+ }
112
+ }
113
+ updateInitialValue() {
114
+ const t = Number.parseFloat(this.getAttribute("value")) || this._value;
115
+ this.setValueInternal(t) && (this.inputElement && (this.inputElement.value = this.formattedValue()), this.fireBothValueChangeEvents());
116
+ }
117
+ shouldUpdate(t) {
118
+ return t.has("step") && this.setValueInternal(this._value) && this.fireBothValueChangeEvents(), super.shouldUpdate(t);
119
+ }
120
+ get value() {
121
+ return this._value;
122
+ }
123
+ set value(t) {
124
+ this.setValueInternal(t) && this.fireBothValueChangeEvents();
125
+ }
126
+ roundToStep(t) {
127
+ let e = Number.parseFloat(t);
128
+ if (Number.isNaN(e))
129
+ return this._value;
130
+ if (this.step) {
131
+ const i = m(e).div(this.step).round().mul(this.step);
132
+ e = Number.parseFloat(i.toString());
133
+ }
134
+ return e;
135
+ }
136
+ setValueInternal(t) {
137
+ const e = this.roundToStep(t);
138
+ if (this._value !== e) {
139
+ const i = this._value;
140
+ return this._value = e, this.relativeValue = (e - this.min) / (this.max - this.min), this.setAttribute("aria-valuenow", this._value.toString()), this.requestUpdate("value", i), !0;
141
+ }
142
+ return !1;
143
+ }
144
+ get relativeValue() {
145
+ return this._relativeValue;
146
+ }
147
+ set relativeValue(t) {
148
+ this._relativeValue !== t && this.doUpdateRelativeValue(t);
149
+ }
150
+ doUpdateRelativeValue(t, e) {
151
+ this._relativeValue = t, this.thumbPosition = Math.min(Math.max(0, t), 1) * this.trackContainerWidth;
152
+ const i = this.min + (this.max - this.min) * this._relativeValue;
153
+ this.setValueInternal(i), !e && this.colors && this.colors.size && (this.baseColor = this.colorBlender.blend(this._relativeValue));
154
+ }
155
+ get colors() {
156
+ return this.colorBlender.colors;
157
+ }
158
+ set colors(t) {
159
+ this.colorBlender.colors = t, this.colors && this.colors.size ? this.baseColor = this.colorBlender.blend(this._relativeValue) : this.baseColor = l.defaultColor;
160
+ }
161
+ static get styles() {
162
+ return [
163
+ g`
164
+ ${v(C)}
165
+ `
166
+ ];
167
+ }
168
+ render() {
169
+ const t = this.colorBlender.transparentize(this.baseColor, 0.26), e = `background-color:${t}; right: ${this.editable ? "calc(var(--slider-suffix-width, 50px) + 8px)" : "0"}`, i = `transform: scaleX(${this.relativeValue}); background-color:${this.baseColor};`, r = `transform: translateX(${this.thumbPosition}px); background-color:${this.baseColor}; border-color:${t};`;
170
+ return d`
171
+ <div id="track-container" style="${e}">
172
+ <div id="track" style="${i}"></div>
173
+ </div>
174
+ <div id="thumb" ?active="${this.active}" style="${r}"></div>
175
+ ${this.editable && d`
176
+ <sd-lit-input
177
+ .value="${this.formattedValue()}"
178
+ @value-change="${this.onInputValueChange}"
179
+ ?disabled="${this.disabled}"
180
+ ><span slot="suffix">${this.inputSuffix}</span>
181
+ </sd-lit-input>
182
+ `}
183
+ ${this.validationMessage && d`
184
+ <sd-field-validation-message
185
+ .message="${this.validationMessage}"
186
+ .icon="${this.validationIconSrc}"
187
+ .level="${this.validationLevel}"
188
+ >
189
+ </sd-field-validation-message>
190
+ `}
191
+ `;
192
+ }
193
+ listenMoveEvents(t) {
194
+ this.active = !0, this.onPointerMove(t);
195
+ const e = [], i = (s) => {
196
+ s.stopPropagation(), s.preventDefault(), this.onPointerMove(s.clientX || s.changedTouches && s.changedTouches[0].clientX);
197
+ }, r = () => {
198
+ this.active = !1, e.forEach((s) => s.remove()), this.fireValueChange();
199
+ };
200
+ this.useTouchEvents() ? (e.push(this.addPointerEventListener("touchmove", i)), e.push(this.addPointerEventListener("touchend", r)), e.push(this.addPointerEventListener("touchcancel", r))) : (e.push(this.addPointerEventListener("pointermove", i)), e.push(this.addPointerEventListener("pointerup", r)));
201
+ }
202
+ onPointerMove(t) {
203
+ this.updateAlreadyRequested || (this.updateAlreadyRequested = !0, window.requestAnimationFrame(async () => {
204
+ this.updateAlreadyRequested = !1, this.updateThumbPosition(t);
205
+ const e = this.relativeValue;
206
+ this.relativeValue = this.thumbPosition / this.trackContainerWidth, this.relativeValue !== e && (await this.updateComplete, this.fireValueChange(!0), this.active || this.fireValueChange());
207
+ }));
208
+ }
209
+ addPointerEventListener(t, e) {
210
+ return window.addEventListener(t, e, !0), {
211
+ remove: () => {
212
+ window.removeEventListener(t, e, !0);
213
+ }
214
+ };
215
+ }
216
+ updateThumbPosition(t) {
217
+ if (this.thumbPosition = Math.min(
218
+ this.trackContainerWidth,
219
+ Math.max(0, t - this.getBoundingClientRect().left)
220
+ ), this.max - this.min > 1) {
221
+ const e = this.trackContainerWidth / (this.max - this.min), i = this.thumbPosition % e;
222
+ i && (i < e / 2 ? this.thumbPosition -= i : this.thumbPosition += e - i);
223
+ }
224
+ }
225
+ onInputValueChange(t) {
226
+ this.value = Number(t.detail.value.replace(RegExp(this.escapedDecimalSeparator), ".")), String(this.value) !== String(t.detail.value) && (t.target.value = String(this.value));
227
+ }
228
+ formattedValue() {
229
+ return this.value.toString().replace(/\./, this.decimalSeparatorOrDefault);
230
+ }
231
+ get escapedDecimalSeparator() {
232
+ return this.decimalSeparatorOrDefault.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
233
+ }
234
+ get decimalSeparatorOrDefault() {
235
+ return this.decimalSeparator || 1.1.toLocaleString(this.navigatorLanguage).substring(1, 2);
236
+ }
237
+ get navigatorLanguage() {
238
+ return navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.userLanguage || navigator.language || navigator.browserLanguage || "en";
239
+ }
240
+ handleKeyDown(t) {
241
+ if (!this.hasAttribute("disabled") && t.composedPath().indexOf(this.inputElement) === -1) {
242
+ let e = this.step || (this.max - this.min) / 100;
243
+ switch (this.max - this.min > 1 && (e = Math.round(e) || 1), t.keyCode) {
244
+ case 37:
245
+ case 40:
246
+ this.value = Math.max(this.value - e, this.min), t.preventDefault();
247
+ break;
248
+ case 38:
249
+ case 39:
250
+ this.value = Math.min(this.value + e, this.max), t.preventDefault();
251
+ break;
252
+ }
253
+ }
254
+ }
255
+ get inputElement() {
256
+ return this._inputElement || (this._inputElement = this.shadowRoot.querySelector("sd-lit-input")), this._inputElement;
257
+ }
258
+ get trackContainer() {
259
+ return this._trackContainer || (this._trackContainer = this.shadowRoot.querySelector("#track-container")), this._trackContainer;
260
+ }
261
+ get trackContainerWidth() {
262
+ return this.trackContainer && this.trackContainer.offsetWidth;
263
+ }
264
+ fireBothValueChangeEvents() {
265
+ this.fireValueChange(!0), this.fireValueChange();
266
+ }
267
+ fireValueChange(t) {
268
+ this.dispatchEvent(
269
+ new CustomEvent(`${t ? "immediate-" : ""}value-change`, {
270
+ detail: { value: this.value }
271
+ })
272
+ );
273
+ }
274
+ useTouchEvents() {
275
+ return this.hasAttribute("use-touch-events");
276
+ }
277
+ }, l.ID = "sd-lit-slider", l.defaultColor = "rgb(20, 103, 186)", l);
278
+ n([
279
+ o({ type: Number })
280
+ ], a.prototype, "thumbPosition", 2);
281
+ n([
282
+ o({ type: Number, reflect: !0 })
283
+ ], a.prototype, "min", 2);
284
+ n([
285
+ o({ type: Number, reflect: !0 })
286
+ ], a.prototype, "max", 2);
287
+ n([
288
+ o({ type: Number, reflect: !0 })
289
+ ], a.prototype, "step", 2);
290
+ n([
291
+ o({ type: Boolean, reflect: !0 })
292
+ ], a.prototype, "editable", 2);
293
+ n([
294
+ o({ type: String, reflect: !0 })
295
+ ], a.prototype, "inputSuffix", 2);
296
+ n([
297
+ o({ type: Boolean, reflect: !0 })
298
+ ], a.prototype, "disabled", 2);
299
+ n([
300
+ o({ type: String, attribute: !0 })
301
+ ], a.prototype, "validationMessage", 2);
302
+ n([
303
+ o({ type: String, attribute: !0 })
304
+ ], a.prototype, "validationIconSrc", 2);
305
+ n([
306
+ o({ type: String, attribute: !0 })
307
+ ], a.prototype, "validationLevel", 2);
308
+ n([
309
+ o({ type: String, attribute: !0 })
310
+ ], a.prototype, "decimalSeparator", 2);
311
+ n([
312
+ o({ type: Boolean })
313
+ ], a.prototype, "active", 2);
314
+ n([
315
+ o()
316
+ ], a.prototype, "baseColor", 2);
317
+ let c = a;
318
+ customElements.get(c.ID) || customElements.define(c.ID, c);
319
+ export {
320
+ c as default
321
+ };
322
+ //# sourceMappingURL=slider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.mjs","sources":["../colorblender.ts","../slider.ts"],"sourcesContent":["import hexRgb from \"hex-rgb\";\n\nexport interface IColor {\n red: number;\n green: number;\n blue: number;\n alpha: number;\n}\n\nexport default class ColorBlender {\n private _rgbaColors: Map<number, IColor> = new Map();\n private _originalColors: Map<number, string> = new Map();\n\n public get colors(): Map<number, string> {\n return this._originalColors;\n }\n\n public set colors(newColors: Map<number, string>) {\n this._rgbaColors.clear();\n this._originalColors = newColors;\n if (newColors && newColors.size) {\n const invalidColorKey = Array.from(newColors.keys()).find((value) => {\n return value < 0 || value > 1;\n });\n if (invalidColorKey) {\n throw Error(\n \"The keys of the colors must represent the relative value where the color is fully applied.\",\n );\n }\n newColors.forEach((value, key) => {\n const color: IColor = this.convertFromRGBAString(value) || this.convertFromHex(value);\n if (Object.keys(color).length === 0 && color.constructor === Object) {\n throw Error(`Cannot convert color: ${value} to rgba-color`);\n } else {\n this._rgbaColors.set(key, color);\n }\n });\n const sortedEntries = Array.from(this._rgbaColors.entries()).sort();\n this._rgbaColors = new Map(sortedEntries);\n }\n }\n\n public blend(relativeValue: number): string {\n if (!this._rgbaColors.size) {\n throw Error(\"It is not possible to blend without a color list.\");\n }\n let leftColor: [number, IColor];\n let rightColor: [number, IColor];\n for (const entry of this._rgbaColors) {\n if (!leftColor) {\n leftColor = entry;\n }\n if (entry[0] < relativeValue) {\n leftColor = entry;\n } else if (entry[0] === relativeValue) {\n leftColor = rightColor = entry;\n break;\n } else {\n rightColor = entry;\n break;\n }\n }\n if (!rightColor) {\n rightColor = leftColor;\n }\n const diff = rightColor[0] - leftColor[0];\n if (diff) {\n return this.blendColors(leftColor[1], rightColor[1], (relativeValue - leftColor[0]) / diff);\n } else {\n return this.convertToRGBAString(leftColor[1]);\n }\n }\n\n private blendColors(colorA: IColor, colorB: IColor, relativeOffsetFromA: number): string {\n return this.convertToRGBAString({\n red: Math.round(colorA.red + (colorB.red - colorA.red) * relativeOffsetFromA),\n green: Math.round(colorA.green + (colorB.green - colorA.green) * relativeOffsetFromA),\n blue: Math.round(colorA.blue + (colorB.blue - colorA.blue) * relativeOffsetFromA),\n alpha: colorA.alpha + (colorB.alpha - colorA.alpha) * relativeOffsetFromA,\n });\n }\n\n private convertFromHex(hexColor: string): IColor {\n const color = hexRgb(hexColor);\n if (color.alpha > 1) {\n color.alpha /= 255;\n }\n return color;\n }\n\n private convertFromRGBAString(rgbaColor: string): IColor {\n const match = rgbaColor.match(/rgba?\\((\\d{1,3}), ?(\\d{1,3}), ?(\\d{1,3})\\)?(?:, ?(\\d(?:\\.\\d?))\\))?/);\n return match\n ? {\n red: parseInt(match[1], 10),\n green: parseInt(match[2], 10),\n blue: parseInt(match[3], 10),\n alpha: parseInt(match[4], 10) || 1,\n }\n : null;\n }\n\n public transparentize(color: string, alpha: number): string {\n return this.convertToRGBAString(this.convertFromRGBAString(color), alpha);\n }\n\n private convertToRGBAString(color: IColor, alpha?: number): string {\n return `rgba(${color.red},${color.green},${color.blue},${alpha || color.alpha})`;\n }\n}\n","import { LitElement, html, PropertyValues, unsafeCSS, TemplateResult, css } from \"lit\";\nimport { property } from \"lit/decorators/property.js\";\nimport ColorBlender from \"./colorblender\";\nimport { ValidationLevel } from \"@cas-smartdesign/field-validation-message\";\nimport SDInput from \"@cas-smartdesign/lit-input\";\nimport \"@cas-smartdesign/lit-input\";\nimport { Big } from \"big.js\";\n\ndeclare global {\n interface HTMLElementTagNameMap {\n [Slider.ID]: Slider;\n }\n}\n\nimport style from \"./style.scss?inline\";\n\ninterface IEventListenerRegistration {\n remove();\n}\n\nexport interface IValueChangeEvent {\n value: number;\n}\n\nexport interface CustomEventMap extends HTMLElementEventMap {\n \"immediate-value-change\": CustomEvent<IValueChangeEvent>;\n \"value-change\": CustomEvent<IValueChangeEvent>;\n}\n\nexport default interface Slider {\n addEventListener<K extends keyof CustomEventMap>(\n event: K,\n listener: ((this: this, ev: CustomEventMap[K]) => unknown) | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n addEventListener(\n type: string,\n callback: EventListenerOrEventListenerObject | null,\n options?: AddEventListenerOptions | boolean,\n ): void;\n removeEventListener<K extends keyof CustomEventMap>(\n type: K,\n listener: (this: this, ev: CustomEventMap[K]) => unknown,\n options?: boolean | EventListenerOptions,\n ): void;\n removeEventListener(\n type: string,\n listener: EventListenerOrEventListenerObject,\n options?: boolean | EventListenerOptions,\n ): void;\n dispatchEvent<EventType extends CustomEventMap[keyof CustomEventMap]>(event: EventType): boolean;\n}\n\nexport default class Slider extends LitElement {\n public static readonly ID = \"sd-lit-slider\";\n\n @property({ type: Number })\n private thumbPosition = 0;\n private _value = 0;\n private _relativeValue = 0;\n\n @property({ type: Number, reflect: true })\n public min = 0;\n @property({ type: Number, reflect: true })\n public max = 1;\n @property({ type: Number, reflect: true })\n public step: number;\n @property({ type: Boolean, reflect: true })\n public editable: boolean;\n @property({ type: String, reflect: true })\n public inputSuffix: string;\n @property({ type: Boolean, reflect: true })\n public disabled: boolean;\n @property({ type: String, attribute: true })\n public validationMessage: string;\n @property({ type: String, attribute: true })\n public validationIconSrc: string;\n @property({ type: String, attribute: true })\n public validationLevel: ValidationLevel;\n @property({ type: String, attribute: true })\n public decimalSeparator: string;\n\n @property({ type: Boolean })\n private active: boolean;\n\n private colorBlender: ColorBlender = new ColorBlender();\n private static defaultColor = \"rgb(20, 103, 186)\";\n @property()\n private baseColor: string = Slider.defaultColor;\n\n private resizeObserver: ResizeObserver;\n private lastKnownWidth: number;\n private _trackContainer: HTMLElement;\n private _inputElement: SDInput;\n private updateAlreadyRequested: boolean;\n\n constructor() {\n super();\n this.resizeObserver = new ResizeObserver(() => {\n window.requestAnimationFrame(() => {\n if (this.lastKnownWidth !== this.trackContainerWidth) {\n this.lastKnownWidth = this.trackContainerWidth;\n this.doUpdateRelativeValue(this._relativeValue, true);\n }\n });\n });\n }\n\n public firstUpdated(changedProperties) {\n super.firstUpdated(changedProperties);\n\n this.updateInitialValue();\n\n this.addEventListener(\n this.useTouchEvents() ? \"touchstart\" : \"pointerdown\",\n (event: TouchEvent | PointerEvent) => {\n if (!this.hasAttribute(\"disabled\") && event.composedPath().indexOf(this.inputElement) === -1) {\n event.preventDefault();\n if ((event as PointerEvent).pointerId) {\n this.setPointerCapture((event as PointerEvent).pointerId);\n }\n this.focus();\n this.listenMoveEvents(\n (event as PointerEvent).clientX || (event as TouchEvent).changedTouches[0].clientX,\n );\n }\n },\n );\n this.addEventListener(\"keydown\", this.handleKeyDown, true);\n this.setAttribute(\"aria-valuemin\", this.min.toString());\n this.setAttribute(\"aria-valuemax\", this.max.toString());\n if (!this.hasAttribute(\"tabindex\")) {\n this.setAttribute(\"tabindex\", \"0\");\n }\n }\n\n public connectedCallback() {\n super.connectedCallback();\n [\"colors\", \"min\", \"max\", \"step\", \"editable\", \"inputSuffix\", \"value\"].forEach((p) => {\n this.upgradeProperty(p);\n });\n this.resizeObserver.observe(this);\n }\n\n public disconnectedCallback() {\n super.disconnectedCallback();\n this.lastKnownWidth = undefined;\n this.resizeObserver.disconnect();\n }\n\n private upgradeProperty(propertyName: string): void {\n if (Object.prototype.hasOwnProperty.call(this, propertyName)) {\n const value = this[propertyName];\n delete this[propertyName];\n this[propertyName] = value;\n }\n }\n\n private updateInitialValue(): void {\n const initialValue = Number.parseFloat(this.getAttribute(\"value\")) || this._value;\n if (this.setValueInternal(initialValue)) {\n if (this.inputElement) {\n this.inputElement.value = this.formattedValue();\n }\n this.fireBothValueChangeEvents();\n }\n }\n\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n if (_changedProperties.has(\"step\")) {\n // Ensure value is rounded based on step.\n if (this.setValueInternal(this._value)) {\n this.fireBothValueChangeEvents();\n }\n }\n return super.shouldUpdate(_changedProperties);\n }\n\n public get value(): number {\n return this._value;\n }\n\n public set value(newValue: number) {\n const hasChanged = this.setValueInternal(newValue);\n if (hasChanged) {\n this.fireBothValueChangeEvents();\n }\n }\n\n private roundToStep(rawValue: number): number {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let roundedValue = Number.parseFloat(rawValue as any);\n if (Number.isNaN(roundedValue)) {\n return this._value;\n }\n if (this.step) {\n const coercedBigDecimal = Big(roundedValue).div(this.step).round().mul(this.step);\n roundedValue = Number.parseFloat(coercedBigDecimal.toString());\n }\n return roundedValue;\n }\n\n private setValueInternal(newValue: number): boolean {\n const roundedValue = this.roundToStep(newValue);\n if (this._value !== roundedValue) {\n const oldValue = this._value;\n this._value = roundedValue;\n this.relativeValue = (roundedValue - this.min) / (this.max - this.min);\n this.setAttribute(\"aria-valuenow\", this._value.toString());\n this.requestUpdate(\"value\", oldValue);\n return true;\n }\n return false;\n }\n\n get relativeValue() {\n return this._relativeValue;\n }\n\n set relativeValue(newRelativeValue: number) {\n if (this._relativeValue !== newRelativeValue) {\n this.doUpdateRelativeValue(newRelativeValue);\n }\n }\n\n private doUpdateRelativeValue(newRelativeValue: number, skipColorUpdate?: boolean) {\n this._relativeValue = newRelativeValue;\n this.thumbPosition = Math.min(Math.max(0, newRelativeValue), 1) * this.trackContainerWidth;\n const newValueBasedOnRelativeValue = this.min + (this.max - this.min) * this._relativeValue;\n this.setValueInternal(newValueBasedOnRelativeValue);\n if (!skipColorUpdate && this.colors && this.colors.size) {\n this.baseColor = this.colorBlender.blend(this._relativeValue);\n }\n }\n\n public get colors(): Map<number, string> {\n return this.colorBlender.colors;\n }\n\n public set colors(newColors: Map<number, string>) {\n this.colorBlender.colors = newColors;\n if (this.colors && this.colors.size) {\n this.baseColor = this.colorBlender.blend(this._relativeValue);\n } else {\n this.baseColor = Slider.defaultColor;\n }\n }\n\n static get styles() {\n return [\n css`\n ${unsafeCSS(style)}\n `,\n ];\n }\n\n public render(): TemplateResult {\n const trackBackgroundColor = this.colorBlender.transparentize(this.baseColor, 0.26);\n const trackContainerStyle = `background-color:${trackBackgroundColor}; right: ${\n this.editable ? \"calc(var(--slider-suffix-width, 50px) + 8px)\" : \"0\"\n }`;\n const trackStyle = `transform: scaleX(${this.relativeValue}); background-color:${this.baseColor};`;\n const thumbStyle = `transform: translateX(${this.thumbPosition}px); background-color:${this.baseColor}; border-color:${trackBackgroundColor};`;\n return html`\n <div id=\"track-container\" style=\"${trackContainerStyle}\">\n <div id=\"track\" style=\"${trackStyle}\"></div>\n </div>\n <div id=\"thumb\" ?active=\"${this.active}\" style=\"${thumbStyle}\"></div>\n ${this.editable &&\n html`\n <sd-lit-input\n .value=\"${this.formattedValue()}\"\n @value-change=\"${this.onInputValueChange}\"\n ?disabled=\"${this.disabled}\"\n ><span slot=\"suffix\">${this.inputSuffix}</span>\n </sd-lit-input>\n `}\n ${this.validationMessage &&\n html`\n <sd-field-validation-message\n .message=\"${this.validationMessage}\"\n .icon=\"${this.validationIconSrc}\"\n .level=\"${this.validationLevel}\"\n >\n </sd-field-validation-message>\n `}\n `;\n }\n\n private listenMoveEvents(currentClientX: number) {\n this.active = true;\n this.onPointerMove(currentClientX);\n\n const eventListenersToRemove: IEventListenerRegistration[] = [];\n const pointerMoveListener = (event) => {\n event.stopPropagation();\n event.preventDefault();\n this.onPointerMove(event.clientX || (event.changedTouches && event.changedTouches[0].clientX));\n };\n const pointerUpListener = () => {\n this.active = false;\n eventListenersToRemove.forEach((reg) => reg.remove());\n this.fireValueChange();\n };\n if (this.useTouchEvents()) {\n eventListenersToRemove.push(this.addPointerEventListener(\"touchmove\", pointerMoveListener));\n eventListenersToRemove.push(this.addPointerEventListener(\"touchend\", pointerUpListener));\n eventListenersToRemove.push(this.addPointerEventListener(\"touchcancel\", pointerUpListener));\n } else {\n eventListenersToRemove.push(this.addPointerEventListener(\"pointermove\", pointerMoveListener));\n eventListenersToRemove.push(this.addPointerEventListener(\"pointerup\", pointerUpListener));\n }\n }\n\n private onPointerMove(clientX: number): void {\n if (this.updateAlreadyRequested) {\n return;\n }\n this.updateAlreadyRequested = true;\n window.requestAnimationFrame(async () => {\n this.updateAlreadyRequested = false;\n this.updateThumbPosition(clientX);\n const previousValue = this.relativeValue;\n this.relativeValue = this.thumbPosition / this.trackContainerWidth;\n if (this.relativeValue !== previousValue) {\n await this.updateComplete;\n this.fireValueChange(true);\n if (!this.active) {\n this.fireValueChange();\n }\n }\n });\n }\n\n private addPointerEventListener(type: string, listener: EventListener): IEventListenerRegistration {\n window.addEventListener(type, listener, true);\n return {\n remove: () => {\n window.removeEventListener(type, listener, true);\n },\n };\n }\n\n private updateThumbPosition(clientX: number): void {\n this.thumbPosition = Math.min(\n this.trackContainerWidth,\n Math.max(0, clientX - this.getBoundingClientRect().left),\n );\n if (this.max - this.min > 1) {\n // Enforce integer steps by pointer move events. Fixes #231868\n const thumbStepForIntegerOffset = this.trackContainerWidth / (this.max - this.min);\n const thumbPositionError = this.thumbPosition % thumbStepForIntegerOffset;\n if (thumbPositionError) {\n if (thumbPositionError < thumbStepForIntegerOffset / 2) {\n this.thumbPosition -= thumbPositionError;\n } else {\n this.thumbPosition += thumbStepForIntegerOffset - thumbPositionError;\n }\n }\n }\n }\n\n private onInputValueChange(event: CustomEvent) {\n this.value = Number(event.detail.value.replace(RegExp(this.escapedDecimalSeparator), \".\"));\n if (String(this.value) !== String(event.detail.value)) {\n (event.target as SDInput).value = String(this.value);\n }\n }\n\n private formattedValue(): string {\n return this.value.toString().replace(/\\./, this.decimalSeparatorOrDefault);\n }\n\n private get escapedDecimalSeparator(): string {\n return this.decimalSeparatorOrDefault.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, \"\\\\$&\");\n }\n\n private get decimalSeparatorOrDefault(): string {\n return this.decimalSeparator || Number(1.1).toLocaleString(this.navigatorLanguage).substring(1, 2);\n }\n\n private get navigatorLanguage(): string {\n if (navigator.languages && navigator.languages.length) {\n return navigator.languages[0];\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (navigator as any).userLanguage || navigator.language || (navigator as any).browserLanguage || \"en\";\n }\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n if (!this.hasAttribute(\"disabled\") && event.composedPath().indexOf(this.inputElement) === -1) {\n let offset = this.step || (this.max - this.min) / 100;\n if (this.max - this.min > 1) {\n // Enforce integer steps by keydown events. Fixes #231868\n offset = Math.round(offset) || 1;\n }\n switch (event.keyCode) {\n case 37:\n case 40:\n this.value = Math.max(this.value - offset, this.min);\n event.preventDefault();\n break;\n case 38:\n case 39:\n this.value = Math.min(this.value + offset, this.max);\n event.preventDefault();\n break;\n }\n }\n }\n\n private get inputElement(): SDInput {\n if (!this._inputElement) {\n this._inputElement = this.shadowRoot.querySelector(\"sd-lit-input\");\n }\n return this._inputElement;\n }\n\n private get trackContainer(): HTMLElement {\n if (!this._trackContainer) {\n this._trackContainer = this.shadowRoot.querySelector(\"#track-container\");\n }\n return this._trackContainer;\n }\n\n private get trackContainerWidth(): number {\n return this.trackContainer && this.trackContainer.offsetWidth;\n }\n\n private fireBothValueChangeEvents(): void {\n this.fireValueChange(true);\n this.fireValueChange();\n }\n\n private fireValueChange(immediate?: boolean): void {\n this.dispatchEvent(\n new CustomEvent<IValueChangeEvent>(`${immediate ? \"immediate-\" : \"\"}value-change`, {\n detail: { value: this.value },\n }),\n );\n }\n\n private useTouchEvents(): boolean {\n return this.hasAttribute(\"use-touch-events\");\n }\n}\n\nif (!customElements.get(Slider.ID)) {\n customElements.define(Slider.ID, Slider);\n}\n"],"names":["ColorBlender","newColors","value","key","color","sortedEntries","relativeValue","leftColor","rightColor","entry","diff","colorA","colorB","relativeOffsetFromA","hexColor","hexRgb","rgbaColor","match","alpha","_Slider","_a","LitElement","changedProperties","event","p","propertyName","initialValue","_changedProperties","newValue","rawValue","roundedValue","coercedBigDecimal","Big","oldValue","newRelativeValue","skipColorUpdate","newValueBasedOnRelativeValue","css","unsafeCSS","style","trackBackgroundColor","trackContainerStyle","trackStyle","thumbStyle","html","currentClientX","eventListenersToRemove","pointerMoveListener","pointerUpListener","reg","clientX","previousValue","type","listener","thumbStepForIntegerOffset","thumbPositionError","offset","immediate","__decorateClass","property","Slider"],"mappings":";;;;;AASA,MAAqBA,EAAa;AAAA,EAAlC,cAAA;AACY,SAAA,kCAAuC,OACvC,KAAA,sCAA2C;EAAI;AAAA,EAEvD,IAAW,SAA8B;AACrC,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAW,OAAOC,GAAgC;AAG1C,QAFJ,KAAK,YAAY,SACjB,KAAK,kBAAkBA,GACnBA,KAAaA,EAAU,MAAM;AAI7B,UAHwB,MAAM,KAAKA,EAAU,MAAM,EAAE,KAAK,CAACC,MAChDA,IAAQ,KAAKA,IAAQ,CAC/B;AAES,cAAA;AAAA,UACF;AAAA,QAAA;AAGE,MAAAD,EAAA,QAAQ,CAACC,GAAOC,MAAQ;AAC9B,cAAMC,IAAgB,KAAK,sBAAsBF,CAAK,KAAK,KAAK,eAAeA,CAAK;AAChF,YAAA,OAAO,KAAKE,CAAK,EAAE,WAAW,KAAKA,EAAM,gBAAgB;AACnD,gBAAA,MAAM,yBAAyBF,CAAK,gBAAgB;AAErD,aAAA,YAAY,IAAIC,GAAKC,CAAK;AAAA,MACnC,CACH;AACK,YAAAC,IAAgB,MAAM,KAAK,KAAK,YAAY,QAAQ,CAAC,EAAE;AACxD,WAAA,cAAc,IAAI,IAAIA,CAAa;AAAA,IAC5C;AAAA,EACJ;AAAA,EAEO,MAAMC,GAA+B;AACpC,QAAA,CAAC,KAAK,YAAY;AAClB,YAAM,MAAM,mDAAmD;AAE/D,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