@pie-lib/graphing-solution-set 4.0.4-next.30 → 4.0.4-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 (310) hide show
  1. package/CHANGELOG.json +1 -0
  2. package/CHANGELOG.md +449 -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 +327 -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 +129 -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 +77 -0
  23. package/lib/coordinates-label.js.map +1 -0
  24. package/lib/graph-with-controls.js +297 -0
  25. package/lib/graph-with-controls.js.map +1 -0
  26. package/lib/graph.js +353 -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 +40 -0
  33. package/lib/index.js.map +1 -0
  34. package/lib/labels.js +199 -0
  35. package/lib/labels.js.map +1 -0
  36. package/lib/mark-label.js +159 -0
  37. package/lib/mark-label.js.map +1 -0
  38. package/lib/toggle-bar.js +248 -0
  39. package/lib/toggle-bar.js.map +1 -0
  40. package/lib/tool-menu.js +218 -0
  41. package/lib/tool-menu.js.map +1 -0
  42. package/lib/tools/index.js +24 -0
  43. package/lib/tools/index.js.map +1 -0
  44. package/lib/tools/line/component.js +92 -0
  45. package/lib/tools/line/component.js.map +1 -0
  46. package/lib/tools/line/index.js +11 -0
  47. package/lib/tools/line/index.js.map +1 -0
  48. package/lib/tools/polygon/component.js +358 -0
  49. package/lib/tools/polygon/component.js.map +1 -0
  50. package/lib/tools/polygon/index.js +89 -0
  51. package/lib/tools/polygon/index.js.map +1 -0
  52. package/lib/tools/polygon/line.js +114 -0
  53. package/lib/tools/polygon/line.js.map +1 -0
  54. package/lib/tools/polygon/polygon.js +128 -0
  55. package/lib/tools/polygon/polygon.js.map +1 -0
  56. package/lib/tools/shared/arrow-head.js +62 -0
  57. package/lib/tools/shared/arrow-head.js.map +1 -0
  58. package/lib/tools/shared/line/index.js +539 -0
  59. package/lib/tools/shared/line/index.js.map +1 -0
  60. package/lib/tools/shared/line/line-path.js +121 -0
  61. package/lib/tools/shared/line/line-path.js.map +1 -0
  62. package/lib/tools/shared/line/with-root-edge.js +121 -0
  63. package/lib/tools/shared/line/with-root-edge.js.map +1 -0
  64. package/lib/tools/shared/point/arrow-point.js +86 -0
  65. package/lib/tools/shared/point/arrow-point.js.map +1 -0
  66. package/lib/tools/shared/point/arrow.js +70 -0
  67. package/lib/tools/shared/point/arrow.js.map +1 -0
  68. package/lib/tools/shared/point/base-point.js +137 -0
  69. package/lib/tools/shared/point/base-point.js.map +1 -0
  70. package/lib/tools/shared/point/index.js +80 -0
  71. package/lib/tools/shared/point/index.js.map +1 -0
  72. package/lib/tools/shared/styles.js +26 -0
  73. package/lib/tools/shared/styles.js.map +1 -0
  74. package/lib/tools/shared/types.js +15 -0
  75. package/lib/tools/shared/types.js.map +1 -0
  76. package/lib/undo-redo.js +67 -0
  77. package/lib/undo-redo.js.map +1 -0
  78. package/lib/use-debounce.js +25 -0
  79. package/lib/use-debounce.js.map +1 -0
  80. package/lib/utils.js +235 -0
  81. package/lib/utils.js.map +1 -0
  82. package/package.json +34 -46
  83. package/src/__tests__/bg.test.jsx +250 -0
  84. package/src/__tests__/coordinates-label.test.jsx +243 -0
  85. package/src/__tests__/graph-with-controls.test.jsx +184 -0
  86. package/src/__tests__/graph.test.jsx +93 -0
  87. package/src/__tests__/grid-setup.test.jsx +645 -0
  88. package/src/__tests__/grid.test.jsx +23 -0
  89. package/src/__tests__/labels.test.jsx +41 -0
  90. package/src/__tests__/mark-label.test.jsx +66 -0
  91. package/src/__tests__/toggle-bar.test.jsx +106 -0
  92. package/src/__tests__/tool-menu.test.jsx +453 -0
  93. package/src/__tests__/undo-redo.test.jsx +26 -0
  94. package/src/__tests__/use-debounce.test.js +21 -0
  95. package/src/__tests__/utils.js +41 -0
  96. package/src/__tests__/utils.test.js +105 -0
  97. package/src/axis/__tests__/arrow.test.jsx +43 -0
  98. package/src/axis/__tests__/axes.test.jsx +182 -0
  99. package/src/axis/arrow.jsx +57 -0
  100. package/src/axis/axes.jsx +284 -0
  101. package/src/axis/index.js +3 -0
  102. package/src/bg.jsx +96 -0
  103. package/src/container/__tests__/actions.test.js +105 -0
  104. package/src/container/__tests__/index.test.jsx +227 -0
  105. package/src/container/__tests__/marks.test.js +172 -0
  106. package/src/container/__tests__/middleware.test.js +235 -0
  107. package/src/container/__tests__/reducer.test.js +324 -0
  108. package/src/container/actions.js +8 -0
  109. package/src/container/index.jsx +93 -0
  110. package/src/container/marks.js +14 -0
  111. package/src/container/middleware.js +7 -0
  112. package/src/container/reducer.js +5 -0
  113. package/src/coordinates-label.jsx +62 -0
  114. package/src/graph-with-controls.jsx +242 -0
  115. package/src/graph.jsx +333 -0
  116. package/src/grid-setup.jsx +432 -0
  117. package/src/grid.jsx +133 -0
  118. package/src/index.js +7 -0
  119. package/src/labels.jsx +173 -0
  120. package/src/mark-label.jsx +125 -0
  121. package/src/toggle-bar.jsx +221 -0
  122. package/src/tool-menu.jsx +235 -0
  123. package/src/tools/index.js +8 -0
  124. package/src/tools/line/__tests__/component.test.jsx +37 -0
  125. package/src/tools/line/component.jsx +77 -0
  126. package/src/tools/line/index.js +4 -0
  127. package/src/tools/polygon/__tests__/component.test.jsx +487 -0
  128. package/src/tools/polygon/__tests__/index.test.js +65 -0
  129. package/src/tools/polygon/__tests__/line.test.jsx +23 -0
  130. package/src/tools/polygon/__tests__/polygon.test.jsx +44 -0
  131. package/src/tools/polygon/component.jsx +324 -0
  132. package/src/tools/polygon/index.js +52 -0
  133. package/src/tools/polygon/line.jsx +80 -0
  134. package/src/tools/polygon/polygon.jsx +93 -0
  135. package/src/tools/shared/__tests__/arrow-head.test.jsx +33 -0
  136. package/src/tools/shared/arrow-head.jsx +46 -0
  137. package/src/tools/shared/line/__tests__/index.test.jsx +553 -0
  138. package/src/tools/shared/line/__tests__/line-path.test.jsx +56 -0
  139. package/src/tools/shared/line/__tests__/with-root-edge.test.jsx +488 -0
  140. package/src/tools/shared/line/index.jsx +471 -0
  141. package/src/tools/shared/line/line-path.jsx +85 -0
  142. package/src/tools/shared/line/with-root-edge.jsx +97 -0
  143. package/src/tools/shared/point/__tests__/arrow-point.test.jsx +91 -0
  144. package/src/tools/shared/point/__tests__/arrow.test.jsx +469 -0
  145. package/src/tools/shared/point/__tests__/base-point.test.jsx +87 -0
  146. package/src/tools/shared/point/arrow-point.jsx +60 -0
  147. package/src/tools/shared/point/arrow.jsx +40 -0
  148. package/src/tools/shared/point/base-point.jsx +113 -0
  149. package/src/tools/shared/point/index.jsx +58 -0
  150. package/src/tools/shared/styles.js +20 -0
  151. package/src/tools/shared/types.js +8 -0
  152. package/src/undo-redo.jsx +37 -0
  153. package/src/use-debounce.js +13 -0
  154. package/src/utils.js +230 -0
  155. package/dist/_virtual/_rolldown/runtime.js +0 -23
  156. package/dist/autosize-input.d.ts +0 -10
  157. package/dist/autosize-input.js +0 -66
  158. package/dist/axis/arrow.d.ts +0 -13
  159. package/dist/axis/arrow.js +0 -34
  160. package/dist/axis/axes.d.ts +0 -132
  161. package/dist/axis/axes.js +0 -214
  162. package/dist/axis/index.d.ts +0 -10
  163. package/dist/bg.d.ts +0 -51
  164. package/dist/bg.js +0 -44
  165. package/dist/container/actions.d.ts +0 -15
  166. package/dist/container/actions.js +0 -7
  167. package/dist/container/index.d.ts +0 -58
  168. package/dist/container/index.js +0 -48
  169. package/dist/container/marks.d.ts +0 -10
  170. package/dist/container/marks.js +0 -11
  171. package/dist/container/middleware.d.ts +0 -10
  172. package/dist/container/middleware.js +0 -4
  173. package/dist/container/reducer.d.ts +0 -14
  174. package/dist/container/reducer.js +0 -7
  175. package/dist/coordinates-label.d.ts +0 -50
  176. package/dist/coordinates-label.js +0 -46
  177. package/dist/graph-with-controls.d.ts +0 -85
  178. package/dist/graph-with-controls.js +0 -155
  179. package/dist/graph.d.ts +0 -119
  180. package/dist/graph.js +0 -221
  181. package/dist/grid-setup.d.ts +0 -27
  182. package/dist/grid-setup.js +0 -307
  183. package/dist/grid.d.ts +0 -43
  184. package/dist/grid.js +0 -59
  185. package/dist/index.d.ts +0 -14
  186. package/dist/index.js +0 -6
  187. package/dist/labels.d.ts +0 -73
  188. package/dist/labels.js +0 -134
  189. package/dist/mark-label.d.ts +0 -50
  190. package/dist/mark-label.js +0 -84
  191. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Axis.js +0 -101
  192. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/AxisRenderer.js +0 -63
  193. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/axis/Ticks.js +0 -44
  194. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/constants/orientation.js +0 -9
  195. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/createPoint.js +0 -14
  196. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getAxisRangePaddingConfig.js +0 -21
  197. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getLabelTransform.js +0 -16
  198. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickFormatter.js +0 -8
  199. package/dist/node_modules/.bun/@visx_axis@3.12.0_f4eacebf2041cd4f/node_modules/@visx/axis/esm/utils/getTickPosition.js +0 -15
  200. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/Grid.js +0 -79
  201. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridColumns.js +0 -79
  202. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/grids/GridRows.js +0 -79
  203. package/dist/node_modules/.bun/@visx_grid@3.12.0_f4eacebf2041cd4f/node_modules/@visx/grid/esm/utils/getScaleBandwidth.js +0 -6
  204. package/dist/node_modules/.bun/@visx_group@3.12.0_f4eacebf2041cd4f/node_modules/@visx/group/esm/Group.js +0 -50
  205. package/dist/node_modules/.bun/@visx_point@3.12.0/node_modules/@visx/point/esm/Point.js +0 -18
  206. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/coerceNumber.js +0 -10
  207. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/getTicks.js +0 -9
  208. package/dist/node_modules/.bun/@visx_scale@3.12.0/node_modules/@visx/scale/esm/utils/toString.js +0 -6
  209. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/esm/shapes/Line.js +0 -47
  210. package/dist/node_modules/.bun/@visx_shape@3.12.0_f4eacebf2041cd4f/node_modules/@visx/shape/lib/shapes/Line.js +0 -53
  211. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/Text.js +0 -57
  212. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/hooks/useText.js +0 -91
  213. package/dist/node_modules/.bun/@visx_text@3.12.0_f4eacebf2041cd4f/node_modules/@visx/text/esm/util/getStringWidth.js +0 -21
  214. package/dist/node_modules/.bun/balanced-match@0.4.2/node_modules/balanced-match/index.js +0 -32
  215. package/dist/node_modules/.bun/balanced-match@1.0.2/node_modules/balanced-match/index.js +0 -33
  216. package/dist/node_modules/.bun/classnames@2.5.1/node_modules/classnames/index.js +0 -32
  217. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +0 -16
  218. package/dist/node_modules/.bun/invariant@2.2.4/node_modules/invariant/browser.js +0 -28
  219. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Hash.js +0 -21
  220. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_ListCache.js +0 -21
  221. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Map.js +0 -10
  222. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_MapCache.js +0 -21
  223. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_Symbol.js +0 -9
  224. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_assocIndexOf.js +0 -14
  225. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +0 -15
  226. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_baseIsNative.js +0 -16
  227. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_coreJsData.js +0 -9
  228. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +0 -8
  229. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getMapData.js +0 -14
  230. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getNative.js +0 -15
  231. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getRawTag.js +0 -19
  232. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_getValue.js +0 -11
  233. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashClear.js +0 -13
  234. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashDelete.js +0 -12
  235. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashGet.js +0 -18
  236. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashHas.js +0 -14
  237. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_hashSet.js +0 -14
  238. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isKeyable.js +0 -12
  239. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_isMasked.js +0 -16
  240. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheClear.js +0 -11
  241. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheDelete.js +0 -14
  242. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheGet.js +0 -14
  243. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheHas.js +0 -13
  244. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_listCacheSet.js +0 -14
  245. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheClear.js +0 -19
  246. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheDelete.js +0 -14
  247. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheGet.js +0 -13
  248. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheHas.js +0 -13
  249. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_mapCacheSet.js +0 -14
  250. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_nativeCreate.js +0 -9
  251. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_objectToString.js +0 -12
  252. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_root.js +0 -10
  253. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/_toSource.js +0 -20
  254. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/eq.js +0 -11
  255. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isFunction.js +0 -16
  256. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/isObject.js +0 -12
  257. package/dist/node_modules/.bun/lodash@4.18.1/node_modules/lodash/memoize.js +0 -20
  258. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/formula_evaluator.js +0 -37
  259. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/lexer.js +0 -509
  260. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/math_function.js +0 -108
  261. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix.js +0 -31
  262. package/dist/node_modules/.bun/math-expression-evaluator@1.4.0/node_modules/math-expression-evaluator/src/postfix_evaluator.js +0 -45
  263. package/dist/node_modules/.bun/react-redux@9.3.0_9e2203c65d1d5fa1/node_modules/react-redux/dist/react-redux.js +0 -471
  264. package/dist/node_modules/.bun/reduce-css-calc@1.3.0/node_modules/reduce-css-calc/index.js +0 -49
  265. package/dist/node_modules/.bun/reduce-function-call@1.0.3/node_modules/reduce-function-call/index.js +0 -34
  266. package/dist/node_modules/.bun/redux-undo@1.1.0/node_modules/redux-undo/dist/redux-undo.js +0 -185
  267. package/dist/node_modules/.bun/redux@5.0.1/node_modules/redux/dist/redux.js +0 -198
  268. 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
  269. 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
  270. package/dist/node_modules/.bun/use-sync-external-store@1.6.0_f4eacebf2041cd4f/node_modules/use-sync-external-store/with-selector.js +0 -10
  271. package/dist/toggle-bar.d.ts +0 -40
  272. package/dist/tool-menu.d.ts +0 -21
  273. package/dist/tool-menu.js +0 -188
  274. package/dist/tools/index.d.ts +0 -17
  275. package/dist/tools/index.js +0 -12
  276. package/dist/tools/line/component.d.ts +0 -113
  277. package/dist/tools/line/component.js +0 -58
  278. package/dist/tools/line/index.d.ts +0 -13
  279. package/dist/tools/line/index.js +0 -6
  280. package/dist/tools/polygon/component.d.ts +0 -117
  281. package/dist/tools/polygon/component.js +0 -194
  282. package/dist/tools/polygon/index.d.ts +0 -19
  283. package/dist/tools/polygon/index.js +0 -55
  284. package/dist/tools/polygon/line.d.ts +0 -125
  285. package/dist/tools/polygon/polygon.d.ts +0 -122
  286. package/dist/tools/polygon/polygon.js +0 -62
  287. package/dist/tools/shared/arrow-head.d.ts +0 -43
  288. package/dist/tools/shared/arrow-head.js +0 -37
  289. package/dist/tools/shared/line/index.d.ts +0 -240
  290. package/dist/tools/shared/line/index.js +0 -320
  291. package/dist/tools/shared/line/line-path.d.ts +0 -57
  292. package/dist/tools/shared/line/with-root-edge.d.ts +0 -143
  293. package/dist/tools/shared/point/arrow-point.d.ts +0 -57
  294. package/dist/tools/shared/point/arrow-point.js +0 -47
  295. package/dist/tools/shared/point/arrow.d.ts +0 -46
  296. package/dist/tools/shared/point/arrow.js +0 -36
  297. package/dist/tools/shared/point/base-point.d.ts +0 -50
  298. package/dist/tools/shared/point/base-point.js +0 -88
  299. package/dist/tools/shared/point/index.d.ts +0 -217
  300. package/dist/tools/shared/point/index.js +0 -51
  301. package/dist/tools/shared/styles.d.ts +0 -24
  302. package/dist/tools/shared/styles.js +0 -17
  303. package/dist/tools/shared/types.d.ts +0 -15
  304. package/dist/tools/shared/types.js +0 -10
  305. package/dist/undo-redo.d.ts +0 -20
  306. package/dist/undo-redo.js +0 -33
  307. package/dist/use-debounce.d.ts +0 -9
  308. package/dist/use-debounce.js +0 -13
  309. package/dist/utils.d.ts +0 -58
  310. package/dist/utils.js +0 -72
