@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,597 @@
|
|
|
1
|
+
import { FocusMonitor } from '@angular/cdk/a11y';
|
|
2
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Directive, inject, DestroyRef, ElementRef, computed, signal, contentChildren, TemplateRef, viewChild, input, output, model, afterNextRender, Component } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import * as i1 from '@angular/forms';
|
|
7
|
+
import { FormsModule } from '@angular/forms';
|
|
8
|
+
import { LucideChevronUp, LucideChevronDown } from '@lucide/angular';
|
|
9
|
+
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
10
|
+
import { rxTimeout } from '@nanahoshi/mona-ui/internal';
|
|
11
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
12
|
+
import { Subject, filter, switchMap, of, tap, delay, concatMap, timer, takeUntil, distinctUntilChanged, map } from 'rxjs';
|
|
13
|
+
import { twMerge } from 'tailwind-merge';
|
|
14
|
+
import { TextBoxDirective } from '@nanahoshi/mona-ui/text-box';
|
|
15
|
+
import { cva } from 'class-variance-authority';
|
|
16
|
+
|
|
17
|
+
class NumericTextBoxPrefixTemplateDirective {
|
|
18
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NumericTextBoxPrefixTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
19
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: NumericTextBoxPrefixTemplateDirective, isStandalone: true, selector: "ng-template[monaNumericTextBoxPrefixTemplate]", ngImport: i0 }); }
|
|
20
|
+
}
|
|
21
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NumericTextBoxPrefixTemplateDirective, decorators: [{
|
|
22
|
+
type: Directive,
|
|
23
|
+
args: [{
|
|
24
|
+
selector: "ng-template[monaNumericTextBoxPrefixTemplate]",
|
|
25
|
+
standalone: true
|
|
26
|
+
}]
|
|
27
|
+
}] });
|
|
28
|
+
|
|
29
|
+
const numericTextboxVariants = cva(`
|
|
30
|
+
flex items-center w-full min-w-0
|
|
31
|
+
bg-transparent
|
|
32
|
+
border border-input-border p-0
|
|
33
|
+
outline-none overflow-hidden
|
|
34
|
+
|
|
35
|
+
placeholder:text-muted-foreground
|
|
36
|
+
|
|
37
|
+
selection:bg-primary selection:text-primary-foreground
|
|
38
|
+
transition-[color,box-shadow,border] ease-in-out duration-300
|
|
39
|
+
|
|
40
|
+
data-[disabled='true']:pointer-events-none
|
|
41
|
+
data-[disabled='true']:cursor-not-allowed
|
|
42
|
+
data-[disabled='true']:opacity-50
|
|
43
|
+
|
|
44
|
+
focus-within:ring-2 focus-within:ring-primary/40
|
|
45
|
+
focus-within:border-primary
|
|
46
|
+
|
|
47
|
+
data-[invalid='true']:border-error
|
|
48
|
+
data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/40
|
|
49
|
+
`, {
|
|
50
|
+
variants: {
|
|
51
|
+
rounded: {
|
|
52
|
+
full: "rounded-full",
|
|
53
|
+
large: "rounded-lg",
|
|
54
|
+
medium: "rounded-md",
|
|
55
|
+
none: "rounded-none",
|
|
56
|
+
small: "rounded-sm"
|
|
57
|
+
},
|
|
58
|
+
size: {
|
|
59
|
+
large: "h-10 text-md",
|
|
60
|
+
medium: "h-9 text-sm",
|
|
61
|
+
small: "h-8 text-xs"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const numericTextboxInputVariants = cva(`
|
|
66
|
+
border-0 outline-none ring-0
|
|
67
|
+
h-full w-full
|
|
68
|
+
focus-visible:ring-0 shadow-none
|
|
69
|
+
rounded-none
|
|
70
|
+
`, {
|
|
71
|
+
variants: {
|
|
72
|
+
leftRounded: {
|
|
73
|
+
full: `
|
|
74
|
+
rounded-tl-full rounded-bl-full
|
|
75
|
+
`,
|
|
76
|
+
large: `
|
|
77
|
+
rounded-tl-lg rounded-bl-lg
|
|
78
|
+
`,
|
|
79
|
+
medium: `
|
|
80
|
+
rounded-tl-md rounded-bl-md
|
|
81
|
+
`,
|
|
82
|
+
none: `
|
|
83
|
+
rounded-tl-none rounded-bl-none
|
|
84
|
+
`,
|
|
85
|
+
small: `
|
|
86
|
+
rounded-tl-sm rounded-bl-sm
|
|
87
|
+
`
|
|
88
|
+
},
|
|
89
|
+
rightRounded: {
|
|
90
|
+
full: `
|
|
91
|
+
rounded-tr-full rounded-br-full
|
|
92
|
+
data-[spinners='true']:rounded-tr-none data-[spinners='true']:rounded-br-none
|
|
93
|
+
`,
|
|
94
|
+
large: `
|
|
95
|
+
rounded-tr-lg rounded-br-lg
|
|
96
|
+
data-[spinners='true']:rounded-tr-none data-[spinners='true']:rounded-br-none
|
|
97
|
+
`,
|
|
98
|
+
medium: `
|
|
99
|
+
rounded-tr-md rounded-br-md
|
|
100
|
+
data-[spinners='true']:rounded-tr-none data-[spinners='true']:rounded-br-none
|
|
101
|
+
`,
|
|
102
|
+
none: `
|
|
103
|
+
rounded-tr-none rounded-br-none
|
|
104
|
+
data-[spinners='true']:rounded-tr-none data-[spinners='true']:rounded-br-none
|
|
105
|
+
`,
|
|
106
|
+
small: `
|
|
107
|
+
rounded-tr-sm rounded-br-sm
|
|
108
|
+
data-[spinners='true']:rounded-tr-none data-[spinners='true']:rounded-br-none
|
|
109
|
+
`
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
const numericTextboxButtonVariants = cva(`
|
|
114
|
+
h-full flex flex-col border-l border-input-border
|
|
115
|
+
overflow-y-hidden
|
|
116
|
+
[&>button]:flex-1
|
|
117
|
+
[&>button]:flex
|
|
118
|
+
[&>button]:items-center
|
|
119
|
+
[&>button]:p-0
|
|
120
|
+
[&>button]:rounded-none
|
|
121
|
+
|
|
122
|
+
[&>button]:first:rounded-tl-none
|
|
123
|
+
[&>button]:first:rounded-bl-none
|
|
124
|
+
[&>button]:first:rounded-br-none
|
|
125
|
+
[&>button]:first:h-1/2
|
|
126
|
+
[&>button]:last:rounded-tl-none
|
|
127
|
+
[&>button]:last:rounded-bl-none
|
|
128
|
+
[&>button]:last:rounded-tr-none
|
|
129
|
+
[&>button]:last:h-1/2
|
|
130
|
+
`, {
|
|
131
|
+
variants: {
|
|
132
|
+
size: {
|
|
133
|
+
large: "min-w-16 w-16",
|
|
134
|
+
medium: "min-w-10 w-10",
|
|
135
|
+
small: "min-w-8 w-8"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const numericTextboxThemeVariants = (theme) => {
|
|
141
|
+
switch (theme) {
|
|
142
|
+
case "mona":
|
|
143
|
+
return numericTextboxVariants;
|
|
144
|
+
default:
|
|
145
|
+
return numericTextboxVariants; // Default to Mona styles
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const numericTextboxInputThemeVariants = (theme) => {
|
|
149
|
+
switch (theme) {
|
|
150
|
+
case "mona":
|
|
151
|
+
return numericTextboxInputVariants;
|
|
152
|
+
default:
|
|
153
|
+
return numericTextboxInputVariants; // Default to Mona styles
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const numericTextboxButtonThemeVariants = (theme) => {
|
|
157
|
+
switch (theme) {
|
|
158
|
+
case "mona":
|
|
159
|
+
return numericTextboxButtonVariants;
|
|
160
|
+
default:
|
|
161
|
+
return numericTextboxButtonVariants; // Default to Mona styles
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
class NumericTextBoxComponent {
|
|
166
|
+
#destroyRef;
|
|
167
|
+
#focusMonitor;
|
|
168
|
+
#hostElementRef;
|
|
169
|
+
#themeService;
|
|
170
|
+
constructor() {
|
|
171
|
+
this.#destroyRef = inject(DestroyRef);
|
|
172
|
+
this.#focusMonitor = inject(FocusMonitor);
|
|
173
|
+
this.#hostElementRef = inject((ElementRef));
|
|
174
|
+
this.#themeService = inject(ThemeService);
|
|
175
|
+
this.beforeInput$ = new Subject();
|
|
176
|
+
this.classes = computed(() => {
|
|
177
|
+
const theme = this.#themeService.theme();
|
|
178
|
+
const rounded = this.rounded();
|
|
179
|
+
const size = this.size();
|
|
180
|
+
const classes = numericTextboxThemeVariants(theme)({ rounded, size });
|
|
181
|
+
const userClass = this.userClass();
|
|
182
|
+
return twMerge(classes, userClass);
|
|
183
|
+
}, /* @ts-ignore */
|
|
184
|
+
...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
|
|
185
|
+
this.inputClasses = computed(() => {
|
|
186
|
+
const theme = this.#themeService.theme();
|
|
187
|
+
const hasPrefixTemplate = this.prefixTemplateList().length > 0;
|
|
188
|
+
const leftRounded = hasPrefixTemplate ? "none" : this.rounded();
|
|
189
|
+
const rightRounded = this.spinners() ? "none" : this.rounded();
|
|
190
|
+
const inputVariants = numericTextboxInputThemeVariants(theme)({ leftRounded, rightRounded });
|
|
191
|
+
return twMerge(inputVariants);
|
|
192
|
+
}, /* @ts-ignore */
|
|
193
|
+
...(ngDevMode ? [{ debugName: "inputClasses" }] : /* istanbul ignore next */ []));
|
|
194
|
+
this.focused = signal(false, /* @ts-ignore */
|
|
195
|
+
...(ngDevMode ? [{ debugName: "focused" }] : /* istanbul ignore next */ []));
|
|
196
|
+
this.formattedValue = computed(() => {
|
|
197
|
+
if (this.focused() && !this.readonly()) {
|
|
198
|
+
return this.rawInputValue();
|
|
199
|
+
}
|
|
200
|
+
return this.formatValueForDisplay(this.value());
|
|
201
|
+
}, /* @ts-ignore */
|
|
202
|
+
...(ngDevMode ? [{ debugName: "formattedValue" }] : /* istanbul ignore next */ []));
|
|
203
|
+
this.invalidInput = computed(() => this.invalid() || (this.required() && this.value() == null && this.touched()), /* @ts-ignore */
|
|
204
|
+
...(ngDevMode ? [{ debugName: "invalidInput" }] : /* istanbul ignore next */ []));
|
|
205
|
+
this.keydown$ = new Subject();
|
|
206
|
+
this.rawInputValue = signal("", /* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [{ debugName: "rawInputValue" }] : /* istanbul ignore next */ []));
|
|
208
|
+
this.spinButtonClasses = computed(() => {
|
|
209
|
+
const theme = this.#themeService.theme();
|
|
210
|
+
const size = this.size();
|
|
211
|
+
return numericTextboxButtonThemeVariants(theme)({ size });
|
|
212
|
+
}, /* @ts-ignore */
|
|
213
|
+
...(ngDevMode ? [{ debugName: "spinButtonClasses" }] : /* istanbul ignore next */ []));
|
|
214
|
+
this.spinButtonIconSize = computed(() => {
|
|
215
|
+
const size = this.size();
|
|
216
|
+
return size === "large" ? 20 : size === "medium" ? 16 : 14;
|
|
217
|
+
}, /* @ts-ignore */
|
|
218
|
+
...(ngDevMode ? [{ debugName: "spinButtonIconSize" }] : /* istanbul ignore next */ []));
|
|
219
|
+
this.spin$ = new Subject();
|
|
220
|
+
this.spinStop$ = new Subject();
|
|
221
|
+
this.prefixTemplateList = contentChildren(NumericTextBoxPrefixTemplateDirective, { ...(ngDevMode ? { debugName: "prefixTemplateList" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
222
|
+
this.valueChange$ = new Subject();
|
|
223
|
+
this.valueTextBoxRef = viewChild.required("valueTextBox", /* @ts-ignore */
|
|
224
|
+
...(ngDevMode ? [{ debugName: "valueTextBoxRef" }] : /* istanbul ignore next */ []));
|
|
225
|
+
this.wheel$ = new Subject();
|
|
226
|
+
/**
|
|
227
|
+
* @description ARIA label for the input.
|
|
228
|
+
*/
|
|
229
|
+
this.ariaLabel = input(null, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
230
|
+
/**
|
|
231
|
+
* @description Number of decimals to show.
|
|
232
|
+
* @default 0
|
|
233
|
+
*/
|
|
234
|
+
this.decimals = input(0, /* @ts-ignore */
|
|
235
|
+
...(ngDevMode ? [{ debugName: "decimals" }] : /* istanbul ignore next */ []));
|
|
236
|
+
/**
|
|
237
|
+
* @description Sets whether the input is disabled.
|
|
238
|
+
*/
|
|
239
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
240
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
241
|
+
/**
|
|
242
|
+
* @description Formats the value to be displayed in the input when the input is not focused.
|
|
243
|
+
*/
|
|
244
|
+
this.formatter = input(null, /* @ts-ignore */
|
|
245
|
+
...(ngDevMode ? [{ debugName: "formatter" }] : /* istanbul ignore next */ []));
|
|
246
|
+
/**
|
|
247
|
+
* @description Emits when the inner input element is blurred.
|
|
248
|
+
*/
|
|
249
|
+
this.inputBlur = output();
|
|
250
|
+
/**
|
|
251
|
+
* @description Emits when the inner input element is focused.
|
|
252
|
+
*/
|
|
253
|
+
this.inputFocus = output();
|
|
254
|
+
/**
|
|
255
|
+
* @description Emits when the inner input element loses focus.
|
|
256
|
+
*/
|
|
257
|
+
this.inputFocusOut = output();
|
|
258
|
+
/**
|
|
259
|
+
* @description Maximum value that can be entered.
|
|
260
|
+
*/
|
|
261
|
+
this.maxValue = input(null, /* @ts-ignore */
|
|
262
|
+
...(ngDevMode ? [{ debugName: "maxValue" }] : /* istanbul ignore next */ []));
|
|
263
|
+
/**
|
|
264
|
+
* @description Minimum value that can be entered.
|
|
265
|
+
*/
|
|
266
|
+
this.minValue = input(null, /* @ts-ignore */
|
|
267
|
+
...(ngDevMode ? [{ debugName: "minValue" }] : /* istanbul ignore next */ []));
|
|
268
|
+
/**
|
|
269
|
+
* @description Sets whether the input can be empty.
|
|
270
|
+
*/
|
|
271
|
+
this.nullable = input(true, /* @ts-ignore */
|
|
272
|
+
...(ngDevMode ? [{ debugName: "nullable" }] : /* istanbul ignore next */ []));
|
|
273
|
+
/**
|
|
274
|
+
* @description Sets whether the input is readonly.
|
|
275
|
+
*/
|
|
276
|
+
this.readonly = input(false, /* @ts-ignore */
|
|
277
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
278
|
+
/**
|
|
279
|
+
* @description Sets whether the input is required.
|
|
280
|
+
*/
|
|
281
|
+
this.required = input(false, /* @ts-ignore */
|
|
282
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
283
|
+
/**
|
|
284
|
+
* @description Marks the numeric text box as invalid. When bound to a signal form field via `[formField]`,
|
|
285
|
+
* this is written by the `FormField` directive.
|
|
286
|
+
* @default false
|
|
287
|
+
*/
|
|
288
|
+
this.invalid = input(false, /* @ts-ignore */
|
|
289
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
290
|
+
/**
|
|
291
|
+
* @description Sets the border radius of the input.
|
|
292
|
+
*/
|
|
293
|
+
this.rounded = input(`medium`, /* @ts-ignore */
|
|
294
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
295
|
+
/**
|
|
296
|
+
* @description Sets the size of the input.
|
|
297
|
+
*/
|
|
298
|
+
this.size = input(`medium`, /* @ts-ignore */
|
|
299
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
300
|
+
/**
|
|
301
|
+
* @description Sets whether the spin buttons are visible.
|
|
302
|
+
*/
|
|
303
|
+
this.spinners = input(true, /* @ts-ignore */
|
|
304
|
+
...(ngDevMode ? [{ debugName: "spinners" }] : /* istanbul ignore next */ []));
|
|
305
|
+
/**
|
|
306
|
+
* @description Step value to increment or decrement the value.
|
|
307
|
+
*/
|
|
308
|
+
this.step = input(1, /* @ts-ignore */
|
|
309
|
+
...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
|
|
310
|
+
/**
|
|
311
|
+
* @description Tab index of the input.
|
|
312
|
+
*/
|
|
313
|
+
this.tabindex = input(0, /* @ts-ignore */
|
|
314
|
+
...(ngDevMode ? [{ debugName: "tabindex" }] : /* istanbul ignore next */ []));
|
|
315
|
+
/**
|
|
316
|
+
* @description Emitted when the numeric text box is interacted with on blur, value change, or spinner update.
|
|
317
|
+
* The `FormField` directive listens to this to mark the field as touched.
|
|
318
|
+
*/
|
|
319
|
+
this.touch = output();
|
|
320
|
+
/**
|
|
321
|
+
* @description Sets the touched state of the numeric text box. When bound to a signal form field via `[formField]`,
|
|
322
|
+
* this is written by the `FormField` directive.
|
|
323
|
+
* @default false
|
|
324
|
+
*/
|
|
325
|
+
this.touched = input(false, /* @ts-ignore */
|
|
326
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
327
|
+
/**
|
|
328
|
+
* @description Additional CSS classes merged onto the host element via `tailwind-merge`.
|
|
329
|
+
* @default ""
|
|
330
|
+
*/
|
|
331
|
+
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
332
|
+
/**
|
|
333
|
+
* @description Two-way bindable current value of the numeric text box.
|
|
334
|
+
* @default null
|
|
335
|
+
*/
|
|
336
|
+
this.value = model(null, /* @ts-ignore */
|
|
337
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
338
|
+
afterNextRender({
|
|
339
|
+
read: () => {
|
|
340
|
+
this.setSubscriptions();
|
|
341
|
+
this.rawInputValue.set(this.formatValueForDisplay(this.value()));
|
|
342
|
+
this.#focusMonitor
|
|
343
|
+
.monitor(this.#hostElementRef, true)
|
|
344
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
345
|
+
.subscribe((focusOrigin) => {
|
|
346
|
+
const isFocused = focusOrigin !== null;
|
|
347
|
+
this.focused.set(isFocused);
|
|
348
|
+
if (isFocused && !this.readonly()) {
|
|
349
|
+
const currentValue = this.value();
|
|
350
|
+
const rawValue = currentValue?.toString() ?? "";
|
|
351
|
+
this.rawInputValue.set(rawValue);
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
this.#destroyRef.onDestroy(() => this.#focusMonitor.stopMonitoring(this.#hostElementRef.nativeElement));
|
|
357
|
+
}
|
|
358
|
+
static calculate(value, step, type) {
|
|
359
|
+
const precision = Math.max(NumericTextBoxComponent.getPrecision(value), NumericTextBoxComponent.getPrecision(step));
|
|
360
|
+
const factor = Math.pow(10, precision);
|
|
361
|
+
const signFactor = type === "+" ? 1 : -1;
|
|
362
|
+
const newValue = (value * factor + signFactor * step * factor) / factor;
|
|
363
|
+
return precision > 0 ? parseFloat(newValue.toFixed(precision)) : newValue;
|
|
364
|
+
}
|
|
365
|
+
static getPrecision(value) {
|
|
366
|
+
const valueString = value.toString();
|
|
367
|
+
if (valueString.includes(".")) {
|
|
368
|
+
const parts = valueString.split(".");
|
|
369
|
+
return parts[1].length;
|
|
370
|
+
}
|
|
371
|
+
return 0;
|
|
372
|
+
}
|
|
373
|
+
static isNumeric(value) {
|
|
374
|
+
if (value === "" || value === "-") {
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
return ((typeof value === "number" || (typeof value === "string" && value.trim() !== "")) && !isNaN(value));
|
|
378
|
+
}
|
|
379
|
+
decrease() {
|
|
380
|
+
const value = this.value();
|
|
381
|
+
if (value == null) {
|
|
382
|
+
this.applyRawValue("0");
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
let result = NumericTextBoxComponent.calculate(value, this.step(), "-");
|
|
386
|
+
const min = this.minValue();
|
|
387
|
+
if (min != null && result < min) {
|
|
388
|
+
result = min;
|
|
389
|
+
}
|
|
390
|
+
this.applyRawValue(result.toString());
|
|
391
|
+
}
|
|
392
|
+
this.focus();
|
|
393
|
+
}
|
|
394
|
+
focus() {
|
|
395
|
+
this.#focusMonitor.focusVia(this.valueTextBoxRef(), "keyboard");
|
|
396
|
+
rxTimeout(this.#destroyRef, () => {
|
|
397
|
+
this.valueTextBoxRef().nativeElement.scrollLeft = this.valueTextBoxRef().nativeElement.scrollWidth;
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
increase() {
|
|
401
|
+
const value = this.value();
|
|
402
|
+
if (value == null) {
|
|
403
|
+
this.applyRawValue("0");
|
|
404
|
+
}
|
|
405
|
+
else {
|
|
406
|
+
let result = NumericTextBoxComponent.calculate(value, this.step(), "+");
|
|
407
|
+
const max = this.maxValue();
|
|
408
|
+
if (max != null && result > max) {
|
|
409
|
+
result = max;
|
|
410
|
+
}
|
|
411
|
+
this.applyRawValue(result.toString());
|
|
412
|
+
}
|
|
413
|
+
this.focus();
|
|
414
|
+
}
|
|
415
|
+
onBlur(event) {
|
|
416
|
+
const relatedTarget = event.relatedTarget;
|
|
417
|
+
if (relatedTarget && this.#hostElementRef.nativeElement.contains(relatedTarget)) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const corrected = this.correctValue();
|
|
421
|
+
if (!corrected) {
|
|
422
|
+
this.touch.emit();
|
|
423
|
+
}
|
|
424
|
+
this.rawInputValue.set(this.formatValueForDisplay(this.value()));
|
|
425
|
+
this.inputBlur.emit(event);
|
|
426
|
+
}
|
|
427
|
+
correctValue() {
|
|
428
|
+
const value = this.value();
|
|
429
|
+
const min = this.minValue();
|
|
430
|
+
const max = this.maxValue();
|
|
431
|
+
if (value == null) {
|
|
432
|
+
if (this.nullable()) {
|
|
433
|
+
this.applyRawValue("");
|
|
434
|
+
}
|
|
435
|
+
else if (min != null) {
|
|
436
|
+
this.applyRawValue(min.toString());
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
this.applyRawValue("0");
|
|
440
|
+
}
|
|
441
|
+
return true;
|
|
442
|
+
}
|
|
443
|
+
if (min != null && value < min) {
|
|
444
|
+
this.applyRawValue(min.toString());
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
if (max != null && value > max) {
|
|
448
|
+
this.applyRawValue(max.toString());
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
formatValueForDisplay(value) {
|
|
454
|
+
if (value == null) {
|
|
455
|
+
return "";
|
|
456
|
+
}
|
|
457
|
+
const formatter = this.formatter();
|
|
458
|
+
if (formatter) {
|
|
459
|
+
return formatter(value);
|
|
460
|
+
}
|
|
461
|
+
const decimals = this.decimals();
|
|
462
|
+
if (decimals > 0) {
|
|
463
|
+
return value.toFixed(decimals);
|
|
464
|
+
}
|
|
465
|
+
return value.toString();
|
|
466
|
+
}
|
|
467
|
+
applyRawValue(text) {
|
|
468
|
+
this.rawInputValue.set(text);
|
|
469
|
+
this.valueChange$.next(text);
|
|
470
|
+
}
|
|
471
|
+
setBeforeInputSubscription() {
|
|
472
|
+
this.beforeInput$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
|
|
473
|
+
const inputElement = event.target;
|
|
474
|
+
const insertedText = event.data;
|
|
475
|
+
if (insertedText == null) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const { value, selectionStart, selectionEnd } = inputElement;
|
|
479
|
+
if (selectionStart == null || selectionEnd == null) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const proposedValue = value.slice(0, selectionStart) + insertedText + value.slice(selectionEnd);
|
|
483
|
+
if (proposedValue.lastIndexOf("-") > 0) {
|
|
484
|
+
event.preventDefault();
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
if ((proposedValue.match(/\./g) || []).length > 1) {
|
|
488
|
+
event.preventDefault();
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (this.decimals() === 0 && proposedValue.includes(".")) {
|
|
492
|
+
event.preventDefault();
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
if (proposedValue.includes(".")) {
|
|
496
|
+
const decimalPart = proposedValue.split(".")[1];
|
|
497
|
+
if (decimalPart && decimalPart.length > this.decimals()) {
|
|
498
|
+
event.preventDefault();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
const numericRegex = new RegExp(`^-?\\d*\\.?\\d{0,${this.decimals()}}$`);
|
|
503
|
+
if (!numericRegex.test(proposedValue)) {
|
|
504
|
+
event.preventDefault();
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
setInputFocusSubscription() {
|
|
509
|
+
this.inputFocus.subscribe(() => this.#hostElementRef.nativeElement.focus());
|
|
510
|
+
}
|
|
511
|
+
setKeydownSubscription() {
|
|
512
|
+
this.keydown$
|
|
513
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), filter(() => !this.readonly() && !this.disabled()))
|
|
514
|
+
.subscribe((event) => {
|
|
515
|
+
if (event.key === "ArrowUp") {
|
|
516
|
+
event.preventDefault();
|
|
517
|
+
this.increase();
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (event.key === "ArrowDown") {
|
|
521
|
+
event.preventDefault();
|
|
522
|
+
this.decrease();
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
setSpinSubscription() {
|
|
527
|
+
this.spin$
|
|
528
|
+
.pipe(filter(() => !this.readonly() && !this.disabled()), switchMap(sign => of(sign).pipe(tap(sign => (sign === "-" ? this.decrease() : this.increase())), delay(300), concatMap(() => timer(0, 30).pipe(tap(() => (sign === "-" ? this.decrease() : this.increase())), takeUntil(this.spinStop$))), takeUntil(this.spinStop$))), takeUntilDestroyed(this.#destroyRef))
|
|
529
|
+
.subscribe();
|
|
530
|
+
}
|
|
531
|
+
setSubscriptions() {
|
|
532
|
+
this.setValueChangeSubscription();
|
|
533
|
+
this.setKeydownSubscription();
|
|
534
|
+
this.setSpinSubscription();
|
|
535
|
+
this.setWheelSubscription();
|
|
536
|
+
this.setInputFocusSubscription();
|
|
537
|
+
this.setBeforeInputSubscription();
|
|
538
|
+
}
|
|
539
|
+
setValueChangeSubscription() {
|
|
540
|
+
this.valueChange$
|
|
541
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), distinctUntilChanged(), map(v => this.parseValue(v)))
|
|
542
|
+
.subscribe(value => {
|
|
543
|
+
this.value.set(value);
|
|
544
|
+
this.touch.emit();
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
setWheelSubscription() {
|
|
548
|
+
this.wheel$
|
|
549
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), filter(() => !this.readonly() && !this.disabled()))
|
|
550
|
+
.subscribe((event) => {
|
|
551
|
+
event.preventDefault();
|
|
552
|
+
if (event.deltaY < 0) {
|
|
553
|
+
this.increase();
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
this.decrease();
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
parseValue(value) {
|
|
561
|
+
const normalizedValue = value == null ? "" : value;
|
|
562
|
+
this.rawInputValue.set(normalizedValue);
|
|
563
|
+
if (normalizedValue === "" || normalizedValue === "-") {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
const sanitizedValue = normalizedValue.replace(/,/g, "");
|
|
567
|
+
if (!NumericTextBoxComponent.isNumeric(sanitizedValue)) {
|
|
568
|
+
return this.value();
|
|
569
|
+
}
|
|
570
|
+
return parseFloat(sanitizedValue);
|
|
571
|
+
}
|
|
572
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NumericTextBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
573
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: NumericTextBoxComponent, isStandalone: true, selector: "mona-numeric-text-box", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, formatter: { classPropertyName: "formatter", publicName: "formatter", isSignal: true, isRequired: false, transformFunction: null }, maxValue: { classPropertyName: "maxValue", publicName: "maxValue", isSignal: true, isRequired: false, transformFunction: null }, minValue: { classPropertyName: "minValue", publicName: "minValue", isSignal: true, isRequired: false, transformFunction: null }, nullable: { classPropertyName: "nullable", publicName: "nullable", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, spinners: { classPropertyName: "spinners", publicName: "spinners", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", 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: { inputBlur: "inputBlur", inputFocus: "inputFocus", inputFocusOut: "inputFocusOut", touch: "touch", value: "valueChange" }, host: { properties: { "class": "classes()", "attr.data-disabled": "disabled() || null", "attr.data-invalid": "invalidInput() || null", "attr.data-readonly": "readonly() || null", "attr.data-required": "required() || null" } }, queries: [{ propertyName: "prefixTemplateList", predicate: NumericTextBoxPrefixTemplateDirective, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "valueTextBoxRef", first: true, predicate: ["valueTextBox"], descendants: true, isSignal: true }], ngImport: i0, template: "@for (prefixTemplate of prefixTemplateList(); track $index) {\r\n <span class=\"flex items-center flex-none flex-wrap h-full overflow-hidden border-none\">\r\n <ng-container *ngTemplateOutlet=\"prefixTemplate\"></ng-container>\r\n </span>\r\n}\r\n<input\r\n monaTextBox\r\n [disabled]=\"disabled()\"\r\n [required]=\"required()\"\r\n [type]=\"'text'\"\r\n inputmode=\"numeric\"\r\n [readonly]=\"readonly()\"\r\n [tabIndex]=\"tabindex()\"\r\n [ngModel]=\"formattedValue()\"\r\n (ngModelChange)=\"applyRawValue($event)\"\r\n (keydown)=\"keydown$.next($event)\"\r\n (focus)=\"inputFocus.emit($event)\"\r\n (focusout)=\"inputFocusOut.emit($event)\"\r\n (blur)=\"onBlur($event)\"\r\n (beforeinput)=\"beforeInput$.next($event)\"\r\n (wheel)=\"wheel$.next($event)\"\r\n [size]=\"size()\"\r\n [class]=\"inputClasses()\"\r\n autocomplete=\"off\"\r\n role=\"spinbutton\"\r\n [attr.aria-disabled]=\"disabled()\"\r\n [attr.aria-invalid]=\"invalidInput() || null\"\r\n [attr.aria-readonly]=\"readonly()\"\r\n [attr.aria-required]=\"required()\"\r\n [attr.aria-label]=\"ariaLabel()\"\r\n [attr.aria-valuenow]=\"value()\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuetext]=\"formattedValue()\"\r\n [attr.data-spinners]=\"spinners()\"\r\n #valueTextBox />\r\n@if (spinners()) {\r\n <div [class]=\"spinButtonClasses()\">\r\n <button\r\n monaButton\r\n [disabled]=\"disabled()\"\r\n [tabindex]=\"-1\"\r\n look=\"secondary\"\r\n [size]=\"size()\"\r\n (mousedown)=\"$event.preventDefault()\"\r\n (pointerdown)=\"spin$.next('+')\"\r\n (pointerup)=\"spinStop$.next()\"\r\n (pointerleave)=\"spinStop$.next()\"\r\n aria-label=\"Increase value\">\r\n <svg lucideChevronUp [size]=\"spinButtonIconSize()\"></svg>\r\n </button>\r\n <button\r\n monaButton\r\n [disabled]=\"disabled()\"\r\n [tabindex]=\"-1\"\r\n look=\"secondary\"\r\n [size]=\"size()\"\r\n (mousedown)=\"$event.preventDefault()\"\r\n (pointerdown)=\"spin$.next('-')\"\r\n (pointerup)=\"spinStop$.next()\"\r\n (pointerleave)=\"spinStop$.next()\"\r\n aria-label=\"Decrease value\">\r\n <svg lucideChevronDown [size]=\"spinButtonIconSize()\"></svg>\r\n </button>\r\n </div>\r\n}\r\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: TextBoxDirective, selector: "input[monaTextBox]", inputs: ["rounded", "size", "class"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "class"], outputs: ["disabledChange", "loadingChange", "lookChange", "selectedChange"] }, { kind: "component", type: LucideChevronUp, selector: "svg[lucideChevronUp]" }, { kind: "component", type: LucideChevronDown, selector: "svg[lucideChevronDown]" }] }); }
|
|
574
|
+
}
|
|
575
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NumericTextBoxComponent, decorators: [{
|
|
576
|
+
type: Component,
|
|
577
|
+
args: [{ selector: "mona-numeric-text-box", imports: [NgTemplateOutlet, TextBoxDirective, FormsModule, ButtonDirective, LucideChevronUp, LucideChevronDown], host: {
|
|
578
|
+
"[class]": "classes()",
|
|
579
|
+
"[attr.data-disabled]": "disabled() || null",
|
|
580
|
+
"[attr.data-invalid]": "invalidInput() || null",
|
|
581
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
582
|
+
"[attr.data-required]": "required() || null"
|
|
583
|
+
}, template: "@for (prefixTemplate of prefixTemplateList(); track $index) {\r\n <span class=\"flex items-center flex-none flex-wrap h-full overflow-hidden border-none\">\r\n <ng-container *ngTemplateOutlet=\"prefixTemplate\"></ng-container>\r\n </span>\r\n}\r\n<input\r\n monaTextBox\r\n [disabled]=\"disabled()\"\r\n [required]=\"required()\"\r\n [type]=\"'text'\"\r\n inputmode=\"numeric\"\r\n [readonly]=\"readonly()\"\r\n [tabIndex]=\"tabindex()\"\r\n [ngModel]=\"formattedValue()\"\r\n (ngModelChange)=\"applyRawValue($event)\"\r\n (keydown)=\"keydown$.next($event)\"\r\n (focus)=\"inputFocus.emit($event)\"\r\n (focusout)=\"inputFocusOut.emit($event)\"\r\n (blur)=\"onBlur($event)\"\r\n (beforeinput)=\"beforeInput$.next($event)\"\r\n (wheel)=\"wheel$.next($event)\"\r\n [size]=\"size()\"\r\n [class]=\"inputClasses()\"\r\n autocomplete=\"off\"\r\n role=\"spinbutton\"\r\n [attr.aria-disabled]=\"disabled()\"\r\n [attr.aria-invalid]=\"invalidInput() || null\"\r\n [attr.aria-readonly]=\"readonly()\"\r\n [attr.aria-required]=\"required()\"\r\n [attr.aria-label]=\"ariaLabel()\"\r\n [attr.aria-valuenow]=\"value()\"\r\n [attr.aria-valuemin]=\"minValue()\"\r\n [attr.aria-valuemax]=\"maxValue()\"\r\n [attr.aria-valuetext]=\"formattedValue()\"\r\n [attr.data-spinners]=\"spinners()\"\r\n #valueTextBox />\r\n@if (spinners()) {\r\n <div [class]=\"spinButtonClasses()\">\r\n <button\r\n monaButton\r\n [disabled]=\"disabled()\"\r\n [tabindex]=\"-1\"\r\n look=\"secondary\"\r\n [size]=\"size()\"\r\n (mousedown)=\"$event.preventDefault()\"\r\n (pointerdown)=\"spin$.next('+')\"\r\n (pointerup)=\"spinStop$.next()\"\r\n (pointerleave)=\"spinStop$.next()\"\r\n aria-label=\"Increase value\">\r\n <svg lucideChevronUp [size]=\"spinButtonIconSize()\"></svg>\r\n </button>\r\n <button\r\n monaButton\r\n [disabled]=\"disabled()\"\r\n [tabindex]=\"-1\"\r\n look=\"secondary\"\r\n [size]=\"size()\"\r\n (mousedown)=\"$event.preventDefault()\"\r\n (pointerdown)=\"spin$.next('-')\"\r\n (pointerup)=\"spinStop$.next()\"\r\n (pointerleave)=\"spinStop$.next()\"\r\n aria-label=\"Decrease value\">\r\n <svg lucideChevronDown [size]=\"spinButtonIconSize()\"></svg>\r\n </button>\r\n </div>\r\n}\r\n" }]
|
|
584
|
+
}], ctorParameters: () => [], propDecorators: { prefixTemplateList: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => NumericTextBoxPrefixTemplateDirective), { ...{
|
|
585
|
+
read: TemplateRef
|
|
586
|
+
}, isSignal: true }] }], valueTextBoxRef: [{ type: i0.ViewChild, args: ["valueTextBox", { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], decimals: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimals", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], formatter: [{ type: i0.Input, args: [{ isSignal: true, alias: "formatter", required: false }] }], inputBlur: [{ type: i0.Output, args: ["inputBlur"] }], inputFocus: [{ type: i0.Output, args: ["inputFocus"] }], inputFocusOut: [{ type: i0.Output, args: ["inputFocusOut"] }], maxValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxValue", required: false }] }], minValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "minValue", required: false }] }], nullable: [{ type: i0.Input, args: [{ isSignal: true, alias: "nullable", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], spinners: [{ type: i0.Input, args: [{ isSignal: true, alias: "spinners", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
587
|
+
|
|
588
|
+
/*
|
|
589
|
+
* Public API Surface of @nanahoshi/mona-ui/numeric-text-box
|
|
590
|
+
*/
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Generated bundle index. Do not edit.
|
|
594
|
+
*/
|
|
595
|
+
|
|
596
|
+
export { NumericTextBoxComponent, NumericTextBoxPrefixTemplateDirective };
|
|
597
|
+
//# sourceMappingURL=nanahoshi-mona-ui-numeric-text-box.mjs.map
|