@umbraco-ui/uui-range-slider 1.2.1 → 1.3.0-rc.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.
@@ -3,4 +3,5 @@ import { UUIRangeSliderElement } from './uui-range-slider.element';
3
3
  export declare class UUIRangeSliderEvent extends UUIEvent<{}, UUIRangeSliderElement> {
4
4
  static readonly INPUT = "input";
5
5
  static readonly CHANGE = "change";
6
+ constructor(evName: string, eventInit?: any | null);
6
7
  }
package/lib/index.js CHANGED
@@ -5,7 +5,26 @@ import { LitElement, html, svg, nothing, css } from 'lit';
5
5
  import { property, state, query } from 'lit/decorators.js';
6
6
  import { UUIEvent } from '@umbraco-ui/uui-base/lib/events';
7
7
 
8
+ var __defProp$1 = Object.defineProperty;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
8
24
  class UUIRangeSliderEvent extends UUIEvent {
25
+ constructor(evName, eventInit = {}) {
26
+ super(evName, __spreadValues(__spreadValues({}, { bubbles: true }), eventInit));
27
+ }
9
28
  }
10
29
  UUIRangeSliderEvent.INPUT = "input";
11
30
  UUIRangeSliderEvent.CHANGE = "change";
@@ -38,6 +57,7 @@ var _setValue, setValue_fn;
38
57
  const TRACK_PADDING = 12;
39
58
  const STEP_MIN_WIDTH = 24;
40
59
  let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
60
+ /** Constructor */
41
61
  constructor() {
42
62
  super();
43
63
  __privateAdd(this, _setValue);
@@ -53,6 +73,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
53
73
  this._startPos = 0;
54
74
  this._startLow = 0;
55
75
  this._startHigh = 0;
76
+ /** Mouse events */
56
77
  this._onMouseDown = (e) => {
57
78
  e.preventDefault();
58
79
  if (this.disabled)
@@ -85,6 +106,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
85
106
  window.removeEventListener("mouseup", this._onMouseUp);
86
107
  window.removeEventListener("mousemove", this._onMouseMove);
87
108
  };
109
+ /** Touch / mobile events */
88
110
  this._onTouchStart = (e) => {
89
111
  e.preventDefault();
90
112
  if (this.disabled)
@@ -204,6 +226,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
204
226
  this.submit();
205
227
  }
206
228
  }
229
+ /** Thumb position */
207
230
  _sliderLowThumbPosition() {
208
231
  const ratio = (this.valueLow - this.min) / (this.max - this.min);
209
232
  const valueLowPercent = `${Math.floor(ratio * 1e5) / 1e3}%`;
@@ -214,12 +237,14 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
214
237
  const valueHighPercent = `${Math.floor(ratio * 1e5) / 1e3}%`;
215
238
  return valueHighPercent;
216
239
  }
240
+ /** Coloring of the line between thumbs */
217
241
  _fillColor() {
218
242
  const percentStart = (this.valueLow - this.min) / (this.max - this.min) * 100;
219
243
  const percentEnd = (this.valueHigh - this.min) / (this.max - this.min) * 100;
220
244
  this._innerColor.style.left = `${percentStart}%`;
221
245
  this._innerColor.style.right = `${100 - percentEnd}%`;
222
246
  }
247
+ /** Moving thumb */
223
248
  _moveThumb(pageX) {
224
249
  const value = this._getValue(pageX);
225
250
  if (value >= this.valueHigh)
@@ -230,11 +255,13 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
230
255
  this._validateValueBasedOnCurrentThumb(value)
231
256
  );
232
257
  }
258
+ /** */
233
259
  _stop() {
234
260
  this._grabbingBoth = false;
235
261
  this.pristine = false;
236
262
  this.dispatchEvent(new UUIRangeSliderEvent(UUIRangeSliderEvent.CHANGE));
237
263
  }
