ngx-com 0.0.19 → 0.0.21
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/fesm2022/ngx-com-components-alert.mjs +346 -0
- package/fesm2022/ngx-com-components-alert.mjs.map +1 -0
- package/fesm2022/ngx-com-components-button.mjs +1 -1
- package/fesm2022/ngx-com-components-button.mjs.map +1 -1
- package/fesm2022/ngx-com-components-calendar.mjs +29 -36
- package/fesm2022/ngx-com-components-calendar.mjs.map +1 -1
- package/fesm2022/ngx-com-components-card.mjs +1 -1
- package/fesm2022/ngx-com-components-card.mjs.map +1 -1
- package/fesm2022/ngx-com-components-carousel.mjs +708 -0
- package/fesm2022/ngx-com-components-carousel.mjs.map +1 -0
- package/fesm2022/ngx-com-components-checkbox.mjs +17 -8
- package/fesm2022/ngx-com-components-checkbox.mjs.map +1 -1
- package/fesm2022/ngx-com-components-code-block.mjs +158 -0
- package/fesm2022/ngx-com-components-code-block.mjs.map +1 -0
- package/fesm2022/ngx-com-components-collapsible.mjs +1 -1
- package/fesm2022/ngx-com-components-collapsible.mjs.map +1 -1
- package/fesm2022/ngx-com-components-confirm.mjs +3 -3
- package/fesm2022/ngx-com-components-confirm.mjs.map +1 -1
- package/fesm2022/ngx-com-components-dialog.mjs +703 -0
- package/fesm2022/ngx-com-components-dialog.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown.mjs +36 -31
- package/fesm2022/ngx-com-components-dropdown.mjs.map +1 -1
- package/fesm2022/ngx-com-components-form-field.mjs +48 -8
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -1
- package/fesm2022/ngx-com-components-item.mjs +1 -1
- package/fesm2022/ngx-com-components-item.mjs.map +1 -1
- package/fesm2022/ngx-com-components-paginator.mjs +3 -3
- package/fesm2022/ngx-com-components-paginator.mjs.map +1 -1
- package/fesm2022/ngx-com-components-radio.mjs +16 -9
- package/fesm2022/ngx-com-components-radio.mjs.map +1 -1
- package/fesm2022/ngx-com-components-segmented-control.mjs +1 -1
- package/fesm2022/ngx-com-components-segmented-control.mjs.map +1 -1
- package/fesm2022/ngx-com-components-separator.mjs +102 -0
- package/fesm2022/ngx-com-components-separator.mjs.map +1 -0
- package/fesm2022/ngx-com-components-switch.mjs +258 -0
- package/fesm2022/ngx-com-components-switch.mjs.map +1 -0
- package/fesm2022/ngx-com-components-table.mjs +631 -0
- package/fesm2022/ngx-com-components-table.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tabs.mjs +2 -2
- package/fesm2022/ngx-com-components-tabs.mjs.map +1 -1
- package/fesm2022/ngx-com-components-toast.mjs +783 -0
- package/fesm2022/ngx-com-components-toast.mjs.map +1 -0
- package/package.json +33 -1
- package/types/ngx-com-components-alert.d.ts +166 -0
- package/types/ngx-com-components-carousel.d.ts +281 -0
- package/types/ngx-com-components-checkbox.d.ts +7 -2
- package/types/ngx-com-components-code-block.d.ts +66 -0
- package/types/ngx-com-components-confirm.d.ts +2 -2
- package/types/ngx-com-components-dialog.d.ts +264 -0
- package/types/ngx-com-components-dropdown.d.ts +8 -5
- package/types/ngx-com-components-form-field.d.ts +19 -3
- package/types/ngx-com-components-radio.d.ts +5 -3
- package/types/ngx-com-components-separator.d.ts +75 -0
- package/types/ngx-com-components-switch.d.ts +110 -0
- package/types/ngx-com-components-table.d.ts +377 -0
- package/types/ngx-com-components-toast.d.ts +217 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Signal, ElementRef, InputSignal, ModelSignal, OutputEmitterRef } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
4
|
+
|
|
5
|
+
/** Switch size variants. */
|
|
6
|
+
type SwitchSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
/** Switch color variants. */
|
|
8
|
+
type SwitchVariant = 'primary' | 'accent' | 'warn';
|
|
9
|
+
/**
|
|
10
|
+
* CVA variants for the switch track (pill-shaped container).
|
|
11
|
+
*
|
|
12
|
+
* Uses `peer` selectors to style based on native input state:
|
|
13
|
+
* - `peer-checked:` for on state
|
|
14
|
+
* - `peer-focus-visible:` for keyboard focus
|
|
15
|
+
* - `peer-disabled:` for disabled state
|
|
16
|
+
*
|
|
17
|
+
* @tokens `--color-primary`, `--color-primary-hover`,
|
|
18
|
+
* `--color-accent`, `--color-accent-hover`,
|
|
19
|
+
* `--color-warn`, `--color-warn-hover`,
|
|
20
|
+
* `--color-muted`, `--color-muted-hover`,
|
|
21
|
+
* `--color-disabled`, `--color-ring`, `--radius-pill`
|
|
22
|
+
*/
|
|
23
|
+
declare const switchTrackVariants: (props?: {
|
|
24
|
+
variant?: SwitchVariant;
|
|
25
|
+
size?: SwitchSize;
|
|
26
|
+
}) => string;
|
|
27
|
+
/** Size-based classes for the sliding thumb. */
|
|
28
|
+
declare const SWITCH_THUMB_SIZES: Record<SwitchSize, string>;
|
|
29
|
+
/** Size-based translate classes applied when the switch is checked. */
|
|
30
|
+
declare const SWITCH_THUMB_TRANSLATE: Record<SwitchSize, string>;
|
|
31
|
+
/** Size-based classes for the label content. */
|
|
32
|
+
declare const SWITCH_LABEL_SIZES: Record<SwitchSize, string>;
|
|
33
|
+
|
|
34
|
+
/** Event emitted when switch state changes. */
|
|
35
|
+
interface SwitchChange {
|
|
36
|
+
checked: boolean;
|
|
37
|
+
source: ComSwitch;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Toggle switch component with full accessibility support.
|
|
41
|
+
*
|
|
42
|
+
* Uses a native `<input type="checkbox" role="switch">` for built-in keyboard
|
|
43
|
+
* handling, `:checked` pseudo-class, and screen reader support.
|
|
44
|
+
*
|
|
45
|
+
* Implements `ControlValueAccessor` for Reactive Forms integration via
|
|
46
|
+
* `NgControl` injection pattern (no `NG_VALUE_ACCESSOR` provider).
|
|
47
|
+
*
|
|
48
|
+
* @tokens `--color-primary`, `--color-primary-hover`,
|
|
49
|
+
* `--color-accent`, `--color-accent-hover`,
|
|
50
|
+
* `--color-warn`, `--color-warn-hover`,
|
|
51
|
+
* `--color-muted`, `--color-muted-hover`,
|
|
52
|
+
* `--color-background`, `--color-disabled`, `--color-disabled-foreground`,
|
|
53
|
+
* `--color-ring`, `--radius-pill`
|
|
54
|
+
*
|
|
55
|
+
* @example Basic usage
|
|
56
|
+
* ```html
|
|
57
|
+
* <com-switch [(checked)]="darkMode">Dark mode</com-switch>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example With reactive forms
|
|
61
|
+
* ```html
|
|
62
|
+
* <com-switch formControlName="notifications">Push notifications</com-switch>
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @example Variants and sizes
|
|
66
|
+
* ```html
|
|
67
|
+
* <com-switch variant="accent" size="lg">Large accent switch</com-switch>
|
|
68
|
+
* <com-switch variant="warn" size="sm">Small warning switch</com-switch>
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare class ComSwitch implements ControlValueAccessor {
|
|
72
|
+
/** Optional NgControl for reactive forms integration. */
|
|
73
|
+
readonly ngControl: NgControl | null;
|
|
74
|
+
/** Reference to the native input element. */
|
|
75
|
+
readonly inputRef: Signal<ElementRef<HTMLInputElement> | undefined>;
|
|
76
|
+
/** Unique ID for this switch instance. */
|
|
77
|
+
private readonly uniqueId;
|
|
78
|
+
readonly size: InputSignal<SwitchSize>;
|
|
79
|
+
readonly variant: InputSignal<SwitchVariant>;
|
|
80
|
+
readonly checked: ModelSignal<boolean>;
|
|
81
|
+
readonly disabled: ModelSignal<boolean>;
|
|
82
|
+
readonly value: InputSignal<string | undefined>;
|
|
83
|
+
readonly name: InputSignal<string | undefined>;
|
|
84
|
+
readonly id: InputSignal<string | undefined>;
|
|
85
|
+
readonly ariaLabel: InputSignal<string | null>;
|
|
86
|
+
readonly ariaLabelledby: InputSignal<string | null>;
|
|
87
|
+
readonly ariaDescribedby: InputSignal<string | null>;
|
|
88
|
+
readonly changed: OutputEmitterRef<SwitchChange>;
|
|
89
|
+
readonly inputId: Signal<string>;
|
|
90
|
+
protected readonly trackClasses: Signal<string>;
|
|
91
|
+
protected readonly thumbClasses: Signal<string>;
|
|
92
|
+
protected readonly labelClasses: Signal<string>;
|
|
93
|
+
private onChange;
|
|
94
|
+
protected onTouched: () => void;
|
|
95
|
+
constructor();
|
|
96
|
+
writeValue(value: boolean): void;
|
|
97
|
+
registerOnChange(fn: (value: boolean) => void): void;
|
|
98
|
+
registerOnTouched(fn: () => void): void;
|
|
99
|
+
setDisabledState(isDisabled: boolean): void;
|
|
100
|
+
protected onInputChange(event: Event): void;
|
|
101
|
+
/** Focuses this switch's input element. */
|
|
102
|
+
focus(): void;
|
|
103
|
+
/** Toggles the switch state programmatically. */
|
|
104
|
+
toggle(): void;
|
|
105
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComSwitch, never>;
|
|
106
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComSwitch, "com-switch", ["comSwitch"], { "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "checked": { "alias": "checked"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "id": { "alias": "id"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "aria-labelledby"; "required": false; "isSignal": true; }; "ariaDescribedby": { "alias": "aria-describedby"; "required": false; "isSignal": true; }; }, { "checked": "checkedChange"; "disabled": "disabledChange"; "changed": "changed"; }, never, ["*"], true, never>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { ComSwitch, SWITCH_LABEL_SIZES, SWITCH_THUMB_SIZES, SWITCH_THUMB_TRANSLATE, switchTrackVariants };
|
|
110
|
+
export type { SwitchChange, SwitchSize, SwitchVariant };
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { TemplateRef, InputSignal, Signal, InputSignalWithTransform, TrackByFunction } from '@angular/core';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Structural directive that captures the template for a header cell.
|
|
7
|
+
*
|
|
8
|
+
* Use with the star syntax inside a `comColumnDef` container.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```html
|
|
12
|
+
* <ng-container comColumnDef="name">
|
|
13
|
+
* <th *comHeaderCellDef>Name</th>
|
|
14
|
+
* <td *comCellDef="let row">{{ row.name }}</td>
|
|
15
|
+
* </ng-container>
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare class ComHeaderCellDef {
|
|
19
|
+
readonly templateRef: TemplateRef<void>;
|
|
20
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComHeaderCellDef, never>;
|
|
21
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComHeaderCellDef, "[comHeaderCellDef]", never, {}, {}, never, never, true, never>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Template context for body cell definitions. */
|
|
25
|
+
interface CellDefContext<T> {
|
|
26
|
+
$implicit: T;
|
|
27
|
+
index: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Structural directive that captures the template for a body cell.
|
|
32
|
+
*
|
|
33
|
+
* Use with the star syntax inside a `comColumnDef` container.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <ng-container comColumnDef="name">
|
|
38
|
+
* <th *comHeaderCellDef>Name</th>
|
|
39
|
+
* <td *comCellDef="let row">{{ row.name }}</td>
|
|
40
|
+
* </ng-container>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare class ComCellDef<T = unknown> {
|
|
44
|
+
readonly templateRef: TemplateRef<CellDefContext<T>>;
|
|
45
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComCellDef<any>, never>;
|
|
46
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComCellDef<any>, "[comCellDef]", never, {}, {}, never, never, true, never>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Structural directive that captures the template for a footer cell.
|
|
51
|
+
*
|
|
52
|
+
* Use with the star syntax inside a `comColumnDef` container.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```html
|
|
56
|
+
* <ng-container comColumnDef="amount">
|
|
57
|
+
* <th *comHeaderCellDef>Amount</th>
|
|
58
|
+
* <td *comCellDef="let row">{{ row.amount | currency }}</td>
|
|
59
|
+
* <td *comFooterCellDef>{{ total() | currency }}</td>
|
|
60
|
+
* </ng-container>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare class ComFooterCellDef {
|
|
64
|
+
readonly templateRef: TemplateRef<void>;
|
|
65
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComFooterCellDef, never>;
|
|
66
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComFooterCellDef, "[comFooterCellDef]", never, {}, {}, never, never, true, never>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Defines a single column in a `com-table`.
|
|
71
|
+
*
|
|
72
|
+
* Contains a header cell template, a body cell template, and an optional footer cell template.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```html
|
|
76
|
+
* <ng-container comColumnDef="name">
|
|
77
|
+
* <th *comHeaderCellDef>Name</th>
|
|
78
|
+
* <td *comCellDef="let row">{{ row.name }}</td>
|
|
79
|
+
* </ng-container>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare class ComColumnDef {
|
|
83
|
+
/** The column name — used to match header/row column lists. */
|
|
84
|
+
readonly name: InputSignal<string>;
|
|
85
|
+
/** @internal Header cell template for this column. */
|
|
86
|
+
readonly headerCellDef: Signal<ComHeaderCellDef | undefined>;
|
|
87
|
+
/** @internal Body cell template for this column. */
|
|
88
|
+
readonly cellDef: Signal<ComCellDef | undefined>;
|
|
89
|
+
/** @internal Optional footer cell template for this column. */
|
|
90
|
+
readonly footerCellDef: Signal<ComFooterCellDef | undefined>;
|
|
91
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComColumnDef, never>;
|
|
92
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComColumnDef, "[comColumnDef]", ["comColumnDef"], { "name": { "alias": "comColumnDef"; "required": true; "isSignal": true; }; }, {}, ["headerCellDef", "cellDef", "footerCellDef"], never, true, never>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Defines which columns appear in the header row and their order.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```html
|
|
100
|
+
* <tr comHeaderRowDef="['name', 'email', 'role']"></tr>
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example Sticky header row
|
|
104
|
+
* ```html
|
|
105
|
+
* <tr comHeaderRowDef="['name', 'email']" comHeaderRowDefSticky></tr>
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare class ComHeaderRowDef {
|
|
109
|
+
/** Ordered list of column names to display. */
|
|
110
|
+
readonly columns: InputSignal<string[]>;
|
|
111
|
+
/** Makes this header row sticky (alternative to table-level `stickyHeader`). */
|
|
112
|
+
readonly sticky: InputSignalWithTransform<boolean, unknown>;
|
|
113
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComHeaderRowDef, never>;
|
|
114
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComHeaderRowDef, "[comHeaderRowDef]", never, { "columns": { "alias": "comHeaderRowDef"; "required": true; "isSignal": true; }; "sticky": { "alias": "comHeaderRowDefSticky"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Defines which columns appear in each body row and their order.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```html
|
|
122
|
+
* <tr comRowDef [comRowDefColumns]="['name', 'email', 'role']"></tr>
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
declare class ComRowDef {
|
|
126
|
+
/** Ordered list of column names to display per body row. */
|
|
127
|
+
readonly columns: InputSignal<string[]>;
|
|
128
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComRowDef, never>;
|
|
129
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComRowDef, "[comRowDef]", never, { "columns": { "alias": "comRowDefColumns"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Defines which columns appear in the footer row and their order.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```html
|
|
137
|
+
* <tr comFooterRowDef="['description', 'amount']"></tr>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
declare class ComFooterRowDef {
|
|
141
|
+
/** Ordered list of column names in the footer. */
|
|
142
|
+
readonly columns: InputSignal<string[]>;
|
|
143
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComFooterRowDef, never>;
|
|
144
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComFooterRowDef, "[comFooterRowDef]", never, { "columns": { "alias": "comFooterRowDef"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Structural directive for the empty-state row shown when the data source is empty.
|
|
149
|
+
*
|
|
150
|
+
* Place inside `com-table`. The template receives the column count for colspan.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```html
|
|
154
|
+
* <com-table [dataSource]="data()">
|
|
155
|
+
* <!-- column defs... -->
|
|
156
|
+
*
|
|
157
|
+
* <ng-template comNoDataRow>
|
|
158
|
+
* <td [attr.colspan]="displayedColumns().length" class="text-center py-8">
|
|
159
|
+
* No results found.
|
|
160
|
+
* </td>
|
|
161
|
+
* </ng-template>
|
|
162
|
+
* </com-table>
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
declare class ComNoDataRow {
|
|
166
|
+
readonly templateRef: TemplateRef<void>;
|
|
167
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComNoDataRow, never>;
|
|
168
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComNoDataRow, "[comNoDataRow]", never, {}, {}, never, never, true, never>;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Abstract data source for ComTable.
|
|
173
|
+
*
|
|
174
|
+
* Implement `connect()` to provide a signal of data, and `disconnect()` to clean up.
|
|
175
|
+
* The table calls `connect()` on init and `disconnect()` on destroy.
|
|
176
|
+
*
|
|
177
|
+
* @example Signal-based data source
|
|
178
|
+
* ```typescript
|
|
179
|
+
* class MyDataSource extends ComDataSource<User> {
|
|
180
|
+
* private readonly data = signal<User[]>([]);
|
|
181
|
+
*
|
|
182
|
+
* connect(): Signal<readonly User[]> {
|
|
183
|
+
* return this.data.asReadonly();
|
|
184
|
+
* }
|
|
185
|
+
*
|
|
186
|
+
* disconnect(): void {
|
|
187
|
+
* // cleanup if needed
|
|
188
|
+
* }
|
|
189
|
+
*
|
|
190
|
+
* setData(users: User[]): void {
|
|
191
|
+
* this.data.set(users);
|
|
192
|
+
* }
|
|
193
|
+
* }
|
|
194
|
+
* ```
|
|
195
|
+
*/
|
|
196
|
+
declare abstract class ComDataSource<T> {
|
|
197
|
+
/** Returns a signal of the current data set. Called once when the table initializes. */
|
|
198
|
+
abstract connect(): Signal<readonly T[]>;
|
|
199
|
+
/** Cleanup resources. Called when the table is destroyed. */
|
|
200
|
+
abstract disconnect(): void;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Simple array-backed data source.
|
|
204
|
+
*
|
|
205
|
+
* Wraps a plain array in a writable signal so it can be used with ComTable's DataSource API.
|
|
206
|
+
*/
|
|
207
|
+
declare class ComArrayDataSource<T> extends ComDataSource<T> {
|
|
208
|
+
private readonly data;
|
|
209
|
+
constructor(initialData?: T[]);
|
|
210
|
+
connect(): Signal<readonly T[]>;
|
|
211
|
+
disconnect(): void;
|
|
212
|
+
/** Replace the entire data set. */
|
|
213
|
+
setData(data: T[]): void;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Type guard to check if a value is a ComDataSource instance.
|
|
217
|
+
*/
|
|
218
|
+
declare function isDataSource<T>(value: unknown): value is ComDataSource<T>;
|
|
219
|
+
/** The types that ComTable accepts for its dataSource input. */
|
|
220
|
+
type ComTableDataSourceInput<T> = T[] | ComDataSource<T>;
|
|
221
|
+
|
|
222
|
+
type TableVariant = 'default' | 'striped';
|
|
223
|
+
type TableDensity = 'compact' | 'default' | 'comfortable';
|
|
224
|
+
/**
|
|
225
|
+
* CVA variants for the table container wrapper.
|
|
226
|
+
*/
|
|
227
|
+
declare const tableContainerVariants: (props?: Record<string, never>) => string;
|
|
228
|
+
type TableContainerVariants = VariantProps<typeof tableContainerVariants>;
|
|
229
|
+
/**
|
|
230
|
+
* CVA variants for the `<table>` element.
|
|
231
|
+
*
|
|
232
|
+
* @tokens `--color-foreground`
|
|
233
|
+
*/
|
|
234
|
+
declare const tableVariants: (props?: Record<string, never>) => string;
|
|
235
|
+
type TableVariants = VariantProps<typeof tableVariants>;
|
|
236
|
+
/**
|
|
237
|
+
* CVA variants for the `<thead>` element.
|
|
238
|
+
*
|
|
239
|
+
* @tokens `--color-background`
|
|
240
|
+
*/
|
|
241
|
+
declare const tableHeaderVariants: (props?: {
|
|
242
|
+
sticky?: boolean;
|
|
243
|
+
}) => string;
|
|
244
|
+
type TableHeaderVariants = VariantProps<typeof tableHeaderVariants>;
|
|
245
|
+
/**
|
|
246
|
+
* CVA variants for `<th>` header cells.
|
|
247
|
+
*
|
|
248
|
+
* @tokens `--color-muted-foreground`
|
|
249
|
+
*/
|
|
250
|
+
declare const tableHeaderCellVariants: (props?: {
|
|
251
|
+
density?: TableDensity;
|
|
252
|
+
}) => string;
|
|
253
|
+
type TableHeaderCellVariants = VariantProps<typeof tableHeaderCellVariants>;
|
|
254
|
+
/**
|
|
255
|
+
* CVA variants for `<tbody> <tr>` rows.
|
|
256
|
+
*
|
|
257
|
+
* @tokens `--color-border-subtle`, `--color-muted`, `--color-muted-hover`
|
|
258
|
+
*/
|
|
259
|
+
declare const tableRowVariants: (props?: {
|
|
260
|
+
variant?: TableVariant;
|
|
261
|
+
}) => string;
|
|
262
|
+
type TableRowVariants = VariantProps<typeof tableRowVariants>;
|
|
263
|
+
/**
|
|
264
|
+
* CVA variants for `<td>` body cells.
|
|
265
|
+
*/
|
|
266
|
+
declare const tableBodyCellVariants: (props?: {
|
|
267
|
+
density?: TableDensity;
|
|
268
|
+
}) => string;
|
|
269
|
+
type TableBodyCellVariants = VariantProps<typeof tableBodyCellVariants>;
|
|
270
|
+
/**
|
|
271
|
+
* CVA variants for `<tfoot> <td>` footer cells.
|
|
272
|
+
*
|
|
273
|
+
* @tokens `--color-foreground`, `--color-border`
|
|
274
|
+
*/
|
|
275
|
+
declare const tableFooterCellVariants: (props?: {
|
|
276
|
+
density?: TableDensity;
|
|
277
|
+
}) => string;
|
|
278
|
+
type TableFooterCellVariants = VariantProps<typeof tableFooterCellVariants>;
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Declarative data table component using native HTML `<table>` semantics.
|
|
282
|
+
*
|
|
283
|
+
* Define columns via `comColumnDef` with `*comHeaderCellDef` and `*comCellDef`,
|
|
284
|
+
* then declare row structure via `comHeaderRowDef` and `comRowDef`.
|
|
285
|
+
*
|
|
286
|
+
* Accepts either a plain `T[]` or a `ComDataSource<T>` for the data source.
|
|
287
|
+
*
|
|
288
|
+
* @tokens `--color-background`, `--color-foreground`, `--color-muted`, `--color-muted-foreground`,
|
|
289
|
+
* `--color-muted-hover`, `--color-border`, `--color-border-subtle`
|
|
290
|
+
*
|
|
291
|
+
* @example Basic table
|
|
292
|
+
* ```html
|
|
293
|
+
* <com-table [dataSource]="users()">
|
|
294
|
+
* <ng-container comColumnDef="name">
|
|
295
|
+
* <th *comHeaderCellDef>Name</th>
|
|
296
|
+
* <td *comCellDef="let row">{{ row.name }}</td>
|
|
297
|
+
* </ng-container>
|
|
298
|
+
*
|
|
299
|
+
* <ng-container comColumnDef="email">
|
|
300
|
+
* <th *comHeaderCellDef>Email</th>
|
|
301
|
+
* <td *comCellDef="let row">{{ row.email }}</td>
|
|
302
|
+
* </ng-container>
|
|
303
|
+
*
|
|
304
|
+
* <tr comHeaderRowDef="['name', 'email']"></tr>
|
|
305
|
+
* <tr comRowDef [comRowDefColumns]="['name', 'email']"></tr>
|
|
306
|
+
* </com-table>
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
309
|
+
* @example With DataSource
|
|
310
|
+
* ```typescript
|
|
311
|
+
* class UserDataSource extends ComDataSource<User> {
|
|
312
|
+
* private data = signal<User[]>([]);
|
|
313
|
+
* connect() { return this.data.asReadonly(); }
|
|
314
|
+
* disconnect() {}
|
|
315
|
+
* setData(users: User[]) { this.data.set(users); }
|
|
316
|
+
* }
|
|
317
|
+
* ```
|
|
318
|
+
* ```html
|
|
319
|
+
* <com-table [dataSource]="userDataSource">
|
|
320
|
+
* ...
|
|
321
|
+
* </com-table>
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
declare class ComTable<T> {
|
|
325
|
+
private readonly destroyRef;
|
|
326
|
+
/** The data to render — accepts a plain array or a ComDataSource. */
|
|
327
|
+
readonly dataSource: InputSignal<ComTableDataSourceInput<T>>;
|
|
328
|
+
/** Track function for `@for`. Defaults to tracking by index. */
|
|
329
|
+
readonly trackByFn: InputSignal<TrackByFunction<T>>;
|
|
330
|
+
/** Visual treatment of body rows. */
|
|
331
|
+
readonly variant: InputSignal<TableVariant>;
|
|
332
|
+
/** Row height / cell padding. */
|
|
333
|
+
readonly density: InputSignal<TableDensity>;
|
|
334
|
+
/** Whether the header row sticks on scroll. */
|
|
335
|
+
readonly stickyHeader: InputSignalWithTransform<boolean, unknown>;
|
|
336
|
+
/** Shows a loading overlay with spinner. */
|
|
337
|
+
readonly loading: InputSignalWithTransform<boolean, unknown>;
|
|
338
|
+
/** Accessible label for the table element. */
|
|
339
|
+
readonly ariaLabel: InputSignal<string | undefined>;
|
|
340
|
+
/** @internal All column definitions projected into the table. */
|
|
341
|
+
readonly columnDefs: Signal<readonly ComColumnDef[]>;
|
|
342
|
+
/** @internal Header row definition. */
|
|
343
|
+
readonly headerRowDef: Signal<ComHeaderRowDef | undefined>;
|
|
344
|
+
/** @internal Body row definition. */
|
|
345
|
+
readonly rowDef: Signal<ComRowDef | undefined>;
|
|
346
|
+
/** @internal Optional footer row definition. */
|
|
347
|
+
readonly footerRowDef: Signal<ComFooterRowDef | undefined>;
|
|
348
|
+
/** @internal Optional no-data row template. */
|
|
349
|
+
readonly noDataRow: Signal<ComNoDataRow | undefined>;
|
|
350
|
+
/** @internal Map of column name → column definition for O(1) lookup. */
|
|
351
|
+
protected readonly columnDefMap: Signal<Map<string, ComColumnDef>>;
|
|
352
|
+
/** @internal Resolved render data — handles both array and DataSource inputs. */
|
|
353
|
+
private readonly dataSourceSignal;
|
|
354
|
+
/** @internal The actual data array to render. */
|
|
355
|
+
readonly renderData: Signal<readonly T[]>;
|
|
356
|
+
/** @internal Header column names. */
|
|
357
|
+
protected readonly headerColumns: Signal<string[]>;
|
|
358
|
+
/** @internal Body column names. */
|
|
359
|
+
protected readonly bodyColumns: Signal<string[]>;
|
|
360
|
+
/** @internal Footer column names. */
|
|
361
|
+
protected readonly footerColumns: Signal<string[]>;
|
|
362
|
+
/** @internal Whether the header should be sticky. */
|
|
363
|
+
private readonly isSticky;
|
|
364
|
+
protected readonly containerClasses: Signal<string>;
|
|
365
|
+
protected readonly tableClasses: Signal<string>;
|
|
366
|
+
protected readonly theadClasses: Signal<string>;
|
|
367
|
+
protected readonly thClasses: Signal<string>;
|
|
368
|
+
protected readonly trClasses: Signal<string>;
|
|
369
|
+
protected readonly tdClasses: Signal<string>;
|
|
370
|
+
protected readonly tfootTdClasses: Signal<string>;
|
|
371
|
+
constructor();
|
|
372
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComTable<any>, never>;
|
|
373
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComTable<any>, "com-table", ["comTable"], { "dataSource": { "alias": "dataSource"; "required": false; "isSignal": true; }; "trackByFn": { "alias": "trackByFn"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "density": { "alias": "density"; "required": false; "isSignal": true; }; "stickyHeader": { "alias": "stickyHeader"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; }, {}, ["columnDefs", "headerRowDef", "rowDef", "footerRowDef", "noDataRow"], never, true, never>;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export { ComArrayDataSource, ComCellDef, ComColumnDef, ComDataSource, ComFooterCellDef, ComFooterRowDef, ComHeaderCellDef, ComHeaderRowDef, ComNoDataRow, ComRowDef, ComTable, isDataSource, tableBodyCellVariants, tableContainerVariants, tableFooterCellVariants, tableHeaderCellVariants, tableHeaderVariants, tableRowVariants, tableVariants };
|
|
377
|
+
export type { CellDefContext, ComTableDataSourceInput, TableBodyCellVariants, TableContainerVariants, TableDensity, TableFooterCellVariants, TableHeaderCellVariants, TableHeaderVariants, TableRowVariants, TableVariant, TableVariants };
|