@krizaka/ui 3.41.1 → 3.43.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/dist/RotatingWord-D9s7FXFD.d.ts +46 -0
- package/dist/app-shell.d.ts +9 -3
- package/dist/app-shell.js +6 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/bird-plate.js +1 -1
- package/dist/{chunk-M4DBVG43.js → chunk-MHUUNC5W.js} +4 -3
- package/dist/chunk-MHUUNC5W.js.map +1 -0
- package/dist/{chunk-EZC54B5C.js → chunk-MIMOTE4W.js} +3 -3
- package/dist/{chunk-EZC54B5C.js.map → chunk-MIMOTE4W.js.map} +1 -1
- package/dist/{chunk-CC2FBLLR.js → chunk-P4TTKYC4.js} +2 -2
- package/dist/chunk-P4TTKYC4.js.map +1 -0
- package/dist/code-block.js +1 -1
- package/dist/code-block.js.map +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/date-picker.js.map +1 -1
- package/dist/elephant.d.ts +57 -0
- package/dist/elephant.js +61 -0
- package/dist/elephant.js.map +1 -0
- package/dist/flock.d.ts +7 -1
- package/dist/flock.js +386 -50
- package/dist/flock.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/map.js.map +1 -1
- package/dist/mascot-quote.js +1 -1
- package/dist/mascot-state.js +1 -1
- package/dist/mascots.d.ts +3 -1
- package/dist/mascots.js +1 -1
- package/dist/motion.css +44 -0
- package/dist/motion.d.ts +46 -39
- package/dist/motion.js +42 -1
- package/dist/motion.js.map +1 -1
- package/dist/native/map.js.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.d.ts +2 -0
- package/dist/nav-bar.js +1 -1
- package/dist/nav-bar.js.map +1 -1
- package/dist/popover.js +1 -1
- package/dist/popover.js.map +1 -1
- package/dist/rail-nav.js +2 -2
- package/dist/rail-nav.js.map +1 -1
- package/dist/site-footer.d.ts +15 -8
- package/dist/site-footer.js +34 -9
- package/dist/site-footer.js.map +1 -1
- package/dist/sites.js +1 -1
- package/dist/sites.js.map +1 -1
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/package.json +21 -7
- package/registry/account-menu.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +11 -3
- package/registry/argument-card.json +1 -1
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +1 -1
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +1 -1
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +192 -0
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/app-shell/collapse-overflow.d.ts +4 -0
- package/registry/examples/app-shell/collapse-overflow.js +35 -0
- package/registry/examples/app-shell/collapse-overflow.tsx +28 -0
- package/registry/examples/elephant/closing.d.ts +4 -0
- package/registry/examples/elephant/closing.js +14 -0
- package/registry/examples/elephant/closing.tsx +11 -0
- package/registry/examples/elephant/poses.d.ts +4 -0
- package/registry/examples/elephant/poses.js +14 -0
- package/registry/examples/elephant/poses.tsx +11 -0
- package/registry/examples/flock/scenes.d.ts +4 -0
- package/registry/examples/flock/scenes.js +28 -0
- package/registry/examples/flock/scenes.tsx +24 -0
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +34 -6
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +40 -9
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +16 -2
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/nav-bar.json +5 -5
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/photo-grid.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +2 -2
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +3 -3
- package/registry/recipes.json +1 -1
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +1 -1
- package/registry/showcase.json +1 -1
- package/registry/site-footer.json +35 -7
- package/registry/sites.json +2 -2
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +2 -2
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/waveform.json +1 -1
- package/dist/chunk-CC2FBLLR.js.map +0 -1
- package/dist/chunk-M4DBVG43.js.map +0 -1
package/dist/mascot-quote.js
CHANGED
package/dist/mascot-state.js
CHANGED
package/dist/mascots.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ type MascotProps = Omit<React.ComponentProps<"svg">, "children"> & {
|
|
|
43
43
|
flying?: boolean;
|
|
44
44
|
/** Which way it leans in flight, -1 (left) to 1 (right). */
|
|
45
45
|
bank?: number;
|
|
46
|
+
/** Whether the pigeon holds its parcel (default `true`): a flock hands it over and the bird flies back light. */
|
|
47
|
+
carrying?: boolean;
|
|
46
48
|
/** A tap or a poke just happened (`life`): a small jump. Set it for a moment, then unset. */
|
|
47
49
|
poked?: boolean;
|
|
48
50
|
};
|
|
@@ -50,7 +52,7 @@ type MascotProps = Omit<React.ComponentProps<"svg">, "children"> & {
|
|
|
50
52
|
* One of the nine Krizaka figures in one mood — for the moments a product speaks to a person: a welcome, a long wait,
|
|
51
53
|
* a success, an empty list, an error. Drawn in the host's brand colours by default (`tone="own"` for the story's).
|
|
52
54
|
*/
|
|
53
|
-
declare function Mascot({ bird, mood, tone, size, animated, title, life, phase, look, flying, bank, poked, className, style, ...props }: MascotProps): React.JSX.Element;
|
|
55
|
+
declare function Mascot({ bird, mood, tone, size, animated, title, life, phase, look, flying, bank, poked, carrying, className, style, ...props }: MascotProps): React.JSX.Element;
|
|
54
56
|
|
|
55
57
|
type PhoenixProps = Omit<React.ComponentProps<"svg">, "children"> & {
|
|
56
58
|
/** `own` (default): the violet wing and the gold wing of the Krizaka story. `brand`: the host's accent and accent-2. */
|
package/dist/mascots.js
CHANGED
package/dist/motion.css
CHANGED
|
@@ -711,3 +711,47 @@ svg[data-kz-icon="ExternalIcon"] {
|
|
|
711
711
|
.kz-iso-item > .kz-iso-lift, .kz-iso-tip { transition: none; }
|
|
712
712
|
[data-kz-arrive], tr:has([data-kz-arrive]), li:has(> [data-kz-arrive]), .kz-grow svg { animation: none !important; }
|
|
713
713
|
}
|
|
714
|
+
|
|
715
|
+
/* ── COMPONENT TRANSITIONS (docs/direction-2027.md, step b) ─────────────────────────────────────────────────────────
|
|
716
|
+
Overlays, panels and tabs enter and leave with the platform: @starting-style + allow-discrete for the enter, a
|
|
717
|
+
keyframe animation for the exit (Radix Presence keeps an element mounted only while it runs an animation). The
|
|
718
|
+
durations and easings are the --kz-motion-* tokens (defined in @krizaka/tokens; the fallbacks below stand until then).
|
|
719
|
+
Reduced motion: no animation, no transition — the change is instant. */
|
|
720
|
+
:root {
|
|
721
|
+
--kz-motion-duration-fast: 150ms;
|
|
722
|
+
--kz-motion-duration-base: 220ms;
|
|
723
|
+
--kz-motion-ease-out: cubic-bezier(0.2, 0, 0, 1);
|
|
724
|
+
--kz-motion-ease-in: cubic-bezier(0.4, 0, 1, 1);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
.kz-overlay {
|
|
728
|
+
transition: opacity var(--kz-motion-duration-base) var(--kz-motion-ease-out), display var(--kz-motion-duration-base), overlay var(--kz-motion-duration-base);
|
|
729
|
+
transition-behavior: allow-discrete;
|
|
730
|
+
}
|
|
731
|
+
.kz-overlay[data-state="open"] { opacity: 1; }
|
|
732
|
+
@starting-style { .kz-overlay[data-state="open"] { opacity: 0; } }
|
|
733
|
+
.kz-overlay[data-state="closed"] { animation: kz-overlay-out var(--kz-motion-duration-fast) var(--kz-motion-ease-in) both; }
|
|
734
|
+
@keyframes kz-overlay-out { from { opacity: 1; } to { opacity: 0; } }
|
|
735
|
+
|
|
736
|
+
.kz-dialog,
|
|
737
|
+
.kz-popover {
|
|
738
|
+
transition: opacity var(--kz-motion-duration-base) var(--kz-motion-ease-out), transform var(--kz-motion-duration-base) var(--kz-motion-ease-out), display var(--kz-motion-duration-base), overlay var(--kz-motion-duration-base);
|
|
739
|
+
transition-behavior: allow-discrete;
|
|
740
|
+
}
|
|
741
|
+
.kz-dialog[data-state="open"],
|
|
742
|
+
.kz-popover[data-state="open"] { opacity: 1; transform: none; }
|
|
743
|
+
@starting-style {
|
|
744
|
+
.kz-dialog[data-state="open"],
|
|
745
|
+
.kz-popover[data-state="open"] { opacity: 0; transform: scale(0.98); }
|
|
746
|
+
}
|
|
747
|
+
.kz-dialog[data-state="closed"] { animation: kz-dialog-out var(--kz-motion-duration-fast) var(--kz-motion-ease-in) both; }
|
|
748
|
+
.kz-popover[data-state="closed"] { animation: kz-popover-out var(--kz-motion-duration-fast) var(--kz-motion-ease-in) both; }
|
|
749
|
+
@keyframes kz-dialog-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(0.98); } }
|
|
750
|
+
@keyframes kz-popover-out { from { opacity: 1; } to { opacity: 0; } }
|
|
751
|
+
|
|
752
|
+
.kz-tabs-panel { animation: kz-tabs-in var(--kz-motion-duration-base) var(--kz-motion-ease-out) both; }
|
|
753
|
+
@keyframes kz-tabs-in { from { opacity: 0; } to { opacity: 1; } }
|
|
754
|
+
|
|
755
|
+
@media (prefers-reduced-motion: reduce) {
|
|
756
|
+
.kz-overlay, .kz-dialog, .kz-popover, .kz-tabs-panel { animation: none; transition: none; }
|
|
757
|
+
}
|
package/dist/motion.d.ts
CHANGED
|
@@ -1,46 +1,53 @@
|
|
|
1
|
-
|
|
1
|
+
export { M as MotionObserver, a as MotionObserverProps, R as RotatingWord, b as RotatingWordProps } from './RotatingWord-D9s7FXFD.js';
|
|
2
|
+
import 'react';
|
|
2
3
|
|
|
3
|
-
interface MotionObserverProps {
|
|
4
|
-
/**
|
|
5
|
-
* Hold the loops of the page (`.kz-loop`, the backdrop's drift) still until the page has loaded and settled
|
|
6
|
-
* (`html[data-motion="settling"]` → `"ready"`, about 1.2 s after `load`): nothing repaints the first screen while it
|
|
7
|
-
* paints.
|
|
8
|
-
* @default true
|
|
9
|
-
*/
|
|
10
|
-
settle?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Pause every animation of a scope while it is off screen (`data-offscreen` on `.kz-backdrop`, `.kz-iso`,
|
|
13
|
-
* `[data-motion-scope]` and the page's sections).
|
|
14
|
-
* @default true
|
|
15
|
-
*/
|
|
16
|
-
pauseOffscreen?: boolean;
|
|
17
|
-
}
|
|
18
4
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* prefers-reduced-motion everything is revealed at once.
|
|
5
|
+
* Page transitions on the platform: `document.startViewTransition` with a cross-fade fallback and an instant change
|
|
6
|
+
* under reduced motion. Pure functions over an injected document, so they are testable without a browser.
|
|
7
|
+
*
|
|
8
|
+
* The contract (docs/direction-2027.md): the DOM always updates; motion is only the way it gets there.
|
|
24
9
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
10
|
+
interface ViewTransitionLike {
|
|
11
|
+
readonly finished: Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
type StartViewTransition = (update: () => void) => ViewTransitionLike;
|
|
14
|
+
interface ViewTransitionEnv {
|
|
15
|
+
/** The document whose transition runs. Defaults to the global one when the call happens in a browser. */
|
|
16
|
+
readonly doc?: {
|
|
17
|
+
startViewTransition?: StartViewTransition;
|
|
18
|
+
documentElement?: {
|
|
19
|
+
animate?: (frames: Keyframe[], options: KeyframeAnimationOptions) => unknown;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** `prefers-reduced-motion: reduce`. */
|
|
23
|
+
readonly reduced?: boolean;
|
|
24
|
+
}
|
|
25
|
+
interface CrossFadeOptions {
|
|
26
|
+
/** Milliseconds of the fallback cross-fade. */
|
|
27
|
+
readonly duration?: number;
|
|
28
|
+
readonly easing?: string;
|
|
37
29
|
}
|
|
30
|
+
/** True when the browser can run a native view transition. */
|
|
31
|
+
declare function canViewTransition(doc: ViewTransitionEnv["doc"]): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Runs `update` inside a view transition when the platform has one and motion is allowed; otherwise it runs `update`
|
|
34
|
+
* at once. Resolves when the transition has finished (or straight away when there is none). It never rejects: a
|
|
35
|
+
* skipped or aborted transition still leaves the DOM in its new state.
|
|
36
|
+
*/
|
|
37
|
+
declare function runViewTransition(update: () => void, env?: ViewTransitionEnv): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* The fallback for a browser without view transitions: the change is applied, then the root cross-fades from
|
|
40
|
+
* transparent. Reduced motion means no fade at all. Returns the animation when one was started, otherwise `null`.
|
|
41
|
+
*/
|
|
42
|
+
declare function crossFallback(update: () => void, env?: ViewTransitionEnv, options?: CrossFadeOptions): unknown;
|
|
43
|
+
/** One call for a change of page or step: a view transition where it exists, a cross-fade otherwise, instant under reduced motion. */
|
|
44
|
+
declare function transitionPage(update: () => void, env?: ViewTransitionEnv, options?: CrossFadeOptions): Promise<void>;
|
|
38
45
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* render shows the first word; it stays put under prefers-reduced-motion and while the tab is hidden. Decorative
|
|
42
|
-
* (`aria-hidden`): give the heading a stable accessible label.
|
|
46
|
+
* The `view-transition-name` for a shared element: the element morphs between the two states wherever it lands. The
|
|
47
|
+
* name must be one CSS identifier and unique on the page while the transition runs.
|
|
43
48
|
*/
|
|
44
|
-
declare function
|
|
49
|
+
declare function sharedElementStyle(name: string): {
|
|
50
|
+
viewTransitionName: string;
|
|
51
|
+
};
|
|
45
52
|
|
|
46
|
-
export {
|
|
53
|
+
export { type CrossFadeOptions, type ViewTransitionEnv, type ViewTransitionLike, canViewTransition, crossFallback, runViewTransition, sharedElementStyle, transitionPage };
|
package/dist/motion.js
CHANGED
|
@@ -3,8 +3,49 @@ import {
|
|
|
3
3
|
MotionObserver,
|
|
4
4
|
RotatingWord
|
|
5
5
|
} from "./chunk-4JO5GSSD.js";
|
|
6
|
+
|
|
7
|
+
// src/motion/view-transition.ts
|
|
8
|
+
var IDENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;
|
|
9
|
+
function canViewTransition(doc) {
|
|
10
|
+
return typeof doc?.startViewTransition === "function";
|
|
11
|
+
}
|
|
12
|
+
function runViewTransition(update, env = {}) {
|
|
13
|
+
if (env.reduced || !canViewTransition(env.doc)) {
|
|
14
|
+
update();
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
const transition = env.doc.startViewTransition(update);
|
|
18
|
+
return transition.finished.then(
|
|
19
|
+
() => void 0,
|
|
20
|
+
() => void 0
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function crossFallback(update, env = {}, options = {}) {
|
|
24
|
+
update();
|
|
25
|
+
if (env.reduced || canViewTransition(env.doc)) return null;
|
|
26
|
+
const root = env.doc?.documentElement;
|
|
27
|
+
if (typeof root?.animate !== "function") return null;
|
|
28
|
+
return root.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
29
|
+
duration: options.duration ?? 200,
|
|
30
|
+
easing: options.easing ?? "ease-out"
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function transitionPage(update, env = {}, options = {}) {
|
|
34
|
+
if (canViewTransition(env.doc) && !env.reduced) return runViewTransition(update, env);
|
|
35
|
+
crossFallback(update, env, options);
|
|
36
|
+
return Promise.resolve();
|
|
37
|
+
}
|
|
38
|
+
function sharedElementStyle(name) {
|
|
39
|
+
if (!IDENT.test(name)) throw new RangeError(`view-transition-name must be one identifier, got "${name}"`);
|
|
40
|
+
return { viewTransitionName: name };
|
|
41
|
+
}
|
|
6
42
|
export {
|
|
7
43
|
MotionObserver,
|
|
8
|
-
RotatingWord
|
|
44
|
+
RotatingWord,
|
|
45
|
+
canViewTransition,
|
|
46
|
+
crossFallback,
|
|
47
|
+
runViewTransition,
|
|
48
|
+
sharedElementStyle,
|
|
49
|
+
transitionPage
|
|
9
50
|
};
|
|
10
51
|
//# sourceMappingURL=motion.js.map
|
package/dist/motion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/motion/view-transition.ts"],"sourcesContent":["/**\n * Page transitions on the platform: `document.startViewTransition` with a cross-fade fallback and an instant change\n * under reduced motion. Pure functions over an injected document, so they are testable without a browser.\n *\n * The contract (docs/direction-2027.md): the DOM always updates; motion is only the way it gets there.\n */\n\nexport interface ViewTransitionLike {\n readonly finished: Promise<void>;\n}\n\nexport type StartViewTransition = (update: () => void) => ViewTransitionLike;\n\nexport interface ViewTransitionEnv {\n /** The document whose transition runs. Defaults to the global one when the call happens in a browser. */\n readonly doc?: {\n startViewTransition?: StartViewTransition;\n documentElement?: { animate?: (frames: Keyframe[], options: KeyframeAnimationOptions) => unknown };\n };\n /** `prefers-reduced-motion: reduce`. */\n readonly reduced?: boolean;\n}\n\nexport interface CrossFadeOptions {\n /** Milliseconds of the fallback cross-fade. */\n readonly duration?: number;\n readonly easing?: string;\n}\n\nconst IDENT = /^[A-Za-z_][A-Za-z0-9_-]*$/;\n\n/** True when the browser can run a native view transition. */\nexport function canViewTransition(doc: ViewTransitionEnv[\"doc\"]): boolean {\n return typeof doc?.startViewTransition === \"function\";\n}\n\n/**\n * Runs `update` inside a view transition when the platform has one and motion is allowed; otherwise it runs `update`\n * at once. Resolves when the transition has finished (or straight away when there is none). It never rejects: a\n * skipped or aborted transition still leaves the DOM in its new state.\n */\nexport function runViewTransition(update: () => void, env: ViewTransitionEnv = {}): Promise<void> {\n if (env.reduced || !canViewTransition(env.doc)) {\n update();\n return Promise.resolve();\n }\n const transition = env.doc!.startViewTransition!(update);\n return transition.finished.then(\n () => undefined,\n () => undefined,\n );\n}\n\n/**\n * The fallback for a browser without view transitions: the change is applied, then the root cross-fades from\n * transparent. Reduced motion means no fade at all. Returns the animation when one was started, otherwise `null`.\n */\nexport function crossFallback(update: () => void, env: ViewTransitionEnv = {}, options: CrossFadeOptions = {}): unknown {\n update();\n if (env.reduced || canViewTransition(env.doc)) return null;\n const root = env.doc?.documentElement;\n if (typeof root?.animate !== \"function\") return null;\n return root.animate([{ opacity: 0 }, { opacity: 1 }], {\n duration: options.duration ?? 200,\n easing: options.easing ?? \"ease-out\",\n });\n}\n\n/** One call for a change of page or step: a view transition where it exists, a cross-fade otherwise, instant under reduced motion. */\nexport function transitionPage(update: () => void, env: ViewTransitionEnv = {}, options: CrossFadeOptions = {}): Promise<void> {\n if (canViewTransition(env.doc) && !env.reduced) return runViewTransition(update, env);\n crossFallback(update, env, options);\n return Promise.resolve();\n}\n\n/**\n * The `view-transition-name` for a shared element: the element morphs between the two states wherever it lands. The\n * name must be one CSS identifier and unique on the page while the transition runs.\n */\nexport function sharedElementStyle(name: string): { viewTransitionName: string } {\n if (!IDENT.test(name)) throw new RangeError(`view-transition-name must be one identifier, got \"${name}\"`);\n return { viewTransitionName: name };\n}\n"],"mappings":";;;;;;;AA6BA,IAAM,QAAQ;AAGP,SAAS,kBAAkB,KAAwC;AACxE,SAAO,OAAO,KAAK,wBAAwB;AAC7C;AAOO,SAAS,kBAAkB,QAAoB,MAAyB,CAAC,GAAkB;AAChG,MAAI,IAAI,WAAW,CAAC,kBAAkB,IAAI,GAAG,GAAG;AAC9C,WAAO;AACP,WAAO,QAAQ,QAAQ;AAAA,EACzB;AACA,QAAM,aAAa,IAAI,IAAK,oBAAqB,MAAM;AACvD,SAAO,WAAW,SAAS;AAAA,IACzB,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AACF;AAMO,SAAS,cAAc,QAAoB,MAAyB,CAAC,GAAG,UAA4B,CAAC,GAAY;AACtH,SAAO;AACP,MAAI,IAAI,WAAW,kBAAkB,IAAI,GAAG,EAAG,QAAO;AACtD,QAAM,OAAO,IAAI,KAAK;AACtB,MAAI,OAAO,MAAM,YAAY,WAAY,QAAO;AAChD,SAAO,KAAK,QAAQ,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,GAAG;AAAA,IACpD,UAAU,QAAQ,YAAY;AAAA,IAC9B,QAAQ,QAAQ,UAAU;AAAA,EAC5B,CAAC;AACH;AAGO,SAAS,eAAe,QAAoB,MAAyB,CAAC,GAAG,UAA4B,CAAC,GAAkB;AAC7H,MAAI,kBAAkB,IAAI,GAAG,KAAK,CAAC,IAAI,QAAS,QAAO,kBAAkB,QAAQ,GAAG;AACpF,gBAAc,QAAQ,KAAK,OAAO;AAClC,SAAO,QAAQ,QAAQ;AACzB;AAMO,SAAS,mBAAmB,MAA8C;AAC/E,MAAI,CAAC,MAAM,KAAK,IAAI,EAAG,OAAM,IAAI,WAAW,qDAAqD,IAAI,GAAG;AACxG,SAAO,EAAE,oBAAoB,KAAK;AACpC;","names":[]}
|