@jumpgroup/jump-design-system 0.3.59 → 0.3.63
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/chunk.H33C3MRM-31110702.js +365 -0
- package/dist/cjs/chunk.H33C3MRM-31110702.js.map +1 -0
- package/dist/cjs/chunk.WLV3FVBR-bfad29d7.js +238 -0
- package/dist/cjs/chunk.WLV3FVBR-bfad29d7.js.map +1 -0
- package/dist/cjs/{class-map-b27ebf69.js → class-map-010ed95d.js} +3 -3
- package/dist/cjs/{class-map-b27ebf69.js.map → class-map-010ed95d.js.map} +1 -1
- package/dist/cjs/{chunk.H33C3MRM-2c09acb5.js → directive-helpers-b6926fa1.js} +2 -360
- package/dist/cjs/directive-helpers-b6926fa1.js.map +1 -0
- package/dist/cjs/if-defined-da1385f1.js +432 -0
- package/dist/cjs/if-defined-da1385f1.js.map +1 -0
- package/dist/cjs/{index-e91b2b41.js → index-864e40de.js} +5 -2
- package/dist/cjs/index-864e40de.js.map +1 -0
- package/dist/cjs/jump-accordion-group.cjs.entry.js +1 -1
- package/dist/cjs/jump-accordion.cjs.entry.js +32 -255
- package/dist/cjs/jump-accordion.cjs.entry.js.map +1 -1
- package/dist/cjs/jump-badge.cjs.entry.js +1 -1
- package/dist/cjs/jump-button_2.cjs.entry.js +3 -2
- package/dist/cjs/jump-button_2.cjs.entry.js.map +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 +46 -470
- package/dist/cjs/jump-filter-checkbox.cjs.entry.js.map +1 -1
- package/dist/cjs/jump-filter-select.cjs.entry.js +4229 -0
- package/dist/cjs/jump-filter-select.cjs.entry.js.map +1 -0
- package/dist/cjs/jump-filter-switch.cjs.entry.js +440 -0
- package/dist/cjs/jump-filter-switch.cjs.entry.js.map +1 -0
- 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-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/live-a9a3fb36.js +14 -0
- package/dist/cjs/live-a9a3fb36.js.map +1 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/jump-filter-checkbox/jump-filter-checkbox.stories.js +0 -5
- package/dist/collection/components/jump-filter-checkbox/jump-filter-checkbox.stories.js.map +1 -1
- package/dist/collection/components/jump-filter-select/jump-filter-select.css +578 -0
- package/dist/collection/components/jump-filter-select/jump-filter-select.js +373 -0
- package/dist/collection/components/jump-filter-select/jump-filter-select.js.map +1 -0
- package/dist/collection/components/jump-filter-select/jump-filter-select.stories.js +211 -0
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.css +536 -0
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.js +175 -0
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.js.map +1 -0
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.stories.js +68 -0
- package/dist/collection/components/jump-filter-switch/jump-filter-switch.stories.js.map +1 -0
- 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-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/components/chunk.H33C3MRM.js +3 -170
- package/dist/components/chunk.H33C3MRM.js.map +1 -1
- package/dist/components/chunk.WLV3FVBR.js +230 -0
- package/dist/components/chunk.WLV3FVBR.js.map +1 -0
- package/dist/components/class-map.js +1 -1
- package/dist/{esm/chunk.H33C3MRM-632f8755.js → components/directive-helpers.js} +2 -359
- package/dist/components/directive-helpers.js.map +1 -0
- package/dist/components/if-defined.js +426 -0
- package/dist/components/if-defined.js.map +1 -0
- package/dist/components/jump-accordion.js +3 -226
- package/dist/components/jump-accordion.js.map +1 -1
- package/dist/components/jump-filter-checkbox.js +8 -432
- package/dist/components/jump-filter-checkbox.js.map +1 -1
- package/dist/components/jump-filter-select.d.ts +11 -0
- package/dist/components/jump-filter-select.js +4257 -0
- package/dist/components/jump-filter-select.js.map +1 -0
- package/dist/components/jump-filter-switch.d.ts +11 -0
- package/dist/components/jump-filter-switch.js +460 -0
- package/dist/components/jump-filter-switch.js.map +1 -0
- package/dist/components/jump-filtergroup.js +3 -3
- package/dist/components/jump-icon2.js +1 -0
- package/dist/components/jump-icon2.js.map +1 -1
- 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-tab-item.js +2 -2
- package/dist/components/jump-tab-panel.js +1 -1
- package/dist/components/jump-tab.js +1 -1
- package/dist/components/live.js +12 -0
- package/dist/components/live.js.map +1 -0
- package/dist/esm/chunk.H33C3MRM-7dcbd943.js +362 -0
- package/dist/esm/chunk.H33C3MRM-7dcbd943.js.map +1 -0
- package/dist/esm/chunk.WLV3FVBR-ded9a646.js +230 -0
- package/dist/esm/chunk.WLV3FVBR-ded9a646.js.map +1 -0
- package/dist/esm/{class-map-3150cdfe.js → class-map-a2676e27.js} +2 -2
- package/dist/esm/{class-map-3150cdfe.js.map → class-map-a2676e27.js.map} +1 -1
- package/dist/esm/directive-helpers-d80c2187.js +172 -0
- package/dist/esm/directive-helpers-d80c2187.js.map +1 -0
- package/dist/esm/if-defined-85ab7b97.js +426 -0
- package/dist/esm/if-defined-85ab7b97.js.map +1 -0
- package/dist/esm/{index-9a1da0f0.js → index-7eb565cd.js} +5 -2
- package/dist/esm/index-7eb565cd.js.map +1 -0
- package/dist/esm/jump-accordion-group.entry.js +1 -1
- package/dist/esm/jump-accordion.entry.js +5 -228
- package/dist/esm/jump-accordion.entry.js.map +1 -1
- package/dist/esm/jump-badge.entry.js +1 -1
- package/dist/esm/jump-button_2.entry.js +3 -2
- package/dist/esm/jump-button_2.entry.js.map +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 +9 -433
- package/dist/esm/jump-filter-checkbox.entry.js.map +1 -1
- package/dist/esm/jump-filter-select.entry.js +4225 -0
- package/dist/esm/jump-filter-select.entry.js.map +1 -0
- package/dist/esm/jump-filter-switch.entry.js +436 -0
- package/dist/esm/jump-filter-switch.entry.js.map +1 -0
- 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-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/live-253d6806.js +12 -0
- package/dist/esm/live-253d6806.js.map +1 -0
- 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-0cbcc5b3.entry.js +2 -0
- package/dist/jump-design-system/p-1b31e36f.js +17 -0
- package/dist/jump-design-system/p-1b31e36f.js.map +1 -0
- package/dist/jump-design-system/{p-2e2bd8a9.entry.js → p-201c09dd.entry.js} +2 -2
- package/dist/jump-design-system/p-35633b03.entry.js +848 -0
- package/dist/jump-design-system/p-35633b03.entry.js.map +1 -0
- package/dist/jump-design-system/p-39b82674.entry.js +2 -0
- package/dist/jump-design-system/{p-feb825e0.entry.js → p-3b4127b0.entry.js} +2 -2
- package/dist/jump-design-system/{p-6b1ab8c3.entry.js → p-3e31b638.entry.js} +2 -2
- package/dist/jump-design-system/p-53bf2958.entry.js +213 -0
- package/dist/jump-design-system/p-53bf2958.entry.js.map +1 -0
- package/dist/jump-design-system/p-67339850.js +63 -0
- package/dist/jump-design-system/p-67339850.js.map +1 -0
- package/dist/jump-design-system/{p-f7c323d2.entry.js → p-7dd5052b.entry.js} +2 -2
- package/dist/jump-design-system/p-8d1d2af9.entry.js +117 -0
- package/dist/jump-design-system/p-8d1d2af9.entry.js.map +1 -0
- package/dist/jump-design-system/p-8e0419b1.entry.js +2 -0
- package/dist/jump-design-system/{p-6dc529fc.entry.js → p-90c51b48.entry.js} +2 -2
- package/dist/jump-design-system/p-926c7bf0.entry.js +2 -0
- package/dist/jump-design-system/p-94229ed5.js +7 -0
- package/dist/jump-design-system/p-94229ed5.js.map +1 -0
- package/dist/jump-design-system/{p-02e863db.entry.js → p-94790673.entry.js} +2 -2
- package/dist/jump-design-system/{p-466e0ade.entry.js → p-947d7f9a.entry.js} +2 -2
- package/dist/jump-design-system/p-95a1bbc5.js +51 -0
- package/dist/jump-design-system/p-95a1bbc5.js.map +1 -0
- package/dist/jump-design-system/p-98ef4924.entry.js +2 -0
- package/dist/jump-design-system/{p-3f6d50d5.entry.js.map → p-98ef4924.entry.js.map} +1 -1
- package/dist/jump-design-system/{p-198cfe62.js → p-9d21c18a.js} +2 -2
- package/dist/jump-design-system/p-a05d9480.entry.js +178 -0
- package/dist/jump-design-system/p-a05d9480.entry.js.map +1 -0
- package/dist/jump-design-system/{p-a9b78af2.entry.js → p-ad550de6.entry.js} +2 -2
- package/dist/jump-design-system/{p-1aa5fb8a.entry.js → p-d3b62e9b.entry.js} +2 -2
- package/dist/jump-design-system/{p-bdafe87d.entry.js → p-d8bfd21c.entry.js} +2 -2
- package/dist/jump-design-system/{p-a1c25113.entry.js → p-d94fabc1.entry.js} +2 -2
- package/dist/jump-design-system/p-e516e812.js +3 -0
- package/dist/jump-design-system/p-e516e812.js.map +1 -0
- package/dist/jump-design-system/p-f2d287d6.js +2 -0
- package/dist/jump-design-system/p-f2d287d6.js.map +1 -0
- package/dist/jump-design-system/{p-2e7c10a5.entry.js → p-fa0dcb05.entry.js} +2 -2
- package/dist/jump-design-system/{p-07633158.entry.js → p-ff8d70ab.entry.js} +2 -2
- package/dist/jump-design-system-elements.json +66 -0
- package/dist/types/components/jump-filter-checkbox/jump-filter-checkbox.stories.d.ts +0 -5
- package/dist/types/components/jump-filter-select/jump-filter-select.d.ts +76 -0
- package/dist/types/components/jump-filter-switch/jump-filter-switch.d.ts +35 -0
- package/dist/types/components/jump-filter-switch/jump-filter-switch.stories.d.ts +24 -0
- package/dist/types/components.d.ts +206 -0
- package/package.json +1 -1
- package/dist/cjs/chunk.H33C3MRM-2c09acb5.js.map +0 -1
- package/dist/cjs/index-e91b2b41.js.map +0 -1
- package/dist/esm/chunk.H33C3MRM-632f8755.js.map +0 -1
- package/dist/esm/index-9a1da0f0.js.map +0 -1
- package/dist/jump-design-system/p-21aa0095.js +0 -3
- package/dist/jump-design-system/p-21aa0095.js.map +0 -1
- package/dist/jump-design-system/p-3f6d50d5.entry.js +0 -2
- package/dist/jump-design-system/p-6e7c80a3.entry.js +0 -244
- package/dist/jump-design-system/p-6e7c80a3.entry.js.map +0 -1
- package/dist/jump-design-system/p-842fff70.entry.js +0 -117
- package/dist/jump-design-system/p-842fff70.entry.js.map +0 -1
- package/dist/jump-design-system/p-8f581228.entry.js +0 -2
- package/dist/jump-design-system/p-a826c477.entry.js +0 -2
- package/dist/jump-design-system/p-b03c5b24.entry.js +0 -2
- package/dist/jump-design-system/p-c77d216c.entry.js +0 -2
- package/dist/jump-design-system/p-d33f4f1d.js +0 -66
- package/dist/jump-design-system/p-d33f4f1d.js.map +0 -1
- /package/dist/jump-design-system/{p-b03c5b24.entry.js.map → p-0cbcc5b3.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-2e2bd8a9.entry.js.map → p-201c09dd.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-8f581228.entry.js.map → p-39b82674.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-feb825e0.entry.js.map → p-3b4127b0.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-6b1ab8c3.entry.js.map → p-3e31b638.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-f7c323d2.entry.js.map → p-7dd5052b.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-c77d216c.entry.js.map → p-8e0419b1.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-6dc529fc.entry.js.map → p-90c51b48.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-a826c477.entry.js.map → p-926c7bf0.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-02e863db.entry.js.map → p-94790673.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-466e0ade.entry.js.map → p-947d7f9a.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-198cfe62.js.map → p-9d21c18a.js.map} +0 -0
- /package/dist/jump-design-system/{p-a9b78af2.entry.js.map → p-ad550de6.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-1aa5fb8a.entry.js.map → p-d3b62e9b.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-bdafe87d.entry.js.map → p-d8bfd21c.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-a1c25113.entry.js.map → p-d94fabc1.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-2e7c10a5.entry.js.map → p-fa0dcb05.entry.js.map} +0 -0
- /package/dist/jump-design-system/{p-07633158.entry.js.map → p-ff8d70ab.entry.js.map} +0 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import { Host, h } from "@stencil/core";
|
|
2
|
+
import "@shoelace-style/shoelace/dist/components/select/select.js";
|
|
3
|
+
import "@shoelace-style/shoelace/dist/components/option/option.js";
|
|
4
|
+
/**
|
|
5
|
+
* Componente select per filtri con supporto per opzioni e stato
|
|
6
|
+
* @slot - Contenitore per elementi sl-option quando le opzioni sono definite come figli
|
|
7
|
+
*/
|
|
8
|
+
export class JumpFilterSelect {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.value = undefined;
|
|
11
|
+
this.placeholder = 'Seleziona un\'opzione';
|
|
12
|
+
this.label = undefined;
|
|
13
|
+
this.options = [];
|
|
14
|
+
this.disabled = false;
|
|
15
|
+
this.multiple = false;
|
|
16
|
+
this.required = false;
|
|
17
|
+
this.loading = false;
|
|
18
|
+
this.open = false;
|
|
19
|
+
this.hasSlottedOptions = false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Controlla se ci sono opzioni definite come slot
|
|
23
|
+
*/
|
|
24
|
+
componentWillRender() {
|
|
25
|
+
// Verifica se ci sono elementi sl-option definiti come figli
|
|
26
|
+
const slotNodes = this.hostElement.childNodes;
|
|
27
|
+
this.hasSlottedOptions = Array.from(slotNodes).some(node => node.nodeName && node.nodeName.toLowerCase() === 'sl-option');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converte le opzioni da string o array a array di oggetti
|
|
31
|
+
*/
|
|
32
|
+
getOptionsArray() {
|
|
33
|
+
if (typeof this.options === 'string') {
|
|
34
|
+
try {
|
|
35
|
+
return JSON.parse(this.options);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
console.error('Errore nel parsing delle opzioni:', e);
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return this.options;
|
|
43
|
+
}
|
|
44
|
+
componentDidLoad() {
|
|
45
|
+
this.listenSLChange();
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Ascolta gli eventi di cambio selezione dal select Shoelace
|
|
49
|
+
*/
|
|
50
|
+
listenSLChange() {
|
|
51
|
+
if (this.host) {
|
|
52
|
+
this.host.addEventListener('sl-change', (event) => {
|
|
53
|
+
if (this.disabled) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.value = event.target.value;
|
|
57
|
+
const optionsArray = this.getOptionsArray();
|
|
58
|
+
const selectedOption = optionsArray.find(option => option.value === this.value);
|
|
59
|
+
const eventData = {
|
|
60
|
+
value: this.value,
|
|
61
|
+
selectedOption
|
|
62
|
+
};
|
|
63
|
+
this.selectionChange.emit(eventData);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Metodo pubblico per ottenere il valore selezionato
|
|
69
|
+
* @returns Il valore attualmente selezionato
|
|
70
|
+
*/
|
|
71
|
+
async getSelectedValue() {
|
|
72
|
+
return this.value;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Metodo pubblico per ottenere l'opzione selezionata
|
|
76
|
+
* @returns L'opzione attualmente selezionata come oggetto {value, label}
|
|
77
|
+
*/
|
|
78
|
+
async getSelectedOption() {
|
|
79
|
+
const optionsArray = this.getOptionsArray();
|
|
80
|
+
return optionsArray.find(option => option.value === this.value);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Metodo pubblico per impostare programmaticamente il valore selezionato
|
|
84
|
+
* @param newValue - Il nuovo valore da selezionare
|
|
85
|
+
* @param emitEvent - Se emettere l'evento di cambio (default: true)
|
|
86
|
+
* @returns Il nuovo valore impostato
|
|
87
|
+
*/
|
|
88
|
+
async setValue(newValue, emitEvent = true) {
|
|
89
|
+
this.value = newValue;
|
|
90
|
+
// Aggiorna anche il valore dell'elemento sl-select interno
|
|
91
|
+
if (this.el) {
|
|
92
|
+
this.el.value = newValue;
|
|
93
|
+
}
|
|
94
|
+
// Emetti l'evento di cambio se richiesto
|
|
95
|
+
if (emitEvent) {
|
|
96
|
+
const optionsArray = this.getOptionsArray();
|
|
97
|
+
const selectedOption = optionsArray.find(option => option.value === this.value);
|
|
98
|
+
const eventData = {
|
|
99
|
+
value: this.value,
|
|
100
|
+
selectedOption,
|
|
101
|
+
programmatic: true // Flag per indicare che il cambio è avvenuto programmaticamente
|
|
102
|
+
};
|
|
103
|
+
this.selectionChange.emit(eventData);
|
|
104
|
+
}
|
|
105
|
+
return this.value;
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
const optionsArray = this.getOptionsArray();
|
|
109
|
+
return (h(Host, { key: '3aeb8a1b3c8757bfecd0b5642ddfa87e61f92849', ref: (host) => (this.host = host) }, this.label && (h("div", { key: '504faaf84a96fd84add35cdaaa34e617391d4c82', class: "select-label" }, this.label)), h("sl-select", { key: '9a707596aa5a2c87c0276ecca51588c02d22edb0', value: this.value, placeholder: this.placeholder, disabled: this.disabled, multiple: this.multiple, required: this.required, loading: this.loading, ref: (el) => (this.el = el) }, !this.hasSlottedOptions && optionsArray.map(option => (h("sl-option", { value: option.value }, option.label))), h("slot", { key: 'b4592e359a2aaea92a87ab7240ddb6d2557697c3' }))));
|
|
110
|
+
}
|
|
111
|
+
static get is() { return "jump-filter-select"; }
|
|
112
|
+
static get encapsulation() { return "shadow"; }
|
|
113
|
+
static get originalStyleUrls() {
|
|
114
|
+
return {
|
|
115
|
+
"$": ["jump-filter-select.scss"]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
static get styleUrls() {
|
|
119
|
+
return {
|
|
120
|
+
"$": ["jump-filter-select.css"]
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
static get properties() {
|
|
124
|
+
return {
|
|
125
|
+
"value": {
|
|
126
|
+
"type": "string",
|
|
127
|
+
"mutable": true,
|
|
128
|
+
"complexType": {
|
|
129
|
+
"original": "string",
|
|
130
|
+
"resolved": "string",
|
|
131
|
+
"references": {}
|
|
132
|
+
},
|
|
133
|
+
"required": false,
|
|
134
|
+
"optional": false,
|
|
135
|
+
"docs": {
|
|
136
|
+
"tags": [],
|
|
137
|
+
"text": "Il valore selezionato"
|
|
138
|
+
},
|
|
139
|
+
"attribute": "value",
|
|
140
|
+
"reflect": true
|
|
141
|
+
},
|
|
142
|
+
"placeholder": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"mutable": false,
|
|
145
|
+
"complexType": {
|
|
146
|
+
"original": "string",
|
|
147
|
+
"resolved": "string",
|
|
148
|
+
"references": {}
|
|
149
|
+
},
|
|
150
|
+
"required": false,
|
|
151
|
+
"optional": false,
|
|
152
|
+
"docs": {
|
|
153
|
+
"tags": [],
|
|
154
|
+
"text": "Il placeholder da mostrare quando nessun valore \u00E8 selezionato"
|
|
155
|
+
},
|
|
156
|
+
"attribute": "placeholder",
|
|
157
|
+
"reflect": false,
|
|
158
|
+
"defaultValue": "'Seleziona un\\'opzione'"
|
|
159
|
+
},
|
|
160
|
+
"label": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"mutable": false,
|
|
163
|
+
"complexType": {
|
|
164
|
+
"original": "string",
|
|
165
|
+
"resolved": "string",
|
|
166
|
+
"references": {}
|
|
167
|
+
},
|
|
168
|
+
"required": false,
|
|
169
|
+
"optional": false,
|
|
170
|
+
"docs": {
|
|
171
|
+
"tags": [],
|
|
172
|
+
"text": "L'etichetta del select"
|
|
173
|
+
},
|
|
174
|
+
"attribute": "label",
|
|
175
|
+
"reflect": false
|
|
176
|
+
},
|
|
177
|
+
"options": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"mutable": false,
|
|
180
|
+
"complexType": {
|
|
181
|
+
"original": "string | { value: string; label: string }[]",
|
|
182
|
+
"resolved": "string | { value: string; label: string; }[]",
|
|
183
|
+
"references": {}
|
|
184
|
+
},
|
|
185
|
+
"required": false,
|
|
186
|
+
"optional": false,
|
|
187
|
+
"docs": {
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": "Opzioni del select come array di oggetti {value, label} o come stringa JSON"
|
|
190
|
+
},
|
|
191
|
+
"attribute": "options",
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"defaultValue": "[]"
|
|
194
|
+
},
|
|
195
|
+
"disabled": {
|
|
196
|
+
"type": "boolean",
|
|
197
|
+
"mutable": false,
|
|
198
|
+
"complexType": {
|
|
199
|
+
"original": "boolean",
|
|
200
|
+
"resolved": "boolean",
|
|
201
|
+
"references": {}
|
|
202
|
+
},
|
|
203
|
+
"required": false,
|
|
204
|
+
"optional": false,
|
|
205
|
+
"docs": {
|
|
206
|
+
"tags": [],
|
|
207
|
+
"text": "Stato del select (disabilitato)"
|
|
208
|
+
},
|
|
209
|
+
"attribute": "disabled",
|
|
210
|
+
"reflect": true,
|
|
211
|
+
"defaultValue": "false"
|
|
212
|
+
},
|
|
213
|
+
"multiple": {
|
|
214
|
+
"type": "boolean",
|
|
215
|
+
"mutable": false,
|
|
216
|
+
"complexType": {
|
|
217
|
+
"original": "boolean",
|
|
218
|
+
"resolved": "boolean",
|
|
219
|
+
"references": {}
|
|
220
|
+
},
|
|
221
|
+
"required": false,
|
|
222
|
+
"optional": false,
|
|
223
|
+
"docs": {
|
|
224
|
+
"tags": [],
|
|
225
|
+
"text": "Flag per indicare se \u00E8 possibile selezionare pi\u00F9 opzioni"
|
|
226
|
+
},
|
|
227
|
+
"attribute": "multiple",
|
|
228
|
+
"reflect": false,
|
|
229
|
+
"defaultValue": "false"
|
|
230
|
+
},
|
|
231
|
+
"required": {
|
|
232
|
+
"type": "boolean",
|
|
233
|
+
"mutable": false,
|
|
234
|
+
"complexType": {
|
|
235
|
+
"original": "boolean",
|
|
236
|
+
"resolved": "boolean",
|
|
237
|
+
"references": {}
|
|
238
|
+
},
|
|
239
|
+
"required": false,
|
|
240
|
+
"optional": false,
|
|
241
|
+
"docs": {
|
|
242
|
+
"tags": [],
|
|
243
|
+
"text": "Flag per indicare se la selezione \u00E8 obbligatoria"
|
|
244
|
+
},
|
|
245
|
+
"attribute": "required",
|
|
246
|
+
"reflect": false,
|
|
247
|
+
"defaultValue": "false"
|
|
248
|
+
},
|
|
249
|
+
"loading": {
|
|
250
|
+
"type": "boolean",
|
|
251
|
+
"mutable": false,
|
|
252
|
+
"complexType": {
|
|
253
|
+
"original": "boolean",
|
|
254
|
+
"resolved": "boolean",
|
|
255
|
+
"references": {}
|
|
256
|
+
},
|
|
257
|
+
"required": false,
|
|
258
|
+
"optional": false,
|
|
259
|
+
"docs": {
|
|
260
|
+
"tags": [],
|
|
261
|
+
"text": "Flag per indicare se il select \u00E8 in stato di caricamento"
|
|
262
|
+
},
|
|
263
|
+
"attribute": "loading",
|
|
264
|
+
"reflect": false,
|
|
265
|
+
"defaultValue": "false"
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
static get states() {
|
|
270
|
+
return {
|
|
271
|
+
"open": {},
|
|
272
|
+
"hasSlottedOptions": {}
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
static get events() {
|
|
276
|
+
return [{
|
|
277
|
+
"method": "selectionChange",
|
|
278
|
+
"name": "jump-select-change",
|
|
279
|
+
"bubbles": true,
|
|
280
|
+
"cancelable": true,
|
|
281
|
+
"composed": true,
|
|
282
|
+
"docs": {
|
|
283
|
+
"tags": [],
|
|
284
|
+
"text": "Evento emesso quando cambia la selezione"
|
|
285
|
+
},
|
|
286
|
+
"complexType": {
|
|
287
|
+
"original": "any",
|
|
288
|
+
"resolved": "any",
|
|
289
|
+
"references": {}
|
|
290
|
+
}
|
|
291
|
+
}];
|
|
292
|
+
}
|
|
293
|
+
static get methods() {
|
|
294
|
+
return {
|
|
295
|
+
"getSelectedValue": {
|
|
296
|
+
"complexType": {
|
|
297
|
+
"signature": "() => Promise<string>",
|
|
298
|
+
"parameters": [],
|
|
299
|
+
"references": {
|
|
300
|
+
"Promise": {
|
|
301
|
+
"location": "global",
|
|
302
|
+
"id": "global::Promise"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
"return": "Promise<string>"
|
|
306
|
+
},
|
|
307
|
+
"docs": {
|
|
308
|
+
"text": "Metodo pubblico per ottenere il valore selezionato",
|
|
309
|
+
"tags": [{
|
|
310
|
+
"name": "returns",
|
|
311
|
+
"text": "Il valore attualmente selezionato"
|
|
312
|
+
}]
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"getSelectedOption": {
|
|
316
|
+
"complexType": {
|
|
317
|
+
"signature": "() => Promise<{ value: string; label: string; }>",
|
|
318
|
+
"parameters": [],
|
|
319
|
+
"references": {
|
|
320
|
+
"Promise": {
|
|
321
|
+
"location": "global",
|
|
322
|
+
"id": "global::Promise"
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"return": "Promise<{ value: string; label: string; }>"
|
|
326
|
+
},
|
|
327
|
+
"docs": {
|
|
328
|
+
"text": "Metodo pubblico per ottenere l'opzione selezionata",
|
|
329
|
+
"tags": [{
|
|
330
|
+
"name": "returns",
|
|
331
|
+
"text": "L'opzione attualmente selezionata come oggetto {value, label}"
|
|
332
|
+
}]
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
"setValue": {
|
|
336
|
+
"complexType": {
|
|
337
|
+
"signature": "(newValue: string, emitEvent?: boolean) => Promise<string>",
|
|
338
|
+
"parameters": [{
|
|
339
|
+
"name": "newValue",
|
|
340
|
+
"type": "string",
|
|
341
|
+
"docs": "- Il nuovo valore da selezionare"
|
|
342
|
+
}, {
|
|
343
|
+
"name": "emitEvent",
|
|
344
|
+
"type": "boolean",
|
|
345
|
+
"docs": "- Se emettere l'evento di cambio (default: true)"
|
|
346
|
+
}],
|
|
347
|
+
"references": {
|
|
348
|
+
"Promise": {
|
|
349
|
+
"location": "global",
|
|
350
|
+
"id": "global::Promise"
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"return": "Promise<string>"
|
|
354
|
+
},
|
|
355
|
+
"docs": {
|
|
356
|
+
"text": "Metodo pubblico per impostare programmaticamente il valore selezionato",
|
|
357
|
+
"tags": [{
|
|
358
|
+
"name": "param",
|
|
359
|
+
"text": "newValue - Il nuovo valore da selezionare"
|
|
360
|
+
}, {
|
|
361
|
+
"name": "param",
|
|
362
|
+
"text": "emitEvent - Se emettere l'evento di cambio (default: true)"
|
|
363
|
+
}, {
|
|
364
|
+
"name": "returns",
|
|
365
|
+
"text": "Il nuovo valore impostato"
|
|
366
|
+
}]
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
static get elementRef() { return "hostElement"; }
|
|
372
|
+
}
|
|
373
|
+
//# sourceMappingURL=jump-filter-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jump-filter-select.js","sourceRoot":"","sources":["../../../src/components/jump-filter-select/jump-filter-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAgB,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,2DAA2D,CAAC;AACnE,OAAO,2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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Host, Prop, h, Event, EventEmitter, Method, State, Element } from '@stencil/core';\nimport '@shoelace-style/shoelace/dist/components/select/select.js';\nimport '@shoelace-style/shoelace/dist/components/option/option.js';\n\n/**\n * Componente select per filtri con supporto per opzioni e stato\n * @slot - Contenitore per elementi sl-option quando le opzioni sono definite come figli\n */\n@Component({\n tag: 'jump-filter-select',\n styleUrl: 'jump-filter-select.scss',\n shadow: true,\n})\nexport class JumpFilterSelect {\n /** Riferimento all'elemento host */\n @Element() hostElement: HTMLElement;\n\n /** Il valore selezionato */\n @Prop({ reflect: true, mutable: true }) value: string;\n\n /** Il placeholder da mostrare quando nessun valore è selezionato */\n @Prop() placeholder: string = 'Seleziona un\\'opzione';\n\n /** L'etichetta del select */\n @Prop() label: string;\n\n /** Opzioni del select come array di oggetti {value, label} o come stringa JSON */\n @Prop() options: string | { value: string; label: string }[] = [];\n\n /** Stato del select (disabilitato) */\n @Prop({ reflect: true }) disabled: boolean = false;\n\n /** Flag per indicare se è possibile selezionare più opzioni */\n @Prop() multiple: boolean = false;\n\n /** Flag per indicare se la selezione è obbligatoria */\n @Prop() required: boolean = false;\n\n /** Flag per indicare se il select è in stato di caricamento */\n @Prop() loading: boolean = false;\n\n /** Stato interno per gestire l'apertura del dropdown */\n @State() open: boolean = false;\n\n /** Flag per determinare se sono presenti opzioni come slot */\n @State() hasSlottedOptions: boolean = false;\n\n /** Riferimento all'elemento host */\n host: HTMLElement;\n\n /** Riferimento all'elemento sl-select interno */\n el: any;\n\n /**\n * Controlla se ci sono opzioni definite come slot\n */\n componentWillRender() {\n // Verifica se ci sono elementi sl-option definiti come figli\n const slotNodes = this.hostElement.childNodes;\n this.hasSlottedOptions = Array.from(slotNodes).some(node => \n node.nodeName && node.nodeName.toLowerCase() === 'sl-option'\n );\n }\n\n /**\n * Converte le opzioni da string o array a array di oggetti\n */\n private getOptionsArray(): { value: string; label: string }[] {\n if (typeof this.options === 'string') {\n try {\n return JSON.parse(this.options);\n } catch (e) {\n console.error('Errore nel parsing delle opzioni:', e);\n return [];\n }\n }\n return this.options;\n }\n\n componentDidLoad() {\n this.listenSLChange();\n }\n\n /**\n * Ascolta gli eventi di cambio selezione dal select Shoelace\n */\n listenSLChange() {\n if (this.host) {\n this.host.addEventListener('sl-change', (event: any) => {\n if (this.disabled) {\n return;\n }\n\n this.value = event.target.value;\n\n const optionsArray = this.getOptionsArray();\n const selectedOption = optionsArray.find(option => option.value === this.value);\n\n const eventData = {\n value: this.value,\n selectedOption\n };\n\n this.selectionChange.emit(eventData);\n });\n }\n }\n\n /**\n * Evento emesso quando cambia la selezione\n */\n @Event({ eventName: 'jump-select-change' }) selectionChange: EventEmitter;\n\n /**\n * Metodo pubblico per ottenere il valore selezionato\n * @returns Il valore attualmente selezionato\n */\n @Method()\n async getSelectedValue() {\n return this.value;\n }\n\n /**\n * Metodo pubblico per ottenere l'opzione selezionata\n * @returns L'opzione attualmente selezionata come oggetto {value, label}\n */\n @Method()\n async getSelectedOption() {\n const optionsArray = this.getOptionsArray();\n return optionsArray.find(option => option.value === this.value);\n }\n\n /**\n * Metodo pubblico per impostare programmaticamente il valore selezionato\n * @param newValue - Il nuovo valore da selezionare\n * @param emitEvent - Se emettere l'evento di cambio (default: true)\n * @returns Il nuovo valore impostato\n */\n @Method()\n async setValue(newValue: string, emitEvent: boolean = true) {\n this.value = newValue;\n \n // Aggiorna anche il valore dell'elemento sl-select interno\n if (this.el) {\n this.el.value = newValue;\n }\n\n // Emetti l'evento di cambio se richiesto\n if (emitEvent) {\n const optionsArray = this.getOptionsArray();\n const selectedOption = optionsArray.find(option => option.value === this.value);\n \n const eventData = {\n value: this.value,\n selectedOption,\n programmatic: true // Flag per indicare che il cambio è avvenuto programmaticamente\n };\n\n this.selectionChange.emit(eventData);\n }\n\n return this.value;\n }\n\n render() {\n const optionsArray = this.getOptionsArray();\n\n return (\n <Host ref={(host: HTMLElement) => (this.host = host)}>\n {this.label && (\n <div class=\"select-label\">{this.label}</div>\n )}\n <sl-select\n value={this.value}\n placeholder={this.placeholder}\n disabled={this.disabled}\n multiple={this.multiple}\n required={this.required}\n loading={this.loading}\n ref={(el: any) => (this.el = el)}\n >\n {/* Renderizza le opzioni dalla prop options solo se non ci sono sl-option nello slot */}\n {!this.hasSlottedOptions && optionsArray.map(option => (\n <sl-option value={option.value}>{option.label}</sl-option>\n ))}\n \n {/* Slot per le opzioni definite come figli */}\n <slot></slot>\n </sl-select>\n </Host>\n );\n }\n} "]}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { generateAttributesFromArgs, formatHtml } from '../../utils/utils';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Components/Filters/JumpFilterSelect',
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
argTypes: {
|
|
7
|
+
value: { control: 'text' },
|
|
8
|
+
placeholder: { control: 'text' },
|
|
9
|
+
label: { control: 'text' },
|
|
10
|
+
disabled: { control: 'boolean' },
|
|
11
|
+
multiple: { control: 'boolean' },
|
|
12
|
+
required: { control: 'boolean' },
|
|
13
|
+
loading: { control: 'boolean' },
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Definisco il tipo come costante anziché come interfaccia
|
|
18
|
+
const defaultOptions = [
|
|
19
|
+
{ value: 'option1', label: 'Opzione 1' },
|
|
20
|
+
{ value: 'option2', label: 'Opzione 2' },
|
|
21
|
+
{ value: 'option3', label: 'Opzione 3' },
|
|
22
|
+
{ value: 'option4', label: 'Opzione 4' },
|
|
23
|
+
{ value: 'option5', label: 'Opzione 5' },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const Template = (args) => {
|
|
27
|
+
const { options, ...otherArgs } = args;
|
|
28
|
+
const attributes = generateAttributesFromArgs(otherArgs);
|
|
29
|
+
|
|
30
|
+
// Crea le opzioni per il select
|
|
31
|
+
const optionsToUse = options || defaultOptions;
|
|
32
|
+
const optionsString = JSON.stringify(optionsToUse).replace(/"/g, '"');
|
|
33
|
+
|
|
34
|
+
return formatHtml(`
|
|
35
|
+
<jump-filter-select ${attributes} options='${optionsString}'>
|
|
36
|
+
</jump-filter-select>
|
|
37
|
+
`);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Versione alternativa con opzioni definite come elementi figli
|
|
41
|
+
const TemplateWithChildren = (args) => {
|
|
42
|
+
const { options, ...otherArgs } = args;
|
|
43
|
+
const attributes = generateAttributesFromArgs(otherArgs);
|
|
44
|
+
|
|
45
|
+
const optionsToUse = options || defaultOptions;
|
|
46
|
+
const optionsHtml = optionsToUse
|
|
47
|
+
.map(opt => `<sl-option value="${opt.value}">${opt.label}</sl-option>`)
|
|
48
|
+
.join('');
|
|
49
|
+
|
|
50
|
+
return formatHtml(`
|
|
51
|
+
<jump-filter-select ${attributes}>
|
|
52
|
+
${optionsHtml}
|
|
53
|
+
</jump-filter-select>
|
|
54
|
+
`);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Default = Template.bind({});
|
|
58
|
+
Default.args = {
|
|
59
|
+
placeholder: 'Seleziona un\'opzione',
|
|
60
|
+
label: 'Ordina per',
|
|
61
|
+
value: '',
|
|
62
|
+
disabled: false,
|
|
63
|
+
multiple: false,
|
|
64
|
+
required: false,
|
|
65
|
+
loading: false,
|
|
66
|
+
options: defaultOptions,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithValue = Template.bind({});
|
|
70
|
+
WithValue.args = {
|
|
71
|
+
...Default.args,
|
|
72
|
+
value: 'option1',
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Disabled = Template.bind({});
|
|
76
|
+
Disabled.args = {
|
|
77
|
+
...Default.args,
|
|
78
|
+
disabled: true,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Multiple = Template.bind({});
|
|
82
|
+
Multiple.args = {
|
|
83
|
+
...Default.args,
|
|
84
|
+
multiple: true,
|
|
85
|
+
value: JSON.stringify(['option1', 'option3']),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const WithCustomLabel = Template.bind({});
|
|
89
|
+
WithCustomLabel.args = {
|
|
90
|
+
...Default.args,
|
|
91
|
+
label: 'Opzioni disponibili',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const Required = Template.bind({});
|
|
95
|
+
Required.args = {
|
|
96
|
+
...Default.args,
|
|
97
|
+
required: true,
|
|
98
|
+
label: 'Campo obbligatorio',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Loading = Template.bind({});
|
|
102
|
+
Loading.args = {
|
|
103
|
+
...Default.args,
|
|
104
|
+
loading: true,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Esempio con opzioni specifiche per l'ordinamento
|
|
108
|
+
export const OrderingExample = Template.bind({});
|
|
109
|
+
OrderingExample.args = {
|
|
110
|
+
...Default.args,
|
|
111
|
+
label: 'Ordina per',
|
|
112
|
+
placeholder: 'Seleziona un criterio',
|
|
113
|
+
options: [
|
|
114
|
+
{ value: 'price-asc', label: 'Prezzo crescente' },
|
|
115
|
+
{ value: 'price-desc', label: 'Prezzo decrescente' },
|
|
116
|
+
{ value: 'name-asc', label: 'Nome A-Z' },
|
|
117
|
+
{ value: 'name-desc', label: 'Nome Z-A' },
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const TemplateCustomStyles = (args) => {
|
|
122
|
+
const { options, ...otherArgs } = args;
|
|
123
|
+
const attributes = generateAttributesFromArgs(otherArgs);
|
|
124
|
+
|
|
125
|
+
const optionsToUse = options || defaultOptions;
|
|
126
|
+
const optionsString = JSON.stringify(optionsToUse).replace(/"/g, '"');
|
|
127
|
+
|
|
128
|
+
return formatHtml(`
|
|
129
|
+
<div>
|
|
130
|
+
<style>
|
|
131
|
+
.custom-select {
|
|
132
|
+
--jump-select-border-color: #ddd;
|
|
133
|
+
--jump-select-border-color-hover: #00a651;
|
|
134
|
+
--jump-select-border-color-focus: #00a651;
|
|
135
|
+
--jump-select-option-selected-background: #00a651;
|
|
136
|
+
--jump-select-height: 48px;
|
|
137
|
+
--jump-select-border-radius: 8px;
|
|
138
|
+
--jump-select-font-size: 16px;
|
|
139
|
+
}
|
|
140
|
+
</style>
|
|
141
|
+
<jump-filter-select class="custom-select" ${attributes} options='${optionsString}'>
|
|
142
|
+
</jump-filter-select>
|
|
143
|
+
</div>
|
|
144
|
+
`);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const CustomStyles = TemplateCustomStyles.bind({});
|
|
148
|
+
CustomStyles.args = {
|
|
149
|
+
...Default.args,
|
|
150
|
+
label: 'Select con stile personalizzato',
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Esempio con opzioni definite come elementi figli nel HTML
|
|
154
|
+
export const WithChildOptions = args => {
|
|
155
|
+
const { options, ...otherArgs } = args;
|
|
156
|
+
const attributes = generateAttributesFromArgs(otherArgs);
|
|
157
|
+
|
|
158
|
+
return formatHtml(`
|
|
159
|
+
<jump-filter-select ${attributes}>
|
|
160
|
+
<sl-option value="pizza">Pizza</sl-option>
|
|
161
|
+
<sl-option value="pasta">Pasta</sl-option>
|
|
162
|
+
<sl-option value="risotto">Risotto</sl-option>
|
|
163
|
+
<sl-option value="tiramisu">Tiramisù</sl-option>
|
|
164
|
+
</jump-filter-select>
|
|
165
|
+
`);
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
WithChildOptions.args = {
|
|
169
|
+
...Default.args,
|
|
170
|
+
label: 'Scegli un piatto italiano',
|
|
171
|
+
placeholder: 'Seleziona un piatto',
|
|
172
|
+
options: null, // Non usiamo le opzioni da proprietà qui
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Esempio con un pulsante che imposta il valore programmaticamente
|
|
176
|
+
export const WithSetValueMethod = args => {
|
|
177
|
+
const { options, ...otherArgs } = args;
|
|
178
|
+
const attributes = generateAttributesFromArgs(otherArgs);
|
|
179
|
+
|
|
180
|
+
const optionsToUse = options || defaultOptions;
|
|
181
|
+
const optionsString = JSON.stringify(optionsToUse).replace(/"/g, '"');
|
|
182
|
+
|
|
183
|
+
return formatHtml(`
|
|
184
|
+
<div>
|
|
185
|
+
<jump-filter-select id="programmable-select" ${attributes} options='${optionsString}'>
|
|
186
|
+
</jump-filter-select>
|
|
187
|
+
|
|
188
|
+
<div style="margin-top: 20px;">
|
|
189
|
+
<button onclick="document.querySelector('#programmable-select').setValue('option3')">
|
|
190
|
+
Seleziona Opzione 3
|
|
191
|
+
</button>
|
|
192
|
+
<button onclick="document.querySelector('#programmable-select').setValue('option5')">
|
|
193
|
+
Seleziona Opzione 5
|
|
194
|
+
</button>
|
|
195
|
+
<button onclick="document.querySelector('#programmable-select').setValue('')">
|
|
196
|
+
Reset
|
|
197
|
+
</button>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div style="margin-top: 10px;">
|
|
201
|
+
<small>Clicca sui pulsanti per cambiare il valore programmaticamente</small>
|
|
202
|
+
</div>
|
|
203
|
+
</div>
|
|
204
|
+
`);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
WithSetValueMethod.args = {
|
|
208
|
+
...Default.args,
|
|
209
|
+
label: 'Select con metodo setValue',
|
|
210
|
+
value: 'option1',
|
|
211
|
+
};
|