@caribeng/ui 22.1.1 → 22.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -8
- package/fesm2022/caribeng-ui-accordion.mjs +2 -2
- package/fesm2022/caribeng-ui-anchor.mjs +169 -0
- package/fesm2022/caribeng-ui-autocomplete.mjs +10 -8
- package/fesm2022/caribeng-ui-avatargroup.mjs +9 -3
- package/fesm2022/caribeng-ui-blockui.mjs +12 -4
- package/fesm2022/caribeng-ui-breadcrumb.mjs +5 -2
- package/fesm2022/caribeng-ui-button.mjs +22 -2
- package/fesm2022/caribeng-ui-caribe-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-animation-lottie.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-button-group.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-calendar.mjs +11 -6
- package/fesm2022/caribeng-ui-caribe-card-content.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-card-move.mjs +29 -7
- package/fesm2022/caribeng-ui-caribe-card-select.mjs +56 -14
- package/fesm2022/caribeng-ui-caribe-circle-loading.mjs +10 -7
- package/fesm2022/caribeng-ui-caribe-coachmark.mjs +42 -19
- package/fesm2022/caribeng-ui-caribe-data-table.mjs +15 -9
- package/fesm2022/caribeng-ui-caribe-dots-indicator.mjs +38 -5
- package/fesm2022/caribeng-ui-caribe-expansion-panel.mjs +16 -5
- package/fesm2022/caribeng-ui-caribe-fab-menu.mjs +56 -7
- package/fesm2022/caribeng-ui-caribe-file-download.mjs +68 -27
- package/fesm2022/caribeng-ui-caribe-file-select.mjs +22 -17
- package/fesm2022/caribeng-ui-caribe-float-menu.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-footer.mjs +8 -4
- package/fesm2022/caribeng-ui-caribe-header.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-icon-button.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-illustration.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-inline-alert.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-input-search.mjs +14 -10
- package/fesm2022/caribeng-ui-caribe-input-select.mjs +12 -10
- package/fesm2022/caribeng-ui-caribe-input-token.mjs +61 -11
- package/fesm2022/caribeng-ui-caribe-link.mjs +7 -2
- package/fesm2022/caribeng-ui-caribe-loader.mjs +8 -5
- package/fesm2022/caribeng-ui-caribe-modal.mjs +32 -16
- package/fesm2022/caribeng-ui-caribe-off-canvas.mjs +26 -12
- package/fesm2022/caribeng-ui-caribe-onboarding.mjs +44 -19
- package/fesm2022/caribeng-ui-caribe-pictogram.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-pop-over.mjs +34 -10
- package/fesm2022/caribeng-ui-caribe-preloader.mjs +9 -6
- package/fesm2022/caribeng-ui-caribe-progress-bar.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-shortcut.mjs +8 -3
- package/fesm2022/caribeng-ui-caribe-step-indicator.mjs +12 -5
- package/fesm2022/caribeng-ui-caribe-stroke.mjs +6 -3
- package/fesm2022/caribeng-ui-caribe-switch.mjs +5 -3
- package/fesm2022/caribeng-ui-caribe-tag-button.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-tracker.mjs +5 -2
- package/fesm2022/caribeng-ui-caribe-transaction-status.mjs +1 -1
- package/fesm2022/caribeng-ui-caribe-voucher.mjs +11 -8
- package/fesm2022/caribeng-ui-carousel.mjs +49 -14
- package/fesm2022/caribeng-ui-cascadeselect.mjs +22 -8
- package/fesm2022/caribeng-ui-chart.mjs +2598 -303
- package/fesm2022/caribeng-ui-chip.mjs +9 -4
- package/fesm2022/caribeng-ui-chips.mjs +9 -5
- package/fesm2022/caribeng-ui-colorpicker.mjs +9 -7
- package/fesm2022/caribeng-ui-confirmdialog.mjs +74 -9
- package/fesm2022/caribeng-ui-confirmpopup.mjs +134 -9
- package/fesm2022/caribeng-ui-contextmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-dataview.mjs +211 -6
- package/fesm2022/caribeng-ui-datepicker.mjs +1630 -393
- package/fesm2022/caribeng-ui-descriptions.mjs +124 -0
- package/fesm2022/caribeng-ui-dialog.mjs +10 -7
- package/fesm2022/caribeng-ui-dock.mjs +6 -3
- package/fesm2022/caribeng-ui-drawer.mjs +10 -7
- package/fesm2022/caribeng-ui-dynamicdialog.mjs +210 -6
- package/fesm2022/caribeng-ui-editor.mjs +4392 -243
- package/fesm2022/caribeng-ui-empty.mjs +80 -0
- package/fesm2022/caribeng-ui-file-card.mjs +2 -2
- package/fesm2022/caribeng-ui-fileupload.mjs +96 -19
- package/fesm2022/caribeng-ui-floatlabel.mjs +4 -2
- package/fesm2022/caribeng-ui-folder-card.mjs +10 -3
- package/fesm2022/caribeng-ui-galleria.mjs +76 -45
- package/fesm2022/caribeng-ui-image.mjs +52 -29
- package/fesm2022/caribeng-ui-inplace.mjs +22 -6
- package/fesm2022/caribeng-ui-input-number.mjs +9 -7
- package/fesm2022/caribeng-ui-inputgroup.mjs +2 -2
- package/fesm2022/caribeng-ui-inputmask.mjs +14 -11
- package/fesm2022/caribeng-ui-inputotp.mjs +12 -6
- package/fesm2022/caribeng-ui-keyfilter.mjs +72 -0
- package/fesm2022/caribeng-ui-listbox.mjs +13 -11
- package/fesm2022/caribeng-ui-megamenu.mjs +222 -30
- package/fesm2022/caribeng-ui-menu.mjs +11 -5
- package/fesm2022/caribeng-ui-menubar.mjs +10 -5
- package/fesm2022/caribeng-ui-message.mjs +7 -4
- package/fesm2022/caribeng-ui-metergroup.mjs +29 -11
- package/fesm2022/caribeng-ui-multiselect.mjs +399 -97
- package/fesm2022/caribeng-ui-orderlist.mjs +230 -11
- package/fesm2022/caribeng-ui-organizationchart.mjs +12 -7
- package/fesm2022/caribeng-ui-paginator.mjs +18 -15
- package/fesm2022/caribeng-ui-panel.mjs +5 -2
- package/fesm2022/caribeng-ui-panelmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-password.mjs +8 -6
- package/fesm2022/caribeng-ui-pdfviewer.mjs +1553 -0
- package/fesm2022/caribeng-ui-picklist.mjs +251 -14
- package/fesm2022/caribeng-ui-pricing.mjs +17 -14
- package/fesm2022/caribeng-ui-rating.mjs +7 -3
- package/fesm2022/caribeng-ui-repeater.mjs +223 -0
- package/fesm2022/caribeng-ui-result.mjs +91 -0
- package/fesm2022/caribeng-ui-scrollpanel.mjs +6 -3
- package/fesm2022/caribeng-ui-scrolltop.mjs +6 -3
- package/fesm2022/caribeng-ui-select.mjs +379 -87
- package/fesm2022/caribeng-ui-selectbutton.mjs +2 -2
- package/fesm2022/caribeng-ui-slider.mjs +171 -75
- package/fesm2022/caribeng-ui-speeddial.mjs +7 -4
- package/fesm2022/caribeng-ui-spinner.mjs +5 -2
- package/fesm2022/caribeng-ui-splitbutton.mjs +163 -0
- package/fesm2022/caribeng-ui-splitter.mjs +5 -2
- package/fesm2022/caribeng-ui-statistic.mjs +183 -0
- package/fesm2022/caribeng-ui-stepper.mjs +8 -5
- package/fesm2022/caribeng-ui-steps.mjs +6 -3
- package/fesm2022/caribeng-ui-table.mjs +708 -82
- package/fesm2022/caribeng-ui-tabmenu.mjs +6 -3
- package/fesm2022/caribeng-ui-tag.mjs +2 -2
- package/fesm2022/caribeng-ui-terminal.mjs +45 -9
- package/fesm2022/caribeng-ui-themetoggle.mjs +82 -0
- package/fesm2022/caribeng-ui-tieredmenu.mjs +9 -6
- package/fesm2022/caribeng-ui-timeline.mjs +175 -6
- package/fesm2022/caribeng-ui-toast.mjs +7 -4
- package/fesm2022/caribeng-ui-togglebutton.mjs +8 -6
- package/fesm2022/caribeng-ui-toolbar.mjs +6 -3
- package/fesm2022/caribeng-ui-tree.mjs +302 -6
- package/fesm2022/caribeng-ui-treeselect.mjs +26 -10
- package/fesm2022/caribeng-ui-treetable.mjs +269 -6
- package/fesm2022/caribeng-ui-virtualscroller.mjs +123 -10
- package/fesm2022/caribeng-ui.mjs +829 -6
- package/package.json +53 -3
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +125 -0
- package/schematics/ng-add/schema.js +2 -0
- package/schematics/ng-add/schema.json +66 -0
- package/styles/caribeng.css +380 -0
- package/styles/scss/_mixins.scss +46 -0
- package/styles/scss/_overlay.scss +15 -0
- package/styles/scss/_tokens.scss +267 -0
- package/styles/scss/_utilities.scss +73 -0
- package/styles/scss/_variables.scss +33 -0
- package/styles/scss/index.scss +16 -0
- package/types/caribeng-ui-anchor.d.ts +50 -0
- package/types/caribeng-ui-autocomplete.d.ts +4 -2
- package/types/caribeng-ui-avatargroup.d.ts +3 -1
- package/types/caribeng-ui-blockui.d.ts +9 -4
- package/types/caribeng-ui-breadcrumb.d.ts +3 -0
- package/types/caribeng-ui-button.d.ts +9 -1
- package/types/caribeng-ui-caribe-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-animation-lottie.d.ts +4 -1
- package/types/caribeng-ui-caribe-button-group.d.ts +4 -1
- package/types/caribeng-ui-caribe-calendar.d.ts +5 -1
- package/types/caribeng-ui-caribe-card-content.d.ts +4 -1
- package/types/caribeng-ui-caribe-card-move.d.ts +13 -13
- package/types/caribeng-ui-caribe-card-select.d.ts +10 -1
- package/types/caribeng-ui-caribe-circle-loading.d.ts +4 -1
- package/types/caribeng-ui-caribe-coachmark.d.ts +6 -0
- package/types/caribeng-ui-caribe-data-table.d.ts +7 -2
- package/types/caribeng-ui-caribe-dots-indicator.d.ts +9 -0
- package/types/caribeng-ui-caribe-expansion-panel.d.ts +7 -10
- package/types/caribeng-ui-caribe-fab-menu.d.ts +10 -1
- package/types/caribeng-ui-caribe-file-download.d.ts +8 -10
- package/types/caribeng-ui-caribe-file-select.d.ts +7 -1
- package/types/caribeng-ui-caribe-float-menu.d.ts +4 -1
- package/types/caribeng-ui-caribe-header.d.ts +3 -0
- package/types/caribeng-ui-caribe-icon-button.d.ts +4 -1
- package/types/caribeng-ui-caribe-illustration.d.ts +4 -1
- package/types/caribeng-ui-caribe-inline-alert.d.ts +3 -0
- package/types/caribeng-ui-caribe-input-search.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-select.d.ts +4 -2
- package/types/caribeng-ui-caribe-input-token.d.ts +16 -1
- package/types/caribeng-ui-caribe-link.d.ts +3 -0
- package/types/caribeng-ui-caribe-loader.d.ts +4 -1
- package/types/caribeng-ui-caribe-modal.d.ts +7 -10
- package/types/caribeng-ui-caribe-off-canvas.d.ts +6 -1
- package/types/caribeng-ui-caribe-onboarding.d.ts +6 -0
- package/types/caribeng-ui-caribe-pictogram.d.ts +4 -1
- package/types/caribeng-ui-caribe-pop-over.d.ts +7 -10
- package/types/caribeng-ui-caribe-preloader.d.ts +4 -1
- package/types/caribeng-ui-caribe-progress-bar.d.ts +3 -0
- package/types/caribeng-ui-caribe-shortcut.d.ts +3 -1
- package/types/caribeng-ui-caribe-step-indicator.d.ts +6 -0
- package/types/caribeng-ui-caribe-stroke.d.ts +4 -1
- package/types/caribeng-ui-caribe-switch.d.ts +3 -1
- package/types/caribeng-ui-caribe-tracker.d.ts +3 -0
- package/types/caribeng-ui-caribe-voucher.d.ts +5 -2
- package/types/caribeng-ui-carousel.d.ts +10 -1
- package/types/caribeng-ui-cascadeselect.d.ts +7 -2
- package/types/caribeng-ui-chart.d.ts +469 -44
- package/types/caribeng-ui-chip.d.ts +6 -0
- package/types/caribeng-ui-chips.d.ts +6 -2
- package/types/caribeng-ui-colorpicker.d.ts +3 -1
- package/types/caribeng-ui-confirmdialog.d.ts +25 -6
- package/types/caribeng-ui-confirmpopup.d.ts +37 -5
- package/types/caribeng-ui-contextmenu.d.ts +4 -1
- package/types/caribeng-ui-dataview.d.ts +63 -5
- package/types/caribeng-ui-datepicker.d.ts +186 -21
- package/types/caribeng-ui-descriptions.d.ts +63 -0
- package/types/caribeng-ui-dialog.d.ts +4 -1
- package/types/caribeng-ui-dock.d.ts +4 -1
- package/types/caribeng-ui-drawer.d.ts +4 -1
- package/types/caribeng-ui-dynamicdialog.d.ts +93 -3
- package/types/caribeng-ui-editor.d.ts +486 -13
- package/types/caribeng-ui-empty.d.ts +34 -0
- package/types/caribeng-ui-file-card.d.ts +1 -1
- package/types/caribeng-ui-fileupload.d.ts +27 -4
- package/types/caribeng-ui-folder-card.d.ts +4 -1
- package/types/caribeng-ui-galleria.d.ts +9 -0
- package/types/caribeng-ui-image.d.ts +10 -0
- package/types/caribeng-ui-inplace.d.ts +8 -0
- package/types/caribeng-ui-input-number.d.ts +3 -1
- package/types/caribeng-ui-inputmask.d.ts +5 -0
- package/types/caribeng-ui-inputotp.d.ts +7 -2
- package/types/caribeng-ui-keyfilter.d.ts +30 -0
- package/types/caribeng-ui-listbox.d.ts +5 -3
- package/types/caribeng-ui-megamenu.d.ts +26 -2
- package/types/caribeng-ui-menu.d.ts +7 -2
- package/types/caribeng-ui-menubar.d.ts +5 -1
- package/types/caribeng-ui-message.d.ts +3 -0
- package/types/caribeng-ui-metergroup.d.ts +9 -1
- package/types/caribeng-ui-multiselect.d.ts +71 -10
- package/types/caribeng-ui-orderlist.d.ts +58 -6
- package/types/caribeng-ui-organizationchart.d.ts +7 -1
- package/types/caribeng-ui-paginator.d.ts +3 -0
- package/types/caribeng-ui-panel.d.ts +3 -0
- package/types/caribeng-ui-panelmenu.d.ts +4 -1
- package/types/caribeng-ui-password.d.ts +4 -2
- package/types/caribeng-ui-pdfviewer.d.ts +258 -0
- package/types/caribeng-ui-picklist.d.ts +67 -7
- package/types/caribeng-ui-pricing.d.ts +8 -5
- package/types/caribeng-ui-rating.d.ts +6 -2
- package/types/caribeng-ui-repeater.d.ts +79 -0
- package/types/caribeng-ui-result.d.ts +35 -0
- package/types/caribeng-ui-scrollpanel.d.ts +4 -1
- package/types/caribeng-ui-scrolltop.d.ts +4 -1
- package/types/caribeng-ui-select.d.ts +73 -9
- package/types/caribeng-ui-slider.d.ts +63 -10
- package/types/caribeng-ui-speeddial.d.ts +5 -2
- package/types/caribeng-ui-spinner.d.ts +3 -0
- package/types/caribeng-ui-splitbutton.d.ts +49 -0
- package/types/caribeng-ui-splitter.d.ts +3 -0
- package/types/caribeng-ui-statistic.d.ts +65 -0
- package/types/caribeng-ui-stepper.d.ts +3 -0
- package/types/caribeng-ui-steps.d.ts +4 -1
- package/types/caribeng-ui-table.d.ts +184 -16
- package/types/caribeng-ui-tabmenu.d.ts +4 -1
- package/types/caribeng-ui-terminal.d.ts +10 -0
- package/types/caribeng-ui-themetoggle.d.ts +32 -0
- package/types/caribeng-ui-tieredmenu.d.ts +5 -2
- package/types/caribeng-ui-timeline.d.ts +63 -4
- package/types/caribeng-ui-toast.d.ts +3 -0
- package/types/caribeng-ui-togglebutton.d.ts +5 -3
- package/types/caribeng-ui-toolbar.d.ts +7 -4
- package/types/caribeng-ui-tree.d.ts +76 -4
- package/types/caribeng-ui-treeselect.d.ts +10 -2
- package/types/caribeng-ui-treetable.d.ts +68 -4
- package/types/caribeng-ui-virtualscroller.d.ts +45 -5
- package/types/caribeng-ui.d.ts +501 -12
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { input, model, output, computed, signal, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
5
|
-
import { cbFieldState } from '@caribeng/ui';
|
|
5
|
+
import { injectCbTranslation, cbFieldState } from '@caribeng/ui';
|
|
6
6
|
|
|
7
7
|
let nextUid = 0;
|
|
8
8
|
/**
|
|
@@ -16,9 +16,11 @@ let nextUid = 0;
|
|
|
16
16
|
*/
|
|
17
17
|
class CbToggleButton {
|
|
18
18
|
constructor() {
|
|
19
|
-
|
|
19
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
20
|
+
this.t = injectCbTranslation();
|
|
21
|
+
this.onLabel = input(undefined, /* @ts-ignore */
|
|
20
22
|
...(ngDevMode ? [{ debugName: "onLabel" }] : /* istanbul ignore next */ []));
|
|
21
|
-
this.offLabel = input(
|
|
23
|
+
this.offLabel = input(undefined, /* @ts-ignore */
|
|
22
24
|
...(ngDevMode ? [{ debugName: "offLabel" }] : /* istanbul ignore next */ []));
|
|
23
25
|
this.onIcon = input('', /* @ts-ignore */
|
|
24
26
|
...(ngDevMode ? [{ debugName: "onIcon" }] : /* istanbul ignore next */ []));
|
|
@@ -40,7 +42,7 @@ class CbToggleButton {
|
|
|
40
42
|
this.changed = output();
|
|
41
43
|
this.checked = computed(() => this.value(), /* @ts-ignore */
|
|
42
44
|
...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
|
|
43
|
-
this.label = computed(() => (this.value() ? this.onLabel() : this.offLabel()), /* @ts-ignore */
|
|
45
|
+
this.label = computed(() => (this.value() ? (this.onLabel() ?? this.t().yes) : (this.offLabel() ?? this.t().no)), /* @ts-ignore */
|
|
44
46
|
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
45
47
|
this.icon = computed(() => (this.value() ? this.onIcon() : this.offIcon()), /* @ts-ignore */
|
|
46
48
|
...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
@@ -99,7 +101,7 @@ class CbToggleButton {
|
|
|
99
101
|
}
|
|
100
102
|
<span class="cb-togglebutton__label">{{ label() }}</span>
|
|
101
103
|
</button>
|
|
102
|
-
`, isInline: true, styles: [":host{display:inline-flex}.cb-togglebutton{display:inline-flex;align-items:center;gap:var(--cb-space-2);height:2.5rem;padding:0 var(--cb-space-4);border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-weight:var(--cb-font-weight-medium);cursor:pointer;transition:background-color var(--cb-duration-fast) var(--cb-ease),border-color var(--cb-duration-fast) var(--cb-ease),color var(--cb-duration-fast) var(--cb-ease)}.cb-togglebutton--sm{height:2.125rem;padding:0 var(--cb-space-3);font-size:var(--cb-text-sm)}.cb-togglebutton--lg{height:2.875rem;padding:0 var(--cb-space-5);font-size:var(--cb-text-lg)}.cb-togglebutton:hover:not(:disabled):not(.cb-is-on){background-color:var(--cb-color-surface-
|
|
104
|
+
`, isInline: true, styles: [":host{display:inline-flex}.cb-togglebutton{display:inline-flex;align-items:center;gap:var(--cb-space-2);height:2.5rem;padding:0 var(--cb-space-4);border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-weight:var(--cb-font-weight-medium);cursor:pointer;transition:background-color var(--cb-duration-fast) var(--cb-ease),border-color var(--cb-duration-fast) var(--cb-ease),color var(--cb-duration-fast) var(--cb-ease)}.cb-togglebutton--sm{height:2.125rem;padding:0 var(--cb-space-3);font-size:var(--cb-text-sm)}.cb-togglebutton--lg{height:2.875rem;padding:0 var(--cb-space-5);font-size:var(--cb-text-lg)}.cb-togglebutton:hover:not(:disabled):not(.cb-is-on){background-color:var(--cb-color-surface-hover)}.cb-togglebutton:focus-visible{outline:none;border-color:var(--cb-color-primary-500);box-shadow:0 0 0 3px var(--cb-color-focus-ring)}.cb-togglebutton.cb-is-on{background-color:var(--cb-color-primary-500);border-color:var(--cb-color-primary-500);color:var(--cb-color-primary-contrast)}.cb-togglebutton:disabled{opacity:var(--cb-opacity-disabled, .55);cursor:default}.cb-togglebutton.cb-is-invalid{border-color:var(--cb-color-danger)}\n"], dependencies: [{ kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
103
105
|
}
|
|
104
106
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbToggleButton, decorators: [{
|
|
105
107
|
type: Component,
|
|
@@ -128,7 +130,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
128
130
|
}
|
|
129
131
|
<span class="cb-togglebutton__label">{{ label() }}</span>
|
|
130
132
|
</button>
|
|
131
|
-
`, styles: [":host{display:inline-flex}.cb-togglebutton{display:inline-flex;align-items:center;gap:var(--cb-space-2);height:2.5rem;padding:0 var(--cb-space-4);border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-weight:var(--cb-font-weight-medium);cursor:pointer;transition:background-color var(--cb-duration-fast) var(--cb-ease),border-color var(--cb-duration-fast) var(--cb-ease),color var(--cb-duration-fast) var(--cb-ease)}.cb-togglebutton--sm{height:2.125rem;padding:0 var(--cb-space-3);font-size:var(--cb-text-sm)}.cb-togglebutton--lg{height:2.875rem;padding:0 var(--cb-space-5);font-size:var(--cb-text-lg)}.cb-togglebutton:hover:not(:disabled):not(.cb-is-on){background-color:var(--cb-color-surface-
|
|
133
|
+
`, styles: [":host{display:inline-flex}.cb-togglebutton{display:inline-flex;align-items:center;gap:var(--cb-space-2);height:2.5rem;padding:0 var(--cb-space-4);border:var(--cb-border-width) solid var(--cb-color-border-strong);border-radius:var(--cb-radius-md);background-color:var(--cb-color-bg);color:var(--cb-color-text);font-family:var(--cb-font-sans);font-weight:var(--cb-font-weight-medium);cursor:pointer;transition:background-color var(--cb-duration-fast) var(--cb-ease),border-color var(--cb-duration-fast) var(--cb-ease),color var(--cb-duration-fast) var(--cb-ease)}.cb-togglebutton--sm{height:2.125rem;padding:0 var(--cb-space-3);font-size:var(--cb-text-sm)}.cb-togglebutton--lg{height:2.875rem;padding:0 var(--cb-space-5);font-size:var(--cb-text-lg)}.cb-togglebutton:hover:not(:disabled):not(.cb-is-on){background-color:var(--cb-color-surface-hover)}.cb-togglebutton:focus-visible{outline:none;border-color:var(--cb-color-primary-500);box-shadow:0 0 0 3px var(--cb-color-focus-ring)}.cb-togglebutton.cb-is-on{background-color:var(--cb-color-primary-500);border-color:var(--cb-color-primary-500);color:var(--cb-color-primary-contrast)}.cb-togglebutton:disabled{opacity:var(--cb-opacity-disabled, .55);cursor:default}.cb-togglebutton.cb-is-invalid{border-color:var(--cb-color-danger)}\n"] }]
|
|
132
134
|
}], propDecorators: { onLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "onLabel", required: false }] }], offLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "offLabel", required: false }] }], onIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "onIcon", required: false }] }], offIcon: [{ type: i0.Input, args: [{ isSignal: true, alias: "offIcon", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], inputId: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputId", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], changed: [{ type: i0.Output, args: ["changed"] }] } });
|
|
133
135
|
function toBoolean(value) {
|
|
134
136
|
return value !== false && value != null && `${value}` !== 'false';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { injectCbTranslation } from '@caribeng/ui';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Toolbar de CaribeNG: contenedor horizontal accesible (`role="toolbar"`) para
|
|
@@ -17,12 +18,14 @@ import { input, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@a
|
|
|
17
18
|
*/
|
|
18
19
|
class CbToolbar {
|
|
19
20
|
constructor() {
|
|
21
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
22
|
+
this.t = injectCbTranslation();
|
|
20
23
|
/** Etiqueta accesible para el contenedor `role="toolbar"`. */
|
|
21
|
-
this.ariaLabel = input(
|
|
24
|
+
this.ariaLabel = input(undefined, /* @ts-ignore */
|
|
22
25
|
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
23
26
|
}
|
|
24
27
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbToolbar, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
25
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.5", type: CbToolbar, isStandalone: true, selector: "cb-toolbar", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "toolbar" }, properties: { "attr.aria-label": "ariaLabel() || null" }, classAttribute: "cb-toolbar" }, ngImport: i0, template: `
|
|
28
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.0.5", type: CbToolbar, isStandalone: true, selector: "cb-toolbar", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "toolbar" }, properties: { "attr.aria-label": "(ariaLabel() ?? t().toolbar) || null" }, classAttribute: "cb-toolbar" }, ngImport: i0, template: `
|
|
26
29
|
<div class="cb-toolbar__group cb-toolbar__start">
|
|
27
30
|
<ng-content select="[cb-toolbar-start]" />
|
|
28
31
|
<ng-content />
|
|
@@ -40,7 +43,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
40
43
|
args: [{ selector: 'cb-toolbar', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, host: {
|
|
41
44
|
class: 'cb-toolbar',
|
|
42
45
|
role: 'toolbar',
|
|
43
|
-
'[attr.aria-label]': 'ariaLabel() || null',
|
|
46
|
+
'[attr.aria-label]': '(ariaLabel() ?? t().toolbar) || null',
|
|
44
47
|
}, template: `
|
|
45
48
|
<div class="cb-toolbar__group cb-toolbar__start">
|
|
46
49
|
<ng-content select="[cb-toolbar-start]" />
|
|
@@ -1,26 +1,322 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
1
2
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, model, signal, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { inject, TemplateRef, Directive, ElementRef, input, model, output, contentChild, signal, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
|
+
import { injectCbTranslation, cbFormat } from '@caribeng/ui';
|
|
5
|
+
import { CbIcon } from '@caribeng/ui/icon';
|
|
3
6
|
|
|
7
|
+
/** Plantilla para el contenido de cada nodo. */
|
|
8
|
+
class CbTreeNodeTemplate {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.template = inject(TemplateRef);
|
|
11
|
+
}
|
|
12
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeNodeTemplate, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
16
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: CbTreeNodeTemplate, isStandalone: true, selector: "ng-template[cbTreeNode]", ngImport: i0 }); }
|
|
17
|
+
}
|
|
18
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeNodeTemplate, decorators: [{
|
|
19
|
+
type: Directive,
|
|
20
|
+
args: [{ selector: 'ng-template[cbTreeNode]' }]
|
|
21
|
+
}] });
|
|
22
|
+
let nextUid = 0;
|
|
23
|
+
/**
|
|
24
|
+
* Árbol jerárquico de CaribeNG con niveles ilimitados, selección simple y
|
|
25
|
+
* navegación con teclado según el patrón *tree* de WAI-ARIA.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```html
|
|
29
|
+
* <cb-tree [value]="nodes" [(selection)]="selected" ariaLabel="Documentos" />
|
|
30
|
+
*
|
|
31
|
+
* <cb-tree [value]="nodes">
|
|
32
|
+
* <ng-template cbTreeNode let-node>{{ node.label }} ({{ node.children?.length ?? 0 }})</ng-template>
|
|
33
|
+
* </cb-tree>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
4
36
|
class CbTree {
|
|
5
37
|
constructor() {
|
|
38
|
+
this.t = injectCbTranslation();
|
|
39
|
+
this.fmt = cbFormat;
|
|
40
|
+
this.host = inject(ElementRef);
|
|
41
|
+
this.uid = `cb-tree-${++nextUid}`;
|
|
42
|
+
/** Nodos raíz. */
|
|
6
43
|
this.value = input([], /* @ts-ignore */
|
|
7
44
|
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
45
|
+
/** Nodo seleccionado (two-way). */
|
|
8
46
|
this.selection = model(null, /* @ts-ignore */
|
|
9
47
|
...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
|
|
48
|
+
/** Nombre accesible del árbol. */
|
|
49
|
+
this.ariaLabel = input('', /* @ts-ignore */
|
|
50
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
51
|
+
/** Se emite al expandir un nodo. */
|
|
52
|
+
this.nodeExpand = output();
|
|
53
|
+
/** Se emite al contraer un nodo. */
|
|
54
|
+
this.nodeCollapse = output();
|
|
55
|
+
/** Se emite al seleccionar un nodo. */
|
|
56
|
+
this.nodeSelect = output();
|
|
57
|
+
this.nodeTemplate = contentChild(CbTreeNodeTemplate, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "nodeTemplate" }] : /* istanbul ignore next */ []));
|
|
10
59
|
this.expanded = signal(new Set(), /* @ts-ignore */
|
|
11
60
|
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
61
|
+
/** Último nodo enfocado por el usuario. */
|
|
62
|
+
this.activeKey = signal(null, /* @ts-ignore */
|
|
63
|
+
...(ngDevMode ? [{ debugName: "activeKey" }] : /* istanbul ignore next */ []));
|
|
64
|
+
/** Nodo que recibe el foco con Tab (roving tabindex): el activo, el seleccionado o el primero. */
|
|
65
|
+
this.tabbableKey = computed(() => this.activeKey() ?? this.selection()?.key ?? this.value()[0]?.key ?? null, /* @ts-ignore */
|
|
66
|
+
...(ngDevMode ? [{ debugName: "tabbableKey" }] : /* istanbul ignore next */ []));
|
|
67
|
+
/** Nodos visibles en orden de lectura (solo ramas expandidas). */
|
|
68
|
+
this.visible = computed(() => {
|
|
69
|
+
const out = [];
|
|
70
|
+
const walk = (nodes, level, parentKey) => {
|
|
71
|
+
for (const node of nodes) {
|
|
72
|
+
out.push({ node, level, parentKey });
|
|
73
|
+
if (node.children?.length && this.expanded().has(node.key))
|
|
74
|
+
walk(node.children, level + 1, node.key);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
walk(this.value(), 1, null);
|
|
78
|
+
return out;
|
|
79
|
+
}, /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
81
|
+
}
|
|
82
|
+
/** Expande todos los nodos. */
|
|
83
|
+
expandAll() {
|
|
84
|
+
const keys = new Set();
|
|
85
|
+
const walk = (nodes) => nodes.forEach((n) => {
|
|
86
|
+
if (n.children?.length) {
|
|
87
|
+
keys.add(n.key);
|
|
88
|
+
walk(n.children);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
walk(this.value());
|
|
92
|
+
this.expanded.set(keys);
|
|
93
|
+
}
|
|
94
|
+
/** Contrae todos los nodos. */
|
|
95
|
+
collapseAll() {
|
|
96
|
+
this.expanded.set(new Set());
|
|
97
|
+
}
|
|
98
|
+
hasChildren(node) {
|
|
99
|
+
return !!node.children?.length;
|
|
100
|
+
}
|
|
101
|
+
isExpanded(node) {
|
|
102
|
+
return this.expanded().has(node.key);
|
|
103
|
+
}
|
|
104
|
+
isSelected(node) {
|
|
105
|
+
return this.selection()?.key === node.key;
|
|
106
|
+
}
|
|
107
|
+
itemId(node) {
|
|
108
|
+
return `${this.uid}-${node.key}`;
|
|
109
|
+
}
|
|
110
|
+
toggle(node, event) {
|
|
111
|
+
event?.stopPropagation();
|
|
112
|
+
this.setExpanded(node, !this.isExpanded(node));
|
|
113
|
+
}
|
|
114
|
+
onClick(event, node) {
|
|
115
|
+
event.stopPropagation();
|
|
116
|
+
this.activeKey.set(node.key);
|
|
117
|
+
this.select(node);
|
|
118
|
+
}
|
|
119
|
+
onKeydown(event) {
|
|
120
|
+
const list = this.visible();
|
|
121
|
+
const index = list.findIndex((v) => v.node.key === this.tabbableKey());
|
|
122
|
+
if (index < 0)
|
|
123
|
+
return;
|
|
124
|
+
const current = list[index];
|
|
125
|
+
let target;
|
|
126
|
+
switch (event.key) {
|
|
127
|
+
case 'ArrowDown':
|
|
128
|
+
target = list[index + 1];
|
|
129
|
+
break;
|
|
130
|
+
case 'ArrowUp':
|
|
131
|
+
target = list[index - 1];
|
|
132
|
+
break;
|
|
133
|
+
case 'Home':
|
|
134
|
+
target = list[0];
|
|
135
|
+
break;
|
|
136
|
+
case 'End':
|
|
137
|
+
target = list[list.length - 1];
|
|
138
|
+
break;
|
|
139
|
+
case 'ArrowRight':
|
|
140
|
+
if (this.hasChildren(current.node)) {
|
|
141
|
+
if (!this.isExpanded(current.node))
|
|
142
|
+
this.setExpanded(current.node, true);
|
|
143
|
+
else
|
|
144
|
+
target = list[index + 1];
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case 'ArrowLeft':
|
|
148
|
+
if (this.hasChildren(current.node) && this.isExpanded(current.node))
|
|
149
|
+
this.setExpanded(current.node, false);
|
|
150
|
+
else if (current.parentKey)
|
|
151
|
+
target = list.find((v) => v.node.key === current.parentKey);
|
|
152
|
+
break;
|
|
153
|
+
case 'Enter':
|
|
154
|
+
case ' ':
|
|
155
|
+
this.select(current.node);
|
|
156
|
+
break;
|
|
157
|
+
default:
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
if (target)
|
|
162
|
+
this.focus(target.node);
|
|
163
|
+
}
|
|
164
|
+
select(node) {
|
|
165
|
+
if (node.disabled)
|
|
166
|
+
return;
|
|
167
|
+
this.selection.set(node);
|
|
168
|
+
this.nodeSelect.emit(node);
|
|
169
|
+
}
|
|
170
|
+
setExpanded(node, open) {
|
|
171
|
+
if (open === this.isExpanded(node))
|
|
172
|
+
return;
|
|
173
|
+
const next = new Set(this.expanded());
|
|
174
|
+
if (open)
|
|
175
|
+
next.add(node.key);
|
|
176
|
+
else
|
|
177
|
+
next.delete(node.key);
|
|
178
|
+
this.expanded.set(next);
|
|
179
|
+
(open ? this.nodeExpand : this.nodeCollapse).emit(node);
|
|
180
|
+
}
|
|
181
|
+
focus(node) {
|
|
182
|
+
this.activeKey.set(node.key);
|
|
183
|
+
const id = this.itemId(node);
|
|
184
|
+
Array.from(this.host.nativeElement.querySelectorAll('[role="treeitem"]'))
|
|
185
|
+
.find((el) => el.id === id)
|
|
186
|
+
?.focus();
|
|
12
187
|
}
|
|
13
|
-
toggle(key) { const next = new Set(this.expanded()); next.has(key) ? next.delete(key) : next.add(key); this.expanded.set(next); }
|
|
14
188
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTree, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
15
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTree, isStandalone: true, selector: "cb-tree", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }
|
|
189
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTree, isStandalone: true, selector: "cb-tree", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selection: "selectionChange", nodeExpand: "nodeExpand", nodeCollapse: "nodeCollapse", nodeSelect: "nodeSelect" }, host: { classAttribute: "cb-tree-host" }, queries: [{ propertyName: "nodeTemplate", first: true, predicate: CbTreeNodeTemplate, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
190
|
+
<ul class="cb-tree" role="tree" [attr.aria-label]="ariaLabel() || null" (keydown)="onKeydown($event)">
|
|
191
|
+
<ng-container *ngTemplateOutlet="branch; context: { $implicit: value(), level: 1 }" />
|
|
192
|
+
</ul>
|
|
193
|
+
|
|
194
|
+
<ng-template #branch let-nodes let-level="level">
|
|
195
|
+
@for (node of nodes; track node.key; let i = $index) {
|
|
196
|
+
<li
|
|
197
|
+
class="cb-tree__item"
|
|
198
|
+
role="treeitem"
|
|
199
|
+
[id]="itemId(node)"
|
|
200
|
+
[attr.aria-level]="level"
|
|
201
|
+
[attr.aria-setsize]="nodes.length"
|
|
202
|
+
[attr.aria-posinset]="i + 1"
|
|
203
|
+
[attr.aria-expanded]="hasChildren(node) ? isExpanded(node) : null"
|
|
204
|
+
[attr.aria-selected]="node.disabled ? null : isSelected(node)"
|
|
205
|
+
[attr.aria-disabled]="node.disabled ? 'true' : null"
|
|
206
|
+
[attr.tabindex]="node.key === tabbableKey() ? 0 : -1"
|
|
207
|
+
(focus)="activeKey.set(node.key)"
|
|
208
|
+
(click)="onClick($event, node)"
|
|
209
|
+
>
|
|
210
|
+
<div
|
|
211
|
+
class="cb-tree__row"
|
|
212
|
+
[class.cb-is-selected]="isSelected(node)"
|
|
213
|
+
[class.cb-is-disabled]="node.disabled"
|
|
214
|
+
[style.padding-inline-start]="'calc(' + (level - 1) + ' * var(--cb-tree-indent, 1.25rem) + 0.25rem)'"
|
|
215
|
+
>
|
|
216
|
+
@if (hasChildren(node)) {
|
|
217
|
+
<button
|
|
218
|
+
type="button"
|
|
219
|
+
class="cb-tree__toggler"
|
|
220
|
+
tabindex="-1"
|
|
221
|
+
[attr.aria-label]="fmt(isExpanded(node) ? t().collapseItem : t().expandItem, node.label)"
|
|
222
|
+
(click)="toggle(node, $event)"
|
|
223
|
+
>
|
|
224
|
+
<cb-icon name="chevron-right" [size]="14" [class.cb-is-open]="isExpanded(node)" aria-hidden="true" />
|
|
225
|
+
</button>
|
|
226
|
+
} @else {
|
|
227
|
+
<span class="cb-tree__spacer" aria-hidden="true"></span>
|
|
228
|
+
}
|
|
229
|
+
@if (node.icon) {
|
|
230
|
+
<cb-icon class="cb-tree__icon" [name]="node.icon" [size]="16" aria-hidden="true" />
|
|
231
|
+
}
|
|
232
|
+
<span class="cb-tree__label">
|
|
233
|
+
@if (nodeTemplate(); as tpl) {
|
|
234
|
+
<ng-container
|
|
235
|
+
*ngTemplateOutlet="tpl.template; context: { $implicit: node, level, expanded: isExpanded(node), selected: isSelected(node) }"
|
|
236
|
+
/>
|
|
237
|
+
} @else {
|
|
238
|
+
{{ node.label }}
|
|
239
|
+
}
|
|
240
|
+
</span>
|
|
241
|
+
</div>
|
|
242
|
+
@if (hasChildren(node) && isExpanded(node)) {
|
|
243
|
+
<ul class="cb-tree__group" role="group">
|
|
244
|
+
<ng-container *ngTemplateOutlet="branch; context: { $implicit: node.children, level: level + 1 }" />
|
|
245
|
+
</ul>
|
|
246
|
+
}
|
|
247
|
+
</li>
|
|
248
|
+
}
|
|
249
|
+
</ng-template>
|
|
250
|
+
`, isInline: true, styles: [":host{display:block;color:var(--cb-color-text);font-size:var(--cb-text-sm, .875rem)}.cb-tree,.cb-tree__group{list-style:none;margin:0;padding:0}.cb-tree__item{outline:none}.cb-tree__row{display:flex;align-items:center;gap:var(--cb-space-1, .25rem);min-height:2.25rem;padding-inline-end:var(--cb-space-2, .5rem);border-radius:var(--cb-radius-md, .5rem);cursor:pointer;transition:background var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__row:hover{background:var(--cb-color-surface-hover)}.cb-tree__row.cb-is-selected{color:var(--cb-color-primary-700);background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent);font-weight:var(--cb-font-weight-medium, 500)}.cb-tree__row.cb-is-disabled{opacity:.55;cursor:default}.cb-tree__item:focus-visible>.cb-tree__row{box-shadow:0 0 0 2px var(--cb-color-focus-ring, var(--cb-color-primary-500))}.cb-tree__toggler{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;flex:none;padding:0;border:0;border-radius:var(--cb-radius-sm, 4px);background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree__toggler:hover{color:var(--cb-color-text);background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}.cb-tree__toggler cb-icon{transition:transform var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__toggler cb-icon.cb-is-open{transform:rotate(90deg)}.cb-tree__spacer{width:1.5rem;flex:none}.cb-tree__icon{flex:none;color:var(--cb-color-text-muted)}.cb-tree__label{flex:1;min-width:0}:host-context([data-theme=\"dark\"]) .cb-tree__row:hover{background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}:host-context([data-theme=\"dark\"]) .cb-tree__row.cb-is-selected{color:var(--cb-color-primary-300)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
16
251
|
}
|
|
17
252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTree, decorators: [{
|
|
18
253
|
type: Component,
|
|
19
|
-
args: [{ selector: 'cb-tree',
|
|
20
|
-
|
|
254
|
+
args: [{ selector: 'cb-tree', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [NgTemplateOutlet, CbIcon], host: { class: 'cb-tree-host' }, template: `
|
|
255
|
+
<ul class="cb-tree" role="tree" [attr.aria-label]="ariaLabel() || null" (keydown)="onKeydown($event)">
|
|
256
|
+
<ng-container *ngTemplateOutlet="branch; context: { $implicit: value(), level: 1 }" />
|
|
257
|
+
</ul>
|
|
258
|
+
|
|
259
|
+
<ng-template #branch let-nodes let-level="level">
|
|
260
|
+
@for (node of nodes; track node.key; let i = $index) {
|
|
261
|
+
<li
|
|
262
|
+
class="cb-tree__item"
|
|
263
|
+
role="treeitem"
|
|
264
|
+
[id]="itemId(node)"
|
|
265
|
+
[attr.aria-level]="level"
|
|
266
|
+
[attr.aria-setsize]="nodes.length"
|
|
267
|
+
[attr.aria-posinset]="i + 1"
|
|
268
|
+
[attr.aria-expanded]="hasChildren(node) ? isExpanded(node) : null"
|
|
269
|
+
[attr.aria-selected]="node.disabled ? null : isSelected(node)"
|
|
270
|
+
[attr.aria-disabled]="node.disabled ? 'true' : null"
|
|
271
|
+
[attr.tabindex]="node.key === tabbableKey() ? 0 : -1"
|
|
272
|
+
(focus)="activeKey.set(node.key)"
|
|
273
|
+
(click)="onClick($event, node)"
|
|
274
|
+
>
|
|
275
|
+
<div
|
|
276
|
+
class="cb-tree__row"
|
|
277
|
+
[class.cb-is-selected]="isSelected(node)"
|
|
278
|
+
[class.cb-is-disabled]="node.disabled"
|
|
279
|
+
[style.padding-inline-start]="'calc(' + (level - 1) + ' * var(--cb-tree-indent, 1.25rem) + 0.25rem)'"
|
|
280
|
+
>
|
|
281
|
+
@if (hasChildren(node)) {
|
|
282
|
+
<button
|
|
283
|
+
type="button"
|
|
284
|
+
class="cb-tree__toggler"
|
|
285
|
+
tabindex="-1"
|
|
286
|
+
[attr.aria-label]="fmt(isExpanded(node) ? t().collapseItem : t().expandItem, node.label)"
|
|
287
|
+
(click)="toggle(node, $event)"
|
|
288
|
+
>
|
|
289
|
+
<cb-icon name="chevron-right" [size]="14" [class.cb-is-open]="isExpanded(node)" aria-hidden="true" />
|
|
290
|
+
</button>
|
|
291
|
+
} @else {
|
|
292
|
+
<span class="cb-tree__spacer" aria-hidden="true"></span>
|
|
293
|
+
}
|
|
294
|
+
@if (node.icon) {
|
|
295
|
+
<cb-icon class="cb-tree__icon" [name]="node.icon" [size]="16" aria-hidden="true" />
|
|
296
|
+
}
|
|
297
|
+
<span class="cb-tree__label">
|
|
298
|
+
@if (nodeTemplate(); as tpl) {
|
|
299
|
+
<ng-container
|
|
300
|
+
*ngTemplateOutlet="tpl.template; context: { $implicit: node, level, expanded: isExpanded(node), selected: isSelected(node) }"
|
|
301
|
+
/>
|
|
302
|
+
} @else {
|
|
303
|
+
{{ node.label }}
|
|
304
|
+
}
|
|
305
|
+
</span>
|
|
306
|
+
</div>
|
|
307
|
+
@if (hasChildren(node) && isExpanded(node)) {
|
|
308
|
+
<ul class="cb-tree__group" role="group">
|
|
309
|
+
<ng-container *ngTemplateOutlet="branch; context: { $implicit: node.children, level: level + 1 }" />
|
|
310
|
+
</ul>
|
|
311
|
+
}
|
|
312
|
+
</li>
|
|
313
|
+
}
|
|
314
|
+
</ng-template>
|
|
315
|
+
`, styles: [":host{display:block;color:var(--cb-color-text);font-size:var(--cb-text-sm, .875rem)}.cb-tree,.cb-tree__group{list-style:none;margin:0;padding:0}.cb-tree__item{outline:none}.cb-tree__row{display:flex;align-items:center;gap:var(--cb-space-1, .25rem);min-height:2.25rem;padding-inline-end:var(--cb-space-2, .5rem);border-radius:var(--cb-radius-md, .5rem);cursor:pointer;transition:background var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__row:hover{background:var(--cb-color-surface-hover)}.cb-tree__row.cb-is-selected{color:var(--cb-color-primary-700);background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent);font-weight:var(--cb-font-weight-medium, 500)}.cb-tree__row.cb-is-disabled{opacity:.55;cursor:default}.cb-tree__item:focus-visible>.cb-tree__row{box-shadow:0 0 0 2px var(--cb-color-focus-ring, var(--cb-color-primary-500))}.cb-tree__toggler{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;flex:none;padding:0;border:0;border-radius:var(--cb-radius-sm, 4px);background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree__toggler:hover{color:var(--cb-color-text);background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}.cb-tree__toggler cb-icon{transition:transform var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__toggler cb-icon.cb-is-open{transform:rotate(90deg)}.cb-tree__spacer{width:1.5rem;flex:none}.cb-tree__icon{flex:none;color:var(--cb-color-text-muted)}.cb-tree__label{flex:1;min-width:0}:host-context([data-theme=\"dark\"]) .cb-tree__row:hover{background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}:host-context([data-theme=\"dark\"]) .cb-tree__row.cb-is-selected{color:var(--cb-color-primary-300)}\n"] }]
|
|
316
|
+
}], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], nodeExpand: [{ type: i0.Output, args: ["nodeExpand"] }], nodeCollapse: [{ type: i0.Output, args: ["nodeCollapse"] }], nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }], nodeTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CbTreeNodeTemplate), { isSignal: true }] }] } });
|
|
21
317
|
|
|
22
318
|
/**
|
|
23
319
|
* Generated bundle index. Do not edit.
|
|
24
320
|
*/
|
|
25
321
|
|
|
26
|
-
export { CbTree };
|
|
322
|
+
export { CbTree, CbTreeNodeTemplate };
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, booleanAttribute, model, signal, computed, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, booleanAttribute, model, signal, computed, viewChild, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
4
|
import { CbIcon } from '@caribeng/ui/icon';
|
|
5
|
-
import { cbFieldState } from '@caribeng/ui';
|
|
5
|
+
import { injectCbTranslation, cbFormat, cbFieldState } from '@caribeng/ui';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* TreeSelect de CaribeNG: selector desplegable jerárquico con soporte CVA.
|
|
9
9
|
*/
|
|
10
10
|
class CbTreeSelect {
|
|
11
11
|
constructor() {
|
|
12
|
+
/** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
|
|
13
|
+
this.t = injectCbTranslation();
|
|
14
|
+
/** Rellena `{0}`, `{1}`… de un texto traducido. */
|
|
15
|
+
this.fmt = cbFormat;
|
|
12
16
|
this.nodes = input([], /* @ts-ignore */
|
|
13
17
|
...(ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []));
|
|
14
|
-
this.placeholder = input(
|
|
18
|
+
this.placeholder = input(undefined, /* @ts-ignore */
|
|
15
19
|
...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
|
|
16
20
|
this.disabled = input(false, /* @ts-ignore */
|
|
17
21
|
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
@@ -54,6 +58,7 @@ class CbTreeSelect {
|
|
|
54
58
|
...(ngDevMode ? [{ debugName: "visibleNodes" }] : /* istanbul ignore next */ []));
|
|
55
59
|
this.onChange = () => { };
|
|
56
60
|
this.onTouched = () => { };
|
|
61
|
+
this.trigger = viewChild.required('trigger');
|
|
57
62
|
}
|
|
58
63
|
writeValue(val) {
|
|
59
64
|
this.value.set(val ?? null);
|
|
@@ -67,6 +72,14 @@ class CbTreeSelect {
|
|
|
67
72
|
setDisabledState(isDisabled) {
|
|
68
73
|
this.cvaDisabled.set(isDisabled);
|
|
69
74
|
}
|
|
75
|
+
/** Escape cierra el panel y devuelve el foco al disparador. */
|
|
76
|
+
closeOnEscape(event) {
|
|
77
|
+
if (!this.open())
|
|
78
|
+
return;
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
this.open.set(false);
|
|
81
|
+
this.trigger().nativeElement.focus();
|
|
82
|
+
}
|
|
70
83
|
toggleOpen() {
|
|
71
84
|
if (this.isDisabled())
|
|
72
85
|
return;
|
|
@@ -105,14 +118,15 @@ class CbTreeSelect {
|
|
|
105
118
|
return null;
|
|
106
119
|
}
|
|
107
120
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeSelect, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
108
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTreeSelect, isStandalone: true, selector: "cb-tree-select", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "class.cb-is-open": "open()", "class.cb-is-disabled": "isDisabled()" }, classAttribute: "cb-tree-select" }, providers: [
|
|
121
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTreeSelect, isStandalone: true, selector: "cb-tree-select", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "keydown.escape": "closeOnEscape($event)" }, properties: { "class.cb-is-open": "open()", "class.cb-is-disabled": "isDisabled()" }, classAttribute: "cb-tree-select" }, providers: [
|
|
109
122
|
{
|
|
110
123
|
provide: NG_VALUE_ACCESSOR,
|
|
111
124
|
useExisting: forwardRef(() => CbTreeSelect),
|
|
112
125
|
multi: true,
|
|
113
126
|
},
|
|
114
|
-
], ngImport: i0, template: `
|
|
127
|
+
], viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
115
128
|
<button
|
|
129
|
+
#trigger
|
|
116
130
|
type="button"
|
|
117
131
|
class="cb-tree-select__trigger"
|
|
118
132
|
[class.cb-is-invalid]="fieldState.invalid()"
|
|
@@ -125,7 +139,7 @@ class CbTreeSelect {
|
|
|
125
139
|
(click)="toggleOpen()"
|
|
126
140
|
>
|
|
127
141
|
<span class="cb-tree-select__label" [class.cb-is-placeholder]="!selectedLabel()">
|
|
128
|
-
{{ selectedLabel() || placeholder() }}
|
|
142
|
+
{{ selectedLabel() || (placeholder() ?? t().select) }}
|
|
129
143
|
</span>
|
|
130
144
|
<cb-icon name="chevron-down" [size]="16" aria-hidden="true" />
|
|
131
145
|
</button>
|
|
@@ -146,7 +160,7 @@ class CbTreeSelect {
|
|
|
146
160
|
type="button"
|
|
147
161
|
class="cb-tree-select__expander"
|
|
148
162
|
(click)="toggleNode(item.node.key, $event)"
|
|
149
|
-
[attr.aria-label]="
|
|
163
|
+
[attr.aria-label]="fmt(t().expandItem, item.node.label)"
|
|
150
164
|
>
|
|
151
165
|
<cb-icon
|
|
152
166
|
[name]="isExpanded(item.node.key) ? 'chevron-down' : 'chevron-right'"
|
|
@@ -184,9 +198,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
184
198
|
], host: {
|
|
185
199
|
class: 'cb-tree-select',
|
|
186
200
|
'[class.cb-is-open]': 'open()',
|
|
201
|
+
'(keydown.escape)': 'closeOnEscape($event)',
|
|
187
202
|
'[class.cb-is-disabled]': 'isDisabled()',
|
|
188
203
|
}, template: `
|
|
189
204
|
<button
|
|
205
|
+
#trigger
|
|
190
206
|
type="button"
|
|
191
207
|
class="cb-tree-select__trigger"
|
|
192
208
|
[class.cb-is-invalid]="fieldState.invalid()"
|
|
@@ -199,7 +215,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
199
215
|
(click)="toggleOpen()"
|
|
200
216
|
>
|
|
201
217
|
<span class="cb-tree-select__label" [class.cb-is-placeholder]="!selectedLabel()">
|
|
202
|
-
{{ selectedLabel() || placeholder() }}
|
|
218
|
+
{{ selectedLabel() || (placeholder() ?? t().select) }}
|
|
203
219
|
</span>
|
|
204
220
|
<cb-icon name="chevron-down" [size]="16" aria-hidden="true" />
|
|
205
221
|
</button>
|
|
@@ -220,7 +236,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
220
236
|
type="button"
|
|
221
237
|
class="cb-tree-select__expander"
|
|
222
238
|
(click)="toggleNode(item.node.key, $event)"
|
|
223
|
-
[attr.aria-label]="
|
|
239
|
+
[attr.aria-label]="fmt(t().expandItem, item.node.label)"
|
|
224
240
|
>
|
|
225
241
|
<cb-icon
|
|
226
242
|
[name]="isExpanded(item.node.key) ? 'chevron-down' : 'chevron-right'"
|
|
@@ -246,7 +262,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
|
|
|
246
262
|
</div>
|
|
247
263
|
}
|
|
248
264
|
`, styles: [":host{position:relative;display:inline-block;width:100%;font-family:var(--cb-font-sans)}.cb-tree-select__trigger{width:100%;display:flex;align-items:center;justify-content:space-between;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-md);background:var(--cb-color-surface);color:var(--cb-color-text);font-family:inherit;font-size:var(--cb-text-sm);cursor:pointer}.cb-tree-select__label.cb-is-placeholder{color:var(--cb-color-text-muted)}.cb-tree-select__panel{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:30;max-height:240px;overflow:auto;padding:var(--cb-space-1);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-md);background:var(--cb-color-surface);box-shadow:var(--cb-shadow-md, 0 8px 20px rgba(0, 0, 0, .12))}.cb-tree-select__item{display:flex;align-items:center;gap:.25rem;border-radius:var(--cb-radius-sm)}.cb-tree-select__item.cb-is-selected{background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent)}.cb-tree-select__expander{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;border:none;background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree-select__spacer{display:inline-block;width:1.25rem}.cb-tree-select__node-btn{flex:1;display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .5rem;border:none;background:transparent;color:var(--cb-color-text);font-family:inherit;font-size:var(--cb-text-sm);text-align:left;cursor:pointer}.cb-tree-select__trigger.cb-is-invalid{border-color:var(--cb-color-danger)}\n"] }]
|
|
249
|
-
}], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
265
|
+
}], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }] } });
|
|
250
266
|
|
|
251
267
|
/**
|
|
252
268
|
* Generated bundle index. Do not edit.
|