@six-group/ui-library 0.0.0-insider.9277796 → 0.0.0-insider.a358260

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/cjs/six-checkbox.cjs.entry.js +57 -46
  2. package/dist/cjs/six-checkbox.cjs.entry.js.map +1 -1
  3. package/dist/cjs/six-input.cjs.entry.js +107 -81
  4. package/dist/cjs/six-input.cjs.entry.js.map +1 -1
  5. package/dist/cjs/six-radio.cjs.entry.js +56 -51
  6. package/dist/cjs/six-radio.cjs.entry.js.map +1 -1
  7. package/dist/cjs/six-range.cjs.entry.js +114 -75
  8. package/dist/cjs/six-range.cjs.entry.js.map +1 -1
  9. package/dist/cjs/six-select.cjs.entry.js +298 -239
  10. package/dist/cjs/six-select.cjs.entry.js.map +1 -1
  11. package/dist/cjs/six-textarea.cjs.entry.js +97 -74
  12. package/dist/cjs/six-textarea.cjs.entry.js.map +1 -1
  13. package/dist/cjs/slot-ad537f24.js.map +1 -1
  14. package/dist/collection/components/six-checkbox/six-checkbox.js +62 -49
  15. package/dist/collection/components/six-checkbox/six-checkbox.js.map +1 -1
  16. package/dist/collection/components/six-input/six-input.js +130 -117
  17. package/dist/collection/components/six-input/six-input.js.map +1 -1
  18. package/dist/collection/components/six-radio/six-radio.js +60 -53
  19. package/dist/collection/components/six-radio/six-radio.js.map +1 -1
  20. package/dist/collection/components/six-range/six-range.js +121 -76
  21. package/dist/collection/components/six-range/six-range.js.map +1 -1
  22. package/dist/collection/components/six-select/six-select.js +248 -240
  23. package/dist/collection/components/six-select/six-select.js.map +1 -1
  24. package/dist/collection/components/six-select/util.js +52 -0
  25. package/dist/collection/components/six-select/util.js.map +1 -0
  26. package/dist/collection/components/six-textarea/six-textarea.js +115 -105
  27. package/dist/collection/components/six-textarea/six-textarea.js.map +1 -1
  28. package/dist/collection/utils/slot.js.map +1 -1
  29. package/dist/components/six-checkbox.js +57 -46
  30. package/dist/components/six-checkbox.js.map +1 -1
  31. package/dist/components/six-input2.js +107 -81
  32. package/dist/components/six-input2.js.map +1 -1
  33. package/dist/components/six-radio.js +56 -51
  34. package/dist/components/six-radio.js.map +1 -1
  35. package/dist/components/six-range.js +114 -75
  36. package/dist/components/six-range.js.map +1 -1
  37. package/dist/components/six-select.js +299 -240
  38. package/dist/components/six-select.js.map +1 -1
  39. package/dist/components/six-textarea.js +97 -74
  40. package/dist/components/six-textarea.js.map +1 -1
  41. package/dist/components/slot.js.map +1 -1
  42. package/dist/components.json +51 -41
  43. package/dist/esm/six-checkbox.entry.js +57 -46
  44. package/dist/esm/six-checkbox.entry.js.map +1 -1
  45. package/dist/esm/six-input.entry.js +107 -81
  46. package/dist/esm/six-input.entry.js.map +1 -1
  47. package/dist/esm/six-radio.entry.js +56 -51
  48. package/dist/esm/six-radio.entry.js.map +1 -1
  49. package/dist/esm/six-range.entry.js +114 -75
  50. package/dist/esm/six-range.entry.js.map +1 -1
  51. package/dist/esm/six-select.entry.js +299 -240
  52. package/dist/esm/six-select.entry.js.map +1 -1
  53. package/dist/esm/six-textarea.entry.js +97 -74
  54. package/dist/esm/six-textarea.entry.js.map +1 -1
  55. package/dist/esm/slot-6f3984c7.js.map +1 -1
  56. package/dist/types/components/six-checkbox/six-checkbox.d.ts +21 -17
  57. package/dist/types/components/six-input/six-input.d.ts +27 -36
  58. package/dist/types/components/six-radio/six-radio.d.ts +10 -11
  59. package/dist/types/components/six-range/six-range.d.ts +24 -20
  60. package/dist/types/components/six-select/six-select.d.ts +35 -40
  61. package/dist/types/components/six-select/util.d.ts +7 -0
  62. package/dist/types/components/six-textarea/six-textarea.d.ts +22 -31
  63. package/dist/types/components.d.ts +20 -28
  64. package/dist/types/utils/testing.d.ts +1 -1
  65. package/dist/ui-library/p-163f2bb0.entry.js +2 -0
  66. package/dist/ui-library/p-163f2bb0.entry.js.map +1 -0
  67. package/dist/ui-library/{p-14f20bbb.entry.js → p-394a2a12.entry.js} +2 -2
  68. package/dist/ui-library/p-394a2a12.entry.js.map +1 -0
  69. package/dist/ui-library/{p-7e0cc4ae.entry.js → p-3c635d0a.entry.js} +2 -2
  70. package/dist/ui-library/p-3c635d0a.entry.js.map +1 -0
  71. package/dist/ui-library/p-5a25d6fb.entry.js +2 -0
  72. package/dist/ui-library/p-5a25d6fb.entry.js.map +1 -0
  73. package/dist/ui-library/{p-90dc6af4.entry.js → p-97cc839c.entry.js} +2 -2
  74. package/dist/ui-library/p-97cc839c.entry.js.map +1 -0
  75. package/dist/ui-library/p-b4dfb7cf.js.map +1 -1
  76. package/dist/ui-library/p-f604e067.entry.js +2 -0
  77. package/dist/ui-library/p-f604e067.entry.js.map +1 -0
  78. package/dist/ui-library/ui-library.esm.js +1 -1
  79. package/package.json +13 -14
  80. package/dist/ui-library/p-0d79b0c6.entry.js +0 -2
  81. package/dist/ui-library/p-0d79b0c6.entry.js.map +0 -1
  82. package/dist/ui-library/p-14f20bbb.entry.js.map +0 -1
  83. package/dist/ui-library/p-7e0cc4ae.entry.js.map +0 -1
  84. package/dist/ui-library/p-835c3ff7.entry.js +0 -2
  85. package/dist/ui-library/p-835c3ff7.entry.js.map +0 -1
  86. package/dist/ui-library/p-90dc6af4.entry.js.map +0 -1
  87. package/dist/ui-library/p-edc96efc.entry.js +0 -2
  88. package/dist/ui-library/p-edc96efc.entry.js.map +0 -1
