ng-primitives 0.35.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/visually-hidden/visually-hidden-state.d.ts +1 -1
- package/accordion/accordion/accordion-state.d.ts +1 -1
- package/accordion/accordion-item/accordion-item-state.d.ts +1 -1
- package/avatar/avatar/avatar-state.d.ts +1 -1
- package/button/button/button-state.d.ts +1 -1
- package/checkbox/checkbox/checkbox-state.d.ts +1 -1
- package/date-picker/date-picker/date-picker-state.d.ts +1 -1
- package/dialog/dialog/dialog-state.d.ts +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs +6 -4
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +73 -50
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +95 -59
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-radio.mjs +4 -0
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-state.mjs +10 -3
- package/fesm2022/ng-primitives-state.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs +17 -22
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +94 -43
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +18 -0
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/file-upload/file-dropzone/file-dropzone-state.d.ts +2 -2
- package/file-upload/file-dropzone/file-dropzone.d.ts +3 -2
- package/file-upload/file-upload/file-upload-state.d.ts +2 -2
- package/file-upload/file-upload/file-upload.d.ts +3 -2
- package/form-field/form-control/form-control-state.d.ts +1 -1
- package/form-field/form-field/form-field-state.d.ts +1 -1
- package/input/input/input-state.d.ts +1 -1
- package/internal/exit-animation/exit-animation-manager.d.ts +17 -0
- package/internal/exit-animation/exit-animation.d.ts +4 -17
- package/internal/index.d.ts +2 -1
- package/listbox/listbox/listbox-state.d.ts +2 -2
- package/package.json +5 -5
- package/pagination/pagination/pagination-state.d.ts +1 -1
- package/popover/index.d.ts +1 -0
- package/popover/popover/popover-token.d.ts +10 -0
- package/popover/popover/popover.d.ts +3 -2
- package/popover/popover-trigger/popover-trigger-state.d.ts +5 -3
- package/popover/popover-trigger/popover-trigger.d.ts +26 -18
- package/progress/progress/progress-state.d.ts +1 -1
- package/radio/radio-group/radio-group-state.d.ts +1 -1
- package/radio/radio-item/radio-item-state.d.ts +1 -1
- package/roving-focus/roving-focus-group/roving-focus-group-state.d.ts +1 -1
- package/schematics/ng-generate/schema.d.ts +3 -1
- package/schematics/ng-generate/schema.json +3 -1
- package/schematics/ng-generate/templates/toolbar/toolbar-button.__fileSuffix@dasherize__.ts.template +58 -0
- package/schematics/ng-generate/templates/toolbar/toolbar.__fileSuffix@dasherize__.ts.template +29 -0
- package/schematics/ng-generate/templates/tooltip/tooltip-trigger.__fileSuffix@dasherize__.ts.template +35 -0
- package/schematics/ng-generate/templates/tooltip/tooltip.__fileSuffix@dasherize__.ts.template +60 -0
- package/search/search/search-state.d.ts +1 -1
- package/select/select/select-state.d.ts +1 -1
- package/slider/slider/slider-state.d.ts +1 -1
- package/state/index.d.ts +7 -1
- package/switch/switch/switch-state.d.ts +1 -1
- package/tabs/index.d.ts +1 -2
- package/tabs/tab-button/tab-button.d.ts +2 -2
- package/tabs/tabset/tabset-state.d.ts +1 -1
- package/textarea/textarea/textarea-state.d.ts +1 -1
- package/toggle/toggle/toggle-state.d.ts +1 -1
- package/toggle-group/toggle-group/toggle-group-state.d.ts +1 -1
- package/toggle-group/toggle-group-item/toggle-group-item-state.d.ts +1 -1
- package/tooltip/index.d.ts +1 -0
- package/tooltip/tooltip/tooltip-token.d.ts +10 -0
- package/tooltip/tooltip/tooltip.d.ts +2 -1
- package/tooltip/tooltip-trigger/tooltip-trigger-state.d.ts +3 -3
- package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +39 -18
- package/tabs/tabset/tabset-token.d.ts +0 -11
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject,
|
|
2
|
+
import { InjectionToken, inject, ViewContainerRef, Injector, input, booleanAttribute, numberAttribute, signal, computed, ComponentRef, TemplateRef, Type, Directive } from '@angular/core';
|
|
3
3
|
import { FocusMonitor, InteractivityChecker } from '@angular/cdk/a11y';
|
|
4
4
|
import { ViewportRuler, BlockScrollStrategy, NoopScrollStrategy } from '@angular/cdk/overlay';
|
|
5
|
-
import { TemplatePortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
5
|
+
import { TemplatePortal, ComponentPortal, DomPortalOutlet } from '@angular/cdk/portal';
|
|
6
6
|
import { DOCUMENT } from '@angular/common';
|
|
7
7
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
8
|
import { offset, shift, flip, autoUpdate, computePosition } from '@floating-ui/dom';
|
|
9
|
+
import * as i2 from 'ng-primitives/internal';
|
|
10
|
+
import { injectElementRef, injectExitAnimationManager, provideExitAnimationManager, NgpExitAnimation } from 'ng-primitives/internal';
|
|
9
11
|
import { fromResizeEvent } from 'ng-primitives/resize';
|
|
10
|
-
import { injectDisposables
|
|
12
|
+
import { injectDisposables } from 'ng-primitives/utils';
|
|
11
13
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
12
14
|
import * as i1 from 'ng-primitives/focus-trap';
|
|
13
15
|
import { NgpFocusTrap } from 'ng-primitives/focus-trap';
|
|
14
|
-
import { injectElementRef } from 'ng-primitives/internal';
|
|
15
16
|
|
|
16
17
|
const defaultPopoverConfig = {
|
|
17
18
|
offset: 4,
|
|
@@ -46,6 +47,20 @@ function injectPopoverConfig() {
|
|
|
46
47
|
return inject(NgpPopoverConfigToken, { optional: true }) ?? defaultPopoverConfig;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
const NgpPopoverContextToken = new InjectionToken('NgpPopoverContextToken');
|
|
51
|
+
/**
|
|
52
|
+
* Inject the Popover context
|
|
53
|
+
*/
|
|
54
|
+
function injectPopoverContext() {
|
|
55
|
+
return inject(NgpPopoverContextToken);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Provide the Popover context
|
|
59
|
+
*/
|
|
60
|
+
function providePopoverContext(context) {
|
|
61
|
+
return { provide: NgpPopoverContextToken, useValue: context };
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
/**
|
|
50
65
|
* The state token for the PopoverTrigger primitive.
|
|
51
66
|
*/
|
|
@@ -71,13 +86,17 @@ class NgpPopoverTrigger {
|
|
|
71
86
|
/**
|
|
72
87
|
* Access the trigger element
|
|
73
88
|
*/
|
|
74
|
-
this.trigger =
|
|
89
|
+
this.trigger = injectElementRef();
|
|
90
|
+
/**
|
|
91
|
+
* Access the exit animation state.
|
|
92
|
+
*/
|
|
93
|
+
this.exitAnimationState = injectExitAnimationManager();
|
|
75
94
|
/**
|
|
76
95
|
* Inject the parent popover trigger if available.
|
|
77
96
|
*/
|
|
78
97
|
this.parentTrigger = injectPopoverTriggerState({
|
|
79
|
-
optional: true,
|
|
80
98
|
skipSelf: true,
|
|
99
|
+
optional: true,
|
|
81
100
|
});
|
|
82
101
|
/**
|
|
83
102
|
* Access the view container ref.
|
|
@@ -110,23 +129,9 @@ class NgpPopoverTrigger {
|
|
|
110
129
|
/**
|
|
111
130
|
* Access the popover template ref.
|
|
112
131
|
*/
|
|
113
|
-
this.popover = input
|
|
132
|
+
this.popover = input(null, {
|
|
114
133
|
alias: 'ngpPopoverTrigger',
|
|
115
134
|
});
|
|
116
|
-
/**
|
|
117
|
-
* The open state of the popover.
|
|
118
|
-
* @default false
|
|
119
|
-
*/
|
|
120
|
-
this.open = input(false, {
|
|
121
|
-
alias: 'ngpPopoverTriggerOpen',
|
|
122
|
-
transform: booleanAttribute,
|
|
123
|
-
});
|
|
124
|
-
/**
|
|
125
|
-
* Emit when the open state changes.
|
|
126
|
-
*/
|
|
127
|
-
this.openChange = output({
|
|
128
|
-
alias: 'ngpPopoverTriggerOpenChange',
|
|
129
|
-
});
|
|
130
135
|
/**
|
|
131
136
|
* Define if the trigger should be disabled.
|
|
132
137
|
* @default false
|
|
@@ -204,10 +209,21 @@ class NgpPopoverTrigger {
|
|
|
204
209
|
this.scrollBehavior = input(this.config.scrollBehavior, {
|
|
205
210
|
alias: 'ngpPopoverTriggerScrollBehavior',
|
|
206
211
|
});
|
|
212
|
+
/**
|
|
213
|
+
* Provide context to the popover.
|
|
214
|
+
* @default null
|
|
215
|
+
*/
|
|
216
|
+
this.context = input(null, {
|
|
217
|
+
alias: 'ngpPopoverTriggerContext',
|
|
218
|
+
});
|
|
207
219
|
/**
|
|
208
220
|
* Store the popover view ref.
|
|
209
221
|
*/
|
|
210
|
-
this.viewRef = null;
|
|
222
|
+
this.viewRef = signal(null);
|
|
223
|
+
/**
|
|
224
|
+
* Determines if the popover is open.
|
|
225
|
+
*/
|
|
226
|
+
this.open = computed(() => this.viewRef() !== null);
|
|
211
227
|
/**
|
|
212
228
|
* Derive the popover middleware from the provided configuration.
|
|
213
229
|
*/
|
|
@@ -246,6 +262,7 @@ class NgpPopoverTrigger {
|
|
|
246
262
|
* @internal
|
|
247
263
|
* Register any child popover to the stack.
|
|
248
264
|
*/
|
|
265
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
249
266
|
this.stack = [];
|
|
250
267
|
/**
|
|
251
268
|
* The popover trigger state.
|
|
@@ -253,8 +270,6 @@ class NgpPopoverTrigger {
|
|
|
253
270
|
this.state = popoverTriggerState(this);
|
|
254
271
|
// if the trigger has a parent trigger then register it to the stack
|
|
255
272
|
this.parentTrigger()?.stack.push(this);
|
|
256
|
-
// any time the open state changes then show or hide the popover
|
|
257
|
-
onBooleanChange(this.state.open, this.show.bind(this, 'program'), this.hide.bind(this, 'program'));
|
|
258
273
|
// update the width of the trigger when it resizes
|
|
259
274
|
fromResizeEvent(this.trigger.nativeElement)
|
|
260
275
|
.pipe(takeUntilDestroyed())
|
|
@@ -262,7 +277,7 @@ class NgpPopoverTrigger {
|
|
|
262
277
|
}
|
|
263
278
|
ngOnDestroy() {
|
|
264
279
|
// remove the trigger from the parent trigger's stack
|
|
265
|
-
this.parentTrigger()?.stack.splice(this.parentTrigger()
|
|
280
|
+
this.parentTrigger()?.stack.splice(this.parentTrigger()?.stack.indexOf(this), 1);
|
|
266
281
|
this.destroyPopover();
|
|
267
282
|
}
|
|
268
283
|
toggleOpenState(event) {
|
|
@@ -273,7 +288,7 @@ class NgpPopoverTrigger {
|
|
|
273
288
|
// determine the origin of the event, 0 is keyboard, 1 is mouse
|
|
274
289
|
const origin = event.detail === 0 ? 'keyboard' : 'mouse';
|
|
275
290
|
// if the popover is open then hide it
|
|
276
|
-
if (this.
|
|
291
|
+
if (this.open()) {
|
|
277
292
|
this.hide(origin);
|
|
278
293
|
}
|
|
279
294
|
else {
|
|
@@ -281,20 +296,17 @@ class NgpPopoverTrigger {
|
|
|
281
296
|
}
|
|
282
297
|
}
|
|
283
298
|
/**
|
|
284
|
-
* @internal
|
|
285
299
|
* Show the popover.
|
|
286
300
|
*/
|
|
287
301
|
show(origin) {
|
|
288
302
|
// if closing is in progress then clear the timeout to stop the popover from closing
|
|
289
303
|
this.closeTimeout?.();
|
|
290
304
|
// if the trigger is disabled or the popover is already open then do not show the popover
|
|
291
|
-
if (this.state.disabled() || this.
|
|
305
|
+
if (this.state.disabled() || this.openTimeout) {
|
|
292
306
|
return;
|
|
293
307
|
}
|
|
294
308
|
this.openTimeout = this.disposables.setTimeout(() => {
|
|
295
309
|
this.openTimeout = undefined;
|
|
296
|
-
this.state.open.set(true);
|
|
297
|
-
this.openChange.emit(true);
|
|
298
310
|
this.createPopover(origin);
|
|
299
311
|
}, this.state.showDelay());
|
|
300
312
|
// Add document click listener to detect outside clicks
|
|
@@ -311,27 +323,27 @@ class NgpPopoverTrigger {
|
|
|
311
323
|
// if opening is in progress then clear the timeout to stop the popover from opening
|
|
312
324
|
this.openTimeout?.();
|
|
313
325
|
// if the trigger is disabled or the popover is not open then do not hide the popover
|
|
314
|
-
if (this.state.disabled() ||
|
|
326
|
+
if (this.state.disabled() || this.closeTimeout || !this.open()) {
|
|
315
327
|
return;
|
|
316
328
|
}
|
|
317
329
|
// close all child popovers
|
|
318
330
|
for (const child of this.stack) {
|
|
319
331
|
child.hide(origin);
|
|
320
332
|
}
|
|
321
|
-
this.closeTimeout = this.disposables.setTimeout(() => {
|
|
333
|
+
this.closeTimeout = this.disposables.setTimeout(async () => {
|
|
322
334
|
this.closeTimeout = undefined;
|
|
323
|
-
this.
|
|
324
|
-
this.openChange.emit(false);
|
|
325
|
-
this.destroyPopover();
|
|
335
|
+
await this.destroyPopover();
|
|
326
336
|
// ensure the trigger is focused after closing the popover
|
|
327
337
|
this.disposables.setTimeout(() => this.focusTrigger(origin), 0);
|
|
328
338
|
}, this.state.hideDelay());
|
|
329
339
|
}
|
|
330
340
|
onDocumentClick(event) {
|
|
331
341
|
const target = event.target;
|
|
342
|
+
const viewRef = this.viewRef();
|
|
343
|
+
// get the popover element
|
|
344
|
+
const popoverElement = viewRef instanceof ComponentRef ? viewRef.location.nativeElement : viewRef?.rootNodes[0];
|
|
332
345
|
// Check if the click is outside the trigger or the popover
|
|
333
|
-
const isOutside = !this.trigger.nativeElement.contains(target) &&
|
|
334
|
-
!this.viewRef?.rootNodes[0]?.contains(target);
|
|
346
|
+
const isOutside = !this.trigger.nativeElement.contains(target) && !popoverElement?.contains(target);
|
|
335
347
|
// Determine if this is a click inside another popover
|
|
336
348
|
if (isOutside) {
|
|
337
349
|
// Close the popover
|
|
@@ -341,14 +353,37 @@ class NgpPopoverTrigger {
|
|
|
341
353
|
createPopover(origin) {
|
|
342
354
|
// clear the open timeout
|
|
343
355
|
this.openTimeout = undefined;
|
|
344
|
-
const
|
|
345
|
-
|
|
356
|
+
const popover = this.state.popover();
|
|
357
|
+
let portal;
|
|
358
|
+
// Create a new inject with the tooltip context
|
|
359
|
+
const injector = Injector.create({
|
|
346
360
|
parent: this.injector,
|
|
347
|
-
providers: [
|
|
348
|
-
})
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
361
|
+
providers: [providePopoverContext(this.state.context())],
|
|
362
|
+
});
|
|
363
|
+
if (popover instanceof TemplateRef) {
|
|
364
|
+
portal = new TemplatePortal(popover, this.viewContainerRef, { $implicit: this.state.context() }, injector);
|
|
365
|
+
}
|
|
366
|
+
else if (popover instanceof Type) {
|
|
367
|
+
portal = new ComponentPortal(popover, this.viewContainerRef, injector);
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
throw new Error('Popover must be either a TemplateRef or a ComponentType');
|
|
371
|
+
}
|
|
372
|
+
const domOutlet = new DomPortalOutlet(this.state.container() ?? this.document.body, undefined, undefined, injector);
|
|
373
|
+
const viewRef = domOutlet.attach(portal);
|
|
374
|
+
this.viewRef.set(viewRef);
|
|
375
|
+
let outletElement = null;
|
|
376
|
+
if (viewRef instanceof ComponentRef) {
|
|
377
|
+
viewRef.changeDetectorRef.detectChanges();
|
|
378
|
+
outletElement = viewRef.location.nativeElement;
|
|
379
|
+
}
|
|
380
|
+
else if (viewRef) {
|
|
381
|
+
viewRef.detectChanges();
|
|
382
|
+
outletElement = viewRef.rootNodes[0];
|
|
383
|
+
}
|
|
384
|
+
if (!outletElement) {
|
|
385
|
+
throw new Error('Outlet element is not available.');
|
|
386
|
+
}
|
|
352
387
|
// determine if the popover is fixed or absolute
|
|
353
388
|
const strategy = getComputedStyle(outletElement).position === 'fixed' ? 'fixed' : 'absolute';
|
|
354
389
|
this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {
|
|
@@ -358,24 +393,25 @@ class NgpPopoverTrigger {
|
|
|
358
393
|
strategy,
|
|
359
394
|
});
|
|
360
395
|
this.position.set({ x: position.x, y: position.y });
|
|
361
|
-
|
|
396
|
+
viewRef?.detectChanges();
|
|
362
397
|
});
|
|
363
398
|
// activate the scroll strategy
|
|
364
399
|
this.scrollStrategy().enable();
|
|
365
400
|
// set the initial focus to the first tabbable element in the popover
|
|
366
401
|
this.popoverInstance?.setInitialFocus(origin);
|
|
367
402
|
}
|
|
368
|
-
destroyPopover() {
|
|
403
|
+
async destroyPopover() {
|
|
369
404
|
// clear the close timeout
|
|
370
405
|
this.closeTimeout = undefined;
|
|
371
|
-
this.
|
|
372
|
-
this.
|
|
406
|
+
await this.exitAnimationState.exit();
|
|
407
|
+
const viewRef = this.viewRef();
|
|
373
408
|
// if the view is already destroyed then do not destroy it again
|
|
374
|
-
|
|
409
|
+
const isDestroyed = viewRef instanceof ComponentRef ? false : viewRef?.destroyed;
|
|
410
|
+
if (viewRef && !isDestroyed) {
|
|
375
411
|
// destroy the view ref
|
|
376
|
-
|
|
412
|
+
viewRef.destroy();
|
|
377
413
|
}
|
|
378
|
-
this.viewRef
|
|
414
|
+
this.viewRef.set(null);
|
|
379
415
|
this.dispose?.();
|
|
380
416
|
// deactivate the scroll strategy
|
|
381
417
|
this.scrollStrategy().disable();
|
|
@@ -404,17 +440,17 @@ class NgpPopoverTrigger {
|
|
|
404
440
|
this.popoverInstance = instance;
|
|
405
441
|
}
|
|
406
442
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpPopoverTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
407
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpPopoverTrigger, isStandalone: true, selector: "[ngpPopoverTrigger]", inputs: { popover: { classPropertyName: "popover", publicName: "ngpPopoverTrigger", isSignal: true, isRequired:
|
|
443
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.7", type: NgpPopoverTrigger, isStandalone: true, selector: "[ngpPopoverTrigger]", inputs: { popover: { classPropertyName: "popover", publicName: "ngpPopoverTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpPopoverTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpPopoverTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpPopoverTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpPopoverTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpPopoverTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpPopoverTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpPopoverTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "ngpPopoverTriggerCloseOnOutsideClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "ngpPopoverTriggerCloseOnEscape", isSignal: true, isRequired: false, transformFunction: null }, scrollBehavior: { classPropertyName: "scrollBehavior", publicName: "ngpPopoverTriggerScrollBehavior", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpPopoverTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "click": "toggleOpenState($event)", "document:keydown.escape": "handleEscapeKey()" }, properties: { "attr.aria-expanded": "open() ? \"true\" : \"false\"", "attr.data-open": "open() ? \"\" : null", "attr.data-placement": "state.placement()", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [providePopoverTriggerState({ inherit: false }), provideExitAnimationManager()], exportAs: ["ngpPopoverTrigger"], ngImport: i0 }); }
|
|
408
444
|
}
|
|
409
445
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpPopoverTrigger, decorators: [{
|
|
410
446
|
type: Directive,
|
|
411
447
|
args: [{
|
|
412
448
|
selector: '[ngpPopoverTrigger]',
|
|
413
449
|
exportAs: 'ngpPopoverTrigger',
|
|
414
|
-
providers: [providePopoverTriggerState()],
|
|
450
|
+
providers: [providePopoverTriggerState({ inherit: false }), provideExitAnimationManager()],
|
|
415
451
|
host: {
|
|
416
|
-
'[attr.aria-expanded]': '
|
|
417
|
-
'[attr.data-open]': '
|
|
452
|
+
'[attr.aria-expanded]': 'open() ? "true" : "false"',
|
|
453
|
+
'[attr.data-open]': 'open() ? "" : null',
|
|
418
454
|
'[attr.data-placement]': 'state.placement()',
|
|
419
455
|
'[attr.data-disabled]': 'state.disabled() ? "" : null',
|
|
420
456
|
'(click)': 'toggleOpenState($event)',
|
|
@@ -508,21 +544,21 @@ class NgpPopover {
|
|
|
508
544
|
}
|
|
509
545
|
}
|
|
510
546
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpPopover, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
511
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.7", type: NgpPopover, isStandalone: true, selector: "[ngpPopover]", host: { attributes: { "role": "menu" }, listeners: { "keydown.escape": "trigger.handleEscapeKey()" }, properties: { "style.left.px": "x()", "style.top.px": "y()", "style.--ngp-popover-trigger-width.px": "trigger().width()", "style.--ngp-popover-transform-origin": "transformOrigin()" } }, exportAs: ["ngpPopover"], hostDirectives: [{ directive: i1.NgpFocusTrap }], ngImport: i0 }); }
|
|
547
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.7", type: NgpPopover, isStandalone: true, selector: "[ngpPopover]", host: { attributes: { "role": "menu" }, listeners: { "keydown.escape": "trigger().handleEscapeKey()" }, properties: { "style.left.px": "x()", "style.top.px": "y()", "style.--ngp-popover-trigger-width.px": "trigger().width()", "style.--ngp-popover-transform-origin": "transformOrigin()" } }, exportAs: ["ngpPopover"], hostDirectives: [{ directive: i1.NgpFocusTrap }, { directive: i2.NgpExitAnimation }], ngImport: i0 }); }
|
|
512
548
|
}
|
|
513
549
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImport: i0, type: NgpPopover, decorators: [{
|
|
514
550
|
type: Directive,
|
|
515
551
|
args: [{
|
|
516
552
|
selector: '[ngpPopover]',
|
|
517
553
|
exportAs: 'ngpPopover',
|
|
518
|
-
hostDirectives: [NgpFocusTrap],
|
|
554
|
+
hostDirectives: [NgpFocusTrap, NgpExitAnimation],
|
|
519
555
|
host: {
|
|
520
556
|
role: 'menu',
|
|
521
557
|
'[style.left.px]': 'x()',
|
|
522
558
|
'[style.top.px]': 'y()',
|
|
523
559
|
'[style.--ngp-popover-trigger-width.px]': 'trigger().width()',
|
|
524
560
|
'[style.--ngp-popover-transform-origin]': 'transformOrigin()',
|
|
525
|
-
'(keydown.escape)': 'trigger.handleEscapeKey()',
|
|
561
|
+
'(keydown.escape)': 'trigger().handleEscapeKey()',
|
|
526
562
|
},
|
|
527
563
|
}]
|
|
528
564
|
}], ctorParameters: () => [] });
|
|
@@ -531,5 +567,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.7", ngImpor
|
|
|
531
567
|
* Generated bundle index. Do not edit.
|
|
532
568
|
*/
|
|
533
569
|
|
|
534
|
-
export { NgpPopover, NgpPopoverTrigger, getTransformOrigin, injectPopoverTriggerState, providePopoverConfig, providePopoverTriggerState };
|
|
570
|
+
export { NgpPopover, NgpPopoverContextToken, NgpPopoverTrigger, getTransformOrigin, injectPopoverContext, injectPopoverTriggerState, providePopoverConfig, providePopoverTriggerState };
|
|
535
571
|
//# sourceMappingURL=ng-primitives-popover.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-popover.mjs","sources":["../../../../packages/ng-primitives/popover/src/config/popover-config.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger-state.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger.ts","../../../../packages/ng-primitives/popover/src/utils/transform-origin.ts","../../../../packages/ng-primitives/popover/src/popover/popover.ts","../../../../packages/ng-primitives/popover/src/ng-primitives-popover.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpPopoverConfig {\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'bottom'\n */\n placement: Placement;\n\n /**\n * Define the delay before the popover is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the popover should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n closeOnOutsideClick: boolean;\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n closeOnEscape: boolean;\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default scroll\n */\n scrollBehavior: 'reposition' | 'block';\n}\n\nexport const defaultPopoverConfig: NgpPopoverConfig = {\n offset: 4,\n placement: 'bottom',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n closeOnOutsideClick: true,\n closeOnEscape: true,\n scrollBehavior: 'reposition',\n};\n\nexport const NgpPopoverConfigToken = new InjectionToken<NgpPopoverConfig>('NgpPopoverConfigToken');\n\n/**\n * Provide the default Popover configuration\n * @param config The Popover configuration\n * @returns The provider\n */\nexport function providePopoverConfig(config: Partial<NgpPopoverConfig>): Provider[] {\n return [\n {\n provide: NgpPopoverConfigToken,\n useValue: { ...defaultPopoverConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Popover configuration\n * @returns The global Popover configuration\n */\nexport function injectPopoverConfig(): NgpPopoverConfig {\n return inject(NgpPopoverConfigToken, { optional: true }) ?? defaultPopoverConfig;\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpPopoverTrigger } from './popover-trigger';\n\n/**\n * The state token for the PopoverTrigger primitive.\n */\nexport const NgpPopoverTriggerStateToken = createStateToken<NgpPopoverTrigger>('PopoverTrigger');\n\n/**\n * Provides the PopoverTrigger state.\n */\nexport const providePopoverTriggerState = createStateProvider(NgpPopoverTriggerStateToken);\n\n/**\n * Injects the PopoverTrigger state.\n */\nexport const injectPopoverTriggerState = createStateInjector<NgpPopoverTrigger>(\n NgpPopoverTriggerStateToken,\n);\n\n/**\n * The PopoverTrigger state registration function.\n */\nexport const popoverTriggerState = createState(NgpPopoverTriggerStateToken);\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { BlockScrollStrategy, NoopScrollStrategy, ViewportRuler } from '@angular/cdk/overlay';\nimport { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT } from '@angular/common';\nimport {\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n EmbeddedViewRef,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n output,\n signal,\n TemplateRef,\n ViewContainerRef,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n autoUpdate,\n computePosition,\n flip,\n Middleware,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport { fromResizeEvent } from 'ng-primitives/resize';\nimport { injectDisposables, onBooleanChange } from 'ng-primitives/utils';\nimport { injectPopoverConfig } from '../config/popover-config';\nimport type { NgpPopover } from '../popover/popover';\nimport {\n injectPopoverTriggerState,\n NgpPopoverTriggerStateToken,\n popoverTriggerState,\n providePopoverTriggerState,\n} from './popover-trigger-state';\n\n/**\n * Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.\n */\n@Directive({\n selector: '[ngpPopoverTrigger]',\n exportAs: 'ngpPopoverTrigger',\n providers: [providePopoverTriggerState()],\n host: {\n '[attr.aria-expanded]': 'state.open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'state.open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggleOpenState($event)',\n '(document:keydown.escape)': 'handleEscapeKey()',\n },\n})\nexport class NgpPopoverTrigger implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Inject the parent popover trigger if available.\n */\n private readonly parentTrigger = injectPopoverTriggerState({\n optional: true,\n skipSelf: true,\n });\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Access the viewport ruler.\n */\n private readonly viewportRuler = inject(ViewportRuler);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global popover configuration.\n */\n private readonly config = injectPopoverConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the popover template ref.\n */\n readonly popover = input.required<TemplateRef<void>>({\n alias: 'ngpPopoverTrigger',\n });\n\n /**\n * The open state of the popover.\n * @default false\n */\n readonly open = input<boolean, BooleanInput>(false, {\n alias: 'ngpPopoverTriggerOpen',\n transform: booleanAttribute,\n });\n\n /**\n * Emit when the open state changes.\n */\n readonly openChange = output<boolean>({\n alias: 'ngpPopoverTriggerOpenChange',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpPopoverTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpPopoverTriggerPlacement',\n });\n\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpPopoverTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpPopoverTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpPopoverTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpPopoverTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the popover should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpPopoverTriggerContainer',\n });\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n readonly closeOnOutsideClick = input<boolean, BooleanInput>(this.config.closeOnOutsideClick, {\n alias: 'ngpPopoverTriggerCloseOnOutsideClick',\n transform: booleanAttribute,\n });\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n readonly closeOnEscape = input<boolean, BooleanInput>(this.config.closeOnEscape, {\n alias: 'ngpPopoverTriggerCloseOnEscape',\n transform: booleanAttribute,\n });\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default 'reposition'\n */\n readonly scrollBehavior = input<'reposition' | 'block'>(this.config.scrollBehavior, {\n alias: 'ngpPopoverTriggerScrollBehavior',\n });\n\n /**\n * Store the popover view ref.\n */\n private viewRef: EmbeddedViewRef<void> | null = null;\n\n /**\n * Derive the popover middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.state.offset()), shift()];\n\n if (this.state.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the popover.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * @internal\n * Store the trigger width.\n */\n readonly width = signal<number | null>(null);\n\n /**\n * The dispose function to stop computing the position of the popover.\n */\n private dispose?: () => void;\n\n /**\n * A document-wide click listener that checks if the click\n * occurred outside of the popover and trigger elements.\n */\n private documentClickListener?: (event: MouseEvent) => void;\n\n /**\n * Store the popover instance.\n * @internal\n */\n private popoverInstance: NgpPopover | null = null;\n\n /**\n * Get the scroll strategy based on the configuration.\n */\n private readonly scrollStrategy = computed(() =>\n this.state.scrollBehavior() === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy(),\n );\n\n /**\n * @internal\n * Register any child popover to the stack.\n */\n readonly stack: NgpPopoverTrigger[] = [];\n\n /**\n * @internal\n * The timeout to open the popover.\n */\n private openTimeout?: () => void;\n\n /**\n * @internal\n * The timeout to close the popover.\n */\n private closeTimeout?: () => void;\n\n /**\n * The popover trigger state.\n */\n protected readonly state = popoverTriggerState<NgpPopoverTrigger>(this);\n\n constructor() {\n // if the trigger has a parent trigger then register it to the stack\n this.parentTrigger()?.stack.push(this);\n\n // any time the open state changes then show or hide the popover\n onBooleanChange(\n this.state.open,\n this.show.bind(this, 'program'),\n this.hide.bind(this, 'program'),\n );\n\n // update the width of the trigger when it resizes\n fromResizeEvent(this.trigger.nativeElement)\n .pipe(takeUntilDestroyed())\n .subscribe(() => this.width.set(this.trigger.nativeElement.offsetWidth));\n }\n\n ngOnDestroy(): void {\n // remove the trigger from the parent trigger's stack\n this.parentTrigger()?.stack.splice(this.parentTrigger().stack.indexOf(this), 1);\n\n this.destroyPopover();\n }\n\n protected toggleOpenState(event: MouseEvent): void {\n // if the trigger is disabled then do not toggle the popover\n if (this.state.disabled()) {\n return;\n }\n\n // determine the origin of the event, 0 is keyboard, 1 is mouse\n const origin: FocusOrigin = event.detail === 0 ? 'keyboard' : 'mouse';\n\n // if the popover is open then hide it\n if (this.state.open()) {\n this.hide(origin);\n } else {\n this.show(origin);\n }\n }\n\n /**\n * @internal\n * Show the popover.\n */\n show(origin: FocusOrigin): void {\n // if closing is in progress then clear the timeout to stop the popover from closing\n this.closeTimeout?.();\n\n // if the trigger is disabled or the popover is already open then do not show the popover\n if (this.state.disabled() || this.state.open() || this.openTimeout) {\n return;\n }\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.state.open.set(true);\n this.openChange.emit(true);\n this.createPopover(origin);\n }, this.state.showDelay());\n\n // Add document click listener to detect outside clicks\n if (this.state.closeOnOutsideClick()) {\n this.documentClickListener = this.onDocumentClick.bind(this);\n this.document.addEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Hide the popover.\n */\n hide(origin: FocusOrigin = 'program'): void {\n // if opening is in progress then clear the timeout to stop the popover from opening\n this.openTimeout?.();\n\n // if the trigger is disabled or the popover is not open then do not hide the popover\n if (this.state.disabled() || !this.state.open() || this.closeTimeout) {\n return;\n }\n\n // close all child popovers\n for (const child of this.stack) {\n child.hide(origin);\n }\n\n this.closeTimeout = this.disposables.setTimeout(() => {\n this.closeTimeout = undefined;\n this.state.open.set(false);\n this.openChange.emit(false);\n\n this.destroyPopover();\n // ensure the trigger is focused after closing the popover\n this.disposables.setTimeout(() => this.focusTrigger(origin), 0);\n }, this.state.hideDelay());\n }\n\n private onDocumentClick(event: MouseEvent): void {\n const target = event.target as HTMLElement;\n\n // Check if the click is outside the trigger or the popover\n const isOutside =\n !this.trigger.nativeElement.contains(target) &&\n !(this.viewRef?.rootNodes[0] as HTMLElement)?.contains(target);\n\n // Determine if this is a click inside another popover\n\n if (isOutside) {\n // Close the popover\n this.hide('mouse');\n }\n }\n\n private createPopover(origin: FocusOrigin): void {\n // clear the open timeout\n this.openTimeout = undefined;\n\n const portal = new TemplatePortal(\n this.state.popover(),\n this.viewContainerRef,\n undefined,\n this.injector,\n );\n\n const domOutlet = new DomPortalOutlet(\n this.state.container() ?? this.document.body,\n undefined,\n undefined,\n Injector.create({\n parent: this.injector,\n providers: [{ provide: NgpPopoverTriggerStateToken, useValue: signal(this.state) }],\n }),\n );\n\n this.viewRef = domOutlet.attach(portal);\n this.viewRef.detectChanges();\n\n const outletElement = this.viewRef.rootNodes[0];\n\n // determine if the popover is fixed or absolute\n const strategy = getComputedStyle(outletElement).position === 'fixed' ? 'fixed' : 'absolute';\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.state.placement(),\n middleware: this.middleware(),\n strategy,\n });\n\n this.position.set({ x: position.x, y: position.y });\n this.viewRef?.detectChanges();\n });\n\n // activate the scroll strategy\n this.scrollStrategy().enable();\n\n // set the initial focus to the first tabbable element in the popover\n this.popoverInstance?.setInitialFocus(origin);\n }\n\n private destroyPopover(): void {\n // clear the close timeout\n this.closeTimeout = undefined;\n\n this.state.open.set(false);\n this.openChange.emit(false);\n\n // if the view is already destroyed then do not destroy it again\n if (this.viewRef && !this.viewRef.destroyed) {\n // destroy the view ref\n this.viewRef.destroy();\n }\n\n this.viewRef = null;\n this.dispose?.();\n\n // deactivate the scroll strategy\n this.scrollStrategy().disable();\n\n // Remove the document click listener when the popover is hidden\n if (this.documentClickListener) {\n this.document.removeEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Handle escape key press to close the popover.\n */\n protected handleEscapeKey(): void {\n if (this.state.closeOnEscape()) {\n this.hide('keyboard');\n }\n }\n\n private focusTrigger(origin: FocusOrigin): void {\n this.focusMonitor.focusVia(this.trigger.nativeElement, origin);\n }\n\n /**\n * Set the popover instance.\n * @internal\n */\n setPopover(instance: NgpPopover): void {\n this.popoverInstance = instance;\n }\n}\n","import type { Placement } from '@floating-ui/dom';\n\nexport function getTransformOrigin(placement: Placement): string {\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n}\n","import { FocusMonitor, FocusOrigin, InteractivityChecker } from '@angular/cdk/a11y';\nimport { computed, Directive, inject } from '@angular/core';\nimport { NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { injectPopoverTriggerState } from '../popover-trigger/popover-trigger-state';\nimport { getTransformOrigin } from '../utils/transform-origin';\n\n/**\n * Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpPopover]',\n exportAs: 'ngpPopover',\n hostDirectives: [NgpFocusTrap],\n host: {\n role: 'menu',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n '[style.--ngp-popover-trigger-width.px]': 'trigger().width()',\n '[style.--ngp-popover-transform-origin]': 'transformOrigin()',\n '(keydown.escape)': 'trigger.handleEscapeKey()',\n },\n})\nexport class NgpPopover {\n /**\n * Access the popover element.\n */\n private readonly popover = injectElementRef();\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivity = inject(InteractivityChecker);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the trigger instance.\n */\n protected readonly trigger = injectPopoverTriggerState();\n\n /**\n * Compute the x position of the popover.\n */\n protected readonly x = computed(() => this.trigger().position().x);\n\n /**\n * Compute the y position of the popover.\n */\n protected readonly y = computed(() => this.trigger().position().y);\n\n /**\n * Derive the transform origin of the popover.\n */\n protected readonly transformOrigin = computed(() =>\n getTransformOrigin(this.trigger().placement()),\n );\n\n constructor() {\n this.trigger().setPopover(this);\n }\n\n /**\n * Focus the first tabbable element inside the popover.\n * If no tabbable element is found, focus the popover itself.\n * @internal\n */\n setInitialFocus(origin: FocusOrigin): void {\n // use a tree walker to find the first tabbable child\n const treeWalker = document.createTreeWalker(\n this.popover.nativeElement,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode: node =>\n node instanceof HTMLElement && this.interactivity.isTabbable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n },\n );\n\n const tabbableNode = treeWalker.nextNode() as HTMLElement | null;\n\n if (tabbableNode) {\n this.focusMonitor.focusVia(tabbableNode, origin);\n } else {\n // if no tabbable child is found, focus the popover element itself\n this.popover.nativeElement.focus();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA2DO,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,QAAQ;AACnB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,mBAAmB,EAAE,IAAI;AACzB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,cAAc,EAAE,YAAY;CAC7B;AAEM,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAmB,uBAAuB,CAAC;AAElG;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;IACpE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACjD,SAA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G;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-popover.mjs","sources":["../../../../packages/ng-primitives/popover/src/config/popover-config.ts","../../../../packages/ng-primitives/popover/src/popover/popover-token.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger-state.ts","../../../../packages/ng-primitives/popover/src/popover-trigger/popover-trigger.ts","../../../../packages/ng-primitives/popover/src/utils/transform-origin.ts","../../../../packages/ng-primitives/popover/src/popover/popover.ts","../../../../packages/ng-primitives/popover/src/ng-primitives-popover.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpPopoverConfig {\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'bottom'\n */\n placement: Placement;\n\n /**\n * Define the delay before the popover is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the popover should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n closeOnOutsideClick: boolean;\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n closeOnEscape: boolean;\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default scroll\n */\n scrollBehavior: 'reposition' | 'block';\n}\n\nexport const defaultPopoverConfig: NgpPopoverConfig = {\n offset: 4,\n placement: 'bottom',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n closeOnOutsideClick: true,\n closeOnEscape: true,\n scrollBehavior: 'reposition',\n};\n\nexport const NgpPopoverConfigToken = new InjectionToken<NgpPopoverConfig>('NgpPopoverConfigToken');\n\n/**\n * Provide the default Popover configuration\n * @param config The Popover configuration\n * @returns The provider\n */\nexport function providePopoverConfig(config: Partial<NgpPopoverConfig>): Provider[] {\n return [\n {\n provide: NgpPopoverConfigToken,\n useValue: { ...defaultPopoverConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Popover configuration\n * @returns The global Popover configuration\n */\nexport function injectPopoverConfig(): NgpPopoverConfig {\n return inject(NgpPopoverConfigToken, { optional: true }) ?? defaultPopoverConfig;\n}\n","import { inject, InjectionToken, ValueProvider } from '@angular/core';\n\nexport const NgpPopoverContextToken = new InjectionToken<unknown>('NgpPopoverContextToken');\n\n/**\n * Inject the Popover context\n */\nexport function injectPopoverContext<T>(): T {\n return inject(NgpPopoverContextToken) as T;\n}\n\n/**\n * Provide the Popover context\n */\nexport function providePopoverContext<T>(context: T): ValueProvider {\n return { provide: NgpPopoverContextToken, useValue: context };\n}\n","import { InjectOptions, Signal } from '@angular/core';\nimport {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n State,\n} from 'ng-primitives/state';\nimport type { NgpPopoverTrigger } from './popover-trigger';\n\n/**\n * The state token for the PopoverTrigger primitive.\n */\nexport const NgpPopoverTriggerStateToken = createStateToken<NgpPopoverTrigger>('PopoverTrigger');\n\n/**\n * Provides the PopoverTrigger state.\n */\nexport const providePopoverTriggerState = createStateProvider(NgpPopoverTriggerStateToken);\n\n/**\n * Injects the PopoverTrigger state.\n */\nexport const injectPopoverTriggerState = createStateInjector<NgpPopoverTrigger>(\n NgpPopoverTriggerStateToken,\n) as <T>(options?: InjectOptions) => Signal<State<NgpPopoverTrigger<T>>>;\n\n/**\n * The PopoverTrigger state registration function.\n */\nexport const popoverTriggerState = createState(NgpPopoverTriggerStateToken);\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { BlockScrollStrategy, NoopScrollStrategy, ViewportRuler } from '@angular/cdk/overlay';\nimport { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT } from '@angular/common';\nimport {\n booleanAttribute,\n ComponentRef,\n computed,\n Directive,\n EmbeddedViewRef,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n signal,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport {\n autoUpdate,\n computePosition,\n flip,\n Middleware,\n offset,\n Placement,\n shift,\n} from '@floating-ui/dom';\nimport {\n injectElementRef,\n injectExitAnimationManager,\n provideExitAnimationManager,\n} from 'ng-primitives/internal';\nimport { fromResizeEvent } from 'ng-primitives/resize';\nimport { injectDisposables } from 'ng-primitives/utils';\nimport { injectPopoverConfig } from '../config/popover-config';\nimport type { NgpPopover } from '../popover/popover';\nimport { providePopoverContext } from '../popover/popover-token';\nimport {\n injectPopoverTriggerState,\n popoverTriggerState,\n providePopoverTriggerState,\n} from './popover-trigger-state';\n\n/**\n * Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.\n */\n@Directive({\n selector: '[ngpPopoverTrigger]',\n exportAs: 'ngpPopoverTrigger',\n providers: [providePopoverTriggerState({ inherit: false }), provideExitAnimationManager()],\n host: {\n '[attr.aria-expanded]': 'open() ? \"true\" : \"false\"',\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-placement]': 'state.placement()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggleOpenState($event)',\n '(document:keydown.escape)': 'handleEscapeKey()',\n },\n})\nexport class NgpPopoverTrigger<T = null> implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = injectElementRef();\n\n /**\n * Access the exit animation state.\n */\n private readonly exitAnimationState = injectExitAnimationManager();\n\n /**\n * Inject the parent popover trigger if available.\n */\n private readonly parentTrigger = injectPopoverTriggerState<T>({\n skipSelf: true,\n optional: true,\n });\n\n /**\n * Access the view container ref.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the document.\n */\n private readonly document = inject(DOCUMENT);\n\n /**\n * Access the viewport ruler.\n */\n private readonly viewportRuler = inject(ViewportRuler);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the global popover configuration.\n */\n private readonly config = injectPopoverConfig();\n\n /**\n * Access the disposable utilities\n */\n private readonly disposables = injectDisposables();\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the popover template ref.\n */\n readonly popover = input<NgpPopoverContent<T> | null>(null, {\n alias: 'ngpPopoverTrigger',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpPopoverTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the popover relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpPopoverTriggerPlacement',\n });\n\n /**\n * Define the offset of the popover relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpPopoverTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpPopoverTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the popover is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpPopoverTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the popover should flip when there is not enough space for the popover.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpPopoverTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the popover should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpPopoverTriggerContainer',\n });\n\n /**\n * Define whether the popover should close when clicking outside of it.\n * @default true\n */\n readonly closeOnOutsideClick = input<boolean, BooleanInput>(this.config.closeOnOutsideClick, {\n alias: 'ngpPopoverTriggerCloseOnOutsideClick',\n transform: booleanAttribute,\n });\n\n /**\n * Define whether the popover should close when the escape key is pressed.\n * @default true\n */\n readonly closeOnEscape = input<boolean, BooleanInput>(this.config.closeOnEscape, {\n alias: 'ngpPopoverTriggerCloseOnEscape',\n transform: booleanAttribute,\n });\n\n /**\n * Defines how the popover behaves when the window is scrolled.\n * @default 'reposition'\n */\n readonly scrollBehavior = input<'reposition' | 'block'>(this.config.scrollBehavior, {\n alias: 'ngpPopoverTriggerScrollBehavior',\n });\n\n /**\n * Provide context to the popover.\n * @default null\n */\n readonly context = input<T | null>(null, {\n alias: 'ngpPopoverTriggerContext',\n });\n\n /**\n * Store the popover view ref.\n */\n protected readonly viewRef = signal<ComponentRef<unknown> | EmbeddedViewRef<void> | null>(null);\n\n /**\n * Determines if the popover is open.\n */\n readonly open = computed(() => this.viewRef() !== null);\n\n /**\n * Derive the popover middleware from the provided configuration.\n */\n private readonly middleware = computed(() => {\n const middleware: Middleware[] = [offset(this.state.offset()), shift()];\n\n if (this.state.flip()) {\n middleware.push(flip());\n }\n\n return middleware;\n });\n\n /**\n * Store the computed position of the popover.\n * @internal\n */\n readonly position = signal<{ x: number; y: number }>({\n x: 0,\n y: 0,\n });\n\n /**\n * @internal\n * Store the trigger width.\n */\n readonly width = signal<number | null>(null);\n\n /**\n * The dispose function to stop computing the position of the popover.\n */\n private dispose?: () => void;\n\n /**\n * A document-wide click listener that checks if the click\n * occurred outside of the popover and trigger elements.\n */\n private documentClickListener?: (event: MouseEvent) => void;\n\n /**\n * Store the popover instance.\n * @internal\n */\n private popoverInstance: NgpPopover | null = null;\n\n /**\n * Get the scroll strategy based on the configuration.\n */\n private readonly scrollStrategy = computed(() =>\n this.state.scrollBehavior() === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy(),\n );\n\n /**\n * @internal\n * Register any child popover to the stack.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly stack: NgpPopoverTrigger<any>[] = [];\n\n /**\n * @internal\n * The timeout to open the popover.\n */\n private openTimeout?: () => void;\n\n /**\n * @internal\n * The timeout to close the popover.\n */\n private closeTimeout?: () => void;\n\n /**\n * The popover trigger state.\n */\n readonly state = popoverTriggerState<NgpPopoverTrigger<T>>(this);\n\n constructor() {\n // if the trigger has a parent trigger then register it to the stack\n this.parentTrigger()?.stack.push(this);\n\n // update the width of the trigger when it resizes\n fromResizeEvent(this.trigger.nativeElement)\n .pipe(takeUntilDestroyed())\n .subscribe(() => this.width.set(this.trigger.nativeElement.offsetWidth));\n }\n\n ngOnDestroy(): void {\n // remove the trigger from the parent trigger's stack\n this.parentTrigger()?.stack.splice(this.parentTrigger()?.stack.indexOf(this), 1);\n\n this.destroyPopover();\n }\n\n protected toggleOpenState(event: MouseEvent): void {\n // if the trigger is disabled then do not toggle the popover\n if (this.state.disabled()) {\n return;\n }\n\n // determine the origin of the event, 0 is keyboard, 1 is mouse\n const origin: FocusOrigin = event.detail === 0 ? 'keyboard' : 'mouse';\n\n // if the popover is open then hide it\n if (this.open()) {\n this.hide(origin);\n } else {\n this.show(origin);\n }\n }\n\n /**\n * Show the popover.\n */\n show(origin: FocusOrigin): void {\n // if closing is in progress then clear the timeout to stop the popover from closing\n this.closeTimeout?.();\n\n // if the trigger is disabled or the popover is already open then do not show the popover\n if (this.state.disabled() || this.openTimeout) {\n return;\n }\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.createPopover(origin);\n }, this.state.showDelay());\n\n // Add document click listener to detect outside clicks\n if (this.state.closeOnOutsideClick()) {\n this.documentClickListener = this.onDocumentClick.bind(this);\n this.document.addEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Hide the popover.\n */\n hide(origin: FocusOrigin = 'program'): void {\n // if opening is in progress then clear the timeout to stop the popover from opening\n this.openTimeout?.();\n\n // if the trigger is disabled or the popover is not open then do not hide the popover\n if (this.state.disabled() || this.closeTimeout || !this.open()) {\n return;\n }\n\n // close all child popovers\n for (const child of this.stack) {\n child.hide(origin);\n }\n\n this.closeTimeout = this.disposables.setTimeout(async () => {\n this.closeTimeout = undefined;\n\n await this.destroyPopover();\n // ensure the trigger is focused after closing the popover\n this.disposables.setTimeout(() => this.focusTrigger(origin), 0);\n }, this.state.hideDelay());\n }\n\n private onDocumentClick(event: MouseEvent): void {\n const target = event.target as HTMLElement;\n\n const viewRef = this.viewRef();\n\n // get the popover element\n const popoverElement =\n viewRef instanceof ComponentRef ? viewRef.location.nativeElement : viewRef?.rootNodes[0];\n\n // Check if the click is outside the trigger or the popover\n const isOutside =\n !this.trigger.nativeElement.contains(target) && !popoverElement?.contains(target);\n\n // Determine if this is a click inside another popover\n\n if (isOutside) {\n // Close the popover\n this.hide('mouse');\n }\n }\n\n private createPopover(origin: FocusOrigin): void {\n // clear the open timeout\n this.openTimeout = undefined;\n\n const popover = this.state.popover();\n\n let portal: TemplatePortal | ComponentPortal<unknown>;\n\n // Create a new inject with the tooltip context\n const injector = Injector.create({\n parent: this.injector,\n providers: [providePopoverContext(this.state.context())],\n });\n\n if (popover instanceof TemplateRef) {\n portal = new TemplatePortal<NgpPopoverTemplateContext<T>>(\n popover,\n this.viewContainerRef,\n { $implicit: this.state.context() } as NgpPopoverTemplateContext<T>,\n injector,\n );\n } else if (popover instanceof Type) {\n portal = new ComponentPortal(popover, this.viewContainerRef, injector);\n } else {\n throw new Error('Popover must be either a TemplateRef or a ComponentType');\n }\n\n const domOutlet = new DomPortalOutlet(\n this.state.container() ?? this.document.body,\n undefined,\n undefined,\n injector,\n );\n\n const viewRef = domOutlet.attach(portal);\n this.viewRef.set(viewRef);\n\n let outletElement: HTMLElement | null = null;\n\n if (viewRef instanceof ComponentRef) {\n viewRef.changeDetectorRef.detectChanges();\n outletElement = viewRef.location.nativeElement;\n } else if (viewRef) {\n viewRef.detectChanges();\n outletElement = viewRef.rootNodes[0] as HTMLElement;\n }\n\n if (!outletElement) {\n throw new Error('Outlet element is not available.');\n }\n\n // determine if the popover is fixed or absolute\n const strategy = getComputedStyle(outletElement).position === 'fixed' ? 'fixed' : 'absolute';\n\n this.dispose = autoUpdate(this.trigger.nativeElement, outletElement, async () => {\n const position = await computePosition(this.trigger.nativeElement, outletElement, {\n placement: this.state.placement(),\n middleware: this.middleware(),\n strategy,\n });\n\n this.position.set({ x: position.x, y: position.y });\n viewRef?.detectChanges();\n });\n\n // activate the scroll strategy\n this.scrollStrategy().enable();\n\n // set the initial focus to the first tabbable element in the popover\n this.popoverInstance?.setInitialFocus(origin);\n }\n\n private async destroyPopover(): Promise<void> {\n // clear the close timeout\n this.closeTimeout = undefined;\n\n await this.exitAnimationState.exit();\n\n const viewRef = this.viewRef();\n\n // if the view is already destroyed then do not destroy it again\n const isDestroyed = viewRef instanceof ComponentRef ? false : viewRef?.destroyed;\n\n if (viewRef && !isDestroyed) {\n // destroy the view ref\n viewRef.destroy();\n }\n\n this.viewRef.set(null);\n this.dispose?.();\n\n // deactivate the scroll strategy\n this.scrollStrategy().disable();\n\n // Remove the document click listener when the popover is hidden\n if (this.documentClickListener) {\n this.document.removeEventListener('mouseup', this.documentClickListener, true);\n }\n }\n\n /**\n * @internal\n * Handle escape key press to close the popover.\n */\n protected handleEscapeKey(): void {\n if (this.state.closeOnEscape()) {\n this.hide('keyboard');\n }\n }\n\n private focusTrigger(origin: FocusOrigin): void {\n this.focusMonitor.focusVia(this.trigger.nativeElement, origin);\n }\n\n /**\n * Set the popover instance.\n * @internal\n */\n setPopover(instance: NgpPopover): void {\n this.popoverInstance = instance;\n }\n}\n\ntype NgpPopoverTemplateContext<T> = {\n $implicit: T;\n};\ntype NgpPopoverContent<T> = TemplateRef<NgpPopoverTemplateContext<T>> | Type<unknown>;\n","import type { Placement } from '@floating-ui/dom';\n\nexport function getTransformOrigin(placement: Placement): string {\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n}\n","import { FocusMonitor, FocusOrigin, InteractivityChecker } from '@angular/cdk/a11y';\nimport { computed, Directive, inject } from '@angular/core';\nimport { NgpFocusTrap } from 'ng-primitives/focus-trap';\nimport { injectElementRef, NgpExitAnimation } from 'ng-primitives/internal';\nimport { injectPopoverTriggerState } from '../popover-trigger/popover-trigger-state';\nimport { getTransformOrigin } from '../utils/transform-origin';\n\n/**\n * Apply the `ngpPopover` directive to an element that represents the popover. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpPopover]',\n exportAs: 'ngpPopover',\n hostDirectives: [NgpFocusTrap, NgpExitAnimation],\n host: {\n role: 'menu',\n '[style.left.px]': 'x()',\n '[style.top.px]': 'y()',\n '[style.--ngp-popover-trigger-width.px]': 'trigger().width()',\n '[style.--ngp-popover-transform-origin]': 'transformOrigin()',\n '(keydown.escape)': 'trigger().handleEscapeKey()',\n },\n})\nexport class NgpPopover {\n /**\n * Access the popover element.\n */\n private readonly popover = injectElementRef();\n\n /**\n * Access the interactivity checker.\n */\n private readonly interactivity = inject(InteractivityChecker);\n\n /**\n * Access the focus monitor.\n */\n private readonly focusMonitor = inject(FocusMonitor);\n\n /**\n * Access the trigger instance.\n */\n protected readonly trigger = injectPopoverTriggerState();\n\n /**\n * Compute the x position of the popover.\n */\n protected readonly x = computed(() => this.trigger().position().x);\n\n /**\n * Compute the y position of the popover.\n */\n protected readonly y = computed(() => this.trigger().position().y);\n\n /**\n * Derive the transform origin of the popover.\n */\n protected readonly transformOrigin = computed(() =>\n getTransformOrigin(this.trigger().placement()),\n );\n\n constructor() {\n this.trigger().setPopover(this);\n }\n\n /**\n * Focus the first tabbable element inside the popover.\n * If no tabbable element is found, focus the popover itself.\n * @internal\n */\n setInitialFocus(origin: FocusOrigin): void {\n // use a tree walker to find the first tabbable child\n const treeWalker = document.createTreeWalker(\n this.popover.nativeElement,\n NodeFilter.SHOW_ELEMENT,\n {\n acceptNode: node =>\n node instanceof HTMLElement && this.interactivity.isTabbable(node)\n ? NodeFilter.FILTER_ACCEPT\n : NodeFilter.FILTER_SKIP,\n },\n );\n\n const tabbableNode = treeWalker.nextNode() as HTMLElement | null;\n\n if (tabbableNode) {\n this.focusMonitor.focusVia(tabbableNode, origin);\n } else {\n // if no tabbable child is found, focus the popover element itself\n this.popover.nativeElement.focus();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA2DO,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,QAAQ;AACnB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,SAAS,EAAE,IAAI;AACf,IAAA,mBAAmB,EAAE,IAAI;AACzB,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,cAAc,EAAE,YAAY;CAC7B;AAEM,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAmB,uBAAuB,CAAC;AAElG;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;IACpE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACjD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,mBAAmB,GAAA;AACjC,IAAA,OAAO,MAAM,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC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A,EAAA,EAAA,CAAA,YAAA,EAAA,EAAA,EAAA,SAAA,EAAA,EAAA,CAAA,gBAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;2FAAV,UAAU,EAAA,UAAA,EAAA,CAAA;kBAbtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,cAAc,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;AAChD,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,MAAM;AACZ,wBAAA,iBAAiB,EAAE,KAAK;AACxB,wBAAA,gBAAgB,EAAE,KAAK;AACvB,wBAAA,wCAAwC,EAAE,mBAAmB;AAC7D,wBAAA,wCAAwC,EAAE,mBAAmB;AAC7D,wBAAA,kBAAkB,EAAE,6BAA6B;AAClD,qBAAA;AACF,iBAAA;;;ACtBD;;AAEG;;;;"}
|
|
@@ -81,6 +81,10 @@ class NgpRadioGroup {
|
|
|
81
81
|
* @param value The value of the radio item to select.
|
|
82
82
|
*/
|
|
83
83
|
select(value) {
|
|
84
|
+
// if the value is already selected, do nothing
|
|
85
|
+
if (this.state.compareWith()(this.state.value(), value)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
84
88
|
this.state.value.set(value);
|
|
85
89
|
this.valueChange.emit(value);
|
|
86
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-radio.mjs","sources":["../../../../packages/ng-primitives/radio/src/radio-group/radio-group-state.ts","../../../../packages/ng-primitives/radio/src/radio-group/radio-group.ts","../../../../packages/ng-primitives/radio/src/radio-item/radio-item-state.ts","../../../../packages/ng-primitives/radio/src/radio-indicator/radio-indicator.ts","../../../../packages/ng-primitives/radio/src/radio-item/radio-item.ts","../../../../packages/ng-primitives/radio/src/ng-primitives-radio.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n InjectedState,\n} from 'ng-primitives/state';\nimport type { NgpRadioGroup } from './radio-group';\n\n/**\n * The state token for the RadioGroup primitive.\n */\nexport const NgpRadioGroupStateToken = createStateToken<NgpRadioGroup<unknown>>('RadioGroup');\n\n/**\n * Provides the RadioGroup state.\n */\nexport const provideRadioGroupState = createStateProvider(NgpRadioGroupStateToken);\n\n/**\n * Injects the RadioGroup state.\n */\nexport const injectRadioGroupState = createStateInjector(NgpRadioGroupStateToken) as <\n T,\n>() => InjectedState<NgpRadioGroup<T>>;\n\n/**\n * The RadioGroup state registration function.\n */\nexport const radioGroupState = createState(NgpRadioGroupStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, OnInit, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { NgpFormControl, syncFormControl } from 'ng-primitives/form-field';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { provideRadioGroupState, radioGroupState } from './radio-group-state';\n\n/**\n * Apply the `ngpRadioGroup` directive to an element that represents the group of radio items.\n */\n@Directive({\n selector: '[ngpRadioGroup]',\n providers: [provideRadioGroupState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusGroup,\n inputs: [\n 'ngpRovingFocusGroupOrientation:ngpRadioGroupOrientation',\n 'ngpRovingFocusGroupDisabled:ngpRadioGroupDisabled',\n ],\n },\n NgpFormControl,\n ],\n host: {\n role: 'radiogroup',\n '[attr.aria-orientation]': 'state.orientation()',\n '[attr.data-orientation]': 'state.orientation()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpRadioGroup<T> implements OnInit {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\n\n /**\n * The value of the radio group.\n */\n readonly value = input<T | null>(null, { alias: 'ngpRadioGroupValue' });\n\n /**\n * Event emitted when the radio group value changes.\n */\n readonly valueChange = output<T | null>({\n alias: 'ngpRadioGroupValueChange',\n });\n\n /**\n * Whether the radio group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpRadioGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The orientation of the radio group.\n * @default 'horizontal'\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpRadioGroupOrientation',\n });\n\n /**\n * The comparator function for the radio group. This is useful if values are objects and you want to compare them by value, not by reference.\n * @default (a, b) => a === b\n */\n readonly compareWith = input<(a: T | null, b: T | null) => boolean>((a, b) => a === b, {\n alias: 'ngpRadioGroupCompareWith',\n });\n\n /**\n * The state of the radio group.\n * @internal\n */\n protected readonly state = radioGroupState<NgpRadioGroup<T>>(this);\n\n constructor() {\n syncFormControl({ disabled: this.state.disabled });\n }\n\n ngOnInit(): void {\n // the roving focus group defaults to vertical orientation whereas we want to default to vertical\n this.rovingFocusGroupState().orientation.set(this.state.orientation());\n }\n\n /**\n * Select a radio item.\n * @param value The value of the radio item to select.\n */\n select(value: T): void {\n this.state.value.set(value);\n this.valueChange.emit(value);\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n InjectedState,\n} from 'ng-primitives/state';\nimport type { NgpRadioItem } from './radio-item';\n\n/**\n * The state token for the RadioItem primitive.\n */\nexport const NgpRadioItemStateToken = createStateToken<NgpRadioItem<unknown>>('RadioItem');\n\n/**\n * Provides the RadioItem state.\n */\nexport const provideRadioItemState = createStateProvider(NgpRadioItemStateToken);\n\n/**\n * Injects the RadioItem state.\n */\nexport const injectRadioItemState = createStateInjector(NgpRadioItemStateToken) as <\n T,\n>() => InjectedState<NgpRadioItem<T>>;\n\n/**\n * The RadioItem state registration function.\n */\nexport const radioItemState = createState(NgpRadioItemStateToken);\n","import { Directive, computed } from '@angular/core';\nimport { NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { injectRadioGroupState } from '../radio-group/radio-group-state';\nimport { injectRadioItemState } from '../radio-item/radio-item-state';\n\n/**\n * Apply the `ngpRadioIndicator` directive to an element that represents the radio indicator (i.e. the dot).\n */\n@Directive({\n selector: '[ngpRadioIndicator]',\n host: {\n '[attr.data-checked]': 'checked() ? \"\" : null',\n '[attr.data-disabled]': 'radioItemState().disabled() ? \"\" : null',\n },\n hostDirectives: [NgpHover, NgpPress],\n})\nexport class NgpRadioIndicator<T> {\n /**\n * Access the radio group state.\n */\n protected readonly radioGroupState = injectRadioGroupState<T>();\n\n /**\n * Access the radio group item state\n */\n protected readonly radioItemState = injectRadioItemState<T>();\n\n /**\n * Determine if the radio indicator is checked.\n */\n protected readonly checked = computed(\n () => this.radioGroupState().value() === this.radioItemState().value(),\n );\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectRadioGroupState } from '../radio-group/radio-group-state';\nimport { provideRadioItemState, radioItemState } from './radio-item-state';\n\n/**\n * Apply the `ngpRadioItem` directive to an element that represents a radio item. This would typically be a `button` element.\n */\n@Directive({\n selector: '[ngpRadioItem]',\n hostDirectives: [NgpRovingFocusItem, NgpHover, NgpFocusVisible, NgpPress],\n providers: [provideRadioItemState()],\n host: {\n role: 'radio',\n '[attr.aria-checked]': 'checked() ? \"true\" : \"false\"',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '[attr.data-checked]': 'checked() ? \"\" : null',\n },\n})\nexport class NgpRadioItem<T> {\n /**\n * Access the radio group state.\n */\n private readonly radioGroupState = injectRadioGroupState<T>();\n\n /**\n * The value of the radio item.\n */\n readonly value = input.required<T>({ alias: 'ngpRadioItemValue' });\n\n /**\n * Whether the radio item is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpRadioItemDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the radio item is checked.\n */\n readonly checked = computed(() =>\n this.radioGroupState().compareWith()(this.radioGroupState().value(), this.value()),\n );\n\n /**\n * The state of the radio item.\n */\n protected readonly state = radioItemState<NgpRadioItem<T>>(this);\n\n /**\n * When the item receives focus, select it.\n * @internal\n */\n @HostListener('focus')\n protected onFocus(): void {\n this.radioGroupState().select(this.value());\n }\n\n /**\n * When the item receives a click, select it.\n * @internal\n */\n @HostListener('click')\n protected onClick(): void {\n this.radioGroupState().select(this.value());\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1","i2"],"mappings":";;;;;;;;;;AASA;;AAEG;AACI,MAAM,uBAAuB,GAAG,gBAAgB,CAAyB,YAAY,CAAC;AAE7F;;AAEG;MACU,sBAAsB,GAAG,mBAAmB,CAAC,uBAAuB;AAEjF;;AAEG;MACU,qBAAqB,GAAG,mBAAmB,CAAC,uBAAuB;AAIhF;;AAEG;AACI,MAAM,eAAe,GAAG,WAAW,CAAC,uBAAuB,CAAC;;ACtBnE;;AAEG;MAqBU,aAAa,CAAA;AAgDxB,IAAA,WAAA,GAAA;AA/CA;;AAEG;QACc,IAAqB,CAAA,qBAAA,GAAG,2BAA2B,EAAE;AAEtE;;AAEG;QACM,IAAK,CAAA,KAAA,GAAG,KAAK,CAAW,IAAI,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;AAEvE;;AAEG;QACM,IAAW,CAAA,WAAA,GAAG,MAAM,CAAW;AACtC,YAAA,KAAK,EAAE,0BAA0B;AAClC,SAAA,CAAC;AAEF;;AAEG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,EAAE,uBAAuB;AAC9B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;;AAGG;AACM,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAiB,YAAY,EAAE;AACzD,YAAA,KAAK,EAAE,0BAA0B;AAClC,SAAA,CAAC;A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,eAAe,EAAE,QAAQ,CAAC;AACzE,oBAAA,SAAS,EAAE,CAAC,qBAAqB,EAAE,CAAC;AACpC,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,OAAO;AACb,wBAAA,qBAAqB,EAAE,8BAA8B;AACrD,wBAAA,sBAAsB,EAAE,8BAA8B;AACtD,wBAAA,qBAAqB,EAAE,uBAAuB;AAC/C,qBAAA;AACF,iBAAA;8BAsCW,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO;gBAUX,OAAO,EAAA,CAAA;sBADhB,YAAY;uBAAC,OAAO;;;AClEvB;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-radio.mjs","sources":["../../../../packages/ng-primitives/radio/src/radio-group/radio-group-state.ts","../../../../packages/ng-primitives/radio/src/radio-group/radio-group.ts","../../../../packages/ng-primitives/radio/src/radio-item/radio-item-state.ts","../../../../packages/ng-primitives/radio/src/radio-indicator/radio-indicator.ts","../../../../packages/ng-primitives/radio/src/radio-item/radio-item.ts","../../../../packages/ng-primitives/radio/src/ng-primitives-radio.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n InjectedState,\n} from 'ng-primitives/state';\nimport type { NgpRadioGroup } from './radio-group';\n\n/**\n * The state token for the RadioGroup primitive.\n */\nexport const NgpRadioGroupStateToken = createStateToken<NgpRadioGroup<unknown>>('RadioGroup');\n\n/**\n * Provides the RadioGroup state.\n */\nexport const provideRadioGroupState = createStateProvider(NgpRadioGroupStateToken);\n\n/**\n * Injects the RadioGroup state.\n */\nexport const injectRadioGroupState = createStateInjector(NgpRadioGroupStateToken) as <\n T,\n>() => InjectedState<NgpRadioGroup<T>>;\n\n/**\n * The RadioGroup state registration function.\n */\nexport const radioGroupState = createState(NgpRadioGroupStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, OnInit, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { NgpFormControl, syncFormControl } from 'ng-primitives/form-field';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { provideRadioGroupState, radioGroupState } from './radio-group-state';\n\n/**\n * Apply the `ngpRadioGroup` directive to an element that represents the group of radio items.\n */\n@Directive({\n selector: '[ngpRadioGroup]',\n providers: [provideRadioGroupState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusGroup,\n inputs: [\n 'ngpRovingFocusGroupOrientation:ngpRadioGroupOrientation',\n 'ngpRovingFocusGroupDisabled:ngpRadioGroupDisabled',\n ],\n },\n NgpFormControl,\n ],\n host: {\n role: 'radiogroup',\n '[attr.aria-orientation]': 'state.orientation()',\n '[attr.data-orientation]': 'state.orientation()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpRadioGroup<T> implements OnInit {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\n\n /**\n * The value of the radio group.\n */\n readonly value = input<T | null>(null, { alias: 'ngpRadioGroupValue' });\n\n /**\n * Event emitted when the radio group value changes.\n */\n readonly valueChange = output<T | null>({\n alias: 'ngpRadioGroupValueChange',\n });\n\n /**\n * Whether the radio group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpRadioGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The orientation of the radio group.\n * @default 'horizontal'\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpRadioGroupOrientation',\n });\n\n /**\n * The comparator function for the radio group. This is useful if values are objects and you want to compare them by value, not by reference.\n * @default (a, b) => a === b\n */\n readonly compareWith = input<(a: T | null, b: T | null) => boolean>((a, b) => a === b, {\n alias: 'ngpRadioGroupCompareWith',\n });\n\n /**\n * The state of the radio group.\n * @internal\n */\n protected readonly state = radioGroupState<NgpRadioGroup<T>>(this);\n\n constructor() {\n syncFormControl({ disabled: this.state.disabled });\n }\n\n ngOnInit(): void {\n // the roving focus group defaults to vertical orientation whereas we want to default to vertical\n this.rovingFocusGroupState().orientation.set(this.state.orientation());\n }\n\n /**\n * Select a radio item.\n * @param value The value of the radio item to select.\n */\n select(value: T): void {\n // if the value is already selected, do nothing\n if (this.state.compareWith()(this.state.value(), value)) {\n return;\n }\n\n this.state.value.set(value);\n this.valueChange.emit(value);\n }\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n InjectedState,\n} from 'ng-primitives/state';\nimport type { NgpRadioItem } from './radio-item';\n\n/**\n * The state token for the RadioItem primitive.\n */\nexport const NgpRadioItemStateToken = createStateToken<NgpRadioItem<unknown>>('RadioItem');\n\n/**\n * Provides the RadioItem state.\n */\nexport const provideRadioItemState = createStateProvider(NgpRadioItemStateToken);\n\n/**\n * Injects the RadioItem state.\n */\nexport const injectRadioItemState = createStateInjector(NgpRadioItemStateToken) as <\n T,\n>() => InjectedState<NgpRadioItem<T>>;\n\n/**\n * The RadioItem state registration function.\n */\nexport const radioItemState = createState(NgpRadioItemStateToken);\n","import { Directive, computed } from '@angular/core';\nimport { NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { injectRadioGroupState } from '../radio-group/radio-group-state';\nimport { injectRadioItemState } from '../radio-item/radio-item-state';\n\n/**\n * Apply the `ngpRadioIndicator` directive to an element that represents the radio indicator (i.e. the dot).\n */\n@Directive({\n selector: '[ngpRadioIndicator]',\n host: {\n '[attr.data-checked]': 'checked() ? \"\" : null',\n '[attr.data-disabled]': 'radioItemState().disabled() ? \"\" : null',\n },\n hostDirectives: [NgpHover, NgpPress],\n})\nexport class NgpRadioIndicator<T> {\n /**\n * Access the radio group state.\n */\n protected readonly radioGroupState = injectRadioGroupState<T>();\n\n /**\n * Access the radio group item state\n */\n protected readonly radioItemState = injectRadioItemState<T>();\n\n /**\n * Determine if the radio indicator is checked.\n */\n protected readonly checked = computed(\n () => this.radioGroupState().value() === this.radioItemState().value(),\n );\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { Directive, HostListener, booleanAttribute, computed, input } from '@angular/core';\nimport { NgpFocusVisible, NgpHover, NgpPress } from 'ng-primitives/interactions';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectRadioGroupState } from '../radio-group/radio-group-state';\nimport { provideRadioItemState, radioItemState } from './radio-item-state';\n\n/**\n * Apply the `ngpRadioItem` directive to an element that represents a radio item. This would typically be a `button` element.\n */\n@Directive({\n selector: '[ngpRadioItem]',\n hostDirectives: [NgpRovingFocusItem, NgpHover, NgpFocusVisible, NgpPress],\n providers: [provideRadioItemState()],\n host: {\n role: 'radio',\n '[attr.aria-checked]': 'checked() ? \"true\" : \"false\"',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '[attr.data-checked]': 'checked() ? \"\" : null',\n },\n})\nexport class NgpRadioItem<T> {\n /**\n * Access the radio group state.\n */\n private readonly radioGroupState = injectRadioGroupState<T>();\n\n /**\n * The value of the radio item.\n */\n readonly value = input.required<T>({ alias: 'ngpRadioItemValue' });\n\n /**\n * Whether the radio item is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpRadioItemDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the radio item is checked.\n */\n readonly checked = computed(() =>\n this.radioGroupState().compareWith()(this.radioGroupState().value(), this.value()),\n );\n\n /**\n * The state of the radio item.\n */\n protected readonly state = radioItemState<NgpRadioItem<T>>(this);\n\n /**\n * When the item receives focus, select it.\n * @internal\n */\n @HostListener('focus')\n protected onFocus(): void {\n this.radioGroupState().select(this.value());\n }\n\n /**\n * When the item receives a click, select it.\n * @internal\n */\n @HostListener('click')\n protected onClick(): void {\n this.radioGroupState().select(this.value());\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["i1","i2"],"mappings":";;;;;;;;;;AASA;;AAEG;AACI,MAAM,uBAAuB,GAAG,gBAAgB,CAAyB,YAAY,CAAC;AAE7F;;AAEG;MACU,sBA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