@pie-lib/graphing 4.0.5-next.31 → 4.0.5-next.34

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 (453) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +1469 -0
  3. package/LICENSE.md +5 -0
  4. package/lib/axis/arrow.js +79 -0
  5. package/lib/axis/arrow.js.map +1 -0
  6. package/lib/axis/axes.js +329 -0
  7. package/lib/axis/axes.js.map +1 -0
  8. package/lib/axis/index.js +21 -0
  9. package/lib/axis/index.js.map +1 -0
  10. package/lib/bg.js +114 -0
  11. package/lib/bg.js.map +1 -0
  12. package/lib/container/actions.js +18 -0
  13. package/lib/container/actions.js.map +1 -0
  14. package/lib/container/index.js +127 -0
  15. package/lib/container/index.js.map +1 -0
  16. package/lib/container/marks.js +22 -0
  17. package/lib/container/marks.js.map +1 -0
  18. package/lib/container/middleware.js +19 -0
  19. package/lib/container/middleware.js.map +1 -0
  20. package/lib/container/reducer.js +18 -0
  21. package/lib/container/reducer.js.map +1 -0
  22. package/lib/coordinates-label.js +79 -0
  23. package/lib/coordinates-label.js.map +1 -0
  24. package/lib/graph-with-controls.js +294 -0
  25. package/lib/graph-with-controls.js.map +1 -0
  26. package/lib/graph.js +327 -0
  27. package/lib/graph.js.map +1 -0
  28. package/lib/grid-setup.js +414 -0
  29. package/lib/grid-setup.js.map +1 -0
  30. package/lib/grid.js +131 -0
  31. package/lib/grid.js.map +1 -0
  32. package/lib/index.js +47 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/key-legend.js +201 -0
  35. package/lib/key-legend.js.map +1 -0
  36. package/lib/label-svg-icon.js +50 -0
  37. package/lib/label-svg-icon.js.map +1 -0
  38. package/lib/labels.js +243 -0
  39. package/lib/labels.js.map +1 -0
  40. package/lib/mark-label.js +285 -0
  41. package/lib/mark-label.js.map +1 -0
  42. package/lib/toggle-bar.js +252 -0
  43. package/lib/toggle-bar.js.map +1 -0
  44. package/lib/tool-menu.js +78 -0
  45. package/lib/tool-menu.js.map +1 -0
  46. package/lib/tools/absolute/component.js +29 -0
  47. package/lib/tools/absolute/component.js.map +1 -0
  48. package/lib/tools/absolute/index.js +50 -0
  49. package/lib/tools/absolute/index.js.map +1 -0
  50. package/lib/tools/circle/bg-circle.js +123 -0
  51. package/lib/tools/circle/bg-circle.js.map +1 -0
  52. package/lib/tools/circle/component.js +321 -0
  53. package/lib/tools/circle/component.js.map +1 -0
  54. package/lib/tools/circle/index.js +41 -0
  55. package/lib/tools/circle/index.js.map +1 -0
  56. package/lib/tools/exponential/component.js +28 -0
  57. package/lib/tools/exponential/component.js.map +1 -0
  58. package/lib/tools/exponential/index.js +56 -0
  59. package/lib/tools/exponential/index.js.map +1 -0
  60. package/lib/tools/index.js +86 -0
  61. package/lib/tools/index.js.map +1 -0
  62. package/lib/tools/line/component.js +97 -0
  63. package/lib/tools/line/component.js.map +1 -0
  64. package/lib/tools/line/index.js +11 -0
  65. package/lib/tools/line/index.js.map +1 -0
  66. package/lib/tools/parabola/component.js +28 -0
  67. package/lib/tools/parabola/component.js.map +1 -0
  68. package/lib/tools/parabola/index.js +50 -0
  69. package/lib/tools/parabola/index.js.map +1 -0
  70. package/lib/tools/point/component.js +148 -0
  71. package/lib/tools/point/component.js.map +1 -0
  72. package/lib/tools/point/index.js +24 -0
  73. package/lib/tools/point/index.js.map +1 -0
  74. package/lib/tools/polygon/component.js +437 -0
  75. package/lib/tools/polygon/component.js.map +1 -0
  76. package/lib/tools/polygon/index.js +89 -0
  77. package/lib/tools/polygon/index.js.map +1 -0
  78. package/lib/tools/polygon/line.js +112 -0
  79. package/lib/tools/polygon/line.js.map +1 -0
  80. package/lib/tools/polygon/polygon.js +130 -0
  81. package/lib/tools/polygon/polygon.js.map +1 -0
  82. package/lib/tools/ray/component.js +95 -0
  83. package/lib/tools/ray/component.js.map +1 -0
  84. package/lib/tools/ray/index.js +11 -0
  85. package/lib/tools/ray/index.js.map +1 -0
  86. package/lib/tools/segment/component.js +71 -0
  87. package/lib/tools/segment/component.js.map +1 -0
  88. package/lib/tools/segment/index.js +11 -0
  89. package/lib/tools/segment/index.js.map +1 -0
  90. package/lib/tools/shared/arrow-head.js +111 -0
  91. package/lib/tools/shared/arrow-head.js.map +1 -0
  92. package/lib/tools/shared/icons/CorrectSVG.js +40 -0
  93. package/lib/tools/shared/icons/CorrectSVG.js.map +1 -0
  94. package/lib/tools/shared/icons/IncorrectSVG.js +40 -0
  95. package/lib/tools/shared/icons/IncorrectSVG.js.map +1 -0
  96. package/lib/tools/shared/icons/MissingSVG.js +39 -0
  97. package/lib/tools/shared/icons/MissingSVG.js.map +1 -0
  98. package/lib/tools/shared/line/index.js +550 -0
  99. package/lib/tools/shared/line/index.js.map +1 -0
  100. package/lib/tools/shared/line/line-path.js +118 -0
  101. package/lib/tools/shared/line/line-path.js.map +1 -0
  102. package/lib/tools/shared/line/with-root-edge.js +121 -0
  103. package/lib/tools/shared/line/with-root-edge.js.map +1 -0
  104. package/lib/tools/shared/point/arrow-point.js +72 -0
  105. package/lib/tools/shared/point/arrow-point.js.map +1 -0
  106. package/lib/tools/shared/point/arrow.js +67 -0
  107. package/lib/tools/shared/point/arrow.js.map +1 -0
  108. package/lib/tools/shared/point/base-point.js +157 -0
  109. package/lib/tools/shared/point/base-point.js.map +1 -0
  110. package/lib/tools/shared/point/index.js +68 -0
  111. package/lib/tools/shared/point/index.js.map +1 -0
  112. package/lib/tools/shared/styles.js +33 -0
  113. package/lib/tools/shared/styles.js.map +1 -0
  114. package/lib/tools/shared/types.js +16 -0
  115. package/lib/tools/shared/types.js.map +1 -0
  116. package/lib/tools/sine/component.js +40 -0
  117. package/lib/tools/sine/component.js.map +1 -0
  118. package/lib/tools/sine/index.js +50 -0
  119. package/lib/tools/sine/index.js.map +1 -0
  120. package/lib/tools/vector/component.js +68 -0
  121. package/lib/tools/vector/component.js.map +1 -0
  122. package/lib/tools/vector/index.js +11 -0
  123. package/lib/tools/vector/index.js.map +1 -0
  124. package/lib/undo-redo.js +86 -0
  125. package/lib/undo-redo.js.map +1 -0
  126. package/lib/use-debounce.js +25 -0
  127. package/lib/use-debounce.js.map +1 -0
  128. package/lib/utils.js +229 -0
  129. package/lib/utils.js.map +1 -0
  130. package/package.json +33 -45
  131. package/src/__tests__/bg.test.jsx +250 -0
  132. package/src/__tests__/coordinates-label.test.jsx +243 -0
  133. package/src/__tests__/graph-with-controls.test.jsx +198 -0
  134. package/src/__tests__/graph.test.jsx +721 -0
  135. package/src/__tests__/grid-setup.test.jsx +645 -0
  136. package/src/__tests__/grid.test.jsx +22 -0
  137. package/src/__tests__/key-legend.test.jsx +260 -0
  138. package/src/__tests__/label-svg-icon.test.jsx +278 -0
  139. package/src/__tests__/labels.test.jsx +55 -0
  140. package/src/__tests__/mark-label.test.jsx +63 -0
  141. package/src/__tests__/toggle-bar.test.jsx +146 -0
  142. package/src/__tests__/tool-menu.test.jsx +115 -0
  143. package/src/__tests__/undo-redo.test.jsx +24 -0
  144. package/src/__tests__/use-debounce.test.js +21 -0
  145. package/src/__tests__/utils.js +41 -0
  146. package/src/__tests__/utils.test.js +105 -0
  147. package/src/axis/__tests__/arrow.test.jsx +38 -0
  148. package/src/axis/__tests__/axes.test.jsx +216 -0
  149. package/src/axis/arrow.jsx +57 -0
  150. package/src/axis/axes.jsx +285 -0
  151. package/src/axis/index.js +3 -0
  152. package/src/bg.jsx +96 -0
  153. package/src/container/__tests__/actions.test.js +105 -0
  154. package/src/container/__tests__/index.test.jsx +319 -0
  155. package/src/container/__tests__/marks.test.js +172 -0
  156. package/src/container/__tests__/middleware.test.js +235 -0
  157. package/src/container/__tests__/reducer.test.js +324 -0
  158. package/src/container/actions.js +8 -0
  159. package/src/container/index.jsx +91 -0
  160. package/src/container/marks.js +14 -0
  161. package/src/container/middleware.js +7 -0
  162. package/src/container/reducer.js +5 -0
  163. package/src/coordinates-label.jsx +63 -0
  164. package/src/graph-with-controls.jsx +239 -0
  165. package/src/graph.jsx +303 -0
  166. package/src/grid-setup.jsx +432 -0
  167. package/src/grid.jsx +133 -0
  168. package/src/index.js +7 -0
  169. package/src/key-legend.jsx +142 -0
  170. package/src/label-svg-icon.jsx +39 -0
  171. package/src/labels.jsx +207 -0
  172. package/src/mark-label.jsx +244 -0
  173. package/src/toggle-bar.jsx +224 -0
  174. package/src/tool-menu.jsx +49 -0
  175. package/src/tools/absolute/__tests__/component.test.jsx +53 -0
  176. package/src/tools/absolute/component.jsx +23 -0
  177. package/src/tools/absolute/index.js +31 -0
  178. package/src/tools/circle/__tests__/bg-circle.test.jsx +26 -0
  179. package/src/tools/circle/__tests__/component.test.jsx +494 -0
  180. package/src/tools/circle/__tests__/index.test.js +480 -0
  181. package/src/tools/circle/bg-circle.jsx +81 -0
  182. package/src/tools/circle/component.jsx +264 -0
  183. package/src/tools/circle/index.js +25 -0
  184. package/src/tools/exponential/__tests__/component.test.jsx +53 -0
  185. package/src/tools/exponential/__tests__/index.test.js +729 -0
  186. package/src/tools/exponential/component.jsx +23 -0
  187. package/src/tools/exponential/index.js +39 -0
  188. package/src/tools/index.js +48 -0
  189. package/src/tools/line/__tests__/component.test.jsx +37 -0
  190. package/src/tools/line/component.jsx +93 -0
  191. package/src/tools/line/index.js +4 -0
  192. package/src/tools/parabola/__tests__/component.test.jsx +48 -0
  193. package/src/tools/parabola/__tests__/index.test.js +470 -0
  194. package/src/tools/parabola/component.jsx +23 -0
  195. package/src/tools/parabola/index.js +31 -0
  196. package/src/tools/point/__tests__/component.test.jsx +349 -0
  197. package/src/tools/point/__tests__/index.test.js +241 -0
  198. package/src/tools/point/component.jsx +126 -0
  199. package/src/tools/point/index.js +11 -0
  200. package/src/tools/polygon/__tests__/component.test.jsx +471 -0
  201. package/src/tools/polygon/__tests__/index.test.js +294 -0
  202. package/src/tools/polygon/__tests__/line.test.jsx +35 -0
  203. package/src/tools/polygon/__tests__/polygon.test.jsx +61 -0
  204. package/src/tools/polygon/component.jsx +409 -0
  205. package/src/tools/polygon/index.js +52 -0
  206. package/src/tools/polygon/line.jsx +74 -0
  207. package/src/tools/polygon/polygon.jsx +110 -0
  208. package/src/tools/ray/__tests__/component.test.jsx +29 -0
  209. package/src/tools/ray/component.jsx +92 -0
  210. package/src/tools/ray/index.js +4 -0
  211. package/src/tools/segment/__tests__/component.test.jsx +28 -0
  212. package/src/tools/segment/component.jsx +65 -0
  213. package/src/tools/segment/index.js +4 -0
  214. package/src/tools/shared/__tests__/arrow-head.test.jsx +31 -0
  215. package/src/tools/shared/arrow-head.jsx +102 -0
  216. package/src/tools/shared/icons/CorrectSVG.jsx +32 -0
  217. package/src/tools/shared/icons/IncorrectSVG.jsx +30 -0
  218. package/src/tools/shared/icons/MissingSVG.jsx +31 -0
  219. package/src/tools/shared/line/__tests__/index.test.jsx +109 -0
  220. package/src/tools/shared/line/__tests__/line-path.test.jsx +53 -0
  221. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +73 -0
  222. package/src/tools/shared/line/index.jsx +487 -0
  223. package/src/tools/shared/line/line-path.jsx +80 -0
  224. package/src/tools/shared/line/with-root-edge.jsx +97 -0
  225. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +91 -0
  226. package/src/tools/shared/point/__tests__/base-point.test.jsx +87 -0
  227. package/src/tools/shared/point/arrow-point.jsx +46 -0
  228. package/src/tools/shared/point/arrow.jsx +37 -0
  229. package/src/tools/shared/point/base-point.jsx +121 -0
  230. package/src/tools/shared/point/index.jsx +54 -0
  231. package/src/tools/shared/styles.js +27 -0
  232. package/src/tools/shared/types.js +10 -0
  233. package/src/tools/sine/__tests__/component.test.jsx +51 -0
  234. package/src/tools/sine/component.jsx +32 -0
  235. package/src/tools/sine/index.js +33 -0
  236. package/src/tools/vector/__tests__/component.test.jsx +25 -0
  237. package/src/tools/vector/component.jsx +56 -0
  238. package/src/tools/vector/index.js +4 -0
  239. package/src/undo-redo.jsx +45 -0
  240. package/src/use-debounce.js +13 -0
  241. package/src/utils.js +224 -0
  242. package/dist/_virtual/_rolldown/runtime.js +0 -23
  243. package/dist/autosize-input.d.ts +0 -10
  244. package/dist/autosize-input.js +0 -66
  245. package/dist/axis/arrow.d.ts +0 -13
  246. package/dist/axis/arrow.js +0 -34
  247. package/dist/axis/axes.d.ts +0 -132
  248. package/dist/axis/axes.js +0 -214
  249. package/dist/axis/index.d.ts +0 -10
  250. package/dist/bg.d.ts +0 -51
  251. package/dist/bg.js +0 -44
  252. package/dist/container/actions.d.ts +0 -15
  253. package/dist/container/actions.js +0 -7
  254. package/dist/container/index.d.ts +0 -58
  255. package/dist/container/index.js +0 -48
  256. package/dist/container/marks.d.ts +0 -10
  257. package/dist/container/marks.js +0 -11
  258. package/dist/container/middleware.d.ts +0 -10
  259. package/dist/container/middleware.js +0 -4
  260. package/dist/container/reducer.d.ts +0 -14
  261. package/dist/container/reducer.js +0 -7
  262. package/dist/coordinates-label.d.ts +0 -50
  263. package/dist/coordinates-label.js +0 -46
  264. package/dist/graph-with-controls.d.ts +0 -88
  265. package/dist/graph-with-controls.js +0 -154
  266. package/dist/graph.d.ts +0 -126
  267. package/dist/graph.js +0 -209
  268. package/dist/grid-setup.d.ts +0 -27
  269. package/dist/grid-setup.js +0 -307
  270. package/dist/grid.d.ts +0 -43
  271. package/dist/grid.js +0 -59
  272. package/dist/index.d.ts +0 -15
  273. package/dist/index.js +0 -7
  274. package/dist/key-legend.d.ts +0 -21
  275. package/dist/key-legend.js +0 -231
  276. package/dist/label-svg-icon.d.ts +0 -18
  277. package/dist/label-svg-icon.js +0 -42
  278. package/dist/labels.d.ts +0 -37
  279. package/dist/labels.js +0 -152
  280. package/dist/mark-label.d.ts +0 -58
  281. package/dist/mark-label.js +0 -171
  282. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +0 -101
  283. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +0 -63
  284. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +0 -44
  285. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +0 -9
  286. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +0 -14
  287. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +0 -21
  288. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +0 -16
  289. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +0 -8
  290. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +0 -15
  291. package/dist/node_modules/.bun/@visx_curve@3.12.0/node_modules/@visx/curve/esm/index.js +0 -2
  292. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +0 -79
  293. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +0 -79
  294. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +0 -79
  295. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +0 -6
  296. package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +0 -50
  297. package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +0 -18
  298. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +0 -10
  299. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +0 -9
  300. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +0 -6
  301. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +0 -47
  302. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/LinePath.js +0 -50
  303. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/D3ShapeFactories.js +0 -9
  304. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/util/setNumberOrNumberAccessor.js +0 -6
  305. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +0 -53
  306. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +0 -57
  307. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +0 -91
  308. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +0 -21
  309. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +0 -32
  310. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -33
  311. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +0 -32
  312. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  313. package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +0 -28
  314. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Hash.js +0 -21
  315. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_ListCache.js +0 -21
  316. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Map.js +0 -10
  317. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_MapCache.js +0 -21
  318. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_Symbol.js +0 -9
  319. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_assocIndexOf.js +0 -14
  320. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseGetTag.js +0 -15
  321. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_baseIsNative.js +0 -16
  322. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_coreJsData.js +0 -9
  323. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_freeGlobal.js +0 -8
  324. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getMapData.js +0 -14
  325. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getNative.js +0 -15
  326. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getRawTag.js +0 -19
  327. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_getValue.js +0 -11
  328. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashClear.js +0 -13
  329. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashDelete.js +0 -12
  330. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashGet.js +0 -18
  331. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashHas.js +0 -14
  332. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_hashSet.js +0 -14
  333. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isKeyable.js +0 -12
  334. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_isMasked.js +0 -16
  335. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheClear.js +0 -11
  336. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheDelete.js +0 -14
  337. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheGet.js +0 -14
  338. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheHas.js +0 -13
  339. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_listCacheSet.js +0 -14
  340. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheClear.js +0 -19
  341. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheDelete.js +0 -14
  342. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheGet.js +0 -13
  343. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheHas.js +0 -13
  344. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_mapCacheSet.js +0 -14
  345. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_nativeCreate.js +0 -9
  346. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_objectToString.js +0 -12
  347. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_root.js +0 -10
  348. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/_toSource.js +0 -20
  349. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/eq.js +0 -11
  350. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isFunction.js +0 -16
  351. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/isObject.js +0 -12
  352. package/dist/node_modules/.bun/lodash@4.17.21/node_modules/lodash/memoize.js +0 -20
  353. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +0 -37
  354. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +0 -509
  355. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +0 -108
  356. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +0 -31
  357. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +0 -45
  358. package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +0 -471
  359. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +0 -49
  360. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +0 -34
  361. package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +0 -185
  362. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +0 -198
  363. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.development.js +0 -53
  364. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/cjs/use-sync-external-store-with-selector.production.js +0 -51
  365. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +0 -10
  366. package/dist/toggle-bar.d.ts +0 -40
  367. package/dist/toggle-bar.js +0 -155
  368. package/dist/tool-menu.d.ts +0 -29
  369. package/dist/tool-menu.js +0 -41
  370. package/dist/tools/absolute/component.d.ts +0 -16
  371. package/dist/tools/absolute/component.js +0 -15
  372. package/dist/tools/absolute/index.d.ts +0 -20
  373. package/dist/tools/absolute/index.js +0 -32
  374. package/dist/tools/circle/bg-circle.d.ts +0 -116
  375. package/dist/tools/circle/bg-circle.js +0 -72
  376. package/dist/tools/circle/component.d.ts +0 -83
  377. package/dist/tools/circle/component.js +0 -195
  378. package/dist/tools/circle/index.d.ts +0 -20
  379. package/dist/tools/circle/index.js +0 -22
  380. package/dist/tools/exponential/component.d.ts +0 -16
  381. package/dist/tools/exponential/component.js +0 -14
  382. package/dist/tools/exponential/index.d.ts +0 -20
  383. package/dist/tools/exponential/index.js +0 -32
  384. package/dist/tools/index.d.ts +0 -27
  385. package/dist/tools/index.js +0 -55
  386. package/dist/tools/line/component.d.ts +0 -124
  387. package/dist/tools/line/component.js +0 -72
  388. package/dist/tools/line/index.d.ts +0 -13
  389. package/dist/tools/line/index.js +0 -6
  390. package/dist/tools/parabola/component.d.ts +0 -16
  391. package/dist/tools/parabola/component.js +0 -14
  392. package/dist/tools/parabola/index.d.ts +0 -20
  393. package/dist/tools/parabola/index.js +0 -32
  394. package/dist/tools/point/component.d.ts +0 -50
  395. package/dist/tools/point/component.js +0 -85
  396. package/dist/tools/point/index.d.ts +0 -15
  397. package/dist/tools/point/index.js +0 -13
  398. package/dist/tools/polygon/component.d.ts +0 -120
  399. package/dist/tools/polygon/component.js +0 -262
  400. package/dist/tools/polygon/index.d.ts +0 -19
  401. package/dist/tools/polygon/index.js +0 -55
  402. package/dist/tools/polygon/line.d.ts +0 -125
  403. package/dist/tools/polygon/line.js +0 -63
  404. package/dist/tools/polygon/polygon.d.ts +0 -122
  405. package/dist/tools/polygon/polygon.js +0 -74
  406. package/dist/tools/ray/component.d.ts +0 -101
  407. package/dist/tools/ray/component.js +0 -71
  408. package/dist/tools/ray/index.d.ts +0 -13
  409. package/dist/tools/ray/index.js +0 -6
  410. package/dist/tools/segment/component.d.ts +0 -100
  411. package/dist/tools/segment/component.js +0 -52
  412. package/dist/tools/segment/index.d.ts +0 -13
  413. package/dist/tools/segment/index.js +0 -6
  414. package/dist/tools/shared/arrow-head.d.ts +0 -51
  415. package/dist/tools/shared/arrow-head.js +0 -63
  416. package/dist/tools/shared/icons/CorrectSVG.d.ts +0 -26
  417. package/dist/tools/shared/icons/CorrectSVG.js +0 -29
  418. package/dist/tools/shared/icons/IncorrectSVG.d.ts +0 -26
  419. package/dist/tools/shared/icons/IncorrectSVG.js +0 -27
  420. package/dist/tools/shared/icons/MissingSVG.d.ts +0 -26
  421. package/dist/tools/shared/icons/MissingSVG.js +0 -28
  422. package/dist/tools/shared/line/index.d.ts +0 -245
  423. package/dist/tools/shared/line/index.js +0 -319
  424. package/dist/tools/shared/line/line-path.d.ts +0 -57
  425. package/dist/tools/shared/line/line-path.js +0 -71
  426. package/dist/tools/shared/line/with-root-edge.d.ts +0 -142
  427. package/dist/tools/shared/line/with-root-edge.js +0 -73
  428. package/dist/tools/shared/point/arrow-point.d.ts +0 -56
  429. package/dist/tools/shared/point/arrow-point.js +0 -41
  430. package/dist/tools/shared/point/arrow.d.ts +0 -45
  431. package/dist/tools/shared/point/arrow.js +0 -35
  432. package/dist/tools/shared/point/base-point.d.ts +0 -52
  433. package/dist/tools/shared/point/base-point.js +0 -103
  434. package/dist/tools/shared/point/index.d.ts +0 -216
  435. package/dist/tools/shared/point/index.js +0 -45
  436. package/dist/tools/shared/styles.d.ts +0 -29
  437. package/dist/tools/shared/styles.js +0 -20
  438. package/dist/tools/shared/types.d.ts +0 -21
  439. package/dist/tools/shared/types.js +0 -11
  440. package/dist/tools/sine/component.d.ts +0 -16
  441. package/dist/tools/sine/component.js +0 -22
  442. package/dist/tools/sine/index.d.ts +0 -20
  443. package/dist/tools/sine/index.js +0 -32
  444. package/dist/tools/vector/component.d.ts +0 -100
  445. package/dist/tools/vector/component.js +0 -44
  446. package/dist/tools/vector/index.d.ts +0 -13
  447. package/dist/tools/vector/index.js +0 -6
  448. package/dist/undo-redo.d.ts +0 -22
  449. package/dist/undo-redo.js +0 -47
  450. package/dist/use-debounce.d.ts +0 -9
  451. package/dist/use-debounce.js +0 -13
  452. package/dist/utils.d.ts +0 -61
  453. package/dist/utils.js +0 -75
