@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
|
@@ -1,31 +1,88 @@
|
|
|
1
1
|
import { DOCUMENT } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { inject, model, input, output, effect, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { inject, model, input, output, signal, computed, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
4
|
import * as i1 from '@angular/cdk/a11y';
|
|
5
5
|
import { A11yModule } from '@angular/cdk/a11y';
|
|
6
|
+
import { injectCbTranslation, CbConfirmationService } from '@caribeng/ui';
|
|
7
|
+
import { CbButton } from '@caribeng/ui/button';
|
|
6
8
|
|
|
7
9
|
let nextUid = 0;
|
|
8
10
|
/**
|
|
9
11
|
* Diálogo de confirmación (`role="alertdialog"`) con trampa de foco, cierre con
|
|
10
|
-
* Escape (equivale a cancelar) y restauración del foco al cerrarse.
|
|
12
|
+
* Escape (equivale a cancelar) y restauración del foco al cerrarse. Al abrirse,
|
|
13
|
+
* el foco va al botón de cancelar (la opción segura).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <cb-confirm-dialog
|
|
18
|
+
* [(visible)]="confirmar"
|
|
19
|
+
* header="Eliminar cuenta"
|
|
20
|
+
* message="Esta acción no se puede deshacer."
|
|
21
|
+
* acceptSeverity="danger"
|
|
22
|
+
* (accepted)="eliminar()"
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Con `service` muestra las confirmaciones pedidas desde código con
|
|
27
|
+
* `CbConfirmationService` (como `ConfirmationService` de PrimeNG):
|
|
28
|
+
*
|
|
29
|
+
* ```html
|
|
30
|
+
* <cb-confirm-dialog service />
|
|
31
|
+
* ```
|
|
32
|
+
* ```ts
|
|
33
|
+
* inject(CbConfirmationService).confirm({ message: '¿Eliminar?', accept: () => this.eliminar() });
|
|
34
|
+
* ```
|
|
11
35
|
*/
|
|
12
36
|
class CbConfirmDialog {
|
|
13
37
|
constructor() {
|
|
38
|
+
this.t = injectCbTranslation();
|
|
14
39
|
this.document = inject(DOCUMENT);
|
|
40
|
+
this.confirmation = inject(CbConfirmationService);
|
|
41
|
+
/** Visibilidad (two-way). */
|
|
15
42
|
this.visible = model(false, /* @ts-ignore */
|
|
16
43
|
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
17
|
-
|
|
44
|
+
/** Título. Por defecto, "Confirmar" del idioma activo. */
|
|
45
|
+
this.header = input(undefined, /* @ts-ignore */
|
|
18
46
|
...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
19
|
-
|
|
47
|
+
/** Mensaje. Por defecto, "¿Deseas continuar?" del idioma activo. */
|
|
48
|
+
this.message = input(undefined, /* @ts-ignore */
|
|
20
49
|
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
21
|
-
this.acceptLabel = input(
|
|
50
|
+
this.acceptLabel = input(undefined, /* @ts-ignore */
|
|
22
51
|
...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
|
|
23
|
-
this.rejectLabel = input(
|
|
52
|
+
this.rejectLabel = input(undefined, /* @ts-ignore */
|
|
24
53
|
...(ngDevMode ? [{ debugName: "rejectLabel" }] : /* istanbul ignore next */ []));
|
|
54
|
+
/** Severidad del botón de aceptar (p. ej. `danger` para acciones destructivas). */
|
|
55
|
+
this.acceptSeverity = input('primary', /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "acceptSeverity" }] : /* istanbul ignore next */ []));
|
|
57
|
+
/**
|
|
58
|
+
* Muestra las confirmaciones pedidas con `CbConfirmationService`. Sin él, el
|
|
59
|
+
* componente solo responde a `[(visible)]` (así un diálogo declarativo no se
|
|
60
|
+
* abre con las confirmaciones de otra parte de la app).
|
|
61
|
+
*/
|
|
62
|
+
this.service = input(false, { ...(ngDevMode ? { debugName: "service" } : /* istanbul ignore next */ {}), transform: toBoolean });
|
|
63
|
+
/** Con `service`: atiende solo las confirmaciones con este mismo `key` (o sin key si no se indica). */
|
|
64
|
+
this.key = input(undefined, /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
|
|
25
66
|
this.accepted = output();
|
|
26
67
|
this.rejected = output();
|
|
27
68
|
this.titleId = `cb-confirm-dialog-${++nextUid}-title`;
|
|
28
69
|
this.messageId = `${this.titleId.replace('-title', '')}-message`;
|
|
70
|
+
/** Confirmación pedida con `CbConfirmationService` que se está mostrando. */
|
|
71
|
+
this.active = signal(null, /* @ts-ignore */
|
|
72
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
73
|
+
/** Textos visibles: los de la confirmación del servicio, si la hay; si no, los inputs y el idioma. */
|
|
74
|
+
this.shown = computed(() => {
|
|
75
|
+
const active = this.active();
|
|
76
|
+
const t = this.t();
|
|
77
|
+
return {
|
|
78
|
+
header: active?.header ?? this.header() ?? t.confirm,
|
|
79
|
+
message: active?.message ?? this.message() ?? t.confirmMessage,
|
|
80
|
+
acceptLabel: active?.acceptLabel ?? this.acceptLabel() ?? t.accept,
|
|
81
|
+
rejectLabel: active?.rejectLabel ?? this.rejectLabel() ?? t.cancel,
|
|
82
|
+
acceptSeverity: active?.acceptSeverity ?? this.acceptSeverity(),
|
|
83
|
+
};
|
|
84
|
+
}, /* @ts-ignore */
|
|
85
|
+
...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
|
|
29
86
|
/** Elemento enfocado antes de abrir; recibe el foco de vuelta al cerrar. */
|
|
30
87
|
this.previouslyFocused = null;
|
|
31
88
|
effect(() => {
|
|
@@ -38,6 +95,22 @@ class CbConfirmDialog {
|
|
|
38
95
|
queueMicrotask(() => el.focus?.());
|
|
39
96
|
}
|
|
40
97
|
});
|
|
98
|
+
effect(() => {
|
|
99
|
+
if (!this.service())
|
|
100
|
+
return;
|
|
101
|
+
const request = this.confirmation.request();
|
|
102
|
+
untracked(() => {
|
|
103
|
+
if (request && request.confirmation.key === this.key()) {
|
|
104
|
+
this.active.set(request.confirmation);
|
|
105
|
+
this.visible.set(true);
|
|
106
|
+
}
|
|
107
|
+
else if (!request && this.active()) {
|
|
108
|
+
// Cerrada desde el servicio (close()).
|
|
109
|
+
this.active.set(null);
|
|
110
|
+
this.visible.set(false);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
41
114
|
}
|
|
42
115
|
onEscape() {
|
|
43
116
|
if (this.visible())
|
|
@@ -45,19 +118,76 @@ class CbConfirmDialog {
|
|
|
45
118
|
}
|
|
46
119
|
confirm() {
|
|
47
120
|
this.accepted.emit();
|
|
48
|
-
this.
|
|
121
|
+
this.finish('accept');
|
|
49
122
|
}
|
|
50
123
|
reject() {
|
|
51
124
|
this.rejected.emit();
|
|
125
|
+
this.finish('reject');
|
|
126
|
+
}
|
|
127
|
+
/** Cierra y, si venía del servicio, lo libera y ejecuta su callback (que puede pedir otra confirmación). */
|
|
128
|
+
finish(action) {
|
|
129
|
+
const active = this.active();
|
|
130
|
+
this.active.set(null);
|
|
52
131
|
this.visible.set(false);
|
|
132
|
+
if (active) {
|
|
133
|
+
this.confirmation.close();
|
|
134
|
+
active[action]?.();
|
|
135
|
+
}
|
|
53
136
|
}
|
|
54
137
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmDialog, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
55
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmDialog, isStandalone: true, selector: "cb-confirm-dialog", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }
|
|
138
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmDialog, isStandalone: true, selector: "cb-confirm-dialog", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }, acceptSeverity: { classPropertyName: "acceptSeverity", publicName: "acceptSeverity", isSignal: true, isRequired: false, transformFunction: null }, service: { classPropertyName: "service", publicName: "service", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, ngImport: i0, template: `
|
|
139
|
+
@if (visible()) {
|
|
140
|
+
<div class="cb-confirm-dialog__mask" (click)="reject()">
|
|
141
|
+
<section
|
|
142
|
+
class="cb-confirm-dialog"
|
|
143
|
+
role="alertdialog"
|
|
144
|
+
aria-modal="true"
|
|
145
|
+
[attr.aria-labelledby]="titleId"
|
|
146
|
+
[attr.aria-describedby]="messageId"
|
|
147
|
+
cdkTrapFocus
|
|
148
|
+
cdkTrapFocusAutoCapture
|
|
149
|
+
(click)="$event.stopPropagation()"
|
|
150
|
+
>
|
|
151
|
+
<h2 class="cb-confirm-dialog__title" [id]="titleId">{{ shown().header }}</h2>
|
|
152
|
+
<p class="cb-confirm-dialog__message" [id]="messageId">{{ shown().message }}</p>
|
|
153
|
+
<footer class="cb-confirm-dialog__actions">
|
|
154
|
+
<cb-button variant="text" severity="secondary" (click)="reject()">{{ shown().rejectLabel }}</cb-button>
|
|
155
|
+
<cb-button [severity]="shown().acceptSeverity" (click)="confirm()">{{ shown().acceptLabel }}</cb-button>
|
|
156
|
+
</footer>
|
|
157
|
+
</section>
|
|
158
|
+
</div>
|
|
159
|
+
}
|
|
160
|
+
`, isInline: true, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:var(--cb-space-4, 1rem);background:color-mix(in srgb,#000 40%,transparent)}.cb-confirm-dialog{box-sizing:border-box;width:min(28rem,100%);padding:var(--cb-space-6, 1.5rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:var(--cb-shadow-lg, 0 1rem 3rem rgb(0 0 0 / 20%))}.cb-confirm-dialog__title{margin:0 0 var(--cb-space-2, .5rem);font-size:var(--cb-text-lg, 1.125rem);font-weight:var(--cb-font-weight-semibold, 600);color:var(--cb-color-text-strong)}.cb-confirm-dialog__message{margin:0;color:var(--cb-color-text-muted);line-height:1.55}.cb-confirm-dialog__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem);margin-top:var(--cb-space-6, 1.5rem)}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "component", type: CbButton, selector: "cb-button", inputs: ["severity", "variant", "size", "disabled", "loading", "fullWidth", "type", "ariaLabel", "ariaHaspopup", "ariaExpanded", "ariaControls"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
56
161
|
}
|
|
57
162
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmDialog, decorators: [{
|
|
58
163
|
type: Component,
|
|
59
|
-
args: [{ selector: 'cb-confirm-dialog',
|
|
60
|
-
|
|
164
|
+
args: [{ selector: 'cb-confirm-dialog', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [A11yModule, CbButton], host: { '(document:keydown.escape)': 'onEscape()' }, template: `
|
|
165
|
+
@if (visible()) {
|
|
166
|
+
<div class="cb-confirm-dialog__mask" (click)="reject()">
|
|
167
|
+
<section
|
|
168
|
+
class="cb-confirm-dialog"
|
|
169
|
+
role="alertdialog"
|
|
170
|
+
aria-modal="true"
|
|
171
|
+
[attr.aria-labelledby]="titleId"
|
|
172
|
+
[attr.aria-describedby]="messageId"
|
|
173
|
+
cdkTrapFocus
|
|
174
|
+
cdkTrapFocusAutoCapture
|
|
175
|
+
(click)="$event.stopPropagation()"
|
|
176
|
+
>
|
|
177
|
+
<h2 class="cb-confirm-dialog__title" [id]="titleId">{{ shown().header }}</h2>
|
|
178
|
+
<p class="cb-confirm-dialog__message" [id]="messageId">{{ shown().message }}</p>
|
|
179
|
+
<footer class="cb-confirm-dialog__actions">
|
|
180
|
+
<cb-button variant="text" severity="secondary" (click)="reject()">{{ shown().rejectLabel }}</cb-button>
|
|
181
|
+
<cb-button [severity]="shown().acceptSeverity" (click)="confirm()">{{ shown().acceptLabel }}</cb-button>
|
|
182
|
+
</footer>
|
|
183
|
+
</section>
|
|
184
|
+
</div>
|
|
185
|
+
}
|
|
186
|
+
`, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:var(--cb-space-4, 1rem);background:color-mix(in srgb,#000 40%,transparent)}.cb-confirm-dialog{box-sizing:border-box;width:min(28rem,100%);padding:var(--cb-space-6, 1.5rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:var(--cb-shadow-lg, 0 1rem 3rem rgb(0 0 0 / 20%))}.cb-confirm-dialog__title{margin:0 0 var(--cb-space-2, .5rem);font-size:var(--cb-text-lg, 1.125rem);font-weight:var(--cb-font-weight-semibold, 600);color:var(--cb-color-text-strong)}.cb-confirm-dialog__message{margin:0;color:var(--cb-color-text-muted);line-height:1.55}.cb-confirm-dialog__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem);margin-top:var(--cb-space-6, 1.5rem)}\n"] }]
|
|
187
|
+
}], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], acceptSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptSeverity", required: false }] }], service: [{ type: i0.Input, args: [{ isSignal: true, alias: "service", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
|
|
188
|
+
function toBoolean(value) {
|
|
189
|
+
return value !== false && value != null && `${value}` !== 'false';
|
|
190
|
+
}
|
|
61
191
|
|
|
62
192
|
/**
|
|
63
193
|
* Generated bundle index. Do not edit.
|
|
@@ -1,28 +1,228 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { model, input, output, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { inject, ViewContainerRef, Injector, model, input, output, viewChild, signal, computed, effect, untracked, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { Overlay } from '@angular/cdk/overlay';
|
|
5
|
+
import { TemplatePortal } from '@angular/cdk/portal';
|
|
6
|
+
import { injectCbTranslation, CbConfirmationService } from '@caribeng/ui';
|
|
7
|
+
import { CbButton } from '@caribeng/ui/button';
|
|
3
8
|
|
|
9
|
+
let nextUid = 0;
|
|
10
|
+
/**
|
|
11
|
+
* Confirmación breve de CaribeNG. Ábrela anclada al botón que la dispara con
|
|
12
|
+
* `confirm($event)` (como PrimeNG), o en línea con `[(visible)]`. Escape o un
|
|
13
|
+
* clic fuera la cancelan; el foco vuelve al disparador al cerrarse.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```html
|
|
17
|
+
* <cb-button severity="danger" (click)="borrar.confirm($event)">Eliminar</cb-button>
|
|
18
|
+
* <cb-confirm-popup #borrar message="¿Eliminar este archivo?" (accepted)="eliminar()" />
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Con `service` muestra las confirmaciones de `CbConfirmationService` que traen
|
|
22
|
+
* `target` (como `ConfirmationService` de PrimeNG):
|
|
23
|
+
*
|
|
24
|
+
* ```html
|
|
25
|
+
* <cb-button (click)="borrar($event)">Eliminar</cb-button>
|
|
26
|
+
* <cb-confirm-popup service />
|
|
27
|
+
* ```
|
|
28
|
+
* ```ts
|
|
29
|
+
* borrar(event: Event) {
|
|
30
|
+
* inject(CbConfirmationService).confirm({ target: event.currentTarget, message: '¿Eliminar?', accept: () => this.eliminar() });
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
4
34
|
class CbConfirmPopup {
|
|
5
35
|
constructor() {
|
|
36
|
+
this.t = injectCbTranslation();
|
|
37
|
+
this.overlay = inject(Overlay);
|
|
38
|
+
this.vcr = inject(ViewContainerRef);
|
|
39
|
+
this.injector = inject(Injector);
|
|
40
|
+
this.confirmation = inject(CbConfirmationService);
|
|
41
|
+
this.messageId = `cb-confirm-popup-${++nextUid}-message`;
|
|
42
|
+
/** Visibilidad (two-way). Con `[(visible)]` se muestra en línea. */
|
|
6
43
|
this.visible = model(false, /* @ts-ignore */
|
|
7
44
|
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
8
|
-
|
|
45
|
+
/** Pregunta a confirmar. Por defecto, la del idioma activo. */
|
|
46
|
+
this.message = input(undefined, /* @ts-ignore */
|
|
9
47
|
...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
|
|
10
|
-
this.acceptLabel = input(
|
|
48
|
+
this.acceptLabel = input(undefined, /* @ts-ignore */
|
|
11
49
|
...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
|
|
12
|
-
this.rejectLabel = input(
|
|
50
|
+
this.rejectLabel = input(undefined, /* @ts-ignore */
|
|
13
51
|
...(ngDevMode ? [{ debugName: "rejectLabel" }] : /* istanbul ignore next */ []));
|
|
52
|
+
/** Severidad del botón de aceptar (p. ej. `danger` para acciones destructivas). */
|
|
53
|
+
this.acceptSeverity = input('primary', /* @ts-ignore */
|
|
54
|
+
...(ngDevMode ? [{ debugName: "acceptSeverity" }] : /* istanbul ignore next */ []));
|
|
55
|
+
/**
|
|
56
|
+
* Muestra las confirmaciones pedidas con `CbConfirmationService`. Sin él, el
|
|
57
|
+
* componente solo responde a `[(visible)]` (así un diálogo declarativo no se
|
|
58
|
+
* abre con las confirmaciones de otra parte de la app).
|
|
59
|
+
*/
|
|
60
|
+
this.service = input(false, { ...(ngDevMode ? { debugName: "service" } : /* istanbul ignore next */ {}), transform: toBoolean });
|
|
61
|
+
/** Con `service`: atiende solo las confirmaciones con este mismo `key` (o sin key si no se indica). */
|
|
62
|
+
this.key = input(undefined, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
|
|
14
64
|
this.accepted = output();
|
|
15
65
|
this.rejected = output();
|
|
66
|
+
this.panel = viewChild.required('panel');
|
|
67
|
+
/** Abierta como overlay anclado a un disparador. */
|
|
68
|
+
this.anchored = signal(false, /* @ts-ignore */
|
|
69
|
+
...(ngDevMode ? [{ debugName: "anchored" }] : /* istanbul ignore next */ []));
|
|
70
|
+
this.overlayRef = null;
|
|
71
|
+
this.trigger = null;
|
|
72
|
+
/** Confirmación pedida con `CbConfirmationService` que se está mostrando. */
|
|
73
|
+
this.active = signal(null, /* @ts-ignore */
|
|
74
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
75
|
+
/** Textos visibles: los de la confirmación del servicio, si la hay; si no, los inputs y el idioma. */
|
|
76
|
+
this.shown = computed(() => {
|
|
77
|
+
const active = this.active();
|
|
78
|
+
const t = this.t();
|
|
79
|
+
return {
|
|
80
|
+
message: active?.message ?? this.message() ?? t.confirmMessage,
|
|
81
|
+
acceptLabel: active?.acceptLabel ?? this.acceptLabel() ?? t.accept,
|
|
82
|
+
rejectLabel: active?.rejectLabel ?? this.rejectLabel() ?? t.cancel,
|
|
83
|
+
acceptSeverity: active?.acceptSeverity ?? this.acceptSeverity(),
|
|
84
|
+
};
|
|
85
|
+
}, /* @ts-ignore */
|
|
86
|
+
...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
|
|
87
|
+
this.positions = [
|
|
88
|
+
{ originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 8 },
|
|
89
|
+
{ originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -8 },
|
|
90
|
+
];
|
|
91
|
+
effect(() => {
|
|
92
|
+
if (!this.service())
|
|
93
|
+
return;
|
|
94
|
+
const request = this.confirmation.request();
|
|
95
|
+
untracked(() => {
|
|
96
|
+
const target = request?.confirmation.target;
|
|
97
|
+
if (request && request.confirmation.key === this.key() && target instanceof HTMLElement) {
|
|
98
|
+
// Una nueva petición sustituye a la que estuviera abierta.
|
|
99
|
+
if (this.overlayRef)
|
|
100
|
+
this.dispose();
|
|
101
|
+
this.active.set(request.confirmation);
|
|
102
|
+
this.show(target);
|
|
103
|
+
}
|
|
104
|
+
else if (!request && this.active()) {
|
|
105
|
+
// Cerrada desde el servicio (close()).
|
|
106
|
+
this.active.set(null);
|
|
107
|
+
this.close();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** Abre la confirmación anclada al elemento que recibió el evento. */
|
|
113
|
+
confirm(event) {
|
|
114
|
+
this.show(event.currentTarget);
|
|
115
|
+
}
|
|
116
|
+
/** Abre la confirmación anclada a `target`. */
|
|
117
|
+
show(target) {
|
|
118
|
+
if (this.overlayRef)
|
|
119
|
+
return;
|
|
120
|
+
this.trigger = target;
|
|
121
|
+
this.overlayRef = this.overlay.create({
|
|
122
|
+
positionStrategy: this.overlay.position().flexibleConnectedTo(target).withPositions(this.positions).withPush(true),
|
|
123
|
+
scrollStrategy: this.overlay.scrollStrategies.reposition(),
|
|
124
|
+
hasBackdrop: true,
|
|
125
|
+
backdropClass: 'cdk-overlay-transparent-backdrop',
|
|
126
|
+
});
|
|
127
|
+
this.overlayRef.attach(new TemplatePortal(this.panel(), this.vcr));
|
|
128
|
+
this.overlayRef.backdropClick().subscribe(() => this.reject());
|
|
129
|
+
this.anchored.set(true);
|
|
130
|
+
this.visible.set(true);
|
|
131
|
+
// Foco en la opción segura (cancelar), como en ConfirmDialog.
|
|
132
|
+
afterNextRender(() => this.overlayRef?.overlayElement.querySelector('button')?.focus(), {
|
|
133
|
+
injector: this.injector,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
accept() {
|
|
137
|
+
this.accepted.emit();
|
|
138
|
+
this.finish('accept');
|
|
139
|
+
}
|
|
140
|
+
reject() {
|
|
141
|
+
this.rejected.emit();
|
|
142
|
+
this.finish('reject');
|
|
143
|
+
}
|
|
144
|
+
/** Cierra y, si venía del servicio, lo libera y ejecuta su callback (que puede pedir otra confirmación). */
|
|
145
|
+
finish(action) {
|
|
146
|
+
const active = this.active();
|
|
147
|
+
this.active.set(null);
|
|
148
|
+
this.close();
|
|
149
|
+
if (active) {
|
|
150
|
+
this.confirmation.close();
|
|
151
|
+
active[action]?.();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
close() {
|
|
155
|
+
this.visible.set(false);
|
|
156
|
+
if (this.overlayRef) {
|
|
157
|
+
this.dispose();
|
|
158
|
+
this.trigger?.focus();
|
|
159
|
+
this.trigger = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/** Quita el overlay sin devolver el foco. */
|
|
163
|
+
dispose() {
|
|
164
|
+
this.overlayRef?.dispose();
|
|
165
|
+
this.overlayRef = null;
|
|
166
|
+
this.anchored.set(false);
|
|
16
167
|
}
|
|
17
|
-
confirm() { this.accepted.emit(); this.visible.set(false); }
|
|
18
|
-
reject() { this.rejected.emit(); this.visible.set(false); }
|
|
19
168
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmPopup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
20
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmPopup, isStandalone: true, selector: "cb-confirm-popup", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }
|
|
169
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmPopup, isStandalone: true, selector: "cb-confirm-popup", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }, acceptSeverity: { classPropertyName: "acceptSeverity", publicName: "acceptSeverity", isSignal: true, isRequired: false, transformFunction: null }, service: { classPropertyName: "service", publicName: "service", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, host: { classAttribute: "cb-confirm-popup-host" }, viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
170
|
+
@if (visible() && !anchored()) {
|
|
171
|
+
<ng-container *ngTemplateOutlet="panel" />
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
<ng-template #panel>
|
|
175
|
+
<section
|
|
176
|
+
class="cb-confirm-popup"
|
|
177
|
+
role="alertdialog"
|
|
178
|
+
aria-modal="false"
|
|
179
|
+
[attr.aria-describedby]="messageId"
|
|
180
|
+
(keydown.escape)="reject()"
|
|
181
|
+
>
|
|
182
|
+
<p class="cb-confirm-popup__message" [id]="messageId">{{ shown().message }}</p>
|
|
183
|
+
<div class="cb-confirm-popup__actions">
|
|
184
|
+
<cb-button size="sm" variant="text" severity="secondary" (click)="reject()">
|
|
185
|
+
{{ shown().rejectLabel }}
|
|
186
|
+
</cb-button>
|
|
187
|
+
<cb-button size="sm" [severity]="shown().acceptSeverity" (click)="accept()">
|
|
188
|
+
{{ shown().acceptLabel }}
|
|
189
|
+
</cb-button>
|
|
190
|
+
</div>
|
|
191
|
+
</section>
|
|
192
|
+
</ng-template>
|
|
193
|
+
`, isInline: true, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:15rem;max-width:22rem;padding:var(--cb-space-4, 1rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:0 .75rem 2rem color-mix(in srgb,#000 18%,transparent)}.cb-confirm-popup__message{margin:0 0 var(--cb-space-3, .75rem);font-size:var(--cb-text-sm, .875rem);line-height:1.5}.cb-confirm-popup__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CbButton, selector: "cb-button", inputs: ["severity", "variant", "size", "disabled", "loading", "fullWidth", "type", "ariaLabel", "ariaHaspopup", "ariaExpanded", "ariaControls"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
21
194
|
}
|
|
22
195
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmPopup, decorators: [{
|
|
23
196
|
type: Component,
|
|
24
|
-
args: [{ selector: 'cb-confirm-popup',
|
|
25
|
-
|
|
197
|
+
args: [{ selector: 'cb-confirm-popup', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [NgTemplateOutlet, CbButton], host: { class: 'cb-confirm-popup-host' }, template: `
|
|
198
|
+
@if (visible() && !anchored()) {
|
|
199
|
+
<ng-container *ngTemplateOutlet="panel" />
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
<ng-template #panel>
|
|
203
|
+
<section
|
|
204
|
+
class="cb-confirm-popup"
|
|
205
|
+
role="alertdialog"
|
|
206
|
+
aria-modal="false"
|
|
207
|
+
[attr.aria-describedby]="messageId"
|
|
208
|
+
(keydown.escape)="reject()"
|
|
209
|
+
>
|
|
210
|
+
<p class="cb-confirm-popup__message" [id]="messageId">{{ shown().message }}</p>
|
|
211
|
+
<div class="cb-confirm-popup__actions">
|
|
212
|
+
<cb-button size="sm" variant="text" severity="secondary" (click)="reject()">
|
|
213
|
+
{{ shown().rejectLabel }}
|
|
214
|
+
</cb-button>
|
|
215
|
+
<cb-button size="sm" [severity]="shown().acceptSeverity" (click)="accept()">
|
|
216
|
+
{{ shown().acceptLabel }}
|
|
217
|
+
</cb-button>
|
|
218
|
+
</div>
|
|
219
|
+
</section>
|
|
220
|
+
</ng-template>
|
|
221
|
+
`, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:15rem;max-width:22rem;padding:var(--cb-space-4, 1rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:0 .75rem 2rem color-mix(in srgb,#000 18%,transparent)}.cb-confirm-popup__message{margin:0 0 var(--cb-space-3, .75rem);font-size:var(--cb-text-sm, .875rem);line-height:1.5}.cb-confirm-popup__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem)}\n"] }]
|
|
222
|
+
}], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], acceptSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptSeverity", required: false }] }], service: [{ type: i0.Input, args: [{ isSignal: true, alias: "service", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }] } });
|
|
223
|
+
function toBoolean(value) {
|
|
224
|
+
return value !== false && value != null && `${value}` !== 'false';
|
|
225
|
+
}
|
|
26
226
|
|
|
27
227
|
/**
|
|
28
228
|
* Generated bundle index. Do not edit.
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ViewContainerRef, DestroyRef, input, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { inject, ViewContainerRef, DestroyRef, input, computed, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
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, cbVisibleItems, cbRunCommand } from '@caribeng/ui';
|
|
6
7
|
|
|
7
8
|
/** Context menu that opens at the pointer position on right click. */
|
|
8
9
|
class CbContextMenu {
|
|
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
|
-
|
|
18
|
+
/** Items sin los de `visible: false`. */
|
|
19
|
+
this.visibleItems = computed(() => cbVisibleItems(this.items()), /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "visibleItems" }] : /* istanbul ignore next */ []));
|
|
21
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
16
22
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
17
23
|
this.itemSelect = output();
|
|
18
24
|
this.content = viewChild.required('content');
|
|
@@ -55,6 +61,7 @@ class CbContextMenu {
|
|
|
55
61
|
select(item) {
|
|
56
62
|
if (item.disabled || item.separator)
|
|
57
63
|
return;
|
|
64
|
+
cbRunCommand(item);
|
|
58
65
|
this.itemSelect.emit(item);
|
|
59
66
|
this.close();
|
|
60
67
|
}
|
|
@@ -66,8 +73,8 @@ class CbContextMenu {
|
|
|
66
73
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbContextMenu, isStandalone: true, selector: "cb-contextmenu", 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: { "contextmenu": "open($event)" }, classAttribute: "cb-contextmenu" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
67
74
|
<ng-content />
|
|
68
75
|
<ng-template #content>
|
|
69
|
-
<div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="ariaLabel()">
|
|
70
|
-
@for (item of
|
|
76
|
+
<div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().contextMenu)">
|
|
77
|
+
@for (item of visibleItems(); track $index) {
|
|
71
78
|
@if (item.separator) { <div class="cb-contextmenu__separator" role="separator"></div> }
|
|
72
79
|
@else {
|
|
73
80
|
<button class="cb-contextmenu__item" type="button" role="menuitem" [disabled]="item.disabled" (click)="select(item)">
|
|
@@ -85,8 +92,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
85
92
|
args: [{ selector: 'cb-contextmenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: { class: 'cb-contextmenu', '(contextmenu)': 'open($event)' }, template: `
|
|
86
93
|
<ng-content />
|
|
87
94
|
<ng-template #content>
|
|
88
|
-
<div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="ariaLabel()">
|
|
89
|
-
@for (item of
|
|
95
|
+
<div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().contextMenu)">
|
|
96
|
+
@for (item of visibleItems(); track $index) {
|
|
90
97
|
@if (item.separator) { <div class="cb-contextmenu__separator" role="separator"></div> }
|
|
91
98
|
@else {
|
|
92
99
|
<button class="cb-contextmenu__item" type="button" role="menuitem" [disabled]="item.disabled" (click)="select(item)">
|