@easemate/web-kit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/build/decorators.cjs +921 -0
  2. package/build/decorators.cjs.map +1 -0
  3. package/build/decorators.d.cts +123 -0
  4. package/build/decorators.d.ts +123 -0
  5. package/build/decorators.js +889 -0
  6. package/build/decorators.js.map +1 -0
  7. package/build/elements.cjs +27604 -0
  8. package/build/elements.cjs.map +1 -0
  9. package/build/elements.d.cts +373 -0
  10. package/build/elements.d.ts +373 -0
  11. package/build/elements.js +27528 -0
  12. package/build/elements.js.map +1 -0
  13. package/build/{elements/monitor/index.d.ts → index-31iOHBv0.d.cts} +26 -5
  14. package/build/{elements/monitor/index.d.cts → index-31iOHBv0.d.ts} +26 -5
  15. package/build/{elements/panel/index.d.cts → index-NzGpn7ai.d.cts} +6 -3
  16. package/build/{elements/panel/index.d.ts → index-NzGpn7ai.d.ts} +6 -3
  17. package/build/{elements/state/index.d.ts → index-qZoNKsHn.d.cts} +46 -5
  18. package/build/{elements/state/index.d.cts → index-qZoNKsHn.d.ts} +46 -5
  19. package/build/index.cjs +38651 -38
  20. package/build/index.cjs.map +1 -0
  21. package/build/index.d.cts +85 -6
  22. package/build/index.d.ts +85 -6
  23. package/build/index.js +38535 -12
  24. package/build/index.js.map +1 -0
  25. package/build/init-B7gNNyTd.d.ts +235 -0
  26. package/build/init-DwVGVxkx.d.cts +235 -0
  27. package/build/jsx.cjs +31 -0
  28. package/build/jsx.cjs.map +1 -0
  29. package/build/jsx.d.cts +317 -0
  30. package/build/jsx.d.ts +317 -0
  31. package/build/jsx.js +6 -0
  32. package/build/jsx.js.map +1 -0
  33. package/build/outside-click-rZ3Di_WX.d.cts +16 -0
  34. package/build/outside-click-rZ3Di_WX.d.ts +16 -0
  35. package/build/react.cjs +37827 -0
  36. package/build/react.cjs.map +1 -0
  37. package/build/react.d.cts +356 -0
  38. package/build/react.d.ts +356 -0
  39. package/build/react.js +37802 -0
  40. package/build/react.js.map +1 -0
  41. package/build/register.cjs +35832 -36
  42. package/build/register.cjs.map +1 -0
  43. package/build/register.d.cts +4 -33
  44. package/build/register.d.ts +4 -33
  45. package/build/register.js +35831 -35
  46. package/build/register.js.map +1 -0
  47. package/build/register.server.cjs +19 -0
  48. package/build/register.server.cjs.map +1 -0
  49. package/build/register.server.d.cts +2 -0
  50. package/build/register.server.d.ts +2 -0
  51. package/build/register.server.js +1 -0
  52. package/build/register.server.js.map +1 -0
  53. package/build/registry-9GX9KTG1.d.cts +264 -0
  54. package/build/registry-9GX9KTG1.d.ts +264 -0
  55. package/build/template-helpers-CguLXtLD.d.cts +10 -0
  56. package/build/template-helpers-CguLXtLD.d.ts +10 -0
  57. package/build/theme.cjs +746 -0
  58. package/build/theme.cjs.map +1 -0
  59. package/build/{theme/index.d.cts → theme.d.cts} +41 -21
  60. package/build/{theme/index.d.ts → theme.d.ts} +41 -21
  61. package/build/theme.js +692 -0
  62. package/build/theme.js.map +1 -0
  63. package/build/utils.cjs +205 -0
  64. package/build/utils.cjs.map +1 -0
  65. package/build/utils.d.cts +26 -0
  66. package/build/utils.d.ts +26 -0
  67. package/build/utils.js +167 -0
  68. package/build/utils.js.map +1 -0
  69. package/package.json +47 -33
  70. package/build/components/code/index.cjs +0 -152
  71. package/build/components/code/index.d.cts +0 -11
  72. package/build/components/code/index.d.ts +0 -11
  73. package/build/components/code/index.js +0 -148
  74. package/build/components/code/utils/highlight-api.cjs +0 -18
  75. package/build/components/code/utils/highlight-api.d.cts +0 -7
  76. package/build/components/code/utils/highlight-api.d.ts +0 -7
  77. package/build/components/code/utils/highlight-api.js +0 -14
  78. package/build/components/code/utils/syntax-grammars.cjs +0 -62
  79. package/build/components/code/utils/syntax-grammars.d.cts +0 -7
  80. package/build/components/code/utils/syntax-grammars.d.ts +0 -7
  81. package/build/components/code/utils/syntax-grammars.js +0 -59
  82. package/build/components/code/utils/syntax-highlighter-theme.cjs +0 -27
  83. package/build/components/code/utils/syntax-highlighter-theme.d.cts +0 -3
  84. package/build/components/code/utils/syntax-highlighter-theme.d.ts +0 -3
  85. package/build/components/code/utils/syntax-highlighter-theme.js +0 -23
  86. package/build/components/code/utils/syntax-highlighter-types.cjs +0 -2
  87. package/build/components/code/utils/syntax-highlighter-types.d.cts +0 -12
  88. package/build/components/code/utils/syntax-highlighter-types.d.ts +0 -12
  89. package/build/components/code/utils/syntax-highlighter-types.js +0 -1
  90. package/build/components/code/utils/syntax-tokenizer.cjs +0 -63
  91. package/build/components/code/utils/syntax-tokenizer.d.cts +0 -3
  92. package/build/components/code/utils/syntax-tokenizer.d.ts +0 -3
  93. package/build/components/code/utils/syntax-tokenizer.js +0 -58
  94. package/build/components/curve/bezier-conversion.cjs +0 -23
  95. package/build/components/curve/bezier-conversion.d.cts +0 -2
  96. package/build/components/curve/bezier-conversion.d.ts +0 -2
  97. package/build/components/curve/bezier-conversion.js +0 -19
  98. package/build/components/curve/canvas-controls.cjs +0 -300
  99. package/build/components/curve/canvas-controls.d.cts +0 -12
  100. package/build/components/curve/canvas-controls.d.ts +0 -12
  101. package/build/components/curve/canvas-controls.js +0 -296
  102. package/build/components/curve/canvas.cjs +0 -1208
  103. package/build/components/curve/canvas.d.cts +0 -24
  104. package/build/components/curve/canvas.d.ts +0 -24
  105. package/build/components/curve/canvas.js +0 -1204
  106. package/build/components/curve/constants.cjs +0 -203
  107. package/build/components/curve/constants.d.cts +0 -23
  108. package/build/components/curve/constants.d.ts +0 -23
  109. package/build/components/curve/constants.js +0 -200
  110. package/build/components/curve/controls.cjs +0 -942
  111. package/build/components/curve/controls.d.cts +0 -37
  112. package/build/components/curve/controls.d.ts +0 -37
  113. package/build/components/curve/controls.js +0 -938
  114. package/build/components/curve/index.cjs +0 -335
  115. package/build/components/curve/index.d.cts +0 -31
  116. package/build/components/curve/index.d.ts +0 -31
  117. package/build/components/curve/index.js +0 -330
  118. package/build/components/curve/output.cjs +0 -141
  119. package/build/components/curve/output.d.cts +0 -19
  120. package/build/components/curve/output.d.ts +0 -19
  121. package/build/components/curve/output.js +0 -137
  122. package/build/components/curve/styles.cjs +0 -493
  123. package/build/components/curve/styles.d.cts +0 -6
  124. package/build/components/curve/styles.d.ts +0 -6
  125. package/build/components/curve/styles.js +0 -490
  126. package/build/components/curve/svg-renderer.cjs +0 -185
  127. package/build/components/curve/svg-renderer.d.cts +0 -9
  128. package/build/components/curve/svg-renderer.d.ts +0 -9
  129. package/build/components/curve/svg-renderer.js +0 -175
  130. package/build/components/curve/toolbar.cjs +0 -368
  131. package/build/components/curve/toolbar.d.cts +0 -26
  132. package/build/components/curve/toolbar.d.ts +0 -26
  133. package/build/components/curve/toolbar.js +0 -364
  134. package/build/components/curve/types.cjs +0 -10
  135. package/build/components/curve/types.d.cts +0 -33
  136. package/build/components/curve/types.d.ts +0 -33
  137. package/build/components/curve/types.js +0 -7
  138. package/build/components/curve/utils.cjs +0 -541
  139. package/build/components/curve/utils.d.cts +0 -33
  140. package/build/components/curve/utils.d.ts +0 -33
  141. package/build/components/curve/utils.js +0 -521
  142. package/build/components/index.cjs +0 -18
  143. package/build/components/index.d.cts +0 -2
  144. package/build/components/index.d.ts +0 -2
  145. package/build/components/index.js +0 -2
  146. package/build/decorators/Component.cjs +0 -127
  147. package/build/decorators/Component.d.cts +0 -28
  148. package/build/decorators/Component.d.ts +0 -28
  149. package/build/decorators/Component.js +0 -123
  150. package/build/decorators/Listen.cjs +0 -154
  151. package/build/decorators/Listen.d.cts +0 -18
  152. package/build/decorators/Listen.d.ts +0 -18
  153. package/build/decorators/Listen.js +0 -151
  154. package/build/decorators/OutsideClick.cjs +0 -64
  155. package/build/decorators/OutsideClick.d.cts +0 -16
  156. package/build/decorators/OutsideClick.d.ts +0 -16
  157. package/build/decorators/OutsideClick.js +0 -59
  158. package/build/decorators/Prop.cjs +0 -273
  159. package/build/decorators/Prop.d.cts +0 -22
  160. package/build/decorators/Prop.d.ts +0 -22
  161. package/build/decorators/Prop.js +0 -270
  162. package/build/decorators/Query.cjs +0 -79
  163. package/build/decorators/Query.d.cts +0 -27
  164. package/build/decorators/Query.d.ts +0 -27
  165. package/build/decorators/Query.js +0 -76
  166. package/build/decorators/Watch.cjs +0 -52
  167. package/build/decorators/Watch.d.cts +0 -11
  168. package/build/decorators/Watch.d.ts +0 -11
  169. package/build/decorators/Watch.js +0 -49
  170. package/build/decorators/index.cjs +0 -15
  171. package/build/decorators/index.d.cts +0 -6
  172. package/build/decorators/index.d.ts +0 -6
  173. package/build/decorators/index.js +0 -6
  174. package/build/elements/button/index.cjs +0 -214
  175. package/build/elements/button/index.d.cts +0 -11
  176. package/build/elements/button/index.d.ts +0 -11
  177. package/build/elements/button/index.js +0 -210
  178. package/build/elements/checkbox/index.cjs +0 -316
  179. package/build/elements/checkbox/index.d.cts +0 -14
  180. package/build/elements/checkbox/index.d.ts +0 -14
  181. package/build/elements/checkbox/index.js +0 -312
  182. package/build/elements/color/index.cjs +0 -154
  183. package/build/elements/color/index.d.cts +0 -18
  184. package/build/elements/color/index.d.ts +0 -18
  185. package/build/elements/color/index.js +0 -150
  186. package/build/elements/color/picker.cjs +0 -544
  187. package/build/elements/color/picker.d.cts +0 -37
  188. package/build/elements/color/picker.d.ts +0 -37
  189. package/build/elements/color/picker.js +0 -540
  190. package/build/elements/color/utils.cjs +0 -235
  191. package/build/elements/color/utils.d.cts +0 -37
  192. package/build/elements/color/utils.d.ts +0 -37
  193. package/build/elements/color/utils.js +0 -218
  194. package/build/elements/dropdown/index.cjs +0 -875
  195. package/build/elements/dropdown/index.d.cts +0 -30
  196. package/build/elements/dropdown/index.d.ts +0 -30
  197. package/build/elements/dropdown/index.js +0 -871
  198. package/build/elements/field/index.cjs +0 -82
  199. package/build/elements/field/index.d.cts +0 -4
  200. package/build/elements/field/index.d.ts +0 -4
  201. package/build/elements/field/index.js +0 -78
  202. package/build/elements/icons/animation/chevron.cjs +0 -57
  203. package/build/elements/icons/animation/chevron.d.cts +0 -10
  204. package/build/elements/icons/animation/chevron.d.ts +0 -10
  205. package/build/elements/icons/animation/chevron.js +0 -53
  206. package/build/elements/icons/animation/clear.cjs +0 -74
  207. package/build/elements/icons/animation/clear.d.cts +0 -3
  208. package/build/elements/icons/animation/clear.d.ts +0 -3
  209. package/build/elements/icons/animation/clear.js +0 -70
  210. package/build/elements/icons/animation/grid.cjs +0 -77
  211. package/build/elements/icons/animation/grid.d.cts +0 -8
  212. package/build/elements/icons/animation/grid.d.ts +0 -8
  213. package/build/elements/icons/animation/grid.js +0 -73
  214. package/build/elements/icons/animation/loading.cjs +0 -68
  215. package/build/elements/icons/animation/loading.d.cts +0 -3
  216. package/build/elements/icons/animation/loading.d.ts +0 -3
  217. package/build/elements/icons/animation/loading.js +0 -64
  218. package/build/elements/icons/animation/snap.cjs +0 -133
  219. package/build/elements/icons/animation/snap.d.cts +0 -8
  220. package/build/elements/icons/animation/snap.d.ts +0 -8
  221. package/build/elements/icons/animation/snap.js +0 -129
  222. package/build/elements/icons/index.cjs +0 -40
  223. package/build/elements/icons/index.d.cts +0 -24
  224. package/build/elements/icons/index.d.ts +0 -24
  225. package/build/elements/icons/index.js +0 -24
  226. package/build/elements/icons/interface/anchor-add.cjs +0 -35
  227. package/build/elements/icons/interface/anchor-add.d.cts +0 -3
  228. package/build/elements/icons/interface/anchor-add.d.ts +0 -3
  229. package/build/elements/icons/interface/anchor-add.js +0 -31
  230. package/build/elements/icons/interface/anchor-remove.cjs +0 -34
  231. package/build/elements/icons/interface/anchor-remove.d.cts +0 -3
  232. package/build/elements/icons/interface/anchor-remove.d.ts +0 -3
  233. package/build/elements/icons/interface/anchor-remove.js +0 -30
  234. package/build/elements/icons/interface/arrow-up.cjs +0 -30
  235. package/build/elements/icons/interface/arrow-up.d.cts +0 -3
  236. package/build/elements/icons/interface/arrow-up.d.ts +0 -3
  237. package/build/elements/icons/interface/arrow-up.js +0 -26
  238. package/build/elements/icons/interface/arrows-vertical.cjs +0 -30
  239. package/build/elements/icons/interface/arrows-vertical.d.cts +0 -3
  240. package/build/elements/icons/interface/arrows-vertical.d.ts +0 -3
  241. package/build/elements/icons/interface/arrows-vertical.js +0 -26
  242. package/build/elements/icons/interface/bezier-angle.cjs +0 -33
  243. package/build/elements/icons/interface/bezier-angle.d.cts +0 -3
  244. package/build/elements/icons/interface/bezier-angle.d.ts +0 -3
  245. package/build/elements/icons/interface/bezier-angle.js +0 -29
  246. package/build/elements/icons/interface/bezier-distribute.cjs +0 -34
  247. package/build/elements/icons/interface/bezier-distribute.d.cts +0 -3
  248. package/build/elements/icons/interface/bezier-distribute.d.ts +0 -3
  249. package/build/elements/icons/interface/bezier-distribute.js +0 -30
  250. package/build/elements/icons/interface/bezier-length.cjs +0 -31
  251. package/build/elements/icons/interface/bezier-length.d.cts +0 -3
  252. package/build/elements/icons/interface/bezier-length.d.ts +0 -3
  253. package/build/elements/icons/interface/bezier-length.js +0 -27
  254. package/build/elements/icons/interface/bezier-mirror.cjs +0 -31
  255. package/build/elements/icons/interface/bezier-mirror.d.cts +0 -3
  256. package/build/elements/icons/interface/bezier-mirror.d.ts +0 -3
  257. package/build/elements/icons/interface/bezier-mirror.js +0 -27
  258. package/build/elements/icons/interface/bezier.cjs +0 -26
  259. package/build/elements/icons/interface/bezier.d.cts +0 -3
  260. package/build/elements/icons/interface/bezier.d.ts +0 -3
  261. package/build/elements/icons/interface/bezier.js +0 -22
  262. package/build/elements/icons/interface/check.cjs +0 -30
  263. package/build/elements/icons/interface/check.d.cts +0 -3
  264. package/build/elements/icons/interface/check.d.ts +0 -3
  265. package/build/elements/icons/interface/check.js +0 -26
  266. package/build/elements/icons/interface/circle-arrow-left.cjs +0 -30
  267. package/build/elements/icons/interface/circle-arrow-left.d.cts +0 -3
  268. package/build/elements/icons/interface/circle-arrow-left.d.ts +0 -3
  269. package/build/elements/icons/interface/circle-arrow-left.js +0 -26
  270. package/build/elements/icons/interface/circle-arrow-right.cjs +0 -30
  271. package/build/elements/icons/interface/circle-arrow-right.d.cts +0 -3
  272. package/build/elements/icons/interface/circle-arrow-right.d.ts +0 -3
  273. package/build/elements/icons/interface/circle-arrow-right.js +0 -26
  274. package/build/elements/icons/interface/code.cjs +0 -30
  275. package/build/elements/icons/interface/code.d.cts +0 -3
  276. package/build/elements/icons/interface/code.d.ts +0 -3
  277. package/build/elements/icons/interface/code.js +0 -26
  278. package/build/elements/icons/interface/dots.cjs +0 -32
  279. package/build/elements/icons/interface/dots.d.cts +0 -3
  280. package/build/elements/icons/interface/dots.d.ts +0 -3
  281. package/build/elements/icons/interface/dots.js +0 -28
  282. package/build/elements/icons/interface/mention.cjs +0 -30
  283. package/build/elements/icons/interface/mention.d.cts +0 -3
  284. package/build/elements/icons/interface/mention.d.ts +0 -3
  285. package/build/elements/icons/interface/mention.js +0 -26
  286. package/build/elements/icons/interface/minus.cjs +0 -30
  287. package/build/elements/icons/interface/minus.d.cts +0 -3
  288. package/build/elements/icons/interface/minus.d.ts +0 -3
  289. package/build/elements/icons/interface/minus.js +0 -26
  290. package/build/elements/icons/interface/picker.cjs +0 -34
  291. package/build/elements/icons/interface/picker.d.cts +0 -3
  292. package/build/elements/icons/interface/picker.d.ts +0 -3
  293. package/build/elements/icons/interface/picker.js +0 -30
  294. package/build/elements/icons/interface/plus.cjs +0 -30
  295. package/build/elements/icons/interface/plus.d.cts +0 -3
  296. package/build/elements/icons/interface/plus.d.ts +0 -3
  297. package/build/elements/icons/interface/plus.js +0 -26
  298. package/build/elements/icons/interface/settings.cjs +0 -30
  299. package/build/elements/icons/interface/settings.d.cts +0 -3
  300. package/build/elements/icons/interface/settings.d.ts +0 -3
  301. package/build/elements/icons/interface/settings.js +0 -26
  302. package/build/elements/index.cjs +0 -65
  303. package/build/elements/index.d.cts +0 -23
  304. package/build/elements/index.d.ts +0 -23
  305. package/build/elements/index.js +0 -23
  306. package/build/elements/input/index.cjs +0 -273
  307. package/build/elements/input/index.d.cts +0 -17
  308. package/build/elements/input/index.d.ts +0 -17
  309. package/build/elements/input/index.js +0 -269
  310. package/build/elements/logo/index.cjs +0 -732
  311. package/build/elements/logo/index.d.cts +0 -17
  312. package/build/elements/logo/index.d.ts +0 -17
  313. package/build/elements/logo/index.js +0 -728
  314. package/build/elements/monitor/fps.cjs +0 -432
  315. package/build/elements/monitor/fps.d.cts +0 -21
  316. package/build/elements/monitor/fps.d.ts +0 -21
  317. package/build/elements/monitor/fps.js +0 -428
  318. package/build/elements/monitor/index.cjs +0 -670
  319. package/build/elements/monitor/index.js +0 -666
  320. package/build/elements/number/index.cjs +0 -173
  321. package/build/elements/number/index.d.cts +0 -19
  322. package/build/elements/number/index.d.ts +0 -19
  323. package/build/elements/number/index.js +0 -169
  324. package/build/elements/origin/index.cjs +0 -169
  325. package/build/elements/origin/index.d.cts +0 -12
  326. package/build/elements/origin/index.d.ts +0 -12
  327. package/build/elements/origin/index.js +0 -165
  328. package/build/elements/panel/index.cjs +0 -496
  329. package/build/elements/panel/index.js +0 -492
  330. package/build/elements/popover/index.cjs +0 -209
  331. package/build/elements/popover/index.d.cts +0 -19
  332. package/build/elements/popover/index.d.ts +0 -19
  333. package/build/elements/popover/index.js +0 -205
  334. package/build/elements/radio/index.cjs +0 -301
  335. package/build/elements/radio/index.d.cts +0 -13
  336. package/build/elements/radio/index.d.ts +0 -13
  337. package/build/elements/radio/index.js +0 -283
  338. package/build/elements/radio/input.cjs +0 -329
  339. package/build/elements/radio/input.d.cts +0 -15
  340. package/build/elements/radio/input.d.ts +0 -15
  341. package/build/elements/radio/input.js +0 -325
  342. package/build/elements/radio/option.cjs +0 -15
  343. package/build/elements/radio/option.d.cts +0 -3
  344. package/build/elements/radio/option.d.ts +0 -3
  345. package/build/elements/radio/option.js +0 -11
  346. package/build/elements/shared.cjs +0 -66
  347. package/build/elements/shared.d.cts +0 -40
  348. package/build/elements/shared.d.ts +0 -40
  349. package/build/elements/shared.js +0 -59
  350. package/build/elements/slider/index.cjs +0 -232
  351. package/build/elements/slider/index.d.cts +0 -20
  352. package/build/elements/slider/index.d.ts +0 -20
  353. package/build/elements/slider/index.js +0 -228
  354. package/build/elements/state/index.cjs +0 -274
  355. package/build/elements/state/index.js +0 -270
  356. package/build/elements/toggle/index.cjs +0 -151
  357. package/build/elements/toggle/index.d.cts +0 -9
  358. package/build/elements/toggle/index.d.ts +0 -9
  359. package/build/elements/toggle/index.js +0 -147
  360. package/build/elements/tooltip/index.cjs +0 -187
  361. package/build/elements/tooltip/index.d.cts +0 -17
  362. package/build/elements/tooltip/index.d.ts +0 -17
  363. package/build/elements/tooltip/index.js +0 -183
  364. package/build/init.cjs +0 -325
  365. package/build/init.d.cts +0 -157
  366. package/build/init.d.ts +0 -157
  367. package/build/init.js +0 -289
  368. package/build/internal/component-loaders.cjs +0 -208
  369. package/build/internal/component-loaders.d.cts +0 -52
  370. package/build/internal/component-loaders.d.ts +0 -52
  371. package/build/internal/component-loaders.js +0 -169
  372. package/build/internal/fonts.cjs +0 -128
  373. package/build/internal/fonts.d.cts +0 -32
  374. package/build/internal/fonts.d.ts +0 -32
  375. package/build/internal/fonts.js +0 -123
  376. package/build/internal/lazy-load.cjs +0 -89
  377. package/build/internal/lazy-load.d.cts +0 -32
  378. package/build/internal/lazy-load.d.ts +0 -32
  379. package/build/internal/lazy-load.js +0 -86
  380. package/build/internal/style-inject.cjs +0 -236
  381. package/build/internal/style-inject.d.cts +0 -44
  382. package/build/internal/style-inject.d.ts +0 -44
  383. package/build/internal/style-inject.js +0 -226
  384. package/build/react/events.cjs +0 -25
  385. package/build/react/events.d.cts +0 -39
  386. package/build/react/events.d.ts +0 -39
  387. package/build/react/events.js +0 -22
  388. package/build/react/index.cjs +0 -19
  389. package/build/react/index.d.cts +0 -13
  390. package/build/react/index.d.ts +0 -13
  391. package/build/react/index.js +0 -12
  392. package/build/react/provider.cjs +0 -134
  393. package/build/react/provider.d.cts +0 -81
  394. package/build/react/provider.d.ts +0 -81
  395. package/build/react/provider.js +0 -98
  396. package/build/react/types.cjs +0 -8
  397. package/build/react/types.d.cts +0 -55
  398. package/build/react/types.d.ts +0 -55
  399. package/build/react/types.js +0 -7
  400. package/build/react/use-ease-state.cjs +0 -129
  401. package/build/react/use-ease-state.d.cts +0 -95
  402. package/build/react/use-ease-state.d.ts +0 -95
  403. package/build/react/use-ease-state.js +0 -126
  404. package/build/react/use-web-kit.cjs +0 -150
  405. package/build/react/use-web-kit.d.cts +0 -80
  406. package/build/react/use-web-kit.d.ts +0 -80
  407. package/build/react/use-web-kit.js +0 -114
  408. package/build/theme/index.cjs +0 -452
  409. package/build/theme/index.js +0 -423
  410. package/build/theme/presets.cjs +0 -54
  411. package/build/theme/presets.d.cts +0 -19
  412. package/build/theme/presets.d.ts +0 -19
  413. package/build/theme/presets.js +0 -51
  414. package/build/theme/registry.cjs +0 -204
  415. package/build/theme/registry.d.cts +0 -99
  416. package/build/theme/registry.d.ts +0 -99
  417. package/build/theme/registry.js +0 -194
  418. package/build/theme/tokens.cjs +0 -148
  419. package/build/theme/tokens.d.cts +0 -163
  420. package/build/theme/tokens.d.ts +0 -163
  421. package/build/theme/tokens.js +0 -145
  422. package/build/utils/dismiss-controller.cjs +0 -77
  423. package/build/utils/dismiss-controller.d.cts +0 -14
  424. package/build/utils/dismiss-controller.d.ts +0 -14
  425. package/build/utils/dismiss-controller.js +0 -73
  426. package/build/utils/index.cjs +0 -18
  427. package/build/utils/index.d.cts +0 -3
  428. package/build/utils/index.d.ts +0 -3
  429. package/build/utils/index.js +0 -3
  430. package/build/utils/outside-click.cjs +0 -82
  431. package/build/utils/outside-click.d.cts +0 -18
  432. package/build/utils/outside-click.d.ts +0 -18
  433. package/build/utils/outside-click.js +0 -74
  434. package/build/utils/template-helpers.cjs +0 -39
  435. package/build/utils/template-helpers.d.cts +0 -13
  436. package/build/utils/template-helpers.d.ts +0 -13
  437. package/build/utils/template-helpers.js +0 -28
