@jumpgroup/jump-design-system 0.3.78 → 0.3.80
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/{index-230bcbae.js → index-e9479989.js} +5 -5
- package/dist/cjs/index-e9479989.js.map +1 -0
- package/dist/cjs/jump-accordion-group.cjs.entry.js +1 -1
- package/dist/cjs/jump-accordion.cjs.entry.js +1 -1
- package/dist/cjs/jump-badge.cjs.entry.js +1 -1
- package/dist/cjs/jump-button_2.cjs.entry.js +1 -1
- package/dist/cjs/jump-card-ecommerce-option.cjs.entry.js +1 -1
- package/dist/cjs/jump-card-ecommerce.cjs.entry.js +1 -1
- package/dist/cjs/jump-card.cjs.entry.js +1 -1
- package/dist/cjs/jump-design-system.cjs.js +2 -2
- package/dist/cjs/jump-filter-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/jump-filter-range.cjs.entry.js +45 -75
- package/dist/cjs/jump-filter-range.cjs.entry.js.map +1 -1
- package/dist/cjs/jump-filter-select.cjs.entry.js +61 -21
- package/dist/cjs/jump-filter-select.cjs.entry.js.map +1 -1
- package/dist/cjs/jump-filter-switch.cjs.entry.js +2 -2
- package/dist/cjs/jump-filter.cjs.entry.js +1 -1
- package/dist/cjs/jump-filtergroup.cjs.entry.js +4 -4
- package/dist/cjs/jump-navbar.cjs.entry.js +6 -6
- package/dist/cjs/jump-pagination-table.cjs.entry.js +4 -4
- package/dist/cjs/jump-pagination.cjs.entry.js +4 -4
- package/dist/cjs/jump-quantity.cjs.entry.js +4 -4
- package/dist/cjs/jump-search-bar-dropdown-item.cjs.entry.js +2 -2
- package/dist/cjs/jump-search-bar-mobile.cjs.entry.js +5 -5
- package/dist/cjs/jump-search-bar.cjs.entry.js +1 -1
- package/dist/cjs/jump-side-cart-example.cjs.entry.js +2 -2
- package/dist/cjs/jump-side-cart.cjs.entry.js +1 -1
- package/dist/cjs/jump-tab-item.cjs.entry.js +3 -3
- package/dist/cjs/jump-tab-panel.cjs.entry.js +2 -2
- package/dist/cjs/jump-tab.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/jump-filter-range/jump-filter-range.js +76 -128
- package/dist/collection/components/jump-filter-range/jump-filter-range.js.map +1 -1
- package/dist/collection/components/jump-filter-range/jump-filter-range.stories.js +13 -4
- package/dist/collection/components/jump-filter-range/jump-filter-range.stories.js.map +1 -1
- package/dist/collection/components/jump-filter-select/jump-filter-select.js +60 -21
- package/dist/collection/components/jump-filter-select/jump-filter-select.js.map +1 -1
- package/dist/collection/components/jump-filter-select/jump-filter-select.stories.js +28 -10
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.js +1 -1
- package/dist/collection/components/jump-filtergroup/jump-filtergroup.js +3 -3
- package/dist/collection/components/jump-navbar/jump-navbar.js +5 -5
- package/dist/collection/components/jump-pagination/jump-pagination.js +3 -3
- package/dist/collection/components/jump-pagination-table/jump-pagination-table.js +3 -3
- package/dist/collection/components/jump-quantity/jump-quantity.js +3 -3
- package/dist/collection/components/jump-search-bar-dropdown-item/jump-search-bar-dropdown-item.js +1 -1
- package/dist/collection/components/jump-search-bar-mobile/jump-search-bar-mobile.js +4 -4
- package/dist/collection/components/jump-side-cart/jump-side-cart.example.js +1 -1
- package/dist/collection/components/jump-tab/jump-tab.js +1 -1
- package/dist/collection/components/jump-tab-item/jump-tab-item.js +2 -2
- package/dist/collection/components/jump-tab-panel/jump-tab-panel.js +1 -1
- package/dist/collection/utils/utils.js +4 -0
- package/dist/collection/utils/utils.js.map +1 -1
- package/dist/components/jump-filter-range.js +51 -81
- package/dist/components/jump-filter-range.js.map +1 -1
- package/dist/components/jump-filter-select.js +60 -21
- package/dist/components/jump-filter-select.js.map +1 -1
- package/dist/components/jump-filter-switch.js +1 -1
- package/dist/components/jump-filtergroup.js +3 -3
- package/dist/components/jump-navbar.js +5 -5
- package/dist/components/jump-pagination-table.js +3 -3
- package/dist/components/jump-pagination.js +3 -3
- package/dist/components/jump-quantity.js +3 -3
- package/dist/components/jump-search-bar-dropdown-item.js +1 -1
- package/dist/components/jump-search-bar-mobile.js +4 -4
- package/dist/components/jump-side-cart-example.js +1 -1
- package/dist/components/jump-tab-item.js +2 -2
- package/dist/components/jump-tab-panel.js +1 -1
- package/dist/components/jump-tab.js +1 -1
- package/dist/esm/{index-4363ffe4.js → index-a94b3471.js} +5 -5
- package/dist/esm/index-a94b3471.js.map +1 -0
- package/dist/esm/jump-accordion-group.entry.js +1 -1
- package/dist/esm/jump-accordion.entry.js +1 -1
- package/dist/esm/jump-badge.entry.js +1 -1
- package/dist/esm/jump-button_2.entry.js +1 -1
- package/dist/esm/jump-card-ecommerce-option.entry.js +1 -1
- package/dist/esm/jump-card-ecommerce.entry.js +1 -1
- package/dist/esm/jump-card.entry.js +1 -1
- package/dist/esm/jump-design-system.js +3 -3
- package/dist/esm/jump-filter-checkbox.entry.js +1 -1
- package/dist/esm/jump-filter-range.entry.js +45 -75
- package/dist/esm/jump-filter-range.entry.js.map +1 -1
- package/dist/esm/jump-filter-select.entry.js +61 -21
- package/dist/esm/jump-filter-select.entry.js.map +1 -1
- package/dist/esm/jump-filter-switch.entry.js +2 -2
- package/dist/esm/jump-filter.entry.js +1 -1
- package/dist/esm/jump-filtergroup.entry.js +4 -4
- package/dist/esm/jump-navbar.entry.js +6 -6
- package/dist/esm/jump-pagination-table.entry.js +4 -4
- package/dist/esm/jump-pagination.entry.js +4 -4
- package/dist/esm/jump-quantity.entry.js +4 -4
- package/dist/esm/jump-search-bar-dropdown-item.entry.js +2 -2
- package/dist/esm/jump-search-bar-mobile.entry.js +5 -5
- package/dist/esm/jump-search-bar.entry.js +1 -1
- package/dist/esm/jump-side-cart-example.entry.js +2 -2
- package/dist/esm/jump-side-cart.entry.js +1 -1
- package/dist/esm/jump-tab-item.entry.js +3 -3
- package/dist/esm/jump-tab-panel.entry.js +2 -2
- package/dist/esm/jump-tab.entry.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/jump-design-system/jump-design-system.esm.js +1 -1
- package/dist/jump-design-system/jump-design-system.esm.js.map +1 -1
- package/dist/jump-design-system/{p-048d87ee.entry.js → p-0140b32c.entry.js} +2 -2
- package/dist/jump-design-system/{p-d40c487f.entry.js → p-02ab8fb7.entry.js} +2 -2
- package/dist/jump-design-system/{p-985e8ea6.entry.js → p-038a2a14.entry.js} +2 -2
- package/dist/jump-design-system/{p-e7b3ebb1.entry.js → p-0d86819c.entry.js} +2 -2
- package/dist/jump-design-system/{p-79e5dac6.entry.js → p-18c359e3.entry.js} +2 -2
- package/dist/jump-design-system/{p-ae1435a6.entry.js → p-1ef1fc5c.entry.js} +2 -2
- package/dist/jump-design-system/{p-1f824808.entry.js → p-264fa972.entry.js} +2 -2
- package/dist/jump-design-system/{p-e7d1e3d8.entry.js → p-421ebb5a.entry.js} +2 -2
- package/dist/jump-design-system/{p-5092836a.entry.js → p-55fcebb1.entry.js} +5 -5
- package/dist/jump-design-system/p-55fcebb1.entry.js.map +1 -0
- package/dist/jump-design-system/{p-5fb2a919.entry.js → p-629835ac.entry.js} +2 -2
- package/dist/jump-design-system/{p-a7d5e687.entry.js → p-6905cee4.entry.js} +2 -2
- package/dist/jump-design-system/{p-6e497dd6.entry.js → p-6b8fccdb.entry.js} +2 -2
- package/dist/jump-design-system/{p-9035201c.entry.js → p-6d82feb3.entry.js} +2 -2
- package/dist/jump-design-system/{p-8f02eb5e.entry.js → p-7ac9382b.entry.js} +2 -2
- package/dist/jump-design-system/{p-48bb1cbf.entry.js → p-7e35d9f1.entry.js} +3 -3
- package/dist/jump-design-system/{p-a0237406.entry.js → p-87903fff.entry.js} +2 -2
- package/dist/jump-design-system/{p-40ca24a6.js → p-98d5dd1f.js} +3 -3
- package/dist/jump-design-system/{p-40ca24a6.js.map → p-98d5dd1f.js.map} +1 -1
- package/dist/jump-design-system/{p-66c79fb9.entry.js → p-b3765945.entry.js} +4 -4
- package/dist/jump-design-system/{p-b03b8328.entry.js → p-bb18f919.entry.js} +2 -2
- package/dist/jump-design-system/{p-0cc799f3.entry.js → p-bd692b1f.entry.js} +2 -2
- package/dist/jump-design-system/{p-83b3a560.entry.js → p-cdc5daf7.entry.js} +2 -2
- package/dist/jump-design-system/p-d0ea0f54.entry.js +2 -0
- package/dist/jump-design-system/p-d1fc1ddf.entry.js +2 -0
- package/dist/jump-design-system/p-e30da431.entry.js +2 -0
- package/dist/jump-design-system/p-e30da431.entry.js.map +1 -0
- package/dist/jump-design-system/{p-916742f5.entry.js → p-f36de1a8.entry.js} +2 -2
- package/dist/jump-design-system/{p-cdc53aae.entry.js → p-ff62e250.entry.js} +2 -2
- package/dist/jump-design-system-elements.json +8 -0
- package/dist/types/components/jump-filter-range/jump-filter-range.d.ts +10 -36
- package/dist/types/components/jump-filter-range/jump-filter-range.stories.d.ts +1 -0
- package/dist/types/components/jump-filter-select/jump-filter-select.d.ts +1 -6
- package/dist/types/components.d.ts +17 -20
- package/package.json +1 -1
- package/dist/cjs/index-230bcbae.js.map +0 -1
- package/dist/esm/index-4363ffe4.js.map +0 -1
- package/dist/jump-design-system/p-37b7b679.entry.js +0 -2
- package/dist/jump-design-system/p-37b7b679.entry.js.map +0 -1
- package/dist/jump-design-system/p-5092836a.entry.js.map +0 -1
- package/dist/jump-design-system/p-6134b84b.entry.js +0 -2
- package/dist/jump-design-system/p-64024e67.entry.js +0 -2
- /package/dist/jump-design-system/{p-048d87ee.entry.js.map → p-0140b32c.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-d40c487f.entry.js.map → p-02ab8fb7.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-985e8ea6.entry.js.map → p-038a2a14.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-e7b3ebb1.entry.js.map → p-0d86819c.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-79e5dac6.entry.js.map → p-18c359e3.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-ae1435a6.entry.js.map → p-1ef1fc5c.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-1f824808.entry.js.map → p-264fa972.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-e7d1e3d8.entry.js.map → p-421ebb5a.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-5fb2a919.entry.js.map → p-629835ac.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-a7d5e687.entry.js.map → p-6905cee4.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-6e497dd6.entry.js.map → p-6b8fccdb.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-9035201c.entry.js.map → p-6d82feb3.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-8f02eb5e.entry.js.map → p-7ac9382b.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-48bb1cbf.entry.js.map → p-7e35d9f1.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-a0237406.entry.js.map → p-87903fff.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-66c79fb9.entry.js.map → p-b3765945.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-b03b8328.entry.js.map → p-bb18f919.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-0cc799f3.entry.js.map → p-bd692b1f.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-83b3a560.entry.js.map → p-cdc5daf7.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-64024e67.entry.js.map → p-d0ea0f54.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-6134b84b.entry.js.map → p-d1fc1ddf.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-916742f5.entry.js.map → p-f36de1a8.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-cdc53aae.entry.js.map → p-ff62e250.entry.js.map} +0 -0
|
@@ -3,43 +3,31 @@ import { Host, h } from "@stencil/core";
|
|
|
3
3
|
const MIN_GAP = 0;
|
|
4
4
|
export class JumpFilterRange {
|
|
5
5
|
constructor() {
|
|
6
|
-
/**
|
|
7
|
-
* Gestisce l'aggiornamento in tempo reale dello slider MINIMO.
|
|
8
|
-
* Aggiorna solo lo stato interno per un feedback visivo immediato.
|
|
9
|
-
*/
|
|
10
6
|
this.handleMinInput = (event) => {
|
|
11
7
|
const input = event.target;
|
|
12
8
|
let newMinVal = parseInt(input.value, 10);
|
|
13
|
-
if (newMinVal > this.
|
|
14
|
-
newMinVal = this.
|
|
9
|
+
if (newMinVal > this.internalMaxVal - MIN_GAP) {
|
|
10
|
+
newMinVal = this.internalMaxVal - MIN_GAP;
|
|
15
11
|
input.value = newMinVal.toString();
|
|
16
12
|
}
|
|
17
|
-
this.
|
|
13
|
+
this.internalMinVal = newMinVal;
|
|
18
14
|
};
|
|
19
|
-
/**
|
|
20
|
-
* Gestisce l'aggiornamento in tempo reale dello slider MASSIMO.
|
|
21
|
-
* Aggiorna solo lo stato interno per un feedback visivo immediato.
|
|
22
|
-
*/
|
|
23
15
|
this.handleMaxInput = (event) => {
|
|
24
16
|
const input = event.target;
|
|
25
17
|
let newMaxVal = parseInt(input.value, 10);
|
|
26
|
-
if (newMaxVal < this.
|
|
27
|
-
newMaxVal = this.
|
|
18
|
+
if (newMaxVal < this.internalMinVal + MIN_GAP) {
|
|
19
|
+
newMaxVal = this.internalMinVal + MIN_GAP;
|
|
28
20
|
input.value = newMaxVal.toString();
|
|
29
21
|
}
|
|
30
|
-
this.
|
|
22
|
+
this.internalMaxVal = newMaxVal;
|
|
31
23
|
};
|
|
32
|
-
/**
|
|
33
|
-
* Eseguito quando l'utente rilascia lo slider (evento onChange).
|
|
34
|
-
* Consolida il valore e emette l'evento finale.
|
|
35
|
-
*/
|
|
36
24
|
this.handleCommit = () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.
|
|
25
|
+
// Sincronizza le prop con lo stato interno prima di emettere l'evento
|
|
26
|
+
this.minVal = this.internalMinVal;
|
|
27
|
+
this.maxVal = this.internalMaxVal;
|
|
40
28
|
this.filterChange.emit({
|
|
41
29
|
name: this.name,
|
|
42
|
-
values:
|
|
30
|
+
values: [this.minVal, this.maxVal],
|
|
43
31
|
});
|
|
44
32
|
};
|
|
45
33
|
this.name = 'range-filter';
|
|
@@ -50,74 +38,55 @@ export class JumpFilterRange {
|
|
|
50
38
|
this.min = 0;
|
|
51
39
|
this.max = 100;
|
|
52
40
|
this.step = 1;
|
|
53
|
-
this.value = [];
|
|
54
|
-
this.disabled = false;
|
|
55
41
|
this.minVal = undefined;
|
|
56
42
|
this.maxVal = undefined;
|
|
43
|
+
this.disabled = false;
|
|
44
|
+
this.internalMinVal = undefined;
|
|
45
|
+
this.internalMaxVal = undefined;
|
|
57
46
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
this.
|
|
47
|
+
watchMinVal(newValue) {
|
|
48
|
+
this.internalMinVal = this.validateValue(newValue, 'min');
|
|
49
|
+
}
|
|
50
|
+
watchMaxVal(newValue) {
|
|
51
|
+
this.internalMaxVal = this.validateValue(newValue, 'max');
|
|
63
52
|
}
|
|
64
53
|
componentWillLoad() {
|
|
65
|
-
this.
|
|
54
|
+
this.initializeValues();
|
|
66
55
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
this.
|
|
73
|
-
this.maxVal = values[1];
|
|
56
|
+
initializeValues() {
|
|
57
|
+
this.internalMinVal = this.validateValue(this.minVal, 'min');
|
|
58
|
+
this.internalMaxVal = this.validateValue(this.maxVal, 'max');
|
|
59
|
+
// Assicura che il valore minimo non superi il massimo
|
|
60
|
+
if (this.internalMinVal > this.internalMaxVal) {
|
|
61
|
+
this.internalMinVal = this.internalMaxVal;
|
|
74
62
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
63
|
+
// Sincronizza le prop se erano indefinite
|
|
64
|
+
this.minVal = this.internalMinVal;
|
|
65
|
+
this.maxVal = this.internalMaxVal;
|
|
66
|
+
}
|
|
67
|
+
validateValue(val, type) {
|
|
68
|
+
const defaultVal = type === 'min' ? this.min : this.max;
|
|
69
|
+
if (val === undefined || val === null)
|
|
70
|
+
return defaultVal;
|
|
71
|
+
if (val < this.min)
|
|
72
|
+
return this.min;
|
|
73
|
+
if (val > this.max)
|
|
74
|
+
return this.max;
|
|
75
|
+
return val;
|
|
82
76
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Calcola lo stile per la barra di riempimento tra i due slider.
|
|
85
|
-
*/
|
|
86
77
|
getFillStyle() {
|
|
87
78
|
const range = this.max - this.min;
|
|
88
79
|
if (range === 0)
|
|
89
80
|
return { left: '0%', width: '0%' };
|
|
90
|
-
const leftPercent = ((this.
|
|
91
|
-
const rightPercent = ((this.
|
|
81
|
+
const leftPercent = ((this.internalMinVal - this.min) / range) * 100;
|
|
82
|
+
const rightPercent = ((this.internalMaxVal - this.min) / range) * 100;
|
|
92
83
|
return { left: `${leftPercent}%`, width: `${rightPercent - leftPercent}%` };
|
|
93
84
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Metodo pubblico per impostare il valore del filtro programmaticamente.
|
|
96
|
-
*/
|
|
97
|
-
async setValue(values, emitEvent = true) {
|
|
98
|
-
if (this.disabled || !values || values.length !== 2) {
|
|
99
|
-
return this.getValues();
|
|
100
|
-
}
|
|
101
|
-
this.setComponentValues(values);
|
|
102
|
-
if (emitEvent) {
|
|
103
|
-
this.handleCommit();
|
|
104
|
-
}
|
|
105
|
-
return this.getValues();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Metodo pubblico per ottenere il valore corrente.
|
|
109
|
-
*/
|
|
110
85
|
async getValues() {
|
|
111
|
-
return [this.
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Metodo pubblico per ottenere il nome del filtro.
|
|
115
|
-
*/
|
|
116
|
-
async getName() {
|
|
117
|
-
return this.name;
|
|
86
|
+
return [this.internalMinVal, this.internalMaxVal];
|
|
118
87
|
}
|
|
119
88
|
render() {
|
|
120
|
-
return (h(Host, { key: '
|
|
89
|
+
return (h(Host, { key: '86845857fd074c171e294dc033aa770700401d26', class: { 'is-disabled': this.disabled } }, h("div", { key: '113c5ed7ef5719a189811785c6e5bf35a4ff8649', class: "label-container" }, h("label", { key: 'b7415f0d21740dd5b65c1c82746a0f385b1d810f', class: "label-min" }, this.labelMinBefore, " ", this.internalMinVal, this.labelMinAfter), h("label", { key: '934a8fdff0fc69f0c2a9e6cd404c7df94d79f7ce', class: "label-max" }, this.labelMaxBefore, " ", this.internalMaxVal, this.labelMaxAfter)), h("div", { key: '71e3c78ba4433bb63d522e34842dcdc91e421100', class: "slider-container" }, h("div", { key: '6514105f0f22b475c2a7f210fed6bbb88d5f7148', class: "slider-track" }), h("div", { key: 'eb02aaa3b388a51136df71a94e9f0128e35653a1', class: "slider-fill", style: this.getFillStyle() }), h("input", { key: 'c11e5cf68251d18d15b46a9fbf2129e33a732e69', type: "range", min: this.min, max: this.max, step: this.step, value: this.internalMinVal, onInput: this.handleMinInput, onChange: this.handleCommit, disabled: this.disabled, class: "range-input", "aria-label": this.labelMinBefore }), h("input", { key: '41a5bc8333377c6028894735e60f8e7645c4abf3', type: "range", min: this.min, max: this.max, step: this.step, value: this.internalMaxVal, onInput: this.handleMaxInput, onChange: this.handleCommit, disabled: this.disabled, class: "range-input", "aria-label": this.labelMaxBefore }))));
|
|
121
90
|
}
|
|
122
91
|
static get is() { return "jump-filter-range"; }
|
|
123
92
|
static get encapsulation() { return "shadow"; }
|
|
@@ -277,21 +246,39 @@ export class JumpFilterRange {
|
|
|
277
246
|
"reflect": false,
|
|
278
247
|
"defaultValue": "1"
|
|
279
248
|
},
|
|
280
|
-
"
|
|
281
|
-
"type": "
|
|
282
|
-
"mutable":
|
|
249
|
+
"minVal": {
|
|
250
|
+
"type": "number",
|
|
251
|
+
"mutable": false,
|
|
283
252
|
"complexType": {
|
|
284
|
-
"original": "number
|
|
285
|
-
"resolved": "number
|
|
253
|
+
"original": "number",
|
|
254
|
+
"resolved": "number",
|
|
255
|
+
"references": {}
|
|
256
|
+
},
|
|
257
|
+
"required": false,
|
|
258
|
+
"optional": false,
|
|
259
|
+
"docs": {
|
|
260
|
+
"tags": [],
|
|
261
|
+
"text": "Il valore minimo dello slider."
|
|
262
|
+
},
|
|
263
|
+
"attribute": "min-val",
|
|
264
|
+
"reflect": false
|
|
265
|
+
},
|
|
266
|
+
"maxVal": {
|
|
267
|
+
"type": "number",
|
|
268
|
+
"mutable": false,
|
|
269
|
+
"complexType": {
|
|
270
|
+
"original": "number",
|
|
271
|
+
"resolved": "number",
|
|
286
272
|
"references": {}
|
|
287
273
|
},
|
|
288
274
|
"required": false,
|
|
289
275
|
"optional": false,
|
|
290
276
|
"docs": {
|
|
291
277
|
"tags": [],
|
|
292
|
-
"text": "
|
|
278
|
+
"text": "Il valore massimo dello slider."
|
|
293
279
|
},
|
|
294
|
-
"
|
|
280
|
+
"attribute": "max-val",
|
|
281
|
+
"reflect": false
|
|
295
282
|
},
|
|
296
283
|
"disabled": {
|
|
297
284
|
"type": "boolean",
|
|
@@ -315,8 +302,8 @@ export class JumpFilterRange {
|
|
|
315
302
|
}
|
|
316
303
|
static get states() {
|
|
317
304
|
return {
|
|
318
|
-
"
|
|
319
|
-
"
|
|
305
|
+
"internalMinVal": {},
|
|
306
|
+
"internalMaxVal": {}
|
|
320
307
|
};
|
|
321
308
|
}
|
|
322
309
|
static get events() {
|
|
@@ -328,7 +315,7 @@ export class JumpFilterRange {
|
|
|
328
315
|
"composed": true,
|
|
329
316
|
"docs": {
|
|
330
317
|
"tags": [],
|
|
331
|
-
"text": "Evento emesso SOLO quando l'utente ha terminato la selezione (al rilascio del mouse)
|
|
318
|
+
"text": "Evento emesso SOLO quando l'utente ha terminato la selezione (al rilascio del mouse)."
|
|
332
319
|
},
|
|
333
320
|
"complexType": {
|
|
334
321
|
"original": "{ name: string; values: number[] }",
|
|
@@ -339,31 +326,6 @@ export class JumpFilterRange {
|
|
|
339
326
|
}
|
|
340
327
|
static get methods() {
|
|
341
328
|
return {
|
|
342
|
-
"setValue": {
|
|
343
|
-
"complexType": {
|
|
344
|
-
"signature": "(values: number[], emitEvent?: boolean) => Promise<number[]>",
|
|
345
|
-
"parameters": [{
|
|
346
|
-
"name": "values",
|
|
347
|
-
"type": "number[]",
|
|
348
|
-
"docs": ""
|
|
349
|
-
}, {
|
|
350
|
-
"name": "emitEvent",
|
|
351
|
-
"type": "boolean",
|
|
352
|
-
"docs": ""
|
|
353
|
-
}],
|
|
354
|
-
"references": {
|
|
355
|
-
"Promise": {
|
|
356
|
-
"location": "global",
|
|
357
|
-
"id": "global::Promise"
|
|
358
|
-
}
|
|
359
|
-
},
|
|
360
|
-
"return": "Promise<number[]>"
|
|
361
|
-
},
|
|
362
|
-
"docs": {
|
|
363
|
-
"text": "Metodo pubblico per impostare il valore del filtro programmaticamente.",
|
|
364
|
-
"tags": []
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
329
|
"getValues": {
|
|
368
330
|
"complexType": {
|
|
369
331
|
"signature": "() => Promise<number[]>",
|
|
@@ -377,24 +339,7 @@ export class JumpFilterRange {
|
|
|
377
339
|
"return": "Promise<number[]>"
|
|
378
340
|
},
|
|
379
341
|
"docs": {
|
|
380
|
-
"text": "
|
|
381
|
-
"tags": []
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
"getName": {
|
|
385
|
-
"complexType": {
|
|
386
|
-
"signature": "() => Promise<string>",
|
|
387
|
-
"parameters": [],
|
|
388
|
-
"references": {
|
|
389
|
-
"Promise": {
|
|
390
|
-
"location": "global",
|
|
391
|
-
"id": "global::Promise"
|
|
392
|
-
}
|
|
393
|
-
},
|
|
394
|
-
"return": "Promise<string>"
|
|
395
|
-
},
|
|
396
|
-
"docs": {
|
|
397
|
-
"text": "Metodo pubblico per ottenere il nome del filtro.",
|
|
342
|
+
"text": "",
|
|
398
343
|
"tags": []
|
|
399
344
|
}
|
|
400
345
|
}
|
|
@@ -403,8 +348,11 @@ export class JumpFilterRange {
|
|
|
403
348
|
static get elementRef() { return "host"; }
|
|
404
349
|
static get watchers() {
|
|
405
350
|
return [{
|
|
406
|
-
"propName": "
|
|
407
|
-
"methodName": "
|
|
351
|
+
"propName": "minVal",
|
|
352
|
+
"methodName": "watchMinVal"
|
|
353
|
+
}, {
|
|
354
|
+
"propName": "maxVal",
|
|
355
|
+
"methodName": "watchMaxVal"
|
|
408
356
|
}];
|
|
409
357
|
}
|
|
410
358
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jump-filter-range.js","sourceRoot":"","sources":["../../../src/components/jump-filter-range/jump-filter-range.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAgB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7G,yEAAyE;AACzE,MAAM,OAAO,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,eAAe;;QAkE1B;;;WAGG;QACK,mBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,IAAI,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAE1C,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC;gBACtC,SAAS,GAAG,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;gBAClC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACrC,CAAC;YACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QAC1B,CAAC,CAAC;QAEF;;;WAGG;QACK,mBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,IAAI,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,E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AI,CAAC,QAAQ,EACvB,KAAK,EAAC,aAAa,gBACP,IAAI,CAAC,cAAc,GAC/B;gBACF,8DACE,IAAI,EAAC,OAAO,EACZ,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,GAAG,EAAE,IAAI,CAAC,GAAG,EACb,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,KAAK,EAAE,IAAI,CAAC,MAAM,EAClB,OAAO,EAAE,IAAI,CAAC,cAAc,EAC5B,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAC,aAAa,gBACP,IAAI,CAAC,cAAc,GAC/B,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h, Event, EventEmitter, Method, State, Watch, Element } from '@stencil/core';\n\n// La distanza minima tra i due slider, per evitare che si sovrappongano.\nconst MIN_GAP = 0;\n\n@Component({\n tag: 'jump-filter-range',\n styleUrl: 'jump-filter-range.scss',\n shadow: true,\n})\nexport class JumpFilterRange {\n @Element() host: HTMLElement;\n\n /** Nome identificativo del filtro, utilizzato nell'evento finale. */\n @Prop() name: string = 'range-filter';\n\n /** Testo da mostrare prima del valore minimo. */\n @Prop() labelMinBefore: string = 'Min:';\n /** Testo da mostrare dopo il valore minimo (es. unità di misura). */\n @Prop() labelMinAfter: string = '';\n\n /** Testo da mostrare prima del valore massimo. */\n @Prop() labelMaxBefore: string = 'Max:';\n /** Testo da mostrare dopo il valore massimo (es. unità di misura). */\n @Prop() labelMaxAfter: string = '';\n\n /** Il valore minimo possibile per lo slider. */\n @Prop() min: number = 0;\n /** Il valore massimo possibile per lo slider. */\n @Prop() max: number = 100;\n /** L'incremento tra i valori dello slider. */\n @Prop() step: number = 1;\n /** I valori iniziali dello slider, come array [min, max]. */\n @Prop({ mutable: true }) value: number[] = [];\n /** Stato disabilitato dello slider. */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n @State() minVal: number;\n @State() maxVal: number;\n\n /**\n * Evento emesso SOLO quando l'utente ha terminato la selezione (al rilascio del mouse).\n * Ideale per lanciare chiamate API o ricalcoli onerosi.\n */\n @Event({ eventName: 'jump-filterchange' }) filterChange: EventEmitter<{ name: string; values: number[] }>;\n\n @Watch('value')\n valueWatcher(newValue: number[]) {\n if (newValue && newValue.length === 2 && newValue[0] === this.minVal && newValue[1] === this.maxVal) {\n return;\n }\n \n this.setComponentValues(newValue);\n }\n\n\n componentWillLoad() {\n this.setComponentValues(this.value);\n }\n\n /**\n * Imposta i valori interni del componente partendo da un array.\n */\n private setComponentValues(values: number[]) {\n if (values && values.length === 2) {\n this.minVal = values[0];\n this.maxVal = values[1];\n } else {\n // Fallback ai valori di default se l'input non è valido\n this.minVal = this.min;\n this.maxVal = this.max;\n }\n // Sincronizza la prop `value` con lo stato interno\n this.value = [this.minVal, this.maxVal];\n }\n\n /**\n * Gestisce l'aggiornamento in tempo reale dello slider MINIMO.\n * Aggiorna solo lo stato interno per un feedback visivo immediato.\n */\n private handleMinInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n let newMinVal = parseInt(input.value, 10);\n\n if (newMinVal > this.maxVal - MIN_GAP) {\n newMinVal = this.maxVal - MIN_GAP;\n input.value = newMinVal.toString();\n }\n this.minVal = newMinVal;\n };\n\n /**\n * Gestisce l'aggiornamento in tempo reale dello slider MASSIMO.\n * Aggiorna solo lo stato interno per un feedback visivo immediato.\n */\n private handleMaxInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n let newMaxVal = parseInt(input.value, 10);\n\n if (newMaxVal < this.minVal + MIN_GAP) {\n newMaxVal = this.minVal + MIN_GAP;\n input.value = newMaxVal.toString();\n }\n this.maxVal = newMaxVal;\n };\n\n /**\n * Eseguito quando l'utente rilascia lo slider (evento onChange).\n * Consolida il valore e emette l'evento finale.\n */\n private handleCommit = () => {\n console.log('Committing values:', this.minVal, this.maxVal);\n const currentValues = [this.minVal, this.maxVal];\n this.value = currentValues; // Sincronizza la prop\n this.filterChange.emit({\n name: this.name,\n values: currentValues,\n });\n };\n\n /**\n * Calcola lo stile per la barra di riempimento tra i due slider.\n */\n private getFillStyle() {\n const range = this.max - this.min;\n if (range === 0) return { left: '0%', width: '0%' };\n\n const leftPercent = ((this.minVal - this.min) / range) * 100;\n const rightPercent = ((this.maxVal - this.min) / range) * 100;\n return { left: `${leftPercent}%`, width: `${rightPercent - leftPercent}%` };\n }\n\n /**\n * Metodo pubblico per impostare il valore del filtro programmaticamente.\n */\n @Method()\n async setValue(values: number[], emitEvent: boolean = true): Promise<number[]> {\n if (this.disabled || !values || values.length !== 2) {\n return this.getValues();\n }\n this.setComponentValues(values);\n if (emitEvent) {\n this.handleCommit();\n }\n return this.getValues();\n }\n\n /**\n * Metodo pubblico per ottenere il valore corrente.\n */\n @Method()\n async getValues(): Promise<number[]> {\n return [this.minVal, this.maxVal];\n }\n\n /**\n * Metodo pubblico per ottenere il nome del filtro.\n */\n @Method()\n async getName(): Promise<string> {\n return this.name;\n }\n\n render() {\n return (\n <Host class={{ 'is-disabled': this.disabled }}>\n <div class=\"label-container\">\n <label class=\"label-min\">\n {this.labelMinBefore} {this.minVal}{this.labelMinAfter}\n </label>\n <label class=\"label-max\">\n {this.labelMaxBefore} {this.maxVal}{this.labelMaxAfter}\n </label>\n </div>\n <div class=\"slider-container\">\n <div class=\"slider-track\"></div>\n <div class=\"slider-fill\" style={this.getFillStyle()}></div>\n <input\n type=\"range\"\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.minVal}\n onInput={this.handleMinInput}\n onChange={this.handleCommit}\n disabled={this.disabled}\n class=\"range-input\"\n aria-label={this.labelMinBefore}\n />\n <input\n type=\"range\"\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.maxVal}\n onInput={this.handleMaxInput}\n onChange={this.handleCommit}\n disabled={this.disabled}\n class=\"range-input\"\n aria-label={this.labelMaxBefore}\n />\n </div>\n </Host>\n );\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"jump-filter-range.js","sourceRoot":"","sources":["../../../src/components/jump-filter-range/jump-filter-range.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAgB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7G,yEAAyE;AACzE,MAAM,OAAO,GAAG,CAAC,CAAC;AAOlB,MAAM,OAAO,eAAe;;QA2ElB,mBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,IAAI,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAE1C,IAAI,SAAS,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,CAAC;gBAC9C,SAAS,GAAG,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;gBAC1C,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACrC,CAAC;YACD,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAClC,CAAC,CAAC;QAEM,mBAAc,GAAG,CAAC,KAAY,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,KAAK,CAAC,MAA0B,CAAC;YAC/C,IAAI,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAE1C,IAAI,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B,QAAQ,EAAE,IAAI,CAAC,YAAY,EAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ,EACvB,KAAK,EAAC,aAAa,gBACP,IAAI,CAAC,cAAc,GAC/B,CACE,CACD,CACR,CAAC;IACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h, Event, EventEmitter, Method, State, Watch, Element } from '@stencil/core';\n\n// La distanza minima tra i due slider, per evitare che si sovrappongano.\nconst MIN_GAP = 0;\n\n@Component({\n tag: 'jump-filter-range',\n styleUrl: 'jump-filter-range.scss',\n shadow: true,\n})\nexport class JumpFilterRange {\n @Element() host: HTMLElement;\n\n /** Nome identificativo del filtro, utilizzato nell'evento finale. */\n @Prop() name: string = 'range-filter';\n\n /** Testo da mostrare prima del valore minimo. */\n @Prop() labelMinBefore: string = 'Min:';\n /** Testo da mostrare dopo il valore minimo (es. unità di misura). */\n @Prop() labelMinAfter: string = '';\n\n /** Testo da mostrare prima del valore massimo. */\n @Prop() labelMaxBefore: string = 'Max:';\n /** Testo da mostrare dopo il valore massimo (es. unità di misura). */\n @Prop() labelMaxAfter: string = '';\n\n /** Il valore minimo possibile per lo slider. */\n @Prop() min: number = 0;\n /** Il valore massimo possibile per lo slider. */\n @Prop() max: number = 100;\n /** L'incremento tra i valori dello slider. */\n @Prop() step: number = 1;\n\n /** Il valore minimo dello slider. */\n @Prop() minVal: number;\n /** Il valore massimo dello slider. */\n @Prop() maxVal: number;\n\n /** Stato disabilitato dello slider. */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n @State() private internalMinVal: number;\n @State() private internalMaxVal: number;\n\n /**\n * Evento emesso SOLO quando l'utente ha terminato la selezione (al rilascio del mouse).\n */\n @Event({ eventName: 'jump-filterchange' }) filterChange: EventEmitter<{ name: string; values: number[] }>;\n\n @Watch('minVal')\n watchMinVal(newValue: number) {\n this.internalMinVal = this.validateValue(newValue, 'min');\n }\n\n @Watch('maxVal')\n watchMaxVal(newValue: number) {\n this.internalMaxVal = this.validateValue(newValue, 'max');\n }\n\n componentWillLoad() {\n this.initializeValues();\n }\n\n private initializeValues() {\n this.internalMinVal = this.validateValue(this.minVal, 'min');\n this.internalMaxVal = this.validateValue(this.maxVal, 'max');\n\n // Assicura che il valore minimo non superi il massimo\n if (this.internalMinVal > this.internalMaxVal) {\n this.internalMinVal = this.internalMaxVal;\n }\n\n // Sincronizza le prop se erano indefinite\n this.minVal = this.internalMinVal;\n this.maxVal = this.internalMaxVal;\n }\n\n private validateValue(val: number, type: 'min' | 'max'): number {\n const defaultVal = type === 'min' ? this.min : this.max;\n if (val === undefined || val === null) return defaultVal;\n if (val < this.min) return this.min;\n if (val > this.max) return this.max;\n return val;\n }\n\n private handleMinInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n let newMinVal = parseInt(input.value, 10);\n\n if (newMinVal > this.internalMaxVal - MIN_GAP) {\n newMinVal = this.internalMaxVal - MIN_GAP;\n input.value = newMinVal.toString();\n }\n this.internalMinVal = newMinVal;\n };\n\n private handleMaxInput = (event: Event) => {\n const input = event.target as HTMLInputElement;\n let newMaxVal = parseInt(input.value, 10);\n\n if (newMaxVal < this.internalMinVal + MIN_GAP) {\n newMaxVal = this.internalMinVal + MIN_GAP;\n input.value = newMaxVal.toString();\n }\n this.internalMaxVal = newMaxVal;\n };\n\n private handleCommit = () => {\n // Sincronizza le prop con lo stato interno prima di emettere l'evento\n this.minVal = this.internalMinVal;\n this.maxVal = this.internalMaxVal;\n\n this.filterChange.emit({\n name: this.name,\n values: [this.minVal, this.maxVal],\n });\n };\n\n private getFillStyle() {\n const range = this.max - this.min;\n if (range === 0) return { left: '0%', width: '0%' };\n\n const leftPercent = ((this.internalMinVal - this.min) / range) * 100;\n const rightPercent = ((this.internalMaxVal - this.min) / range) * 100;\n return { left: `${leftPercent}%`, width: `${rightPercent - leftPercent}%` };\n }\n\n @Method()\n async getValues(): Promise<number[]> {\n return [this.internalMinVal, this.internalMaxVal];\n }\n\n render() {\n return (\n <Host class={{ 'is-disabled': this.disabled }}>\n <div class=\"label-container\">\n <label class=\"label-min\">\n {this.labelMinBefore} {this.internalMinVal}{this.labelMinAfter}\n </label>\n <label class=\"label-max\">\n {this.labelMaxBefore} {this.internalMaxVal}{this.labelMaxAfter}\n </label>\n </div>\n <div class=\"slider-container\">\n <div class=\"slider-track\"></div>\n <div class=\"slider-fill\" style={this.getFillStyle()}></div>\n <input\n type=\"range\"\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.internalMinVal}\n onInput={this.handleMinInput}\n onChange={this.handleCommit}\n disabled={this.disabled}\n class=\"range-input\"\n aria-label={this.labelMinBefore}\n />\n <input\n type=\"range\"\n min={this.min}\n max={this.max}\n step={this.step}\n value={this.internalMaxVal}\n onInput={this.handleMaxInput}\n onChange={this.handleCommit}\n disabled={this.disabled}\n class=\"range-input\"\n aria-label={this.labelMaxBefore}\n />\n </div>\n </Host>\n );\n }\n}"]}
|
|
@@ -43,7 +43,6 @@ Default.args = {
|
|
|
43
43
|
min: 0,
|
|
44
44
|
max: 100,
|
|
45
45
|
step: 1,
|
|
46
|
-
value: [25, 75],
|
|
47
46
|
disabled: false,
|
|
48
47
|
};
|
|
49
48
|
// --- NUOVA STORIA AGGIUNTA ---
|
|
@@ -57,7 +56,6 @@ PriceRange.args = {
|
|
|
57
56
|
min: 0,
|
|
58
57
|
max: 1500,
|
|
59
58
|
step: 10,
|
|
60
|
-
value: [250, 900],
|
|
61
59
|
disabled: false, // Come richiesto, non è disabilitato
|
|
62
60
|
};
|
|
63
61
|
// -----------------------------
|
|
@@ -71,7 +69,6 @@ Percentage.args = {
|
|
|
71
69
|
min: 0,
|
|
72
70
|
max: 100,
|
|
73
71
|
step: 1,
|
|
74
|
-
value: [20, 80],
|
|
75
72
|
};
|
|
76
73
|
export const OnlyValues = Template.bind({});
|
|
77
74
|
OnlyValues.args = {
|
|
@@ -83,8 +80,20 @@ OnlyValues.args = {
|
|
|
83
80
|
min: 0,
|
|
84
81
|
max: 100,
|
|
85
82
|
step: 1,
|
|
86
|
-
value: [20, 80],
|
|
87
83
|
};
|
|
88
84
|
export const Disabled = Template.bind({});
|
|
89
85
|
Disabled.args = Object.assign(Object.assign({}, PriceRange.args), { name: 'disabled-price-filter', disabled: true });
|
|
86
|
+
export const WithValues = Template.bind({});
|
|
87
|
+
WithValues.args = {
|
|
88
|
+
name: 'satisfaction-range',
|
|
89
|
+
labelMinBefore: '',
|
|
90
|
+
labelMinAfter: '',
|
|
91
|
+
labelMaxBefore: '',
|
|
92
|
+
labelMaxAfter: '',
|
|
93
|
+
min: 0,
|
|
94
|
+
max: 100,
|
|
95
|
+
step: 1,
|
|
96
|
+
minVal: 50,
|
|
97
|
+
maxVal: 75,
|
|
98
|
+
};
|
|
90
99
|
//# sourceMappingURL=jump-filter-range.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jump-filter-range.stories.js","sourceRoot":"","sources":["../../../src/components/jump-filter-range/jump-filter-range.stories.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE3E,eAAe;IACb,KAAK,EAAE,oCAAoC;IAC3C,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;QACzB,cAAc,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,gCAAgC,EAAE;QAClF,aAAa,EAAE,EAAE,OAAO,EAA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,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,mCAER,UAAU,CAAC,IAAI,KAClB,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,EAAE,IAAI,GACf,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC5C,UAAU,CAAC,IAAI,GAAG;IAChB,IAAI,EAAE,oBAAoB;IAC1B,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,EAAE;CACX,CAAC","sourcesContent":["import { generateAttributesFromArgs, formatHtml } from '../../utils/utils';\n\nexport default {\n title: 'Components/Filters/JumpFilterRange',\n tags: ['autodocs'],\n argTypes: {\n name: { control: 'text' },\n labelMinBefore: { control: 'text', description: \"Testo prima del valore minimo.\" },\n labelMinAfter: { control: 'text', description: \"Testo dopo il valore minimo (es. €).\" },\n labelMaxBefore: { control: 'text', description: \"Testo prima del valore massimo.\" },\n labelMaxAfter: { control: 'text', description: \"Testo dopo il valore massimo (es. €).\" },\n min: { control: 'number' },\n max: { control: 'number' },\n step: { control: 'number' },\n value: { control: 'object' },\n disabled: { control: 'boolean' },\n },\n};\n\nconst Template = (args) => {\n const { value, ...rest } = args;\n const attributes = generateAttributesFromArgs(rest);\n const valueAttribute = value ? `value='${JSON.stringify(value)}'` : '';\n return formatHtml(`<jump-filter-range ${attributes} ${valueAttribute}></jump-filter-range>`);\n};\n\nexport const Default = Template.bind({});\nDefault.args = {\n name: 'default-range',\n labelMinBefore: 'Min:',\n labelMinAfter: '',\n labelMaxBefore: 'Max:',\n labelMaxAfter: '',\n min: 0,\n max: 100,\n step: 1,\n disabled: false,\n};\n\n// --- NUOVA STORIA AGGIUNTA ---\nexport const PriceRange = Template.bind({});\nPriceRange.args = {\n name: 'price-filter',\n labelMinBefore: 'Prezzo da',\n labelMinAfter: '€',\n labelMaxBefore: 'a',\n labelMaxAfter: '€',\n min: 0,\n max: 1500,\n step: 10,\n disabled: false, // Come richiesto, non è disabilitato\n};\n// -----------------------------\n\nexport const Percentage = Template.bind({});\nPercentage.args = {\n name: 'satisfaction-range',\n labelMinBefore: 'Soddisfazione da',\n labelMinAfter: '%',\n labelMaxBefore: 'a',\n labelMaxAfter: '%',\n min: 0,\n max: 100,\n step: 1,\n};\n\nexport const OnlyValues = Template.bind({});\nOnlyValues.args = {\n name: 'satisfaction-range',\n labelMinBefore: '',\n labelMinAfter: '',\n labelMaxBefore: '',\n labelMaxAfter: '',\n min: 0,\n max: 100,\n step: 1,\n};\n\nexport const Disabled = Template.bind({});\nDisabled.args = {\n // Usiamo i valori di PriceRange ma in stato disabilitato\n ...PriceRange.args,\n name: 'disabled-price-filter',\n disabled: true,\n};\n\nexport const WithValues = Template.bind({});\nWithValues.args = {\n name: 'satisfaction-range',\n labelMinBefore: '',\n labelMinAfter: '',\n labelMaxBefore: '',\n labelMaxAfter: '',\n min: 0,\n max: 100,\n step: 1,\n minVal: 50,\n maxVal: 75,\n};"]}
|
|
@@ -17,17 +17,8 @@ export class JumpFilterSelect {
|
|
|
17
17
|
this.required = false;
|
|
18
18
|
this.loading = false;
|
|
19
19
|
this.open = false;
|
|
20
|
-
this.hasSlottedOptions = false;
|
|
21
20
|
this.values = [];
|
|
22
21
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Controlla se ci sono opzioni definite come slot
|
|
25
|
-
*/
|
|
26
|
-
componentWillRender() {
|
|
27
|
-
// Verifica se ci sono elementi sl-option definiti come figli
|
|
28
|
-
const slotNodes = this.hostElement.childNodes;
|
|
29
|
-
this.hasSlottedOptions = Array.from(slotNodes).some(node => node.nodeName && node.nodeName.toLowerCase() === 'sl-option');
|
|
30
|
-
}
|
|
31
22
|
/**
|
|
32
23
|
* Converte le opzioni da string o array a array di oggetti
|
|
33
24
|
*/
|
|
@@ -50,36 +41,61 @@ export class JumpFilterSelect {
|
|
|
50
41
|
this.values = this.value ? [this.value] : [];
|
|
51
42
|
}
|
|
52
43
|
componentDidLoad() {
|
|
53
|
-
this.listenSLChange();
|
|
54
44
|
// Inizializza l'array dei valori
|
|
55
45
|
this.updateValues();
|
|
46
|
+
// Aspetta che il render sia completato e che Shoelace abbia processato gli slot
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
this.listenSLChange();
|
|
49
|
+
}, 100); // Aumentiamo il timeout per dare più tempo a Shoelace
|
|
50
|
+
}
|
|
51
|
+
componentDidRender() {
|
|
52
|
+
// Assicuriamoci che il listener sia attivo anche dopo ogni render
|
|
53
|
+
if (this.el && !this.el._jumpListenerAttached) {
|
|
54
|
+
this.listenSLChange();
|
|
55
|
+
}
|
|
56
56
|
}
|
|
57
57
|
/**
|
|
58
58
|
* Ascolta gli eventi di cambio selezione dal select Shoelace
|
|
59
59
|
*/
|
|
60
60
|
listenSLChange() {
|
|
61
|
-
if (this.
|
|
62
|
-
|
|
61
|
+
if (this.el && !this.el._jumpListenerAttached) {
|
|
62
|
+
// Marchiamo l'elemento per evitare listener multipli
|
|
63
|
+
this.el._jumpListenerAttached = true;
|
|
64
|
+
this.el.addEventListener('sl-change', (event) => {
|
|
63
65
|
if (this.disabled) {
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
68
|
+
console.log('sl-change event received:', event.target.value);
|
|
69
|
+
// AGGIORNA PRIMA I VALORI INTERNI
|
|
66
70
|
this.value = event.target.value;
|
|
67
71
|
this.updateValues();
|
|
68
72
|
const optionsArray = this.getOptionsArray();
|
|
69
|
-
|
|
73
|
+
let selectedOption = optionsArray.find(option => option.value === this.value);
|
|
74
|
+
// Se non abbiamo trovato l'opzione nell'array (caso slot), proviamo a trovarla negli elementi sl-option
|
|
75
|
+
if (!selectedOption && this.value) {
|
|
76
|
+
const slotOptions = this.hostElement.querySelectorAll('sl-option');
|
|
77
|
+
const slotOption = Array.from(slotOptions).find((opt) => opt.value === this.value);
|
|
78
|
+
if (slotOption) {
|
|
79
|
+
selectedOption = {
|
|
80
|
+
value: this.value,
|
|
81
|
+
label: slotOption.textContent || this.value
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
70
85
|
// Evento specifico per il componente select
|
|
71
86
|
const selectEventData = {
|
|
72
87
|
value: this.value,
|
|
73
88
|
selectedOption
|
|
74
89
|
};
|
|
75
90
|
this.selectionChange.emit(selectEventData);
|
|
76
|
-
// Evento standard per il sistema di filtri
|
|
91
|
+
// CORREZIONE: Evento standard per il sistema di filtri con valori aggiornati
|
|
77
92
|
const filterEventData = {
|
|
78
93
|
name: this.name,
|
|
79
|
-
values: this.values,
|
|
80
|
-
value: this.value,
|
|
81
|
-
selectedOption
|
|
94
|
+
values: this.values, // Ora questo sarà popolato correttamente
|
|
95
|
+
value: this.value, // E anche questo
|
|
96
|
+
selectedOption // E anche questo
|
|
82
97
|
};
|
|
98
|
+
console.log('jump-filter-select: Emitting jump-filterchange with data:', filterEventData);
|
|
83
99
|
this.selectionFilterChange.emit(filterEventData);
|
|
84
100
|
});
|
|
85
101
|
}
|
|
@@ -97,7 +113,19 @@ export class JumpFilterSelect {
|
|
|
97
113
|
*/
|
|
98
114
|
async getSelectedOption() {
|
|
99
115
|
const optionsArray = this.getOptionsArray();
|
|
100
|
-
|
|
116
|
+
let selectedOption = optionsArray.find(option => option.value === this.value);
|
|
117
|
+
// Se non abbiamo trovato l'opzione nell'array (caso slot), proviamo a trovarla negli elementi sl-option
|
|
118
|
+
if (!selectedOption && this.value) {
|
|
119
|
+
const slotOptions = this.hostElement.querySelectorAll('sl-option');
|
|
120
|
+
const slotOption = Array.from(slotOptions).find((opt) => opt.value === this.value);
|
|
121
|
+
if (slotOption) {
|
|
122
|
+
selectedOption = {
|
|
123
|
+
value: this.value,
|
|
124
|
+
label: slotOption.textContent || this.value
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return selectedOption;
|
|
101
129
|
}
|
|
102
130
|
/**
|
|
103
131
|
* Metodo pubblico per ottenere i valori selezionati come array
|
|
@@ -139,7 +167,18 @@ export class JumpFilterSelect {
|
|
|
139
167
|
// Emetti l'evento di cambio se richiesto
|
|
140
168
|
if (emitEvent) {
|
|
141
169
|
const optionsArray = this.getOptionsArray();
|
|
142
|
-
|
|
170
|
+
let selectedOption = optionsArray.find(option => option.value === this.value);
|
|
171
|
+
// Se non abbiamo trovato l'opzione nell'array (caso slot), proviamo a trovarla negli elementi sl-option
|
|
172
|
+
if (!selectedOption && this.value) {
|
|
173
|
+
const slotOptions = this.hostElement.querySelectorAll('sl-option');
|
|
174
|
+
const slotOption = Array.from(slotOptions).find((opt) => opt.value === this.value);
|
|
175
|
+
if (slotOption) {
|
|
176
|
+
selectedOption = {
|
|
177
|
+
value: this.value,
|
|
178
|
+
label: slotOption.textContent || this.value
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
}
|
|
143
182
|
// Evento specifico per il componente select
|
|
144
183
|
const selectEventData = {
|
|
145
184
|
value: this.value,
|
|
@@ -169,7 +208,8 @@ export class JumpFilterSelect {
|
|
|
169
208
|
}
|
|
170
209
|
render() {
|
|
171
210
|
const optionsArray = this.getOptionsArray();
|
|
172
|
-
|
|
211
|
+
const hasOptionsFromProp = optionsArray && optionsArray.length > 0;
|
|
212
|
+
return (h(Host, { key: '97473942caed469dfb681d77e1335542d5d67808', ref: (host) => (this.host = host) }, this.label && (h("div", { key: 'eb5d0f4a428642694bb47f1bedf1da14d375e592', class: "select-label" }, this.label)), h("sl-select", { key: 'c3d4cb422603fdf837e5433dddd061c47832723a', value: this.value, placeholder: this.placeholder, disabled: this.disabled, multiple: this.multiple, required: this.required, loading: this.loading, ref: (el) => (this.el = el) }, hasOptionsFromProp ? (optionsArray.map(option => (h("sl-option", { value: option.value }, option.label)))) : (h("slot", null)))));
|
|
173
213
|
}
|
|
174
214
|
static get is() { return "jump-filter-select"; }
|
|
175
215
|
static get encapsulation() { return "shadow"; }
|
|
@@ -350,7 +390,6 @@ export class JumpFilterSelect {
|
|
|
350
390
|
static get states() {
|
|
351
391
|
return {
|
|
352
392
|
"open": {},
|
|
353
|
-
"hasSlottedOptions": {},
|
|
354
393
|
"values": {}
|
|
355
394
|
};
|
|
356
395
|
}
|