@pecb-ui/components 1.1.2 → 1.2.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 (56) hide show
  1. package/README.md +556 -556
  2. package/fesm2022/pecb-ui-components.mjs +3826 -1945
  3. package/fesm2022/pecb-ui-components.mjs.map +1 -1
  4. package/index.d.ts +3937 -3
  5. package/package.json +6 -8
  6. package/esm2022/lib/components/button/button.component.mjs +0 -171
  7. package/esm2022/lib/components/card/card.component.mjs +0 -182
  8. package/esm2022/lib/components/checkbox/checkbox.component.mjs +0 -126
  9. package/esm2022/lib/components/datepicker/datepicker.component.mjs +0 -349
  10. package/esm2022/lib/components/dropdown/dropdown.component.mjs +0 -329
  11. package/esm2022/lib/components/input/input.component.mjs +0 -321
  12. package/esm2022/lib/components/pagination/pagination.component.mjs +0 -197
  13. package/esm2022/lib/components/radio/radio.component.mjs +0 -147
  14. package/esm2022/lib/components/right-modal/right-modal.component.mjs +0 -234
  15. package/esm2022/lib/components/sidebar/sidebar.component.mjs +0 -155
  16. package/esm2022/lib/components/status/status.component.mjs +0 -50
  17. package/esm2022/lib/components/tab/tab.component.mjs +0 -151
  18. package/esm2022/lib/components/table/table.component.mjs +0 -503
  19. package/esm2022/lib/components/toggle/toggle.component.mjs +0 -126
  20. package/esm2022/lib/pecb-components.module.mjs +0 -118
  21. package/esm2022/lib/services/loading.service.mjs +0 -182
  22. package/esm2022/lib/services/notification.service.mjs +0 -144
  23. package/esm2022/lib/services/theme.service.mjs +0 -232
  24. package/esm2022/lib/shared/interfaces/component.interfaces.mjs +0 -2
  25. package/esm2022/lib/shared/types/common.types.mjs +0 -6
  26. package/esm2022/lib/shared/utils/accessibility.utils.mjs +0 -223
  27. package/esm2022/lib/shared/utils/dom.utils.mjs +0 -240
  28. package/esm2022/lib/shared/utils/error.utils.mjs +0 -277
  29. package/esm2022/lib/shared/utils/string.utils.mjs +0 -204
  30. package/esm2022/pecb-ui-components.mjs +0 -5
  31. package/esm2022/public-api.mjs +0 -53
  32. package/lib/components/button/button.component.d.ts +0 -130
  33. package/lib/components/card/card.component.d.ts +0 -140
  34. package/lib/components/checkbox/checkbox.component.d.ts +0 -74
  35. package/lib/components/datepicker/datepicker.component.d.ts +0 -155
  36. package/lib/components/dropdown/dropdown.component.d.ts +0 -144
  37. package/lib/components/input/input.component.d.ts +0 -215
  38. package/lib/components/pagination/pagination.component.d.ts +0 -53
  39. package/lib/components/radio/radio.component.d.ts +0 -93
  40. package/lib/components/right-modal/right-modal.component.d.ts +0 -137
  41. package/lib/components/sidebar/sidebar.component.d.ts +0 -97
  42. package/lib/components/status/status.component.d.ts +0 -19
  43. package/lib/components/tab/tab.component.d.ts +0 -102
  44. package/lib/components/table/table.component.d.ts +0 -403
  45. package/lib/components/toggle/toggle.component.d.ts +0 -74
  46. package/lib/pecb-components.module.d.ts +0 -37
  47. package/lib/services/loading.service.d.ts +0 -129
  48. package/lib/services/notification.service.d.ts +0 -136
  49. package/lib/services/theme.service.d.ts +0 -142
  50. package/lib/shared/interfaces/component.interfaces.d.ts +0 -283
  51. package/lib/shared/types/common.types.d.ts +0 -86
  52. package/lib/shared/utils/accessibility.utils.d.ts +0 -167
  53. package/lib/shared/utils/dom.utils.d.ts +0 -108
  54. package/lib/shared/utils/error.utils.d.ts +0 -191
  55. package/lib/shared/utils/string.utils.d.ts +0 -144
  56. package/public-api.d.ts +0 -24
