@mmstack/primitives 21.4.0 → 21.4.1
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/package.json
CHANGED
|
@@ -403,6 +403,67 @@ type TransactionRef = {
|
|
|
403
403
|
*/
|
|
404
404
|
declare function injectStartTransaction(): (fn: () => void) => TransactionRef;
|
|
405
405
|
|
|
406
|
+
type MmTransitionContext<T> = {
|
|
407
|
+
readonly $implicit: T;
|
|
408
|
+
readonly mmTransition: T;
|
|
409
|
+
};
|
|
410
|
+
/**
|
|
411
|
+
* Generic hold-and-swap: the non-router `TransitionRouterOutlet`. When the bound value changes,
|
|
412
|
+
* the OLD view stays mounted and visible (it keeps its old context value — that's the hold) while
|
|
413
|
+
* the NEW view mounts hidden with its **own transition scope**; resources created in the incoming
|
|
414
|
+
* subtree register into that scope just by existing, and once they've gone in flight and settled
|
|
415
|
+
* the views swap in one frame. Tabs, wizard steps, master-detail — any branch change that would
|
|
416
|
+
* otherwise flash a loading state.
|
|
417
|
+
*
|
|
418
|
+
* ```html
|
|
419
|
+
* <div *mmTransition="selectedTab(); let tab">
|
|
420
|
+
* @switch (tab) { ... }
|
|
421
|
+
* </div>
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* Distinct from `<mm-suspense>` (the readiness gate): suspense decides placeholder-vs-content
|
|
425
|
+
* *within* one branch, but can't stop an `@switch` from unmounting the old branch the instant the
|
|
426
|
+
* value flips. This directive is the swap itself — the old branch survives until the new one is
|
|
427
|
+
* ready. Compose them freely: suspense inside a transitioned branch handles its first load.
|
|
428
|
+
*
|
|
429
|
+
* Semantics mirror the outlet: the first render is immediate (nothing to hold); an interrupting
|
|
430
|
+
* value change mid-hold destroys the half-ready hidden view and re-targets; a branch that loads
|
|
431
|
+
* nothing swaps right after its first render. Per-view scopes mean the outgoing branch's
|
|
432
|
+
* background work can never delay the swap. Set `mmTransitionImmediate` to skip holding, and
|
|
433
|
+
* `mmTransitionViewTransition` to wrap the swap in `document.startViewTransition` (feature
|
|
434
|
+
* detected). On the server every change swaps immediately.
|
|
435
|
+
*/
|
|
436
|
+
declare class MmTransition<T> {
|
|
437
|
+
private readonly tpl;
|
|
438
|
+
private readonly vcr;
|
|
439
|
+
private readonly parent;
|
|
440
|
+
private readonly onServer;
|
|
441
|
+
/** The value whose changes are transitioned. Each view keeps the value it was created with. */
|
|
442
|
+
readonly value: i0.InputSignal<T>;
|
|
443
|
+
/** Skip holding entirely — every change swaps at once (the plain re-render behavior). */
|
|
444
|
+
readonly immediate: i0.InputSignal<boolean>;
|
|
445
|
+
/** Wrap the swap in the View Transitions API for an animated cross-fade (feature detected). */
|
|
446
|
+
readonly viewTransition: i0.InputSignal<boolean>;
|
|
447
|
+
private current;
|
|
448
|
+
private incoming;
|
|
449
|
+
/** Bumped on every re-target/teardown so a superseded (possibly deferred) swap can't commit. */
|
|
450
|
+
private swapEpoch;
|
|
451
|
+
private readonly holding;
|
|
452
|
+
/** True while an incoming view is mounted hidden, waiting to settle. */
|
|
453
|
+
readonly pending: Signal<boolean>;
|
|
454
|
+
static ngTemplateContextGuard<T>(dir: MmTransition<T>, ctx: unknown): ctx is MmTransitionContext<T>;
|
|
455
|
+
constructor();
|
|
456
|
+
private onValue;
|
|
457
|
+
private commitSwap;
|
|
458
|
+
/** The actual swap: destroy the old view, reveal the new one. Always instant. */
|
|
459
|
+
private finishSwap;
|
|
460
|
+
private dropIncoming;
|
|
461
|
+
private createView;
|
|
462
|
+
private setHidden;
|
|
463
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MmTransition<any>, never>;
|
|
464
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<MmTransition<any>, "[mmTransition]", ["mmTransition"], { "value": { "alias": "mmTransition"; "required": true; "isSignal": true; }; "immediate": { "alias": "mmTransitionImmediate"; "required": false; "isSignal": true; }; "viewTransition": { "alias": "mmTransitionViewTransition"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
465
|
+
}
|
|
466
|
+
|
|
406
467
|
/**
|
|
407
468
|
* Options for creating a debounced writable signal.
|
|
408
469
|
* Extends Angular's `CreateSignalOptions` with a debounce time setting.
|
|
@@ -3266,5 +3327,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
3266
3327
|
*/
|
|
3267
3328
|
declare function withHistory<T>(sourceOrValue: WritableSignal<T> | T, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
3268
3329
|
|
|
3269
|
-
export { MmActivity, PAUSABLE_OPTIONS, SuspenseBoundary, SuspenseBoundaryBase, UnscopedSuspenseBoundary, activeTransaction, batteryStatus, chunked, clipboard, combineWith, createAttributedPending, createForwardingScope, createTransaction, createTransitionScope, debounce, debounced, derived, distinct, elementSize, elementVisibility, extendStore, filter, filterWith, focusWithin, forkStore, geolocation, getTransitionScope, holdUntilReady, idle, indexArray, injectPaused, injectRegisterResource, injectStartTransaction, injectStartTransition, injectTransitionScope, isDerivation, isLeaf, isMutable, isOpaque, isStore, keepPrevious, keyArray, map, mapArray, mapObject, mediaQuery, merge3, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, opaque, orientation, pageVisibility, pairwise, pausableComputed, pausableEffect, pausableSignal, pipeable, piped, pointerDrag, pooled, pooledArray, pooledMap, pooledSet, prefersDarkMode, prefersReducedMotion, provideForwardingTransitionScope, providePausableOptions, providePaused, provideTransitionScope, registerResource, resolvePause, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
3270
|
-
export type { BatteryStatus, ClipboardSignal, Computation, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, DebouncedSignal, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, Fork, ForkStoreOptions, ForkStrategy, ForwardingTransitionScope, Frame, GeolocationOptions, GeolocationSignal, IdleOptions, IdleSignal, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, Opaque, PausableOptions, PauseOption, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ReconcileFn, RegisterOptions, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreOptions, StoredSignal, SuspendType, ThrottledSignal, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|
|
3330
|
+
export { MmActivity, MmTransition, PAUSABLE_OPTIONS, SuspenseBoundary, SuspenseBoundaryBase, UnscopedSuspenseBoundary, activeTransaction, batteryStatus, chunked, clipboard, combineWith, createAttributedPending, createForwardingScope, createTransaction, createTransitionScope, debounce, debounced, derived, distinct, elementSize, elementVisibility, extendStore, filter, filterWith, focusWithin, forkStore, geolocation, getTransitionScope, holdUntilReady, idle, indexArray, injectPaused, injectRegisterResource, injectStartTransaction, injectStartTransition, injectTransitionScope, isDerivation, isLeaf, isMutable, isOpaque, isStore, keepPrevious, keyArray, map, mapArray, mapObject, mediaQuery, merge3, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, opaque, orientation, pageVisibility, pairwise, pausableComputed, pausableEffect, pausableSignal, pipeable, piped, pointerDrag, pooled, pooledArray, pooledMap, pooledSet, prefersDarkMode, prefersReducedMotion, provideForwardingTransitionScope, providePausableOptions, providePaused, provideTransitionScope, registerResource, resolvePause, scan, scrollPosition, select, sensor, sensors, signalFromEvent, startWith, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
3331
|
+
export type { BatteryStatus, ClipboardSignal, Computation, CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreatePooledOptions, CreateProvidedPooledOptions, CreateStoredOptions, CreateThrottledOptions, DebouncedSignal, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, ExtendStoreOptions, Fork, ForkStoreOptions, ForkStrategy, ForwardingTransitionScope, Frame, GeolocationOptions, GeolocationSignal, IdleOptions, IdleSignal, MmTransitionContext, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, Opaque, PausableOptions, PauseOption, PipeableSignal, PointerDragOptions, PointerDragSignal, PointerDragState, PointerModifiers, PointerPoint, ReconcileFn, RegisterOptions, ScreenOrientation, ScreenOrientationState, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SensorRunOptions, SignalFromEventOptions, SignalStore, SignalWithHistory, StoreOptions, StoredSignal, SuspendType, ThrottledSignal, Transaction, TransactionRef, TransitionRef, TransitionScope, UntilOptions, Vivify, WindowSize, WindowSizeOptions, WindowSizeSignal, WithVivify, WritableSignalStore, toStoreOptions };
|