@@ -0,0 +1,91 @@
1
+ import { render } from '@pie-lib/test-utils';
2
+ import React from 'react';
3
+ import { ArrowPoint } from '../index';
4
+ import { graphProps } from '../../../../__tests__/utils';
5
+ import { bounds } from '../../../../utils';
6
+ import { gridDraggable, utils } from '@pie-lib/plot';
7
+
8
+ const { xy } = utils;
9
+ jest.mock('../../../../utils', () => {
10
+ const { point, getAngleDeg, arrowDimensions } = jest.requireActual('../../../../utils');
11
+ return {
12
+ bounds: jest.fn(),
13
+ point,
14
+ getAngleDeg,
15
+ arrowDimensions,
16
+ };
17
+ });
18
+
19
+ jest.mock('@pie-lib/plot', () => {
20
+ const { types, utils } = jest.requireActual('@pie-lib/plot');
21
+ return {
22
+ gridDraggable: jest.fn((opts) => (Comp) => Comp),
23
+ types,
24
+ utils,
25
+ };
26
+ });
27
+
28
+ describe('ArrowPoint', () => {
29
+ let onChange = jest.fn();
30
+ const renderComponent = (extras) => {
31
+ const defaults = {
32
+ classes: {},
33
+ className: 'className',
34
+ onChange,
35
+ graphProps: graphProps(),
36
+ from: xy(0, 0),
37
+ to: xy(1, 1),
38
+ x: 0,
39
+ y: 0,
40
+ };
41
+ const props = { ...defaults, ...extras };
42
+ return render(<ArrowPoint {...props} />);
43
+ };
44
+
45
+ describe('rendering', () => {
46
+ it('renders without crashing', () => {
47
+ const { container } = renderComponent();
48
+ expect(container.firstChild).toBeInTheDocument();
49
+ });
50
+ });
51
+
52
+ describe('gridDraggable options', () => {
53
+ let opts;
54
+ let domain;
55
+ let range;
56
+ beforeEach(() => {
57
+ domain = {
58
+ min: 0,
59
+ max: 1,
60
+ step: 1,
61
+ };
62
+ range = {
63
+ min: 0,
64
+ max: 1,
65
+ step: 1,
66
+ };
67
+ renderComponent();
68
+ opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
69
+ });
70
+
71
+ describe('bounds', () => {
72
+ it('calls utils.bounds with area', () => {
73
+ const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
74
+ expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
75
+ });
76
+ });
77
+ describe('anchorPoint', () => {
78
+ it('returns x/y', () => {
79
+ const result = opts.anchorPoint({ x: 0, y: 0 });
80
+ expect(result).toEqual({ x: 0, y: 0 });
81
+ });
82
+ });
83
+
84
+ describe('fromDelta', () => {
85
+ it('returns a new point from the x/y + delta', () => {
86
+ const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
87
+ expect(result).toEqual({ x: 0, y: 3 });
88
+ });
89
+ });
90
+ });
91
+ });
@@ -0,0 +1,87 @@
1
+ import { render } from '@pie-lib/test-utils';
2
+ import React from 'react';
3
+ import { BasePoint } from '../index';
4
+ import { gridDraggable } from '@pie-lib/plot';
5
+ import { graphProps } from '../../../../__tests__/utils';
6
+ import { bounds } from '../../../../utils';
7
+
8
+ jest.mock('../../../../utils', () => {
9
+ const { point, thinnerShapesNeeded } = jest.requireActual('../../../../utils');
10
+ return {
11
+ bounds: jest.fn(),
12
+ point,
13
+ thinnerShapesNeeded,
14
+ };
15
+ });
16
+
17
+ jest.mock('@pie-lib/plot', () => {
18
+ const { types, utils } = jest.requireActual('@pie-lib/plot');
19
+ return {
20
+ gridDraggable: jest.fn((opts) => (Comp) => Comp),
21
+ types,
22
+ utils,
23
+ };
24
+ });
25
+
26
+ describe('BasePoint', () => {
27
+ let onChange = jest.fn();
28
+ const renderComponent = (extras) => {
29
+ const defaults = {
30
+ classes: {},
31
+ className: 'className',
32
+ onChange,
33
+ graphProps: graphProps(),
34
+ x: 0,
35
+ y: 0,
36
+ };
37
+ const props = { ...defaults, ...extras };
38
+ return render(<BasePoint {...props} />);
39
+ };
40
+
41
+ describe('rendering', () => {
42
+ it('renders without crashing', () => {
43
+ const { container } = renderComponent();
44
+ expect(container.firstChild).toBeInTheDocument();
45
+ });
46
+ });
47
+
48
+ describe('gridDraggable options', () => {
49
+ let opts;
50
+ let domain;
51
+ let range;
52
+ beforeEach(() => {
53
+ domain = {
54
+ min: 0,
55
+ max: 1,
56
+ step: 1,
57
+ };
58
+ range = {
59
+ min: 0,
60
+ max: 1,
61
+ step: 1,
62
+ };
63
+ renderComponent();
64
+ opts = gridDraggable.mock.calls[gridDraggable.mock.calls.length - 1][0];
65
+ });
66
+
67
+ describe('bounds', () => {
68
+ it('calls utils.bounds with area', () => {
69
+ const result = opts.bounds({ x: 0, y: 0 }, { domain, range });
70
+ expect(bounds).toHaveBeenCalledWith({ left: 0, top: 0, bottom: 0, right: 0 }, domain, range);
71
+ });
72
+ });
73
+ describe('anchorPoint', () => {
74
+ it('returns x/y', () => {
75
+ const result = opts.anchorPoint({ x: 0, y: 0 });
76
+ expect(result).toEqual({ x: 0, y: 0 });
77
+ });
78
+ });
79
+
80
+ describe('fromDelta', () => {
81
+ it('returns a new point from the x/y + delta', () => {
82
+ const result = opts.fromDelta({ x: -1, y: 0 }, { x: 1, y: 3 });
83
+ expect(result).toEqual({ x: 0, y: 3 });
84
+ });
85
+ });
86
+ });
87
+ });
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { types } from '@pie-lib/plot';
4
+ import { arrowDimensions, getAngleDeg } from '../../../utils';
5
+
6
+ export class RawArrow extends React.Component {
7
+ static propTypes = {
8
+ className: PropTypes.string,
9
+ correctness: PropTypes.string,
10
+ disabled: PropTypes.bool,
11
+ x: PropTypes.number.isRequired,
12
+ y: PropTypes.number.isRequired,
13
+ from: PropTypes.shape({
14
+ x: PropTypes.number,
15
+ y: PropTypes.number,
16
+ }).isRequired,
17
+ to: PropTypes.shape({
18
+ x: PropTypes.number,
19
+ y: PropTypes.number,
20
+ }),
21
+ graphProps: types.GraphPropsType.isRequired,
22
+ };
23
+
24
+ static defaultProps = {
25
+ from: {},
26
+ to: {},
27
+ };
28
+
29
+ render() {
30
+ const { className, x, y, graphProps, from, to, ...rest } = this.props;
31
+ const { scale } = graphProps;
32
+
33
+ const angle = from && to ? getAngleDeg(from.x, from.y, to.x, to.y) : 0;
34
+
35
+ const points =
36
+ from && to && (from.x !== to.x || from.y !== to.y)
37
+ ? `0,0 ${arrowDimensions.vector},${arrowDimensions.vector * 2} -${arrowDimensions.vector},${arrowDimensions.vector * 2}`
38
+ : '0,0 0,0 0,0';
39
+
40
+ return (
41
+ <g className={className} {...rest}>
42
+ <polygon points={points} transform={`translate(${scale.x(x)}, ${scale.y(y)}) rotate(${angle} 0 0)`} />
43
+ </g>
44
+ );
45
+ }
46
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { types } from '@pie-lib/plot';
4
+ import { ArrowHead } from '../arrow-head';
5
+ import { thinnerShapesNeeded } from '../../../utils';
6
+
7
+ export class BaseArrow extends React.Component {
8
+ static propTypes = {
9
+ className: PropTypes.string,
10
+ correctness: PropTypes.string,
11
+ disabled: PropTypes.bool,
12
+ x: PropTypes.number.isRequired,
13
+ y: PropTypes.number.isRequired,
14
+ angle: PropTypes.number.isRequired,
15
+ graphProps: types.GraphPropsType.isRequired,
16
+ };
17
+
18
+ render() {
19
+ const { className, angle, x, y, correctness, graphProps, ...rest } = this.props;
20
+ const size = thinnerShapesNeeded(graphProps) ? 12 : 14;
21
+ const { scale } = graphProps;
22
+
23
+ const scaledX = scale.x(x);
24
+ const scaledY = scale.y(y);
25
+
26
+ const transform = `rotate(${-angle}, ${scaledX},${scaledY})`;
27
+ const points = `${scaledX},${scaledY}
28
+ ${scaledX - size},${scaledY - size / 2}
29
+ ${scaledX - size},${scaledY + size / 2}`;
30
+
31
+ return (
32
+ <g className={className} {...rest}>
33
+ <ArrowHead size={size} transform={transform} points={points} correctness={correctness} />
34
+ </g>
35
+ );
36
+ }
37
+ }
@@ -0,0 +1,121 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { types } from '@pie-lib/plot';
4
+ import ReactDOM from 'react-dom';
5
+ import { styled } from '@mui/material/styles';
6
+
7
+ import CoordinatesLabel from '../../../coordinates-label';
8
+ import { thinnerShapesNeeded } from '../../../utils';
9
+ import MissingSVG from '../icons/MissingSVG';
10
+ import CorrectSVG from '../icons/CorrectSVG';
11
+ import IncorrectSVG from '../icons/IncorrectSVG';
12
+ import * as styles from '../styles';
13
+
14
+ const StyledPointGroup = styled('g')(({ disabled, correctness }) => ({
15
+ cursor: 'pointer',
16
+ '& circle': {
17
+ fill: 'currentColor',
18
+ },
19
+ ...(disabled && {
20
+ ...styles.disabled('fill'),
21
+ ...styles.disabled('color'),
22
+ }),
23
+ ...(correctness === 'correct' && {
24
+ ...styles.correct('fill'),
25
+ ...styles.correct('color'),
26
+ }),
27
+ ...(correctness === 'incorrect' && {
28
+ ...styles.incorrect('fill'),
29
+ ...styles.incorrect('color'),
30
+ }),
31
+ ...(correctness === 'missing' && {
32
+ ...styles.missing('fill'),
33
+ ...styles.missing('color'),
34
+ }),
35
+ }));
36
+
37
+ export class RawBp extends React.Component {
38
+ static propTypes = {
39
+ className: PropTypes.string,
40
+ coordinatesOnHover: PropTypes.bool,
41
+ correctness: PropTypes.string,
42
+ disabled: PropTypes.bool,
43
+ labelNode: PropTypes.object,
44
+ x: PropTypes.number.isRequired,
45
+ y: PropTypes.number.isRequired,
46
+ graphProps: types.GraphPropsType.isRequired,
47
+ onClick: PropTypes.func,
48
+ onTouchStart: PropTypes.func,
49
+ onTouchEnd: PropTypes.func,
50
+ };
51
+
52
+ state = { showCoordinates: false };
53
+
54
+ render() {
55
+ const {
56
+ className,
57
+ coordinatesOnHover,
58
+ x,
59
+ y,
60
+ disabled,
61
+ correctness,
62
+ graphProps,
63
+ labelNode,
64
+ onClick,
65
+ onTouchStart,
66
+ onTouchEnd,
67
+ ...rest
68
+ } = this.props;
69
+
70
+ const { showCoordinates } = this.state;
71
+ const { scale } = graphProps;
72
+ const r = thinnerShapesNeeded(graphProps) ? 5 : 7;
73
+
74
+ let SvgComponent;
75
+ switch (correctness) {
76
+ case 'missing':
77
+ SvgComponent = MissingSVG;
78
+ break;
79
+ case 'correct':
80
+ SvgComponent = CorrectSVG;
81
+ break;
82
+ case 'incorrect':
83
+ SvgComponent = IncorrectSVG;
84
+ break;
85
+ default:
86
+ SvgComponent = null;
87
+ }
88
+
89
+ return (
90
+ <>
91
+ {/* Outer invisible circle for easier touch/click */}
92
+ <circle
93
+ style={{ fill: 'transparent', cursor: 'pointer', pointerEvents: 'all' }}
94
+ r={r * 3}
95
+ cx={scale.x(x)}
96
+ cy={scale.y(y)}
97
+ onMouseEnter={() => this.setState({ showCoordinates: true })}
98
+ onMouseLeave={() => this.setState({ showCoordinates: false })}
99
+ onTouchStart={onTouchStart}
100
+ onTouchEnd={onTouchEnd}
101
+ onClick={onClick}
102
+ />
103
+ {/* Actual point */}
104
+ <StyledPointGroup
105
+ className={className}
106
+ disabled={disabled}
107
+ correctness={correctness}
108
+ onMouseEnter={() => this.setState({ showCoordinates: true })}
109
+ onMouseLeave={() => this.setState({ showCoordinates: false })}
110
+ >
111
+ <circle {...rest} r={r} cx={scale.x(x)} cy={scale.y(y)} />
112
+ {SvgComponent && <SvgComponent scale={scale} x={x} y={y} />}
113
+ {labelNode &&
114
+ coordinatesOnHover &&
115
+ showCoordinates &&
116
+ ReactDOM.createPortal(<CoordinatesLabel graphProps={graphProps} x={x} y={y} />, labelNode)}
117
+ </StyledPointGroup>
118
+ </>
119
+ );
120
+ }
121
+ }
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { styled } from '@mui/material/styles';
3
+ import { gridDraggable } from '@pie-lib/plot';
4
+ import { color } from '@pie-lib/render-ui';
5
+ import * as utils from '../../../utils';
6
+ import { RawBp } from './base-point';
7
+ import { RawArrow } from './arrow-point';
8
+ import { BaseArrow } from './arrow';
9
+
10
+ // Drag & bounds options
11
+ const opts = {
12
+ bounds: (props, { domain, range }) => {
13
+ const { x, y } = props;
14
+ const area = { left: x, top: y, bottom: y, right: x };
15
+ return utils.bounds(area, domain, range);
16
+ },
17
+ anchorPoint: (props) => {
18
+ const { x, y } = props;
19
+ return { x, y };
20
+ },
21
+ fromDelta: (props, delta) => {
22
+ return utils.point(props).add(utils.point(delta));
23
+ },
24
+ };
25
+
26
+ // Common styled point
27
+ const PointStyle = styled('g')(() => ({
28
+ '& circle, & polygon': {
29
+ cursor: 'pointer',
30
+ },
31
+ '&[disabled]': {
32
+ '& circle, & polygon': {
33
+ fill: color.disabledSecondary(),
34
+ },
35
+ },
36
+ }));
37
+
38
+ export const BasePoint = gridDraggable(opts)((props) => (
39
+ <PointStyle {...props}>
40
+ <RawBp {...props} />
41
+ </PointStyle>
42
+ ));
43
+
44
+ export const ArrowPoint = gridDraggable(opts)((props) => (
45
+ <PointStyle {...props}>
46
+ <RawArrow {...props} />
47
+ </PointStyle>
48
+ ));
49
+
50
+ export const Arrow = gridDraggable(opts)((props) => (
51
+ <PointStyle {...props}>
52
+ <BaseArrow {...props} />
53
+ </PointStyle>
54
+ ));
@@ -0,0 +1,27 @@
1
+ import { color } from '@pie-lib/render-ui';
2
+
3
+ export const graphingShapeFill = () => color.visualElementsColors.SHAPES_FILL_COLOR;
4
+
5
+ export const disabled = (key = 'fill') => ({
6
+ [key]: color.disabledSecondary(), // this is needed to match previous disabled color for backward compatibility
7
+ pointerEvents: 'none',
8
+ });
9
+
10
+ export const disabledSecondary = (key = 'fill') => ({
11
+ [key]: color.disabledSecondary(),
12
+ pointerEvents: 'none',
13
+ });
14
+
15
+ export const correct = (key = 'fill') => ({
16
+ [key]: color.correctWithIcon(),
17
+ pointerEvents: 'none',
18
+ });
19
+ export const incorrect = (key = 'fill') => ({
20
+ [key]: color.incorrectWithIcon(),
21
+ pointerEvents: 'none',
22
+ });
23
+
24
+ export const missing = (key = 'fill') => ({
25
+ [key]: color.missingWithIcon(),
26
+ pointerEvents: 'none',
27
+ });
@@ -0,0 +1,10 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ export const ToolPropTypeFields = {
4
+ mark: PropTypes.any,
5
+ onChange: PropTypes.func,
6
+ onDragStart: PropTypes.func,
7
+ onDragStop: PropTypes.func,
8
+ };
9
+
10
+ export const ToolPropType = PropTypes.shape(ToolPropTypeFields);
@@ -0,0 +1,51 @@
1
+ import { withRootEdge } from '../../shared/line/with-root-edge';
2
+ import { buildDataPoints, sinY } from '@pie-lib/graphing-utils';
3
+ import { utils } from '@pie-lib/plot';
4
+
5
+ import { graphProps as getGraphProps } from '../../../__tests__/utils';
6
+
7
+ const { xy } = utils;
8
+ jest.mock('@pie-lib/graphing-utils', () => ({
9
+ sinY: jest.fn().mockReturnValue(0),
10
+ buildDataPoints: jest.fn().mockReturnValue([]),
11
+ parabolaFromTwoPoints: jest.fn(() => jest.fn()),
12
+ getAmplitudeAndFreq: jest.fn().mockReturnValue({ freq: 4, amplitude: 1 }),
13
+ FREQ_DIVIDER: 16,
14
+ }));
15
+
16
+ jest.mock('../../shared/line/with-root-edge', () => ({
17
+ withRootEdge: jest.fn(),
18
+ rootEdgeComponent: jest.fn(),
19
+ }));
20
+ describe('Parabola', () => {
21
+ let fnBody;
22
+ let graphProps;
23
+ let root;
24
+ let edge;
25
+ let result;
26
+ beforeEach(() => {
27
+ require('../component');
28
+ fnBody = withRootEdge.mock.calls[0][0];
29
+ graphProps = getGraphProps();
30
+ root = xy(0, 0);
31
+ edge = xy(1, 1);
32
+
33
+ result = fnBody({ graphProps, root, edge });
34
+ });
35
+ it('fnBody is not null', () => {
36
+ expect(fnBody).toBeDefined();
37
+ });
38
+
39
+ it('calls buildDataPoints', () => {
40
+ const { domain, range } = graphProps;
41
+ expect(buildDataPoints).toHaveBeenCalledWith({ ...domain, step: 0.25 }, range, root, edge, expect.anything());
42
+ });
43
+
44
+ it('calls sinY', () => {
45
+ expect(sinY).toHaveBeenCalledWith(1, 4, expect.anything());
46
+ });
47
+
48
+ it('returns dataPoints', () => {
49
+ expect(result).toEqual({ root, edge, dataPoints: [] });
50
+ });
51
+ });
@@ -0,0 +1,32 @@
1
+ import debug from 'debug';
2
+ import { buildDataPoints, FREQ_DIVIDER, getAmplitudeAndFreq, sinY } from '@pie-lib/graphing-utils';
3
+ import { rootEdgeComponent, withRootEdge } from '../shared/line/with-root-edge';
4
+
5
+ const log = debug('pie-lib:graphing:sine');
6
+
7
+ const Sine = withRootEdge((props) => {
8
+ const { root, edge, graphProps } = props;
9
+ const { domain, range } = graphProps;
10
+
11
+ const { amplitude, freq } = getAmplitudeAndFreq(root, edge);
12
+ const interval = freq / FREQ_DIVIDER;
13
+
14
+ log('[getPoints] amplitude:', amplitude, 'freq:', freq);
15
+
16
+ const dataPoints =
17
+ edge && edge.x === root.x
18
+ ? []
19
+ : buildDataPoints(
20
+ { ...domain, step: interval },
21
+ range,
22
+ root,
23
+ edge,
24
+ sinY(amplitude, freq, { phase: root.x, vertical: root.y }),
25
+ );
26
+
27
+ return { root: props.root, edge: props.edge, dataPoints };
28
+ });
29
+
30
+ const Component = rootEdgeComponent(Sine);
31
+
32
+ export default Component;
@@ -0,0 +1,33 @@
1
+ import Sine from './component';
2
+ import debug from 'debug';
3
+ import { equalPoints, sameAxes } from '../../utils';
4
+
5
+ const log = debug('pie-lib:graphing:sine');
6
+
7
+ export const tool = () => ({
8
+ type: 'sine',
9
+ Component: Sine,
10
+ complete: (data, mark) => {
11
+ return { ...mark, building: false, closed: true };
12
+ },
13
+ addPoint: (point, mark) => {
14
+ log('add point to sine model: ', point, 'mark: ', mark);
15
+ if (mark && (equalPoints(mark.root, point) || sameAxes(mark.root, point))) {
16
+ return mark;
17
+ }
18
+
19
+ if (!mark) {
20
+ return {
21
+ type: 'sine',
22
+ root: point,
23
+ edge: undefined,
24
+ closed: false,
25
+ building: true,
26
+ };
27
+ } else if (mark && !mark.root) {
28
+ throw new Error('no root - should never happen');
29
+ } else {
30
+ return { ...mark, edge: point, closed: true, building: false };
31
+ }
32
+ },
33
+ });
@@ -0,0 +1,25 @@
1
+ import { render } from '@pie-lib/test-utils';
2
+ import React from 'react';
3
+ import { Line } from '../component';
4
+ import { graphProps as getGraphProps } from '../../../__tests__/utils';
5
+ import { utils } from '@pie-lib/plot';
6
+
7
+ describe('Line', () => {
8
+ const renderComponent = (extras) => {
9
+ const defaults = {
10
+ classes: {},
11
+ className: 'className',
12
+ graphProps: getGraphProps(),
13
+ from: utils.xy(0, 0),
14
+ to: utils.xy(1, 1),
15
+ };
16
+ const props = { ...defaults, ...extras };
17
+ return render(<Line {...props} />);
18
+ };
19
+ describe('rendering', () => {
20
+ it('renders without crashing', () => {
21
+ const { container } = renderComponent();
22
+ expect(container.firstChild).toBeInTheDocument();
23
+ });
24
+ });
25
+ });
@@ -0,0 +1,56 @@
1
+ import { lineBase, lineToolComponent, styles } from '../shared/line';
2
+ import { Arrow } from '../shared/point';
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { types } from '@pie-lib/plot';
6
+ import { styled } from '@mui/material/styles';
7
+ import { getDistanceBetweenTwoPoints } from '../../utils';
8
+
9
+ const StyledLine = styled('line')(({ theme, disabled, correctness }) => ({
10
+ ...styles.line(theme),
11
+ ...(disabled && styles.disabledSecondary(theme)),
12
+ ...(correctness && styles[correctness] && styles[correctness](theme, 'stroke')),
13
+ }));
14
+
15
+ export const Line = (props) => {
16
+ const {
17
+ className,
18
+ disabled,
19
+ correctness,
20
+ graphProps: { scale },
21
+ from,
22
+ to,
23
+ ...rest
24
+ } = props;
25
+ const startPoint = { x: scale.x(from.x), y: scale.y(from.y) };
26
+ const endPoint = { x: scale.x(to.x), y: scale.y(to.y) };
27
+ const length = getDistanceBetweenTwoPoints(startPoint, endPoint);
28
+
29
+ return (
30
+ <StyledLine
31
+ className={className}
32
+ disabled={disabled}
33
+ correctness={correctness}
34
+ x1={startPoint.x}
35
+ y1={startPoint.y}
36
+ x2={endPoint.x}
37
+ y2={endPoint.y}
38
+ strokeDasharray={length - 7}
39
+ {...rest}
40
+ />
41
+ );
42
+ };
43
+
44
+ Line.propTypes = {
45
+ className: PropTypes.string,
46
+ disabled: PropTypes.bool,
47
+ correctness: PropTypes.string,
48
+ graphProps: PropTypes.any,
49
+ from: types.PointType,
50
+ to: types.PointType,
51
+ };
52
+
53
+ const Vector = lineBase(Line, { to: Arrow });
54
+ const Component = lineToolComponent(Vector);
55
+
56
+ export default Component;
@@ -0,0 +1,4 @@
1
+ import Vector from './component';
2
+ import { lineTool } from '../shared/line';
3
+
4
+ export const tool = lineTool('vector', Vector);