@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,476 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, ViewContainerRef, Injector, viewChild, input, model, booleanAttribute, output, computed, signal, 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, cbFormat } from '@caribeng/ui';
|
|
7
|
+
import { CbIcon } from '@caribeng/ui/icon';
|
|
8
|
+
import { CbKbd } from '@caribeng/ui/kbd';
|
|
9
|
+
|
|
10
|
+
/** Minúsculas y sin tildes, carácter a carácter (conserva las posiciones). */
|
|
11
|
+
function cbCommandNormalize(text) {
|
|
12
|
+
let out = '';
|
|
13
|
+
for (const ch of text)
|
|
14
|
+
out += ch.normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase().charAt(0) || ch;
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
function isSubsequence(needle, haystack) {
|
|
18
|
+
let i = 0;
|
|
19
|
+
for (const ch of haystack)
|
|
20
|
+
if (ch === needle[i] && ++i === needle.length)
|
|
21
|
+
return true;
|
|
22
|
+
return needle.length === 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Relevancia de `item` para `query` (0 = no coincide). Prioriza el label que
|
|
26
|
+
* empieza por la búsqueda, luego el inicio de una palabra, el texto contenido,
|
|
27
|
+
* los sinónimos y la descripción, y por último las letras en orden ("cfg" → "Configuración").
|
|
28
|
+
*/
|
|
29
|
+
function cbCommandScore(item, query) {
|
|
30
|
+
const q = cbCommandNormalize(query.trim());
|
|
31
|
+
if (!q)
|
|
32
|
+
return 1;
|
|
33
|
+
const label = cbCommandNormalize(item.label);
|
|
34
|
+
if (label.startsWith(q))
|
|
35
|
+
return 100;
|
|
36
|
+
if (label.split(/[\s\-_/.]+/).some((word) => word.startsWith(q)))
|
|
37
|
+
return 80;
|
|
38
|
+
if (label.includes(q))
|
|
39
|
+
return 60;
|
|
40
|
+
const keywords = (item.keywords ?? []).map(cbCommandNormalize);
|
|
41
|
+
if (keywords.some((k) => k.startsWith(q)))
|
|
42
|
+
return 50;
|
|
43
|
+
if (keywords.some((k) => k.includes(q)))
|
|
44
|
+
return 40;
|
|
45
|
+
if (cbCommandNormalize(item.description ?? '').includes(q) || cbCommandNormalize(item.group ?? '').includes(q))
|
|
46
|
+
return 30;
|
|
47
|
+
if (q.length > 1 && isSubsequence(q, label.replace(/\s+/g, '')))
|
|
48
|
+
return 10;
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Filtra, ordena y agrupa los items. Sin búsqueda conserva el orden original;
|
|
53
|
+
* con búsqueda ordena por relevancia y los grupos siguen a su mejor resultado.
|
|
54
|
+
*/
|
|
55
|
+
function cbCommandFilter(items, query, filter = true) {
|
|
56
|
+
const ranked = items
|
|
57
|
+
.map((item, index) => ({ item, index, score: filter ? cbCommandScore(item, query) : 1 }))
|
|
58
|
+
.filter((entry) => entry.score > 0);
|
|
59
|
+
if (filter && query.trim())
|
|
60
|
+
ranked.sort((a, b) => b.score - a.score || a.index - b.index);
|
|
61
|
+
const groups = new Map();
|
|
62
|
+
for (const { item } of ranked) {
|
|
63
|
+
const key = item.group ?? '';
|
|
64
|
+
if (!groups.has(key))
|
|
65
|
+
groups.set(key, []);
|
|
66
|
+
groups.get(key).push(item);
|
|
67
|
+
}
|
|
68
|
+
return [...groups].map(([label, groupItems]) => ({ label, items: groupItems }));
|
|
69
|
+
}
|
|
70
|
+
/** Partes del label para resaltar la coincidencia contigua con la búsqueda. */
|
|
71
|
+
function cbCommandHighlight(label, query) {
|
|
72
|
+
const q = cbCommandNormalize(query.trim());
|
|
73
|
+
const start = q ? cbCommandNormalize(label).indexOf(q) : -1;
|
|
74
|
+
if (start < 0)
|
|
75
|
+
return [{ text: label, match: false }];
|
|
76
|
+
const chars = [...label];
|
|
77
|
+
const parts = [
|
|
78
|
+
{ text: chars.slice(0, start).join(''), match: false },
|
|
79
|
+
{ text: chars.slice(start, start + [...q].length).join(''), match: true },
|
|
80
|
+
{ text: chars.slice(start + [...q].length).join(''), match: false },
|
|
81
|
+
];
|
|
82
|
+
return parts.filter((p) => p.text);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let nextUid = 0;
|
|
86
|
+
/** Combinación de teclas en texto (`mod+k`, `ctrl+shift+p`, `/`). `mod` acepta ⌘ y Ctrl. */
|
|
87
|
+
function matchesShortcut(event, shortcut) {
|
|
88
|
+
const parts = shortcut.toLowerCase().split('+').map((p) => p.trim()).filter(Boolean);
|
|
89
|
+
const key = parts.pop();
|
|
90
|
+
if (!key || event.key.toLowerCase() !== key)
|
|
91
|
+
return false;
|
|
92
|
+
const wants = new Set(parts);
|
|
93
|
+
if (wants.has('mod')) {
|
|
94
|
+
if (!event.metaKey && !event.ctrlKey)
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
else if (event.ctrlKey !== wants.has('ctrl') || event.metaKey !== wants.has('meta')) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return event.shiftKey === wants.has('shift') && event.altKey === wants.has('alt');
|
|
101
|
+
}
|
|
102
|
+
/** Si el foco está en un campo de texto (para no robar atajos sin modificador como `/`). */
|
|
103
|
+
function isTyping(target) {
|
|
104
|
+
const el = target;
|
|
105
|
+
return !!el && (el.isContentEditable || /^(input|textarea|select)$/i.test(el.tagName));
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Paleta de comandos de CaribeNG (Ctrl/⌘ + K): buscador global de páginas y
|
|
109
|
+
* acciones con teclado. Filtra sin tildes ni mayúsculas, agrupa, resalta la
|
|
110
|
+
* coincidencia y muestra atajos con `cb-kbd`.
|
|
111
|
+
*
|
|
112
|
+
* Accesibilidad: diálogo modal con un combobox (`aria-activedescendant`) que
|
|
113
|
+
* controla una lista de opciones; el foco no sale del campo y vuelve al
|
|
114
|
+
* elemento anterior al cerrar.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```html
|
|
118
|
+
* <cb-command-palette [items]="comandos" (itemSelect)="ir($event.item)" />
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
class CbCommandPalette {
|
|
122
|
+
constructor() {
|
|
123
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
124
|
+
this.t = injectCbTranslation();
|
|
125
|
+
this.overlay = inject(Overlay);
|
|
126
|
+
this.vcr = inject(ViewContainerRef);
|
|
127
|
+
this.document = inject(DOCUMENT);
|
|
128
|
+
this.injector = inject(Injector);
|
|
129
|
+
this.tpl = viewChild.required('tpl');
|
|
130
|
+
this.inputEl = viewChild('input', /* @ts-ignore */
|
|
131
|
+
...(ngDevMode ? [{ debugName: "inputEl" }] : /* istanbul ignore next */ []));
|
|
132
|
+
this.overlayRef = null;
|
|
133
|
+
this.previouslyFocused = null;
|
|
134
|
+
this.listId = `cb-command-${++nextUid}`;
|
|
135
|
+
/** Páginas y acciones. */
|
|
136
|
+
this.items = input([], /* @ts-ignore */
|
|
137
|
+
...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
|
|
138
|
+
/** Abierta o cerrada. */
|
|
139
|
+
this.visible = model(false, /* @ts-ignore */
|
|
140
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
141
|
+
/** Texto buscado (bidireccional, para búsquedas en servidor). */
|
|
142
|
+
this.query = model('', /* @ts-ignore */
|
|
143
|
+
...(ngDevMode ? [{ debugName: "query" }] : /* istanbul ignore next */ []));
|
|
144
|
+
/** Atajo global que abre o cierra la paleta. `''` lo desactiva. */
|
|
145
|
+
this.shortcut = input('mod+k', /* @ts-ignore */
|
|
146
|
+
...(ngDevMode ? [{ debugName: "shortcut" }] : /* istanbul ignore next */ []));
|
|
147
|
+
this.placeholder = input(undefined, /* @ts-ignore */
|
|
148
|
+
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
149
|
+
/** Mensaje sin resultados. Por defecto, "Sin resultados". */
|
|
150
|
+
this.emptyMessage = input(undefined, /* @ts-ignore */
|
|
151
|
+
...(ngDevMode ? [{ debugName: "emptyMessage" }] : /* istanbul ignore next */ []));
|
|
152
|
+
/** Nombre del diálogo. Por defecto, "Paleta de comandos". */
|
|
153
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
154
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
155
|
+
/** Filtra `items` con la búsqueda. Desactívalo si los resultados llegan ya filtrados (servidor). */
|
|
156
|
+
this.filter = input(true, { ...(ngDevMode ? { debugName: "filter" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
157
|
+
/** Muestra "Cargando" mientras no hay resultados. */
|
|
158
|
+
this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
159
|
+
/** Cierra la paleta al elegir un item. */
|
|
160
|
+
this.closeOnSelect = input(true, { ...(ngDevMode ? { debugName: "closeOnSelect" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
161
|
+
/** Item elegido (con clic o Enter). */
|
|
162
|
+
this.itemSelect = output();
|
|
163
|
+
this.label = computed(() => this.ariaLabel() ?? this.t().commandPalette, /* @ts-ignore */
|
|
164
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
165
|
+
this.groups = computed(() => cbCommandFilter(this.items(), this.query(), this.filter()), /* @ts-ignore */
|
|
166
|
+
...(ngDevMode ? [{ debugName: "groups" }] : /* istanbul ignore next */ []));
|
|
167
|
+
/** Resultados en el orden en que se muestran (para el teclado). */
|
|
168
|
+
this.flat = computed(() => this.groups().flatMap((g) => g.items), /* @ts-ignore */
|
|
169
|
+
...(ngDevMode ? [{ debugName: "flat" }] : /* istanbul ignore next */ []));
|
|
170
|
+
this.enabled = computed(() => this.flat().filter((item) => !item.disabled), /* @ts-ignore */
|
|
171
|
+
...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
172
|
+
this.activeItem = signal(null, /* @ts-ignore */
|
|
173
|
+
...(ngDevMode ? [{ debugName: "activeItem" }] : /* istanbul ignore next */ []));
|
|
174
|
+
this.activeOptionId = computed(() => {
|
|
175
|
+
const item = this.activeItem();
|
|
176
|
+
return item ? this.optionId(item) : null;
|
|
177
|
+
}, /* @ts-ignore */
|
|
178
|
+
...(ngDevMode ? [{ debugName: "activeOptionId" }] : /* istanbul ignore next */ []));
|
|
179
|
+
this.announcement = computed(() => this.query().trim() && !this.loading() ? cbFormat(this.t().commandResults, String(this.flat().length)) : '', /* @ts-ignore */
|
|
180
|
+
...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
|
|
181
|
+
effect(() => {
|
|
182
|
+
const open = this.visible();
|
|
183
|
+
untracked(() => {
|
|
184
|
+
if (open && !this.overlayRef)
|
|
185
|
+
this.attach();
|
|
186
|
+
else if (!open && this.overlayRef)
|
|
187
|
+
this.detach();
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
// Al cambiar los resultados, el activo pasa al primero disponible.
|
|
191
|
+
effect(() => {
|
|
192
|
+
const enabled = this.enabled();
|
|
193
|
+
untracked(() => {
|
|
194
|
+
const current = this.activeItem();
|
|
195
|
+
if (!current || !enabled.includes(current))
|
|
196
|
+
this.activeItem.set(enabled[0] ?? null);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
open() {
|
|
201
|
+
this.visible.set(true);
|
|
202
|
+
}
|
|
203
|
+
close() {
|
|
204
|
+
this.visible.set(false);
|
|
205
|
+
}
|
|
206
|
+
toggle() {
|
|
207
|
+
this.visible.update((v) => !v);
|
|
208
|
+
}
|
|
209
|
+
optionId(item) {
|
|
210
|
+
return `${this.listId}-o${this.flat().indexOf(item)}`;
|
|
211
|
+
}
|
|
212
|
+
highlight(item) {
|
|
213
|
+
return this.filter() ? cbCommandHighlight(item.label, this.query()) : [{ text: item.label, match: false }];
|
|
214
|
+
}
|
|
215
|
+
onDocumentKeydown(event) {
|
|
216
|
+
const shortcut = this.shortcut();
|
|
217
|
+
if (!shortcut || !matchesShortcut(event, shortcut))
|
|
218
|
+
return;
|
|
219
|
+
// Un atajo sin modificador (p. ej. "/") no se roba mientras se escribe en otro campo.
|
|
220
|
+
const hasModifier = /(^|\+)(mod|ctrl|meta|alt)\+/i.test(shortcut);
|
|
221
|
+
if (!hasModifier && !this.visible() && isTyping(event.target))
|
|
222
|
+
return;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
this.toggle();
|
|
225
|
+
}
|
|
226
|
+
onInput(event) {
|
|
227
|
+
this.query.set(event.target.value);
|
|
228
|
+
}
|
|
229
|
+
hover(item) {
|
|
230
|
+
if (!item.disabled && this.activeItem() !== item)
|
|
231
|
+
this.activeItem.set(item);
|
|
232
|
+
}
|
|
233
|
+
onKeydown(event) {
|
|
234
|
+
const enabled = this.enabled();
|
|
235
|
+
const index = enabled.indexOf(this.activeItem());
|
|
236
|
+
switch (event.key) {
|
|
237
|
+
case 'ArrowDown':
|
|
238
|
+
case 'ArrowUp': {
|
|
239
|
+
event.preventDefault();
|
|
240
|
+
if (!enabled.length)
|
|
241
|
+
return;
|
|
242
|
+
const step = event.key === 'ArrowDown' ? 1 : -1;
|
|
243
|
+
this.setActive(enabled[(index + step + enabled.length) % enabled.length]);
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
case 'Home':
|
|
247
|
+
case 'End':
|
|
248
|
+
if (!event.ctrlKey && !event.metaKey)
|
|
249
|
+
return;
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
this.setActive(event.key === 'Home' ? enabled[0] : enabled[enabled.length - 1]);
|
|
252
|
+
break;
|
|
253
|
+
case 'Enter': {
|
|
254
|
+
event.preventDefault();
|
|
255
|
+
const item = this.activeItem();
|
|
256
|
+
if (item)
|
|
257
|
+
this.select(item, event);
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
case 'Tab':
|
|
261
|
+
// El foco se queda en el campo: la lista se recorre con las flechas.
|
|
262
|
+
event.preventDefault();
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
/** Elige un item: ejecuta su `command`, emite `itemSelect` y cierra (según `closeOnSelect`). */
|
|
267
|
+
select(item, originalEvent) {
|
|
268
|
+
if (item.disabled)
|
|
269
|
+
return;
|
|
270
|
+
const event = { item, query: this.query(), originalEvent };
|
|
271
|
+
if (this.closeOnSelect())
|
|
272
|
+
this.close();
|
|
273
|
+
item.command?.(event);
|
|
274
|
+
this.itemSelect.emit(event);
|
|
275
|
+
}
|
|
276
|
+
setActive(item) {
|
|
277
|
+
if (!item)
|
|
278
|
+
return;
|
|
279
|
+
this.activeItem.set(item);
|
|
280
|
+
afterNextRender(() => {
|
|
281
|
+
this.document.getElementById(this.optionId(item))?.scrollIntoView?.({ block: 'nearest' });
|
|
282
|
+
}, { injector: this.injector });
|
|
283
|
+
}
|
|
284
|
+
attach() {
|
|
285
|
+
this.previouslyFocused = this.document.activeElement;
|
|
286
|
+
this.query.set('');
|
|
287
|
+
this.overlayRef = this.overlay.create({
|
|
288
|
+
hasBackdrop: true,
|
|
289
|
+
backdropClass: 'cb-dialog-backdrop',
|
|
290
|
+
panelClass: 'cb-command-pane',
|
|
291
|
+
scrollStrategy: this.overlay.scrollStrategies.block(),
|
|
292
|
+
positionStrategy: this.overlay.position().global().centerHorizontally().top('12vh'),
|
|
293
|
+
});
|
|
294
|
+
this.overlayRef.attach(new TemplatePortal(this.tpl(), this.vcr));
|
|
295
|
+
this.overlayRef.backdropClick().subscribe(() => this.close());
|
|
296
|
+
this.overlayRef.keydownEvents().subscribe((event) => {
|
|
297
|
+
if (event.key === 'Escape') {
|
|
298
|
+
event.preventDefault();
|
|
299
|
+
this.close();
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
this.activeItem.set(this.enabled()[0] ?? null);
|
|
303
|
+
afterNextRender(() => this.inputEl()?.nativeElement.focus(), { injector: this.injector });
|
|
304
|
+
}
|
|
305
|
+
detach() {
|
|
306
|
+
this.overlayRef?.dispose();
|
|
307
|
+
this.overlayRef = null;
|
|
308
|
+
const target = this.previouslyFocused;
|
|
309
|
+
this.previouslyFocused = null;
|
|
310
|
+
if (target?.isConnected)
|
|
311
|
+
target.focus();
|
|
312
|
+
}
|
|
313
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbCommandPalette, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
314
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbCommandPalette, isStandalone: true, selector: "cb-command-palette", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, query: { classPropertyName: "query", publicName: "query", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, emptyMessage: { classPropertyName: "emptyMessage", publicName: "emptyMessage", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, filter: { classPropertyName: "filter", publicName: "filter", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, closeOnSelect: { classPropertyName: "closeOnSelect", publicName: "closeOnSelect", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", query: "queryChange", itemSelect: "itemSelect" }, host: { listeners: { "document:keydown": "onDocumentKeydown($event)" }, classAttribute: "cb-command-palette" }, viewQueries: [{ propertyName: "tpl", first: true, predicate: ["tpl"], descendants: true, isSignal: true }, { propertyName: "inputEl", first: true, predicate: ["input"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
315
|
+
<ng-template #tpl>
|
|
316
|
+
<div class="cb-command" role="dialog" aria-modal="true" [attr.aria-label]="label()">
|
|
317
|
+
<div class="cb-command__search">
|
|
318
|
+
<cb-icon name="search" [size]="18" class="cb-command__search-icon" aria-hidden="true" />
|
|
319
|
+
<input
|
|
320
|
+
#input
|
|
321
|
+
class="cb-command__input"
|
|
322
|
+
type="text"
|
|
323
|
+
role="combobox"
|
|
324
|
+
aria-autocomplete="list"
|
|
325
|
+
aria-expanded="true"
|
|
326
|
+
autocomplete="off"
|
|
327
|
+
spellcheck="false"
|
|
328
|
+
[attr.aria-controls]="listId"
|
|
329
|
+
[attr.aria-activedescendant]="activeOptionId()"
|
|
330
|
+
[attr.aria-label]="label()"
|
|
331
|
+
[placeholder]="placeholder() ?? t().commandPlaceholder"
|
|
332
|
+
[value]="query()"
|
|
333
|
+
(input)="onInput($event)"
|
|
334
|
+
(keydown)="onKeydown($event)"
|
|
335
|
+
/>
|
|
336
|
+
</div>
|
|
337
|
+
|
|
338
|
+
<div class="cb-command__list" role="listbox" [id]="listId" [attr.aria-label]="label()">
|
|
339
|
+
@for (group of groups(); track group.label; let g = $index) {
|
|
340
|
+
<div role="group" [attr.aria-labelledby]="group.label ? listId + '-g' + g : null">
|
|
341
|
+
@if (group.label) {
|
|
342
|
+
<div class="cb-command__group" [id]="listId + '-g' + g" aria-hidden="true">{{ group.label }}</div>
|
|
343
|
+
}
|
|
344
|
+
@for (item of group.items; track item.id ?? item.label) {
|
|
345
|
+
<div
|
|
346
|
+
class="cb-command__option"
|
|
347
|
+
role="option"
|
|
348
|
+
[id]="optionId(item)"
|
|
349
|
+
[class.cb-command__option--active]="item === activeItem()"
|
|
350
|
+
[attr.aria-selected]="item === activeItem()"
|
|
351
|
+
[attr.aria-disabled]="item.disabled ? 'true' : null"
|
|
352
|
+
(mousemove)="hover(item)"
|
|
353
|
+
(mousedown)="$event.preventDefault()"
|
|
354
|
+
(click)="select(item, $event)"
|
|
355
|
+
>
|
|
356
|
+
@if (item.icon) {
|
|
357
|
+
<cb-icon class="cb-command__icon" [name]="item.icon" [size]="18" aria-hidden="true" />
|
|
358
|
+
}
|
|
359
|
+
<span class="cb-command__text">
|
|
360
|
+
<!-- En una línea: los saltos de línea añadirían espacios dentro de la palabra resaltada. -->
|
|
361
|
+
<span class="cb-command__label">@for (part of highlight(item); track $index) {@if (part.match) {<mark class="cb-command__match">{{ part.text }}</mark>} @else {<span>{{ part.text }}</span>}}</span>
|
|
362
|
+
@if (item.description) {
|
|
363
|
+
<span class="cb-command__description">{{ item.description }}</span>
|
|
364
|
+
}
|
|
365
|
+
</span>
|
|
366
|
+
@if (item.shortcut?.length) {
|
|
367
|
+
<cb-kbd class="cb-command__shortcut" [keys]="item.shortcut!" size="sm" aria-hidden="true" />
|
|
368
|
+
}
|
|
369
|
+
</div>
|
|
370
|
+
}
|
|
371
|
+
</div>
|
|
372
|
+
}
|
|
373
|
+
@if (!flat().length) {
|
|
374
|
+
<div class="cb-command__empty">{{ loading() ? t().loading : (emptyMessage() ?? t().noResults) }}</div>
|
|
375
|
+
}
|
|
376
|
+
</div>
|
|
377
|
+
|
|
378
|
+
<div class="cb-command__footer" aria-hidden="true">
|
|
379
|
+
<span><cb-kbd [keys]="['up', 'down']" size="sm" /> {{ t().commandNavigate }}</span>
|
|
380
|
+
<span><cb-kbd [keys]="['enter']" size="sm" /> {{ t().commandSelect }}</span>
|
|
381
|
+
<span><cb-kbd size="sm">Esc</cb-kbd> {{ t().close }}</span>
|
|
382
|
+
</div>
|
|
383
|
+
<div class="cb-command__status" role="status">{{ announcement() }}</div>
|
|
384
|
+
</div>
|
|
385
|
+
</ng-template>
|
|
386
|
+
`, isInline: true, styles: [":host{display:contents}.cb-command{display:flex;flex-direction:column;width:min(40rem,calc(100vw - 2rem));max-height:min(32rem,76vh);overflow:hidden;border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, 12px);background:var(--cb-color-surface-raised);box-shadow:var(--cb-shadow-lg);color:var(--cb-color-text);font-family:var(--cb-font-sans)}.cb-command__search{display:flex;align-items:center;gap:.625rem;padding:0 1rem;border-bottom:1px solid var(--cb-color-border)}.cb-command__search-icon{flex:none;color:var(--cb-color-text-muted)}.cb-command__input{flex:1;min-width:0;height:3.25rem;padding:0;border:0;outline:none;background:transparent;color:inherit;font:inherit;font-size:var(--cb-text-base, 1rem)}.cb-command__input::placeholder{color:var(--cb-color-text-muted)}.cb-command__list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:.375rem}.cb-command__group{padding:.625rem .625rem .25rem;color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-command__option{display:flex;align-items:center;gap:.75rem;min-height:2.5rem;padding:.375rem .625rem;border-radius:var(--cb-radius-md, 8px);cursor:pointer;-webkit-user-select:none;user-select:none}.cb-command__option--active{background:var(--cb-color-surface-hover);color:var(--cb-color-text-strong);outline:2px solid transparent;box-shadow:inset 3px 0 0 var(--cb-color-primary)}.cb-command__option[aria-disabled=true]{cursor:not-allowed;opacity:.5}.cb-command__icon{flex:none;color:var(--cb-color-text-muted)}.cb-command__text{display:flex;flex:1;flex-direction:column;min-width:0}.cb-command__label,.cb-command__description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cb-command__description{color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem)}.cb-command__match{background:transparent;color:var(--cb-color-primary);font-weight:var(--cb-font-weight-semibold, 600)}.cb-command__shortcut{flex:none}.cb-command__empty{padding:2rem 1rem;color:var(--cb-color-text-muted);text-align:center}.cb-command__footer{display:flex;flex-wrap:wrap;gap:1rem;padding:.5rem 1rem;border-top:1px solid var(--cb-color-border);color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem)}.cb-command__footer span{display:inline-flex;align-items:center;gap:.375rem}.cb-command__status{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}@media(max-width:480px){.cb-command__footer{display:none}}\n"], dependencies: [{ kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }, { kind: "component", type: CbKbd, selector: "cb-kbd", inputs: ["keys", "platform", "size"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
387
|
+
}
|
|
388
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbCommandPalette, decorators: [{
|
|
389
|
+
type: Component,
|
|
390
|
+
args: [{ selector: 'cb-command-palette', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon, CbKbd], host: {
|
|
391
|
+
class: 'cb-command-palette',
|
|
392
|
+
'(document:keydown)': 'onDocumentKeydown($event)',
|
|
393
|
+
}, template: `
|
|
394
|
+
<ng-template #tpl>
|
|
395
|
+
<div class="cb-command" role="dialog" aria-modal="true" [attr.aria-label]="label()">
|
|
396
|
+
<div class="cb-command__search">
|
|
397
|
+
<cb-icon name="search" [size]="18" class="cb-command__search-icon" aria-hidden="true" />
|
|
398
|
+
<input
|
|
399
|
+
#input
|
|
400
|
+
class="cb-command__input"
|
|
401
|
+
type="text"
|
|
402
|
+
role="combobox"
|
|
403
|
+
aria-autocomplete="list"
|
|
404
|
+
aria-expanded="true"
|
|
405
|
+
autocomplete="off"
|
|
406
|
+
spellcheck="false"
|
|
407
|
+
[attr.aria-controls]="listId"
|
|
408
|
+
[attr.aria-activedescendant]="activeOptionId()"
|
|
409
|
+
[attr.aria-label]="label()"
|
|
410
|
+
[placeholder]="placeholder() ?? t().commandPlaceholder"
|
|
411
|
+
[value]="query()"
|
|
412
|
+
(input)="onInput($event)"
|
|
413
|
+
(keydown)="onKeydown($event)"
|
|
414
|
+
/>
|
|
415
|
+
</div>
|
|
416
|
+
|
|
417
|
+
<div class="cb-command__list" role="listbox" [id]="listId" [attr.aria-label]="label()">
|
|
418
|
+
@for (group of groups(); track group.label; let g = $index) {
|
|
419
|
+
<div role="group" [attr.aria-labelledby]="group.label ? listId + '-g' + g : null">
|
|
420
|
+
@if (group.label) {
|
|
421
|
+
<div class="cb-command__group" [id]="listId + '-g' + g" aria-hidden="true">{{ group.label }}</div>
|
|
422
|
+
}
|
|
423
|
+
@for (item of group.items; track item.id ?? item.label) {
|
|
424
|
+
<div
|
|
425
|
+
class="cb-command__option"
|
|
426
|
+
role="option"
|
|
427
|
+
[id]="optionId(item)"
|
|
428
|
+
[class.cb-command__option--active]="item === activeItem()"
|
|
429
|
+
[attr.aria-selected]="item === activeItem()"
|
|
430
|
+
[attr.aria-disabled]="item.disabled ? 'true' : null"
|
|
431
|
+
(mousemove)="hover(item)"
|
|
432
|
+
(mousedown)="$event.preventDefault()"
|
|
433
|
+
(click)="select(item, $event)"
|
|
434
|
+
>
|
|
435
|
+
@if (item.icon) {
|
|
436
|
+
<cb-icon class="cb-command__icon" [name]="item.icon" [size]="18" aria-hidden="true" />
|
|
437
|
+
}
|
|
438
|
+
<span class="cb-command__text">
|
|
439
|
+
<!-- En una línea: los saltos de línea añadirían espacios dentro de la palabra resaltada. -->
|
|
440
|
+
<span class="cb-command__label">@for (part of highlight(item); track $index) {@if (part.match) {<mark class="cb-command__match">{{ part.text }}</mark>} @else {<span>{{ part.text }}</span>}}</span>
|
|
441
|
+
@if (item.description) {
|
|
442
|
+
<span class="cb-command__description">{{ item.description }}</span>
|
|
443
|
+
}
|
|
444
|
+
</span>
|
|
445
|
+
@if (item.shortcut?.length) {
|
|
446
|
+
<cb-kbd class="cb-command__shortcut" [keys]="item.shortcut!" size="sm" aria-hidden="true" />
|
|
447
|
+
}
|
|
448
|
+
</div>
|
|
449
|
+
}
|
|
450
|
+
</div>
|
|
451
|
+
}
|
|
452
|
+
@if (!flat().length) {
|
|
453
|
+
<div class="cb-command__empty">{{ loading() ? t().loading : (emptyMessage() ?? t().noResults) }}</div>
|
|
454
|
+
}
|
|
455
|
+
</div>
|
|
456
|
+
|
|
457
|
+
<div class="cb-command__footer" aria-hidden="true">
|
|
458
|
+
<span><cb-kbd [keys]="['up', 'down']" size="sm" /> {{ t().commandNavigate }}</span>
|
|
459
|
+
<span><cb-kbd [keys]="['enter']" size="sm" /> {{ t().commandSelect }}</span>
|
|
460
|
+
<span><cb-kbd size="sm">Esc</cb-kbd> {{ t().close }}</span>
|
|
461
|
+
</div>
|
|
462
|
+
<div class="cb-command__status" role="status">{{ announcement() }}</div>
|
|
463
|
+
</div>
|
|
464
|
+
</ng-template>
|
|
465
|
+
`, styles: [":host{display:contents}.cb-command{display:flex;flex-direction:column;width:min(40rem,calc(100vw - 2rem));max-height:min(32rem,76vh);overflow:hidden;border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, 12px);background:var(--cb-color-surface-raised);box-shadow:var(--cb-shadow-lg);color:var(--cb-color-text);font-family:var(--cb-font-sans)}.cb-command__search{display:flex;align-items:center;gap:.625rem;padding:0 1rem;border-bottom:1px solid var(--cb-color-border)}.cb-command__search-icon{flex:none;color:var(--cb-color-text-muted)}.cb-command__input{flex:1;min-width:0;height:3.25rem;padding:0;border:0;outline:none;background:transparent;color:inherit;font:inherit;font-size:var(--cb-text-base, 1rem)}.cb-command__input::placeholder{color:var(--cb-color-text-muted)}.cb-command__list{flex:1;overflow-y:auto;overscroll-behavior:contain;padding:.375rem}.cb-command__group{padding:.625rem .625rem .25rem;color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem);font-weight:var(--cb-font-weight-semibold, 600)}.cb-command__option{display:flex;align-items:center;gap:.75rem;min-height:2.5rem;padding:.375rem .625rem;border-radius:var(--cb-radius-md, 8px);cursor:pointer;-webkit-user-select:none;user-select:none}.cb-command__option--active{background:var(--cb-color-surface-hover);color:var(--cb-color-text-strong);outline:2px solid transparent;box-shadow:inset 3px 0 0 var(--cb-color-primary)}.cb-command__option[aria-disabled=true]{cursor:not-allowed;opacity:.5}.cb-command__icon{flex:none;color:var(--cb-color-text-muted)}.cb-command__text{display:flex;flex:1;flex-direction:column;min-width:0}.cb-command__label,.cb-command__description{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.cb-command__description{color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem)}.cb-command__match{background:transparent;color:var(--cb-color-primary);font-weight:var(--cb-font-weight-semibold, 600)}.cb-command__shortcut{flex:none}.cb-command__empty{padding:2rem 1rem;color:var(--cb-color-text-muted);text-align:center}.cb-command__footer{display:flex;flex-wrap:wrap;gap:1rem;padding:.5rem 1rem;border-top:1px solid var(--cb-color-border);color:var(--cb-color-text-muted);font-size:var(--cb-text-xs, .75rem)}.cb-command__footer span{display:inline-flex;align-items:center;gap:.375rem}.cb-command__status{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}@media(max-width:480px){.cb-command__footer{display:none}}\n"] }]
|
|
466
|
+
}], ctorParameters: () => [], propDecorators: { tpl: [{ type: i0.ViewChild, args: ['tpl', { isSignal: true }] }], inputEl: [{ type: i0.ViewChild, args: ['input', { isSignal: true }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], query: [{ type: i0.Input, args: [{ isSignal: true, alias: "query", required: false }] }, { type: i0.Output, args: ["queryChange"] }], shortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcut", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], emptyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyMessage", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], filter: [{ type: i0.Input, args: [{ isSignal: true, alias: "filter", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], closeOnSelect: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSelect", required: false }] }], itemSelect: [{ type: i0.Output, args: ["itemSelect"] }] } });
|
|
467
|
+
|
|
468
|
+
/*
|
|
469
|
+
* Public API Surface de @caribeng/ui/command-palette
|
|
470
|
+
*/
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Generated bundle index. Do not edit.
|
|
474
|
+
*/
|
|
475
|
+
|
|
476
|
+
export { CbCommandPalette, cbCommandFilter, cbCommandHighlight, cbCommandNormalize, cbCommandScore };
|