@cognitap/radiant 0.0.6 → 0.0.7

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.
Files changed (158) hide show
  1. package/CHANGELOG.md +68 -385
  2. package/README.md +41 -1014
  3. package/RELEASE_POLICY.md +3 -3
  4. package/dist/library/Accordion.d.ts +3 -0
  5. package/dist/library/Accordion.d.ts.map +1 -1
  6. package/dist/library/Accordion.js +1 -1
  7. package/dist/library/Accordion.js.map +1 -1
  8. package/dist/library/Button.d.ts +5 -0
  9. package/dist/library/Button.d.ts.map +1 -1
  10. package/dist/library/Button.js +8 -7
  11. package/dist/library/Button.js.map +1 -1
  12. package/dist/library/Card.d.ts +2 -0
  13. package/dist/library/Card.d.ts.map +1 -1
  14. package/dist/library/Card.js +1 -1
  15. package/dist/library/Card.js.map +1 -1
  16. package/dist/library/Checkbox.d.ts +5 -0
  17. package/dist/library/Checkbox.d.ts.map +1 -1
  18. package/dist/library/Checkbox.js +3 -2
  19. package/dist/library/Checkbox.js.map +1 -1
  20. package/dist/library/Collapsible.d.ts +4 -0
  21. package/dist/library/Collapsible.d.ts.map +1 -1
  22. package/dist/library/Collapsible.js +22 -4
  23. package/dist/library/Collapsible.js.map +1 -1
  24. package/dist/library/Dialog.d.ts +3 -0
  25. package/dist/library/Dialog.d.ts.map +1 -1
  26. package/dist/library/Dialog.js.map +1 -1
  27. package/dist/library/Field.d.ts +8 -0
  28. package/dist/library/Field.d.ts.map +1 -1
  29. package/dist/library/Field.js +2 -0
  30. package/dist/library/Field.js.map +1 -1
  31. package/dist/library/Input.d.ts +3 -0
  32. package/dist/library/Input.d.ts.map +1 -1
  33. package/dist/library/Input.js +1 -0
  34. package/dist/library/Input.js.map +1 -1
  35. package/dist/library/Link.d.ts +5 -0
  36. package/dist/library/Link.d.ts.map +1 -1
  37. package/dist/library/Link.js.map +1 -1
  38. package/dist/library/RadioGroup.d.ts +8 -0
  39. package/dist/library/RadioGroup.d.ts.map +1 -1
  40. package/dist/library/RadioGroup.js +4 -2
  41. package/dist/library/RadioGroup.js.map +1 -1
  42. package/dist/library/examples/expressive.d.ts +4 -0
  43. package/dist/library/examples/expressive.d.ts.map +1 -0
  44. package/dist/library/{themes → examples}/expressive.js +4 -3
  45. package/dist/library/examples/expressive.js.map +1 -0
  46. package/dist/library/examples/glass.d.ts +4 -0
  47. package/dist/library/examples/glass.d.ts.map +1 -0
  48. package/dist/library/{themes → examples}/glass.js +4 -3
  49. package/dist/library/examples/glass.js.map +1 -0
  50. package/dist/library/examples/index.d.ts +13 -0
  51. package/dist/library/examples/index.d.ts.map +1 -0
  52. package/dist/library/examples/index.js +32 -0
  53. package/dist/library/examples/index.js.map +1 -0
  54. package/dist/library/examples/jelly.d.ts +4 -0
  55. package/dist/library/examples/jelly.d.ts.map +1 -0
  56. package/dist/library/{themes → examples}/jelly.js +4 -3
  57. package/dist/library/examples/jelly.js.map +1 -0
  58. package/dist/library/examples/preset-values.d.ts.map +1 -0
  59. package/dist/library/examples/preset-values.js.map +1 -0
  60. package/dist/library/examples/radiant.d.ts +4 -0
  61. package/dist/library/examples/radiant.d.ts.map +1 -0
  62. package/dist/library/{themes → examples}/radiant.js +4 -3
  63. package/dist/library/examples/radiant.js.map +1 -0
  64. package/dist/library/examples/sharp-3d.d.ts +4 -0
  65. package/dist/library/examples/sharp-3d.d.ts.map +1 -0
  66. package/dist/library/{themes → examples}/sharp-3d.js +4 -3
  67. package/dist/library/examples/sharp-3d.js.map +1 -0
  68. package/dist/library/examples/soft-squircle.d.ts +4 -0
  69. package/dist/library/examples/soft-squircle.d.ts.map +1 -0
  70. package/dist/library/{themes → examples}/soft-squircle.js +4 -3
  71. package/dist/library/examples/soft-squircle.js.map +1 -0
  72. package/dist/library/examples/ticket.d.ts +4 -0
  73. package/dist/library/examples/ticket.d.ts.map +1 -0
  74. package/dist/library/{themes → examples}/ticket.js +4 -3
  75. package/dist/library/examples/ticket.js.map +1 -0
  76. package/dist/library/index.d.ts +1 -1
  77. package/dist/library/index.d.ts.map +1 -1
  78. package/dist/library/index.js +1 -1
  79. package/dist/library/index.js.map +1 -1
  80. package/dist/library/motion/MotionLink.d.ts +1 -0
  81. package/dist/library/motion/MotionLink.d.ts.map +1 -1
  82. package/dist/library/motion/MotionLink.js +9 -10
  83. package/dist/library/motion/MotionLink.js.map +1 -1
  84. package/dist/library/motion/host.d.ts +5 -2
  85. package/dist/library/motion/host.d.ts.map +1 -1
  86. package/dist/library/motion/host.js +13 -5
  87. package/dist/library/motion/host.js.map +1 -1
  88. package/dist/library/motion/press.d.ts.map +1 -1
  89. package/dist/library/motion/press.js +41 -14
  90. package/dist/library/motion/press.js.map +1 -1
  91. package/dist/library/motion/pressPolicy.d.ts.map +1 -1
  92. package/dist/library/motion/pressPolicy.js +2 -2
  93. package/dist/library/motion/pressPolicy.js.map +1 -1
  94. package/dist/library/motion/transitions.d.ts.map +1 -1
  95. package/dist/library/motion/transitions.js +48 -15
  96. package/dist/library/motion/transitions.js.map +1 -1
  97. package/dist/library/styles.css +1 -1
  98. package/dist/library/themes/index.d.ts +1 -11
  99. package/dist/library/themes/index.d.ts.map +1 -1
  100. package/dist/library/themes/index.js +1 -19
  101. package/dist/library/themes/index.js.map +1 -1
  102. package/docs/accessibility.md +76 -142
  103. package/docs/architecture.md +197 -0
  104. package/docs/motion.md +115 -396
  105. package/docs/theming.md +275 -882
  106. package/package.json +9 -5
  107. package/src/Accordion.tsx +4 -1
  108. package/src/Button.tsx +13 -7
  109. package/src/Card.tsx +3 -1
  110. package/src/Checkbox.tsx +7 -2
  111. package/src/Collapsible.tsx +28 -4
  112. package/src/Dialog.tsx +3 -0
  113. package/src/Field.tsx +8 -0
  114. package/src/Input.tsx +3 -0
  115. package/src/Link.tsx +5 -0
  116. package/src/RadioGroup.tsx +10 -2
  117. package/src/{themes → examples}/expressive.ts +5 -3
  118. package/src/{themes → examples}/glass.ts +5 -3
  119. package/src/examples/index.ts +35 -0
  120. package/src/{themes → examples}/jelly.ts +5 -3
  121. package/src/{themes → examples}/radiant.ts +5 -3
  122. package/src/{themes → examples}/sharp-3d.ts +5 -3
  123. package/src/{themes → examples}/soft-squircle.ts +5 -3
  124. package/src/{themes → examples}/ticket.ts +5 -3
  125. package/src/index.ts +1 -13
  126. package/src/motion/MotionLink.tsx +16 -11
  127. package/src/motion/host.ts +14 -6
  128. package/src/motion/press.ts +32 -12
  129. package/src/motion/pressPolicy.ts +4 -2
  130. package/src/motion/transitions.ts +45 -14
  131. package/src/themes/index.ts +1 -22
  132. package/dist/library/themes/expressive.d.ts +0 -2
  133. package/dist/library/themes/expressive.d.ts.map +0 -1
  134. package/dist/library/themes/expressive.js.map +0 -1
  135. package/dist/library/themes/glass.d.ts +0 -2
  136. package/dist/library/themes/glass.d.ts.map +0 -1
  137. package/dist/library/themes/glass.js.map +0 -1
  138. package/dist/library/themes/jelly.d.ts +0 -2
  139. package/dist/library/themes/jelly.d.ts.map +0 -1
  140. package/dist/library/themes/jelly.js.map +0 -1
  141. package/dist/library/themes/preset-values.d.ts.map +0 -1
  142. package/dist/library/themes/preset-values.js.map +0 -1
  143. package/dist/library/themes/radiant.d.ts +0 -2
  144. package/dist/library/themes/radiant.d.ts.map +0 -1
  145. package/dist/library/themes/radiant.js.map +0 -1
  146. package/dist/library/themes/sharp-3d.d.ts +0 -2
  147. package/dist/library/themes/sharp-3d.d.ts.map +0 -1
  148. package/dist/library/themes/sharp-3d.js.map +0 -1
  149. package/dist/library/themes/soft-squircle.d.ts +0 -2
  150. package/dist/library/themes/soft-squircle.d.ts.map +0 -1
  151. package/dist/library/themes/soft-squircle.js.map +0 -1
  152. package/dist/library/themes/ticket.d.ts +0 -2
  153. package/dist/library/themes/ticket.d.ts.map +0 -1
  154. package/dist/library/themes/ticket.js.map +0 -1
  155. package/docs/system.md +0 -264
  156. /package/dist/library/{themes → examples}/preset-values.d.ts +0 -0
  157. /package/dist/library/{themes → examples}/preset-values.js +0 -0
  158. /package/src/{themes → examples}/preset-values.ts +0 -0