@@ -19,20 +19,54 @@ const SixRange = class {
19
19
  this.inputId = `input-${++id}`;
20
20
  this.labelId = `input-label-${id}`;
21
21
  this.helpTextId = `input-help-text-${id}`;
22
- this.errorTextId = `input-error-text-${id}`;
23
22
  this.customErrorText = '';
24
23
  this.customValidation = false;
24
+ this.errorTextId = `input-error-text-${id}`;
25
25
  this.eventListeners = new eventListeners.EventListeners();
26
26
  /** default value the slider will be reverted to when reset is executed */
27
27
  this.defaultValue = 0;
28
+ this.handleInput = () => {
29
+ if (this.nativeInput != null) {
30
+ this.update(parseFloat(this.nativeInput.value));
31
+ }
32
+ requestAnimationFrame(() => {
33
+ this.sixChange.emit();
34
+ });
35
+ };
36
+ this.handleBlur = () => {
37
+ var _a;
38
+ this.hasFocus = false;
39
+ this.hasTooltip = false;
40
+ this.sixBlur.emit();
41
+ if (this.nativeInput != null) {
42
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.nativeInput);
43
+ }
44
+ };
45
+ this.handleFocus = () => {
46
+ var _a;
47
+ this.hasFocus = true;
48
+ this.hasTooltip = true;
49
+ this.sixFocus.emit();
50
+ if (this.nativeInput != null) {
51
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.nativeInput);
52
+ }
53
+ };
54
+ this.handleSlotChange = () => {
55
+ this.hasHelpTextSlot = slot.hasSlot(this.host, 'help-text');
56
+ this.hasErrorTextSlot = slot.hasSlot(this.host, 'error-text');
57
+ this.hasLabelSlot = slot.hasSlot(this.host, 'label');
58
+ };
59
+ this.handleTouchStart = () => {
60
+ this.setFocus();
61
+ };
28
62
  this.hasFocus = false;
29
63
  this.hasHelpTextSlot = false;
30
64
  this.hasLabelSlot = false;
31
65
  this.hasErrorTextSlot = false;
32
66
  this.hasTooltip = false;
33
67
  this.name = '';
34
- this.value = undefined;
35
- this.required = undefined;
68
+ this.value = 0;
69
+ this.required = false;
36
70
  this.label = '';
37
71
  this.helpText = '';
38
72
  this.errorText = '';
@@ -49,119 +83,125 @@ const SixRange = class {
49
83
  this.handleSlotChange();
50
84
  }
51
85
  handleValueChange() {
52
- if (this.input) {
53
- this.input.value = this.value;
54
- this.calculateColorRunnableTrack();
86
+ this.update();
87
+ if (this.nativeInput != null) {
88
+ this.invalid = !this.nativeInput.checkValidity();
55
89
  }
56
- // In rare cases, the watcher may be called before render so we need to make sure the input exists
57
- this.invalid = this.input ? !this.input.checkValidity() : false;
58
90
  }
59
91
  connectedCallback() {
60
- this.handleInput = this.handleInput.bind(this);
61
- this.handleBlur = this.handleBlur.bind(this);
62
- this.handleFocus = this.handleFocus.bind(this);
63
- this.handleSlotChange = this.handleSlotChange.bind(this);
64
- this.handleTouchStart = this.handleTouchStart.bind(this);
65
- this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);
92
+ var _a;
93
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.addEventListener('slotchange', this.handleSlotChange);
66
94
  }
67
95
  componentWillLoad() {
68
- if (this.value === undefined || this.value === null)
69
- this.value = this.min;
70
- if (this.value < this.min)
71
- this.value = this.min;
72
- if (this.value > this.max)
73
- this.value = this.max;
96
+ this.update();
74
97
  this.defaultValue = this.value;
75
98
  this.handleSlotChange();
76
99
  }
