@ngbase/adk 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 +57 -0
- package/a11y/accessibility-group.d.ts +49 -0
- package/a11y/accessibility-item.d.ts +49 -0
- package/a11y/accessibility.service.d.ts +17 -0
- package/a11y/autofocus.d.ts +12 -0
- package/a11y/focus-trap.d.ts +15 -0
- package/a11y/index.d.ts +5 -0
- package/a11y/public-api.d.ts +4 -0
- package/accordion/accordion-content.d.ts +8 -0
- package/accordion/accordion-group.d.ts +10 -0
- package/accordion/accordion-header.d.ts +7 -0
- package/accordion/accordion-item.d.ts +10 -0
- package/accordion/index.d.ts +5 -0
- package/accordion/public-api.d.ts +4 -0
- package/autocomplete/autocomplete-input.d.ts +21 -0
- package/autocomplete/autocomplete.d.ts +25 -0
- package/autocomplete/index.d.ts +5 -0
- package/autocomplete/public-api.d.ts +2 -0
- package/avatar/avatar.d.ts +22 -0
- package/avatar/index.d.ts +5 -0
- package/avatar/public-api.d.ts +1 -0
- package/bidi/direction.service.d.ts +14 -0
- package/bidi/index.d.ts +5 -0
- package/bidi/public-api.d.ts +1 -0
- package/breadcrumb/breadcrumb-link.d.ts +7 -0
- package/breadcrumb/breadcrumb-separator.d.ts +10 -0
- package/breadcrumb/breadcrumb.d.ts +12 -0
- package/breadcrumb/breadcrumbs.d.ts +7 -0
- package/breadcrumb/index.d.ts +5 -0
- package/breadcrumb/public-api.d.ts +4 -0
- package/cache/cache-config.d.ts +22 -0
- package/cache/cache.d.ts +17 -0
- package/cache/cache.interecptor.d.ts +2 -0
- package/cache/index.d.ts +5 -0
- package/cache/public-api.d.ts +3 -0
- package/carousel/carousel-item.d.ts +7 -0
- package/carousel/carousel-next.d.ts +8 -0
- package/carousel/carousel.d.ts +61 -0
- package/carousel/index.d.ts +5 -0
- package/carousel/public-api.d.ts +3 -0
- package/checkbox/checkbox.d.ts +22 -0
- package/checkbox/index.d.ts +5 -0
- package/checkbox/public-api.d.ts +1 -0
- package/chip/chip-group.d.ts +7 -0
- package/chip/chip.d.ts +19 -0
- package/chip/index.d.ts +5 -0
- package/chip/public-api.d.ts +2 -0
- package/clipboard/clipboard.d.ts +7 -0
- package/clipboard/index.d.ts +5 -0
- package/clipboard/public-api.d.ts +1 -0
- package/collections/SelectionModel.d.ts +14 -0
- package/collections/index.d.ts +5 -0
- package/collections/public-api.d.ts +1 -0
- package/color-picker/color-input.d.ts +16 -0
- package/color-picker/color-picker-trigger.d.ts +30 -0
- package/color-picker/color-picker.d.ts +72 -0
- package/color-picker/index.d.ts +5 -0
- package/color-picker/public-api.d.ts +3 -0
- package/color-picker/utils.d.ts +21 -0
- package/cookies/cookie.service.d.ts +32 -0
- package/cookies/index.d.ts +5 -0
- package/cookies/public-api.d.ts +1 -0
- package/datepicker/calendar.d.ts +121 -0
- package/datepicker/datepicker-trigger.d.ts +49 -0
- package/datepicker/datepicker.d.ts +54 -0
- package/datepicker/index.d.ts +5 -0
- package/datepicker/native-date-adapter.d.ts +33 -0
- package/datepicker/public-api.d.ts +5 -0
- package/datepicker/time.d.ts +42 -0
- package/dialog/dialog.animation.d.ts +3 -0
- package/dialog/dialog.d.ts +49 -0
- package/dialog/dialog.service.d.ts +7 -0
- package/dialog/index.d.ts +5 -0
- package/dialog/public-api.d.ts +3 -0
- package/drag/drag-drop.d.ts +37 -0
- package/drag/drag-move.d.ts +17 -0
- package/drag/drag.d.ts +53 -0
- package/drag/index.d.ts +5 -0
- package/drag/public-api.d.ts +3 -0
- package/fesm2022/ngbase-adk-a11y.mjs +617 -0
- package/fesm2022/ngbase-adk-a11y.mjs.map +1 -0
- package/fesm2022/ngbase-adk-accordion.mjs +117 -0
- package/fesm2022/ngbase-adk-accordion.mjs.map +1 -0
- package/fesm2022/ngbase-adk-autocomplete.mjs +150 -0
- package/fesm2022/ngbase-adk-autocomplete.mjs.map +1 -0
- package/fesm2022/ngbase-adk-avatar.mjs +69 -0
- package/fesm2022/ngbase-adk-avatar.mjs.map +1 -0
- package/fesm2022/ngbase-adk-bidi.mjs +42 -0
- package/fesm2022/ngbase-adk-bidi.mjs.map +1 -0
- package/fesm2022/ngbase-adk-breadcrumb.mjs +103 -0
- package/fesm2022/ngbase-adk-breadcrumb.mjs.map +1 -0
- package/fesm2022/ngbase-adk-cache.mjs +127 -0
- package/fesm2022/ngbase-adk-cache.mjs.map +1 -0
- package/fesm2022/ngbase-adk-carousel.mjs +337 -0
- package/fesm2022/ngbase-adk-carousel.mjs.map +1 -0
- package/fesm2022/ngbase-adk-checkbox.mjs +78 -0
- package/fesm2022/ngbase-adk-checkbox.mjs.map +1 -0
- package/fesm2022/ngbase-adk-chip.mjs +60 -0
- package/fesm2022/ngbase-adk-chip.mjs.map +1 -0
- package/fesm2022/ngbase-adk-clipboard.mjs +41 -0
- package/fesm2022/ngbase-adk-clipboard.mjs.map +1 -0
- package/fesm2022/ngbase-adk-collections.mjs +39 -0
- package/fesm2022/ngbase-adk-collections.mjs.map +1 -0
- package/fesm2022/ngbase-adk-color-picker.mjs +580 -0
- package/fesm2022/ngbase-adk-color-picker.mjs.map +1 -0
- package/fesm2022/ngbase-adk-cookies.mjs +81 -0
- package/fesm2022/ngbase-adk-cookies.mjs.map +1 -0
- package/fesm2022/ngbase-adk-datepicker.mjs +1130 -0
- package/fesm2022/ngbase-adk-datepicker.mjs.map +1 -0
- package/fesm2022/ngbase-adk-dialog.mjs +223 -0
- package/fesm2022/ngbase-adk-dialog.mjs.map +1 -0
- package/fesm2022/ngbase-adk-drag.mjs +406 -0
- package/fesm2022/ngbase-adk-drag.mjs.map +1 -0
- package/fesm2022/ngbase-adk-form-field.mjs +364 -0
- package/fesm2022/ngbase-adk-form-field.mjs.map +1 -0
- package/fesm2022/ngbase-adk-hover-card.mjs +79 -0
- package/fesm2022/ngbase-adk-hover-card.mjs.map +1 -0
- package/fesm2022/ngbase-adk-icon.mjs +90 -0
- package/fesm2022/ngbase-adk-icon.mjs.map +1 -0
- package/fesm2022/ngbase-adk-inline-edit.mjs +127 -0
- package/fesm2022/ngbase-adk-inline-edit.mjs.map +1 -0
- package/fesm2022/ngbase-adk-jwt.mjs +90 -0
- package/fesm2022/ngbase-adk-jwt.mjs.map +1 -0
- package/fesm2022/ngbase-adk-keys.mjs +219 -0
- package/fesm2022/ngbase-adk-keys.mjs.map +1 -0
- package/fesm2022/ngbase-adk-layout.mjs +100 -0
- package/fesm2022/ngbase-adk-layout.mjs.map +1 -0
- package/fesm2022/ngbase-adk-list.mjs +110 -0
- package/fesm2022/ngbase-adk-list.mjs.map +1 -0
- package/fesm2022/ngbase-adk-mask.mjs +234 -0
- package/fesm2022/ngbase-adk-mask.mjs.map +1 -0
- package/fesm2022/ngbase-adk-menu.mjs +546 -0
- package/fesm2022/ngbase-adk-menu.mjs.map +1 -0
- package/fesm2022/ngbase-adk-network.mjs +90 -0
- package/fesm2022/ngbase-adk-network.mjs.map +1 -0
- package/fesm2022/ngbase-adk-pagination.mjs +187 -0
- package/fesm2022/ngbase-adk-pagination.mjs.map +1 -0
- package/fesm2022/ngbase-adk-popover.mjs +953 -0
- package/fesm2022/ngbase-adk-popover.mjs.map +1 -0
- package/fesm2022/ngbase-adk-portal.mjs +279 -0
- package/fesm2022/ngbase-adk-portal.mjs.map +1 -0
- package/fesm2022/ngbase-adk-progress.mjs +57 -0
- package/fesm2022/ngbase-adk-progress.mjs.map +1 -0
- package/fesm2022/ngbase-adk-radio.mjs +129 -0
- package/fesm2022/ngbase-adk-radio.mjs.map +1 -0
- package/fesm2022/ngbase-adk-resizable.mjs +367 -0
- package/fesm2022/ngbase-adk-resizable.mjs.map +1 -0
- package/fesm2022/ngbase-adk-scroll-area.mjs +232 -0
- package/fesm2022/ngbase-adk-scroll-area.mjs.map +1 -0
- package/fesm2022/ngbase-adk-select.mjs +599 -0
- package/fesm2022/ngbase-adk-select.mjs.map +1 -0
- package/fesm2022/ngbase-adk-selectable.mjs +79 -0
- package/fesm2022/ngbase-adk-selectable.mjs.map +1 -0
- package/fesm2022/ngbase-adk-sidenav.mjs +209 -0
- package/fesm2022/ngbase-adk-sidenav.mjs.map +1 -0
- package/fesm2022/ngbase-adk-slider.mjs +337 -0
- package/fesm2022/ngbase-adk-slider.mjs.map +1 -0
- package/fesm2022/ngbase-adk-sonner.mjs +176 -0
- package/fesm2022/ngbase-adk-sonner.mjs.map +1 -0
- package/fesm2022/ngbase-adk-stepper.mjs +211 -0
- package/fesm2022/ngbase-adk-stepper.mjs.map +1 -0
- package/fesm2022/ngbase-adk-switch.mjs +115 -0
- package/fesm2022/ngbase-adk-switch.mjs.map +1 -0
- package/fesm2022/ngbase-adk-table.mjs +348 -0
- package/fesm2022/ngbase-adk-table.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tabs.mjs +386 -0
- package/fesm2022/ngbase-adk-tabs.mjs.map +1 -0
- package/fesm2022/ngbase-adk-test.mjs +267 -0
- package/fesm2022/ngbase-adk-test.mjs.map +1 -0
- package/fesm2022/ngbase-adk-toggle-group.mjs +114 -0
- package/fesm2022/ngbase-adk-toggle-group.mjs.map +1 -0
- package/fesm2022/ngbase-adk-toggle.mjs +48 -0
- package/fesm2022/ngbase-adk-toggle.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tooltip.mjs +237 -0
- package/fesm2022/ngbase-adk-tooltip.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tour.mjs +312 -0
- package/fesm2022/ngbase-adk-tour.mjs.map +1 -0
- package/fesm2022/ngbase-adk-translate.mjs +162 -0
- package/fesm2022/ngbase-adk-translate.mjs.map +1 -0
- package/fesm2022/ngbase-adk-tree.mjs +301 -0
- package/fesm2022/ngbase-adk-tree.mjs.map +1 -0
- package/fesm2022/ngbase-adk-utils.mjs +228 -0
- package/fesm2022/ngbase-adk-utils.mjs.map +1 -0
- package/fesm2022/ngbase-adk-virtualizer.mjs +198 -0
- package/fesm2022/ngbase-adk-virtualizer.mjs.map +1 -0
- package/fesm2022/ngbase-adk.mjs +6 -0
- package/fesm2022/ngbase-adk.mjs.map +1 -0
- package/form-field/auto-height.d.ts +9 -0
- package/form-field/error.d.ts +18 -0
- package/form-field/form-field.d.ts +14 -0
- package/form-field/index.d.ts +5 -0
- package/form-field/input.d.ts +16 -0
- package/form-field/label.d.ts +7 -0
- package/form-field/otp.d.ts +48 -0
- package/form-field/public-api.d.ts +6 -0
- package/hover-card/hover-card.d.ts +18 -0
- package/hover-card/index.d.ts +5 -0
- package/hover-card/public-api.d.ts +1 -0
- package/icon/icon.d.ts +12 -0
- package/icon/icon.service.d.ts +12 -0
- package/icon/index.d.ts +5 -0
- package/icon/public-api.d.ts +2 -0
- package/index.d.ts +5 -0
- package/inline-edit/index.d.ts +5 -0
- package/inline-edit/inline-edit.d.ts +47 -0
- package/inline-edit/public-api.d.ts +1 -0
- package/jwt/index.d.ts +5 -0
- package/jwt/jwt.service.d.ts +27 -0
- package/jwt/public-api.d.ts +1 -0
- package/keys/index.d.ts +5 -0
- package/keys/keys.service.d.ts +13 -0
- package/keys/public-api.d.ts +2 -0
- package/keys/shortcuts.service.d.ts +38 -0
- package/layout/index.d.ts +5 -0
- package/layout/layout.d.ts +16 -0
- package/layout/public-api.d.ts +1 -0
- package/list/index.d.ts +5 -0
- package/list/list.d.ts +20 -0
- package/list/list.directive.d.ts +12 -0
- package/list/public-api.d.ts +2 -0
- package/mask/index.d.ts +5 -0
- package/mask/mask-pipe.d.ts +7 -0
- package/mask/mask.d.ts +25 -0
- package/mask/public-api.d.ts +2 -0
- package/menu/context-menu.d.ts +21 -0
- package/menu/index.d.ts +5 -0
- package/menu/mention.d.ts +18 -0
- package/menu/menu-trigger.d.ts +34 -0
- package/menu/menu.d.ts +52 -0
- package/menu/navigation-menu.d.ts +19 -0
- package/menu/public-api.d.ts +5 -0
- package/network/index.d.ts +5 -0
- package/network/network.interceptor.d.ts +6 -0
- package/network/network.service.d.ts +18 -0
- package/network/public-api.d.ts +2 -0
- package/package.json +247 -0
- package/pagination/index.d.ts +5 -0
- package/pagination/pagination.d.ts +28 -0
- package/pagination/public-api.d.ts +1 -0
- package/popover/base-popover.service.d.ts +16 -0
- package/popover/index.d.ts +5 -0
- package/popover/popover-trigger.d.ts +21 -0
- package/popover/popover.d.ts +50 -0
- package/popover/popover.service.d.ts +42 -0
- package/popover/public-api.d.ts +5 -0
- package/popover/utils.d.ts +85 -0
- package/portal/dialog-ref.d.ts +71 -0
- package/portal/index.d.ts +5 -0
- package/portal/portal-base.service.d.ts +19 -0
- package/portal/portal-close.directive.d.ts +8 -0
- package/portal/portal.component.d.ts +7 -0
- package/portal/portal.service.d.ts +16 -0
- package/portal/public-api.d.ts +5 -0
- package/progress/index.d.ts +5 -0
- package/progress/progress.d.ts +13 -0
- package/progress/public-api.d.ts +1 -0
- package/public-api.d.ts +2 -0
- package/radio/index.d.ts +5 -0
- package/radio/public-api.d.ts +2 -0
- package/radio/radio-group.d.ts +19 -0
- package/radio/radio.d.ts +22 -0
- package/resizable/index.d.ts +5 -0
- package/resizable/public-api.d.ts +2 -0
- package/resizable/resizable-group.d.ts +22 -0
- package/resizable/resizable.d.ts +50 -0
- package/scroll-area/index.d.ts +5 -0
- package/scroll-area/public-api.d.ts +1 -0
- package/scroll-area/scroll-area.d.ts +56 -0
- package/select/index.d.ts +5 -0
- package/select/list-selection.d.ts +7 -0
- package/select/option-group.d.ts +7 -0
- package/select/option.d.ts +25 -0
- package/select/public-api.d.ts +6 -0
- package/select/select-base.d.ts +64 -0
- package/select/select-input.d.ts +23 -0
- package/select/select.d.ts +50 -0
- package/selectable/index.d.ts +5 -0
- package/selectable/public-api.d.ts +2 -0
- package/selectable/selectable-item.d.ts +12 -0
- package/selectable/selectable.d.ts +19 -0
- package/sidenav/index.d.ts +5 -0
- package/sidenav/public-api.d.ts +3 -0
- package/sidenav/sidenav-header.d.ts +31 -0
- package/sidenav/sidenav.d.ts +23 -0
- package/sidenav/sidenav.service.d.ts +18 -0
- package/slider/index.d.ts +5 -0
- package/slider/public-api.d.ts +1 -0
- package/slider/slider.d.ts +73 -0
- package/sonner/index.d.ts +5 -0
- package/sonner/public-api.d.ts +2 -0
- package/sonner/sonner.d.ts +24 -0
- package/sonner/sonner.service.d.ts +21 -0
- package/stepper/animation.d.ts +1 -0
- package/stepper/index.d.ts +5 -0
- package/stepper/public-api.d.ts +3 -0
- package/stepper/step.d.ts +24 -0
- package/stepper/stepper.d.ts +26 -0
- package/switch/index.d.ts +5 -0
- package/switch/public-api.d.ts +1 -0
- package/switch/switch.d.ts +44 -0
- package/table/body-cell.d.ts +11 -0
- package/table/body-row.d.ts +21 -0
- package/table/column.d.ts +10 -0
- package/table/head-cell.d.ts +12 -0
- package/table/head-row.d.ts +21 -0
- package/table/index.d.ts +5 -0
- package/table/public-api.d.ts +8 -0
- package/table/table.d.ts +32 -0
- package/tabs/index.d.ts +5 -0
- package/tabs/public-api.d.ts +2 -0
- package/tabs/tab-group.d.ts +52 -0
- package/tabs/tab.d.ts +31 -0
- package/test/index.d.ts +5 -0
- package/test/public-api.d.ts +1 -0
- package/test/utils.d.ts +62 -0
- package/toggle/index.d.ts +5 -0
- package/toggle/public-api.d.ts +1 -0
- package/toggle/toggle.d.ts +13 -0
- package/toggle-group/index.d.ts +5 -0
- package/toggle-group/public-api.d.ts +2 -0
- package/toggle-group/toggle-group.d.ts +25 -0
- package/toggle-group/toggle-item.d.ts +14 -0
- package/tooltip/index.d.ts +5 -0
- package/tooltip/public-api.d.ts +2 -0
- package/tooltip/tooltip.d.ts +20 -0
- package/tooltip/tooltip.directive.d.ts +34 -0
- package/tooltip/tooltip.service.d.ts +26 -0
- package/tour/animation.d.ts +2 -0
- package/tour/index.d.ts +5 -0
- package/tour/public-api.d.ts +5 -0
- package/tour/tour-base.d.ts +21 -0
- package/tour/tour-step.d.ts +11 -0
- package/tour/tour.d.ts +9 -0
- package/tour/tour.service.d.ts +30 -0
- package/translate/config.d.ts +16 -0
- package/translate/index.d.ts +5 -0
- package/translate/public-api.d.ts +3 -0
- package/translate/translate.d.ts +11 -0
- package/translate/translate.service.d.ts +31 -0
- package/tree/index.d.ts +5 -0
- package/tree/public-api.d.ts +3 -0
- package/tree/tree-node.d.ts +28 -0
- package/tree/tree-toggle.d.ts +16 -0
- package/tree/tree.d.ts +55 -0
- package/utils/animation.d.ts +3 -0
- package/utils/disposals.d.ts +7 -0
- package/utils/index.d.ts +5 -0
- package/utils/number-only.d.ts +22 -0
- package/utils/public-api.d.ts +6 -0
- package/utils/range.pipe.d.ts +7 -0
- package/utils/ssr.d.ts +2 -0
- package/utils/utils.d.ts +27 -0
- package/virtualizer/index.d.ts +5 -0
- package/virtualizer/public-api.d.ts +1 -0
- package/virtualizer/virtualizer.d.ts +42 -0
|
@@ -0,0 +1,1130 @@
|
|
|
1
|
+
import { NgTemplateOutlet, NgClass } from '@angular/common';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { InjectionToken, inject, ElementRef, Injector, input, booleanAttribute, computed, effect, afterNextRender, Directive, viewChild, model, signal, Component, ChangeDetectionStrategy, output, untracked, viewChildren } from '@angular/core';
|
|
4
|
+
import * as i1$1 from '@ngbase/adk/a11y';
|
|
5
|
+
import { AccessibleGroup, AccessibleItem } from '@ngbase/adk/a11y';
|
|
6
|
+
import { Directionality } from '@ngbase/adk/bidi';
|
|
7
|
+
import { DialogRef } from '@ngbase/adk/portal';
|
|
8
|
+
import * as i1$2 from '@ngbase/adk/utils';
|
|
9
|
+
import { uniqueId, RangePipe, NumberOnly, padString, provideValueAccessor } from '@ngbase/adk/utils';
|
|
10
|
+
import * as i1 from '@ngbase/adk/form-field';
|
|
11
|
+
import { InputBase } from '@ngbase/adk/form-field';
|
|
12
|
+
import { ngbPopoverPortal } from '@ngbase/adk/popover';
|
|
13
|
+
|
|
14
|
+
const NgbDateAdapter = new InjectionToken('mat-date-formats');
|
|
15
|
+
function injectNgbDateAdapter() {
|
|
16
|
+
const adapter = inject(NgbDateAdapter, { optional: true });
|
|
17
|
+
return adapter || new NgbNativeDateAdapter();
|
|
18
|
+
}
|
|
19
|
+
class NgbNativeDateAdapter {
|
|
20
|
+
now() {
|
|
21
|
+
return new Date();
|
|
22
|
+
}
|
|
23
|
+
create(year, month = 0, date = 1) {
|
|
24
|
+
return new Date(year, month, date);
|
|
25
|
+
}
|
|
26
|
+
compare(first, second) {
|
|
27
|
+
return first.getTime() - second.getTime();
|
|
28
|
+
}
|
|
29
|
+
getTime(date) {
|
|
30
|
+
return date.getTime();
|
|
31
|
+
}
|
|
32
|
+
getYear(date) {
|
|
33
|
+
return date.getFullYear();
|
|
34
|
+
}
|
|
35
|
+
getMonth(date) {
|
|
36
|
+
return date.getMonth();
|
|
37
|
+
}
|
|
38
|
+
getDate(date) {
|
|
39
|
+
return date.getDate();
|
|
40
|
+
}
|
|
41
|
+
getDay(date) {
|
|
42
|
+
return date.getDay();
|
|
43
|
+
}
|
|
44
|
+
format(date, format) {
|
|
45
|
+
if (!date)
|
|
46
|
+
return '';
|
|
47
|
+
const d = new Date(date);
|
|
48
|
+
if (isNaN(d.getTime()))
|
|
49
|
+
return '';
|
|
50
|
+
const formatters = {
|
|
51
|
+
YYYY: () => d.getFullYear().toString(),
|
|
52
|
+
yyyy: () => d.getFullYear().toString(),
|
|
53
|
+
yy: () => d.getFullYear().toString().slice(-2),
|
|
54
|
+
MMM: () => d.toLocaleString('default', { month: 'short' }),
|
|
55
|
+
MM: () => this.pad(d.getMonth() + 1),
|
|
56
|
+
M: () => (d.getMonth() + 1).toString(),
|
|
57
|
+
DD: () => this.pad(d.getDate()),
|
|
58
|
+
dd: () => this.pad(d.getDate()),
|
|
59
|
+
d: () => d.getDate().toString(),
|
|
60
|
+
HH: () => this.pad(d.getHours()),
|
|
61
|
+
H: () => d.getHours().toString(),
|
|
62
|
+
hh: () => this.pad(d.getHours() % 12 || 12),
|
|
63
|
+
h: () => (d.getHours() % 12 || 12).toString(),
|
|
64
|
+
mm: () => this.pad(d.getMinutes()),
|
|
65
|
+
ss: () => this.pad(d.getSeconds()),
|
|
66
|
+
SSS: () => this.pad(d.getMilliseconds(), 3),
|
|
67
|
+
ISO: () => d.toISOString(),
|
|
68
|
+
a: () => (d.getHours() < 12 ? 'AM' : 'PM'),
|
|
69
|
+
};
|
|
70
|
+
const regex = /\b(?:yyyy|YYYY|yy|MMM|MM|M|DD|dd|d|HH|H|hh|h|mm|ss|SSS|a|ISO)\b/g;
|
|
71
|
+
return format.replace(regex, match => formatters[match]?.() ?? match);
|
|
72
|
+
}
|
|
73
|
+
pad(value, length = 2) {
|
|
74
|
+
return value.toString().padStart(length, '0');
|
|
75
|
+
}
|
|
76
|
+
// We have to parse the date string like '2024-10-01T00:00:00.000Z'
|
|
77
|
+
parse(value, _) {
|
|
78
|
+
if (value instanceof Date)
|
|
79
|
+
return new Date(value.setHours(0, 0, 0, 0));
|
|
80
|
+
if (typeof value !== 'string')
|
|
81
|
+
return new Date(NaN);
|
|
82
|
+
if (value.includes('T')) {
|
|
83
|
+
return new Date(value);
|
|
84
|
+
}
|
|
85
|
+
const parts = value.split(/\D+/).map(Number);
|
|
86
|
+
if (parts.length !== 3)
|
|
87
|
+
return new Date(NaN);
|
|
88
|
+
const [a, b, c] = parts;
|
|
89
|
+
return a > 31 ? new Date(a, b - 1, c) : new Date(c, b - 1, a);
|
|
90
|
+
}
|
|
91
|
+
set(date, value, unit) {
|
|
92
|
+
const newDate = new Date(date);
|
|
93
|
+
if (unit === 'year')
|
|
94
|
+
newDate.setFullYear(value);
|
|
95
|
+
else if (unit === 'month')
|
|
96
|
+
newDate.setMonth(value);
|
|
97
|
+
else if (unit === 'date')
|
|
98
|
+
newDate.setDate(value);
|
|
99
|
+
else if (unit === 'hour')
|
|
100
|
+
newDate.setHours(value);
|
|
101
|
+
else if (unit === 'minute')
|
|
102
|
+
newDate.setMinutes(value);
|
|
103
|
+
else if (unit === 'second')
|
|
104
|
+
newDate.setSeconds(value);
|
|
105
|
+
else if (unit === 'millisecond')
|
|
106
|
+
newDate.setMilliseconds(value);
|
|
107
|
+
return newDate;
|
|
108
|
+
}
|
|
109
|
+
longMonthNames(date) {
|
|
110
|
+
return date.toLocaleString('default', { month: 'long' });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const DEFAULT_FIELD_FORMAT = 'ISO';
|
|
115
|
+
const DEFAULT_FORMAT = 'M/d/yyyy';
|
|
116
|
+
const DEFAULT_TIME_FORMAT = 'M/d/yyyy, HH:mm a';
|
|
117
|
+
const DatePicker = new InjectionToken('DatePicker');
|
|
118
|
+
class NgbDatepickerTrigger {
|
|
119
|
+
constructor() {
|
|
120
|
+
this.el = inject(ElementRef);
|
|
121
|
+
this.inputS = inject(InputBase);
|
|
122
|
+
this.injector = inject(Injector);
|
|
123
|
+
this.adapter = injectNgbDateAdapter();
|
|
124
|
+
this.popover = ngbPopoverPortal();
|
|
125
|
+
this.datepicker = inject(DatePicker, { optional: true }) ?? (NgbDatePicker);
|
|
126
|
+
// readonly datepicker = input<NgbDatePicker<D>>();
|
|
127
|
+
this.noOfCalendars = input(1, { transform: (v) => Math.max(1, v) });
|
|
128
|
+
this.range = input(false, { transform: booleanAttribute });
|
|
129
|
+
this.time = input(false, { transform: booleanAttribute });
|
|
130
|
+
this.format = input('');
|
|
131
|
+
this.fieldFormat = input(DEFAULT_FIELD_FORMAT);
|
|
132
|
+
this.displayFormat = computed(() => {
|
|
133
|
+
return this.format() || (this.time() ? DEFAULT_TIME_FORMAT : DEFAULT_FORMAT);
|
|
134
|
+
});
|
|
135
|
+
this.dateFilter = input(() => true);
|
|
136
|
+
this.pickerType = input('date');
|
|
137
|
+
this.pickerTemplate = input(null);
|
|
138
|
+
effect(() => {
|
|
139
|
+
const value = this.getInputValue();
|
|
140
|
+
this.updateField(value);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
getInputValue() {
|
|
144
|
+
const v = this.inputS.value();
|
|
145
|
+
let value = [];
|
|
146
|
+
if (v) {
|
|
147
|
+
value = this.range() ? v : [v];
|
|
148
|
+
}
|
|
149
|
+
return value.map(x => this.adapter.parse(x));
|
|
150
|
+
}
|
|
151
|
+
open() {
|
|
152
|
+
const data = {
|
|
153
|
+
value: this.getInputValue(),
|
|
154
|
+
pickerType: this.pickerType(),
|
|
155
|
+
noOfCalendars: this.noOfCalendars(),
|
|
156
|
+
range: this.range(),
|
|
157
|
+
format: this.displayFormat(),
|
|
158
|
+
fieldFormat: this.fieldFormat(),
|
|
159
|
+
target: this.el.nativeElement,
|
|
160
|
+
template: this.pickerTemplate(),
|
|
161
|
+
dateFilter: this.dateFilter(),
|
|
162
|
+
time: this.time(),
|
|
163
|
+
};
|
|
164
|
+
const { diaRef } = this.popover.open(this.datepicker, {
|
|
165
|
+
target: this.el.nativeElement,
|
|
166
|
+
position: 'bl',
|
|
167
|
+
data,
|
|
168
|
+
width: 'none',
|
|
169
|
+
});
|
|
170
|
+
this.close = diaRef.close;
|
|
171
|
+
}
|
|
172
|
+
updateInput(dates) {
|
|
173
|
+
const filtered = dates.filter(x => x);
|
|
174
|
+
const formatDate = dates.map(x => (x ? this.adapter.format(x, this.fieldFormat()) : x));
|
|
175
|
+
if (this.range()) {
|
|
176
|
+
if (filtered.length === 1) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
this.inputS?.setValue(formatDate);
|
|
180
|
+
}
|
|
181
|
+
else if (filtered.length) {
|
|
182
|
+
this.inputS?.setValue(formatDate[0]);
|
|
183
|
+
}
|
|
184
|
+
this.updateField(filtered);
|
|
185
|
+
}
|
|
186
|
+
updateField(filtered) {
|
|
187
|
+
// console.log(this.fieldFormat());
|
|
188
|
+
const d = filtered
|
|
189
|
+
.map(x => this.adapter.format(x, this.displayFormat()))
|
|
190
|
+
.filter(x => x)
|
|
191
|
+
.join(' - ');
|
|
192
|
+
afterNextRender(() => (this.el.nativeElement.value = d), { injector: this.injector });
|
|
193
|
+
}
|
|
194
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbDatepickerTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
195
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: NgbDatepickerTrigger, isStandalone: true, selector: "[ngbDatepickerTrigger]", inputs: { noOfCalendars: { classPropertyName: "noOfCalendars", publicName: "noOfCalendars", isSignal: true, isRequired: false, transformFunction: null }, range: { classPropertyName: "range", publicName: "range", isSignal: true, isRequired: false, transformFunction: null }, time: { classPropertyName: "time", publicName: "time", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, fieldFormat: { classPropertyName: "fieldFormat", publicName: "fieldFormat", isSignal: true, isRequired: false, transformFunction: null }, dateFilter: { classPropertyName: "dateFilter", publicName: "dateFilter", isSignal: true, isRequired: false, transformFunction: null }, pickerType: { classPropertyName: "pickerType", publicName: "pickerType", isSignal: true, isRequired: false, transformFunction: null }, pickerTemplate: { classPropertyName: "pickerTemplate", publicName: "pickerTemplate", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "readonly": "true" }, listeners: { "click": "open()" }, classAttribute: "cursor-pointer hover:bg-muted-background" }, exportAs: ["ngbDatepickerTrigger"], hostDirectives: [{ directive: i1.InputBase }], ngImport: i0 }); }
|
|
196
|
+
}
|
|
197
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbDatepickerTrigger, decorators: [{
|
|
198
|
+
type: Directive,
|
|
199
|
+
args: [{
|
|
200
|
+
selector: '[ngbDatepickerTrigger]',
|
|
201
|
+
exportAs: 'ngbDatepickerTrigger',
|
|
202
|
+
hostDirectives: [InputBase],
|
|
203
|
+
host: {
|
|
204
|
+
class: 'cursor-pointer hover:bg-muted-background',
|
|
205
|
+
'(click)': 'open()',
|
|
206
|
+
readonly: 'true',
|
|
207
|
+
},
|
|
208
|
+
}]
|
|
209
|
+
}], ctorParameters: () => [] });
|
|
210
|
+
function registerDatePicker(datePicker) {
|
|
211
|
+
return {
|
|
212
|
+
provide: DatePicker,
|
|
213
|
+
useValue: datePicker,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
class DatepickerGroup {
|
|
218
|
+
constructor() {
|
|
219
|
+
this.picker = inject((NgbDatePicker));
|
|
220
|
+
this.allyGroup = inject(AccessibleGroup);
|
|
221
|
+
this.allyGroup._ayId.set(this.picker.ayId);
|
|
222
|
+
this.allyGroup._columns.set(7);
|
|
223
|
+
this.allyGroup._initialFocus.set(false);
|
|
224
|
+
}
|
|
225
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DatepickerGroup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
226
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: DatepickerGroup, isStandalone: true, selector: "[ngbDatepickerGroup]", exportAs: ["ngbDatepickerGroup"], hostDirectives: [{ directive: i1$1.AccessibleGroup }], ngImport: i0 }); }
|
|
227
|
+
}
|
|
228
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: DatepickerGroup, decorators: [{
|
|
229
|
+
type: Directive,
|
|
230
|
+
args: [{
|
|
231
|
+
selector: '[ngbDatepickerGroup]',
|
|
232
|
+
exportAs: 'ngbDatepickerGroup',
|
|
233
|
+
hostDirectives: [AccessibleGroup],
|
|
234
|
+
}]
|
|
235
|
+
}], ctorParameters: () => [] });
|
|
236
|
+
class NgbDatePicker {
|
|
237
|
+
constructor() {
|
|
238
|
+
this.datepickerTrigger = inject(NgbDatepickerTrigger, {
|
|
239
|
+
optional: true,
|
|
240
|
+
});
|
|
241
|
+
this.dialogRef = inject(DialogRef, { optional: true });
|
|
242
|
+
this.adapter = injectNgbDateAdapter();
|
|
243
|
+
this.dateFilter = input(this.data?.dateFilter || (() => true));
|
|
244
|
+
this.pickerType = input(this.data?.pickerType || 'date');
|
|
245
|
+
this.allyGroup = viewChild(AccessibleGroup);
|
|
246
|
+
this.noOfCalendar = model(this.data?.noOfCalendars || 1);
|
|
247
|
+
this.range = model(this.data?.range || false);
|
|
248
|
+
this.time = signal(this.data?.time || false);
|
|
249
|
+
this.format = signal(this.data?.format || `MM-dd-yyyy${this.data?.time ? ' HH:mm a' : ''}`);
|
|
250
|
+
this.template = signal(this.data?.template || null);
|
|
251
|
+
this.showType = signal(this.pickerType());
|
|
252
|
+
this.selectedDates = signal([null, null]);
|
|
253
|
+
this.times = signal([null, null]);
|
|
254
|
+
this.startDate = computed(() => {
|
|
255
|
+
const dates = this.selectedDates();
|
|
256
|
+
return Array.isArray(dates) && dates[0] ? dates[0] : this.adapter.now();
|
|
257
|
+
});
|
|
258
|
+
this.startMonth = signal(this.adapter.getMonth(this.startDate()));
|
|
259
|
+
this.startYear = signal(this.adapter.getYear(this.startDate()));
|
|
260
|
+
this.hoveredDate = signal(null);
|
|
261
|
+
this.hoveredCount = computed(() => {
|
|
262
|
+
const date = this.hoveredDate();
|
|
263
|
+
return date ? this.adapter.getTime(date) : 0;
|
|
264
|
+
});
|
|
265
|
+
this.startDateCount = computed(() => {
|
|
266
|
+
const date = this.selectedDates()[0];
|
|
267
|
+
return date ? this.adapter.getTime(date) : 0;
|
|
268
|
+
});
|
|
269
|
+
this.dates = computed(() => {
|
|
270
|
+
const dates = this.selectedDates();
|
|
271
|
+
const v = { year: [], month: [], day: [] };
|
|
272
|
+
for (const x of dates) {
|
|
273
|
+
if (x) {
|
|
274
|
+
const year = this.adapter.getYear(x);
|
|
275
|
+
const month = this.adapter.getMonth(x);
|
|
276
|
+
const day = this.adapter.getDate(x);
|
|
277
|
+
v.year.push(year);
|
|
278
|
+
v.month.push(`${month}-${year}`);
|
|
279
|
+
v.day.push(`${day}-${month}-${year}`);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return v;
|
|
283
|
+
});
|
|
284
|
+
this.ayId = uniqueId();
|
|
285
|
+
this.init();
|
|
286
|
+
// this.allyGroup.focusChanged.subscribe(item => this.focusChanged(item));
|
|
287
|
+
}
|
|
288
|
+
init() {
|
|
289
|
+
const v = this.data?.value?.filter(x => x).map(x => this.adapter.parse(x));
|
|
290
|
+
if (Array.isArray(v) && v.length) {
|
|
291
|
+
let date;
|
|
292
|
+
let dates;
|
|
293
|
+
if (v.length === 2) {
|
|
294
|
+
dates = v;
|
|
295
|
+
this.hoveredDate.set(v[1]);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
dates = [v[0], null];
|
|
299
|
+
}
|
|
300
|
+
date = dates[0];
|
|
301
|
+
this.selectedDates.set(dates);
|
|
302
|
+
this.startYear.set(this.adapter.getYear(date));
|
|
303
|
+
this.startMonth.set(this.adapter.getMonth(date));
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
get data() {
|
|
307
|
+
return this.dialogRef?.data;
|
|
308
|
+
}
|
|
309
|
+
// focusChanged(_: { current: AccessibleItem; previous?: AccessibleItem }) {
|
|
310
|
+
// const cData = item.current.data();
|
|
311
|
+
// const pData = item.previous?.data();
|
|
312
|
+
// console.log('focusChanged', cData, pData);
|
|
313
|
+
// console.log(data);
|
|
314
|
+
// if (cData.day) {
|
|
315
|
+
// let add = 0;
|
|
316
|
+
// if (pData) {
|
|
317
|
+
// const v = (cData.day - pData.day) / 7;
|
|
318
|
+
// console.log(Math.abs(1));
|
|
319
|
+
// if (1 === Math.abs(v)) {
|
|
320
|
+
// add = 0;
|
|
321
|
+
// } else if (v > 0) {
|
|
322
|
+
// add = -1;
|
|
323
|
+
// } else {
|
|
324
|
+
// add = 1;
|
|
325
|
+
// }
|
|
326
|
+
// }
|
|
327
|
+
// console.log(add);
|
|
328
|
+
// this.startMonth.set(cData.mon + add);
|
|
329
|
+
// }
|
|
330
|
+
// }
|
|
331
|
+
updateHoveredDate(date) {
|
|
332
|
+
if (this.range()) {
|
|
333
|
+
const single = this.selectedDates().filter(x => x).length === 1;
|
|
334
|
+
this.hoveredDate.set(single ? date : null);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
selectDate(date, index) {
|
|
338
|
+
let dates = this.selectedDates();
|
|
339
|
+
if (index != undefined) {
|
|
340
|
+
dates[index] = date;
|
|
341
|
+
}
|
|
342
|
+
else if (this.range()) {
|
|
343
|
+
if ((dates[0] && dates[1]) || !dates[0] || this.adapter.compare(dates[0], date) > 0) {
|
|
344
|
+
dates = [date, null];
|
|
345
|
+
this.hoveredDate.set(null);
|
|
346
|
+
}
|
|
347
|
+
else if (dates[0]) {
|
|
348
|
+
dates[1] = date;
|
|
349
|
+
this.hoveredDate.set(date);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
dates = [date, null];
|
|
354
|
+
}
|
|
355
|
+
this.selectedDates.set([...dates]);
|
|
356
|
+
this.datepickerTrigger?.updateInput(dates);
|
|
357
|
+
}
|
|
358
|
+
selectYear(year) {
|
|
359
|
+
this.startYear.set(year);
|
|
360
|
+
if (this.pickerType() !== 'year') {
|
|
361
|
+
this.showType.set('month');
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
this.selectDate(this.adapter.create(year, this.startMonth()));
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
selectMonth(month, year) {
|
|
368
|
+
this.startMonth.set(month);
|
|
369
|
+
this.startYear.set(year);
|
|
370
|
+
if (this.pickerType() === 'date') {
|
|
371
|
+
this.showType.set('date');
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
this.selectDate(this.adapter.create(year, month));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
toggleView() {
|
|
378
|
+
let type = this.showType();
|
|
379
|
+
if (type === 'date') {
|
|
380
|
+
type = 'month';
|
|
381
|
+
}
|
|
382
|
+
else if (type === 'month' || this.pickerType() === 'year') {
|
|
383
|
+
type = 'year';
|
|
384
|
+
}
|
|
385
|
+
else if (this.pickerType() === 'date') {
|
|
386
|
+
type = 'date';
|
|
387
|
+
}
|
|
388
|
+
else {
|
|
389
|
+
type = 'month';
|
|
390
|
+
}
|
|
391
|
+
this.showType.set(type);
|
|
392
|
+
}
|
|
393
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbDatePicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
394
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.0", type: NgbDatePicker, isStandalone: true, selector: "[ngbDatepicker]", inputs: { dateFilter: { classPropertyName: "dateFilter", publicName: "dateFilter", isSignal: true, isRequired: false, transformFunction: null }, pickerType: { classPropertyName: "pickerType", publicName: "pickerType", isSignal: true, isRequired: false, transformFunction: null }, noOfCalendar: { classPropertyName: "noOfCalendar", publicName: "noOfCalendar", isSignal: true, isRequired: false, transformFunction: null }, range: { classPropertyName: "range", publicName: "range", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { noOfCalendar: "noOfCalendarChange", range: "rangeChange" }, host: { classAttribute: "inline-block" }, viewQueries: [{ propertyName: "allyGroup", first: true, predicate: AccessibleGroup, descendants: true, isSignal: true }], ngImport: i0, template: `
|
|
395
|
+
<div class="flex" ngbDatepickerGroup>
|
|
396
|
+
@for (no of noOfCalendar() | range; track no) {
|
|
397
|
+
<ngb-calendar [first]="$first" [last]="$last" [index]="$index" />
|
|
398
|
+
}
|
|
399
|
+
</div>
|
|
400
|
+
@if (template()) {
|
|
401
|
+
<div class="px-b2 pb-b2">
|
|
402
|
+
<ng-container *ngTemplateOutlet="template()" />
|
|
403
|
+
</div>
|
|
404
|
+
}
|
|
405
|
+
`, isInline: true, dependencies: [{ kind: "component", type: NgbCalendar, selector: "ngb-calendar", inputs: ["first", "last", "index"] }, { kind: "pipe", type: RangePipe, name: "range" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: DatepickerGroup, selector: "[ngbDatepickerGroup]", exportAs: ["ngbDatepickerGroup"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
406
|
+
}
|
|
407
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbDatePicker, decorators: [{
|
|
408
|
+
type: Component,
|
|
409
|
+
args: [{
|
|
410
|
+
selector: '[ngbDatepicker]',
|
|
411
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
412
|
+
imports: [NgbCalendar, RangePipe, NgTemplateOutlet, AccessibleGroup, DatepickerGroup],
|
|
413
|
+
template: `
|
|
414
|
+
<div class="flex" ngbDatepickerGroup>
|
|
415
|
+
@for (no of noOfCalendar() | range; track no) {
|
|
416
|
+
<ngb-calendar [first]="$first" [last]="$last" [index]="$index" />
|
|
417
|
+
}
|
|
418
|
+
</div>
|
|
419
|
+
@if (template()) {
|
|
420
|
+
<div class="px-b2 pb-b2">
|
|
421
|
+
<ng-container *ngTemplateOutlet="template()" />
|
|
422
|
+
</div>
|
|
423
|
+
}
|
|
424
|
+
`,
|
|
425
|
+
host: {
|
|
426
|
+
class: 'inline-block',
|
|
427
|
+
},
|
|
428
|
+
}]
|
|
429
|
+
}], ctorParameters: () => [] });
|
|
430
|
+
function provideDatePicker(picker) {
|
|
431
|
+
return {
|
|
432
|
+
provide: NgbDatePicker,
|
|
433
|
+
useExisting: picker,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
class NgbTimeInput {
|
|
438
|
+
constructor() {
|
|
439
|
+
this.numberOnly = inject(NumberOnly);
|
|
440
|
+
this.timePicker = inject(NgbTimePicker);
|
|
441
|
+
this.ngbTimeInput = input.required();
|
|
442
|
+
this.numberOnly._min.set(0);
|
|
443
|
+
this.numberOnly._len.set(2);
|
|
444
|
+
effect(() => {
|
|
445
|
+
const type = this.ngbTimeInput();
|
|
446
|
+
if (type === 'hours') {
|
|
447
|
+
this.numberOnly._max.set(this.timePicker.is24() ? 23 : 11);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
this.numberOnly._max.set(59);
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbTimeInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
455
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: NgbTimeInput, isStandalone: true, selector: "[ngbTimeInput]", inputs: { ngbTimeInput: { classPropertyName: "ngbTimeInput", publicName: "ngbTimeInput", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "type": "tel" } }, hostDirectives: [{ directive: i1$2.NumberOnly, inputs: ["value", "value"], outputs: ["valueChange", "valueChange"] }], ngImport: i0 }); }
|
|
456
|
+
}
|
|
457
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbTimeInput, decorators: [{
|
|
458
|
+
type: Directive,
|
|
459
|
+
args: [{
|
|
460
|
+
selector: '[ngbTimeInput]',
|
|
461
|
+
hostDirectives: [{ directive: NumberOnly, inputs: ['value'], outputs: ['valueChange'] }],
|
|
462
|
+
host: {
|
|
463
|
+
type: 'tel',
|
|
464
|
+
},
|
|
465
|
+
}]
|
|
466
|
+
}], ctorParameters: () => [] });
|
|
467
|
+
class NgbTimePicker {
|
|
468
|
+
constructor() {
|
|
469
|
+
this.is24 = input(false);
|
|
470
|
+
this.value = input();
|
|
471
|
+
this.valueChange = output();
|
|
472
|
+
this.time = computed(() => {
|
|
473
|
+
return (`${padString(this.hours())}:${padString(this.minutes())}:${padString(this.seconds())}` +
|
|
474
|
+
(!this.is24() ? ` ${this.am() ? 'AM' : 'PM'}` : ''));
|
|
475
|
+
});
|
|
476
|
+
this.hours = signal('00');
|
|
477
|
+
this.minutes = signal('00');
|
|
478
|
+
this.seconds = signal('00');
|
|
479
|
+
this.am = signal(true);
|
|
480
|
+
this.onChange = (_) => { };
|
|
481
|
+
this.onTouched = () => { };
|
|
482
|
+
effect(() => {
|
|
483
|
+
const value = this.value();
|
|
484
|
+
untracked(() => {
|
|
485
|
+
this.parseValue(value);
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
parseValue(value) {
|
|
490
|
+
if (value) {
|
|
491
|
+
const [time, period] = value.split(' ');
|
|
492
|
+
const [hours, minutes, seconds] = time.split(':');
|
|
493
|
+
const am = period === 'AM';
|
|
494
|
+
this.hours.set(padString(hours));
|
|
495
|
+
this.minutes.set(padString(minutes));
|
|
496
|
+
this.seconds.set(padString(seconds));
|
|
497
|
+
this.am.set(am);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
changeAm(active) {
|
|
501
|
+
this.am.set(active);
|
|
502
|
+
this.updateValue();
|
|
503
|
+
}
|
|
504
|
+
updateValue() {
|
|
505
|
+
this.notify(this.time());
|
|
506
|
+
}
|
|
507
|
+
notify(time) {
|
|
508
|
+
this.valueChange.emit(time);
|
|
509
|
+
this.onChange(time);
|
|
510
|
+
this.onTouched();
|
|
511
|
+
}
|
|
512
|
+
writeValue(value) {
|
|
513
|
+
if (value) {
|
|
514
|
+
this.parseValue(value);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
registerOnChange(fn) {
|
|
518
|
+
this.onChange = fn;
|
|
519
|
+
}
|
|
520
|
+
registerOnTouched(fn) {
|
|
521
|
+
this.onTouched = fn;
|
|
522
|
+
}
|
|
523
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbTimePicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
524
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.0", type: NgbTimePicker, isStandalone: true, selector: "[ngbTime]", inputs: { is24: { classPropertyName: "is24", publicName: "is24", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "inline-flex gap-b items-center justify-center" }, providers: [_provide(NgbTimePicker)], ngImport: i0, template: `
|
|
525
|
+
<input ngbTimeInput="hours" [(value)]="hours" (valueChange)="updateValue()" />
|
|
526
|
+
<span>:</span>
|
|
527
|
+
<input ngbTimeInput="minutes" [(value)]="minutes" (valueChange)="updateValue()" />
|
|
528
|
+
<span>:</span>
|
|
529
|
+
<input ngbTimeInput="seconds" [(value)]="seconds" (valueChange)="updateValue()" />
|
|
530
|
+
@if (!is24()) {
|
|
531
|
+
<div class="ml-b flex gap-b2">
|
|
532
|
+
<button type="button" class="small" (click)="changeAm(true)">AM</button>
|
|
533
|
+
<button type="button" class="small" (click)="changeAm(false)">PM</button>
|
|
534
|
+
</div>
|
|
535
|
+
}
|
|
536
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgbTimeInput, selector: "[ngbTimeInput]", inputs: ["ngbTimeInput"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
537
|
+
}
|
|
538
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbTimePicker, decorators: [{
|
|
539
|
+
type: Component,
|
|
540
|
+
args: [{
|
|
541
|
+
selector: '[ngbTime]',
|
|
542
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
543
|
+
providers: [_provide(NgbTimePicker)],
|
|
544
|
+
imports: [NumberOnly, NgbTimeInput],
|
|
545
|
+
template: `
|
|
546
|
+
<input ngbTimeInput="hours" [(value)]="hours" (valueChange)="updateValue()" />
|
|
547
|
+
<span>:</span>
|
|
548
|
+
<input ngbTimeInput="minutes" [(value)]="minutes" (valueChange)="updateValue()" />
|
|
549
|
+
<span>:</span>
|
|
550
|
+
<input ngbTimeInput="seconds" [(value)]="seconds" (valueChange)="updateValue()" />
|
|
551
|
+
@if (!is24()) {
|
|
552
|
+
<div class="ml-b flex gap-b2">
|
|
553
|
+
<button type="button" class="small" (click)="changeAm(true)">AM</button>
|
|
554
|
+
<button type="button" class="small" (click)="changeAm(false)">PM</button>
|
|
555
|
+
</div>
|
|
556
|
+
}
|
|
557
|
+
`,
|
|
558
|
+
host: {
|
|
559
|
+
class: 'inline-flex gap-b items-center justify-center',
|
|
560
|
+
},
|
|
561
|
+
}]
|
|
562
|
+
}], ctorParameters: () => [] });
|
|
563
|
+
function _provide(picker) {
|
|
564
|
+
return [provideValueAccessor(picker)];
|
|
565
|
+
}
|
|
566
|
+
function provideTimePicker(picker) {
|
|
567
|
+
return [_provide(picker), { provide: NgbTimePicker, useExisting: picker }];
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
class CalendarBtn {
|
|
571
|
+
constructor() {
|
|
572
|
+
this.cal = inject(NgbCalendar);
|
|
573
|
+
this.ngbCalendarBtn = input.required();
|
|
574
|
+
this.disabled = computed(() => {
|
|
575
|
+
return this.ngbCalendarBtn() === 'left' ? this.cal.leftBtn() : this.cal.rightBtn();
|
|
576
|
+
});
|
|
577
|
+
this.visible = computed(() => {
|
|
578
|
+
return this.ngbCalendarBtn() === 'left' ? this.cal.first() : this.cal.last();
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarBtn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
582
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: CalendarBtn, isStandalone: true, selector: "[ngbCalendarBtn]", inputs: { ngbCalendarBtn: { classPropertyName: "ngbCalendarBtn", publicName: "ngbCalendarBtn", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "click": "cal.navigate(ngbCalendarBtn() === \"left\" ? -1 : 1)" }, properties: { "class": "!visible() ? \"invisible\" : \"\"", "disabled": "disabled()", "tabIndex": "disabled() ? -1 : 0" } }, ngImport: i0 }); }
|
|
583
|
+
}
|
|
584
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarBtn, decorators: [{
|
|
585
|
+
type: Directive,
|
|
586
|
+
args: [{
|
|
587
|
+
selector: '[ngbCalendarBtn]',
|
|
588
|
+
host: {
|
|
589
|
+
type: 'button',
|
|
590
|
+
'[class]': '!visible() ? "invisible" : ""',
|
|
591
|
+
'(click)': 'cal.navigate(ngbCalendarBtn() === "left" ? -1 : 1)',
|
|
592
|
+
'[disabled]': 'disabled()',
|
|
593
|
+
'[tabIndex]': 'disabled() ? -1 : 0',
|
|
594
|
+
},
|
|
595
|
+
}]
|
|
596
|
+
}] });
|
|
597
|
+
class CalendarTitle {
|
|
598
|
+
constructor() {
|
|
599
|
+
this.cal = inject(NgbCalendar);
|
|
600
|
+
}
|
|
601
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarTitle, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
602
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: CalendarTitle, isStandalone: true, selector: "[ngbCalendarTitle]", host: { attributes: { "type": "button" }, listeners: { "click": "cal.toggleView()" }, properties: { "tabIndex": "0" } }, ngImport: i0 }); }
|
|
603
|
+
}
|
|
604
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarTitle, decorators: [{
|
|
605
|
+
type: Directive,
|
|
606
|
+
args: [{
|
|
607
|
+
selector: '[ngbCalendarTitle]',
|
|
608
|
+
host: {
|
|
609
|
+
type: 'button',
|
|
610
|
+
'(click)': 'cal.toggleView()',
|
|
611
|
+
'[tabIndex]': '0',
|
|
612
|
+
},
|
|
613
|
+
}]
|
|
614
|
+
}] });
|
|
615
|
+
class CalendarYearBtn {
|
|
616
|
+
constructor() {
|
|
617
|
+
this.cal = inject(NgbCalendar);
|
|
618
|
+
this.ally = inject(AccessibleItem);
|
|
619
|
+
this.ngbCalYearBtn = input.required();
|
|
620
|
+
this.active = computed(() => this.ngbCalYearBtn().year === this.cal.cStartYear());
|
|
621
|
+
this.selected = computed(() => this.cal.todayDay() && this.active());
|
|
622
|
+
this.ally._ayId.set(this.cal.datePicker.ayId);
|
|
623
|
+
effect(() => {
|
|
624
|
+
this.ally._data.set(this.ngbCalYearBtn());
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarYearBtn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
628
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: CalendarYearBtn, isStandalone: true, selector: "[ngbCalYearBtn]", inputs: { ngbCalYearBtn: { classPropertyName: "ngbCalYearBtn", publicName: "ngbCalYearBtn", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "click": "!ngbCalYearBtn().disabled && cal.selectYear(ngbCalYearBtn().year)" } }, exportAs: ["ngbCalYearBtn"], hostDirectives: [{ directive: i1$1.AccessibleItem }], ngImport: i0 }); }
|
|
629
|
+
}
|
|
630
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarYearBtn, decorators: [{
|
|
631
|
+
type: Directive,
|
|
632
|
+
args: [{
|
|
633
|
+
selector: '[ngbCalYearBtn]',
|
|
634
|
+
exportAs: 'ngbCalYearBtn',
|
|
635
|
+
hostDirectives: [AccessibleItem],
|
|
636
|
+
host: {
|
|
637
|
+
type: 'button',
|
|
638
|
+
'(click)': '!ngbCalYearBtn().disabled && cal.selectYear(ngbCalYearBtn().year)',
|
|
639
|
+
},
|
|
640
|
+
}]
|
|
641
|
+
}], ctorParameters: () => [] });
|
|
642
|
+
class CalendarMonthBtn {
|
|
643
|
+
constructor() {
|
|
644
|
+
this.cal = inject(NgbCalendar);
|
|
645
|
+
this.ally = inject(AccessibleItem);
|
|
646
|
+
this.ngbCalMonthBtn = input.required();
|
|
647
|
+
this.active = computed(() => this.cal.datePicker
|
|
648
|
+
.dates()
|
|
649
|
+
.month.includes(this.ngbCalMonthBtn().value + '-' + this.cal.cStartYear()));
|
|
650
|
+
this.selected = computed(() => this.cal.todayDay() && this.cal.cStartMonth() === this.ngbCalMonthBtn().value);
|
|
651
|
+
this.ally._ayId.set(this.cal.datePicker.ayId);
|
|
652
|
+
effect(() => {
|
|
653
|
+
this.ally._data.set(this.ngbCalMonthBtn());
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarMonthBtn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
657
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: CalendarMonthBtn, isStandalone: true, selector: "[ngbCalMonthBtn]", inputs: { ngbCalMonthBtn: { classPropertyName: "ngbCalMonthBtn", publicName: "ngbCalMonthBtn", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "click": "!ngbCalMonthBtn().disabled && cal.selectMonth(ngbCalMonthBtn())" } }, exportAs: ["ngbCalMonthBtn"], hostDirectives: [{ directive: i1$1.AccessibleItem }], ngImport: i0 }); }
|
|
658
|
+
}
|
|
659
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarMonthBtn, decorators: [{
|
|
660
|
+
type: Directive,
|
|
661
|
+
args: [{
|
|
662
|
+
selector: '[ngbCalMonthBtn]',
|
|
663
|
+
exportAs: 'ngbCalMonthBtn',
|
|
664
|
+
hostDirectives: [AccessibleItem],
|
|
665
|
+
host: {
|
|
666
|
+
type: 'button',
|
|
667
|
+
'(click)': '!ngbCalMonthBtn().disabled && cal.selectMonth(ngbCalMonthBtn())',
|
|
668
|
+
},
|
|
669
|
+
}]
|
|
670
|
+
}], ctorParameters: () => [] });
|
|
671
|
+
class CalendarDayBtn {
|
|
672
|
+
constructor() {
|
|
673
|
+
this.cal = inject(NgbCalendar);
|
|
674
|
+
this.ally = inject(AccessibleItem);
|
|
675
|
+
this.ngbCalDayBtn = input.required();
|
|
676
|
+
this.active = computed(() => this.cal.datePicker
|
|
677
|
+
.dates()
|
|
678
|
+
.day.includes(this.ngbCalDayBtn().day + '-' + this.ngbCalDayBtn().mon + '-' + this.cal.cStartYear()));
|
|
679
|
+
this.dummy = computed(() => !this.ngbCalDayBtn().current || this.ngbCalDayBtn().disabled);
|
|
680
|
+
this.selected = computed(() => {
|
|
681
|
+
const day = this.ngbCalDayBtn();
|
|
682
|
+
return ((day.day === this.cal.todayDay() && day.current) ||
|
|
683
|
+
(day.count <= this.cal.datePicker.hoveredCount() &&
|
|
684
|
+
this.cal.datePicker.startDateCount() &&
|
|
685
|
+
day.count >= this.cal.datePicker.startDateCount()));
|
|
686
|
+
});
|
|
687
|
+
this.ally._ayId.set(this.cal.datePicker.ayId);
|
|
688
|
+
effect(() => {
|
|
689
|
+
this.ally._data.set(this.ngbCalDayBtn());
|
|
690
|
+
this.ally._id.set(this.ngbCalDayBtn().day + '-' + this.ngbCalDayBtn().mon);
|
|
691
|
+
this.ally._skip.set(this.ngbCalDayBtn().disabled);
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarDayBtn, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
695
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: CalendarDayBtn, isStandalone: true, selector: "[ngbCalDayBtn]", inputs: { ngbCalDayBtn: { classPropertyName: "ngbCalDayBtn", publicName: "ngbCalDayBtn", isSignal: true, isRequired: true, transformFunction: null } }, host: { attributes: { "type": "button" }, listeners: { "click": "!ngbCalDayBtn().disabled && cal.selectDate(ngbCalDayBtn().day, ngbCalDayBtn().mon)" } }, exportAs: ["ngbCalDayBtn"], hostDirectives: [{ directive: i1$1.AccessibleItem }], ngImport: i0 }); }
|
|
696
|
+
}
|
|
697
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: CalendarDayBtn, decorators: [{
|
|
698
|
+
type: Directive,
|
|
699
|
+
args: [{
|
|
700
|
+
selector: '[ngbCalDayBtn]',
|
|
701
|
+
exportAs: 'ngbCalDayBtn',
|
|
702
|
+
hostDirectives: [AccessibleItem],
|
|
703
|
+
host: {
|
|
704
|
+
type: 'button',
|
|
705
|
+
'(click)': '!ngbCalDayBtn().disabled && cal.selectDate(ngbCalDayBtn().day, ngbCalDayBtn().mon)',
|
|
706
|
+
},
|
|
707
|
+
}]
|
|
708
|
+
}], ctorParameters: () => [] });
|
|
709
|
+
class NgbCalendar {
|
|
710
|
+
constructor() {
|
|
711
|
+
this.dir = inject(Directionality);
|
|
712
|
+
this.datePicker = inject(NgbDatePicker);
|
|
713
|
+
this.days = viewChildren(CalendarDayBtn, {
|
|
714
|
+
read: ElementRef,
|
|
715
|
+
});
|
|
716
|
+
this.first = input(false);
|
|
717
|
+
this.last = input(false);
|
|
718
|
+
this.index = input(0);
|
|
719
|
+
this.time1 = signal(null);
|
|
720
|
+
this.time2 = signal(null);
|
|
721
|
+
this.cStartMonth = computed(() => {
|
|
722
|
+
const month = this.datePicker.startMonth() + this.index();
|
|
723
|
+
return month > 11 ? 12 - month : month;
|
|
724
|
+
});
|
|
725
|
+
this.cStartYear = computed(() => {
|
|
726
|
+
const year = this.datePicker.startYear();
|
|
727
|
+
const month = this.datePicker.startMonth();
|
|
728
|
+
const showType = this.datePicker.showType();
|
|
729
|
+
const index = this.index();
|
|
730
|
+
if (showType === 'date') {
|
|
731
|
+
return year + Math.floor((month + index) / 12);
|
|
732
|
+
}
|
|
733
|
+
else if (showType === 'month') {
|
|
734
|
+
return year + index;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
return year + index * 24;
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
this.selectedMonthName = computed(() => {
|
|
741
|
+
const date = this.adapter.create(this.cStartYear(), this.cStartMonth());
|
|
742
|
+
return this.adapter.longMonthNames(date);
|
|
743
|
+
});
|
|
744
|
+
this.currentYear = signal(this.cStartYear());
|
|
745
|
+
this.years = computed(() => {
|
|
746
|
+
const year = this.currentYear();
|
|
747
|
+
const filter = this.datePicker.dateFilter();
|
|
748
|
+
return Array.from({ length: 18 }, (_, i) => {
|
|
749
|
+
const y = year - (18 - 6) + i;
|
|
750
|
+
return { year: y, disabled: !filter?.(this.adapter.create(y, 0)) };
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
this.months = computed(() => {
|
|
754
|
+
const filter = this.datePicker.dateFilter();
|
|
755
|
+
return Array.from({ length: 12 }, (_, i) => {
|
|
756
|
+
const date = this.adapter.create(this.cStartYear(), i);
|
|
757
|
+
const isDisabled = !filter?.(date);
|
|
758
|
+
const name = this.adapter.longMonthNames(date);
|
|
759
|
+
return { name: name.substring(0, 3), value: i, disabled: isDisabled };
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
// computed the title based on the type
|
|
763
|
+
this.title = computed(() => {
|
|
764
|
+
const type = this.datePicker.showType();
|
|
765
|
+
const month = this.selectedMonthName();
|
|
766
|
+
const year = this.cStartYear();
|
|
767
|
+
const years = this.years();
|
|
768
|
+
const r = type === 'year'
|
|
769
|
+
? `${years[0].year} - ${years[years.length - 1].year} `
|
|
770
|
+
: type === 'month'
|
|
771
|
+
? year
|
|
772
|
+
: month + ' ' + year;
|
|
773
|
+
return r;
|
|
774
|
+
});
|
|
775
|
+
this.dayNames = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];
|
|
776
|
+
// get the days array based on the month and year
|
|
777
|
+
this.getDaysArray = computed(() => {
|
|
778
|
+
const month = this.cStartMonth();
|
|
779
|
+
const year = this.cStartYear();
|
|
780
|
+
const dateFilter = this.datePicker.dateFilter();
|
|
781
|
+
const numDays = this.adapter.getDate(this.adapter.create(year, month + 1, 0));
|
|
782
|
+
const daysArray = Array.from({ length: numDays }, (_, i) => {
|
|
783
|
+
const date = this.adapter.create(year, month, i + 1);
|
|
784
|
+
return {
|
|
785
|
+
mon: month,
|
|
786
|
+
day: i + 1,
|
|
787
|
+
year: this.adapter.getYear(date),
|
|
788
|
+
disabled: !dateFilter?.(date) || false,
|
|
789
|
+
current: true,
|
|
790
|
+
count: this.adapter.getTime(date),
|
|
791
|
+
};
|
|
792
|
+
});
|
|
793
|
+
const startDay = this.adapter.getDay(this.adapter.create(year, month));
|
|
794
|
+
// get the additional days from the previous month
|
|
795
|
+
const prevMonth = this.adapter.getDate(this.adapter.create(year, month, 0));
|
|
796
|
+
const daysArrayPrev = Array.from({ length: startDay }, (_, i) => {
|
|
797
|
+
const date = this.adapter.create(year, month - 1, prevMonth - startDay + i + 1);
|
|
798
|
+
return {
|
|
799
|
+
mon: this.adapter.getMonth(date),
|
|
800
|
+
day: prevMonth - startDay + i + 1,
|
|
801
|
+
year: this.adapter.getYear(date),
|
|
802
|
+
disabled: !dateFilter?.(date) || false,
|
|
803
|
+
current: false,
|
|
804
|
+
count: this.adapter.getTime(date),
|
|
805
|
+
};
|
|
806
|
+
});
|
|
807
|
+
const t = daysArrayPrev.concat(daysArray); // Padding for start day alignment
|
|
808
|
+
// get the additional days from the next month to fill the last row
|
|
809
|
+
// we need to check whether it is divisible by 7 and we have to fill only the remaining days
|
|
810
|
+
const remaining = t.length % 7 === 0 ? 0 : 7 - (t.length % 7);
|
|
811
|
+
const daysArrayNext = Array.from({ length: remaining }, (_, i) => {
|
|
812
|
+
const date = this.adapter.create(year, month + 1, i + 1);
|
|
813
|
+
return {
|
|
814
|
+
mon: this.adapter.getMonth(date),
|
|
815
|
+
day: i + 1,
|
|
816
|
+
year: this.adapter.getYear(date),
|
|
817
|
+
disabled: !dateFilter?.(date) || false,
|
|
818
|
+
current: false,
|
|
819
|
+
count: this.adapter.getTime(date),
|
|
820
|
+
};
|
|
821
|
+
});
|
|
822
|
+
t.push(...daysArrayNext);
|
|
823
|
+
return t;
|
|
824
|
+
});
|
|
825
|
+
// whether the left button is disabled based on the type
|
|
826
|
+
// and disabled state
|
|
827
|
+
this.leftBtn = computed(() => {
|
|
828
|
+
const type = this.datePicker.showType();
|
|
829
|
+
const year = this.cStartYear();
|
|
830
|
+
const filter = this.datePicker.dateFilter();
|
|
831
|
+
if (type === 'year') {
|
|
832
|
+
return !filter?.(this.adapter.create(this.years()[0].year - 1, 11, 31));
|
|
833
|
+
}
|
|
834
|
+
else if (type === 'month') {
|
|
835
|
+
return !filter?.(this.adapter.create(year - 1, 0));
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
return !filter?.(this.adapter.create(year, this.cStartMonth() - 1));
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
// whether the right button is disabled based on the type
|
|
842
|
+
// and disabled state
|
|
843
|
+
this.rightBtn = computed(() => {
|
|
844
|
+
const type = this.datePicker.showType();
|
|
845
|
+
const year = this.cStartYear();
|
|
846
|
+
const filter = this.datePicker.dateFilter();
|
|
847
|
+
if (type === 'year') {
|
|
848
|
+
return !filter?.(this.adapter.create(this.years()[this.years().length - 1].year + 1, 0));
|
|
849
|
+
}
|
|
850
|
+
else if (type === 'month') {
|
|
851
|
+
return !filter?.(this.adapter.create(year + 1, 0));
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
return !filter?.(this.adapter.create(year, this.cStartMonth() + 1));
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
this.todayDay = computed(() => {
|
|
858
|
+
const today = this.adapter.now();
|
|
859
|
+
return this.getSelectedDayOfMonth(today);
|
|
860
|
+
});
|
|
861
|
+
this.eventListeners = [];
|
|
862
|
+
if (this.datePicker.time() && this.datePicker.range()) {
|
|
863
|
+
const [first, second] = this.datePicker.selectedDates();
|
|
864
|
+
this.time1.set(first ? this.adapter.format(first, 'hh:mm a') : '');
|
|
865
|
+
this.time2.set(second ? this.adapter.format(second, 'hh:mm a') : '');
|
|
866
|
+
}
|
|
867
|
+
effect(() => {
|
|
868
|
+
const days = this.days();
|
|
869
|
+
const range = this.datePicker.range();
|
|
870
|
+
const dates = this.datePicker.selectedDates();
|
|
871
|
+
this.clearListeners();
|
|
872
|
+
if (days.length && range && dates[0] && !dates[1]) {
|
|
873
|
+
const arr = this.getDaysArray();
|
|
874
|
+
days.forEach((day, i) => {
|
|
875
|
+
const listener = () => {
|
|
876
|
+
this.hoverDate(arr[i].day, arr[i].mon);
|
|
877
|
+
};
|
|
878
|
+
day.nativeElement.addEventListener('mouseover', listener);
|
|
879
|
+
this.eventListeners.push({ element: day.nativeElement, listener });
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
get adapter() {
|
|
885
|
+
return this.datePicker.adapter;
|
|
886
|
+
}
|
|
887
|
+
getSelectedDayOfMonth(date) {
|
|
888
|
+
const r = this.cStartMonth() === this.adapter.getMonth(date) &&
|
|
889
|
+
this.cStartYear() === this.adapter.getYear(date)
|
|
890
|
+
? this.adapter.getDate(date)
|
|
891
|
+
: 0;
|
|
892
|
+
return r;
|
|
893
|
+
}
|
|
894
|
+
clearListeners() {
|
|
895
|
+
this.eventListeners.forEach(({ element, listener }) => {
|
|
896
|
+
element.removeEventListener('mouseover', listener);
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
hoverDate(day, month) {
|
|
900
|
+
this.datePicker.updateHoveredDate(this.adapter.create(this.cStartYear(), month, day));
|
|
901
|
+
}
|
|
902
|
+
timeChanged(index, timing) {
|
|
903
|
+
const [time, period] = timing.split(' ');
|
|
904
|
+
const [hours, min] = time.split(':').map(Number);
|
|
905
|
+
const dates = this.datePicker.selectedDates();
|
|
906
|
+
let date = dates[index];
|
|
907
|
+
date = this.adapter.set(date, period === 'PM' ? hours + 12 : hours, 'hour');
|
|
908
|
+
date = this.adapter.set(date, min, 'minute');
|
|
909
|
+
this.datePicker.selectDate(date, index);
|
|
910
|
+
}
|
|
911
|
+
selectDate(day, month) {
|
|
912
|
+
const date = this.adapter.create(this.cStartYear(), month, day);
|
|
913
|
+
this.datePicker.selectDate(date);
|
|
914
|
+
}
|
|
915
|
+
navigate(direction) {
|
|
916
|
+
let selectedYear = this.datePicker.startYear();
|
|
917
|
+
let selectedMonth = this.datePicker.startMonth();
|
|
918
|
+
const count = this.datePicker.noOfCalendar();
|
|
919
|
+
direction = direction * count;
|
|
920
|
+
const type = this.datePicker.showType();
|
|
921
|
+
if (type === 'year') {
|
|
922
|
+
selectedYear += direction * 24;
|
|
923
|
+
this.currentYear.set(selectedYear);
|
|
924
|
+
}
|
|
925
|
+
else if (type === 'month') {
|
|
926
|
+
selectedYear += direction;
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
selectedMonth += direction;
|
|
930
|
+
if (selectedMonth < 0) {
|
|
931
|
+
selectedMonth = 12 + selectedMonth;
|
|
932
|
+
selectedYear--;
|
|
933
|
+
}
|
|
934
|
+
else if (selectedMonth > 11) {
|
|
935
|
+
selectedMonth = selectedMonth - 12;
|
|
936
|
+
selectedYear++;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
this.datePicker.startYear.set(selectedYear);
|
|
940
|
+
this.datePicker.startMonth.set(selectedMonth);
|
|
941
|
+
}
|
|
942
|
+
selectYear(year) {
|
|
943
|
+
this.datePicker.selectYear(year);
|
|
944
|
+
}
|
|
945
|
+
selectMonth(month) {
|
|
946
|
+
this.datePicker.selectMonth(month.value, this.cStartYear());
|
|
947
|
+
}
|
|
948
|
+
toggleView() {
|
|
949
|
+
this.datePicker.toggleView();
|
|
950
|
+
}
|
|
951
|
+
ngOnDestroy() {
|
|
952
|
+
this.clearListeners();
|
|
953
|
+
}
|
|
954
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbCalendar, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
955
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.0", type: NgbCalendar, isStandalone: true, selector: "ngb-calendar", inputs: { first: { classPropertyName: "first", publicName: "first", isSignal: true, isRequired: false, transformFunction: null }, last: { classPropertyName: "last", publicName: "last", isSignal: true, isRequired: false, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "days", predicate: CalendarDayBtn, descendants: true, read: ElementRef, isSignal: true }], ngImport: i0, template: `
|
|
956
|
+
<div class="mb-b2 flex items-center justify-between">
|
|
957
|
+
<button ngbCalendarBtn="left">{{ dir.isRtl() ? '>' : '<' }}</button>
|
|
958
|
+
<button ngbCalendarTitle>{{ title() }}</button>
|
|
959
|
+
<button ngbCalendarBtn="right">{{ dir.isRtl() ? '<' : '>' }}</button>
|
|
960
|
+
</div>
|
|
961
|
+
|
|
962
|
+
@if (datePicker.showType() === 'year') {
|
|
963
|
+
<div class="grid grid-cols-3">
|
|
964
|
+
@for (year of years(); track year.year) {
|
|
965
|
+
<button
|
|
966
|
+
[ngbCalYearBtn]="year"
|
|
967
|
+
#yearBtn="ngbCalYearBtn"
|
|
968
|
+
class="items-center justify-center rounded-md py-b2 h-9 w-[84px] {{
|
|
969
|
+
year.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
970
|
+
}}"
|
|
971
|
+
[ngClass]="{
|
|
972
|
+
'border bg-muted-background': yearBtn.selected(),
|
|
973
|
+
'!bg-primary text-foreground': yearBtn.active(),
|
|
974
|
+
}"
|
|
975
|
+
>
|
|
976
|
+
{{ year.year }}
|
|
977
|
+
</button>
|
|
978
|
+
}
|
|
979
|
+
</div>
|
|
980
|
+
} @else if (datePicker.showType() === 'month') {
|
|
981
|
+
<div class="grid grid-cols-3">
|
|
982
|
+
@for (month of months(); track month.value) {
|
|
983
|
+
<button
|
|
984
|
+
[ngbCalMonthBtn]="month"
|
|
985
|
+
#monthBtn="ngbCalMonthBtn"
|
|
986
|
+
class="items-center justify-center rounded-md py-b2 h-9 w-[84px] {{
|
|
987
|
+
month.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
988
|
+
}}"
|
|
989
|
+
[ngClass]="{
|
|
990
|
+
'border bg-muted-background': monthBtn.selected(),
|
|
991
|
+
'!bg-primary text-foreground': monthBtn.active(),
|
|
992
|
+
}"
|
|
993
|
+
>
|
|
994
|
+
{{ month.name }}
|
|
995
|
+
</button>
|
|
996
|
+
}
|
|
997
|
+
</div>
|
|
998
|
+
} @else {
|
|
999
|
+
<div class="day-names grid grid-cols-7">
|
|
1000
|
+
@for (dayName of dayNames; track dayName) {
|
|
1001
|
+
<div class="p-b text-center text-muted">{{ dayName }}</div>
|
|
1002
|
+
}
|
|
1003
|
+
</div>
|
|
1004
|
+
<div class="grid grid-cols-7 gap-y-b2">
|
|
1005
|
+
@for (day of getDaysArray(); track day.day + '-' + day.mon) {
|
|
1006
|
+
<button
|
|
1007
|
+
#days="ngbCalDayBtn"
|
|
1008
|
+
[ngbCalDayBtn]="day"
|
|
1009
|
+
class="mx-auto flex h-b9 w-b9 items-center justify-center text-center {{
|
|
1010
|
+
day.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
1011
|
+
}}"
|
|
1012
|
+
[ngClass]="{
|
|
1013
|
+
'bg-muted-background': days.selected(),
|
|
1014
|
+
'opacity-40': days.dummy(),
|
|
1015
|
+
'!bg-primary text-foreground': days.active(),
|
|
1016
|
+
}"
|
|
1017
|
+
>
|
|
1018
|
+
{{ day.day }}
|
|
1019
|
+
</button>
|
|
1020
|
+
}
|
|
1021
|
+
</div>
|
|
1022
|
+
@if (datePicker.time() && datePicker.range()) {
|
|
1023
|
+
<div ngbTime [(value)]="time1" (valueChange)="timeChanged(0, time1()!)"></div>
|
|
1024
|
+
<div ngbTime [(value)]="time2" (valueChange)="timeChanged(1, time2()!)"></div>
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: NgbTimePicker, selector: "[ngbTime]", inputs: ["is24", "value"], outputs: ["valueChange"] }, { kind: "directive", type: CalendarBtn, selector: "[ngbCalendarBtn]", inputs: ["ngbCalendarBtn"] }, { kind: "directive", type: CalendarTitle, selector: "[ngbCalendarTitle]" }, { kind: "directive", type: CalendarYearBtn, selector: "[ngbCalYearBtn]", inputs: ["ngbCalYearBtn"], exportAs: ["ngbCalYearBtn"] }, { kind: "directive", type: CalendarMonthBtn, selector: "[ngbCalMonthBtn]", inputs: ["ngbCalMonthBtn"], exportAs: ["ngbCalMonthBtn"] }, { kind: "directive", type: CalendarDayBtn, selector: "[ngbCalDayBtn]", inputs: ["ngbCalDayBtn"], exportAs: ["ngbCalDayBtn"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
1028
|
+
}
|
|
1029
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbCalendar, decorators: [{
|
|
1030
|
+
type: Component,
|
|
1031
|
+
args: [{
|
|
1032
|
+
selector: 'ngb-calendar',
|
|
1033
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1034
|
+
imports: [
|
|
1035
|
+
NgClass,
|
|
1036
|
+
NgbTimePicker,
|
|
1037
|
+
CalendarBtn,
|
|
1038
|
+
CalendarTitle,
|
|
1039
|
+
CalendarYearBtn,
|
|
1040
|
+
CalendarMonthBtn,
|
|
1041
|
+
CalendarDayBtn,
|
|
1042
|
+
],
|
|
1043
|
+
template: `
|
|
1044
|
+
<div class="mb-b2 flex items-center justify-between">
|
|
1045
|
+
<button ngbCalendarBtn="left">{{ dir.isRtl() ? '>' : '<' }}</button>
|
|
1046
|
+
<button ngbCalendarTitle>{{ title() }}</button>
|
|
1047
|
+
<button ngbCalendarBtn="right">{{ dir.isRtl() ? '<' : '>' }}</button>
|
|
1048
|
+
</div>
|
|
1049
|
+
|
|
1050
|
+
@if (datePicker.showType() === 'year') {
|
|
1051
|
+
<div class="grid grid-cols-3">
|
|
1052
|
+
@for (year of years(); track year.year) {
|
|
1053
|
+
<button
|
|
1054
|
+
[ngbCalYearBtn]="year"
|
|
1055
|
+
#yearBtn="ngbCalYearBtn"
|
|
1056
|
+
class="items-center justify-center rounded-md py-b2 h-9 w-[84px] {{
|
|
1057
|
+
year.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
1058
|
+
}}"
|
|
1059
|
+
[ngClass]="{
|
|
1060
|
+
'border bg-muted-background': yearBtn.selected(),
|
|
1061
|
+
'!bg-primary text-foreground': yearBtn.active(),
|
|
1062
|
+
}"
|
|
1063
|
+
>
|
|
1064
|
+
{{ year.year }}
|
|
1065
|
+
</button>
|
|
1066
|
+
}
|
|
1067
|
+
</div>
|
|
1068
|
+
} @else if (datePicker.showType() === 'month') {
|
|
1069
|
+
<div class="grid grid-cols-3">
|
|
1070
|
+
@for (month of months(); track month.value) {
|
|
1071
|
+
<button
|
|
1072
|
+
[ngbCalMonthBtn]="month"
|
|
1073
|
+
#monthBtn="ngbCalMonthBtn"
|
|
1074
|
+
class="items-center justify-center rounded-md py-b2 h-9 w-[84px] {{
|
|
1075
|
+
month.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
1076
|
+
}}"
|
|
1077
|
+
[ngClass]="{
|
|
1078
|
+
'border bg-muted-background': monthBtn.selected(),
|
|
1079
|
+
'!bg-primary text-foreground': monthBtn.active(),
|
|
1080
|
+
}"
|
|
1081
|
+
>
|
|
1082
|
+
{{ month.name }}
|
|
1083
|
+
</button>
|
|
1084
|
+
}
|
|
1085
|
+
</div>
|
|
1086
|
+
} @else {
|
|
1087
|
+
<div class="day-names grid grid-cols-7">
|
|
1088
|
+
@for (dayName of dayNames; track dayName) {
|
|
1089
|
+
<div class="p-b text-center text-muted">{{ dayName }}</div>
|
|
1090
|
+
}
|
|
1091
|
+
</div>
|
|
1092
|
+
<div class="grid grid-cols-7 gap-y-b2">
|
|
1093
|
+
@for (day of getDaysArray(); track day.day + '-' + day.mon) {
|
|
1094
|
+
<button
|
|
1095
|
+
#days="ngbCalDayBtn"
|
|
1096
|
+
[ngbCalDayBtn]="day"
|
|
1097
|
+
class="mx-auto flex h-b9 w-b9 items-center justify-center text-center {{
|
|
1098
|
+
day.disabled ? 'cursor-default opacity-50' : 'hover:bg-muted-background'
|
|
1099
|
+
}}"
|
|
1100
|
+
[ngClass]="{
|
|
1101
|
+
'bg-muted-background': days.selected(),
|
|
1102
|
+
'opacity-40': days.dummy(),
|
|
1103
|
+
'!bg-primary text-foreground': days.active(),
|
|
1104
|
+
}"
|
|
1105
|
+
>
|
|
1106
|
+
{{ day.day }}
|
|
1107
|
+
</button>
|
|
1108
|
+
}
|
|
1109
|
+
</div>
|
|
1110
|
+
@if (datePicker.time() && datePicker.range()) {
|
|
1111
|
+
<div ngbTime [(value)]="time1" (valueChange)="timeChanged(0, time1()!)"></div>
|
|
1112
|
+
<div ngbTime [(value)]="time2" (valueChange)="timeChanged(1, time2()!)"></div>
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
`,
|
|
1116
|
+
}]
|
|
1117
|
+
}], ctorParameters: () => [] });
|
|
1118
|
+
function provideCalendar(cal) {
|
|
1119
|
+
return {
|
|
1120
|
+
provide: NgbCalendar,
|
|
1121
|
+
useExisting: cal,
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* Generated bundle index. Do not edit.
|
|
1127
|
+
*/
|
|
1128
|
+
|
|
1129
|
+
export { CalendarBtn, CalendarDayBtn, CalendarMonthBtn, CalendarTitle, CalendarYearBtn, DatepickerGroup, NgbCalendar, NgbDateAdapter, NgbDatePicker, NgbDatepickerTrigger, NgbNativeDateAdapter, NgbTimeInput, NgbTimePicker, injectNgbDateAdapter, provideCalendar, provideDatePicker, provideTimePicker, registerDatePicker };
|
|
1130
|
+
//# sourceMappingURL=ngbase-adk-datepicker.mjs.map
|