@radix-ng/primitives 0.26.0 → 0.28.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/collapsible/src/collapsible-content.directive.d.ts +1 -1
- package/collapsible/src/collapsible-root.directive.d.ts +11 -11
- package/compodoc/documentation.json +13169 -6206
- package/dialog/src/dialog-close.directive.d.ts +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +20 -27
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +2 -3
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-hover-card.mjs +1213 -0
- package/fesm2022/radix-ng-primitives-hover-card.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-popover.mjs +1 -3
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +250 -0
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +72 -336
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +15 -2
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +23 -5
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/hover-card/README.md +3 -0
- package/hover-card/index.d.ts +20 -0
- package/hover-card/src/hover-card-anchor.directive.d.ts +28 -0
- package/hover-card/src/hover-card-anchor.token.d.ts +3 -0
- package/hover-card/src/hover-card-arrow.directive.d.ts +40 -0
- package/hover-card/src/hover-card-arrow.token.d.ts +3 -0
- package/hover-card/src/hover-card-close.directive.d.ts +18 -0
- package/hover-card/src/hover-card-close.token.d.ts +3 -0
- package/hover-card/src/hover-card-content-attributes.component.d.ts +25 -0
- package/hover-card/src/hover-card-content-attributes.token.d.ts +3 -0
- package/hover-card/src/hover-card-content.directive.d.ts +104 -0
- package/hover-card/src/hover-card-root.directive.d.ts +168 -0
- package/hover-card/src/hover-card-root.inject.d.ts +3 -0
- package/hover-card/src/hover-card-trigger.directive.d.ts +26 -0
- package/hover-card/src/hover-card.types.d.ts +18 -0
- package/hover-card/src/utils/cdk-event.service.d.ts +30 -0
- package/hover-card/src/utils/constants.d.ts +1 -0
- package/hover-card/src/utils/types.d.ts +7 -0
- package/package.json +9 -1
- package/popover/src/popover-root.directive.d.ts +4 -4
- package/popover/src/popover-trigger.directive.d.ts +1 -1
- package/presence/index.d.ts +4 -0
- package/presence/src/presence.d.ts +42 -0
- package/presence/src/transitions/transition.collapse.d.ts +15 -0
- package/presence/src/transitions/transition.toast.d.ts +3 -0
- package/presence/src/types.d.ts +15 -0
- package/presence/src/utils.d.ts +42 -0
- package/toggle/src/toggle.directive.d.ts +14 -1
- package/toggle-group/index.d.ts +0 -1
- package/toggle-group/src/toggle-group-item.directive.d.ts +13 -27
- package/toggle-group/src/toggle-group-item.token.d.ts +1 -0
- package/toggle-group/src/toggle-group.directive.d.ts +17 -45
- package/toggle-group/src/toggle-group.token.d.ts +2 -3
- package/tooltip/src/tooltip-content-attributes.component.d.ts +8 -0
- package/tooltip/src/tooltip-root.directive.d.ts +4 -4
- package/toggle-group/src/toggle-group-multiple.directive.d.ts +0 -99
@@ -0,0 +1,250 @@
|
|
1
|
+
import { Observable, EMPTY, of, Subject, endWith, fromEvent, filter, takeUntil, timer, race } from 'rxjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Ensures that the observable stream runs inside Angular's NgZone.
|
5
|
+
*
|
6
|
+
* This function is a higher-order function that takes an observable stream as input and ensures
|
7
|
+
* that all emissions, errors, and completion notifications are run inside Angular's NgZone. This
|
8
|
+
* is particularly useful for ensuring that change detection is triggered properly in Angular
|
9
|
+
* applications.
|
10
|
+
*
|
11
|
+
* @template T - The type of the items emitted by the observable.
|
12
|
+
* @param {NgZone} zone - The Angular zone to control the change detection context.
|
13
|
+
* @returns {(source: Observable<T>) => Observable<T>} - A function that takes an observable as input
|
14
|
+
* and returns an observable that runs inside Angular's NgZone.
|
15
|
+
*
|
16
|
+
* Example usage:
|
17
|
+
*
|
18
|
+
* const source$ = of('some value');
|
19
|
+
* const zoned$ = source$.pipe(runInZone(zone));
|
20
|
+
* zoned$.subscribe(value => {
|
21
|
+
* console.log('Value:', value);
|
22
|
+
* });
|
23
|
+
*/
|
24
|
+
function runInZone(zone) {
|
25
|
+
return (source) => new Observable((observer) => source.subscribe({
|
26
|
+
next: (value) => zone.run(() => observer.next(value)),
|
27
|
+
error: (err) => zone.run(() => observer.error(err)),
|
28
|
+
complete: () => zone.run(() => observer.complete())
|
29
|
+
}));
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Calculates the total transition duration in milliseconds for a given HTML element.
|
33
|
+
*
|
34
|
+
* This function retrieves the computed style of the specified element and extracts the
|
35
|
+
* transition duration and delay properties. It then converts these values from seconds
|
36
|
+
* to milliseconds and returns their sum, representing the total transition duration.
|
37
|
+
*
|
38
|
+
* @param {HTMLElement} element - The HTML element for which to calculate the transition duration.
|
39
|
+
* @returns {number} - The total transition duration in milliseconds.
|
40
|
+
*
|
41
|
+
* Example usage:
|
42
|
+
*
|
43
|
+
* const durationMs = getTransitionDurationMs(element);
|
44
|
+
* console.log(`Transition duration: ${durationMs} ms`);
|
45
|
+
*/
|
46
|
+
function getTransitionDurationMs(element) {
|
47
|
+
const { transitionDelay, transitionDuration } = window.getComputedStyle(element);
|
48
|
+
const transitionDelaySec = parseFloat(transitionDelay);
|
49
|
+
const transitionDurationSec = parseFloat(transitionDuration);
|
50
|
+
return (transitionDelaySec + transitionDurationSec) * 1000;
|
51
|
+
}
|
52
|
+
function triggerReflow(element) {
|
53
|
+
return (element || document.body).getBoundingClientRect();
|
54
|
+
}
|
55
|
+
|
56
|
+
const noopFn = () => {
|
57
|
+
/* Noop */
|
58
|
+
};
|
59
|
+
const TransitionsMap = new Map();
|
60
|
+
/**
|
61
|
+
* Manages the presence of an element with optional transition animation.
|
62
|
+
*
|
63
|
+
* @template T - The type of the context object used in the transition.
|
64
|
+
* @param {NgZone} zone - The Angular zone to control the change detection context.
|
65
|
+
* @param {HTMLElement} element - The target HTML element to apply the transition.
|
66
|
+
* @param {TransitionOptions<T>} options - Options for controlling the transition behavior.
|
67
|
+
* @param {T} [options.context] - An optional context object to pass through the transition.
|
68
|
+
* @param {boolean} options.animation - A flag indicating if the transition should be animated.
|
69
|
+
* @param {'start' | 'continue' | 'stop'} options.state - The desired state of the transition.
|
70
|
+
* @param {TransitionStartFn<T>} startFn - A function to start the transition.
|
71
|
+
* @returns {Observable<void>} - An observable that emits when the transition completes.
|
72
|
+
*
|
73
|
+
* The `usePresence` function is designed to manage the presence and visibility of an HTML element,
|
74
|
+
* optionally applying a transition animation. It utilizes Angular's NgZone for efficient change
|
75
|
+
* detection management and allows for different states of transitions ('start', 'continue', 'stop').
|
76
|
+
* The function takes a start function to handle the beginning of the transition and returns an
|
77
|
+
* observable that completes when the transition ends.
|
78
|
+
*
|
79
|
+
* Example usage:
|
80
|
+
*
|
81
|
+
* const options: TransitionOptions<MyContext> = {
|
82
|
+
* context: {}, // your context object
|
83
|
+
* animation: true,
|
84
|
+
* state: 'start'
|
85
|
+
* };
|
86
|
+
*
|
87
|
+
* const startFn: TransitionStartFn<MyContext> = (el, animation, context) => {
|
88
|
+
* el.classList.add('active');
|
89
|
+
* return () => el.classList.remove('active');
|
90
|
+
* };
|
91
|
+
*
|
92
|
+
* usePresence(zone, element, startFn, options).subscribe(() => {
|
93
|
+
* console.log('Transition completed');
|
94
|
+
* });
|
95
|
+
*/
|
96
|
+
const usePresence = (zone, element, startFn, options) => {
|
97
|
+
let context = options.context || {};
|
98
|
+
const transitionTimerDelayMs = options.transitionTimerDelayMs ?? 5;
|
99
|
+
const state = options.state ?? 'stop';
|
100
|
+
const running = TransitionsMap.get(element);
|
101
|
+
if (running) {
|
102
|
+
switch (state) {
|
103
|
+
case 'continue':
|
104
|
+
return EMPTY;
|
105
|
+
case 'stop':
|
106
|
+
zone.run(() => running.transition$.complete());
|
107
|
+
context = { ...running.context, ...context };
|
108
|
+
TransitionsMap.delete(element);
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
const endFn = startFn(element, options.animation, context) || noopFn;
|
113
|
+
if (!options.animation || window.getComputedStyle(element).transitionProperty === 'none') {
|
114
|
+
zone.run(() => endFn());
|
115
|
+
return of(undefined).pipe(runInZone(zone));
|
116
|
+
}
|
117
|
+
const transition$ = new Subject();
|
118
|
+
const finishTransition$ = new Subject();
|
119
|
+
const stop$ = transition$.pipe(endWith(true));
|
120
|
+
TransitionsMap.set(element, {
|
121
|
+
transition$,
|
122
|
+
complete: () => {
|
123
|
+
finishTransition$.next();
|
124
|
+
finishTransition$.complete();
|
125
|
+
},
|
126
|
+
context
|
127
|
+
});
|
128
|
+
const transitionDurationMs = getTransitionDurationMs(element);
|
129
|
+
zone.runOutsideAngular(() => {
|
130
|
+
const transitionEnd$ = fromEvent(element, 'transitionend').pipe(filter(({ target }) => target === element), takeUntil(stop$));
|
131
|
+
const timer$ = timer(transitionDurationMs + transitionTimerDelayMs).pipe(takeUntil(stop$));
|
132
|
+
race(timer$, transitionEnd$, finishTransition$)
|
133
|
+
.pipe(takeUntil(stop$))
|
134
|
+
.subscribe(() => {
|
135
|
+
TransitionsMap.delete(element);
|
136
|
+
zone.run(() => {
|
137
|
+
endFn();
|
138
|
+
transition$.next();
|
139
|
+
transition$.complete();
|
140
|
+
});
|
141
|
+
});
|
142
|
+
});
|
143
|
+
return transition$.asObservable();
|
144
|
+
};
|
145
|
+
const completeTransition = (element) => {
|
146
|
+
TransitionsMap.get(element)?.complete();
|
147
|
+
};
|
148
|
+
|
149
|
+
// Define constants for class names
|
150
|
+
const COLLAPSE_CLASS = 'collapse';
|
151
|
+
const COLLAPSING_CLASS = 'collapsing';
|
152
|
+
const SHOW_CLASS = 'show';
|
153
|
+
/**
|
154
|
+
* Function to handle the start of a collapsing transition.
|
155
|
+
*
|
156
|
+
* @param element - The HTML element to animate.
|
157
|
+
* @param animation - Whether to use animation or not.
|
158
|
+
* @param context - The context containing direction and dimension information.
|
159
|
+
* @returns A function to clean up the animation.
|
160
|
+
*/
|
161
|
+
const transitionCollapsing = (element, animation, context) => {
|
162
|
+
const { direction, dimension } = context;
|
163
|
+
let { maxSize } = context;
|
164
|
+
const { classList } = element;
|
165
|
+
/**
|
166
|
+
* Sets initial classes based on the direction.
|
167
|
+
*/
|
168
|
+
function setInitialClasses() {
|
169
|
+
classList.add(COLLAPSE_CLASS);
|
170
|
+
if (direction === 'show') {
|
171
|
+
classList.add(SHOW_CLASS);
|
172
|
+
}
|
173
|
+
else {
|
174
|
+
classList.remove(SHOW_CLASS);
|
175
|
+
}
|
176
|
+
}
|
177
|
+
if (!animation) {
|
178
|
+
setInitialClasses();
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
if (!maxSize) {
|
182
|
+
maxSize = measureCollapsingElementDimensionPx(element, dimension);
|
183
|
+
context.maxSize = maxSize;
|
184
|
+
// Fix the height before starting the animation
|
185
|
+
element.style[dimension] = direction !== 'show' ? maxSize : '0px';
|
186
|
+
classList.remove(COLLAPSE_CLASS, COLLAPSING_CLASS, 'show');
|
187
|
+
triggerReflow(element);
|
188
|
+
// Start the animation
|
189
|
+
classList.add(COLLAPSING_CLASS);
|
190
|
+
}
|
191
|
+
element.style[dimension] = direction === 'show' ? maxSize : '0px';
|
192
|
+
return () => {
|
193
|
+
setInitialClasses();
|
194
|
+
classList.remove(COLLAPSING_CLASS);
|
195
|
+
element.style[dimension] = '';
|
196
|
+
};
|
197
|
+
};
|
198
|
+
/**
|
199
|
+
* Measures the dimension of the collapsing element in pixels.
|
200
|
+
*
|
201
|
+
* @param element - The HTML element to measure.
|
202
|
+
* @param dimension - The dimension ('width' or 'height') to measure.
|
203
|
+
* @returns The size of the dimension in pixels.
|
204
|
+
*/
|
205
|
+
function measureCollapsingElementDimensionPx(element, dimension) {
|
206
|
+
// SSR fix
|
207
|
+
if (typeof navigator === 'undefined') {
|
208
|
+
return '0px';
|
209
|
+
}
|
210
|
+
const { classList } = element;
|
211
|
+
const hasShownClass = classList.contains(SHOW_CLASS);
|
212
|
+
if (!hasShownClass) {
|
213
|
+
classList.add(SHOW_CLASS);
|
214
|
+
}
|
215
|
+
element.style[dimension] = '';
|
216
|
+
const dimensionSize = element.getBoundingClientRect()[dimension] + 'px';
|
217
|
+
if (!hasShownClass) {
|
218
|
+
classList.remove(SHOW_CLASS);
|
219
|
+
}
|
220
|
+
return dimensionSize;
|
221
|
+
}
|
222
|
+
|
223
|
+
const toastFadeInTransition = (element, animation) => {
|
224
|
+
const { classList } = element;
|
225
|
+
if (animation) {
|
226
|
+
classList.add('fade');
|
227
|
+
}
|
228
|
+
else {
|
229
|
+
classList.add('show');
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
triggerReflow(element);
|
233
|
+
classList.add('show', 'showing');
|
234
|
+
return () => {
|
235
|
+
classList.remove('showing');
|
236
|
+
};
|
237
|
+
};
|
238
|
+
const toastFadeOutTransition = ({ classList }) => {
|
239
|
+
classList.add('showing');
|
240
|
+
return () => {
|
241
|
+
classList.remove('show', 'showing');
|
242
|
+
};
|
243
|
+
};
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Generated bundle index. Do not edit.
|
247
|
+
*/
|
248
|
+
|
249
|
+
export { completeTransition, toastFadeInTransition, toastFadeOutTransition, transitionCollapsing, usePresence };
|
250
|
+
//# sourceMappingURL=radix-ng-primitives-presence.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"radix-ng-primitives-presence.mjs","sources":["../../../packages/primitives/presence/src/utils.ts","../../../packages/primitives/presence/src/presence.ts","../../../packages/primitives/presence/src/transitions/transition.collapse.ts","../../../packages/primitives/presence/src/transitions/transition.toast.ts","../../../packages/primitives/presence/radix-ng-primitives-presence.ts"],"sourcesContent":["import { NgZone } from '@angular/core';\nimport { Observable } from 'rxjs';\n\n/**\n * Ensures that the observable stream runs inside Angular's NgZone.\n *\n * This function is a higher-order function that takes an observable stream as input and ensures\n * that all emissions, errors, and completion notifications are run inside Angular's NgZone. This\n * is particularly useful for ensuring that change detection is triggered properly in Angular\n * applications.\n *\n * @template T - The type of the items emitted by the observable.\n * @param {NgZone} zone - The Angular zone to control the change detection context.\n * @returns {(source: Observable<T>) => Observable<T>} - A function that takes an observable as input\n * and returns an observable that runs inside Angular's NgZone.\n *\n * Example usage:\n *\n * const source$ = of('some value');\n * const zoned$ = source$.pipe(runInZone(zone));\n * zoned$.subscribe(value => {\n * console.log('Value:', value);\n * });\n */\nfunction runInZone<T>(zone: NgZone): (source: Observable<T>) => Observable<T> {\n return (source: Observable<T>) =>\n new Observable((observer) =>\n source.subscribe({\n next: (value) => zone.run(() => observer.next(value)),\n error: (err) => zone.run(() => observer.error(err)),\n complete: () => zone.run(() => observer.complete())\n })\n );\n}\n\n/**\n * Calculates the total transition duration in milliseconds for a given HTML element.\n *\n * This function retrieves the computed style of the specified element and extracts the\n * transition duration and delay properties. It then converts these values from seconds\n * to milliseconds and returns their sum, representing the total transition duration.\n *\n * @param {HTMLElement} element - The HTML element for which to calculate the transition duration.\n * @returns {number} - The total transition duration in milliseconds.\n *\n * Example usage:\n *\n * const durationMs = getTransitionDurationMs(element);\n * console.log(`Transition duration: ${durationMs} ms`);\n */\nfunction getTransitionDurationMs(element: HTMLElement): number {\n const { transitionDelay, transitionDuration } = window.getComputedStyle(element);\n const transitionDelaySec = parseFloat(transitionDelay);\n const transitionDurationSec = parseFloat(transitionDuration);\n\n return (transitionDelaySec + transitionDurationSec) * 1000;\n}\n\nexport { getTransitionDurationMs, runInZone };\n\nexport function triggerReflow(element: HTMLElement) {\n return (element || document.body).getBoundingClientRect();\n}\n","import { NgZone } from '@angular/core';\nimport { EMPTY, endWith, filter, fromEvent, Observable, of, race, Subject, takeUntil, timer } from 'rxjs';\nimport { TransitionContext, TransitionEndFn, TransitionOptions, TransitionStartFn } from './types';\nimport { getTransitionDurationMs, runInZone } from './utils';\n\nconst noopFn: TransitionEndFn = () => {\n /* Noop */\n};\nconst TransitionsMap = new Map<HTMLElement, TransitionContext<any>>();\n\n/**\n * Manages the presence of an element with optional transition animation.\n *\n * @template T - The type of the context object used in the transition.\n * @param {NgZone} zone - The Angular zone to control the change detection context.\n * @param {HTMLElement} element - The target HTML element to apply the transition.\n * @param {TransitionOptions<T>} options - Options for controlling the transition behavior.\n * @param {T} [options.context] - An optional context object to pass through the transition.\n * @param {boolean} options.animation - A flag indicating if the transition should be animated.\n * @param {'start' | 'continue' | 'stop'} options.state - The desired state of the transition.\n * @param {TransitionStartFn<T>} startFn - A function to start the transition.\n * @returns {Observable<void>} - An observable that emits when the transition completes.\n *\n * The `usePresence` function is designed to manage the presence and visibility of an HTML element,\n * optionally applying a transition animation. It utilizes Angular's NgZone for efficient change\n * detection management and allows for different states of transitions ('start', 'continue', 'stop').\n * The function takes a start function to handle the beginning of the transition and returns an\n * observable that completes when the transition ends.\n *\n * Example usage:\n *\n * const options: TransitionOptions<MyContext> = {\n * context: {}, // your context object\n * animation: true,\n * state: 'start'\n * };\n *\n * const startFn: TransitionStartFn<MyContext> = (el, animation, context) => {\n * el.classList.add('active');\n * return () => el.classList.remove('active');\n * };\n *\n * usePresence(zone, element, startFn, options).subscribe(() => {\n * console.log('Transition completed');\n * });\n */\nconst usePresence = <T>(\n zone: NgZone,\n element: HTMLElement,\n startFn: TransitionStartFn<T>,\n options: TransitionOptions<T>\n): Observable<void> => {\n let context = options.context || <T>{};\n\n const transitionTimerDelayMs = options.transitionTimerDelayMs ?? 5;\n const state = options.state ?? 'stop';\n\n const running = TransitionsMap.get(element);\n\n if (running) {\n switch (state) {\n case 'continue':\n return EMPTY;\n case 'stop':\n zone.run(() => running.transition$.complete());\n context = { ...running.context, ...context };\n TransitionsMap.delete(element);\n break;\n }\n }\n const endFn = startFn(element, options.animation, context) || noopFn;\n\n if (!options.animation || window.getComputedStyle(element).transitionProperty === 'none') {\n zone.run(() => endFn());\n return of(undefined).pipe(runInZone(zone));\n }\n\n const transition$ = new Subject<void>();\n const finishTransition$ = new Subject<void>();\n const stop$ = transition$.pipe(endWith(true));\n\n TransitionsMap.set(element, {\n transition$,\n complete: () => {\n finishTransition$.next();\n finishTransition$.complete();\n },\n context\n });\n\n const transitionDurationMs = getTransitionDurationMs(element);\n\n zone.runOutsideAngular(() => {\n const transitionEnd$ = fromEvent<TransitionEvent>(element, 'transitionend').pipe(\n filter(({ target }) => target === element),\n takeUntil(stop$)\n );\n const timer$ = timer(transitionDurationMs + transitionTimerDelayMs).pipe(takeUntil(stop$));\n\n race(timer$, transitionEnd$, finishTransition$)\n .pipe(takeUntil(stop$))\n .subscribe(() => {\n TransitionsMap.delete(element);\n zone.run(() => {\n endFn();\n transition$.next();\n transition$.complete();\n });\n });\n });\n\n return transition$.asObservable();\n};\n\nconst completeTransition = (element: HTMLElement) => {\n TransitionsMap.get(element)?.complete();\n};\n\nexport { completeTransition, usePresence };\n","import { TransitionStartFn } from '../types';\nimport { triggerReflow } from '../utils';\n\nexport type CollapseContext = {\n direction: 'show' | 'hide';\n dimension: 'width' | 'height';\n maxSize?: string;\n};\n\n// Define constants for class names\nconst COLLAPSE_CLASS = 'collapse';\nconst COLLAPSING_CLASS = 'collapsing';\nconst SHOW_CLASS = 'show';\n/**\n * Function to handle the start of a collapsing transition.\n *\n * @param element - The HTML element to animate.\n * @param animation - Whether to use animation or not.\n * @param context - The context containing direction and dimension information.\n * @returns A function to clean up the animation.\n */\nexport const transitionCollapsing: TransitionStartFn<CollapseContext> = (\n element: HTMLElement,\n animation: boolean,\n context: CollapseContext\n) => {\n const { direction, dimension } = context;\n let { maxSize } = context;\n const { classList } = element;\n\n /**\n * Sets initial classes based on the direction.\n */\n function setInitialClasses() {\n classList.add(COLLAPSE_CLASS);\n if (direction === 'show') {\n classList.add(SHOW_CLASS);\n } else {\n classList.remove(SHOW_CLASS);\n }\n }\n\n if (!animation) {\n setInitialClasses();\n return;\n }\n\n if (!maxSize) {\n maxSize = measureCollapsingElementDimensionPx(element, dimension);\n context.maxSize = maxSize;\n\n // Fix the height before starting the animation\n element.style[dimension] = direction !== 'show' ? maxSize : '0px';\n\n classList.remove(COLLAPSE_CLASS, COLLAPSING_CLASS, 'show');\n\n triggerReflow(element);\n\n // Start the animation\n classList.add(COLLAPSING_CLASS);\n }\n\n element.style[dimension] = direction === 'show' ? maxSize : '0px';\n\n return () => {\n setInitialClasses();\n classList.remove(COLLAPSING_CLASS);\n element.style[dimension] = '';\n };\n};\n\n/**\n * Measures the dimension of the collapsing element in pixels.\n *\n * @param element - The HTML element to measure.\n * @param dimension - The dimension ('width' or 'height') to measure.\n * @returns The size of the dimension in pixels.\n */\nfunction measureCollapsingElementDimensionPx(element: HTMLElement, dimension: 'width' | 'height'): string {\n // SSR fix\n if (typeof navigator === 'undefined') {\n return '0px';\n }\n\n const { classList } = element;\n const hasShownClass = classList.contains(SHOW_CLASS);\n if (!hasShownClass) {\n classList.add(SHOW_CLASS);\n }\n\n element.style[dimension] = '';\n const dimensionSize = element.getBoundingClientRect()[dimension] + 'px';\n\n if (!hasShownClass) {\n classList.remove(SHOW_CLASS);\n }\n\n return dimensionSize;\n}\n","import { TransitionStartFn } from '../types';\nimport { triggerReflow } from '../utils';\n\nexport const toastFadeInTransition: TransitionStartFn = (element: HTMLElement, animation: boolean) => {\n const { classList } = element;\n\n if (animation) {\n classList.add('fade');\n } else {\n classList.add('show');\n return;\n }\n\n triggerReflow(element);\n classList.add('show', 'showing');\n\n return () => {\n classList.remove('showing');\n };\n};\n\nexport const toastFadeOutTransition: TransitionStartFn = ({ classList }: HTMLElement) => {\n classList.add('showing');\n return () => {\n classList.remove('show', 'showing');\n };\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mapp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