@cognitap/radiant 0.0.5 → 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 (234) hide show
  1. package/CHANGELOG.md +68 -368
  2. package/README.md +41 -1006
  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 +8 -1
  9. package/dist/library/Button.d.ts.map +1 -1
  10. package/dist/library/Button.js +44 -2
  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 +6 -1
  21. package/dist/library/Collapsible.d.ts.map +1 -1
  22. package/dist/library/Collapsible.js +24 -3
  23. package/dist/library/Collapsible.js.map +1 -1
  24. package/dist/library/Dialog.d.ts +5 -1
  25. package/dist/library/Dialog.d.ts.map +1 -1
  26. package/dist/library/Dialog.js +5 -2
  27. package/dist/library/Dialog.js.map +1 -1
  28. package/dist/library/Field.d.ts +8 -0
  29. package/dist/library/Field.d.ts.map +1 -1
  30. package/dist/library/Field.js +2 -0
  31. package/dist/library/Field.js.map +1 -1
  32. package/dist/library/Input.d.ts +3 -0
  33. package/dist/library/Input.d.ts.map +1 -1
  34. package/dist/library/Input.js +1 -0
  35. package/dist/library/Input.js.map +1 -1
  36. package/dist/library/Link.d.ts +5 -0
  37. package/dist/library/Link.d.ts.map +1 -1
  38. package/dist/library/Link.js.map +1 -1
  39. package/dist/library/RadioGroup.d.ts +8 -0
  40. package/dist/library/RadioGroup.d.ts.map +1 -1
  41. package/dist/library/RadioGroup.js +4 -2
  42. package/dist/library/RadioGroup.js.map +1 -1
  43. package/dist/library/ThemeScope.d.ts.map +1 -1
  44. package/dist/library/ThemeScope.js +10 -9
  45. package/dist/library/ThemeScope.js.map +1 -1
  46. package/dist/library/examples/expressive.d.ts +4 -0
  47. package/dist/library/examples/expressive.d.ts.map +1 -0
  48. package/dist/library/{themes → examples}/expressive.js +4 -3
  49. package/dist/library/examples/expressive.js.map +1 -0
  50. package/dist/library/examples/glass.d.ts +4 -0
  51. package/dist/library/examples/glass.d.ts.map +1 -0
  52. package/dist/library/{themes → examples}/glass.js +4 -3
  53. package/dist/library/examples/glass.js.map +1 -0
  54. package/dist/library/examples/index.d.ts +13 -0
  55. package/dist/library/examples/index.d.ts.map +1 -0
  56. package/dist/library/examples/index.js +32 -0
  57. package/dist/library/examples/index.js.map +1 -0
  58. package/dist/library/examples/jelly.d.ts +4 -0
  59. package/dist/library/examples/jelly.d.ts.map +1 -0
  60. package/dist/library/{themes → examples}/jelly.js +4 -3
  61. package/dist/library/examples/jelly.js.map +1 -0
  62. package/dist/library/examples/preset-values.d.ts.map +1 -0
  63. package/dist/library/examples/preset-values.js.map +1 -0
  64. package/dist/library/examples/radiant.d.ts +4 -0
  65. package/dist/library/examples/radiant.d.ts.map +1 -0
  66. package/dist/library/{themes → examples}/radiant.js +4 -3
  67. package/dist/library/examples/radiant.js.map +1 -0
  68. package/dist/library/examples/sharp-3d.d.ts +4 -0
  69. package/dist/library/examples/sharp-3d.d.ts.map +1 -0
  70. package/dist/library/{themes → examples}/sharp-3d.js +4 -3
  71. package/dist/library/examples/sharp-3d.js.map +1 -0
  72. package/dist/library/examples/soft-squircle.d.ts +4 -0
  73. package/dist/library/examples/soft-squircle.d.ts.map +1 -0
  74. package/dist/library/{themes → examples}/soft-squircle.js +4 -3
  75. package/dist/library/examples/soft-squircle.js.map +1 -0
  76. package/dist/library/examples/ticket.d.ts +4 -0
  77. package/dist/library/examples/ticket.d.ts.map +1 -0
  78. package/dist/library/{themes → examples}/ticket.js +4 -3
  79. package/dist/library/examples/ticket.js.map +1 -0
  80. package/dist/library/index.d.ts +4 -2
  81. package/dist/library/index.d.ts.map +1 -1
  82. package/dist/library/index.js +2 -1
  83. package/dist/library/index.js.map +1 -1
  84. package/dist/library/motion/MotionLink.d.ts +8 -0
  85. package/dist/library/motion/MotionLink.d.ts.map +1 -0
  86. package/dist/library/motion/MotionLink.js +44 -0
  87. package/dist/library/motion/MotionLink.js.map +1 -0
  88. package/dist/library/motion/browser.d.ts +5 -0
  89. package/dist/library/motion/browser.d.ts.map +1 -0
  90. package/dist/library/motion/browser.js +35 -0
  91. package/dist/library/motion/browser.js.map +1 -0
  92. package/dist/library/motion/config.d.ts +26 -0
  93. package/dist/library/motion/config.d.ts.map +1 -0
  94. package/dist/library/motion/config.js +58 -0
  95. package/dist/library/motion/config.js.map +1 -0
  96. package/dist/library/motion/context.d.ts +2 -0
  97. package/dist/library/motion/context.d.ts.map +1 -0
  98. package/dist/library/motion/context.js +5 -0
  99. package/dist/library/motion/context.js.map +1 -0
  100. package/dist/library/motion/drag.d.ts +20 -0
  101. package/dist/library/motion/drag.d.ts.map +1 -0
  102. package/dist/library/motion/drag.js +138 -0
  103. package/dist/library/motion/drag.js.map +1 -0
  104. package/dist/library/motion/dragBrowser.d.ts +4 -0
  105. package/dist/library/motion/dragBrowser.d.ts.map +1 -0
  106. package/dist/library/motion/dragBrowser.js +156 -0
  107. package/dist/library/motion/dragBrowser.js.map +1 -0
  108. package/dist/library/motion/follow.d.ts +9 -0
  109. package/dist/library/motion/follow.d.ts.map +1 -0
  110. package/dist/library/motion/follow.js +26 -0
  111. package/dist/library/motion/follow.js.map +1 -0
  112. package/dist/library/motion/host.d.ts +30 -0
  113. package/dist/library/motion/host.d.ts.map +1 -0
  114. package/dist/library/motion/host.js +70 -0
  115. package/dist/library/motion/host.js.map +1 -0
  116. package/dist/library/motion/index.d.ts +16 -0
  117. package/dist/library/motion/index.d.ts.map +1 -0
  118. package/dist/library/motion/index.js +9 -0
  119. package/dist/library/motion/index.js.map +1 -0
  120. package/dist/library/motion/layout.d.ts +20 -0
  121. package/dist/library/motion/layout.d.ts.map +1 -0
  122. package/dist/library/motion/layout.js +67 -0
  123. package/dist/library/motion/layout.js.map +1 -0
  124. package/dist/library/motion/layoutDom.d.ts +17 -0
  125. package/dist/library/motion/layoutDom.d.ts.map +1 -0
  126. package/dist/library/motion/layoutDom.js +272 -0
  127. package/dist/library/motion/layoutDom.js.map +1 -0
  128. package/dist/library/motion/press.d.ts +5 -0
  129. package/dist/library/motion/press.d.ts.map +1 -0
  130. package/dist/library/motion/press.js +99 -0
  131. package/dist/library/motion/press.js.map +1 -0
  132. package/dist/library/motion/pressPolicy.d.ts +5 -0
  133. package/dist/library/motion/pressPolicy.d.ts.map +1 -0
  134. package/dist/library/motion/pressPolicy.js +8 -0
  135. package/dist/library/motion/pressPolicy.js.map +1 -0
  136. package/dist/library/motion/react.d.ts +35 -0
  137. package/dist/library/motion/react.d.ts.map +1 -0
  138. package/dist/library/motion/react.js +224 -0
  139. package/dist/library/motion/react.js.map +1 -0
  140. package/dist/library/motion/runtime.d.ts +22 -0
  141. package/dist/library/motion/runtime.d.ts.map +1 -0
  142. package/dist/library/motion/runtime.js +117 -0
  143. package/dist/library/motion/runtime.js.map +1 -0
  144. package/dist/library/motion/transitions.d.ts +5 -0
  145. package/dist/library/motion/transitions.d.ts.map +1 -0
  146. package/dist/library/motion/transitions.js +244 -0
  147. package/dist/library/motion/transitions.js.map +1 -0
  148. package/dist/library/styles.css +1 -1
  149. package/dist/library/themes/defineTheme.d.ts +3 -0
  150. package/dist/library/themes/defineTheme.d.ts.map +1 -1
  151. package/dist/library/themes/defineTheme.js +4 -2
  152. package/dist/library/themes/defineTheme.js.map +1 -1
  153. package/dist/library/themes/index.d.ts +2 -12
  154. package/dist/library/themes/index.d.ts.map +1 -1
  155. package/dist/library/themes/index.js +1 -19
  156. package/dist/library/themes/index.js.map +1 -1
  157. package/dist/library/themes/themeDocument.d.ts.map +1 -1
  158. package/dist/library/themes/themeDocument.js +11 -5
  159. package/dist/library/themes/themeDocument.js.map +1 -1
  160. package/dist/library/themes/themeDocumentTypes.d.ts +5 -1
  161. package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
  162. package/dist/library/themes/themeDocumentTypes.js.map +1 -1
  163. package/docs/accessibility.md +76 -142
  164. package/docs/architecture.md +197 -0
  165. package/docs/motion.md +153 -0
  166. package/docs/theming.md +275 -882
  167. package/package.json +22 -7
  168. package/src/Accordion.tsx +4 -1
  169. package/src/Button.tsx +55 -1
  170. package/src/Card.tsx +3 -1
  171. package/src/Checkbox.tsx +7 -2
  172. package/src/Collapsible.tsx +38 -2
  173. package/src/Dialog.tsx +13 -1
  174. package/src/Field.tsx +8 -0
  175. package/src/Input.tsx +3 -0
  176. package/src/Link.tsx +5 -0
  177. package/src/RadioGroup.tsx +10 -2
  178. package/src/ThemeScope.tsx +21 -17
  179. package/src/{themes → examples}/expressive.ts +5 -3
  180. package/src/{themes → examples}/glass.ts +5 -3
  181. package/src/examples/index.ts +35 -0
  182. package/src/{themes → examples}/jelly.ts +5 -3
  183. package/src/{themes → examples}/radiant.ts +5 -3
  184. package/src/{themes → examples}/sharp-3d.ts +5 -3
  185. package/src/{themes → examples}/soft-squircle.ts +5 -3
  186. package/src/{themes → examples}/ticket.ts +5 -3
  187. package/src/index.ts +10 -13
  188. package/src/motion/MotionLink.tsx +69 -0
  189. package/src/motion/browser.ts +45 -0
  190. package/src/motion/config.ts +79 -0
  191. package/src/motion/context.ts +4 -0
  192. package/src/motion/drag.ts +151 -0
  193. package/src/motion/dragBrowser.ts +159 -0
  194. package/src/motion/follow.ts +28 -0
  195. package/src/motion/host.ts +96 -0
  196. package/src/motion/index.ts +28 -0
  197. package/src/motion/layout.ts +78 -0
  198. package/src/motion/layoutDom.ts +293 -0
  199. package/src/motion/press.ts +97 -0
  200. package/src/motion/pressPolicy.ts +14 -0
  201. package/src/motion/react.ts +272 -0
  202. package/src/motion/runtime.ts +122 -0
  203. package/src/motion/transitions.ts +237 -0
  204. package/src/themes/defineTheme.ts +10 -2
  205. package/src/themes/index.ts +2 -22
  206. package/src/themes/themeDocument.ts +14 -6
  207. package/src/themes/themeDocumentTypes.ts +12 -5
  208. package/dist/library/themes/expressive.d.ts +0 -2
  209. package/dist/library/themes/expressive.d.ts.map +0 -1
  210. package/dist/library/themes/expressive.js.map +0 -1
  211. package/dist/library/themes/glass.d.ts +0 -2
  212. package/dist/library/themes/glass.d.ts.map +0 -1
  213. package/dist/library/themes/glass.js.map +0 -1
  214. package/dist/library/themes/jelly.d.ts +0 -2
  215. package/dist/library/themes/jelly.d.ts.map +0 -1
  216. package/dist/library/themes/jelly.js.map +0 -1
  217. package/dist/library/themes/preset-values.d.ts.map +0 -1
  218. package/dist/library/themes/preset-values.js.map +0 -1
  219. package/dist/library/themes/radiant.d.ts +0 -2
  220. package/dist/library/themes/radiant.d.ts.map +0 -1
  221. package/dist/library/themes/radiant.js.map +0 -1
  222. package/dist/library/themes/sharp-3d.d.ts +0 -2
  223. package/dist/library/themes/sharp-3d.d.ts.map +0 -1
  224. package/dist/library/themes/sharp-3d.js.map +0 -1
  225. package/dist/library/themes/soft-squircle.d.ts +0 -2
  226. package/dist/library/themes/soft-squircle.d.ts.map +0 -1
  227. package/dist/library/themes/soft-squircle.js.map +0 -1
  228. package/dist/library/themes/ticket.d.ts +0 -2
  229. package/dist/library/themes/ticket.d.ts.map +0 -1
  230. package/dist/library/themes/ticket.js.map +0 -1
  231. package/docs/system.md +0 -238
  232. /package/dist/library/{themes → examples}/preset-values.d.ts +0 -0
  233. /package/dist/library/{themes → examples}/preset-values.js +0 -0
  234. /package/src/{themes → examples}/preset-values.ts +0 -0
