@caribeng/ui 22.1.1 → 22.4.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 +134 -12
- package/fesm2022/caribeng-ui-accordion.mjs +4 -4
- package/fesm2022/caribeng-ui-anchor.mjs +169 -0
- package/fesm2022/caribeng-ui-autocomplete.mjs +10 -8
- package/fesm2022/caribeng-ui-avatar.mjs +2 -2
- package/fesm2022/caribeng-ui-avatargroup.mjs +9 -3
- package/fesm2022/caribeng-ui-badge.mjs +8 -2
- package/fesm2022/caribeng-ui-blockui.mjs +12 -4
- package/fesm2022/caribeng-ui-breadcrumb.mjs +17 -7
- 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 +2601 -303
- package/fesm2022/caribeng-ui-chat.mjs +1303 -0
- package/fesm2022/caribeng-ui-chip.mjs +9 -4
- package/fesm2022/caribeng-ui-chips.mjs +9 -5
- package/fesm2022/caribeng-ui-code-block.mjs +332 -0
- package/fesm2022/caribeng-ui-colorpicker.mjs +107 -11
- package/fesm2022/caribeng-ui-command-palette.mjs +476 -0
- package/fesm2022/caribeng-ui-confirmdialog.mjs +140 -10
- package/fesm2022/caribeng-ui-confirmpopup.mjs +209 -9
- package/fesm2022/caribeng-ui-contextmenu.mjs +13 -6
- package/fesm2022/caribeng-ui-copy-button.mjs +230 -0
- package/fesm2022/caribeng-ui-dataview.mjs +214 -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 +58 -15
- package/fesm2022/caribeng-ui-drawer.mjs +17 -9
- package/fesm2022/caribeng-ui-dynamicdialog.mjs +210 -6
- package/fesm2022/caribeng-ui-editor.mjs +4413 -243
- package/fesm2022/caribeng-ui-empty.mjs +80 -0
- package/fesm2022/caribeng-ui-fieldset.mjs +2 -2
- package/fesm2022/caribeng-ui-file-card.mjs +136 -19
- package/fesm2022/caribeng-ui-fileupload.mjs +96 -19
- package/fesm2022/caribeng-ui-floatlabel.mjs +4 -2
- package/fesm2022/caribeng-ui-folder-card.mjs +132 -15
- package/fesm2022/caribeng-ui-galleria.mjs +76 -45
- package/fesm2022/caribeng-ui-image.mjs +52 -29
- package/fesm2022/caribeng-ui-inlinemessage.mjs +2 -2
- 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 +22 -13
- package/fesm2022/caribeng-ui-inputotp.mjs +12 -6
- package/fesm2022/caribeng-ui-kanban.mjs +4612 -0
- package/fesm2022/caribeng-ui-kbd.mjs +122 -0
- package/fesm2022/caribeng-ui-keyfilter.mjs +72 -0
- package/fesm2022/caribeng-ui-listbox.mjs +13 -11
- package/fesm2022/caribeng-ui-megamenu.mjs +228 -32
- package/fesm2022/caribeng-ui-mentions.mjs +495 -0
- package/fesm2022/caribeng-ui-menu.mjs +18 -8
- package/fesm2022/caribeng-ui-menubar.mjs +17 -8
- package/fesm2022/caribeng-ui-message.mjs +13 -7
- 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 +16 -15
- package/fesm2022/caribeng-ui-paginator.mjs +18 -15
- package/fesm2022/caribeng-ui-panel.mjs +11 -8
- package/fesm2022/caribeng-ui-panelmenu.mjs +14 -8
- package/fesm2022/caribeng-ui-password.mjs +8 -6
- package/fesm2022/caribeng-ui-pdfviewer.mjs +1553 -0
- package/fesm2022/caribeng-ui-phone-input.mjs +688 -0
- package/fesm2022/caribeng-ui-picklist.mjs +251 -14
- package/fesm2022/caribeng-ui-pricing.mjs +272 -75
- package/fesm2022/caribeng-ui-qrcode.mjs +564 -0
- 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-ripple.mjs +2 -0
- package/fesm2022/caribeng-ui-scrollpanel.mjs +6 -3
- package/fesm2022/caribeng-ui-scrolltop.mjs +9 -4
- package/fesm2022/caribeng-ui-select.mjs +379 -87
- package/fesm2022/caribeng-ui-selectbutton.mjs +2 -2
- package/fesm2022/caribeng-ui-sidebar.mjs +573 -0
- 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 +17 -7
- package/fesm2022/caribeng-ui-steps.mjs +6 -3
- package/fesm2022/caribeng-ui-table.mjs +716 -84
- package/fesm2022/caribeng-ui-tabmenu.mjs +13 -6
- 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 +113 -20
- 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 +1216 -6
- package/package.json +93 -3
- package/schematics/collection.json +15 -0
- package/schematics/migrate-from-primeng/core-icons.json +1 -0
- package/schematics/migrate-from-primeng/icons.js +269 -0
- package/schematics/migrate-from-primeng/index.js +290 -0
- package/schematics/migrate-from-primeng/mappings/button.js +93 -0
- package/schematics/migrate-from-primeng/mappings/card.js +33 -0
- package/schematics/migrate-from-primeng/mappings/checkbox.js +44 -0
- package/schematics/migrate-from-primeng/mappings/confirm.js +221 -0
- package/schematics/migrate-from-primeng/mappings/datepicker.js +121 -0
- package/schematics/migrate-from-primeng/mappings/dialog.js +84 -0
- package/schematics/migrate-from-primeng/mappings/index.js +88 -0
- package/schematics/migrate-from-primeng/mappings/inputnumber.js +62 -0
- package/schematics/migrate-from-primeng/mappings/inputtext.js +60 -0
- package/schematics/migrate-from-primeng/mappings/menu.js +468 -0
- package/schematics/migrate-from-primeng/mappings/multiselect.js +49 -0
- package/schematics/migrate-from-primeng/mappings/radiobutton.js +22 -0
- package/schematics/migrate-from-primeng/mappings/rules.js +206 -0
- package/schematics/migrate-from-primeng/mappings/select.js +97 -0
- package/schematics/migrate-from-primeng/mappings/service-calls.js +100 -0
- package/schematics/migrate-from-primeng/mappings/table.js +613 -0
- package/schematics/migrate-from-primeng/mappings/tabs.js +225 -0
- package/schematics/migrate-from-primeng/mappings/tag.js +29 -0
- package/schematics/migrate-from-primeng/mappings/textarea.js +44 -0
- package/schematics/migrate-from-primeng/mappings/toast.js +173 -0
- package/schematics/migrate-from-primeng/mappings/toggleswitch.js +37 -0
- package/schematics/migrate-from-primeng/mappings/tooltip.js +44 -0
- package/schematics/migrate-from-primeng/mappings/types.js +10 -0
- package/schematics/migrate-from-primeng/report.js +79 -0
- package/schematics/migrate-from-primeng/schema.js +2 -0
- package/schematics/migrate-from-primeng/schema.json +34 -0
- package/schematics/migrate-from-primeng/template.js +387 -0
- package/schematics/migrate-from-primeng/todo.js +5 -0
- package/schematics/migrate-from-primeng/typescript.js +442 -0
- package/schematics/migrate-from-primeng/workspace.js +117 -0
- package/schematics/ng-add/index.js +140 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +66 -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-badge.d.ts +3 -1
- package/types/caribeng-ui-blockui.d.ts +9 -4
- package/types/caribeng-ui-breadcrumb.d.ts +11 -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 +471 -44
- package/types/caribeng-ui-chat.d.ts +299 -0
- package/types/caribeng-ui-chip.d.ts +6 -0
- package/types/caribeng-ui-chips.d.ts +6 -2
- package/types/caribeng-ui-code-block.d.ts +65 -0
- package/types/caribeng-ui-colorpicker.d.ts +8 -2
- package/types/caribeng-ui-command-palette.d.ts +133 -0
- package/types/caribeng-ui-confirmdialog.d.ts +57 -6
- package/types/caribeng-ui-confirmpopup.d.ts +74 -5
- package/types/caribeng-ui-contextmenu.d.ts +11 -1
- package/types/caribeng-ui-copy-button.d.ts +90 -0
- package/types/caribeng-ui-dataview.d.ts +65 -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 +17 -2
- package/types/caribeng-ui-drawer.d.ts +7 -2
- 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 +28 -3
- package/types/caribeng-ui-fileupload.d.ts +27 -4
- package/types/caribeng-ui-folder-card.d.ts +31 -6
- 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 +8 -1
- package/types/caribeng-ui-inputotp.d.ts +7 -2
- package/types/caribeng-ui-kanban.d.ts +783 -0
- package/types/caribeng-ui-kbd.d.ts +36 -0
- 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 +37 -2
- package/types/caribeng-ui-mentions.d.ts +127 -0
- package/types/caribeng-ui-menu.d.ts +14 -2
- package/types/caribeng-ui-menubar.d.ts +12 -1
- package/types/caribeng-ui-message.d.ts +5 -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 +11 -1
- package/types/caribeng-ui-password.d.ts +4 -2
- package/types/caribeng-ui-pdfviewer.d.ts +258 -0
- package/types/caribeng-ui-phone-input.d.ts +168 -0
- package/types/caribeng-ui-picklist.d.ts +67 -7
- package/types/caribeng-ui-pricing.d.ts +49 -9
- package/types/caribeng-ui-qrcode.d.ts +88 -0
- 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-sidebar.d.ts +167 -0
- 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 +5 -0
- package/types/caribeng-ui-steps.d.ts +4 -1
- package/types/caribeng-ui-table.d.ts +185 -17
- package/types/caribeng-ui-tabmenu.d.ts +11 -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 +22 -3
- 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 +775 -12
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
/** Teclas con nombre: `mod` es ⌘ en Mac y Ctrl en el resto. */
|
|
6
|
+
const NAMED_KEYS = {
|
|
7
|
+
mod: { mac: { text: '⌘', spoken: 'Command' }, other: { text: 'Ctrl' } },
|
|
8
|
+
cmd: { mac: { text: '⌘', spoken: 'Command' }, other: { text: 'Win' } },
|
|
9
|
+
ctrl: { mac: { text: '⌃', spoken: 'Control' }, other: { text: 'Ctrl' } },
|
|
10
|
+
alt: { mac: { text: '⌥', spoken: 'Option' }, other: { text: 'Alt' } },
|
|
11
|
+
shift: { mac: { text: '⇧', spoken: 'Shift' }, other: { text: 'Shift' } },
|
|
12
|
+
enter: { mac: { text: '↵', spoken: 'Enter' }, other: { text: 'Enter' } },
|
|
13
|
+
backspace: { mac: { text: '⌫', spoken: 'Delete' }, other: { text: 'Backspace' } },
|
|
14
|
+
tab: { mac: { text: 'Tab' }, other: { text: 'Tab' } },
|
|
15
|
+
esc: { mac: { text: 'Esc' }, other: { text: 'Esc' } },
|
|
16
|
+
space: { mac: { text: 'Space' }, other: { text: 'Space' } },
|
|
17
|
+
up: { mac: { text: '↑', spoken: 'Up' }, other: { text: '↑', spoken: 'Up' } },
|
|
18
|
+
down: { mac: { text: '↓', spoken: 'Down' }, other: { text: '↓', spoken: 'Down' } },
|
|
19
|
+
left: { mac: { text: '←', spoken: 'Left' }, other: { text: '←', spoken: 'Left' } },
|
|
20
|
+
right: { mac: { text: '→', spoken: 'Right' }, other: { text: '→', spoken: 'Right' } },
|
|
21
|
+
};
|
|
22
|
+
/** Detecta macOS/iOS en el navegador (en SSR devuelve `false`). */
|
|
23
|
+
function isApplePlatform(doc) {
|
|
24
|
+
const nav = doc.defaultView?.navigator;
|
|
25
|
+
const platform = nav?.userAgentData?.platform ?? nav?.platform ?? '';
|
|
26
|
+
return /mac|iphone|ipad|ipod/i.test(platform);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Tecla o atajo de teclado de CaribeNG. Con contenido muestra una tecla; con
|
|
30
|
+
* `keys` muestra la combinación (⌘ K en Mac, Ctrl + K en el resto).
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```html
|
|
34
|
+
* <cb-kbd>Esc</cb-kbd>
|
|
35
|
+
* <cb-kbd [keys]="['mod', 'K']" />
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class CbKbd {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.doc = inject(DOCUMENT);
|
|
41
|
+
/** Teclas de la combinación: nombres (`mod`, `shift`, `alt`, `enter`, `up`…) o texto libre (`K`, `F2`). */
|
|
42
|
+
this.keys = input([], /* @ts-ignore */
|
|
43
|
+
...(ngDevMode ? [{ debugName: "keys" }] : /* istanbul ignore next */ []));
|
|
44
|
+
/** Plataforma a mostrar. `auto` la detecta (⌘ en Mac). */
|
|
45
|
+
this.platform = input('auto', /* @ts-ignore */
|
|
46
|
+
...(ngDevMode ? [{ debugName: "platform" }] : /* istanbul ignore next */ []));
|
|
47
|
+
this.size = input('md', /* @ts-ignore */
|
|
48
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
49
|
+
this.isMac = computed(() => {
|
|
50
|
+
const platform = this.platform();
|
|
51
|
+
return platform === 'auto' ? isApplePlatform(this.doc) : platform === 'mac';
|
|
52
|
+
}, /* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [{ debugName: "isMac" }] : /* istanbul ignore next */ []));
|
|
54
|
+
this.labels = computed(() => {
|
|
55
|
+
const mac = this.isMac();
|
|
56
|
+
return this.keys().map((key) => {
|
|
57
|
+
const named = NAMED_KEYS[key.toLowerCase()];
|
|
58
|
+
if (named)
|
|
59
|
+
return mac ? named.mac : named.other;
|
|
60
|
+
return { text: key.length === 1 ? key.toUpperCase() : key };
|
|
61
|
+
});
|
|
62
|
+
}, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "labels" }] : /* istanbul ignore next */ []));
|
|
64
|
+
}
|
|
65
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbKbd, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
66
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbKbd, isStandalone: true, selector: "cb-kbd", inputs: { keys: { classPropertyName: "keys", publicName: "keys", isSignal: true, isRequired: false, transformFunction: null }, platform: { classPropertyName: "platform", publicName: "platform", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cb-kbd--sm": "size() === 'sm'" }, classAttribute: "cb-kbd" }, ngImport: i0, template: `
|
|
67
|
+
@if (labels().length) {
|
|
68
|
+
<kbd class="cb-kbd__combo">
|
|
69
|
+
@for (key of labels(); track $index) {
|
|
70
|
+
@if (!$first && !isMac()) {
|
|
71
|
+
<span class="cb-kbd__plus" aria-hidden="true">+</span>
|
|
72
|
+
}
|
|
73
|
+
<kbd class="cb-kbd__key">
|
|
74
|
+
@if (key.spoken) {
|
|
75
|
+
<span aria-hidden="true">{{ key.text }}</span><span class="cb-kbd__sr">{{ key.spoken }}</span>
|
|
76
|
+
} @else {
|
|
77
|
+
{{ key.text }}
|
|
78
|
+
}
|
|
79
|
+
</kbd>
|
|
80
|
+
}
|
|
81
|
+
</kbd>
|
|
82
|
+
} @else {
|
|
83
|
+
<kbd class="cb-kbd__key"><ng-content /></kbd>
|
|
84
|
+
}
|
|
85
|
+
`, isInline: true, styles: [":host{display:inline-flex;vertical-align:middle;font-size:var(--cb-text-xs, .75rem)}.cb-kbd__combo{display:inline-flex;align-items:center;gap:.25em;font:inherit}.cb-kbd__key{display:inline-flex;align-items:center;justify-content:center;min-width:1.75em;height:1.75em;padding:0 .4em;border:1px solid var(--cb-color-border-strong);border-bottom-width:2px;border-radius:var(--cb-radius-sm, 4px);background:var(--cb-color-surface-raised);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-size:inherit;font-weight:var(--cb-font-weight-medium, 500);line-height:1;white-space:nowrap}.cb-kbd__plus{color:var(--cb-color-text-muted)}:host(.cb-kbd--sm){font-size:.6875rem}.cb-kbd__sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
86
|
+
}
|
|
87
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbKbd, decorators: [{
|
|
88
|
+
type: Component,
|
|
89
|
+
args: [{ selector: 'cb-kbd', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, host: {
|
|
90
|
+
class: 'cb-kbd',
|
|
91
|
+
'[class.cb-kbd--sm]': "size() === 'sm'",
|
|
92
|
+
}, template: `
|
|
93
|
+
@if (labels().length) {
|
|
94
|
+
<kbd class="cb-kbd__combo">
|
|
95
|
+
@for (key of labels(); track $index) {
|
|
96
|
+
@if (!$first && !isMac()) {
|
|
97
|
+
<span class="cb-kbd__plus" aria-hidden="true">+</span>
|
|
98
|
+
}
|
|
99
|
+
<kbd class="cb-kbd__key">
|
|
100
|
+
@if (key.spoken) {
|
|
101
|
+
<span aria-hidden="true">{{ key.text }}</span><span class="cb-kbd__sr">{{ key.spoken }}</span>
|
|
102
|
+
} @else {
|
|
103
|
+
{{ key.text }}
|
|
104
|
+
}
|
|
105
|
+
</kbd>
|
|
106
|
+
}
|
|
107
|
+
</kbd>
|
|
108
|
+
} @else {
|
|
109
|
+
<kbd class="cb-kbd__key"><ng-content /></kbd>
|
|
110
|
+
}
|
|
111
|
+
`, styles: [":host{display:inline-flex;vertical-align:middle;font-size:var(--cb-text-xs, .75rem)}.cb-kbd__combo{display:inline-flex;align-items:center;gap:.25em;font:inherit}.cb-kbd__key{display:inline-flex;align-items:center;justify-content:center;min-width:1.75em;height:1.75em;padding:0 .4em;border:1px solid var(--cb-color-border-strong);border-bottom-width:2px;border-radius:var(--cb-radius-sm, 4px);background:var(--cb-color-surface-raised);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-size:inherit;font-weight:var(--cb-font-weight-medium, 500);line-height:1;white-space:nowrap}.cb-kbd__plus{color:var(--cb-color-text-muted)}:host(.cb-kbd--sm){font-size:.6875rem}.cb-kbd__sr{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"] }]
|
|
112
|
+
}], propDecorators: { keys: [{ type: i0.Input, args: [{ isSignal: true, alias: "keys", required: false }] }], platform: [{ type: i0.Input, args: [{ isSignal: true, alias: "platform", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }] } });
|
|
113
|
+
|
|
114
|
+
/*
|
|
115
|
+
* Public API Surface de @caribeng/ui/kbd
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Generated bundle index. Do not edit.
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
export { CbKbd };
|
|
@@ -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,189 @@
|
|
|
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, computed, output, signal, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { injectCbTranslation, cbVisibleItems, cbRunCommand } 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
|
+
/** Items sin los de `visible: false`. */
|
|
28
|
+
this.visibleItems = computed(() => cbVisibleItems(this.items()), /* @ts-ignore */
|
|
29
|
+
...(ngDevMode ? [{ debugName: "visibleItems" }] : /* istanbul ignore next */ []));
|
|
30
|
+
/** Nombre accesible de la navegación. Por defecto, "Categorías" del idioma activo. */
|
|
31
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
12
32
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
33
|
+
/** Se emite al elegir un enlace. */
|
|
13
34
|
this.itemSelect = output();
|
|
14
35
|
this.openIndex = signal(null, /* @ts-ignore */
|
|
15
36
|
...(ngDevMode ? [{ debugName: "openIndex" }] : /* istanbul ignore next */ []));
|
|
16
37
|
}
|
|
17
|
-
toggle(index) {
|
|
18
|
-
|
|
38
|
+
toggle(index) {
|
|
39
|
+
this.openIndex.update((current) => (current === index ? null : index));
|
|
40
|
+
}
|
|
41
|
+
select(link) {
|
|
42
|
+
if (link.disabled)
|
|
43
|
+
return;
|
|
44
|
+
cbRunCommand(link);
|
|
19
45
|
this.itemSelect.emit(link);
|
|
20
46
|
this.close();
|
|
21
|
-
}
|
|
22
|
-
close() {
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
}
|
|
48
|
+
close() {
|
|
49
|
+
this.openIndex.set(null);
|
|
50
|
+
}
|
|
51
|
+
onDocumentClick(event) {
|
|
52
|
+
if (!this.host.nativeElement.contains(event.target))
|
|
53
|
+
this.close();
|
|
54
|
+
}
|
|
55
|
+
/** Al salir el foco del componente (p. ej. con Tab), se cierra el panel. */
|
|
56
|
+
onFocusOut(event) {
|
|
57
|
+
const next = event.relatedTarget;
|
|
58
|
+
if (next && !this.host.nativeElement.contains(next))
|
|
59
|
+
this.close();
|
|
60
|
+
}
|
|
61
|
+
onTriggerKeydown(event, index) {
|
|
62
|
+
const count = this.visibleItems().length;
|
|
63
|
+
switch (event.key) {
|
|
64
|
+
case 'ArrowRight':
|
|
65
|
+
this.focusTrigger((index + 1) % count);
|
|
66
|
+
break;
|
|
67
|
+
case 'ArrowLeft':
|
|
68
|
+
this.focusTrigger((index - 1 + count) % count);
|
|
69
|
+
break;
|
|
70
|
+
case 'Home':
|
|
71
|
+
this.focusTrigger(0);
|
|
72
|
+
break;
|
|
73
|
+
case 'End':
|
|
74
|
+
this.focusTrigger(count - 1);
|
|
75
|
+
break;
|
|
76
|
+
case 'ArrowDown':
|
|
77
|
+
this.openIndex.set(index);
|
|
78
|
+
afterNextRender(() => this.links()[0]?.focus(), { injector: this.injector });
|
|
79
|
+
break;
|
|
80
|
+
case 'Escape':
|
|
81
|
+
this.close();
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
}
|
|
88
|
+
onPanelKeydown(event) {
|
|
89
|
+
const links = this.links();
|
|
90
|
+
const current = links.indexOf(document.activeElement);
|
|
91
|
+
switch (event.key) {
|
|
92
|
+
case 'ArrowDown':
|
|
93
|
+
links[Math.min(links.length - 1, current + 1)]?.focus();
|
|
94
|
+
break;
|
|
95
|
+
case 'ArrowUp':
|
|
96
|
+
if (current <= 0)
|
|
97
|
+
this.focusTrigger(this.openIndex());
|
|
98
|
+
else
|
|
99
|
+
links[current - 1].focus();
|
|
100
|
+
break;
|
|
101
|
+
case 'Home':
|
|
102
|
+
links[0]?.focus();
|
|
103
|
+
break;
|
|
104
|
+
case 'End':
|
|
105
|
+
links[links.length - 1]?.focus();
|
|
106
|
+
break;
|
|
107
|
+
case 'Escape': {
|
|
108
|
+
const index = this.openIndex();
|
|
109
|
+
this.close();
|
|
110
|
+
this.focusTrigger(index);
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
}
|
|
118
|
+
/** Enlaces navegables del panel abierto, en orden de lectura. */
|
|
119
|
+
links() {
|
|
120
|
+
return Array.from(this.host.nativeElement.querySelectorAll('.cb-megamenu__panel .cb-megamenu__link:not([disabled])'));
|
|
121
|
+
}
|
|
122
|
+
focusTrigger(index) {
|
|
123
|
+
this.host.nativeElement.querySelectorAll('.cb-megamenu__trigger')[index]?.focus();
|
|
124
|
+
}
|
|
25
125
|
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()">
|
|
126
|
+
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: `
|
|
127
|
+
<nav [attr.aria-label]="ariaLabel() ?? t().categories">
|
|
28
128
|
<ul class="cb-megamenu__bar">
|
|
29
|
-
@for (item of
|
|
30
|
-
<li
|
|
129
|
+
@for (item of visibleItems(); track $index; let i = $index) {
|
|
130
|
+
<li>
|
|
131
|
+
<button
|
|
132
|
+
class="cb-megamenu__trigger"
|
|
133
|
+
type="button"
|
|
134
|
+
[attr.aria-expanded]="openIndex() === i"
|
|
135
|
+
[attr.aria-controls]="openIndex() === i ? panelId : null"
|
|
136
|
+
(click)="toggle(i)"
|
|
137
|
+
(keydown)="onTriggerKeydown($event, i)"
|
|
138
|
+
>
|
|
139
|
+
@if (item.icon) {
|
|
140
|
+
<cb-icon [name]="item.icon" [size]="16" aria-hidden="true" />
|
|
141
|
+
}
|
|
142
|
+
{{ item.label }}
|
|
143
|
+
<cb-icon
|
|
144
|
+
class="cb-megamenu__chevron"
|
|
145
|
+
[class.cb-megamenu__chevron--open]="openIndex() === i"
|
|
146
|
+
name="chevron-down"
|
|
147
|
+
[size]="14"
|
|
148
|
+
aria-hidden="true"
|
|
149
|
+
/>
|
|
150
|
+
</button>
|
|
151
|
+
</li>
|
|
31
152
|
}
|
|
32
153
|
</ul>
|
|
33
154
|
@if (openIndex() !== null) {
|
|
34
|
-
<section
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
155
|
+
<section
|
|
156
|
+
class="cb-megamenu__panel"
|
|
157
|
+
[id]="panelId"
|
|
158
|
+
role="region"
|
|
159
|
+
[attr.aria-label]="visibleItems()[openIndex()!].label"
|
|
160
|
+
(keydown)="onPanelKeydown($event)"
|
|
161
|
+
>
|
|
162
|
+
@for (group of visibleItems()[openIndex()!].groups; track $index) {
|
|
163
|
+
<div class="cb-megamenu__group">
|
|
164
|
+
<h3>{{ group.label }}</h3>
|
|
165
|
+
<ul>
|
|
166
|
+
@for (link of group.items; track $index) {
|
|
167
|
+
<li>
|
|
168
|
+
@if (link.url && !link.disabled) {
|
|
169
|
+
<a class="cb-megamenu__link" [href]="link.url" (click)="select(link)">
|
|
170
|
+
@if (link.icon) {
|
|
171
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
172
|
+
}
|
|
173
|
+
{{ link.label }}
|
|
174
|
+
</a>
|
|
175
|
+
} @else {
|
|
176
|
+
<button class="cb-megamenu__link" type="button" [disabled]="link.disabled" (click)="select(link)">
|
|
177
|
+
@if (link.icon) {
|
|
178
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
179
|
+
}
|
|
180
|
+
{{ link.label }}
|
|
181
|
+
</button>
|
|
182
|
+
}
|
|
183
|
+
</li>
|
|
184
|
+
}
|
|
185
|
+
</ul>
|
|
186
|
+
</div>
|
|
41
187
|
}
|
|
42
188
|
</section>
|
|
43
189
|
}
|
|
@@ -46,21 +192,71 @@ class CbMegaMenu {
|
|
|
46
192
|
}
|
|
47
193
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbMegaMenu, decorators: [{
|
|
48
194
|
type: Component,
|
|
49
|
-
args: [{ selector: 'cb-megamenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: {
|
|
50
|
-
|
|
195
|
+
args: [{ selector: 'cb-megamenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: {
|
|
196
|
+
class: 'cb-megamenu',
|
|
197
|
+
'(document:click)': 'onDocumentClick($event)',
|
|
198
|
+
'(focusout)': 'onFocusOut($event)',
|
|
199
|
+
}, template: `
|
|
200
|
+
<nav [attr.aria-label]="ariaLabel() ?? t().categories">
|
|
51
201
|
<ul class="cb-megamenu__bar">
|
|
52
|
-
@for (item of
|
|
53
|
-
<li
|
|
202
|
+
@for (item of visibleItems(); track $index; let i = $index) {
|
|
203
|
+
<li>
|
|
204
|
+
<button
|
|
205
|
+
class="cb-megamenu__trigger"
|
|
206
|
+
type="button"
|
|
207
|
+
[attr.aria-expanded]="openIndex() === i"
|
|
208
|
+
[attr.aria-controls]="openIndex() === i ? panelId : null"
|
|
209
|
+
(click)="toggle(i)"
|
|
210
|
+
(keydown)="onTriggerKeydown($event, i)"
|
|
211
|
+
>
|
|
212
|
+
@if (item.icon) {
|
|
213
|
+
<cb-icon [name]="item.icon" [size]="16" aria-hidden="true" />
|
|
214
|
+
}
|
|
215
|
+
{{ item.label }}
|
|
216
|
+
<cb-icon
|
|
217
|
+
class="cb-megamenu__chevron"
|
|
218
|
+
[class.cb-megamenu__chevron--open]="openIndex() === i"
|
|
219
|
+
name="chevron-down"
|
|
220
|
+
[size]="14"
|
|
221
|
+
aria-hidden="true"
|
|
222
|
+
/>
|
|
223
|
+
</button>
|
|
224
|
+
</li>
|
|
54
225
|
}
|
|
55
226
|
</ul>
|
|
56
227
|
@if (openIndex() !== null) {
|
|
57
|
-
<section
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
228
|
+
<section
|
|
229
|
+
class="cb-megamenu__panel"
|
|
230
|
+
[id]="panelId"
|
|
231
|
+
role="region"
|
|
232
|
+
[attr.aria-label]="visibleItems()[openIndex()!].label"
|
|
233
|
+
(keydown)="onPanelKeydown($event)"
|
|
234
|
+
>
|
|
235
|
+
@for (group of visibleItems()[openIndex()!].groups; track $index) {
|
|
236
|
+
<div class="cb-megamenu__group">
|
|
237
|
+
<h3>{{ group.label }}</h3>
|
|
238
|
+
<ul>
|
|
239
|
+
@for (link of group.items; track $index) {
|
|
240
|
+
<li>
|
|
241
|
+
@if (link.url && !link.disabled) {
|
|
242
|
+
<a class="cb-megamenu__link" [href]="link.url" (click)="select(link)">
|
|
243
|
+
@if (link.icon) {
|
|
244
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
245
|
+
}
|
|
246
|
+
{{ link.label }}
|
|
247
|
+
</a>
|
|
248
|
+
} @else {
|
|
249
|
+
<button class="cb-megamenu__link" type="button" [disabled]="link.disabled" (click)="select(link)">
|
|
250
|
+
@if (link.icon) {
|
|
251
|
+
<cb-icon [name]="link.icon" [size]="16" aria-hidden="true" />
|
|
252
|
+
}
|
|
253
|
+
{{ link.label }}
|
|
254
|
+
</button>
|
|
255
|
+
}
|
|
256
|
+
</li>
|
|
257
|
+
}
|
|
258
|
+
</ul>
|
|
259
|
+
</div>
|
|
64
260
|
}
|
|
65
261
|
</section>
|
|
66
262
|
}
|