77
100
  componentDidLoad() {
78
- this.syncTooltip();
79
- this.calculateColorRunnableTrack();
80
- this.resizeObserver = new ResizeObserver(() => this.syncTooltip());
81
- this.eventListeners.add(this.input, 'invalid', (event) => {
82
- if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {
83
- this.customErrorText = this.input.validationMessage;
101
+ const nativeInput = this.nativeInput;
102
+ if (nativeInput == null) {
103
+ return;
104
+ }
105
+ this.update();
106
+ this.resizeObserver = new ResizeObserver(() => this.update());
107
+ this.eventListeners.add(nativeInput, 'invalid', (event) => {
108
+ if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {
109
+ this.customErrorText = nativeInput.validationMessage;
84
110
  }
85
111
  event.preventDefault();
86
112
  });
87
113
  }
88
114
  disconnectedCallback() {
89
- this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);
115
+ var _a;
116
+ (_a = this.host.shadowRoot) === null || _a === void 0 ? void 0 : _a.removeEventListener('slotchange', this.handleSlotChange);
90
117
  this.eventListeners.removeAll();
91
118
  }
92
119
  /** Sets focus on the input. */
93
120
  async setFocus(options) {
94
- this.input.focus(options);
121
+ var _a;
122
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.focus(options);
95
123
  }
96
124
  /** Removes focus from the input. */
97
125
  async removeFocus() {
98
- this.input.blur();
126
+ var _a;
127
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.blur();
99
128
  }
100
129
  /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */
101
130
  async setCustomValidity(message) {
102
131
  this.customErrorText = '';
103
132
  this.customValidation = message !== '';
104
- this.input.setCustomValidity(message);
105
- this.invalid = !this.input.checkValidity();
133
+ if (this.nativeInput != null) {
134
+ this.nativeInput.setCustomValidity(message);
135
+ this.invalid = !this.nativeInput.checkValidity();
136
+ }
106
137
  }
107
138
  /** Resets the formcontrol */
108
139
  async reset() {
140
+ var _a;
109
141
  this.value = this.defaultValue;
110
142
  this.customErrorText = '';
111
143
  this.customValidation = false;
112
- this.input.setCustomValidity('');
144
+ (_a = this.nativeInput) === null || _a === void 0 ? void 0 : _a.setCustomValidity('');
113
145
  this.invalid = false;
114
146
  }
115
- handleInput() {
116
- this.value = Number(this.input.value);
117
- this.sixChange.emit();
118
- requestAnimationFrame(() => this.syncTooltip());
119
- requestAnimationFrame(() => this.calculateColorRunnableTrack());
120
- }
121
- handleBlur() {
122
- this.hasFocus = false;
123
- this.hasTooltip = false;
124
- this.sixBlur.emit();
125
- this.resizeObserver.unobserve(this.input);
126
- }
127
- handleFocus() {
128
- this.hasFocus = true;
129
- this.hasTooltip = true;
130
- this.sixFocus.emit();
131
- this.resizeObserver.observe(this.input);
132
- }
133
- handleSlotChange() {
134
- this.hasHelpTextSlot = slot.hasSlot(this.host, 'help-text');
135
- this.hasErrorTextSlot = slot.hasSlot(this.host, 'error-text');
136
- this.hasLabelSlot = slot.hasSlot(this.host, 'label');
137
- }
138
- handleTouchStart() {
139
- this.setFocus();
140
- }
141
147
  displayError() {
142
148
  return this.invalid && (!this.errorOnBlur || !this.hasFocus);
143
149
  }
144
- syncTooltip() {
145
- if (this.tooltip !== 'none') {
146
- const percent = Math.max(0, (this.value - this.min) / (this.max - this.min));
147
- const inputWidth = this.input.offsetWidth;
150
+ syncTooltip(min, max, value) {
151
+ if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {
152
+ const percent = Math.max(0, (value - min) / (max - min));
153
+ const inputWidth = this.nativeInput.offsetWidth;
148
154
  const tooltipWidth = this.output.offsetWidth;
149
- const thumbSize = getComputedStyle(this.input).getPropertyValue('--thumb-size');
155
+ const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');
150
156
  const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;
151
157
  this.output.style.transform = `translateX(${x})`;
152
158
  this.output.style.marginLeft = `-${tooltipWidth / 2}px`;
153
159
  }
154
160
  }
161
+ isFirefox() {
162
+ return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
163
+ }
164
+ update(updateValue) {
165
+ var _a, _b;
166
+ if (updateValue != null) {
167
+ this.value = updateValue;
168
+ }
169
+ const min = (_a = Number(this.min)) !== null && _a !== void 0 ? _a : 0;
170
+ const max = (_b = Number(this.max)) !== null && _b !== void 0 ? _b : 0;
171
+ let value;
172
+ const parsedValue = parseFloat(this.value);
173
+ if (isNaN(parsedValue)) {
174
+ value = this.getDefaultValue(min, max);
175
+ }
176
+ else {
177
+ value = parsedValue;
178
+ }
179
+ if (this.nativeInput != null) {
180
+ // The value may have constraints, so we set the native control's
181
+ // value and sync it back to ensure it adheres to min, max, and step
182
+ // properly.
183
+ this.nativeInput.value = value.toString();
184
+ this.value = parseFloat(this.nativeInput.value);
185
+ }
186
+ else {
187
+ this.value = value;
188
+ }
189
+ this.calculateColorRunnableTrack(min, max, this.value);
190
+ this.syncTooltip(min, max, this.value);
191
+ }
192
+ /**
193
+ * from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value
194
+ */
195
+ getDefaultValue(min, max) {
196
+ return max < min ? min : min + (max - min) / 2;
197
+ }
155
198
  /**
156
199
  * For Firefox this functionality is not needed because it is supported by standard CSS.
157
200
  */
158
- calculateColorRunnableTrack() {
159
- if (!this.isFirefox()) {
160
- const value = parseInt(this.input.value, 10);
161
- const min = parseInt(this.input.min, 10);
162
- const max = parseInt(this.input.max, 10);
201
+ calculateColorRunnableTrack(min, max, value) {
202
+ if (!this.isFirefox() && this.nativeInput != null) {
163
203
  const percent = Math.ceil(((value - min) / (max - min)) * 100);
164
- this.input.style.background =
204
+ this.nativeInput.style.background =
165
205
  '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +
166
206
  percent +
167
207
  '%, var(--six-color-web-rock-300) ' +
@@ -169,11 +209,8 @@ const SixRange = class {
169
209
  '%)';
170
210
  }
171
211
  }
172
- isFirefox() {
173
- return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
174
- }
175
212
  render() {
176
- return (index.h(formControl.FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.customErrorText ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, disabled: this.disabled, required: this.required, displayError: this.displayError() }, index.h("div", { part: "base", class: {
213
+ return (index.h(formControl.FormControl, { inputId: this.inputId, label: this.label, labelId: this.labelId, hasLabelSlot: this.hasLabelSlot, helpTextId: this.helpTextId, helpText: this.helpText, hasHelpTextSlot: this.hasHelpTextSlot, size: "medium", errorTextId: this.errorTextId, errorText: this.customErrorText != null ? this.customErrorText : this.errorText, hasErrorTextSlot: this.hasErrorTextSlot, disabled: this.disabled, required: this.required, displayError: this.displayError() }, index.h("div", { part: "base", class: {
177
214
  range: true,
178
215
  // States
179
216
  'range--disabled': this.disabled,
@@ -181,14 +218,16 @@ const SixRange = class {
181
218
  'range--tooltip-visible': this.hasTooltip,
182
219
  'range--tooltip-top': this.tooltip === 'top',
183
220
  'range--tooltip-bottom': this.tooltip === 'bottom',
184
- }, onTouchStart: this.handleTouchStart }, index.h("input", { part: "input", ref: (el) => (this.input = el), type: "range", class: "range__control", name: this.name, disabled: this.disabled, min: this.min, max: this.max, step: this.step, value: this.value, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur }), this.tooltip !== 'none' && (index.h("output", { part: "tooltip", ref: (el) => (this.output = el), class: "range__tooltip" }, this.tooltipFormatter(this.value))))));
221
+ }, onTouchStart: this.handleTouchStart }, index.h("input", { part: "input", ref: (el) => (this.nativeInput = el), type: "range", class: "range__control", name: this.name, disabled: this.disabled, min: this.min, max: this.max, step: this.step, value: this.value, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur }), this.tooltip !== 'none' && (index.h("output", { part: "tooltip", ref: (el) => (this.output = el), class: "range__tooltip" }, this.tooltipFormatter(this.value))))));
185
222
  }
186
223
  get host() { return index.getElement(this); }
187
224
  static get watchers() { return {
188
225
  "label": ["handleLabelChange"],
189
226
  "errorText": ["handleLabelChange"],
190
227
  "helpText": ["handleLabelChange"],
191
- "value": ["handleValueChange"]
228
+ "value": ["handleValueChange"],
229
+ "min": ["handleValueChange"],
230
+ "max": ["handleValueChange"]
192
231
  }; }
193
232
  };
194
233
  SixRange.style = sixRangeCss;
@@ -1 +1 @@
1
- {"file":"six-range.entry.cjs.js","mappings":";;;;;;;;;AAAA,MAAM,WAAW,GAAG,89MAA89M;;ACMl/M,IAAI,EAAE,GAAG,CAAC,CAAC;MAqBE,QAAQ;;;;;;IACnB,YAAO,GAAG,SAAS,EAAE,EAAE,EAAE,CAAC;IAC1B,YAAO,GAAG,eAAe,EAAE,EAAE,CAAC;IAC9B,eAAU,GAAG,mBAAmB,EAAE,EAAE,CAAC;IACrC,gBAAW,GAAG,oBAAoB,EAAE,EAAE,CAAC;IAKvC,oBAAe,GAAG,EAAE,CAAC;IACrB,qBAAgB,GAAG,KAAK,CAAC;IAEhB,mBAAc,GAAG,IAAIA,6BAAc,EAAE,CAAC;;IAiEvC,iBAAY,GAAG,CAAC,CAAC;oBA7DL,KAAK;2BACE,KAAK;wBACR,KAAK;4BACD,KAAK;sBACX,KAAK;gBAGZ,EAAE;;;iBASD,EAAE;oB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,EAAE,IAAI,CAAC,YAAY,EAAE,IAEjCD,iBACE,IAAI,EAAC,MAAM,EACX,KAAK,EAAE;QACL,KAAK,EAAE,IAAI;;QAGX,iBAAiB,EAAE,IAAI,CAAC,QAAQ;QAChC,gBAAgB,EAAE,IAAI,CAAC,QAAQ;QAC/B,wBAAwB,EAAE,IAAI,CAAC,UAAU;QACzC,oBAAoB,EAAE,IAAI,CAAC,OAAO,KAAK,KAAK;QAC5C,uBAAuB,EAAE,IAAI,CAAC,OAAO,KAAK,QAAQ;OACnD,EACD,YAAY,EAAE,IAAI,CAAC,gBAAgB,IAEnCA,mBACE,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,gBAAgB,EACtB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,GACvB,EACD,IAAI,CAAC,OAAO,KAAK,MAAM,KACtBA,oBAAQ,IAAI,EAAC,SAAS,EAAC,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,gBAAgB,IAC3E,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC3B,CACV,CACG,CACM,EACd;GACH;;;;;;;;;;;;;","names":["EventListeners","hasSlot","h","FormControl"],"sources":["./src/components/six-range/six-range.scss?tag=six-range&encapsulation=shadow","./src/components/six-range/six-range.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n --thumb-size: 14px;\n --tooltip-offset-y: 10px;\n --track-color: var(--six-color-web-rock-900);\n --thumb-color: var(--six-color-web-rock-900);\n --track-height: 3px;\n\n display: block;\n}\n\n.range {\n position: relative;\n\n .range__control {\n -webkit-appearance: none;\n width: 100%;\n height: var(--six-input-height-medium);\n background: transparent;\n line-height: var(--six-input-height-medium);\n vertical-align: middle;\n\n &::-webkit-slider-runnable-track {\n width: 100%;\n height: var(--track-height);\n border-radius: 3px;\n border: none;\n }\n\n &::-webkit-slider-thumb {\n border: none;\n width: var(--thumb-size);\n height: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n -webkit-appearance: none;\n margin-top: calc(var(--thumb-size) / -2 + var(--track-height) / 2);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-webkit-slider-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-webkit-slider-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-webkit-slider-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // Firefox\n &::-moz-focus-outer {\n border: 0;\n }\n\n &::-moz-range-track {\n width: 100%;\n height: var(--track-height);\n background-color: var(--six-progress-track-color);\n border-radius: 3px;\n border: none;\n }\n\n &::-moz-range-progress {\n height: var(--track-height);\n border-radius: 3px;\n background-color: var(--track-color);\n border: none;\n }\n\n &::-moz-range-thumb {\n border: none;\n height: var(--thumb-size);\n width: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-moz-range-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-moz-range-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-moz-range-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // States\n &:focus {\n outline: none;\n }\n\n &:disabled {\n &::-webkit-slider-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n\n &::-moz-range-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n }\n }\n}\n\n// Tooltip\n.range__tooltip {\n position: absolute;\n z-index: var(--six-z-index-tooltip);\n left: 1px;\n border-radius: var(--six-border-radius-medium);\n background-color: var(--six-color-web-rock-900);\n font-family: var(--six-font-family);\n font-size: var(--six-tooltip-font-size);\n font-weight: var(--six-tooltip-font-weight);\n line-height: var(--six-tooltip-line-height);\n color: var(--six-color-white);\n opacity: 0;\n padding: var(--six-spacing-xxx-small) var(--six-spacing-xx-small);\n transition: var(--six-transition-fast) opacity;\n pointer-events: none;\n\n &::after {\n content: '';\n position: absolute;\n width: 0;\n height: 0;\n left: 50%;\n margin-left: calc(-1 * var(--six-tooltip-arrow-size));\n }\n}\n\n.range--tooltip-visible .range__tooltip {\n opacity: 1;\n}\n\n// Tooltip on top\n.range--tooltip-top .range__tooltip {\n top: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-top: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n top: 100%;\n }\n}\n\n// Tooltip on bottom\n.range--tooltip-bottom .range__tooltip {\n bottom: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-bottom: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n bottom: 100%;\n }\n}\n","import { Component, Element, Event, EventEmitter, Method, Prop, State, Watch, h } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n inputId = `input-${++id}`;\n labelId = `input-label-${id}`;\n helpTextId = `input-help-text-${id}`;\n errorTextId = `input-error-text-${id}`;\n resizeObserver: ResizeObserver;\n\n output: HTMLElement;\n input: HTMLInputElement;\n customErrorText = '';\n customValidation = false;\n\n readonly eventListeners = new EventListeners();\n\n @Element() host: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value: number;\n\n /** Set to true to make the input a required field. */\n @Prop({ reflect: true }) required: boolean;\n\n /** The range's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus: EventEmitter<EmptyPayload>;\n\n /** default value the slider will be reverted to when reset is executed */\n private defaultValue = 0;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n handleValueChange() {\n if (this.input) {\n this.input.value = this.value as any;\n this.calculateColorRunnableTrack();\n }\n // In rare cases, the watcher may be called before render so we need to make sure the input exists\n this.invalid = this.input ? !this.input.checkValidity() : false;\n }\n\n connectedCallback() {\n this.handleInput = this.handleInput.bind(this);\n this.handleBlur = this.handleBlur.bind(this);\n this.handleFocus = this.handleFocus.bind(this);\n this.handleSlotChange = this.handleSlotChange.bind(this);\n this.handleTouchStart = this.handleTouchStart.bind(this);\n\n this.host.shadowRoot.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n if (this.value === undefined || this.value === null) this.value = this.min;\n if (this.value < this.min) this.value = this.min;\n if (this.value > this.max) this.value = this.max;\n this.defaultValue = this.value;\n\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n this.syncTooltip();\n this.calculateColorRunnableTrack();\n this.resizeObserver = new ResizeObserver(() => this.syncTooltip());\n this.eventListeners.add(this.input, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && !this.errorText && !this.customErrorText)) {\n this.customErrorText = this.input.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n this.host.shadowRoot.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.input.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.input.blur();\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n this.input.setCustomValidity(message);\n this.invalid = !this.input.checkValidity();\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.input.setCustomValidity('');\n this.invalid = false;\n }\n\n handleInput() {\n this.value = Number(this.input.value);\n this.sixChange.emit();\n\n requestAnimationFrame(() => this.syncTooltip());\n requestAnimationFrame(() => this.calculateColorRunnableTrack());\n }\n\n handleBlur() {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n this.resizeObserver.unobserve(this.input);\n }\n\n handleFocus() {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n this.resizeObserver.observe(this.input);\n }\n\n handleSlotChange() {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n }\n\n handleTouchStart() {\n this.setFocus();\n }\n\n displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n syncTooltip() {\n if (this.tooltip !== 'none') {\n const percent = Math.max(0, (this.value - this.min) / (this.max - this.min));\n const inputWidth = this.input.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.input).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n calculateColorRunnableTrack() {\n if (!this.isFirefox()) {\n const value = parseInt(this.input.value, 10);\n const min = parseInt(this.input.min, 10);\n const max = parseInt(this.input.max, 10);\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.input.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.customErrorText ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.input = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=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AK,EAAE,IAAI;;QAGX,iBAAiB,EAAE,IAAI,CAAC,QAAQ;QAChC,gBAAgB,EAAE,IAAI,CAAC,QAAQ;QAC/B,wBAAwB,EAAE,IAAI,CAAC,UAAU;QACzC,oBAAoB,EAAE,IAAI,CAAC,OAAO,KAAK,KAAK;QAC5C,uBAAuB,EAAE,IAAI,CAAC,OAAO,KAAK,QAAQ;OACnD,EACD,YAAY,EAAE,IAAI,CAAC,gBAAgB,IAEnCA,mBACE,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EACpC,IAAI,EAAC,OAAO,EACZ,KAAK,EAAC,gBAAgB,EACtB,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,OAAO,EAAE,IAAI,CAAC,WAAW,EACzB,MAAM,EAAE,IAAI,CAAC,UAAU,GACvB,EACD,IAAI,CAAC,OAAO,KAAK,MAAM,KACtBA,oBAAQ,IAAI,EAAC,SAAS,EAAC,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,EAAC,gBAAgB,IAC3E,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAC3B,CACV,CACG,CACM,EACd;GACH;;;;;;;;;;;;;;;","names":["EventListeners","hasSlot","h","FormControl"],"sources":["./src/components/six-range/six-range.scss?tag=six-range&encapsulation=shadow","./src/components/six-range/six-range.tsx"],"sourcesContent":["@import 'src/global/component';\n@import '../../functional-components/form-control/form-control';\n\n:host {\n --thumb-size: 14px;\n --tooltip-offset-y: 10px;\n --track-color: var(--six-color-web-rock-900);\n --thumb-color: var(--six-color-web-rock-900);\n --track-height: 3px;\n\n display: block;\n}\n\n.range {\n position: relative;\n\n .range__control {\n -webkit-appearance: none;\n width: 100%;\n height: var(--six-input-height-medium);\n background: transparent;\n line-height: var(--six-input-height-medium);\n vertical-align: middle;\n\n &::-webkit-slider-runnable-track {\n width: 100%;\n height: var(--track-height);\n border-radius: 3px;\n border: none;\n }\n\n &::-webkit-slider-thumb {\n border: none;\n width: var(--thumb-size);\n height: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n -webkit-appearance: none;\n margin-top: calc(var(--thumb-size) / -2 + var(--track-height) / 2);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-webkit-slider-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-webkit-slider-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-webkit-slider-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // Firefox\n &::-moz-focus-outer {\n border: 0;\n }\n\n &::-moz-range-track {\n width: 100%;\n height: var(--track-height);\n background-color: var(--six-progress-track-color);\n border-radius: 3px;\n border: none;\n }\n\n &::-moz-range-progress {\n height: var(--track-height);\n border-radius: 3px;\n background-color: var(--track-color);\n border: none;\n }\n\n &::-moz-range-thumb {\n border: none;\n height: var(--thumb-size);\n width: var(--thumb-size);\n border-radius: 50%;\n background-color: var(--thumb-color);\n transition: var(--six-transition-fast) border-color, var(--six-transition-fast) background-color,\n var(--six-transition-fast) color, var(--six-transition-fast) box-shadow, var(--six-transition-fast) transform;\n cursor: pointer;\n }\n\n &:not(:disabled)::-moz-range-thumb:hover {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled):focus::-moz-range-thumb {\n background-color: var(--thumb-color);\n }\n\n &:not(:disabled)::-moz-range-thumb:active {\n background-color: var(--thumb-color);\n cursor: grabbing;\n }\n\n // States\n &:focus {\n outline: none;\n }\n\n &:disabled {\n &::-webkit-slider-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n\n &::-moz-range-thumb {\n cursor: not-allowed;\n color: var(--six-color-web-rock-300);\n border-color: var(--six-color-web-rock-300);\n background-color: var(--six-color-web-rock-300);\n }\n }\n }\n}\n\n// Tooltip\n.range__tooltip {\n position: absolute;\n z-index: var(--six-z-index-tooltip);\n left: 1px;\n border-radius: var(--six-border-radius-medium);\n background-color: var(--six-color-web-rock-900);\n font-family: var(--six-font-family);\n font-size: var(--six-tooltip-font-size);\n font-weight: var(--six-tooltip-font-weight);\n line-height: var(--six-tooltip-line-height);\n color: var(--six-color-white);\n opacity: 0;\n padding: var(--six-spacing-xxx-small) var(--six-spacing-xx-small);\n transition: var(--six-transition-fast) opacity;\n pointer-events: none;\n\n &::after {\n content: '';\n position: absolute;\n width: 0;\n height: 0;\n left: 50%;\n margin-left: calc(-1 * var(--six-tooltip-arrow-size));\n }\n}\n\n.range--tooltip-visible .range__tooltip {\n opacity: 1;\n}\n\n// Tooltip on top\n.range--tooltip-top .range__tooltip {\n top: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-top: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n top: 100%;\n }\n}\n\n// Tooltip on bottom\n.range--tooltip-bottom .range__tooltip {\n bottom: calc(-1 * var(--thumb-size) - var(--tooltip-offset-y));\n\n &::after {\n border-bottom: var(--six-tooltip-arrow-size) solid var(--six-color-web-rock-900);\n border-left: var(--six-tooltip-arrow-size) solid transparent;\n border-right: var(--six-tooltip-arrow-size) solid transparent;\n bottom: 100%;\n }\n}\n","import { Component, Element, Event, EventEmitter, h, Method, Prop, State, Watch } from '@stencil/core';\nimport FormControl from '../../functional-components/form-control/form-control';\nimport { hasSlot } from '../../utils/slot';\nimport { EmptyPayload } from '../../utils/types';\nimport { EventListeners } from '../../utils/event-listeners';\n\nlet id = 0;\n\n/**\n * @since 1.0\n * @status stable\n *\n * Forked from https://github.com/shoelace-style/shoelace version v2.0.0-beta27.\n *\n * @slot label - The input's label. Alternatively, you can use the label prop.\n * @slot help-text - Help text that describes how to use the input. Alternatively, you can use the help-text prop.\n * @slot error-text - Error text that is shown for validation errors. Alternatively, you can use the error-text prop.\n *\n * @part base - The component's base wrapper.\n * @part input - The native range input.\n * @part tooltip - The range tooltip.\n */\n@Component({\n tag: 'six-range',\n styleUrl: 'six-range.scss',\n shadow: true,\n})\nexport class SixRange {\n private inputId = `input-${++id}`;\n private labelId = `input-label-${id}`;\n private helpTextId = `input-help-text-${id}`;\n private customErrorText = '';\n private customValidation = false;\n private errorTextId = `input-error-text-${id}`;\n private eventListeners = new EventListeners();\n private resizeObserver?: ResizeObserver;\n\n private output?: HTMLElement;\n private nativeInput?: HTMLInputElement;\n\n @Element() host!: HTMLSixRangeElement;\n\n @State() hasFocus = false;\n @State() hasHelpTextSlot = false;\n @State() hasLabelSlot = false;\n @State() hasErrorTextSlot = false;\n @State() hasTooltip = false;\n\n /** The input's name attribute. */\n @Prop() name = '';\n\n /** The input's value attribute. */\n @Prop({ mutable: true }) value = 0;\n\n /** Set to true to make the input a required field. */\n @Prop({ reflect: true }) required = false;\n\n /** The range's label. Alternatively, you can use the label slot. */\n @Prop() label = '';\n\n /** The range's help text. Alternatively, you can use the help-text slot. */\n @Prop() helpText = '';\n\n /** The input's error text. Alternatively, you can use the error-text slot. */\n @Prop() errorText = '';\n\n /** Set to true to disable the input. */\n @Prop() disabled = false;\n\n /**\n * This will be true when the control is in an invalid state. Validity in range inputs is determined by the message\n * provided by the `setCustomValidity` method.\n */\n @Prop({ mutable: true, reflect: true }) invalid = false;\n\n /** The input's min attribute. */\n @Prop() min = 0;\n\n /** The input's max attribute. */\n @Prop() max = 100;\n\n /** The input's step attribute. */\n @Prop() step = 1;\n\n /** The preferred placedment of the tooltip. */\n @Prop() tooltip: 'top' | 'bottom' | 'none' = 'top';\n\n /** A function used to format the tooltip's value. */\n @Prop() tooltipFormatter = (value: number) => value.toString();\n\n /** Set to display the error text on blur and not when typing */\n @Prop() errorOnBlur = false;\n\n /** Emitted when the control's value changes. */\n @Event({ eventName: 'six-range-change' }) sixChange!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control loses focus. */\n @Event({ eventName: 'six-range-blur' }) sixBlur!: EventEmitter<EmptyPayload>;\n\n /** Emitted when the control gains focus. */\n @Event({ eventName: 'six-range-focus' }) sixFocus!: EventEmitter<EmptyPayload>;\n\n /** default value the slider will be reverted to when reset is executed */\n private defaultValue = 0;\n\n @Watch('label')\n @Watch('errorText')\n @Watch('helpText')\n handleLabelChange() {\n this.handleSlotChange();\n }\n\n @Watch('value')\n @Watch('min')\n @Watch('max')\n handleValueChange() {\n this.update();\n if (this.nativeInput != null) {\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n connectedCallback() {\n this.host.shadowRoot?.addEventListener('slotchange', this.handleSlotChange);\n }\n\n componentWillLoad() {\n this.update();\n this.defaultValue = this.value;\n this.handleSlotChange();\n }\n\n componentDidLoad() {\n const nativeInput = this.nativeInput;\n if (nativeInput == null) {\n return;\n }\n this.update();\n this.resizeObserver = new ResizeObserver(() => this.update());\n this.eventListeners.add(nativeInput, 'invalid', (event) => {\n if (this.customValidation || (!this.hasErrorTextSlot && this.errorText === '' && this.customErrorText === '')) {\n this.customErrorText = nativeInput.validationMessage;\n }\n event.preventDefault();\n });\n }\n\n disconnectedCallback() {\n this.host.shadowRoot?.removeEventListener('slotchange', this.handleSlotChange);\n this.eventListeners.removeAll();\n }\n\n /** Sets focus on the input. */\n @Method()\n async setFocus(options?: FocusOptions) {\n this.nativeInput?.focus(options);\n }\n\n /** Removes focus from the input. */\n @Method()\n async removeFocus() {\n this.nativeInput?.blur();\n }\n\n /** Sets a custom validation message. If `message` is not empty, the field will be considered invalid. */\n @Method()\n async setCustomValidity(message: string) {\n this.customErrorText = '';\n this.customValidation = message !== '';\n if (this.nativeInput != null) {\n this.nativeInput.setCustomValidity(message);\n this.invalid = !this.nativeInput.checkValidity();\n }\n }\n\n /** Resets the formcontrol */\n @Method()\n async reset() {\n this.value = this.defaultValue;\n this.customErrorText = '';\n this.customValidation = false;\n this.nativeInput?.setCustomValidity('');\n this.invalid = false;\n }\n\n private handleInput = () => {\n if (this.nativeInput != null) {\n this.update(parseFloat(this.nativeInput.value));\n }\n requestAnimationFrame(() => {\n this.sixChange.emit();\n });\n };\n\n private handleBlur = () => {\n this.hasFocus = false;\n this.hasTooltip = false;\n this.sixBlur.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.unobserve(this.nativeInput);\n }\n };\n\n private handleFocus = () => {\n this.hasFocus = true;\n this.hasTooltip = true;\n this.sixFocus.emit();\n if (this.nativeInput != null) {\n this.resizeObserver?.observe(this.nativeInput);\n }\n };\n\n private handleSlotChange = () => {\n this.hasHelpTextSlot = hasSlot(this.host, 'help-text');\n this.hasErrorTextSlot = hasSlot(this.host, 'error-text');\n this.hasLabelSlot = hasSlot(this.host, 'label');\n };\n\n private handleTouchStart = () => {\n this.setFocus();\n };\n\n private displayError() {\n return this.invalid && (!this.errorOnBlur || !this.hasFocus);\n }\n\n private syncTooltip(min: number, max: number, value: number) {\n if (this.tooltip !== 'none' && this.nativeInput != null && this.output != null) {\n const percent = Math.max(0, (value - min) / (max - min));\n const inputWidth = this.nativeInput.offsetWidth;\n const tooltipWidth = this.output.offsetWidth;\n const thumbSize = getComputedStyle(this.nativeInput).getPropertyValue('--thumb-size');\n const x = `calc(${inputWidth * percent}px - calc(calc(${percent} * ${thumbSize}) - calc(${thumbSize} / 2)))`;\n this.output.style.transform = `translateX(${x})`;\n this.output.style.marginLeft = `-${tooltipWidth / 2}px`;\n }\n }\n\n private isFirefox() {\n return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;\n }\n\n private update(updateValue?: number) {\n if (updateValue != null) {\n this.value = updateValue;\n }\n\n const min = Number(this.min) ?? 0;\n const max = Number(this.max) ?? 0;\n let value;\n const parsedValue = parseFloat(this.value as never);\n if (isNaN(parsedValue)) {\n value = this.getDefaultValue(min, max);\n } else {\n value = parsedValue;\n }\n\n if (this.nativeInput != null) {\n // The value may have constraints, so we set the native control's\n // value and sync it back to ensure it adheres to min, max, and step\n // properly.\n this.nativeInput.value = value.toString();\n this.value = parseFloat(this.nativeInput.value);\n } else {\n this.value = value;\n }\n this.calculateColorRunnableTrack(min, max, this.value);\n this.syncTooltip(min, max, this.value);\n }\n\n /**\n * from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range#value\n */\n private getDefaultValue(min: number, max: number): number {\n return max < min ? min : min + (max - min) / 2;\n }\n\n /**\n * For Firefox this functionality is not needed because it is supported by standard CSS.\n */\n private calculateColorRunnableTrack(min: number, max: number, value: number) {\n if (!this.isFirefox() && this.nativeInput != null) {\n const percent = Math.ceil(((value - min) / (max - min)) * 100);\n this.nativeInput.style.background =\n '-webkit-linear-gradient(left, var(--track-color) 0%, var(--track-color) ' +\n percent +\n '%, var(--six-color-web-rock-300) ' +\n percent +\n '%)';\n }\n }\n\n render() {\n return (\n <FormControl\n inputId={this.inputId}\n label={this.label}\n labelId={this.labelId}\n hasLabelSlot={this.hasLabelSlot}\n helpTextId={this.helpTextId}\n helpText={this.helpText}\n hasHelpTextSlot={this.hasHelpTextSlot}\n size=\"medium\"\n errorTextId={this.errorTextId}\n errorText={this.customErrorText != null ? this.customErrorText : this.errorText}\n hasErrorTextSlot={this.hasErrorTextSlot}\n disabled={this.disabled}\n required={this.required}\n displayError={this.displayError()}\n >\n <div\n part=\"base\"\n class={{\n range: true,\n\n // States\n 'range--disabled': this.disabled,\n 'range--focused': this.hasFocus,\n 'range--tooltip-visible': this.hasTooltip,\n 'range--tooltip-top': this.tooltip === 'top',\n 'range--tooltip-bottom': this.tooltip === 'bottom',\n }}\n onTouchStart={this.handleTouchStart}\n >\n <input\n part=\"input\"\n ref={(el) => (this.nativeInput = el)}\n type=\"range\"\n class=\"range__control\"\n name={this.name}\n disabled={this.disabled}\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.value}\n onInput={this.handleInput}\n onFocus={this.handleFocus}\n onBlur={this.handleBlur}\n />\n {this.tooltip !== 'none' && (\n <output part=\"tooltip\" ref={(el) => (this.output = el)} class=\"range__tooltip\">\n {this.tooltipFormatter(this.value)}\n </output>\n )}\n </div>\n </FormControl>\n );\n }\n}\n"],"version":3}