@caribeng/ui 22.1.0 → 22.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -12
- package/fesm2022/caribeng-ui-accordion.mjs +2 -2
- package/fesm2022/caribeng-ui-anchor.mjs +169 -0
- package/fesm2022/caribeng-ui-autocomplete.mjs +10 -8
- package/fesm2022/caribeng-ui-avatargroup.mjs +9 -3
- package/fesm2022/caribeng-ui-blockui.mjs +12 -4
- package/fesm2022/caribeng-ui-breadcrumb.mjs +5 -2
- package/fesm2022/caribeng-ui-button.mjs +22 -2
- package/fesm2022/caribeng-ui-caribe-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-animation-lottie.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-button-group.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-calendar.mjs +11 -6
- package/fesm2022/caribeng-ui-caribe-card-content.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-card-move.mjs +29 -7
- package/fesm2022/caribeng-ui-caribe-card-select.mjs +56 -14
- package/fesm2022/caribeng-ui-caribe-circle-loading.mjs +10 -7
- package/fesm2022/caribeng-ui-caribe-coachmark.mjs +42 -19
- package/fesm2022/caribeng-ui-caribe-data-table.mjs +15 -9
- package/fesm2022/caribeng-ui-caribe-dots-indicator.mjs +38 -5
- package/fesm2022/caribeng-ui-caribe-expansion-panel.mjs +16 -5
- package/fesm2022/caribeng-ui-caribe-fab-menu.mjs +56 -7
- package/fesm2022/caribeng-ui-caribe-file-download.mjs +68 -27
- package/fesm2022/caribeng-ui-caribe-file-select.mjs +22 -17
- package/fesm2022/caribeng-ui-caribe-float-menu.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-footer.mjs +8 -4
- package/fesm2022/caribeng-ui-caribe-header.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-icon-button.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-illustration.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-inline-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-input-search.mjs +14 -10
- package/fesm2022/caribeng-ui-caribe-input-select.mjs +12 -10
- package/fesm2022/caribeng-ui-caribe-input-token.mjs +61 -11
- package/fesm2022/caribeng-ui-caribe-link.mjs +7 -2
- package/fesm2022/caribeng-ui-caribe-loader.mjs +8 -5
- package/fesm2022/caribeng-ui-caribe-modal.mjs +32 -16
- package/fesm2022/caribeng-ui-caribe-off-canvas.mjs +26 -12
- package/fesm2022/caribeng-ui-caribe-onboarding.mjs +44 -19
- package/fesm2022/caribeng-ui-caribe-pictogram.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-pop-over.mjs +34 -10
- package/fesm2022/caribeng-ui-caribe-preloader.mjs +9 -6
- package/fesm2022/caribeng-ui-caribe-progress-bar.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-shortcut.mjs +8 -3
- package/fesm2022/caribeng-ui-caribe-step-indicator.mjs +12 -5
- package/fesm2022/caribeng-ui-caribe-stroke.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-switch.mjs +5 -3
- package/fesm2022/caribeng-ui-caribe-tag-button.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-tracker.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-transaction-status.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-voucher.mjs +11 -8
- package/fesm2022/caribeng-ui-carousel.mjs +49 -14
- package/fesm2022/caribeng-ui-cascadeselect.mjs +22 -8
- package/fesm2022/caribeng-ui-chart.mjs +2598 -303
- package/fesm2022/caribeng-ui-chip.mjs +9 -4
- package/fesm2022/caribeng-ui-chips.mjs +9 -5
- package/fesm2022/caribeng-ui-colorpicker.mjs +9 -7
- package/fesm2022/caribeng-ui-confirmdialog.mjs +74 -9
- package/fesm2022/caribeng-ui-confirmpopup.mjs +134 -9
- package/fesm2022/caribeng-ui-contextmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-dataview.mjs +211 -6
- package/fesm2022/caribeng-ui-datepicker.mjs +1630 -393
- package/fesm2022/caribeng-ui-descriptions.mjs +124 -0
- package/fesm2022/caribeng-ui-dialog.mjs +10 -7
- package/fesm2022/caribeng-ui-dock.mjs +6 -3
- package/fesm2022/caribeng-ui-drawer.mjs +10 -7
- package/fesm2022/caribeng-ui-dynamicdialog.mjs +210 -6
- package/fesm2022/caribeng-ui-editor.mjs +4392 -243
- package/fesm2022/caribeng-ui-empty.mjs +80 -0
- package/fesm2022/caribeng-ui-file-card.mjs +2 -2
- package/fesm2022/caribeng-ui-fileupload.mjs +96 -19
- package/fesm2022/caribeng-ui-floatlabel.mjs +4 -2
- package/fesm2022/caribeng-ui-folder-card.mjs +10 -3
- package/fesm2022/caribeng-ui-galleria.mjs +76 -45
- package/fesm2022/caribeng-ui-image.mjs +52 -29
- package/fesm2022/caribeng-ui-inplace.mjs +22 -6
- package/fesm2022/caribeng-ui-input-number.mjs +9 -7
- package/fesm2022/caribeng-ui-inputgroup.mjs +2 -2
- package/fesm2022/caribeng-ui-inputmask.mjs +14 -11
- package/fesm2022/caribeng-ui-inputotp.mjs +12 -6
- package/fesm2022/caribeng-ui-keyfilter.mjs +72 -0
- package/fesm2022/caribeng-ui-listbox.mjs +13 -11
- package/fesm2022/caribeng-ui-megamenu.mjs +222 -30
- package/fesm2022/caribeng-ui-menu.mjs +11 -5
- package/fesm2022/caribeng-ui-menubar.mjs +10 -5
- package/fesm2022/caribeng-ui-message.mjs +7 -4
- package/fesm2022/caribeng-ui-metergroup.mjs +29 -11
- package/fesm2022/caribeng-ui-multiselect.mjs +399 -97
- package/fesm2022/caribeng-ui-orderlist.mjs +230 -11
- package/fesm2022/caribeng-ui-organizationchart.mjs +12 -7
- package/fesm2022/caribeng-ui-paginator.mjs +18 -15
- package/fesm2022/caribeng-ui-panel.mjs +5 -2
- package/fesm2022/caribeng-ui-panelmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-password.mjs +8 -6
- package/fesm2022/caribeng-ui-pdfviewer.mjs +1553 -0
- package/fesm2022/caribeng-ui-picklist.mjs +251 -14
- package/fesm2022/caribeng-ui-pricing.mjs +17 -14
- package/fesm2022/caribeng-ui-rating.mjs +7 -3
- package/fesm2022/caribeng-ui-repeater.mjs +223 -0
- package/fesm2022/caribeng-ui-result.mjs +91 -0
- package/fesm2022/caribeng-ui-scrollpanel.mjs +6 -3
- package/fesm2022/caribeng-ui-scrolltop.mjs +6 -3
- package/fesm2022/caribeng-ui-select.mjs +379 -87
- package/fesm2022/caribeng-ui-selectbutton.mjs +2 -2
- package/fesm2022/caribeng-ui-slider.mjs +171 -75
- package/fesm2022/caribeng-ui-speeddial.mjs +7 -4
- package/fesm2022/caribeng-ui-spinner.mjs +5 -2
- package/fesm2022/caribeng-ui-splitbutton.mjs +163 -0
- package/fesm2022/caribeng-ui-splitter.mjs +5 -2
- package/fesm2022/caribeng-ui-statistic.mjs +183 -0
- package/fesm2022/caribeng-ui-stepper.mjs +8 -5
- package/fesm2022/caribeng-ui-steps.mjs +6 -3
- package/fesm2022/caribeng-ui-table.mjs +708 -82
- package/fesm2022/caribeng-ui-tabmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-tag.mjs +2 -2
- package/fesm2022/caribeng-ui-terminal.mjs +45 -9
- package/fesm2022/caribeng-ui-themetoggle.mjs +82 -0
- package/fesm2022/caribeng-ui-tieredmenu.mjs +9 -6
- package/fesm2022/caribeng-ui-timeline.mjs +175 -6
- package/fesm2022/caribeng-ui-toast.mjs +7 -4
- package/fesm2022/caribeng-ui-togglebutton.mjs +8 -6
- package/fesm2022/caribeng-ui-toolbar.mjs +6 -3
- package/fesm2022/caribeng-ui-tree.mjs +302 -6
- package/fesm2022/caribeng-ui-treeselect.mjs +26 -10
- package/fesm2022/caribeng-ui-treetable.mjs +269 -6
- package/fesm2022/caribeng-ui-virtualscroller.mjs +123 -10
- package/fesm2022/caribeng-ui.mjs +829 -6
- package/package.json +70 -11
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +125 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +66 -0
- package/styles/caribeng.css +380 -0
- package/styles/scss/_mixins.scss +46 -0
- package/styles/scss/_overlay.scss +15 -0
- package/styles/scss/_tokens.scss +267 -0
- package/styles/scss/_utilities.scss +73 -0
- package/styles/scss/_variables.scss +33 -0
- package/styles/scss/index.scss +16 -0
- package/types/caribeng-ui-anchor.d.ts +50 -0
- package/types/caribeng-ui-autocomplete.d.ts +4 -2
- package/types/caribeng-ui-avatargroup.d.ts +3 -1
- package/types/caribeng-ui-blockui.d.ts +9 -4
- package/types/caribeng-ui-breadcrumb.d.ts +3 -0
- package/types/caribeng-ui-button.d.ts +9 -1
- package/types/caribeng-ui-caribe-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-animation-lottie.d.ts +4 -1
- package/types/caribeng-ui-caribe-button-group.d.ts +4 -1
- package/types/caribeng-ui-caribe-calendar.d.ts +5 -1
- package/types/caribeng-ui-caribe-card-content.d.ts +4 -1
- package/types/caribeng-ui-caribe-card-move.d.ts +13 -13
- package/types/caribeng-ui-caribe-card-select.d.ts +10 -1
- package/types/caribeng-ui-caribe-circle-loading.d.ts +4 -1
- package/types/caribeng-ui-caribe-coachmark.d.ts +6 -0
- package/types/caribeng-ui-caribe-data-table.d.ts +7 -2
- package/types/caribeng-ui-caribe-dots-indicator.d.ts +9 -0
- package/types/caribeng-ui-caribe-expansion-panel.d.ts +7 -10
- package/types/caribeng-ui-caribe-fab-menu.d.ts +10 -1
- package/types/caribeng-ui-caribe-file-download.d.ts +8 -10
- package/types/caribeng-ui-caribe-file-select.d.ts +7 -1
- package/types/caribeng-ui-caribe-float-menu.d.ts +4 -1
- package/types/caribeng-ui-caribe-header.d.ts +3 -0
- package/types/caribeng-ui-caribe-icon-button.d.ts +4 -1
- package/types/caribeng-ui-caribe-illustration.d.ts +4 -1
- package/types/caribeng-ui-caribe-inline-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-input-search.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-select.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-token.d.ts +16 -1
- package/types/caribeng-ui-caribe-link.d.ts +3 -0
- package/types/caribeng-ui-caribe-loader.d.ts +4 -1
- package/types/caribeng-ui-caribe-modal.d.ts +7 -10
- package/types/caribeng-ui-caribe-off-canvas.d.ts +6 -1
- package/types/caribeng-ui-caribe-onboarding.d.ts +6 -0
- package/types/caribeng-ui-caribe-pictogram.d.ts +4 -1
- package/types/caribeng-ui-caribe-pop-over.d.ts +7 -10
- package/types/caribeng-ui-caribe-preloader.d.ts +4 -1
- package/types/caribeng-ui-caribe-progress-bar.d.ts +3 -0
- package/types/caribeng-ui-caribe-shortcut.d.ts +3 -1
- package/types/caribeng-ui-caribe-step-indicator.d.ts +6 -0
- package/types/caribeng-ui-caribe-stroke.d.ts +4 -1
- package/types/caribeng-ui-caribe-switch.d.ts +3 -1
- package/types/caribeng-ui-caribe-tracker.d.ts +3 -0
- package/types/caribeng-ui-caribe-voucher.d.ts +5 -2
- package/types/caribeng-ui-carousel.d.ts +10 -1
- package/types/caribeng-ui-cascadeselect.d.ts +7 -2
- package/types/caribeng-ui-chart.d.ts +469 -44
- package/types/caribeng-ui-chip.d.ts +6 -0
- package/types/caribeng-ui-chips.d.ts +6 -2
- package/types/caribeng-ui-colorpicker.d.ts +3 -1
- package/types/caribeng-ui-confirmdialog.d.ts +25 -6
- package/types/caribeng-ui-confirmpopup.d.ts +37 -5
- package/types/caribeng-ui-contextmenu.d.ts +4 -1
- package/types/caribeng-ui-dataview.d.ts +63 -5
- package/types/caribeng-ui-datepicker.d.ts +186 -21
- package/types/caribeng-ui-descriptions.d.ts +63 -0
- package/types/caribeng-ui-dialog.d.ts +4 -1
- package/types/caribeng-ui-dock.d.ts +4 -1
- package/types/caribeng-ui-drawer.d.ts +4 -1
- package/types/caribeng-ui-dynamicdialog.d.ts +93 -3
- package/types/caribeng-ui-editor.d.ts +486 -13
- package/types/caribeng-ui-empty.d.ts +34 -0
- package/types/caribeng-ui-file-card.d.ts +1 -1
- package/types/caribeng-ui-fileupload.d.ts +27 -4
- package/types/caribeng-ui-folder-card.d.ts +4 -1
- package/types/caribeng-ui-galleria.d.ts +9 -0
- package/types/caribeng-ui-image.d.ts +10 -0
- package/types/caribeng-ui-inplace.d.ts +8 -0
- package/types/caribeng-ui-input-number.d.ts +3 -1
- package/types/caribeng-ui-inputmask.d.ts +5 -0
- package/types/caribeng-ui-inputotp.d.ts +7 -2
- package/types/caribeng-ui-keyfilter.d.ts +30 -0
- package/types/caribeng-ui-listbox.d.ts +5 -3
- package/types/caribeng-ui-megamenu.d.ts +26 -2
- package/types/caribeng-ui-menu.d.ts +7 -2
- package/types/caribeng-ui-menubar.d.ts +5 -1
- package/types/caribeng-ui-message.d.ts +3 -0
- package/types/caribeng-ui-metergroup.d.ts +9 -1
- package/types/caribeng-ui-multiselect.d.ts +71 -10
- package/types/caribeng-ui-orderlist.d.ts +58 -6
- package/types/caribeng-ui-organizationchart.d.ts +7 -1
- package/types/caribeng-ui-paginator.d.ts +3 -0
- package/types/caribeng-ui-panel.d.ts +3 -0
- package/types/caribeng-ui-panelmenu.d.ts +4 -1
- package/types/caribeng-ui-password.d.ts +4 -2
- package/types/caribeng-ui-pdfviewer.d.ts +258 -0
- package/types/caribeng-ui-picklist.d.ts +67 -7
- package/types/caribeng-ui-pricing.d.ts +8 -5
- package/types/caribeng-ui-rating.d.ts +6 -2
- package/types/caribeng-ui-repeater.d.ts +79 -0
- package/types/caribeng-ui-result.d.ts +35 -0
- package/types/caribeng-ui-scrollpanel.d.ts +4 -1
- package/types/caribeng-ui-scrolltop.d.ts +4 -1
- package/types/caribeng-ui-select.d.ts +73 -9
- package/types/caribeng-ui-slider.d.ts +63 -10
- package/types/caribeng-ui-speeddial.d.ts +5 -2
- package/types/caribeng-ui-spinner.d.ts +3 -0
- package/types/caribeng-ui-splitbutton.d.ts +49 -0
- package/types/caribeng-ui-splitter.d.ts +3 -0
- package/types/caribeng-ui-statistic.d.ts +65 -0
- package/types/caribeng-ui-stepper.d.ts +3 -0
- package/types/caribeng-ui-steps.d.ts +4 -1
- package/types/caribeng-ui-table.d.ts +184 -16
- package/types/caribeng-ui-tabmenu.d.ts +4 -1
- package/types/caribeng-ui-terminal.d.ts +10 -0
- package/types/caribeng-ui-themetoggle.d.ts +32 -0
- package/types/caribeng-ui-tieredmenu.d.ts +5 -2
- package/types/caribeng-ui-timeline.d.ts +63 -4
- package/types/caribeng-ui-toast.d.ts +3 -0
- package/types/caribeng-ui-togglebutton.d.ts +5 -3
- package/types/caribeng-ui-toolbar.d.ts +7 -4
- package/types/caribeng-ui-tree.d.ts +76 -4
- package/types/caribeng-ui-treeselect.d.ts +10 -2
- package/types/caribeng-ui-treetable.d.ts +68 -4
- package/types/caribeng-ui-virtualscroller.d.ts +45 -5
- package/types/caribeng-ui.d.ts +501 -12
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, Directive } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/** Caracteres permitidos por cada filtro predefinido (se comprueba carácter a carácter). */
|
|
5
|
+
const PRESETS = {
|
|
6
|
+
int: /[\d-]/,
|
|
7
|
+
pint: /\d/,
|
|
8
|
+
num: /[\d\-.,]/,
|
|
9
|
+
pnum: /[\d.,]/,
|
|
10
|
+
money: /[\d.,]/,
|
|
11
|
+
alpha: /[a-záéíóúüñ\s]/i,
|
|
12
|
+
alphanum: /[a-z0-9áéíóúüñ\s]/i,
|
|
13
|
+
hex: /[0-9a-f]/i,
|
|
14
|
+
email: /[a-z0-9@._+-]/i,
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* KeyFilter de CaribeNG: limita los caracteres que se pueden escribir en un
|
|
18
|
+
* `input` o `textarea`. Usa el evento `beforeinput`, así filtra lo tecleado,
|
|
19
|
+
* lo pegado y lo autocompletado (no solo las teclas).
|
|
20
|
+
*
|
|
21
|
+
* Solo restringe la entrada: valida el formato final con Validators en el formulario.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```html
|
|
25
|
+
* <input cbKeyFilter="pint" inputmode="numeric" aria-label="Número de cédula" />
|
|
26
|
+
* <input [cbKeyFilter]="/[A-Z0-9]/" aria-label="Placa" />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
class CbKeyFilter {
|
|
30
|
+
constructor() {
|
|
31
|
+
/** Filtro predefinido o expresión que debe cumplir cada carácter. */
|
|
32
|
+
this.cbKeyFilter = input.required(/* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "cbKeyFilter" }] : /* istanbul ignore next */ []));
|
|
34
|
+
}
|
|
35
|
+
/** ¿Se acepta este texto? (cada carácter debe cumplir el filtro). */
|
|
36
|
+
allows(text) {
|
|
37
|
+
const filter = this.cbKeyFilter();
|
|
38
|
+
const pattern = filter instanceof RegExp ? new RegExp(filter.source, filter.flags.replace('g', '')) : PRESETS[filter];
|
|
39
|
+
if (!pattern)
|
|
40
|
+
return true;
|
|
41
|
+
return [...text].every((ch) => pattern.test(ch));
|
|
42
|
+
}
|
|
43
|
+
onBeforeInput(e) {
|
|
44
|
+
const event = e;
|
|
45
|
+
// Borrar, deshacer o mover texto siempre se permite; solo se filtra lo que se inserta.
|
|
46
|
+
if (!event.inputType?.startsWith('insert'))
|
|
47
|
+
return;
|
|
48
|
+
const text = event.data ?? event.dataTransfer?.getData('text/plain') ?? '';
|
|
49
|
+
if (text && !this.allows(text))
|
|
50
|
+
event.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbKeyFilter, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
53
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", type: CbKeyFilter, isStandalone: true, selector: "input[cbKeyFilter], textarea[cbKeyFilter]", inputs: { cbKeyFilter: { classPropertyName: "cbKeyFilter", publicName: "cbKeyFilter", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "beforeinput": "onBeforeInput($event)" } }, ngImport: i0 }); }
|
|
54
|
+
}
|
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbKeyFilter, decorators: [{
|
|
56
|
+
type: Directive,
|
|
57
|
+
args: [{
|
|
58
|
+
selector: 'input[cbKeyFilter], textarea[cbKeyFilter]',
|
|
59
|
+
standalone: true,
|
|
60
|
+
host: { '(beforeinput)': 'onBeforeInput($event)' },
|
|
61
|
+
}]
|
|
62
|
+
}], propDecorators: { cbKeyFilter: [{ type: i0.Input, args: [{ isSignal: true, alias: "cbKeyFilter", required: true }] }] } });
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Public API Surface de @caribeng/ui/keyfilter
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generated bundle index. Do not edit.
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
export { CbKeyFilter };
|
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { input, model, signal, computed, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
5
|
-
import { cbFieldState } from '@caribeng/ui';
|
|
5
|
+
import { injectCbTranslation, cbFieldState } from '@caribeng/ui';
|
|
6
6
|
|
|
7
7
|
let nextUid = 0;
|
|
8
8
|
/**
|
|
@@ -18,6 +18,8 @@ let nextUid = 0;
|
|
|
18
18
|
*/
|
|
19
19
|
class CbListBox {
|
|
20
20
|
constructor() {
|
|
21
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
22
|
+
this.t = injectCbTranslation();
|
|
21
23
|
this.options = input([], /* @ts-ignore */
|
|
22
24
|
...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
|
|
23
25
|
this.optionLabel = input('label', /* @ts-ignore */
|
|
@@ -28,9 +30,9 @@ class CbListBox {
|
|
|
28
30
|
...(ngDevMode ? [{ debugName: "optionDisabled" }] : /* istanbul ignore next */ []));
|
|
29
31
|
this.multiple = input(false, { ...(ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {}), transform: toBoolean });
|
|
30
32
|
this.filter = input(false, { ...(ngDevMode ? { debugName: "filter" } : /* istanbul ignore next */ {}), transform: toBoolean });
|
|
31
|
-
this.filterPlaceholder = input(
|
|
33
|
+
this.filterPlaceholder = input(undefined, /* @ts-ignore */
|
|
32
34
|
...(ngDevMode ? [{ debugName: "filterPlaceholder" }] : /* istanbul ignore next */ []));
|
|
33
|
-
this.emptyMessage = input(
|
|
35
|
+
this.emptyMessage = input(undefined, /* @ts-ignore */
|
|
34
36
|
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
35
37
|
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: toBoolean });
|
|
36
38
|
/** Marca visual y ARIA de estado inválido (también se activa con Angular Forms). */
|
|
@@ -187,11 +189,11 @@ class CbListBox {
|
|
|
187
189
|
<input
|
|
188
190
|
type="text"
|
|
189
191
|
class="cb-listbox__filter-input"
|
|
190
|
-
[placeholder]="filterPlaceholder()"
|
|
192
|
+
[placeholder]="(filterPlaceholder() ?? t().search)"
|
|
191
193
|
[value]="filterText()"
|
|
192
194
|
[disabled]="isDisabled()"
|
|
193
195
|
(input)="onFilter($event)"
|
|
194
|
-
aria-label="
|
|
196
|
+
[attr.aria-label]="t().filterOptions"
|
|
195
197
|
/>
|
|
196
198
|
</div>
|
|
197
199
|
}
|
|
@@ -230,12 +232,12 @@ class CbListBox {
|
|
|
230
232
|
</li>
|
|
231
233
|
} @empty {
|
|
232
234
|
<li class="cb-listbox__empty" role="option" aria-disabled="true">
|
|
233
|
-
{{ emptyMessage() }}
|
|
235
|
+
{{ (emptyMessage() ?? t().noResults) }}
|
|
234
236
|
</li>
|
|
235
237
|
}
|
|
236
238
|
</ul>
|
|
237
239
|
</div>
|
|
238
|
-
`, isInline: true, styles: [":host{display:block}.cb-listbox{border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);font-family:var(--cb-font-sans);overflow:hidden}.cb-listbox.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55)}.cb-listbox__filter{padding:var(--cb-space-2);border-bottom:var(--cb-border-width) solid var(--cb-color-border)}.cb-listbox__filter-input{width:100%;padding:var(--cb-space-2);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-sm);background-color:var(--cb-color-bg);color:var(--cb-color-text);font:inherit;outline:none}.cb-listbox__filter-input:focus{border-color:var(--cb-color-primary-500)}.cb-listbox__list{list-style:none;margin:0;padding:var(--cb-space-1);max-height:15rem;overflow-y:auto;outline:none}.cb-listbox__list:focus-visible{box-shadow:inset 0 0 0 2px var(--cb-color-focus-ring);border-radius:var(--cb-radius-sm)}.cb-listbox__option{display:flex;align-items:center;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border-radius:var(--cb-radius-sm);color:var(--cb-color-text);cursor:pointer}.cb-listbox__option.cb-is-active{background-color:var(--cb-color-surface-
|
|
240
|
+
`, isInline: true, styles: [":host{display:block}.cb-listbox{border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);font-family:var(--cb-font-sans);overflow:hidden}.cb-listbox.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55)}.cb-listbox__filter{padding:var(--cb-space-2);border-bottom:var(--cb-border-width) solid var(--cb-color-border)}.cb-listbox__filter-input{width:100%;padding:var(--cb-space-2);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-sm);background-color:var(--cb-color-bg);color:var(--cb-color-text);font:inherit;outline:none}.cb-listbox__filter-input:focus{border-color:var(--cb-color-primary-500)}.cb-listbox__list{list-style:none;margin:0;padding:var(--cb-space-1);max-height:15rem;overflow-y:auto;outline:none}.cb-listbox__list:focus-visible{box-shadow:inset 0 0 0 2px var(--cb-color-focus-ring);border-radius:var(--cb-radius-sm)}.cb-listbox__option{display:flex;align-items:center;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border-radius:var(--cb-radius-sm);color:var(--cb-color-text);cursor:pointer}.cb-listbox__option.cb-is-active{background-color:var(--cb-color-surface-hover)}.cb-listbox__option.cb-is-selected:not(.cb-is-active){background-color:var(--cb-color-primary-50)}.cb-listbox__option.cb-is-selected{color:var(--cb-color-primary-700);font-weight:var(--cb-font-weight-medium)}.cb-listbox__option.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55);cursor:default}.cb-listbox__check{display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.1rem;height:1.1rem;border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-sm);color:var(--cb-color-primary-contrast)}.cb-listbox__check.cb-is-checked{background-color:var(--cb-color-primary-500);border-color:var(--cb-color-primary-500)}.cb-listbox__empty{padding:var(--cb-space-3);color:var(--cb-color-text-muted);text-align:center}:host-context([data-theme=\"dark\"]) .cb-listbox__option.cb-is-selected{color:var(--cb-color-primary-200)}:host-context([data-theme=\"dark\"]) .cb-listbox__option.cb-is-selected:not(.cb-is-active){background-color:color-mix(in srgb,var(--cb-color-primary-500) 18%,transparent)}.cb-listbox.cb-is-invalid{border-color:var(--cb-color-danger)}\n"], dependencies: [{ kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
239
241
|
}
|
|
240
242
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbListBox, decorators: [{
|
|
241
243
|
type: Component,
|
|
@@ -252,11 +254,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
252
254
|
<input
|
|
253
255
|
type="text"
|
|
254
256
|
class="cb-listbox__filter-input"
|
|
255
|
-
[placeholder]="filterPlaceholder()"
|
|
257
|
+
[placeholder]="(filterPlaceholder() ?? t().search)"
|
|
256
258
|
[value]="filterText()"
|
|
257
259
|
[disabled]="isDisabled()"
|
|
258
260
|
(input)="onFilter($event)"
|
|
259
|
-
aria-label="
|
|
261
|
+
[attr.aria-label]="t().filterOptions"
|
|
260
262
|
/>
|
|
261
263
|
</div>
|
|
262
264
|
}
|
|
@@ -295,12 +297,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
295
297
|
</li>
|
|
296
298
|
} @empty {
|
|
297
299
|
<li class="cb-listbox__empty" role="option" aria-disabled="true">
|
|
298
|
-
{{ emptyMessage() }}
|
|
300
|
+
{{ (emptyMessage() ?? t().noResults) }}
|
|
299
301
|
</li>
|
|
300
302
|
}
|
|
301
303
|
</ul>
|
|
302
304
|
</div>
|
|
303
|
-
`, styles: [":host{display:block}.cb-listbox{border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);font-family:var(--cb-font-sans);overflow:hidden}.cb-listbox.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55)}.cb-listbox__filter{padding:var(--cb-space-2);border-bottom:var(--cb-border-width) solid var(--cb-color-border)}.cb-listbox__filter-input{width:100%;padding:var(--cb-space-2);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-sm);background-color:var(--cb-color-bg);color:var(--cb-color-text);font:inherit;outline:none}.cb-listbox__filter-input:focus{border-color:var(--cb-color-primary-500)}.cb-listbox__list{list-style:none;margin:0;padding:var(--cb-space-1);max-height:15rem;overflow-y:auto;outline:none}.cb-listbox__list:focus-visible{box-shadow:inset 0 0 0 2px var(--cb-color-focus-ring);border-radius:var(--cb-radius-sm)}.cb-listbox__option{display:flex;align-items:center;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border-radius:var(--cb-radius-sm);color:var(--cb-color-text);cursor:pointer}.cb-listbox__option.cb-is-active{background-color:var(--cb-color-surface-
|
|
305
|
+
`, styles: [":host{display:block}.cb-listbox{border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);font-family:var(--cb-font-sans);overflow:hidden}.cb-listbox.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55)}.cb-listbox__filter{padding:var(--cb-space-2);border-bottom:var(--cb-border-width) solid var(--cb-color-border)}.cb-listbox__filter-input{width:100%;padding:var(--cb-space-2);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-sm);background-color:var(--cb-color-bg);color:var(--cb-color-text);font:inherit;outline:none}.cb-listbox__filter-input:focus{border-color:var(--cb-color-primary-500)}.cb-listbox__list{list-style:none;margin:0;padding:var(--cb-space-1);max-height:15rem;overflow-y:auto;outline:none}.cb-listbox__list:focus-visible{box-shadow:inset 0 0 0 2px var(--cb-color-focus-ring);border-radius:var(--cb-radius-sm)}.cb-listbox__option{display:flex;align-items:center;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border-radius:var(--cb-radius-sm);color:var(--cb-color-text);cursor:pointer}.cb-listbox__option.cb-is-active{background-color:var(--cb-color-surface-hover)}.cb-listbox__option.cb-is-selected:not(.cb-is-active){background-color:var(--cb-color-primary-50)}.cb-listbox__option.cb-is-selected{color:var(--cb-color-primary-700);font-weight:var(--cb-font-weight-medium)}.cb-listbox__option.cb-is-disabled{opacity:var(--cb-opacity-disabled, .55);cursor:default}.cb-listbox__check{display:inline-flex;align-items:center;justify-content:center;flex:none;width:1.1rem;height:1.1rem;border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-sm);color:var(--cb-color-primary-contrast)}.cb-listbox__check.cb-is-checked{background-color:var(--cb-color-primary-500);border-color:var(--cb-color-primary-500)}.cb-listbox__empty{padding:var(--cb-space-3);color:var(--cb-color-text-muted);text-align:center}:host-context([data-theme=\"dark\"]) .cb-listbox__option.cb-is-selected{color:var(--cb-color-primary-200)}:host-context([data-theme=\"dark\"]) .cb-listbox__option.cb-is-selected:not(.cb-is-active){background-color:color-mix(in srgb,var(--cb-color-primary-500) 18%,transparent)}.cb-listbox.cb-is-invalid{border-color:var(--cb-color-danger)}\n"] }]
|
|
304
306
|
}], propDecorators: { options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: false }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: false }] }], optionDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionDisabled", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], filterPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterPlaceholder", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
305
307
|
function toBoolean(value) {
|
|
306
308
|
return value !== false && value != null && `${value}` !== 'false';
|
|
@@ -1,43 +1,185 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, input, output, signal, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, Injector, input, output, signal, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { injectCbTranslation } from '@caribeng/ui';
|
|
3
4
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
let nextUid = 0;
|
|
7
|
+
/**
|
|
8
|
+
* Menú de categorías con paneles de varias columnas (patrón *disclosure
|
|
9
|
+
* navigation* de WAI-ARIA). Teclado: ←/→ entre categorías, ↓ abre el panel y
|
|
10
|
+
* entra al primer enlace, ↑/↓ recorre los enlaces y Escape cierra devolviendo
|
|
11
|
+
* el foco a la categoría.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```html
|
|
15
|
+
* <cb-megamenu [items]="categorias" (itemSelect)="navegar($event)" />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
6
18
|
class CbMegaMenu {
|
|
7
19
|
constructor() {
|
|
8
|
-
this.
|
|
20
|
+
this.t = injectCbTranslation();
|
|
21
|
+
this.host = inject(ElementRef);
|
|
22
|
+
this.injector = inject(Injector);
|
|
23
|
+
this.panelId = `cb-megamenu-${++nextUid}-panel`;
|
|
24
|
+
/** Categorías con sus grupos de enlaces. */
|
|
9
25
|
this.items = input([], /* @ts-ignore */
|
|
10
26
|
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
11
|
-
|
|
27
|
+
/** Nombre accesible de la navegación. Por defecto, "Categorías" del idioma activo. */
|
|
28
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
12
29
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
30
|
+
/** Se emite al elegir un enlace. */
|
|
13
31
|
this.itemSelect = output();
|
|
14
32
|
this.openIndex = signal(null, /* @ts-ignore */
|
|
15
33
|
...(ngDevMode ? [{ debugName: "openIndex" }] : /* istanbul ignore next */ []));
|
|
16
34
|
}
|
|
17
|
-
toggle(index) {
|
|
18
|
-
|
|
35
|
+
toggle(index) {
|
|
36
|
+
this.openIndex.update((current) => (current === index ? null : index));
|
|
37
|
+
}
|
|
38
|
+
select(link) {
|
|
39
|
+
if (link.disabled)
|
|
40
|
+
return;
|
|
19
41
|
this.itemSelect.emit(link);
|
|
20
42
|
this.close();
|
|
21
|
-
}
|
|
22
|
-
close() {
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
}
|
|
44
|
+
close() {
|
|
45
|
+
this.openIndex.set(null);
|
|
46
|
+
}
|
|
47
|
+
onDocumentClick(event) {
|
|
48
|
+
if (!this.host.nativeElement.contains(event.target))
|
|
49
|
+
this.close();
|
|
50
|
+
}
|
|
51
|
+
/** Al salir el foco del componente (p. ej. con Tab), se cierra el panel. */
|
|
52
|
+
onFocusOut(event) {
|
|
53
|
+
const next = event.relatedTarget;
|
|
54
|
+
if (next && !this.host.nativeElement.contains(next))
|
|
55
|
+
this.close();
|
|
56
|
+
}
|
|
57
|
+
onTriggerKeydown(event, index) {
|
|
58
|
+
const count = this.items().length;
|
|
59
|
+
switch (event.key) {
|
|
60
|
+
case 'ArrowRight':
|
|
61
|
+
this.focusTrigger((index + 1) % count);
|
|
62
|
+
break;
|
|
63
|
+
case 'ArrowLeft':
|
|
64
|
+
this.focusTrigger((index - 1 + count) % count);
|
|
65
|
+
break;
|
|
66
|
+
case 'Home':
|
|
67
|
+
this.focusTrigger(0);
|
|
68
|
+
break;
|
|
69
|
+
case 'End':
|
|
70
|
+
this.focusTrigger(count - 1);
|
|
71
|
+
break;
|
|
72
|
+
case 'ArrowDown':
|
|
73
|
+
this.openIndex.set(index);
|
|
74
|
+
afterNextRender(() => this.links()[0]?.focus(), { injector: this.injector });
|
|
75
|
+
break;
|
|
76
|
+
case 'Escape':
|
|
77
|
+
this.close();
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
event.preventDefault();
|
|
83
|
+
}
|
|
84
|
+
onPanelKeydown(event) {
|
|
85
|
+
const links = this.links();
|
|
86
|
+
const current = links.indexOf(document.activeElement);
|
|
87
|
+
switch (event.key) {
|
|
88
|
+
case 'ArrowDown':
|
|
89
|
+
links[Math.min(links.length - 1, current + 1)]?.focus();
|
|
90
|
+
break;
|
|
91
|
+
case 'ArrowUp':
|
|
92
|
+
if (current <= 0)
|
|
93
|
+
this.focusTrigger(this.openIndex());
|
|
94
|
+
else
|
|
95
|
+
links[current - 1].focus();
|
|
96
|
+
break;
|
|
97
|
+
case 'Home':
|
|
98
|
+
links[0]?.focus();
|
|
99
|
+
break;
|
|
100
|
+
case 'End':
|
|
101
|
+
links[links.length - 1]?.focus();
|
|
102
|
+
break;
|
|
103
|
+
case 'Escape': {
|
|
104
|
+
const index = this.openIndex();
|
|
105
|
+
this.close();
|
|
106
|
+
this.focusTrigger(index);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
default:
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
/** Enlaces navegables del panel abierto, en orden de lectura. */
|
|
115
|
+
links() {
|
|
116
|
+
return Array.from(this.host.nativeElement.querySelectorAll('.cb-megamenu__panel .cb-megamenu__link:not([disabled])'));
|
|
117
|
+
}
|
|
118
|
+
focusTrigger(index) {
|
|
119
|
+
this.host.nativeElement.querySelectorAll('.cb-megamenu__trigger')[index]?.focus();
|
|
120
|
+
}
|
|
25
121
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbMegaMenu, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
26
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbMegaMenu, isStandalone: true, selector: "cb-megamenu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, host: { listeners: { "document:click": "onDocumentClick($event)", "
|
|
27
|
-
<nav [attr.aria-label]="ariaLabel()">
|
|
122
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbMegaMenu, isStandalone: true, selector: "cb-megamenu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, host: { listeners: { "document:click": "onDocumentClick($event)", "focusout": "onFocusOut($event)" }, classAttribute: "cb-megamenu" }, ngImport: i0, template: `
|
|
123
|
+
<nav [attr.aria-label]="ariaLabel() ?? t().categories">
|
|
28
124
|
<ul class="cb-megamenu__bar">
|
|
29
125
|
@for (item of items(); track $index; let i = $index) {
|
|
30
|
-
<li
|
|
126
|
+
<li>
|
|
127
|
+
<button
|
|
128
|
+
class="cb-megamenu__trigger"
|
|
129
|
+
type="button"
|
|
130
|
+
[attr.aria-expanded]="openIndex() === i"
|
|
131
|
+
[attr.aria-controls]="openIndex() === i ? panelId : null"
|
|
132
|
+
(click)="toggle(i)"
|
|
133
|
+
(keydown)="onTriggerKeydown($event, i)"
|
|
134
|
+
>
|
|
135
|
+
@if (item.icon) {
|
|
136
|
+
<cb-icon [name]="item.icon" [size]="16" aria-hidden="true" />
|
|
137
|
+
}
|
|
138
|
+
{{ item.label }}
|
|
139
|
+
<cb-icon
|
|
140
|
+
class="cb-megamenu__chevron"
|
|
141
|
+
[class.cb-megamenu__chevron--open]="openIndex() === i"
|
|
142
|
+
name="chevron-down"
|
|
143
|
+
[size]="14"
|
|
144
|
+
aria-hidden="true"
|
|
145
|
+
/>
|
|
146
|
+
</button>
|
|
147
|
+
</li>
|
|
31
148
|
}
|
|
32
149
|
</ul>
|
|
33
150
|
@if (openIndex() !== null) {
|
|
34
|
-
<section
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
151
|
+
<section
|
|
152
|
+
class="cb-megamenu__panel"
|
|
153
|
+
[id]="panelId"
|
|
154
|
+
role="region"
|
|
155
|
+
[attr.aria-label]="items()[openIndex()!].label"
|
|
156
|
+
(keydown)="onPanelKeydown($event)"
|
|
157
|
+
>
|
|
158
|
+
@for (group of items()[openIndex()!].groups; track $index) {
|
|
159
|
+
<div class="cb-megamenu__group">
|
|
160
|
+
<h3>{{ group.label }}</h3>
|
|
161
|
+
<ul>
|
|
162
|
+
@for (link of group.items; track $index) {
|
|
163
|
+
<li>
|
|
164
|
+
@if (link.url && !link.disabled) {
|
|
165
|
+
<a class="cb-megamenu__link" [href]="link.url" (click)="select(link)">
|
|
166
|
+
@if (link.icon) {
|
|
167
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
168
|
+
}
|
|
169
|
+
{{ link.label }}
|
|
170
|
+
</a>
|
|
171
|
+
} @else {
|
|
172
|
+
<button class="cb-megamenu__link" type="button" [disabled]="link.disabled" (click)="select(link)">
|
|
173
|
+
@if (link.icon) {
|
|
174
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
175
|
+
}
|
|
176
|
+
{{ link.label }}
|
|
177
|
+
</button>
|
|
178
|
+
}
|
|
179
|
+
</li>
|
|
180
|
+
}
|
|
181
|
+
</ul>
|
|
182
|
+
</div>
|
|
41
183
|
}
|
|
42
184
|
</section>
|
|
43
185
|
}
|
|
@@ -46,21 +188,71 @@ class CbMegaMenu {
|
|
|
46
188
|
}
|
|
47
189
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbMegaMenu, decorators: [{
|
|
48
190
|
type: Component,
|
|
49
|
-
args: [{ selector: 'cb-megamenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: {
|
|
50
|
-
|
|
191
|
+
args: [{ selector: 'cb-megamenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: {
|
|
192
|
+
class: 'cb-megamenu',
|
|
193
|
+
'(document:click)': 'onDocumentClick($event)',
|
|
194
|
+
'(focusout)': 'onFocusOut($event)',
|
|
195
|
+
}, template: `
|
|
196
|
+
<nav [attr.aria-label]="ariaLabel() ?? t().categories">
|
|
51
197
|
<ul class="cb-megamenu__bar">
|
|
52
198
|
@for (item of items(); track $index; let i = $index) {
|
|
53
|
-
<li
|
|
199
|
+
<li>
|
|
200
|
+
<button
|
|
201
|
+
class="cb-megamenu__trigger"
|
|
202
|
+
type="button"
|
|
203
|
+
[attr.aria-expanded]="openIndex() === i"
|
|
204
|
+
[attr.aria-controls]="openIndex() === i ? panelId : null"
|
|
205
|
+
(click)="toggle(i)"
|
|
206
|
+
(keydown)="onTriggerKeydown($event, i)"
|
|
207
|
+
>
|
|
208
|
+
@if (item.icon) {
|
|
209
|
+
<cb-icon [name]="item.icon" [size]="16" aria-hidden="true" />
|
|
210
|
+
}
|
|
211
|
+
{{ item.label }}
|
|
212
|
+
<cb-icon
|
|
213
|
+
class="cb-megamenu__chevron"
|
|
214
|
+
[class.cb-megamenu__chevron--open]="openIndex() === i"
|
|
215
|
+
name="chevron-down"
|
|
216
|
+
[size]="14"
|
|
217
|
+
aria-hidden="true"
|
|
218
|
+
/>
|
|
219
|
+
</button>
|
|
220
|
+
</li>
|
|
54
221
|
}
|
|
55
222
|
</ul>
|
|
56
223
|
@if (openIndex() !== null) {
|
|
57
|
-
<section
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
224
|
+
<section
|
|
225
|
+
class="cb-megamenu__panel"
|
|
226
|
+
[id]="panelId"
|
|
227
|
+
role="region"
|
|
228
|
+
[attr.aria-label]="items()[openIndex()!].label"
|
|
229
|
+
(keydown)="onPanelKeydown($event)"
|
|
230
|
+
>
|
|
231
|
+
@for (group of items()[openIndex()!].groups; track $index) {
|
|
232
|
+
<div class="cb-megamenu__group">
|
|
233
|
+
<h3>{{ group.label }}</h3>
|
|
234
|
+
<ul>
|
|
235
|
+
@for (link of group.items; track $index) {
|
|
236
|
+
<li>
|
|
237
|
+
@if (link.url && !link.disabled) {
|
|
238
|
+
<a class="cb-megamenu__link" [href]="link.url" (click)="select(link)">
|
|
239
|
+
@if (link.icon) {
|
|
240
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
241
|
+
}
|
|
242
|
+
{{ link.label }}
|
|
243
|
+
</a>
|
|
244
|
+
} @else {
|
|
245
|
+
<button class="cb-megamenu__link" type="button" [disabled]="link.disabled" (click)="select(link)">
|
|
246
|
+
@if (link.icon) {
|
|
247
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
248
|
+
}
|
|
249
|
+
{{ link.label }}
|
|
250
|
+
</button>
|
|
251
|
+
}
|
|
252
|
+
</li>
|
|
253
|
+
}
|
|
254
|
+
</ul>
|
|
255
|
+
</div>
|
|
64
256
|
}
|
|
65
257
|
</section>
|
|
66
258
|
}
|
|
@@ -3,18 +3,23 @@ import { inject, ViewContainerRef, DestroyRef, input, output, viewChild, ViewEnc
|
|
|
3
3
|
import { Overlay } from '@angular/cdk/overlay';
|
|
4
4
|
import { TemplatePortal } from '@angular/cdk/portal';
|
|
5
5
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
6
|
+
import { injectCbTranslation } from '@caribeng/ui';
|
|
6
7
|
|
|
7
8
|
/** Popup menu anchored to any trigger element. */
|
|
8
9
|
class CbMenu {
|
|
9
10
|
constructor() {
|
|
11
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
12
|
+
this.t = injectCbTranslation();
|
|
10
13
|
this.overlay = inject(Overlay);
|
|
11
14
|
this.vcr = inject(ViewContainerRef);
|
|
12
15
|
this.destroyRef = inject(DestroyRef);
|
|
13
16
|
this.items = input([], /* @ts-ignore */
|
|
14
17
|
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
15
|
-
this.ariaLabel = input(
|
|
18
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
16
19
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
17
20
|
this.itemSelect = output();
|
|
21
|
+
/** Se emite al cerrarse el menú (clic fuera, Escape o al elegir una opción). */
|
|
22
|
+
this.hidden = output();
|
|
18
23
|
this.content = viewChild.required('content');
|
|
19
24
|
this.overlayRef = null;
|
|
20
25
|
this.trigger = null;
|
|
@@ -59,6 +64,7 @@ class CbMenu {
|
|
|
59
64
|
const trigger = this.trigger;
|
|
60
65
|
this.trigger = null;
|
|
61
66
|
trigger?.focus();
|
|
67
|
+
this.hidden.emit();
|
|
62
68
|
}
|
|
63
69
|
activate(item, event) {
|
|
64
70
|
if (item.disabled || item.separator) {
|
|
@@ -91,9 +97,9 @@ class CbMenu {
|
|
|
91
97
|
}
|
|
92
98
|
}
|
|
93
99
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbMenu, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
94
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbMenu, isStandalone: true, selector: "cb-menu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
100
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbMenu, isStandalone: true, selector: "cb-menu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect", hidden: "hidden" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
95
101
|
<ng-template #content>
|
|
96
|
-
<div class="cb-menu__panel" role="menu" [attr.aria-label]="ariaLabel() || null" (click)="onPanelClick($event)">
|
|
102
|
+
<div class="cb-menu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().menu) || null" (click)="onPanelClick($event)">
|
|
97
103
|
@for (item of items(); track $index) {
|
|
98
104
|
@if (item.separator) {
|
|
99
105
|
<div class="cb-menu__separator" role="separator"></div>
|
|
@@ -133,7 +139,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
133
139
|
type: Component,
|
|
134
140
|
args: [{ selector: 'cb-menu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], template: `
|
|
135
141
|
<ng-template #content>
|
|
136
|
-
<div class="cb-menu__panel" role="menu" [attr.aria-label]="ariaLabel() || null" (click)="onPanelClick($event)">
|
|
142
|
+
<div class="cb-menu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().menu) || null" (click)="onPanelClick($event)">
|
|
137
143
|
@for (item of items(); track $index) {
|
|
138
144
|
@if (item.separator) {
|
|
139
145
|
<div class="cb-menu__separator" role="separator"></div>
|
|
@@ -168,7 +174,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
168
174
|
</div>
|
|
169
175
|
</ng-template>
|
|
170
176
|
`, styles: [".cb-menu__panel{min-width:12rem;padding:.375rem;background:var(--cb-color-surface-raised);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-md);box-shadow:var(--cb-shadow-lg);color:var(--cb-color-text);font-family:var(--cb-font-sans)}.cb-menu__item{display:flex;align-items:center;gap:.625rem;width:100%;min-height:2.25rem;padding:.5rem .625rem;border:0;border-radius:var(--cb-radius-sm);background:transparent;color:inherit;font:inherit;text-align:left;text-decoration:none;cursor:pointer}.cb-menu__item:hover:not(:disabled):not([aria-disabled=true]),.cb-menu__item:focus-visible{outline:none;background:var(--cb-color-surface)}.cb-menu__item:disabled,.cb-menu__item[aria-disabled=true]{opacity:.5;cursor:default}.cb-menu__separator{height:1px;margin:.375rem .25rem;background:var(--cb-color-border)}\n"] }]
|
|
171
|
-
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], itemSelect: [{ type: i0.Output, args: ["itemSelect"] }], content: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }] } });
|
|
177
|
+
}], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], itemSelect: [{ type: i0.Output, args: ["itemSelect"] }], hidden: [{ type: i0.Output, args: ["hidden"] }], content: [{ type: i0.ViewChild, args: ['content', { isSignal: true }] }] } });
|
|
172
178
|
|
|
173
179
|
/**
|
|
174
180
|
* Generated bundle index. Do not edit.
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, input, output, signal, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, Injector, input, output, signal, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
4
|
+
import { injectCbTranslation } from '@caribeng/ui';
|
|
4
5
|
|
|
5
6
|
/** Horizontal navigation bar with optional one-level dropdown menus. */
|
|
6
7
|
class CbMenubar {
|
|
7
8
|
constructor() {
|
|
9
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
10
|
+
this.t = injectCbTranslation();
|
|
8
11
|
this.host = inject((ElementRef));
|
|
12
|
+
this.injector = inject(Injector);
|
|
9
13
|
this.items = input([], /* @ts-ignore */
|
|
10
14
|
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
11
|
-
this.ariaLabel = input(
|
|
15
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
12
16
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
13
17
|
this.itemSelect = output();
|
|
14
18
|
this.openIndex = signal(null, /* @ts-ignore */
|
|
@@ -56,7 +60,8 @@ class CbMenubar {
|
|
|
56
60
|
if (event.key === 'ArrowDown' && root && this.items()[rootIndex]?.items?.length) {
|
|
57
61
|
event.preventDefault();
|
|
58
62
|
this.openIndex.set(rootIndex);
|
|
59
|
-
|
|
63
|
+
// El submenú se pinta en el siguiente render (zoneless): se enfoca después.
|
|
64
|
+
afterNextRender(() => this.host.nativeElement.querySelector('.cb-menubar__submenu [role="menuitem"]:not([aria-disabled="true"]):not(:disabled)')?.focus(), { injector: this.injector });
|
|
60
65
|
}
|
|
61
66
|
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && target.closest('.cb-menubar__submenu')) {
|
|
62
67
|
const children = Array.from(target.closest('.cb-menubar__submenu').querySelectorAll('[role="menuitem"]:not([aria-disabled="true"]):not(:disabled)'));
|
|
@@ -68,7 +73,7 @@ class CbMenubar {
|
|
|
68
73
|
}
|
|
69
74
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbMenubar, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
70
75
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbMenubar, isStandalone: true, selector: "cb-menubar", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, host: { listeners: { "keydown": "onKeydown($event)", "document:click": "onDocumentClick($event)" }, classAttribute: "cb-menubar" }, ngImport: i0, template: `
|
|
71
|
-
<nav [attr.aria-label]="ariaLabel()">
|
|
76
|
+
<nav [attr.aria-label]="(ariaLabel() ?? t().mainNavigation)">
|
|
72
77
|
<ul class="cb-menubar__list" role="menubar">
|
|
73
78
|
@for (item of items(); track $index; let i = $index) {
|
|
74
79
|
<li class="cb-menubar__entry" role="none">
|
|
@@ -129,7 +134,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
129
134
|
'(keydown)': 'onKeydown($event)',
|
|
130
135
|
'(document:click)': 'onDocumentClick($event)',
|
|
131
136
|
}, template: `
|
|
132
|
-
<nav [attr.aria-label]="ariaLabel()">
|
|
137
|
+
<nav [attr.aria-label]="(ariaLabel() ?? t().mainNavigation)">
|
|
133
138
|
<ul class="cb-menubar__list" role="menubar">
|
|
134
139
|
@for (item of items(); track $index; let i = $index) {
|
|
135
140
|
<li class="cb-menubar__entry" role="none">
|