@@ -0,0 +1,471 @@
1
+ import React from 'react';
2
+ import { cloneDeep, isEmpty, isEqual } from 'lodash-es';
3
+ import { BasePoint } from '../point';
4
+ import { gridDraggable, trig, types, utils } from '@pie-lib/plot';
5
+ import PropTypes from 'prop-types';
6
+ import { correct, disabled, incorrect, missing } from '../styles';
7
+ import ReactDOM from 'react-dom';
8
+ import MarkLabel from '../../../mark-label';
9
+ import { color } from '@pie-lib/render-ui';
10
+ import { equalPoints, getMiddleOfTwoPoints, sameAxes } from '../../../utils';
11
+
12
+ export const lineTool = (type, Component) => () => ({
13
+ type,
14
+ Component,
15
+ addPoint: (point, mark) => {
16
+ if (mark && equalPoints(mark.root, point)) {
17
+ return mark;
18
+ }
19
+
20
+ if (!mark) {
21
+ return {
22
+ type,
23
+ building: true,
24
+ from: point,
25
+ };
26
+ }
27
+
28
+ if (equalPoints(point, mark.from)) {
29
+ return { ...mark };
30
+ }
31
+
32
+ return { ...mark, building: false, to: point };
33
+ },
34
+ });
35
+
36
+ export const lineToolComponent = (Component) => {
37
+ return class LineToolComponent extends React.Component {
38
+ static propTypes = {
39
+ ...types.ToolPropTypeFields,
40
+ graphProps: types.GraphPropsType.isRequired,
41
+ };
42
+
43
+ constructor(props) {
44
+ super(props);
45
+ this.state = {};
46
+ }
47
+
48
+ startDrag = () => this.setState({ mark: { ...this.props.mark } });
49
+
50
+ stopDrag = () => {
51
+ const { onChange, mark } = this.props;
52
+ const update = { ...this.state.mark };
53
+
54
+ this.setState({ mark: undefined }, () => {
55
+ const { type } = update;
56
+ let shouldNotChange =
57
+ type &&
58
+ (type === 'parabola' || type === 'sine' || type === 'absolute' || type === 'exponential') &&
59
+ sameAxes(update.from, update.to);
60
+ if (!shouldNotChange && type && type === 'exponential' && update.from && update.to) {
61
+ shouldNotChange = update.from.y === 0 || update.to.y === 0 || update.from.y * update.to.y < 0;
62
+ }
63
+ if (!isEqual(mark, update) && !shouldNotChange) {
64
+ onChange(mark, update);
65
+ }
66
+ });
67
+ };
68
+
69
+ changeMark = ({ from, to, middle }) => {
70
+ let mark = { ...this.state.mark, from, to };
71
+
72
+ if (middle) {
73
+ mark = { ...mark, middle };
74
+ }
75
+
76
+ this.setState({ mark });
77
+ };
78
+
79
+ changeMarkProps = ({ from, to, middle }) => {
80
+ const { onChange, mark } = this.props;
81
+ let update = { ...mark, ...this.state.mark };
82
+
83
+ if (from) {
84
+ update = { ...update, from };
85
+ }
86
+
87
+ if (to) {
88
+ update = { ...update, to };
89
+ }
90
+
91
+ if (middle) {
92
+ update = { ...update, middle };
93
+ }
94
+
95
+ if (!isEqual(mark, update)) {
96
+ onChange(mark, update);
97
+ }
98
+ };
99
+
100
+ render() {
101
+ const { graphProps, onClick, labelNode, labelModeEnabled, coordinatesOnHover, gssLineData } = this.props;
102
+ const mark = this.state.mark ? this.state.mark : this.props.mark;
103
+
104
+ const from = cloneDeep(mark.from);
105
+ const to = cloneDeep(mark.to);
106
+ const middle = cloneDeep(mark.middle);
107
+
108
+ // SET DISABLED
109
+ // if it's a background mark, we need to force disable it
110
+ if (from && mark.isBackground) {
111
+ from.disabled = true;
112
+ }
113
+
114
+ if (to && mark.isBackground) {
115
+ to.disabled = true;
116
+ }
117
+
118
+ if (middle && mark.isBackground) {
119
+ middle.disabled = true;
120
+ }
121
+
122
+ return (
123
+ <Component
124
+ disabled={mark.disabled}
125
+ coordinatesOnHover={coordinatesOnHover}
126
+ correctness={mark.correctness}
127
+ from={from}
128
+ to={to}
129
+ middle={middle}
130
+ graphProps={graphProps}
131
+ fill={mark && mark.fill}
132
+ gssLineData={gssLineData}
133
+ onChange={this.changeMark}
134
+ changeMarkProps={this.changeMarkProps}
135
+ onClick={onClick}
136
+ onDragStart={this.startDrag}
137
+ onDragStop={this.stopDrag}
138
+ labelNode={labelNode}
139
+ labelModeEnabled={labelModeEnabled}
140
+ />
141
+ );
142
+ }
143
+ };
144
+ };
145
+
146
+ const dragOpts = () => ({
147
+ bounds: (props, { domain, range }) => {
148
+ const area = utils.lineToArea(props.from, props.to);
149
+ return utils.bounds(area, domain, range);
150
+ },
151
+ anchorPoint: (props) => {
152
+ const { from } = props;
153
+ return from;
154
+ },
155
+ fromDelta: (props, delta) => {
156
+ const { from, to } = props;
157
+ return {
158
+ from: utils.point(from).add(utils.point(delta)),
159
+ to: utils.point(to).add(utils.point(delta)),
160
+ };
161
+ },
162
+ });
163
+
164
+ export const lineBase = (Comp, opts) => {
165
+ const DraggableComp = gridDraggable(dragOpts())(Comp);
166
+
167
+ const FromPoint = opts && opts.from ? opts.from : BasePoint;
168
+ const ToPoint = opts && opts.to ? opts.to : BasePoint;
169
+
170
+ class LineBase extends React.Component {
171
+ static propTypes = {
172
+ coordinatesOnHover: PropTypes.bool,
173
+ graphProps: types.GraphPropsType,
174
+ from: types.PointType,
175
+ to: types.PointType,
176
+ middle: types.PointType,
177
+ onChange: PropTypes.func,
178
+ onDragStart: PropTypes.func,
179
+ onDragStop: PropTypes.func,
180
+ onClick: PropTypes.func,
181
+ correctness: PropTypes.string,
182
+ fill: PropTypes.string,
183
+ gssLineData: PropTypes.object,
184
+ disabled: PropTypes.bool,
185
+ labelNode: PropTypes.object,
186
+ labelModeEnabled: PropTypes.bool,
187
+ changeMarkProps: PropTypes.func,
188
+ };
189
+
190
+ onChangePoint = (point) => {
191
+ const { middle, onChange } = this.props;
192
+ const { from, to } = point;
193
+
194
+ // because point.from.label and point.to.label can be different
195
+ if (!equalPoints(from, to)) {
196
+ if (middle) {
197
+ point.middle = { ...middle, ...getMiddleOfTwoPoints(from, to) };
198
+ }
199
+
200
+ onChange(point);
201
+ }
202
+ };
203
+
204
+ dragComp = ({ from: draggedFrom, to: draggedTo }) => {
205
+ const { from, to, onChange, middle } = this.props;
206
+
207
+ if (from.label) {
208
+ draggedFrom.label = from.label;
209
+ }
210
+
211
+ if (to.label) {
212
+ draggedTo.label = to.label;
213
+ }
214
+
215
+ const updated = { from: draggedFrom, to: draggedTo };
216
+
217
+ if (middle) {
218
+ updated.middle = { ...middle, ...getMiddleOfTwoPoints(draggedFrom, draggedTo) };
219
+ }
220
+
221
+ onChange(updated);
222
+ };
223
+
224
+ dragFrom = (draggedFrom) => {
225
+ const { from, to } = this.props;
226
+
227
+ if (from.label) {
228
+ draggedFrom.label = from.label;
229
+ }
230
+
231
+ if (!equalPoints(draggedFrom, to)) {
232
+ this.onChangePoint({ from: draggedFrom, to: to });
233
+ }
234
+ };
235
+
236
+ dragTo = (draggedTo) => {
237
+ const { from, to } = this.props;
238
+
239
+ if (to.label) {
240
+ draggedTo.label = to.label;
241
+ }
242
+
243
+ if (!equalPoints(from, draggedTo)) {
244
+ this.onChangePoint({ from: from, to: draggedTo });
245
+ }
246
+ };
247
+
248
+ labelChange = (point, type) => {
249
+ const { changeMarkProps } = this.props;
250
+ const update = { ...point };
251
+
252
+ if (!point.label || isEmpty(point.label)) {
253
+ delete update.label;
254
+ }
255
+
256
+ changeMarkProps({ [type]: update });
257
+ };
258
+
259
+ clickPoint = (point, type, data) => {
260
+ const { changeMarkProps, disabled, from, to, labelModeEnabled, onClick } = this.props;
261
+
262
+ if (!labelModeEnabled) {
263
+ onClick(point || data);
264
+ return;
265
+ }
266
+
267
+ if (disabled) {
268
+ return;
269
+ }
270
+
271
+ if (type === 'middle' && !point && from && to) {
272
+ point = { ...point, ...getMiddleOfTwoPoints(from, to) };
273
+ }
274
+
275
+ changeMarkProps({ from, to, [type]: { label: '', ...point } });
276
+
277
+ if (this.input[type]) {
278
+ this.input[type].focus();
279
+ }
280
+ };
281
+
282
+ // IMPORTANT, do not remove
283
+ input = {};
284
+
285
+ render() {
286
+ const {
287
+ coordinatesOnHover,
288
+ graphProps,
289
+ fill,
290
+ gssLineData,
291
+ onDragStart,
292
+ onDragStop,
293
+ from,
294
+ to,
295
+ middle,
296
+ disabled,
297
+ correctness,
298
+ onClick,
299
+ labelNode,
300
+ labelModeEnabled,
301
+ } = this.props;
302
+ let common = { graphProps, fill, onDragStart, onDragStop, disabled, correctness, onClick };
303
+ if (gssLineData && gssLineData.selectedTool === 'solutionSet') {
304
+ //removing dragging option for line if solution set is clicked.
305
+ common = { graphProps, fill, disabled, correctness, onClick };
306
+ }
307
+ const angle = to ? trig.toDegrees(trig.angle(from, to)) : 0;
308
+
309
+ let fromLabelNode = null;
310
+ let toLabelNode = null;
311
+ let lineLabelNode = null;
312
+
313
+ if (labelNode) {
314
+ if (from && Object.prototype.hasOwnProperty.call(from, 'label')) {
315
+ fromLabelNode = ReactDOM.createPortal(
316
+ <MarkLabel
317
+ inputRef={(r) => (this.input.from = r)}
318
+ disabled={!labelModeEnabled}
319
+ mark={from}
320
+ graphProps={graphProps}
321
+ onChange={(label) => this.labelChange({ ...from, label }, 'from')}
322
+ />,
323
+ labelNode,
324
+ );
325
+ }
326
+
327
+ if (to && Object.prototype.hasOwnProperty.call(to, 'label')) {
328
+ toLabelNode = ReactDOM.createPortal(
329
+ <MarkLabel
330
+ inputRef={(r) => (this.input.to = r)}
331
+ disabled={!labelModeEnabled}
332
+ mark={to}
333
+ graphProps={graphProps}
334
+ onChange={(label) => this.labelChange({ ...to, label }, 'to')}
335
+ />,
336
+ labelNode,
337
+ );
338
+ }
339
+
340
+ if (middle && Object.prototype.hasOwnProperty.call(middle, 'label')) {
341
+ lineLabelNode = ReactDOM.createPortal(
342
+ <MarkLabel
343
+ inputRef={(r) => (this.input.middle = r)}
344
+ disabled={!labelModeEnabled}
345
+ mark={middle}
346
+ graphProps={graphProps}
347
+ onChange={(label) => this.labelChange({ ...middle, label }, 'middle')}
348
+ />,
349
+ labelNode,
350
+ );
351
+ }
352
+ }
353
+ if (gssLineData && gssLineData.selectedTool === 'solutionSet') {
354
+ //removing dragging feature of line and point if solution set is true.
355
+ return (
356
+ <g>
357
+ {to && <DraggableComp from={from} to={to} middle={middle} {...common} />}
358
+ {lineLabelNode}
359
+
360
+ <FromPoint
361
+ x={from.x}
362
+ y={from.y}
363
+ labelNode={labelNode}
364
+ coordinatesOnHover={coordinatesOnHover}
365
+ {...common}
366
+ />
367
+ {fromLabelNode}
368
+
369
+ {to && (
370
+ <ToPoint
371
+ x={to.x}
372
+ y={to.y}
373
+ angle={angle} //angle + 45}
374
+ labelNode={labelNode}
375
+ coordinatesOnHover={coordinatesOnHover}
376
+ {...common}
377
+ />
378
+ )}
379
+ {toLabelNode}
380
+ </g>
381
+ );
382
+ } else {
383
+ return (
384
+ <g>
385
+ {to && (
386
+ <DraggableComp
387
+ from={from}
388
+ to={to}
389
+ middle={middle}
390
+ onDrag={this.dragComp}
391
+ {...common}
392
+ onClick={(data) => this.clickPoint(middle, 'middle', data)}
393
+ />
394
+ )}
395
+ {lineLabelNode}
396
+
397
+ <FromPoint
398
+ x={from.x}
399
+ y={from.y}
400
+ labelNode={labelNode}
401
+ coordinatesOnHover={coordinatesOnHover}
402
+ onDrag={this.dragFrom}
403
+ {...common}
404
+ onClick={(data) => this.clickPoint(from, 'from', data)}
405
+ />
406
+ {fromLabelNode}
407
+
408
+ {to && (
409
+ <ToPoint
410
+ x={to.x}
411
+ y={to.y}
412
+ angle={angle} //angle + 45}
413
+ labelNode={labelNode}
414
+ coordinatesOnHover={coordinatesOnHover}
415
+ onDrag={this.dragTo}
416
+ {...common}
417
+ onClick={(data) => this.clickPoint(to, 'to', data)}
418
+ />
419
+ )}
420
+ {toLabelNode}
421
+ </g>
422
+ );
423
+ }
424
+ }
425
+ }
426
+
427
+ return LineBase;
428
+ };
429
+
430
+ export const styles = {
431
+ line: () => ({
432
+ fill: 'transparent',
433
+ stroke: color.defaults.BLACK,
434
+ strokeWidth: 4,
435
+ transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
436
+ '&:hover': {
437
+ strokeWidth: 6,
438
+ stroke: color.defaults.BLACK,
439
+ },
440
+ }),
441
+ dashedLine: () => ({
442
+ fill: 'transparent',
443
+ stroke: color.defaults.BLACK,
444
+ strokeWidth: 4,
445
+ transition: 'stroke 200ms ease-in, stroke-width 200ms ease-in',
446
+ '&:hover': {
447
+ strokeWidth: 6,
448
+ stroke: color.defaults.BLACK,
449
+ },
450
+ strokeDasharray: '3,3',
451
+ }),
452
+ arrow: () => ({
453
+ fill: color.defaults.SECONDARY,
454
+ }),
455
+ disabledArrow: () => ({
456
+ ...disabled(),
457
+ }),
458
+ disabled: () => ({
459
+ ...disabled('stroke'),
460
+ strokeWidth: 2,
461
+ }),
462
+ correct: (theme, key) => ({
463
+ ...correct(key),
464
+ }),
465
+ incorrect: (theme, key) => ({
466
+ ...incorrect(key),
467
+ }),
468
+ missing: (theme, key) => ({
469
+ ...missing(key),
470
+ }),
471
+ };
@@ -0,0 +1,85 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { styled } from '@mui/material/styles';
4
+ import { types } from '@pie-lib/plot';
5
+ import { correct, disabled, incorrect, missing } from '../styles';
6
+ import * as vx from '@visx/shape';
7
+ import { color } from '@pie-lib/render-ui';
8
+
9
+ const dragging = () => ({
10
+ strokeWidth: 7,
11
+ stroke: color.defaults.BLACK,
12
+ });
13
+
14
+ const StyledDrawLine = styled(vx.LinePath, {
15
+ shouldForwardProp: (prop) => !['disabled', 'correctness'].includes(prop),
16
+ })(({ disabled: isDisabled, correctness }) => ({
17
+ fill: 'none',
18
+ strokeWidth: 2,
19
+ stroke: color.secondaryLight(),
20
+ ...(isDisabled && {
21
+ ...disabled('stroke'),
22
+ strokeWidth: 2,
23
+ }),
24
+ ...(correctness === 'correct' && correct('stroke')),
25
+ ...(correctness === 'incorrect' && incorrect('stroke')),
26
+ ...(correctness === 'missing' && missing('stroke')),
27
+ }));
28
+
29
+ const StyledInteractionLine = styled(vx.LinePath, {
30
+ shouldForwardProp: (prop) => !['disabled', 'correctness', 'isDragging'].includes(prop),
31
+ })(({ disabled: isDisabled, correctness, isDragging }) => ({
32
+ strokeWidth: 6,
33
+ fill: 'none',
34
+ transition: 'stroke-width 200ms ease-in, stroke 200ms ease-in',
35
+ stroke: 'transparent',
36
+ '&:hover': dragging(),
37
+ ...(isDragging && dragging()),
38
+ ...(isDisabled && {
39
+ ...disabled('stroke'),
40
+ strokeWidth: 2,
41
+ }),
42
+ ...(correctness === 'correct' && correct('stroke')),
43
+ ...(correctness === 'incorrect' && incorrect('stroke')),
44
+ ...(correctness === 'missing' && missing('stroke')),
45
+ }));
46
+
47
+ export class RawLinePath extends React.Component {
48
+ static propTypes = {
49
+ className: PropTypes.string,
50
+ data: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.number)),
51
+ graphProps: types.GraphPropsType.isRequired,
52
+ disabled: PropTypes.bool,
53
+ correctness: PropTypes.string,
54
+ from: types.PointType,
55
+ to: types.PointType,
56
+ isDragging: PropTypes.bool,
57
+ };
58
+
59
+ static defaultProps = {
60
+ from: {},
61
+ to: {},
62
+ };
63
+
64
+ render() {
65
+ /* eslint-disable no-unused-vars */
66
+ const { data, className, disabled, correctness, from, to, graphProps, isDragging, ...rest } = this.props;
67
+ /* eslint-enable */
68
+
69
+ return (
70
+ <React.Fragment>
71
+ <StyledDrawLine data={data} disabled={disabled} correctness={correctness} className={className} {...rest} />
72
+ <StyledInteractionLine
73
+ data={data}
74
+ isDragging={isDragging}
75
+ disabled={disabled}
76
+ correctness={correctness}
77
+ className={className}
78
+ {...rest}
79
+ />
80
+ </React.Fragment>
81
+ );
82
+ }
83
+ }
84
+
85
+ export const LinePath = RawLinePath;
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { types } from '@pie-lib/plot';
4
+ import { LinePath } from './line-path';
5
+ import { curveMonotoneX } from '@visx/curve';
6
+ import { lineBase, lineToolComponent } from './index';
7
+
8
+ const toRootEdge = (m) => {
9
+ const out = { ...m };
10
+ out.root = { ...m.from };
11
+ out.edge = m.to ? { ...m.to } : undefined;
12
+ delete out.from;
13
+ delete out.to;
14
+ return out;
15
+ };
16
+
17
+ const toFromTo = (m) => {
18
+ const out = { ...m };
19
+ out.from = { ...m.root };
20
+ out.to = m.edge ? { ...m.edge } : undefined;
21
+ delete out.root;
22
+ delete out.edge;
23
+ return out;
24
+ };
25
+
26
+ export const rootEdgeToFromToWrapper = (BaseComp) => {
27
+ const Wrapper = (props) => {
28
+ const m = toFromTo(props.mark);
29
+
30
+ const onChange = (current, next) => {
31
+ props.onChange(toRootEdge(current), toRootEdge(next));
32
+ };
33
+
34
+ return <BaseComp {...props} mark={m} onChange={onChange} />;
35
+ };
36
+
37
+ Wrapper.propTypes = {
38
+ onChange: PropTypes.func,
39
+ mark: PropTypes.object,
40
+ };
41
+
42
+ return Wrapper;
43
+ };
44
+
45
+ export const rootEdgeComponent = (RootEdgeComp) => {
46
+ const BaseComponent = lineToolComponent(RootEdgeComp);
47
+ return rootEdgeToFromToWrapper(BaseComponent);
48
+ };
49
+
50
+ const withPointsGenerationLinePath = (getPoints) => {
51
+ const LinePathComponent = (props) => {
52
+ const { graphProps, from, to, onClick, onDragStart, onDragStop, onChange, disabled, correctness, ...rest } = props;
53
+
54
+ const { dataPoints, enableCurve = true } = getPoints({
55
+ graphProps: props.graphProps,
56
+ root: from,
57
+ edge: to,
58
+ });
59
+
60
+ const raw = dataPoints.map((d) => [graphProps.scale.x(d.x), graphProps.scale.y(d.y)]);
61
+
62
+ const common = {
63
+ onClick,
64
+ graphProps,
65
+ onDragStart,
66
+ onDragStop,
67
+ onChange,
68
+ disabled,
69
+ correctness,
70
+ };
71
+
72
+ if (!enableCurve) {
73
+ return <LinePath data={raw} from={from} to={to} {...common} {...rest} />;
74
+ } else {
75
+ return <LinePath data={raw} from={from} to={to} curve={curveMonotoneX} {...common} {...rest} />;
76
+ }
77
+ };
78
+
79
+ LinePathComponent.propTypes = {
80
+ graphProps: types.GraphPropsType.isRequired,
81
+ from: types.PointType.isRequired,
82
+ to: types.PointType,
83
+ onClick: PropTypes.func,
84
+ onDragStart: PropTypes.func,
85
+ onDragStop: PropTypes.func,
86
+ onChange: PropTypes.func,
87
+ disabled: PropTypes.bool,
88
+ correctness: PropTypes.string,
89
+ };
90
+
91
+ return LinePathComponent;
92
+ };
93
+
94
+ export const withRootEdge = (getPoints) => {
95
+ const LinePathComp = withPointsGenerationLinePath(getPoints);
96
+ return lineBase(LinePathComp);
97
+ };