@@ -1,1208 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CurveCanvas = void 0;
4
- const lit_html_1 = require("lit-html");
5
- const constants_1 = require("./constants.cjs");
6
- const styles_1 = require("./styles.cjs");
7
- const svg_renderer_1 = require("./svg-renderer.cjs");
8
- const types_1 = require("./types.cjs");
9
- const utils_1 = require("./utils.cjs");
10
- const Component_1 = require("../../decorators/Component");
11
- const Prop_1 = require("../../decorators/Prop");
12
- const Query_1 = require("../../decorators/Query");
13
- const shared_1 = require("../../elements/shared");
14
- @(0, Component_1.Component)({
15
- tag: 'ease-curve-canvas',
16
- styles: styles_1.canvasStyles,
17
- template() {
18
- const hoverPreviewPath = this.getHoverCurvePath();
19
- const controlElements = this.getControlElements();
20
- const hoverInsertElements = this.getHoverInsertElements();
21
- const curvePath = this.getCurvePath();
22
- return (0, lit_html_1.html) `
23
- <svg
24
- viewBox="0 0 ${constants_1.SVG_WIDTH} ${constants_1.SVG_HEIGHT}"
25
- width="${constants_1.SVG_WIDTH}"
26
- height="${constants_1.SVG_HEIGHT}"
27
- @pointerdown=${this.handlePointerDown}
28
- @pointermove=${this.handlePointerMove}
29
- @pointerup=${this.handlePointerUp}
30
- @pointerleave=${this.handlePointerLeave}
31
- @pointercancel=${this.handlePointerLeave}
32
- >
33
- ${this.showGrid ? (0, lit_html_1.svg) `<g style="view-transition-name: grid-lines">${this.getGridLines()}</g>` : null}
34
- ${hoverPreviewPath ? (0, lit_html_1.html) `<path class="curve-path curve-path--preview" d=${hoverPreviewPath}></path>` : null}
35
- <path class="curve-path" d=${curvePath} />
36
- ${controlElements}
37
- ${hoverInsertElements}
38
- </svg>
39
- `;
40
- }
41
- })
42
- class CurveCanvas extends HTMLElement {
43
- @(0, Prop_1.Prop)({ reflect: true })
44
- accessor easingType;
45
- @(0, Prop_1.Prop)({ type: Object, reflect: false })
46
- accessor points;
47
- @(0, Prop_1.Prop)({ type: Boolean, reflect: true, defaultValue: true })
48
- accessor showGrid;
49
- @(0, Prop_1.Prop)({ type: Boolean, reflect: true, defaultValue: false })
50
- accessor snapToGrid;
51
- @(0, Prop_1.Prop)({ type: Number, reflect: true, defaultValue: 8 })
52
- accessor gridSize = 8;
53
- @(0, Prop_1.Prop)({ type: Number, reflect: false, defaultValue: null })
54
- accessor focusedLinearIndex = null;
55
- @(0, Prop_1.Prop)({ type: Number, reflect: true, defaultValue: 0 })
56
- accessor simplify = 0;
57
- @(0, Prop_1.Prop)({ type: Number, reflect: true, defaultValue: 5 })
58
- accessor round = 5;
59
- @(0, Query_1.Query)('svg')
60
- accessor svgElement;
61
- #isDragging = false;
62
- #dragIndex = null;
63
- #dragMode = null;
64
- #hoverPoint = null;
65
- #hoverInsertPreview = null;
66
- #dragStartPoints = null;
67
- #dragPointId = null;
68
- #pendingDrag = null;
69
- #getEventTarget = () => {
70
- const root = this.getRootNode();
71
- if (root instanceof ShadowRoot && root.host instanceof HTMLElement) {
72
- return root.host;
73
- }
74
- return this;
75
- };
76
- #renderCubicBezier = () => {
77
- const points = this.#getCubicBezierPoints();
78
- if (!points) {
79
- console.warn('Invalid cubic-bezier points for rendering:', this.points);
80
- return [];
81
- }
82
- try {
83
- const anchorStart = this.#toSvgCoords({ x: 0, y: 0 });
84
- const anchorEnd = this.#toSvgCoords({ x: 1, y: 1 });
85
- const controlOne = this.#toSvgCoords(points.p1);
86
- const controlTwo = this.#toSvgCoords(points.p2);
87
- const elements = [];
88
- const handlePathOne = this.#createHandlePath(anchorStart, controlOne);
89
- const handlePathTwo = this.#createHandlePath(anchorEnd, controlTwo);
90
- elements.push((0, lit_html_1.svg) `<circle
91
- class="hit-area-point"
92
- cx="${controlOne.x}"
93
- cy="${controlOne.y}"
94
- r="${constants_1.HIT_AREA_RADIUS}"
95
- data-index="0"
96
- data-role="point"
97
- />`);
98
- elements.push((0, lit_html_1.svg) `<circle
99
- class="hit-area-point"
100
- cx="${controlTwo.x}"
101
- cy="${controlTwo.y}"
102
- r="${constants_1.HIT_AREA_RADIUS}"
103
- data-index="1"
104
- data-role="point"
105
- />`);
106
- if (handlePathOne) {
107
- elements.push((0, lit_html_1.svg) `<path
108
- class="control-point ${this.#dragIndex === 0 && this.#dragMode === 'point' ? 'selected' : ''}"
109
- d="${handlePathOne}"
110
- data-index="0"
111
- data-role="point"
112
- />`);
113
- }
114
- if (handlePathTwo) {
115
- elements.push((0, lit_html_1.svg) `<path
116
- class="control-point ${this.#dragIndex === 1 && this.#dragMode === 'point' ? 'selected' : ''}"
117
- d="${handlePathTwo}"
118
- data-index="1"
119
- data-role="point"
120
- />`);
121
- }
122
- elements.push((0, lit_html_1.svg) `<circle class="anchor-point-start" cx="${anchorStart.x}" cy="${anchorStart.y}" />`);
123
- elements.push((0, lit_html_1.svg) `<circle class="anchor-point-start" cx="${anchorEnd.x}" cy="${anchorEnd.y}" />`);
124
- return elements;
125
- }
126
- catch (error) {
127
- console.error('Error rendering cubic-bezier elements:', error);
128
- return [];
129
- }
130
- };
131
- #toSvgCoords = (p) => {
132
- return {
133
- x: p.x * constants_1.SVG_WIDTH,
134
- y: (1 - p.y) * constants_1.SVG_HEIGHT
135
- };
136
- };
137
- #renderLinear = () => {
138
- const points = this.#getLinearPoints();
139
- if (!points) {
140
- return [];
141
- }
142
- try {
143
- const elements = [];
144
- const focusedIndex = this.focusedLinearIndex;
145
- points.forEach((point, index) => {
146
- if (!point) {
147
- return;
148
- }
149
- const isPointFocused = focusedIndex === index;
150
- const isDraggingPoint = this.#isDragging && this.#dragIndex === index;
151
- if (!isPointFocused && !isDraggingPoint) {
152
- return;
153
- }
154
- const anchorSvg = this.#toSvgCoords(point);
155
- if (index > 0 && (point.cpInX !== undefined || point.cpInY !== undefined)) {
156
- this.#renderLinearHandle(elements, point, anchorSvg, index, 'In');
157
- }
158
- if (index < points.length - 1 && (point.cpOutX !== undefined || point.cpOutY !== undefined)) {
159
- this.#renderLinearHandle(elements, point, anchorSvg, index, 'Out');
160
- }
161
- });
162
- points.forEach((point, index) => {
163
- if (!point) {
164
- return;
165
- }
166
- const isPointFocused = focusedIndex === index;
167
- const isPointActive = (this.#dragMode === 'point' && this.#dragIndex === index) || isPointFocused;
168
- const anchorSvg = this.#toSvgCoords(point);
169
- elements.push((0, lit_html_1.svg) `<circle
170
- class="hit-area-point"
171
- cx="${anchorSvg.x}"
172
- cy="${anchorSvg.y}"
173
- r="${constants_1.HIT_AREA_RADIUS}"
174
- data-index="${index}"
175
- data-role="point"
176
- />`);
177
- elements.push((0, lit_html_1.svg) `<circle
178
- class="linear-point ${isPointActive ? 'selected' : ''}"
179
- cx="${anchorSvg.x}"
180
- cy="${anchorSvg.y}"
181
- data-index="${index}"
182
- data-role="point"
183
- title="Point P${index + 1}: ${Math.round(point.x * 100)}%, ${Math.round(point.y * 100)}%"
184
- />`);
185
- });
186
- return elements;
187
- }
188
- catch (error) {
189
- console.error('Error rendering linear points:', error);
190
- return [];
191
- }
192
- };
193
- #renderLinearHandle(elements, point, anchorSvg, index, direction) {
194
- const dx = direction === 'In' ? (point.cpInX ?? 0) : (point.cpOutX ?? 0);
195
- const dy = direction === 'In' ? (point.cpInY ?? 0) : (point.cpOutY ?? 0);
196
- const handlePos = { x: point.x + dx, y: point.y + dy };
197
- const handleSvg = this.#toSvgCoords(handlePos);
198
- const role = direction === 'In' ? 'handleIn' : 'handleOut';
199
- const dragMode = direction === 'In' ? 'handleIn' : 'handleOut';
200
- const isHandleActive = this.#dragMode === dragMode && this.#dragIndex === index;
201
- const handlePath = this.#createHandlePath(anchorSvg, handleSvg);
202
- if (!handlePath) {
203
- return;
204
- }
205
- elements.push((0, lit_html_1.svg) `<circle
206
- class="hit-area-handle"
207
- cx="${handleSvg.x}"
208
- cy="${handleSvg.y}"
209
- r="${constants_1.HIT_AREA_RADIUS}"
210
- data-index="${index}"
211
- data-role="${role}"
212
- />`);
213
- elements.push((0, lit_html_1.svg) `<path
214
- class="linear-handle ${isHandleActive ? 'selected' : ''}"
215
- d="${handlePath}"
216
- data-index="${index}"
217
- data-role="${role}"
218
- title="Handle ${direction}: ${Math.round(handlePos.x * 100)}%, ${Math.round(handlePos.y * 100)}%"
219
- />`);
220
- }
221
- #getCurvePath = () => {
222
- try {
223
- if (this.easingType === types_1.EasingType.CUBIC_BEZIER) {
224
- const points = this.#getCubicBezierPoints();
225
- if (!points) {
226
- console.warn('Invalid cubic-bezier points:', this.points);
227
- return '';
228
- }
229
- return (0, utils_1.cubicBezierPath)(points);
230
- }
231
- const points = this.#getLinearPoints();
232
- if (!points || points.length < 2) {
233
- return '';
234
- }
235
- if (this.simplify > 0) {
236
- const approxPoints = (0, utils_1.getLinearApproximation)(points, {
237
- simplify: this.simplify,
238
- round: this.round
239
- });
240
- return (0, utils_1.linearDisplayPath)(approxPoints);
241
- }
242
- return (0, utils_1.linearDisplayPath)(points);
243
- }
244
- catch (error) {
245
- console.error('Error generating curve path:', error);
246
- return '';
247
- }
248
- };
249
- #getHoverCurvePath = () => {
250
- if (this.#isDragging) {
251
- return '';
252
- }
253
- try {
254
- if (this.easingType === types_1.EasingType.CUBIC_BEZIER) {
255
- const hoverPoint = this.#hoverPoint;
256
- if (!hoverPoint) {
257
- return '';
258
- }
259
- const points = this.#getCubicBezierPoints();
260
- if (!points) {
261
- return '';
262
- }
263
- return (0, utils_1.cubicBezierPath)({
264
- p1: hoverPoint,
265
- p2: points.p2
266
- });
267
- }
268
- if (this.easingType === types_1.EasingType.LINEAR) {
269
- return this.#hoverInsertPreview?.path ?? '';
270
- }
271
- return '';
272
- }
273
- catch (error) {
274
- console.error('Error generating hover curve path:', error);
275
- return '';
276
- }
277
- };
278
- getHoverInsertElements() {
279
- if (this.easingType !== types_1.EasingType.LINEAR) {
280
- return null;
281
- }
282
- const preview = this.#hoverInsertPreview;
283
- if (!preview || !preview.insertedPoint) {
284
- return null;
285
- }
286
- const point = preview.insertedPoint;
287
- const anchor = this.#toSvgCoords(point);
288
- const elements = [];
289
- if (point.cpInX !== undefined || point.cpInY !== undefined) {
290
- const handlePoint = this.#toSvgCoords({
291
- x: point.x + (point.cpInX ?? 0),
292
- y: point.y + (point.cpInY ?? 0)
293
- });
294
- const handlePath = this.#createHandlePath(anchor, handlePoint);
295
- if (handlePath) {
296
- elements.push((0, lit_html_1.svg) `<path
297
- class="linear-handle linear-handle--preview"
298
- d="${handlePath}"
299
- />`);
300
- }
301
- }
302
- if (point.cpOutX !== undefined || point.cpOutY !== undefined) {
303
- const handlePoint = this.#toSvgCoords({
304
- x: point.x + (point.cpOutX ?? 0),
305
- y: point.y + (point.cpOutY ?? 0)
306
- });
307
- const handlePath = this.#createHandlePath(anchor, handlePoint);
308
- if (handlePath) {
309
- elements.push((0, lit_html_1.svg) `<path
310
- class="linear-handle linear-handle--preview"
311
- d="${handlePath}"
312
- />`);
313
- }
314
- }
315
- elements.push((0, lit_html_1.svg) `<circle class="linear-point linear-point--preview" cx="${anchor.x}" cy="${anchor.y}" />`);
316
- return (0, lit_html_1.svg) `<g class="linear-preview-group" pointer-events="none">${elements}</g>`;
317
- }
318
- #createHandlePath(anchorSvg, handleSvg) {
319
- const vecX = handleSvg.x - anchorSvg.x;
320
- const vecY = handleSvg.y - anchorSvg.y;
321
- const length = Math.sqrt(vecX * vecX + vecY * vecY);
322
- const circleRadius = 4.5;
323
- const barHalfHeight = 0.66;
324
- if (length < circleRadius + 2) {
325
- return null;
326
- }
327
- const dirX = vecX / length;
328
- const dirY = vecY / length;
329
- const perpX = -dirY;
330
- const perpY = dirX;
331
- const cx = handleSvg.x;
332
- const cy = handleSvg.y;
333
- const transitionZone = Math.min(8, (length - circleRadius) * 0.5);
334
- const barEndDist = length - circleRadius - transitionZone;
335
- const barTopStartX = anchorSvg.x + perpX * barHalfHeight;
336
- const barTopStartY = anchorSvg.y + perpY * barHalfHeight;
337
- const barBottomStartX = anchorSvg.x - perpX * barHalfHeight;
338
- const barBottomStartY = anchorSvg.y - perpY * barHalfHeight;
339
- const barTopEndX = anchorSvg.x + dirX * barEndDist + perpX * barHalfHeight;
340
- const barTopEndY = anchorSvg.y + dirY * barEndDist + perpY * barHalfHeight;
341
- const barBottomEndX = anchorSvg.x + dirX * barEndDist - perpX * barHalfHeight;
342
- const barBottomEndY = anchorSvg.y + dirY * barEndDist - perpY * barHalfHeight;
343
- const circleTopX = cx + perpX * circleRadius;
344
- const circleTopY = cy + perpY * circleRadius;
345
- const circleBottomX = cx - perpX * circleRadius;
346
- const circleBottomY = cy - perpY * circleRadius;
347
- const ctrl1Dist = transitionZone * 0.35;
348
- const ctrl2Dist = transitionZone * 0.65;
349
- const ctrl1TopX = barTopEndX + dirX * ctrl1Dist;
350
- const ctrl1TopY = barTopEndY + dirY * ctrl1Dist;
351
- const ctrl2TopX = circleTopX - dirX * ctrl2Dist;
352
- const ctrl2TopY = circleTopY - dirY * ctrl2Dist;
353
- const ctrl1BottomX = barBottomEndX + dirX * ctrl1Dist;
354
- const ctrl1BottomY = barBottomEndY + dirY * ctrl1Dist;
355
- const ctrl2BottomX = circleBottomX - dirX * ctrl2Dist;
356
- const ctrl2BottomY = circleBottomY - dirY * ctrl2Dist;
357
- return `
358
- M ${circleBottomX} ${circleBottomY}
359
- C ${ctrl2BottomX} ${ctrl2BottomY} ${ctrl1BottomX} ${ctrl1BottomY} ${barBottomEndX} ${barBottomEndY}
360
- L ${barBottomStartX} ${barBottomStartY}
361
- A ${barHalfHeight} ${barHalfHeight} 0 0 0 ${barTopStartX} ${barTopStartY}
362
- L ${barTopEndX} ${barTopEndY}
363
- C ${ctrl1TopX} ${ctrl1TopY} ${ctrl2TopX} ${ctrl2TopY} ${circleTopX} ${circleTopY}
364
- A ${circleRadius} ${circleRadius} 0 1 0 ${circleBottomX} ${circleBottomY}
365
- Z
366
- `;
367
- }
368
- #getCubicBezierPoints = () => {
369
- if (Array.isArray(this.points)) {
370
- return null;
371
- }
372
- return this.points ?? null;
373
- };
374
- #getLinearPoints = () => {
375
- if (!Array.isArray(this.points)) {
376
- return null;
377
- }
378
- this.#ensureLinearPointIds(this.points);
379
- return this.points;
380
- };
381
- #ensureLinearPointIds = (points) => {
382
- if (!points) {
383
- return;
384
- }
385
- for (const point of points) {
386
- if (!point) {
387
- continue;
388
- }
389
- (0, utils_1.ensureLinearPointId)(point);
390
- }
391
- };
392
- #createLinearStartPointMap = (points) => {
393
- if (!points) {
394
- return null;
395
- }
396
- const map = new Map();
397
- for (const point of points) {
398
- if (!point) {
399
- continue;
400
- }
401
- const id = (0, utils_1.ensureLinearPointId)(point);
402
- map.set(id, (0, utils_1.cloneLinearPoint)(point));
403
- }
404
- return map;
405
- };
406
- #getDistanceToLinearPath(point, points) {
407
- if (points.length < 2) {
408
- return Number.POSITIVE_INFINITY;
409
- }
410
- let minDistanceSquared = Number.POSITIVE_INFINITY;
411
- for (let index = 0; index < points.length - 1; index += 1) {
412
- const start = points[index];
413
- const end = points[index + 1];
414
- if (!start || !end) {
415
- continue;
416
- }
417
- const cp1 = {
418
- x: start.x + (start.cpOutX ?? 0),
419
- y: start.y + (start.cpOutY ?? 0)
420
- };
421
- const cp2 = {
422
- x: end.x + (end.cpInX ?? 0),
423
- y: end.y + (end.cpInY ?? 0)
424
- };
425
- for (let sample = 0; sample <= constants_1.LINEAR_PATH_SAMPLES; sample += 1) {
426
- const t = sample / constants_1.LINEAR_PATH_SAMPLES;
427
- const samplePoint = evaluateCubicPointNormalized(t, start, cp1, cp2, end);
428
- const dx = point.x - samplePoint.x;
429
- const dy = point.y - samplePoint.y;
430
- const distanceSquared = dx * dx + dy * dy;
431
- if (distanceSquared < minDistanceSquared) {
432
- minDistanceSquared = distanceSquared;
433
- }
434
- }
435
- }
436
- return Math.sqrt(minDistanceSquared);
437
- }
438
- #isPointNearLinearPath(point, points) {
439
- const distance = this.#getDistanceToLinearPath(point, points);
440
- return distance <= constants_1.LINEAR_HIT_THRESHOLD;
441
- }
442
- #isNearExistingPointOrHandle(position, points) {
443
- const mouseSvg = this.#toSvgCoords(position);
444
- const thresholdSquared = constants_1.HIT_AREA_RADIUS * constants_1.HIT_AREA_RADIUS;
445
- for (const point of points) {
446
- if (!point) {
447
- continue;
448
- }
449
- const pointSvg = this.#toSvgCoords(point);
450
- const dx = pointSvg.x - mouseSvg.x;
451
- const dy = pointSvg.y - mouseSvg.y;
452
- if (dx * dx + dy * dy < thresholdSquared) {
453
- return true;
454
- }
455
- if (point.cpInX !== undefined || point.cpInY !== undefined) {
456
- const handleIn = {
457
- x: point.x + (point.cpInX ?? 0),
458
- y: point.y + (point.cpInY ?? 0)
459
- };
460
- const handleInSvg = this.#toSvgCoords(handleIn);
461
- const hdx = handleInSvg.x - mouseSvg.x;
462
- const hdy = handleInSvg.y - mouseSvg.y;
463
- if (hdx * hdx + hdy * hdy < thresholdSquared) {
464
- return true;
465
- }
466
- }
467
- if (point.cpOutX !== undefined || point.cpOutY !== undefined) {
468
- const handleOut = {
469
- x: point.x + (point.cpOutX ?? 0),
470
- y: point.y + (point.cpOutY ?? 0)
471
- };
472
- const handleOutSvg = this.#toSvgCoords(handleOut);
473
- const hdx = handleOutSvg.x - mouseSvg.x;
474
- const hdy = handleOutSvg.y - mouseSvg.y;
475
- if (hdx * hdx + hdy * hdy < thresholdSquared) {
476
- return true;
477
- }
478
- }
479
- }
480
- return false;
481
- }
482
- #getMousePosition = (event, options) => {
483
- const svgElement = this.svgElement;
484
- if (!svgElement) {
485
- return { x: 0, y: 0 };
486
- }
487
- const rect = svgElement.getBoundingClientRect();
488
- const svgX = event.clientX - rect.left;
489
- const svgY = event.clientY - rect.top;
490
- let x = svgX / rect.width;
491
- let y = 1 - svgY / rect.height;
492
- const skipSnap = options?.skipSnap ?? false;
493
- const shouldSnap = !skipSnap &&
494
- this.snapToGrid &&
495
- !(this.#isDragging && (this.#dragMode === 'handleIn' || this.#dragMode === 'handleOut'));
496
- if (shouldSnap) {
497
- const ratioX = constants_1.SVG_WIDTH / this.gridSize;
498
- const ratioY = constants_1.SVG_HEIGHT / this.gridSize;
499
- x = Math.round(x * ratioX) / ratioX;
500
- y = Math.round(y * ratioY) / ratioY;
501
- }
502
- const bezierBounds = this.easingType === types_1.EasingType.CUBIC_BEZIER
503
- ? { minY: constants_1.BEZIER_CONTROL_MIN_Y, maxY: constants_1.BEZIER_CONTROL_MAX_Y }
504
- : undefined;
505
- return (0, utils_1.clampPoint)({ x, y }, bezierBounds);
506
- };
507
- #constrainLinearPoint = (index, position, points) => {
508
- let x = position.x;
509
- if (index === 0) {
510
- x = 0;
511
- }
512
- else if (index === points.length - 1) {
513
- x = 1;
514
- }
515
- else {
516
- x = Math.min(Math.max(x, utils_1.MIN_LINEAR_DELTA), 1 - utils_1.MIN_LINEAR_DELTA);
517
- }
518
- const clamped = (0, utils_1.clampPoint)({ x, y: position.y }, { minY: -2, maxY: 3 });
519
- const sourcePoint = points[index];
520
- return {
521
- ...sourcePoint,
522
- x: clamped.x,
523
- y: clamped.y
524
- };
525
- };
526
- #emitPoints = (value, event) => {
527
- const target = this.#getEventTarget();
528
- const detail = { value, event };
529
- (0, shared_1.dispatchControlEvent)(target, 'points-change', detail);
530
- };
531
- #notifyLinearFocus = (index, event) => {
532
- if (this.easingType !== types_1.EasingType.LINEAR) {
533
- return;
534
- }
535
- const target = this.#getEventTarget();
536
- const detail = { value: index, event };
537
- (0, shared_1.dispatchControlEvent)(target, 'linear-point-focus', detail);
538
- };
539
- #toggleLinearHandleLinking = (index, event) => {
540
- const points = this.#getLinearPoints();
541
- if (!points || index < 0 || index >= points.length) {
542
- return;
543
- }
544
- const point = points[index];
545
- if (!point) {
546
- return;
547
- }
548
- const updatedPoints = [...points];
549
- const updatedPoint = { ...point };
550
- updatedPoints[index] = updatedPoint;
551
- const newLinkingState = !updatedPoint.isLinked;
552
- updatedPoint.isLinked = newLinkingState;
553
- updatedPoint.mirrorLength = Boolean(newLinkingState);
554
- if (newLinkingState) {
555
- this.#ensureLinkedHandles(updatedPoint, index, points);
556
- }
557
- const normalizedPoints = (0, utils_1.normalizeLinearPoints)(updatedPoints);
558
- this.points = normalizedPoints;
559
- this.#emitPoints(normalizedPoints, event);
560
- this.#notifyLinearFocus(index, event);
561
- this.requestRender();
562
- };
563
- #ensureLinkedHandles(point, index, points) {
564
- const prev = points[index - 1];
565
- const next = points[index + 1];
566
- let refDx = point.cpOutX ?? -(point.cpInX ?? 0);
567
- let refDy = point.cpOutY ?? -(point.cpInY ?? 0);
568
- if (refDx === 0 && refDy === 0) {
569
- let dirX = 0;
570
- let dirY = 0;
571
- if (prev && next) {
572
- dirX = next.x - prev.x;
573
- dirY = next.y - prev.y;
574
- }
575
- else if (next) {
576
- dirX = next.x - point.x;
577
- dirY = next.y - point.y;
578
- }
579
- else if (prev) {
580
- dirX = point.x - prev.x;
581
- dirY = point.y - prev.y;
582
- }
583
- else {
584
- dirX = 1;
585
- dirY = 0;
586
- }
587
- const direction = (0, utils_1.normalizeVector)(dirX, dirY);
588
- const length = constants_1.DEFAULT_HANDLE_LENGTH;
589
- point.cpInX = -direction.dx * length;
590
- point.cpInY = -direction.dy * length;
591
- point.cpOutX = direction.dx * length;
592
- point.cpOutY = direction.dy * length;
593
- refDx = point.cpOutX;
594
- refDy = point.cpOutY;
595
- }
596
- if (refDx === 0 && refDy === 0) {
597
- return;
598
- }
599
- const normalized = (0, utils_1.normalizeVector)(refDx, refDy);
600
- const referenceLength = (0, utils_1.vectorLength)(refDx, refDy) || constants_1.DEFAULT_HANDLE_LENGTH;
601
- const inLength = (0, utils_1.vectorLength)(point.cpInX ?? 0, point.cpInY ?? 0) || referenceLength;
602
- point.cpInX = -normalized.dx * inLength;
603
- point.cpInY = -normalized.dy * inLength;
604
- const outLength = (0, utils_1.vectorLength)(point.cpOutX ?? 0, point.cpOutY ?? 0) || referenceLength;
605
- point.cpOutX = normalized.dx * outLength;
606
- point.cpOutY = normalized.dy * outLength;
607
- if (point.mirrorLength !== false) {
608
- this.#alignLinkedHandleLengths(point);
609
- }
610
- }
611
- #alignLinkedHandleLengths(point) {
612
- if (!point.isLinked) {
613
- point.mirrorLength = false;
614
- return;
615
- }
616
- const outLength = (0, utils_1.vectorLength)(point.cpOutX ?? 0, point.cpOutY ?? 0);
617
- const inLength = (0, utils_1.vectorLength)(point.cpInX ?? 0, point.cpInY ?? 0);
618
- const targetLength = Math.max(outLength, inLength);
619
- if (targetLength <= 0) {
620
- return;
621
- }
622
- if (outLength > 0) {
623
- const outDirection = (0, utils_1.normalizeVector)(point.cpOutX ?? 0, point.cpOutY ?? 0);
624
- point.cpOutX = outDirection.dx * targetLength;
625
- point.cpOutY = outDirection.dy * targetLength;
626
- }
627
- else if (inLength > 0) {
628
- const inDirection = (0, utils_1.normalizeVector)(point.cpInX ?? 0, point.cpInY ?? 0);
629
- point.cpOutX = -inDirection.dx * targetLength;
630
- point.cpOutY = -inDirection.dy * targetLength;
631
- }
632
- if (inLength > 0) {
633
- const inDirection = (0, utils_1.normalizeVector)(point.cpInX ?? 0, point.cpInY ?? 0);
634
- point.cpInX = inDirection.dx * targetLength;
635
- point.cpInY = inDirection.dy * targetLength;
636
- }
637
- else if (outLength > 0) {
638
- const outDirection = (0, utils_1.normalizeVector)(point.cpOutX ?? 0, point.cpOutY ?? 0);
639
- point.cpInX = -outDirection.dx * targetLength;
640
- point.cpInY = -outDirection.dy * targetLength;
641
- }
642
- }
643
- getGridLines() {
644
- return (0, svg_renderer_1.generateGridLines)(this.gridSize);
645
- }
646
- getControlElements() {
647
- return this.easingType === types_1.EasingType.CUBIC_BEZIER ? this.#renderCubicBezier() : this.#renderLinear();
648
- }
649
- getCurvePath() {
650
- return this.#getCurvePath();
651
- }
652
- getHoverCurvePath() {
653
- return this.#getHoverCurvePath();
654
- }
655
- handlePointerDown = (event) => {
656
- event.preventDefault();
657
- let linearPoints = this.easingType === types_1.EasingType.LINEAR ? this.#getLinearPoints() : null;
658
- this.#dragStartPoints = this.#createLinearStartPointMap(linearPoints);
659
- this.#pendingDrag = null;
660
- this.#dragPointId = null;
661
- const target = event.target;
662
- if (!(target instanceof SVGElement)) {
663
- return;
664
- }
665
- const role = target.getAttribute('data-role');
666
- const indexAttribute = target.getAttribute('data-index');
667
- if (indexAttribute !== null) {
668
- const index = Number.parseInt(indexAttribute, 10);
669
- if (Number.isNaN(index)) {
670
- return;
671
- }
672
- if (this.easingType === types_1.EasingType.LINEAR) {
673
- if (role === 'handleIn' || role === 'handleOut') {
674
- const point = linearPoints?.[index];
675
- if (point) {
676
- this.#dragPointId = (0, utils_1.ensureLinearPointId)(point);
677
- }
678
- this.svgElement?.setPointerCapture(event.pointerId);
679
- this.#isDragging = true;
680
- this.#dragMode = role;
681
- this.#dragIndex = index;
682
- this.#pendingDrag = null;
683
- this.#hoverPoint = null;
684
- this.#notifyLinearFocus(index, event);
685
- this.handlePointerMove(event);
686
- this.requestRender();
687
- return;
688
- }
689
- if (role === 'point') {
690
- if (event.detail === 2) {
691
- this.#toggleLinearHandleLinking(index, event);
692
- return;
693
- }
694
- const point = linearPoints?.[index];
695
- if (point) {
696
- this.#dragPointId = (0, utils_1.ensureLinearPointId)(point);
697
- }
698
- this.#notifyLinearFocus(index, event);
699
- this.svgElement?.setPointerCapture(event.pointerId);
700
- this.#isDragging = false;
701
- this.#dragMode = 'point';
702
- this.#dragIndex = index;
703
- this.#pendingDrag = {
704
- mode: 'point',
705
- index,
706
- startX: event.clientX,
707
- startY: event.clientY
708
- };
709
- this.#hoverPoint = null;
710
- this.requestRender();
711
- return;
712
- }
713
- }
714
- if (this.easingType === types_1.EasingType.CUBIC_BEZIER && role === 'point') {
715
- this.svgElement?.setPointerCapture(event.pointerId);
716
- this.#isDragging = true;
717
- this.#dragMode = 'point';
718
- this.#dragIndex = index;
719
- this.#hoverPoint = null;
720
- this.requestRender();
721
- return;
722
- }
723
- }
724
- if (indexAttribute === null) {
725
- if (this.easingType === types_1.EasingType.LINEAR) {
726
- const insertResult = this.#insertLinearPoint(this.#getMousePosition(event), event);
727
- if (insertResult) {
728
- linearPoints = this.#getLinearPoints();
729
- this.#dragStartPoints = this.#createLinearStartPointMap(linearPoints);
730
- this.#dragPointId = insertResult.pointId;
731
- this.svgElement?.setPointerCapture(event.pointerId);
732
- this.#isDragging = true;
733
- this.#dragMode = 'point';
734
- this.#dragIndex = insertResult.index;
735
- this.#pendingDrag = null;
736
- this.#hoverPoint = null;
737
- this.#notifyLinearFocus(insertResult.index, event);
738
- this.requestRender();
739
- return;
740
- }
741
- else {
742
- this.#notifyLinearFocus(null, event);
743
- }
744
- }
745
- if (this.easingType === types_1.EasingType.CUBIC_BEZIER) {
746
- this.#hoverPoint = this.#getMousePosition(event);
747
- this.svgElement?.setPointerCapture(event.pointerId);
748
- this.#isDragging = true;
749
- this.#dragMode = 'point';
750
- this.#dragIndex = 0;
751
- this.#pendingDrag = null;
752
- this.handlePointerMove(event);
753
- this.requestRender();
754
- return;
755
- }
756
- }
757
- };
758
- handlePointerMove = (event) => {
759
- if (!this.svgElement) {
760
- return;
761
- }
762
- const skipSnapForPending = !this.#isDragging && this.#pendingDrag !== null && this.#pendingDrag.mode === 'point';
763
- let position = this.#getMousePosition(event, { skipSnap: skipSnapForPending });
764
- if (this.#pendingDrag && !this.#isDragging) {
765
- const deltaX = event.clientX - this.#pendingDrag.startX;
766
- const deltaY = event.clientY - this.#pendingDrag.startY;
767
- const distanceSquared = deltaX * deltaX + deltaY * deltaY;
768
- if (distanceSquared >= constants_1.DRAG_ACTIVATION_DISTANCE_PX_SQUARED) {
769
- this.#isDragging = true;
770
- this.#pendingDrag = null;
771
- if (skipSnapForPending) {
772
- position = this.#getMousePosition(event);
773
- }
774
- }
775
- else {
776
- return;
777
- }
778
- }
779
- if (this.#isDragging && this.#dragIndex !== null) {
780
- event.preventDefault();
781
- this.#hoverInsertPreview = null;
782
- if (this.easingType === types_1.EasingType.LINEAR) {
783
- const points = this.#getLinearPoints();
784
- if (!points || this.#dragIndex >= points.length) {
785
- return;
786
- }
787
- if (this.#dragMode === 'point') {
788
- this.#handleLinearPointDrag(points, this.#dragIndex, position, event);
789
- return;
790
- }
791
- if (this.#dragMode === 'handleIn' || this.#dragMode === 'handleOut') {
792
- this.#handleLinearHandleDrag(points, this.#dragIndex, position, event);
793
- return;
794
- }
795
- }
796
- if (this.easingType === types_1.EasingType.CUBIC_BEZIER) {
797
- const points = this.#getCubicBezierPoints();
798
- if (!points) {
799
- return;
800
- }
801
- const updatedPoints = { ...points };
802
- let adjustedPosition = position;
803
- if (event.shiftKey) {
804
- const reference = this.#dragIndex === 0 ? points.p1 : points.p2;
805
- if (reference) {
806
- const deltaX = Math.abs(position.x - reference.x);
807
- const deltaY = Math.abs(position.y - reference.y);
808
- adjustedPosition = deltaX > deltaY ? { x: position.x, y: reference.y } : { x: reference.x, y: position.y };
809
- }
810
- }
811
- const clampedPosition = (0, utils_1.clampPoint)(adjustedPosition, {
812
- minY: constants_1.BEZIER_CONTROL_MIN_Y,
813
- maxY: constants_1.BEZIER_CONTROL_MAX_Y
814
- });
815
- if (this.#dragIndex === 0) {
816
- updatedPoints.p1 = clampedPosition;
817
- }
818
- else if (this.#dragIndex === 1) {
819
- updatedPoints.p2 = clampedPosition;
820
- }
821
- else {
822
- return;
823
- }
824
- this.points = updatedPoints;
825
- this.#emitPoints(updatedPoints, event);
826
- this.requestRender();
827
- return;
828
- }
829
- return;
830
- }
831
- if (this.easingType === types_1.EasingType.LINEAR) {
832
- const points = this.#getLinearPoints();
833
- // Use rawPosition for the hit test to avoid flickering when snapToGrid is on
834
- if (points && this.#isNearExistingPointOrHandle(position, points)) {
835
- this.#hoverInsertPreview = null;
836
- this.#hoverPoint = null;
837
- this.requestRender();
838
- return;
839
- }
840
- const preview = this.#buildLinearInsertPreview(position);
841
- this.#hoverInsertPreview = preview;
842
- if (!preview) {
843
- this.#hoverPoint = null;
844
- this.requestRender();
845
- return;
846
- }
847
- }
848
- else {
849
- this.#hoverInsertPreview = null;
850
- }
851
- this.#hoverPoint = position;
852
- this.requestRender();
853
- };
854
- #handleLinearPointDrag(points, index, position, event) {
855
- let workingPosition = position;
856
- const currentPoint = points[index];
857
- const activePointId = currentPoint ? (this.#dragPointId ?? (0, utils_1.ensureLinearPointId)(currentPoint)) : null;
858
- if (event.shiftKey && this.#dragStartPoints && activePointId) {
859
- const startPoint = this.#dragStartPoints.get(activePointId);
860
- if (startPoint) {
861
- const deltaX = Math.abs(position.x - startPoint.x);
862
- const deltaY = Math.abs(position.y - startPoint.y);
863
- workingPosition = deltaX > deltaY ? { x: position.x, y: startPoint.y } : { x: startPoint.x, y: position.y };
864
- }
865
- }
866
- const constrainedPoint = this.#constrainLinearPoint(index, workingPosition, points);
867
- const updatedPoints = points.map((point, i) => {
868
- if (i === index) {
869
- return constrainedPoint;
870
- }
871
- return { ...point };
872
- });
873
- const normalizedPoints = (0, utils_1.normalizeLinearPoints)(updatedPoints);
874
- this.points = normalizedPoints;
875
- this.#emitPoints(normalizedPoints, event);
876
- if (activePointId) {
877
- const newIndex = normalizedPoints.findIndex((point) => point?.id === activePointId);
878
- if (newIndex !== -1) {
879
- this.#dragIndex = newIndex;
880
- this.#dragPointId = activePointId;
881
- this.#notifyLinearFocus(newIndex, event);
882
- }
883
- else {
884
- this.#notifyLinearFocus(index, event);
885
- }
886
- }
887
- else {
888
- this.#notifyLinearFocus(index, event);
889
- }
890
- this.requestRender();
891
- }
892
- #handleLinearHandleDrag(points, index, position, event) {
893
- const point = points[index];
894
- if (!point) {
895
- return;
896
- }
897
- const activePointId = this.#dragPointId ?? (0, utils_1.ensureLinearPointId)(point);
898
- const direction = this.#dragMode === 'handleIn' ? 'In' : 'Out';
899
- let dx = position.x - point.x;
900
- const dy = position.y - point.y;
901
- if (direction === 'In') {
902
- dx = Math.min(0, dx);
903
- }
904
- else {
905
- dx = Math.max(0, dx);
906
- }
907
- let isLinked = point.isLinked ?? false;
908
- if (event.shiftKey) {
909
- isLinked = false;
910
- }
911
- const updatedPoints = [...points];
912
- const updatedPoint = { ...point };
913
- updatedPoints[index] = updatedPoint;
914
- updatedPoint.isLinked = isLinked;
915
- if (direction === 'In') {
916
- updatedPoint.cpInX = dx;
917
- updatedPoint.cpInY = dy;
918
- }
919
- else {
920
- updatedPoint.cpOutX = dx;
921
- updatedPoint.cpOutY = dy;
922
- }
923
- const mirrorAngle = isLinked;
924
- const mirrorLength = mirrorAngle && updatedPoint.mirrorLength !== false;
925
- if (mirrorAngle || mirrorLength) {
926
- const draggedLength = (0, utils_1.vectorLength)(dx, dy);
927
- if (draggedLength <= utils_1.MIN_LINEAR_DELTA) {
928
- if (direction === 'In') {
929
- delete updatedPoint.cpInX;
930
- delete updatedPoint.cpInY;
931
- if (mirrorAngle) {
932
- delete updatedPoint.cpOutX;
933
- delete updatedPoint.cpOutY;
934
- }
935
- }
936
- else {
937
- delete updatedPoint.cpOutX;
938
- delete updatedPoint.cpOutY;
939
- if (mirrorAngle) {
940
- delete updatedPoint.cpInX;
941
- delete updatedPoint.cpInY;
942
- }
943
- }
944
- }
945
- else {
946
- const normalized = (0, utils_1.normalizeVector)(dx, dy);
947
- if (mirrorAngle) {
948
- if (direction === 'In') {
949
- const existingLength = mirrorLength
950
- ? draggedLength
951
- : (0, utils_1.vectorLength)(updatedPoint.cpOutX ?? 0, updatedPoint.cpOutY ?? 0) || draggedLength;
952
- updatedPoint.cpOutX = -normalized.dx * existingLength;
953
- updatedPoint.cpOutY = -normalized.dy * existingLength;
954
- }
955
- else {
956
- const existingLength = mirrorLength
957
- ? draggedLength
958
- : (0, utils_1.vectorLength)(updatedPoint.cpInX ?? 0, updatedPoint.cpInY ?? 0) || draggedLength;
959
- updatedPoint.cpInX = -normalized.dx * existingLength;
960
- updatedPoint.cpInY = -normalized.dy * existingLength;
961
- }
962
- }
963
- else if (mirrorLength) {
964
- if (direction === 'In') {
965
- const inDirection = (0, utils_1.normalizeVector)(updatedPoint.cpInX ?? 0, updatedPoint.cpInY ?? 0);
966
- const outDirection = (0, utils_1.normalizeVector)(updatedPoint.cpOutX ?? 0, updatedPoint.cpOutY ?? 0);
967
- const outLength = (0, utils_1.vectorLength)(updatedPoint.cpOutX ?? 0, updatedPoint.cpOutY ?? 0);
968
- if (outLength > 0) {
969
- updatedPoint.cpOutX = outDirection.dx * draggedLength;
970
- updatedPoint.cpOutY = outDirection.dy * draggedLength;
971
- }
972
- updatedPoint.cpInX = inDirection.dx * draggedLength;
973
- updatedPoint.cpInY = inDirection.dy * draggedLength;
974
- }
975
- else {
976
- const inDirection = (0, utils_1.normalizeVector)(updatedPoint.cpInX ?? 0, updatedPoint.cpInY ?? 0);
977
- const outDirection = (0, utils_1.normalizeVector)(updatedPoint.cpOutX ?? 0, updatedPoint.cpOutY ?? 0);
978
- const inLength = (0, utils_1.vectorLength)(updatedPoint.cpInX ?? 0, updatedPoint.cpInY ?? 0);
979
- if (inLength > 0) {
980
- updatedPoint.cpInX = inDirection.dx * draggedLength;
981
- updatedPoint.cpInY = inDirection.dy * draggedLength;
982
- }
983
- updatedPoint.cpOutX = outDirection.dx * draggedLength;
984
- updatedPoint.cpOutY = outDirection.dy * draggedLength;
985
- }
986
- }
987
- if (mirrorLength) {
988
- this.#alignLinkedHandleLengths(updatedPoint);
989
- }
990
- }
991
- }
992
- const normalizedPoints = (0, utils_1.normalizeLinearPoints)(updatedPoints);
993
- this.points = normalizedPoints;
994
- this.#emitPoints(normalizedPoints, event);
995
- if (activePointId) {
996
- const newIndex = normalizedPoints.findIndex((candidate) => candidate?.id === activePointId);
997
- if (newIndex !== -1) {
998
- this.#dragIndex = newIndex;
999
- this.#dragPointId = activePointId;
1000
- this.#notifyLinearFocus(newIndex, event);
1001
- }
1002
- else {
1003
- this.#notifyLinearFocus(index, event);
1004
- }
1005
- }
1006
- else {
1007
- this.#notifyLinearFocus(index, event);
1008
- }
1009
- this.requestRender();
1010
- }
1011
- handlePointerUp = (event) => {
1012
- const previousIndex = this.#dragIndex;
1013
- if (this.svgElement?.hasPointerCapture(event.pointerId)) {
1014
- this.svgElement.releasePointerCapture(event.pointerId);
1015
- }
1016
- this.#isDragging = false;
1017
- this.#dragIndex = null;
1018
- this.#dragMode = null;
1019
- this.#dragStartPoints = null;
1020
- this.#dragPointId = null;
1021
- this.#pendingDrag = null;
1022
- this.#hoverInsertPreview = null;
1023
- if (previousIndex !== null && this.easingType === types_1.EasingType.LINEAR) {
1024
- this.#notifyLinearFocus(previousIndex, event);
1025
- }
1026
- this.requestRender();
1027
- };
1028
- handlePointerLeave = (event) => {
1029
- if (this.#isDragging) {
1030
- this.handlePointerUp(event);
1031
- }
1032
- this.#pendingDrag = null;
1033
- this.#hoverPoint = null;
1034
- this.#dragPointId = null;
1035
- this.#hoverInsertPreview = null;
1036
- this.requestRender();
1037
- };
1038
- #insertLinearPoint(position, event) {
1039
- const preview = this.#hoverInsertPreview ?? this.#buildLinearInsertPreview(position);
1040
- if (!preview) {
1041
- return null;
1042
- }
1043
- const { normalizedPoints, insertedIndex, insertedPoint } = preview;
1044
- const insertedPointId = insertedPoint ? (0, utils_1.ensureLinearPointId)(insertedPoint) : null;
1045
- this.points = normalizedPoints;
1046
- this.#emitPoints(normalizedPoints, event);
1047
- this.requestRender();
1048
- this.#hoverInsertPreview = null;
1049
- return {
1050
- index: insertedIndex,
1051
- pointId: insertedPointId
1052
- };
1053
- }
1054
- #buildLinearInsertPreview(position) {
1055
- if (this.easingType !== types_1.EasingType.LINEAR) {
1056
- return null;
1057
- }
1058
- const points = this.#getLinearPoints();
1059
- if (!points || points.length >= types_1.MAX_LINEAR_POINTS) {
1060
- return null;
1061
- }
1062
- // Allow Y values outside [0, 1] for bounce/elastic effects
1063
- const clamped = (0, utils_1.clampPoint)(position, { minY: -2, maxY: 3 });
1064
- if (!this.#isPointNearLinearPath(clamped, points)) {
1065
- return null;
1066
- }
1067
- const insertIndex = points.findIndex((point) => clamped.x < point.x);
1068
- if (insertIndex <= 0) {
1069
- return null;
1070
- }
1071
- const prev = points[insertIndex - 1];
1072
- const next = points[insertIndex];
1073
- if (!prev || !next) {
1074
- return null;
1075
- }
1076
- if (clamped.x - prev.x < utils_1.MIN_LINEAR_DELTA || next.x - clamped.x < utils_1.MIN_LINEAR_DELTA) {
1077
- return null;
1078
- }
1079
- let updatedPoints;
1080
- let insertedPointId = null;
1081
- const splitResult = splitCurveSegment(prev, next, clamped);
1082
- if (splitResult) {
1083
- const { prev: newPrev, newPoint, next: newNext } = splitResult;
1084
- insertedPointId = (0, utils_1.ensureLinearPointId)(newPoint);
1085
- updatedPoints = [
1086
- ...points.slice(0, insertIndex - 1),
1087
- newPrev,
1088
- newPoint,
1089
- newNext,
1090
- ...points.slice(insertIndex + 1)
1091
- ];
1092
- }
1093
- else {
1094
- const newPoint = {
1095
- x: clamped.x,
1096
- y: clamped.y,
1097
- cpInX: -0.1,
1098
- cpInY: 0,
1099
- cpOutX: 0.1,
1100
- cpOutY: 0,
1101
- isLinked: true,
1102
- mirrorLength: true
1103
- };
1104
- insertedPointId = (0, utils_1.ensureLinearPointId)(newPoint);
1105
- updatedPoints = [...points.slice(0, insertIndex), newPoint, ...points.slice(insertIndex)];
1106
- }
1107
- const normalizedPoints = (0, utils_1.normalizeLinearPoints)(updatedPoints);
1108
- const normalizedIndex = insertedPointId !== null ? normalizedPoints.findIndex((point) => point?.id === insertedPointId) : -1;
1109
- const insertedIndex = normalizedIndex !== -1 ? normalizedIndex : insertIndex;
1110
- const insertedPoint = normalizedPoints[insertedIndex];
1111
- if (!insertedPoint) {
1112
- return null;
1113
- }
1114
- return {
1115
- path: (0, utils_1.linearDisplayPath)(normalizedPoints),
1116
- normalizedPoints,
1117
- insertedIndex,
1118
- insertedPoint
1119
- };
1120
- }
1121
- }
1122
- exports.CurveCanvas = CurveCanvas;
1123
- const lerp = (a, b, t) => a + (b - a) * t;
1124
- const lerpPoint = (p1, p2, t) => {
1125
- return {
1126
- x: lerp(p1.x, p2.x, t),
1127
- y: lerp(p1.y, p2.y, t)
1128
- };
1129
- };
1130
- // Helper to find t for a given x on a cubic bezier curve
1131
- const findTForX = (x, p0, cp1, cp2, p3) => {
1132
- let minT = 0;
1133
- let maxT = 1;
1134
- let t = 0.5;
1135
- const tolerance = 0.0001;
1136
- const maxIterations = 20;
1137
- // Use binary search since x is monotonic
1138
- for (let i = 0; i < maxIterations; i++) {
1139
- const px = (1 - t) ** 3 * p0.x + 3 * (1 - t) ** 2 * t * cp1.x + 3 * (1 - t) * t ** 2 * cp2.x + t ** 3 * p3.x;
1140
- if (Math.abs(px - x) < tolerance) {
1141
- return t;
1142
- }
1143
- if (px < x) {
1144
- minT = t;
1145
- }
1146
- else {
1147
- maxT = t;
1148
- }
1149
- t = (minT + maxT) / 2;
1150
- }
1151
- return t;
1152
- };
1153
- const splitCurveSegment = (prev, next, position) => {
1154
- const cp1 = {
1155
- x: prev.x + (prev.cpOutX ?? 0),
1156
- y: prev.y + (prev.cpOutY ?? 0)
1157
- };
1158
- const cp2 = {
1159
- x: next.x + (next.cpInX ?? 0),
1160
- y: next.y + (next.cpInY ?? 0)
1161
- };
1162
- const wasCurved = prev.cpOutX || prev.cpOutY || next.cpInX || next.cpInY;
1163
- if (!wasCurved) {
1164
- return null;
1165
- }
1166
- // Find the correct t parameter that corresponds to the mouse X position
1167
- const t = findTForX(position.x, prev, cp1, cp2, next);
1168
- const P01 = lerpPoint(prev, cp1, t);
1169
- const P12 = lerpPoint(cp1, cp2, t);
1170
- const P23 = lerpPoint(cp2, next, t);
1171
- const P012 = lerpPoint(P01, P12, t);
1172
- const P123 = lerpPoint(P12, P23, t);
1173
- const P_new = lerpPoint(P012, P123, t);
1174
- const newPoint = {
1175
- x: P_new.x,
1176
- y: P_new.y,
1177
- cpInX: P012.x - P_new.x,
1178
- cpInY: P012.y - P_new.y,
1179
- cpOutX: P123.x - P_new.x,
1180
- cpOutY: P123.y - P_new.y,
1181
- isLinked: true,
1182
- mirrorLength: prev.mirrorLength === false && next.mirrorLength
1183
- };
1184
- (0, utils_1.ensureLinearPointId)(newPoint);
1185
- const newPrev = {
1186
- ...prev,
1187
- cpOutX: P01.x - prev.x,
1188
- cpOutY: P01.y - prev.y
1189
- };
1190
- const newNext = {
1191
- ...next,
1192
- cpInX: P23.x - next.x,
1193
- cpInY: P23.y - next.y
1194
- };
1195
- return {
1196
- prev: newPrev,
1197
- newPoint,
1198
- next: newNext
1199
- };
1200
- };
1201
- const evaluateCubicPointNormalized = (t, p0, cp1, cp2, p3) => {
1202
- const P01 = lerpPoint(p0, cp1, t);
1203
- const P12 = lerpPoint(cp1, cp2, t);
1204
- const P23 = lerpPoint(cp2, p3, t);
1205
- const P012 = lerpPoint(P01, P12, t);
1206
- const P123 = lerpPoint(P12, P23, t);
1207
- return lerpPoint(P012, P123, t);
1208
- };