@nanahoshi/mona-ui 0.1.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 +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, Injectable, inject, ApplicationRef, DestroyRef, ElementRef, Injector, Renderer2, computed, input, model, effect, untracked, afterNextRender, createComponent, Directive } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { IndicatorIconComponent } from '@nanahoshi/mona-ui/internal/indicator-icon';
|
|
5
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
6
|
+
import { Subject, fromEvent, takeWhile } from 'rxjs';
|
|
7
|
+
import { twMerge } from 'tailwind-merge';
|
|
8
|
+
import { cva } from 'class-variance-authority';
|
|
9
|
+
|
|
10
|
+
class ButtonService {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.buttonClick$ = new Subject();
|
|
13
|
+
this.buttonSelect$ = new Subject();
|
|
14
|
+
this.groupDisabled = signal(false, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "groupDisabled" }] : /* istanbul ignore next */ []));
|
|
16
|
+
this.groupLook = signal(undefined, /* @ts-ignore */
|
|
17
|
+
...(ngDevMode ? [{ debugName: "groupLook" }] : /* istanbul ignore next */ []));
|
|
18
|
+
this.groupRounded = signal(undefined, /* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [{ debugName: "groupRounded" }] : /* istanbul ignore next */ []));
|
|
20
|
+
this.groupSize = signal(undefined, /* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [{ debugName: "groupSize" }] : /* istanbul ignore next */ []));
|
|
22
|
+
}
|
|
23
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
24
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService }); }
|
|
25
|
+
}
|
|
26
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonService, decorators: [{
|
|
27
|
+
type: Injectable
|
|
28
|
+
}] });
|
|
29
|
+
|
|
30
|
+
const buttonVariants = cva(`
|
|
31
|
+
inline-flex items-center justify-center gap-2
|
|
32
|
+
text-sm font-medium cursor-pointer whitespace-nowrap
|
|
33
|
+
outline-none shadow-xs
|
|
34
|
+
focus-visible:outline-none focus-visible:shadow
|
|
35
|
+
transition-colors duration-100 ease-in-out
|
|
36
|
+
`, {
|
|
37
|
+
variants: {
|
|
38
|
+
disabled: {
|
|
39
|
+
true: "pointer-events-none opacity-50 cursor-not-allowed select-none",
|
|
40
|
+
false: ""
|
|
41
|
+
},
|
|
42
|
+
iconOnly: {
|
|
43
|
+
true: "aspect-square",
|
|
44
|
+
false: "aspect-auto"
|
|
45
|
+
},
|
|
46
|
+
loading: {
|
|
47
|
+
true: "pointer-events-none",
|
|
48
|
+
false: ""
|
|
49
|
+
},
|
|
50
|
+
look: {
|
|
51
|
+
default: `
|
|
52
|
+
bg-background text-foreground
|
|
53
|
+
border border-input-border
|
|
54
|
+
hover:bg-hover active:bg-active
|
|
55
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
56
|
+
`,
|
|
57
|
+
primary: `
|
|
58
|
+
bg-primary text-primary-foreground
|
|
59
|
+
hover:bg-primary-hover active:bg-primary-active
|
|
60
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
61
|
+
`,
|
|
62
|
+
success: `
|
|
63
|
+
bg-success text-success-foreground
|
|
64
|
+
hover:bg-success-hover
|
|
65
|
+
active:bg-success-active
|
|
66
|
+
focus-visible:ring-2 focus-visible:ring-success/40
|
|
67
|
+
`,
|
|
68
|
+
error: `
|
|
69
|
+
bg-error text-error-foreground
|
|
70
|
+
hover:bg-error-hover
|
|
71
|
+
active:bg-error-active
|
|
72
|
+
focus-visible:ring-2 focus-visible:ring-error/40
|
|
73
|
+
`,
|
|
74
|
+
warning: `
|
|
75
|
+
bg-warning text-warning-foreground
|
|
76
|
+
hover:bg-warning-hover
|
|
77
|
+
active:bg-warning-active
|
|
78
|
+
focus-visible:ring-2 focus-visible:ring-warning/40
|
|
79
|
+
`,
|
|
80
|
+
info: `
|
|
81
|
+
bg-info text-info-foreground
|
|
82
|
+
hover:bg-info-hover
|
|
83
|
+
active:bg-info-active
|
|
84
|
+
focus-visible:ring-2 focus-visible:ring-info/40
|
|
85
|
+
`,
|
|
86
|
+
outline: `
|
|
87
|
+
border border-border
|
|
88
|
+
hover:bg-accent
|
|
89
|
+
active:bg-accent-dark
|
|
90
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
91
|
+
`,
|
|
92
|
+
secondary: `
|
|
93
|
+
bg-secondary text-secondary-foreground
|
|
94
|
+
hover:bg-secondary-hover
|
|
95
|
+
active:bg-secondary-active
|
|
96
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
97
|
+
`,
|
|
98
|
+
ghost: `
|
|
99
|
+
shadow-none
|
|
100
|
+
hover:bg-secondary-hover
|
|
101
|
+
active:bg-secondary-active
|
|
102
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
103
|
+
`,
|
|
104
|
+
link: `
|
|
105
|
+
shadow-none
|
|
106
|
+
underline-offset-4 hover:underline
|
|
107
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
108
|
+
`,
|
|
109
|
+
clear: `
|
|
110
|
+
bg-transparent border-0 shadow-none
|
|
111
|
+
hover:bg-transparent active:bg-transparent
|
|
112
|
+
focus-visible:ring-2 focus-visible:ring-primary/40
|
|
113
|
+
`
|
|
114
|
+
},
|
|
115
|
+
rounded: {
|
|
116
|
+
full: "rounded-full",
|
|
117
|
+
large: "rounded-lg",
|
|
118
|
+
medium: "rounded-md",
|
|
119
|
+
none: "rounded-none",
|
|
120
|
+
small: "rounded-sm"
|
|
121
|
+
},
|
|
122
|
+
size: {
|
|
123
|
+
large: "px-6 h-10",
|
|
124
|
+
medium: "px-4 h-9",
|
|
125
|
+
small: "px-3 text-xs h-8"
|
|
126
|
+
},
|
|
127
|
+
selected: {
|
|
128
|
+
true: "bg-accent text-accent-foreground hover:bg-accent/90 hover:text-accent-foreground"
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
compoundVariants: [
|
|
132
|
+
{
|
|
133
|
+
look: "default",
|
|
134
|
+
selected: true,
|
|
135
|
+
class: `
|
|
136
|
+
bg-selected text-foreground
|
|
137
|
+
hover:bg-selected/95 hover:text-foreground
|
|
138
|
+
active:bg-selected/100 active:text-foreground
|
|
139
|
+
`
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
look: "primary",
|
|
143
|
+
selected: true,
|
|
144
|
+
class: `
|
|
145
|
+
bg-primary-selected text-primary-foreground
|
|
146
|
+
hover:bg-primary-selected/95 hover:text-primary-foreground
|
|
147
|
+
active:bg-primary-selected/100 active:text-primary-foreground
|
|
148
|
+
`
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
look: "secondary",
|
|
152
|
+
selected: true,
|
|
153
|
+
class: `
|
|
154
|
+
bg-secondary-selected text-secondary-foreground
|
|
155
|
+
hover:bg-secondary-selected/95 hover:text-secondary-foreground
|
|
156
|
+
active:bg-secondary-selected/100 active:text-secondary-foreground
|
|
157
|
+
`
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
look: "success",
|
|
161
|
+
selected: true,
|
|
162
|
+
class: `
|
|
163
|
+
bg-success-selected text-success-foreground
|
|
164
|
+
hover:bg-success-selected/95 hover:text-success-foreground
|
|
165
|
+
active:bg-success-selected/100 active:text-success-foreground
|
|
166
|
+
`
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
look: "error",
|
|
170
|
+
selected: true,
|
|
171
|
+
class: `
|
|
172
|
+
bg-error-selected text-error-foreground
|
|
173
|
+
hover:bg-error-selected/95 hover:text-error-foreground
|
|
174
|
+
active:bg-error-selected/100 active:text-error-foreground
|
|
175
|
+
`
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
look: "warning",
|
|
179
|
+
selected: true,
|
|
180
|
+
class: `
|
|
181
|
+
bg-warning-selected text-warning-foreground
|
|
182
|
+
hover:bg-warning-selected/95 hover:text-warning-foreground
|
|
183
|
+
active:bg-warning-selected/100 active:text-warning-foreground
|
|
184
|
+
`
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
look: "info",
|
|
188
|
+
selected: true,
|
|
189
|
+
class: `
|
|
190
|
+
bg-info-selected text-info-foreground
|
|
191
|
+
hover:bg-info-selected/95 hover:text-info-foreground
|
|
192
|
+
active:bg-info-selected/100 active:text-info-foreground
|
|
193
|
+
`
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
look: "outline",
|
|
197
|
+
selected: true,
|
|
198
|
+
class: `
|
|
199
|
+
bg-primary-selected text-primary-foreground
|
|
200
|
+
hover:bg-primary-selected/95 hover:text-primary-foreground
|
|
201
|
+
active:bg-primary-selected/100 active:text-primary-foreground
|
|
202
|
+
`
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
look: "ghost",
|
|
206
|
+
selected: true,
|
|
207
|
+
class: `
|
|
208
|
+
bg-secondary-selected text-secondary-foreground
|
|
209
|
+
hover:bg-secondary-selected/95 hover:text-secondary-foreground
|
|
210
|
+
active:bg-secondary-selected/100 active:text-secondary-foreground
|
|
211
|
+
`
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
look: "link",
|
|
215
|
+
selected: true,
|
|
216
|
+
class: `
|
|
217
|
+
bg-secondary-selected text-secondary-foreground
|
|
218
|
+
hover:bg-secondary-selected/95 hover:text-secondary-foreground
|
|
219
|
+
active:bg-secondary-selected/100 active:text-secondary-foreground
|
|
220
|
+
`
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
look: "clear",
|
|
224
|
+
selected: true,
|
|
225
|
+
class: `
|
|
226
|
+
bg-transparent border-0
|
|
227
|
+
hover:bg-transparent active:bg-transparent
|
|
228
|
+
`
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
iconOnly: true,
|
|
232
|
+
loading: false,
|
|
233
|
+
size: "small",
|
|
234
|
+
class: "w-8 h-8 p-0"
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
iconOnly: true,
|
|
238
|
+
loading: false,
|
|
239
|
+
size: "medium",
|
|
240
|
+
class: "w-9 h-9 p-0"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
iconOnly: true,
|
|
244
|
+
loading: false,
|
|
245
|
+
size: "large",
|
|
246
|
+
class: "w-10 h-10 p-0"
|
|
247
|
+
}
|
|
248
|
+
],
|
|
249
|
+
defaultVariants: {
|
|
250
|
+
look: "default",
|
|
251
|
+
rounded: "medium",
|
|
252
|
+
size: "medium"
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
const buttonThemeVariants = (theme) => {
|
|
257
|
+
switch (theme) {
|
|
258
|
+
case "mona":
|
|
259
|
+
return buttonVariants;
|
|
260
|
+
default:
|
|
261
|
+
return buttonVariants;
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
class ButtonDirective {
|
|
266
|
+
#appRef;
|
|
267
|
+
#buttonService;
|
|
268
|
+
#destroyRef;
|
|
269
|
+
#hostElementRef;
|
|
270
|
+
#injector;
|
|
271
|
+
#renderer;
|
|
272
|
+
#themeService;
|
|
273
|
+
#loaderComponentRef;
|
|
274
|
+
#toggleSubscription;
|
|
275
|
+
constructor() {
|
|
276
|
+
this.#appRef = inject(ApplicationRef);
|
|
277
|
+
this.#buttonService = inject(ButtonService, { optional: true });
|
|
278
|
+
this.#destroyRef = inject(DestroyRef);
|
|
279
|
+
this.#hostElementRef = inject(ElementRef);
|
|
280
|
+
this.#injector = inject(Injector);
|
|
281
|
+
this.#renderer = inject(Renderer2);
|
|
282
|
+
this.#themeService = inject(ThemeService);
|
|
283
|
+
this.#loaderComponentRef = null;
|
|
284
|
+
this.#toggleSubscription = null;
|
|
285
|
+
this.effectiveDisabled = computed(() => this.#buttonService?.groupDisabled() || this.disabled(), /* @ts-ignore */
|
|
286
|
+
...(ngDevMode ? [{ debugName: "effectiveDisabled" }] : /* istanbul ignore next */ []));
|
|
287
|
+
this.effectiveLook = computed(() => this.#buttonService?.groupLook() ?? this.look(), /* @ts-ignore */
|
|
288
|
+
...(ngDevMode ? [{ debugName: "effectiveLook" }] : /* istanbul ignore next */ []));
|
|
289
|
+
this.effectiveRounded = computed(() => this.#buttonService?.groupRounded() ?? this.rounded(), /* @ts-ignore */
|
|
290
|
+
...(ngDevMode ? [{ debugName: "effectiveRounded" }] : /* istanbul ignore next */ []));
|
|
291
|
+
this.effectiveSize = computed(() => this.#buttonService?.groupSize() ?? this.size(), /* @ts-ignore */
|
|
292
|
+
...(ngDevMode ? [{ debugName: "effectiveSize" }] : /* istanbul ignore next */ []));
|
|
293
|
+
this.effectiveToggleable = computed(() => this.isInButtonGroup() || this.toggleable(), /* @ts-ignore */
|
|
294
|
+
...(ngDevMode ? [{ debugName: "effectiveToggleable" }] : /* istanbul ignore next */ []));
|
|
295
|
+
this.isInButtonGroup = computed(() => !!this.#buttonService, /* @ts-ignore */
|
|
296
|
+
...(ngDevMode ? [{ debugName: "isInButtonGroup" }] : /* istanbul ignore next */ []));
|
|
297
|
+
this.baseClass = computed(() => {
|
|
298
|
+
const disabled = this.effectiveDisabled();
|
|
299
|
+
const iconOnly = this.iconOnly();
|
|
300
|
+
const loading = this.loading();
|
|
301
|
+
const look = this.effectiveLook();
|
|
302
|
+
const rounded = this.effectiveRounded();
|
|
303
|
+
const size = this.effectiveSize();
|
|
304
|
+
const selected = this.selected();
|
|
305
|
+
const userClass = this.userClass();
|
|
306
|
+
const theme = this.#themeService.theme();
|
|
307
|
+
const variants = buttonThemeVariants(theme);
|
|
308
|
+
const variantClasses = variants({ disabled, iconOnly, loading, look, rounded, selected, size });
|
|
309
|
+
return twMerge(variantClasses, userClass);
|
|
310
|
+
}, /* @ts-ignore */
|
|
311
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
312
|
+
this.loadingSize = computed(() => {
|
|
313
|
+
const size = this.effectiveSize();
|
|
314
|
+
switch (size) {
|
|
315
|
+
case "small":
|
|
316
|
+
return 12;
|
|
317
|
+
case "large":
|
|
318
|
+
return 16;
|
|
319
|
+
case "medium":
|
|
320
|
+
default:
|
|
321
|
+
return 14;
|
|
322
|
+
}
|
|
323
|
+
}, /* @ts-ignore */
|
|
324
|
+
...(ngDevMode ? [{ debugName: "loadingSize" }] : /* istanbul ignore next */ []));
|
|
325
|
+
/**
|
|
326
|
+
* @description Value forwarded to the `aria-haspopup` attribute. Set when this button triggers a popup, menu,
|
|
327
|
+
* listbox, tree, grid, or dialog. Omit or leave as `"false"` for plain action buttons.
|
|
328
|
+
* @default "false"
|
|
329
|
+
*/
|
|
330
|
+
this.ariaHasPopup = input("false", { ...(ngDevMode ? { debugName: "ariaHasPopup" } : /* istanbul ignore next */ {}), alias: "aria-haspopup" });
|
|
331
|
+
/**
|
|
332
|
+
* @description Renders the component with reduced visual emphasis and removes pointer interaction.
|
|
333
|
+
* When inside a `ButtonGroup`, the group's disabled state takes precedence.
|
|
334
|
+
* @default false
|
|
335
|
+
*/
|
|
336
|
+
this.disabled = model(false, /* @ts-ignore */
|
|
337
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
338
|
+
/**
|
|
339
|
+
* @description Removes horizontal padding and fixes a square aspect ratio sized to match `size`.
|
|
340
|
+
* Provide `aria-label` on the host when using icon-only buttons.
|
|
341
|
+
* @default false
|
|
342
|
+
*/
|
|
343
|
+
this.iconOnly = input(false, /* @ts-ignore */
|
|
344
|
+
...(ngDevMode ? [{ debugName: "iconOnly" }] : /* istanbul ignore next */ []));
|
|
345
|
+
/**
|
|
346
|
+
* @description Displays a loading indicator and prevents interaction while an operation is in progress.
|
|
347
|
+
* Sets `aria-busy="true"` on the host.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
this.loading = model(false, /* @ts-ignore */
|
|
351
|
+
...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
|
|
352
|
+
/**
|
|
353
|
+
* @description Visual style variant of the button. When inside a `ButtonGroup`, the group's look takes precedence.
|
|
354
|
+
* @default "default"
|
|
355
|
+
*/
|
|
356
|
+
this.look = model("default", /* @ts-ignore */
|
|
357
|
+
...(ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []));
|
|
358
|
+
/**
|
|
359
|
+
* @description Border-radius preset applied to the component.
|
|
360
|
+
* When inside a `ButtonGroup`, the group's value takes precedence.
|
|
361
|
+
* @default "medium"
|
|
362
|
+
*/
|
|
363
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
364
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
365
|
+
/**
|
|
366
|
+
* @description Whether the button is in the selected/pressed state. Drives `aria-pressed` when the button is toggleable.
|
|
367
|
+
* Managed by `toggleable` click handling or by `ButtonGroup` selection policy.
|
|
368
|
+
* @default false
|
|
369
|
+
*/
|
|
370
|
+
this.selected = model(false, /* @ts-ignore */
|
|
371
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
372
|
+
/**
|
|
373
|
+
* @description Size preset controlling the button's height and horizontal padding.
|
|
374
|
+
* When inside a `ButtonGroup`, the group's value takes precedence.
|
|
375
|
+
* @default "medium"
|
|
376
|
+
*/
|
|
377
|
+
this.size = input("medium", /* @ts-ignore */
|
|
378
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
379
|
+
/**
|
|
380
|
+
* @description Tab index of the host element. Automatically overridden to `-1` when the button is disabled or loading.
|
|
381
|
+
* Accepts a numeric string and converts it to a number.
|
|
382
|
+
* @default 0
|
|
383
|
+
*/
|
|
384
|
+
this.tabindex = input(0, { ...(ngDevMode ? { debugName: "tabindex" } : /* istanbul ignore next */ {}), transform: (value) => (typeof value === "string" ? parseInt(value, 10) : value) });
|
|
385
|
+
/**
|
|
386
|
+
* @description Enables toggle behavior — each click flips the `selected` state and `aria-pressed` is managed.
|
|
387
|
+
* Must use `[toggleable]="true"` binding syntax, not bare attribute form.
|
|
388
|
+
* @default false
|
|
389
|
+
*/
|
|
390
|
+
this.toggleable = input(false, /* @ts-ignore */
|
|
391
|
+
...(ngDevMode ? [{ debugName: "toggleable" }] : /* istanbul ignore next */ []));
|
|
392
|
+
/**
|
|
393
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
394
|
+
* @default ""
|
|
395
|
+
*/
|
|
396
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
397
|
+
effect(() => {
|
|
398
|
+
const toggleable = this.effectiveToggleable();
|
|
399
|
+
if (toggleable) {
|
|
400
|
+
untracked(() => this.#setToggleableEvent());
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
effect(() => {
|
|
404
|
+
const loading = this.loading();
|
|
405
|
+
const loaderSize = this.loadingSize();
|
|
406
|
+
untracked(() => {
|
|
407
|
+
if (loading) {
|
|
408
|
+
this.#createLoader(loaderSize);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
this.#removeLoader();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
afterNextRender({
|
|
416
|
+
read: () => this.#setSubscriptions()
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
#createLoader(size) {
|
|
420
|
+
if (this.#loaderComponentRef) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
this.#loaderComponentRef = createComponent(IndicatorIconComponent, {
|
|
424
|
+
environmentInjector: this.#appRef.injector,
|
|
425
|
+
elementInjector: this.#injector
|
|
426
|
+
});
|
|
427
|
+
this.#loaderComponentRef.setInput("preset", "loading");
|
|
428
|
+
this.#loaderComponentRef.setInput("size", size);
|
|
429
|
+
this.#loaderComponentRef.setInput("class", "self-center h-auto");
|
|
430
|
+
this.#appRef.attachView(this.#loaderComponentRef.hostView);
|
|
431
|
+
const loaderElement = this.#loaderComponentRef.location.nativeElement;
|
|
432
|
+
this.#renderer.insertBefore(this.#hostElementRef.nativeElement, loaderElement, this.#hostElementRef.nativeElement.firstChild);
|
|
433
|
+
}
|
|
434
|
+
#removeLoader() {
|
|
435
|
+
if (this.#loaderComponentRef) {
|
|
436
|
+
this.#appRef.detachView(this.#loaderComponentRef.hostView);
|
|
437
|
+
this.#loaderComponentRef.destroy();
|
|
438
|
+
this.#loaderComponentRef = null;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
#setSubscriptions() {
|
|
442
|
+
this.#buttonService?.buttonSelect$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(result => {
|
|
443
|
+
const [button, selected] = result;
|
|
444
|
+
if (button === this) {
|
|
445
|
+
this.selected.set(selected);
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
#setToggleableEvent() {
|
|
450
|
+
this.#toggleSubscription?.unsubscribe();
|
|
451
|
+
this.#toggleSubscription = fromEvent(this.#hostElementRef.nativeElement, "click")
|
|
452
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), takeWhile(() => this.effectiveToggleable()))
|
|
453
|
+
.subscribe(() => {
|
|
454
|
+
if (this.effectiveDisabled()) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const wasSelected = this.selected();
|
|
458
|
+
if (this.#buttonService) {
|
|
459
|
+
this.#buttonService.buttonClick$.next([this, wasSelected]);
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this.selected.set(!this.selected());
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
466
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
467
|
+
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 }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", loading: "loadingChange", look: "lookChange", selected: "selectedChange" }, host: { properties: { "attr.aria-busy": "loading() ? 'true' : undefined", "attr.aria-disabled": "effectiveDisabled() || loading() ? '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() || loading() ? '' : undefined", "attr.tabindex": "effectiveDisabled() || loading() ? -1 : tabindex()", "attr.type": "'button'", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
468
|
+
}
|
|
469
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonDirective, decorators: [{
|
|
470
|
+
type: Directive,
|
|
471
|
+
args: [{
|
|
472
|
+
selector: "button[monaButton]",
|
|
473
|
+
host: {
|
|
474
|
+
"[attr.aria-busy]": "loading() ? 'true' : undefined",
|
|
475
|
+
"[attr.aria-disabled]": "effectiveDisabled() || loading() ? 'true' : undefined",
|
|
476
|
+
"[attr.aria-haspopup]": "ariaHasPopup() !== 'false' ? ariaHasPopup() : null",
|
|
477
|
+
"[attr.aria-pressed]": "effectiveToggleable() ? (selected() ? 'true' : 'false') : undefined",
|
|
478
|
+
"[attr.data-look]": "effectiveLook()",
|
|
479
|
+
"[attr.data-size]": "effectiveSize()",
|
|
480
|
+
"[attr.disabled]": "effectiveDisabled() || loading() ? '' : undefined",
|
|
481
|
+
"[attr.tabindex]": "effectiveDisabled() || loading() ? -1 : tabindex()",
|
|
482
|
+
"[attr.type]": "'button'",
|
|
483
|
+
"[class]": "baseClass()"
|
|
484
|
+
}
|
|
485
|
+
}]
|
|
486
|
+
}], 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 }] }, { type: i0.Output, args: ["disabledChange"] }], iconOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconOnly", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }, { type: i0.Output, args: ["loadingChange"] }], 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 }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
487
|
+
|
|
488
|
+
/*
|
|
489
|
+
* Public API Surface of @nanahoshi/mona-ui/button
|
|
490
|
+
*/
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Generated bundle index. Do not edit.
|
|
494
|
+
*/
|
|
495
|
+
|
|
496
|
+
export { ButtonDirective, ButtonService };
|
|
497
|
+
//# sourceMappingURL=nanahoshi-mona-ui-button.mjs.map
|