ngx-com 0.0.1 → 0.0.3
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-badge.mjs +138 -0
- package/fesm2022/ngx-com-components-badge.mjs.map +1 -0
- package/fesm2022/ngx-com-components-button.mjs +146 -0
- package/fesm2022/ngx-com-components-button.mjs.map +1 -0
- package/fesm2022/ngx-com-components-calendar.mjs +5046 -0
- package/fesm2022/ngx-com-components-calendar.mjs.map +1 -0
- package/fesm2022/ngx-com-components-card.mjs +590 -0
- package/fesm2022/ngx-com-components-card.mjs.map +1 -0
- package/fesm2022/ngx-com-components-checkbox.mjs +344 -0
- package/fesm2022/ngx-com-components-checkbox.mjs.map +1 -0
- package/fesm2022/ngx-com-components-collapsible.mjs +612 -0
- package/fesm2022/ngx-com-components-collapsible.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown-testing.mjs +255 -0
- package/fesm2022/ngx-com-components-dropdown-testing.mjs.map +1 -0
- package/fesm2022/ngx-com-components-dropdown.mjs +2598 -0
- package/fesm2022/ngx-com-components-dropdown.mjs.map +1 -0
- package/fesm2022/ngx-com-components-form-field.mjs +923 -0
- package/fesm2022/ngx-com-components-form-field.mjs.map +1 -0
- package/fesm2022/ngx-com-components-icon.mjs +183 -0
- package/fesm2022/ngx-com-components-icon.mjs.map +1 -0
- package/fesm2022/ngx-com-components-menu.mjs +1200 -0
- package/fesm2022/ngx-com-components-menu.mjs.map +1 -0
- package/fesm2022/ngx-com-components-popover.mjs +901 -0
- package/fesm2022/ngx-com-components-popover.mjs.map +1 -0
- package/fesm2022/ngx-com-components-radio.mjs +621 -0
- package/fesm2022/ngx-com-components-radio.mjs.map +1 -0
- package/fesm2022/ngx-com-components-sort.mjs +368 -0
- package/fesm2022/ngx-com-components-sort.mjs.map +1 -0
- package/fesm2022/ngx-com-components-tabs.mjs +1522 -0
- package/fesm2022/ngx-com-components-tabs.mjs.map +1 -0
- package/fesm2022/ngx-com-components.mjs +17 -0
- package/fesm2022/ngx-com-components.mjs.map +1 -0
- package/fesm2022/ngx-com-tokens.mjs +12 -0
- package/fesm2022/ngx-com-tokens.mjs.map +1 -0
- package/fesm2022/ngx-com-utils.mjs +601 -0
- package/fesm2022/ngx-com-utils.mjs.map +1 -0
- package/fesm2022/ngx-com.mjs +9 -23
- package/fesm2022/ngx-com.mjs.map +1 -1
- package/package.json +73 -1
- package/types/ngx-com-components-badge.d.ts +97 -0
- package/types/ngx-com-components-button.d.ts +69 -0
- package/types/ngx-com-components-calendar.d.ts +1665 -0
- package/types/ngx-com-components-card.d.ts +373 -0
- package/types/ngx-com-components-checkbox.d.ts +116 -0
- package/types/ngx-com-components-collapsible.d.ts +379 -0
- package/types/ngx-com-components-dropdown-testing.d.ts +116 -0
- package/types/ngx-com-components-dropdown.d.ts +914 -0
- package/types/ngx-com-components-form-field.d.ts +531 -0
- package/types/ngx-com-components-icon.d.ts +94 -0
- package/types/ngx-com-components-menu.d.ts +479 -0
- package/types/ngx-com-components-popover.d.ts +309 -0
- package/types/ngx-com-components-radio.d.ts +258 -0
- package/types/ngx-com-components-sort.d.ts +133 -0
- package/types/ngx-com-components-tabs.d.ts +396 -0
- package/types/ngx-com-components.d.ts +12 -0
- package/types/ngx-com-tokens.d.ts +7 -0
- package/types/ngx-com-utils.d.ts +424 -0
- package/types/ngx-com.d.ts +10 -7
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InputSignal, TemplateRef, Type, InputSignalWithTransform, ModelSignal, OutputEmitterRef, Signal, InjectionToken } from '@angular/core';
|
|
3
|
+
import { VariantProps, cva } from 'class-variance-authority';
|
|
4
|
+
import { ConnectedPosition, ConnectionPositionPair } from '@angular/cdk/overlay';
|
|
5
|
+
|
|
6
|
+
type PopoverPosition = 'above' | 'below' | 'left' | 'right' | 'auto';
|
|
7
|
+
type PopoverAlignment = 'start' | 'center' | 'end';
|
|
8
|
+
type PopoverTriggerOn = 'click' | 'focus' | 'manual';
|
|
9
|
+
type PopoverVariant = 'default' | 'compact' | 'wide' | 'flush';
|
|
10
|
+
type PopoverBackdrop = 'transparent' | 'dimmed' | 'none';
|
|
11
|
+
type PopoverSide = 'top' | 'bottom' | 'left' | 'right';
|
|
12
|
+
/**
|
|
13
|
+
* Popover panel styling variants.
|
|
14
|
+
*
|
|
15
|
+
* @tokens `--color-popover`, `--color-popover-foreground`, `--color-border`, `--shadow-lg`, `--radius-popover`, `--radius-overlay`
|
|
16
|
+
*/
|
|
17
|
+
declare const popoverPanelVariants: ReturnType<typeof cva<{
|
|
18
|
+
variant: Record<PopoverVariant, string>;
|
|
19
|
+
}>>;
|
|
20
|
+
type PopoverPanelVariants = VariantProps<typeof popoverPanelVariants>;
|
|
21
|
+
/**
|
|
22
|
+
* Popover arrow positioning variants.
|
|
23
|
+
* The arrow is positioned on the edge of the popover pointing toward the trigger.
|
|
24
|
+
*
|
|
25
|
+
* @tokens `--color-popover`, `--color-border`
|
|
26
|
+
*/
|
|
27
|
+
declare const popoverArrowVariants: ReturnType<typeof cva<{
|
|
28
|
+
side: Record<PopoverSide, string>;
|
|
29
|
+
}>>;
|
|
30
|
+
type PopoverArrowVariants = VariantProps<typeof popoverArrowVariants>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Popover trigger directive — manages the popover overlay lifecycle.
|
|
34
|
+
* Applied to the trigger element, it handles opening, closing, positioning,
|
|
35
|
+
* and accessibility for floating popover content.
|
|
36
|
+
*
|
|
37
|
+
* @tokens `--color-popover`, `--color-popover-foreground`, `--color-border`, `--shadow-lg`, `--color-ring`
|
|
38
|
+
*
|
|
39
|
+
* @example Basic usage with template
|
|
40
|
+
* ```html
|
|
41
|
+
* <button comButton [comPopoverTrigger]="helpContent">Help</button>
|
|
42
|
+
* <ng-template #helpContent>
|
|
43
|
+
* <p>This is help content.</p>
|
|
44
|
+
* </ng-template>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example With positioning
|
|
48
|
+
* ```html
|
|
49
|
+
* <button
|
|
50
|
+
* comButton
|
|
51
|
+
* [comPopoverTrigger]="menuContent"
|
|
52
|
+
* popoverPosition="below"
|
|
53
|
+
* popoverAlignment="start"
|
|
54
|
+
* [popoverShowArrow]="false"
|
|
55
|
+
* >
|
|
56
|
+
* Menu
|
|
57
|
+
* </button>
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example With component content
|
|
61
|
+
* ```html
|
|
62
|
+
* <button
|
|
63
|
+
* comButton
|
|
64
|
+
* [comPopoverTrigger]="UserProfilePopover"
|
|
65
|
+
* [popoverData]="{ userId: user.id }"
|
|
66
|
+
* >
|
|
67
|
+
* Profile
|
|
68
|
+
* </button>
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @example Manual control
|
|
72
|
+
* ```html
|
|
73
|
+
* <button
|
|
74
|
+
* comButton
|
|
75
|
+
* [comPopoverTrigger]="content"
|
|
76
|
+
* popoverTriggerOn="manual"
|
|
77
|
+
* [(popoverOpen)]="isOpen"
|
|
78
|
+
* >
|
|
79
|
+
* Controlled
|
|
80
|
+
* </button>
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
declare class PopoverTriggerDirective {
|
|
84
|
+
private readonly overlay;
|
|
85
|
+
private readonly elementRef;
|
|
86
|
+
private readonly viewContainerRef;
|
|
87
|
+
private readonly injector;
|
|
88
|
+
private readonly destroyRef;
|
|
89
|
+
private readonly focusTrapFactory;
|
|
90
|
+
private readonly document;
|
|
91
|
+
private overlayRef;
|
|
92
|
+
private focusTrap;
|
|
93
|
+
private scrollCleanup;
|
|
94
|
+
private readonly popoverId;
|
|
95
|
+
/** Content to render: TemplateRef or Component class. */
|
|
96
|
+
readonly comPopoverTrigger: InputSignal<TemplateRef<unknown> | Type<unknown>>;
|
|
97
|
+
/** Preferred position direction. */
|
|
98
|
+
readonly popoverPosition: InputSignal<PopoverPosition>;
|
|
99
|
+
/** Alignment along the cross-axis. */
|
|
100
|
+
readonly popoverAlignment: InputSignal<PopoverAlignment>;
|
|
101
|
+
/** What interaction opens the popover. */
|
|
102
|
+
readonly popoverTriggerOn: InputSignal<PopoverTriggerOn>;
|
|
103
|
+
/** Gap in px between trigger and popover edge. */
|
|
104
|
+
readonly popoverOffset: InputSignal<number>;
|
|
105
|
+
/** Whether to render the connecting arrow. */
|
|
106
|
+
readonly popoverShowArrow: InputSignalWithTransform<boolean, unknown>;
|
|
107
|
+
/** Size/padding preset for the content panel. */
|
|
108
|
+
readonly popoverVariant: InputSignal<PopoverVariant>;
|
|
109
|
+
/** Backdrop behavior. */
|
|
110
|
+
readonly popoverBackdrop: InputSignal<PopoverBackdrop>;
|
|
111
|
+
/** Close when clicking outside the popover. */
|
|
112
|
+
readonly popoverCloseOnOutside: InputSignalWithTransform<boolean, unknown>;
|
|
113
|
+
/** Close on Escape key. */
|
|
114
|
+
readonly popoverCloseOnEscape: InputSignalWithTransform<boolean, unknown>;
|
|
115
|
+
/** Close when ancestor scrollable container scrolls. */
|
|
116
|
+
readonly popoverCloseOnScroll: InputSignalWithTransform<boolean, unknown>;
|
|
117
|
+
/** Prevents opening when true. */
|
|
118
|
+
readonly popoverDisabled: InputSignalWithTransform<boolean, unknown>;
|
|
119
|
+
/** Two-way bindable open state. */
|
|
120
|
+
readonly popoverOpen: ModelSignal<boolean>;
|
|
121
|
+
/** Arbitrary data passed to the content component/template. */
|
|
122
|
+
readonly popoverData: InputSignal<unknown>;
|
|
123
|
+
/** Custom CSS class(es) on the overlay panel. */
|
|
124
|
+
readonly popoverPanelClass: InputSignal<string | string[]>;
|
|
125
|
+
/** Trap focus inside popover. */
|
|
126
|
+
readonly popoverTrapFocus: InputSignalWithTransform<boolean, unknown>;
|
|
127
|
+
/** Optional accessibility label for the popover dialog. */
|
|
128
|
+
readonly popoverAriaLabel: InputSignal<string | undefined>;
|
|
129
|
+
/** Emitted after popup opens and is visible. */
|
|
130
|
+
readonly popoverOpened: OutputEmitterRef<void>;
|
|
131
|
+
/** Emitted after popup closes and is detached. */
|
|
132
|
+
readonly popoverClosed: OutputEmitterRef<void>;
|
|
133
|
+
private readonly activeSide;
|
|
134
|
+
private readonly activeAlignment;
|
|
135
|
+
private readonly animationState;
|
|
136
|
+
private contentComponentRef;
|
|
137
|
+
private readonly hasBackdrop;
|
|
138
|
+
private readonly backdropClass;
|
|
139
|
+
protected readonly ariaControls: Signal<string | null>;
|
|
140
|
+
private readonly panelClassArray;
|
|
141
|
+
constructor();
|
|
142
|
+
/** Programmatically open the popover. */
|
|
143
|
+
open(): void;
|
|
144
|
+
/** Programmatically close the popover. */
|
|
145
|
+
close(): void;
|
|
146
|
+
/** Toggle the popover open/close state. */
|
|
147
|
+
toggle(): void;
|
|
148
|
+
/** Force recalculation of position. */
|
|
149
|
+
reposition(): void;
|
|
150
|
+
protected onTriggerClick(event: MouseEvent): void;
|
|
151
|
+
protected onTriggerFocus(): void;
|
|
152
|
+
protected onTriggerBlur(): void;
|
|
153
|
+
protected onEscapeKey(event: Event): void;
|
|
154
|
+
private openPopover;
|
|
155
|
+
private closePopover;
|
|
156
|
+
private subscribeToScrollEvents;
|
|
157
|
+
private unsubscribeFromScrollEvents;
|
|
158
|
+
private createOverlay;
|
|
159
|
+
private attachContent;
|
|
160
|
+
private updateContentComponentInputs;
|
|
161
|
+
private detachContent;
|
|
162
|
+
private subscribeToCloseEvents;
|
|
163
|
+
private setupFocusTrap;
|
|
164
|
+
private destroyFocusTrap;
|
|
165
|
+
private disposeOverlay;
|
|
166
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PopoverTriggerDirective, never>;
|
|
167
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<PopoverTriggerDirective, "[comPopoverTrigger]", ["comPopoverTrigger"], { "comPopoverTrigger": { "alias": "comPopoverTrigger"; "required": true; "isSignal": true; }; "popoverPosition": { "alias": "popoverPosition"; "required": false; "isSignal": true; }; "popoverAlignment": { "alias": "popoverAlignment"; "required": false; "isSignal": true; }; "popoverTriggerOn": { "alias": "popoverTriggerOn"; "required": false; "isSignal": true; }; "popoverOffset": { "alias": "popoverOffset"; "required": false; "isSignal": true; }; "popoverShowArrow": { "alias": "popoverShowArrow"; "required": false; "isSignal": true; }; "popoverVariant": { "alias": "popoverVariant"; "required": false; "isSignal": true; }; "popoverBackdrop": { "alias": "popoverBackdrop"; "required": false; "isSignal": true; }; "popoverCloseOnOutside": { "alias": "popoverCloseOnOutside"; "required": false; "isSignal": true; }; "popoverCloseOnEscape": { "alias": "popoverCloseOnEscape"; "required": false; "isSignal": true; }; "popoverCloseOnScroll": { "alias": "popoverCloseOnScroll"; "required": false; "isSignal": true; }; "popoverDisabled": { "alias": "popoverDisabled"; "required": false; "isSignal": true; }; "popoverOpen": { "alias": "popoverOpen"; "required": false; "isSignal": true; }; "popoverData": { "alias": "popoverData"; "required": false; "isSignal": true; }; "popoverPanelClass": { "alias": "popoverPanelClass"; "required": false; "isSignal": true; }; "popoverTrapFocus": { "alias": "popoverTrapFocus"; "required": false; "isSignal": true; }; "popoverAriaLabel": { "alias": "popoverAriaLabel"; "required": false; "isSignal": true; }; }, { "popoverOpen": "popoverOpenChange"; "popoverOpened": "popoverOpened"; "popoverClosed": "popoverClosed"; }, never, never, true, never>;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Convenience directive that closes the parent popover when clicked.
|
|
172
|
+
* Applied to elements inside the popover that should dismiss it.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```html
|
|
176
|
+
* <ng-template #confirmPop>
|
|
177
|
+
* <div class="space-y-3">
|
|
178
|
+
* <p>Are you sure?</p>
|
|
179
|
+
* <div class="flex gap-2">
|
|
180
|
+
* <button comButton variant="ghost" comPopoverClose>Cancel</button>
|
|
181
|
+
* <button comButton (click)="confirm()" comPopoverClose>Confirm</button>
|
|
182
|
+
* </div>
|
|
183
|
+
* </div>
|
|
184
|
+
* </ng-template>
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @example With a result value
|
|
188
|
+
* ```html
|
|
189
|
+
* <button [comPopoverClose]="'confirmed'" (click)="onConfirm()">Yes</button>
|
|
190
|
+
* <button [comPopoverClose]="'cancelled'">No</button>
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare class PopoverCloseDirective {
|
|
194
|
+
private readonly popoverRef;
|
|
195
|
+
/**
|
|
196
|
+
* Optional result value to pass when closing.
|
|
197
|
+
* This value is emitted via the trigger's close event.
|
|
198
|
+
*/
|
|
199
|
+
readonly comPopoverClose: InputSignal<unknown>;
|
|
200
|
+
protected closePopover(): void;
|
|
201
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PopoverCloseDirective, never>;
|
|
202
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<PopoverCloseDirective, "[comPopoverClose]", ["comPopoverClose"], { "comPopoverClose": { "alias": "comPopoverClose"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Marker directive for lazy popover content templates.
|
|
207
|
+
* Applied to `<ng-template>` to indicate content that should be
|
|
208
|
+
* lazily instantiated when the popover opens.
|
|
209
|
+
*
|
|
210
|
+
* This directive is primarily semantic — it marks the template as popover content
|
|
211
|
+
* and provides access to the TemplateRef for potential content queries.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```html
|
|
215
|
+
* <button [comPopoverTrigger]="helpContent">Help</button>
|
|
216
|
+
* <ng-template comPopoverTemplate #helpContent>
|
|
217
|
+
* <p>This is help content.</p>
|
|
218
|
+
* </ng-template>
|
|
219
|
+
* ```
|
|
220
|
+
*
|
|
221
|
+
* Note: You can also pass a template reference directly without this directive:
|
|
222
|
+
* ```html
|
|
223
|
+
* <button [comPopoverTrigger]="helpContent">Help</button>
|
|
224
|
+
* <ng-template #helpContent>
|
|
225
|
+
* <p>This also works.</p>
|
|
226
|
+
* </ng-template>
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare class PopoverTemplateDirective {
|
|
230
|
+
/** Reference to the template for rendering. */
|
|
231
|
+
readonly templateRef: TemplateRef<unknown>;
|
|
232
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PopoverTemplateDirective, never>;
|
|
233
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<PopoverTemplateDirective, "[comPopoverTemplate]", ["comPopoverTemplate"], {}, {}, never, never, true, never>;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Interface for the popover reference injected into content.
|
|
238
|
+
* Provides methods to control the popover from within content.
|
|
239
|
+
*/
|
|
240
|
+
interface PopoverRef {
|
|
241
|
+
/** Programmatically open the popover. */
|
|
242
|
+
open(): void;
|
|
243
|
+
/** Programmatically close the popover. */
|
|
244
|
+
close(): void;
|
|
245
|
+
/** Toggle the popover open/close state. */
|
|
246
|
+
toggle(): void;
|
|
247
|
+
/** Force recalculation of position. */
|
|
248
|
+
reposition(): void;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Data passed to a component rendered inside the popover.
|
|
252
|
+
* Inject this token to access the data provided via `popoverData` input.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* @Component({ ... })
|
|
257
|
+
* export class UserProfilePopover {
|
|
258
|
+
* readonly data = inject(POPOVER_DATA); // { userId: '123' }
|
|
259
|
+
* }
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
declare const POPOVER_DATA: InjectionToken<unknown>;
|
|
263
|
+
/**
|
|
264
|
+
* Reference to the popover trigger directive for closing from inside the popover.
|
|
265
|
+
* Inject this token to programmatically close the popover from within content.
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* @Component({ ... })
|
|
270
|
+
* export class UserProfilePopover {
|
|
271
|
+
* readonly popoverRef = inject(POPOVER_REF);
|
|
272
|
+
*
|
|
273
|
+
* save(): void {
|
|
274
|
+
* // ... save logic
|
|
275
|
+
* this.popoverRef.close();
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
declare const POPOVER_REF: InjectionToken<PopoverRef>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Build an ordered list of position pairs for the CDK overlay.
|
|
284
|
+
* The first position is the preferred position; remaining positions are fallbacks.
|
|
285
|
+
*
|
|
286
|
+
* @param position - Preferred position direction ('above', 'below', 'left', 'right', 'auto')
|
|
287
|
+
* @param alignment - Alignment along the cross-axis ('start', 'center', 'end')
|
|
288
|
+
* @param offset - Gap in pixels between trigger and popover edge (default: 8)
|
|
289
|
+
* @returns Array of ConnectedPosition for FlexibleConnectedPositionStrategy
|
|
290
|
+
*/
|
|
291
|
+
declare function buildPopoverPositions(position: PopoverPosition, alignment: PopoverAlignment, offset?: number): ConnectedPosition[];
|
|
292
|
+
/**
|
|
293
|
+
* Derive which side of the trigger the popover is on from a connection pair.
|
|
294
|
+
* Used to position the arrow correctly.
|
|
295
|
+
*
|
|
296
|
+
* The returned side indicates where the popover sits relative to the trigger:
|
|
297
|
+
* - 'bottom': popover is below trigger, arrow at top pointing up
|
|
298
|
+
* - 'top': popover is above trigger, arrow at bottom pointing down
|
|
299
|
+
* - 'right': popover is right of trigger, arrow at left pointing left
|
|
300
|
+
* - 'left': popover is left of trigger, arrow at right pointing right
|
|
301
|
+
*/
|
|
302
|
+
declare function deriveSideFromPosition(pair: ConnectionPositionPair): PopoverSide;
|
|
303
|
+
/**
|
|
304
|
+
* Derive alignment from a connection pair.
|
|
305
|
+
*/
|
|
306
|
+
declare function deriveAlignmentFromPosition(pair: ConnectionPositionPair): PopoverAlignment;
|
|
307
|
+
|
|
308
|
+
export { POPOVER_DATA, POPOVER_REF, PopoverCloseDirective, PopoverTemplateDirective, PopoverTriggerDirective, buildPopoverPositions, deriveAlignmentFromPosition, deriveSideFromPosition, popoverArrowVariants, popoverPanelVariants };
|
|
309
|
+
export type { PopoverAlignment, PopoverArrowVariants, PopoverBackdrop, PopoverPanelVariants, PopoverPosition, PopoverRef, PopoverSide, PopoverTriggerOn, PopoverVariant };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Signal, InputSignal, ModelSignal, InputSignalWithTransform, OutputEmitterRef, OnInit, ElementRef } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NgControl } from '@angular/forms';
|
|
4
|
+
import { ErrorStateMatcher } from 'ngx-com/components/form-field';
|
|
5
|
+
|
|
6
|
+
/** Radio size variants. */
|
|
7
|
+
type RadioSize = 'sm' | 'md' | 'lg';
|
|
8
|
+
/** Radio color variants. */
|
|
9
|
+
type RadioVariant = 'primary' | 'accent' | 'warn';
|
|
10
|
+
/** Radio group orientation. */
|
|
11
|
+
type RadioOrientation = 'vertical' | 'horizontal';
|
|
12
|
+
/**
|
|
13
|
+
* CVA variants for the visual radio circle.
|
|
14
|
+
*
|
|
15
|
+
* Uses `peer` selectors to style based on native input state:
|
|
16
|
+
* - `peer-checked:` for checked state
|
|
17
|
+
* - `peer-focus-visible:` for keyboard focus
|
|
18
|
+
* - `peer-disabled:` for disabled state
|
|
19
|
+
*
|
|
20
|
+
* @tokens `--color-border`, `--color-primary`, `--color-primary-hover`,
|
|
21
|
+
* `--color-accent`, `--color-accent-hover`,
|
|
22
|
+
* `--color-warn`, `--color-warn-hover`,
|
|
23
|
+
* `--color-disabled`, `--color-ring`
|
|
24
|
+
*/
|
|
25
|
+
declare const radioCircleVariants: (props?: {
|
|
26
|
+
variant?: RadioVariant;
|
|
27
|
+
size?: RadioSize;
|
|
28
|
+
}) => string;
|
|
29
|
+
/** Size-based classes for the inner dot indicator. */
|
|
30
|
+
declare const RADIO_DOT_SIZES: Record<RadioSize, string>;
|
|
31
|
+
/** Size-based classes for the label content. */
|
|
32
|
+
declare const RADIO_LABEL_SIZES: Record<RadioSize, string>;
|
|
33
|
+
/** Orientation-based classes for the radio group container. */
|
|
34
|
+
declare const RADIO_GROUP_ORIENTATIONS: Record<RadioOrientation, string>;
|
|
35
|
+
|
|
36
|
+
/** Event emitted when radio group value changes. */
|
|
37
|
+
interface RadioGroupChange {
|
|
38
|
+
value: string | null;
|
|
39
|
+
}
|
|
40
|
+
/** Interface for radio items that register with the group. */
|
|
41
|
+
interface RadioItem {
|
|
42
|
+
value: () => string;
|
|
43
|
+
isDisabled: () => boolean;
|
|
44
|
+
focus: () => void;
|
|
45
|
+
}
|
|
46
|
+
/** Context provided to child radio components via DI. */
|
|
47
|
+
interface ComRadioGroupContext {
|
|
48
|
+
name: Signal<string>;
|
|
49
|
+
value: Signal<string | null>;
|
|
50
|
+
disabled: Signal<boolean>;
|
|
51
|
+
size: Signal<RadioSize>;
|
|
52
|
+
variant: Signal<RadioVariant>;
|
|
53
|
+
orientation: Signal<RadioOrientation>;
|
|
54
|
+
focusedValue: Signal<string | null>;
|
|
55
|
+
select: (value: string) => void;
|
|
56
|
+
focusNext: (currentValue: string) => void;
|
|
57
|
+
focusPrevious: (currentValue: string) => void;
|
|
58
|
+
register: (radio: RadioItem) => void;
|
|
59
|
+
unregister: (radio: RadioItem) => void;
|
|
60
|
+
onTouched?: () => void;
|
|
61
|
+
}
|
|
62
|
+
/** Injection token for radio group context. */
|
|
63
|
+
declare const COM_RADIO_GROUP: InjectionToken<ComRadioGroupContext>;
|
|
64
|
+
/**
|
|
65
|
+
* Radio group component that manages a set of radio buttons.
|
|
66
|
+
*
|
|
67
|
+
* Provides mutual exclusion, shared name, and roving tabindex keyboard navigation.
|
|
68
|
+
* Implements `ControlValueAccessor` for Reactive Forms integration.
|
|
69
|
+
*
|
|
70
|
+
* @tokens `--color-border`, `--color-primary`, `--color-primary-foreground`, `--color-primary-hover`,
|
|
71
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-hover`,
|
|
72
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-hover`,
|
|
73
|
+
* `--color-disabled`, `--color-disabled-foreground`, `--color-ring`
|
|
74
|
+
*
|
|
75
|
+
* @example Basic usage
|
|
76
|
+
* ```html
|
|
77
|
+
* <com-radio-group [(value)]="selectedFruit" aria-label="Select a fruit">
|
|
78
|
+
* <com-radio value="apple">Apple</com-radio>
|
|
79
|
+
* <com-radio value="banana">Banana</com-radio>
|
|
80
|
+
* <com-radio value="cherry">Cherry</com-radio>
|
|
81
|
+
* </com-radio-group>
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @example With reactive forms
|
|
85
|
+
* ```html
|
|
86
|
+
* <com-radio-group formControlName="size" aria-label="Select size">
|
|
87
|
+
* <com-radio value="sm">Small</com-radio>
|
|
88
|
+
* <com-radio value="md">Medium</com-radio>
|
|
89
|
+
* <com-radio value="lg">Large</com-radio>
|
|
90
|
+
* </com-radio-group>
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @example Horizontal orientation
|
|
94
|
+
* ```html
|
|
95
|
+
* <com-radio-group [(value)]="color" orientation="horizontal">
|
|
96
|
+
* <com-radio value="red">Red</com-radio>
|
|
97
|
+
* <com-radio value="green">Green</com-radio>
|
|
98
|
+
* <com-radio value="blue">Blue</com-radio>
|
|
99
|
+
* </com-radio-group>
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @example With variants
|
|
103
|
+
* ```html
|
|
104
|
+
* <com-radio-group [(value)]="priority" variant="warn" size="lg">
|
|
105
|
+
* <com-radio value="low">Low</com-radio>
|
|
106
|
+
* <com-radio value="medium">Medium</com-radio>
|
|
107
|
+
* <com-radio value="high">High</com-radio>
|
|
108
|
+
* </com-radio-group>
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
declare class ComRadioGroup implements ControlValueAccessor {
|
|
112
|
+
/** Optional NgControl for reactive forms integration. */
|
|
113
|
+
readonly ngControl: NgControl | null;
|
|
114
|
+
/** Error state matcher for determining when to show validation errors. */
|
|
115
|
+
private readonly defaultErrorStateMatcher;
|
|
116
|
+
private readonly parentForm;
|
|
117
|
+
private readonly parentFormGroup;
|
|
118
|
+
/** Unique ID for this radio group instance. */
|
|
119
|
+
private readonly uniqueId;
|
|
120
|
+
/** ID for the error message element. */
|
|
121
|
+
readonly errorId: string;
|
|
122
|
+
/** Registered radio items. */
|
|
123
|
+
private readonly registeredRadios;
|
|
124
|
+
readonly name: InputSignal<string>;
|
|
125
|
+
readonly value: ModelSignal<string | null>;
|
|
126
|
+
readonly disabled: ModelSignal<boolean>;
|
|
127
|
+
readonly required: InputSignalWithTransform<boolean, unknown>;
|
|
128
|
+
readonly orientation: InputSignal<RadioOrientation>;
|
|
129
|
+
readonly size: InputSignal<RadioSize>;
|
|
130
|
+
readonly variant: InputSignal<RadioVariant>;
|
|
131
|
+
readonly errorMessage: InputSignal<string>;
|
|
132
|
+
readonly errorStateMatcher: InputSignal<ErrorStateMatcher | undefined>;
|
|
133
|
+
/** Internal signal to track when control is touched, used to trigger error state re-evaluation. */
|
|
134
|
+
private readonly _touched;
|
|
135
|
+
readonly ariaLabel: InputSignal<string | null>;
|
|
136
|
+
readonly ariaLabelledby: InputSignal<string | null>;
|
|
137
|
+
readonly ariaDescribedby: InputSignal<string | null>;
|
|
138
|
+
/** Emits when the selection changes, with full event details. */
|
|
139
|
+
readonly selectionChange: OutputEmitterRef<RadioGroupChange>;
|
|
140
|
+
/**
|
|
141
|
+
* Tracks the currently focused radio value for roving tabindex.
|
|
142
|
+
* Resets to the current selection (or first focusable) when value or radios change.
|
|
143
|
+
*/
|
|
144
|
+
private readonly focusedValueSignal;
|
|
145
|
+
/**
|
|
146
|
+
* Computed error state derived from form validation.
|
|
147
|
+
* Shows errors when control is invalid and touched/submitted.
|
|
148
|
+
*/
|
|
149
|
+
readonly errorState: Signal<boolean>;
|
|
150
|
+
readonly computedAriaDescribedby: Signal<string | null>;
|
|
151
|
+
protected readonly groupClasses: Signal<string>;
|
|
152
|
+
private onChange;
|
|
153
|
+
private onTouchedCallback;
|
|
154
|
+
constructor();
|
|
155
|
+
/** Creates the context object for child radios. */
|
|
156
|
+
createContext(): ComRadioGroupContext;
|
|
157
|
+
/** Register a radio item with the group. */
|
|
158
|
+
private register;
|
|
159
|
+
/** Unregister a radio item from the group. */
|
|
160
|
+
private unregister;
|
|
161
|
+
writeValue(value: string | null): void;
|
|
162
|
+
registerOnChange(fn: (value: string | null) => void): void;
|
|
163
|
+
registerOnTouched(fn: () => void): void;
|
|
164
|
+
setDisabledState(isDisabled: boolean): void;
|
|
165
|
+
/** Selects a radio by value. */
|
|
166
|
+
select(newValue: string): void;
|
|
167
|
+
/** Focuses the next non-disabled radio (with cyclic wrap). */
|
|
168
|
+
focusNext(currentValue: string): void;
|
|
169
|
+
/** Focuses the previous non-disabled radio (with cyclic wrap). */
|
|
170
|
+
focusPrevious(currentValue: string): void;
|
|
171
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComRadioGroup, never>;
|
|
172
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComRadioGroup, "com-radio-group", ["comRadioGroup"], { "name": { "alias": "name"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "errorMessage": { "alias": "errorMessage"; "required": false; "isSignal": true; }; "errorStateMatcher": { "alias": "errorStateMatcher"; "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; }; }, { "value": "valueChange"; "disabled": "disabledChange"; "selectionChange": "selectionChange"; }, never, ["*"], true, never>;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Event emitted when a radio is selected. */
|
|
176
|
+
interface RadioChange {
|
|
177
|
+
value: string;
|
|
178
|
+
source: ComRadio;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Production-grade radio component with full accessibility support.
|
|
182
|
+
*
|
|
183
|
+
* Uses a native `<input type="radio">` for built-in keyboard handling,
|
|
184
|
+
* `:checked` pseudo-class, and screen reader support.
|
|
185
|
+
*
|
|
186
|
+
* Must be used within a `ComRadioGroup` which manages the selected value
|
|
187
|
+
* and provides the shared `name` attribute.
|
|
188
|
+
*
|
|
189
|
+
* @tokens `--color-border`, `--color-primary`, `--color-primary-foreground`, `--color-primary-hover`,
|
|
190
|
+
* `--color-accent`, `--color-accent-foreground`, `--color-accent-hover`,
|
|
191
|
+
* `--color-warn`, `--color-warn-foreground`, `--color-warn-hover`,
|
|
192
|
+
* `--color-disabled`, `--color-disabled-foreground`, `--color-ring`
|
|
193
|
+
*
|
|
194
|
+
* @example Basic usage within a group
|
|
195
|
+
* ```html
|
|
196
|
+
* <com-radio-group [(value)]="selectedOption">
|
|
197
|
+
* <com-radio value="option1">Option 1</com-radio>
|
|
198
|
+
* <com-radio value="option2">Option 2</com-radio>
|
|
199
|
+
* <com-radio value="option3">Option 3</com-radio>
|
|
200
|
+
* </com-radio-group>
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @example Disabled option
|
|
204
|
+
* ```html
|
|
205
|
+
* <com-radio-group [(value)]="selected">
|
|
206
|
+
* <com-radio value="enabled">Enabled option</com-radio>
|
|
207
|
+
* <com-radio value="disabled" [disabled]="true">Disabled option</com-radio>
|
|
208
|
+
* </com-radio-group>
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
declare class ComRadio implements OnInit, RadioItem {
|
|
212
|
+
/** Optional parent radio group context. */
|
|
213
|
+
private readonly group;
|
|
214
|
+
/** DestroyRef for cleanup. */
|
|
215
|
+
private readonly destroyRef;
|
|
216
|
+
/** Reference to the native input element. */
|
|
217
|
+
readonly inputRef: Signal<ElementRef<HTMLInputElement> | undefined>;
|
|
218
|
+
/** Unique ID for this radio instance. */
|
|
219
|
+
private readonly uniqueId;
|
|
220
|
+
readonly value: InputSignal<string>;
|
|
221
|
+
readonly size: InputSignal<RadioSize>;
|
|
222
|
+
readonly variant: InputSignal<RadioVariant>;
|
|
223
|
+
readonly disabled: ModelSignal<boolean>;
|
|
224
|
+
readonly id: InputSignal<string | undefined>;
|
|
225
|
+
readonly ariaLabel: InputSignal<string | null>;
|
|
226
|
+
readonly ariaLabelledby: InputSignal<string | null>;
|
|
227
|
+
readonly ariaDescribedby: InputSignal<string | null>;
|
|
228
|
+
readonly changed: OutputEmitterRef<RadioChange>;
|
|
229
|
+
readonly inputId: Signal<string>;
|
|
230
|
+
/** Resolve size from group or local input. */
|
|
231
|
+
readonly resolvedSize: Signal<RadioSize>;
|
|
232
|
+
/** Resolve variant from group or local input. */
|
|
233
|
+
readonly resolvedVariant: Signal<RadioVariant>;
|
|
234
|
+
/** Whether this radio is checked based on group value. */
|
|
235
|
+
readonly isChecked: Signal<boolean>;
|
|
236
|
+
/** Whether this radio is disabled (from local or group). */
|
|
237
|
+
readonly isDisabled: Signal<boolean>;
|
|
238
|
+
/** Get name from group. */
|
|
239
|
+
readonly groupName: Signal<string | undefined>;
|
|
240
|
+
/** Tab index for roving tabindex pattern. */
|
|
241
|
+
readonly tabIndex: Signal<number>;
|
|
242
|
+
protected readonly circleClasses: Signal<string>;
|
|
243
|
+
protected readonly dotSizeClass: Signal<string>;
|
|
244
|
+
protected readonly labelSizeClass: Signal<string>;
|
|
245
|
+
ngOnInit(): void;
|
|
246
|
+
protected onInputChange(event: Event): void;
|
|
247
|
+
protected onBlur(): void;
|
|
248
|
+
protected onKeyDown(event: KeyboardEvent): void;
|
|
249
|
+
/** Focuses this radio's input element. */
|
|
250
|
+
focus(): void;
|
|
251
|
+
/** Selects this radio programmatically. */
|
|
252
|
+
select(): void;
|
|
253
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<ComRadio, never>;
|
|
254
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<ComRadio, "com-radio", ["comRadio"], { "value": { "alias": "value"; "required": true; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "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; }; }, { "disabled": "disabledChange"; "changed": "changed"; }, never, ["*"], true, never>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { COM_RADIO_GROUP, ComRadio, ComRadioGroup, RADIO_DOT_SIZES, RADIO_GROUP_ORIENTATIONS, RADIO_LABEL_SIZES, radioCircleVariants };
|
|
258
|
+
export type { ComRadioGroupContext, RadioChange, RadioGroupChange, RadioItem, RadioOrientation, RadioSize, RadioVariant };
|