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.
Files changed (116) hide show
  1. package/README.md +19 -14
  2. package/fesm2022/dasar-ui.mjs +9664 -0
  3. package/fesm2022/dasar-ui.mjs.map +1 -0
  4. package/package.json +39 -42
  5. package/types/dasar-ui.d.ts +2114 -0
  6. package/.editorconfig +0 -17
  7. package/.nvmrc +0 -1
  8. package/.prettierrc +0 -12
  9. package/.vscode/extensions.json +0 -4
  10. package/.vscode/launch.json +0 -20
  11. package/.vscode/settings.json +0 -4
  12. package/.vscode/tasks.json +0 -42
  13. package/CHANGELOG.md +0 -18
  14. package/angular.json +0 -37
  15. package/projects/dasar-ui/README.md +0 -64
  16. package/projects/dasar-ui/ng-package.json +0 -10
  17. package/projects/dasar-ui/package.json +0 -27
  18. package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.html +0 -9
  19. package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.scss +0 -352
  20. package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.spec.ts +0 -21
  21. package/projects/dasar-ui/src/lib/components/dasar-button/dasar-button.ts +0 -154
  22. package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.html +0 -1
  23. package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.scss +0 -69
  24. package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.spec.ts +0 -21
  25. package/projects/dasar-ui/src/lib/components/dasar-button-group/dasar-button-group.ts +0 -30
  26. package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.html +0 -158
  27. package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.scss +0 -371
  28. package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.spec.ts +0 -21
  29. package/projects/dasar-ui/src/lib/components/dasar-calendar/dasar-calendar.ts +0 -458
  30. package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.html +0 -80
  31. package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.scss +0 -184
  32. package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.spec.ts +0 -21
  33. package/projects/dasar-ui/src/lib/components/dasar-card/dasar-card.ts +0 -294
  34. package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.html +0 -42
  35. package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.scss +0 -38
  36. package/projects/dasar-ui/src/lib/components/dasar-chip/dasar-chip.ts +0 -207
  37. package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.html +0 -102
  38. package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.scss +0 -301
  39. package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.spec.ts +0 -21
  40. package/projects/dasar-ui/src/lib/components/dasar-datepicker/dasar-datepicker.ts +0 -527
  41. package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.html +0 -1
  42. package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.registry.ts +0 -5089
  43. package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.scss +0 -24
  44. package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.spec.ts +0 -21
  45. package/projects/dasar-ui/src/lib/components/dasar-icon/dasar-icon.ts +0 -97
  46. package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.html +0 -54
  47. package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.scss +0 -281
  48. package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.spec.ts +0 -21
  49. package/projects/dasar-ui/src/lib/components/dasar-input/dasar-input.ts +0 -323
  50. package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.html +0 -63
  51. package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.scss +0 -195
  52. package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.spec.ts +0 -21
  53. package/projects/dasar-ui/src/lib/components/dasar-menu/dasar-menu.ts +0 -240
  54. package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.html +0 -90
  55. package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.scss +0 -358
  56. package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.spec.ts +0 -21
  57. package/projects/dasar-ui/src/lib/components/dasar-number-input/dasar-number-input.ts +0 -337
  58. package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.html +0 -98
  59. package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.scss +0 -51
  60. package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.spec.ts +0 -21
  61. package/projects/dasar-ui/src/lib/components/dasar-pagination/dasar-pagination.ts +0 -99
  62. package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.css +0 -0
  63. package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.html +0 -1
  64. package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.spec.ts +0 -21
  65. package/projects/dasar-ui/src/lib/components/dasar-pin/dasar-pin.ts +0 -9
  66. package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.html +0 -163
  67. package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.scss +0 -283
  68. package/projects/dasar-ui/src/lib/components/dasar-pivot-table/dasar-pivot-table.ts +0 -230
  69. package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.css +0 -0
  70. package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.html +0 -1
  71. package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.spec.ts +0 -21
  72. package/projects/dasar-ui/src/lib/components/dasar-radio/dasar-radio.ts +0 -9
  73. package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.html +0 -185
  74. package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.scss +0 -347
  75. package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.spec.ts +0 -21
  76. package/projects/dasar-ui/src/lib/components/dasar-select/dasar-select.ts +0 -497
  77. package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.css +0 -0
  78. package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.html +0 -1
  79. package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.spec.ts +0 -21
  80. package/projects/dasar-ui/src/lib/components/dasar-slider/dasar-slider.ts +0 -9
  81. package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.html +0 -162
  82. package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.scss +0 -283
  83. package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.spec.ts +0 -21
  84. package/projects/dasar-ui/src/lib/components/dasar-table/dasar-table.ts +0 -380
  85. package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.html +0 -41
  86. package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.scss +0 -126
  87. package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.spec.ts +0 -21
  88. package/projects/dasar-ui/src/lib/components/dasar-tabs/dasar-tabs.ts +0 -72
  89. package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.html +0 -43
  90. package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.scss +0 -189
  91. package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.spec.ts +0 -21
  92. package/projects/dasar-ui/src/lib/components/dasar-textarea/dasar-textarea.ts +0 -139
  93. package/projects/dasar-ui/src/lib/components/dasar-theme-provider/dasar-theme-provider.ts +0 -286
  94. package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.css +0 -0
  95. package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.html +0 -1
  96. package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.spec.ts +0 -21
  97. package/projects/dasar-ui/src/lib/components/dasar-toast/dasar-toast.ts +0 -9
  98. package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.css +0 -0
  99. package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.html +0 -1
  100. package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.spec.ts +0 -21
  101. package/projects/dasar-ui/src/lib/components/dasar-toggle/dasar-toggle.ts +0 -9
  102. package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.css +0 -0
  103. package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.html +0 -1
  104. package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.spec.ts +0 -21
  105. package/projects/dasar-ui/src/lib/components/dasar-tooltip/dasar-tooltip.ts +0 -9
  106. package/projects/dasar-ui/src/lib/models/theme.model.ts +0 -643
  107. package/projects/dasar-ui/src/lib/models/type.model.ts +0 -11
  108. package/projects/dasar-ui/src/lib/services/theme.service.ts +0 -643
  109. package/projects/dasar-ui/src/lib/styles/theme.ts +0 -70
  110. package/projects/dasar-ui/src/lib/utils/common.ts +0 -175
  111. package/projects/dasar-ui/src/public-api.ts +0 -23
  112. package/projects/dasar-ui/tsconfig.lib.json +0 -21
  113. package/projects/dasar-ui/tsconfig.lib.prod.json +0 -11
  114. package/projects/dasar-ui/tsconfig.spec.json +0 -11
  115. package/tsconfig.json +0 -37
  116. /package/{projects/dasar-ui/src/lib/styles → styles}/theme.scss +0 -0
