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,337 +0,0 @@
1
- import {
2
- booleanAttribute,
3
- Component,
4
- Input,
5
- Output,
6
- EventEmitter,
7
- ViewEncapsulation,
8
- ContentChild,
9
- Directive,
10
- HostBinding,
11
- forwardRef,
12
- inject,
13
- ChangeDetectorRef,
14
- } from '@angular/core';
15
- import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
16
- import { CommonModule } from '@angular/common';
17
-
18
- import { DASAR_THEME_PROVIDER } from '../dasar-theme-provider/dasar-theme-provider';
19
- import { ClassType, StyleType, ScaleAttributeType } from '../../models/type.model';
20
- import { DasarThemeService } from '../../services/theme.service';
21
- import { DasarButton } from '../dasar-button/dasar-button';
22
- import { resolveThemeDefault } from '../../utils/common';
23
- import { DasarIcon } from '../dasar-icon/dasar-icon';
24
-
25
- export type DasarNumberInputSize = Extract<ScaleAttributeType, 'xs' | 'sm' | 'md' | 'lg' | 'xl'>;
26
- export type DasarNumberInputAppearanceType = 'outline' | 'filled';
27
- export type DasarNumberInputRadiusType = ScaleAttributeType;
28
-
29
- export interface DasarNumberInputConfig {
30
- appearance?: DasarNumberInputAppearanceType;
31
- radius?: DasarNumberInputRadiusType;
32
- size?: DasarNumberInputSize;
33
- label?: string;
34
- labelRight?: string;
35
- placeholder?: string;
36
- hint?: string;
37
- step?: number;
38
- min?: number;
39
- max?: number;
40
- disabled?: boolean;
41
- fullWidth?: boolean;
42
- error?: boolean;
43
- containerClass?: ClassType;
44
- inputClass?: ClassType;
45
- hostClass?: ClassType;
46
- hintClass?: ClassType;
47
- containerStyle?: StyleType;
48
- inputStyle?: StyleType;
49
- hintStyle?: StyleType;
50
- hideOverflow?: boolean;
51
- }
52
-
53
- @Directive({ selector: '[extra-label-slot]', standalone: true })
54
- export class DasarNumberInputExtraLabelSlot {}
55
- @Directive({ selector: '[prefix-slot]', standalone: true })
56
- export class DasarNumberInputPrefixSlot {}
57
- @Directive({ selector: '[decrement-slot]', standalone: true })
58
- export class DasarNumberInputDecrementSlot {}
59
- @Directive({ selector: '[increment-slot]', standalone: true })
60
- export class DasarNumberInputIncrementSlot {}
61
-
62
- @Component({
63
- providers: [
64
- {
65
- useExisting: forwardRef(() => DasarNumberInput),
66
- provide: NG_VALUE_ACCESSOR,
67
- multi: true,
68
- },
69
- ],
70
- imports: [CommonModule, FormsModule, DasarIcon, DasarButton],
71
- templateUrl: './dasar-number-input.html',
72
- styleUrls: ['./dasar-number-input.scss'],
73
- encapsulation: ViewEncapsulation.None,
74
- selector: 'dasar-number-input',
75
- standalone: true,
76
- })
77
- export class DasarNumberInput implements ControlValueAccessor {
78
- @ContentChild(DasarNumberInputExtraLabelSlot)
79
- providedExtraLabelSlot?: DasarNumberInputExtraLabelSlot;
80
- @ContentChild(DasarNumberInputDecrementSlot) providedDecrement?: DasarNumberInputDecrementSlot;
81
- @ContentChild(DasarNumberInputIncrementSlot) providedIncrement?: DasarNumberInputIncrementSlot;
82
- @ContentChild(DasarNumberInputPrefixSlot) providedPrefix?: DasarNumberInputPrefixSlot;
83
-
84
- private themeProvider = inject(DASAR_THEME_PROVIDER, { optional: true });
85
- private themeService = inject(DasarThemeService, { optional: true });
86
- private cdr = inject(ChangeDetectorRef);
87
-
88
- @Input() appearance = resolveThemeDefault(
89
- 'numberInput',
90
- 'appearance',
91
- 'outline',
92
- this.themeProvider,
93
- this.themeService,
94
- );
95
- @Input() radius = resolveThemeDefault(
96
- 'numberInput',
97
- 'radius',
98
- 'md',
99
- this.themeProvider,
100
- this.themeService,
101
- );
102
- @Input() size = resolveThemeDefault(
103
- 'numberInput',
104
- 'size',
105
- 'md',
106
- this.themeProvider,
107
- this.themeService,
108
- );
109
- @Input() label = resolveThemeDefault(
110
- 'numberInput',
111
- 'label',
112
- undefined,
113
- this.themeProvider,
114
- this.themeService,
115
- );
116
- @Input() labelRight = resolveThemeDefault(
117
- 'numberInput',
118
- 'labelRight',
119
- undefined,
120
- this.themeProvider,
121
- this.themeService,
122
- );
123
- @Input() placeholder = resolveThemeDefault(
124
- 'numberInput',
125
- 'placeholder',
126
- '',
127
- this.themeProvider,
128
- this.themeService,
129
- );
130
- @Input() hint = resolveThemeDefault(
131
- 'numberInput',
132
- 'hint',
133
- '',
134
- this.themeProvider,
135
- this.themeService,
136
- );
137
- @Input() step = resolveThemeDefault(
138
- 'numberInput',
139
- 'step',
140
- 1,
141
- this.themeProvider,
142
- this.themeService,
143
- );
144
- @Input() min = resolveThemeDefault(
145
- 'numberInput',
146
- 'min',
147
- undefined,
148
- this.themeProvider,
149
- this.themeService,
150
- );
151
- @Input() max = resolveThemeDefault(
152
- 'numberInput',
153
- 'max',
154
- undefined,
155
- this.themeProvider,
156
- this.themeService,
157
- );
158
- @Input({ transform: booleanAttribute }) disabled = resolveThemeDefault(
159
- 'numberInput',
160
- 'disabled',
161
- false,
162
- this.themeProvider,
163
- this.themeService,
164
- );
165
-
166
- @Input({ transform: booleanAttribute, alias: 'full-width' }) fullWidth = resolveThemeDefault(
167
- 'numberInput',
168
- 'fullWidth',
169
- false,
170
- this.themeProvider,
171
- this.themeService,
172
- );
173
- @Input({ transform: booleanAttribute }) error = resolveThemeDefault(
174
- 'numberInput',
175
- 'error',
176
- false,
177
- this.themeProvider,
178
- this.themeService,
179
- );
180
- @Input('container-class') containerClass = resolveThemeDefault(
181
- 'numberInput',
182
- 'containerClass',
183
- null,
184
- this.themeProvider,
185
- this.themeService,
186
- );
187
- @Input('input-class') inputClass = resolveThemeDefault(
188
- 'numberInput',
189
- 'inputClass',
190
- null,
191
- this.themeProvider,
192
- this.themeService,
193
- );
194
- @Input('host-class') hostClass = resolveThemeDefault(
195
- 'numberInput',
196
- 'hostClass',
197
- null,
198
- this.themeProvider,
199
- this.themeService,
200
- );
201
- @Input('hint-class') hintClass = resolveThemeDefault(
202
- 'numberInput',
203
- 'hintClass',
204
- null,
205
- this.themeProvider,
206
- this.themeService,
207
- );
208
- @Input('container-style') containerStyle = resolveThemeDefault(
209
- 'numberInput',
210
- 'containerStyle',
211
- null,
212
- this.themeProvider,
213
- this.themeService,
214
- );
215
- @Input('input-style') inputStyle = resolveThemeDefault(
216
- 'numberInput',
217
- 'inputStyle',
218
- null,
219
- this.themeProvider,
220
- this.themeService,
221
- );
222
- @Input('hint-style') hintStyle = resolveThemeDefault(
223
- 'numberInput',
224
- 'hintStyle',
225
- null,
226
- this.themeProvider,
227
- this.themeService,
228
- );
229
- @Input({ alias: 'hide-overflow', transform: booleanAttribute }) hideOverflow =
230
- resolveThemeDefault('card', 'hideOverflow', false, this.themeProvider, this.themeService);
231
-
232
- @Output() valueChange = new EventEmitter<number | null>();
233
- @Output() onIncrementClick = new EventEmitter<number>();
234
- @Output() onDecrementClick = new EventEmitter<number>();
235
- @Output() onInputFocus = new EventEmitter<FocusEvent>();
236
- @Output() onInputBlur = new EventEmitter<FocusEvent>();
237
- @Output() onInputChange = new EventEmitter<Event>();
238
-
239
- @HostBinding('class.dasar-number-input') readonly baseClass = true;
240
- @HostBinding('class.full-width') get hasFullWidth(): boolean {
241
- return this.fullWidth;
242
- }
243
- @HostBinding('class.disabled') get isDisabled(): boolean {
244
- return this.disabled;
245
- }
246
-
247
- private _value: number | null = null;
248
- @Input()
249
- get value(): number | null {
250
- return this._value;
251
- }
252
- set value(val: number | null) {
253
- if (this._value !== val) {
254
- this._value = val;
255
- this.cdr.markForCheck();
256
- }
257
- }
258
- onTouched: any = () => {};
259
- onChange: any = () => {};
260
-
261
- get hasDecrementSlot(): boolean {
262
- return !!this.providedDecrement;
263
- }
264
- get hasIncrementSlot(): boolean {
265
- return !!this.providedIncrement;
266
- }
267
- get hasExtraLabelSlot(): boolean {
268
- return !!this.providedExtraLabelSlot;
269
- }
270
- get hasPrefixSlot(): boolean {
271
- return !!this.providedPrefix;
272
- }
273
-
274
- writeValue(value: any): void {
275
- const parsedValue =
276
- value === null || value === undefined || value === '' ? null : Number(value);
277
- this._value = parsedValue;
278
- this.cdr.markForCheck();
279
- }
280
- registerOnChange(fn: any): void {
281
- this.onChange = fn;
282
- }
283
- registerOnTouched(fn: any): void {
284
- this.onTouched = fn;
285
- }
286
- setDisabledState(isDisabled: boolean): void {
287
- this.disabled = isDisabled;
288
- this.cdr.markForCheck();
289
- }
290
- onDecrement(event: MouseEvent): void {
291
- if (this.disabled) return;
292
- event.preventDefault();
293
- const currentValue = this.value ?? 0;
294
- const newValue = currentValue - this.step;
295
- if (this.min === undefined || newValue >= this.min) {
296
- this.updateValue(newValue);
297
- this.onDecrementClick.emit(newValue);
298
- }
299
- }
300
- onIncrement(event: MouseEvent): void {
301
- if (this.disabled) return;
302
- event.preventDefault();
303
- const currentValue = this.value ?? 0;
304
- const newValue = currentValue + this.step;
305
- if (this.max === undefined || newValue <= this.max) {
306
- this.updateValue(newValue);
307
- this.onIncrementClick.emit(newValue);
308
- }
309
- }
310
- onInput(event: Event): void {
311
- const inputElement = event.target as HTMLInputElement;
312
- const parsedValue = inputElement.value === '' ? null : Number(inputElement.value);
313
- this.updateValue(parsedValue);
314
- this.onInputChange.emit(event);
315
- }
316
- onFocus(event: FocusEvent): void {
317
- this.onInputFocus.emit(event);
318
- }
319
- onBlur(event: FocusEvent): void {
320
- this.onTouched();
321
- this.onInputBlur.emit(event);
322
- }
323
- private updateValue(newValue: number | null): void {
324
- if (this._value !== newValue) {
325
- this._value = newValue;
326
- this.onChange(newValue);
327
- this.valueChange.emit(newValue);
328
- this.cdr.markForCheck();
329
- }
330
- }
331
- }
332
- export const DasarNumberInputComponent = [
333
- DasarNumberInputDecrementSlot,
334
- DasarNumberInputIncrementSlot,
335
- DasarNumberInputPrefixSlot,
336
- DasarNumberInput,
337
- ] as const;
@@ -1,98 +0,0 @@
1
- <nav class="dasar-pagination-container size-{{ size }}">
2
- <ul class="dasar-pagination-list">
3
- @if (showFirstLast) {
4
- <li>
5
- <dasar-button
6
- [variant]="appearance === 'outline' ? 'ghost' : 'primary'"
7
- [appearance]="appearance === 'solid' ? 'outline' : appearance"
8
- [size]="size"
9
- [radius]="radius"
10
- [disabled]="currentPage === 1 || disabled"
11
- (click)="goToPage(1)"
12
- class="dasar-pagination-btn"
13
- aria-label="First page"
14
- >
15
- &laquo;
16
- </dasar-button>
17
- </li>
18
- }
19
-
20
- <li>
21
- <dasar-button
22
- [variant]="appearance === 'outline' ? 'ghost' : 'primary'"
23
- [appearance]="appearance === 'solid' ? 'outline' : appearance"
24
- [size]="size"
25
- [radius]="radius"
26
- [disabled]="currentPage === 1 || disabled"
27
- (click)="goToPage(currentPage - 1)"
28
- class="dasar-pagination-btn"
29
- aria-label="Previous page"
30
- >
31
- &lsaquo;
32
- </dasar-button>
33
- </li>
34
-
35
- @for (page of pages; track $index) {
36
- <li>
37
- @if (page === '...') {
38
- <span class="dasar-pagination-ellipsis">...</span>
39
- } @else {
40
- <dasar-button
41
- [variant]="
42
- currentPage === page ? 'primary' : appearance === 'outline' ? 'ghost' : 'secondary'
43
- "
44
- [appearance]="
45
- currentPage === page
46
- ? appearance === 'outline'
47
- ? 'solid'
48
- : appearance
49
- : appearance === 'solid'
50
- ? 'outline'
51
- : appearance
52
- "
53
- [size]="size"
54
- [radius]="radius"
55
- [disabled]="disabled"
56
- (click)="goToPage(page)"
57
- class="dasar-pagination-btn"
58
- [class.active]="currentPage === page"
59
- >
60
- {{ page }}
61
- </dasar-button>
62
- }
63
- </li>
64
- }
65
-
66
- <li>
67
- <dasar-button
68
- [variant]="appearance === 'outline' ? 'ghost' : 'primary'"
69
- [appearance]="appearance === 'solid' ? 'outline' : appearance"
70
- [size]="size"
71
- [radius]="radius"
72
- [disabled]="currentPage === totalPages || disabled"
73
- (click)="goToPage(currentPage + 1)"
74
- class="dasar-pagination-btn"
75
- aria-label="Next page"
76
- >
77
- &rsaquo;
78
- </dasar-button>
79
- </li>
80
-
81
- @if (showFirstLast) {
82
- <li>
83
- <dasar-button
84
- [variant]="appearance === 'outline' ? 'ghost' : 'primary'"
85
- [appearance]="appearance === 'solid' ? 'outline' : appearance"
86
- [size]="size"
87
- [radius]="radius"
88
- [disabled]="currentPage === totalPages || disabled"
89
- (click)="goToPage(totalPages)"
90
- class="dasar-pagination-btn"
91
- aria-label="Last page"
92
- >
93
- &raquo;
94
- </dasar-button>
95
- </li>
96
- }
97
- </ul>
98
- </nav>
@@ -1,51 +0,0 @@
1
- @use '../../styles/theme.scss' as *;
2
-
3
- .dasar-pagination-container {
4
- display: inline-flex;
5
- align-items: center;
6
- justify-content: center;
7
- width: 100%;
8
-
9
- .dasar-pagination-list {
10
- display: inline-flex;
11
- align-items: center;
12
- list-style: none;
13
- padding: 0;
14
- margin: 0;
15
- gap: $dasar-space-1;
16
- flex-wrap: wrap;
17
-
18
- li {
19
- display: inline-flex;
20
- align-items: center;
21
- justify-content: center;
22
- }
23
- }
24
-
25
- .dasar-pagination-btn {
26
- ::ng-deep .dasar-button-native {
27
- min-width: $dasar-space-10;
28
- padding-left: $dasar-space-base;
29
- padding-right: $dasar-space-base;
30
- }
31
- }
32
-
33
- &.size-sm .dasar-pagination-btn ::ng-deep .dasar-button-native {
34
- min-width: $dasar-space-8;
35
- }
36
-
37
- &.size-lg .dasar-pagination-btn ::ng-deep .dasar-button-native {
38
- min-width: $dasar-space-12;
39
- }
40
-
41
- .dasar-pagination-ellipsis {
42
- display: inline-flex;
43
- align-items: center;
44
- justify-content: center;
45
- color: var(--theme-text-secondary-color);
46
- font-weight: var(--font-weight-medium, $dasar-font-weight-medium);
47
- padding: 0 $dasar-space-base;
48
- letter-spacing: 2px;
49
- user-select: none;
50
- }
51
- }
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DasarPagination } from './dasar-pagination';
3
-
4
- describe('DasarPagination', () => {
5
- let component: DasarPagination;
6
- let fixture: ComponentFixture<DasarPagination>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [DasarPagination],
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(DasarPagination);
14
- component = fixture.componentInstance;
15
- await fixture.whenStable();
16
- });
17
-
18
- it('should create', () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,99 +0,0 @@
1
- import {
2
- Component,
3
- Input,
4
- Output,
5
- EventEmitter,
6
- booleanAttribute,
7
- computed,
8
- signal,
9
- effect,
10
- } from '@angular/core';
11
- import { CommonModule } from '@angular/common';
12
- import { DasarButtonComponent } from '../dasar-button/dasar-button'; // Adjust path as needed
13
-
14
- export type DasarPaginationRadiusType = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
15
- export type DasarPaginationAppearanceType = 'solid' | 'subtle' | 'outline';
16
- export type DasarPaginationSizeType = 'sm' | 'md' | 'lg';
17
-
18
- @Component({
19
- imports: [CommonModule, DasarButtonComponent],
20
- templateUrl: './dasar-pagination.html',
21
- styleUrls: ['./dasar-pagination.scss'],
22
- selector: 'dasar-pagination',
23
- standalone: true,
24
- })
25
- export class DasarPagination {
26
- @Input({ transform: booleanAttribute }) showFirstLast: boolean = true;
27
- @Input({ transform: booleanAttribute }) disabled: boolean = false;
28
- @Input() appearance: DasarPaginationAppearanceType = 'solid';
29
- @Input() radius: DasarPaginationRadiusType = 'md';
30
- @Input() size: DasarPaginationSizeType = 'md';
31
- @Input() siblingCount: number = 1;
32
- @Input() currentPage: number = 1;
33
- @Input() pageSize: number = 10;
34
- @Input() totalItems: number = 0;
35
-
36
- @Output() pageChange = new EventEmitter<number>();
37
-
38
- get totalPages(): number {
39
- return Math.ceil(this.totalItems / this.pageSize);
40
- }
41
-
42
- get pages(): (number | string)[] {
43
- const totalPages = this.totalPages;
44
- const siblingCount = this.siblingCount;
45
- const currentPage = this.currentPage;
46
- const totalPageNumbers = siblingCount + 5;
47
-
48
- if (totalPageNumbers >= totalPages) {
49
- return this.range(1, totalPages);
50
- }
51
-
52
- const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);
53
- const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPages);
54
- const showLeftDots = leftSiblingIndex > 2;
55
- const showRightDots = rightSiblingIndex < totalPages - 2;
56
- const firstPageIndex = 1;
57
- const lastPageIndex = totalPages;
58
-
59
- if (!showLeftDots && showRightDots) {
60
- const leftItemCount = 3 + 2 * siblingCount;
61
- const leftRange = this.range(1, leftItemCount);
62
- return [...leftRange, '...', totalPages];
63
- }
64
-
65
- if (showLeftDots && !showRightDots) {
66
- const rightItemCount = 3 + 2 * siblingCount;
67
- const rightRange = this.range(totalPages - rightItemCount + 1, totalPages);
68
- return [firstPageIndex, '...', ...rightRange];
69
- }
70
-
71
- if (showLeftDots && showRightDots) {
72
- const middleRange = this.range(leftSiblingIndex, rightSiblingIndex);
73
- return [firstPageIndex, '...', ...middleRange, '...', lastPageIndex];
74
- }
75
-
76
- return [];
77
- }
78
-
79
- private range(start: number, end: number): number[] {
80
- const length = end - start + 1;
81
- return Array.from({ length }, (_, idx) => idx + start);
82
- }
83
-
84
- goToPage(page: number | string) {
85
- if (
86
- typeof page === 'string' ||
87
- page === this.currentPage ||
88
- page < 1 ||
89
- page > this.totalPages ||
90
- this.disabled
91
- ) {
92
- return;
93
- }
94
- this.currentPage = page;
95
- this.pageChange.emit(this.currentPage);
96
- }
97
- }
98
-
99
- export const DasarPaginationComponent = [DasarPagination] as const;
@@ -1 +0,0 @@
1
- <p>dasar-pin works!</p>
@@ -1,21 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
- import { DasarPin } from './dasar-pin';
3
-
4
- describe('DasarPin', () => {
5
- let component: DasarPin;
6
- let fixture: ComponentFixture<DasarPin>;
7
-
8
- beforeEach(async () => {
9
- await TestBed.configureTestingModule({
10
- imports: [DasarPin],
11
- }).compileComponents();
12
-
13
- fixture = TestBed.createComponent(DasarPin);
14
- component = fixture.componentInstance;
15
- await fixture.whenStable();
16
- });
17
-
18
- it('should create', () => {
19
- expect(component).toBeTruthy();
20
- });
21
- });
@@ -1,9 +0,0 @@
1
- import { Component } from '@angular/core';
2
-
3
- @Component({
4
- imports: [],
5
- selector: 'dasar-dasar-pin',
6
- styleUrl: './dasar-pin.css',
7
- templateUrl: './dasar-pin.html',
8
- })
9
- export class DasarPin {}