@@ -1,9 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useContext } from 'react';
4
3
  import { Link } from '../Link.js';
5
4
  import { cn } from '../cn.js';
6
- import { MotionHostContext } from './host.js';
7
5
  import { usePressHost } from './host.js';
8
6
  import { callerOwnsPress, springPressClass, offPressClass } from './pressPolicy.js';
9
7
  /** Optional client adapter for action-shaped Link; ordinary Link stays server-renderable. */
@@ -14,22 +12,23 @@ export function MotionLink({ ref, motion = 'inherit', className, ...props }) {
14
12
  props.variant === undefined ||
15
13
  props.variant === 'inline' ||
16
14
  props.variant === 'subtle';
17
- const runtime = useContext(MotionHostContext);
18
- const active = runtime !== null && !disabled;
19
- const { ref: motionRef, press: startPress, release } = usePressHost(ref, disabled);
20
- return (_jsx(Link, { ...props, ref: active ? motionRef : ref, className: cn(active && springPressClass, motion === 'off' && !owns && offPressClass, className), onPointerDown: event => {
15
+ const { ref: motionRef, press: startPress, release, off, active } = usePressHost(ref, disabled);
16
+ return (_jsx(Link, { ...props, ref: active ? motionRef : ref, className: cn(active && springPressClass, (motion === 'off' || off) && !owns && offPressClass, className), onPointerDown: event => {
21
17
  props.onPointerDown?.(event);
22
18
  if (!event.defaultPrevented)
23
19
  startPress(event.nativeEvent);
24
20
  }, onPointerUp: event => {
25
21
  props.onPointerUp?.(event);
26
- release();
22
+ release(event.nativeEvent);
27
23
  }, onPointerCancel: event => {
28
24
  props.onPointerCancel?.(event);
29
- release();
25
+ release(event.nativeEvent);
30
26
  }, onPointerLeave: event => {
31
27
  props.onPointerLeave?.(event);
32
- release();
28
+ release(event.nativeEvent);
29
+ }, onLostPointerCapture: event => {
30
+ props.onLostPointerCapture?.(event);
31
+ release(event.nativeEvent);
33
32
  }, onBlur: event => {
34
33
  props.onBlur?.(event);
35
34
  release();
@@ -39,7 +38,7 @@ export function MotionLink({ ref, motion = 'inherit', className, ...props }) {
39
38
  startPress(event.nativeEvent);
40
39
  }, onKeyUp: event => {
41
40
  props.onKeyUp?.(event);
42
- release();
41
+ release(event.nativeEvent);
43
42
  } }));
44
43
  }
45
44
  //# sourceMappingURL=MotionLink.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MotionLink.js","sourceRoot":"","sources":["../../../src/motion/MotionLink.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEnF,6FAA6F;AAC7F,MAAM,UAAU,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,GAAG,KAAK,EAAmB;IAC1F,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACpD,MAAM,QAAQ,GACZ,IAAI;QACJ,MAAM,KAAK,KAAK;QAChB,KAAK,CAAC,OAAO,KAAK,SAAS;QAC3B,KAAK,CAAC,OAAO,KAAK,QAAQ;QAC1B,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAA;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7C,MAAM,MAAM,GAAG,OAAO,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAA;IAC5C,MAAM,EACJ,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,UAAU,EACjB,OAAO,EACR,GAAG,YAAY,CAAoB,GAAG,EAAE,QAAQ,CAAC,CAAA;IAClD,OAAO,CACL,KAAC,IAAI,OACC,KAAK,EACT,GAAG,EAAE,MAAM,CAAC,CAAC,CA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Props } from '../Link.js'\nimport { cn } from '../cn.js'\nimport { MotionHostContext } from './host.js'\nimport { usePressHost } from './host.js'\nimport { callerOwnsPress, springPressClass, offPressClass } from './pressPolicy.js'\nexport type MotionLinkProps = LinkProps & { motion?: 'inherit' | 'off' }\n/** Optional client adapter for action-shaped Link; ordinary Link stays server-renderable. */\nexport function MotionLink({ ref, motion = 'inherit', className, ...props }: MotionLinkProps) {\n const owns = callerOwnsPress(props.style, className)\n const disabled =\n owns ||\n motion === 'off' ||\n props.variant === undefined ||\n props.variant === 'inline' ||\n props.variant === 'subtle'\n const runtime = useContext(MotionHostContext)\n const active = runtime !== null && !disabled\n const {\n ref: motionRef,\n press: startPress,\n release\n } = usePressHost<HTMLAnchorElement>(ref, disabled)\n return (\n <Link\n {...props}\n ref={active ? motionRef : ref}\n className={cn(\n active && springPressClass,\n motion === 'off' && !owns && offPressClass,\n className\n )}\n onPointerDown={event => {\n props.onPointerDown?.(event)\n if (!event.defaultPrevented) startPress(event.nativeEvent)\n }}\n onPointerUp={event => {\n props.onPointerUp?.(event)\n release()\n }}\n onPointerCancel={event => {\n props.onPointerCancel?.(event)\n release()\n }}\n onPointerLeave={event => {\n props.onPointerLeave?.(event)\n release()\n }}\n onBlur={event => {\n props.onBlur?.(event)\n release()\n }}\n onKeyDown={event => {\n props.onKeyDown?.(event)\n if (!event.defaultPrevented) startPress(event.nativeEvent)\n }}\n onKeyUp={event => {\n props.onKeyUp?.(event)\n release()\n }}\n />\n )\n}\n"]}
1
+ {"version":3,"file":"MotionLink.js","sourceRoot":"","sources":["../../../src/motion/MotionLink.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,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B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC5B,CAAC,EACD,cAAc,EAAE,KAAK,CAAC,EAAE;YACtB,KAAK,CAAC,cAAc,EAAE,CAAC,KAAK,CAAC,CAAA;YAC7B,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC5B,CAAC,EACD,oBAAoB,EAAE,KAAK,CAAC,EAAE;YAC5B,KAAK,CAAC,oBAAoB,EAAE,CAAC,KAAK,CAAC,CAAA;YACnC,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC5B,CAAC,EACD,MAAM,EAAE,KAAK,CAAC,EAAE;YACd,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAA;YACrB,OAAO,EAAE,CAAA;QACX,CAAC,EACD,SAAS,EAAE,KAAK,CAAC,EAAE;YACjB,KAAK,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,CAAA;YACxB,IAAI,CAAC,KAAK,CAAC,gBAAgB;gBAAE,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC5D,CAAC,EACD,OAAO,EAAE,KAAK,CAAC,EAAE;YACf,KAAK,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAA;YACtB,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAC5B,CAAC,GACD,CACH,CAAA;AACH,CAAC","sourcesContent":["'use client'\nimport { Link, type LinkProps } from '../Link.js'\nimport { cn } from '../cn.js'\nimport { usePressHost } from './host.js'\nimport { callerOwnsPress, springPressClass, offPressClass } from './pressPolicy.js'\nexport type MotionLinkProps = LinkProps & {\n /** Inherit the theme's spring policy; off suppresses spatial feedback. Requires MotionProvider. */\n motion?: 'inherit' | 'off'\n}\n/** Optional client adapter for action-shaped Link; ordinary Link stays server-renderable. */\nexport function MotionLink({ ref, motion = 'inherit', className, ...props }: MotionLinkProps) {\n const owns = callerOwnsPress(props.style, className)\n const disabled =\n owns ||\n motion === 'off' ||\n props.variant === undefined ||\n props.variant === 'inline' ||\n props.variant === 'subtle'\n const {\n ref: motionRef,\n press: startPress,\n release,\n off,\n active\n } = usePressHost<HTMLAnchorElement>(ref, disabled)\n return (\n <Link\n {...props}\n ref={active ? motionRef : ref}\n className={cn(\n active && springPressClass,\n (motion === 'off' || off) && !owns && offPressClass,\n className\n )}\n onPointerDown={event => {\n props.onPointerDown?.(event)\n if (!event.defaultPrevented) startPress(event.nativeEvent)\n }}\n onPointerUp={event => {\n props.onPointerUp?.(event)\n release(event.nativeEvent)\n }}\n onPointerCancel={event => {\n props.onPointerCancel?.(event)\n release(event.nativeEvent)\n }}\n onPointerLeave={event => {\n props.onPointerLeave?.(event)\n release(event.nativeEvent)\n }}\n onLostPointerCapture={event => {\n props.onLostPointerCapture?.(event)\n release(event.nativeEvent)\n }}\n onBlur={event => {\n props.onBlur?.(event)\n release()\n }}\n onKeyDown={event => {\n props.onKeyDown?.(event)\n if (!event.defaultPrevented) startPress(event.nativeEvent)\n }}\n onKeyUp={event => {\n props.onKeyUp?.(event)\n release(event.nativeEvent)\n }}\n />\n )\n}\n"]}
@@ -3,7 +3,7 @@ import type { MotionProfile } from './config.js';
3
3
  export interface MotionHostBinding {
4
4
  update(profile: MotionProfile): void;
5
5
  press?(event: PointerEvent | KeyboardEvent): void;
6
- release?(): void;
6
+ release?(event?: PointerEvent | KeyboardEvent): void;
7
7
  destroy(): void;
8
8
  }
9
9
  export interface MotionHostRuntime {
@@ -16,12 +16,15 @@ export declare const MotionHostContext: import("react").Context<MotionHostRuntim
16
16
  export declare function usePressHost<Node extends HTMLElement>(ref: Ref<Node> | undefined, disabled: boolean): {
17
17
  ref: import("react").RefCallback<Node>;
18
18
  active: boolean;
19
+ off: boolean;
19
20
  press(event: PointerEvent | KeyboardEvent): void;
20
- release(): void;
21
+ release(event?: PointerEvent | KeyboardEvent): void;
21
22
  };
22
23
  /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
23
24
  export declare function useTransitionHost<Node extends HTMLElement>(kind: 'disclosure' | 'dialog', ref: Ref<Node> | undefined, disabled: boolean): {
24
25
  ref: import("react").RefCallback<Node>;
25
26
  active: boolean;
27
+ ready: boolean;
28
+ off: boolean;
26
29
  };
27
30
  //# sourceMappingURL=host.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../../src/motion/host.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IACpC,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI,CAAA;IACjD,OAAO,CAAC,IAAI,IAAI,CAAA;IAChB,OAAO,IAAI,IAAI,CAAA;CAChB;AACD,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;IACnE,UAAU,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;IACzE,MAAM,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAAA;CACtE;AACD,eAAO,MAAM,iBAAiB,mDAAgD,CAAA;AAC9E,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,IAAI,SAAS,WAAW,EACnD,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,SAAS,EAC1B,QAAQ,EAAE,OAAO;;;iBA2BF,YAAY,GAAG,aAAa;;EAO5C;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,IAAI,SAAS,WAAW,EACxD,IAAI,EAAE,YAAY,GAAG,QAAQ,EAC7B,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,GAAG,SA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@
1
1
  'use client';
2
- import { createContext, useContext, useEffect, useRef } from 'react';
2
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
3
3
  import { MotionProfileContext } from './context.js';
4
4
  import { useComposedRefs } from '../react/useComposedRefs.js';
5
5
  export const MotionHostContext = createContext(null);
@@ -27,11 +27,12 @@ export function usePressHost(ref, disabled) {
27
27
  return {
28
28
  ref: composed,
29
29
  active: runtime !== null && !disabled,
30
+ off: profile.mode === 'off',
30
31
  press(event) {
31
32
  binding.current?.value.press?.(event);
32
33
  },
33
- release() {
34
- binding.current?.value.release?.();
34
+ release(event) {
35
+ binding.current?.value.release?.(event);
35
36
  }
36
37
  };
37
38
  }
@@ -42,6 +43,7 @@ export function useTransitionHost(kind, ref, disabled) {
42
43
  const node = useRef(null);
43
44
  const binding = useRef(null);
44
45
  const composed = useComposedRefs(node, ref);
46
+ const [ready, setReady] = useState(false);
45
47
  useEffect(() => {
46
48
  const attach = runtime?.[kind];
47
49
  if (disabled || !attach || !node.current || binding.current?.node !== node.current) {
@@ -52,11 +54,17 @@ export function useTransitionHost(kind, ref, disabled) {
52
54
  binding.current ??= { node: node.current, value: attach(node.current, profile) };
53
55
  binding.current.value.update(profile);
54
56
  }
55
- });
57
+ setReady(binding.current !== null);
58
+ }, [disabled, kind, runtime, profile, composed]);
56
59
  useEffect(() => () => {
57
60
  binding.current?.value.destroy();
58
61
  binding.current = null;
59
62
  }, []);
60
- return { ref: composed, active: !disabled && runtime?.[kind] !== undefined };
63
+ return {
64
+ ref: composed,
65
+ active: !disabled && runtime?.[kind] !== undefined,
66
+ ready,
67
+ off: profile.mode === 'off'
68
+ };
61
69
  }
62
70
  //# sourceMappingURL=host.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host.js","sourceRoot":"","sources":["../../../src/motion/host.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAY,MAAM,OAAO,CAAA;AAE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O,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;YAChF,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAC,CAAA;IACF,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,EACD,EAAE,CACH,CAAA;IACD,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAA;AAC9E,CAAC","sourcesContent":["'use client'\nimport { createContext, useContext, useEffect, useRef, type Ref } from 'react'\nimport type { MotionProfile } from './config.js'\nimport { MotionProfileContext } from './context.js'\nimport { useComposedRefs } from '../react/useComposedRefs.js'\n\nexport interface MotionHostBinding {\n update(profile: MotionProfile): void\n press?(event: PointerEvent | KeyboardEvent): void\n release?(): void\n destroy(): void\n}\nexport interface MotionHostRuntime {\n press(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n}\nexport const MotionHostContext = createContext<MotionHostRuntime | null>(null)\n/** Engine-free bridge: only the opt-in provider supplies implementation. */\nexport function usePressHost<Node extends HTMLElement>(\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: HTMLElement; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n useEffect(() => {\n if (disabled || !runtime || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && runtime && node.current) {\n binding.current ??= { node: node.current, value: runtime.press(node.current, profile) }\n binding.current.value.update(profile)\n }\n })\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return {\n ref: composed,\n active: runtime !== null && !disabled,\n press(event: PointerEvent | KeyboardEvent) {\n binding.current?.value.press?.(event)\n },\n release() {\n binding.current?.value.release?.()\n }\n }\n}\n\n/** Shared lifecycle for native presentation adapters; no engine enters the root path. */\nexport function useTransitionHost<Node extends HTMLElement>(\n kind: 'disclosure' | 'dialog',\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: Node; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n useEffect(() => {\n const attach = runtime?.[kind]\n if (disabled || !attach || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && attach && node.current) {\n binding.current ??= { node: node.current, value: attach(node.current, profile) }\n binding.current.value.update(profile)\n }\n })\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return { ref: composed, active: !disabled && runtime?.[kind] !== undefined }\n}\n"]}
1
+ {"version":3,"file":"host.js","sourceRoot":"","sources":["../../../src/motion/host.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAY,MAAM,OAAO,CAAA;AAExF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAa7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAA2B,IAAI,CAAC,CAAA;AAC9E,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAC1B,G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,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAA;YAChF,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;QACvC,CAAC;QACD,QAAQ,CAAC,OAAO,CAAC,OAAO,KAAK,IAAI,CAAC,CAAA;IACpC,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAA;IAChD,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,OAAO,GAAG,IAAI,CAAA;IACxB,CAAC,EACD,EAAE,CACH,CAAA;IACD,OAAO;QACL,GAAG,EAAE,QAAQ;QACb,MAAM,EAAE,CAAC,QAAQ,IAAI,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,SAAS;QAClD,KAAK;QACL,GAAG,EAAE,OAAO,CAAC,IAAI,KAAK,KAAK;KAC5B,CAAA;AACH,CAAC","sourcesContent":["'use client'\nimport { createContext, useContext, useEffect, useRef, useState, type Ref } from 'react'\nimport type { MotionProfile } from './config.js'\nimport { MotionProfileContext } from './context.js'\nimport { useComposedRefs } from '../react/useComposedRefs.js'\n\nexport interface MotionHostBinding {\n update(profile: MotionProfile): void\n press?(event: PointerEvent | KeyboardEvent): void\n release?(event?: PointerEvent | KeyboardEvent): void\n destroy(): void\n}\nexport interface MotionHostRuntime {\n press(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding\n}\nexport const MotionHostContext = createContext<MotionHostRuntime | null>(null)\n/** Engine-free bridge: only the opt-in provider supplies implementation. */\nexport function usePressHost<Node extends HTMLElement>(\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: HTMLElement; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n useEffect(() => {\n if (disabled || !runtime || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && runtime && node.current) {\n binding.current ??= { node: node.current, value: runtime.press(node.current, profile) }\n binding.current.value.update(profile)\n }\n })\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return {\n ref: composed,\n active: runtime !== null && !disabled,\n off: profile.mode === 'off',\n press(event: PointerEvent | KeyboardEvent) {\n binding.current?.value.press?.(event)\n },\n release(event?: PointerEvent | KeyboardEvent) {\n binding.current?.value.release?.(event)\n }\n }\n}\n\n/** Shared lifecycle for native presentation adapters; no engine enters the root path. */\nexport function useTransitionHost<Node extends HTMLElement>(\n kind: 'disclosure' | 'dialog',\n ref: Ref<Node> | undefined,\n disabled: boolean\n) {\n const runtime = useContext(MotionHostContext)\n const profile = useContext(MotionProfileContext)\n const node = useRef<Node>(null)\n const binding = useRef<{ node: Node; value: MotionHostBinding } | null>(null)\n const composed = useComposedRefs(node, ref)\n const [ready, setReady] = useState(false)\n useEffect(() => {\n const attach = runtime?.[kind]\n if (disabled || !attach || !node.current || binding.current?.node !== node.current) {\n binding.current?.value.destroy()\n binding.current = null\n }\n if (!disabled && attach && node.current) {\n binding.current ??= { node: node.current, value: attach(node.current, profile) }\n binding.current.value.update(profile)\n }\n setReady(binding.current !== null)\n }, [disabled, kind, runtime, profile, composed])\n useEffect(\n () => () => {\n binding.current?.value.destroy()\n binding.current = null\n },\n []\n )\n return {\n ref: composed,\n active: !disabled && runtime?.[kind] !== undefined,\n ready,\n off: profile.mode === 'off'\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/motion/press.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,yFAAyF;AACzF,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,aAAa,GAC5B,iBAAiB,CAmEnB"}
1
+ {"version":3,"file":"press.d.ts","sourceRoot":"","sources":["../../../src/motion/press.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,yFAAyF;AACzF,wBAAgB,eAAe,CAC7B,IAAI,EAAE,WAAW,EACjB,cAAc,EAAE,aAAa,GAC5B,iBAAiB,CAuFnB"}
@@ -10,25 +10,45 @@ export function bindPressMotion(node, initialProfile) {
10
10
  reducedValue: 1
11
11
  });
12
12
  const unbind = bindSpringStyle(node, spring, 'scale');
13
- const blocked = () => node.matches(':disabled') ||
13
+ let pressed = null;
14
+ const blocked = () => (node.tagName === 'A' && !node.hasAttribute('href')) ||
15
+ node.matches(':disabled') ||
14
16
  node.getAttribute('aria-busy') === 'true' ||
15
17
  node.getAttribute('aria-disabled') === 'true';
16
- const release = () => spring.to(1);
18
+ function release(event) {
19
+ if (!pressed)
20
+ return;
21
+ if (event) {
22
+ if ('key' in event) {
23
+ if (!('key' in pressed) || event.key !== pressed.key)
24
+ return;
25
+ }
26
+ else if (!('pointerId' in pressed) || event.pointerId !== pressed.pointerId)
27
+ return;
28
+ }
29
+ pressed = null;
30
+ spring.to(1);
31
+ }
32
+ function reset() {
33
+ pressed = null;
34
+ spring.jump(1);
35
+ }
17
36
  function update(next) {
18
37
  profile = next;
19
- spring.configure({ ...resolveMotion(profile, 'press', query.matches), reducedValue: 1 });
20
- if (blocked())
21
- spring.jump(1);
38
+ const resolved = resolveMotion(profile, 'press', query.matches);
39
+ spring.configure({ ...resolved, reducedValue: 1 });
40
+ if (blocked() || !resolved.enabled)
41
+ reset();
22
42
  }
23
43
  const changed = () => update(profile);
24
44
  query.addEventListener('change', changed);
25
45
  const observer = new MutationObserver(() => {
26
46
  if (blocked())
27
- spring.jump(1);
47
+ reset();
28
48
  });
29
49
  observer.observe(node, {
30
50
  attributes: true,
31
- attributeFilter: ['disabled', 'aria-busy', 'aria-disabled']
51
+ attributeFilter: ['disabled', 'aria-busy', 'aria-disabled', 'href']
32
52
  });
33
53
  for (let parent = node.parentElement; parent; parent = parent.parentElement) {
34
54
  if (parent.tagName === 'FIELDSET')
@@ -38,21 +58,28 @@ export function bindPressMotion(node, initialProfile) {
38
58
  document.addEventListener('pointerup', release);
39
59
  document.addEventListener('pointercancel', release);
40
60
  document.addEventListener('keyup', release);
41
- document.defaultView.addEventListener('blur', release);
61
+ const blur = () => release();
62
+ document.defaultView.addEventListener('blur', blur);
42
63
  return {
43
64
  update,
44
65
  press(event) {
45
- if (event.defaultPrevented || blocked()) {
46
- release();
66
+ if (event.defaultPrevented || blocked())
67
+ return;
68
+ if (!resolveMotion(profile, 'press', query.matches).enabled)
47
69
  return;
48
- }
49
70
  if ('key' in event) {
50
71
  if (event.repeat ||
51
72
  !['Enter', ...(node.tagName === 'BUTTON' ? [' '] : [])].includes(event.key))
52
73
  return;
74
+ if (pressed)
75
+ return;
76
+ pressed = { key: event.key };
77
+ }
78
+ else {
79
+ if (event.button !== 0 || event.isPrimary === false || pressed)
80
+ return;
81
+ pressed = { pointerId: event.pointerId };
53
82
  }
54
- else if (event.button !== 0 || event.isPrimary === false)
55
- return;
56
83
  const scale = Number(getComputedStyle(node).getPropertyValue('--rad-button-press-scale').trim() || '.97');
57
84
  spring.to(Number.isFinite(scale) && scale >= 0.5 && scale <= 1 ? scale : 0.97);
58
85
  },
@@ -63,7 +90,7 @@ export function bindPressMotion(node, initialProfile) {
63
90
  document.removeEventListener('pointerup', release);
64
91
  document.removeEventListener('pointercancel', release);
65
92
  document.removeEventListener('keyup', release);
66
- document.defaultView.removeEventListener('blur', release);
93
+ document.defaultView.removeEventListener('blur', blur);
67
94
  spring.destroy();
68
95
  unbind();
69
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"press.js","sourceRoot":"","sources":["../../../src/motion/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAA;AAG/D,yFAAyF;AACzF,MAAM,UAAU,eAAe,CAC7B,IAAiB,EACjB,cAA6B;IAE7B,IAAI,OAAO,GAAG,cAAc,CAAA;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAY,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;IAC5F,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,EAAE;QAC7B,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACjD,YAAY,EAAE,CAAC;KAChB,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,MAAM;QACzC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAA;IAC/C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAClC,SAAS,MAAM,CAAC,IAAmB;QACjC,OAAO,GAAG,IAAI,CAAA;QACd,MAAM,CAAC,SAAS,CAAC,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC,CAAA;QACxF,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ourcesContent":["import { createSpring } from './runtime.js'\nimport { bindSpringStyle } from './browser.js'\nimport { resolveMotion, type MotionProfile } from './config.js'\nimport type { MotionHostBinding } from './host.js'\n\n/** Presentation only: this adapter never clicks, submits, captures or prevents input. */\nexport function bindPressMotion(\n node: HTMLElement,\n initialProfile: MotionProfile\n): MotionHostBinding {\n let profile = initialProfile\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n const spring = createSpring(1, {\n ...resolveMotion(profile, 'press', query.matches),\n reducedValue: 1\n })\n const unbind = bindSpringStyle(node, spring, 'scale')\n const blocked = () =>\n node.matches(':disabled') ||\n node.getAttribute('aria-busy') === 'true' ||\n node.getAttribute('aria-disabled') === 'true'\n const release = () => spring.to(1)\n function update(next: MotionProfile) {\n profile = next\n spring.configure({ ...resolveMotion(profile, 'press', query.matches), reducedValue: 1 })\n if (blocked()) spring.jump(1)\n }\n const changed = () => update(profile)\n query.addEventListener('change', changed)\n const observer = new MutationObserver(() => {\n if (blocked()) spring.jump(1)\n })\n observer.observe(node, {\n attributes: true,\n attributeFilter: ['disabled', 'aria-busy', 'aria-disabled']\n })\n for (let parent = node.parentElement; parent; parent = parent.parentElement) {\n if (parent.tagName === 'FIELDSET')\n observer.observe(parent, { attributes: true, attributeFilter: ['disabled'] })\n }\n const document = node.ownerDocument\n document.addEventListener('pointerup', release)\n document.addEventListener('pointercancel', release)\n document.addEventListener('keyup', release)\n document.defaultView!.addEventListener('blur', release)\n return {\n update,\n press(event) {\n if (event.defaultPrevented || blocked()) {\n release()\n return\n }\n if ('key' in event) {\n if (\n event.repeat ||\n !['Enter', ...(node.tagName === 'BUTTON' ? [' '] : [])].includes(event.key)\n )\n return\n } else if (event.button !== 0 || event.isPrimary === false) return\n const scale = Number(\n getComputedStyle(node).getPropertyValue('--rad-button-press-scale').trim() || '.97'\n )\n spring.to(Number.isFinite(scale) && scale >= 0.5 && scale <= 1 ? scale : 0.97)\n },\n release,\n destroy() {\n observer.disconnect()\n query.removeEventListener('change', changed)\n document.removeEventListener('pointerup', release)\n document.removeEventListener('pointercancel', release)\n document.removeEventListener('keyup', release)\n document.defaultView!.removeEventListener('blur', release)\n spring.destroy()\n unbind()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"press.js","sourceRoot":"","sources":["../../../src/motion/press.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAA;AAG/D,yFAAyF;AACzF,MAAM,UAAU,eAAe,CAC7B,IAAiB,EACjB,cAA6B;IAE7B,IAAI,OAAO,GAAG,cAAc,CAAA;IAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAY,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;IAC5F,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,EAAE;QAC7B,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;QACjD,YAAY,EAAE,CAAC;KAChB,CAAC,CAAA;IACF,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACrD,IAAI,OAAO,GAAmD,IAAI,CAAA;IAClE,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,CAAC,IAAI,CAAC,OAAO,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACpD,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,MAAM;QACzC,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAA;IAC/C,SAAS,OAAO,CAAC,KAAoC;QACnD,IAAI,CAAC,OAAO;YAAE,OAAM;QACpB,IAAI,KAAK,EAAE,CAAC;YACV,IAA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AAG,EAAE,CAAA;YAC9B,CAAC;iBAAM,CAAC;gBACN,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,SAAS,KAAK,KAAK,IAAI,OAAO;oBAAE,OAAM;gBACtE,OAAO,GAAG,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAA;YAC1C,CAAC;YACD,MAAM,KAAK,GAAG,MAAM,CAClB,gBAAgB,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC,0BAA0B,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,CACpF,CAAA;YACD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAChF,CAAC;QACD,OAAO;QACP,OAAO;YACL,QAAQ,CAAC,UAAU,EAAE,CAAA;YACrB,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;YAC5C,QAAQ,CAAC,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;YAClD,QAAQ,CAAC,mBAAmB,CAAC,eAAe,EAAE,OAAO,CAAC,CAAA;YACtD,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC9C,QAAQ,CAAC,WAAY,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACvD,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,MAAM,EAAE,CAAA;QACV,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createSpring } from './runtime.js'\nimport { bindSpringStyle } from './browser.js'\nimport { resolveMotion, type MotionProfile } from './config.js'\nimport type { MotionHostBinding } from './host.js'\n\n/** Presentation only: this adapter never clicks, submits, captures or prevents input. */\nexport function bindPressMotion(\n node: HTMLElement,\n initialProfile: MotionProfile\n): MotionHostBinding {\n let profile = initialProfile\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n const spring = createSpring(1, {\n ...resolveMotion(profile, 'press', query.matches),\n reducedValue: 1\n })\n const unbind = bindSpringStyle(node, spring, 'scale')\n let pressed: { key: string } | { pointerId: number } | null = null\n const blocked = () =>\n (node.tagName === 'A' && !node.hasAttribute('href')) ||\n node.matches(':disabled') ||\n node.getAttribute('aria-busy') === 'true' ||\n node.getAttribute('aria-disabled') === 'true'\n function release(event?: PointerEvent | KeyboardEvent) {\n if (!pressed) return\n if (event) {\n if ('key' in event) {\n if (!('key' in pressed) || event.key !== pressed.key) return\n } else if (!('pointerId' in pressed) || event.pointerId !== pressed.pointerId) return\n }\n pressed = null\n spring.to(1)\n }\n function reset() {\n pressed = null\n spring.jump(1)\n }\n function update(next: MotionProfile) {\n profile = next\n const resolved = resolveMotion(profile, 'press', query.matches)\n spring.configure({ ...resolved, reducedValue: 1 })\n if (blocked() || !resolved.enabled) reset()\n }\n const changed = () => update(profile)\n query.addEventListener('change', changed)\n const observer = new MutationObserver(() => {\n if (blocked()) reset()\n })\n observer.observe(node, {\n attributes: true,\n attributeFilter: ['disabled', 'aria-busy', 'aria-disabled', 'href']\n })\n for (let parent = node.parentElement; parent; parent = parent.parentElement) {\n if (parent.tagName === 'FIELDSET')\n observer.observe(parent, { attributes: true, attributeFilter: ['disabled'] })\n }\n const document = node.ownerDocument\n document.addEventListener('pointerup', release)\n document.addEventListener('pointercancel', release)\n document.addEventListener('keyup', release)\n const blur = () => release()\n document.defaultView!.addEventListener('blur', blur)\n return {\n update,\n press(event) {\n if (event.defaultPrevented || blocked()) return\n if (!resolveMotion(profile, 'press', query.matches).enabled) return\n if ('key' in event) {\n if (\n event.repeat ||\n !['Enter', ...(node.tagName === 'BUTTON' ? [' '] : [])].includes(event.key)\n )\n return\n if (pressed) return\n pressed = { key: event.key }\n } else {\n if (event.button !== 0 || event.isPrimary === false || pressed) return\n pressed = { pointerId: event.pointerId }\n }\n const scale = Number(\n getComputedStyle(node).getPropertyValue('--rad-button-press-scale').trim() || '.97'\n )\n spring.to(Number.isFinite(scale) && scale >= 0.5 && scale <= 1 ? scale : 0.97)\n },\n release,\n destroy() {\n observer.disconnect()\n query.removeEventListener('change', changed)\n document.removeEventListener('pointerup', release)\n document.removeEventListener('pointercancel', release)\n document.removeEventListener('keyup', release)\n document.defaultView!.removeEventListener('blur', blur)\n spring.destroy()\n unbind()\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"pressPolicy.d.ts","sourceRoot":"","sources":["../../../src/motion/pressPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,WAM9F;AACD,eAAO,MAAM,gBAAgB,gJACkH,CAAA;AAC/I,eAAO,MAAM,aAAa,+KACoJ,CAAA"}
1
+ {"version":3,"file":"pressPolicy.d.ts","sourceRoot":"","sources":["../../../src/motion/pressPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,WAQ9F;AACD,eAAO,MAAM,gBAAgB,gJACkH,CAAA;AAC/I,eAAO,MAAM,aAAa,+KACoJ,CAAA"}
@@ -1,7 +1,7 @@
1
1
  export function callerOwnsPress(style, className) {
2
2
  return (style?.scale !== undefined ||
3
- /(?:scale-|\[scale:|transition-all|transition-\[[^\]]*scale)/.test(className ?? '') ||
4
- /(?:scale|all)/.test(String(style?.transition ?? style?.transitionProperty ?? '')));
3
+ /(?:^|[\s:!])(?:-?scale-|\[scale:|transition-all(?:$|[\s!])|transition-\[[^\]]*(?:\bscale\b|\ball\b))/.test(className ?? '') ||
4
+ /\b(?:scale|all)\b/.test(`${style?.transition ?? ''} ${style?.transitionProperty ?? ''}`));
5
5
  }
6
6
  export const springPressClass = 'transition-[translate,border-radius,corner-shape,box-shadow,background-color,color] not-disabled:not-aria-busy:motion-safe:active:scale-100';
7
7
  export const offPressClass = 'not-disabled:not-aria-busy:motion-safe:active:scale-100 not-disabled:not-aria-busy:motion-safe:active:translate-0 not-disabled:not-aria-busy:motion-safe:hover:translate-0';
@@ -1 +1 @@
1
- {"version":3,"file":"pressPolicy.js","sourceRoot":"","sources":["../../../src/motion/pressPolicy.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,eAAe,CAAC,KAAgC,EAAE,SAA6B;IAC7F,OAAO,CACL,KAAK,EAAE,KAAK,KAAK,SAAS;QAC1B,6DAA6D,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;QACnF,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,UAAU,IAAI,KAAK,EAAE,kBAAkB,IAAI,EAAE,CAAC,CAAC,CACnF,CAAA;AACH,CAAC;AACD,MAAM,CAAC,MAAM,gBAAgB,GAC3B,6IAA6I,CAAA;AAC/I,MAAM,CAAC,MAAM,aAAa,GACxB,4KAA4K,CAAA","sourcesContent":["import type { CSSProperties } from 'react'\nexport function callerOwnsPress(style: CSSProperties | undefined, className: string | undefined) {\n return (\n style?.scale !== undefined ||\n /(?:scale-|\\[scale:|transition-all|transition-\\[[^\\]]*scale)/.test(className ?? '') ||\n /(?:scale|all)/.test(String(style?.transition ?? style?.transitionProperty ?? ''))\n )\n}\nexport const springPressClass =\n 'transition-[translate,border-radius,corner-shape,box-shadow,background-color,color] not-disabled:not-aria-busy:motion-safe:active:scale-100'\nexport const offPressClass =\n 'not-disabled:not-aria-busy:motion-safe:active:scale-100 not-disabled:not-aria-busy:motion-safe:active:translate-0 not-disabled:not-aria-busy:motion-safe:hover:translate-0'\n"]}
1
+ {"version":3,"file":"pressPolicy.js","sourceRoot":"","sources":["../../../src/motion/pressPolicy.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,eAAe,CAAC,KAAgC,EAAE,SAA6B;IAC7F,OAAO,CACL,KAAK,EAAE,KAAK,KAAK,SAAS;QAC1B,sGAAsG,CAAC,IAAI,CACzG,SAAS,IAAI,EAAE,CAChB;QACD,mBAAmB,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,UAAU,IAAI,EAAE,IAAI,KAAK,EAAE,kBAAkB,IAAI,EAAE,EAAE,CAAC,CAC1F,CAAA;AACH,CAAC;AACD,MAAM,CAAC,MAAM,gBAAgB,GAC3B,6IAA6I,CAAA;AAC/I,MAAM,CAAC,MAAM,aAAa,GACxB,4KAA4K,CAAA","sourcesContent":["import type { CSSProperties } from 'react'\nexport function callerOwnsPress(style: CSSProperties | undefined, className: string | undefined) {\n return (\n style?.scale !== undefined ||\n /(?:^|[\\s:!])(?:-?scale-|\\[scale:|transition-all(?:$|[\\s!])|transition-\\[[^\\]]*(?:\\bscale\\b|\\ball\\b))/.test(\n className ?? ''\n ) ||\n /\\b(?:scale|all)\\b/.test(`${style?.transition ?? ''} ${style?.transitionProperty ?? ''}`)\n )\n}\nexport const springPressClass =\n 'transition-[translate,border-radius,corner-shape,box-shadow,background-color,color] not-disabled:not-aria-busy:motion-safe:active:scale-100'\nexport const offPressClass =\n 'not-disabled:not-aria-busy:motion-safe:active:scale-100 not-disabled:not-aria-busy:motion-safe:active:translate-0 not-disabled:not-aria-busy:motion-safe:hover:translate-0'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../src/motion/transitions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAgEjG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAsI7F"}
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../../src/motion/transitions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAElD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CA4EjG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,iBAAiB,CAyJ7F"}
@@ -13,8 +13,21 @@ export function bindDisclosureMotion(host, initial) {
13
13
  const render = (value) => node.style.setProperty('--_rad-spring-details-height', `${Math.max(0, value)}px`);
14
14
  const off = spring.subscribe(render);
15
15
  render(spring.get());
16
+ const observed = new Set();
16
17
  function sync() {
17
- for (const child of contents()) {
18
+ const current = new Set(contents());
19
+ for (const child of observed) {
20
+ if (current.has(child))
21
+ continue;
22
+ resize.unobserve(child);
23
+ restore(child);
24
+ observed.delete(child);
25
+ }
26
+ for (const child of current) {
27
+ if (!observed.has(child)) {
28
+ observed.add(child);
29
+ resize.observe(child);
30
+ }
18
31
  if (!node.open) {
19
32
  if (!saved.has(child))
20
33
  saved.set(child, { inert: child.inert, hidden: child.getAttribute('aria-hidden') });
@@ -40,7 +53,6 @@ export function bindDisclosureMotion(host, initial) {
40
53
  const observer = new MutationObserver(sync);
41
54
  observer.observe(node, { attributes: true, attributeFilter: ['open'], childList: true });
42
55
  const resize = new ResizeObserver(sync);
43
- contents().forEach(child => resize.observe(child));
44
56
  function update(next) {
45
57
  profile = next;
46
58
  spring.configure(resolveMotion(profile, 'disclosure', query.matches));
@@ -54,6 +66,7 @@ export function bindDisclosureMotion(host, initial) {
54
66
  destroy() {
55
67
  observer.disconnect();
56
68
  resize.disconnect();
69
+ observed.clear();
57
70
  query.removeEventListener('change', preference);
58
71
  off();
59
72
  spring.destroy();
@@ -71,23 +84,29 @@ export function bindDialogMotion(host, initial) {
71
84
  let profile = initial;
72
85
  const query = node.ownerDocument.defaultView.matchMedia('(prefers-reduced-motion: reduce)');
73
86
  let open = node.open;
74
- const geometry = () => ({
75
- left: node.offsetLeft,
76
- top: node.offsetTop,
77
- width: node.offsetWidth,
78
- height: node.offsetHeight,
79
- variables: Array.from(getComputedStyle(node))
80
- .filter(key => key.startsWith('--'))
81
- .map(key => [key, getComputedStyle(node).getPropertyValue(key)])
82
- });
87
+ const geometry = () => {
88
+ const style = getComputedStyle(node);
89
+ return {
90
+ left: node.offsetLeft,
91
+ top: node.offsetTop,
92
+ width: node.offsetWidth,
93
+ height: node.offsetHeight,
94
+ variables: Array.from(style)
95
+ .filter(key => key.startsWith('--'))
96
+ .map(key => [key, style.getPropertyValue(key)])
97
+ };
98
+ };
83
99
  let bounds = node.open ? geometry() : null;
84
100
  let ghost = null;
101
+ let exitTimer;
85
102
  const spring = createSpring(open ? 1 : 0.94, {
86
103
  ...resolveMotion(profile, 'dialog', query.matches),
87
104
  reducedValue: open ? 1 : 0.94
88
105
  });
89
106
  const unbind = bindSpringStyle(node, spring, 'scale');
90
107
  function clear() {
108
+ node.ownerDocument.defaultView.clearTimeout(exitTimer);
109
+ exitTimer = undefined;
91
110
  ghost?.remove();
92
111
  ghost = null;
93
112
  }
@@ -95,9 +114,14 @@ export function bindDialogMotion(host, initial) {
95
114
  clear();
96
115
  if (!bounds || bounds.width === 0)
97
116
  return;
98
- if (node.parentElement?.closest('dialog[open]') ||
99
- Array.from(node.querySelectorAll('*')).some(child => child.localName.includes('-') ||
100
- /^(script|style|link|iframe|object|embed|canvas|video|audio)$/.test(child.localName)))
117
+ const descendants = node.querySelectorAll('*');
118
+ // A visual copy is optional: bound its work and avoid activating nested platform lifecycles.
119
+ if (descendants.length > 500 ||
120
+ node.hasAttribute('is') ||
121
+ node.parentElement?.closest('dialog[open]') ||
122
+ Array.from(descendants).some(child => child.localName.includes('-') ||
123
+ child.hasAttribute('is') ||
124
+ /^(dialog|script|style|link|iframe|object|embed|canvas|video|audio)$/.test(child.localName)))
101
125
  return;
102
126
  const copy = node.cloneNode(true);
103
127
  ghost = node.ownerDocument.createElement('div');
@@ -141,6 +165,12 @@ export function bindDialogMotion(host, initial) {
141
165
  transition: 'none'
142
166
  });
143
167
  node.ownerDocument.body.append(ghost);
168
+ // Theme physics can be arbitrarily slow. Never retain an invisible copy or engine work indefinitely.
169
+ exitTimer = node.ownerDocument.defaultView.setTimeout(() => {
170
+ clear();
171
+ if (!node.open)
172
+ spring.jump(0.94);
173
+ }, 2000);
144
174
  }
145
175
  const off = spring.subscribe(value => {
146
176
  if (ghost) {
@@ -165,7 +195,10 @@ export function bindDialogMotion(host, initial) {
165
195
  if (enabled)
166
196
  snapshot();
167
197
  spring.configure({ reducedValue: 0.94 });
168
- spring.to(0.94);
198
+ if (ghost)
199
+ spring.to(0.94);
200
+ else
201
+ spring.jump(0.94);
169
202
  if (!enabled)
170
203
  clear();
171
204
  }
@@ -1 +1 @@
1
- {"version":3,"file":"transitions.js","sourceRoot":"","sources":["../../../src/motion/transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAA;AAG/D,MAAM,UAAU,oBAAoB,CAAC,IAAiB,EAAE,OAAsB;IAC5E,MAAM,IAAI,GAAG,IAA0B,CAAA;IACvC,IAAI,OAAO,GAAG,OAAO,CAAA;IACrB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAY,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;IAC5F,MAAM,QAAQ,GAAG,GAAG,EAAE,CACpB,KAAK,CAAC,IAAI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C,cAAc,EAAE,YAAY,CAAC,CAAA;YACtD,KAAK,EAAE,CAAA;QACT,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createSpring } from './runtime.js'\nimport { bindSpringStyle } from './browser.js'\nimport { resolveMotion, type MotionProfile } from './config.js'\nimport type { MotionHostBinding } from './host.js'\n\nexport function bindDisclosureMotion(host: HTMLElement, initial: MotionProfile): MotionHostBinding {\n const node = host as HTMLDetailsElement\n let profile = initial\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n const contents = () =>\n Array.from(node.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && child.tagName !== 'SUMMARY'\n )\n const measure = () =>\n contents().reduce((sum, child) => sum + child.getBoundingClientRect().height, 0)\n const previous = node.style.getPropertyValue('--_rad-spring-details-height')\n const spring = createSpring(\n node.open ? measure() : 0,\n resolveMotion(profile, 'disclosure', query.matches)\n )\n const saved = new Map<HTMLElement, { inert: boolean; hidden: string | null }>()\n const render = (value: number) =>\n node.style.setProperty('--_rad-spring-details-height', `${Math.max(0, value)}px`)\n const off = spring.subscribe(render)\n render(spring.get())\n function sync() {\n for (const child of contents()) {\n if (!node.open) {\n if (!saved.has(child))\n saved.set(child, { inert: child.inert, hidden: child.getAttribute('aria-hidden') })\n child.inert = true\n child.setAttribute('aria-hidden', 'true')\n } else restore(child)\n }\n spring.to(node.open ? measure() : 0)\n }\n function restore(child: HTMLElement) {\n const prior = saved.get(child)\n if (!prior) return\n child.inert = prior.inert\n if (prior.hidden === null) child.removeAttribute('aria-hidden')\n else child.setAttribute('aria-hidden', prior.hidden)\n saved.delete(child)\n }\n const observer = new MutationObserver(sync)\n observer.observe(node, { attributes: true, attributeFilter: ['open'], childList: true })\n const resize = new ResizeObserver(sync)\n contents().forEach(child => resize.observe(child))\n function update(next: MotionProfile) {\n profile = next\n spring.configure(resolveMotion(profile, 'disclosure', query.matches))\n sync()\n }\n const preference = () => update(profile)\n query.addEventListener('change', preference)\n sync()\n return {\n update,\n destroy() {\n observer.disconnect()\n resize.disconnect()\n query.removeEventListener('change', preference)\n off()\n spring.destroy()\n for (const child of saved.keys()) restore(child)\n if (previous) node.style.setProperty('--_rad-spring-details-height', previous)\n else node.style.removeProperty('--_rad-spring-details-height')\n }\n }\n}\n\nexport function bindDialogMotion(host: HTMLElement, initial: MotionProfile): MotionHostBinding {\n const node = host as HTMLDialogElement\n let profile = initial\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n let open = node.open\n const geometry = () => ({\n left: node.offsetLeft,\n top: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n variables: Array.from(getComputedStyle(node))\n .filter(key => key.startsWith('--'))\n .map(key => [key, getComputedStyle(node).getPropertyValue(key)])\n })\n let bounds = node.open ? geometry() : null\n let ghost: HTMLDivElement | null = null\n const spring = createSpring(open ? 1 : 0.94, {\n ...resolveMotion(profile, 'dialog', query.matches),\n reducedValue: open ? 1 : 0.94\n })\n const unbind = bindSpringStyle(node, spring, 'scale')\n function clear() {\n ghost?.remove()\n ghost = null\n }\n function snapshot() {\n clear()\n if (!bounds || bounds.width === 0) return\n if (\n node.parentElement?.closest('dialog[open]') ||\n Array.from(node.querySelectorAll('*')).some(\n child =>\n child.localName.includes('-') ||\n /^(script|style|link|iframe|object|embed|canvas|video|audio)$/.test(child.localName)\n )\n )\n return\n const copy = node.cloneNode(true) as HTMLDialogElement\n ghost = node.ownerDocument.createElement('div')\n for (const attribute of copy.attributes) ghost.setAttribute(attribute.name, attribute.value)\n while (copy.firstChild) ghost.append(copy.firstChild)\n ghost.setAttribute('open', '')\n ghost.removeAttribute('data-slot')\n ghost.setAttribute('role', 'presentation')\n ghost.setAttribute('data-state', 'open')\n ghost.inert = true\n ghost.setAttribute('aria-hidden', 'true')\n ghost.setAttribute('data-rad-motion-exit', '')\n for (const child of [ghost, ...ghost.querySelectorAll('*')]) {\n for (const attribute of Array.from(child.attributes))\n if (attribute.name.toLowerCase().startsWith('on')) child.removeAttribute(attribute.name)\n for (const attribute of ['id', 'name', 'form', 'autofocus']) child.removeAttribute(attribute)\n if (\n child instanceof HTMLInputElement ||\n child instanceof HTMLButtonElement ||\n child instanceof HTMLSelectElement ||\n child instanceof HTMLTextAreaElement\n )\n child.disabled = true\n }\n for (const [key, value] of bounds.variables) ghost.style.setProperty(key, value)\n ghost.style.font = getComputedStyle(node).font\n ghost.style.colorScheme = getComputedStyle(node).colorScheme\n Object.assign(ghost.style, {\n position: 'fixed',\n margin: '0px',\n left: `${bounds.left}px`,\n top: `${bounds.top}px`,\n width: `${bounds.width}px`,\n height: `${bounds.height}px`,\n maxHeight: 'none',\n pointerEvents: 'none',\n zIndex: '2147483647',\n transition: 'none'\n })\n node.ownerDocument.body.append(ghost)\n }\n const off = spring.subscribe(value => {\n if (ghost) {\n ghost.style.scale = String(Math.max(0, value))\n ghost.style.opacity = String(Math.max(0, Math.min(1, (value - 0.94) / 0.06)))\n if (!node.open && Math.abs(value - 0.94) < 0.0001) clear()\n }\n })\n function sync() {\n if (node.open === open) return\n open = node.open\n const enabled = resolveMotion(profile, 'dialog', query.matches).enabled\n if (open) {\n clear()\n bounds = geometry()\n spring.configure({ reducedValue: 1 })\n spring.to(1)\n } else {\n if (enabled) snapshot()\n spring.configure({ reducedValue: 0.94 })\n spring.to(0.94)\n if (!enabled) clear()\n }\n }\n const beforeToggle = () => {\n if (node.open) bounds = geometry()\n }\n node.addEventListener('beforetoggle', beforeToggle)\n const observer = new MutationObserver(sync)\n observer.observe(node, { attributes: true, attributeFilter: ['open'] })\n const resize = new ResizeObserver(() => {\n if (node.open) bounds = geometry()\n })\n resize.observe(node)\n function update(next: MotionProfile) {\n profile = next\n spring.configure({\n ...resolveMotion(profile, 'dialog', query.matches),\n reducedValue: node.open ? 1 : 0.94\n })\n if (!resolveMotion(profile, 'dialog', query.matches).enabled) clear()\n sync()\n }\n const preference = () => update(profile)\n query.addEventListener('change', preference)\n return {\n update,\n destroy() {\n observer.disconnect()\n resize.disconnect()\n query.removeEventListener('change', preference)\n off()\n spring.destroy()\n unbind()\n node.removeEventListener('beforetoggle', beforeToggle)\n clear()\n }\n }\n}\n"]}
1
+ {"version":3,"file":"transitions.js","sourceRoot":"","sources":["../../../src/motion/transitions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAsB,MAAM,aAAa,CAAA;AAG/D,MAAM,UAAU,oBAAoB,CAAC,IAAiB,EAAE,OAAsB;IAC5E,MAAM,IAAI,GAAG,IAA0B,CAAA;IACvC,IAAI,OAAO,GAAG,OAAO,CAAA;IACrB,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,WAAY,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAA;IAC5F,MAAM,QAAQ,GAAG,GAAG,EAAE,CACpB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAC9B,CAAC,KAAK,EAAwB,EAAE,CAAC,KAAK,YAAY,WAAW,IAAI,KAAK,CAAC,OAAO,KAAK,SAAS,CAC7F,CAAA;IACH,MAAM,OAAO,GAAG,GAAG,EAAE,CACnB,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,qBAAqB,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAClF,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,CAAA;IAC5E,MAAM,MAAM,GAAG,YAAY,CACzB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,EACzB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CACpD,CAAA;IACD,MAAM,K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C,OAAO;YAAE,KAAK,EAAE,CAAA;QACrE,IAAI,EAAE,CAAA;IACR,CAAC;IACD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACxC,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IAC5C,OAAO;QACL,MAAM;QACN,OAAO;YACL,QAAQ,CAAC,UAAU,EAAE,CAAA;YACrB,MAAM,CAAC,UAAU,EAAE,CAAA;YACnB,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;YAC/C,GAAG,EAAE,CAAA;YACL,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,MAAM,EAAE,CAAA;YACR,IAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,YAAY,CAAC,CAAA;YACtD,KAAK,EAAE,CAAA;QACT,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createSpring } from './runtime.js'\nimport { bindSpringStyle } from './browser.js'\nimport { resolveMotion, type MotionProfile } from './config.js'\nimport type { MotionHostBinding } from './host.js'\n\nexport function bindDisclosureMotion(host: HTMLElement, initial: MotionProfile): MotionHostBinding {\n const node = host as HTMLDetailsElement\n let profile = initial\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n const contents = () =>\n Array.from(node.children).filter(\n (child): child is HTMLElement => child instanceof HTMLElement && child.tagName !== 'SUMMARY'\n )\n const measure = () =>\n contents().reduce((sum, child) => sum + child.getBoundingClientRect().height, 0)\n const previous = node.style.getPropertyValue('--_rad-spring-details-height')\n const spring = createSpring(\n node.open ? measure() : 0,\n resolveMotion(profile, 'disclosure', query.matches)\n )\n const saved = new Map<HTMLElement, { inert: boolean; hidden: string | null }>()\n const render = (value: number) =>\n node.style.setProperty('--_rad-spring-details-height', `${Math.max(0, value)}px`)\n const off = spring.subscribe(render)\n render(spring.get())\n const observed = new Set<HTMLElement>()\n function sync() {\n const current = new Set(contents())\n for (const child of observed) {\n if (current.has(child)) continue\n resize.unobserve(child)\n restore(child)\n observed.delete(child)\n }\n for (const child of current) {\n if (!observed.has(child)) {\n observed.add(child)\n resize.observe(child)\n }\n if (!node.open) {\n if (!saved.has(child))\n saved.set(child, { inert: child.inert, hidden: child.getAttribute('aria-hidden') })\n child.inert = true\n child.setAttribute('aria-hidden', 'true')\n } else restore(child)\n }\n spring.to(node.open ? measure() : 0)\n }\n function restore(child: HTMLElement) {\n const prior = saved.get(child)\n if (!prior) return\n child.inert = prior.inert\n if (prior.hidden === null) child.removeAttribute('aria-hidden')\n else child.setAttribute('aria-hidden', prior.hidden)\n saved.delete(child)\n }\n const observer = new MutationObserver(sync)\n observer.observe(node, { attributes: true, attributeFilter: ['open'], childList: true })\n const resize = new ResizeObserver(sync)\n function update(next: MotionProfile) {\n profile = next\n spring.configure(resolveMotion(profile, 'disclosure', query.matches))\n sync()\n }\n const preference = () => update(profile)\n query.addEventListener('change', preference)\n sync()\n return {\n update,\n destroy() {\n observer.disconnect()\n resize.disconnect()\n observed.clear()\n query.removeEventListener('change', preference)\n off()\n spring.destroy()\n for (const child of saved.keys()) restore(child)\n if (previous) node.style.setProperty('--_rad-spring-details-height', previous)\n else node.style.removeProperty('--_rad-spring-details-height')\n }\n }\n}\n\nexport function bindDialogMotion(host: HTMLElement, initial: MotionProfile): MotionHostBinding {\n const node = host as HTMLDialogElement\n let profile = initial\n const query = node.ownerDocument.defaultView!.matchMedia('(prefers-reduced-motion: reduce)')\n let open = node.open\n const geometry = () => {\n const style = getComputedStyle(node)\n return {\n left: node.offsetLeft,\n top: node.offsetTop,\n width: node.offsetWidth,\n height: node.offsetHeight,\n variables: Array.from(style)\n .filter(key => key.startsWith('--'))\n .map(key => [key, style.getPropertyValue(key)])\n }\n }\n let bounds = node.open ? geometry() : null\n let ghost: HTMLDivElement | null = null\n let exitTimer: number | undefined\n const spring = createSpring(open ? 1 : 0.94, {\n ...resolveMotion(profile, 'dialog', query.matches),\n reducedValue: open ? 1 : 0.94\n })\n const unbind = bindSpringStyle(node, spring, 'scale')\n function clear() {\n node.ownerDocument.defaultView!.clearTimeout(exitTimer)\n exitTimer = undefined\n ghost?.remove()\n ghost = null\n }\n function snapshot() {\n clear()\n if (!bounds || bounds.width === 0) return\n const descendants = node.querySelectorAll('*')\n // A visual copy is optional: bound its work and avoid activating nested platform lifecycles.\n if (\n descendants.length > 500 ||\n node.hasAttribute('is') ||\n node.parentElement?.closest('dialog[open]') ||\n Array.from(descendants).some(\n child =>\n child.localName.includes('-') ||\n child.hasAttribute('is') ||\n /^(dialog|script|style|link|iframe|object|embed|canvas|video|audio)$/.test(\n child.localName\n )\n )\n )\n return\n const copy = node.cloneNode(true) as HTMLDialogElement\n ghost = node.ownerDocument.createElement('div')\n for (const attribute of copy.attributes) ghost.setAttribute(attribute.name, attribute.value)\n while (copy.firstChild) ghost.append(copy.firstChild)\n ghost.setAttribute('open', '')\n ghost.removeAttribute('data-slot')\n ghost.setAttribute('role', 'presentation')\n ghost.setAttribute('data-state', 'open')\n ghost.inert = true\n ghost.setAttribute('aria-hidden', 'true')\n ghost.setAttribute('data-rad-motion-exit', '')\n for (const child of [ghost, ...ghost.querySelectorAll('*')]) {\n for (const attribute of Array.from(child.attributes))\n if (attribute.name.toLowerCase().startsWith('on')) child.removeAttribute(attribute.name)\n for (const attribute of ['id', 'name', 'form', 'autofocus']) child.removeAttribute(attribute)\n if (\n child instanceof HTMLInputElement ||\n child instanceof HTMLButtonElement ||\n child instanceof HTMLSelectElement ||\n child instanceof HTMLTextAreaElement\n )\n child.disabled = true\n }\n for (const [key, value] of bounds.variables) ghost.style.setProperty(key, value)\n ghost.style.font = getComputedStyle(node).font\n ghost.style.colorScheme = getComputedStyle(node).colorScheme\n Object.assign(ghost.style, {\n position: 'fixed',\n margin: '0px',\n left: `${bounds.left}px`,\n top: `${bounds.top}px`,\n width: `${bounds.width}px`,\n height: `${bounds.height}px`,\n maxHeight: 'none',\n pointerEvents: 'none',\n zIndex: '2147483647',\n transition: 'none'\n })\n node.ownerDocument.body.append(ghost)\n // Theme physics can be arbitrarily slow. Never retain an invisible copy or engine work indefinitely.\n exitTimer = node.ownerDocument.defaultView!.setTimeout(() => {\n clear()\n if (!node.open) spring.jump(0.94)\n }, 2000)\n }\n const off = spring.subscribe(value => {\n if (ghost) {\n ghost.style.scale = String(Math.max(0, value))\n ghost.style.opacity = String(Math.max(0, Math.min(1, (value - 0.94) / 0.06)))\n if (!node.open && Math.abs(value - 0.94) < 0.0001) clear()\n }\n })\n function sync() {\n if (node.open === open) return\n open = node.open\n const enabled = resolveMotion(profile, 'dialog', query.matches).enabled\n if (open) {\n clear()\n bounds = geometry()\n spring.configure({ reducedValue: 1 })\n spring.to(1)\n } else {\n if (enabled) snapshot()\n spring.configure({ reducedValue: 0.94 })\n if (ghost) spring.to(0.94)\n else spring.jump(0.94)\n if (!enabled) clear()\n }\n }\n const beforeToggle = () => {\n if (node.open) bounds = geometry()\n }\n node.addEventListener('beforetoggle', beforeToggle)\n const observer = new MutationObserver(sync)\n observer.observe(node, { attributes: true, attributeFilter: ['open'] })\n const resize = new ResizeObserver(() => {\n if (node.open) bounds = geometry()\n })\n resize.observe(node)\n function update(next: MotionProfile) {\n profile = next\n spring.configure({\n ...resolveMotion(profile, 'dialog', query.matches),\n reducedValue: node.open ? 1 : 0.94\n })\n if (!resolveMotion(profile, 'dialog', query.matches).enabled) clear()\n sync()\n }\n const preference = () => update(profile)\n query.addEventListener('change', preference)\n return {\n update,\n destroy() {\n observer.disconnect()\n resize.disconnect()\n query.removeEventListener('change', preference)\n off()\n spring.destroy()\n unbind()\n node.removeEventListener('beforetoggle', beforeToggle)\n clear()\n }\n }\n}\n"]}