@cscfi/csc-ui 1.1.1 → 1.2.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.
Files changed (34) hide show
  1. package/dist/cjs/c-accordion-item.cjs.entry.js +1 -1
  2. package/dist/cjs/c-accordion-item.cjs.entry.js.map +1 -1
  3. package/dist/cjs/c-slider.cjs.entry.js +100 -0
  4. package/dist/cjs/c-slider.cjs.entry.js.map +1 -0
  5. package/dist/cjs/csc-ui.cjs.js +1 -1
  6. package/dist/cjs/index-91ba22ab.js +4 -0
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/collection/collection-manifest.json +1 -0
  9. package/dist/collection/components/c-accordion-item/c-accordion-item.css +1 -1
  10. package/dist/collection/components/c-slider/c-slider.css +250 -0
  11. package/dist/collection/components/c-slider/c-slider.js +380 -0
  12. package/dist/collection/components/c-slider/c-slider.js.map +1 -0
  13. package/dist/components/c-accordion-item.js +1 -1
  14. package/dist/components/c-accordion-item.js.map +1 -1
  15. package/dist/components/c-slider.d.ts +11 -0
  16. package/dist/components/c-slider.js +134 -0
  17. package/dist/components/c-slider.js.map +1 -0
  18. package/dist/csc-ui/csc-ui.esm.js +1 -1
  19. package/dist/csc-ui/csc-ui.esm.js.map +1 -1
  20. package/dist/csc-ui/{p-5d21c4c7.entry.js → p-0569fc3e.entry.js} +2 -2
  21. package/dist/csc-ui/{p-5d21c4c7.entry.js.map → p-0569fc3e.entry.js.map} +1 -1
  22. package/dist/csc-ui/p-088b9c5e.entry.js +2 -0
  23. package/dist/csc-ui/p-088b9c5e.entry.js.map +1 -0
  24. package/dist/esm/c-accordion-item.entry.js +1 -1
  25. package/dist/esm/c-accordion-item.entry.js.map +1 -1
  26. package/dist/esm/c-slider.entry.js +96 -0
  27. package/dist/esm/c-slider.entry.js.map +1 -0
  28. package/dist/esm/csc-ui.js +1 -1
  29. package/dist/esm/index-47956d53.js +4 -0
  30. package/dist/esm/loader.js +1 -1
  31. package/dist/types/components/c-slider/c-slider.d.ts +32 -0
  32. package/dist/types/components.d.ts +156 -0
  33. package/package.json +1 -1
  34. package/vscode-data.json +65 -0
