@nanahoshi/mona-ui 0.27.2 → 0.28.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/docs/api/chart.md +2 -2
- package/docs/api/popup.md +1 -1
- package/docs/api/theme.md +2 -2
- package/docs/chart.md +14 -0
- package/docs/editor.md +2 -0
- package/docs/installation.md +147 -15
- package/docs/introduction.md +37 -15
- package/docs/theming-built-in-themes.md +67 -0
- package/docs/theming-custom-colors.md +274 -0
- package/docs/theming-custom-themes.md +168 -0
- package/docs/theming.md +164 -248
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
- package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
- package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
- package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
- package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
- package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
- package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
- package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
- package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
- package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
- package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
- package/llms.txt +6 -2
- package/package.json +62 -23
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
- package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
- package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
- package/types/nanahoshi-mona-ui-button.d.ts +227 -166
- package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
- package/types/nanahoshi-mona-ui-card.d.ts +125 -111
- package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
- package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
- package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
- package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
- package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
- package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
- package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
- package/types/nanahoshi-mona-ui-command.d.ts +279 -191
- package/types/nanahoshi-mona-ui-common.d.ts +354 -385
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
- package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
- package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
- package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
- package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
- package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
- package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
- package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
- package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
- package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
- package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
- package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
- package/types/nanahoshi-mona-ui-label.d.ts +108 -78
- package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
- package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
- package/types/nanahoshi-mona-ui-list.d.ts +2 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
- package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
- package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
- package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
- package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
- package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
- package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
- package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
- package/types/nanahoshi-mona-ui-query.d.ts +82 -88
- package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
- package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
- package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
- package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
- package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
- package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
- package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
- package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
- package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
- package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
- package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
- package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
- package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
- package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
- package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
- package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
- package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
- package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
- package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
- package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
- package/types/nanahoshi-mona-ui-window.d.ts +494 -399
- package/types/nanahoshi-mona-ui.d.ts +1 -2
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
|
@@ -1,70 +1,54 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import { takeUntilDestroyed } from
|
|
4
|
-
import { IndicatorIconComponent } from
|
|
5
|
-
import { Subject, fromEvent, takeWhile } from
|
|
6
|
-
import { twMerge } from
|
|
7
|
-
import { cva } from
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
...(ngDevMode ? [{ debugName: "members" }] : /* istanbul ignore next */ []));
|
|
53
|
-
}
|
|
54
|
-
#members;
|
|
55
|
-
/**
|
|
56
|
-
* Sets the source of the group's members, such as the group's `contentChildren(ButtonDirective)` query.
|
|
57
|
-
*/
|
|
58
|
-
setMembers(members) {
|
|
59
|
-
this.#members.set(members);
|
|
60
|
-
}
|
|
61
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
62
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService }); }
|
|
63
|
-
}
|
|
64
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService, decorators: [{
|
|
65
|
-
type: Injectable
|
|
66
|
-
}] });
|
|
67
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ApplicationRef, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, Renderer2, afterNextRender, afterRenderEffect, booleanAttribute, computed, createComponent, effect, inject, input, isDevMode, model, numberAttribute, signal, untracked } from "@angular/core";
|
|
3
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
4
|
+
import { IndicatorIconComponent } from "@nanahoshi/mona-ui/internal/indicator-icon";
|
|
5
|
+
import { Subject, fromEvent, takeWhile } from "rxjs";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { cva } from "class-variance-authority";
|
|
8
|
+
import { themeControlSurfaceClasses, themeSelectionBorderClasses } from "@nanahoshi/mona-ui/internal";
|
|
9
|
+
var ButtonService = class ButtonService {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.#members = signal(null, ...ngDevMode ? [{ debugName: "#members" }] : /* istanbul ignore next */ []);
|
|
12
|
+
this.buttonClick$ = new Subject();
|
|
13
|
+
this.buttonSelect$ = new Subject();
|
|
14
|
+
this.groupDisabled = signal(false, ...ngDevMode ? [{ debugName: "groupDisabled" }] : /* istanbul ignore next */ []);
|
|
15
|
+
this.groupLook = signal(void 0, ...ngDevMode ? [{ debugName: "groupLook" }] : /* istanbul ignore next */ []);
|
|
16
|
+
this.groupReadonly = signal(false, ...ngDevMode ? [{ debugName: "groupReadonly" }] : /* istanbul ignore next */ []);
|
|
17
|
+
this.groupRounded = signal(void 0, ...ngDevMode ? [{ debugName: "groupRounded" }] : /* istanbul ignore next */ []);
|
|
18
|
+
this.groupSize = signal(void 0, ...ngDevMode ? [{ debugName: "groupSize" }] : /* istanbul ignore next */ []);
|
|
19
|
+
this.memberClick$ = new Subject();
|
|
20
|
+
this.members = computed(() => this.#members()?.() ?? [], ...ngDevMode ? [{ debugName: "members" }] : /* istanbul ignore next */ []);
|
|
21
|
+
}
|
|
22
|
+
#members;
|
|
23
|
+
setMembers(members) {
|
|
24
|
+
this.#members.set(members);
|
|
25
|
+
}
|
|
26
|
+
static {
|
|
27
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
28
|
+
minVersion: "12.0.0",
|
|
29
|
+
version: "22.2.6",
|
|
30
|
+
ngImport: i0,
|
|
31
|
+
type: ButtonService,
|
|
32
|
+
deps: [],
|
|
33
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static {
|
|
37
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
38
|
+
minVersion: "12.0.0",
|
|
39
|
+
version: "22.2.6",
|
|
40
|
+
ngImport: i0,
|
|
41
|
+
type: ButtonService
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
46
|
+
minVersion: "12.0.0",
|
|
47
|
+
version: "22.2.6",
|
|
48
|
+
ngImport: i0,
|
|
49
|
+
type: ButtonService,
|
|
50
|
+
decorators: [{ type: Injectable }]
|
|
51
|
+
});
|
|
68
52
|
const buttonThemeVariants = cva(`
|
|
69
53
|
inline-flex items-center justify-center gap-2
|
|
70
54
|
cursor-pointer whitespace-nowrap
|
|
@@ -73,550 +57,671 @@ const buttonThemeVariants = cva(`
|
|
|
73
57
|
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator
|
|
74
58
|
forced-colors:border forced-colors:border-[ButtonBorder]
|
|
75
59
|
`, {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
variants: {
|
|
61
|
+
disabled: {
|
|
62
|
+
true: `
|
|
79
63
|
pointer-events-none select-none
|
|
80
64
|
disabled:border-disabled-border disabled:bg-disabled-background disabled:text-disabled-foreground
|
|
81
65
|
disabled:shadow-none
|
|
82
66
|
`,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
67
|
+
false: ""
|
|
68
|
+
},
|
|
69
|
+
iconOnly: {
|
|
70
|
+
true: "aspect-square",
|
|
71
|
+
false: "aspect-auto"
|
|
72
|
+
},
|
|
73
|
+
loading: {
|
|
74
|
+
true: "pointer-events-none",
|
|
75
|
+
false: ""
|
|
76
|
+
},
|
|
77
|
+
look: {
|
|
78
|
+
default: `
|
|
95
79
|
${themeControlSurfaceClasses} text-foreground
|
|
96
80
|
border border-input-border
|
|
97
81
|
hover:bg-hover active:bg-active
|
|
98
82
|
focus-visible:border-focus-indicator
|
|
99
83
|
`,
|
|
100
|
-
|
|
84
|
+
primary: `
|
|
101
85
|
bg-primary text-primary-foreground
|
|
102
86
|
hover:bg-primary-hover active:bg-primary-active
|
|
103
87
|
`,
|
|
104
|
-
|
|
88
|
+
success: `
|
|
105
89
|
bg-success text-success-foreground
|
|
106
90
|
hover:bg-success-hover
|
|
107
91
|
active:bg-success-active
|
|
108
92
|
`,
|
|
109
|
-
|
|
93
|
+
error: `
|
|
110
94
|
bg-error text-error-foreground
|
|
111
95
|
hover:bg-error-hover
|
|
112
96
|
active:bg-error-active
|
|
113
97
|
`,
|
|
114
|
-
|
|
98
|
+
warning: `
|
|
115
99
|
bg-warning text-warning-foreground
|
|
116
100
|
hover:bg-warning-hover
|
|
117
101
|
active:bg-warning-active
|
|
118
102
|
`,
|
|
119
|
-
|
|
103
|
+
info: `
|
|
120
104
|
bg-info text-info-foreground
|
|
121
105
|
hover:bg-info-hover
|
|
122
106
|
active:bg-info-active
|
|
123
107
|
`,
|
|
124
|
-
|
|
108
|
+
outline: `
|
|
125
109
|
${themeControlSurfaceClasses} text-foreground
|
|
126
110
|
border border-input-border
|
|
127
111
|
hover:bg-hover active:bg-active
|
|
128
112
|
focus-visible:border-focus-indicator
|
|
129
113
|
`,
|
|
130
|
-
|
|
114
|
+
secondary: `
|
|
131
115
|
bg-secondary text-secondary-foreground
|
|
132
116
|
hover:bg-secondary-hover
|
|
133
117
|
active:bg-secondary-active
|
|
134
118
|
`,
|
|
135
|
-
|
|
119
|
+
ghost: `
|
|
136
120
|
bg-transparent text-foreground
|
|
137
121
|
shadow-none
|
|
138
122
|
hover:bg-hover active:bg-active
|
|
139
123
|
`,
|
|
140
|
-
|
|
124
|
+
link: `
|
|
141
125
|
bg-transparent text-foreground
|
|
142
126
|
shadow-none
|
|
143
127
|
underline-offset-4 hover:underline
|
|
144
128
|
`,
|
|
145
|
-
|
|
129
|
+
clear: `
|
|
146
130
|
bg-transparent
|
|
147
131
|
border-0 shadow-none
|
|
148
132
|
hover:bg-transparent active:bg-transparent
|
|
149
133
|
`
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
selected: true,
|
|
171
|
-
class: `
|
|
134
|
+
},
|
|
135
|
+
rounded: {
|
|
136
|
+
full: "rounded-full",
|
|
137
|
+
large: "rounded-lg",
|
|
138
|
+
medium: "rounded-md",
|
|
139
|
+
none: "rounded-none",
|
|
140
|
+
small: "rounded-sm"
|
|
141
|
+
},
|
|
142
|
+
size: {
|
|
143
|
+
large: "h-10 px-6",
|
|
144
|
+
medium: "h-9 px-4",
|
|
145
|
+
small: "h-8 px-3 text-xs"
|
|
146
|
+
},
|
|
147
|
+
selected: { true: themeSelectionBorderClasses }
|
|
148
|
+
},
|
|
149
|
+
compoundVariants: [
|
|
150
|
+
{
|
|
151
|
+
look: "default",
|
|
152
|
+
selected: true,
|
|
153
|
+
class: `
|
|
172
154
|
after:-inset-px
|
|
173
155
|
bg-(--color-selected) text-(--color-selected-foreground)
|
|
174
156
|
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
175
157
|
active:bg-(--color-selected-active) active:text-(--color-selected-active-foreground)
|
|
176
158
|
`
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
look: "primary",
|
|
162
|
+
selected: true,
|
|
163
|
+
class: `
|
|
182
164
|
bg-primary-selected text-primary-foreground
|
|
183
165
|
hover:bg-primary-selected hover:text-primary-foreground
|
|
184
166
|
active:bg-primary-active active:text-primary-foreground
|
|
185
167
|
`
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
look: "secondary",
|
|
171
|
+
selected: true,
|
|
172
|
+
class: `
|
|
191
173
|
bg-secondary-selected text-secondary-foreground
|
|
192
174
|
hover:bg-secondary-selected hover:text-secondary-foreground
|
|
193
175
|
active:bg-secondary-active active:text-secondary-foreground
|
|
194
176
|
`
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
look: "success",
|
|
180
|
+
selected: true,
|
|
181
|
+
class: `
|
|
200
182
|
bg-success-selected text-success-foreground
|
|
201
183
|
hover:bg-success-selected hover:text-success-foreground
|
|
202
184
|
active:bg-success-active active:text-success-foreground
|
|
203
185
|
`
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
look: "error",
|
|
189
|
+
selected: true,
|
|
190
|
+
class: `
|
|
209
191
|
bg-error-selected text-error-foreground
|
|
210
192
|
hover:bg-error-selected hover:text-error-foreground
|
|
211
193
|
active:bg-error-active active:text-error-foreground
|
|
212
194
|
`
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
look: "warning",
|
|
198
|
+
selected: true,
|
|
199
|
+
class: `
|
|
218
200
|
bg-warning-selected text-warning-foreground
|
|
219
201
|
hover:bg-warning-selected hover:text-warning-foreground
|
|
220
202
|
active:bg-warning-active active:text-warning-foreground
|
|
221
203
|
`
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
look: "info",
|
|
207
|
+
selected: true,
|
|
208
|
+
class: `
|
|
227
209
|
bg-info-selected text-info-foreground
|
|
228
210
|
hover:bg-info-selected hover:text-info-foreground
|
|
229
211
|
active:bg-info-active active:text-info-foreground
|
|
230
212
|
`
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
look: "outline",
|
|
216
|
+
selected: true,
|
|
217
|
+
class: `
|
|
236
218
|
after:-inset-px
|
|
237
219
|
bg-(--color-selected) text-(--color-selected-foreground)
|
|
238
220
|
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
239
221
|
active:bg-(--color-selected-active) active:text-(--color-selected-active-foreground)
|
|
240
222
|
`
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
look: "ghost",
|
|
226
|
+
selected: true,
|
|
227
|
+
class: `
|
|
246
228
|
bg-(--color-selected) text-(--color-selected-foreground)
|
|
247
229
|
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
248
230
|
active:bg-(--color-selected-active) active:text-(--color-selected-active-foreground)
|
|
249
231
|
`
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
look: "link",
|
|
235
|
+
selected: true,
|
|
236
|
+
class: `
|
|
255
237
|
bg-(--color-selected) text-(--color-selected-foreground)
|
|
256
238
|
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
257
239
|
active:bg-(--color-selected-active) active:text-(--color-selected-active-foreground)
|
|
258
240
|
`
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
look: "clear",
|
|
244
|
+
selected: true,
|
|
245
|
+
class: `
|
|
264
246
|
bg-transparent border-0
|
|
265
247
|
hover:bg-transparent active:bg-transparent
|
|
266
248
|
`
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
disabled: true,
|
|
252
|
+
look: "ghost",
|
|
253
|
+
class: "disabled:bg-transparent disabled:text-disabled-foreground"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
iconOnly: true,
|
|
257
|
+
loading: true,
|
|
258
|
+
class: "[&>:not(mona-indicator-icon)]:hidden"
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
iconOnly: true,
|
|
262
|
+
size: "small",
|
|
263
|
+
class: "h-8 w-8 p-0"
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
iconOnly: true,
|
|
267
|
+
size: "medium",
|
|
268
|
+
class: "h-9 w-9 p-0"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
iconOnly: true,
|
|
272
|
+
size: "large",
|
|
273
|
+
class: "h-10 w-10 p-0"
|
|
274
|
+
}
|
|
275
|
+
],
|
|
276
|
+
defaultVariants: {
|
|
277
|
+
look: "default",
|
|
278
|
+
rounded: "medium",
|
|
279
|
+
size: "medium"
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
var ButtonDirective = class ButtonDirective {
|
|
283
|
+
#appRef;
|
|
284
|
+
#buttonService;
|
|
285
|
+
#destroyRef;
|
|
286
|
+
#group;
|
|
287
|
+
#hostElementRef;
|
|
288
|
+
#injector;
|
|
289
|
+
#renderer;
|
|
290
|
+
#loaderComponentRef;
|
|
291
|
+
#toggleSubscription;
|
|
292
|
+
constructor() {
|
|
293
|
+
this.#appRef = inject(ApplicationRef);
|
|
294
|
+
this.#buttonService = inject(ButtonService, { optional: true });
|
|
295
|
+
this.#destroyRef = inject(DestroyRef);
|
|
296
|
+
this.#group = computed(() => this.#buttonService?.members().includes(this) ? this.#buttonService : null, ...ngDevMode ? [{ debugName: "#group" }] : /* istanbul ignore next */ []);
|
|
297
|
+
this.#hostElementRef = inject(ElementRef);
|
|
298
|
+
this.#injector = inject(Injector);
|
|
299
|
+
this.#renderer = inject(Renderer2);
|
|
300
|
+
this.#loaderComponentRef = null;
|
|
301
|
+
this.#toggleSubscription = null;
|
|
302
|
+
this.baseClass = computed(() => {
|
|
303
|
+
const disabled = this.effectiveDisabled();
|
|
304
|
+
const iconOnly = this.iconOnly();
|
|
305
|
+
const loading = this.loading();
|
|
306
|
+
const look = this.effectiveLook();
|
|
307
|
+
const rounded = this.effectiveRounded();
|
|
308
|
+
const size = this.effectiveSize();
|
|
309
|
+
const selected = this.selected();
|
|
310
|
+
const userClass = this.userClass();
|
|
311
|
+
const variantClasses = buttonThemeVariants({
|
|
312
|
+
disabled,
|
|
313
|
+
iconOnly,
|
|
314
|
+
loading,
|
|
315
|
+
look,
|
|
316
|
+
rounded,
|
|
317
|
+
selected,
|
|
318
|
+
size
|
|
319
|
+
});
|
|
320
|
+
return twMerge(variantClasses, userClass);
|
|
321
|
+
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
322
|
+
this.effectiveLook = computed(() => this.#group()?.groupLook() ?? this.look(), ...ngDevMode ? [{ debugName: "effectiveLook" }] : /* istanbul ignore next */ []);
|
|
323
|
+
this.effectiveRounded = computed(() => this.#group()?.groupRounded() ?? this.rounded(), ...ngDevMode ? [{ debugName: "effectiveRounded" }] : /* istanbul ignore next */ []);
|
|
324
|
+
this.effectiveSize = computed(() => this.#group()?.groupSize() ?? this.size(), ...ngDevMode ? [{ debugName: "effectiveSize" }] : /* istanbul ignore next */ []);
|
|
325
|
+
this.groupReadonly = computed(() => !!this.#group()?.groupReadonly() && this.effectiveToggleable(), ...ngDevMode ? [{ debugName: "groupReadonly" }] : /* istanbul ignore next */ []);
|
|
326
|
+
this.loadingSize = computed(() => {
|
|
327
|
+
switch (this.effectiveSize()) {
|
|
328
|
+
case "small": return 12;
|
|
329
|
+
case "large": return 16;
|
|
330
|
+
default: return 14;
|
|
331
|
+
}
|
|
332
|
+
}, ...ngDevMode ? [{ debugName: "loadingSize" }] : /* istanbul ignore next */ []);
|
|
333
|
+
this.ariaHasPopup = input("false", {
|
|
334
|
+
...ngDevMode ? { debugName: "ariaHasPopup" } : /* istanbul ignore next */ {},
|
|
335
|
+
alias: "aria-haspopup"
|
|
336
|
+
});
|
|
337
|
+
this.disabled = input(false, {
|
|
338
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
339
|
+
transform: booleanAttribute
|
|
340
|
+
});
|
|
341
|
+
this.effectiveDisabled = computed(() => this.#group()?.groupDisabled() || this.disabled(), ...ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []);
|
|
342
|
+
this.effectiveToggleable = computed(() => this.toggleable() ?? !!this.#group(), ...ngDevMode ? [{ debugName: "effectiveToggleable" }] : /* istanbul ignore next */ []);
|
|
343
|
+
this.iconOnly = input(false, {
|
|
344
|
+
...ngDevMode ? { debugName: "iconOnly" } : /* istanbul ignore next */ {},
|
|
345
|
+
transform: booleanAttribute
|
|
346
|
+
});
|
|
347
|
+
this.loading = input(false, {
|
|
348
|
+
...ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {},
|
|
349
|
+
transform: booleanAttribute
|
|
350
|
+
});
|
|
351
|
+
this.look = model("default", ...ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []);
|
|
352
|
+
this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
|
|
353
|
+
this.selected = model(false, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
|
|
354
|
+
this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
|
|
355
|
+
this.tabindex = input(0, {
|
|
356
|
+
...ngDevMode ? { debugName: "tabindex" } : /* istanbul ignore next */ {},
|
|
357
|
+
transform: (value) => numberAttribute(value, 0)
|
|
358
|
+
});
|
|
359
|
+
this.toggleable = input(void 0, {
|
|
360
|
+
...ngDevMode ? { debugName: "toggleable" } : /* istanbul ignore next */ {},
|
|
361
|
+
transform: (value) => value === void 0 ? void 0 : booleanAttribute(value)
|
|
362
|
+
});
|
|
363
|
+
this.type = input("button", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
|
|
364
|
+
this.userClass = input("", {
|
|
365
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
366
|
+
alias: "class"
|
|
367
|
+
});
|
|
368
|
+
this.value = input(...ngDevMode ? [void 0, { debugName: "value" }] : /* istanbul ignore next */ []);
|
|
369
|
+
effect(() => {
|
|
370
|
+
if (this.effectiveToggleable()) untracked(() => this.#setToggleableEvent());
|
|
371
|
+
});
|
|
372
|
+
effect(() => {
|
|
373
|
+
const loading = this.loading();
|
|
374
|
+
const loaderSize = this.loadingSize();
|
|
375
|
+
untracked(() => {
|
|
376
|
+
if (loading) this.#createLoader(loaderSize);
|
|
377
|
+
else this.#removeLoader();
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
this.#blockClicksWhileLoading();
|
|
381
|
+
this.#destroyRef.onDestroy(() => this.#removeLoader());
|
|
382
|
+
if (this.#buttonService) afterNextRender({ read: () => this.#setSubscriptions() });
|
|
383
|
+
if (isDevMode()) this.#warnIfIconOnlyWithoutName();
|
|
384
|
+
}
|
|
385
|
+
#blockClicksWhileLoading() {
|
|
386
|
+
const host = this.#hostElementRef.nativeElement;
|
|
387
|
+
const listener = (event) => {
|
|
388
|
+
if (this.loading()) {
|
|
389
|
+
event.preventDefault();
|
|
390
|
+
event.stopImmediatePropagation();
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
host.addEventListener("click", listener, { capture: true });
|
|
394
|
+
this.#destroyRef.onDestroy(() => host.removeEventListener("click", listener, { capture: true }));
|
|
395
|
+
}
|
|
396
|
+
#createLoader(size) {
|
|
397
|
+
if (this.#loaderComponentRef) {
|
|
398
|
+
this.#loaderComponentRef.setInput("size", size);
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
this.#loaderComponentRef = createComponent(IndicatorIconComponent, {
|
|
402
|
+
environmentInjector: this.#appRef.injector,
|
|
403
|
+
elementInjector: this.#injector
|
|
404
|
+
});
|
|
405
|
+
this.#loaderComponentRef.setInput("preset", "loading");
|
|
406
|
+
this.#loaderComponentRef.setInput("size", size);
|
|
407
|
+
this.#loaderComponentRef.setInput("class", "self-center h-auto");
|
|
408
|
+
this.#appRef.attachView(this.#loaderComponentRef.hostView);
|
|
409
|
+
const loaderElement = this.#loaderComponentRef.location.nativeElement;
|
|
410
|
+
this.#renderer.insertBefore(this.#hostElementRef.nativeElement, loaderElement, this.#hostElementRef.nativeElement.firstChild);
|
|
411
|
+
}
|
|
412
|
+
#removeLoader() {
|
|
413
|
+
if (this.#loaderComponentRef) {
|
|
414
|
+
this.#appRef.detachView(this.#loaderComponentRef.hostView);
|
|
415
|
+
this.#loaderComponentRef.destroy();
|
|
416
|
+
this.#loaderComponentRef = null;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
#setSubscriptions() {
|
|
420
|
+
this.#buttonService?.buttonSelect$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((result) => {
|
|
421
|
+
const [button, selected] = result;
|
|
422
|
+
if (button === this) this.selected.set(selected);
|
|
423
|
+
});
|
|
424
|
+
const host = this.#hostElementRef.nativeElement;
|
|
425
|
+
fromEvent(host, "click").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
426
|
+
if (!this.effectiveToggleable()) this.#group()?.memberClick$.next([this, host]);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
#hasAccessibleName() {
|
|
430
|
+
const host = this.#hostElementRef.nativeElement;
|
|
431
|
+
return [
|
|
432
|
+
"aria-label",
|
|
433
|
+
"aria-labelledby",
|
|
434
|
+
"title"
|
|
435
|
+
].some((name) => !!host.getAttribute(name)?.trim()) || !!host.textContent?.trim();
|
|
436
|
+
}
|
|
437
|
+
#setToggleableEvent() {
|
|
438
|
+
this.#toggleSubscription?.unsubscribe();
|
|
439
|
+
this.#toggleSubscription = fromEvent(this.#hostElementRef.nativeElement, "click").pipe(takeUntilDestroyed(this.#destroyRef), takeWhile(() => this.effectiveToggleable())).subscribe(() => {
|
|
440
|
+
if (this.effectiveDisabled()) return;
|
|
441
|
+
const wasSelected = this.selected();
|
|
442
|
+
const group = this.#group();
|
|
443
|
+
if (group) {
|
|
444
|
+
group.buttonClick$.next([this, wasSelected]);
|
|
445
|
+
group.memberClick$.next([this, this.#hostElementRef.nativeElement]);
|
|
446
|
+
} else this.selected.set(!this.selected());
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
#warnIfIconOnlyWithoutName() {
|
|
450
|
+
let warned = false;
|
|
451
|
+
afterRenderEffect({ read: () => {
|
|
452
|
+
if (warned || !this.iconOnly() || this.#hasAccessibleName()) return;
|
|
453
|
+
warned = true;
|
|
454
|
+
console.warn("[Mona Button] An icon-only button needs an accessible name. Add aria-label, aria-labelledby or title.", this.#hostElementRef.nativeElement);
|
|
455
|
+
} });
|
|
456
|
+
}
|
|
457
|
+
static {
|
|
458
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
459
|
+
minVersion: "12.0.0",
|
|
460
|
+
version: "22.2.6",
|
|
461
|
+
ngImport: i0,
|
|
462
|
+
type: ButtonDirective,
|
|
463
|
+
deps: [],
|
|
464
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
static {
|
|
468
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
469
|
+
minVersion: "17.1.0",
|
|
470
|
+
version: "22.2.6",
|
|
471
|
+
type: ButtonDirective,
|
|
472
|
+
isStandalone: true,
|
|
473
|
+
selector: "button[monaButton]",
|
|
474
|
+
inputs: {
|
|
475
|
+
ariaHasPopup: {
|
|
476
|
+
classPropertyName: "ariaHasPopup",
|
|
477
|
+
publicName: "aria-haspopup",
|
|
478
|
+
isSignal: true,
|
|
479
|
+
isRequired: false,
|
|
480
|
+
transformFunction: null
|
|
481
|
+
},
|
|
482
|
+
disabled: {
|
|
483
|
+
classPropertyName: "disabled",
|
|
484
|
+
publicName: "disabled",
|
|
485
|
+
isSignal: true,
|
|
486
|
+
isRequired: false,
|
|
487
|
+
transformFunction: null
|
|
488
|
+
},
|
|
489
|
+
iconOnly: {
|
|
490
|
+
classPropertyName: "iconOnly",
|
|
491
|
+
publicName: "iconOnly",
|
|
492
|
+
isSignal: true,
|
|
493
|
+
isRequired: false,
|
|
494
|
+
transformFunction: null
|
|
495
|
+
},
|
|
496
|
+
loading: {
|
|
497
|
+
classPropertyName: "loading",
|
|
498
|
+
publicName: "loading",
|
|
499
|
+
isSignal: true,
|
|
500
|
+
isRequired: false,
|
|
501
|
+
transformFunction: null
|
|
502
|
+
},
|
|
503
|
+
look: {
|
|
504
|
+
classPropertyName: "look",
|
|
505
|
+
publicName: "look",
|
|
506
|
+
isSignal: true,
|
|
507
|
+
isRequired: false,
|
|
508
|
+
transformFunction: null
|
|
509
|
+
},
|
|
510
|
+
rounded: {
|
|
511
|
+
classPropertyName: "rounded",
|
|
512
|
+
publicName: "rounded",
|
|
513
|
+
isSignal: true,
|
|
514
|
+
isRequired: false,
|
|
515
|
+
transformFunction: null
|
|
516
|
+
},
|
|
517
|
+
selected: {
|
|
518
|
+
classPropertyName: "selected",
|
|
519
|
+
publicName: "selected",
|
|
520
|
+
isSignal: true,
|
|
521
|
+
isRequired: false,
|
|
522
|
+
transformFunction: null
|
|
523
|
+
},
|
|
524
|
+
size: {
|
|
525
|
+
classPropertyName: "size",
|
|
526
|
+
publicName: "size",
|
|
527
|
+
isSignal: true,
|
|
528
|
+
isRequired: false,
|
|
529
|
+
transformFunction: null
|
|
530
|
+
},
|
|
531
|
+
tabindex: {
|
|
532
|
+
classPropertyName: "tabindex",
|
|
533
|
+
publicName: "tabindex",
|
|
534
|
+
isSignal: true,
|
|
535
|
+
isRequired: false,
|
|
536
|
+
transformFunction: null
|
|
537
|
+
},
|
|
538
|
+
toggleable: {
|
|
539
|
+
classPropertyName: "toggleable",
|
|
540
|
+
publicName: "toggleable",
|
|
541
|
+
isSignal: true,
|
|
542
|
+
isRequired: false,
|
|
543
|
+
transformFunction: null
|
|
544
|
+
},
|
|
545
|
+
type: {
|
|
546
|
+
classPropertyName: "type",
|
|
547
|
+
publicName: "type",
|
|
548
|
+
isSignal: true,
|
|
549
|
+
isRequired: false,
|
|
550
|
+
transformFunction: null
|
|
551
|
+
},
|
|
552
|
+
userClass: {
|
|
553
|
+
classPropertyName: "userClass",
|
|
554
|
+
publicName: "class",
|
|
555
|
+
isSignal: true,
|
|
556
|
+
isRequired: false,
|
|
557
|
+
transformFunction: null
|
|
558
|
+
},
|
|
559
|
+
value: {
|
|
560
|
+
classPropertyName: "value",
|
|
561
|
+
publicName: "value",
|
|
562
|
+
isSignal: true,
|
|
563
|
+
isRequired: false,
|
|
564
|
+
transformFunction: null
|
|
565
|
+
}
|
|
566
|
+
},
|
|
567
|
+
outputs: {
|
|
568
|
+
look: "lookChange",
|
|
569
|
+
selected: "selectedChange"
|
|
570
|
+
},
|
|
571
|
+
host: { properties: {
|
|
572
|
+
"attr.aria-busy": "loading() ? 'true' : undefined",
|
|
573
|
+
"attr.aria-disabled": "effectiveDisabled() || loading() || groupReadonly() ? 'true' : undefined",
|
|
574
|
+
"attr.aria-haspopup": "ariaHasPopup() !== 'false' ? ariaHasPopup() : null",
|
|
575
|
+
"attr.aria-pressed": "effectiveToggleable() ? (selected() ? 'true' : 'false') : undefined",
|
|
576
|
+
"attr.data-look": "effectiveLook()",
|
|
577
|
+
"attr.data-size": "effectiveSize()",
|
|
578
|
+
"attr.disabled": "effectiveDisabled() ? '' : undefined",
|
|
579
|
+
"attr.tabindex": "effectiveDisabled() ? -1 : tabindex()",
|
|
580
|
+
"attr.type": "type()",
|
|
581
|
+
"class": "baseClass()"
|
|
582
|
+
} },
|
|
583
|
+
ngImport: i0
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
588
|
+
minVersion: "12.0.0",
|
|
589
|
+
version: "22.2.6",
|
|
590
|
+
ngImport: i0,
|
|
591
|
+
type: ButtonDirective,
|
|
592
|
+
decorators: [{
|
|
593
|
+
type: Directive,
|
|
594
|
+
args: [{
|
|
595
|
+
selector: "button[monaButton]",
|
|
596
|
+
host: {
|
|
597
|
+
"[attr.aria-busy]": "loading() ? 'true' : undefined",
|
|
598
|
+
"[attr.aria-disabled]": "effectiveDisabled() || loading() || groupReadonly() ? 'true' : undefined",
|
|
599
|
+
"[attr.aria-haspopup]": "ariaHasPopup() !== 'false' ? ariaHasPopup() : null",
|
|
600
|
+
"[attr.aria-pressed]": "effectiveToggleable() ? (selected() ? 'true' : 'false') : undefined",
|
|
601
|
+
"[attr.data-look]": "effectiveLook()",
|
|
602
|
+
"[attr.data-size]": "effectiveSize()",
|
|
603
|
+
"[attr.disabled]": "effectiveDisabled() ? '' : undefined",
|
|
604
|
+
"[attr.tabindex]": "effectiveDisabled() ? -1 : tabindex()",
|
|
605
|
+
"[attr.type]": "type()",
|
|
606
|
+
"[class]": "baseClass()"
|
|
607
|
+
}
|
|
608
|
+
}]
|
|
609
|
+
}],
|
|
610
|
+
ctorParameters: () => [],
|
|
611
|
+
propDecorators: {
|
|
612
|
+
ariaHasPopup: [{
|
|
613
|
+
type: i0.Input,
|
|
614
|
+
args: [{
|
|
615
|
+
isSignal: true,
|
|
616
|
+
alias: "aria-haspopup",
|
|
617
|
+
required: false
|
|
618
|
+
}]
|
|
619
|
+
}],
|
|
620
|
+
disabled: [{
|
|
621
|
+
type: i0.Input,
|
|
622
|
+
args: [{
|
|
623
|
+
isSignal: true,
|
|
624
|
+
alias: "disabled",
|
|
625
|
+
required: false
|
|
626
|
+
}]
|
|
627
|
+
}],
|
|
628
|
+
iconOnly: [{
|
|
629
|
+
type: i0.Input,
|
|
630
|
+
args: [{
|
|
631
|
+
isSignal: true,
|
|
632
|
+
alias: "iconOnly",
|
|
633
|
+
required: false
|
|
634
|
+
}]
|
|
635
|
+
}],
|
|
636
|
+
loading: [{
|
|
637
|
+
type: i0.Input,
|
|
638
|
+
args: [{
|
|
639
|
+
isSignal: true,
|
|
640
|
+
alias: "loading",
|
|
641
|
+
required: false
|
|
642
|
+
}]
|
|
643
|
+
}],
|
|
644
|
+
look: [{
|
|
645
|
+
type: i0.Input,
|
|
646
|
+
args: [{
|
|
647
|
+
isSignal: true,
|
|
648
|
+
alias: "look",
|
|
649
|
+
required: false
|
|
650
|
+
}]
|
|
651
|
+
}, {
|
|
652
|
+
type: i0.Output,
|
|
653
|
+
args: ["lookChange"]
|
|
654
|
+
}],
|
|
655
|
+
rounded: [{
|
|
656
|
+
type: i0.Input,
|
|
657
|
+
args: [{
|
|
658
|
+
isSignal: true,
|
|
659
|
+
alias: "rounded",
|
|
660
|
+
required: false
|
|
661
|
+
}]
|
|
662
|
+
}],
|
|
663
|
+
selected: [{
|
|
664
|
+
type: i0.Input,
|
|
665
|
+
args: [{
|
|
666
|
+
isSignal: true,
|
|
667
|
+
alias: "selected",
|
|
668
|
+
required: false
|
|
669
|
+
}]
|
|
670
|
+
}, {
|
|
671
|
+
type: i0.Output,
|
|
672
|
+
args: ["selectedChange"]
|
|
673
|
+
}],
|
|
674
|
+
size: [{
|
|
675
|
+
type: i0.Input,
|
|
676
|
+
args: [{
|
|
677
|
+
isSignal: true,
|
|
678
|
+
alias: "size",
|
|
679
|
+
required: false
|
|
680
|
+
}]
|
|
681
|
+
}],
|
|
682
|
+
tabindex: [{
|
|
683
|
+
type: i0.Input,
|
|
684
|
+
args: [{
|
|
685
|
+
isSignal: true,
|
|
686
|
+
alias: "tabindex",
|
|
687
|
+
required: false
|
|
688
|
+
}]
|
|
689
|
+
}],
|
|
690
|
+
toggleable: [{
|
|
691
|
+
type: i0.Input,
|
|
692
|
+
args: [{
|
|
693
|
+
isSignal: true,
|
|
694
|
+
alias: "toggleable",
|
|
695
|
+
required: false
|
|
696
|
+
}]
|
|
697
|
+
}],
|
|
698
|
+
type: [{
|
|
699
|
+
type: i0.Input,
|
|
700
|
+
args: [{
|
|
701
|
+
isSignal: true,
|
|
702
|
+
alias: "type",
|
|
703
|
+
required: false
|
|
704
|
+
}]
|
|
705
|
+
}],
|
|
706
|
+
userClass: [{
|
|
707
|
+
type: i0.Input,
|
|
708
|
+
args: [{
|
|
709
|
+
isSignal: true,
|
|
710
|
+
alias: "class",
|
|
711
|
+
required: false
|
|
712
|
+
}]
|
|
713
|
+
}],
|
|
714
|
+
value: [{
|
|
715
|
+
type: i0.Input,
|
|
716
|
+
args: [{
|
|
717
|
+
isSignal: true,
|
|
718
|
+
alias: "value",
|
|
719
|
+
required: false
|
|
720
|
+
}]
|
|
721
|
+
}]
|
|
722
|
+
}
|
|
299
723
|
});
|
|
300
|
-
|
|
301
|
-
class ButtonDirective {
|
|
302
|
-
#appRef;
|
|
303
|
-
#buttonService;
|
|
304
|
-
#destroyRef;
|
|
305
|
-
/**
|
|
306
|
-
* The service of the group this button belongs to. A `ButtonService` higher up the injector tree is not enough:
|
|
307
|
-
* buttons inside a component projected into a group, or inside a popup opened from one, are not members.
|
|
308
|
-
*/
|
|
309
|
-
#group;
|
|
310
|
-
#hostElementRef;
|
|
311
|
-
#injector;
|
|
312
|
-
#renderer;
|
|
313
|
-
#loaderComponentRef;
|
|
314
|
-
#toggleSubscription;
|
|
315
|
-
constructor() {
|
|
316
|
-
this.#appRef = inject(ApplicationRef);
|
|
317
|
-
this.#buttonService = inject(ButtonService, { optional: true });
|
|
318
|
-
this.#destroyRef = inject(DestroyRef);
|
|
319
|
-
/**
|
|
320
|
-
* The service of the group this button belongs to. A `ButtonService` higher up the injector tree is not enough:
|
|
321
|
-
* buttons inside a component projected into a group, or inside a popup opened from one, are not members.
|
|
322
|
-
*/
|
|
323
|
-
this.#group = computed(() => (this.#buttonService?.members().includes(this) ? this.#buttonService : null), /* @ts-ignore */
|
|
324
|
-
...(ngDevMode ? [{ debugName: "#group" }] : /* istanbul ignore next */ []));
|
|
325
|
-
this.#hostElementRef = inject(ElementRef);
|
|
326
|
-
this.#injector = inject(Injector);
|
|
327
|
-
this.#renderer = inject(Renderer2);
|
|
328
|
-
this.#loaderComponentRef = null;
|
|
329
|
-
this.#toggleSubscription = null;
|
|
330
|
-
this.baseClass = computed(() => {
|
|
331
|
-
const disabled = this.effectiveDisabled();
|
|
332
|
-
const iconOnly = this.iconOnly();
|
|
333
|
-
const loading = this.loading();
|
|
334
|
-
const look = this.effectiveLook();
|
|
335
|
-
const rounded = this.effectiveRounded();
|
|
336
|
-
const size = this.effectiveSize();
|
|
337
|
-
const selected = this.selected();
|
|
338
|
-
const userClass = this.userClass();
|
|
339
|
-
const variantClasses = buttonThemeVariants({ disabled, iconOnly, loading, look, rounded, selected, size });
|
|
340
|
-
return twMerge(variantClasses, userClass);
|
|
341
|
-
}, /* @ts-ignore */
|
|
342
|
-
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
343
|
-
this.effectiveLook = computed(() => this.#group()?.groupLook() ?? this.look(), /* @ts-ignore */
|
|
344
|
-
...(ngDevMode ? [{ debugName: "effectiveLook" }] : /* istanbul ignore next */ []));
|
|
345
|
-
this.effectiveRounded = computed(() => this.#group()?.groupRounded() ?? this.rounded(), /* @ts-ignore */
|
|
346
|
-
...(ngDevMode ? [{ debugName: "effectiveRounded" }] : /* istanbul ignore next */ []));
|
|
347
|
-
this.effectiveSize = computed(() => this.#group()?.groupSize() ?? this.size(), /* @ts-ignore */
|
|
348
|
-
...(ngDevMode ? [{ debugName: "effectiveSize" }] : /* istanbul ignore next */ []));
|
|
349
|
-
/**
|
|
350
|
-
* A read-only group's toggle buttons keep focus, so they can't be natively disabled.
|
|
351
|
-
*/
|
|
352
|
-
this.groupReadonly = computed(() => !!this.#group()?.groupReadonly() && this.effectiveToggleable(), /* @ts-ignore */
|
|
353
|
-
...(ngDevMode ? [{ debugName: "groupReadonly" }] : /* istanbul ignore next */ []));
|
|
354
|
-
this.loadingSize = computed(() => {
|
|
355
|
-
const size = this.effectiveSize();
|
|
356
|
-
switch (size) {
|
|
357
|
-
case "small":
|
|
358
|
-
return 12;
|
|
359
|
-
case "large":
|
|
360
|
-
return 16;
|
|
361
|
-
case "medium":
|
|
362
|
-
default:
|
|
363
|
-
return 14;
|
|
364
|
-
}
|
|
365
|
-
}, /* @ts-ignore */
|
|
366
|
-
...(ngDevMode ? [{ debugName: "loadingSize" }] : /* istanbul ignore next */ []));
|
|
367
|
-
/**
|
|
368
|
-
* @description Value forwarded to the `aria-haspopup` attribute. Set when this button triggers a popup, menu,
|
|
369
|
-
* listbox, tree, grid, or dialog. Omit or leave as `"false"` for plain action buttons.
|
|
370
|
-
* @default "false"
|
|
371
|
-
*/
|
|
372
|
-
this.ariaHasPopup = input("false", { ...(ngDevMode ? { debugName: "ariaHasPopup" } : /* istanbul ignore next */ {}), alias: "aria-haspopup" });
|
|
373
|
-
/**
|
|
374
|
-
* @description Renders the component with reduced visual emphasis and removes pointer interaction.
|
|
375
|
-
* Accepts the bare attribute form (`<button monaButton disabled>`).
|
|
376
|
-
* When inside a `ButtonGroup`, the button is disabled when either it or the group is disabled.
|
|
377
|
-
* @default false
|
|
378
|
-
*/
|
|
379
|
-
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
380
|
-
/**
|
|
381
|
-
* Whether the button is disabled, by its own input or its group's. A dropdown or split button reads this to close
|
|
382
|
-
* its menu.
|
|
383
|
-
*/
|
|
384
|
-
this.effectiveDisabled = computed(() => this.#group()?.groupDisabled() || this.disabled(), /* @ts-ignore */
|
|
385
|
-
...(ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []));
|
|
386
|
-
/**
|
|
387
|
-
* Whether a click toggles the button: buttons in a group do unless `toggleable` is `false`. The group reads this to
|
|
388
|
-
* know which buttons take part in its selection.
|
|
389
|
-
*/
|
|
390
|
-
this.effectiveToggleable = computed(() => this.toggleable() ?? !!this.#group(), /* @ts-ignore */
|
|
391
|
-
...(ngDevMode ? [{ debugName: "effectiveToggleable" }] : /* istanbul ignore next */ []));
|
|
392
|
-
/**
|
|
393
|
-
* @description Removes horizontal padding and fixes a square aspect ratio sized to match `size`.
|
|
394
|
-
* Provide `aria-label` on the host when using icon-only buttons; in dev mode, an icon-only button without an
|
|
395
|
-
* accessible name logs a warning.
|
|
396
|
-
* @default false
|
|
397
|
-
*/
|
|
398
|
-
this.iconOnly = input(false, { ...(ngDevMode ? { debugName: "iconOnly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
399
|
-
/**
|
|
400
|
-
* @description Displays a loading indicator and prevents interaction while an operation is in progress.
|
|
401
|
-
* Sets `aria-busy="true"` and `aria-disabled="true"` on the host. The button stays focusable, so keyboard focus
|
|
402
|
-
* isn't lost when loading starts, and clicks (including form submission) are blocked until it ends.
|
|
403
|
-
* @default false
|
|
404
|
-
*/
|
|
405
|
-
this.loading = input(false, { ...(ngDevMode ? { debugName: "loading" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
406
|
-
/**
|
|
407
|
-
* @description Visual style variant of the button. When inside a `ButtonGroup`, the group's look takes precedence.
|
|
408
|
-
* `"outline"` looks the same as `"default"`. `"clear"` shows no selected state, so use another look for
|
|
409
|
-
* toggle buttons.
|
|
410
|
-
* @default "default"
|
|
411
|
-
*/
|
|
412
|
-
this.look = model("default", /* @ts-ignore */
|
|
413
|
-
...(ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []));
|
|
414
|
-
/**
|
|
415
|
-
* @description Border-radius preset applied to the component.
|
|
416
|
-
* When inside a `ButtonGroup`, the group's value takes precedence.
|
|
417
|
-
* @default "medium"
|
|
418
|
-
*/
|
|
419
|
-
this.rounded = input("medium", /* @ts-ignore */
|
|
420
|
-
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
421
|
-
/**
|
|
422
|
-
* @description Whether the button is in the selected/pressed state. Drives `aria-pressed` when the button is toggleable.
|
|
423
|
-
* Managed by `toggleable` click handling or by `ButtonGroup` selection policy.
|
|
424
|
-
* @default false
|
|
425
|
-
*/
|
|
426
|
-
this.selected = model(false, /* @ts-ignore */
|
|
427
|
-
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
428
|
-
/**
|
|
429
|
-
* @description Size preset controlling the button's height and horizontal padding.
|
|
430
|
-
* When inside a `ButtonGroup`, the group's value takes precedence.
|
|
431
|
-
* @default "medium"
|
|
432
|
-
*/
|
|
433
|
-
this.size = input("medium", /* @ts-ignore */
|
|
434
|
-
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
435
|
-
/**
|
|
436
|
-
* @description Tab index of the host element. Automatically overridden to `-1` when the button is disabled.
|
|
437
|
-
* Accepts a numeric string and converts it to a number; a value that is not a number falls back to `0`.
|
|
438
|
-
* @default 0
|
|
439
|
-
*/
|
|
440
|
-
this.tabindex = input(0, { ...(ngDevMode ? { debugName: "tabindex" } : /* istanbul ignore next */ {}), transform: (value) => numberAttribute(value, 0) });
|
|
441
|
-
/**
|
|
442
|
-
* @description Enables toggle behavior — each click flips the `selected` state and `aria-pressed` is managed.
|
|
443
|
-
* Accepts the bare attribute form. Buttons in a `ButtonGroup` are toggleable unless this is set to `false`.
|
|
444
|
-
* @default undefined
|
|
445
|
-
*/
|
|
446
|
-
this.toggleable = input(undefined, { ...(ngDevMode ? { debugName: "toggleable" } : /* istanbul ignore next */ {}), transform: (value) => (value === undefined ? undefined : booleanAttribute(value)) });
|
|
447
|
-
/**
|
|
448
|
-
* @description Native `type` attribute of the button. Defaults to `"button"` to prevent accidental
|
|
449
|
-
* form submission; set to `"submit"` or `"reset"` explicitly when that behavior is intended.
|
|
450
|
-
* @default "button"
|
|
451
|
-
*/
|
|
452
|
-
this.type = input("button", /* @ts-ignore */
|
|
453
|
-
...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
|
|
454
|
-
/**
|
|
455
|
-
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
456
|
-
* @default ""
|
|
457
|
-
*/
|
|
458
|
-
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
459
|
-
/**
|
|
460
|
-
* @description What a `ButtonGroup`'s `value` holds while this button is selected. A button without one takes no part
|
|
461
|
-
* in the group's `value`.
|
|
462
|
-
* @default undefined
|
|
463
|
-
*/
|
|
464
|
-
this.value = input(/* @ts-ignore */
|
|
465
|
-
...(ngDevMode ? [undefined, { debugName: "value" }] : /* istanbul ignore next */ []));
|
|
466
|
-
effect(() => {
|
|
467
|
-
const toggleable = this.effectiveToggleable();
|
|
468
|
-
if (toggleable) {
|
|
469
|
-
untracked(() => this.#setToggleableEvent());
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
effect(() => {
|
|
473
|
-
const loading = this.loading();
|
|
474
|
-
const loaderSize = this.loadingSize();
|
|
475
|
-
untracked(() => {
|
|
476
|
-
if (loading) {
|
|
477
|
-
this.#createLoader(loaderSize);
|
|
478
|
-
}
|
|
479
|
-
else {
|
|
480
|
-
this.#removeLoader();
|
|
481
|
-
}
|
|
482
|
-
});
|
|
483
|
-
});
|
|
484
|
-
this.#blockClicksWhileLoading();
|
|
485
|
-
this.#destroyRef.onDestroy(() => this.#removeLoader());
|
|
486
|
-
if (this.#buttonService) {
|
|
487
|
-
afterNextRender({
|
|
488
|
-
read: () => this.#setSubscriptions()
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
if (isDevMode()) {
|
|
492
|
-
this.#warnIfIconOnlyWithoutName();
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* A loading button keeps focus, so it is not natively disabled. A capturing listener registered before any other
|
|
497
|
-
* stops activation from reaching the user's handlers, the toggle handler and form submission.
|
|
498
|
-
*/
|
|
499
|
-
#blockClicksWhileLoading() {
|
|
500
|
-
const host = this.#hostElementRef.nativeElement;
|
|
501
|
-
const listener = (event) => {
|
|
502
|
-
if (this.loading()) {
|
|
503
|
-
event.preventDefault();
|
|
504
|
-
event.stopImmediatePropagation();
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
host.addEventListener("click", listener, { capture: true });
|
|
508
|
-
this.#destroyRef.onDestroy(() => host.removeEventListener("click", listener, { capture: true }));
|
|
509
|
-
}
|
|
510
|
-
#createLoader(size) {
|
|
511
|
-
if (this.#loaderComponentRef) {
|
|
512
|
-
this.#loaderComponentRef.setInput("size", size);
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
this.#loaderComponentRef = createComponent(IndicatorIconComponent, {
|
|
516
|
-
environmentInjector: this.#appRef.injector,
|
|
517
|
-
elementInjector: this.#injector
|
|
518
|
-
});
|
|
519
|
-
this.#loaderComponentRef.setInput("preset", "loading");
|
|
520
|
-
this.#loaderComponentRef.setInput("size", size);
|
|
521
|
-
this.#loaderComponentRef.setInput("class", "self-center h-auto");
|
|
522
|
-
this.#appRef.attachView(this.#loaderComponentRef.hostView);
|
|
523
|
-
const loaderElement = this.#loaderComponentRef.location.nativeElement;
|
|
524
|
-
this.#renderer.insertBefore(this.#hostElementRef.nativeElement, loaderElement, this.#hostElementRef.nativeElement.firstChild);
|
|
525
|
-
}
|
|
526
|
-
#removeLoader() {
|
|
527
|
-
if (this.#loaderComponentRef) {
|
|
528
|
-
this.#appRef.detachView(this.#loaderComponentRef.hostView);
|
|
529
|
-
this.#loaderComponentRef.destroy();
|
|
530
|
-
this.#loaderComponentRef = null;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
#setSubscriptions() {
|
|
534
|
-
this.#buttonService?.buttonSelect$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(result => {
|
|
535
|
-
const [button, selected] = result;
|
|
536
|
-
if (button === this) {
|
|
537
|
-
this.selected.set(selected);
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
const host = this.#hostElementRef.nativeElement;
|
|
541
|
-
fromEvent(host, "click")
|
|
542
|
-
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
543
|
-
.subscribe(() => {
|
|
544
|
-
if (!this.effectiveToggleable()) {
|
|
545
|
-
this.#group()?.memberClick$.next([this, host]);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
#hasAccessibleName() {
|
|
550
|
-
const host = this.#hostElementRef.nativeElement;
|
|
551
|
-
const named = ["aria-label", "aria-labelledby", "title"].some(name => !!host.getAttribute(name)?.trim());
|
|
552
|
-
return named || !!host.textContent?.trim();
|
|
553
|
-
}
|
|
554
|
-
#setToggleableEvent() {
|
|
555
|
-
this.#toggleSubscription?.unsubscribe();
|
|
556
|
-
this.#toggleSubscription = fromEvent(this.#hostElementRef.nativeElement, "click")
|
|
557
|
-
.pipe(takeUntilDestroyed(this.#destroyRef), takeWhile(() => this.effectiveToggleable()))
|
|
558
|
-
.subscribe(() => {
|
|
559
|
-
if (this.effectiveDisabled()) {
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
|
-
const wasSelected = this.selected();
|
|
563
|
-
const group = this.#group();
|
|
564
|
-
if (group) {
|
|
565
|
-
group.buttonClick$.next([this, wasSelected]);
|
|
566
|
-
group.memberClick$.next([this, this.#hostElementRef.nativeElement]);
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
this.selected.set(!this.selected());
|
|
570
|
-
}
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
#warnIfIconOnlyWithoutName() {
|
|
574
|
-
let warned = false;
|
|
575
|
-
afterRenderEffect({
|
|
576
|
-
read: () => {
|
|
577
|
-
if (warned || !this.iconOnly() || this.#hasAccessibleName()) {
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
warned = true;
|
|
581
|
-
console.warn("[Mona Button] An icon-only button needs an accessible name. Add aria-label, aria-labelledby or title.", this.#hostElementRef.nativeElement);
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
}
|
|
585
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
586
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ButtonDirective, isStandalone: true, selector: "button[monaButton]", inputs: { ariaHasPopup: { classPropertyName: "ariaHasPopup", publicName: "aria-haspopup", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, iconOnly: { classPropertyName: "iconOnly", publicName: "iconOnly", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, toggleable: { classPropertyName: "toggleable", publicName: "toggleable", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { look: "lookChange", selected: "selectedChange" }, host: { properties: { "attr.aria-busy": "loading() ? 'true' : undefined", "attr.aria-disabled": "effectiveDisabled() || loading() || groupReadonly() ? 'true' : undefined", "attr.aria-haspopup": "ariaHasPopup() !== 'false' ? ariaHasPopup() : null", "attr.aria-pressed": "effectiveToggleable() ? (selected() ? 'true' : 'false') : undefined", "attr.data-look": "effectiveLook()", "attr.data-size": "effectiveSize()", "attr.disabled": "effectiveDisabled() ? '' : undefined", "attr.tabindex": "effectiveDisabled() ? -1 : tabindex()", "attr.type": "type()", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
587
|
-
}
|
|
588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonDirective, decorators: [{
|
|
589
|
-
type: Directive,
|
|
590
|
-
args: [{
|
|
591
|
-
selector: "button[monaButton]",
|
|
592
|
-
host: {
|
|
593
|
-
"[attr.aria-busy]": "loading() ? 'true' : undefined",
|
|
594
|
-
"[attr.aria-disabled]": "effectiveDisabled() || loading() || groupReadonly() ? 'true' : undefined",
|
|
595
|
-
"[attr.aria-haspopup]": "ariaHasPopup() !== 'false' ? ariaHasPopup() : null",
|
|
596
|
-
"[attr.aria-pressed]": "effectiveToggleable() ? (selected() ? 'true' : 'false') : undefined",
|
|
597
|
-
"[attr.data-look]": "effectiveLook()",
|
|
598
|
-
"[attr.data-size]": "effectiveSize()",
|
|
599
|
-
"[attr.disabled]": "effectiveDisabled() ? '' : undefined",
|
|
600
|
-
"[attr.tabindex]": "effectiveDisabled() ? -1 : tabindex()",
|
|
601
|
-
"[attr.type]": "type()",
|
|
602
|
-
"[class]": "baseClass()"
|
|
603
|
-
}
|
|
604
|
-
}]
|
|
605
|
-
}], ctorParameters: () => [], propDecorators: { ariaHasPopup: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-haspopup", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], iconOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconOnly", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }, { type: i0.Output, args: ["lookChange"] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], toggleable: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleable", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }] } });
|
|
606
|
-
|
|
607
|
-
/**
|
|
608
|
-
* Provided by a component that implements {@link ButtonGroupMember}, so a `mona-button-group` can find it among its
|
|
609
|
-
* content children.
|
|
610
|
-
*/
|
|
611
724
|
const BUTTON_GROUP_MEMBER = new InjectionToken("BUTTON_GROUP_MEMBER");
|
|
612
|
-
|
|
613
|
-
/*
|
|
614
|
-
* Public API Surface of @nanahoshi/mona-ui/button
|
|
615
|
-
*/
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* Generated bundle index. Do not edit.
|
|
619
|
-
*/
|
|
620
|
-
|
|
621
725
|
export { BUTTON_GROUP_MEMBER, ButtonDirective, ButtonService };
|
|
622
|
-
|
|
726
|
+
|
|
727
|
+
//# sourceMappingURL=nanahoshi-mona-ui-button.mjs.map
|