@@ -1,527 +0,0 @@
1
- import {
2
- Component,
3
- Input,
4
- Output,
5
- EventEmitter,
6
- booleanAttribute,
7
- ElementRef,
8
- HostListener,
9
- OnInit,
10
- forwardRef,
11
- inject,
12
- ChangeDetectorRef,
13
- ViewEncapsulation,
14
- Directive,
15
- ContentChild,
16
- HostBinding,
17
- ViewChild,
18
- } from '@angular/core';
19
- import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
20
- import { DASAR_THEME_PROVIDER } from '../dasar-theme-provider/dasar-theme-provider';
21
- import { ClassType, StyleType, ScaleAttributeType } from '../../models/type.model';
22
- import { DasarCalendarComponent } from '../dasar-calendar/dasar-calendar';
23
- import { resolveThemeDefault, safeFormat } 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
- import { CommonModule } from '@angular/common';
28
-
29
- export type DasarDatepickerPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end';
30
- export type DasarDatepickerSize = Extract<ScaleAttributeType, 'sm' | 'md' | 'lg'>;
31
- export type DasarDatepickerAppearance = 'outline' | 'filled' | 'subtle';
32
- export type DasarDatepickerRadius = ScaleAttributeType;
33
- export type DasarDatepickerType = 'date';
34
-
35
- export interface DasarDatepickerConfig {
36
- fullWidth?: boolean;
37
- clearable?: boolean;
38
- disabled?: boolean;
39
- fluid?: boolean;
40
- error?: boolean;
41
- displayFormat?: string;
42
- valueFormat?: string;
43
- placement?: DasarDatepickerPlacement;
44
- appearance?: DasarDatepickerAppearance;
45
- extraLabel?: string;
46
- placeholder?: string;
47
- radius?: DasarDatepickerRadius;
48
- type?: DasarDatepickerType;
49
- size?: DasarDatepickerSize;
50
- locale?: string;
51
- label?: string;
52
- hint?: string;
53
- containerClass?: ClassType;
54
- wrapperClass?: ClassType;
55
- triggerClass?: ClassType;
56
- dropdownClass?: ClassType;
57
- labelWrapperClass?: ClassType;
58
- hintWrapperClass?: ClassType;
59
- wrapperStyle?: StyleType;
60
- triggerStyle?: StyleType;
61
- labelWrapperStyle?: StyleType;
62
- hintWrapperStyle?: StyleType;
63
- containerStyle?: StyleType;
64
- dropdownStyle?: StyleType;
65
- }
66
-
67
- @Directive({ selector: '[prefix-slot]', standalone: true })
68
- export class DasarDatepickerPrefixSlot {}
69
- @Directive({ selector: '[label-slot]', standalone: true })
70
- export class DasarDatepickerLabelSlot {}
71
- @Directive({ selector: '[extra-label-slot]', standalone: true })
72
- export class DasarDatepickerExtraLabelSlot {}
73
- @Directive({ selector: '[extra-header-slot]', standalone: true })
74
- export class DasarDatepickerExtraHeaderSlot {}
75
- @Directive({ selector: '[extra-footer-slot]', standalone: true })
76
- export class DasarDatepickerExtraFooterSlot {}
77
- @Directive({ selector: '[hint-slot]', standalone: true })
78
- export class DasarDatepickerHintSlot {}
79
-
80
- @Component({
81
- selector: 'dasar-datepicker',
82
- standalone: true,
83
- imports: [
84
- CommonModule,
85
- FormsModule,
86
- DasarCalendarComponent,
87
- DasarIconComponent,
88
- DasarButtonComponent,
89
- ],
90
- templateUrl: './dasar-datepicker.html',
91
- styleUrls: ['./dasar-datepicker.scss'],
92
- encapsulation: ViewEncapsulation.None,
93
- providers: [
94
- {
95
- provide: NG_VALUE_ACCESSOR,
96
- useExisting: forwardRef(() => DasarDatepicker),
97
- multi: true,
98
- },
99
- ],
100
- })
101
- export class DasarDatepicker implements OnInit, ControlValueAccessor {
102
- private themeProvider = inject(DASAR_THEME_PROVIDER, { optional: true });
103
- private themeService = inject(DasarThemeService, { optional: true });
104
- private cdr = inject(ChangeDetectorRef);
105
- private elementRef = inject(ElementRef);
106
-
107
- @ContentChild(DasarDatepickerExtraHeaderSlot) extraHeaderSlot?: DasarDatepickerExtraHeaderSlot;
108
- @ContentChild(DasarDatepickerExtraFooterSlot) extraFooterSlot?: DasarDatepickerExtraFooterSlot;
109
- @ContentChild(DasarDatepickerExtraLabelSlot) extraLabelSlot?: DasarDatepickerExtraLabelSlot;
110
- @ContentChild(DasarDatepickerLabelSlot) labelSlot?: DasarDatepickerLabelSlot;
111
- @ContentChild(DasarDatepickerHintSlot) hintSlot?: DasarDatepickerHintSlot;
112
- @ContentChild(DasarDatepickerPrefixSlot) prefixSlot?: DasarDatepickerPrefixSlot;
113
-
114
- @ViewChild('triggerElement') triggerEl?: ElementRef<HTMLElement>;
115
- @ViewChild('dropdownElement') dropdownEl?: ElementRef<HTMLElement>;
116
-
117
- @Input({ alias: 'display-format' }) displayFormat = resolveThemeDefault(
118
- 'datepicker',
119
- 'displayFormat',
120
- 'DD-MM-YYYY',
121
- this.themeProvider,
122
- this.themeService,
123
- );
124
- @Input({ alias: 'value-format' }) valueFormat = resolveThemeDefault(
125
- 'datepicker',
126
- 'valueFormat',
127
- 'yyyy-MM-dd',
128
- this.themeProvider,
129
- this.themeService,
130
- );
131
- @Input() locale = resolveThemeDefault(
132
- 'datepicker',
133
- 'locale',
134
- 'en-US',
135
- this.themeProvider,
136
- this.themeService,
137
- );
138
- @Input() placement = resolveThemeDefault(
139
- 'datepicker',
140
- 'placement',
141
- 'bottom-start',
142
- this.themeProvider,
143
- this.themeService,
144
- );
145
- @Input() appearance = resolveThemeDefault(
146
- 'datepicker',
147
- 'appearance',
148
- 'outline',
149
- this.themeProvider,
150
- this.themeService,
151
- );
152
- @Input() radius = resolveThemeDefault(
153
- 'datepicker',
154
- 'radius',
155
- 'md',
156
- this.themeProvider,
157
- this.themeService,
158
- );
159
- @Input() type = resolveThemeDefault(
160
- 'datepicker',
161
- 'type',
162
- 'date',
163
- this.themeProvider,
164
- this.themeService,
165
- );
166
- @Input() size = resolveThemeDefault(
167
- 'datepicker',
168
- 'size',
169
- 'md',
170
- this.themeProvider,
171
- this.themeService,
172
- );
173
- @Input() placeholder = resolveThemeDefault(
174
- 'datepicker',
175
- 'placeholder',
176
- 'Select date',
177
- this.themeProvider,
178
- this.themeService,
179
- );
180
- @Input() label = resolveThemeDefault(
181
- 'datepicker',
182
- 'label',
183
- undefined,
184
- this.themeProvider,
185
- this.themeService,
186
- );
187
- @Input({ alias: 'extra-label' }) extraLabel = resolveThemeDefault(
188
- 'datepicker',
189
- 'extraLabel',
190
- undefined,
191
- this.themeProvider,
192
- this.themeService,
193
- );
194
- @Input() hint = resolveThemeDefault(
195
- 'datepicker',
196
- 'hint',
197
- undefined,
198
- this.themeProvider,
199
- this.themeService,
200
- );
201
- @Input({ alias: 'container-class' }) containerClass = resolveThemeDefault(
202
- 'datepicker',
203
- 'containerClass',
204
- null,
205
- this.themeProvider,
206
- this.themeService,
207
- );
208
- @Input({ alias: 'wrapper-class' }) wrapperClass = resolveThemeDefault(
209
- 'datepicker',
210
- 'wrapperClass',
211
- null,
212
- this.themeProvider,
213
- this.themeService,
214
- );
215
- @Input({ alias: 'trigger-class' }) triggerClass = resolveThemeDefault(
216
- 'datepicker',
217
- 'triggerClass',
218
- null,
219
- this.themeProvider,
220
- this.themeService,
221
- );
222
- @Input({ alias: 'dropdown-class' }) dropdownClass = resolveThemeDefault(
223
- 'datepicker',
224
- 'dropdownClass',
225
- null,
226
- this.themeProvider,
227
- this.themeService,
228
- );
229
- @Input({ alias: 'label-wrapper-class' }) labelWrapperClass = resolveThemeDefault(
230
- 'datepicker',
231
- 'labelWrapperClass',
232
- null,
233
- this.themeProvider,
234
- this.themeService,
235
- );
236
- @Input({ alias: 'hint-wrapper-class' }) hintWrapperClass = resolveThemeDefault(
237
- 'datepicker',
238
- 'hintWrapperClass',
239
- null,
240
- this.themeProvider,
241
- this.themeService,
242
- );
243
- @Input({ alias: 'container-style' }) containerStyle = resolveThemeDefault(
244
- 'datepicker',
245
- 'containerStyle',
246
- null,
247
- this.themeProvider,
248
- this.themeService,
249
- );
250
- @Input({ alias: 'wrapper-style' }) wrapperStyle = resolveThemeDefault(
251
- 'datepicker',
252
- 'wrapperStyle',
253
- null,
254
- this.themeProvider,
255
- this.themeService,
256
- );
257
- @Input({ alias: 'trigger-style' }) triggerStyle = resolveThemeDefault(
258
- 'datepicker',
259
- 'triggerStyle',
260
- null,
261
- this.themeProvider,
262
- this.themeService,
263
- );
264
- @Input({ alias: 'dropdown-style' }) dropdownStyle = resolveThemeDefault(
265
- 'datepicker',
266
- 'dropdownStyle',
267
- null,
268
- this.themeProvider,
269
- this.themeService,
270
- );
271
- @Input({ alias: 'label-wrapper-style' }) labelWrapperStyle = resolveThemeDefault(
272
- 'datepicker',
273
- 'labelWrapperStyle',
274
- null,
275
- this.themeProvider,
276
- this.themeService,
277
- );
278
- @Input({ alias: 'hint-wrapper-style' }) hintWrapperStyle = resolveThemeDefault(
279
- 'datepicker',
280
- 'hintWrapperStyle',
281
- null,
282
- this.themeProvider,
283
- this.themeService,
284
- );
285
- @Input({ alias: 'full-width', transform: booleanAttribute }) fullWidth = resolveThemeDefault(
286
- 'datepicker',
287
- 'fullWidth',
288
- false,
289
- this.themeProvider,
290
- this.themeService,
291
- );
292
- @Input({ transform: booleanAttribute }) clearable = resolveThemeDefault(
293
- 'datepicker',
294
- 'clearable',
295
- false,
296
- this.themeProvider,
297
- this.themeService,
298
- );
299
- @Input({ transform: booleanAttribute }) disabled = resolveThemeDefault(
300
- 'datepicker',
301
- 'disabled',
302
- false,
303
- this.themeProvider,
304
- this.themeService,
305
- );
306
- @Input({ transform: booleanAttribute }) fluid = resolveThemeDefault(
307
- 'datepicker',
308
- 'fluid',
309
- false,
310
- this.themeProvider,
311
- this.themeService,
312
- );
313
- @Input({ transform: booleanAttribute }) error = resolveThemeDefault(
314
- 'datepicker',
315
- 'error',
316
- false,
317
- this.themeProvider,
318
- this.themeService,
319
- );
320
-
321
- @Output() valueChange = new EventEmitter<any>();
322
- @Output() onDateSelected = new EventEmitter<any>();
323
- @Output() onInitialized = new EventEmitter<void>();
324
- @Output() onClickIn = new EventEmitter<Event>();
325
- @Output() onClickOut = new EventEmitter<Event>();
326
-
327
- @Output() onNextMonthClick = new EventEmitter<void>();
328
- @Output() onPrevMonthClick = new EventEmitter<void>();
329
- @Output() onNextYearClick = new EventEmitter<void>();
330
- @Output() onPrevYearClick = new EventEmitter<void>();
331
-
332
- @Output() onCleared = new EventEmitter<void>();
333
- @Output() onCouched = new EventEmitter<void>();
334
- @Output() onFocus = new EventEmitter<Event | void>();
335
- @Output() onBlur = new EventEmitter<Event | void>();
336
-
337
- @HostBinding('class.dasar-datepicker') readonly baseClass = true;
338
- @HostBinding('class.full-width') get hasFullWidth(): boolean {
339
- return this.fullWidth;
340
- }
341
- @HostBinding('class.disabled') get isDisabled(): boolean {
342
- return this.disabled;
343
- }
344
-
345
- private _value: any = null;
346
- internalDate: Date | null = null;
347
- isOpen: boolean = false;
348
- private isFocused: boolean = false;
349
-
350
- @Input()
351
- get value(): any {
352
- return this._value;
353
- }
354
- set value(val: any) {
355
- if (this._value !== val) {
356
- this._value = val ?? null;
357
- this.syncInternalDate();
358
- this.cdr.markForCheck();
359
- }
360
- }
361
-
362
- onTouched: any = () => {};
363
- onChange: any = () => {};
364
-
365
- ngOnInit() {
366
- this.syncInternalDate();
367
- this.onInitialized.emit();
368
- }
369
-
370
- get hasLabelRow(): boolean {
371
- return !!(this.label || this.labelSlot || this.extraLabel || this.extraLabelSlot);
372
- }
373
- get hasHintRow(): boolean {
374
- return !!(this.hint || this.hintSlot);
375
- }
376
- get formattedDisplay(): string {
377
- if (!this.internalDate || isNaN(this.internalDate.getTime())) return '';
378
- try {
379
- const formatToUse = () => {
380
- // return this.type === 'datetime' ? `${this.displayFormat} HH:mm` : this.displayFormat;
381
- return this.displayFormat;
382
- };
383
- return safeFormat(this.internalDate, formatToUse(), this.locale);
384
- } catch {
385
- return this.internalDate.toDateString();
386
- }
387
- }
388
-
389
- // Control Value Accessor
390
- writeValue(value: any): void {
391
- if (this._value === value) return;
392
- this._value = value ?? null;
393
- this.syncInternalDate();
394
- this.cdr.markForCheck();
395
- }
396
- registerOnChange(fn: any): void {
397
- this.onChange = fn;
398
- }
399
- registerOnTouched(fn: any): void {
400
- this.onTouched = fn;
401
- }
402
- setDisabledState(isDisabled: boolean): void {
403
- this.disabled = isDisabled;
404
- this.cdr.detectChanges();
405
- }
406
-
407
- // Date Processing
408
- @HostListener('document:click', ['$event'])
409
- onClickOutside(event: Event) {
410
- if (this.isOpen && !this.elementRef.nativeElement.contains(event.target)) {
411
- this.isOpen = false;
412
- this.onClickOut.emit(event);
413
- this.setFocus(false, event); // Emits blur and touched automatically
414
- }
415
- }
416
- private syncInternalDate() {
417
- if (!this._value) {
418
- this.internalDate = null;
419
- return;
420
- }
421
- this.internalDate = new Date(this._value);
422
- }
423
- private setFocus(state: boolean, event?: Event) {
424
- if (this.disabled) return;
425
- if (state !== this.isFocused) {
426
- this.isFocused = state;
427
- if (state) {
428
- this.onFocus.emit(event);
429
- } else {
430
- this.onBlur.emit(event);
431
- this.onTouched();
432
- this.onTouched.emit();
433
- }
434
- }
435
- }
436
- toggleDropdown(event: Event) {
437
- if (this.disabled) return;
438
- this.isOpen = !this.isOpen;
439
-
440
- if (this.isOpen) {
441
- this.onClickIn.emit(event);
442
- this.setFocus(true, event);
443
- // Reset to user requested placement first
444
- this.placement = this.placement;
445
- setTimeout(() => this.calculateSmartPlacement(), 0);
446
- } else {
447
- this.onClickOut.emit(event);
448
- this.setFocus(false, event);
449
- }
450
- }
451
- clearValue(event: Event) {
452
- event.stopPropagation();
453
- if (this.disabled) return;
454
- this._value = null;
455
- this.internalDate = null;
456
- this.onChange(null);
457
- this.valueChange.emit(null);
458
- this.onCleared.emit();
459
- this.setFocus(true, event); // Keep focused after clear
460
- this.cdr.markForCheck();
461
- }
462
- onCalendarSelect(date: Date | null) {
463
- if (!date) return;
464
- this.internalDate = date;
465
-
466
- const returnValue = this.formatReturnValue(date);
467
- this._value = returnValue;
468
-
469
- this.onChange(returnValue);
470
- this.valueChange.emit(returnValue);
471
- this.onDateSelected.emit(returnValue);
472
-
473
- if (this.type === 'date') {
474
- this.isOpen = false;
475
- this.setFocus(false);
476
- }
477
- this.cdr.detectChanges();
478
- }
479
- private formatReturnValue(date: Date): any {
480
- if (!this.valueFormat) return date;
481
- if (this.valueFormat === 'timestamp') return date.getTime();
482
- if (this.valueFormat === 'iso') return date.toISOString();
483
- try {
484
- return safeFormat(date, this.valueFormat, this.locale);
485
- } catch {
486
- return date;
487
- }
488
- }
489
- private calculateSmartPlacement() {
490
- if (!this.triggerEl?.nativeElement || !this.dropdownEl?.nativeElement) return;
491
- const triggerRect = this.triggerEl.nativeElement.getBoundingClientRect();
492
- const dropdownRect = this.dropdownEl.nativeElement.getBoundingClientRect();
493
- // Calculate available space in the browser window
494
- const spaceBelow = window.innerHeight - triggerRect.bottom;
495
- const spaceAbove = triggerRect.top;
496
- // 16px safety margin so it doesn't touch the exact edge of the screen
497
- const requiredSpace = dropdownRect.height + 16;
498
- let newPlacement = this.placement;
499
- if (
500
- newPlacement.startsWith('bottom') &&
501
- spaceBelow < requiredSpace &&
502
- spaceAbove > requiredSpace
503
- ) {
504
- newPlacement = newPlacement.replace('bottom', 'top') as DasarDatepickerPlacement;
505
- } else if (
506
- newPlacement.startsWith('top') &&
507
- spaceAbove < requiredSpace &&
508
- spaceBelow > requiredSpace
509
- ) {
510
- newPlacement = newPlacement.replace('top', 'bottom') as DasarDatepickerPlacement;
511
- }
512
- if (this.placement !== newPlacement) {
513
- this.placement = newPlacement;
514
- this.cdr.detectChanges();
515
- }
516
- }
517
- }
518
-
519
- export const DasarDatepickerComponent = [
520
- DasarDatepicker,
521
- DasarDatepickerLabelSlot,
522
- DasarDatepickerExtraLabelSlot,
523
- DasarDatepickerExtraHeaderSlot,
524
- DasarDatepickerExtraFooterSlot,
525
- DasarDatepickerHintSlot,
526
- DasarDatepickerPrefixSlot,
527
- ] as const;
@@ -1 +0,0 @@
1
- <span class="dasar-icon" [class.fluid]="fluid" [innerHTML]="svgContent"></span>