@@ -0,0 +1,250 @@
1
+ html {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ *,
6
+ *:before,
7
+ *:after {
8
+ box-sizing: inherit;
9
+ -webkit-tap-highlight-color: transparent;
10
+ }
11
+
12
+ :host {
13
+ font-family: var(--c-font-family);
14
+ }
15
+
16
+ ::-ms-reveal {
17
+ display: none;
18
+ }
19
+
20
+ :host(c-slider) {
21
+ /**
22
+ * @prop --c-slider-background-color: Slider background color
23
+ * @prop --c-slider-background-color-active: Slider active background color
24
+ * @prop --c-slider-thumb-background-color: Slider thumb background color
25
+ * @prop --c-slider-thumb-background-color-hover: Slider thumb background color on hover
26
+ * @prop --c-slider-tooltip-background-color: Slider tooltip background color
27
+ * @prop --c-slider-tooltip-text-color: Slider tooltip text color
28
+ * @prop --c-slider-tick-color: Slider tick color
29
+ * @prop --c-slider-tick-color-active: Slider active tick color
30
+ * @prop --_c-slider-background-color-disabled: Disabled slider background color
31
+ * @prop --_c-slider-background-color-active-disabled: Active disabled slider background color
32
+ * @prop --_c-slider-thumb-background-color-disabled: Disabled slider thumb background color
33
+ */
34
+ --_c-slider-background-color: var(--c-slider-background-color, rgba(var(--c-tertiary-rgb), 0.2));
35
+ --_c-slider-background-color-active: var(--c-slider-background-color-active, var(--c-primary-500));
36
+ --_c-slider-thumb-background-color: var(--c-slider-thumb-background-color, var(--c-primary-600));
37
+ --_c-slider-thumb-background-color-hover: var(--c-slider-thumb-background-color-hover, rgba(var(--c-primary-rgb), 0.2));
38
+ --_c-slider-tooltip-background-color: var(--c-slider-tooltip-background-color, var(--c-primary-900));
39
+ --_c-slider-tooltip-text-color: var(--c-slider-tooltip-text-color, var(--c-white));
40
+ --_c-slider-tick-color: var(--c-slider-tick-color, var(--c-tertiary-500));
41
+ --_c-slider-tick-color-active: var(--c-slider-tick-color-active, var(--c-white));
42
+ --_c-slider-background-color-disabled: var(--c-slider-background-color-disabled, rgba(var(--c-tertiary-rgb), 0.2));
43
+ --_c-slider-background-color-active-disabled: var(--c-slider-background-color-active-disabled, var(--c-tertiary-400));
44
+ --_c-slider-thumb-background-color-disabled: var(--c-slider-thumb-background-color-disabled, var(--c-tertiary-500));
45
+ --_c-slider-tooltip-opacity: 0;
46
+ --_c-slider-tooltip-y: -4px;
47
+ --_c-slider-outline: none;
48
+ --_c-slider-thumb-scale: 1;
49
+ --_c-slider-thumb-shadow-size: 8px;
50
+ display: block;
51
+ isolation: isolate;
52
+ /** Mozilla Firefox */
53
+ }
54
+ :host(c-slider) .c-slider__label {
55
+ display: block;
56
+ margin-bottom: 16px;
57
+ }
58
+ :host(c-slider) .c-slider__label span.required {
59
+ color: var(--c-error-600);
60
+ }
61
+ :host(c-slider) .c-slider__wrapper {
62
+ position: relative;
63
+ padding-inline: 10px;
64
+ /** Mozilla Firefox */
65
+ }
66
+ @-moz-document url-prefix() {
67
+ :host(c-slider) .c-slider__wrapper {
68
+ padding-inline: 0;
69
+ }
70
+ }
71
+ :host(c-slider) input[type=range] {
72
+ margin: 0;
73
+ width: 100%;
74
+ appearance: none;
75
+ position: relative;
76
+ background-color: transparent;
77
+ height: 8px;
78
+ display: flex;
79
+ align-items: center;
80
+ }
81
+ :host(c-slider) input[type=range]:focus-visible {
82
+ --_c-slider-outline: 2px var(--_c-slider-thumb-background-color) solid;
83
+ outline: none;
84
+ }
85
+ :host(c-slider) input[type=range]::-webkit-slider-runnable-track {
86
+ width: calc(100% - 20px);
87
+ margin: 0 -20px;
88
+ }
89
+ :host(c-slider) input[type=range]:active {
90
+ --_c-slider-thumb-scale: 1.33;
91
+ --_c-slider-thumb-shadow-size: 0;
92
+ }
93
+ :host(c-slider) input[type=range]::-webkit-slider-container {
94
+ display: flex;
95
+ padding: 0 10px;
96
+ }
97
+ :host(c-slider) input[type=range]::-webkit-slider-thumb {
98
+ background-color: var(--_c-slider-thumb-background-color);
99
+ border-radius: 100%;
100
+ cursor: pointer;
101
+ height: 24px;
102
+ width: 24px;
103
+ appearance: none;
104
+ outline: var(--_c-slider-outline);
105
+ outline-offset: 4px;
106
+ transform: scale(var(--_c-slider-thumb-scale));
107
+ transform-origin: center;
108
+ transition: box-shadow 0.3s cubic-bezier(0.075, 0.82, 0.165, 1), transform 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
109
+ z-index: 1;
110
+ position: relative;
111
+ }
112
+ :host(c-slider) input[type=range]::-webkit-slider-thumb:hover {
113
+ box-shadow: 0 0 0 var(--_c-slider-thumb-shadow-size) var(--_c-slider-thumb-background-color-hover);
114
+ }
115
+ :host(c-slider) input[type=range][disabled] {
116
+ --_c-slider-background-color: var(--_c-slider-background-color-disabled);
117
+ --_c-slider-background-color-active: var(--_c-slider-background-color-active-disabled);
118
+ --_c-slider-thumb-background-color: var(--_c-slider-thumb-background-color-disabled);
119
+ pointer-events: none;
120
+ }
121
+ @-moz-document url-prefix() {
122
+ :host(c-slider) input[type=range]::-moz-range-thumb {
123
+ border: 0;
124
+ background-color: var(--_c-slider-thumb-background-color);
125
+ border-radius: 100%;
126
+ cursor: pointer;
127
+ height: 24px;
128
+ width: 24px;
129
+ appearance: none;
130
+ outline: var(--_c-slider-outline);
131
+ outline-offset: 2px;
132
+ transform: scale(var(--_c-slider-thumb-scale));
133
+ transform-origin: center;
134
+ transition: box-shadow 0.3s cubic-bezier(0.075, 0.82, 0.165, 1), transform 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
135
+ z-index: 1;
136
+ position: relative;
137
+ }
138
+ :host(c-slider) input[type=range]::-moz-range-thumb:hover {
139
+ box-shadow: 0 0 0 var(--_c-slider-thumb-shadow-size) var(--_c-slider-thumb-background-color-hover);
140
+ }
141
+ }
142
+ :host(c-slider) .c-slider__tooltip-wrapper {
143
+ position: relative;
144
+ height: 0;
145
+ margin-inline: 2px;
146
+ /** Mozilla Firefox */
147
+ }
148
+ @-moz-document url-prefix() {
149
+ :host(c-slider) .c-slider__tooltip-wrapper {
150
+ margin-inline: 12px;
151
+ }
152
+ }
153
+ :host(c-slider) .c-slider__tooltip-wrapper span {
154
+ transform: translate(-50%, var(--_c-slider-tooltip-y));
155
+ position: absolute;
156
+ display: inline-flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ left: calc(1% * var(--_c-slider-position));
160
+ box-sizing: border-box;
161
+ width: 24px;
162
+ height: 24px;
163
+ border-radius: 50%;
164
+ opacity: var(--_c-slider-tooltip-opacity);
165
+ transition: opacity 0.3s cubic-bezier(0.075, 0.82, 0.165, 1), transform 0.3s cubic-bezier(0.075, 0.82, 0.165, 1);
166
+ pointer-events: none;
167
+ }
168
+ :host(c-slider) .c-slider__tooltip-wrapper span::before {
169
+ content: attr(data-tooltip);
170
+ position: absolute;
171
+ bottom: 100%;
172
+ color: var(--_c-slider-tooltip-text-color);
173
+ background: var(--_c-slider-tooltip-background-color);
174
+ border-radius: 4px;
175
+ padding: 6px;
176
+ height: 30px;
177
+ display: inline-flex;
178
+ flex-wrap: nowrap;
179
+ white-space: nowrap;
180
+ top: -42px;
181
+ align-items: center;
182
+ }
183
+ :host(c-slider) .c-slider__tooltip-wrapper span::after {
184
+ position: absolute;
185
+ content: "";
186
+ width: 0;
187
+ height: 0;
188
+ left: 50%;
189
+ margin: -42px 0 0 -6px;
190
+ border-left: 6px solid transparent;
191
+ border-right: 6px solid transparent;
192
+ border-top: 6px solid var(--_c-slider-tooltip-background-color);
193
+ }
194
+ :host(c-slider) .c-slider__ticks {
195
+ --c-slider-tick-color: var(--c-tertiary-400);
196
+ justify-content: space-between;
197
+ pointer-events: none;
198
+ margin: -8px auto 0;
199
+ width: calc(100% - 16px);
200
+ height: 8px;
201
+ display: flex;
202
+ align-items: center;
203
+ border-radius: 100vw;
204
+ position: relative;
205
+ background: linear-gradient(to right, var(--_c-slider-background-color-active) calc(1% * var(--_c-slider-position)), var(--_c-slider-background-color) calc(1% * var(--_c-slider-position)));
206
+ z-index: -1;
207
+ /** Mozilla Firefox */
208
+ }
209
+ @-moz-document url-prefix() {
210
+ :host(c-slider) .c-slider__ticks {
211
+ width: calc(100% - 20px);
212
+ }
213
+ }
214
+ :host(c-slider) .c-slider__ticks--disabled {
215
+ --_c-slider-background-color-active: var(--_c-slider-background-color-active-disabled);
216
+ }
217
+ :host(c-slider) .c-slider__ticks span {
218
+ height: 4px;
219
+ padding: 0;
220
+ width: 4px;
221
+ position: relative;
222
+ font-size: 12px;
223
+ border-radius: 50%;
224
+ }
225
+ :host(c-slider) .c-slider__ticks span.ticks {
226
+ background-color: var(--_c-slider-tick-color);
227
+ }
228
+ :host(c-slider) .c-slider__ticks span.ticks.active {
229
+ background-color: var(--_c-slider-tick-color-active);
230
+ }
231
+ :host(c-slider) .c-slider__ticks span.ticks:first-child, :host(c-slider) .c-slider__ticks span.ticks:last-child {
232
+ background-color: transparent;
233
+ }
234
+ :host(c-slider) .c-slider__ticks span.labels::after {
235
+ content: attr(data-value);
236
+ position: absolute;
237
+ transform: translate(-50%);
238
+ top: 16px;
239
+ left: 2px;
240
+ }
241
+
242
+ :host(c-slider.c-slider--labels) {
243
+ padding-bottom: 20px;
244
+ }
245
+
246
+ :host(c-slider:focus-within),
247
+ :host(c-slider:hover) {
248
+ --_c-slider-tooltip-opacity: 1;
249
+ --_c-slider-tooltip-y: -8px;
250
+ }
@@ -0,0 +1,380 @@
1
+ import { Host, h, } from "@stencil/core";
2
+ export class CSlider {
3
+ constructor() {
4
+ this.hostId = undefined;
5
+ this.hostName = undefined;
6
+ this.ariaLabel = undefined;
7
+ this.max = '100';
8
+ this.min = '0';
9
+ this.step = '1';
10
+ this.value = '50';
11
+ this.unit = '%';
12
+ this.ticks = false;
13
+ this.showLabels = false;
14
+ this.disableTooltip = false;
15
+ this.label = undefined;
16
+ this.disabled = false;
17
+ this.segments = '10';
18
+ this.trackPosition = undefined;
19
+ this.tickPositions = [];
20
+ }
21
+ onSegmentChange() {
22
+ this._calculateTickPositions();
23
+ }
24
+ onValueChange(value) {
25
+ this._calculateTrackPosition();
26
+ requestAnimationFrame(() => {
27
+ this._inputElement.value = value.toString();
28
+ });
29
+ }
30
+ _formatNumber(number, decimals = 0) {
31
+ return new Intl.NumberFormat('fi-FI', {
32
+ maximumFractionDigits: decimals,
33
+ minimumFractionDigits: decimals,
34
+ }).format(number);
35
+ }
36
+ _calculateTickPositions() {
37
+ this.tickPositions = [...new Array(+this.segments + 1)].map((_, index) => {
38
+ const fraction = +this.max / +this.segments;
39
+ return (index * fraction).toString();
40
+ });
41
+ }
42
+ _calculateTrackPosition() {
43
+ this.trackPosition =
44
+ ((+this.value - +this.min) / (+this.max - +this.min)) * 100;
45
+ }
46
+ _onInput(event) {
47
+ const { value } = event.target;
48
+ this.changeValue.emit(typeof this.value === 'number' ? +value : value);
49
+ this._calculateTrackPosition();
50
+ }
51
+ _isActive(value) {
52
+ return this.trackPosition >= value;
53
+ }
54
+ componentWillLoad() {
55
+ CSlider._uniqueId += 1;
56
+ }
57
+ componentDidLoad() {
58
+ this._calculateTrackPosition();
59
+ this._calculateTickPositions();
60
+ requestAnimationFrame(() => {
61
+ this._inputElement.value = this.value.toString();
62
+ });
63
+ }
64
+ render() {
65
+ const classes = {
66
+ 'c-slider': true,
67
+ 'c-slider--labels': this.showLabels,
68
+ };
69
+ const styles = {
70
+ '--_c-slider-position': `${this.trackPosition}`,
71
+ };
72
+ return (h(Host, { class: classes, style: styles }, !!this.label && (h("label", { class: "c-slider__label" }, !!this.label && this.label)), h("div", { class: "c-slider__wrapper" }, !this.disableTooltip && (h("div", { class: "c-slider__tooltip-wrapper", "aria-hidden": "true" }, h("span", { "data-tooltip": `${this._formatNumber(+this.value)}${this.unit}` }))), h("input", { ref: (el) => (this._inputElement = el), "aria-label": this.ariaLabel || this.label, "aria-valuenow": this.value, "aria-valuetext": `${this.value}${this.unit}`, "aria-valuemin": this.min, "aria-valuemax": this.max, type: "range", name: this.hostName, id: this.hostId || `c-slider__${CSlider._uniqueId}`, min: this.min, max: this.max, step: this.step, disabled: this.disabled, onInput: (event) => this._onInput(event) })), h("div", { class: {
73
+ 'c-slider__ticks': true,
74
+ 'c-slider__ticks--disabled': this.disabled,
75
+ }, "aria-hidden": "true" }, this.tickPositions.map((position) => (h("span", { class: {
76
+ active: this._isActive(Math.round(+position)),
77
+ ticks: this.ticks,
78
+ labels: this.showLabels,
79
+ }, "data-value": Math.round(+position) }))))));
80
+ }
81
+ static get is() { return "c-slider"; }
82
+ static get encapsulation() { return "shadow"; }
83
+ static get originalStyleUrls() {
84
+ return {
85
+ "$": ["c-slider.scss"]
86
+ };
87
+ }
88
+ static get styleUrls() {
89
+ return {
90
+ "$": ["c-slider.css"]
91
+ };
92
+ }
93
+ static get properties() {
94
+ return {
95
+ "hostId": {
96
+ "type": "string",
97
+ "mutable": false,
98
+ "complexType": {
99
+ "original": "string",
100
+ "resolved": "string",
101
+ "references": {}
102
+ },
103
+ "required": false,
104
+ "optional": false,
105
+ "docs": {
106
+ "tags": [],
107
+ "text": "Id of the element"
108
+ },
109
+ "attribute": "id",
110
+ "reflect": false
111
+ },
112
+ "hostName": {
113
+ "type": "string",
114
+ "mutable": false,
115
+ "complexType": {
116
+ "original": "string",
117
+ "resolved": "string",
118
+ "references": {}
119
+ },
120
+ "required": false,
121
+ "optional": false,
122
+ "docs": {
123
+ "tags": [],
124
+ "text": "Id of the element"
125
+ },
126
+ "attribute": "name",
127
+ "reflect": false
128
+ },
129
+ "ariaLabel": {
130
+ "type": "string",
131
+ "mutable": false,
132
+ "complexType": {
133
+ "original": "string",
134
+ "resolved": "string",
135
+ "references": {}
136
+ },
137
+ "required": false,
138
+ "optional": false,
139
+ "docs": {
140
+ "tags": [],
141
+ "text": "Aria label"
142
+ },
143
+ "attribute": "aria-label",
144
+ "reflect": false
145
+ },
146
+ "max": {
147
+ "type": "string",
148
+ "mutable": false,
149
+ "complexType": {
150
+ "original": "string",
151
+ "resolved": "string",
152
+ "references": {}
153
+ },
154
+ "required": false,
155
+ "optional": false,
156
+ "docs": {
157
+ "tags": [],
158
+ "text": "Max value"
159
+ },
160
+ "attribute": "max",
161
+ "reflect": false,
162
+ "defaultValue": "'100'"
163
+ },
164
+ "min": {
165
+ "type": "string",
166
+ "mutable": false,
167
+ "complexType": {
168
+ "original": "string",
169
+ "resolved": "string",
170
+ "references": {}
171
+ },
172
+ "required": false,
173
+ "optional": false,
174
+ "docs": {
175
+ "tags": [],
176
+ "text": "Min value"
177
+ },
178
+ "attribute": "min",
179
+ "reflect": false,
180
+ "defaultValue": "'0'"
181
+ },
182
+ "step": {
183
+ "type": "string",
184
+ "mutable": false,
185
+ "complexType": {
186
+ "original": "string",
187
+ "resolved": "string",
188
+ "references": {}
189
+ },
190
+ "required": false,
191
+ "optional": false,
192
+ "docs": {
193
+ "tags": [],
194
+ "text": "Step"
195
+ },
196
+ "attribute": "step",
197
+ "reflect": false,
198
+ "defaultValue": "'1'"
199
+ },
200
+ "value": {
201
+ "type": "any",
202
+ "mutable": false,
203
+ "complexType": {
204
+ "original": "string | number",
205
+ "resolved": "number | string",
206
+ "references": {}
207
+ },
208
+ "required": false,
209
+ "optional": false,
210
+ "docs": {
211
+ "tags": [],
212
+ "text": "Value"
213
+ },
214
+ "attribute": "value",
215
+ "reflect": false,
216
+ "defaultValue": "'50'"
217
+ },
218
+ "unit": {
219
+ "type": "string",
220
+ "mutable": false,
221
+ "complexType": {
222
+ "original": "string",
223
+ "resolved": "string",
224
+ "references": {}
225
+ },
226
+ "required": false,
227
+ "optional": false,
228
+ "docs": {
229
+ "tags": [],
230
+ "text": "Unit"
231
+ },
232
+ "attribute": "unit",
233
+ "reflect": false,
234
+ "defaultValue": "'%'"
235
+ },
236
+ "ticks": {
237
+ "type": "boolean",
238
+ "mutable": false,
239
+ "complexType": {
240
+ "original": "boolean",
241
+ "resolved": "boolean",
242
+ "references": {}
243
+ },
244
+ "required": false,
245
+ "optional": false,
246
+ "docs": {
247
+ "tags": [],
248
+ "text": "Thow ticks"
249
+ },
250
+ "attribute": "ticks",
251
+ "reflect": false,
252
+ "defaultValue": "false"
253
+ },
254
+ "showLabels": {
255
+ "type": "boolean",
256
+ "mutable": false,
257
+ "complexType": {
258
+ "original": "boolean",
259
+ "resolved": "boolean",
260
+ "references": {}
261
+ },
262
+ "required": false,
263
+ "optional": false,
264
+ "docs": {
265
+ "tags": [],
266
+ "text": "Show tick labels"
267
+ },
268
+ "attribute": "show-labels",
269
+ "reflect": false,
270
+ "defaultValue": "false"
271
+ },
272
+ "disableTooltip": {
273
+ "type": "boolean",
274
+ "mutable": false,
275
+ "complexType": {
276
+ "original": "boolean",
277
+ "resolved": "boolean",
278
+ "references": {}
279
+ },
280
+ "required": false,
281
+ "optional": false,
282
+ "docs": {
283
+ "tags": [],
284
+ "text": "Disable tooltip"
285
+ },
286
+ "attribute": "disable-tooltip",
287
+ "reflect": false,
288
+ "defaultValue": "false"
289
+ },
290
+ "label": {
291
+ "type": "string",
292
+ "mutable": false,
293
+ "complexType": {
294
+ "original": "string",
295
+ "resolved": "string",
296
+ "references": {}
297
+ },
298
+ "required": false,
299
+ "optional": false,
300
+ "docs": {
301
+ "tags": [],
302
+ "text": "Label of the slider"
303
+ },
304
+ "attribute": "label",
305
+ "reflect": false
306
+ },
307
+ "disabled": {
308
+ "type": "boolean",
309
+ "mutable": false,
310
+ "complexType": {
311
+ "original": "boolean",
312
+ "resolved": "boolean",
313
+ "references": {}
314
+ },
315
+ "required": false,
316
+ "optional": false,
317
+ "docs": {
318
+ "tags": [],
319
+ "text": "Disable the slider"
320
+ },
321
+ "attribute": "disabled",
322
+ "reflect": false,
323
+ "defaultValue": "false"
324
+ },
325
+ "segments": {
326
+ "type": "string",
327
+ "mutable": false,
328
+ "complexType": {
329
+ "original": "string",
330
+ "resolved": "string",
331
+ "references": {}
332
+ },
333
+ "required": false,
334
+ "optional": false,
335
+ "docs": {
336
+ "tags": [],
337
+ "text": "Segment count"
338
+ },
339
+ "attribute": "segments",
340
+ "reflect": false,
341
+ "defaultValue": "'10'"
342
+ }
343
+ };
344
+ }
345
+ static get states() {
346
+ return {
347
+ "trackPosition": {},
348
+ "tickPositions": {}
349
+ };
350
+ }
351
+ static get events() {
352
+ return [{
353
+ "method": "changeValue",
354
+ "name": "changeValue",
355
+ "bubbles": false,
356
+ "cancelable": true,
357
+ "composed": true,
358
+ "docs": {
359
+ "tags": [],
360
+ "text": "Emit value changes to parent"
361
+ },
362
+ "complexType": {
363
+ "original": "any",
364
+ "resolved": "any",
365
+ "references": {}
366
+ }
367
+ }];
368
+ }
369
+ static get watchers() {
370
+ return [{
371
+ "propName": "segments",
372
+ "methodName": "onSegmentChange"
373
+ }, {
374
+ "propName": "value",
375
+ "methodName": "onValueChange"
376
+ }];
377
+ }
378
+ }
379
+ CSlider._uniqueId = 0;
380
+ //# sourceMappingURL=c-slider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"c-slider.js","sourceRoot":"","sources":["../../../../src/components/c-slider/c-slider.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EAEL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,KAAK,EACL,CAAC,GACF,MAAM,eAAe,CAAC;AAUvB,MAAM,OAAO,OAAO;;;;;eAmBJ,KAAK;eAKL,GAAG;gBAKF,GAAG;iBAKe,IAAI;gBAKtB,GAAG;iBAKF,KAAK;sBAKA,KAAK;0BAKD,KAAK;;oBAUX,KAAK;oBAKL,IAAI;;yBASY,EAAE;;EAOrC,eAAe;IACb,IAAI,CAAC,uBAAuB,EAAE,CAAC;EACjC,CAAC;EAGD,aAAa,CAAC,KAAK;IACjB,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAE/B,qBAAqB,CAAC,GAAG,EAAE;MACzB,IAAI,CAAC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;EACL,CAAC;EAEO,aAAa,CAAC,MAAc,EAAE,QAAQ,GAAG,CAAC;IAChD,OAAO,IAAI,IAAI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\n tag: 'c-slider',\n styleUrl: 'c-slider.scss',\n shadow: true,\n})\nexport class CSlider {\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'name' }) hostName: string;\n\n /**\n * Aria label\n */\n @Prop({ attribute: 'aria-label' }) ariaLabel: string;\n\n /**\n * Max value\n */\n @Prop() max = '100';\n\n /**\n * Min value\n */\n @Prop() min = '0';\n\n /**\n * Step\n */\n @Prop() step = '1';\n\n /**\n * Value\n */\n @Prop() value: string | number = '50';\n\n /**\n * Unit\n */\n @Prop() unit = '%';\n\n /**\n * Thow ticks\n */\n @Prop() ticks = false;\n\n /**\n * Show tick labels\n */\n @Prop() showLabels = false;\n\n /**\n * Disable tooltip\n */\n @Prop() disableTooltip = false;\n\n /**\n * Label of the slider\n */\n @Prop() label: string;\n\n /**\n * Disable the slider\n */\n @Prop() disabled = false;\n\n /**\n * Segment count\n */\n @Prop() segments = '10';\n\n /**\n * Emit value changes to parent\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n @State() trackPosition: number;\n\n @State() tickPositions: string[] = [];\n\n private static _uniqueId = 0;\n\n private _inputElement: HTMLInputElement;\n\n @Watch('segments')\n onSegmentChange() {\n this._calculateTickPositions();\n }\n\n @Watch('value')\n onValueChange(value) {\n this._calculateTrackPosition();\n\n requestAnimationFrame(() => {\n this._inputElement.value = value.toString();\n });\n }\n\n private _formatNumber(number: number, decimals = 0) {\n return new Intl.NumberFormat('fi-FI', {\n maximumFractionDigits: decimals,\n minimumFractionDigits: decimals,\n }).format(number);\n }\n\n private _calculateTickPositions() {\n this.tickPositions = [...new Array(+this.segments + 1)].map((_, index) => {\n const fraction = +this.max / +this.segments;\n\n return (index * fraction).toString();\n });\n }\n\n private _calculateTrackPosition() {\n this.trackPosition =\n ((+this.value - +this.min) / (+this.max - +this.min)) * 100;\n }\n\n private _onInput(event: Event) {\n const { value } = event.target as HTMLInputElement;\n\n this.changeValue.emit(typeof this.value === 'number' ? +value : value);\n\n this._calculateTrackPosition();\n }\n\n private _isActive(value: number) {\n return this.trackPosition >= value;\n }\n\n componentWillLoad() {\n CSlider._uniqueId += 1;\n }\n\n componentDidLoad() {\n this._calculateTrackPosition();\n\n this._calculateTickPositions();\n\n requestAnimationFrame(() => {\n this._inputElement.value = this.value.toString();\n });\n }\n\n render() {\n const classes = {\n 'c-slider': true,\n 'c-slider--labels': this.showLabels,\n };\n\n const styles = {\n '--_c-slider-position': `${this.trackPosition}`,\n };\n\n return (\n <Host class={classes} style={styles}>\n {!!this.label && (\n <label class=\"c-slider__label\">{!!this.label && this.label}</label>\n )}\n\n <div class=\"c-slider__wrapper\">\n {!this.disableTooltip && (\n <div class=\"c-slider__tooltip-wrapper\" aria-hidden=\"true\">\n <span\n data-tooltip={`${this._formatNumber(+this.value)}${this.unit}`}\n ></span>\n </div>\n )}\n\n <input\n ref={(el) => (this._inputElement = el)}\n aria-label={this.ariaLabel || this.label}\n aria-valuenow={this.value}\n aria-valuetext={`${this.value}${this.unit}`}\n aria-valuemin={this.min}\n aria-valuemax={this.max}\n type=\"range\"\n name={this.hostName}\n id={this.hostId || `c-slider__${CSlider._uniqueId}`}\n min={this.min}\n max={this.max}\n step={this.step}\n disabled={this.disabled}\n onInput={(event) => this._onInput(event)}\n />\n </div>\n\n <div\n class={{\n 'c-slider__ticks': true,\n 'c-slider__ticks--disabled': this.disabled,\n }}\n aria-hidden=\"true\"\n >\n {this.tickPositions.map((position) => (\n <span\n class={{\n active: this._isActive(Math.round(+position)),\n ticks: this.ticks,\n labels: this.showLabels,\n }}\n data-value={Math.round(+position)}\n ></span>\n ))}\n </div>\n </Host>\n );\n }\n}\n"]}
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
2
2
  import { m as mdiChevronRight } from './mdi.js';
3
3
  import { d as defineCustomElement$2 } from './c-icon2.js';
4
4
 
5
- const cAccordionItemCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-accordion-item-header-background-color:var(--c-accordion-item-header-background-color, var(--c-primary-200));--_c-accordion-item-outline-color:var(--c-accordion-item-outline-color, var(--c-primary-600));--_c-accordion-item-text-color:var(--c-accordion-item-text-color, var(--c-primary-600));max-width:100%}:host summary::-webkit-details-marker{display:none}.c-accordion-item{--_c-accordion-item-indicator-rotation:rotate(0deg);--_c-accordion-item-content-height:0;--_c-accordion-item-min-height:46px;--_c-accordion-item-border-radius:6px;--_c-accordion-item-padding:12px;--_c-accordion-item-overflow:visible;--_c-accordion-item-outline-color-offset:4px;display:block;overflow:var(--_c-accordion-item-overflow)}.c-accordion-item--expanding{--_c-accordion-item-overflow:hidden !important;--_c-accordion-item-outline-color:transparent}.c-accordion-item--expanded{--_c-accordion-item-content-height:auto;--_c-accordion-item-indicator-rotation:rotate(90deg);--_c-accordion-item-overflow:visible}.c-accordion-item--outlined{box-shadow:inset 0 0 0 2px var(--_c-accordion-item-header-background-color);border-radius:var(--_c-accordion-item-border-radius)}.c-accordion-item__header{min-height:var(--_c-accordion-item-min-height);user-select:none;background-color:var(--_c-accordion-item-header-background-color);display:grid;column-gap:8px;align-items:center;padding:0 var(--_c-accordion-item-padding);border-radius:var(--_c-accordion-item-border-radius);cursor:pointer;grid-template-columns:auto 1fr auto;border:none;text-align:left;margin:0;font-family:var(--c-font-family);position:relative}.c-accordion-item__header--expanded{cursor:default}.c-accordion-item__header--expanded.c-accordion-item__header--collapsable{cursor:pointer}.c-accordion-item__header:focus{outline:2px var(--_c-accordion-item-outline-color) solid;outline-offset:var(--_c-accordion-item-outline-color-offset)}@supports selector(:focus-visible){.c-accordion-item__header:focus{outline:none}}.c-accordion-item__header:focus-visible{outline:2px var(--_c-accordion-item-outline-color) solid;outline-offset:var(--_c-accordion-item-outline-color-offset)}.c-accordion-item__title{margin-top:0;margin-bottom:0;font-weight:500;font-size:16px;line-height:1;color:var(--_c-accordion-item-text-color)}.c-accordion-item__content{padding:16px}.c-accordion-item__content-wrapper{overflow:visible}.c-accordion-item__icon{height:24px;font-size:24px;color:var(--_c-accordion-item-text-color);display:flex;align-items:center}.c-accordion-item__icon>*{height:24px;display:flex;align-items:center}.c-accordion-item__indicator{display:flex;align-items:center;color:var(--_c-accordion-item-text-color)}.c-accordion-item__indicator c-icon{width:24px;height:24px !important;transform:var(--_c-accordion-item-indicator-rotation);transition:transform 0.3s ease}";
5
+ const cAccordionItemCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host{--_c-accordion-item-header-background-color:var(--c-accordion-item-header-background-color, var(--c-primary-200));--_c-accordion-item-outline-color:var(--c-accordion-item-outline-color, var(--c-primary-600));--_c-accordion-item-text-color:var(--c-accordion-item-text-color, var(--c-primary-600));max-width:100%}:host summary::-webkit-details-marker{display:none}.c-accordion-item{--_c-accordion-item-indicator-rotation:rotate(0deg);--_c-accordion-item-content-height:0;--_c-accordion-item-min-height:46px;--_c-accordion-item-border-radius:6px;--_c-accordion-item-padding:12px;--_c-accordion-item-overflow:visible;--_c-accordion-item-outline-color-offset:2px;display:block;overflow:var(--_c-accordion-item-overflow)}.c-accordion-item--expanding{--_c-accordion-item-overflow:hidden !important;--_c-accordion-item-outline-color:transparent}.c-accordion-item--expanded{--_c-accordion-item-content-height:auto;--_c-accordion-item-indicator-rotation:rotate(90deg);--_c-accordion-item-overflow:visible}.c-accordion-item--outlined{box-shadow:inset 0 0 0 2px var(--_c-accordion-item-header-background-color);border-radius:var(--_c-accordion-item-border-radius)}.c-accordion-item__header{min-height:var(--_c-accordion-item-min-height);user-select:none;background-color:var(--_c-accordion-item-header-background-color);display:grid;column-gap:8px;align-items:center;padding:0 var(--_c-accordion-item-padding);border-radius:var(--_c-accordion-item-border-radius);cursor:pointer;grid-template-columns:auto 1fr auto;border:none;text-align:left;margin:0;font-family:var(--c-font-family);position:relative}.c-accordion-item__header--expanded{cursor:default}.c-accordion-item__header--expanded.c-accordion-item__header--collapsable{cursor:pointer}.c-accordion-item__header:focus{outline:2px var(--_c-accordion-item-outline-color) solid;outline-offset:var(--_c-accordion-item-outline-color-offset)}@supports selector(:focus-visible){.c-accordion-item__header:focus{outline:none}}.c-accordion-item__header:focus-visible{outline:2px var(--_c-accordion-item-outline-color) solid;outline-offset:var(--_c-accordion-item-outline-color-offset)}.c-accordion-item__title{margin-top:0;margin-bottom:0;font-weight:500;font-size:16px;line-height:1;color:var(--_c-accordion-item-text-color)}.c-accordion-item__content{padding:16px}.c-accordion-item__content-wrapper{overflow:visible}.c-accordion-item__icon{height:24px;font-size:24px;color:var(--_c-accordion-item-text-color);display:flex;align-items:center}.c-accordion-item__icon>*{height:24px;display:flex;align-items:center}.c-accordion-item__indicator{display:flex;align-items:center;color:var(--_c-accordion-item-text-color)}.c-accordion-item__indicator c-icon{width:24px;height:24px !important;transform:var(--_c-accordion-item-indicator-rotation);transition:transform 0.3s ease}";
6
6
 
7
7
  const CAccordionItem$1 = proxyCustomElement(class CAccordionItem extends HTMLElement {
8
8
  constructor() {