@@ -1,403 +0,0 @@
1
- import { EventEmitter, TemplateRef, Type } from '@angular/core';
2
- import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
3
- import { PageChangeEvent } from '../pagination/pagination.component';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * Defines the available table sizes
7
- */
8
- export type TableSize = 'sm' | 'md' | 'lg';
9
- /**
10
- * Defines the available table variants
11
- */
12
- export type TableVariant = 'default' | 'striped' | 'bordered';
13
- /**
14
- * Defines built-in column types
15
- */
16
- export type PecbTableColumnType = 'text' | 'status' | 'action' | 'user' | 'custom';
17
- /**
18
- * Defines built-in component names for columns
19
- */
20
- export type PecbTableColumnComponent = 'status' | 'action' | 'user';
21
- /**
22
- * Action button definition for action columns
23
- */
24
- export interface TableAction {
25
- /** Unique identifier for the action */
26
- id: string;
27
- /** Icon name or type */
28
- icon: 'view' | 'edit' | 'delete' | 'download' | 'copy' | 'custom';
29
- /** Tooltip/title text */
30
- tooltip?: string;
31
- /** Custom icon SVG (when icon is 'custom') */
32
- customIcon?: string;
33
- /** Whether the action is disabled */
34
- disabled?: boolean;
35
- /** Variant for styling (e.g., 'danger' for delete) */
36
- variant?: 'default' | 'danger';
37
- /** Click handler for this specific action */
38
- action?: (row: any, index: number) => void;
39
- }
40
- /**
41
- * Status mapping configuration
42
- */
43
- export interface TableStatusConfig {
44
- /** Map of value to status type */
45
- typeMap?: Record<string, string>;
46
- /** Status variant */
47
- variant?: 'accent' | 'filled' | 'outline';
48
- /** Status size */
49
- size?: 'sm' | 'md' | 'lg';
50
- }
51
- /**
52
- * User cell configuration
53
- */
54
- export interface TableUserConfig {
55
- /** Key for the avatar/image URL */
56
- avatarKey?: string;
57
- /** Key for the name */
58
- nameKey?: string;
59
- /** Key for the secondary text (e.g., email) */
60
- secondaryKey?: string;
61
- }
62
- /**
63
- * Column definition for the table
64
- */
65
- export interface PecbTableColumn {
66
- /** Unique key for the column, used to access data */
67
- key: string;
68
- /** Display label for the column header */
69
- label: string;
70
- /** Width of the column (e.g., '200px', '20%', 'auto') */
71
- width?: string;
72
- /** Alignment of the column content */
73
- align?: 'left' | 'center' | 'right';
74
- /** Whether the column is sortable */
75
- sortable?: boolean;
76
- /** Custom template reference for cell content */
77
- cellTemplate?: TemplateRef<any>;
78
- /** Custom template reference for header content */
79
- headerTemplate?: TemplateRef<any>;
80
- /** CSS class to apply to the column */
81
- cssClass?: string;
82
- /** Built-in column type (deprecated, use 'component' instead) */
83
- type?: PecbTableColumnType;
84
- /** Built-in component to render: 'status', 'action', 'user' */
85
- component?: PecbTableColumnComponent;
86
- /** Dynamic component class to render in the cell (e.g., StatusComponent) */
87
- dynamicComponent?: Type<any>;
88
- /** Inputs to pass to the dynamic component */
89
- componentInputs?: Record<string, any>;
90
- /** Function to generate dynamic inputs based on row data */
91
- componentInputsFn?: (row: any, value: any, index: number) => Record<string, any>;
92
- /** Action buttons configuration (when component is 'action') */
93
- actions?: TableAction[];
94
- /** Status configuration (when component is 'status') */
95
- statusConfig?: TableStatusConfig;
96
- /** User cell configuration (when component is 'user') */
97
- userConfig?: TableUserConfig;
98
- }
99
- /**
100
- * Sort event emitted when a sortable column is clicked
101
- */
102
- export interface TableSortEvent {
103
- /** Column key that was sorted */
104
- column: string;
105
- /** Sort direction */
106
- direction: 'asc' | 'desc' | null;
107
- }
108
- /**
109
- * Row action event emitted when an action button is clicked
110
- */
111
- export interface TableRowActionEvent {
112
- /** Type of action performed */
113
- action: string;
114
- /** Row data for the action */
115
- row: any;
116
- /** Row index */
117
- index: number;
118
- }
119
- /**
120
- * Row selection event emitted when rows are selected/deselected
121
- */
122
- export interface TableSelectionEvent {
123
- /** Selected rows data */
124
- selectedRows: any[];
125
- /** Selected row indices */
126
- selectedIndices: number[];
127
- }
128
- /**
129
- * Table component for displaying tabular data with pagination support.
130
- *
131
- * @example
132
- * ```html
133
- * <pecb-table
134
- * [columns]="columns"
135
- * [data]="tableData"
136
- * [showPagination]="true"
137
- * [totalItems]="500"
138
- * [pageSize]="15"
139
- * (pageChange)="onPageChange($event)"
140
- * (rowAction)="onRowAction($event)">
141
- * </pecb-table>
142
- * ```
143
- */
144
- export declare class TableComponent {
145
- private sanitizer;
146
- constructor(sanitizer: DomSanitizer);
147
- /**
148
- * Column definitions for the table
149
- */
150
- columns: PecbTableColumn[];
151
- /**
152
- * Data array to display in the table
153
- */
154
- data: any[];
155
- /**
156
- * Size variant of the table
157
- * @default 'md'
158
- */
159
- size: TableSize;
160
- /**
161
- * Visual variant of the table
162
- * @default 'default'
163
- */
164
- variant: TableVariant;
165
- /**
166
- * Whether to show the table header
167
- * @default true
168
- */
169
- showHeader: boolean;
170
- /**
171
- * Whether to enable row hover effect
172
- * @default true
173
- */
174
- hoverable: boolean;
175
- /**
176
- * Whether to show pagination
177
- * @default true
178
- */
179
- showPagination: boolean;
180
- /**
181
- * Total number of items for pagination
182
- */
183
- totalItems: number;
184
- /**
185
- * Current page number (1-based)
186
- * @default 1
187
- */
188
- currentPage: number;
189
- /**
190
- * Number of items per page
191
- * @default 15
192
- */
193
- pageSize: number;
194
- /**
195
- * Available page size options
196
- */
197
- pageSizeOptions: number[];
198
- /**
199
- * Whether to show page size selector in pagination
200
- * @default true
201
- */
202
- showPageSizeSelector: boolean;
203
- /**
204
- * Pagination variant
205
- * @default 'full'
206
- */
207
- paginationVariant: 'full' | 'compact' | 'minimal' | 'centered';
208
- /**
209
- * Message to display when there is no data
210
- */
211
- emptyMessage: string;
212
- /**
213
- * Whether to show loading state
214
- * @default false
215
- */
216
- loading: boolean;
217
- /**
218
- * Whether to enable row selection
219
- * @default false
220
- */
221
- selectable: boolean;
222
- /**
223
- * Currently selected row indices
224
- */
225
- selectedIndices: number[];
226
- /**
227
- * Whether the table has a fixed header
228
- * @default false
229
- */
230
- stickyHeader: boolean;
231
- /**
232
- * Maximum height of the table body (enables scrolling)
233
- */
234
- maxHeight?: string;
235
- /**
236
- * Column key currently being sorted
237
- */
238
- sortColumn?: string;
239
- /**
240
- * Current sort direction
241
- */
242
- sortDirection: 'asc' | 'desc' | null;
243
- /**
244
- * ARIA label for the table
245
- */
246
- ariaLabel: string;
247
- /**
248
- * Emitted when a page change occurs
249
- */
250
- pageChange: EventEmitter<PageChangeEvent>;
251
- /**
252
- * Emitted when page size changes
253
- */
254
- pageSizeChange: EventEmitter<number>;
255
- /**
256
- * Emitted when a row is clicked
257
- */
258
- rowClick: EventEmitter<{
259
- row: any;
260
- index: number;
261
- }>;
262
- /**
263
- * Emitted when a row action is triggered
264
- */
265
- rowAction: EventEmitter<TableRowActionEvent>;
266
- /**
267
- * Emitted when sorting changes
268
- */
269
- sortChange: EventEmitter<TableSortEvent>;
270
- /**
271
- * Emitted when row selection changes
272
- */
273
- selectionChange: EventEmitter<TableSelectionEvent>;
274
- /**
275
- * Custom template for empty state
276
- */
277
- emptyTemplate?: TemplateRef<any>;
278
- /**
279
- * Custom template for loading state
280
- */
281
- loadingTemplate?: TemplateRef<any>;
282
- /**
283
- * Gets the CSS classes for the table container
284
- */
285
- get containerClasses(): string;
286
- /**
287
- * Gets the CSS classes for the pagination container
288
- */
289
- get paginationClasses(): string;
290
- /**
291
- * Gets the CSS classes for the table element
292
- */
293
- get tableClasses(): string;
294
- /**
295
- * Gets the value from a row for a given column key
296
- * Supports nested keys like 'user.name'
297
- */
298
- getCellValue(row: any, key: string): any;
299
- /**
300
- * Gets the alignment class for a column
301
- */
302
- getAlignmentClass(column: PecbTableColumn): string;
303
- /**
304
- * Handles row click events
305
- */
306
- onRowClick(row: any, index: number): void;
307
- /**
308
- * Handles row action button clicks
309
- */
310
- onRowAction(action: string, row: any, index: number, event: Event): void;
311
- /**
312
- * Handles column header click for sorting
313
- */
314
- onHeaderClick(column: PecbTableColumn): void;
315
- /**
316
- * Toggles row selection
317
- */
318
- toggleRowSelection(index: number): void;
319
- /**
320
- * Toggles all rows selection
321
- */
322
- toggleAllSelection(): void;
323
- /**
324
- * Checks if a row is selected
325
- */
326
- isRowSelected(index: number): boolean;
327
- /**
328
- * Checks if all rows are selected
329
- */
330
- isAllSelected(): boolean;
331
- /**
332
- * Checks if some rows are selected (for indeterminate state)
333
- */
334
- isSomeSelected(): boolean;
335
- /**
336
- * Handles page change from pagination component
337
- */
338
- onPageChange(event: PageChangeEvent): void;
339
- /**
340
- * Handles page size change from pagination component
341
- */
342
- onPageSizeChange(newSize: number): void;
343
- /**
344
- * Gets the sort icon state for a column
345
- */
346
- getSortState(column: PecbTableColumn): 'asc' | 'desc' | 'none';
347
- /**
348
- * Tracks rows by index for ngFor performance
349
- */
350
- trackByIndex(index: number): number;
351
- /**
352
- * Tracks columns by key for ngFor performance
353
- */
354
- trackByKey(_: number, column: PecbTableColumn): string;
355
- /**
356
- * Gets the effective column type (supports both 'type' and 'component' properties)
357
- */
358
- getColumnType(column: PecbTableColumn): string;
359
- /**
360
- * Gets the status type for a value based on column config
361
- */
362
- getStatusType(value: any, column: PecbTableColumn): any;
363
- /**
364
- * Gets the status variant for a column
365
- */
366
- getStatusVariant(column: PecbTableColumn): any;
367
- /**
368
- * Gets the status size for a column
369
- */
370
- getStatusSize(column: PecbTableColumn): any;
371
- /**
372
- * Gets user display data from row
373
- */
374
- getUserData(row: any, column: PecbTableColumn): {
375
- avatar: string;
376
- name: string;
377
- secondary: string;
378
- };
379
- /**
380
- * Gets default actions if none specified
381
- */
382
- getActions(column: PecbTableColumn): TableAction[];
383
- /**
384
- * Handles action button click
385
- */
386
- onActionClick(action: TableAction, row: any, index: number, event: Event): void;
387
- /**
388
- * Gets the inputs for a dynamic component
389
- * Combines static componentInputs with row-specific data from componentInputsFn
390
- */
391
- getDynamicComponentInputs(row: any, column: PecbTableColumn, index: number): Record<string, any>;
392
- /**
393
- * Checks if column has a dynamic component
394
- */
395
- hasDynamicComponent(column: PecbTableColumn): boolean;
396
- /**
397
- * Sanitizes custom icon SVG for safe rendering
398
- */
399
- getSafeIcon(iconSvg: string | undefined): SafeHtml;
400
- private emitSelectionChange;
401
- static ɵfac: i0.ɵɵFactoryDeclaration<TableComponent, never>;
402
- static ɵcmp: i0.ɵɵComponentDeclaration<TableComponent, "pecb-table", never, { "columns": { "alias": "columns"; "required": false; }; "data": { "alias": "data"; "required": false; }; "size": { "alias": "size"; "required": false; }; "variant": { "alias": "variant"; "required": false; }; "showHeader": { "alias": "showHeader"; "required": false; }; "hoverable": { "alias": "hoverable"; "required": false; }; "showPagination": { "alias": "showPagination"; "required": false; }; "totalItems": { "alias": "totalItems"; "required": false; }; "currentPage": { "alias": "currentPage"; "required": false; }; "pageSize": { "alias": "pageSize"; "required": false; }; "pageSizeOptions": { "alias": "pageSizeOptions"; "required": false; }; "showPageSizeSelector": { "alias": "showPageSizeSelector"; "required": false; }; "paginationVariant": { "alias": "paginationVariant"; "required": false; }; "emptyMessage": { "alias": "emptyMessage"; "required": false; }; "loading": { "alias": "loading"; "required": false; }; "selectable": { "alias": "selectable"; "required": false; }; "selectedIndices": { "alias": "selectedIndices"; "required": false; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; }; "maxHeight": { "alias": "maxHeight"; "required": false; }; "sortColumn": { "alias": "sortColumn"; "required": false; }; "sortDirection": { "alias": "sortDirection"; "required": false; }; "ariaLabel": { "alias": "aria-label"; "required": false; }; }, { "pageChange": "pageChange"; "pageSizeChange": "pageSizeChange"; "rowClick": "rowClick"; "rowAction": "rowAction"; "sortChange": "sortChange"; "selectionChange": "selectionChange"; }, ["emptyTemplate", "loadingTemplate"], never, true, never>;
403
- }
@@ -1,74 +0,0 @@
1
- import { EventEmitter, ChangeDetectorRef } from '@angular/core';
2
- import { ControlValueAccessor } from '@angular/forms';
3
- import * as i0 from "@angular/core";
4
- export type ToggleLabelPosition = 'right' | 'left';
5
- /**
6
- * A professional toggle/switch component with label and description support.
7
- * Fully accessible with WCAG 2.1 AA compliance and reactive forms support.
8
- *
9
- * @example
10
- * ```html
11
- * <pecb-toggle
12
- * label="Enable notifications"
13
- * description="Receive email notifications"
14
- * [(ngModel)]="notificationsEnabled"
15
- * ></pecb-toggle>
16
- * ```
17
- *
18
- * @publicApi
19
- */
20
- export declare class ToggleComponent implements ControlValueAccessor {
21
- private cdr;
22
- /**
23
- * Unique ID for the toggle element
24
- */
25
- id: string;
26
- /**
27
- * Name attribute for the toggle
28
- */
29
- name?: string;
30
- /**
31
- * Label text to display
32
- */
33
- label?: string;
34
- /**
35
- * Description text to display below label
36
- */
37
- description?: string;
38
- /**
39
- * Position of the label relative to the toggle control.
40
- * 'right' (default): [toggle] Title Description
41
- * 'left': Title Description [toggle]
42
- */
43
- labelPosition: ToggleLabelPosition;
44
- /**
45
- * Whether the toggle is disabled
46
- */
47
- disabled: boolean;
48
- /**
49
- * Event emitted when toggle state changes
50
- */
51
- toggleChange: EventEmitter<boolean>;
52
- checked: boolean;
53
- private onChange;
54
- private onTouched;
55
- constructor(cdr: ChangeDetectorRef);
56
- /**
57
- * Get CSS classes for the toggle wrapper
58
- */
59
- get wrapperClasses(): string[];
60
- /**
61
- * Handle toggle change
62
- */
63
- onToggleChange(event: Event): void;
64
- /**
65
- * Handle blur event
66
- */
67
- onBlur(): void;
68
- writeValue(value: boolean): void;
69
- registerOnChange(fn: (value: boolean) => void): void;
70
- registerOnTouched(fn: () => void): void;
71
- setDisabledState(isDisabled: boolean): void;
72
- static ɵfac: i0.ɵɵFactoryDeclaration<ToggleComponent, never>;
73
- static ɵcmp: i0.ɵɵComponentDeclaration<ToggleComponent, "pecb-toggle", never, { "id": { "alias": "id"; "required": false; }; "name": { "alias": "name"; "required": false; }; "label": { "alias": "label"; "required": false; }; "description": { "alias": "description"; "required": false; }; "labelPosition": { "alias": "labelPosition"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; }, { "toggleChange": "toggleChange"; }, never, never, true, never>;
74
- }
@@ -1,37 +0,0 @@
1
- import * as i0 from "@angular/core";
2
- import * as i1 from "@angular/common";
3
- import * as i2 from "./components/button/button.component";
4
- import * as i3 from "./components/card/card.component";
5
- import * as i4 from "./components/status/status.component";
6
- import * as i5 from "./components/pagination/pagination.component";
7
- import * as i6 from "./components/table/table.component";
8
- import * as i7 from "./components/tab/tab.component";
9
- import * as i8 from "./components/datepicker/datepicker.component";
10
- import * as i9 from "./components/input/input.component";
11
- import * as i10 from "./components/radio/radio.component";
12
- import * as i11 from "./components/checkbox/checkbox.component";
13
- import * as i12 from "./components/toggle/toggle.component";
14
- import * as i13 from "./components/dropdown/dropdown.component";
15
- import * as i14 from "./components/right-modal/right-modal.component";
16
- import * as i15 from "./components/sidebar/sidebar.component";
17
- /**
18
- * PECB UI Components Module
19
- *
20
- * A professional Angular components library with TypeScript and SCSS.
21
- * Import this module to use all PECB UI components in your application.
22
- *
23
- * @example
24
- * ```typescript
25
- * import { PecbComponentsModule } from '@pecb-ui/components';
26
- *
27
- * @NgModule({
28
- * imports: [PecbComponentsModule]
29
- * })
30
- * export class AppModule { }
31
- * ```
32
- */
33
- export declare class PecbComponentsModule {
34
- static ɵfac: i0.ɵɵFactoryDeclaration<PecbComponentsModule, never>;
35
- static ɵmod: i0.ɵɵNgModuleDeclaration<PecbComponentsModule, never, [typeof i1.CommonModule, typeof i2.ButtonComponent, typeof i3.CardComponent, typeof i3.CardHeaderComponent, typeof i3.CardBodyComponent, typeof i3.CardFooterComponent, typeof i4.StatusComponent, typeof i5.PaginationComponent, typeof i6.TableComponent, typeof i7.TabComponent, typeof i8.DatepickerComponent, typeof i9.InputComponent, typeof i10.RadioComponent, typeof i11.CheckboxComponent, typeof i12.ToggleComponent, typeof i13.DropdownComponent, typeof i14.RightModalComponent, typeof i14.RightModalHeaderDirective, typeof i14.RightModalContentDirective, typeof i14.RightModalFooterDirective, typeof i15.SidebarComponent], [typeof i2.ButtonComponent, typeof i3.CardComponent, typeof i3.CardHeaderComponent, typeof i3.CardBodyComponent, typeof i3.CardFooterComponent, typeof i4.StatusComponent, typeof i5.PaginationComponent, typeof i6.TableComponent, typeof i7.TabComponent, typeof i8.DatepickerComponent, typeof i9.InputComponent, typeof i10.RadioComponent, typeof i11.CheckboxComponent, typeof i12.ToggleComponent, typeof i13.DropdownComponent, typeof i14.RightModalComponent, typeof i14.RightModalHeaderDirective, typeof i14.RightModalContentDirective, typeof i14.RightModalFooterDirective, typeof i15.SidebarComponent]>;
36
- static ɵinj: i0.ɵɵInjectorDeclaration<PecbComponentsModule>;
37
- }
@@ -1,129 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import * as i0 from "@angular/core";
3
- /**
4
- * Loading state for a specific operation
5
- */
6
- export interface LoadingState {
7
- /** Unique identifier for the loading operation */
8
- id: string;
9
- /** Whether this operation is currently loading */
10
- isLoading: boolean;
11
- /** Optional message to display */
12
- message?: string;
13
- /** Optional progress percentage (0-100) */
14
- progress?: number;
15
- }
16
- /**
17
- * A stateless, injectable loading service for managing loading states.
18
- *
19
- * This service provides a centralized way to track loading states across
20
- * the application, supporting multiple concurrent loading operations with
21
- * individual tracking capabilities.
22
- *
23
- * @example
24
- * ```typescript
25
- * import { LoadingService } from '@pecb-ui/components';
26
- *
27
- * @Component({...})
28
- * export class MyComponent {
29
- * isLoading$ = this.loadingService.isLoading$('my-operation');
30
- *
31
- * constructor(private loadingService: LoadingService) {}
32
- *
33
- * async loadData(): Promise<void> {
34
- * this.loadingService.start('my-operation', 'Loading data...');
35
- * try {
36
- * await this.fetchData();
37
- * } finally {
38
- * this.loadingService.stop('my-operation');
39
- * }
40
- * }
41
- * }
42
- * ```
43
- *
44
- * @publicApi
45
- */
46
- export declare class LoadingService {
47
- private readonly loadingStates;
48
- private readonly statesSubject;
49
- /** Default loading operation ID */
50
- private readonly defaultId;
51
- /**
52
- * Observable of all loading states
53
- */
54
- get states$(): Observable<Map<string, LoadingState>>;
55
- /**
56
- * Observable that emits true when any loading operation is active
57
- */
58
- get isAnyLoading$(): Observable<boolean>;
59
- /**
60
- * Get observable for a specific loading operation
61
- * @param id - The loading operation identifier
62
- */
63
- isLoading$(id?: string): Observable<boolean>;
64
- /**
65
- * Get observable for loading state with message
66
- * @param id - The loading operation identifier
67
- */
68
- getState$(id?: string): Observable<LoadingState | undefined>;
69
- /**
70
- * Check if a specific operation is currently loading (synchronous)
71
- * @param id - The loading operation identifier
72
- */
73
- isLoading(id?: string): boolean;
74
- /**
75
- * Check if any operation is currently loading (synchronous)
76
- */
77
- isAnyLoading(): boolean;
78
- /**
79
- * Start a loading operation
80
- * @param id - The loading operation identifier
81
- * @param message - Optional message to display
82
- */
83
- start(id?: string, message?: string): void;
84
- /**
85
- * Stop a loading operation
86
- * @param id - The loading operation identifier
87
- */
88
- stop(id?: string): void;
89
- /**
90
- * Update progress for a loading operation
91
- * @param id - The loading operation identifier
92
- * @param progress - Progress percentage (0-100)
93
- * @param message - Optional updated message
94
- */
95
- setProgress(id: string, progress: number, message?: string): void;
96
- /**
97
- * Update the message for a loading operation
98
- * @param id - The loading operation identifier
99
- * @param message - New message to display
100
- */
101
- setMessage(id: string, message: string): void;
102
- /**
103
- * Stop all loading operations
104
- */
105
- stopAll(): void;
106
- /**
107
- * Remove a loading state completely
108
- * @param id - The loading operation identifier
109
- */
110
- remove(id: string): void;
111
- /**
112
- * Execute an async operation with automatic loading state management
113
- * @param id - The loading operation identifier
114
- * @param operation - The async operation to execute
115
- * @param message - Optional loading message
116
- * @returns The result of the operation
117
- */
118
- withLoading<T>(id: string, operation: () => Promise<T>, message?: string): Promise<T>;
119
- /**
120
- * Update a loading state
121
- */
122
- private updateState;
123
- /**
124
- * Emit current states to subscribers
125
- */
126
- private emitStates;
127
- static ɵfac: i0.ɵɵFactoryDeclaration<LoadingService, never>;
128
- static ɵprov: i0.ɵɵInjectableDeclaration<LoadingService>;
129
- }