@cscfi/csc-ui 1.1.0 → 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.
- package/dist/cjs/c-accordion-item.cjs.entry.js +1 -1
- package/dist/cjs/c-accordion-item.cjs.entry.js.map +1 -1
- package/dist/cjs/c-dropdown_2.cjs.entry.js +1 -1
- package/dist/cjs/c-dropdown_2.cjs.entry.js.map +1 -1
- package/dist/cjs/c-slider.cjs.entry.js +100 -0
- package/dist/cjs/c-slider.cjs.entry.js.map +1 -0
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/index-91ba22ab.js +4 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/c-accordion-item/c-accordion-item.css +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +1 -0
- package/dist/collection/components/c-slider/c-slider.css +250 -0
- package/dist/collection/components/c-slider/c-slider.js +380 -0
- package/dist/collection/components/c-slider/c-slider.js.map +1 -0
- package/dist/components/c-accordion-item.js +1 -1
- package/dist/components/c-accordion-item.js.map +1 -1
- package/dist/components/c-dropdown2.js +1 -1
- package/dist/components/c-dropdown2.js.map +1 -1
- package/dist/components/c-slider.d.ts +11 -0
- package/dist/components/c-slider.js +134 -0
- package/dist/components/c-slider.js.map +1 -0
- package/dist/csc-ui/csc-ui.esm.js +1 -1
- package/dist/csc-ui/csc-ui.esm.js.map +1 -1
- package/dist/csc-ui/{p-5d21c4c7.entry.js → p-0569fc3e.entry.js} +2 -2
- package/dist/csc-ui/{p-5d21c4c7.entry.js.map → p-0569fc3e.entry.js.map} +1 -1
- package/dist/csc-ui/p-088b9c5e.entry.js +2 -0
- package/dist/csc-ui/p-088b9c5e.entry.js.map +1 -0
- package/dist/csc-ui/p-f148aad1.entry.js +2 -0
- package/dist/csc-ui/p-f148aad1.entry.js.map +1 -0
- package/dist/esm/c-accordion-item.entry.js +1 -1
- package/dist/esm/c-accordion-item.entry.js.map +1 -1
- package/dist/esm/c-dropdown_2.entry.js +1 -1
- package/dist/esm/c-dropdown_2.entry.js.map +1 -1
- package/dist/esm/c-slider.entry.js +96 -0
- package/dist/esm/c-slider.entry.js.map +1 -0
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/index-47956d53.js +4 -0
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/c-slider/c-slider.d.ts +32 -0
- package/dist/types/components.d.ts +156 -0
- package/package.json +1 -1
- package/vscode-data.json +65 -0
- package/dist/csc-ui/p-35e770d6.entry.js +0 -2
- package/dist/csc-ui/p-35e770d6.entry.js.map +0 -1
|
@@ -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,CAAC,YAAY,CAAC,OAAO,EAAE;MACpC,qBAAqB,EAAE,QAAQ;MAC/B,qBAAqB,EAAE,QAAQ;KAChC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;EACpB,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Q,EAAE,IAAI,CAAC,QAAQ,EACvB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GACxC,CACE;MAEN,WACE,KAAK,EAAE;UACL,iBAAiB,EAAE,IAAI;UACvB,2BAA2B,EAAE,IAAI,CAAC,QAAQ;SAC3C,iBACW,MAAM,IAEjB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CACpC,YACE,KAAK,EAAE;UACL,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC;UAC7C,KAAK,EAAE,IAAI,CAAC,KAAK;UACjB,MAAM,EAAE,IAAI,CAAC,UAAU;SACxB,gBACW,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,GAC3B,CACT,CAAC,CACE,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA/Hc,iBAAS,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import {\n Component,\n Event,\n EventEmitter,\n Host,\n Prop,\n State,\n Watch,\n h,\n} from '@stencil/core';\n\n/**\n * @group Form\n */\n@Component({\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:
|
|
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() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-accordion-item.js","mappings":";;;;AAAA,MAAM,iBAAiB,GAAG,u6FAAu6F;;MCqBp7FA,gBAAc;;;;;;IA4CjB,kBAAa,GAAG,KAAK,CAAC;IAEtB,iBAAY,GAAG,KAAK,CAAC;uBAvCP,KAAK;;;oBAeR,KAAK;oBAML,KAAK;;EAuBxB,aAAa,CAAC,KAAoB;IAChC,IACG,KAAK,CAAC,MAAsB,CAAC,OAAO,KAAK,kBAAkB;OAC3D,KAAK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,EACjD;MACA,KAAK,CAAC,cAAc,EAAE,CAAC;MAEvB,IAAI,CAAC,kBAAkB,CAAC,KA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,CAAC,SAAS,EAAE,EACxC,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,iBAAiB,GAAG,EAAwB,CAAC,EAChE,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,IAErB,eACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,gBAAgB,GAAG,EAAwB,CAAC,EAC/D,KAAK,EAAE,aAAa,EACpB,OAAO,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAElD,WAAK,KAAK,EAAC,wBAAwB,kBAAc,QAAQ,IACvD,YAAM,IAAI,EAAC,MAAM,GAAQ,CACrB,EAEN,WAAK,KAAK,EAAC,yBAAyB,IAAE,IAAI,CAAC,OAAO,CAAO,EAEzD,WAAK,KAAK,EAAE,gBAAgB,IAC1B,cACE,IAAI,EAAE,eAAe,EACrB,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAC1B,CACN,CACE,EAEV,WACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,iBAAiB,GAAG,EAAoB,CAAC,EAC5D,KAAK,EAAC,mCAAmC,IAEzC,WACE,KAAK,EAAC,2BAA2B,EACjC,IAAI,EAAC,QAAQ,qBACI,WAAW,cAAc,CAAC,SAAS,EAAE,IAEtD,eAAa,CACT,CACF,CACE,CACL,EACP;GACH;;;;;;;;;;AAjLcA,0BAAS,GAAG,CAAH,CAAK;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CAccordionItem"],"sources":["src/components/c-accordion-item/c-accordion-item.scss?tag=c-accordion-item&encapsulation=shadow","src/components/c-accordion-item/c-accordion-item.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-accordion-item-header-background-color: Accordion item header background color\n * @prop --c-accordion-item-outline-color: Accordion item outline color\n * @prop --c-accordion-item-text-color: Accordion item text color\n */\n --_c-accordion-item-header-background-color: var(--c-accordion-item-header-background-color, var(--c-primary-200));\n --_c-accordion-item-outline-color: var(--c-accordion-item-outline-color, var(--c-primary-600));\n --_c-accordion-item-text-color: var(--c-accordion-item-text-color, var(--c-primary-600));\n\n max-width: 100%;\n\n summary::-webkit-details-marker {\n display: none;\n }\n}\n\n.c-accordion-item {\n $this: &;\n\n --_c-accordion-item-indicator-rotation: rotate(0deg);\n --_c-accordion-item-content-height: 0;\n --_c-accordion-item-min-height: 46px;\n --_c-accordion-item-border-radius: 6px;\n --_c-accordion-item-padding: 12px;\n --_c-accordion-item-overflow: visible;\n --_c-accordion-item-outline-color-offset: 4px;\n\n display: block;\n overflow: var(--_c-accordion-item-overflow);\n\n &--expanding {\n --_c-accordion-item-overflow: hidden !important;\n --_c-accordion-item-outline-color: transparent;\n }\n\n &--expanded {\n --_c-accordion-item-content-height: auto;\n --_c-accordion-item-indicator-rotation: rotate(90deg);\n --_c-accordion-item-overflow: visible;\n }\n\n &--outlined {\n box-shadow: inset 0 0 0 2px var(--_c-accordion-item-header-background-color);\n border-radius: var(--_c-accordion-item-border-radius);\n }\n\n &__header {\n min-height: var(--_c-accordion-item-min-height);\n user-select: none;\n background-color: var(--_c-accordion-item-header-background-color);\n display: grid;\n column-gap: 8px;\n align-items: center;\n padding: 0 var(--_c-accordion-item-padding);\n border-radius: var(--_c-accordion-item-border-radius);\n cursor: pointer;\n grid-template-columns: auto 1fr auto;\n border: none;\n text-align: left;\n margin: 0;\n font-family: var(--c-font-family);\n position: relative;\n\n &--expanded {\n cursor: default;\n\n &#{$this}__header--collapsable {\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: 2px var(--_c-accordion-item-outline-color) solid;\n outline-offset: var(--_c-accordion-item-outline-color-offset);\n }\n\n @supports selector(:focus-visible) {\n &:focus {\n outline: none;\n }\n }\n\n &:focus-visible {\n outline: 2px var(--_c-accordion-item-outline-color) solid;\n outline-offset: var(--_c-accordion-item-outline-color-offset);\n }\n }\n\n &__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 500;\n font-size: 16px;\n line-height: 1;\n color: var(--_c-accordion-item-text-color);\n }\n\n &__content {\n padding: 16px;\n }\n\n &__content-wrapper {\n overflow: visible;\n }\n\n &__icon {\n height: 24px;\n font-size: 24px;\n color: var(--_c-accordion-item-text-color);\n display: flex;\n align-items: center;\n\n > * {\n height: 24px;\n display: flex;\n align-items: center;\n }\n }\n\n &__indicator {\n display: flex;\n align-items: center;\n color: var(--_c-accordion-item-text-color);\n\n c-icon {\n width: 24px;\n height: 24px !important;\n transform: var(--_c-accordion-item-indicator-rotation);\n transition: transform 0.3s ease;\n }\n }\n}\n","import {\n Component,\n h,\n Prop,\n Event,\n EventEmitter,\n Listen,\n Element,\n Host,\n} from '@stencil/core';\nimport { mdiChevronRight } from '@mdi/js';\n\n/**\n * @parent c-accordion\n * @slot Default slot - Default slot\n */\n@Component({\n tag: 'c-accordion-item',\n styleUrl: 'c-accordion-item.scss',\n shadow: true,\n})\nexport class CAccordionItem {\n @Element() el: HTMLCAccordionItemElement;\n\n /**\n * Marks the item as collapsable\n * @private\n */\n @Prop() collapsable = false;\n\n /**\n * Heading of the accordion item\n */\n @Prop() heading: string;\n\n /**\n * Value of the accordion item\n */\n @Prop() value: number | string;\n\n /**\n * Expansion status of the item\n */\n @Prop() expanded = false;\n\n /**\n * Show an outline around the expanded item\n * @private\n */\n @Prop() outlined = false;\n\n /**\n * Emit changes to the c-accordion\n * @private\n */\n @Event() itemChange: EventEmitter;\n\n private _animation: Animation;\n\n private _accordionElement: HTMLDetailsElement;\n\n private _accordionHeader: HTMLDetailsElement;\n\n private _accordionContent: HTMLDivElement;\n\n private _isCollapsing = false;\n\n private _isExpanding = false;\n\n private static _uniqueId = 0;\n\n @Listen('keydown', { capture: true })\n handleKeyDown(event: KeyboardEvent) {\n if (\n (event.target as HTMLElement).tagName === 'C-ACCORDION-ITEM' &&\n (event.key === 'Enter' || event.code === 'Space')\n ) {\n event.preventDefault();\n\n this._onToggleAccordion(event);\n }\n }\n\n @Listen('changeValue')\n stop(event: Event) {\n event.stopPropagation();\n }\n\n private get _collapsedHeight() {\n const outlineHeight = this.outlined ? 4 : 0;\n\n return this._accordionHeader.offsetHeight + outlineHeight;\n }\n\n private get _expandedHeight() {\n const outlineHeight = this.outlined ? 4 : 0;\n const headerHeight = this._accordionHeader.offsetHeight;\n const contentHeight = this._accordionContent.offsetHeight;\n\n return headerHeight + contentHeight + outlineHeight;\n }\n\n private _onToggleAccordion(e) {\n e.preventDefault();\n\n if (!this.collapsable && this.expanded) return;\n\n this._accordionElement.classList.add('c-accordion-item--expanding');\n\n if (this._isCollapsing || !this.expanded) {\n this._expand();\n } else if (this._isExpanding || this.expanded) {\n this._collapse();\n }\n }\n\n private _collapse() {\n this._isCollapsing = true;\n\n const startHeight = `${this._accordionElement.offsetHeight}px`;\n\n const endHeight = `${this._collapsedHeight}px`;\n\n if (this._animation) {\n this._animation.cancel();\n }\n\n this.itemChange.emit({ value: this.value, expanded: this.expanded });\n\n this._animation = this._accordionElement.animate(\n { height: [startHeight, endHeight] },\n { duration: 300, easing: 'cubic-bezier(0.075, 0.82, 0.165, 1)' },\n );\n\n this._animation.onfinish = () => this._onAnimationFinish(false);\n this._animation.oncancel = () => (this._isCollapsing = false);\n }\n\n private _expand() {\n this._accordionElement.style.height = `${this._accordionElement.offsetHeight}px`;\n\n this.expanded = true;\n\n window.requestAnimationFrame(() => {\n this._isExpanding = true;\n\n const startHeight = `${this._collapsedHeight}px`;\n\n const endHeight = `${this._expandedHeight}px`;\n\n if (this._animation) {\n this._animation.cancel();\n }\n\n this.itemChange.emit({ value: this.value, expanded: this.expanded });\n\n this._animation = this._accordionElement.animate(\n { height: [startHeight, endHeight] },\n { duration: 300, easing: 'cubic-bezier(0.25, 0.8, 0.5, 1)' },\n );\n\n this._animation.onfinish = () => this._onAnimationFinish(true);\n this._animation.oncancel = () => (this._isExpanding = false);\n });\n }\n\n private _onAnimationFinish(isOpen: boolean) {\n this.expanded = isOpen;\n\n this._animation = null;\n\n this._isCollapsing = false;\n\n this._isExpanding = false;\n\n this._accordionElement.style.height = '';\n\n this._accordionElement.classList.remove('c-accordion-item--expanding');\n\n this.expanded = isOpen;\n }\n\n componentWillLoad() {\n CAccordionItem._uniqueId += 1;\n }\n\n render() {\n const accordionClasses = {\n 'c-accordion-item': true,\n 'c-accordion-item--expanded': this.expanded,\n 'c-accordion-item--outlined': this.outlined,\n };\n\n const headerClasses = {\n 'c-accordion-item__header': true,\n 'c-accordion-item__header--collapsable': this.collapsable,\n 'c-accordion-item__header--expanded': this.expanded,\n };\n\n const indicatorClasses = {\n 'c-accordion-item__indicator': true,\n 'c-accordion-item__indicator--expanded': this.expanded,\n };\n\n return (\n <Host>\n <details\n id={`panel__${CAccordionItem._uniqueId}`}\n ref={(el) => (this._accordionElement = el as HTMLDetailsElement)}\n class={accordionClasses}\n open={!!this.expanded}\n >\n <summary\n ref={(el) => (this._accordionHeader = el as HTMLDetailsElement)}\n class={headerClasses}\n onClick={(event) => this._onToggleAccordion(event)}\n >\n <div class=\"c-accordion-item__icon\" aria-visible=\"hidden\">\n <slot name=\"icon\"></slot>\n </div>\n\n <div class=\"c-accordion-item__title\">{this.heading}</div>\n\n <div class={indicatorClasses}>\n <c-icon\n path={mdiChevronRight}\n class={{ expanded: this.expanded }}\n ></c-icon>\n </div>\n </summary>\n\n <div\n ref={(el) => (this._accordionContent = el as HTMLDivElement)}\n class=\"c-accordion-item__content-wrapper\"\n >\n <div\n class=\"c-accordion-item__content\"\n role=\"region\"\n aria-labelledby={`header__${CAccordionItem._uniqueId}`}\n >\n <slot></slot>\n </div>\n </div>\n </details>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-accordion-item.js","mappings":";;;;AAAA,MAAM,iBAAiB,GAAG,u6FAAu6F;;MCqBp7FA,gBAAc;;;;;;IA4CjB,kBAAa,GAAG,KAAK,CAAC;IAEtB,iBAAY,GAAG,KAAK,CAAC;uBAvCP,KAAK;;;oBAeR,KAAK;oBAML,KAAK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components/c-accordion-item/c-accordion-item.scss?tag=c-accordion-item&encapsulation=shadow","src/components/c-accordion-item/c-accordion-item.tsx"],"sourcesContent":[":host {\n /**\n * @prop --c-accordion-item-header-background-color: Accordion item header background color\n * @prop --c-accordion-item-outline-color: Accordion item outline color\n * @prop --c-accordion-item-text-color: Accordion item text color\n */\n --_c-accordion-item-header-background-color: var(--c-accordion-item-header-background-color, var(--c-primary-200));\n --_c-accordion-item-outline-color: var(--c-accordion-item-outline-color, var(--c-primary-600));\n --_c-accordion-item-text-color: var(--c-accordion-item-text-color, var(--c-primary-600));\n\n max-width: 100%;\n\n summary::-webkit-details-marker {\n display: none;\n }\n}\n\n.c-accordion-item {\n $this: &;\n\n --_c-accordion-item-indicator-rotation: rotate(0deg);\n --_c-accordion-item-content-height: 0;\n --_c-accordion-item-min-height: 46px;\n --_c-accordion-item-border-radius: 6px;\n --_c-accordion-item-padding: 12px;\n --_c-accordion-item-overflow: visible;\n --_c-accordion-item-outline-color-offset: 2px;\n\n display: block;\n overflow: var(--_c-accordion-item-overflow);\n\n &--expanding {\n --_c-accordion-item-overflow: hidden !important;\n --_c-accordion-item-outline-color: transparent;\n }\n\n &--expanded {\n --_c-accordion-item-content-height: auto;\n --_c-accordion-item-indicator-rotation: rotate(90deg);\n --_c-accordion-item-overflow: visible;\n }\n\n &--outlined {\n box-shadow: inset 0 0 0 2px var(--_c-accordion-item-header-background-color);\n border-radius: var(--_c-accordion-item-border-radius);\n }\n\n &__header {\n min-height: var(--_c-accordion-item-min-height);\n user-select: none;\n background-color: var(--_c-accordion-item-header-background-color);\n display: grid;\n column-gap: 8px;\n align-items: center;\n padding: 0 var(--_c-accordion-item-padding);\n border-radius: var(--_c-accordion-item-border-radius);\n cursor: pointer;\n grid-template-columns: auto 1fr auto;\n border: none;\n text-align: left;\n margin: 0;\n font-family: var(--c-font-family);\n position: relative;\n\n &--expanded {\n cursor: default;\n\n &#{$this}__header--collapsable {\n cursor: pointer;\n }\n }\n\n &:focus {\n outline: 2px var(--_c-accordion-item-outline-color) solid;\n outline-offset: var(--_c-accordion-item-outline-color-offset);\n }\n\n @supports selector(:focus-visible) {\n &:focus {\n outline: none;\n }\n }\n\n &:focus-visible {\n outline: 2px var(--_c-accordion-item-outline-color) solid;\n outline-offset: var(--_c-accordion-item-outline-color-offset);\n }\n }\n\n &__title {\n margin-top: 0;\n margin-bottom: 0;\n font-weight: 500;\n font-size: 16px;\n line-height: 1;\n color: var(--_c-accordion-item-text-color);\n }\n\n &__content {\n padding: 16px;\n }\n\n &__content-wrapper {\n overflow: visible;\n }\n\n &__icon {\n height: 24px;\n font-size: 24px;\n color: var(--_c-accordion-item-text-color);\n display: flex;\n align-items: center;\n\n > * {\n height: 24px;\n display: flex;\n align-items: center;\n }\n }\n\n &__indicator {\n display: flex;\n align-items: center;\n color: var(--_c-accordion-item-text-color);\n\n c-icon {\n width: 24px;\n height: 24px !important;\n transform: var(--_c-accordion-item-indicator-rotation);\n transition: transform 0.3s ease;\n }\n }\n}\n","import {\n Component,\n h,\n Prop,\n Event,\n EventEmitter,\n Listen,\n Element,\n Host,\n} from '@stencil/core';\nimport { mdiChevronRight } from '@mdi/js';\n\n/**\n * @parent c-accordion\n * @slot Default slot - Default slot\n */\n@Component({\n tag: 'c-accordion-item',\n styleUrl: 'c-accordion-item.scss',\n shadow: true,\n})\nexport class CAccordionItem {\n @Element() el: HTMLCAccordionItemElement;\n\n /**\n * Marks the item as collapsable\n * @private\n */\n @Prop() collapsable = false;\n\n /**\n * Heading of the accordion item\n */\n @Prop() heading: string;\n\n /**\n * Value of the accordion item\n */\n @Prop() value: number | string;\n\n /**\n * Expansion status of the item\n */\n @Prop() expanded = false;\n\n /**\n * Show an outline around the expanded item\n * @private\n */\n @Prop() outlined = false;\n\n /**\n * Emit changes to the c-accordion\n * @private\n */\n @Event() itemChange: EventEmitter;\n\n private _animation: Animation;\n\n private _accordionElement: HTMLDetailsElement;\n\n private _accordionHeader: HTMLDetailsElement;\n\n private _accordionContent: HTMLDivElement;\n\n private _isCollapsing = false;\n\n private _isExpanding = false;\n\n private static _uniqueId = 0;\n\n @Listen('keydown', { capture: true })\n handleKeyDown(event: KeyboardEvent) {\n if (\n (event.target as HTMLElement).tagName === 'C-ACCORDION-ITEM' &&\n (event.key === 'Enter' || event.code === 'Space')\n ) {\n event.preventDefault();\n\n this._onToggleAccordion(event);\n }\n }\n\n @Listen('changeValue')\n stop(event: Event) {\n event.stopPropagation();\n }\n\n private get _collapsedHeight() {\n const outlineHeight = this.outlined ? 4 : 0;\n\n return this._accordionHeader.offsetHeight + outlineHeight;\n }\n\n private get _expandedHeight() {\n const outlineHeight = this.outlined ? 4 : 0;\n const headerHeight = this._accordionHeader.offsetHeight;\n const contentHeight = this._accordionContent.offsetHeight;\n\n return headerHeight + contentHeight + outlineHeight;\n }\n\n private _onToggleAccordion(e) {\n e.preventDefault();\n\n if (!this.collapsable && this.expanded) return;\n\n this._accordionElement.classList.add('c-accordion-item--expanding');\n\n if (this._isCollapsing || !this.expanded) {\n this._expand();\n } else if (this._isExpanding || this.expanded) {\n this._collapse();\n }\n }\n\n private _collapse() {\n this._isCollapsing = true;\n\n const startHeight = `${this._accordionElement.offsetHeight}px`;\n\n const endHeight = `${this._collapsedHeight}px`;\n\n if (this._animation) {\n this._animation.cancel();\n }\n\n this.itemChange.emit({ value: this.value, expanded: this.expanded });\n\n this._animation = this._accordionElement.animate(\n { height: [startHeight, endHeight] },\n { duration: 300, easing: 'cubic-bezier(0.075, 0.82, 0.165, 1)' },\n );\n\n this._animation.onfinish = () => this._onAnimationFinish(false);\n this._animation.oncancel = () => (this._isCollapsing = false);\n }\n\n private _expand() {\n this._accordionElement.style.height = `${this._accordionElement.offsetHeight}px`;\n\n this.expanded = true;\n\n window.requestAnimationFrame(() => {\n this._isExpanding = true;\n\n const startHeight = `${this._collapsedHeight}px`;\n\n const endHeight = `${this._expandedHeight}px`;\n\n if (this._animation) {\n this._animation.cancel();\n }\n\n this.itemChange.emit({ value: this.value, expanded: this.expanded });\n\n this._animation = this._accordionElement.animate(\n { height: [startHeight, endHeight] },\n { duration: 300, easing: 'cubic-bezier(0.25, 0.8, 0.5, 1)' },\n );\n\n this._animation.onfinish = () => this._onAnimationFinish(true);\n this._animation.oncancel = () => (this._isExpanding = false);\n });\n }\n\n private _onAnimationFinish(isOpen: boolean) {\n this.expanded = isOpen;\n\n this._animation = null;\n\n this._isCollapsing = false;\n\n this._isExpanding = false;\n\n this._accordionElement.style.height = '';\n\n this._accordionElement.classList.remove('c-accordion-item--expanding');\n\n this.expanded = isOpen;\n }\n\n componentWillLoad() {\n CAccordionItem._uniqueId += 1;\n }\n\n render() {\n const accordionClasses = {\n 'c-accordion-item': true,\n 'c-accordion-item--expanded': this.expanded,\n 'c-accordion-item--outlined': this.outlined,\n };\n\n const headerClasses = {\n 'c-accordion-item__header': true,\n 'c-accordion-item__header--collapsable': this.collapsable,\n 'c-accordion-item__header--expanded': this.expanded,\n };\n\n const indicatorClasses = {\n 'c-accordion-item__indicator': true,\n 'c-accordion-item__indicator--expanded': this.expanded,\n };\n\n return (\n <Host>\n <details\n id={`panel__${CAccordionItem._uniqueId}`}\n ref={(el) => (this._accordionElement = el as HTMLDetailsElement)}\n class={accordionClasses}\n open={!!this.expanded}\n >\n <summary\n ref={(el) => (this._accordionHeader = el as HTMLDetailsElement)}\n class={headerClasses}\n onClick={(event) => this._onToggleAccordion(event)}\n >\n <div class=\"c-accordion-item__icon\" aria-visible=\"hidden\">\n <slot name=\"icon\"></slot>\n </div>\n\n <div class=\"c-accordion-item__title\">{this.heading}</div>\n\n <div class={indicatorClasses}>\n <c-icon\n path={mdiChevronRight}\n class={{ expanded: this.expanded }}\n ></c-icon>\n </div>\n </summary>\n\n <div\n ref={(el) => (this._accordionContent = el as HTMLDivElement)}\n class=\"c-accordion-item__content-wrapper\"\n >\n <div\n class=\"c-accordion-item__content\"\n role=\"region\"\n aria-labelledby={`header__${CAccordionItem._uniqueId}`}\n >\n <slot></slot>\n </div>\n </div>\n </details>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -2,7 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
|
|
|
2
2
|
import { a as mdiAlert } from './mdi.js';
|
|
3
3
|
import { d as defineCustomElement$1 } from './c-icon2.js';
|
|
4
4
|
|
|
5
|
-
const cDropdownCss = "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-dropdown){--_c-dropdown-background-color:var(\n --c-dropdown-background-color,\n var(--c-white)\n );--_c-dropdown-background-color-hover:var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );--_c-dropdown-text-color:var(--c-dropdown-text-color, var(--c-text-body));--_c-dropdown-text-color-active:var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );--_c-dropdown-font-size:14px;--_c-dropdown-height:42px;display:block;position:relative}:host(c-dropdown) mark{background-color:transparent;box-shadow:0 2px 0 0 var(--_c-dropdown-text-color-active);color:inherit}:host(c-dropdown) dialog{border-radius:4px;background-color:transparent;border:none;margin:-4px 0 0;overflow:visible;padding:4px 0 0;position:fixed}:host(c-dropdown) dialog::backdrop{display:none}:host(c-dropdown) dialog[open].mobile{width:100vw;max-width:100vw;height:100vh;max-height:100svh;inset:0}:host(c-dropdown) dialog[open].mobile .input-top-wrapper{padding:8px}:host(c-dropdown) dialog .input-bottom-wrapper.active{padding-top:8px}:host(c-dropdown) .dummy{display:none}:host(c-dropdown) ul{background-color:var(--_c-dropdown-background-color);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);border-radius:4px;list-style:none;margin:0;outline:none;padding:0;pointer-events:auto;visibility:hidden;width:100%;height:max-content;overflow-y:scroll}:host(c-dropdown) ul.active{visibility:visible;animation:0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1)}:host(c-dropdown) ul.active.mobile{width:100vw;max-width:100vw;height:100vh;max-height:calc(100svh - 60px)}:host(c-dropdown) li{align-items:center;column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-dropdown-font-size);min-height:var(--_c-dropdown-height);outline:none;padding-left:10px;padding-right:10px;pointer-events:auto;white-space:nowrap;width:100%;border-radius:4px}:host(c-dropdown) li span,:host(c-dropdown) li c-option-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}:host(c-dropdown) li:not(.disabled):hover,:host(c-dropdown) li:not(.disabled):focus,:host(c-dropdown) li.active{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);box-shadow:inset 0 0 0 1px var(--_c-dropdown-text-color-active)}:host(c-dropdown) li.disabled{background-color:rgba(var(--c-tertiary-rgb), 0.05);cursor:default;filter:grayscale(1) opacity(0.75)}:host(c-dropdown) .visuallyhidden{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}@keyframes fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}";
|
|
5
|
+
const cDropdownCss = "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-dropdown){--_c-dropdown-background-color:var(\n --c-dropdown-background-color,\n var(--c-white)\n );--_c-dropdown-background-color-hover:var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );--_c-dropdown-text-color:var(--c-dropdown-text-color, var(--c-text-body));--_c-dropdown-text-color-active:var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );--_c-dropdown-font-size:14px;--_c-dropdown-height:42px;display:block;position:relative}:host(c-dropdown) mark{background-color:transparent;box-shadow:0 2px 0 0 var(--_c-dropdown-text-color-active);color:inherit}:host(c-dropdown) dialog{border-radius:4px;background-color:transparent;border:none;margin:-4px 0 0;overflow:visible;padding:4px 0 0;position:fixed}:host(c-dropdown) dialog::backdrop{display:none}:host(c-dropdown) dialog[open].mobile{background-color:var(--_c-dropdown-background-color);width:100vw;max-width:100vw;height:100vh;max-height:100svh;inset:0}:host(c-dropdown) dialog[open].mobile .input-top-wrapper{padding:8px}:host(c-dropdown) dialog .input-bottom-wrapper.active{padding-top:8px}:host(c-dropdown) .dummy{display:none}:host(c-dropdown) ul{background-color:var(--_c-dropdown-background-color);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);border-radius:4px;list-style:none;margin:0;outline:none;padding:0;pointer-events:auto;visibility:hidden;width:100%;height:max-content;overflow-y:scroll}:host(c-dropdown) ul.active{visibility:visible;animation:0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1)}:host(c-dropdown) ul.active.mobile{width:100vw;max-width:100vw;height:100vh;max-height:calc(100svh - 60px)}:host(c-dropdown) li{align-items:center;column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-dropdown-font-size);min-height:var(--_c-dropdown-height);outline:none;padding-left:10px;padding-right:10px;pointer-events:auto;white-space:nowrap;width:100%;border-radius:4px}:host(c-dropdown) li span,:host(c-dropdown) li c-option-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}:host(c-dropdown) li:not(.disabled):hover,:host(c-dropdown) li:not(.disabled):focus,:host(c-dropdown) li.active{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);box-shadow:inset 0 0 0 1px var(--_c-dropdown-text-color-active)}:host(c-dropdown) li.disabled{background-color:rgba(var(--c-tertiary-rgb), 0.05);cursor:default;filter:grayscale(1) opacity(0.75)}:host(c-dropdown) .visuallyhidden{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}@keyframes fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}";
|
|
6
6
|
|
|
7
7
|
const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
8
8
|
constructor() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-drop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;;;;","names":[],"sources":["src/components/c-dropdown/c-dropdown.scss?tag=c-dropdown&encapsulation=shadow","src/components/c-dropdown/c-dropdown.tsx"],"sourcesContent":[":host(c-dropdown) {\n /**\n * @prop --c-dropdown-background-color: Menu background color\n * @prop --c-dropdown-background-color-hover: Menu item hover background color\n * @prop --c-dropdown-text-color: Menu item text color\n * @prop --c-dropdown-text-color-active: Active menu item text color\n */\n --_c-dropdown-background-color: var(\n --c-dropdown-background-color,\n var(--c-white)\n );\n --_c-dropdown-background-color-hover: var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );\n --_c-dropdown-text-color: var(--c-dropdown-text-color, var(--c-text-body));\n --_c-dropdown-text-color-active: var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );\n\n // private\n --_c-dropdown-font-size: 14px;\n --_c-dropdown-height: 42px;\n\n display: block;\n position: relative;\n\n mark {\n background-color: transparent;\n box-shadow: 0 2px 0 0 var(--_c-dropdown-text-color-active);\n color: inherit;\n }\n\n dialog {\n border-radius: 4px;\n background-color: transparent;\n border: none;\n margin: -4px 0 0;\n overflow: visible;\n padding: 4px 0 0;\n position: fixed;\n\n &::backdrop {\n display: none;\n }\n\n &[open].mobile {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100svh;\n inset: 0;\n\n .input-top-wrapper {\n padding: 8px;\n }\n }\n\n .input-bottom-wrapper.active {\n padding-top: 8px;\n }\n }\n\n .dummy {\n display: none;\n }\n\n ul {\n background-color: var(--_c-dropdown-background-color);\n box-shadow: 2px 4px 10px #00000029;\n border-radius: 4px;\n list-style: none;\n margin: 0;\n outline: none;\n padding: 0;\n pointer-events: auto;\n visibility: hidden;\n width: 100%;\n height: max-content;\n overflow-y: scroll;\n\n &.active {\n visibility: visible;\n animation: 0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n\n &.mobile {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: calc(100svh - 60px);\n }\n }\n }\n\n li {\n align-items: center;\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-dropdown-font-size);\n min-height: var(--_c-dropdown-height);\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n pointer-events: auto;\n white-space: nowrap;\n width: 100%;\n border-radius: 4px;\n\n span,\n c-option-value {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n }\n\n &:not(.disabled):hover,\n &:not(.disabled):focus,\n &.active {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n box-shadow: inset 0 0 0 1px var(--_c-dropdown-text-color-active);\n }\n\n &.disabled {\n background-color: rgba(var(--c-tertiary-rgb), 0.05);\n cursor: default;\n filter: grayscale(1) opacity(0.75);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n","import { mdiAlert } from '@mdi/js';\nimport {\n Component,\n Host,\n Prop,\n h,\n Element,\n Method,\n Watch,\n Event,\n EventEmitter,\n State,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\n\n@Component({\n tag: 'c-dropdown',\n styleUrl: 'c-dropdown.scss',\n shadow: true,\n})\nexport class CDropdown {\n @Element() el: HTMLCDropdownElement;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * Dropdown parent\n */\n @Prop() parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n /**\n * Dropdown options\n */\n @Prop() items:\n | NodeListOf<HTMLCOptionElement>\n | CAutocompleteItem[]\n | CSelectItem[];\n\n /**\n * Current index value\n */\n @Prop() index: number;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Triggered when option is selected\n */\n @Event() selectOption: EventEmitter;\n\n /**\n * Type of the parent element\n */\n @Prop() type: 'select' | 'autocomplete';\n\n /**\n * Type of items\n */\n @Prop() itemType: 'option' | 'item';\n\n /**\n * Triggered when dropdown opens or closes\n */\n @Event() dropdownStateChange: EventEmitter<boolean>;\n\n /**\n * Dropdown dialog element\n */\n private _dialog: HTMLDialogElement;\n\n private _debounce = null;\n\n private _list: HTMLUListElement;\n\n private _outsideClickFn: () => void;\n\n private _resizeObserver: ResizeObserver;\n\n private _inputElement: HTMLCInputElement;\n\n private _dummyElement: HTMLDivElement;\n\n private _isMobile = false;\n\n private _listItems: HTMLLIElement[] = [];\n\n @State() renderedList = null;\n\n @State() isOpen = false;\n\n @State() statusText = '';\n\n @Watch('items')\n optionsWatcher() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n @Watch('isOpen')\n stateWatcher() {\n this.dropdownStateChange.emit(this.isOpen);\n }\n\n @Watch('index')\n handleIndexChange(index) {\n requestAnimationFrame(() => {\n this._updateStatusText();\n\n this._listItems.forEach((item, itemIndex) => {\n item?.classList.toggle('active', index === itemIndex);\n\n if (index === itemIndex) {\n item?.focus();\n }\n });\n });\n }\n\n /**\n * @private\n */\n @Method()\n async setStatusText(text: string) {\n requestAnimationFrame(() => {\n this.statusText = text;\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(index: number) {\n requestAnimationFrame(() => {\n this._listItems[index]?.focus();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async open() {\n if (this._dialog.open) return;\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n window.addEventListener('click', this._outsideClickFn);\n\n requestAnimationFrame(() => {\n this.isOpen = true;\n\n this._positionMenu();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async close() {\n this._dialog.close();\n\n this.isOpen = false;\n\n this._inputElement.slot = 'default';\n\n this._inputElement.hideDetails = this._hideDetails;\n\n this._dummyElement.style.width = '0';\n this._dummyElement.style.display = 'none';\n this._dialog.style.width = '0';\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n private _setIsMobile() {\n this._isMobile = window.matchMedia(\n 'only screen and (max-width: 760px)',\n ).matches;\n }\n\n componentDidLoad() {\n this._setIsMobile();\n\n this._hideDetails = this.parent.hideDetails;\n\n this._inputElement = this.el.querySelector('c-input');\n\n this._resizeObserver = new ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n if (!Array.isArray(entries) || !entries.length) return;\n\n this._setIsMobile();\n\n if (!this._dialog.open) return;\n\n this.close();\n });\n });\n\n this._resizeObserver.observe(window.document.body);\n\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n /**\n * Select item\n * @returns the disabled status of the input\n */\n @Method()\n async selectItem(index: number) {\n const item = this._listItems[index];\n\n if (item.classList.contains('disabled')) {\n return true;\n }\n\n this._listItems[index].click();\n\n return false;\n }\n\n /**\n * Update list items\n */\n @Method()\n async updateList() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n private _handleOutsideClick(event) {\n if (!this.isOpen) return;\n\n if (!event.composedPath().includes(this._dialog)) {\n this.close();\n }\n }\n\n private _inputSize = {\n height: 0,\n width: 0,\n };\n\n private _openedOnTop = false;\n\n private _hideDetails = false;\n\n private _highlightMatchingText(value: string) {\n const { query } = this.parent as HTMLCAutocompleteElement;\n\n if (this.parent.tagName === 'C-SELECT' || query === '') return value;\n\n const regex = new RegExp(query, 'gi');\n\n const highlighted = value\n .replace(/(<([^>]+)>)/gi, '')\n .replace(regex, (match) => `<mark>${match}</mark>`);\n\n return highlighted;\n }\n\n private _getParentPosition() {\n return this.parent.shadowRoot\n .querySelector('.c-input__slot')\n .getBoundingClientRect();\n }\n\n private _positionMenu() {\n const { innerWidth, innerHeight } = window;\n\n this._dialog.style.width = 'auto';\n this._dialog.style.opacity = '0';\n\n this._dialog.showModal();\n\n requestAnimationFrame(() => {\n let inputSlot = 'input-top';\n\n if (!this._isMobile) {\n const { top: parentTop, width } = this._getParentPosition();\n\n const inputSize = this.el.getBoundingClientRect();\n\n this._inputSize = {\n height: inputSize.height,\n width: inputSize.width,\n };\n\n this._dialog.style.width = `${width}px`;\n this._dialog.style.top = `${inputSize.top}px`;\n this._dialog.style.bottom = 'auto';\n this._dialog.style.left = `${inputSize.left}px`;\n\n const { bottom, right, height } = this._dialog.getBoundingClientRect();\n\n const isInView = {\n x: right < innerWidth,\n y: bottom < innerHeight,\n };\n\n const fitsOnTop = parentTop - height > 0;\n\n if (!fitsOnTop && !isInView.y) {\n this._dialog.style.maxHeight = `${parentTop}px`;\n }\n\n if (!isInView.y || this._openedOnTop) {\n this._openedOnTop = true;\n\n this._inputElement.hideDetails = true;\n inputSlot = 'input-bottom';\n\n this._dialog.style.top = 'auto';\n this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;\n this._inputElement.scrollIntoView();\n }\n\n this._dummyElement.style.width = `${this._getParentPosition().width}px`;\n this._dummyElement.style.height = `${this._inputSize.height}px`;\n this._dummyElement.style.display = 'block';\n }\n\n this._dummyElement.slot = 'default';\n\n this._inputElement.slot = inputSlot;\n\n this._inputElement.hideDetails = true;\n\n this._dialog.style.opacity = '1';\n\n const input = this.parent.shadowRoot.querySelector('input');\n\n input.focus();\n });\n }\n\n private _emptyItem() {\n const { query, loading } = this.parent as HTMLCAutocompleteElement;\n\n if (!query || loading) return;\n\n return (\n <li>\n <c-icon path={mdiAlert} size={18} color=\"var(--c-warning-600)\"></c-icon>\n No suggestions found\n </li>\n );\n }\n\n private _renderList() {\n return this.itemType === 'option'\n ? this._renderOptionsList()\n : this._renderItemsList();\n }\n\n private _renderOptionsList() {\n if (!this.items.length) return this._emptyItem();\n\n const options = Array.from(this.items) as HTMLCOptionElement[];\n\n this._listItems.length = 0;\n\n return options.map((option, index) => {\n const optionValue = option.querySelector('c-option-value');\n\n if (optionValue) {\n optionValue.innerHTML = this._highlightMatchingText(\n optionValue.textContent,\n );\n }\n\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${option.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(!!option.selected).toString()}\n class={{ disabled: !!option.disabled }}\n data-name={option.name}\n onClick={(event) => {\n if (option.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: option.name, value: option.value });\n }}\n innerHTML={option.outerHTML}\n ></li>\n );\n });\n }\n\n private _renderItemsList() {\n if (!this.items.length) return this._emptyItem();\n\n this._listItems.length = 0;\n\n return (this.items as unknown as CAutocompleteItem[]).map((item, index) => {\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${item.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(this.index === index).toString()}\n class={{ disabled: !!item.disabled }}\n data-name={item.name}\n onClick={(event) => {\n if (item.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: item.name, value: item.value });\n }}\n >\n <span innerHTML={this._highlightMatchingText(item.name)}></span>\n </li>\n );\n });\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n const selection = this._listItems[this.index];\n\n const ending = !!this.items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const total = this._listItems.length;\n\n const position = this.index + 1;\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n let selectionText = !!selection\n ? `${beginning}${selection.dataset.name} - ${position} of ${total} is highlighted`\n : null;\n\n if (this.index === null && this.type === 'autocomplete') {\n selectionText = this.items.length\n ? `${this.items.length} result${\n this.items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n if (\n !this._isMobile &&\n this._dialog &&\n this.itemsPerPage &&\n this.itemsPerPage > 0 &&\n this.items.length > this.itemsPerPage\n ) {\n this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';\n this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';\n }\n\n return (\n <Host>\n <slot name=\"default\"></slot>\n\n <div class=\"dummy\" ref={(el) => (this._dummyElement = el)}></div>\n\n <dialog\n tabindex=\"-1\"\n ref={(el) => (this._dialog = el)}\n class={{ mobile: this._isMobile }}\n onCancel={() => this.close()}\n >\n <div\n id={'announce-' + this.hostId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class=\"input-top-wrapper\">\n <slot name=\"input-top\"></slot>\n </div>\n\n <ul\n ref={(el) => (this._list = el)}\n id={`${this.hostId}--results`}\n role=\"listbox\"\n aria-expanded={this.isOpen.toString()}\n class={{ active: this.isOpen, mobile: this._isMobile }}\n tabindex=\"-1\"\n >\n {this.renderedList}\n </ul>\n\n <div\n class={{ active: this._openedOnTop, 'input-bottom-wrapper': true }}\n >\n <slot name=\"input-bottom\"></slot>\n </div>\n </dialog>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-dropdown2.js","mappings":";;;;AAAA,MAAM,YAAY,GAAG,6zFAA6zF;;MCoBr0F,SAAS;;;;;;;IAwDZ,cAAS,GAAG,IAAI,CAAC;IAYjB,cAAS,GAAG,KAAK,CAAC;IAElB,eAAU,GAAoB,EAAE,CAAC;IAgKjC,eAAU,GAAG;MACnB,MAAM,EAAE,CAAC;MACT,KAAK,EAAE,CAAC;KACT,CAAC;IAEM,iBAAY,GAAG,KAAK,CAAC;IAErB,iBAAY,GAAG,KAAK,CAAC;;;;;;;;wBArKL,IAAI;kBAEV,KAAK;sBAED,EAAE;;EAGxB,cAAc;IACZ,qBAAqB,CAAC;MACpB,IAAI,CAAC,YAAY,GAA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EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,IAE5B,WACE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC,MAAM,EAC7B,KAAK,EAAC,gBAAgB,eACZ,QAAQ,iBACN,MAAM,IAEjB,IAAI,CAAC,UAAU,CACZ,EAEN,WAAK,KAAK,EAAC,mBAAmB,IAC5B,YAAM,IAAI,EAAC,WAAW,GAAQ,CAC1B,EAEN,UACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,WAAW,EAC7B,IAAI,EAAC,SAAS,mBACC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EACrC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EACtD,QAAQ,EAAC,IAAI,IAEZ,IAAI,CAAC,YAAY,CACf,EAEL,WACE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,sBAAsB,EAAE,IAAI,EAAE,IAElE,YAAM,IAAI,EAAC,cAAc,GAAQ,CAC7B,CACC,CACJ,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/c-dropdown/c-dropdown.scss?tag=c-dropdown&encapsulation=shadow","src/components/c-dropdown/c-dropdown.tsx"],"sourcesContent":[":host(c-dropdown) {\n /**\n * @prop --c-dropdown-background-color: Menu background color\n * @prop --c-dropdown-background-color-hover: Menu item hover background color\n * @prop --c-dropdown-text-color: Menu item text color\n * @prop --c-dropdown-text-color-active: Active menu item text color\n */\n --_c-dropdown-background-color: var(\n --c-dropdown-background-color,\n var(--c-white)\n );\n --_c-dropdown-background-color-hover: var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );\n --_c-dropdown-text-color: var(--c-dropdown-text-color, var(--c-text-body));\n --_c-dropdown-text-color-active: var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );\n\n // private\n --_c-dropdown-font-size: 14px;\n --_c-dropdown-height: 42px;\n\n display: block;\n position: relative;\n\n mark {\n background-color: transparent;\n box-shadow: 0 2px 0 0 var(--_c-dropdown-text-color-active);\n color: inherit;\n }\n\n dialog {\n border-radius: 4px;\n background-color: transparent;\n border: none;\n margin: -4px 0 0;\n overflow: visible;\n padding: 4px 0 0;\n position: fixed;\n\n &::backdrop {\n display: none;\n }\n\n &[open].mobile {\n background-color: var(--_c-dropdown-background-color);\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100svh;\n inset: 0;\n\n .input-top-wrapper {\n padding: 8px;\n }\n }\n\n .input-bottom-wrapper.active {\n padding-top: 8px;\n }\n }\n\n .dummy {\n display: none;\n }\n\n ul {\n background-color: var(--_c-dropdown-background-color);\n box-shadow: 2px 4px 10px #00000029;\n border-radius: 4px;\n list-style: none;\n margin: 0;\n outline: none;\n padding: 0;\n pointer-events: auto;\n visibility: hidden;\n width: 100%;\n height: max-content;\n overflow-y: scroll;\n\n &.active {\n visibility: visible;\n animation: 0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n\n &.mobile {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: calc(100svh - 60px);\n }\n }\n }\n\n li {\n align-items: center;\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-dropdown-font-size);\n min-height: var(--_c-dropdown-height);\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n pointer-events: auto;\n white-space: nowrap;\n width: 100%;\n border-radius: 4px;\n\n span,\n c-option-value {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n }\n\n &:not(.disabled):hover,\n &:not(.disabled):focus,\n &.active {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n box-shadow: inset 0 0 0 1px var(--_c-dropdown-text-color-active);\n }\n\n &.disabled {\n background-color: rgba(var(--c-tertiary-rgb), 0.05);\n cursor: default;\n filter: grayscale(1) opacity(0.75);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n","import { mdiAlert } from '@mdi/js';\nimport {\n Component,\n Host,\n Prop,\n h,\n Element,\n Method,\n Watch,\n Event,\n EventEmitter,\n State,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\n\n@Component({\n tag: 'c-dropdown',\n styleUrl: 'c-dropdown.scss',\n shadow: true,\n})\nexport class CDropdown {\n @Element() el: HTMLCDropdownElement;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * Dropdown parent\n */\n @Prop() parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n /**\n * Dropdown options\n */\n @Prop() items:\n | NodeListOf<HTMLCOptionElement>\n | CAutocompleteItem[]\n | CSelectItem[];\n\n /**\n * Current index value\n */\n @Prop() index: number;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Triggered when option is selected\n */\n @Event() selectOption: EventEmitter;\n\n /**\n * Type of the parent element\n */\n @Prop() type: 'select' | 'autocomplete';\n\n /**\n * Type of items\n */\n @Prop() itemType: 'option' | 'item';\n\n /**\n * Triggered when dropdown opens or closes\n */\n @Event() dropdownStateChange: EventEmitter<boolean>;\n\n /**\n * Dropdown dialog element\n */\n private _dialog: HTMLDialogElement;\n\n private _debounce = null;\n\n private _list: HTMLUListElement;\n\n private _outsideClickFn: () => void;\n\n private _resizeObserver: ResizeObserver;\n\n private _inputElement: HTMLCInputElement;\n\n private _dummyElement: HTMLDivElement;\n\n private _isMobile = false;\n\n private _listItems: HTMLLIElement[] = [];\n\n @State() renderedList = null;\n\n @State() isOpen = false;\n\n @State() statusText = '';\n\n @Watch('items')\n optionsWatcher() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n @Watch('isOpen')\n stateWatcher() {\n this.dropdownStateChange.emit(this.isOpen);\n }\n\n @Watch('index')\n handleIndexChange(index) {\n requestAnimationFrame(() => {\n this._updateStatusText();\n\n this._listItems.forEach((item, itemIndex) => {\n item?.classList.toggle('active', index === itemIndex);\n\n if (index === itemIndex) {\n item?.focus();\n }\n });\n });\n }\n\n /**\n * @private\n */\n @Method()\n async setStatusText(text: string) {\n requestAnimationFrame(() => {\n this.statusText = text;\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(index: number) {\n requestAnimationFrame(() => {\n this._listItems[index]?.focus();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async open() {\n if (this._dialog.open) return;\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n window.addEventListener('click', this._outsideClickFn);\n\n requestAnimationFrame(() => {\n this.isOpen = true;\n\n this._positionMenu();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async close() {\n this._dialog.close();\n\n this.isOpen = false;\n\n this._inputElement.slot = 'default';\n\n this._inputElement.hideDetails = this._hideDetails;\n\n this._dummyElement.style.width = '0';\n this._dummyElement.style.display = 'none';\n this._dialog.style.width = '0';\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n private _setIsMobile() {\n this._isMobile = window.matchMedia(\n 'only screen and (max-width: 760px)',\n ).matches;\n }\n\n componentDidLoad() {\n this._setIsMobile();\n\n this._hideDetails = this.parent.hideDetails;\n\n this._inputElement = this.el.querySelector('c-input');\n\n this._resizeObserver = new ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n if (!Array.isArray(entries) || !entries.length) return;\n\n this._setIsMobile();\n\n if (!this._dialog.open) return;\n\n this.close();\n });\n });\n\n this._resizeObserver.observe(window.document.body);\n\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n /**\n * Select item\n * @returns the disabled status of the input\n */\n @Method()\n async selectItem(index: number) {\n const item = this._listItems[index];\n\n if (item.classList.contains('disabled')) {\n return true;\n }\n\n this._listItems[index].click();\n\n return false;\n }\n\n /**\n * Update list items\n */\n @Method()\n async updateList() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n private _handleOutsideClick(event) {\n if (!this.isOpen) return;\n\n if (!event.composedPath().includes(this._dialog)) {\n this.close();\n }\n }\n\n private _inputSize = {\n height: 0,\n width: 0,\n };\n\n private _openedOnTop = false;\n\n private _hideDetails = false;\n\n private _highlightMatchingText(value: string) {\n const { query } = this.parent as HTMLCAutocompleteElement;\n\n if (this.parent.tagName === 'C-SELECT' || query === '') return value;\n\n const regex = new RegExp(query, 'gi');\n\n const highlighted = value\n .replace(/(<([^>]+)>)/gi, '')\n .replace(regex, (match) => `<mark>${match}</mark>`);\n\n return highlighted;\n }\n\n private _getParentPosition() {\n return this.parent.shadowRoot\n .querySelector('.c-input__slot')\n .getBoundingClientRect();\n }\n\n private _positionMenu() {\n const { innerWidth, innerHeight } = window;\n\n this._dialog.style.width = 'auto';\n this._dialog.style.opacity = '0';\n\n this._dialog.showModal();\n\n requestAnimationFrame(() => {\n let inputSlot = 'input-top';\n\n if (!this._isMobile) {\n const { top: parentTop, width } = this._getParentPosition();\n\n const inputSize = this.el.getBoundingClientRect();\n\n this._inputSize = {\n height: inputSize.height,\n width: inputSize.width,\n };\n\n this._dialog.style.width = `${width}px`;\n this._dialog.style.top = `${inputSize.top}px`;\n this._dialog.style.bottom = 'auto';\n this._dialog.style.left = `${inputSize.left}px`;\n\n const { bottom, right, height } = this._dialog.getBoundingClientRect();\n\n const isInView = {\n x: right < innerWidth,\n y: bottom < innerHeight,\n };\n\n const fitsOnTop = parentTop - height > 0;\n\n if (!fitsOnTop && !isInView.y) {\n this._dialog.style.maxHeight = `${parentTop}px`;\n }\n\n if (!isInView.y || this._openedOnTop) {\n this._openedOnTop = true;\n\n this._inputElement.hideDetails = true;\n inputSlot = 'input-bottom';\n\n this._dialog.style.top = 'auto';\n this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;\n this._inputElement.scrollIntoView();\n }\n\n this._dummyElement.style.width = `${this._getParentPosition().width}px`;\n this._dummyElement.style.height = `${this._inputSize.height}px`;\n this._dummyElement.style.display = 'block';\n }\n\n this._dummyElement.slot = 'default';\n\n this._inputElement.slot = inputSlot;\n\n this._inputElement.hideDetails = true;\n\n this._dialog.style.opacity = '1';\n\n const input = this.parent.shadowRoot.querySelector('input');\n\n input.focus();\n });\n }\n\n private _emptyItem() {\n const { query, loading } = this.parent as HTMLCAutocompleteElement;\n\n if (!query || loading) return;\n\n return (\n <li>\n <c-icon path={mdiAlert} size={18} color=\"var(--c-warning-600)\"></c-icon>\n No suggestions found\n </li>\n );\n }\n\n private _renderList() {\n return this.itemType === 'option'\n ? this._renderOptionsList()\n : this._renderItemsList();\n }\n\n private _renderOptionsList() {\n if (!this.items.length) return this._emptyItem();\n\n const options = Array.from(this.items) as HTMLCOptionElement[];\n\n this._listItems.length = 0;\n\n return options.map((option, index) => {\n const optionValue = option.querySelector('c-option-value');\n\n if (optionValue) {\n optionValue.innerHTML = this._highlightMatchingText(\n optionValue.textContent,\n );\n }\n\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${option.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(!!option.selected).toString()}\n class={{ disabled: !!option.disabled }}\n data-name={option.name}\n onClick={(event) => {\n if (option.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: option.name, value: option.value });\n }}\n innerHTML={option.outerHTML}\n ></li>\n );\n });\n }\n\n private _renderItemsList() {\n if (!this.items.length) return this._emptyItem();\n\n this._listItems.length = 0;\n\n return (this.items as unknown as CAutocompleteItem[]).map((item, index) => {\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${item.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(this.index === index).toString()}\n class={{ disabled: !!item.disabled }}\n data-name={item.name}\n onClick={(event) => {\n if (item.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: item.name, value: item.value });\n }}\n >\n <span innerHTML={this._highlightMatchingText(item.name)}></span>\n </li>\n );\n });\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n const selection = this._listItems[this.index];\n\n const ending = !!this.items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const total = this._listItems.length;\n\n const position = this.index + 1;\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n let selectionText = !!selection\n ? `${beginning}${selection.dataset.name} - ${position} of ${total} is highlighted`\n : null;\n\n if (this.index === null && this.type === 'autocomplete') {\n selectionText = this.items.length\n ? `${this.items.length} result${\n this.items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n if (\n !this._isMobile &&\n this._dialog &&\n this.itemsPerPage &&\n this.itemsPerPage > 0 &&\n this.items.length > this.itemsPerPage\n ) {\n this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';\n this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';\n }\n\n return (\n <Host>\n <slot name=\"default\"></slot>\n\n <div class=\"dummy\" ref={(el) => (this._dummyElement = el)}></div>\n\n <dialog\n tabindex=\"-1\"\n ref={(el) => (this._dialog = el)}\n class={{ mobile: this._isMobile }}\n onCancel={() => this.close()}\n >\n <div\n id={'announce-' + this.hostId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class=\"input-top-wrapper\">\n <slot name=\"input-top\"></slot>\n </div>\n\n <ul\n ref={(el) => (this._list = el)}\n id={`${this.hostId}--results`}\n role=\"listbox\"\n aria-expanded={this.isOpen.toString()}\n class={{ active: this.isOpen, mobile: this._isMobile }}\n tabindex=\"-1\"\n >\n {this.renderedList}\n </ul>\n\n <div\n class={{ active: this._openedOnTop, 'input-bottom-wrapper': true }}\n >\n <slot name=\"input-bottom\"></slot>\n </div>\n </dialog>\n </Host>\n );\n }\n}\n"],"version":3}
|