264
+ /** The latest thumb in use */
238
265
  _setThumb(target) {
239
266
  this._currentThumbFocus = target === this._thumbLow ? "low" : "high";
240
267
  this._currentThumbFocus === "low" ? this._currentInputFocus = this._inputLow : this._currentInputFocus = this._inputHigh;
@@ -243,6 +270,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
243
270
  _setValueBasedOnCurrentThumb(val) {
244
271
  this._currentThumbFocus === "low" ? this.valueLow = val : this.valueHigh = val;
245
272
  }
273
+ /** Get the value depends on where clicked/touched */
246
274
  _getValue(pageX) {
247
275
  const mouseXPosition = pageX - this._innerTrack.getBoundingClientRect().left;
248
276
  const clickPercent = mouseXPosition / (this._trackWidth - TRACK_PADDING * 2);
@@ -286,6 +314,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
286
314
  newHigh = this.maxGap ? this._validateHighByMaxGap(newHigh) : newHigh;
287
315
  return newHigh;
288
316
  }
317
+ /** Methods when moving both thumbs */
289
318
  _saveStartPoint(pageX, lowVal, highVal) {
290
319
  this._startPos = pageX;
291
320
  this._startLow = lowVal;
@@ -310,6 +339,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
310
339
  const validatedHigh = high < this.max ? high : this.max;
311
340
  return { low: validatedLow, high: validatedHigh };
312
341
  }
342
+ /** CHANGE AND INPUT EVENT LISTENERS */
313
343
  _onChange(e) {
314
344
  e.stopPropagation();
315
345
  this.pristine = false;
@@ -345,6 +375,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
345
375
  this._trackWidth = this._outerTrack.offsetWidth;
346
376
  this._fillColor();
347
377
  }
378
+ /** RENDER */
348
379
  render() {
349
380
  return html`
350
381
  <div id="range-slider">
@@ -397,6 +428,7 @@ let UUIRangeSliderElement = class extends FormControlMixin(LitElement) {
397
428
  <div class="value value-max">${this.valueHigh}</div>
398
429
  </div>`;
399
430
  }
431
+ /** RENDER STEPS & STEP VALUES */
400
432
  renderStepsOutput() {
401
433
  return html`<div class="svg-wrapper">
402
434
  <svg height="100%" width="100%">
@@ -532,13 +564,19 @@ UUIRangeSliderElement.styles = [
532
564
  transition: background-color 320ms ease-out;
533
565
  }
534
566
 
535
- #range-slider #inner-track .color:has(.color-target:hover),
536
- #range-slider #inner-track .color:has(.color-target:active) {
537
- background-color: var(--uui-color-focus,#3879ff);
567
+ :host(:not([disabled]))
568
+ #range-slider
569
+ #inner-track
570
+ .color:has(.color-target:hover),
571
+ :host(:not([disabled]))
572
+ #range-slider
573
+ #inner-track
574
+ .color:has(.color-target:active) {
575
+ background-color: var(--uui-color-focus,var(--uui-palette-malibu));
538
576
  }
539
577
 
540
578
  :host(:not([disabled])) #range-slider .color {
541
- background-color: var(--uui-color-selected,#3544b1);
579
+ background-color: var(--uui-color-selected,var(--uui-palette-violet-blue));
542
580
  }
543
581
 
544
582
  :host([disabled]) #range-slider .color {
@@ -575,7 +613,7 @@ UUIRangeSliderElement.styles = [
575
613
  }
576
614
 
577
615
  :host .track-step.filled {
578
- fill: var(--uui-color-selected,#3544b1) !important;
616
+ fill: var(--uui-color-selected,var(--uui-palette-violet-blue)) !important;
579
617
  }
580
618
 
581
619
  :host .track-step.filled-disabled {
@@ -598,14 +636,14 @@ UUIRangeSliderElement.styles = [
598
636
  #step-values > span {
599
637
  flex-basis: 0;
600
638
  flex-grow: 1;
601
- color: var(--uui-color-disabled-contrast,#c4c4c4);
639
+ color: var(--uui-color-disabled-contrast,var(--uui-palette-grey));
602
640
  }
603
641
 
604
642
  #step-values > span > span {
605
643
  transform: translateX(-50%);
606
644
  display: inline-block;
607
645
  text-align: center;
608
- font-size: var(--uui-type-small-size,12px);
646
+ font-size: var(--uui-type-small-size,var(--uui-size-4));
609
647
  }
610
648
 
611
649
  #step-values > span:last-child {
@@ -643,23 +681,36 @@ UUIRangeSliderElement.styles = [
643
681
  #low-input:active ~ #inner-track #low.thumb,
644
682
  #high-input:active ~ #inner-track #high-thumb {
645
683
  outline: calc(2px * var(--uui-show-focus-outline, 1)) solid
646
- var(--uui-color-focus,#3879ff);
684
+ var(--uui-color-focus,var(--uui-palette-malibu));
647
685
  }
648
686
 
649
687
  input[type='range']:focus + .thumb {
650
688
  outline: calc(2px * var(--uui-show-focus-outline, 1)) solid
651
- var(--uui-color-focus,#3879ff);
689
+ var(--uui-color-focus,var(--uui-palette-malibu));
652
690
  }
653
691
 
654
- #range-slider #inner-track .color:has(.color-target:hover) ~ #low-thumb,
655
- #range-slider #inner-track .color:has(.color-target:active) ~ #low-thumb,
656
- #range-slider #inner-track .color:has(.color-target:hover) ~ #high-thumb,
657
- #range-slider
692
+ :host(:not([disabled]))
693
+ #range-slider
694
+ #inner-track
695
+ .color:has(.color-target:hover)
696
+ ~ #low-thumb,
697
+ :host(:not([disabled]))
698
+ #range-slider
699
+ #inner-track
700
+ .color:has(.color-target:active)
701
+ ~ #low-thumb,
702
+ :host(:not([disabled]))
703
+ #range-slider
704
+ #inner-track
705
+ .color:has(.color-target:hover)
706
+ ~ #high-thumb,
707
+ :host(:not([disabled]))
708
+ #range-slider
658
709
  #inner-track
659
710
  .color:has(.color-target:active)
660
711
  ~ #high-thumb {
661
712
  outline: calc(2px * var(--uui-show-focus-outline, 1)) solid
662
- var(--uui-color-focus,#3879ff);
713
+ var(--uui-color-focus,var(--uui-palette-malibu));
663
714
  }
664
715
 
665
716
  /** THUMBS */
@@ -690,11 +741,11 @@ UUIRangeSliderElement.styles = [
690
741
  height: 9px;
691
742
  width: 9px;
692
743
  border-radius: 50%;
693
- background-color: var(--uui-color-selected,#3544b1);
744
+ background-color: var(--uui-color-selected,var(--uui-palette-violet-blue));
694
745
  }
695
746
 
696
747
  :host([disabled]) .thumb {
697
- background-color: var(--uui-color-disabled,#f3f3f5);
748
+ background-color: var(--uui-color-disabled,var(--uui-palette-sand));
698
749
  border-color: var(--uui-palette-mine-grey,#3e3e3e);
699
750
  }
700
751
  :host([disabled]) .thumb:after {
@@ -712,7 +763,7 @@ UUIRangeSliderElement.styles = [
712
763
  text-align: center;
713
764
  opacity: 1;
714
765
  transition: 120ms opacity;
715
- color: var(--uui-color-selected,#3544b1);
766
+ color: var(--uui-color-selected,var(--uui-palette-violet-blue));
716
767
  visibility: hidden;
717
768
  opacity: 0;
718
769
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umbraco-ui/uui-range-slider",
3
- "version": "1.2.1",
3
+ "version": "1.3.0-rc.0",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "Umbraco",
@@ -30,16 +30,16 @@
30
30
  "custom-elements.json"
31
31
  ],
32
32
  "dependencies": {
33
- "@umbraco-ui/uui-base": "1.2.1"
33
+ "@umbraco-ui/uui-base": "1.3.0-rc.0"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "npm run analyze && tsc --build --force && rollup -c rollup.config.js",
37
- "clean": "tsc --build --clean && rimraf dist lib/*.js lib/**/*.js custom-elements.json",
37
+ "clean": "tsc --build --clean && rimraf -g dist lib/*.js lib/**/*.js custom-elements.json",
38
38
  "analyze": "web-component-analyzer **/*.element.ts --outFile custom-elements.json"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
43
  "homepage": "https://uui.umbraco.com/?path=/story/uui-range-slider",
44
- "gitHead": "94eb22bee5ff21bac6fadbd78653671279bebe36"
44
+ "gitHead": "45c3824056586d9817efb3f61dc0bef5478747f0"
45
45
  }