dasar-ui 1.1.0 → 1.3.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 +19 -14
- package/fesm2022/dasar-ui.mjs +9664 -0
- package/fesm2022/dasar-ui.mjs.map +1 -0
- package/package.json +39 -42
- package/types/dasar-ui.d.ts +2114 -0
- package/.editorconfig +0 -17
- package/.nvmrc +0 -1
- package/.prettierrc +0 -12
- package/.vscode/extensions.json +0 -4
- package/.vscode/launch.json +0 -20
- package/.vscode/settings.json +0 -4
- package/.vscode/tasks.json +0 -42
- package/CHANGELOG.md +0 -18
- package/angular.json +0 -37
- package/projects/dasar-ui/README.md +0 -64
- package/projects/dasar-ui/ng-package.json +0 -10
- package/projects/dasar-ui/package.json +0 -27
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.html +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.scss +0 -352
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.ts +0 -154
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.scss +0 -69
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.ts +0 -30
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.html +0 -158
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.scss +0 -371
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.ts +0 -458
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.html +0 -80
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.scss +0 -184
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.ts +0 -294
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.html +0 -42
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.scss +0 -38
- package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.ts +0 -207
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.html +0 -102
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.scss +0 -301
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.ts +0 -527
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.registry.ts +0 -5089
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.scss +0 -24
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.ts +0 -97
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.html +0 -54
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.scss +0 -281
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.ts +0 -323
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.html +0 -63
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.scss +0 -195
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.ts +0 -240
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.html +0 -90
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.scss +0 -358
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.ts +0 -337
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.html +0 -98
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.scss +0 -51
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.ts +0 -99
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.html +0 -163
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.scss +0 -283
- package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.ts +0 -230
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.html +0 -185
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.scss +0 -347
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.ts +0 -497
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.html +0 -162
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.scss +0 -283
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.ts +0 -380
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.html +0 -41
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.scss +0 -126
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.ts +0 -72
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.html +0 -43
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.scss +0 -189
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.ts +0 -139
- package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.ts +0 -286
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.ts +0 -9
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.css +0 -0
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.html +0 -1
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.spec.ts +0 -21
- package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.ts +0 -9
- package/projects/dasar-ui/src/lib/models/theme.model.ts +0 -643
- package/projects/dasar-ui/src/lib/models/type.model.ts +0 -11
- package/projects/dasar-ui/src/lib/services/theme.service.ts +0 -643
- package/projects/dasar-ui/src/lib/styles/theme.ts +0 -70
- package/projects/dasar-ui/src/lib/utils/common.ts +0 -175
- package/projects/dasar-ui/src/public-api.ts +0 -23
- package/projects/dasar-ui/tsconfig.lib.json +0 -21
- package/projects/dasar-ui/tsconfig.lib.prod.json +0 -11
- package/projects/dasar-ui/tsconfig.spec.json +0 -11
- package/tsconfig.json +0 -37
- /package/{projects/dasar-ui/src/lib/styles → styles}/theme.scss +0 -0
|
@@ -1,458 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Component,
|
|
3
|
-
Input,
|
|
4
|
-
Output,
|
|
5
|
-
EventEmitter,
|
|
6
|
-
OnInit,
|
|
7
|
-
OnChanges,
|
|
8
|
-
Directive,
|
|
9
|
-
TemplateRef,
|
|
10
|
-
ContentChild,
|
|
11
|
-
booleanAttribute,
|
|
12
|
-
ViewEncapsulation,
|
|
13
|
-
forwardRef,
|
|
14
|
-
ChangeDetectorRef,
|
|
15
|
-
inject,
|
|
16
|
-
HostBinding,
|
|
17
|
-
} from '@angular/core';
|
|
18
|
-
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
19
|
-
import { CommonModule } from '@angular/common';
|
|
20
|
-
|
|
21
|
-
import { DASAR_THEME_PROVIDER } from '../dasar-theme-provider/dasar-theme-provider';
|
|
22
|
-
import { ClassType, ScaleAttributeType, StyleType } from '../../models/type.model';
|
|
23
|
-
import { safeFormat, resolveThemeDefault } from '../../utils/common';
|
|
24
|
-
import { DasarButtonComponent } from '../dasar-button/dasar-button';
|
|
25
|
-
import { DasarThemeService } from '../../services/theme.service';
|
|
26
|
-
import { DasarIconComponent } from '../dasar-icon/dasar-icon';
|
|
27
|
-
|
|
28
|
-
export type DasarCalendarSizeType = Extract<ScaleAttributeType, 'sm' | 'md' | 'lg'>;
|
|
29
|
-
export type DasarCalendarAppearance = 'outline' | 'borderless';
|
|
30
|
-
export type DasarCalendarVariant = 'dashboard' | 'dropdown';
|
|
31
|
-
export type DasarCalendarRadius = ScaleAttributeType;
|
|
32
|
-
|
|
33
|
-
export interface DasarCalendarConfig {
|
|
34
|
-
appearance?: 'outline' | 'borderless';
|
|
35
|
-
variant?: 'dashboard' | 'dropdown';
|
|
36
|
-
size?: DasarCalendarSizeType;
|
|
37
|
-
radius?: DasarCalendarRadius;
|
|
38
|
-
containerStyle?: StyleType;
|
|
39
|
-
containerClass?: ClassType;
|
|
40
|
-
headerClass?: ClassType;
|
|
41
|
-
headerStyle?: StyleType;
|
|
42
|
-
hideFullDate?: boolean;
|
|
43
|
-
weekdayFormat?: string;
|
|
44
|
-
headerFormat?: string;
|
|
45
|
-
valueFormat?: string;
|
|
46
|
-
hideHeader?: boolean;
|
|
47
|
-
fullWidth?: boolean;
|
|
48
|
-
disabled?: boolean;
|
|
49
|
-
locale?: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface CalendarDay {
|
|
53
|
-
isCurrentMonth: boolean;
|
|
54
|
-
weekdayStr?: string;
|
|
55
|
-
fullDateStr: string;
|
|
56
|
-
isSelected: boolean;
|
|
57
|
-
dayNumber: number;
|
|
58
|
-
isToday: boolean;
|
|
59
|
-
date: Date;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
@Directive({ selector: '[calendar-header-template]', standalone: true })
|
|
63
|
-
export class DasarCalendarHeaderTemplate {
|
|
64
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
65
|
-
}
|
|
66
|
-
@Directive({ selector: '[calendar-prev-year-template]', standalone: true })
|
|
67
|
-
export class DasarCalendarPrevYearTemplate {
|
|
68
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
69
|
-
}
|
|
70
|
-
@Directive({ selector: '[calendar-prev-month-template]', standalone: true })
|
|
71
|
-
export class DasarCalendarPrevMonthTemplate {
|
|
72
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
73
|
-
}
|
|
74
|
-
@Directive({ selector: '[calendar-today-template]', standalone: true })
|
|
75
|
-
export class DasarCalendarTodayTemplate {
|
|
76
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
77
|
-
}
|
|
78
|
-
@Directive({ selector: '[calendar-next-month-template]', standalone: true })
|
|
79
|
-
export class DasarCalendarNextMonthTemplate {
|
|
80
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
81
|
-
}
|
|
82
|
-
@Directive({ selector: '[calendar-next-year-template]', standalone: true })
|
|
83
|
-
export class DasarCalendarNextYearTemplate {
|
|
84
|
-
constructor(public templateRef: TemplateRef<any>) {}
|
|
85
|
-
}
|
|
86
|
-
@Directive({ selector: '[calendar-footer-slot]', standalone: true })
|
|
87
|
-
export class DasarCalendarFooterSlot {}
|
|
88
|
-
|
|
89
|
-
@Component({
|
|
90
|
-
providers: [
|
|
91
|
-
{
|
|
92
|
-
useExisting: forwardRef(() => DasarCalendarComponent),
|
|
93
|
-
provide: NG_VALUE_ACCESSOR,
|
|
94
|
-
multi: true,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
imports: [CommonModule, DasarButtonComponent, DasarIconComponent],
|
|
98
|
-
encapsulation: ViewEncapsulation.None,
|
|
99
|
-
styleUrls: ['./dasar-calendar.scss'],
|
|
100
|
-
templateUrl: './dasar-calendar.html',
|
|
101
|
-
selector: 'dasar-calendar',
|
|
102
|
-
standalone: true,
|
|
103
|
-
})
|
|
104
|
-
export class DasarCalendar implements OnInit, OnChanges, ControlValueAccessor {
|
|
105
|
-
@ContentChild(DasarCalendarPrevMonthTemplate) prevMonthTemplate?: DasarCalendarPrevMonthTemplate;
|
|
106
|
-
@ContentChild(DasarCalendarNextMonthTemplate) nextMonthTemplate?: DasarCalendarNextMonthTemplate;
|
|
107
|
-
@ContentChild(DasarCalendarPrevYearTemplate) prevYearTemplate?: DasarCalendarPrevYearTemplate;
|
|
108
|
-
@ContentChild(DasarCalendarNextYearTemplate) nextYearTemplate?: DasarCalendarNextYearTemplate;
|
|
109
|
-
@ContentChild(DasarCalendarHeaderTemplate) headerTemplate?: DasarCalendarHeaderTemplate;
|
|
110
|
-
@ContentChild(DasarCalendarTodayTemplate) todayTemplate?: DasarCalendarTodayTemplate;
|
|
111
|
-
@ContentChild(DasarCalendarFooterSlot) footerSlot?: DasarCalendarFooterSlot;
|
|
112
|
-
|
|
113
|
-
private themeProvider = inject(DASAR_THEME_PROVIDER, { optional: true });
|
|
114
|
-
private themeService = inject(DasarThemeService, { optional: true });
|
|
115
|
-
|
|
116
|
-
@Input({ alias: 'header-format' }) headerFormat = resolveThemeDefault(
|
|
117
|
-
'calendar',
|
|
118
|
-
'headerFormat',
|
|
119
|
-
'MMMM yyyy',
|
|
120
|
-
this.themeProvider,
|
|
121
|
-
this.themeService,
|
|
122
|
-
);
|
|
123
|
-
@Input({ alias: 'value-format' }) valueFormat = resolveThemeDefault(
|
|
124
|
-
'calendar',
|
|
125
|
-
'valueFormat',
|
|
126
|
-
'dd-MM-yyyy',
|
|
127
|
-
this.themeProvider,
|
|
128
|
-
this.themeService,
|
|
129
|
-
);
|
|
130
|
-
@Input() size = resolveThemeDefault(
|
|
131
|
-
'select',
|
|
132
|
-
'size',
|
|
133
|
-
'md',
|
|
134
|
-
this.themeProvider,
|
|
135
|
-
this.themeService,
|
|
136
|
-
);
|
|
137
|
-
@Input({ alias: 'weekday-format' }) weekdayFormat = resolveThemeDefault(
|
|
138
|
-
'calendar',
|
|
139
|
-
'weekdayFormat',
|
|
140
|
-
'dddd',
|
|
141
|
-
this.themeProvider,
|
|
142
|
-
this.themeService,
|
|
143
|
-
);
|
|
144
|
-
@Input() locale = resolveThemeDefault(
|
|
145
|
-
'calendar',
|
|
146
|
-
'locale',
|
|
147
|
-
'en-US',
|
|
148
|
-
this.themeProvider,
|
|
149
|
-
this.themeService,
|
|
150
|
-
);
|
|
151
|
-
@Input() appearance = resolveThemeDefault(
|
|
152
|
-
'calendar',
|
|
153
|
-
'appearance',
|
|
154
|
-
'outline',
|
|
155
|
-
this.themeProvider,
|
|
156
|
-
this.themeService,
|
|
157
|
-
);
|
|
158
|
-
@Input() variant = resolveThemeDefault(
|
|
159
|
-
'calendar',
|
|
160
|
-
'variant',
|
|
161
|
-
'dashboard',
|
|
162
|
-
this.themeProvider,
|
|
163
|
-
this.themeService,
|
|
164
|
-
);
|
|
165
|
-
@Input() radius = resolveThemeDefault(
|
|
166
|
-
'calendar',
|
|
167
|
-
'radius',
|
|
168
|
-
'md',
|
|
169
|
-
this.themeProvider,
|
|
170
|
-
this.themeService,
|
|
171
|
-
);
|
|
172
|
-
@Input({ alias: 'container-style' }) containerStyle = resolveThemeDefault(
|
|
173
|
-
'calendar',
|
|
174
|
-
'containerStyle',
|
|
175
|
-
null,
|
|
176
|
-
this.themeProvider,
|
|
177
|
-
this.themeService,
|
|
178
|
-
);
|
|
179
|
-
@Input({ alias: 'container-class' }) containerClass = resolveThemeDefault(
|
|
180
|
-
'calendar',
|
|
181
|
-
'containerClass',
|
|
182
|
-
null,
|
|
183
|
-
this.themeProvider,
|
|
184
|
-
this.themeService,
|
|
185
|
-
);
|
|
186
|
-
@Input({ alias: 'header-class' }) headerClass = resolveThemeDefault(
|
|
187
|
-
'calendar',
|
|
188
|
-
'headerClass',
|
|
189
|
-
null,
|
|
190
|
-
this.themeProvider,
|
|
191
|
-
this.themeService,
|
|
192
|
-
);
|
|
193
|
-
@Input({ alias: 'header-style' }) headerStyle = resolveThemeDefault(
|
|
194
|
-
'calendar',
|
|
195
|
-
'headerStyle',
|
|
196
|
-
null,
|
|
197
|
-
this.themeProvider,
|
|
198
|
-
this.themeService,
|
|
199
|
-
);
|
|
200
|
-
@Input({ transform: booleanAttribute }) disabled = resolveThemeDefault(
|
|
201
|
-
'calendar',
|
|
202
|
-
'disabled',
|
|
203
|
-
false,
|
|
204
|
-
this.themeProvider,
|
|
205
|
-
this.themeService,
|
|
206
|
-
);
|
|
207
|
-
@Input({ alias: 'hide-header', transform: booleanAttribute }) hideHeader = resolveThemeDefault(
|
|
208
|
-
'calendar',
|
|
209
|
-
'hideHeader',
|
|
210
|
-
false,
|
|
211
|
-
this.themeProvider,
|
|
212
|
-
this.themeService,
|
|
213
|
-
);
|
|
214
|
-
@Input({ alias: 'full-width', transform: booleanAttribute }) fullWidth = resolveThemeDefault(
|
|
215
|
-
'calendar',
|
|
216
|
-
'fullWidth',
|
|
217
|
-
false,
|
|
218
|
-
this.themeProvider,
|
|
219
|
-
this.themeService,
|
|
220
|
-
);
|
|
221
|
-
@Input({ alias: 'hide-full-date', transform: booleanAttribute }) hideFullDate =
|
|
222
|
-
resolveThemeDefault('calendar', 'hideFullDate', false, this.themeProvider, this.themeService);
|
|
223
|
-
|
|
224
|
-
@Output() onMonthChange = new EventEmitter<Date>();
|
|
225
|
-
@Output() onYearChange = new EventEmitter<Date>();
|
|
226
|
-
@Output() onPrevMonthClick = new EventEmitter<Date>();
|
|
227
|
-
@Output() onNextMonthClick = new EventEmitter<Date>();
|
|
228
|
-
@Output() onPrevYearClick = new EventEmitter<Date>();
|
|
229
|
-
@Output() onNextYearClick = new EventEmitter<Date>();
|
|
230
|
-
@Output() onTodayClick = new EventEmitter<Date>();
|
|
231
|
-
|
|
232
|
-
@HostBinding('class.dasar-calendar') readonly baseClass = true;
|
|
233
|
-
@HostBinding('class.full-width') get hasFullWidth(): boolean {
|
|
234
|
-
return this.fullWidth;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
private _value: Date | null = null;
|
|
238
|
-
private cdr = inject(ChangeDetectorRef);
|
|
239
|
-
weekdays: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
240
|
-
viewMode: 'days' | 'months' | 'years' = 'days';
|
|
241
|
-
currentViewDate: Date = new Date();
|
|
242
|
-
calendarDays: CalendarDay[] = [];
|
|
243
|
-
|
|
244
|
-
onTouched: any = () => {};
|
|
245
|
-
onChange: any = () => {};
|
|
246
|
-
|
|
247
|
-
@Input()
|
|
248
|
-
get value(): Date | null {
|
|
249
|
-
return this._value;
|
|
250
|
-
}
|
|
251
|
-
set value(val: Date | null | string | number) {
|
|
252
|
-
const parsedVal = val ? new Date(val) : null;
|
|
253
|
-
if (this.getTimeSafe(this._value) !== this.getTimeSafe(parsedVal)) {
|
|
254
|
-
this._value = parsedVal;
|
|
255
|
-
this.cdr.markForCheck();
|
|
256
|
-
|
|
257
|
-
if (parsedVal) {
|
|
258
|
-
this.currentViewDate = new Date(parsedVal);
|
|
259
|
-
}
|
|
260
|
-
this.generateCalendar();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
@Output() valueChange = new EventEmitter<Date | null>();
|
|
264
|
-
|
|
265
|
-
ngOnInit() {
|
|
266
|
-
if (this.value) this.currentViewDate = new Date(this.value);
|
|
267
|
-
this.generateCalendar();
|
|
268
|
-
}
|
|
269
|
-
ngOnChanges() {
|
|
270
|
-
if (this.value) {
|
|
271
|
-
this.currentViewDate = new Date(this.value);
|
|
272
|
-
this.generateCalendar();
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
get currentMonthYear(): string {
|
|
277
|
-
return safeFormat(this.currentViewDate, this.headerFormat, this.locale);
|
|
278
|
-
}
|
|
279
|
-
get monthsList(): { name: string; index: number }[] {
|
|
280
|
-
return Array.from({ length: 12 }, (_, i) => {
|
|
281
|
-
const d = new Date(this.currentViewDate.getFullYear(), i, 1);
|
|
282
|
-
return {
|
|
283
|
-
name: safeFormat(d, 'LLLL', this.locale),
|
|
284
|
-
index: i,
|
|
285
|
-
};
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
get yearsList(): number[] {
|
|
289
|
-
const currentYear = new Date().getFullYear();
|
|
290
|
-
const startYear = 1999;
|
|
291
|
-
const years: number[] = [];
|
|
292
|
-
for (let y = startYear; y <= currentYear; y++) {
|
|
293
|
-
years.push(y);
|
|
294
|
-
}
|
|
295
|
-
return years;
|
|
296
|
-
}
|
|
297
|
-
get localizedDropdownWeekdays(): string[] {
|
|
298
|
-
const baseDate = new Date(2026, 5, 7); // Sunday
|
|
299
|
-
return Array.from({ length: 7 }, (_, i) => {
|
|
300
|
-
const d = new Date(baseDate);
|
|
301
|
-
d.setDate(baseDate.getDate() + i);
|
|
302
|
-
return safeFormat(d, this.variant == 'dropdown' ? 'ddd' : this.weekdayFormat, this.locale);
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
toggleViewMode() {
|
|
307
|
-
if (this.viewMode === 'days') {
|
|
308
|
-
this.viewMode = 'months';
|
|
309
|
-
} else if (this.viewMode === 'months') {
|
|
310
|
-
this.viewMode = 'years';
|
|
311
|
-
} else {
|
|
312
|
-
this.viewMode = 'days';
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
selectMonth(monthIndex: number, event: Event) {
|
|
316
|
-
event.stopPropagation();
|
|
317
|
-
this.currentViewDate = new Date(this.currentViewDate.getFullYear(), monthIndex, 1);
|
|
318
|
-
this.viewMode = 'days';
|
|
319
|
-
this.generateCalendar();
|
|
320
|
-
this.onMonthChange.emit(this.currentViewDate);
|
|
321
|
-
}
|
|
322
|
-
selectYear(year: number, event: Event) {
|
|
323
|
-
event.stopPropagation();
|
|
324
|
-
this.currentViewDate = new Date(year, this.currentViewDate.getMonth(), 1);
|
|
325
|
-
this.viewMode = 'months';
|
|
326
|
-
this.generateCalendar();
|
|
327
|
-
this.onYearChange.emit(this.currentViewDate);
|
|
328
|
-
}
|
|
329
|
-
writeValue(value: any): void {
|
|
330
|
-
const parsedVal = value ? new Date(value) : null;
|
|
331
|
-
this._value = parsedVal;
|
|
332
|
-
if (parsedVal) {
|
|
333
|
-
this.currentViewDate = new Date(parsedVal);
|
|
334
|
-
}
|
|
335
|
-
this.generateCalendar();
|
|
336
|
-
this.cdr.markForCheck();
|
|
337
|
-
}
|
|
338
|
-
registerOnChange(fn: any): void {
|
|
339
|
-
this.onChange = fn;
|
|
340
|
-
}
|
|
341
|
-
registerOnTouched(fn: any): void {
|
|
342
|
-
this.onTouched = fn;
|
|
343
|
-
}
|
|
344
|
-
setDisabledState(isDisabled: boolean): void {
|
|
345
|
-
this.disabled = isDisabled;
|
|
346
|
-
this.cdr.markForCheck();
|
|
347
|
-
}
|
|
348
|
-
getTimeSafe(date: Date | null): number | null {
|
|
349
|
-
return date ? date.getTime() : null;
|
|
350
|
-
}
|
|
351
|
-
changeMonth(offset: number, event?: Event) {
|
|
352
|
-
if (event) event.stopPropagation();
|
|
353
|
-
if (this.disabled) return;
|
|
354
|
-
const oldYear = this.currentViewDate.getFullYear();
|
|
355
|
-
this.currentViewDate = new Date(oldYear, this.currentViewDate.getMonth() + offset, 1);
|
|
356
|
-
this.generateCalendar();
|
|
357
|
-
this.onMonthChange.emit(this.currentViewDate);
|
|
358
|
-
if (oldYear !== this.currentViewDate.getFullYear()) {
|
|
359
|
-
this.onYearChange.emit(this.currentViewDate);
|
|
360
|
-
}
|
|
361
|
-
offset > 0
|
|
362
|
-
? this.onNextMonthClick.emit(this.currentViewDate)
|
|
363
|
-
: this.onPrevMonthClick.emit(this.currentViewDate);
|
|
364
|
-
}
|
|
365
|
-
changeYear(offset: number, event?: Event) {
|
|
366
|
-
if (event) event.stopPropagation();
|
|
367
|
-
if (this.disabled) return;
|
|
368
|
-
const oldYear = this.currentViewDate.getFullYear();
|
|
369
|
-
this.currentViewDate = new Date(oldYear + offset, this.currentViewDate.getMonth(), 1);
|
|
370
|
-
this.generateCalendar();
|
|
371
|
-
this.onYearChange.emit(this.currentViewDate);
|
|
372
|
-
offset > 0
|
|
373
|
-
? this.onNextYearClick.emit(this.currentViewDate)
|
|
374
|
-
: this.onPrevYearClick.emit(this.currentViewDate);
|
|
375
|
-
}
|
|
376
|
-
goToToday(event?: Event) {
|
|
377
|
-
if (event) event.stopPropagation();
|
|
378
|
-
const oldYear = this.currentViewDate.getFullYear();
|
|
379
|
-
this.currentViewDate = new Date();
|
|
380
|
-
this.generateCalendar();
|
|
381
|
-
this.onTodayClick.emit(this.currentViewDate);
|
|
382
|
-
this.onMonthChange.emit(this.currentViewDate);
|
|
383
|
-
if (oldYear !== this.currentViewDate.getFullYear()) {
|
|
384
|
-
this.onYearChange.emit(this.currentViewDate);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
selectDate(day: CalendarDay, event: Event) {
|
|
388
|
-
event.stopPropagation();
|
|
389
|
-
if (this.disabled) return;
|
|
390
|
-
if (!day.isCurrentMonth) {
|
|
391
|
-
const oldYear = this.currentViewDate.getFullYear();
|
|
392
|
-
this.currentViewDate = new Date(day.date.getFullYear(), day.date.getMonth(), 1);
|
|
393
|
-
this.onMonthChange.emit(this.currentViewDate);
|
|
394
|
-
if (oldYear !== this.currentViewDate.getFullYear()) {
|
|
395
|
-
this.onYearChange.emit(this.currentViewDate);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
const newDate = new Date(day.date);
|
|
399
|
-
this.value = newDate;
|
|
400
|
-
this.valueChange.emit(newDate);
|
|
401
|
-
this.generateCalendar();
|
|
402
|
-
}
|
|
403
|
-
generateCalendar() {
|
|
404
|
-
const totalCell = 42;
|
|
405
|
-
const year = this.currentViewDate.getFullYear();
|
|
406
|
-
const month = this.currentViewDate.getMonth();
|
|
407
|
-
const firstDayOfMonth = new Date(year, month, 1).getDay();
|
|
408
|
-
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
409
|
-
const daysInPrevMonth = new Date(year, month, 0).getDate();
|
|
410
|
-
const today = new Date();
|
|
411
|
-
today.setHours(0, 0, 0, 0);
|
|
412
|
-
const selected = this.value ? new Date(this.value) : null;
|
|
413
|
-
if (selected) selected.setHours(0, 0, 0, 0);
|
|
414
|
-
const days: CalendarDay[] = [];
|
|
415
|
-
for (let i = firstDayOfMonth - 1; i >= 0; i--) {
|
|
416
|
-
const date = new Date(year, month - 1, daysInPrevMonth - i);
|
|
417
|
-
days.push(this.createCalendarDay(date, days.length, false, today, selected));
|
|
418
|
-
}
|
|
419
|
-
for (let i = 1; i <= daysInMonth; i++) {
|
|
420
|
-
const date = new Date(year, month, i);
|
|
421
|
-
days.push(this.createCalendarDay(date, days.length, true, today, selected));
|
|
422
|
-
}
|
|
423
|
-
const remainingDays = totalCell - days.length;
|
|
424
|
-
for (let i = 1; i <= remainingDays; i++) {
|
|
425
|
-
const date = new Date(year, month + 1, i);
|
|
426
|
-
days.push(this.createCalendarDay(date, days.length, false, today, selected));
|
|
427
|
-
}
|
|
428
|
-
this.calendarDays = days;
|
|
429
|
-
}
|
|
430
|
-
private createCalendarDay(
|
|
431
|
-
date: Date,
|
|
432
|
-
index: number,
|
|
433
|
-
isCurrentMonth: boolean,
|
|
434
|
-
today: Date,
|
|
435
|
-
selected: Date | null,
|
|
436
|
-
): CalendarDay {
|
|
437
|
-
return {
|
|
438
|
-
weekdayStr: index < 7 ? safeFormat(date, this.weekdayFormat, this.locale) : undefined,
|
|
439
|
-
isSelected: selected ? date.getTime() === selected.getTime() : false,
|
|
440
|
-
fullDateStr: safeFormat(date, this.valueFormat, this.locale),
|
|
441
|
-
isToday: date.getTime() === today.getTime(),
|
|
442
|
-
dayNumber: date.getDate(),
|
|
443
|
-
isCurrentMonth,
|
|
444
|
-
date,
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
export const DasarCalendarComponent = [
|
|
450
|
-
DasarCalendar,
|
|
451
|
-
DasarCalendarFooterSlot,
|
|
452
|
-
DasarCalendarHeaderTemplate,
|
|
453
|
-
DasarCalendarPrevYearTemplate,
|
|
454
|
-
DasarCalendarPrevMonthTemplate,
|
|
455
|
-
DasarCalendarTodayTemplate,
|
|
456
|
-
DasarCalendarNextMonthTemplate,
|
|
457
|
-
DasarCalendarNextYearTemplate,
|
|
458
|
-
] as const;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<div
|
|
2
|
-
class="dasar-card-container appearance-{{ appearance }} size-{{ size }} radius-{{
|
|
3
|
-
radius
|
|
4
|
-
}} spacing-{{ spacing }}"
|
|
5
|
-
[class.hide-overflow]="hideOverflow"
|
|
6
|
-
[class.fluid]="fluid"
|
|
7
|
-
[ngClass]="containerClass"
|
|
8
|
-
[ngStyle]="containerStyle"
|
|
9
|
-
>
|
|
10
|
-
@if (label || hasHeader || hasCaption || closable || hasExtraHeader) {
|
|
11
|
-
<div
|
|
12
|
-
class="dasar-card-header"
|
|
13
|
-
[class.fluid]="headerFluid"
|
|
14
|
-
[ngClass]="headerClass"
|
|
15
|
-
[ngStyle]="headerStyle"
|
|
16
|
-
>
|
|
17
|
-
<div
|
|
18
|
-
class="dasar-card-header-content"
|
|
19
|
-
[ngClass]="contentHeaderClass"
|
|
20
|
-
[ngStyle]="contentHeaderStyle"
|
|
21
|
-
>
|
|
22
|
-
@if (hasHeader) {
|
|
23
|
-
<ng-content select="[header-slot]"></ng-content>
|
|
24
|
-
} @else if (label) {
|
|
25
|
-
<span class="dasar-card-title">{{ label }}</span>
|
|
26
|
-
}
|
|
27
|
-
@if (hasCaption) {
|
|
28
|
-
<div
|
|
29
|
-
class="dasar-card-caption"
|
|
30
|
-
[class.fluid]="captionFluid"
|
|
31
|
-
[ngClass]="captionClass"
|
|
32
|
-
[ngStyle]="captionStyle"
|
|
33
|
-
>
|
|
34
|
-
<ng-content select="[caption-slot]"></ng-content>
|
|
35
|
-
</div>
|
|
36
|
-
}
|
|
37
|
-
</div>
|
|
38
|
-
@if (closable || hasExtraHeader) {
|
|
39
|
-
<div
|
|
40
|
-
class="dasar-card-extra-header"
|
|
41
|
-
[ngClass]="extraHeaderClass"
|
|
42
|
-
[ngStyle]="extraHeaderStyle"
|
|
43
|
-
>
|
|
44
|
-
@if (hasExtraHeader) {
|
|
45
|
-
<ng-content select="[extra-header-slot]"></ng-content>
|
|
46
|
-
}
|
|
47
|
-
@if (closable) {
|
|
48
|
-
<dasar-button
|
|
49
|
-
variant="ghost"
|
|
50
|
-
tabindex="-1"
|
|
51
|
-
icon-only
|
|
52
|
-
[size]="size"
|
|
53
|
-
(click)="closeCard()"
|
|
54
|
-
>
|
|
55
|
-
<dasar-icon name="x"></dasar-icon>
|
|
56
|
-
</dasar-button>
|
|
57
|
-
}
|
|
58
|
-
</div>
|
|
59
|
-
}
|
|
60
|
-
</div>
|
|
61
|
-
}
|
|
62
|
-
<div
|
|
63
|
-
class="dasar-card-body"
|
|
64
|
-
[class.fluid]="bodyFluid"
|
|
65
|
-
[ngClass]="bodyClass"
|
|
66
|
-
[ngStyle]="bodyStyle"
|
|
67
|
-
>
|
|
68
|
-
<ng-content></ng-content>
|
|
69
|
-
</div>
|
|
70
|
-
@if (hasAction) {
|
|
71
|
-
<div
|
|
72
|
-
class="dasar-card-actions"
|
|
73
|
-
[class.fluid]="actionFluid"
|
|
74
|
-
[ngClass]="actionClass"
|
|
75
|
-
[ngStyle]="actionStyle"
|
|
76
|
-
>
|
|
77
|
-
<ng-content select="[action-slot]"></ng-content>
|
|
78
|
-
</div>
|
|
79
|
-
}
|
|
80
|
-
</div>
|