@cognitap/radiant 0.0.4 → 0.0.6

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 (175) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +17 -0
  3. package/dist/library/Button.d.ts +3 -1
  4. package/dist/library/Button.d.ts.map +1 -1
  5. package/dist/library/Button.js +43 -2
  6. package/dist/library/Button.js.map +1 -1
  7. package/dist/library/Card.d.ts.map +1 -1
  8. package/dist/library/Card.js +8 -6
  9. package/dist/library/Card.js.map +1 -1
  10. package/dist/library/Checkbox.js +2 -2
  11. package/dist/library/Checkbox.js.map +1 -1
  12. package/dist/library/Collapsible.d.ts +2 -1
  13. package/dist/library/Collapsible.d.ts.map +1 -1
  14. package/dist/library/Collapsible.js +10 -6
  15. package/dist/library/Collapsible.js.map +1 -1
  16. package/dist/library/Dialog.d.ts +2 -1
  17. package/dist/library/Dialog.d.ts.map +1 -1
  18. package/dist/library/Dialog.js +13 -8
  19. package/dist/library/Dialog.js.map +1 -1
  20. package/dist/library/Field.js +4 -4
  21. package/dist/library/Field.js.map +1 -1
  22. package/dist/library/Input.d.ts.map +1 -1
  23. package/dist/library/Input.js +4 -3
  24. package/dist/library/Input.js.map +1 -1
  25. package/dist/library/Link.d.ts.map +1 -1
  26. package/dist/library/Link.js +0 -1
  27. package/dist/library/Link.js.map +1 -1
  28. package/dist/library/RadioGroup.js +2 -2
  29. package/dist/library/RadioGroup.js.map +1 -1
  30. package/dist/library/ThemeScope.d.ts.map +1 -1
  31. package/dist/library/ThemeScope.js +11 -10
  32. package/dist/library/ThemeScope.js.map +1 -1
  33. package/dist/library/actionStyles.js +2 -2
  34. package/dist/library/actionStyles.js.map +1 -1
  35. package/dist/library/cn.d.ts +2 -1
  36. package/dist/library/cn.d.ts.map +1 -1
  37. package/dist/library/cn.js +22 -1
  38. package/dist/library/cn.js.map +1 -1
  39. package/dist/library/index.d.ts +5 -1
  40. package/dist/library/index.d.ts.map +1 -1
  41. package/dist/library/index.js +2 -0
  42. package/dist/library/index.js.map +1 -1
  43. package/dist/library/motion/MotionLink.d.ts +7 -0
  44. package/dist/library/motion/MotionLink.d.ts.map +1 -0
  45. package/dist/library/motion/MotionLink.js +45 -0
  46. package/dist/library/motion/MotionLink.js.map +1 -0
  47. package/dist/library/motion/browser.d.ts +5 -0
  48. package/dist/library/motion/browser.d.ts.map +1 -0
  49. package/dist/library/motion/browser.js +35 -0
  50. package/dist/library/motion/browser.js.map +1 -0
  51. package/dist/library/motion/config.d.ts +26 -0
  52. package/dist/library/motion/config.d.ts.map +1 -0
  53. package/dist/library/motion/config.js +58 -0
  54. package/dist/library/motion/config.js.map +1 -0
  55. package/dist/library/motion/context.d.ts +2 -0
  56. package/dist/library/motion/context.d.ts.map +1 -0
  57. package/dist/library/motion/context.js +5 -0
  58. package/dist/library/motion/context.js.map +1 -0
  59. package/dist/library/motion/drag.d.ts +20 -0
  60. package/dist/library/motion/drag.d.ts.map +1 -0
  61. package/dist/library/motion/drag.js +138 -0
  62. package/dist/library/motion/drag.js.map +1 -0
  63. package/dist/library/motion/dragBrowser.d.ts +4 -0
  64. package/dist/library/motion/dragBrowser.d.ts.map +1 -0
  65. package/dist/library/motion/dragBrowser.js +156 -0
  66. package/dist/library/motion/dragBrowser.js.map +1 -0
  67. package/dist/library/motion/follow.d.ts +9 -0
  68. package/dist/library/motion/follow.d.ts.map +1 -0
  69. package/dist/library/motion/follow.js +26 -0
  70. package/dist/library/motion/follow.js.map +1 -0
  71. package/dist/library/motion/host.d.ts +27 -0
  72. package/dist/library/motion/host.d.ts.map +1 -0
  73. package/dist/library/motion/host.js +62 -0
  74. package/dist/library/motion/host.js.map +1 -0
  75. package/dist/library/motion/index.d.ts +16 -0
  76. package/dist/library/motion/index.d.ts.map +1 -0
  77. package/dist/library/motion/index.js +9 -0
  78. package/dist/library/motion/index.js.map +1 -0
  79. package/dist/library/motion/layout.d.ts +20 -0
  80. package/dist/library/motion/layout.d.ts.map +1 -0
  81. package/dist/library/motion/layout.js +67 -0
  82. package/dist/library/motion/layout.js.map +1 -0
  83. package/dist/library/motion/layoutDom.d.ts +17 -0
  84. package/dist/library/motion/layoutDom.d.ts.map +1 -0
  85. package/dist/library/motion/layoutDom.js +272 -0
  86. package/dist/library/motion/layoutDom.js.map +1 -0
  87. package/dist/library/motion/press.d.ts +5 -0
  88. package/dist/library/motion/press.d.ts.map +1 -0
  89. package/dist/library/motion/press.js +72 -0
  90. package/dist/library/motion/press.js.map +1 -0
  91. package/dist/library/motion/pressPolicy.d.ts +5 -0
  92. package/dist/library/motion/pressPolicy.d.ts.map +1 -0
  93. package/dist/library/motion/pressPolicy.js +8 -0
  94. package/dist/library/motion/pressPolicy.js.map +1 -0
  95. package/dist/library/motion/react.d.ts +35 -0
  96. package/dist/library/motion/react.d.ts.map +1 -0
  97. package/dist/library/motion/react.js +224 -0
  98. package/dist/library/motion/react.js.map +1 -0
  99. package/dist/library/motion/runtime.d.ts +22 -0
  100. package/dist/library/motion/runtime.d.ts.map +1 -0
  101. package/dist/library/motion/runtime.js +117 -0
  102. package/dist/library/motion/runtime.js.map +1 -0
  103. package/dist/library/motion/transitions.d.ts +5 -0
  104. package/dist/library/motion/transitions.d.ts.map +1 -0
  105. package/dist/library/motion/transitions.js +211 -0
  106. package/dist/library/motion/transitions.js.map +1 -0
  107. package/dist/library/styles.css +1 -1
  108. package/dist/library/themes/defineTheme.d.ts +3 -0
  109. package/dist/library/themes/defineTheme.d.ts.map +1 -1
  110. package/dist/library/themes/defineTheme.js +9 -3
  111. package/dist/library/themes/defineTheme.js.map +1 -1
  112. package/dist/library/themes/index.d.ts +1 -1
  113. package/dist/library/themes/index.d.ts.map +1 -1
  114. package/dist/library/themes/index.js.map +1 -1
  115. package/dist/library/themes/themeDocument.d.ts.map +1 -1
  116. package/dist/library/themes/themeDocument.js +39 -8
  117. package/dist/library/themes/themeDocument.js.map +1 -1
  118. package/dist/library/themes/themeDocumentTypes.d.ts +16 -1
  119. package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
  120. package/dist/library/themes/themeDocumentTypes.js.map +1 -1
  121. package/dist/library/themes/tokens.d.ts +7 -0
  122. package/dist/library/themes/tokens.d.ts.map +1 -1
  123. package/dist/library/themes/tokens.js +99 -0
  124. package/dist/library/themes/tokens.js.map +1 -1
  125. package/dist/library/typography/index.d.ts +72 -0
  126. package/dist/library/typography/index.d.ts.map +1 -0
  127. package/dist/library/typography/index.js +160 -0
  128. package/dist/library/typography/index.js.map +1 -0
  129. package/dist/library/typography/types.d.ts +78 -0
  130. package/dist/library/typography/types.d.ts.map +1 -0
  131. package/dist/library/typography/types.js +2 -0
  132. package/dist/library/typography/types.js.map +1 -0
  133. package/docs/motion.md +434 -0
  134. package/docs/system.md +33 -0
  135. package/docs/theming.md +204 -0
  136. package/package.json +20 -4
  137. package/src/Button.tsx +49 -1
  138. package/src/Card.tsx +8 -6
  139. package/src/Checkbox.tsx +2 -2
  140. package/src/Collapsible.tsx +18 -5
  141. package/src/Dialog.tsx +18 -7
  142. package/src/Field.tsx +4 -4
  143. package/src/Input.tsx +4 -3
  144. package/src/Link.tsx +0 -1
  145. package/src/RadioGroup.tsx +2 -2
  146. package/src/ThemeScope.tsx +22 -18
  147. package/src/actionStyles.ts +2 -2
  148. package/src/cn.ts +25 -1
  149. package/src/index.ts +12 -0
  150. package/src/motion/MotionLink.tsx +64 -0
  151. package/src/motion/browser.ts +45 -0
  152. package/src/motion/config.ts +79 -0
  153. package/src/motion/context.ts +4 -0
  154. package/src/motion/drag.ts +151 -0
  155. package/src/motion/dragBrowser.ts +159 -0
  156. package/src/motion/follow.ts +28 -0
  157. package/src/motion/host.ts +88 -0
  158. package/src/motion/index.ts +28 -0
  159. package/src/motion/layout.ts +78 -0
  160. package/src/motion/layoutDom.ts +293 -0
  161. package/src/motion/press.ts +77 -0
  162. package/src/motion/pressPolicy.ts +12 -0
  163. package/src/motion/react.ts +272 -0
  164. package/src/motion/runtime.ts +122 -0
  165. package/src/motion/transitions.ts +206 -0
  166. package/src/styles.css +1 -0
  167. package/src/themes/baseline.css +131 -0
  168. package/src/themes/defineTheme.ts +15 -3
  169. package/src/themes/index.ts +2 -0
  170. package/src/themes/themeDocument.ts +47 -9
  171. package/src/themes/themeDocumentTypes.ts +24 -5
  172. package/src/themes/tokens.ts +137 -0
  173. package/src/typography/index.ts +199 -0
  174. package/src/typography/types.ts +92 -0
  175. package/src/typography.css +336 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"drag.js","sourceRoot":"","sources":["../../../src/motion/drag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,cAAc,CAAA;AActF,SAAS,SAAS,CAAC,KAAwB;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG;QACtF,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAA;IAClE,IAAI,KAAK,CAAC,YAAY,KAAK,SAAS;QAClC,MAAM,IAAI,SAAS,CAAC,uEAAuE,CAAC,CAAA;IAC9F,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;IACzD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACtB,CAAC,MAAM,CAAC,MAAM;QACd,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QAEvF,MAAM,IAAI,SAAS,CAAC,qDAAqD,CAAC,CAAA;IAC5E,OAAO,EAAE,GAAG,KAAK,EAAE,UAAU,EA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;gBAAE,OAAM;YACrB,QAAQ,GAAG,KAAK,CAAA;YAChB,MAAM,OAAO,GAAG,IAAI,CAAA;YACpB,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAA;YACjC,MAAM,MAAM,GACV,SAAS,KAAK,OAAO;gBACnB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;gBACX,CAAC,CAAC,SAAS,KAAK,MAAM;oBACpB,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE;oBAChB,CAAC,CAAC,SAAS,KAAK,CAAC;wBACf,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC;wBAClE,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;YACpF,EAAE,CAAC,MAAM,CAAC,CAAA;QACZ,CAAC;QACD,OAAO;YACL,SAAS,GAAG,IAAI,CAAA;YAChB,QAAQ,GAAG,KAAK,CAAA;YAChB,MAAM,CAAC,OAAO,EAAE,CAAA;QAClB,CAAC;KACF,CAAA;IACD,OAAO,UAAU,CAAA;AACnB,CAAC","sourcesContent":["import { createSpring, type SpringController, type SpringOptions } from './runtime.js'\nexport interface SpringDragOptions extends SpringOptions {\n readonly min: number\n readonly max: number\n readonly snapPoints?: readonly number[]\n}\nexport interface SpringDragController extends SpringController {\n begin(): void\n move(position: number, time: number): void\n release(time: number): { target: number; velocity: number }\n cancel(): void\n step(direction: -1 | 1 | 'first' | 'last'): void\n configure(options: Partial<SpringDragOptions>): void\n}\nfunction validated(input: SpringDragOptions) {\n if (!Number.isFinite(input.min) || !Number.isFinite(input.max) || input.min >= input.max)\n throw new TypeError('Drag bounds must be finite and min < max.')\n if (input.reducedValue !== undefined)\n throw new TypeError('Drag off snaps to its functional goal, not a decorative reducedValue.')\n const points = input.snapPoints ?? [input.min, input.max]\n if (\n !Array.isArray(points) ||\n !points.length ||\n points.some(value => !Number.isFinite(value) || value < input.min || value > input.max)\n )\n throw new TypeError('Snap points must be a nonempty array within bounds.')\n return { ...input, snapPoints: [...new Set(points)].sort((a, b) => a - b) }\n}\n/** One axis, local pixels; Motion supplies all spring physics. */\nexport function createSpringDrag(initial: number, input: SpringDragOptions): SpringDragController {\n let options = validated(input)\n const clamp = (value: number) => Math.max(options.min, Math.min(options.max, value))\n if (!Number.isFinite(initial) || initial < options.min || initial > options.max)\n throw new TypeError('Initial drag position must be within bounds.')\n const spring = createSpring(initial, options)\n let goal = initial,\n cancelGoal = initial,\n dragging = false,\n velocity = 0,\n lastTime: number | undefined,\n lastPosition = initial,\n destroyed = false\n const choose = (position: number) =>\n options.snapPoints.reduce(\n (best, point) => (Math.abs(point - position) < Math.abs(best - position) ? point : best),\n options.snapPoints[0]\n )\n const to = (target: number, speed?: number) => {\n if (!Number.isFinite(target)) throw new TypeError('Drag target must be finite.')\n if (destroyed) return\n goal = clamp(target)\n spring.to(goal, speed)\n }\n const controller: SpringDragController = {\n get: () => clamp(spring.get()),\n getVelocity: () =>\n spring.get() < options.min || spring.get() > options.max ? 0 : spring.getVelocity(),\n isAnimating: () => spring.isAnimating(),\n to,\n jump(target) {\n if (!Number.isFinite(target)) throw new TypeError('Drag target must be finite.')\n if (destroyed) return\n goal = clamp(target)\n spring.jump(goal)\n },\n stop() {\n if (destroyed) return\n spring.stop()\n goal = controller.get()\n },\n subscribe(listener) {\n return spring.subscribe(() => listener(controller.get()))\n },\n configure(next) {\n if (destroyed) return\n const resolved = validated({ ...options, ...next })\n spring.configure(resolved)\n options = resolved\n goal = clamp(goal)\n cancelGoal = clamp(cancelGoal)\n if (dragging) spring.jump(controller.get())\n else spring.to(goal)\n },\n begin() {\n if (destroyed) return\n cancelGoal = goal\n dragging = true\n lastTime = undefined\n velocity = 0\n lastPosition = controller.get()\n spring.jump(lastPosition)\n },\n move(position, time) {\n if (!Number.isFinite(position) || !Number.isFinite(time))\n throw new TypeError('Drag samples need finite pixel positions and millisecond times.')\n if (!dragging || destroyed) return\n const current = clamp(position)\n if (lastTime !== undefined) {\n const dt = time - lastTime\n velocity =\n dt > 0 && dt <= 80\n ? Math.max(-3000, Math.min(3000, ((current - lastPosition) * 1000) / dt))\n : 0\n }\n lastTime = time\n lastPosition = current\n spring.jump(current)\n },\n release(time) {\n if (!Number.isFinite(time)) throw new TypeError('Release time must be finite.')\n if (!dragging || destroyed) return { target: goal, velocity: 0 }\n dragging = false\n const speed =\n options.enabled === false ||\n lastTime === undefined ||\n time - lastTime > 80 ||\n time < lastTime\n ? 0\n : velocity\n const target = choose(clamp(controller.get() + speed * 0.18))\n to(target, speed)\n return { target, velocity: speed }\n },\n cancel() {\n if (!dragging || destroyed) return\n dragging = false\n to(cancelGoal, 0)\n },\n step(direction) {\n if (destroyed) return\n dragging = false\n const current = goal\n const points = options.snapPoints\n const target =\n direction === 'first'\n ? points[0]\n : direction === 'last'\n ? points.at(-1)!\n : direction === 1\n ? (points.find(point => point > current + 0.01) ?? points.at(-1)!)\n : ([...points].reverse().find(point => point < current - 0.01) ?? points[0])\n to(target)\n },\n destroy() {\n destroyed = true\n dragging = false\n spring.destroy()\n }\n }\n return controller\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { SpringDragController } from './drag.js';
2
+ /** Bind one dedicated handle. Document bubble handlers let React/native consumers cancel first. */
3
+ export declare function bindSpringDrag(node: HTMLElement, controller: SpringDragController, axis?: 'x' | 'y'): () => void;
4
+ //# sourceMappingURL=dragBrowser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dragBrowser.d.ts","sourceRoot":"","sources":["../../../src/motion/dragBrowser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAErD,mGAAmG;AACnG,wBAAgB,cAAc,CAC5B,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,oBAAoB,EAChC,IAAI,GAAE,GAAG,GAAG,GAAS,cAwJtB"}
@@ -0,0 +1,156 @@
1
+ import { bindSpringStyle } from './browser.js';
2
+ /** Bind one dedicated handle. Document bubble handlers let React/native consumers cancel first. */
3
+ export function bindSpringDrag(node, controller, axis = 'x') {
4
+ const document = node.ownerDocument;
5
+ const unbind = bindSpringStyle(node, controller, axis === 'x' ? 'translateX' : 'translateY');
6
+ const previousTouch = node.style.touchAction;
7
+ const ownsTouch = !previousTouch;
8
+ if (ownsTouch)
9
+ node.style.touchAction = axis === 'x' ? 'pan-y' : 'pan-x';
10
+ const ownedTouch = node.style.touchAction;
11
+ let active, start = 0, origin = 0, cross = 0, moved = false, suppress = false;
12
+ const coordinate = (event) => (axis === 'x' ? event.clientX : event.clientY);
13
+ const other = (event) => (axis === 'x' ? event.clientY : event.clientX);
14
+ const blocked = () => node.matches(':disabled') ||
15
+ node.getAttribute('aria-busy') === 'true' ||
16
+ node.getAttribute('aria-disabled') === 'true';
17
+ const target = (event) => event.target instanceof Node && node.contains(event.target);
18
+ function free() {
19
+ if (active !== undefined && node.hasPointerCapture(active))
20
+ node.releasePointerCapture(active);
21
+ active = undefined;
22
+ }
23
+ function down(event) {
24
+ if (event.defaultPrevented ||
25
+ !target(event) ||
26
+ event.button !== 0 ||
27
+ event.isPrimary === false ||
28
+ active !== undefined ||
29
+ blocked())
30
+ return;
31
+ suppress = false;
32
+ active = event.pointerId;
33
+ start = coordinate(event);
34
+ cross = other(event);
35
+ origin = controller.get();
36
+ moved = false;
37
+ controller.begin();
38
+ controller.move(origin, event.timeStamp);
39
+ }
40
+ function move(event) {
41
+ if (active !== event.pointerId)
42
+ return;
43
+ if (event.defaultPrevented || blocked()) {
44
+ cancel();
45
+ return;
46
+ }
47
+ const delta = coordinate(event) - start;
48
+ if (!moved && Math.abs(other(event) - cross) > Math.max(4, Math.abs(delta))) {
49
+ cancel();
50
+ return;
51
+ }
52
+ if (!moved && Math.abs(delta) < 3)
53
+ return;
54
+ if (!moved) {
55
+ moved = true;
56
+ try {
57
+ node.setPointerCapture(event.pointerId);
58
+ }
59
+ catch {
60
+ /* Document events still provide outside release for synthetic input. */
61
+ }
62
+ }
63
+ controller.move(origin + delta, event.timeStamp);
64
+ }
65
+ function up(event) {
66
+ if (active !== event.pointerId)
67
+ return;
68
+ if (event.defaultPrevented || blocked()) {
69
+ cancel();
70
+ return;
71
+ }
72
+ suppress = moved;
73
+ controller.release(event.timeStamp);
74
+ free();
75
+ moved = false;
76
+ }
77
+ function cancel() {
78
+ if (active === undefined)
79
+ return;
80
+ controller.cancel();
81
+ free();
82
+ suppress = moved;
83
+ }
84
+ function cancelled(event) {
85
+ if (active === event.pointerId)
86
+ cancel();
87
+ }
88
+ function key(event) {
89
+ if (!target(event) || event.defaultPrevented || blocked())
90
+ return;
91
+ const backward = axis === 'x' ? 'ArrowLeft' : 'ArrowUp', forward = axis === 'x' ? 'ArrowRight' : 'ArrowDown';
92
+ if (event.key === 'Escape') {
93
+ if (active !== undefined) {
94
+ event.preventDefault();
95
+ cancel();
96
+ }
97
+ return;
98
+ }
99
+ if ([backward, forward, 'Home', 'End'].includes(event.key)) {
100
+ event.preventDefault();
101
+ if (active !== undefined)
102
+ cancel();
103
+ controller.step(event.key === 'Home'
104
+ ? 'first'
105
+ : event.key === 'End'
106
+ ? 'last'
107
+ : event.key === forward
108
+ ? 1
109
+ : -1);
110
+ }
111
+ }
112
+ function click(event) {
113
+ if (suppress) {
114
+ suppress = false;
115
+ event.preventDefault();
116
+ event.stopPropagation();
117
+ }
118
+ }
119
+ document.addEventListener('pointerdown', down);
120
+ document.addEventListener('pointermove', move);
121
+ document.addEventListener('pointerup', up);
122
+ document.addEventListener('pointercancel', cancelled);
123
+ document.addEventListener('keydown', key);
124
+ node.addEventListener('lostpointercapture', cancelled);
125
+ node.addEventListener('click', click, true);
126
+ document.defaultView.addEventListener('blur', cancel);
127
+ node.addEventListener('blur', cancel);
128
+ const observer = new MutationObserver(() => {
129
+ if (blocked())
130
+ cancel();
131
+ });
132
+ observer.observe(node, {
133
+ attributes: true,
134
+ attributeFilter: ['disabled', 'aria-busy', 'aria-disabled']
135
+ });
136
+ for (let parent = node.parentElement; parent; parent = parent.parentElement)
137
+ if (parent.tagName === 'FIELDSET')
138
+ observer.observe(parent, { attributes: true, attributeFilter: ['disabled'] });
139
+ return () => {
140
+ cancel();
141
+ unbind();
142
+ if (ownsTouch && node.style.touchAction === ownedTouch)
143
+ node.style.touchAction = previousTouch;
144
+ document.removeEventListener('pointerdown', down);
145
+ document.removeEventListener('pointermove', move);
146
+ document.removeEventListener('pointerup', up);
147
+ document.removeEventListener('pointercancel', cancelled);
148
+ document.removeEventListener('keydown', key);
149
+ node.removeEventListener('lostpointercapture', cancelled);
150
+ node.removeEventListener('click', click, true);
151
+ document.defaultView.removeEventListener('blur', cancel);
152
+ node.removeEventListener('blur', cancel);
153
+ observer.disconnect();
154
+ };
155
+ }
156
+ //# sourceMappingURL=dragBrowser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dragBrowser.js","sourceRoot":"","sources":["../../../src/motion/dragBrowser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,mGAAmG;AACnG,MAAM,UAAU,cAAc,CAC5B,IAAiB,EACjB,UAAgC,EAChC,OAAkB,GAAG;IAErB,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAA;IACnC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAA;IAC5F,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA;IAC5C,MAAM,SAAS,GAAG,CAAC,a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AI,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAA;QACzD,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QAC9C,QAAQ,CAAC,WAAY,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACzD,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACxC,QAAQ,CAAC,UAAU,EAAE,CAAA;IACvB,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { SpringDragController } from './drag.js'\nimport { bindSpringStyle } from './browser.js'\n/** Bind one dedicated handle. Document bubble handlers let React/native consumers cancel first. */\nexport function bindSpringDrag(\n node: HTMLElement,\n controller: SpringDragController,\n axis: 'x' | 'y' = 'x'\n) {\n const document = node.ownerDocument\n const unbind = bindSpringStyle(node, controller, axis === 'x' ? 'translateX' : 'translateY')\n const previousTouch = node.style.touchAction\n const ownsTouch = !previousTouch\n if (ownsTouch) node.style.touchAction = axis === 'x' ? 'pan-y' : 'pan-x'\n const ownedTouch = node.style.touchAction\n let active: number | undefined,\n start = 0,\n origin = 0,\n cross = 0,\n moved = false,\n suppress = false\n const coordinate = (event: PointerEvent) => (axis === 'x' ? event.clientX : event.clientY)\n const other = (event: PointerEvent) => (axis === 'x' ? event.clientY : event.clientX)\n const blocked = () =>\n node.matches(':disabled') ||\n node.getAttribute('aria-busy') === 'true' ||\n node.getAttribute('aria-disabled') === 'true'\n const target = (event: Event) => event.target instanceof Node && node.contains(event.target)\n function free() {\n if (active !== undefined && node.hasPointerCapture(active)) node.releasePointerCapture(active)\n active = undefined\n }\n function down(event: PointerEvent) {\n if (\n event.defaultPrevented ||\n !target(event) ||\n event.button !== 0 ||\n event.isPrimary === false ||\n active !== undefined ||\n blocked()\n )\n return\n suppress = false\n active = event.pointerId\n start = coordinate(event)\n cross = other(event)\n origin = controller.get()\n moved = false\n controller.begin()\n controller.move(origin, event.timeStamp)\n }\n function move(event: PointerEvent) {\n if (active !== event.pointerId) return\n if (event.defaultPrevented || blocked()) {\n cancel()\n return\n }\n const delta = coordinate(event) - start\n if (!moved && Math.abs(other(event) - cross) > Math.max(4, Math.abs(delta))) {\n cancel()\n return\n }\n if (!moved && Math.abs(delta) < 3) return\n if (!moved) {\n moved = true\n try {\n node.setPointerCapture(event.pointerId)\n } catch {\n /* Document events still provide outside release for synthetic input. */\n }\n }\n controller.move(origin + delta, event.timeStamp)\n }\n function up(event: PointerEvent) {\n if (active !== event.pointerId) return\n if (event.defaultPrevented || blocked()) {\n cancel()\n return\n }\n suppress = moved\n controller.release(event.timeStamp)\n free()\n moved = false\n }\n function cancel() {\n if (active === undefined) return\n controller.cancel()\n free()\n suppress = moved\n }\n function cancelled(event: PointerEvent) {\n if (active === event.pointerId) cancel()\n }\n function key(event: KeyboardEvent) {\n if (!target(event) || event.defaultPrevented || blocked()) return\n const backward = axis === 'x' ? 'ArrowLeft' : 'ArrowUp',\n forward = axis === 'x' ? 'ArrowRight' : 'ArrowDown'\n if (event.key === 'Escape') {\n if (active !== undefined) {\n event.preventDefault()\n cancel()\n }\n return\n }\n if ([backward, forward, 'Home', 'End'].includes(event.key)) {\n event.preventDefault()\n if (active !== undefined) cancel()\n controller.step(\n event.key === 'Home'\n ? 'first'\n : event.key === 'End'\n ? 'last'\n : event.key === forward\n ? 1\n : -1\n )\n }\n }\n function click(event: MouseEvent) {\n if (suppress) {\n suppress = false\n event.preventDefault()\n event.stopPropagation()\n }\n }\n document.addEventListener('pointerdown', down)\n document.addEventListener('pointermove', move)\n document.addEventListener('pointerup', up)\n document.addEventListener('pointercancel', cancelled)\n document.addEventListener('keydown', key)\n node.addEventListener('lostpointercapture', cancelled)\n node.addEventListener('click', click, true)\n document.defaultView!.addEventListener('blur', cancel)\n node.addEventListener('blur', cancel)\n const observer = new MutationObserver(() => {\n if (blocked()) cancel()\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 return () => {\n cancel()\n unbind()\n if (ownsTouch && node.style.touchAction === ownedTouch) node.style.touchAction = previousTouch\n document.removeEventListener('pointerdown', down)\n document.removeEventListener('pointermove', move)\n document.removeEventListener('pointerup', up)\n document.removeEventListener('pointercancel', cancelled)\n document.removeEventListener('keydown', key)\n node.removeEventListener('lostpointercapture', cancelled)\n node.removeEventListener('click', click, true)\n document.defaultView!.removeEventListener('blur', cancel)\n node.removeEventListener('blur', cancel)\n observer.disconnect()\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { SpringController } from './runtime.js';
2
+ /** Synchronous numeric snapshot with notifications in the same units as the follower. */
3
+ export interface SpringSource {
4
+ get(): number;
5
+ subscribe(listener: (value: number) => void): () => void;
6
+ }
7
+ /** The source owns destinations; the existing spring owns position, momentum and physics. */
8
+ export declare function bindSpringSource(spring: SpringController, source: SpringSource): () => void;
9
+ //# sourceMappingURL=follow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow.d.ts","sourceRoot":"","sources":["../../../src/motion/follow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEpD,yFAAyF;AACzF,MAAM,WAAW,YAAY;IAC3B,GAAG,IAAI,MAAM,CAAA;IACb,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;CACzD;AACD,6FAA6F;AAC7F,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,GAAG,MAAM,IAAI,CAmB3F"}
@@ -0,0 +1,26 @@
1
+ /** The source owns destinations; the existing spring owns position, momentum and physics. */
2
+ export function bindSpringSource(spring, source) {
3
+ if (source === spring)
4
+ throw new TypeError('A spring cannot follow itself.');
5
+ let active = true;
6
+ const off = source.subscribe(value => {
7
+ if (active)
8
+ spring.to(value);
9
+ });
10
+ try {
11
+ // Read after subscribing so a synchronous subscription cannot leave a stale goal.
12
+ spring.to(source.get());
13
+ }
14
+ catch (error) {
15
+ active = false;
16
+ off();
17
+ throw error;
18
+ }
19
+ return () => {
20
+ if (!active)
21
+ return;
22
+ active = false;
23
+ off();
24
+ };
25
+ }
26
+ //# sourceMappingURL=follow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"follow.js","sourceRoot":"","sources":["../../../src/motion/follow.ts"],"names":[],"mappings":"AAOA,6FAA6F;AAC7F,MAAM,UAAU,gBAAgB,CAAC,MAAwB,EAAE,MAAoB;IAC7E,IAAI,MAAM,KAAK,MAAM;QAAE,MAAM,IAAI,SAAS,CAAC,gCAAgC,CAAC,CAAA;IAC5E,IAAI,MAAM,GAAG,IAAI,CAAA;IACjB,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACnC,IAAI,MAAM;YAAE,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC,CAAC,CAAA;IACF,IAAI,CAAC;QACH,kFAAkF;QAClF,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAA;IACzB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,GAAG,KAAK,CAAA;QACd,GAAG,EAAE,CAAA;QACL,MAAM,KAAK,CAAA;IACb,CAAC;IACD,OAAO,GAAG,EAAE;QACV,IAAI,CAAC,MAAM;YAAE,OAAM;QACnB,MAAM,GAAG,KAAK,CAAA;QACd,GAAG,EAAE,CAAA;IACP,CAAC,CAAA;AACH,CAAC","sourcesContent":["import type { SpringController } from './runtime.js'\n\n/** Synchronous numeric snapshot with notifications in the same units as the follower. */\nexport interface SpringSource {\n get(): number\n subscribe(listener: (value: number) => void): () => void\n}\n/** The source owns destinations; the existing spring owns position, momentum and physics. */\nexport function bindSpringSource(spring: SpringController, source: SpringSource): () => void {\n if (source === spring) throw new TypeError('A spring cannot follow itself.')\n let active = true\n const off = source.subscribe(value => {\n if (active) spring.to(value)\n })\n try {\n // Read after subscribing so a synchronous subscription cannot leave a stale goal.\n spring.to(source.get())\n } catch (error) {\n active = false\n off()\n throw error\n }\n return () => {\n if (!active) return\n active = false\n off()\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ import { type Ref } from 'react';
2
+ import type { MotionProfile } from './config.js';
3
+ export interface MotionHostBinding {
4
+ update(profile: MotionProfile): void;
5
+ press?(event: PointerEvent | KeyboardEvent): void;
6
+ release?(): void;
7
+ destroy(): void;
8
+ }
9
+ export interface MotionHostRuntime {
10
+ press(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
11
+ disclosure?(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
12
+ dialog?(node: HTMLElement, profile: MotionProfile): MotionHostBinding;
13
+ }
14
+ export declare const MotionHostContext: import("react").Context<MotionHostRuntime | null>;
15
+ /** Engine-free bridge: only the opt-in provider supplies implementation. */
16
+ export declare function usePressHost<Node extends HTMLElement>(ref: Ref<Node> | undefined, disabled: boolean): {
17
+ ref: import("react").RefCallback<Node>;
18
+ active: boolean;
19
+ press(event: PointerEvent | KeyboardEvent): void;
20
+ release(): void;
21
+ };
22
+ /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
23
+ export declare function useTransitionHost<Node extends HTMLElement>(kind: 'disclosure' | 'dialog', ref: Ref<Node> | undefined, disabled: boolean): {
24
+ ref: import("react").RefCallback<Node>;
25
+ active: boolean;
26
+ };
27
+ //# sourceMappingURL=host.d.ts.map
@@ -0,0 +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,SAAS,EAC1B,QAAQ,EAAE,OAAO;;;EA0BlB"}
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+ import { createContext, useContext, useEffect, useRef } from 'react';
3
+ import { MotionProfileContext } from './context.js';
4
+ import { useComposedRefs } from '../react/useComposedRefs.js';
5
+ export const MotionHostContext = createContext(null);
6
+ /** Engine-free bridge: only the opt-in provider supplies implementation. */
7
+ export function usePressHost(ref, disabled) {
8
+ const runtime = useContext(MotionHostContext);
9
+ const profile = useContext(MotionProfileContext);
10
+ const node = useRef(null);
11
+ const binding = useRef(null);
12
+ const composed = useComposedRefs(node, ref);
13
+ useEffect(() => {
14
+ if (disabled || !runtime || !node.current || binding.current?.node !== node.current) {
15
+ binding.current?.value.destroy();
16
+ binding.current = null;
17
+ }
18
+ if (!disabled && runtime && node.current) {
19
+ binding.current ??= { node: node.current, value: runtime.press(node.current, profile) };
20
+ binding.current.value.update(profile);
21
+ }
22
+ });
23
+ useEffect(() => () => {
24
+ binding.current?.value.destroy();
25
+ binding.current = null;
26
+ }, []);
27
+ return {
28
+ ref: composed,
29
+ active: runtime !== null && !disabled,
30
+ press(event) {
31
+ binding.current?.value.press?.(event);
32
+ },
33
+ release() {
34
+ binding.current?.value.release?.();
35
+ }
36
+ };
37
+ }
38
+ /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
39
+ export function useTransitionHost(kind, ref, disabled) {
40
+ const runtime = useContext(MotionHostContext);
41
+ const profile = useContext(MotionProfileContext);
42
+ const node = useRef(null);
43
+ const binding = useRef(null);
44
+ const composed = useComposedRefs(node, ref);
45
+ useEffect(() => {
46
+ const attach = runtime?.[kind];
47
+ if (disabled || !attach || !node.current || binding.current?.node !== node.current) {
48
+ binding.current?.value.destroy();
49
+ binding.current = null;
50
+ }
51
+ if (!disabled && attach && node.current) {
52
+ binding.current ??= { node: node.current, value: attach(node.current, profile) };
53
+ binding.current.value.update(profile);
54
+ }
55
+ });
56
+ useEffect(() => () => {
57
+ binding.current?.value.destroy();
58
+ binding.current = null;
59
+ }, []);
60
+ return { ref: composed, active: !disabled && runtime?.[kind] !== undefined };
61
+ }
62
+ //# sourceMappingURL=host.js.map
@@ -0,0 +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;AAE9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MA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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"]}
@@ -0,0 +1,16 @@
1
+ export { defineMotionProfile, defaultMotionProfile, motionInteractions, resolveMotion, resolveSpringParameters } from './config.js';
2
+ export type { MotionProfile, MotionProfileInput, MotionInteraction, SpringParameters } from './config.js';
3
+ export { createSpring } from './runtime.js';
4
+ export type { SpringController, SpringOptions } from './runtime.js';
5
+ export { bindSpringStyle } from './browser.js';
6
+ export type { SpringStyleProperty } from './browser.js';
7
+ export { createLayoutSpring } from './layout.js';
8
+ export type { LayoutBounds } from './layout.js';
9
+ export { createSpringDrag } from './drag.js';
10
+ export type { SpringDragOptions, SpringDragController } from './drag.js';
11
+ export { bindSpringDrag } from './dragBrowser.js';
12
+ export { bindSpringSource } from './follow.js';
13
+ export type { SpringSource } from './follow.js';
14
+ export { bindSpringLayout } from './layoutDom.js';
15
+ export type { SpringLayoutController } from './layoutDom.js';
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAA;AACpB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,9 @@
1
+ export { defineMotionProfile, defaultMotionProfile, motionInteractions, resolveMotion, resolveSpringParameters } from './config.js';
2
+ export { createSpring } from './runtime.js';
3
+ export { bindSpringStyle } from './browser.js';
4
+ export { createLayoutSpring } from './layout.js';
5
+ export { createSpringDrag } from './drag.js';
6
+ export { bindSpringDrag } from './dragBrowser.js';
7
+ export { bindSpringSource } from './follow.js';
8
+ export { bindSpringLayout } from './layoutDom.js';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACxB,MAAM,aAAa,CAAA;AAOpB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA","sourcesContent":["export {\n defineMotionProfile,\n defaultMotionProfile,\n motionInteractions,\n resolveMotion,\n resolveSpringParameters\n} from './config.js'\nexport type {\n MotionProfile,\n MotionProfileInput,\n MotionInteraction,\n SpringParameters\n} from './config.js'\nexport { createSpring } from './runtime.js'\nexport type { SpringController, SpringOptions } from './runtime.js'\nexport { bindSpringStyle } from './browser.js'\nexport type { SpringStyleProperty } from './browser.js'\nexport { createLayoutSpring } from './layout.js'\nexport type { LayoutBounds } from './layout.js'\nexport { createSpringDrag } from './drag.js'\nexport type { SpringDragOptions, SpringDragController } from './drag.js'\nexport { bindSpringDrag } from './dragBrowser.js'\n\nexport { bindSpringSource } from './follow.js'\nexport type { SpringSource } from './follow.js'\n\nexport { bindSpringLayout } from './layoutDom.js'\nexport type { SpringLayoutController } from './layoutDom.js'\n"]}
@@ -0,0 +1,20 @@
1
+ import { type SpringOptions } from './runtime.js';
2
+ export interface LayoutBounds {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ readonly width: number;
6
+ readonly height: number;
7
+ }
8
+ /** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */
9
+ export declare function createLayoutSpring(initial: LayoutBounds, options?: SpringOptions): {
10
+ get: () => LayoutBounds;
11
+ getVelocity: () => LayoutBounds;
12
+ isAnimating: () => boolean;
13
+ to(next: LayoutBounds): void;
14
+ jump(next: LayoutBounds): void;
15
+ configure(next: SpringOptions): void;
16
+ subscribe(listener: (bounds: LayoutBounds) => void): () => void;
17
+ stop(): void;
18
+ destroy(): void;
19
+ };
20
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../../src/motion/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAA;AAE/D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAaD,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,GAAE,aAAkB;eAWxE,YAAY;uBAMJ,YAAY;;aAOpB,YAAY;eAIV,YAAY;oBAIP,aAAa;wBAMT,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI;;;EAkBrD"}
@@ -0,0 +1,67 @@
1
+ import { createSpring } from './runtime.js';
2
+ const axes = ['x', 'y', 'width', 'height'];
3
+ function validate(bounds) {
4
+ for (const axis of axes) {
5
+ if (!Number.isFinite(bounds[axis]) ||
6
+ ((axis === 'width' || axis === 'height') && bounds[axis] < 0))
7
+ throw new TypeError('Layout bounds require finite local pixel coordinates and nonnegative dimensions.');
8
+ }
9
+ }
10
+ /** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */
11
+ export function createLayoutSpring(initial, options = {}) {
12
+ validate(initial);
13
+ if (options.reducedValue !== undefined)
14
+ throw new TypeError('Layout off mode snaps to measured bounds; reducedValue is scalar only.');
15
+ const values = {
16
+ x: createSpring(initial.x, options),
17
+ y: createSpring(initial.y, options),
18
+ width: createSpring(initial.width, options),
19
+ height: createSpring(initial.height, options)
20
+ };
21
+ return {
22
+ get: () => ({
23
+ x: values.x.get(),
24
+ y: values.y.get(),
25
+ width: values.width.get(),
26
+ height: values.height.get()
27
+ }),
28
+ getVelocity: () => ({
29
+ x: values.x.getVelocity(),
30
+ y: values.y.getVelocity(),
31
+ width: values.width.getVelocity(),
32
+ height: values.height.getVelocity()
33
+ }),
34
+ isAnimating: () => axes.some(axis => values[axis].isAnimating()),
35
+ to(next) {
36
+ validate(next);
37
+ axes.forEach(axis => values[axis].to(next[axis]));
38
+ },
39
+ jump(next) {
40
+ validate(next);
41
+ axes.forEach(axis => values[axis].jump(next[axis]));
42
+ },
43
+ configure(next) {
44
+ if (next.reducedValue !== undefined)
45
+ throw new TypeError('Layout off mode snaps to measured bounds.');
46
+ // Validate all options before changing any axis.
47
+ axes.forEach(axis => values[axis].configure(next));
48
+ },
49
+ subscribe(listener) {
50
+ const snapshot = () => listener({
51
+ x: values.x.get(),
52
+ y: values.y.get(),
53
+ width: values.width.get(),
54
+ height: values.height.get()
55
+ });
56
+ const off = axes.map(axis => values[axis].subscribe(snapshot));
57
+ return () => off.forEach(remove => remove());
58
+ },
59
+ stop() {
60
+ axes.forEach(axis => values[axis].stop());
61
+ },
62
+ destroy() {
63
+ axes.forEach(axis => values[axis].destroy());
64
+ }
65
+ };
66
+ }
67
+ //# sourceMappingURL=layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/motion/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAA;AAQ/D,MAAM,IAA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AAC,GAAG,EAAE;gBACjB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;gBACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE;aAC5B,CAAC,CAAA;YACJ,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAA;YAC9D,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAA;QAC9C,CAAC;QACD,IAAI;YACF,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;QAC3C,CAAC;QACD,OAAO;YACL,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;QAC9C,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import { createSpring, type SpringOptions } from './runtime.js'\n\nexport interface LayoutBounds {\n readonly x: number\n readonly y: number\n readonly width: number\n readonly height: number\n}\nconst axes = ['x', 'y', 'width', 'height'] as const\nfunction validate(bounds: LayoutBounds) {\n for (const axis of axes) {\n if (\n !Number.isFinite(bounds[axis]) ||\n ((axis === 'width' || axis === 'height') && bounds[axis] < 0)\n )\n throw new TypeError(\n 'Layout bounds require finite local pixel coordinates and nonnegative dimensions.'\n )\n }\n}\n/** Measured local-pixel foundation; measurement and host projection belong to the layout adapter. */\nexport function createLayoutSpring(initial: LayoutBounds, options: SpringOptions = {}) {\n validate(initial)\n if (options.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds; reducedValue is scalar only.')\n const values = {\n x: createSpring(initial.x, options),\n y: createSpring(initial.y, options),\n width: createSpring(initial.width, options),\n height: createSpring(initial.height, options)\n }\n return {\n get: (): LayoutBounds => ({\n x: values.x.get(),\n y: values.y.get(),\n width: values.width.get(),\n height: values.height.get()\n }),\n getVelocity: (): LayoutBounds => ({\n x: values.x.getVelocity(),\n y: values.y.getVelocity(),\n width: values.width.getVelocity(),\n height: values.height.getVelocity()\n }),\n isAnimating: () => axes.some(axis => values[axis].isAnimating()),\n to(next: LayoutBounds) {\n validate(next)\n axes.forEach(axis => values[axis].to(next[axis]))\n },\n jump(next: LayoutBounds) {\n validate(next)\n axes.forEach(axis => values[axis].jump(next[axis]))\n },\n configure(next: SpringOptions) {\n if (next.reducedValue !== undefined)\n throw new TypeError('Layout off mode snaps to measured bounds.')\n // Validate all options before changing any axis.\n axes.forEach(axis => values[axis].configure(next))\n },\n subscribe(listener: (bounds: LayoutBounds) => void) {\n const snapshot = () =>\n listener({\n x: values.x.get(),\n y: values.y.get(),\n width: values.width.get(),\n height: values.height.get()\n })\n const off = axes.map(axis => values[axis].subscribe(snapshot))\n return () => off.forEach(remove => remove())\n },\n stop() {\n axes.forEach(axis => values[axis].stop())\n },\n destroy() {\n axes.forEach(axis => values[axis].destroy())\n }\n }\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import { type LayoutBounds } from './layout.js';
2
+ import type { SpringOptions } from './runtime.js';
3
+ export interface SpringLayoutController {
4
+ /** Measure all natural-flow slots together and retarget their persistent springs. */
5
+ measure(): void;
6
+ configure(options: SpringOptions): void;
7
+ get(slot: HTMLElement): LayoutBounds | undefined;
8
+ getVelocity(slot: HTMLElement): LayoutBounds | undefined;
9
+ isAnimating(): boolean;
10
+ destroy(): void;
11
+ }
12
+ /**
13
+ * Direct-child natural-flow slots with one dedicated motion part each.
14
+ * Never clone/reparent a semantic host or scale text, borders or children.
15
+ */
16
+ export declare function bindSpringLayout(root: HTMLElement, options?: SpringOptions): SpringLayoutController;
17
+ //# sourceMappingURL=layoutDom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layoutDom.d.ts","sourceRoot":"","sources":["../../../src/motion/layoutDom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,WAAW,sBAAsB;IACrC,qFAAqF;IACrF,OAAO,IAAI,IAAI,CAAA;IACf,SAAS,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IACvC,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;IAChD,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;IACxD,WAAW,IAAI,OAAO,CAAA;IACtB,OAAO,IAAI,IAAI,CAAA;CAChB;AAiCD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,EACjB,OAAO,GAAE,aAAkB,GAC1B,sBAAsB,CAgPxB"}