@@ -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,aAAa,CAAA;IAChC,IAAI,SAAS;QAAE,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAA;IACxE,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAA;IACzC,IAAI,MAA0B,EAC5B,KAAK,GAAG,CAAC,EACT,MAAM,GAAG,CAAC,EACV,K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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,30 @@
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?(event?: PointerEvent | KeyboardEvent): 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
+ off: boolean;
20
+ press(event: PointerEvent | KeyboardEvent): void;
21
+ release(event?: PointerEvent | KeyboardEvent): void;
22
+ };
23
+ /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
24
+ export declare function useTransitionHost<Node extends HTMLElement>(kind: 'disclosure' | 'dialog', ref: Ref<Node> | undefined, disabled: boolean): {
25
+ ref: import("react").RefCallback<Node>;
26
+ active: boolean;
27
+ ready: boolean;
28
+ off: boolean;
29
+ };
30
+ //# 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,EAA0D,KAAK,GAAG,EAAE,MAAM,OAAO,CAAA;AACxF,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,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,IAAI,CAAA;IACpD,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;;;;iBA4BF,YAAY,GAAG,aAAa;oBAGzB,YAAY,GAAG,aAAa;EAI/C;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;;;;;EAiClB"}
@@ -0,0 +1,70 @@
1
+ 'use client';
2
+ import { createContext, useContext, useEffect, useRef, useState } 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
+ off: profile.mode === 'off',
31
+ press(event) {
32
+ binding.current?.value.press?.(event);
33
+ },
34
+ release(event) {
35
+ binding.current?.value.release?.(event);
36
+ }
37
+ };
38
+ }
39
+ /** Shared lifecycle for native presentation adapters; no engine enters the root path. */
40
+ export function useTransitionHost(kind, ref, disabled) {
41
+ const runtime = useContext(MotionHostContext);
42
+ const profile = useContext(MotionProfileContext);
43
+ const node = useRef(null);
44
+ const binding = useRef(null);
45
+ const composed = useComposedRefs(node, ref);
46
+ const [ready, setReady] = useState(false);
47
+ useEffect(() => {
48
+ const attach = runtime?.[kind];
49
+ if (disabled || !attach || !node.current || binding.current?.node !== node.current) {
50
+ binding.current?.value.destroy();
51
+ binding.current = null;
52
+ }
53
+ if (!disabled && attach && node.current) {
54
+ binding.current ??= { node: node.current, value: attach(node.current, profile) };
55
+ binding.current.value.update(profile);
56
+ }
57
+ setReady(binding.current !== null);
58
+ }, [disabled, kind, runtime, profile, composed]);
59
+ useEffect(() => () => {
60
+ binding.current?.value.destroy();
61
+ binding.current = null;
62
+ }, []);
63
+ return {
64
+ ref: composed,
65
+ active: !disabled && runtime?.[kind] !== undefined,
66
+ ready,
67
+ off: profile.mode === 'off'
68
+ };
69
+ }
70
+ //# 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,EAAE,QAAQ,EAAY,MAAM,OAAO,CAAA;AAExF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAA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CAAA;QACxB,CAAC;QACD,IAAI,CAAC,QAAQ,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACxC,OAAO,CAAC,OAAO,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;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"]}
@@ -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,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAA;AACnD,SAAS,QAAQ,CAAC,MAAoB;IACpC,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;QACxB,IACE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC9B,CAAC,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,QAAQ,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAE7D,MAAM,IAAI,SAAS,CACjB,kFAAkF,CACnF,CAAA;IACL,CAAC;AACH,CAAC;AACD,qGAAqG;AACrG,MAAM,UAAU,kBAAkB,CAAC,OAAqB,EAAE,UAAyB,EAAE;IACnF,QAAQ,CAAC,OAAO,CAAC,CAAA;IACjB,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QACpC,MAAM,IAAI,SAAS,CAAC,wEAAwE,CAAC,CAAA;IAC/F,MAAM,MAAM,GAAG;QACb,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,E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ourcesContent":["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"}