@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,723 @@
|
|
|
1
|
+
import { DecimalPipe } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { inject, DestroyRef, ElementRef, signal, computed, input, effect, Directive, viewChild, output, model, afterNextRender, untracked, Component } from '@angular/core';
|
|
4
|
+
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
+
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
6
|
+
import { PreventableEvent } from '@nanahoshi/mona-ui/common';
|
|
7
|
+
import { TimeSelectorService, generateMinuteSet, generateSecondSet, generateHourSet, TimeLimiterPipe } from '@nanahoshi/mona-ui/date-input';
|
|
8
|
+
import { rxTimeout, createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
9
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
10
|
+
import { DateTime } from 'luxon';
|
|
11
|
+
import { tap, fromEvent } from 'rxjs';
|
|
12
|
+
import { filter } from 'rxjs/operators';
|
|
13
|
+
import { cva } from 'class-variance-authority';
|
|
14
|
+
|
|
15
|
+
const timeSelectorBaseVariants = cva(`
|
|
16
|
+
flex flex-col w-full h-full overflow-hidden
|
|
17
|
+
data-[invalid='true']:border data-[invalid='true']:border-error
|
|
18
|
+
data-[invalid='true']:ring-2 data-[invalid='true']:ring-error/40
|
|
19
|
+
`, {
|
|
20
|
+
variants: {
|
|
21
|
+
disabled: {
|
|
22
|
+
true: "opacity-50 cursor-not-allowed pointer-events-none",
|
|
23
|
+
false: ""
|
|
24
|
+
},
|
|
25
|
+
size: {
|
|
26
|
+
small: "text-xs",
|
|
27
|
+
medium: "text-sm",
|
|
28
|
+
large: "text-md"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const timeSelectorFooterVariants = cva(`
|
|
33
|
+
w-full flex items-center justify-end px-1 py-1 border-0 border-t border-input-border bg-accent
|
|
34
|
+
`);
|
|
35
|
+
const timeSelectorHeaderVariants = cva(`
|
|
36
|
+
flex bg-accent text-accent-foreground
|
|
37
|
+
border-b border-input-border
|
|
38
|
+
text-xs font-semibold uppercase
|
|
39
|
+
[&>div]:flex-1 [&>div]:py-2 [&>div]:text-center
|
|
40
|
+
`);
|
|
41
|
+
const timeSelectorInfoContainerVariants = cva(`
|
|
42
|
+
flex items-center justify-between
|
|
43
|
+
px-2 py-1 border-b border-input-border/40
|
|
44
|
+
[&>span]:text-xs [&>span]:font-medium [&>span]:select-none
|
|
45
|
+
`);
|
|
46
|
+
const timeSelectorListContainerVariants = cva(`
|
|
47
|
+
flex flex-row w-full relative overflow-hidden
|
|
48
|
+
`);
|
|
49
|
+
const timeSelectorListVariants = cva(`
|
|
50
|
+
flex-1 overflow-y-auto h-full
|
|
51
|
+
scrollbar-hide scroll-smooth
|
|
52
|
+
snap-y snap-mandatory
|
|
53
|
+
scrollbar-width:none
|
|
54
|
+
select-none outline-none
|
|
55
|
+
[&::-webkit-scrollbar]:hidden
|
|
56
|
+
focus-visible:bg-accent
|
|
57
|
+
focus-within:bg-accent
|
|
58
|
+
`, {
|
|
59
|
+
variants: {
|
|
60
|
+
size: {
|
|
61
|
+
small: "h-24",
|
|
62
|
+
medium: "h-32",
|
|
63
|
+
large: "h-40"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
const timeSelectorListItemVariants = cva(`
|
|
68
|
+
flex items-center justify-center cursor-pointer
|
|
69
|
+
snap-center relative z-10
|
|
70
|
+
`, {
|
|
71
|
+
variants: {
|
|
72
|
+
selected: {
|
|
73
|
+
true: "bg-primary text-primary-foreground",
|
|
74
|
+
false: ""
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
small: "h-6",
|
|
78
|
+
medium: "h-7",
|
|
79
|
+
large: "h-8"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
selected: false
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const timeSelectorBaseThemeVariants = (theme) => {
|
|
88
|
+
switch (theme) {
|
|
89
|
+
case "mona":
|
|
90
|
+
return timeSelectorBaseVariants;
|
|
91
|
+
default:
|
|
92
|
+
return timeSelectorBaseVariants;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const timeSelectorFooterThemeVariants = (theme) => {
|
|
96
|
+
switch (theme) {
|
|
97
|
+
case "mona":
|
|
98
|
+
return timeSelectorFooterVariants;
|
|
99
|
+
default:
|
|
100
|
+
return timeSelectorFooterVariants;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const timeSelectorHeaderThemeVariants = (theme) => {
|
|
104
|
+
switch (theme) {
|
|
105
|
+
case "mona":
|
|
106
|
+
return timeSelectorHeaderVariants;
|
|
107
|
+
default:
|
|
108
|
+
return timeSelectorHeaderVariants;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const timeSelectorInfoContainerThemeVariants = (theme) => {
|
|
112
|
+
switch (theme) {
|
|
113
|
+
case "mona":
|
|
114
|
+
return timeSelectorInfoContainerVariants;
|
|
115
|
+
default:
|
|
116
|
+
return timeSelectorInfoContainerVariants;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
const timeSelectorListContainerThemeVariants = (theme) => {
|
|
120
|
+
switch (theme) {
|
|
121
|
+
case "mona":
|
|
122
|
+
return timeSelectorListContainerVariants;
|
|
123
|
+
default:
|
|
124
|
+
return timeSelectorListContainerVariants;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const timeSelectorListThemeVariants = (theme) => {
|
|
128
|
+
switch (theme) {
|
|
129
|
+
case "mona":
|
|
130
|
+
return timeSelectorListVariants;
|
|
131
|
+
default:
|
|
132
|
+
return timeSelectorListVariants;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const timeSelectorListItemThemeVariants = (theme) => {
|
|
136
|
+
switch (theme) {
|
|
137
|
+
case "mona":
|
|
138
|
+
return timeSelectorListItemVariants;
|
|
139
|
+
default:
|
|
140
|
+
return timeSelectorListItemVariants;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
class TimeSelectorItemDirective {
|
|
145
|
+
#destroyRef;
|
|
146
|
+
#host;
|
|
147
|
+
#scrollBehavior;
|
|
148
|
+
#themeService;
|
|
149
|
+
constructor() {
|
|
150
|
+
this.#destroyRef = inject(DestroyRef);
|
|
151
|
+
this.#host = inject((ElementRef));
|
|
152
|
+
this.#scrollBehavior = signal("instant", /* @ts-ignore */
|
|
153
|
+
...(ngDevMode ? [{ debugName: "#scrollBehavior" }] : /* istanbul ignore next */ []));
|
|
154
|
+
this.#themeService = inject(ThemeService);
|
|
155
|
+
this.baseClass = computed(() => {
|
|
156
|
+
const theme = this.#themeService.theme();
|
|
157
|
+
const selected = this.selected();
|
|
158
|
+
const size = this.size();
|
|
159
|
+
return timeSelectorListItemThemeVariants(theme)({ selected, size });
|
|
160
|
+
}, /* @ts-ignore */
|
|
161
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
162
|
+
this.selected = input.required(/* @ts-ignore */
|
|
163
|
+
...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
|
|
164
|
+
this.size = input.required(/* @ts-ignore */
|
|
165
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
166
|
+
this.value = input.required(/* @ts-ignore */
|
|
167
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
168
|
+
effect(() => {
|
|
169
|
+
const selected = this.selected();
|
|
170
|
+
rxTimeout(this.#destroyRef, () => {
|
|
171
|
+
if (selected) {
|
|
172
|
+
this.#host.nativeElement.scrollIntoView({ block: "center", behavior: this.#scrollBehavior() });
|
|
173
|
+
}
|
|
174
|
+
if (this.#scrollBehavior() === "instant") {
|
|
175
|
+
this.#scrollBehavior.set("auto");
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
181
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TimeSelectorItemDirective, isStandalone: true, selector: "li[monaTimeSelectorItem]", inputs: { selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: true, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "option" }, properties: { "attr.aria-selected": "selected()", "attr.data-value": "value()", "class": "baseClass()" } }, ngImport: i0 }); }
|
|
182
|
+
}
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorItemDirective, decorators: [{
|
|
184
|
+
type: Directive,
|
|
185
|
+
args: [{
|
|
186
|
+
selector: "li[monaTimeSelectorItem]",
|
|
187
|
+
host: {
|
|
188
|
+
role: "option",
|
|
189
|
+
"[attr.aria-selected]": "selected()",
|
|
190
|
+
"[attr.data-value]": "value()",
|
|
191
|
+
"[class]": "baseClass()"
|
|
192
|
+
}
|
|
193
|
+
}]
|
|
194
|
+
}], ctorParameters: () => [], propDecorators: { selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: true }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: true }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }] } });
|
|
195
|
+
|
|
196
|
+
class TimeSelectorListDirective {
|
|
197
|
+
constructor() {
|
|
198
|
+
this.#itemHeight = computed(() => {
|
|
199
|
+
const size = this.size();
|
|
200
|
+
return size === "small" ? 24 : size === "medium" ? 28 : 32; // TODO: Get rid of magic numbers
|
|
201
|
+
}, /* @ts-ignore */
|
|
202
|
+
...(ngDevMode ? [{ debugName: "#itemHeight" }] : /* istanbul ignore next */ []));
|
|
203
|
+
this.#themeService = inject(ThemeService);
|
|
204
|
+
this.baseClass = computed(() => {
|
|
205
|
+
const theme = this.#themeService.theme();
|
|
206
|
+
return timeSelectorListThemeVariants(theme)();
|
|
207
|
+
}, /* @ts-ignore */
|
|
208
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
209
|
+
this.listPadding = computed(() => {
|
|
210
|
+
const itemHeight = this.#itemHeight();
|
|
211
|
+
const popupHeight = this.popupHeight();
|
|
212
|
+
return popupHeight / 2 - itemHeight / 2;
|
|
213
|
+
}, /* @ts-ignore */
|
|
214
|
+
...(ngDevMode ? [{ debugName: "listPadding" }] : /* istanbul ignore next */ []));
|
|
215
|
+
this.active = input.required(/* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
217
|
+
this.popupHeight = input.required(/* @ts-ignore */
|
|
218
|
+
...(ngDevMode ? [{ debugName: "popupHeight" }] : /* istanbul ignore next */ []));
|
|
219
|
+
this.size = input.required(/* @ts-ignore */
|
|
220
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
221
|
+
}
|
|
222
|
+
#itemHeight;
|
|
223
|
+
#themeService;
|
|
224
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorListDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
225
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TimeSelectorListDirective, isStandalone: true, selector: "ol[monaTimeSelectorList]", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: true, transformFunction: null }, popupHeight: { classPropertyName: "popupHeight", publicName: "popupHeight", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "role": "listbox" }, properties: { "class": "baseClass()", "style.padding-top.px": "listPadding()", "style.padding-bottom.px": "listPadding()", "attr.tabindex": "active() ? 0 : -1" } }, ngImport: i0 }); }
|
|
226
|
+
}
|
|
227
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorListDirective, decorators: [{
|
|
228
|
+
type: Directive,
|
|
229
|
+
args: [{
|
|
230
|
+
selector: "ol[monaTimeSelectorList]",
|
|
231
|
+
host: {
|
|
232
|
+
role: "listbox",
|
|
233
|
+
"[class]": "baseClass()",
|
|
234
|
+
"[style.padding-top.px]": "listPadding()",
|
|
235
|
+
"[style.padding-bottom.px]": "listPadding()",
|
|
236
|
+
"[attr.tabindex]": "active() ? 0 : -1"
|
|
237
|
+
}
|
|
238
|
+
}]
|
|
239
|
+
}], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: true }] }], popupHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupHeight", required: true }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: true }] }] } });
|
|
240
|
+
|
|
241
|
+
class TimeSelectorComponent {
|
|
242
|
+
#destroyRef;
|
|
243
|
+
#height;
|
|
244
|
+
#hostElementRef;
|
|
245
|
+
#themeService;
|
|
246
|
+
#timeSelectorService;
|
|
247
|
+
constructor() {
|
|
248
|
+
this.#destroyRef = inject(DestroyRef);
|
|
249
|
+
this.#height = signal(0, /* @ts-ignore */
|
|
250
|
+
...(ngDevMode ? [{ debugName: "#height" }] : /* istanbul ignore next */ []));
|
|
251
|
+
this.#hostElementRef = inject((ElementRef));
|
|
252
|
+
this.#themeService = inject(ThemeService);
|
|
253
|
+
this.#timeSelectorService = inject(TimeSelectorService, { optional: true });
|
|
254
|
+
this.amMeridiemVisible = computed(() => {
|
|
255
|
+
const min = this.min();
|
|
256
|
+
return !(min && min.getHours() >= 12);
|
|
257
|
+
}, /* @ts-ignore */
|
|
258
|
+
...(ngDevMode ? [{ debugName: "amMeridiemVisible" }] : /* istanbul ignore next */ []));
|
|
259
|
+
this.baseClass = computed(() => {
|
|
260
|
+
const theme = this.#themeService.theme();
|
|
261
|
+
const disabled = this.disabled();
|
|
262
|
+
return timeSelectorBaseThemeVariants(theme)({ disabled });
|
|
263
|
+
}, /* @ts-ignore */
|
|
264
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
265
|
+
this.computedPopupHeight = this.#height.asReadonly();
|
|
266
|
+
this.focusedList = signal("hours", /* @ts-ignore */
|
|
267
|
+
...(ngDevMode ? [{ debugName: "focusedList" }] : /* istanbul ignore next */ []));
|
|
268
|
+
this.footerClass = computed(() => {
|
|
269
|
+
const theme = this.#themeService.theme();
|
|
270
|
+
return timeSelectorFooterThemeVariants(theme)();
|
|
271
|
+
}, /* @ts-ignore */
|
|
272
|
+
...(ngDevMode ? [{ debugName: "footerClass" }] : /* istanbul ignore next */ []));
|
|
273
|
+
this.headerClass = computed(() => {
|
|
274
|
+
const theme = this.#themeService.theme();
|
|
275
|
+
return timeSelectorHeaderThemeVariants(theme)();
|
|
276
|
+
}, /* @ts-ignore */
|
|
277
|
+
...(ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []));
|
|
278
|
+
this.hour = computed(() => {
|
|
279
|
+
const hour = this.navigatedDate().hour;
|
|
280
|
+
const hourFormat = this.hourFormat();
|
|
281
|
+
if (hourFormat === "24") {
|
|
282
|
+
return hour;
|
|
283
|
+
}
|
|
284
|
+
return hour % 12 || 12;
|
|
285
|
+
}, /* @ts-ignore */
|
|
286
|
+
...(ngDevMode ? [{ debugName: "hour" }] : /* istanbul ignore next */ []));
|
|
287
|
+
this.hourListId = createElementControlId();
|
|
288
|
+
this.hourListRef = viewChild.required("hourList", /* @ts-ignore */
|
|
289
|
+
...(ngDevMode ? [{ debugName: "hourListRef" }] : /* istanbul ignore next */ []));
|
|
290
|
+
this.infoContainerClass = computed(() => {
|
|
291
|
+
const theme = this.#themeService.theme();
|
|
292
|
+
return timeSelectorInfoContainerThemeVariants(theme)();
|
|
293
|
+
}, /* @ts-ignore */
|
|
294
|
+
...(ngDevMode ? [{ debugName: "infoContainerClass" }] : /* istanbul ignore next */ []));
|
|
295
|
+
this.listContainerClass = computed(() => {
|
|
296
|
+
const theme = this.#themeService.theme();
|
|
297
|
+
return timeSelectorListContainerThemeVariants(theme)();
|
|
298
|
+
}, /* @ts-ignore */
|
|
299
|
+
...(ngDevMode ? [{ debugName: "listContainerClass" }] : /* istanbul ignore next */ []));
|
|
300
|
+
this.maxDate = computed(() => {
|
|
301
|
+
const max = this.max();
|
|
302
|
+
return max ? DateTime.fromJSDate(max) : null;
|
|
303
|
+
}, /* @ts-ignore */
|
|
304
|
+
...(ngDevMode ? [{ debugName: "maxDate" }] : /* istanbul ignore next */ []));
|
|
305
|
+
this.meridiem = signal("AM", /* @ts-ignore */
|
|
306
|
+
...(ngDevMode ? [{ debugName: "meridiem" }] : /* istanbul ignore next */ []));
|
|
307
|
+
this.meridiemListId = createElementControlId();
|
|
308
|
+
this.meridiemListRef = viewChild("meridiemList", /* @ts-ignore */
|
|
309
|
+
...(ngDevMode ? [{ debugName: "meridiemListRef" }] : /* istanbul ignore next */ []));
|
|
310
|
+
this.minDate = computed(() => {
|
|
311
|
+
const min = this.min();
|
|
312
|
+
return min ? DateTime.fromJSDate(min) : null;
|
|
313
|
+
}, /* @ts-ignore */
|
|
314
|
+
...(ngDevMode ? [{ debugName: "minDate" }] : /* istanbul ignore next */ []));
|
|
315
|
+
this.minute = computed(() => this.navigatedDate().minute, /* @ts-ignore */
|
|
316
|
+
...(ngDevMode ? [{ debugName: "minute" }] : /* istanbul ignore next */ []));
|
|
317
|
+
this.minuteListId = createElementControlId();
|
|
318
|
+
this.minuteListRef = viewChild.required("minuteList", /* @ts-ignore */
|
|
319
|
+
...(ngDevMode ? [{ debugName: "minuteListRef" }] : /* istanbul ignore next */ []));
|
|
320
|
+
this.minutes = computed(() => generateMinuteSet(this.minuteStep()), /* @ts-ignore */
|
|
321
|
+
...(ngDevMode ? [{ debugName: "minutes" }] : /* istanbul ignore next */ []));
|
|
322
|
+
this.navigatedDate = signal(DateTime.now(), /* @ts-ignore */
|
|
323
|
+
...(ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []));
|
|
324
|
+
this.navigatedDateText = computed(() => {
|
|
325
|
+
const hourFormat = this.hourFormat();
|
|
326
|
+
return this.navigatedDate().toLocaleString({ hour: "numeric", minute: "numeric", hour12: hourFormat === "12" });
|
|
327
|
+
}, /* @ts-ignore */
|
|
328
|
+
...(ngDevMode ? [{ debugName: "navigatedDateText" }] : /* istanbul ignore next */ []));
|
|
329
|
+
this.pmMeridiemVisible = computed(() => {
|
|
330
|
+
const max = this.max();
|
|
331
|
+
return !(max && max.getHours() < 12);
|
|
332
|
+
}, /* @ts-ignore */
|
|
333
|
+
...(ngDevMode ? [{ debugName: "pmMeridiemVisible" }] : /* istanbul ignore next */ []));
|
|
334
|
+
this.second = computed(() => this.navigatedDate().second, /* @ts-ignore */
|
|
335
|
+
...(ngDevMode ? [{ debugName: "second" }] : /* istanbul ignore next */ []));
|
|
336
|
+
this.secondListId = createElementControlId();
|
|
337
|
+
this.secondListRef = viewChild("secondList", /* @ts-ignore */
|
|
338
|
+
...(ngDevMode ? [{ debugName: "secondListRef" }] : /* istanbul ignore next */ []));
|
|
339
|
+
this.seconds = computed(() => generateSecondSet(this.secondStep()), /* @ts-ignore */
|
|
340
|
+
...(ngDevMode ? [{ debugName: "seconds" }] : /* istanbul ignore next */ []));
|
|
341
|
+
this.viewHours = computed(() => {
|
|
342
|
+
const meridiem = this.meridiem();
|
|
343
|
+
const hourFormat = this.hourFormat();
|
|
344
|
+
const hourStep = this.hourStep();
|
|
345
|
+
return generateHourSet(hourFormat, meridiem, hourStep);
|
|
346
|
+
}, /* @ts-ignore */
|
|
347
|
+
...(ngDevMode ? [{ debugName: "viewHours" }] : /* istanbul ignore next */ []));
|
|
348
|
+
this.ariaLabel = input("Time selector", /* @ts-ignore */
|
|
349
|
+
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
350
|
+
this.disabled = input(false, /* @ts-ignore */
|
|
351
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
352
|
+
this.focusOnMount = input(true, /* @ts-ignore */
|
|
353
|
+
...(ngDevMode ? [{ debugName: "focusOnMount" }] : /* istanbul ignore next */ []));
|
|
354
|
+
this.footer = input(true, /* @ts-ignore */
|
|
355
|
+
...(ngDevMode ? [{ debugName: "footer" }] : /* istanbul ignore next */ []));
|
|
356
|
+
this.hourFormat = input("24", /* @ts-ignore */
|
|
357
|
+
...(ngDevMode ? [{ debugName: "hourFormat" }] : /* istanbul ignore next */ []));
|
|
358
|
+
this.hourStep = input(1, /* @ts-ignore */
|
|
359
|
+
...(ngDevMode ? [{ debugName: "hourStep" }] : /* istanbul ignore next */ []));
|
|
360
|
+
/**
|
|
361
|
+
* @description Marks the time selector as invalid. When bound to a signal form field via `[formField]`,
|
|
362
|
+
* this is written by the `FormField` directive.
|
|
363
|
+
* @default false
|
|
364
|
+
*/
|
|
365
|
+
this.invalid = input(false, /* @ts-ignore */
|
|
366
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
367
|
+
this.max = input(undefined, { ...(ngDevMode ? { debugName: "max" } : /* istanbul ignore next */ {}), transform: value => (value instanceof Date ? value : undefined) });
|
|
368
|
+
this.min = input(undefined, { ...(ngDevMode ? { debugName: "min" } : /* istanbul ignore next */ {}), transform: value => (value instanceof Date ? value : undefined) });
|
|
369
|
+
this.minuteStep = input(1, /* @ts-ignore */
|
|
370
|
+
...(ngDevMode ? [{ debugName: "minuteStep" }] : /* istanbul ignore next */ []));
|
|
371
|
+
/**
|
|
372
|
+
* @description Prevents value changes while preserving the component's visual state.
|
|
373
|
+
* @default false
|
|
374
|
+
*/
|
|
375
|
+
this.readonly = input(false, /* @ts-ignore */
|
|
376
|
+
...(ngDevMode ? [{ debugName: "readonly" }] : /* istanbul ignore next */ []));
|
|
377
|
+
/**
|
|
378
|
+
* @description Sets whether the time selector is required. When bound to a signal form field via `[formField]`,
|
|
379
|
+
* this is written by the `FormField` directive.
|
|
380
|
+
* @default false
|
|
381
|
+
*/
|
|
382
|
+
this.required = input(false, /* @ts-ignore */
|
|
383
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
384
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
385
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
386
|
+
this.secondStep = input(1, /* @ts-ignore */
|
|
387
|
+
...(ngDevMode ? [{ debugName: "secondStep" }] : /* istanbul ignore next */ []));
|
|
388
|
+
this.showSeconds = input(false, /* @ts-ignore */
|
|
389
|
+
...(ngDevMode ? [{ debugName: "showSeconds" }] : /* istanbul ignore next */ []));
|
|
390
|
+
this.size = input("medium", /* @ts-ignore */
|
|
391
|
+
...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
|
|
392
|
+
/**
|
|
393
|
+
* @description Emitted when the time selector is interacted with via blur or value selection.
|
|
394
|
+
* The `FormField` directive listens to this to mark the field as touched.
|
|
395
|
+
*/
|
|
396
|
+
this.touch = output();
|
|
397
|
+
/**
|
|
398
|
+
* @description Sets the touched state of the time selector. When bound to a signal form field via `[formField]`,
|
|
399
|
+
* this is written by the `FormField` directive.
|
|
400
|
+
* @default false
|
|
401
|
+
*/
|
|
402
|
+
this.touched = input(false, /* @ts-ignore */
|
|
403
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
404
|
+
/**
|
|
405
|
+
* @description Two-way bindable current time value.
|
|
406
|
+
* @default null
|
|
407
|
+
*/
|
|
408
|
+
this.value = model(null, /* @ts-ignore */
|
|
409
|
+
...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
|
|
410
|
+
afterNextRender({
|
|
411
|
+
read: () => {
|
|
412
|
+
this.#height.set(this.#hostElementRef.nativeElement.offsetHeight);
|
|
413
|
+
this.setDateValues();
|
|
414
|
+
const value = this.value();
|
|
415
|
+
if (value) {
|
|
416
|
+
const dt = DateTime.fromJSDate(value);
|
|
417
|
+
if (dt.isValid) {
|
|
418
|
+
this.navigatedDate.set(dt);
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
this.initializeNavigatedDate(value);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
this.setupKeyboardNavigation();
|
|
425
|
+
if (this.focusOnMount()) {
|
|
426
|
+
this.focusList(this.focusedList());
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
effect(() => {
|
|
431
|
+
const value = this.value();
|
|
432
|
+
untracked(() => this.setDateValues(value));
|
|
433
|
+
});
|
|
434
|
+
toObservable(this.navigatedDate)
|
|
435
|
+
.pipe(takeUntilDestroyed(), filter(() => !this.footer()), tap(() => this.updateValue(this.navigatedDate().toJSDate(), true)))
|
|
436
|
+
.subscribe();
|
|
437
|
+
}
|
|
438
|
+
focus() {
|
|
439
|
+
this.focusList(this.focusedList());
|
|
440
|
+
}
|
|
441
|
+
onBlur() {
|
|
442
|
+
this.touch.emit();
|
|
443
|
+
}
|
|
444
|
+
onHourChange(hour) {
|
|
445
|
+
if (this.disabled() || this.readonly()) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
this.navigatedDate.update(d => d.set({ hour }));
|
|
449
|
+
}
|
|
450
|
+
onMeridiemClick(meridiem) {
|
|
451
|
+
if (this.disabled() || this.readonly()) {
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
if (this.meridiem() === meridiem) {
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const hour = this.navigatedDate().hour;
|
|
458
|
+
if (meridiem === "PM" && hour < 12) {
|
|
459
|
+
this.navigatedDate.update(date => date.set({ hour: hour + 12 }));
|
|
460
|
+
}
|
|
461
|
+
else if (meridiem === "AM" && hour >= 12) {
|
|
462
|
+
this.navigatedDate.update(date => date.set({ hour: hour - 12 }));
|
|
463
|
+
}
|
|
464
|
+
this.meridiem.set(meridiem);
|
|
465
|
+
}
|
|
466
|
+
onMinuteChange(minute) {
|
|
467
|
+
if (this.disabled() || this.readonly()) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
this.navigatedDate.update(date => date.set({ minute }));
|
|
471
|
+
}
|
|
472
|
+
onNowClick(event) {
|
|
473
|
+
if (this.disabled() || this.readonly()) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
let now = DateTime.now();
|
|
477
|
+
const min = this.minDate();
|
|
478
|
+
const max = this.maxDate();
|
|
479
|
+
if (min && now < min) {
|
|
480
|
+
if (min.isValid) {
|
|
481
|
+
now = min;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
else if (max && now > max) {
|
|
485
|
+
if (max.isValid) {
|
|
486
|
+
now = max;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
this.navigatedDate.update(date => date.set({ hour: now.hour, minute: now.minute, second: now.second, millisecond: now.millisecond }));
|
|
490
|
+
this.meridiem.set(now.hour >= 12 ? "PM" : "AM");
|
|
491
|
+
}
|
|
492
|
+
onSecondChange(second) {
|
|
493
|
+
if (this.disabled() || this.readonly()) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
this.navigatedDate.update(date => date.set({ second }));
|
|
497
|
+
}
|
|
498
|
+
onSetTimeClick() {
|
|
499
|
+
if (this.disabled() || this.readonly()) {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
502
|
+
this.updateValue(this.navigatedDate().toJSDate(), true);
|
|
503
|
+
}
|
|
504
|
+
getListRef(listType) {
|
|
505
|
+
switch (listType) {
|
|
506
|
+
case "hours":
|
|
507
|
+
return this.hourListRef();
|
|
508
|
+
case "minutes":
|
|
509
|
+
return this.minuteListRef();
|
|
510
|
+
case "seconds":
|
|
511
|
+
return this.secondListRef();
|
|
512
|
+
case "meridiem":
|
|
513
|
+
return this.meridiemListRef();
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
getNextList(current, direction) {
|
|
517
|
+
const lists = ["hours", "minutes"];
|
|
518
|
+
if (this.showSeconds()) {
|
|
519
|
+
lists.push("seconds");
|
|
520
|
+
}
|
|
521
|
+
if (this.hourFormat() === "12") {
|
|
522
|
+
lists.push("meridiem");
|
|
523
|
+
}
|
|
524
|
+
const currentIndex = lists.indexOf(current);
|
|
525
|
+
if (direction === "right") {
|
|
526
|
+
return lists[(currentIndex + 1) % lists.length];
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
return lists[(currentIndex - 1 + lists.length) % lists.length];
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
handleKeydown(event) {
|
|
533
|
+
if (this.disabled() || this.readonly()) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
const preventableEvent = new PreventableEvent("calendarKeydown", event);
|
|
537
|
+
this.#timeSelectorService?.keydown$.next(preventableEvent);
|
|
538
|
+
if (preventableEvent.isDefaultPrevented()) {
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const focusedList = this.focusedList();
|
|
542
|
+
switch (event.key) {
|
|
543
|
+
case "ArrowUp":
|
|
544
|
+
event.preventDefault();
|
|
545
|
+
this.navigateItem(focusedList, -1);
|
|
546
|
+
break;
|
|
547
|
+
case "ArrowDown":
|
|
548
|
+
event.preventDefault();
|
|
549
|
+
this.navigateItem(focusedList, 1);
|
|
550
|
+
break;
|
|
551
|
+
case "ArrowLeft":
|
|
552
|
+
if (event.altKey) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
event.preventDefault();
|
|
556
|
+
this.focusedList.set(this.getNextList(focusedList, "left"));
|
|
557
|
+
this.focusList(this.focusedList());
|
|
558
|
+
break;
|
|
559
|
+
case "ArrowRight":
|
|
560
|
+
if (event.altKey) {
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
event.preventDefault();
|
|
564
|
+
this.focusedList.set(this.getNextList(focusedList, "right"));
|
|
565
|
+
this.focusList(this.focusedList());
|
|
566
|
+
break;
|
|
567
|
+
case "Home":
|
|
568
|
+
event.preventDefault();
|
|
569
|
+
this.navigateToEdge(focusedList, "first");
|
|
570
|
+
break;
|
|
571
|
+
case "End":
|
|
572
|
+
event.preventDefault();
|
|
573
|
+
this.navigateToEdge(focusedList, "last");
|
|
574
|
+
break;
|
|
575
|
+
case "Enter":
|
|
576
|
+
case " ":
|
|
577
|
+
this.updateValue(this.navigatedDate().toJSDate(), true);
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
focusList(listType) {
|
|
582
|
+
const listRef = this.getListRef(listType);
|
|
583
|
+
listRef?.nativeElement.focus();
|
|
584
|
+
}
|
|
585
|
+
dateValuesEqual(date1, date2) {
|
|
586
|
+
return date1?.getTime() === date2?.getTime();
|
|
587
|
+
}
|
|
588
|
+
initializeNavigatedDate(date) {
|
|
589
|
+
const min = this.min();
|
|
590
|
+
const max = this.max();
|
|
591
|
+
if (!date) {
|
|
592
|
+
this.navigatedDate.set(DateTime.now());
|
|
593
|
+
}
|
|
594
|
+
else if (min && date < min) {
|
|
595
|
+
const minDate = DateTime.fromJSDate(min);
|
|
596
|
+
if (minDate.isValid) {
|
|
597
|
+
this.navigatedDate.set(minDate);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
else if (max && date > max) {
|
|
601
|
+
const maxDate = DateTime.fromJSDate(max);
|
|
602
|
+
if (maxDate.isValid) {
|
|
603
|
+
this.navigatedDate.set(maxDate);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
const dateToSet = DateTime.fromJSDate(date);
|
|
608
|
+
if (dateToSet.isValid) {
|
|
609
|
+
this.navigatedDate.set(dateToSet);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
navigateItem(listType, direction) {
|
|
614
|
+
switch (listType) {
|
|
615
|
+
case "hours": {
|
|
616
|
+
const hours = Array.from(this.viewHours());
|
|
617
|
+
const currentIndex = hours.findIndex(h => h.viewValue === this.hour());
|
|
618
|
+
const newIndex = Math.max(0, Math.min(hours.length - 1, currentIndex + direction));
|
|
619
|
+
if (hours[newIndex]) {
|
|
620
|
+
this.onHourChange(hours[newIndex].value);
|
|
621
|
+
}
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
case "minutes": {
|
|
625
|
+
const currentMinute = this.minute();
|
|
626
|
+
const newMinute = Math.max(0, Math.min(59, currentMinute + direction));
|
|
627
|
+
this.onMinuteChange(newMinute);
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
case "seconds": {
|
|
631
|
+
const currentSecond = this.second();
|
|
632
|
+
const newSecond = Math.max(0, Math.min(59, currentSecond + direction));
|
|
633
|
+
this.onSecondChange(newSecond);
|
|
634
|
+
break;
|
|
635
|
+
}
|
|
636
|
+
case "meridiem": {
|
|
637
|
+
const current = this.meridiem();
|
|
638
|
+
if (direction !== 0) {
|
|
639
|
+
this.onMeridiemClick(current === "AM" ? "PM" : "AM");
|
|
640
|
+
}
|
|
641
|
+
break;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
navigateToEdge(listType, edge) {
|
|
646
|
+
switch (listType) {
|
|
647
|
+
case "hours": {
|
|
648
|
+
const hours = Array.from(this.viewHours());
|
|
649
|
+
const target = edge === "first" ? hours[0] : hours[hours.length - 1];
|
|
650
|
+
if (target) {
|
|
651
|
+
this.onHourChange(target.value);
|
|
652
|
+
}
|
|
653
|
+
break;
|
|
654
|
+
}
|
|
655
|
+
case "minutes": {
|
|
656
|
+
this.onMinuteChange(edge === "first" ? 0 : 59);
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
case "seconds": {
|
|
660
|
+
this.onSecondChange(edge === "first" ? 0 : 59);
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
case "meridiem": {
|
|
664
|
+
this.onMeridiemClick(edge === "first" ? "AM" : "PM");
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
setDateValues(value = this.value()) {
|
|
670
|
+
const currentDate = this.navigatedDate().toJSDate();
|
|
671
|
+
if (!this.dateValuesEqual(currentDate, value)) {
|
|
672
|
+
this.initializeNavigatedDate(value);
|
|
673
|
+
}
|
|
674
|
+
const meridiem = this.navigatedDate().hour >= 12 ? "PM" : "AM";
|
|
675
|
+
this.meridiem.set(meridiem);
|
|
676
|
+
}
|
|
677
|
+
setupKeyboardNavigation() {
|
|
678
|
+
fromEvent(this.#hostElementRef.nativeElement, "keydown")
|
|
679
|
+
.pipe(takeUntilDestroyed(this.#destroyRef), filter(() => !this.disabled()))
|
|
680
|
+
.subscribe(event => this.handleKeydown(event));
|
|
681
|
+
}
|
|
682
|
+
updateValue(date, notify) {
|
|
683
|
+
if (this.dateValuesEqual(this.value(), date)) {
|
|
684
|
+
if (notify) {
|
|
685
|
+
this.touch.emit();
|
|
686
|
+
}
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
this.value.set(date);
|
|
690
|
+
if (notify) {
|
|
691
|
+
this.touch.emit();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
695
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: TimeSelectorComponent, isStandalone: true, selector: "mona-time-selector", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, focusOnMount: { classPropertyName: "focusOnMount", publicName: "focusOnMount", isSignal: true, isRequired: false, transformFunction: null }, footer: { classPropertyName: "footer", publicName: "footer", isSignal: true, isRequired: false, transformFunction: null }, hourFormat: { classPropertyName: "hourFormat", publicName: "hourFormat", isSignal: true, isRequired: false, transformFunction: null }, hourStep: { classPropertyName: "hourStep", publicName: "hourStep", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, minuteStep: { classPropertyName: "minuteStep", publicName: "minuteStep", 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 }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, secondStep: { classPropertyName: "secondStep", publicName: "secondStep", isSignal: true, isRequired: false, transformFunction: null }, showSeconds: { classPropertyName: "showSeconds", publicName: "showSeconds", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { touch: "touch", value: "valueChange" }, host: { attributes: { "role": "group" }, listeners: { "blur": "onBlur()" }, properties: { "attr.aria-label": "ariaLabel()", "attr.aria-disabled": "disabled()", "attr.aria-invalid": "invalid() ? 'true' : null", "attr.aria-readonly": "readonly()", "attr.aria-required": "required()", "attr.data-invalid": "invalid() || null", "attr.data-readonly": "readonly() || null", "attr.data-required": "required() || null", "class": "baseClass()" } }, viewQueries: [{ propertyName: "hourListRef", first: true, predicate: ["hourList"], descendants: true, isSignal: true }, { propertyName: "meridiemListRef", first: true, predicate: ["meridiemList"], descendants: true, isSignal: true }, { propertyName: "minuteListRef", first: true, predicate: ["minuteList"], descendants: true, isSignal: true }, { propertyName: "secondListRef", first: true, predicate: ["secondList"], descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"headerClass()\">\n <div>Hr</div>\n <div>Min</div>\n @if (showSeconds()) {\n <div>Sec</div>\n }\n</div>\n\n<div [class]=\"infoContainerClass()\">\n <span>{{ navigatedDateText() }}</span>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n (click)=\"onNowClick($event)\"\n (keydown.enter)=\"onNowClick($event)\"\n (keydown.space)=\"onNowClick($event)\">\n Now\n </button>\n</div>\n\n<div [class]=\"listContainerClass()\">\n <ol\n #hourList\n monaTimeSelectorList\n aria-label=\"Hours\"\n [attr.aria-activedescendant]=\"`${hourListId}${navigatedDate().hour}`\"\n [active]=\"focusedList() === 'hours'\"\n [id]=\"hourListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (h of viewHours() | timeLimiter: \"h\" : navigatedDate() : minDate() : maxDate(); track h) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"h.viewValue === hour()\"\n [value]=\"h.value\"\n [id]=\"`${hourListId}${h.value}`\"\n (click)=\"onHourChange(h.value)\">\n {{ h.viewValue | number: \"2.0\" }}\n </li>\n }\n </ol>\n <ol\n #minuteList\n monaTimeSelectorList\n aria-label=\"Minutes\"\n [attr.aria-activedescendant]=\"`${minuteListId}${navigatedDate().minute}`\"\n [active]=\"focusedList() === 'minutes'\"\n [id]=\"minuteListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (m of minutes() | timeLimiter: \"m\" : navigatedDate() : minDate() : maxDate(); track m) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"m.value === minute()\"\n [value]=\"m.value\"\n [id]=\"`${minuteListId}${m.value}`\"\n (click)=\"onMinuteChange(m.value)\">\n {{ m.viewValue | number: \"2.0\" }}\n </li>\n }\n </ol>\n @if (showSeconds()) {\n <ol\n #secondList\n monaTimeSelectorList\n aria-label=\"Seconds\"\n [attr.aria-activedescendant]=\"`${secondListId}${navigatedDate().second}`\"\n [active]=\"focusedList() === 'seconds'\"\n [id]=\"secondListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (s of seconds() | timeLimiter: \"s\" : navigatedDate() : minDate() : maxDate(); track s) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"s.value === second()\"\n [value]=\"s.value\"\n [id]=\"`${secondListId}${s.value}`\"\n (click)=\"onSecondChange(s.value)\">\n {{ s.value | number: \"2.0\" }}\n </li>\n }\n </ol>\n }\n @if (hourFormat() === \"12\") {\n <ol\n #meridiemList\n monaTimeSelectorList\n aria-label=\"AM/PM\"\n [attr.aria-activedescendant]=\"`${meridiemListId}${meridiem()}`\"\n [active]=\"focusedList() === 'meridiem'\"\n [id]=\"meridiemListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @if (amMeridiemVisible()) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"meridiem() === 'AM'\"\n [value]=\"'AM'\"\n (click)=\"onMeridiemClick('AM')\"\n [id]=\"`${meridiemListId}AM`\">\n AM\n </li>\n }\n @if (pmMeridiemVisible()) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"meridiem() === 'PM'\"\n [value]=\"'PM'\"\n (click)=\"onMeridiemClick('PM')\"\n [id]=\"`${meridiemListId}PM`\">\n PM\n </li>\n }\n </ol>\n }\n</div>\n\n@if (footer()) {\n <div [class]=\"footerClass()\">\n <button monaButton look=\"primary\" [rounded]=\"rounded()\" [size]=\"size()\" (click)=\"onSetTimeClick()\">Set</button>\n </div>\n}\n", dependencies: [{ kind: "directive", type: TimeSelectorItemDirective, selector: "li[monaTimeSelectorItem]", inputs: ["selected", "size", "value"] }, { 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: "directive", type: TimeSelectorListDirective, selector: "ol[monaTimeSelectorList]", inputs: ["active", "popupHeight", "size"] }, { kind: "pipe", type: DecimalPipe, name: "number" }, { kind: "pipe", type: TimeLimiterPipe, name: "timeLimiter" }] }); }
|
|
696
|
+
}
|
|
697
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TimeSelectorComponent, decorators: [{
|
|
698
|
+
type: Component,
|
|
699
|
+
args: [{ selector: "mona-time-selector", imports: [DecimalPipe, TimeLimiterPipe, TimeSelectorItemDirective, ButtonDirective, TimeSelectorListDirective], host: {
|
|
700
|
+
role: "group",
|
|
701
|
+
"[attr.aria-label]": "ariaLabel()",
|
|
702
|
+
"[attr.aria-disabled]": "disabled()",
|
|
703
|
+
"[attr.aria-invalid]": "invalid() ? 'true' : null",
|
|
704
|
+
"[attr.aria-readonly]": "readonly()",
|
|
705
|
+
"[attr.aria-required]": "required()",
|
|
706
|
+
"[attr.data-invalid]": "invalid() || null",
|
|
707
|
+
"[attr.data-readonly]": "readonly() || null",
|
|
708
|
+
"[attr.data-required]": "required() || null",
|
|
709
|
+
"[class]": "baseClass()",
|
|
710
|
+
"(blur)": "onBlur()"
|
|
711
|
+
}, template: "<div [class]=\"headerClass()\">\n <div>Hr</div>\n <div>Min</div>\n @if (showSeconds()) {\n <div>Sec</div>\n }\n</div>\n\n<div [class]=\"infoContainerClass()\">\n <span>{{ navigatedDateText() }}</span>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n (click)=\"onNowClick($event)\"\n (keydown.enter)=\"onNowClick($event)\"\n (keydown.space)=\"onNowClick($event)\">\n Now\n </button>\n</div>\n\n<div [class]=\"listContainerClass()\">\n <ol\n #hourList\n monaTimeSelectorList\n aria-label=\"Hours\"\n [attr.aria-activedescendant]=\"`${hourListId}${navigatedDate().hour}`\"\n [active]=\"focusedList() === 'hours'\"\n [id]=\"hourListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (h of viewHours() | timeLimiter: \"h\" : navigatedDate() : minDate() : maxDate(); track h) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"h.viewValue === hour()\"\n [value]=\"h.value\"\n [id]=\"`${hourListId}${h.value}`\"\n (click)=\"onHourChange(h.value)\">\n {{ h.viewValue | number: \"2.0\" }}\n </li>\n }\n </ol>\n <ol\n #minuteList\n monaTimeSelectorList\n aria-label=\"Minutes\"\n [attr.aria-activedescendant]=\"`${minuteListId}${navigatedDate().minute}`\"\n [active]=\"focusedList() === 'minutes'\"\n [id]=\"minuteListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (m of minutes() | timeLimiter: \"m\" : navigatedDate() : minDate() : maxDate(); track m) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"m.value === minute()\"\n [value]=\"m.value\"\n [id]=\"`${minuteListId}${m.value}`\"\n (click)=\"onMinuteChange(m.value)\">\n {{ m.viewValue | number: \"2.0\" }}\n </li>\n }\n </ol>\n @if (showSeconds()) {\n <ol\n #secondList\n monaTimeSelectorList\n aria-label=\"Seconds\"\n [attr.aria-activedescendant]=\"`${secondListId}${navigatedDate().second}`\"\n [active]=\"focusedList() === 'seconds'\"\n [id]=\"secondListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @for (s of seconds() | timeLimiter: \"s\" : navigatedDate() : minDate() : maxDate(); track s) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"s.value === second()\"\n [value]=\"s.value\"\n [id]=\"`${secondListId}${s.value}`\"\n (click)=\"onSecondChange(s.value)\">\n {{ s.value | number: \"2.0\" }}\n </li>\n }\n </ol>\n }\n @if (hourFormat() === \"12\") {\n <ol\n #meridiemList\n monaTimeSelectorList\n aria-label=\"AM/PM\"\n [attr.aria-activedescendant]=\"`${meridiemListId}${meridiem()}`\"\n [active]=\"focusedList() === 'meridiem'\"\n [id]=\"meridiemListId\"\n [popupHeight]=\"computedPopupHeight()\"\n [size]=\"size()\">\n @if (amMeridiemVisible()) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"meridiem() === 'AM'\"\n [value]=\"'AM'\"\n (click)=\"onMeridiemClick('AM')\"\n [id]=\"`${meridiemListId}AM`\">\n AM\n </li>\n }\n @if (pmMeridiemVisible()) {\n <li\n monaTimeSelectorItem\n [size]=\"size()\"\n [selected]=\"meridiem() === 'PM'\"\n [value]=\"'PM'\"\n (click)=\"onMeridiemClick('PM')\"\n [id]=\"`${meridiemListId}PM`\">\n PM\n </li>\n }\n </ol>\n }\n</div>\n\n@if (footer()) {\n <div [class]=\"footerClass()\">\n <button monaButton look=\"primary\" [rounded]=\"rounded()\" [size]=\"size()\" (click)=\"onSetTimeClick()\">Set</button>\n </div>\n}\n" }]
|
|
712
|
+
}], ctorParameters: () => [], propDecorators: { hourListRef: [{ type: i0.ViewChild, args: ["hourList", { isSignal: true }] }], meridiemListRef: [{ type: i0.ViewChild, args: ["meridiemList", { isSignal: true }] }], minuteListRef: [{ type: i0.ViewChild, args: ["minuteList", { isSignal: true }] }], secondListRef: [{ type: i0.ViewChild, args: ["secondList", { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], focusOnMount: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnMount", required: false }] }], footer: [{ type: i0.Input, args: [{ isSignal: true, alias: "footer", required: false }] }], hourFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "hourFormat", required: false }] }], hourStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "hourStep", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], minuteStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "minuteStep", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], secondStep: [{ type: i0.Input, args: [{ isSignal: true, alias: "secondStep", required: false }] }], showSeconds: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSeconds", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
|
|
713
|
+
|
|
714
|
+
/*
|
|
715
|
+
* Public API Surface of @nanahoshi/mona-ui/time-selector
|
|
716
|
+
*/
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Generated bundle index. Do not edit.
|
|
720
|
+
*/
|
|
721
|
+
|
|
722
|
+
export { TimeSelectorComponent };
|
|
723
|
+
//# sourceMappingURL=nanahoshi-mona-ui-time-selector.mjs.map
|