@mieweb/ui 0.9.0 → 0.10.0-dev.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/MIGRATION.md +112 -0
- package/dist/{Animated-Cs-naa2g.d.cts → Animated-XmH6k8pZ.d.cts} +16 -3
- package/dist/{Animated-Cs-naa2g.d.ts → Animated-XmH6k8pZ.d.ts} +16 -3
- package/dist/{chunk-XUVEF2RQ.js → chunk-24SEAAOH.js} +2 -2
- package/dist/{chunk-XUVEF2RQ.js.map → chunk-24SEAAOH.js.map} +1 -1
- package/dist/{chunk-FUFBRKOG.cjs → chunk-2WBPNXO2.cjs} +21 -21
- package/dist/{chunk-FUFBRKOG.cjs.map → chunk-2WBPNXO2.cjs.map} +1 -1
- package/dist/{chunk-IUDY6S7I.cjs → chunk-37UZHCLM.cjs} +35 -14
- package/dist/chunk-37UZHCLM.cjs.map +1 -0
- package/dist/{chunk-L52N6BEN.cjs → chunk-AUOTJQGO.cjs} +7 -7
- package/dist/{chunk-L52N6BEN.cjs.map → chunk-AUOTJQGO.cjs.map} +1 -1
- package/dist/{chunk-6XDPJWSC.cjs → chunk-E7G22IQM.cjs} +32 -28
- package/dist/chunk-E7G22IQM.cjs.map +1 -0
- package/dist/chunk-IIFQ6BSJ.js +1888 -0
- package/dist/chunk-IIFQ6BSJ.js.map +1 -0
- package/dist/{chunk-ONNY7UO4.js → chunk-JDJQTKTX.js} +3 -3
- package/dist/{chunk-ONNY7UO4.js.map → chunk-JDJQTKTX.js.map} +1 -1
- package/dist/{chunk-BJKAVWED.js → chunk-MBWF36DJ.js} +35 -14
- package/dist/chunk-MBWF36DJ.js.map +1 -0
- package/dist/chunk-NV2CWBI2.cjs +290 -0
- package/dist/chunk-NV2CWBI2.cjs.map +1 -0
- package/dist/{chunk-FQBTGS3E.cjs → chunk-OFUKTVBN.cjs} +363 -285
- package/dist/chunk-OFUKTVBN.cjs.map +1 -0
- package/dist/{chunk-7KN6J7XV.cjs → chunk-OMAACCFW.cjs} +7 -7
- package/dist/{chunk-7KN6J7XV.cjs.map → chunk-OMAACCFW.cjs.map} +1 -1
- package/dist/chunk-OYQ7GYAA.cjs +1921 -0
- package/dist/chunk-OYQ7GYAA.cjs.map +1 -0
- package/dist/{chunk-YJP6DUFO.cjs → chunk-PKD3JLS2.cjs} +6 -6
- package/dist/{chunk-YJP6DUFO.cjs.map → chunk-PKD3JLS2.cjs.map} +1 -1
- package/dist/{chunk-CXDMZT45.cjs → chunk-PY7XAG4D.cjs} +27 -4
- package/dist/chunk-PY7XAG4D.cjs.map +1 -0
- package/dist/{chunk-5H7SAEQO.js → chunk-QKFJDQEK.js} +3 -3
- package/dist/{chunk-5H7SAEQO.js.map → chunk-QKFJDQEK.js.map} +1 -1
- package/dist/{chunk-XJTFZLWH.cjs → chunk-QO6PRHDX.cjs} +2 -2
- package/dist/{chunk-XJTFZLWH.cjs.map → chunk-QO6PRHDX.cjs.map} +1 -1
- package/dist/{chunk-OHDIJOGG.js → chunk-RD3JDFYJ.js} +3 -3
- package/dist/{chunk-OHDIJOGG.js.map → chunk-RD3JDFYJ.js.map} +1 -1
- package/dist/{chunk-4SM3I7WE.cjs → chunk-RXPEZXAB.cjs} +67 -38
- package/dist/chunk-RXPEZXAB.cjs.map +1 -0
- package/dist/{chunk-VTR2KGLY.cjs → chunk-S3BCHPXT.cjs} +9 -9
- package/dist/{chunk-VTR2KGLY.cjs.map → chunk-S3BCHPXT.cjs.map} +1 -1
- package/dist/{chunk-KU3XRHWA.js → chunk-TZX76ZNZ.js} +67 -38
- package/dist/chunk-TZX76ZNZ.js.map +1 -0
- package/dist/{chunk-MXQ7J4BB.js → chunk-VSVGMMNO.js} +361 -284
- package/dist/chunk-VSVGMMNO.js.map +1 -0
- package/dist/{chunk-Q7G56ZIO.js → chunk-WUBMDOTG.js} +3 -3
- package/dist/{chunk-Q7G56ZIO.js.map → chunk-WUBMDOTG.js.map} +1 -1
- package/dist/{chunk-DGRXAIWK.js → chunk-X5YM3KXY.js} +27 -4
- package/dist/chunk-X5YM3KXY.js.map +1 -0
- package/dist/chunk-XCP454Q6.js +263 -0
- package/dist/chunk-XCP454Q6.js.map +1 -0
- package/dist/{chunk-I3DQXUSC.js → chunk-Y6DFMDMH.js} +3 -3
- package/dist/{chunk-I3DQXUSC.js.map → chunk-Y6DFMDMH.js.map} +1 -1
- package/dist/{chunk-ODYQYLO2.js → chunk-YSEMAI4I.js} +8 -4
- package/dist/chunk-YSEMAI4I.js.map +1 -0
- package/dist/components/AlertDialog/index.cjs +4 -4
- package/dist/components/AlertDialog/index.js +3 -3
- package/dist/components/Collapsible/index.cjs +6 -4
- package/dist/components/Collapsible/index.js +3 -1
- package/dist/components/Dropdown/index.cjs +9 -8
- package/dist/components/Dropdown/index.js +2 -1
- package/dist/components/KeyboardShortcutsOverlay/index.cjs +5 -5
- package/dist/components/KeyboardShortcutsOverlay/index.js +3 -3
- package/dist/components/MediaEditor/index.cjs +8 -8
- package/dist/components/MediaEditor/index.js +3 -3
- package/dist/components/Modal/index.cjs +10 -10
- package/dist/components/Modal/index.js +2 -2
- package/dist/components/RichTextEditor/index.cjs +6 -5
- package/dist/components/RichTextEditor/index.js +3 -2
- package/dist/components/SuperChat/index.cjs +40 -17
- package/dist/components/SuperChat/index.cjs.map +1 -1
- package/dist/components/SuperChat/index.d.cts +20 -7
- package/dist/components/SuperChat/index.d.ts +20 -7
- package/dist/components/SuperChat/index.js +35 -12
- package/dist/components/SuperChat/index.js.map +1 -1
- package/dist/components/SuperChat/plugins/index.cjs +10 -3
- package/dist/components/SuperChat/plugins/index.cjs.map +1 -1
- package/dist/components/SuperChat/plugins/index.d.cts +3 -3
- package/dist/components/SuperChat/plugins/index.d.ts +3 -3
- package/dist/components/SuperChat/plugins/index.js +9 -2
- package/dist/components/SuperChat/plugins/index.js.map +1 -1
- package/dist/esheet.cjs +6 -6
- package/dist/esheet.js +3 -3
- package/dist/hooks/index.cjs +13 -13
- package/dist/hooks/index.js +1 -1
- package/dist/index.cjs +720 -1671
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +347 -347
- package/dist/index.d.ts +347 -347
- package/dist/index.js +459 -1405
- package/dist/index.js.map +1 -1
- package/dist/motion.cjs +7 -7
- package/dist/motion.d.cts +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +2 -2
- package/dist/styles.css +1 -1
- package/dist/tailwind-preset.cjs +4 -4
- package/dist/tailwind-preset.js +1 -1
- package/dist/{types-DZDroUW8.d.cts → types-B97JNRNQ.d.cts} +1 -1
- package/dist/{types-B2RLmdVd.d.ts → types-CnPEwzlp.d.cts} +6 -2
- package/dist/{types-B2RLmdVd.d.cts → types-CnPEwzlp.d.ts} +6 -2
- package/dist/{types-9vK_YdEb.d.ts → types-gZXrfLj6.d.ts} +1 -1
- package/package.json +2 -1
- package/dist/chunk-4SM3I7WE.cjs.map +0 -1
- package/dist/chunk-5BVFVXHN.cjs +0 -1244
- package/dist/chunk-5BVFVXHN.cjs.map +0 -1
- package/dist/chunk-6XDPJWSC.cjs.map +0 -1
- package/dist/chunk-BJKAVWED.js.map +0 -1
- package/dist/chunk-BN75TLUN.cjs +0 -163
- package/dist/chunk-BN75TLUN.cjs.map +0 -1
- package/dist/chunk-CXDMZT45.cjs.map +0 -1
- package/dist/chunk-DGRXAIWK.js.map +0 -1
- package/dist/chunk-FQBTGS3E.cjs.map +0 -1
- package/dist/chunk-IUDY6S7I.cjs.map +0 -1
- package/dist/chunk-KU3XRHWA.js.map +0 -1
- package/dist/chunk-MXQ7J4BB.js.map +0 -1
- package/dist/chunk-O6GJ4IYS.js +0 -1210
- package/dist/chunk-O6GJ4IYS.js.map +0 -1
- package/dist/chunk-ODYQYLO2.js.map +0 -1
- package/dist/chunk-WYMO3IIK.js +0 -136
- package/dist/chunk-WYMO3IIK.js.map +0 -1
package/dist/chunk-WYMO3IIK.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { cn } from './chunk-TQONQSJO.js';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
4
|
-
|
|
5
|
-
// src/motion/presets.ts
|
|
6
|
-
var motionPresets = {
|
|
7
|
-
/**
|
|
8
|
-
* Off-canvas panel pinned to the inline-start edge. Animates `x` only, which
|
|
9
|
-
* the compositor can handle without layout or paint.
|
|
10
|
-
*/
|
|
11
|
-
drawerStart: {
|
|
12
|
-
variants: {
|
|
13
|
-
open: { x: "0%" },
|
|
14
|
-
// Off-canvas direction follows writing direction, mirroring the
|
|
15
|
-
// `-translate-x-full rtl:translate-x-full` CSS fallback.
|
|
16
|
-
closed: (isRtl) => ({ x: isRtl ? "100%" : "-100%" })
|
|
17
|
-
},
|
|
18
|
-
transition: { type: "spring", stiffness: 400, damping: 40, mass: 1 }
|
|
19
|
-
},
|
|
20
|
-
/** Scrim behind a drawer or modal. */
|
|
21
|
-
overlay: {
|
|
22
|
-
variants: {
|
|
23
|
-
open: { opacity: 1 },
|
|
24
|
-
closed: { opacity: 0 }
|
|
25
|
-
},
|
|
26
|
-
transition: { duration: 0.2, ease: "easeOut" }
|
|
27
|
-
},
|
|
28
|
-
/** Centered dialog surface — rises and settles rather than popping. */
|
|
29
|
-
modalContent: {
|
|
30
|
-
variants: {
|
|
31
|
-
open: { opacity: 1, scale: 1, y: 0 },
|
|
32
|
-
closed: { opacity: 0, scale: 0.96, y: 8 }
|
|
33
|
-
},
|
|
34
|
-
transition: { type: "spring", stiffness: 500, damping: 40, mass: 0.8 }
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Text that disappears as its container narrows — sidebar labels on collapse.
|
|
38
|
-
*
|
|
39
|
-
* Opacity only, and deliberately so. An inline-axis slide would read slightly
|
|
40
|
-
* better but would make every label direction-aware, and resolving direction
|
|
41
|
-
* per nav item is a disproportionate amount of plumbing for an 8px nudge.
|
|
42
|
-
* Fading also degrades to itself under reduced motion instead of becoming a
|
|
43
|
-
* different animation.
|
|
44
|
-
*
|
|
45
|
-
* Short because it runs on many elements at once and has to finish inside the
|
|
46
|
-
* container's own width transition, or labels are still fading after the rail
|
|
47
|
-
* has stopped moving.
|
|
48
|
-
*/
|
|
49
|
-
sidebarLabel: {
|
|
50
|
-
variants: {
|
|
51
|
-
open: { opacity: 1 },
|
|
52
|
-
closed: { opacity: 0 }
|
|
53
|
-
},
|
|
54
|
-
transition: { duration: 0.15, ease: "easeOut" }
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var CONTEXT_KEY = /* @__PURE__ */ Symbol.for("@mieweb/ui.motionRuntimeContext.v1");
|
|
58
|
-
function getMotionRuntimeContext() {
|
|
59
|
-
const globalScope = globalThis;
|
|
60
|
-
if (!globalScope[CONTEXT_KEY]) {
|
|
61
|
-
globalScope[CONTEXT_KEY] = React.createContext(null);
|
|
62
|
-
}
|
|
63
|
-
return globalScope[CONTEXT_KEY];
|
|
64
|
-
}
|
|
65
|
-
var MotionRuntimeContext = getMotionRuntimeContext();
|
|
66
|
-
function useMotionRuntime() {
|
|
67
|
-
return React.useContext(MotionRuntimeContext);
|
|
68
|
-
}
|
|
69
|
-
function createPresetPropBuilders() {
|
|
70
|
-
return {
|
|
71
|
-
toggle(preset, open, custom) {
|
|
72
|
-
const { variants, transition } = motionPresets[preset];
|
|
73
|
-
return {
|
|
74
|
-
variants,
|
|
75
|
-
transition,
|
|
76
|
-
custom,
|
|
77
|
-
// `false` pins the element to its current variant on mount instead of
|
|
78
|
-
// animating into it.
|
|
79
|
-
initial: false,
|
|
80
|
-
animate: open ? "open" : "closed"
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
presence(preset, custom) {
|
|
84
|
-
const { variants, transition } = motionPresets[preset];
|
|
85
|
-
return {
|
|
86
|
-
variants,
|
|
87
|
-
transition,
|
|
88
|
-
custom,
|
|
89
|
-
initial: "closed",
|
|
90
|
-
animate: "open",
|
|
91
|
-
exit: "closed"
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
var Animated = React.forwardRef(
|
|
97
|
-
function Animated2({
|
|
98
|
-
as = "div",
|
|
99
|
-
preset,
|
|
100
|
-
mode,
|
|
101
|
-
open = false,
|
|
102
|
-
custom,
|
|
103
|
-
className,
|
|
104
|
-
fallbackClassName,
|
|
105
|
-
enabled = true,
|
|
106
|
-
children,
|
|
107
|
-
...rest
|
|
108
|
-
}, ref) {
|
|
109
|
-
const runtime = useMotionRuntime();
|
|
110
|
-
if (!runtime || !runtime.enabled || !enabled) {
|
|
111
|
-
const Tag = as;
|
|
112
|
-
return /* @__PURE__ */ jsx(Tag, { ref, className: cn(fallbackClassName, className), ...rest, children });
|
|
113
|
-
}
|
|
114
|
-
const Component = as === "nav" ? runtime.Nav : as === "span" ? runtime.Span : runtime.Div;
|
|
115
|
-
const motionProps = mode === "toggle" ? runtime.toggle(preset, open, custom) : runtime.presence(preset, custom);
|
|
116
|
-
return /* @__PURE__ */ jsx(Component, { ref, className, ...motionProps, ...rest, children });
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
Animated.displayName = "Animated";
|
|
120
|
-
function AnimatedPresence({
|
|
121
|
-
children,
|
|
122
|
-
initial,
|
|
123
|
-
onExitComplete
|
|
124
|
-
}) {
|
|
125
|
-
const runtime = useMotionRuntime();
|
|
126
|
-
if (!runtime) {
|
|
127
|
-
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
128
|
-
}
|
|
129
|
-
const { Presence } = runtime;
|
|
130
|
-
return /* @__PURE__ */ jsx(Presence, { initial, onExitComplete, children });
|
|
131
|
-
}
|
|
132
|
-
AnimatedPresence.displayName = "AnimatedPresence";
|
|
133
|
-
|
|
134
|
-
export { Animated, AnimatedPresence, MotionRuntimeContext, createPresetPropBuilders, motionPresets, useMotionRuntime };
|
|
135
|
-
//# sourceMappingURL=chunk-WYMO3IIK.js.map
|
|
136
|
-
//# sourceMappingURL=chunk-WYMO3IIK.js.map
|
|
@@ -1 +0,0 @@
|
|
|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M,UAAU,gBAAA,EAAiB;AAEjC,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,uCAAU,QAAA,EAAS,CAAA;AAAA,EACrB;AAEA,EAAA,MAAM,EAAE,UAAS,GAAI,OAAA;AACrB,EAAA,uBACE,GAAA,CAAC,QAAA,EAAA,EAAS,OAAA,EAAkB,cAAA,EACzB,QAAA,EACH,CAAA;AAEJ;AAEA,gBAAA,CAAiB,WAAA,GAAc,kBAAA","file":"chunk-WYMO3IIK.js","sourcesContent":["/**\n * Motion presets — the shared vocabulary of animations.\n *\n * This module is intentionally **free of any `motion` import**. It ships in the\n * main `@mieweb/ui` entry so components can describe *what* they animate\n * without pulling in a runtime to actually do it. The `@mieweb/ui/motion` entry\n * is what turns these descriptions into real animations.\n *\n * Every preset is expressed as an open/closed variant pair so the same\n * definition serves both usages:\n *\n * - **toggle** — the element stays mounted and animates between `open` and\n * `closed` (a drawer sliding in and out).\n * - **presence** — the element mounts and unmounts, entering on `open` and\n * exiting back to `closed` (a modal).\n */\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/** Named animation recipes shared by components. */\nexport type MotionPreset =\n | 'drawerStart'\n | 'overlay'\n | 'modalContent'\n | 'sidebarLabel';\n\n/**\n * A variant value. Either a plain target object or a function of the element's\n * `custom` value — the latter lets a single preset adapt to context, e.g. a\n * drawer flipping its off-canvas direction in RTL.\n */\nexport type MotionVariant =\n | Record<string, unknown>\n | ((custom: unknown) => Record<string, unknown>);\n\nexport interface MotionPresetDefinition {\n variants: {\n open: MotionVariant;\n closed: MotionVariant;\n };\n transition: Record<string, unknown>;\n}\n\n// =============================================================================\n// Presets\n// =============================================================================\n\n/**\n * `custom` contract per preset:\n *\n * - `drawerStart` — `boolean`, whether the document direction is RTL.\n * - `overlay`, `modalContent`, `sidebarLabel` — unused.\n */\nexport const motionPresets: Record<MotionPreset, MotionPresetDefinition> = {\n /**\n * Off-canvas panel pinned to the inline-start edge. Animates `x` only, which\n * the compositor can handle without layout or paint.\n */\n drawerStart: {\n variants: {\n open: { x: '0%' },\n // Off-canvas direction follows writing direction, mirroring the\n // `-translate-x-full rtl:translate-x-full` CSS fallback.\n closed: (isRtl: unknown) => ({ x: isRtl ? '100%' : '-100%' }),\n },\n transition: { type: 'spring', stiffness: 400, damping: 40, mass: 1 },\n },\n\n /** Scrim behind a drawer or modal. */\n overlay: {\n variants: {\n open: { opacity: 1 },\n closed: { opacity: 0 },\n },\n transition: { duration: 0.2, ease: 'easeOut' },\n },\n\n /** Centered dialog surface — rises and settles rather than popping. */\n modalContent: {\n variants: {\n open: { opacity: 1, scale: 1, y: 0 },\n closed: { opacity: 0, scale: 0.96, y: 8 },\n },\n transition: { type: 'spring', stiffness: 500, damping: 40, mass: 0.8 },\n },\n\n /**\n * Text that disappears as its container narrows — sidebar labels on collapse.\n *\n * Opacity only, and deliberately so. An inline-axis slide would read slightly\n * better but would make every label direction-aware, and resolving direction\n * per nav item is a disproportionate amount of plumbing for an 8px nudge.\n * Fading also degrades to itself under reduced motion instead of becoming a\n * different animation.\n *\n * Short because it runs on many elements at once and has to finish inside the\n * container's own width transition, or labels are still fading after the rail\n * has stopped moving.\n */\n sidebarLabel: {\n variants: {\n open: { opacity: 1 },\n closed: { opacity: 0 },\n },\n transition: { duration: 0.15, ease: 'easeOut' },\n },\n};\n","/**\n * Motion runtime — the seam between components and an optional animation library.\n *\n * Components in the main entry never import `motion`. They ask this module for\n * a runtime; if an app has opted in by rendering `<MotionProvider>` from\n * `@mieweb/ui/motion`, they get one and animate. If not, `useMotionRuntime()`\n * returns `null` and they fall back to their existing CSS transitions. That is\n * what keeps `motion` out of the bundle of every app that hasn't asked for it —\n * the opt-in is resolved in the *module graph*, not by a prop.\n *\n * Like `presets`, this module must stay free of any `motion` import.\n */\n\nimport * as React from 'react';\nimport { motionPresets, type MotionPreset } from './presets';\n\n// =============================================================================\n// Types\n// =============================================================================\n\nexport interface MotionPresenceProps {\n children?: React.ReactNode;\n /** Suppress the initial mount animation. */\n initial?: boolean;\n /**\n * Fires once every exiting child has finished and been removed.\n *\n * Needed by anything that guards the DOM while it is open — a focus trap, a\n * scroll lock — because those guards must outlive `open` for as long as the\n * subtree is still on screen. Never fires when no runtime is active, since\n * there is no exit to wait for.\n */\n onExitComplete?: () => void;\n}\n\n/**\n * The capabilities a motion library must supply. Deliberately small: element\n * factories, a presence wrapper, and prop builders. Components depend on this\n * interface, never on a concrete library, so swapping or dropping the library\n * stays a one-file change.\n */\nexport interface MotionRuntime {\n /**\n * Whether animations should actually run.\n *\n * A disabled provider still supplies a runtime rather than `null` so that\n * consumers can tell \"disabled\" apart from \"never opted in\": `Modal` uses it\n * to decide whether an exit animation will ever report completion, and\n * `AnimatedPresence` keeps its wrapper element stable across the flip.\n * `Animated` itself renders the plain fallback tag whenever this is false —\n * withholding animation props from a mounted motion component corrupts\n * `toggle`-mode elements, so the swap (and the remount it implies) is the\n * correct behaviour. See the render branches in `Animated`.\n */\n enabled: boolean;\n /** Animated `div`. */\n Div: React.ElementType;\n /** Animated `nav`. */\n Nav: React.ElementType;\n /** Animated `span`, for inline content that must not become a block. */\n Span: React.ElementType;\n /** Enables exit animations for conditionally rendered children. */\n Presence: React.ComponentType<MotionPresenceProps>;\n /**\n * Props for an element that stays mounted and animates between states.\n * Skips the initial animation so a closed drawer doesn't slide out on load.\n */\n toggle: (\n preset: MotionPreset,\n open: boolean,\n custom?: unknown\n ) => Record<string, unknown>;\n /** Props for an element that mounts and unmounts inside `Presence`. */\n presence: (preset: MotionPreset, custom?: unknown) => Record<string, unknown>;\n}\n\n// =============================================================================\n// Context\n// =============================================================================\n\n/**\n * The context is stashed on `globalThis` under a registered symbol rather than\n * held in a module-local `const`.\n *\n * `@mieweb/ui` and `@mieweb/ui/motion` are separate bundle entries, and CJS\n * builds cannot code-split. Without this, the provider and the components\n * would each get their own copy of the context object and the provider would\n * silently never be seen — animations would simply never turn on, with no\n * error to explain why. A duplicated install of the package causes the same\n * failure. Keying off the global symbol registry makes the context a true\n * singleton in every one of those cases.\n *\n * The key is versioned. Two copies of this package sharing one page share\n * whatever lives under the key, so the `v1` suffix is a compatibility\n * contract: bump it if the `MotionRuntime` interface ever changes shape,\n * or an old provider will hand a new component a runtime it cannot use.\n */\nconst CONTEXT_KEY = Symbol.for('@mieweb/ui.motionRuntimeContext.v1');\n\ntype GlobalWithMotionContext = typeof globalThis & {\n [CONTEXT_KEY]?: React.Context<MotionRuntime | null>;\n};\n\nfunction getMotionRuntimeContext(): React.Context<MotionRuntime | null> {\n const globalScope = globalThis as GlobalWithMotionContext;\n if (!globalScope[CONTEXT_KEY]) {\n globalScope[CONTEXT_KEY] = React.createContext<MotionRuntime | null>(null);\n }\n return globalScope[CONTEXT_KEY];\n}\n\n/** @internal Consumed by `<MotionProvider>` in the `@mieweb/ui/motion` entry. */\nexport const MotionRuntimeContext = getMotionRuntimeContext();\n\n// =============================================================================\n// Hooks\n// =============================================================================\n\n/**\n * The active motion runtime, or `null` when the app has not opted in.\n *\n * Components must treat `null` as the normal case and keep a CSS path that\n * looks good on its own — motion is an enhancement, never a requirement.\n */\nexport function useMotionRuntime(): MotionRuntime | null {\n return React.useContext(MotionRuntimeContext);\n}\n\n// =============================================================================\n// Prop builders\n// =============================================================================\n\n/**\n * Builds the `toggle`/`presence` prop builders around a library-agnostic core.\n * Exported so `<MotionProvider>` can assemble a runtime without restating the\n * preset lookup.\n *\n * @internal\n */\nexport function createPresetPropBuilders(): Pick<\n MotionRuntime,\n 'toggle' | 'presence'\n> {\n return {\n toggle(preset, open, custom) {\n const { variants, transition } = motionPresets[preset];\n return {\n variants,\n transition,\n custom,\n // `false` pins the element to its current variant on mount instead of\n // animating into it.\n initial: false,\n animate: open ? 'open' : 'closed',\n };\n },\n\n presence(preset, custom) {\n const { variants, transition } = motionPresets[preset];\n return {\n variants,\n transition,\n custom,\n initial: 'closed',\n animate: 'open',\n exit: 'closed',\n };\n },\n };\n}\n","/**\n * `Animated` / `AnimatedPresence` — the ergonomic layer components use.\n *\n * These exist so an individual component never has to branch on whether motion\n * is available. It declares the preset it wants and the CSS classes that stand\n * in when motion is absent; this module picks the element to render.\n *\n * Adding motion to a further component should be a matter of swapping its\n * root `<div>` for an `<Animated>` and naming a preset — no new imports, no\n * new dependency, and no behavior change for apps that have not opted in.\n */\n\nimport * as React from 'react';\nimport { cn } from '../utils/cn';\nimport { useMotionRuntime, type MotionPresenceProps } from './runtime';\nimport type { MotionPreset } from './presets';\n\n// =============================================================================\n// Animated\n// =============================================================================\n\nexport interface AnimatedProps extends React.HTMLAttributes<HTMLElement> {\n /** Intrinsic element to render. */\n as?: 'div' | 'nav' | 'span';\n /** Which shared animation recipe to use. */\n preset: MotionPreset;\n /**\n * - `toggle` — element stays mounted and animates between open and closed.\n * - `presence` — element mounts and unmounts; wrap it in `<AnimatedPresence>`\n * so the exit animation gets a chance to run.\n */\n mode: 'toggle' | 'presence';\n /** Current state. Only read in `toggle` mode. */\n open?: boolean;\n /** Per-preset context value — see the `custom` contract in `presets.ts`. */\n custom?: unknown;\n /**\n * Classes applied whenever this element is **not** animating — no provider,\n * a disabled provider, or `enabled={false}`. This is where a component's\n * existing CSS transition lives, so the two paths never both try to drive\n * the same property.\n */\n fallbackClassName?: string;\n /**\n * Set `false` to stop this element animating even when a runtime is active.\n *\n * For states where an animated element would be wrong rather than merely\n * unnecessary. Motion writes a `transform` to hold an element at its resting\n * position, and a transformed ancestor becomes the containing block for any\n * `position: fixed` descendant — so an element that is only sometimes\n * animated should opt out the rest of the time.\n *\n * Flipping this (or the provider's `disabled`) swaps the element back to a\n * plain tag, which **remounts** it — deliberately. See the note on the\n * render branches below.\n */\n enabled?: boolean;\n}\n\nexport const Animated = React.forwardRef<HTMLElement, AnimatedProps>(\n function Animated(\n {\n as = 'div',\n preset,\n mode,\n open = false,\n custom,\n className,\n fallbackClassName,\n enabled = true,\n children,\n ...rest\n },\n ref\n ) {\n const runtime = useMotionRuntime();\n\n /*\n * Anything not animating renders the plain tag with the CSS fallback —\n * no provider, a disabled provider, or `enabled={false}` alike.\n *\n * Crossing between this branch and the motion one changes the element\n * type, which remounts the subtree. That is deliberate. The obvious\n * alternative — keeping the motion component mounted and only withholding\n * its animation props — corrupts `toggle`-mode elements in both\n * directions, because motion only writes variant styles at mount or in\n * response to an animation:\n *\n * - props added in place (a drawer crossing into its mobile breakpoint\n * while closed) never get the `closed` transform, so the drawer sits\n * fully visible over the page;\n * - props removed in place strand whatever inline `transform` motion last\n * wrote, so a sidebar returning to desktop stays off-canvas.\n *\n * Fresh mounts are correct in both worlds, so remounting at the flip is\n * the fix. The flips are rare — a breakpoint cross, a test toggling the\n * provider — and a remount that resets local state beats a stale\n * transform that removes the navigation.\n */\n if (!runtime || !runtime.enabled || !enabled) {\n const Tag = as as React.ElementType;\n return (\n <Tag ref={ref} className={cn(fallbackClassName, className)} {...rest}>\n {children}\n </Tag>\n );\n }\n\n const Component =\n as === 'nav' ? runtime.Nav : as === 'span' ? runtime.Span : runtime.Div;\n\n const motionProps =\n mode === 'toggle'\n ? runtime.toggle(preset, open, custom)\n : runtime.presence(preset, custom);\n\n return (\n <Component ref={ref} className={className} {...motionProps} {...rest}>\n {children}\n </Component>\n );\n }\n);\n\nAnimated.displayName = 'Animated';\n\n// =============================================================================\n// AnimatedPresence\n// =============================================================================\n\n/**\n * Keeps unmounting children on screen long enough to animate out.\n *\n * Without a runtime this is a pass-through, so children disappear immediately —\n * which is exactly what they do today. Children rendered conditionally inside\n * it need a stable `key`.\n */\nexport function AnimatedPresence({\n children,\n initial,\n onExitComplete,\n}: MotionPresenceProps): React.JSX.Element {\n const runtime = useMotionRuntime();\n\n if (!runtime) {\n return <>{children}</>;\n }\n\n const { Presence } = runtime;\n return (\n <Presence initial={initial} onExitComplete={onExitComplete}>\n {children}\n </Presence>\n );\n}\n\nAnimatedPresence.displayName = 'AnimatedPresence';\n"]}
|