@prolibu-suite/cobalt-core 0.9.3 → 0.9.5
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/custom-elements.json +375 -25
- package/dist/cjs/co-audio-player.cjs.entry.js +107 -18
- package/dist/cjs/co-avatar_2.cjs.entry.js +7 -31
- package/dist/cjs/co-button.cjs.entry.js +6 -4
- package/dist/cjs/co-calendar-month_2.cjs.entry.js +59 -2
- package/dist/cjs/co-checkbox.cjs.entry.js +10 -4
- package/dist/cjs/co-chip_2.cjs.entry.js +388 -18
- package/dist/cjs/co-color-picker.cjs.entry.js +36 -3
- package/dist/cjs/co-combobox.cjs.entry.js +44 -4
- package/dist/cjs/co-event-popover.cjs.entry.js +5 -2
- package/dist/cjs/co-file-field.cjs.entry.js +12 -6
- package/dist/cjs/co-icon-button.cjs.entry.js +5 -2
- package/dist/cjs/co-icon.cjs.entry.js +17 -1
- package/dist/cjs/co-input.cjs.entry.js +21 -1
- package/dist/cjs/co-loader.cjs.entry.js +1 -1
- package/dist/cjs/co-number-field.cjs.entry.js +22 -2
- package/dist/cjs/co-ref-field.cjs.entry.js +99 -13
- package/dist/cjs/co-select.cjs.entry.js +273 -8
- package/dist/cjs/co-tags-field.cjs.entry.js +1 -1
- package/dist/cjs/cobalt.cjs.js +1 -1
- package/dist/cjs/color-YhUkm10t.js +32 -0
- package/dist/cjs/fieldChip-BLzo9MEV.js +7 -0
- package/dist/cjs/index-DK-2Lzmf.js +4 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cobalt/cobalt.esm.js +1 -1
- package/dist/cobalt/p-0c463d9a.entry.js +1 -0
- package/dist/cobalt/{p-3ced4269.entry.js → p-2828ecf6.entry.js} +1 -1
- package/dist/cobalt/p-2f88d151.entry.js +1 -0
- package/dist/cobalt/p-409f28bb.entry.js +1 -0
- package/dist/cobalt/{p-18af9e44.entry.js → p-568cfe8d.entry.js} +1 -1
- package/dist/cobalt/p-6bf814f9.entry.js +1 -0
- package/dist/cobalt/p-76420ac1.entry.js +1 -0
- package/dist/cobalt/p-7ea87b75.entry.js +1 -0
- package/dist/cobalt/p-8b4b3589.entry.js +1 -0
- package/dist/cobalt/p-93c68029.entry.js +1 -0
- package/dist/cobalt/p-BG4WRR22.js +1 -0
- package/dist/cobalt/p-a2d31248.entry.js +1 -0
- package/dist/cobalt/p-bcedbd73.entry.js +1 -0
- package/dist/cobalt/p-dfd25f1d.entry.js +1 -0
- package/dist/cobalt/p-e364b8a5.entry.js +1 -0
- package/dist/cobalt/p-e84eda2e.entry.js +1 -0
- package/dist/cobalt/p-f25967fb.entry.js +1 -0
- package/dist/cobalt/p-f5f1b463.entry.js +1 -0
- package/dist/cobalt/p-fef5db54.entry.js +1 -0
- package/dist/cobalt/p-mAGnZXRn.js +1 -0
- package/dist/collection/components/co-audio-player/co-audio-player.js +81 -17
- package/dist/collection/components/co-audio-player/co-audio-player.utils.js +27 -2
- package/dist/collection/components/co-autocomplete/co-autocomplete.js +1 -1
- package/dist/collection/components/co-avatar/co-avatar.js +5 -1
- package/dist/collection/components/co-avatar-group/co-avatar-group.js +1 -1
- package/dist/collection/components/co-button/co-button.css +7 -0
- package/dist/collection/components/co-button/co-button.js +7 -5
- package/dist/collection/components/co-calendar-month/co-calendar-month.js +59 -2
- package/dist/collection/components/co-checkbox/co-checkbox.css +22 -0
- package/dist/collection/components/co-checkbox/co-checkbox.js +9 -3
- package/dist/collection/components/co-checkbox-group/co-checkbox-group.js +1 -1
- package/dist/collection/components/co-color-picker/co-color-picker.css +7 -0
- package/dist/collection/components/co-color-picker/co-color-picker.js +35 -2
- package/dist/collection/components/co-combobox/co-combobox.css +7 -0
- package/dist/collection/components/co-combobox/co-combobox.js +44 -4
- package/dist/collection/components/co-command-search/co-command-search.js +1 -1
- package/dist/collection/components/co-data-table/co-data-table.js +1 -1
- package/dist/collection/components/co-date-range-picker/co-date-range-picker.js +2 -2
- package/dist/collection/components/co-event-popover/co-event-popover.js +5 -2
- package/dist/collection/components/co-file-field/co-file-field.css +2 -0
- package/dist/collection/components/co-file-field/co-file-field.js +8 -5
- package/dist/collection/components/co-icon/iconLoader.js +17 -1
- package/dist/collection/components/co-icon-button/co-icon-button.css +7 -0
- package/dist/collection/components/co-icon-button/co-icon-button.js +6 -3
- package/dist/collection/components/co-input/co-input.css +13 -0
- package/dist/collection/components/co-input/co-input.js +21 -0
- package/dist/collection/components/co-loader/co-loader.css +5 -3
- package/dist/collection/components/co-number-field/co-number-field.js +23 -2
- package/dist/collection/components/co-option-list/co-option-list.css +45 -2
- package/dist/collection/components/co-option-list/co-option-list.js +468 -18
- package/dist/collection/components/co-option-list/optionListLogic.js +25 -0
- package/dist/collection/components/co-popover/co-popover.js +1 -1
- package/dist/collection/components/co-radio-group/co-radio-group.js +1 -1
- package/dist/collection/components/co-ref-field/co-ref-field.css +49 -0
- package/dist/collection/components/co-ref-field/co-ref-field.js +252 -12
- package/dist/collection/components/co-segmented-bar/co-segmented-bar.js +1 -1
- package/dist/collection/components/co-select/co-select.css +19 -0
- package/dist/collection/components/co-select/co-select.js +275 -9
- package/dist/collection/components/co-sidebar-nav/co-sidebar-nav.js +1 -1
- package/dist/collection/components/co-toast/co-toast.js +2 -2
- package/dist/collection/components/co-transfer-list/co-transfer-list.js +1 -1
- package/dist/collection/utils/fieldChip.js +1 -1
- package/dist/collection/utils/fileI18n.js +3 -0
- package/dist/components/co-accordion.js +1 -1
- package/dist/components/co-action-bar.js +1 -1
- package/dist/components/co-audio-player.js +1 -1
- package/dist/components/co-autocomplete.js +1 -1
- package/dist/components/co-avatar-group.js +1 -1
- package/dist/components/co-avatar.js +1 -1
- package/dist/components/co-breadcrumb-item.js +1 -1
- package/dist/components/co-breadcrumb.js +1 -1
- package/dist/components/co-button.js +1 -1
- package/dist/components/co-calendar-month.js +1 -1
- package/dist/components/co-calendar-timegrid.js +1 -1
- package/dist/components/co-calendar.js +1 -1
- package/dist/components/co-carousel.js +1 -1
- package/dist/components/co-checkbox-group.js +1 -1
- package/dist/components/co-checkbox.js +1 -1
- package/dist/components/co-chip.js +1 -1
- package/dist/components/co-color-picker.js +1 -1
- package/dist/components/co-column-picker.js +1 -1
- package/dist/components/co-combobox.js +1 -1
- package/dist/components/co-command-search.js +1 -1
- package/dist/components/co-data-table-pagination.js +1 -1
- package/dist/components/co-data-table.js +1 -1
- package/dist/components/co-date-field.js +1 -1
- package/dist/components/co-date-picker.js +1 -1
- package/dist/components/co-date-range-picker.js +1 -1
- package/dist/components/co-date-range.js +1 -1
- package/dist/components/co-date-time-picker.js +1 -1
- package/dist/components/co-drawer.js +1 -1
- package/dist/components/co-drive-card.js +1 -1
- package/dist/components/co-drop-zone.js +1 -1
- package/dist/components/co-emoji-picker.js +1 -1
- package/dist/components/co-empty-state.js +1 -1
- package/dist/components/co-event-calendar.js +1 -1
- package/dist/components/co-event-popover.js +1 -1
- package/dist/components/co-fab.js +1 -1
- package/dist/components/co-file-field.js +1 -1
- package/dist/components/co-file-type-tile.js +1 -1
- package/dist/components/co-helper-text.js +1 -1
- package/dist/components/co-icon-button.js +1 -1
- package/dist/components/co-icon.js +1 -1
- package/dist/components/co-input.js +1 -1
- package/dist/components/co-json-field.js +1 -1
- package/dist/components/co-lightbox.js +1 -1
- package/dist/components/co-list-footer.js +1 -1
- package/dist/components/co-list-item.js +1 -1
- package/dist/components/co-loader.js +1 -1
- package/dist/components/co-menu-item.js +1 -1
- package/dist/components/co-modal.js +1 -1
- package/dist/components/co-number-field.js +1 -1
- package/dist/components/co-option-list.js +1 -1
- package/dist/components/co-page-header.js +1 -1
- package/dist/components/co-phone-field.js +1 -1
- package/dist/components/co-radio-group.js +1 -1
- package/dist/components/co-rating.js +1 -1
- package/dist/components/co-ref-field.js +1 -1
- package/dist/components/co-rich-text-editor.js +1 -1
- package/dist/components/co-rich-text-toolbar.js +1 -1
- package/dist/components/co-select.js +1 -1
- package/dist/components/co-sidebar-nav.js +1 -1
- package/dist/components/co-slider.js +1 -1
- package/dist/components/co-switch.js +1 -1
- package/dist/components/co-tab.js +1 -1
- package/dist/components/co-tags-field.js +1 -1
- package/dist/components/co-textarea.js +1 -1
- package/dist/components/co-toast.js +1 -1
- package/dist/components/co-toggle-button.js +1 -1
- package/dist/components/co-transfer-list.js +1 -1
- package/dist/components/co-video.js +1 -1
- package/dist/components/{p-CklsvHeL.js → p-B0Dc-I_C.js} +1 -1
- package/dist/components/{p-DzoNGEDU.js → p-BH184F0X.js} +1 -1
- package/dist/components/{p-BGD3oQ73.js → p-BHYtxTzM.js} +1 -1
- package/dist/components/{p-mom5kiBa.js → p-BTQEg3UO.js} +1 -1
- package/dist/components/p-BZIB4JDs.js +1 -0
- package/dist/components/p-Bbny3WUc.js +1 -0
- package/dist/components/{p-D5QJpmqf.js → p-Bxk96Zgc.js} +1 -1
- package/dist/components/p-C1Kv3zYZ.js +1 -0
- package/dist/components/p-C4U2tbRp.js +1 -0
- package/dist/components/{p-CyMaOb1j.js → p-CA_JAK9s.js} +1 -1
- package/dist/components/{p-AvSaw4Ua.js → p-CR0izsJC.js} +1 -1
- package/dist/components/p-CuZXTvDM.js +1 -0
- package/dist/components/{p-_131DL6m.js → p-D4qzGifz.js} +1 -1
- package/dist/components/{p-BsQQ7Mki.js → p-D5EdMieb.js} +1 -1
- package/dist/components/p-Dabi98BI.js +1 -0
- package/dist/components/p-DbipMAyT.js +1 -0
- package/dist/components/p-DgUBcJIS.js +1 -0
- package/dist/components/p-Dj1EZ5qD.js +1 -0
- package/dist/components/{p-DkmKOF60.js → p-P8wvwhM2.js} +1 -1
- package/dist/components/{p-nwy6X1QT.js → p-hfGFsvaD.js} +1 -1
- package/dist/esm/co-audio-player.entry.js +107 -18
- package/dist/esm/co-avatar_2.entry.js +6 -30
- package/dist/esm/co-button.entry.js +6 -4
- package/dist/esm/co-calendar-month_2.entry.js +59 -2
- package/dist/esm/co-checkbox.entry.js +10 -4
- package/dist/esm/co-chip_2.entry.js +388 -18
- package/dist/esm/co-color-picker.entry.js +36 -3
- package/dist/esm/co-combobox.entry.js +44 -4
- package/dist/esm/co-event-popover.entry.js +5 -2
- package/dist/esm/co-file-field.entry.js +12 -6
- package/dist/esm/co-icon-button.entry.js +5 -2
- package/dist/esm/co-icon.entry.js +17 -1
- package/dist/esm/co-input.entry.js +21 -1
- package/dist/esm/co-loader.entry.js +1 -1
- package/dist/esm/co-number-field.entry.js +22 -2
- package/dist/esm/co-ref-field.entry.js +99 -13
- package/dist/esm/co-select.entry.js +273 -8
- package/dist/esm/co-tags-field.entry.js +1 -1
- package/dist/esm/cobalt.js +1 -1
- package/dist/esm/color-BG4WRR22.js +30 -0
- package/dist/esm/fieldChip-DsAfq1e0.js +5 -0
- package/dist/esm/index-CrtiywTB.js +4 -4
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/co-audio-player/co-audio-player.d.ts +13 -0
- package/dist/types/components/co-audio-player/co-audio-player.utils.d.ts +18 -1
- package/dist/types/components/co-button/co-button.d.ts +3 -1
- package/dist/types/components/co-calendar-month/co-calendar-month.d.ts +7 -0
- package/dist/types/components/co-checkbox/co-checkbox.d.ts +1 -0
- package/dist/types/components/co-color-picker/co-color-picker.d.ts +15 -0
- package/dist/types/components/co-combobox/co-combobox.d.ts +17 -0
- package/dist/types/components/co-icon-button/co-icon-button.d.ts +3 -0
- package/dist/types/components/co-input/co-input.d.ts +9 -0
- package/dist/types/components/co-number-field/co-number-field.d.ts +9 -0
- package/dist/types/components/co-option-list/co-option-list.d.ts +79 -0
- package/dist/types/components/co-option-list/optionListLogic.d.ts +23 -1
- package/dist/types/components/co-ref-field/co-ref-field.d.ts +46 -0
- package/dist/types/components/co-select/co-select.d.ts +67 -0
- package/dist/types/components.d.ts +110 -4
- package/dist/types/utils/fieldChip.d.ts +5 -0
- package/dist/types/utils/fileI18n.d.ts +1 -0
- package/package.json +4 -4
- package/dist/cjs/fieldChip-xNJPEFcS.js +0 -7
- package/dist/cobalt/p-02ac492f.entry.js +0 -1
- package/dist/cobalt/p-0ccb672b.entry.js +0 -1
- package/dist/cobalt/p-2d81b292.entry.js +0 -1
- package/dist/cobalt/p-4a503187.entry.js +0 -1
- package/dist/cobalt/p-55566b37.entry.js +0 -1
- package/dist/cobalt/p-680d3db8.entry.js +0 -1
- package/dist/cobalt/p-7457aa89.entry.js +0 -1
- package/dist/cobalt/p-77719335.entry.js +0 -1
- package/dist/cobalt/p-8f600512.entry.js +0 -1
- package/dist/cobalt/p-CQAYgqA6.js +0 -1
- package/dist/cobalt/p-a02db338.entry.js +0 -1
- package/dist/cobalt/p-a51d8775.entry.js +0 -1
- package/dist/cobalt/p-aafb9d11.entry.js +0 -1
- package/dist/cobalt/p-b28dc0fe.entry.js +0 -1
- package/dist/cobalt/p-c6b9b9d6.entry.js +0 -1
- package/dist/cobalt/p-d4debd6f.entry.js +0 -1
- package/dist/cobalt/p-d629fb4e.entry.js +0 -1
- package/dist/components/p-B3TkpLNh.js +0 -1
- package/dist/components/p-B7hvddnu.js +0 -1
- package/dist/components/p-BT5tSgZa.js +0 -1
- package/dist/components/p-CXLX8DpD.js +0 -1
- package/dist/components/p-DTvb412h.js +0 -1
- package/dist/components/p-DvhR3H61.js +0 -1
- package/dist/components/p-KWTokD0C.js +0 -1
- package/dist/components/p-Q6caHt79.js +0 -1
- package/dist/components/p-WWlZiln1.js +0 -1
- package/dist/esm/fieldChip-BZDUy9Z-.js +0 -5
|
@@ -35,21 +35,154 @@ export class CoSelect {
|
|
|
35
35
|
// Frozen at open time so selected options render first without jumping while
|
|
36
36
|
// the user toggles them during the session (mirrors co-ref-field).
|
|
37
37
|
this.sortSnapshot = new Set();
|
|
38
|
+
/** Índice (sobre `filteredOptions`) de la opción resaltada por teclado.
|
|
39
|
+
* Patrón APG de combobox: el foco NUNCA baja a las opciones — queda en el
|
|
40
|
+
* trigger (o en el search input) y esto viaja por `aria-activedescendant`. */
|
|
41
|
+
this.activeIndex = -1;
|
|
42
|
+
/** Scroll pendiente hacia la opción activa, resuelto en componentDidRender. */
|
|
43
|
+
this.pendingActiveScroll = false;
|
|
44
|
+
this.activeScrollFrames = 0;
|
|
38
45
|
this.lastParsedOptions = [];
|
|
39
46
|
this.lastRankSearch = '';
|
|
40
47
|
this.lastRanked = [];
|
|
41
48
|
this.handleSearchInput = (e) => {
|
|
42
49
|
this.searchText = e.target.value;
|
|
43
50
|
this.scrollTop = 0;
|
|
51
|
+
// Resultset nuevo: la activa vuelve a la primera coincidencia (si el índice
|
|
52
|
+
// viejo sobreviviera, apuntaría a otra opción o a ninguna).
|
|
53
|
+
this.activeIndex = this.filteredOptions.length ? 0 : -1;
|
|
44
54
|
};
|
|
45
55
|
this.handleTriggerClick = (e) => {
|
|
46
56
|
if (this.disabled)
|
|
47
57
|
e.stopPropagation();
|
|
48
58
|
};
|
|
59
|
+
this.handleTriggerKeyDown = (e) => {
|
|
60
|
+
if (this.disabled)
|
|
61
|
+
return;
|
|
62
|
+
// Los botones internos (quitar chip, clear) son tabIndex={-1} pero quedan
|
|
63
|
+
// focuseados al clickearlos: sin este guard su Enter/Space nativo lo
|
|
64
|
+
// secuestraría el toggle del trigger y el botón nunca se activaría.
|
|
65
|
+
if (e.target !== this.triggerEl)
|
|
66
|
+
return;
|
|
67
|
+
// Panel abierto: manda la navegación del listbox (Enter/Space seleccionan
|
|
68
|
+
// la activa en vez de togglear).
|
|
69
|
+
if (this.handleNavKeyDown(e))
|
|
70
|
+
return;
|
|
71
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
if (this.isOpen)
|
|
74
|
+
this.isOpen = false;
|
|
75
|
+
else
|
|
76
|
+
this.openPanel();
|
|
77
|
+
}
|
|
78
|
+
else if (e.key === 'ArrowDown' && !this.isOpen) {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
this.openPanel();
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/** Navegación del panel abierto, compartida por el trigger (caso
|
|
84
|
+
* no-searchable, donde el foco se queda ahí) y el search input (caso
|
|
85
|
+
* searchable, donde las flechas no deben mover el caret). Devuelve `true`
|
|
86
|
+
* si consumió la tecla — con el panel cerrado no consume nada, así el
|
|
87
|
+
* comportamiento del trigger (Enter/Space togglean, ArrowDown abre) queda
|
|
88
|
+
* intacto. */
|
|
89
|
+
this.handleNavKeyDown = (e) => {
|
|
90
|
+
if (this.disabled || !this.isOpen)
|
|
91
|
+
return false;
|
|
92
|
+
// Divergencia consciente con co-option-list: las flechas NO saltean las
|
|
93
|
+
// opciones deshabilitadas (mapeo 1:1 índice↔fila, `aria-posinset` estable);
|
|
94
|
+
// seleccionarlas sigue siendo imposible — ver activateActiveOption.
|
|
95
|
+
const total = this.filteredOptions.length;
|
|
96
|
+
const last = total - 1;
|
|
97
|
+
const current = this.activeIndex >= 0 ? this.activeIndex : -1;
|
|
98
|
+
switch (e.key) {
|
|
99
|
+
case 'ArrowDown':
|
|
100
|
+
if (total)
|
|
101
|
+
this.setActiveIndex(current >= last ? 0 : current + 1);
|
|
102
|
+
break;
|
|
103
|
+
case 'ArrowUp':
|
|
104
|
+
if (total)
|
|
105
|
+
this.setActiveIndex(current <= 0 ? last : current - 1);
|
|
106
|
+
break;
|
|
107
|
+
case 'Home':
|
|
108
|
+
if (total)
|
|
109
|
+
this.setActiveIndex(0);
|
|
110
|
+
break;
|
|
111
|
+
case 'End':
|
|
112
|
+
if (total)
|
|
113
|
+
this.setActiveIndex(last);
|
|
114
|
+
break;
|
|
115
|
+
case ' ':
|
|
116
|
+
// En el search input la barra espaciadora tipea: solo el trigger
|
|
117
|
+
// (no-searchable) la usa para seleccionar.
|
|
118
|
+
if (e.target === this.searchInputEl)
|
|
119
|
+
return false;
|
|
120
|
+
this.activateActiveOption();
|
|
121
|
+
break;
|
|
122
|
+
case 'Enter':
|
|
123
|
+
this.activateActiveOption();
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
/** Alinea el scroll REAL con la ventana virtual ya renderizada.
|
|
132
|
+
*
|
|
133
|
+
* Escribe `scrollTop` DIRECTO sobre el viewport de OverlayScrollbars: el
|
|
134
|
+
* `[role="listbox"]` queda en `overflow:hidden` y OS monta su propio
|
|
135
|
+
* elemento scrolleable, así que `scrollIntoView` desde el nodo de la opción
|
|
136
|
+
* no siempre encuentra un ancestro que scrollee. Y reintenta unos frames
|
|
137
|
+
* porque en la APERTURA el panel del popover todavía no tiene layout (su
|
|
138
|
+
* ciclo de posicionamiento son 2 rAF): sin layout el `scrollTop` se clampea
|
|
139
|
+
* a 0 en silencio y el usuario ve el panel EN BLANCO con la fila activa
|
|
140
|
+
* renderizada fuera del área visible. */
|
|
141
|
+
this.flushActiveScroll = () => {
|
|
142
|
+
var _a, _b, _c, _d, _e;
|
|
143
|
+
if (!this.pendingActiveScroll)
|
|
144
|
+
return;
|
|
145
|
+
if (!this.isOpen) {
|
|
146
|
+
this.pendingActiveScroll = false;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const target = this.scrollTop || 0;
|
|
150
|
+
const viewport = (_b = (_a = this.osInstance) === null || _a === void 0 ? void 0 : _a.elements().viewport) !== null && _b !== void 0 ? _b : this.optionsContainerEl;
|
|
151
|
+
if (viewport) {
|
|
152
|
+
viewport.scrollTop = target;
|
|
153
|
+
if (Math.abs(viewport.scrollTop - target) <= 1) {
|
|
154
|
+
this.pendingActiveScroll = false;
|
|
155
|
+
this.activeScrollFrames = 0;
|
|
156
|
+
// Afinado dentro del slice ya visible (las alturas reales de fila no son
|
|
157
|
+
// exactamente ITEM_HEIGHT). jsdom no implementa scrollIntoView.
|
|
158
|
+
(_e = (_d = (_c = this.el.shadowRoot) === null || _c === void 0 ? void 0 : _c.getElementById(this.optionId(this.activeIndex))) === null || _d === void 0 ? void 0 : _d.scrollIntoView) === null || _e === void 0 ? void 0 : _e.call(_d, { block: 'nearest' });
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (++this.activeScrollFrames > CoSelect.ACTIVE_SCROLL_MAX_FRAMES) {
|
|
163
|
+
this.pendingActiveScroll = false;
|
|
164
|
+
this.activeScrollFrames = 0;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
requestAnimationFrame(this.flushActiveScroll);
|
|
168
|
+
};
|
|
49
169
|
this.handlePopoverOpen = () => {
|
|
170
|
+
// `coOpen` no es exclusivo de la transición cerrado→abierto: co-popover lo
|
|
171
|
+
// emite desde su componentDidLoad cuando monta/upgradea ya con open=true.
|
|
172
|
+
// Con el panel YA abierto no hay nada que (re)congelar — y re-congelar sí
|
|
173
|
+
// haría daño: en multiple, un snapshot nuevo reordena la lista
|
|
174
|
+
// (selected-first) por debajo de un `activeIndex` que es POSICIONAL, así que
|
|
175
|
+
// la activa saltaría de fila. También evita el doble-freeze del path de
|
|
176
|
+
// teclado, donde openPanel() ya congeló antes de mover `isOpen`.
|
|
177
|
+
if (this.isOpen)
|
|
178
|
+
return;
|
|
50
179
|
// Freeze the selected-first ordering for this opening.
|
|
51
180
|
this.sortSnapshot = new Set(this.selectedValues);
|
|
52
181
|
this.isOpen = true;
|
|
182
|
+
// ⚠️ La opción activa NO se recalcula acá: la inicialización vive en el
|
|
183
|
+
// @Watch('isOpen'), que corre una sola vez por apertura. Un reset colgado de
|
|
184
|
+
// este evento devolvería la activa a la opción SELECCIONADA en pleno uso del
|
|
185
|
+
// teclado (las flechas quedarían clavadas en ese índice).
|
|
53
186
|
};
|
|
54
187
|
this.handlePopoverClose = () => {
|
|
55
188
|
this.isOpen = false;
|
|
@@ -169,14 +302,107 @@ export class CoSelect {
|
|
|
169
302
|
};
|
|
170
303
|
return map[this.status] || null;
|
|
171
304
|
}
|
|
305
|
+
optionId(index) {
|
|
306
|
+
return `co-select-option-${index}`;
|
|
307
|
+
}
|
|
308
|
+
/** Al abrir, la activa arranca en la opción seleccionada (la primera de ellas
|
|
309
|
+
* en multiple) para que las flechas continúen desde donde el usuario está. */
|
|
310
|
+
resetActiveIndex() {
|
|
311
|
+
const opts = this.filteredOptions;
|
|
312
|
+
if (opts.length === 0) {
|
|
313
|
+
this.activeIndex = -1;
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const sel = this.selectedValues;
|
|
317
|
+
const i = sel.length ? opts.findIndex((o) => sel.includes(o.value)) : -1;
|
|
318
|
+
this.activeIndex = i >= 0 ? i : 0;
|
|
319
|
+
// En single NO hay hoisting selected-first (`filteredOptions` solo reordena
|
|
320
|
+
// en multiple): con la selección abajo en la lista, el índice inicial cae
|
|
321
|
+
// fuera del slice virtual y el `aria-activedescendant` apuntaría a un nodo
|
|
322
|
+
// inexistente. Hay que arrastrar el scroll con la activa.
|
|
323
|
+
this.scrollActiveIntoView();
|
|
324
|
+
}
|
|
172
325
|
onOpenChange(open) {
|
|
173
326
|
if (open) {
|
|
174
327
|
this.scrollTop = 0;
|
|
328
|
+
this.resetActiveIndex();
|
|
175
329
|
if (this.searchable)
|
|
176
|
-
|
|
330
|
+
this.focusSearchWhenVisible();
|
|
177
331
|
}
|
|
178
332
|
else {
|
|
179
333
|
this.searchText = '';
|
|
334
|
+
this.activeIndex = -1;
|
|
335
|
+
this.restoreTriggerFocus();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/** Apertura por TECLADO. Congela el orden selected-first ANTES de mover
|
|
339
|
+
* `isOpen` para que el @Watch calcule la opción activa sobre la lista
|
|
340
|
+
* definitiva; por mouse eso ya lo garantiza handlePopoverOpen, que corre
|
|
341
|
+
* antes del cambio de estado. */
|
|
342
|
+
openPanel() {
|
|
343
|
+
this.sortSnapshot = new Set(this.selectedValues);
|
|
344
|
+
this.isOpen = true;
|
|
345
|
+
}
|
|
346
|
+
setActiveIndex(index) {
|
|
347
|
+
this.activeIndex = index;
|
|
348
|
+
this.scrollActiveIntoView();
|
|
349
|
+
}
|
|
350
|
+
/** Enter/Space sobre una opción deshabilitada no hace nada — igual que el
|
|
351
|
+
* click (la tecla igual se consume: el panel abierto no togglea). */
|
|
352
|
+
activateActiveOption() {
|
|
353
|
+
const opt = this.filteredOptions[this.activeIndex];
|
|
354
|
+
if (opt && !opt.disabled)
|
|
355
|
+
this.handleOptionClick(opt.value);
|
|
356
|
+
}
|
|
357
|
+
/** Deja la opción activa dentro de la ventana virtual (state) y agenda el
|
|
358
|
+
* scroll real para después del próximo render. */
|
|
359
|
+
scrollActiveIntoView() {
|
|
360
|
+
const { ITEM_HEIGHT, VIEWPORT_ITEMS } = CoSelect;
|
|
361
|
+
const index = this.activeIndex;
|
|
362
|
+
if (!(index >= 0))
|
|
363
|
+
return;
|
|
364
|
+
// La lista está virtualizada: un índice fuera de la ventana renderizada
|
|
365
|
+
// (apertura con la selección abajo, Home/End, wrap) no tendría nodo — y el
|
|
366
|
+
// `aria-activedescendant` quedaría colgado. Se empuja la posición virtual
|
|
367
|
+
// para que el próximo slice lo incluya.
|
|
368
|
+
const top = index * ITEM_HEIGHT;
|
|
369
|
+
const viewportH = ITEM_HEIGHT * VIEWPORT_ITEMS;
|
|
370
|
+
const from = this.scrollTop || 0;
|
|
371
|
+
if (top < from)
|
|
372
|
+
this.scrollTop = top;
|
|
373
|
+
else if (top + ITEM_HEIGHT > from + viewportH)
|
|
374
|
+
this.scrollTop = top + ITEM_HEIGHT - viewportH;
|
|
375
|
+
// El scroll REAL se resuelve en componentDidRender, no en un rAF suelto:
|
|
376
|
+
// al abrir, el @Watch('isOpen') corre ANTES de que Stencil agende el
|
|
377
|
+
// re-render, así que un rAF pedido acá se ejecutaría con el slice viejo
|
|
378
|
+
// todavía en el DOM y no encontraría el nodo.
|
|
379
|
+
this.pendingActiveScroll = true;
|
|
380
|
+
this.activeScrollFrames = 0;
|
|
381
|
+
}
|
|
382
|
+
/** Enfoca el search esperando visibilidad real (paridad focusSearch de
|
|
383
|
+
* co-option-list): el panel se posiciona 2+ rAF después de abrir — y más
|
|
384
|
+
* tarde dentro de un modal/drawer animado — y focus() sobre un subtree sin
|
|
385
|
+
* layout es no-op silencioso. Un solo rAF dejaba el buscador sin foco en
|
|
386
|
+
* esos hosts. Reintenta ~20 frames; aborta si el panel se cerró. */
|
|
387
|
+
focusSearchWhenVisible(attempt = 0) {
|
|
388
|
+
var _a, _b;
|
|
389
|
+
if (!this.isOpen || !this.searchable)
|
|
390
|
+
return;
|
|
391
|
+
(_a = this.searchInputEl) === null || _a === void 0 ? void 0 : _a.focus();
|
|
392
|
+
if (this.searchInputEl && ((_b = this.el.shadowRoot) === null || _b === void 0 ? void 0 : _b.activeElement) === this.searchInputEl)
|
|
393
|
+
return;
|
|
394
|
+
if (attempt >= 20)
|
|
395
|
+
return;
|
|
396
|
+
requestAnimationFrame(() => this.focusSearchWhenVisible(attempt + 1));
|
|
397
|
+
}
|
|
398
|
+
/** Devuelve el foco al trigger al cerrar el panel (Escape, selección),
|
|
399
|
+
* salvo que el cierre venga de un click-outside que ya movió el foco a
|
|
400
|
+
* otro elemento — en ese caso no robarlo. */
|
|
401
|
+
restoreTriggerFocus() {
|
|
402
|
+
var _a;
|
|
403
|
+
const active = document.activeElement;
|
|
404
|
+
if (active === this.el || this.el.contains(active)) {
|
|
405
|
+
(_a = this.triggerEl) === null || _a === void 0 ? void 0 : _a.focus();
|
|
180
406
|
}
|
|
181
407
|
}
|
|
182
408
|
// OverlayScrollbars: floating, auto-hide handle that overlays the content (no
|
|
@@ -194,12 +420,26 @@ export class CoSelect {
|
|
|
194
420
|
}
|
|
195
421
|
}
|
|
196
422
|
componentDidRender() {
|
|
423
|
+
// Orden importante: primero se (re)crea la instancia de OverlayScrollbars,
|
|
424
|
+
// porque el scroll se escribe sobre SU viewport.
|
|
197
425
|
this.syncOverlayScrollbars();
|
|
426
|
+
this.flushActiveScroll();
|
|
427
|
+
}
|
|
428
|
+
componentWillLoad() {
|
|
429
|
+
// searchText se LEE en cada render (filteredOptions lo trimea con
|
|
430
|
+
// `searchable`) antes de que nadie lo escriba: se ancla acá y no solo en
|
|
431
|
+
// el class-field initializer, que el harness de specs no aplica (paridad
|
|
432
|
+
// `this.term = initialTerm || ''` de co-option-list).
|
|
433
|
+
this.searchText = this.searchText || '';
|
|
198
434
|
}
|
|
199
435
|
disconnectedCallback() {
|
|
200
436
|
var _a;
|
|
201
437
|
(_a = this.osInstance) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
202
438
|
this.osInstance = undefined;
|
|
439
|
+
// El retry por rAF del scroll no debe seguir escribiendo sobre nodos ya
|
|
440
|
+
// desprendidos del documento.
|
|
441
|
+
this.pendingActiveScroll = false;
|
|
442
|
+
this.activeScrollFrames = 0;
|
|
203
443
|
}
|
|
204
444
|
/** Option label with the matched substring wrapped for highlighting. */
|
|
205
445
|
renderLabel(label) {
|
|
@@ -221,31 +461,43 @@ export class CoSelect {
|
|
|
221
461
|
var _a;
|
|
222
462
|
const selected = this.selectedValues;
|
|
223
463
|
const options = this.filteredOptions;
|
|
224
|
-
|
|
464
|
+
// Se calcula UNA vez sobre `options` (no en un getter): el virtualizador
|
|
465
|
+
// re-renderiza en cada frame de scroll y `filteredOptions` recorre la lista
|
|
466
|
+
// de nuevo en modo multiple. Ausente con el panel cerrado o si el índice no
|
|
467
|
+
// apunta a una opción listada — un IDREF colgado es peor que ninguno.
|
|
468
|
+
const activeOptionId = this.isOpen && this.activeIndex >= 0 && this.activeIndex < options.length
|
|
469
|
+
? this.optionId(this.activeIndex)
|
|
470
|
+
: undefined;
|
|
471
|
+
return (h("div", { key: '0305b0465d53217480a9c8eb7a7f8eb9f1a6d01e', class: {
|
|
225
472
|
'co-select': true,
|
|
226
473
|
'co-select--open': this.isOpen,
|
|
227
474
|
'co-select--disabled': this.disabled,
|
|
228
475
|
[`co-select--${this.size}`]: true,
|
|
229
476
|
[`co-select--${this.status}`]: this.status !== 'default',
|
|
230
477
|
'co-select--flat': this.variant === 'flat',
|
|
231
|
-
} }, (this.label || this.secondaryLabel) && (h("div", { key: '
|
|
478
|
+
} }, (this.label || this.secondaryLabel) && (h("div", { key: '7b13a836b8124f62b711481c35fe0efa7be01ee2', class: "co-select__labels" }, this.label && h("label", { key: 'a05933f160d3b48cf746fda1a01195e99fca94bc', class: "co-select__label" }, this.label, h(RequiredMark, { key: 'd71397f773f28a1f8a224587a5c4e67bd5f80d41', required: this.required })), this.secondaryLabel && h("span", { key: '26cb193f44b4e57395d305a54044d2e54f925963', class: "co-select__secondary-label" }, this.secondaryLabel))), h("co-popover", { key: '7becd47bbac023383cfa3f0f2a5cef15d12d7510', open: this.isOpen, placement: "bottom-start", matchWidth: true, offset: 4, onCoOpen: this.handlePopoverOpen, onCoClose: this.handlePopoverClose }, h("div", { key: 'e93a10d03648cb510b27d80b9cf665724827d9c0', slot: "trigger", class: "co-select__trigger", role: "combobox", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-haspopup": "listbox", "aria-label": this.label || undefined, "aria-disabled": this.disabled ? 'true' : undefined, "aria-controls": CoSelect.LISTBOX_ID, "aria-activedescendant": activeOptionId, tabIndex: this.disabled ? -1 : 0, ref: (el) => (this.triggerEl = el), onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown }, this.iconLeft && h("co-icon", { key: '837f075fcae3b2bd11c4f5199591fdb4e840518c', name: this.iconLeft, size: 16, class: "co-select__icon" }), ((_a = this.selectedOption) === null || _a === void 0 ? void 0 : _a.image) && (h("img", { key: 'b7d067c82372fb525132a1079332aac6fd7e77d5', class: "co-select__flag", src: this.selectedOption.image, alt: "" })), this.multiple && this.hasValue ? (h("div", { class: "co-select__chips" }, this.selectedValues.map((v) => {
|
|
232
479
|
const opt = this.parsedOptions.find((o) => o.value === v);
|
|
233
480
|
return (h("span", { class: "co-select__chip", key: v }, h("span", { class: "co-select__chip-label" }, opt ? opt.label : v), h("button", { class: "co-select__chip-remove", type: "button", tabIndex: -1, "aria-label": "Remove", onClick: (e) => {
|
|
234
481
|
e.stopPropagation();
|
|
235
482
|
this.handleOptionClick(v);
|
|
236
483
|
} }, h("co-icon", { name: "x", size: 12 }))));
|
|
237
|
-
}))) : (h("span", { class: { 'co-select__text': true, 'co-select__text--placeholder': !this.hasValue } }, this.hasValue ? this.displayText : this.placeholder)), this.clearable && this.hasValue && !this.disabled && (h("button", { key: '
|
|
484
|
+
}))) : (h("span", { class: { 'co-select__text': true, 'co-select__text--placeholder': !this.hasValue } }, this.hasValue ? this.displayText : this.placeholder)), this.clearable && this.hasValue && !this.disabled && (h("button", { key: 'e9444409fcba6b16d6ff520b3c2632456d2604a2', class: "co-select__clear", type: "button", tabIndex: -1, onClick: this.handleClear, "aria-label": "Clear" }, h("co-icon", { key: '34df04cf14b9e7c56f7244a00263c2182094b61c', name: "x-circle", size: 16, weight: "fill" }))), h("co-icon", { key: 'f9c02e5d08b8ffb30cd8ef8d5ca6c30fa5d21280', name: this.isOpen ? 'caret-up' : 'caret-down', size: 16, class: "co-select__caret" })), h("div", { key: 'cdd17b6eef07e54ce1d8cdd2b48d055f18c24d9e', class: "co-select__dropdown" }, this.isOpen && this.searchable && (h("div", { key: '743f19477657f1cfadbf1e8c9ddba9fa1dc439b8', class: "co-select__search" }, h("co-icon", { key: 'd7e2518a33ad48306041c8f85994c446960718e1', name: "magnifying-glass", size: 16, class: "co-select__search-icon" }), h("input", { key: '4e928b2bb41fac16e410c42217629ede0441e335', class: "co-select__search-input", type: "text", placeholder: this.searchPlaceholder, value: this.searchText, "aria-controls": CoSelect.LISTBOX_ID, "aria-activedescendant": activeOptionId, onInput: this.handleSearchInput, onKeyDown: this.handleNavKeyDown, ref: (el) => (this.searchInputEl = el) }))), this.isOpen && this.searchable && options.length === 0 && (h("div", { key: '27a8c9cd56b398f6e8f9c0cc66dee5ee8df3b9ed', class: "co-select__empty" }, this.emptyText)), h("div", { key: 'b6275f538ac6b92d3ee3c7f40dfcdd8468ce6d98', class: "co-select__options", id: CoSelect.LISTBOX_ID, role: "listbox", "aria-multiselectable": this.multiple ? 'true' : undefined, ref: (el) => (this.optionsContainerEl = el) }, this.isOpen && (() => {
|
|
238
485
|
const { totalHeight, startIdx, endIdx, offsetY } = this.getVirtualSlice(options);
|
|
239
|
-
return (
|
|
486
|
+
return (
|
|
487
|
+
// Los wrappers del virtualizador van `presentation` para que las
|
|
488
|
+
// opciones sigan siendo hijas del listbox en el árbol de a11y.
|
|
489
|
+
h("div", { role: "presentation", class: "co-select__virtual-spacer", style: { height: `${totalHeight}px`, position: 'relative' } }, h("div", { role: "presentation", style: { position: 'absolute', top: `${offsetY}px`, left: '0', right: '0' } }, options.slice(startIdx, endIdx).map((opt, i) => {
|
|
490
|
+
const index = startIdx + i;
|
|
240
491
|
const isSelected = selected.includes(opt.value);
|
|
241
492
|
const isDisabled = !!opt.disabled;
|
|
242
|
-
return (h("div", { class: {
|
|
493
|
+
return (h("div", { id: this.optionId(index), role: "option", "aria-selected": isSelected ? 'true' : 'false', "aria-disabled": isDisabled ? 'true' : undefined, "aria-setsize": options.length, "aria-posinset": index + 1, class: {
|
|
243
494
|
'co-select__option': true,
|
|
244
495
|
'co-select__option--selected': isSelected,
|
|
245
496
|
'co-select__option--disabled': isDisabled,
|
|
497
|
+
'co-select__option--active': index === this.activeIndex,
|
|
246
498
|
}, onClick: () => !isDisabled && this.handleOptionClick(opt.value) }, opt.image ? (h("img", { class: "co-select__option-flag", src: opt.image, alt: "", loading: "lazy" })) : opt.icon ? (h("co-icon", { name: opt.icon, size: 20, class: "co-select__option-icon" })) : null, h("span", { class: "co-select__option-label" }, this.renderLabel(opt.label)), isSelected && h("co-icon", { name: "check", size: 16, class: "co-select__option-check" })));
|
|
247
499
|
}))));
|
|
248
|
-
})()), this.isOpen && this.showFooter && (h("co-list-footer", { key: '
|
|
500
|
+
})()), this.isOpen && this.showFooter && (h("co-list-footer", { key: 'c149c3f4f7b530c29b01f793a47a07b1a1d0987e', class: "co-select__footer", primaryLabel: this.footerPrimaryLabel, primaryIcon: "check", onCoPrimary: this.handleFooterPrimary })))), this.helperText && (h("div", { key: '3b803c16df5f825c240b8c48a4d5377b85fa1b23', class: `co-select__helper co-select__helper--${this.status}` }, this.statusIcon && h("co-icon", { key: '5e076fb55ded68c8d2febde25aa1f6ef6fc6e445', name: this.statusIcon, size: 14, class: "co-select__helper-icon" }), h("span", { key: 'eb5d5a290f80869bf4c0eecf1b2eaa6d48145721', class: "co-select__helper-text" }, this.helperText)))));
|
|
249
501
|
}
|
|
250
502
|
static get is() { return "co-select"; }
|
|
251
503
|
static get encapsulation() { return "shadow"; }
|
|
@@ -466,7 +718,7 @@ export class CoSelect {
|
|
|
466
718
|
"references": {
|
|
467
719
|
"SelectOption": {
|
|
468
720
|
"location": "local",
|
|
469
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
721
|
+
"path": "/Users/agox/worktrees/cobalt-rel-095/packages/core/src/components/co-select/co-select.tsx",
|
|
470
722
|
"id": "src/components/co-select/co-select.tsx::SelectOption"
|
|
471
723
|
}
|
|
472
724
|
}
|
|
@@ -670,7 +922,8 @@ export class CoSelect {
|
|
|
670
922
|
"isOpen": {},
|
|
671
923
|
"scrollTop": {},
|
|
672
924
|
"searchText": {},
|
|
673
|
-
"sortSnapshot": {}
|
|
925
|
+
"sortSnapshot": {},
|
|
926
|
+
"activeIndex": {}
|
|
674
927
|
};
|
|
675
928
|
}
|
|
676
929
|
static get events() {
|
|
@@ -732,3 +985,16 @@ export class CoSelect {
|
|
|
732
985
|
CoSelect.ITEM_HEIGHT = 34;
|
|
733
986
|
CoSelect.VIEWPORT_ITEMS = 8;
|
|
734
987
|
CoSelect.OVERSCAN = 3;
|
|
988
|
+
/** Ids del shadow root (únicos por instancia sin sufijos aleatorios).
|
|
989
|
+
* Acá `aria-controls` se emite SIEMPRE (no solo abierto) porque este nodo
|
|
990
|
+
* listbox es permanente en el shadow root — el IDREF nunca cuelga. En
|
|
991
|
+
* co-ref-field/co-combobox/co-color-picker el panel se monta on-demand, así
|
|
992
|
+
* que ahí `aria-controls` va solo con el panel abierto: no unificar en la
|
|
993
|
+
* dirección equivocada. */
|
|
994
|
+
CoSelect.LISTBOX_ID = 'co-select-listbox';
|
|
995
|
+
/** Frames que esperamos a que el panel tenga layout para escribir el scroll.
|
|
996
|
+
* Holgado a propósito (~0.8s a 60Hz): dentro de un co-modal/drawer animado el
|
|
997
|
+
* layout llega tarde y con 12 frames el flush se rendía a mitad de camino —
|
|
998
|
+
* el scroll quedaba clampeado en cualquier parte de la lista en vez de en la
|
|
999
|
+
* opción seleccionada. El loop corta solo al verificar el write o al cerrar. */
|
|
1000
|
+
CoSelect.ACTIVE_SCROLL_MAX_FRAMES = 48;
|
|
@@ -702,7 +702,7 @@ export class CoSidebarNav {
|
|
|
702
702
|
"references": {
|
|
703
703
|
"NavigateDetail": {
|
|
704
704
|
"location": "local",
|
|
705
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
705
|
+
"path": "/Users/agox/worktrees/cobalt-rel-095/packages/core/src/components/co-sidebar-nav/co-sidebar-nav.tsx",
|
|
706
706
|
"id": "src/components/co-sidebar-nav/co-sidebar-nav.tsx::NavigateDetail"
|
|
707
707
|
}
|
|
708
708
|
}
|
|
@@ -180,7 +180,7 @@ export class CoToast {
|
|
|
180
180
|
"references": {
|
|
181
181
|
"CoToastActionsLayout": {
|
|
182
182
|
"location": "local",
|
|
183
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
183
|
+
"path": "/Users/agox/worktrees/cobalt-rel-095/packages/core/src/components/co-toast/co-toast.tsx",
|
|
184
184
|
"id": "src/components/co-toast/co-toast.tsx::CoToastActionsLayout"
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -206,7 +206,7 @@ export class CoToast {
|
|
|
206
206
|
"references": {
|
|
207
207
|
"CoToastVariant": {
|
|
208
208
|
"location": "local",
|
|
209
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
209
|
+
"path": "/Users/agox/worktrees/cobalt-rel-095/packages/core/src/components/co-toast/co-toast.tsx",
|
|
210
210
|
"id": "src/components/co-toast/co-toast.tsx::CoToastVariant"
|
|
211
211
|
}
|
|
212
212
|
}
|
|
@@ -205,7 +205,7 @@ export class CoTransferList {
|
|
|
205
205
|
"references": {
|
|
206
206
|
"TransferOption": {
|
|
207
207
|
"location": "local",
|
|
208
|
-
"path": "/Users/agox/worktrees/cobalt-
|
|
208
|
+
"path": "/Users/agox/worktrees/cobalt-rel-095/packages/core/src/components/co-transfer-list/co-transfer-list.tsx",
|
|
209
209
|
"id": "src/components/co-transfer-list/co-transfer-list.tsx::TransferOption"
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { h } from "@stencil/core";
|
|
2
|
-
export const FieldChip = ({ baseClass, label, modifiers = {}, title, key, onRemove, onChipDblClick }, children) => (h("span", { class: Object.assign({ [baseClass]: true }, modifiers), title: title, key: key, onDblClick: onChipDblClick }, children, h("span", { class: `${baseClass}-label` }, label), onRemove && (h("button", { class: `${baseClass}-remove`, type: "button", tabIndex: -1, onClick: onRemove }, h("co-icon", { name: "x-circle", weight: "fill", size: 16 })))));
|
|
2
|
+
export const FieldChip = ({ baseClass, label, modifiers = {}, style, title, key, onRemove, onChipDblClick }, children) => (h("span", { class: Object.assign({ [baseClass]: true }, modifiers), style: style, title: title, key: key, onDblClick: onChipDblClick }, children, h("span", { class: `${baseClass}-label` }, label), onRemove && (h("button", { class: `${baseClass}-remove`, type: "button", tabIndex: -1, onClick: onRemove }, h("co-icon", { name: "x-circle", weight: "fill", size: 16 })))));
|
|
@@ -16,6 +16,7 @@ const DICT = {
|
|
|
16
16
|
uploadedTitle: 'Archivos subidos',
|
|
17
17
|
removeFile: 'Eliminar archivo',
|
|
18
18
|
copyUrl: 'Copiar enlace',
|
|
19
|
+
downloadFile: 'Descargar',
|
|
19
20
|
copied: 'Copiado',
|
|
20
21
|
dragToReorder: 'Arrastra para reordenar',
|
|
21
22
|
openPreview: 'Abrir vista previa',
|
|
@@ -32,6 +33,7 @@ const DICT = {
|
|
|
32
33
|
uploadedTitle: 'Uploaded files',
|
|
33
34
|
removeFile: 'Remove file',
|
|
34
35
|
copyUrl: 'Copy link',
|
|
36
|
+
downloadFile: 'Download',
|
|
35
37
|
copied: 'Copied',
|
|
36
38
|
dragToReorder: 'Drag to reorder',
|
|
37
39
|
openPreview: 'Open preview',
|
|
@@ -48,6 +50,7 @@ const DICT = {
|
|
|
48
50
|
uploadedTitle: 'Arquivos enviados',
|
|
49
51
|
removeFile: 'Remover arquivo',
|
|
50
52
|
copyUrl: 'Copiar link',
|
|
53
|
+
downloadFile: 'Baixar',
|
|
51
54
|
copied: 'Copiado',
|
|
52
55
|
dragToReorder: 'Arraste para reordenar',
|
|
53
56
|
openPreview: 'Abrir pré-visualização',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as o,p as c,H as e,c as i,h as a}from"./index.js";import{d as t}from"./p-
|
|
1
|
+
import{t as o,p as c,H as e,c as i,h as a}from"./index.js";import{d as t}from"./p-Dj1EZ5qD.js";const n=c(class extends e{constructor(o){super(),!1!==o&&this.__registerHost(),this.__attachShadow(),this.coToggle=i(this,"coToggle",7),this.open=!0,this.heading="",this.subheading="",this.disabled=!1,this.hasSubheadingSlot=!1,this.handleToggle=()=>{this.disabled||(this.open=!this.open,this.coToggle.emit(this.open))}}componentWillLoad(){this.hasSubheadingSlot=!!this.el.querySelector('[slot="subheading"]')}componentWillRender(){this.hasSubheadingSlot=!!this.el.querySelector('[slot="subheading"]')}get showSubheading(){return!(!this.subheading||!this.subheading.trim())||this.hasSubheadingSlot}render(){return a("div",{key:"4e2089349432ce39bb797397aacaebd022fcbcee",class:{"co-accordion":!0,"co-accordion--open":this.open,"co-accordion--disabled":this.disabled},part:"accordion"},a("div",{key:"4337878858bd31822201a925010f3150568fa056",class:"co-accordion__header",part:"header"},a("span",{key:"cf69c69cc786981ca6bd54bd0f6a6c38a3baa0b6",class:"co-accordion__heading-group"},a("span",{key:"0e7efd52e6d48c35ce0270485e8ce6099c6a3302",class:"co-accordion__heading",part:"heading"},a("slot",{key:"b575ce7ae5611007490724f430819f083781f84d",name:"header"},this.heading)),this.showSubheading&&a("span",{key:"996a58f3f3b5cd656849b413b0f998675452cc2f",class:"co-accordion__subheading",part:"subheading"},a("slot",{key:"a9029aa67f51162ad54c010d23bf20545883ef45",name:"subheading"},this.subheading))),a("button",{key:"757286aaf2914fe7d32fc14ab0f5de57ffeab48c",class:"co-accordion__caret",type:"button","aria-expanded":this.open?"true":"false","aria-label":this.heading||"Toggle section",disabled:this.disabled,onClick:this.handleToggle,part:"caret"},a("co-icon",{key:"b4c3c96489a30607727a44955dbff2d504ef2b6e",name:"caret-up",size:20}))),a("div",{key:"bd56b12cbd7484f61fec140740312800536d7b18",class:"co-accordion__body",part:"body"},a("div",{key:"1f2ff56e7bd7a49f8484c988ecdf434d108ef4ed",class:"co-accordion__body-inner",part:"body-inner"},a("slot",{key:"25ef25609ccece786a05709d90a32e7e135fec72"}))))}get el(){return this}static get style(){return":host{display:block}.co-accordion{display:flex;flex-direction:column;width:100%}.co-accordion__header{display:flex;align-items:center;justify-content:space-between;gap:var(--co-spacing-sm, 6px);width:100%;font-family:var(--co-font-family-primary);color:var(--co-semantic-text-default);text-align:left}.co-accordion__heading-group{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--co-spacing-xxs, 2px)}.co-accordion__heading{font-size:var(--co-font-size-24);font-weight:500;line-height:1.25;letter-spacing:-0.03em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.co-accordion__subheading{font-size:var(--co-font-size-14);font-weight:400;line-height:1.3;letter-spacing:normal;color:var(--co-semantic-text-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.co-accordion__caret{flex-shrink:0;display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;padding:0;border:none;background:transparent;border-radius:var(--co-border-radius-full, 9999px);color:var(--co-semantic-text-default);cursor:pointer;transition:transform var(--co-motion-duration-base) var(--co-motion-ease-out), background-color var(--co-motion-duration-fast) var(--co-motion-ease-out);transform:rotate(180deg);}.co-accordion__caret:hover:not(:disabled){background:var(--co-color-opacity-negro-8, rgba(31, 28, 27, 0.08))}.co-accordion--open .co-accordion__caret{transform:rotate(0deg);}.co-accordion__body{display:grid;grid-template-rows:0fr;transition:grid-template-rows var(--co-motion-duration-slow) var(--co-motion-ease-out)}.co-accordion__body-inner{min-height:0;overflow:hidden;padding-top:var(--co-spacing-2xl);transition:padding-top var(--co-motion-duration-slow) var(--co-motion-ease-out)}.co-accordion:not(.co-accordion--open) .co-accordion__body-inner{padding-top:0}.co-accordion--open .co-accordion__body{grid-template-rows:1fr}.co-accordion:not(.co-accordion--open) .co-accordion__body-inner{visibility:hidden;transition:padding-top var(--co-motion-duration-slow) var(--co-motion-ease-out), visibility 0s linear var(--co-motion-duration-slow)}.co-accordion--open .co-accordion__body-inner{visibility:visible;transition:padding-top var(--co-motion-duration-slow) var(--co-motion-ease-out), visibility 0s linear 0s}.co-accordion__caret:focus-visible{outline:2px solid var(--co-color-primary-azul, #2563eb);outline-offset:2px}.co-accordion--disabled .co-accordion__header{opacity:0.5}.co-accordion--disabled .co-accordion__caret{cursor:not-allowed}"}},[257,"co-accordion",{open:[1540],heading:[1],subheading:[1],disabled:[4],hasSubheadingSlot:[32]}]);function r(){"undefined"!=typeof customElements&&["co-accordion","co-icon"].forEach((c=>{switch(c){case"co-accordion":customElements.get(o(c))||customElements.define(o(c),n);break;case"co-icon":customElements.get(o(c))||t()}}))}r();const d=n,s=r;export{d as CoAccordion,s as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as a,p as i,H as o,c as t,h as e}from"./index.js";import{d as n}from"./p-
|
|
1
|
+
import{t as a,p as i,H as o,c as t,h as e}from"./index.js";import{d as n}from"./p-Dj1EZ5qD.js";import{d as s}from"./p-DgUBcJIS.js";const c=i(class extends o{constructor(a){super(),!1!==a&&this.__registerHost(),this.__attachShadow(),this.coDismiss=t(this,"coDismiss",7),this.open=!1,this.dismissible=!0,this.position="none",this.liveText="",this.animated=!1,this.handleDismiss=()=>{this.coDismiss.emit()}}onLabelChange(a){void 0!==this.liveTimer&&clearTimeout(this.liveTimer),this.liveTimer=setTimeout((()=>{this.liveTimer=void 0,this.liveText=null!=a?a:""}),600)}componentWillLoad(){var a;this.liveText=null!==(a=this.label)&&void 0!==a?a:""}componentDidLoad(){const a=()=>this.animated=!0;"function"==typeof requestAnimationFrame?this.rafId=requestAnimationFrame(a):a()}disconnectedCallback(){void 0!==this.liveTimer&&(clearTimeout(this.liveTimer),this.liveTimer=void 0),void 0!==this.rafId&&"function"==typeof cancelAnimationFrame&&(cancelAnimationFrame(this.rafId),this.rafId=void 0)}render(){return e("div",{key:"c350ea38a12157a5cefe26f303ef7100938d55c9",class:{"co-action-bar":!0,"co-action-bar--open":this.open,"co-action-bar--animated":this.animated},part:"bar",role:"group","aria-label":this.ariaLabelText||this.label,"aria-hidden":this.open?null:"true"},e("span",{key:"9f2d3d5729fd150e5aa0c487067c7c8ad6cd8b59",class:"co-action-bar__live","aria-live":"polite"},this.liveText),e("span",{key:"d2617507df8f2b48a743c1bb20482d9cc2e227df",class:"co-action-bar__label",part:"label"},e("slot",{key:"aad415247f017bd8ea38e38f84a0cd768a2f6f38",name:"label"},this.label)),e("div",{key:"8999cd574e430246824effda0bfa531d62a3530a",class:"co-action-bar__actions",part:"actions"},e("slot",{key:"f06636fd076da38bc07982637f7def5d75df733e"})),!1!==this.dismissible&&e("co-icon-button",{key:"4227fa464073430c67190ac4afc6c6534b627934",class:"co-action-bar__dismiss",part:"dismiss",icon:"x",variant:"ghost",surface:"dark",size:"xs",label:"Dismiss",onClick:this.handleDismiss}))}static get watchers(){return{label:[{onLabelChange:0}]}}static get style(){return":host{display:inline-flex;font-family:var(--co-font-family-primary);pointer-events:none}:host([position='bottom-center']){position:fixed;left:50%;transform:translateX(-50%);bottom:var(--co-action-bar-offset, 24px);z-index:var(--co-action-bar-z, 1000);max-width:calc(100vw - 2 * var(--co-action-bar-inline-margin, 24px))}.co-action-bar{position:relative;display:flex;align-items:center;box-sizing:border-box;max-width:100%;gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-md) var(--co-spacing-sm2) var(--co-spacing-lg);border-radius:var(--co-border-radius-lg);background:var(--co-semantic-surface-primary);color:var(--co-semantic-text-inverse);box-shadow:var(--co-shadow-lg);opacity:0;transform:translateY(8px);pointer-events:none;visibility:hidden}.co-action-bar--open{opacity:1;transform:translateY(0);pointer-events:auto;visibility:visible}.co-action-bar--animated{transition:opacity var(--co-motion-duration-base) var(--co-motion-ease-out), transform var(--co-motion-duration-base) var(--co-motion-ease-out), visibility 0s linear var(--co-motion-duration-base)}.co-action-bar--animated.co-action-bar--open{transition:opacity var(--co-motion-duration-base) var(--co-motion-ease-out), transform var(--co-motion-duration-base) var(--co-motion-ease-out), visibility 0s}.co-action-bar__label{font-size:var(--co-font-size-14);font-weight:500;letter-spacing:var(--co-font-letter-spacing-body);line-height:1;white-space:nowrap;flex-shrink:0;padding-right:var(--co-spacing-xs)}.co-action-bar__actions{display:flex;align-items:center;gap:var(--co-spacing-xs);min-width:0}::slotted(hr){width:1px;height:24px;flex-shrink:0;align-self:center;margin:0 var(--co-spacing-xs);border:none;padding:0;background:color-mix(in srgb, var(--co-color-base-blanco, #fff) 28%, transparent)}.co-action-bar__dismiss{flex-shrink:0}.co-action-bar__live{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap}"}},[257,"co-action-bar",{open:[516],label:[1],dismissible:[4],position:[513],ariaLabelText:[1,"aria-label-text"],liveText:[32],animated:[32]},void 0,{label:[{onLabelChange:0}]}]);function r(){"undefined"!=typeof customElements&&["co-action-bar","co-icon","co-icon-button"].forEach((i=>{switch(i){case"co-action-bar":customElements.get(a(i))||customElements.define(a(i),c);break;case"co-icon":customElements.get(a(i))||n();break;case"co-icon-button":customElements.get(a(i))||s()}}))}r();const l=c,d=r;export{l as CoActionBar,d as defineCustomElement}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t,p as i,H as a,c as e,h as s}from"./index.js";import{d as o}from"./p-Q6caHt79.js";function r(t){const i=Math.max(0,Math.floor(t||0));return`${Math.floor(i/60)}:${(""+i%60).padStart(2,"0")}`}function c(t,i){const a=t.length;if(!a||i<=0)return[];const e=Math.max(1,Math.floor(a/i)),s=[];for(let o=0;o<i;o++){let i=0;const r=o*e;for(let s=r;s<r+e&&s<a;s++){const a=Math.abs(t[s]);a>i&&(i=a)}s.push(.12+.88*i)}return s}function h(t){if(t<=0)return[];const i=[];for(let a=0;a<t;a++)i.push(.12+(.6*Math.sin(a/Math.max(1,t)*Math.PI)+.3)*(.75+.25*Math.abs(Math.sin(1.7*a)))*.88);return i}const n=i(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.coPlay=e(this,"coPlay",7),this.coPause=e(this,"coPause",7),this.coEnded=e(this,"coEnded",7),this.coError=e(this,"coError",7),this.compact=!1,this.bars=64,this.barDensity=3,this.preload="metadata",this.downloadFilename="audio",this.noDownload=!1,this.isPlaying=!1,this.isLoading=!1,this.hasError=!1,this.currentTime=0,this.duration=0,this.peaks=[],this.containerWidth=0,this.playbackRate=1,this.rawChannelData=null,this.onMeta=()=>{var t;this.duration=(null===(t=this.audio)||void 0===t?void 0:t.duration)||0},this.onCanPlay=()=>{this.isLoading=!1},this.onWaiting=()=>{this.isLoading=!0},this.onTime=()=>{var t;this.currentTime=(null===(t=this.audio)||void 0===t?void 0:t.currentTime)||0},this.onEnded=()=>{this.isPlaying=!1,this.currentTime=0,this.coEnded.emit()},this.onErr=t=>{this.isLoading=!1,this.hasError=!0,this.coError.emit(t)},this.toggle=()=>{this.audio&&!this.hasError&&(this.isPlaying?(this.audio.pause(),this.isPlaying=!1,this.coPause.emit()):this.audio.play().then((()=>{this.isPlaying=!0,this.coPlay.emit()})).catch((()=>{})))},this.SPEEDS=[1,1.5,2,.5],this.cycleSpeed=()=>{const t=this.SPEEDS.indexOf(this.playbackRate);this.playbackRate=this.SPEEDS[(t+1)%this.SPEEDS.length],this.audio&&(this.audio.playbackRate=this.playbackRate)},this.seekAt=t=>{if(!this.audio||!this.waveEl||!this.duration)return;const i=function(t,i){return i.width?Math.max(0,Math.min(1,(t-i.left)/i.width)):0}(t,this.waveEl.getBoundingClientRect());this.audio.currentTime=i*this.duration,this.currentTime=this.audio.currentTime},this.onWaveKey=t=>{if(" "===t.key||"Enter"===t.key)return t.preventDefault(),void this.toggle();if(this.audio&&this.duration){if("ArrowRight"===t.key)this.audio.currentTime=Math.min(this.duration,this.audio.currentTime+5);else{if("ArrowLeft"!==t.key)return;this.audio.currentTime=Math.max(0,this.audio.currentTime-5)}this.currentTime=this.audio.currentTime}}}get effectiveBars(){return this.containerWidth>0?Math.max(24,Math.floor(this.containerWidth/this.barDensity)):this.bars}componentWillLoad(){this.init()}componentDidLoad(){if("undefined"==typeof ResizeObserver||!this.waveEl)return;this.resizeObserver=new ResizeObserver((t=>{var i;for(const a of t){const t=(null===(i=a.contentRect)||void 0===i?void 0:i.width)||a.target.clientWidth||0;t>2&&Math.abs(t-this.containerWidth)>2&&(this.containerWidth=t,this.rebuildBars())}})),this.resizeObserver.observe(this.waveEl);const t=this.waveEl.clientWidth||0;t>2&&(this.containerWidth=t,this.rebuildBars())}disconnectedCallback(){var t;this.teardown(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0}onSrcChange(){this.init()}rebuildBars(){this.peaks=this.rawChannelData?c(this.rawChannelData,this.effectiveBars):h(this.effectiveBars)}init(){if(this.teardown(),this.rawChannelData=null,this.peaks=h(this.effectiveBars),this.currentTime=0,this.duration=0,this.playbackRate=1,this.hasError=!1,!this.src)return;if(this.isLoading=!0,this.extractPeaks(this.src),"undefined"==typeof Audio)return;const t=new Audio;t.preload=this.preload,t.crossOrigin="anonymous",t.src=this.src,t.addEventListener("loadedmetadata",this.onMeta),t.addEventListener("timeupdate",this.onTime),t.addEventListener("ended",this.onEnded),t.addEventListener("error",this.onErr),t.addEventListener("canplay",this.onCanPlay),t.addEventListener("waiting",this.onWaiting),this.audio=t}teardown(){this.audio&&(this.audio.pause(),this.audio.removeEventListener("loadedmetadata",this.onMeta),this.audio.removeEventListener("timeupdate",this.onTime),this.audio.removeEventListener("ended",this.onEnded),this.audio.removeEventListener("error",this.onErr),this.audio.removeEventListener("canplay",this.onCanPlay),this.audio.removeEventListener("waiting",this.onWaiting),this.audio.src="",this.audio=void 0),this.isPlaying=!1}async extractPeaks(t){try{const i=window.AudioContext||window.webkitAudioContext;if(!i||"undefined"==typeof fetch)return;const a=new i,e=await(await fetch(t)).arrayBuffer(),s=await a.decodeAudioData(e);this.rawChannelData=s.getChannelData(0),this.peaks=c(this.rawChannelData,this.effectiveBars),a.close()}catch(t){this.rawChannelData=null,this.peaks=h(this.effectiveBars)}}async download(){if(this.src&&"undefined"!=typeof fetch)try{const t=await(await fetch(this.src)).blob(),i=URL.createObjectURL(t),a=document.createElement("a");a.href=i,a.download=this.downloadFilename,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}catch(t){}}render(){const t=Math.max(1,3*this.peaks.length),i=this.duration?this.currentTime/this.duration*100:0,a=(t,i,a=!1)=>s("rect",{key:"ffe5ce97626e52c12e60b953b62d237f14acb582",x:3*i,y:20-40*t/2,width:1.8,height:Math.max(40*t,2),rx:.6,class:{"co-audio-player__bar":!0,"co-audio-player__bar--played":a}});return s("div",{key:"012710aded6ca183e80d7fde087cb0fdf413249b",class:{"co-audio-player":!0,"co-audio-player--compact":this.compact,"co-audio-player--error":this.hasError,"co-audio-player--playing":this.isPlaying},part:"player"},s("button",{key:"2505b88e97e73fd39aa31e3dad5e7fe0c1b94c80",type:"button",class:"co-audio-player__play",part:"play","aria-label":this.hasError?"Audio no disponible":this.isPlaying?"Pausar":"Reproducir","aria-busy":this.isLoading?"true":"false",disabled:this.hasError||!this.src,onClick:this.toggle},s("co-icon",{key:"e0e0d2dd5f6e0578ba80a3c235e5c221a6e8fe21",name:this.hasError?"warning-circle":this.isPlaying?"pause":"play",weight:"fill",size:this.compact?12:14})),s("div",{key:"d2b32119c69c64d2f68d469fe4ae056780446322",class:"co-audio-player__wave",part:"wave",role:"slider",tabindex:"0","aria-label":"Progreso de reproducción","aria-valuemin":0,"aria-valuemax":Math.floor(this.duration),"aria-valuenow":Math.floor(this.currentTime),ref:t=>this.waveEl=t,onClick:t=>this.seekAt(t.clientX),onKeyDown:this.onWaveKey},s("svg",{key:"fb9643df152d2d0b119580954f639cb3a9c2cd66",class:"co-audio-player__svg",viewBox:`0 0 ${t} 40`,preserveAspectRatio:"none","aria-hidden":"true"},this.peaks.map(((t,i)=>a(t,i))),s("clipPath",{key:"c2901cfe7c7e910bd53c8c92894b2d2395cde270",id:"co-ap-clip"},s("rect",{key:"8129a85201e09ba6646b08ed0075798b0a0b0dfc",x:"0",y:"0",width:i/100*t,height:40})),s("g",{key:"69bc1780122d48f1a545d1c59bf7ed6536285ed2","clip-path":"url(#co-ap-clip)"},this.peaks.map(((t,i)=>a(t,i,!0)))))),s("span",{key:"3747622619bd81545f85e7eb2f9c19b1aca6e7c2",class:"co-audio-player__time",part:"time"},r(this.currentTime)," / ",r(this.duration)),!this.compact&&s("button",{key:"84341856fb2e0b6a094c673a727370b148190e30",type:"button",class:"co-audio-player__speed",part:"speed","aria-label":`Velocidad de reproducción ${this.playbackRate}x`,onClick:this.cycleSpeed},this.playbackRate,"x"),!this.compact&&!this.noDownload&&s("button",{key:"d6767d185317f20299b40c4050a806d88165682f",type:"button",class:"co-audio-player__dl",part:"download","aria-label":"Descargar",onClick:()=>this.download()},s("co-icon",{key:"a0f0a09cdf705ecf15e0156cf93011f89f41ffa5",name:"download-simple",size:14})))}static get watchers(){return{src:[{onSrcChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary)}.co-audio-player{display:flex;align-items:center;gap:var(--co-spacing-md);padding:var(--co-spacing-sm) var(--co-spacing-md);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);background:var(--co-semantic-surface-secondary);min-width:180px}.co-audio-player--compact{gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-sm);min-width:140px}.co-audio-player__play{flex:0 0 auto;width:28px;height:28px;border:none;border-radius:50%;cursor:pointer;background:var(--co-semantic-surface-primary);color:var(--co-semantic-text-inverse);display:inline-flex;align-items:center;justify-content:center}.co-audio-player--compact .co-audio-player__play{width:24px;height:24px}.co-audio-player__play:disabled{opacity:.5;cursor:not-allowed}.co-audio-player__play:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player__wave{flex:1;height:40px;min-width:0;cursor:pointer;display:flex;align-items:center}.co-audio-player__wave:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__svg{width:100%;height:100%;display:block}.co-audio-player__bar{fill:var(--co-semantic-border-field);transition:fill var(--co-motion-duration-fast)}.co-audio-player__wave:hover .co-audio-player__bar{fill:var(--co-semantic-text-muted)}.co-audio-player__bar--played{fill:var(--co-semantic-surface-primary)}.co-audio-player__time{flex:0 0 auto;font-size:var(--co-font-size-12);color:var(--co-semantic-text-muted);font-variant-numeric:tabular-nums;min-width:62px;text-align:right}.co-audio-player__speed{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px 4px;color:var(--co-semantic-text-muted);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12);font-variant-numeric:tabular-nums;min-width:34px;text-align:center}.co-audio-player__speed:hover{color:var(--co-semantic-text-default)}.co-audio-player__speed:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__dl{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px;color:var(--co-semantic-text-muted);display:inline-flex}.co-audio-player__dl:hover{color:var(--co-semantic-text-default)}.co-audio-player__dl:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player--error .co-audio-player__wave{opacity:.5}.co-audio-player--error .co-audio-player__play{background:var(--co-color-status-error);color:var(--co-semantic-text-inverse);opacity:1}"}},[1,"co-audio-player",{src:[1],compact:[4],bars:[2],barDensity:[2,"bar-density"],preload:[1],downloadFilename:[1,"download-filename"],noDownload:[4,"no-download"],isPlaying:[32],isLoading:[32],hasError:[32],currentTime:[32],duration:[32],peaks:[32],containerWidth:[32],playbackRate:[32]},void 0,{src:[{onSrcChange:0}]}]);function d(){"undefined"!=typeof customElements&&["co-audio-player","co-icon"].forEach((i=>{switch(i){case"co-audio-player":customElements.get(t(i))||customElements.define(t(i),n);break;case"co-icon":customElements.get(t(i))||o()}}))}d();const l=n,u=d;export{l as CoAudioPlayer,u as defineCustomElement}
|
|
1
|
+
import{t,p as i,H as a,c as e,h as s}from"./index.js";import{d as o}from"./p-Dj1EZ5qD.js";function r(t){if(!Number.isFinite(t)||t<0)return"--:--";const i=Math.floor(t);return`${Math.floor(i/60)}:${(""+i%60).padStart(2,"0")}`}function c(t,i){const a=t.length;if(!a||i<=0)return[];const e=Math.max(1,Math.floor(a/i)),s=[];for(let o=0;o<i;o++){let i=0;const r=o*e;for(let s=r;s<r+e&&s<a;s++){const a=Math.abs(t[s]);a>i&&(i=a)}s.push(.12+.88*i)}return s}function n(t){if(t<=0)return[];const i=[];for(let a=0;a<t;a++)i.push(.12+(.6*Math.sin(a/Math.max(1,t)*Math.PI)+.3)*(.75+.25*Math.abs(Math.sin(1.7*a)))*.88);return i}const h=i(class extends a{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow(),this.coPlay=e(this,"coPlay",7),this.coPause=e(this,"coPause",7),this.coEnded=e(this,"coEnded",7),this.coError=e(this,"coError",7),this.compact=!1,this.bars=64,this.barDensity=3,this.preload="metadata",this.downloadFilename="audio",this.noDownload=!1,this.isPlaying=!1,this.isLoading=!1,this.hasError=!1,this.currentTime=0,this.duration=NaN,this.peaks=[],this.containerWidth=0,this.playbackRate=1,this.rawChannelData=null,this.decodedDuration=NaN,this.loadToken=0,this.onMeta=()=>{this.syncDuration()},this.onCanPlay=()=>{this.isLoading=!1},this.onWaiting=()=>{this.isLoading=!0},this.onTime=()=>{var t;this.currentTime=(null===(t=this.audio)||void 0===t?void 0:t.currentTime)||0},this.onEnded=()=>{this.isPlaying=!1,this.currentTime=0,this.coEnded.emit()},this.onErr=t=>{this.isLoading=!1,this.hasError=!0,this.coError.emit(t)},this.toggle=()=>{this.audio&&!this.hasError&&(this.isPlaying?(this.audio.pause(),this.isPlaying=!1,this.coPause.emit()):this.audio.play().then((()=>{this.isPlaying=!0,this.coPlay.emit()})).catch((()=>{})))},this.SPEEDS=[1,1.5,2,.5],this.cycleSpeed=()=>{const t=this.SPEEDS.indexOf(this.playbackRate);this.playbackRate=this.SPEEDS[(t+1)%this.SPEEDS.length],this.audio&&(this.audio.playbackRate=this.playbackRate)},this.seekAt=t=>{const i=this.knownDuration;if(!this.audio||!this.waveEl||!i)return;const a=function(t,i){return i.width?Math.max(0,Math.min(1,(t-i.left)/i.width)):0}(t,this.waveEl.getBoundingClientRect());this.audio.currentTime=a*i,this.currentTime=this.audio.currentTime},this.onWaveKey=t=>{if(" "===t.key||"Enter"===t.key)return t.preventDefault(),void this.toggle();if(!this.audio)return;const i=this.knownDuration,a=this.audio.currentTime;if("ArrowRight"===t.key)this.audio.currentTime=i?Math.min(i,a+5):a+5;else{if("ArrowLeft"!==t.key)return;this.audio.currentTime=Math.max(0,a-5)}this.currentTime=this.audio.currentTime}}get knownDuration(){return Number.isFinite(this.duration)&&this.duration>0?this.duration:0}get effectiveBars(){return this.containerWidth>0?Math.max(24,Math.floor(this.containerWidth/this.barDensity)):this.bars}componentWillLoad(){this.init()}componentDidLoad(){if("undefined"==typeof ResizeObserver||!this.waveEl)return;this.resizeObserver=new ResizeObserver((t=>{var i;for(const a of t){const t=(null===(i=a.contentRect)||void 0===i?void 0:i.width)||a.target.clientWidth||0;t>2&&Math.abs(t-this.containerWidth)>2&&(this.containerWidth=t,this.rebuildBars())}})),this.resizeObserver.observe(this.waveEl);const t=this.waveEl.clientWidth||0;t>2&&(this.containerWidth=t,this.rebuildBars())}disconnectedCallback(){var t;this.loadToken++,this.teardown(),null===(t=this.resizeObserver)||void 0===t||t.disconnect(),this.resizeObserver=void 0}onSrcChange(){this.init()}rebuildBars(){this.peaks=this.rawChannelData?c(this.rawChannelData,this.effectiveBars):n(this.effectiveBars)}init(){this.teardown();const t=++this.loadToken;if(this.rawChannelData=null,this.decodedDuration=NaN,this.peaks=n(this.effectiveBars),this.currentTime=0,this.duration=NaN,this.playbackRate=1,this.hasError=!1,!this.src)return;if(this.isLoading=!0,this.extractPeaks(this.src,t),"undefined"==typeof Audio)return;const i=new Audio;i.preload=this.preload,i.crossOrigin="anonymous",i.src=this.src,i.addEventListener("loadedmetadata",this.onMeta),i.addEventListener("timeupdate",this.onTime),i.addEventListener("ended",this.onEnded),i.addEventListener("error",this.onErr),i.addEventListener("canplay",this.onCanPlay),i.addEventListener("waiting",this.onWaiting),this.audio=i}teardown(){this.audio&&(this.audio.pause(),this.audio.removeEventListener("loadedmetadata",this.onMeta),this.audio.removeEventListener("timeupdate",this.onTime),this.audio.removeEventListener("ended",this.onEnded),this.audio.removeEventListener("error",this.onErr),this.audio.removeEventListener("canplay",this.onCanPlay),this.audio.removeEventListener("waiting",this.onWaiting),this.audio.src="",this.audio=void 0),this.isPlaying=!1}async extractPeaks(t,i){let a;try{const e=window.AudioContext||window.webkitAudioContext;if(!e||"undefined"==typeof fetch)return;a=new e;const s=await(await fetch(t)).arrayBuffer(),o=await a.decodeAudioData(s);if(i!==this.loadToken)return;this.rawChannelData=o.getChannelData(0),this.decodedDuration=o.duration,this.peaks=c(this.rawChannelData,this.effectiveBars)}catch(t){if(i!==this.loadToken)return;this.rawChannelData=null,this.decodedDuration=NaN,this.peaks=n(this.effectiveBars)}finally{try{await(null==a?void 0:a.close())}catch(t){}}i===this.loadToken&&this.syncDuration()}syncDuration(){var t,i;const a=function(t,i){return Number.isFinite(t)&&t>0?t:Number.isFinite(i)&&i>0?i:NaN}(null!==(i=null===(t=this.audio)||void 0===t?void 0:t.duration)&&void 0!==i?i:NaN,this.decodedDuration);Object.is(a,this.duration)||(this.duration=a)}async download(){if(this.src&&"undefined"!=typeof fetch)try{const t=await(await fetch(this.src)).blob(),i=URL.createObjectURL(t),a=document.createElement("a");a.href=i,a.download=this.downloadFilename,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}catch(t){}}render(){const t=Math.max(1,3*this.peaks.length),i=this.knownDuration,a=i?this.currentTime/i*100:0,e=i?Math.floor(i):void 0,o=(t,i,a=!1)=>s("rect",{key:"997dcefc32f5188c41afa0a7b5135c70cceeed1d",x:3*i,y:20-40*t/2,width:1.8,height:Math.max(40*t,2),rx:.6,class:{"co-audio-player__bar":!0,"co-audio-player__bar--played":a}});return s("div",{key:"8ac91ab3f8eb417df5e7cf4d1e016d6ca7eb45a3",class:{"co-audio-player":!0,"co-audio-player--compact":this.compact,"co-audio-player--error":this.hasError,"co-audio-player--playing":this.isPlaying},part:"player"},s("button",{key:"0e5897dc64c91ee67432f17d7b0d57a27f44cd0e",type:"button",class:"co-audio-player__play",part:"play","aria-label":this.hasError?"Audio no disponible":this.isPlaying?"Pausar":"Reproducir","aria-busy":this.isLoading?"true":"false",disabled:this.hasError||!this.src,onClick:this.toggle},s("co-icon",{key:"4843751a2a3709942a49ae03ff9ba0eb08ab7d97",name:this.hasError?"warning-circle":this.isPlaying?"pause":"play",weight:"fill",size:this.compact?12:14})),s("div",{key:"b7aebd0e0c5197b0dec6257bbec7c9dd8dd55d6f",class:"co-audio-player__wave",part:"wave",role:"slider",tabindex:"0","aria-label":"Progreso de reproducción","aria-valuemin":0,"aria-valuemax":e,"aria-valuenow":Math.floor(this.currentTime),ref:t=>this.waveEl=t,onClick:t=>this.seekAt(t.clientX),onKeyDown:this.onWaveKey},s("svg",{key:"a504d058a27bb33dd57733ec32db306eb0ed87e9",class:"co-audio-player__svg",viewBox:`0 0 ${t} 40`,preserveAspectRatio:"none","aria-hidden":"true"},this.peaks.map(((t,i)=>o(t,i))),s("clipPath",{key:"9cfa69ba28801893baf62c8f66b18a31319fdebe",id:"co-ap-clip"},s("rect",{key:"6e5cb34baeb2b7dddd6ef7e94f8585ef912e0315",x:"0",y:"0",width:a/100*t,height:40})),s("g",{key:"4b78a29dde762cabc85d7921aacbcd261d8fa6b5","clip-path":"url(#co-ap-clip)"},this.peaks.map(((t,i)=>o(t,i,!0)))))),s("span",{key:"9067d22b0e2994e46ef49c60356292ec59f61a21",class:"co-audio-player__time",part:"time"},r(this.currentTime)," / ",r(this.duration)),!this.compact&&s("button",{key:"f6149a9996e6ce15230221c2f6fcec95fec5f485",type:"button",class:"co-audio-player__speed",part:"speed","aria-label":`Velocidad de reproducción ${this.playbackRate}x`,onClick:this.cycleSpeed},this.playbackRate,"x"),!this.compact&&!this.noDownload&&s("button",{key:"73d291d31d92bcb0e18e230fe0ac35d3ab4077b2",type:"button",class:"co-audio-player__dl",part:"download","aria-label":"Descargar",onClick:()=>this.download()},s("co-icon",{key:"9ab09f5d6b975f4f5544019f70bd2ca1ee521068",name:"download-simple",size:14})))}static get watchers(){return{src:[{onSrcChange:0}]}}static get style(){return":host{display:block;font-family:var(--co-font-family-primary)}.co-audio-player{display:flex;align-items:center;gap:var(--co-spacing-md);padding:var(--co-spacing-sm) var(--co-spacing-md);border:1px solid var(--co-semantic-border-default);border-radius:var(--co-border-radius-xs);background:var(--co-semantic-surface-secondary);min-width:180px}.co-audio-player--compact{gap:var(--co-spacing-sm2);padding:var(--co-spacing-sm2) var(--co-spacing-sm);min-width:140px}.co-audio-player__play{flex:0 0 auto;width:28px;height:28px;border:none;border-radius:50%;cursor:pointer;background:var(--co-semantic-surface-primary);color:var(--co-semantic-text-inverse);display:inline-flex;align-items:center;justify-content:center}.co-audio-player--compact .co-audio-player__play{width:24px;height:24px}.co-audio-player__play:disabled{opacity:.5;cursor:not-allowed}.co-audio-player__play:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player__wave{flex:1;height:40px;min-width:0;cursor:pointer;display:flex;align-items:center}.co-audio-player__wave:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__svg{width:100%;height:100%;display:block}.co-audio-player__bar{fill:var(--co-semantic-border-field);transition:fill var(--co-motion-duration-fast)}.co-audio-player__wave:hover .co-audio-player__bar{fill:var(--co-semantic-text-muted)}.co-audio-player__bar--played{fill:var(--co-semantic-surface-primary)}.co-audio-player__time{flex:0 0 auto;font-size:var(--co-font-size-12);color:var(--co-semantic-text-muted);font-variant-numeric:tabular-nums;min-width:62px;text-align:right}.co-audio-player__speed{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px 4px;color:var(--co-semantic-text-muted);font-family:var(--co-font-family-primary);font-size:var(--co-font-size-12);font-variant-numeric:tabular-nums;min-width:34px;text-align:center}.co-audio-player__speed:hover{color:var(--co-semantic-text-default)}.co-audio-player__speed:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px;border-radius:var(--co-border-radius-xxs)}.co-audio-player__dl{flex:0 0 auto;border:none;background:transparent;cursor:pointer;padding:2px;color:var(--co-semantic-text-muted);display:inline-flex}.co-audio-player__dl:hover{color:var(--co-semantic-text-default)}.co-audio-player__dl:focus-visible{outline:2px solid var(--co-semantic-border-focus);outline-offset:2px}.co-audio-player--error .co-audio-player__wave{opacity:.5}.co-audio-player--error .co-audio-player__play{background:var(--co-color-status-error);color:var(--co-semantic-text-inverse);opacity:1}"}},[1,"co-audio-player",{src:[1],compact:[4],bars:[2],barDensity:[2,"bar-density"],preload:[1],downloadFilename:[1,"download-filename"],noDownload:[4,"no-download"],isPlaying:[32],isLoading:[32],hasError:[32],currentTime:[32],duration:[32],peaks:[32],containerWidth:[32],playbackRate:[32]},void 0,{src:[{onSrcChange:0}]}]);function d(){"undefined"!=typeof customElements&&["co-audio-player","co-icon"].forEach((i=>{switch(i){case"co-audio-player":customElements.get(t(i))||customElements.define(t(i),h);break;case"co-icon":customElements.get(t(i))||o()}}))}d();const l=h,u=d;export{l as CoAudioPlayer,u as defineCustomElement}
|