ngx-com 0.0.3 → 0.0.4
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-avatar.mjs +772 -0
- package/fesm2022/ngx-com-components-avatar.mjs.map +1 -0
- package/fesm2022/ngx-com-components-confirm.mjs +562 -0
- package/fesm2022/ngx-com-components-confirm.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown.mjs +119 -25
- package/fesm2022/ngx-com-components-dropdown.mjs.map +1 -1
- package/fesm2022/ngx-com-components-empty-state.mjs +382 -0
- package/fesm2022/ngx-com-components-empty-state.mjs.map +1 -0
- package/fesm2022/ngx-com-components-form-field.mjs +16 -15
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -1
- package/fesm2022/ngx-com-components-item.mjs +578 -0
- package/fesm2022/ngx-com-components-item.mjs.map +1 -0
- package/fesm2022/ngx-com-components-paginator.mjs +823 -0
- package/fesm2022/ngx-com-components-paginator.mjs.map +1 -0
- package/fesm2022/ngx-com-components-segmented-control.mjs +538 -0
- package/fesm2022/ngx-com-components-segmented-control.mjs.map +1 -0
- package/fesm2022/ngx-com-components-spinner.mjs +189 -0
- package/fesm2022/ngx-com-components-spinner.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tooltip.mjs +625 -0
- package/fesm2022/ngx-com-components-tooltip.mjs.map +1 -0
- package/package.json +33 -1
- package/types/ngx-com-components-avatar.d.ts +409 -0
- package/types/ngx-com-components-confirm.d.ts +160 -0
- package/types/ngx-com-components-dropdown.d.ts +52 -28
- package/types/ngx-com-components-empty-state.d.ts +269 -0
- package/types/ngx-com-components-item.d.ts +336 -0
- package/types/ngx-com-components-paginator.d.ts +265 -0
- package/types/ngx-com-components-segmented-control.d.ts +274 -0
- package/types/ngx-com-components-spinner.d.ts +120 -0
- package/types/ngx-com-components-tooltip.d.ts +200 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { TemplateRef, InputSignal, ModelSignal, InputSignalWithTransform, Signal } from '@angular/core';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Template context provided to custom segment templates.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```html
|
|
10
|
+
* <ng-template comSegmentDef let-option let-active="active">
|
|
11
|
+
* <com-icon [name]="option.value" />
|
|
12
|
+
* <span>{{ option.label }}</span>
|
|
13
|
+
* </ng-template>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
interface SegmentTemplateContext<T = unknown> {
|
|
17
|
+
/** The option object (default for `let-option`). */
|
|
18
|
+
$implicit: SegmentOption<T>;
|
|
19
|
+
/** Whether this segment is currently selected. */
|
|
20
|
+
active: boolean;
|
|
21
|
+
/** Whether this segment is disabled. */
|
|
22
|
+
disabled: boolean;
|
|
23
|
+
/** Position in the options list (0-indexed). */
|
|
24
|
+
index: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Directive to mark a custom template for segment content.
|
|
28
|
+
*
|
|
29
|
+
* The template receives a `SegmentTemplateContext` with the option data,
|
|
30
|
+
* active state, disabled state, and index. Use this to customize the
|
|
31
|
+
* inner content of each segment while the component manages the button,
|
|
32
|
+
* styling, and ARIA attributes.
|
|
33
|
+
*
|
|
34
|
+
* @example Icon + text
|
|
35
|
+
* ```html
|
|
36
|
+
* <com-segmented-control [options]="viewOptions" [(value)]="currentView">
|
|
37
|
+
* <ng-template comSegmentDef let-option let-active="active">
|
|
38
|
+
* <com-icon [name]="option.value" size="sm" />
|
|
39
|
+
* <span>{{ option.label }}</span>
|
|
40
|
+
* </ng-template>
|
|
41
|
+
* </com-segmented-control>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @example Icon only (label used for accessibility)
|
|
45
|
+
* ```html
|
|
46
|
+
* <com-segmented-control [options]="alignmentOptions" [(value)]="alignment">
|
|
47
|
+
* <ng-template comSegmentDef let-option>
|
|
48
|
+
* <com-icon [name]="'align-' + option.value" size="sm" />
|
|
49
|
+
* </ng-template>
|
|
50
|
+
* </com-segmented-control>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare class ComSegmentDef<T = unknown> {
|
|
54
|
+
readonly templateRef: TemplateRef<SegmentTemplateContext<T>>;
|
|
55
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComSegmentDef<any>, never>;
|
|
56
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComSegmentDef<any>, "ng-template[comSegmentDef]", never, {}, {}, never, never, true, never>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
type SegmentedControlSize = 'sm' | 'md' | 'lg';
|
|
60
|
+
type SegmentedControlColor = 'primary' | 'accent' | 'muted';
|
|
61
|
+
type SegmentedControlVariant = 'filled' | 'outline';
|
|
62
|
+
/**
|
|
63
|
+
* CVA variants for the segmented control container (track).
|
|
64
|
+
* Controls overall sizing, padding, and track background.
|
|
65
|
+
*/
|
|
66
|
+
declare const segmentedControlContainerVariants: (props?: {
|
|
67
|
+
size?: SegmentedControlSize;
|
|
68
|
+
fullWidth?: boolean;
|
|
69
|
+
}) => string;
|
|
70
|
+
/**
|
|
71
|
+
* CVA variants for individual segment buttons.
|
|
72
|
+
* Controls per-segment sizing, typography, and active/inactive color states.
|
|
73
|
+
*/
|
|
74
|
+
declare const segmentedControlSegmentVariants: (props?: {
|
|
75
|
+
size?: SegmentedControlSize;
|
|
76
|
+
color?: SegmentedControlColor;
|
|
77
|
+
variant?: SegmentedControlVariant;
|
|
78
|
+
active?: boolean;
|
|
79
|
+
fullWidth?: boolean;
|
|
80
|
+
}) => string;
|
|
81
|
+
/**
|
|
82
|
+
* Classes to apply when a segment is disabled.
|
|
83
|
+
* Separate from CVA to avoid complex variant combinations.
|
|
84
|
+
*/
|
|
85
|
+
declare const SEGMENT_DISABLED_CLASSES = "bg-disabled text-disabled-foreground cursor-not-allowed hover:bg-disabled";
|
|
86
|
+
type SegmentedControlContainerVariants = VariantProps<typeof segmentedControlContainerVariants>;
|
|
87
|
+
type SegmentedControlSegmentVariants = VariantProps<typeof segmentedControlSegmentVariants>;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Represents a single option in the segmented control.
|
|
91
|
+
*/
|
|
92
|
+
interface SegmentOption<T = unknown> {
|
|
93
|
+
/** The value associated with this option. */
|
|
94
|
+
value: T;
|
|
95
|
+
/** Display label (also used as aria-label fallback for custom templates). */
|
|
96
|
+
label: string;
|
|
97
|
+
/** Whether this option is disabled. */
|
|
98
|
+
disabled?: boolean | undefined;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Segmented control component — a horizontal group of mutually exclusive options
|
|
102
|
+
* where one is always selected. Think of it as a styled radio group in pill form.
|
|
103
|
+
*
|
|
104
|
+
* Supports two rendering modes:
|
|
105
|
+
* - **Simple mode**: Plain text labels from the `label` property
|
|
106
|
+
* - **Custom template mode**: Full control via `ng-template[comSegmentDef]`
|
|
107
|
+
*
|
|
108
|
+
* @tokens `--color-primary`, `--color-primary-foreground`,
|
|
109
|
+
* `--color-accent`, `--color-accent-foreground`,
|
|
110
|
+
* `--color-muted`, `--color-muted-foreground`, `--color-muted-hover`,
|
|
111
|
+
* `--color-background`, `--color-foreground`,
|
|
112
|
+
* `--color-disabled`, `--color-disabled-foreground`,
|
|
113
|
+
* `--color-border`, `--color-ring`
|
|
114
|
+
*
|
|
115
|
+
* @example Basic two-option toggle
|
|
116
|
+
* ```html
|
|
117
|
+
* <com-segmented-control
|
|
118
|
+
* [options]="[
|
|
119
|
+
* { value: 'admin', label: 'Admin' },
|
|
120
|
+
* { value: 'user', label: 'User' }
|
|
121
|
+
* ]"
|
|
122
|
+
* [(value)]="selectedRole"
|
|
123
|
+
* />
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example Multiple options with variants
|
|
127
|
+
* ```html
|
|
128
|
+
* <com-segmented-control
|
|
129
|
+
* [options]="viewOptions"
|
|
130
|
+
* [(value)]="currentView"
|
|
131
|
+
* color="primary"
|
|
132
|
+
* size="sm"
|
|
133
|
+
* />
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @example Custom template with icons
|
|
137
|
+
* ```html
|
|
138
|
+
* <com-segmented-control [options]="viewOptions" [(value)]="currentView" color="primary">
|
|
139
|
+
* <ng-template comSegmentDef let-option let-active="active">
|
|
140
|
+
* <com-icon [name]="option.value === 'grid' ? 'grid' : 'list'" size="sm" />
|
|
141
|
+
* <span>{{ option.label }}</span>
|
|
142
|
+
* </ng-template>
|
|
143
|
+
* </com-segmented-control>
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @example Custom template with badges
|
|
147
|
+
* ```html
|
|
148
|
+
* <com-segmented-control [options]="statusOptions" [(value)]="statusFilter" color="accent">
|
|
149
|
+
* <ng-template comSegmentDef let-option let-active="active">
|
|
150
|
+
* <span>{{ option.label }}</span>
|
|
151
|
+
* <span
|
|
152
|
+
* class="ml-1.5 rounded-pill px-1.5 text-xs"
|
|
153
|
+
* [class]="active ? 'bg-accent-foreground/20 text-accent-foreground' : 'bg-muted text-muted-foreground'"
|
|
154
|
+
* >
|
|
155
|
+
* {{ option.value === 'open' ? openCount : closedCount }}
|
|
156
|
+
* </span>
|
|
157
|
+
* </ng-template>
|
|
158
|
+
* </com-segmented-control>
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example Icon only (label used for accessibility)
|
|
162
|
+
* ```html
|
|
163
|
+
* <com-segmented-control
|
|
164
|
+
* [options]="[
|
|
165
|
+
* { value: 'left', label: 'Align left' },
|
|
166
|
+
* { value: 'center', label: 'Align center' },
|
|
167
|
+
* { value: 'right', label: 'Align right' }
|
|
168
|
+
* ]"
|
|
169
|
+
* [(value)]="alignment"
|
|
170
|
+
* size="sm"
|
|
171
|
+
* >
|
|
172
|
+
* <ng-template comSegmentDef let-option>
|
|
173
|
+
* <com-icon [name]="'align-' + option.value" size="sm" />
|
|
174
|
+
* </ng-template>
|
|
175
|
+
* </com-segmented-control>
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @example Full width + outline variant
|
|
179
|
+
* ```html
|
|
180
|
+
* <com-segmented-control
|
|
181
|
+
* [options]="plans"
|
|
182
|
+
* [(value)]="selectedPlan"
|
|
183
|
+
* variant="outline"
|
|
184
|
+
* color="primary"
|
|
185
|
+
* [fullWidth]="true"
|
|
186
|
+
* />
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example Disabled options
|
|
190
|
+
* ```html
|
|
191
|
+
* <com-segmented-control
|
|
192
|
+
* [options]="[
|
|
193
|
+
* { value: 'free', label: 'Free' },
|
|
194
|
+
* { value: 'pro', label: 'Pro' },
|
|
195
|
+
* { value: 'enterprise', label: 'Enterprise', disabled: true }
|
|
196
|
+
* ]"
|
|
197
|
+
* [(value)]="plan"
|
|
198
|
+
* color="primary"
|
|
199
|
+
* size="lg"
|
|
200
|
+
* />
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
declare class ComSegmentedControl<T = unknown> {
|
|
204
|
+
/** References to all segment buttons for focus management. */
|
|
205
|
+
private readonly segmentButtons;
|
|
206
|
+
/** The list of options to display. */
|
|
207
|
+
readonly options: InputSignal<SegmentOption<T>[]>;
|
|
208
|
+
/** Currently selected value. Two-way bindable with `[(value)]`. */
|
|
209
|
+
readonly value: ModelSignal<T | undefined>;
|
|
210
|
+
/** Controls segment height, padding, and font size. */
|
|
211
|
+
readonly size: InputSignal<SegmentedControlSize>;
|
|
212
|
+
/** Color scheme for the active segment. */
|
|
213
|
+
readonly color: InputSignal<SegmentedControlColor>;
|
|
214
|
+
/** Visual variant: filled (solid background) or outline (ring border). */
|
|
215
|
+
readonly variant: InputSignal<SegmentedControlVariant>;
|
|
216
|
+
/** When true, segments stretch equally to fill available width. */
|
|
217
|
+
readonly fullWidth: InputSignalWithTransform<boolean, unknown>;
|
|
218
|
+
/** Accessible label for the radiogroup container. */
|
|
219
|
+
readonly ariaLabel: InputSignal<string | null>;
|
|
220
|
+
/** Custom CSS classes to merge with container classes. */
|
|
221
|
+
readonly userClass: InputSignal<string>;
|
|
222
|
+
/** Optional custom template for segment content. */
|
|
223
|
+
readonly customTemplate: Signal<ComSegmentDef<T> | undefined>;
|
|
224
|
+
/** Classes for the container/track element. */
|
|
225
|
+
protected readonly containerClasses: Signal<string>;
|
|
226
|
+
/**
|
|
227
|
+
* Checks if the given option is currently selected.
|
|
228
|
+
*/
|
|
229
|
+
isActive(option: SegmentOption<T>): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Selects the given option (if not disabled).
|
|
232
|
+
*/
|
|
233
|
+
select(option: SegmentOption<T>): void;
|
|
234
|
+
/**
|
|
235
|
+
* Returns the tabindex for a segment at the given index.
|
|
236
|
+
* Implements roving tabindex: only the selected (or first focusable) segment has tabindex="0".
|
|
237
|
+
*/
|
|
238
|
+
tabIndexFor(index: number): number;
|
|
239
|
+
/**
|
|
240
|
+
* Returns computed classes for a segment button.
|
|
241
|
+
*/
|
|
242
|
+
segmentClasses(option: SegmentOption<T>): string;
|
|
243
|
+
/**
|
|
244
|
+
* Builds the template context for custom templates.
|
|
245
|
+
*/
|
|
246
|
+
getTemplateContext(option: SegmentOption<T>, index: number): SegmentTemplateContext<T>;
|
|
247
|
+
/**
|
|
248
|
+
* Handles keyboard navigation for the segmented control.
|
|
249
|
+
* Implements ARIA radiogroup keyboard patterns.
|
|
250
|
+
*/
|
|
251
|
+
onKeydown(event: KeyboardEvent, currentIndex: number): void;
|
|
252
|
+
/**
|
|
253
|
+
* Finds the next focusable (non-disabled) option index in the given direction.
|
|
254
|
+
* Wraps around to the beginning/end of the list.
|
|
255
|
+
*/
|
|
256
|
+
private findNextFocusableIndex;
|
|
257
|
+
/**
|
|
258
|
+
* Finds the first focusable (non-disabled) option index.
|
|
259
|
+
*/
|
|
260
|
+
private findFirstFocusableIndex;
|
|
261
|
+
/**
|
|
262
|
+
* Finds the last focusable (non-disabled) option index.
|
|
263
|
+
*/
|
|
264
|
+
private findLastFocusableIndex;
|
|
265
|
+
/**
|
|
266
|
+
* Focuses the segment button at the given index.
|
|
267
|
+
*/
|
|
268
|
+
private focusSegmentAt;
|
|
269
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComSegmentedControl<any>, never>;
|
|
270
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComSegmentedControl<any>, "com-segmented-control", ["comSegmentedControl"], { "options": { "alias": "options"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "fullWidth": { "alias": "fullWidth"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "aria-label"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; }, ["customTemplate"], never, true, never>;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export { ComSegmentDef, ComSegmentedControl, SEGMENT_DISABLED_CLASSES, segmentedControlContainerVariants, segmentedControlSegmentVariants };
|
|
274
|
+
export type { SegmentOption, SegmentTemplateContext, SegmentedControlColor, SegmentedControlContainerVariants, SegmentedControlSegmentVariants, SegmentedControlSize, SegmentedControlVariant };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InputSignal, Signal } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/** Spinner size variants. */
|
|
5
|
+
type SpinnerSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
/** Spinner color variants. */
|
|
7
|
+
type SpinnerColor = 'current' | 'primary' | 'accent' | 'warn' | 'success' | 'muted';
|
|
8
|
+
/** Label position relative to spinner. */
|
|
9
|
+
type SpinnerLabelPosition = 'right' | 'bottom';
|
|
10
|
+
/**
|
|
11
|
+
* CVA variants for the spinning circle element.
|
|
12
|
+
*
|
|
13
|
+
* Creates a circular track with a faded ring and a colored arc that rotates.
|
|
14
|
+
* Uses `border` for the track and `border-t-*` for the spinning arc.
|
|
15
|
+
*
|
|
16
|
+
* @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`, `--color-muted-foreground`
|
|
17
|
+
*/
|
|
18
|
+
declare const spinnerVariants: (props?: {
|
|
19
|
+
size?: SpinnerSize;
|
|
20
|
+
color?: SpinnerColor;
|
|
21
|
+
}) => string;
|
|
22
|
+
/**
|
|
23
|
+
* CVA variants for the spinner container layout.
|
|
24
|
+
*
|
|
25
|
+
* Controls flex direction and gap based on label position.
|
|
26
|
+
* Only applies when a visible label is present.
|
|
27
|
+
*
|
|
28
|
+
* @tokens none (layout only)
|
|
29
|
+
*/
|
|
30
|
+
declare const spinnerContainerVariants: (props?: {
|
|
31
|
+
labelPosition?: SpinnerLabelPosition;
|
|
32
|
+
}) => string;
|
|
33
|
+
/** Label font size classes mapped to spinner size. */
|
|
34
|
+
declare const SPINNER_LABEL_SIZES: Record<SpinnerSize, string>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A minimal, CSS-only loading indicator.
|
|
38
|
+
*
|
|
39
|
+
* Drop-in anywhere: inside buttons, next to inline text, centered in cards,
|
|
40
|
+
* or as a page-level overlay. The animation is fast (0.6s) for a snappy feel.
|
|
41
|
+
*
|
|
42
|
+
* @tokens `--color-primary`, `--color-accent`, `--color-warn`, `--color-success`, `--color-muted-foreground`
|
|
43
|
+
*
|
|
44
|
+
* @example Simplest usage (inherits parent text color)
|
|
45
|
+
* ```html
|
|
46
|
+
* <com-spinner />
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Inside a button (inline, inherits button text color)
|
|
50
|
+
* ```html
|
|
51
|
+
* <button class="btn-primary" [disabled]="saving">
|
|
52
|
+
* @if (saving) {
|
|
53
|
+
* <com-spinner size="xs" />
|
|
54
|
+
* }
|
|
55
|
+
* Save
|
|
56
|
+
* </button>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @example With visible label
|
|
60
|
+
* ```html
|
|
61
|
+
* <com-spinner label="Loading results..." />
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Centered in a card
|
|
65
|
+
* ```html
|
|
66
|
+
* <div class="flex items-center justify-center p-8">
|
|
67
|
+
* <com-spinner size="lg" color="primary" label="Loading..." labelPosition="bottom" />
|
|
68
|
+
* </div>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example Inline with text
|
|
72
|
+
* ```html
|
|
73
|
+
* <p class="text-muted-foreground">
|
|
74
|
+
* <com-spinner size="xs" /> Checking availability...
|
|
75
|
+
* </p>
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @example Color variants
|
|
79
|
+
* ```html
|
|
80
|
+
* <com-spinner color="primary" />
|
|
81
|
+
* <com-spinner color="accent" />
|
|
82
|
+
* <com-spinner color="warn" />
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example Large page-level
|
|
86
|
+
* ```html
|
|
87
|
+
* <com-spinner size="xl" color="primary" label="Preparing your dashboard..." labelPosition="bottom" />
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare class ComSpinner {
|
|
91
|
+
/**
|
|
92
|
+
* Optional loading text (e.g., "Loading...", "Saving...").
|
|
93
|
+
* When omitted, "Loading" is rendered for screen readers only (sr-only).
|
|
94
|
+
* When provided, the label is visible next to or below the spinner.
|
|
95
|
+
*/
|
|
96
|
+
readonly label: InputSignal<string | undefined>;
|
|
97
|
+
/**
|
|
98
|
+
* Position of the label relative to the spinner.
|
|
99
|
+
* Only relevant when a visible `label` is provided.
|
|
100
|
+
*/
|
|
101
|
+
readonly labelPosition: InputSignal<SpinnerLabelPosition>;
|
|
102
|
+
/** Size of the spinner. */
|
|
103
|
+
readonly size: InputSignal<SpinnerSize>;
|
|
104
|
+
/**
|
|
105
|
+
* Color of the spinner.
|
|
106
|
+
* `current` inherits from `currentColor` to match surrounding text.
|
|
107
|
+
*/
|
|
108
|
+
readonly color: InputSignal<SpinnerColor>;
|
|
109
|
+
/** @internal Computed classes for the spinning circle. */
|
|
110
|
+
protected readonly spinnerClasses: Signal<string>;
|
|
111
|
+
/** @internal Computed classes for the container/host. */
|
|
112
|
+
protected readonly containerClasses: Signal<string>;
|
|
113
|
+
/** @internal Computed label font size class. */
|
|
114
|
+
protected readonly labelSizeClass: Signal<string>;
|
|
115
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComSpinner, never>;
|
|
116
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComSpinner, "com-spinner", ["comSpinner"], { "label": { "alias": "label"; "required": false; "isSignal": true; }; "labelPosition": { "alias": "labelPosition"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { ComSpinner, SPINNER_LABEL_SIZES, spinnerContainerVariants, spinnerVariants };
|
|
120
|
+
export type { SpinnerColor, SpinnerLabelPosition, SpinnerSize };
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InputSignal, TemplateRef, InputSignalWithTransform, OutputEmitterRef } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Position direction for tooltip placement relative to the trigger.
|
|
6
|
+
*/
|
|
7
|
+
type TooltipPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
8
|
+
/**
|
|
9
|
+
* Color variant for tooltip styling.
|
|
10
|
+
*/
|
|
11
|
+
type TooltipColor = 'default' | 'primary' | 'accent' | 'warn' | 'invert';
|
|
12
|
+
/**
|
|
13
|
+
* Size variant for tooltip dimensions.
|
|
14
|
+
*/
|
|
15
|
+
type TooltipSize = 'sm' | 'md' | 'lg';
|
|
16
|
+
/**
|
|
17
|
+
* Touch gesture handling mode.
|
|
18
|
+
* - 'auto': Long-press to show, tap elsewhere to hide
|
|
19
|
+
* - 'on': Same as auto
|
|
20
|
+
* - 'off': Touch does not trigger tooltip
|
|
21
|
+
*/
|
|
22
|
+
type TooltipTouchGestures = 'auto' | 'on' | 'off';
|
|
23
|
+
/**
|
|
24
|
+
* Context provided to custom tooltip templates.
|
|
25
|
+
*/
|
|
26
|
+
interface TooltipTemplateContext {
|
|
27
|
+
/** The text content passed to comTooltip input. */
|
|
28
|
+
$implicit: string;
|
|
29
|
+
/** Function to programmatically close the tooltip from inside the template. */
|
|
30
|
+
hide: () => void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Which side of the trigger the tooltip is positioned on.
|
|
34
|
+
* Used internally for arrow orientation.
|
|
35
|
+
*/
|
|
36
|
+
type TooltipSide = 'top' | 'bottom' | 'left' | 'right';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Tooltip directive — displays supplementary information on hover/focus.
|
|
40
|
+
*
|
|
41
|
+
* Applied as an attribute directive to any trigger element. The tooltip panel
|
|
42
|
+
* is rendered via CDK Overlay when triggered by mouse hover, keyboard focus,
|
|
43
|
+
* or programmatically.
|
|
44
|
+
*
|
|
45
|
+
* @tokens `--color-tooltip`, `--color-tooltip-foreground`, `--color-primary`, `--color-primary-foreground`,
|
|
46
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-warn`, `--color-warn-foreground`,
|
|
47
|
+
* `--color-popover`, `--color-popover-foreground`, `--color-border`
|
|
48
|
+
*
|
|
49
|
+
* @example Simple text tooltip
|
|
50
|
+
* ```html
|
|
51
|
+
* <button comTooltip="Save your changes">
|
|
52
|
+
* <com-icon name="save" />
|
|
53
|
+
* </button>
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @example Positioned
|
|
57
|
+
* ```html
|
|
58
|
+
* <button comTooltip="Settings" comTooltipPosition="right">
|
|
59
|
+
* <com-icon name="settings" />
|
|
60
|
+
* </button>
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @example Color variants
|
|
64
|
+
* ```html
|
|
65
|
+
* <com-icon name="alert-triangle" comTooltip="3 warnings found" comTooltipColor="warn" />
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example Custom template
|
|
69
|
+
* ```html
|
|
70
|
+
* <button
|
|
71
|
+
* comTooltip="Keyboard shortcuts"
|
|
72
|
+
* [comTooltipTpl]="shortcutsTpl"
|
|
73
|
+
* comTooltipSize="lg"
|
|
74
|
+
* >
|
|
75
|
+
* <com-icon name="keyboard" />
|
|
76
|
+
* </button>
|
|
77
|
+
*
|
|
78
|
+
* <ng-template #shortcutsTpl let-hide="hide">
|
|
79
|
+
* <div class="flex flex-col gap-1">
|
|
80
|
+
* <span>Press Ctrl+S to save</span>
|
|
81
|
+
* <button (click)="hide()">Got it</button>
|
|
82
|
+
* </div>
|
|
83
|
+
* </ng-template>
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @example Programmatic control
|
|
87
|
+
* ```html
|
|
88
|
+
* <input
|
|
89
|
+
* #tooltipRef="comTooltip"
|
|
90
|
+
* comTooltip="Invalid email"
|
|
91
|
+
* comTooltipColor="warn"
|
|
92
|
+
* [comTooltipDisabled]="true"
|
|
93
|
+
* />
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* ```ts
|
|
97
|
+
* // Show tooltip on validation error
|
|
98
|
+
* if (emailInvalid) {
|
|
99
|
+
* this.tooltipRef.show();
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
declare class ComTooltip {
|
|
104
|
+
private readonly overlay;
|
|
105
|
+
private readonly elementRef;
|
|
106
|
+
private readonly viewContainerRef;
|
|
107
|
+
private readonly injector;
|
|
108
|
+
private readonly destroyRef;
|
|
109
|
+
private readonly renderer;
|
|
110
|
+
private readonly platformId;
|
|
111
|
+
private readonly document;
|
|
112
|
+
private overlayRef;
|
|
113
|
+
private panelInstance;
|
|
114
|
+
private showTimeoutId;
|
|
115
|
+
private hideTimeoutId;
|
|
116
|
+
private touchTimeoutId;
|
|
117
|
+
private readonly tooltipId;
|
|
118
|
+
/** Current active side (updated from position changes). */
|
|
119
|
+
private readonly activeSide;
|
|
120
|
+
/** Whether the tooltip is currently visible. */
|
|
121
|
+
private readonly isVisible;
|
|
122
|
+
/** Simple text content for the tooltip. Also serves as the directive selector. */
|
|
123
|
+
readonly comTooltip: InputSignal<string>;
|
|
124
|
+
/** Custom template for rich tooltip content. Takes precedence over text when provided. */
|
|
125
|
+
readonly comTooltipTpl: InputSignal<TemplateRef<TooltipTemplateContext> | null>;
|
|
126
|
+
/** Preferred position direction. Default: 'top'. */
|
|
127
|
+
readonly comTooltipPosition: InputSignal<TooltipPosition>;
|
|
128
|
+
/** Delay in ms before showing the tooltip. Default: 200. */
|
|
129
|
+
readonly comTooltipShowDelay: InputSignalWithTransform<number, unknown>;
|
|
130
|
+
/** Delay in ms before hiding the tooltip. Default: 100. */
|
|
131
|
+
readonly comTooltipHideDelay: InputSignalWithTransform<number, unknown>;
|
|
132
|
+
/** Disable the tooltip entirely. Default: false. */
|
|
133
|
+
readonly comTooltipDisabled: InputSignalWithTransform<boolean, unknown>;
|
|
134
|
+
/** Touch device handling. Default: 'auto'. */
|
|
135
|
+
readonly comTooltipTouchGestures: InputSignal<TooltipTouchGestures>;
|
|
136
|
+
/** Color variant. Default: 'default'. */
|
|
137
|
+
readonly comTooltipColor: InputSignal<TooltipColor>;
|
|
138
|
+
/** Size variant. Default: 'md'. */
|
|
139
|
+
readonly comTooltipSize: InputSignal<TooltipSize>;
|
|
140
|
+
/** Whether to show the arrow/caret. Default: true. */
|
|
141
|
+
readonly comTooltipHasArrow: InputSignalWithTransform<boolean, unknown>;
|
|
142
|
+
/** Emitted when the tooltip becomes visible (after delay + animation). */
|
|
143
|
+
readonly comTooltipShown: OutputEmitterRef<void>;
|
|
144
|
+
/** Emitted when the tooltip is fully hidden. */
|
|
145
|
+
readonly comTooltipHidden: OutputEmitterRef<void>;
|
|
146
|
+
constructor();
|
|
147
|
+
/** Programmatically show the tooltip (ignores disabled state for error validation use cases). */
|
|
148
|
+
show(): void;
|
|
149
|
+
/** Programmatically hide the tooltip. */
|
|
150
|
+
hide(): void;
|
|
151
|
+
protected onMouseEnter(): void;
|
|
152
|
+
protected onMouseLeave(): void;
|
|
153
|
+
protected onFocusIn(): void;
|
|
154
|
+
protected onFocusOut(): void;
|
|
155
|
+
protected onEscapeKey(): void;
|
|
156
|
+
protected onTouchStart(event: TouchEvent): void;
|
|
157
|
+
/** Called when mouse enters the tooltip panel. */
|
|
158
|
+
private onPanelMouseEnter;
|
|
159
|
+
/** Called when mouse leaves the tooltip panel. */
|
|
160
|
+
private onPanelMouseLeave;
|
|
161
|
+
private scheduleShow;
|
|
162
|
+
private scheduleHide;
|
|
163
|
+
private clearTimers;
|
|
164
|
+
private clearShowTimeout;
|
|
165
|
+
private clearHideTimeout;
|
|
166
|
+
private clearTouchTimeout;
|
|
167
|
+
private createOverlay;
|
|
168
|
+
private attachPanel;
|
|
169
|
+
private detachPanel;
|
|
170
|
+
private handleDetachment;
|
|
171
|
+
private disposeOverlay;
|
|
172
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComTooltip, never>;
|
|
173
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<ComTooltip, "[comTooltip]", ["comTooltip"], { "comTooltip": { "alias": "comTooltip"; "required": true; "isSignal": true; }; "comTooltipTpl": { "alias": "comTooltipTpl"; "required": false; "isSignal": true; }; "comTooltipPosition": { "alias": "comTooltipPosition"; "required": false; "isSignal": true; }; "comTooltipShowDelay": { "alias": "comTooltipShowDelay"; "required": false; "isSignal": true; }; "comTooltipHideDelay": { "alias": "comTooltipHideDelay"; "required": false; "isSignal": true; }; "comTooltipDisabled": { "alias": "comTooltipDisabled"; "required": false; "isSignal": true; }; "comTooltipTouchGestures": { "alias": "comTooltipTouchGestures"; "required": false; "isSignal": true; }; "comTooltipColor": { "alias": "comTooltipColor"; "required": false; "isSignal": true; }; "comTooltipSize": { "alias": "comTooltipSize"; "required": false; "isSignal": true; }; "comTooltipHasArrow": { "alias": "comTooltipHasArrow"; "required": false; "isSignal": true; }; }, { "comTooltipShown": "comTooltipShown"; "comTooltipHidden": "comTooltipHidden"; }, never, never, true, never>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* CVA variants for the tooltip panel wrapper.
|
|
178
|
+
*
|
|
179
|
+
* @tokens `--color-tooltip`, `--color-tooltip-foreground`, `--color-primary`, `--color-primary-foreground`,
|
|
180
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-warn`, `--color-warn-foreground`,
|
|
181
|
+
* `--color-popover`, `--color-popover-foreground`, `--color-border`
|
|
182
|
+
*/
|
|
183
|
+
declare const tooltipPanelVariants: (props?: {
|
|
184
|
+
color?: TooltipColor;
|
|
185
|
+
size?: TooltipSize;
|
|
186
|
+
}) => string;
|
|
187
|
+
/**
|
|
188
|
+
* CVA variants for the tooltip arrow element.
|
|
189
|
+
* The arrow points toward the trigger element.
|
|
190
|
+
*
|
|
191
|
+
* @tokens `--color-tooltip`, `--color-primary`, `--color-accent`, `--color-warn`,
|
|
192
|
+
* `--color-popover`, `--color-border`
|
|
193
|
+
*/
|
|
194
|
+
declare const tooltipArrowVariants: (props?: {
|
|
195
|
+
color?: TooltipColor;
|
|
196
|
+
side?: TooltipSide;
|
|
197
|
+
}) => string;
|
|
198
|
+
|
|
199
|
+
export { ComTooltip, tooltipArrowVariants, tooltipPanelVariants };
|
|
200
|
+
export type { TooltipColor, TooltipPosition, TooltipSize, TooltipTemplateContext, TooltipTouchGestures };
|